Yingdi Yu | 908f841 | 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 | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame^] | 17 | #include <QCloseEvent> |
Yingdi Yu | 908f841 | 2013-11-09 00:03:26 -0800 | [diff] [blame] | 18 | #include "warningdialog.h" |
| 19 | |
| 20 | |
| 21 | #ifndef Q_MOC_RUN |
| 22 | #include <ndn.cxx/security/certificate/identity-certificate.h> |
| 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: |
| 38 | explicit BrowseContactDialog(ndn::Ptr<ContactManager> contactManager, |
| 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 | 19aec3c | 2013-11-09 23:07:48 -0800 | [diff] [blame] | 48 | void |
| 49 | getCertNames(std::vector<std::string> &names); |
Yingdi Yu | 908f841 | 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 | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame^] | 60 | protected: |
| 61 | void |
| 62 | closeEvent(QCloseEvent *e); |
| 63 | |
Yingdi Yu | 908f841 | 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 |
| 70 | onCertificateFetched(const ndn::security::IdentityCertificate& identityCertificate); |
| 71 | |
| 72 | void |
| 73 | onCertificateFetchFailed(const ndn::Name& identity); |
| 74 | |
| 75 | void |
| 76 | onWarning(QString msg); |
| 77 | |
| 78 | void |
| 79 | onAddClicked(); |
| 80 | |
| 81 | void |
| 82 | onCancelClicked(); |
| 83 | |
| 84 | public slots: |
| 85 | void |
| 86 | refreshList(); |
| 87 | |
| 88 | signals: |
| 89 | void |
| 90 | newContactAdded(); |
| 91 | |
| 92 | private: |
| 93 | Ui::BrowseContactDialog *ui; |
| 94 | |
| 95 | ndn::Ptr<ContactManager> m_contactManager; |
| 96 | |
| 97 | WarningDialog* m_warningDialog; |
| 98 | QStringListModel* m_contactListModel; |
| 99 | |
| 100 | QStringList m_contactList; |
| 101 | std::vector<ndn::Name> m_contactNameList; |
| 102 | std::vector<ndn::Name> m_certificateNameList; |
| 103 | std::map<ndn::Name, ndn::security::IdentityCertificate> m_certificateMap; |
| 104 | std::map<ndn::Name, Profile> m_profileMap; |
| 105 | |
| 106 | RecLock m_mutex; |
| 107 | |
| 108 | |
| 109 | }; |
| 110 | |
| 111 | #endif // BROWSECONTACTDIALOG_H |