[telepathy-mission-control/master] McdDispatcher: tell McdClientProxy when it becomes active/inactive

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 26 05:54:02 PDT 2009


---
 src/mcd-client-priv.h |    4 ++++
 src/mcd-client.c      |   19 +++++++++++++++++++
 src/mcd-dispatcher.c  |    9 ++++++++-
 3 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index 4604727..f11afd7 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -77,6 +77,10 @@ G_GNUC_INTERNAL gboolean _mcd_client_proxy_is_active (McdClientProxy *self);
 G_GNUC_INTERNAL const gchar *_mcd_client_proxy_get_unique_name (
     McdClientProxy *self);
 
+G_GNUC_INTERNAL void _mcd_client_proxy_set_inactive (McdClientProxy *self);
+G_GNUC_INTERNAL void _mcd_client_proxy_set_active (McdClientProxy *self,
+                                                   const gchar *unique_name);
+
 /* Analogous to TP_CM_*_BASE */
 #define MC_CLIENT_BUS_NAME_BASE MC_IFACE_CLIENT "."
 #define MC_CLIENT_OBJECT_PATH_BASE "/org/freedesktop/Telepathy/Client/"
diff --git a/src/mcd-client.c b/src/mcd-client.c
index 6369005..9fe293e 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -296,3 +296,22 @@ _mcd_client_proxy_new (TpDBusDaemon *dbus_daemon,
 
     return self;
 }
+
+void
+_mcd_client_proxy_set_inactive (McdClientProxy *self)
+{
+    g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+    g_free (self->priv->unique_name);
+    self->priv->unique_name = NULL;
+}
+
+void
+_mcd_client_proxy_set_active (McdClientProxy *self,
+                              const gchar *unique_name)
+{
+    g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+    g_free (self->priv->unique_name);
+    self->priv->unique_name = g_strdup (unique_name);
+}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 2a9484d..aa2ab50 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -2374,6 +2374,7 @@ mcd_dispatcher_add_client (McdDispatcher *self,
     }
 
     client = g_hash_table_lookup (priv->clients, name);
+
     if (client)
     {
         /* This Telepathy Client is already known so don't create it
@@ -2385,6 +2386,7 @@ mcd_dispatcher_add_client (McdDispatcher *self,
         }
         else
         {
+            _mcd_client_proxy_set_active (client->proxy, owner);
             client->active = TRUE;
         }
 
@@ -2494,12 +2496,17 @@ name_owner_changed_cb (TpDBusDaemon *proxy,
     }
     else if (old_owner[0] != '\0' && new_owner[0] == '\0')
     {
-        /* The name disappeared from the bus */
+        /* The name disappeared from the bus. It might be either well-known
+         * or unique */
         McdClient *client;
 
         client = g_hash_table_lookup (priv->clients, name);
+
         if (client)
         {
+            client->active = FALSE;
+            _mcd_client_proxy_set_inactive (client->proxy);
+
             if (!client->activatable)
                 g_hash_table_remove (priv->clients, name);
             else
-- 
1.5.6.5




More information about the telepathy-commits mailing list