aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--libempathy-gtk/empathy-account-chooser.c177
-rw-r--r--libempathy-gtk/empathy-account-chooser.h10
-rw-r--r--libempathy-gtk/empathy-account-widget.c28
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c1
-rw-r--r--libempathy-gtk/empathy-chat.c68
-rw-r--r--libempathy-gtk/empathy-chat.h2
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.c7
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c18
-rw-r--r--libempathy-gtk/empathy-contact-widget.c6
-rw-r--r--libempathy-gtk/empathy-irc-network-dialog.c1
-rw-r--r--libempathy-gtk/empathy-location-manager.c104
-rw-r--r--libempathy-gtk/empathy-log-window.c79
-rw-r--r--libempathy-gtk/empathy-log-window.h4
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c1
-rw-r--r--libempathy-gtk/empathy-presence-chooser.c59
-rw-r--r--libempathy-gtk/empathy-theme-adium.c6
-rw-r--r--libempathy-gtk/empathy-ui-utils.h1
-rw-r--r--libempathy/Makefile.am4
-rw-r--r--libempathy/empathy-account-manager.c1060
-rw-r--r--libempathy/empathy-account-manager.h111
-rw-r--r--libempathy/empathy-account-settings.c154
-rw-r--r--libempathy/empathy-account-settings.h8
-rw-r--r--libempathy/empathy-account.c1305
-rw-r--r--libempathy/empathy-account.h124
-rw-r--r--libempathy/empathy-chatroom-manager.c62
-rw-r--r--libempathy/empathy-chatroom-manager.h11
-rw-r--r--libempathy/empathy-chatroom.c16
-rw-r--r--libempathy/empathy-chatroom.h11
-rw-r--r--libempathy/empathy-contact-manager.c71
-rw-r--r--libempathy/empathy-contact.c24
-rw-r--r--libempathy/empathy-contact.h6
-rw-r--r--libempathy/empathy-dispatcher.c80
-rw-r--r--libempathy/empathy-idle.c171
-rw-r--r--libempathy/empathy-idle.h7
-rw-r--r--libempathy/empathy-log-manager.c10
-rw-r--r--libempathy/empathy-log-manager.h12
-rw-r--r--libempathy/empathy-log-store-empathy.c36
-rw-r--r--libempathy/empathy-log-store.c12
-rw-r--r--libempathy/empathy-log-store.h26
-rw-r--r--libempathy/empathy-tp-roomlist.c10
-rw-r--r--libempathy/empathy-tp-roomlist.h4
-rw-r--r--libempathy/empathy-utils.c67
-rw-r--r--libempathy/empathy-utils.h4
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/empathy-account-assistant.c6
-rw-r--r--src/empathy-accounts-dialog.c218
-rw-r--r--src/empathy-accounts-dialog.h4
-rw-r--r--src/empathy-chat-window.c27
-rw-r--r--src/empathy-chat-window.h5
-rw-r--r--src/empathy-chatrooms-window.c4
-rw-r--r--src/empathy-event-manager.c15
-rw-r--r--src/empathy-import-mc4-accounts.c10
-rw-r--r--src/empathy-import-widget.c62
-rw-r--r--src/empathy-main-window.c138
-rw-r--r--src/empathy-new-chatroom-dialog.c6
-rw-r--r--src/empathy-status-icon.c60
-rw-r--r--src/empathy.c223
-rw-r--r--tests/check-empathy-chatroom-manager.c2
-rw-r--r--tests/check-empathy-helpers.c2
-rw-r--r--tests/check-empathy-helpers.h7
61 files changed, 1308 insertions, 3462 deletions
diff --git a/configure.ac b/configure.ac
index 67b2d2e4f..b68ebb696 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ GLIB_REQUIRED=2.22.0
GTK_REQUIRED=2.16.0
GCONF_REQUIRED=1.2.0
LIBPANELAPPLET_REQUIRED=2.10.0
-TELEPATHY_GLIB_REQUIRED=0.7.35
+TELEPATHY_GLIB_REQUIRED=0.9.0
ENCHANT_REQUIRED=1.2.0
ISO_CODES_REQUIRED=0.35
LIBNOTIFY_REQUIRED=0.4.4
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index a91b0eb29..8256707c0 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -29,12 +29,16 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libempathy/empathy-account-manager.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-utils.h>
#include "empathy-ui-utils.h"
#include "empathy-account-chooser.h"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
+
/**
* SECTION:empathy-account-chooser
* @title:EmpathyAccountChooser
@@ -54,7 +58,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountChooser)
typedef struct {
- EmpathyAccountManager *manager;
+ TpAccountManager *manager;
gboolean set_active_item;
gboolean account_manually_set;
gboolean has_all_option;
@@ -64,7 +68,7 @@ typedef struct {
typedef struct {
EmpathyAccountChooser *chooser;
- EmpathyAccount *account;
+ TpAccount *account;
gboolean set;
} SetAccountData;
@@ -86,24 +90,26 @@ static void account_chooser_set_property (GObject
const GValue *value,
GParamSpec *pspec);
static void account_chooser_setup (EmpathyAccountChooser *chooser);
-static void account_chooser_account_created_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+static void account_chooser_account_validity_changed_cb (TpAccountManager *manager,
+ TpAccount *account,
+ gboolean valid,
EmpathyAccountChooser *chooser);
-static void account_chooser_account_add_foreach (EmpathyAccount *account,
+static void account_chooser_account_add_foreach (TpAccount *account,
EmpathyAccountChooser *chooser);
-static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+static void account_chooser_account_removed_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountChooser *chooser);
-static void account_chooser_account_remove_foreach (EmpathyAccount *account,
+static void account_chooser_account_remove_foreach (TpAccount *account,
EmpathyAccountChooser *chooser);
static void account_chooser_update_iter (EmpathyAccountChooser *chooser,
GtkTreeIter *iter);
-static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus new_status,
- TpConnectionStatus old_status,
- EmpathyAccountChooser *chooser);
+static void account_chooser_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ gpointer user_data);
static gboolean account_chooser_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
EmpathyAccountChooser *chooser);
@@ -156,16 +162,13 @@ empathy_account_chooser_init (EmpathyAccountChooser *chooser)
priv->filter = NULL;
priv->filter_data = NULL;
- priv->manager = empathy_account_manager_dup_singleton ();
+ priv->manager = tp_account_manager_dup ();
- g_signal_connect (priv->manager, "account-created",
- G_CALLBACK (account_chooser_account_created_cb),
- chooser);
- g_signal_connect (priv->manager, "account-deleted",
- G_CALLBACK (account_chooser_account_deleted_cb),
+ g_signal_connect (priv->manager, "account-validity-changed",
+ G_CALLBACK (account_chooser_account_validity_changed_cb),
chooser);
- g_signal_connect (priv->manager, "account-connection-changed",
- G_CALLBACK (account_chooser_connection_changed_cb),
+ g_signal_connect (priv->manager, "account-removed",
+ G_CALLBACK (account_chooser_account_removed_cb),
chooser);
account_chooser_setup (EMPATHY_ACCOUNT_CHOOSER (chooser));
@@ -177,13 +180,10 @@ account_chooser_finalize (GObject *object)
EmpathyAccountChooserPriv *priv = GET_PRIV (object);
g_signal_handlers_disconnect_by_func (priv->manager,
- account_chooser_connection_changed_cb,
+ account_chooser_account_validity_changed_cb,
object);
g_signal_handlers_disconnect_by_func (priv->manager,
- account_chooser_account_created_cb,
- object);
- g_signal_handlers_disconnect_by_func (priv->manager,
- account_chooser_account_deleted_cb,
+ account_chooser_account_removed_cb,
object);
g_object_unref (priv->manager);
@@ -253,16 +253,16 @@ empathy_account_chooser_new (void)
* @chooser: an #EmpathyAccountChooser
*
* Returns the account which is currently selected in the chooser or %NULL
- * if there is no account selected. The #EmpathyAccount returned should be
+ * if there is no account selected. The #TpAccount returned should be
* unrefed with g_object_unref() when finished with.
*
- * Return value: a new ref to the #EmpathyAccount currently selected, or %NULL.
+ * Return value: a new ref to the #TpAccount currently selected, or %NULL.
*/
-EmpathyAccount *
+TpAccount *
empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser)
{
EmpathyAccountChooserPriv *priv;
- EmpathyAccount *account;
+ TpAccount *account;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -295,7 +295,7 @@ TpConnection *
empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
{
EmpathyAccountChooserPriv *priv;
- EmpathyAccount *account;
+ TpAccount *account;
TpConnection *connection;
g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL);
@@ -303,7 +303,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
priv = GET_PRIV (chooser);
account = empathy_account_chooser_dup_account (chooser);
- connection = empathy_account_get_connection (account);
+ connection = tp_account_get_connection (account);
g_object_unref (account);
return connection;
@@ -312,7 +312,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
/**
* empathy_account_chooser_set_account:
* @chooser: an #EmpathyAccountChooser
- * @account: an #EmpathyAccount
+ * @account: a #TpAccount
*
* Sets the currently selected account to @account, if it exists in the list.
*
@@ -320,7 +320,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
*/
gboolean
empathy_account_chooser_set_account (EmpathyAccountChooser *chooser,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyAccountChooserPriv *priv;
GtkComboBox *combobox;
@@ -443,10 +443,40 @@ empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser,
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *l;
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyAccountChooser *chooser = user_data;
+ 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;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (manager);
+
+ for (l = accounts; l != NULL; l = l->next) {
+ TpAccount *account = l->data;
+
+ account_chooser_account_add_foreach (account, chooser);
+
+ empathy_signal_connect_weak (account, "status-changed",
+ G_CALLBACK (account_chooser_status_changed_cb),
+ G_OBJECT (chooser));
+ }
+
+ g_list_free (accounts);
+}
+
+static void
account_chooser_setup (EmpathyAccountChooser *chooser)
{
EmpathyAccountChooserPriv *priv;
- GList *accounts;
GtkListStore *store;
GtkCellRenderer *renderer;
GtkComboBox *combobox;
@@ -462,7 +492,7 @@ account_chooser_setup (EmpathyAccountChooser *chooser)
G_TYPE_STRING, /* Image */
G_TYPE_STRING, /* Name */
G_TYPE_BOOLEAN, /* Enabled */
- EMPATHY_TYPE_ACCOUNT);
+ TP_TYPE_ACCOUNT);
gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store));
@@ -482,25 +512,27 @@ account_chooser_setup (EmpathyAccountChooser *chooser)
NULL);
/* Populate accounts */
- accounts = empathy_account_manager_dup_accounts (priv->manager);
- g_list_foreach (accounts,
- (GFunc) account_chooser_account_add_foreach,
- chooser);
+ tp_account_manager_prepare_async (priv->manager, NULL,
+ account_manager_prepared_cb, chooser);
- g_list_free (accounts);
g_object_unref (store);
}
static void
-account_chooser_account_created_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountChooser *chooser)
+account_chooser_account_validity_changed_cb (TpAccountManager *manager,
+ TpAccount *account,
+ gboolean valid,
+ EmpathyAccountChooser *chooser)
{
- account_chooser_account_add_foreach (account, chooser);
+ if (valid) {
+ account_chooser_account_add_foreach (account, chooser);
+ } else {
+ account_chooser_account_remove_foreach (account, chooser);
+ }
}
static void
-account_chooser_account_add_foreach (EmpathyAccount *account,
+account_chooser_account_add_foreach (TpAccount *account,
EmpathyAccountChooser *chooser)
{
GtkListStore *store;
@@ -516,20 +548,18 @@ account_chooser_account_add_foreach (EmpathyAccount *account,
COL_ACCOUNT_POINTER, account,
-1);
account_chooser_update_iter (chooser, &iter);
- /* We got a reffed account and it was reffed by the liststore as well */
- g_object_unref (account);
}
static void
-account_chooser_account_deleted_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+account_chooser_account_removed_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountChooser *chooser)
{
account_chooser_account_remove_foreach (account, chooser);
}
typedef struct {
- EmpathyAccount *account;
+ TpAccount *account;
GtkTreeIter *iter;
gboolean found;
} FindAccountData;
@@ -541,7 +571,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model,
gpointer user_data)
{
FindAccountData *data = user_data;
- EmpathyAccount *account;
+ TpAccount *account;
gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
@@ -560,7 +590,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model,
static gboolean
account_chooser_find_account (EmpathyAccountChooser *chooser,
- EmpathyAccount *account,
+ TpAccount *account,
GtkTreeIter *iter)
{
GtkListStore *store;
@@ -580,7 +610,7 @@ account_chooser_find_account (EmpathyAccountChooser *chooser,
}
static void
-account_chooser_account_remove_foreach (EmpathyAccount *account,
+account_chooser_account_remove_foreach (TpAccount *account,
EmpathyAccountChooser *chooser)
{
GtkListStore *store;
@@ -602,7 +632,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
EmpathyAccountChooserPriv *priv;
GtkListStore *store;
GtkComboBox *combobox;
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *icon_name;
gboolean is_enabled = TRUE;
@@ -615,14 +645,14 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
COL_ACCOUNT_POINTER, &account,
-1);
- icon_name = empathy_account_get_icon_name (account);
+ icon_name = tp_account_get_icon_name (account);
if (priv->filter) {
is_enabled = priv->filter (account, priv->filter_data);
}
gtk_list_store_set (store, iter,
COL_ACCOUNT_IMAGE, icon_name,
- COL_ACCOUNT_TEXT, empathy_account_get_display_name (account),
+ COL_ACCOUNT_TEXT, tp_account_get_display_name (account),
COL_ACCOUNT_ENABLED, is_enabled,
-1);
@@ -637,13 +667,15 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
}
static void
-account_chooser_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus new_status,
- TpConnectionStatus old_status,
- EmpathyAccountChooser *chooser)
+account_chooser_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ gpointer user_data)
{
+ EmpathyAccountChooser *chooser = user_data;
GtkTreeIter iter;
if (account_chooser_find_account (chooser, account, &iter)) {
@@ -679,7 +711,7 @@ account_chooser_set_account_foreach (GtkTreeModel *model,
GtkTreeIter *iter,
SetAccountData *data)
{
- EmpathyAccount *account;
+ TpAccount *account;
gboolean equal;
gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
@@ -750,7 +782,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser,
/**
* EmpathyAccountChooserFilterFunc:
- * @account: an #EmpathyAccount
+ * @account: a #TpAccount
* @user_data: user data, or %NULL
*
* A function which decides whether the account indicated by @account
@@ -761,7 +793,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser,
/**
* empathy_account_chooser_filter_is_connected:
- * @account: an #EmpathyAccount
+ * @account: a #TpAccount
* @user_data: user data or %NULL
*
* A useful #EmpathyAccountChooserFilterFunc that one could pass into
@@ -770,13 +802,10 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser,
* Return value: Whether @account is connected
*/
gboolean
-empathy_account_chooser_filter_is_connected (EmpathyAccount *account,
+empathy_account_chooser_filter_is_connected (TpAccount *account,
gpointer user_data)
{
- TpConnectionStatus status;
-
- g_object_get (account, "connection-status", &status, NULL);
-
- return status == TP_CONNECTION_STATUS_CONNECTED;
+ return (tp_account_get_connection_status (account, NULL)
+ == TP_CONNECTION_STATUS_CONNECTED);
}
diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h
index 255b6841f..075bea81c 100644
--- a/libempathy-gtk/empathy-account-chooser.h
+++ b/libempathy-gtk/empathy-account-chooser.h
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
G_BEGIN_DECLS
@@ -38,7 +38,7 @@ G_BEGIN_DECLS
#define EMPATHY_IS_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER))
#define EMPATHY_ACCOUNT_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass))
-typedef gboolean (* EmpathyAccountChooserFilterFunc) (EmpathyAccount *account,
+typedef gboolean (* EmpathyAccountChooserFilterFunc) (TpAccount *account,
gpointer user_data);
@@ -58,17 +58,17 @@ struct _EmpathyAccountChooserClass {
GType empathy_account_chooser_get_type (void) G_GNUC_CONST;
GtkWidget * empathy_account_chooser_new (void);
-EmpathyAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser);
+TpAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser);
TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser);
gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser,
- EmpathyAccount *account);
+ TpAccount *account);
gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser);
void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser,
gboolean has_all_option);
void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser,
EmpathyAccountChooserFilterFunc filter,
gpointer user_data);
-gboolean empathy_account_chooser_filter_is_connected (EmpathyAccount *account,
+gboolean empathy_account_chooser_filter_is_connected (TpAccount *account,
gpointer user_data);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 05911144a..293b2c711 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -35,8 +35,8 @@
#endif
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
#include <telepathy-glib/connection-manager.h>
#include <telepathy-glib/util.h>
#include <dbus/dbus-protocol.h>
@@ -570,10 +570,10 @@ account_widget_account_enabled_cb (GObject *source_object,
gpointer user_data)
{
GError *error = NULL;
- EmpathyAccount *account = EMPATHY_ACCOUNT (source_object);
+ TpAccount *account = TP_ACCOUNT (source_object);
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
- empathy_account_set_enabled_finish (account, res, &error);
+ tp_account_set_enabled_finish (account, res, &error);
if (error != NULL)
{
@@ -592,7 +592,7 @@ account_widget_applied_cb (GObject *source_object,
gpointer user_data)
{
GError *error = NULL;
- EmpathyAccount *account;
+ TpAccount *account;
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
@@ -613,7 +613,7 @@ account_widget_applied_cb (GObject *source_object,
if (priv->creating_account)
{
/* By default, when an account is created, we enable it. */
- empathy_account_set_enabled_async (account, TRUE,
+ tp_account_set_enabled_async (account, TRUE,
account_widget_account_enabled_cb, widget);
}
else if (priv->enabled_checkbox != NULL)
@@ -629,12 +629,12 @@ account_widget_applied_cb (GObject *source_object,
NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
#endif
- if (empathy_account_is_enabled (account) && enabled_checked)
+ if (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
* information entered by the user is validated on the server. */
- empathy_account_reconnect_async (account, NULL, NULL);
+ tp_account_reconnect_async (account, NULL, NULL);
}
}
}
@@ -1047,13 +1047,13 @@ account_widget_destroy_cb (GtkWidget *widget,
}
static void
-empathy_account_widget_enabled_cb (EmpathyAccount *account,
+empathy_account_widget_enabled_cb (TpAccount *account,
GParamSpec *spec,
gpointer user_data)
{
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
- gboolean enabled = empathy_account_is_enabled (account);
+ gboolean enabled = tp_account_is_enabled (account);
if (priv->enabled_checkbox != NULL)
{
@@ -1079,7 +1079,7 @@ account_widget_switch_flipped_cb (NbtkGtkLightSwitch *sw,
#endif /* HAVE_MOBLIN */
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (user_data);
- EmpathyAccount *account;
+ TpAccount *account;
#ifndef HAVE_MOBLIN
gboolean state;
@@ -1089,7 +1089,7 @@ account_widget_switch_flipped_cb (NbtkGtkLightSwitch *sw,
account = empathy_account_settings_get_account (priv->settings);
/* Enable the account according to the value of the "Enabled" checkbox */
- empathy_account_set_enabled_async (account, state, NULL, NULL);
+ tp_account_set_enabled_async (account, state, NULL, NULL);
}
static void
@@ -1153,7 +1153,7 @@ do_constructed (GObject *obj)
{
EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *protocol, *cm_name;
guint i = 0;
struct {
@@ -1295,7 +1295,7 @@ do_constructed (GObject *obj)
guint nb_rows, nb_columns;
gboolean is_enabled;
- is_enabled = empathy_account_is_enabled (account);
+ is_enabled = tp_account_is_enabled (account);
#ifndef HAVE_MOBLIN
priv->enabled_checkbox =
@@ -1373,7 +1373,7 @@ do_dispose (GObject *obj)
if (priv->settings != NULL)
{
- EmpathyAccount *account;
+ TpAccount *account;
account = empathy_account_settings_get_account (priv->settings);
if (account != NULL)
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index 5822a429d..de777f2fb 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -36,7 +36,6 @@
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account.h>
#include "empathy-chat-text-view.h"
#include "empathy-chat.h"
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 3931115be..7984b8a3a 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -34,9 +34,9 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-log-manager.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-utils.h>
@@ -64,7 +64,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat)
typedef struct {
EmpathyTpChat *tp_chat;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *id;
gchar *name;
gchar *subject;
@@ -72,7 +72,7 @@ typedef struct {
gboolean show_contacts;
EmpathyLogManager *log_manager;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
GSList *sent_messages;
gint sent_messages_index;
GList *compositors;
@@ -196,15 +196,19 @@ chat_connect_channel_reconnected (EmpathyDispatchOperation *dispatch,
}
static void
-chat_new_connection_cb (EmpathyAccountManager *manager,
- TpConnection *connection,
+chat_new_connection_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
- EmpathyAccount *account;
+ TpConnection *connection;
+
+ connection = tp_account_get_connection (account);
- account = empathy_account_manager_get_account_for_connection (manager,
- connection);
if (!priv->tp_chat && account == priv->account &&
priv->handle_type != TP_HANDLE_TYPE_NONE &&
!EMP_STR_EMPTY (priv->id)) {
@@ -1540,9 +1544,6 @@ chat_finalize (GObject *object)
chat_composing_remove_timeout (chat);
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- chat_new_connection_cb, object);
-
g_object_unref (priv->account_manager);
g_object_unref (priv->log_manager);
@@ -1621,7 +1622,7 @@ empathy_chat_class_init (EmpathyChatClass *klass)
g_param_spec_object ("account",
"Account of the chat",
"The account of the chat",
- EMPATHY_TYPE_ACCOUNT,
+ TP_TYPE_ACCOUNT,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
@@ -1699,6 +1700,34 @@ chat_block_events_timeout_cb (gpointer data)
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *l;
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyChat *chat = user_data;
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
+ DEBUG ("Failed to prepare the account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+
+ for (l = accounts; l != NULL; l = l->next) {
+ TpAccount *account = l->data;
+ empathy_signal_connect_weak (account, "status-changed",
+ G_CALLBACK (chat_new_connection_cb),
+ G_OBJECT (chat));
+ }
+
+ g_list_free (accounts);
+}
+
+static void
empathy_chat_init (EmpathyChat *chat)
{
EmpathyChatPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chat,
@@ -1709,12 +1738,10 @@ empathy_chat_init (EmpathyChat *chat)
priv->contacts_width = -1;
priv->sent_messages = NULL;
priv->sent_messages_index = -1;
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
- g_signal_connect (priv->account_manager,
- "new-connection",
- G_CALLBACK (chat_new_connection_cb),
- chat);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, chat);
empathy_conf_get_bool (empathy_conf_get (),
EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
@@ -1767,10 +1794,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
priv->tp_chat = g_object_ref (tp_chat);
connection = empathy_tp_chat_get_connection (priv->tp_chat);
- priv->account = empathy_account_manager_get_account_for_connection (
- priv->account_manager,
- connection);
- g_object_ref (priv->account);
+ priv->account = g_object_ref (empathy_get_account_for_connection (connection));
g_signal_connect (tp_chat, "destroy",
G_CALLBACK (chat_destroy_cb),
@@ -1813,7 +1837,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
show_pending_messages (chat);
}
-EmpathyAccount *
+TpAccount *
empathy_chat_get_account (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h
index c7158759a..9123d11dd 100644
--- a/libempathy-gtk/empathy-chat.h
+++ b/libempathy-gtk/empathy-chat.h
@@ -66,7 +66,7 @@ EmpathyChat * empathy_chat_new (EmpathyTpChat *tp_chat);
EmpathyTpChat * empathy_chat_get_tp_chat (EmpathyChat *chat);
void empathy_chat_set_tp_chat (EmpathyChat *chat,
EmpathyTpChat *tp_chat);
-EmpathyAccount * empathy_chat_get_account (EmpathyChat *chat);
+TpAccount * empathy_chat_get_account (EmpathyChat *chat);
const gchar * empathy_chat_get_id (EmpathyChat *chat);
const gchar * empathy_chat_get_name (EmpathyChat *chat);
const gchar * empathy_chat_get_subject (EmpathyChat *chat);
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index 6c15dd876..b7108d8f3 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -27,8 +27,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-contact-manager.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-utils.h>
@@ -327,14 +328,14 @@ empathy_contact_personal_dialog_show (GtkWindow *parent)
*/
static gboolean
-can_add_contact_to_account (EmpathyAccount *account,
+can_add_contact_to_account (TpAccount *account,
gpointer user_data)
{
EmpathyContactManager *contact_manager;
TpConnection *connection;
gboolean result;
- connection = empathy_account_get_connection (account);
+ connection = tp_account_get_connection (account);
if (connection == NULL)
return FALSE;
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index a6623506b..c19ad32df 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -31,9 +31,9 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-list.h>
@@ -244,9 +244,9 @@ contact_list_view_drag_data_received (GtkWidget *view,
guint time_)
{
EmpathyContactListViewPriv *priv;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
EmpathyTpContactFactory *factory = NULL;
- EmpathyAccount *account = NULL;
+ TpAccount *account = NULL;
GtkTreeModel *model;
GtkTreeViewDropPosition position;
GtkTreePath *path;
@@ -298,17 +298,19 @@ contact_list_view_drag_data_received (GtkWidget *view,
context->action == GDK_ACTION_COPY ? "copy" : "",
id);
- account_manager = empathy_account_manager_dup_singleton ();
+ /* FIXME: should probably make sure the account manager is prepared
+ * before calling _ensure_account on it. See bug 600115. */
+ account_manager = tp_account_manager_dup ();
strv = g_strsplit (id, ":", 2);
if (g_strv_length (strv) == 2) {
account_id = strv[0];
contact_id = strv[1];
- account = empathy_account_manager_get_account (account_manager, account_id);
+ account = tp_account_manager_ensure_account (account_manager, account_id);
}
if (account) {
TpConnection *connection;
- connection = empathy_account_get_connection (account);
+ connection = tp_account_get_connection (account);
if (connection) {
factory = empathy_tp_contact_factory_dup_singleton (connection);
}
@@ -458,7 +460,7 @@ contact_list_view_drag_data_get (GtkWidget *widget,
GtkTreeIter iter;
GtkTreeModel *model;
EmpathyContact *contact;
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *contact_id;
const gchar *account_id;
gchar *str;
@@ -488,7 +490,7 @@ contact_list_view_drag_data_get (GtkWidget *widget,
}
account = empathy_contact_get_account (contact);
- account_id = empathy_account_get_unique_name (account);
+ account_id = tp_proxy_get_object_path (account);
contact_id = empathy_contact_get_id (contact);
g_object_unref (contact);
str = g_strconcat (account_id, ":", contact_id, NULL);
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 17bed7298..81e01ff0b 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -32,6 +32,7 @@
#include <champlain-gtk/champlain-gtk.h>
#endif
+#include <telepathy-glib/account.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-tp-contact-factory.h>
@@ -40,7 +41,6 @@
#include <libempathy/empathy-location.h>
#include <libempathy/empathy-time.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account.h>
#include "empathy-contact-widget.h"
#include "empathy-account-chooser.h"
@@ -718,7 +718,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
static void
contact_widget_contact_update (EmpathyContactWidget *information)
{
- EmpathyAccount *account = NULL;
+ TpAccount *account = NULL;
const gchar *id = NULL;
/* Connect and get info from new contact */
@@ -758,7 +758,7 @@ contact_widget_contact_update (EmpathyContactWidget *information)
{
const gchar *name;
- name = empathy_account_get_display_name (account);
+ name = tp_account_get_display_name (account);
gtk_label_set_label (GTK_LABEL (information->widget_account), name);
}
}
diff --git a/libempathy-gtk/empathy-irc-network-dialog.c b/libempathy-gtk/empathy-irc-network-dialog.c
index 8d4676417..69f83637d 100644
--- a/libempathy-gtk/empathy-irc-network-dialog.c
+++ b/libempathy-gtk/empathy-irc-network-dialog.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account.h>
#include <libempathy/empathy-irc-network-manager.h>
#include "empathy-ui-utils.h"
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index a00d6cb63..4ef27dba7 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -26,6 +26,7 @@
#include <glib/gi18n.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <geoclue/geoclue-master.h>
@@ -35,7 +36,6 @@
#include "empathy-location-manager.h"
#include "empathy-conf.h"
-#include "libempathy/empathy-account-manager.h"
#include "libempathy/empathy-enum-types.h"
#include "libempathy/empathy-location.h"
#include "libempathy/empathy-tp-contact-factory.h"
@@ -63,7 +63,7 @@ typedef struct {
GeoclueAddress *gc_address;
gboolean reduce_accuracy;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
/* The idle id for publish_on_idle func */
guint timeout_id;
@@ -217,21 +217,57 @@ publish_location (EmpathyLocationManager *self,
g_object_unref (factory);
}
+typedef struct
+{
+ EmpathyLocationManager *self;
+ gboolean force_publication;
+} PublishToAllData;
+
+static void
+publish_to_all_am_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ PublishToAllData *data = user_data;
+ GList *accounts, *l;
+ 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);
+ goto out;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (manager);
+ for (l = accounts; l; l = l->next)
+ {
+ TpConnection *conn = tp_account_get_connection (TP_ACCOUNT (l->data));
+
+ if (conn != NULL)
+ publish_location (data->self, conn, data->force_publication);
+ }
+ g_list_free (accounts);
+
+out:
+ g_object_unref (data->self);
+ g_slice_free (PublishToAllData, data);
+}
+
static void
publish_to_all_connections (EmpathyLocationManager *self,
gboolean force_publication)
{
EmpathyLocationManagerPriv *priv = GET_PRIV (self);
- GList *connections = NULL, *l;
+ PublishToAllData *data;
- connections = empathy_account_manager_dup_connections (priv->account_manager);
- for (l = connections; l; l = l->next)
- {
- publish_location (self, l->data, force_publication);
- g_object_unref (l->data);
- }
- g_list_free (connections);
+ data = g_slice_new0 (PublishToAllData);
+ data->self = g_object_ref (self);
+ data->force_publication = force_publication;
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ publish_to_all_am_prepared_cb, data);
}
static gboolean
@@ -246,11 +282,19 @@ publish_on_idle (gpointer user_data)
}
static void
-new_connection_cb (EmpathyAccountManager *manager,
- TpConnection *conn,
+new_connection_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
gpointer *self)
{
EmpathyLocationManagerPriv *priv = GET_PRIV (self);
+ TpConnection *conn;
+
+ conn = tp_account_get_connection (account);
+
DEBUG ("New connection %p", conn);
/* Don't publish if it is already planned (ie startup) */
@@ -626,6 +670,34 @@ accuracy_cb (EmpathyConf *conf,
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *l;
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyLocationManager *self = user_data;
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+ for (l = accounts; l != NULL; l = l->next)
+ {
+ TpAccount *account = TP_ACCOUNT (l->data);
+
+ empathy_signal_connect_weak (account, "status-changed",
+ G_CALLBACK (new_connection_cb), G_OBJECT (self));
+ }
+ g_list_free (accounts);
+}
+
+static void
empathy_location_manager_init (EmpathyLocationManager *self)
{
EmpathyConf *conf;
@@ -638,10 +710,10 @@ empathy_location_manager_init (EmpathyLocationManager *self)
g_free, (GDestroyNotify) tp_g_value_slice_free);
/* Setup account status callbacks */
- priv->account_manager = empathy_account_manager_dup_singleton ();
- g_signal_connect (priv->account_manager,
- "new-connection",
- G_CALLBACK (new_connection_cb), self);
+ priv->account_manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, self);
/* Setup settings status callbacks */
conf = empathy_conf_get ();
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 11ddca74b..247a99806 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -30,8 +30,9 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-log-manager.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-message.h>
@@ -95,11 +96,11 @@ static void log_window_chats_setup (EmpathyLogWindow *wi
static void log_window_chats_accounts_changed_cb (GtkWidget *combobox,
EmpathyLogWindow *window);
static void log_window_chats_set_selected (EmpathyLogWindow *window,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom);
static gboolean log_window_chats_get_selected (EmpathyLogWindow *window,
- EmpathyAccount **account,
+ TpAccount **account,
gchar **chat_id,
gboolean *is_chatroom);
static void log_window_chats_get_messages (EmpathyLogWindow *window,
@@ -134,16 +135,45 @@ enum {
COL_CHAT_COUNT
};
+static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyLogWindow *window = user_data;
+ guint account_num;
+ GList *accounts;
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+ account_num = g_list_length (accounts);
+ g_list_free (accounts);
+
+ if (account_num > 1) {
+ gtk_widget_show (window->vbox_chats);
+ gtk_widget_show (window->account_chooser_chats);
+ } else {
+ gtk_widget_hide (window->vbox_chats);
+ gtk_widget_hide (window->account_chooser_chats);
+ }
+}
+
GtkWidget *
-empathy_log_window_show (EmpathyAccount *account,
+empathy_log_window_show (TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom,
GtkWindow *parent)
{
static EmpathyLogWindow *window = NULL;
EmpathyAccountChooser *account_chooser;
- EmpathyAccountManager *account_manager;
- gint account_num;
+ TpAccountManager *account_manager;
GtkBuilder *gui;
gchar *filename;
@@ -229,18 +259,11 @@ empathy_log_window_show (EmpathyAccount *account,
window);
/* Populate */
- account_manager = empathy_account_manager_dup_singleton ();
- account_num = empathy_account_manager_get_count (account_manager);
+ account_manager = tp_account_manager_dup ();
+ tp_account_manager_prepare_async (account_manager, NULL,
+ account_manager_prepared_cb, window);
g_object_unref (account_manager);
- if (account_num > 1) {
- gtk_widget_show (window->vbox_chats);
- gtk_widget_show (window->account_chooser_chats);
- } else {
- gtk_widget_hide (window->vbox_chats);
- gtk_widget_hide (window->account_chooser_chats);
- }
-
/* Search List */
log_window_find_setup (window);
@@ -302,7 +325,7 @@ log_window_find_changed_cb (GtkTreeSelection *selection,
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeIter iter;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
gchar *date;
@@ -418,8 +441,8 @@ log_window_find_populate (EmpathyLogWindow *window,
}
date_readable = empathy_log_manager_get_date_readable (hit->date);
- account_name = empathy_account_get_display_name (hit->account);
- account_icon = empathy_account_get_icon_name (hit->account);
+ account_name = tp_account_get_display_name (hit->account);
+ account_icon = tp_account_get_icon_name (hit->account);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
@@ -465,7 +488,7 @@ log_window_find_setup (EmpathyLogWindow *window)
store = gtk_list_store_new (COL_FIND_COUNT,
G_TYPE_STRING, /* account icon name */
G_TYPE_STRING, /* account name */
- EMPATHY_TYPE_ACCOUNT, /* account */
+ TP_TYPE_ACCOUNT, /* account */
G_TYPE_STRING, /* chat name */
G_TYPE_STRING, /* chat id */
G_TYPE_BOOLEAN, /* is chatroom */
@@ -609,7 +632,7 @@ static void
log_window_chats_populate (EmpathyLogWindow *window)
{
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
GList *chats, *l;
GtkTreeView *view;
@@ -687,7 +710,7 @@ log_window_chats_setup (EmpathyLogWindow *window)
store = gtk_list_store_new (COL_CHAT_COUNT,
G_TYPE_STRING, /* icon */
G_TYPE_STRING, /* name */
- EMPATHY_TYPE_ACCOUNT, /* account */
+ TP_TYPE_ACCOUNT, /* account */
G_TYPE_STRING, /* id */
G_TYPE_BOOLEAN); /* is chatroom */
@@ -740,7 +763,7 @@ log_window_chats_accounts_changed_cb (GtkWidget *combobox,
static void
log_window_chats_set_selected (EmpathyLogWindow *window,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom)
{
@@ -764,7 +787,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window,
}
for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) {
- EmpathyAccount *this_account;
+ TpAccount *this_account;
gchar *this_chat_id;
gboolean this_is_chatroom;
@@ -793,7 +816,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window,
static gboolean
log_window_chats_get_selected (EmpathyLogWindow *window,
- EmpathyAccount **account,
+ TpAccount **account,
gchar **chat_id,
gboolean *is_chatroom)
{
@@ -802,7 +825,7 @@ log_window_chats_get_selected (EmpathyLogWindow *window,
GtkTreeSelection *selection;
GtkTreeIter iter;
gchar *id = NULL;
- EmpathyAccount *acc = NULL;
+ TpAccount *acc = NULL;
gboolean room = FALSE;
view = GTK_TREE_VIEW (window->treeview_chats);
@@ -840,7 +863,7 @@ static void
log_window_chats_get_messages (EmpathyLogWindow *window,
const gchar *date_to_show)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
EmpathyMessage *message;
@@ -1000,7 +1023,7 @@ static void
log_window_calendar_chats_month_changed_cb (GtkWidget *calendar,
EmpathyLogWindow *window)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
guint year_selected;
diff --git a/libempathy-gtk/empathy-log-window.h b/libempathy-gtk/empathy-log-window.h
index 298d96099..def0d846b 100644
--- a/libempathy-gtk/empathy-log-window.h
+++ b/libempathy-gtk/empathy-log-window.h
@@ -25,11 +25,11 @@
#ifndef __EMPATHY_LOG_WINDOW_H__
#define __EMPATHY_LOG_WINDOW_H__
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
G_BEGIN_DECLS
-GtkWidget * empathy_log_window_show (EmpathyAccount *account,
+GtkWidget * empathy_log_window_show (TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
GtkWindow *parent);
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
index 66b2adb2d..d39f71bcc 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -32,7 +32,6 @@
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account.h>
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
#include <libempathy/empathy-debug.h>
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 7113c77fd..678ec835c 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -33,13 +33,13 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-connectivity.h>
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-status-presets.h>
-#include <libempathy/empathy-account-manager.h>
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
@@ -114,7 +114,7 @@ typedef struct {
TpConnectionPresenceType flash_state_2;
guint flash_timeout_id;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
} EmpathyPresenceChooserPriv;
/* States to be listed in the menu.
@@ -715,21 +715,32 @@ presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser,
}
static void
-presence_chooser_update_sensitivity (EmpathyPresenceChooser *chooser)
+update_sensitivity_am_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyPresenceChooser *chooser = user_data;
EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
gboolean sensitive = FALSE;
GList *accounts, *l;
+ 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;
+ }
- accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+ accounts = tp_account_manager_get_valid_accounts (manager);
for (l = accounts ; l != NULL ; l = g_list_next (l)) {
- EmpathyAccount *a = EMPATHY_ACCOUNT (l->data);
+ TpAccount *a = TP_ACCOUNT (l->data);
- if (empathy_account_is_enabled (a))
+ if (tp_account_is_enabled (a)) {
sensitive = TRUE;
-
- g_object_unref (a);
+ break;
+ }
}
g_list_free (accounts);
@@ -741,9 +752,29 @@ presence_chooser_update_sensitivity (EmpathyPresenceChooser *chooser)
}
static void
+presence_chooser_update_sensitivity (EmpathyPresenceChooser *chooser)
+{
+ EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
+
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ update_sensitivity_am_prepared_cb,
+ chooser);
+}
+
+static void
+presence_chooser_account_manager_account_validity_changed_cb (
+ TpAccountManager *manager,
+ TpAccount *account,
+ gboolean valid,
+ EmpathyPresenceChooser *chooser)
+{
+ presence_chooser_update_sensitivity (chooser);
+}
+
+static void
presence_chooser_account_manager_account_changed_cb (
- EmpathyAccountManager *manager,
- EmpathyAccount *account,
+ TpAccountManager *manager,
+ TpAccount *account,
EmpathyPresenceChooser *chooser)
{
presence_chooser_update_sensitivity (chooser);
@@ -825,12 +856,12 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
G_CALLBACK (presence_chooser_presence_changed_cb),
chooser);
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
- empathy_signal_connect_weak (priv->account_manager, "account-created",
- G_CALLBACK (presence_chooser_account_manager_account_changed_cb),
+ empathy_signal_connect_weak (priv->account_manager, "account-validity-changed",
+ G_CALLBACK (presence_chooser_account_manager_account_validity_changed_cb),
G_OBJECT (chooser));
- empathy_signal_connect_weak (priv->account_manager, "account-deleted",
+ empathy_signal_connect_weak (priv->account_manager, "account-removed",
G_CALLBACK (presence_chooser_account_manager_account_changed_cb),
G_OBJECT (chooser));
empathy_signal_connect_weak (priv->account_manager, "account-enabled",
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index fcf95ca02..a41cbd6c0 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -441,7 +441,7 @@ theme_adium_append_message (EmpathyChatView *view,
EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (view);
EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
EmpathyContact *sender;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *dup_body = NULL;
const gchar *body;
const gchar *name;
@@ -467,9 +467,9 @@ theme_adium_append_message (EmpathyChatView *view,
sender = empathy_message_get_sender (msg);
account = empathy_contact_get_account (sender);
service_name = empathy_protocol_name_to_display_name
- (empathy_account_get_protocol (account));
+ (tp_account_get_protocol (account));
if (service_name == NULL)
- service_name = empathy_account_get_protocol (account);
+ service_name = tp_account_get_protocol (account);
timestamp = empathy_message_get_timestamp (msg);
body = empathy_message_get_body (msg);
dup_body = theme_adium_parse_body (theme, body);
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 39baeaf41..486301cb1 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -35,7 +35,6 @@
#include <gtk/gtk.h>
#include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-account.h>
#include <libempathy/empathy-ft-handler.h>
#include "empathy-chat-view.h"
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 1e7d01ca3..91fdf7ba1 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -27,8 +27,6 @@ noinst_LTLIBRARIES = libempathy.la
libempathy_headers = \
empathy-account-settings.h \
- empathy-account.h \
- empathy-account-manager.h \
empathy-chatroom.h \
empathy-chatroom-manager.h \
empathy-call-factory.h \
@@ -70,9 +68,7 @@ libempathy_headers = \
libempathy_la_SOURCES = \
$(libempathy_headers) \
- empathy-account.c \
empathy-account-settings.c \
- empathy-account-manager.c \
empathy-chatroom.c \
empathy-chatroom-manager.c \
empathy-call-factory.c \
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
deleted file mode 100644
index c71439bd4..000000000
--- a/libempathy/empathy-account-manager.c
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/defs.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/interfaces.h>
-
-#include "empathy-account-manager.h"
-#include "empathy-marshal.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountManager)
-
-#define MC5_BUS_NAME "org.freedesktop.Telepathy.MissionControl5"
-
-typedef struct {
- /* (owned) unique name -> (reffed) EmpathyAccount */
- GHashTable *accounts;
- int connected;
- int connecting;
- gboolean dispose_run;
- gboolean ready;
- TpAccountManager *tp_manager;
- TpDBusDaemon *dbus;
-
- /* global presence */
- EmpathyAccount *global_account;
-
- TpConnectionPresenceType global_presence;
- gchar *global_status;
- gchar *global_status_message;
-
- /* requested global presence, could be different
- * from the actual global one.
- */
- TpConnectionPresenceType requested_presence;
- gchar *requested_status;
- gchar *requested_status_message;
-
- GHashTable *create_results;
-} EmpathyAccountManagerPriv;
-
-enum {
- ACCOUNT_CREATED,
- ACCOUNT_DELETED,
- ACCOUNT_ENABLED,
- ACCOUNT_DISABLED,
- ACCOUNT_CHANGED,
- ACCOUNT_CONNECTION_CHANGED,
- GLOBAL_PRESENCE_CHANGED,
- NEW_CONNECTION,
- LAST_SIGNAL
-};
-
-enum {
- PROP_READY = 1,
-};
-
-static guint signals[LAST_SIGNAL];
-static EmpathyAccountManager *manager_singleton = NULL;
-
-G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT);
-
-static void
-emp_account_connection_cb (EmpathyAccount *account,
- GParamSpec *spec,
- gpointer manager)
-{
- TpConnection *connection = empathy_account_get_connection (account);
-
- DEBUG ("Signalling connection %p of account %s",
- connection, empathy_account_get_unique_name (account));
-
- if (connection != NULL)
- g_signal_emit (manager, signals[NEW_CONNECTION], 0, connection);
-}
-
-static void
-emp_account_enabled_cb (EmpathyAccount *account,
- GParamSpec *spec,
- gpointer manager)
-{
- if (empathy_account_is_enabled (account))
- g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account);
- else
- g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account);
-}
-
-static void
-emp_account_status_changed_cb (EmpathyAccount *account,
- TpConnectionStatus old,
- TpConnectionStatus new,
- TpConnectionStatusReason reason,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- switch (old)
- {
- case TP_CONNECTION_STATUS_CONNECTING:
- priv->connecting--;
- break;
- case TP_CONNECTION_STATUS_CONNECTED:
- priv->connected--;
- break;
- default:
- break;
- }
-
- switch (new)
- {
- case TP_CONNECTION_STATUS_CONNECTING:
- priv->connecting++;
- break;
- case TP_CONNECTION_STATUS_CONNECTED:
- priv->connected++;
- break;
- default:
- break;
- }
-
- g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0,
- account, reason, new, old);
-}
-
-static void
-emp_account_manager_update_global_presence (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- TpConnectionPresenceType presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
- EmpathyAccount *account = NULL;
- GHashTableIter iter;
- gpointer value;
-
- /* Make the global presence is equal to the presence of the account with the
- * highest availability */
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *a = EMPATHY_ACCOUNT (value);
- TpConnectionPresenceType p;
-
- g_object_get (a, "presence", &p, NULL);
-
- if (tp_connection_presence_type_cmp_availability (p, presence) > 0)
- {
- account = a;
- presence = p;
- }
- }
-
- priv->global_account = account;
- g_free (priv->global_status);
- g_free (priv->global_status_message);
-
- if (account == NULL)
- {
- priv->global_presence = presence;
- priv->global_status = NULL;
- priv->global_status_message = NULL;
- return;
- }
-
- g_object_get (account,
- "presence", &priv->global_presence,
- "status", &priv->global_status,
- "status-message", &priv->global_status_message,
- NULL);
-
- DEBUG ("Updated global presence to: %s (%d) \"%s\"",
- priv->global_status, priv->global_presence, priv->global_status_message);
-}
-
-static void
-emp_account_presence_changed_cb (EmpathyAccount *account,
- TpConnectionPresenceType presence,
- const gchar *status,
- const gchar *status_message,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (tp_connection_presence_type_cmp_availability (presence,
- priv->global_presence) > 0)
- {
- priv->global_account = account;
-
- priv->global_presence = presence;
-
- g_free (priv->global_status);
- priv->global_status = g_strdup (status);
-
- g_free (priv->global_status_message);
- priv->global_status_message = g_strdup (status_message);
-
- goto signal;
- }
- else if (priv->global_account == account)
- {
- emp_account_manager_update_global_presence (manager);
- goto signal;
- }
-
- return;
-signal:
- g_signal_emit (manager, signals[GLOBAL_PRESENCE_CHANGED], 0,
- priv->global_presence, priv->global_status, priv->global_status_message);
-}
-
-static void
-emp_account_removed_cb (EmpathyAccount *account, gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- g_object_ref (account);
- g_hash_table_remove (priv->accounts,
- empathy_account_get_unique_name (account));
-
- g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
- g_object_unref (account);
-}
-
-static void
-empathy_account_manager_check_ready (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- gpointer value;
-
- if (priv->ready)
- return;
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (!ready)
- return;
- }
-
- /* Rerequest global presence on the initial set of accounts for cases where a
- * global presence was requested before the manager was ready */
- if (priv->requested_presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
- empathy_account_manager_request_global_presence (manager,
- priv->requested_presence,
- priv->requested_status,
- priv->requested_status_message);
-
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (manager), "ready");
-}
-
-static void
-account_manager_account_ready_cb (GObject *obj,
- GParamSpec *spec,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- EmpathyAccount *account = EMPATHY_ACCOUNT (obj);
- GSimpleAsyncResult *result;
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (!ready)
- return;
-
- /* see if there's any pending callbacks for this account */
- result = g_hash_table_lookup (priv->create_results, account);
- if (result != NULL)
- {
- g_simple_async_result_set_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result), account, NULL);
-
- g_simple_async_result_complete (result);
-
- g_hash_table_remove (priv->create_results, account);
- g_object_unref (result);
- }
-
- g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account);
-
- g_signal_connect (account, "notify::connection",
- G_CALLBACK (emp_account_connection_cb), manager);
-
- g_signal_connect (account, "notify::enabled",
- G_CALLBACK (emp_account_enabled_cb), manager);
-
- g_signal_connect (account, "status-changed",
- G_CALLBACK (emp_account_status_changed_cb), manager);
-
- g_signal_connect (account, "presence-changed",
- G_CALLBACK (emp_account_presence_changed_cb), manager);
-
- g_signal_connect (account, "removed",
- G_CALLBACK (emp_account_removed_cb), manager);
-
- empathy_account_manager_check_ready (manager);
-}
-
-EmpathyAccount *
-empathy_account_manager_get_account (EmpathyAccountManager *manager,
- const gchar *path)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- return g_hash_table_lookup (priv->accounts, path);
-}
-
-EmpathyAccount *
-empathy_account_manager_ensure_account (EmpathyAccountManager *manager,
- const gchar *path)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- EmpathyAccount *account;
-
- account = g_hash_table_lookup (priv->accounts, path);
- if (account != NULL)
- return account;
-
- account = empathy_account_new (priv->dbus, path);
- g_hash_table_insert (priv->accounts, g_strdup (path), account);
-
- g_signal_connect (account, "notify::ready",
- G_CALLBACK (account_manager_account_ready_cb), manager);
-
- return account;
-}
-
-
-static void
-account_manager_ensure_all_accounts (EmpathyAccountManager *manager,
- GPtrArray *accounts)
-{
- guint i, missing_accounts;
- GHashTableIter iter;
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- gpointer value;
- EmpathyAccount *account;
- gboolean found = FALSE;
- const gchar *name;
-
- /* ensure all accounts coming from MC5 first */
- for (i = 0; i < accounts->len; i++)
- {
- name = g_ptr_array_index (accounts, i);
-
- account = empathy_account_manager_ensure_account (manager, name);
- empathy_account_refresh_properties (account);
- }
-
- missing_accounts = empathy_account_manager_get_count (manager) -
- accounts->len;
-
- if (missing_accounts > 0)
- {
- /* look for accounts we have and the Tp AccountManager doesn't,
- * and remove them from our cache.
- */
-
- DEBUG ("%d missing accounts", missing_accounts);
-
- g_hash_table_iter_init (&iter, priv->accounts);
-
- while (g_hash_table_iter_next (&iter, NULL, &value) &&
- missing_accounts > 0)
- {
- account = value;
-
- /* look for this account in the AccountManager provided array */
- for (i = 0; i < accounts->len; i++)
- {
- name = g_ptr_array_index (accounts, i);
-
- if (!tp_strdiff
- (name, empathy_account_get_unique_name (account)))
- {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- {
- DEBUG ("Account %s was not found, remove it from the cache",
- empathy_account_get_unique_name (account));
-
- g_object_ref (account);
- g_hash_table_iter_remove (&iter);
- g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account);
- g_object_unref (account);
-
- missing_accounts--;
- }
-
- found = FALSE;
- }
- }
-}
-
-static void
-account_manager_got_all_cb (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
- GPtrArray *accounts;
-
- if (error != NULL)
- {
- DEBUG ("Failed to get account manager properties: %s", error->message);
- return;
- }
-
- accounts = tp_asv_get_boxed (properties, "ValidAccounts",
- EMPATHY_ARRAY_TYPE_OBJECT);
-
- if (accounts != NULL)
- account_manager_ensure_all_accounts (manager, accounts);
-
- empathy_account_manager_check_ready (manager);
-}
-
-static void
-account_validity_changed_cb (TpAccountManager *proxy,
- const gchar *path,
- gboolean valid,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
-
- if (!valid)
- return;
-
- empathy_account_manager_ensure_account (manager, path);
-}
-
-static void
-account_manager_start_mc5 (TpDBusDaemon *bus)
-{
- TpProxy *mc5_proxy;
-
- /* trigger MC5 starting */
- mc5_proxy = g_object_new (TP_TYPE_PROXY,
- "dbus-daemon", bus,
- "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (bus)),
- "bus-name", MC5_BUS_NAME,
- "object-path", "/",
- NULL);
-
- tp_cli_dbus_peer_call_ping (mc5_proxy, -1, NULL, NULL, NULL, NULL);
-
- g_object_unref (mc5_proxy);
-}
-
-static void
-account_manager_name_owner_cb (TpDBusDaemon *proxy,
- const gchar *name,
- const gchar *new_owner,
- gpointer user_data)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- DEBUG ("Name owner changed for %s, new name: %s", name, new_owner);
-
- if (EMP_STR_EMPTY (new_owner))
- {
- /* MC5 quit or crashed for some reason, let's start it again */
- account_manager_start_mc5 (priv->dbus);
-
- if (priv->tp_manager != NULL)
- g_object_unref (priv->tp_manager);
-
- priv->tp_manager = NULL;
- return;
- }
-
- if (priv->tp_manager == NULL)
- {
- priv->tp_manager = tp_account_manager_new (priv->dbus);
-
- tp_cli_account_manager_connect_to_account_validity_changed (
- priv->tp_manager,
- account_validity_changed_cb,
- NULL,
- NULL,
- G_OBJECT (manager),
- NULL);
-
- tp_cli_dbus_properties_call_get_all (priv->tp_manager, -1,
- TP_IFACE_ACCOUNT_MANAGER,
- account_manager_got_all_cb,
- NULL,
- NULL,
- G_OBJECT (manager));
- }
-}
-
-static void
-empathy_account_manager_init (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv);
-
- manager->priv = priv;
- priv->connected = priv->connecting = 0;
- priv->global_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET;
-
- priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) g_object_unref);
-
- priv->create_results = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- priv->dbus = tp_dbus_daemon_dup (NULL);
-
- tp_dbus_daemon_watch_name_owner (priv->dbus,
- TP_ACCOUNT_MANAGER_BUS_NAME,
- account_manager_name_owner_cb,
- manager,
- NULL);
-
- account_manager_start_mc5 (priv->dbus);
-}
-
-static void
-do_finalize (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- g_hash_table_destroy (priv->create_results);
- g_hash_table_destroy (priv->accounts);
-
- g_free (priv->global_status);
- g_free (priv->global_status_message);
-
- g_free (priv->requested_status);
- g_free (priv->requested_status_message);
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->finalize (obj);
-}
-
-static void
-do_dispose (GObject *obj)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- GSimpleAsyncResult *result;
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- /* the manager is being destroyed while there are account creation
- * processes pending; this should not happen, but emit the callbacks
- * with an error anyway.
- */
- g_hash_table_iter_init (&iter, priv->create_results);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &result))
- {
- g_simple_async_result_set_error (result, G_IO_ERROR,
- G_IO_ERROR_CANCELLED, "The account manager was disposed while "
- "creating the account");
- g_simple_async_result_complete (result);
- g_object_unref (result);
- }
- g_hash_table_remove_all (priv->create_results);
-
- if (priv->dbus != NULL)
- {
- tp_dbus_daemon_cancel_name_owner_watch (priv->dbus,
- TP_ACCOUNT_MANAGER_BUS_NAME, account_manager_name_owner_cb, manager);
-
- g_object_unref (priv->dbus);
- priv->dbus = NULL;
- }
-
- G_OBJECT_CLASS (empathy_account_manager_parent_class)->dispose (obj);
-}
-
-static GObject *
-do_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *retval;
-
- if (!manager_singleton)
- {
- retval = G_OBJECT_CLASS
- (empathy_account_manager_parent_class)->constructor (type,
- n_construct_params, construct_params);
- manager_singleton = EMPATHY_ACCOUNT_MANAGER (retval);
- g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
- }
- else
- {
- retval = g_object_ref (manager_singleton);
- }
-
- return retval;
-}
-
-static void
-do_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (object);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- switch (prop_id)
- {
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_manager_class_init (EmpathyAccountManagerClass *klass)
-{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
-
- oclass->finalize = do_finalize;
- oclass->dispose = do_dispose;
- oclass->constructor = do_constructor;
- oclass->get_property = do_get_property;
-
- g_object_class_install_property (oclass, PROP_READY,
- g_param_spec_boolean ("ready",
- "Ready",
- "Whether the initial state dump from the account manager is finished",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- signals[ACCOUNT_CREATED] =
- g_signal_new ("account-created",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DELETED] =
- g_signal_new ("account-deleted",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_ENABLED] =
- g_signal_new ("account-enabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_DISABLED] =
- g_signal_new ("account-disabled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CHANGED] =
- g_signal_new ("account-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_ACCOUNT);
-
- signals[ACCOUNT_CONNECTION_CHANGED] =
- g_signal_new ("account-connection-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__OBJECT_INT_UINT_UINT,
- G_TYPE_NONE,
- 4, EMPATHY_TYPE_ACCOUNT,
- G_TYPE_INT, /* reason */
- G_TYPE_UINT, /* actual connection */
- G_TYPE_UINT); /* previous connection */
-
- signals[GLOBAL_PRESENCE_CHANGED] =
- g_signal_new ("global-presence-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _empathy_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE,
- 3, G_TYPE_UINT, /* Presence type */
- G_TYPE_STRING, /* status */
- G_TYPE_STRING); /* stauts message*/
-
- signals[NEW_CONNECTION] =
- g_signal_new ("new-connection",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, TP_TYPE_CONNECTION);
-
- g_type_class_add_private (oclass, sizeof (EmpathyAccountManagerPriv));
-}
-
-/* public methods */
-
-EmpathyAccountManager *
-empathy_account_manager_dup_singleton (void)
-{
- return g_object_new (EMPATHY_TYPE_ACCOUNT_MANAGER, NULL);
-}
-
-gboolean
-empathy_account_manager_is_ready (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- return priv->ready;
-}
-
-int
-empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connected;
-}
-
-int
-empathy_account_manager_get_connecting_accounts (
- EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return priv->connecting;
-}
-
-/**
- * empathy_account_manager_get_count:
- * @manager: a #EmpathyAccountManager
- *
- * Get the number of accounts.
- *
- * Returns: the number of accounts.
- **/
-int
-empathy_account_manager_get_count (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- return g_hash_table_size (priv->accounts);
-}
-
-EmpathyAccount *
-empathy_account_manager_get_account_for_connection (
- EmpathyAccountManager *manager,
- TpConnection *connection)
-{
- EmpathyAccountManagerPriv *priv;
- GHashTableIter iter;
- gpointer value;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0);
-
- priv = GET_PRIV (manager);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
-
- if (connection == empathy_account_get_connection (account))
- return account;
- }
-
- return NULL;
-}
-
-GList *
-empathy_account_manager_dup_accounts (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
- GList *ret;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
-
- priv = GET_PRIV (manager);
-
- ret = g_hash_table_get_values (priv->accounts);
- g_list_foreach (ret, (GFunc) g_object_ref, NULL);
-
- return ret;
-}
-
-/**
- * empathy_account_manager_dup_connections:
- * @manager: a #EmpathyAccountManager
- *
- * Get a #GList of all ready #TpConnection. The list must be freed with
- * g_list_free, and its elements must be unreffed.
- *
- * Returns: the list of connections
- **/
-GList *
-empathy_account_manager_dup_connections (EmpathyAccountManager *manager)
-{
- EmpathyAccountManagerPriv *priv;
- GHashTableIter iter;
- gpointer value;
- GList *ret = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
-
- priv = GET_PRIV (manager);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- TpConnection *connection;
-
- connection = empathy_account_get_connection (account);
- if (connection != NULL)
- ret = g_list_prepend (ret, g_object_ref (connection));
- }
-
- return ret;
-}
-
-void
-empathy_account_manager_request_global_presence (
- EmpathyAccountManager *manager,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GHashTableIter iter;
- gpointer value;
-
- DEBUG ("request global presence, type: %d, status: %s, message: %s",
- type, status, message);
-
- g_hash_table_iter_init (&iter, priv->accounts);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- EmpathyAccount *account = EMPATHY_ACCOUNT (value);
- gboolean ready;
-
- g_object_get (account, "ready", &ready, NULL);
-
- if (ready)
- empathy_account_request_presence (account, type, status, message);
- }
-
- /* save the requested global presence, to use it in case we create
- * new accounts or some accounts become ready.
- */
- priv->requested_presence = type;
-
- if (tp_strdiff (priv->requested_status, status))
- {
- g_free (priv->requested_status);
- priv->requested_status = g_strdup (status);
- }
-
- if (tp_strdiff (priv->requested_status_message, message))
- {
- g_free (priv->requested_status_message);
- priv->requested_status_message = g_strdup (message);
- }
-}
-
-TpConnectionPresenceType
-empathy_account_manager_get_requested_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (status != NULL)
- *status = g_strdup (priv->requested_status);
- if (message != NULL)
- *message = g_strdup (priv->requested_status_message);
-
- return priv->requested_presence;
-}
-
-TpConnectionPresenceType
-empathy_account_manager_get_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
-
- if (status != NULL)
- *status = g_strdup (priv->global_status);
- if (message != NULL)
- *message = g_strdup (priv->global_status_message);
-
- return priv->global_presence;
-}
-
-static void
-empathy_account_manager_created_cb (TpAccountManager *proxy,
- const gchar *account_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (weak_object);
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GSimpleAsyncResult *my_res = user_data;
- EmpathyAccount *account;
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (my_res,
- (GError *) error);
- g_simple_async_result_complete (my_res);
- g_object_unref (my_res);
-
- return;
- }
-
- account = empathy_account_manager_ensure_account (manager, account_path);
-
- g_hash_table_insert (priv->create_results, account, my_res);
-}
-
-void
-empathy_account_manager_create_account_async (EmpathyAccountManager *manager,
- const gchar *connection_manager,
- const gchar *protocol,
- const gchar *display_name,
- GHashTable *parameters,
- GHashTable *properties,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new
- (G_OBJECT (manager), callback, user_data,
- empathy_account_manager_create_account_finish);
-
- tp_cli_account_manager_call_create_account (priv->tp_manager,
- -1,
- connection_manager,
- protocol,
- display_name,
- parameters,
- properties,
- empathy_account_manager_created_cb,
- res,
- NULL,
- G_OBJECT (manager));
-}
-
-EmpathyAccount *
-empathy_account_manager_create_account_finish (
- EmpathyAccountManager *manager, GAsyncResult *result, GError **error)
-{
- EmpathyAccount *retval;
-
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return NULL;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (manager), empathy_account_manager_create_account_finish), NULL);
-
- retval = EMPATHY_ACCOUNT (g_simple_async_result_get_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result)));
-
- return retval;
-}
-
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
deleted file mode 100644
index 7b4ebd9bb..000000000
--- a/libempathy/empathy-account-manager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_ACCOUNT_MANAGER_H__
-#define __EMPATHY_ACCOUNT_MANAGER_H__
-
-#include <glib-object.h>
-
-#include "empathy-account.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_ACCOUNT_MANAGER (empathy_account_manager_get_type ())
-#define EMPATHY_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManager))
-#define EMPATHY_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-#define EMPATHY_IS_ACCOUNT_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_IS_ACCOUNT_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- EMPATHY_TYPE_ACCOUNT_MANAGER))
-#define EMPATHY_ACCOUNT_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerClass))
-
-typedef struct _EmpathyAccountManager EmpathyAccountManager;
-typedef struct _EmpathyAccountManagerClass EmpathyAccountManagerClass;
-
-struct _EmpathyAccountManager {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyAccountManagerClass {
- GObjectClass parent_class;
-};
-
-GType empathy_account_manager_get_type (void);
-
-/* public methods */
-
-EmpathyAccountManager * empathy_account_manager_dup_singleton (void);
-
-gboolean empathy_account_manager_is_ready (EmpathyAccountManager *manager);
-
-int empathy_account_manager_get_connected_accounts
- (EmpathyAccountManager *manager);
-int empathy_account_manager_get_connecting_accounts
- (EmpathyAccountManager *manager);
-int empathy_account_manager_get_count
- (EmpathyAccountManager *manager);
-EmpathyAccount * empathy_account_manager_get_account_for_connection
- (EmpathyAccountManager *manager,
- TpConnection *connection);
-EmpathyAccount * empathy_account_manager_ensure_account
- (EmpathyAccountManager *manager,
- const gchar *unique_name);
-EmpathyAccount * empathy_account_manager_get_account
- (EmpathyAccountManager *manager,
- const gchar *unique_name);
-GList * empathy_account_manager_dup_accounts
- (EmpathyAccountManager *manager);
-GList * empathy_account_manager_dup_connections
- (EmpathyAccountManager *manager);
-
-void empathy_account_manager_request_global_presence (
- EmpathyAccountManager *manager,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message);
-
-TpConnectionPresenceType empathy_account_manager_get_requested_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message);
-
-TpConnectionPresenceType empathy_account_manager_get_global_presence (
- EmpathyAccountManager *manager,
- gchar **status,
- gchar **message);
-
-void empathy_account_manager_create_account_async (
- EmpathyAccountManager *manager, const gchar *connection_manager,
- const gchar *protocol, const gchar *display_name,
- GHashTable *parameters, GHashTable *properties,
- GAsyncReadyCallback callback, gpointer user_data);
-
-EmpathyAccount * empathy_account_manager_create_account_finish (
- EmpathyAccountManager *settings, GAsyncResult *result, GError **error);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_ACCOUNT_MANAGER_H__ */
-
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 0acc8006f..f33e43799 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -22,14 +22,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/gtypes.h>
#include "empathy-account-settings.h"
-#include "empathy-account-manager.h"
#include "empathy-connection-managers.h"
#include "empathy-utils.h"
+#include "empathy-idle.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
@@ -54,12 +55,11 @@ struct _EmpathyAccountSettingsPriv
{
gboolean dispose_has_run;
EmpathyConnectionManagers *managers;
- EmpathyAccountManager *account_manager;
- gulong account_manager_ready_id;
+ TpAccountManager *account_manager;
TpConnectionManager *manager;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *cm_name;
gchar *protocol;
gchar *display_name;
@@ -72,7 +72,6 @@ struct _EmpathyAccountSettingsPriv
GArray *required_params;
gulong managers_ready_id;
- gulong account_ready_id;
GSimpleAsyncResult *apply_result;
};
@@ -87,7 +86,7 @@ empathy_account_settings_init (EmpathyAccountSettings *obj)
/* allocate any data required by the object here */
priv->managers = empathy_connection_managers_dup_singleton ();
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) tp_g_value_slice_free);
@@ -97,8 +96,10 @@ empathy_account_settings_init (EmpathyAccountSettings *obj)
static void empathy_account_settings_dispose (GObject *object);
static void empathy_account_settings_finalize (GObject *object);
-static void empathy_account_settings_ready_cb (GObject *obj,
- GParamSpec *spec, gpointer user_data);
+static void empathy_account_settings_account_ready_cb (GObject *source_object,
+ GAsyncResult *result, gpointer user_data);
+static void empathy_account_settings_managers_ready_cb (GObject *obj,
+ GParamSpec *pspec, gpointer user_data);
static void empathy_account_settings_check_readyness (
EmpathyAccountSettings *self);
@@ -181,11 +182,11 @@ empathy_account_settings_constructed (GObject *object)
g_free (priv->protocol);
priv->cm_name =
- g_strdup (empathy_account_get_connection_manager (priv->account));
+ g_strdup (tp_account_get_connection_manager (priv->account));
priv->protocol =
- g_strdup (empathy_account_get_protocol (priv->account));
+ g_strdup (tp_account_get_protocol (priv->account));
priv->icon_name = g_strdup
- (empathy_account_get_icon_name (priv->account));
+ (tp_account_get_icon_name (priv->account));
}
else
{
@@ -198,10 +199,10 @@ empathy_account_settings_constructed (GObject *object)
if (!priv->ready)
{
- g_signal_connect (priv->account, "notify::ready",
- G_CALLBACK (empathy_account_settings_ready_cb), self);
+ tp_account_prepare_async (priv->account, NULL,
+ empathy_account_settings_account_ready_cb, self);
g_signal_connect (priv->managers, "notify::ready",
- G_CALLBACK (empathy_account_settings_ready_cb), self);
+ G_CALLBACK (empathy_account_settings_managers_ready_cb), self);
}
if (G_OBJECT_CLASS (
@@ -229,8 +230,8 @@ empathy_account_settings_class_init (
g_object_class_install_property (object_class, PROP_ACCOUNT,
g_param_spec_object ("account",
"Account",
- "The EmpathyAccount backing these settings",
- EMPATHY_TYPE_ACCOUNT,
+ "The TpAccount backing these settings",
+ TP_TYPE_ACCOUNT,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_CM_NAME,
@@ -293,19 +294,10 @@ empathy_account_settings_dispose (GObject *object)
g_object_unref (priv->manager);
priv->manager = NULL;
- if (priv->account_manager_ready_id != 0)
- g_signal_handler_disconnect (priv->account_manager,
- priv->account_manager_ready_id);
- priv->account_manager_ready_id = 0;
-
if (priv->account_manager != NULL)
g_object_unref (priv->account_manager);
priv->account_manager = NULL;
- if (priv->account_ready_id != 0)
- g_signal_handler_disconnect (priv->account, priv->account_ready_id);
- priv->account_ready_id = 0;
-
if (priv->account != NULL)
g_object_unref (priv->account);
priv->account = NULL;
@@ -360,7 +352,8 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
if (priv->ready)
return;
- if (priv->account != NULL && !empathy_account_is_ready (priv->account))
+ if (priv->account != NULL
+ && !tp_account_is_prepared (priv->account, TP_ACCOUNT_FEATURE_CORE))
return;
if (!empathy_connection_managers_is_ready (priv->managers))
@@ -376,11 +369,11 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
{
g_free (priv->display_name);
priv->display_name =
- g_strdup (empathy_account_get_display_name (priv->account));
+ g_strdup (tp_account_get_display_name (priv->account));
g_free (priv->icon_name);
priv->icon_name =
- g_strdup (empathy_account_get_icon_name (priv->account));
+ g_strdup (tp_account_get_icon_name (priv->account));
}
tp_protocol = tp_connection_manager_get_protocol (priv->manager,
@@ -416,8 +409,27 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
}
static void
-empathy_account_settings_ready_cb (GObject *obj,
- GParamSpec *spec,
+empathy_account_settings_account_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data);
+ TpAccount *account = TP_ACCOUNT (source_object);
+ GError *error = NULL;
+
+ if (!tp_account_prepare_finish (account, result, &error))
+ {
+ DEBUG ("Failed to prepare account: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ empathy_account_settings_check_readyness (settings);
+}
+
+static void
+empathy_account_settings_managers_ready_cb (GObject *object,
+ GParamSpec *pspec,
gpointer user_data)
{
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data);
@@ -438,7 +450,7 @@ empathy_account_settings_new (const gchar *connection_manager,
}
EmpathyAccountSettings *
-empathy_account_settings_new_for_account (EmpathyAccount *account)
+empathy_account_settings_new_for_account (TpAccount *account)
{
return g_object_new (EMPATHY_TYPE_ACCOUNT_SETTINGS,
"account", account,
@@ -506,7 +518,7 @@ empathy_account_settings_get_display_name (EmpathyAccountSettings *settings)
return priv->display_name;
}
-EmpathyAccount *
+TpAccount *
empathy_account_settings_get_account (EmpathyAccountSettings *settings)
{
EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
@@ -621,7 +633,7 @@ empathy_account_settings_get (EmpathyAccountSettings *settings,
{
const GHashTable *parameters;
- parameters = empathy_account_get_parameters (priv->account);
+ parameters = tp_account_get_parameters (priv->account);
result = tp_asv_lookup (parameters, param);
if (result != NULL)
@@ -910,10 +922,10 @@ account_settings_display_name_set_cb (GObject *src,
gpointer user_data)
{
GError *error = NULL;
- EmpathyAccount *account = EMPATHY_ACCOUNT (src);
+ TpAccount *account = TP_ACCOUNT (src);
GSimpleAsyncResult *set_result = user_data;
- empathy_account_set_display_name_finish (account, res, &error);
+ tp_account_set_display_name_finish (account, res, &error);
if (error != NULL)
{
@@ -950,7 +962,7 @@ empathy_account_settings_set_display_name_async (
return;
}
- empathy_account_set_display_name_async (priv->account, name,
+ tp_account_set_display_name_async (priv->account, name,
account_settings_display_name_set_cb, result);
}
@@ -977,10 +989,10 @@ account_settings_icon_name_set_cb (GObject *src,
gpointer user_data)
{
GError *error = NULL;
- EmpathyAccount *account = EMPATHY_ACCOUNT (src);
+ TpAccount *account = TP_ACCOUNT (src);
GSimpleAsyncResult *set_result = user_data;
- empathy_account_set_icon_name_finish (account, res, &error);
+ tp_account_set_icon_name_finish (account, res, &error);
if (error != NULL)
{
@@ -1017,7 +1029,7 @@ empathy_account_settings_set_icon_name_async (
return;
}
- empathy_account_set_icon_name_async (priv->account, name,
+ tp_account_set_icon_name_async (priv->account, name,
account_settings_icon_name_set_cb, result);
}
@@ -1048,8 +1060,8 @@ empathy_account_settings_account_updated (GObject *source,
GSimpleAsyncResult *r;
GError *error = NULL;
- if (!empathy_account_update_settings_finish (EMPATHY_ACCOUNT (source),
- result, &error))
+ if (!tp_account_update_parameters_finish (TP_ACCOUNT (source),
+ result, NULL, &error))
{
g_simple_async_result_set_from_error (priv->apply_result, error);
g_error_free (error);
@@ -1073,12 +1085,12 @@ empathy_account_settings_created_cb (GObject *source,
{
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data);
EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
- EmpathyAccount *account;
+ TpAccount *account;
GError *error = NULL;
GSimpleAsyncResult *r;
- 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)
{
@@ -1106,11 +1118,13 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings)
TpConnectionPresenceType type;
gchar *status;
gchar *message;
+ EmpathyIdle *idle;
properties = tp_asv_new (NULL, NULL);
- type = empathy_account_manager_get_requested_global_presence
- (priv->account_manager, &status, &message);
+ idle = empathy_idle_dup_singleton ();
+ type = empathy_idle_get_requested_presence (idle, &status, &message);
+ g_object_unref (idle);
if (type != TP_CONNECTION_PRESENCE_TYPE_UNSET)
{
@@ -1142,7 +1156,7 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings)
tp_asv_set_string (properties, TP_IFACE_ACCOUNT ".Icon",
priv->icon_name);
- empathy_account_manager_create_account_async (priv->account_manager,
+ tp_account_manager_create_account_async (priv->account_manager,
priv->cm_name, priv->protocol, priv->display_name,
priv->parameters, properties,
empathy_account_settings_created_cb,
@@ -1152,22 +1166,24 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings)
}
static void
-empathy_account_settings_manager_ready_cb (EmpathyAccountManager *manager,
- GParamSpec *spec,
+empathy_account_settings_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data);
EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
- if (empathy_account_manager_is_ready (manager))
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
{
- g_assert (priv->apply_result != NULL && priv->account == NULL);
- g_signal_handler_disconnect (priv->account_manager,
- priv->account_manager_ready_id);
- priv->account_manager_ready_id = 0;
-
- empathy_account_settings_do_create_account (settings);
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
}
+
+ g_assert (priv->apply_result != NULL && priv->account == NULL);
+ empathy_account_settings_do_create_account (settings);
}
void
@@ -1180,8 +1196,8 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
if (priv->apply_result != NULL)
{
g_simple_async_report_error_in_idle (G_OBJECT (settings),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING, "Applying already in progress");
+ callback, user_data,
+ G_IO_ERROR, G_IO_ERROR_PENDING, "Applying already in progress");
return;
}
@@ -1190,20 +1206,14 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
if (priv->account == NULL)
{
- if (empathy_account_manager_is_ready (priv->account_manager))
- empathy_account_settings_do_create_account (settings);
- else
- priv->account_manager_ready_id = g_signal_connect (
- priv->account_manager,
- "notify::ready",
- G_CALLBACK (empathy_account_settings_manager_ready_cb),
- settings);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ empathy_account_settings_manager_ready_cb, settings);
}
else
{
- empathy_account_update_settings_async (priv->account,
- priv->parameters, (const gchar **)priv->unset_parameters->data,
- empathy_account_settings_account_updated, settings);
+ tp_account_update_parameters_async (priv->account,
+ priv->parameters, (const gchar **)priv->unset_parameters->data,
+ empathy_account_settings_account_updated, settings);
}
}
@@ -1224,12 +1234,12 @@ empathy_account_settings_apply_finish (EmpathyAccountSettings *settings,
gboolean
empathy_account_settings_has_account (EmpathyAccountSettings *settings,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyAccountSettingsPriv *priv;
g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), FALSE);
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT (account), FALSE);
+ g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
priv = GET_PRIV (settings);
@@ -1262,7 +1272,7 @@ empathy_account_settings_is_valid (EmpathyAccountSettings *settings)
{
const GHashTable *account_params;
- account_params = empathy_account_get_parameters (priv->account);
+ account_params = tp_account_get_parameters (priv->account);
if (tp_asv_lookup (account_params, current))
continue;
}
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index c7d263e3b..0ea9b5567 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
#include <telepathy-glib/connection-manager.h>
G_BEGIN_DECLS
@@ -66,7 +66,7 @@ EmpathyAccountSettings * empathy_account_settings_new (
const char *display_name);
EmpathyAccountSettings * empathy_account_settings_new_for_account (
- EmpathyAccount *account);
+ TpAccount *account);
gboolean empathy_account_settings_is_ready (EmpathyAccountSettings *settings);
@@ -74,11 +74,11 @@ const gchar *empathy_account_settings_get_cm (EmpathyAccountSettings *settings);
const gchar *empathy_account_settings_get_protocol (
EmpathyAccountSettings *settings);
-EmpathyAccount *empathy_account_settings_get_account (
+TpAccount *empathy_account_settings_get_account (
EmpathyAccountSettings *settings);
gboolean empathy_account_settings_has_account (
- EmpathyAccountSettings *settings, EmpathyAccount *account);
+ EmpathyAccountSettings *settings, TpAccount *account);
TpConnectionManagerParam *empathy_account_settings_get_tp_params (
EmpathyAccountSettings *settings);
diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c
deleted file mode 100644
index fb1b2756d..000000000
--- a/libempathy/empathy-account.c
+++ /dev/null
@@ -1,1305 +0,0 @@
-/*
- * empathy-account.c - Source for EmpathyAccount
- * Copyright (C) 2009 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/account.h>
-#include <telepathy-glib/gtypes.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/defs.h>
-
-#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "empathy-account.h"
-#include "empathy-account-manager.h"
-#include "empathy-utils.h"
-#include "empathy-marshal.h"
-
-/* signals */
-enum {
- STATUS_CHANGED,
- PRESENCE_CHANGED,
- REMOVED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-/* properties */
-enum {
- PROP_ENABLED = 1,
- PROP_PRESENCE,
- PROP_STATUS,
- PROP_STATUS_MESSAGE,
- PROP_READY,
- PROP_CONNECTION_STATUS,
- PROP_CONNECTION_STATUS_REASON,
- PROP_CONNECTION,
- PROP_UNIQUE_NAME,
- PROP_DBUS_DAEMON,
- PROP_DISPLAY_NAME
-};
-
-G_DEFINE_TYPE(EmpathyAccount, empathy_account, G_TYPE_OBJECT)
-
-/* private structure */
-typedef struct _EmpathyAccountPriv EmpathyAccountPriv;
-
-struct _EmpathyAccountPriv
-{
- gboolean dispose_has_run;
-
- TpConnection *connection;
- guint connection_invalidated_id;
-
- TpConnectionStatus connection_status;
- TpConnectionStatusReason reason;
-
- TpConnectionPresenceType presence;
- gchar *status;
- gchar *message;
-
- gboolean enabled;
- gboolean valid;
- gboolean ready;
- gboolean removed;
- /* Timestamp when the connection got connected in seconds since the epoch */
- glong connect_time;
-
- gchar *cm_name;
- gchar *proto_name;
- gchar *icon_name;
-
- gchar *unique_name;
- gchar *display_name;
- TpDBusDaemon *dbus;
-
- TpAccount *account;
- GHashTable *parameters;
-};
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccount)
-
-static void _empathy_account_set_connection (EmpathyAccount *account,
- const gchar *path);
-
-static void
-empathy_account_init (EmpathyAccount *obj)
-{
- EmpathyAccountPriv *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
- EMPATHY_TYPE_ACCOUNT, EmpathyAccountPriv);
-
- obj->priv = priv;
-
- priv->connection_status = TP_CONNECTION_STATUS_DISCONNECTED;
-}
-
-static void
-empathy_account_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- switch (prop_id)
- {
- case PROP_ENABLED:
- empathy_account_set_enabled_async (account,
- g_value_get_boolean (value), NULL, NULL);
- break;
- case PROP_UNIQUE_NAME:
- priv->unique_name = g_value_dup_string (value);
- break;
- case PROP_DBUS_DAEMON:
- priv->dbus = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- switch (prop_id)
- {
- case PROP_ENABLED:
- g_value_set_boolean (value, priv->enabled);
- break;
- case PROP_READY:
- g_value_set_boolean (value, priv->ready);
- break;
- case PROP_PRESENCE:
- g_value_set_uint (value, priv->presence);
- break;
- case PROP_STATUS:
- g_value_set_string (value, priv->status);
- break;
- case PROP_STATUS_MESSAGE:
- g_value_set_string (value, priv->message);
- break;
- case PROP_CONNECTION_STATUS:
- g_value_set_uint (value, priv->connection_status);
- break;
- case PROP_CONNECTION_STATUS_REASON:
- g_value_set_uint (value, priv->reason);
- break;
- case PROP_CONNECTION:
- g_value_set_object (value,
- empathy_account_get_connection (account));
- break;
- case PROP_UNIQUE_NAME:
- g_value_set_string (value,
- empathy_account_get_unique_name (account));
- break;
- case PROP_DISPLAY_NAME:
- g_value_set_string (value,
- empathy_account_get_display_name (account));
- break;
- case PROP_DBUS_DAEMON:
- g_value_set_object (value, priv->dbus);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-empathy_account_update (EmpathyAccount *account,
- GHashTable *properties)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GValueArray *arr;
- TpConnectionStatus old_s = priv->connection_status;
- gboolean presence_changed = FALSE;
-
- if (g_hash_table_lookup (properties, "ConnectionStatus") != NULL)
- priv->connection_status =
- tp_asv_get_int32 (properties, "ConnectionStatus", NULL);
-
- if (g_hash_table_lookup (properties, "ConnectionStatusReason") != NULL)
- priv->reason = tp_asv_get_int32 (properties,
- "ConnectionStatusReason", NULL);
-
- if (g_hash_table_lookup (properties, "CurrentPresence") != NULL)
- {
- presence_changed = TRUE;
- arr = tp_asv_get_boxed (properties, "CurrentPresence",
- TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- priv->presence = g_value_get_uint (g_value_array_get_nth (arr, 0));
-
- g_free (priv->status);
- priv->status = g_value_dup_string (g_value_array_get_nth (arr, 1));
-
- g_free (priv->message);
- priv->message = g_value_dup_string (g_value_array_get_nth (arr, 2));
- }
-
- if (g_hash_table_lookup (properties, "DisplayName") != NULL)
- {
- g_free (priv->display_name);
- priv->display_name =
- g_strdup (tp_asv_get_string (properties, "DisplayName"));
- g_object_notify (G_OBJECT (account), "display-name");
- }
-
- if (g_hash_table_lookup (properties, "Icon") != NULL)
- {
- const gchar *icon_name;
-
- icon_name = tp_asv_get_string (properties, "Icon");
-
- g_free (priv->icon_name);
-
- if (EMP_STR_EMPTY (icon_name))
- priv->icon_name = empathy_protocol_icon_name (priv->proto_name);
- else
- priv->icon_name = g_strdup (icon_name);
- }
-
- if (g_hash_table_lookup (properties, "Enabled") != NULL)
- {
- gboolean enabled = tp_asv_get_boolean (properties, "Enabled", NULL);
- if (priv->enabled != enabled)
- {
- priv->enabled = enabled;
- g_object_notify (G_OBJECT (account), "enabled");
- }
- }
-
- if (g_hash_table_lookup (properties, "Valid") != NULL)
- priv->valid = tp_asv_get_boolean (properties, "Valid", NULL);
-
- if (g_hash_table_lookup (properties, "Parameters") != NULL)
- {
- GHashTable *parameters;
-
- parameters = tp_asv_get_boxed (properties, "Parameters",
- TP_HASH_TYPE_STRING_VARIANT_MAP);
-
- if (priv->parameters != NULL)
- g_hash_table_unref (priv->parameters);
-
- priv->parameters = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP,
- parameters);
- }
-
- if (!priv->ready)
- {
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (account), "ready");
- }
-
- if (priv->connection_status != old_s)
- {
- if (priv->connection_status == TP_CONNECTION_STATUS_CONNECTED)
- {
- GTimeVal val;
- g_get_current_time (&val);
-
- priv->connect_time = val.tv_sec;
- }
-
- g_signal_emit (account, signals[STATUS_CHANGED], 0,
- old_s, priv->connection_status, priv->reason);
-
- g_object_notify (G_OBJECT (account), "connection-status");
- g_object_notify (G_OBJECT (account), "connection-status-reason");
- }
-
- if (presence_changed)
- {
- g_signal_emit (account, signals[PRESENCE_CHANGED], 0,
- priv->presence, priv->status, priv->message);
- g_object_notify (G_OBJECT (account), "presence");
- g_object_notify (G_OBJECT (account), "status");
- g_object_notify (G_OBJECT (account), "status-message");
- }
-
- if (g_hash_table_lookup (properties, "Connection") != NULL)
- {
- const gchar *conn_path =
- tp_asv_get_object_path (properties, "Connection");
-
- _empathy_account_set_connection (account, conn_path);
- }
-}
-
-static void
-empathy_account_properties_changed (TpAccount *proxy,
- GHashTable *properties,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (!priv->ready)
- return;
-
- empathy_account_update (account, properties);
-}
-
-static void
-empathy_account_removed_cb (TpAccount *proxy,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->removed)
- return;
-
- priv->removed = TRUE;
-
- g_signal_emit (account, signals[REMOVED], 0);
-}
-
-static void
-empathy_account_got_all_cb (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);
-
- DEBUG ("Got whole set of properties for %s",
- empathy_account_get_unique_name (account));
-
- if (error != NULL)
- {
- DEBUG ("Failed to get the initial set of account properties: %s",
- error->message);
- return;
- }
-
- empathy_account_update (account, properties);
-}
-
-static gchar *
-empathy_account_unescape_protocol (const gchar *protocol, gssize len)
-{
- gchar *result, *escape;
- /* Bad implementation might accidentally use tp_escape_as_identifier,
- * which escapes - in the wrong way... */
- if ((escape = g_strstr_len (protocol, len, "_2d")) != NULL)
- {
- GString *str;
- const gchar *input;
-
- str = g_string_new ("");
- input = protocol;
- do {
- g_string_append_len (str, input, escape - input);
- g_string_append_c (str, '-');
-
- len -= escape - input + 3;
- input = escape + 3;
- } while ((escape = g_strstr_len (input, len, "_2d")) != NULL);
-
- g_string_append_len (str, input, len);
-
- result = g_string_free (str, FALSE);
- }
- else
- {
- result = g_strndup (protocol, len);
- }
-
- g_strdelimit (result, "_", '-');
-
- return result;
-}
-
-static gboolean
-empathy_account_parse_unique_name (const gchar *bus_name,
- gchar **protocol, gchar **manager)
-{
- const gchar *proto, *proto_end;
- const gchar *cm, *cm_end;
-
- g_return_val_if_fail (
- g_str_has_prefix (bus_name, TP_ACCOUNT_OBJECT_PATH_BASE), FALSE);
-
- cm = bus_name + strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
-
- for (cm_end = cm; *cm_end != '/' && *cm_end != '\0'; cm_end++)
- /* pass */;
-
- if (*cm_end == '\0')
- return FALSE;
-
- if (cm_end == '\0')
- return FALSE;
-
- proto = cm_end + 1;
-
- for (proto_end = proto; *proto_end != '/' && *proto_end != '\0'; proto_end++)
- /* pass */;
-
- if (*proto_end == '\0')
- return FALSE;
-
- if (protocol != NULL)
- {
- *protocol = empathy_account_unescape_protocol (proto, proto_end - proto);
- }
-
- if (manager != NULL)
- *manager = g_strndup (cm, cm_end - cm);
-
- return TRUE;
-}
-
-static void
-account_invalidated_cb (TpProxy *proxy, guint domain, gint code,
- gchar *message, gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->removed)
- return;
-
- priv->removed = TRUE;
-
- g_signal_emit (account, signals[REMOVED], 0);
-}
-
-static void
-empathy_account_constructed (GObject *object)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- priv->account = tp_account_new (priv->dbus, priv->unique_name, NULL);
-
- g_signal_connect (priv->account, "invalidated",
- G_CALLBACK (account_invalidated_cb), object);
-
- empathy_account_parse_unique_name (priv->unique_name,
- &(priv->proto_name), &(priv->cm_name));
-
- priv->icon_name = empathy_protocol_icon_name (priv->proto_name);
-
- tp_cli_account_connect_to_account_property_changed (priv->account,
- empathy_account_properties_changed,
- NULL, NULL, object, NULL);
-
- tp_cli_account_connect_to_removed (priv->account,
- empathy_account_removed_cb,
- NULL, NULL, object, NULL);
-
- empathy_account_refresh_properties (account);
-}
-
-static void empathy_account_dispose (GObject *object);
-static void empathy_account_finalize (GObject *object);
-
-static void
-empathy_account_class_init (EmpathyAccountClass *empathy_account_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (empathy_account_class);
-
- g_type_class_add_private (empathy_account_class,
- sizeof (EmpathyAccountPriv));
-
- object_class->set_property = empathy_account_set_property;
- object_class->get_property = empathy_account_get_property;
- object_class->dispose = empathy_account_dispose;
- object_class->finalize = empathy_account_finalize;
- object_class->constructed = empathy_account_constructed;
-
- g_object_class_install_property (object_class, PROP_ENABLED,
- g_param_spec_boolean ("enabled",
- "Enabled",
- "Whether this account is enabled or not",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class, PROP_READY,
- g_param_spec_boolean ("ready",
- "Ready",
- "Whether this account is ready to be used",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_PRESENCE,
- g_param_spec_uint ("presence",
- "Presence",
- "The account connections presence type",
- 0,
- NUM_TP_CONNECTION_PRESENCE_TYPES,
- TP_CONNECTION_PRESENCE_TYPE_UNSET,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_STATUS,
- g_param_spec_string ("status",
- "Status",
- "The Status string of the account",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_STATUS_MESSAGE,
- g_param_spec_string ("status-message",
- "status-message",
- "The Status message string of the account",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION_STATUS,
- g_param_spec_uint ("connection-status",
- "ConnectionStatus",
- "The accounts connections status type",
- 0,
- NUM_TP_CONNECTION_STATUSES,
- TP_CONNECTION_STATUS_DISCONNECTED,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION_STATUS_REASON,
- g_param_spec_uint ("connection-status-reason",
- "ConnectionStatusReason",
- "The account connections status reason",
- 0,
- NUM_TP_CONNECTION_STATUS_REASONS,
- TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_CONNECTION,
- g_param_spec_object ("connection",
- "Connection",
- "The accounts connection",
- TP_TYPE_CONNECTION,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- g_object_class_install_property (object_class, PROP_UNIQUE_NAME,
- g_param_spec_string ("unique-name",
- "UniqueName",
- "The accounts unique name",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class, PROP_DBUS_DAEMON,
- g_param_spec_object ("dbus-daemon",
- "dbus-daemon",
- "The Tp Dbus daemon on which this account exists",
- TP_TYPE_DBUS_DAEMON,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class, PROP_DISPLAY_NAME,
- g_param_spec_string ("display-name",
- "DisplayName",
- "The accounts display name",
- NULL,
- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
-
- signals[STATUS_CHANGED] = g_signal_new ("status-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _empathy_marshal_VOID__UINT_UINT_UINT,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
-
- signals[PRESENCE_CHANGED] = g_signal_new ("presence-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _empathy_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[REMOVED] = g_signal_new ("removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-empathy_account_free_connection (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- TpConnection *conn;
-
- if (priv->connection == NULL)
- return;
-
- conn = priv->connection;
- priv->connection = NULL;
-
- if (priv->connection_invalidated_id != 0)
- g_signal_handler_disconnect (conn, priv->connection_invalidated_id);
- priv->connection_invalidated_id = 0;
-
- g_object_unref (conn);
-}
-
-void
-empathy_account_dispose (GObject *object)
-{
- EmpathyAccount *self = EMPATHY_ACCOUNT (object);
- EmpathyAccountPriv *priv = GET_PRIV (self);
-
- if (priv->dispose_has_run)
- return;
-
- priv->dispose_has_run = TRUE;
-
- empathy_account_free_connection (self);
-
- /* release any references held by the object here */
- if (G_OBJECT_CLASS (empathy_account_parent_class)->dispose != NULL)
- G_OBJECT_CLASS (empathy_account_parent_class)->dispose (object);
-}
-
-void
-empathy_account_finalize (GObject *object)
-{
- EmpathyAccountPriv *priv = GET_PRIV (object);
-
- g_free (priv->status);
- g_free (priv->message);
-
- g_free (priv->cm_name);
- g_free (priv->proto_name);
- g_free (priv->icon_name);
- g_free (priv->display_name);
-
- /* free any data held directly by the object here */
- if (G_OBJECT_CLASS (empathy_account_parent_class)->finalize != NULL)
- G_OBJECT_CLASS (empathy_account_parent_class)->finalize (object);
-}
-
-gboolean
-empathy_account_is_just_connected (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GTimeVal val;
-
- if (priv->connection_status != TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- g_get_current_time (&val);
-
- return (val.tv_sec - priv->connect_time) < 10;
-}
-
-/**
- * empathy_account_get_connection:
- * @account: a #EmpathyAccount
- *
- * Get the connection of the account, or NULL if account is offline or the
- * connection is not yet ready. This function does not return a new ref.
- *
- * Returns: the connection of the account.
- **/
-TpConnection *
-empathy_account_get_connection (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection != NULL &&
- tp_connection_is_ready (priv->connection))
- return priv->connection;
-
- return NULL;
-}
-
-/**
- * empathy_account_get_connection_for_path:
- * @account: a #EmpathyAccount
- * @patch: the path to connection object for #EmpathyAccount
- *
- * Get the connection of the account on path. This function does not return a
- * new ref. It is not guaranteed that the returned connection object is ready
- *
- * Returns: the connection of the account.
- **/
-TpConnection *
-empathy_account_get_connection_for_path (EmpathyAccount *account,
- const gchar *path)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- /* double-check that the object path is valid */
- if (!tp_dbus_check_valid_object_path (path, NULL))
- return NULL;
-
- /* Should be a full object path, not the special "/" value */
- if (strlen (path) == 1)
- return NULL;
-
- _empathy_account_set_connection (account, path);
-
- return priv->connection;
-}
-
-/**
- * empathy_account_get_unique_name:
- * @account: a #EmpathyAccount
- *
- * Returns: the unique name of the account.
- **/
-const gchar *
-empathy_account_get_unique_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->unique_name;
-}
-
-/**
- * empathy_account_get_display_name:
- * @account: a #EmpathyAccount
- *
- * Returns: the display name of the account.
- **/
-const gchar *
-empathy_account_get_display_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->display_name;
-}
-
-gboolean
-empathy_account_is_valid (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->valid;
-}
-
-const gchar *
-empathy_account_get_connection_manager (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->cm_name;
-}
-
-const gchar *
-empathy_account_get_protocol (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->proto_name;
-}
-
-const gchar *
-empathy_account_get_icon_name (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->icon_name;
-}
-
-const GHashTable *
-empathy_account_get_parameters (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->parameters;
-}
-
-gboolean
-empathy_account_is_enabled (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->enabled;
-}
-
-gboolean
-empathy_account_is_ready (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- return priv->ready;
-}
-
-
-EmpathyAccount *
-empathy_account_new (TpDBusDaemon *dbus,
- const gchar *unique_name)
-{
- return EMPATHY_ACCOUNT (g_object_new (EMPATHY_TYPE_ACCOUNT,
- "dbus-daemon", dbus,
- "unique-name", unique_name,
- NULL));
-}
-
-static void
-empathy_account_connection_ready_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
-
- if (error != NULL)
- {
- DEBUG ("(%s) Connection failed to become ready: %s",
- empathy_account_get_unique_name (account), error->message);
- empathy_account_free_connection (account);
- }
- else
- {
- DEBUG ("(%s) Connection ready",
- empathy_account_get_unique_name (account));
- g_object_notify (G_OBJECT (account), "connection");
- }
-}
-
-static void
-_empathy_account_connection_invalidated_cb (TpProxy *self,
- guint domain,
- gint code,
- gchar *message,
- gpointer user_data)
-{
- EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection == NULL)
- return;
-
- DEBUG ("(%s) Connection invalidated",
- empathy_account_get_unique_name (account));
-
- g_assert (priv->connection == TP_CONNECTION (self));
-
- empathy_account_free_connection (account);
-
- g_object_notify (G_OBJECT (account), "connection");
-}
-
-static void
-_empathy_account_set_connection (EmpathyAccount *account,
- const gchar *path)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (priv->connection != NULL)
- {
- const gchar *current;
-
- current = tp_proxy_get_object_path (priv->connection);
- if (!tp_strdiff (current, path))
- return;
- }
-
- empathy_account_free_connection (account);
-
- if (tp_strdiff ("/", path))
- {
- GError *error = NULL;
- priv->connection = tp_connection_new (priv->dbus, NULL, path, &error);
-
- if (priv->connection == NULL)
- {
- DEBUG ("Failed to create a new TpConnection: %s",
- error->message);
- g_error_free (error);
- }
- else
- {
- priv->connection_invalidated_id = g_signal_connect (priv->connection,
- "invalidated",
- G_CALLBACK (_empathy_account_connection_invalidated_cb), account);
-
- DEBUG ("Readying connection for %s", priv->unique_name);
- /* notify a change in the connection property when it's ready */
- tp_connection_call_when_ready (priv->connection,
- empathy_account_connection_ready_cb, account);
- }
- }
-
- g_object_notify (G_OBJECT (account), "connection");
-}
-
-static void
-account_enabled_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-gboolean
-empathy_account_set_enabled_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_enabled_finish))
- return FALSE;
-
- return TRUE;
-}
-
-void
-empathy_account_set_enabled_async (EmpathyAccount *account,
- gboolean enabled,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- EmpathyAccountManager *acc_manager;
- GValue value = {0, };
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_set_enabled_finish);
- char *status = NULL;
- char *status_message = NULL;
- TpConnectionPresenceType presence;
-
- if (priv->enabled == enabled)
- {
- g_simple_async_result_complete_in_idle (result);
- return;
- }
-
- if (enabled)
- {
- acc_manager = empathy_account_manager_dup_singleton ();
- presence = empathy_account_manager_get_requested_global_presence
- (acc_manager, &status, &status_message);
-
- if (presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
- empathy_account_request_presence (account, presence, status,
- status_message);
-
- g_object_unref (acc_manager);
- g_free (status);
- g_free (status_message);
- }
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, enabled);
-
- tp_cli_dbus_properties_call_set (TP_PROXY (priv->account),
- -1, TP_IFACE_ACCOUNT, "Enabled", &value,
- account_enabled_set_cb, result, NULL, G_OBJECT (account));
-}
-
-static void
-account_reconnected_cb (TpAccount *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-gboolean
-empathy_account_reconnect_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_reconnect_finish))
- return FALSE;
-
- return TRUE;
-}
-
-void
-empathy_account_reconnect_async (EmpathyAccount *account,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_reconnect_finish);
-
- tp_cli_account_call_reconnect (priv->account,
- -1, account_reconnected_cb, result, NULL, G_OBJECT (account));
-}
-
-static void
-empathy_account_requested_presence_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- DEBUG ("Failed to set the requested presence: %s", error->message);
-}
-
-
-void
-empathy_account_request_presence (EmpathyAccount *account,
- TpConnectionPresenceType type,
- const gchar *status,
- const gchar *message)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GValue value = {0, };
- GValueArray *arr;
-
- g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- g_value_take_boxed (&value, dbus_g_type_specialized_construct
- (TP_STRUCT_TYPE_SIMPLE_PRESENCE));
- arr = (GValueArray *) g_value_get_boxed (&value);
-
- g_value_set_uint (arr->values, type);
- g_value_set_static_string (arr->values + 1, status);
- g_value_set_static_string (arr->values + 2, message);
-
- tp_cli_dbus_properties_call_set (TP_PROXY (priv->account),
- -1,
- TP_IFACE_ACCOUNT,
- "RequestedPresence",
- &value,
- empathy_account_requested_presence_cb,
- NULL,
- NULL,
- G_OBJECT (account));
-
- g_value_unset (&value);
-}
-
-static void
-empathy_account_updated_cb (TpAccount *proxy,
- const gchar **reconnect_required,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (result, (GError *) error);
- }
-
- g_simple_async_result_complete (result);
- g_object_unref (G_OBJECT (result));
-}
-
-void
-empathy_account_update_settings_async (EmpathyAccount *account,
- GHashTable *parameters, const gchar **unset_parameters,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_update_settings_finish);
-
- tp_cli_account_call_update_parameters (priv->account,
- -1,
- parameters,
- unset_parameters,
- empathy_account_updated_cb,
- result,
- NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_update_settings_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return FALSE;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (account), empathy_account_update_settings_finish), FALSE);
-
- return TRUE;
-}
-
-static void
-account_display_name_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-void
-empathy_account_set_display_name_async (EmpathyAccount *account,
- const char *display_name,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
- GValue value = {0, };
- EmpathyAccountPriv *priv = GET_PRIV (account);
-
- if (display_name == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (account),
- callback, user_data, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Can't set an empty display name"));
- return;
- }
-
- result = g_simple_async_result_new (G_OBJECT (account), callback,
- user_data, empathy_account_set_display_name_finish);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, display_name);
-
- tp_cli_dbus_properties_call_set (priv->account, -1, TP_IFACE_ACCOUNT,
- "DisplayName", &value, account_display_name_set_cb, result, NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_set_display_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_display_name_finish))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-account_icon_name_set_cb (TpProxy *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL)
- g_simple_async_result_set_from_error (result, (GError *) error);
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-void
-empathy_account_set_icon_name_async (EmpathyAccount *account,
- const char *icon_name,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
- GValue value = {0, };
- EmpathyAccountPriv *priv = GET_PRIV (account);
- const char *icon_name_set;
-
- if (icon_name == NULL)
- /* settings an empty icon name is allowed */
- icon_name_set = "";
- else
- icon_name_set = icon_name;
-
- result = g_simple_async_result_new (G_OBJECT (account), callback,
- user_data, empathy_account_set_icon_name_finish);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, icon_name_set);
-
- tp_cli_dbus_properties_call_set (priv->account, -1, TP_IFACE_ACCOUNT,
- "Icon", &value, account_icon_name_set_cb, result, NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_set_icon_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error) ||
- !g_simple_async_result_is_valid (result, G_OBJECT (account),
- empathy_account_set_icon_name_finish))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-empathy_account_remove_cb (TpAccount *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-
- if (error != NULL)
- {
- g_simple_async_result_set_from_error (result, (GError *) error);
- }
-
- g_simple_async_result_complete (result);
- g_object_unref (G_OBJECT (result));
-}
-
-void
-empathy_account_remove_async (EmpathyAccount *account,
- GAsyncReadyCallback callback, gpointer user_data)
-{
- EmpathyAccountPriv *priv = GET_PRIV (account);
- GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, empathy_account_remove_finish);
-
- tp_cli_account_call_remove (priv->account,
- -1,
- empathy_account_remove_cb,
- result,
- NULL,
- G_OBJECT (account));
-}
-
-gboolean
-empathy_account_remove_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return FALSE;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (account), empathy_account_update_settings_finish), FALSE);
-
- return TRUE;
-}
-
-void
-empathy_account_refresh_properties (EmpathyAccount *account)
-{
- EmpathyAccountPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_ACCOUNT (account));
-
- priv = GET_PRIV (account);
-
- tp_cli_dbus_properties_call_get_all (priv->account, -1,
- TP_IFACE_ACCOUNT,
- empathy_account_got_all_cb,
- NULL,
- NULL,
- G_OBJECT (account));
-}
-
diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h
deleted file mode 100644
index 66f899448..000000000
--- a/libempathy/empathy-account.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * empathy-account.h - Header for EmpathyAccount
- * Copyright (C) 2009 Collabora Ltd.
- * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __EMPATHY_ACCOUNT_H__
-#define __EMPATHY_ACCOUNT_H__
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include <telepathy-glib/connection.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyAccount EmpathyAccount;
-typedef struct _EmpathyAccountClass EmpathyAccountClass;
-
-struct _EmpathyAccountClass {
- GObjectClass parent_class;
-};
-
-struct _EmpathyAccount {
- GObject parent;
- gpointer priv;
-};
-
-GType empathy_account_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_ACCOUNT (empathy_account_get_type ())
-#define EMPATHY_ACCOUNT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_ACCOUNT, EmpathyAccount))
-#define EMPATHY_ACCOUNT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_ACCOUNT, EmpathyAccountClass))
-#define EMPATHY_IS_ACCOUNT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_ACCOUNT))
-#define EMPATHY_IS_ACCOUNT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_ACCOUNT))
-#define EMPATHY_ACCOUNT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT, \
- EmpathyAccountClass))
-
-gboolean empathy_account_is_just_connected (EmpathyAccount *account);
-TpConnection *empathy_account_get_connection (EmpathyAccount *account);
-TpConnection *empathy_account_get_connection_for_path (EmpathyAccount *account,
- const gchar *path);
-const gchar *empathy_account_get_unique_name (EmpathyAccount *account);
-const gchar *empathy_account_get_display_name (EmpathyAccount *account);
-
-const gchar *empathy_account_get_connection_manager (EmpathyAccount *account);
-const gchar *empathy_account_get_protocol (EmpathyAccount *account);
-const gchar *empathy_account_get_icon_name (EmpathyAccount *account);
-
-void empathy_account_set_enabled_async (EmpathyAccount *account,
- gboolean enabled, GAsyncReadyCallback callback, gpointer user_data);
-gboolean empathy_account_set_enabled_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_reconnect_async (EmpathyAccount *account,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_reconnect_finish (EmpathyAccount *account,
- GAsyncResult *result,
- GError **error);
-
-gboolean empathy_account_is_enabled (EmpathyAccount *account);
-
-gboolean empathy_account_is_valid (EmpathyAccount *account);
-gboolean empathy_account_is_ready (EmpathyAccount *account);
-
-void empathy_account_update_settings_async (EmpathyAccount *account,
- GHashTable *parameters, const gchar **unset_parameters,
- GAsyncReadyCallback callback, gpointer user_data);
-
-gboolean empathy_account_update_settings_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_remove_async (EmpathyAccount *account,
- GAsyncReadyCallback callback, gpointer user_data);
-gboolean empathy_account_remove_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_set_display_name_async (EmpathyAccount *account,
- const gchar *display_name, GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_set_display_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-void empathy_account_set_icon_name_async (EmpathyAccount *account,
- const gchar *icon_name, GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean empathy_account_set_icon_name_finish (EmpathyAccount *account,
- GAsyncResult *result, GError **error);
-
-EmpathyAccount *empathy_account_new (TpDBusDaemon *bus_daemon,
- const gchar *unique_name);
-
-void empathy_account_request_presence (EmpathyAccount *account,
- TpConnectionPresenceType type, const gchar *status, const gchar *message);
-
-const GHashTable *empathy_account_get_parameters (EmpathyAccount *account);
-
-void empathy_account_refresh_properties (EmpathyAccount *account);
-
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_ACCOUNT_H__*/
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index b8c721bcb..56295fe5a 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -30,11 +30,11 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/interfaces.h>
#include "empathy-tp-chat.h"
#include "empathy-chatroom-manager.h"
-#include "empathy-account-manager.h"
#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -51,8 +51,8 @@ typedef struct
{
GList *chatrooms;
gchar *file;
- EmpathyAccountManager *account_manager;
- gulong account_manager_ready_handler_id;
+ TpAccountManager *account_manager;
+
/* source id of the autosave timer */
gint save_timer_id;
gboolean ready;
@@ -105,7 +105,7 @@ chatroom_manager_file_save (EmpathyChatroomManager *manager)
continue;
}
- account_id = empathy_account_get_unique_name (
+ account_id = tp_proxy_get_object_path (
empathy_chatroom_get_account (chatroom));
node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL);
@@ -184,7 +184,7 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
{
EmpathyChatroomManagerPriv *priv;
EmpathyChatroom *chatroom;
- EmpathyAccount *account;
+ TpAccount *account;
xmlNodePtr child;
gchar *str;
gchar *name;
@@ -230,7 +230,7 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
xmlFree (str);
}
- account = empathy_account_manager_get_account (priv->account_manager,
+ account = tp_account_manager_ensure_account (priv->account_manager,
account_id);
if (!account) {
g_free (name);
@@ -369,12 +369,6 @@ chatroom_manager_finalize (GObject *object)
priv = GET_PRIV (object);
- if (priv->account_manager_ready_handler_id > 0)
- {
- g_signal_handler_disconnect (priv->account_manager,
- priv->account_manager_ready_handler_id);
- }
-
g_object_unref (priv->account_manager);
if (priv->save_timer_id > 0)
@@ -402,18 +396,22 @@ chatroom_manager_finalize (GObject *object)
}
static void
-account_manager_ready_cb (GObject *gobject,
- GParamSpec *pspec,
+account_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
EmpathyChatroomManager *self = EMPATHY_CHATROOM_MANAGER (user_data);
- EmpathyChatroomManagerPriv *priv = GET_PRIV (self);
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
- chatroom_manager_get_all (self);
+ if (!tp_account_manager_prepare_finish (manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- g_signal_handler_disconnect (gobject,
- priv->account_manager_ready_handler_id);
- priv->account_manager_ready_handler_id = 0;
+ chatroom_manager_get_all (self);
}
static GObject *
@@ -440,16 +438,10 @@ empathy_chatroom_manager_constructor (GType type,
chatroom_manager_singleton = self;
g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton);
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
- priv->account_manager_ready_handler_id = 0;
-
- if (empathy_account_manager_is_ready (priv->account_manager))
- chatroom_manager_get_all (self);
- else
- priv->account_manager_ready_handler_id = g_signal_connect (
- G_OBJECT (priv->account_manager), "notify::ready",
- G_CALLBACK (account_manager_ready_cb), self);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_ready_cb, self);
if (priv->file == NULL)
{
@@ -612,7 +604,7 @@ empathy_chatroom_manager_remove (EmpathyChatroomManager *manager,
EmpathyChatroom *
empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *room)
{
EmpathyChatroomManagerPriv *priv;
@@ -625,7 +617,7 @@ empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
for (l = priv->chatrooms; l; l = l->next) {
EmpathyChatroom *chatroom;
- EmpathyAccount *this_account;
+ TpAccount *this_account;
const gchar *this_room;
chatroom = l->data;
@@ -643,7 +635,7 @@ empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
GList *
empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyChatroomManagerPriv *priv;
GList *chatrooms, *l;
@@ -672,7 +664,7 @@ empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
guint
empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyChatroomManagerPriv *priv;
GList *l;
@@ -731,14 +723,13 @@ static void
chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
EmpathyDispatchOperation *operation, gpointer manager)
{
- EmpathyChatroomManagerPriv *priv = GET_PRIV (manager);
EmpathyChatroom *chatroom;
TpChannel *channel;
EmpathyTpChat *chat;
const gchar *roomname;
GQuark channel_type;
TpHandleType handle_type;
- EmpathyAccount *account;
+ TpAccount *account;
TpConnection *connection;
channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
@@ -756,8 +747,7 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
chat = EMPATHY_TP_CHAT (
empathy_dispatch_operation_get_channel_wrapper (operation));
connection = empathy_tp_chat_get_connection (chat);
- account = empathy_account_manager_get_account_for_connection (
- priv->account_manager, connection);
+ account = empathy_get_account_for_connection (connection);
roomname = empathy_tp_chat_get_id (chat);
diff --git a/libempathy/empathy-chatroom-manager.h b/libempathy/empathy-chatroom-manager.h
index a6038f7fc..8ee2a897a 100644
--- a/libempathy/empathy-chatroom-manager.h
+++ b/libempathy/empathy-chatroom-manager.h
@@ -27,7 +27,8 @@
#include <glib-object.h>
-#include "empathy-account.h"
+#include <telepathy-glib/account.h>
+
#include "empathy-chatroom.h"
#include "empathy-dispatcher.h"
@@ -59,12 +60,12 @@ gboolean empathy_chatroom_manager_add (EmpathyChatroomMa
void empathy_chatroom_manager_remove (EmpathyChatroomManager *manager,
EmpathyChatroom *chatroom);
EmpathyChatroom * empathy_chatroom_manager_find (EmpathyChatroomManager *manager,
- EmpathyAccount *account,
- const gchar *room);
+ TpAccount *account,
+ const gchar *room);
GList * empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager,
- EmpathyAccount *account);
+ TpAccount *account);
guint empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager,
- EmpathyAccount *account);
+ TpAccount *account);
void empathy_chatroom_manager_observe (EmpathyChatroomManager *manager,
EmpathyDispatcher *dispatcher);
diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c
index 33df9a3d6..5d43a3ec1 100644
--- a/libempathy/empathy-chatroom.c
+++ b/libempathy/empathy-chatroom.c
@@ -31,7 +31,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroom)
typedef struct {
- EmpathyAccount *account;
+ TpAccount *account;
gchar *room;
gchar *name;
gboolean auto_connect;
@@ -84,7 +84,7 @@ empathy_chatroom_class_init (EmpathyChatroomClass *klass)
g_param_spec_object ("account",
"Chatroom Account",
"The account associated with an chatroom",
- EMPATHY_TYPE_ACCOUNT,
+ TP_TYPE_ACCOUNT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
@@ -312,7 +312,7 @@ chatroom_set_property (GObject *object,
}
EmpathyChatroom *
-empathy_chatroom_new (EmpathyAccount *account)
+empathy_chatroom_new (TpAccount *account)
{
return g_object_new (EMPATHY_TYPE_CHATROOM,
"account", account,
@@ -320,7 +320,7 @@ empathy_chatroom_new (EmpathyAccount *account)
}
EmpathyChatroom *
-empathy_chatroom_new_full (EmpathyAccount *account,
+empathy_chatroom_new_full (TpAccount *account,
const gchar *room,
const gchar *name,
gboolean auto_connect)
@@ -335,7 +335,7 @@ empathy_chatroom_new_full (EmpathyAccount *account,
NULL);
}
-EmpathyAccount *
+TpAccount *
empathy_chatroom_get_account (EmpathyChatroom *chatroom)
{
EmpathyChatroomPriv *priv;
@@ -348,7 +348,7 @@ empathy_chatroom_get_account (EmpathyChatroom *chatroom)
void
empathy_chatroom_set_account (EmpathyChatroom *chatroom,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyChatroomPriv *priv;
@@ -466,8 +466,8 @@ gboolean
empathy_chatroom_equal (gconstpointer v1,
gconstpointer v2)
{
- EmpathyAccount *account_a;
- EmpathyAccount *account_b;
+ TpAccount *account_a;
+ TpAccount *account_b;
const gchar *room_a;
const gchar *room_b;
diff --git a/libempathy/empathy-chatroom.h b/libempathy/empathy-chatroom.h
index c18c27449..3048aded7 100644
--- a/libempathy/empathy-chatroom.h
+++ b/libempathy/empathy-chatroom.h
@@ -24,7 +24,8 @@
#include <glib-object.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
+
#include <libempathy/empathy-tp-chat.h>
G_BEGIN_DECLS
@@ -51,14 +52,14 @@ struct _EmpathyChatroomClass {
};
GType empathy_chatroom_get_type (void) G_GNUC_CONST;
-EmpathyChatroom *empathy_chatroom_new (EmpathyAccount *account);
-EmpathyChatroom *empathy_chatroom_new_full (EmpathyAccount *account,
+EmpathyChatroom *empathy_chatroom_new (TpAccount *account);
+EmpathyChatroom *empathy_chatroom_new_full (TpAccount *account,
const gchar *room,
const gchar *name,
gboolean auto_connect);
-EmpathyAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom);
+TpAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom);
void empathy_chatroom_set_account (EmpathyChatroom *chatroom,
- EmpathyAccount *account);
+ TpAccount *account);
const gchar * empathy_chatroom_get_room (EmpathyChatroom *chatroom);
void empathy_chatroom_set_room (EmpathyChatroom *chatroom,
const gchar *room);
diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c
index 302fad3c5..53ccfbd63 100644
--- a/libempathy/empathy-contact-manager.c
+++ b/libempathy/empathy-contact-manager.c
@@ -23,10 +23,10 @@
#include <string.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/enums.h>
#include "empathy-contact-manager.h"
-#include "empathy-account-manager.h"
#include "empathy-contact-monitor.h"
#include "empathy-contact-list.h"
#include "empathy-utils.h"
@@ -37,7 +37,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactManager)
typedef struct {
GHashTable *lists;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
EmpathyContactMonitor *contact_monitor;
} EmpathyContactManagerPriv;
@@ -132,14 +132,21 @@ contact_manager_disconnect_foreach (gpointer key,
}
static void
-contact_manager_new_connection_cb (EmpathyAccountManager *account_manager,
- TpConnection *connection,
+contact_manager_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyContactManager *self)
{
EmpathyContactManagerPriv *priv = GET_PRIV (self);
EmpathyTpContactList *list;
+ TpConnection *connection;
+
+ connection = tp_account_get_connection (account);
- if (g_hash_table_lookup (priv->lists, connection)) {
+ if (connection == NULL || g_hash_table_lookup (priv->lists, connection)) {
return;
}
@@ -174,9 +181,6 @@ contact_manager_finalize (GObject *object)
object);
g_hash_table_destroy (priv->lists);
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- contact_manager_new_connection_cb,
- object);
g_object_unref (priv->account_manager);
if (priv->contact_monitor) {
@@ -233,9 +237,42 @@ empathy_contact_manager_class_init (EmpathyContactManagerClass *klass)
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *l;
+ EmpathyContactManager *manager = user_data;
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+
+ for (l = accounts; l != NULL; l = l->next) {
+ TpAccount *account = l->data;
+ TpConnection *conn = tp_account_get_connection (account);
+
+ if (conn != NULL) {
+ contact_manager_status_changed_cb (account, 0, 0, 0,
+ NULL, NULL, manager);
+ }
+
+ empathy_signal_connect_weak (account, "status-changed",
+ G_CALLBACK (contact_manager_status_changed_cb),
+ G_OBJECT (manager));
+ }
+ g_list_free (accounts);
+}
+
+static void
empathy_contact_manager_init (EmpathyContactManager *manager)
{
- GList *connections, *l;
EmpathyContactManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv);
@@ -244,21 +281,11 @@ empathy_contact_manager_init (EmpathyContactManager *manager)
empathy_proxy_equal,
(GDestroyNotify) g_object_unref,
(GDestroyNotify) g_object_unref);
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
priv->contact_monitor = NULL;
- g_signal_connect (priv->account_manager, "new-connection",
- G_CALLBACK (contact_manager_new_connection_cb),
- manager);
-
- /* Get ContactList for existing connections */
- connections = empathy_account_manager_dup_connections (priv->account_manager);
- for (l = connections; l; l = l->next) {
- contact_manager_new_connection_cb (priv->account_manager,
- l->data, manager);
- g_object_unref (l->data);
- }
- g_list_free (connections);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, manager);
}
EmpathyContactManager *
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 83ffd0780..a440ef23b 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -25,10 +25,10 @@
#include <glib/gi18n-lib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include "empathy-contact.h"
-#include "empathy-account-manager.h"
#include "empathy-utils.h"
#include "empathy-enum-types.h"
#include "empathy-marshal.h"
@@ -39,7 +39,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
typedef struct {
TpContact *tp_contact;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *id;
gchar *name;
EmpathyAvatar *avatar;
@@ -159,7 +159,7 @@ empathy_contact_class_init (EmpathyContactClass *class)
g_param_spec_object ("account",
"The account",
"The account associated with the contact",
- EMPATHY_TYPE_ACCOUNT,
+ TP_TYPE_ACCOUNT,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
@@ -409,7 +409,7 @@ empathy_contact_new (TpContact *tp_contact)
}
EmpathyContact *
-empathy_contact_new_for_log (EmpathyAccount *account,
+empathy_contact_new_for_log (TpAccount *account,
const gchar *id,
const gchar *name,
gboolean is_user)
@@ -554,7 +554,7 @@ empathy_contact_set_avatar (EmpathyContact *contact,
g_object_notify (G_OBJECT (contact), "avatar");
}
-EmpathyAccount *
+TpAccount *
empathy_contact_get_account (EmpathyContact *contact)
{
EmpathyContactPriv *priv;
@@ -565,16 +565,12 @@ empathy_contact_get_account (EmpathyContact *contact)
if (priv->account == NULL && priv->tp_contact != NULL)
{
- EmpathyAccountManager *manager;
TpConnection *connection;
/* FIXME: This assume the account manager already exists */
- manager = empathy_account_manager_dup_singleton ();
connection = tp_contact_get_connection (priv->tp_contact);
- priv->account = empathy_account_manager_get_account_for_connection (
- manager, connection);
- g_object_ref (priv->account);
- g_object_unref (manager);
+ priv->account =
+ g_object_ref (empathy_get_account_for_connection (connection));
}
return priv->account;
@@ -855,7 +851,7 @@ static gchar *
contact_get_avatar_filename (EmpathyContact *contact,
const gchar *token)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *avatar_path;
gchar *avatar_file;
gchar *token_escaped;
@@ -869,8 +865,8 @@ contact_get_avatar_filename (EmpathyContact *contact,
avatar_path = g_build_filename (g_get_user_cache_dir (),
"telepathy",
"avatars",
- empathy_account_get_connection_manager (account),
- empathy_account_get_protocol (account),
+ tp_account_get_connection_manager (account),
+ tp_account_get_protocol (account),
NULL);
g_mkdir_with_parents (avatar_path, 0700);
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index 4e9c98756..d5525818b 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -25,7 +25,7 @@
#include <glib-object.h>
#include <telepathy-glib/contact.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
G_BEGIN_DECLS
@@ -70,7 +70,7 @@ typedef enum {
GType empathy_contact_get_type (void) G_GNUC_CONST;
EmpathyContact * empathy_contact_new (TpContact *tp_contact);
-EmpathyContact * empathy_contact_new_for_log (EmpathyAccount *account,
+EmpathyContact * empathy_contact_new_for_log (TpAccount *account,
const gchar *id, const gchar *name, gboolean is_user);
TpContact * empathy_contact_get_tp_contact (EmpathyContact *contact);
const gchar * empathy_contact_get_id (EmpathyContact *contact);
@@ -80,7 +80,7 @@ void empathy_contact_set_name (EmpathyContact *contact, const gchar *name);
EmpathyAvatar * empathy_contact_get_avatar (EmpathyContact *contact);
void empathy_contact_set_avatar (EmpathyContact *contact,
EmpathyAvatar *avatar);
-EmpathyAccount * empathy_contact_get_account (EmpathyContact *contact);
+TpAccount * empathy_contact_get_account (EmpathyContact *contact);
TpConnection * empathy_contact_get_connection (EmpathyContact *contact);
TpConnectionPresenceType empathy_contact_get_presence (EmpathyContact *contact);
void empathy_contact_set_presence (EmpathyContact *contact,
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index eb43bc10e..40045cdb1 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -28,6 +28,7 @@
#include <glib/gi18n-lib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/enums.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/util.h>
@@ -45,7 +46,6 @@
#include "empathy-handler.h"
#include "empathy-utils.h"
#include "empathy-tube-handler.h"
-#include "empathy-account-manager.h"
#include "empathy-tp-contact-factory.h"
#include "empathy-chatroom-manager.h"
#include "empathy-utils.h"
@@ -58,7 +58,7 @@ typedef struct
{
gboolean dispose_has_run;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
/* connection to connection data mapping */
GHashTable *connections;
GHashTable *outstanding_classes_requests;
@@ -890,11 +890,18 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
}
static void
-dispatcher_new_connection_cb (EmpathyAccountManager *manager,
- TpConnection *connection,
+dispatcher_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyDispatcher *self)
{
- dispatcher_init_connection_if_needed (self, connection);
+ TpConnection *conn = tp_account_get_connection (account);
+
+ if (conn != NULL)
+ dispatcher_init_connection_if_needed (self, conn);
}
static void
@@ -993,9 +1000,6 @@ dispatcher_finalize (GObject *object)
g_hash_table_destroy (priv->request_channel_class_async_ids);
}
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- dispatcher_new_connection_cb, object);
-
for (l = priv->channels; l; l = l->next)
{
g_signal_handlers_disconnect_by_func (l->data,
@@ -1111,18 +1115,46 @@ empathy_dispatcher_class_init (EmpathyDispatcherClass *klass)
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *l;
+ EmpathyDispatcher *self = user_data;
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+ for (l = accounts; l; l = l->next)
+ {
+ TpAccount *a = l->data;
+ TpConnection *conn = tp_account_get_connection (a);
+
+ if (conn != NULL)
+ dispatcher_status_changed_cb (a, 0, 0, 0, NULL, NULL, self);
+
+ empathy_signal_connect_weak (a, "status-changed",
+ G_CALLBACK (dispatcher_status_changed_cb),
+ G_OBJECT (self));
+ }
+ g_list_free (accounts);
+}
+
+static void
empathy_dispatcher_init (EmpathyDispatcher *self)
{
- GList *connections, *l;
EmpathyDispatcherPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_DISPATCHER, EmpathyDispatcherPriv);
self->priv = priv;
- priv->account_manager = empathy_account_manager_dup_singleton ();
-
- g_signal_connect (priv->account_manager, "new-connection",
- G_CALLBACK (dispatcher_new_connection_cb),
- self);
+ priv->account_manager = tp_account_manager_dup ();
priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_object_unref, (GDestroyNotify) free_connection_data);
@@ -1132,15 +1164,8 @@ empathy_dispatcher_init (EmpathyDispatcher *self)
priv->channels = NULL;
- connections = empathy_account_manager_dup_connections (
- priv->account_manager);
- for (l = connections; l; l = l->next)
- {
- dispatcher_new_connection_cb (priv->account_manager, l->data,
- self);
- g_object_unref (l->data);
- }
- g_list_free (connections);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, self);
priv->request_channel_class_async_ids = g_hash_table_new (g_direct_hash,
g_direct_equal);
@@ -1956,15 +1981,16 @@ empathy_dispatcher_handle_channels (EmpathyHandler *handler,
EmpathyDispatcher *self = EMPATHY_DISPATCHER (user_data);
EmpathyDispatcherPriv *priv = GET_PRIV (self);
guint i;
- EmpathyAccount *account;
+ TpAccount *account;
TpConnection *connection;
- account = empathy_account_manager_ensure_account (priv->account_manager,
+ /* FIXME: should probably find out whether the account manager is prepared
+ * before ensuring. See bug #600111. */
+ account = tp_account_manager_ensure_account (priv->account_manager,
account_path);
g_assert (account != NULL);
- connection = empathy_account_get_connection_for_path (account,
- connection_path);
+ connection = tp_account_ensure_connection (account, connection_path);
if (connection == NULL)
{
g_set_error_literal (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index cc6ca62f4..8a0fcd88d 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -26,10 +26,10 @@
#include <glib/gi18n-lib.h>
#include <dbus/dbus-glib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
-#include "empathy-account-manager.h"
#include "empathy-idle.h"
#include "empathy-utils.h"
#include "empathy-connectivity.h"
@@ -40,6 +40,10 @@
/* Number of seconds before entering extended autoaway. */
#define EXT_AWAY_TIME (30*60)
+/* Number of seconds to consider an account in the "just connected" state
+ * for. */
+#define ACCOUNT_IS_JUST_CONNECTED_SECONDS 10
+
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIdle)
typedef struct {
DBusGProxy *gs_proxy;
@@ -58,7 +62,14 @@ typedef struct {
gboolean is_idle;
guint ext_away_timeout;
- EmpathyAccountManager *manager;
+ TpAccountManager *manager;
+
+ /* pointer to a TpAccount --> glong of time of connection */
+ GHashTable *connect_times;
+
+ TpConnectionPresenceType requested_presence_type;
+ gchar *requested_status_message;
+
} EmpathyIdlePriv;
typedef enum {
@@ -81,8 +92,20 @@ G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT);
static EmpathyIdle * idle_singleton = NULL;
+static const gchar *presence_type_to_status[NUM_TP_CONNECTION_PRESENCE_TYPES] = {
+ NULL,
+ "offline",
+ "available",
+ "away",
+ "xa",
+ "hidden",
+ "busy",
+ NULL,
+ NULL,
+};
+
static void
-idle_presence_changed_cb (EmpathyAccountManager *manager,
+idle_presence_changed_cb (TpAccountManager *manager,
TpConnectionPresenceType state,
gchar *status,
gchar *status_message,
@@ -279,6 +302,7 @@ idle_finalize (GObject *object)
priv = GET_PRIV (object);
g_free (priv->status);
+ g_free (priv->requested_status_message);
if (priv->gs_proxy) {
g_object_unref (priv->gs_proxy);
@@ -290,6 +314,9 @@ idle_finalize (GObject *object)
g_object_unref (priv->connectivity);
+ g_hash_table_destroy (priv->connect_times);
+ priv->connect_times = NULL;
+
idle_ext_away_stop (EMPATHY_IDLE (object));
}
@@ -421,22 +448,60 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
}
static void
-account_manager_ready_cb (EmpathyAccountManager *account_manager,
- GParamSpec *pspec,
- EmpathyIdle *idle)
+account_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ gpointer user_data)
{
- EmpathyIdlePriv *priv;
+ EmpathyIdle *idle = EMPATHY_IDLE (user_data);
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+ GTimeVal val;
+
+ if (new_status == TP_CONNECTION_STATUS_CONNECTED) {
+ g_get_current_time (&val);
+ g_hash_table_insert (priv->connect_times, account,
+ GINT_TO_POINTER (val.tv_sec));
+ } else if (new_status == TP_CONNECTION_STATUS_DISCONNECTED) {
+ g_hash_table_remove (priv->connect_times, account);
+ }
+}
+
+static void
+account_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EmpathyIdle *idle = EMPATHY_IDLE (user_data);
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
TpConnectionPresenceType state;
gchar *status, *status_message;
+ GList *accounts, *l;
+ GError *error = NULL;
- priv = GET_PRIV (idle);
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- state = empathy_account_manager_get_global_presence (priv->manager,
+ state = tp_account_manager_get_most_available_presence (priv->manager,
&status, &status_message);
idle_presence_changed_cb (account_manager, state, status,
status_message, idle);
+ accounts = tp_account_manager_get_valid_accounts (priv->manager);
+ for (l = accounts; l != NULL; l = l->next) {
+ empathy_signal_connect_weak (l->data, "status-changed",
+ G_CALLBACK (account_status_changed_cb),
+ G_OBJECT (idle));
+ }
+ g_list_free (accounts);
+
g_free (status);
g_free (status_message);
}
@@ -450,18 +515,12 @@ empathy_idle_init (EmpathyIdle *idle)
idle->priv = priv;
priv->is_idle = FALSE;
- priv->manager = empathy_account_manager_dup_singleton ();
-
- if (empathy_account_manager_is_ready (priv->manager)) {
- priv->state = empathy_account_manager_get_global_presence (priv->manager,
- NULL, &priv->status);
- } else {
- g_signal_connect (priv->manager, "notify::ready",
- G_CALLBACK (account_manager_ready_cb), idle);
- }
+ priv->manager = tp_account_manager_dup ();
+ tp_account_manager_prepare_async (priv->manager, NULL,
+ account_manager_ready_cb, idle);
- g_signal_connect (priv->manager, "global-presence-changed",
+ g_signal_connect (priv->manager, "most-available-presence-changed",
G_CALLBACK (idle_presence_changed_cb), idle);
priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
@@ -481,6 +540,8 @@ empathy_idle_init (EmpathyIdle *idle)
priv->connectivity = empathy_connectivity_dup_singleton ();
priv->state_change_signal_id = g_signal_connect (priv->connectivity,
"state-change", G_CALLBACK (idle_state_change_cb), idle);
+
+ priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal);
}
EmpathyIdle *
@@ -567,26 +628,21 @@ empathy_idle_do_set_presence (EmpathyIdle *idle,
const gchar *status_message)
{
EmpathyIdlePriv *priv = GET_PRIV (idle);
- const gchar *statuses[NUM_TP_CONNECTION_PRESENCE_TYPES] = {
- NULL,
- "offline",
- "available",
- "away",
- "xa",
- "hidden",
- "busy",
- NULL,
- NULL,
- };
const gchar *status;
g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES);
- status = statuses[status_type];
+ status = presence_type_to_status[status_type];
g_return_if_fail (status != NULL);
- empathy_account_manager_request_global_presence (priv->manager,
+ /* We possibly should be sure that the account manager is prepared, but
+ * sometimes this isn't possible, like when exiting. In other words,
+ * we need a callback to empathy_idle_set_presence to be sure the
+ * presence is set on all accounts successfully.
+ * However, in practice, this is fine as we've already prepared the
+ * account manager here in _init. */
+ tp_account_manager_set_all_requested_presences (priv->manager,
status_type, status, status_message);
}
@@ -602,6 +658,10 @@ empathy_idle_set_presence (EmpathyIdle *idle,
DEBUG ("Changing presence to %s (%d)", status, state);
+ g_free (priv->requested_status_message);
+ priv->requested_presence_type = state;
+ priv->requested_status_message = g_strdup (status);
+
/* Do not set translated default messages */
default_status = empathy_presence_get_default_message (state);
if (!tp_strdiff (status, default_status)) {
@@ -645,3 +705,50 @@ empathy_idle_set_auto_away (EmpathyIdle *idle,
g_object_notify (G_OBJECT (idle), "auto-away");
}
+TpConnectionPresenceType
+empathy_idle_get_requested_presence (EmpathyIdle *idle,
+ gchar **status,
+ gchar **status_message)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ if (status != NULL) {
+ *status = g_strdup (presence_type_to_status[priv->requested_presence_type]);
+ }
+
+ if (status_message != NULL) {
+ *status_message = g_strdup (priv->requested_status_message);
+ }
+
+ return priv->requested_presence_type;
+}
+
+/* This function returns %TRUE if EmpathyIdle considers the account
+ * @account as having just connected recently. Otherwise, it returns
+ * %FALSE. In doubt, %FALSE is returned. */
+gboolean
+empathy_idle_account_is_just_connected (EmpathyIdle *idle,
+ TpAccount *account)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+ GTimeVal val;
+ gpointer ptr;
+ glong t;
+
+ if (tp_account_get_connection_status (account, NULL)
+ != TP_CONNECTION_STATUS_CONNECTED) {
+ return FALSE;
+ }
+
+ ptr = g_hash_table_lookup (priv->connect_times, account);
+
+ if (ptr == NULL) {
+ return FALSE;
+ }
+
+ t = GPOINTER_TO_INT (ptr);
+
+ g_get_current_time (&val);
+
+ return (val.tv_sec - t) < ACCOUNT_IS_JUST_CONNECTED_SECONDS;
+}
diff --git a/libempathy/empathy-idle.h b/libempathy/empathy-idle.h
index 47dcfee23..1a8c313bc 100644
--- a/libempathy/empathy-idle.h
+++ b/libempathy/empathy-idle.h
@@ -65,6 +65,13 @@ gboolean empathy_idle_get_auto_away (EmpathyIdle *idle);
void empathy_idle_set_auto_away (EmpathyIdle *idle,
gboolean auto_away);
+TpConnectionPresenceType empathy_idle_get_requested_presence (EmpathyIdle *idle,
+ gchar **status,
+ gchar **status_message);
+
+gboolean empathy_idle_account_is_just_connected (EmpathyIdle *idle,
+ TpAccount *account);
+
G_END_DECLS
#endif /* __EMPATHY_IDLE_H__ */
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c
index 309b3b60f..5a57f0c74 100644
--- a/libempathy/empathy-log-manager.c
+++ b/libempathy/empathy-log-manager.c
@@ -158,7 +158,7 @@ empathy_log_manager_add_message (EmpathyLogManager *manager,
gboolean
empathy_log_manager_exists (EmpathyLogManager *manager,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -182,7 +182,7 @@ empathy_log_manager_exists (EmpathyLogManager *manager,
GList *
empathy_log_manager_get_dates (EmpathyLogManager *manager,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -218,7 +218,7 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager,
GList *
empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
const gchar *date)
@@ -259,7 +259,7 @@ log_manager_message_date_cmp (gconstpointer a,
GList *
empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
guint num_messages,
@@ -319,7 +319,7 @@ empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager,
GList *
empathy_log_manager_get_chats (EmpathyLogManager *manager,
- EmpathyAccount *account)
+ TpAccount *account)
{
GList *l, *out = NULL;
EmpathyLogManagerPriv *priv;
diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h
index a67f6e8dd..25f1b5fcd 100644
--- a/libempathy/empathy-log-manager.h
+++ b/libempathy/empathy-log-manager.h
@@ -63,7 +63,7 @@ struct _EmpathyLogManagerClass
struct _EmpathyLogSearchHit
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
gchar *filename;
@@ -79,17 +79,17 @@ gboolean empathy_log_manager_add_message (EmpathyLogManager *manager,
const gchar *chat_id, gboolean chatroom, EmpathyMessage *message,
GError **error);
gboolean empathy_log_manager_exists (EmpathyLogManager *manager,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom);
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
GList *empathy_log_manager_get_dates (EmpathyLogManager *manager,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom);
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
GList *empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
const gchar *date);
GList *empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data);
GList *empathy_log_manager_get_chats (EmpathyLogManager *manager,
- EmpathyAccount *account);
+ TpAccount *account);
GList *empathy_log_manager_search_new (EmpathyLogManager *manager,
const gchar *text);
void empathy_log_manager_search_free (GList *hits);
diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c
index 9771a9f28..8a25df7bc 100644
--- a/libempathy/empathy-log-store-empathy.c
+++ b/libempathy/empathy-log-store-empathy.c
@@ -29,13 +29,13 @@
#include <stdlib.h>
#include <glib/gstdio.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/defs.h>
#include "empathy-log-store.h"
#include "empathy-log-store-empathy.h"
#include "empathy-log-manager.h"
-#include "empathy-account-manager.h"
#include "empathy-contact.h"
#include "empathy-time.h"
#include "empathy-utils.h"
@@ -63,7 +63,7 @@ typedef struct
{
gchar *basedir;
gchar *name;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
} EmpathyLogStoreEmpathyPriv;
static void log_store_iface_init (gpointer g_iface,gpointer iface_data);
@@ -105,15 +105,15 @@ empathy_log_store_empathy_init (EmpathyLogStoreEmpathy *self)
PACKAGE_NAME, "logs", NULL);
priv->name = g_strdup ("Empathy");
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
}
static gchar *
-log_store_account_to_dirname (EmpathyAccount *account)
+log_store_account_to_dirname (TpAccount *account)
{
const gchar *name;
- name = empathy_account_get_unique_name (account);
+ name = tp_proxy_get_object_path (account);
if (g_str_has_prefix (name, TP_ACCOUNT_OBJECT_PATH_BASE))
name += strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
@@ -123,7 +123,7 @@ log_store_account_to_dirname (EmpathyAccount *account)
static gchar *
log_store_empathy_get_dir (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -176,7 +176,7 @@ log_store_empathy_get_timestamp_from_message (EmpathyMessage *message)
static gchar *
log_store_empathy_get_filename (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -202,7 +202,7 @@ log_store_empathy_add_message (EmpathyLogStore *self,
GError **error)
{
FILE *file;
- EmpathyAccount *account;
+ TpAccount *account;
EmpathyContact *sender;
const gchar *body_str;
const gchar *str;
@@ -289,7 +289,7 @@ log_store_empathy_add_message (EmpathyLogStore *self,
static gboolean
log_store_empathy_exists (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -305,7 +305,7 @@ log_store_empathy_exists (EmpathyLogStore *self,
static GList *
log_store_empathy_get_dates (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -357,7 +357,7 @@ log_store_empathy_get_dates (EmpathyLogStore *self,
static gchar *
log_store_empathy_get_filename_for_date (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
const gchar *date)
@@ -406,11 +406,13 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self,
else
account_name = strv[len-3];
- accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+ /* FIXME: This assumes the account manager is prepared, but the
+ * synchronous API forces this. See bug #599189. */
+ accounts = tp_account_manager_get_valid_accounts (priv->account_manager);
for (l = accounts; l != NULL; l = g_list_next (l))
{
- EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+ TpAccount *account = TP_ACCOUNT (l->data);
gchar *name;
name = log_store_account_to_dirname (account);
@@ -434,7 +436,7 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self,
static GList *
log_store_empathy_get_messages_for_file (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *filename)
{
GList *messages = NULL;
@@ -703,7 +705,7 @@ log_store_empathy_get_chats_for_dir (EmpathyLogStore *self,
static GList *
log_store_empathy_get_messages_for_date (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
const gchar *date)
@@ -726,7 +728,7 @@ log_store_empathy_get_messages_for_date (EmpathyLogStore *self,
static GList *
log_store_empathy_get_chats (EmpathyLogStore *self,
- EmpathyAccount *account)
+ TpAccount *account)
{
gchar *dir;
GList *hits;
@@ -753,7 +755,7 @@ log_store_empathy_get_name (EmpathyLogStore *self)
static GList *
log_store_empathy_get_filtered_messages (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
guint num_messages,
diff --git a/libempathy/empathy-log-store.c b/libempathy/empathy-log-store.c
index f136f7910..512c4c09b 100644
--- a/libempathy/empathy-log-store.c
+++ b/libempathy/empathy-log-store.c
@@ -55,7 +55,7 @@ empathy_log_store_get_name (EmpathyLogStore *self)
gboolean
empathy_log_store_exists (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -84,7 +84,7 @@ empathy_log_store_add_message (EmpathyLogStore *self,
GList *
empathy_log_store_get_dates (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -97,7 +97,7 @@ empathy_log_store_get_dates (EmpathyLogStore *self,
GList *
empathy_log_store_get_messages_for_date (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
const gchar *date)
@@ -111,7 +111,7 @@ empathy_log_store_get_messages_for_date (EmpathyLogStore *self,
GList *
empathy_log_store_get_last_messages (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom)
{
@@ -124,7 +124,7 @@ empathy_log_store_get_last_messages (EmpathyLogStore *self,
GList *
empathy_log_store_get_chats (EmpathyLogStore *self,
- EmpathyAccount *account)
+ TpAccount *account)
{
if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats)
return NULL;
@@ -157,7 +157,7 @@ empathy_log_store_ack_message (EmpathyLogStore *self,
GList *
empathy_log_store_get_filtered_messages (EmpathyLogStore *self,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
guint num_messages,
diff --git a/libempathy/empathy-log-store.h b/libempathy/empathy-log-store.h
index 5b6a87875..94bc87386 100644
--- a/libempathy/empathy-log-store.h
+++ b/libempathy/empathy-log-store.h
@@ -25,7 +25,7 @@
#include <glib-object.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
#include "empathy-message.h"
#include "empathy-log-manager.h"
@@ -50,23 +50,23 @@ struct _EmpathyLogStoreInterface
GTypeInterface parent;
const gchar * (*get_name) (EmpathyLogStore *self);
- gboolean (*exists) (EmpathyLogStore *self, EmpathyAccount *account,
+ gboolean (*exists) (EmpathyLogStore *self, TpAccount *account,
const gchar *chat_id, gboolean chatroom);
gboolean (*add_message) (EmpathyLogStore *self, const gchar *chat_id,
gboolean chatroom, EmpathyMessage *message, GError **error);
- GList * (*get_dates) (EmpathyLogStore *self, EmpathyAccount *account,
+ GList * (*get_dates) (EmpathyLogStore *self, TpAccount *account,
const gchar *chat_id, gboolean chatroom);
GList * (*get_messages_for_date) (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
const gchar *date);
- GList * (*get_last_messages) (EmpathyLogStore *self, EmpathyAccount *account,
+ GList * (*get_last_messages) (EmpathyLogStore *self, TpAccount *account,
const gchar *chat_id, gboolean chatroom);
GList * (*get_chats) (EmpathyLogStore *self,
- EmpathyAccount *account);
+ TpAccount *account);
GList * (*search_new) (EmpathyLogStore *self, const gchar *text);
void (*ack_message) (EmpathyLogStore *self, const gchar *chat_id,
gboolean chatroom, EmpathyMessage *message);
- GList * (*get_filtered_messages) (EmpathyLogStore *self, EmpathyAccount *account,
+ GList * (*get_filtered_messages) (EmpathyLogStore *self, TpAccount *account,
const gchar *chat_id, gboolean chatroom, guint num_messages,
EmpathyLogMessageFilter filter, gpointer user_data);
};
@@ -75,25 +75,25 @@ GType empathy_log_store_get_type (void) G_GNUC_CONST;
const gchar *empathy_log_store_get_name (EmpathyLogStore *self);
gboolean empathy_log_store_exists (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom);
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
gboolean empathy_log_store_add_message (EmpathyLogStore *self,
const gchar *chat_id, gboolean chatroom, EmpathyMessage *message,
GError **error);
GList *empathy_log_store_get_dates (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom);
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
GList *empathy_log_store_get_messages_for_date (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
const gchar *date);
GList *empathy_log_store_get_last_messages (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom);
+ TpAccount *account, const gchar *chat_id, gboolean chatroom);
GList *empathy_log_store_get_chats (EmpathyLogStore *self,
- EmpathyAccount *account);
+ TpAccount *account);
GList *empathy_log_store_search_new (EmpathyLogStore *self,
const gchar *text);
void empathy_log_store_ack_message (EmpathyLogStore *self,
const gchar *chat_id, gboolean chatroom, EmpathyMessage *message);
GList *empathy_log_store_get_filtered_messages (EmpathyLogStore *self,
- EmpathyAccount *account, const gchar *chat_id, gboolean chatroom,
+ TpAccount *account, const gchar *chat_id, gboolean chatroom,
guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data);
G_END_DECLS
diff --git a/libempathy/empathy-tp-roomlist.c b/libempathy/empathy-tp-roomlist.c
index 54d232339..2e95f3957 100644
--- a/libempathy/empathy-tp-roomlist.c
+++ b/libempathy/empathy-tp-roomlist.c
@@ -28,8 +28,6 @@
#include <telepathy-glib/util.h>
#include <telepathy-glib/interfaces.h>
-#include "empathy-account.h"
-
#include "empathy-tp-roomlist.h"
#include "empathy-chatroom.h"
#include "empathy-utils.h"
@@ -41,7 +39,7 @@
typedef struct {
TpConnection *connection;
TpChannel *channel;
- EmpathyAccount *account;
+ TpAccount *account;
gboolean is_listing;
gboolean start_requested;
} EmpathyTpRoomlistPriv;
@@ -354,7 +352,7 @@ tp_roomlist_constructed (GObject *list)
{
EmpathyTpRoomlistPriv *priv = GET_PRIV (list);
- priv->connection = empathy_account_get_connection (priv->account);
+ priv->connection = tp_account_get_connection (priv->account);
g_object_ref (priv->connection);
tp_cli_connection_call_request_channel (priv->connection, -1,
@@ -421,7 +419,7 @@ empathy_tp_roomlist_class_init (EmpathyTpRoomlistClass *klass)
g_param_spec_object ("account",
"The Account",
"The account on which it lists rooms",
- EMPATHY_TYPE_ACCOUNT,
+ TP_TYPE_ACCOUNT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
@@ -477,7 +475,7 @@ empathy_tp_roomlist_init (EmpathyTpRoomlist *list)
}
EmpathyTpRoomlist *
-empathy_tp_roomlist_new (EmpathyAccount *account)
+empathy_tp_roomlist_new (TpAccount *account)
{
EmpathyTpRoomlist *list;
diff --git a/libempathy/empathy-tp-roomlist.h b/libempathy/empathy-tp-roomlist.h
index 801e5c69f..f400766a9 100644
--- a/libempathy/empathy-tp-roomlist.h
+++ b/libempathy/empathy-tp-roomlist.h
@@ -24,8 +24,8 @@
#include <glib.h>
+#include <telepathy-glib/account.h>
#include <telepathy-glib/connection.h>
-#include <libempathy/empathy-account.h>
G_BEGIN_DECLS
@@ -49,7 +49,7 @@ struct _EmpathyTpRoomlistClass {
};
GType empathy_tp_roomlist_get_type (void) G_GNUC_CONST;
-EmpathyTpRoomlist *empathy_tp_roomlist_new (EmpathyAccount *account);
+EmpathyTpRoomlist *empathy_tp_roomlist_new (TpAccount *account);
gboolean empathy_tp_roomlist_is_listing (EmpathyTpRoomlist *list);
void empathy_tp_roomlist_start (EmpathyTpRoomlist *list);
void empathy_tp_roomlist_stop (EmpathyTpRoomlist *list);
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index a0cb4111e..21b0599c8 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003-2007 Imendio AB
* Copyright (C) 2007-2008 Collabora Ltd.
@@ -32,6 +31,8 @@
#include <glib/gi18n-lib.h>
#include <libxml/uri.h>
+
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/channel.h>
#include <telepathy-glib/dbus.h>
@@ -490,3 +491,67 @@ empathy_signal_connect_weak (gpointer instance,
g_object_weak_ref (instance_obj, instance_destroyed_cb, ctx);
g_object_weak_ref (user_data, user_data_destroyed_cb, ctx);
}
+
+/* Note: this function depends on the account manager having its core feature
+ * prepared. */
+TpAccount *
+empathy_get_account_for_connection (TpConnection *connection)
+{
+ TpAccountManager *manager;
+ TpAccount *account = NULL;
+ GList *accounts, *l;
+
+ manager = tp_account_manager_dup ();
+
+ accounts = tp_account_manager_get_valid_accounts (manager);
+
+ for (l = accounts; l != NULL; l = l->next)
+ {
+ TpAccount *a = l->data;
+
+ if (tp_account_get_connection (a) == connection)
+ {
+ account = a;
+ break;
+ }
+ }
+
+ g_list_free (accounts);
+ g_object_unref (manager);
+
+ return account;
+}
+
+gboolean
+empathy_account_manager_get_accounts_connected (gboolean *connecting)
+{
+ TpAccountManager *manager;
+ GList *accounts, *l;
+ gboolean out_connecting = FALSE;
+ gboolean out_connected = FALSE;
+
+ manager = tp_account_manager_dup ();
+ accounts = tp_account_manager_get_valid_accounts (manager);
+
+ for (l = accounts; l != NULL; l = l->next)
+ {
+ TpConnectionStatus s = tp_account_get_connection_status (
+ TP_ACCOUNT (l->data), NULL);
+
+ if (s == TP_CONNECTION_STATUS_CONNECTING)
+ out_connecting = TRUE;
+ else if (s == TP_CONNECTION_STATUS_CONNECTED)
+ out_connected = TRUE;
+
+ if (out_connecting && out_connected)
+ break;
+ }
+
+ g_list_free (accounts);
+ g_object_unref (manager);
+
+ if (connecting != NULL)
+ *connecting = out_connecting;
+
+ return out_connected;
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index d62e096ae..97e5e85b7 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -85,6 +85,10 @@ void empathy_signal_connect_weak (gpointer instance,
GCallback c_handler,
GObject *user_data);
+TpAccount * empathy_get_account_for_connection (TpConnection *connection);
+
+gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
+
G_END_DECLS
#endif /* __EMPATHY_UTILS_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fdb074483..6af70385d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,7 +4,6 @@
data/empathy.desktop.in.in
data/empathy.schemas.in
-libempathy/empathy-account.c
libempathy/empathy-ft-handler.c
libempathy/empathy-tp-contact-list.c
libempathy/empathy-tp-file.c
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index d9834f38b..08cf025d3 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -225,7 +225,7 @@ account_assistant_account_enabled_cb (GObject *source,
EmpathyAccountAssistant *self = user_data;
EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
- empathy_account_set_enabled_finish (EMPATHY_ACCOUNT (source),
+ tp_account_set_enabled_finish (TP_ACCOUNT (source),
result, &error);
if (error)
@@ -249,7 +249,7 @@ account_assistant_apply_account_cb (GObject *source,
EmpathyAccountAssistant *self = user_data;
EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
- EmpathyAccount *account;
+ TpAccount *account;
empathy_account_settings_apply_finish (settings, result, &error);
@@ -265,7 +265,7 @@ account_assistant_apply_account_cb (GObject *source,
/* enable the newly created account */
account = empathy_account_settings_get_account (settings);
- empathy_account_set_enabled_async (account, TRUE,
+ tp_account_set_enabled_async (account, TRUE,
account_assistant_account_enabled_cb, self);
}
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index e877e632f..460ea9023 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -32,10 +32,10 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-connection-managers.h>
#include <libempathy-gtk/empathy-ui-utils.h>
@@ -107,11 +107,11 @@ typedef struct {
gulong settings_ready_id;
EmpathyAccountSettings *settings_ready;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
EmpathyConnectionManagers *cms;
GtkWindow *parent_window;
- EmpathyAccount *initial_selection;
+ TpAccount *initial_selection;
/* Those are needed when changing the selected row. When a user selects
* another account and there are unsaved changes on the currently selected
@@ -146,9 +146,6 @@ static gboolean accounts_dialog_get_settings_iter (
static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_update (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings);
-
static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings);
@@ -175,7 +172,7 @@ empathy_account_dialog_widget_cancelled_cb (
GtkTreeSelection *selection;
GtkTreeIter iter;
EmpathyAccountSettings *settings;
- EmpathyAccount *account;
+ TpAccount *account;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
view = GTK_TREE_VIEW (priv->treeview);
@@ -354,7 +351,7 @@ accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog)
static gboolean
accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog,
- EmpathyAccount **account)
+ TpAccount **account)
{
GtkTreeIter iter;
GtkTreeModel *model;
@@ -502,13 +499,13 @@ static void
accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account = NULL;
+ TpAccount *account = NULL;
if (accounts_dialog_has_pending_change (dialog, &account))
{
gchar *question_dialog_primary_text = g_strdup_printf (
PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- empathy_account_get_display_name (account));
+ tp_account_get_display_name (account));
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,
@@ -708,9 +705,11 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
GtkTreePath *treepath;
GtkTreeIter iter;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ gboolean connecting;
- if (empathy_account_manager_get_connecting_accounts
- (priv->account_manager) > 0)
+ empathy_account_manager_get_accounts_connected (&connecting);
+
+ if (connecting)
{
priv->connecting_id = g_timeout_add (FLASH_TIMEOUT,
(GSourceFunc) accounts_dialog_flash_connecting_cb,
@@ -739,7 +738,7 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
gint response_id,
gpointer user_data)
{
- EmpathyAccount *account;
+ TpAccount *account;
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *selection;
@@ -757,7 +756,7 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
if (account != NULL)
{
- empathy_account_remove_async (account, NULL, NULL);
+ tp_account_remove_async (account, NULL, NULL);
g_object_unref (account);
account = NULL;
}
@@ -774,7 +773,7 @@ accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
const gchar *path_string,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account;
+ TpAccount *account;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *question_dialog_primary_text;
@@ -787,7 +786,7 @@ accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
- if (account == NULL || !empathy_account_is_valid (account))
+ if (account == NULL || !tp_account_is_valid (account))
{
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
accounts_dialog_model_select_first (dialog);
@@ -802,7 +801,7 @@ accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
/* Translators: this is used only when built on a moblin platform */
_("Do you want to remove %s from your computer?"),
#endif /* HAVE_MOBLIN */
- empathy_account_get_display_name (account));
+ tp_account_get_display_name (account));
accounts_dialog_show_question_dialog (dialog, question_dialog_primary_text,
#ifndef HAVE_MOBLIN
@@ -977,7 +976,7 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
gboolean path_currently_selected,
gpointer data)
{
- EmpathyAccount *account = NULL;
+ TpAccount *account = NULL;
EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (data);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
@@ -1000,7 +999,7 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
question_dialog_primary_text = g_strdup_printf (
PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- empathy_account_get_display_name (account));
+ tp_account_get_display_name (account));
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,
@@ -1031,7 +1030,7 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
store = gtk_list_store_new (COL_COUNT,
G_TYPE_STRING, /* name */
G_TYPE_UINT, /* status */
- EMPATHY_TYPE_ACCOUNT, /* account */
+ TP_TYPE_ACCOUNT, /* account */
EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
@@ -1093,7 +1092,7 @@ accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog,
static gboolean
accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account,
+ TpAccount *account,
GtkTreeIter *iter)
{
GtkTreeView *view;
@@ -1162,11 +1161,12 @@ accounts_dialog_add (EmpathyAccountsDialog *dialog,
}
static void
-accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
+accounts_dialog_connection_changed_cb (TpAccount *account,
+ guint old_status,
+ guint current,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyAccountsDialog *dialog)
{
GtkTreeModel *model;
@@ -1190,7 +1190,7 @@ accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
gtk_tree_path_free (path);
}
- found = (empathy_account_manager_get_connecting_accounts (manager) > 0);
+ empathy_account_manager_get_accounts_connected (&found);
if (!found && priv->connecting_id)
{
@@ -1205,7 +1205,7 @@ accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
}
static void
-accounts_dialog_account_display_name_changed_cb (EmpathyAccount *account,
+accounts_dialog_account_display_name_changed_cb (TpAccount *account,
GParamSpec *pspec,
gpointer user_data)
{
@@ -1213,11 +1213,11 @@ accounts_dialog_account_display_name_changed_cb (EmpathyAccount *account,
GtkTreeIter iter;
GtkTreeModel *model;
EmpathyAccountSettings *settings;
- EmpathyAccount *selected_account;
+ TpAccount *selected_account;
EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- display_name = empathy_account_get_display_name (account);
+ display_name = tp_account_get_display_name (account);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
settings = accounts_dialog_model_get_selected_settings (dialog);
if (settings == NULL)
@@ -1240,7 +1240,7 @@ accounts_dialog_account_display_name_changed_cb (EmpathyAccount *account,
static void
accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+ TpAccount *account)
{
EmpathyAccountSettings *settings;
GtkTreeModel *model;
@@ -1251,9 +1251,9 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
- g_object_get (account, "connection-status", &status, NULL);
- name = empathy_account_get_display_name (account);
- enabled = empathy_account_is_enabled (account);
+ status = tp_account_get_connection_status (account, NULL);
+ name = tp_account_get_display_name (account);
+ enabled = tp_account_is_enabled (account);
settings = empathy_account_settings_new_for_account (account);
@@ -1267,11 +1267,12 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
COL_ACCOUNT_SETTINGS_POINTER, settings,
-1);
- accounts_dialog_connection_changed_cb (priv->account_manager,
- account,
- TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
+ accounts_dialog_connection_changed_cb (account,
+ 0,
status,
TP_CONNECTION_STATUS_DISCONNECTED,
+ NULL,
+ NULL,
dialog);
empathy_signal_connect_weak (account, "notify::display-name",
@@ -1282,48 +1283,16 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
}
static void
-accounts_dialog_update (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- TpConnectionStatus status = TP_CONNECTION_STATUS_DISCONNECTED;
- const gchar *name;
- gboolean enabled = FALSE;
- EmpathyAccount *account;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
- name = empathy_account_settings_get_display_name (settings);
-
- account = empathy_account_settings_get_account (settings);
- if (account != NULL)
- {
- enabled = empathy_account_is_enabled (account);
- g_object_get (account, "connection-status", &status, NULL);
- }
-
- accounts_dialog_get_settings_iter (dialog, settings, &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_NAME, name,
- COL_STATUS, status,
- COL_ACCOUNT_POINTER, account,
- COL_ACCOUNT_SETTINGS_POINTER, settings,
- -1);
-}
-
-static void
-accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+accounts_dialog_account_validity_changed_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountsDialog *dialog)
{
accounts_dialog_add_account (dialog, account);
}
-
static void
-accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+accounts_dialog_account_removed_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountsDialog *dialog)
{
GtkTreeIter iter;
@@ -1338,7 +1307,7 @@ accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
static void
enable_or_disable_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account,
+ TpAccount *account,
gboolean enabled)
{
GtkTreeModel *model;
@@ -1348,60 +1317,27 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
DEBUG ("Account %s is now %s",
- empathy_account_get_display_name (account),
+ tp_account_get_display_name (account),
enabled ? "enabled" : "disabled");
}
static void
-accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+accounts_dialog_account_disabled_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountsDialog *dialog)
{
enable_or_disable_account (dialog, account, FALSE);
}
static void
-accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
+accounts_dialog_account_enabled_cb (TpAccountManager *manager,
+ TpAccount *account,
EmpathyAccountsDialog *dialog)
{
enable_or_disable_account (dialog, account, TRUE);
}
static void
-accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
-{
- EmpathyAccountSettings *settings, *selected_settings;
- GtkTreeModel *model;
- GtkTreeIter iter;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
-
- if (!accounts_dialog_get_account_iter (dialog, account, &iter))
- return;
-
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_SETTINGS_POINTER, &settings,
- -1);
-
- accounts_dialog_update (dialog, settings);
- selected_settings = accounts_dialog_model_get_selected_settings (dialog);
-
- if (settings == selected_settings)
- accounts_dialog_update_name_label (dialog,
- empathy_account_settings_get_display_name (settings));
-
- if (settings)
- g_object_unref (settings);
-
- if (selected_settings)
- g_object_unref (selected_settings);
-}
-
-static void
accounts_dialog_button_create_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
@@ -1504,14 +1440,14 @@ accounts_dialog_response_cb (GtkWidget *widget,
gint response,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account = NULL;
+ TpAccount *account = NULL;
if (accounts_dialog_has_pending_change (dialog, &account))
{
gchar *question_dialog_primary_text;
question_dialog_primary_text = g_strdup_printf (
PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- empathy_account_get_display_name (account));
+ tp_account_get_display_name (account));
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,
@@ -1549,7 +1485,7 @@ accounts_dialog_destroy_cb (GtkObject *obj,
static void
accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+ TpAccount *account)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
@@ -1587,10 +1523,10 @@ accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
GList *accounts, *l;
- g_signal_connect (priv->account_manager, "account-created",
- G_CALLBACK (accounts_dialog_account_added_cb),
+ g_signal_connect (priv->account_manager, "account-validity-changed",
+ G_CALLBACK (accounts_dialog_account_validity_changed_cb),
dialog);
- g_signal_connect (priv->account_manager, "account-deleted",
+ g_signal_connect (priv->account_manager, "account-removed",
G_CALLBACK (accounts_dialog_account_removed_cb),
dialog);
g_signal_connect (priv->account_manager, "account-enabled",
@@ -1599,19 +1535,15 @@ accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
g_signal_connect (priv->account_manager, "account-disabled",
G_CALLBACK (accounts_dialog_account_disabled_cb),
dialog);
- g_signal_connect (priv->account_manager, "account-changed",
- G_CALLBACK (accounts_dialog_account_changed_cb),
- dialog);
- g_signal_connect (priv->account_manager, "account-connection-changed",
- G_CALLBACK (accounts_dialog_connection_changed_cb),
- dialog);
/* Add existing accounts */
- accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+ accounts = tp_account_manager_get_valid_accounts (priv->account_manager);
for (l = accounts; l; l = l->next)
{
accounts_dialog_add_account (dialog, l->data);
- g_object_unref (l->data);
+
+ empathy_signal_connect_weak (l->data, "status-changed",
+ G_CALLBACK (accounts_dialog_connection_changed_cb), G_OBJECT (dialog));
}
g_list_free (accounts);
@@ -1624,12 +1556,19 @@ accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
}
static void
-accounts_dialog_manager_ready_cb (EmpathyAccountManager *manager,
- GParamSpec *pspec,
+accounts_dialog_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
- if (!empathy_account_manager_is_ready (manager))
- return;
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ 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;
+ }
accounts_dialog_accounts_setup (user_data);
}
@@ -1709,7 +1648,7 @@ do_dispose (GObject *obj)
/* Disconnect signals */
g_signal_handlers_disconnect_by_func (priv->account_manager,
- accounts_dialog_account_added_cb,
+ accounts_dialog_account_validity_changed_cb,
dialog);
g_signal_handlers_disconnect_by_func (priv->account_manager,
accounts_dialog_account_removed_cb,
@@ -1721,12 +1660,6 @@ do_dispose (GObject *obj)
accounts_dialog_account_disabled_cb,
dialog);
g_signal_handlers_disconnect_by_func (priv->account_manager,
- accounts_dialog_account_changed_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- accounts_dialog_connection_changed_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (priv->account_manager,
accounts_dialog_manager_ready_cb,
dialog);
@@ -1827,13 +1760,10 @@ do_constructed (GObject *object)
accounts_dialog_model_setup (dialog);
/* Set up signalling */
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
- if (!empathy_account_manager_is_ready (priv->account_manager))
- g_signal_connect (priv->account_manager, "notify::ready",
- G_CALLBACK (accounts_dialog_manager_ready_cb), dialog);
- else
- accounts_dialog_accounts_setup (dialog);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ accounts_dialog_manager_ready_cb, dialog);
empathy_conf_get_bool (empathy_conf_get (),
EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
@@ -1891,7 +1821,7 @@ empathy_accounts_dialog_init (EmpathyAccountsDialog *dialog)
GtkWidget *
empathy_accounts_dialog_show (GtkWindow *parent,
- EmpathyAccount *selected_account)
+ TpAccount *selected_account)
{
EmpathyAccountsDialog *dialog;
EmpathyAccountsDialogPriv *priv;
diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h
index aa8f7c06b..2d9d60c2b 100644
--- a/src/empathy-accounts-dialog.h
+++ b/src/empathy-accounts-dialog.h
@@ -26,7 +26,7 @@
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
G_BEGIN_DECLS
@@ -55,7 +55,7 @@ typedef struct {
GType empathy_accounts_dialog_get_type (void);
GtkWidget *empathy_accounts_dialog_show (GtkWindow *parent,
- EmpathyAccount *selected_account);
+ TpAccount *selected_account);
G_END_DECLS
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 7b81d7a43..69469815e 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -35,13 +35,13 @@
#include <glib/gi18n.h>
#include <libnotify/notification.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-images.h>
@@ -434,7 +434,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
EmpathyContact *remote_contact;
const gchar *name;
const gchar *id;
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *subject;
const gchar *status = NULL;
GtkWidget *widget;
@@ -457,7 +457,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
remote_contact = empathy_chat_get_remote_contact (chat);
DEBUG ("Updating chat tab, name=%s, account=%s, subject=%s, remote_contact=%p",
- name, empathy_account_get_unique_name (account), subject, remote_contact);
+ name, tp_proxy_get_object_path (account), subject, remote_contact);
/* Update tab image */
if (empathy_chat_get_tp_chat (chat) == NULL) {
@@ -501,7 +501,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
append_markup_printf (tooltip,
"<b>%s</b><small> (%s)</small>",
id,
- empathy_account_get_display_name (account));
+ tp_account_get_display_name (account));
if (!EMP_STR_EMPTY (status)) {
append_markup_printf (tooltip, "\n<i>%s</i>", status);
@@ -596,7 +596,7 @@ chat_window_conv_activate_cb (GtkAction *action,
is_room = empathy_chat_is_room (priv->current_chat);
if (is_room) {
const gchar *room;
- EmpathyAccount *account;
+ TpAccount *account;
gboolean found = FALSE;
EmpathyChatroom *chatroom;
@@ -645,7 +645,7 @@ chat_window_favorite_toggled_cb (GtkToggleAction *toggle_action,
{
EmpathyChatWindowPriv *priv = GET_PRIV (window);
gboolean active;
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *room;
EmpathyChatroom *chatroom;
@@ -1346,15 +1346,18 @@ chat_window_drag_data_received (GtkWidget *widget,
if (info == DND_DRAG_TYPE_CONTACT_ID) {
EmpathyChat *chat = NULL;
EmpathyChatWindow *old_window;
- EmpathyAccount *account = NULL;
- EmpathyAccountManager *account_manager;
+ TpAccount *account = NULL;
+ TpAccountManager *account_manager;
const gchar *id;
gchar **strv;
const gchar *account_id;
const gchar *contact_id;
id = (const gchar*) gtk_selection_data_get_data (selection);
- account_manager = empathy_account_manager_dup_singleton ();
+
+ /* FIXME: Perhaps should be sure that the account manager is
+ * prepared before calling _ensure_account on it. */
+ account_manager = tp_account_manager_dup ();
DEBUG ("DND contact from roster with id:'%s'", id);
@@ -1363,7 +1366,7 @@ chat_window_drag_data_received (GtkWidget *widget,
account_id = strv[0];
contact_id = strv[1];
account =
- empathy_account_manager_get_account (account_manager, account_id);
+ tp_account_manager_ensure_account (account_manager, account_id);
if (account != NULL)
chat = empathy_chat_window_find_chat (account, contact_id);
}
@@ -1377,7 +1380,7 @@ chat_window_drag_data_received (GtkWidget *widget,
if (!chat) {
TpConnection *connection;
- connection = empathy_account_get_connection (account);
+ connection = tp_account_get_connection (account);
if (connection) {
empathy_dispatcher_chat_with_contact_id (
@@ -1855,7 +1858,7 @@ empathy_chat_window_has_focus (EmpathyChatWindow *window)
}
EmpathyChat *
-empathy_chat_window_find_chat (EmpathyAccount *account,
+empathy_chat_window_find_chat (TpAccount *account,
const gchar *id)
{
GList *l;
diff --git a/src/empathy-chat-window.h b/src/empathy-chat-window.h
index 6f3d21fca..1e4a001e5 100644
--- a/src/empathy-chat-window.h
+++ b/src/empathy-chat-window.h
@@ -31,7 +31,8 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
+
#include <libempathy-gtk/empathy-chat.h>
G_BEGIN_DECLS
@@ -69,7 +70,7 @@ void empathy_chat_window_move_chat (EmpathyChatWindow *old_wi
void empathy_chat_window_switch_to_chat (EmpathyChatWindow *window,
EmpathyChat *chat);
gboolean empathy_chat_window_has_focus (EmpathyChatWindow *window);
-EmpathyChat * empathy_chat_window_find_chat (EmpathyAccount *account,
+EmpathyChat * empathy_chat_window_find_chat (TpAccount *account,
const gchar *id);
void empathy_chat_window_present_chat (EmpathyChat *chat);
diff --git a/src/empathy-chatrooms-window.c b/src/empathy-chatrooms-window.c
index 4ec71ec49..278a1d686 100644
--- a/src/empathy-chatrooms-window.c
+++ b/src/empathy-chatrooms-window.c
@@ -308,7 +308,7 @@ chatrooms_window_model_refresh_data (EmpathyChatroomsWindow *window,
GtkTreeIter iter;
GtkTreeViewColumn *column;
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
GList *chatrooms, *l;
view = GTK_TREE_VIEW (window->treeview);
@@ -506,7 +506,7 @@ chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager,
EmpathyChatroomsWindow *window)
{
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser);
account = empathy_account_chooser_dup_account (account_chooser);
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index c68458d69..f3eb2992d 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -24,11 +24,12 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/interfaces.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-tp-chat.h>
@@ -918,13 +919,16 @@ event_manager_presence_changed_cb (EmpathyContactMonitor *monitor,
TpConnectionPresenceType previous,
EmpathyEventManager *manager)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *header = NULL;
gboolean preference = FALSE;
+ EmpathyIdle *idle;
account = empathy_contact_get_account (contact);
- if (empathy_account_is_just_connected (account))
- return;
+ idle = empathy_idle_dup_singleton ();
+
+ if (empathy_idle_account_is_just_connected (idle, account))
+ goto out;
if (tp_connection_presence_type_cmp_availability (previous,
TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
@@ -960,6 +964,9 @@ event_manager_presence_changed_cb (EmpathyContactMonitor *monitor,
}
}
g_free (header);
+
+out:
+ g_object_unref (idle);
}
diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c
index 0a72c4929..b4bca6fdb 100644
--- a/src/empathy-import-mc4-accounts.c
+++ b/src/empathy-import-mc4-accounts.c
@@ -24,11 +24,11 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/defs.h>
#include <dbus/dbus-protocol.h>
#include <gnome-keyring.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-account-settings.h>
#include <libempathy/empathy-connection-managers.h>
@@ -189,12 +189,12 @@ _move_contents (const gchar *old, const gchar *new)
}
static void
-_move_logs (EmpathyAccount *account, const gchar *account_name)
+_move_logs (TpAccount *account, const gchar *account_name)
{
gchar *old_path, *new_path, *escaped;
const gchar *name;
- name = empathy_account_get_unique_name (account);
+ name = tp_proxy_get_object_path (account);
if (g_str_has_prefix (name, TP_ACCOUNT_OBJECT_PATH_BASE))
name += strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
@@ -215,7 +215,7 @@ _create_account_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
- EmpathyAccount *account;
+ TpAccount *account;
GError *error = NULL;
Misc *misc = (Misc *) user_data;
@@ -233,7 +233,7 @@ _create_account_cb (GObject *source,
_move_logs (account, misc->account_name);
- empathy_account_set_enabled_async (account,
+ tp_account_set_enabled_async (account,
misc->enable, NULL, NULL);
g_free (misc->account_name);
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));
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 83daac08d..a2f9dde13 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -27,9 +27,11 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-contact.h>
+#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-chatroom.h>
@@ -79,7 +81,7 @@
typedef struct {
EmpathyContactListView *list_view;
EmpathyContactListStore *list_store;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyEventManager *event_manager;
guint flash_timeout_id;
@@ -305,7 +307,7 @@ static void
main_window_error_edit_clicked_cb (GtkButton *button,
EmpathyMainWindow *window)
{
- EmpathyAccount *account;
+ TpAccount *account;
GtkWidget *error_widget;
account = g_object_get_data (G_OBJECT (button), "account");
@@ -320,7 +322,7 @@ static void
main_window_error_clear_clicked_cb (GtkButton *button,
EmpathyMainWindow *window)
{
- EmpathyAccount *account;
+ TpAccount *account;
GtkWidget *error_widget;
account = g_object_get_data (G_OBJECT (button), "account");
@@ -331,7 +333,7 @@ main_window_error_clear_clicked_cb (GtkButton *button,
static void
main_window_error_display (EmpathyMainWindow *window,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *message)
{
GtkWidget *child;
@@ -352,7 +354,7 @@ main_window_error_display (EmpathyMainWindow *window,
/* Just set the latest error and return */
str = g_markup_printf_escaped ("<b>%s</b>\n%s",
- empathy_account_get_display_name (account),
+ tp_account_get_display_name (account),
message);
gtk_label_set_markup (GTK_LABEL (label), str);
g_free (str);
@@ -433,7 +435,7 @@ main_window_error_display (EmpathyMainWindow *window,
gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
str = g_markup_printf_escaped ("<b>%s</b>\n%s",
- empathy_account_get_display_name (account),
+ tp_account_get_display_name (account),
message);
gtk_label_set_markup (GTK_LABEL (label), str);
g_free (str);
@@ -460,18 +462,15 @@ main_window_error_display (EmpathyMainWindow *window,
}
static void
-main_window_update_status (EmpathyMainWindow *window, EmpathyAccountManager *manager)
+main_window_update_status (EmpathyMainWindow *window)
{
- int connected;
- int connecting;
+ gboolean connected, connecting;
GList *l;
- /* Count number of connected/connecting/disconnected accounts */
- connected = empathy_account_manager_get_connected_accounts (manager);
- connecting = empathy_account_manager_get_connecting_accounts (manager);
+ connected = empathy_account_manager_get_accounts_connected (&connecting);
/* Update the spinner state */
- if (connecting > 0) {
+ if (connecting) {
ephy_spinner_start (EPHY_SPINNER (window->throbber));
} else {
ephy_spinner_stop (EPHY_SPINNER (window->throbber));
@@ -479,19 +478,20 @@ main_window_update_status (EmpathyMainWindow *window, EmpathyAccountManager *man
/* Update widgets sensibility */
for (l = window->actions_connected; l; l = l->next) {
- gtk_action_set_sensitive (l->data, (connected > 0));
+ gtk_action_set_sensitive (l->data, connected);
}
}
static void
-main_window_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
+main_window_connection_changed_cb (TpAccount *account,
+ guint old_status,
+ guint current,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyMainWindow *window)
{
- main_window_update_status (window, manager);
+ main_window_update_status (window);
if (current == TP_CONNECTION_STATUS_DISCONNECTED &&
reason != TP_CONNECTION_STATUS_REASON_REQUESTED) {
@@ -572,15 +572,17 @@ main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
TpConnectionPresenceType previous,
EmpathyMainWindow *window)
{
- EmpathyAccount *account;
- gboolean should_play;
+ TpAccount *account;
+ gboolean should_play = FALSE;
+ EmpathyIdle *idle;
- account = empathy_contact_get_account (contact);
- should_play = !empathy_account_is_just_connected (account);
+ account = empathy_contact_get_account (contact);
+ idle = empathy_idle_dup_singleton ();
- if (!should_play) {
- return;
- }
+ should_play = !empathy_idle_account_is_just_connected (idle, account);
+
+ if (!should_play)
+ goto out;
if (tp_connection_presence_type_cmp_availability (previous,
TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
@@ -601,6 +603,9 @@ main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
empathy_sound_play (GTK_WIDGET (window->window),
EMPATHY_SOUND_CONTACT_CONNECTED);
}
+
+out:
+ g_object_unref (idle);
}
static void
@@ -641,10 +646,6 @@ main_window_destroy_cb (GtkWidget *widget,
/* Save user-defined accelerators. */
main_window_accels_save ();
- g_signal_handlers_disconnect_by_func (window->account_manager,
- main_window_connection_changed_cb,
- window);
-
if (window->size_timeout_id) {
g_source_remove (window->size_timeout_id);
}
@@ -845,12 +846,12 @@ main_window_view_show_map_cb (GtkCheckMenuItem *item,
static void
main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
{
- EmpathyAccount *account;
+ TpAccount *account;
TpConnection *connection;
const gchar *room;
account = empathy_chatroom_get_account (chatroom);
- connection = empathy_account_get_connection (account);
+ connection = tp_account_get_connection (account);
room = empathy_chatroom_get_room (chatroom);
if (connection != NULL) {
@@ -1121,12 +1122,27 @@ main_window_configure_event_cb (GtkWidget *widget,
}
static void
-main_window_account_created_or_deleted_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyMainWindow *window)
+main_window_account_removed_cb (TpAccountManager *manager,
+ TpAccount *account,
+ EmpathyMainWindow *window)
{
+ GList *a;
+
+ a = tp_account_manager_get_valid_accounts (manager);
+
gtk_action_set_sensitive (window->view_history,
- empathy_account_manager_get_count (manager) > 0);
+ g_list_length (a) > 0);
+
+ g_list_free (a);
+}
+
+static void
+main_window_account_validity_changed_cb (TpAccountManager *manager,
+ TpAccount *account,
+ gboolean valid,
+ EmpathyMainWindow *window)
+{
+ main_window_account_removed_cb (manager, account, window);
}
static void
@@ -1169,6 +1185,33 @@ empathy_main_window_get (void)
return main_window != NULL ? main_window->window : NULL;
}
+static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *accounts, *j;
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyMainWindow *window = user_data;
+ 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;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (window->account_manager);
+ for (j = accounts; j != NULL; j = j->next) {
+ TpAccount *account = TP_ACCOUNT (j->data);
+
+ g_signal_connect (account, "status-changed",
+ G_CALLBACK (main_window_connection_changed_cb),
+ window);
+ }
+ g_list_free (accounts);
+}
+
GtkWidget *
empathy_main_window_show (void)
{
@@ -1250,11 +1293,10 @@ empathy_main_window_show (void)
gtk_action_set_visible (show_map_widget, FALSE);
#endif
- window->account_manager = empathy_account_manager_dup_singleton ();
+ window->account_manager = tp_account_manager_dup ();
- g_signal_connect (window->account_manager,
- "account-connection-changed",
- G_CALLBACK (main_window_connection_changed_cb), window);
+ tp_account_manager_prepare_async (window->account_manager, NULL,
+ account_manager_prepared_cb, window);
window->errors = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
@@ -1352,13 +1394,13 @@ empathy_main_window_show (void)
G_CALLBACK (main_window_event_removed_cb),
window);
- g_signal_connect (window->account_manager, "account-created",
- G_CALLBACK (main_window_account_created_or_deleted_cb),
+ g_signal_connect (window->account_manager, "account-validity-changed",
+ G_CALLBACK (main_window_account_validity_changed_cb),
window);
- g_signal_connect (window->account_manager, "account-deleted",
- G_CALLBACK (main_window_account_created_or_deleted_cb),
+ g_signal_connect (window->account_manager, "account-removed",
+ G_CALLBACK (main_window_account_removed_cb),
window);
- main_window_account_created_or_deleted_cb (window->account_manager, NULL, window);
+ main_window_account_removed_cb (window->account_manager, NULL, window);
l = empathy_event_manager_get_events (window->event_manager);
while (l) {
@@ -1404,7 +1446,7 @@ empathy_main_window_show (void)
EMPATHY_PREFS_UI_SHOW_AVATARS,
window);
- main_window_update_status (window, window->account_manager);
+ main_window_update_status (window);
return window->window;
}
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 219be371d..8ea65adf2 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -354,7 +354,7 @@ static void
new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
{
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
const gchar *protocol;
const gchar *room;
@@ -364,7 +364,7 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
if (account == NULL)
return;
- protocol = empathy_account_get_protocol (account);
+ protocol = tp_account_get_protocol (account);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), "");
@@ -396,7 +396,7 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog)
{
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
gboolean listing = FALSE;
gboolean expanded = FALSE;
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index a2a6f54fb..21cb2dd3d 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -32,11 +32,11 @@
#include <libnotify/notification.h>
#include <libnotify/notify.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-idle.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy-gtk/empathy-presence-chooser.h>
#include <libempathy-gtk/empathy-conf.h>
@@ -60,7 +60,7 @@
typedef struct {
GtkStatusIcon *icon;
EmpathyIdle *idle;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
gboolean showing_event_icon;
guint blink_timeout;
EmpathyEventManager *event_manager;
@@ -511,20 +511,18 @@ status_icon_create_menu (EmpathyStatusIcon *icon)
}
static void
-status_icon_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
- EmpathyStatusIcon *icon)
+status_icon_status_changed_cb (TpAccount *account,
+ TpConnectionStatus current,
+ TpConnectionStatus previous,
+ TpConnectionStatusReason reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ EmpathyStatusIcon *icon)
{
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
- int connected_accounts;
- /* Check for a connected account */
- connected_accounts = empathy_account_manager_get_connected_accounts (manager);
-
- gtk_action_set_sensitive (priv->new_message_item, connected_accounts > 0);
+ gtk_action_set_sensitive (priv->new_message_item,
+ empathy_account_manager_get_accounts_connected (NULL));
}
static void
@@ -536,10 +534,6 @@ status_icon_finalize (GObject *object)
g_source_remove (priv->blink_timeout);
}
- g_signal_handlers_disconnect_by_func (priv->account_manager,
- status_icon_connection_changed_cb,
- object);
-
if (priv->notification) {
notify_notification_close (priv->notification, NULL);
g_object_unref (priv->notification);
@@ -564,6 +558,31 @@ empathy_status_icon_class_init (EmpathyStatusIconClass *klass)
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *list, *l;
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyStatusIcon *icon = user_data;
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ list = tp_account_manager_get_valid_accounts (account_manager);
+ for (l = list; l != NULL; l = l->next) {
+ empathy_signal_connect_weak (l->data, "status-changed",
+ G_CALLBACK (status_icon_status_changed_cb),
+ G_OBJECT (icon));
+ }
+ g_list_free (list);
+}
+
+static void
empathy_status_icon_init (EmpathyStatusIcon *icon)
{
EmpathyStatusIconPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (icon,
@@ -572,13 +591,12 @@ empathy_status_icon_init (EmpathyStatusIcon *icon)
icon->priv = priv;
priv->icon = gtk_status_icon_new ();
- priv->account_manager = empathy_account_manager_dup_singleton ();
+ priv->account_manager = tp_account_manager_dup ();
priv->idle = empathy_idle_dup_singleton ();
priv->event_manager = empathy_event_manager_dup_singleton ();
- g_signal_connect (priv->account_manager,
- "account-connection-changed",
- G_CALLBACK (status_icon_connection_changed_cb), icon);
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, icon);
/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
empathy_conf_notify_add (empathy_conf_get (),
diff --git a/src/empathy.c b/src/empathy.c
index 69210760e..72b691c16 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -38,6 +38,7 @@
#include <libebook/e-book.h>
#include <libnotify/notify.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/connection-manager.h>
@@ -49,7 +50,6 @@
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-account-settings.h>
#include <libempathy/empathy-connectivity.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-debugger.h>
#include <libempathy/empathy-dispatcher.h>
@@ -105,16 +105,12 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
id = empathy_tp_chat_get_id (tp_chat);
if (!EMP_STR_EMPTY (id))
{
- EmpathyAccountManager *manager;
TpConnection *connection;
- EmpathyAccount *account;
+ TpAccount *account;
- manager = empathy_account_manager_dup_singleton ();
connection = empathy_tp_chat_get_connection (tp_chat);
- account = empathy_account_manager_get_account_for_connection (
- manager, connection);
+ account = empathy_get_account_for_connection (connection);
chat = empathy_chat_window_find_chat (account, id);
- g_object_unref (manager);
}
if (chat)
@@ -155,11 +151,11 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
}
}
-/* Salut account creation */
+/* Salut account creation. The TpAccountManager first argument
+ * must already be prepared when calling this function. */
static gboolean
-should_create_salut_account (void)
+should_create_salut_account (TpAccountManager *manager)
{
- EmpathyAccountManager *manager;
gboolean salut_created = FALSE;
GList *accounts, *l;
@@ -174,20 +170,20 @@ should_create_salut_account (void)
return FALSE;
}
- manager = empathy_account_manager_dup_singleton ();
- accounts = empathy_account_manager_dup_accounts (manager);
+ accounts = tp_account_manager_get_valid_accounts (manager);
for (l = accounts; l != NULL; l = g_list_next (l))
{
- EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+ TpAccount *account = TP_ACCOUNT (l->data);
- if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
- salut_created = TRUE;
-
- g_object_unref (account);
+ if (!tp_strdiff (tp_account_get_protocol (account), "local-xmpp"))
+ {
+ salut_created = TRUE;
+ break;
+ }
}
- g_object_unref (manager);
+ g_list_free (accounts);
if (salut_created)
{
@@ -206,7 +202,7 @@ salut_account_created (GObject *source,
gpointer user_data)
{
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
- EmpathyAccount *account;
+ TpAccount *account;
GError *error = NULL;
if (!empathy_account_settings_apply_finish (settings, result, &error))
@@ -218,7 +214,7 @@ salut_account_created (GObject *source,
account = empathy_account_settings_get_account (settings);
- empathy_account_set_enabled_async (account, TRUE, NULL, NULL);
+ tp_account_set_enabled_async (account, TRUE, NULL, NULL);
empathy_conf_set_bool (empathy_conf_get (),
EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
TRUE);
@@ -239,8 +235,12 @@ use_conn_notify_cb (EmpathyConf *conf,
}
static void
-create_salut_account_if_needed (EmpathyConnectionManagers *managers)
+create_salut_account_am_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyConnectionManagers *managers = user_data;
EmpathyAccountSettings *settings;
TpConnectionManager *manager;
const TpConnectionManagerProtocol *protocol;
@@ -253,22 +253,28 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers)
gchar *jid = NULL;
GError *error = NULL;
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
- if (!should_create_salut_account ())
- return;
+ if (!should_create_salut_account (account_manager))
+ goto out;
manager = empathy_connection_managers_get_cm (managers, "salut");
if (manager == NULL)
{
DEBUG ("Salut not installed, not making a salut account");
- return;
+ goto out;
}
protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
if (protocol == NULL)
{
DEBUG ("Salut doesn't support local-xmpp!!");
- return;
+ goto out;
}
DEBUG ("Trying to add a salut account...");
@@ -279,7 +285,7 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers)
DEBUG ("Failed to get self econtact: %s",
error ? error->message : "No error given");
g_clear_error (&error);
- return;
+ goto out;
}
settings = empathy_account_settings_new ("salut", "local-xmpp",
@@ -321,24 +327,39 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers)
g_object_unref (settings);
g_object_unref (contact);
g_object_unref (book);
+
+ out:
+ g_object_unref (managers);
+}
+
+static void
+create_salut_account_if_needed (EmpathyConnectionManagers *managers)
+{
+ TpAccountManager *manager;
+
+ manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (manager, NULL,
+ create_salut_account_am_ready_cb, g_object_ref (managers));
+
+ g_object_unref (manager);
}
static gboolean
-has_non_salut_accounts (EmpathyAccountManager *manager)
+has_non_salut_accounts (TpAccountManager *manager)
{
gboolean ret = FALSE;
GList *accounts, *l;
- accounts = empathy_account_manager_dup_accounts (manager);
+ accounts = tp_account_manager_get_valid_accounts (manager);
for (l = accounts ; l != NULL; l = g_list_next (l))
{
- EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
-
- if (tp_strdiff (empathy_account_get_protocol (l->data), "local-xmpp"))
- ret = TRUE;
-
- g_object_unref (account);
+ if (tp_strdiff (tp_account_get_protocol (l->data), "local-xmpp"))
+ {
+ ret = TRUE;
+ break;
+ }
}
g_list_free (accounts);
@@ -349,11 +370,13 @@ has_non_salut_accounts (EmpathyAccountManager *manager)
static void
maybe_show_account_assistant (void)
{
- EmpathyAccountManager *manager;
- manager = empathy_account_manager_dup_singleton ();
+ TpAccountManager *manager;
+ manager = tp_account_manager_dup ();
if (!has_non_salut_accounts (manager))
empathy_account_assistant_show (GTK_WINDOW (empathy_main_window_get ()));
+
+ g_object_unref (manager);
}
static gboolean
@@ -450,7 +473,7 @@ migrate_config_to_xdg_dir (void)
static void
do_show_accounts_ui (GtkWindow *window,
- EmpathyAccountManager *manager)
+ TpAccountManager *manager)
{
GtkWidget *ui;
@@ -466,12 +489,19 @@ do_show_accounts_ui (GtkWindow *window,
}
static void
-account_manager_ready_for_accounts_cb (EmpathyAccountManager *manager,
- GParamSpec *spec,
+account_manager_ready_for_accounts_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
- if (!empathy_account_manager_is_ready (manager))
- return;
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ 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;
+ }
do_show_accounts_ui (user_data, manager);
}
@@ -480,24 +510,15 @@ static void
show_accounts_ui (GtkWindow *window,
gboolean force)
{
- EmpathyAccountManager *manager;
+ TpAccountManager *manager;
- manager = empathy_account_manager_dup_singleton ();
- if (empathy_account_manager_is_ready (manager))
- {
- if (force)
- do_show_accounts_ui (window, manager);
- else
- maybe_show_account_assistant ();
- }
- else if (force)
- {
- /* Only if we we're forced to show the widget connect to ready, otherwise
- * the initial readyness will cause the accounts ui to be shown when
- * needed */
- g_signal_connect (manager, "notify::ready",
- G_CALLBACK (account_manager_ready_for_accounts_cb), window);
- }
+ if (!force)
+ return;
+
+ manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (manager, NULL,
+ account_manager_ready_for_accounts_cb, window);
g_object_unref (manager);
}
@@ -615,14 +636,22 @@ default_log_handler (const gchar *log_domain,
#endif /* ENABLE_DEBUG */
static void
-account_manager_ready_cb (EmpathyAccountManager *manager,
- GParamSpec *spec,
+account_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
gpointer user_data)
{
- if (!empathy_account_manager_is_ready (manager))
- return;
+ TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
+ 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;
+ }
- if (should_create_salut_account () || !empathy_import_mc4_has_imported ())
+ if (should_create_salut_account (manager)
+ || !empathy_import_mc4_has_imported ())
{
EmpathyConnectionManagers *managers;
managers = empathy_connection_managers_dup_singleton ();
@@ -730,37 +759,48 @@ setup_dispatcher (void)
}
static void
-account_connection_notify_cb (EmpathyAccount *account,
- GParamSpec *pspec,
+account_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
EmpathyChatroom *room)
{
TpConnection *conn;
- conn = empathy_account_get_connection (account);
-
- if (conn == NULL)
- return;
+ conn = tp_account_get_connection (account);
empathy_dispatcher_join_muc (conn,
empathy_chatroom_get_room (room), NULL, NULL);
}
static void
-account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager,
- GParamSpec *pspec,
- EmpathyChatroomManager *chatroom_manager)
+account_manager_chatroom_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyChatroomManager *chatroom_manager = user_data;
GList *accounts, *l;
+ GError *error = NULL;
- accounts = empathy_account_manager_dup_accounts (account_manager);
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
for (l = accounts; l != NULL; l = g_list_next (l))
{
- EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+ TpAccount *account = TP_ACCOUNT (l->data);
TpConnection *conn;
GList *chatrooms, *p;
- conn = empathy_account_get_connection (account);
+ conn = tp_account_get_connection (account);
chatrooms = empathy_chatroom_manager_get_chatrooms (
chatroom_manager, account);
@@ -774,8 +814,8 @@ account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager,
if (conn == NULL)
{
- g_signal_connect (G_OBJECT (account), "notify::connection",
- G_CALLBACK (account_connection_notify_cb), room);
+ g_signal_connect (G_OBJECT (account), "status-changed",
+ G_CALLBACK (account_status_changed_cb), room);
}
else
{
@@ -787,29 +827,18 @@ account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager,
g_list_free (chatrooms);
}
- g_list_foreach (accounts, (GFunc) g_object_unref, NULL);
g_list_free (accounts);
}
static void
chatroom_manager_ready_cb (EmpathyChatroomManager *chatroom_manager,
GParamSpec *pspec,
- EmpathyAccountManager *account_manager)
+ gpointer user_data)
{
- gboolean ready;
+ TpAccountManager *account_manager = user_data;
- g_object_get (G_OBJECT (account_manager), "ready", &ready, NULL);
-
- if (ready)
- {
- account_manager_chatroom_ready_cb (account_manager, NULL,
- chatroom_manager);
- }
- else
- {
- g_signal_connect (account_manager, "notify::ready",
- G_CALLBACK (account_manager_chatroom_ready_cb), chatroom_manager);
- }
+ tp_account_manager_prepare_async (account_manager, NULL,
+ account_manager_chatroom_ready_cb, chatroom_manager);
}
int
@@ -820,7 +849,7 @@ main (int argc, char *argv[])
#endif
EmpathyStatusIcon *icon;
EmpathyDispatcher *dispatcher;
- EmpathyAccountManager *account_manager;
+ TpAccountManager *account_manager;
EmpathyLogManager *log_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyCallFactory *call_factory;
@@ -923,7 +952,7 @@ main (int argc, char *argv[])
if (account_dialog_only)
{
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
show_accounts_ui (NULL, TRUE);
gtk_main ();
@@ -955,9 +984,9 @@ main (int argc, char *argv[])
empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
/* account management */
- account_manager = empathy_account_manager_dup_singleton ();
- g_signal_connect (account_manager, "notify::ready",
- G_CALLBACK (account_manager_ready_cb), NULL);
+ account_manager = tp_account_manager_dup ();
+ tp_account_manager_prepare_async (account_manager, NULL,
+ account_manager_ready_cb, NULL);
/* Handle channels */
dispatcher = setup_dispatcher ();
diff --git a/tests/check-empathy-chatroom-manager.c b/tests/check-empathy-chatroom-manager.c
index 5a3384fe4..dd0d93f52 100644
--- a/tests/check-empathy-chatroom-manager.c
+++ b/tests/check-empathy-chatroom-manager.c
@@ -5,6 +5,7 @@
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <check.h>
@@ -13,7 +14,6 @@
#include "check-empathy-helpers.h"
#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-account-manager.h>
#define CHATROOM_SAMPLE "chatrooms-sample.xml"
#define CHATROOM_FILE "chatrooms.xml"
diff --git a/tests/check-empathy-helpers.c b/tests/check-empathy-helpers.c
index 5fb8b4a35..d176d0abe 100644
--- a/tests/check-empathy-helpers.c
+++ b/tests/check-empathy-helpers.c
@@ -24,7 +24,7 @@
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
-#include <libempathy/empathy-account-manager.h>
+#include <telepathy-glib/account-manager.h>
#include "check-helpers.h"
#include "check-empathy-helpers.h"
diff --git a/tests/check-empathy-helpers.h b/tests/check-empathy-helpers.h
index 5544b80aa..665e7e256 100644
--- a/tests/check-empathy-helpers.h
+++ b/tests/check-empathy-helpers.h
@@ -20,12 +20,13 @@
#define __CHECK_EMPATHY_HELPERS_H__
#include <glib.h>
-#include <libempathy/empathy-account.h>
+
+#include <telepathy-glib/account.h>
gchar * get_xml_file (const gchar *filename);
gchar * get_user_xml_file (const gchar *filename);
void copy_xml_file (const gchar *orig, const gchar *dest);
-EmpathyAccount * get_test_account (void);
-void destroy_test_account (EmpathyAccount *account);
+TpAccount * get_test_account (void);
+void destroy_test_account (TpAccount *account);
#endif /* #ifndef __CHECK_EMPATHY_HELPERS_H__ */