From 54a80e8f70924c6bdcbbc369235691a18f77b076 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 31 May 2017 20:33:14 +0100 Subject: [PATCH 04/10] 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 4e9b67cb..c3f344ad 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 61bbf778..2964b6d4 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 71313190..0ede03f7 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.11.0