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 | 8e13583 | 2013-11-09 20:12:31 -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 |
| 62 | setLocalPrefix(); |
| 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, |
| 69 | ndn::Ptr<ndn::Interest> interest); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 70 | |
| 71 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 72 | setInvitationListener(); |
| 73 | |
| 74 | void |
| 75 | onInvitation(ndn::Ptr<ndn::Interest> interest); |
| 76 | |
| 77 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 78 | onUnverified(ndn::Ptr<ndn::Data> data); |
| 79 | |
| 80 | void |
| 81 | onTimeout(ndn::Ptr<ndn::Closure> closure, |
| 82 | ndn::Ptr<ndn::Interest> interest); |
| 83 | |
| 84 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 85 | onInvitationCertVerified(ndn::Ptr<ndn::Data> data, |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 86 | ndn::Ptr<ChronosInvitation> invitation); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 87 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 88 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 89 | popChatInvitation(ndn::Ptr<ChronosInvitation> invitation, |
| 90 | const ndn::Name& inviterNameSpace, |
| 91 | ndn::Ptr<ndn::security::IdentityCertificate> certificate); |
| 92 | |
| 93 | void |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 94 | collectEndorsement(); |
| 95 | |
| 96 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 97 | onDnsEndorseeVerified(ndn::Ptr<ndn::Data> data, int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 98 | |
| 99 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 100 | onDnsEndorseeTimeout(ndn::Ptr<ndn::Closure> closure, |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 101 | ndn::Ptr<ndn::Interest> interest, |
| 102 | int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 103 | |
| 104 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 105 | onDnsEndorseeUnverified(ndn::Ptr<ndn::Data> data, int count); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 106 | |
| 107 | void |
| 108 | updateCollectStatus(int count); |
| 109 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 110 | std::string |
| 111 | getRandomString(); |
| 112 | |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 113 | signals: |
| 114 | void |
| 115 | newInvitationReady(); |
| 116 | |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 117 | void |
| 118 | refreshCertDirectory(); |
| 119 | |
Yingdi Yu | 40eca75 | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 120 | private slots: |
| 121 | void |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame^] | 122 | showError(const QString& msg); |
| 123 | |
| 124 | void |
Yingdi Yu | 40eca75 | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 125 | updateSelection(const QItemSelection &selected, |
| 126 | const QItemSelection &deselected); |
| 127 | |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 128 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 129 | updateDefaultIdentity(const QString& identity, |
| 130 | const QString& nickName); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 131 | |
| 132 | void |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 133 | openProfileEditor(); |
| 134 | |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 135 | void |
| 136 | openAddContactPanel(); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 137 | |
| 138 | void |
| 139 | openBrowseContactDialog(); |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 140 | |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 141 | void |
| 142 | openSetAliasDialog(); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 143 | |
| 144 | void |
| 145 | removeContactButton(); |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 146 | |
| 147 | void |
| 148 | openStartChatDialog(); |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 149 | |
| 150 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 151 | openSettingDialog(); |
| 152 | |
| 153 | void |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 154 | openInvitationDialog(); |
| 155 | |
| 156 | void |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 157 | refreshContactList(); |
| 158 | |
| 159 | void |
| 160 | showContextMenu(const QPoint& pos); |
| 161 | |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 162 | void |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 163 | startChatroom(const QString& chatroom, |
| 164 | const QString& invitee, |
| 165 | bool isIntroducer); |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 166 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 167 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 168 | startChatroom2(const ChronosInvitation& invitation, |
| 169 | const ndn::security::IdentityCertificate& identityCertificate); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 170 | |
| 171 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 172 | acceptInvitation(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 | rejectInvitation(const ChronosInvitation& invitation); |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 177 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 178 | void |
| 179 | isIntroducerChanged(int state); |
| 180 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 181 | void |
| 182 | addScopeClicked(); |
| 183 | |
| 184 | void |
| 185 | deleteScopeClicked(); |
| 186 | |
| 187 | void |
| 188 | saveScopeClicked(); |
| 189 | |
| 190 | void |
| 191 | endorseButtonClicked(); |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 192 | |
| 193 | void |
| 194 | removeChatDialog(const ndn::Name& chatroomName); |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 195 | |
| 196 | |
| 197 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 198 | private: |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 199 | Ui::ContactPanel *ui; |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame^] | 200 | WarningDialog* m_warningDialog; |
Yingdi Yu | 9236c43 | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 201 | ndn::Ptr<ContactManager> m_contactManager; |
Yingdi Yu | 3b318c1 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 202 | QStringListModel* m_contactListModel; |
| 203 | ProfileEditor* m_profileEditor; |
Yingdi Yu | 0269c87 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 204 | AddContactPanel* m_addContactPanel; |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 205 | BrowseContactDialog* m_browseContactDialog; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 206 | SetAliasDialog* m_setAliasDialog; |
Yingdi Yu | 595aadc | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 207 | StartChatDialog* m_startChatDialog; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 208 | InvitationDialog* m_invitationDialog; |
| 209 | SettingDialog* m_settingDialog; |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 210 | std::map<ndn::Name, ChatDialog*> m_chatDialogs; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 211 | QAction* m_menuInvite; |
| 212 | QAction* m_menuAlias; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 213 | std::vector<ndn::Ptr<ContactItem> > m_contactList; |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 214 | ndn::Ptr<std::vector<bool> > m_collectStatus; |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 215 | |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 216 | ndn::Ptr<PanelPolicyManager> m_panelPolicyManager; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 217 | ndn::Ptr<ndn::security::Keychain> m_keychain; |
| 218 | ndn::Ptr<ndn::Wrapper> m_handler; |
| 219 | |
| 220 | ndn::Name m_defaultIdentity; |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 221 | std::string m_nickName; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 222 | ndn::Name m_localPrefix; |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 223 | ndn::Name m_inviteListenPrefix; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 224 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 225 | ndn::Ptr<ContactItem> m_currentSelectedContact; |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 226 | QSqlTableModel* m_trustScopeModel; |
| 227 | QSqlTableModel* m_endorseDataModel; |
| 228 | EndorseComboBoxDelegate* m_endorseComboBoxDelegate; |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | #endif // CONTACTPANEL_H |