[telepathy-mission-control/master] _mcd_dispatch_operation_check_client_locks: move mcd_dispatcher_context_check_client_locks here; use new run-handlers signal to tell context to run handlers
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Nov 2 06:41:36 PST 2009
---
src/mcd-dispatch-operation-priv.h | 3 ++
src/mcd-dispatch-operation.c | 25 +++++++++++++++++++++++
src/mcd-dispatcher.c | 39 ++++++++++++++----------------------
3 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 6d9f823..3de6375 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -149,6 +149,9 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_get_cancelled (
G_GNUC_INTERNAL void _mcd_dispatch_operation_set_cancelled (
McdDispatchOperation *self);
+G_GNUC_INTERNAL void _mcd_dispatch_operation_check_client_locks (
+ McdDispatchOperation *self);
+
G_END_DECLS
#endif
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index f7cafc8..1b70a26 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -75,6 +75,7 @@ G_DEFINE_TYPE_WITH_CODE (McdDispatchOperation, _mcd_dispatch_operation,
enum
{
S_READY_TO_DISPATCH,
+ S_RUN_HANDLERS,
N_SIGNALS
};
@@ -294,6 +295,23 @@ _mcd_dispatch_operation_set_cancelled (McdDispatchOperation *self)
self->priv->cancelled = TRUE;
}
+void
+_mcd_dispatch_operation_check_client_locks (McdDispatchOperation *self)
+{
+ if (!_mcd_dispatch_operation_is_invoking_early_clients (self) &&
+ !_mcd_dispatch_operation_has_observers_pending (self) &&
+ _mcd_dispatch_operation_is_approved (self))
+ {
+ /* no observers etc. left */
+ if (!_mcd_dispatch_operation_get_channels_handled (self))
+ {
+ _mcd_dispatch_operation_set_channels_handled (self,
+ TRUE);
+ g_signal_emit (self, signals[S_RUN_HANDLERS], 0);
+ }
+ }
+}
+
enum
{
PROP_0,
@@ -830,6 +848,13 @@ _mcd_dispatch_operation_class_init (McdDispatchOperationClass * klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[S_RUN_HANDLERS] = g_signal_new ("run-handlers",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 92e046b..82fce19 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -485,7 +485,8 @@ mcd_dispatcher_set_channel_handled_by (McdDispatcher *self,
tp_channel, unique_name);
}
-static void mcd_dispatcher_run_handlers (McdDispatcherContext *context);
+static void mcd_dispatcher_run_handlers (McdDispatchOperation *op,
+ McdDispatcherContext *context);
static void
handle_channels_cb (TpClient *proxy, const GError *error, gpointer user_data,
@@ -503,7 +504,7 @@ handle_channels_cb (TpClient *proxy, const GError *error, gpointer user_data,
tp_proxy_get_bus_name (proxy));
/* try again */
- mcd_dispatcher_run_handlers (context);
+ mcd_dispatcher_run_handlers (context->operation, context);
}
else
{
@@ -769,7 +770,8 @@ mcd_dispatcher_handle_channels (McdDispatcherContext *context,
}
static void
-mcd_dispatcher_run_handlers (McdDispatcherContext *context)
+mcd_dispatcher_run_handlers (McdDispatchOperation *op,
+ McdDispatcherContext *context)
{
McdDispatcher *self = context->dispatcher;
GList *channels, *list;
@@ -863,27 +865,10 @@ finally:
}
static void
-mcd_dispatcher_context_check_client_locks (McdDispatcherContext *context)
-{
- if (!_mcd_dispatch_operation_is_invoking_early_clients (context->operation) &&
- !_mcd_dispatch_operation_has_observers_pending (context->operation) &&
- _mcd_dispatch_operation_is_approved (context->operation))
- {
- /* no observers etc. left */
- if (!_mcd_dispatch_operation_get_channels_handled (context->operation))
- {
- _mcd_dispatch_operation_set_channels_handled (context->operation,
- TRUE);
- mcd_dispatcher_run_handlers (context);
- }
- }
-}
-
-static void
mcd_dispatcher_context_release_pending_observer (McdDispatcherContext *context)
{
_mcd_dispatch_operation_dec_observers_pending (context->operation);
- mcd_dispatcher_context_check_client_locks (context);
+ _mcd_dispatch_operation_check_client_locks (context->operation);
}
static void
@@ -1049,7 +1034,7 @@ mcd_dispatcher_context_release_pending_approver (McdDispatcherContext *context)
_mcd_dispatch_operation_set_approved (context->operation);
}
- mcd_dispatcher_context_check_client_locks (context);
+ _mcd_dispatch_operation_check_client_locks (context->operation);
}
static void
@@ -1199,7 +1184,7 @@ mcd_dispatcher_run_clients (McdDispatcherContext *context)
_mcd_dispatch_operation_set_invoking_early_clients (context->operation,
FALSE);
- mcd_dispatcher_context_check_client_locks (context);
+ _mcd_dispatch_operation_check_client_locks (context->operation);
mcd_dispatcher_context_unref (context, "CTXREF07");
}
@@ -1307,7 +1292,7 @@ mcd_dispatcher_op_ready_to_dispatch_cb (McdDispatchOperation *operation,
mcd_dispatcher_context_unref (context, "CTXREF14");
}
- mcd_dispatcher_context_check_client_locks (context);
+ _mcd_dispatch_operation_check_client_locks (context->operation);
mcd_dispatcher_context_unref (context, "CTXREF15");
}
@@ -1361,6 +1346,9 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher,
priv->operations = g_list_prepend (priv->operations, context->operation);
+ g_signal_connect (context->operation, "run-handlers",
+ G_CALLBACK (mcd_dispatcher_run_handlers), context);
+
if (!requested)
{
if (priv->operation_list_active)
@@ -2035,6 +2023,9 @@ mcd_dispatcher_context_unref (McdDispatcherContext * context,
DEBUG ("freeing the context %p", context);
g_signal_handlers_disconnect_by_func (context->operation,
+ mcd_dispatcher_run_handlers, context);
+
+ g_signal_handlers_disconnect_by_func (context->operation,
on_operation_finished,
context->dispatcher);
--
1.5.6.5
More information about the telepathy-commits
mailing list