Changeset 6ddb223 for protocols/msn


Ignore:
Timestamp:
2010-08-14T19:57:13Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4fc95c5
Parents:
193dc74
Message:

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).

Location:
protocols/msn
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r193dc74 r6ddb223  
    147147                return msn_write( ic, buf, strlen( buf ) );
    148148        }
     149       
     150        return 1;
    149151}
    150152
     
    188190        }
    189191       
    190         return( 0 );
     192        return 1;
    191193}
    192194
  • protocols/msn/soap.c

    r193dc74 r6ddb223  
    145145                g_free( soap_req );
    146146        }
     147}
     148
     149static char *msn_soap_abservice_build( const char *body_fmt, const char *scenario, const char *ticket, ... )
     150{
     151        va_list params;
     152        char *ret, *format, *body;
     153       
     154        format = g_markup_printf_escaped( SOAP_ABSERVICE_PAYLOAD, scenario, ticket );
     155       
     156        va_start( params, ticket );
     157        body = g_strdup_vprintf( body_fmt, params );
     158        va_end( params );
     159       
     160        ret = g_strdup_printf( format, body );
     161        g_free( body );
     162        g_free( format );
     163       
     164        return ret;
    147165}
    148166
     
    445463        soap_req->url = g_strdup( SOAP_MEMLIST_URL );
    446464        soap_req->action = g_strdup( SOAP_MEMLIST_ACTION );
    447         soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_PAYLOAD, md->tokens[1] );
     465        soap_req->payload = msn_soap_abservice_build( SOAP_MEMLIST_PAYLOAD, "Initial", md->tokens[1] );
    448466       
    449467        return 1;
     
    562580                break;
    563581        }
    564         soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_EDIT_PAYLOAD,
     582        soap_req->payload = msn_soap_abservice_build( SOAP_MEMLIST_EDIT_PAYLOAD,
    565583                scenario, md->tokens[1], add, list, med->handle, add );
    566584       
     
    607625        soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL );
    608626        soap_req->action = g_strdup( SOAP_ADDRESSBOOK_ACTION );
    609         soap_req->payload = g_markup_printf_escaped( SOAP_ADDRESSBOOK_PAYLOAD, md->tokens[1] );
     627        soap_req->payload = msn_soap_abservice_build( SOAP_ADDRESSBOOK_PAYLOAD, "Initial", md->tokens[1] );
    610628       
    611629        return 1;
     
    706724        soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL );
    707725        soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION );
    708         soap_req->payload = g_markup_printf_escaped( SOAP_AB_NAMECHANGE_PAYLOAD,
    709                 md->tokens[1], (char *) soap_req->data );
     726        soap_req->payload = msn_soap_abservice_build( SOAP_AB_NAMECHANGE_PAYLOAD,
     727                "Initial", md->tokens[1], (char *) soap_req->data );
    710728       
    711729        return 1;
  • protocols/msn/soap.h

    r193dc74 r6ddb223  
    167167
    168168
    169 #define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx"
    170 #define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership"
    171 
    172 #define SOAP_MEMLIST_PAYLOAD \
    173 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
    174 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
    175   "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
    176     "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    177       "<ApplicationId xmlns=\"http://www.msn.com/webservices/AddressBook\">CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \
    178       "<IsMigration xmlns=\"http://www.msn.com/webservices/AddressBook\">false</IsMigration>" \
    179       "<PartnerScenario xmlns=\"http://www.msn.com/webservices/AddressBook\">Initial</PartnerScenario>" \
    180     "</ABApplicationHeader>" \
    181     "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    182       "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \
    183       "<TicketToken>%s</TicketToken>" \
    184     "</ABAuthHeader>" \
    185   "</soap:Header>" \
    186   "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
    187     "<FindMembership xmlns=\"http://www.msn.com/webservices/AddressBook\"><serviceFilter xmlns=\"http://www.msn.com/webservices/AddressBook\"><Types xmlns=\"http://www.msn.com/webservices/AddressBook\"><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Messenger</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Invitation</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">SocialNetwork</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Space</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Profile</ServiceType></Types></serviceFilter>" \
    188     "</FindMembership>" \
    189   "</soap:Body>" \
    190 "</soap:Envelope>"
    191 
    192 #define SOAP_MEMLIST_ADD_ACTION "http://www.msn.com/webservices/AddressBook/AddMember"
    193 #define SOAP_MEMLIST_DEL_ACTION "http://www.msn.com/webservices/AddressBook/DeleteMember"
    194 
    195 #define SOAP_MEMLIST_EDIT_PAYLOAD \
     169#define SOAP_ABSERVICE_PAYLOAD \
    196170"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
    197171"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     
    208182  "</soap:Header>" \
    209183  "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     184    "%%s" \
     185  "</soap:Body>" \
     186"</soap:Envelope>"
     187
     188#define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx"
     189#define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership"
     190
     191#define SOAP_MEMLIST_PAYLOAD \
     192    "<FindMembership xmlns=\"http://www.msn.com/webservices/AddressBook\"><serviceFilter xmlns=\"http://www.msn.com/webservices/AddressBook\"><Types xmlns=\"http://www.msn.com/webservices/AddressBook\"><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Messenger</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Invitation</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">SocialNetwork</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Space</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Profile</ServiceType></Types></serviceFilter>" \
     193    "</FindMembership>"
     194
     195#define SOAP_MEMLIST_ADD_ACTION "http://www.msn.com/webservices/AddressBook/AddMember"
     196#define SOAP_MEMLIST_DEL_ACTION "http://www.msn.com/webservices/AddressBook/DeleteMember"
     197
     198#define SOAP_MEMLIST_EDIT_PAYLOAD \
    210199  "<%sMember xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    211200   "<serviceHandle>" \
     
    226215    "</Membership>" \
    227216   "</memberships>" \
    228   "</%sMember>" \
    229   "</soap:Body>" \
    230 "</soap:Envelope>"
     217  "</%sMember>"
    231218
    232219int msn_soap_memlist_request( struct im_connection *ic );
     
    238225
    239226#define SOAP_ADDRESSBOOK_PAYLOAD \
    240 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
    241 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">" \
    242   "<soap:Header>" \
    243     "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    244       "<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \
    245       "<IsMigration>false</IsMigration>" \
    246       "<PartnerScenario>Initial</PartnerScenario>" \
    247     "</ABApplicationHeader>" \
    248     "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    249       "<ManagedGroupRequest>false</ManagedGroupRequest>" \
    250       "<TicketToken>%s</TicketToken>" \
    251     "</ABAuthHeader>" \
    252   "</soap:Header>" \
    253   "<soap:Body>" \
    254227    "<ABFindAll xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    255228      "<abId>00000000-0000-0000-0000-000000000000</abId>" \
     
    257230      "<deltasOnly>false</deltasOnly>" \
    258231      "<lastChange>0001-01-01T00:00:00.0000000-08:00</lastChange>" \
    259     "</ABFindAll>" \
    260   "</soap:Body>" \
    261 "</soap:Envelope>"
     232    "</ABFindAll>"
    262233
    263234#define SOAP_AB_NAMECHANGE_ACTION "http://www.msn.com/webservices/AddressBook/ABContactUpdate"
    264235
    265236#define SOAP_AB_NAMECHANGE_PAYLOAD \
    266 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
    267 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">" \
    268   "<soap:Header>" \
    269     "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    270       "<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \
    271       "<IsMigration>false</IsMigration>" \
    272       "<PartnerScenario>Initial</PartnerScenario>" \
    273     "</ABApplicationHeader>" \
    274     "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    275       "<ManagedGroupRequest>false</ManagedGroupRequest>" \
    276       "<TicketToken>%s</TicketToken>" \
    277     "</ABAuthHeader>" \
    278   "</soap:Header>" \
    279     "<soap:Body>" \
    280237        "<ABContactUpdate xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
    281238            "<abId>00000000-0000-0000-0000-000000000000</abId>" \
     
    289246                "</Contact>" \
    290247            "</contacts>" \
    291         "</ABContactUpdate>" \
    292     "</soap:Body>" \
    293 "</soap:Envelope>"
     248        "</ABContactUpdate>"
    294249
    295250int msn_soap_addressbook_request( struct im_connection *ic );
Note: See TracChangeset for help on using the changeset viewer.