blob: 2a1d21fba45c906a7ecd646852343bcf3d418284 [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 Yua1a688f2014-02-06 18:09:22 -080017using namespace chronos;
Yingdi Yudaceb8a2013-10-22 23:42:16 -070018
19InvitationDialog::InvitationDialog(QWidget *parent) :
20 QDialog(parent),
21 ui(new Ui::InvitationDialog)
22{
23 ui->setupUi(this);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070024
25 connect(ui->okButton, SIGNAL(clicked()),
26 this, SLOT(onOkClicked()));
27 connect(ui->cancelButton, SIGNAL(clicked()),
28 this, SLOT(onCancelClicked()));
Yingdi Yudaceb8a2013-10-22 23:42:16 -070029}
30
31InvitationDialog::~InvitationDialog()
32{
33 delete ui;
34}
35
36void
Yingdi Yu42f66462013-10-31 17:38:22 -070037InvitationDialog::setInvitation(const string& alias,
Yingdi Yua1a688f2014-02-06 18:09:22 -080038 const Name& interestName)
Yingdi Yudaceb8a2013-10-22 23:42:16 -070039{
Yingdi Yu42f66462013-10-31 17:38:22 -070040 m_inviterAlias = alias;
41 string msg = alias;
Yingdi Yu3e87bd82013-11-10 10:47:44 -080042 msg.append("\ninvites you to join the chat room: ");
Yingdi Yub35b8652013-11-07 11:32:40 -080043 ui->msgLabel->setText(QString::fromStdString(msg));
Yingdi Yu42f66462013-10-31 17:38:22 -070044
Yingdi Yua1a688f2014-02-06 18:09:22 -080045 m_invitationInterest = interestName;
46 Invitation invitation(interestName);
47 ui->chatroomLine->setText(QString::fromStdString(invitation.getChatroom().get(0).toEscapedString()));
Yingdi Yudaceb8a2013-10-22 23:42:16 -070048}
49
50void
51InvitationDialog::onOkClicked()
Yingdi Yu53eb8a72013-10-23 11:50:51 -070052{
Yingdi Yua1a688f2014-02-06 18:09:22 -080053 emit invitationAccepted(m_invitationInterest);
Yingdi Yuc4d08d22013-10-23 23:07:29 -070054 this->close();
Yingdi Yu53eb8a72013-10-23 11:50:51 -070055}
Yingdi Yudaceb8a2013-10-22 23:42:16 -070056
57void
58InvitationDialog::onCancelClicked()
59{
60 ui->msgLabel->clear();
61 ui->chatroomLine->clear();
Yingdi Yu42f66462013-10-31 17:38:22 -070062
Yingdi Yua1a688f2014-02-06 18:09:22 -080063 emit invitationRejected(m_invitationInterest);
Yingdi Yu97936352013-11-08 14:13:42 -080064
Yingdi Yua1a688f2014-02-06 18:09:22 -080065 m_invitationInterest.clear();
Yingdi Yu42f66462013-10-31 17:38:22 -070066 m_inviterAlias.clear();
67
Yingdi Yuc4d08d22013-10-23 23:07:29 -070068 this->close();
Yingdi Yudaceb8a2013-10-22 23:42:16 -070069}
70
71#if WAF
72#include "invitationdialog.moc"
73#include "invitationdialog.cpp.moc"
74#endif