]> git.0d.be Git - empathy.git/commitdiff
presence-chooser: port to new tp-glib account API
authorJonny Lamb <jonnylamb@gnome.org>
Sat, 24 Oct 2009 14:56:30 +0000 (15:56 +0100)
committerJonny Lamb <jonnylamb@gnome.org>
Sat, 24 Oct 2009 14:56:30 +0000 (15:56 +0100)
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
libempathy-gtk/empathy-presence-chooser.c

index 7113c77fd5ddf8fd9d727010b3d5d112ad9c2fc4..84b0c4d08efef1e74df25b6f80e5ebd3b1569215 100644 (file)
 #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);
@@ -740,10 +748,30 @@ presence_chooser_update_sensitivity (EmpathyPresenceChooser *chooser)
        gtk_widget_set_sensitive (GTK_WIDGET (chooser), sensitive);
 }
 
+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",