From 1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 23 Oct 2009 18:37:45 +0100 Subject: Add empathy_idle_get_requested_presence function. Signed-off-by: Jonny Lamb --- libempathy/empathy-idle.c | 51 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'libempathy/empathy-idle.c') diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c index cc6ca62f4..8def5ba12 100644 --- a/libempathy/empathy-idle.c +++ b/libempathy/empathy-idle.c @@ -59,6 +59,10 @@ typedef struct { guint ext_away_timeout; EmpathyAccountManager *manager; + + TpConnectionPresenceType requested_presence_type; + gchar *requested_status_message; + } EmpathyIdlePriv; typedef enum { @@ -81,6 +85,18 @@ G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT); static EmpathyIdle * idle_singleton = NULL; +static const gchar *presence_type_to_status[NUM_TP_CONNECTION_PRESENCE_TYPES] = { + NULL, + "offline", + "available", + "away", + "xa", + "hidden", + "busy", + NULL, + NULL, +}; + static void idle_presence_changed_cb (EmpathyAccountManager *manager, TpConnectionPresenceType state, @@ -279,6 +295,7 @@ idle_finalize (GObject *object) priv = GET_PRIV (object); g_free (priv->status); + g_free (priv->requested_status_message); if (priv->gs_proxy) { g_object_unref (priv->gs_proxy); @@ -567,22 +584,11 @@ empathy_idle_do_set_presence (EmpathyIdle *idle, const gchar *status_message) { EmpathyIdlePriv *priv = GET_PRIV (idle); - const gchar *statuses[NUM_TP_CONNECTION_PRESENCE_TYPES] = { - NULL, - "offline", - "available", - "away", - "xa", - "hidden", - "busy", - NULL, - NULL, - }; const gchar *status; g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES); - status = statuses[status_type]; + status = presence_type_to_status[status_type]; g_return_if_fail (status != NULL); @@ -602,6 +608,10 @@ empathy_idle_set_presence (EmpathyIdle *idle, DEBUG ("Changing presence to %s (%d)", status, state); + g_free (priv->requested_status_message); + priv->requested_presence_type = state; + priv->requested_status_message = g_strdup (status); + /* Do not set translated default messages */ default_status = empathy_presence_get_default_message (state); if (!tp_strdiff (status, default_status)) { @@ -645,3 +655,20 @@ empathy_idle_set_auto_away (EmpathyIdle *idle, g_object_notify (G_OBJECT (idle), "auto-away"); } +TpConnectionPresenceType +empathy_idle_get_requested_presence (EmpathyIdle *idle, + gchar **status, + gchar **status_message) +{ + EmpathyIdlePriv *priv = GET_PRIV (idle); + + if (status != NULL) { + *status = g_strdup (presence_type_to_status[priv->requested_presence_type]); + } + + if (status_message != NULL) { + *status_message = g_strdup (priv->requested_status_message); + } + + return priv->requested_presence_type; +} -- cgit v1.2.3