Changeset 76c89dc7 for protocols


Ignore:
Timestamp:
2010-12-12T00:25:17Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8eec79d
Parents:
c775a58
Message:

Allow changing MSN display names in server-side profiles. (I.e. the changes
are finally always persistent again.)

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rc775a58 r76c89dc7  
    108108                }
    109109               
     110                g_free( md->profile_rid );
     111               
    110112                g_tree_destroy( md->domaintree );
    111113                md->domaintree = NULL;
     
    322324        struct msn_data *md = ic->proto_data;
    323325       
    324         if( strlen( value ) > 129 )
    325         {
    326                 imcb_log( ic, "Maximum name length exceeded" );
    327                 return NULL;
    328         }
    329        
    330         if( md->flags & MSN_GOT_PROFILE_DN )
    331                 imcb_log( ic, "Warning: Persistent name changes for this account have to be done "
    332                               "in the profile. BitlBee doesn't currently support this." );
    333        
    334326        if( md->flags & MSN_EMAIL_UNVERIFIED )
    335327                imcb_log( ic, "Warning: Your e-mail address is unverified. MSN doesn't allow "
    336328                              "changing your display name until your e-mail address is verified." );
    337329       
    338         msn_soap_addressbook_set_display_name( ic, value );
     330        if( md->flags & MSN_GOT_PROFILE_DN )
     331                msn_soap_profile_set_dn( ic, value );
     332        else
     333                msn_soap_addressbook_set_display_name( ic, value );
     334       
    339335        return msn_ns_set_display_name( ic, value ) ? value : NULL;
    340336}
     
    363359       
    364360        ret->name = "msn";
    365     ret->mms = 1409;         /* this guess taken from libotr UPGRADING file */
     361        ret->mms = 1409;         /* this guess taken from libotr UPGRADING file */
    366362        ret->login = msn_login;
    367363        ret->init = msn_init;
  • protocols/msn/msn.h

    rc775a58 r76c89dc7  
    119119        const struct msn_away_state *away_state;
    120120        GSList *groups;
     121        char *profile_rid;
    121122       
    122123        /* Mostly used for sending the ADL command; since MSNP13 the client
  • protocols/msn/soap.c

    rc775a58 r76c89dc7  
    398398       
    399399        if( md->soapq )
     400        {
     401                md->flags &= ~MSN_REAUTHING;
    400402                return msn_soapq_flush( ic, TRUE );
     403        }
    401404       
    402405        if( sd->secret == NULL )
     
    10721075}
    10731076
     1077static xt_status msn_soap_profile_get_rid( struct xt_node *node, gpointer data )
     1078{
     1079        struct msn_soap_req_data *soap_req = data;
     1080        struct msn_data *md = soap_req->ic->proto_data;
     1081       
     1082        g_free( md->profile_rid );
     1083        md->profile_rid = g_strdup( node->text );
     1084       
     1085        return XT_HANDLED;
     1086}
     1087
    10741088static const struct xt_handler_entry msn_soap_profile_get_parser[] = {
    10751089        { "ExpressionProfile", "GetProfileResult", msn_soap_profile_get_result },
     1090        { "ResourceID",        "GetProfileResult", msn_soap_profile_get_rid },
    10761091        { NULL,               NULL,     NULL                        }
    10771092};
     
    11011116                               msn_soap_profile_get_free_data );
    11021117}
     1118
     1119/* Update profile (display name). */
     1120static int msn_soap_profile_set_dn_build_request( struct msn_soap_req_data *soap_req )
     1121{
     1122        struct msn_data *md = soap_req->ic->proto_data;
     1123       
     1124        soap_req->url = g_strdup( SOAP_STORAGE_URL );
     1125        soap_req->action = g_strdup( SOAP_PROFILE_SET_DN_ACTION );
     1126        soap_req->payload = g_markup_printf_escaped( SOAP_PROFILE_SET_DN_PAYLOAD,
     1127                md->tokens[3], md->profile_rid, (char*) soap_req->data );
     1128       
     1129        return 1;
     1130}
     1131
     1132static const struct xt_handler_entry msn_soap_profile_set_dn_parser[] = {
     1133        { NULL,               NULL,     NULL                        }
     1134};
     1135
     1136static int msn_soap_profile_set_dn_handle_response( struct msn_soap_req_data *soap_req )
     1137{
     1138        return MSN_SOAP_OK;
     1139}
     1140
     1141static int msn_soap_profile_set_dn_free_data( struct msn_soap_req_data *soap_req )
     1142{
     1143        g_free( soap_req->data );
     1144        return 0;
     1145}
     1146
     1147int msn_soap_profile_set_dn( struct im_connection *ic, const char *dn )
     1148{
     1149        return msn_soap_start( ic, g_strdup( dn ),
     1150                               msn_soap_profile_set_dn_build_request,
     1151                               msn_soap_profile_set_dn_parser,
     1152                               msn_soap_profile_set_dn_handle_response,
     1153                               msn_soap_profile_set_dn_free_data );
     1154}
  • protocols/msn/soap.h

    rc775a58 r76c89dc7  
    303303#define SOAP_STORAGE_URL "https://storage.msn.com/storageservice/SchematizedStore.asmx"
    304304#define SOAP_PROFILE_GET_ACTION "http://www.msn.com/webservices/storage/w10/GetProfile"
     305#define SOAP_PROFILE_SET_DN_ACTION "http://www.msn.com/webservices/storage/w10/UpdateProfile"
    305306
    306307#define SOAP_PROFILE_GET_PAYLOAD \
     
    345346"</soap:Envelope>"
    346347
     348#define SOAP_PROFILE_SET_DN_PAYLOAD \
     349"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
     350"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     351  "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     352    "<StorageApplicationHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">" \
     353      "<ApplicationID>Messenger Client 9.0</ApplicationID>" \
     354      "<Scenario>Initial</Scenario>" \
     355    "</StorageApplicationHeader>" \
     356    "<StorageUserHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">" \
     357      "<Puid>0</Puid>" \
     358      "<TicketToken>%s</TicketToken>" \
     359    "</StorageUserHeader>" \
     360  "</soap:Header>" \
     361  "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \
     362    "<UpdateProfile xmlns=\"http://www.msn.com/webservices/storage/w10\">" \
     363      "<profile>" \
     364        "<ResourceID>%s</ResourceID>" \
     365        "<ExpressionProfile>" \
     366          "<FreeText>Update</FreeText>" \
     367          "<DisplayName>%s</DisplayName>" \
     368          "<Flags>0</Flags>" \
     369        "</ExpressionProfile>" \
     370      "</profile>" \
     371    "</UpdateProfile>" \
     372  "</soap:Body>" \
     373"</soap:Envelope>"
     374
    347375int msn_soap_profile_get( struct im_connection *ic, const char *cid );
    348 
     376int msn_soap_profile_set_dn( struct im_connection *ic, const char *dn );
    349377
    350378#endif /* __SOAP_H__ */
Note: See TracChangeset for help on using the changeset viewer.