From 1d44e5cf4d3aca1cf501e59d4ccd79c484194312 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 15 Feb 2011 19:50:55 -0500 Subject: Don't report standard interfaces more than once If they have a custom implementation, don't add the canned introspection XML, just rely on the generated XML. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=642042 --- gio/gdbusconnection.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 809f97640..44d5446df 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -4228,7 +4228,7 @@ static const gchar introspect_header[] = static const gchar introspect_tail[] = "\n"; -static const gchar introspect_standard_interfaces[] = +static const gchar introspect_properties_interface[] = " \n" " \n" " \n" @@ -4249,7 +4249,9 @@ static const gchar introspect_standard_interfaces[] = " \n" " \n" " \n" - " \n" + " \n"; + +static const gchar introspect_introspectable_interface[] = " \n" " \n" " \n" @@ -4268,12 +4270,6 @@ introspect_append_header (GString *s) g_string_append (s, introspect_header); } -static void -introspect_append_standard_interfaces (GString *s) -{ - g_string_append (s, introspect_standard_interfaces); -} - static void maybe_add_path (const gchar *path, gsize path_len, const gchar *object_path, GHashTable *set) { @@ -4365,10 +4361,17 @@ handle_introspect (GDBusConnection *connection, /* first the header with the standard interfaces */ s = g_string_sized_new (sizeof (introspect_header) + - sizeof (introspect_standard_interfaces) + + sizeof (introspect_properties_interface) + + sizeof (introspect_introspectable_interface) + sizeof (introspect_tail)); introspect_append_header (s); - introspect_append_standard_interfaces (s); + if (!g_hash_table_lookup (eo->map_if_name_to_ei, + "org.freedesktop.DBus.Properties")) + g_string_append (s, introspect_properties_interface); + + if (!g_hash_table_lookup (eo->map_if_name_to_ei, + "org.freedesktop.DBus.Introspectable")) + g_string_append (s, introspect_introspectable_interface); /* then include the registered interfaces */ g_hash_table_iter_init (&hash_iter, eo->map_if_name_to_ei); @@ -5377,6 +5380,8 @@ handle_subtree_introspect (GDBusConnection *connection, GDBusInterfaceInfo **interfaces; guint n; gchar **subnode_paths; + gboolean has_properties_interface; + gboolean has_introspectable_interface; handled = FALSE; @@ -5416,7 +5421,20 @@ handle_subtree_introspect (GDBusConnection *connection, es->user_data); if (interfaces != NULL) { - introspect_append_standard_interfaces (s); + has_properties_interface = FALSE; + has_introspectable_interface = FALSE; + + for (n = 0; interfaces[n] != NULL; n++) + { + if (strcmp (interfaces[n]->name, "org.freedesktop.DBus.Properties") == 0) + has_properties_interface = TRUE; + else if (strcmp (interfaces[n]->name, "org.freedesktop.DBus.Introspectable") == 0) + has_introspectable_interface = TRUE; + } + if (!has_properties_interface) + g_string_append (s, introspect_properties_interface); + if (!has_introspectable_interface) + g_string_append (s, introspect_introspectable_interface); for (n = 0; interfaces[n] != NULL; n++) { -- cgit v1.2.3