aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-15 18:20:59 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-16 18:28:38 +0800
commita98b91f97661f7a94ef44f957f1edbfebf680fc2 (patch)
treee10ee0dd1723c6e4e24b19889e9dd4f606fd5f3a
parent2d295e9cc7b2ce7a173144624e7226765a125c65 (diff)
downloadgsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar.gz
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar.bz2
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar.lz
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar.xz
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.tar.zst
gsoc2013-empathy-a98b91f97661f7a94ef44f957f1edbfebf680fc2.zip
only try reconnecting accounts if needed (#642358)
-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 7d71f3ac7..63bf9275a 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -766,8 +766,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)
{
@@ -804,10 +806,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 2ee1a3933..12bde7b5b 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -1363,9 +1363,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);
@@ -1390,6 +1391,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);
@@ -1398,6 +1402,7 @@ out:
g_simple_async_result_complete (r);
g_object_unref (r);
+ g_strfreev (reconnect_required);
}
static void
@@ -1526,6 +1531,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,
@@ -1542,6 +1551,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),
@@ -1551,6 +1561,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 d92a59598..3a2264e28 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -170,6 +170,7 @@ void empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
gboolean empathy_account_settings_apply_finish (
EmpathyAccountSettings *settings,
GAsyncResult *result,
+ gboolean *reconnect_required,
GError **error);
gboolean empathy_account_settings_is_valid (EmpathyAccountSettings *settings);
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index a8245c604..dee2d31af 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;