blob: 9194bcce64fcc3f4f401a4bbdfeecce0349dc7e0 [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
Yingdi Yu42f66462013-10-31 17:38:22 -070036InvitationDialog::setInvitation(const string& alias,
37 Ptr<ChronosInvitation> invitation,
38 Ptr<security::IdentityCertificate> identityCertificate)
Yingdi Yudaceb8a2013-10-22 23:42:16 -070039{
Yingdi Yu42f66462013-10-31 17:38:22 -070040 m_inviterAlias = alias;
41 string msg = alias;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070042 msg.append(" invites you to join the chat room: ");
Yingdi Yudaceb8a2013-10-22 23:42:16 -070043 ui->msgLabel->setText(QString::fromUtf8(msg.c_str()));
Yingdi Yu42f66462013-10-31 17:38:22 -070044
45 m_invitation = invitation;
46 ui->chatroomLine->setText(QString::fromUtf8(invitation->getChatroom().get(0).toUri().c_str()));
47
48 m_identityCertificate = identityCertificate;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070049}
50
51void
52InvitationDialog::onOkClicked()
Yingdi Yu53eb8a72013-10-23 11:50:51 -070053{
Yingdi Yu42f66462013-10-31 17:38:22 -070054 emit invitationAccepted(*m_invitation, *m_identityCertificate);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070055 this->close();
Yingdi Yu53eb8a72013-10-23 11:50:51 -070056}
Yingdi Yudaceb8a2013-10-22 23:42:16 -070057
58void
59InvitationDialog::onCancelClicked()
60{
61 ui->msgLabel->clear();
62 ui->chatroomLine->clear();
Yingdi Yu42f66462013-10-31 17:38:22 -070063
64 m_invitation = NULL;
65 m_identityCertificate = NULL;
66 m_inviterAlias.clear();
67
68 emit invitationRejected(*m_invitation);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070069 this->close();
Yingdi Yudaceb8a2013-10-22 23:42:16 -070070}
71
72#if WAF
73#include "invitationdialog.moc"
74#include "invitationdialog.cpp.moc"
75#endif