QtDBus com::blah::test Interface fails to receive dbus-send signals and unittest signals
-
wrote on 16 Jul 2019, 07:34 last edited by sayo9394
I already posed the question on Stackoverflow and can be found here:
https://stackoverflow.com/questions/57050454/qtdbus-not-receiving-signals-from-dbus-send-when-using-qt-dbus-xml-interfaceSystem information:
QT5.10
Ubuntu 16.04I'm fairly new to QT development, and for the past few weeks have been successfully developing a QtDBus application structured around DBus signals only, with unittest and BDD test (python scripts + dbus-send) and all has been going well.
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="com.blah.XYZ"> <signal name="Event"> <arg name="event_json" type="s" direction="out"/> </signal> <method name="AuthenticateUser"> <arg name="auth_req_json" type="s" direction="in"/> <arg name="result" type="s" direction="out"/> </method> </interface> </node>
Now that I wanted to add dbus method calls, I found that I'm unable to make those calls through the Qt interface created from the xml. Then I realised this whole time I was creating the interface with empty strings for the service name, and path. I was following the DBUS Chat example that creates interface same way i'm doing below.
#include "xyz_interface.hxx" com::blah::Xyz interface = new com::blah::Xyz(QString(), QString(), QDBusConnection::systemBus(), this); connect(interface , &com::blah::Xyz::Event, this, &SomeClass::HandleEvents)
unit test as such worked in triggering HandleEvents function;
QDBusMessage xyz_signal = QDBusMessage::createSignal( "/com/blah/XYZ", "com.blah.XYZ", "Event"); xyz_signal << "hello"; ASSERT_TRUE(connection.send(xyz_signal ));
this dbus-send command worked in triggering HandleEvents function
dbus-send --system --type=signal /com/blah/XYZ com.blah.XYZ.Event string:"hello"
The way I confirmed that I'm unable to call methods, I created a python test dbus service that printed hello when the method call to it was successful. Using d-feet I was able to call the python method, but not able to do so from my QT code.
When I created the interface using actual name and path as such;
com::blah::XYZ interface = new com::blah::XYZ("com.blah.XYZ", "/com/blah/XYZ", QDBusConnection::systemBus(), this);
Then I was able to call the interface method interface->AuthenticateUser(str) from the python dbus service, but now i'm unable to receive any signals sent by dbus-send or the unit test code is failing.
pls help!
Cheers,
Simon
1/1