Using multiple matches for d-bus signals

Havoc Pennington hp at pobox.com
Fri Oct 24 08:08:26 PDT 2008


Hi,

On Fri, Oct 24, 2008 at 3:40 AM, Soh Kam Yung <sohkamyung at gmail.com> wrote:
> dbus_bus_add_match (dbus_connection,
>    "type='signal',"
>    "interface='my.test.[interface-to-match]'", &error);

This would get all signals from the interface, regardless of which
process sends it; you could add sender= to also filter by sender.

> dbus_bus_add_match (dbus_connection,
>    "type='signal'", &error);
>
> And then go through the received messages, searching for the expected signal(s)?

This will get all signals of any kind.

Which you should do depends on the use case. On a typical linux
desktop, getting all signals of any kind would be bad, since your app
would wake up in lots of cases where it need not.

> Or should I consider using a single app that will listen to all d-bus
> signals, interpret and dispatch the signals to other apps via some
> other method?
>

Unlikely; the bus daemon itself should be able to dispatch signals
according to the match rules. That's the daemon's job.

Basically you should figure out how to match only the signals you
need, or not too many extras anyway.

Havoc


More information about the dbus mailing list