separate controller backend frontend

Change-Id: Ic4ba9c8154a600c978e75ea82ff36569270dd656
diff --git a/src/chat-dialog-backend.cpp b/src/chat-dialog-backend.cpp
index 87eed37..680d24b 100644
--- a/src/chat-dialog-backend.cpp
+++ b/src/chat-dialog-backend.cpp
@@ -61,8 +61,6 @@
 void
 ChatDialogBackend::initializeSync()
 {
-  QMutexLocker locker(&mutex);
-
   // if a SyncSocket is running, turn it off
   if (static_cast<bool>(m_sock)) {
     if (m_joined)
@@ -375,6 +373,14 @@
 void
 ChatDialogBackend::shutdown()
 {
+  if (static_cast<bool>(m_sock)) {
+    if (m_joined)
+      sendLeave();
+    m_sock.reset();
+
+    usleep(100000);
+  }
+
   m_face.getIoService().stop();
 }