| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| /* |
| * Copyright (c) 2013, Regents of the University of California |
| * Yingdi Yu |
| * |
| * BSD license, See the LICENSE file for more information |
| * |
| * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| */ |
| |
| #ifndef CHRONOS_CONTROLLER_H |
| #define CHRONOS_CONTROLLER_H |
| |
| #include <QDialog> |
| #include <QMenu> |
| #include <QSystemTrayIcon> |
| #include <QtSql/QSqlDatabase> |
| |
| #include "setting-dialog.h" |
| #include "start-chat-dialog.h" |
| #include "profile-editor.h" |
| #include "invitation-dialog.h" |
| #include "contact-panel.h" |
| #include "browse-contact-dialog.h" |
| #include "add-contact-panel.h" |
| #include "chat-dialog.h" |
| |
| #ifndef Q_MOC_RUN |
| #include "contact-manager.h" |
| #include "validator-invitation.h" |
| #include <ndn-cpp-dev/face.hpp> |
| #include <ndn-cpp-dev/security/key-chain.hpp> |
| #endif |
| |
| namespace chronos { |
| |
| class Controller : public QDialog |
| { |
| Q_OBJECT |
| |
| public: // public methods |
| Controller(ndn::shared_ptr<ndn::Face> face, |
| QWidget* parent = 0); |
| |
| virtual |
| ~Controller(); |
| |
| private: // private methods |
| std::string |
| getDBName(); |
| |
| void |
| openDB(); |
| |
| void |
| initialize(); |
| |
| void |
| setInvitationListener(); |
| |
| void |
| loadConf(); |
| |
| void |
| saveConf(); |
| |
| void |
| createActions(); |
| |
| void |
| createTrayIcon(); |
| |
| void |
| updateMenu(); |
| |
| void |
| onLocalPrefix(const ndn::Interest& interest, ndn::Data& data); |
| |
| void |
| onLocalPrefixTimeout(const ndn::Interest& interest); |
| |
| void |
| onInvitationInterest(const ndn::Name& prefix, const ndn::Interest& interest, size_t routingPrefixOffset); |
| |
| void |
| onInvitationRegisterFailed(const ndn::Name& prefix, const std::string& failInfo); |
| |
| void |
| onInvitationValidated(const ndn::shared_ptr<const ndn::Interest>& interest); |
| |
| void |
| onInvitationValidationFailed(const ndn::shared_ptr<const ndn::Interest>& interest, std::string failureInfo); |
| |
| std::string |
| getRandomString(); |
| |
| ndn::Name |
| getInvitationRoutingPrefix(); |
| |
| void |
| addChatDialog(const QString& chatroomName, ChatDialog* chatDialog); |
| |
| signals: |
| void |
| closeDBModule(); |
| |
| void |
| localPrefixUpdated(const QString& localPrefix); |
| |
| void |
| identityUpdated(const QString& identity); |
| |
| void |
| refreshBrowseContact(); |
| |
| private slots: |
| void |
| onIdentityUpdated(const QString& identity); |
| |
| void |
| onIdentityUpdatedContinued(); |
| |
| void |
| onContactIdListReady(const QStringList& list); |
| |
| void |
| onNickUpdated(const QString& nick); |
| |
| void |
| onLocalPrefixUpdated(const QString& localPrefix); |
| |
| void |
| onStartChatAction(); |
| |
| void |
| onSettingsAction(); |
| |
| void |
| onProfileEditorAction(); |
| |
| void |
| onAddContactAction(); |
| |
| void |
| onContactListAction(); |
| |
| void |
| onDirectAdd(); |
| |
| void |
| onUpdateLocalPrefixAction(); |
| |
| void |
| onMinimizeAction(); |
| |
| void |
| onQuitAction(); |
| |
| void |
| onStartChatroom(const QString& chatroom, bool secured); |
| |
| void |
| onInvitationResponded(const ndn::Name& invitationName, bool accepted); |
| |
| void |
| onShowChatMessage(const QString& chatroomName, const QString& from, const QString& data); |
| |
| void |
| onRemoveChatDialog(const QString& chatroom); |
| |
| void |
| onWarning(const QString& msg); |
| |
| void |
| onError(const QString& msg); |
| |
| private: // private member |
| typedef std::map<std::string, QAction*> ChatActionList; |
| typedef std::map<std::string, ChatDialog*> ChatDialogList; |
| |
| // Communication |
| ndn::shared_ptr<ndn::Face> m_face; |
| ndn::Name m_localPrefix; |
| const ndn::RegisteredPrefixId* m_invitationListenerId; |
| |
| // Contact Manager |
| ContactManager m_contactManager; |
| |
| // Tray |
| QAction* m_startChatroom; |
| QAction* m_minimizeAction; |
| QAction* m_settingsAction; |
| QAction* m_editProfileAction; |
| QAction* m_contactListAction; |
| QAction* m_addContactAction; |
| QAction* m_updateLocalPrefixAction; |
| QAction* m_quitAction; |
| QMenu* m_trayIconMenu; |
| QMenu* m_closeMenu; |
| QSystemTrayIcon* m_trayIcon; |
| ChatActionList m_chatActionList; |
| ChatActionList m_closeActionList; |
| |
| // Dialogs |
| SettingDialog* m_settingDialog; |
| StartChatDialog* m_startChatDialog; |
| ProfileEditor* m_profileEditor; |
| InvitationDialog* m_invitationDialog; |
| ContactPanel* m_contactPanel; |
| BrowseContactDialog* m_browseContactDialog; |
| AddContactPanel* m_addContactPanel; |
| ChatDialogList m_chatDialogList; |
| |
| // Conf |
| ndn::Name m_identity; |
| std::string m_nick; |
| QSqlDatabase m_db; |
| |
| // Security related; |
| ndn::KeyChain m_keyChain; |
| chronos::ValidatorInvitation m_validator; |
| }; |
| |
| } // namespace chronos |
| |
| #endif //CHRONOS_CONTROLLER_H |