QDBusObjectBase Class Reference

Base interface for D-Bus service objects. More...

#include <qdbusobject.h>

List of all members.

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

Detailed Description

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

Examples:

example-service.cpp.


Constructor & Destructor Documentation

virtual QDBusObjectBase::~QDBusObjectBase (  )  [inline, virtual]

Destroys the object.


Member Function Documentation

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.

Parameters:
message the method call to delegate
delegate the object which should handle the call instead
Returns:
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.

Parameters:
message the method call to handle
Returns:
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
Examples:
example-service.cpp.

Referenced by delegateMethodCall().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2