driver: Generate child node elements in introspection

This makes the /org/freedesktop/DBus path discoverable.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101257
This commit is contained in:
Simon McVittie 2017-05-31 20:33:14 +01:00
parent db5bab32fe
commit 175c6c14d3
3 changed files with 28 additions and 4 deletions

View file

@ -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,
" <node name=\"org/freedesktop/DBus\"/>\n"))
return FALSE;
}
else if (dbus_message_has_path (message, "/org"))
{
if (!_dbus_string_append (xml,
" <node name=\"freedesktop/DBus\"/>\n"))
return FALSE;
}
else if (dbus_message_has_path (message, "/org/freedesktop"))
{
if (!_dbus_string_append (xml, " <node name=\"DBus\"/>\n"))
return FALSE;
}
}
if (!_dbus_string_append (xml, "</node>\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);

View file

@ -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 */

View file

@ -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;