From 9a32d8b58f3b91b491b3d6cfe3a3e1bc6c98738c Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 21 Apr 2008 14:06:39 +0000 Subject: [PATCH] Fix OUTGOING calls svn path=/trunk/; revision=1022 --- libempathy/empathy-tp-call.c | 77 +++++++++++++++++++++++------------ libempathy/empathy-tp-group.c | 2 +- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index e39389ea..a51ded45 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -281,24 +281,6 @@ tp_call_request_streams (EmpathyTpCall *call) empathy_contact_get_capabilities (priv->contact)); } -static void -tp_call_group_ready_cb (EmpathyTpCall *call) -{ - EmpathyTpCallPriv *priv = GET_PRIV (call); - EmpathyPendingInfo *invitation; - - invitation = empathy_tp_group_get_invitation (priv->group, &priv->contact); - priv->is_incoming = (invitation != NULL); - priv->status = EMPATHY_TP_CALL_STATUS_PENDING; - - if (!priv->is_incoming) - tp_call_request_streams (call); - - g_object_notify (G_OBJECT (call), "is-incoming"); - g_object_notify (G_OBJECT (call), "contact"); - g_object_notify (G_OBJECT (call), "status"); -} - static void tp_call_member_added_cb (EmpathyTpGroup *group, EmpathyContact *contact, @@ -318,6 +300,49 @@ tp_call_member_added_cb (EmpathyTpGroup *group, } } +static void +tp_call_local_pending_cb (EmpathyTpGroup *group, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + const gchar *message, + EmpathyTpCall *call) +{ + EmpathyTpCallPriv *priv = GET_PRIV (call); + + if (!priv->contact && !empathy_contact_is_user (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 +tp_call_remote_pending_cb (EmpathyTpGroup *group, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + const gchar *message, + EmpathyTpCall *call) +{ + EmpathyTpCallPriv *priv = GET_PRIV (call); + + if (!priv->contact && !empathy_contact_is_user (contact)) + { + priv->contact = g_object_ref (contact); + priv->is_incoming = FALSE; + priv->status = EMPATHY_TP_CALL_STATUS_PENDING; + tp_call_request_streams (call); + g_object_notify (G_OBJECT (call), "is-incoming"); + g_object_notify (G_OBJECT (call), "contact"); + g_object_notify (G_OBJECT (call), "status"); + } +} + static void tp_call_channel_invalidated_cb (TpChannel *channel, GQuark domain, @@ -356,8 +381,7 @@ tp_call_close_channel (EmpathyTpCall *call) empathy_debug (DEBUG_DOMAIN, "Closing channel"); tp_cli_channel_call_close (priv->channel, -1, - (tp_cli_channel_callback_for_close) tp_call_async_cb, - "closing channel", NULL, G_OBJECT (call)); + NULL, NULL, NULL, NULL); priv->status = EMPATHY_TP_CALL_STATUS_CLOSED; g_object_notify (G_OBJECT (call), "status"); @@ -484,14 +508,12 @@ tp_call_constructor (GType type, /* Setup group interface */ priv->group = empathy_tp_group_new (priv->channel); - g_signal_connect (G_OBJECT (priv->group), "member-added", + g_signal_connect (priv->group, "member-added", G_CALLBACK (tp_call_member_added_cb), call); - - if (empathy_tp_group_is_ready (priv->group)) - tp_call_group_ready_cb (call); - else - g_signal_connect_swapped (priv->group, "notify::ready", - G_CALLBACK (tp_call_group_ready_cb), call); + g_signal_connect (priv->group, "local-pending", + G_CALLBACK (tp_call_local_pending_cb), call); + g_signal_connect (priv->group, "remote-pending", + G_CALLBACK (tp_call_remote_pending_cb), call); /* Start stream engine */ tp_call_stream_engine_handle_channel (call); @@ -514,6 +536,7 @@ tp_call_finalize (GObject *object) { g_signal_handlers_disconnect_by_func (priv->channel, tp_call_channel_invalidated_cb, object); + tp_call_close_channel (EMPATHY_TP_CALL (object)); g_object_unref (priv->channel); } diff --git a/libempathy/empathy-tp-group.c b/libempathy/empathy-tp-group.c index f09d8ce1..f5cbb708 100644 --- a/libempathy/empathy-tp-group.c +++ b/libempathy/empathy-tp-group.c @@ -966,7 +966,7 @@ empathy_tp_group_get_invitation (EmpathyTpGroup *group, contact = priv->remote_pendings->data; } - if (remote_contact) { + if (remote_contact && contact) { *remote_contact = g_object_ref (contact); } -- 2.39.2