aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/ns.c
diff options
context:
space:
mode:
authorSven Moritz Hallberg <pesco@khjk.org>2010-06-03 13:00:45 +0200
committerSven Moritz Hallberg <pesco@khjk.org>2010-06-03 13:00:45 +0200
commit814aa52228c7cad1d036c1a6dc5ea03cce61c048 (patch)
tree7db06b9191f00b086f25789a0a040d15cef580cf /protocols/msn/ns.c
parent5f8ab6a9adf09ea7c07f728227bdb6d3953588f1 (diff)
parentf4bcc223fea70de8555bbc4d2caf48e0476c0e13 (diff)
merge in bitlbee 1.2.6
Diffstat (limited to 'protocols/msn/ns.c')
-rw-r--r--protocols/msn/ns.c77
1 files changed, 59 insertions, 18 deletions
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 046fe0af..ca3c38e2 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -34,6 +34,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts );
static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
static void msn_auth_got_passport_token( struct msn_auth_data *mad );
+static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name );
gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
{
@@ -230,25 +231,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
}
else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 )
{
- set_t *s;
-
if( num_parts == 7 )
- {
- http_decode( cmd[4] );
-
- strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
- ic->displayname[sizeof(ic->displayname)-1] = 0;
-
- if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
- {
- g_free( s->value );
- s->value = g_strdup( cmd[4] );
- }
- }
+ msn_ns_got_display_name( ic, cmd[4] );
else
- {
imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
- }
imcb_log( ic, "Authenticated, getting buddy list" );
@@ -421,8 +407,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
}
else if( strcmp( cmd[0], "FLN" ) == 0 )
{
- if( cmd[1] )
- imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
+ 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 )
{
@@ -448,6 +438,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
( st != msn_away_state_list ? OPT_AWAY : 0 ),
st->name, NULL );
+
+ msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
}
else if( strcmp( cmd[0], "RNG" ) == 0 )
{
@@ -552,6 +544,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
imc_logout( ic, allow_reconnect );
return( 0 );
}
+#if 0
+ /* Discard this one completely for now since I don't care about the ack
+ and since MSN servers can apparently screw up the formatting. */
else if( strcmp( cmd[0], "REA" ) == 0 )
{
if( num_parts != 5 )
@@ -582,6 +577,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
imcb_rename_buddy( ic, cmd[3], cmd[4] );
}
}
+#endif
else if( strcmp( cmd[0], "IPG" ) == 0 )
{
imcb_error( ic, "Received IPG command, we don't handle them yet." );
@@ -731,3 +727,48 @@ static void msn_auth_got_passport_token( struct msn_auth_data *mad )
imc_logout( ic, TRUE );
}
}
+
+static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name )
+{
+ set_t *s;
+
+ if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL )
+ return FALSE; /* Shouldn't happen.. */
+
+ http_decode( name );
+
+ if( s->value && strcmp( s->value, name ) == 0 )
+ {
+ return TRUE;
+ /* The names match, nothing to worry about. */
+ }
+ else if( s->value != NULL &&
+ ( strcmp( name, ic->acc->user ) == 0 ||
+ set_getbool( &ic->acc->set, "local_display_name" ) ) )
+ {
+ /* The server thinks our display name is our e-mail address
+ which is probably wrong, or the user *wants* us to do this:
+ Always use the locally set display_name. */
+ return msn_set_display_name( ic, s->value );
+ }
+ else
+ {
+ if( s->value && *s->value )
+ imcb_log( ic, "BitlBee thinks your display name is `%s' but "
+ "the MSN server says it's `%s'. Using the MSN "
+ "server's name. Set local_display_name to true "
+ "to use the local name.", s->value, name );
+
+ if( g_utf8_validate( name, -1, NULL ) )
+ {
+ g_free( s->value );
+ s->value = g_strdup( name );
+ }
+ else
+ {
+ imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
+ }
+
+ return TRUE;
+ }
+}