]> git.0d.be Git - empathy.git/blob - src/empathy-call-chandler.c
2b359ec24bcf42819fc803eec151dc7ec4c17a5b
[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 <gtk/gtk.h>
22
23 #include <libmissioncontrol/mission-control.h>
24
25 #include <extensions/extensions.h>
26 #include <libempathy/empathy-tp-call.h>
27 #include <libempathy/empathy-chandler.h>
28 #include <libempathy/empathy-debug.h>
29 #include <libempathy/empathy-utils.h>
30
31 #include <libempathy-gtk/empathy-call-window.h>
32
33 #define DEBUG_DOMAIN "CallChandler"
34
35 static guint nb_calls = 0;
36
37 static void
38 weak_notify (gpointer data,
39              GObject *where_the_object_was)
40 {
41   nb_calls--;
42   if (nb_calls == 0)
43     {
44       empathy_debug (DEBUG_DOMAIN, "No more calls, leaving...");
45       gtk_main_quit ();
46     }
47 }
48
49 static void
50 new_channel_cb (EmpathyChandler *chandler,
51                 TpConn *connection,
52                 TpChan *channel,
53                 MissionControl *mc)
54 {
55   EmpathyTpCall *call;
56
57   call = empathy_tp_call_new (connection, channel);
58   empathy_call_window_new (call);
59   g_object_unref (call);
60
61   nb_calls++;
62   g_object_weak_ref (G_OBJECT (call), weak_notify, NULL);
63 }
64
65 int
66 main (int argc, char *argv[])
67 {
68   MissionControl *mc;
69   EmpathyChandler *chandler;
70
71   gtk_init (&argc, &argv);
72   emp_cli_init ();
73
74   mc = empathy_mission_control_new ();
75
76   chandler = empathy_chandler_new ("org.gnome.Empathy.CallChandler",
77       "/org/gnome/Empathy/CallChandler");
78   g_signal_connect (chandler, "new-channel",
79       G_CALLBACK (new_channel_cb), mc);
80
81   empathy_debug (DEBUG_DOMAIN, "Ready to handle new streamed media channels");
82
83   gtk_main ();
84
85   g_object_unref (chandler);
86   g_object_unref (mc);
87
88   return EXIT_SUCCESS;
89 }