From 1e35d2ae0ecc14c02cacb02b3053162a27ce9004 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Wed, 14 Dec 2011 23:16:53 +0200 Subject: [PATCH] ms-dlx: parse SearchAbRequest response Now "Get Info" buddy menu entry works again for Lync. --- src/core/sipe-buddy.c | 86 ++++++++++++++++++++++++++++++++++++++++++++--- src/core/sipe-svc.c | 2 +- src/purple/purple-buddy.c | 8 +++-- 3 files changed, 88 insertions(+), 8 deletions(-) diff --git a/src/core/sipe-buddy.c b/src/core/sipe-buddy.c index 38d7870d..cbe99a65 100644 --- a/src/core/sipe-buddy.c +++ b/src/core/sipe-buddy.c @@ -663,19 +663,97 @@ static void ab_entry_response(struct sipe_core_private *sipe_private, gpointer callback_data) { gchar *who = callback_data; + struct sipe_backend_buddy_info *info = NULL; + gchar *server_alias = NULL; + gchar *email = NULL; if (soap_body) { + const sipe_xml *node; SIPE_DEBUG_INFO("ab_entry_response: received valid SOAP message from service %s", uri); + + info = sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC); + + for (node = sipe_xml_child(soap_body, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry/Attributes/Attribute"); + node; + node = sipe_xml_twin(node)) { + gchar *name = sipe_xml_data(sipe_xml_child(node, + "Name")); + gchar *value = sipe_xml_data(sipe_xml_child(node, + "Value")); + const sipe_xml *values = sipe_xml_child(node, + "Values"); + + /* Single value entries */ + if (!is_empty(value)) { + + if (sipe_strcase_equal(name, "displayname")) { + g_free(server_alias); + server_alias = value; + value = NULL; + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Display name"), + server_alias); + } else if (sipe_strcase_equal(name, "mail")) { + g_free(email); + email = value; + value = NULL; + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Email address"), + email); + } else if (sipe_strcase_equal(name, "title")) { + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Job title"), + value); + } else if (sipe_strcase_equal(name, "title")) { + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Job title"), + value); + } else if (sipe_strcase_equal(name, "company")) { + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Company"), + value); + } else if (sipe_strcase_equal(name, "country")) { + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Country"), + value); + } + + } else if (values) { + gchar *first = sipe_xml_data(sipe_xml_child(values, + "string")); + + if (sipe_strcase_equal(name, "telephonenumber")) { + sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC, + info, + _("Business phone"), + first); + } + + g_free(first); + } + + g_free(value); + g_free(name); + } } - /* request failed: this will show the minmum information */ + /* this will show the minmum information */ get_info_finalize(sipe_private, - NULL, + info, who, - NULL, - NULL); + server_alias, + email); + + g_free(email); + g_free(server_alias); g_free(who); } diff --git a/src/core/sipe-svc.c b/src/core/sipe-svc.c index 936b3baa..b7ae6568 100644 --- a/src/core/sipe-svc.c +++ b/src/core/sipe-svc.c @@ -359,7 +359,7 @@ gboolean sipe_svc_ab_entry_request(struct sipe_core_private *sipe_private, " " " false" " 1" - " displayName,msRTCSIP-PrimaryUserAddress,telephoneNumber,homePhone,mobile,otherTelephone,custom1Phone,mail,company,country" + " displayName,msRTCSIP-PrimaryUserAddress,title,telephoneNumber,homePhone,mobile,otherTelephone,mail,company,country" " " " " "", diff --git a/src/purple/purple-buddy.c b/src/purple/purple-buddy.c index a73d570b..54a9bd4b 100644 --- a/src/purple/purple-buddy.c +++ b/src/purple/purple-buddy.c @@ -332,12 +332,14 @@ void sipe_backend_buddy_info_add(SIPE_UNUSED_PARAMETER struct sipe_core_public * const gchar *description, const gchar *value) { + if (info) { #if PURPLE_VERSION_CHECK(3,0,0) - purple_notify_user_info_add_pair_html + purple_notify_user_info_add_pair_html #else - purple_notify_user_info_add_pair + purple_notify_user_info_add_pair #endif - ((PurpleNotifyUserInfo *) info, description, value); + ((PurpleNotifyUserInfo *) info, description, value); + } } void sipe_backend_buddy_info_break(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, -- 2.11.4.GIT