1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ |
2 | /* dbus-message.h DBusMessage object |
3 | * |
4 | * Copyright (C) 2002, 2003, 2005 Red Hat Inc. |
5 | * |
6 | * Licensed under the Academic Free License version 2.1 |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | * |
22 | */ |
23 | #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) |
24 | #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents." |
25 | #endif |
26 | |
27 | #ifndef DBUS_MESSAGE_H |
28 | #define DBUS_MESSAGE_H |
29 | |
30 | #include <dbus/dbus-macros.h> |
31 | #include <dbus/dbus-types.h> |
32 | #include <dbus/dbus-arch-deps.h> |
33 | #include <dbus/dbus-memory.h> |
34 | #include <dbus/dbus-errors.h> |
35 | #include <stdarg.h> |
36 | |
37 | DBUS_BEGIN_DECLS |
38 | |
39 | /** |
40 | * @addtogroup DBusMessage |
41 | * @{ |
42 | */ |
43 | |
44 | typedef struct DBusMessage DBusMessage; |
45 | /** |
46 | * Opaque type representing a message iterator. Can be copied by value and |
47 | * allocated on the stack. |
48 | * |
49 | * A DBusMessageIter usually contains no allocated memory. However, there |
50 | * is one special case: after a successful call to |
51 | * dbus_message_iter_open_container(), the caller is responsible for calling |
52 | * either dbus_message_iter_close_container() or |
53 | * dbus_message_iter_abandon_container() exactly once, with the same pair |
54 | * of iterators. |
55 | */ |
56 | typedef struct DBusMessageIter DBusMessageIter; |
57 | |
58 | /** |
59 | * DBusMessageIter struct; contains no public fields. |
60 | */ |
61 | struct DBusMessageIter |
62 | { |
63 | void *dummy1; /**< Don't use this */ |
64 | void *dummy2; /**< Don't use this */ |
65 | dbus_uint32_t dummy3; /**< Don't use this */ |
66 | int dummy4; /**< Don't use this */ |
67 | int dummy5; /**< Don't use this */ |
68 | int dummy6; /**< Don't use this */ |
69 | int dummy7; /**< Don't use this */ |
70 | int dummy8; /**< Don't use this */ |
71 | int dummy9; /**< Don't use this */ |
72 | int dummy10; /**< Don't use this */ |
73 | int dummy11; /**< Don't use this */ |
74 | int pad1; /**< Don't use this */ |
75 | void *pad2; /**< Don't use this */ |
76 | void *pad3; /**< Don't use this */ |
77 | }; |
78 | |
79 | /** |
80 | * A message iterator for which dbus_message_iter_abandon_container_if_open() |
81 | * is the only valid operation. |
82 | */ |
83 | #define DBUS_MESSAGE_ITER_INIT_CLOSED \ |
84 | { \ |
85 | NULL, /* dummy1 */ \ |
86 | NULL, /* dummy2 */ \ |
87 | 0, /* dummy3 */ \ |
88 | 0, /* dummy4 */ \ |
89 | 0, /* dummy5 */ \ |
90 | 0, /* dummy6 */ \ |
91 | 0, /* dummy7 */ \ |
92 | 0, /* dummy8 */ \ |
93 | 0, /* dummy9 */ \ |
94 | 0, /* dummy10 */ \ |
95 | 0, /* dummy11 */ \ |
96 | 0, /* pad1 */ \ |
97 | NULL, /* pad2 */ \ |
98 | NULL /* pad3 */ \ |
99 | } |
100 | |
101 | DBUS_EXPORT |
102 | DBusMessage* dbus_message_new (int message_type); |
103 | DBUS_EXPORT |
104 | DBusMessage* dbus_message_new_method_call (const char *bus_name, |
105 | const char *path, |
106 | const char *iface, |
107 | const char *method); |
108 | DBUS_EXPORT |
109 | DBusMessage* dbus_message_new_method_return (DBusMessage *method_call); |
110 | DBUS_EXPORT |
111 | DBusMessage* dbus_message_new_signal (const char *path, |
112 | const char *iface, |
113 | const char *name); |
114 | DBUS_EXPORT |
115 | DBusMessage* dbus_message_new_error (DBusMessage *reply_to, |
116 | const char *error_name, |
117 | const char *error_message); |
118 | DBUS_EXPORT |
119 | DBusMessage* dbus_message_new_error_printf (DBusMessage *reply_to, |
120 | const char *error_name, |
121 | const char *error_format, |
122 | ...) _DBUS_GNUC_PRINTF (3, 4); |
123 | |
124 | DBUS_EXPORT |
125 | DBusMessage* dbus_message_copy (const DBusMessage *message); |
126 | |
127 | DBUS_EXPORT |
128 | DBusMessage* dbus_message_ref (DBusMessage *message); |
129 | DBUS_EXPORT |
130 | void dbus_message_unref (DBusMessage *message); |
131 | DBUS_EXPORT |
132 | int dbus_message_get_type (DBusMessage *message); |
133 | DBUS_EXPORT |
134 | dbus_bool_t dbus_message_set_path (DBusMessage *message, |
135 | const char *object_path); |
136 | DBUS_EXPORT |
137 | const char* dbus_message_get_path (DBusMessage *message); |
138 | DBUS_EXPORT |
139 | dbus_bool_t dbus_message_has_path (DBusMessage *message, |
140 | const char *object_path); |
141 | DBUS_EXPORT |
142 | dbus_bool_t dbus_message_set_interface (DBusMessage *message, |
143 | const char *iface); |
144 | DBUS_EXPORT |
145 | const char* dbus_message_get_interface (DBusMessage *message); |
146 | DBUS_EXPORT |
147 | dbus_bool_t dbus_message_has_interface (DBusMessage *message, |
148 | const char *iface); |
149 | DBUS_EXPORT |
150 | dbus_bool_t dbus_message_set_member (DBusMessage *message, |
151 | const char *member); |
152 | DBUS_EXPORT |
153 | const char* dbus_message_get_member (DBusMessage *message); |
154 | DBUS_EXPORT |
155 | dbus_bool_t dbus_message_has_member (DBusMessage *message, |
156 | const char *member); |
157 | DBUS_EXPORT |
158 | dbus_bool_t dbus_message_set_error_name (DBusMessage *message, |
159 | const char *name); |
160 | DBUS_EXPORT |
161 | const char* dbus_message_get_error_name (DBusMessage *message); |
162 | DBUS_EXPORT |
163 | dbus_bool_t dbus_message_set_destination (DBusMessage *message, |
164 | const char *destination); |
165 | DBUS_EXPORT |
166 | const char* dbus_message_get_destination (DBusMessage *message); |
167 | DBUS_EXPORT |
168 | dbus_bool_t dbus_message_set_sender (DBusMessage *message, |
169 | const char *sender); |
170 | DBUS_EXPORT |
171 | const char* dbus_message_get_sender (DBusMessage *message); |
172 | DBUS_EXPORT |
173 | const char* dbus_message_get_signature (DBusMessage *message); |
174 | DBUS_EXPORT |
175 | void dbus_message_set_no_reply (DBusMessage *message, |
176 | dbus_bool_t no_reply); |
177 | DBUS_EXPORT |
178 | dbus_bool_t dbus_message_get_no_reply (DBusMessage *message); |
179 | DBUS_EXPORT |
180 | dbus_bool_t dbus_message_is_method_call (DBusMessage *message, |
181 | const char *iface, |
182 | const char *method); |
183 | DBUS_EXPORT |
184 | dbus_bool_t dbus_message_is_signal (DBusMessage *message, |
185 | const char *iface, |
186 | const char *signal_name); |
187 | DBUS_EXPORT |
188 | dbus_bool_t dbus_message_is_error (DBusMessage *message, |
189 | const char *error_name); |
190 | DBUS_EXPORT |
191 | dbus_bool_t dbus_message_has_destination (DBusMessage *message, |
192 | const char *bus_name); |
193 | DBUS_EXPORT |
194 | dbus_bool_t dbus_message_has_sender (DBusMessage *message, |
195 | const char *unique_bus_name); |
196 | DBUS_EXPORT |
197 | dbus_bool_t dbus_message_has_signature (DBusMessage *message, |
198 | const char *signature); |
199 | DBUS_EXPORT |
200 | dbus_uint32_t dbus_message_get_serial (DBusMessage *message); |
201 | DBUS_EXPORT |
202 | void dbus_message_set_serial (DBusMessage *message, |
203 | dbus_uint32_t serial); |
204 | DBUS_EXPORT |
205 | dbus_bool_t dbus_message_set_reply_serial (DBusMessage *message, |
206 | dbus_uint32_t reply_serial); |
207 | DBUS_EXPORT |
208 | dbus_uint32_t dbus_message_get_reply_serial (DBusMessage *message); |
209 | |
210 | DBUS_EXPORT |
211 | void dbus_message_set_auto_start (DBusMessage *message, |
212 | dbus_bool_t auto_start); |
213 | DBUS_EXPORT |
214 | dbus_bool_t dbus_message_get_auto_start (DBusMessage *message); |
215 | |
216 | DBUS_EXPORT |
217 | dbus_bool_t dbus_message_get_path_decomposed (DBusMessage *message, |
218 | char ***path); |
219 | |
220 | DBUS_EXPORT |
221 | dbus_bool_t dbus_message_append_args (DBusMessage *message, |
222 | int first_arg_type, |
223 | ...); |
224 | DBUS_EXPORT |
225 | dbus_bool_t dbus_message_append_args_valist (DBusMessage *message, |
226 | int first_arg_type, |
227 | va_list var_args); |
228 | DBUS_EXPORT |
229 | dbus_bool_t dbus_message_get_args (DBusMessage *message, |
230 | DBusError *error, |
231 | int first_arg_type, |
232 | ...); |
233 | DBUS_EXPORT |
234 | dbus_bool_t dbus_message_get_args_valist (DBusMessage *message, |
235 | DBusError *error, |
236 | int first_arg_type, |
237 | va_list var_args); |
238 | |
239 | DBUS_EXPORT |
240 | dbus_bool_t dbus_message_contains_unix_fds (DBusMessage *message); |
241 | |
242 | DBUS_EXPORT |
243 | void dbus_message_iter_init_closed (DBusMessageIter *iter); |
244 | DBUS_EXPORT |
245 | dbus_bool_t dbus_message_iter_init (DBusMessage *message, |
246 | DBusMessageIter *iter); |
247 | DBUS_EXPORT |
248 | dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter); |
249 | DBUS_EXPORT |
250 | dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter); |
251 | DBUS_EXPORT |
252 | char* dbus_message_iter_get_signature (DBusMessageIter *iter); |
253 | DBUS_EXPORT |
254 | int dbus_message_iter_get_arg_type (DBusMessageIter *iter); |
255 | DBUS_EXPORT |
256 | int dbus_message_iter_get_element_type (DBusMessageIter *iter); |
257 | DBUS_EXPORT |
258 | void dbus_message_iter_recurse (DBusMessageIter *iter, |
259 | DBusMessageIter *sub); |
260 | DBUS_EXPORT |
261 | void dbus_message_iter_get_basic (DBusMessageIter *iter, |
262 | void *value); |
263 | DBUS_EXPORT |
264 | int dbus_message_iter_get_element_count(DBusMessageIter *iter); |
265 | |
266 | #ifndef DBUS_DISABLE_DEPRECATED |
267 | /* This function returns the wire protocol size of the array in bytes, |
268 | * you do not want to know that probably |
269 | */ |
270 | DBUS_EXPORT |
271 | DBUS_DEPRECATED int dbus_message_iter_get_array_len (DBusMessageIter *iter); |
272 | #endif |
273 | DBUS_EXPORT |
274 | void dbus_message_iter_get_fixed_array (DBusMessageIter *iter, |
275 | void *value, |
276 | int *n_elements); |
277 | |
278 | |
279 | DBUS_EXPORT |
280 | void dbus_message_iter_init_append (DBusMessage *message, |
281 | DBusMessageIter *iter); |
282 | DBUS_EXPORT |
283 | dbus_bool_t dbus_message_iter_append_basic (DBusMessageIter *iter, |
284 | int type, |
285 | const void *value); |
286 | DBUS_EXPORT |
287 | dbus_bool_t dbus_message_iter_append_fixed_array (DBusMessageIter *iter, |
288 | int element_type, |
289 | const void *value, |
290 | int n_elements); |
291 | DBUS_EXPORT |
292 | dbus_bool_t dbus_message_iter_open_container (DBusMessageIter *iter, |
293 | int type, |
294 | const char *contained_signature, |
295 | DBusMessageIter *sub); |
296 | DBUS_EXPORT |
297 | dbus_bool_t dbus_message_iter_close_container (DBusMessageIter *iter, |
298 | DBusMessageIter *sub); |
299 | DBUS_EXPORT |
300 | void dbus_message_iter_abandon_container (DBusMessageIter *iter, |
301 | DBusMessageIter *sub); |
302 | |
303 | DBUS_EXPORT |
304 | void dbus_message_iter_abandon_container_if_open (DBusMessageIter *iter, |
305 | DBusMessageIter *sub); |
306 | |
307 | DBUS_EXPORT |
308 | void dbus_message_lock (DBusMessage *message); |
309 | |
310 | DBUS_EXPORT |
311 | dbus_bool_t dbus_set_error_from_message (DBusError *error, |
312 | DBusMessage *message); |
313 | |
314 | |
315 | DBUS_EXPORT |
316 | dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p); |
317 | DBUS_EXPORT |
318 | void dbus_message_free_data_slot (dbus_int32_t *slot_p); |
319 | DBUS_EXPORT |
320 | dbus_bool_t dbus_message_set_data (DBusMessage *message, |
321 | dbus_int32_t slot, |
322 | void *data, |
323 | DBusFreeFunction free_data_func); |
324 | DBUS_EXPORT |
325 | void* dbus_message_get_data (DBusMessage *message, |
326 | dbus_int32_t slot); |
327 | |
328 | DBUS_EXPORT |
329 | int dbus_message_type_from_string (const char *type_str); |
330 | DBUS_EXPORT |
331 | const char* dbus_message_type_to_string (int type); |
332 | |
333 | DBUS_EXPORT |
334 | dbus_bool_t dbus_message_marshal (DBusMessage *msg, |
335 | char **marshalled_data_p, |
336 | int *len_p); |
337 | DBUS_EXPORT |
338 | DBusMessage* dbus_message_demarshal (const char *str, |
339 | int len, |
340 | DBusError *error); |
341 | |
342 | DBUS_EXPORT |
343 | int dbus_message_demarshal_bytes_needed (const char *str, |
344 | int len); |
345 | |
346 | DBUS_EXPORT |
347 | void dbus_message_set_allow_interactive_authorization (DBusMessage *message, |
348 | dbus_bool_t allow); |
349 | |
350 | DBUS_EXPORT |
351 | dbus_bool_t dbus_message_get_allow_interactive_authorization ( |
352 | DBusMessage *message); |
353 | |
354 | /** |
355 | * Clear a variable or struct member that contains a #DBusMessage. |
356 | * If it does not contain #NULL, the message that was previously |
357 | * there is unreferenced with dbus_message_unref(). |
358 | * |
359 | * This is very similar to dbus_clear_connection(): see that function |
360 | * for more details. |
361 | * |
362 | * @param pointer_to_message A pointer to a variable or struct member. |
363 | * pointer_to_message must not be #NULL, but *pointer_to_message |
364 | * may be #NULL. |
365 | */ |
366 | static inline void |
367 | dbus_clear_message (DBusMessage **pointer_to_message) |
368 | { |
369 | _dbus_clear_pointer_impl (DBusMessage, pointer_to_message, |
370 | dbus_message_unref); |
371 | } |
372 | |
373 | /** @} */ |
374 | |
375 | DBUS_END_DECLS |
376 | |
377 | #endif /* DBUS_MESSAGE_H */ |
378 | |