diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-15 11:31:13 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-15 11:31:13 +0200 | 
| commit | e97827bee83d3a0663aa284e72a4f6c84b4b4dfe (patch) | |
| tree | 38fcda3162027d741598536c28a2c0cd4c3f52c6 | |
| parent | 3ef6410bab141e5c6ea465730a37289991c38f9f (diff) | |
| parent | 695e39232324711816f1db8e25fdba59a0c6456f (diff) | |
Merging from devel.
| -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 | ||||
| -rw-r--r-- | protocols/yahoo/yahoo.c | 14 | ||||
| -rw-r--r-- | root_commands.c | 2 | 
6 files changed, 50 insertions, 73 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 ) diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 23c6f813..6f286196 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -191,13 +191,18 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg  	gc->away = NULL; -	if( msg ) +	if( state && msg && g_strcasecmp( state, msg ) != 0 )  	{  		yd->current_status = YAHOO_STATUS_CUSTOM;  		gc->away = "";  	} -	if( state ) +	else if( state )  	{ +		/* Set msg to NULL since (if it isn't NULL already) it's equal +		   to state. msg must be empty if we want to use an existing +		   away state. */ +		msg = NULL; +		  		gc->away = "";  		if( g_strcasecmp( state, "Available" ) == 0 )  		{ @@ -234,10 +239,7 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg  	else  		yd->current_status = YAHOO_STATUS_AVAILABLE; -	if( yd->current_status == YAHOO_STATUS_INVISIBLE ) -		yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL ); -	else -		yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); +	yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );  }  static GList *byahoo_away_states( struct gaim_connection *gc ) diff --git a/root_commands.c b/root_commands.c index 64dc71b9..e0cd15b9 100644 --- a/root_commands.c +++ b/root_commands.c @@ -655,7 +655,7 @@ static void cmd_allow( irc_t *irc, char **cmd )  			format = "%-32.32s  %-16.16s";  		irc_usermsg( irc, format, "Handle", "Nickname" ); -		for( l = a->gc->deny; l; l = l->next ) +		for( l = a->gc->permit; l; l = l->next )  		{  			user_t *u = user_findhandle( a->gc, l->data );  			irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); | 
