Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -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 |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 4 | * Yingdi Yu |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 5 | * |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 6 | * BSD license, See the LICENSE file for more information |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 7 | * |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 8 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 9 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 10 | * Yingdi Yu <yingdi@cs.ucla.edu> |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
Zhenkai Zhu | 6d589aa | 2012-05-29 17:34:35 -0700 | [diff] [blame] | 13 | #ifndef CHATDIALOG_H |
| 14 | #define CHATDIALOG_H |
Alexander Afanasyev | f829f4d | 2013-05-07 15:59:36 -0700 | [diff] [blame] | 15 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 16 | #include <QDialog> |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 17 | #include <QTextTable> |
| 18 | #include <QStringListModel> |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 19 | #include <QSystemTrayIcon> |
Yingdi Yu | 702d6f1 | 2013-11-07 17:00:54 -0800 | [diff] [blame] | 20 | #include <QMenu> |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 21 | |
| 22 | #include "invitelistdialog.h" |
Alexander Afanasyev | f829f4d | 2013-05-07 15:59:36 -0700 | [diff] [blame] | 23 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 24 | #ifndef Q_MOC_RUN |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 25 | #include "contact-item.h" |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 26 | #include "chatbuf.pb.h" |
| 27 | #include "digesttreescene.h" |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 28 | #include <sync-socket.h> |
| 29 | #include <sync-seq-no.h> |
| 30 | #include <ndn-cpp-dev/security/key-chain.hpp> |
| 31 | #ifdef WITH_SECURITY |
| 32 | #include "validator-invitation.h" |
| 33 | #include <validator-sync.h> |
| 34 | #else |
| 35 | #include <ndn-cpp-dev/security/validator-null.hpp> |
| 36 | #endif |
Yingdi Yu | 6eabbd7 | 2013-12-27 08:44:12 +0800 | [diff] [blame] | 37 | |
| 38 | #include <boost/thread/locks.hpp> |
| 39 | #include <boost/thread/recursive_mutex.hpp> |
| 40 | #include <boost/thread/thread.hpp> |
Alexander Afanasyev | f829f4d | 2013-05-07 15:59:36 -0700 | [diff] [blame] | 41 | #endif |
| 42 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 43 | typedef ndn::function<void()> OnEventualTimeout; |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 44 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 45 | #define MAX_HISTORY_ENTRY 20 |
| 46 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 47 | namespace Ui { |
| 48 | class ChatDialog; |
| 49 | } |
Zhenkai Zhu | 6d589aa | 2012-05-29 17:34:35 -0700 | [diff] [blame] | 50 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 51 | class ChatDialog : public QDialog |
Zhenkai Zhu | 6d589aa | 2012-05-29 17:34:35 -0700 | [diff] [blame] | 52 | { |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 53 | Q_OBJECT |
Zhenkai Zhu | 6d589aa | 2012-05-29 17:34:35 -0700 | [diff] [blame] | 54 | |
| 55 | public: |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 56 | explicit ChatDialog(ndn::shared_ptr<chronos::ContactManager> contactManager, |
| 57 | ndn::shared_ptr<ndn::Face> face, |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 58 | const ndn::Name& chatroomPrefix, |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 59 | const ndn::Name& localPrefix, |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 60 | const ndn::Name& defaultIdentity, |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 61 | const std::string& nick, |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 62 | QWidget *parent = 0); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 63 | |
Zhenkai Zhu | 82a6275 | 2012-06-04 17:11:04 -0700 | [diff] [blame] | 64 | ~ChatDialog(); |
Zhenkai Zhu | b45e38a | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 65 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 66 | const ndn::Name& |
| 67 | getChatroomPrefix() const |
| 68 | { return m_chatroomPrefix; } |
Zhenkai Zhu | 3a008fc | 2012-06-08 17:36:39 -0700 | [diff] [blame] | 69 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 70 | const ndn::Name& |
| 71 | getLocalPrefix() const |
| 72 | { return m_localPrefix; } |
| 73 | |
| 74 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 75 | sendInvitation(ndn::shared_ptr<chronos::ContactItem> contact, bool isIntroducer); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 76 | |
| 77 | void |
| 78 | addChatDataRule(const ndn::Name& prefix, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 79 | const ndn::IdentityCertificate& identityCertificate, |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 80 | bool isIntroducer); |
| 81 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 82 | void |
| 83 | addTrustAnchor(const chronos::EndorseCertificate& selfEndorseCertificate); |
| 84 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 85 | void |
| 86 | appendMessage(const SyncDemo::ChatMessage msg, bool isHistory = false); |
| 87 | |
| 88 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 89 | processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>&, Sync::SyncSocket *); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 90 | |
| 91 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 92 | processDataWrapper(const ndn::shared_ptr<const ndn::Data>& data); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 93 | |
| 94 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 95 | processDataNoShowWrapper(const ndn::shared_ptr<const ndn::Data>& data); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 96 | |
| 97 | void |
| 98 | processRemoveWrapper(std::string); |
Zhenkai Zhu | 10ccb5a | 2012-06-04 21:55:14 -0700 | [diff] [blame] | 99 | |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 100 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 101 | publishIntroCert(const ndn::IdentityCertificate& dskCertificate, bool isIntroducer); |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 102 | |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 103 | protected: |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 104 | void |
| 105 | closeEvent(QCloseEvent *e); |
| 106 | |
| 107 | void |
| 108 | changeEvent(QEvent *e); |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 109 | |
Zhenkai Zhu | b45e38a | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 110 | private: |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 111 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 112 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 113 | initializeSetting(); |
| 114 | |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 115 | QString |
| 116 | getRandomString(); |
| 117 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 118 | void |
| 119 | updateLabels(); |
| 120 | |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 121 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 122 | initializeSync(); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 123 | |
| 124 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 125 | onTargetData(const ndn::Interest& interest, |
| 126 | const ndn::Data& data, |
| 127 | const ndn::OnDataValidated& onValidated, |
| 128 | const ndn::OnDataValidationFailed& onValidationFailed) |
| 129 | { m_invitationValidator->validate(data, onValidated, onValidationFailed); } |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 130 | |
| 131 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 132 | onTargetTimeout(const ndn::Interest& interest, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 133 | int retry, |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 134 | const ndn::OnDataValidated& onValidated, |
| 135 | const ndn::OnDataValidationFailed& onValidationFailed, |
| 136 | const OnEventualTimeout& timeoutNotify) |
| 137 | { |
| 138 | if(retry > 0) |
| 139 | sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, retry-1); |
| 140 | else |
| 141 | timeoutNotify(); |
| 142 | } |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 143 | |
| 144 | void |
| 145 | sendInterest(const ndn::Interest& interest, |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 146 | const ndn::OnDataValidated& onValidated, |
| 147 | const ndn::OnDataValidationFailed& onValidationFailed, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 148 | const OnEventualTimeout& timeoutNotify, |
Yingdi Yu | 68de61d | 2014-01-16 19:13:03 -0800 | [diff] [blame] | 149 | int retry = 1); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 150 | |
| 151 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 152 | onInviteReplyValidated(const ndn::shared_ptr<const ndn::Data>& data, |
| 153 | const ndn::Name& identity, |
| 154 | bool isIntroduce); |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 155 | |
| 156 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 157 | onInviteReplyValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 158 | const ndn::Name& identity); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 159 | |
| 160 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 161 | onInviteReplyTimeout(const ndn::Name& identity); |
| 162 | |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 163 | |
| 164 | void |
| 165 | invitationRejected(const ndn::Name& identity); |
| 166 | |
| 167 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 168 | invitationAccepted(const ndn::Name& identity, |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 169 | ndn::shared_ptr<const ndn::Data> data, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 170 | const std::string& inviteePrefix, |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 171 | bool isIntroducer); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 172 | |
| 173 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 174 | onLocalPrefix(const ndn::Interest& interest, |
| 175 | ndn::Data& data); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 176 | |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 177 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 178 | onLocalPrefixTimeout(const ndn::Interest& interest); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 179 | |
| 180 | // void |
| 181 | // fetchHistory(std::string name); |
| 182 | |
| 183 | void |
| 184 | formChatMessage(const QString &text, SyncDemo::ChatMessage &msg); |
| 185 | |
| 186 | void |
| 187 | formControlMessage(SyncDemo::ChatMessage &msg, SyncDemo::ChatMessage::ChatMessageType type); |
| 188 | |
| 189 | void |
| 190 | sendMsg(SyncDemo::ChatMessage &msg); |
| 191 | |
| 192 | void |
| 193 | resizeEvent(QResizeEvent *); |
| 194 | |
| 195 | void |
| 196 | showEvent(QShowEvent *); |
| 197 | |
| 198 | void |
| 199 | fitView(); |
| 200 | |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 201 | void |
| 202 | createActions(); |
| 203 | |
| 204 | void |
| 205 | createTrayIcon(); |
| 206 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 207 | QString |
| 208 | formatTime(time_t); |
| 209 | |
| 210 | void |
| 211 | printTimeInCell(QTextTable *, time_t); |
| 212 | |
| 213 | void |
| 214 | disableTreeDisplay(); |
| 215 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 216 | signals: |
| 217 | void |
| 218 | dataReceived(ndn::shared_ptr<const ndn::Data> data, bool show, bool isHistory); |
| 219 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 220 | void |
| 221 | treeUpdated(const std::vector<Sync::MissingDataInfo>); |
| 222 | |
| 223 | void |
| 224 | removeReceived(QString prefix); |
| 225 | |
Yingdi Yu | 4694828 | 2013-11-06 18:43:31 -0800 | [diff] [blame] | 226 | void |
| 227 | closeChatDialog(const ndn::Name& chatroomPrefix); |
| 228 | |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 229 | void |
| 230 | noNdnConnection(const QString& msg); |
Yingdi Yu | 0aca265 | 2013-11-10 10:47:44 -0800 | [diff] [blame] | 231 | |
| 232 | void |
| 233 | inivationRejection(const QString& msg); |
Yingdi Yu | 8e13583 | 2013-11-09 20:12:31 -0800 | [diff] [blame] | 234 | |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 235 | void |
| 236 | triggerHello(); |
| 237 | |
| 238 | void |
| 239 | triggerJoin(); |
| 240 | |
| 241 | void |
| 242 | triggerLeave(); |
| 243 | |
| 244 | void |
| 245 | triggerReplot(); |
| 246 | |
| 247 | void |
| 248 | triggerEnableTreeDisplay(); |
| 249 | |
| 250 | void |
| 251 | triggerReap(); |
| 252 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 253 | public slots: |
| 254 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 255 | processTreeUpdate(const std::vector<Sync::MissingDataInfo>&); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 256 | |
| 257 | void |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 258 | processData(ndn::shared_ptr<const ndn::Data> data, bool show, bool isHistory); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 259 | |
| 260 | void |
| 261 | processRemove(QString prefix); |
| 262 | |
| 263 | private slots: |
| 264 | void |
| 265 | returnPressed(); |
| 266 | |
| 267 | void |
| 268 | treeButtonPressed(); |
| 269 | |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 270 | void |
| 271 | settingUpdated(QString, QString, QString); |
| 272 | |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 273 | void |
| 274 | sendJoinWrapper(); |
| 275 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 276 | void |
| 277 | sendJoin(); |
| 278 | |
| 279 | void |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 280 | sendHelloWrapper(); |
| 281 | |
| 282 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 283 | sendHello(); |
| 284 | |
| 285 | void |
| 286 | sendLeave(); |
| 287 | |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 288 | void |
| 289 | sendLeaveWrapper(); |
| 290 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 291 | void |
| 292 | replot(); |
| 293 | |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 294 | void |
| 295 | replotWrapper(); |
| 296 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 297 | void |
| 298 | updateRosterList(QStringList); |
| 299 | |
| 300 | void |
| 301 | enableTreeDisplay(); |
| 302 | |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 303 | void |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 304 | enableTreeDisplayWrapper(); |
| 305 | |
| 306 | void |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 307 | updateLocalPrefix(); |
| 308 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 309 | void |
| 310 | summonReaper(); |
| 311 | |
| 312 | void |
| 313 | reap(); |
| 314 | |
Yingdi Yu | 3a01485 | 2014-02-11 22:54:11 -0800 | [diff] [blame^] | 315 | void |
| 316 | reapWrapper(); |
| 317 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 318 | void |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 319 | iconActivated(QSystemTrayIcon::ActivationReason reason); |
| 320 | |
| 321 | void |
| 322 | messageClicked(); |
| 323 | |
| 324 | void |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 325 | showMessage(QString, QString); |
| 326 | |
| 327 | void |
| 328 | openInviteListDialog(); |
| 329 | |
| 330 | void |
| 331 | sendInvitationWrapper(QString, bool); |
Yingdi Yu | 702d6f1 | 2013-11-07 17:00:54 -0800 | [diff] [blame] | 332 | |
| 333 | void |
| 334 | quit(); |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 335 | |
| 336 | private: |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 337 | Ui::ChatDialog *ui; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 338 | ndn::shared_ptr<chronos::ContactManager> m_contactManager; |
| 339 | ndn::shared_ptr<ndn::Face> m_face; |
| 340 | ndn::shared_ptr<boost::asio::io_service> m_ioService; |
| 341 | |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 342 | ndn::Name m_chatroomPrefix; |
| 343 | ndn::Name m_localPrefix; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 344 | ndn::Name m_localChatPrefix; |
Yingdi Yu | eda39aa | 2013-10-23 23:07:29 -0700 | [diff] [blame] | 345 | ndn::Name m_defaultIdentity; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 346 | User m_user; |
| 347 | std::string m_nick; |
Yingdi Yu | a66183f | 2013-11-10 10:32:18 -0800 | [diff] [blame] | 348 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 349 | ndn::Scheduler m_scheduler; |
| 350 | ndn::EventId m_replotEventId; |
| 351 | |
| 352 | #ifndef WITH_SECURITY |
| 353 | ndn::shared_ptr<ndn::Validator> m_invitationValidator; |
| 354 | ndn::shared_ptr<ndn::Validator> m_syncValidator; |
| 355 | #else |
| 356 | ndn::shared_ptr<chronos::ValidatorInvitation> m_invitationValidator; |
| 357 | ndn::shared_ptr<Sync::ValidatorSync> m_syncValidator; |
| 358 | #endif |
| 359 | ndn::shared_ptr<ndn::KeyChain> m_keyChain; |
Yingdi Yu | 6eabbd7 | 2013-12-27 08:44:12 +0800 | [diff] [blame] | 360 | |
Yingdi Yu | a66183f | 2013-11-10 10:32:18 -0800 | [diff] [blame] | 361 | ndn::Name m_newLocalPrefix; |
| 362 | bool m_newLocalPrefixReady; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 363 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 364 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 365 | Sync::SyncSocket *m_sock; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 366 | uint64_t m_session; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 367 | DigestTreeScene *m_scene; |
| 368 | boost::recursive_mutex m_msgMutex; |
| 369 | boost::recursive_mutex m_sceneMutex; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 370 | int64_t m_lastMsgTime; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 371 | int m_randomizedInterval; |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 372 | |
| 373 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 374 | QStringListModel *m_rosterModel; |
Yingdi Yu | 83eae84 | 2013-11-06 22:07:38 -0800 | [diff] [blame] | 375 | QSystemTrayIcon *trayIcon; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 376 | |
Yingdi Yu | 702d6f1 | 2013-11-07 17:00:54 -0800 | [diff] [blame] | 377 | QAction *minimizeAction; |
| 378 | QAction *maximizeAction; |
| 379 | QAction *restoreAction; |
Yingdi Yu | fdb8ab8 | 2013-11-10 01:38:21 -0800 | [diff] [blame] | 380 | QAction *updateLocalPrefixAction; |
Yingdi Yu | 702d6f1 | 2013-11-07 17:00:54 -0800 | [diff] [blame] | 381 | QAction *quitAction; |
| 382 | QMenu *trayIconMenu; |
| 383 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 384 | bool m_joined; |
| 385 | |
| 386 | QList<QString> m_zombieList; |
| 387 | int m_zombieIndex; |
| 388 | |
| 389 | InviteListDialog* m_inviteListDialog; |
Zhenkai Zhu | 6d589aa | 2012-05-29 17:34:35 -0700 | [diff] [blame] | 390 | }; |
Yingdi Yu | 5b98913 | 2013-10-23 14:03:09 -0700 | [diff] [blame] | 391 | |
| 392 | #endif // ChatDIALOG_H |