~ubuntu-branches/ubuntu/precise/empathy/precise-proposed-201205180810

« back to all changes in this revision

Viewing changes to src/empathy-call.c

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis, Brian Curtis, Ken VanDine
  • Date: 2011-06-01 10:35:24 UTC
  • mfrom: (1.1.70 upstream) (6.3.44 experimental)
  • Revision ID: james.westby@ubuntu.com-20110601103524-wx3wgp71394730jt
Tags: 3.1.1-1ubuntu1
[ Brian Curtis ]
* Merge with Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Drop geoclue/mapping build-depends (they are in Universe)
  - Add Vcz-Bzr link
  - Add Suggests on telepathy-idle
  - Bump telepathy-butterfly, telepathy-haze to recommends
  - Don't recommend the freedesktop sound theme we have an ubuntu one
  - Add build depend for libunity-dev
* debian/rules:
  - Use autoreconf.mk
  - Disable map and location
* debian/empathy.install:
  - Install message indicator configuration
* debian/indicators/empathy:
  - Message indicator configuration
* debian/patches/01_lpi.patch:
  - Add Launchpad integration
* debian/patches/10_use_notify_osd_icons.patch:
  - Use the notify-osd image for new messages
* debian/patches/34_start_raised_execpt_in_session.patch
  - If not started with the session, we should always raise
* debian/patches/36_chat_window_default_size.patch:
  - Make the default chat window size larger
* debian/patches/37_facebook_default.patch:
  - Make facebook the default chat account type
* debian/patches/38_lp_569289.patch
  - Set freenode as default IRC network for new IRC accounts 
* debian/patches/41_unity_launcher_progress.patch
  - Display file transfer progress in the unity launcher

[ Ken VanDine ]
* debian/control
  - build depend on libgcr-3-dev instead of libgcr-dev
  - dropped build depends for libindicate, we will use telepathy-indicator
  - Depend on dconf-gsettings-backend | gsettings-backend
  - Added a Recommends for telepathy-indicator
* +debian/empathy.gsettings-override
  - Added an override for notifications-focus
* debian/patches/series
  - commented out 23_idomessagedialog_for_voip_and_ft.patch, until ido has 
    been ported to gtk3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2007-2011 Collabora Ltd.
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
18
 
 *
19
 
 * Authors: Xavier Claessens <xclaesse@gmail.com>
20
 
 *          Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
21
 
 */
22
 
 
23
 
#include <config.h>
24
 
 
25
 
#include <glib.h>
26
 
#include <glib/gi18n.h>
27
 
#include <gtk/gtk.h>
28
 
 
29
 
#include <telepathy-glib/debug-sender.h>
30
 
 
31
 
#include <telepathy-yell/telepathy-yell.h>
32
 
 
33
 
#include <libempathy-gtk/empathy-ui-utils.h>
34
 
 
35
 
#include "empathy-call-window.h"
36
 
#include "empathy-call-factory.h"
37
 
 
38
 
#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
39
 
#include <libempathy/empathy-debug.h>
40
 
 
41
 
#include <gst/gst.h>
42
 
 
43
 
/* Exit after $TIMEOUT seconds if not displaying any call window */
44
 
#define TIMEOUT 60
45
 
 
46
 
static guint nb_windows = 0;
47
 
static guint timeout_id = 0;
48
 
static gboolean use_timer = TRUE;
49
 
 
50
 
static gboolean
51
 
timeout_cb (gpointer data)
52
 
{
53
 
  DEBUG ("Timing out; exiting");
54
 
 
55
 
  gtk_main_quit ();
56
 
  return FALSE;
57
 
}
58
 
 
59
 
static void
60
 
start_timer (void)
61
 
{
62
 
  if (!use_timer)
63
 
    return;
64
 
 
65
 
  if (timeout_id != 0)
66
 
    return;
67
 
 
68
 
  DEBUG ("Start timer");
69
 
 
70
 
  timeout_id = g_timeout_add_seconds (TIMEOUT, timeout_cb, NULL);
71
 
}
72
 
 
73
 
static void
74
 
stop_timer (void)
75
 
{
76
 
  if (timeout_id == 0)
77
 
    return;
78
 
 
79
 
  DEBUG ("Stop timer");
80
 
 
81
 
  g_source_remove (timeout_id);
82
 
  timeout_id = 0;
83
 
}
84
 
 
85
 
static void
86
 
call_window_destroy_cb (EmpathyCallWindow *window,
87
 
    gpointer user_data)
88
 
{
89
 
  nb_windows--;
90
 
 
91
 
  if (nb_windows > 0)
92
 
    return;
93
 
 
94
 
  start_timer ();
95
 
}
96
 
 
97
 
static void
98
 
new_call_handler_cb (EmpathyCallFactory *factory,
99
 
    EmpathyCallHandler *handler,
100
 
    gboolean outgoing,
101
 
    gpointer user_data)
102
 
{
103
 
  EmpathyCallWindow *window;
104
 
 
105
 
  DEBUG ("Create a new call window");
106
 
 
107
 
  window = empathy_call_window_new (handler);
108
 
 
109
 
  nb_windows++;
110
 
  stop_timer ();
111
 
 
112
 
  g_signal_connect (window, "destroy",
113
 
      G_CALLBACK (call_window_destroy_cb), NULL);
114
 
 
115
 
  gtk_widget_show (GTK_WIDGET (window));
116
 
}
117
 
 
118
 
int
119
 
main (int argc,
120
 
    char *argv[])
121
 
{
122
 
  GOptionContext *optcontext;
123
 
  GOptionEntry options[] = {
124
 
      { NULL }
125
 
  };
126
 
#ifdef ENABLE_DEBUG
127
 
  TpDebugSender *debug_sender;
128
 
#endif
129
 
  EmpathyCallFactory *call_factory;
130
 
  GError *error = NULL;
131
 
 
132
 
  /* Init */
133
 
  g_thread_init (NULL);
134
 
 
135
 
  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
136
 
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
137
 
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
138
 
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);
139
 
 
140
 
  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
141
 
    g_print ("%s\nRun '%s --help' to see a full list of available command "
142
 
        "line options.\n",
143
 
        error->message, argv[0]);
144
 
    g_warning ("Error in empathy-call init: %s", error->message);
145
 
    return EXIT_FAILURE;
146
 
  }
147
 
 
148
 
  g_option_context_free (optcontext);
149
 
 
150
 
  tpy_cli_init ();
151
 
 
152
 
  empathy_gtk_init ();
153
 
  g_set_application_name (_("Empathy Audio/Video Client"));
154
 
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);
155
 
 
156
 
  gtk_window_set_default_icon_name ("empathy");
157
 
  textdomain (GETTEXT_PACKAGE);
158
 
 
159
 
#ifdef ENABLE_DEBUG
160
 
  /* Set up debug sender */
161
 
  debug_sender = tp_debug_sender_dup ();
162
 
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
163
 
#endif
164
 
 
165
 
  call_factory = empathy_call_factory_initialise ();
166
 
 
167
 
  g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
168
 
      G_CALLBACK (new_call_handler_cb), NULL);
169
 
 
170
 
  if (!empathy_call_factory_register (call_factory, &error))
171
 
    {
172
 
      g_critical ("Failed to register Handler: %s", error->message);
173
 
      g_error_free (error);
174
 
      return EXIT_FAILURE;
175
 
    }
176
 
 
177
 
  if (g_getenv ("EMPATHY_PERSIST") != NULL)
178
 
    {
179
 
      DEBUG ("Disable timer");
180
 
 
181
 
      use_timer = FALSE;
182
 
    }
183
 
 
184
 
  start_timer ();
185
 
 
186
 
  gtk_main ();
187
 
 
188
 
  g_object_unref (call_factory);
189
 
 
190
 
#ifdef ENABLE_DEBUG
191
 
  g_object_unref (debug_sender);
192
 
#endif
193
 
 
194
 
  return EXIT_SUCCESS;
195
 
}