I need to write an application in C for asynchronous sending and reading messages on the dbus message queue. I’ve read that for doing that I should use the DBusWatch and DBusTimeout objects that the connection provides, but I cannot find an example of how to use these anywhere…
For the moment i use dbus_connection_read_write_dispatch in order to do that, but I’ve read that it is not recommended for asynchronous operations, so I’ll have to switch to creating my own main loop and using it…
The closest answer to my question was this one:
http://lists.freedesktop.org/archives/dbus/2007-September/008555.html ,
suggesting to look through the dbus-gmain.c file, which I did, but all I found there was a call of the dbus_connection_set_watch_functions and dbus_connection_set_timeout_functions, with other functions as parameters – should I overwrite those functions? Should I use them as they are?
I simply cannot figure out how to use these in order to read and write something to the dbus message queue…
Any idea would be more than welcome…
Here’s something I wrote some time ago. I removed application specific code, you should just add your snippets where you handle DBus messages meant for your application and that should be it.