The class DBusApplication (gb.dbus) represents an application registered on the D-Bus. You can create this class. It behaves like an array that you can only read.
The class DBusApplication has the following properties:
|Connection||DBusConnection||DBusConnection type object whose application is connected to the D-Bus.|
|Index||Integer||Index in the (internal) application cache.|
|Name||String||Name of the application on the D-Bus (DBus.name).|
Table 126.96.36.199.1: Properties of Class DBusApplication
The class DBusApplication has these three methods:
|Register ( Object As DBusObject, Path As String [, Interfaces As String ] )||Registers a D-Bus object on the D-Bus - since Gambas 3.9. The following applies to the parameters: Object is the D-Bus object to be registered, Path is the D-Bus path for the D-Bus object and Interface (optional) allows the names of additional interfaces to be specified if they exist for the D-Bus object used.|
|Unregister ( Object As DBusObject )||Deregisters the D-Bus object specified in the parameter from the D-Bus.|
|Raise ( Object As DBusObject, Signal As String [ , Arguments As Variant ))||Triggers a D-Bus signal. For the parameters: Object is the D-Bus object that transmits the signal, Signal is the name of the transmitted signal and Argument (optional) represents the arguments of the signal of data type Variant Array.|
Table 188.8.131.52.1: Methods of Class DBusApplication
With New DBusApplication(parameter list) you can create a DBusApplication object:
Dim hDBusApplication As DBusApplication hDBusApplication = New DBusApplication ( Connection As DBusConnection, ApplicationName As String )
The created object represents an application that is connected to the session bus or the system bus. The following applies to both parameters:
Alternatively, you can also use DBus[ ApplicationName ] as an array.
The class DBusApplication behaves like a read-only array. The following two source texts use this fact - the first only formally:
Dim hDBusApplication As DBusApplication Dim hDBusProxy As DBusProxy hDBusProxy = hDBusApplication [ ObjectPath As String [ , Interface As String ] ]
hDBusProxy returns a proxy to an (existing) D-Bus object specified in the first parameter.
If the argument for the optional parameter Interface is not specified, you have access to each method and all properties of the (exported) object. Otherwise, you only have access to methods and properties of the specified interface - as in the following example:
Dim hDBusApplication As DBusApplication Dim hDBusProxy As DBusProxy Dim sDBusName, sDBusObjectPath, sDBusInterface As String Dim hConnection As DBusConnection hConnection = DBus.Session sDBusName = "org.freedesktop.Notifications" sDBusObjectPath = "/org/freedesktop/Notifications" sDBusInterface = "org.freedesktop.Notifications" hDBusApplication = New DBusApplication(hConnection, sDBusName) hDBusProxy = New DBusProxy(hDBusApplication, sDBusObjectPath, sDBusInterface)
In terms of good data encapsulation, the generation of an interface on the side of the application that exports the object to the D-Bus is always an advantage.