2012-05-16 18:35:22 +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
|
|
|
|
as published by the Free Software Foundation version 2
|
|
|
|
of the License.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2012-05-16 20:52:17 +04:00
|
|
|
#include "util/FileSystem.hh"
|
2012-05-16 18:35:22 +04:00
|
|
|
|
2012-05-16 20:52:17 +04:00
|
|
|
#include <memory>
|
2012-05-16 18:35:22 +04:00
|
|
|
|
|
|
|
namespace gr {
|
|
|
|
|
|
|
|
class Json ;
|
2012-05-17 20:37:11 +04:00
|
|
|
class Collection ;
|
|
|
|
class Entry ;
|
2012-05-16 18:35:22 +04:00
|
|
|
|
|
|
|
class State
|
|
|
|
{
|
|
|
|
public :
|
2012-05-16 20:52:17 +04:00
|
|
|
explicit State( const fs::path& filename ) ;
|
2012-05-16 18:35:22 +04:00
|
|
|
|
2012-05-16 20:52:17 +04:00
|
|
|
void Sync( const fs::path& p ) ;
|
|
|
|
|
2012-05-17 20:37:11 +04:00
|
|
|
void OnEntry( const Entry& e ) ;
|
|
|
|
void ResolveEntry() ;
|
|
|
|
|
2012-05-16 21:20:02 +04:00
|
|
|
void SetId( const fs::path& p, const std::string& id ) ;
|
|
|
|
|
2012-05-16 20:52:17 +04:00
|
|
|
void Read( const fs::path& filename ) ;
|
|
|
|
void Write( const fs::path& filename ) const ;
|
2012-05-16 18:35:22 +04:00
|
|
|
|
2012-05-16 20:52:17 +04:00
|
|
|
std::string ChangeStamp() const ;
|
|
|
|
void ChangeStamp( const std::string& cs ) ;
|
|
|
|
|
2012-05-17 20:37:11 +04:00
|
|
|
Collection* FindFolderByHref( const std::string& href ) ;
|
|
|
|
Collection* FindFolderByID( const std::string& id ) ;
|
|
|
|
|
|
|
|
private :
|
|
|
|
void Sync( const fs::path& p, Collection *folder ) ;
|
|
|
|
bool Update( const Entry& e ) ;
|
|
|
|
std::size_t TryResolveEntry() ;
|
|
|
|
|
2012-05-16 18:35:22 +04:00
|
|
|
private :
|
2012-05-16 20:52:17 +04:00
|
|
|
struct Impl ;
|
|
|
|
std::auto_ptr<Impl> m_impl ;
|
2012-05-16 18:35:22 +04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
} // end of namespace
|