[telepathy-mission-control/master] McdDispatchOperation: rename ->finished to be less misleading, and correct result of _mcd_dispatch_operation_is_finished

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


The "finished" boolean didn't actually mean "we have emitted Finished",
it meant "we will emit Finished as soon as we are allowed to", so
wants_to_finish would be a more accurate name.

The only current caller of _mcd_dispatch_operation_is_finished is the
McdDispatcher, when listing dispatch operations. To be consistent with
the change-notification signals, this API should list all dispatch
operations that have not yet emitted the D-Bus signal, even if they are
going to emit it as soon as their clients have finished.
---
 src/mcd-dispatch-operation.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 06d2ace..e2d4ea3 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -87,8 +87,8 @@ struct _McdDispatchOperationPrivate
      * dup'd bus name (string) => dummy non-NULL pointer */
     GHashTable *failed_handlers;
 
-    /* Results */
-    guint finished : 1;
+    /* if TRUE, we will emit finished as soon as we can */
+    gboolean wants_to_finish;
     gchar *handler;
     gchar *claimer;
     DBusGMethodInvocation *claim_context;
@@ -154,7 +154,7 @@ void
 _mcd_dispatch_operation_inc_observers_pending (McdDispatchOperation *self)
 {
     g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
-    g_return_if_fail (!self->priv->finished);
+    g_return_if_fail (!self->priv->wants_to_finish);
 
     g_object_ref (self);
 
@@ -189,7 +189,7 @@ void
 _mcd_dispatch_operation_inc_ado_pending (McdDispatchOperation *self)
 {
     g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
-    g_return_if_fail (!self->priv->finished);
+    g_return_if_fail (!self->priv->wants_to_finish);
 
     g_object_ref (self);
 
@@ -356,13 +356,13 @@ _mcd_dispatch_operation_finish (McdDispatchOperation *operation)
 {
     McdDispatchOperationPrivate *priv = operation->priv;
 
-    if (priv->finished)
+    if (priv->wants_to_finish)
     {
-        DEBUG ("already finished!");
+        DEBUG ("already finished (or about to)!");
         return FALSE;
     }
 
-    priv->finished = TRUE;
+    priv->wants_to_finish = TRUE;
 
     if (mcd_dispatch_operation_may_finish (operation))
     {
@@ -415,10 +415,10 @@ dispatch_operation_claim (TpSvcChannelDispatchOperation *self,
     McdDispatchOperationPrivate *priv;
 
     priv = MCD_DISPATCH_OPERATION_PRIV (self);
-    if (priv->finished)
+    if (priv->wants_to_finish)
     {
         GError *error = g_error_new (TP_ERRORS, TP_ERROR_NOT_YOURS,
-                                     "CDO already finished");
+                                     "CDO already finished (or trying to)");
         DEBUG ("Giving error to %s: %s", dbus_g_method_get_sender (context),
                error->message);
         dbus_g_method_return_error (context, error);
@@ -880,7 +880,9 @@ gboolean
 _mcd_dispatch_operation_is_finished (McdDispatchOperation *self)
 {
     g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
-    return self->priv->finished;
+    /* if we want to finish, and we can, then we have */
+    return (self->priv->wants_to_finish &&
+            mcd_dispatch_operation_may_finish (self));
 }
 
 const gchar * const *
@@ -910,7 +912,7 @@ mcd_dispatch_operation_check_handle_with (McdDispatchOperation *self,
 {
     g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
 
-    if (self->priv->finished)
+    if (self->priv->wants_to_finish)
     {
         DEBUG ("NotYours: already finished");
         g_set_error (error, TP_ERRORS, TP_ERROR_NOT_YOURS,
@@ -1059,7 +1061,7 @@ _mcd_dispatch_operation_check_finished (McdDispatchOperation *self)
             lost_channels = g_list_delete_link (lost_channels, lost_channels);
         }
 
-        if (self->priv->finished)
+        if (self->priv->wants_to_finish)
         {
             DEBUG ("%s/%p finished", self->priv->unique_name, self);
             mcd_dispatch_operation_actually_finish (self);
-- 
1.5.6.5




More information about the telepathy-commits mailing list