Fix bugs in storage classes
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index 34eb2e9..a3dabf7 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -26,8 +26,8 @@
           this, SLOT(onCancelClicked()));
   connect(ui->searchButton, SIGNAL(clicked()),
           this, SLOT(onSearchClicked()));
-  connect(&*m_contactManager, SIGNAL(contactFetched(Ptr<EndorseCertificate>)),
-          this, SLOT(selfEndorseCertificateFetched(Ptr<EndorseCertificate>)));
+  connect(&*m_contactManager, SIGNAL(contactFetched(ndn::Ptr<EndorseCertificate>)),
+          this, SLOT(selfEndorseCertificateFetched(ndn::Ptr<EndorseCertificate>)));
 }
 
 AddContactPanel::~AddContactPanel()
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index b525215..7b07824 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -20,14 +20,19 @@
 #include <ndn.cxx/security/cache/ttl-certificate-cache.h>
 #include <ndn.cxx/security/encryption/basic-encryption-manager.h>
 #include <fstream>
+#include "logging.h"
 #endif
 
 using namespace ndn;
 using namespace ndn::security;
 
+INIT_LOGGER("ContactManager");
+
 ContactManager::ContactManager(Ptr<ContactStorage> contactStorage,
-                               Ptr<DnsStorage> dnsStorage)
-  : m_contactStorage(contactStorage)
+                               Ptr<DnsStorage> dnsStorage,
+                               QObject* parent)
+  : QObject(parent)
+  , m_contactStorage(contactStorage)
   , m_dnsStorage(dnsStorage)
 {
   setKeychain();
@@ -134,7 +139,7 @@
       // _LOG_DEBUG("Signing DONE!");
       if(NULL == newEndorseCertificate)
         return;
-
+      _LOG_DEBUG("About to update");
       m_contactStorage->updateSelfEndorseCertificate(newEndorseCertificate, identity);
 
       publishSelfEndorseCertificateInDNS(newEndorseCertificate);
@@ -145,7 +150,7 @@
       // _LOG_DEBUG("Signing DONE!");
       if(NULL == newEndorseCertificate)
         return;
-      
+      _LOG_DEBUG("About to Insert");
       m_contactStorage->addSelfEndorseCertificate(newEndorseCertificate, identity);
 
       publishSelfEndorseCertificateInDNS(newEndorseCertificate);
@@ -249,6 +254,8 @@
   data->setContent(content);
 
   m_keychain->signByIdentity(*data, identity);
+
+  m_dnsStorage->updateDnsSelfProfileData(*data, identity);
   
   Ptr<Blob> dnsBlob = data->encodeToWire();
 
diff --git a/src/contact-manager.h b/src/contact-manager.h
index 1cde4bc..3cc816d 100644
--- a/src/contact-manager.h
+++ b/src/contact-manager.h
@@ -17,7 +17,7 @@
 #include "contact-storage.h"
 #include "dns-storage.h"
 #include "endorse-certificate.h"
-#include "ndn.cxx/wrapper/wrapper.h"
+#include <ndn.cxx/wrapper/wrapper.h>
 #endif
 
 
@@ -27,7 +27,8 @@
 
 public:
   ContactManager(ndn::Ptr<ContactStorage> contactStorage,
-                 ndn::Ptr<DnsStorage> dnsStorage);
+                 ndn::Ptr<DnsStorage> dnsStorage,
+                 QObject* parent = 0);
 
   ~ContactManager();
 
diff --git a/src/contact-storage.cpp b/src/contact-storage.cpp
index 989702a..5c6dc31 100644
--- a/src/contact-storage.cpp
+++ b/src/contact-storage.cpp
@@ -34,15 +34,15 @@
 CREATE INDEX sp_index ON SelfProfile(profile_identity,profile_type); \n \
 ";
 
-const string INIT_PD_TABLE = "\
+const string INIT_SE_TABLE = "\
 CREATE TABLE IF NOT EXISTS                                           \n \
-  ProfileData(                                                       \n \
+  SelfEndorse(                                                       \n \
       identity          BLOB NOT NULL UNIQUE,                        \n \
-      profile_data      BLOB NOT NULL,                               \n \
+      endorse_data      BLOB NOT NULL,                               \n \
                                                                      \
       PRIMARY KEY (identity)                                         \n \
   );                                                                 \n \
-CREATE INDEX pd_index ON ProfileData(identity);                      \n \
+CREATE INDEX se_index ON SelfEndorse(identity);                      \n \
 ";
 
 const string INIT_TC_TABLE = "\
@@ -99,21 +99,21 @@
         throw LnException("Init \"error\" in SelfProfile");
     }
 
-  // Check if ProfileData table exists
-  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='ProfileData'", -1, &stmt, 0);
+  // Check if SelfEndorse table exists
+  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='SelfEndorse'", -1, &stmt, 0);
   res = sqlite3_step (stmt);
 
-  bool pdTableExist = false;
+  bool seTableExist = false;
   if (res == SQLITE_ROW)
-      pdTableExist = true;
+      seTableExist = true;
   sqlite3_finalize (stmt);
 
-  if(!pdTableExist)
+  if(!seTableExist)
     {
       char *errmsg = 0;
-      res = sqlite3_exec (m_db, INIT_PD_TABLE.c_str (), NULL, NULL, &errmsg);
+      res = sqlite3_exec (m_db, INIT_SE_TABLE.c_str (), NULL, NULL, &errmsg);
       if (res != SQLITE_OK && errmsg != 0)
-        throw LnException("Init \"error\" in ProfileData");
+        throw LnException("Init \"error\" in SelfEndorse");
     }
 
 
@@ -360,7 +360,7 @@
 ContactStorage::getSelfEndorseCertificate(const Name& identity)
 {
   sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, "SELECT profile_data FROM ProfileData where identity=?", -1, &stmt, 0);
+  sqlite3_prepare_v2 (m_db, "SELECT endorse_data FROM SelfEndorse where identity=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
 
   Ptr<Blob> result = NULL;
@@ -378,7 +378,7 @@
   Ptr<Blob> newEndorseCertificateBlob = newEndorseCertificate->encodeToWire();
 
   sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, "UPDATE ProfileData SET profile_data=? WHERE identity=?", -1, &stmt, 0);
+  sqlite3_prepare_v2 (m_db, "UPDATE SelfEndorse SET endorse_data=? WHERE identity=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
   sqlite3_bind_text(stmt, 2, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
@@ -390,7 +390,7 @@
   Ptr<Blob> newEndorseCertificateBlob = newEndorseCertificate->encodeToWire();
 
   sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, "INSERT INTO ProfileData (identity, profile_data) values (?, ?)", -1, &stmt, 0);
+  sqlite3_prepare_v2 (m_db, "INSERT INTO SelfEndorse (identity, endorse_data) values (?, ?)", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
   sqlite3_bind_text(stmt, 2, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
diff --git a/src/dns-storage.cpp b/src/dns-storage.cpp
index c71789f..13a8f25 100644
--- a/src/dns-storage.cpp
+++ b/src/dns-storage.cpp
@@ -12,12 +12,15 @@
 #include "exception.h"
 
 #include <boost/filesystem.hpp>
+#include "logging.h"
 
 
 using namespace std;
 using namespace ndn;
 namespace fs = boost::filesystem;
 
+INIT_LOGGER("DnsStorage");
+
 const string INIT_DD_TABLE = "\
 CREATE TABLE IF NOT EXISTS                                           \n \
   DnsData(                                                           \n \
@@ -77,6 +80,7 @@
 
   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);
@@ -89,6 +93,7 @@
     }
   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);