The class DBusVariant (gb.dbus) allows you to define a D-Bus variant value for a given D-Bus signature. The class DBusValues (gb.dbus) inherits from DBusVariant and provides you with a list of several D-Bus values. The two classes each have only the property DBusValues.Value and a constant.
The reason for this is that there are two classes is that this is the only way to make a difference between two methods, for example, one method returns an array of three Variant type values and the other returns three Variant type values, each of which is a Variant type value. In both cases, however, there are exactly three D-Bus values!
For a signature such as “(ia{sv}av)” you will therefore use the class DBusVariant and for a signature such as “u(ia{sv}av)” you will use the class DBusValues.
The class DBusVariant (gb.dbus) allows you to define a D-Bus variant value with a predefined D-Bus signature. In the component gb.dbus.trayicon, for example, a specific signature is defined in the class _DBusMenuItem.class. The class DBusVariant is used because an array of values is returned:
' Gambas class file Export Inherits DBusVariant Public Const Signature As String = "(ia{sv}av)"
Good to know: The class DBusValues (gb.dbus) inherits from DBusVariant and provides you with a list of several D-Bus values.
The class DBusValues is used, for example, in the class _DBusMenuLayout.class of the component gb.dbus.trayicon:
' Gambas class file Export Inherits DBusValues Public Const Signature As String = "u(ia{sv}av)"
Note:Use the table at http://gambaswiki.org/wiki/doc/dbus#t10 to learn how to convert Gambas data types to D-Bus data types and vice versa.
In the following 2 chapters with 4 Gambas projects you will learn how to define D-Bus objects for a data server, export them to the D-Bus and how you can use the services offered with a d-bus-capable client. Complex data types are also used as return values in the methods used.