blob: f6e794c947820600d2c93b1b4d36faddf68df06c [file] [log] [blame]
Yingdi Yu9e0dc292013-10-10 11:39:45 -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
Yingdi Yudef90612013-10-09 22:34:42 -070011#ifndef CONTACTPANEL_H
12#define CONTACTPANEL_H
13
14#include <QDialog>
Yingdi Yu01a942b2013-10-10 15:00:58 -070015#include <QStringListModel>
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070016#include <QtSql/QSqlDatabase>
Yingdi Yu79c25a22013-10-21 13:38:38 -070017#include <QMenu>
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070018
19#include "profileeditor.h"
Yingdi Yud59b5932013-10-16 13:16:49 -070020#include "addcontactpanel.h"
Yingdi Yu79c25a22013-10-21 13:38:38 -070021#include "setaliasdialog.h"
Yingdi Yu100267f2013-10-21 15:01:40 -070022#include "startchatdialog.h"
Yingdi Yu53eb8a72013-10-23 11:50:51 -070023#include "invitationdialog.h"
24#include "settingdialog.h"
Yingdi Yuc4d08d22013-10-23 23:07:29 -070025#include "chatdialog.h"
Yingdi Yu8dacdf22013-11-05 23:06:43 -080026#include "endorse-combobox-delegate.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070027
28#ifndef Q_MOC_RUN
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070029#include "contact-manager.h"
Yingdi Yu42f66462013-10-31 17:38:22 -070030#include "chronos-invitation.h"
Yingdi Yued8cfc42013-11-01 17:37:51 -070031#include "panel-policy-manager.h"
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070032#endif
Yingdi Yudef90612013-10-09 22:34:42 -070033
Yingdi Yu53eb8a72013-10-23 11:50:51 -070034
Yingdi Yudef90612013-10-09 22:34:42 -070035namespace Ui {
36class ContactPanel;
37}
38
39class ContactPanel : public QDialog
40{
Yingdi Yuc4d08d22013-10-23 23:07:29 -070041 Q_OBJECT
Yingdi Yudef90612013-10-09 22:34:42 -070042
43public:
Yingdi Yu42372442013-11-06 18:43:31 -080044 explicit ContactPanel(ndn::Ptr<ContactManager> contactManager,
45 QWidget *parent = 0);
Yingdi Yu53eb8a72013-10-23 11:50:51 -070046
Yingdi Yu0a6b6c52013-10-15 17:54:00 -070047 ~ContactPanel();
Yingdi Yudef90612013-10-09 22:34:42 -070048
Yingdi Yu53eb8a72013-10-23 11:50:51 -070049private:
50 void
Yingdi Yu42372442013-11-06 18:43:31 -080051 createAction();
52
53 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070054 openDB();
55
56 void
57 setKeychain();
58
59 void
60 setLocalPrefix();
61
62 void
63 onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
64
65 void
Yingdi Yu42372442013-11-06 18:43:31 -080066 onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure,
67 ndn::Ptr<ndn::Interest> interest);
Yingdi Yu53eb8a72013-10-23 11:50:51 -070068
69 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070070 setInvitationListener();
71
72 void
73 onInvitation(ndn::Ptr<ndn::Interest> interest);
74
75 void
Yingdi Yu42372442013-11-06 18:43:31 -080076 onUnverified(ndn::Ptr<ndn::Data> data);
77
78 void
79 onTimeout(ndn::Ptr<ndn::Closure> closure,
80 ndn::Ptr<ndn::Interest> interest);
81
82 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070083 onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
Yingdi Yued8cfc42013-11-01 17:37:51 -070084 ndn::Ptr<ChronosInvitation> invitation);
Yingdi Yu53eb8a72013-10-23 11:50:51 -070085
Yingdi Yu8dacdf22013-11-05 23:06:43 -080086 void
Yingdi Yu42372442013-11-06 18:43:31 -080087 popChatInvitation(ndn::Ptr<ChronosInvitation> invitation,
88 const ndn::Name& inviterNameSpace,
89 ndn::Ptr<ndn::security::IdentityCertificate> certificate);
90
91 void
Yingdi Yu8dacdf22013-11-05 23:06:43 -080092 collectEndorsement();
93
94 void
Yingdi Yu42372442013-11-06 18:43:31 -080095 onDnsEndorseeVerified(ndn::Ptr<ndn::Data> data, int count);
Yingdi Yu8dacdf22013-11-05 23:06:43 -080096
97 void
Yingdi Yu42372442013-11-06 18:43:31 -080098 onDnsEndorseeTimeout(ndn::Ptr<ndn::Closure> closure,
Yingdi Yua0594092013-11-06 22:07:38 -080099 ndn::Ptr<ndn::Interest> interest,
100 int count);
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800101
102 void
Yingdi Yu42372442013-11-06 18:43:31 -0800103 onDnsEndorseeUnverified(ndn::Ptr<ndn::Data> data, int count);
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800104
105 void
106 updateCollectStatus(int count);
107
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700108 std::string
109 getRandomString();
110
Yingdi Yuc4d08d22013-10-23 23:07:29 -0700111signals:
112 void
113 newInvitationReady();
114
Yingdi Yu01a942b2013-10-10 15:00:58 -0700115private slots:
116 void
117 updateSelection(const QItemSelection &selected,
118 const QItemSelection &deselected);
119
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700120 void
Yingdi Yu42372442013-11-06 18:43:31 -0800121 updateDefaultIdentity(const QString& identity,
122 const QString& nickName);
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700123
124 void
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700125 openProfileEditor();
126
Yingdi Yud59b5932013-10-16 13:16:49 -0700127 void
128 openAddContactPanel();
129
Yingdi Yu79c25a22013-10-21 13:38:38 -0700130 void
131 openSetAliasDialog();
Yingdi Yu100267f2013-10-21 15:01:40 -0700132
133 void
134 openStartChatDialog();
Yingdi Yu79c25a22013-10-21 13:38:38 -0700135
136 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700137 openSettingDialog();
138
139 void
Yingdi Yuc4d08d22013-10-23 23:07:29 -0700140 openInvitationDialog();
141
142 void
Yingdi Yu79c25a22013-10-21 13:38:38 -0700143 refreshContactList();
144
145 void
146 showContextMenu(const QPoint& pos);
147
Yingdi Yu100267f2013-10-21 15:01:40 -0700148 void
Yingdi Yu42372442013-11-06 18:43:31 -0800149 startChatroom(const QString& chatroom,
150 const QString& invitee,
151 bool isIntroducer);
Yingdi Yu100267f2013-10-21 15:01:40 -0700152
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700153 void
Yingdi Yu42f66462013-10-31 17:38:22 -0700154 startChatroom2(const ChronosInvitation& invitation,
155 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700156
157 void
Yingdi Yu42f66462013-10-31 17:38:22 -0700158 acceptInvitation(const ChronosInvitation& invitation,
159 const ndn::security::IdentityCertificate& identityCertificate);
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700160
161 void
Yingdi Yu42f66462013-10-31 17:38:22 -0700162 rejectInvitation(const ChronosInvitation& invitation);
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700163
Yingdi Yua50c3252013-11-03 15:05:26 -0800164 void
165 isIntroducerChanged(int state);
166
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800167 void
168 addScopeClicked();
169
170 void
171 deleteScopeClicked();
172
173 void
174 saveScopeClicked();
175
176 void
177 endorseButtonClicked();
Yingdi Yu42372442013-11-06 18:43:31 -0800178
179 void
180 removeChatDialog(const ndn::Name& chatroomName);
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800181
182
183
Yingdi Yudef90612013-10-09 22:34:42 -0700184private:
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700185 Ui::ContactPanel *ui;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -0700186 ndn::Ptr<ContactManager> m_contactManager;
Yingdi Yu0a6b6c52013-10-15 17:54:00 -0700187 QStringListModel* m_contactListModel;
188 ProfileEditor* m_profileEditor;
Yingdi Yud59b5932013-10-16 13:16:49 -0700189 AddContactPanel* m_addContactPanel;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700190 SetAliasDialog* m_setAliasDialog;
Yingdi Yu100267f2013-10-21 15:01:40 -0700191 StartChatDialog* m_startChatDialog;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700192 InvitationDialog* m_invitationDialog;
193 SettingDialog* m_settingDialog;
Yingdi Yuc4d08d22013-10-23 23:07:29 -0700194 std::map<ndn::Name, ChatDialog*> m_chatDialogs;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700195 QAction* m_menuInvite;
196 QAction* m_menuAlias;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700197 std::vector<ndn::Ptr<ContactItem> > m_contactList;
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800198 ndn::Ptr<std::vector<bool> > m_collectStatus;
Yingdi Yu79c25a22013-10-21 13:38:38 -0700199
Yingdi Yued8cfc42013-11-01 17:37:51 -0700200 ndn::Ptr<PanelPolicyManager> m_panelPolicyManager;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700201 ndn::Ptr<ndn::security::Keychain> m_keychain;
202 ndn::Ptr<ndn::Wrapper> m_handler;
203
204 ndn::Name m_defaultIdentity;
Yingdi Yu42372442013-11-06 18:43:31 -0800205 std::string m_nickName;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700206 ndn::Name m_localPrefix;
Yingdi Yuc4d08d22013-10-23 23:07:29 -0700207 ndn::Name m_inviteListenPrefix;
Yingdi Yu53eb8a72013-10-23 11:50:51 -0700208
Yingdi Yua50c3252013-11-03 15:05:26 -0800209 ndn::Ptr<ContactItem> m_currentSelectedContact;
Yingdi Yu8dacdf22013-11-05 23:06:43 -0800210 QSqlTableModel* m_trustScopeModel;
211 QSqlTableModel* m_endorseDataModel;
212 EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
Yingdi Yudef90612013-10-09 22:34:42 -0700213};
214
215#endif // CONTACTPANEL_H