[empathy: 7/13] empathy_call_factory_new_call_with_streams: request channel using the CD



commit 2064d5324ec602a7a6c2e9e63d5b406e5228824c
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Jun 22 11:25:01 2010 +0200

    empathy_call_factory_new_call_with_streams: request channel using the CD
    
    Also allow caller to pass the timestamp and an optionnal callback.

 libempathy-gtk/empathy-contact-menu.c    |    6 +++-
 libempathy-gtk/empathy-new-call-dialog.c |   33 ++++++++++++++++++++++--
 libempathy/empathy-call-factory.c        |   41 +++++++++++++++++++----------
 libempathy/empathy-call-factory.h        |    8 +++++-
 4 files changed, 68 insertions(+), 20 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 6dfe63a..7c18694 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -248,7 +248,8 @@ empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item,
 	EmpathyCallFactory *factory;
 
 	factory = empathy_call_factory_get ();
-	empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE);
+	empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE,
+		gtk_get_current_event_time (), NULL, NULL);
 }
 
 GtkWidget *
@@ -280,7 +281,8 @@ empathy_contact_video_call_menu_item_activated (GtkMenuItem *item,
 	EmpathyCallFactory *factory;
 
 	factory = empathy_call_factory_get ();
-	empathy_call_factory_new_call_with_streams (factory, contact, TRUE, TRUE);
+	empathy_call_factory_new_call_with_streams (factory, contact, TRUE, TRUE,
+		gtk_get_current_event_time (), NULL, NULL);
 }
 
 GtkWidget *
diff --git a/libempathy-gtk/empathy-new-call-dialog.c b/libempathy-gtk/empathy-new-call-dialog.c
index 10d34f3..c266f89 100644
--- a/libempathy-gtk/empathy-new-call-dialog.c
+++ b/libempathy-gtk/empathy-new-call-dialog.c
@@ -68,6 +68,29 @@ struct _EmpathyNewCallDialogPriv {
  * to be started with any contact on any enabled account.
  */
 
+typedef struct
+{
+  gboolean video;
+  gint64 timestamp;
+} new_call_ctx;
+
+static new_call_ctx *
+new_call_ctx_new (gboolean video,
+    gint64 timestamp)
+{
+  new_call_ctx *ctx = g_slice_new (new_call_ctx);
+
+  ctx->video = video;
+  ctx->timestamp = timestamp;
+  return ctx;
+}
+
+static void
+new_call_ctx_free (new_call_ctx *ctx)
+{
+  g_slice_free (new_call_ctx, ctx);
+}
+
 static void
 got_contact_cb (TpConnection *connection,
     EmpathyContact *contact,
@@ -76,7 +99,7 @@ got_contact_cb (TpConnection *connection,
     GObject *object)
 {
   EmpathyCallFactory *call_factory;
-  gboolean video = GPOINTER_TO_UINT (user_data);
+  new_call_ctx *ctx = user_data;
 
   if (error != NULL)
     {
@@ -85,8 +108,9 @@ got_contact_cb (TpConnection *connection,
     }
 
   call_factory = empathy_call_factory_get ();
+
   empathy_call_factory_new_call_with_streams (call_factory, contact, TRUE,
-      video);
+      ctx->video, ctx->timestamp, NULL, NULL);
 }
 
 static void
@@ -96,6 +120,7 @@ empathy_new_call_dialog_response (GtkDialog *dialog, int response_id)
   gboolean video;
   TpConnection *connection;
   const gchar *contact_id;
+  new_call_ctx *ctx;
 
   if (response_id != GTK_RESPONSE_ACCEPT) goto out;
 
@@ -108,8 +133,10 @@ empathy_new_call_dialog_response (GtkDialog *dialog, int response_id)
    * we return from this function. */
   video = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_video));
 
+  ctx = new_call_ctx_new (video, gtk_get_current_event_time ());
+
   empathy_tp_contact_factory_get_from_id (connection, contact_id,
-      got_contact_cb, GUINT_TO_POINTER (video), NULL, NULL);
+      got_contact_cb, ctx, (GDestroyNotify) new_call_ctx_free, NULL);
 
 out:
   gtk_widget_destroy (GTK_WIDGET (dialog));
diff --git a/libempathy/empathy-call-factory.c b/libempathy/empathy-call-factory.c
index 376ff91..65ab883 100644
--- a/libempathy/empathy-call-factory.c
+++ b/libempathy/empathy-call-factory.c
@@ -26,6 +26,7 @@
 #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"
@@ -205,21 +206,33 @@ void
 empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory,
     EmpathyContact *contact,
     gboolean initial_audio,
-    gboolean initial_video)
+    gboolean initial_video,
+    gint64 timestamp,
+    EmpathyDispatcherRequestCb callback,
+    gpointer user_data)
 {
-  EmpathyCallHandler *handler;
-
-  g_return_if_fail (factory != NULL);
-  g_return_if_fail (contact != NULL);
-
-  handler = empathy_call_handler_new_for_contact_with_streams (contact,
-    initial_audio, initial_video);
-
-  g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
-    handler, TRUE);
-
-  g_object_unref (handler);
-#endif
+  EmpathyDispatcher *dispatcher;
+  GHashTable *request;
+
+  request = 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);
+
+  dispatcher = empathy_dispatcher_dup_singleton ();
+
+  empathy_dispatcher_create_channel (dispatcher,
+      empathy_contact_get_connection (contact), request, timestamp, callback,
+      user_data);
+
+  g_object_unref (dispatcher);
 }
 
 static void
diff --git a/libempathy/empathy-call-factory.h b/libempathy/empathy-call-factory.h
index c17163d..b9b812b 100644
--- a/libempathy/empathy-call-factory.h
+++ b/libempathy/empathy-call-factory.h
@@ -25,6 +25,7 @@
 
 #include <libempathy/empathy-dispatch-operation.h>
 #include <libempathy/empathy-call-handler.h>
+#include <libempathy/empathy-dispatcher.h>
 
 G_BEGIN_DECLS
 
@@ -65,7 +66,12 @@ EmpathyCallFactory *empathy_call_factory_initialise (void);
 EmpathyCallFactory *empathy_call_factory_get (void);
 
 void empathy_call_factory_new_call_with_streams (EmpathyCallFactory *factory,
-  EmpathyContact *contact, gboolean initial_audio, gboolean initial_video);
+  EmpathyContact *contact,
+  gboolean initial_audio,
+  gboolean initial_video,
+  gint64 timestamp,
+  EmpathyDispatcherRequestCb callback,
+  gpointer user_data);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]