aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-26 15:47:20 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-26 17:02:51 +0800
commit08d8020862035a1d8f4e41a31b10dcde870d8b73 (patch)
tree2e8ed9d22dd71632a47265d9c97fb6715d753b3a /src
parent2a1759c28d088b821fdf0ae7f86cac153fd9d46e (diff)
downloadgsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar.gz
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar.bz2
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar.lz
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar.xz
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.tar.zst
gsoc2013-empathy-08d8020862035a1d8f4e41a31b10dcde870d8b73.zip
empathy-accounts: re-use existing TpAccount rather than creating a new one
This allows us to detect right away if the account is a valid one and we don't have to prepare it any more as the AM already did it for us. https://bugzilla.gnome.org/show_bug.cgi?id=662504
Diffstat (limited to 'src')
-rw-r--r--src/empathy-accounts.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c
index 3cad96744..d3cdf2a50 100644
--- a/src/empathy-accounts.c
+++ b/src/empathy-accounts.c
@@ -58,27 +58,6 @@ static gboolean account_manager_prepared = FALSE;
static gboolean assistant = FALSE;
static void
-account_prepare_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data);
- TpAccount *account = TP_ACCOUNT (source_object);
- GError *error = NULL;
-
- if (!tp_proxy_prepare_finish (account, result, &error))
- {
- DEBUG ("Failed to prepare account: %s", error->message);
- g_error_free (error);
-
- account = NULL;
- }
-
- empathy_accounts_show_accounts_ui (manager, account, assistant,
- G_CALLBACK (gtk_main_quit));
-}
-
-static void
maybe_show_accounts_ui (TpAccountManager *manager)
{
if (hidden ||
@@ -88,6 +67,27 @@ maybe_show_accounts_ui (TpAccountManager *manager)
empathy_accounts_show_accounts_ui (manager, NULL, assistant, gtk_main_quit);
}
+static TpAccount *
+find_account (TpAccountManager *mgr,
+ const gchar *path)
+{
+ GList *accounts, *l;
+ TpAccount *found = NULL;
+
+ accounts = tp_account_manager_get_valid_accounts (mgr);
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ if (!tp_strdiff (tp_proxy_get_object_path (l->data), path))
+ {
+ found = l->data;
+ break;
+ }
+ }
+
+ g_list_free (accounts);
+ return found;
+}
+
static void
account_manager_ready_for_accounts_cb (GObject *source_object,
GAsyncResult *result,
@@ -108,8 +108,7 @@ account_manager_ready_for_accounts_cb (GObject *source_object,
if (selected_account_name != NULL)
{
gchar *account_path;
- TpAccount *account = NULL;
- TpDBusDaemon *bus;
+ TpAccount *account;
/* create and prep the corresponding TpAccount so it's fully ready by the
* time we try to select it in the accounts dialog */
@@ -119,23 +118,24 @@ account_manager_ready_for_accounts_cb (GObject *source_object,
account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
selected_account_name);
- bus = tp_dbus_daemon_dup (NULL);
- if ((account = tp_account_new (bus, account_path, &error)))
+ account = find_account (manager, account_path);
+
+ if (account != NULL)
{
- tp_proxy_prepare_async (account, NULL, account_prepare_cb, manager);
- g_object_unref (bus);
+ empathy_accounts_show_accounts_ui (manager, account, assistant,
+ G_CALLBACK (gtk_main_quit));
+
return;
}
else
{
- DEBUG ("Failed to find account with path %s: %s", account_path,
- error->message);
+ DEBUG ("Failed to find account with path %s", account_path);
+
g_clear_error (&error);
maybe_show_accounts_ui (manager);
}
- g_object_unref (bus);
g_free (account_path);
}
else