2 * Copyright (C) 2007-2010 Collabora Ltd.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
20 * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
26 #include <glib/gi18n.h>
29 #include <telepathy-glib/debug-sender.h>
31 #include <libempathy/empathy-idle.h>
32 #include <libempathy-gtk/empathy-ui-utils.h>
34 #include "empathy-chat-manager.h"
36 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
37 #include <libempathy/empathy-debug.h>
39 /* Exit after $TIMEOUT seconds if not displaying any call window */
42 #define EMPATHY_CHAT_DBUS_NAME "org.gnome.Empathy.Chat"
44 static GtkApplication *app = NULL;
45 static gboolean app_held = FALSE;
46 static guint timeout_id = 0;
47 static gboolean use_timer = TRUE;
55 DEBUG ("Start timer");
58 g_application_release (G_APPLICATION (app));
69 g_application_hold (G_APPLICATION (app));
74 handled_chats_changed_cb (EmpathyChatManager *mgr,
92 GOptionContext *optcontext;
93 GOptionEntry options[] = {
97 TpDebugSender *debug_sender;
99 EmpathyChatManager *chat_mgr;
100 GError *error = NULL;
104 g_thread_init (NULL);
106 optcontext = g_option_context_new (N_("- Empathy Chat Client"));
107 g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
108 g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);
110 if (!g_option_context_parse (optcontext, &argc, &argv, &error))
112 g_print ("%s\nRun '%s --help' to see a full list of available command "
114 error->message, argv[0]);
115 g_warning ("Error in empathy-av init: %s", error->message);
119 g_option_context_free (optcontext);
123 gtk_window_set_default_icon_name ("empathy");
124 textdomain (GETTEXT_PACKAGE);
126 app = gtk_application_new (EMPATHY_CHAT_DBUS_NAME, G_APPLICATION_IS_SERVICE);
129 /* Set up debug sender */
130 debug_sender = tp_debug_sender_dup ();
131 g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
134 /* Setting up Idle */
135 idle = empathy_idle_dup_singleton ();
137 chat_mgr = empathy_chat_manager_dup_singleton ();
139 g_signal_connect (chat_mgr, "handled-chats-changed",
140 G_CALLBACK (handled_chats_changed_cb), NULL);
142 if (g_getenv ("EMPATHY_PERSIST") != NULL)
144 DEBUG ("Disable timer");
149 /* the inactivity timeout can only be set while the application is held */
150 g_application_hold (G_APPLICATION (app));
151 g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
154 g_application_release (G_APPLICATION (app));
164 DEBUG ("Waiting for text channels to handle");
166 g_application_run (G_APPLICATION (app), argc, argv);
168 g_object_unref (app);
169 g_object_unref (idle);
170 g_object_unref (chat_mgr);
173 g_object_unref (debug_sender);