Adding exception handling
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index c5c80e4..8e90f66 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -130,6 +130,7 @@
}catch(exception& e){
m_warningDialog->setMsg(e.what());
m_warningDialog->show();
+ _LOG_ERROR("Exception: " << e.what());
return;
}
emit newContactAdded();
@@ -139,7 +140,14 @@
void
AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate)
{
- m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
+ try{
+ m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
+ }catch(exception& e){
+ m_warningDialog->setMsg(e.what());
+ m_warningDialog->show();
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
m_currentEndorseCertificateReady = true;
if(m_currentCollectEndorseReady == true)
@@ -156,7 +164,14 @@
void
AddContactPanel::onContactKeyFetched(const EndorseCertificate& endorseCertificate)
{
- m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
+ try{
+ m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
+ }catch(exception& e){
+ m_warningDialog->setMsg(e.what());
+ m_warningDialog->show();
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
m_currentCollectEndorseReady = NULL;
@@ -193,7 +208,7 @@
void
AddContactPanel::displayContactInfo()
{
- _LOG_TRACE("displayContactInfo");
+ // _LOG_TRACE("displayContactInfo");
const Profile& profile = m_currentEndorseCertificate->getProfileData()->getProfile();
const Blob& profileBlob = m_currentEndorseCertificate->getProfileData()->content();
@@ -201,7 +216,6 @@
if(m_currentCollectEndorse != NULL)
{
- _LOG_DEBUG("CollectEndorse fetched");
boost::iostreams::stream
<boost::iostreams::array_source> is (m_currentCollectEndorse->content().buf(), m_currentCollectEndorse->content().size());
@@ -212,10 +226,16 @@
for(int i = 0; i < children.size(); i++)
{
Ptr<Blob> dataBlob = boost::any_cast<Ptr<Blob> >(children[i]->accept(simpleVisitor));
- Ptr<Data> data = Data::decodeFromWire(dataBlob);
- Ptr<EndorseCertificate> endorseCert = Ptr<EndorseCertificate>(new EndorseCertificate(*data));
- _LOG_DEBUG("endorseCert name: " << endorseCert->getName().toUri());
+ Ptr<Data> data = NULL;
+ Ptr<EndorseCertificate> endorseCert = NULL;
+ try{
+ data = Data::decodeFromWire(dataBlob);
+ endorseCert = Ptr<EndorseCertificate>(new EndorseCertificate(*data));
+ }catch(exception& e){
+ continue;
+ }
+
Name signerKeyName = endorseCert->getSigner();
Name signerName = signerKeyName.getPrefix(signerKeyName.size()-1);
@@ -239,12 +259,6 @@
endorseCount[*it] += 1;
}
}
-
- // map<string, int>::iterator tmp_it = endorseCount.begin();
- // for(; tmp_it != endorseCount.end(); tmp_it++)
- // {
- // _LOG_DEBUG("Entry: " << tmp_it->first << " " << tmp_it->second);
- // }
ui->infoView->setColumnCount(3);
Profile::const_iterator it = profile.begin();
diff --git a/src/chat-policy-rule.cpp b/src/chat-policy-rule.cpp
index 201cf70..76d0cf1 100644
--- a/src/chat-policy-rule.cpp
+++ b/src/chat-policy-rule.cpp
@@ -36,7 +36,15 @@
bool
ChatPolicyRule::matchSignerName(const Data & data)
{
- Ptr<const signature::Sha256WithRsa> sigPtr = DynamicCast<const signature::Sha256WithRsa> (data.getSignature());
+ Ptr<const Signature> sig = data.getSignature();
+
+ if(NULL == sig)
+ return false;
+
+ Ptr<const signature::Sha256WithRsa> sigPtr = DynamicCast<const signature::Sha256WithRsa> (sig);
+ if(KeyLocator::KEYNAME != sigPtr->getKeyLocator().getType())
+ return false;
+
Name signerName = sigPtr->getKeyLocator ().getKeyName ();
return m_signerRegex->match(signerName);
}
diff --git a/src/chatdialog.cpp b/src/chatdialog.cpp
index 1e30f87..fd3179c 100644
--- a/src/chatdialog.cpp
+++ b/src/chatdialog.cpp
@@ -46,7 +46,7 @@
, m_chatroomPrefix(chatroomPrefix)
, m_localPrefix(localPrefix)
, m_defaultIdentity(defaultIdentity)
- , m_invitationPolicyManager(ndn::Ptr<InvitationPolicyManager>(new InvitationPolicyManager(m_chatroomPrefix.get(-1).toUri())))
+ , m_invitationPolicyManager(ndn::Ptr<InvitationPolicyManager>(new InvitationPolicyManager(m_chatroomPrefix.get(-1).toUri(), m_defaultIdentity)))
, m_nick(nick)
, m_sock(NULL)
, m_lastMsgTime(0)
@@ -328,7 +328,6 @@
QTimer::singleShot(2200, this, SLOT(enableTreeDisplay()));
// Sync::CcnxWrapperPtr handle = boost::make_shared<Sync::CcnxWrapper> ();
// handle->setInterestFilter(m_user.getPrefix().toStdString(), bind(&ChatDialog::respondHistoryRequest, this, _1));
- // _LOG_DEBUG("initializeSync is done!");
}
void
diff --git a/src/chronos-invitation.cpp b/src/chronos-invitation.cpp
index 5a392a1..f918342 100644
--- a/src/chronos-invitation.cpp
+++ b/src/chronos-invitation.cpp
@@ -42,8 +42,6 @@
throw LnException("Wrong ChronosInvitation Name, No chatroom tag");
m_inviteeNameSpace = interestName.getSubName(inviteeBegin, i - inviteeBegin);
- _LOG_DEBUG(m_inviteeNameSpace.toUri());
-
string inviterPrefixStr("inviter-prefix");
int chatroomBegin = (++i);
for(; i < size; i++)
@@ -54,8 +52,6 @@
throw LnException("Wrong ChronosInvitation Name, No inviter-prefix tag");
m_chatroom = interestName.getSubName(chatroomBegin, i - chatroomBegin);
- _LOG_DEBUG(m_chatroom.toUri());
-
string inviterStr("inviter");
int inviterPrefixBegin = (++i);
for(; i < size; i++)
@@ -66,12 +62,8 @@
throw LnException("Wrong ChronosInvitation Name, No inviter tag");
m_inviterPrefix = interestName.getSubName(inviterPrefixBegin, i - inviterPrefixBegin);
- _LOG_DEBUG(m_inviterPrefix.toUri());
-
int inviterCertBegin = (++i);
m_inviterCertificateName = interestName.getSubName(inviterCertBegin, size - 1 - inviterCertBegin);
-
- _LOG_DEBUG(m_inviterCertificateName.toUri());
string signature = interestName.get(-1).toBlob();
m_signatureBits.insert(m_signatureBits.end(), signature.begin(), signature.end());
diff --git a/src/contact-item.cpp b/src/contact-item.cpp
index 839988c..9ce1b66 100644
--- a/src/contact-item.cpp
+++ b/src/contact-item.cpp
@@ -28,41 +28,14 @@
, m_isIntroducer(isIntroducer)
{
Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName();
- // Ptr<const signature::Sha256WithRsa> endorseSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(selfEndorseCertificate.getSignature());
- // const Name& signingKeyName = endorseSig->getKeyLocator().getKeyName();
-
- // int i = 0;
- // int j = -1;
- // string keyString("KEY");
- // string idString("ID-CERT");
- // for(; i < signingKeyName.size(); i++)
- // {
- // if(keyString == signingKeyName.get(i).toUri())
- // j = i;
- // if(idString == signingKeyName.get(i).toUri())
- // break;
- // }
-
- // if(i >= signingKeyName.size() || j < 0)
- // throw LnException("Wrong name!");
-
- // Name subName = signingKeyName.getSubName(0, j);
- // subName.append(signingKeyName.getSubName(j+1, i-j-1));
-
-
-
- // // _LOG_DEBUG("endorsedkeyName " << endorsedkeyName.toUri());
- // // _LOG_DEBUG("subKeyName " << subName.toUri());
-
- // if(endorsedkeyName != subName)
- // throw LnException("not a self-claimed");
m_namespace = endorsedkeyName.getSubName(0, endorsedkeyName.size() - 1);
- m_alias = alias.empty() ? m_namespace.toUri() : alias;
+
Ptr<ProfileData> profileData = selfEndorseCertificate.getProfileData();
Ptr<const Blob> nameBlob = profileData->getProfile().getProfileEntry("name");
m_name = string(nameBlob->buf(), nameBlob->size());
+ m_alias = alias.empty() ? m_name : alias;
Ptr<const Blob> institutionBlob = profileData->getProfile().getProfileEntry("institution");
m_institution = string(institutionBlob->buf(), institutionBlob->size());
}
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 2b834c6..651ab82 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -232,11 +232,17 @@
Name certificateName = identityManager->getDefaultCertificateName ();
identityManager->signByCertificate(*profileData, certificateName);
- EndorseCertificate endorseCertificate(identityCertificate, profileData);
+ Ptr<EndorseCertificate> endorseCertificate = NULL;
+ try{
+ endorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(identityCertificate, profileData));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
- identityManager->signByCertificate(endorseCertificate, certificateName);
+ identityManager->signByCertificate(*endorseCertificate, certificateName);
- emit contactKeyFetched (endorseCertificate);
+ emit contactKeyFetched (*endorseCertificate);
}
void
@@ -250,7 +256,6 @@
void
ContactManager::updateProfileData(const Name& identity)
{
- // _LOG_DEBUG("updateProfileData: " << identity.toUri());
// Get current profile;
Ptr<Profile> newProfile = m_contactStorage->getSelfProfile(identity);
if(NULL == newProfile)
@@ -261,19 +266,26 @@
Ptr<Blob> profileDataBlob = m_contactStorage->getSelfEndorseCertificate(identity);
if(NULL != profileDataBlob)
{
- Ptr<Data> plainData = Data::decodeFromWire(profileDataBlob);
- EndorseCertificate oldEndorseCertificate(*plainData);
- // _LOG_DEBUG("Certificate converted!");
- const Blob& oldProfileBlob = oldEndorseCertificate.getProfileData()->content();
+
+ Ptr<EndorseCertificate> oldEndorseCertificate = NULL;
+ try{
+ Ptr<Data> plainData = Data::decodeFromWire(profileDataBlob);
+ oldEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
+
+ const Blob& oldProfileBlob = oldEndorseCertificate->getProfileData()->content();
if(oldProfileBlob == *newProfileBlob)
return;
Ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
- // _LOG_DEBUG("Signing DONE!");
+
if(NULL == newEndorseCertificate)
return;
- // _LOG_DEBUG("About to update");
+
m_contactStorage->updateSelfEndorseCertificate(newEndorseCertificate, identity);
publishSelfEndorseCertificateInDNS(newEndorseCertificate);
@@ -281,10 +293,10 @@
else
{
Ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
- // _LOG_DEBUG("Signing DONE!");
+
if(NULL == newEndorseCertificate)
return;
- // _LOG_DEBUG("About to Insert");
+
m_contactStorage->addSelfEndorseCertificate(newEndorseCertificate, identity);
publishSelfEndorseCertificateInDNS(newEndorseCertificate);
@@ -298,9 +310,15 @@
Ptr<EndorseCertificate> newEndorseCertificate = generateEndorseCertificate(identity, signerIdentity);
if(NULL != oldEndorseCertificateBlob)
{
- Ptr<Data> plainData = Data::decodeFromWire(oldEndorseCertificateBlob);
- EndorseCertificate oldEndorseCertificate(*plainData);
- const Blob& oldEndorseContent = oldEndorseCertificate.content();
+ Ptr<EndorseCertificate> oldEndorseCertificate = NULL;
+ try{
+ Ptr<Data> plainData = Data::decodeFromWire(oldEndorseCertificateBlob);
+ oldEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
+ const Blob& oldEndorseContent = oldEndorseCertificate->content();
const Blob& newEndorseContent = newEndorseCertificate->content();
if(oldEndorseContent == newEndorseContent)
return;
@@ -327,7 +345,13 @@
vector<string> endorseList = m_contactStorage->getEndorseList(identity);
- Ptr<EndorseCertificate> cert = Ptr<EndorseCertificate>(new EndorseCertificate(contact->getSelfEndorseCertificate(), signerKeyName, endorseList));
+ Ptr<EndorseCertificate> cert = NULL;
+ try{
+ cert = Ptr<EndorseCertificate>(new EndorseCertificate(contact->getSelfEndorseCertificate(), signerKeyName, endorseList));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return NULL;
+ }
identityManager->signByCertificate(*cert, signerCertName);
return cert;
@@ -384,9 +408,16 @@
for(; it != profile.end(); it++)
endorseList.push_back(it->first);
- Ptr<EndorseCertificate> selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*kskCert,
- profileData,
- endorseList));
+ Ptr<EndorseCertificate> selfEndorseCertificate = NULL;
+ try{
+ selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*kskCert,
+ profileData,
+ endorseList));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return NULL;
+ }
+
identityManager->signByCertificate(*selfEndorseCertificate, kskCert->getName());
return selfEndorseCertificate;
@@ -398,9 +429,15 @@
{
Ptr<Blob> dataContentBlob = Ptr<Blob>(new Blob(data->content().buf(), data->content().size()));
- Ptr<Data> plainData = Data::decodeFromWire(dataContentBlob);
-
- Ptr<EndorseCertificate> selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
+ Ptr<Data> plainData = NULL;
+ Ptr<EndorseCertificate> selfEndorseCertificate = NULL;
+ try{
+ plainData = Data::decodeFromWire(dataContentBlob);
+ selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
const security::Publickey& ksk = selfEndorseCertificate->getPublicKeyInfo();
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index de35f51..57d8c80 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -55,14 +55,9 @@
createAction();
- openDB();
-
m_contactManager = contactManager;
- m_profileEditor = new ProfileEditor(m_contactManager);
- m_addContactPanel = new AddContactPanel(contactManager);
- m_setAliasDialog = new SetAliasDialog(contactManager);
-
- ui->setupUi(this);
+
+ openDB();
refreshContactList();
@@ -72,6 +67,14 @@
m_nickName = m_defaultIdentity.get(-1).toUri();
m_settingDialog->setIdentity(m_defaultIdentity.toUri(), m_nickName);
+ m_profileEditor = new ProfileEditor(m_contactManager);
+ m_profileEditor->setCurrentIdentity(m_defaultIdentity);
+
+ m_addContactPanel = new AddContactPanel(contactManager);
+ m_setAliasDialog = new SetAliasDialog(contactManager);
+
+ ui->setupUi(this);
+
m_handler = Ptr<Wrapper>(new Wrapper(m_keychain));
setLocalPrefix();
@@ -184,7 +187,9 @@
vector<Ptr<ContactItem> >::const_iterator it = m_contactList.begin();
for(; it != m_contactList.end(); it++)
- m_panelPolicyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
+ {
+ m_panelPolicyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
+ }
m_keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(),
m_panelPolicyManager,
@@ -243,15 +248,21 @@
ContactPanel::onInvitation(Ptr<Interest> interest)
{
_LOG_DEBUG("Receive invitation!" << interest->getName().toUri());
-
- Ptr<ChronosInvitation> invitation = Ptr<ChronosInvitation>(new ChronosInvitation(interest->getName()));
-
+
+ Ptr<ChronosInvitation> invitation = NULL;
+ try{
+ invitation = Ptr<ChronosInvitation>(new ChronosInvitation(interest->getName()));
+ }catch(exception& e){
+ _LOG_ERROR("Exception: " << e.what());
+ return;
+ }
+
Name chatroomName("/ndn/broadcast/chronos");
chatroomName.append(invitation->getChatroom());
map<Name, ChatDialog*>::iterator it = m_chatDialogs.find(chatroomName);
if(it != m_chatDialogs.end())
{
- _LOG_DEBUG("Exisiting chatroom!");
+ _LOG_ERROR("Exisiting chatroom!");
return;
}
@@ -485,6 +496,7 @@
ContactPanel::updateDefaultIdentity(const QString& identity, const QString& nickName)
{
m_defaultIdentity = Name(identity.toStdString());
+ m_profileEditor->setCurrentIdentity(m_defaultIdentity);
m_nickName = nickName.toStdString();
m_handler->clearInterestFilter(m_inviteListenPrefix);
setInvitationListener();
diff --git a/src/dns-storage.cpp b/src/dns-storage.cpp
index 70d04fe..52a23b2 100644
--- a/src/dns-storage.cpp
+++ b/src/dns-storage.cpp
@@ -80,7 +80,6 @@
if(sqlite3_step (stmt) != SQLITE_ROW)
{
- _LOG_DEBUG("INSERT");
sqlite3_finalize(stmt);
sqlite3_prepare_v2 (m_db, "INSERT INTO DnsData (dns_identity, dns_name, dns_type, dns_value, data_name) VALUES (?, ?, ?, ?, ?)", -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, identity.c_str(), identity.size(), SQLITE_TRANSIENT);
@@ -93,7 +92,6 @@
}
else
{
- _LOG_DEBUG("UPDATE");
sqlite3_finalize(stmt);
sqlite3_prepare_v2 (m_db, "UPDATE DnsData SET dns_value=?, data_name=? WHERE dns_identity=? and dns_name=?, dns_type=?", -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, data.buf(), data.size(), SQLITE_TRANSIENT);
@@ -148,10 +146,13 @@
if(sqlite3_step (stmt) == SQLITE_ROW)
{
- Blob dnsDataBlob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
- boost::iostreams::stream
- <boost::iostreams::array_source> is (dnsDataBlob.buf(), dnsDataBlob.size());
- return Data::decodeFromWire(is);
+ Ptr<Blob> dnsDataBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0)));
+ // boost::iostreams::stream
+ // <boost::iostreams::array_source> is (dnsDataBlob.buf(), dnsDataBlob.size());
+ sqlite3_finalize(stmt);
+ return Data::decodeFromWire(dnsDataBlob);
}
+ sqlite3_finalize(stmt);
+
return NULL;
}
diff --git a/src/endorse-certificate.cpp b/src/endorse-certificate.cpp
index 20e2aff..80ff165 100644
--- a/src/endorse-certificate.cpp
+++ b/src/endorse-certificate.cpp
@@ -39,10 +39,8 @@
Ptr<ProfileData>
ProfileExtension::getProfileData()
{
- // _LOG_DEBUG("size: " << m_extnValue.size ());
- boost::iostreams::stream
- <boost::iostreams::array_source> is (m_extnValue.buf (), m_extnValue.size ());
- return Ptr<ProfileData>(new ProfileData(*Data::decodeFromWire(is)));
+ Ptr<Blob> dataBlob = Ptr<Blob>(new Blob(m_extnValue.buf (), m_extnValue.size ()));
+ return Ptr<ProfileData>(new ProfileData(*Data::decodeFromWire(dataBlob)));
}
EndorseExtension::EndorseExtension(const vector<string>& endorsedList)
@@ -97,35 +95,6 @@
return blobStream.buf ();
}
-// EndorseCertificate::EndorseCertificate(const IdentityCertificate& kskCertificate)
-// : Certificate()
-// , m_keyName(kskCertificate.getPublicKeyName())
-// , m_signer(kskCertificate.getPublicKeyName())
-// {
-// Profile profile(m_keyName.getPrefix(m_keyName.size()-1),
-// m_keyName.get(-2).toUri(),
-// m_keyName.get(m_keyName.size()-2).toUri());
-
-// Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(m_keyName.getPrefix(m_keyName.size()-1),
-// profile));
-
-// m_profileData = profileData;
-
-// Name dataName = m_keyName;
-// dataName.append("PROFILE-CERT").append(m_signer).appendVersion();
-// setName(dataName);
-
-// setNotBefore(kskCertificate.getNotBefore());
-// setNotAfter(kskCertificate.getNotAfter());
-// addSubjectDescription(CertificateSubDescrypt("2.5.4.41", m_keyName.toUri()));
-// setPublicKeyInfo(kskCertificate.getPublicKeyInfo());
-// addExtension(ProfileExtension(*m_profileData));
-// addExtension(EndorseExtension(m_endorseList));
-
-// encode();
-// }
-
-
EndorseCertificate::EndorseCertificate(const IdentityCertificate& kskCertificate,
Ptr<ProfileData> profileData,
const vector<string>& endorseList)
@@ -183,11 +152,8 @@
EndorseCertificate::EndorseCertificate(const Data& data)
: Certificate(data)
{
- // _LOG_DEBUG("0");
const Name& dataName = data.getName();
- // _LOG_DEBUG("1");
name::Component certFlag(string("PROFILE-CERT"));
- // _LOG_DEBUG("2");
int profileIndex = -1;
for(int i = 0; i < dataName.size(); i++)
{
@@ -197,35 +163,25 @@
break;
}
}
- // _LOG_DEBUG("3");
if(profileIndex < 0)
throw LnException("No PROFILE-CERT component in data name!");
m_keyName = dataName.getSubName(0, profileIndex);
m_signer = dataName.getSubName(profileIndex + 1, dataName.size() - profileIndex - 2);
- // _LOG_DEBUG("keyName: " << m_keyName.toUri());
- // _LOG_DEBUG("signer: " << m_signer.toUri());
-
OID profileExtensionOID("1.3.6.1.5.32.2.1");
OID endorseExtensionOID("1.3.6.1.5.32.2.2");
- // _LOG_DEBUG("OID ready");
ExtensionList::iterator it = m_extnList.begin();
for(; it != m_extnList.end(); it++)
{
- // _LOG_DEBUG("entry");
if(profileExtensionOID == it->getOID())
{
- // _LOG_DEBUG("ProfileExtn");
ProfileExtension profileExtension(*it);
- // _LOG_DEBUG("ProfileExtn created");
m_profileData = profileExtension.getProfileData();
- // _LOG_DEBUG("get profileDate");
}
if(endorseExtensionOID == it->getOID())
{
- // _LOG_DEBUG("EndorseExtn");
EndorseExtension endorseExtension(*it);
m_endorseList = endorseExtension.getEndorsedList();
}
diff --git a/src/endorse-certificate.h b/src/endorse-certificate.h
index 1b9b897..99d9d65 100644
--- a/src/endorse-certificate.h
+++ b/src/endorse-certificate.h
@@ -57,8 +57,6 @@
public:
EndorseCertificate() {}
- // EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate);
-
EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate,
ndn::Ptr<ProfileData> profileData,
const std::vector<std::string>& endorseList = std::vector<std::string>());
diff --git a/src/endorse-combobox-delegate.cpp b/src/endorse-combobox-delegate.cpp
index e909e3d..a70a772 100644
--- a/src/endorse-combobox-delegate.cpp
+++ b/src/endorse-combobox-delegate.cpp
@@ -44,7 +44,6 @@
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
int value = index.model()->data(index, Qt::EditRole).toUInt();
- _LOG_DEBUG("value: " << value);
comboBox->setCurrentIndex(value);
}
@@ -52,7 +51,6 @@
EndorseComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
- _LOG_DEBUG("currentIndex: " << comboBox->currentIndex());
model->setData(index, comboBox->currentIndex(), Qt::EditRole);
}
diff --git a/src/invitation-policy-manager.cpp b/src/invitation-policy-manager.cpp
index ca4ae5b..58c9fcc 100644
--- a/src/invitation-policy-manager.cpp
+++ b/src/invitation-policy-manager.cpp
@@ -21,9 +21,11 @@
INIT_LOGGER("InvitationPolicyManager");
InvitationPolicyManager::InvitationPolicyManager(const string& chatroomName,
- int stepLimit,
- Ptr<CertificateCache> certificateCache)
+ const Name& signingIdentity,
+ int stepLimit,
+ Ptr<CertificateCache> certificateCache)
: m_chatroomName(chatroomName)
+ , m_signingIdentity(signingIdentity)
, m_stepLimit(stepLimit)
, m_certificateCache(certificateCache)
{
@@ -62,7 +64,7 @@
{
if(m_stepLimit == stepCount)
{
- _LOG_DEBUG("reach the maximum steps of verification");
+ _LOG_ERROR("Reach the maximum steps of verification!");
unverifiedCallback(data);
return NULL;
}
@@ -71,6 +73,7 @@
if(KeyLocator::KEYNAME != sha256sig->getKeyLocator().getType())
{
+ _LOG_ERROR("KeyLocator is not name!");
unverifiedCallback(data);
return NULL;
}
@@ -102,8 +105,6 @@
return NULL;
}
- _LOG_DEBUG("KeyLocator has not been cached and validated!");
-
DataCallback recursiveVerifiedCallback = boost::bind(&InvitationPolicyManager::onDskCertificateVerified,
this,
_1,
@@ -131,17 +132,13 @@
if(m_kskRegex->match(data->getName()))
{
- _LOG_DEBUG("is ksk");
Name keyName = m_kskRegex->expand();
- _LOG_DEBUG("ksk name: " << keyName.toUri());
map<Name, Publickey>::iterator it = m_trustAnchors.find(keyName);
if(m_trustAnchors.end() != it)
{
- _LOG_DEBUG("found key!");
Ptr<IdentityCertificate> identityCertificate = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
if(it->second.getKeyBlob() == identityCertificate->getPublicKeyInfo().getKeyBlob())
{
- _LOG_DEBUG("same key!");
verifiedCallback(data);
}
else
@@ -177,15 +174,13 @@
InvitationPolicyManager::checkSigningPolicy(const Name& dataName,
const Name& certificateName)
{
- //TODO:
return true;
}
Name
InvitationPolicyManager::inferSigningIdentity(const Name& dataName)
{
- //TODO:
- return Name();
+ return m_signingIdentity;
}
void
@@ -215,9 +210,9 @@
void
InvitationPolicyManager::onDskCertificateVerified(Ptr<Data> certData,
- Ptr<Data> originalData,
- const DataCallback& verifiedCallback,
- const UnverifiedCallback& unverifiedCallback)
+ Ptr<Data> originalData,
+ const DataCallback& verifiedCallback,
+ const UnverifiedCallback& unverifiedCallback)
{
Ptr<IdentityCertificate> certificate = Ptr<IdentityCertificate>(new IdentityCertificate(*certData));
diff --git a/src/invitation-policy-manager.h b/src/invitation-policy-manager.h
index cc37d7b..f2cfc1c 100644
--- a/src/invitation-policy-manager.h
+++ b/src/invitation-policy-manager.h
@@ -24,8 +24,9 @@
{
public:
InvitationPolicyManager(const std::string& chatroomName,
- int stepLimit = 10,
- ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
+ const ndn::Name& signingIdentity,
+ int stepLimit = 10,
+ ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
virtual
~InvitationPolicyManager();
@@ -73,6 +74,7 @@
private:
std::string m_chatroomName;
+ ndn::Name m_signingIdentity;
int m_stepLimit;
diff --git a/src/invitationdialog.cpp b/src/invitationdialog.cpp
index 9194bcc..1522314 100644
--- a/src/invitationdialog.cpp
+++ b/src/invitationdialog.cpp
@@ -40,10 +40,10 @@
m_inviterAlias = alias;
string msg = alias;
msg.append(" invites you to join the chat room: ");
- ui->msgLabel->setText(QString::fromUtf8(msg.c_str()));
+ ui->msgLabel->setText(QString::fromStdString(msg));
m_invitation = invitation;
- ui->chatroomLine->setText(QString::fromUtf8(invitation->getChatroom().get(0).toUri().c_str()));
+ ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toUri()));
m_identityCertificate = identityCertificate;
}
diff --git a/src/invitelistdialog.cpp b/src/invitelistdialog.cpp
index 797a312..c3d12af 100644
--- a/src/invitelistdialog.cpp
+++ b/src/invitelistdialog.cpp
@@ -43,7 +43,7 @@
{
string msg("invite to chatroom:\n");
msg += label;
- ui->inviteLabel->setText(QString::fromUtf8(msg.c_str()));
+ ui->inviteLabel->setText(QString::fromStdString(msg));
refreshContactList();
}
@@ -54,7 +54,7 @@
QStringList contactNameList;
for(int i = 0; i < m_contactList.size(); i++)
{
- contactNameList << QString::fromUtf8(m_contactList[i]->getAlias().c_str());
+ contactNameList << QString::fromStdString(m_contactList[i]->getAlias());
}
m_contactListModel->setStringList(contactNameList);
@@ -65,7 +65,7 @@
{
QModelIndexList selected = ui->contactListView->selectionModel()->selectedIndexes();
QString text = m_contactListModel->data(selected.first(), Qt::DisplayRole).toString();
- string alias = text.toUtf8().constData();
+ string alias = text.toStdString();
int i = 0;
for(; i < m_contactList.size(); i++)
@@ -74,7 +74,7 @@
break;
}
- QString invitedContactNamespace = QString::fromUtf8(m_contactList[i]->getNameSpace().toUri().c_str());
+ QString invitedContactNamespace = QString::fromStdString(m_contactList[i]->getNameSpace().toUri());
bool isIntroducer = true;
diff --git a/src/main.cpp b/src/main.cpp
index 44a67ee..0ed7fc2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -11,7 +11,6 @@
#include <QApplication>
#include <QSystemTrayIcon>
-#include "chronochat.h"
#include "contactpanel.h"
#include "contact-storage.h"
#include "dns-storage.h"
@@ -54,13 +53,15 @@
// app.setWindowIcon(QIcon(":/demo.icns"));
Ptr<ContactStorage> contactStorage = NULL;
+ Ptr<DnsStorage> dnsStorage = NULL;
try{
contactStorage = Ptr<ContactStorage>::Create();
+ dnsStorage = Ptr<DnsStorage>::Create();
}catch(std::exception& e){
std::cerr << e.what() << std::endl;
exit(1);
}
- Ptr<DnsStorage> dnsStorage = Ptr<DnsStorage>::Create();
+
Ptr<ContactManager> contactManager = Ptr<ContactManager>(new ContactManager(contactStorage, dnsStorage));
ContactPanel contactPanel(contactManager);
diff --git a/src/panel-policy-manager.cpp b/src/panel-policy-manager.cpp
index 1bbd849..679a3c9 100644
--- a/src/panel-policy-manager.cpp
+++ b/src/panel-policy-manager.cpp
@@ -82,10 +82,9 @@
const DataCallback& verifiedCallback,
const UnverifiedCallback& unverifiedCallback)
{
- _LOG_DEBUG("checkVerificationPolicy");
if(m_stepLimit == stepCount)
{
- _LOG_DEBUG("reach the maximum steps of verification");
+ _LOG_ERROR("Reach the maximum steps of verification!");
unverifiedCallback(data);
return NULL;
}
@@ -94,6 +93,7 @@
if(KeyLocator::KEYNAME != sha256sig->getKeyLocator().getType())
{
+ _LOG_ERROR("Keylocator is not name!");
unverifiedCallback(data);
return NULL;
}
@@ -102,9 +102,7 @@
if(m_kskRegex->match(data->getName()))
{
- _LOG_DEBUG("is ksk");
Name keyName = m_kskRegex->expand();
- _LOG_DEBUG("ksk name: " << keyName.toUri());
map<Name, Publickey>::iterator it = m_trustAnchors.find(keyName);
if(m_trustAnchors.end() != it)
{
@@ -112,7 +110,6 @@
Ptr<IdentityCertificate> identityCertificate = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
if(it->second.getKeyBlob() == identityCertificate->getPublicKeyInfo().getKeyBlob())
{
- _LOG_DEBUG("same key!");
verifiedCallback(data);
}
else
@@ -140,13 +137,10 @@
return NULL;
}
- _LOG_DEBUG("KEY Locator: " << keyLocatorName.toUri());
if(m_endorseeRule->satisfy(*data))
{
m_keyNameRegex->match(keyLocatorName);
Name keyName = m_keyNameRegex->expand();
- _LOG_DEBUG("data name: " << data->getName());
- _LOG_DEBUG("keyName: " << keyName.toUri());
if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
if(verifySignature(*data, m_trustAnchors[keyName]))
verifiedCallback(data);
@@ -164,26 +158,6 @@
return NULL;
}
-// void
-// PanelPolicyManager::onCertificateVerified(Ptr<Data> certData,
-// Ptr<Data> originalData,
-// const DataCallback& verifiedCallback,
-// const UnverifiedCallback& unverifiedCallback)
-// {
-// IdentityCertificate certificate(*certData);
-
-// if(verifySignature(*originalData, certificate.getPublicKeyInfo()))
-// verifiedCallback(originalData);
-// else
-// unverifiedCallback(originalData);
-// }
-
-// void
-// PanelPolicyManager::onCertificateUnverified(Ptr<Data> certData,
-// Ptr<Data> originalData,
-// const UnverifiedCallback& unverifiedCallback)
-// { unverifiedCallback(originalData); }
-
bool
PanelPolicyManager::checkSigningPolicy(const Name & dataName, const Name & certificateName)
{
@@ -202,6 +176,6 @@
void
PanelPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
{
- _LOG_DEBUG(selfEndorseCertificate.getPublicKeyName().toUri());
+ // _LOG_DEBUG("Add Anchor: " << selfEndorseCertificate.getPublicKeyName().toUri());
m_trustAnchors.insert(pair <Name, Publickey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo()));
}
diff --git a/src/profile-data.cpp b/src/profile-data.cpp
index ef067f9..e839f0f 100644
--- a/src/profile-data.cpp
+++ b/src/profile-data.cpp
@@ -57,7 +57,6 @@
ProfileData::ProfileData(const Data& data)
: Data()
{
- // _LOG_DEBUG("ProfileData constructor");
const Name& dataName = data.getName();
name::Component appFlag(string("PROFILE"));
@@ -91,7 +90,7 @@
setSignature(newSig);
setContent(data.getContent());
setSignedBlob(newSignedBlob);
- // _LOG_DEBUG("Decode Profile");
+
m_profile = *Profile::fromDerBlob(data.content());
- // _LOG_DEBUG("Profile Decoded");
+
}
diff --git a/src/profileeditor.cpp b/src/profileeditor.cpp
index d3d2608..7014794 100644
--- a/src/profileeditor.cpp
+++ b/src/profileeditor.cpp
@@ -32,8 +32,8 @@
{
ui->setupUi(this);
- Name defaultIdentity = contactManager->getDefaultIdentity();
- ui->identityInput->setText(defaultIdentity.toUri().c_str());
+ m_currentIdentity = contactManager->getDefaultIdentity();
+ ui->identityInput->setText(m_currentIdentity.toUri().c_str());
connect(ui->addRowButton, SIGNAL(clicked()),
this, SLOT(onAddClicked()));
@@ -94,7 +94,6 @@
m_currentIdentity = Name(inputIdentity.toUtf8().constData());
string filter("profile_identity = '");
filter.append(m_currentIdentity.toUri()).append("'");
- _LOG_DEBUG("filter: " << filter);
m_tableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
m_tableModel->setTable("SelfProfile");
@@ -104,8 +103,6 @@
m_tableModel->setHeaderData(1, Qt::Horizontal, QObject::tr("Type"));
m_tableModel->setHeaderData(2, Qt::Horizontal, QObject::tr("Value"));
- _LOG_DEBUG("row count: " << m_tableModel->rowCount());
-
ui->profileTable->setModel(m_tableModel);
ui->profileTable->setColumnHidden(0, true);
ui->profileTable->show();
diff --git a/src/profileeditor.h b/src/profileeditor.h
index 196a263..92ceaeb 100644
--- a/src/profileeditor.h
+++ b/src/profileeditor.h
@@ -31,6 +31,10 @@
QWidget *parent = 0);
~ProfileEditor();
+
+ inline void
+ setCurrentIdentity(const ndn::Name& name)
+ { m_currentIdentity = name; }
private slots:
void
@@ -50,7 +54,6 @@
Ui::ProfileEditor *ui;
QSqlTableModel* m_tableModel;
ndn::Ptr<ContactManager> m_contactManager;
- ndn::Name m_defaultIdentity;
ndn::Name m_currentIdentity;
};
diff --git a/src/setaliasdialog.cpp b/src/setaliasdialog.cpp
index 38e70d9..c615127 100644
--- a/src/setaliasdialog.cpp
+++ b/src/setaliasdialog.cpp
@@ -38,7 +38,7 @@
SetAliasDialog::onOkClicked()
{
QString text = ui->aliasInput->text();
- string alias = text.toUtf8().constData();
+ string alias = text.toStdString();
m_contactManager->getContactStorage()->updateAlias(Name(m_target), alias);
@@ -57,7 +57,7 @@
m_target = name;
string msg("Set alias for ");
msg.append(name).append(":");
- ui->introLabel->setText(QString::fromUtf8(msg.c_str()));
+ ui->introLabel->setText(QString::fromStdString(msg));
ui->aliasInput->clear();
}
diff --git a/src/startchatdialog.cpp b/src/startchatdialog.cpp
index 02d88f0..64795c0 100644
--- a/src/startchatdialog.cpp
+++ b/src/startchatdialog.cpp
@@ -33,14 +33,14 @@
StartChatDialog::setInvitee(const string& invitee, const string& chatroom)
{
m_invitee = invitee;
- ui->chatroomInput->setText(QString::fromUtf8(chatroom.c_str()));
+ ui->chatroomInput->setText(QString::fromStdString(chatroom));
}
void
StartChatDialog::onOkClicked()
{
QString chatroom = ui->chatroomInput->text();
- QString invitee = QString::fromUtf8(m_invitee.c_str());
+ QString invitee = QString::fromStdString(m_invitee);
// bool isIntroducer = ui->introCheckBox->isChecked();
bool isIntroducer = true;
emit chatroomConfirmed(chatroom, invitee, isIntroducer);
diff --git a/src/warningdialog.cpp b/src/warningdialog.cpp
index 6c7eb8a..6dcae60 100644
--- a/src/warningdialog.cpp
+++ b/src/warningdialog.cpp
@@ -30,7 +30,7 @@
void
WarningDialog::setMsg(const string& msg)
-{ ui->message->setText(QApplication::translate("WarningDialog",msg.c_str(), 0, QApplication::UnicodeUTF8)); }
+{ ui->message->setText(QString::fromStdString(msg)); }
void
WarningDialog::onOkClicked()
diff --git a/wscript b/wscript
index 98451fa..f7bdf1c 100644
--- a/wscript
+++ b/wscript
@@ -2,9 +2,11 @@
VERSION='0.1'
APPNAME='QT-Test'
-from waflib import Configure
+from waflib import Configure, Utils
def options(opt):
+ opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
+
opt.load('compiler_c compiler_cxx boost protoc qt4')
opt.load('tinyxml', tooldir=['waf-tools'])
@@ -13,8 +15,19 @@
def configure(conf):
conf.load("compiler_c compiler_cxx boost protoc qt4 tinyxml cryptopp")
- conf.add_supported_cxxflags (cxxflags = ['-O0', '-g'])
-
+ if conf.options.debug:
+ conf.define ('_DEBUG', 1)
+ conf.add_supported_cxxflags (cxxflags = ['-O0',
+ '-Wall',
+ '-Wno-unused-variable',
+ '-g3',
+ '-Wno-unused-private-field', # only clang supports
+ '-fcolor-diagnostics', # only clang supports
+ '-Qunused-arguments', # only clang supports
+ ])
+ else:
+ conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
+
conf.check_tinyxml(path=conf.options.tinyxml_dir)
conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
@@ -46,6 +59,44 @@
use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
)
+ if Utils.unversioned_sys_platform () == "darwin":
+ app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleIconFile</key>
+ <string>demo.icns</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Waf</string>
+ <key>CFBundleIdentifier</key>
+ <string>edu.ucla.cs.irl.Contacts</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>NOTE</key>
+ <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
+ <key>CFBundleExecutable</key>
+ <string>%s</string>
+ <key>LSUIElement</key>
+ <string>1</string>
+ <key>SUPublicDSAKeyFile</key>
+ <string>dsa_pub.pem</string>
+ <key>CFBundleIconFile</key>
+ <string>demo.icns</string>
+</dict>
+</plist>'''
+
+ qt.mac_app = "Contacts.app"
+ qt.mac_plist = app_plist % "Contacts"
+ qt.mac_resources = 'demo.icns'
+
+
+from waflib import TaskGen
+@TaskGen.extension('.mm')
+def m_hook(self, node):
+ """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
+ return self.create_compiled_task('cxx', node)
@Configure.conf
def add_supported_cxxflags(self, cxxflags):