[Gambas-user] Support for DBus in Gambas 3
gambas at ...1...
Mon Jul 19 15:53:09 CEST 2010
The DBus system is now (almost) fully supported in Gambas 3, by the gb.dbus
What is DBus ? It is a "message bus system", i.e. a little program that can
pass different kinds of messages between applications. It's like the old KDE 3
DCOP system. For more information, see http://dbus.freedesktop.org.
There are normally two kind of bus running on your machine: the "system bus",
that is global and unique, and the "session bus", that is launched for each
gb.dbus allows you to:
(1) Call any method or property exported by any application that is connected
with the bus.
[0, 24, 1024, 768]
The syntax is:
- DBus[<Application>][<Object path>].<Method>(<Arguments>)
- DBus[<Application>][<Object path>].<Property>
<Application> can begin with "system://" or "session://" to define which bus
you want to connect with. By default you connect with the session bus.
(2) Catch any signal raised by any interface.
MySignal = New DBusSignal(DBus.System, "org.freedesktop.Hal.Manager",
"DeviceAdded") As "DBusSignal"
Public Sub DBusSignal_Signal(Signal As String, Arguments As Variant)
(3) Export any Gambas object to DBus, provided that the object inherits
Dim hObject As MyClass ' MyClass inherits DBusObject
The Gambas object is attached to an "object path", because all objects exposed
to the DBus by your application is like a hierarchical file system.
What is exported?
- Public methods whose name has no underscore inside, and whose arguments and
return type can be converted to a DBus datatype.
- Public properties whose name has no underscore inside, and whose type can be
converted to a DBus datatype.
As soon as you register at least one object, your application appears on the
bus with the name "org.gambas.<application name>".
All these methods and properties are exported with an interface name named
"org.gambas.<application name>.<class name>".
You can test that with the DBus explorer example, or the qdbusviewer Qt4
What is not done yet ?
- You cannot raise DBus signals yet.
- You cannot use Collections yet.
Note that the gb.dbus component has a part written in C and a part written in
Gambas. The part written in C provide hidden classes (whose name begins with
"_") that the part written in Gambas uses to provided the full (and easy!)
Now just play with it and tell me what you think!
More information about the User