blob: c142014410929b32d2a8dc9cc30b8addaa62d313 [file] [log] [blame]
Yingdi Yu24ca96f2013-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 Yu978b3ae2013-10-23 11:50:51 -070016using namespace ndn;
Yingdi Yu76dd8002013-12-24 11:16:32 +080017using namespace ndn::ptr_lib;
Yingdi Yu24ca96f2013-10-22 23:42:16 -070018
19InvitationDialog::InvitationDialog(QWidget *parent) :
20 QDialog(parent),
21 ui(new Ui::InvitationDialog)
22{
23 ui->setupUi(this);
Yingdi Yueda39aa2013-10-23 23:07:29 -070024
25 connect(ui->okButton, SIGNAL(clicked()),
26 this, SLOT(onOkClicked()));
27 connect(ui->cancelButton, SIGNAL(clicked()),
28 this, SLOT(onCancelClicked()));
Yingdi Yu24ca96f2013-10-22 23:42:16 -070029}
30
31InvitationDialog::~InvitationDialog()
32{
33 delete ui;
34}
35
36void
Yingdi Yu7989eb22013-10-31 17:38:22 -070037InvitationDialog::setInvitation(const string& alias,
Yingdi Yu76dd8002013-12-24 11:16:32 +080038 shared_ptr<ChronosInvitation> invitation,
39 shared_ptr<IdentityCertificate> identityCertificate)
Yingdi Yu24ca96f2013-10-22 23:42:16 -070040{
Yingdi Yu7989eb22013-10-31 17:38:22 -070041 m_inviterAlias = alias;
42 string msg = alias;
Yingdi Yu0aca2652013-11-10 10:47:44 -080043 msg.append("\ninvites you to join the chat room: ");
Yingdi Yue35bdb82013-11-07 11:32:40 -080044 ui->msgLabel->setText(QString::fromStdString(msg));
Yingdi Yu7989eb22013-10-31 17:38:22 -070045
46 m_invitation = invitation;
Yingdi Yu76dd8002013-12-24 11:16:32 +080047 ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toEscapedString()));
Yingdi Yu7989eb22013-10-31 17:38:22 -070048
49 m_identityCertificate = identityCertificate;
Yingdi Yu24ca96f2013-10-22 23:42:16 -070050}
51
52void
53InvitationDialog::onOkClicked()
Yingdi Yu978b3ae2013-10-23 11:50:51 -070054{
Yingdi Yu7989eb22013-10-31 17:38:22 -070055 emit invitationAccepted(*m_invitation, *m_identityCertificate);
Yingdi Yueda39aa2013-10-23 23:07:29 -070056 this->close();
Yingdi Yu978b3ae2013-10-23 11:50:51 -070057}
Yingdi Yu24ca96f2013-10-22 23:42:16 -070058
59void
60InvitationDialog::onCancelClicked()
61{
62 ui->msgLabel->clear();
63 ui->chatroomLine->clear();
Yingdi Yu7989eb22013-10-31 17:38:22 -070064
Yingdi Yue9195fd2013-11-08 14:13:42 -080065 emit invitationRejected(*m_invitation);
66
Yingdi Yu76dd8002013-12-24 11:16:32 +080067 m_invitation = make_shared<ChronosInvitation>();
68 m_identityCertificate = make_shared<IdentityCertificate>();
Yingdi Yu7989eb22013-10-31 17:38:22 -070069 m_inviterAlias.clear();
70
Yingdi Yueda39aa2013-10-23 23:07:29 -070071 this->close();
Yingdi Yu24ca96f2013-10-22 23:42:16 -070072}
73
74#if WAF
75#include "invitationdialog.moc"
76#include "invitationdialog.cpp.moc"
77#endif