Open mvidner opened 2 years ago
I've had success on my machine with applying this transformation between GetSettings
and Update
def fix_types(settings)
types = {
"connection.permissions" => "as",
"802-11-wireless.mac-address" => "ay",
"802-11-wireless.mac-address-blacklist" => "as",
"802-11-wireless.ssid" => "ay",
"ipv4.address-data" => "aa{sv}",
"ipv4.addresses" => "aau",
"ipv4.dns" => "au",
"ipv4.dns-search" => "as",
"ipv4.route-data" => "aa{sv}",
"ipv4.routes" => "aau",
"ipv6.address-data" => "aa{sv}",
"ipv6.addresses" => "a(ayuay)",
"ipv6.dns" => "aay",
"ipv6.dns-search" => "as",
"ipv6.route-data" => "aa{sv}",
"ipv6.routes" => "a(ayuayu)"
}
types.each do |dot_prop, type|
section, prop = dot_prop.split "."
settings[section][prop] = ::DBus::Data.make_typed(type, settings[section][prop])
end
end
fix_types(conn_settings)
See https://www.rubydoc.info/gems/ruby-dbus/0.18.1/DBus/Data#make_typed-class_method
"A-Ayu-Ayu!" is my favorite type from now on!
In general, I'd like to improve the library so that you'll be able to specify that a method call (like GetSettings
) should only return DBus::Data
values instead of plain Ruby values. They need unwrapping but are the perfect fit for round-tripping like this.
It works just fine. Having an API to do this kind of type annotation is more than enough for us. Thanks!
(reported by @imobachgs)
We would like to use ruby-dbus to interact with NetworkManager through D-Bus. The following example tries to use the method to
Update
a connection. It basically asks for the current configuration (GetSettings
) an tries to apply the same configuration (callingUpdate
).However, it fails because data types for empty values (empty arrays and hashes) are not what NetworkManager expects. Our guess is that there is no typing information available, so ruby-dbus cannot figure out what to send in such cases.
Even if we do not send any empty attribute (cleaning up the settings), we find an additional problem with
ipv4.address-data
:Are our assumptions right? Do we have a way to workaround this problem?
Thanks!