controller: use a single keychain

Fixes crash due to inconsistent keychains between contact-manager,
controller and the face.

Change-Id: I8adcd0767e36d7447468899eabd0debcf4185380
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 04700f5..db59560 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -44,9 +44,11 @@
 
 
 ContactManager::ContactManager(Face& face,
+                               ndn::KeyChain& keyChain,
                                QObject* parent)
   : QObject(parent)
   , m_face(face)
+  , m_keyChain(keyChain)
 {
   initializeSecurity();
 }
diff --git a/src/contact-manager.hpp b/src/contact-manager.hpp
index 456a19d..d622a6f 100644
--- a/src/contact-manager.hpp
+++ b/src/contact-manager.hpp
@@ -38,7 +38,7 @@
   Q_OBJECT
 
 public:
-  ContactManager(ndn::Face& m_face, QObject* parent = 0);
+  ContactManager(ndn::Face& face, ndn::KeyChain& keyChain, QObject* parent = 0);
 
   ~ContactManager();
 
@@ -275,7 +275,7 @@
   shared_ptr<ContactStorage> m_contactStorage;
   shared_ptr<ndn::security::ValidatorConfig> m_validator;
   ndn::Face& m_face;
-  ndn::KeyChain m_keyChain;
+  ndn::KeyChain& m_keyChain;
   Name m_identity;
   ContactList m_contactList;
 
diff --git a/src/controller-backend.cpp b/src/controller-backend.cpp
index f28ec8c..fb97f25 100644
--- a/src/controller-backend.cpp
+++ b/src/controller-backend.cpp
@@ -36,7 +36,8 @@
 ControllerBackend::ControllerBackend(QObject* parent)
   : QThread(parent)
   , m_shouldResume(false)
-  , m_contactManager(m_face)
+  , m_face(nullptr, m_keyChain)
+  , m_contactManager(m_face, m_keyChain)
 {
   // connection to contact manager
   connect(this, SIGNAL(identityUpdated(const QString&)),
diff --git a/src/controller-backend.hpp b/src/controller-backend.hpp
index 2e3aa9f..adf60a8 100644
--- a/src/controller-backend.hpp
+++ b/src/controller-backend.hpp
@@ -149,17 +149,17 @@
 private:
   bool m_isNfdConnected;
   bool m_shouldResume;
-  ndn::Face m_face;
 
   Name m_identity;  //TODO: set/get
 
   Name m_localPrefix;
 
+  ndn::KeyChain m_keyChain;
+  ndn::Face m_face;
+
   // Contact Manager
   ContactManager m_contactManager;
 
-  // Security related;
-  ndn::KeyChain m_keyChain;
   shared_ptr<ndn::security::Validator> m_validator;
   ndn::security::ValidatorNull m_nullValidator;