]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
Merge remote-tracking branch 'origin/call1' into master+call
[empathy.git] / src / empathy-call-window.c
index 451722839ae57f471c029de1ccac0086174e0d78..51732e0243ffa85983513f348941dc418d087c8c 100644 (file)
@@ -53,6 +53,7 @@
 #include <libempathy-gtk/empathy-sound-manager.h>
 #include <libempathy-gtk/empathy-geometry.h>
 #include <libempathy-gtk/empathy-images.h>
+#include <libempathy-gtk/empathy-call-utils.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
 #include <libempathy/empathy-debug.h>
@@ -194,17 +195,13 @@ struct _EmpathyCallWindowPriv
   /* These are used to accept or reject an incoming call when the status
      is RINGING. */
   GtkWidget *incoming_call_dialog;
-  TpyCallChannel *pending_channel;
+  TpCallChannel *pending_channel;
   TpChannelDispatchOperation *pending_cdo;
   TpAddDispatchOperationContext *pending_context;
 
   gulong video_output_motion_handler_id;
   guint bus_message_source_id;
 
-  /* String that contains the queued tones to send after the current ones
-     are sent */
-  GString *tones;
-  gboolean sending_tones;
   GtkWidget *dtmf_panel;
 
   /* Details vbox */
@@ -346,61 +343,21 @@ empathy_call_window_video_call_cb (GtkToggleToolButton *button,
   empathy_call_window_restart_call (self);
 }
 
-static void
-empathy_call_window_emit_tones (EmpathyCallWindow *self)
-{
-  TpChannel *channel;
-
-  if (tp_str_empty (self->priv->tones->str))
-    return;
-
-  g_object_get (self->priv->handler, "call-channel", &channel, NULL);
-
-  DEBUG ("Emitting multiple tones: %s", self->priv->tones->str);
-
-  tp_cli_channel_interface_dtmf_call_multiple_tones (channel, -1,
-      self->priv->tones->str,
-      NULL, NULL, NULL, NULL);
-
-  self->priv->sending_tones = TRUE;
-
-  g_string_set_size (self->priv->tones, 0);
-
-  g_object_unref (channel);
-}
-
-static void
-empathy_call_window_maybe_emit_tones (EmpathyCallWindow *self)
-{
-  if (self->priv->sending_tones)
-    return;
-
-  empathy_call_window_emit_tones (self);
-}
-
-static void
-empathy_call_window_tones_stopped_cb (TpChannel *proxy,
-    gboolean arg_cancelled,
-    gpointer user_data,
-    GObject *weak_object)
-{
-  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
-
-  self->priv->sending_tones = FALSE;
-
-  empathy_call_window_emit_tones (self);
-}
-
 static void
 dtmf_start_tone_cb (EmpathyDialpadWidget *dialpad,
     TpDTMFEvent event,
     EmpathyCallWindow *self)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  TpCallChannel *call;
+  gchar tones[2];
 
-  g_string_append_c (priv->tones, tp_dtmf_event_to_char (event));
+  g_object_get (self->priv->handler, "call-channel", &call, NULL);
 
-  empathy_call_window_maybe_emit_tones (self);
+  tones[0] = tp_dtmf_event_to_char (event);
+  tones[1] = '\0';
+  tp_call_channel_send_tones_async (call, tones, NULL, NULL, NULL);
+
+  g_object_unref (call);
 }
 
 static void
@@ -1557,7 +1514,7 @@ empathy_call_window_set_state_ringing (EmpathyCallWindow *self)
 
   g_assert (self->priv->call_state != CONNECTED);
 
-  video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
+  video = tp_call_channel_has_initial_video (self->priv->pending_channel, NULL);
 
   empathy_call_window_status_message (self, _("Incoming call"));
   self->priv->call_state = RINGING;
@@ -1601,7 +1558,7 @@ empathy_call_window_cdo_invalidated_cb (TpProxy *channel,
 
 void
 empathy_call_window_start_ringing (EmpathyCallWindow *self,
-    TpyCallChannel *channel,
+    TpCallChannel *channel,
     TpChannelDispatchOperation *dispatch_operation,
     TpAddDispatchOperationContext *context)
 {
@@ -1825,8 +1782,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
   g_signal_connect (priv->dtmf_panel, "start-tone",
       G_CALLBACK (dtmf_start_tone_cb), self);
 
-  priv->tones = g_string_new ("");
-
   gtk_box_pack_start (GTK_BOX (priv->pane), priv->dtmf_panel,
       FALSE, FALSE, 6);
 
@@ -2254,14 +2209,14 @@ empathy_call_window_constructed (GObject *object)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
-  TpyCallState state;
+  TpCallChannel *call;
+  TpCallState state;
 
   g_assert (priv->handler != NULL);
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
-  state = tpy_call_channel_get_state (call, NULL, NULL);
-  priv->outgoing = (state == TPY_CALL_STATE_PENDING_INITIATOR);
+  state = tp_call_channel_get_state (call, NULL, NULL, NULL);
+  priv->outgoing = (state == TP_CALL_STATE_PENDING_INITIATOR);
   tp_clear_object (&call);
 
   g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
@@ -2451,8 +2406,6 @@ empathy_call_window_finalize (GObject *object)
 
   g_timer_destroy (priv->timer);
 
-  g_string_free (priv->tones, TRUE);
-
   G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
 }
 
@@ -2604,9 +2557,6 @@ empathy_call_window_disconnected (EmpathyCallWindow *self,
   gtk_action_set_sensitive (priv->menu_fullscreen, FALSE);
   gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
 
-  priv->sending_tones = FALSE;
-  g_string_set_size (priv->tones, 0);
-
   could_reset_pipeline = empathy_call_window_reset_pipeline (self);
 
   if (priv->call_state == CONNECTING)
@@ -3062,7 +3012,7 @@ display_error (EmpathyCallWindow *self,
 #if 0
 static gchar *
 media_stream_error_to_txt (EmpathyCallWindow *self,
-    TpyCallChannel *call,
+    TpCallChannel *call,
     gboolean audio,
     TpMediaStreamError error)
 {
@@ -3134,7 +3084,7 @@ media_stream_error_to_txt (EmpathyCallWindow *self,
 
 static void
 empathy_call_window_stream_error (EmpathyCallWindow *self,
-    TpyCallChannel *call,
+    TpCallChannel *call,
     gboolean audio,
     guint code,
     const gchar *msg,
@@ -3158,7 +3108,7 @@ empathy_call_window_stream_error (EmpathyCallWindow *self,
 }
 
 static void
-empathy_call_window_audio_stream_error (TpyCallChannel *call,
+empathy_call_window_audio_stream_error (TpCallChannel *call,
     guint code,
     const gchar *msg,
     EmpathyCallWindow *self)
@@ -3168,7 +3118,7 @@ empathy_call_window_audio_stream_error (TpyCallChannel *call,
 }
 
 static void
-empathy_call_window_video_stream_error (TpyCallChannel *call,
+empathy_call_window_video_stream_error (TpCallChannel *call,
     guint code,
     const gchar *msg,
     EmpathyCallWindow *self)
@@ -3227,22 +3177,22 @@ show_balance_error (EmpathyCallWindow *self)
 
 static void
 empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
-    TpyCallState state,
+    TpCallState state,
     gchar *reason,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
   gboolean can_send_video;
 
-  if (state == TPY_CALL_STATE_ENDED &&
+  if (state == TP_CALL_STATE_ENDED &&
       !tp_strdiff (reason, TP_ERROR_STR_INSUFFICIENT_BALANCE))
     {
       show_balance_error (self);
       return;
     }
 
-  if (state != TPY_CALL_STATE_ACCEPTED)
+  if (state != TP_CALL_STATE_ACCEPTED)
     return;
 
   if (priv->call_state == CONNECTED)
@@ -3259,7 +3209,7 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
 
-  if (tpy_call_channel_has_dtmf (call))
+  if (tp_call_channel_has_dtmf (call))
     gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
 
   if (priv->video_input == NULL)
@@ -3604,20 +3554,20 @@ start_call (EmpathyCallWindow *self)
 
   if (empathy_call_handler_has_initial_video (priv->handler))
     {
-      TpyCallChannel *call;
-      TpySendingState s;
+      TpCallChannel *call;
+      TpSendingState s;
 
       g_object_get (priv->handler, "call-channel", &call, NULL);
       /* If the call channel isn't set yet we're requesting it, if we're
        * requesting it with initial video it should be PENDING_SEND when we get
        * it */
       if (call == NULL)
-        s = TPY_SENDING_STATE_PENDING_SEND;
+        s = TP_SENDING_STATE_PENDING_SEND;
       else
-        s = tpy_call_channel_get_video_state (call);
+        s = empathy_call_channel_get_video_state (call);
 
-      if (s == TPY_SENDING_STATE_PENDING_SEND ||
-          s == TPY_SENDING_STATE_SENDING)
+      if (s == TP_SENDING_STATE_PENDING_SEND ||
+          s == TP_SENDING_STATE_SENDING)
         {
           /* Enable 'send video' buttons and display the preview */
           gtk_toggle_tool_button_set_active (
@@ -3733,8 +3683,10 @@ empathy_call_window_bus_message (GstBus *bus, GstMessage *message,
 }
 
 static void
-empathy_call_window_members_changed_cb (TpyCallChannel *call,
-    GHashTable *members,
+empathy_call_window_members_changed_cb (TpCallChannel *call,
+    GHashTable *updates,
+    GPtrArray *removed,
+    TpCallStateReason *reason,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
@@ -3742,10 +3694,10 @@ empathy_call_window_members_changed_cb (TpyCallChannel *call,
   gpointer key, value;
   gboolean held = FALSE;
 
-  g_hash_table_iter_init (&iter, members);
+  g_hash_table_iter_init (&iter, updates);
   while (g_hash_table_iter_next (&iter, &key, &value))
     {
-      if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
+      if (GPOINTER_TO_INT (value) & TP_CALL_MEMBER_FLAG_HELD)
         {
           /* This assumes this is a 1-1 call, otherwise one participant
            * putting the call on hold wouldn't mean the call is on hold
@@ -3767,7 +3719,7 @@ call_handler_notify_call_cb (EmpathyCallHandler *handler,
     EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
   if (call == NULL)
@@ -3783,10 +3735,6 @@ call_handler_notify_call_cb (EmpathyCallHandler *handler,
   tp_g_signal_connect_object (call, "members-changed",
       G_CALLBACK (empathy_call_window_members_changed_cb), self, 0);
 
-  tp_cli_channel_interface_dtmf_connect_to_stopped_tones (TP_CHANNEL (call),
-      empathy_call_window_tones_stopped_cb, self, NULL,
-      G_OBJECT (call), NULL);
-
   g_object_unref (call);
 }
 
@@ -3794,7 +3742,7 @@ static void
 empathy_call_window_connect_handler (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   g_signal_connect (priv->handler, "state-changed",
     G_CALLBACK (empathy_call_window_state_changed_cb), self);
@@ -4007,7 +3955,7 @@ empathy_call_window_set_send_video (EmpathyCallWindow *window,
   CameraState state)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
-  TpyCallChannel *call;
+  TpCallChannel *call;
 
   priv->sending_video = (state == CAMERA_STATE_ON);
 
@@ -4027,7 +3975,7 @@ empathy_call_window_set_send_video (EmpathyCallWindow *window,
 
   g_object_get (priv->handler, "call-channel", &call, NULL);
   DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
-  tpy_call_channel_send_video (call, priv->sending_video);
+  empathy_call_channel_send_video (call, priv->sending_video);
   g_object_unref (call);
 }