[fpc-pascal] D-Bus. Non blocking listening for signals

Henry Vermaak henry.vermaak at gmail.com
Thu Jan 13 16:00:00 CET 2011


On 13/01/11 12:24, dibo20 at wp.pl wrote:
>
> "integrate the GLib event loop with an external event loop" - I think
> this is what I want.

What you want to do is to integrate the dbus connection into your main 
loop (in this case glib).  Let me quote from the documentation:

"If you're using GLib or Qt add-on libraries for D-Bus, there are 
special convenience APIs in those libraries that hide all the details of 
dispatch and watch/timeout monitoring. For example, 
dbus_connection_setup_with_g_main().

"If you aren't using these add-on libraries, but want to process 
messages asynchronously, you must manually call 
dbus_connection_set_dispatch_status_function(), 
dbus_connection_set_watch_functions(), 
dbus_connection_set_timeout_functions() providing appropriate functions 
to integrate the connection with your application's main loop. This can 
be tricky to get right; main loops are not simple."

If you look at the dbus_connection_set_watch_functions documentation:

http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html#gaebf031eb444b4f847606aa27daa3d8e6

You'll see that this will provide you will file descriptors that you can 
add to your main loop to watch for the dbus events.

This is all _much_ simpler if you use the dbus-glib functions:

http://www.ibm.com/developerworks/linux/library/l-dbus.html

It doesn't look like that header has been translated to pascal, yet. 
That doesn't matter, since it's now considered obsolete, since glib has 
dbus support now:

http://www.freedesktop.org/wiki/Software/DBusBindings

fpc doesn't seem to have bindings for that, either...

Henry



More information about the fpc-pascal mailing list