blob: 9d332a7764f29efb377083daa5b71aa1ef03613b [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#include "addcontactpanel.h"
12#include "ui_addcontactpanel.h"
13
Yingdi Yuc29fb982013-10-20 19:43:10 -070014#ifndef Q_MOC_RUN
15#include "logging.h"
16#endif
17
Yingdi Yuaa8d7692013-10-18 17:05:02 -070018using namespace ndn;
19using namespace std;
20
Yingdi Yuc29fb982013-10-20 19:43:10 -070021INIT_LOGGER("AddContactPanel");
22
Yingdi Yuaa8d7692013-10-18 17:05:02 -070023AddContactPanel::AddContactPanel(Ptr<ContactManager> contactManager,
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070024 QWidget *parent)
Yingdi Yud59b5932013-10-16 13:16:49 -070025 : QDialog(parent)
26 , ui(new Ui::AddContactPanel)
Yingdi Yu0b82a4e2013-10-18 11:29:25 -070027 , m_contactManager(contactManager)
Yingdi Yuc29fb982013-10-20 19:43:10 -070028 , m_warningDialog(new WarningDialog())
Yingdi Yua4898752013-10-15 20:31:37 -070029{
Yingdi Yud59b5932013-10-16 13:16:49 -070030 ui->setupUi(this);
Yingdi Yuc29fb982013-10-20 19:43:10 -070031
32 qRegisterMetaType<ndn::Name>("NdnName");
33 qRegisterMetaType<EndorseCertificate>("EndorseCertificate");
Yingdi Yud59b5932013-10-16 13:16:49 -070034
35 connect(ui->cancelButton, SIGNAL(clicked()),
36 this, SLOT(onCancelClicked()));
37 connect(ui->searchButton, SIGNAL(clicked()),
38 this, SLOT(onSearchClicked()));
Yingdi Yuc29fb982013-10-20 19:43:10 -070039 connect(&*m_contactManager, SIGNAL(contactFetched(const EndorseCertificate&>)),
40 this, SLOT(selfEndorseCertificateFetched(const EndorseCertificate&>)));
41 connect(&*m_contactManager, SIGNAL(contactFetchFailed(const ndn::Name&)),
42 this, SLOT(selfEndorseCertificateFetchFailed(const ndn::Name&)));
Yingdi Yua4898752013-10-15 20:31:37 -070043}
44
45AddContactPanel::~AddContactPanel()
46{
47 delete ui;
Yingdi Yuc29fb982013-10-20 19:43:10 -070048 delete m_warningDialog;
Yingdi Yua4898752013-10-15 20:31:37 -070049}
Yingdi Yud59b5932013-10-16 13:16:49 -070050
51void
52AddContactPanel::onCancelClicked()
53{ this->close(); }
54
55void
56AddContactPanel::onSearchClicked()
57{
Yingdi Yuaa8d7692013-10-18 17:05:02 -070058 QString inputIdentity = ui->contactInput->text();
59 m_searchIdentity = Name(inputIdentity.toUtf8().constData());
Yingdi Yuc29fb982013-10-20 19:43:10 -070060
61 m_contactManager->fetchSelfEndorseCertificate(m_searchIdentity);
Yingdi Yud59b5932013-10-16 13:16:49 -070062}
63
64void
65AddContactPanel::onAddClicked()
66{
67}
68
Yingdi Yuaa8d7692013-10-18 17:05:02 -070069void
Yingdi Yuc29fb982013-10-20 19:43:10 -070070AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate)
Yingdi Yuaa8d7692013-10-18 17:05:02 -070071{
Yingdi Yuc29fb982013-10-20 19:43:10 -070072 _LOG_DEBUG("CALLED");
73}
74
75void
76AddContactPanel::selfEndorseCertificateFetchFailed(const Name& identity)
77{
78 m_warningDialog->setMsg("Cannot fetch contact profile");
79 m_warningDialog->show();
Yingdi Yuaa8d7692013-10-18 17:05:02 -070080}
81
Yingdi Yud59b5932013-10-16 13:16:49 -070082#if WAF
83#include "addcontactpanel.moc"
84#include "addcontactpanel.cpp.moc"
85#endif