D-Bus
From Openmoko
(updated to make the command line example work on FSO milestone 3) |
(fix example) |
||
Line 40: | Line 40: | ||
=== Python === | === Python === | ||
− | To use D-Bus in [[Python]], the package python-dbus needs to be compiled and installed. | + | To use D-Bus in [[Python]], the package python-dbus needs to be compiled and installed. Note that since the interfaces change over time you might want to read the source code of zhone from git.freesmartphone.org to get examples of current API. |
− | + | ||
− | + | ||
To dial a number: | To dial a number: | ||
Line 49: | Line 47: | ||
import dbus | import dbus | ||
bus = dbus.SessionBus() | bus = dbus.SessionBus() | ||
+ | gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") | ||
+ | gsm_call_iface = dbus.Interface(gsm_device_obj,'org.freesmartphone.GSM.Call') | ||
proxy = bus.get_object("org.openmoko.Dialer", "/org/openmoko/Dialer") | proxy = bus.get_object("org.openmoko.Dialer", "/org/openmoko/Dialer") | ||
− | + | gsm_call_iface.Initiate("12345", "voice") | |
− | + | ||
− | + | ||
</pre> | </pre> | ||
− | |||
− | |||
To run the program use the following: | To run the program use the following: |
Revision as of 02:29, 3 December 2008
Openmoko uses D-Bus, a message bus system which provides a simple way for applications to talk to one another and to be available as services in the system. If the application providing the service is not running when a message is sent, the application will be started.
There are two separate busses:
- a system bus for root which runs whenever the phone is on
- a session bus which is started for the user when X starts
Contents |
Session bus services
These can at least be defined in /usr/share/dbus-1.0/services/ and /usr/share/dbus-1/services/
- org.freesmartphone.Phone
- org.gnome.evolution.dataserver.AddressBook
- org.gnome.evolution.dataserver.Calendar
- org.gnome.GConf
- ...
System bus services
There is information about these in /etc/dbus-1/system.d/
- org.freedesktop.Avahi
- org.bluez.*
- ...
Accessing the services
Command line
For simple uses, there's a command mdbus. Try
mdbus -s
to explore the DBus environment.
For example, to dial a number (using FSO milestone 3):
mdbus -s org.freesmartphone.ogsmd /org/freesmartphone/GSM/Device org.freesmartphone.GSM.Call.Initiate '12345' 'voice'
Python
To use D-Bus in Python, the package python-dbus needs to be compiled and installed. Note that since the interfaces change over time you might want to read the source code of zhone from git.freesmartphone.org to get examples of current API.
To dial a number:
#!/usr/bin/env python import dbus bus = dbus.SessionBus() gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") gsm_call_iface = dbus.Interface(gsm_device_obj,'org.freesmartphone.GSM.Call') proxy = bus.get_object("org.openmoko.Dialer", "/org/openmoko/Dialer") gsm_call_iface.Initiate("12345", "voice")
To run the program use the following:
dbus-launch python my_program.py