Skip to content

Commit

Permalink
Fixing the Add/Delete Contact bug, now when a contact is added and re…
Browse files Browse the repository at this point in the history
…moved, the panelPolicyManager will add/remove the contact into/from trust anchors

Change-Id: Ia7a8bc5c6cbe1744018410c0ca0019db3e5d3994
  • Loading branch information
bruinfish authored and cawka committed May 9, 2014
1 parent cc22ba3 commit 7223269
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/contact-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,23 @@ ContactManager::addContact(const IdentityCertificate& identityCertificate, const

try{
m_contactStorage->addContact(contactItem);
emit contactAdded(contactItem.getNameSpace());
}catch(exception& e){
emit warning(e.what());
_LOG_ERROR("Exception: " << e.what());
return;
}
}

void
ContactManager::removeContact(const ndn::Name& contactNameSpace)
{
Ptr<ContactItem> contact = getContact(contactNameSpace);
if(contact == NULL)
return;
m_contactStorage->removeContact(contactNameSpace);
emit contactRemoved(contact->getPublicKeyName());
}


#if WAF
Expand Down
10 changes: 10 additions & 0 deletions src/contact-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class ContactManager : public QObject
void
addContact(const ndn::security::IdentityCertificate& idCert, const Profile& profile);

void
removeContact(const ndn::Name& contactNameSpace);


private:
void
setKeychain();
Expand Down Expand Up @@ -168,6 +172,12 @@ class ContactManager : public QObject
void
warning(QString msg);

void
contactRemoved(const ndn::Name& identity);

void
contactAdded(const ndn::Name& identity);

private slots:


Expand Down
17 changes: 17 additions & 0 deletions src/contactpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ ContactPanel::ContactPanel(QWidget *parent)
this, SLOT(acceptInvitation(const ChronosInvitation&, const ndn::security::IdentityCertificate&)));
connect(m_invitationDialog, SIGNAL(invitationRejected(const ChronosInvitation&)),
this, SLOT(rejectInvitation(const ChronosInvitation&)));

connect(&*m_contactManager, SIGNAL(contactAdded(const ndn::Name&)),
this, SLOT(addContactIntoPanelPolicy(const ndn::Name&)));
connect(&*m_contactManager, SIGNAL(contactRemoved(const ndn::Name&)),
this, SLOT(removeContactFromPanelPolicy(const ndn::Name&)));

connect(m_settingDialog, SIGNAL(identitySet(const QString&, const QString&)),
this, SLOT(updateDefaultIdentity(const QString&, const QString&)));
Expand Down Expand Up @@ -643,6 +648,18 @@ void
ContactPanel::openInvitationDialog()
{ m_invitationDialog->show(); }

void
ContactPanel::addContactIntoPanelPolicy(const Name& contactNameSpace)
{
Ptr<ContactItem> contact = m_contactManager->getContact(contactNameSpace);
if(contact != NULL)
m_panelPolicyManager->addTrustAnchor(contact->getSelfEndorseCertificate());
}

void
ContactPanel::removeContactFromPanelPolicy(const Name& keyName)
{ m_panelPolicyManager->removeTrustAnchor(keyName); }

void
ContactPanel::refreshContactList()
{
Expand Down
5 changes: 5 additions & 0 deletions src/contactpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ private slots:
void
removeChatDialog(const ndn::Name& chatroomName);

void
addContactIntoPanelPolicy(const ndn::Name& nameSpace);

void
removeContactFromPanelPolicy(const ndn::Name& keyName);


private:
Expand Down
6 changes: 6 additions & 0 deletions src/panel-policy-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ PanelPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertific
m_trustAnchors.insert(pair <Name, Publickey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo()));
}

void
PanelPolicyManager::removeTrustAnchor(const Name& keyName)
{
m_trustAnchors.erase(keyName);
}

Ptr<Publickey>
PanelPolicyManager::getTrustedKey(const ndn::Name& inviterCertName)
{
Expand Down
3 changes: 3 additions & 0 deletions src/panel-policy-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class PanelPolicyManager : public ndn::security::PolicyManager
void
addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);

void
removeTrustAnchor(const ndn::Name& keyName);

// private:
// void
// onCertificateVerified(ndn::Ptr<ndn::Data> certData,
Expand Down

0 comments on commit 7223269

Please sign in to comment.