From 2811940d678bd9340055e08a0462c21e710d5714 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 27 Jul 2006 16:55:53 +0200 Subject: Copy-paste considered harmful + Fixed double handling of gc->permit/deny which actually broke the block/allow commands. --- protocols/msn/msn_util.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'protocols') diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index c3bd73cc..4e748099 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -53,19 +53,8 @@ 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 ); @@ -75,9 +64,6 @@ int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char { g_free( realname ); - if( lp ) - *lp = g_slist_append( *lp, g_strdup( who ) ); - return( 1 ); } @@ -89,32 +75,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 ); } -- cgit v1.2.3 From a36b030d747a39fed8224e6350d56d55b2aec4e2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 27 Jul 2006 21:18:33 +0200 Subject: The Yahoo! module now properly sets away states instead of away messages. (So other BitlBees can read your Yahoo! away states better and others can see the proper icons again.) --- protocols/yahoo/yahoo.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'protocols') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 79c0febb..28735432 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 ) -- cgit v1.2.3 From 54794b8e01b5cce0675e9cfbd7282d011ebcb99e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 25 Aug 2006 14:34:36 +0200 Subject: Added msn_http_encode() so it can be used in msn_buddy_list_add() too. Most likely fixes #198. --- protocols/msn/msn.c | 20 ++------------------ protocols/msn/msn.h | 1 + protocols/msn/msn_util.c | 30 +++++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 21 deletions(-) (limited to 'protocols') diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index a8d85a66..0d2d7283 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -211,8 +211,7 @@ static void msn_set_away( struct gaim_connection *gc, char *state, char *message static void msn_set_info( struct gaim_connection *gc, char *info ) { - int i; - char buf[1024], *fn, *s; + char buf[1024], *fn; struct msn_data *md = gc->proto_data; if( strlen( info ) > 129 ) @@ -221,22 +220,7 @@ static void msn_set_info( struct gaim_connection *gc, char *info ) return; } - /* 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( info ) * 3 + 1 ); - for( i = 0; info[i]; i ++ ) - if( info[i] & 128 ) - { - *s = info[i]; - s ++; - } - else - { - g_snprintf( s, 4, "%%%02X", info[i] ); - s += 3; - } + fn = msn_http_encode( info ); 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 4e748099..ff4c148c 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -55,9 +55,7 @@ int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char struct msn_data *md = gc->proto_data; char buf[1024], *realname; - 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 ) ) ) @@ -314,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; +} -- cgit v1.2.3 From 695e39232324711816f1db8e25fdba59a0c6456f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 13 Oct 2006 23:44:54 +0200 Subject: Fixed some memory leaking in the MSN Passport code. --- protocols/msn/passport.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'protocols') 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 ) -- cgit v1.2.3