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