cpw.qulogic.msn: 08c7dad6: Add real server-side aliasing to MSN.
qulogic at pidgin.im
qulogic at pidgin.im
Sat Jun 7 04:10:48 EDT 2008
-----------------------------------------------------------------
Revision: 08c7dad6f6504b8f75816081fcd284f1608eb358
Ancestor: 831e8102ea63c0c128495c0ba6c1c7d6dced0454
Author: qulogic at pidgin.im
Date: 2008-06-07T08:01:41
Branch: im.pidgin.cpw.qulogic.msn
URL: http://d.pidgin.im/viewmtn/revision/info/08c7dad6f6504b8f75816081fcd284f1608eb358
Modified files:
libpurple/protocols/msn/contact.c
libpurple/protocols/msn/contact.h
libpurple/protocols/msn/msn.c
libpurple/protocols/msn/notification.c
ChangeLog:
Add real server-side aliasing to MSN.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c 2d394fc02b073aef8ff50c3002b248e5fdef09de
+++ libpurple/protocols/msn/contact.c 8ebee01ab8ed341a6c28f37bc881782748c8066d
@@ -510,12 +510,14 @@ msn_parse_addressbook_contacts(MsnSessio
msn_parse_addressbook_contacts(MsnSession *session, xmlnode *node)
{
xmlnode *contactNode;
- char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL, *mobile_number = NULL;
+ char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL, *mobile_number = NULL, *alias = NULL;
gboolean mobile = FALSE;
+ PurpleConnection *pc = purple_account_get_connection(session->account);
for(contactNode = xmlnode_get_child(node, "Contact"); contactNode;
contactNode = xmlnode_get_next_twin(contactNode)) {
xmlnode *contactId, *contactInfo, *contactType, *passportName, *displayName, *guid, *groupIds, *messenger_user;
+ xmlnode *annotation;
MsnUser *user;
MsnUserType usertype;
@@ -526,10 +528,11 @@ msn_parse_addressbook_contacts(MsnSessio
g_free(passport);
g_free(Name);
+ g_free(alias);
g_free(uid);
g_free(type);
g_free(mobile_number);
- passport = Name = uid = type = mobile_number = NULL;
+ passport = Name = uid = type = mobile_number = alias = NULL;
mobile = FALSE;
uid = xmlnode_get_data(contactId);
@@ -610,10 +613,19 @@ msn_parse_addressbook_contacts(MsnSessio
else
Name = g_strdup(passport);
+ for (annotation = xmlnode_get_child(contactInfo, "annotations/Annotation");
+ annotation; annotation = xmlnode_get_next_twin(annotation)) {
+ char *name;
+ name = xmlnode_get_data(xmlnode_get_child(annotation, "Name"));
+ if (!strcmp(name, "AB.NickName"))
+ alias = xmlnode_get_data(xmlnode_get_child(annotation, "Value"));
+ g_free(name);
+ }
+
mobile = msn_parse_addressbook_mobile(contactInfo, &mobile_number);
- purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s} mobile:{%s} mobile number:{%s}\n",
- passport, uid ? uid : "(null)", Name ? Name : "(null)",
+ purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s} alias: {%s} mobile:{%s} mobile number:{%s}\n",
+ passport, uid ? uid : "(null)", Name ? Name : "(null)", alias ? alias : "(null)",
mobile ? "true" : "false", mobile_number ? mobile_number : "(null)");
user = msn_userlist_find_add_user(session->userlist, passport, Name);
@@ -644,6 +656,8 @@ msn_parse_addressbook_contacts(MsnSessio
purple_prpl_got_user_status(session->account, user->passport, "mobile", NULL);
purple_prpl_got_user_status(session->account, user->passport, "available", NULL);
}
+ if (alias)
+ purple_serv_got_private_alias(pc, passport, alias);
}
g_free(passport);
@@ -1185,28 +1199,72 @@ msn_update_contact_read_cb(MsnSoapMessag
purple_debug_info("MSN CL","Contact updated successfully\n");
}
-/* Update a contact's nickname */
+/* Update a contact's info */
void
-msn_update_contact(MsnSession *session, const char* nickname)
+msn_update_contact(MsnSession *session, const char *passport, MsnContactUpdateType type, const char* value)
{
MsnCallbackState *state;
- gchar *body = NULL, *escaped_nickname;
+ xmlnode *contact;
+ xmlnode *contact_info;
+ xmlnode *changes;
- purple_debug_info("MSN CL","Update contact information with new friendly name: %s\n", nickname);
+ purple_debug_info("MSN CL","Update contact information with new %s: %s\n",
+ type==MSN_UPDATE_DISPLAY ? "display name" : "alias", value);
+ purple_debug_info("msncl", "passport=%s\n", passport);
+ g_return_if_fail(passport != NULL);
+ contact_info = xmlnode_new("contactInfo");
+ changes = xmlnode_new("propertiesChanged");
- escaped_nickname = g_markup_escape_text(nickname, -1);
+ switch (type) {
+ xmlnode *annotations;
+ xmlnode *display;
+ xmlnode *a, *n, *v;
+ case MSN_UPDATE_DISPLAY:
+ display = xmlnode_new_child(contact_info, "displayName");
+ xmlnode_insert_data(display, value, -1);
+ xmlnode_insert_data(changes, "DisplayName", -1);
+ break;
- body = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, escaped_nickname);
+ case MSN_UPDATE_ALIAS:
+ annotations = xmlnode_new_child(contact_info, "annotations");
+ xmlnode_insert_data(changes, "Annotation ", -1);
+ a = xmlnode_new_child(annotations, "Annotation");
+ n = xmlnode_new_child(a, "Name");
+ xmlnode_insert_data(n, "AB.NickName", -1);
+ v = xmlnode_new_child(a, "Value");
+ xmlnode_insert_data(v, value, -1);
+ break;
+
+ default:
+ g_return_if_reached();
+ }
+
+
+
state = msn_callback_state_new(session);
- state->body = xmlnode_from_str(body, -1);
+
+ state->body = xmlnode_from_str(MSN_CONTACT_UPDATE_TEMPLATE, -1);
state->action = MSN_UPDATE_INFO;
state->post_action = MSN_CONTACT_UPDATE_SOAP_ACTION;
state->post_url = MSN_ADDRESS_BOOK_POST_URL;
state->cb = msn_update_contact_read_cb;
- g_free(escaped_nickname);
- g_free(body);
+ contact = xmlnode_get_child(state->body, "Body/ABContactUpdate/contacts/Contact");
+ xmlnode_insert_child(contact, contact_info);
+ xmlnode_insert_child(contact, changes);
+
+ if (!strcmp(passport, "Me")) {
+ xmlnode *contactType = xmlnode_new_child(contact_info, "contactType");
+ xmlnode_insert_data(contactType, "Me", -1);
+ } else {
+ MsnUser *user = msn_userlist_find_user(session->userlist, passport);
+ xmlnode *contactId = xmlnode_new_child(contact, "contactId");
+ msn_callback_state_set_uid(state, user->uid);
+ xmlnode_insert_data(contactId, state->uid, -1);
+ }
+
+ msn_contact_request(state);
}
static void
============================================================
--- libpurple/protocols/msn/contact.h 56acd3276c764e88d636be4a3bfd8fb209a62486
+++ libpurple/protocols/msn/contact.h 9561c43700f057f7b5ff5745bd99c1ca864c6b9a
@@ -331,7 +331,7 @@
"</soap:Envelope>"
-/* Update Contact Nickname */
+/* Update Contact Information */
#define MSN_CONTACT_UPDATE_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABContactUpdate"
#define MSN_CONTACT_UPDATE_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
"<soap:Envelope"\
@@ -355,11 +355,7 @@
"<abId>00000000-0000-0000-0000-000000000000</abId>"\
"<contacts>"\
"<Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">"\
- "<contactInfo>"\
- "<contactType>Me</contactType>"\
- "<displayName>%s</displayName>"\
- "</contactInfo>"\
- "<propertiesChanged>DisplayName</propertiesChanged>"\
+ ""\
"</Contact>"\
"</contacts>"\
"</ABContactUpdate>"\
@@ -618,6 +614,13 @@ typedef enum
MSN_PS_BLOCK_UNBLOCK
} MsnSoapPartnerScenario;
+typedef enum
+{
+ MSN_UPDATE_DISPLAY, /* Real display name */
+ MSN_UPDATE_ALIAS, /* Aliased display name */
+ MSN_UPDATE_COMMENT
+} MsnContactUpdateType;
+
/************************************************
* function prototype
************************************************/
@@ -644,7 +647,7 @@ void msn_get_address_book(MsnSession *se
const char * update, const char * gupdate);
/* contact SOAP operations */
-void msn_update_contact(MsnSession *session, const char* nickname);
+void msn_update_contact(MsnSession *session, const char *passport, MsnContactUpdateType type, const char* value);
void msn_add_contact(MsnSession *session, MsnCallbackState *state,
const char *passport);
============================================================
--- libpurple/protocols/msn/msn.c 5e967879f295a0d610b7db16fef6ab445695aa17
+++ libpurple/protocols/msn/msn.c 4c5f76548f0af42ceb8051f49452b716e0b439ab
@@ -1581,6 +1581,15 @@ msn_keepalive(PurpleConnection *gc)
}
}
+static void msn_alias_buddy(PurpleConnection *pc, const char *name, const char *alias)
+{
+ MsnSession *session;
+
+ session = pc->proto_data;
+
+ msn_update_contact(session, name, MSN_UPDATE_ALIAS, alias);
+}
+
static void
msn_group_buddy(PurpleConnection *gc, const char *who,
const char *old_group_name, const char *new_group_name)
@@ -2418,7 +2427,7 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* register_user */
NULL, /* get_cb_info */
NULL, /* get_cb_away */
- NULL, /* alias_buddy */
+ msn_alias_buddy, /* alias_buddy */
msn_group_buddy, /* group_buddy */
msn_rename_group, /* rename_group */
NULL, /* buddy_free */
============================================================
--- libpurple/protocols/msn/notification.c 2606cd32fa25542bc6c172de63e89bab407f3c95
+++ libpurple/protocols/msn/notification.c 3f40cfcb4f67a2f87847755f2d67253e31a6114d
@@ -1284,7 +1284,7 @@ prp_cmd(MsnCmdProc *cmdproc, MsnCommand
if (!strcmp(type, "MFN")) {
friendlyname = purple_url_decode(cmd->params[2]);
- msn_update_contact(session, friendlyname);
+ msn_update_contact(session, "Me", MSN_UPDATE_DISPLAY, friendlyname);
purple_connection_set_display_name(
purple_account_get_connection(session->account),
More information about the Commits
mailing list