blob: e48216942c57882b6b20420e5979bae219d67acc [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
Yingdi Yu5b989132013-10-23 14:03:09 -07004 * Yingdi Yu
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07005 *
Yingdi Yu5b989132013-10-23 14:03:09 -07006 * BSD license, See the LICENSE file for more information
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07007 *
Yingdi Yu5b989132013-10-23 14:03:09 -07008 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07009 */
10
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070011#ifndef CHATDIALOG_H
12#define CHATDIALOG_H
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070013
Yingdi Yu5b989132013-10-23 14:03:09 -070014#include <QDialog>
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070015
Yingdi Yu5b989132013-10-23 14:03:09 -070016#ifndef Q_MOC_RUN
17#include <ndn.cxx/data.h>
Yingdi Yueda39aa2013-10-23 23:07:29 -070018#include <ndn.cxx/security/keychain.h>
19#include <ndn.cxx/wrapper/wrapper.h>
20#include "chatroom-policy-manager.h"
21#include "contact-item.h"
Alexander Afanasyevf829f4d2013-05-07 15:59:36 -070022#endif
23
Yingdi Yu5b989132013-10-23 14:03:09 -070024namespace Ui {
25class ChatDialog;
26}
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070027
Yingdi Yu5b989132013-10-23 14:03:09 -070028class ChatDialog : public QDialog
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070029{
Yingdi Yu5b989132013-10-23 14:03:09 -070030 Q_OBJECT
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070031
32public:
Yingdi Yu5b989132013-10-23 14:03:09 -070033 explicit ChatDialog(const ndn::Name& chatroomPrefix,
34 const ndn::Name& localPrefix,
Yingdi Yueda39aa2013-10-23 23:07:29 -070035 const ndn::Name& defaultIdentity,
Yingdi Yu5b989132013-10-23 14:03:09 -070036 QWidget *parent = 0);
Zhenkai Zhu82a62752012-06-04 17:11:04 -070037 ~ChatDialog();
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070038
Yingdi Yu5b989132013-10-23 14:03:09 -070039 const ndn::Name&
40 getChatroomPrefix() const
41 { return m_chatroomPrefix; }
Zhenkai Zhu3a008fc2012-06-08 17:36:39 -070042
Yingdi Yu5b989132013-10-23 14:03:09 -070043 const ndn::Name&
44 getLocalPrefix() const
45 { return m_localPrefix; }
46
47 void
Yingdi Yueda39aa2013-10-23 23:07:29 -070048 sendInvitation(ndn::Ptr<ContactItem> contact);
Zhenkai Zhu10ccb5a2012-06-04 21:55:14 -070049
Zhenkai Zhub45e38a2012-06-01 15:44:36 -070050private:
Yingdi Yueda39aa2013-10-23 23:07:29 -070051 void
52 setWrapper();
53
54 void
55 onInviteReplyVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
56
57 void
58 onInviteTimeout(ndn::Ptr<ndn::Closure> closure,
59 ndn::Ptr<ndn::Interest> interest,
60 const ndn::Name& identity,
61 int retry);
62
63 void
64 invitationRejected(const ndn::Name& identity);
65
66 void
67 invitationAccepted(const ndn::Name& identity);
68
69 void
70 onUnverified(ndn::Ptr<ndn::Data> data);
71
72private:
Yingdi Yu5b989132013-10-23 14:03:09 -070073 Ui::ChatDialog *ui;
74 ndn::Name m_chatroomPrefix;
75 ndn::Name m_localPrefix;
Yingdi Yueda39aa2013-10-23 23:07:29 -070076 ndn::Name m_defaultIdentity;
77 ndn::Ptr<ChatroomPolicyManager> m_policyManager;
78 ndn::Ptr<ndn::security::IdentityManager> m_identityManager;
79 ndn::Ptr<ndn::security::Keychain> m_keychain;
80 ndn::Ptr<ndn::Wrapper> m_handler;
Zhenkai Zhu6d589aa2012-05-29 17:34:35 -070081};
Yingdi Yu5b989132013-10-23 14:03:09 -070082
83#endif // ChatDIALOG_H