diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-account-chooser.c | 177 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-chooser.h | 10 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 28 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat-text-view.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 68 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.c | 7 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 18 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-irc-network-dialog.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-location-manager.c | 104 | ||||
-rw-r--r-- | libempathy-gtk/empathy-log-window.c | 79 | ||||
-rw-r--r-- | libempathy-gtk/empathy-log-window.h | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-new-message-dialog.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.c | 59 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 1 |
17 files changed, 375 insertions, 197 deletions
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" |