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.
The DBusObserver class has these two properties:
Property | Data type | Description |
---|---|---|
Enabled | Boolean | The 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. |
Message | DBusObserver.Message | Message of type .DBusObserver.Message contains the message received from the observer. |
Table 24.9.5.0.1 : Properties of the class DBusObserver
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':
Property | Data type | Description |
---|---|---|
Arguments | Variant[ ] | A Variant array containing all arguments of a message. It returns NULL if the received message has no arguments. |
Destination | String | Message destination. |
Interface | String | Message-Interface. |
Member | String | Message Member (Method or Signal). |
Object | String | Path of the message object. |
Sender | String | Message sender. |
Serial | Integer | Message Serial Number. |
Type | Integer | Message 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
The DBusObserver class has only these two methods:
Method | Description |
---|---|
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
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.
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"