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

Henry Vermaak henry.vermaak at gmail.com
Sun Jan 2 21:36:51 CET 2011


On 2 January 2011 19:42,  <dibo20 at wp.pl> wrote:
>>
>> You may already know this, but it may help to point out that the
>> OnIdle event won't fire if there are no other events.  For example,
>> you'll have to move your mouse or hit the keyboard for the OnIdle
>> event to be called.  I don't know if this will affect talking to dbus
>> (does it queue up the signals?).
>>
>> Henry
>
> Yes, but I noticed that when there are no events, OnIdle is fired even so
> (at 5 seconds cycle). I thought it was enough to catch signal, but maybe
> it's too long and signals may have short live. C example uses glib main loop
> to check signals. I see that free pascal have some glib librarys. Can I
> somehow use it (I do not know what it is)? I need this solution only for
> linux

I had a quick look at the dbus functions.  Perhaps you can use
dbus_connection_set_wakeup_main_function to set up a function that
wakes up your main loop (containing something like:
g_main_context_wakeup(g_main_context_default) for gtk+).  This will
fire the OnIdle event where you can read the message.

Another solution can be to launch a thread that executes a loop of
dbus reads.  You can then communicate back to the main thread.

Henry



More information about the fpc-pascal mailing list