diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2009-10-24 01:37:45 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2009-10-24 01:37:45 +0800 |
commit | 1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d (patch) | |
tree | ba80e2fa83d3aa40422a8a64afbbd6b0f5c9b9b5 /libempathy | |
parent | 9750a6735d088fa5c1930f2ac581619ff31c8491 (diff) | |
download | gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar.gz gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar.bz2 gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar.lz gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar.xz gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.tar.zst gsoc2013-empathy-1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d.zip |
Add empathy_idle_get_requested_presence function.
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-idle.c | 51 | ||||
-rw-r--r-- | libempathy/empathy-idle.h | 5 |
2 files changed, 44 insertions, 12 deletions
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; +} diff --git a/libempathy/empathy-idle.h b/libempathy/empathy-idle.h index 47dcfee23..8d565d036 100644 --- a/libempathy/empathy-idle.h +++ b/libempathy/empathy-idle.h @@ -65,6 +65,11 @@ gboolean empathy_idle_get_auto_away (EmpathyIdle *idle); void empathy_idle_set_auto_away (EmpathyIdle *idle, gboolean auto_away); +TpConnectionPresenceType empathy_idle_get_requested_presence (EmpathyIdle *idle, + gchar **status, + gchar **status_message); + + G_END_DECLS #endif /* __EMPATHY_IDLE_H__ */ |