This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[DBus] How exactly DBus works?

Tags: None
(comma "," separated)
Lukas
Registered Member
Posts
427
Karma
0

[DBus] How exactly DBus works?

Wed Jul 01, 2009 5:26 pm
I know that DBus is created to be a brighe between apps and if it is used to 1to1 communication - it calls to exact another app like "org.freedesktop.DBus.GLib = do smething" -

or it could do more generic 1 to Many actions like "org.freedesktop.DBus.IM.status = away" and all apps who is registered to org.freedesktop.IM would change its status
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: [DBus] How exactly DBus works?

Thu Jul 02, 2009 6:59 am
According to the Qt documentation, this is possible http://doc.trolltech.com/4.5/qtdbus.html

The QtDBus module provides an interface that extends the Qt Signals and Slots mechanism, allowing one to connect to a signal emitted remotely as well as to connect a local signal to remote slot.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

Re: [DBus] How exactly DBus works?

Thu Jul 02, 2009 10:51 am
Basically it works like this:

An application can have any number of connections with the bus.

Each connection gets an unique identifier so one can send messages to a specific connection and one can check which specific connection a message came from.

Connections can optionally be associated with additional names, often referred to as "well known names", e.g. org.kde.knotify

There are four types of messages: method calls, method returns, errors and signals.
Method calls are sent to a specific connection, same for method returns and errors.
(theoretically all connections can see them, in reality they are filtered by a default filter in the library)

Signals are "broadcasted" to all connections.

For a use case like "set all IM apps to 'away'" one could use a signal.

Another option is to make all IM apps register with a central service which forwards method calls to each registered app.
The caller would then call the method on the central service and it would spread it to all actual receivers.

Another option is to make all IM apps register additional names using a specified prefix.
The caller would fetch a list of all connections and call the method on all connections which have a name beginning with that prefix.
(this approach is for example used to control media players)

They all have advantages and disadvantages, it depends on the actual use case which one might fit best.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
Lukas
Registered Member
Posts
427
Karma
0

Re: [DBus] How exactly DBus works?

Thu Jul 02, 2009 4:02 pm
Te case is that I was thinking about writing a very simple remote control app for my mobile phone over http:// (in local wifi network it should work enough fast, i hope :)), so I was thinking if there are global standard calls to do simple play pause vol up/down calls.

Or might be easier to simply emulate keyboard clicks like space to play/pause wheel up/down for volume.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

Re: [DBus] How exactly DBus works?

Sun Jul 12, 2009 10:28 am
I this case you might want to have a look at the MPRIS spec:
http://wiki.xmms2.xmms.se/wiki/MPRIS

Quite some media players implement it can can therefore be controlled over D-Bus in a common way.
More or less the last of the options I listed in my other comment.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]