added catch exception for auth code

pull/40/head
Nestal Wan 2012-06-06 23:21:04 +08:00
parent b6aafd7ccd
commit 856914c4dc
2 changed files with 19 additions and 17 deletions

View File

@ -42,11 +42,13 @@
const std::string client_id = "22314510474.apps.googleusercontent.com" ; const std::string client_id = "22314510474.apps.googleusercontent.com" ;
const std::string client_secret = "bl4ufi89h-9MkFlypcI7R785" ; const std::string client_secret = "bl4ufi89h-9MkFlypcI7R785" ;
using namespace gr ;
// libgcrypt insist this to be done in application, not library // libgcrypt insist this to be done in application, not library
void InitGCrypt() void InitGCrypt()
{ {
if ( !gcry_check_version(GCRYPT_VERSION) ) if ( !gcry_check_version(GCRYPT_VERSION) )
throw gr::Exception() << gr::expt::ErrMsg( "libgcrypt version mismatch" ) ; throw Exception() << expt::ErrMsg( "libgcrypt version mismatch" ) ;
// disable secure memory // disable secure memory
gcry_control(GCRYCTL_DISABLE_SECMEM, 0); gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
@ -55,10 +57,8 @@ void InitGCrypt()
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
} }
int main( int argc, char **argv ) int Main( int argc, char **argv )
{ {
using namespace gr ;
InitGCrypt() ; InitGCrypt() ;
Config config ; Config config ;
@ -155,21 +155,26 @@ int main( int argc, char **argv )
return -1; return -1;
} }
OAuth2 token( refresh_token, client_id, client_secret ) ;
Drive drive( token, options ) ;
drive.Update() ;
drive.SaveState() ;
config.Save() ;
return 0 ;
}
int main( int argc, char **argv )
{
try try
{ {
OAuth2 token( refresh_token, client_id, client_secret ) ; return Main( argc, argv ) ;
Drive drive( token, options ) ;
drive.Update() ;
drive.SaveState() ;
config.Save() ;
} }
catch ( gr::Exception& e ) catch ( Exception& e )
{ {
Log( "exception: %1%", boost::diagnostic_information(e), log::critical ) ; Log( "exception: %1%", boost::diagnostic_information(e), log::critical ) ;
return -1 ; return -1 ;
} }
return 0 ;
} }

View File

@ -138,10 +138,7 @@ void Drive::FromChange( const Entry& entry )
Log( "file \"%1%\" is a google document, ignored", entry.Title(), log::verbose ) ; Log( "file \"%1%\" is a google document, ignored", entry.Title(), log::verbose ) ;
else if ( !entry.ContentSrc().empty() ) else if ( !entry.ContentSrc().empty() )
{
Log( "changed entry: %1% %2%", entry.Filename(), entry.ContentSrc() ) ;
m_state.FromChange( entry ) ; m_state.FromChange( entry ) ;
}
} }
void Drive::SaveState() void Drive::SaveState()