blob: 0994aa30a4656446b1b8c9fa4e21207968350d5c [file] [log] [blame]
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20 */
21
22#include "notify-i.h"
Alexander Afanasyeva199f972013-01-02 19:37:26 -080023#include <hash-helper.h>
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080024
25using namespace std;
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080026using namespace boost;
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080027
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080028NotifyI::NotifyI (ActionLogPtr &actionLog)
29 : m_actionLog (actionLog)
30{
31}
Alexander Afanasyeva199f972013-01-02 19:37:26 -080032
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080033void
34NotifyI::updateFile (const ::std::string &filename,
Alexander Afanasyeva199f972013-01-02 19:37:26 -080035 const ::std::pair<const Ice::Byte*, const Ice::Byte*> &hashRaw,
Alexander Afanasyev433ecda2013-01-02 22:13:45 -080036 ::Ice::Long atime,
37 ::Ice::Long mtime,
38 ::Ice::Long ctime,
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080039 ::Ice::Int mode,
40 const ::Ice::Current&)
41{
Alexander Afanasyeva199f972013-01-02 19:37:26 -080042 Hash hash (hashRaw.first, hashRaw.second-hashRaw.first);
43
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080044 cout << "updateFile " << filename << " with hash " << hash << endl;
45 try
46 {
47 m_actionLog->AddActionUpdate (filename, hash, atime, mtime, ctime, mode);
48
49 m_actionLog->RememberStateInStateLog ();
50 }
51 catch (const boost::exception &e)
52 {
53 cout << "ERRORR: " << *get_error_info<errmsg_info_str> (e) << endl;
54 }
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080055}
56
Alexander Afanasyeva199f972013-01-02 19:37:26 -080057void
58NotifyI::moveFile (const ::std::string &oldFilename,
59 const ::std::string &newFilename,
60 const ::Ice::Current&)
61{
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080062 cout << "moveFile from " << oldFilename << " to " << newFilename << endl;
63 // m_actionLog->AddActionMove (oldFilename, newFilename);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080064}
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080065
66void
67NotifyI::deleteFile (const ::std::string &filename,
68 const ::Ice::Current&)
69{
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080070 cout << "deleteFile " << filename << endl;
71 m_actionLog->AddActionDelete (filename);
72 m_actionLog->RememberStateInStateLog ();
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080073}
74