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" |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 13 | #include <QMessageBox> |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 14 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 15 | #ifndef Q_MOC_RUN |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 16 | #include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp> |
| 17 | #include <boost/iostreams/stream.hpp> |
| 18 | #include "null-ptrs.h" |
| 19 | #include "endorse-collection.pb.h" |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 20 | #include "logging.h" |
| 21 | #endif |
| 22 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 23 | using namespace ndn; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 24 | using namespace ndn::ptr_lib; |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 25 | using namespace std; |
| 26 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 27 | INIT_LOGGER("AddContactPanel"); |
| 28 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 29 | AddContactPanel::AddContactPanel(shared_ptr<ContactManager> contactManager, |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 30 | QWidget *parent) |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 31 | : QDialog(parent) |
| 32 | , ui(new Ui::AddContactPanel) |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 33 | , m_contactManager(contactManager) |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 34 | , m_warningDialog(new WarningDialog()) |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 35 | { |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 36 | ui->setupUi(this); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 37 | |
| 38 | qRegisterMetaType<ndn::Name>("NdnName"); |
| 39 | qRegisterMetaType<EndorseCertificate>("EndorseCertificate"); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 40 | qRegisterMetaType<ndn::Data>("NdnData"); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 41 | |
| 42 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 43 | this, SLOT(onCancelClicked())); |
| 44 | connect(ui->searchButton, SIGNAL(clicked()), |
| 45 | this, SLOT(onSearchClicked())); |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 46 | connect(ui->addButton, SIGNAL(clicked()), |
| 47 | this, SLOT(onAddClicked())); |
| 48 | connect(&*m_contactManager, SIGNAL(contactFetched(const EndorseCertificate&)), |
| 49 | this, SLOT(selfEndorseCertificateFetched(const EndorseCertificate&))); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 50 | connect(&*m_contactManager, SIGNAL(contactFetchFailed(const ndn::Name&)), |
| 51 | this, SLOT(selfEndorseCertificateFetchFailed(const ndn::Name&))); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 52 | connect(&*m_contactManager, SIGNAL(collectEndorseFetched(const ndn::Data&)), |
| 53 | this, SLOT(onCollectEndorseFetched(const ndn::Data&))); |
| 54 | connect(&*m_contactManager, SIGNAL(collectEndorseFetchFailed(const ndn::Name&)), |
| 55 | this, SLOT(onCollectEndorseFetchFailed(const ndn::Name&))); |
| 56 | connect(&*m_contactManager, SIGNAL(contactKeyFetched(const EndorseCertificate&)), |
| 57 | this, SLOT(onContactKeyFetched(const EndorseCertificate&))); |
| 58 | connect(&*m_contactManager, SIGNAL(contactKeyFetchFailed(const ndn::Name&)), |
| 59 | this, SLOT(onContactKeyFetchFailed(const ndn::Name&))); |
| 60 | |
| 61 | |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | AddContactPanel::~AddContactPanel() |
| 65 | { |
| 66 | delete ui; |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 67 | delete m_warningDialog; |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 68 | } |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 69 | |
| 70 | void |
| 71 | AddContactPanel::onCancelClicked() |
| 72 | { this->close(); } |
| 73 | |
| 74 | void |
| 75 | AddContactPanel::onSearchClicked() |
| 76 | { |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 77 | m_currentEndorseCertificateReady = false; |
| 78 | m_currentCollectEndorseReady = false; |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 79 | ui->infoView->clear(); |
| 80 | for(int i = ui->infoView->rowCount() - 1; i >= 0 ; i--) |
| 81 | ui->infoView->removeRow(i); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 82 | QString inputIdentity = ui->contactInput->text(); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 83 | m_searchIdentity = Name(inputIdentity.toStdString()); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 84 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 85 | if(Qt::Checked == ui->fetchBox->checkState()) |
| 86 | { |
| 87 | m_contactManager->fetchSelfEndorseCertificate(m_searchIdentity); |
| 88 | m_contactManager->fetchCollectEndorse(m_searchIdentity); |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | if(isCorrectName(m_searchIdentity)) |
| 93 | m_contactManager->fetchKey(m_searchIdentity); |
| 94 | else |
| 95 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 96 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Wrong key certificate name!")); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | bool |
| 102 | AddContactPanel::isCorrectName(const Name& name) |
| 103 | { |
| 104 | string key("KEY"); |
| 105 | string idCert("ID-CERT"); |
| 106 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 107 | if(name.get(-1).toEscapedString() != idCert) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 108 | return false; |
| 109 | |
| 110 | int keyIndex = -1; |
| 111 | for(int i = 0; i < name.size(); i++) |
| 112 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 113 | if(name.get(i).toEscapedString() == key) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 114 | { |
| 115 | keyIndex = i; |
| 116 | break; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if(keyIndex < 0) |
| 121 | return false; |
| 122 | else |
| 123 | return true; |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void |
| 127 | AddContactPanel::onAddClicked() |
| 128 | { |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 129 | ContactItem contactItem(*m_currentEndorseCertificate); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 130 | try{ |
| 131 | m_contactManager->getContactStorage()->addContact(contactItem); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 132 | }catch(std::exception& e){ |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 133 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what())); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 134 | _LOG_ERROR("Exception: " << e.what()); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 135 | return; |
| 136 | } |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 137 | emit newContactAdded(); |
| 138 | this->close(); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 141 | void |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 142 | AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate) |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 143 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 144 | try{ |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 145 | m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate); |
| 146 | }catch(std::exception& e){ |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 147 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what())); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 148 | _LOG_ERROR("Exception: " << e.what()); |
| 149 | return; |
| 150 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 151 | m_currentEndorseCertificateReady = true; |
| 152 | |
| 153 | if(m_currentCollectEndorseReady == true) |
| 154 | displayContactInfo(); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void |
| 158 | AddContactPanel::selfEndorseCertificateFetchFailed(const Name& identity) |
| 159 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 160 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact profile")); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 163 | void |
| 164 | AddContactPanel::onContactKeyFetched(const EndorseCertificate& endorseCertificate) |
| 165 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 166 | try{ |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 167 | m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate); |
| 168 | }catch(std::exception& e){ |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 169 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what())); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 170 | _LOG_ERROR("Exception: " << e.what()); |
| 171 | return; |
| 172 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 173 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 174 | m_currentCollectEndorseReady = false; |
Yingdi Yu | e9ea5c9 | 2013-11-06 18:42:34 -0800 | [diff] [blame] | 175 | |
| 176 | displayContactInfo(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | void |
| 180 | AddContactPanel::onContactKeyFetchFailed(const Name& identity) |
| 181 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 182 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact ksk certificate")); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | void |
| 186 | AddContactPanel::onCollectEndorseFetched(const Data& data) |
| 187 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 188 | m_currentCollectEndorse = make_shared<Data>(data); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 189 | m_currentCollectEndorseReady = true; |
| 190 | |
| 191 | if(m_currentEndorseCertificateReady == true) |
| 192 | displayContactInfo(); |
| 193 | } |
| 194 | |
| 195 | void |
| 196 | AddContactPanel::onCollectEndorseFetchFailed(const Name& identity) |
| 197 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 198 | m_currentCollectEndorse = CHRONOCHAT_NULL_DATA_PTR; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 199 | m_currentCollectEndorseReady = true; |
| 200 | |
| 201 | if(m_currentEndorseCertificateReady == true) |
| 202 | displayContactInfo(); |
| 203 | } |
| 204 | |
| 205 | void |
| 206 | AddContactPanel::displayContactInfo() |
| 207 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 208 | // _LOG_TRACE("displayContactInfo"); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 209 | const Profile& profile = m_currentEndorseCertificate->getProfileData().getProfile(); |
| 210 | const Blob& profileBlob = m_currentEndorseCertificate->getProfileData().getContent(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 211 | |
| 212 | map<string, int> endorseCount; |
| 213 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 214 | if(m_currentCollectEndorse != CHRONOCHAT_NULL_DATA_PTR) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 215 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 216 | Chronos::EndorseCollection endorseCollection; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 217 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 218 | boost::iostreams::stream |
| 219 | <boost::iostreams::array_source> is ((const char*)m_currentCollectEndorse->getContent().buf(), m_currentCollectEndorse->getContent().size()); |
| 220 | |
| 221 | endorseCollection.ParseFromIstream(&is); |
| 222 | |
| 223 | for(int i = 0; i < endorseCollection.endorsement_size(); i ++) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 224 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 225 | try{ |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 226 | Data data; |
| 227 | data.wireDecode((const uint8_t*)endorseCollection.endorsement(i).blob().c_str(), endorseCollection.endorsement(i).blob().size()); |
| 228 | EndorseCertificate endorseCert(data); |
| 229 | |
| 230 | Name signerKeyName = endorseCert.getSigner(); |
| 231 | Name signerName = signerKeyName.getPrefix(-1); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 232 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 233 | shared_ptr<ContactItem> contact = m_contactManager->getContact(signerName); |
| 234 | if(contact == CHRONOCHAT_NULL_CONTACTITEM_PTR) |
| 235 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 236 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 237 | if(!contact->isIntroducer() || !contact->canBeTrustedFor(m_currentEndorseCertificate->getProfileData().getIdentityName())) |
| 238 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 239 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 240 | if(!Sha256WithRsaHandler::verifySignature(data, contact->getSelfEndorseCertificate().getPublicKeyInfo())) |
| 241 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 242 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 243 | const Blob& tmpProfileBlob = endorseCert.getProfileData().getContent(); |
| 244 | if(!isSameBlob(profileBlob, tmpProfileBlob)) |
| 245 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 246 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 247 | const vector<string>& endorseList = endorseCert.getEndorseList(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 248 | vector<string>::const_iterator it = endorseList.begin(); |
| 249 | for(; it != endorseList.end(); it++) |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 250 | endorseCount[*it] += 1; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 251 | }catch(std::exception& e){ |
| 252 | continue; |
| 253 | } |
| 254 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 255 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 256 | |
| 257 | ui->infoView->setColumnCount(3); |
| 258 | Profile::const_iterator it = profile.begin(); |
| 259 | int rowCount = 0; |
| 260 | |
| 261 | QTableWidgetItem *typeHeader = new QTableWidgetItem(QString::fromUtf8("Type")); |
| 262 | ui->infoView->setHorizontalHeaderItem(0, typeHeader); |
| 263 | QTableWidgetItem *valueHeader = new QTableWidgetItem(QString::fromUtf8("Value")); |
| 264 | ui->infoView->setHorizontalHeaderItem(1, valueHeader); |
| 265 | QTableWidgetItem *endorseHeader = new QTableWidgetItem(QString::fromUtf8("Endorse")); |
| 266 | ui->infoView->setHorizontalHeaderItem(2, endorseHeader); |
| 267 | |
| 268 | for(; it != profile.end(); it++) |
| 269 | { |
| 270 | ui->infoView->insertRow(rowCount); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 271 | QTableWidgetItem *type = new QTableWidgetItem(QString::fromStdString(it->first)); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 272 | ui->infoView->setItem(rowCount, 0, type); |
| 273 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 274 | QTableWidgetItem *value = new QTableWidgetItem(QString::fromStdString(it->second)); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 275 | ui->infoView->setItem(rowCount, 1, value); |
| 276 | |
| 277 | map<string, int>::iterator map_it = endorseCount.find(it->first); |
| 278 | QTableWidgetItem *endorse = NULL; |
| 279 | if(map_it == endorseCount.end()) |
| 280 | endorse = new QTableWidgetItem(QString::number(0)); |
| 281 | else |
| 282 | endorse = new QTableWidgetItem(QString::number(map_it->second)); |
| 283 | ui->infoView->setItem(rowCount, 2, endorse); |
| 284 | |
| 285 | rowCount++; |
| 286 | } |
| 287 | } |
| 288 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 289 | bool |
| 290 | AddContactPanel::isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB) |
| 291 | { |
| 292 | size_t size = blobA.size(); |
| 293 | |
| 294 | if(size != blobB.size()) |
| 295 | return false; |
| 296 | |
| 297 | const uint8_t* ap = blobA.buf(); |
| 298 | const uint8_t* bp = blobB.buf(); |
| 299 | |
| 300 | for(int i = 0; i < size; i++) |
| 301 | { |
| 302 | if(ap[i] != bp[i]) |
| 303 | return false; |
| 304 | } |
| 305 | |
| 306 | return true; |
| 307 | |
| 308 | } |
| 309 | |
| 310 | |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 311 | #if WAF |
| 312 | #include "addcontactpanel.moc" |
| 313 | #include "addcontactpanel.cpp.moc" |
| 314 | #endif |