The class DBusApplication (gb.dbus) represents an application that is registered on the D-Bus. You can create this class. It behaves like Array, which you can only read.
The DBusApplication class has the following properties:
Property | Data type | Description |
---|---|---|
Connection | DBusConnection | Object of type DBusConnection 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 24.9.3.1.1 : Properties of the class DBusApplication
The DBusApplication class has these three methods:
Method | Description |
---|---|
Register ( Object As DBusObject, Path As String [ , Interfaces As String[] ] ) | Registers a D-Bus object to the D-Bus - since Gambas 3.9. For the parameters: Object is the D-Bus object to register, 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 ) | Unregisters the D-Bus object named in the parameter from the D-Bus. |
Raise ( Object As DBusObject, Signal As String [ , Arguments As Variant[] ] ) |
Table 24.9.3.2.1 : Methods of the class DBusApplication
Use New DBusApplication(parameter list) to create a DBusApplication object:
Dim hDBusApplication As DBusApplication hDBusApplication = New DBusApplication ( Connection As DBusConnection, ApplicationName As String )
The object created represents an application connected to the session bus or the system bus. For the two parameters:
In the same way, you can alternatively use DBus[ ApplicationName ] as an array.
The DBusApplication class behaves like a read-only array. The following two source texts make use of this fact - the first only formally:
Dim hDBusApplication As DBusApplication Dim hDBusProxy As DBusProxy hDBusProxy = hDBusApplication [ ObjectPath As String [ , Interface As String ] ]
Returned with hDBusProxy is a proxy to an (existing) D-Bus object specified in the first parameter.
If the argument for the optional parameter Interface is not given, you have access to every 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, creating an interface on the side of the application that exports the object to the D-Bus is always advantageous.