~ubuntu-branches/ubuntu/maverick/ekiga/maverick

« back to all changes in this revision

Viewing changes to src/endpoints/ekiga.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Eugen Dedu, Eugen Dedu, Loic Minier
  • Date: 2008-09-27 10:00:00 UTC
  • mfrom: (1.1.8 upstream)
  • mto: (1.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20080927100000-l5k5werb6czr5b3h
Tags: 3.0.1-1
[ Eugen Dedu ]
* New version.  (Closes: #500089).
* Add our own changelog file in /usr/share/doc.
* Remove gnomemeeting transitional package.
* Discover new interfaces.  (Closes: #488199).
* Compile with dbus support.  (Closes: #467212).
* Numeric keypad inserts digits at correct position.  (Closes: #440159).
* Use libnotify upon call.  (Closes: #412604).
* Symlink identical GNOME help files, to reduce size.  (Closes: #505536).
* Explicitely build-depends on a few dev packages, even if they were
  pulled out anyway by the other dependencies.

[ Loic Minier ]
* Use clean:: instead of clean: in rules.
* Don't disable Uploaders: generation for control.in -> control generation
  in rules.
* Fix some tabs which were size 4 anyway.
* Generate a PO template during build by calling intltool-update -p in
  install; thanks Ubuntu and Martin Pitt; closes: #505535.
* Also let the -dbg depend on ${misc:Depends}.
* Cleanup rules; in particular, use dpkg-parsechangelog and honor
  distclean/clean failures, remove old clean rules, commented out stuff,
  gtk-only stuff.
* Pass -s to dh_* in binary-arch.
* Use debian/*.links and debian/*.manpages instead of symlink manually or
  passing files to dh_installman.
* Use ftp.gnome.org in copyright.
* Switch to quilt and fix target deps in the process; build-dep on quilt
  instead of dpatch; rename news.dpatch to 00_news.patch and refresh;
  replace 00list with series.
* Install autotools-dev config.guess and .sub after patching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 */
37
37
 
38
38
 
39
 
#include "../../config.h"
 
39
#include "config.h"
40
40
 
41
41
#include "ekiga.h"
42
42
#include "callbacks.h"
43
 
#include "audio.h"
44
 
#if 0
45
 
#include "ils.h"
46
 
#endif 
47
 
#include "urlhandler.h"
48
 
#include "addressbook.h"
49
43
#include "preferences.h"
50
 
#include "chat.h"
51
 
#include "callshistory.h"
52
 
#include "druid.h"
53
 
#include "tools.h"
 
44
#include "chat-window.h"
 
45
#include "assistant.h"
54
46
#include "statusicon.h"
55
 
#include "history.h"
 
47
#include "accounts.h"
56
48
#include "main.h"
57
49
#include "misc.h"
58
50
 
59
 
#ifdef HAS_DBUS
 
51
#ifdef HAVE_DBUS
60
52
#include "dbus.h"
61
53
#endif
62
54
 
63
55
#include "gmdialog.h"
64
56
#include "gmstockicons.h"
65
57
#include "gmconf.h"
66
 
#include "gmcontacts.h"
 
58
 
 
59
#include "engine.h"
67
60
 
68
61
#define new PNEW
69
62
 
75
68
  : PProcess("", "", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
76
69
 
77
70
{
78
 
  /* no endpoint for the moment */
79
 
  endpoint = NULL;
80
 
  url_handler = NULL;
81
 
 
82
 
  
83
 
  addressbook_window = NULL;
84
 
 
85
71
  GM = this;
86
72
  
87
 
  endpoint = new GMManager ();
88
 
  
89
73
  call_number = 0;
 
74
 
 
75
  service_core = NULL;
 
76
  assistant_window = NULL;
 
77
  prefs_window = NULL;
90
78
}
91
79
 
92
80
 
96
84
}
97
85
 
98
86
 
99
 
void 
100
 
GnomeMeeting::Connect (PString url)
101
 
{
102
 
  /* If incoming connection, then answer it */
103
 
  if (endpoint->GetCallingState () == GMManager::Called) {
104
 
 
105
 
    gm_history_window_insert (history_window, _("Answering incoming call"));
106
 
 
107
 
    url_handler = new GMURLHandler ("", FALSE);
108
 
  }
109
 
  else if (endpoint->GetCallingState () == GMManager::Standby
110
 
           && !GMURL (url).IsEmpty ()) {
111
 
    
112
 
    /* Update the GUI */
113
 
    gm_main_window_set_call_url (main_window, url);
114
 
 
115
 
    /* if we call somebody, and if the URL is not empty */
116
 
    url_handler = new GMURLHandler (url);
117
 
  }
118
 
}
119
 
 
120
 
 
121
 
void
122
 
GnomeMeeting::Disconnect (H323Connection::CallEndReason reason)
123
 
{
124
 
  PString call_token;
125
 
 
126
 
  call_token = endpoint->GetCurrentCallToken ();
127
 
  
128
 
  /* if we are trying to call somebody */
129
 
  if (endpoint->GetCallingState () == GMManager::Calling) {
130
 
 
131
 
    endpoint->ClearCall (call_token, reason);
132
 
  }
133
 
  else {
134
 
 
135
 
    /* if we are in call with somebody */
136
 
    if (endpoint->GetCallingState () == GMManager::Connected) {
137
 
 
138
 
      endpoint->ClearAllCalls (OpalConnection::EndedByLocalUser, FALSE);
139
 
    }
140
 
    else if (endpoint->GetCallingState () == GMManager::Called) {
141
 
 
142
 
      endpoint->ClearCall (call_token,
143
 
                           OpalConnection::EndedByAnswerDenied);
144
 
    }
145
 
    else {
146
 
      endpoint->ClearCall (call_token,
147
 
                           OpalConnection::EndedByAnswerDenied);
148
 
    }
149
 
  }
150
 
}
151
 
 
152
 
 
153
 
void
154
 
GnomeMeeting::Init ()
155
 
{
156
 
  /* Init the endpoint */
157
 
  endpoint->Init ();
158
 
}
159
 
 
160
 
 
161
87
void
162
88
GnomeMeeting::Exit ()
163
89
{
164
 
  RemoveManager ();
 
90
  PWaitAndSignal m(ep_var_mutex);
165
91
 
166
 
  if (addressbook_window) 
167
 
    gtk_widget_destroy (addressbook_window);  
168
 
  addressbook_window = NULL;
169
 
  
170
92
  if (prefs_window)
171
93
    gtk_widget_destroy (prefs_window);
172
94
  prefs_window = NULL;
173
95
  
174
 
  if (pc2phone_window)
175
 
    gtk_widget_destroy (pc2phone_window);
176
 
  pc2phone_window = NULL;
177
 
  
178
 
  if (history_window)
179
 
    gtk_widget_destroy (history_window);
180
 
  history_window = NULL;
181
 
  
182
96
  if (main_window)
183
97
    gtk_widget_destroy (main_window);
184
98
  main_window = NULL;
185
99
  
186
 
  if (druid_window)
187
 
    gtk_widget_destroy (druid_window);
188
 
  druid_window = NULL;
 
100
  if (assistant_window)
 
101
    gtk_widget_destroy (assistant_window);
 
102
  assistant_window = NULL;
189
103
  
190
104
  if (accounts_window)
191
105
    gtk_widget_destroy (accounts_window);
192
106
  accounts_window = NULL;
193
 
  
194
 
  if (chat_window)
195
 
    gtk_widget_destroy (chat_window);
196
 
  chat_window = NULL;
197
 
  
 
107
 
198
108
  if (statusicon)
199
 
    gtk_widget_destroy (statusicon);
 
109
    g_object_unref (statusicon);
200
110
  statusicon = NULL;
201
111
  
202
 
#ifdef HAS_DBUS
 
112
#ifdef HAVE_DBUS
203
113
  if (dbus_component)
204
114
    g_object_unref (dbus_component);
205
115
  dbus_component = NULL;
206
116
#endif
 
117
 
 
118
  if (service_core)
 
119
    delete service_core;
 
120
  service_core = NULL;
207
121
}
208
122
 
209
123
 
210
 
BOOL
 
124
bool
211
125
GnomeMeeting::DetectInterfaces ()
212
126
{
 
127
  //TODO
213
128
  PString config_interface;
214
129
  PString iface_noip;
215
130
  PString ip;
217
132
 
218
133
  PINDEX i = 0;
219
134
  PINDEX pos = 0;
220
 
  BOOL res = FALSE;
 
135
  bool res = FALSE;
221
136
 
222
137
  gchar *conf_interface = NULL;
223
 
  
 
138
 
224
139
  PWaitAndSignal m(iface_access_mutex);
225
 
  
 
140
 
226
141
  /* Detect the valid interfaces */
227
142
  res = PIPSocket::GetInterfaceTable (ifaces);
228
143
  interfaces.RemoveAll ();
229
 
  
 
144
 
230
145
  conf_interface = gm_conf_get_string (PROTOCOLS_KEY "interface");
231
146
  config_interface = conf_interface;
232
147
  g_free (conf_interface);
233
 
  
 
148
 
234
149
  pos = config_interface.Find("[");
235
150
  if (pos != P_MAX_INDEX)
236
151
    iface_noip = config_interface.Left (pos).Trim ();
237
152
  while (i < ifaces.GetSize ()) {
238
 
    
 
153
 
239
154
    ip = " [" + ifaces [i].GetAddress ().AsString () + "]";
240
 
    
 
155
 
241
156
    if (ifaces [i].GetName () + ip == config_interface || ifaces [i].GetName () == iface_noip) 
242
157
      break;
243
 
      
 
158
 
244
159
    i++;
245
160
  }
246
161
 
274
189
        interfaces += interfaces [0];
275
190
      interfaces [0] = ifaces [pos].GetName () + ip;
276
191
    }
277
 
    
 
192
 
278
193
    i++;
279
194
  }
280
195
 
281
 
  
282
 
  /* Update the GUI, if it is already there */
283
 
  if (prefs_window)
284
 
    gm_prefs_window_update_interfaces_list (prefs_window, 
285
 
                                            interfaces);
286
 
  
287
196
  return res;
288
197
}
289
198
 
290
199
 
291
 
BOOL
292
 
GnomeMeeting::DetectDevices ()
293
 
{
294
 
  gchar *audio_plugin = NULL;
295
 
  gchar *video_plugin = NULL;
296
 
 
297
 
  PINDEX fake_idx;
298
 
 
299
 
  audio_plugin = gm_conf_get_string (AUDIO_DEVICES_KEY "plugin");
300
 
  video_plugin = gm_conf_get_string (VIDEO_DEVICES_KEY "plugin");
301
 
 
302
 
  PWaitAndSignal m(dev_access_mutex);
303
 
  
304
 
 
305
 
  /* Detect the devices */
306
 
  gnomemeeting_sound_daemons_suspend ();
307
 
 
308
 
  
309
 
  /* Detect the plugins */
310
 
  audio_managers = PSoundChannel::GetDriverNames ();
311
 
  video_managers = PVideoInputDevice::GetDriverNames ();
312
 
  
313
 
  fake_idx = video_managers.GetValuesIndex (PString ("FakeVideo"));
314
 
  if (fake_idx != P_MAX_INDEX)
315
 
    video_managers.RemoveAt (fake_idx);
316
 
 
317
 
  PTRACE (1, "Detected audio plugins: " << setfill (',') << audio_managers
318
 
          << setfill (' '));
319
 
  PTRACE (1, "Detected video plugins: " << setfill (',') << video_managers
320
 
          << setfill (' '));
321
 
 
322
 
#ifdef HAX_IXJ
323
 
  audio_managers += PString ("Quicknet");
324
 
#endif
325
 
 
326
 
  PTRACE (1, "Detected audio plugins: " << setfill (',') << audio_managers
327
 
          << setfill (' '));
328
 
  PTRACE (1, "Detected video plugins: " << setfill (',') << video_managers
329
 
          << setfill (' '));
330
 
  
331
 
 
332
 
  fake_idx = video_managers.GetValuesIndex (PString ("Picture"));
333
 
  if (fake_idx == P_MAX_INDEX)
334
 
    return FALSE;
335
 
 
336
 
  /* No audio plugin => Exit */
337
 
  if (audio_managers.GetSize () == 0)
338
 
    return FALSE;
339
 
  
340
 
  
341
 
  /* Detect the devices */
342
 
  video_input_devices = PVideoInputDevice::GetDriversDeviceNames (video_plugin);
343
 
 
344
 
  audio_input_devices = 
345
 
    PSoundChannel::GetDeviceNames (audio_plugin, PSoundChannel::Recorder);
346
 
  audio_output_devices = 
347
 
    PSoundChannel::GetDeviceNames (audio_plugin, PSoundChannel::Player);
348
 
 
349
 
  
350
 
  if (audio_input_devices.GetSize () == 0) 
351
 
    audio_input_devices += PString (_("No device found"));
352
 
  if (audio_output_devices.GetSize () == 0)
353
 
    audio_output_devices += PString (_("No device found"));
354
 
  if (video_input_devices.GetSize () == 0)
355
 
    video_input_devices += PString (_("No device found"));
356
 
 
357
 
 
358
 
  PTRACE (1, "Detected the following audio input devices: "
359
 
          << setfill (',') << audio_input_devices << setfill (' ')
360
 
          << " with plugin " << audio_plugin);
361
 
  PTRACE (1, "Detected the following audio output devices: "
362
 
          << setfill (',') << audio_output_devices << setfill (' ')
363
 
          << " with plugin " << audio_plugin);
364
 
  PTRACE (1, "Detected the following video input devices: "
365
 
          << setfill (',') << video_input_devices << setfill (' ')
366
 
          << " with plugin " << video_plugin);
367
 
  
368
 
  PTRACE (1, "Detected the following audio input devices: " 
369
 
          << setfill (',') << audio_input_devices << setfill (' ') 
370
 
          << " with plugin " << audio_plugin);
371
 
  PTRACE (1, "Detected the following audio output devices: " 
372
 
          << setfill (',') << audio_output_devices << setfill (' ') 
373
 
          << " with plugin " << audio_plugin);
374
 
  PTRACE (1, "Detected the following video input devices: " 
375
 
          << setfill (',') << video_input_devices << setfill (' ')  
376
 
          << " with plugin " << video_plugin);
377
 
 
378
 
  g_free (audio_plugin);
379
 
  g_free (video_plugin);
380
 
 
381
 
  gnomemeeting_sound_daemons_resume ();
382
 
 
383
 
  /* Update the GUI, if it is already there */
384
 
  if (prefs_window)
385
 
    gm_prefs_window_update_devices_list (prefs_window, 
386
 
                                         audio_input_devices,
387
 
                                         audio_output_devices,
388
 
                                         video_input_devices);
389
 
  return TRUE;
390
 
}
391
 
 
392
 
 
393
 
GMManager *
394
 
GnomeMeeting::GetManager ()
395
 
{
396
 
  GMManager *ep = NULL;
 
200
Ekiga::ServiceCore *
 
201
GnomeMeeting::GetServiceCore ()
 
202
{
397
203
  PWaitAndSignal m(ep_var_mutex);
398
 
 
399
 
  ep = endpoint;
400
204
  
401
 
  return ep;
 
205
  return service_core;
402
206
}
403
207
 
404
208
 
417
221
 
418
222
 
419
223
GtkWidget *
420
 
GnomeMeeting::GetPrefsWindow ()
 
224
GnomeMeeting::GetPrefsWindow (bool create)
421
225
{
 
226
  if (!prefs_window && create)
 
227
    prefs_window = gm_prefs_window_new (service_core);
422
228
  return prefs_window;
423
229
}
424
230
 
425
231
 
426
232
GtkWidget *
427
 
GnomeMeeting::GetChatWindow ()
428
 
{
429
 
  return chat_window;
430
 
}
431
 
 
432
 
 
433
 
GtkWidget *
434
 
GnomeMeeting::GetDruidWindow ()
435
 
{
436
 
  return druid_window;
437
 
}
438
 
 
439
 
 
440
 
GtkWidget *
441
 
GnomeMeeting::GetCallsHistoryWindow ()
442
 
{
443
 
  return calls_history_window;
444
 
}
445
 
 
446
 
 
447
 
GtkWidget *
448
 
GnomeMeeting::GetAddressbookWindow ()
449
 
{
450
 
  return addressbook_window;
451
 
}
452
 
 
453
 
 
454
 
GtkWidget *
455
 
GnomeMeeting::GetHistoryWindow ()
456
 
{
457
 
  return history_window;
458
 
}
459
 
 
460
 
 
461
 
GtkWidget *
462
 
GnomeMeeting::GetPC2PhoneWindow ()
463
 
{
464
 
  return pc2phone_window;
 
233
GnomeMeeting::GetAssistantWindow (bool create)
 
234
{
 
235
  if (!assistant_window && create)
 
236
    assistant_window = ekiga_assistant_new (service_core);
 
237
 
 
238
  return assistant_window;
465
239
}
466
240
 
467
241
 
472
246
}
473
247
 
474
248
 
475
 
GtkWidget *
 
249
StatusIcon *
476
250
GnomeMeeting::GetStatusicon ()
477
251
{
478
252
  return statusicon;
479
253
}
480
254
 
481
 
#ifdef HAS_DBUS
482
 
GObject *
483
 
GnomeMeeting::GetDbusComponent ()
484
 
{
485
 
  return dbus_component;
486
 
}
487
 
#endif
488
 
 
489
255
void GnomeMeeting::Main ()
490
256
{
491
257
}
493
259
 
494
260
void GnomeMeeting::BuildGUI ()
495
261
{
496
 
  IncomingCallMode icm = AVAILABLE;
497
 
  BOOL forward_on_busy = FALSE;
498
 
 
499
 
  /* Init the address book */
500
 
  gnomemeeting_addressbook_init (_("On This Computer"), _("Personal"));
501
 
  
502
262
  /* Init the stock icons */
503
263
  gnomemeeting_stock_icons_init ();
504
264
  
505
265
  /* Build the GUI */
506
 
  pc2phone_window = gm_pc2phone_window_new ();  
507
 
  prefs_window = gm_prefs_window_new ();  
508
 
  calls_history_window = gm_calls_history_window_new ();
509
 
  history_window = gm_history_window_new ();
510
 
  chat_window = gm_text_chat_window_new ();
511
 
  addressbook_window = gm_addressbook_window_new ();
512
 
  druid_window = gm_druid_window_new ();
513
 
  accounts_window = gm_accounts_window_new ();
514
 
  main_window = gm_main_window_new ();
515
 
#ifdef HAS_DBUS
516
 
  dbus_component = gnomemeeting_dbus_component_new ();
517
 
#endif
518
 
  statusicon = gm_statusicon_new (); /* must come last (uses the windows) */
519
 
 
520
 
  /* we must put the statusicon in the right state */
521
 
  icm = (IncomingCallMode)
522
 
    gm_conf_get_int (CALL_OPTIONS_KEY "incoming_call_mode"); 
523
 
  forward_on_busy = gm_conf_get_bool (CALL_FORWARDING_KEY "forward_on_busy");
524
 
  gm_statusicon_update_full (statusicon,
525
 
                             GMManager::Standby, icm, forward_on_busy);
526
 
 
 
266
  gtk_window_set_default_icon_name (GM_ICON_LOGO);
 
267
  accounts_window = gm_accounts_window_new (*service_core);
 
268
 
 
269
  statusicon = statusicon_new (*service_core);
 
270
  main_window = gm_main_window_new (*service_core);
 
271
 
527
272
  /* GM is started */
528
 
  gm_history_window_insert (history_window,
529
 
                            _("Started Ekiga %d.%d.%d for user %s"), 
530
 
                            MAJOR_VERSION, MINOR_VERSION, BUILD_NUMBER,
531
 
                            g_get_user_name ());
532
 
 
533
273
  PTRACE (1, "Ekiga version "
534
274
          << MAJOR_VERSION << "." << MINOR_VERSION << "." << BUILD_NUMBER);
535
275
  PTRACE (1, "OPAL version " << OPAL_VERSION);
536
 
  PTRACE (1, "PWLIB version " << PWLIB_VERSION);
537
 
#ifndef DISABLE_GNOME
 
276
  PTRACE (1, "PTLIB version " << PTLIB_VERSION);
 
277
#ifdef HAVE_GNOME
538
278
  PTRACE (1, "GNOME support enabled");
539
279
#else
540
280
  PTRACE (1, "GNOME support disabled");
541
281
#endif
542
 
#ifdef HAS_SDL
543
 
  PTRACE (1, "Fullscreen support enabled");
 
282
#if defined HAVE_XV || defined HAVE_DX
 
283
  PTRACE (1, "Accelerated rendering support enabled");
544
284
#else
545
 
  PTRACE (1, "Fullscreen support disabled");
 
285
  PTRACE (1, "Accelerated rendering support disabled");
546
286
#endif
547
 
#ifdef HAS_DBUS
 
287
#ifdef HAVE_DBUS
548
288
  PTRACE (1, "DBUS support enabled");
549
289
#else
550
290
  PTRACE (1, "DBUS support disabled");
551
291
#endif
552
 
}
553
 
 
554
 
 
555
 
void GnomeMeeting::RemoveManager ()
556
 
{
557
 
  PWaitAndSignal m(ep_var_mutex);
558
 
 
559
 
  if (endpoint) {
560
 
 
561
 
    endpoint->Exit ();
562
 
    delete (endpoint);
563
 
  }
564
 
  
565
 
  endpoint = NULL;
566
 
}
567
 
 
 
292
#ifdef HAVE_GCONF
 
293
  PTRACE (1, "GConf support enabled");
 
294
#else
 
295
  PTRACE (1, "GConf support disabled");
 
296
#endif
 
297
#ifdef HAVE_ESD
 
298
  PTRACE (1, "ESound support enabled");
 
299
#else
 
300
  PTRACE (1, "ESound support disabled");
 
301
#endif
 
302
}
568
303
 
569
304
PStringArray 
570
305
GnomeMeeting::GetInterfaces ()
575
310
}
576
311
 
577
312
 
578
 
PStringArray 
579
 
GnomeMeeting::GetVideoInputDevices ()
580
 
{
581
 
  PWaitAndSignal m(dev_access_mutex);
582
 
 
583
 
  return video_input_devices;
584
 
}
585
 
 
586
 
 
587
 
PStringArray 
588
 
GnomeMeeting::GetAudioInputDevices ()
589
 
{
590
 
  PWaitAndSignal m(dev_access_mutex);
591
 
 
592
 
  return audio_input_devices;
593
 
}
594
 
 
595
 
 
596
 
 
597
 
PStringArray 
598
 
GnomeMeeting::GetAudioOutpoutDevices ()
599
 
{
600
 
  PWaitAndSignal m(dev_access_mutex);
601
 
 
602
 
  return audio_output_devices;
603
 
}
604
 
 
605
 
 
606
 
PStringArray 
607
 
GnomeMeeting::GetAudioPlugins ()
608
 
{
609
 
  PWaitAndSignal m(dev_access_mutex);
610
 
 
611
 
  return audio_managers;
612
 
}
613
 
 
614
 
 
615
 
PStringArray 
616
 
GnomeMeeting::GetVideoPlugins ()
617
 
{
618
 
  PWaitAndSignal m(dev_access_mutex);
619
 
 
620
 
  return video_managers;
 
313
void
 
314
GnomeMeeting::InitEngine ()
 
315
{
 
316
  PWaitAndSignal m(ep_var_mutex);
 
317
 
 
318
  Ekiga::Runtime *runtime = new Ekiga::GlibRuntime;
 
319
  engine_init (1, NULL, runtime, service_core);
 
320
 
 
321
  if (!service_core)
 
322
    std::cout << "engine couldn't init!" << std::endl;
621
323
}