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
37DBUS_BEGIN_DECLS
38
39/**
40 * @addtogroup DBusMessage
41 * @{
42 */
43
44typedef 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 */
56typedef struct DBusMessageIter DBusMessageIter;
57
58/**
59 * DBusMessageIter struct; contains no public fields.
60 */
61struct 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
101DBUS_EXPORT
102DBusMessage* dbus_message_new (int message_type);
103DBUS_EXPORT
104DBusMessage* dbus_message_new_method_call (const char *bus_name,
105 const char *path,
106 const char *iface,
107 const char *method);
108DBUS_EXPORT
109DBusMessage* dbus_message_new_method_return (DBusMessage *method_call);
110DBUS_EXPORT
111DBusMessage* dbus_message_new_signal (const char *path,
112 const char *iface,
113 const char *name);
114DBUS_EXPORT
115DBusMessage* dbus_message_new_error (DBusMessage *reply_to,
116 const char *error_name,
117 const char *error_message);
118DBUS_EXPORT
119DBusMessage* 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
124DBUS_EXPORT
125DBusMessage* dbus_message_copy (const DBusMessage *message);
126
127DBUS_EXPORT
128DBusMessage* dbus_message_ref (DBusMessage *message);
129DBUS_EXPORT
130void dbus_message_unref (DBusMessage *message);
131DBUS_EXPORT
132int dbus_message_get_type (DBusMessage *message);
133DBUS_EXPORT
134dbus_bool_t dbus_message_set_path (DBusMessage *message,
135 const char *object_path);
136DBUS_EXPORT
137const char* dbus_message_get_path (DBusMessage *message);
138DBUS_EXPORT
139dbus_bool_t dbus_message_has_path (DBusMessage *message,
140 const char *object_path);
141DBUS_EXPORT
142dbus_bool_t dbus_message_set_interface (DBusMessage *message,
143 const char *iface);
144DBUS_EXPORT
145const char* dbus_message_get_interface (DBusMessage *message);
146DBUS_EXPORT
147dbus_bool_t dbus_message_has_interface (DBusMessage *message,
148 const char *iface);
149DBUS_EXPORT
150dbus_bool_t dbus_message_set_member (DBusMessage *message,
151 const char *member);
152DBUS_EXPORT
153const char* dbus_message_get_member (DBusMessage *message);
154DBUS_EXPORT
155dbus_bool_t dbus_message_has_member (DBusMessage *message,
156 const char *member);
157DBUS_EXPORT
158dbus_bool_t dbus_message_set_error_name (DBusMessage *message,
159 const char *name);
160DBUS_EXPORT
161const char* dbus_message_get_error_name (DBusMessage *message);
162DBUS_EXPORT
163dbus_bool_t dbus_message_set_destination (DBusMessage *message,
164 const char *destination);
165DBUS_EXPORT
166const char* dbus_message_get_destination (DBusMessage *message);
167DBUS_EXPORT
168dbus_bool_t dbus_message_set_sender (DBusMessage *message,
169 const char *sender);
170DBUS_EXPORT
171const char* dbus_message_get_sender (DBusMessage *message);
172DBUS_EXPORT
173const char* dbus_message_get_signature (DBusMessage *message);
174DBUS_EXPORT
175void dbus_message_set_no_reply (DBusMessage *message,
176 dbus_bool_t no_reply);
177DBUS_EXPORT
178dbus_bool_t dbus_message_get_no_reply (DBusMessage *message);
179DBUS_EXPORT
180dbus_bool_t dbus_message_is_method_call (DBusMessage *message,
181 const char *iface,
182 const char *method);
183DBUS_EXPORT
184dbus_bool_t dbus_message_is_signal (DBusMessage *message,
185 const char *iface,
186 const char *signal_name);
187DBUS_EXPORT
188dbus_bool_t dbus_message_is_error (DBusMessage *message,
189 const char *error_name);
190DBUS_EXPORT
191dbus_bool_t dbus_message_has_destination (DBusMessage *message,
192 const char *bus_name);
193DBUS_EXPORT
194dbus_bool_t dbus_message_has_sender (DBusMessage *message,
195 const char *unique_bus_name);
196DBUS_EXPORT
197dbus_bool_t dbus_message_has_signature (DBusMessage *message,
198 const char *signature);
199DBUS_EXPORT
200dbus_uint32_t dbus_message_get_serial (DBusMessage *message);
201DBUS_EXPORT
202void dbus_message_set_serial (DBusMessage *message,
203 dbus_uint32_t serial);
204DBUS_EXPORT
205dbus_bool_t dbus_message_set_reply_serial (DBusMessage *message,
206 dbus_uint32_t reply_serial);
207DBUS_EXPORT
208dbus_uint32_t dbus_message_get_reply_serial (DBusMessage *message);
209
210DBUS_EXPORT
211void dbus_message_set_auto_start (DBusMessage *message,
212 dbus_bool_t auto_start);
213DBUS_EXPORT
214dbus_bool_t dbus_message_get_auto_start (DBusMessage *message);
215
216DBUS_EXPORT
217dbus_bool_t dbus_message_get_path_decomposed (DBusMessage *message,
218 char ***path);
219
220DBUS_EXPORT
221dbus_bool_t dbus_message_append_args (DBusMessage *message,
222 int first_arg_type,
223 ...);
224DBUS_EXPORT
225dbus_bool_t dbus_message_append_args_valist (DBusMessage *message,
226 int first_arg_type,
227 va_list var_args);
228DBUS_EXPORT
229dbus_bool_t dbus_message_get_args (DBusMessage *message,
230 DBusError *error,
231 int first_arg_type,
232 ...);
233DBUS_EXPORT
234dbus_bool_t dbus_message_get_args_valist (DBusMessage *message,
235 DBusError *error,
236 int first_arg_type,
237 va_list var_args);
238
239DBUS_EXPORT
240dbus_bool_t dbus_message_contains_unix_fds (DBusMessage *message);
241
242DBUS_EXPORT
243void dbus_message_iter_init_closed (DBusMessageIter *iter);
244DBUS_EXPORT
245dbus_bool_t dbus_message_iter_init (DBusMessage *message,
246 DBusMessageIter *iter);
247DBUS_EXPORT
248dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter);
249DBUS_EXPORT
250dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter);
251DBUS_EXPORT
252char* dbus_message_iter_get_signature (DBusMessageIter *iter);
253DBUS_EXPORT
254int dbus_message_iter_get_arg_type (DBusMessageIter *iter);
255DBUS_EXPORT
256int dbus_message_iter_get_element_type (DBusMessageIter *iter);
257DBUS_EXPORT
258void dbus_message_iter_recurse (DBusMessageIter *iter,
259 DBusMessageIter *sub);
260DBUS_EXPORT
261void dbus_message_iter_get_basic (DBusMessageIter *iter,
262 void *value);
263DBUS_EXPORT
264int 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 */
270DBUS_EXPORT
271DBUS_DEPRECATED int dbus_message_iter_get_array_len (DBusMessageIter *iter);
272#endif
273DBUS_EXPORT
274void dbus_message_iter_get_fixed_array (DBusMessageIter *iter,
275 void *value,
276 int *n_elements);
277
278
279DBUS_EXPORT
280void dbus_message_iter_init_append (DBusMessage *message,
281 DBusMessageIter *iter);
282DBUS_EXPORT
283dbus_bool_t dbus_message_iter_append_basic (DBusMessageIter *iter,
284 int type,
285 const void *value);
286DBUS_EXPORT
287dbus_bool_t dbus_message_iter_append_fixed_array (DBusMessageIter *iter,
288 int element_type,
289 const void *value,
290 int n_elements);
291DBUS_EXPORT
292dbus_bool_t dbus_message_iter_open_container (DBusMessageIter *iter,
293 int type,
294 const char *contained_signature,
295 DBusMessageIter *sub);
296DBUS_EXPORT
297dbus_bool_t dbus_message_iter_close_container (DBusMessageIter *iter,
298 DBusMessageIter *sub);
299DBUS_EXPORT
300void dbus_message_iter_abandon_container (DBusMessageIter *iter,
301 DBusMessageIter *sub);
302
303DBUS_EXPORT
304void dbus_message_iter_abandon_container_if_open (DBusMessageIter *iter,
305 DBusMessageIter *sub);
306
307DBUS_EXPORT
308void dbus_message_lock (DBusMessage *message);
309
310DBUS_EXPORT
311dbus_bool_t dbus_set_error_from_message (DBusError *error,
312 DBusMessage *message);
313
314
315DBUS_EXPORT
316dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p);
317DBUS_EXPORT
318void dbus_message_free_data_slot (dbus_int32_t *slot_p);
319DBUS_EXPORT
320dbus_bool_t dbus_message_set_data (DBusMessage *message,
321 dbus_int32_t slot,
322 void *data,
323 DBusFreeFunction free_data_func);
324DBUS_EXPORT
325void* dbus_message_get_data (DBusMessage *message,
326 dbus_int32_t slot);
327
328DBUS_EXPORT
329int dbus_message_type_from_string (const char *type_str);
330DBUS_EXPORT
331const char* dbus_message_type_to_string (int type);
332
333DBUS_EXPORT
334dbus_bool_t dbus_message_marshal (DBusMessage *msg,
335 char **marshalled_data_p,
336 int *len_p);
337DBUS_EXPORT
338DBusMessage* dbus_message_demarshal (const char *str,
339 int len,
340 DBusError *error);
341
342DBUS_EXPORT
343int dbus_message_demarshal_bytes_needed (const char *str,
344 int len);
345
346DBUS_EXPORT
347void dbus_message_set_allow_interactive_authorization (DBusMessage *message,
348 dbus_bool_t allow);
349
350DBUS_EXPORT
351dbus_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 */
366static inline void
367dbus_clear_message (DBusMessage **pointer_to_message)
368{
369 _dbus_clear_pointer_impl (DBusMessage, pointer_to_message,
370 dbus_message_unref);
371}
372
373/** @} */
374
375DBUS_END_DECLS
376
377#endif /* DBUS_MESSAGE_H */
378

source code of include/dbus-1.0/dbus/dbus-message.h