-
Notifications
You must be signed in to change notification settings - Fork 52
Description
ruby-dbus represents data using plain Ruby types, which is natural and perfectly fine when the method and property types are simple.
If we export a property with a more complex type, like (stttt) in the following example (available as
Gist, inspired by dinstaller/dbus/manager.rb) then the result will have a similar but incorrect type.
Given a Properties.Get(Progress) call, implemented like this:
$ svc() { pkill -f complex-property; RUBYLIB=lib ruby examples/service/complex-property.rb & sleep 1; }
$ get() { dbus-send --print-reply --dest=net.vidner.Scratch /net/vidner/Scratch org.freedesktop.DBus.Properties.Get string:net.vidner.Scratch string:Progress; }The EXPECTED result should be a variant of struct containing uint64's
$ svc; get
variant struct {
string "working"
uint64 1
uint64 0
uint64 100
uint64 42
}At the time this issue was originally reported, it was:
$ git checkout v0.17.0
$ svc; get
variant array [
variant string "working"
variant int32 1
variant int32 0
variant int32 100
variant int32 42
]PR #98 was a partial fix for Get but it is actually wrong since it doesn't respect the Variant return type:
# git checkout v0.18.0.beta1
$ svc; get
struct {
string "working"
uint64 1
uint64 0
uint64 100
uint64 42
}
# Notice the missing variant above, which is why busctl fails below
$ busctl --user --verbose get-property net.vidner.Scratch /net/vidner/Scratch net.vidner.Scratch Progress
Failed to parse bus message: Invalid argumentGetAll is still mistyped:
$ dbus-send --print-reply --dest=net.vidner.Scratch /net/vidner/Scratch org.freedesktop.DBus.Properties.GetAll string:net.vidner.Scratch
array [
dict entry(
string "Progress"
variant array [
variant string "working"
variant int32 1
variant int32 0
variant int32 100
variant int32 42
]
)
]Original issue description by JReidinger
Hi,
basically issue is with properties. If property has signature, then ruby-dbus should convert result same as it does for methods. So something like
def initialize
@test = ["a", "b", {}]
end
dbus_attr_reader :test, "(ssa{sv})"should work out of the box.
(mvidner: the original report had a(ssa{sv}) as the signature, off by one level of nesting)