]> git.0d.be Git - empathy.git/commitdiff
NewCallDialog: support Calls
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Fri, 18 Feb 2011 16:26:28 +0000 (16:26 +0000)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Wed, 8 Jun 2011 15:39:18 +0000 (16:39 +0100)
Conflicts:

libempathy-gtk/Makefile.am
libempathy-gtk/empathy-new-call-dialog.c

libempathy-gtk/Makefile.am
libempathy-gtk/empathy-new-call-dialog.c

index be1aeeea3bdc31a2deeed248a398a61ff0dff795..3b00f6ebd62648bd5ab085640531617f62666745 100644 (file)
@@ -8,6 +8,7 @@ AM_CPPFLAGS =                                           \
        -DPKGDATADIR=\""$(pkgdatadir)"\"                \
        -DGCR_API_SUBJECT_TO_CHANGE                     \
        $(EMPATHY_CFLAGS)                               \
+       $(YELL_CFLAGS)                                  \
        $(ENCHANT_CFLAGS)                               \
        $(LIBCHAMPLAIN_CFLAGS)                          \
        $(GEOCLUE_CFLAGS)                               \
@@ -158,6 +159,7 @@ nodist_libempathy_gtk_la_SOURCES =\
        $(BUILT_SOURCES)
 
 libempathy_gtk_la_LIBADD =                     \
+       $(EMPATHY_LIBS)                 \
        $(EMPATHY_LIBS)                 \
        $(GTK_LIBS)                     \
        $(LIBNOTIFY_LIBS)                       \
index 86430cd2416c230156b03a2be9966b45a2abe0e3..8ecb042bec82aae33ea2f399eec626483e2933c8 100644 (file)
 
 #include <telepathy-glib/interfaces.h>
 
+#if HAVE_CALL
+#include <telepathy-yell/telepathy-yell.h>
+#endif
+
 #include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-utils.h>
@@ -54,6 +58,11 @@ typedef struct {
   gpointer                                  user_data;
 } FilterCallbackData;
 
+typedef struct {
+  gboolean video;
+  gint64 timestamp;
+} ContactCallbackData;
+
 struct _EmpathyNewCallDialogPriv {
   GtkWidget *check_video;
 };
@@ -62,21 +71,6 @@ struct _EmpathyNewCallDialogPriv {
   (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_NEW_CALL_DIALOG, \
     EmpathyNewCallDialogPriv))
 
-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);
-    }
-}
-
 /**
  * SECTION:empathy-new-call-dialog
  * @title: EmpathyNewCallDialog
@@ -87,32 +81,39 @@ create_media_channel_cb (GObject *source,
  * to be started with any contact on any enabled account.
  */
 
+static void
+got_contact_cb (TpConnection *connection,
+    EmpathyContact *contact,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
+{
+  ContactCallbackData *data = user_data;
+
+  if (error != NULL)
+    g_warning ("Could not get contact: %s", error->message);
+  else
+    empathy_call_new_with_streams (contact,
+        TRUE, data->video, data->timestamp);
+
+  g_slice_free (ContactCallbackData, data);
+}
+
 static void
 call_contact (TpAccount *account,
     const gchar *contact_id,
     gboolean video,
     gint64 timestamp)
 {
-  GHashTable *request;
-  TpAccountChannelRequest *req;
-
-  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_ID, G_TYPE_STRING, contact_id,
-      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN,
-        TRUE,
-      TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN,
-        video,
-      NULL);
-
-  req = tp_account_channel_request_new (account, request, timestamp);
-
-  tp_account_channel_request_create_channel_async (req, EMPATHY_AV_BUS_NAME,
-      NULL, create_media_channel_cb, NULL);
-
-  g_object_unref (req);
+  ContactCallbackData *data = g_slice_new0 (ContactCallbackData);
+
+  data->video = video;
+  data->timestamp = timestamp;
+
+  empathy_tp_contact_factory_get_from_id (tp_account_get_connection (account),
+      contact_id,
+      got_contact_cb, data,
+      NULL, NULL);
 }
 
 static void
@@ -169,7 +170,11 @@ conn_prepared_cb (GObject *conn,
 
       chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
 
-      if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
+      if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)
+#if HAVE_CALL
+          && tp_strdiff (chan_type, TPY_IFACE_CHANNEL_TYPE_CALL)
+#endif
+         )
         continue;
 
       if (tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL) !=