]> git.0d.be Git - empathy.git/commitdiff
Add support for approving video channels
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 9 Jan 2009 16:13:58 +0000 (16:13 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 9 Jan 2009 16:13:58 +0000 (16:13 +0000)
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
svn path=/trunk/; revision=2161

src/empathy-event-manager.c

index a012a50b917d0b843c07755e03bb1b253df0a150..514b8b21c3feaca79f53605ee0dd2cb5a00d9905 100644 (file)
@@ -29,6 +29,7 @@
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-tp-chat.h>
+#include <libempathy/empathy-tp-call.h>
 #include <libempathy/empathy-tp-group.h>
 #include <libempathy/empathy-utils.h>
 
@@ -243,6 +244,46 @@ event_manager_operation_claimed_cb (EmpathyDispatchOperation *operation,
   event_manager_approval_done (approval);
 }
 
+static void
+event_manager_media_channel_got_name_cb (EmpathyContact *contact,
+  gpointer user_data)
+{
+  EventManagerApproval *approval = user_data;
+  gchar *msg;
+
+  msg = g_strdup_printf (_("Incoming call from %s"),
+    empathy_contact_get_name (contact));
+
+  event_manager_add (approval->manager,
+    approval->contact, EMPATHY_IMAGE_VOIP, msg,
+    approval, event_channel_process_func, NULL);
+
+  g_free (msg);
+}
+
+static void
+event_manager_media_channel_got_contact (EventManagerApproval *approval)
+{
+  empathy_contact_call_when_ready (approval->contact,
+     EMPATHY_CONTACT_READY_NAME, event_manager_media_channel_got_name_cb,
+        approval);
+}
+
+static void
+event_manager_media_channel_contact_changed_cb (EmpathyTpCall *call,
+  GParamSpec *param, EventManagerApproval *approval)
+{
+  EmpathyContact *contact;
+
+  g_object_get (G_OBJECT (call), "contact", &contact, NULL);
+
+  if (contact == NULL)
+    return;
+
+  approval->contact = contact;
+  event_manager_media_channel_got_contact (approval);
+}
+
 static void
 event_manager_tube_approved_cb (EventPriv *event)
 {
@@ -351,30 +392,27 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
       g_object_unref (G_OBJECT (tp_chat));
 
     }
-#if 0
-       else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) {
-               EmpathyTpGroup *tp_group;
-               EmpathyContact *contact;
-               gchar          *msg;
-
-               tp_group = empathy_tp_group_new (channel);
-               empathy_run_until_ready (tp_group);
-               empathy_tp_group_get_invitation (tp_group, &contact);
-               empathy_contact_run_until_ready (contact,
-                                                EMPATHY_CONTACT_READY_NAME,
-                                                NULL);
-
-               msg = g_strdup_printf (_("Incoming call from %s"),
-                                      empathy_contact_get_name (contact));
-
-               event_manager_add (manager, contact, EMPATHY_IMAGE_VOIP, msg,
-                                  channel, event_channel_process_func, NULL);
-
-               g_free (msg);
-               g_object_unref (contact);
-               g_object_unref (tp_group);
-       }
-#endif
+  else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
+    {
+      EmpathyContact *contact;
+      EmpathyTpCall *call = EMPATHY_TP_CALL (
+          empathy_dispatch_operation_get_channel_wrapper (operation));
+
+      g_object_get (G_OBJECT (call), "contact", &contact, NULL);
+
+      if (contact == NULL)
+        {
+          g_signal_connect (call, "notify::contact",
+            G_CALLBACK (event_manager_media_channel_contact_changed_cb),
+            approval);
+        }
+      else
+        {
+          approval->contact = contact;
+          event_manager_media_channel_got_contact (approval);
+        }
+
+    }
   else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
     {
       EmpathyContact        *contact;