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-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.

24.9.4.1 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 24.9.4.1.1: Properties of Class DBusConnection

24.9.4.2 Methods

The class DBusConnection has these two methods:

MethodDescription
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 24.9.4.2.1: Methods of Class DBusConnection

24.9.4.3 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]
  Next
 
End

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:

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

Download

This website uses cookies. By using the website, you agree with storing the cookies on your computer. More information in the privacy policy.
k24/k24.9/k24.9.4/start.txt · Last modified: 02.07.2018 (external edit)

Page Tools