Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [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 | |
| 11 | |
| 12 | #ifndef BROWSECONTACTDIALOG_H |
| 13 | #define BROWSECONTACTDIALOG_H |
| 14 | |
| 15 | #include <QDialog> |
| 16 | #include <QStringListModel> |
Yingdi Yu | e433a50 | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 17 | #include <QCloseEvent> |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 18 | #include "warningdialog.h" |
| 19 | |
| 20 | |
| 21 | #ifndef Q_MOC_RUN |
Yingdi Yu | 93adb1a | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 22 | #include <ndn-cpp/security/identity-certificate.hpp> |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 23 | #include <boost/thread/locks.hpp> |
| 24 | #include <boost/thread/recursive_mutex.hpp> |
| 25 | #include "profile.h" |
| 26 | #include "contact-manager.h" |
| 27 | #endif |
| 28 | |
| 29 | namespace Ui { |
| 30 | class BrowseContactDialog; |
| 31 | } |
| 32 | |
| 33 | class BrowseContactDialog : public QDialog |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | public: |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 38 | explicit BrowseContactDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager, |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 39 | QWidget *parent = 0); |
| 40 | |
| 41 | ~BrowseContactDialog(); |
| 42 | |
| 43 | protected: |
| 44 | typedef boost::recursive_mutex RecLock; |
| 45 | typedef boost::unique_lock<RecLock> UniqueRecLock; |
| 46 | |
| 47 | private: |
Alexander Afanasyev | e5b5513 | 2013-11-09 23:07:48 -0800 | [diff] [blame] | 48 | void |
| 49 | getCertNames(std::vector<std::string> &names); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 50 | |
| 51 | void |
| 52 | updateCertificateMap(bool filter = false); |
| 53 | |
| 54 | void |
| 55 | updateCertificateFetchingStatus(int count); |
| 56 | |
| 57 | void |
| 58 | fetchCertificate(); |
| 59 | |
Yingdi Yu | e433a50 | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 60 | protected: |
| 61 | void |
| 62 | closeEvent(QCloseEvent *e); |
| 63 | |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 64 | private slots: |
| 65 | void |
| 66 | updateSelection(const QItemSelection &selected, |
| 67 | const QItemSelection &deselected); |
| 68 | |
| 69 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 70 | onCertificateFetched(const ndn::IdentityCertificate& identityCertificate); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 71 | |
| 72 | void |
| 73 | onCertificateFetchFailed(const ndn::Name& identity); |
| 74 | |
| 75 | void |
| 76 | onWarning(QString msg); |
| 77 | |
| 78 | void |
| 79 | onAddClicked(); |
| 80 | |
| 81 | void |
Yingdi Yu | 9d7dfc2 | 2013-11-10 17:59:58 -0800 | [diff] [blame] | 82 | onDirectAddClicked(); |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 83 | |
| 84 | public slots: |
| 85 | void |
| 86 | refreshList(); |
| 87 | |
| 88 | signals: |
| 89 | void |
| 90 | newContactAdded(); |
| 91 | |
Yingdi Yu | 9d7dfc2 | 2013-11-10 17:59:58 -0800 | [diff] [blame] | 92 | void |
| 93 | directAddClicked(); |
| 94 | |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 95 | private: |
| 96 | Ui::BrowseContactDialog *ui; |
| 97 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 98 | ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager; |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 99 | |
| 100 | WarningDialog* m_warningDialog; |
| 101 | QStringListModel* m_contactListModel; |
| 102 | |
| 103 | QStringList m_contactList; |
| 104 | std::vector<ndn::Name> m_contactNameList; |
| 105 | std::vector<ndn::Name> m_certificateNameList; |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 106 | std::map<ndn::Name, ndn::IdentityCertificate, ndn::Name::BreadthFirstLess> m_certificateMap; |
| 107 | std::map<ndn::Name, Profile, ndn::Name::BreadthFirstLess> m_profileMap; |
Yingdi Yu | ae8217c | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 108 | |
| 109 | RecLock m_mutex; |
| 110 | |
| 111 | |
| 112 | }; |
| 113 | |
| 114 | #endif // BROWSECONTACTDIALOG_H |