<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
Once more thanks for these explanations!<br>
<br>
bogdan<br>
<br>
On 7/30/2013 20:53, David Zeuthen wrote:
<blockquote
cite="mid:CAHkOivRH8pKcpxKd2W=D9raSKTU+dRDT9UBmEPTWP7fG6ryZAg@mail.gmail.com"
type="cite">
<div dir="ltr">Hi,
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, Jul 30, 2013 at 11:32 AM,
Bogdan Lotko <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:boguslaw.lotko@chello.at" target="_blank">boguslaw.lotko@chello.at</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hello David,<br>
<br>
Thank you for the answer and yes, I've read the
documentation.<br>
Though I still don't understand how shall I proceed to
achieve my goal i.e. <b>atomic acquirement</b> of
service name on D-Bus.<br>
<br>
as I wrote the <br>
<br>
id = g_bus_own_name_on_connection(...);<br>
wait_for_handler(s) <br>
<br>
is for me rather strange solution, beside of this it
creates a time window where other application can
register the name.<br>
</div>
</blockquote>
<div><br>
</div>
<div>What's so strange about it? The exact same window
exists with libdbus ... that is, if you're using
dbus_bus_request_name() - the only difference is that
g_dbus_own_name() gives is non-blocking and
dbus_bus_request_name() is blocking.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Shall I really wait
for these callbacks? The documentation states "callbacks
will be invoked after calling this function" - does it
mean immediately after calling this function?<br>
</div>
</blockquote>
<div><br>
</div>
<div>No, of course not. They're called from the main loop
when the response from the D-Bus daemon comes in.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> What I still don't
have my main loop started and the decision if to start
it depends on result of this method? <br>
<br>
For me the simple and clean solution would be:<br>
returns 0 - failure name already on use<br>
returns > 0 - OK success name acquired</div>
</blockquote>
<div><br>
</div>
<div>The way g_bus_own_name() is designed, is that it
_explicitly_ requires the use of a main-loop. Why? Because
the philosophy is that sync, blocking APIs - such as
dbus_bus_request_name() - are bad. By only providing an
async API, it's harder for programmers to screw up and
write bad programs that block indefinitely ... or at
least, up to 25 seconds which is timeout used in this
case.</div>
<div><br>
</div>
<div>It's not a big deal. You really just move the
everything but g_main_loop() out of main() and into
on_name_acquired(). That's it. It's cleaner that way.</div>
<div><br>
</div>
<div>If you don't like this - but you really should - you
can always use g_dbus_connection_call_sync() and invoke
the RequstName() method yourself.</div>
<div><br>
</div>
<div> David</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<p><b>Bogdan Lotko</b></p>
<a class="moz-txt-link-abbreviated"
href="mailto:b.lotko@chello.at">b.lotko@chello.at</a>
<br>
Phone: +43 1 2852458
<br>
Mobile: +43 676 6615012
</div>
</body>
</html>