From 330028919295ad9d65334383e90b2432cb12e5fd Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 23 Jan 2012 14:46:24 +0100 Subject: [PATCH] presence-manager: stop watching connectivity changes Mission-Control does it for us now (thanks Will!). We don't remove empathy-connectivity yet because some Empathy components still rely on it to display the status of the network. Ideally, this could be exposed by MC as well (fdo #45126). https://bugzilla.gnome.org/show_bug.cgi?id=668498 --- libempathy/empathy-presence-manager.c | 70 ++------------------------- 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/libempathy/empathy-presence-manager.c b/libempathy/empathy-presence-manager.c index 67867f96..22af1ec7 100644 --- a/libempathy/empathy-presence-manager.c +++ b/libempathy/empathy-presence-manager.c @@ -32,7 +32,6 @@ #include #include "empathy-utils.h" -#include "empathy-connectivity.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include "empathy-debug.h" @@ -47,7 +46,6 @@ struct _EmpathyPresenceManagerPrivate { DBusGProxy *gs_proxy; - EmpathyConnectivity *connectivity; gboolean ready; @@ -56,8 +54,6 @@ struct _EmpathyPresenceManagerPrivate gboolean auto_away; TpConnectionPresenceType away_saved_state; - TpConnectionPresenceType saved_state; - gchar *saved_status; gboolean is_idle; guint ext_away_timeout; @@ -175,9 +171,8 @@ session_status_changed_cb (DBusGProxy *gs_proxy, is_idle ? "yes" : "no"); if (!self->priv->auto_away || - (self->priv->saved_state == TP_CONNECTION_PRESENCE_TYPE_UNSET && - (self->priv->state <= TP_CONNECTION_PRESENCE_TYPE_OFFLINE || - self->priv->state == TP_CONNECTION_PRESENCE_TYPE_HIDDEN))) + (self->priv->state <= TP_CONNECTION_PRESENCE_TYPE_OFFLINE || + self->priv->state == TP_CONNECTION_PRESENCE_TYPE_HIDDEN)) { /* We don't want to go auto away OR we explicitely asked to be * offline, nothing to do here */ @@ -192,13 +187,7 @@ session_status_changed_cb (DBusGProxy *gs_proxy, ext_away_start (self); - if (self->priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) - /* We are disconnected, when coming back from away - * we want to restore the presence before the - * disconnection. */ - self->priv->away_saved_state = self->priv->saved_state; - else - self->priv->away_saved_state = self->priv->state; + self->priv->away_saved_state = self->priv->state; new_state = TP_CONNECTION_PRESENCE_TYPE_AWAY; if (self->priv->state == TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY) @@ -240,37 +229,6 @@ session_status_changed_cb (DBusGProxy *gs_proxy, self->priv->is_idle = is_idle; } -static void -state_change_cb (EmpathyConnectivity *connectivity, - gboolean new_online, - EmpathyPresenceManager *self) -{ - if (!new_online) - { - /* We are no longer connected */ - DEBUG ("Disconnected: Save state %d (%s)", - self->priv->state, self->priv->status); - self->priv->saved_state = self->priv->state; - g_free (self->priv->saved_status); - self->priv->saved_status = g_strdup (self->priv->status); - empathy_presence_manager_set_state (self, - TP_CONNECTION_PRESENCE_TYPE_OFFLINE); - } - else if (new_online - && self->priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) - { - /* We are now connected */ - DEBUG ("Reconnected: Restore state %d (%s)", - self->priv->saved_state, self->priv->saved_status); - empathy_presence_manager_set_presence (self, - self->priv->saved_state, - self->priv->saved_status); - self->priv->saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET; - g_free (self->priv->saved_status); - self->priv->saved_status = NULL; - } -} - static void presence_manager_dispose (GObject *object) { @@ -279,7 +237,6 @@ presence_manager_dispose (GObject *object) tp_clear_object (&self->priv->gs_proxy); tp_clear_object (&self->priv->manager); - tp_clear_object (&self->priv->connectivity); tp_clear_pointer (&self->priv->connect_times, g_hash_table_unref); next_away_stop (EMPATHY_PRESENCE_MANAGER (object)); @@ -530,11 +487,6 @@ empathy_presence_manager_init (EmpathyPresenceManager *self) g_object_unref (dbus); - self->priv->connectivity = empathy_connectivity_dup_singleton (); - - tp_g_signal_connect_object (self->priv->connectivity, - "state-change", G_CALLBACK (state_change_cb), self, 0); - self->priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal); } @@ -609,22 +561,6 @@ empathy_presence_manager_set_presence (EmpathyPresenceManager *self, if (!tp_strdiff (status, default_status)) status = NULL; - if (state != TP_CONNECTION_PRESENCE_TYPE_OFFLINE && - !empathy_connectivity_is_online (self->priv->connectivity)) - { - DEBUG ("Empathy is not online"); - - self->priv->saved_state = state; - if (tp_strdiff (self->priv->status, status)) - { - g_free (self->priv->saved_status); - self->priv->saved_status = NULL; - if (!EMP_STR_EMPTY (status)) - self->priv->saved_status = g_strdup (status); - } - return; - } - empathy_presence_manager_do_set_presence (self, state, status); } -- 2.39.2