passively listening for signals

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Aug 2 05:24:36 PDT 2007


On Wed, 01 Aug 2007 at 22:49:27 -0400, Jim Kytola wrote:
> The other problem was that it was starting those that were not yet started
> (for example, Rhythmbox would start if I tried to connect). I noticed the
> line "You shouldn't use proxy objects just to listen to signals, since they
> might activate the relevant service when created, but if you already have a
> proxy object in order to call methods, it's often convenient to use it to
> add signal matches too." from the dbus-python tutorial, but it wasn't clear
> to me how to avoid this (by not using proxy objects).

Use dbus.connection.Connection.add_signal_receiver() (the system and
session bus objects are subclasses of Connection, so they have that
method too).

> Also, could you clarify what you mean by
> 
> "  2) request the current state that would be notified about by the signal"
> 
> What kind of request is this? I'm hoping I can figure out how to implement
> what has been suggested, so it may not be a concern - I would just like to
> understand what you mean by this.

For example, in the Telepathy D-Bus API, wherever we have a signal for
something changing (e.g. StatusChanged) we make sure we also have a
method you can call to get the initial state (e.g. GetStatus).

In your case this would be a method like GetAllUnreadMail() or
something (unless you decide that nobody will ever be interested in
finding out what mail was new before their new-mail-notification applet
started; but if so, that should be a deliberate design decision, not an
omission).

	Simon


More information about the dbus mailing list