Table of Contents

24.9.5.0 DBusObserver

The DBusObserver (gb.dbus) class allows you to intercept and evaluate any message sent over the D-Bus.
The class DBusObserver has two properties, two methods and one event.

24.9.5.0.1 Properties

The DBusObserver class has these two properties:

PropertyData typeDescription
EnabledBooleanThe default value is True. This means that a D-Bus observer is always enabled when you start a programme that uses this class. You can read the value as well as set it.
MessageDBusObserver.MessageMessage of type .DBusObserver.Message contains the message received from the observer.

Table 24.9.5.0.1 : Properties of the class DBusObserver

24.9.5.0.2 Properties of class .DBusObserver.Message

The virtual class .DbusObserver.Message, which cannot be created, represents a message received from the DBusObserver object. It has the following properties, which can only be read out and are to be understood as meta data except for 'Arguments':

PropertyData typeDescription
ArgumentsVariant[ ]A Variant array containing all arguments of a message. It returns NULL if the received message has no arguments.
DestinationStringMessage destination.
InterfaceStringMessage-Interface.
MemberStringMessage Member (Method or Signal).
ObjectStringPath of the message object.
SenderStringMessage sender.
SerialIntegerMessage Serial Number.
TypeIntegerMessage type, which can take one of the following values - represented by one of the following constants: DBus.Method (1), DBus.Reply (2), DBus.Error (3) or DBus.Signal (4).

Table 24.9.5.0.2 : Properties of the virtual class .DBusObserver.Message

24.9.5.0.3 Methods

The DBusObserver class has only these two methods:

MethodDescription
Error ( [ Error As String, Type As String ] )An error message is issued in response to a message. The following applies to both parameters: Error is the error message. Type is the error type. By default it is “org.freedesktop.DBus.Error.Failed”. See the D-Bus documentation for the list of allowed error types.
Reply ( [ Signature As String, Arguments As Array ] ) Reply to the call of the method message. For the two parameters: Signature is the signature of the reply. It should be the identification of the output arguments of the method call. Arguments is an array of the returned response values.

Table 24.9.5.0.3 : Methods of the class DBusObserver

24.9.5.0.4 Event

The DBusObserver class has only the Message() event. This event is triggered when the DBus-Observer receives a message from a specific object. The received message is stored in the Message property of type .DBusObserver.Message.

You can create this class. You should use this class if you need additional information - such as the meta-data mentioned above - about the observed messages. Otherwise use the class DBusSignal.

24.9.5.0.5 Create DBusObserver

The following example shows you how to formally create a new DBus-Observer using New DBusObserver( parameterlist ):

Dim hDBusObserver As DBusObserver

hDBusObserver = New DBusObserver ( Connection As DBusConnection, Type As Integer
[ , Object As String, Member As String, Interface As String, Destination As String ] ) As "ObserverEventName"

The above source code creates a new D-Bus observer to intercept messages on the specified DBus. For the parameters:

To create a new observer to intercept signals from the object whose object path is specified as /org/gtk/Private/RemoteVolumeMonitor:

Dim hDBusObserver As DBusObserver

hDBusObserver = New DBusObserver(DBus.Session, DBus.Signal, "/org/gtk/Private/RemoteVolumeMonitor",
"VolumeAdded", "org.gtk.Private.RemoteVolumeMonitor", "*") As "hDBusObserver"