Changeset 193dc74


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

Responses to add requests work now.

Location:
protocols/msn
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    re5854a8 r193dc74  
    217217        struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who );
    218218       
    219         msn_buddy_list_add( ic, "FL", who, who, group );
     219        msn_buddy_list_add( ic, MSN_BUDDY_FL, who, who, group );
    220220        if( bu && bu->group )
    221                 msn_buddy_list_remove( ic, "FL", who, bu->group->name );
     221                msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, bu->group->name );
    222222}
    223223
    224224static void msn_remove_buddy( struct im_connection *ic, char *who, char *group )
    225225{
    226         msn_buddy_list_remove( ic, "FL", who, NULL );
     226        msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, NULL );
    227227}
    228228
     
    289289static void msn_add_permit( struct im_connection *ic, char *who )
    290290{
    291         msn_buddy_list_add( ic, "AL", who, who, NULL );
     291        msn_buddy_list_add( ic, MSN_BUDDY_AL, who, who, NULL );
    292292}
    293293
    294294static void msn_rem_permit( struct im_connection *ic, char *who )
    295295{
    296         msn_buddy_list_remove( ic, "AL", who, NULL );
     296        msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL );
    297297}
    298298
     
    301301        struct msn_switchboard *sb;
    302302       
    303         msn_buddy_list_add( ic, "BL", who, who, NULL );
     303        msn_buddy_list_add( ic, MSN_BUDDY_BL, who, who, NULL );
    304304       
    305305        /* If there's still a conversation with this person, close it. */
     
    312312static void msn_rem_deny( struct im_connection *ic, char *who )
    313313{
    314         msn_buddy_list_remove( ic, "BL", who, NULL );
     314        msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL );
    315315}
    316316
  • protocols/msn/msn.h

    re5854a8 r193dc74  
    201201int msn_write( struct im_connection *ic, char *s, int len );
    202202int msn_logged_in( struct im_connection *ic );
    203 int msn_buddy_list_add( struct im_connection *ic, const char *list, const char *who, const char *realname_, const char *group );
    204 int msn_buddy_list_remove( struct im_connection *ic, char *list, const char *who, const char *group );
     203int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group );
     204int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group );
    205205void msn_buddy_ask( bee_user_t *bu );
    206206char *msn_findheader( char *text, char *header, int len );
  • protocols/msn/msn_util.c

    re5854a8 r193dc74  
    2727#include "msn.h"
    2828#include "md5.h"
     29#include "soap.h"
    2930#include <ctype.h>
    3031
     
    5859}
    5960
    60 int msn_buddy_list_add( struct im_connection *ic, const char *list, const char *who, const char *realname_, const char *group )
     61static char *adlrml_entry( const char *handle_, msn_buddy_flags_t list )
     62{
     63        char *domain, handle[strlen(handle_)+1];
     64       
     65        strcpy( handle, handle_ );
     66        if( ( domain = strchr( handle, '@' ) ) )
     67                *(domain
     68                ++) = '\0';
     69        else
     70                return NULL;
     71       
     72        return g_markup_printf_escaped( "<ml><d n=\"%s\"><c n=\"%s\" l=\"%d\" t=\"1\"/></d></ml>",
     73                domain, handle, list );
     74}
     75
     76int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group )
    6177{
    6278        struct msn_data *md = ic->proto_data;
    63         char buf[1024], realname[strlen(realname_)*3+1], groupid[8];
     79        char buf[1024], groupid[8];
     80        bee_user_t *bu;
     81        struct msn_buddy_data *bd;
     82        char *adl;
    6483       
    6584        *groupid = '\0';
     85#if 0
    6686        if( group )
    6787        {
     
    109129                }
    110130        }
    111        
    112         strcpy( realname, realname_ );
    113         http_encode( realname );
    114         g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s%s\r\n", ++md->trId, list, who, realname, groupid );
    115        
    116         return msn_write( ic, buf, strlen( buf ) );
    117 }
    118 
    119 int msn_buddy_list_remove( struct im_connection *ic, char *list, const char *who, const char *group )
     131#endif
     132       
     133        if( !( bu = bee_user_by_handle( ic->bee, ic, who ) ) ||
     134            !( bd = bu->data ) || bd->flags & list )
     135                return 1;
     136       
     137        bd->flags |= list;
     138       
     139        msn_soap_memlist_edit( ic, who, TRUE, list );
     140       
     141        if( ( adl = adlrml_entry( who, list ) ) )
     142        {
     143                g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n%s",
     144                            ++md->trId, strlen( adl ), adl );
     145                g_free( adl );
     146               
     147                return msn_write( ic, buf, strlen( buf ) );
     148        }
     149}
     150
     151int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group )
    120152{
    121153        struct msn_data *md = ic->proto_data;
    122154        char buf[1024], groupid[8];
     155        bee_user_t *bu;
     156        struct msn_buddy_data *bd;
     157        char *adl;
    123158       
    124159        *groupid = '\0';
     160#if 0
    125161        if( group )
    126162        {
     
    133169                        }
    134170        }
    135        
    136         g_snprintf( buf, sizeof( buf ), "REM %d %s %s%s\r\n", ++md->trId, list, who, groupid );
    137         if( msn_write( ic, buf, strlen( buf ) ) )
    138                 return( 1 );
     171#endif
     172       
     173        if( !( bu = bee_user_by_handle( ic->bee, ic, who ) ) ||
     174            !( bd = bu->data ) || !( bd->flags & list ) )
     175                return 1;
     176       
     177        bd->flags &= ~list;
     178       
     179        msn_soap_memlist_edit( ic, who, FALSE, list );
     180       
     181        if( ( adl = adlrml_entry( who, list ) ) )
     182        {
     183                g_snprintf( buf, sizeof( buf ), "RML %d %zd\r\n%s",
     184                            ++md->trId, strlen( adl ), adl );
     185                g_free( adl );
     186               
     187                return msn_write( ic, buf, strlen( buf ) );
     188        }
    139189       
    140190        return( 0 );
     
    152202        struct msn_buddy_ask_data *bla = data;
    153203       
    154         msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname, NULL );
     204        msn_buddy_list_add( bla->ic, MSN_BUDDY_AL, bla->handle, bla->realname, NULL );
    155205       
    156206        imcb_ask_add( bla->ic, bla->handle, NULL );
     
    165215        struct msn_buddy_ask_data *bla = data;
    166216       
    167         msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname, NULL );
     217        msn_buddy_list_add( bla->ic, MSN_BUDDY_BL, bla->handle, bla->realname, NULL );
    168218       
    169219        g_free( bla->handle );
  • protocols/msn/ns.c

    re5854a8 r193dc74  
    264264                {
    265265                        char buf[1024];
    266                         char *fn_raw = set_getstr( &ic->acc->set, "display_name" );
     266                        char *fn_raw;
    267267                        char *fn;
    268268                       
    269                         if( fn_raw == NULL )
     269                        if( ic->flags & OPT_LOGGED_IN )
     270                                return 1;
     271                       
     272                        if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL )
    270273                                fn_raw = ic->acc->user;
    271274                        fn = g_malloc( strlen( fn_raw ) * 3 + 1 );
  • protocols/msn/soap.c

    re5854a8 r193dc74  
    517517}
    518518
     519/* Variant: Adding/Removing people */
     520struct msn_soap_memlist_edit_data
     521{
     522        char *handle;
     523        gboolean add;
     524        msn_buddy_flags_t list;
     525};
     526
     527static int msn_soap_memlist_edit_build_request( struct msn_soap_req_data *soap_req )
     528{
     529        struct msn_data *md = soap_req->ic->proto_data;
     530        struct msn_soap_memlist_edit_data *med = soap_req->data;
     531        char *add, *scenario, *list;
     532       
     533        soap_req->url = g_strdup( SOAP_MEMLIST_URL );
     534        if( med->add )
     535        {
     536                soap_req->action = g_strdup( SOAP_MEMLIST_ADD_ACTION );
     537                add = "Add";
     538        }
     539        else
     540        {
     541                soap_req->action = g_strdup( SOAP_MEMLIST_DEL_ACTION );
     542                add = "Delete";
     543        }
     544        switch( med->list )
     545        {
     546        case MSN_BUDDY_AL:
     547                scenario = "BlockUnblock";
     548                list = "Allow";
     549                break;
     550        case MSN_BUDDY_BL:
     551                scenario = "BlockUnblock";
     552                list = "Block";
     553                break;
     554        case MSN_BUDDY_RL:
     555                scenario = "Timer";
     556                list = "Reverse";
     557                break;
     558        case MSN_BUDDY_PL:
     559        default:
     560                scenario = "Timer";
     561                list = "Pending";
     562                break;
     563        }
     564        soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_EDIT_PAYLOAD,
     565                scenario, md->tokens[1], add, list, med->handle, add );
     566       
     567        return 1;
     568}
     569
     570static int msn_soap_memlist_edit_handle_response( struct msn_soap_req_data *soap_req )
     571{
     572        return MSN_SOAP_OK;
     573}
     574
     575static int msn_soap_memlist_edit_free_data( struct msn_soap_req_data *soap_req )
     576{
     577        struct msn_soap_memlist_edit_data *med = soap_req->data;
     578       
     579        g_free( med->handle );
     580        g_free( med );
     581       
     582        return 0;
     583}
     584
     585int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list )
     586{
     587        struct msn_soap_memlist_edit_data *med;
     588       
     589        med = g_new0( struct msn_soap_memlist_edit_data, 1 );
     590        med->handle = g_strdup( handle );
     591        med->add = add;
     592        med->list = list;
     593       
     594        return msn_soap_start( ic, med, msn_soap_memlist_edit_build_request,
     595                                        NULL,
     596                                        msn_soap_memlist_edit_handle_response,
     597                                        msn_soap_memlist_edit_free_data );
     598}
     599
    519600
    520601/* addressbook: Fetching the membership list (NOT address book) */
  • protocols/msn/soap.h

    re5854a8 r193dc74  
    190190"</soap:Envelope>"
    191191
     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 \
     196"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
     197"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     198  "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     199    "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     200      "<ApplicationId xmlns=\"http://www.msn.com/webservices/AddressBook\">CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \
     201      "<IsMigration xmlns=\"http://www.msn.com/webservices/AddressBook\">false</IsMigration>" \
     202      "<PartnerScenario xmlns=\"http://www.msn.com/webservices/AddressBook\">%s</PartnerScenario>" \
     203    "</ABApplicationHeader>" \
     204    "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     205      "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \
     206      "<TicketToken>%s</TicketToken>" \
     207    "</ABAuthHeader>" \
     208  "</soap:Header>" \
     209  "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     210  "<%sMember xmlns=\"http://www.msn.com/webservices/AddressBook\">" \
     211   "<serviceHandle>" \
     212    "<Id>0</Id>" \
     213    "<Type>Messenger</Type>" \
     214    "<ForeignId></ForeignId>" \
     215   "</serviceHandle>" \
     216   "<memberships>" \
     217    "<Membership>" \
     218     "<MemberRole>%s</MemberRole>" \
     219     "<Members>" \
     220      "<Member xsi:type=\"PassportMember\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" \
     221       "<Type>Passport</Type>" \
     222       "<State>Accepted</State>" \
     223       "<PassportName>%s</PassportName>" \
     224      "</Member>" \
     225     "</Members>" \
     226    "</Membership>" \
     227   "</memberships>" \
     228  "</%sMember>" \
     229  "</soap:Body>" \
     230"</soap:Envelope>"
     231
    192232int msn_soap_memlist_request( struct im_connection *ic );
     233int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list );
    193234
    194235
Note: See TracChangeset for help on using the changeset viewer.