Changeset c42e8b9
- Timestamp:
- 2010-04-26T22:40:11Z (15 years ago)
- Branches:
- master
- Children:
- 78a2f1e
- Parents:
- 713d611
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth.c
r713d611 rc42e8b9 302 302 } 303 303 304 st->stage = OAUTH_REQUEST_TOKEN; 304 305 st->func( st ); 305 306 } … … 322 323 323 324 if( req->status_code == 200 ) 324 st->access_token = g_strdup( req->reply_body ); 325 325 { 326 GSList *params; 327 const char *token, *token_secret; 328 329 oauth_params_parse( ¶ms, req->reply_body ); 330 token = oauth_params_get( ¶ms, "oauth_token" ); 331 token_secret = oauth_params_get( ¶ms, "oauth_token_secret" ); 332 st->access_token = g_strdup_printf( 333 "oauth_token=%s&oauth_token_secret=%s", token, token_secret ); 334 oauth_params_free( ¶ms ); 335 } 336 337 st->stage = OAUTH_ACCESS_TOKEN; 326 338 st->func( st ); 327 339 } -
lib/oauth.h
r713d611 rc42e8b9 27 27 typedef void (*oauth_cb)( struct oauth_info * ); 28 28 29 typedef enum 30 { 31 OAUTH_INIT, 32 OAUTH_REQUEST_TOKEN, 33 OAUTH_ACCESS_TOKEN, 34 } oauth_stage_t; 35 29 36 struct oauth_info 30 37 { 38 oauth_stage_t stage; 39 31 40 oauth_cb func; 32 41 void *data; -
protocols/twitter/twitter.c
r713d611 rc42e8b9 70 70 static void twitter_oauth_start( struct im_connection *ic ) 71 71 { 72 imcb_log( ic, "Requesting OAuth request token" ); 73 72 74 oauth_request_token( TWITTER_OAUTH_REQUEST_TOKEN, twitter_oauth_callback, ic ); 73 75 } … … 76 78 { 77 79 struct im_connection *ic = info->data; 78 79 if( info->request_token && info->access_token == NULL ) 80 struct twitter_data *td = ic->proto_data; 81 82 if( info->stage == OAUTH_REQUEST_TOKEN ) 80 83 { 81 84 char name[strlen(ic->acc->user)+9], *msg; 85 86 if( info->request_token == NULL ) 87 { 88 imcb_error( ic, "OAuth error: %s", info->http->status_string ); 89 imc_logout( ic, TRUE ); 90 return; 91 } 92 93 td->oauth_info = info; 82 94 83 95 sprintf( name, "twitter_%s", ic->acc->user ); … … 88 100 g_free( msg ); 89 101 } 102 else if( info->stage == OAUTH_ACCESS_TOKEN ) 103 { 104 if( info->access_token == NULL ) 105 { 106 imcb_error( ic, "OAuth error: %s", info->http->status_string ); 107 imc_logout( ic, TRUE ); 108 return; 109 } 110 111 td->oauth = g_strdup( info->access_token ); 112 113 twitter_main_loop_start( ic ); 114 } 90 115 } 91 116 … … 171 196 static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message, int away ) 172 197 { 198 struct twitter_data *td = ic->proto_data; 199 173 200 if (g_strncasecmp(who, "twitter_", 8) == 0 && 174 201 g_strcasecmp(who + 8, ic->acc->user) == 0) 175 twitter_post_status(ic, message); 202 { 203 if( set_getbool( &ic->acc->set, "oauth" ) && td->oauth == NULL ) 204 oauth_access_token( TWITTER_OAUTH_ACCESS_TOKEN, message, td->oauth_info ); 205 else 206 twitter_post_status(ic, message); 207 } 176 208 else 209 { 177 210 twitter_direct_messages_new(ic, who, message); 178 211 } 179 212 return( 0 ); 180 213 } -
protocols/twitter/twitter.h
r713d611 rc42e8b9 38 38 char* pass; 39 39 char* oauth; 40 struct oauth_info *oauth_info; 40 41 guint64 home_timeline_id; 41 42 gint main_loop_id;
Note: See TracChangeset
for help on using the changeset viewer.