do not use sync app socket for local prefix discovery
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 6fdc657..7ed7cfd 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -55,7 +55,7 @@
   connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
   connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
   connect(treeButton, SIGNAL(pressed()), this, SLOT(treeButtonPressed()));
-  connect(refreshButton, SIGNAL(pressed()), this, SLOT(getLocalPrefix()));
+  connect(refreshButton, SIGNAL(pressed()), this, SLOT(updateLocalPrefix()));
   connect(this, SIGNAL(dataReceived(QString, const char *, size_t, bool, bool)), this, SLOT(processData(QString, const char *, size_t, bool, bool)));
   connect(this, SIGNAL(treeUpdated(const std::vector<Sync::MissingDataInfo>)), this, SLOT(processTreeUpdate(const std::vector<Sync::MissingDataInfo>)));
   connect(m_timer, SIGNAL(timeout()), this, SLOT(replot()));
@@ -76,7 +76,6 @@
                                        bind(&ChatDialog::processRemoveWrapper, this, _1));
       Sync::CcnxWrapperPtr handle = Sync::CcnxWrapper::Create();
       handle->setInterestFilter(m_user.getPrefix().toStdString(), bind(&ChatDialog::respondHistoryRequest, this, _1));
-      QTimer::singleShot(100, this, SLOT(getLocalPrefix()));
 
       QTimer::singleShot(600, this, SLOT(sendJoin()));
       m_timer->start(FRESHNESS * 1000);
@@ -547,60 +546,42 @@
   return randStr.c_str();
 }
 
-void
+QString
 ChatDialog::getLocalPrefix()
 {
-//   /* 
-//    * this method tries to use ccncat 
-//    * however, it does not work in Mac OS X app bundle
-//    * it works well in command line though
-//    */
-
-//   std::string cmd = CCN_EXEC;
-//   cmd += " -c -v ";
-//   cmd += LOCAL_PREFIX_QUERY;
-//   QString localPrefix;
-// #define MAX_PREFIX_LEN 100
-//   FILE *fp = popen(cmd.c_str(), "r");
-//   if (fp != NULL)
-//   {
-//     char prefix[MAX_PREFIX_LEN];
-//     if (fgets(prefix, MAX_PREFIX_LEN, fp) != NULL)
-//     {
-//       localPrefix = prefix;
-//       localPrefix.remove('\n');
-//     }
-//     else
-//     {
-//       localPrefix = DEFAULT_LOCAL_PREFIX;
-//     }
-//     pclose(fp);
-//   }
-//   else
-//   {
-//     localPrefix = DEFAULT_LOCAL_PREFIX;
-//   }
-//   return localPrefix;
   std::cerr << "trying to get local prefix" << std::endl;
   
-  if (m_sock != NULL)
-    {
-      std::cerr << "trying to get local prefix2" << std::endl;
-      QString originPrefix = QString::fromStdString (m_sock->getLocalPrefix()).trimmed ();
-      std::cerr << "got: " << originPrefix.toStdString () << std::endl;
+  try
+  {
+    Sync::CcnxWrapperPtr handle = Sync::CcnxWrapper::Create();
+    QString originPrefix = QString::fromStdString (handle->getLocalPrefix()).trimmed ();
+    std::cerr << "got: " << originPrefix.toStdString () << std::endl;
 
-      if (originPrefix != "" && m_user.getOriginPrefix () != originPrefix)
-        {
-          // m_user.setOriginPrefix(originPrefix);
-          emit settingUpdated(m_user.getNick (), m_user.getChatroom (), originPrefix);
-          // connect(&dialog, SIGNAL(updated(QString, QString, QString)), this, SLOT());
-        }
-    }
-  else
+    if (originPrefix != "" && m_user.getOriginPrefix () != originPrefix)
+      {
+        // emit settingUpdated(m_user.getNick (), m_user.getChatroom (), originPrefix);
+        return originPrefix;
+      }
+    else
     {
-      std::cerr << "socket is not availble" << std::endl;
-      // QTimer::singleShot(1000, this, SLOT(getLocalPrefix())); // try again
+      return DEFAULT_LOCAL_PREFIX;
     }
+  }
+  catch (Sync::CcnxOperationException ex)
+  {
+    QMessageBox::critical(this, tr("Chronos"), tr("Canno connect to ccnd.\n Have you started your ccnd?"), QMessageBox::Ok);
+    std::exit(1);
+  }
+}
+
+void 
+ChatDialog::updateLocalPrefix()
+{
+  QString localPrefix = getLocalPrefix();
+  if (localPrefix != m_user.getOriginPrefix())
+  {
+    emit settingUpdated(m_user.getNick(), m_user.getChatroom(), localPrefix);
+  }
 }
 
 bool
@@ -609,13 +590,9 @@
   QSettings s(ORGANIZATION, APPLICATION);
   QString nick = s.value("nick", "").toString();
   QString chatroom = s.value("chatroom", "").toString();
-  // QString originPrefix = s.value("originPrefix", "").toString();
 
-  // Sync::CcnxWrapperPtr wrapper = Sync::CcnxWrapper::Create ();
-  // QString originPrefix = QString::fromStdString (wrapper->getLocalPrefix());
-  // Sync::CcnxWrapper::Destroy ();
   
-  QString originPrefix = DEFAULT_LOCAL_PREFIX;
+  QString originPrefix = getLocalPrefix();
   
   m_minimaniho = s.value("minimaniho", false).toBool();
   if (nick == "" || chatroom == "" || originPrefix == "") {
@@ -695,6 +672,9 @@
     std::cerr << "Errrrr.. msg was not probally initialized "<<__FILE__ <<":"<<__LINE__<<". what is happening?" << std::endl;
     abort();
   }
+#ifdef __DEBUG
+  std::cout << "Sending message for " << msg.from() << " prefix = " << m_user.getPrefix().toStdString() << std::endl;
+#endif
   m_sock->publishRaw(m_user.getPrefix().toStdString(), m_session, buf, size, FRESHNESS);
 
   delete buf;
@@ -715,6 +695,9 @@
 void 
 ChatDialog::sendJoin()
 {
+#ifdef __DEBUG
+  std::cout << "Sending join for " << m_user.getPrefix().toStdString() << std::endl;
+#endif
   SyncDemo::ChatMessage msg;
   formControlMessage(msg, SyncDemo::ChatMessage::JOIN);
   sendMsg(msg);
diff --git a/chatdialog.h b/chatdialog.h
index f0c58c2..8e09749 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -47,6 +47,7 @@
   void processRemove(QString);
 
 private:
+  QString getLocalPrefix();
   void fetchHistory(std::string name);
   QString getRandomString();
   void formChatMessage(const QString &text, SyncDemo::ChatMessage &msg);
@@ -77,8 +78,7 @@
   void replot();
   void updateRosterList(QStringList);
   void enableTreeDisplay();
-  void getLocalPrefix();
-
+  void updateLocalPrefix();
   // icon related
   void iconActivated(QSystemTrayIcon::ActivationReason reason);
   void showMessage(QString, QString);
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 64f6949..403610e 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -33,6 +33,9 @@
       p->setPrefix(v[i].prefix.c_str());
       p->setSeq(v[i].high);
       m_roster.insert(p->getPrefix(), p);
+#ifdef __DEBUG
+      std::cout << "<<<<<<< Adding user. Prefix = " << p->getPrefix().toStdString() << std::endl;
+#endif
     }
     else 
     {
@@ -91,6 +94,9 @@
 void
 DigestTreeScene::msgReceived(QString prefix, QString nick)
 {
+#ifdef __DEBUG
+  std::cout << "<<<<<<< MsgReceived. Prefix = " << prefix.toStdString() << ". Nick = " << nick.toStdString() << std::endl;
+#endif
   Roster_iterator it = m_roster.find(prefix);
   if (it != m_roster.end()) 
   {