]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tp-call.c
Change EmpathyTpContactFactory API to look more like TpConnection. Add function to...
[empathy.git] / libempathy / empathy-tp-call.c
index a3c31b618271ed96c5ca8c951b78daca8038db35..a5c0003c56741182ad665d9292d61a811899fd9e 100644 (file)
@@ -27,7 +27,7 @@
 #include <telepathy-glib/interfaces.h>
 
 #include "empathy-tp-call.h"
-#include "empathy-contact-factory.h"
+#include "empathy-tp-contact-factory.h"
 #include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_TP
@@ -253,22 +253,27 @@ tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
   g_array_free (stream_types, TRUE);
 }
 
-static EmpathyContact *
-tp_call_dup_contact_from_handle (EmpathyTpCall *call, TpHandle handle)
+static void
+tp_call_got_contact_cb (EmpathyTpContactFactory *factory,
+                        EmpathyContact          *contact,
+                        const GError            *error,
+                        gpointer                 user_data,
+                        GObject                 *call)
 {
   EmpathyTpCallPriv *priv = GET_PRIV (call);
-  EmpathyContactFactory *factory;
-  McAccount *account;
-  EmpathyContact *contact;
-
-  factory = empathy_contact_factory_dup_singleton ();
-  account = empathy_channel_get_account (priv->channel);
-  contact = empathy_contact_factory_get_from_handle (factory, account, handle);
 
-  g_object_unref (factory);
-  g_object_unref (account);
+  if (error)
+    {
+      DEBUG ("Error: %s", error->message);
+      return;
+    }
 
-  return contact;
+  priv->contact = g_object_ref (contact);
+  priv->is_incoming = TRUE;
+  priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
+  g_object_notify (G_OBJECT (call), "is-incoming");
+  g_object_notify (G_OBJECT (call), "contact");
+  g_object_notify (G_OBJECT (call), "status");
 }
 
 static void
@@ -288,13 +293,15 @@ tp_call_update_status (EmpathyTpCall *call)
     {
       if (priv->contact == NULL && iter.element != self_handle)
         {
+          EmpathyTpContactFactory *factory;
+          TpConnection *connection;
+
           /* We found the remote contact */
-          priv->contact = tp_call_dup_contact_from_handle (call, iter.element);
-          priv->is_incoming = TRUE;
-          priv->status = EMPATHY_TP_CALL_STATUS_PENDING;
-          g_object_notify (G_OBJECT (call), "is-incoming");
-          g_object_notify (G_OBJECT (call), "contact");
-          g_object_notify (G_OBJECT (call), "status");
+          connection = tp_channel_borrow_connection (priv->channel);
+          factory = empathy_tp_contact_factory_dup_singleton (connection);
+          empathy_tp_contact_factory_get_from_handle (factory, iter.element,
+              tp_call_got_contact_cb, NULL, NULL, G_OBJECT (call));
+          g_object_unref (factory);
         }
 
       if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
@@ -309,20 +316,6 @@ tp_call_update_status (EmpathyTpCall *call)
   g_object_unref (call);
 }
 
-static void
-tp_call_members_changed_cb (TpChannel *channel,
-                            gchar *message,
-                            GArray *added,
-                            GArray *removed,
-                            GArray *local_pending,
-                            GArray *remote_pending,
-                            guint actor,
-                            guint reason,
-                            EmpathyTpCall *call)
-{
-  tp_call_update_status (call);
-}
-
 void
 empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact)
 {
@@ -334,8 +327,7 @@ empathy_tp_call_to (EmpathyTpCall *call, EmpathyContact *contact)
   g_object_notify (G_OBJECT (call), "is-incoming");
   g_object_notify (G_OBJECT (call), "contact");
   g_object_notify (G_OBJECT (call), "status");
-  tp_call_request_streams_for_capabilities (call,
-     EMPATHY_CAPABILITIES_VIDEO | EMPATHY_CAPABILITIES_AUDIO);
+  tp_call_request_streams_for_capabilities (call, EMPATHY_CAPABILITIES_AUDIO);
 }
 
 static void
@@ -362,23 +354,6 @@ tp_call_async_cb (TpProxy *proxy,
       DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
 }
 
-static void
-tp_call_close_channel (EmpathyTpCall *call)
-{
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED)
-      return;
-
-  DEBUG ("Closing channel");
-
-  tp_cli_channel_call_close (priv->channel, -1,
-      NULL, NULL, NULL, NULL);
-
-  priv->status = EMPATHY_TP_CALL_STATUS_CLOSED;
-  g_object_notify (G_OBJECT (call), "status");
-}
-
 static GObject *
 tp_call_constructor (GType type,
                      guint n_construct_params,
@@ -410,8 +385,8 @@ tp_call_constructor (GType type,
 
   /* Update status when members changes */
   tp_call_update_status (call);
-  g_signal_connect (priv->channel, "group-members-changed",
-      G_CALLBACK (tp_call_members_changed_cb), call);
+  g_signal_connect_swapped (priv->channel, "group-members-changed",
+      G_CALLBACK (tp_call_update_status), call);
 
   return object;
 }
@@ -427,9 +402,6 @@ tp_call_dispose (GObject *object)
 
   priv->dispose_has_run = TRUE;
 
-  g_slice_free (EmpathyTpCallStream, priv->audio);
-  g_slice_free (EmpathyTpCallStream, priv->video);
-
   if (priv->channel != NULL)
     {
       g_signal_handlers_disconnect_by_func (priv->channel,
@@ -645,84 +617,6 @@ empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call,
       tp_call_async_cb, NULL, NULL, G_OBJECT (call));
 }
 
-void
-empathy_tp_call_add_preview_video (EmpathyTpCall *call,
-                                   guint preview_video_socket_id)
-{
-  //EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Adding preview video");
-
-  /* FIXME add the preview window */
-}
-
-void
-empathy_tp_call_remove_preview_video (EmpathyTpCall *call,
-                                      guint preview_video_socket_id)
-{
-  //EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Removing preview video");
-
-  /* FIXME remove the preview window */
-}
-
-void
-empathy_tp_call_add_output_video (EmpathyTpCall *call,
-                                  guint output_video_socket_id)
-{
-  //EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Adding output video - socket: %d", output_video_socket_id);
-
-  /* FIXME add output window */
-}
-
-void
-empathy_tp_call_set_output_volume (EmpathyTpCall *call,
-                                   guint volume)
-{
-  EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-  g_return_if_fail (priv->status != EMPATHY_TP_CALL_STATUS_CLOSED);
-
-  DEBUG ("Setting output volume: %d", volume);
-
-  /* FIXME set volume */
-}
-
-void
-empathy_tp_call_mute_output (EmpathyTpCall *call,
-                             gboolean is_muted)
-{
-  //EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Setting output mute: %d", is_muted);
-  /* FIXME mute output */
-}
-
-void
-empathy_tp_call_mute_input (EmpathyTpCall *call,
-                            gboolean is_muted)
-{
-  //EmpathyTpCallPriv *priv = GET_PRIV (call);
-
-  g_return_if_fail (EMPATHY_IS_TP_CALL (call));
-
-  DEBUG ("Setting input mute: %d", is_muted);
-
-  /* FIXME mute input */
-}
-
 void
 empathy_tp_call_start_tone (EmpathyTpCall *call, TpDTMFEvent event)
 {