diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-12-12 00:25:17 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-12-12 00:25:17 +0000 |
commit | 76c89dc7e58c9d4806e83c04ab4005faa84e2703 (patch) | |
tree | febb7fa1c057d7fcc591f1c397e9af6f98c2999c | |
parent | c775a58faa7d5905b06e2f8900db7337082d5165 (diff) |
Allow changing MSN display names in server-side profiles. (I.e. the changes
are finally always persistent again.)
-rw-r--r-- | protocols/msn/msn.c | 20 | ||||
-rw-r--r-- | protocols/msn/msn.h | 1 | ||||
-rw-r--r-- | protocols/msn/soap.c | 52 | ||||
-rw-r--r-- | protocols/msn/soap.h | 30 |
4 files changed, 90 insertions, 13 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index ce1221c9..11e50fb7 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -107,6 +107,8 @@ static void msn_logout( struct im_connection *ic ) md->groups = g_slist_remove( md->groups, mg ); } + g_free( md->profile_rid ); + g_tree_destroy( md->domaintree ); md->domaintree = NULL; @@ -321,21 +323,15 @@ static char *set_eval_display_name( set_t *set, char *value ) struct im_connection *ic = acc->ic; struct msn_data *md = ic->proto_data; - if( strlen( value ) > 129 ) - { - imcb_log( ic, "Maximum name length exceeded" ); - return NULL; - } - - if( md->flags & MSN_GOT_PROFILE_DN ) - imcb_log( ic, "Warning: Persistent name changes for this account have to be done " - "in the profile. BitlBee doesn't currently support this." ); - if( md->flags & MSN_EMAIL_UNVERIFIED ) imcb_log( ic, "Warning: Your e-mail address is unverified. MSN doesn't allow " "changing your display name until your e-mail address is verified." ); - msn_soap_addressbook_set_display_name( ic, value ); + if( md->flags & MSN_GOT_PROFILE_DN ) + msn_soap_profile_set_dn( ic, value ); + else + msn_soap_addressbook_set_display_name( ic, value ); + return msn_ns_set_display_name( ic, value ) ? value : NULL; } @@ -362,7 +358,7 @@ void msn_initmodule() struct prpl *ret = g_new0(struct prpl, 1); ret->name = "msn"; - ret->mms = 1409; /* this guess taken from libotr UPGRADING file */ + ret->mms = 1409; /* this guess taken from libotr UPGRADING file */ ret->login = msn_login; ret->init = msn_init; ret->logout = msn_logout; diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 39a44c30..f9993868 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -118,6 +118,7 @@ struct msn_data const struct msn_away_state *away_state; GSList *groups; + char *profile_rid; /* Mostly used for sending the ADL command; since MSNP13 the client is responsible for downloading the contact list and then sending diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 57e1800b..21eb0fd1 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -397,7 +397,10 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap return MSN_SOAP_RETRY; if( md->soapq ) + { + md->flags &= ~MSN_REAUTHING; return msn_soapq_flush( ic, TRUE ); + } if( sd->secret == NULL ) { @@ -1071,8 +1074,20 @@ static xt_status msn_soap_profile_get_result( struct xt_node *node, gpointer dat return XT_HANDLED; } +static xt_status msn_soap_profile_get_rid( struct xt_node *node, gpointer data ) +{ + struct msn_soap_req_data *soap_req = data; + struct msn_data *md = soap_req->ic->proto_data; + + g_free( md->profile_rid ); + md->profile_rid = g_strdup( node->text ); + + return XT_HANDLED; +} + static const struct xt_handler_entry msn_soap_profile_get_parser[] = { { "ExpressionProfile", "GetProfileResult", msn_soap_profile_get_result }, + { "ResourceID", "GetProfileResult", msn_soap_profile_get_rid }, { NULL, NULL, NULL } }; @@ -1100,3 +1115,40 @@ int msn_soap_profile_get( struct im_connection *ic, const char *cid ) msn_soap_profile_get_handle_response, msn_soap_profile_get_free_data ); } + +/* Update profile (display name). */ +static int msn_soap_profile_set_dn_build_request( struct msn_soap_req_data *soap_req ) +{ + struct msn_data *md = soap_req->ic->proto_data; + + soap_req->url = g_strdup( SOAP_STORAGE_URL ); + soap_req->action = g_strdup( SOAP_PROFILE_SET_DN_ACTION ); + soap_req->payload = g_markup_printf_escaped( SOAP_PROFILE_SET_DN_PAYLOAD, + md->tokens[3], md->profile_rid, (char*) soap_req->data ); + + return 1; +} + +static const struct xt_handler_entry msn_soap_profile_set_dn_parser[] = { + { NULL, NULL, NULL } +}; + +static int msn_soap_profile_set_dn_handle_response( struct msn_soap_req_data *soap_req ) +{ + return MSN_SOAP_OK; +} + +static int msn_soap_profile_set_dn_free_data( struct msn_soap_req_data *soap_req ) +{ + g_free( soap_req->data ); + return 0; +} + +int msn_soap_profile_set_dn( struct im_connection *ic, const char *dn ) +{ + return msn_soap_start( ic, g_strdup( dn ), + msn_soap_profile_set_dn_build_request, + msn_soap_profile_set_dn_parser, + msn_soap_profile_set_dn_handle_response, + msn_soap_profile_set_dn_free_data ); +} diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h index fccdebc6..c844d3ad 100644 --- a/protocols/msn/soap.h +++ b/protocols/msn/soap.h @@ -302,6 +302,7 @@ int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu ); #define SOAP_STORAGE_URL "https://storage.msn.com/storageservice/SchematizedStore.asmx" #define SOAP_PROFILE_GET_ACTION "http://www.msn.com/webservices/storage/w10/GetProfile" +#define SOAP_PROFILE_SET_DN_ACTION "http://www.msn.com/webservices/storage/w10/UpdateProfile" #define SOAP_PROFILE_GET_PAYLOAD \ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ @@ -344,7 +345,34 @@ int msn_soap_ab_contact_del( struct im_connection *ic, bee_user_t *bu ); "</soap:Body>" \ "</soap:Envelope>" -int msn_soap_profile_get( struct im_connection *ic, const char *cid ); +#define SOAP_PROFILE_SET_DN_PAYLOAD \ +"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ +"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ + "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ + "<StorageApplicationHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">" \ + "<ApplicationID>Messenger Client 9.0</ApplicationID>" \ + "<Scenario>Initial</Scenario>" \ + "</StorageApplicationHeader>" \ + "<StorageUserHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">" \ + "<Puid>0</Puid>" \ + "<TicketToken>%s</TicketToken>" \ + "</StorageUserHeader>" \ + "</soap:Header>" \ + "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ + "<UpdateProfile xmlns=\"http://www.msn.com/webservices/storage/w10\">" \ + "<profile>" \ + "<ResourceID>%s</ResourceID>" \ + "<ExpressionProfile>" \ + "<FreeText>Update</FreeText>" \ + "<DisplayName>%s</DisplayName>" \ + "<Flags>0</Flags>" \ + "</ExpressionProfile>" \ + "</profile>" \ + "</UpdateProfile>" \ + "</soap:Body>" \ +"</soap:Envelope>" +int msn_soap_profile_get( struct im_connection *ic, const char *cid ); +int msn_soap_profile_set_dn( struct im_connection *ic, const char *dn ); #endif /* __SOAP_H__ */ |