3

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?

bitfield
  • 83
  • 5

1 Answers1

1

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

mshroyer
  • 1,928
  • 17
  • 14
  • It should be noted this largely defeats the purpose of adaptors. The object being exported now knows about D-Bus. – Logan Aug 30 '23 at 21:01