[telepathy-mission-control/master] McdDispatchOperation: track the "awaiting approval" flag

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


---
 src/mcd-dispatch-operation-priv.h |    6 ++++++
 src/mcd-dispatch-operation.c      |   21 +++++++++++++++++++++
 src/mcd-dispatcher.c              |   20 ++++++++------------
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 9f109bf..ee137b4 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -126,6 +126,12 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_is_invoking_early_clients (
 G_GNUC_INTERNAL void _mcd_dispatch_operation_set_invoking_early_clients (
     McdDispatchOperation *self, gboolean value);
 
+/* Client lock while waiting for approvers' opinion */
+G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_is_awaiting_approval (
+    McdDispatchOperation *self);
+G_GNUC_INTERNAL void _mcd_dispatch_operation_set_awaiting_approval (
+    McdDispatchOperation *self, gboolean value);
+
 G_END_DECLS
 
 #endif
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index e2d4ea3..6e1ba77 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -110,6 +110,12 @@ struct _McdDispatchOperationPrivate
      * or a client approved processing with arbitrary handlers */
     gboolean approved;
 
+    /* If TRUE, at least one Approver accepted this dispatch operation, and
+     * we're waiting for one of them to call HandleWith or Claim. This is a
+     * client lock; a reference must be held while it is TRUE (in the
+     * McdDispatcherContext, CTXREF14 ensures this). */
+    gboolean awaiting_approval;
+
     /* If TRUE, we're still working out what Observers and Approvers to
      * run. This is a temporary client lock; a reference must be held
      * while it is TRUE (in the McdDispatcherContext, CTXREF07 ensures this).
@@ -229,6 +235,21 @@ _mcd_dispatch_operation_set_invoking_early_clients (McdDispatchOperation *self,
     self->priv->invoking_early_clients = value;
 }
 
+gboolean
+_mcd_dispatch_operation_is_awaiting_approval (McdDispatchOperation *self)
+{
+    g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
+    return self->priv->awaiting_approval;
+}
+
+void
+_mcd_dispatch_operation_set_awaiting_approval (McdDispatchOperation *self,
+                                               gboolean value)
+{
+    g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
+    self->priv->awaiting_approval = value;
+}
+
 enum
 {
     PROP_0,
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 3e6e641..e2a3630 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -93,12 +93,6 @@ struct _McdDispatcherContext
     /* If this flag is TRUE, dispatching must be cancelled ASAP */
     guint cancelled : 1;
 
-    /* If TRUE, at least one Approver has accepted the CDO. This is a
-     * client lock.
-     *
-     * CTXREF14 is held while we await approval. */
-    guint awaiting_approval : 1;
-
     /* If TRUE, either we've already arranged for the channels to get a
      * handler, or there are no channels left. */
     guint channels_handled : 1;
@@ -1058,7 +1052,7 @@ mcd_dispatcher_context_release_pending_approver (McdDispatcherContext *context)
     _mcd_dispatch_operation_dec_ado_pending (context->operation);
 
     if (!_mcd_dispatch_operation_has_ado_pending (context->operation) &&
-        !context->awaiting_approval)
+        !_mcd_dispatch_operation_is_awaiting_approval (context->operation))
     {
         DEBUG ("No approver accepted the channels; considering them to be "
                "approved");
@@ -1088,9 +1082,10 @@ add_dispatch_operation_cb (TpClient *proxy, const GError *error,
                _mcd_dispatch_operation_get_path (context->operation),
                context);
 
-        if (!context->awaiting_approval)
+        if (!_mcd_dispatch_operation_is_awaiting_approval (context->operation))
         {
-            context->awaiting_approval = TRUE;
+            _mcd_dispatch_operation_set_awaiting_approval (context->operation,
+                                                           TRUE);
             mcd_dispatcher_context_ref (context, "CTXREF14");
         }
     }
@@ -1347,9 +1342,10 @@ on_operation_finished (McdDispatchOperation *operation,
         context->channels_handled = TRUE;
     }
 
-    if (context->awaiting_approval)
+    if (_mcd_dispatch_operation_is_awaiting_approval (context->operation))
     {
-        context->awaiting_approval = FALSE;
+        _mcd_dispatch_operation_set_awaiting_approval (context->operation,
+                                                       FALSE);
         _mcd_dispatch_operation_set_approved (context->operation);
         mcd_dispatcher_context_unref (context, "CTXREF14");
     }
@@ -2658,7 +2654,7 @@ _mcd_dispatcher_add_channel_request (McdDispatcher *dispatcher,
             context = find_context_from_channel (dispatcher, channel);
             DEBUG ("channel %p is in context %p", channel, context);
             if (_mcd_dispatch_operation_has_ado_pending (context->operation)
-                || context->awaiting_approval)
+                || _mcd_dispatch_operation_is_awaiting_approval (context->operation))
             {
                 /* the existing channel is waiting for approval; but since the
                  * same channel has been requested, the approval operation must
-- 
1.5.6.5




More information about the telepathy-commits mailing list