Merging TrustedContact to ContactItem
diff --git a/src/trusted-contact.cpp b/disable/trusted-contact.cpp
similarity index 100%
rename from src/trusted-contact.cpp
rename to disable/trusted-contact.cpp
diff --git a/src/trusted-contact.h b/disable/trusted-contact.h
similarity index 100%
rename from src/trusted-contact.h
rename to disable/trusted-contact.h
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index 80675ea..b1cec57 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -70,7 +70,7 @@
 AddContactPanel::onAddClicked()
 {
   ContactItem contactItem(*m_currentEndorseCertificate);
-  m_contactManager->getContactStorage()->addNormalContact(contactItem);
+  m_contactManager->getContactStorage()->addContact(contactItem);
   emit newContactAdded();
   this->close();
 }
diff --git a/src/contact-item.cpp b/src/contact-item.cpp
index b737daa..eb342d6 100644
--- a/src/contact-item.cpp
+++ b/src/contact-item.cpp
@@ -22,9 +22,10 @@
 INIT_LOGGER("ContactItem");
 
 ContactItem::ContactItem(const EndorseCertificate& selfEndorseCertificate,
+                         bool isIntroducer,
                          const string& alias)
   : m_selfEndorseCertificate(selfEndorseCertificate)
-  , m_isIntroducer(false)
+  , m_isIntroducer(isIntroducer)
 {
   Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName();
   Ptr<const signature::Sha256WithRsa> endorseSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(selfEndorseCertificate.getSignature());
@@ -72,6 +73,18 @@
   , m_alias(contactItem.m_alias)
   , m_name(contactItem.m_name)
   , m_institution(contactItem.m_institution)
-  , m_isIntroducer(false)
+  , m_isIntroducer(contactItem.m_isIntroducer)
+  , m_trustScope(contactItem.m_trustScope)
+  , m_trustScopeName(contactItem.m_trustScopeName)
 {}
 
+bool 
+ContactItem::canBeTrustedFor(const Name& name)
+{
+  vector<Ptr<Regex> >::iterator it = m_trustScope.begin();
+
+  for(; it != m_trustScope.end(); it++)
+    if((*it)->match(name))
+      return true;
+  return false;
+}
diff --git a/src/contact-item.h b/src/contact-item.h
index 4dada26..fcf24a1 100644
--- a/src/contact-item.h
+++ b/src/contact-item.h
@@ -12,6 +12,7 @@
 #define LINKNDN_CONTACT_ITEM_H
 
 #include <ndn.cxx/data.h>
+#include <ndn.cxx/regex/regex.h>
 #include <vector>
 #include "endorse-certificate.h"
 
@@ -21,6 +22,7 @@
 
 public:
   ContactItem(const EndorseCertificate& selfEndorseCertificate,
+              bool isIntroducer = false,
               const std::string& alias = std::string());
 
   ContactItem(const ContactItem& contactItem);
@@ -53,9 +55,23 @@
   { return m_selfEndorseCertificate.getPublicKeyName(); }
 
   inline bool
-  isIntroducer()
+  isIntroducer() const
   { return m_isIntroducer; }
 
+  void
+  addTrustScope(const ndn::Name& nameSpace)
+  {
+    m_trustScopeName.push_back(nameSpace);
+    m_trustScope.push_back(ndn::Regex::fromName(nameSpace)); 
+  }
+
+  bool
+  canBeTrustedFor(const ndn::Name& name);
+
+  inline const std::vector<ndn::Name>&
+  getTrustScopeList() const
+  { return m_trustScopeName; }
+
 protected:
   EndorseCertificate m_selfEndorseCertificate;
 
@@ -66,6 +82,9 @@
   std::string m_institution;
 
   bool m_isIntroducer;
+
+  std::vector<ndn::Ptr<ndn::Regex> > m_trustScope;
+  std::vector<ndn::Name> m_trustScopeName;
 };
 
 #endif
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 9bd8ca2..2c30921 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -161,31 +161,11 @@
 
 vector<Ptr<ContactItem> >
 ContactManager::getContactItemList()
-{
-  vector<Ptr<ContactItem> > result;
-  
-  vector<Ptr<ContactItem> > ncList = m_contactStorage->getAllNormalContacts();
-  vector<Ptr<TrustedContact> > tcList = m_contactStorage->getAllTrustedContacts();
-
-  result.insert(result.end(), tcList.begin(), tcList.end());
-  result.insert(result.end(), ncList.begin(), ncList.end());
-
-  return result;
-}
+{ return m_contactStorage->getAllContacts(); }
 
 Ptr<ContactItem>
 ContactManager::getContact(const ndn::Name& contactNamespace)
-{
-  Ptr<ContactItem> contactItem = m_contactStorage->getNormalContact(contactNamespace);
-  if(NULL != contactItem)
-    return contactItem;
-  
-  contactItem = m_contactStorage->getTrustedContact(contactNamespace);
-  if(NULL != contactItem)
-    return contactItem;
-  
-  return NULL;
-}
+{ return m_contactStorage->getContact(contactNamespace); }
 
 Ptr<EndorseCertificate>
 ContactManager::getSignedSelfEndorseCertificate(const Name& identity,
diff --git a/src/contact-storage.cpp b/src/contact-storage.cpp
index 7a24fdc..073eaa1 100644
--- a/src/contact-storage.cpp
+++ b/src/contact-storage.cpp
@@ -45,31 +45,30 @@
 CREATE INDEX se_index ON SelfEndorse(identity);                      \n \
 ";
 
-const string INIT_TC_TABLE = "\
+const string INIT_CONTACT_TABLE = "\
 CREATE TABLE IF NOT EXISTS                                           \n \
-  TrustedContact(                                                    \n \
+  Contact(                                                           \n \
       contact_namespace BLOB NOT NULL,                               \n \
       contact_alias     BLOB NOT NULL,                               \n \
       self_certificate  BLOB NOT NULL,                               \n \
-      trust_scope       BLOB NOT NULL,                               \n \
+      is_introducer     INTEGER DEFAULT 0,                           \n \
                                                                      \
       PRIMARY KEY (contact_namespace)                                \n \
   );                                                                 \n \
                                                                      \
-CREATE INDEX tc_index ON TrustedContact(contact_namespace);          \n \
+CREATE INDEX contact_index ON TrustedContact(contact_namespace);     \n \
 ";
 
-const string INIT_NC_TABLE = "\
+const string INIT_TS_TABLE = "\
 CREATE TABLE IF NOT EXISTS                                           \n \
-  NormalContact(                                                     \n \
+  TrustScope(                                                        \n \
       contact_namespace BLOB NOT NULL,                               \n \
-      contact_alias     BLOB NOT NULL,                               \n \
-      self_certificate  BLOB NOT NULL,                               \n \
+      trust_scope       BLOB NOT NULL,                               \n \
                                                                      \
-      PRIMARY KEY (contact_namespace)                                \n \
+      PRIMARY KEY (contact_namespace, trust_scope)                   \n \
   );                                                                 \n \
                                                                      \
-CREATE INDEX nc_index ON NormalContact(contact_namespace);           \n \
+CREATE INDEX ts_index ON TrustedContact(contact_namespace);          \n \
 ";
 
 ContactStorage::ContactStorage()
@@ -118,38 +117,37 @@
 
 
   // Check if TrustedContact table exists
-  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='TrustedContact'", -1, &stmt, 0);
+  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='Contact'", -1, &stmt, 0);
   res = sqlite3_step (stmt);
 
-  bool tcTableExist = false;
+  bool contactTableExist = false;
   if (res == SQLITE_ROW)
-      tcTableExist = true;
+      contactTableExist = true;
   sqlite3_finalize (stmt);
 
-  if(!tcTableExist)
+  if(!contactTableExist)
     {
       char *errmsg = 0;
-      res = sqlite3_exec (m_db, INIT_TC_TABLE.c_str (), NULL, NULL, &errmsg);
+      res = sqlite3_exec (m_db, INIT_CONTACT_TABLE.c_str (), NULL, NULL, &errmsg);
       if (res != SQLITE_OK && errmsg != 0)
-        throw LnException("Init \"error\" in TrustedContact");
+        throw LnException("Init \"error\" in Contact");
     }
-    
-  // Check if NormalContact table exists
-  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='NormalContact'", -1, &stmt, 0);
+
+  // Check if TrustedContact table exists
+  sqlite3_prepare_v2 (m_db, "SELECT name FROM sqlite_master WHERE type='table' And name='TrustScope'", -1, &stmt, 0);
   res = sqlite3_step (stmt);
 
-  bool ncTableExist = false;
+  bool tsTableExist = false;
   if (res == SQLITE_ROW)
-      ncTableExist = true;
+      tsTableExist = true;
   sqlite3_finalize (stmt);
 
-  if(!ncTableExist)
+  if(!tsTableExist)
     {
       char *errmsg = 0;
-      res = sqlite3_exec (m_db, INIT_NC_TABLE.c_str (), NULL, NULL, &errmsg);
-        
+      res = sqlite3_exec (m_db, INIT_TS_TABLE.c_str (), NULL, NULL, &errmsg);
       if (res != SQLITE_OK && errmsg != 0)
-        throw LnException("Init \"error\" in NormalContact");
+        throw LnException("Init \"error\" in TrustScope");
     }
 }
 
@@ -218,89 +216,73 @@
 
   return profile;
 }
-
-void
-ContactStorage::addTrustedContact(const TrustedContact& trustedContact)
-{
-  if(doesTrustedContactExist(trustedContact.getNameSpace()))
-    throw LnException("Trusted Contact has already existed");
-  
-  sqlite3_stmt *stmt;  
-  sqlite3_prepare_v2 (m_db, 
-                      "INSERT INTO TrustedContact (contact_namespace, contact_alias, self_certificate, trust_scope) values (?, ?, ?, ?)", 
-                      -1, 
-                      &stmt, 
-                      0);
-  
-  sqlite3_bind_text(stmt, 1, trustedContact.getNameSpace().toUri().c_str(),  trustedContact.getNameSpace().toUri().size (), SQLITE_TRANSIENT);
-  sqlite3_bind_text(stmt, 2, trustedContact.getAlias().c_str(), trustedContact.getAlias().size(), SQLITE_TRANSIENT);
-  Ptr<Blob> selfCertificateBlob = trustedContact.getSelfEndorseCertificate().encodeToWire();
-  sqlite3_bind_text(stmt, 3, selfCertificateBlob->buf(), selfCertificateBlob->size(), SQLITE_TRANSIENT);
-  Ptr<Blob> trustScopeBlob = trustedContact.getTrustScopeBlob();
-  sqlite3_bind_text(stmt, 4, trustScopeBlob->buf(), trustScopeBlob->size(),SQLITE_TRANSIENT);
-
-  int res = sqlite3_step (stmt);
-  sqlite3_finalize (stmt);
-}
   
 void
-ContactStorage::addNormalContact(const ContactItem& normalContact)
+ContactStorage::addContact(const ContactItem& contact)
 {
-  if(doesNormalContactExist(normalContact.getNameSpace()))
+  if(doesContactExist(contact.getNameSpace()))
     throw LnException("Normal Contact has already existed");
 
+  bool isIntroducer = contact.isIntroducer();
+
   sqlite3_stmt *stmt;  
   sqlite3_prepare_v2 (m_db, 
-                      "INSERT INTO NormalContact (contact_namespace, contact_alias, self_certificate) values (?, ?, ?)", 
+                      "INSERT INTO Contact (contact_namespace, contact_alias, self_certificate, is_introducer) values (?, ?, ?, ?)", 
                       -1, 
                       &stmt, 
                       0);
 
-  sqlite3_bind_text(stmt, 1, normalContact.getNameSpace().toUri().c_str(),  normalContact.getNameSpace().toUri().size (), SQLITE_TRANSIENT);
-  sqlite3_bind_text(stmt, 2, normalContact.getAlias().c_str(), normalContact.getAlias().size(), SQLITE_TRANSIENT);
-  Ptr<Blob> selfCertificateBlob = normalContact.getSelfEndorseCertificate().encodeToWire();
+  sqlite3_bind_text(stmt, 1, contact.getNameSpace().toUri().c_str(),  contact.getNameSpace().toUri().size (), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 2, contact.getAlias().c_str(), contact.getAlias().size(), SQLITE_TRANSIENT);
+  Ptr<Blob> selfCertificateBlob = contact.getSelfEndorseCertificate().encodeToWire();
   sqlite3_bind_text(stmt, 3, selfCertificateBlob->buf(), selfCertificateBlob->size(), SQLITE_TRANSIENT);
+  sqlite3_bind_int(stmt, 4, (isIntroducer ? 1 : 0));
 
   int res = sqlite3_step (stmt);
   // _LOG_DEBUG("res " << res);
   sqlite3_finalize (stmt);
+
+  if(isIntroducer)
+    {
+      const vector<Name>& scopeList = contact.getTrustScopeList();
+      vector<Name>::const_iterator it = scopeList.begin();
+      string nameSpace = contact.getNameSpace().toUri();
+      
+      while(it != scopeList.end())
+        {
+          sqlite3_prepare_v2 (m_db, 
+                              "INSERT INTO TrustScope (contact_namespace, trust_scope) values (?, ?)", 
+                              -1, 
+                              &stmt, 
+                              0);
+          sqlite3_bind_text(stmt, 1, nameSpace.c_str(),  nameSpace.size (), SQLITE_TRANSIENT);
+          sqlite3_bind_text(stmt, 2, it->toUri().c_str(), it->toUri().size(), SQLITE_TRANSIENT);
+          res = sqlite3_step (stmt);
+          sqlite3_finalize (stmt);          
+          it++;
+        }
+    }
 }
 
 void 
 ContactStorage::updateAlias(const ndn::Name& identity, std::string alias)
 {
-  if(doesNormalContactExist(identity))
-    {
-      sqlite3_stmt *stmt;
-      sqlite3_prepare_v2 (m_db, "UPDATE NormalContact SET contact_alias=? WHERE contact_namespace=?", -1, &stmt, 0);
-      sqlite3_bind_text(stmt, 1, alias.c_str(), alias.size(), SQLITE_TRANSIENT);
-      sqlite3_bind_text(stmt, 2, identity.toUri().c_str(),  identity.toUri().size (), SQLITE_TRANSIENT);
-      int res = sqlite3_step (stmt);
-      sqlite3_finalize (stmt);
-      return;
-    }
-  if(doesTrustedContactExist(identity))
-    {
-      sqlite3_stmt *stmt;
-      sqlite3_prepare_v2 (m_db, "UPDATE TrustedContact SET contact_alias=? WHERE contact_namespace=?", -1, &stmt, 0);
-      sqlite3_bind_text(stmt, 1, alias.c_str(), alias.size(), SQLITE_TRANSIENT);
-      sqlite3_bind_text(stmt, 2, identity.toUri().c_str(),  identity.toUri().size (), SQLITE_TRANSIENT);
-      int res = sqlite3_step (stmt);
-      sqlite3_finalize (stmt);
-      return;
-    }
+  sqlite3_stmt *stmt;
+  sqlite3_prepare_v2 (m_db, "UPDATE Contact SET contact_alias=? WHERE contact_namespace=?", -1, &stmt, 0);
+  sqlite3_bind_text(stmt, 1, alias.c_str(), alias.size(), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 2, identity.toUri().c_str(),  identity.toUri().size (), SQLITE_TRANSIENT);
+  int res = sqlite3_step (stmt);
+  sqlite3_finalize (stmt);
+  return;
 }
 
 bool
-ContactStorage::doesContactExist(const Name& name, bool normal)
+ContactStorage::doesContactExist(const Name& name)
 {
   bool result = false;
   
   sqlite3_stmt *stmt;
-  if(normal)
-    sqlite3_prepare_v2 (m_db, "SELECT count(*) FROM NormalContact WHERE contact_namespace=?", -1, &stmt, 0);
-  else
-    sqlite3_prepare_v2 (m_db, "SELECT count(*) FROM TrustedContact WHERE contact_namespace=?", -1, &stmt, 0);
+  sqlite3_prepare_v2 (m_db, "SELECT count(*) FROM Contact WHERE contact_namespace=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, name.toUri().c_str(), name.toUri().size(), SQLITE_TRANSIENT);
 
   int res = sqlite3_step (stmt);
@@ -315,43 +297,13 @@
   return result;
 }
 
-vector<Ptr<TrustedContact> >
-ContactStorage::getAllTrustedContacts() const
-{
-  vector<Ptr<TrustedContact> > trustedContacts;
-
-  sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, 
-                      "SELECT contact_alias, self_certificate, trust_scope FROM TrustedContact", 
-                      -1, 
-                      &stmt, 
-                      0);
-  
-  while( sqlite3_step (stmt) == SQLITE_ROW)
-    {
-      string alias(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
-      Ptr<Data> certData = Data::decodeFromWire(certBlob);
-      EndorseCertificate endorseCertificate(*certData);
-      string trustScope(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 2)), sqlite3_column_bytes (stmt, 2));
-
-      trustedContacts.push_back(Ptr<TrustedContact>(new TrustedContact(endorseCertificate, trustScope, alias)));      
-    }
-
-  return trustedContacts;
-}
-
 vector<Ptr<ContactItem> >
-ContactStorage::getAllNormalContacts() const
+ContactStorage::getAllContacts() const
 {
-  vector<Ptr<ContactItem> > normalContacts;
+  vector<Ptr<ContactItem> > contacts;
 
   sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, 
-                      "SELECT contact_alias, self_certificate FROM NormalContact", 
-                      -1, 
-                      &stmt, 
-                      0);
+  sqlite3_prepare_v2 (m_db, "SELECT contact_alias, self_certificate, is_introducer FROM Contact", -1, &stmt, 0);
   
   while( sqlite3_step (stmt) == SQLITE_ROW)
     {
@@ -359,22 +311,37 @@
       Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
       Ptr<Data> certData = Data::decodeFromWire(certBlob);
       EndorseCertificate endorseCertificate(*certData);
+      int isIntroducer = sqlite3_column_int (stmt, 2);
 
-      normalContacts.push_back(Ptr<ContactItem>(new ContactItem(endorseCertificate, alias)));      
+      contacts.push_back(Ptr<ContactItem>(new ContactItem(endorseCertificate, isIntroducer, alias)));      
     }
-  
-  return normalContacts;
+  sqlite3_finalize (stmt);  
+
+  vector<Ptr<ContactItem> >::iterator it = contacts.begin();
+  for(; it != contacts.end(); it++)
+    {
+      if((*it)->isIntroducer())
+        {
+          sqlite3_prepare_v2 (m_db, "SELECT trust_scope FROM TrustScope WHERE contact_namespace=?", -1, &stmt, 0);
+          sqlite3_bind_text(stmt, 1, (*it)->getNameSpace().toUri().c_str(), (*it)->getNameSpace().toUri().size(), SQLITE_TRANSIENT);
+
+          while( sqlite3_step (stmt) == SQLITE_ROW)
+            {
+              Name scope(string(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0)));
+              (*it)->addTrustScope(scope);
+            }
+          sqlite3_finalize (stmt);  
+        }
+    }
+
+  return contacts;
 }
 
 Ptr<ContactItem>
-ContactStorage::getNormalContact(const Name& name)
+ContactStorage::getContact(const Name& name)
 {
   sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, 
-                      "SELECT contact_alias, self_certificate FROM NormalContact where contact_namespace=?", 
-                      -1, 
-                      &stmt, 
-                      0);
+  sqlite3_prepare_v2 (m_db, "SELECT contact_alias, self_certificate, is_introducer FROM Contact where contact_namespace=?", -1, &stmt, 0);
   sqlite3_bind_text (stmt, 1, name.toUri().c_str(), name.toUri().size(), SQLITE_TRANSIENT);
   
   if( sqlite3_step (stmt) == SQLITE_ROW)
@@ -383,36 +350,13 @@
       Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
       Ptr<Data> certData = Data::decodeFromWire(certBlob);
       EndorseCertificate endorseCertificate(*certData);
+      int isIntroducer = sqlite3_column_int (stmt, 2);
 
-      return Ptr<ContactItem>(new ContactItem(endorseCertificate, alias));      
+      return Ptr<ContactItem>(new ContactItem(endorseCertificate, isIntroducer, alias));      
     } 
   return NULL;
 }
 
-Ptr<TrustedContact>
-ContactStorage::getTrustedContact(const Name& name)
-{
-  sqlite3_stmt *stmt;
-  sqlite3_prepare_v2 (m_db, 
-                      "SELECT contact_alias, self_certificate, trust_scope FROM TrustedContact where contact_namespace=?", 
-                      -1, 
-                      &stmt, 
-                      0);
-  sqlite3_bind_text (stmt, 1, name.toUri().c_str(), name.toUri().size(), SQLITE_TRANSIENT);
-  
-  if( sqlite3_step (stmt) == SQLITE_ROW)
-    {
-      string alias(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
-      Ptr<Data> certData = Data::decodeFromWire(certBlob);
-      EndorseCertificate endorseCertificate(*certData);
-      string trustScope(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 2)), sqlite3_column_bytes (stmt, 2));
-
-      return Ptr<TrustedContact>(new TrustedContact(endorseCertificate, trustScope, alias));      
-    }
-  return NULL;
-}
-
 Ptr<Profile>
 ContactStorage::getSelfProfile(const Name& identity) const
 {  
diff --git a/src/contact-storage.h b/src/contact-storage.h
index d0f5f5b..882dff5 100644
--- a/src/contact-storage.h
+++ b/src/contact-storage.h
@@ -12,7 +12,6 @@
 #define LINKNDN_CONTACT_STORAGE_H
 
 #include <sqlite3.h>
-#include "trusted-contact.h"
 #include "contact-item.h"
 #include "endorse-certificate.h"
 #include <ndn.cxx/security/identity/identity-manager.h>
@@ -35,25 +34,16 @@
   getSelfProfile(const ndn::Name& identity);
 
   void
-  addTrustedContact(const TrustedContact& trustedContact);
-  
-  void
-  addNormalContact(const ContactItem& contactItem);
+  addContact(const ContactItem& contactItem);
 
   void 
   updateAlias(const ndn::Name& identity, std::string alias);
 
-  std::vector<ndn::Ptr<TrustedContact> >
-  getAllTrustedContacts() const;
-
   std::vector<ndn::Ptr<ContactItem> >
-  getAllNormalContacts() const;
+  getAllContacts() const;
 
   ndn::Ptr<ContactItem>
-  getNormalContact(const ndn::Name& name);
-
-  ndn::Ptr<TrustedContact>
-  getTrustedContact(const ndn::Name& name);
+  getContact(const ndn::Name& name);
     
   ndn::Ptr<Profile>
   getSelfProfile(const ndn::Name& identity) const;
@@ -71,16 +61,8 @@
   bool
   doesSelfEntryExist(const ndn::Name& identity, const std::string& profileType);
 
-  inline bool
-  doesTrustedContactExist(const ndn::Name& name)
-  { return doesContactExist(name, false); }
-
-  inline bool
-  doesNormalContactExist(const ndn::Name& name)
-  { return doesContactExist(name, true); }
-
   bool
-  doesContactExist(const ndn::Name& name, bool normal);
+  doesContactExist(const ndn::Name& name);
 
 private:
   sqlite3 *m_db;
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index 7940145..cc44a37 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -323,7 +323,6 @@
       ui->isIntroducer->setChecked(true);
       ui->addScope->setEnabled(true);
       ui->deleteScope->setEnabled(true);
-      Ptr<TrustedContact> trustedContact = boost::dynamic_pointer_cast<TrustedContact>(m_currentSelectedContact);      
       m_currentContactTrustScopeListModel = new QStringListModel;
     }
   else
@@ -487,11 +486,9 @@
     {
       ui->addScope->setEnabled(true);
       ui->deleteScope->setEnabled(true);
-      Ptr<TrustedContact> trustedContact = boost::dynamic_pointer_cast<TrustedContact>(m_currentSelectedContact);      
     }
   else
     {
-      ui->isIntroducer->setChecked(false);
       ui->addScope->setEnabled(false);
       ui->deleteScope->setEnabled(false);
     }