-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variant of Map #74
Comments
Have you also tried to use DBusMap (org.freedesktop.dbus.DBusMap<K, V>)? |
When I try to wrap a DBusMap in a Variant the following exceptions is thrown:
Another approach could be to use the DBusMap in the method call as
Are there other options? Should we prepare a test case for this problem? |
A test case would be great. |
@hypfvieh , could you please tell me if there are any updates on this issue? I am experiencing the same problem. Seems that there is a problem to set map argument. An example of the code can be as simple as getting config map and setting it back:
Do you have any idea of what could go wrong? |
Please provide full sample code which does not rely on any system service which might not be available on any system (or is access restricted like in my case). I added a unit test ( |
I think I just found a sample code which correspond to this issue:
Doing this results following exception (with version 3.3.1):
I also tried a DBusMap with the same result:
|
This issue cannot be fixed, as it is caused by type erasure in Java. |
Thank you for this clarification. Do you have any workaround suggestions in order to manage properties with dictionary values (like maps in Java) ? |
I don't know any application which uses Maps as value in properties when it comes to DBus. If you need to provide data organized in Maps you should create a method in you DBusInterface extending interface (like |
Thanks for your suggestions, I'll look into it. |
Good day! In my case there is the issue with setting P2P settings for WiFi interface. While your Wi-Fi chip supports P2P connections (and nowadays most of them support this functionality) you will have available P2PDevice under your wpa_supplicant DBus path. Here is the example: Under the hood it contains property called "P2PDeviceConfig - a{sv} - (read/write)" which I'm not able to set due to the same issue. Thanks in advance! |
First of all, always provide sample code, otherwise it is not clear what you are trying to do. As far as I can see in the wpa-supplicant documentation, the properties do not contain a map. The properties are None of the keys are defined to require a Map as value.
No generics used here. |
Hello there @hypfvieh 👋 First and foremost: thank you for building this project :) I think I am in the same situation as the other guys in this thread: I'm currently trying to set the IP address through NetworkManager's DBus API. To do so I'm following the examples provided in the NetworkManager repo in particular the Python one because the principle is the same even if the language is different. The procedure requires to call the Therefore we incur in the situation described here. Is this correct? A little further above in this thread you propose the following alternatives to work around this limitation:
Can you elaborate a little bit further on these two options? @josephguinet can you share some details on your solution? |
Hello again everyone, in the end I was able to solve the issue on my own by leveraging the In my case this meant: Map<String, Variant<?>> address = new HashMap<>();
address.put("address", new Variant<String>("192.168.1.224"));
address.put("prefix", new Variant<UInt32>(new UInt32(24)));
List<Map<String, Variant<?>>> addressData = Arrays.asList(address);
Variant<?> addressDataVariant = new Variant<>(addressData, "aa{sv}");
ipv4Map.put("address-data", addressDataVariant); Similarly for @josephguinet the code should become: HashMap<String, String> map = new HashMap<>();
Map<String, Variant<?>> variantMap = new HashMap<>();
variantMap.put("key", new Variant<Map<String, String>>(map, "a{ss}")); @hypfvieh is this correct? Do you find any issue in this approach? |
I think this is the way it can be done. As stated previously, you are pretty out of luck trying to create a proper DBus signature when generics come into play. It would be great if you could provide a simple example of this so I can add it to the examples project. |
Great to hear. Thanks for the feedback.
I'm really busy these days but I'll try my best :) |
How can I express this ( a{sv} as parameter to a Method) with the spring expression language that is used in the FX-GUI? Example: UDisks2 In d-feet (the python programm) you enter something like this, nowakeuo is a standardoption or an empty Set here for SmartGetAttributes() works too: In both cases you get a return value. How do you express this with the spring expression language? |
Sorry no idea. I don't use spring in any project so I'm not familiar it (and I don't like to have black magic in my projects). |
Oops wrong page. dj-feet belongs to another person. |
First off: thanks for this great piece of work and the improvements coming in during the last couples of month. We're now using version 3.2.0.
I'm currently working on a java facade for connman (and ofono) and I'm facing the following issue:
The API for DBus interface
net.connman.Service
is described here https://github.com/aldebaran/connman/blob/master/doc/service-api.txtThe interface has a method
SetProperty(string name, variant value)
. I want to pass a new IPv4.Configuration. The internal type of that value isdict
, that should be defined in aMap<String, Variant<?>
. By contract I need to define a Variant likenew Variant(map)
to pass it to the call ofSetProperty
. Doing this results in an exception with the following message:How would you solve this?
The text was updated successfully, but these errors were encountered: