Tizen 2.1 base
[platform/upstream/glib2.0.git] / docs / reference / gio / html / gdbus.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>gdbus</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="tools.html" title="GIO Tools">
9 <link rel="prev" href="glib-compile-resources.html" title="glib-compile-resources">
10 <link rel="next" href="gdbus-codegen.html" title="gdbus-codegen">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
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="glib-compile-resources.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="tools.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="gdbus-codegen.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div lang="en" class="refentry">
23 <a name="gdbus"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
25 <td valign="top">
26 <h2><span class="refentrytitle">gdbus</span></h2>
27 <p>gdbus — Tool for working with D-Bus objects</p>
28 </td>
29 <td valign="top" align="right"></td>
30 </tr></table></div>
31 <div class="refsynopsisdiv">
32 <h2>Synopsis</h2>
33 <div class="cmdsynopsis"><p><code class="command">gdbus</code>   introspect  [ --system  |   --session  |   --address <em class="replaceable"><code>address</code></em> ]  --dest <em class="replaceable"><code>bus_name</code></em>   --object-path <em class="replaceable"><code>/path/to/object</code></em>  [ --xml ] [ --recurse ] [ --only-properties ]</p></div>
34 <div class="cmdsynopsis"><p><code class="command">gdbus</code>   monitor  [ --system  |   --session  |   --address <em class="replaceable"><code>address</code></em> ]  --dest <em class="replaceable"><code>bus_name</code></em>  [ --object-path <em class="replaceable"><code>/path/to/object</code></em> ]</p></div>
35 <div class="cmdsynopsis"><p><code class="command">gdbus</code>   call  [ --system  |   --session  |   --address <em class="replaceable"><code>address</code></em> ]  --dest <em class="replaceable"><code>bus_name</code></em>   --object-path <em class="replaceable"><code>/path/to/object</code></em>   --method <em class="replaceable"><code>org.project.InterfaceName.MethodName</code></em>  [ --timeout <em class="replaceable"><code>seconds</code></em> ]  ARG1   ARG2... </p></div>
36 <div class="cmdsynopsis"><p><code class="command">gdbus</code>   emit  [ --system  |   --session  |   --address <em class="replaceable"><code>address</code></em> ]  --object-path <em class="replaceable"><code>/path/to/object</code></em>   --signal <em class="replaceable"><code>org.project.InterfaceName.SignalName</code></em>  [ --dest <em class="replaceable"><code>unique_bus_name</code></em> ]  ARG1   ARG2... </p></div>
37 <div class="cmdsynopsis"><p><code class="command">gdbus</code>   help </p></div>
38 </div>
39 <div class="refsect1">
40 <a name="id543700"></a><h2>Description</h2>
41 <p>
42     <span class="command"><strong>gdbus</strong></span> is a simple tool for working with D-Bus objects.
43   </p>
44 <div class="refsect2">
45 <a name="id884507"></a><h3>Commands</h3>
46 <div class="variablelist"><table border="0">
47 <col align="left" valign="top">
48 <tbody>
49 <tr>
50 <td><p><span class="term"><code class="option">introspect</code></span></p></td>
51 <td><p>
52           Prints out interfaces and property values for a remote object.
53           For this to work, the owner of the object needs to implement the
54           <code class="literal">org.freedesktop.DBus.Introspectable</code> interface.
55           If the <code class="option">--xml</code> option is used, the returned
56           introspection XML is printed, otherwise a parsed pretty
57           representation is printed.
58           The <code class="option">--recurse</code> option can be used to
59           introspect children (and their children and so on) and the
60           <code class="option">--only-properties</code> option can be used to
61           only print the interfaces with properties.
62           </p></td>
63 </tr>
64 <tr>
65 <td><p><span class="term"><code class="option">monitor</code></span></p></td>
66 <td><p>
67           Monitors one or all objects owned by the owner of
68           <em class="replaceable"><code>bus_name</code></em>.
69         </p></td>
70 </tr>
71 <tr>
72 <td><p><span class="term"><code class="option">call</code></span></p></td>
73 <td><p>
74           Invokes a method on a remote object.  Each argument to pass to the
75           method must be specified as a serialized
76           <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> except that strings do
77           not need explicit quotes. The return values are printed out as
78           serialized <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a>
79           values.
80         </p></td>
81 </tr>
82 <tr>
83 <td><p><span class="term"><code class="option">emit</code></span></p></td>
84 <td><p>
85           Emits a signal. Each argument to include in the signal must be specified as a serialized
86           <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> except that strings do
87           not need explicit quotes.
88         </p></td>
89 </tr>
90 <tr>
91 <td><p><span class="term"><code class="option">help</code></span></p></td>
92 <td><p>
93           Prints help and exit.
94         </p></td>
95 </tr>
96 </tbody>
97 </table></div>
98 </div>
99 </div>
100 <div class="refsect1">
101 <a name="id967616"></a><h2>Bash Completion</h2>
102 <p>
103     <span class="command"><strong>gdbus</strong></span> ships with a bash completion script to
104     complete commands, destinations, bus names, object paths and
105     interface/method names.
106   </p>
107 </div>
108 <div class="refsect1">
109 <a name="id685353"></a><h2>Examples</h2>
110   This shows how to introspect an object - note that the value of each
111   property is displayed:
112 <pre class="programlisting">
113 $ gdbus introspect --system \
114         --dest org.freedesktop.NetworkManager \
115         --object-path /org/freedesktop/NetworkManager/Devices/0
116 node /org/freedesktop/NetworkManager/Devices/0 {
117   interface org.freedesktop.DBus.Introspectable {
118     methods:
119       Introspect(out s data);
120   };
121   interface org.freedesktop.DBus.Properties {
122     methods:
123       Get(in  s interface,
124           in  s propname,
125           out v value);
126       Set(in  s interface,
127           in  s propname,
128           in  v value);
129       GetAll(in  s interface,
130              out a{sv} props);
131   };
132   interface org.freedesktop.NetworkManager.Device.Wired {
133     signals:
134       PropertiesChanged(a{sv} arg_0);
135     properties:
136       readonly b Carrier = false;
137       readonly u Speed = 0;
138       readonly s HwAddress = '00:1D:72:88:BE:97';
139   };
140   interface org.freedesktop.NetworkManager.Device {
141     methods:
142       Disconnect();
143     signals:
144       StateChanged(u arg_0,
145                    u arg_1,
146                    u arg_2);
147     properties:
148       readonly u DeviceType = 1;
149       readonly b Managed = true;
150       readwrite o Ip6Config = '/';
151       readwrite o Dhcp4Config = '/';
152       readwrite o Ip4Config = '/';
153       readonly u State = 2;
154       readwrite u Ip4Address = 0;
155       readonly u Capabilities = 3;
156       readonly s Driver = 'e1000e';
157       readwrite s Interface = 'eth0';
158       readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
159   };
160 };
161 </pre>
162 <p>
163   The <code class="option">--recurse</code> and <code class="option">--only-properties</code> options can be useful when wanting to inspect all objects owned by a particular process:
164 </p>
165 <pre class="programlisting">
166 $ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse  --only-properties 
167 node / {
168   node /org {
169     node /org/freedesktop {
170       node /org/freedesktop/UPower {
171         interface org.freedesktop.UPower {
172           properties:
173             readonly b IsDocked = true;
174             readonly b LidForceSleep = false;
175             readonly b LidIsPresent = false;
176             readonly b LidIsClosed = false;
177             readonly b OnLowBattery = false;
178             readonly b OnBattery = false;
179             readonly b CanHibernate = true;
180             readonly b CanSuspend = true;
181             readonly s DaemonVersion = '0.9.10';
182         };
183         node /org/freedesktop/UPower/Policy {
184         };
185         node /org/freedesktop/UPower/Wakeups {
186           interface org.freedesktop.UPower.Wakeups {
187             properties:
188               readonly b HasCapability = true;
189           };
190         };
191       };
192     };
193   };
194 };
195 </pre>
196 <p>
197   In a similar fashion, the <code class="option">introspect</code> command can be
198   used to learn details about the <code class="literal">Notify</code> method:
199 </p>
200 <pre class="programlisting">
201 [...]
202   interface org.freedesktop.Notifications {
203     methods:
204       GetServerInformation(out s return_name,
205                            out s return_vendor,
206                            out s return_version,
207                            out s return_spec_version);
208       GetCapabilities(out as return_caps);
209       CloseNotification(in  u id);
210       Notify(in  s app_name,
211              in  u id,
212              in  s icon,
213              in  s summary,
214              in  s body,
215              in  as actions,
216              in  a{sv} hints,
217              in  i timeout,
218              out u return_id);
219   };
220 [...]
221 </pre>
222 <p>
223   With this information, it's easy to use the <code class="option">call</code>
224   command to display a notification
225 </p>
226 <pre class="programlisting">
227 $ gdbus call --session \
228              --dest org.freedesktop.Notifications \
229              --object-path /org/freedesktop/Notifications \
230              --method org.freedesktop.Notifications.Notify \
231              my_app_name \
232              42 \
233              gtk-dialog-info \
234              "The Summary" \
235              "Here's the body of the notification" \
236              [] \
237              {} \
238              5000
239 (uint32 12,)
240 </pre>
241 <p>
242   Monitoring all objects on a service:
243 </p>
244 <pre class="programlisting">
245 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
246 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
247 The name org.freedesktop.ConsoleKit is owned by :1.15
248 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
249 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
250 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
251 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
252 </pre>
253 <p>
254   Monitoring a single object on a service:
255 </p>
256 <pre class="programlisting">
257 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
258 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
259 The name org.freedesktop.NetworkManager is owned by :1.5
260 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': &lt;byte 0x5c&gt;},)
261 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': &lt;byte 0x64&gt;},)
262 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': &lt;byte 0x5e&gt;},)
263 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': &lt;byte 0x64&gt;},)
264 </pre>
265 <p>
266   Emitting a signal:
267 </p>
268 <pre class="programlisting">
269 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
270 </pre>
271 <p>
272   Emitting a signal to a specific process:
273 </p>
274 <pre class="programlisting">
275 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
276 </pre>
277 </div>
278 <div class="refsect1">
279 <a name="id983238"></a><h2>AUTHOR</h2>
280 <p>
281     Written by David Zeuthen <code class="email">&lt;<a class="email" href="mailto:zeuthen@gmail.com">zeuthen@gmail.com</a>&gt;</code> with
282     a lot of help from many others.
283   </p>
284 </div>
285 <div class="refsect1">
286 <a name="id538698"></a><h2>BUGS</h2>
287 <p>
288     Please send bug reports to either the distribution bug tracker
289     or the upstream bug tracker at
290     <a class="ulink" href="https://bugzilla.gnome.org/enter_bug.cgi?product=glib" target="_top">https://bugzilla.gnome.org/enter_bug.cgi?product=glib</a>.
291   </p>
292 </div>
293 <div class="refsect1">
294 <a name="id607169"></a><h2>SEE ALSO</h2>
295 <p>
296     <span class="citerefentry"><span class="refentrytitle">dbus-send</span>(1)</span>
297   </p>
298 </div>
299 </div>
300 <div class="footer">
301 <hr>
302           Generated by GTK-Doc V1.18</div>
303 </body>
304 </html>