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