From 6d6b34b49171602e9bf47039b991d0376dd2c457 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 21 Dec 2010 15:58:22 +0000 Subject: mcd-dispatch-operation: don't call ADO if DelayApprover Observers haven't returned Signed-off-by: Jonny Lamb --- src/mcd-dispatch-operation.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index f65cacb8..aea5bb70 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -370,6 +370,8 @@ static gboolean mcd_dispatch_operation_idle_run_approvers (gpointer p); static void mcd_dispatch_operation_set_channel_handled_by ( McdDispatchOperation *self, McdChannel *channel, const gchar *unique_name, const gchar *well_known_name); +static gboolean _mcd_dispatch_operation_observers_can_delay_approvers ( + McdDispatchOperation *self); static gboolean _mcd_dispatch_operation_handlers_can_bypass_approval ( McdDispatchOperation *self); static gboolean _mcd_dispatch_operation_handlers_can_bypass_observers ( @@ -411,6 +413,7 @@ _mcd_dispatch_operation_check_client_locks (McdDispatchOperation *self) * return, then run that handler, then proceed with the other handlers. */ if (!self->priv->tried_handlers_before_approval && !_mcd_dispatch_operation_handlers_can_bypass_approval (self) + && !_mcd_dispatch_operation_observers_can_delay_approvers (self) && self->priv->channels != NULL && ! _mcd_plugin_dispatch_operation_will_terminate ( self->priv->plugin_api)) @@ -1662,6 +1665,58 @@ _mcd_dispatch_operation_get_handler_failed (McdDispatchOperation *self, != NULL); } +static gboolean +_mcd_dispatch_operation_observers_can_delay_approvers ( + McdDispatchOperation *self) +{ + GHashTableIter iter; + gpointer client_p; + const GList *cl; + + _mcd_client_registry_init_hash_iter (self->priv->client_registry, &iter); + + while (g_hash_table_iter_next (&iter, NULL, &client_p)) + { + McdClientProxy *client = MCD_CLIENT_PROXY (client_p); + gboolean can_observe = FALSE; + gboolean bypass; + + if (!tp_proxy_has_interface_by_id (client, + TP_IFACE_QUARK_CLIENT_OBSERVER)) + continue; + + for (cl = self->priv->channels; cl != NULL; cl = cl->next) + { + McdChannel *channel = MCD_CHANNEL (cl->data); + GHashTable *properties; + + properties = _mcd_channel_get_immutable_properties (channel); + g_assert (properties != NULL); + + if (_mcd_client_match_filters (properties, + _mcd_client_proxy_get_observer_filters (client), + FALSE)) + { + can_observe = TRUE; + break; + } + } + + if (!can_observe) + continue; + + bypass = _mcd_client_proxy_get_delay_approvers (client); + + DEBUG ("%s has DelayApprovers=%c", + tp_proxy_get_object_path (client), bypass ? 'T' : 'F'); + + if (bypass) + return bypass; + } + + return FALSE; +} + static gboolean _mcd_dispatch_operation_handlers_can_bypass_approval ( McdDispatchOperation *self) -- cgit v1.2.3