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