Fixing some bugs causing segment faults, and update ChronoSync. Now it should work, but we need to run more tests to see if there are some other bugs.

Change-Id: Ib06603cb7262a7f38abe42be94da685f18eab65d
diff --git a/src/browsecontactdialog.cpp b/src/browsecontactdialog.cpp
index ee783e5..58396ba 100644
--- a/src/browsecontactdialog.cpp
+++ b/src/browsecontactdialog.cpp
@@ -45,8 +45,8 @@
 
   connect(ui->ContactList->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
           this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
-  connect(&*m_contactManager, SIGNAL(contactCertificateFetched(const ndn::security::IdentityCertificate &)),
-	  this, SLOT(onCertificateFetched(const ndn::security::IdentityCertificate &)));
+  connect(&*m_contactManager, SIGNAL(contactCertificateFetched(const ndn::IdentityCertificate &)),
+	  this, SLOT(onCertificateFetched(const ndn::IdentityCertificate &)));
   connect(&*m_contactManager, SIGNAL(contactCertificateFetchFailed(const ndn::Name&)),
           this, SLOT(onCertificateFetchFailed(const ndn::Name&)));
   connect(&*m_contactManager, SIGNAL(warning(QString)),
@@ -71,7 +71,7 @@
   try{
     using namespace boost::asio::ip;
     tcp::iostream request_stream;
-    request_stream.expires_from_now(boost::posix_time::milliseconds(3000));
+    request_stream.expires_from_now(boost::posix_time::milliseconds(5000));
     request_stream.connect("ndncert.named-data.net","80");
     if(!request_stream)
       {
@@ -137,6 +137,11 @@
 {
   vector<string> certNameList;
   getCertNames(certNameList);
+  _LOG_DEBUG("Get Certificate Name List");
+  for(int i = 0; i < certNameList.size(); i++)
+    {
+      _LOG_DEBUG(" " << certNameList[i]);
+    }
   
   if(filter)
     {
@@ -198,6 +203,8 @@
   int count = 0;
   for(; it != m_certificateNameList.end(); it++)
     {
+      _LOG_DEBUG("fetch " << it->toUri());
+      usleep(1000);
       m_contactManager->fetchIdCertificate(*it);
     }
 }
@@ -205,8 +212,8 @@
 void
 BrowseContactDialog::onCertificateFetched(const IdentityCertificate& identityCertificate)
 {
-  Name certName = identityCertificate.getName();
-  Name certNameNoVersion = certName.getPrefix(certName.size()-1);
+  Name certNameNoVersion = identityCertificate.getName().getPrefix(-1);
+  _LOG_DEBUG("Fetch: " << certNameNoVersion.toUri());
   m_certificateMap.insert(pair<Name, IdentityCertificate>(certNameNoVersion, identityCertificate));
   m_profileMap.insert(pair<Name, Profile>(certNameNoVersion, Profile(identityCertificate)));
   string name = m_profileMap[certNameNoVersion].getProfileEntry("name");
@@ -221,7 +228,9 @@
 
 void
 BrowseContactDialog::onCertificateFetchFailed(const Name& identity)
-{}
+{
+  _LOG_DEBUG("Cannot fetch " << identity.toUri());
+}
 
 void
 BrowseContactDialog::refreshList()
diff --git a/src/chatdialog.cpp b/src/chatdialog.cpp
index 5a6d483..c2d498d 100644
--- a/src/chatdialog.cpp
+++ b/src/chatdialog.cpp
@@ -35,6 +35,7 @@
 Q_DECLARE_METATYPE(size_t)
 
 ChatDialog::ChatDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
+                       ndn::ptr_lib::shared_ptr<ndn::IdentityManager> identityManager,
                        const ndn::Name& chatroomPrefix,
 		       const ndn::Name& localPrefix,
                        const ndn::Name& defaultIdentity,
@@ -48,6 +49,7 @@
   , m_localPrefix(localPrefix)
   , m_defaultIdentity(defaultIdentity)
   , m_invitationPolicyManager(new InvitationPolicyManager(m_chatroomPrefix.get(-1).toEscapedString(), m_defaultIdentity))
+  , m_identityManager(identityManager)
   , m_nick(nick)
   , m_sock(NULL)
   , m_lastMsgTime(0)
@@ -85,13 +87,10 @@
 
   m_timer = new QTimer(this);
 
+  startFace();
+
   ndn::Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(m_defaultIdentity);
-  m_syncPolicyManager = ndn::ptr_lib::make_shared<SyncPolicyManager>(m_defaultIdentity, certificateName, m_chatroomPrefix);
-
-  m_transport = ndn::ptr_lib::make_shared<ndn::TcpTransport>();
-  m_face = ndn::ptr_lib::make_shared<ndn::Face>(m_transport, ndn::ptr_lib::make_shared<ndn::TcpTransport::ConnectionInfo>("localhost"));
-
-  connectToDaemon();
+  m_syncPolicyManager = ndn::ptr_lib::make_shared<SyncPolicyManager>(m_defaultIdentity, certificateName, m_chatroomPrefix, m_face, m_transport);
 
   connect(ui->inviteButton, SIGNAL(clicked()),
           this, SLOT(openInviteListDialog()));
@@ -129,10 +128,48 @@
       delete m_sock;
       m_sock = NULL;
     }
+  shutdownFace();
+}
+
+void
+ChatDialog::startFace()
+{
+  m_transport = ndn::ptr_lib::make_shared<ndn::TcpTransport>();
+  m_face = ndn::ptr_lib::make_shared<ndn::Face>(m_transport, ndn::ptr_lib::make_shared<ndn::TcpTransport::ConnectionInfo>("localhost"));
+  
+  connectToDaemon();
+
+  m_running = true;
+  m_thread = boost::thread (&ChatDialog::eventLoop, this);  
+}
+
+void
+ChatDialog::shutdownFace()
+{
+  {
+    boost::unique_lock<boost::recursive_mutex> lock(m_mutex);
+    m_running = false;
+  }
+  
+  m_thread.join();
   m_face->shutdown();
 }
 
 void
+ChatDialog::eventLoop()
+{
+  while (m_running)
+    {
+      try{
+        m_face->processEvents();
+        usleep(1000);
+      }catch(std::exception& e){
+        _LOG_DEBUG(" " << e.what() );
+      }
+    }
+}
+
+void
 ChatDialog::connectToDaemon()
 {
   //Hack! transport does not connect to daemon unless an interest is expressed.
@@ -314,7 +351,12 @@
   ndn::ptr_lib::shared_ptr<const ndn::Sha256WithRsaSignature> sha256sig = ndn::ptr_lib::dynamic_pointer_cast<const ndn::Sha256WithRsaSignature>(m_identityManager->signByCertificate(signedBlob.buf(), signedBlob.size(), certificateName));
   const ndn::Blob& sigBits = sha256sig->getSignature();
 
+  _LOG_DEBUG("size A: " << interestName.size());
+
   interestName.append(sigBits);
+
+  _LOG_DEBUG("size B: " << interestName.size());
+
   //TODO... remove version from invitation interest
   //  interestName.appendVersion();
 
@@ -421,6 +463,8 @@
   
   m_sock = new Sync::SyncSocket(m_chatroomPrefix.toUri(),
                                 m_syncPolicyManager,
+                                m_face,
+                                m_transport,
                                 boost::bind(&ChatDialog::processTreeUpdateWrapper, this, _1, _2),
                                 boost::bind(&ChatDialog::processRemoveWrapper, this, _1));
   
@@ -854,6 +898,8 @@
       usleep(100000);
       m_sock = new Sync::SyncSocket(m_chatroomPrefix.toUri(),
                                     m_syncPolicyManager,
+                                    m_face,
+                                    m_transport,
                                     bind(&ChatDialog::processTreeUpdateWrapper, this, _1, _2),
                                     bind(&ChatDialog::processRemoveWrapper, this, _1));
       usleep(100000);
diff --git a/src/chatdialog.h b/src/chatdialog.h
index 0c06783..be2c89b 100644
--- a/src/chatdialog.h
+++ b/src/chatdialog.h
@@ -33,6 +33,10 @@
 #include <sync-seq-no.h>
 #include "chatbuf.pb.h"
 #include "digesttreescene.h"
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
 #endif
 
 typedef ndn::func_lib::function<void()> OnEventualTimeout;
@@ -49,6 +53,7 @@
 
 public:
   explicit ChatDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
+                      ndn::ptr_lib::shared_ptr<ndn::IdentityManager> identityManager,
                       const ndn::Name& chatroomPrefix,
                       const ndn::Name& localPrefix,
                       const ndn::Name& defaultIdentity,
@@ -110,6 +115,15 @@
 
 private:
 
+  void 
+  startFace();
+
+  void
+  shutdownFace();
+
+  void
+  eventLoop();
+
   void
   connectToDaemon();
 
@@ -334,6 +348,10 @@
   ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
   ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
 
+  boost::recursive_mutex m_mutex;
+  boost::thread m_thread;
+  bool m_running;
+
   ndn::Name m_newLocalPrefix;
   bool m_newLocalPrefixReady;
 
diff --git a/src/chronos-invitation.cpp b/src/chronos-invitation.cpp
index 28d36e1..fb9d918 100644
--- a/src/chronos-invitation.cpp
+++ b/src/chronos-invitation.cpp
@@ -22,7 +22,7 @@
 ChronosInvitation::ChronosInvitation(const ndn::Name& originalInterestName)
   : m_interestName(originalInterestName)
 {
-  Name interestName = originalInterestName.getPrefix(-1);
+  Name interestName = originalInterestName;
   if(interestName.get(0).toEscapedString() != string("ndn")
      || interestName.get(1).toEscapedString() != string("broadcast")
      || interestName.get(2).toEscapedString() != string("chronos")
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 25c32a1..b940bd8 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -28,48 +28,47 @@
 
 INIT_LOGGER("ContactManager");
 
-ContactManager::ContactManager(shared_ptr<IdentityManager> identityManager, QObject* parent)
-  : QObject(parent)
+ContactManager::ContactManager(shared_ptr<IdentityManager> identityManager, 
+                               shared_ptr<Face> face,
+                               shared_ptr<Transport> transport,
+                               QObject* parent)
+  : QObject(parent),
+    m_face(face),
+    m_transport(transport)
 {
   m_identityManager = identityManager;
   m_contactStorage = make_shared<ContactStorage>();
   m_dnsStorage = make_shared<DnsStorage>();
 
-  m_transport = make_shared<TcpTransport>();
-  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
-  
-  connectToDaemon();
-
   initializeSecurity();
 }
 
 ContactManager::~ContactManager()
-{
-}
+{}
 
-void
-ContactManager::connectToDaemon()
-{
-  //Hack! transport does not connect to daemon unless an interest is expressed.
-  Name name("/ndn");
-  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(name);
-  m_face->expressInterest(*interest, 
-                          bind(&ContactManager::onConnectionData, this, _1, _2),
-                          bind(&ContactManager::onConnectionDataTimeout, this, _1));
-}
+// void
+// ContactManager::connectToDaemon()
+// {
+//   //Hack! transport does not connect to daemon unless an interest is expressed.
+//   Name name("/ndn");
+//   shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(name);
+//   m_face->expressInterest(*interest, 
+//                           bind(&ContactManager::onConnectionData, this, _1, _2),
+//                           bind(&ContactManager::onConnectionDataTimeout, this, _1));
+// }
 
-void
-ContactManager::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
-                            const shared_ptr<Data>& data)
-{
-  _LOG_DEBUG("onConnectionData");
-}
+// void
+// ContactManager::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+//                             const shared_ptr<Data>& data)
+// {
+//   _LOG_DEBUG("onConnectionData");
+// }
 
-void
-ContactManager::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
-{
-  _LOG_DEBUG("onConnectionDataTimeout");
-}
+// void
+// ContactManager::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+// {
+//   _LOG_DEBUG("onConnectionDataTimeout");
+// }
 
 void
 ContactManager::initializeSecurity()
@@ -291,7 +290,7 @@
 }
 
 void
-ContactManager::fetchIdCertificate(const ndn::Name& certName)
+ContactManager::fetchIdCertificate(const Name& certName)
 {
   Name interestName = certName;
   
@@ -308,7 +307,9 @@
 
 void
 ContactManager::onIdCertificateTimeoutNotify(const Name& identity)
-{ emit contactCertificateFetchFailed (identity); }
+{ 
+  emit contactCertificateFetchFailed (identity); 
+}
 
 
 void
@@ -320,7 +321,9 @@
 
 void
 ContactManager::onIdCertificateVerifyFailed(const shared_ptr<Data>& data, const Name& identity)
-{ emit contactCertificateFetchFailed (identity); }
+{ 
+  emit contactCertificateFetchFailed (identity); 
+}
 
 void
 ContactManager::onTargetData(const shared_ptr<const ndn::Interest>& interest, 
@@ -405,7 +408,7 @@
                              int retry /* = 1 */,
                              int stepCount /* = 0 */)
 {
-  m_face->expressInterest(interest, 
+  uint64_t id = m_face->expressInterest(interest, 
                           boost::bind(&ContactManager::onTargetData, 
                                       this,
                                       _1,
@@ -422,6 +425,8 @@
                                       onVerified,
                                       onVerifyFailed,
                                       timeoutNotify));
+
+  _LOG_DEBUG("id: " << id << " entry id: " << m_face->getNode().getEntryIndexForExpressedInterest(interest.getName()));
 }
 
 void
diff --git a/src/contact-manager.h b/src/contact-manager.h
index 0c4cc06..d096abf 100644
--- a/src/contact-manager.h
+++ b/src/contact-manager.h
@@ -31,6 +31,8 @@
 
 public:
   ContactManager(ndn::ptr_lib::shared_ptr<ndn::IdentityManager> identityManager,
+                 ndn::ptr_lib::shared_ptr<ndn::Face> m_face,
+                 ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport,
                  QObject* parent = 0);
 
   ~ContactManager();
@@ -89,15 +91,15 @@
   { return m_identityManager; }
 
 private:
-  void 
-  connectToDaemon();
+  // void 
+  // connectToDaemon();
 
-  void
-  onConnectionData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
-                   const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+  // void
+  // onConnectionData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
+  //                  const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
  
-  void
-  onConnectionDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest);
+  // void
+  // onConnectionDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest);
   
   void
   initializeSecurity();
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index f3ad618..d9f3324 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -56,14 +56,16 @@
 {
   qRegisterMetaType<IdentityCertificate>("IdentityCertificate");
   qRegisterMetaType<ChronosInvitation>("ChronosInvitation");
-  
+
+  startFace();  
+
   createAction();
 
   shared_ptr<BasicIdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
   shared_ptr<OSXPrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
   m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
 
-  m_contactManager = make_shared<ContactManager>(m_identityManager);
+  m_contactManager = make_shared<ContactManager>(m_identityManager, m_face, m_transport);
 
   connect(&*m_contactManager, SIGNAL(noNdnConnection(const QString&)),
           this, SLOT(showError(const QString&)));
@@ -96,10 +98,6 @@
  
   ui->setupUi(this);
 
-  m_transport = make_shared<TcpTransport>();
-  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
-  
-  connectToDaemon();
   
   m_localPrefix = Name("/private/local");
   setLocalPrefix();
@@ -201,6 +199,46 @@
   map<Name, ChatDialog*>::iterator it = m_chatDialogs.begin();
   for(; it != m_chatDialogs.end(); it++)
     delete it->second;
+
+  shutdownFace();
+}
+
+void
+ContactPanel::startFace()
+{
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+  
+  connectToDaemon();
+
+  m_running = true;
+  m_thread = boost::thread (&ContactPanel::eventLoop, this);  
+}
+
+void
+ContactPanel::shutdownFace()
+{
+  {
+    boost::unique_lock<boost::recursive_mutex> lock(m_mutex);
+    m_running = false;
+  }
+  
+  m_thread.join();
+  m_face->shutdown();
+}
+
+void
+ContactPanel::eventLoop()
+{
+  while (m_running)
+    {
+      try{
+        m_face->processEvents();
+        usleep(100);
+      }catch(std::exception& e){
+        _LOG_DEBUG(" " << e.what() );
+      }
+    }
 }
 
 void
@@ -251,6 +289,7 @@
   vector<shared_ptr<ContactItem> >::const_iterator it = m_contactList.begin();
   for(; it != m_contactList.end(); it++)
     {
+      _LOG_DEBUG("load contact: " << (*it)->getNameSpace().toUri());
       m_policyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
     }
 }
@@ -419,6 +458,7 @@
                            uint64_t registeredPrefixId)
 {
   _LOG_DEBUG("Receive invitation!" << interest->getName().toUri());
+
   
   shared_ptr<ChronosInvitation> invitation;
   try{
@@ -465,6 +505,8 @@
       return;
     }
 
+  _LOG_DEBUG("Cannot find the inviter's key in trust anchors");
+
   Interest newInterest(invitation->getInviterCertificateName());
   OnVerified onVerified = boost::bind(&ContactPanel::onInvitationCertVerified, this, _1, invitation);
   OnVerifyFailed onVerifyFailed = boost::bind(&ContactPanel::onInvitationCertVerifyFailed, this, _1);
@@ -818,7 +860,7 @@
   Name inviteeNamespace(invitee.toStdString());
   shared_ptr<ContactItem> inviteeItem = m_contactManager->getContact(inviteeNamespace);
 
-  ChatDialog* chatDialog = new ChatDialog(m_contactManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName);
+  ChatDialog* chatDialog = new ChatDialog(m_contactManager, m_identityManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName);
   m_chatDialogs.insert(pair <Name, ChatDialog*> (chatroomName, chatDialog));
 
   connect(chatDialog, SIGNAL(closeChatDialog(const ndn::Name&)),
@@ -844,7 +886,7 @@
   Name chatroomName("/ndn/broadcast/chronos");
   chatroomName.append(invitation.getChatroom());
 
-  ChatDialog* chatDialog = new ChatDialog(m_contactManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName, true);
+  ChatDialog* chatDialog = new ChatDialog(m_contactManager, m_identityManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName, true);
 
   connect(chatDialog, SIGNAL(closeChatDialog(const ndn::Name&)),
           this, SLOT(removeChatDialog(const ndn::Name&)));
@@ -867,7 +909,12 @@
 ContactPanel::acceptInvitation(const ChronosInvitation& invitation, 
                                const IdentityCertificate& identityCertificate)
 {
-  Data data(invitation.getInterestName());
+  Name dataName = invitation.getInterestName();
+  time_t nowSeconds = time(NULL);
+  struct tm current = *gmtime(&nowSeconds);
+  MillisecondsSince1970 version = timegm(&current) * 1000.0;
+  dataName.appendVersion(version);
+  Data data(dataName);
   string content = m_localPrefix.toUri();
   data.setContent((const uint8_t *)&content[0], content.size());
   data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
diff --git a/src/contactpanel.h b/src/contactpanel.h
index 1c2c9fc..615a836 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -32,6 +32,9 @@
 #include "contact-manager.h"
 #include "chronos-invitation.h"
 #include "panel-policy-manager.h"
+#include <boost/thread/locks.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
 #endif
 
 
@@ -49,6 +52,16 @@
   ~ContactPanel();
 
 private:
+  
+  void 
+  startFace();
+
+  void
+  shutdownFace();
+
+  void
+  eventLoop();
+  
   void 
   connectToDaemon();
 
@@ -275,6 +288,11 @@
   ndn::ptr_lib::shared_ptr<ndn::IdentityManager> m_identityManager;
   ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
   ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
+
+  boost::recursive_mutex m_mutex;
+  boost::thread m_thread;
+  bool m_running;
+
   uint64_t m_invitationListenerId;
 
   ndn::Name m_defaultIdentity;
diff --git a/src/invitation-policy-manager.cpp b/src/invitation-policy-manager.cpp
index cd86cbd..0885e25 100644
--- a/src/invitation-policy-manager.cpp
+++ b/src/invitation-policy-manager.cpp
@@ -79,20 +79,20 @@
   if(m_invitationPolicyRule->satisfy(*data))
     {
       // Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-      // map<Name, Publickey>::iterator it = m_trustAnchors.find(keyName);
+      // map<Name, PublicKey>::iterator it = m_trustAnchors.find(keyName);
       // if(m_trustAnchors.end() != it)
       //   {
-      //     if(verifySignature(*data, it->second))
-      //       verifiedCallback(data);
+      //     if(Sha256WithRsaHandler::verifySignature(*data, it->second))
+      //       onVerified(data);
       //     else
-      //       unverifiedCallback(data);
+      //       onVerifyFailed(data);
 
-      //     return NULL;
+      //     return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
       //   }
 
       shared_ptr<const Certificate> trustedCert = m_certificateCache.getCertificate(keyLocatorName);
       
-      if(!trustedCert){
+      if(trustedCert != ndn::TCC_NULL_CERTIFICATE_PTR){
 	if(Sha256WithRsaHandler::verifySignature(*data, trustedCert->getPublicKeyInfo()))
 	  onVerified(data);
 	else
diff --git a/src/null-ptrs.h b/src/null-ptrs.h
index 0dfd3f2..0120a2f 100644
--- a/src/null-ptrs.h
+++ b/src/null-ptrs.h
@@ -19,6 +19,7 @@
 #include "profile.h"
 #include <ndn-cpp/security/certificate/identity-certificate.hpp>
 #include <ndn-cpp/security/policy/validation-request.hpp>
+#include <ndn-cpp/security/certificate/certificate.hpp>
 
 
 static std::string CHRONOCHAT_NULL_STR;
@@ -31,5 +32,6 @@
 static ndn::ptr_lib::shared_ptr<Profile> CHRONOCHAT_NULL_PROFILE_PTR;
 static ndn::ptr_lib::shared_ptr<ndn::PublicKey> CHRONOCHAT_NULL_PUBLICKEY_PTR;
 static ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
+static ndn::ptr_lib::shared_ptr<const ndn::Certificate> CHRONOCHAT_NULL_CONST_CERTIFICATE_PTR;
 
 #endif
diff --git a/src/panel-policy-manager.cpp b/src/panel-policy-manager.cpp
index 8d6300d..92511ed 100644
--- a/src/panel-policy-manager.cpp
+++ b/src/panel-policy-manager.cpp
@@ -171,7 +171,7 @@
 void
 PanelPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
 { 
-  // _LOG_DEBUG("Add Anchor: " << selfEndorseCertificate.getPublicKeyName().toUri());
+  _LOG_DEBUG("Add Anchor: " << selfEndorseCertificate.getPublicKeyName().toUri());
   m_trustAnchors.insert(pair <Name, PublicKey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); 
 }
 
@@ -185,6 +185,7 @@
 PanelPolicyManager::getTrustedKey(const Name& inviterCertName)
 {
   Name keyLocatorName = inviterCertName.getPrefix(-1);
+  _LOG_DEBUG("inviter cert name: " << inviterCertName.toUri());
   m_keyNameRegex->match(keyLocatorName);
   Name keyName = m_keyNameRegex->expand();
 
diff --git a/src/profile-data.cpp b/src/profile-data.cpp
index 6bb70cc..0e17552 100644
--- a/src/profile-data.cpp
+++ b/src/profile-data.cpp
@@ -44,11 +44,11 @@
 
 }
 
-ProfileData::ProfileData(const ProfileData& profileData)
-  : Data(profileData)
-  , m_identity(profileData.m_identity)
-  , m_profile(profileData.m_profile)
-{}
+// ProfileData::ProfileData(const ProfileData& profileData)
+//   : Data(profileData)
+//   , m_identity(profileData.m_identity)
+//   , m_profile(profileData.m_profile)
+// {}
 
 ProfileData::ProfileData(const Data& data)
   : Data(data)
diff --git a/src/profile-data.h b/src/profile-data.h
index dcde0d8..dbe4ca5 100644
--- a/src/profile-data.h
+++ b/src/profile-data.h
@@ -21,7 +21,7 @@
 
   ProfileData(const Profile& profile);
 
-  ProfileData(const ProfileData& profileData);
+  // ProfileData(const ProfileData& profileData);
 
   ProfileData(const ndn::Data& data);