[Interest] Beginner DBUS Question: how to enforce the XML?

Thiago Macieira thiago.macieira at intel.com
Wed Jun 16 00:21:28 CEST 2021


On Tuesday, 15 June 2021 13:24:12 PDT Jason H wrote:
> So I think the Qt docs and support on DBUS are quite good. But I keep coming
> back to a non-Q- non-G DBUS question: When interfacing with C/CPP code
> using libdbus or sdbus, which manually pack parameters to messages, how is
> "proper" DBUS messaging enforced?

There is no XML when messages are being exchanged. So there's nothing to be 
enforced.

> Example:
> I have a XML Definition for a service I publish, I use tools to generate the
> wrappers for it. Someone using libdbus/sdbus consumes that service. I
> update the XML (say add or remove a parameter), do my workflow, and now
> their client is expecting the wrong parameters.
> 
> Reverse example:
> I consume a DBUS service and they update their libdbus/sdbus code, they
> don't have an XML, how do I identify it before it gets deployed?
> 
> I'm interested in some kind of build-time compilation process check. I'm
> thinking: 
> 1. Force them to publish a XML.
> 2. Generate a header from it
> 3. Force them to have an implementation that consumes the header
> 4. Rely on the compiler to error when the header doesn't match the
> implementation.

Ok, that makes sense.

> However there are two bug flaws with this:
> 1. I'm forcing them to adhere to the development protocol (maybe a makefile
> is sufficiently forceful?) 
> 2. I can't guarantee the functions are actually the ones used (a bigger
> issue I know) 

If they aren't used, why do you care? It's the same as requiring everyone to 
use blue pens: if it's not part of something you see, why do you care?

> 3. Most of the tools generate "ugly bindings"  - that is I can't take:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <node name="/com/example/MyObject">
>   <interface name="com.example.MyObject">
>     <method name="ManyArgs">
>       <arg type="u" name="x" direction="in" />
>       <arg type="s" name="str" direction="in" />
>       <arg type="d" name="trouble" direction="in" />
>       <arg type="d" name="d_ret" direction="out" />
>       <arg type="s" name="str_ret" direction="out" />
>     </method>
>   </interface>
> </node>
> 
> and have it generate:
> 
> void ManyArgs(unsigned int x, std::string str, double trouble, double*
> d_ret, std::string *out);

"s" is always QString and that cannot be changed.

> Has anyone handled this before? How/Are DBUS signals versioned?

They aren't.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Interest mailing list