]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
Fix typo
[empathy.git] / src / empathy-call-window.c
index c7f202ee3a29c946171bbe90c9a1abb67abdab57..1ea9570796806e129b18a61404762ea1bd398520 100644 (file)
 /*
- *  Copyright (C) 2007 Elliot Fairweather
+ * empathy-call-window.c - Source for EmpathyCallWindow
+ * Copyright (C) 2008 Collabora Ltd.
+ * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
  *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- *  Authors: Elliot Fairweather <elliot.fairweather@collabora.co.uk>
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <string.h>
 
-#include <libtelepathy/tp-chan.h>
+#include <stdio.h>
+#include <stdlib.h>
 
-#include <libmissioncontrol/mc-account.h>
-#include <libmissioncontrol/mc-account-monitor.h>
-#include <libmissioncontrol/mission-control.h>
+#include <gst/gst.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
 
-#include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-tp-call.h>
-#include <libempathy/empathy-chandler.h>
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-utils.h>
+#include <telepathy-farsight/channel.h>
 
-#include <libempathy-gtk/empathy-call-window.h>
+#include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-video-widget.h>
+#include <libempathy-gtk/empathy-audio-src.h>
+#include <libempathy-gtk/empathy-audio-sink.h>
+#include <libempathy-gtk/empathy-video-src.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
-#define DEBUG_DOMAIN "CallWindow"
+#include "empathy-call-window.h"
 
-typedef struct 
+#include "empathy-sidebar.h"
+
+G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW)
+
+/* signal enum */
+#if 0
+enum
 {
-  GtkWidget *window;
-  GtkWidget *status_label;
-  GtkWidget *start_call_button;
-  GtkWidget *end_call_button;
-  GtkWidget *input_volume_scale;
-  GtkWidget *output_volume_scale;
-  GtkWidget *input_mute_button;
-  GtkWidget *output_mute_button;
-  GtkWidget *preview_video_frame;
-  GtkWidget *output_video_frame;
-  GtkWidget *preview_video_socket;
-  GtkWidget *output_video_socket;
-  GtkWidget *video_button;
-  GtkWidget *output_video_label;
+    LAST_SIGNAL
+};
 
-  EmpathyTpCall *call;
+static guint signals[LAST_SIGNAL] = {0};
+#endif
 
-  GTimeVal start_time;
-  guint timeout_event_id;
+enum {
+  PROP_CALL_HANDLER = 1,
+};
 
-  gboolean is_drawing;
-} EmpathyCallWindow;
+/* private structure */
+typedef struct _EmpathyCallWindowPriv EmpathyCallWindowPriv;
 
-static gboolean
-call_window_update_timer (gpointer data)
+struct _EmpathyCallWindowPriv
 {
-  EmpathyCallWindow *window = data;
-  GTimeVal current;
-  gchar *str;
-  glong now, then;
-  glong time, seconds, minutes, hours;
+  gboolean dispose_has_run;
+  EmpathyCallHandler *handler;
 
-  g_get_current_time (&current);
+  GtkWidget *video_output;
+  GtkWidget *video_preview;
+  GtkWidget *sidebar;
+  GtkWidget *sidebar_button;
+  GtkWidget *statusbar;
 
-  now = current.tv_sec;
-  then = (window->start_time).tv_sec;
+  GstElement *video_input;
+  GstElement *audio_input;
+  GstElement *audio_output;
+  GstElement *pipeline;
+  GstElement *video_tee;
 
-  time = now - then;
+  GladeXML *glade;
+  guint context_id;
+};
 
-  seconds = time % 60;
-  time /= 60;
-  minutes = time % 60;
-  time /= 60;
-  hours = time % 60;
+#define GET_PRIV(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_CALL_WINDOW, \
+    EmpathyCallWindowPriv))
 
-  if (hours > 0)
-    {
-      str = g_strdup_printf ("Connected  -  %02ld : %02ld : %02ld", hours,
-          minutes, seconds);
-    }
-  else
-    {
-      str = g_strdup_printf ("Connected  -  %02ld : %02ld", minutes, seconds);
-    }
+static void empathy_call_window_realized_cb (GtkWidget *widget,
+  EmpathyCallWindow *window);
 
-  gtk_label_set_text (GTK_LABEL (window->status_label), str);
+static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
+  GdkEvent*event, EmpathyCallWindow *window);
 
-  g_free (str);
+static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
+  EmpathyCallWindow *window);
+
+static void empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
+  EmpathyCallWindow *window);
+
+static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
+  EmpathyCallWindow *window);
+
+static void empathy_call_window_hangup (EmpathyCallWindow *window);
+
+static void empathy_call_window_status_message (EmpathyCallWindow *window,
+  gchar *message);
+
+static void
+empathy_call_window_session_created_cb (TfChannel *tfchannel,
+  FsConference  *conference, FsParticipant *participant,
+  gpointer user_data);
 
-  return TRUE;
+static void
+empathy_call_window_setup_menubar (EmpathyCallWindow *self)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  GtkWidget *hangup;
+
+  hangup = glade_xml_get_widget (priv->glade, "menuhangup");
+  g_signal_connect_swapped (G_OBJECT (hangup), "activate",
+    G_CALLBACK (empathy_call_window_hangup), self);
 }
 
 static void
-call_window_stop_timeout (EmpathyCallWindow *window)
+empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
 {
-  GMainContext *context;
-  GSource *source;
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  GtkWidget *hangup;
+  GtkWidget *mic;
+  GtkWidget *volume;
+  GtkWidget *volume_button;
+  GtkWidget *camera;
 
-  context = g_main_context_default ();
+  hangup = glade_xml_get_widget (priv->glade, "hangup");
 
-  empathy_debug (DEBUG_DOMAIN, "Timer stopped");
+  g_signal_connect_swapped (G_OBJECT (hangup), "clicked",
+    G_CALLBACK (empathy_call_window_hangup), self);
 
-  if (window->timeout_event_id)
-    {
-      source = g_main_context_find_source_by_id (context,
-          window->timeout_event_id);
-      g_source_destroy (source);
-      window->timeout_event_id = 0;
-    }
+  mic = glade_xml_get_widget (priv->glade, "microphone");
+  gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (mic), TRUE);
+
+  volume = glade_xml_get_widget (priv->glade, "volume");
+  volume_button = gtk_volume_button_new ();
+  gtk_container_add (GTK_CONTAINER (volume), volume_button);
+  gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume_button), 0.5);
+
+  camera = glade_xml_get_widget (priv->glade, "camera");
+  gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (camera), FALSE);
+
+  g_signal_connect (G_OBJECT (camera), "toggled",
+    G_CALLBACK (empathy_call_window_camera_toggled_cb), self);
 }
 
-static void
-call_window_set_output_video_is_drawing (EmpathyCallWindow *window,
-                                         gboolean is_drawing)
+static GtkWidget *
+empathy_call_window_create_dtmf (EmpathyCallWindow *self)
 {
-  GtkWidget* child;
-
-  child = gtk_bin_get_child (GTK_BIN (window->output_video_frame));
+  GtkWidget *table;
+  int i;
+  const gchar *strings[] = { "1", "2", "3",
+                             "4", "5", "6",
+                             "7", "8", "9",
+                             "#", "0", "*",
+                             NULL };
 
-  empathy_debug (DEBUG_DOMAIN,
-      "Setting output video is drawing - %d", is_drawing);
+  table = gtk_table_new (4, 3, TRUE);
 
-  if (is_drawing)
+  for (i = 0; strings[i] != NULL; i++)
     {
-      if (!window->is_drawing)
-        {
-          if (child)
-            {
-              gtk_container_remove (GTK_CONTAINER (window->output_video_frame),
-                  child);
-            }
-          gtk_container_add (GTK_CONTAINER (window->output_video_frame),
-              window->output_video_socket);
-          gtk_widget_show (window->output_video_socket);
-          empathy_tp_call_add_output_video (window->call,
-              gtk_socket_get_id (GTK_SOCKET (window->output_video_socket)));
-          window->is_drawing = is_drawing;
-        }
+      GtkWidget *button = gtk_button_new_with_label (strings[i]);
+      gtk_table_attach (GTK_TABLE (table), button, i % 3, i % 3 + 1,
+        i/3, i/3 + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1);
     }
-  else
+
+  return table;
+}
+
+static GtkWidget *
+empathy_call_window_create_video_input (EmpathyCallWindow *self)
+{
+  GtkWidget *hbox;
+  int i;
+  gchar *controls[] = { _("Contrast"), _("Brightness"), _("Gamma"), NULL };
+
+  hbox = gtk_hbox_new (TRUE, 3);
+
+  for (i = 0; controls[i] != NULL; i++)
     {
-      if (window->is_drawing)
-        {
-          empathy_tp_call_add_output_video (window->call, 0);
-          if (child)
-            {
-              gtk_container_remove (GTK_CONTAINER (window->output_video_frame),
-                  child);
-            }
-          gtk_container_add (GTK_CONTAINER (window->output_video_frame),
-              window->output_video_label);
-          gtk_widget_show (window->output_video_label);
-          window->is_drawing = is_drawing;
-        }
+      GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
+      GtkWidget *scale = gtk_vscale_new_with_range (0, 100, 10);
+      GtkWidget *label = gtk_label_new (controls[i]);
+
+      gtk_container_add (GTK_CONTAINER (hbox), vbox);
+
+      gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
+      gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
     }
+
+  return hbox;
 }
 
-static gboolean
-call_window_delete_event_cb (GtkWidget *widget,
-                             GdkEvent *event,
-                             EmpathyCallWindow *window)
+static GtkWidget *
+empathy_call_window_create_audio_input (EmpathyCallWindow *self)
 {
-  GtkWidget *dialog;
-  gint result;
-  guint status;
+  GtkWidget *hbox, *vbox, *scale, *progress, *label;
 
-  empathy_debug (DEBUG_DOMAIN, "Delete event occurred");
+  hbox = gtk_hbox_new (TRUE, 3);
 
-  g_object_get (G_OBJECT (window->call), "status", &status, NULL);
+  vbox = gtk_vbox_new (FALSE, 3);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
 
-  if (status != EMPATHY_TP_CALL_STATUS_CLOSED)
-    {
-      dialog = gtk_message_dialog_new (GTK_WINDOW (window->window),
-          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-          GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
-          "This call will be ended. Continue?");
-
-      result = gtk_dialog_run (GTK_DIALOG (dialog));
-      gtk_widget_destroy (dialog);
-
-      switch (result)
-        {
-        case GTK_RESPONSE_YES:
-          call_window_stop_timeout (window);
-          call_window_set_output_video_is_drawing (window, FALSE);
-          empathy_tp_call_close_channel (window->call);
-          empathy_tp_call_remove_preview_video (window->call,
-              gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
-          return FALSE;
-        default:
-          return TRUE;
-        }
-    }
-  else
-    {
-      empathy_tp_call_remove_preview_video (window->call,
-          gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
-      return FALSE;
-    }
+  scale = gtk_vscale_new_with_range (0, 100, 10);
+  gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
+  label = gtk_label_new (_("Volume"));
+
+  gtk_box_pack_start (GTK_BOX (vbox), scale, TRUE, TRUE, 3);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 3);
+
+
+  progress = gtk_progress_bar_new ();
+  gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (progress),
+    GTK_PROGRESS_BOTTOM_TO_TOP);
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 0.5);
+
+  gtk_box_pack_start (GTK_BOX (hbox), progress, FALSE, FALSE, 3);
+
+  return hbox;
 }
 
 static void
-call_window_video_button_toggled_cb (GtkWidget *button,
-                                     EmpathyCallWindow *window)
+empathy_call_window_init (EmpathyCallWindow *self)
 {
-  gboolean is_sending;
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  GtkWidget *vbox, *top_vbox;
+  GtkWidget *hbox, *h;
+  GtkWidget *arrow;
+  GtkWidget *page;
+  GstBus *bus;
+  gchar *filename;
+  GtkWidget *pane;
+
+  filename = empathy_file_lookup ("empathy-call-window.glade", "src");
+
+  priv->glade = empathy_glade_get_file (filename, "call_window", NULL,
+    "call_window_vbox", &top_vbox,
+    "pane", &pane,
+    "statusbar", &priv->statusbar,
+    NULL);
+
+  gtk_widget_reparent (top_vbox, GTK_WIDGET (self));
+
+  empathy_call_window_setup_menubar (self);
+  empathy_call_window_setup_toolbar (self);
+
+  priv->pipeline = gst_pipeline_new (NULL);
+
+  hbox = gtk_hbox_new (FALSE, 3);
+  gtk_paned_pack1 (GTK_PANED(pane), hbox, TRUE, FALSE);
+
+  bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
+
+  priv->video_output = empathy_video_widget_new (bus);
+  gtk_box_pack_start (GTK_BOX (hbox), priv->video_output, TRUE, TRUE, 3);
+
+  priv->video_tee = gst_element_factory_make ("tee", NULL);
+  gst_object_ref (priv->video_tee);
+  gst_object_sink (priv->video_tee);
 
-  is_sending = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  vbox = gtk_vbox_new (FALSE, 3);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
 
-  empathy_debug (DEBUG_DOMAIN, "Send video toggled - %d", is_sending);
+  priv->video_preview = empathy_video_widget_new_with_size (bus, 160, 120);
+  gtk_box_pack_start (GTK_BOX (vbox), priv->video_preview, FALSE, FALSE, 3);
 
-  empathy_tp_call_request_video_stream_direction (window->call, is_sending);
+  priv->video_input = empathy_video_src_new ();
+  gst_object_ref (priv->video_input);
+  gst_object_sink (priv->video_input);
+
+  priv->audio_input = empathy_audio_src_new ();
+  gst_object_ref (priv->audio_input);
+  gst_object_sink (priv->audio_input);
+
+  priv->audio_output = empathy_audio_sink_new ();
+  gst_object_ref (priv->audio_output);
+  gst_object_sink (priv->audio_output);
+
+  g_object_unref (bus);
+
+  priv->sidebar_button = gtk_toggle_button_new_with_mnemonic (_("_Sidebar"));
+  arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+  g_signal_connect (G_OBJECT (priv->sidebar_button), "toggled",
+    G_CALLBACK (empathy_call_window_sidebar_toggled_cb), self);
+
+  gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
+
+  h = gtk_hbox_new (FALSE, 3);
+  gtk_box_pack_end (GTK_BOX (vbox), h, FALSE, FALSE, 3);
+  gtk_box_pack_end (GTK_BOX (h), priv->sidebar_button, FALSE, FALSE, 3);
+
+  priv->sidebar = empathy_sidebar_new ();
+  g_signal_connect (G_OBJECT (priv->sidebar),
+    "hide", G_CALLBACK (empathy_call_window_sidebar_hidden_cb),
+    self);
+  gtk_paned_pack2 (GTK_PANED(pane), priv->sidebar, FALSE, FALSE);
+
+  page = empathy_call_window_create_dtmf (self);
+  empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
+    page);
+
+  page = empathy_call_window_create_audio_input (self);
+  empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Audio input"),
+    page);
+
+  page = empathy_call_window_create_video_input (self);
+  empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Video input"),
+    page);
+
+  gtk_widget_show_all (top_vbox);
+
+  gtk_widget_hide (priv->sidebar);
+
+  g_signal_connect (G_OBJECT (self), "realize",
+    G_CALLBACK (empathy_call_window_realized_cb), self);
+
+  g_signal_connect (G_OBJECT (self), "delete-event",
+    G_CALLBACK (empathy_call_window_delete_cb), self);
+
+  empathy_call_window_status_message (self, _("Connecting..."));
 }
 
+static void empathy_call_window_dispose (GObject *object);
+static void empathy_call_window_finalize (GObject *object);
+
 static void
-call_window_status_changed_cb (EmpathyTpCall *call,
-                               EmpathyCallWindow *window)
+empathy_call_window_set_property (GObject *object,
+  guint property_id, const GValue *value, GParamSpec *pspec)
 {
-  EmpathyContact *contact;
-  guint status;
-  guint stream_state;
-  EmpathyTpCallStream *audio_stream;
-  EmpathyTpCallStream *video_stream;
-  gboolean is_incoming;
-  gchar *title;
-
-  g_object_get (G_OBJECT (window->call), "status", &status, NULL);
-  g_object_get (G_OBJECT (window->call), "audio-stream", &audio_stream, NULL);
-  g_object_get (G_OBJECT (window->call), "video-stream", &video_stream, NULL);
-
-  if (video_stream->state > audio_stream->state)
-    {
-      stream_state = video_stream->state;
-    }
-  else
+  EmpathyCallWindowPriv *priv = GET_PRIV (object);
+
+  switch (property_id)
     {
-      stream_state = audio_stream->state;
+      case PROP_CALL_HANDLER:
+        priv->handler = g_value_dup_object (value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
+}
 
-  empathy_debug (DEBUG_DOMAIN, "Status changed - status: %d, stream state: %d",
-      status, stream_state);
+static void
+empathy_call_window_get_property (GObject *object,
+  guint property_id, GValue *value, GParamSpec *pspec)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (object);
 
-  if (window->timeout_event_id)
+  switch (property_id)
     {
-      call_window_stop_timeout (window);
+      case PROP_CALL_HANDLER:
+        g_value_set_object (value, priv->handler);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
+}
 
-  if (status == EMPATHY_TP_CALL_STATUS_CLOSED)
-    {
-      gtk_label_set_text (GTK_LABEL (window->status_label), "Closed");
-      gtk_widget_set_sensitive (window->end_call_button, FALSE);
-      gtk_widget_set_sensitive (window->start_call_button, FALSE);
+static void
+empathy_call_window_class_init (
+  EmpathyCallWindowClass *empathy_call_window_class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class);
+  GParamSpec *param_spec;
+
+  g_type_class_add_private (empathy_call_window_class,
+    sizeof (EmpathyCallWindowPriv));
+
+  object_class->set_property = empathy_call_window_set_property;
+  object_class->get_property = empathy_call_window_get_property;
+
+  object_class->dispose = empathy_call_window_dispose;
+  object_class->finalize = empathy_call_window_finalize;
+
+  param_spec = g_param_spec_object ("handler",
+    "handler", "The call handler",
+    EMPATHY_TYPE_CALL_HANDLER,
+    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class,
+    PROP_CALL_HANDLER, param_spec);
 
-      call_window_set_output_video_is_drawing (window, FALSE);
-    }
-  else if (stream_state == TP_MEDIA_STREAM_STATE_DISCONNECTED)
-    {
-      gtk_label_set_text (GTK_LABEL (window->status_label), "Disconnected");
-    }
-  else if (status == EMPATHY_TP_CALL_STATUS_PENDING)
-    {
-      g_object_get (G_OBJECT (window->call), "contact", &contact, NULL);
-
-      title = g_strdup_printf ("%s - Empathy Call",
-          empathy_contact_get_name (contact));
-      gtk_window_set_title (GTK_WINDOW (window->window), title);
-
-      gtk_label_set_text (GTK_LABEL (window->status_label), "Ringing");
-      gtk_widget_set_sensitive (window->end_call_button, TRUE);
-      gtk_widget_set_sensitive (window->video_button, TRUE);
-
-      g_object_get (G_OBJECT (window->call), "is-incoming", &is_incoming, NULL);
-      if (is_incoming)
-        {
-          gtk_widget_set_sensitive (window->start_call_button, TRUE);
-        }
-      else
-        {
-          g_signal_connect (GTK_OBJECT (window->video_button), "toggled",
-              G_CALLBACK (call_window_video_button_toggled_cb),
-              window);
-        }
-    }
-  else if (status == EMPATHY_TP_CALL_STATUS_ACCEPTED)
-    {
-      if (stream_state == TP_MEDIA_STREAM_STATE_CONNECTING)
-        {
-          gtk_label_set_text (GTK_LABEL (window->status_label), "Connecting");
-        }
-      else if (stream_state == TP_MEDIA_STREAM_STATE_CONNECTED)
-        {
-          if ((window->start_time).tv_sec == 0)
-            {
-              g_get_current_time (&(window->start_time));
-            }
-          window->timeout_event_id = g_timeout_add (1000,
-              call_window_update_timer, window);
-          empathy_debug (DEBUG_DOMAIN, "Timer started");
-        }
-    }
+}
+
+void
+empathy_call_window_dispose (GObject *object)
+{
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
+
+  if (priv->handler != NULL)
+    g_object_unref (priv->handler);
+
+  priv->handler = NULL;
+
+  if (priv->pipeline != NULL)
+    g_object_unref (priv->pipeline);
+  priv->pipeline = NULL;
+
+  if (priv->video_input != NULL)
+    g_object_unref (priv->video_input);
+  priv->video_input = NULL;
+
+  if (priv->audio_input != NULL)
+    g_object_unref (priv->audio_input);
+  priv->audio_input = NULL;
+
+  if (priv->audio_output != NULL)
+    g_object_unref (priv->audio_output);
+  priv->audio_output = NULL;
+
+  if (priv->video_tee != NULL)
+    g_object_unref (priv->video_tee);
+  priv->video_tee = NULL;
+
+  /* release any references held by the object here */
+  if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose)
+    G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
+}
+
+void
+empathy_call_window_finalize (GObject *object)
+{
+  //EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
+  //EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+  /* free any data held directly by the object here */
+
+  G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
+}
+
+
+EmpathyCallWindow *
+empathy_call_window_new (EmpathyCallHandler *handler)
+{
+  return EMPATHY_CALL_WINDOW (
+    g_object_new (EMPATHY_TYPE_CALL_WINDOW, "handler", handler, NULL));
 }
 
 static void
-call_window_receiving_video_cb (EmpathyTpCall *call,
-                                gboolean receiving_video,
-                                EmpathyCallWindow *window)
+empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
+  GstElement *conference, gpointer user_data)
 {
-  empathy_debug (DEBUG_DOMAIN, "Receiving video signal received");
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+  gst_bin_add (GST_BIN (priv->pipeline), conference);
 
-  call_window_set_output_video_is_drawing (window, receiving_video);
+  gst_element_set_state (conference, GST_STATE_PLAYING);
 }
 
 static void
-call_window_sending_video_cb (EmpathyTpCall *call,
-                              gboolean sending_video,
-                              EmpathyCallWindow *window)
+empathy_call_window_channel_closed_cb (TfChannel *channel, gpointer user_data)
 {
-  empathy_debug (DEBUG_DOMAIN, "Sending video signal received");
-
-  g_signal_handlers_block_by_func (window->video_button,
-      call_window_video_button_toggled_cb, window);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (window->video_button),
-      sending_video);
-  g_signal_handlers_unblock_by_func (window->video_button,
-      call_window_video_button_toggled_cb, window);
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+
+  empathy_call_window_status_message (self, _("Disconnected"));
 }
 
 static void
-call_window_socket_realized_cb (GtkWidget *widget,
-                                EmpathyCallWindow *window)
+empathy_call_window_session_created_cb (TfChannel *tfchannel,
+  FsConference  *conference, FsParticipant *participant,
+  gpointer user_data)
 {
-  if (widget == window->preview_video_socket)
-    {
-      empathy_debug (DEBUG_DOMAIN, "Preview socket realized");
-      empathy_tp_call_add_preview_video (window->call,
-          gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
-    }
-  else
-    {
-      empathy_debug (DEBUG_DOMAIN, "Output socket realized");
-    }
+  g_signal_connect (G_OBJECT (tfchannel), "closed",
+    G_CALLBACK (empathy_call_window_channel_closed_cb), user_data);
 }
 
 static void
-call_window_start_call_button_clicked_cb (GtkWidget *widget,
-                                          EmpathyCallWindow *window)
+empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
+  GstPad *src, guint media_type, gpointer user_data)
 {
-  gboolean send_video;
-  gboolean is_incoming;
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
 
-  empathy_debug (DEBUG_DOMAIN, "Start call clicked");
+  GstPad *pad;
+  GstElement *element;
+  gchar *str;
 
-  gtk_widget_set_sensitive (window->start_call_button, FALSE);
-  g_object_get (G_OBJECT (window->call), "is-incoming", &is_incoming, NULL);
-  if (is_incoming)
+  str = g_strdup_printf (_("Connected -- %d:%02dm"), 0, 0);
+  empathy_call_window_status_message (self, str);
+  g_free (str);
+
+  switch (media_type)
     {
-      empathy_tp_call_accept_incoming_call (window->call);
-      send_video = gtk_toggle_button_get_active
-          (GTK_TOGGLE_BUTTON (window->video_button));
-      empathy_tp_call_request_video_stream_direction (window->call, send_video);
-      g_signal_connect (GTK_OBJECT (window->video_button), "toggled",
-          G_CALLBACK (call_window_video_button_toggled_cb), window);
+      case TP_MEDIA_STREAM_TYPE_AUDIO:
+        element = priv->audio_output;
+        g_object_ref (element);
+        break;
+      case TP_MEDIA_STREAM_TYPE_VIDEO:
+        element =
+          empathy_video_widget_get_element (
+            EMPATHY_VIDEO_WIDGET (priv->video_output));
+        break;
+      default:
+        g_assert_not_reached ();
     }
+
+  gst_bin_add (GST_BIN (priv->pipeline), element);
+
+  pad = gst_element_get_static_pad (element, "sink");
+  gst_element_set_state (element, GST_STATE_PLAYING);
+
+  gst_pad_link (src, pad);
 }
 
 static void
-call_window_end_call_button_clicked_cb (GtkWidget *widget,
-                                        EmpathyCallWindow *window)
+empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
+  GstPad *sink, guint media_type, gpointer user_data)
 {
-  empathy_debug (DEBUG_DOMAIN, "End call clicked");
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+  EmpathyCallWindowPriv *priv = GET_PRIV (self);
+  GstPad *pad;
+
+  switch (media_type)
+    {
+      case TP_MEDIA_STREAM_TYPE_AUDIO:
+        gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input);
+        gst_element_set_state (priv->audio_input, GST_STATE_PLAYING);
+
+        pad = gst_element_get_static_pad (priv->audio_input, "src");
+        gst_pad_link (pad, sink);
+        break;
+      case TP_MEDIA_STREAM_TYPE_VIDEO:
+        pad =  gst_element_get_request_pad (priv->video_tee, "src%d");
+        gst_pad_link (pad, sink);
+        break;
+      default:
+        g_assert_not_reached ();
+    }
 
-  call_window_set_output_video_is_drawing (window, FALSE);
-  empathy_tp_call_close_channel (window->call);
-  gtk_widget_set_sensitive (window->end_call_button, FALSE);
-  gtk_widget_set_sensitive (window->start_call_button, FALSE);
 }
 
 static void
-call_window_output_volume_changed_cb (GtkWidget *scale,
-                                      EmpathyCallWindow *window)
+empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
 {
-  guint volume;
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  GstElement *preview;
+  GstBus *bus;
+
+  g_signal_connect (priv->handler, "conference-added",
+    G_CALLBACK (empathy_call_window_conference_added_cb), window);
+  g_signal_connect (priv->handler, "session-created",
+    G_CALLBACK (empathy_call_window_session_created_cb), window);
+  g_signal_connect (priv->handler, "src-pad-added",
+    G_CALLBACK (empathy_call_window_src_added_cb), window);
+  g_signal_connect (priv->handler, "sink-pad-added",
+    G_CALLBACK (empathy_call_window_sink_added_cb), window);
+
+  bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
+  empathy_call_handler_set_bus (priv->handler, bus);
+  empathy_call_handler_start_call (priv->handler);
+
+  preview = empathy_video_widget_get_element (
+    EMPATHY_VIDEO_WIDGET (priv->video_preview));
+
+  gst_bin_add_many (GST_BIN (priv->pipeline), priv->video_input,
+    priv->video_tee, preview, NULL);
+  gst_element_link_many (priv->video_input, priv->video_tee,
+    preview, NULL);
+
+  gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
+
+  g_object_unref (bus);
+}
 
-  volume = (guint) gtk_range_get_value (GTK_RANGE (scale));
+static gboolean
+empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event,
+  EmpathyCallWindow *window)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
 
-  empathy_debug (DEBUG_DOMAIN, "Output volume changed - %u", volume);
+  gst_element_set_state (priv->pipeline, GST_STATE_NULL);
 
-  empathy_tp_call_set_output_volume (window->call, volume);
+  return FALSE;
 }
 
 static void
-call_window_output_mute_button_toggled_cb (GtkWidget *button,
-                                           EmpathyCallWindow *window)
+empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
+  EmpathyCallWindow *window)
 {
-  gboolean is_muted;
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  GtkWidget *arrow;
 
-  is_muted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
-
-  empathy_debug (DEBUG_DOMAIN, "Mute output toggled - %d", is_muted);
+  if (gtk_toggle_button_get_active (toggle))
+    {
+      arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
+      gtk_widget_show (priv->sidebar);
+    }
+  else
+    {
+      arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+      gtk_widget_hide (priv->sidebar);
+    }
 
-  empathy_tp_call_mute_output (window->call, is_muted);
+  gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
 }
 
 static void
-call_window_input_mute_button_toggled_cb (GtkWidget *button,
-                                          EmpathyCallWindow *window)
+empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
+  EmpathyCallWindow *window)
 {
-  gboolean is_muted;
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  gboolean active;
+  EmpathyTpCall *call;
 
-  is_muted = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  active = (gtk_toggle_tool_button_get_active (toggle));
 
-  empathy_debug (DEBUG_DOMAIN, "Mute input toggled - %d", is_muted);
+  g_object_get (priv->handler, "tp-call", &call, NULL);
 
-  empathy_tp_call_mute_input (window->call, is_muted);
+  empathy_tp_call_request_video_stream_direction (call, active);
+
+  g_object_unref (call);
 }
 
 static void
-call_window_destroy_cb (GtkWidget *widget,
-                        EmpathyCallWindow *window)
+empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
+  EmpathyCallWindow *window)
 {
-  g_signal_handlers_disconnect_by_func (window->call,
-      call_window_status_changed_cb, window);
-  g_signal_handlers_disconnect_by_func (window->call,
-      call_window_receiving_video_cb, window);
-  g_signal_handlers_disconnect_by_func (window->call,
-      call_window_sending_video_cb, window);
-
-  g_object_unref (window->call);
-  g_object_unref (window->output_video_socket);
-  g_object_unref (window->preview_video_socket);
-  g_object_unref (window->output_video_label);
-
-  g_slice_free (EmpathyCallWindow, window);
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button),
+    FALSE);
 }
 
-GtkWidget *
-empathy_call_window_new (EmpathyTpCall *call)
+static void
+empathy_call_window_hangup (EmpathyCallWindow *window)
 {
-  EmpathyCallWindow *window;
-  GladeXML *glade;
-  guint status;
-
-  g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), NULL);
-
-  window = g_slice_new0 (EmpathyCallWindow);
-  window->call = g_object_ref (call);
-
-  glade = empathy_glade_get_file ("empathy-call-window.glade",
-      "window",
-      NULL,
-      "window", &window->window,
-      "status_label", &window->status_label,
-      "start_call_button", &window->start_call_button,
-      "end_call_button", &window->end_call_button,
-      "input_volume_scale", &window->input_volume_scale,
-      "output_volume_scale", &window->output_volume_scale,
-      "input_mute_button", &window->input_mute_button,
-      "output_mute_button", &window->output_mute_button,
-      "preview_video_frame", &window->preview_video_frame,
-      "output_video_frame", &window->output_video_frame,
-      "video_button", &window->video_button,
-      NULL);
-
-  empathy_glade_connect (glade,
-      window,
-      "window", "destroy", call_window_destroy_cb,
-      "window", "delete_event", call_window_delete_event_cb,
-      "input_mute_button", "toggled", call_window_input_mute_button_toggled_cb,
-      "output_mute_button", "toggled", call_window_output_mute_button_toggled_cb,
-      "output_volume_scale", "value-changed", call_window_output_volume_changed_cb,
-      "start_call_button", "clicked", call_window_start_call_button_clicked_cb,
-      "end_call_button", "clicked", call_window_end_call_button_clicked_cb,
-      NULL);
-
-  g_object_unref (glade);
-
-  /* Output video label */
-  window->output_video_label = g_object_ref (gtk_label_new ("No video output"));
-  gtk_container_add (GTK_CONTAINER (window->output_video_frame),
-      window->output_video_label);
-  gtk_widget_show (window->output_video_label);
-
-  /* Output video socket */
-  window->output_video_socket = g_object_ref (gtk_socket_new ());
-  g_signal_connect (GTK_OBJECT (window->output_video_socket), "realize",
-      G_CALLBACK (call_window_socket_realized_cb), window);
-  gtk_widget_show (window->output_video_socket);
-
-  /* Preview video socket */
-  window->preview_video_socket = g_object_ref (gtk_socket_new ());
-  g_signal_connect (GTK_OBJECT (window->preview_video_socket), "realize",
-      G_CALLBACK (call_window_socket_realized_cb), window);
-  gtk_container_add (GTK_CONTAINER (window->preview_video_frame),
-      window->preview_video_socket);
-  gtk_widget_show (window->preview_video_socket);
-
-  g_signal_connect (G_OBJECT (window->call), "status-changed",
-      G_CALLBACK (call_window_status_changed_cb),
-      window);
-  g_signal_connect (G_OBJECT (window->call), "receiving-video",
-      G_CALLBACK (call_window_receiving_video_cb),
-      window);
-  g_signal_connect (G_OBJECT (window->call), "sending-video",
-      G_CALLBACK (call_window_sending_video_cb),
-      window);
-
-  window->is_drawing = FALSE;
-
-  g_object_get (G_OBJECT (window->call), "status", &status, NULL);
-
-  if (status == EMPATHY_TP_CALL_STATUS_READYING)
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  gst_element_set_state (priv->pipeline, GST_STATE_NULL);
+  gtk_widget_destroy (GTK_WIDGET (window));
+}
+
+static void
+empathy_call_window_status_message (EmpathyCallWindow *window,
+  gchar *message)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  if (priv->context_id == 0)
     {
-      gtk_window_set_title (GTK_WINDOW (window->window), "Empathy Call");
-      gtk_label_set_text (GTK_LABEL (window->status_label), "Readying");
+      priv->context_id = gtk_statusbar_get_context_id (
+        GTK_STATUSBAR (priv->statusbar), "voip call status messages");
+    }
+  else
+    {
+      gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
     }
 
-  gtk_widget_show (window->window);
-
-  return window->window;
+  gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
+    message);
 }
-