The class DBusConnection (gb.dbus) represents a connection of a d-bus-enabled application to the system D-bus or to the session D-bus. You cannot create objects of the class because the connection always refers to an already existing connection.
The DBusConnection class has only one usable property:
Property | Data type | Description |
---|---|---|
Applications | String[ ] | A list is output with the D-Bus names of the applications registered on the D-Bus. |
Tag | Variant | Note: The property cannot be used because it is already used within the component gb.dbus! |
Table 24.9.4.1.1 : Properties of the class DBusConnection
The DBusConnection class has these two methods:
Method | Description |
---|---|
Register ( Object As DBusObject, Path As String [ , Interfaces As String[] ] ) | Exports a D-Bus object to the D-Bus, as of Gambas version 3.9. For the parameters: Object is the D-Bus object to be exported, Path is the D-Bus path for the D-Bus object and Interface (optional) allows the names of additional interfaces implemented for the specified D-Bus object to be specified in a string array. |
Unregister ( Object As DBusObject ) | Unregisters the D-Bus object named in the parameter from the D-Bus. |
Table 24.9.4.2.1 : Methods of the class DBusConnection
Since the DBusConnection class represents a connection of a d-bus-enabled application to the system D-bus or to the session D-bus, it is always used in conjunction with the DBusApplication class - as in the following example:
Dim hDBusApplication As DBusApplication Dim hConnection As DBusConnection Dim sDBusName As String sDBusName = "org.freedesktop.NetworkManager" hConnection = DBus.System hDBusApplication = New DBusApplication(hConnection, sDBusName)
The following source code uses the Applications property to display the applications registered on the System D bus:
Private Sub GetDBusSsystemApplications2() Dim i As Integer Dim aSessionList As String[] Dim hConnection As DBusConnection hConnection = DBus.System aSessionList = hConnection.Applications.Sort(gb.Descent) For i = 0 To aSessionList.Max Print aSessionList[i] Next End
In the console of the Gambas IDE, all registered applications on the system D-bus are output sorted. Here you can only see a small section:
org.freedesktop.thermald org.freedesktop.systemd1 org.freedesktop.login1 org.freedesktop.UPower org.freedesktop.UDisks2 org.freedesktop.RealtimeKit1 org.freedesktop.PolicyKit1 org.freedesktop.NetworkManager.dnsmasq org.freedesktop.NetworkManager org.freedesktop.ModemManager1 ... :1.9 :1.84 ... :1.20 :1.16 :1.1 :1.0