dispatcher

Change-Id: I5ff25afcba3f03249ae32cf9c656f69ecc38d424
diff --git a/src/action-log.cpp b/src/action-log.cpp
index 7dbc663..7c5bacd 100644
--- a/src/action-log.cpp
+++ b/src/action-log.cpp
@@ -90,7 +90,7 @@
 // }
 
 ActionLog::ActionLog(Face& face, const boost::filesystem::path& path, SyncLogPtr syncLog,
-                     const std::string& sharedFolder, const std::string& appName,
+                     const std::string& sharedFolder, const name::Component& appName,
                      OnFileAddedOrChangedCallback onFileAddedOrChanged,
                      OnFileRemovedCallback onFileRemoved)
   : DbHelper(path / ".chronoshare", "action-log.db")
@@ -631,15 +631,12 @@
     return ActionItemPtr();
   }
 
-  std::string action = name.get(-3).toUri();
-
-  if (action != "action") {
+  if (name.get(-3).toUri() != "action") {
     _LOG_ERROR("not an action");
     return ActionItemPtr();
   }
 
-  std::string appName = name.get(-4).toUri();
-  if (appName != m_appName) {
+  if (name.get(-4) != m_appName) {
     _LOG_ERROR("Action doesn't belong to this application");
     return ActionItemPtr();
   }
diff --git a/src/action-log.hpp b/src/action-log.hpp
index 99bcb0e..263ec83 100644
--- a/src/action-log.hpp
+++ b/src/action-log.hpp
@@ -60,7 +60,7 @@
 
 public:
   ActionLog(Face& face, const boost::filesystem::path& path, SyncLogPtr syncLog,
-            const std::string& sharedFolder, const std::string& appName,
+            const std::string& sharedFolder, const name::Component& appName,
             OnFileAddedOrChangedCallback onFileAddedOrChanged, OnFileRemovedCallback onFileRemoved);
 
   virtual ~ActionLog()
@@ -154,7 +154,7 @@
 
   // Face& m_face;
   std::string m_sharedFolderName;
-  std::string m_appName;
+  name::Component m_appName;
 
   OnFileAddedOrChangedCallback m_onFileAddedOrChanged;
   OnFileRemovedCallback m_onFileRemoved;
diff --git a/src/content-server.cpp b/src/content-server.cpp
index 888baea..382a029 100644
--- a/src/content-server.cpp
+++ b/src/content-server.cpp
@@ -35,8 +35,8 @@
 
 ContentServer::ContentServer(Face& face, ActionLogPtr actionLog,
                              const boost::filesystem::path& rootDir, const Name& userName,
-                             const std::string& sharedFolderName, const std::string& appName,
-                             KeyChain& keyChain, int freshness)
+                             const std::string& sharedFolderName, const name::Component& appName,
+                             KeyChain& keyChain, time::milliseconds freshness)
   : m_face(face)
   , m_actionLog(actionLog)
   , m_dbFolder(rootDir / ".chronoshare")
@@ -98,7 +98,7 @@
   // name for files:   /<device_name>/<appname>/file/<hash>/<segment>
   // name for actions: /<device_name>/<appname>/action/<shared-folder>/<action-seq>
 
-  if (name.size() >= 4 && name.get(-4).toUri() == m_appName) {
+  if (name.size() >= 4 && name.get(-4) == m_appName) {
     std::string type = name.get(-3).toUri();
     if (type == "file") {
       serve_File(forwardingHint, name, interest);
@@ -199,7 +199,7 @@
         shared_ptr<Data> outerData = make_shared<Data>();
 
         outerData->setContent(data->wireEncode());
-        outerData->setFreshnessPeriod(time::seconds(m_freshness));
+        outerData->setFreshnessPeriod(m_freshness);
         outerData->setName(interest);
 
         m_keyChain.sign(*outerData, signingWithSha256());;
@@ -235,9 +235,7 @@
     }
     else {
       data->setName(interest);
-      if (m_freshness > 0) {
-        data->setFreshnessPeriod(time::seconds(m_freshness));
-      }
+      data->setFreshnessPeriod(m_freshness);
       m_keyChain.sign(*data);
       m_face.put(*data);
     }
diff --git a/src/content-server.hpp b/src/content-server.hpp
index ccba737..809b2e9 100644
--- a/src/content-server.hpp
+++ b/src/content-server.hpp
@@ -45,7 +45,8 @@
 public:
   ContentServer(Face& face, ActionLogPtr actionLog, const boost::filesystem::path& rootDir,
                 const Name& userName, const std::string& sharedFolderName,
-                const std::string& appName, KeyChain& keyChain, int freshness = -1);
+                const name::Component& appName, KeyChain& keyChain,
+                time::milliseconds freshness = time::seconds(5));
   ~ContentServer();
 
   // the assumption is, when the interest comes in, interest is informs of
@@ -90,7 +91,7 @@
 
   Mutex m_mutex;
   boost::filesystem::path m_dbFolder;
-  int m_freshness;
+  time::milliseconds m_freshness;
 
   Scheduler m_scheduler;
   util::scheduler::ScopedEventId m_flushStateDbCacheEvent;
@@ -100,7 +101,7 @@
 
   Name m_userName;
   std::string m_sharedFolderName;
-  std::string m_appName;
+  name::Component m_appName;
   KeyChain& m_keyChain;
 };
 
diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp
index 3bc3bff..a554454 100644
--- a/src/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -19,69 +19,63 @@
  */
 
 #include "dispatcher.hpp"
-#include "ccnx-discovery.hpp"
 #include "fetch-task-db.hpp"
-#include "logging.hpp"
+#include "core/logging.hpp"
+
+#include <ndn-cxx/util/digest.hpp>
+#include <ndn-cxx/util/string-helper.hpp>
 
 #include <boost/lexical_cast.hpp>
-#include <boost/make_shared.hpp>
 
-using namespace Ndnx;
-using namespace std;
-using namespace boost;
+namespace ndn {
+namespace chronoshare {
 
 _LOG_INIT(Dispatcher);
 
-static const string CHRONOSHARE_APP = "chronoshare";
-static const string BROADCAST_DOMAIN = "/ndn/broadcast";
+namespace fs = boost::filesystem;
 
-static const int CONTENT_FRESHNESS = 1800;                 // seconds
-const static double DEFAULT_SYNC_INTEREST_INTERVAL = 10.0; // seconds;
+static const name::Component CHRONOSHARE_APP = name::Component("chronoshare");
+static const Name BROADCAST_DOMAIN = "/ndn/multicast";
+
+static const time::seconds DEFAULT_SYNC_INTEREST_INTERVAL = time::seconds(10);
 
 Dispatcher::Dispatcher(const std::string& localUserName, const std::string& sharedFolder,
-                       const filesystem::path& rootDir, Ccnx::CcnxWrapperPtr ccnx,
-                       bool enablePrefixDiscovery)
-  : m_ccnx(ccnx)
-  , m_core(NULL)
+                       const fs::path& rootDir, Face& face, bool enablePrefixDiscovery)
+  : m_face(face)
   , m_rootDir(rootDir)
-  , m_executor(1)
-    // creates problems with file assembly. need to ensure somehow that
-    // FinishExectute is called after all Segment_Execute finished
-  , m_objectManager(ccnx, rootDir, CHRONOSHARE_APP)
+  , m_ioService(face.getIoService())
+  , m_objectManager(face, m_keyChain, rootDir, CHRONOSHARE_APP.toUri())
   , m_localUserName(localUserName)
   , m_sharedFolder(sharedFolder)
-  , m_server(NULL)
   , m_enablePrefixDiscovery(enablePrefixDiscovery)
 {
-  KeyChain keyChain;
   m_syncLog = make_shared<SyncLog>(m_rootDir, localUserName);
   m_actionLog =
-    make_shared<ActionLog>(m_ccnx, m_rootDir, m_syncLog, sharedFolder, CHRONOSHARE_APP,
-                           // bind (&Dispatcher::Did_ActionLog_ActionApply_AddOrModify, this, _1, _2, _3, _4, _5, _6, _7),
+    make_shared<ActionLog>(m_face, m_rootDir, m_syncLog, sharedFolder, CHRONOSHARE_APP,
+                           // bind(&Dispatcher::Did_ActionLog_ActionApply_AddOrModify, this, _1, _2, _3, _4, _5, _6, _7),
                            ActionLog::OnFileAddedOrChangedCallback(), // don't really need this callback
                            bind(&Dispatcher::Did_ActionLog_ActionApply_Delete, this, _1));
   m_fileState = m_actionLog->GetFileState();
 
-  Name syncPrefix = Name(BROADCAST_DOMAIN)(CHRONOSHARE_APP)(sharedFolder);
+  Name syncPrefix = Name(BROADCAST_DOMAIN);
+  syncPrefix.append(CHRONOSHARE_APP);
+  syncPrefix.append(sharedFolder);
 
-  // m_server needs a different ccnx face
-  m_server = new ContentServer(make_shared<CcnxWrapper>(), m_actionLog, rootDir, m_localUserName,
-                               m_sharedFolder, CHRONOSHARE_APP, keyChain, CONTENT_FRESHNESS);
+  m_server = make_unique<ContentServer>(m_face, m_actionLog, rootDir, m_localUserName,
+                                        m_sharedFolder, CHRONOSHARE_APP, m_keyChain);
   m_server->registerPrefix(Name("/"));
   m_server->registerPrefix(Name(BROADCAST_DOMAIN));
 
-  m_stateServer =
-    new StateServer(make_shared<CcnxWrapper>(), m_actionLog, rootDir, m_localUserName,
-                    m_sharedFolder, CHRONOSHARE_APP, m_objectManager, CONTENT_FRESHNESS);
-  // no need to register, right now only listening on localhost prefix
+  //m_stateServer = make_unique<StateServer>(m_face, m_actionLog, rootDir, m_localUserName, m_sharedFolder,
+  //                                         CHRONOSHARE_APP, m_objectManager, m_keyChair);
 
-  m_core = new SyncCore(m_syncLog, localUserName, Name("/"), syncPrefix,
-                        bind(&Dispatcher::Did_SyncLog_StateChange, this, _1), ccnx,
-                        DEFAULT_SYNC_INTEREST_INTERVAL);
+  m_core = make_unique<SyncCore>(m_face, m_syncLog, localUserName, Name("/"), syncPrefix,
+                                 bind(&Dispatcher::Did_SyncLog_StateChange, this, _1),
+                                 DEFAULT_SYNC_INTEREST_INTERVAL);
 
   FetchTaskDbPtr actionTaskDb = make_shared<FetchTaskDb>(m_rootDir, "action");
   m_actionFetcher =
-    make_shared<FetchManager>(m_ccnx, bind(&SyncLog::LookupLocator, &*m_syncLog, _1),
+    make_shared<FetchManager>(m_face, bind(&SyncLog::LookupLocator, &*m_syncLog, _1),
                               Name(BROADCAST_DOMAIN), // no appname suffix now
                               3,
                               bind(&Dispatcher::Did_FetchManager_ActionFetch, this, _1, _2, _3, _4),
@@ -89,60 +83,47 @@
 
   FetchTaskDbPtr fileTaskDb = make_shared<FetchTaskDb>(m_rootDir, "file");
   m_fileFetcher =
-    make_shared<FetchManager>(m_ccnx, bind(&SyncLog::LookupLocator, &*m_syncLog, _1),
+    make_shared<FetchManager>(m_face, bind(&SyncLog::LookupLocator, &*m_syncLog, _1),
                               Name(BROADCAST_DOMAIN), // no appname suffix now
                               3, bind(&Dispatcher::Did_FetchManager_FileSegmentFetch, this, _1, _2,
                                       _3, _4),
                               bind(&Dispatcher::Did_FetchManager_FileFetchComplete, this, _1, _2),
                               fileTaskDb);
 
-
   if (m_enablePrefixDiscovery) {
     _LOG_DEBUG("registering prefix discovery in Dispatcher");
-    string tag = "dispatcher" + m_localUserName.toString();
-    Ccnx::CcnxDiscovery::registerCallback(
-      TaggedFunction(bind(&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
+    std::string tag = "dispatcher" + m_localUserName.toUri();
+    // Ccnx::CcnxDiscovery::registerCallback(TaggedFunction(bind(&Dispatcher::Did_LocalPrefix_Updated,
+    // this, _1), tag));
+    // TODO registerCallback...?
+    //
+    // this registerCallback is used when the local prefix changes.
+    // the ndn-cxx library does not have this functionality
+    // thus, the application will need to implement this.
+    // send a data packet and get the local prefix. If they are different, call the callback
+    // function, else do nothing.
   }
-
-  m_executor.start();
 }
 
 Dispatcher::~Dispatcher()
 {
   _LOG_DEBUG("Enter destructor of dispatcher");
-  m_executor.shutdown();
-
-  // _LOG_DEBUG (">>");
 
   if (m_enablePrefixDiscovery) {
     _LOG_DEBUG("deregistering prefix discovery in Dispatcher");
-    string tag = "dispatcher" + m_localUserName.toString();
-    Ccnx::CcnxDiscovery::deregisterCallback(
-      TaggedFunction(bind(&Dispatcher::Did_LocalPrefix_Updated, this, _1), tag));
-  }
-
-  if (m_core != NULL) {
-    delete m_core;
-    m_core = NULL;
-  }
-
-  if (m_server != NULL) {
-    delete m_server;
-    m_server = NULL;
-  }
-
-  if (m_stateServer != NULL) {
-    delete m_stateServer;
-    m_stateServer = NULL;
+    std::string tag = "dispatcher" + m_localUserName.toUri();
+    // TODO
+    //    Ccnx::CcnxDiscovery::deregisterCallback(TaggedFunction(bind(&Dispatcher::Did_LocalPrefix_Updated,
+    //    this, _1), tag));
   }
 }
 
 void
-Dispatcher::Did_LocalPrefix_Updated(const Ccnx::Name& forwardingHint)
+Dispatcher::Did_LocalPrefix_Updated(const Name& forwardingHint)
 {
   Name effectiveForwardingHint;
   if (m_localUserName.size() >= forwardingHint.size() &&
-      m_localUserName.getPartialName(0, forwardingHint.size()) == forwardingHint) {
+      m_localUserName.getSubName(0, forwardingHint.size()) == forwardingHint) {
     effectiveForwardingHint = Name("/"); // "directly" accesible
   }
   else {
@@ -177,45 +158,45 @@
   m_server->deregisterPrefix(oldLocalPrefix);
 }
 
-// moved to state-server
-// void
-// Dispatcher::Restore_LocalFile (FileItemPtr file)
-// {
-//   m_executor.execute (bind (&Dispatcher::Restore_LocalFile_Execute, this, file));
-// }
-
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void
-Dispatcher::Did_LocalFile_AddOrModify(const filesystem::path& relativeFilePath)
+Dispatcher::Did_LocalFile_AddOrModify(const fs::path& relativeFilePath)
 {
-  m_executor.execute(bind(&Dispatcher::Did_LocalFile_AddOrModify_Execute, this, relativeFilePath));
+  m_ioService.post(bind(&Dispatcher::Did_LocalFile_AddOrModify_Execute, this, relativeFilePath));
 }
 
 void
-Dispatcher::Did_LocalFile_AddOrModify_Execute(filesystem::path relativeFilePath)
+Dispatcher::Did_LocalFile_AddOrModify_Execute(fs::path relativeFilePath)
 {
   _LOG_DEBUG(m_localUserName << " calls LocalFile_AddOrModify_Execute");
-  filesystem::path absolutePath = m_rootDir / relativeFilePath;
-  if (!filesystem::exists(absolutePath)) {
-    //BOOST_THROW_EXCEPTION (Error::Dispatcher() << error_info_str("Update non exist file: " + absolutePath.string() ));
+  fs::path absolutePath = m_rootDir / relativeFilePath;
+  _LOG_DEBUG("relativeFilePath : " << relativeFilePath);
+  _LOG_DEBUG("absolutePath : " << absolutePath);
+  if (!fs::exists(absolutePath)) {
+    // BOOST_THROW_EXCEPTION(Error::Dispatcher() << error_info_str("Update non exist file: " +
+    // absolutePath.string() ));
     _LOG_DEBUG("Update non exist file: " << absolutePath.string());
     return;
   }
 
   FileItemPtr currentFile = m_fileState->LookupFile(relativeFilePath.generic_string());
-  if (currentFile &&
-      *Hash::FromFileContent(absolutePath) ==
-        Hash(currentFile->file_hash().c_str(), currentFile->file_hash().size())
-      // The following two are commented out to prevent front end from reporting intermediate files
-      // should enable it if there is other way to prevent this
-      // && last_write_time (absolutePath) == currentFile->mtime ()
-      // && status (absolutePath).permissions () == static_cast<filesystem::perms> (currentFile->mode ())
-      ) {
-    _LOG_ERROR("Got notification about the same file [" << relativeFilePath << "]");
-    return;
+
+  if (currentFile) {
+    fs::ifstream input(absolutePath);
+    if (*util::Sha256(input).computeDigest() ==
+        Buffer(currentFile->file_hash().c_str(), currentFile->file_hash().size())
+        // The following two are commented out to prevent front end from reporting intermediate files
+        // should enable it if there is other way to prevent this
+        // && last_write_time(absolutePath) == currentFile->mtime()
+        // && status(absolutePath).permissions() ==
+        // static_cast<fs::perms>(currentFile->mode())
+        ) {
+      _LOG_ERROR("Got notification about the same file [" << relativeFilePath << "]");
+      return;
+    }
   }
 
   if (currentFile && !currentFile->is_complete()) {
@@ -223,14 +204,13 @@
     return;
   }
 
-
   int seg_num;
-  HashPtr hash;
+  ConstBufferPtr hash;
+  _LOG_DEBUG("absolutePath: " << absolutePath << " m_localUserName: " << m_localUserName);
   tie(hash, seg_num) = m_objectManager.localFileToObjects(absolutePath, m_localUserName);
 
   try {
-    m_actionLog->AddLocalActionUpdate(relativeFilePath.generic_string(),
-                                      *hash,
+    m_actionLog->AddLocalActionUpdate(relativeFilePath.generic_string(), *hash,
                                       last_write_time(absolutePath),
 #if BOOST_VERSION >= 104900
                                       status(absolutePath).permissions(),
@@ -242,22 +222,24 @@
     // notify SyncCore to propagate the change
     m_core->localStateChangedDelayed();
   }
-  catch (filesystem::filesystem_error& error) {
-    _LOG_ERROR("File operations failed on [" << relativeFilePath << "] (ignoring)");
+  catch (fs::filesystem_error& error) {
+    _LOG_ERROR("File operations failed on [" << relativeFilePath << "](ignoring)");
   }
+
+  _LOG_DEBUG("LocalFile_AddOrModify_Execute Finished!");
 }
 
 void
-Dispatcher::Did_LocalFile_Delete(const filesystem::path& relativeFilePath)
+Dispatcher::Did_LocalFile_Delete(const fs::path& relativeFilePath)
 {
-  m_executor.execute(bind(&Dispatcher::Did_LocalFile_Delete_Execute, this, relativeFilePath));
+  m_ioService.post(bind(&Dispatcher::Did_LocalFile_Delete_Execute, this, relativeFilePath));
 }
 
 void
-Dispatcher::Did_LocalFile_Delete_Execute(filesystem::path relativeFilePath)
+Dispatcher::Did_LocalFile_Delete_Execute(fs::path relativeFilePath)
 {
-  filesystem::path absolutePath = m_rootDir / relativeFilePath;
-  if (filesystem::exists(absolutePath)) {
+  fs::path absolutePath = m_rootDir / relativeFilePath;
+  if (fs::exists(absolutePath)) {
     _LOG_ERROR("DELETE command, but file still exists: " << absolutePath.string());
     return;
   }
@@ -271,27 +253,10 @@
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 
-/**
- * Callbacks:
- *
- * - from SyncLog: when state changes -> to fetch missing actions
- *
- * - from FetchManager/Actions: when action is fetched -> to request a file, specified by the action
- *                                                     -> to add action to the action log
- *
- * - from ActionLog/Delete:      when action applied (file state changed, file deleted)           -> to delete local file
- *
- * - from ActionLog/AddOrUpdate: when action applied (file state changes, file added or modified) -> do nothing?
- *
- * - from FetchManager/Files: when file segment is retrieved -> save it in ObjectDb
- *                            when file fetch is completed   -> if file belongs to FileState, then assemble it to filesystem.
- *                                                              Don't do anything otherwise
- */
-
 void
 Dispatcher::Did_SyncLog_StateChange(SyncStateMsgPtr stateMsg)
 {
-  m_executor.execute(bind(&Dispatcher::Did_SyncLog_StateChange_Execute, this, stateMsg));
+  m_ioService.post(bind(&Dispatcher::Did_SyncLog_StateChange_Execute, this, stateMsg));
 }
 
 void
@@ -305,84 +270,77 @@
     if (state.has_old_seq() && state.has_seq()) {
       uint64_t oldSeq = state.old_seq();
       uint64_t newSeq = state.seq();
-      Name userName(reinterpret_cast<const unsigned char*>(state.name().c_str()),
-                    state.name().size());
+      Name userName(Block((const unsigned char*)state.name().c_str(), state.name().size()));
 
-      // fetch actions with oldSeq + 1 to newSeq (inclusive)
-      Name actionNameBase = Name("/")(userName)(CHRONOSHARE_APP)("action")(m_sharedFolder);
-
+      // fetch actions with oldSeq + 1 to newSeq(inclusive)
+      Name actionNameBase = Name("/");
+      actionNameBase.append(userName).append(CHRONOSHARE_APP).append("action").append(m_sharedFolder);
       m_actionFetcher->Enqueue(userName, actionNameBase, std::max<uint64_t>(oldSeq + 1, 1), newSeq,
                                FetchManager::PRIORITY_HIGH);
     }
   }
 }
 
-
 void
-Dispatcher::Did_FetchManager_ActionFetch(const Ccnx::Name& deviceName,
-                                         const Ccnx::Name& actionBaseName, uint32_t seqno,
-                                         Ccnx::PcoPtr actionPco)
+Dispatcher::Did_FetchManager_ActionFetch(const Name& deviceName, const Name& actionBaseName,
+                                         uint32_t seqno, shared_ptr<Data> actionData)
 {
   /// @todo Errors and exception checking
   _LOG_DEBUG("Received action deviceName: " << deviceName << ", actionBaseName: " << actionBaseName
                                             << ", seqno: "
                                             << seqno);
 
-  ActionItemPtr action = m_actionLog->AddRemoteAction(deviceName, seqno, actionPco);
+  ActionItemPtr action = m_actionLog->AddRemoteAction(deviceName, seqno, actionData);
   if (!action) {
     _LOG_ERROR("AddRemoteAction did not insert action, ignoring");
     return;
   }
-  // trigger may invoke Did_ActionLog_ActionApply_Delete or Did_ActionLog_ActionApply_AddOrModify callbacks
+  // trigger may invoke Did_ActionLog_ActionApply_Delete or Did_ActionLog_ActionApply_AddOrModify
+  // callbacks
 
   if (action->action() == ActionItem::UPDATE) {
-    Hash hash(action->file_hash().c_str(), action->file_hash().size());
+    ConstBufferPtr hash =
+      make_shared<Buffer>(action->file_hash().c_str(), action->file_hash().size());
 
-    Name fileNameBase =
-      Name("/")(deviceName)(CHRONOSHARE_APP)("file")(hash.GetHash(), hash.GetHashBytes());
+    Name fileNameBase = Name("/");
+    fileNameBase.append(deviceName).append(CHRONOSHARE_APP).append("file");
+    //      fileNameBase.append(name::Component(hash));
+    fileNameBase.appendImplicitSha256Digest(hash);
 
-    string hashStr = lexical_cast<string>(hash);
-    if (ObjectDb::DoesExist(m_rootDir / ".chronoshare", deviceName, hashStr)) {
-      _LOG_DEBUG(
-        "File already exists in the database. No need to refetch, just directly applying the action");
+    std::string hashStr = toHex(*hash);
+    if (ObjectDb::doesExist(m_rootDir / ".chronoshare", deviceName, hashStr)) {
+      _LOG_DEBUG("File already exists in the database. No need to refetch, just directly applying "
+                 "the action");
       Did_FetchManager_FileFetchComplete(deviceName, fileNameBase);
     }
     else {
-      if (m_objectDbMap.find(hash) == m_objectDbMap.end()) {
-        _LOG_DEBUG("create ObjectDb for " << hash);
-        m_objectDbMap[hash] = make_shared<ObjectDb>(m_rootDir / ".chronoshare", hashStr);
+      if (m_objectDbMap.find(*hash) == m_objectDbMap.end()) {
+        _LOG_DEBUG("create ObjectDb for " << toHex(*hash));
+        m_objectDbMap[*hash] = make_shared<ObjectDb>(m_rootDir / ".chronoshare", hashStr);
       }
 
       m_fileFetcher->Enqueue(deviceName, fileNameBase, 0, action->seg_num() - 1,
                              FetchManager::PRIORITY_NORMAL);
     }
   }
-  // if necessary (when version number is the highest) delete will be
-  // applied through the trigger in m_actionLog->AddRemoteAction call
 }
 
 void
 Dispatcher::Did_ActionLog_ActionApply_Delete(const std::string& filename)
 {
-  m_executor.execute(bind(&Dispatcher::Did_ActionLog_ActionApply_Delete_Execute, this, filename));
-}
-
-void
-Dispatcher::Did_ActionLog_ActionApply_Delete_Execute(std::string filename)
-{
   _LOG_DEBUG("Action to delete " << filename);
 
-  filesystem::path absolutePath = m_rootDir / filename;
+  fs::path absolutePath = m_rootDir / filename;
   try {
-    if (filesystem::exists(absolutePath)) {
+    if (fs::exists(absolutePath)) {
       // need some protection from local detection of removal
       remove(absolutePath);
 
       // hack to remove empty parent dirs
-      filesystem::path parentPath = absolutePath.parent_path();
+      fs::path parentPath = absolutePath.parent_path();
       while (parentPath > m_rootDir) {
-        if (filesystem::is_empty(parentPath)) {
-          filesystem::remove(parentPath);
+        if (fs::is_empty(parentPath)) {
+          fs::remove(parentPath);
           parentPath = parentPath.parent_path();
         }
         else {
@@ -392,102 +350,102 @@
     }
     // don't exist
   }
-  catch (filesystem::filesystem_error& error) {
-    _LOG_ERROR("File operations failed when removing [" << absolutePath << "] (ignoring)");
+  catch (fs::filesystem_error& error) {
+    _LOG_ERROR("File operations failed when removing [" << absolutePath << "](ignoring)");
   }
 }
 
 void
-Dispatcher::Did_FetchManager_FileSegmentFetch(const Ccnx::Name& deviceName,
-                                              const Ccnx::Name& fileSegmentBaseName,
-                                              uint32_t segment, Ccnx::PcoPtr fileSegmentPco)
+Dispatcher::Did_FetchManager_FileSegmentFetch(const Name& deviceName,
+                                              const Name& fileSegmentBaseName,
+                                              uint32_t segment,
+                                              shared_ptr<Data>
+                                                fileSegmentData)
 {
-  m_executor.execute(bind(&Dispatcher::Did_FetchManager_FileSegmentFetch_Execute, this, deviceName,
-                          fileSegmentBaseName, segment, fileSegmentPco));
+  m_ioService.post(bind(&Dispatcher::Did_FetchManager_FileSegmentFetch_Execute, this, deviceName,
+                        fileSegmentBaseName, segment, fileSegmentData));
 }
 
 void
-Dispatcher::Did_FetchManager_FileSegmentFetch_Execute(Ccnx::Name deviceName,
-                                                      Ccnx::Name fileSegmentBaseName,
-                                                      uint32_t segment, Ccnx::PcoPtr fileSegmentPco)
+Dispatcher::Did_FetchManager_FileSegmentFetch_Execute(Name deviceName,
+                                                      Name fileSegmentBaseName,
+                                                      uint32_t segment,
+                                                      shared_ptr<Data> fileSegmentData)
 {
   // fileSegmentBaseName:  /<device_name>/<appname>/file/<hash>
 
-  const Bytes& hashBytes = fileSegmentBaseName.getCompFromBack(0);
-  Hash hash(head(hashBytes), hashBytes.size());
+  Buffer hash(fileSegmentBaseName.get(-1).value(), fileSegmentBaseName.get(-1).value_size());
 
   _LOG_DEBUG("Received segment deviceName: " << deviceName << ", segmentBaseName: " << fileSegmentBaseName
                                              << ", segment: "
                                              << segment);
 
-  // _LOG_DEBUG ("Looking up objectdb for " << hash);
+  // _LOG_DEBUG("Looking up objectdb for " << hash);
 
-  map<Hash, ObjectDbPtr>::iterator db = m_objectDbMap.find(hash);
+  std::map<Buffer, shared_ptr<ObjectDb>>::iterator db = m_objectDbMap.find(hash);
   if (db != m_objectDbMap.end()) {
-    db->second->saveContentObject(deviceName, segment, fileSegmentPco->buf());
+    db->second->saveContentObject(deviceName, segment, *fileSegmentData);
   }
   else {
     _LOG_ERROR("no db available for this content object: " << fileSegmentBaseName << ", size: "
-                                                           << fileSegmentPco->buf().size());
+                                                           << fileSegmentData->getContent().size());
   }
 
-  // ObjectDb objectDb (m_rootDir / ".chronoshare", lexical_cast<string> (hash));
-  // objectDb.saveContentObject(deviceName, segment, fileSegmentPco->buf ());
+  // ObjectDb objectDb(m_rootDir / ".chronoshare", lexical_cast<string>(hash));
+  // objectDb.saveContentObject(deviceName, segment, *fileSegmentData);
 }
 
 void
-Dispatcher::Did_FetchManager_FileFetchComplete(const Ccnx::Name& deviceName,
-                                               const Ccnx::Name& fileBaseName)
+Dispatcher::Did_FetchManager_FileFetchComplete(const Name& deviceName, const Name& fileBaseName)
 {
-  m_executor.execute(
+  m_ioService.post(
     bind(&Dispatcher::Did_FetchManager_FileFetchComplete_Execute, this, deviceName, fileBaseName));
 }
 
 void
-Dispatcher::Did_FetchManager_FileFetchComplete_Execute(Ccnx::Name deviceName, Ccnx::Name fileBaseName)
+Dispatcher::Did_FetchManager_FileFetchComplete_Execute(Name deviceName, Name fileBaseName)
 {
   // fileBaseName:  /<device_name>/<appname>/file/<hash>
 
   _LOG_DEBUG("Finished fetching " << deviceName << ", fileBaseName: " << fileBaseName);
 
-  const Bytes& hashBytes = fileBaseName.getCompFromBack(0);
-  Hash hash(head(hashBytes), hashBytes.size());
-  _LOG_DEBUG("Extracted hash: " << hash.shortHash());
+  Buffer hash(fileBaseName.get(-1).value(), fileBaseName.get(-1).value_size());
+
+  _LOG_DEBUG("Extracted hash: " << toHex(hash));
 
   if (m_objectDbMap.find(hash) != m_objectDbMap.end()) {
     // remove the db handle
     m_objectDbMap.erase(hash); // to commit write
   }
   else {
-    _LOG_ERROR("no db available for this file: " << hash);
+    _LOG_ERROR("no db available for this file: " << toHex(hash));
   }
 
   FileItemsPtr filesToAssemble = m_fileState->LookupFilesForHash(hash);
 
   for (FileItems::iterator file = filesToAssemble->begin(); file != filesToAssemble->end(); file++) {
-    boost::filesystem::path filePath = m_rootDir / file->filename();
+    fs::path filePath = m_rootDir / file->filename();
 
     try {
-      if (filesystem::exists(filePath) && filesystem::last_write_time(filePath) == file->mtime() &&
-#if BOOST_VERSION >= 104900
-          filesystem::status(filePath).permissions() == static_cast<filesystem::perms>(file->mode()) &&
-#endif
-          *Hash::FromFileContent(filePath) == hash) {
-        _LOG_DEBUG("Asking to assemble a file, but file already exists on a filesystem");
-        continue;
+      if (fs::exists(filePath) && fs::last_write_time(filePath) == file->mtime() &&
+          fs::status(filePath).permissions() == static_cast<fs::perms>(file->mode())) {
+          fs::ifstream input(filePath, std::ios::in | std::ios::binary);
+          if (*util::Sha256(input).computeDigest() == hash) {
+            _LOG_DEBUG("Asking to assemble a file, but file already exists on a filesystem");
+            continue;
+          }
       }
     }
-    catch (filesystem::filesystem_error& error) {
-      _LOG_ERROR("File operations failed on [" << filePath << "] (ignoring)");
+    catch (fs::filesystem_error& error) {
+      _LOG_ERROR("File operations failed on [" << filePath << "](ignoring)");
     }
 
-    if (ObjectDb::DoesExist(m_rootDir / ".chronoshare", deviceName,
-                            boost::lexical_cast<string>(hash))) {
+    if (ObjectDb::doesExist(m_rootDir / ".chronoshare", deviceName, toHex(hash))) {
       bool ok = m_objectManager.objectsToLocalFile(deviceName, hash, filePath);
       if (ok) {
         last_write_time(filePath, file->mtime());
 #if BOOST_VERSION >= 104900
-        permissions(filePath, static_cast<filesystem::perms>(file->mode()));
+        permissions(filePath, static_cast<fs::perms>(file->mode()));
 #endif
 
         m_fileState->SetFileComplete(file->filename());
@@ -505,36 +463,5 @@
   }
 }
 
-// moved to state-server
-// void
-// Dispatcher::Restore_LocalFile_Execute (FileItemPtr file)
-// {
-//   _LOG_DEBUG ("Got request to restore local file [" << file->filename () << "]");
-//   // the rest will gracefully fail if object-db is missing or incomplete
-
-//   boost::filesystem::path filePath = m_rootDir / file->filename ();
-//   Name deviceName (file->device_name ().c_str (), file->device_name ().size ());
-//   Hash hash (file->file_hash ().c_str (), file->file_hash ().size ());
-
-//   try
-//     {
-//       if (filesystem::exists (filePath) &&
-//           filesystem::last_write_time (filePath) == file->mtime () &&
-//           filesystem::status (filePath).permissions () == static_cast<filesystem::perms> (file->mode ()) &&
-//           *Hash::FromFileContent (filePath) == hash)
-//         {
-//           _LOG_DEBUG ("Asking to assemble a file, but file already exists on a filesystem");
-//           return;
-//         }
-//     }
-//   catch (filesystem::filesystem_error &error)
-//     {
-//       _LOG_ERROR ("File operations failed on [" << filePath << "] (ignoring)");
-//     }
-
-//   m_objectManager.objectsToLocalFile (deviceName, hash, filePath);
-
-//   last_write_time (filePath, file->mtime ());
-//   permissions (filePath, static_cast<filesystem::perms> (file->mode ()));
-
-// }
+} // namespace chronoshare
+} // namespace ndn
diff --git a/src/dispatcher.hpp b/src/dispatcher.hpp
index 526a633..dcc73e4 100644
--- a/src/dispatcher.hpp
+++ b/src/dispatcher.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016, Regents of the University of California.
+ * Copyright (c) 2013-2017, Regents of the University of California.
  *
  * This file is part of ChronoShare, a decentralized file sharing application over NDN.
  *
@@ -18,41 +18,60 @@
  * See AUTHORS.md for complete list of ChronoShare authors and contributors.
  */
 
-#ifndef DISPATCHER_H
-#define DISPATCHER_H
+#ifndef CHRONOSHARE_SRC_DISPATCHER_HPP
+#define CHRONOSHARE_SRC_DISPATCHER_HPP
+
+#include "core/chronoshare-common.hpp"
 
 #include "action-log.hpp"
-#include "ccnx-wrapper.hpp"
 #include "content-server.hpp"
-#include "executor.hpp"
 #include "fetch-manager.hpp"
 #include "object-db.hpp"
 #include "object-manager.hpp"
-#include "state-server.hpp"
 #include "sync-core.hpp"
 
 #include <boost/filesystem.hpp>
-#include <boost/function.hpp>
-#include <boost/shared_ptr.hpp>
+#include <boost/filesystem/fstream.hpp>
 #include <map>
 
-typedef boost::shared_ptr<ActionItem> ActionItemPtr;
+namespace ndn {
+namespace chronoshare {
+
+typedef shared_ptr<ActionItem> ActionItemPtr;
 
 // TODO:
 // This class lacks a permanent table to store the files in fetching process
 // and fetch the missing pieces for those in the table after the application launches
+
+/**
+  * @brief Class synchroize different components
+  *
+  * - from SyncLog: when state changes -> to fetch missing actions
+  *
+  * - from FetchManager/Actions: when action is fetched -> to request a file, specified by the action
+  *                                                     -> to add action to the action log
+  *
+  * - from ActionLog/Delete: when action applied(file state changed, file deleted) -> to delete local file
+  *
+  * - from ActionLog/AddOrUpdate: when action applied(file state changes, file added or modified) ->
+  *                               to assemble the file if file is available in the ObjectDb, otherwise, do nothing
+  *
+  * - from FetchManager/Files: when file segment is retrieved -> save it in ObjectDb
+  *                            when file fetch is completed   -> if file belongs to FileState, then assemble
+  *                            it to filesystem. Don't do anything otherwise
+  */
+
 class Dispatcher
 {
 public:
   // sharedFolder is the name to be used in NDN name;
   // rootDir is the shared folder dir in local file system;
   Dispatcher(const std::string& localUserName, const std::string& sharedFolder,
-             const boost::filesystem::path& rootDir, Ccnx::CcnxWrapperPtr ccnx,
-             bool enablePrefixDiscovery = true);
+             const boost::filesystem::path& rootDir, Face& face, bool enablePrefixDiscovery = true);
   ~Dispatcher();
 
-  // ----- Callbacks, they only submit the job to executor and immediately return so that event processing thread won't be blocked for too long -------
-
+  // ----- Callbacks, they only submit the job to executor and immediately return so that event
+  // processing thread won't be blocked for too long -------
 
   // callback to process local file change
   void
@@ -68,7 +87,7 @@
   Restore_LocalFile(FileItemPtr file);
 
   // for test
-  HashPtr
+  ConstBufferPtr
   SyncRoot()
   {
     return m_core->root();
@@ -83,12 +102,17 @@
 
 private:
   void
-  Did_LocalFile_AddOrModify_Execute(
-    boost::filesystem::path relativeFilepath); // cannot be const & for Execute event!!! otherwise there will be segfault
+  Did_LocalFile_AddOrModify_Execute(boost::filesystem::path relativeFilepath); // cannot be const &
+                                                                               // for Execute
+                                                                               // event!!! otherwise
+                                                                               // there will be
+                                                                               // segfault
 
   void
-  Did_LocalFile_Delete_Execute(
-    boost::filesystem::path relativeFilepath); // cannot be const & for Execute event!!! otherwise there will be segfault
+  Did_LocalFile_Delete_Execute(boost::filesystem::path relativeFilepath); // cannot be const & for
+                                                                          // Execute event!!!
+                                                                          // otherwise there will be
+                                                                          // segfault
 
   void
   Restore_LocalFile_Execute(FileItemPtr file);
@@ -97,17 +121,19 @@
   /**
    * Callbacks:
    *
- x * - from SyncLog: when state changes -> to fetch missing actions
+   * - from SyncLog: when state changes -> to fetch missing actions
    *
- x * - from FetchManager/Actions: when action is fetched -> to request a file, specified by the action
+   * - from FetchManager/Actions: when action is fetched -> to request a file, specified by the action
    *                                                     -> to add action to the action log
    *
-   * - from ActionLog/Delete:      when action applied (file state changed, file deleted)           -> to delete local file
+   * - from ActionLog/Delete: when action applied(file state changed, file deleted) -> to delete local file
    *
-   * - from ActionLog/AddOrUpdate: when action applied (file state changes, file added or modified) -> to assemble the file if file is available in the ObjectDb, otherwise, do nothing
+   * - from ActionLog/AddOrUpdate: when action applied(file state changes, file added or modified) ->
+   *                               to assemble the file if file is available in the ObjectDb, otherwise, do nothing
    *
- x * - from FetchManager/Files: when file segment is retrieved -> save it in ObjectDb
-   *                            when file fetch is completed   -> if file belongs to FileState, then assemble it to filesystem. Don't do anything otherwise
+   * - from FetchManager/Files: when file segment is retrieved -> save it in ObjectDb
+   *                            when file fetch is completed   -> if file belongs to FileState, then assemble
+   *                            it to filesystem. Don't do anything otherwise
    */
 
   // callback to process remote sync state change
@@ -118,8 +144,8 @@
   Did_SyncLog_StateChange_Execute(SyncStateMsgPtr stateMsg);
 
   void
-  Did_FetchManager_ActionFetch(const Ccnx::Name& deviceName, const Ccnx::Name& actionName,
-                               uint32_t seqno, Ccnx::PcoPtr actionPco);
+  Did_FetchManager_ActionFetch(const Name& deviceName, const Name& actionName, uint32_t seqno,
+                               shared_ptr<Data> actionData);
 
   void
   Did_ActionLog_ActionApply_Delete(const std::string& filename);
@@ -128,29 +154,31 @@
   Did_ActionLog_ActionApply_Delete_Execute(std::string filename);
 
   // void
-  // Did_ActionLog_ActionApply_AddOrModify (const std::string &filename, Ndnx::Name device_name, sqlite3_int64 seq_no,
-  //                                        HashPtr hash, time_t m_time, int mode, int seg_num);
+  // Did_ActionLog_ActionApply_AddOrModify(const std::string &filename, Name device_name,
+  // sqlite3_int64 seq_no,
+  //                                        ConstBufferPtr hash, time_t m_time, int mode, int
+  //                                        seg_num);
 
   void
-  Did_FetchManager_FileSegmentFetch(const Ccnx::Name& deviceName, const Ccnx::Name& fileSegmentName,
-                                    uint32_t segment, Ccnx::PcoPtr fileSegmentPco);
+  Did_FetchManager_FileSegmentFetch(const Name& deviceName, const Name& fileSegmentName,
+                                    uint32_t segment, shared_ptr<Data> fileSegmentData);
 
   void
-  Did_FetchManager_FileSegmentFetch_Execute(Ccnx::Name deviceName, Ccnx::Name fileSegmentName,
-                                            uint32_t segment, Ccnx::PcoPtr fileSegmentPco);
+  Did_FetchManager_FileSegmentFetch_Execute(Name deviceName, Name fileSegmentName, uint32_t segment,
+                                            shared_ptr<Data> fileSegmentData);
 
   void
-  Did_FetchManager_FileFetchComplete(const Ccnx::Name& deviceName, const Ccnx::Name& fileBaseName);
+  Did_FetchManager_FileFetchComplete(const Name& deviceName, const Name& fileBaseName);
 
   void
-  Did_FetchManager_FileFetchComplete_Execute(Ccnx::Name deviceName, Ccnx::Name fileBaseName);
+  Did_FetchManager_FileFetchComplete_Execute(Name deviceName, Name fileBaseName);
 
   void
-  Did_LocalPrefix_Updated(const Ccnx::Name& prefix);
+  Did_LocalPrefix_Updated(const Name& prefix);
 
 private:
   void
-  AssembleFile_Execute(const Ccnx::Name& deviceName, const Hash& filehash,
+  AssembleFile_Execute(const Name& deviceName, const Buffer& filehash,
                        const boost::filesystem::path& relativeFilepath);
 
   // void
@@ -163,42 +191,48 @@
   // actionReceived(const ActionItemPtr &actionItem);
 
   // void
-  // fileSegmentReceived(const Ndnx::Name &name, const Ndnx::Bytes &content);
+  // fileSegmentReceived(const Name &name, const Ccnx::Bytes &content);
 
   // void
-  // fileReady(const Ndnx::Name &fileNamePrefix);
+  // fileReady(const Name &fileNamePrefix);
 
 private:
-  Ccnx::CcnxWrapperPtr m_ccnx;
-  SyncCore* m_core;
+  Face& m_face;
+  unique_ptr<SyncCore> m_core;
   SyncLogPtr m_syncLog;
   ActionLogPtr m_actionLog;
   FileStatePtr m_fileState;
   FileStatePtr m_fileStateCow;
 
   boost::filesystem::path m_rootDir;
-  Executor m_executor;
+  boost::asio::io_service& m_ioService;
+
   ObjectManager m_objectManager;
-  Ndnx::Name m_localUserName;
+  Name m_localUserName;
   // maintain object db ptrs so that we don't need to create them
   // for every fetched segment of a file
 
-  std::map<Hash, ObjectDbPtr> m_objectDbMap;
+  std::map<Buffer, shared_ptr<ObjectDb>> m_objectDbMap;
 
   std::string m_sharedFolder;
-  ContentServer* m_server;
-  StateServer* m_stateServer;
+  unique_ptr<ContentServer> m_server;
+  //unique_ptr<StateServer> m_stateServer;
   bool m_enablePrefixDiscovery;
 
   FetchManagerPtr m_actionFetcher;
   FetchManagerPtr m_fileFetcher;
+
+  KeyChain m_keyChain;
 };
 
-namespace Error {
+namespace error {
 struct Dispatcher : virtual boost::exception, virtual std::exception
 {
 };
 typedef boost::error_info<struct tag_errmsg, std::string> error_info_str;
-}
+} // namespace error
 
-#endif // DISPATCHER_H
+} // namespace chronoshare
+} // namespace ndn
+
+#endif // CHRONOSHARE_SRC_DISPATCHER_HPP
diff --git a/src/sync-core.cpp b/src/sync-core.cpp
index f894746..23c65c3 100644
--- a/src/sync-core.cpp
+++ b/src/sync-core.cpp
@@ -38,7 +38,7 @@
 
 SyncCore::SyncCore(Face& face, SyncLogPtr syncLog, const Name& userName, const Name& localPrefix,
                    const Name& syncPrefix, const StateMsgCallback& callback,
-                   long syncInterestInterval /*= -1.0*/)
+                   time::seconds syncInterestInterval /*= -1.0*/)
   : m_face(face)
   , m_log(syncLog)
   , m_scheduler(m_face.getIoService())
@@ -60,8 +60,9 @@
 
   m_log->UpdateLocalLocator(localPrefix);
 
-  time::seconds interval = time::seconds(
-    (m_syncInterestInterval > 0 && m_syncInterestInterval < 30) ? m_syncInterestInterval : 4);
+  time::seconds interval =
+    (m_syncInterestInterval > time::seconds(0) && m_syncInterestInterval < time::seconds(30)) ?
+      m_syncInterestInterval : time::seconds(4);
 
   m_periodicInterestEvent =
     m_scheduler.scheduleEvent(interval, bind(&SyncCore::sendPeriodicSyncInterest, this, interval));
@@ -156,8 +157,8 @@
                  << syncInterest);
 
   Interest interest(syncInterest);
-  if (m_syncInterestInterval > 0 && m_syncInterestInterval < 30) {
-    interest.setInterestLifetime(time::seconds(m_syncInterestInterval));
+  if (m_syncInterestInterval > time::seconds(0) && m_syncInterestInterval < time::seconds(30)) {
+    interest.setInterestLifetime(m_syncInterestInterval);
   }
 
   m_face.expressInterest(interest, bind(&SyncCore::handleSyncData, this, _1, _2),
diff --git a/src/sync-core.hpp b/src/sync-core.hpp
index 6679244..f41bc0c 100644
--- a/src/sync-core.hpp
+++ b/src/sync-core.hpp
@@ -123,7 +123,7 @@
            ,
            const StateMsgCallback& callback // callback when state change is detected
            ,
-           long syncInterestInterval = -1);
+           time::seconds syncInterestInterval = time::seconds(0));
   ~SyncCore();
 
   void updateLocalState(sqlite3_int64);
@@ -214,7 +214,7 @@
 
   IntervalGeneratorPtr m_recoverWaitGenerator;
 
-  long m_syncInterestInterval;
+  time::seconds m_syncInterestInterval;
   KeyChain m_keyChain;
   const RegisteredPrefixId* m_registeredPrefixId;
 };
diff --git a/tests/unit-tests/action-log.t.cpp b/tests/unit-tests/action-log.t.cpp
index 8d874bc..deaff17 100644
--- a/tests/unit-tests/action-log.t.cpp
+++ b/tests/unit-tests/action-log.t.cpp
@@ -56,7 +56,7 @@
 BOOST_AUTO_TEST_CASE(UpdateAction)
 {
   auto actionLog = std::make_shared<ActionLog>(forwarder.addFace(), tmpdir, syncLog,
-                                               "top-secret", "test-chronoshare",
+                                               "top-secret", name::Component("test-chronoshare"),
                                                ActionLog::OnFileAddedOrChangedCallback(),
                                                ActionLog::OnFileRemovedCallback());
 
@@ -156,7 +156,7 @@
 {
   bool hasDeleteCallbackCalled = false;
   auto actionLog = std::make_shared<ActionLog>(forwarder.addFace(), tmpdir, syncLog,
-                                               "top-secret", "test-chronoshare",
+                                               "top-secret", name::Component("test-chronoshare"),
                                                ActionLog::OnFileAddedOrChangedCallback(),
                                                bind([&] { hasDeleteCallbackCalled = true; }));
 
diff --git a/tests/unit-tests/content-server.t.cpp b/tests/unit-tests/content-server.t.cpp
index 8dca18f..4df3777 100644
--- a/tests/unit-tests/content-server.t.cpp
+++ b/tests/unit-tests/content-server.t.cpp
@@ -50,7 +50,7 @@
 
     syncLog = make_shared<SyncLog>(root, deviceName);
     actionLog = std::make_shared<ActionLog>(face, root, syncLog,
-                                            "top-secret", "test-chronoshare",
+                                            "top-secret", name::Component("test-chronoshare"),
                                             ActionLog::OnFileAddedOrChangedCallback(),
                                             ActionLog::OnFileRemovedCallback());
 
@@ -61,9 +61,8 @@
 
     ndn::ConstBufferPtr hash = syncLog->RememberStateInStateLog();
 
-    server = make_unique<ContentServer>(face, actionLog, root,
-                                        deviceName, shareFolderName,
-                                        "test-chronoshare", m_keyChain, 5);
+    server = make_unique<ContentServer>(face, actionLog, root, deviceName, shareFolderName,
+                                        name::Component("test-chronoshare"), m_keyChain, time::seconds(5));
 
     Name localPrefix("/local");
     Name broadcastPrefix("/multicast");
diff --git a/tests/unit-tests/serve-and-fetch.t.cpp b/tests/unit-tests/serve-and-fetch.t.cpp
index c5ea473..79c57f4 100644
--- a/tests/unit-tests/serve-and-fetch.t.cpp
+++ b/tests/unit-tests/serve-and-fetch.t.cpp
@@ -151,7 +151,8 @@
                         << " seconds ...");
 
   ActionLogPtr dummyLog;
-  ContentServer server(face_serve, dummyLog, root, deviceName, "pentagon's secrets", APPNAME, m_keyChain, 5);
+  ContentServer server(face_serve, dummyLog, root, deviceName, "pentagon's secrets",
+                       name::Component(APPNAME), m_keyChain, time::seconds(5));
   server.registerPrefix(localPrefix);
   server.registerPrefix(broadcastPrefix);
 
diff --git a/wscript b/wscript
index 552b26f..12c7f3d 100644
--- a/wscript
+++ b/wscript
@@ -109,7 +109,8 @@
                                   'src/action-log.cpp',
                                   'src/object-*.cpp',
                                   'src/fetch*.cpp',
-                                  'src/content-server.cpp'
+                                  'src/content-server.cpp',
+                                  'src/dispatcher.cpp'
                                   ]),
         use='core-objects adhoc NDN_CXX BOOST TINYXML SQLITE3',
         includes="src",