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