From 63c9b8383796bdbc0918f7f376cb7ab3960538aa Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 15 Dec 2010 10:17:07 +0000 Subject: contact-view: display presence messages where available Signed-off-by: Jonny Lamb --- liszt/contact-view.c | 78 +++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/liszt/contact-view.c b/liszt/contact-view.c index b7daf7fc3..70e704f19 100644 --- a/liszt/contact-view.c +++ b/liszt/contact-view.c @@ -48,6 +48,39 @@ lol_contact_view_init (LolContactView *self) LolContactViewPrivate); } +static TpContact * +get_contact_and_account (LolContactView *self, + TpAccount **account) +{ + LolContactViewPrivate *priv = self->priv; + GList *personas, *l; + FolksPersona *persona = NULL; + FolksPersonaStore *store; + TpContact *contact; + + personas = folks_individual_get_personas (priv->individual); + + for (l = personas; l != NULL; l = l->next) + { + if (!TPF_IS_PERSONA (l->data)) + continue; + + persona = l->data; + break; + } + + if (persona == NULL) + return NULL; + + store = folks_persona_get_store (persona); + contact = tpf_persona_get_contact (TPF_PERSONA (persona)); + + if (account != NULL) + *account = tpf_persona_store_get_account (TPF_PERSONA_STORE (store)); + + return contact; +} + static void lol_contact_view_set_markup (LolContactView *self, const gchar *text, @@ -56,11 +89,21 @@ lol_contact_view_set_markup (LolContactView *self, LolContactViewPrivate *priv = self->priv; gchar *markup; TpConnectionPresenceType tmp; + TpContact *contact; + const gchar *status = NULL; tmp = empathy_folks_presence_type_to_tp (presence); + contact = get_contact_and_account (self, NULL); + + if (contact != NULL) + status = tp_contact_get_presence_message (contact); + + if (EMP_STR_EMPTY (status)) + status = empathy_presence_get_default_message (tmp); + markup = g_strdup_printf ("%s\n%s", - text, empathy_presence_get_default_message (tmp)); + text, status); clutter_text_set_markup (CLUTTER_TEXT (priv->name_text), markup); g_free (markup); } @@ -141,39 +184,6 @@ lol_contact_view_set_presence (LolContactView *self, g_free (tmp); } -static TpContact * -get_contact_and_account (LolContactView *self, - TpAccount **account) -{ - LolContactViewPrivate *priv = self->priv; - GList *personas, *l; - FolksPersona *persona = NULL; - FolksPersonaStore *store; - TpContact *contact; - - personas = folks_individual_get_personas (priv->individual); - - for (l = personas; l != NULL; l = l->next) - { - if (!TPF_IS_PERSONA (l->data)) - continue; - - persona = l->data; - break; - } - - if (persona == NULL) - return NULL; - - store = folks_persona_get_store (persona); - contact = tpf_persona_get_contact (TPF_PERSONA (persona)); - - if (account != NULL) - *account = tpf_persona_store_get_account (TPF_PERSONA_STORE (store)); - - return contact; -} - static void lol_contact_view_update_capabilities (LolContactView *self) { -- cgit v1.2.3