From 6922019f8d80c361ba6f6a32ff8195e326b1d07d Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Thu, 8 Dec 2011 06:52:13 +0200 Subject: [PATCH] core cleanup: move sipe_get_buddy_status() to backend --- src/api/core-depurple.h | 1 - src/api/sipe-backend.h | 13 ++++++++++++- src/core/sipe-notify.c | 8 +++++--- src/core/sipe.c | 10 ---------- src/core/sipe.h | 8 -------- src/purple/purple-buddy.c | 24 +++++++++++++++--------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/api/core-depurple.h b/src/api/core-depurple.h index 0de6d23b..d04fd766 100644 --- a/src/api/core-depurple.h +++ b/src/api/core-depurple.h @@ -30,7 +30,6 @@ void sipe_purple_setup(struct sipe_core_public *sipe_public, PurpleConnection *gc); /* Convenience macros */ -#define PURPLE_ACCOUNT_TO_SIPE_CORE_PRIVATE ((struct sipe_core_private *)account->gc->proto_data) #define PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE ((struct sipe_core_private *)buddy->account->gc->proto_data) #define PURPLE_GC_TO_SIPE_CORE_PRIVATE ((struct sipe_core_private *)gc->proto_data) #define PURPLE_GC_TO_SIPE_CORE_PUBLIC ((struct sipe_core_public *) gc->proto_data) diff --git a/src/api/sipe-backend.h b/src/api/sipe-backend.h index 4b81f16f..052190ad 100644 --- a/src/api/sipe-backend.h +++ b/src/api/sipe-backend.h @@ -744,7 +744,7 @@ gchar* sipe_backend_buddy_get_string(struct sipe_core_public *sipe_public, const sipe_buddy_info_fields key); /** - * Called to retrieve a buddy-specific setting. + * Called to set a buddy-specific setting. * * @param sipe_public The handle representing the protocol instance making the call * @param buddy The handle representing the buddy @@ -757,6 +757,17 @@ void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public, const gchar *val); /** + * Get the status token for a contact + * + * @param sipe_public The handle representing the protocol instance making the call + * @param uri SIP URI of the contact + * + * @return status token + */ +const gchar *sipe_backend_buddy_get_status(struct sipe_core_public *sipe_public, + const gchar *uri); + +/** * Sets the alias for a contact. * * @param sipe_public The handle representing the protocol instance making the call diff --git a/src/core/sipe-notify.c b/src/core/sipe-notify.c index debb54eb..a8033433 100644 --- a/src/core/sipe-notify.c +++ b/src/core/sipe-notify.c @@ -773,9 +773,11 @@ static void process_incoming_notify_rlmi(struct sipe_core_private *sipe_private, } if (do_update_status) { - if (!status) { /* no status category in this update, using contact's current status */ - status = sipe_get_buddy_status(sipe_private, - uri); + if (!status) { + /* no status category in this update, + using contact's current status */ + status = sipe_backend_buddy_get_status(SIPE_CORE_PUBLIC, + uri); } SIPE_DEBUG_INFO("process_incoming_notify_rlmi: %s", status); diff --git a/src/core/sipe.c b/src/core/sipe.c index 43662a84..f0f7a1e4 100644 --- a/src/core/sipe.c +++ b/src/core/sipe.c @@ -93,16 +93,6 @@ #include "sipe.h" -const gchar *sipe_get_buddy_status(struct sipe_core_private *sipe_private, - const gchar *uri) -{ - struct sipe_account_data *sip = SIPE_ACCOUNT_DATA_PRIVATE; - PurpleBuddy *pbuddy = purple_find_buddy((PurpleAccount *)sip->account, uri); - const PurplePresence *presence = purple_buddy_get_presence(pbuddy); - const PurpleStatus *pstatus = purple_presence_get_active_status(presence); - return(purple_status_get_id(pstatus)); -} - void send_presence_status(struct sipe_core_private *sipe_private, SIPE_UNUSED_PARAMETER gpointer unused) { diff --git a/src/core/sipe.h b/src/core/sipe.h index 3f2882fa..6a19e654 100644 --- a/src/core/sipe.h +++ b/src/core/sipe.h @@ -117,12 +117,4 @@ void send_presence_status(struct sipe_core_private *sipe_private, /* libpurple memory leak workaround */ void sipe_blist_menu_free_containers(struct sipe_core_private *sipe_private); -/** - * referenced by sipe-notify.c - start - */ -const gchar *sipe_get_buddy_status(struct sipe_core_private *sipe_private, - const gchar *uri); -/* referenced by sipe-notify.c - end */ - - /*** THE BIG SPLIT END ***/ diff --git a/src/purple/purple-buddy.c b/src/purple/purple-buddy.c index fb6b9eff..d27dc3dd 100644 --- a/src/purple/purple-buddy.c +++ b/src/purple/purple-buddy.c @@ -171,6 +171,16 @@ gchar* sipe_backend_buddy_get_group_name(SIPE_UNUSED_PARAMETER struct sipe_core_ return g_strdup(purple_buddy_get_group((PurpleBuddy*)who)->name); } +const gchar *sipe_backend_buddy_get_status(struct sipe_core_public *sipe_public, + const gchar *uri) +{ + struct sipe_backend_private *purple_private = sipe_public->backend_private; + PurpleBuddy *pbuddy = purple_find_buddy(purple_private->account, uri); + const PurplePresence *presence = purple_buddy_get_presence(pbuddy); + const PurpleStatus *pstatus = purple_presence_get_active_status(presence); + return(purple_status_get_id(pstatus)); +} + void sipe_backend_buddy_set_alias(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public, const sipe_backend_buddy who, const gchar *alias) @@ -283,15 +293,11 @@ void sipe_backend_buddy_set_blocked_status(struct sipe_core_public *sipe_public, } /* stupid workaround to make pidgin re-render screen to reflect our changes */ - { - PurpleBuddy *pbuddy = purple_find_buddy(purple_private->account, who); - const PurplePresence *presence = purple_buddy_get_presence(pbuddy); - const PurpleStatus *pstatus = purple_presence_get_active_status(presence); - - SIPE_DEBUG_INFO_NOFORMAT("sipe_backend_buddy_set_blocked_status: forcefully refreshing screen."); - sipe_core_buddy_got_status(sipe_public, who, purple_status_get_id(pstatus)); - } - + SIPE_DEBUG_INFO_NOFORMAT("sipe_backend_buddy_set_blocked_status: forcefully refreshing screen."); + sipe_core_buddy_got_status(sipe_public, + who, + sipe_backend_buddy_get_status(sipe_public, + who)); } void sipe_backend_buddy_set_status(struct sipe_core_public *sipe_public, -- 2.11.4.GIT