ActionLog preliminary works, but still has a lot of pieces missing
diff --git a/daemon/daemon.cc b/daemon/daemon.cc
index 97fee4f..5b953d3 100644
--- a/daemon/daemon.cc
+++ b/daemon/daemon.cc
@@ -25,6 +25,7 @@
#include <Ice/Identity.h>
#include "notify-i.h"
+#include <boost/make_shared.hpp>
using namespace std;
using namespace boost;
@@ -34,6 +35,12 @@
class MyService : public Ice::Service
{
+public:
+ MyService (ActionLogPtr actionLog)
+ : m_actionLog (actionLog)
+ {
+ }
+
protected:
virtual bool start (int, char*[], int&)
{
@@ -41,7 +48,7 @@
Ice::Identity identity;
identity.name="NotifyDaemon";
- NotifyPtr servant=new NotifyI;
+ NotifyPtr servant=new NotifyI (m_actionLog);
_adapter->add (servant, identity);
@@ -51,7 +58,8 @@
}
private:
- Ice::ObjectAdapterPtr _adapter;
+ Ice::ObjectAdapterPtr _adapter;
+ ActionLogPtr m_actionLog;
};
int
@@ -62,9 +70,9 @@
try
{
// DbHelper db ("./", "/ndn/ucla.edu/alex");
- ActionLog bla ("./", "/ndn/ucla.edu/alex");
+ ActionLogPtr actionLog = make_shared<ActionLog> ("./", "/ndn/ucla.edu/alex");
- MyService svc;
+ MyService svc (actionLog);
status = svc.main (argc, argv);
// HashPtr hash = db.RememberStateInStateLog ();
diff --git a/daemon/notify-i.cc b/daemon/notify-i.cc
index 43aa32e..0994aa3 100644
--- a/daemon/notify-i.cc
+++ b/daemon/notify-i.cc
@@ -23,11 +23,12 @@
#include <hash-helper.h>
using namespace std;
+using namespace boost;
-// NotifyI::NotifyI (DbHelperPtr &db)
-// : m_db (db)
-// {
-// }
+NotifyI::NotifyI (ActionLogPtr &actionLog)
+ : m_actionLog (actionLog)
+{
+}
void
NotifyI::updateFile (const ::std::string &filename,
@@ -40,9 +41,17 @@
{
Hash hash (hashRaw.first, hashRaw.second-hashRaw.first);
- // m_db->AddActionUpdate (filename, hash, atime, mtime, ctime, mode);
-
- // cout << "updateFile " << filename << " with hash " << hash << endl;
+ cout << "updateFile " << filename << " with hash " << hash << endl;
+ try
+ {
+ m_actionLog->AddActionUpdate (filename, hash, atime, mtime, ctime, mode);
+
+ m_actionLog->RememberStateInStateLog ();
+ }
+ catch (const boost::exception &e)
+ {
+ cout << "ERRORR: " << *get_error_info<errmsg_info_str> (e) << endl;
+ }
}
void
@@ -50,16 +59,16 @@
const ::std::string &newFilename,
const ::Ice::Current&)
{
- // cout << "moveFile from " << oldFilename << " to " << newFilename << endl;
- // m_db->AddActionMove (filename, oldFilename);
+ cout << "moveFile from " << oldFilename << " to " << newFilename << endl;
+ // m_actionLog->AddActionMove (oldFilename, newFilename);
}
void
NotifyI::deleteFile (const ::std::string &filename,
const ::Ice::Current&)
{
- // m_db->AddActionDelete (filename, oldFilename);
-
- // cout << "deleteFile " << filename << endl;
+ cout << "deleteFile " << filename << endl;
+ m_actionLog->AddActionDelete (filename);
+ m_actionLog->RememberStateInStateLog ();
}
diff --git a/daemon/notify-i.h b/daemon/notify-i.h
index 42d4d7e..9fd7044 100644
--- a/daemon/notify-i.h
+++ b/daemon/notify-i.h
@@ -22,12 +22,13 @@
#ifndef NOTIFY_I_H
#define NOTIFY_I_H
+#include <action-log.h>
#include <chronoshare-client.ice.h>
class NotifyI : public ChronoshareClient::Notify
{
public:
- // NotifyI (DbHelperPtr &db);
+ NotifyI (ActionLogPtr &actionLog);
virtual void
updateFile (const ::std::string &filename,
@@ -48,7 +49,7 @@
const ::Ice::Current& = ::Ice::Current());
private:
- // DbHelperPtr m_db;
+ ActionLogPtr m_actionLog;
};
#endif // NOTIFY_I_H