From 0ff09c9c9bf89948a8e37b3c3606fc42f0d8e618 Mon Sep 17 00:00:00 2001 From: Travis Reitter Date: Fri, 22 Oct 2010 12:04:26 -0700 Subject: 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 file changed, 56 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/empathy.c b/src/empathy.c index b2005f19c..8ef5c5d6f 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; @@ -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 -- cgit v1.2.3