From 0b06b701197e0bb130c709d64e66e6700a4c2245 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Sep 2012 17:13:35 +0100 Subject: [PATCH 21/21] _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 4407803..da34f7f 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -1125,20 +1125,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 { @@ -1168,18 +1170,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 { @@ -1194,6 +1186,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)); @@ -1212,8 +1205,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; } @@ -1221,7 +1213,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.7.10.4