Mercurial > pidgin.yaz
diff libpurple/protocols/msn/contact.c @ 23490:b70f30dd4753
Patch 3 from Qulogic, this one updates contact list actions to use ticket
tokens
committer: Ka-Hing Cheung <khc@hxbc.us>
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Wed, 26 Dec 2007 00:34:50 +0000 |
parents | 068b412ba385 |
children | f1f5efd679a4 |
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c Wed Dec 26 00:34:12 2007 +0000 +++ b/libpurple/protocols/msn/contact.c Wed Dec 26 00:34:50 2007 +0000 @@ -29,6 +29,7 @@ #include "xmlnode.h" #include "group.h" #include "soap2.h" +#include "nexus.h" const char *MsnSoapPartnerScenarioText[] = { @@ -206,6 +207,26 @@ return MSN_USER_TYPE_UNKNOWN; } +/* Get a ticket token that's correctly formatted */ +static const char * +msn_contact_get_token(MsnContact *contact) +{ + GHashTable *token; + char *msn_t; + char *msn_p; + static char token_str[BUF_LEN]; + + token = msn_nexus_get_token(contact->session->nexus, MSN_AUTH_CONTACTS); + msn_t = g_hash_table_lookup(token, "t"); + msn_p = g_hash_table_lookup(token, "p"); + + g_sprintf(token_str, "t=%s&p=%s", msn_t, msn_p); + + g_hash_table_unref(token); + + return token_str; +} + /* Create the AddressBook in the server, if we don't have one */ static void msn_create_address_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data) @@ -230,7 +251,9 @@ purple_debug_info("msnab","Creating an Address Book.\n"); - body = g_strdup_printf(MSN_ADD_ADDRESSBOOK_TEMPLATE, contact->session->user->passport); + body = g_strdup_printf(MSN_ADD_ADDRESSBOOK_TEMPLATE, + msn_contact_get_token(contact), + contact->session->user->passport); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_ADD_ADDRESSBOOK_SOAP_ACTION, @@ -416,7 +439,9 @@ update_str = g_strdup_printf(MSN_GET_CONTACT_UPDATE_XML,update_time); } - body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, partner_scenario_str, update_str ? update_str : ""); + body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, partner_scenario_str, + msn_contact_get_token(contact), + update_str ? update_str : ""); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_GET_CONTACT_SOAP_ACTION, @@ -729,7 +754,10 @@ else if (LastChanged != NULL) update_str = g_strdup_printf(MSN_GET_ADDRESS_UPDATE_XML, LastChanged); - body = g_strdup_printf(MSN_GET_ADDRESS_TEMPLATE, MsnSoapPartnerScenarioText[partner_scenario], update_str ? update_str : ""); + body = g_strdup_printf(MSN_GET_ADDRESS_TEMPLATE, + MsnSoapPartnerScenarioText[partner_scenario], + msn_contact_get_token(contact), + update_str ? update_str : ""); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_GET_ADDRESS_SOAP_ACTION, @@ -794,7 +822,9 @@ purple_debug_info("MSNCL","Adding contact %s to contact list\n", passport); contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport); - body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE, contact_xml); + body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE, + msn_contact_get_token(contact), + contact_xml); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_CONTACT_ADD_SOAP_ACTION, @@ -902,7 +932,10 @@ contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport); } - body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE, groupId, contact_xml); + body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE, + msn_contact_get_token(contact), + groupId, + contact_xml); msn_soap_message_send(state->session, msn_soap_message_new(MSN_ADD_CONTACT_GROUP_SOAP_ACTION, @@ -950,7 +983,9 @@ /* build SOAP request */ purple_debug_info("MSNCL","Deleting contact with contactId: %s\n", contactId); - body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE, contact_id_xml); + body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE, + msn_contact_get_token(contact), + contact_id_xml); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_CONTACT_DEL_SOAP_ACTION, xmlnode_from_str(body, -1)), @@ -1022,7 +1057,10 @@ msn_callback_state_set_old_group_name(state, group_name); contact_id_xml = g_strdup_printf(MSN_CONTACT_ID_XML, user->uid); - body = g_strdup_printf(MSN_CONTACT_DEL_GROUP_TEMPLATE, contact_id_xml, groupId); + body = g_strdup_printf(MSN_CONTACT_DEL_GROUP_TEMPLATE, + msn_contact_get_token(contact), + contact_id_xml, + groupId); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_CONTACT_DEL_GROUP_SOAP_ACTION, @@ -1055,7 +1093,9 @@ escaped_nickname = g_markup_escape_text(nickname, -1); - body = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, escaped_nickname); + body = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, + msn_contact_get_token(contact), + escaped_nickname); msn_soap_message_send(contact->session, msn_soap_message_new(MSN_CONTACT_UPDATE_SOAP_ACTION, @@ -1134,6 +1174,7 @@ body = g_strdup_printf( MSN_CONTACT_DELECT_FROM_LIST_TEMPLATE, MsnSoapPartnerScenarioText[partner_scenario], + msn_contact_get_token(contact), MsnMemberRole[list], member); @@ -1206,6 +1247,7 @@ body = g_strdup_printf(MSN_CONTACT_ADD_TO_LIST_TEMPLATE, MsnSoapPartnerScenarioText[partner_scenario], + msn_contact_get_token(contact), MsnMemberRole[list], member); @@ -1234,13 +1276,18 @@ msn_get_gleams(MsnContact *contact) { MsnSoapReq *soap_request; + gchar *body = NULL; purple_debug_info("MSNP14","msn get gleams info...\n"); + + body = g_strdup_printf(MSN_GLEAMS_TEMPLATE, + msn_contact_get_token(contact)) msn_soap_message_send(contact->session, msn_soap_message_new(MSN_GET_GLEAMS_SOAP_ACTION, - xmlnode_from_str(MSN_GLEAMS_TEMPLATE, -1)), + xmlnode_from_str(body, -1)), MSN_CONTACT_SERVER, MSN_ADDRESS_BOOK_POST_URL, msn_gleams_read_cb, NULL); + g_free(body); } #endif @@ -1339,7 +1386,9 @@ /* escape group name's html special chars so it can safely be sent * in a XML SOAP request */ - body = g_markup_printf_escaped(MSN_GROUP_ADD_TEMPLATE, group_name); + body = g_markup_printf_escaped(MSN_GROUP_ADD_TEMPLATE, + msn_contact_get_token(session->contact), + group_name); msn_soap_message_send(session, msn_soap_message_new(MSN_GROUP_ADD_SOAP_ACTION, @@ -1382,7 +1431,9 @@ msn_callback_state_set_action(state, MSN_DEL_GROUP); msn_callback_state_set_guid(state, guid); - body = g_strdup_printf(MSN_GROUP_DEL_TEMPLATE, guid); + body = g_strdup_printf(MSN_GROUP_DEL_TEMPLATE, + msn_contact_get_token(session->contact), + guid); msn_soap_message_send(session, msn_soap_message_new(MSN_GROUP_DEL_SOAP_ACTION, @@ -1424,7 +1475,8 @@ msn_callback_state_set_action(state, MSN_RENAME_GROUP); body = g_markup_printf_escaped(MSN_GROUP_RENAME_TEMPLATE, - guid, new_group_name); + msn_contact_get_token(session->contact), + guid, new_group_name); msn_soap_message_send(session, msn_soap_message_new(MSN_GROUP_RENAME_SOAP_ACTION,