I am trying to a byte array over D-Bus using the GDBus bindings. Can you please let me know how I can achive that. I tried googling but didnt help.
Byte array contains a image file so cannot be converted to charbytearray
Any help is appriciated
I did some tests using an XML where I used the type ay
. This works well with the QT binding (generated with qdbusxml2cpp
) where it translates into QByteArray
however it seems that it doesn't work with the glib binding (generated with gdbus-codegen
) where it translates in gchar *
and it seems you lose what's after \0
- because somehow it's handled as a string. However you will find that:
This automatic mapping can be turned off by using the annotation org.gtk.GDBus.C.ForceGVariant - if used then a
GVariant
is always exchanged instead of the corresponding native C type. This annotation may be convenient to use when using bytestrings (type-stringay
) for data that could have embedded NUL bytes.
Which means according to https://developer.gnome.org/gio/stable/gdbus-codegen.html that you could handle it as GVariant
. I tested this by adding the tag for annotation org.gtk.GDBus.C.ForceGVariant
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
on each arg and it works.