2003-10-09 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / dbus / dbus-message.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-message.h DBusMessage object
3  *
4  * Copyright (C) 2002  Red Hat Inc.
5  *
6  * Licensed under the Academic Free License version 1.2
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 typedef struct DBusMessage DBusMessage;
40 typedef struct DBusMessageIter DBusMessageIter;
41
42 /**
43  * DBusMessageIter struct; contains no public fields 
44  */
45 struct DBusMessageIter
46
47   void *dummy1;         /**< Don't use this */
48   void *dummy2;         /**< Don't use this */
49   dbus_uint32_t dummy3; /**< Don't use this */
50   int dummy4;           /**< Don't use this */
51   int dummy5;           /**< Don't use this */
52   int dummy6;           /**< Don't use this */
53   int dummy7;           /**< Don't use this */
54   int dummy8;           /**< Don't use this */
55   int dummy9;           /**< Don't use this */
56   int dummy10;          /**< Don't use this */
57   int dummy11;          /**< Don't use this */
58   int pad1;             /**< Don't use this */
59   int pad2;             /**< Don't use this */
60   void *pad3;           /**< Don't use this */
61 };
62
63 DBusMessage* dbus_message_new               (int          message_type);
64 DBusMessage* dbus_message_new_method_call   (const char  *service,
65                                              const char  *path,
66                                              const char  *interface,
67                                              const char  *method);
68 DBusMessage* dbus_message_new_method_return (DBusMessage *method_call);
69 DBusMessage* dbus_message_new_signal        (const char  *path,
70                                              const char  *interface,
71                                              const char  *name);
72 DBusMessage* dbus_message_new_error         (DBusMessage *reply_to,
73                                              const char  *error_name,
74                                              const char  *error_message);
75
76 DBusMessage *dbus_message_copy              (const DBusMessage *message);
77
78 void          dbus_message_ref              (DBusMessage   *message);
79 void          dbus_message_unref            (DBusMessage   *message);
80 int           dbus_message_get_type         (DBusMessage   *message);
81 dbus_bool_t   dbus_message_set_path         (DBusMessage   *message,
82                                              const char    *object_path);
83 const char*   dbus_message_get_path         (DBusMessage   *message);
84 dbus_bool_t   dbus_message_set_interface    (DBusMessage   *message,
85                                              const char    *interface);
86 const char*   dbus_message_get_interface    (DBusMessage   *message);
87 dbus_bool_t   dbus_message_set_member       (DBusMessage   *message,
88                                              const char    *member);
89 const char*   dbus_message_get_member       (DBusMessage   *message);
90 dbus_bool_t   dbus_message_set_error_name   (DBusMessage   *message,
91                                              const char    *name);
92 const char*   dbus_message_get_error_name   (DBusMessage   *message);
93 dbus_bool_t   dbus_message_set_destination  (DBusMessage   *message,
94                                              const char    *destination);
95 const char*   dbus_message_get_destination  (DBusMessage   *message);
96 dbus_bool_t   dbus_message_set_sender       (DBusMessage   *message,
97                                              const char    *sender);
98 const char*   dbus_message_get_sender       (DBusMessage   *message);
99 void          dbus_message_set_no_reply     (DBusMessage   *message,
100                                              dbus_bool_t    no_reply);
101 dbus_bool_t   dbus_message_get_no_reply     (DBusMessage   *message);
102 dbus_bool_t   dbus_message_is_method_call   (DBusMessage   *message,
103                                              const char    *interface,
104                                              const char    *method);
105 dbus_bool_t   dbus_message_is_signal        (DBusMessage   *message,
106                                              const char    *interface,
107                                              const char    *signal_name);
108 dbus_bool_t   dbus_message_is_error         (DBusMessage   *message,
109                                              const char    *error_name);
110 dbus_bool_t   dbus_message_has_destination  (DBusMessage   *message,
111                                              const char    *service);
112 dbus_bool_t   dbus_message_has_sender       (DBusMessage   *message,
113                                              const char    *service);
114 dbus_uint32_t dbus_message_get_serial       (DBusMessage   *message);
115 dbus_bool_t   dbus_message_set_reply_serial (DBusMessage   *message,
116                                              dbus_uint32_t  reply_serial);
117 dbus_uint32_t dbus_message_get_reply_serial (DBusMessage   *message);
118
119 dbus_bool_t   dbus_message_get_path_decomposed (DBusMessage   *message,
120                                                 char        ***path);
121
122 dbus_bool_t dbus_message_append_args          (DBusMessage     *message,
123                                                int              first_arg_type,
124                                                ...);
125 dbus_bool_t dbus_message_append_args_valist   (DBusMessage     *message,
126                                                int              first_arg_type,
127                                                va_list          var_args);
128 dbus_bool_t dbus_message_get_args             (DBusMessage     *message,
129                                                DBusError       *error,
130                                                int              first_arg_type,
131                                                ...);
132 dbus_bool_t dbus_message_get_args_valist      (DBusMessage     *message,
133                                                DBusError       *error,
134                                                int              first_arg_type,
135                                                va_list          var_args);
136 dbus_bool_t dbus_message_iter_get_args        (DBusMessageIter *iter,
137                                                DBusError       *error,
138                                                int              first_arg_type,
139                                                ...);
140 dbus_bool_t dbus_message_iter_get_args_valist (DBusMessageIter *iter,
141                                                DBusError       *error,
142                                                int              first_arg_type,
143                                                va_list          var_args);
144
145
146
147 void          dbus_message_iter_init           (DBusMessage      *message,
148                                                 DBusMessageIter  *iter);
149 dbus_bool_t   dbus_message_iter_has_next       (DBusMessageIter  *iter);
150 dbus_bool_t   dbus_message_iter_next           (DBusMessageIter  *iter);
151 int           dbus_message_iter_get_arg_type   (DBusMessageIter  *iter);
152 int           dbus_message_iter_get_array_type (DBusMessageIter  *iter);
153 unsigned char dbus_message_iter_get_byte       (DBusMessageIter  *iter);
154 dbus_bool_t   dbus_message_iter_get_boolean    (DBusMessageIter  *iter);
155 dbus_int32_t  dbus_message_iter_get_int32      (DBusMessageIter  *iter);
156 dbus_uint32_t dbus_message_iter_get_uint32     (DBusMessageIter  *iter);
157 #ifdef DBUS_HAVE_INT64
158 dbus_int64_t  dbus_message_iter_get_int64      (DBusMessageIter  *iter);
159 dbus_uint64_t dbus_message_iter_get_uint64     (DBusMessageIter  *iter);
160 #endif /* DBUS_HAVE_INT64 */
161 double        dbus_message_iter_get_double     (DBusMessageIter  *iter);
162 char *        dbus_message_iter_get_string     (DBusMessageIter  *iter);
163 char *        dbus_message_iter_get_dict_key   (DBusMessageIter  *iter);
164 dbus_bool_t   dbus_message_iter_get_named      (DBusMessageIter  *iter,
165                                                 char            **name,
166                                                 unsigned char   **value,
167                                                 int              *len);
168
169 dbus_bool_t dbus_message_iter_init_array_iterator (DBusMessageIter   *iter,
170                                                    DBusMessageIter   *array_iter,
171                                                    int               *array_type);
172 dbus_bool_t dbus_message_iter_init_dict_iterator  (DBusMessageIter   *iter,
173                                                    DBusMessageIter   *dict_iter);
174 dbus_bool_t dbus_message_iter_get_byte_array      (DBusMessageIter   *iter,
175                                                    unsigned char    **value,
176                                                    int               *len);
177 dbus_bool_t dbus_message_iter_get_boolean_array   (DBusMessageIter   *iter,
178                                                    unsigned char    **value,
179                                                    int               *len);
180 dbus_bool_t dbus_message_iter_get_int32_array     (DBusMessageIter   *iter,
181                                                    dbus_int32_t     **value,
182                                                    int               *len);
183 dbus_bool_t dbus_message_iter_get_uint32_array    (DBusMessageIter   *iter,
184                                                    dbus_uint32_t    **value,
185                                                    int               *len);
186 #ifdef DBUS_HAVE_INT64
187 dbus_bool_t dbus_message_iter_get_int64_array     (DBusMessageIter   *iter,
188                                                    dbus_int64_t     **value,
189                                                    int               *len);
190 dbus_bool_t dbus_message_iter_get_uint64_array    (DBusMessageIter   *iter,
191                                                    dbus_uint64_t    **value,
192                                                    int               *len);
193 #endif /* DBUS_HAVE_INT64 */
194 dbus_bool_t dbus_message_iter_get_double_array    (DBusMessageIter   *iter,
195                                                    double           **value,
196                                                    int               *len);
197 dbus_bool_t dbus_message_iter_get_string_array    (DBusMessageIter   *iter,
198                                                    char            ***value,
199                                                    int               *len);
200
201
202 void        dbus_message_append_iter_init          (DBusMessage          *message,
203                                                     DBusMessageIter      *iter);
204 dbus_bool_t dbus_message_iter_append_nil           (DBusMessageIter      *iter);
205 dbus_bool_t dbus_message_iter_append_boolean       (DBusMessageIter      *iter,
206                                                     dbus_bool_t           value);
207 dbus_bool_t dbus_message_iter_append_byte          (DBusMessageIter      *iter,
208                                                     unsigned char         value);
209 dbus_bool_t dbus_message_iter_append_int32         (DBusMessageIter      *iter,
210                                                     dbus_int32_t          value);
211 dbus_bool_t dbus_message_iter_append_uint32        (DBusMessageIter      *iter,
212                                                     dbus_uint32_t         value);
213 #ifdef DBUS_HAVE_INT64
214 dbus_bool_t dbus_message_iter_append_int64         (DBusMessageIter      *iter,
215                                                     dbus_int64_t          value);
216 dbus_bool_t dbus_message_iter_append_uint64        (DBusMessageIter      *iter,
217                                                     dbus_uint64_t         value);
218 #endif /* DBUS_HAVE_INT64 */
219 dbus_bool_t dbus_message_iter_append_double        (DBusMessageIter      *iter,
220                                                     double                value);
221 dbus_bool_t dbus_message_iter_append_string        (DBusMessageIter      *iter,
222                                                     const char           *value);
223 dbus_bool_t dbus_message_iter_append_named         (DBusMessageIter      *iter,
224                                                     const char           *name,
225                                                     const unsigned char  *data,
226                                                     int                   len);
227 dbus_bool_t dbus_message_iter_append_dict_key      (DBusMessageIter      *iter,
228                                                     const char           *value);
229 dbus_bool_t dbus_message_iter_append_array         (DBusMessageIter      *iter,
230                                                     DBusMessageIter      *array_iter,
231                                                     int                   element_type);
232 dbus_bool_t dbus_message_iter_append_dict          (DBusMessageIter      *iter,
233                                                     DBusMessageIter      *dict_iter);
234
235 /* Helpers for normal types: */
236 dbus_bool_t dbus_message_iter_append_boolean_array (DBusMessageIter      *iter,
237                                                     unsigned const char  *value,
238                                                     int                   len);
239 dbus_bool_t dbus_message_iter_append_int32_array   (DBusMessageIter      *iter,
240                                                     const dbus_int32_t   *value,
241                                                     int                   len);
242 dbus_bool_t dbus_message_iter_append_uint32_array  (DBusMessageIter      *iter,
243                                                     const dbus_uint32_t  *value,
244                                                     int                   len);
245 #ifdef DBUS_HAVE_INT64
246 dbus_bool_t dbus_message_iter_append_int64_array   (DBusMessageIter      *iter,
247                                                     const dbus_int64_t   *value,
248                                                     int                   len);
249 dbus_bool_t dbus_message_iter_append_uint64_array  (DBusMessageIter      *iter,
250                                                     const dbus_uint64_t  *value,
251                                                     int                   len);
252 #endif /* DBUS_HAVE_INT64 */
253 dbus_bool_t dbus_message_iter_append_double_array  (DBusMessageIter      *iter,
254                                                     const double         *value,
255                                                     int                   len);
256 dbus_bool_t dbus_message_iter_append_byte_array    (DBusMessageIter      *iter,
257                                                     unsigned const char  *value,
258                                                     int                   len);
259 dbus_bool_t dbus_message_iter_append_string_array  (DBusMessageIter      *iter,
260                                                     const char          **value,
261                                                     int                   len);
262
263
264
265 dbus_bool_t  dbus_set_error_from_message  (DBusError    *error,
266                                            DBusMessage  *message);
267
268
269 dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t     *slot_p);
270 void        dbus_message_free_data_slot     (dbus_int32_t     *slot_p);
271 dbus_bool_t dbus_message_set_data           (DBusMessage      *message,
272                                              dbus_int32_t      slot,
273                                              void             *data,
274                                              DBusFreeFunction  free_data_func);
275 void*       dbus_message_get_data           (DBusMessage      *message,
276                                              dbus_int32_t      slot);
277
278 int dbus_message_type_from_string (const char *type_str);
279
280 DBUS_END_DECLS;
281
282 #endif /* DBUS_MESSAGE_H */