D-Bus in MID
Article |
Discussion |
View source |
History |
From MIDWiki
Author : Loc Nguyen
D-Bus
D-Bus is a fast, lightweight message bus system which allows applications to communicate with each other (Inter-process communication). It has a so called D-Bus message bus (dbus deamon) which can accept messages from multiple applications and forward messages to them. D-Bus can be used as low-level API or higher level binding, such as Qt, Python, Java, C#, Perl.
D-Bus was first developed by Red Hat and can be included in the Moblin stack.
There are 2 buses defined:
- system bus - allows communication between an application and the operating system
- session bus - is design to serve the communication between two applications
D-Bus Concepts
In order to use D-Bus, we need to explore some concepts about D-Bus.
- First, an object is an endpoint on the bus, an object is created by an application in the context that the application’s connection to the bus (either system bus or session bus).
- Objects have names, and these names are called object paths.
- A proxy is an object on the bus that can be accessed through references.
- We can find an object by searching the bus name and the object living in that bus connection. Once we find it, we usually keep a proxy to that object so we can refer to that object again without searching it again.
- An object can perform some specific operations, each operation is referred as a method. Thus, a client can send a request to an object and asks the object to invoke a method. The object then invokes the method (if the method exists) and the result is sent back to the client. If a method requires input parameters, these parameters have to be passed with the request. The result can be one or more output parameters, these parameters are sent back to the client in the reply message.
- An object can also emit an event, or signal. A signal is generated by an object which will be broadcasted to any observers who are interested in that particular signal. Signals can carry parameters too. Methods and Signals are instead members of an object. They can be grouped. Interface of an object is just a group of its members. An object can declare one or many interfaces, its members are then classified in these interfaces.
- Instead of forming a D-Bus method call message and send to the remote object, using Glib bindings one can instantiate a proxy object representing the remote object and then just call the method of that object.
D-Bus has been adapted by many applications, including a recently the Platform Awareness Service(http://softwarewiki.intel.com/mid/Platform_Service_Awareness) developed for MID.
References
D-Bus, http://www.freedesktop.org/wiki/Software/dbus
D-Bus Tutorial, http://dbus.freedesktop.org/doc/dbus-tutorial.html
http://www.moblin.org/toolkits/basicDevGuides/mobLinux/toolkits_DevGds_mobLinux_createDBUS.php
Mobile and Internet Linux Project, http://moblin.org/