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/soap.c | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 protocols/msn/soap.c (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c new file mode 100644 index 00000000..d3a022ec --- /dev/null +++ b/protocols/msn/soap.c @@ -0,0 +1,216 @@ +/** soap.c + * + * SOAP-related functions. Some manager at Microsoft apparently thought + * MSNP wasn't XMLy enough so someone stepped up and changed that. This + * is the result. + * + * Copyright (C) 2010 Wilmer van der Gaast + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that is will be useful, + * bit WITHOU ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "http_client.h" +#include "soap.h" +#include "msn.h" +#include "bitlbee.h" +#include "url.h" +#include "misc.h" +#include "base64.h" +#include "xmltree.h" +#include +#include + +typedef enum +{ + MSN_SOAP_OK, + MSN_SOAP_RETRY, + MSN_SOAP_ABORT, +} msn_soap_result_t; + +struct msn_soap_req_data; + +typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); + +struct msn_soap_req_data +{ + void *data; + struct im_connection *ic; + int ttl; + + char *url, *action, *payload; + struct http_request *http_req; + + const struct xt_handler_entry *xml_parser; + msn_soap_func build_request, handle_response, free_data; +}; + +struct msn_soap_oim_send_data +{ + char *to; + char *msg; + int number; + int need_retry; +}; + +static int msn_soap_send_request( struct msn_soap_req_data *req ); + +static int msn_soap_start( struct im_connection *ic, + void *data, + msn_soap_func build_request, + const struct xt_handler_entry *xml_parser, + msn_soap_func handle_response, + msn_soap_func free_data ) +{ + struct msn_soap_req_data *req = g_new0( struct msn_soap_req_data, 1 ); + + req->ic = ic; + req->data = data; + req->xml_parser = xml_parser; + req->build_request = build_request; + req->handle_response = handle_response; + req->free_data = free_data; + req->ttl = 3; + + return msn_soap_send_request( req ); +} + +static void msn_soap_handle_response( struct http_request *http_req ); + +static int msn_soap_send_request( struct msn_soap_req_data *soap_req ) +{ + char *http_req; + url_t url; + + soap_req->build_request( soap_req ); + + url_set( &url, soap_req->url ); + http_req = g_strdup_printf( SOAP_HTTP_REQUEST, url.file, url.host, + soap_req->action, strlen( soap_req->payload ), soap_req->payload ); + + soap_req->http_req = http_dorequest( url.host, url.port, url.proto == PROTO_HTTPS, + http_req, msn_soap_handle_response, soap_req ); + + return soap_req->http_req != NULL; +} + +static void msn_soap_handle_response( struct http_request *http_req ) +{ + struct msn_soap_req_data *soap_req = http_req->data; + int st; + + if( http_req->body_size > 0 ) + { + struct xt_parser *parser; + + parser = xt_new( soap_req->xml_parser, soap_req ); + xt_feed( parser, http_req->reply_body, http_req->body_size ); + xt_handle( parser, NULL, -1 ); + xt_free( parser ); + } + + st = soap_req->handle_response( soap_req ); + + if( st == MSN_SOAP_RETRY && --soap_req->ttl ) + msn_soap_send_request( soap_req ); + else + { + soap_req->free_data( soap_req ); + g_free( soap_req->url ); + g_free( soap_req->action ); + g_free( soap_req->payload ); + g_free( soap_req ); + } +} + +static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_oim_send_data *oim = soap_req->data; + struct im_connection *ic = soap_req->ic; + struct msn_data *md = ic->proto_data; + char *display_name_b64; + + display_name_b64 = tobase64( ic->displayname ); + + soap_req->url = g_strdup( SOAP_OIM_SEND_URL ); + soap_req->action = g_strdup( SOAP_OIM_ACTION_URL ); + soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD, + ic->acc->user, display_name_b64, oim->to, md->passport_token, + MSNP11_PROD_ID, md->lock_key ? : "", oim->number, oim->number, oim->msg ); + + g_free( display_name_b64 ); + + return 1; +} + +static xt_status msn_soap_oim_send_challenge( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + struct msn_soap_oim_send_data *oim = soap_req->data; + struct im_connection *ic = soap_req->ic; + struct msn_data *md = ic->proto_data; + + g_free( md->lock_key ); + md->lock_key = msn_p11_challenge( node->text ); + + oim->need_retry = 1; + + return XT_HANDLED; +} + +static const struct xt_handler_entry msn_soap_oim_send_parser[] = { + { "LockKeyChallenge", "detail", msn_soap_oim_send_challenge }, + { NULL, NULL, NULL } +}; + +static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_oim_send_data *oim = soap_req->data; + + if( soap_req->http_req->status_code == 500 && oim->need_retry ) + { + oim->need_retry = 0; + return MSN_SOAP_RETRY; + } + else if( soap_req->http_req->status_code == 200 ) + return MSN_SOAP_OK; + else + return MSN_SOAP_ABORT; +} + +static int msn_soap_oim_free_data( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_oim_send_data *oim = soap_req->data; + + g_free( oim->to ); + g_free( oim->msg ); + g_free( oim ); + + return 0; +} + +int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg ) +{ + struct msn_soap_oim_send_data *data; + + data = g_new0( struct msn_soap_oim_send_data, 1 ); + data->to = g_strdup( to ); + data->msg = tobase64( msg ); + data->number = 1; + + return msn_soap_start( ic, data, msn_soap_oim_build_request, + msn_soap_oim_send_parser, + msn_soap_oim_handle_response, + msn_soap_oim_free_data ); +} -- cgit v1.2.3 From ffb6dea650db7671d2414b1a9541cf0baba8ff11 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 20 Mar 2010 21:58:04 +0000 Subject: Killing some memory leaks. --- protocols/msn/soap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index d3a022ec..f329cea9 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -102,6 +102,8 @@ static int msn_soap_send_request( struct msn_soap_req_data *soap_req ) soap_req->http_req = http_dorequest( url.host, url.port, url.proto == PROTO_HTTPS, http_req, msn_soap_handle_response, soap_req ); + g_free( http_req ); + return soap_req->http_req != NULL; } @@ -122,14 +124,16 @@ static void msn_soap_handle_response( struct http_request *http_req ) st = soap_req->handle_response( soap_req ); + g_free( soap_req->url ); + g_free( soap_req->action ); + g_free( soap_req->payload ); + soap_req->url = soap_req->action = soap_req->payload = NULL; + if( st == MSN_SOAP_RETRY && --soap_req->ttl ) msn_soap_send_request( soap_req ); else { soap_req->free_data( soap_req ); - g_free( soap_req->url ); - g_free( soap_req->action ); - g_free( soap_req->payload ); g_free( soap_req ); } } -- cgit v1.2.3 From bc090f0c3bc243de277a8e04f906384838d95e35 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 20 Mar 2010 22:42:59 +0000 Subject: Error reporting and added a msgq_send function. Need to put some more intelligence into it later. --- protocols/msn/soap.c | 54 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index f329cea9..82ecfea2 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -56,14 +56,6 @@ struct msn_soap_req_data msn_soap_func build_request, handle_response, free_data; }; -struct msn_soap_oim_send_data -{ - char *to; - char *msg; - int number; - int need_retry; -}; - static int msn_soap_send_request( struct msn_soap_req_data *req ); static int msn_soap_start( struct im_connection *ic, @@ -138,6 +130,17 @@ static void msn_soap_handle_response( struct http_request *http_req ) } } + +/* oim_send: Sending offline messages */ + +struct msn_soap_oim_send_data +{ + char *to; + char *msg; + int number; + int need_retry; +}; + static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) { struct msn_soap_oim_send_data *oim = soap_req->data; @@ -182,15 +185,21 @@ static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req ) { struct msn_soap_oim_send_data *oim = soap_req->data; - if( soap_req->http_req->status_code == 500 && oim->need_retry ) + if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 ) { oim->need_retry = 0; return MSN_SOAP_RETRY; } else if( soap_req->http_req->status_code == 200 ) + { + imcb_log( soap_req->ic, "Offline message successfully delivered to %s", oim->to ); return MSN_SOAP_OK; + } else + { + imcb_log( soap_req->ic, "Failed to deliver offline message to %s:\n%s", oim->to, oim->msg ); return MSN_SOAP_ABORT; + } } static int msn_soap_oim_free_data( struct msn_soap_req_data *soap_req ) @@ -218,3 +227,30 @@ int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg msn_soap_oim_handle_response, msn_soap_oim_free_data ); } + +int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ) +{ + GSList *l; + char *n = NULL; + + for( l = *msgq; l; l = l->next ) + { + struct msn_message *m = l->data; + + if( n == NULL ) + n = m->who; + if( strcmp( n, m->who ) == 0 ) + msn_soap_oim_send( ic, m->who, m->text ); + } + + while( *msgq != NULL ) + { + struct msn_message *m = (*msgq)->data; + + g_free( m->who ); + g_free( m->text ); + g_free( m ); + + *msgq = g_slist_remove( *msgq, m ); + } +} -- 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/soap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 82ecfea2..4d623a9d 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -154,7 +154,8 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) soap_req->action = g_strdup( SOAP_OIM_ACTION_URL ); soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD, ic->acc->user, display_name_b64, oim->to, md->passport_token, - MSNP11_PROD_ID, md->lock_key ? : "", oim->number, oim->number, oim->msg ); + MSNP11_PROD_ID, md->lock_key ? md->lock_key : "", + oim->number, oim->number, oim->msg ); g_free( display_name_b64 ); -- 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/soap.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 4d623a9d..252bddeb 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -82,14 +82,22 @@ static void msn_soap_handle_response( struct http_request *http_req ); static int msn_soap_send_request( struct msn_soap_req_data *soap_req ) { + struct msn_data *md = soap_req->ic->proto_data; char *http_req; + char *pom, *s; url_t url; soap_req->build_request( soap_req ); + pom = g_new0( char, strlen( md->passport_token ) * 3 ); + strcpy( pom, md->passport_token + 2 ); + if( ( s = strchr( pom, '&' ) ) ) + *s = '\0'; + url_set( &url, soap_req->url ); http_req = g_strdup_printf( SOAP_HTTP_REQUEST, url.file, url.host, - soap_req->action, strlen( soap_req->payload ), soap_req->payload ); + soap_req->action, pom, + strlen( soap_req->payload ), soap_req->payload ); soap_req->http_req = http_dorequest( url.host, url.port, url.proto == PROTO_HTTPS, http_req, msn_soap_handle_response, soap_req ); @@ -151,7 +159,7 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) display_name_b64 = tobase64( ic->displayname ); soap_req->url = g_strdup( SOAP_OIM_SEND_URL ); - soap_req->action = g_strdup( SOAP_OIM_ACTION_URL ); + soap_req->action = g_strdup( SOAP_OIM_SEND_ACTION ); soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD, ic->acc->user, display_name_b64, oim->to, md->passport_token, MSNP11_PROD_ID, md->lock_key ? md->lock_key : "", @@ -255,3 +263,47 @@ int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ) *msgq = g_slist_remove( *msgq, m ); } } + + +/* memlist: Fetching the membership list (NOT address book) */ + +#if 0 +struct msn_soap_oim_send_data +{ + char *to; + char *msg; + int number; + int need_retry; +}; +#endif + +static int msn_soap_memlist_build_request( struct msn_soap_req_data *soap_req ) +{ + soap_req->url = g_strdup( SOAP_MEMLIST_URL ); + soap_req->action = g_strdup( SOAP_MEMLIST_ACTION ); + soap_req->payload = g_strdup( SOAP_MEMLIST_PAYLOAD ); + + return 1; +} + +static const struct xt_handler_entry msn_soap_memlist_parser[] = { + { NULL, NULL, NULL } +}; + +static int msn_soap_memlist_handle_response( struct msn_soap_req_data *soap_req ) +{ + return 0; +} + +static int msn_soap_memlist_free_data( struct msn_soap_req_data *soap_req ) +{ + return 0; +} + +int msn_soap_memlist_request( struct im_connection *ic ) +{ + return msn_soap_start( ic, NULL, msn_soap_memlist_build_request, + msn_soap_memlist_parser, + msn_soap_memlist_handle_response, + msn_soap_memlist_free_data ); +} -- 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/soap.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 165 insertions(+), 10 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 252bddeb..e837986e 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -27,6 +27,7 @@ #include "bitlbee.h" #include "url.h" #include "misc.h" +#include "sha1.h" #include "base64.h" #include "xmltree.h" #include @@ -82,27 +83,25 @@ static void msn_soap_handle_response( struct http_request *http_req ); static int msn_soap_send_request( struct msn_soap_req_data *soap_req ) { - struct msn_data *md = soap_req->ic->proto_data; char *http_req; - char *pom, *s; + char *soap_action = NULL; url_t url; soap_req->build_request( soap_req ); - pom = g_new0( char, strlen( md->passport_token ) * 3 ); - strcpy( pom, md->passport_token + 2 ); - if( ( s = strchr( pom, '&' ) ) ) - *s = '\0'; + if( soap_req->action ) + soap_action = g_strdup_printf( "SOAPAction: \"%s\"\r\n", soap_req->action ); url_set( &url, soap_req->url ); http_req = g_strdup_printf( SOAP_HTTP_REQUEST, url.file, url.host, - soap_req->action, pom, + soap_action ? soap_action : "", strlen( soap_req->payload ), soap_req->payload ); soap_req->http_req = http_dorequest( url.host, url.port, url.proto == PROTO_HTTPS, http_req, msn_soap_handle_response, soap_req ); g_free( http_req ); + g_free( soap_action ); return soap_req->http_req != NULL; } @@ -139,6 +138,160 @@ static void msn_soap_handle_response( struct http_request *http_req ) } +/* passport_sso: Authentication MSNP15+ */ + +struct msn_soap_passport_sso_data +{ + char *policy; + char *nonce; + char *secret; +}; + +static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_passport_sso_data *sd = soap_req->data; + struct im_connection *ic = soap_req->ic; + + soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL ); + soap_req->payload = g_markup_printf_escaped( SOAP_PASSPORT_SSO_PAYLOAD, + ic->acc->user, ic->acc->pass, sd->policy ); + + return MSN_SOAP_OK; +} + +static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + struct msn_soap_passport_sso_data *sd = soap_req->data; + struct msn_data *md = soap_req->ic->proto_data; + struct xt_node *p; + char *id; + + if( ( id = xt_find_attr( node, "Id" ) ) == NULL ) + return XT_HANDLED; + id += strlen( id ) - 1; + if( *id == '1' && + ( p = node->parent ) && ( p = p->parent ) && + ( p = xt_find_node( p->children, "wst:RequestedProofToken" ) ) && + ( p = xt_find_node( p->children, "wst:BinarySecret" ) ) && + p->text ) + sd->secret = g_strdup( p->text ); + + if( *id == '1' ) + md->tokens[0] = g_strdup( node->text ); + else if( *id == '2' ) + md->tokens[1] = g_strdup( node->text ); + + return XT_HANDLED; +} + +static const struct xt_handler_entry msn_soap_passport_sso_parser[] = { + { "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", msn_soap_passport_sso_token }, + { NULL, NULL, NULL } +}; + +static char *msn_key_fuckery( char *key, int key_len, char *type ) +{ + unsigned char hash1[20+strlen(type)+1]; + unsigned char hash2[20]; + char *ret; + + sha1_hmac( key, key_len, type, 0, hash1 ); + strcpy( (char*) hash1 + 20, type ); + sha1_hmac( key, key_len, (char*) hash1, sizeof( hash1 ) - 1, hash2 ); + + /* This is okay as hash1 is read completely before it's overwritten. */ + sha1_hmac( key, key_len, (char*) hash1, 20, hash1 ); + sha1_hmac( key, key_len, (char*) hash1, sizeof( hash1 ) - 1, hash1 ); + + ret = g_malloc( 24 ); + memcpy( ret, hash2, 20 ); + memcpy( ret + 20, hash1, 4 ); + return ret; +} + +static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_passport_sso_data *sd = soap_req->data; + struct im_connection *ic = soap_req->ic; + char *key1, *key2, *key3, *blurb64; + int key1_len; + unsigned char *padnonce, *des3res; + struct + { + unsigned int uStructHeaderSize; // 28. Does not count data + unsigned int uCryptMode; // CRYPT_MODE_CBC (1) + unsigned int uCipherType; // TripleDES (0x6603) + unsigned int uHashType; // SHA1 (0x8004) + unsigned int uIVLen; // 8 + unsigned int uHashLen; // 20 + unsigned int uCipherLen; // 72 + unsigned char iv[8]; + unsigned char hash[20]; + unsigned char cipherbytes[72]; + } blurb = { + GUINT32_TO_LE( 28 ), + GUINT32_TO_LE( 1 ), + GUINT32_TO_LE( 0x6603 ), + GUINT32_TO_LE( 0x8004 ), + GUINT32_TO_LE( 8 ), + GUINT32_TO_LE( 20 ), + GUINT32_TO_LE( 72 ), + }; + + key1_len = base64_decode( sd->secret, (unsigned char**) &key1 ); + + key2 = msn_key_fuckery( key1, key1_len, "WS-SecureConversationSESSION KEY HASH" ); + key3 = msn_key_fuckery( key1, key1_len, "WS-SecureConversationSESSION KEY ENCRYPTION" ); + + sha1_hmac( key2, 24, sd->nonce, 0, blurb.hash ); + padnonce = g_malloc( strlen( sd->nonce ) + 8 ); + strcpy( (char*) padnonce, sd->nonce ); + memset( padnonce + strlen( sd->nonce ), 8, 8 ); + + random_bytes( blurb.iv, 8 ); + + ssl_des3_encrypt( (unsigned char*) key3, 24, padnonce, strlen( sd->nonce ) + 8, blurb.iv, &des3res ); + memcpy( blurb.cipherbytes, des3res, 72 ); + + blurb64 = base64_encode( (unsigned char*) &blurb, sizeof( blurb ) ); + msn_auth_got_passport_token( ic, blurb64 ); + + g_free( padnonce ); + g_free( blurb64 ); + g_free( des3res ); + g_free( key1 ); + g_free( key2 ); + g_free( key3 ); + + return MSN_SOAP_OK; +} + +static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_passport_sso_data *sd = soap_req->data; + + g_free( sd->policy ); + g_free( sd->nonce ); + g_free( sd->secret ); + + return MSN_SOAP_OK; +} + +int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ) +{ + struct msn_soap_passport_sso_data *sd = g_new0( struct msn_soap_passport_sso_data, 1 ); + + sd->policy = g_strdup( policy ); + sd->nonce = g_strdup( nonce ); + + return msn_soap_start( ic, sd, msn_soap_passport_sso_build_request, + msn_soap_passport_sso_parser, + msn_soap_passport_sso_handle_response, + msn_soap_passport_sso_free_data ); +} + + /* oim_send: Sending offline messages */ struct msn_soap_oim_send_data @@ -161,13 +314,13 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) soap_req->url = g_strdup( SOAP_OIM_SEND_URL ); soap_req->action = g_strdup( SOAP_OIM_SEND_ACTION ); soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD, - ic->acc->user, display_name_b64, oim->to, md->passport_token, + ic->acc->user, display_name_b64, oim->to, "bla", //md->passport_token, MSNP11_PROD_ID, md->lock_key ? md->lock_key : "", oim->number, oim->number, oim->msg ); g_free( display_name_b64 ); - return 1; + return MSN_SOAP_OK; } static xt_status msn_soap_oim_send_challenge( struct xt_node *node, gpointer data ) @@ -219,7 +372,7 @@ static int msn_soap_oim_free_data( struct msn_soap_req_data *soap_req ) g_free( oim->msg ); g_free( oim ); - return 0; + return MSN_SOAP_OK; } int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg ) @@ -262,6 +415,8 @@ int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ) *msgq = g_slist_remove( *msgq, m ); } + + return 1; } -- cgit v1.2.3 From 7f34ce254c1a1587e5560456dd11acb29345206d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 12 Aug 2010 00:03:33 +0100 Subject: Get contact list/address book info. Next step: We have to send it back. Seriously. Wish I were joking. --- protocols/msn/soap.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 142 insertions(+), 12 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index e837986e..62d58200 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -422,32 +422,61 @@ int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ) /* memlist: Fetching the membership list (NOT address book) */ -#if 0 -struct msn_soap_oim_send_data -{ - char *to; - char *msg; - int number; - int need_retry; -}; -#endif - static int msn_soap_memlist_build_request( struct msn_soap_req_data *soap_req ) { + struct msn_data *md = soap_req->ic->proto_data; + soap_req->url = g_strdup( SOAP_MEMLIST_URL ); soap_req->action = g_strdup( SOAP_MEMLIST_ACTION ); - soap_req->payload = g_strdup( SOAP_MEMLIST_PAYLOAD ); + soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_PAYLOAD, md->tokens[1] ); return 1; } +static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) +{ + bee_user_t *bu; + struct msn_buddy_data *bd; + struct xt_node *p; + char *role = NULL, *handle = NULL; + struct msn_soap_req_data *soap_req = data; + struct im_connection *ic = soap_req->ic; + + if( ( p = node->parent ) && ( p = p->parent ) && + ( p = xt_find_node( p->children, "MemberRole" ) ) ) + role = p->text; + + if( ( p = xt_find_node( node->children, "PassportName" ) ) ) + handle = p->text; + + if( !role || !handle || + !( ( bu = bee_user_by_handle( ic->bee, ic, handle ) ) || + ( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) ) + return XT_HANDLED; + + bd = bu->data; + if( strcmp( role, "Allow" ) == 0 ) + bd->flags |= MSN_BUDDY_AL; + else if( strcmp( role, "Block" ) == 0 ) + bd->flags |= MSN_BUDDY_BL; + else if( strcmp( role, "Reverse" ) == 0 ) + bd->flags |= MSN_BUDDY_RL; + else if( strcmp( role, "Pending" ) == 0 ) + bd->flags |= MSN_BUDDY_PL; + + return XT_HANDLED; +} + static const struct xt_handler_entry msn_soap_memlist_parser[] = { + { "Member", "Members", msn_soap_memlist_member }, { NULL, NULL, NULL } }; static int msn_soap_memlist_handle_response( struct msn_soap_req_data *soap_req ) { - return 0; + msn_soap_addressbook_request( soap_req->ic ); + + return MSN_SOAP_OK; } static int msn_soap_memlist_free_data( struct msn_soap_req_data *soap_req ) @@ -462,3 +491,104 @@ int msn_soap_memlist_request( struct im_connection *ic ) msn_soap_memlist_handle_response, msn_soap_memlist_free_data ); } + + +/* addressbook: Fetching the membership list (NOT address book) */ + +static int msn_soap_addressbook_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + + soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); + soap_req->action = g_strdup( SOAP_ADDRESSBOOK_ACTION ); + soap_req->payload = g_markup_printf_escaped( SOAP_ADDRESSBOOK_PAYLOAD, md->tokens[1] ); + + return 1; +} + +static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data ) +{ + struct xt_node *p; + char *id = NULL, *name = NULL; + struct msn_soap_req_data *soap_req = data; + struct im_connection *ic = soap_req->ic; + + if( ( p = node->parent ) && + ( p = xt_find_node( p->children, "groupId" ) ) ) + id = p->text; + + if( ( p = xt_find_node( node->children, "name" ) ) ) + name = p->text; + + printf( "%s %s\n", id, name ); + + return XT_HANDLED; +} + +static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer data ) +{ + bee_user_t *bu; + struct msn_buddy_data *bd; + struct xt_node *p; + char *id = NULL, *type = NULL, *handle = NULL, *display_name = NULL; + struct msn_soap_req_data *soap_req = data; + struct im_connection *ic = soap_req->ic; + + if( ( p = node->parent ) && + ( p = xt_find_node( p->children, "contactId" ) ) ) + id = p->text; + if( ( p = xt_find_node( node->children, "contactType" ) ) ) + type = p->text; + if( ( p = xt_find_node( node->children, "passportName" ) ) ) + handle = p->text; + if( ( p = xt_find_node( node->children, "displayName" ) ) ) + display_name = p->text; + + if( type && g_strcasecmp( type, "me" ) == 0 ) + { + set_t *set = set_find( &ic->acc->set, "display_name" ); + g_free( set->value ); + set->value = g_strdup( display_name ); + + return XT_HANDLED; + } + + if( !( bu = bee_user_by_handle( ic->bee, ic, handle ) ) && + !( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) + return XT_HANDLED; + + bd = bu->data; + bd->flags |= MSN_BUDDY_FL; + g_free( bd->cid ); + bd->cid = g_strdup( id ); + + imcb_rename_buddy( ic, handle, display_name ); + + printf( "%s %s %s %s\n", id, type, handle, display_name ); + + return XT_HANDLED; +} + +static const struct xt_handler_entry msn_soap_addressbook_parser[] = { + { "contactInfo", "Contact", msn_soap_addressbook_contact }, + { "groupInfo", "Group", msn_soap_addressbook_group }, + { NULL, NULL, NULL } +}; + +static int msn_soap_addressbook_handle_response( struct msn_soap_req_data *soap_req ) +{ + return MSN_SOAP_OK; +} + +static int msn_soap_addressbook_free_data( struct msn_soap_req_data *soap_req ) +{ + return 0; +} + +int msn_soap_addressbook_request( struct im_connection *ic ) +{ + return msn_soap_start( ic, NULL, msn_soap_addressbook_build_request, + msn_soap_addressbook_parser, + msn_soap_addressbook_handle_response, + msn_soap_addressbook_free_data ); +} -- 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/soap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 62d58200..bb664861 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -577,6 +577,7 @@ static const struct xt_handler_entry msn_soap_addressbook_parser[] = { static int msn_soap_addressbook_handle_response( struct msn_soap_req_data *soap_req ) { + msn_auth_got_contact_list( soap_req->ic ); return MSN_SOAP_OK; } -- 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/soap.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index bb664861..0fb36bb4 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -177,10 +177,12 @@ static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer dat p->text ) sd->secret = g_strdup( p->text ); - if( *id == '1' ) - md->tokens[0] = g_strdup( node->text ); - else if( *id == '2' ) - md->tokens[1] = g_strdup( node->text ); + *id -= '1'; + if( *id >= 0 && *id <= 2 ) + { + g_free( md->tokens[(int)*id] ); + md->tokens[(int)*id] = g_strdup( node->text ); + } return XT_HANDLED; } @@ -309,12 +311,13 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) struct msn_data *md = ic->proto_data; char *display_name_b64; - display_name_b64 = tobase64( ic->displayname ); + display_name_b64 = tobase64( set_getstr( &ic->acc->set, "display_name" ) ); soap_req->url = g_strdup( SOAP_OIM_SEND_URL ); soap_req->action = g_strdup( SOAP_OIM_SEND_ACTION ); soap_req->payload = g_markup_printf_escaped( SOAP_OIM_SEND_PAYLOAD, - ic->acc->user, display_name_b64, oim->to, "bla", //md->passport_token, + ic->acc->user, display_name_b64, MSNP_VER, MSNP_BUILD, + oim->to, md->tokens[2], MSNP11_PROD_ID, md->lock_key ? md->lock_key : "", oim->number, oim->number, oim->msg ); -- 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/soap.c | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 0fb36bb4..621e213b 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -1,25 +1,30 @@ -/** soap.c - * - * SOAP-related functions. Some manager at Microsoft apparently thought - * MSNP wasn't XMLy enough so someone stepped up and changed that. This - * is the result. - * - * Copyright (C) 2010 Wilmer van der Gaast - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that is will be useful, - * bit WITHOU ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ + /********************************************************************\ + * BitlBee -- An IRC to other IM-networks gateway * + * * + * Copyright 2002-2010 Wilmer van der Gaast and others * + \********************************************************************/ + +/* MSN module - All the SOAPy XML stuff. + Some manager at Microsoft apparently thought MSNP wasn't XMLy enough so + someone stepped up and changed that. This is the result. Kilobytes and + more kilobytes of XML vomit to transfer tiny bits of informaiton. */ + +/* + 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 program 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. + + You should have received a copy of the GNU General Public License with + the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; + if not, write to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA +*/ #include "http_client.h" #include "soap.h" @@ -33,6 +38,11 @@ #include #include +/* This file tries to make SOAP stuff pretty simple to do by letting you just + provide a function to build a request, a few functions to parse various + parts of the response, and a function to run when the full response was + received and parsed. See the various examples below. */ + typedef enum { MSN_SOAP_OK, @@ -40,10 +50,6 @@ typedef enum MSN_SOAP_ABORT, } msn_soap_result_t; -struct msn_soap_req_data; - -typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); - struct msn_soap_req_data { void *data; @@ -57,6 +63,8 @@ struct msn_soap_req_data msn_soap_func build_request, handle_response, free_data; }; +typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); + static int msn_soap_send_request( struct msn_soap_req_data *req ); static int msn_soap_start( struct im_connection *ic, -- cgit v1.2.3 From 73efe3a6ea04ca19f3a4088990eda60ad852a94f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 12:07:45 +0100 Subject: Allow Passport authentication with @msn.com accounts. --- protocols/msn/soap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 621e213b..c23d190a 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -160,7 +160,11 @@ static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_r struct msn_soap_passport_sso_data *sd = soap_req->data; struct im_connection *ic = soap_req->ic; - soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL ); + if( g_str_has_suffix( ic->acc->user, "@msn.com" ) ) + soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL_MSN ); + else + soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL ); + soap_req->payload = g_markup_printf_escaped( SOAP_PASSPORT_SSO_PAYLOAD, ic->acc->user, ic->acc->pass, sd->policy ); -- cgit v1.2.3 From 12767e39dbafc36d54995727ff2c6043e8292f16 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 12:30:40 +0100 Subject: Status/Away messages. --- protocols/msn/soap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index c23d190a..5eae3089 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -50,6 +50,9 @@ typedef enum MSN_SOAP_ABORT, } msn_soap_result_t; +struct msn_soap_req_data; +typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); + struct msn_soap_req_data { void *data; @@ -63,8 +66,6 @@ struct msn_soap_req_data msn_soap_func build_request, handle_response, free_data; }; -typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); - static int msn_soap_send_request( struct msn_soap_req_data *req ); static int msn_soap_start( struct im_connection *ic, @@ -526,7 +527,6 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data struct xt_node *p; char *id = NULL, *name = NULL; struct msn_soap_req_data *soap_req = data; - struct im_connection *ic = soap_req->ic; if( ( p = node->parent ) && ( p = xt_find_node( p->children, "groupId" ) ) ) -- 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/soap.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 5eae3089..cd54858f 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -608,3 +608,37 @@ int msn_soap_addressbook_request( struct im_connection *ic ) msn_soap_addressbook_handle_response, msn_soap_addressbook_free_data ); } + +/* Variant: Change our display name. */ +static int msn_soap_ab_namechange_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + + soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); + soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION ); + soap_req->payload = g_markup_printf_escaped( SOAP_AB_NAMECHANGE_PAYLOAD, + md->tokens[1], (char *) soap_req->data ); + + return 1; +} + +static int msn_soap_ab_namechange_handle_response( struct msn_soap_req_data *soap_req ) +{ + /* TODO: Ack the change? Not sure what the NAKs look like.. */ + return MSN_SOAP_OK; +} + +static int msn_soap_ab_namechange_free_data( struct msn_soap_req_data *soap_req ) +{ + g_free( soap_req->data ); + return 0; +} + +int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new ) +{ + return msn_soap_start( ic, g_strdup( new ), + msn_soap_ab_namechange_build_request, + NULL, + msn_soap_ab_namechange_handle_response, + msn_soap_ab_namechange_free_data ); +} -- 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/soap.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index cd54858f..8cc241b8 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -476,9 +476,17 @@ static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) else if( strcmp( role, "Block" ) == 0 ) bd->flags |= MSN_BUDDY_BL; else if( strcmp( role, "Reverse" ) == 0 ) + { bd->flags |= MSN_BUDDY_RL; + msn_buddy_ask( bu ); + } else if( strcmp( role, "Pending" ) == 0 ) + { bd->flags |= MSN_BUDDY_PL; + msn_buddy_ask( bu ); + } + + printf( "%s %d\n", handle, bd->flags ); return XT_HANDLED; } -- 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/soap.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 8cc241b8..93bb37a6 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -516,6 +516,87 @@ int msn_soap_memlist_request( struct im_connection *ic ) msn_soap_memlist_free_data ); } +/* Variant: Adding/Removing people */ +struct msn_soap_memlist_edit_data +{ + char *handle; + gboolean add; + msn_buddy_flags_t list; +}; + +static int msn_soap_memlist_edit_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + struct msn_soap_memlist_edit_data *med = soap_req->data; + char *add, *scenario, *list; + + soap_req->url = g_strdup( SOAP_MEMLIST_URL ); + if( med->add ) + { + soap_req->action = g_strdup( SOAP_MEMLIST_ADD_ACTION ); + add = "Add"; + } + else + { + soap_req->action = g_strdup( SOAP_MEMLIST_DEL_ACTION ); + add = "Delete"; + } + switch( med->list ) + { + case MSN_BUDDY_AL: + scenario = "BlockUnblock"; + list = "Allow"; + break; + case MSN_BUDDY_BL: + scenario = "BlockUnblock"; + list = "Block"; + break; + case MSN_BUDDY_RL: + scenario = "Timer"; + list = "Reverse"; + break; + case MSN_BUDDY_PL: + default: + scenario = "Timer"; + list = "Pending"; + break; + } + soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_EDIT_PAYLOAD, + scenario, md->tokens[1], add, list, med->handle, add ); + + return 1; +} + +static int msn_soap_memlist_edit_handle_response( struct msn_soap_req_data *soap_req ) +{ + return MSN_SOAP_OK; +} + +static int msn_soap_memlist_edit_free_data( struct msn_soap_req_data *soap_req ) +{ + struct msn_soap_memlist_edit_data *med = soap_req->data; + + g_free( med->handle ); + g_free( med ); + + return 0; +} + +int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list ) +{ + struct msn_soap_memlist_edit_data *med; + + med = g_new0( struct msn_soap_memlist_edit_data, 1 ); + med->handle = g_strdup( handle ); + med->add = add; + med->list = list; + + return msn_soap_start( ic, med, msn_soap_memlist_edit_build_request, + NULL, + msn_soap_memlist_edit_handle_response, + msn_soap_memlist_edit_free_data ); +} + /* addressbook: Fetching the membership list (NOT address book) */ -- cgit v1.2.3 From 6ddb2236943384d45cacd08e02cb4ef9ed03bba3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 20:57:13 +0100 Subject: Separate boilerplate and body of abservice SOAP requests since the former's the same all the time (and I have to add some more request types). --- protocols/msn/soap.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 93bb37a6..130df840 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -146,6 +146,24 @@ static void msn_soap_handle_response( struct http_request *http_req ) } } +static char *msn_soap_abservice_build( const char *body_fmt, const char *scenario, const char *ticket, ... ) +{ + va_list params; + char *ret, *format, *body; + + format = g_markup_printf_escaped( SOAP_ABSERVICE_PAYLOAD, scenario, ticket ); + + va_start( params, ticket ); + body = g_strdup_vprintf( body_fmt, params ); + va_end( params ); + + ret = g_strdup_printf( format, body ); + g_free( body ); + g_free( format ); + + return ret; +} + /* passport_sso: Authentication MSNP15+ */ @@ -444,7 +462,7 @@ static int msn_soap_memlist_build_request( struct msn_soap_req_data *soap_req ) soap_req->url = g_strdup( SOAP_MEMLIST_URL ); soap_req->action = g_strdup( SOAP_MEMLIST_ACTION ); - soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_PAYLOAD, md->tokens[1] ); + soap_req->payload = msn_soap_abservice_build( SOAP_MEMLIST_PAYLOAD, "Initial", md->tokens[1] ); return 1; } @@ -561,7 +579,7 @@ static int msn_soap_memlist_edit_build_request( struct msn_soap_req_data *soap_r list = "Pending"; break; } - soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_EDIT_PAYLOAD, + soap_req->payload = msn_soap_abservice_build( SOAP_MEMLIST_EDIT_PAYLOAD, scenario, md->tokens[1], add, list, med->handle, add ); return 1; @@ -606,7 +624,7 @@ static int msn_soap_addressbook_build_request( struct msn_soap_req_data *soap_re soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); soap_req->action = g_strdup( SOAP_ADDRESSBOOK_ACTION ); - soap_req->payload = g_markup_printf_escaped( SOAP_ADDRESSBOOK_PAYLOAD, md->tokens[1] ); + soap_req->payload = msn_soap_abservice_build( SOAP_ADDRESSBOOK_PAYLOAD, "Initial", md->tokens[1] ); return 1; } @@ -705,8 +723,8 @@ static int msn_soap_ab_namechange_build_request( struct msn_soap_req_data *soap_ soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION ); - soap_req->payload = g_markup_printf_escaped( SOAP_AB_NAMECHANGE_PAYLOAD, - md->tokens[1], (char *) soap_req->data ); + soap_req->payload = msn_soap_abservice_build( SOAP_AB_NAMECHANGE_PAYLOAD, + "Initial", md->tokens[1], (char *) soap_req->data ); return 1; } -- cgit v1.2.3 From 4fc95c57361193c5338d9916fd37cc8a939067cd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 14 Aug 2010 22:33:33 +0100 Subject: Add/Remove support. --- protocols/msn/soap.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 130df840..13ef7e37 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -749,3 +749,89 @@ int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char msn_soap_ab_namechange_handle_response, msn_soap_ab_namechange_free_data ); } + +/* Add a contact. */ +static int msn_soap_ab_contact_add_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + bee_user_t *bu = soap_req->data; + + soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); + soap_req->action = g_strdup( SOAP_AB_CONTACT_ADD_ACTION ); + soap_req->payload = msn_soap_abservice_build( SOAP_AB_CONTACT_ADD_PAYLOAD, + "ContactSave", md->tokens[1], bu->handle, bu->fullname ? bu->fullname : bu->handle ); + + return 1; +} + +static xt_status msn_soap_ab_contact_add_cid( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + bee_user_t *bu = soap_req->data; + struct msn_buddy_data *bd = bu->data; + + g_free( bd->cid ); + bd->cid = g_strdup( node->text ); + + return XT_HANDLED; +} + +static const struct xt_handler_entry msn_soap_ab_contact_add_parser[] = { + { "guid", "ABContactAddResult", msn_soap_ab_contact_add_cid }, + { NULL, NULL, NULL } +}; + +static int msn_soap_ab_contact_add_handle_response( struct msn_soap_req_data *soap_req ) +{ + /* TODO: Ack the change? Not sure what the NAKs look like.. */ + return MSN_SOAP_OK; +} + +static int msn_soap_ab_contact_add_free_data( struct msn_soap_req_data *soap_req ) +{ + return 0; +} + +int msn_soap_ab_contact_add( struct im_connection *ic, bee_user_t *bu ) +{ + return msn_soap_start( ic, bu, + msn_soap_ab_contact_add_build_request, + msn_soap_ab_contact_add_parser, + msn_soap_ab_contact_add_handle_response, + msn_soap_ab_contact_add_free_data ); +} + +/* Remove a contact. */ +static int msn_soap_ab_contact_del_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + bee_user_t *bu = soap_req->data; + struct msn_buddy_data *bd = bu->data; + + soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); + soap_req->action = g_strdup( SOAP_AB_CONTACT_DEL_ACTION ); + soap_req->payload = msn_soap_abservice_build( SOAP_AB_CONTACT_DEL_PAYLOAD, + "Timer", md->tokens[1], bd->cid ); + + return 1; +} + +static int msn_soap_ab_contact_del_handle_response( struct msn_soap_req_data *soap_req ) +{ + /* TODO: Ack the change? Not sure what the NAKs look like.. */ + return MSN_SOAP_OK; +} + +static int msn_soap_ab_contact_del_free_data( struct msn_soap_req_data *soap_req ) +{ + return 0; +} + +int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu ) +{ + return msn_soap_start( ic, bu, + msn_soap_ab_contact_del_build_request, + NULL, + msn_soap_ab_contact_del_handle_response, + msn_soap_ab_contact_del_free_data ); +} -- 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/soap.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 13ef7e37..5d641542 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -202,9 +202,7 @@ static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer dat return XT_HANDLED; id += strlen( id ) - 1; if( *id == '1' && - ( p = node->parent ) && ( p = p->parent ) && - ( p = xt_find_node( p->children, "wst:RequestedProofToken" ) ) && - ( p = xt_find_node( p->children, "wst:BinarySecret" ) ) && + ( p = xt_find_path( node, "../../wst:RequestedProofToken/wst:BinarySecret" ) ) && p->text ) sd->secret = g_strdup( p->text ); @@ -476,8 +474,7 @@ static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; - if( ( p = node->parent ) && ( p = p->parent ) && - ( p = xt_find_node( p->children, "MemberRole" ) ) ) + if( ( p = xt_find_path( node, "../../MemberRole" ) ) ) role = p->text; if( ( p = xt_find_node( node->children, "PassportName" ) ) ) @@ -635,8 +632,7 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data char *id = NULL, *name = NULL; struct msn_soap_req_data *soap_req = data; - if( ( p = node->parent ) && - ( p = xt_find_node( p->children, "groupId" ) ) ) + if( ( p = xt_find_path( node, "../groupId" ) ) ) id = p->text; if( ( p = xt_find_node( node->children, "name" ) ) ) @@ -656,8 +652,7 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; - if( ( p = node->parent ) && - ( p = xt_find_node( p->children, "contactId" ) ) ) + if( ( p = xt_find_path( node, "../contactId" ) ) ) id = p->text; if( ( p = xt_find_node( node->children, "contactType" ) ) ) type = p->text; @@ -675,6 +670,9 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da return XT_HANDLED; } + if( handle == NULL ) + return XT_HANDLED; + if( !( bu = bee_user_by_handle( ic->bee, ic, handle ) ) && !( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) return XT_HANDLED; -- cgit v1.2.3 From ff27648aee17e649cdd1e47f503271e4fccbff43 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 01:05:49 +0100 Subject: Read group info. --- protocols/msn/soap.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 5d641542..b8762ce1 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -631,6 +631,7 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data struct xt_node *p; char *id = NULL, *name = NULL; struct msn_soap_req_data *soap_req = data; + struct msn_data *md = soap_req->ic->proto_data; if( ( p = xt_find_path( node, "../groupId" ) ) ) id = p->text; @@ -638,6 +639,14 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data if( ( p = xt_find_node( node->children, "name" ) ) ) name = p->text; + if( id && name ) + { + struct msn_group *mg = g_new0( struct msn_group, 1 ); + mg->id = g_strdup( id ); + mg->name = g_strdup( name ); + md->groups = g_slist_prepend( md->groups, mg ); + } + printf( "%s %s\n", id, name ); return XT_HANDLED; @@ -648,9 +657,11 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da bee_user_t *bu; struct msn_buddy_data *bd; struct xt_node *p; - char *id = NULL, *type = NULL, *handle = NULL, *display_name = NULL; + char *id = NULL, *type = NULL, *handle = NULL, + *display_name = NULL, *group_id = NULL; struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; + struct msn_group *group; if( ( p = xt_find_path( node, "../contactId" ) ) ) id = p->text; @@ -660,6 +671,8 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da handle = p->text; if( ( p = xt_find_node( node->children, "displayName" ) ) ) display_name = p->text; + if( ( p = xt_find_path( node, "groupIds/guid" ) ) ) + group_id = p->text; if( type && g_strcasecmp( type, "me" ) == 0 ) { @@ -684,6 +697,9 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da imcb_rename_buddy( ic, handle, display_name ); + if( group_id && ( group = msn_group_by_id( ic, group_id ) ) ) + imcb_add_buddy( ic, handle, group->name ); + printf( "%s %s %s %s\n", id, type, handle, display_name ); return XT_HANDLED; -- 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/soap.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index b8762ce1..fe716d9d 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -172,6 +172,7 @@ struct msn_soap_passport_sso_data char *policy; char *nonce; char *secret; + char *error; }; static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req ) @@ -216,8 +217,25 @@ static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer dat return XT_HANDLED; } +static xt_status msn_soap_passport_failure( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + struct msn_soap_passport_sso_data *sd = soap_req->data; + struct xt_node *code = xt_find_node( node->children, "faultcode" ); + struct xt_node *string = xt_find_node( node->children, "faultstring" ); + + if( code == NULL || code->text_len == 0 ) + sd->error = g_strdup( "Unknown error" ); + else + sd->error = g_strdup_printf( "%s (%s)", code->text, string && string->text_len ? + string->text : "no description available" ); + + return XT_HANDLED; +} + static const struct xt_handler_entry msn_soap_passport_sso_parser[] = { { "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", msn_soap_passport_sso_token }, + { "S:Fault", "S:Envelope", msn_soap_passport_failure }, { NULL, NULL, NULL } }; @@ -269,6 +287,12 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap GUINT32_TO_LE( 20 ), GUINT32_TO_LE( 72 ), }; + + if( sd->secret == NULL ) + { + msn_auth_got_passport_token( ic, NULL, sd->error ); + return MSN_SOAP_OK; + } key1_len = base64_decode( sd->secret, (unsigned char**) &key1 ); @@ -286,7 +310,7 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap memcpy( blurb.cipherbytes, des3res, 72 ); blurb64 = base64_encode( (unsigned char*) &blurb, sizeof( blurb ) ); - msn_auth_got_passport_token( ic, blurb64 ); + msn_auth_got_passport_token( ic, blurb64, NULL ); g_free( padnonce ); g_free( blurb64 ); @@ -305,6 +329,7 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req ) g_free( sd->policy ); g_free( sd->nonce ); g_free( sd->secret ); + g_free( sd->error ); return MSN_SOAP_OK; } -- cgit v1.2.3 From 9b01339168bc79d08c4e371552cc44648bd8878d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Aug 2010 18:19:06 +0100 Subject: Check the flag in address book entries, ignore the ones that have it set to false, or this code will add all non-Messenger contacts to the contact list (oops). --- protocols/msn/soap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index fe716d9d..91f93afd 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -682,7 +682,7 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da bee_user_t *bu; struct msn_buddy_data *bd; struct xt_node *p; - char *id = NULL, *type = NULL, *handle = NULL, + char *id = NULL, *type = NULL, *handle = NULL, *is_msgr = "false", *display_name = NULL, *group_id = NULL; struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; @@ -696,6 +696,8 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da handle = p->text; if( ( p = xt_find_node( node->children, "displayName" ) ) ) display_name = p->text; + if( ( p = xt_find_node( node->children, "isMessengerUser" ) ) ) + is_msgr = p->text; if( ( p = xt_find_path( node, "groupIds/guid" ) ) ) group_id = p->text; @@ -708,7 +710,7 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da return XT_HANDLED; } - if( handle == NULL ) + if( !bool2int( is_msgr ) || handle == NULL ) return XT_HANDLED; if( !( bu = bee_user_by_handle( ic->bee, ic, handle ) ) && -- 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/soap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 91f93afd..b717343f 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -686,6 +686,7 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da *display_name = NULL, *group_id = NULL; struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; + struct msn_data *md = soap_req->ic->proto_data; struct msn_group *group; if( ( p = xt_find_path( node, "../contactId" ) ) ) @@ -703,6 +704,10 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da if( type && g_strcasecmp( type, "me" ) == 0 ) { +#if 0 + g_free( md->myid ); + md->myid = g_strdup( id ); +#endif set_t *set = set_find( &ic->acc->set, "display_name" ); g_free( set->value ); set->value = g_strdup( display_name ); @@ -765,7 +770,7 @@ static int msn_soap_ab_namechange_build_request( struct msn_soap_req_data *soap_ soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION ); soap_req->payload = msn_soap_abservice_build( SOAP_AB_NAMECHANGE_PAYLOAD, - "Initial", md->tokens[1], (char *) soap_req->data ); + "Timer", md->tokens[1], (char *) soap_req->data ); return 1; } -- 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/soap.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 6 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index b717343f..410ff37c 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -208,7 +208,7 @@ static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer dat sd->secret = g_strdup( p->text ); *id -= '1'; - if( *id >= 0 && *id <= 2 ) + if( *id >= 0 && *id < sizeof( md->tokens ) / sizeof( md->tokens[0] ) ) { g_free( md->tokens[(int)*id] ); md->tokens[(int)*id] = g_strdup( node->text ); @@ -686,7 +686,6 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da *display_name = NULL, *group_id = NULL; struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; - struct msn_data *md = soap_req->ic->proto_data; struct msn_group *group; if( ( p = xt_find_path( node, "../contactId" ) ) ) @@ -704,14 +703,15 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da if( type && g_strcasecmp( type, "me" ) == 0 ) { -#if 0 - g_free( md->myid ); - md->myid = g_strdup( id ); -#endif set_t *set = set_find( &ic->acc->set, "display_name" ); g_free( set->value ); set->value = g_strdup( display_name ); + /* Try to fetch the profile; if the user has one, that's where + we can find the persistent display_name. */ + if( ( p = xt_find_node( node->children, "CID" ) ) && p->text ) + msn_soap_profile_get( ic, p->text ); + return XT_HANDLED; } @@ -881,3 +881,67 @@ int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu ) msn_soap_ab_contact_del_handle_response, msn_soap_ab_contact_del_free_data ); } + + + +/* Storage stuff: Fetch profile. */ +static int msn_soap_profile_get_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + + soap_req->url = g_strdup( SOAP_STORAGE_URL ); + soap_req->action = g_strdup( SOAP_PROFILE_GET_ACTION ); + soap_req->payload = g_markup_printf_escaped( SOAP_PROFILE_GET_PAYLOAD, + md->tokens[3], (char*) soap_req->data ); + + return 1; +} + +static xt_status msn_soap_profile_get_result( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + struct im_connection *ic = soap_req->ic; + struct msn_data *md = soap_req->ic->proto_data; + struct xt_node *dn; + + if( ( dn = xt_find_node( node->children, "DisplayName" ) ) && dn->text ) + { + set_t *set = set_find( &ic->acc->set, "display_name" ); + g_free( set->value ); + set->value = g_strdup( dn->text ); + + md->flags |= MSN_GOT_PROFILE_DN; + } + + return XT_HANDLED; +} + +static const struct xt_handler_entry msn_soap_profile_get_parser[] = { + { "ExpressionProfile", "GetProfileResult", msn_soap_profile_get_result }, + { NULL, NULL, NULL } +}; + +static int msn_soap_profile_get_handle_response( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + + md->flags |= MSN_GOT_PROFILE; + msn_ns_finish_login( soap_req->ic ); + + return MSN_SOAP_OK; +} + +static int msn_soap_profile_get_free_data( struct msn_soap_req_data *soap_req ) +{ + g_free( soap_req->data ); + return 0; +} + +int msn_soap_profile_get( struct im_connection *ic, const char *cid ) +{ + return msn_soap_start( ic, g_strdup( cid ), + msn_soap_profile_get_build_request, + msn_soap_profile_get_parser, + msn_soap_profile_get_handle_response, + msn_soap_profile_get_free_data ); +} -- cgit v1.2.3 From f2520b5ad5a82d9bf08a550fb0e49913f57d4685 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Aug 2010 09:22:28 +0100 Subject: In debugging mode, dump all SOAP requests + responses with some indentation for easier debugging. --- protocols/msn/soap.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 410ff37c..6665eef1 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -67,6 +67,7 @@ struct msn_soap_req_data }; static int msn_soap_send_request( struct msn_soap_req_data *req ); +static void msn_soap_debug_print( const char *headers, const char *payload ); static int msn_soap_start( struct im_connection *ic, void *data, @@ -106,6 +107,8 @@ static int msn_soap_send_request( struct msn_soap_req_data *soap_req ) soap_action ? soap_action : "", strlen( soap_req->payload ), soap_req->payload ); + msn_soap_debug_print( http_req, soap_req->payload ); + soap_req->http_req = http_dorequest( url.host, url.port, url.proto == PROTO_HTTPS, http_req, msn_soap_handle_response, soap_req ); @@ -130,6 +133,8 @@ static void msn_soap_handle_response( struct http_request *http_req ) xt_free( parser ); } + msn_soap_debug_print( http_req->reply_headers, http_req->reply_body ); + st = soap_req->handle_response( soap_req ); g_free( soap_req->url ); @@ -164,6 +169,28 @@ static char *msn_soap_abservice_build( const char *body_fmt, const char *scenari return ret; } +static void msn_soap_debug_print( const char *headers, const char *payload ) +{ + char *s; + + if( !getenv( "BITLBEE_DEBUG" ) ) + return; + + if( ( s = strstr( headers, "\r\n\r\n" ) ) ) + write( 1, s, s - headers + 4 ); + else + write( 1, headers, strlen( headers ) ); + +#ifdef DEBUG + { + struct xt_node *xt = xt_from_string( payload ); + if( xt ) + xt_print( xt ); + xt_free_node( xt ); + } +#endif +} + /* passport_sso: Authentication MSNP15+ */ -- cgit v1.2.3 From 801b90b3e76f6eed7027f46a7d11e3d3fe0e04e9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Aug 2010 20:30:12 +0100 Subject: Check if a connection is down before handling its SOAP responses. --- protocols/msn/soap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 6665eef1..e67da2a1 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -123,6 +123,16 @@ static void msn_soap_handle_response( struct http_request *http_req ) struct msn_soap_req_data *soap_req = http_req->data; int st; + if( g_slist_find( msn_connections, soap_req->ic ) == NULL ) + { + soap_req->free_data( soap_req ); + g_free( soap_req->url ); + g_free( soap_req->action ); + g_free( soap_req->payload ); + g_free( soap_req ); + return; + } + if( http_req->body_size > 0 ) { struct xt_parser *parser; -- cgit v1.2.3 From 327af51a28fe292cfc4a68caa086a13175a69719 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Aug 2010 18:27:32 +0100 Subject: Some general cleanup, plus fixing a bug in the memberlist parsing code: the lists can come in in any order, so parse it *completely* before showing auth requests. --- protocols/msn/soap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index e67da2a1..8d276108 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -553,17 +553,11 @@ static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) else if( strcmp( role, "Block" ) == 0 ) bd->flags |= MSN_BUDDY_BL; else if( strcmp( role, "Reverse" ) == 0 ) - { bd->flags |= MSN_BUDDY_RL; - msn_buddy_ask( bu ); - } else if( strcmp( role, "Pending" ) == 0 ) - { bd->flags |= MSN_BUDDY_PL; - msn_buddy_ask( bu ); - } - printf( "%s %d\n", handle, bd->flags ); + printf( "%p %s %d\n", bu, handle, bd->flags ); return XT_HANDLED; } @@ -782,7 +776,18 @@ static const struct xt_handler_entry msn_soap_addressbook_parser[] = { static int msn_soap_addressbook_handle_response( struct msn_soap_req_data *soap_req ) { + GSList *l; + + for( l = soap_req->ic->bee->users; l; l = l->next ) + { + struct bee_user *bu = l->data; + + if( bu->ic == soap_req->ic ) + msn_buddy_ask( bu ); + } + msn_auth_got_contact_list( soap_req->ic ); + return MSN_SOAP_OK; } -- 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/soap.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 8d276108..592dbd4f 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -136,9 +136,24 @@ static void msn_soap_handle_response( struct http_request *http_req ) if( http_req->body_size > 0 ) { struct xt_parser *parser; + struct xt_node *err; parser = xt_new( soap_req->xml_parser, soap_req ); xt_feed( parser, http_req->reply_body, http_req->body_size ); + if( http_req->status_code == 500 && + ( err = xt_find_path( parser->root, "soap:Body/soap:Fault/detail/errorcode" ) ) && + err->text_len > 0 && strcmp( err->text, "PassportAuthFail" ) == 0 ) + { + struct msn_data *md = soap_req->ic->proto_data; + + xt_free( parser ); + if( md->auth->fd == -1 ) + msn_ns_connect( soap_req->ic, md->auth, MSN_NS_HOST, MSN_NS_PORT ); + md->soapq = g_slist_prepend( md->soapq, soap_req ); + + return; + } + xt_handle( parser, NULL, -1 ); xt_free( parser ); } @@ -201,12 +216,24 @@ static void msn_soap_debug_print( const char *headers, const char *payload ) #endif } +static int msn_soapq_empty( struct im_connection *ic ) +{ + struct msn_data *md = ic->proto_data; + + while( md->soapq ) + { + msn_soap_send_request( (struct msn_soap_req_data*) md->soapq->data ); + md->soapq = g_slist_remove( md->soapq, md->soapq->data ); + } + + return MSN_SOAP_OK; +} + /* passport_sso: Authentication MSNP15+ */ struct msn_soap_passport_sso_data { - char *policy; char *nonce; char *secret; char *error; @@ -216,6 +243,7 @@ static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_r { struct msn_soap_passport_sso_data *sd = soap_req->data; struct im_connection *ic = soap_req->ic; + struct msn_data *md = ic->proto_data; if( g_str_has_suffix( ic->acc->user, "@msn.com" ) ) soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL_MSN ); @@ -223,7 +251,7 @@ static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_r soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL ); soap_req->payload = g_markup_printf_escaped( SOAP_PASSPORT_SSO_PAYLOAD, - ic->acc->user, ic->acc->pass, sd->policy ); + ic->acc->user, ic->acc->pass, md->pp_policy ); return MSN_SOAP_OK; } @@ -300,6 +328,7 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap { struct msn_soap_passport_sso_data *sd = soap_req->data; struct im_connection *ic = soap_req->ic; + struct msn_data *md = ic->proto_data; char *key1, *key2, *key3, *blurb64; int key1_len; unsigned char *padnonce, *des3res; @@ -325,6 +354,9 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap GUINT32_TO_LE( 72 ), }; + if( md->soapq ) + return msn_soapq_empty( ic ); + if( sd->secret == NULL ) { msn_auth_got_passport_token( ic, NULL, sd->error ); @@ -363,7 +395,6 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req ) { struct msn_soap_passport_sso_data *sd = soap_req->data; - g_free( sd->policy ); g_free( sd->nonce ); g_free( sd->secret ); g_free( sd->error ); @@ -371,11 +402,10 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req ) return MSN_SOAP_OK; } -int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ) +int msn_soap_passport_sso_request( struct im_connection *ic, const char *nonce ) { struct msn_soap_passport_sso_data *sd = g_new0( struct msn_soap_passport_sso_data, 1 ); - sd->policy = g_strdup( policy ); sd->nonce = g_strdup( nonce ); return msn_soap_start( ic, sd, msn_soap_passport_sso_build_request, -- 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/soap.c | 67 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 23 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 592dbd4f..2c26271b 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -47,6 +47,7 @@ typedef enum { MSN_SOAP_OK, MSN_SOAP_RETRY, + MSN_SOAP_REAUTH, MSN_SOAP_ABORT, } msn_soap_result_t; @@ -133,6 +134,8 @@ static void msn_soap_handle_response( struct http_request *http_req ) return; } + msn_soap_debug_print( http_req->reply_headers, http_req->reply_body ); + if( http_req->body_size > 0 ) { struct xt_parser *parser; @@ -142,33 +145,45 @@ static void msn_soap_handle_response( struct http_request *http_req ) xt_feed( parser, http_req->reply_body, http_req->body_size ); if( http_req->status_code == 500 && ( err = xt_find_path( parser->root, "soap:Body/soap:Fault/detail/errorcode" ) ) && - err->text_len > 0 && strcmp( err->text, "PassportAuthFail" ) == 0 ) + err->text_len > 0 ) { - struct msn_data *md = soap_req->ic->proto_data; - - xt_free( parser ); - if( md->auth->fd == -1 ) - msn_ns_connect( soap_req->ic, md->auth, MSN_NS_HOST, MSN_NS_PORT ); - md->soapq = g_slist_prepend( md->soapq, soap_req ); - - return; + if( strcmp( err->text, "PassportAuthFail" ) == 0 ) + { + xt_free( parser ); + st = MSN_SOAP_REAUTH; + goto fail; + } + /* TODO: Handle/report other errors. */ } xt_handle( parser, NULL, -1 ); xt_free( parser ); } - msn_soap_debug_print( http_req->reply_headers, http_req->reply_body ); - st = soap_req->handle_response( soap_req ); - + +fail: g_free( soap_req->url ); g_free( soap_req->action ); g_free( soap_req->payload ); soap_req->url = soap_req->action = soap_req->payload = NULL; if( st == MSN_SOAP_RETRY && --soap_req->ttl ) + { msn_soap_send_request( soap_req ); + } + else if( st == MSN_SOAP_REAUTH ) + { + struct msn_data *md = soap_req->ic->proto_data; + + if( !( md->flags & MSN_REAUTHING ) ) + { + /* Nonce shouldn't actually be touched for re-auths. */ + msn_soap_passport_sso_request( soap_req->ic, "blaataap" ); + md->flags |= MSN_REAUTHING; + } + md->soapq = g_slist_append( md->soapq, soap_req ); + } else { soap_req->free_data( soap_req ); @@ -241,7 +256,6 @@ struct msn_soap_passport_sso_data static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req ) { - struct msn_soap_passport_sso_data *sd = soap_req->data; struct im_connection *ic = soap_req->ic; struct msn_data *md = ic->proto_data; @@ -422,7 +436,7 @@ struct msn_soap_oim_send_data char *to; char *msg; int number; - int need_retry; + msn_soap_result_t need_retry; }; static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) @@ -443,28 +457,36 @@ static int msn_soap_oim_build_request( struct msn_soap_req_data *soap_req ) oim->number, oim->number, oim->msg ); g_free( display_name_b64 ); + oim->need_retry = MSN_SOAP_OK; return MSN_SOAP_OK; } -static xt_status msn_soap_oim_send_challenge( struct xt_node *node, gpointer data ) +static xt_status msn_soap_oim_reauth( struct xt_node *node, gpointer data ) { struct msn_soap_req_data *soap_req = data; struct msn_soap_oim_send_data *oim = soap_req->data; struct im_connection *ic = soap_req->ic; struct msn_data *md = ic->proto_data; + struct xt_node *c; - g_free( md->lock_key ); - md->lock_key = msn_p11_challenge( node->text ); - - oim->need_retry = 1; + if( ( c = xt_find_node( node->children, "LockKeyChallenge" ) ) && c->text_len > 0 ) + { + g_free( md->lock_key ); + md->lock_key = msn_p11_challenge( c->text ); + oim->need_retry = MSN_SOAP_RETRY; + } + if( xt_find_node( node->children, "RequiredAuthPolicy" ) ) + { + oim->need_retry = MSN_SOAP_REAUTH; + } return XT_HANDLED; } static const struct xt_handler_entry msn_soap_oim_send_parser[] = { - { "LockKeyChallenge", "detail", msn_soap_oim_send_challenge }, - { NULL, NULL, NULL } + { "detail", "soap:Fault", msn_soap_oim_reauth }, + { NULL, NULL, NULL } }; static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req ) @@ -473,8 +495,7 @@ static int msn_soap_oim_handle_response( struct msn_soap_req_data *soap_req ) if( soap_req->http_req->status_code == 500 && oim->need_retry && soap_req->ttl > 0 ) { - oim->need_retry = 0; - return MSN_SOAP_RETRY; + return oim->need_retry; } else if( soap_req->http_req->status_code == 200 ) { -- cgit v1.2.3 From 4e1be76617060e89795e381d356f81cd2cbf32dc Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 4 Sep 2010 18:23:46 +0100 Subject: Clean up any stuff stuck in the soap queue at disconnect time. --- protocols/msn/soap.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 2c26271b..05d91109 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -68,6 +68,7 @@ struct msn_soap_req_data }; static int msn_soap_send_request( struct msn_soap_req_data *req ); +static void msn_soap_free( struct msn_soap_req_data *soap_req ); static void msn_soap_debug_print( const char *headers, const char *payload ); static int msn_soap_start( struct im_connection *ic, @@ -126,11 +127,7 @@ static void msn_soap_handle_response( struct http_request *http_req ) if( g_slist_find( msn_connections, soap_req->ic ) == NULL ) { - soap_req->free_data( soap_req ); - g_free( soap_req->url ); - g_free( soap_req->action ); - g_free( soap_req->payload ); - g_free( soap_req ); + msn_soap_free( soap_req ); return; } @@ -231,19 +228,31 @@ static void msn_soap_debug_print( const char *headers, const char *payload ) #endif } -static int msn_soapq_empty( struct im_connection *ic ) +int msn_soapq_flush( struct im_connection *ic, gboolean resend ) { struct msn_data *md = ic->proto_data; while( md->soapq ) { - msn_soap_send_request( (struct msn_soap_req_data*) md->soapq->data ); + if( resend ) + msn_soap_send_request( (struct msn_soap_req_data*) md->soapq->data ); + else + msn_soap_free( (struct msn_soap_req_data*) md->soapq->data ); md->soapq = g_slist_remove( md->soapq, md->soapq->data ); } return MSN_SOAP_OK; } +static void msn_soap_free( struct msn_soap_req_data *soap_req ) +{ + soap_req->free_data( soap_req ); + g_free( soap_req->url ); + g_free( soap_req->action ); + g_free( soap_req->payload ); + g_free( soap_req ); +} + /* passport_sso: Authentication MSNP15+ */ @@ -369,7 +378,7 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap }; if( md->soapq ) - return msn_soapq_empty( ic ); + return msn_soapq_flush( ic, TRUE ); if( sd->secret == NULL ) { -- cgit v1.2.3 From 2c6b0f4dbc367963d21314636c4b114dc7aadd32 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 5 Sep 2010 15:09:43 +0100 Subject: Fix auth for @msn.com accounts. --- protocols/msn/soap.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 05d91109..21e9feec 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -261,14 +261,21 @@ struct msn_soap_passport_sso_data char *nonce; char *secret; char *error; + char *redirect; }; static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req ) { + struct msn_soap_passport_sso_data *sd = soap_req->data; struct im_connection *ic = soap_req->ic; struct msn_data *md = ic->proto_data; - if( g_str_has_suffix( ic->acc->user, "@msn.com" ) ) + if( sd->redirect ) + { + soap_req->url = sd->redirect; + sd->redirect = NULL; + } + else if( g_str_has_suffix( ic->acc->user, "@msn.com" ) ) soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL_MSN ); else soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL ); @@ -311,9 +318,14 @@ static xt_status msn_soap_passport_failure( struct xt_node *node, gpointer data struct msn_soap_passport_sso_data *sd = soap_req->data; struct xt_node *code = xt_find_node( node->children, "faultcode" ); struct xt_node *string = xt_find_node( node->children, "faultstring" ); + struct xt_node *url; if( code == NULL || code->text_len == 0 ) sd->error = g_strdup( "Unknown error" ); + else if( strcmp( code->text, "psf:Redirect" ) == 0 && + ( url = xt_find_node( node->children, "psf:redirectUrl" ) ) && + url->text_len > 0 ) + sd->redirect = g_strdup( url->text ); else sd->error = g_strdup_printf( "%s (%s)", code->text, string && string->text_len ? string->text : "no description available" ); @@ -377,6 +389,9 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap GUINT32_TO_LE( 72 ), }; + if( sd->redirect ) + return MSN_SOAP_RETRY; + if( md->soapq ) return msn_soapq_flush( ic, TRUE ); @@ -421,6 +436,7 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req ) g_free( sd->nonce ); g_free( sd->secret ); g_free( sd->error ); + g_free( sd->redirect ); return MSN_SOAP_OK; } -- cgit v1.2.3 From 52f5e90f166179d461e29af98d8b2852d9f12be0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 1 Oct 2010 21:21:50 -0700 Subject: Fixed possible crash bug on removing contacts while the auth cookie expired. --- protocols/msn/soap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 21e9feec..baa73718 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -969,13 +969,12 @@ int msn_soap_ab_contact_add( struct im_connection *ic, bee_user_t *bu ) static int msn_soap_ab_contact_del_build_request( struct msn_soap_req_data *soap_req ) { struct msn_data *md = soap_req->ic->proto_data; - bee_user_t *bu = soap_req->data; - struct msn_buddy_data *bd = bu->data; + const char *cid = soap_req->data; soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); soap_req->action = g_strdup( SOAP_AB_CONTACT_DEL_ACTION ); soap_req->payload = msn_soap_abservice_build( SOAP_AB_CONTACT_DEL_PAYLOAD, - "Timer", md->tokens[1], bd->cid ); + "Timer", md->tokens[1], cid ); return 1; } @@ -988,12 +987,15 @@ static int msn_soap_ab_contact_del_handle_response( struct msn_soap_req_data *so static int msn_soap_ab_contact_del_free_data( struct msn_soap_req_data *soap_req ) { + g_free( soap_req->data ); return 0; } int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu ) { - return msn_soap_start( ic, bu, + struct msn_buddy_data *bd = bu->data; + + return msn_soap_start( ic, g_strdup( bd->cid ), msn_soap_ab_contact_del_build_request, NULL, msn_soap_ab_contact_del_handle_response, -- cgit v1.2.3 From ed86165b5681b7c3ed8a7b2ce8bda0dafd6fcd52 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 1 Oct 2010 21:22:57 -0700 Subject: Silence some debugging stuff that was still going to stdout. --- protocols/msn/soap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index baa73718..63e5c638 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -633,7 +633,8 @@ static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) else if( strcmp( role, "Pending" ) == 0 ) bd->flags |= MSN_BUDDY_PL; - printf( "%p %s %d\n", bu, handle, bd->flags ); + if( getenv( "BITLBEE_DEBUG" ) ) + printf( "%p %s %d\n", bu, handle, bd->flags ); return XT_HANDLED; } @@ -779,7 +780,8 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data md->groups = g_slist_prepend( md->groups, mg ); } - printf( "%s %s\n", id, name ); + if( getenv( "BITLBEE_DEBUG" ) ) + printf( "%s %s\n", id, name ); return XT_HANDLED; } @@ -839,7 +841,8 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da if( group_id && ( group = msn_group_by_id( ic, group_id ) ) ) imcb_add_buddy( ic, handle, group->name ); - printf( "%s %s %s %s\n", id, type, handle, display_name ); + if( getenv( "BITLBEE_DEBUG" ) ) + printf( "%s %s %s %s\n", id, type, handle, display_name ); return XT_HANDLED; } -- cgit v1.2.3 From 04cd284bce74c114fde3043c951a5c8ef9eb79ae Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 1 Oct 2010 22:19:27 -0700 Subject: Export block/allow list again. The way this is done is ugly though and needs to change. --- protocols/msn/soap.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'protocols/msn/soap.c') diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 63e5c638..a1b5be76 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -625,9 +625,15 @@ static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) bd = bu->data; if( strcmp( role, "Allow" ) == 0 ) + { bd->flags |= MSN_BUDDY_AL; + ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) ); + } else if( strcmp( role, "Block" ) == 0 ) + { bd->flags |= MSN_BUDDY_BL; + ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) ); + } else if( strcmp( role, "Reverse" ) == 0 ) bd->flags |= MSN_BUDDY_RL; else if( strcmp( role, "Pending" ) == 0 ) -- cgit v1.2.3