aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/gnunet_dbus_lib_push.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_push.h')
-rw-r--r--src/lib/include/gnunet_dbus_lib_push.h397
1 files changed, 397 insertions, 0 deletions
diff --git a/src/lib/include/gnunet_dbus_lib_push.h b/src/lib/include/gnunet_dbus_lib_push.h
new file mode 100644
index 0000000..31a9bc9
--- /dev/null
+++ b/src/lib/include/gnunet_dbus_lib_push.h
@@ -0,0 +1,397 @@
1#ifndef GNUNET_DBUS_LIB_PUSH_H
2#define GNUNET_DBUS_LIB_PUSH_H
3
4#include <dbus/dbus.h>
5#include <gnunet/platform.h>
6#include <gnunet/gnunet_common.h>
7#include <gnunet/gnunet_crypto_lib.h>
8
9/**
10 * Push a byte to a DBus message, advancing the iterator.
11 */
12void
13GNUNET_DBUS_push_byte (
14 DBusMessage *message,
15 DBusMessageIter *iter,
16 const unsigned char *value);
17
18/**
19 * Push a boolean to a DBus message, advancing the iterator.
20 */
21void
22GNUNET_DBUS_push_boolean (
23 DBusMessage *message,
24 DBusMessageIter *iter,
25 const dbus_bool_t *value);
26
27/**
28 * Push an int16 to a DBus message, advancing the iterator.
29 */
30void
31GNUNET_DBUS_push_int16 (
32 DBusMessage *message,
33 DBusMessageIter *iter,
34 const dbus_int16_t *value);
35
36/**
37 * Push a uint16 to a DBus message, advancing the iterator.
38 */
39void
40GNUNET_DBUS_push_uint16 (
41 DBusMessage *message,
42 DBusMessageIter *iter,
43 const dbus_uint16_t *value);
44
45/**
46 * Push an int32 to a DBus message, advancing the iterator.
47 */
48void
49GNUNET_DBUS_push_int32 (
50 DBusMessage *message,
51 DBusMessageIter *iter,
52 const dbus_int32_t *value);
53
54/**
55 * Push a uint32 to a DBus message, advancing the iterator.
56 */
57void
58GNUNET_DBUS_push_uint32 (
59 DBusMessage *message,
60 DBusMessageIter *iter,
61 const dbus_uint32_t *value);
62
63/**
64 * Push an int64 to a DBus message, advancing the iterator.
65 */
66void
67GNUNET_DBUS_push_int64 (
68 DBusMessage *message,
69 DBusMessageIter *iter,
70 const dbus_int64_t *value);
71
72/**
73 * Push a uint64 to a DBus message, advancing the iterator.
74 */
75void
76GNUNET_DBUS_push_uint64 (
77 DBusMessage *message,
78 DBusMessageIter *iter,
79 const dbus_uint64_t *value);
80
81/**
82 * Push a double to a DBus message, advancing the iterator.
83 */
84void
85GNUNET_DBUS_push_double (
86 DBusMessage *message,
87 DBusMessageIter *iter,
88 const double *value);
89
90/**
91 * Push a string to a DBus message, advancing the iterator.
92 */
93void
94GNUNET_DBUS_push_string (
95 DBusMessage *message,
96 DBusMessageIter *iter,
97 const char *const *value);
98
99/**
100 * Push an object path to a DBus message, advancing the iterator.
101 */
102void
103GNUNET_DBUS_push_object_path (
104 DBusMessage *message,
105 DBusMessageIter *iter,
106 const struct GNUNET_DBUS_ObjectPath *path);
107
108/**
109 * Push a DBus type signature to a DBus message, advancing the iterator.
110 */
111void
112GNUNET_DBUS_push_signature (
113 DBusMessage *message,
114 DBusMessageIter *iter,
115 const char *const *value);
116
117/**
118 * Push a unix file descriptor to a DBus message, advancing the iterator.
119 */
120void
121GNUNET_DBUS_push_unix_fd (
122 DBusMessage *message,
123 DBusMessageIter *iter,
124 const int *value);
125
126/**
127 * Push a unix file descriptor to a DBus message, advancing the iterator.
128 */
129void
130GNUNET_DBUS_push_open_array (
131 DBusMessage *message,
132 DBusMessageIter *iter,
133 DBusMessageIter *iter_sub,
134 const char *signature);
135
136/**
137 * Commence pushing an array to a DBusMessage. iter_sub is initialised to point
138 * to the start of a new array and can be used to populate the array.
139 * GNUNET_DBUS_push_close_array must be called after the array has been
140 * populated. iter is invalid until GNUNET_DBUS_push_close_array has been called.
141 */
142void
143GNUNET_DBUS_push_open_struct (
144 DBusMessage *message,
145 DBusMessageIter *iter,
146 DBusMessageIter *iter_sub);
147
148/**
149 * Commence pushing a variant to a DBusMessage. iter_sub is initialised to
150 * point to an empty variant and must be used to place the value in the
151 * variant. After the value is placed, GNUNET_DBUS_push_close_variant must be
152 * called. iter is invalid until GNUNET_DBUS_push_close_array has been called.
153 */
154void
155GNUNET_DBUS_push_open_variant (
156 DBusMessage *message,
157 DBusMessageIter *iter,
158 DBusMessageIter *iter_sub,
159 const char *signature);
160
161/**
162 * Commence pushing a dictionary entry onto a DBusMessage. iter_sub is
163 * initialised to point to the start of the new dictionary entry. It must be
164 * used to push the key and value in order after which
165 * GNUNET_DBUS_push_close_dict_entry must be called. iter is invalid until
166 * GNUNET_DBUS_push_close_array has been called.
167 */
168void
169GNUNET_DBUS_push_open_dict_entry (
170 DBusMessage *message,
171 DBusMessageIter *iter,
172 DBusMessageIter *iter_sub);
173
174/**
175 * Finish pushing an array to a DBusMesage. This must be called after
176 * GNUNET_DBUS_push_open_array and after the array elements have been pushed to
177 * the message. After calling this function, iter_sub becomes invalid and iter
178 * can again be used to push data to the message.
179 */
180void
181GNUNET_DBUS_push_close_array (
182 DBusMessage *message,
183 DBusMessageIter *iter,
184 DBusMessageIter *iter_sub);
185
186/**
187 * Finish pushing a struct to a DBusMessage. This must be called after
188 * GNUNET_DBUS_push_open_struct and after the struct members have been pushed
189 * to the message. iter is invalid until GNUNET_DBUS_push_close_array has been
190 * called. After calling this function, iter_sub becomes invalid and iter can
191 * again be used to push data to the message.
192 */
193void
194GNUNET_DBUS_push_close_struct (
195 DBusMessage *message,
196 DBusMessageIter *iter,
197 DBusMessageIter *iter_sub);
198
199/**
200 * Finish pushing a variant to a DBusMessage. This must be called after
201 * GNUNET_DBUS_push_open_variant and after the variant's value has been pushed
202 * to the message. After calling this function, iter_sub becomes invalid and
203 * iter can again be used to push data to the message.
204 */
205void
206GNUNET_DBUS_push_close_variant (
207 DBusMessage *message,
208 DBusMessageIter *iter,
209 DBusMessageIter *iter_sub);
210
211/**
212 * Finish pushing a dictionary entry to a DBusMessage. This must be called
213 * after GNUNET_DBUS_push_open_dict_entry and after the key and value have been
214 * pushed to the message. After calling this function, iter_sub becomes invalid
215 * and iter can again be used to push data to the message.
216 */
217void
218GNUNET_DBUS_push_close_dict_entry (
219 DBusMessage *message,
220 DBusMessageIter *iter,
221 DBusMessageIter *iter_sub);
222
223/**
224 * Push an array of bytes to a DBusMessage, advancing the iterator. The values
225 * are copied to the message. value_count is the number of elements in the array.
226 */
227void
228GNUNET_DBUS_push_byte_array (
229 DBusMessage *message,
230 DBusMessageIter *iter,
231 const unsigned char *value,
232 size_t value_count);
233
234/**
235 * Push an array of booleans to a DBusMessage, advancing the iterator. The values
236 * are copied to the message. value_count is the number of elements in the array.
237 */
238void
239GNUNET_DBUS_push_boolean_array (
240 DBusMessage *message,
241 DBusMessageIter *iter,
242 const dbus_bool_t *value,
243 size_t value_count);
244
245/**
246 * Push an array of int16s to a DBusMessage, advancing the iterator. The values
247 * are copied to the message. value_count is the number of elements in the array.
248 */
249void
250GNUNET_DBUS_push_int16_array (
251 DBusMessage *message,
252 DBusMessageIter *iter,
253 const dbus_int16_t *value,
254 size_t value_count);
255
256/**
257 * Push an array of uint16s to a DBusMessage, advancing the iterator. The values
258 * are copied to the message. value_count is the number of elements in the array.
259 */
260void
261GNUNET_DBUS_push_uint16_array (
262 DBusMessage *message,
263 DBusMessageIter *iter,
264 const dbus_uint16_t *value,
265 size_t value_count);
266
267/**
268 * Push an array of int32s to a DBusMessage, advancing the iterator. The values
269 * are copied to the message. value_count is the number of elements in the array.
270 */
271void
272GNUNET_DBUS_push_int32_array (
273 DBusMessage *message,
274 DBusMessageIter *iter,
275 const unsigned char *value,
276 size_t value_count);
277
278/**
279 * Push an array of uint32s to a DBusMessage, advancing the iterator. The values
280 * are copied to the message. value_count is the number of elements in the array.
281 */
282void
283GNUNET_DBUS_push_uint32_array (
284 DBusMessage *message,
285 DBusMessageIter *iter,
286 const unsigned char *value,
287 size_t value_count);
288
289/**
290 * Push an array of int64s to a DBusMessage, advancing the iterator. The values
291 * are copied to the message. value_count is the number of elements in the array.
292 */
293void
294GNUNET_DBUS_push_int64_array (
295 DBusMessage *message,
296 DBusMessageIter *iter,
297 const unsigned char *value,
298 size_t value_count);
299
300/**
301 * Push an array of uint64s to a DBusMessage, advancing the iterator. The values
302 * are copied to the message. value_count is the number of elements in the array.
303 */
304void
305GNUNET_DBUS_push_uint64_array (
306 DBusMessage *message,
307 DBusMessageIter *iter,
308 const unsigned char *value,
309 size_t value_count);
310
311/**
312 * Push an array of doubles to a DBusMessage, advancing the iterator. The values
313 * are copied to the message. value_count is the number of elements in the array.
314 */
315void
316GNUNET_DBUS_push_double_array (
317 DBusMessage *message,
318 DBusMessageIter *iter,
319 const unsigned char *value,
320 size_t value_count);
321
322/**
323 * Push binary data to a DBusMessage, advancing the iterator. The data is
324 * copied to the message. value_count is the number of bytes of data. The data
325 * may be represented on-the-wire as either an array of bytes or a base32
326 * encoded string depending on the pretty_encoding flag of the message.
327 */
328void
329GNUNET_DBUS_push_data (
330 DBusMessage *message,
331 DBusMessageIter *iter,
332 const void *value,
333 size_t value_size);
334
335/*
336 * Push a bitfield enum to a DBusMessage, advancing the iterator. A bitfield
337 * enum is an enum where the individual bits represent different flags. See for
338 * example the definition of GNUNET_GNSRECORD_Flags:
339 *
340 * enum GNUNET_GNSRECORD_Flags { GNUNET_GNSRECORD_RF_PRIVATE = 2, //
341 * GNUNET_GNSRECORD_RF_UNUSED = 4, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION =
342 * 8, GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16 }
343 *
344 * Bitfield enums can be sent across the wire in either their integer form (as
345 * a uint32) or as an array of strings depending on the pretty_encoding flag of
346 * the message. Sending an int is more efficient and is what libraries built
347 * around the DBus API would use. People using the DBus API directly via the
348 * command line or a DBus debugger may prefer to receive human-readable strings
349 * for convenience. names is a pointer to a {NULL, 0}-terminated array of
350 * GNUNET_DBUS_StringEnumPair which assigns human-readable names to the
351 * bitfields.
352 */
353void
354GNUNET_DBUS_push_bitfield (
355 DBusMessage *message,
356 DBusMessageIter *iter,
357 const int *value,
358 const struct GNUNET_DBUS_StringEnumPair *fields);
359
360/**
361 * Push an enum to a DBusMessage, advancing the iterator. enums can be sent
362 * across the wire as either a uint32 or as a string depending on the
363 * pretty_encoding flag of the message. Sending a uint32 is more efficient and
364 * is what libraries built around the DBus API would use. People using the DBus
365 * API directly via the command line or a DBus debugger may prefer to receive
366 * human-readable strings for convenience. names is a pointer to a
367 * {NULL, 0}-terminated array of GNUNET_DBUS_StringEnumPair which assigns
368 * human-readable names to the different enum variants.
369 */
370void
371GNUNET_DBUS_push_enum (
372 DBusMessage *message,
373 DBusMessageIter *iter,
374 const int *value,
375 const struct GNUNET_DBUS_StringEnumPair *names);
376
377/**
378 * Push a GNUNET_HashCode to a DBusMessage, advancing the iterator.
379 */
380void
381GNUNET_DBUS_push_hashcode (
382 DBusMessage *message,
383 DBusMessageIter *iter,
384 const struct GNUNET_HashCode *value);
385
386/**
387 * Push a GNUNET_PeerIdentity to a DBusMessage, advancing the iterator.
388 */
389void
390GNUNET_DBUS_push_peer_identity (
391 DBusMessage *message,
392 DBusMessageIter *iter,
393 const struct GNUNET_PeerIdentity *value);
394
395#endif
396
397