aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-idle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy/empathy-idle.c')
-rw-r--r--libempathy/empathy-idle.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index 92ab9f39f..2ed1440fc 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -68,6 +68,14 @@ typedef enum {
NM_STATE_DISCONNECTED
} NMState;
+typedef enum {
+ SESSION_STATUS_AVAILABLE,
+ SESSION_STATUS_INVISIBLE,
+ SESSION_STATUS_BUSY,
+ SESSION_STATUS_IDLE,
+ SESSION_STATUS_UNKNOWN
+} SessionStatus;
+
enum {
PROP_0,
PROP_STATE,
@@ -91,6 +99,10 @@ idle_presence_changed_cb (MissionControl *mc,
priv = GET_PRIV (idle);
+ if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET)
+ /* Assume our presence is offline if MC reports UNSET */
+ state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+
DEBUG ("Presence changed to '%s' (%d)", status, state);
g_free (priv->status);
@@ -147,14 +159,17 @@ idle_ext_away_start (EmpathyIdle *idle)
}
static void
-idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
- gboolean is_idle,
- EmpathyIdle *idle)
+idle_session_status_changed_cb (DBusGProxy *gs_proxy,
+ SessionStatus status,
+ EmpathyIdle *idle)
{
EmpathyIdlePriv *priv;
+ gboolean is_idle;
priv = GET_PRIV (idle);
+ is_idle = (status == SESSION_STATUS_IDLE);
+
DEBUG ("Session idle state changed, %s -> %s",
priv->is_idle ? "yes" : "no",
is_idle ? "yes" : "no");
@@ -465,7 +480,10 @@ empathy_idle_init (EmpathyIdle *idle)
if (error) {
DEBUG ("Error getting actual presence: %s", error->message);
- priv->state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
+ /* Fallback to OFFLINE as that's what mission_control_get_presence_actual
+ does. This also ensure to always display the status icon (there is no
+ unset presence icon). */
+ priv->state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
g_clear_error (&error);
}
priv->status = mission_control_get_presence_message_actual (priv->mc, &error);
@@ -485,15 +503,14 @@ empathy_idle_init (EmpathyIdle *idle)
idle, NULL);
priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
- "org.gnome.ScreenSaver",
- "/org/gnome/ScreenSaver",
- "org.gnome.ScreenSaver");
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager/Presence",
+ "org.gnome.SessionManager.Presence");
if (priv->gs_proxy) {
- dbus_g_proxy_add_signal (priv->gs_proxy, "SessionIdleChanged",
- G_TYPE_BOOLEAN,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->gs_proxy, "SessionIdleChanged",
- G_CALLBACK (idle_session_idle_changed_cb),
+ dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged",
+ G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged",
+ G_CALLBACK (idle_session_status_changed_cb),
idle, NULL);
} else {
DEBUG ("Failed to get gs proxy");
@@ -726,7 +743,7 @@ empathy_idle_set_use_nm (EmpathyIdle *idle,
g_clear_error (&error);
nm_status = NM_STATE_ASLEEP;
}
-
+
idle_nm_state_change_cb (priv->nm_proxy, nm_status, idle);
} else {
priv->nm_connected = TRUE;