Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | 40eca75 | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 15 | #include <QStringListModel> |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 16 | #include <QtSql/QSqlDatabase> |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 17 | #include <QMenu> |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 18 | #include <QMessageBox> |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 19 | |
| 20 | #include "profileeditor.h" |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 21 | #include "addcontactpanel.h" |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 22 | #include "setaliasdialog.h" |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 23 | #include "startchatdialog.h" |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 24 | #include "invitationdialog.h" |
| 25 | #include "settingdialog.h" |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 26 | #include "chatdialog.h" |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 27 | #include "endorse-combobox-delegate.h" |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 28 | #include "browsecontactdialog.h" |
Yingdi Yu | b5a0fd3 | 2013-11-10 16:26:52 -0800 | [diff] [blame] | 29 | #include "warningdialog.h" |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 30 | |
| 31 | #ifndef Q_MOC_RUN |
Yingdi Yu | 9236c43 | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 32 | #include "contact-manager.h" |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 33 | #include "chronos-invitation.h" |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 34 | #include "panel-policy-manager.h" |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 35 | #endif |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 36 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 37 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 38 | namespace Ui { |
| 39 | class ContactPanel; |
| 40 | } |
| 41 | |
| 42 | class ContactPanel : public QDialog |
| 43 | { |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 44 | Q_OBJECT |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 45 | |
| 46 | public: |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 47 | explicit ContactPanel(QWidget *parent = 0); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 48 | |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 49 | ~ContactPanel(); |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 50 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 51 | private: |
| 52 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 53 | createAction(); |
| 54 | |
| 55 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 56 | openDB(); |
| 57 | |
| 58 | void |
| 59 | setKeychain(); |
| 60 | |
| 61 | void |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 62 | setLocalPrefix(int retry = 10); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 63 | |
| 64 | void |
| 65 | onLocalPrefixVerified(ndn::Ptr<ndn::Data> data); |
| 66 | |
| 67 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 68 | onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 69 | ndn::Ptr<ndn::Interest> interest, |
| 70 | int retry); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 71 | |
| 72 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 73 | setInvitationListener(); |
| 74 | |
| 75 | void |
| 76 | onInvitation(ndn::Ptr<ndn::Interest> interest); |
| 77 | |
| 78 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 79 | onUnverified(ndn::Ptr<ndn::Data> data); |
| 80 | |
| 81 | void |
| 82 | onTimeout(ndn::Ptr<ndn::Closure> closure, |
| 83 | ndn::Ptr<ndn::Interest> interest); |
| 84 | |
| 85 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 86 | onInvitationCertVerified(ndn::Ptr<ndn::Data> data, |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 87 | ndn::Ptr<ChronosInvitation> invitation); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 88 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 89 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 90 | popChatInvitation(ndn::Ptr<ChronosInvitation> invitation, |
| 91 | const ndn::Name& inviterNameSpace, |
| 92 | ndn::Ptr<ndn::security::IdentityCertificate> certificate); |
| 93 | |
| 94 | void |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 95 | collectEndorsement(); |
| 96 | |
| 97 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 98 | onDnsEndorseeVerified(ndn::Ptr<ndn::Data> data, int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 99 | |
| 100 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 101 | onDnsEndorseeTimeout(ndn::Ptr<ndn::Closure> closure, |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 102 | ndn::Ptr<ndn::Interest> interest, |
| 103 | int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 104 | |
| 105 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 106 | onDnsEndorseeUnverified(ndn::Ptr<ndn::Data> data, int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 107 | |
| 108 | void |
| 109 | updateCollectStatus(int count); |
| 110 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 111 | std::string |
| 112 | getRandomString(); |
| 113 | |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 114 | signals: |
| 115 | void |
| 116 | newInvitationReady(); |
| 117 | |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 118 | void |
| 119 | refreshCertDirectory(); |
| 120 | |
Yingdi Yu | 40eca75 | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 121 | private slots: |
| 122 | void |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 123 | showError(const QString& msg); |
| 124 | |
| 125 | void |
Yingdi Yu | e433a50 | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 126 | showWarning(const QString& msg); |
| 127 | |
| 128 | void |
Yingdi Yu | 40eca75 | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 129 | updateSelection(const QItemSelection &selected, |
| 130 | const QItemSelection &deselected); |
| 131 | |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 132 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 133 | updateDefaultIdentity(const QString& identity, |
| 134 | const QString& nickName); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 135 | |
| 136 | void |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 137 | openProfileEditor(); |
| 138 | |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 139 | void |
| 140 | openAddContactPanel(); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 141 | |
| 142 | void |
| 143 | openBrowseContactDialog(); |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 144 | |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 145 | void |
| 146 | openSetAliasDialog(); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 147 | |
| 148 | void |
| 149 | removeContactButton(); |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 150 | |
| 151 | void |
| 152 | openStartChatDialog(); |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 153 | |
| 154 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 155 | openSettingDialog(); |
| 156 | |
| 157 | void |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 158 | openInvitationDialog(); |
| 159 | |
| 160 | void |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 161 | refreshContactList(); |
| 162 | |
| 163 | void |
| 164 | showContextMenu(const QPoint& pos); |
| 165 | |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 166 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 167 | startChatroom(const QString& chatroom, |
| 168 | const QString& invitee, |
| 169 | bool isIntroducer); |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 170 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 171 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 172 | startChatroom2(const ChronosInvitation& invitation, |
| 173 | const ndn::security::IdentityCertificate& identityCertificate); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 174 | |
| 175 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 176 | acceptInvitation(const ChronosInvitation& invitation, |
| 177 | const ndn::security::IdentityCertificate& identityCertificate); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 178 | |
| 179 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 180 | rejectInvitation(const ChronosInvitation& invitation); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 181 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 182 | void |
| 183 | isIntroducerChanged(int state); |
| 184 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 185 | void |
| 186 | addScopeClicked(); |
| 187 | |
| 188 | void |
| 189 | deleteScopeClicked(); |
| 190 | |
| 191 | void |
| 192 | saveScopeClicked(); |
| 193 | |
| 194 | void |
| 195 | endorseButtonClicked(); |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 196 | |
| 197 | void |
| 198 | removeChatDialog(const ndn::Name& chatroomName); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 199 | |
Yingdi Yu | 7223269 | 2013-11-12 17:50:21 -0800 | [diff] [blame^] | 200 | void |
| 201 | addContactIntoPanelPolicy(const ndn::Name& nameSpace); |
| 202 | |
| 203 | void |
| 204 | removeContactFromPanelPolicy(const ndn::Name& keyName); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 205 | |
| 206 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 207 | private: |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 208 | Ui::ContactPanel *ui; |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 209 | WarningDialog* m_warningDialog; |
Yingdi Yu | 9236c43 | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 210 | ndn::Ptr<ContactManager> m_contactManager; |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 211 | QStringListModel* m_contactListModel; |
| 212 | ProfileEditor* m_profileEditor; |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 213 | AddContactPanel* m_addContactPanel; |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 214 | BrowseContactDialog* m_browseContactDialog; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 215 | SetAliasDialog* m_setAliasDialog; |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 216 | StartChatDialog* m_startChatDialog; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 217 | InvitationDialog* m_invitationDialog; |
| 218 | SettingDialog* m_settingDialog; |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 219 | std::map<ndn::Name, ChatDialog*> m_chatDialogs; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 220 | QAction* m_menuInvite; |
| 221 | QAction* m_menuAlias; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 222 | std::vector<ndn::Ptr<ContactItem> > m_contactList; |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 223 | ndn::Ptr<std::vector<bool> > m_collectStatus; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 224 | |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 225 | ndn::Ptr<PanelPolicyManager> m_panelPolicyManager; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 226 | ndn::Ptr<ndn::security::Keychain> m_keychain; |
| 227 | ndn::Ptr<ndn::Wrapper> m_handler; |
| 228 | |
| 229 | ndn::Name m_defaultIdentity; |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 230 | std::string m_nickName; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 231 | ndn::Name m_localPrefix; |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 232 | ndn::Name m_inviteListenPrefix; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 233 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 234 | ndn::Ptr<ContactItem> m_currentSelectedContact; |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 235 | QSqlTableModel* m_trustScopeModel; |
| 236 | QSqlTableModel* m_endorseDataModel; |
| 237 | EndorseComboBoxDelegate* m_endorseComboBoxDelegate; |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | #endif // CONTACTPANEL_H |