]> git.0d.be Git - empathy.git/blob - libempathy/empathy-tp-call.c
Merge branch 'master' into tp-tube
[empathy.git] / libempathy / empathy-tp-call.c
1 /*
2  * Copyright (C) 2007 Elliot Fairweather
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
20  *          Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include <string.h>
24
25 #include <telepathy-glib/proxy-subclass.h>
26 #include <telepathy-glib/dbus.h>
27 #include <telepathy-glib/interfaces.h>
28
29 #include "empathy-tp-call.h"
30 #include "empathy-tp-contact-factory.h"
31 #include "empathy-utils.h"
32
33 #define DEBUG_FLAG EMPATHY_DEBUG_TP
34 #include "empathy-debug.h"
35
36 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpCall)
37 typedef struct
38 {
39   gboolean dispose_has_run;
40   TpChannel *channel;
41   EmpathyContact *contact;
42   gboolean is_incoming;
43   guint status;
44
45   EmpathyTpCallStream *audio;
46   EmpathyTpCallStream *video;
47 } EmpathyTpCallPriv;
48
49 enum
50 {
51   PROP_0,
52   PROP_CHANNEL,
53   PROP_CONTACT,
54   PROP_IS_INCOMING,
55   PROP_STATUS,
56   PROP_AUDIO_STREAM,
57   PROP_VIDEO_STREAM
58 };
59
60 G_DEFINE_TYPE (EmpathyTpCall, empathy_tp_call, G_TYPE_OBJECT)
61
62 static void
63 tp_call_add_stream (EmpathyTpCall *call,
64                     guint stream_id,
65                     guint contact_handle,
66                     guint stream_type,
67                     guint stream_state,
68                     guint stream_direction)
69 {
70   EmpathyTpCallPriv *priv = GET_PRIV (call);
71
72   switch (stream_type)
73     {
74       case TP_MEDIA_STREAM_TYPE_AUDIO:
75         DEBUG ("Audio stream - id: %d, state: %d, direction: %d",
76             stream_id, stream_state, stream_direction);
77         priv->audio->exists = TRUE;
78         priv->audio->id = stream_id;
79         priv->audio->state = stream_state;
80         priv->audio->direction = stream_direction;
81         g_object_notify (G_OBJECT (call), "audio-stream");
82         break;
83       case TP_MEDIA_STREAM_TYPE_VIDEO:
84         DEBUG ("Video stream - id: %d, state: %d, direction: %d",
85             stream_id, stream_state, stream_direction);
86         priv->video->exists = TRUE;
87         priv->video->id = stream_id;
88         priv->video->state = stream_state;
89         priv->video->direction = stream_direction;
90         g_object_notify (G_OBJECT (call), "video-stream");
91         break;
92       default:
93         DEBUG ("Unknown stream type: %d", stream_type);
94     }
95 }
96
97 static void
98 tp_call_stream_added_cb (TpChannel *channel,
99                          guint stream_id,
100                          guint contact_handle,
101                          guint stream_type,
102                          gpointer user_data,
103                          GObject *call)
104 {
105   DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d",
106       stream_id, contact_handle, stream_type);
107
108   tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
109       stream_type, TP_MEDIA_STREAM_STATE_DISCONNECTED,
110       TP_MEDIA_STREAM_DIRECTION_NONE);
111 }
112
113 static void
114 tp_call_stream_removed_cb (TpChannel *channel,
115                            guint stream_id,
116                            gpointer user_data,
117                            GObject *call)
118 {
119   EmpathyTpCallPriv *priv = GET_PRIV (call);
120
121   DEBUG ("Stream removed - stream id: %d", stream_id);
122
123   if (stream_id == priv->audio->id)
124     {
125       priv->audio->exists = FALSE;
126       g_object_notify (call, "audio-stream");
127     }
128   else if (stream_id == priv->video->id)
129     {
130       priv->video->exists = FALSE;
131       g_object_notify (call, "video-stream");
132     }
133 }
134
135 static void
136 tp_call_stream_state_changed_cb (TpChannel *proxy,
137                                  guint stream_id,
138                                  guint stream_state,
139                                  gpointer user_data,
140                                  GObject *call)
141 {
142   EmpathyTpCallPriv *priv = GET_PRIV (call);
143
144   DEBUG ("Stream state changed - stream id: %d, state state: %d",
145       stream_id, stream_state);
146
147   if (stream_id == priv->audio->id)
148     {
149       priv->audio->state = stream_state;
150       g_object_notify (call, "audio-stream");
151     }
152   else if (stream_id == priv->video->id)
153     {
154       priv->video->state = stream_state;
155       g_object_notify (call, "video-stream");
156     }
157 }
158
159 static void
160 tp_call_stream_direction_changed_cb (TpChannel *channel,
161                                      guint stream_id,
162                                      guint stream_direction,
163                                      guint pending_flags,
164                                      gpointer user_data,
165                                      GObject *call)
166 {
167   EmpathyTpCallPriv *priv = GET_PRIV (call);
168
169   DEBUG ("Stream direction changed - stream: %d, direction: %d",
170       stream_id, stream_direction);
171
172   if (stream_id == priv->audio->id)
173     {
174       priv->audio->direction = stream_direction;
175       g_object_notify (call, "audio-stream");
176     }
177   else if (stream_id == priv->video->id)
178     {
179       priv->video->direction = stream_direction;
180       g_object_notify (call, "video-stream");
181     }
182 }
183
184 static void
185 tp_call_request_streams_cb (TpChannel *channel,
186                             const GPtrArray *streams,
187                             const GError *error,
188                             gpointer user_data,
189                             GObject *call)
190 {
191   guint i;
192
193   if (error)
194     {
195       DEBUG ("Error requesting streams: %s", error->message);
196       return;
197     }
198
199   for (i = 0; i < streams->len; i++)
200     {
201       GValueArray *values;
202       guint stream_id;
203       guint contact_handle;
204       guint stream_type;
205       guint stream_state;
206       guint stream_direction;
207
208       values = g_ptr_array_index (streams, i);
209       stream_id = g_value_get_uint (g_value_array_get_nth (values, 0));
210       contact_handle = g_value_get_uint (g_value_array_get_nth (values, 1));
211       stream_type = g_value_get_uint (g_value_array_get_nth (values, 2));
212       stream_state = g_value_get_uint (g_value_array_get_nth (values, 3));
213       stream_direction = g_value_get_uint (g_value_array_get_nth (values, 4));
214
215       tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle,
216           stream_type, stream_state, stream_direction);
217   }
218 }
219
220 static void
221 tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
222                                           EmpathyCapabilities capabilities)
223 {
224   EmpathyTpCallPriv *priv = GET_PRIV (call);
225   GArray *stream_types;
226   guint handle;
227   guint stream_type;
228
229   if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN)
230       capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO;
231
232   DEBUG ("Requesting new stream for capabilities %d",
233       capabilities);
234
235   stream_types = g_array_new (FALSE, FALSE, sizeof (guint));
236   handle = empathy_contact_get_handle (priv->contact);
237
238   if (capabilities & EMPATHY_CAPABILITIES_AUDIO)
239     {
240       stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
241       g_array_append_val (stream_types, stream_type);
242     }
243   if (capabilities & EMPATHY_CAPABILITIES_VIDEO)
244     {
245       stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
246       g_array_append_val (stream_types, stream_type);
247     }
248
249   tp_cli_channel_type_streamed_media_call_request_streams (priv->channel, -1,
250       handle, stream_types, tp_call_request_streams_cb, NULL, NULL,
251       G_OBJECT (call));
252
253   g_array_free (stream_types, TRUE);
254 }
255
256 static void
257 tp_call_got_contact_cb (EmpathyTpContactFactory *factory,
258                         EmpathyContact          *contact,
259                         const GError            *error,
260                         gpointer                 user_data,
261                         GObject                 *call)
262 {
263   EmpathyTpCallPriv *priv = GET_PRIV (call);
264
265   if (error)
266     {
267       DEBUG ("Error: %s", error->message);
268       return;
269     }
270
271   priv->contact = g_object_ref (contact);
272   priv->is_incoming = TRUE;
273   priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
274   g_object_notify (G_OBJECT (call), "is-incoming");
275   g_object_notify (G_OBJECT (call), "contact");
276   g_object_notify (G_OBJECT (call), "status");
277 }
278
279 static void
280 tp_call_update_status (EmpathyTpCall *call)
281 {
282   EmpathyTpCallPriv *priv = GET_PRIV (call);
283   TpHandle self_handle;
284   const TpIntSet *set;
285   TpIntSetIter iter;
286
287   g_object_ref (call);
288
289   self_handle = tp_channel_group_get_self_handle (priv->channel);
290   set = tp_channel_group_get_members (priv->channel);
291   tp_intset_iter_init (&iter, set);
292   while (tp_intset_iter_next (&iter))
293     {
294       if (priv->contact == NULL && iter.element != self_handle)
295         {
296           EmpathyTpContactFactory *factory;
297           TpConnection *connection;
298
299           /* We found the remote contact */
300           connection = tp_channel_borrow_connection (priv->channel);
301           factory = empathy_tp_contact_factory_dup_singleton (connection);
302           empathy_tp_contact_factory_get_from_handle (factory, iter.element,
303               tp_call_got_contact_cb, NULL, NULL, G_OBJECT (call));
304           g_object_unref (factory);
305         }
306
307       if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
308           ((priv->is_incoming && iter.element == self_handle) ||
309            (!priv->is_incoming && iter.element != self_handle)))
310         {
311           priv->status = EMPATHY_TP_CALL_STATUS_ACCEPTED;
312           g_object_notify (G_OBJECT (call), "status");
313         }
314     }
315
316   g_object_unref (call);
317 }
318
319 void
320 empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact)
321 {
322   EmpathyTpCallPriv *priv = GET_PRIV (call);
323
324   priv->contact = g_object_ref (contact);
325   priv->is_incoming = FALSE;
326   priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
327   g_object_notify (G_OBJECT (call), "is-incoming");
328   g_object_notify (G_OBJECT (call), "contact");
329   g_object_notify (G_OBJECT (call), "status");
330   tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_AUDIO);
331 }
332
333 static void
334 tp_call_channel_invalidated_cb (TpChannel     *channel,
335                                 GQuark         domain,
336                                 gint           code,
337                                 gchar         *message,
338                                 EmpathyTpCall *call)
339 {
340   EmpathyTpCallPriv *priv = GET_PRIV (call);
341
342   DEBUG ("Channel invalidated: %s", message);
343   priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
344   g_object_notify (G_OBJECT (call), "status");
345 }
346
347 static void
348 tp_call_async_cb (TpProxy *proxy,
349                   const GError *error,
350                   gpointer user_data,
351                   GObject *call)
352 {
353   if (error)
354       DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
355 }
356
357 static GObject *
358 tp_call_constructor (GType type,
359                      guint n_construct_params,
360                      GObjectConstructParam *construct_params)
361 {
362   GObject *object;
363   EmpathyTpCall *call;
364   EmpathyTpCallPriv *priv;
365
366   object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type,
367       n_construct_params, construct_params);
368
369   call = EMPATHY_TP_CALL (object);
370   priv = GET_PRIV (call);
371
372   /* Setup streamed media channel */
373   g_signal_connect (priv->channel, "invalidated",
374       G_CALLBACK (tp_call_channel_invalidated_cb), call);
375   tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
376       tp_call_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
377   tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
378       tp_call_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
379   tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
380       tp_call_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
381   tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
382       tp_call_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
383   tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
384       tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call));
385
386   /* Update status when members changes */
387   tp_call_update_status (call);
388   g_signal_connect_swapped (priv->channel, "group-members-changed",
389       G_CALLBACK (tp_call_update_status), call);
390
391   return object;
392 }
393 static void
394 tp_call_dispose (GObject *object)
395 {
396   EmpathyTpCallPriv *priv = GET_PRIV (object);
397
398   DEBUG ("Disposing: %p, %d", object, priv->dispose_has_run);
399
400   if (priv->dispose_has_run)
401     return;
402
403   priv->dispose_has_run = TRUE;
404
405   if (priv->channel != NULL)
406     {
407       g_signal_handlers_disconnect_by_func (priv->channel,
408         tp_call_channel_invalidated_cb, object);
409
410       g_object_unref (priv->channel);
411       priv->channel = NULL;
412     }
413
414   if (priv->contact != NULL)
415       g_object_unref (priv->contact);
416
417   if (G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose)
418     G_OBJECT_CLASS (empathy_tp_call_parent_class)->dispose (object);
419 }
420
421 static void
422 tp_call_finalize (GObject *object)
423 {
424   EmpathyTpCallPriv *priv = GET_PRIV (object);
425
426   DEBUG ("Finalizing: %p", object);
427
428   g_slice_free (EmpathyTpCallStream, priv->audio);
429   g_slice_free (EmpathyTpCallStream, priv->video);
430
431   (G_OBJECT_CLASS (empathy_tp_call_parent_class)->finalize) (object);
432 }
433
434 static void
435 tp_call_set_property (GObject *object,
436                       guint prop_id,
437                       const GValue *value,
438                       GParamSpec *pspec)
439 {
440   EmpathyTpCallPriv *priv = GET_PRIV (object);
441
442   switch (prop_id)
443     {
444     case PROP_CHANNEL:
445       priv->channel = g_value_dup_object (value);
446       break;
447     default:
448       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
449       break;
450   }
451 }
452
453 static void
454 tp_call_get_property (GObject *object,
455                       guint prop_id,
456                       GValue *value,
457                       GParamSpec *pspec)
458 {
459   EmpathyTpCallPriv *priv = GET_PRIV (object);
460
461   switch (prop_id)
462     {
463     case PROP_CHANNEL:
464       g_value_set_object (value, priv->channel);
465       break;
466     case PROP_CONTACT:
467       g_value_set_object (value, priv->contact);
468       break;
469     case PROP_IS_INCOMING:
470       g_value_set_boolean (value, priv->is_incoming);
471       break;
472     case PROP_STATUS:
473       g_value_set_uint (value, priv->status);
474       break;
475     case PROP_AUDIO_STREAM:
476       g_value_set_pointer (value, priv->audio);
477       break;
478     case PROP_VIDEO_STREAM:
479       g_value_set_pointer (value, priv->video);
480       break;
481     default:
482       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
483       break;
484   }
485 }
486
487 static void
488 empathy_tp_call_class_init (EmpathyTpCallClass *klass)
489 {
490   GObjectClass *object_class = G_OBJECT_CLASS (klass);
491
492   object_class->constructor = tp_call_constructor;
493   object_class->dispose = tp_call_dispose;
494   object_class->finalize = tp_call_finalize;
495   object_class->set_property = tp_call_set_property;
496   object_class->get_property = tp_call_get_property;
497
498   g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv));
499
500   g_object_class_install_property (object_class, PROP_CHANNEL,
501       g_param_spec_object ("channel", "channel", "channel",
502       TP_TYPE_CHANNEL,
503       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
504       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
505   g_object_class_install_property (object_class, PROP_CONTACT,
506       g_param_spec_object ("contact", "Call contact", "Call contact",
507       EMPATHY_TYPE_CONTACT,
508       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
509   g_object_class_install_property (object_class, PROP_IS_INCOMING,
510       g_param_spec_boolean ("is-incoming", "Is media stream incoming",
511       "Is media stream incoming", FALSE, G_PARAM_READABLE |
512       G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
513   g_object_class_install_property (object_class, PROP_STATUS,
514       g_param_spec_uint ("status", "Call status",
515       "Call status", 0, 255, 0, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
516       G_PARAM_STATIC_BLURB));
517   g_object_class_install_property (object_class, PROP_AUDIO_STREAM,
518       g_param_spec_pointer ("audio-stream", "Audio stream data",
519       "Audio stream data",
520       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
521   g_object_class_install_property (object_class, PROP_VIDEO_STREAM,
522       g_param_spec_pointer ("video-stream", "Video stream data",
523       "Video stream data",
524       G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
525 }
526
527 static void
528 empathy_tp_call_init (EmpathyTpCall *call)
529 {
530   EmpathyTpCallPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (call,
531     EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv);
532
533   call->priv = priv;
534   priv->status = EMPATHY_TP_CALL_STATUS_READYING;
535   priv->contact = NULL;
536   priv->audio = g_slice_new0 (EmpathyTpCallStream);
537   priv->video = g_slice_new0 (EmpathyTpCallStream);
538   priv->audio->exists = FALSE;
539   priv->video->exists = FALSE;
540 }
541
542 EmpathyTpCall *
543 empathy_tp_call_new (TpChannel *channel)
544 {
545   g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
546
547   return g_object_new (EMPATHY_TYPE_TP_CALL,
548       "channel", channel,
549       NULL);
550 }
551
552 void
553 empathy_tp_call_accept_incoming_call (EmpathyTpCall *call)
554 {
555   EmpathyTpCallPriv *priv = GET_PRIV (call);
556   TpHandle self_handle;
557   GArray handles = {(gchar *) &self_handle, 1};
558
559   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
560   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING);
561   g_return_if_fail (priv->is_incoming);
562
563   DEBUG ("Accepting incoming call");
564
565   self_handle = tp_channel_group_get_self_handle (priv->channel);
566   tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
567       &handles, NULL, NULL, NULL, NULL, NULL);
568 }
569
570 void
571 empathy_tp_call_close (EmpathyTpCall *call)
572 {
573   EmpathyTpCallPriv *priv = GET_PRIV (call);
574
575   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
576
577   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
578       return;
579
580   DEBUG ("Closing channel");
581
582   tp_cli_channel_call_close (priv->channel, -1,
583       NULL, NULL, NULL, NULL);
584
585   priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
586   g_object_notify (G_OBJECT (call), "status");
587 }
588
589 void
590 empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
591                                                 gboolean is_sending)
592 {
593   EmpathyTpCallPriv *priv = GET_PRIV (call);
594   guint new_direction;
595
596   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
597   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
598
599   DEBUG ("Requesting video stream direction - is_sending: %d", is_sending);
600
601   if (!priv->video->exists)
602     {
603       if (is_sending)
604           tp_call_request_streams_for_capabilities (call,
605               EMPATHY_CAPABILITIES_VIDEO);
606       return;
607     }
608
609   if (is_sending)
610       new_direction = priv->video->direction | TP_MEDIA_STREAM_DIRECTION_SEND;
611   else
612       new_direction = priv->video->direction & ~TP_MEDIA_STREAM_DIRECTION_SEND;
613
614   tp_cli_channel_type_streamed_media_call_request_stream_direction (priv->channel,
615       -1, priv->video->id, new_direction,
616       (tp_cli_channel_type_streamed_media_callback_for_request_stream_direction)
617       tp_call_async_cb, NULL, NULL, G_OBJECT (call));
618 }
619
620 void
621 empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
622 {
623   EmpathyTpCallPriv *priv = GET_PRIV (call);
624
625   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
626   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
627
628   if (!priv->audio->exists)
629       return;
630
631   tp_cli_channel_interface_dtmf_call_start_tone (priv->channel, -1,
632       priv->audio->id, event,
633       (tp_cli_channel_interface_dtmf_callback_for_start_tone) tp_call_async_cb,
634       "starting tone", NULL, G_OBJECT (call));
635 }
636
637 void
638 empathy_tp_call_stop_tone (EmpathyTpCall *call)
639 {
640   EmpathyTpCallPriv *priv = GET_PRIV (call);
641
642   g_return_if_fail (EMPATHY_IS_TP_CALL (call));
643   g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED);
644
645   if (!priv->audio->exists)
646       return;
647
648   tp_cli_channel_interface_dtmf_call_stop_tone (priv->channel, -1,
649       priv->audio->id,
650       (tp_cli_channel_interface_dtmf_callback_for_stop_tone) tp_call_async_cb,
651       "stoping tone", NULL, G_OBJECT (call));
652 }
653
654 gboolean
655 empathy_tp_call_has_dtmf (EmpathyTpCall *call)
656 {
657   EmpathyTpCallPriv *priv = GET_PRIV (call);
658
659   g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), FALSE);
660
661   return tp_proxy_has_interface_by_id (priv->channel,
662       TP_IFACE_QUARK_CHANNEL_INTERFACE_DTMF);
663 }
664