Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 23 | #include <hash-helper.h> |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 24 | |
| 25 | using namespace std; |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 26 | using namespace boost; |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 28 | NotifyI::NotifyI (ActionLogPtr &actionLog) |
| 29 | : m_actionLog (actionLog) |
| 30 | { |
| 31 | } |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 32 | |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 33 | void |
| 34 | NotifyI::updateFile (const ::std::string &filename, |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 35 | const ::std::pair<const Ice::Byte*, const Ice::Byte*> &hashRaw, |
Alexander Afanasyev | 433ecda | 2013-01-02 22:13:45 -0800 | [diff] [blame] | 36 | ::Ice::Long atime, |
| 37 | ::Ice::Long mtime, |
| 38 | ::Ice::Long ctime, |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 39 | ::Ice::Int mode, |
| 40 | const ::Ice::Current&) |
| 41 | { |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 42 | Hash hash (hashRaw.first, hashRaw.second-hashRaw.first); |
| 43 | |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 44 | 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 Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 57 | void |
| 58 | NotifyI::moveFile (const ::std::string &oldFilename, |
| 59 | const ::std::string &newFilename, |
| 60 | const ::Ice::Current&) |
| 61 | { |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 62 | cout << "moveFile from " << oldFilename << " to " << newFilename << endl; |
| 63 | // m_actionLog->AddActionMove (oldFilename, newFilename); |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 64 | } |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 65 | |
| 66 | void |
| 67 | NotifyI::deleteFile (const ::std::string &filename, |
| 68 | const ::Ice::Current&) |
| 69 | { |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 70 | cout << "deleteFile " << filename << endl; |
| 71 | m_actionLog->AddActionDelete (filename); |
| 72 | m_actionLog->RememberStateInStateLog (); |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 73 | } |
| 74 | |