[empathy/gnome-3-2] empathy-accounts: re-use existing TpAccount rather than creating a new one
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy/gnome-3-2] empathy-accounts: re-use existing TpAccount rather than creating a new one
- Date: Wed, 26 Oct 2011 09:24:58 +0000 (UTC)
commit 35c8dca4f051944b011ef8c0843548a10be9117b
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Wed Oct 26 11:12:44 2011 +0200
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
Conflicts:
src/empathy-accounts.c
src/empathy-accounts.c | 60 ++++++++++++++++++++++++------------------------
1 files changed, 30 insertions(+), 30 deletions(-)
---
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c
index 165dd05..de28f7a 100644
--- a/src/empathy-accounts.c
+++ b/src/empathy-accounts.c
@@ -57,27 +57,6 @@ static gchar *selected_account_name = NULL;
static gboolean account_manager_prepared = 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,
- G_CALLBACK (gtk_main_quit));
-}
-
-static void
maybe_show_accounts_ui (TpAccountManager *manager)
{
if (hidden ||
@@ -87,6 +66,27 @@ maybe_show_accounts_ui (TpAccountManager *manager)
empathy_accounts_show_accounts_ui (manager, NULL, 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,
@@ -107,8 +107,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 */
@@ -118,23 +117,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,
+ 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]