2012-06-03 21:07:14 +04:00
|
|
|
/*
|
2015-05-17 22:09:42 +03:00
|
|
|
Item list ("Feed") implementation for the old "Document List" Google Docs API
|
|
|
|
Copyright (C) 2012 Wan Wai Ho, (C) 2015 Vitaliy Filippov
|
2012-06-03 21:07:14 +04:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
#include "CommonUri.hh"
|
|
|
|
#include "Feed1.hh"
|
2012-06-03 21:07:14 +04:00
|
|
|
|
2015-05-16 21:10:38 +03:00
|
|
|
#include "Entry1.hh"
|
|
|
|
|
2012-06-03 21:07:14 +04:00
|
|
|
#include "http/Agent.hh"
|
2013-04-28 20:13:34 +04:00
|
|
|
#include "http/Header.hh"
|
2012-06-03 21:07:14 +04:00
|
|
|
#include "http/XmlResponse.hh"
|
|
|
|
#include "xml/NodeSet.hh"
|
|
|
|
|
2012-07-11 20:36:58 +04:00
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
2012-06-03 21:07:14 +04:00
|
|
|
#include <cassert>
|
|
|
|
|
2013-04-29 09:23:34 +04:00
|
|
|
namespace gr { namespace v1 {
|
2012-06-03 21:07:14 +04:00
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
Feed1::Feed1( const std::string &url ):
|
|
|
|
Feed( url )
|
2012-07-11 20:36:58 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
bool Feed1::GetNext( http::Agent *http )
|
2012-07-11 20:36:58 +04:00
|
|
|
{
|
|
|
|
http::XmlResponse xrsp ;
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
if ( m_next.empty() )
|
|
|
|
return false;
|
|
|
|
|
2015-09-30 13:53:53 +03:00
|
|
|
http->Get( m_next, &xrsp, http::Header() ) ;
|
2012-07-11 20:36:58 +04:00
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
xml::Node m_root = xrsp.Response() ;
|
2015-05-17 14:32:04 +03:00
|
|
|
xml::NodeSet xe = m_root["entry"] ;
|
|
|
|
m_entries.clear() ;
|
|
|
|
for ( xml::NodeSet::iterator i = xe.begin() ; i != xe.end() ; ++i )
|
|
|
|
{
|
|
|
|
m_entries.push_back( Entry1( *i ) );
|
|
|
|
}
|
2015-05-17 16:54:04 +03:00
|
|
|
|
2012-06-03 21:07:14 +04:00
|
|
|
xml::NodeSet nss = m_root["link"].Find( "@rel", "next" ) ;
|
2015-05-17 16:54:04 +03:00
|
|
|
m_next = nss.empty() ? std::string( "" ) : nss["@href"];
|
|
|
|
|
|
|
|
return true;
|
2012-07-11 20:36:58 +04:00
|
|
|
}
|
|
|
|
|
2013-04-29 09:23:34 +04:00
|
|
|
} } // end of namespace gr::v1
|