diff options
| -rw-r--r-- | lib/oauth.c | 11 | ||||
| -rw-r--r-- | lib/oauth.h | 4 | ||||
| -rw-r--r-- | protocols/twitter/twitter.c | 10 | 
3 files changed, 19 insertions, 6 deletions
| diff --git a/lib/oauth.c b/lib/oauth.c index 57dd10f8..14e7797c 100644 --- a/lib/oauth.c +++ b/lib/oauth.c @@ -228,6 +228,7 @@ void oauth_info_free( struct oauth_info *info )  		g_free( info->request_token );  		g_free( info->token );  		g_free( info->token_secret ); +		oauth_params_free( &info->params );  		g_free( info );  	}  } @@ -353,12 +354,9 @@ static void oauth_access_token_done( struct http_request *req )  	if( req->status_code == 200 )  	{ -		GSList *params = NULL; -		 -		oauth_params_parse( ¶ms, req->reply_body ); -		st->token = g_strdup( oauth_params_get( ¶ms, "oauth_token" ) ); -		st->token_secret = g_strdup( oauth_params_get( ¶ms, "oauth_token_secret" ) ); -		oauth_params_free( ¶ms ); +		oauth_params_parse( &st->params, req->reply_body ); +		st->token = g_strdup( oauth_params_get( &st->params, "oauth_token" ) ); +		st->token_secret = g_strdup( oauth_params_get( &st->params, "oauth_token_secret" ) );  	}  	st->stage = OAUTH_ACCESS_TOKEN; @@ -369,6 +367,7 @@ static void oauth_access_token_done( struct http_request *req )  		st->auth_url = NULL;  		g_free( st->request_token );  		st->request_token = NULL; +		oauth_params_free( &st->params );  	}  } diff --git a/lib/oauth.h b/lib/oauth.h index 5dfe0ae5..8270a545 100644 --- a/lib/oauth.h +++ b/lib/oauth.h @@ -51,6 +51,7 @@ struct oauth_info  	char *token;  	char *token_secret; +	GSList *params;  };  struct oauth_service @@ -88,3 +89,6 @@ void oauth_info_free( struct oauth_info *info );  /* Convert to and back from strings, for easier saving. */  char *oauth_to_string( struct oauth_info *oi );  struct oauth_info *oauth_from_string( char *in, const struct oauth_service *sp ); + +/* For reading misc. data. */ +const char *oauth_params_get( GSList **params, const char *key ); diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 286d6c3c..dbe9b984 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -148,6 +148,16 @@ static gboolean twitter_oauth_callback( struct oauth_info *info )  			imc_logout( ic, TRUE );  			return FALSE;  		} +		else +		{ +			const char *sn = oauth_params_get( &info->params, "screen_name" ); +			 +			if( sn != NULL && ic->acc->prpl->handle_cmp( sn, ic->acc->user ) != 0 ) +			{ +				imcb_log( ic, "Warning: You logged in via OAuth as %s " +				          "instead of %s.", sn, ic->acc->user ); +			} +		}  		/* IM mods didn't do this so far and it's ugly but I should  		   be able to get away with it... */ | 
