User Tools

Site Tools


Network and communication


24.9.4 DBusConnection

The class DBusConnection (gb.dbus) represents a connection of a d-bus-capable application to the system D-Bus or to the session D-Bus. You cannot create objects of the class, since the connection always refers to an existing existing connection. Properties

The class DBusConnection has only one useful property:

PropertyData typeDescription
ApplicationsString[ A list is displayed 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 Properties of Class DBusConnection Methods

The class DBusConnection has these two methods:

Register ( Object As DBusObject, Path As String [, Interfaces As String[] ] )Exports a D-Bus object to the D-Bus, from Gambas version 3.9. The following applies to 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 in a string array that have been implemented for the specified D-Bus object to be specified.
Unregister ( Object As DBusObject )Deregisters the D-Bus object specified in the parameter from the D-Bus.

Table Methods of Class DBusConnection Examples

Since the class DBusConnection represents a connection of a d-bus-capable application to the system D bus or to the session D bus, it is always used in conjunction with the class DBusApplication - 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]

In the console of the Gambas IDE all registered applications are displayed sorted on the system D-Bus. Here you see only a small excerpt:



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: 02.07.2018 (external edit)

Page Tools