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 | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 29 | #endif |
Yingdi Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 30 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 31 | |
Yingdi Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 32 | namespace Ui { |
| 33 | class ContactPanel; |
| 34 | } |
| 35 | |
| 36 | class ContactPanel : public QDialog |
| 37 | { |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 38 | Q_OBJECT |
Yingdi Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 39 | |
| 40 | public: |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 41 | explicit ContactPanel(ndn::Ptr<ContactManager> contactManager, QWidget *parent = 0); |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 42 | |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 43 | ~ContactPanel(); |
Yingdi Yu | def9061 | 2013-10-09 22:34:42 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 45 | private: |
| 46 | void |
| 47 | openDB(); |
| 48 | |
| 49 | void |
| 50 | setKeychain(); |
| 51 | |
| 52 | void |
| 53 | setLocalPrefix(); |
| 54 | |
| 55 | void |
| 56 | onLocalPrefixVerified(ndn::Ptr<ndn::Data> data); |
| 57 | |
| 58 | void |
| 59 | onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest); |
| 60 | |
| 61 | void |
| 62 | onUnverified(ndn::Ptr<ndn::Data> data); |
| 63 | |
| 64 | void |
| 65 | onTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest); |
| 66 | |
| 67 | void |
| 68 | setInvitationListener(); |
| 69 | |
| 70 | void |
| 71 | onInvitation(ndn::Ptr<ndn::Interest> interest); |
| 72 | |
| 73 | void |
| 74 | onInvitationCertVerified(ndn::Ptr<ndn::Data> data, |
| 75 | const ndn::Name& interestName, |
| 76 | int inviterIndex); |
| 77 | |
| 78 | std::string |
| 79 | getRandomString(); |
| 80 | |
| 81 | void |
| 82 | popChatInvitation(const ndn::Name& interestName, |
| 83 | int inviterIndex, |
| 84 | const ndn::Name& inviterNameSpace, |
| 85 | ndn::Ptr<ndn::security::IdentityCertificate> certificate); |
| 86 | |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 87 | signals: |
| 88 | void |
| 89 | newInvitationReady(); |
| 90 | |
Yingdi Yu | 01a942b | 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 | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 96 | void |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 97 | updateDefaultIdentity(const QString& identity); |
| 98 | |
| 99 | void |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame] | 100 | openProfileEditor(); |
| 101 | |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 102 | void |
| 103 | openAddContactPanel(); |
| 104 | |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 105 | void |
| 106 | openSetAliasDialog(); |
Yingdi Yu | 100267f | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 107 | |
| 108 | void |
| 109 | openStartChatDialog(); |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 110 | |
| 111 | void |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 112 | openSettingDialog(); |
| 113 | |
| 114 | void |
Yingdi Yu | c4d08d2 | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 115 | openInvitationDialog(); |
| 116 | |
| 117 | void |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 118 | refreshContactList(); |
| 119 | |
| 120 | void |
| 121 | showContextMenu(const QPoint& pos); |
| 122 | |
Yingdi Yu | 100267f | 2013-10-21 15:01:40 -0700 | [diff] [blame] | 123 | void |
| 124 | startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer); |
| 125 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 126 | void |
| 127 | startChatroom2(const QString& chatroom, const QString& inviter); |
| 128 | |
| 129 | void |
| 130 | acceptInvitation(const ndn::Name& interestName, |
| 131 | const ndn::security::IdentityCertificate& identityCertificate, |
| 132 | QString inviter, |
| 133 | QString chatroom); |
| 134 | |
| 135 | void |
| 136 | rejectInvitation(const ndn::Name& interestName); |
| 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 |