Fixing some bugs causing segment faults, and update ChronoSync. Now it should work, but we need to run more tests to see if there are some other bugs.

Change-Id: Ib06603cb7262a7f38abe42be94da685f18eab65d
diff --git a/src/chatdialog.h b/src/chatdialog.h
index 0c06783..be2c89b 100644
--- a/src/chatdialog.h
+++ b/src/chatdialog.h
@@ -33,6 +33,10 @@
 #include <sync-seq-no.h>
 #include "chatbuf.pb.h"
 #include "digesttreescene.h"
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
 #endif
 
 typedef ndn::func_lib::function<void()> OnEventualTimeout;
@@ -49,6 +53,7 @@
 
 public:
   explicit ChatDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
+                      ndn::ptr_lib::shared_ptr<ndn::IdentityManager> identityManager,
                       const ndn::Name& chatroomPrefix,
                       const ndn::Name& localPrefix,
                       const ndn::Name& defaultIdentity,
@@ -110,6 +115,15 @@
 
 private:
 
+  void 
+  startFace();
+
+  void
+  shutdownFace();
+
+  void
+  eventLoop();
+
   void
   connectToDaemon();
 
@@ -334,6 +348,10 @@
   ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
   ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
 
+  boost::recursive_mutex m_mutex;
+  boost::thread m_thread;
+  bool m_running;
+
   ndn::Name m_newLocalPrefix;
   bool m_newLocalPrefixReady;