[telepathy-mission-control/master] McdClientRegistry: watch for new clients here, rather than in McdDispatcher
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Oct 19 07:01:10 PDT 2009
This lets us simplify McdDispatcher's name-owner watch considerably, since
now it only cares about unique names.
---
src/client-registry.c | 29 ++++++++++++++++++++++++++---
src/mcd-dispatcher.c | 31 ++++---------------------------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/client-registry.c b/src/client-registry.c
index 338e457..8a286b8 100644
--- a/src/client-registry.c
+++ b/src/client-registry.c
@@ -331,6 +331,27 @@ mcd_client_registry_list_names_cb (TpDBusDaemon *proxy,
}
static void
+mcd_client_registry_name_owner_changed_cb (TpDBusDaemon *proxy,
+ const gchar *name,
+ const gchar *old_owner,
+ const gchar *new_owner,
+ gpointer user_data G_GNUC_UNUSED,
+ GObject *weak_object)
+{
+ McdClientRegistry *self = MCD_CLIENT_REGISTRY (weak_object);
+
+ /* dbus-glib guarantees this */
+ g_assert (name != NULL);
+ g_assert (old_owner != NULL);
+ g_assert (new_owner != NULL);
+
+ if (old_owner[0] == '\0' && new_owner[0] != '\0')
+ {
+ _mcd_client_registry_found_name (self, name, new_owner, FALSE);
+ }
+}
+
+static void
mcd_client_registry_constructed (GObject *object)
{
McdClientRegistry *self = MCD_CLIENT_REGISTRY (object);
@@ -342,9 +363,11 @@ mcd_client_registry_constructed (GObject *object)
g_return_if_fail (self->priv->dbus_daemon != NULL);
- /* FIXME: strictly speaking, we should connect to NameOwnerChanged
- * *before* calling ListNames. This will be fixed when the NameOwnerChanged
- * handling moves here too. */
+ /* FIXME: ideally, this would be a more specific match, using arg0prefix
+ * (when dbus-daemon supports that, which it doesn't yet) so we only get
+ * new clients. */
+ tp_cli_dbus_daemon_connect_to_name_owner_changed (self->priv->dbus_daemon,
+ mcd_client_registry_name_owner_changed_cb, NULL, NULL, object, NULL);
tp_cli_dbus_daemon_call_list_names (self->priv->dbus_daemon, -1,
mcd_client_registry_list_names_cb, NULL, NULL, object);
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 48e32eb..c5f099d 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1887,34 +1887,11 @@ name_owner_changed_cb (TpDBusDaemon *proxy,
g_assert (old_owner != NULL);
g_assert (new_owner != NULL);
- if (old_owner[0] == '\0' && new_owner[0] != '\0')
+ if (name[0] == ':' && new_owner[0] == '\0')
{
- _mcd_client_registry_found_name (self->priv->clients,
- name, new_owner, FALSE);
- }
- else if (old_owner[0] != '\0' && new_owner[0] == '\0')
- {
- /* The name disappeared from the bus. It might be either well-known
- * (handled within McdClientProxy) or unique (handled here) */
- if (name[0] == ':')
- {
- /* it's a unique name - maybe it was handling some channels? */
- _mcd_handler_map_set_handler_crashed (priv->handler_map, name);
- }
- }
- else if (old_owner[0] != '\0' && new_owner[0] != '\0')
- {
- /* Atomic ownership handover - handle this like an exit + startup */
- name_owner_changed_cb (proxy, name, old_owner, "", user_data,
- weak_object);
- name_owner_changed_cb (proxy, name, "", new_owner, user_data,
- weak_object);
- }
- else
- {
- /* dbus-daemon is sick */
- DEBUG ("Malformed message from the D-Bus daemon about '%s' "
- "('%s' -> '%s')", name, old_owner, new_owner);
+ /* A unique name disappeared from the bus. It might be handling
+ * channels? */
+ _mcd_handler_map_set_handler_crashed (priv->handler_map, name);
}
}
--
1.5.6.5
More information about the telepathy-commits
mailing list