]> git.0d.be Git - empathy.git/commitdiff
Add TargetContact property that's guaranteed to exist on CallHandler
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 23 Feb 2011 11:14:06 +0000 (11:14 +0000)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Thu, 9 Jun 2011 09:20:06 +0000 (10:20 +0100)
Conflicts:

src/empathy-call-factory.c

src/empathy-call-factory.c
src/empathy-call-handler.c
src/empathy-call-handler.h

index 0bae03a0cb73a65d3e90f9042bcd01152010e910..5501f499f5ab3cc43d862ffc262b56b49c8b0307 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <libempathy/empathy-channel-factory.h>
 #include <libempathy/empathy-request-util.h>
+#include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-call-utils.h>
@@ -256,21 +257,35 @@ empathy_call_factory_new_call_with_streams (EmpathyContact *contact,
 }
 
 static void
-create_call_handler (EmpathyCallFactory *factory,
-  TpyCallChannel *call)
+call_channel_got_contact (TpConnection *connection,
+  EmpathyContact *contact,
+  const GError *error,
+  gpointer user_data,
+  GObject *weak_object)
 {
+  EmpathyCallFactory *factory = EMPATHY_CALL_FACTORY (weak_object);
   EmpathyCallHandler *handler;
+  TpyCallChannel *call = TPY_CALL_CHANNEL (user_data);
 
-  g_return_if_fail (factory != NULL);
+  if (contact == NULL)
+    {
+      /* FIXME use hangup with an appropriate error */
+      tp_channel_close_async (TP_CHANNEL (call), NULL, NULL);
+      goto out;
+    }
 
-  handler = empathy_call_handler_new_for_channel (call);
+  handler = empathy_call_handler_new_for_channel (call, contact);
 
   g_signal_emit (factory, signals[NEW_CALL_HANDLER], 0,
     handler, FALSE);
 
   g_object_unref (handler);
+
+out:
+  g_object_unref (call);
 }
 
+
 static void
 handle_channels_cb (TpSimpleHandler *handler,
     TpAccount *account,
@@ -288,6 +303,7 @@ handle_channels_cb (TpSimpleHandler *handler,
     {
       TpChannel *channel = l->data;
       TpyCallChannel *call;
+      const gchar *id;
 
       if (tp_proxy_get_invalidated (channel) != NULL)
         continue;
@@ -300,8 +316,14 @@ handle_channels_cb (TpSimpleHandler *handler,
         continue;
 
       call = TPY_CALL_CHANNEL (channel);
-      create_call_handler (self, call);
-      g_object_unref (call);
+
+      id = tp_channel_get_identifier (channel);
+      empathy_tp_contact_factory_get_from_id (connection,
+        id,
+        call_channel_got_contact,
+        g_object_ref (channel),
+        g_object_unref,
+        (GObject *) self);
     }
 
   tp_handle_channels_context_accept (context);
index cc94e4ad800f6c9890296a17f82f573f6bc1ed99..eca076d94b046038dfc8c78bbf95dfcabb3ef23c 100644 (file)
@@ -59,6 +59,7 @@ static guint signals[LAST_SIGNAL] = {0};
 enum {
   PROP_CALL_CHANNEL = 1,
   PROP_GST_BUS,
+  PROP_CONTACT,
   PROP_MEMBERS,
   PROP_INITIAL_AUDIO,
   PROP_INITIAL_VIDEO,
@@ -77,6 +78,7 @@ enum {
 typedef struct {
   TpyCallChannel *call;
 
+  EmpathyContact *contact;
   /* GArray of TpContacts */
   GArray *members;
   TfChannel *tfchannel;
@@ -102,6 +104,7 @@ empathy_call_handler_dispose (GObject *object)
 
   tp_clear_object (&priv->tfchannel);
   tp_clear_object (&priv->call);
+  tp_clear_object (&priv->contact);
 
   tp_clear_pointer (&priv->members, g_array_unref);
 
@@ -231,6 +234,9 @@ empathy_call_handler_set_property (GObject *object,
 
   switch (property_id)
     {
+      case PROP_CONTACT:
+        priv->contact = g_value_dup_object (value);
+        break;
       case PROP_MEMBERS:
         priv->members = g_value_get_boxed (value);
         break;
@@ -256,6 +262,9 @@ empathy_call_handler_get_property (GObject *object,
 
   switch (property_id)
     {
+      case PROP_CONTACT:
+        g_value_set_object (value, priv->contact);
+        break;
       case PROP_MEMBERS:
         g_value_set_boxed (value, priv->members);
         break;
@@ -312,6 +321,12 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
   object_class->dispose = empathy_call_handler_dispose;
   object_class->finalize = empathy_call_handler_finalize;
 
+  param_spec = g_param_spec_object ("target-contact",
+    "TargetContact", "The contact",
+    EMPATHY_TYPE_CONTACT,
+    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_CONTACT, param_spec);
+
   param_spec = g_param_spec_boxed ("members",
     "call members", "The call participants",
     G_TYPE_ARRAY,
@@ -448,11 +463,13 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
 }
 
 EmpathyCallHandler *
-empathy_call_handler_new_for_channel (TpyCallChannel *call)
+empathy_call_handler_new_for_channel (TpyCallChannel *call,
+  EmpathyContact *contact)
 {
   return EMPATHY_CALL_HANDLER (g_object_new (EMPATHY_TYPE_CALL_HANDLER,
     "call-channel", call,
     "initial-video", tpy_call_channel_has_initial_video (call),
+    "target-contact", contact,
     NULL));
 }
 
@@ -925,7 +942,10 @@ empathy_call_handler_stop_call (EmpathyCallHandler *handler)
       tpy_call_channel_hangup_async (priv->call,
           TPY_CALL_STATE_CHANGE_REASON_USER_REQUESTED,
           "", "", NULL, NULL);
+      tp_channel_close_async (TP_CHANNEL (priv->call),
+        NULL, NULL);
       tp_clear_object (&priv->call);
+      tp_clear_object (&priv->tfchannel);
     }
 }
 
index 8ad1da7208df00c91d8734d181896b528d55bf9e..3cc0421c779278c7cf41c4aa73d6f78a990258d7 100644 (file)
@@ -67,7 +67,8 @@ EmpathyCallHandler * empathy_call_handler_new_for_contact (
   EmpathyContact *contact);
 
 EmpathyCallHandler * empathy_call_handler_new_for_channel (
-  TpyCallChannel *call);
+  TpyCallChannel *call,
+  EmpathyContact *contact);
 
 void empathy_call_handler_start_call (EmpathyCallHandler *handler,
     gint64 timestamp);