]> git.0d.be Git - empathy.git/commitdiff
Don't try to register for unique bus names in remote instances of Empathy.
authorTravis Reitter <travis.reitter@collabora.co.uk>
Fri, 22 Oct 2010 19:04:26 +0000 (12:04 -0700)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Fri, 29 Oct 2010 16:35:09 +0000 (09:35 -0700)
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

index b2005f19c520e11c2acc39f62daaa1bfa9fb0da5..8ef5c5d6fe2073fe5e2452aa496773c1f4ce70f9 100644 (file)
@@ -104,6 +104,8 @@ struct _EmpathyApp
   gboolean no_connect;
   gboolean start_hidden;
 
+  gboolean activated;
+
   GtkWidget *window;
   EmpathyStatusIcon *icon;
   EmpathyDispatcher *dispatcher;
@@ -197,17 +199,63 @@ 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));
 
@@ -349,32 +397,6 @@ show_version_cb (const char *option_name,
   exit (EXIT_SUCCESS);
 }
 
-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,
@@ -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