blob: 3437e54aad2582898b5a92ef8c324b11be1f0787 [file] [log] [blame]
Yingdi Yud59b5932013-10-16 13:16:49 -07001/* -*- 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
Yingdi Yua4898752013-10-15 20:31:37 -070011#ifndef ADDCONTACTPANEL_H
12#define ADDCONTACTPANEL_H
13
14#include <QDialog>
Yingdi Yuc29fb982013-10-20 19:43:10 -070015#include <QMetaType>
16#include "warningdialog.h"
Yingdi Yua4898752013-10-15 20:31:37 -070017
Yingdi Yud59b5932013-10-16 13:16:49 -070018#ifndef Q_MOC_RUN
19#include "endorse-certificate.h"
Yingdi Yu79c25a22013-10-21 13:38:38 -070020#include "profile.h"
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070021#include "contact-manager.h"
Yingdi Yud59b5932013-10-16 13:16:49 -070022#endif
23
Yingdi Yua4898752013-10-15 20:31:37 -070024namespace Ui {
25class AddContactPanel;
26}
27
Yingdi Yuc29fb982013-10-20 19:43:10 -070028Q_DECLARE_METATYPE(ndn::Name)
29
30Q_DECLARE_METATYPE(EndorseCertificate)
31
Yingdi Yu8dacdf22013-11-05 23:06:43 -080032Q_DECLARE_METATYPE(ndn::Data)
33
Yingdi Yua4898752013-10-15 20:31:37 -070034class AddContactPanel : public QDialog
35{
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070036 Q_OBJECT
Yingdi Yua4898752013-10-15 20:31:37 -070037
38public:
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070039 explicit AddContactPanel(ndn::Ptr<ContactManager> contactManager,
40 QWidget *parent = 0);
41
42 ~AddContactPanel();
Yingdi Yua4898752013-10-15 20:31:37 -070043
Yingdi Yu8dacdf22013-11-05 23:06:43 -080044private:
45 void
46 displayContactInfo();
47
48 bool
49 isCorrectName(const ndn::Name& name);
50
Yingdi Yud59b5932013-10-16 13:16:49 -070051private slots:
52 void
53 onCancelClicked();
54
55 void
56 onSearchClicked();
57
58 void
59 onAddClicked();
60
Yingdi Yuaa8d7692013-10-18 17:05:02 -070061 void
Yingdi Yuc29fb982013-10-20 19:43:10 -070062 selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate);
63
64 void
65 selfEndorseCertificateFetchFailed(const ndn::Name& identity);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070066
Yingdi Yu8dacdf22013-11-05 23:06:43 -080067 void
68 onContactKeyFetched(const EndorseCertificate& endorseCertificate);
69
70 void
71 onContactKeyFetchFailed(const ndn::Name& identity);
72
73 void
74 onCollectEndorseFetched(const ndn::Data& data);
75
76 void
77 onCollectEndorseFetchFailed(const ndn::Name& identity);
78
Yingdi Yu79c25a22013-10-21 13:38:38 -070079signals:
80 void
81 newContactAdded();
82
Yingdi Yua4898752013-10-15 20:31:37 -070083private:
Yingdi Yud59b5932013-10-16 13:16:49 -070084 Ui::AddContactPanel *ui;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070085 ndn::Name m_searchIdentity;
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070086 ndn::Ptr<ContactManager> m_contactManager;
Yingdi Yuc29fb982013-10-20 19:43:10 -070087 WarningDialog* m_warningDialog;
Yingdi Yu79c25a22013-10-21 13:38:38 -070088 ndn::Ptr<EndorseCertificate> m_currentEndorseCertificate;
Yingdi Yu8dacdf22013-11-05 23:06:43 -080089 ndn::Ptr<ndn::Data> m_currentCollectEndorse;
90 bool m_currentEndorseCertificateReady;
91 bool m_currentCollectEndorseReady;
Yingdi Yua4898752013-10-15 20:31:37 -070092};
93
94#endif // ADDCONTACTPANEL_H