Receiving dbus signals using low-level C API

Krishna R sith.list at
Wed Jan 24 13:12:46 PST 2007


I have a basic question about sending and receiving signals. Most of what i
have learnt till now is based on the dbus low level API tutorial.

I am using dbus 1.0.2 and a session bus.

Sending signal:
I send a signal as told in the tutorial, i use dbus_message_append_args() to
send some arguments with the message.

Rcving signal: (this is where i have some questions)

1. I set a filter function and read the arguements of the message in the
filter function.
2. I add a match rule  to recv the signal like this
dbus_bus_add_match(conn, "type='signal',interface='test.signal.Type'",

3. And instead of dbus_connection_pop_message as used in the tutorial, do
while (dbus_connection_read_write_dispatch (conn, -1) ) ;

4. In my filter function, i read the message using dbus_message_get_args()


1. Is this a correct way to recv signals? Do i have to do
dbus_message_unref(message) in the filter function after handling it before
i return?

2. I also see that as soon as i call the match rule api, the filter function
gets called. I further found that the message has a argument which a string,
which is 2. Is this expected? I had assumed that the filter function will
only be called when i send a signal and not before that. Why is this?

Seperate point: Also in the tutorial the send signal function closes the
dbus connection and the dbus version 1.0.2 complains about this. Can someone
pls fix the tutorial for this. I assume from the error message we dont close
the connection anymore?

Thanks for any help or insights!
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the dbus mailing list