blob: a65635a4f2810d23a9be009706ff5e803669aedf [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
Yingdi Yua1a688f2014-02-06 18:09:22 -080030Q_DECLARE_METATYPE(chronos::EndorseCertificate)
Yingdi Yuc29fb982013-10-20 19:43:10 -070031
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 Yua1a688f2014-02-06 18:09:22 -080039 explicit AddContactPanel(ndn::shared_ptr<chronos::ContactManager> contactManager,
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070040 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 Yuc9ffa9f2014-01-13 11:19:47 -080051 // static bool
52 // isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB);
Yingdi Yu64206112013-12-24 11:16:32 +080053
Yingdi Yud59b5932013-10-16 13:16:49 -070054private slots:
55 void
56 onCancelClicked();
57
58 void
59 onSearchClicked();
60
61 void
62 onAddClicked();
63
Yingdi Yuaa8d7692013-10-18 17:05:02 -070064 void
Yingdi Yua1a688f2014-02-06 18:09:22 -080065 selfEndorseCertificateFetched(const chronos::EndorseCertificate& endorseCertificate);
Yingdi Yuc29fb982013-10-20 19:43:10 -070066
67 void
68 selfEndorseCertificateFetchFailed(const ndn::Name& identity);
Yingdi Yuaa8d7692013-10-18 17:05:02 -070069
Yingdi Yu8dacdf22013-11-05 23:06:43 -080070 void
Yingdi Yua1a688f2014-02-06 18:09:22 -080071 onContactKeyFetched(const chronos::EndorseCertificate& endorseCertificate);
Yingdi Yu8dacdf22013-11-05 23:06:43 -080072
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 Yu79c25a22013-10-21 13:38:38 -070082signals:
83 void
84 newContactAdded();
85
Yingdi Yua4898752013-10-15 20:31:37 -070086private:
Yingdi Yueaa84e22014-01-16 10:30:26 -080087
Yingdi Yud59b5932013-10-16 13:16:49 -070088 Ui::AddContactPanel *ui;
Yingdi Yuaa8d7692013-10-18 17:05:02 -070089 ndn::Name m_searchIdentity;
Yingdi Yua1a688f2014-02-06 18:09:22 -080090 ndn::shared_ptr<chronos::ContactManager> m_contactManager;
Yingdi Yuc29fb982013-10-20 19:43:10 -070091 WarningDialog* m_warningDialog;
Yingdi Yua1a688f2014-02-06 18:09:22 -080092 ndn::shared_ptr<chronos::EndorseCertificate> m_currentEndorseCertificate;
93 ndn::shared_ptr<ndn::Data> m_currentCollectEndorse;
Yingdi Yu8dacdf22013-11-05 23:06:43 -080094 bool m_currentEndorseCertificateReady;
95 bool m_currentCollectEndorseReady;
Yingdi Yua4898752013-10-15 20:31:37 -070096};
97
98#endif // ADDCONTACTPANEL_H