aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-idle.c51
-rw-r--r--libempathy/empathy-idle.h5
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__ */