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