]> git.0d.be Git - empathy.git/commitdiff
empathy_tp_chat_leave: try to remove the self-handle instead of closing (#610461)
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 19 Feb 2010 15:43:17 +0000 (15:43 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 19 Feb 2010 15:43:17 +0000 (15:43 +0000)
libempathy/empathy-tp-chat.c

index 0b19a66807af5b7fbbe8e2d58b9e996ac01b55b6..3c613245c7e49e2a924c80359fc700e094e541ee 100644 (file)
@@ -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);
 }