The class DBus (gb.dbus) manages the connection of an application to the session bus or system bus and inherits _DBus from the virtual class.
The class DBus has the following six properties:
|Debug||Boolean||Is True when debugging messages are output after DBus.debug = True or sets the boolean value.|
|Name||String||The name of the D-Bus application is set or returned. By default, the D-Bus name has the following syntax: org.gambas. <xxx>, where <xxx> is the value of the Application.name property. Note: The D-Bus name is automatically normalized and adapted to the D-Bus specification.|
|Null||Object||A special object is returned that represents the D-Bus value NULL.|
|Session||DBusConnection||Indicates the connection between an application and the session bus of type DBusConnection.|
|System||DBusConnection||Indicates the connection between an application and the system bus of type DBusConnection.|
|Unique||Boolean||Is True if an application is registered on the D-Bus with a unique ID or sets the Unique property. Please note the following information.|
Table 126.96.36.199.1: Properties of Class DBus
Notes on the DBus.Unique property:
If you set the DBus.Unique property to True, the name of the application is
sDBusApplicationName = org.gambas.projektname
For the alternative case DBus.Unique = False (this is the default value), however, this becomes
sDBusApplicationName = org.gambas.projektname-PID ' PID = Process Identification Number
Since it is not necessarily known what the current value DBus.Unique is for a D-Bus server to be used, for example, you can use the following function in the source code for a D-Bus client to determine the correct name of the server on the D-Bus:
The class DBus has four methods, which are specified and described in the following table:
|IsRegistered ( Object As DBusObject )||The boolean function returns True if the object passed as parameter is registered on the D-Bus.|
|Register ( Object As DBusObject, Path As String [, Interfaces As String ] )||Exports a DBus object to the D-Bus. 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 implemented for the D-Bus object used to be specified. Details can be found in the documentation under DBusConnection.Register().|
|Unregister ( Object As DBusObject )||Deregisters the DBus object passed in the parameter from the D-Bus and is the equivalent of DBus.Session.Unregister().|
|Raise ( Object As DBusObject, Signal As String [ , Arguments As Variant ))||Triggers a D-Bus signal. For the parameters: Object is the object that transmits the signal, Signal is the name of the transmitted signal and Argument represents the (optional) arguments of the signal in a variant array.|
Table 188.8.131.52.1: Methods of Class DBus
To determine whether a particular application is currently registered on the D-Bus, you can use the following source code when you modify the application name:
If DBus.Session.Applications.Exist($sDBusName) Then
If necessary, you can log off the objects exported by your Gambas program from the D-Bus:
Public Sub Form_Close() If DBus.IsRegistered($hDBusObject) Then DBus.Session.Unregister($hDBusObject) FMain.Close() End
The answer to the question'What is exported to the D-Bus' depends on whether you use the optional argument Interfaces As String in the register method or not.
Registration without interfaces:
As soon as you export at least one object, your application will be installed on the D-Bus under the name org.gambas. Application Name > registered. You can always use the Application.name property for <Application name>.
All methods and properties whose name begins with an interface name specified in the interface argument - where the dots are replaced by underscores and followed by an additional underscore - are exported under this interface.
Registration with at least one interface:
In chapters 184.108.40.206 and 220.127.116.11 you will find two (server) projects that export objects to the D-Bus.
The following four constants of the class DBus each represent a message type that can take one of the following integer values:
It is started with DBus[…] returns an object representing an application connected to the D-Bus, because the class DBus is static and behaves like a (read-only) array:
Dim hDBusApplication As DBusApplication hDBusApplication = DBus [ Application As String ]
The default value for the prefix of the Application argument is“session://”.
Dim hDBusApplication As DBusApplication Dim hConnection As DBusConnection hConnection = DBus.System hDBusApplication = DBus["system://org.freedesktop.ConsoleKit"]
Dim hDBusApplication As DBusApplication hDBusApplication = DBus["session://org.Cinnamon.LookingGlass"] oder hDBusApplication = DBus["org.Cinnamon.LookingGlass"] Standard-Parameter 'session:\\' intern gesetzt