blob: bbe7c52d13363d437665470b1369cea850dad134 [file] [log] [blame]
Yingdi Yu847aa862013-10-09 16:35:53 -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#ifndef CONTACTPANEL_H
12#define CONTACTPANEL_H
13
14#include <QDialog>
Yingdi Yu40eca752013-10-10 15:00:58 -070015#include <QStringListModel>
Yingdi Yu3b318c12013-10-15 17:54:00 -070016#include <QtSql/QSqlDatabase>
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070017#include <QMenu>
Yingdi Yu3b318c12013-10-15 17:54:00 -070018
19#include "profileeditor.h"
Yingdi Yu0269c872013-10-16 13:16:49 -070020#include "addcontactpanel.h"
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070021#include "setaliasdialog.h"
Yingdi Yu595aadc2013-10-21 15:01:40 -070022#include "startchatdialog.h"
Yingdi Yu978b3ae2013-10-23 11:50:51 -070023#include "invitationdialog.h"
24#include "settingdialog.h"
Yingdi Yueda39aa2013-10-23 23:07:29 -070025#include "chatdialog.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070026
27#ifndef Q_MOC_RUN
Yingdi Yu9236c432013-10-18 11:29:25 -070028#include "contact-manager.h"
Yingdi Yu7989eb22013-10-31 17:38:22 -070029#include "chronos-invitation.h"
Yingdi Yu9b34b1f2013-11-01 17:37:51 -070030#include "panel-policy-manager.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070031#endif
Yingdi Yu847aa862013-10-09 16:35:53 -070032
Yingdi Yu978b3ae2013-10-23 11:50:51 -070033
Yingdi Yu847aa862013-10-09 16:35:53 -070034namespace Ui {
35class ContactPanel;
36}
37
38class ContactPanel : public QDialog
39{
Yingdi Yueda39aa2013-10-23 23:07:29 -070040 Q_OBJECT
Yingdi Yu847aa862013-10-09 16:35:53 -070041
42public:
Yingdi Yu9236c432013-10-18 11:29:25 -070043 explicit ContactPanel(ndn::Ptr<ContactManager> contactManager, QWidget *parent = 0);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070044
Yingdi Yu3b318c12013-10-15 17:54:00 -070045 ~ContactPanel();
Yingdi Yu847aa862013-10-09 16:35:53 -070046
Yingdi Yu978b3ae2013-10-23 11:50:51 -070047private:
48 void
49 openDB();
50
51 void
52 setKeychain();
53
54 void
55 setLocalPrefix();
56
57 void
58 onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
59
60 void
61 onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
62
63 void
64 onUnverified(ndn::Ptr<ndn::Data> data);
65
66 void
67 onTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
68
69 void
70 setInvitationListener();
71
72 void
73 onInvitation(ndn::Ptr<ndn::Interest> interest);
74
75 void
76 onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
Yingdi Yu9b34b1f2013-11-01 17:37:51 -070077 ndn::Ptr<ChronosInvitation> invitation);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070078
79 std::string
80 getRandomString();
81
82 void
Yingdi Yu7989eb22013-10-31 17:38:22 -070083 popChatInvitation(ndn::Ptr<ChronosInvitation> invitation,
Yingdi Yu978b3ae2013-10-23 11:50:51 -070084 const ndn::Name& inviterNameSpace,
85 ndn::Ptr<ndn::security::IdentityCertificate> certificate);
86
Yingdi Yueda39aa2013-10-23 23:07:29 -070087signals:
88 void
89 newInvitationReady();
90
Yingdi Yu40eca752013-10-10 15:00:58 -070091private slots:
92 void
93 updateSelection(const QItemSelection &selected,
94 const QItemSelection &deselected);
95
Yingdi Yu3b318c12013-10-15 17:54:00 -070096 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -070097 updateDefaultIdentity(const QString& identity);
98
99 void
Yingdi Yu3b318c12013-10-15 17:54:00 -0700100 openProfileEditor();
101
Yingdi Yu0269c872013-10-16 13:16:49 -0700102 void
103 openAddContactPanel();
104
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700105 void
106 openSetAliasDialog();
Yingdi Yu595aadc2013-10-21 15:01:40 -0700107
108 void
109 openStartChatDialog();
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700110
111 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700112 openSettingDialog();
113
114 void
Yingdi Yueda39aa2013-10-23 23:07:29 -0700115 openInvitationDialog();
116
117 void
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700118 refreshContactList();
119
120 void
121 showContextMenu(const QPoint& pos);
122
Yingdi Yu595aadc2013-10-21 15:01:40 -0700123 void
124 startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer);
125
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700126 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700127 startChatroom2(const ChronosInvitation& invitation,
128 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700129
130 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700131 acceptInvitation(const ChronosInvitation& invitation,
132 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700133
134 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700135 rejectInvitation(const ChronosInvitation& invitation);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700136
Yingdi Yuec5e72a2013-11-03 15:05:26 -0800137 void
138 isIntroducerChanged(int state);
139
Yingdi Yu847aa862013-10-09 16:35:53 -0700140private:
Yingdi Yu3b318c12013-10-15 17:54:00 -0700141 Ui::ContactPanel *ui;
Yingdi Yu9236c432013-10-18 11:29:25 -0700142 ndn::Ptr<ContactManager> m_contactManager;
Yingdi Yu3b318c12013-10-15 17:54:00 -0700143 QStringListModel* m_contactListModel;
144 ProfileEditor* m_profileEditor;
Yingdi Yu0269c872013-10-16 13:16:49 -0700145 AddContactPanel* m_addContactPanel;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700146 SetAliasDialog* m_setAliasDialog;
Yingdi Yu595aadc2013-10-21 15:01:40 -0700147 StartChatDialog* m_startChatDialog;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700148 InvitationDialog* m_invitationDialog;
149 SettingDialog* m_settingDialog;
Yingdi Yueda39aa2013-10-23 23:07:29 -0700150 std::map<ndn::Name, ChatDialog*> m_chatDialogs;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700151 QAction* m_menuInvite;
152 QAction* m_menuAlias;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700153 std::vector<ndn::Ptr<ContactItem> > m_contactList;
154
Yingdi Yu9b34b1f2013-11-01 17:37:51 -0700155 ndn::Ptr<PanelPolicyManager> m_panelPolicyManager;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700156 ndn::Ptr<ndn::security::Keychain> m_keychain;
157 ndn::Ptr<ndn::Wrapper> m_handler;
158
159 ndn::Name m_defaultIdentity;
160 ndn::Name m_localPrefix;
Yingdi Yueda39aa2013-10-23 23:07:29 -0700161 ndn::Name m_inviteListenPrefix;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700162
Yingdi Yuec5e72a2013-11-03 15:05:26 -0800163 // std::string m_currentSelectedContactAlias;
164 // std::string m_currentSelectedContactNamespace;
165 ndn::Ptr<ContactItem> m_currentSelectedContact;
166 QStringListModel* m_currentContactTrustScopeListModel;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700167
168
Yingdi Yu847aa862013-10-09 16:35:53 -0700169};
170
171#endif // CONTACTPANEL_H