/* empathy-import-widget.c */
+#include <config.h>
+
#include "empathy-import-dialog.h"
#include "empathy-import-widget.h"
#include "empathy-import-pidgin.h"
#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>
+#include <glib/gi18n-lib.h>
G_DEFINE_TYPE (EmpathyImportWidget, empathy_import_widget, G_TYPE_OBJECT)
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;
+ parameters = tp_account_get_parameters (account);
- account_string = g_value_get_string (value);
-
- result = tp_strdiff (account_string, account_id);
-
- if (!result)
+ if (!tp_strdiff (tp_asv_get_string (parameters, "account"), account_id))
return TRUE;
}
}
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_proxy_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));
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);
COL_ACCOUNT_DATA, data,
-1);
}
+}
+
+static void
+import_widget_add_accounts_to_model (EmpathyImportWidget *self)
+{
+ TpAccountManager *manager;
+
+ manager = tp_account_manager_dup ();
+
+ tp_proxy_prepare_async (manager, NULL,
+ account_manager_prepared_cb, self);
g_object_unref (manager);
}
GAsyncResult *result,
gpointer user_data)
{
- EmpathyAccount *account;
+ TpAccountManager *account_manager;
+ 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)
{
DEBUG ("account created\n");
+ if (tp_account_is_enabled (account))
+ {
+ account_manager = tp_account_manager_dup ();
+ empathy_connect_new_account (account, account_manager);
+ g_object_unref (account_manager);
+ }
+
g_object_unref (self);
}
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);
DEBUG ("display name: %s\n", display_name);
- properties = g_hash_table_new (NULL, NULL);
+ properties = tp_asv_new (NULL, NULL);
+ tp_asv_set_boolean (properties, TP_IFACE_ACCOUNT ".Enabled", data->enabled);
- 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));
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
+ priv->accounts = empathy_import_accounts_load (priv->app_id);
+
store = gtk_list_store_new (COL_COUNT, G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
}
static void
-import_widget_cms_ready_cb (EmpathyConnectionManagers *cms,
- GParamSpec *pspec,
- EmpathyImportWidget *self)
+import_widget_cms_prepare_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
- if (empathy_connection_managers_is_ready (cms))
- import_widget_set_up_account_list (self);
+ EmpathyImportWidget *self = user_data;
+
+ if (!empathy_connection_managers_prepare_finish (
+ EMPATHY_CONNECTION_MANAGERS (source), result, NULL))
+ return;
+
+ import_widget_set_up_account_list (self);
}
static void
GtkBuilder *gui;
gchar *filename;
- priv->accounts = empathy_import_accounts_load (priv->app_id);
-
filename = empathy_file_lookup ("empathy-import-dialog.ui", "src");
gui = empathy_builder_get_file (filename,
"widget_vbox", &priv->vbox,
g_signal_connect (priv->vbox, "destroy",
G_CALLBACK (import_widget_destroy_cb), self);
- if (empathy_connection_managers_is_ready (priv->cms))
- import_widget_set_up_account_list (self);
- else
- g_signal_connect (priv->cms, "notify::ready",
- G_CALLBACK (import_widget_cms_ready_cb), self);
+ empathy_connection_managers_prepare_async (priv->cms,
+ import_widget_cms_prepare_cb, self);
}
static void