From e5a8118236442d51eb202a8bdebe5866449554e4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 20 Mar 2010 17:27:23 +0000 Subject: Added soap.c with a fairly reusable SOAP framework and simple code for sending offline messages. It works somewhat, just that Pidgin shows the messages as empty. :-( --- protocols/msn/ns.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index d78d753a..f9c8ab29 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -736,6 +736,8 @@ static void msn_auth_got_passport_token( struct msn_auth_data *mad ) { char buf[1024]; + md->passport_token = g_strdup( mad->token ); + g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, mad->token ); msn_write( ic, buf, strlen( buf ) ); } -- cgit v1.2.3 From 5fecede7db56a41cf9d6ecb2b821f5a833ce0f59 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 8 Aug 2010 18:29:43 +0100 Subject: Enough changes to successfully login up to (but not including) fetching the contact list. --- protocols/msn/ns.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 40c4cdec..897650a6 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -72,7 +72,7 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) md->handler->fd = md->fd; md->handler->rxq = g_new0( char, 1 ); - g_snprintf( s, sizeof( s ), "VER %d MSNP8 CVR0\r\n", ++md->trId ); + g_snprintf( s, sizeof( s ), "VER %d MSNP14 CVR0\r\n", ++md->trId ); if( msn_write( ic, s, strlen( s ) ) ) { ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); @@ -112,7 +112,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[0], "VER" ) == 0 ) { - if( cmd[2] && strncmp( cmd[2], "MSNP8", 5 ) != 0 ) + if( cmd[2] && strncmp( cmd[2], "MSNP14", 5 ) != 0 ) { imcb_error( ic, "Unsupported protocol" ); imc_logout( ic, FALSE ); @@ -229,7 +229,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } - else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) + else if( strcmp( cmd[2], "OK" ) == 0 ) { if( num_parts == 7 ) msn_ns_got_display_name( ic, cmd[4] ); @@ -655,6 +655,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } } } + else if( strcmp( cmd[0], "GCF" ) == 0 ) + { + /* Coming up is cmd[2] bytes of stuff we're supposed to + censore. Meh. */ + md->handler->msglen = atoi( cmd[2] ); + } else if( isdigit( cmd[0][0] ) ) { int num = atoi( cmd[0] ); -- cgit v1.2.3 From 7db65b7df08a3c7cab28e065b2ffa3d9941ceccb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 9 Aug 2010 20:04:55 +0100 Subject: Not working yet, but some code for fetching the membership list. Apparently an upgrade to MSNP15 is needed. Oh well. --- protocols/msn/ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 897650a6..8236b731 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -28,6 +28,7 @@ #include "msn.h" #include "passport.h" #include "md5.h" +#include "soap.h" static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ); static int msn_ns_command( gpointer data, char **cmd, int num_parts ); @@ -238,8 +239,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) imcb_log( ic, "Authenticated, getting buddy list" ); - g_snprintf( buf, sizeof( buf ), "SYN %d 0\r\n", ++md->trId ); - return( msn_write( ic, buf, strlen( buf ) ) ); + msn_soap_memlist_request( ic ); } else { -- cgit v1.2.3 From 523fb2324a351e9607ad2a803c6e866c5175aa16 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 11 Aug 2010 09:08:39 +0100 Subject: Implement MSNP15 SSO (Sadistic Sign-On). --- protocols/msn/ns.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 8236b731..f0d6a58d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -34,7 +34,6 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c 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 ) @@ -73,7 +72,7 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) md->handler->fd = md->fd; md->handler->rxq = g_new0( char, 1 ); - g_snprintf( s, sizeof( s ), "VER %d MSNP14 CVR0\r\n", ++md->trId ); + g_snprintf( s, sizeof( s ), "VER %d MSNP15 CVR0\r\n", ++md->trId ); if( msn_write( ic, s, strlen( s ) ) ) { ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); @@ -113,7 +112,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[0], "VER" ) == 0 ) { - if( cmd[2] && strncmp( cmd[2], "MSNP14", 5 ) != 0 ) + if( cmd[2] && strncmp( cmd[2], "MSNP15", 5 ) != 0 ) { imcb_error( ic, "Unsupported protocol" ); imc_logout( ic, FALSE ); @@ -127,7 +126,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "CVR" ) == 0 ) { /* We don't give a damn about the information we just received */ - g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, ic->acc->user ); + g_snprintf( buf, sizeof( buf ), "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); return( msn_write( ic, buf, strlen( buf ) ) ); } else if( strcmp( cmd[0], "XFR" ) == 0 ) @@ -220,15 +219,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "USR" ) == 0 ) { - if( num_parts == 5 && strcmp( cmd[2], "TWN" ) == 0 && strcmp( cmd[3], "S" ) == 0 ) + if( num_parts >= 6 && strcmp( cmd[2], "SSO" ) == 0 && + strcmp( cmd[3], "S" ) == 0 ) { - /* Time for some Passport black magic... */ - if( !passport_get_token( msn_auth_got_passport_token, ic, ic->acc->user, ic->acc->pass, cmd[4] ) ) - { - imcb_error( ic, "Error while contacting Passport server" ); - imc_logout( ic, TRUE ); - return( 0 ); - } + msn_soap_passport_sso_request( ic, cmd[4], cmd[5] ); } else if( strcmp( cmd[2], "OK" ) == 0 ) { @@ -774,9 +768,8 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int return( 1 ); } -static void msn_auth_got_passport_token( struct msn_auth_data *mad ) +void msn_auth_got_passport_token( struct im_connection *ic, char *token ) { - struct im_connection *ic = mad->data; struct msn_data *md; /* Dead connection? */ @@ -784,20 +777,13 @@ static void msn_auth_got_passport_token( struct msn_auth_data *mad ) return; md = ic->proto_data; - if( mad->token ) + { char buf[1024]; - md->passport_token = g_strdup( mad->token ); - - g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, mad->token ); + g_snprintf( buf, sizeof( buf ), "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); msn_write( ic, buf, strlen( buf ) ); } - else - { - imcb_error( ic, "Error during Passport authentication: %s", mad->error ); - imc_logout( ic, TRUE ); - } } static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) -- cgit v1.2.3 From ca7de3ac72f0ef10613badecb7eb6cc9a10f996b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 12 Aug 2010 23:13:26 +0100 Subject: Successful login (including contact list sync). \o/ --- protocols/msn/ns.c | 200 ++++++++++++++++++++++++++--------------------------- 1 file changed, 100 insertions(+), 100 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index f0d6a58d..ffb21c47 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -26,15 +26,16 @@ #include #include "nogaim.h" #include "msn.h" -#include "passport.h" #include "md5.h" #include "soap.h" +#include "xmltree.h" static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ); 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 gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); +static void msn_ns_send_adl( struct im_connection *ic ); gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) { @@ -134,7 +135,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) char *server; int port; - if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 ) + if( num_parts >= 6 && strcmp( cmd[2], "NS" ) == 0 ) { b_event_remove( ic->inpa ); ic->inpa = 0; @@ -155,7 +156,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) md->fd = proxy_connect( server, port, msn_ns_connected, ic ); } - else if( num_parts == 6 && strcmp( cmd[2], "SB" ) == 0 ) + else if( num_parts >= 6 && strcmp( cmd[2], "SB" ) == 0 ) { struct msn_switchboard *sb; @@ -260,109 +261,34 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } - else if( strcmp( cmd[0], "SYN" ) == 0 ) + else if( strcmp( cmd[0], "BLP" ) == 0 ) { - if( num_parts == 5 ) - { - int i, groupcount; - - groupcount = atoi( cmd[4] ); - if( groupcount > 0 ) - { - /* valgrind says this is leaking memory, I'm guessing - that this happens during server redirects. */ - if( md->grouplist ) - { - for( i = 0; i < md->groupcount; i ++ ) - g_free( md->grouplist[i] ); - g_free( md->grouplist ); - } - - md->groupcount = groupcount; - md->grouplist = g_new0( char *, md->groupcount ); - } - - md->buddycount = atoi( cmd[3] ); - if( !*cmd[3] || md->buddycount == 0 ) - msn_logged_in( ic ); - } - else - { - /* Hrrm... This SYN reply doesn't really look like something we expected. - Let's assume everything is okay. */ - - msn_logged_in( ic ); - } + msn_ns_send_adl( ic ); } - else if( strcmp( cmd[0], "LST" ) == 0 ) + else if( strcmp( cmd[0], "ADL" ) == 0 ) { - int list; - - if( num_parts != 4 && num_parts != 5 ) - { - imcb_error( ic, "Syntax error" ); - imc_logout( ic, TRUE ); - return( 0 ); - } - - http_decode( cmd[2] ); - list = atoi( cmd[3] ); - - if( list & 1 ) /* FL */ + if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) { - char *group = NULL; - int num; + char buf[1024]; + char *fn_raw = set_getstr( &ic->acc->set, "display_name" ); + char *fn; - if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 && num < md->groupcount ) - group = md->grouplist[num]; + if( fn_raw == NULL ) + fn_raw = ic->acc->user; + fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); + strcpy( fn, fn_raw ); + http_encode( fn ); - imcb_add_buddy( ic, cmd[1], group ); - imcb_rename_buddy( ic, cmd[1], cmd[2] ); - } - if( list & 2 ) /* AL */ - { - ic->permit = g_slist_append( ic->permit, g_strdup( cmd[1] ) ); - } - if( list & 4 ) /* BL */ - { - ic->deny = g_slist_append( ic->deny, g_strdup( cmd[1] ) ); - } - if( list & 8 ) /* RL */ - { - if( ( list & 6 ) == 0 ) - msn_buddy_ask( ic, cmd[1], cmd[2] ); - } - - if( --md->buddycount == 0 ) - { - if( ic->flags & OPT_LOGGED_IN ) - { - imcb_log( ic, "Successfully transferred to different server" ); - g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); - return( msn_write( ic, buf, strlen( buf ) ) ); - } - else - { - msn_logged_in( ic ); - } + g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", + ++md->trId, fn ); + g_free( fn ); + + msn_write( ic, buf, strlen( buf ) ); } } - else if( strcmp( cmd[0], "LSG" ) == 0 ) + else if( strcmp( cmd[0], "PRP" ) == 0 ) { - int num; - - if( num_parts != 4 ) - { - imcb_error( ic, "Syntax error" ); - imc_logout( ic, TRUE ); - return( 0 ); - } - - http_decode( cmd[2] ); - num = atoi( cmd[1] ); - - if( num < md->groupcount ) - md->grouplist[num] = g_strdup( cmd[2] ); + imcb_connected( ic ); } else if( strcmp( cmd[0], "CHL" ) == 0 ) { @@ -392,15 +318,15 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { const struct msn_away_state *st; - if( num_parts != 6 ) + if( num_parts < 6 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); return( 0 ); } - http_decode( cmd[4] ); - imcb_rename_buddy( ic, cmd[3], cmd[4] ); + http_decode( cmd[5] ); + imcb_rename_buddy( ic, cmd[3], cmd[5] ); st = msn_away_state_by_code( cmd[2] ); if( !st ) @@ -786,6 +712,80 @@ void msn_auth_got_passport_token( struct im_connection *ic, char *token ) } } +void msn_auth_got_contact_list( struct im_connection *ic ) +{ + char buf[64]; + struct msn_data *md; + + /* Dead connection? */ + if( g_slist_find( msn_connections, ic ) == NULL ) + return; + + md = ic->proto_data; + + + g_snprintf( buf, sizeof( buf ), "BLP %d %s\r\n", ++md->trId, "BL" ); + msn_write( ic, buf, strlen( buf ) ); +} + +static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) +{ + struct xt_node *adl = data, *d, *c; + struct bee_user *bu = value; + struct msn_buddy_data *bd = bu->data; + char handle[strlen(bu->handle)]; + char *domain; + char l[4]; + + strcpy( handle, bu->handle ); + if( ( domain = strchr( handle, '@' ) ) == NULL ) /* WTF */ + return FALSE; + *domain = '\0'; + domain ++; + + if( ( d = adl->children ) == NULL || + g_strcasecmp( xt_find_attr( d, "n" ), domain ) != 0 ) + { + d = xt_new_node( "d", NULL, NULL ); + xt_add_attr( d, "n", domain ); + xt_insert_child( adl, d ); + } + + g_snprintf( l, sizeof( l ), "%d", bd->flags & 7 ); + c = xt_new_node( "c", NULL, NULL ); + xt_add_attr( c, "n", handle ); + xt_add_attr( c, "l", l ); + xt_add_attr( c, "t", "1" ); /* 1 means normal, 4 means mobile? */ + xt_insert_child( d, c ); + + return FALSE; +} + +static void msn_ns_send_adl( struct im_connection *ic ) +{ + struct xt_node *adl; + struct msn_data *md; + char *adls, buf[64]; + + /* Dead connection? */ + if( g_slist_find( msn_connections, ic ) == NULL ) + return; + + md = ic->proto_data; + + adl = xt_new_node( "ml", NULL, NULL ); + xt_add_attr( adl, "l", "1" ); + g_tree_foreach( md->domaintree, msn_ns_send_adl_1, adl ); + adls = xt_to_string( adl ); + + g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); + if( msn_write( ic, buf, strlen( buf ) ) ) + msn_write( ic, adls, strlen( adls ) ); + + g_free( adls ); + xt_free_node( adl ); +} + static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) { set_t *s; -- cgit v1.2.3 From be7a180689ba5dc2b1cd1dc14f55c59246e238ed Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 12 Aug 2010 23:38:30 +0100 Subject: Proper responses to CHL challenges. Clean up bee_users before calling prpl->logout() since the buddy_data functions would like some structs to still exist. --- protocols/msn/ns.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index ffb21c47..3e02e328 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -292,25 +292,20 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "CHL" ) == 0 ) { - md5_state_t state; - md5_byte_t digest[16]; - int i; + char *resp; - if( num_parts != 3 ) + if( num_parts < 3 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); return( 0 ); } - md5_init( &state ); - md5_append( &state, (const md5_byte_t *) cmd[2], strlen( cmd[2] ) ); - md5_append( &state, (const md5_byte_t *) QRY_CODE, strlen( QRY_CODE ) ); - md5_finish( &state, digest ); - - g_snprintf( buf, sizeof( buf ), "QRY %d %s %d\r\n", ++md->trId, QRY_NAME, 32 ); - for( i = 0; i < 16; i ++ ) - g_snprintf( buf + strlen( buf ), 3, "%02x", digest[i] ); + resp = msn_p11_challenge( cmd[2] ); + g_snprintf( buf, sizeof( buf ), "QRY %d %s %zd\r\n%s", + ++md->trId, MSNP11_PROD_ID, + strlen( resp ), resp ); + g_free( resp ); return( msn_write( ic, buf, strlen( buf ) ) ); } @@ -581,6 +576,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) censore. Meh. */ md->handler->msglen = atoi( cmd[2] ); } + else if( strcmp( cmd[0], "UBX" ) == 0 ) + { + /* Status message. Parser coming soon. */ + if( num_parts >= 4 ) + md->handler->msglen = atoi( cmd[3] ); + } else if( isdigit( cmd[0][0] ) ) { int num = atoi( cmd[0] ); -- cgit v1.2.3 From b46769d05371e501800a4658a0faf82c4ccdb0dd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 12 Aug 2010 23:44:56 +0100 Subject: Some syntax checking fixups; don't make the same mistake of failing just if the MSN server is sending a little bit *more* info. And adding xt_insert_node() used in the ADL generation code. --- protocols/msn/ns.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 3e02e328..2d40b47b 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -227,13 +227,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[2], "OK" ) == 0 ) { - if( num_parts == 7 ) - 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" ); - msn_soap_memlist_request( ic ); } else @@ -245,7 +239,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "MSG" ) == 0 ) { - if( num_parts != 4 ) + if( num_parts < 4 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -347,7 +341,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { const struct msn_away_state *st; - if( num_parts != 5 ) + if( num_parts < 5 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -376,7 +370,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) char *server; int session, port; - if( num_parts != 7 ) + if( num_parts < 7 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -420,7 +414,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "ADD" ) == 0 ) { - if( num_parts == 6 && strcmp( cmd[2], "RL" ) == 0 ) + if( num_parts >= 6 && strcmp( cmd[2], "RL" ) == 0 ) { GSList *l; @@ -484,7 +478,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) and since MSN servers can apparently screw up the formatting. */ else if( strcmp( cmd[0], "REA" ) == 0 ) { - if( num_parts != 5 ) + if( num_parts < 5 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); -- cgit v1.2.3 From 91d6e9108bce93925a1bad60613d01c5382d003d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 13 Aug 2010 10:12:31 +0100 Subject: Sending offline messages works now ... but Pidgin doesn't seem to receive them. :-/ --- protocols/msn/ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 2d40b47b..4ae8693d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -73,7 +73,7 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) md->handler->fd = md->fd; md->handler->rxq = g_new0( char, 1 ); - g_snprintf( s, sizeof( s ), "VER %d MSNP15 CVR0\r\n", ++md->trId ); + g_snprintf( s, sizeof( s ), "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ); if( msn_write( ic, s, strlen( s ) ) ) { ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); @@ -113,7 +113,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[0], "VER" ) == 0 ) { - if( cmd[2] && strncmp( cmd[2], "MSNP15", 5 ) != 0 ) + if( cmd[2] && strncmp( cmd[2], MSNP_VER, 5 ) != 0 ) { imcb_error( ic, "Unsupported protocol" ); imc_logout( ic, FALSE ); -- cgit v1.2.3 From 4e4af1b0fe073fd2d43f4ea0d55f8deadbeb974d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 09:48:46 +0100 Subject: Remove some old Passport stuff, this is all in soap.[ch] now. --- protocols/msn/ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 4ae8693d..40f96b21 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2002-2004 Wilmer van der Gaast and others * + * Copyright 2002-2010 Wilmer van der Gaast and others * \********************************************************************/ /* MSN module - Notification server callbacks */ -- cgit v1.2.3 From d93c0eb9f3f5d2d2cd78f02422d0c0ed25743e3a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 13:20:59 +0100 Subject: Read incoming MSN status/away messages. --- protocols/msn/ns.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 40f96b21..0c067b8c 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -576,6 +576,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts >= 4 ) md->handler->msglen = atoi( cmd[3] ); } + else if( strcmp( cmd[0], "NOT" ) == 0 ) + { + /* Some kind of notification, not sure if it still exists + but we have to skip the payload or stuff breaks. */ + if( num_parts >= 3 ) + md->handler->msglen = atoi( cmd[2] ); + } else if( isdigit( cmd[0][0] ) ) { int num = atoi( cmd[0] ); @@ -685,6 +692,19 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int g_free( ct ); } } + else if( strcmp( cmd[0], "UBX" ) == 0 ) + { + struct xt_node *psm; + char *psm_text = NULL; + + psm = xt_from_string( msg ); + if( psm && strcmp( psm->name, "Data" ) == 0 && + ( psm = xt_find_node( psm->children, "PSM" ) ) ) + psm_text = psm->text; + + imcb_buddy_status_msg( ic, cmd[1], psm_text ); + xt_free_node( psm ); + } return( 1 ); } -- cgit v1.2.3 From 4452e69ab1f01793a37205db8227a2de2f211d3e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 14:06:11 +0100 Subject: Allow changing the display_name, now permanently! --- protocols/msn/ns.c | 80 ------------------------------------------------------ 1 file changed, 80 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 0c067b8c..777a6ebd 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -34,7 +34,6 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c 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 gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); static void msn_ns_send_adl( struct im_connection *ic ); gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) @@ -473,40 +472,6 @@ 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 ) - { - imcb_error( ic, "Syntax error" ); - imc_logout( ic, TRUE ); - return( 0 ); - } - - if( g_strcasecmp( cmd[3], ic->acc->user ) == 0 ) - { - set_t *s; - - 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] ); - } - } - else - { - /* This is not supposed to happen, but let's handle it anyway... */ - http_decode( cmd[4] ); - 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." ); @@ -800,48 +765,3 @@ static void msn_ns_send_adl( struct im_connection *ic ) g_free( adls ); xt_free_node( adl ); } - -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; - } -} -- cgit v1.2.3 From 584867592546f43f857645e02169d135f0df25e8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 14:32:46 +0100 Subject: The contact's full name is in a different field now in NLN messages. --- protocols/msn/ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 777a6ebd..a1b88ae1 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -347,8 +347,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } - http_decode( cmd[3] ); - imcb_rename_buddy( ic, cmd[2], cmd[3] ); + http_decode( cmd[4] ); + imcb_rename_buddy( ic, cmd[2], cmd[4] ); st = msn_away_state_by_code( cmd[1] ); if( !st ) -- cgit v1.2.3 From e5854a80111e337be01cf1e506073a231fac1c3d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 15:50:10 +0100 Subject: Show incoming auth. requests (although responding to them currently causes a disconnect). --- protocols/msn/ns.c | 109 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 45 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index a1b88ae1..7518dc25 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -278,6 +278,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) msn_write( ic, buf, strlen( buf ) ); } + else if( num_parts >= 3 ) + { + md->handler->msglen = atoi( cmd[2] ); + } } else if( strcmp( cmd[0], "PRP" ) == 0 ) { @@ -411,46 +415,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) sb->who = g_strdup( cmd[5] ); } } - else if( strcmp( cmd[0], "ADD" ) == 0 ) - { - if( num_parts >= 6 && strcmp( cmd[2], "RL" ) == 0 ) - { - GSList *l; - - http_decode( cmd[5] ); - - if( strchr( cmd[4], '@' ) == NULL ) - { - imcb_error( ic, "Syntax error" ); - imc_logout( ic, TRUE ); - return 0; - } - - /* We got added by someone. If we don't have this - person in permit/deny yet, inform the user. */ - for( l = ic->permit; l; l = l->next ) - if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return 1; - - for( l = ic->deny; l; l = l->next ) - if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return 1; - - msn_buddy_ask( ic, cmd[4], cmd[5] ); - } - else if( num_parts >= 6 && strcmp( cmd[2], "FL" ) == 0 ) - { - const char *group = NULL; - int num; - - if( cmd[6] != NULL && sscanf( cmd[6], "%d", &num ) == 1 && num < md->groupcount ) - group = md->grouplist[num]; - - http_decode( cmd[5] ); - imcb_add_buddy( ic, cmd[4], group ); - imcb_rename_buddy( ic, cmd[4], cmd[5] ); - } - } else if( strcmp( cmd[0], "OUT" ) == 0 ) { int allow_reconnect = TRUE; @@ -485,6 +449,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } +#if 0 else if( strcmp( cmd[0], "ADG" ) == 0 ) { char *group = g_strdup( cmd[3] ); @@ -529,6 +494,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } } } +#endif else if( strcmp( cmd[0], "GCF" ) == 0 ) { /* Coming up is cmd[2] bytes of stuff we're supposed to @@ -537,16 +503,16 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "UBX" ) == 0 ) { - /* Status message. Parser coming soon. */ + /* Status message. */ if( num_parts >= 4 ) md->handler->msglen = atoi( cmd[3] ); } else if( strcmp( cmd[0], "NOT" ) == 0 ) { - /* Some kind of notification, not sure if it still exists - but we have to skip the payload or stuff breaks. */ - if( num_parts >= 3 ) - md->handler->msglen = atoi( cmd[2] ); + /* Some kind of notification, poorly documented but + apparently used to announce address book changes. */ + if( num_parts >= 2 ) + md->handler->msglen = atoi( cmd[1] ); } else if( isdigit( cmd[0][0] ) ) { @@ -670,6 +636,56 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int imcb_buddy_status_msg( ic, cmd[1], psm_text ); xt_free_node( psm ); } + else if( strcmp( cmd[0], "ADL" ) == 0 ) + { + struct xt_node *adl, *d, *c; + + if( !( adl = xt_from_string( msg ) ) ) + return 1; + + for( d = adl->children; d; d = d->next ) + { + char *dn; + if( strcmp( d->name, "d" ) != 0 || + ( dn = xt_find_attr( d, "n" ) ) == NULL ) + continue; + for( c = d->children; c; c = c->next ) + { + bee_user_t *bu; + struct msn_buddy_data *bd; + char *cn, *handle, *f, *l; + int flags; + + if( strcmp( c->name, "c" ) != 0 || + ( l = xt_find_attr( c, "l" ) ) == NULL || + ( cn = xt_find_attr( c, "n" ) ) == NULL ) + continue; + + handle = g_strdup_printf( "%s@%s", cn, dn ); + if( !( ( bu = bee_user_by_handle( ic->bee, ic, handle ) ) || + ( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) ) + { + g_free( handle ); + continue; + } + g_free( handle ); + bd = bu->data; + + if( ( f = xt_find_attr( c, "f" ) ) ) + { + http_decode( f ); + imcb_rename_buddy( ic, bu->handle, f ); + } + + flags = atoi( l ) & 15; + if( bd->flags != flags ) + { + bd->flags = flags; + msn_buddy_ask( bu ); + } + } + } + } return( 1 ); } @@ -717,6 +733,9 @@ static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) char *domain; char l[4]; + if( ( bd->flags & 7 ) == 0 ) + return FALSE; + strcpy( handle, bu->handle ); if( ( domain = strchr( handle, '@' ) ) == NULL ) /* WTF */ return FALSE; -- cgit v1.2.3 From 193dc742d357bb604fff8921417c74ddf9e8729c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 17:16:52 +0100 Subject: Responses to add requests work now. --- protocols/msn/ns.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 7518dc25..23b8f3b1 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -263,10 +263,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) { char buf[1024]; - char *fn_raw = set_getstr( &ic->acc->set, "display_name" ); + char *fn_raw; char *fn; - if( fn_raw == NULL ) + if( ic->flags & OPT_LOGGED_IN ) + return 1; + + if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) fn_raw = ic->acc->user; fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); strcpy( fn, fn_raw ); -- cgit v1.2.3 From d97f51b59a3ac6d9557ebd1e42a45928fe064b4b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 00:23:23 +0100 Subject: Fix issues with logging in with huge SSO tickets (hilariously, the 1024- byte buffer was just one byte too short, resulting in a \r-terminated login line and the server waiting for the \n). Also using xt_find_path(). --- protocols/msn/ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 23b8f3b1..5bf07c3e 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -704,7 +704,7 @@ void msn_auth_got_passport_token( struct im_connection *ic, char *token ) md = ic->proto_data; { - char buf[1024]; + char buf[1536]; g_snprintf( buf, sizeof( buf ), "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); msn_write( ic, buf, strlen( buf ) ); -- cgit v1.2.3 From 5a7af1ba940521a65b3611e5f96ffa9306497e45 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 14:02:52 +0100 Subject: The ADL command doesn't support >150 contacts. Split it up. --- protocols/msn/ns.c | 88 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 28 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 5bf07c3e..a599b0ba 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -34,6 +34,7 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c 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_ns_send_adl_start( struct im_connection *ic ); static void msn_ns_send_adl( struct im_connection *ic ); gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) @@ -256,30 +257,32 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "BLP" ) == 0 ) { - msn_ns_send_adl( ic ); + msn_ns_send_adl_start( ic ); } else if( strcmp( cmd[0], "ADL" ) == 0 ) { if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) { - char buf[1024]; - char *fn_raw; - char *fn; + msn_ns_send_adl( ic ); - if( ic->flags & OPT_LOGGED_IN ) - return 1; - - if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) - fn_raw = ic->acc->user; - fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); - strcpy( fn, fn_raw ); - http_encode( fn ); - - g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", - ++md->trId, fn ); - g_free( fn ); - - msn_write( ic, buf, strlen( buf ) ); + if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) + { + char buf[1024]; + char *fn_raw; + char *fn; + + if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) + fn_raw = ic->acc->user; + fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); + strcpy( fn, fn_raw ); + http_encode( fn ); + + g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", + ++md->trId, fn ); + g_free( fn ); + + msn_write( ic, buf, strlen( buf ) ); + } } else if( num_parts >= 3 ) { @@ -732,11 +735,12 @@ static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) struct xt_node *adl = data, *d, *c; struct bee_user *bu = value; struct msn_buddy_data *bd = bu->data; + struct msn_data *md = bu->ic->proto_data; char handle[strlen(bu->handle)]; char *domain; char l[4]; - if( ( bd->flags & 7 ) == 0 ) + if( ( bd->flags & 7 ) == 0 || ( bd->flags & MSN_BUDDY_ADL_SYNCED ) ) return FALSE; strcpy( handle, bu->handle ); @@ -760,24 +764,27 @@ static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) xt_add_attr( c, "t", "1" ); /* 1 means normal, 4 means mobile? */ xt_insert_child( d, c ); - return FALSE; + /* Do this in batches of 100. */ + bd->flags |= MSN_BUDDY_ADL_SYNCED; + return (--md->adl_todo % 140) == 0; } static void msn_ns_send_adl( struct im_connection *ic ) { struct xt_node *adl; - struct msn_data *md; + struct msn_data *md = ic->proto_data; char *adls, buf[64]; - /* Dead connection? */ - if( g_slist_find( msn_connections, ic ) == NULL ) - return; - - md = ic->proto_data; - adl = xt_new_node( "ml", NULL, NULL ); xt_add_attr( adl, "l", "1" ); g_tree_foreach( md->domaintree, msn_ns_send_adl_1, adl ); + if( adl->children == NULL ) + { + /* This tells the caller that we're done now. */ + md->adl_todo = -1; + xt_free_node( adl ); + return; + } adls = xt_to_string( adl ); g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); @@ -785,5 +792,30 @@ static void msn_ns_send_adl( struct im_connection *ic ) msn_write( ic, adls, strlen( adls ) ); g_free( adls ); - xt_free_node( adl ); +} + +static void msn_ns_send_adl_start( struct im_connection *ic ) +{ + struct msn_data *md; + GSList *l; + + /* Dead connection? */ + if( g_slist_find( msn_connections, ic ) == NULL ) + return; + + md = ic->proto_data; + md->adl_todo = 0; + for( l = ic->bee->users; l; l = l->next ) + { + bee_user_t *bu = l->data; + struct msn_buddy_data *bd = bu->data; + + if( bu->ic != ic || ( bd->flags & 7 ) == 0 ) + continue; + + bd->flags &= ~MSN_BUDDY_ADL_SYNCED; + md->adl_todo++; + } + + msn_ns_send_adl( ic ); } -- cgit v1.2.3 From 660cb00687dbe0abd37e705a2923d1cf8bf6f45c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 14:23:03 +0100 Subject: Parse authentication errors. --- protocols/msn/ns.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index a599b0ba..2449c8d5 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -696,7 +696,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int return( 1 ); } -void msn_auth_got_passport_token( struct im_connection *ic, char *token ) +void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error ) { struct msn_data *md; @@ -706,12 +706,18 @@ void msn_auth_got_passport_token( struct im_connection *ic, char *token ) md = ic->proto_data; + if( token ) { char buf[1536]; g_snprintf( buf, sizeof( buf ), "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); msn_write( ic, buf, strlen( buf ) ); } + else + { + imcb_error( ic, "Error during Passport authentication: %s", error ); + imc_logout( ic, TRUE ); + } } void msn_auth_got_contact_list( struct im_connection *ic ) -- cgit v1.2.3 From e0e15468835d5ae5bce54a28bd7a5b7aea66a1e2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 19:46:10 +0100 Subject: Making display name code a bit saner. Apparently PoS MSN is still suffering from display_name amnesia a little bit though at least with Hotmail accounts. --- protocols/msn/ns.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 2449c8d5..c9b01ef2 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -258,6 +258,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "BLP" ) == 0 ) { msn_ns_send_adl_start( ic ); + + if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) + return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); } else if( strcmp( cmd[0], "ADL" ) == 0 ) { @@ -267,21 +270,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) { - char buf[1024]; - char *fn_raw; - char *fn; - - if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) - fn_raw = ic->acc->user; - fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); - strcpy( fn, fn_raw ); - http_encode( fn ); - - g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", - ++md->trId, fn ); - g_free( fn ); + msn_ns_send_adl( ic ); - msn_write( ic, buf, strlen( buf ) ); + if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) + return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); } } else if( num_parts >= 3 ) -- cgit v1.2.3 From 80175a1558f297d5505ed4e91a261781ec9c65a2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 18 Aug 2010 20:21:44 +0100 Subject: Fetch the user's profile to see if there's a display name set there. If there is, the one in the address book should be ignored. No support for changing the profile yet though. --- protocols/msn/ns.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index c9b01ef2..4b779a58 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -258,23 +258,14 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "BLP" ) == 0 ) { msn_ns_send_adl_start( ic ); - - if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) - return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); + return msn_ns_finish_login( ic ); } else if( strcmp( cmd[0], "ADL" ) == 0 ) { if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) { msn_ns_send_adl( ic ); - - if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) - { - msn_ns_send_adl( ic ); - - if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) - return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); - } + return msn_ns_finish_login( ic ); } else if( num_parts >= 3 ) { @@ -817,3 +808,19 @@ static void msn_ns_send_adl_start( struct im_connection *ic ) msn_ns_send_adl( ic ); } + +int msn_ns_finish_login( struct im_connection *ic ) +{ + struct msn_data *md = ic->proto_data; + + if( ic->flags & OPT_LOGGED_IN ) + return 1; + + if( md->adl_todo < 0 ) + md->flags |= MSN_DONE_ADL; + + if( ( md->flags & MSN_DONE_ADL ) && ( md->flags & MSN_GOT_PROFILE ) ) + return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); + else + return 1; +} -- cgit v1.2.3 From fd424c891db6da587cce3da8ac98ab7dfa986fb3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Aug 2010 00:08:33 +0100 Subject: Also pick up MSN Messenger mobile info. --- protocols/msn/ns.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 4b779a58..bd13c3a6 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -332,8 +332,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "NLN" ) == 0 ) { const struct msn_away_state *st; + int cap; - if( num_parts < 5 ) + if( num_parts < 6 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -341,6 +342,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } http_decode( cmd[4] ); + cap = atoi( cmd[5] ); imcb_rename_buddy( ic, cmd[2], cmd[4] ); st = msn_away_state_by_code( cmd[1] ); @@ -351,7 +353,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 != 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] ) ); -- cgit v1.2.3 From 02bb9db2edd535036e030e004a58ed1459c15bb8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 29 Aug 2010 11:39:27 +0200 Subject: Handle payloads attached to errors (assume any number in cmd[2] would be a payload length, which seems like a fair assumption). This should solve problems with logging in with dodgy contact/membership lists. --- protocols/msn/ns.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index bd13c3a6..fa445aa7 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -518,6 +518,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) imc_logout( ic, TRUE ); return( 0 ); } + + /* Oh yes, errors can have payloads too now. Discard them for now. */ + if( num_parts >= 3 ) + md->handler->msglen = atoi( cmd[2] ); } else { -- cgit v1.2.3 From 64768d4ec0c3ad473573c3f3c34871e0081b4e59 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 2 Sep 2010 10:15:44 +0100 Subject: Replace msn*write functions with saner versions that accept format strings. Also preparing for additional temporary NS connections (auth token renewal). --- protocols/msn/ns.c | 75 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 29 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index fa445aa7..23a1951d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -37,11 +37,41 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int static void msn_ns_send_adl_start( struct im_connection *ic ); static void msn_ns_send_adl( struct im_connection *ic ); +int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) +{ + struct msn_data *md = ic->proto_data; + va_list params; + char *out; + size_t len; + int st; + + va_start( params, fmt ); + out = g_strdup_vprintf( fmt, params ); + va_end( params ); + + if( fd < 0 ) + fd = md->fd; + + if( getenv( "BITLBEE_DEBUG" ) ) + fprintf( stderr, "->NS%d:%s", fd, out ); + + len = strlen( out ); + st = write( fd, out, len ); + g_free( out ); + if( st != len ) + { + imcb_error( ic, "Short write() to main server" ); + imc_logout( ic, TRUE ); + return 0; + } + + return 1; +} + gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) { struct im_connection *ic = data; struct msn_data *md; - char s[1024]; if( !g_slist_find( msn_connections, ic ) ) return FALSE; @@ -73,8 +103,7 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) md->handler->fd = md->fd; md->handler->rxq = g_new0( char, 1 ); - g_snprintf( s, sizeof( s ), "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ); - if( msn_write( ic, s, strlen( s ) ) ) + if( msn_ns_write( ic, -1, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) { ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); imcb_log( ic, "Connected to server, waiting for reply" ); @@ -103,7 +132,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { struct im_connection *ic = data; struct msn_data *md = ic->proto_data; - char buf[1024]; if( num_parts == 0 ) { @@ -120,15 +148,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } - g_snprintf( buf, sizeof( buf ), "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", - ++md->trId, ic->acc->user ); - return( msn_write( ic, buf, strlen( buf ) ) ); + return( msn_ns_write( ic, -1, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", + ++md->trId, ic->acc->user ) ); } else if( strcmp( cmd[0], "CVR" ) == 0 ) { /* We don't give a damn about the information we just received */ - g_snprintf( buf, sizeof( buf ), "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); - return( msn_write( ic, buf, strlen( buf ) ) ); + return msn_ns_write( ic, -1, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); } else if( strcmp( cmd[0], "XFR" ) == 0 ) { @@ -279,6 +305,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "CHL" ) == 0 ) { char *resp; + int st; if( num_parts < 3 ) { @@ -288,12 +315,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } resp = msn_p11_challenge( cmd[2] ); - g_snprintf( buf, sizeof( buf ), "QRY %d %s %zd\r\n%s", - ++md->trId, MSNP11_PROD_ID, - strlen( resp ), resp ); - g_free( resp ); - return( msn_write( ic, buf, strlen( buf ) ) ); + st = msn_ns_write( ic, -1, "QRY %d %s %zd\r\n%s", + ++md->trId, MSNP11_PROD_ID, + strlen( resp ), resp ); + g_free( resp ); + return st; } else if( strcmp( cmd[0], "ILN" ) == 0 ) { @@ -698,10 +725,7 @@ void msn_auth_got_passport_token( struct im_connection *ic, const char *token, c if( token ) { - char buf[1536]; - - g_snprintf( buf, sizeof( buf ), "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); - msn_write( ic, buf, strlen( buf ) ); + msn_ns_write( ic, -1, "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); } else { @@ -712,7 +736,6 @@ void msn_auth_got_passport_token( struct im_connection *ic, const char *token, c void msn_auth_got_contact_list( struct im_connection *ic ) { - char buf[64]; struct msn_data *md; /* Dead connection? */ @@ -720,10 +743,7 @@ void msn_auth_got_contact_list( struct im_connection *ic ) return; md = ic->proto_data; - - - g_snprintf( buf, sizeof( buf ), "BLP %d %s\r\n", ++md->trId, "BL" ); - msn_write( ic, buf, strlen( buf ) ); + msn_ns_write( ic, -1, "BLP %d %s\r\n", ++md->trId, "BL" ); } static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) @@ -769,7 +789,7 @@ static void msn_ns_send_adl( struct im_connection *ic ) { struct xt_node *adl; struct msn_data *md = ic->proto_data; - char *adls, buf[64]; + char *adls; adl = xt_new_node( "ml", NULL, NULL ); xt_add_attr( adl, "l", "1" ); @@ -781,12 +801,9 @@ static void msn_ns_send_adl( struct im_connection *ic ) xt_free_node( adl ); return; } - adls = xt_to_string( adl ); - - g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); - if( msn_write( ic, buf, strlen( buf ) ) ) - msn_write( ic, adls, strlen( adls ) ); + adls = xt_to_string( adl ); + msn_ns_write( ic, -1, "ADL %d %zd\r\n%s", ++md->trId, strlen( adls ), adls ); g_free( adls ); } -- cgit v1.2.3 From bae06178bbe3863b39ec307c34d2781a53472272 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 3 Sep 2010 22:24:58 +0100 Subject: Rearrange things a bit to support multiple NS connections. This is apparently needed for refreshing auth. tokens. --- protocols/msn/ns.c | 114 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 46 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 23a1951d..6260e300 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -30,9 +30,10 @@ #include "soap.h" #include "xmltree.h" +static gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ); static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ); -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 int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num_parts ); +static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int num_parts ); static void msn_ns_send_adl_start( struct im_connection *ic ); static void msn_ns_send_adl( struct im_connection *ic ); @@ -50,7 +51,7 @@ int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) va_end( params ); if( fd < 0 ) - fd = md->fd; + fd = md->ns->fd; if( getenv( "BITLBEE_DEBUG" ) ) fprintf( stderr, "->NS%d:%s", fd, out ); @@ -68,56 +69,79 @@ int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) return 1; } -gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) +gboolean msn_ns_connect( struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port ) { - struct im_connection *ic = data; - struct msn_data *md; - - if( !g_slist_find( msn_connections, ic ) ) - return FALSE; + if( handler->fd >= 0 ) + closesocket( handler->fd ); - if( source == -1 ) + handler->exec_command = msn_ns_command; + handler->exec_message = msn_ns_message; + handler->data = ic; + handler->fd = proxy_connect( host, port, msn_ns_connected, handler ); + if( handler->fd < 0 ) { imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); return FALSE; } + return TRUE; +} + +static gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) +{ + struct msn_handler_data *handler = data; + struct im_connection *ic = handler->data; + struct msn_data *md; + + if( !g_slist_find( msn_connections, ic ) ) + return FALSE; + md = ic->proto_data; - if( !md->handler ) - { - md->handler = g_new0( struct msn_handler_data, 1 ); - md->handler->data = ic; - md->handler->exec_command = msn_ns_command; - md->handler->exec_message = msn_ns_message; - } - else + if( source == -1 ) { - if( md->handler->rxq ) - g_free( md->handler->rxq ); - - md->handler->rxlen = 0; + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); + return FALSE; } - md->handler->fd = md->fd; - md->handler->rxq = g_new0( char, 1 ); + g_free( handler->rxq ); + handler->rxlen = 0; + handler->rxq = g_new0( char, 1 ); if( msn_ns_write( ic, -1, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) { - ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic ); + handler->inpa = b_input_add( handler->fd, B_EV_IO_READ, msn_ns_callback, handler ); imcb_log( ic, "Connected to server, waiting for reply" ); } return FALSE; } +void msn_ns_close( struct msn_handler_data *handler ) +{ + if( handler->fd >= 0 ) + { + closesocket( handler->fd ); + b_event_remove( handler->inpa ); + } + + handler->fd = handler->inpa = -1; + g_free( handler->rxq ); + g_free( handler->cmd_text ); + + handler->rxlen = 0; + handler->rxq = NULL; + handler->cmd_text = NULL; +} + static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ) { - struct im_connection *ic = data; - struct msn_data *md = ic->proto_data; + struct msn_handler_data *handler = data; + struct im_connection *ic = handler->data; - if( msn_handler( md->handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ + if( msn_handler( handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ { imcb_error( ic, "Error while reading from server" ); imc_logout( ic, TRUE ); @@ -128,9 +152,9 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c return TRUE; } -static int msn_ns_command( gpointer data, char **cmd, int num_parts ) +static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num_parts ) { - struct im_connection *ic = data; + struct im_connection *ic = handler->data; struct msn_data *md = ic->proto_data; if( num_parts == 0 ) @@ -163,9 +187,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts >= 6 && strcmp( cmd[2], "NS" ) == 0 ) { - b_event_remove( ic->inpa ); - ic->inpa = 0; - closesocket( md->fd ); + b_event_remove( handler->inpa ); + handler->inpa = -1; server = strchr( cmd[3], ':' ); if( !server ) @@ -179,8 +202,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) server = cmd[3]; imcb_log( ic, "Transferring to other server" ); - - md->fd = proxy_connect( server, port, msn_ns_connected, ic ); + return msn_ns_connect( ic, handler, server, port ); } else if( num_parts >= 6 && strcmp( cmd[2], "SB" ) == 0 ) { @@ -272,9 +294,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } - md->handler->msglen = atoi( cmd[3] ); + handler->msglen = atoi( cmd[3] ); - if( md->handler->msglen <= 0 ) + if( handler->msglen <= 0 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -295,7 +317,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( num_parts >= 3 ) { - md->handler->msglen = atoi( cmd[2] ); + handler->msglen = atoi( cmd[2] ); } } else if( strcmp( cmd[0], "PRP" ) == 0 ) @@ -459,9 +481,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { imcb_error( ic, "Received IPG command, we don't handle them yet." ); - md->handler->msglen = atoi( cmd[1] ); + handler->msglen = atoi( cmd[1] ); - if( md->handler->msglen <= 0 ) + if( handler->msglen <= 0 ) { imcb_error( ic, "Syntax error" ); imc_logout( ic, TRUE ); @@ -518,20 +540,20 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { /* Coming up is cmd[2] bytes of stuff we're supposed to censore. Meh. */ - md->handler->msglen = atoi( cmd[2] ); + handler->msglen = atoi( cmd[2] ); } else if( strcmp( cmd[0], "UBX" ) == 0 ) { /* Status message. */ if( num_parts >= 4 ) - md->handler->msglen = atoi( cmd[3] ); + handler->msglen = atoi( cmd[3] ); } else if( strcmp( cmd[0], "NOT" ) == 0 ) { /* Some kind of notification, poorly documented but apparently used to announce address book changes. */ if( num_parts >= 2 ) - md->handler->msglen = atoi( cmd[1] ); + handler->msglen = atoi( cmd[1] ); } else if( isdigit( cmd[0][0] ) ) { @@ -548,7 +570,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) /* Oh yes, errors can have payloads too now. Discard them for now. */ if( num_parts >= 3 ) - md->handler->msglen = atoi( cmd[2] ); + handler->msglen = atoi( cmd[2] ); } else { @@ -558,9 +580,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 1 ); } -static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ) +static int msn_ns_message( struct msn_handler_data *handler, char *msg, int msglen, char **cmd, int num_parts ) { - struct im_connection *ic = data; + struct im_connection *ic = handler->data; char *body; int blen = 0; -- cgit v1.2.3 From 4aa8a046968bff0a08dc5ae96e228861fa21fcbe Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 4 Sep 2010 16:54:52 +0100 Subject: This works (includes some token sabotage code to ease testing), but I just realised there's probably no need for the additional temporary NS connection. --- protocols/msn/ns.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 6260e300..401461b2 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -110,7 +110,7 @@ static gboolean msn_ns_connected( gpointer data, gint source, b_input_condition handler->rxlen = 0; handler->rxq = g_new0( char, 1 ); - if( msn_ns_write( ic, -1, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) + if( msn_ns_write( ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) { handler->inpa = b_input_add( handler->fd, B_EV_IO_READ, msn_ns_callback, handler ); imcb_log( ic, "Connected to server, waiting for reply" ); @@ -172,13 +172,13 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num return( 0 ); } - return( msn_ns_write( ic, -1, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", + return( msn_ns_write( ic, handler->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", ++md->trId, ic->acc->user ) ); } else if( strcmp( cmd[0], "CVR" ) == 0 ) { /* We don't give a damn about the information we just received */ - return msn_ns_write( ic, -1, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); + return msn_ns_write( ic, handler->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); } else if( strcmp( cmd[0], "XFR" ) == 0 ) { @@ -271,7 +271,14 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num if( num_parts >= 6 && strcmp( cmd[2], "SSO" ) == 0 && strcmp( cmd[3], "S" ) == 0 ) { - msn_soap_passport_sso_request( ic, cmd[4], cmd[5] ); + g_free( md->pp_policy ); + md->pp_policy = g_strdup( cmd[4] ); + msn_soap_passport_sso_request( ic, cmd[5] ); + if( handler == md->auth ) + { + msn_ns_close( md->auth ); + return 0; + } } else if( strcmp( cmd[2], "OK" ) == 0 ) { -- cgit v1.2.3 From 27053b516db4d0e648d666e6d9e36856af428775 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 4 Sep 2010 18:13:55 +0100 Subject: Finish re-authentication works. Should now work for OIMs as well. --- protocols/msn/ns.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 401461b2..d64a71ac 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -274,11 +274,6 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num g_free( md->pp_policy ); md->pp_policy = g_strdup( cmd[4] ); msn_soap_passport_sso_request( ic, cmd[5] ); - if( handler == md->auth ) - { - msn_ns_close( md->auth ); - return 0; - } } else if( strcmp( cmd[2], "OK" ) == 0 ) { -- cgit v1.2.3