blob: c00727d47cf91498ac11025b96f1e2caa7bcceb2 [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
36InvitationDialog::setMsg(const string& inviter, const string& chatroom)
37{
Yingdi Yu53eb8a72013-10-23 11:50:51 -070038 m_inviter = inviter;
39 m_chatroom = chatroom;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070040 string msg = inviter;
41 msg.append(" invites you to join the chat room: ");
42
43 ui->msgLabel->setText(QString::fromUtf8(msg.c_str()));
Yingdi Yuc4d08d22013-10-23 23:07:29 -070044 ui->chatroomLine->setText(QString::fromUtf8(chatroom.c_str()));
Yingdi Yudaceb8a2013-10-22 23:42:16 -070045}
46
47void
48InvitationDialog::onOkClicked()
Yingdi Yu53eb8a72013-10-23 11:50:51 -070049{
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 Yuc4d08d22013-10-23 23:07:29 -070053 this->close();
Yingdi Yu53eb8a72013-10-23 11:50:51 -070054}
Yingdi Yudaceb8a2013-10-22 23:42:16 -070055
56void
57InvitationDialog::onCancelClicked()
58{
59 ui->msgLabel->clear();
60 ui->chatroomLine->clear();
61 m_interestName = Name();
Yingdi Yu53eb8a72013-10-23 11:50:51 -070062 m_inviter.clear();
63 m_chatroom.clear();
Yingdi Yudaceb8a2013-10-22 23:42:16 -070064 emit invitationRejected(m_interestName);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070065 this->close();
Yingdi Yudaceb8a2013-10-22 23:42:16 -070066}
67
68#if WAF
69#include "invitationdialog.moc"
70#include "invitationdialog.cpp.moc"
71#endif