]> git.0d.be Git - empathy.git/blob - src/empathy-call-chandler.c
Revert "merge git work"
[empathy.git] / src / empathy-call-chandler.c
1 /*
2  *  Copyright (C) 2007 Elliot Fairweather
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2.1 of the License, or (at your option) any later version.
8  *
9  *  This library 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  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with this library; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  *  Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
19  */
20
21 #include <config.h>
22
23 #include <stdlib.h>
24
25 #include <glib.h>
26 #include <glib/gi18n.h>
27 #include <gtk/gtk.h>
28
29 #include <libgnomevfs/gnome-vfs.h>
30
31 #include <libmissioncontrol/mission-control.h>
32
33 #include <libempathy/empathy-chandler.h>
34 #include <libempathy/empathy-utils.h>
35 #include <libempathy/empathy-tp-call.h>
36 #include <libempathy/empathy-debug.h>
37
38 #include <libempathy-gtk/empathy-call-window.h>
39
40 #define DEBUG_DOMAIN "EmpathyCall"
41
42 #define BUS_NAME "org.gnome.Empathy.CallChandler"
43 #define OBJECT_PATH "/org/gnome/Empathy/CallChandler"
44
45 static guint nb_calls = 0;
46
47 static void
48 call_chandler_weak_notify (gpointer  data,
49                            GObject  *where_the_object_was)
50 {
51         nb_calls--;
52         if (nb_calls == 0) {
53                 empathy_debug (DEBUG_DOMAIN, "No more calls, leaving...");
54                 gtk_main_quit ();
55         }
56 }
57
58 static void
59 call_chandler_new_channel_cb (EmpathyChandler *chandler,
60                               TpConn          *tp_conn,
61                               TpChan          *tp_chan,
62                               MissionControl  *mc)
63 {
64         EmpathyTpCall *call;
65         McAccount     *account;
66         GtkWidget     *window;
67
68         account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
69
70         call = empathy_tp_call_new (account, tp_chan);
71         window = empathy_call_window_show (call);
72         g_object_unref (account);
73         g_object_unref (call);
74
75         nb_calls++;
76         g_object_weak_ref (G_OBJECT (window), call_chandler_weak_notify, NULL);
77 }
78
79 int
80 main (int argc, char *argv[])
81 {
82         EmpathyChandler *chandler;
83         MissionControl  *mc;
84
85         empathy_debug_set_log_file_from_env ();
86
87         bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
88         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
89         textdomain (GETTEXT_PACKAGE);
90
91         gtk_init (&argc, &argv);
92
93         gtk_window_set_default_icon_name ("empathy");
94         gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
95                                            PKGDATADIR G_DIR_SEPARATOR_S "icons");
96
97         mc = empathy_mission_control_new ();
98         chandler = empathy_chandler_new (BUS_NAME, OBJECT_PATH);
99         g_signal_connect (chandler, "new-channel",
100                           G_CALLBACK (call_chandler_new_channel_cb),
101                           mc);
102
103         empathy_debug (DEBUG_DOMAIN, "Ready to handle new streamed media channels");
104
105         gtk_main ();
106
107         g_object_unref (chandler);
108         g_object_unref (mc);
109
110         return EXIT_SUCCESS;
111 }
112