From c8166c52a0b133c3af082277270d3f911f634163 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 19 Feb 2010 15:43:17 +0000 Subject: empathy_tp_chat_leave: try to remove the self-handle instead of closing (#610461) --- libempathy/empathy-tp-chat.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'libempathy/empathy-tp-chat.c') diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 0b19a6680..3c613245c 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1805,8 +1805,42 @@ empathy_tp_chat_can_add_contact (EmpathyTpChat *self) TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP);; } +static void +leave_remove_members_cb (TpChannel *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpChat *self = user_data; + + if (error == NULL) + return; + + DEBUG ("RemoveMembers failed (%s); closing the channel", error->message); + empathy_tp_chat_close (self); +} + void empathy_tp_chat_leave (EmpathyTpChat *self) { - empathy_tp_chat_close (self); + EmpathyTpChatPriv *priv = GET_PRIV (self); + TpHandle self_handle; + GArray *array; + + if (!tp_proxy_has_interface_by_id (priv->channel, + TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) + empathy_tp_chat_close (self); + + self_handle = tp_channel_group_get_self_handle (priv->channel); + if (self_handle == 0) + /* we are not member of the channel */ + empathy_tp_chat_close (self); + + array = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1); + g_array_insert_val (array, 0, self_handle); + + tp_cli_channel_interface_group_call_remove_members (priv->channel, -1, array, + "", leave_remove_members_cb, self, NULL, G_OBJECT (self)); + + g_array_free (array, TRUE); } -- cgit v1.2.3