From d4cc2c6f60ba99c5e7772b08af6407b983f4b7a0 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 15 Feb 2011 11:20:59 +0100 Subject: only try reconnecting accounts if needed (#642358) --- libempathy-gtk/empathy-account-widget.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index f53df39d3..f4d6f7e9c 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -923,8 +923,10 @@ account_widget_applied_cb (GObject *source_object, EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object); EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data); EmpathyAccountWidgetPriv *priv = GET_PRIV (widget); + gboolean reconnect_required; - empathy_account_settings_apply_finish (settings, res, &error); + empathy_account_settings_apply_finish (settings, res, &reconnect_required, + &error); if (error != NULL) { @@ -961,10 +963,19 @@ account_widget_applied_cb (GObject *source_object, GTK_TOGGLE_BUTTON (priv->enabled_checkbox)); #endif /* HAVE_MEEGO */ - if (tp_account_is_enabled (account) && enabled_checked) + /* If the account was offline, we always want to try reconnecting, + * to give it a chance to connect if the previous params were wrong. + * tp_account_reconnect_async() won't do anything if the requested + * presence is offline anyway. */ + if (tp_account_get_connection_status (account, NULL) == + TP_CONNECTION_STATUS_DISCONNECTED) + reconnect_required = TRUE; + + if (reconnect_required && tp_account_is_enabled (account) + && enabled_checked) { /* After having applied changes to a user account, we - * automatically reconnect it. This is done so the new + * reconnect it if needed. This is done so the new * information entered by the user is validated on the server. */ tp_account_reconnect_async (account, NULL, NULL); } -- cgit v1.2.3