~ubuntu-branches/ubuntu/natty/empathy/natty-updates

« back to all changes in this revision

Viewing changes to src/empathy-call-chandler.c

Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
19
19
 */
20
20
 
21
 
#include <config.h>
22
 
 
23
 
#include <stdlib.h>
24
 
 
25
 
#include <glib.h>
26
 
#include <glib/gi18n.h>
27
21
#include <gtk/gtk.h>
28
22
 
29
 
#include <libgnomevfs/gnome-vfs.h>
30
 
 
31
23
#include <libmissioncontrol/mission-control.h>
32
24
 
 
25
#include <libempathy/empathy-tp-call.h>
33
26
#include <libempathy/empathy-chandler.h>
 
27
#include <libempathy/empathy-debug.h>
34
28
#include <libempathy/empathy-utils.h>
35
 
#include <libempathy/empathy-tp-call.h>
36
 
#include <libempathy/empathy-debug.h>
37
29
 
38
30
#include <libempathy-gtk/empathy-call-window.h>
39
31
 
40
 
#define DEBUG_DOMAIN "EmpathyCall"
41
 
 
42
 
#define BUS_NAME "org.gnome.Empathy.CallChandler"
43
 
#define OBJECT_PATH "/org/gnome/Empathy/CallChandler"
 
32
#define DEBUG_DOMAIN "CallChandler"
44
33
 
45
34
static guint nb_calls = 0;
46
35
 
47
36
static void
48
 
call_chandler_weak_notify (gpointer  data,
49
 
                           GObject  *where_the_object_was)
 
37
weak_notify (gpointer data,
 
38
             GObject *where_the_object_was)
50
39
{
51
 
        nb_calls--;
52
 
        if (nb_calls == 0) {
53
 
                empathy_debug (DEBUG_DOMAIN, "No more calls, leaving...");
54
 
                gtk_main_quit ();
55
 
        }
 
40
  nb_calls--;
 
41
  if (nb_calls == 0)
 
42
    {
 
43
      empathy_debug (DEBUG_DOMAIN, "No more calls, leaving...");
 
44
      gtk_main_quit ();
 
45
    }
56
46
}
57
47
 
58
48
static void
59
 
call_chandler_new_channel_cb (EmpathyChandler *chandler,
60
 
                              TpConn          *tp_conn,
61
 
                              TpChan          *tp_chan,
62
 
                              MissionControl  *mc)
 
49
new_channel_cb (EmpathyChandler *chandler,
 
50
                TpConn *connection,
 
51
                TpChan *channel,
 
52
                MissionControl *mc)
63
53
{
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);
 
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);
77
62
}
78
63
 
79
64
int
80
65
main (int argc, char *argv[])
81
66
{
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;
 
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;
111
87
}
112