Oops. I was thinking auto_ptr is smart_ptr O_o. Sorry. Also fix #33

pull/40/head
Vitaliy Filippov 2015-10-07 01:57:28 +03:00
parent dc8e172a27
commit f288c559c6
6 changed files with 12 additions and 13 deletions

View File

@ -153,7 +153,7 @@ int Main( int argc, char **argv )
if ( vm.count( "auth" ) ) if ( vm.count( "auth" ) )
{ {
OAuth2 token( http, client_id, client_secret ) ; OAuth2 token( http.get(), client_id, client_secret ) ;
std::cout std::cout
<< "-----------------------\n" << "-----------------------\n"
@ -189,8 +189,8 @@ int Main( int argc, char **argv )
return -1; return -1;
} }
OAuth2 token( http, refresh_token, client_id, client_secret ) ; OAuth2 token( http.get(), refresh_token, client_id, client_secret ) ;
AuthAgent agent( token, http ) ; AuthAgent agent( token, http.get() ) ;
v2::Syncer2 syncer( &agent ); v2::Syncer2 syncer( &agent );
Drive drive( &syncer, config.GetAll() ) ; Drive drive( &syncer, config.GetAll() ) ;

View File

@ -132,7 +132,7 @@ Val ValBuilder::Result() const
if ( !m_ctx.size() ) if ( !m_ctx.size() )
BOOST_THROW_EXCEPTION( Error() << NoKey_( Val(std::string("")) ) ) ; BOOST_THROW_EXCEPTION( Error() << NoKey_( Val(std::string("")) ) ) ;
Val r = m_ctx.top().val; Val r = m_ctx.top().val;
if ( m_ctx.size() > 0 ) if ( m_ctx.size() > 1 )
BOOST_THROW_EXCEPTION( Error() << Unexpected_(m_ctx.top().val) ) ; BOOST_THROW_EXCEPTION( Error() << Unexpected_(m_ctx.top().val) ) ;
return r; return r;
} }

View File

@ -31,11 +31,10 @@ namespace gr {
using namespace http ; using namespace http ;
AuthAgent::AuthAgent( OAuth2& auth, std::auto_ptr<Agent> real_agent ) : AuthAgent::AuthAgent( OAuth2& auth, Agent *real_agent ) :
m_auth ( auth ), m_auth ( auth ),
m_agent ( real_agent ) m_agent ( real_agent )
{ {
assert( m_agent.get() != 0 ) ;
} }
http::ResponseLog* AuthAgent::GetLog() const http::ResponseLog* AuthAgent::GetLog() const

View File

@ -34,7 +34,7 @@ namespace gr {
class AuthAgent : public http::Agent class AuthAgent : public http::Agent
{ {
public : public :
AuthAgent( OAuth2& auth, std::auto_ptr<http::Agent> real_agent ) ; AuthAgent( OAuth2& auth, http::Agent* real_agent ) ;
http::ResponseLog* GetLog() const ; http::ResponseLog* GetLog() const ;
void SetLog( http::ResponseLog *log ) ; void SetLog( http::ResponseLog *log ) ;
@ -86,7 +86,7 @@ private :
private : private :
OAuth2& m_auth ; OAuth2& m_auth ;
const std::auto_ptr<http::Agent> m_agent ; http::Agent* m_agent ;
} ; } ;
} // end of namespace } // end of namespace

View File

@ -33,7 +33,7 @@ namespace gr {
const std::string token_url = "https://accounts.google.com/o/oauth2/token" ; const std::string token_url = "https://accounts.google.com/o/oauth2/token" ;
OAuth2::OAuth2( OAuth2::OAuth2(
std::auto_ptr<http::Agent>& agent, http::Agent* agent,
const std::string& refresh_code, const std::string& refresh_code,
const std::string& client_id, const std::string& client_id,
const std::string& client_secret ) : const std::string& client_secret ) :
@ -46,7 +46,7 @@ OAuth2::OAuth2(
} }
OAuth2::OAuth2( OAuth2::OAuth2(
std::auto_ptr<http::Agent>& agent, http::Agent* agent,
const std::string& client_id, const std::string& client_id,
const std::string& client_secret ) : const std::string& client_secret ) :
m_agent( agent ), m_agent( agent ),

View File

@ -33,11 +33,11 @@ public :
public : public :
OAuth2( OAuth2(
std::auto_ptr<http::Agent>& agent, http::Agent* agent,
const std::string& client_id, const std::string& client_id,
const std::string& client_secret ) ; const std::string& client_secret ) ;
OAuth2( OAuth2(
std::auto_ptr<http::Agent>& agent, http::Agent* agent,
const std::string& refresh_code, const std::string& refresh_code,
const std::string& client_id, const std::string& client_id,
const std::string& client_secret ) ; const std::string& client_secret ) ;
@ -58,7 +58,7 @@ public :
private : private :
std::string m_access ; std::string m_access ;
std::string m_refresh ; std::string m_refresh ;
std::auto_ptr<http::Agent> m_agent ; http::Agent* m_agent ;
const std::string m_client_id ; const std::string m_client_id ;
const std::string m_client_secret ; const std::string m_client_secret ;