[Interest] Beginner DBUS Question: how to enforce the XML?
jhihn at gmx.com
Tue Jun 15 22:24:12 CEST 2021
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?
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.
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.
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)
3. Most of the tools generate "ugly bindings" - that is I can't take:
<?xml version="1.0" encoding="UTF-8" ?>
<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" />
and have it generate:
void ManyArgs(unsigned int x, std::string str, double trouble, double* d_ret, std::string *out);
for which they provide a matching implementation for. But most of the tools generate accurate and correct code.
An alternative approach would be to proxy the commands against the XML, so make sure every message sent/received conforms to it. I don't know if there is software to enable this?
Has anyone handled this before? How/Are DBUS signals versioned?
Many thanks for any insights.
More information about the Interest