Add Trust Scope UI operation
diff --git a/src/contact-item.cpp b/src/contact-item.cpp
index c14b328..b737daa 100644
--- a/src/contact-item.cpp
+++ b/src/contact-item.cpp
@@ -24,6 +24,7 @@
 ContactItem::ContactItem(const EndorseCertificate& selfEndorseCertificate,
                          const string& alias)
   : m_selfEndorseCertificate(selfEndorseCertificate)
+  , m_isIntroducer(false)
 {
   Name endorsedkeyName = selfEndorseCertificate.getPublicKeyName();
   Ptr<const signature::Sha256WithRsa> endorseSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(selfEndorseCertificate.getSignature());
@@ -65,3 +66,12 @@
   m_institution = string(institutionBlob->buf(), institutionBlob->size());
 }
 
+ContactItem::ContactItem(const ContactItem& contactItem)
+  : m_selfEndorseCertificate(contactItem.m_selfEndorseCertificate)
+  , m_namespace(contactItem.m_namespace)
+  , m_alias(contactItem.m_alias)
+  , m_name(contactItem.m_name)
+  , m_institution(contactItem.m_institution)
+  , m_isIntroducer(false)
+{}
+
diff --git a/src/contact-item.h b/src/contact-item.h
index e681ba7..4dada26 100644
--- a/src/contact-item.h
+++ b/src/contact-item.h
@@ -22,7 +22,10 @@
 public:
   ContactItem(const EndorseCertificate& selfEndorseCertificate,
               const std::string& alias = std::string());
+
+  ContactItem(const ContactItem& contactItem);
   
+  virtual
   ~ContactItem() {}
 
   inline const EndorseCertificate&
@@ -49,6 +52,10 @@
   getPublicKeyName() const
   { return m_selfEndorseCertificate.getPublicKeyName(); }
 
+  inline bool
+  isIntroducer()
+  { return m_isIntroducer; }
+
 protected:
   EndorseCertificate m_selfEndorseCertificate;
 
@@ -57,6 +64,8 @@
 
   std::string m_name;
   std::string m_institution;
+
+  bool m_isIntroducer;
 };
 
 #endif
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index 0407d8f..7940145 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -40,14 +40,14 @@
 Q_DECLARE_METATYPE(ChronosInvitation)
 
 ContactPanel::ContactPanel(Ptr<ContactManager> contactManager, QWidget *parent) 
-    : QDialog(parent)
-    , ui(new Ui::ContactPanel)
-    , m_contactListModel(new QStringListModel)
-    , m_startChatDialog(new StartChatDialog)
-    , m_invitationDialog(new InvitationDialog)
-    , m_settingDialog(new SettingDialog)
-    , m_menuInvite(new QAction("&Chat", this))
-    , m_menuAlias(new QAction("&Set Alias", this))
+  : QDialog(parent)
+  , ui(new Ui::ContactPanel)
+  , m_contactListModel(new QStringListModel)
+  , m_startChatDialog(new StartChatDialog)
+  , m_invitationDialog(new InvitationDialog)
+  , m_settingDialog(new SettingDialog)
+  , m_menuInvite(new QAction("&Chat", this))
+  , m_menuAlias(new QAction("&Set Alias", this))
 {
   qRegisterMetaType<ndn::security::IdentityCertificate>("IdentityCertificate");
   qRegisterMetaType<ChronosInvitation>("ChronosInvitation");
@@ -111,8 +111,8 @@
   connect(this, SIGNAL(newInvitationReady()),
           this, SLOT(openInvitationDialog()));
 
-
-
+  connect(ui->isIntroducer, SIGNAL(stateChanged(int)),
+          this, SLOT(isIntroducerChanged(int)));
 }
 
 ContactPanel::~ContactPanel()
@@ -121,6 +121,8 @@
   delete m_contactListModel;
   delete m_profileEditor;
   delete m_addContactPanel;
+  if(NULL != m_currentContactTrustScopeListModel)
+    delete m_currentContactTrustScopeListModel;
 
   delete m_menuInvite;
 
@@ -304,16 +306,33 @@
         break;
     }
   
-  QString name = QString::fromUtf8(m_contactList[i]->getName().c_str());
-  QString institution = QString::fromUtf8(m_contactList[i]->getInstitution().c_str());
-  QString nameSpace = QString::fromUtf8(m_contactList[i]->getNameSpace().toUri().c_str());
+  m_currentSelectedContact = m_contactList[i];
+  QString name = QString::fromUtf8(m_currentSelectedContact->getName().c_str());
+  QString institution = QString::fromUtf8(m_currentSelectedContact->getInstitution().c_str());
+  QString nameSpace = QString::fromUtf8(m_currentSelectedContact->getNameSpace().toUri().c_str());
   ui->NameData->setText(name);
   ui->NameSpaceData->setText(nameSpace);
   ui->InstitutionData->setText(institution);
 
-  m_currentSelectedContactAlias = alias;
-  m_currentSelectedContactNamespace = m_contactList[i]->getNameSpace().toUri();
+  // m_currentSelectedContactAlias = alias;
+  // m_currentSelectedContactNamespace = m_contactList[i]->getNameSpace().toUri();
   // _LOG_DEBUG("current Alias: " << m_currentSelectedContact);
+
+  if(m_currentSelectedContact->isIntroducer())
+    {
+      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
+    {
+      ui->isIntroducer->setChecked(false);
+      ui->addScope->setEnabled(false);
+      ui->deleteScope->setEnabled(false);
+      delete m_currentContactTrustScopeListModel;
+    }
 }
 
 void
@@ -373,7 +392,7 @@
 void
 ContactPanel::openSetAliasDialog()
 {
-  m_setAliasDialog->setTargetIdentity(m_currentSelectedContactNamespace);
+  m_setAliasDialog->setTargetIdentity(m_currentSelectedContact->getNameSpace().toUri());
   m_setAliasDialog->show();
 }
 
@@ -394,7 +413,7 @@
   Name chatroom("/ndn/broadcast/chronos");
   chatroom.append(string("chatroom-") + getRandomString());
 
-  m_startChatDialog->setInvitee(m_currentSelectedContactNamespace, chatroom.toUri());
+  m_startChatDialog->setInvitee(m_currentSelectedContact->getNameSpace().toUri(), chatroom.toUri());
   m_startChatDialog->show();
 }
 
@@ -461,6 +480,22 @@
   m_handler->publishDataByIdentity (invitation.getInterestName(), empty);
 }
 
+void
+ContactPanel::isIntroducerChanged(int state)
+{
+  if(state == Qt::Checked)
+    {
+      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);
+    }
+}
 
 #if WAF
 #include "contactpanel.moc"
diff --git a/src/contactpanel.h b/src/contactpanel.h
index d6c0787..bbe7c52 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -134,6 +134,9 @@
   void
   rejectInvitation(const ChronosInvitation& invitation);
 
+  void
+  isIntroducerChanged(int state);
+
 private:
   Ui::ContactPanel *ui;
   ndn::Ptr<ContactManager> m_contactManager;
@@ -157,8 +160,10 @@
   ndn::Name m_localPrefix;
   ndn::Name m_inviteListenPrefix;
 
-  std::string m_currentSelectedContactAlias;
-  std::string m_currentSelectedContactNamespace;
+  // std::string m_currentSelectedContactAlias;
+  // std::string m_currentSelectedContactNamespace;
+  ndn::Ptr<ContactItem> m_currentSelectedContact;
+  QStringListModel* m_currentContactTrustScopeListModel;
 
 
 };
diff --git a/src/contactpanel.ui b/src/contactpanel.ui
index 0e5bbfb..08c15a3 100644
--- a/src/contactpanel.ui
+++ b/src/contactpanel.ui
@@ -206,13 +206,19 @@
                <property name="text">
                 <string>Add Scope</string>
                </property>
+               <property name="autoDefault">
+                <bool>false</bool>
+               </property>
               </widget>
              </item>
              <item>
-              <widget class="QPushButton" name="addScope_2">
+              <widget class="QPushButton" name="deleteScope">
                <property name="text">
                 <string>Delete Scope</string>
                </property>
+               <property name="autoDefault">
+                <bool>false</bool>
+               </property>
               </widget>
              </item>
             </layout>
diff --git a/src/trusted-contact.cpp b/src/trusted-contact.cpp
index 7db842a..9e574b7 100644
--- a/src/trusted-contact.cpp
+++ b/src/trusted-contact.cpp
@@ -21,6 +21,8 @@
 			       const string& alias)
   : ContactItem(selfEndorseCertificate, alias)
 {
+  m_isIntroducer = true;
+
   tokenizer<escaped_list_separator<char> > trustScopeItems(trustScope, escaped_list_separator<char> ("\\", " \t", "'\""));
 
   tokenizer<escaped_list_separator<char> >::iterator it = trustScopeItems.begin();
@@ -33,6 +35,20 @@
     }
 }
 
+TrustedContact::TrustedContact(const ContactItem& contactItem)
+  : ContactItem(contactItem)
+{
+  m_isIntroducer = true;
+}
+
+TrustedContact::TrustedContact(const TrustedContact& trustedContact)
+  : ContactItem(trustedContact)
+  , m_trustScope(trustedContact.m_trustScope)
+  , m_trustScopeName(trustedContact.m_trustScopeName)
+{
+  m_isIntroducer = true;
+}
+
 bool 
 TrustedContact::canBeTrustedFor(const Name& name)
 {
@@ -57,3 +73,4 @@
 
   return Ptr<Blob>(new Blob(oss.str().c_str(), oss.str().size()));
 }
+
diff --git a/src/trusted-contact.h b/src/trusted-contact.h
index bd2e84a..b080dbb 100644
--- a/src/trusted-contact.h
+++ b/src/trusted-contact.h
@@ -14,13 +14,18 @@
 #include "contact-item.h"
 #include <ndn.cxx/regex/regex.h>
 
-class TrustedContact : public ContactItem
+class TrustedContact : public virtual ContactItem
 {
 public:
   TrustedContact(const EndorseCertificate& selfEndorseCertificate,
                  const std::string& trustScope,
                  const std::string& alias = std::string());
 
+  TrustedContact(const ContactItem& contactItem);
+
+  TrustedContact(const TrustedContact& trustedContact);
+ 
+  virtual
   ~TrustedContact() {}
 
   void
@@ -33,6 +38,10 @@
   ndn::Ptr<ndn::Blob> 
   getTrustScopeBlob() const;
 
+  inline const std::vector<ndn::Name>&
+  getTrustScopeList() const
+  { return m_trustScopeName; }
+
 private:
   std::vector<ndn::Ptr<ndn::Regex> > m_trustScope;
   std::vector<ndn::Name> m_trustScopeName;