[empathy] Don't try to register for unique bus names in remote instances of Empathy.



commit 0ff09c9c9bf89948a8e37b3c3606fc42f0d8e618
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Fri Oct 22 12:04:26 2010 -0700

    Don't try to register for unique bus names in remote instances of Empathy.
    
    This means, that remote (secondary) instances of Empathy won't try to hold the
    Chat or FT bus names (which will always fail.
    
    It also means that remote instances don't try to hold the GApplication (though
    they would release it upon exit anyhow).

 src/empathy.c |  101 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 56 insertions(+), 45 deletions(-)
---
diff --git a/src/empathy.c b/src/empathy.c
index b2005f1..8ef5c5d 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -104,6 +104,8 @@ struct _EmpathyApp
   gboolean no_connect;
   gboolean start_hidden;
 
+  gboolean activated;
+
   GtkWidget *window;
   EmpathyStatusIcon *icon;
   EmpathyDispatcher *dispatcher;
@@ -198,16 +200,62 @@ empathy_app_set_property (GObject *object,
 }
 
 static void
+new_incoming_transfer_cb (EmpathyFTFactory *factory,
+    EmpathyFTHandler *handler,
+    GError *error,
+    gpointer user_data)
+{
+  if (error)
+    empathy_ft_manager_display_error (handler, error);
+  else
+    empathy_receive_file_with_file_chooser (handler);
+}
+
+static void
+new_ft_handler_cb (EmpathyFTFactory *factory,
+    EmpathyFTHandler *handler,
+    GError *error,
+    gpointer user_data)
+{
+  if (error)
+    empathy_ft_manager_display_error (handler, error);
+  else
+    empathy_ft_manager_add_handler (handler);
+
+  g_object_unref (handler);
+}
+
+static void
 empathy_app_activate (GApplication *app)
 {
   EmpathyApp *self = (EmpathyApp *) app;
 
-  /* We're requested to show stuff again, disable the start hidden global
-   * in case the accounts wizard wants to pop up.
-   */
-  self->start_hidden = FALSE;
+  if (!self->activated)
+    {
+      GError *error = NULL;
+
+      /* Create the FT factory */
+      self->ft_factory = empathy_ft_factory_dup_singleton ();
+      g_signal_connect (self->ft_factory, "new-ft-handler",
+          G_CALLBACK (new_ft_handler_cb), NULL);
+      g_signal_connect (self->ft_factory, "new-incoming-transfer",
+          G_CALLBACK (new_incoming_transfer_cb), NULL);
+
+      if (!empathy_ft_factory_register (self->ft_factory, &error))
+        {
+          g_warning ("Failed to register FileTransfer handler: %s",
+              error->message);
+          g_error_free (error);
+        }
 
-  g_application_hold (G_APPLICATION (app));
+      /* We're requested to show stuff again, disable the start hidden global in
+       * case the accounts wizard wants to pop up.
+      */
+      self->start_hidden = FALSE;
+
+      g_application_hold (G_APPLICATION (app));
+      self->activated = TRUE;
+    }
 
   empathy_window_present (GTK_WINDOW (self->window));
 
@@ -350,32 +398,6 @@ show_version_cb (const char *option_name,
 }
 
 static void
-new_incoming_transfer_cb (EmpathyFTFactory *factory,
-    EmpathyFTHandler *handler,
-    GError *error,
-    gpointer user_data)
-{
-  if (error)
-    empathy_ft_manager_display_error (handler, error);
-  else
-    empathy_receive_file_with_file_chooser (handler);
-}
-
-static void
-new_ft_handler_cb (EmpathyFTFactory *factory,
-    EmpathyFTHandler *handler,
-    GError *error,
-    gpointer user_data)
-{
-  if (error)
-    empathy_ft_manager_display_error (handler, error);
-  else
-    empathy_ft_manager_add_handler (handler);
-
-  g_object_unref (handler);
-}
-
-static void
 account_manager_ready_cb (GObject *source_object,
     GAsyncResult *result,
     gpointer user_data)
@@ -522,7 +544,6 @@ static void
 empathy_app_constructed (GObject *object)
 {
   EmpathyApp *self = (EmpathyApp *) object;
-  GError *error = NULL;
   gboolean chatroom_manager_ready;
   gboolean autoaway;
 
@@ -593,23 +614,13 @@ empathy_app_constructed (GObject *object)
           self->account_manager);
     }
 
-  /* Create the FT factory */
-  self->ft_factory = empathy_ft_factory_dup_singleton ();
-  g_signal_connect (self->ft_factory, "new-ft-handler",
-      G_CALLBACK (new_ft_handler_cb), NULL);
-  g_signal_connect (self->ft_factory, "new-incoming-transfer",
-      G_CALLBACK (new_incoming_transfer_cb), NULL);
-
-  if (!empathy_ft_factory_register (self->ft_factory, &error))
-    {
-      g_warning ("Failed to register FileTransfer handler: %s", error->message);
-      g_error_free (error);
-    }
-
   /* Location mananger */
 #ifdef HAVE_GEOCLUE
   self->location_manager = empathy_location_manager_dup_singleton ();
 #endif
+
+  self->activated = FALSE;
+  self->ft_factory = NULL;
 }
 
 int



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