[telepathy-mission-control/master] McdClientProxy: add stub "ready lock" (count of tasks to do before ready)

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Sep 22 10:09:07 PDT 2009


---
 src/mcd-client-priv.h |    3 +++
 src/mcd-client.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index eb257b6..c920e5d 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -122,6 +122,9 @@ G_GNUC_INTERNAL gboolean _mcd_client_proxy_set_handler_properties (
     McdClientProxy *client, GHashTable *properties, const GError *error,
     const GPtrArray **handled_channels);
 
+G_GNUC_INTERNAL void _mcd_client_proxy_inc_ready_lock (McdClientProxy *self);
+G_GNUC_INTERNAL void _mcd_client_proxy_dec_ready_lock (McdClientProxy *self);
+
 #define MC_CLIENT_BUS_NAME_BASE_LEN (sizeof (TP_CLIENT_BUS_NAME_BASE) - 1)
 
 G_END_DECLS
diff --git a/src/mcd-client.c b/src/mcd-client.c
index 6fafd1a..89e3950 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -50,6 +50,7 @@ enum
 
 enum
 {
+    S_READY,
     S_UNIQUE_NAME_KNOWN,
     N_SIGNALS
 };
@@ -64,6 +65,7 @@ struct _McdClientProxyPrivate
     TpHandleSet *capability_tokens;
 
     gchar *unique_name;
+    guint ready_lock;
     gboolean introspect_started;
     gboolean ready;
     gboolean bypass_approval;
@@ -93,6 +95,36 @@ struct _McdClientProxyPrivate
     GList *observer_filters;
 };
 
+void
+_mcd_client_proxy_inc_ready_lock (McdClientProxy *self)
+{
+    g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+    if (self->priv->ready)
+        return;
+
+    g_return_if_fail (self->priv->ready_lock > 0);
+
+    self->priv->ready_lock++;
+}
+
+void
+_mcd_client_proxy_dec_ready_lock (McdClientProxy *self)
+{
+    g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+    if (self->priv->ready)
+        return;
+
+    g_return_if_fail (self->priv->ready_lock > 0);
+
+    if (--self->priv->ready_lock == 0)
+    {
+        self->priv->ready = TRUE;
+        g_signal_emit (self, signals[S_READY], 0);
+    }
+}
+
 static void _mcd_client_proxy_take_approver_filters
     (McdClientProxy *self, GList *filters);
 static void _mcd_client_proxy_take_observer_filters
@@ -495,6 +527,8 @@ _mcd_client_proxy_init (McdClientProxy *self)
 {
     self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MCD_TYPE_CLIENT_PROXY,
                                               McdClientProxyPrivate);
+    /* paired with first call to mcd_client_proxy_introspect */
+    self->priv->ready_lock = 1;
 }
 
 gboolean
@@ -646,6 +680,7 @@ mcd_client_proxy_introspect (gpointer data)
     {
         self->priv->introspect_started = TRUE;
         g_signal_emit (self, signals[S_UNIQUE_NAME_KNOWN], 0);
+        _mcd_client_proxy_dec_ready_lock (self);
     }
 
     return FALSE;
@@ -801,6 +836,13 @@ _mcd_client_proxy_class_init (McdClientProxyClass *klass)
         g_cclosure_marshal_VOID__VOID,
         G_TYPE_NONE, 0);
 
+    signals[S_READY] = g_signal_new ("ready",
+        G_OBJECT_CLASS_TYPE (klass),
+        G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+        0, NULL, NULL,
+        g_cclosure_marshal_VOID__VOID,
+        G_TYPE_NONE, 0);
+
     g_object_class_install_property (object_class, PROP_ACTIVATABLE,
         g_param_spec_boolean ("activatable", "Activatable?",
             "TRUE if this client can be service-activated", FALSE,
-- 
1.5.6.5




More information about the telepathy-commits mailing list