Fixing a bug in introducing others
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index d29fdb0..8775ae5 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -408,12 +408,9 @@
     }
   
   m_currentSelectedContact = m_contactList[i];
-  QString name = QString::fromStdString(m_currentSelectedContact->getName());
-  QString institution = QString::fromStdString(m_currentSelectedContact->getInstitution());
-  QString nameSpace = QString::fromStdString(m_currentSelectedContact->getNameSpace().toUri());
-  ui->NameData->setText(name);
-  ui->NameSpaceData->setText(nameSpace);
-  ui->InstitutionData->setText(institution);
+  ui->NameData->setText(QString::fromStdString(m_currentSelectedContact->getName()));
+  ui->NameSpaceData->setText(QString::fromStdString(m_currentSelectedContact->getNameSpace().toUri()));
+  ui->InstitutionData->setText(QString::fromStdString(m_currentSelectedContact->getInstitution()));
 
   if(m_currentSelectedContact->isIntroducer())
     {
@@ -512,7 +509,7 @@
   m_contactList = m_contactManager->getContactItemList();
   QStringList contactNameList;
   for(int i = 0; i < m_contactList.size(); i++)
-    contactNameList << QString::fromUtf8(m_contactList[i]->getAlias().c_str());
+    contactNameList << QString::fromStdString(m_contactList[i]->getAlias());
 
   m_contactListModel->setStringList(contactNameList);
 }
@@ -524,6 +521,7 @@
   menu.addAction(m_menuInvite);
   connect(m_menuInvite, SIGNAL(triggered()),
           this, SLOT(openStartChatDialog()));
+  menu.addSeparator();
   menu.addAction(m_menuAlias);
   connect(m_menuAlias, SIGNAL(triggered()),
           this, SLOT(openSetAliasDialog()));
@@ -548,10 +546,6 @@
 void
 ContactPanel::openStartChatDialog()
 {
-  // TimeInterval ti = time::NowUnixTimestamp();
-  // ostringstream oss;
-  // oss << ti.total_seconds();
-
   Name chatroom("/ndn/broadcast/chronos");
   chatroom.append(string("chatroom-") + getRandomString());
 
@@ -563,10 +557,6 @@
 void
 ContactPanel::startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer)
 {
-  _LOG_DEBUG("room: " << chatroom.toUtf8().constData());
-  _LOG_DEBUG("invitee: " << invitee.toUtf8().constData());
-  _LOG_DEBUG("introducer: " << std::boolalpha << isIntroducer);
-
   Name chatroomName(chatroom.toUtf8().constData());
   ChatDialog* chatDialog = new ChatDialog(m_contactManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName);
   m_chatDialogs.insert(pair <Name, ChatDialog*> (chatroomName, chatDialog));
@@ -588,24 +578,21 @@
 ContactPanel::startChatroom2(const ChronosInvitation& invitation, 
                              const security::IdentityCertificate& identityCertificate)
 {
-  _LOG_DEBUG("room: " << invitation.getChatroom().toUri());
-  _LOG_DEBUG("inviter: " << invitation.getInviterNameSpace().toUri());
-
   Name chatroomName("/ndn/broadcast/chronos");
   chatroomName.append(invitation.getChatroom());
   ChatDialog* chatDialog = new ChatDialog(m_contactManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName, true);
+
   connect(chatDialog, SIGNAL(closeChatDialog(const ndn::Name&)),
           this, SLOT(removeChatDialog(const ndn::Name&)));
 
   chatDialog->addChatDataRule(invitation.getInviterPrefix(), identityCertificate, true);
+  chatDialog->publishIntroCert(identityCertificate, true);
 
   Ptr<ContactItem> inviterItem = m_contactManager->getContact(invitation.getInviterNameSpace());
   chatDialog->addTrustAnchor(inviterItem->getSelfEndorseCertificate());
   
   m_chatDialogs.insert(pair <Name, ChatDialog*> (chatroomName, chatDialog));
 
-
-
   chatDialog->show();
 }
 
@@ -614,10 +601,7 @@
                                const security::IdentityCertificate& identityCertificate)
 {
   string prefix = m_localPrefix.toUri();
-
   m_handler->publishDataByIdentity (invitation.getInterestName(), prefix);
-  //TODO:: open chat dialog
-  _LOG_DEBUG("TO open chat dialog");
   startChatroom2(invitation, identityCertificate);
 }
 
@@ -639,7 +623,6 @@
       
       string filter("contact_namespace = '");
       filter.append(m_currentSelectedContact->getNameSpace().toUri()).append("'");
-      _LOG_DEBUG("filter: " << filter);
 
       m_trustScopeModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
       m_trustScopeModel->setTable("TrustScope");
@@ -648,8 +631,6 @@
       m_trustScopeModel->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
       m_trustScopeModel->setHeaderData(1, Qt::Horizontal, QObject::tr("Contact"));
       m_trustScopeModel->setHeaderData(2, Qt::Horizontal, QObject::tr("TrustScope"));
-      _LOG_DEBUG("row count: " << m_trustScopeModel->rowCount());
-
 
       ui->trustScopeList->setModel(m_trustScopeModel);
       ui->trustScopeList->setColumnHidden(0, true);
@@ -713,9 +694,7 @@
 
 void
 ContactPanel::saveScopeClicked()
-{
-  m_trustScopeModel->submitAll();
-}
+{ m_trustScopeModel->submitAll(); }
 
 void
 ContactPanel::endorseButtonClicked()
@@ -728,15 +707,15 @@
 ContactPanel::removeChatDialog(const ndn::Name& chatroomName)
 {
   map<Name, ChatDialog*>::iterator it = m_chatDialogs.find(chatroomName);
-  _LOG_DEBUG("about to leave 2!");
-  ChatDialog* deletedChat;
+
+  ChatDialog* deletedChat = NULL;
   if(it != m_chatDialogs.end())
     {
-      _LOG_DEBUG("about to leave 3!");
       deletedChat = it->second;
       m_chatDialogs.erase(it);      
     }
-  delete deletedChat;
+  if (deletedChat != NULL)
+    delete deletedChat;
 }
 
 #if WAF