major change: Add security support & Adjust GUI

Change-Id: I7abef37169dec1ef4b68e760dee5214c147c1915
diff --git a/src/contact-storage.h b/src/contact-storage.h
index da6c812..5662ebb 100644
--- a/src/contact-storage.h
+++ b/src/contact-storage.h
@@ -11,7 +11,8 @@
 #ifndef CHRONOS_CONTACT_STORAGE_H
 #define CHRONOS_CONTACT_STORAGE_H
 
-#include "contact-item.h"
+#include "contact.h"
+#include "endorse-collection.pb.h"
 #include <sqlite3.h>
 
 
@@ -23,22 +24,18 @@
 public:
   struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
 
-  ContactStorage();
+  ContactStorage(const ndn::Name& identity);
   
   ~ContactStorage() 
-  { sqlite3_close(m_db); }
+  {
+    sqlite3_close(m_db); 
+  }
 
   ndn::shared_ptr<Profile>
-  getSelfProfile(const ndn::Name& identity) const;
-
-  // ndn::Block
-  // getSelfEndorseCertificate(const ndn::Name& identity);
+  getSelfProfile();
   
   void
-  addSelfEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
-
-  // ndn::Block
-  // getEndorseCertificate(const ndn::Name& identity);
+  addSelfEndorseCertificate(const EndorseCertificate& endorseCertificate);
 
   void
   addEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
@@ -47,7 +44,7 @@
   updateCollectEndorse(const EndorseCertificate& endorseCertificate);
 
   void
-  getCollectEndorseList(const ndn::Name& name, std::vector<ndn::Buffer>& endorseList);
+  getCollectEndorse(EndorseCollection& endorseCollection);
 
   void
   getEndorseList(const ndn::Name& identity, std::vector<std::string>& endorseList);
@@ -58,10 +55,10 @@
   removeContact(const ndn::Name& identity);
 
   void
-  addContact(const ContactItem& contactItem);
+  addContact(const Contact& contact);
 
-  ndn::shared_ptr<ContactItem>
-  getContact(const ndn::Name& name);
+  ndn::shared_ptr<Contact>
+  getContact(const ndn::Name& identity) const;
 
   void
   updateIsIntroducer(const ndn::Name& identity, bool isIntroducer);
@@ -70,19 +67,48 @@
   updateAlias(const ndn::Name& identity, std::string alias);
 
   void
-  getAllContacts(std::vector<ndn::shared_ptr<ContactItem> >& contacts) const;
+  getAllContacts(std::vector<ndn::shared_ptr<Contact> >& contacts) const;
 
- 
+  void
+  updateDnsSelfProfileData(const ndn::Data& data)
+  {
+    updateDnsData(data.wireEncode(), "N/A", "PROFILE", data.getName().toUri());
+  }
+
+  void
+  updateDnsEndorseOthers(const ndn::Data& data, const std::string& endorsee)
+  {
+    updateDnsData(data.wireEncode(), endorsee, "ENDORSEE", data.getName().toUri());
+  }
   
+  void
+  updateDnsOthersEndorse(const ndn::Data& data)
+  {
+    updateDnsData(data.wireEncode(), "N/A", "ENDORSED", data.getName().toUri()); 
+  }
+
+  ndn::shared_ptr<ndn::Data>
+  getDnsData(const ndn::Name& name);
+
+  ndn::shared_ptr<ndn::Data>
+  getDnsData(const std::string& name, const std::string& type);
 
 private:
+  std::string
+  getDBName();
+  
   void
   initializeTable(const std::string& tableName, const std::string& sqlCreateStmt);
 
   bool
   doesContactExist(const ndn::Name& name);
 
+  void
+  updateDnsData(const ndn::Block& data, const std::string& name, const std::string& type, const std::string& dataName);
+
 private:
+  ndn::Name m_identity;
+
   sqlite3 *m_db;
 };