blob: 55f9daf031d6423d65f7b0219ee60bde7bf71f36 [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 Yub2e747d2013-11-05 23:06:43 -080026#include "endorse-combobox-delegate.h"
Yingdi Yuae8217c2013-11-09 00:03:26 -080027#include "browsecontactdialog.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070028
29#ifndef Q_MOC_RUN
Yingdi Yu9236c432013-10-18 11:29:25 -070030#include "contact-manager.h"
Yingdi Yu7989eb22013-10-31 17:38:22 -070031#include "chronos-invitation.h"
Yingdi Yu9b34b1f2013-11-01 17:37:51 -070032#include "panel-policy-manager.h"
Yingdi Yu3b318c12013-10-15 17:54:00 -070033#endif
Yingdi Yu847aa862013-10-09 16:35:53 -070034
Yingdi Yu978b3ae2013-10-23 11:50:51 -070035
Yingdi Yu847aa862013-10-09 16:35:53 -070036namespace Ui {
37class ContactPanel;
38}
39
40class ContactPanel : public QDialog
41{
Yingdi Yueda39aa2013-10-23 23:07:29 -070042 Q_OBJECT
Yingdi Yu847aa862013-10-09 16:35:53 -070043
44public:
Yingdi Yu46948282013-11-06 18:43:31 -080045 explicit ContactPanel(ndn::Ptr<ContactManager> contactManager,
46 QWidget *parent = 0);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070047
Yingdi Yu3b318c12013-10-15 17:54:00 -070048 ~ContactPanel();
Yingdi Yu847aa862013-10-09 16:35:53 -070049
Yingdi Yu978b3ae2013-10-23 11:50:51 -070050private:
51 void
Yingdi Yu46948282013-11-06 18:43:31 -080052 createAction();
53
54 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -070055 openDB();
56
57 void
58 setKeychain();
59
60 void
61 setLocalPrefix();
62
63 void
64 onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
65
66 void
Yingdi Yu46948282013-11-06 18:43:31 -080067 onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure,
68 ndn::Ptr<ndn::Interest> interest);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070069
70 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -070071 setInvitationListener();
72
73 void
74 onInvitation(ndn::Ptr<ndn::Interest> interest);
75
76 void
Yingdi Yu46948282013-11-06 18:43:31 -080077 onUnverified(ndn::Ptr<ndn::Data> data);
78
79 void
80 onTimeout(ndn::Ptr<ndn::Closure> closure,
81 ndn::Ptr<ndn::Interest> interest);
82
83 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -070084 onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
Yingdi Yu9b34b1f2013-11-01 17:37:51 -070085 ndn::Ptr<ChronosInvitation> invitation);
Yingdi Yu978b3ae2013-10-23 11:50:51 -070086
Yingdi Yub2e747d2013-11-05 23:06:43 -080087 void
Yingdi Yu46948282013-11-06 18:43:31 -080088 popChatInvitation(ndn::Ptr<ChronosInvitation> invitation,
89 const ndn::Name& inviterNameSpace,
90 ndn::Ptr<ndn::security::IdentityCertificate> certificate);
91
92 void
Yingdi Yub2e747d2013-11-05 23:06:43 -080093 collectEndorsement();
94
95 void
Yingdi Yu46948282013-11-06 18:43:31 -080096 onDnsEndorseeVerified(ndn::Ptr<ndn::Data> data, int count);
Yingdi Yub2e747d2013-11-05 23:06:43 -080097
98 void
Yingdi Yu46948282013-11-06 18:43:31 -080099 onDnsEndorseeTimeout(ndn::Ptr<ndn::Closure> closure,
Yingdi Yu83eae842013-11-06 22:07:38 -0800100 ndn::Ptr<ndn::Interest> interest,
101 int count);
Yingdi Yub2e747d2013-11-05 23:06:43 -0800102
103 void
Yingdi Yu46948282013-11-06 18:43:31 -0800104 onDnsEndorseeUnverified(ndn::Ptr<ndn::Data> data, int count);
Yingdi Yub2e747d2013-11-05 23:06:43 -0800105
106 void
107 updateCollectStatus(int count);
108
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700109 std::string
110 getRandomString();
111
Yingdi Yueda39aa2013-10-23 23:07:29 -0700112signals:
113 void
114 newInvitationReady();
115
Yingdi Yuae8217c2013-11-09 00:03:26 -0800116 void
117 refreshCertDirectory();
118
Yingdi Yu40eca752013-10-10 15:00:58 -0700119private slots:
120 void
121 updateSelection(const QItemSelection &selected,
122 const QItemSelection &deselected);
123
Yingdi Yu3b318c12013-10-15 17:54:00 -0700124 void
Yingdi Yu46948282013-11-06 18:43:31 -0800125 updateDefaultIdentity(const QString& identity,
126 const QString& nickName);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700127
128 void
Yingdi Yu3b318c12013-10-15 17:54:00 -0700129 openProfileEditor();
130
Yingdi Yu0269c872013-10-16 13:16:49 -0700131 void
132 openAddContactPanel();
Yingdi Yuae8217c2013-11-09 00:03:26 -0800133
134 void
135 openBrowseContactDialog();
Yingdi Yu0269c872013-10-16 13:16:49 -0700136
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700137 void
138 openSetAliasDialog();
Yingdi Yuae8217c2013-11-09 00:03:26 -0800139
140 void
141 removeContactButton();
Yingdi Yu595aadc2013-10-21 15:01:40 -0700142
143 void
144 openStartChatDialog();
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700145
146 void
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700147 openSettingDialog();
148
149 void
Yingdi Yueda39aa2013-10-23 23:07:29 -0700150 openInvitationDialog();
151
152 void
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700153 refreshContactList();
154
155 void
156 showContextMenu(const QPoint& pos);
157
Yingdi Yu595aadc2013-10-21 15:01:40 -0700158 void
Yingdi Yu46948282013-11-06 18:43:31 -0800159 startChatroom(const QString& chatroom,
160 const QString& invitee,
161 bool isIntroducer);
Yingdi Yu595aadc2013-10-21 15:01:40 -0700162
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700163 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700164 startChatroom2(const ChronosInvitation& invitation,
165 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700166
167 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700168 acceptInvitation(const ChronosInvitation& invitation,
169 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700170
171 void
Yingdi Yu7989eb22013-10-31 17:38:22 -0700172 rejectInvitation(const ChronosInvitation& invitation);
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700173
Yingdi Yuec5e72a2013-11-03 15:05:26 -0800174 void
175 isIntroducerChanged(int state);
176
Yingdi Yub2e747d2013-11-05 23:06:43 -0800177 void
178 addScopeClicked();
179
180 void
181 deleteScopeClicked();
182
183 void
184 saveScopeClicked();
185
186 void
187 endorseButtonClicked();
Yingdi Yu46948282013-11-06 18:43:31 -0800188
189 void
190 removeChatDialog(const ndn::Name& chatroomName);
Yingdi Yub2e747d2013-11-05 23:06:43 -0800191
192
193
Yingdi Yu847aa862013-10-09 16:35:53 -0700194private:
Yingdi Yu3b318c12013-10-15 17:54:00 -0700195 Ui::ContactPanel *ui;
Yingdi Yu9236c432013-10-18 11:29:25 -0700196 ndn::Ptr<ContactManager> m_contactManager;
Yingdi Yu3b318c12013-10-15 17:54:00 -0700197 QStringListModel* m_contactListModel;
198 ProfileEditor* m_profileEditor;
Yingdi Yu0269c872013-10-16 13:16:49 -0700199 AddContactPanel* m_addContactPanel;
Yingdi Yuae8217c2013-11-09 00:03:26 -0800200 BrowseContactDialog* m_browseContactDialog;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700201 SetAliasDialog* m_setAliasDialog;
Yingdi Yu595aadc2013-10-21 15:01:40 -0700202 StartChatDialog* m_startChatDialog;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700203 InvitationDialog* m_invitationDialog;
204 SettingDialog* m_settingDialog;
Yingdi Yueda39aa2013-10-23 23:07:29 -0700205 std::map<ndn::Name, ChatDialog*> m_chatDialogs;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700206 QAction* m_menuInvite;
207 QAction* m_menuAlias;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700208 std::vector<ndn::Ptr<ContactItem> > m_contactList;
Yingdi Yub2e747d2013-11-05 23:06:43 -0800209 ndn::Ptr<std::vector<bool> > m_collectStatus;
Yingdi Yu2ac40fb2013-10-21 13:38:38 -0700210
Yingdi Yu9b34b1f2013-11-01 17:37:51 -0700211 ndn::Ptr<PanelPolicyManager> m_panelPolicyManager;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700212 ndn::Ptr<ndn::security::Keychain> m_keychain;
213 ndn::Ptr<ndn::Wrapper> m_handler;
214
215 ndn::Name m_defaultIdentity;
Yingdi Yu46948282013-11-06 18:43:31 -0800216 std::string m_nickName;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700217 ndn::Name m_localPrefix;
Yingdi Yueda39aa2013-10-23 23:07:29 -0700218 ndn::Name m_inviteListenPrefix;
Yingdi Yu978b3ae2013-10-23 11:50:51 -0700219
Yingdi Yuec5e72a2013-11-03 15:05:26 -0800220 ndn::Ptr<ContactItem> m_currentSelectedContact;
Yingdi Yub2e747d2013-11-05 23:06:43 -0800221 QSqlTableModel* m_trustScopeModel;
222 QSqlTableModel* m_endorseDataModel;
223 EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
Yingdi Yu847aa862013-10-09 16:35:53 -0700224};
225
226#endif // CONTACTPANEL_H