Changeset 4fc95c5 for protocols


Ignore:
Timestamp:
2010-08-14T21:33:33Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d912fe4
Parents:
6ddb223
Message:

Add/Remove support.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r6ddb223 r4fc95c5  
    7474}
    7575
    76 int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group )
     76int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname, const char *group )
    7777{
    7878        struct msn_data *md = ic->proto_data;
     
    131131#endif
    132132       
    133         if( !( bu = bee_user_by_handle( ic->bee, ic, who ) ) ||
     133        if( !( ( bu = bee_user_by_handle( ic->bee, ic, who ) ) ||
     134               ( bu = bee_user_new( ic->bee, ic, who, 0 ) ) ) ||
    134135            !( bd = bu->data ) || bd->flags & list )
    135136                return 1;
     
    137138        bd->flags |= list;
    138139       
    139         msn_soap_memlist_edit( ic, who, TRUE, list );
     140        if( list == MSN_BUDDY_FL )
     141                msn_soap_ab_contact_add( ic, bu );
     142        else
     143                msn_soap_memlist_edit( ic, who, TRUE, list );
    140144       
    141145        if( ( adl = adlrml_entry( who, list ) ) )
     
    179183        bd->flags &= ~list;
    180184       
    181         msn_soap_memlist_edit( ic, who, FALSE, list );
     185        if( list == MSN_BUDDY_FL )
     186                msn_soap_ab_contact_del( ic, bu );
     187        else
     188                msn_soap_memlist_edit( ic, who, FALSE, list );
    182189       
    183190        if( ( adl = adlrml_entry( who, list ) ) )
  • protocols/msn/soap.c

    r6ddb223 r4fc95c5  
    750750                               msn_soap_ab_namechange_free_data );
    751751}
     752
     753/* Add a contact. */
     754static int msn_soap_ab_contact_add_build_request( struct msn_soap_req_data *soap_req )
     755{
     756        struct msn_data *md = soap_req->ic->proto_data;
     757        bee_user_t *bu = soap_req->data;
     758       
     759        soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL );
     760        soap_req->action = g_strdup( SOAP_AB_CONTACT_ADD_ACTION );
     761        soap_req->payload = msn_soap_abservice_build( SOAP_AB_CONTACT_ADD_PAYLOAD,
     762                "ContactSave", md->tokens[1], bu->handle, bu->fullname ? bu->fullname : bu->handle );
     763       
     764        return 1;
     765}
     766
     767static xt_status msn_soap_ab_contact_add_cid( struct xt_node *node, gpointer data )
     768{
     769        struct msn_soap_req_data *soap_req = data;
     770        bee_user_t *bu = soap_req->data;
     771        struct msn_buddy_data *bd = bu->data;
     772       
     773        g_free( bd->cid );
     774        bd->cid = g_strdup( node->text );
     775       
     776        return XT_HANDLED;
     777}
     778
     779static const struct xt_handler_entry msn_soap_ab_contact_add_parser[] = {
     780        { "guid", "ABContactAddResult", msn_soap_ab_contact_add_cid },
     781        { NULL,               NULL,     NULL                        }
     782};
     783
     784static int msn_soap_ab_contact_add_handle_response( struct msn_soap_req_data *soap_req )
     785{
     786        /* TODO: Ack the change? Not sure what the NAKs look like.. */
     787        return MSN_SOAP_OK;
     788}
     789
     790static int msn_soap_ab_contact_add_free_data( struct msn_soap_req_data *soap_req )
     791{
     792        return 0;
     793}
     794
     795int msn_soap_ab_contact_add( struct im_connection *ic, bee_user_t *bu )
     796{
     797        return msn_soap_start( ic, bu,
     798                               msn_soap_ab_contact_add_build_request,
     799                               msn_soap_ab_contact_add_parser,
     800                               msn_soap_ab_contact_add_handle_response,
     801                               msn_soap_ab_contact_add_free_data );
     802}
     803
     804/* Remove a contact. */
     805static int msn_soap_ab_contact_del_build_request( struct msn_soap_req_data *soap_req )
     806{
     807        struct msn_data *md = soap_req->ic->proto_data;
     808        bee_user_t *bu = soap_req->data;
     809        struct msn_buddy_data *bd = bu->data;
     810       
     811        soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL );
     812        soap_req->action = g_strdup( SOAP_AB_CONTACT_DEL_ACTION );
     813        soap_req->payload = msn_soap_abservice_build( SOAP_AB_CONTACT_DEL_PAYLOAD,
     814                "Timer", md->tokens[1], bd->cid );
     815       
     816        return 1;
     817}
     818
     819static int msn_soap_ab_contact_del_handle_response( struct msn_soap_req_data *soap_req )
     820{
     821        /* TODO: Ack the change? Not sure what the NAKs look like.. */
     822        return MSN_SOAP_OK;
     823}
     824
     825static int msn_soap_ab_contact_del_free_data( struct msn_soap_req_data *soap_req )
     826{
     827        return 0;
     828}
     829
     830int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu )
     831{
     832        return msn_soap_start( ic, bu,
     833                               msn_soap_ab_contact_del_build_request,
     834                               NULL,
     835                               msn_soap_ab_contact_del_handle_response,
     836                               msn_soap_ab_contact_del_free_data );
     837}
  • protocols/msn/soap.h

    r6ddb223 r4fc95c5  
    248248        "</ABContactUpdate>"
    249249
     250#define SOAP_AB_CONTACT_ADD_ACTION "http://www.msn.com/webservices/AddressBook/ABContactAdd"
     251
     252#define SOAP_AB_CONTACT_ADD_PAYLOAD \
     253        "<ABContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     254            "<abId>00000000-0000-0000-0000-000000000000</abId>" \
     255            "<contacts>" \
     256                "<Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     257                    "<contactInfo>" \
     258                        "<contactType>LivePending</contactType>" \
     259                        "<passportName>%s</passportName>" \
     260                        "<isMessengerUser>true</isMessengerUser>" \
     261                        "<MessengerMemberInfo>" \
     262                            "<DisplayName>%s</DisplayName>" \
     263                        "</MessengerMemberInfo>" \
     264                    "</contactInfo>" \
     265                "</Contact>" \
     266            "</contacts>" \
     267            "<options>" \
     268                "<EnableAllowListManagement>true</EnableAllowListManagement>" \
     269            "</options>" \
     270        "</ABContactAdd>"
     271
     272#define SOAP_AB_CONTACT_DEL_ACTION "http://www.msn.com/webservices/AddressBook/ABContactDelete"
     273
     274#define SOAP_AB_CONTACT_DEL_PAYLOAD \
     275        "<ABContactDelete xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     276            "<abId>00000000-0000-0000-0000-000000000000</abId>" \
     277            "<contacts>" \
     278                "<Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     279                    "<contactId>%s</contactId>" \
     280                "</Contact>" \
     281            "</contacts>" \
     282        "</ABContactDelete>"
     283
    250284int msn_soap_addressbook_request( struct im_connection *ic );
    251285int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new );
    252 
     286int msn_soap_ab_contact_add( struct im_connection *ic, bee_user_t *bu );
     287int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu );
    253288
    254289#endif /* __SOAP_H__ */
  • protocols/msn/tables.c

    r6ddb223 r4fc95c5  
    8383        { 230, "Cannot remove that group",                              0 },
    8484        { 231, "Invalid group",                                         0 },
     85        { 240, "ADL/RML command with corrupted payload",                STATUS_FATAL },
     86        { 241, "ADL/RML command with invalid modification",             STATUS_FATAL },
    8587        { 280, "Switchboard failed",                                    STATUS_SB_FATAL },
    8688        { 281, "Transfer to switchboard failed",                        0 },
Note: See TracChangeset for help on using the changeset viewer.