Going through the Qt Dbus example code and there isn’t much of an explanation as to how the examples are done. Plus I haven’t found any helpful tutorials about QtDbus. I will make a rough attempt at giving some explanation to the ‘RemoteControllerCar’ example. I using that example because it’s most like what I’ll be doing where the server and client code will be in different programs.
The IDL is car.xml
<node name="/com/trollech/examples/car"> <interface name="com.trolltech.Examples.CarInterface"> <method name="accelerate"/> <method name="decelerate"/> <method name="turnLeft"/> <method name="turnRight"/> <signal name="crashed"/> </interface> </node>
What does this .xml file defining? It defines the interface with funtion names and argument that will be available to call between the two programs.
In this case, there are functions:
In this RemoteControllerCar example the car acts as the server, and the controller is the client.
To compile the xml interface for the car (server):
Server stub (adaptor):
$ qdbusxml2cpp -c CarInterfaceAdaptor -a car_adaptor.h:car_adaptor.cpp car.xml
To compile for the controller (client):
$ qdbusxml2cpp -v -c CarInterface -p car_interface.h:car_interface.cpp car.xml
Important parts in Car:
In main.cpp ln 66-69. That is how you add our D-Bus interface and connect to the D-Bus
Important parts in Controller:
In controller.cpp ln 50-51. This is how to connect to our D-Bus interface.
OK need to cut it short. Got to implement something like this now.