blob: 4129ba033f059775e67061ce3085521d8dda5884 [file] [log] [blame]
Yingdi Yudaceb8a2013-10-22 23:42:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
11
12#include "invitationdialog.h"
13#include "ui_invitationdialog.h"
14
15using namespace std;
Yingdi Yu53eb8a72013-10-23 11:50:51 -070016using namespace ndn;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070017
18InvitationDialog::InvitationDialog(QWidget *parent) :
19 QDialog(parent),
20 ui(new Ui::InvitationDialog)
21{
22 ui->setupUi(this);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070023
24 connect(ui->okButton, SIGNAL(clicked()),
25 this, SLOT(onOkClicked()));
26 connect(ui->cancelButton, SIGNAL(clicked()),
27 this, SLOT(onCancelClicked()));
Yingdi Yudaceb8a2013-10-22 23:42:16 -070028}
29
30InvitationDialog::~InvitationDialog()
31{
32 delete ui;
33}
34
35void
Yingdi Yu42f66462013-10-31 17:38:22 -070036InvitationDialog::setInvitation(const string& alias,
37 Ptr<ChronosInvitation> invitation,
38 Ptr<security::IdentityCertificate> identityCertificate)
Yingdi Yudaceb8a2013-10-22 23:42:16 -070039{
Yingdi Yu42f66462013-10-31 17:38:22 -070040 m_inviterAlias = alias;
41 string msg = alias;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070042 msg.append(" invites you to join the chat room: ");
Yingdi Yub35b8652013-11-07 11:32:40 -080043 ui->msgLabel->setText(QString::fromStdString(msg));
Yingdi Yu42f66462013-10-31 17:38:22 -070044
45 m_invitation = invitation;
Yingdi Yub35b8652013-11-07 11:32:40 -080046 ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toUri()));
Yingdi Yu42f66462013-10-31 17:38:22 -070047
48 m_identityCertificate = identityCertificate;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070049}
50
51void
52InvitationDialog::onOkClicked()
Yingdi Yu53eb8a72013-10-23 11:50:51 -070053{
Yingdi Yu42f66462013-10-31 17:38:22 -070054 emit invitationAccepted(*m_invitation, *m_identityCertificate);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070055 this->close();
Yingdi Yu53eb8a72013-10-23 11:50:51 -070056}
Yingdi Yudaceb8a2013-10-22 23:42:16 -070057
58void
59InvitationDialog::onCancelClicked()
60{
61 ui->msgLabel->clear();
62 ui->chatroomLine->clear();
Yingdi Yu42f66462013-10-31 17:38:22 -070063
Yingdi Yu97936352013-11-08 14:13:42 -080064 emit invitationRejected(*m_invitation);
65
Yingdi Yu42f66462013-10-31 17:38:22 -070066 m_invitation = NULL;
67 m_identityCertificate = NULL;
68 m_inviterAlias.clear();
69
Yingdi Yuc4d08d22013-10-23 23:07:29 -070070 this->close();
Yingdi Yudaceb8a2013-10-22 23:42:16 -070071}
72
73#if WAF
74#include "invitationdialog.moc"
75#include "invitationdialog.cpp.moc"
76#endif