Changeset 713d611
- Timestamp:
- 2010-04-26T21:50:48Z (15 years ago)
- Branches:
- master
- Children:
- c42e8b9
- Parents:
- acba168
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth.c
racba168 r713d611 298 298 st->auth_params = g_strdup( req->reply_body ); 299 299 oauth_params_parse( ¶ms, st->auth_params ); 300 st-> token = g_strdup( oauth_params_get( ¶ms, "oauth_token" ) );300 st->request_token = g_strdup( oauth_params_get( ¶ms, "oauth_token" ) ); 301 301 oauth_params_free( ¶ms ); 302 302 } 303 303 304 //st->func( st );304 st->func( st ); 305 305 } 306 306 … … 311 311 GSList *params = NULL; 312 312 313 oauth_params_add( ¶ms, "oauth_token", st-> token );313 oauth_params_add( ¶ms, "oauth_token", st->request_token ); 314 314 oauth_params_add( ¶ms, "oauth_verifier", pin ); 315 315 … … 324 324 st->access_token = g_strdup( req->reply_body ); 325 325 326 //st->func( st );326 st->func( st ); 327 327 } 328 328 -
lib/oauth.h
racba168 r713d611 35 35 36 36 char *auth_params; 37 char * token;37 char *request_token; 38 38 39 39 char *access_token; -
protocols/twitter/twitter.c
racba168 r713d611 23 23 24 24 #include "nogaim.h" 25 #include "oauth.h" 25 26 #include "twitter.h" 26 27 #include "twitter_http.h" … … 49 50 // If we are still logged in run this function again after timeout. 50 51 return (ic->flags & OPT_LOGGED_IN) == OPT_LOGGED_IN; 52 } 53 54 static void twitter_main_loop_start( struct im_connection *ic ) 55 { 56 struct twitter_data *td = ic->proto_data; 57 58 imcb_log( ic, "Connecting to Twitter" ); 59 60 // Run this once. After this queue the main loop function. 61 twitter_main_loop(ic, -1, 0); 62 63 // Queue the main_loop 64 // Save the return value, so we can remove the timeout on logout. 65 td->main_loop_id = b_timeout_add(60000, twitter_main_loop, ic); 66 } 67 68 static void twitter_oauth_callback( struct oauth_info *info ); 69 70 static void twitter_oauth_start( struct im_connection *ic ) 71 { 72 oauth_request_token( TWITTER_OAUTH_REQUEST_TOKEN, twitter_oauth_callback, ic ); 73 } 74 75 static void twitter_oauth_callback( struct oauth_info *info ) 76 { 77 struct im_connection *ic = info->data; 78 79 if( info->request_token && info->access_token == NULL ) 80 { 81 char name[strlen(ic->acc->user)+9], *msg; 82 83 sprintf( name, "twitter_%s", ic->acc->user ); 84 msg = g_strdup_printf( "To finish OAuth authentication, please visit " 85 "%s?%s and respond with the resulting PIN code.", 86 TWITTER_OAUTH_AUTHORIZE, info->auth_params ); 87 imcb_buddy_msg( ic, name, msg, 0, 0 ); 88 g_free( msg ); 89 } 51 90 } 52 91 … … 67 106 s = set_add( &acc->set, "mode", "one", set_eval_mode, acc ); 68 107 s->flags |= ACC_SET_OFFLINE_ONLY; 108 109 s = set_add( &acc->set, "oauth", "true", set_eval_bool, acc ); 69 110 } 70 111 … … 80 121 81 122 twitter_connections = g_slist_append( twitter_connections, ic ); 82 123 ic->proto_data = td; 124 83 125 td->user = acc->user; 84 if( strstr( acc->pass, "oauth_token=" ) == NULL)126 if( !set_getbool( &acc->set, "oauth" ) ) 85 127 td->pass = g_strdup( acc->pass ); 86 else 128 else if( strstr( acc->pass, "oauth_token=" ) ) 87 129 td->oauth = g_strdup( acc->pass ); 88 130 td->home_timeline_id = 0; 89 90 ic->proto_data = td;91 92 imcb_log( ic, "Connecting to Twitter" );93 94 // Run this once. After this queue the main loop function.95 twitter_main_loop(ic, -1, 0);96 97 // Queue the main_loop98 // Save the return value, so we can remove the timeout on logout.99 td->main_loop_id = b_timeout_add(60000, twitter_main_loop, ic);100 131 101 132 sprintf( name, "twitter_%s", acc->user ); 102 133 imcb_add_buddy( ic, name, NULL ); 103 134 imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); 135 136 if( td->pass || td->oauth ) 137 twitter_main_loop_start( ic ); 138 else 139 twitter_oauth_start( ic ); 104 140 } 105 141 -
protocols/twitter/twitter.h
racba168 r713d611 51 51 GSList *twitter_connections; 52 52 53 #define TWITTER_OAUTH_REQUEST_TOKEN "http://api.twitter.com/oauth/request_token" 54 #define TWITTER_OAUTH_ACCESS_TOKEN "http://api.twitter.com/oauth/access_token" 55 #define TWITTER_OAUTH_AUTHORIZE "http://api.twitter.com/oauth/authorize" 56 53 57 #endif //_TWITTER_H
Note: See TracChangeset
for help on using the changeset viewer.