diff options
Diffstat (limited to 'protocols/msn')
| -rw-r--r-- | protocols/msn/msn.c | 19 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 1 | ||||
| -rw-r--r-- | protocols/msn/msn_util.c | 65 | ||||
| -rw-r--r-- | protocols/msn/passport.c | 22 | 
4 files changed, 41 insertions, 66 deletions
| diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 01b011c7..46049108 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -365,7 +365,7 @@ static char *msn_set_display_name( set_t *set, char *value )  	account_t *acc = set->data;  	struct gaim_connection *gc = acc->gc;  	struct msn_data *md; -	char buf[1024], *fn, *s; +	char buf[1024], *fn;  	int i;  	/* Double-check. */ @@ -380,22 +380,7 @@ static char *msn_set_display_name( set_t *set, char *value )  		return NULL;  	} -	/* Of course we could use http_encode() here, but when we encode -	   every character, the server is less likely to complain about the -	   chosen name. However, the MSN server doesn't seem to like escaped -	   non-ASCII chars, so we keep those unescaped. */ -	s = fn = g_new0( char, strlen( value ) * 3 + 1 ); -	for( i = 0; value[i]; i ++ ) -		if( value[i] & 128 ) -		{ -			*s = value[i]; -			s ++; -		} -		else -		{ -			g_snprintf( s, 4, "%%%02X", value[i] ); -			s += 3; -		} +	fn = msn_http_encode( value );  	g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );  	msn_write( gc, buf, strlen( buf ) ); diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index dbbb6aa0..b4777d41 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -156,6 +156,7 @@ void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname );  char *msn_findheader( char *text, char *header, int len );  char **msn_linesplit( char *line );  int msn_handler( struct msn_handler_data *h ); +char *msn_http_encode( const char *input );  /* tables.c */  const struct msn_away_state *msn_away_state_by_number( int number ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index c3bd73cc..ff4c148c 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -53,31 +53,15 @@ int msn_logged_in( struct gaim_connection *gc )  int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname_ )  {  	struct msn_data *md = gc->proto_data; -	GSList *l, **lp = NULL;  	char buf[1024], *realname; -	if( strcmp( list, "AL" ) == 0 ) -		lp = &gc->permit; -	else if( strcmp( list, "BL" ) == 0 ) -		lp = &gc->deny; -	 -	if( lp ) -		for( l = *lp; l; l = l->next ) -			if( g_strcasecmp( l->data, who ) == 0 ) -				return( 1 ); -	 -	realname = g_new0( char, strlen( realname_ ) * 3 + 1 ); -	strcpy( realname, realname_ ); -	http_encode( realname ); +	realname = msn_http_encode( realname_ );  	g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname );  	if( msn_write( gc, buf, strlen( buf ) ) )  	{  		g_free( realname ); -		if( lp ) -			*lp = g_slist_append( *lp, g_strdup( who ) ); -		  		return( 1 );  	} @@ -89,32 +73,11 @@ int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char  int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who )  {  	struct msn_data *md = gc->proto_data; -	GSList *l = NULL, **lp = NULL;  	char buf[1024]; -	if( strcmp( list, "AL" ) == 0 ) -		lp = &gc->permit; -	else if( strcmp( list, "BL" ) == 0 ) -		lp = &gc->deny; -	 -	if( lp ) -	{ -		for( l = *lp; l; l = l->next ) -			if( g_strcasecmp( l->data, who ) == 0 ) -				break; -		 -		if( !l ) -			return( 1 ); -	} -	  	g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who );  	if( msn_write( gc, buf, strlen( buf ) ) ) -	{ -		if( lp ) -			*lp = g_slist_remove( *lp, l->data ); -		  		return( 1 ); -	}  	return( 0 );  } @@ -349,3 +312,29 @@ int msn_handler( struct msn_handler_data *h )  	return( 1 );  } + +/* The difference between this function and the normal http_encode() function +   is that this one escapes every 7-bit ASCII character because this is said +   to avoid some lame server-side checks when setting a real-name. Also, +   non-ASCII characters are not escaped because MSN servers don't seem to +   appreciate that! */ +char *msn_http_encode( const char *input ) +{ +	char *ret, *s; +	int i; +	 +	ret = s = g_new0( char, strlen( input ) * 3 + 1 ); +	for( i = 0; input[i]; i ++ ) +		if( input[i] & 128 ) +		{ +			*s = input[i]; +			s ++; +		} +		else +		{ +			g_snprintf( s, 4, "%%%02X", input[i] ); +			s += 3; +		} +	 +	return ret; +} diff --git a/protocols/msn/passport.c b/protocols/msn/passport.c index dd1d9b6f..42b6ea73 100644 --- a/protocols/msn/passport.c +++ b/protocols/msn/passport.c @@ -58,6 +58,7 @@ static int passport_get_id_real( gpointer func, gpointer data, char *header )  	rep = g_new0( struct passport_reply, 1 );  	rep->data = data;  	rep->func = func; +	rep->header = header;  	server = g_strdup( prd_cached );  	dummy = strchr( server, '/' ); @@ -124,10 +125,14 @@ static void passport_get_id_ready( struct http_request *req )  static char *passport_create_header( char *cookie, char *email, char *pwd )  { -	char *buffer = g_new0( char, 2048 ); +	char *buffer;  	char *currenttoken;  	char *email_enc, *pwd_enc; +	currenttoken = strstr( cookie, "lc=" ); +	if( currenttoken == NULL ) +		return NULL; +	  	email_enc = g_new0( char, strlen( email ) * 3 + 1 );  	strcpy( email_enc, email );  	http_encode( email_enc ); @@ -136,20 +141,15 @@ static char *passport_create_header( char *cookie, char *email, char *pwd )  	strcpy( pwd_enc, pwd );  	http_encode( pwd_enc ); -	currenttoken = strstr( cookie, "lc=" ); -	if( currenttoken == NULL ) -		return( NULL ); -	 -	g_snprintf( buffer, 2048, -	            "Authorization: Passport1.4 OrgVerb=GET," -	            "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom," -	            "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc, -	            currenttoken ); +	buffer = g_strdup_printf( "Authorization: Passport1.4 OrgVerb=GET," +	                          "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom," +	                          "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc, +	                          currenttoken );  	g_free( email_enc );  	g_free( pwd_enc ); -	return( buffer ); +	return buffer;  }  static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header ) | 
