[nautilus-sendto] Port to Mission Control 5 (bug #593124).



commit bb014358c6a2d1da48e556fb979b85d6c03c5681
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Sep 1 12:39:29 2009 +0200

    Port to Mission Control 5 (bug #593124).

 src/plugins/empathy/empathy.c |   54 +++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/empathy/empathy.c b/src/plugins/empathy/empathy.c
index e5a829a..d45bb4f 100644
--- a/src/plugins/empathy/empathy.c
+++ b/src/plugins/empathy/empathy.c
@@ -35,25 +35,45 @@
 #include <libempathy/empathy-ft-factory.h>
 #include <libempathy/empathy-ft-handler.h>
 #include <libempathy/empathy-tp-file.h>
-#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-account-manager.h>
 
 #include <libempathy-gtk/empathy-contact-selector.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
 #include "nautilus-sendto-plugin.h"
 
-static MissionControl *mc = NULL;
+static EmpathyAccountManager *acc_manager = NULL;
 static EmpathyFTFactory *factory = NULL;
 static guint transfers = 0;
 
 static gboolean destroy (NstPlugin *plugin);
 
+static void
+handle_account_manager_ready ()
+{
+  TpConnectionPresenceType presence;
+
+  presence = empathy_account_manager_get_global_presence (acc_manager,
+      NULL, NULL);
+
+  if (presence < TP_CONNECTION_PRESENCE_TYPE_AVAILABLE)
+    return;
+}
+
+static void
+acc_manager_ready_cb (EmpathyAccountManager *am,
+    GParamSpec *pspec,
+    gpointer _user_data)
+{
+  if (!empathy_account_manager_is_ready (am))
+    return;
+
+  handle_account_manager_ready ();
+}
+
 static gboolean
 init (NstPlugin *plugin)
 {
-  GSList *accounts = NULL;
-  GSList *l;
-
   g_print ("Init %s plugin\n", plugin->info->id);
 
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@@ -61,19 +81,13 @@ init (NstPlugin *plugin)
 
   empathy_gtk_init ();
 
-  mc = empathy_mission_control_dup_singleton ();
-  accounts = mission_control_get_online_connections (mc, FALSE);
-
-  if (g_slist_length (accounts) == 0)
-    {
-      destroy (plugin);
-      return FALSE;
-    }
-
-  for (l = accounts; l; l = l->next)
-    g_object_unref (l->data);
+  acc_manager = empathy_account_manager_dup_singleton ();
 
-  g_slist_free (accounts);
+  if (empathy_account_manager_is_ready (acc_manager))
+    handle_account_manager_ready ();
+  else
+    g_signal_connect (acc_manager, "notify::ready",
+        G_CALLBACK (acc_manager_ready_cb), NULL);
 
   return TRUE;
 }
@@ -183,8 +197,6 @@ handler_ready_cb (EmpathyFTFactory *factory,
                   GError *error,
                   NstPlugin *plugin)
 {
-  g_print ("handler ready!, error %p", error);
-
   if (error != NULL)
     {
       GtkWidget *dialog;
@@ -253,8 +265,8 @@ send_files (NstPlugin *plugin,
 static gboolean
 destroy (NstPlugin *plugin)
 {
-  if (mc)
-    g_object_unref (mc);
+  if (acc_manager)
+    g_object_unref (acc_manager);
 
   if (factory)
     g_object_unref (factory);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]