diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2009-10-24 22:56:30 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2009-10-24 22:56:30 +0800 |
commit | 7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2 (patch) | |
tree | fa47706065a04cf31347bcfd72e5fe1e56909292 /libempathy-gtk | |
parent | ed1550ec4ce29466e6c4b840ee37f2d78862c3d9 (diff) | |
download | gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar.gz gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar.bz2 gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar.lz gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar.xz gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.tar.zst gsoc2013-empathy-7a3e1db6e3a795a3bbf85c9d2489c43a9e6537e2.zip |
presence-chooser: port to new tp-glib account API
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 7113c77fd..84b0c4d08 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,29 @@ 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; - accounts = empathy_account_manager_dup_accounts (priv->account_manager); + if (!tp_account_manager_prepare_finish (manager, result, NULL)) { + return; + } + + 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 +749,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 +853,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", |