[telepathy-mission-control/master] _mcd_dispatch_operation_handlers_can_bypass_approval: move from McdDispatcher

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Oct 20 08:47:18 PDT 2009


---
 src/mcd-dispatch-operation-priv.h |    2 +
 src/mcd-dispatch-operation.c      |   35 ++++++++++++++++++++++++++++++++
 src/mcd-dispatcher.c              |   40 +-----------------------------------
 3 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index c6f5c65..22659ea 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -96,6 +96,8 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_needs_approval (
 G_GNUC_INTERNAL
 const gchar * const *_mcd_dispatch_operation_get_possible_handlers (
     McdDispatchOperation *self);
+G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_handlers_can_bypass_approval
+   (McdDispatchOperation *self);
 
 G_GNUC_INTERNAL void _mcd_dispatch_operation_set_handler_failed (
     McdDispatchOperation *self, const gchar *bus_name);
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index ef89e7c..e12ca96 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -994,3 +994,38 @@ _mcd_dispatch_operation_get_handler_failed (McdDispatchOperation *self,
     return (g_hash_table_lookup (self->priv->failed_handlers, bus_name)
             != NULL);
 }
+
+gboolean
+_mcd_dispatch_operation_handlers_can_bypass_approval (
+    McdDispatchOperation *self)
+{
+    gchar **iter;
+
+    for (iter = self->priv->possible_handlers;
+         iter != NULL && *iter != NULL;
+         iter++)
+    {
+        McdClientProxy *handler = _mcd_client_registry_lookup (
+            self->priv->client_registry, *iter);
+
+        /* If the best handler that still exists bypasses approval, then
+         * we're going to bypass approval.
+         *
+         * Also, because handlers are sorted with the best ones first, and
+         * handlers with BypassApproval are "better", we can be sure that if
+         * we've found a handler that still exists and does not bypass
+         * approval, no handler bypasses approval. */
+        if (handler != NULL)
+        {
+            gboolean bypass = _mcd_client_proxy_get_bypass_approval (
+                handler);
+
+            DEBUG ("%s has BypassApproval=%c", *iter, bypass ? 'T' : 'F');
+            return bypass;
+        }
+    }
+
+    /* If no handler still exists, we don't bypass approval, although if that
+     * happens we're basically doomed anyway. */
+    return FALSE;
+}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index cdcc3b9..f280412 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1216,43 +1216,6 @@ mcd_dispatcher_run_approvers (McdDispatcherContext *context)
     mcd_dispatcher_context_release_pending_approver (context);
 }
 
-static gboolean
-handlers_can_bypass_approval (McdDispatcherContext *context)
-{
-    McdDispatcher *self = context->dispatcher;
-    const gchar * const *possible_handlers;
-    const gchar * const *iter;
-
-    possible_handlers = _mcd_dispatch_operation_get_possible_handlers (
-        context->operation);
-
-    for (iter = possible_handlers; iter != NULL && *iter != NULL; iter++)
-    {
-        McdClientProxy *handler = _mcd_client_registry_lookup (
-            self->priv->clients, *iter);
-
-        /* If the best handler that still exists bypasses approval, then
-         * we're going to bypass approval.
-         *
-         * Also, because handlers are sorted with the best ones first, and
-         * handlers with BypassApproval are "better", we can be sure that if
-         * we've found a handler that still exists and does not bypass
-         * approval, no handler bypasses approval. */
-        if (handler != NULL)
-        {
-            gboolean bypass = _mcd_client_proxy_get_bypass_approval (
-                handler);
-
-            DEBUG ("%s has BypassApproval=%c", *iter, bypass ? 'T' : 'F');
-            return bypass;
-        }
-    }
-
-    /* If no handler still exists, we don't bypass approval, although if that
-     * happens we're basically doomed anyway. */
-    return FALSE;
-}
-
 /* Happens at the end of successful filter chain execution (empty chain
  * is always successful)
  */
@@ -1273,7 +1236,8 @@ mcd_dispatcher_run_clients (McdDispatcherContext *context)
          * FIXME: we should really run BypassApproval handlers as a separate
          * stage, rather than considering the existence of a BypassApproval
          * handler to constitute approval - this is fd.o #23687 */
-        if (handlers_can_bypass_approval (context))
+        if (_mcd_dispatch_operation_handlers_can_bypass_approval
+            (context->operation))
             context->approved = TRUE;
 
         if (!context->approved)
-- 
1.5.6.5




More information about the telepathy-commits mailing list