Yingdi Yu | daceb8a | 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 | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 16 | using namespace ndn; |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 17 | |
| 18 | InvitationDialog::InvitationDialog(QWidget *parent) : |
| 19 | QDialog(parent), |
| 20 | ui(new Ui::InvitationDialog) |
| 21 | { |
| 22 | ui->setupUi(this); |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 23 | |
| 24 | connect(ui->okButton, SIGNAL(clicked()), |
| 25 | this, SLOT(onOkClicked())); |
| 26 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 27 | this, SLOT(onCancelClicked())); |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | InvitationDialog::~InvitationDialog() |
| 31 | { |
| 32 | delete ui; |
| 33 | } |
| 34 | |
| 35 | void |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 36 | InvitationDialog::setInvitation(const string& alias, |
| 37 | Ptr<ChronosInvitation> invitation, |
| 38 | Ptr<security::IdentityCertificate> identityCertificate) |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 39 | { |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 40 | m_inviterAlias = alias; |
| 41 | string msg = alias; |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 42 | msg.append(" invites you to join the chat room: "); |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 43 | ui->msgLabel->setText(QString::fromUtf8(msg.c_str())); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 44 | |
| 45 | m_invitation = invitation; |
| 46 | ui->chatroomLine->setText(QString::fromUtf8(invitation->getChatroom().get(0).toUri().c_str())); |
| 47 | |
| 48 | m_identityCertificate = identityCertificate; |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void |
| 52 | InvitationDialog::onOkClicked() |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 53 | { |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 54 | emit invitationAccepted(*m_invitation, *m_identityCertificate); |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 55 | this->close(); |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 56 | } |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 57 | |
| 58 | void |
| 59 | InvitationDialog::onCancelClicked() |
| 60 | { |
| 61 | ui->msgLabel->clear(); |
| 62 | ui->chatroomLine->clear(); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 63 | |
| 64 | m_invitation = NULL; |
| 65 | m_identityCertificate = NULL; |
| 66 | m_inviterAlias.clear(); |
| 67 | |
| 68 | emit invitationRejected(*m_invitation); |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 69 | this->close(); |
Yingdi Yu | daceb8a | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | #if WAF |
| 73 | #include "invitationdialog.moc" |
| 74 | #include "invitationdialog.cpp.moc" |
| 75 | #endif |