DBusGuide

  1. D-bus Guide
    1. Motivation for this WIKI page
    2. D-Bus service file
    3. Maemo platform overall usage of D-bus
      1. Maemo initialization
      2. Remote process messages
      3. Hardware state messages
      4. System Exit messages
    4. D-bus problems and knowns issues related to Maemo
    5. List of good examples for D-bus usage in maemo

D-bus Guide

D-BUS is a message bus system, which is used for applications and libraries to talk to one another. D-BUS supplies both a system daemon and a per-user-login-session daemon (for general IPC needs among user applications). Also, the message bus is built on top of a general one-to-one message passing framework, which can be used by any two applications to communicate directly.

D-BUS is mostly used with assistance functions of LibOSSO library.

|http://www.freedesktop.org/Software/dbus/p>


Motivation for this WIKI page

To provide everyone better information about the usage of D-bus in the maemo platform, it would be valuable information to gather and document the different services/interfaces available to one document. This could work as a nice guideline for developers on what to prepare for in their applications and what they can use.

Important items

  • listing all the services available
  • listing the interfaces available
  • Building a comprehensive document that provides the necessary information to developer applications, that use the D-bus architecture in the best possible way.

We hope filling this document would be done in collabration with the open source developers and the people working on maemo inside Nokia.


D-Bus service file

D-BUS service file is needed to be able to launch the maemo application and connect it to D-BUS services. One special feature of D-BUS is that if application is not running already when D-BUS message is sent to it, D-BUS will start the application automatically. Also only one instance of a D-BUS service is running at the same time which guarantees that each application is running only once.

The format of the service file is simpler than desktop file, below is what “example_libosso.service” looks like.

[D-BUS Service]
Name=org.maemo.example_libosso
Exec=/usr/bin/example_libosso

The fields in this file are:

  • Name – The D-BUS service name. This needs to be unique and same which is used in application source codes when initializing application. Usually name is build with application provider URL following the application name to minimize the possibility for conflicts with other service files.

  • Exec – The full path of application binary to launch when service name gets called.

D-BUS service file is installed in “/usr/share/dbus-1.0/services/” and maemo GUI needs to be restarted with “af-sb-init.sh restart” before D-BUS daemon recognizes it.


Maemo platform overall usage of D-bus

  • System notifications (e.g. “Battery low”). Every application can receive these events and proceed accordingly.
  • For separating applications UI and engine, for example this way email engine can be used from different applications.
  • For launching the applications from task navigator. D-BUS is used to be able launch each application only once, and application can receive different messages from task navigator to e.g. save its state.

Maemo initialization

All maemo applications need to be initialized correctly or they will not work as expected. One symptom of missing initialization is that application starts from Task Navigator but closes automatically after few seconds.

Initializing application is done with osso_initialize() function. With this function application connects to D-BUS session bus and system bus. osso_initialize() function should only be called once in the application, and the structure of type osso_context_t type it returns should be stored for later usage.

Remote process messages

System wide messages in maemo platform are handled with D-BUS system messaging which is a Remote Process Communication (RPC) method. LibOSSO has own wrappers to normal D-BUS functions to make usage simpler and to maintain backward compatibility. By using D-BUS applications can send messages from one process to another.

Hardware state messages

Maemo applications can connect to listen the system D-BUS messages like “battery low” and “shutdown”.

System Exit messages

There is a separate system message apart from the hardware state messages which comes when the applications are required to close themselves.


D-bus problems and knowns issues related to Maemo

If any....


List of good examples for D-bus usage in maemo