add dbus connection
About you
CamiTK dev
Product
CamiTK Core / Application
Overview
Issue #168 (closed) was not detected during configure/make/test as it is not possible to set a test where an application that starts a user interaction loop would be run and stopped automatically after a while. For example, in the case of camitk-fancy
that would have allowed for a simple start and exit. In the presence of a bug similar to #168 (closed), the test would then have failed.
A possible way of offering extended testing for application would be to add the possibility for any CamiTK application to listen to dbus messages.
- it would then be possible to send message from outside the application (e.g. a shell, a test script or program...) such as "run action
Quit
". - it would also add the great advantage of opening a whole lot of testing and automation. For instance by sending message analog to state in the action state machine (e.g. by sending XML/json message containing the action to apply and its parameter).
Relevant logs and/or screenshots
Adding dbus message support in CamiTK::Application
For instance by using:
QDBusConnection::sessionBus().connect(QString(), QString(), "camitk.action", "apply", this, SLOT(applyActionFromDBus(QString)));
...
void Application::applyActionFromDBus(const QString &message) {
if(message=="...") {
...
}
}
From the test application
QProcess myProcess;
myProcess.start("camitk-fancy", "");
if (!myProcess.waitForStarted())
return false;
QDBusMessage msg = QDBusMessage::createSignal("/", "camitk.action", "apply");
message="Quit"
QDBusConnection::sessionBus().send(msg);
if (!myProcess.waitForFinished())
return false;
Note
DBus is supported on Linux desktops by default. A windows port exists but this need further checks.
dbus not allowed by default
For security reason, the default behaviour should be not to listen to DBus, and flag --dbus
should be added to the arguments to enable the feature in the application.
See also
KDE doc for creating dbus interface