action-log: Switch code to use ndn-cxx

This commit also moves code to ndn::chronoshare namespace

Change-Id: I3431833f1037eec9100515c405528cd4674be158
diff --git a/src/action-log.hpp b/src/action-log.hpp
index 80f354c..99bcb0e 100644
--- a/src/action-log.hpp
+++ b/src/action-log.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,34 +18,48 @@
  * See AUTHORS.md for complete list of ChronoShare authors and contributors.
  */
 
-#ifndef ACTION_LOG_H
-#define ACTION_LOG_H
+#ifndef CHRONOSHARE_SRC_ACTION_LOG_HPP
+#define CHRONOSHARE_SRC_ACTION_LOG_HPP
 
-#include "action-item.pb.hpp"
-#include "ccnx-pco.hpp"
-#include "ccnx-wrapper.hpp"
 #include "db-helper.hpp"
-#include "file-item.pb.hpp"
 #include "file-state.hpp"
 #include "sync-log.hpp"
+#include "core/chronoshare-common.hpp"
 
-#include <boost/tuple/tuple.hpp>
+#include "action-item.pb.h"
+#include "file-item.pb.h"
+
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+
+namespace ndn {
+namespace chronoshare {
 
 class ActionLog;
-typedef boost::shared_ptr<ActionLog> ActionLogPtr;
-typedef boost::shared_ptr<ActionItem> ActionItemPtr;
+typedef shared_ptr<ActionLog> ActionLogPtr;
+typedef shared_ptr<ActionItem> ActionItemPtr;
 
 class ActionLog : public DbHelper
 {
 public:
-  typedef boost::function<void(std::string /*filename*/, Ccnx::Name /*device_name*/, sqlite3_int64 /*seq_no*/,
-                               HashPtr /*hash*/, time_t /*m_time*/, int /*mode*/, int /*seg_num*/)>
+  class Error : public DbHelper::Error
+  {
+  public:
+    explicit Error(const std::string& what)
+      : DbHelper::Error(what)
+    {
+    }
+  };
+
+public:
+  typedef function<void(std::string /*filename*/, Name /*device_name*/, sqlite3_int64 /*seq_no*/,
+                        ConstBufferPtr /*hash*/, time_t /*m_time*/, int /*mode*/, int /*seg_num*/)>
     OnFileAddedOrChangedCallback;
 
   typedef boost::function<void(std::string /*filename*/)> OnFileRemovedCallback;
 
 public:
-  ActionLog(Ccnx::CcnxWrapperPtr ccnx, const boost::filesystem::path& path, SyncLogPtr syncLog,
+  ActionLog(Face& face, const boost::filesystem::path& path, SyncLogPtr syncLog,
             const std::string& sharedFolder, const std::string& appName,
             OnFileAddedOrChangedCallback onFileAddedOrChanged, OnFileRemovedCallback onFileRemoved);
 
@@ -57,14 +71,11 @@
   // Local operations     //
   //////////////////////////
   ActionItemPtr
-  AddLocalActionUpdate(const std::string& filename,
-                       const Hash& hash,
-                       time_t wtime,
-                       int mode,
+  AddLocalActionUpdate(const std::string& filename, const Buffer& hash, time_t wtime, int mode,
                        int seg_num);
 
   // void
-  // AddActionMove (const std::string &oldFile, const std::string &newFile);
+  // AddActionMove(const std::string &oldFile, const std::string &newFile);
 
   ActionItemPtr
   AddLocalActionDelete(const std::string& filename);
@@ -74,51 +85,52 @@
   //////////////////////////
 
   ActionItemPtr
-  AddRemoteAction(const Ccnx::Name& deviceName, sqlite3_int64 seqno, Ccnx::PcoPtr actionPco);
+  AddRemoteAction(const Name& deviceName, sqlite3_int64 seqno, shared_ptr<Data> actionData);
 
   /**
    * @brief Add remote action using just action's parsed content object
    *
-   * This function extracts device name and sequence number from the content object's and calls the overloaded method
+   * This function extracts device name and sequence number from the content object's and calls the
+   * overloaded method
    */
   ActionItemPtr
-  AddRemoteAction(Ccnx::PcoPtr actionPco);
+  AddRemoteAction(shared_ptr<Data> actionData);
 
   ///////////////////////////
   // General operations    //
   ///////////////////////////
 
-  Ccnx::PcoPtr
-  LookupActionPco(const Ccnx::Name& deviceName, sqlite3_int64 seqno);
+  shared_ptr<Data>
+  LookupActionData(const Name& deviceName, sqlite3_int64 seqno);
 
-  Ccnx::PcoPtr
-  LookupActionPco(const Ccnx::Name& actionName);
+  shared_ptr<Data>
+  LookupActionData(const Name& actionName);
 
   ActionItemPtr
-  LookupAction(const Ccnx::Name& deviceName, sqlite3_int64 seqno);
+  LookupAction(const Name& deviceName, sqlite3_int64 seqno);
 
   ActionItemPtr
-  LookupAction(const Ccnx::Name& actionName);
+  LookupAction(const Name& actionName);
 
   FileItemPtr
-  LookupAction(const std::string& filename, sqlite3_int64 version, const Hash& filehash);
+  LookupAction(const std::string& filename, sqlite3_int64 version, const Buffer& filehash);
 
   /**
-   * @brief Lookup up to [limit] actions starting [offset] in decreasing order (by timestamp) and calling visitor(device_name,seqno,action) for each action
+   * @brief Lookup up to [limit] actions starting [offset] in decreasing order(by timestamp) and
+   * calling visitor(device_name,seqno,action) for each action
    */
   bool
   LookupActionsInFolderRecursively(
-    const boost::function<void(const Ccnx::Name& name, sqlite3_int64 seq_no, const ActionItem&)>& visitor,
+    const function<void(const Name& name, sqlite3_int64 seq_no, const ActionItem&)>& visitor,
     const std::string& folder, int offset = 0, int limit = -1);
 
   bool
   LookupActionsForFile(
-    const boost::function<void(const Ccnx::Name& name, sqlite3_int64 seq_no, const ActionItem&)>& visitor,
+    const function<void(const Name& name, sqlite3_int64 seq_no, const ActionItem&)>& visitor,
     const std::string& file, int offset = 0, int limit = -1);
 
   void
-  LookupRecentFileActions(const boost::function<void(const std::string&, int, int)>& visitor,
-                          int limit = 5);
+  LookupRecentFileActions(const function<void(const std::string&, int, int)>& visitor, int limit = 5);
 
   //
   inline FileStatePtr
@@ -130,7 +142,7 @@
   LogSize();
 
 private:
-  boost::tuple<sqlite3_int64 /*version*/, Ccnx::CcnxCharbufPtr /*device name*/, sqlite3_int64 /*seq_no*/>
+  std::tuple<sqlite3_int64 /*version*/, BufferPtr /*device name*/, sqlite3_int64 /*seq_no*/>
   GetLatestActionForFile(const std::string& filename);
 
   static void
@@ -140,25 +152,22 @@
   SyncLogPtr m_syncLog;
   FileStatePtr m_fileState;
 
-  Ndnx::NdnxWrapperPtr m_ndnx;
+  // Face& m_face;
   std::string m_sharedFolderName;
   std::string m_appName;
 
   OnFileAddedOrChangedCallback m_onFileAddedOrChanged;
   OnFileRemovedCallback m_onFileRemoved;
+  KeyChain m_keyChain;
 };
 
-namespace Error {
-struct ActionLog : virtual boost::exception, virtual std::exception
-{
-};
-}
-
 inline FileStatePtr
 ActionLog::GetFileState()
 {
   return m_fileState;
 }
 
+} // namespace chronoshare
+} // namespace ndn
 
-#endif // ACTION_LOG_H
+#endif // CHRONOSHARE_SRC_ACTION_LOG_HPP