dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

Support "" as interface name in org.freedesktop.DBus.Properties GetAll method #312

Open zeenix opened 1 year ago

zeenix commented 1 year ago

In GitLab by @zevweiss on Dec 30, 2022, 05:50

While it's a bit light on description of exactly what the semantics are, the dbus spec does say that "[a]n empty string may be provided for the interface name" for the methods of the org.freedesktop.DBus.Properties interface. Inspecting the libsdbus implementation as a reference (here and here), it looks like it only supports it for GetAll, and just returns the union of all properties on all interfaces. (Given the lack of implementation there, I assume that Get and Set with an empty interface_name argument is not widely used.)

At present, calling GetAll with an empty string as the interface name produces an error:

Invalid interface or error name: `` is 0 characters long, which is smaller than minimum allowed (3)

zeenix commented 1 year ago

You're right. That was an oversight I believe. The argument here should be Optional<InterfaceName<'_>> instead. However, I think for backwards-compat and keeping in mind that this is a very niche use case (I think), we should add another wrapper (e.g get_all_optional) that takes the more correct type and with #[dbus_proxy(name = "GetAll"] attribute so it's the same method call underneath.

zeenix commented 1 year ago

In case you (or anyone else) decide to handle this before I get a chance, keep in mind that's the zvariant::Optional we need to use, as unfortunately Option is not an option. :disappointed: