aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-presence-chooser.c3
-rw-r--r--libempathy/empathy-connectivity.c31
-rw-r--r--libempathy/empathy-idle.c5
3 files changed, 24 insertions, 15 deletions
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index b0668196b..490ad898a 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -713,7 +713,6 @@ presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser,
static void
presence_chooser_connectivity_state_change (EmpathyConnectivity *connectivity,
- gboolean old_online,
gboolean new_online,
EmpathyPresenceChooser *chooser)
{
@@ -796,7 +795,7 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
g_signal_connect (priv->connectivity, "state-change",
G_CALLBACK (presence_chooser_connectivity_state_change),
chooser);
- presence_chooser_connectivity_state_change (priv->connectivity, FALSE,
+ presence_chooser_connectivity_state_change (priv->connectivity,
empathy_connectivity_is_online (priv->connectivity), chooser);
}
diff --git a/libempathy/empathy-connectivity.c b/libempathy/empathy-connectivity.c
index 8c38cf2c3..82ac9c9cb 100644
--- a/libempathy/empathy-connectivity.c
+++ b/libempathy/empathy-connectivity.c
@@ -58,6 +58,23 @@ static EmpathyConnectivity *connectivity_singleton = NULL;
G_DEFINE_TYPE (EmpathyConnectivity, empathy_connectivity, G_TYPE_OBJECT);
+static void
+connectivity_change_state (EmpathyConnectivity *connectivity,
+ gboolean new_state)
+{
+ EmpathyConnectivityPriv *priv;
+
+ priv = GET_PRIV (connectivity);
+
+ if (priv->connected == new_state)
+ return;
+
+ priv->connected = new_state;
+
+ g_signal_emit (connectivity, signals[STATE_CHANGE], 0,
+ priv->connected);
+}
+
#ifdef HAVE_NM
static void
connectivity_nm_state_change_cb (NMClient *client,
@@ -65,7 +82,6 @@ connectivity_nm_state_change_cb (NMClient *client,
EmpathyConnectivity *connectivity)
{
EmpathyConnectivityPriv *priv;
- gboolean old_nm_connected;
gboolean new_nm_connected;
NMState state;
@@ -75,16 +91,12 @@ connectivity_nm_state_change_cb (NMClient *client,
return;
state = nm_client_get_state (priv->nm_client);
- old_nm_connected = priv->connected;
new_nm_connected = !(state == NM_STATE_CONNECTING
|| state == NM_STATE_DISCONNECTED);
DEBUG ("New NetworkManager network state %d", state);
- priv->connected = new_nm_connected;
-
- g_signal_emit (connectivity, signals[STATE_CHANGE], 0,
- old_nm_connected, new_nm_connected);
+ connectivity_change_state (connectivity, new_nm_connected);
}
#endif
@@ -223,9 +235,9 @@ empathy_connectivity_class_init (EmpathyConnectivityClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- _empathy_marshal_VOID__BOOLEAN_BOOLEAN,
+ _empathy_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
- 2, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, NULL);
+ 1, G_TYPE_BOOLEAN, NULL);
g_object_class_install_property (oclass,
PROP_USE_CONN,
@@ -294,8 +306,7 @@ empathy_connectivity_set_use_conn (EmpathyConnectivity *connectivity,
}
else
{
- g_signal_emit (connectivity, signals[STATE_CHANGE], 0,
- FALSE, TRUE);
+ connectivity_change_state (connectivity, TRUE);
}
g_object_notify (G_OBJECT (connectivity), "use-conn");
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index c3e6b0177..f408cf69b 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -226,7 +226,6 @@ idle_session_status_changed_cb (DBusGProxy *gs_proxy,
static void
idle_state_change_cb (EmpathyConnectivity *connectivity,
- gboolean old_online,
gboolean new_online,
EmpathyIdle *idle)
{
@@ -234,7 +233,7 @@ idle_state_change_cb (EmpathyConnectivity *connectivity,
priv = GET_PRIV (idle);
- if (old_online && !new_online) {
+ if (!new_online) {
/* We are no longer connected */
DEBUG ("Disconnected: Save state %d (%s)",
priv->state, priv->status);
@@ -243,7 +242,7 @@ idle_state_change_cb (EmpathyConnectivity *connectivity,
priv->saved_status = g_strdup (priv->status);
empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
}
- else if (!old_online && new_online
+ else if (new_online
&& priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
/* We are now connected */
DEBUG ("Reconnected: Restore state %d (%s)",