D-Bus  1.13.7
dbus-message.h
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 
38 
44 typedef struct DBusMessage DBusMessage;
57 
62 {
63  void *dummy1;
64  void *dummy2;
65  dbus_uint32_t dummy3;
66  int dummy4;
67  int dummy5;
68  int dummy6;
69  int dummy7;
70  int dummy8;
71  int dummy9;
72  int dummy10;
73  int dummy11;
74  int pad1;
75  void *pad2;
76  void *pad3;
77 };
78 
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
110 DBUS_EXPORT
111 DBusMessage* dbus_message_new_signal (const char *path,
112  const char *iface,
113  const char *name);
114 DBUS_EXPORT
116  const char *error_name,
117  const char *error_message);
118 DBUS_EXPORT
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
129 DBUS_EXPORT
130 void dbus_message_unref (DBusMessage *message);
131 DBUS_EXPORT
132 int dbus_message_get_type (DBusMessage *message);
133 DBUS_EXPORT
135  const char *object_path);
136 DBUS_EXPORT
137 const char* dbus_message_get_path (DBusMessage *message);
138 DBUS_EXPORT
140  const char *object_path);
141 DBUS_EXPORT
143  const char *iface);
144 DBUS_EXPORT
145 const char* dbus_message_get_interface (DBusMessage *message);
146 DBUS_EXPORT
148  const char *iface);
149 DBUS_EXPORT
151  const char *member);
152 DBUS_EXPORT
153 const char* dbus_message_get_member (DBusMessage *message);
154 DBUS_EXPORT
156  const char *member);
157 DBUS_EXPORT
159  const char *name);
160 DBUS_EXPORT
161 const char* dbus_message_get_error_name (DBusMessage *message);
162 DBUS_EXPORT
164  const char *destination);
165 DBUS_EXPORT
166 const char* dbus_message_get_destination (DBusMessage *message);
167 DBUS_EXPORT
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
176  dbus_bool_t no_reply);
177 DBUS_EXPORT
179 DBUS_EXPORT
181  const char *iface,
182  const char *method);
183 DBUS_EXPORT
185  const char *iface,
186  const char *signal_name);
187 DBUS_EXPORT
189  const char *error_name);
190 DBUS_EXPORT
192  const char *bus_name);
193 DBUS_EXPORT
195  const char *unique_bus_name);
196 DBUS_EXPORT
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
206  dbus_uint32_t reply_serial);
207 DBUS_EXPORT
208 dbus_uint32_t dbus_message_get_reply_serial (DBusMessage *message);
209 
210 DBUS_EXPORT
212  dbus_bool_t auto_start);
213 DBUS_EXPORT
215 
216 DBUS_EXPORT
218  char ***path);
219 
220 DBUS_EXPORT
221 const char *dbus_message_get_container_instance (DBusMessage *message);
222 DBUS_EXPORT
224  const char *object_path);
225 
226 DBUS_EXPORT
228  int first_arg_type,
229  ...);
230 DBUS_EXPORT
232  int first_arg_type,
233  va_list var_args);
234 DBUS_EXPORT
236  DBusError *error,
237  int first_arg_type,
238  ...);
239 DBUS_EXPORT
241  DBusError *error,
242  int first_arg_type,
243  va_list var_args);
244 
245 DBUS_EXPORT
247 
248 DBUS_EXPORT
250 DBUS_EXPORT
252  DBusMessageIter *iter);
253 DBUS_EXPORT
255 DBUS_EXPORT
257 DBUS_EXPORT
259 DBUS_EXPORT
261 DBUS_EXPORT
263 DBUS_EXPORT
265  DBusMessageIter *sub);
266 DBUS_EXPORT
268  void *value);
269 DBUS_EXPORT
271 
272 #ifndef DBUS_DISABLE_DEPRECATED
273 /* This function returns the wire protocol size of the array in bytes,
274  * you do not want to know that probably
275  */
276 DBUS_EXPORT
278 #endif
279 DBUS_EXPORT
281  void *value,
282  int *n_elements);
283 
284 
285 DBUS_EXPORT
287  DBusMessageIter *iter);
288 DBUS_EXPORT
290  int type,
291  const void *value);
292 DBUS_EXPORT
294  int element_type,
295  const void *value,
296  int n_elements);
297 DBUS_EXPORT
299  int type,
300  const char *contained_signature,
301  DBusMessageIter *sub);
302 DBUS_EXPORT
304  DBusMessageIter *sub);
305 DBUS_EXPORT
307  DBusMessageIter *sub);
308 
309 DBUS_EXPORT
311  DBusMessageIter *sub);
312 
313 DBUS_EXPORT
314 void dbus_message_lock (DBusMessage *message);
315 
316 DBUS_EXPORT
318  DBusMessage *message);
319 
320 
321 DBUS_EXPORT
322 dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p);
323 DBUS_EXPORT
324 void dbus_message_free_data_slot (dbus_int32_t *slot_p);
325 DBUS_EXPORT
327  dbus_int32_t slot,
328  void *data,
329  DBusFreeFunction free_data_func);
330 DBUS_EXPORT
331 void* dbus_message_get_data (DBusMessage *message,
332  dbus_int32_t slot);
333 
334 DBUS_EXPORT
335 int dbus_message_type_from_string (const char *type_str);
336 DBUS_EXPORT
337 const char* dbus_message_type_to_string (int type);
338 
339 DBUS_EXPORT
341  char **marshalled_data_p,
342  int *len_p);
343 DBUS_EXPORT
344 DBusMessage* dbus_message_demarshal (const char *str,
345  int len,
346  DBusError *error);
347 
348 DBUS_EXPORT
349 int dbus_message_demarshal_bytes_needed (const char *str,
350  int len);
351 
352 DBUS_EXPORT
354  dbus_bool_t allow);
355 
356 DBUS_EXPORT
358  DBusMessage *message);
359 
372 static inline void
373 dbus_clear_message (DBusMessage **pointer_to_message)
374 {
375  _dbus_clear_pointer_impl (DBusMessage, pointer_to_message,
377 }
378 
382 
383 #endif /* DBUS_MESSAGE_H */
DBUS_EXPORT const char * dbus_message_type_to_string(int type)
Utility function to convert a D-Bus message type into a machine-readable string (not translated)...
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
dbus_bool_t dbus_message_has_path(DBusMessage *message, const char *path)
Checks if the message has a particular object path.
DBUS_EXPORT dbus_bool_t dbus_message_get_allow_interactive_authorization(DBusMessage *message)
Returns whether the flag controlled by dbus_message_set_allow_interactive_authorization() has been se...
dbus_bool_t dbus_message_is_method_call(DBusMessage *message, const char *iface, const char *method)
Checks whether the message is a method call with the given interface and member fields.
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:63
void dbus_message_set_no_reply(DBusMessage *message, dbus_bool_t no_reply)
Sets a flag indicating that the message does not want a reply; if this flag is set, the other end of the connection may (but is not required to) optimize by not sending method return or error replies.
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
Returns the argument type of the argument that the message iterator points to.
#define DBUS_DEPRECATED
Tells the compiler to warn about a function or type if it&#39;s used.
void * dummy2
Don&#39;t use this.
Definition: dbus-message.h:64
DBUS_EXPORT dbus_bool_t dbus_message_allocate_data_slot(dbus_int32_t *slot_p)
Allocates an integer ID to be used for storing application-specific data on any DBusMessage.
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
dbus_uint32_t dbus_message_get_serial(DBusMessage *message)
Returns the serial of a message or 0 if none has been specified.
void dbus_message_iter_recurse(DBusMessageIter *iter, DBusMessageIter *sub)
Recurses into a container value when reading values from a message, initializing a sub-iterator to us...
dbus_bool_t dbus_message_set_interface(DBusMessage *message, const char *iface)
Sets the interface this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or the interface...
const char * dbus_message_get_error_name(DBusMessage *message)
Gets the error name (DBUS_MESSAGE_TYPE_ERROR only) or NULL if none.
dbus_bool_t dbus_message_iter_close_container(DBusMessageIter *iter, DBusMessageIter *sub)
Closes a container-typed value appended to the message; may write out more information to the message...
DBUS_EXPORT DBusMessage * dbus_message_demarshal(const char *str, int len, DBusError *error)
Demarshal a D-Bus message from the format described in the D-Bus specification.
DBUS_EXPORT void dbus_message_iter_init_closed(DBusMessageIter *iter)
Initialize iter as if with DBUS_MESSAGE_ITER_INIT_CLOSED.
Definition: dbus-message.c:743
dbus_bool_t dbus_message_is_error(DBusMessage *message, const char *error_name)
Checks whether the message is an error reply with the given error name.
const char * dbus_message_get_sender(DBusMessage *message)
Gets the unique name of the connection which originated this message, or NULL if unknown or inapplica...
DBusMessage * dbus_message_new(int message_type)
Constructs a new message of the given message type.
const char * dbus_message_get_signature(DBusMessage *message)
Gets the type signature of the message, i.e.
void dbus_message_iter_init_append(DBusMessage *message, DBusMessageIter *iter)
Initializes a DBusMessageIter for appending arguments to the end of a message.
void dbus_message_set_auto_start(DBusMessage *message, dbus_bool_t auto_start)
Sets a flag indicating that an owner for the destination name will be automatically started before th...
DBUS_EXPORT void dbus_message_lock(DBusMessage *message)
Locks a message.
Definition: dbus-message.c:419
dbus_bool_t dbus_message_has_interface(DBusMessage *message, const char *iface)
Checks if the message has an interface.
int dummy4
Don&#39;t use this.
Definition: dbus-message.h:66
const char * dbus_message_get_path(DBusMessage *message)
Gets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitt...
DBusMessage * dbus_message_new_signal(const char *path, const char *iface, const char *name)
Constructs a new message representing a signal emission.
int dummy7
Don&#39;t use this.
Definition: dbus-message.h:69
dbus_bool_t dbus_message_iter_has_next(DBusMessageIter *iter)
Checks if an iterator has any more fields.
dbus_bool_t dbus_message_has_member(DBusMessage *message, const char *member)
Checks if the message has an interface member.
DBusMessageIter struct; contains no public fields.
Definition: dbus-message.h:61
int dummy10
Don&#39;t use this.
Definition: dbus-message.h:72
dbus_bool_t dbus_message_iter_init(DBusMessage *message, DBusMessageIter *iter)
Initializes a DBusMessageIter for reading the arguments of the message passed in. ...
const char * dbus_message_get_destination(DBusMessage *message)
Gets the destination of a message or NULL if there is none set.
dbus_bool_t dbus_message_iter_append_fixed_array(DBusMessageIter *iter, int element_type, const void *value, int n_elements)
Appends a block of fixed-length values to an array.
dbus_bool_t dbus_message_set_error_name(DBusMessage *message, const char *error_name)
Sets the name of the error (DBUS_MESSAGE_TYPE_ERROR).
const char * dbus_message_get_member(DBusMessage *message)
Gets the interface member being invoked (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted (DBUS_MESSAGE_TYPE...
Internals of DBusMessage.
DBUS_EXPORT dbus_bool_t dbus_message_marshal(DBusMessage *msg, char **marshalled_data_p, int *len_p)
Turn a DBusMessage into the marshalled form as described in the D-Bus specification.
DBUS_EXPORT void dbus_message_set_serial(DBusMessage *message, dbus_uint32_t serial)
Sets the serial number of a message.
Definition: dbus-message.c:289
const char * dbus_message_get_container_instance(DBusMessage *message)
Gets the container instance this message was sent from, or NULL if none.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
dbus_bool_t dbus_message_set_sender(DBusMessage *message, const char *sender)
Sets the message sender.
dbus_bool_t dbus_message_is_signal(DBusMessage *message, const char *iface, const char *signal_name)
Checks whether the message is a signal with the given interface and member fields.
DBUS_EXPORT void dbus_message_set_allow_interactive_authorization(DBusMessage *message, dbus_bool_t allow)
Sets a flag indicating that the caller of the method is prepared to wait for interactive authorizatio...
dbus_bool_t dbus_message_get_path_decomposed(DBusMessage *message, char ***path)
Gets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitt...
dbus_bool_t dbus_message_set_path(DBusMessage *message, const char *object_path)
Sets the object path this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or the one a s...
DBUS_EXPORT void dbus_message_free_data_slot(dbus_int32_t *slot_p)
Deallocates a global ID for message data slots.
dbus_bool_t dbus_message_set_container_instance(DBusMessage *message, const char *object_path)
Sets the container instance this message was sent from.
dbus_bool_t dbus_message_get_args(DBusMessage *message, DBusError *error, int first_arg_type,...)
Gets arguments from a message given a variable argument list.
Object representing an exception.
Definition: dbus-errors.h:48
int dbus_message_iter_get_element_count(DBusMessageIter *iter)
Returns the number of elements in the array-typed value pointed to by the iterator.
dbus_bool_t dbus_message_append_args(DBusMessage *message, int first_arg_type,...)
Appends fields to a message given a variable argument list.
dbus_uint32_t dbus_message_get_reply_serial(DBusMessage *message)
Returns the serial that the message is a reply to or 0 if none.
dbus_bool_t dbus_message_has_signature(DBusMessage *message, const char *signature)
Checks whether the message has the given signature; see dbus_message_get_signature() for more details...
DBusMessage * dbus_message_new_method_call(const char *destination, const char *path, const char *iface, const char *method)
Constructs a new message to invoke a method on a remote object.
int dummy8
Don&#39;t use this.
Definition: dbus-message.h:70
int dummy6
Don&#39;t use this.
Definition: dbus-message.h:68
dbus_bool_t dbus_message_has_destination(DBusMessage *message, const char *name)
Checks whether the message was sent to the given name.
dbus_bool_t dbus_message_get_auto_start(DBusMessage *message)
Returns TRUE if the message will cause an owner for destination name to be auto-started.
void * pad3
Don&#39;t use this.
Definition: dbus-message.h:76
void dbus_message_iter_abandon_container_if_open(DBusMessageIter *iter, DBusMessageIter *sub)
Abandons creation of a contained-typed value and frees resources created by dbus_message_iter_open_co...
DBusMessage * dbus_message_copy(const DBusMessage *message)
Creates a new message that is an exact replica of the message specified, except that its refcount is ...
int dbus_message_iter_get_element_type(DBusMessageIter *iter)
Returns the element type of the array that the message iterator points to.
DBUS_EXPORT void * dbus_message_get_data(DBusMessage *message, dbus_int32_t slot)
Retrieves data previously set with dbus_message_set_data().
dbus_bool_t dbus_message_get_args_valist(DBusMessage *message, DBusError *error, int first_arg_type, va_list var_args)
Like dbus_message_get_args but takes a va_list for use by language bindings.
dbus_bool_t dbus_set_error_from_message(DBusError *error, DBusMessage *message)
Sets a DBusError based on the contents of the given message.
void dbus_message_iter_get_fixed_array(DBusMessageIter *iter, void *value, int *n_elements)
Reads a block of fixed-length values from the message iterator.
const char * dbus_message_get_interface(DBusMessage *message)
Gets the interface this message is being sent to (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitted...
dbus_bool_t dbus_message_set_reply_serial(DBusMessage *message, dbus_uint32_t reply_serial)
Sets the reply serial of a message (the serial of the message this is a reply to).
dbus_bool_t dbus_message_has_sender(DBusMessage *message, const char *name)
Checks whether the message has the given unique name as its sender.
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
Moves the iterator to the next field, if any.
void dbus_message_iter_get_basic(DBusMessageIter *iter, void *value)
Reads a basic-typed value from the message iterator.
dbus_bool_t dbus_message_set_destination(DBusMessage *message, const char *destination)
Sets the message&#39;s destination.
void * pad2
Don&#39;t use this.
Definition: dbus-message.h:75
dbus_bool_t dbus_message_get_no_reply(DBusMessage *message)
Returns TRUE if the message does not expect a reply.
dbus_bool_t dbus_message_iter_open_container(DBusMessageIter *iter, int type, const char *contained_signature, DBusMessageIter *sub)
Appends a container-typed value to the message.
dbus_bool_t dbus_message_iter_append_basic(DBusMessageIter *iter, int type, const void *value)
Appends a basic-typed value to the message.
int dbus_message_iter_get_array_len(DBusMessageIter *iter)
Returns the number of bytes in the array as marshaled in the wire protocol.
int dummy5
Don&#39;t use this.
Definition: dbus-message.h:67
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
int dummy11
Don&#39;t use this.
Definition: dbus-message.h:73
DBUS_EXPORT int dbus_message_demarshal_bytes_needed(const char *str, int len)
Returns the number of bytes required to be in the buffer to demarshal a D-Bus message.
dbus_bool_t dbus_message_append_args_valist(DBusMessage *message, int first_arg_type, va_list var_args)
Like dbus_message_append_args() but takes a va_list for use by language bindings. ...
char * dbus_message_iter_get_signature(DBusMessageIter *iter)
Returns the current signature of a message iterator.
void dbus_message_iter_abandon_container(DBusMessageIter *iter, DBusMessageIter *sub)
Abandons creation of a contained-typed value and frees resources created by dbus_message_iter_open_co...
dbus_bool_t dbus_message_contains_unix_fds(DBusMessage *message)
Checks whether a message contains unix fds.
dbus_uint32_t dummy3
Don&#39;t use this.
Definition: dbus-message.h:65
dbus_bool_t dbus_message_set_member(DBusMessage *message, const char *member)
Sets the interface member being invoked (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted (DBUS_MESSAGE_TYPE...
DBUS_EXPORT dbus_bool_t dbus_message_set_data(DBusMessage *message, dbus_int32_t slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusMessage, along with an optional function to be used for freeing the data wh...
void dbus_message_unref(DBusMessage *message)
Decrements the reference count of a DBusMessage, freeing the message if the count reaches 0...
int dummy9
Don&#39;t use this.
Definition: dbus-message.h:71
void * dummy1
Don&#39;t use this.
Definition: dbus-message.h:63
int pad1
Don&#39;t use this.
Definition: dbus-message.h:74
DBusMessage * dbus_message_new_error_printf(DBusMessage *reply_to, const char *error_name, const char *error_format,...)
Creates a new message that is an error reply to another message, allowing you to use printf formattin...
DBusMessage * dbus_message_new_method_return(DBusMessage *method_call)
Constructs a message that is a reply to a method call.
DBUS_EXPORT int dbus_message_type_from_string(const char *type_str)
Utility function to convert a machine-readable (not translated) string into a D-Bus message type...
DBusMessage * dbus_message_new_error(DBusMessage *reply_to, const char *error_name, const char *error_message)
Creates a new message that is an error reply to another message.
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.