diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-10 12:00:14 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-12 11:34:18 +0100 |
commit | fe1e8ce4b830f665fbe098b1928969d26c553441 (patch) | |
tree | 40abe61d6b7bdbc43f12e8624b7cf0fdc2182625 | |
parent | 966ca2d58f87f9cfa7b1551885dd2f160971e19b (diff) |
_mcd_channel_depart: use tp_channel_leave_async or tp_channel_close_async5.16-branchpoint
This avoids some deprecated APIs, and is considerably simpler.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55391
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55392
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
-rw-r--r-- | src/mcd-channel.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/src/mcd-channel.c b/src/mcd-channel.c index cba836c3..fe2b0323 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 { @@ -1164,22 +1166,10 @@ mcd_channel_ready_to_depart_cb (GObject *source_object, return; } - 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); - } + /* If it's a Group, this will leave gracefully. + * If not, it will just close it. Either's good. */ + tp_channel_leave_async (channel, d->reason, d->message, + mcd_channel_depart_cb, NULL); } void @@ -1189,6 +1179,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)); @@ -1207,8 +1198,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; } @@ -1216,7 +1206,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); } |