]> git.0d.be Git - empathy.git/commitdiff
EmpathyCallFactory -> EmpathyStreamedMediaFactory
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Wed, 9 Feb 2011 16:29:24 +0000 (16:29 +0000)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Thu, 10 Feb 2011 09:24:55 +0000 (09:24 +0000)
15 files changed:
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-contact-menu.c
libempathy-gtk/empathy-individual-menu.c
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-new-call-dialog.c
libempathy/Makefile.am
libempathy/empathy-call-factory.c [deleted file]
libempathy/empathy-call-factory.h [deleted file]
libempathy/empathy-streamed-media-factory.c [new file with mode: 0644]
libempathy/empathy-streamed-media-factory.h [new file with mode: 0644]
libempathy/empathy-streamed-media-handler.c
libempathy/empathy-streamed-media-handler.h
src/empathy-av.c
src/empathy-event-manager.c
src/empathy-streamed-media-window.c

index 4ab3607ec7bea94a08becb7ac407178f097bdd94..c558738df78bf0e0c9aa3be1f7e48f6352940779 100644 (file)
@@ -34,7 +34,6 @@
 #include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/util.h>
 
-#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-contact-groups.h>
index 00d83ce5b060962a82d663c7339d93c001879127..ac5d98f48c03caef8210560e178e41fbd2ee3d33 100644 (file)
@@ -27,7 +27,7 @@
 #include <gtk/gtk.h>
 #include <telepathy-logger/log-manager.h>
 
-#include <libempathy/empathy-call-factory.h>
+#include <libempathy/empathy-streamed-media-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-dispatcher.h>
 #include <libempathy/empathy-utils.h>
@@ -248,7 +248,7 @@ empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item,
        EmpathyContact *contact)
 {
 
-       empathy_call_factory_new_call_with_streams (contact, TRUE, FALSE,
+       empathy_streamed_media_factory_new_call_with_streams (contact, TRUE, FALSE,
                gtk_get_current_event_time (), NULL);
 }
 
@@ -279,7 +279,7 @@ static void
 empathy_contact_video_call_menu_item_activated (GtkMenuItem *item,
        EmpathyContact *contact)
 {
-       empathy_call_factory_new_call_with_streams (contact, TRUE, TRUE,
+       empathy_streamed_media_factory_new_call_with_streams (contact, TRUE, TRUE,
                gtk_get_current_event_time (), NULL);
 }
 
index 76d708156e8dfb94e71eb4744ef150844075b27d..faa4ff6aaa7073c07a1649d60388a9bfb416de19 100644 (file)
@@ -31,7 +31,7 @@
 #include <folks/folks.h>
 #include <folks/folks-telepathy.h>
 
-#include <libempathy/empathy-call-factory.h>
+#include <libempathy/empathy-streamed-media-factory.h>
 #include <libempathy/empathy-dispatcher.h>
 #include <libempathy/empathy-individual-manager.h>
 #include <libempathy/empathy-chatroom-manager.h>
@@ -543,7 +543,7 @@ empathy_individual_audio_call_menu_item_activated (GtkMenuItem *item,
 {
   g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-  empathy_call_factory_new_call_with_streams (contact, TRUE, FALSE,
+  empathy_streamed_media_factory_new_call_with_streams (contact, TRUE, FALSE,
       gtk_get_current_event_time (), NULL);
 }
 
@@ -585,7 +585,7 @@ empathy_individual_video_call_menu_item_activated (GtkMenuItem *item,
 {
   g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-  empathy_call_factory_new_call_with_streams (contact, TRUE, TRUE,
+  empathy_streamed_media_factory_new_call_with_streams (contact, TRUE, TRUE,
       gtk_get_current_event_time (), NULL);
 }
 
index d384d780900e88fdf80289fc9cbb8e44d82b50e3..f2574408f97865ffb9ff1d625af4f14b2bf69c09 100644 (file)
@@ -38,7 +38,6 @@
 #include <folks/folks.h>
 #include <folks/folks-telepathy.h>
 
-#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-individual-manager.h>
 #include <libempathy/empathy-contact-groups.h>
 #include <libempathy/empathy-dispatcher.h>
index ab9a86a6f7b0ce519884b9e6397aa25655aba51c..2d35fadecfc486bcb74814c565d154c9815c5575 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-contact-manager.h>
-#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-utils.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
index 0255156042e03b79cc3e758c3a40d376692479f2..b2d88885f2cbedaac40c3a6d1a136733fe4e86c3 100644 (file)
@@ -28,7 +28,6 @@ noinst_LTLIBRARIES = libempathy.la
 libempathy_headers =                           \
        empathy-account-settings.h              \
        empathy-auth-factory.h                  \
-       empathy-call-factory.h                  \
        empathy-chatroom-manager.h              \
        empathy-chatroom.h                      \
        empathy-connection-managers.h           \
@@ -53,6 +52,7 @@ libempathy_headers =                          \
        empathy-server-sasl-handler.h           \
        empathy-server-tls-handler.h            \
        empathy-status-presets.h                \
+       empathy-streamed-media-factory.h        \
        empathy-streamed-media-handler.h        \
        empathy-time.h                          \
        empathy-tls-certificate.h               \
@@ -70,7 +70,6 @@ libempathy_la_SOURCES =                                       \
        $(libempathy_headers)                           \
        empathy-account-settings.c                      \
        empathy-auth-factory.c                          \
-       empathy-call-factory.c                          \
        empathy-chatroom-manager.c                      \
        empathy-chatroom.c                              \
        empathy-connection-managers.c                   \
@@ -93,6 +92,7 @@ libempathy_la_SOURCES =                                       \
        empathy-server-sasl-handler.c                   \
        empathy-server-tls-handler.c                    \
        empathy-status-presets.c                        \
+       empathy-streamed-media-factory.c                \
        empathy-streamed-media-handler.c                \
        empathy-time.c                                  \
        empathy-tls-certificate.c                       \
diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c
deleted file mode 100644 (file)
index 281434c..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * empathy-call-factory.c - Source for EmpathyCallFactory
- * 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 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
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <telepathy-glib/account-channel-request.h>
-#include <telepathy-glib/simple-handler.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/util.h>
-
-#include "empathy-dispatcher.h"
-#include "empathy-marshal.h"
-#include "empathy-call-factory.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
-
-G_DEFINE_TYPE(EmpathyCallFactory, empathy_call_factory, G_TYPE_OBJECT)
-
-static void handle_channels_cb (TpSimpleHandler *handler,
-    TpAccount *account,
-    TpConnection *connection,
-    GList *channels,
-    GList *requests_satisfied,
-    gint64 user_action_time,
-    TpHandleChannelsContext *context,
-    gpointer user_data);
-
-/* signal enum */
-enum
-{
-    NEW_STREAMED_MEDIA_HANDLER,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-/* private structure */
-typedef struct {
-  TpBaseClient *handler;
-  gboolean dispose_has_run;
-} EmpathyCallFactoryPriv;
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCallFactory)
-
-static GObject *call_factory = NULL;
-
-static void
-empathy_call_factory_init (EmpathyCallFactory *obj)
-{
-  EmpathyCallFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
-    EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPriv);
-  TpDBusDaemon *dbus;
-  GError *error = NULL;
-
-  obj->priv = priv;
-
-  dbus = tp_dbus_daemon_dup (&error);
-  if (dbus == NULL)
-    {
-      g_warning ("Failed to get TpDBusDaemon: %s", error->message);
-      g_error_free (error);
-      return;
-    }
-
-  priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
-      "Empathy.AudioVideo", FALSE, handle_channels_cb, obj, NULL);
-
-  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
-        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
-        NULL));
-
-  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
-        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
-        TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE,
-        NULL));
-
-  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
-        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
-        TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE,
-        NULL));
-
-  tp_base_client_add_handler_capabilities_varargs (priv->handler,
-    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp",
-    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p",
-    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264",
-    NULL);
-
-  g_object_unref (dbus);
-}
-
-static GObject *
-empathy_call_factory_constructor (GType type, guint n_construct_params,
-  GObjectConstructParam *construct_params)
-{
-  g_return_val_if_fail (call_factory == NULL, NULL);
-
-  call_factory = G_OBJECT_CLASS (empathy_call_factory_parent_class)->constructor
-          (type, n_construct_params, construct_params);
-  g_object_add_weak_pointer (call_factory, (gpointer)&call_factory);
-
-  return call_factory;
-}
-
-static void
-empathy_call_factory_finalize (GObject *object)
-{
-  /* free any data held directly by the object here */
-
-  if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize)
-    G_OBJECT_CLASS (empathy_call_factory_parent_class)->finalize (object);
-}
-
-static void
-empathy_call_factory_dispose (GObject *object)
-{
-  EmpathyCallFactoryPriv *priv = GET_PRIV (object);
-
-  if (priv->dispose_has_run)
-    return;
-
-  priv->dispose_has_run = TRUE;
-
-  tp_clear_object (&priv->handler);
-
-  if (G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose)
-    G_OBJECT_CLASS (empathy_call_factory_parent_class)->dispose (object);
-}
-
-static void
-empathy_call_factory_class_init (
-  EmpathyCallFactoryClass *empathy_call_factory_class)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_factory_class);
-
-  g_type_class_add_private (empathy_call_factory_class,
-    sizeof (EmpathyCallFactoryPriv));
-
-  object_class->constructor = empathy_call_factory_constructor;
-  object_class->dispose = empathy_call_factory_dispose;
-  object_class->finalize = empathy_call_factory_finalize;
-
-  signals[NEW_STREAMED_MEDIA_HANDLER] =
-    g_signal_new ("new-streamed-media-handler",
-      G_TYPE_FROM_CLASS (empathy_call_factory_class),
-      G_SIGNAL_RUN_LAST, 0,
-      NULL, NULL,
-      _empathy_marshal_VOID__OBJECT_BOOLEAN,
-      G_TYPE_NONE,
-      2, EMPATHY_TYPE_STREAMED_MEDIA_HANDLER, G_TYPE_BOOLEAN);
-}
-
-EmpathyCallFactory *
-empathy_call_factory_initialise (void)
-{
-  g_return_val_if_fail (call_factory == NULL, NULL);
-
-  return EMPATHY_CALL_FACTORY (g_object_new (EMPATHY_TYPE_CALL_FACTORY, NULL));
-}
-
-EmpathyCallFactory *
-empathy_call_factory_get (void)
-{
-  g_return_val_if_fail (call_factory != NULL, NULL);
-
-  return EMPATHY_CALL_FACTORY (call_factory);
-}
-
-GHashTable *
-empathy_call_factory_create_request (EmpathyContact *contact,
-    gboolean initial_audio,
-    gboolean initial_video)
-{
-  return tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-        TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
-      TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT,
-        empathy_contact_get_handle (contact),
-      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN,
-        initial_audio,
-      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN,
-        initial_video,
-      NULL);
-}
-
-static void
-create_media_channel_cb (GObject *source,
-    GAsyncResult *result,
-    gpointer user_data)
-{
-  GError *error = NULL;
-
-  if (!tp_account_channel_request_create_channel_finish (
-        TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
-    {
-      DEBUG ("Failed to create media channel: %s", error->message);
-      g_error_free (error);
-    }
-}
-
-/**
- * empathy_call_factory_new_call_with_streams:
- * @factory: an #EmpathyCallFactory
- * @contact: an #EmpathyContact
- * @initial_audio: if %TRUE the call will be started with audio
- * @initial_video: if %TRUE the call will be started with video
- *
- * Initiate a new call with @contact.
- */
-void
-empathy_call_factory_new_call_with_streams (EmpathyContact *contact,
-    gboolean initial_audio,
-    gboolean initial_video,
-    gint64 timestamp,
-    gpointer user_data)
-{
-  GHashTable *request;
-  TpAccount *account;
-  TpAccountChannelRequest *req;
-
-  request = empathy_call_factory_create_request (contact, initial_audio,
-      initial_video);
-
-  account = empathy_contact_get_account (contact);
-
-  req = tp_account_channel_request_new (account, request, timestamp);
-
-  tp_account_channel_request_create_channel_async (req, NULL, NULL,
-      create_media_channel_cb, NULL);
-
-  g_hash_table_unref (request);
-  g_object_unref (req);
-}
-
-static void
-create_call_handler (EmpathyCallFactory *factory,
-  EmpathyTpStreamedMedia *call)
-{
-  EmpathyStreamedMediaHandler *handler;
-
-  g_return_if_fail (factory != NULL);
-
-  handler = empathy_streamed_media_handler_new_for_channel (call);
-
-  g_signal_emit (factory, signals[NEW_STREAMED_MEDIA_HANDLER], 0,
-    handler, FALSE);
-
-  g_object_unref (handler);
-}
-
-static void
-call_status_changed_cb (EmpathyTpStreamedMedia *call,
-    GParamSpec *spec,
-    EmpathyCallFactory *self)
-{
-  if (empathy_tp_streamed_media_get_status (call) <= EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING)
-    return;
-
-  create_call_handler (self, call);
-
-  g_signal_handlers_disconnect_by_func (call, call_status_changed_cb, self);
-  g_object_unref (call);
-}
-
-static void
-handle_channels_cb (TpSimpleHandler *handler,
-    TpAccount *account,
-    TpConnection *connection,
-    GList *channels,
-    GList *requests_satisfied,
-    gint64 user_action_time,
-    TpHandleChannelsContext *context,
-    gpointer user_data)
-{
-  EmpathyCallFactory *self = user_data;
-  GList *l;
-
-  for (l = channels; l != NULL; l = g_list_next (l))
-    {
-      TpChannel *channel = l->data;
-      EmpathyTpStreamedMedia *call;
-
-      if (tp_proxy_get_invalidated (channel) != NULL)
-        continue;
-
-      if (tp_channel_get_channel_type_id (channel) !=
-          TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
-        continue;
-
-      call = empathy_tp_streamed_media_new (account, channel);
-
-      if (empathy_tp_streamed_media_get_status (call) <= EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING)
-        {
-          /* We have to wait that the TpStreamedMedia is ready as the
-           * call-handler rely on it. */
-          tp_g_signal_connect_object (call, "notify::status",
-              G_CALLBACK (call_status_changed_cb), self, 0);
-          continue;
-        }
-
-      create_call_handler (self, call);
-      g_object_unref (call);
-    }
-
-  tp_handle_channels_context_accept (context);
-}
-
-gboolean
-empathy_call_factory_register (EmpathyCallFactory *self,
-    GError **error)
-{
-  EmpathyCallFactoryPriv *priv = GET_PRIV (self);
-
-  return tp_base_client_register (priv->handler, error);
-}
diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h
deleted file mode 100644 (file)
index 36c0891..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * empathy-call-factory.h - Header for EmpathyCallFactory
- * 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 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
- */
-
-#ifndef __EMPATHY_CALL_FACTORY_H__
-#define __EMPATHY_CALL_FACTORY_H__
-
-#include <glib-object.h>
-
-#include <libempathy/empathy-streamed-media-handler.h>
-#include <libempathy/empathy-dispatcher.h>
-
-G_BEGIN_DECLS
-
-typedef struct _EmpathyCallFactory EmpathyCallFactory;
-typedef struct _EmpathyCallFactoryClass EmpathyCallFactoryClass;
-
-struct _EmpathyCallFactoryClass {
-    GObjectClass parent_class;
-};
-
-struct _EmpathyCallFactory {
-    GObject parent;
-    gpointer priv;
-};
-
-GType empathy_call_factory_get_type (void);
-
-/* TYPE MACROS */
-#define EMPATHY_TYPE_CALL_FACTORY \
-  (empathy_call_factory_get_type ())
-#define EMPATHY_CALL_FACTORY(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_CALL_FACTORY, \
-    EmpathyCallFactory))
-#define EMPATHY_CALL_FACTORY_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_CALL_FACTORY, \
-    EmpathyCallFactoryClass))
-#define EMPATHY_IS_CALL_FACTORY(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_CALL_FACTORY))
-#define EMPATHY_IS_CALL_FACTORY_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_CALL_FACTORY))
-#define EMPATHY_CALL_FACTORY_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CALL_FACTORY, \
-    EmpathyCallFactoryClass))
-
-
-EmpathyCallFactory *empathy_call_factory_initialise (void);
-
-EmpathyCallFactory *empathy_call_factory_get (void);
-
-void empathy_call_factory_new_call_with_streams (EmpathyContact *contact,
-  gboolean initial_audio,
-  gboolean initial_video,
-  gint64 timestamp,
-  gpointer user_data);
-
-gboolean empathy_call_factory_register (EmpathyCallFactory *self,
-    GError **error);
-
-GHashTable * empathy_call_factory_create_request (EmpathyContact *contact,
-    gboolean initial_audio,
-    gboolean initial_video);
-
-G_END_DECLS
-
-#endif /* #ifndef __EMPATHY_CALL_FACTORY_H__*/
diff --git a/libempathy/empathy-streamed-media-factory.c b/libempathy/empathy-streamed-media-factory.c
new file mode 100644 (file)
index 0000000..7e77855
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * empathy-streamed-media-factory.c - Source for EmpathyStreamedMediaFactory
+ * Copyright (C) 2008-2011 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 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
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <telepathy-glib/account-channel-request.h>
+#include <telepathy-glib/simple-handler.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/util.h>
+
+#include "empathy-dispatcher.h"
+#include "empathy-marshal.h"
+#include "empathy-streamed-media-factory.h"
+#include "empathy-utils.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
+#include <libempathy/empathy-debug.h>
+
+G_DEFINE_TYPE(EmpathyStreamedMediaFactory, empathy_streamed_media_factory, G_TYPE_OBJECT)
+
+static void handle_channels_cb (TpSimpleHandler *handler,
+    TpAccount *account,
+    TpConnection *connection,
+    GList *channels,
+    GList *requests_satisfied,
+    gint64 user_action_time,
+    TpHandleChannelsContext *context,
+    gpointer user_data);
+
+/* signal enum */
+enum
+{
+    NEW_STREAMED_MEDIA_HANDLER,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+/* private structure */
+typedef struct {
+  TpBaseClient *handler;
+  gboolean dispose_has_run;
+} EmpathyStreamedMediaFactoryPriv;
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyStreamedMediaFactory)
+
+static GObject *call_factory = NULL;
+
+static void
+empathy_streamed_media_factory_init (EmpathyStreamedMediaFactory *obj)
+{
+  EmpathyStreamedMediaFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
+    EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, EmpathyStreamedMediaFactoryPriv);
+  TpDBusDaemon *dbus;
+  GError *error = NULL;
+
+  obj->priv = priv;
+
+  dbus = tp_dbus_daemon_dup (&error);
+  if (dbus == NULL)
+    {
+      g_warning ("Failed to get TpDBusDaemon: %s", error->message);
+      g_error_free (error);
+      return;
+    }
+
+  priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
+      "Empathy.AudioVideo", FALSE, handle_channels_cb, obj, NULL);
+
+  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
+        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
+        NULL));
+
+  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
+        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
+        TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE,
+        NULL));
+
+  tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
+        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+          TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
+        TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE,
+        NULL));
+
+  tp_base_client_add_handler_capabilities_varargs (priv->handler,
+    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp",
+    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p",
+    "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264",
+    NULL);
+
+  g_object_unref (dbus);
+}
+
+static GObject *
+empathy_streamed_media_factory_constructor (GType type, guint n_construct_params,
+  GObjectConstructParam *construct_params)
+{
+  g_return_val_if_fail (call_factory == NULL, NULL);
+
+  call_factory = G_OBJECT_CLASS (empathy_streamed_media_factory_parent_class)->constructor
+          (type, n_construct_params, construct_params);
+  g_object_add_weak_pointer (call_factory, (gpointer)&call_factory);
+
+  return call_factory;
+}
+
+static void
+empathy_streamed_media_factory_finalize (GObject *object)
+{
+  /* free any data held directly by the object here */
+
+  if (G_OBJECT_CLASS (empathy_streamed_media_factory_parent_class)->finalize)
+    G_OBJECT_CLASS (empathy_streamed_media_factory_parent_class)->finalize (object);
+}
+
+static void
+empathy_streamed_media_factory_dispose (GObject *object)
+{
+  EmpathyStreamedMediaFactoryPriv *priv = GET_PRIV (object);
+
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
+
+  tp_clear_object (&priv->handler);
+
+  if (G_OBJECT_CLASS (empathy_streamed_media_factory_parent_class)->dispose)
+    G_OBJECT_CLASS (empathy_streamed_media_factory_parent_class)->dispose (object);
+}
+
+static void
+empathy_streamed_media_factory_class_init (
+  EmpathyStreamedMediaFactoryClass *empathy_streamed_media_factory_class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (empathy_streamed_media_factory_class);
+
+  g_type_class_add_private (empathy_streamed_media_factory_class,
+    sizeof (EmpathyStreamedMediaFactoryPriv));
+
+  object_class->constructor = empathy_streamed_media_factory_constructor;
+  object_class->dispose = empathy_streamed_media_factory_dispose;
+  object_class->finalize = empathy_streamed_media_factory_finalize;
+
+  signals[NEW_STREAMED_MEDIA_HANDLER] =
+    g_signal_new ("new-streamed-media-handler",
+      G_TYPE_FROM_CLASS (empathy_streamed_media_factory_class),
+      G_SIGNAL_RUN_LAST, 0,
+      NULL, NULL,
+      _empathy_marshal_VOID__OBJECT_BOOLEAN,
+      G_TYPE_NONE,
+      2, EMPATHY_TYPE_STREAMED_MEDIA_HANDLER, G_TYPE_BOOLEAN);
+}
+
+EmpathyStreamedMediaFactory *
+empathy_streamed_media_factory_initialise (void)
+{
+  g_return_val_if_fail (call_factory == NULL, NULL);
+
+  return EMPATHY_STREAMED_MEDIA_FACTORY (g_object_new (EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, NULL));
+}
+
+EmpathyStreamedMediaFactory *
+empathy_streamed_media_factory_get (void)
+{
+  g_return_val_if_fail (call_factory != NULL, NULL);
+
+  return EMPATHY_STREAMED_MEDIA_FACTORY (call_factory);
+}
+
+GHashTable *
+empathy_streamed_media_factory_create_request (EmpathyContact *contact,
+    gboolean initial_audio,
+    gboolean initial_video)
+{
+  return tp_asv_new (
+      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+        TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
+      TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT,
+        empathy_contact_get_handle (contact),
+      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN,
+        initial_audio,
+      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN,
+        initial_video,
+      NULL);
+}
+
+static void
+create_media_channel_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  GError *error = NULL;
+
+  if (!tp_account_channel_request_create_channel_finish (
+        TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
+    {
+      DEBUG ("Failed to create media channel: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+/**
+ * empathy_streamed_media_factory_new_call_with_streams:
+ * @factory: an #EmpathyStreamedMediaFactory
+ * @contact: an #EmpathyContact
+ * @initial_audio: if %TRUE the call will be started with audio
+ * @initial_video: if %TRUE the call will be started with video
+ *
+ * Initiate a new call with @contact.
+ */
+void
+empathy_streamed_media_factory_new_call_with_streams (EmpathyContact *contact,
+    gboolean initial_audio,
+    gboolean initial_video,
+    gint64 timestamp,
+    gpointer user_data)
+{
+  GHashTable *request;
+  TpAccount *account;
+  TpAccountChannelRequest *req;
+
+  request = empathy_streamed_media_factory_create_request (contact, initial_audio,
+      initial_video);
+
+  account = empathy_contact_get_account (contact);
+
+  req = tp_account_channel_request_new (account, request, timestamp);
+
+  tp_account_channel_request_create_channel_async (req, NULL, NULL,
+      create_media_channel_cb, NULL);
+
+  g_hash_table_unref (request);
+  g_object_unref (req);
+}
+
+static void
+create_streamed_media_handler (EmpathyStreamedMediaFactory *factory,
+  EmpathyTpStreamedMedia *call)
+{
+  EmpathyStreamedMediaHandler *handler;
+
+  g_return_if_fail (factory != NULL);
+
+  handler = empathy_streamed_media_handler_new_for_channel (call);
+
+  g_signal_emit (factory, signals[NEW_STREAMED_MEDIA_HANDLER], 0,
+    handler, FALSE);
+
+  g_object_unref (handler);
+}
+
+static void
+call_status_changed_cb (EmpathyTpStreamedMedia *call,
+    GParamSpec *spec,
+    EmpathyStreamedMediaFactory *self)
+{
+  if (empathy_tp_streamed_media_get_status (call) <= EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING)
+    return;
+
+  create_streamed_media_handler (self, call);
+
+  g_signal_handlers_disconnect_by_func (call, call_status_changed_cb, self);
+  g_object_unref (call);
+}
+
+static void
+handle_channels_cb (TpSimpleHandler *handler,
+    TpAccount *account,
+    TpConnection *connection,
+    GList *channels,
+    GList *requests_satisfied,
+    gint64 user_action_time,
+    TpHandleChannelsContext *context,
+    gpointer user_data)
+{
+  EmpathyStreamedMediaFactory *self = user_data;
+  GList *l;
+
+  for (l = channels; l != NULL; l = g_list_next (l))
+    {
+      TpChannel *channel = l->data;
+      EmpathyTpStreamedMedia *call;
+
+      if (tp_proxy_get_invalidated (channel) != NULL)
+        continue;
+
+      if (tp_channel_get_channel_type_id (channel) !=
+          TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA)
+        continue;
+
+      call = empathy_tp_streamed_media_new (account, channel);
+
+      if (empathy_tp_streamed_media_get_status (call) <= EMPATHY_TP_STREAMED_MEDIA_STATUS_READYING)
+        {
+          /* We have to wait that the TpStreamedMedia is ready as the
+           * call-handler rely on it. */
+          tp_g_signal_connect_object (call, "notify::status",
+              G_CALLBACK (call_status_changed_cb), self, 0);
+          continue;
+        }
+
+      create_streamed_media_handler (self, call);
+      g_object_unref (call);
+    }
+
+  tp_handle_channels_context_accept (context);
+}
+
+gboolean
+empathy_streamed_media_factory_register (EmpathyStreamedMediaFactory *self,
+    GError **error)
+{
+  EmpathyStreamedMediaFactoryPriv *priv = GET_PRIV (self);
+
+  return tp_base_client_register (priv->handler, error);
+}
diff --git a/libempathy/empathy-streamed-media-factory.h b/libempathy/empathy-streamed-media-factory.h
new file mode 100644 (file)
index 0000000..ab433bb
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * empathy-streamed-media-factory.h - Header for EmpathyStreamedMediaFactory
+ * Copyright (C) 2008-2011 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 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
+ */
+
+#ifndef __EMPATHY_STREAMED_MEDIA_FACTORY_H__
+#define __EMPATHY_STREAMED_MEDIA_FACTORY_H__
+
+#include <glib-object.h>
+
+#include <libempathy/empathy-streamed-media-handler.h>
+#include <libempathy/empathy-dispatcher.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EmpathyStreamedMediaFactory EmpathyStreamedMediaFactory;
+typedef struct _EmpathyStreamedMediaFactoryClass EmpathyStreamedMediaFactoryClass;
+
+struct _EmpathyStreamedMediaFactoryClass {
+    GObjectClass parent_class;
+};
+
+struct _EmpathyStreamedMediaFactory {
+    GObject parent;
+    gpointer priv;
+};
+
+GType empathy_streamed_media_factory_get_type (void);
+
+/* TYPE MACROS */
+#define EMPATHY_TYPE_STREAMED_MEDIA_FACTORY \
+  (empathy_streamed_media_factory_get_type ())
+#define EMPATHY_STREAMED_MEDIA_FACTORY(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, \
+    EmpathyStreamedMediaFactory))
+#define EMPATHY_STREAMED_MEDIA_FACTORY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, \
+    EmpathyStreamedMediaFactoryClass))
+#define EMPATHY_IS_STREAMED_MEDIA_FACTORY(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_STREAMED_MEDIA_FACTORY))
+#define EMPATHY_IS_STREAMED_MEDIA_FACTORY_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_STREAMED_MEDIA_FACTORY))
+#define EMPATHY_STREAMED_MEDIA_FACTORY_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, \
+    EmpathyStreamedMediaFactoryClass))
+
+
+EmpathyStreamedMediaFactory *empathy_streamed_media_factory_initialise (void);
+
+EmpathyStreamedMediaFactory *empathy_streamed_media_factory_get (void);
+
+void empathy_streamed_media_factory_new_call_with_streams (EmpathyContact *contact,
+  gboolean initial_audio,
+  gboolean initial_video,
+  gint64 timestamp,
+  gpointer user_data);
+
+gboolean empathy_streamed_media_factory_register (EmpathyStreamedMediaFactory *self,
+    GError **error);
+
+GHashTable * empathy_streamed_media_factory_create_request (EmpathyContact *contact,
+    gboolean initial_audio,
+    gboolean initial_video);
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_STREAMED_MEDIA_FACTORY_H__*/
index 7fa49cde70c5698b0085be3b41a3eade82f353de..152cf644ecd3d8a18cd59aae70a4c681f9d7be7b 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * empathy-call-handler.c - Source for EmpathyStreamedMediaHandler
- * Copyright (C) 2008-2009 Collabora Ltd.
+ * empathy-streamed-media-handler.c - Source for EmpathyStreamedMediaHandler
+ * Copyright (C) 2008-2011 Collabora Ltd.
  * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
@@ -30,7 +30,7 @@
 #include <telepathy-farsight/stream.h>
 
 #include "empathy-streamed-media-handler.h"
-#include "empathy-call-factory.h"
+#include "empathy-streamed-media-factory.h"
 #include "empathy-marshal.h"
 #include "empathy-utils.h"
 
@@ -806,7 +806,7 @@ empathy_streamed_media_handler_start_call (EmpathyStreamedMediaHandler *handler,
   g_assert (priv->contact != NULL);
 
   account = empathy_contact_get_account (priv->contact);
-  request = empathy_call_factory_create_request (priv->contact,
+  request = empathy_streamed_media_factory_create_request (priv->contact,
       priv->initial_audio, priv->initial_video);
 
   req = tp_account_channel_request_new (account, request, timestamp);
index b6d7049c230bdba3175c3ffc49fe4ae45f333fef..ab655b8e454ecf30d342afad29a0c5bf5184c89c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * empathy-call-handler.h - Header for EmpathyStreamedMediaHandler
+ * empathy-streamed-media-handler.h - Header for EmpathyStreamedMediaHandler
  * Copyright (C) 2008-2009 Collabora Ltd.
  * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
  *
index 6aef1fdd1335460f674853580319c688f8cc4474..cfe71d1a536d471c523ddbbe14df0d89293b69db 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <telepathy-glib/debug-sender.h>
 
-#include <libempathy/empathy-call-factory.h>
+#include <libempathy/empathy-streamed-media-factory.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
 #include "empathy-streamed-media-window.h"
@@ -47,17 +47,17 @@ static GtkApplication *app = NULL;
 static gboolean activated = FALSE;
 static gboolean use_timer = TRUE;
 
-static EmpathyCallFactory *call_factory = NULL;
+static EmpathyStreamedMediaFactory *call_factory = NULL;
 
 static void
-new_call_handler_cb (EmpathyCallFactory *factory,
+new_call_handler_cb (EmpathyStreamedMediaFactory *factory,
     EmpathyStreamedMediaHandler *handler,
     gboolean outgoing,
     gpointer user_data)
 {
   EmpathyStreamedMediaWindow *window;
 
-  DEBUG ("Create a new call window");
+  DEBUG ("Create a new StreamedMedia window");
 
   window = empathy_streamed_media_window_new (handler);
 
@@ -86,12 +86,12 @@ activate_cb (GApplication *application)
     }
 
   g_assert (call_factory == NULL);
-  call_factory = empathy_call_factory_initialise ();
+  call_factory = empathy_streamed_media_factory_initialise ();
 
   g_signal_connect (G_OBJECT (call_factory), "new-streamed-media-handler",
       G_CALLBACK (new_call_handler_cb), NULL);
 
-  if (!empathy_call_factory_register (call_factory, &error))
+  if (!empathy_streamed_media_factory_register (call_factory, &error))
     {
       g_critical ("Failed to register Handler: %s", error->message);
       g_error_free (error);
index ffe8e597f6881dc97665a69e3dd0121f44fe1afa..96950c5f90152c3c8f46ce65dda6e3598e9e7950 100644 (file)
@@ -36,7 +36,6 @@
 #include <libempathy/empathy-tp-streamed-media.h>
 #include <libempathy/empathy-tp-file.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-gsettings.h>
 
 #include <extensions/extensions.h>
index c324d45c06941e3cc559404c670caaeac3c77954..2408f975adf38369e3a7f7f1224a46248e0524ca 100644 (file)
@@ -36,7 +36,6 @@
 #include <gst/farsight/fs-element-added-notifier.h>
 
 #include <libempathy/empathy-tp-contact-factory.h>
-#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy-gtk/empathy-avatar-image.h>
 #include <libempathy-gtk/empathy-video-widget.h>