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