aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-15 11:34:02 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-15 11:34:02 +0200
commit93b7bd4373c7c020f37fb96b547b5eda99daf547 (patch)
treededa2d1081455b832d6f3354d927544fde39e1c8
parent7e83adca0e875710627588bf28ddb60fb61bd43b (diff)
parente97827bee83d3a0663aa284e72a4f6c84b4b4dfe (diff)
Merging from devel and storage-xml.
-rw-r--r--lib/rc4.c20
-rw-r--r--protocols/msn/msn.c19
-rw-r--r--protocols/msn/msn.h1
-rw-r--r--protocols/msn/msn_util.c65
-rw-r--r--protocols/msn/passport.c22
-rw-r--r--protocols/yahoo/yahoo.c14
-rw-r--r--root_commands.c4
7 files changed, 61 insertions, 84 deletions
diff --git a/lib/rc4.c b/lib/rc4.c
index 6223077a..f2c76f54 100644
--- a/lib/rc4.c
+++ b/lib/rc4.c
@@ -5,19 +5,19 @@
* *
* Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> *
* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
+* This library is free software; you can redistribute it and/or *
+* modify it under the terms of the GNU Lesser General Public *
+* License as published by the Free Software Foundation, version *
+* 2.1. *
* *
-* This program is distributed in the hope that it will be useful, *
+* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-* GNU General Public License for more details. *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+* Lesser General Public License for more details. *
* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, write to the Free Software Foundation, Inc., *
-* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this library; if not, write to the Free Software Foundation, *
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
* *
\***************************************************************************/
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index d36d861f..8c53e620 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -366,7 +366,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. */
@@ -381,22 +381,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 3097dc81..e0cd15b9 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -572,7 +572,7 @@ static void cmd_remove( irc_t *irc, char **cmd )
u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL );
user_del( irc, cmd[1] );
- nick_del( u->gc->acc, u->handle );
+ nick_del( u->gc->acc, s );
irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] );
g_free( s );
@@ -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)" );