Base interface for D-Bus service objects. More...
#include <qdbusobject.h>
Public Member Functions | |
virtual | ~QDBusObjectBase () |
Destroys the object. | |
Protected Member Functions | |
virtual bool | handleMethodCall (const QDBusMessage &message)=0 |
Method call entry point. | |
bool | delegateMethodCall (const QDBusMessage &message, QDBusObjectBase *delegate) |
Delegate a method call to another object. | |
Friends | |
class | QDBusConnectionPrivate |
Base interface for D-Bus service objects.
In order to register a service object with the QDBusConnection it needs to implement the interface specified by this class.
The connection will forward all method calls that have a path equivalent to the path the service object was registered with to the object's handleMethodCall() method. See QDBusConnection::registerObject()
If for some reason, e.g. the call is not meant for this interface, or the method is unknown, the implementation can just return false
and the connection will handle the rest.
See section Providing services over D-Bus for documentation on how to use QDBusObjectBase
virtual QDBusObjectBase::~QDBusObjectBase | ( | ) | [inline, virtual] |
Destroys the object.
bool QDBusObjectBase::delegateMethodCall | ( | const QDBusMessage & | message, | |
QDBusObjectBase * | delegate | |||
) | [inline, protected] |
Delegate a method call to another object.
When a service object is built as a collection of separated interface class instances, i.e. each interface of the object is implemented in its own QDBusObjectBase subclass and the main object just wanst to pass on the method calls to the respective interface implementations, it can do so by calling this base class method.
Since it is a method of the base class, it can call the otherwise protected handleMethodCall() of the interface implementor.
See Service interfaces for an example.
message | the method call to delegate | |
delegate | the object which should handle the call instead |
true
if the message can be handled independent if handling resulted in an error. In this case implementations should an error reply. Returns false
only if interface or method are unknown References handleMethodCall().
virtual bool QDBusObjectBase::handleMethodCall | ( | const QDBusMessage & | message | ) | [protected, pure virtual] |
Method call entry point.
This method has to be implemented to handle method calls sent to the service object. An object implementation can handle all its interfaces in one class or again forward the method call to interface implementators.
If for some reason, e.g. the call is not meant for this interface, or the method is unknown, the implementation can just return false
and the connection will handle the rest.
If an error occurs during the method call, e.g. the number of parameters or their types are not what would be expected, the service object should reply with a QDBusMessage of type QDBusMessage::ErrorMessage which in turn should include the D-Bus error describing the problem. See QDBusConnection::send() for sending reply messages.
See QDBusMessage::methodError() and QDBusMessage::methodReply() on how to create suitable reply messages for the given method call.
message | the method call to handle |
true
if the message can be handled independent if handling resulted in an error. In this case implementations should an error reply. Returns false
only if interface or method are unknown Referenced by delegateMethodCall().