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> |
| 17 | #include "warningdialog.h" |
| 18 | |
| 19 | |
| 20 | #ifndef Q_MOC_RUN |
| 21 | #include <ndn.cxx/security/certificate/identity-certificate.h> |
| 22 | #include <boost/thread/locks.hpp> |
| 23 | #include <boost/thread/recursive_mutex.hpp> |
| 24 | #include "profile.h" |
| 25 | #include "contact-manager.h" |
| 26 | #endif |
| 27 | |
| 28 | namespace Ui { |
| 29 | class BrowseContactDialog; |
| 30 | } |
| 31 | |
| 32 | class BrowseContactDialog : public QDialog |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | |
| 36 | public: |
| 37 | explicit BrowseContactDialog(ndn::Ptr<ContactManager> contactManager, |
| 38 | QWidget *parent = 0); |
| 39 | |
| 40 | ~BrowseContactDialog(); |
| 41 | |
| 42 | protected: |
| 43 | typedef boost::recursive_mutex RecLock; |
| 44 | typedef boost::unique_lock<RecLock> UniqueRecLock; |
| 45 | |
| 46 | private: |
| 47 | std::vector<std::string> |
| 48 | getCertName(); |
| 49 | |
| 50 | void |
| 51 | updateCertificateMap(bool filter = false); |
| 52 | |
| 53 | void |
| 54 | updateCertificateFetchingStatus(int count); |
| 55 | |
| 56 | void |
| 57 | fetchCertificate(); |
| 58 | |
| 59 | private slots: |
| 60 | void |
| 61 | updateSelection(const QItemSelection &selected, |
| 62 | const QItemSelection &deselected); |
| 63 | |
| 64 | void |
| 65 | onCertificateFetched(const ndn::security::IdentityCertificate& identityCertificate); |
| 66 | |
| 67 | void |
| 68 | onCertificateFetchFailed(const ndn::Name& identity); |
| 69 | |
| 70 | void |
| 71 | onWarning(QString msg); |
| 72 | |
| 73 | void |
| 74 | onAddClicked(); |
| 75 | |
| 76 | void |
| 77 | onCancelClicked(); |
| 78 | |
| 79 | public slots: |
| 80 | void |
| 81 | refreshList(); |
| 82 | |
| 83 | signals: |
| 84 | void |
| 85 | newContactAdded(); |
| 86 | |
| 87 | private: |
| 88 | Ui::BrowseContactDialog *ui; |
| 89 | |
| 90 | ndn::Ptr<ContactManager> m_contactManager; |
| 91 | |
| 92 | WarningDialog* m_warningDialog; |
| 93 | QStringListModel* m_contactListModel; |
| 94 | |
| 95 | QStringList m_contactList; |
| 96 | std::vector<ndn::Name> m_contactNameList; |
| 97 | std::vector<ndn::Name> m_certificateNameList; |
| 98 | std::map<ndn::Name, ndn::security::IdentityCertificate> m_certificateMap; |
| 99 | std::map<ndn::Name, Profile> m_profileMap; |
| 100 | |
| 101 | RecLock m_mutex; |
| 102 | |
| 103 | |
| 104 | }; |
| 105 | |
| 106 | #endif // BROWSECONTACTDIALOG_H |