]> git.0d.be Git - empathy.git/blob - src/empathy.c
Remove useless mission-control includes
[empathy.git] / src / empathy.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include <config.h>
24
25 #include <stdlib.h>
26 #include <errno.h>
27 #include <string.h>
28
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <gtk/gtk.h>
32 #include <gdk/gdkx.h>
33
34 #if HAVE_LIBCHAMPLAIN
35 #include <clutter-gtk/gtk-clutter-embed.h>
36 #endif
37
38 #include <libebook/e-book.h>
39 #include <libnotify/notify.h>
40
41 #include <telepathy-glib/dbus.h>
42 #include <telepathy-glib/util.h>
43 #include <telepathy-glib/connection-manager.h>
44
45 #include <libempathy/empathy-idle.h>
46 #include <libempathy/empathy-utils.h>
47 #include <libempathy/empathy-call-factory.h>
48 #include <libempathy/empathy-chatroom-manager.h>
49 #include <libempathy/empathy-account-manager.h>
50 #include <libempathy/empathy-debugger.h>
51 #include <libempathy/empathy-dispatcher.h>
52 #include <libempathy/empathy-dispatch-operation.h>
53 #include <libempathy/empathy-log-manager.h>
54 #include <libempathy/empathy-ft-factory.h>
55 #include <libempathy/empathy-tp-chat.h>
56 #include <libempathy/empathy-tp-call.h>
57
58 #include <libempathy-gtk/empathy-conf.h>
59 #include <libempathy-gtk/empathy-ui-utils.h>
60 #include <libempathy-gtk/empathy-location-manager.h>
61
62 #include "empathy-accounts-dialog.h"
63 #include "empathy-main-window.h"
64 #include "empathy-status-icon.h"
65 #include "empathy-call-window.h"
66 #include "empathy-chat-window.h"
67 #include "empathy-ft-manager.h"
68 #include "bacon-message-connection.h"
69
70 #include "extensions/extensions.h"
71
72 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
73 #include <libempathy/empathy-debug.h>
74
75 #include <gst/gst.h>
76
77 static BaconMessageConnection *connection = NULL;
78
79 static void
80 dispatch_cb (EmpathyDispatcher *dispatcher,
81              EmpathyDispatchOperation *operation,
82              gpointer           user_data)
83 {
84         GQuark channel_type;
85
86         channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
87
88         if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT) {
89                 EmpathyTpChat *tp_chat;
90                 EmpathyChat   *chat = NULL;
91                 const gchar   *id;
92
93                 tp_chat = EMPATHY_TP_CHAT (
94                         empathy_dispatch_operation_get_channel_wrapper (operation));
95
96                 id = empathy_tp_chat_get_id (tp_chat);
97                 if (!id) {
98                         EmpathyContact *contact;
99
100                         contact = empathy_tp_chat_get_remote_contact (tp_chat);
101                         if (contact) {
102                                 id = empathy_contact_get_id (contact);
103                         }
104                 }
105
106                 if (id) {
107                         EmpathyAccountManager *manager;
108                         TpConnection *connection;
109                         EmpathyAccount *account;
110
111                         manager = empathy_account_manager_dup_singleton ();
112                         connection = empathy_tp_chat_get_connection (tp_chat);
113                         account = empathy_account_manager_get_account (manager,
114                                                                        connection);
115                         chat = empathy_chat_window_find_chat (account, id);
116                         g_object_unref (manager);
117                 }
118
119                 if (chat) {
120                         empathy_chat_set_tp_chat (chat, tp_chat);
121                 } else {
122                         chat = empathy_chat_new (tp_chat);
123                 }
124
125                 empathy_chat_window_present_chat (chat);
126
127                 empathy_dispatch_operation_claim (operation);
128         } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) {
129                 EmpathyCallFactory *factory;
130
131                 factory = empathy_call_factory_get ();
132                 empathy_call_factory_claim_channel (factory, operation);
133         } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) {
134                 EmpathyFTFactory *factory;
135
136                 factory = empathy_ft_factory_dup_singleton ();
137
138                 /* if the operation is not incoming, don't claim it,
139                  * as it might have been triggered by another client, and
140                  * we are observing it.
141                  */
142                 if (empathy_dispatch_operation_is_incoming (operation)) {
143                         empathy_ft_factory_claim_channel (factory, operation);
144                 }
145         }
146 }
147
148 static void
149 service_ended_cb (MissionControl *mc,
150                   gpointer        user_data)
151 {
152         DEBUG ("Mission Control stopped");
153 }
154
155 static void
156 operation_error_cb (MissionControl *mc,
157                     guint           operation_id,
158                     guint           error_code,
159                     gpointer        user_data)
160 {
161         const gchar *message;
162
163         switch (error_code) {
164         case MC_DISCONNECTED_ERROR:
165                 message = "Disconnected";
166                 break;
167         case MC_INVALID_HANDLE_ERROR:
168                 message = "Invalid handle";
169                 break;
170         case MC_NO_MATCHING_CONNECTION_ERROR:
171                 message = "No matching connection";
172                 break;
173         case MC_INVALID_ACCOUNT_ERROR:
174                 message = "Invalid account";
175                 break;
176         case MC_PRESENCE_FAILURE_ERROR:
177                 message = "Presence failure";
178                 break;
179         case MC_NO_ACCOUNTS_ERROR:
180                 message = "No accounts";
181                 break;
182         case MC_NETWORK_ERROR:
183                 message = "Network error";
184                 break;
185         case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR:
186                 message = "Contact does not support voice";
187                 break;
188         case MC_LOWMEM_ERROR:
189                 message = "Lowmem";
190                 break;
191         case MC_CHANNEL_REQUEST_GENERIC_ERROR:
192                 message = "Channel request generic error";
193                 break;
194         case MC_CHANNEL_BANNED_ERROR:
195                 message = "Channel banned";
196                 break;
197         case MC_CHANNEL_FULL_ERROR:
198                 message = "Channel full";
199                 break;
200         case MC_CHANNEL_INVITE_ONLY_ERROR:
201                 message = "Channel invite only";
202                 break;
203         default:
204                 message = "Unknown error code";
205         }
206
207         DEBUG ("Error during operation %d: %s", operation_id, message);
208 }
209
210 static void
211 use_nm_notify_cb (EmpathyConf *conf,
212                   const gchar *key,
213                   gpointer     user_data)
214 {
215         EmpathyIdle *idle = user_data;
216         gboolean     use_nm;
217
218         if (empathy_conf_get_bool (conf, key, &use_nm)) {
219                 empathy_idle_set_use_nm (idle, use_nm);
220         }
221 }
222
223 static gboolean
224 should_create_salut_account (void)
225 {
226         EmpathyAccountManager *manager;
227         gboolean salut_created = FALSE;
228         GList *accounts, *l;
229
230         /* Check if we already created a salut account */
231         empathy_conf_get_bool (empathy_conf_get (),
232                                EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
233                                &salut_created);
234
235         manager = empathy_account_manager_dup_singleton ();
236         accounts = empathy_account_manager_dup_accounts (manager);
237
238         for (l = accounts; l != NULL;  l = g_list_next (l)) {
239                 EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
240
241                 if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
242                         salut_created = TRUE;
243
244                 g_object_unref (account);
245         }
246
247         g_object_unref (manager);
248
249         return !salut_created;
250 }
251
252 static void
253 create_salut_account_if_needed (void)
254 {
255         EmpathyAccount  *account;
256         EmpathyAccountManager *account_manager;
257         EBook      *book;
258         EContact   *contact;
259         gchar      *nickname = NULL;
260         gchar      *first_name = NULL;
261         gchar      *last_name = NULL;
262         gchar      *email = NULL;
263         gchar      *jid = NULL;
264         GError     *error = NULL;
265
266
267         if (!should_create_salut_account())
268                 return;
269         
270         DEBUG ("Trying to add a salut account...");
271
272         /* Get self EContact from EDS */
273         if (!e_book_get_self (&contact, &book, &error)) {
274                 DEBUG ("Failed to get self econtact: %s",
275                         error ? error->message : "No error given");
276                 g_clear_error (&error);
277                 return;
278         }
279
280         account_manager = empathy_account_manager_dup_singleton ();
281         account = empathy_account_manager_create (account_manager,
282                 "salut", "local-xmpp", _("People nearby"));
283         g_object_unref (account_manager);
284         empathy_account_set_enabled (account, TRUE);
285
286         nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
287         first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
288         last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME);
289         email = e_contact_get (contact, E_CONTACT_EMAIL_1);
290         jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1);
291
292         if (!tp_strdiff (nickname, "nickname")) {
293                 g_free (nickname);
294                 nickname = NULL;
295         }
296
297         DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n"
298                 "last-name=%s\nemail=%s\njid=%s\n",
299                 nickname, first_name, last_name, email, jid);
300
301         empathy_account_set_param_string (account, "nickname", nickname ? nickname : "");
302         empathy_account_set_param_string (account, "first-name", first_name ? first_name : "");
303         empathy_account_set_param_string (account, "last-name", last_name ? last_name : "");
304         empathy_account_set_param_string (account, "email", email ? email : "");
305         empathy_account_set_param_string (account, "jid", jid ? jid : "");
306
307         g_free (nickname);
308         g_free (first_name);
309         g_free (last_name);
310         g_free (email);
311         g_free (jid);
312         g_object_unref (account);
313         g_object_unref (contact);
314         g_object_unref (book);
315
316         empathy_conf_set_bool (empathy_conf_get (),
317                                EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
318                                TRUE);
319
320 }
321
322 static void
323 connection_manager_listed (TpConnectionManager * const * cms,
324         gsize n_cms,
325         const GError *error,
326         gpointer user_data,
327         GObject *weak_object)
328 {
329         int i;
330         if (error != NULL) {
331                 DEBUG ("Couldn't get the connection manager list: %s", error->message);
332                 return;
333         }
334
335         for (i = 0; i < n_cms; i++) {
336                 if (!tp_strdiff (tp_connection_manager_get_name (cms[i]), "salut")) {
337                                 /* salut installed, see if we need to create a new account */
338                                 create_salut_account_if_needed ();
339                                 return;
340                         }
341         }
342 }
343
344 static void
345 create_salut_account (void)
346 {
347         TpDBusDaemon *d;
348
349         if (!should_create_salut_account())
350                 return;
351
352         d = tp_dbus_daemon_dup (NULL);
353
354         tp_list_connection_managers (d, connection_manager_listed, NULL,
355                 NULL, NULL);
356
357         g_object_unref (d);
358 }
359
360 /* The code that handles single-instance and startup notification is
361  * copied from gedit.
362  *
363  * Copyright (C) 2005 - Paolo Maggi
364  */
365 static void
366 on_bacon_message_received (const char *message,
367                            gpointer    data)
368 {
369         GtkWidget *window = data;
370         guint32    startup_timestamp;
371
372         g_return_if_fail (message != NULL);
373
374         DEBUG ("Other instance launched, presenting the main window. message='%s'",
375                 message);
376
377         if (strcmp (message, "accounts") == 0) {
378                 /* accounts dialog requested */
379                 empathy_accounts_dialog_show (GTK_WINDOW (window), NULL);
380         } else {
381                 startup_timestamp = atoi (message);
382
383                 /* Set the proper interaction time on the window.
384                  * Fall back to roundtripping to the X server when we
385                  * don't have the timestamp, e.g. when launched from
386                  * terminal. We also need to make sure that the window
387                  * has been realized otherwise it will not work. lame. */
388                 if (startup_timestamp == 0) {
389                         /* Work if launched from the terminal */
390                         DEBUG ("Using X server timestamp as a fallback");
391
392                         if (!GTK_WIDGET_REALIZED (window)) {
393                                 gtk_widget_realize (GTK_WIDGET (window));
394                         }
395
396                         startup_timestamp = gdk_x11_get_server_time (window->window);
397                 }
398
399                 gtk_window_present_with_time (GTK_WINDOW (window), startup_timestamp);
400         }
401 }
402
403 static guint32
404 get_startup_timestamp ()
405 {
406         const gchar *startup_id_env;
407         gchar       *startup_id = NULL;
408         gchar       *time_str;
409         gchar       *end;
410         gulong       retval = 0;
411
412         /* we don't unset the env, since startup-notification
413          * may still need it */
414         startup_id_env = g_getenv ("DESKTOP_STARTUP_ID");
415         if (startup_id_env == NULL) {
416                 goto out;
417         }
418
419         startup_id = g_strdup (startup_id_env);
420
421         time_str = g_strrstr (startup_id, "_TIME");
422         if (time_str == NULL) {
423                 goto out;
424         }
425
426         errno = 0;
427
428         /* Skip past the "_TIME" part */
429         time_str += 5;
430
431         retval = strtoul (time_str, &end, 0);
432         if (end == time_str || errno != 0)
433                 retval = 0;
434
435  out:
436         g_free (startup_id);
437
438         return (retval > 0) ? retval : 0;
439 }
440
441 static gboolean
442 show_version_cb (const char *option_name,
443                  const char *value,
444                  gpointer data,
445                  GError **error)
446 {
447         g_print ("%s\n", PACKAGE_STRING);
448
449         exit (EXIT_SUCCESS);
450
451         return FALSE;
452 }
453
454 static void
455 new_incoming_transfer_cb (EmpathyFTFactory *factory,
456                           EmpathyFTHandler *handler,
457                           GError *error,
458                           gpointer user_data)
459 {
460         if (error) {
461                 empathy_ft_manager_display_error (handler, error);
462         } else {
463                 empathy_receive_file_with_file_chooser (handler);
464         }
465 }
466
467 static void
468 new_ft_handler_cb (EmpathyFTFactory *factory,
469                    EmpathyFTHandler *handler,
470                    GError *error,
471                    gpointer user_data)
472 {
473         if (error) {
474                 empathy_ft_manager_display_error (handler, error);
475         } else {
476                 empathy_ft_manager_add_handler (handler);
477         }
478
479         g_object_unref (handler);
480 }
481
482 static void
483 new_call_handler_cb (EmpathyCallFactory *factory, EmpathyCallHandler *handler,
484         gboolean outgoing, gpointer user_data)
485 {
486         EmpathyCallWindow *window;
487
488         window = empathy_call_window_new (handler);
489         gtk_widget_show (GTK_WIDGET (window));
490 }
491
492 #ifdef ENABLE_DEBUG
493 static void
494 default_log_handler (const gchar *log_domain,
495     GLogLevelFlags log_level,
496     const gchar *message,
497     gpointer user_data)
498 {
499         g_log_default_handler (log_domain, log_level, message, NULL);
500
501         /* G_LOG_DOMAIN = "empathy". No need to send empathy messages to the
502          * debugger as they already have in empathy_debug. */
503         if (log_level != G_LOG_LEVEL_DEBUG
504             || tp_strdiff (log_domain, G_LOG_DOMAIN)) {
505                 EmpathyDebugger *dbg;
506                 GTimeVal now;
507
508                 dbg = empathy_debugger_get_singleton ();
509                 g_get_current_time (&now);
510
511                 empathy_debugger_add_message (dbg, &now, log_domain,
512                                               log_level, message);
513         }
514 }
515 #endif /* ENABLE_DEBUG */
516
517 int
518 main (int argc, char *argv[])
519 {
520         guint32            startup_timestamp;
521 #if HAVE_GEOCLUE
522         EmpathyLocationManager *location_manager = NULL;
523 #endif
524         EmpathyStatusIcon *icon;
525         EmpathyDispatcher *dispatcher;
526         EmpathyAccountManager *account_manager;
527         EmpathyLogManager *log_manager;
528         EmpathyChatroomManager *chatroom_manager;
529         EmpathyCallFactory *call_factory;
530         EmpathyFTFactory  *ft_factory;
531         GtkWidget         *window;
532         MissionControl    *mc;
533         EmpathyIdle       *idle;
534         gboolean           autoconnect = TRUE;
535         gboolean           no_connect = FALSE;
536         gboolean           hide_contact_list = FALSE;
537         gboolean           accounts_dialog = FALSE;
538         GError            *error = NULL;
539         TpDBusDaemon      *dbus_daemon;
540         GOptionEntry       options[] = {
541                 { "no-connect", 'n',
542                   0, G_OPTION_ARG_NONE, &no_connect,
543                   N_("Don't connect on startup"),
544                   NULL },
545                 { "hide-contact-list", 'h',
546                   0, G_OPTION_ARG_NONE, &hide_contact_list,
547                   N_("Don't show the contact list on startup"),
548                   NULL },
549                 { "accounts", 'a',
550                   0, G_OPTION_ARG_NONE, &accounts_dialog,
551                   N_("Show the accounts dialog"),
552                   NULL },
553                 { "version", 'v',
554                   G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, NULL, NULL },
555                 { NULL }
556         };
557
558         /* Init */
559         g_thread_init (NULL);
560         empathy_init ();
561
562         if (!gtk_init_with_args (&argc, &argv,
563                                  N_("- Empathy Instant Messenger"),
564                                  options, GETTEXT_PACKAGE, &error)) {
565                 g_warning ("Error in empathy init: %s", error->message);
566                 return EXIT_FAILURE;
567         }
568
569         empathy_gtk_init ();
570         g_set_application_name (_(PACKAGE_NAME));
571         g_setenv ("PULSE_PROP_media.role", "phone", TRUE);
572
573         gst_init (&argc, &argv);
574
575 #if HAVE_LIBCHAMPLAIN
576         gtk_clutter_init (&argc, &argv);
577 #endif
578
579         gtk_window_set_default_icon_name ("empathy");
580         textdomain (GETTEXT_PACKAGE);
581
582 #ifdef ENABLE_DEBUG
583         /* Set up debugger */
584         g_log_set_default_handler (default_log_handler, NULL);
585 #endif
586
587         /* Setting up the bacon connection */
588         startup_timestamp = get_startup_timestamp ();
589         connection = bacon_message_connection_new ("empathy");
590         if (connection != NULL) {
591                 if (!bacon_message_connection_get_is_server (connection)) {
592                         gchar *message;
593
594                         if (accounts_dialog) {
595                                 DEBUG ("Showing accounts dialog from existing Empathy instance");
596
597                                 message = g_strdup ("accounts");
598
599                         } else {
600
601                                 DEBUG ("Activating existing instance");
602
603                                 message = g_strdup_printf ("%" G_GUINT32_FORMAT,
604                                                            startup_timestamp);
605                         }
606
607                         bacon_message_connection_send (connection, message);
608
609                         /* We never popup a window, so tell startup-notification
610                          * that we are done. */
611                         gdk_notify_startup_complete ();
612
613                         g_free (message);
614                         bacon_message_connection_free (connection);
615
616                         return EXIT_SUCCESS;
617                 }
618         } else {
619                 g_warning ("Cannot create the 'empathy' bacon connection.");
620         }
621
622         /* Take well-known name */
623         dbus_daemon = tp_dbus_daemon_dup (&error);
624         if (error == NULL) {
625                 if (!tp_dbus_daemon_request_name (dbus_daemon,
626                                                   "org.gnome.Empathy",
627                                                   TRUE, &error)) {
628                         DEBUG ("Failed to request well-known name: %s",
629                                error ? error->message : "no message");
630                         g_clear_error (&error);
631                 }
632                 g_object_unref (dbus_daemon);
633         } else {
634                 DEBUG ("Failed to dup dbus daemon: %s",
635                        error ? error->message : "no message");
636                 g_clear_error (&error);
637         }
638
639         /* Setting up MC */
640         mc = empathy_mission_control_dup_singleton ();
641         g_signal_connect (mc, "ServiceEnded",
642                           G_CALLBACK (service_ended_cb),
643                           NULL);
644         g_signal_connect (mc, "Error",
645                           G_CALLBACK (operation_error_cb),
646                           NULL);
647
648         if (accounts_dialog) {
649                 GtkWidget *dialog;
650
651                 dialog = empathy_accounts_dialog_show (NULL, NULL);
652                 g_signal_connect (dialog, "destroy",
653                                   G_CALLBACK (gtk_main_quit),
654                                   NULL);
655
656                 gtk_main ();
657                 return 0;
658         }
659
660         /* Setting up Idle */
661         idle = empathy_idle_dup_singleton ();
662         empathy_idle_set_auto_away (idle, TRUE);
663         use_nm_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_NM, idle);
664         empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_NM,
665                                  use_nm_notify_cb, idle);
666
667         /* Autoconnect */
668         empathy_conf_get_bool (empathy_conf_get (),
669                                EMPATHY_PREFS_AUTOCONNECT,
670                                &autoconnect);
671         if (autoconnect && ! no_connect &&
672                 tp_connection_presence_type_cmp_availability (empathy_idle_get_state
673                         (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) {
674                 empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
675         }
676
677         /* account management */
678         account_manager = empathy_account_manager_dup_singleton ();
679
680         create_salut_account ();
681
682         /* Setting up UI */
683         window = empathy_main_window_show ();
684         icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);
685
686         if (connection) {
687                 /* We se the callback here because we need window */
688                 bacon_message_connection_set_callback (connection,
689                                                        on_bacon_message_received,
690                                                        window);
691         }
692
693         /* Handle channels */
694         dispatcher = empathy_dispatcher_dup_singleton ();
695         g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);
696
697         /* Logging */
698         log_manager = empathy_log_manager_dup_singleton ();
699         empathy_log_manager_observe (log_manager, dispatcher);
700
701         chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
702         empathy_chatroom_manager_observe (chatroom_manager, dispatcher);
703
704         notify_init (_(PACKAGE_NAME));
705         /* Create the call factory */
706         call_factory = empathy_call_factory_initialise ();
707         g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
708                 G_CALLBACK (new_call_handler_cb), NULL);
709         /* Create the FT factory */
710         ft_factory = empathy_ft_factory_dup_singleton ();
711         g_signal_connect (ft_factory, "new-ft-handler",
712                 G_CALLBACK (new_ft_handler_cb), NULL);
713         g_signal_connect (ft_factory, "new-incoming-transfer",
714                 G_CALLBACK (new_incoming_transfer_cb), NULL);
715
716         /* Location mananger */
717 #if HAVE_GEOCLUE
718         location_manager = empathy_location_manager_dup_singleton ();
719 #endif
720
721         gtk_main ();
722
723         empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
724
725         g_object_unref (mc);
726         g_object_unref (idle);
727         g_object_unref (icon);
728         g_object_unref (account_manager);
729         g_object_unref (log_manager);
730         g_object_unref (dispatcher);
731         g_object_unref (chatroom_manager);
732 #if HAVE_GEOCLUE
733         g_object_unref (location_manager);
734 #endif
735         g_object_unref (ft_factory);
736
737         notify_uninit ();
738
739         return EXIT_SUCCESS;
740 }
741