aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-import-widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/empathy-import-widget.c')
-rw-r--r--src/empathy-import-widget.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c
index 2dc810b0a..5a0d82c8c 100644
--- a/src/empathy-import-widget.c
+++ b/src/empathy-import-widget.c
@@ -28,13 +28,12 @@
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-account.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-ui-utils.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <glib/gi18n.h>
@@ -77,24 +76,12 @@ import_widget_account_id_in_list (GList *accounts,
for (l = accounts; l; l = l->next)
{
- EmpathyAccount *account = l->data;
- const gchar *account_string;
- GValue *value;
- gboolean result;
+ TpAccount *account = l->data;
const GHashTable *parameters;
- parameters = empathy_account_get_parameters (account);
-
- value = g_hash_table_lookup ((GHashTable *) parameters, "account");
-
- if (value == NULL)
- continue;
-
- account_string = g_value_get_string (value);
-
- result = tp_strdiff (account_string, account_id);
+ parameters = tp_account_get_parameters (account);
- if (!result)
+ if (!tp_strdiff (tp_asv_get_string (parameters, "account"), account_id))
return TRUE;
}
@@ -102,13 +89,24 @@ import_widget_account_id_in_list (GList *accounts,
}
static void
-import_widget_add_accounts_to_model (EmpathyImportWidget *self)
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyImportWidget *self = user_data;
GtkTreeModel *model;
GtkTreeIter iter;
GList *l;
EmpathyImportWidgetPriv *priv = GET_PRIV (self);
- EmpathyAccountManager *manager = empathy_account_manager_dup_singleton ();
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
@@ -128,14 +126,13 @@ import_widget_add_accounts_to_model (EmpathyImportWidget *self)
value = g_hash_table_lookup (data->settings, "account");
- accounts = empathy_account_manager_dup_accounts (manager);
+ accounts = tp_account_manager_get_valid_accounts (manager);
/* Only set the "Import" cell to be active if there isn't already an
* account set up with the same account id. */
import = !import_widget_account_id_in_list (accounts,
g_value_get_string (value));
- g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
g_list_free (accounts);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
@@ -148,6 +145,17 @@ import_widget_add_accounts_to_model (EmpathyImportWidget *self)
COL_ACCOUNT_DATA, data,
-1);
}
+}
+
+static void
+import_widget_add_accounts_to_model (EmpathyImportWidget *self)
+{
+ TpAccountManager *manager;
+
+ manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (manager, NULL,
+ account_manager_prepared_cb, self);
g_object_unref (manager);
}
@@ -157,12 +165,12 @@ import_widget_create_account_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
- EmpathyAccount *account;
+ TpAccount *account;
GError *error = NULL;
EmpathyImportWidget *self = user_data;
- account = empathy_account_manager_create_account_finish (
- EMPATHY_ACCOUNT_MANAGER (source), result, &error);
+ account = tp_account_manager_create_account_finish (
+ TP_ACCOUNT_MANAGER (source), result, &error);
if (account == NULL)
{
@@ -181,12 +189,12 @@ static void
import_widget_add_account (EmpathyImportWidget *self,
EmpathyImportAccountData *data)
{
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
gchar *display_name;
GHashTable *properties;
GValue *username;
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
DEBUG ("connection_manager: %s\n", data->connection_manager);
@@ -200,7 +208,7 @@ import_widget_add_account (EmpathyImportWidget *self,
properties = g_hash_table_new (NULL, NULL);
- empathy_account_manager_create_account_async (account_manager,
+ tp_account_manager_create_account_async (account_manager,
(const gchar*) data->connection_manager, data->protocol, display_name,
data->settings, properties, import_widget_create_account_cb,
g_object_ref (self));