From 1eb4217056e28f1fcc05d9f34488f241f321228f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Sep 2012 17:13:35 +0100 Subject: [PATCH 2/6] _mcd_channel_depart: use tp_channel_leave_async if it's a Group Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55391 --- src/mcd-channel.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/mcd-channel.c b/src/mcd-channel.c index b6b152e..2be54cf 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -1124,20 +1124,22 @@ mcd_channel_get_tp_channel (McdChannel *channel) } static void -mcd_channel_depart_cb (TpChannel *channel, - const GError *error, - gpointer data G_GNUC_UNUSED, - GObject *weak_object G_GNUC_UNUSED) +mcd_channel_depart_cb (GObject *source_object, + GAsyncResult *result, + gpointer data G_GNUC_UNUSED) { - if (error == NULL) + GError *error = NULL; + + /* By this point, TpChannel has already called Close() for us; + * we only get an error if that failed. If Close() fails, there's + * not a whole lot we can do about it. */ + + if (!tp_channel_leave_finish (TP_CHANNEL (source_object), result, &error)) { - DEBUG ("successful"); - return; + WARNING ("failed to depart, even via Close(): %s %d: %s", + g_quark_to_string (error->domain), error->code, error->message); + g_error_free (error); } - - DEBUG ("failed to depart, calling Close instead: %s %d: %s", - g_quark_to_string (error->domain), error->code, error->message); - tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL); } typedef struct { @@ -1167,18 +1169,8 @@ mcd_channel_ready_to_depart_cb (GObject *source_object, if (tp_proxy_has_interface_by_id (channel, TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) { - GArray *a = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1); - guint self_handle = tp_channel_group_get_self_handle (channel); - - g_array_append_val (a, self_handle); - - tp_cli_channel_interface_group_call_remove_members_with_reason ( - channel, -1, a, d->message, d->reason, - mcd_channel_depart_cb, NULL, NULL, NULL); - - g_array_unref (a); - g_free (d->message); - g_slice_free (DepartData, d); + tp_channel_leave_async (channel, d->reason, d->message, + mcd_channel_depart_cb, NULL); } else { @@ -1193,6 +1185,7 @@ _mcd_channel_depart (McdChannel *channel, { DepartData *d; const GError *invalidated; + GQuark just_group_feature[] = { TP_CHANNEL_FEATURE_GROUP, 0 }; g_return_if_fail (MCD_IS_CHANNEL (channel)); @@ -1211,8 +1204,7 @@ _mcd_channel_depart (McdChannel *channel, if (message[0] == '\0' && reason == TP_CHANNEL_GROUP_CHANGE_REASON_NONE) { /* exactly equivalent to Close(), so skip the Group interface */ - tp_cli_channel_call_close (channel->priv->tp_chan, -1, - NULL, NULL, NULL, NULL); + tp_channel_close_async (channel->priv->tp_chan, NULL, NULL); return; } @@ -1220,7 +1212,9 @@ _mcd_channel_depart (McdChannel *channel, d->reason = reason; d->message = g_strdup (message); - tp_proxy_prepare_async (channel->priv->tp_chan, NULL, + /* tp_channel_leave_async documents calling it without first preparing + * GROUP as deprecated. */ + tp_proxy_prepare_async (channel->priv->tp_chan, just_group_feature, mcd_channel_ready_to_depart_cb, d); } -- 1.8.4.rc3