diff -rU3 protocols/msn/msn.c ../bitlbee-20050410/protocols/msn/msn.c --- protocols/msn/msn.c 2005-02-24 03:31:49.000000000 +1000 +++ ../bitlbee-20050410/protocols/msn/msn.c 2005-04-20 09:47:39.046029128 +1000 @@ -186,31 +186,19 @@ return( "" ); } -static void msn_set_away( struct gaim_connection *gc, char *state, char *message ) -{ - char buf[1024]; - struct msn_data *md = gc->proto_data; - struct msn_away_state *st; - - if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) - st = msn_away_state_by_name( "Away" ); - else - st = msn_away_state_by_name( state ); - - if( !st ) st = msn_away_state_list; - md->away_state = st; - - g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); - msn_write( gc, buf, strlen( buf ) ); -} - static void msn_set_info( struct gaim_connection *gc, char *info ) { int i; char buf[1024], *fn, *s; struct msn_data *md = gc->proto_data; - if( strlen( info ) > 129 ) + /* Include the away message in nick like Messenger Plus!. */ + if( gc->away ) + g_snprintf( buf, sizeof(buf), "%s\302\240{%s}", info, gc->away ); + else + strncpy( buf, info, sizeof( buf ) ); + + if( strlen( buf ) > 129 ) { do_error_dialog( gc, "Maximum name length exceeded", "MSN" ); return; @@ -220,16 +208,16 @@ 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 = fn = g_new0( char, strlen( buf ) * 3 + 1 ); + for( i = 0; buf[i]; i ++ ) + if( buf[i] & 128 ) { - *s = info[i]; + *s = buf[i]; s ++; } else { - g_snprintf( s, 4, "%%%02X", info[i] ); + g_snprintf( s, 4, "%%%02X", buf[i] ); s += 3; } @@ -244,6 +232,34 @@ serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); } +static void msn_set_away( struct gaim_connection *gc, char *state, char *message ) +{ + char buf[1024]; + struct msn_data *md = gc->proto_data; + struct msn_away_state *st; + + if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) + st = msn_away_state_by_name( "Away" ); + else + st = msn_away_state_by_name( state ); + + if( !st ) + { + st = msn_away_state_list; + g_free(gc->away); + gc->away = NULL; + } + else + gc->away = g_strndup( message, 126 ); + md->away_state = st; + + /* Let msn_set_info handle the Messenger Plus! nick change. */ + msn_set_info( gc, gc->displayname ); + + g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); + msn_write( gc, buf, strlen( buf ) ); +} + static void msn_add_buddy( struct gaim_connection *gc, char *who ) { msn_buddy_list_add( gc, "FL", who, who ); diff -rU3 protocols/msn/msn_util.c ../bitlbee-20050410/protocols/msn/msn_util.c --- protocols/msn/msn_util.c 2004-05-04 06:02:52.000000000 +1000 +++ ../bitlbee-20050410/protocols/msn/msn_util.c 2005-04-20 09:47:39.051028368 +1000 @@ -54,6 +54,8 @@ execute this code if we're not away. */ if( md->away_state == msn_away_state_list ) { + /* Clear the away message. */ + proto_away( gc, NULL ); g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); return( msn_write( gc, buf, strlen( buf ) ) ); } diff -rU3 protocols/msn/ns.c ../bitlbee-20050410/protocols/msn/ns.c --- protocols/msn/ns.c 2005-02-24 03:28:41.000000000 +1000 +++ ../bitlbee-20050410/protocols/msn/ns.c 2005-04-20 09:47:39.061026848 +1000 @@ -96,6 +96,7 @@ struct gaim_connection *gc = data; struct msn_data *md = gc->proto_data; char buf[1024]; + char *cp; if( !num_parts ) { @@ -220,6 +221,9 @@ strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); gc->displayname[sizeof(gc->displayname)-1] = 0; + /* Strip away message, if any. */ + cp = strstr( gc->displayname, "\302\240{" ); + if( cp ) *cp = 0; set_login_progress( gc, 1, "Authenticated, getting buddy list" ); @@ -515,6 +519,9 @@ http_decode( cmd[4] ); strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); gc->displayname[sizeof(gc->displayname)-1] = 0; + /* Strip away message, if any. */ + cp = strstr( gc->displayname, "\302\240{" ); + if( cp ) *cp = 0; } else {