[telepathy-mission-control/master] McdDispatchOperation: store the cancelled flag here

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


---
 src/mcd-dispatch-operation-priv.h |    5 +++++
 src/mcd-dispatch-operation.c      |   17 +++++++++++++++++
 src/mcd-dispatcher.c              |    7 ++-----
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 5d2a424..1f9256c 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -137,6 +137,11 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_get_channels_handled (
 G_GNUC_INTERNAL void _mcd_dispatch_operation_set_channels_handled (
     McdDispatchOperation *self, gboolean value);
 
+G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_get_cancelled (
+    McdDispatchOperation *self);
+G_GNUC_INTERNAL void _mcd_dispatch_operation_set_cancelled (
+    McdDispatchOperation *self);
+
 G_END_DECLS
 
 #endif
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index b9d5eeb..3d98fcd 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -141,6 +141,9 @@ struct _McdDispatchOperationPrivate
     /* If TRUE, either we've already arranged for the channels to get a
      * handler, or there are no channels left. */
     gboolean channels_handled;
+
+    /* If TRUE, we're dispatching a channel request and it was cancelled */
+    gboolean cancelled;
 };
 
 static void _mcd_dispatch_operation_check_finished (
@@ -269,6 +272,20 @@ _mcd_dispatch_operation_get_channels_handled (McdDispatchOperation *self)
     return self->priv->channels_handled;
 }
 
+gboolean
+_mcd_dispatch_operation_get_cancelled (McdDispatchOperation *self)
+{
+    g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
+    return self->priv->cancelled;
+}
+
+void
+_mcd_dispatch_operation_set_cancelled (McdDispatchOperation *self)
+{
+    g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
+    self->priv->cancelled = TRUE;
+}
+
 enum
 {
     PROP_0,
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 343bf48..94d9912 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -90,9 +90,6 @@ struct _McdDispatcherContext
 {
     gint ref_count;
 
-    /* If this flag is TRUE, dispatching must be cancelled ASAP */
-    guint cancelled : 1;
-
     McdDispatcher *dispatcher;
 
     GList *channels;
@@ -1236,7 +1233,7 @@ on_channel_abort_context (McdChannel *channel, McdDispatcherContext *context)
      * context should be aborted */
     error = mcd_channel_get_error (channel);
     if (error && error->code == TP_ERROR_CANCELLED)
-        context->cancelled = TRUE;
+        _mcd_dispatch_operation_set_cancelled (context->operation);
 
     /* Losing the channel might mean we get freed, which would make some of
      * the operations below very unhappy */
@@ -1883,7 +1880,7 @@ mcd_dispatcher_context_proceed (McdDispatcherContext *context)
     GError error = { TP_ERRORS, 0, NULL };
     McdFilter *filter;
 
-    if (context->cancelled)
+    if (_mcd_dispatch_operation_get_cancelled (context->operation))
     {
         error.code = TP_ERROR_CANCELLED;
         error.message = "Channel request cancelled";
-- 
1.5.6.5




More information about the telepathy-commits mailing list