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/msn_util.c | 4 ++- protocols/msn/soap.c | 28 +++++++++++++++---- protocols/msn/soap.h | 71 +++++++++--------------------------------------- 3 files changed, 39 insertions(+), 64 deletions(-) (limited to 'protocols') diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 54bfad7f..b7fdda28 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -146,6 +146,8 @@ int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const return msn_write( ic, buf, strlen( buf ) ); } + + return 1; } int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ) @@ -187,7 +189,7 @@ int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, con return msn_write( ic, buf, strlen( buf ) ); } - return( 0 ); + return 1; } struct msn_buddy_ask_data 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; } diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h index 9ef68df9..8ce893df 100644 --- a/protocols/msn/soap.h +++ b/protocols/msn/soap.h @@ -166,17 +166,14 @@ int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ); -#define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx" -#define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership" - -#define SOAP_MEMLIST_PAYLOAD \ +#define SOAP_ABSERVICE_PAYLOAD \ "" \ "" \ "" \ "" \ "CFE80F9D-180F-4399-82AB-413F33A1FA11" \ "false" \ - "Initial" \ + "%s" \ "" \ "" \ "false" \ @@ -184,29 +181,21 @@ int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ); "" \ "" \ "" \ - "MessengerInvitationSocialNetworkSpaceProfile" \ - "" \ + "%%s" \ "" \ "" +#define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx" +#define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership" + +#define SOAP_MEMLIST_PAYLOAD \ + "MessengerInvitationSocialNetworkSpaceProfile" \ + "" + #define SOAP_MEMLIST_ADD_ACTION "http://www.msn.com/webservices/AddressBook/AddMember" #define SOAP_MEMLIST_DEL_ACTION "http://www.msn.com/webservices/AddressBook/DeleteMember" #define SOAP_MEMLIST_EDIT_PAYLOAD \ -"" \ -"" \ - "" \ - "" \ - "CFE80F9D-180F-4399-82AB-413F33A1FA11" \ - "false" \ - "%s" \ - "" \ - "" \ - "false" \ - "%s" \ - "" \ - "" \ - "" \ "<%sMember xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ "" \ "0" \ @@ -225,9 +214,7 @@ int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ); "" \ "" \ "" \ - "" \ - "" \ -"" + "" int msn_soap_memlist_request( struct im_connection *ic ); int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list ); @@ -237,46 +224,16 @@ int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolea #define SOAP_ADDRESSBOOK_ACTION "http://www.msn.com/webservices/AddressBook/ABFindAll" #define SOAP_ADDRESSBOOK_PAYLOAD \ -"" \ -"" \ - "" \ - "" \ - "CFE80F9D-180F-4399-82AB-413F33A1FA11" \ - "false" \ - "Initial" \ - "" \ - "" \ - "false" \ - "%s" \ - "" \ - "" \ - "" \ "" \ "00000000-0000-0000-0000-000000000000" \ "Full" \ "false" \ "0001-01-01T00:00:00.0000000-08:00" \ - "" \ - "" \ -"" + "" #define SOAP_AB_NAMECHANGE_ACTION "http://www.msn.com/webservices/AddressBook/ABContactUpdate" #define SOAP_AB_NAMECHANGE_PAYLOAD \ -"" \ -"" \ - "" \ - "" \ - "CFE80F9D-180F-4399-82AB-413F33A1FA11" \ - "false" \ - "Initial" \ - "" \ - "" \ - "false" \ - "%s" \ - "" \ - "" \ - "" \ "" \ "00000000-0000-0000-0000-000000000000" \ "" \ @@ -288,9 +245,7 @@ int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolea "DisplayName" \ "" \ "" \ - "" \ - "" \ -"" + "" int msn_soap_addressbook_request( struct im_connection *ic ); int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new ); -- cgit v1.2.3