1dbus-binding-tool(1) User Commands dbus-binding-tool(1)
2
3
4
6 dbus-binding-tool - C language dbus-glib bindings generation utility.
7
9 dbus-binding-tool [--force] [--help] [--ignore-unsupported]
10 [--mode=pretty|glib-client|glib-server] [--output=file] [--prefix=sym‐
11 bol-prefix] [--version] [file...]
12
14 dbus-binding-tool is used to expose a GObject via D-Bus, using the dep‐
15 recated dbus-glib binding for GLib. As input, dbus-binding-tool uses a
16 D-Bus Introspection XML file. As output, the client-side or server-
17 side bindings is generated. This output is a header file which eases
18 the use of a remote D-Bus object. Output is sent to standard out or to
19 the filename specified with the --output argument.
20
22
23 The following is a sample D-Bus Introspection XML file which describes
24 an object that exposes one method, named ManyArgs:
25
26 <?xml version="1.0" encoding="UTF-8" ?>
27 <node name="/com/example/MyObject">
28 <interface name="com.example.MyObject">
29 <method name="ManyArgs">
30 <arg type="u" name="x" direction="in" />
31 <arg type="s" name="str" direction="in" />
32 <arg type="d" name="trouble" direction="in" />
33 <arg type="d" name="d_ret" direction="out" />
34 <arg type="s" name="str_ret" direction="out" />
35 </method>
36 </interface>
37 </node>
38
39 dbus-binding-tool supports annotations in the XML format to further
40 control how the bindings are generated.
41
42 client-side bindings
43 When building client-side bindings, the --mode=glib-client argument is
44 used. The client-side bindings support the "org.freedesk‐
45 top.DBus.Glib.NoReply" annotation. This is specified within the
46 <method> tag to indicate that the client is not expecting a reply to
47 the method call, so a reply should not be sent. This is often used to
48 speed up rapid method calls where there are no "out" arguments, and not
49 knowing if the method succeeded is an acceptable compromise to halve
50 the traffic on the bus. For example:
51
52 <method name "FooMethod">
53 [...]
54 <annotation name="org.freedesktop.DBus.GLib.NoReply" value="yes"/>
55 [...]
56 </method>
57
58 server-side bindings
59 When building server-side bindings, the --mode=glib-server argument is
60 used. Also the --prefix argument must be used when building server-
61 side bindings so that functions in the generated output are prefexed
62 with the specified value. The server-side bindings support the follow‐
63 ing annotations:
64
65 "org.freedesktop.DBus.GLib.CSymbol"
66
67 This annotation is used to specify the C symbol names for the various
68 types (interface, method, etc.), if it differs from the name D-Bus gen‐
69 erates.
70
71 <interface name="com.example.MyObject">
72 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="my_object"/>
73 [...]
74 <method name "ManyArgs">
75 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="my_object_many_args"/>
76 [...]
77 </method>
78 </interface>
79
80 "org.freedesktop.DBus.GLib.Async"
81
82 This annotation marks the method implementation as an asynchronous
83 function, which does not return a response straight away but will send
84 the response at some later point to complete the call. This is used to
85 implement non-blocking services where method calls can take time.
86
87 When a method is asynchronous, the function prototype is different. It
88 is required that the function conform to the following rules:
89
90 • The function must return a value of type gboolean; TRUE on suc‐
91 cess, and FALSE otherwise.
92 • The first parameter is a pointer to an instance of the object.
93 • Following the object instance pointer are the method input values.
94 • The final parameter must be a (DBusGMethodInvocation *). This is
95 used when sending the response message back to the client, by
96 calling dbus_g_method_return or dbus_g_method_return_error.
97
98 For example:
99
100 <method name "FooMethod">
101 [...]
102 <annotation name="org.freedesktop.DBus.GLib.Async" value="yes"/>
103 [...]
104 </method>
105
106 "org.freedesktop.DBus.GLib.Const"
107
108 This attribute can only be applied to "out" <arg> nodes, and specifies
109 that the parameter is not being copied when returned. For example, this
110 turns a 's' argument from a (char **) to a (const char **), and results
111 in the argument not being freed by D-Bus after the message is sent.
112 For example:
113
114 <arg type="u" name="x" direction="out">
115 <annotation name="org.freedesktop.DBus.GLib.Const" value=""/>
116 </arg>
117
118 "org.freedesktop.DBus.GLib.ReturnVal"
119
120 This attribute can only be applied to "out" <arg> nodes, and alters the
121 expected function signature. It currently can be set to two values: ""
122 or "error". The argument marked with this attribute is not returned via
123 a pointer argument, but by the function's return value. If the attri‐
124 bute's value is the empty string, the (GError *) argument is also omit‐
125 ted so there is no standard way to return an error value. This is very
126 useful for interfacing with existing code, as it is possible to match
127 existing APIs. If the attribute's value is "error", then the final ar‐
128 gument is a (GError *) as usual. For example:
129
130 <arg type="u" name="x" direction="out">
131 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
132 </arg>
133
135 The following options are supported:
136
137 --force
138
139 Overwrite the output file if it already exists with a newer time‐
140 stamp than the source files.
141
142
143
144 --help
145
146 Display usage information.
147
148
149
150 --ignore-unsupported
151
152 If set, then unsupported signatures for <method> parameters are ig‐
153 nored.
154
155
156
157 --mode=pretty|glib-client|glib-server
158
159 If the value is "glib-client", then client bindings are generated.
160 If the value is "glib-server", then server bindings are generated.
161 If the value is "pretty", then the output is in a more human read‐
162 able format.
163
164
165
166 --output=file
167
168 Specify the output file.
169
170
171
172 --prefix=symbol-prefix
173
174 Functions in the generated output are prefixed with the symbol-pre‐
175 fix value.
176
177
178
179 --version
180
181 Display the version number of the dbus-binding-tool command.
182
183
184
186 The following operands are supported:
187
188 file A list of one or more input D-Bus Introspection XML
189 files to include in the generated output.
190
191
192
194 The following files are used by this application:
195
196 /usr/bin/dbus-binding-tool Executable for the D-Bus Binding Tool
197 application.
198
199
200
202 gdbus-codegen(1), dbus-cleanup-sockets(1), dbus-daemon(1), dbus-moni‐
203 tor(1), dbus-send(1), dbus-uuidgen(1)
204
206 dbus-binding-tool is part of dbus-glib, which is a deprecated D-Bus
207 binding for GLib.
208
209 dbus-glib receives minimal maintenance and security fixes for the bene‐
210 fit of projects like Telepathy and NetworkManager that still rely on
211 it, but should not be used in new projects (and existing projects
212 should try to move away from it, too). Please use GDBus, part of GLib
213 since 2.26.
214
215 gdbus-codegen(1) is the GDBus replacement for dbus-binding-tool.
216
218 Man page written by Brian Cameron, Sun Microsystems Inc., 2009.
219
220
221
222dbus-glib 0.112 8 Oct 2018 dbus-binding-tool(1)