1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Creating proxies for well-known names</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="ch30.html" title="Migrating to GDBus">
9 <link rel="prev" href="ch30s03.html" title="Owning bus names">
10 <link rel="next" href="ch30s05.html" title="Generating code and docs">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="ch30s03.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="ch30.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GIO Reference Manual</th>
20 <td><a accesskey="n" href="ch30s05.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="id1071627"></a>Creating proxies for well-known names</h2></div></div></div>
26 dbus-glib lets you create proxy objects for well-known names, like the
29 <div class="informalexample">
30 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
33 <td class="listing_lines" align="right"><pre>1
37 <td class="listing_code"><pre class="programlisting"><span class="normal">proxy </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/dbus-glib/dbus-glib-DBusGProxy.html#dbus-g-proxy-new-for-name">dbus_g_proxy_new_for_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">system_bus_connection</span><span class="symbol">,</span>
38 <span class="normal"> </span><span class="string">"org.freedesktop.Accounts"</span><span class="symbol">,</span>
39 <span class="normal"> </span><span class="string">"/org/freedesktop/Accounts"</span><span class="symbol">,</span>
40 <span class="normal"> </span><span class="string">"org.freedesktop.Accounts"</span><span class="symbol">);</span></pre></td>
47 For a <a href="/usr/share/gtk-doc/html/dbus-glib/dbus-glib-DBusGProxy.html#DBusGProxy"><span class="type">DBusGProxy</span></a> constructed like this, method calls will be sent to
48 the current owner of the name, and that owner can change over time.
51 The same can be achieved with <a class="link" href="GDBusProxy.html" title="GDBusProxy"><span class="type">GDBusProxy</span></a>:
53 <div class="informalexample">
54 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
57 <td class="listing_lines" align="right"><pre>1
66 <td class="listing_code"><pre class="programlisting"><span class="normal">error </span><span class="symbol">=</span><span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">;</span>
67 <span class="normal">proxy </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GDBusProxy.html#g-dbus-proxy-new-for-bus-sync">g_dbus_proxy_new_for_bus_sync</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="GDBusConnection.html#G-BUS-TYPE-SYSTEM:CAPS">G_BUS_TYPE_SYSTEM</a></span><span class="symbol">,</span>
68 <span class="normal"> <a href="GDBusProxy.html#G-DBUS-PROXY-FLAGS-NONE:CAPS">G_DBUS_PROXY_FLAGS_NONE</a></span><span class="symbol">,</span>
69 <span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> </span><span class="comment">/* GDBusInterfaceInfo */</span>
70 <span class="normal"> </span><span class="string">"org.freedesktop.Accounts"</span><span class="symbol">,</span>
71 <span class="normal"> </span><span class="string">"/org/freedesktop/Accounts"</span><span class="symbol">,</span>
72 <span class="normal"> </span><span class="string">"org.freedesktop.Accounts"</span><span class="symbol">,</span>
73 <span class="normal"> <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> </span><span class="comment">/* GCancellable */</span>
74 <span class="normal"> </span><span class="symbol">&</span><span class="normal">error</span><span class="symbol">);</span></pre></td>
81 For an added layer of safety, you can specify what D-Bus
82 interface the proxy is expected to conform to by using the
83 <a class="link" href="gio-D-Bus-Introspection-Data.html#GDBusInterfaceInfo"><span class="type">GDBusInterfaceInfo</span></a> type. Additionally, <a class="link" href="GDBusProxy.html" title="GDBusProxy"><span class="type">GDBusProxy</span></a> loads,
84 caches and tracks changes to the D-Bus properties on the remote
85 object. It also sets up match rules so D-Bus signals from the
86 remote object are delivered locally.
89 The <a class="link" href="GDBusProxy.html" title="GDBusProxy"><span class="type">GDBusProxy</span></a> type normally isn't used directly - instead
90 proxies subclassing <a class="link" href="GDBusProxy.html" title="GDBusProxy"><span class="type">GDBusProxy</span></a> generated by <span class="command"><strong><a href="gdbus-codegen.html">gdbus-codegen</a></strong></span> is used, see <a class="xref" href="ch30s05.html#gdbus-example-gdbus-codegen" title="Using gdbus-codegen">the section called “Using gdbus-codegen”</a>
95 Generated by GTK-Doc V1.18</div>