Receiving dbus signals using low-level C API
Havoc Pennington
hp at redhat.com
Wed Jan 24 13:27:22 PST 2007
Krishna R wrote:
>
> 4. In my filter function, i read the message using
> dbus_message_get_args() and return DBUS_HANDLER_RESULT_HANDLED.
>
It usually makes more sense to return NOT_YET_HANDLED from a signal
handler, since other handlers may also be interested. Though if your app
isn't using any libraries that may also be interested, it doesn't matter.
> 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?
I don't believe so, I could misremember, but it would be documented if
you did have to probably.
> 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?
The filter function will be called for any kind of message.
> 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?
Yes, if it's a shared connection you should unref but not close. (The
documentation goes into more detail.)
Havoc
More information about the dbus
mailing list