From 23df5d23afd6214d5dede98ebea26e40ddf8f1df Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 10 Sep 2013 12:19:32 +0100 Subject: [PATCH 2/8] Remove deprecated mcp_dispatch_operation_leave_channels() --- mission-control-plugins/dispatch-operation.c | 39 ---------- mission-control-plugins/dispatch-operation.h | 7 -- mission-control-plugins/implementation.h | 3 - src/mcd-channel-priv.h | 4 - src/mcd-channel.c | 89 ---------------------- src/mcd-dispatch-operation-priv.h | 3 - src/mcd-dispatch-operation.c | 23 ------ src/plugin-dispatch-operation.c | 40 ---------- .../dispatcher/dispatch-delayed-by-mini-plugin.py | 6 +- .../dispatcher/dispatch-rejected-by-mini-plugin.py | 5 +- tests/twisted/mcp-plugin.c | 15 +--- 11 files changed, 8 insertions(+), 226 deletions(-) diff --git a/mission-control-plugins/dispatch-operation.c b/mission-control-plugins/dispatch-operation.c index ab51eb9..db14ffe 100644 --- a/mission-control-plugins/dispatch-operation.c +++ b/mission-control-plugins/dispatch-operation.c @@ -285,45 +285,6 @@ mcp_dispatch_operation_end_delay (McpDispatchOperation *self, } /** - * mcp_dispatch_operation_leave_channels: - * @self: a dispatch operation - * @wait_for_observers: if %FALSE, leave the channels immediately; if %TRUE - * (usually recommended), wait for Observers to reply first - * @reason: the reason code to give - * @message: a human-readable message provided by the user, or either the - * empty string or %NULL if no message has been provided - * - * Leave all channels in this bundle by using RemoveMembersWithReason if the - * channel has the Group interface, or Close if not. - * - * This method was intended for StreamedMedia channels, which (ab)used the - * Group interface for call control. StreamedMedia channels have been - * superseded by Call channels, which have a proper "hang up" method which - * should be used instead. - * - * Deprecated: 5.15.UNRELEASED: Use tp_call_channel_hangup_async() to - * hang up Call channels, mcp_dispatch_operation_close_channels() to close - * generic channels, or mcp_dispatch_operation_destroy_channels() to - * terminate the channel destructively. - */ -void -mcp_dispatch_operation_leave_channels (McpDispatchOperation *self, - gboolean wait_for_observers, - TpChannelGroupChangeReason reason, - const gchar *message) -{ - McpDispatchOperationIface *iface = MCP_DISPATCH_OPERATION_GET_IFACE (self); - - g_return_if_fail (iface != NULL); - g_return_if_fail (iface->leave_channels != NULL); - - if (message == NULL) - message = ""; - - iface->leave_channels (self, wait_for_observers, reason, message); -} - -/** * mcp_dispatch_operation_close_channels: * @self: a dispatch operation * @wait_for_observers: if %FALSE, close the channels immediately; if %TRUE diff --git a/mission-control-plugins/dispatch-operation.h b/mission-control-plugins/dispatch-operation.h index 5ad12d9..c7279aa 100644 --- a/mission-control-plugins/dispatch-operation.h +++ b/mission-control-plugins/dispatch-operation.h @@ -85,13 +85,6 @@ McpDispatchOperationDelay *mcp_dispatch_operation_start_delay ( void mcp_dispatch_operation_end_delay (McpDispatchOperation *self, McpDispatchOperationDelay *delay); -#ifndef MC_DISABLE_DEPRECATED -G_DEPRECATED_FOR (mcp_dispatch_operation_close_channels or tp_call_channel_hangup_async) -void mcp_dispatch_operation_leave_channels (McpDispatchOperation *self, - gboolean wait_for_observers, TpChannelGroupChangeReason reason, - const gchar *message); -#endif - void mcp_dispatch_operation_close_channels (McpDispatchOperation *self, gboolean wait_for_observers); void mcp_dispatch_operation_destroy_channels (McpDispatchOperation *self, diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h index 20c5fdf..eaed4f7 100644 --- a/mission-control-plugins/implementation.h +++ b/mission-control-plugins/implementation.h @@ -68,9 +68,6 @@ struct _McpDispatchOperationIface { McpDispatchOperationDelay *delay); /* Close */ - void (*leave_channels) (McpDispatchOperation *self, - gboolean wait_for_observers, TpChannelGroupChangeReason reason, - const gchar *message); void (*close_channels) (McpDispatchOperation *self, gboolean wait_for_observers); void (*destroy_channels) (McpDispatchOperation *self, diff --git a/src/mcd-channel-priv.h b/src/mcd-channel-priv.h index b45ad31..9e04583 100644 --- a/src/mcd-channel-priv.h +++ b/src/mcd-channel-priv.h @@ -67,10 +67,6 @@ void _mcd_channel_set_request_proxy (McdChannel *channel, McdChannel *source); void _mcd_channel_close (McdChannel *channel); -G_GNUC_INTERNAL void _mcd_channel_depart (McdChannel *channel, - TpChannelGroupChangeReason reason, - const gchar *message); - G_GNUC_INTERNAL gboolean _mcd_channel_is_primary_for_path (McdChannel *self, const gchar *channel_path); diff --git a/src/mcd-channel.c b/src/mcd-channel.c index fe2b032..eed88ae 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -1123,95 +1123,6 @@ mcd_channel_get_tp_channel (McdChannel *channel) return channel->priv->tp_chan; } -static void -mcd_channel_depart_cb (GObject *source_object, - GAsyncResult *result, - gpointer data G_GNUC_UNUSED) -{ - 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)) - { - WARNING ("failed to depart, even via Close(): %s %d: %s", - g_quark_to_string (error->domain), error->code, error->message); - g_error_free (error); - } -} - -typedef struct { - TpChannelGroupChangeReason reason; - gchar *message; -} DepartData; - -static void -mcd_channel_ready_to_depart_cb (GObject *source_object, - GAsyncResult *result, - gpointer data) -{ - TpChannel *channel = TP_CHANNEL (source_object); - DepartData *d = data; - GError *error = NULL; - - if (!tp_proxy_prepare_finish (channel, result, &error)) - { - DEBUG ("%s %d: %s", g_quark_to_string (error->domain), error->code, - error->message); - g_free (d->message); - g_slice_free (DepartData, d); - g_clear_error (&error); - return; - } - - /* 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 -_mcd_channel_depart (McdChannel *channel, - TpChannelGroupChangeReason reason, - const gchar *message) -{ - DepartData *d; - const GError *invalidated; - GQuark just_group_feature[] = { TP_CHANNEL_FEATURE_GROUP, 0 }; - - g_return_if_fail (MCD_IS_CHANNEL (channel)); - - g_return_if_fail (channel->priv->tp_chan != NULL); - g_return_if_fail (message != NULL); - - invalidated = tp_proxy_get_invalidated (channel->priv->tp_chan); - - if (invalidated != NULL) - { - DEBUG ("%s %d: %s", g_quark_to_string (invalidated->domain), - invalidated->code, invalidated->message); - return; - } - - if (message[0] == '\0' && reason == TP_CHANNEL_GROUP_CHANGE_REASON_NONE) - { - /* exactly equivalent to Close(), so skip the Group interface */ - tp_channel_close_async (channel->priv->tp_chan, NULL, NULL); - return; - } - - d = g_slice_new (DepartData); - d->reason = reason; - d->message = g_strdup (message); - - /* 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); -} - /* * _mcd_channel_is_primary_for_path: * @self: an McdChannel diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h index ce168fc..a61bb7b 100644 --- a/src/mcd-dispatch-operation-priv.h +++ b/src/mcd-dispatch-operation-priv.h @@ -108,9 +108,6 @@ G_GNUC_INTERNAL void _mcd_dispatch_operation_start_plugin_delay ( G_GNUC_INTERNAL void _mcd_dispatch_operation_end_plugin_delay ( McdDispatchOperation *self); -G_GNUC_INTERNAL void _mcd_dispatch_operation_leave_channels ( - McdDispatchOperation *self, TpChannelGroupChangeReason reason, - const gchar *message); G_GNUC_INTERNAL void _mcd_dispatch_operation_close_channels ( McdDispatchOperation *self); G_GNUC_INTERNAL void _mcd_dispatch_operation_destroy_channels ( diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index 8df17cb..020d6b8 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -2544,29 +2544,6 @@ _mcd_dispatch_operation_forget_channels (McdDispatchOperation *self) } void -_mcd_dispatch_operation_leave_channels (McdDispatchOperation *self, - TpChannelGroupChangeReason reason, - const gchar *message) -{ - if (message == NULL) - { - message = ""; - } - - if (self->priv->channel != NULL) - { - /* Take a temporary copy, because self->priv->channels could - * be modified as a result */ - McdChannel *channel = g_object_ref (self->priv->channel); - - _mcd_channel_depart (channel, reason, message); - g_object_unref (channel); - } - - _mcd_dispatch_operation_forget_channels (self); -} - -void _mcd_dispatch_operation_close_channels (McdDispatchOperation *self) { if (self->priv->channel != NULL) diff --git a/src/plugin-dispatch-operation.c b/src/plugin-dispatch-operation.c index cd9c279..22d777c 100644 --- a/src/plugin-dispatch-operation.c +++ b/src/plugin-dispatch-operation.c @@ -34,7 +34,6 @@ typedef enum { PLUGIN_ACTION_NONE, PLUGIN_ACTION_CLOSE, - PLUGIN_ACTION_LEAVE, PLUGIN_ACTION_DESTROY } PluginAction; @@ -279,38 +278,6 @@ plugin_do_end_delay (McpDispatchOperation *obj, g_object_unref (self); } - -/* Close */ -static void -plugin_do_leave_channels (McpDispatchOperation *obj, - gboolean wait_for_observers, TpChannelGroupChangeReason reason, - const gchar *message) -{ - McdPluginDispatchOperation *self = MCD_PLUGIN_DISPATCH_OPERATION (obj); - - DEBUG ("%p (wait=%c reason=%d message=%s)", self, - wait_for_observers ? 'T' : 'F', reason, message); - - g_return_if_fail (self != NULL); - - if (wait_for_observers) - { - if (self->after_observers < PLUGIN_ACTION_LEAVE) - { - DEBUG ("Remembering for later"); - self->after_observers = PLUGIN_ACTION_LEAVE; - self->reason = reason; - g_free (self->message); - self->message = g_strdup (message); - } - } - else - { - DEBUG ("Leaving now"); - _mcd_dispatch_operation_leave_channels (self->real_cdo, reason, message); - } -} - static void plugin_do_close_channels (McpDispatchOperation *obj, gboolean wait_for_observers) @@ -370,12 +337,6 @@ _mcd_plugin_dispatch_operation_observers_finished ( _mcd_dispatch_operation_destroy_channels (self->real_cdo); break; - case PLUGIN_ACTION_LEAVE: - DEBUG ("leaving now: %d %s", self->reason, self->message); - _mcd_dispatch_operation_leave_channels (self->real_cdo, - self->reason, self->message); - break; - case PLUGIN_ACTION_CLOSE: DEBUG ("closing now"); _mcd_dispatch_operation_close_channels (self->real_cdo); @@ -412,7 +373,6 @@ plugin_iface_init (McpDispatchOperationIface *iface, iface->start_delay = plugin_do_start_delay; iface->end_delay = plugin_do_end_delay; - iface->leave_channels = plugin_do_leave_channels; iface->close_channels = plugin_do_close_channels; iface->destroy_channels = plugin_do_destroy_channels; } diff --git a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py index eeab38c..48da4c1 100644 --- a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py @@ -145,10 +145,8 @@ def test(q, bus, mc): args=[cdo_path]), EventPattern('dbus-method-call', path=chan.object_path, - interface=cs.CHANNEL_IFACE_GROUP, - # this error message is from the plugin - method='RemoveMembersWithReason', args=[[conn.self_handle], - "Computer says no", cs.GROUP_REASON_PERMISSION_DENIED], + interface=cs.CHANNEL_IFACE_DESTROYABLE, + method='Destroy', handled=False), ) q.dbus_return(e.message, signature='') diff --git a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py index eeb6e9e..893ff14 100644 --- a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py @@ -205,9 +205,8 @@ def test(q, bus, mc): args=[cdo_path]), EventPattern('dbus-method-call', path=chan.object_path, - interface=cs.CHANNEL_IFACE_GROUP, - method='RemoveMembersWithReason', args=[[conn.self_handle], - "Can't touch this", cs.GROUP_REASON_PERMISSION_DENIED], + interface=cs.CHANNEL_IFACE_DESTROYABLE, + method='Destroy', handled=False), ) q.dbus_return(e.message, signature='') diff --git a/tests/twisted/mcp-plugin.c b/tests/twisted/mcp-plugin.c index 7d347b1..34079c8 100644 --- a/tests/twisted/mcp-plugin.c +++ b/tests/twisted/mcp-plugin.c @@ -137,11 +137,8 @@ permission_cb (DBusPendingCall *pc, } else { - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - mcp_dispatch_operation_leave_channels (ctx->dispatch_operation, - TRUE, TP_CHANNEL_GROUP_CHANGE_REASON_PERMISSION_DENIED, - "Computer says no"); - G_GNUC_END_IGNORE_DEPRECATIONS + mcp_dispatch_operation_destroy_channels (ctx->dispatch_operation, + TRUE); } } else @@ -513,12 +510,8 @@ test_rejection_plugin_check_cdo (McpDispatchOperationPolicy *policy, } else if (!tp_strdiff (target_id, "mc.hammer@example.net")) { - DEBUG ("MC Hammer detected, leaving channels when observers have run"); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - mcp_dispatch_operation_leave_channels (dispatch_operation, TRUE, - TP_CHANNEL_GROUP_CHANGE_REASON_PERMISSION_DENIED, - "Can't touch this"); - G_GNUC_END_IGNORE_DEPRECATIONS + DEBUG ("MC Hammer detected, destroying channels when observers have run"); + mcp_dispatch_operation_destroy_channels (dispatch_operation, TRUE); } g_hash_table_unref (properties); -- 1.8.4.rc3