diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2018-08-20 21:12:06 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2018-08-20 21:12:06 -0400 |
commit | 63e87c2d0c9d263f14c77b68f85c67d46ece82a9 (patch) | |
tree | 6260365cbf7d24f37d27669e8538227fcb72e243 /gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html | |
parent | a4460f6d9453bbd7e584937686449cef3e19f052 (diff) |
Diffstat (limited to 'gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html')
-rw-r--r-- | gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html b/gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html deleted file mode 100644 index b498280..0000000 --- a/gtk+-mingw/share/gtk-doc/html/gio/ch31s03.html +++ /dev/null @@ -1,123 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<title>Owning bus names</title> -<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> -<link rel="home" href="index.html" title="GIO Reference Manual"> -<link rel="up" href="ch31.html" title="Migrating to GDBus"> -<link rel="prev" href="ch31s02.html" title="API comparison"> -<link rel="next" href="ch31s04.html" title="Creating proxies for well-known names"> -<meta name="generator" content="GTK-Doc V1.18 (XML mode)"> -<link rel="stylesheet" href="style.css" type="text/css"> -</head> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"> -<td><a accesskey="p" href="ch31s02.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> -<td><a accesskey="u" href="ch31.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> -<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> -<th width="100%" align="center">GIO Reference Manual</th> -<td><a accesskey="n" href="ch31s04.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> -</tr></table> -<div class="section"> -<div class="titlepage"><div><div><h2 class="title" style="clear: both"> -<a name="idp77071728"></a>Owning bus names</h2></div></div></div> -<p> - Using dbus-glib, you typically call RequestName manually - to own a name, like in the following excerpt: - </p> -<div class="informalexample"><pre class="programlisting"> - error = NULL; - res = dbus_g_proxy_call (system_bus_proxy, - "RequestName", - &error, - G_TYPE_STRING, NAME_TO_CLAIM, - G_TYPE_UINT, DBUS_NAME_FLAG_ALLOW_REPLACEMENT, - G_TYPE_INVALID, - G_TYPE_UINT, &result, - G_TYPE_INVALID); - if (!res) - { - if (error != NULL) - { - g_warning ("Failed to acquire %s: %s", - NAME_TO_CLAIM, error->message); - g_error_free (error); - } - else - { - g_warning ("Failed to acquire %s", NAME_TO_CLAIM); - } - goto out; - } - - if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) - { - if (error != NULL) - { - g_warning ("Failed to acquire %s: %s", - NAME_TO_CLAIM, error->message); - g_error_free (error); - } - else - { - g_warning ("Failed to acquire %s", NAME_TO_CLAIM); - } - exit (1); - } - - dbus_g_proxy_add_signal (system_bus_proxy, "NameLost", - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (system_bus_proxy, "NameLost", - G_CALLBACK (on_name_lost), NULL, NULL); - - /* further setup ... */ - - </pre></div> -<p> - </p> -<p> - While you can do things this way with GDBus too, using - <a class="link" href="GDBusProxy.html#g-dbus-proxy-call-sync" title="g_dbus_proxy_call_sync ()"><code class="function">g_dbus_proxy_call_sync()</code></a>, it is much nicer to use the high-level API - for this: - </p> -<div class="informalexample"><pre class="programlisting"> -static void -on_name_acquired (GDBusConnection *connection, - const gchar *name, - gpointer user_data) -{ - /* further setup ... */ -} - -/* ... */ - - owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, - NAME_TO_CLAIM, - G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, - on_bus_acquired, - on_name_acquired, - on_name_lost, - NULL, - NULL); - - g_main_loop_run (loop); - - g_bus_unown_name (owner_id); - - </pre></div> -<p> - Note that <a class="link" href="gio-Owning-Bus-Names.html#g-bus-own-name" title="g_bus_own_name ()"><code class="function">g_bus_own_name()</code></a> works asynchronously and requires - you to enter your mainloop to await the <code class="function">on_name_aquired()</code> - callback. Also note that in order to avoid race conditions (e.g. - when your service is activated by a method call), you have to export - your manager object <span class="emphasis"><em>before</em></span> acquiring the - name. The <code class="function">on_bus_acquired()</code> callback is the right place to do - such preparations. - </p> -</div> -<div class="footer"> -<hr> - Generated by GTK-Doc V1.18</div> -</body> -</html>
\ No newline at end of file |