From f2bc08dc5827ec9157a648040f858765153b2a8c Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Tue, 18 Sep 2012 20:05:56 +0300 Subject: [PATCH] buddy: add backend API to refresh properties When the core has called sipe_backend_buddy_set_string() one or more times for a buddy then it calls sipe_backend_buddy_refresh_properties(). This can be used by the backend to trigger e.g. an UI update event. Added dummy stub to all backends. --- src/api/sipe-backend.h | 11 +++++++++++ src/core/sipe-buddy.c | 3 +++ src/core/sipe-notify.c | 7 +++++++ src/core/sipe-ocs2007.c | 1 + src/miranda/miranda-buddy.c | 6 ++++++ src/purple/purple-buddy.c | 6 ++++++ src/telepathy/telepathy-stubs.c | 2 ++ 7 files changed, 36 insertions(+) diff --git a/src/api/sipe-backend.h b/src/api/sipe-backend.h index 8b7715f4..95fbc900 100644 --- a/src/api/sipe-backend.h +++ b/src/api/sipe-backend.h @@ -768,6 +768,17 @@ void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public, const gchar *val); /** + * Called after one ore more buddy-specific settings have been updated. + * + * Can be used by the backend to trigger an UI update event + * + * @param sipe_public The handle representing the protocol instance making the call + * @param uri SIP URI of the contact + */ +void sipe_backend_buddy_refresh_properties(struct sipe_core_public *sipe_public, + const gchar *uri); + +/** * Get the status token for a contact * * @param sipe_public The handle representing the protocol instance making the call diff --git a/src/core/sipe-buddy.c b/src/core/sipe-buddy.c index 270b2650..bc9f62e2 100644 --- a/src/core/sipe-buddy.c +++ b/src/core/sipe-buddy.c @@ -1088,6 +1088,9 @@ static gboolean process_get_info_response(struct sipe_core_private *sipe_private sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_WORK_PHONE, tel_uri); sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY, phone_number); g_free(tel_uri); + + sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC, + uri); } if (!is_empty(server_alias)) { diff --git a/src/core/sipe-notify.c b/src/core/sipe-notify.c index cfcd09b7..a1b12916 100644 --- a/src/core/sipe-notify.c +++ b/src/core/sipe-notify.c @@ -340,6 +340,9 @@ static void process_incoming_notify_msrtc(struct sipe_core_private *sipe_private } } + if (xn_display_name || xn_contact) + sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC, uri); + /* devicePresence */ for (node = sipe_xml_child(xn_presentity, "devices/devicePresence"); node; node = sipe_xml_twin(node)) { const sipe_xml *xn_device_name; @@ -816,6 +819,8 @@ static void process_incoming_notify_rlmi(struct sipe_core_private *sipe_private, sipe_core_buddy_got_status(SIPE_CORE_PUBLIC, uri, activity); } + sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC, uri); + sipe_xml_free(xn_categories); } @@ -901,6 +906,8 @@ static void process_incoming_notify_pidf(struct sipe_core_private *sipe_private, sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_DISPLAY_NAME, display_name); g_free(display_name); + + sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC, uri); } if ((tuple = sipe_xml_child(pidf, "tuple"))) { diff --git a/src/core/sipe-ocs2007.c b/src/core/sipe-ocs2007.c index 53b1569c..1568e696 100644 --- a/src/core/sipe-ocs2007.c +++ b/src/core/sipe-ocs2007.c @@ -2378,6 +2378,7 @@ void sipe_ocs2007_process_roaming_self(struct sipe_core_private *sipe_private, uri = sip_uri_from_name(user); sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_DISPLAY_NAME, display_name); + sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC, uri); acknowledged= sipe_xml_attribute(node, "acknowledged"); if(sipe_strcase_equal(acknowledged,"false")){ diff --git a/src/miranda/miranda-buddy.c b/src/miranda/miranda-buddy.c index 8be0de5c..db78f6bc 100644 --- a/src/miranda/miranda-buddy.c +++ b/src/miranda/miranda-buddy.c @@ -377,6 +377,12 @@ void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public, sipe_miranda_setContactString(pr, buddy, prop_name, val); } +void sipe_backend_buddy_refresh_properties(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, + SIPE_UNUSED_PARAMETER const gchar *uri) +{ + /* nothing to do here: already taken care of by Miranda */ +} + void sipe_backend_buddy_list_processing_start(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public) { } diff --git a/src/purple/purple-buddy.c b/src/purple/purple-buddy.c index aeb9b218..8b71726b 100644 --- a/src/purple/purple-buddy.c +++ b/src/purple/purple-buddy.c @@ -186,6 +186,12 @@ void sipe_backend_buddy_set_string(SIPE_UNUSED_PARAMETER struct sipe_core_public purple_blist_node_set_string(&b->node, buddy_info_property(key), val); } +void sipe_backend_buddy_refresh_properties(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, + SIPE_UNUSED_PARAMETER const gchar *uri) +{ + /* nothing to do here: already taken care of by libpurple */ +} + void sipe_backend_buddy_list_processing_start(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public) { } diff --git a/src/telepathy/telepathy-stubs.c b/src/telepathy/telepathy-stubs.c index a496dc2a..64ab0752 100644 --- a/src/telepathy/telepathy-stubs.c +++ b/src/telepathy/telepathy-stubs.c @@ -41,6 +41,8 @@ /** BUDDIES ******************************************************************/ +void sipe_backend_buddy_refresh_properties(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, + SIPE_UNUSED_PARAMETER const gchar *uri) {} void sipe_backend_buddy_list_processing_start(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public) {} void sipe_backend_buddy_request_add(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, SIPE_UNUSED_PARAMETER const gchar *who, -- 2.11.4.GIT