[telepathy-mission-control/master] McdDispatchOperation: process Claim(), and check for no-more-channels, in _mcd_dispatch_operation_check_client_locks rather than in mcd_dispatch_operation_actually_finish

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Oct 27 14:09:47 PDT 2009


---
 src/mcd-dispatch-operation.c |   67 ++++++++++++++++++++++-------------------
 1 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 2339aed..4445902 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -295,6 +295,8 @@ static gboolean _mcd_dispatch_operation_try_next_handler (
 static void _mcd_dispatch_operation_close_as_undispatchable (
     McdDispatchOperation *self);
 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);
 
 static void
 _mcd_dispatch_operation_check_client_locks (McdDispatchOperation *self)
@@ -334,6 +336,39 @@ _mcd_dispatch_operation_check_client_locks (McdDispatchOperation *self)
         return;
     }
 
+    if (self->priv->channels == NULL)
+    {
+        DEBUG ("Nothing left to dispatch");
+        self->priv->channels_handled = TRUE;
+    }
+
+    /* if we've been claimed, respond, then do not call HandleChannels */
+    if (self->priv->claim_context != NULL)
+    {
+        const GList *list;
+
+        g_assert (!self->priv->channels_handled);
+        self->priv->channels_handled = TRUE;
+
+        g_assert (self->priv->claimer != NULL);
+
+        for (list = self->priv->channels; list != NULL; list = list->next)
+        {
+            McdChannel *channel = MCD_CHANNEL (list->data);
+
+            mcd_dispatch_operation_set_channel_handled_by (self, channel,
+                self->priv->claimer);
+        }
+
+        DEBUG ("Replying to Claim call from %s", self->priv->claimer);
+
+        tp_svc_channel_dispatch_operation_return_from_claim (
+            self->priv->claim_context);
+        self->priv->claim_context = NULL;
+
+        return;
+    }
+
     if (self->priv->invoked_approvers_if_needed)
     {
         if (_mcd_dispatch_operation_is_approved (self))
@@ -509,42 +544,12 @@ mcd_dispatch_operation_actually_finish (McdDispatchOperation *self)
     DEBUG ("%s/%p: finished", self->priv->unique_name, self);
     tp_svc_channel_dispatch_operation_emit_finished (self);
 
-    if (self->priv->channels == NULL)
-    {
-        DEBUG ("Nothing left to dispatch");
-        self->priv->channels_handled = TRUE;
-    }
-
-    if (self->priv->claimer != NULL)
-    {
-        const GList *list;
-
-        /* we don't release the client lock, in order to not run the handlers,
-         * but we do have to mark all channels as dispatched */
-        for (list = self->priv->channels; list != NULL; list = list->next)
-        {
-            McdChannel *channel = MCD_CHANNEL (list->data);
-
-            mcd_dispatch_operation_set_channel_handled_by (self, channel,
-                self->priv->claimer);
-        }
-
-        g_assert (!self->priv->channels_handled);
-        self->priv->channels_handled = TRUE;
-    }
-
     if (self->priv->awaiting_approval)
     {
         self->priv->awaiting_approval = FALSE;
-        _mcd_dispatch_operation_check_client_locks (self);
     }
 
-    if (self->priv->claim_context != NULL)
-    {
-        DEBUG ("Replying to Claim call from %s", self->priv->claimer);
-        tp_svc_channel_dispatch_operation_return_from_claim (self->priv->claim_context);
-        self->priv->claim_context = NULL;
-    }
+    _mcd_dispatch_operation_check_client_locks (self);
 
     g_object_unref (self);
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list