aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/msn/msn.h5
-rw-r--r--protocols/msn/msn_util.c10
-rw-r--r--protocols/msn/ns.c70
-rw-r--r--protocols/msn/sb.c4
4 files changed, 43 insertions, 46 deletions
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index ed6db6f0..7c23f282 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2010 Wilmer van der Gaast and others *
+ * Copyright 2002-2012 Wilmer van der Gaast and others *
\********************************************************************/
/* MSN module */
@@ -252,6 +252,7 @@ gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ );
struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name );
struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id );
int msn_ns_set_display_name( struct im_connection *ic, const char *value );
+const char *msn_normalize_handle( const char *handle );
/* tables.c */
const struct msn_away_state *msn_away_state_by_number( int number );
@@ -262,7 +263,7 @@ const struct msn_status_code *msn_status_by_number( int number );
/* sb.c */
int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3 );;
struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session );
-struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle );
+struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, const char *handle );
struct msn_switchboard *msn_sb_by_chat( struct groupchat *c );
struct msn_switchboard *msn_sb_spare( struct im_connection *ic );
int msn_sb_sendmessage( struct msn_switchboard *sb, char *text );
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index d5a74a47..f2f67eb3 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2010 Wilmer van der Gaast and others *
+ * Copyright 2002-2012 Wilmer van der Gaast and others *
\********************************************************************/
/* MSN module - Miscellaneous utilities */
@@ -536,3 +536,11 @@ int msn_ns_set_display_name( struct im_connection *ic, const char *value )
and won't give proper feedback yet if it doesn't. */
return msn_ns_write( ic, -1, "PRP %d MFN %s\r\n", ++md->trId, fn );
}
+
+const char *msn_normalize_handle( const char *handle )
+{
+ if( strncmp( handle, "1:", 2 ) == 0 )
+ return handle + 2;
+ else
+ return handle;
+}
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index f8f18c80..4f80f490 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -371,9 +371,11 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num
g_free( resp );
return st;
}
- else if( strcmp( cmd[0], "ILN" ) == 0 )
+ else if( strcmp( cmd[0], "ILN" ) == 0 || strcmp( cmd[0], "NLN" ) == 0 )
{
const struct msn_away_state *st;
+ const char *handle;
+ int cap = 0;
if( num_parts < 6 )
{
@@ -381,59 +383,45 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num
imc_logout( ic, TRUE );
return( 0 );
}
+ /* ILN and NLN are more or less the same, except ILN has a trId
+ at the start, and NLN has a capability field at the end.
+ Does ILN still exist BTW? */
+ if( cmd[0][1] == 'I' )
+ cmd ++;
+ else
+ cap = atoi( cmd[4] );
+
+ handle = msn_normalize_handle( cmd[2] );
+ if( strcmp( handle, ic->acc->user ) == 0 )
+ return 1; /* That's me! */
- http_decode( cmd[5] );
- imcb_rename_buddy( ic, cmd[3], cmd[5] );
+ http_decode( cmd[3] );
+ imcb_rename_buddy( ic, handle, cmd[3] );
- st = msn_away_state_by_code( cmd[2] );
+ st = msn_away_state_by_code( cmd[1] );
if( !st )
{
/* FIXME: Warn/Bomb about unknown away state? */
st = msn_away_state_list + 1;
}
- imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
- ( st != msn_away_state_list ? OPT_AWAY : 0 ),
+ imcb_buddy_status( ic, handle, OPT_LOGGED_IN |
+ ( st != msn_away_state_list ? OPT_AWAY : 0 ) |
+ ( cap & 1 ? OPT_MOBILE : 0 ),
st->name, NULL );
+
+ msn_sb_stop_keepalives( msn_sb_by_handle( ic, handle ) );
}
else if( strcmp( cmd[0], "FLN" ) == 0 )
{
+ const char *handle;
+
if( cmd[1] == NULL )
return 1;
- imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
-
- msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE );
- }
- else if( strcmp( cmd[0], "NLN" ) == 0 )
- {
- const struct msn_away_state *st;
- int cap;
-
- if( num_parts < 6 )
- {
- imcb_error( ic, "Syntax error" );
- imc_logout( ic, TRUE );
- return( 0 );
- }
-
- http_decode( cmd[4] );
- cap = atoi( cmd[5] );
- imcb_rename_buddy( ic, cmd[2], cmd[4] );
-
- st = msn_away_state_by_code( cmd[1] );
- if( !st )
- {
- /* FIXME: Warn/Bomb about unknown away state? */
- st = msn_away_state_list + 1;
- }
-
- imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
- ( st != msn_away_state_list ? OPT_AWAY : 0 ) |
- ( cap & 1 ? OPT_MOBILE : 0 ),
- st->name, NULL );
-
- msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
+ handle = msn_normalize_handle( cmd[1] );
+ imcb_buddy_status( ic, handle, 0, NULL, NULL );
+ msn_sb_start_keepalives( msn_sb_by_handle( ic, handle ), TRUE );
}
else if( strcmp( cmd[0], "RNG" ) == 0 )
{
@@ -480,7 +468,7 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num
}
else
{
- sb->who = g_strdup( cmd[5] );
+ sb->who = g_strdup( msn_normalize_handle( cmd[5] ) );
}
}
else if( strcmp( cmd[0], "OUT" ) == 0 )
@@ -706,7 +694,7 @@ static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msgl
( psm = xt_find_node( ubx->children, "PSM" ) ) )
psm_text = psm->text;
- imcb_buddy_status_msg( ic, cmd[1], psm_text );
+ imcb_buddy_status_msg( ic, msn_normalize_handle( cmd[1] ), psm_text );
xt_free_node( ubx );
}
else if( strcmp( cmd[0], "ADL" ) == 0 )
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index c8e97433..a1e07b73 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -1,7 +1,7 @@
/********************************************************************\
* BitlBee -- An IRC to other IM-networks gateway *
* *
- * Copyright 2002-2010 Wilmer van der Gaast and others *
+ * Copyright 2002-2012 Wilmer van der Gaast and others *
\********************************************************************/
/* MSN module - Switchboard server callbacks and utilities */
@@ -121,7 +121,7 @@ struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int
return( sb );
}
-struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle )
+struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, const char *handle )
{
struct msn_data *md = ic->proto_data;
struct msn_switchboard *sb;