Dbus-switchboard for Maemo : Online Info

Latest version v1.1.4  (5/29/08)  Added more associations to apps registry. 

Dbus-switchboard is a utility which allows association of programs like mplayer, transmission, and any non-hildonized app which accepts parameters over the command line.

Normally, the File Manager and web browser can only launch hildonized programs, passing parameters over dbus messaging. This program intercepts those messages for certain mime types (file types) and passes them over the command-line to programs which were not coded for dbus (like mplayer and transmission).

You will still need to edit system files (as root), but it should be fairly clear what you need to edit (read further down). This program basically makes this process 'as easy as it should have been in the first place' :/

Parameter handling is inconsistent among the maemo apps available. Some only accept dbus parameters, some only accept command line parameters, some accept both dbus and command line parameters, and some accept neither.

So for the popular choices i will keep it configured with 'known/working' command line applications.

If you attempt to associate an application i haven't configured it for, it may or may not work or require specially forming the command line setting in dbus-switchboard config files before it will accept it. Experiment launching files yourself from xterm to get the command line right.

Ok since dbus-switchboard is sort of an 'intermediary' or broker, it is configured in two ways but the most important 'side' of configuration is to 'hook it up' to the operating system.

Hookup to OS :
dbus-switchboard comes preloaded with capability to handle various mplayer video types/streams, torrents, pdfs (evince), comix (cbr). If all you wanted to do was utiliize those file types then you would probably just need to edit (as root) the :
/usr/share/application/defaults.list

file, and set the relevant mimetypes to =hildon-dbus-switchboard.desktop

Examples (just add the items you want to use to the bottom of the /usr/share/applications/defaults.list file) :
CCode:
#dbus-switchboard reassignments
video/x-msvideo=hildon-dbus-switchboard.desktop
video/avi=hildon-dbus-switchboard.desktop
video/mpeg=hildon-dbus-switchboard.desktop
audio/mid=hildon-dbus-switchboard.desktop
application/x-bittorrent=hildon-dbus-switchboard.desktop
application/pdf=hildon-dbus-switchboard.desktop
application/octet-stream=hildon-dbus-switchboard.desktop
Note that after editing the defaults.list you might have to reboot or run (as root in xterm) before your association changes are effected :
update-mime-database /usr/share/mime

Some files which were previously unknown in maemo (like torrents), when saved lose their mime-types, in which case they are known as the generic 'application/octet-stream' and dbus-switchboard.

Also some web links like mms:// streams can be routed to dbus-switchboard, but the important setting to change for those 'uri/protocol' type handlers is in a different file :br /> /usr/share/applications/uri-action-defaults.list

So for mms: example edit the line beginning with mms= to read :
mms=hildon-dbus-switchboard.desktop

(Users who only care about the apps already supported can stop reading here)

HOOKING UP TO YOUR APP(S) :
Once dbus-switchboard has been registered as the handler for specific types, it relies on its own configuration files to determine which program to route to and how to form the command-line.

Currently this is done with two files in your /home/user directory... one is a list of all the apps it knows how to launch, and the other is a xref file which allows you to route file types to one of those known applications.

Apps list is /home/user/.dbus-switch-apps.cfg and currently looks like :
Code:
MPlayer,cli,/usr/bin/mplayer %params%
MPlayer-playlist,cli,/usr/bin/mplayer -playlist %params%
Transmission,cli,/usr/lib/transmission/transmission %params%
Evince,cli,evince %params%
Comix,cli,comix %params%
Mono,cli,mono %params%
BrontideTel,cli,call.sh %params%
The xref file is /home/user/.dbus-switch-xref.cfg and currently looks like (file ext, appname, protocol) :
Code:
.torrent,Transmission,
.avi,MPlayer,
.wmv,MPlayer,
.mp4,MPlayer,
.mpeg,MPlayer,
.pls,MPlayer-playlist,
.asf,MPlayer-playlist,
.asx,MPlayer-playlist,
.pdf,Evince,
.cbr,Comix,
,BrontideTel,tel:
As more and more programs get added, the xref file will grow to be more 'custom' and the apps like more 'universal'... at least thats the idea... perfect the apps file and tweak the xref file.

In the future i may support hildonized apps just so you can switch between them on the fly.

RUN-TIME : The end result of all of that configuration is that opening files in maemo file manager or mozilla browser go to your app, and dbus-switchboard behaves similarly to how the other apps handle it... just flash a little message bubble saying Loading....

So the key 'engine' of the program is barely noticable other than the result is what you want. In the future, a separate editor might be made for the editing of its two /home/user/ config files.

Clicking multiple times will open multiple windows with this method, so be sure only one instance of the program is loaded. For transmission that means if you load multiple torrents then only the first can be loaded automatically, save the others and load within the running program for more. For mplayer, hitting escape with exit the program so it unlikely to be an issue.

CONTRIBUTING :

If you figure out new apps that work, let me know and i'll add them to configuration files.

I have tried to make it so all you need to do is edit the configuration data but let me know if i need to update the python source code in /usr/bin/dbus-switchboard.py

To debug (if association doesnt work), load in xterm dbus-switchboard.py so that future request are logged (visible) in xterm console. This isnt necessary though since hildon will launch it invisibly if you dont manually have it loaded.