Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return error to dbus using qt-dbus?

Tags:

qtdbus

I'm using qt-dbus to expose some API from my software.

I convert foo.xml with interface declaration to foo_adaptor.cpp and foo_adaptor.h holding FooAdaptor class via qdbusxml2cpp, then I bind real Foo class to the FooAdaptor by calling new FooAdaptor(this) inside Foo's constructor.

So, it works: Foo metods are called, when I send message via dbus-send to my app.

For specific builds of my software I want to disable some methods. I need somehow to inform the caller, that some method call actually unallowed and does nothing/have no meaning. Is there any function to call/exception to throw to do this?

like image 928
bitfield Avatar asked Nov 19 '25 22:11

bitfield


1 Answers

Error responses can be sent by making your D-Bus object (the one registered with QDBusConnection::registerObject(), not the adaptor) inherit from QDBusContext and then using the sendErrorReply() method:

http://qt-project.org/doc/qt-5.1/qtdbus/qdbuscontext.html

like image 62
mshroyer Avatar answered Nov 23 '25 00:11

mshroyer