User Tools

Site Tools


Sidebar

Network and communication

k24:k24.9:k24.9.3:start

24.9.3 DBusApplication

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.

24.9.3.1 Properties

The DBusApplication class has the following properties:

PropertyData typeDescription
ConnectionDBusConnectionObject of type DBusConnection whose application is connected to the D-Bus.
IndexIntegerIndex in the (internal) application cache.
NameStringName of the application on the D-Bus (DBus.Name).

Table 24.9.3.1.1 : Properties of the class DBusApplication

24.9.3.2 Methods

The DBusApplication class has these three methods:

MethodDescription
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

24.9.3.3 Example 1 - New 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:

  • Connection is a D-Bus Connection object (DBus.Session or DBus.System).
  • ApplicationName is the name of the application on the D-Bus.

In the same way, you can alternatively use DBus[ ApplicationName ] as an array.

24.9.3.4 Example 2 - DBusApplication[ ]

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.

  • ObjectPath is the D-Bus path to the object.
  • Interface is the interface of the object you want to use.

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.

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.3/start.txt · Last modified: 16.08.2022 (external edit)

Page Tools