Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 15 | using namespace std; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 16 | using namespace ndn; |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 17 | using namespace ndn::ptr_lib; |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 18 | |
| 19 | InvitationDialog::InvitationDialog(QWidget *parent) : |
| 20 | QDialog(parent), |
| 21 | ui(new Ui::InvitationDialog) |
| 22 | { |
| 23 | ui->setupUi(this); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 24 | |
| 25 | connect(ui->okButton, SIGNAL(clicked()), |
| 26 | this, SLOT(onOkClicked())); |
| 27 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 28 | this, SLOT(onCancelClicked())); |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | InvitationDialog::~InvitationDialog() |
| 32 | { |
| 33 | delete ui; |
| 34 | } |
| 35 | |
| 36 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 37 | InvitationDialog::setInvitation(const string& alias, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 38 | shared_ptr<ChronosInvitation> invitation, |
| 39 | shared_ptr<IdentityCertificate> identityCertificate) |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 40 | { |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 41 | m_inviterAlias = alias; |
| 42 | string msg = alias; |
Yingdi Yu | 0aca265 | 2013-11-10 10:47:44 -0800 | [diff] [blame] | 43 | msg.append("\ninvites you to join the chat room: "); |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 44 | ui->msgLabel->setText(QString::fromStdString(msg)); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 45 | |
| 46 | m_invitation = invitation; |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 47 | ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toEscapedString())); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 48 | |
| 49 | m_identityCertificate = identityCertificate; |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | void |
| 53 | InvitationDialog::onOkClicked() |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 54 | { |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 55 | emit invitationAccepted(*m_invitation, *m_identityCertificate); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 56 | this->close(); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 57 | } |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | InvitationDialog::onCancelClicked() |
| 61 | { |
| 62 | ui->msgLabel->clear(); |
| 63 | ui->chatroomLine->clear(); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 64 | |
Yingdi Yu | e9195fd | 2013-11-08 14:13:42 -0800 | [diff] [blame] | 65 | emit invitationRejected(*m_invitation); |
| 66 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 67 | m_invitation = make_shared<ChronosInvitation>(); |
| 68 | m_identityCertificate = make_shared<IdentityCertificate>(); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 69 | m_inviterAlias.clear(); |
| 70 | |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 71 | this->close(); |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | #if WAF |
| 75 | #include "invitationdialog.moc" |
| 76 | #include "invitationdialog.cpp.moc" |
| 77 | #endif |