Re: [systemd-devel] Reading an "ao" signature message with the sdbus c library?

2017-08-31 Thread Lennart Poettering
On Do, 17.08.17 13:43, James Johnson (jjjwallyh...@gmail.com) wrote:

> Hello,
> 
> Can someone please point me to the correct method for reading an "ao"
> signature dbus message using the sd_bus C api?
> 
> I am trying to read all the network devices with the following call:
> 
>   result = sd_bus_get_property(m_bus, "org.freedesktop.NetworkManager",
>  "/org/freedesktop/NetworkManager",
>  "org.freedesktop.NetworkManager",
>  "AllDevices", ,
>  , "ao");
> I have tried:
> 
> char * ptr;
> size_t size;
> 
> result = sd_bus_message_read_array(msgCall, 'o', , );

_read_array() only works for trivial types, not for strings and
other variable length types. If you have such complex types you need
to enter the array with _enter_container() and then _read() each item
individually...

But I see you already figure that out...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Reading an "ao" signature message with the sdbus c library?

2017-08-17 Thread James Johnson
Hello,


It looks like I figured out my problem, I have to use:

result = sd_bus_message_enter_container(msgCall, 'a', "o");

before I try reading the array with :

result = sd_bus_message_read(msgCall, "o", );

Thanks,
Jimmy

On Thu, Aug 17, 2017 at 1:43 PM, James Johnson 
wrote:

> Hello,
>
> Can someone please point me to the correct method for reading an "ao"
> signature dbus message using the sd_bus C api?
>
> I am trying to read all the network devices with the following call:
>
>   result = sd_bus_get_property(m_bus, "org.freedesktop.NetworkManager",
>  "/org/freedesktop/NetworkManager",
>  "org.freedesktop.NetworkManager",
>  "AllDevices", ,
>  , "ao");
> I have tried:
>
> char * ptr;
> size_t size;
>
> result = sd_bus_message_read_array(msgCall, 'o', , );
>
> as well as:
>
> result = sd_bus_message_read(msgCall, "ao", ptr);
>
> but these both return an error. I am not sure what method to use to parse
> the returned message when it is an array of path objects.
>
> Please note this interface gives me the following when executed via the
> busctl command:
>
> [jjohnson@macbookpro]$ busctl --verbose get-property
> org.freedesktop.NetworkManager /org/freedesktop/NetworkManager
> org.freedesktop.NetworkManager AllDevices
> ARRAY "o" {
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/1";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/3";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/11";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/12";
> };
>
>
> Thanks!
> Jimmy
>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel