The class DBusObserver (gb.dbus) enables you to intercept and evaluate every message sent via the D-Bus.
The class DBusObserver has two properties, two methods and an event.
The class DBusObserver has these two properties:
|Enabled||Boolean||The default value is True. This means that a D-Bus Observer is always on when you start a program that uses this class. You can read and set the value.|
|Message||DBusObserver.Message||Message of type.DBusObserver.Message contains the message received from the Observer.|
Table 126.96.36.199.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 metadata except for'Arguments':
|Arguments||Variant||A variant array containing all arguments of a message. It returns NULL if the received message has no arguments.|
|Member||String||Message member (method or signal).|
|Object||String||Path of the message object.|
|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 188.8.131.52.2: Properties of the virtual class .DBusObserver.Message
The class DBusObserver has only these two methods:
|Error ( [ Error As String, Type As String ] )||The response to a message is an error 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 list of permitted error types in the D-Bus documentation.|
|Reply ( [ Signature As String, Arguments As Array ))||Reply to the call of the method message. The following applies to both parameters: Signature is the signature of the response. It should be the identification of the output arguments of the method call. argument is an array of the returned response values.|
Table 184.108.40.206.3: Methods of the class DBusObserver
The class DBusObserver only has the event Message(). 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 with New DBusObserver( parameterliste ):
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. The following applies to the parameters:
To create a new Observer to intercept signals from the object whose object path is specified with /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"