blob: 9369d0504da666c5c0b157bbccf1b703c3bcafee [file] [log] [blame]
Yingdi Yuae8217c2013-11-09 00:03:26 -08001/* -*- 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 Yue433a502013-11-10 01:34:57 -080017#include <QCloseEvent>
Yingdi Yuae8217c2013-11-09 00:03:26 -080018#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
29namespace Ui {
30class BrowseContactDialog;
31}
32
33class BrowseContactDialog : public QDialog
34{
35 Q_OBJECT
36
37public:
38 explicit BrowseContactDialog(ndn::Ptr<ContactManager> contactManager,
39 QWidget *parent = 0);
40
41 ~BrowseContactDialog();
42
43protected:
44 typedef boost::recursive_mutex RecLock;
45 typedef boost::unique_lock<RecLock> UniqueRecLock;
46
47private:
Alexander Afanasyeve5b55132013-11-09 23:07:48 -080048 void
49 getCertNames(std::vector<std::string> &names);
Yingdi Yuae8217c2013-11-09 00:03:26 -080050
51 void
52 updateCertificateMap(bool filter = false);
53
54 void
55 updateCertificateFetchingStatus(int count);
56
57 void
58 fetchCertificate();
59
Yingdi Yue433a502013-11-10 01:34:57 -080060protected:
61 void
62 closeEvent(QCloseEvent *e);
63
Yingdi Yuae8217c2013-11-09 00:03:26 -080064private 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
Yingdi Yu9d7dfc22013-11-10 17:59:58 -080082 onDirectAddClicked();
Yingdi Yuae8217c2013-11-09 00:03:26 -080083
84public slots:
85 void
86 refreshList();
87
88signals:
89 void
90 newContactAdded();
91
Yingdi Yu9d7dfc22013-11-10 17:59:58 -080092 void
93 directAddClicked();
94
Yingdi Yuae8217c2013-11-09 00:03:26 -080095private:
96 Ui::BrowseContactDialog *ui;
97
98 ndn::Ptr<ContactManager> m_contactManager;
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;
106 std::map<ndn::Name, ndn::security::IdentityCertificate> m_certificateMap;
107 std::map<ndn::Name, Profile> m_profileMap;
108
109 RecLock m_mutex;
110
111
112};
113
114#endif // BROWSECONTACTDIALOG_H