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 | 24ca96f | 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 | eda39aa | 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 | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | InvitationDialog::~InvitationDialog() |
| 31 | { |
| 32 | delete ui; |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | InvitationDialog::setMsg(const string& inviter, const string& chatroom) |
| 37 | { |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 38 | m_inviter = inviter; |
| 39 | m_chatroom = chatroom; |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 40 | string msg = inviter; |
| 41 | msg.append(" invites you to join the chat room: "); |
| 42 | |
| 43 | ui->msgLabel->setText(QString::fromUtf8(msg.c_str())); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame^] | 44 | ui->chatroomLine->setText(QString::fromUtf8(chatroom.c_str())); |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void |
| 48 | InvitationDialog::onOkClicked() |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 49 | { |
| 50 | QString inviter = QString::fromUtf8(m_inviter.c_str()); |
| 51 | QString chatroom = QString::fromUtf8(m_chatroom.c_str()); |
| 52 | emit invitationAccepted(m_interestName, *m_identityCertificate, inviter, chatroom); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame^] | 53 | this->close(); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 54 | } |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 55 | |
| 56 | void |
| 57 | InvitationDialog::onCancelClicked() |
| 58 | { |
| 59 | ui->msgLabel->clear(); |
| 60 | ui->chatroomLine->clear(); |
| 61 | m_interestName = Name(); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 62 | m_inviter.clear(); |
| 63 | m_chatroom.clear(); |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 64 | emit invitationRejected(m_interestName); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame^] | 65 | this->close(); |
Yingdi Yu | 24ca96f | 2013-10-22 23:42:16 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | #if WAF |
| 69 | #include "invitationdialog.moc" |
| 70 | #include "invitationdialog.cpp.moc" |
| 71 | #endif |