blob: 2264b9ef04840a8843e77106261bf2e6c26d3c8c [file] [log] [blame]
Yingdi Yu0269c872013-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 Yubf7517c2013-10-15 20:31:37 -070011#ifndef ADDCONTACTPANEL_H
12#define ADDCONTACTPANEL_H
13
14#include <QDialog>
Yingdi Yud95c5642013-10-20 19:43:10 -070015#include <QMetaType>
16#include "warningdialog.h"
Yingdi Yubf7517c2013-10-15 20:31:37 -070017
Yingdi Yu0269c872013-10-16 13:16:49 -070018#ifndef Q_MOC_RUN
19#include "endorse-certificate.h"
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070020#include "profile.h"
Yingdi Yu9236c432013-10-18 11:29:25 -070021#include "contact-manager.h"
Yingdi Yu0269c872013-10-16 13:16:49 -070022#endif
23
Yingdi Yubf7517c2013-10-15 20:31:37 -070024namespace Ui {
25class AddContactPanel;
26}
27
Yingdi Yud95c5642013-10-20 19:43:10 -070028Q_DECLARE_METATYPE(ndn::Name)
29
30Q_DECLARE_METATYPE(EndorseCertificate)
31
Yingdi Yub2e747d2013-11-05 23:06:43 -080032Q_DECLARE_METATYPE(ndn::Data)
33
Yingdi Yubf7517c2013-10-15 20:31:37 -070034class AddContactPanel : public QDialog
35{
Yingdi Yu9236c432013-10-18 11:29:25 -070036 Q_OBJECT
Yingdi Yubf7517c2013-10-15 20:31:37 -070037
38public:
Yingdi Yu76dd8002013-12-24 11:16:32 +080039 explicit AddContactPanel(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
Yingdi Yu9236c432013-10-18 11:29:25 -070040 QWidget *parent = 0);
41
42 ~AddContactPanel();
Yingdi Yubf7517c2013-10-15 20:31:37 -070043
Yingdi Yub2e747d2013-11-05 23:06:43 -080044private:
45 void
46 displayContactInfo();
47
48 bool
49 isCorrectName(const ndn::Name& name);
50
Yingdi Yuf8f572d2014-01-13 11:19:47 -080051 // static bool
52 // isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB);
Yingdi Yu76dd8002013-12-24 11:16:32 +080053
Yingdi Yu0269c872013-10-16 13:16:49 -070054private slots:
55 void
56 onCancelClicked();
57
58 void
59 onSearchClicked();
60
61 void
62 onAddClicked();
63
Yingdi Yu4685b1b2013-10-18 17:05:02 -070064 void
Yingdi Yud95c5642013-10-20 19:43:10 -070065 selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate);
66
67 void
68 selfEndorseCertificateFetchFailed(const ndn::Name& identity);
Yingdi Yu4685b1b2013-10-18 17:05:02 -070069
Yingdi Yub2e747d2013-11-05 23:06:43 -080070 void
71 onContactKeyFetched(const EndorseCertificate& endorseCertificate);
72
73 void
74 onContactKeyFetchFailed(const ndn::Name& identity);
75
76 void
77 onCollectEndorseFetched(const ndn::Data& data);
78
79 void
80 onCollectEndorseFetchFailed(const ndn::Name& identity);
81
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070082signals:
83 void
84 newContactAdded();
85
Yingdi Yubf7517c2013-10-15 20:31:37 -070086private:
Yingdi Yu93adb1a2014-01-16 10:30:26 -080087
Yingdi Yu0269c872013-10-16 13:16:49 -070088 Ui::AddContactPanel *ui;
Yingdi Yu4685b1b2013-10-18 17:05:02 -070089 ndn::Name m_searchIdentity;
Yingdi Yu76dd8002013-12-24 11:16:32 +080090 ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
Yingdi Yud95c5642013-10-20 19:43:10 -070091 WarningDialog* m_warningDialog;
Yingdi Yu76dd8002013-12-24 11:16:32 +080092 ndn::ptr_lib::shared_ptr<EndorseCertificate> m_currentEndorseCertificate;
93 ndn::ptr_lib::shared_ptr<ndn::Data> m_currentCollectEndorse;
Yingdi Yub2e747d2013-11-05 23:06:43 -080094 bool m_currentEndorseCertificateReady;
95 bool m_currentCollectEndorseReady;
Yingdi Yubf7517c2013-10-15 20:31:37 -070096};
97
98#endif // ADDCONTACTPANEL_H