Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 11 | #include "addcontactpanel.h" |
| 12 | #include "ui_addcontactpanel.h" |
| 13 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 14 | #ifndef Q_MOC_RUN |
| 15 | #include "logging.h" |
| 16 | #endif |
| 17 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 18 | using namespace ndn; |
| 19 | using namespace std; |
| 20 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 21 | INIT_LOGGER("AddContactPanel"); |
| 22 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 23 | AddContactPanel::AddContactPanel(Ptr<ContactManager> contactManager, |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 24 | QWidget *parent) |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 25 | : QDialog(parent) |
| 26 | , ui(new Ui::AddContactPanel) |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 27 | , m_contactManager(contactManager) |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 28 | , m_warningDialog(new WarningDialog()) |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 29 | { |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 30 | ui->setupUi(this); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 31 | |
| 32 | qRegisterMetaType<ndn::Name>("NdnName"); |
| 33 | qRegisterMetaType<EndorseCertificate>("EndorseCertificate"); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 34 | |
| 35 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 36 | this, SLOT(onCancelClicked())); |
| 37 | connect(ui->searchButton, SIGNAL(clicked()), |
| 38 | this, SLOT(onSearchClicked())); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 39 | 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 Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | AddContactPanel::~AddContactPanel() |
| 46 | { |
| 47 | delete ui; |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 48 | delete m_warningDialog; |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 49 | } |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 50 | |
| 51 | void |
| 52 | AddContactPanel::onCancelClicked() |
| 53 | { this->close(); } |
| 54 | |
| 55 | void |
| 56 | AddContactPanel::onSearchClicked() |
| 57 | { |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 58 | QString inputIdentity = ui->contactInput->text(); |
| 59 | m_searchIdentity = Name(inputIdentity.toUtf8().constData()); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 60 | |
| 61 | m_contactManager->fetchSelfEndorseCertificate(m_searchIdentity); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void |
| 65 | AddContactPanel::onAddClicked() |
| 66 | { |
| 67 | } |
| 68 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 69 | void |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 70 | AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate) |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 71 | { |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 72 | _LOG_DEBUG("CALLED"); |
| 73 | } |
| 74 | |
| 75 | void |
| 76 | AddContactPanel::selfEndorseCertificateFetchFailed(const Name& identity) |
| 77 | { |
| 78 | m_warningDialog->setMsg("Cannot fetch contact profile"); |
| 79 | m_warningDialog->show(); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 82 | #if WAF |
| 83 | #include "addcontactpanel.moc" |
| 84 | #include "addcontactpanel.cpp.moc" |
| 85 | #endif |