Half of invitation works
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index e2c8359..4ba7323 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -18,62 +18,96 @@
#include <QDir>
#ifndef Q_MOC_RUN
+#include <ndn.cxx/security/keychain.h>
+#include <ndn.cxx/security/identity/osx-privatekey-storage.h>
+#include <ndn.cxx/security/identity/identity-manager.h>
+#include <ndn.cxx/security/identity/basic-identity-storage.h>
+#include <ndn.cxx/security/cache/ttl-certificate-cache.h>
+#include <ndn.cxx/security/encryption/basic-encryption-manager.h>
#include <ndn.cxx/common.h>
#include <boost/filesystem.hpp>
+#include <boost/random/random_device.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
+#include "invitation-policy-manager.h"
#include "logging.h"
#include "exception.h"
#endif
namespace fs = boost::filesystem;
using namespace ndn;
+
using namespace std;
INIT_LOGGER("ContactPanel");
+Q_DECLARE_METATYPE(ndn::security::IdentityCertificate)
+
ContactPanel::ContactPanel(Ptr<ContactManager> contactManager, QWidget *parent)
: QDialog(parent)
, ui(new Ui::ContactPanel)
, m_contactManager(contactManager)
, m_contactListModel(new QStringListModel)
+ , m_profileEditor(new ProfileEditor(m_contactManager))
, m_addContactPanel(new AddContactPanel(contactManager))
, m_setAliasDialog(new SetAliasDialog(contactManager))
, m_startChatDialog(new StartChatDialog)
+ , m_invitationDialog(new InvitationDialog)
+ , m_settingDialog(new SettingDialog)
, m_menuInvite(new QAction("&Chat", this))
, m_menuAlias(new QAction("&Set Alias", this))
{
+ qRegisterMetaType<ndn::security::IdentityCertificate>("IdentityCertificate");
- ui->setupUi(this);
+ ui->setupUi(this);
+ refreshContactList();
- QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
- QString path = (QDir::home().path());
- path.append(QDir::separator()).append(".chronos").append(QDir::separator()).append("chronos.db");
- db.setDatabaseName(path);
- bool ok = db.open();
+ openDB();
- m_profileEditor = new ProfileEditor(m_contactManager);
+ setKeychain();
+ m_handler = Ptr<Wrapper>(new Wrapper(m_keychain));
+
+ setLocalPrefix();
+
+ // Set Identity, TODO: through user interface
+ m_defaultIdentity = m_keychain->getDefaultIdentity();
+ m_settingDialog->setIdentity(m_defaultIdentity.toUri());
+ setInvitationListener();
- refreshContactList();
- ui->ContactList->setModel(m_contactListModel);
+ ui->ContactList->setModel(m_contactListModel);
- QItemSelectionModel* selectionModel = ui->ContactList->selectionModel();
+ QItemSelectionModel* selectionModel = ui->ContactList->selectionModel();
- connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
- this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
- connect(ui->ContactList, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(showContextMenu(const QPoint&)));
- connect(ui->EditProfileButton, SIGNAL(clicked()),
- this, SLOT(openProfileEditor()));
+ connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
- connect(ui->AddContactButton, SIGNAL(clicked()),
- this, SLOT(openAddContactPanel()));
+ connect(ui->ContactList, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(showContextMenu(const QPoint&)));
- connect(m_addContactPanel, SIGNAL(newContactAdded()),
- this, SLOT(refreshContactList()));
- connect(m_setAliasDialog, SIGNAL(aliasChanged()),
- this, SLOT(refreshContactList()));
+ connect(ui->EditProfileButton, SIGNAL(clicked()),
+ this, SLOT(openProfileEditor()));
- connect(m_startChatDialog, SIGNAL(chatroomConfirmed(const QString&, const QString&, bool)),
- this, SLOT(startChatroom(const QString&, const QString&, bool)));
+ connect(ui->AddContactButton, SIGNAL(clicked()),
+ this, SLOT(openAddContactPanel()));
+
+ connect(ui->settingButton, SIGNAL(clicked()),
+ this, SLOT(openSettingDialog()));
+
+ connect(m_addContactPanel, SIGNAL(newContactAdded()),
+ this, SLOT(refreshContactList()));
+
+ connect(m_setAliasDialog, SIGNAL(aliasChanged()),
+ this, SLOT(refreshContactList()));
+
+ connect(m_startChatDialog, SIGNAL(chatroomConfirmed(const QString&, const QString&, bool)),
+ this, SLOT(startChatroom(const QString&, const QString&, bool)));
+
+ connect(m_invitationDialog, SIGNAL(invitationAccepted(const ndn::Name&, const ndn::security::IdentityCertificate&, QString, QString)),
+ this, SLOT(acceptInvitation(const ndn::Name&, const ndn::security::IdentityCertificate&, QString, QString)));
+ connect(m_invitationDialog, SIGNAL(invitationRejected(const ndn::Name&)),
+ this, SLOT(rejectInvitation(const ndn::Name&)));
+
+ connect(m_settingDialog, SIGNAL(identitySet(const QString&)),
+ this, SLOT(updateDefaultIdentity(const QString&)));
@@ -90,6 +124,204 @@
}
void
+ContactPanel::openDB()
+{
+ QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
+ QString path = (QDir::home().path());
+ path.append(QDir::separator()).append(".chronos").append(QDir::separator()).append("chronos.db");
+ db.setDatabaseName(path);
+ bool ok = db.open();
+}
+
+void
+ContactPanel::setKeychain()
+{
+ Ptr<security::OSXPrivatekeyStorage> privateStorage = Ptr<security::OSXPrivatekeyStorage>::Create();
+ Ptr<security::IdentityManager> identityManager = Ptr<security::IdentityManager>(new security::IdentityManager(Ptr<security::BasicIdentityStorage>::Create(), privateStorage));
+ Ptr<security::CertificateCache> certificateCache = Ptr<security::CertificateCache>(new security::TTLCertificateCache());
+ Ptr<InvitationPolicyManager> policyManager = Ptr<InvitationPolicyManager>(new InvitationPolicyManager(10, certificateCache));
+ Ptr<security::EncryptionManager> encryptionManager = Ptr<security::EncryptionManager>(new security::BasicEncryptionManager(privateStorage, "/tmp/encryption.db"));
+
+ vector<Ptr<ContactItem> >::const_iterator it = m_contactList.begin();
+ for(; it != m_contactList.end(); it++)
+ policyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
+
+ m_keychain = Ptr<security::Keychain>(new security::Keychain(identityManager, policyManager, encryptionManager));
+}
+
+void
+ContactPanel::setLocalPrefix()
+{
+ Ptr<Interest> interest = Ptr<Interest>(new Interest(Name("/local/ndn/prefix")));
+ interest->setChildSelector(Interest::CHILD_RIGHT);
+
+ Ptr<Closure> closure = Ptr<Closure>(new Closure(boost::bind(&ContactPanel::onLocalPrefixVerified,
+ this,
+ _1),
+ boost::bind(&ContactPanel::onLocalPrefixTimeout,
+ this,
+ _1,
+ _2),
+ boost::bind(&ContactPanel::onLocalPrefixVerified,
+ this,
+ _1)));
+
+ m_handler->sendInterest(interest, closure);
+}
+
+void
+ContactPanel::onLocalPrefixVerified(Ptr<Data> data)
+{
+ string originPrefix(data->content().buf(), data->content().size());
+ string prefix = QString::fromStdString (originPrefix).trimmed ().toUtf8().constData();
+ string randomSuffix = getRandomString();
+ _LOG_DEBUG("prefix: " << prefix);
+ _LOG_DEBUG("randomSuffix: " << randomSuffix);
+ m_localPrefix = Name(prefix);
+}
+
+void
+ContactPanel::onLocalPrefixTimeout(Ptr<Closure> closure, Ptr<Interest> interest)
+{ throw LnException("No local prefix is found!"); }
+
+void
+ContactPanel::onUnverified(Ptr<Data> data)
+{}
+
+void
+ContactPanel::onTimeout(Ptr<Closure> closure, Ptr<Interest> interest)
+{}
+
+void
+ContactPanel::onInvitationCertVerified(Ptr<Data> data,
+ const Name& interestName,
+ int inviterIndex)
+{
+ Ptr<security::IdentityCertificate> certificate = Ptr<security::IdentityCertificate>(new security::IdentityCertificate(*data));
+
+ const int end = interestName.size();
+
+ string signature = interestName.get(end-1).toBlob();
+ Blob signatureBlob(signature.c_str(), signature.size());
+ string signedName = interestName.getSubName(0, end - 1).toUri();
+ Blob signedBlob(signedName.c_str(), signedName.size());
+
+ if(security::PolicyManager::verifySignature(signedBlob, signatureBlob, certificate->getPublicKeyInfo()))
+ {
+ Name keyName = certificate->getPublicKeyName();
+ Name inviterNameSpace = keyName.getSubName(0, keyName.size() - 1);
+ popChatInvitation(interestName, inviterIndex, inviterNameSpace, certificate);
+ }
+}
+
+void
+ContactPanel::popChatInvitation(const Name& interestName,
+ int inviterIndex,
+ const Name& inviterNameSpace,
+ Ptr<security::IdentityCertificate> certificate)
+{
+ string chatroomTag("chatroom");
+ int i = 0;
+ for(; i < inviterIndex; i++)
+ if(interestName.get(i).toUri() == chatroomTag)
+ break;
+ if(i+1 >= inviterIndex)
+ return;
+
+ string chatroom = interestName.get(i+1).toUri();
+ string inviter = inviterNameSpace.toUri();
+
+ m_invitationDialog->setMsg(inviter, chatroom);
+ m_invitationDialog->setIdentityCertificate(certificate);
+ m_invitationDialog->setInterestName(interestName);
+ m_invitationDialog->show();
+}
+
+static std::string chars("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789");
+
+string
+ContactPanel::getRandomString()
+{
+ string randStr;
+ boost::random::random_device rng;
+ boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);
+ for (int i = 0; i < 10; i ++)
+ {
+ randStr += chars[index_dist(rng)];
+ }
+ return randStr;
+}
+
+
+void
+ContactPanel::setInvitationListener()
+{
+ Name prefix("/ndn/broadcast/chronos/invitation");
+ prefix.append(m_defaultIdentity);
+ m_handler->setInterestFilter (prefix,
+ boost::bind(&ContactPanel::onInvitation,
+ this,
+ _1));
+
+}
+
+void
+ContactPanel::onInvitation(Ptr<Interest> interest)
+{
+ const Name& interestName = interest->getName();
+ const int end = interestName.size();
+
+ string inviter("inviter");
+ int j = end-2;
+ for(; j >= 0; j--)
+ if(interestName.get(j).toUri() == inviter)
+ break;
+
+ //No certificate name found
+ if(j < 0)
+ return;
+
+ Name certName = interestName.getSubName(j+1, end-2-j);
+ string keyString("KEY");
+ string idString("ID-CERT");
+ int m = certName.size() - 1;
+ int keyIndex = -1;
+ int idIndex = -1;
+ for(; m >= 0; m--)
+ if(certName.get(m).toUri() == idString)
+ {
+ idIndex = m;
+ break;
+ }
+
+ for(; m >=0; m--)
+ if(certName.get(m).toUri() == keyString)
+ {
+ keyIndex = m;
+ break;
+ }
+
+ //Not a qualified certificate name
+ if(keyIndex < 0 && idIndex < 0)
+ return;
+
+ Ptr<Interest> newInterest = Ptr<Interest>(new Interest(certName));
+ Ptr<Closure> closure = Ptr<Closure>(new Closure(boost::bind(&ContactPanel::onInvitationCertVerified,
+ this,
+ _1,
+ interestName,
+ j),
+ boost::bind(&ContactPanel::onTimeout,
+ this,
+ _1,
+ _2),
+ boost::bind(&ContactPanel::onUnverified,
+ this,
+ _1)));
+ m_handler->sendInterest(newInterest, closure);
+}
+
+void
ContactPanel::updateSelection(const QItemSelection &selected,
const QItemSelection &deselected)
{
@@ -117,6 +349,10 @@
}
void
+ContactPanel::updateDefaultIdentity(const QString& identity)
+{ m_defaultIdentity = Name(identity.toUtf8().constData()); }
+
+void
ContactPanel::openProfileEditor()
{ m_profileEditor->show(); }
@@ -157,6 +393,13 @@
}
void
+ContactPanel::openSettingDialog()
+{
+ m_settingDialog->setIdentity(m_defaultIdentity.toUri());
+ m_settingDialog->show();
+}
+
+void
ContactPanel::openStartChatDialog()
{
TimeInterval ti = time::NowUnixTimestamp();
@@ -178,6 +421,32 @@
_LOG_DEBUG("introducer: " << std::boolalpha << isIntroducer);
}
+void
+ContactPanel::startChatroom2(const QString& chatroom, const QString& inviter)
+{
+ _LOG_DEBUG("room: " << chatroom.toUtf8().constData());
+ _LOG_DEBUG("inviter: " << inviter.toUtf8().constData());
+}
+
+void
+ContactPanel::acceptInvitation(const Name& interestName,
+ const security::IdentityCertificate& identityCertificate,
+ QString inviter,
+ QString chatroom)
+{
+ string prefix = m_localPrefix.toUri();
+ m_handler->publishDataByIdentity (interestName, prefix);
+ //TODO:: open chat dialog
+ startChatroom2(chatroom, inviter);
+}
+
+void
+ContactPanel::rejectInvitation(const ndn::Name& interestName)
+{
+ string empty;
+ m_handler->publishDataByIdentity (interestName, empty);
+}
+
#if WAF
#include "contactpanel.moc"
diff --git a/src/contactpanel.h b/src/contactpanel.h
index dff0e56..9803a6a 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -20,11 +20,14 @@
#include "addcontactpanel.h"
#include "setaliasdialog.h"
#include "startchatdialog.h"
+#include "invitationdialog.h"
+#include "settingdialog.h"
#ifndef Q_MOC_RUN
#include "contact-manager.h"
#endif
+
namespace Ui {
class ContactPanel;
}
@@ -35,14 +38,60 @@
public:
explicit ContactPanel(ndn::Ptr<ContactManager> contactManager, QWidget *parent = 0);
+
~ContactPanel();
+private:
+ void
+ openDB();
+
+ void
+ setKeychain();
+
+ void
+ setLocalPrefix();
+
+ void
+ onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
+
+ void
+ onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
+
+ void
+ onUnverified(ndn::Ptr<ndn::Data> data);
+
+ void
+ onTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
+
+ void
+ setInvitationListener();
+
+ void
+ onInvitation(ndn::Ptr<ndn::Interest> interest);
+
+ void
+ onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
+ const ndn::Name& interestName,
+ int inviterIndex);
+
+ std::string
+ getRandomString();
+
+ void
+ popChatInvitation(const ndn::Name& interestName,
+ int inviterIndex,
+ const ndn::Name& inviterNameSpace,
+ ndn::Ptr<ndn::security::IdentityCertificate> certificate);
+
private slots:
void
updateSelection(const QItemSelection &selected,
const QItemSelection &deselected);
void
+ updateDefaultIdentity(const QString& identity);
+
+ void
openProfileEditor();
void
@@ -55,6 +104,9 @@
openStartChatDialog();
void
+ openSettingDialog();
+
+ void
refreshContactList();
void
@@ -63,6 +115,18 @@
void
startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer);
+ void
+ startChatroom2(const QString& chatroom, const QString& inviter);
+
+ void
+ acceptInvitation(const ndn::Name& interestName,
+ const ndn::security::IdentityCertificate& identityCertificate,
+ QString inviter,
+ QString chatroom);
+
+ void
+ rejectInvitation(const ndn::Name& interestName);
+
private:
Ui::ContactPanel *ui;
ndn::Ptr<ContactManager> m_contactManager;
@@ -71,14 +135,22 @@
AddContactPanel* m_addContactPanel;
SetAliasDialog* m_setAliasDialog;
StartChatDialog* m_startChatDialog;
+ InvitationDialog* m_invitationDialog;
+ SettingDialog* m_settingDialog;
QAction* m_menuInvite;
QAction* m_menuAlias;
-
-
std::vector<ndn::Ptr<ContactItem> > m_contactList;
+ ndn::Ptr<ndn::security::Keychain> m_keychain;
+ ndn::Ptr<ndn::Wrapper> m_handler;
+
+ ndn::Name m_defaultIdentity;
+ ndn::Name m_localPrefix;
+
std::string m_currentSelectedContactAlias;
std::string m_currentSelectedContactNamespace;
+
+
};
#endif // CONTACTPANEL_H
diff --git a/src/contactpanel.ui b/src/contactpanel.ui
index 6819ad0..0e5bbfb 100644
--- a/src/contactpanel.ui
+++ b/src/contactpanel.ui
@@ -253,9 +253,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="ButtonsLayout" stretch="1,1">
+ <layout class="QHBoxLayout" name="ButtonsLayout" stretch="1,1,1">
<property name="spacing">
- <number>100</number>
+ <number>50</number>
</property>
<item>
<widget class="QPushButton" name="AddContactButton">
@@ -265,6 +265,13 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="settingButton">
+ <property name="text">
+ <string>Setting</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="EditProfileButton">
<property name="text">
<string>Edit Profile</string>
diff --git a/src/invitation-policy-manager.cpp b/src/invitation-policy-manager.cpp
index 3c87c46..9016eb6 100644
--- a/src/invitation-policy-manager.cpp
+++ b/src/invitation-policy-manager.cpp
@@ -9,6 +9,10 @@
*/
#include "invitation-policy-manager.h"
+
+#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <boost/bind.hpp>
+
#include "logging.h"
using namespace std;
@@ -18,19 +22,21 @@
INIT_LOGGER("InvitationPolicyManager");
InvitationPolicyManager::InvitationPolicyManager(const int & stepLimit,
- Ptr<CertificateCache> certificateCache,
- Name signingIdentity)
+ Ptr<CertificateCache> certificateCache)
: m_stepLimit(stepLimit)
, m_certificateCache(certificateCache)
, m_localPrefixRegex(Ptr<Regex>(new Regex("^<local><ndn><prefix><><>$")))
{
m_invitationDataRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>",
- "^([^<KEY>]*)<KEY><DSK-.*><ID-CERT>$",
+ "^([^<KEY>]*)<KEY><DSK-.*><ID-CERT><>$",
"==", "\\1", "\\1", true));
- m_dskRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><DSK-.*><ID-CERT>$",
- "^([^<KEY>]*)<KEY>(<>*)<KSK-.*><ID-CERT>$",
+ m_dskRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><DSK-.*><ID-CERT><>$",
+ "^([^<KEY>]*)<KEY>(<>*)<KSK-.*><ID-CERT><>$",
"==", "\\1", "\\1\\2", true));
+
+ m_keyNameRegex = Ptr<Regex>(new Regex("^([^<KEY>]*)<KEY>(<>*<KSK-.*>)<ID-CERT><>$", "\\1\\2"));
+
m_signingCertificateRegex = Ptr<Regex>(new Regex("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", "\\1"));
}
@@ -121,22 +127,22 @@
if(m_dskRule->satisfy(*data))
{
- Ptr<IdentityCertificate> trustedCert;
- if(m_trustAnchors.end() != m_trustAnchors.find(keyLocatorName))
- trustedCert = m_trustAnchors[keyLocatorName];
- else
- {
- unverifiedCallback(data);
- return NULL;
- }
+ m_keyNameRegex->match(keyLocatorName);
+ Name keyName = m_keyNameRegex->expand();
- if(verifySignature(*data, trustedCert->getPublicKeyInfo()))
- verifiedCallback(data);
+ if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
+ if(verifySignature(*data, m_trustAnchors[keyName]))
+ verifiedCallback(data);
+ else
+ unverifiedCallback(data);
else
- unverifiedCallback(data);
+ unverifiedCallback(data);
return NULL;
}
+
+ unverifiedCallback(data);
+ return NULL;
}
void
@@ -151,8 +157,6 @@
verifiedCallback(originalData);
else
unverifiedCallback(originalData);
-
- return NULL;
}
void
@@ -170,15 +174,12 @@
Name
InvitationPolicyManager::inferSigningIdentity(const Name & dataName)
{
- if(m_signingCertificateRegex->match(data))
+ if(m_signingCertificateRegex->match(dataName))
return m_signingCertificateRegex->expand();
else
return Name();
}
void
-InvitationPolicyManager::addTrustAnchor(Ptr<IdentityCertificate> ksk)
-{
- Name name = ksk->getName();
- m_cache.insert(pair <Name, Ptr<IdentityCertificate> > (name, ksk));
-}
+InvitationPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
+{ m_trustAnchors.insert(pair <Name, Publickey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); }
diff --git a/src/invitation-policy-manager.h b/src/invitation-policy-manager.h
index 5684138..7d4b944 100644
--- a/src/invitation-policy-manager.h
+++ b/src/invitation-policy-manager.h
@@ -13,14 +13,16 @@
#include <ndn.cxx/security/policy/policy-manager.h>
#include <ndn.cxx/security/policy/identity-policy-rule.h>
+#include <ndn.cxx/security/cache/certificate-cache.h>
#include <map>
-class InvitationPolicyManager : ndn::security::PolicyManager
+#include "endorse-certificate.h"
+
+class InvitationPolicyManager : public ndn::security::PolicyManager
{
public:
InvitationPolicyManager(const int & stepLimit,
- ndn::Ptr<ndn::security::CertificateCache> certificateCache,
- ndn::Name signingIdentity);
+ ndn::Ptr<ndn::security::CertificateCache> certificateCache);
~InvitationPolicyManager()
{}
@@ -49,7 +51,7 @@
* @param unverifiedCallback the callback function that will be called if the received data packet cannot be validated
* @return the indication of next verification step, NULL if there is no further step
*/
- Ptr<ValidationRequest>
+ ndn::Ptr<ndn::security::ValidationRequest>
checkVerificationPolicy(ndn::Ptr<ndn::Data> data,
const int & stepCount,
const ndn::DataCallback& verifiedCallback,
@@ -70,12 +72,12 @@
* @param dataName, the name of data to be signed
* @return the signing identity.
*/
- Name
+ ndn::Name
inferSigningIdentity(const ndn::Name & dataName);
void
- addTrustAnchor(ndn::Ptr<ndn::security::IdentityCertificate> ksk);
+ addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
private:
void
@@ -93,10 +95,11 @@
int m_stepLimit;
ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
ndn::Ptr<ndn::Regex> m_localPrefixRegex;
- ndn::Ptr<ndn::IdentityPolicyRule> m_invitationDataRule;
- ndn::Ptr<ndn::IdentityPolicyRule> m_dskRule;
+ ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationDataRule;
+ ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
+ ndn::Ptr<ndn::Regex> m_keyNameRegex;
ndn::Ptr<ndn::Regex> m_signingCertificateRegex;
- std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_trustAnchors;
+ std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
};
diff --git a/src/invitationdialog.cpp b/src/invitationdialog.cpp
index bea2693..f7b2a59 100644
--- a/src/invitationdialog.cpp
+++ b/src/invitationdialog.cpp
@@ -13,6 +13,7 @@
#include "ui_invitationdialog.h"
using namespace std;
+using namespace ndn;
InvitationDialog::InvitationDialog(QWidget *parent) :
QDialog(parent),
@@ -29,6 +30,8 @@
void
InvitationDialog::setMsg(const string& inviter, const string& chatroom)
{
+ m_inviter = inviter;
+ m_chatroom = chatroom;
string msg = inviter;
msg.append(" invites you to join the chat room: ");
@@ -38,7 +41,11 @@
void
InvitationDialog::onOkClicked()
-{ emit invitationAccepted(m_interestName); }
+{
+ QString inviter = QString::fromUtf8(m_inviter.c_str());
+ QString chatroom = QString::fromUtf8(m_chatroom.c_str());
+ emit invitationAccepted(m_interestName, *m_identityCertificate, inviter, chatroom);
+}
void
InvitationDialog::onCancelClicked()
@@ -46,6 +53,8 @@
ui->msgLabel->clear();
ui->chatroomLine->clear();
m_interestName = Name();
+ m_inviter.clear();
+ m_chatroom.clear();
emit invitationRejected(m_interestName);
}
diff --git a/src/invitationdialog.h b/src/invitationdialog.h
index bcfeaa6..3826ad4 100644
--- a/src/invitationdialog.h
+++ b/src/invitationdialog.h
@@ -13,6 +13,11 @@
#include <QDialog>
+#ifndef Q_MOC_RUN
+#include <ndn.cxx/data.h>
+#include <ndn.cxx/security/certificate/identity-certificate.h>
+#endif
+
namespace Ui {
class InvitationDialog;
}
@@ -32,9 +37,16 @@
setInterestName(const ndn::Name& interestName)
{ m_interestName = interestName; }
+ inline void
+ setIdentityCertificate(const ndn::Ptr<ndn::security::IdentityCertificate> identityCertificate)
+ { m_identityCertificate = identityCertificate; }
+
signals:
void
- invitationAccepted(const ndn::Name& interestName);
+ invitationAccepted(const ndn::Name& interestName,
+ const ndn::security::IdentityCertificate& identityCertificate,
+ QString inviter,
+ QString chatroom);
void
invitationRejected(const ndn::Name& interestName);
@@ -49,7 +61,10 @@
private:
Ui::InvitationDialog *ui;
+ std::string m_inviter;
+ std::string m_chatroom;
ndn::Name m_interestName;
+ ndn::Ptr<ndn::security::IdentityCertificate> m_identityCertificate;
};
#endif // INVITATIONDIALOG_H
diff --git a/src/settingdialog.cpp b/src/settingdialog.cpp
index 291d7e6..a8dca16 100644
--- a/src/settingdialog.cpp
+++ b/src/settingdialog.cpp
@@ -18,6 +18,9 @@
ui(new Ui::SettingDialog)
{
ui->setupUi(this);
+
+ connect(ui->okButton, SIGNAL(clicked()),
+ this, SLOT(onOkClicked()));
}
SettingDialog::~SettingDialog()
@@ -26,7 +29,7 @@
}
void
-setIdentity(const std::string& identity)
+SettingDialog::setIdentity(const std::string& identity)
{
m_identity = identity;
ui->identityLine->setText(QString::fromUtf8(m_identity.c_str()));
@@ -42,6 +45,7 @@
m_identity = identity;
emit identitySet(text);
}
+ this->close();
}