Make use of generated code for using stream engine.
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 26 Feb 2008 13:31:14 +0000 (13:31 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 26 Feb 2008 13:31:14 +0000 (13:31 +0000)
svn path=/trunk/; revision=664

libempathy-gtk/empathy-call-window.c
libempathy/Makefile.am
libempathy/empathy-tp-call.c
libempathy/empathy-tp-call.h
libempathy/tp-stream-engine.xml [deleted file]
python/pyempathy/pyempathy.defs
src/Makefile.am
src/empathy-call-chandler.c

index 5cd62d1ce79a242960927a081da88ab2ba9cb1e1..7b3ebc2b5575f6b5bd69e3a113739970df0b32a3 100644 (file)
@@ -196,8 +196,8 @@ call_window_delete_event_cb (GtkWidget *widget,
           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 (gtk_socket_get_id (GTK_SOCKET
-              (window->preview_video_socket)));
+          empathy_tp_call_remove_preview_video (window->call,
+              gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
           return FALSE;
         default:
           return TRUE;
@@ -205,8 +205,8 @@ call_window_delete_event_cb (GtkWidget *widget,
     }
   else
     {
-      empathy_tp_call_remove_preview_video (gtk_socket_get_id (GTK_SOCKET
-          (window->preview_video_socket)));
+      empathy_tp_call_remove_preview_video (window->call,
+          gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
       return FALSE;
     }
 }
@@ -344,8 +344,8 @@ call_window_socket_realized_cb (GtkWidget *widget,
   if (widget == window->preview_video_socket)
     {
       empathy_debug (DEBUG_DOMAIN, "Preview socket realized");
-      empathy_tp_call_add_preview_video (gtk_socket_get_id (GTK_SOCKET
-          (window->preview_video_socket)));
+      empathy_tp_call_add_preview_video (window->call,
+          gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
     }
   else
     {
index adf9b7d5b276ddc8197144378bb3192c28d7bca7..f88a8cbc85d83160e6cd65c6b4c8a6aac657f6bc 100644 (file)
@@ -13,8 +13,7 @@ BUILT_SOURCES =                                       \
        empathy-enum-types.h                            \
        empathy-enum-types.c                            \
        empathy-filter-glue.h                           \
-       empathy-chandler-glue.h                         \
-       tp-stream-engine-gen.h
+       empathy-chandler-glue.h
 
 lib_LTLIBRARIES = libempathy.la
 
@@ -116,9 +115,6 @@ empathy-chandler-glue.h: empathy-chandler.xml Makefile
 empathy-filter-glue.h: empathy-filter.xml Makefile
        $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=empathy_filter --mode=glib-server --output=$@ $<
 
-tp-stream-engine-gen.h: tp-stream-engine.xml Makefile.am
-       $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=tp_stream_engine --mode=glib-client --output=$@ $<
-
 
 empathy-enum-types.h: stamp-empathy-enum-types.h
        @true
@@ -180,7 +176,6 @@ EXTRA_DIST =                        \
        empathy-marshal.list    \
        empathy-chandler.xml    \
        empathy-filter.xml      \
-       tp-stream-engine.xml    \
        $(stylesheet_DATA)      \
        $(dtd_DATA)             \
        $(ircnetworks_DATA)
index 7deb31c251f18467a6a532bd564bf04e6ab9ba9d..6dd24a51a34c193baa8bb303a4697b8d76034dcf 100644 (file)
 #include <libtelepathy/tp-chan-type-streamed-media-gen.h>
 #include <libtelepathy/tp-connmgr.h>
 #include <libtelepathy/tp-helpers.h>
+#include <telepathy-glib/proxy-subclass.h>
 
 #include <libmissioncontrol/mc-account.h>
 
+#include <extensions/extensions.h>
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-tp-group.h>
 #include <libempathy/empathy-utils.h>
 
-#include "tp-stream-engine-gen.h"
-
 #include "empathy-tp-call.h"
 
 #define DEBUG_DOMAIN "TpCall"
@@ -43,8 +43,6 @@
 
 #define STREAM_ENGINE_BUS_NAME "org.freedesktop.Telepathy.StreamEngine"
 #define STREAM_ENGINE_OBJECT_PATH "/org/freedesktop/Telepathy/StreamEngine"
-#define STREAM_ENGINE_INTERFACE "org.freedesktop.Telepathy.StreamEngine"
-#define CHANNEL_HANDLER_INTERFACE "org.freedesktop.Telepathy.ChannelHandler"
 
 typedef struct _EmpathyTpCallPriv EmpathyTpCallPriv;
 
@@ -52,6 +50,7 @@ struct _EmpathyTpCallPriv
 {
   TpConn *connection;
   TpChan *channel;
+  TpProxy *stream_engine;
   EmpathyTpGroup *group;
   EmpathyContact *contact;
   gboolean is_incoming;
@@ -478,29 +477,44 @@ tp_call_remote_pending_cb (EmpathyTpGroup *group,
   tp_call_is_ready (call);
 }
 
+static void
+tp_call_async_cb (TpProxy *proxy,
+                  const GError *error,
+                  gpointer user_data,
+                  GObject *weak_object)
+{
+  if (error)
+    {
+      empathy_debug (DEBUG_DOMAIN, "Error %s: %s",
+          user_data, error->message);
+    }
+}
+
 static void
 tp_call_start_stream_engine (EmpathyTpCall *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  DBusGProxy *ch_proxy;
-  GError *error = NULL;
 
   empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine");
 
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, CHANNEL_HANDLER_INTERFACE);
+  priv->stream_engine = g_object_new (TP_TYPE_PROXY,
+      "bus-name", STREAM_ENGINE_BUS_NAME,
+      "dbus-connection", tp_get_bus (),
+      "object-path", STREAM_ENGINE_OBJECT_PATH);
+  tp_proxy_add_interface_by_id (priv->stream_engine,
+      EMP_IFACE_QUARK_STREAM_ENGINE);
+  tp_proxy_add_interface_by_id (priv->stream_engine,
+      EMP_IFACE_QUARK_CHANNEL_HANDLER);
 
-  if (!org_freedesktop_Telepathy_ChannelHandler_handle_channel (ch_proxy,
+  emp_cli_channel_handler_call_handle_channel (priv->stream_engine, -1,
         dbus_g_proxy_get_bus_name (DBUS_G_PROXY (priv->connection)),
         dbus_g_proxy_get_path (DBUS_G_PROXY (priv->connection)),
         priv->channel->type,
         dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
-        priv->channel->handle_type, priv->channel->handle, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't start stream engine: %s",
-          error->message);
-      g_clear_error (&error);
-    }
+        priv->channel->handle_type, priv->channel->handle,
+        tp_call_async_cb,
+        "calling handle channel", NULL,
+        G_OBJECT (call));
 }
 
 static GObject *
@@ -541,6 +555,7 @@ tp_call_constructor (GType type,
   account = mission_control_get_account_for_connection (mc, priv->connection,
       NULL);
   priv->group = empathy_tp_group_new (account, priv->channel);
+  g_object_unref (mc);
 
   g_signal_connect (G_OBJECT (priv->group), "member-added",
       G_CALLBACK (tp_call_member_added_cb), (gpointer) call);
@@ -810,43 +825,33 @@ empathy_tp_call_close_channel (EmpathyTpCall *call)
 }
 
 void
-empathy_tp_call_add_preview_video (guint preview_video_socket_id)
+empathy_tp_call_add_preview_video (EmpathyTpCall *call,
+                                   guint preview_video_socket_id)
 {
-  GError *error = NULL;
-  DBusGProxy *ch_proxy;
+  EmpathyTpCallPriv *priv = GET_PRIV (call);
 
   empathy_debug (DEBUG_DOMAIN, "Adding preview video");
 
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_add_preview_window (ch_proxy,
-        preview_video_socket_id, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
-          error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_add_preview_window (priv->stream_engine, -1,
+      preview_video_socket_id,
+      tp_call_async_cb,
+      "adding preview window", NULL,
+      G_OBJECT (call));
 }
 
 void
-empathy_tp_call_remove_preview_video (guint preview_video_socket_id)
+empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
+                                      guint preview_video_socket_id)
 {
-  GError *error = NULL;
-  DBusGProxy *ch_proxy;
+  EmpathyTpCallPriv *priv = GET_PRIV (call);
 
   empathy_debug (DEBUG_DOMAIN, "Removing preview video");
 
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_remove_preview_window (ch_proxy,
-        preview_video_socket_id, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't set video preview: %s",
-          error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_remove_preview_window (priv->stream_engine, -1,
+      preview_video_socket_id,
+      tp_call_async_cb,
+      "removing preview window", NULL,
+      G_OBJECT (call));
 }
 
 void
@@ -854,24 +859,16 @@ empathy_tp_call_add_output_video (EmpathyTpCall *call,
                                   guint output_video_socket_id)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  const gchar *object_path;
-  DBusGProxy *ch_proxy;
-  GError *error = NULL;
 
   empathy_debug (DEBUG_DOMAIN, "Adding output video - socket: %d",
       output_video_socket_id);
 
-  object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_set_output_window (ch_proxy,
-        object_path, priv->video->id, output_video_socket_id, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't set video output: %s",
-          error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_set_output_window (priv->stream_engine, -1,
+      dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
+      priv->video->id, output_video_socket_id,
+      tp_call_async_cb,
+      "setting output window", NULL,
+      G_OBJECT (call));
 }
 
 void
@@ -879,52 +876,37 @@ empathy_tp_call_set_output_volume (EmpathyTpCall *call,
                                    guint volume)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  const gchar *object_path;
-  DBusGProxy *ch_proxy;
-  GError *error = NULL;
 
   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
     return;
 
   empathy_debug (DEBUG_DOMAIN, "Setting output volume: %d", volume);
 
-  object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_set_output_volume (ch_proxy,
-        object_path, priv->audio->id, volume, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't set volume: %s", error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_set_output_volume (priv->stream_engine, -1,
+      dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
+      priv->audio->id, volume,
+      tp_call_async_cb,
+      "setting output volume", NULL,
+      G_OBJECT (call));
 }
 
-
 void
 empathy_tp_call_mute_output (EmpathyTpCall *call,
                              gboolean is_muted)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  const gchar *object_path;
-  DBusGProxy *ch_proxy;
-  GError *error = NULL;
 
   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
     return;
 
   empathy_debug (DEBUG_DOMAIN, "Setting output mute: %d", is_muted);
 
-  object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_mute_output (ch_proxy,
-        object_path, priv->audio->id, is_muted, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't mute output: %s", error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_mute_output (priv->stream_engine, -1,
+      dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
+      priv->audio->id, is_muted,
+      tp_call_async_cb,
+      "muting output", NULL,
+      G_OBJECT (call));
 }
 
 void
@@ -932,24 +914,17 @@ empathy_tp_call_mute_input (EmpathyTpCall *call,
                             gboolean is_muted)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  const gchar *object_path;
-  DBusGProxy *ch_proxy;
-  GError *error = NULL;
 
   if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
     return;
 
   empathy_debug (DEBUG_DOMAIN, "Setting input mute: %d", is_muted);
 
-  object_path = dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel));
-  ch_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), STREAM_ENGINE_BUS_NAME,
-      STREAM_ENGINE_OBJECT_PATH, STREAM_ENGINE_INTERFACE);
-
-  if (!org_freedesktop_Telepathy_StreamEngine_mute_input (ch_proxy,
-        object_path, priv->audio->id, is_muted, &error))
-    {
-      empathy_debug (DEBUG_DOMAIN, "Couldn't mute input: %s", error->message);
-      g_clear_error (&error);
-    }
+  emp_cli_stream_engine_call_mute_input (priv->stream_engine, -1,
+      dbus_g_proxy_get_path (DBUS_G_PROXY (priv->channel)),
+      priv->audio->id, is_muted,
+      tp_call_async_cb,
+      "muting input", NULL,
+      G_OBJECT (call));
 }
 
index 69f873425d946f65b842f4ad8b2ababcd9017d3d..b0c3208261e91488ec637ebd90970308dcdf7075 100644 (file)
@@ -78,8 +78,10 @@ void empathy_tp_call_accept_incoming_call (EmpathyTpCall *call);
 void empathy_tp_call_close_channel (EmpathyTpCall *call);
 void empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
     gboolean is_sending);
-void empathy_tp_call_add_preview_video (guint preview_video_socket_id);
-void empathy_tp_call_remove_preview_video (guint preview_video_socket_id);
+void empathy_tp_call_add_preview_video (EmpathyTpCall *call,
+    guint preview_video_socket_id);
+void empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
+    guint preview_video_socket_id);
 void empathy_tp_call_add_output_video (EmpathyTpCall *call,
     guint output_video_socket_id);
 void empathy_tp_call_set_output_volume (EmpathyTpCall *call, guint volume);
diff --git a/libempathy/tp-stream-engine.xml b/libempathy/tp-stream-engine.xml
deleted file mode 100644 (file)
index 5a8783d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/TpMediaEngine">
-  <interface name="org.freedesktop.Telepathy.ChannelHandler">
-    <method name="HandleChannel">
-      <arg direction="in" type="s" name="bus_name" />
-      <arg direction="in" type="o" name="connection" />
-      <arg direction="in" type="s" name="channel_type" />
-      <arg direction="in" type="o" name="channel" />
-      <arg direction="in" type="u" name="handle_type" />
-      <arg direction="in" type="u" name="handle" />
-    </method>
-  </interface>
-  <interface name="org.freedesktop.Telepathy.StreamEngine">
-    <method name="SetOutputVolume">
-      <arg direction="in" type="o" name="channel_path" />
-      <arg direction="in" type="u" name="stream_id" />
-      <arg direction="in" type="u" name="volume" />
-    </method>
-    <method name="MuteInput">
-      <arg direction="in" type="o" name="channel_path" />
-      <arg direction="in" type="u" name="stream_id" />
-      <arg direction="in" type="b" name="mute_state" />
-    </method>
-    <method name="MuteOutput">
-      <arg direction="in" type="o" name="channel_path" />
-      <arg direction="in" type="u" name="stream_id" />
-      <arg direction="in" type="b" name="mute_state" />
-    </method>
-    <method name="SetOutputWindow">
-      <arg direction="in" type="o" name="channel_path" />
-      <arg direction="in" type="u" name="stream_id" />
-      <arg direction="in" type="u" name="window" />
-    </method>
-    <method name="AddPreviewWindow">
-      <arg direction="in" type="u" name="window" />
-    </method>
-    <method name="RemovePreviewWindow">
-      <arg direction="in" type="u" name="window" />
-    </method>
-    <signal name="Receiving">
-      <arg type="o" name="channel_path" />
-      <arg type="u" name="stream_id" />
-      <arg type="b" name="state" />
-    </signal>
-    <signal name="StreamStateChanged">
-      <arg type="o" name="channel_path" />
-      <arg type="u" name="stream_id" />
-      <arg type="u" name="state" />
-      <arg type="u" name="direction" />
-    </signal>
-    <method name="Shutdown">
-    </method>
-  </interface>
-</node>
index 8d8f7c7eada8612f90d563c306090f0f650c30d4..8196a5a349fb7c933fe4b51447e08d8958512fd2 100644 (file)
   )
 )
 
-(define-function empathy_tp_call_add_preview_video
+(define-method add_preview_video
+  (of-object "EmpathyTpCall")
   (c-name "empathy_tp_call_add_preview_video")
   (return-type "none")
   (parameters
   )
 )
 
-(define-function empathy_tp_call_remove_preview_video
+(define-method remove_preview_video
+  (of-object "EmpathyTpCall")
   (c-name "empathy_tp_call_remove_preview_video")
   (return-type "none")
   (parameters
index 59d6c5c1ffbeac7748e57ac79cf628de6fa31024..d23eea90e9816aa449c1581fa54d6a92d254b783 100644 (file)
@@ -12,6 +12,7 @@ AM_CPPFLAGS =                                         \
 LDADD =                                                                \
        $(top_builddir)/libempathy-gtk/libempathy-gtk.la        \
        $(top_builddir)/libempathy/libempathy.la                \
+       $(top_builddir)/extensions/libemp-extensions.la         \
        $(EMPATHY_LIBS)
 
 bin_PROGRAMS =                 \
index e1568c18cf2cb21b2d3c71b37c1b594b7fd1bbd5..2b359ec24bcf42819fc803eec151dc7ec4c17a5b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <libmissioncontrol/mission-control.h>
 
+#include <extensions/extensions.h>
 #include <libempathy/empathy-tp-call.h>
 #include <libempathy/empathy-chandler.h>
 #include <libempathy/empathy-debug.h>
@@ -68,6 +69,7 @@ main (int argc, char *argv[])
   EmpathyChandler *chandler;
 
   gtk_init (&argc, &argv);
+  emp_cli_init ();
 
   mc = empathy_mission_control_new ();