<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
W dniu 13.01.2011 16:02, Henry Vermaak pisze:
<blockquote cite="mid:4D2F141C.6070009@gmail.com" type="cite">On
13/01/11 15:00, Henry Vermaak wrote:
<br>
<blockquote type="cite">On 13/01/11 12:24, <a class="moz-txt-link-abbreviated" href="mailto:dibo20@wp.pl">dibo20@wp.pl</a> wrote:
<br>
<blockquote type="cite">
<br>
"integrate the GLib event loop with an external event loop" -
I think
<br>
this is what I want.
<br>
</blockquote>
<br>
What you want to do is to integrate the dbus connection into
your main
<br>
loop (in this case glib). Let me quote from the documentation:
<br>
<br>
"If you're using GLib or Qt add-on libraries for D-Bus, there
are
<br>
special convenience APIs in those libraries that hide all the
details of
<br>
dispatch and watch/timeout monitoring. For example,
<br>
dbus_connection_setup_with_g_main().
<br>
<br>
"If you aren't using these add-on libraries, but want to process
<br>
messages asynchronously, you must manually call
<br>
dbus_connection_set_dispatch_status_function(),
<br>
dbus_connection_set_watch_functions(),
<br>
dbus_connection_set_timeout_functions() providing appropriate
functions
<br>
to integrate the connection with your application's main loop.
This can
<br>
be tricky to get right; main loops are not simple."
<br>
<br>
If you look at the dbus_connection_set_watch_functions
documentation:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html#gaebf031eb444b4f847606aa27daa3d8e6">http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html#gaebf031eb444b4f847606aa27daa3d8e6</a>
<br>
<br>
<br>
You'll see that this will provide you will file descriptors that
you can
<br>
add to your main loop to watch for the dbus events.
<br>
<br>
This is all _much_ simpler if you use the dbus-glib functions:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.ibm.com/developerworks/linux/library/l-dbus.html">http://www.ibm.com/developerworks/linux/library/l-dbus.html</a>
<br>
<br>
It doesn't look like that header has been translated to pascal,
yet.
<br>
That doesn't matter, since it's now considered obsolete, since
glib has
<br>
dbus support now:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.freedesktop.org/wiki/Software/DBusBindings">http://www.freedesktop.org/wiki/Software/DBusBindings</a>
<br>
<br>
fpc doesn't seem to have bindings for that, either...
<br>
</blockquote>
<br>
Having said all of this, you can get around this by calling
blocking dbus calls in a thread and notifying the user interface
by virtue of Synchronize, PostMessage and QueueAsycCall.
<br>
<br>
Henry
<br>
_______________________________________________
<br>
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a>
<br>
<br>
</blockquote>
I'm trying with "dbus_connection_set_watch_functions" but this is
not easy like it look. <span id="result_box" class="short_text"
lang="en"><span title="Kliknij, aby wyświetlić alternatywne
tłumaczenia" class="hps">I thought</span> <span title="Kliknij,
aby wyświetlić alternatywne tłumaczenia" class="hps">that I must
only register my event procedures by calling this functions but
there is much more work. </span></span><span id="result_box"
class="short_text" lang="en"><span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">I have a headache. Now I
understand why </span></span>dbus documentation <span
id="result_box" class="short_text" lang="en"><span title="Kliknij,
aby wyświetlić alternatywne tłumaczenia" class="hps">begins with</span>
<span title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps">the words "If you use this low-level API directly,
you're signing up for some pain" ;) . Tomorrow I look for some
"live example" of using this functions in C.<br>
<br>
I tried with thread. It doesn't catch all signals even if I call
sleep(1) in loop. </span></span><span id="result_box"
class="short_text" lang="en"><span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">I don't know</span> what
is reason of this loss<span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">. Thread and
AddEventHandler have this same problem - they don't catch all
signals. Only one way which works is
"g_main_context_set_poll_func" </span></span><span
id="result_box" class="short_text" lang="en"><span title="Kliknij,
aby wyświetlić alternatywne tłumaczenia" class="hps">but now I</span>
<span title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps">see</span> <span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">that the</span>
application <span title="Kliknij, aby wyświetlić alternatywne
tłumaczenia" class="hps">consumes 30</span><span class=""
title="Kliknij, aby wyświetlić alternatywne tłumaczenia">%</span>
<span title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps">CPU. So now I understand why it catch all signals. @</span></span><b></b>Matthias
how you solved problem with CPU and this function?<br>
<span id="result_box" class="short_text" lang="en"><span
title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps"><br>
This all problems started after this upgrade (probably):<br>
<a class="moz-txt-link-freetext" href="http://bugs.freepascal.org/view.php?id=14086">http://bugs.freepascal.org/view.php?id=14086</a><br>
Because before I listened for signals in thread with sleep(100)
without problems.<br>
<br>
P.S. People who have demo from me, please comment line:<br>
dbus_connection_close(conn);<br>
in my_client_app -> busexample.pas<br>
</span></span><span id="result_box" class="short_text" lang="en"><span
title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps">This</span> <span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">should</span> <span
title="Kliknij, aby wyświetlić alternatywne tłumaczenia"
class="hps">not</span> <span title="Kliknij, aby wyświetlić
alternatywne tłumaczenia" class="hps">be there.</span></span><br>
</body>
</html>