From 175c6c14d3c995585f365ba013c8267674e868ba Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 31 May 2017 20:33:14 +0100 Subject: [PATCH] driver: Generate child node elements in introspection This makes the /org/freedesktop/DBus path discoverable. Signed-off-by: Simon McVittie Reviewed-by: Philip Withnall Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101257 --- bus/driver.c | 27 +++++++++++++++++++++++++-- bus/driver.h | 3 ++- bus/main.c | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 4e9b67c..c3f344a 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -2537,7 +2537,8 @@ write_args_for_direction (DBusString *xml, dbus_bool_t bus_driver_generate_introspect_string (DBusString *xml, - dbus_bool_t is_canonical_path) + dbus_bool_t is_canonical_path, + DBusMessage *message) { const InterfaceHandler *ih; const MessageHandler *mh; @@ -2580,6 +2581,28 @@ bus_driver_generate_introspect_string (DBusString *xml, return FALSE; } + if (message != NULL) + { + /* Make the bus driver object path discoverable */ + if (dbus_message_has_path (message, "/")) + { + if (!_dbus_string_append (xml, + " \n")) + return FALSE; + } + else if (dbus_message_has_path (message, "/org")) + { + if (!_dbus_string_append (xml, + " \n")) + return FALSE; + } + else if (dbus_message_has_path (message, "/org/freedesktop")) + { + if (!_dbus_string_append (xml, " \n")) + return FALSE; + } + } + if (!_dbus_string_append (xml, "\n")) return FALSE; @@ -2618,7 +2641,7 @@ bus_driver_handle_introspect (DBusConnection *connection, is_canonical_path = dbus_message_has_path (message, DBUS_PATH_DBUS); - if (!bus_driver_generate_introspect_string (&xml, is_canonical_path)) + if (!bus_driver_generate_introspect_string (&xml, is_canonical_path, message)) goto oom; v_STRING = _dbus_string_get_const_data (&xml); diff --git a/bus/driver.h b/bus/driver.h index 61bbf77..2964b6d 100644 --- a/bus/driver.h +++ b/bus/driver.h @@ -46,6 +46,7 @@ dbus_bool_t bus_driver_send_service_owner_changed (const char *service_name BusTransaction *transaction, DBusError *error); dbus_bool_t bus_driver_generate_introspect_string (DBusString *xml, - dbus_bool_t canonical_path); + dbus_bool_t canonical_path, + DBusMessage *message); #endif /* BUS_DRIVER_H */ diff --git a/bus/main.c b/bus/main.c index 7131319..0ede03f 100644 --- a/bus/main.c +++ b/bus/main.c @@ -189,7 +189,7 @@ introspect (void) if (!_dbus_string_init (&xml)) goto oom; - if (!bus_driver_generate_introspect_string (&xml, TRUE)) + if (!bus_driver_generate_introspect_string (&xml, TRUE, NULL)) { _dbus_string_free (&xml); goto oom; -- 2.7.4