User Tools

Site Tools


Sidebar

Network and communication

k24:k24.9:k24.9.4:start

24.9.4 DBusConnection

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.

24.9.4.1 Properties

The DBusConnection class has only one usable property:

PropertyData typeDescription
ApplicationsString[ ]A list is output with the D-Bus names of the applications registered on the D-Bus.
TagVariantNote: 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

24.9.4.2 Methods

The DBusConnection class has these two methods:

MethodDescription
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

24.9.4.3 Examples

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
The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k24/k24.9/k24.9.4/start.txt · Last modified: 16.08.2022 (external edit)

Page Tools