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 | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 36 | ::Ice::Long wtime, |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 37 | ::Ice::Int mode, |
| 38 | const ::Ice::Current&) |
| 39 | { |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 40 | Hash hash (hashRaw.first, hashRaw.second-hashRaw.first); |
| 41 | |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 42 | cout << "updateFile " << filename << " with hash " << hash << endl; |
| 43 | try |
| 44 | { |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 45 | m_actionLog->AddActionUpdate (filename, hash, wtime, mode); |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 46 | |
| 47 | m_actionLog->RememberStateInStateLog (); |
| 48 | } |
| 49 | catch (const boost::exception &e) |
| 50 | { |
| 51 | cout << "ERRORR: " << *get_error_info<errmsg_info_str> (e) << endl; |
| 52 | } |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 55 | void |
| 56 | NotifyI::moveFile (const ::std::string &oldFilename, |
| 57 | const ::std::string &newFilename, |
| 58 | const ::Ice::Current&) |
| 59 | { |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 60 | cout << "moveFile from " << oldFilename << " to " << newFilename << endl; |
| 61 | // m_actionLog->AddActionMove (oldFilename, newFilename); |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 62 | } |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 63 | |
| 64 | void |
| 65 | NotifyI::deleteFile (const ::std::string &filename, |
| 66 | const ::Ice::Current&) |
| 67 | { |
Alexander Afanasyev | b6bc01a | 2013-01-02 23:34:20 -0800 | [diff] [blame] | 68 | cout << "deleteFile " << filename << endl; |
| 69 | m_actionLog->AddActionDelete (filename); |
| 70 | m_actionLog->RememberStateInStateLog (); |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 71 | } |
| 72 | |