aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-account-widget.c17
-rw-r--r--libempathy/empathy-account-settings.c16
-rw-r--r--libempathy/empathy-account-settings.h1
-rw-r--r--src/empathy-account-assistant.c2
4 files changed, 31 insertions, 5 deletions
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);
}
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 604392202..541a7e113 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -1422,9 +1422,10 @@ empathy_account_settings_account_updated (GObject *source,
EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
GSimpleAsyncResult *r;
GError *error = NULL;
+ GStrv reconnect_required;
if (!tp_account_update_parameters_finish (TP_ACCOUNT (source),
- result, NULL, &error))
+ result, &reconnect_required, &error))
{
g_simple_async_result_set_from_error (priv->apply_result, error);
g_error_free (error);
@@ -1449,6 +1450,9 @@ empathy_account_settings_account_updated (GObject *source,
return;
}
+ g_simple_async_result_set_op_res_gboolean (priv->apply_result,
+ g_strv_length (reconnect_required) > 0);
+
out:
empathy_account_settings_discard_changes (settings);
@@ -1457,6 +1461,7 @@ out:
g_simple_async_result_complete (r);
g_object_unref (r);
+ g_strfreev (reconnect_required);
}
static void
@@ -1589,6 +1594,10 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
priv->apply_result = g_simple_async_result_new (G_OBJECT (settings),
callback, user_data, empathy_account_settings_apply_finish);
+ /* We'll have to reconnect only if we change none DBus_Property on an
+ * existing account. */
+ g_simple_async_result_set_op_res_gboolean (priv->apply_result, FALSE);
+
if (priv->account == NULL)
{
tp_account_manager_prepare_async (priv->account_manager, NULL,
@@ -1605,6 +1614,7 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
gboolean
empathy_account_settings_apply_finish (EmpathyAccountSettings *settings,
GAsyncResult *result,
+ gboolean *reconnect_required,
GError **error)
{
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
@@ -1614,6 +1624,10 @@ empathy_account_settings_apply_finish (EmpathyAccountSettings *settings,
g_return_val_if_fail (g_simple_async_result_is_valid (result,
G_OBJECT (settings), empathy_account_settings_apply_finish), FALSE);
+ if (reconnect_required != NULL)
+ *reconnect_required = g_simple_async_result_get_op_res_gboolean (
+ G_SIMPLE_ASYNC_RESULT (result));
+
return TRUE;
}
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index 4d5f6ddc9..fb2b8f4c6 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -174,6 +174,7 @@ void empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
gboolean empathy_account_settings_apply_finish (
EmpathyAccountSettings *settings,
GAsyncResult *result,
+ gboolean *reconnect_required,
GError **error);
void empathy_account_settings_set_regex (EmpathyAccountSettings *settings,
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index 26032d7e8..2c89d6fc8 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -319,7 +319,7 @@ account_assistant_apply_account_cb (GObject *source,
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
TpAccount *account;
- empathy_account_settings_apply_finish (settings, result, &error);
+ empathy_account_settings_apply_finish (settings, result, NULL, &error);
priv->is_creating = FALSE;