[empathy: 2/59] Add empathy_idle_get_requested_presence function.
- From: Jonny Lamb <jonnylamb src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy: 2/59] Add empathy_idle_get_requested_presence function.
- Date: Mon, 2 Nov 2009 13:37:53 +0000 (UTC)
commit 1d66bb9bffcb1e9d6eb034be4bf7c5eaea839a5d
Author: Jonny Lamb <jonnylamb gnome org>
Date: Fri Oct 23 18:37:45 2009 +0100
Add empathy_idle_get_requested_presence function.
Signed-off-by: Jonny Lamb <jonnylamb gnome org>
libempathy/empathy-idle.c | 51 ++++++++++++++++++++++++++++++++++----------
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 cc6ca62..8def5ba 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 47dcfee..8d565d0 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]