2012-04-25 20:13:17 +04:00
|
|
|
/*
|
|
|
|
grive: an GPL program to sync a local directory with Google Drive
|
|
|
|
Copyright (C) 2012 Wan Wai Ho
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
2012-04-26 19:40:38 +04:00
|
|
|
as published by the Free Software Foundation version 2
|
2012-04-26 08:21:40 +04:00
|
|
|
of the License.
|
2012-04-25 20:13:17 +04:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
#include "base/State.hh"
|
2012-05-15 20:54:58 +04:00
|
|
|
|
2015-05-16 00:27:59 +03:00
|
|
|
#include "json/Val.hh"
|
2012-05-13 11:27:58 +04:00
|
|
|
#include "util/Exception.hh"
|
2012-04-26 19:40:38 +04:00
|
|
|
|
2012-04-25 20:13:17 +04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace gr {
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
class Syncer ;
|
2012-05-06 14:26:45 +04:00
|
|
|
|
2012-06-04 20:32:12 +04:00
|
|
|
class Entry ;
|
2012-04-25 20:13:17 +04:00
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
class State ;
|
2015-05-16 21:10:38 +03:00
|
|
|
|
2012-04-25 20:13:17 +04:00
|
|
|
class Drive
|
|
|
|
{
|
|
|
|
public :
|
2015-05-17 16:54:04 +03:00
|
|
|
Drive( Syncer *syncer, const Val& options ) ;
|
2012-04-25 20:13:17 +04:00
|
|
|
|
2012-06-23 14:23:43 +04:00
|
|
|
void DetectChanges() ;
|
2015-11-10 12:54:47 +03:00
|
|
|
bool Move( fs::path old_p, fs::path new_p );
|
2012-05-13 21:07:23 +04:00
|
|
|
void Update() ;
|
2012-06-17 12:33:38 +04:00
|
|
|
void DryRun() ;
|
2012-05-20 13:12:01 +04:00
|
|
|
void SaveState() ;
|
2012-05-15 20:54:58 +04:00
|
|
|
|
2012-05-13 11:27:58 +04:00
|
|
|
struct Error : virtual Exception {} ;
|
|
|
|
|
2012-04-25 20:13:17 +04:00
|
|
|
private :
|
2012-07-19 20:39:36 +04:00
|
|
|
void SyncFolders( ) ;
|
2012-06-04 20:32:12 +04:00
|
|
|
void FromRemote( const Entry& entry ) ;
|
|
|
|
void FromChange( const Entry& entry ) ;
|
2012-07-19 20:39:36 +04:00
|
|
|
void UpdateChangeStamp( ) ;
|
2012-04-26 19:40:38 +04:00
|
|
|
|
2012-04-25 20:13:17 +04:00
|
|
|
private :
|
2015-05-17 16:54:04 +03:00
|
|
|
Syncer *m_syncer ;
|
2012-07-30 12:52:59 +04:00
|
|
|
fs::path m_root ;
|
2012-06-03 12:42:51 +04:00
|
|
|
State m_state ;
|
2015-05-16 00:27:59 +03:00
|
|
|
Val m_options ;
|
2012-04-25 20:13:17 +04:00
|
|
|
} ;
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
} // end of namespace gr
|