diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index e31c2c8..ea46654 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -99,10 +99,8 @@ void Drive::SyncFolders( ) Log( "Synchronizing folders", log::info ) ; - http::XmlResponse xml ; - m_http->Get( feed_base + "/-/folder?max-results=50&showroot=true", &xml, http::Header() ) ; - - Feed feed( xml.Response() ) ; + Feed feed ; + feed.Start( m_http, feed_base + "/-/folder?max-results=50&showroot=true" ) ; do { // first, get all collections from the query result @@ -143,9 +141,6 @@ void Drive::DetectChanges() feed.Start( m_http, feed_base + "?showfolders=true&showroot=true" ) ; - m_resume_link = feed.Root()["link"]. - Find( "@rel", "http://schemas.google.com/g/2005#resumable-create-media" )["@href"] ; - do { std::for_each( diff --git a/libgrive/src/drive/Drive.hh b/libgrive/src/drive/Drive.hh index 57c24f9..c11a744 100644 --- a/libgrive/src/drive/Drive.hh +++ b/libgrive/src/drive/Drive.hh @@ -53,14 +53,12 @@ public : private : void SyncFolders( ) ; - void file(); void FromRemote( const Entry& entry ) ; void FromChange( const Entry& entry ) ; void UpdateChangeStamp( ) ; private : http::Agent *m_http ; - std::string m_resume_link ; fs::path m_root ; State m_state ; Val m_options ; diff --git a/libgrive/src/drive/Feed.cc b/libgrive/src/drive/Feed.cc index f57545d..1ce3563 100644 --- a/libgrive/src/drive/Feed.cc +++ b/libgrive/src/drive/Feed.cc @@ -37,18 +37,6 @@ Feed::Feed( ) { } -Feed::Feed( const xml::Node& root ) : - m_root ( root ), - m_entries ( m_root["entry"] ) -{ -} - -void Feed::Assign( const xml::Node& root ) -{ - m_root = root ; - m_entries = m_root["entry"] ; -} - Feed::iterator Feed::begin() const { return iterator( m_entries.begin() ) ; @@ -59,12 +47,6 @@ Feed::iterator Feed::end() const return iterator( m_entries.end() ) ; } -std::string Feed::Next() const -{ - xml::NodeSet nss = m_root["link"].Find( "@rel", "next" ) ; - return nss.empty() ? "" : std::string(nss["@href"]) ; -} - void Feed::Start( http::Agent *http, const std::string& url ) { http::XmlResponse xrsp ; @@ -120,9 +102,4 @@ void Feed::EnableLog( const std::string& prefix, const std::string& suffix ) m_log->sequence = 0 ; } -const xml::Node& Feed::Root() const -{ - return m_root ; -} - } } // end of namespace gr::v1 diff --git a/libgrive/src/drive/Feed.hh b/libgrive/src/drive/Feed.hh index ce85435..ef87a27 100644 --- a/libgrive/src/drive/Feed.hh +++ b/libgrive/src/drive/Feed.hh @@ -33,7 +33,6 @@ namespace gr { namespace http { class Agent ; - class Header ; } namespace v1 { @@ -44,21 +43,14 @@ public : class iterator ; public : - explicit Feed( const xml::Node& root ) ; Feed( ) ; void Start( http::Agent *http, const std::string& url ) ; - - void Assign( const xml::Node& root ) ; - const xml::Node& Root() const ; + bool GetNext( http::Agent *http ) ; iterator begin() const ; iterator end() const ; - std::string Next() const ; - bool GetNext( http::Agent *http ) ; - void EnableLog( const std::string& prefix, const std::string& suffix ) ; - private : struct LogInfo { diff --git a/libgrive/src/drive2/Feed.cc b/libgrive/src/drive2/Feed.cc index 93f5a24..03fcea4 100644 --- a/libgrive/src/drive2/Feed.cc +++ b/libgrive/src/drive2/Feed.cc @@ -27,44 +27,32 @@ namespace gr { namespace v2 { -Feed::Feed( const std::string& base ) : - m_base( base ) +Feed::Feed( ) { - // Next() will grab this link - m_content.Add( "nextLink", Val(base) ) ; } -// for example to find dirs: Query( "mimeType", mime_types::folder ) -void Feed::Query( const std::string& field, const std::string& value ) +// for example to find dirs: '?q=mimeType%3d%27' + mime_types::folder + '%27' +void Feed::Start( http::Agent *http, const std::string& url ) { - std::string url = m_content["nextLink"].Str() ; - m_content.Add( "nextLink", Val( url + "?q=" + field + "+%3d+%27" + value + "%27" ) ) ; -} - -bool Feed::Next( http::Agent *agent ) -{ - Val url ; - if ( !m_content.Get("nextLink", url) ) - return false ; - http::ValResponse out ; - try - { - agent->Get( url.Str(), &out, http::Header() ) ; - } - catch ( Exception& e ) - { - e << DriveFeed_( m_content ) ; - throw ; - } - m_content = out.Response() ; - return true ; + http->Get( url, &out, http::Header() ) ; + + m_content = out.Response() ; } -Val Feed::Content() const +bool Feed::GetNext( http::Agent *http ) { - return m_content ; + assert( http != 0 ) ; + + Val url ; + if ( m_content.Get( "nextLink", url ) ) + { + Start( http, url ) ; + return true ; + } + else + return false ; } } } // end of namespace diff --git a/libgrive/src/drive2/Feed.hh b/libgrive/src/drive2/Feed.hh index ad1f294..7191750 100644 --- a/libgrive/src/drive2/Feed.hh +++ b/libgrive/src/drive2/Feed.hh @@ -29,7 +29,6 @@ namespace gr namespace http { class Agent ; - class Header ; } class Val ; @@ -39,21 +38,12 @@ namespace v2 { class Feed { public : - // exception info - typedef boost::error_info DriveFeed_ ; - -public : - Feed( const std::string& base ) ; - void Query( const std::string& field, const std::string& value ) ; - - - bool Next( http::Agent *agent ) ; - - Val Content() const ; + Feed( ) ; + void Start( http::Agent *http, const std::string& url ) ; + bool GetNext( http::Agent *http ) ; private : - std::string m_base ; - Val m_content ; + Val m_content ; } ; } } // end of namespace gr::v2