From f6f3161ee85ef86e9dcb728590051ba7033d4158 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 31 May 2017 20:33:14 +0100 Subject: [PATCH 2/3] driver: Generate child node elements in introspection This makes the /org/freedesktop/DBus path discoverable. Signed-off-by: Simon McVittie --- 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 c150e3e1..4ff05b3f 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -2532,7 +2532,8 @@ write_args_for_direction (DBusString *xml, dbus_bool_t bus_driver_generate_introspect_string (DBusString *xml, - dbus_bool_t canonical_path) + dbus_bool_t canonical_path, + DBusMessage *message) { const InterfaceHandler *ih; const MessageHandler *mh; @@ -2575,6 +2576,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; @@ -2613,7 +2636,7 @@ bus_driver_handle_introspect (DBusConnection *connection, canonical_path = dbus_message_has_path (message, DBUS_PATH_DBUS); - if (!bus_driver_generate_introspect_string (&xml, canonical_path)) + if (!bus_driver_generate_introspect_string (&xml, 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