Report child nodes of the "/" path
The code in dbus-c++ which searches for child nodes of a path did
not special case the prefix used for searching for children of "/".
Add this code, as well as adding another special case to avoid
including "" as a child of "/" (since the "/" is a strict substring
of "/").
BUG=chromium:394470
TEST=gdbus introspect --system --dest org.chromium.flimflam --object-path / --recurse --only-properties
dbus-send --system --dest=org.chromium.flimflam --type=method_call --print-reply / org.freedesktop.DBus.Introspectable.Introspect
Change-Id: I622603bcbf6dcec2c1541f77fb10c60b2982ca81
Reviewed-on: https://chromium-review.googlesource.com/211617
Reviewed-by: mukesh agrawal <[email protected]>
Commit-Queue: Paul Stewart <[email protected]>
Tested-by: Paul Stewart <[email protected]>
diff --git a/src/introspection.cpp b/src/introspection.cpp
index 1ff179e..f6f6bcc 100644
--- a/src/introspection.cpp
+++ b/src/introspection.cpp
@@ -114,7 +114,8 @@
}
}
- const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(path + '/');
+ const std::string prefix(path == "/" ? path : path + '/');
+ const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(prefix);
ObjectPathList::const_iterator oni;
for (oni = nodes.begin(); oni != nodes.end(); ++oni)
diff --git a/src/object.cpp b/src/object.cpp
index c9bf02d..40f7cac 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -133,7 +133,8 @@
while (ati != _adaptor_table.end())
{
- if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
+ if (ati->second->path() != "/" && // Root node is never a child.
+ !strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
{
std::string p = ati->second->path().substr(plen);
p = p.substr(0,p.find('/'));