autoconfig prefix
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 2c33137..d7da61c 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -8,8 +8,12 @@
 #include <QMessageBox>
 #include <boost/random/random_device.hpp>
 #include <boost/random/uniform_int_distribution.hpp>
+#include <stdio.h>
 
 #define BROADCAST_PREFIX_FOR_SYNC_DEMO "/ndn/broadcast/chronos"
+#define LOCAL_PREFIX_QUERY "/local/ndn/prefix" 
+#define DEFAULT_LOCAL_PREFIX "/private/local"
+#define CCN_EXEC  "ccncat"
 
 static const int HELLO_INTERVAL = 90;  // seconds
 
@@ -479,13 +483,44 @@
   return randStr.c_str();
 }
 
+QString
+ChatDialog::getLocalPrefix()
+{
+  std::string cmd = CCN_EXEC;
+  cmd += " ";
+  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;
+}
+
 bool
 ChatDialog::readSettings()
 {
   QSettings s(ORGANIZATION, APPLICATION);
   QString nick = s.value("nick", "").toString();
   QString chatroom = s.value("chatroom", "").toString();
-  QString originPrefix = s.value("originPrefix", "").toString();
+  //QString originPrefix = s.value("originPrefix", "").toString();
+  QString originPrefix = getLocalPrefix();
   m_minimaniho = s.value("minimaniho", false).toBool();
   if (nick == "" || chatroom == "" || originPrefix == "") {
     QTimer::singleShot(500, this, SLOT(buttonPressed()));
@@ -509,7 +544,7 @@
   QSettings s(ORGANIZATION, APPLICATION);
   s.setValue("nick", m_user.getNick());
   s.setValue("chatroom", m_user.getChatroom());
-  s.setValue("originPrefix", m_user.getOriginPrefix());
+  //s.setValue("originPrefix", m_user.getOriginPrefix());
   s.setValue("minimaniho", m_minimaniho);
 }
 
@@ -519,8 +554,18 @@
   QString settingDisp = QString("Chatroom: %1").arg(m_user.getChatroom());
   infoLabel->setStyleSheet("QLabel {color: #630; font-size: 16px; font: bold \"Verdana\";}");
   infoLabel->setText(settingDisp);
-  //QString prefixDisp = QString("<Prefix: %1>").arg(m_user.getPrefix());
-  //prefixLabel->setText(prefixDisp);
+  QString prefixDisp; 
+  if (m_user.getPrefix().startsWith(DEFAULT_LOCAL_PREFIX))
+  {
+    prefixDisp = QString("<Warning: Auto config prefix failed.>\n <Prefix = %1>").arg(m_user.getPrefix());
+    prefixLabel->setStyleSheet("QLabel {color: red; font-size: 12px; font: bold \"Verdana\";}");
+  }
+  else
+  {
+    prefixDisp = QString("<Prefix = %1>").arg(m_user.getPrefix());
+    prefixLabel->setStyleSheet("QLabel {color: Green; font-size: 12px; font: bold \"Verdana\";}");
+  }
+  prefixLabel->setText(prefixDisp);
 }
 
 void 
diff --git a/chatdialog.h b/chatdialog.h
index 7c366e5..840afb2 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -59,6 +59,7 @@
   QString formatTime(time_t);
   void printTimeInCell(QTextTable *, time_t);
   void disableTreeDisplay();
+  QString getLocalPrefix();
 
 private slots:
   void returnPressed();
diff --git a/chatdialog.ui b/chatdialog.ui
index 4fb3c6f..dc5e943 100644
--- a/chatdialog.ui
+++ b/chatdialog.ui
@@ -27,11 +27,28 @@
             <number>6</number>
           </property>
           <item>
-            <widget class="QLabel" name="infoLabel">
-            <property name="focusPolicy">
-              <enum>Qt::NoFocus</enum>
-            </property>
-            </widget>
+            <layout class = "QVBoxLayout" >
+              <property name="margin">
+                <number>0</number>
+              </property>
+              <property name="spacing">
+                <number>6</number>
+              </property>
+              <item>
+                <widget class="QLabel" name="infoLabel">
+                <property name="focusPolicy">
+                  <enum>Qt::NoFocus</enum>
+                </property>
+                </widget>
+              </item>
+              <item>
+                <widget class="QLabel" name="prefixLabel">
+                <property name="focusPolicy">
+                  <enum>Qt::NoFocus</enum>
+                </property>
+                </widget>
+              </item>
+            </layout>
           </item>
           <item>
             <layout class = "QVBoxLayout" >
@@ -41,15 +58,6 @@
               <property name="spacing">
                 <number>6</number>
               </property>
-              <!--
-              <item>
-                <widget class="QLabel" name="prefixLabel">
-                <property name="focusPolicy">
-                  <enum>Qt::NoFocus</enum>
-                </property>
-                </widget>
-              </item>
-              -->
               <item>
                 <widget class="QPushButton" name="setButton">
                 <property name="focusPolicy">