diff options
Diffstat (limited to 'meta/packages/dbus/dbus/dbussend.patch')
-rw-r--r-- | meta/packages/dbus/dbus/dbussend.patch | 399 |
1 files changed, 399 insertions, 0 deletions
diff --git a/meta/packages/dbus/dbus/dbussend.patch b/meta/packages/dbus/dbus/dbussend.patch new file mode 100644 index 0000000000..49a251bbb0 --- /dev/null +++ b/meta/packages/dbus/dbus/dbussend.patch | |||
@@ -0,0 +1,399 @@ | |||
1 | Index: dbus-send.1 | ||
2 | =================================================================== | ||
3 | --- tools/dbus-send.1 (revision 691) | ||
4 | +++ tools/dbus-send.1 (working copy) | ||
5 | @@ -36,8 +36,8 @@ | ||
6 | specified. Following arguments, if any, are the message contents | ||
7 | (message arguments). These are given as a type name, a colon, and | ||
8 | then the value of the argument. The possible type names are: string, | ||
9 | -int32, uint32, double, byte, boolean. (D-BUS supports more types than | ||
10 | -these, but \fIdbus-send\fP currently does not.) | ||
11 | +int32, uint32, double, byte, boolean, array. (D-BUS supports more types | ||
12 | +than these, but \fIdbus-send\fP currently does not.) | ||
13 | |||
14 | .PP | ||
15 | Here is an example invocation: | ||
16 | @@ -46,7 +46,8 @@ | ||
17 | dbus-send \-\-dest='org.freedesktop.ExampleService' \\ | ||
18 | /org/freedesktop/sample/object/name \\ | ||
19 | org.freedesktop.ExampleInterface.ExampleMethod \\ | ||
20 | - int32:47 string:'hello world' double:65.32 | ||
21 | + int32:47 string:'hello world' double:65.32 \\ | ||
22 | + array:byte[0,1,2] | ||
23 | |||
24 | .fi | ||
25 | |||
26 | Index: dbus-print-message.c | ||
27 | =================================================================== | ||
28 | --- tools/dbus-print-message.c (revision 691) | ||
29 | +++ tools/dbus-print-message.c (working copy) | ||
30 | @@ -39,6 +39,78 @@ | ||
31 | } | ||
32 | } | ||
33 | |||
34 | +static void | ||
35 | +iterate (DBusMessageIter* iter, int entry_type) | ||
36 | +{ | ||
37 | + do | ||
38 | + { | ||
39 | + char *str; | ||
40 | + dbus_uint32_t uint32; | ||
41 | + dbus_int32_t int32; | ||
42 | + double d; | ||
43 | + unsigned char byte; | ||
44 | + dbus_bool_t boolean; | ||
45 | + int type = dbus_message_iter_get_arg_type (iter); | ||
46 | + | ||
47 | + DBusMessageIter array_iter; | ||
48 | + int array_type = DBUS_TYPE_INVALID; | ||
49 | + | ||
50 | + if (type == DBUS_TYPE_INVALID) | ||
51 | + { | ||
52 | + if (entry_type == DBUS_TYPE_INVALID) | ||
53 | + break; | ||
54 | + else | ||
55 | + type == entry_type; | ||
56 | + } | ||
57 | + | ||
58 | + switch (type) | ||
59 | + { | ||
60 | + case DBUS_TYPE_STRING: | ||
61 | + str = dbus_message_iter_get_string (iter); | ||
62 | + printf ("string:%s\n", str); | ||
63 | + break; | ||
64 | + | ||
65 | + case DBUS_TYPE_INT32: | ||
66 | + int32 = dbus_message_iter_get_int32 (iter); | ||
67 | + printf ("int32:%d\n", int32); | ||
68 | + break; | ||
69 | + | ||
70 | + case DBUS_TYPE_UINT32: | ||
71 | + uint32 = dbus_message_iter_get_uint32 (iter); | ||
72 | + printf ("int32:%u\n", uint32); | ||
73 | + break; | ||
74 | + | ||
75 | + case DBUS_TYPE_DOUBLE: | ||
76 | + d = dbus_message_iter_get_double (iter); | ||
77 | + printf ("double:%f\n", d); | ||
78 | + break; | ||
79 | + | ||
80 | + case DBUS_TYPE_BYTE: | ||
81 | + byte = dbus_message_iter_get_byte (iter); | ||
82 | + printf ("byte:%d\n", byte); | ||
83 | + break; | ||
84 | + | ||
85 | + case DBUS_TYPE_BOOLEAN: | ||
86 | + boolean = dbus_message_iter_get_boolean (iter); | ||
87 | + printf ("boolean:%s\n", boolean ? "true" : "false"); | ||
88 | + break; | ||
89 | + | ||
90 | + case DBUS_TYPE_ARRAY: | ||
91 | + dbus_message_iter_init_array_iterator (iter, | ||
92 | + &array_iter, | ||
93 | + &array_type); | ||
94 | + printf ("array[\n"); | ||
95 | + iterate (&array_iter, array_type); | ||
96 | + printf ("]\n"); | ||
97 | + break; | ||
98 | + | ||
99 | + default: | ||
100 | + printf ("(unknown arg type %d)\n", type); | ||
101 | + break; | ||
102 | + } | ||
103 | + } while (dbus_message_iter_next (iter)); | ||
104 | +} | ||
105 | + | ||
106 | void | ||
107 | print_message (DBusMessage *message) | ||
108 | { | ||
109 | @@ -81,55 +153,6 @@ | ||
110 | |||
111 | dbus_message_iter_init (message, &iter); | ||
112 | |||
113 | - do | ||
114 | - { | ||
115 | - int type = dbus_message_iter_get_arg_type (&iter); | ||
116 | - char *str; | ||
117 | - dbus_uint32_t uint32; | ||
118 | - dbus_int32_t int32; | ||
119 | - double d; | ||
120 | - unsigned char byte; | ||
121 | - dbus_bool_t boolean; | ||
122 | - | ||
123 | - if (type == DBUS_TYPE_INVALID) | ||
124 | - break; | ||
125 | - | ||
126 | - switch (type) | ||
127 | - { | ||
128 | - case DBUS_TYPE_STRING: | ||
129 | - str = dbus_message_iter_get_string (&iter); | ||
130 | - printf ("string:%s\n", str); | ||
131 | - break; | ||
132 | - | ||
133 | - case DBUS_TYPE_INT32: | ||
134 | - int32 = dbus_message_iter_get_int32 (&iter); | ||
135 | - printf ("int32:%d\n", int32); | ||
136 | - break; | ||
137 | - | ||
138 | - case DBUS_TYPE_UINT32: | ||
139 | - uint32 = dbus_message_iter_get_uint32 (&iter); | ||
140 | - printf ("int32:%u\n", uint32); | ||
141 | - break; | ||
142 | - | ||
143 | - case DBUS_TYPE_DOUBLE: | ||
144 | - d = dbus_message_iter_get_double (&iter); | ||
145 | - printf ("double:%f\n", d); | ||
146 | - break; | ||
147 | - | ||
148 | - case DBUS_TYPE_BYTE: | ||
149 | - byte = dbus_message_iter_get_byte (&iter); | ||
150 | - printf ("byte:%d\n", byte); | ||
151 | - break; | ||
152 | - | ||
153 | - case DBUS_TYPE_BOOLEAN: | ||
154 | - boolean = dbus_message_iter_get_boolean (&iter); | ||
155 | - printf ("boolean:%s\n", boolean ? "true" : "false"); | ||
156 | - break; | ||
157 | - | ||
158 | - default: | ||
159 | - printf ("(unknown arg type %d)\n", type); | ||
160 | - break; | ||
161 | - } | ||
162 | - } while (dbus_message_iter_next (&iter)); | ||
163 | + iterate (&iter, DBUS_TYPE_INVALID); | ||
164 | } | ||
165 | |||
166 | Index: dbus-send.c | ||
167 | =================================================================== | ||
168 | --- tools/dbus-send.c (revision 691) | ||
169 | +++ tools/dbus-send.c (working copy) | ||
170 | @@ -34,6 +34,146 @@ | ||
171 | exit (ecode); | ||
172 | } | ||
173 | |||
174 | + | ||
175 | +static int | ||
176 | +get_type (char **argv, char *arg) | ||
177 | +{ | ||
178 | + int type; | ||
179 | + | ||
180 | + if (arg[0] == 0 || !strcmp (arg, "string")) | ||
181 | + type = DBUS_TYPE_STRING; | ||
182 | + else if (!strcmp (arg, "int32")) | ||
183 | + type = DBUS_TYPE_INT32; | ||
184 | + else if (!strcmp (arg, "uint32")) | ||
185 | + type = DBUS_TYPE_UINT32; | ||
186 | + else if (!strcmp (arg, "double")) | ||
187 | + type = DBUS_TYPE_DOUBLE; | ||
188 | + else if (!strcmp (arg, "byte")) | ||
189 | + type = DBUS_TYPE_BYTE; | ||
190 | + else if (!strcmp (arg, "boolean")) | ||
191 | + type = DBUS_TYPE_BOOLEAN; | ||
192 | + else if (!strcmp (arg, "array")) | ||
193 | + type = DBUS_TYPE_ARRAY; | ||
194 | + else | ||
195 | + { | ||
196 | + fprintf (stderr, "%s: Unknown type \"%s\"\n", argv[0], arg); | ||
197 | + exit (1); | ||
198 | + } | ||
199 | + | ||
200 | + return type; | ||
201 | +} | ||
202 | + | ||
203 | + | ||
204 | +static void | ||
205 | +append (char **argv, char *arg, char *c, DBusMessageIter *iter) | ||
206 | +{ | ||
207 | + int type, atype = 0; | ||
208 | + dbus_uint32_t uint32; | ||
209 | + dbus_int32_t int32; | ||
210 | + double d; | ||
211 | + unsigned char byte; | ||
212 | + DBusMessageIter array_iter; | ||
213 | + int end_found = 0; | ||
214 | + char *next; | ||
215 | + | ||
216 | + /* FIXME - we are ignoring OOM returns on all these functions */ | ||
217 | + | ||
218 | + type = get_type(argv, arg); | ||
219 | + if (type == DBUS_TYPE_ARRAY) | ||
220 | + { | ||
221 | + arg = c; | ||
222 | + c = strchr (c, '['); | ||
223 | + if (c == NULL) | ||
224 | + { | ||
225 | + fprintf (stderr, "%s: Data item \"%s\" is badly formed\n", argv[0], arg); | ||
226 | + exit (1); | ||
227 | + } | ||
228 | + | ||
229 | + if (strchr(c, ']') == NULL) | ||
230 | + { | ||
231 | + fprintf (stderr, "%s: Data item \"%s\" is badly formed\n", argv[0], arg); | ||
232 | + exit (1); | ||
233 | + } | ||
234 | + | ||
235 | + *(c++) = 0; | ||
236 | + | ||
237 | + atype = get_type(argv, arg); | ||
238 | + } | ||
239 | + | ||
240 | + | ||
241 | + switch (type) | ||
242 | + { | ||
243 | + case DBUS_TYPE_BYTE: | ||
244 | + byte = strtoul (c, NULL, 0); | ||
245 | + dbus_message_iter_append_byte (iter, byte); | ||
246 | + break; | ||
247 | + | ||
248 | + case DBUS_TYPE_DOUBLE: | ||
249 | + d = strtod (c, NULL); | ||
250 | + dbus_message_iter_append_double (iter, d); | ||
251 | + break; | ||
252 | + | ||
253 | + case DBUS_TYPE_INT32: | ||
254 | + int32 = strtol (c, NULL, 0); | ||
255 | + dbus_message_iter_append_int32 (iter, int32); | ||
256 | + break; | ||
257 | + | ||
258 | + case DBUS_TYPE_UINT32: | ||
259 | + uint32 = strtoul (c, NULL, 0); | ||
260 | + dbus_message_iter_append_uint32 (iter, uint32); | ||
261 | + break; | ||
262 | + | ||
263 | + case DBUS_TYPE_STRING: | ||
264 | + dbus_message_iter_append_string (iter, c); | ||
265 | + break; | ||
266 | + | ||
267 | + case DBUS_TYPE_BOOLEAN: | ||
268 | + if (strcmp(c, "true") == 0) | ||
269 | + dbus_message_iter_append_boolean (iter, TRUE); | ||
270 | + else if (strcmp(c, "false") == 0) | ||
271 | + dbus_message_iter_append_boolean (iter, FALSE); | ||
272 | + else | ||
273 | + { | ||
274 | + fprintf (stderr, "%s: Expected \"true\" or \"false\" instead of \"%s\"\n", argv[0], c); | ||
275 | + exit (1); | ||
276 | + } | ||
277 | + break; | ||
278 | + | ||
279 | + case DBUS_TYPE_ARRAY: | ||
280 | + /* Decompose parameters and put it as array */ | ||
281 | + dbus_message_iter_append_array(iter, &array_iter, atype); | ||
282 | + | ||
283 | + while(!end_found) | ||
284 | + { | ||
285 | + next = strchr(c, ','); | ||
286 | + if (next == NULL) | ||
287 | + { | ||
288 | + next = strchr(c, ']'); | ||
289 | + | ||
290 | + if (next != NULL) | ||
291 | + next[0] = 0; | ||
292 | + else | ||
293 | + break; | ||
294 | + | ||
295 | + end_found = 1; | ||
296 | + } | ||
297 | + else | ||
298 | + { | ||
299 | + next[0] = 0; | ||
300 | + next++; | ||
301 | + } | ||
302 | + | ||
303 | + append (argv, arg, c, &array_iter); | ||
304 | + c = next; | ||
305 | + } | ||
306 | + break; | ||
307 | + | ||
308 | + default: | ||
309 | + fprintf (stderr, "%s: Unsupported data type\n", argv[0]); | ||
310 | + exit (1); | ||
311 | + } | ||
312 | +} | ||
313 | + | ||
314 | int | ||
315 | main (int argc, char *argv[]) | ||
316 | { | ||
317 | @@ -174,12 +314,7 @@ | ||
318 | { | ||
319 | char *arg; | ||
320 | char *c; | ||
321 | - int type; | ||
322 | - dbus_uint32_t uint32; | ||
323 | - dbus_int32_t int32; | ||
324 | - double d; | ||
325 | - unsigned char byte; | ||
326 | - | ||
327 | + | ||
328 | type = DBUS_TYPE_INVALID; | ||
329 | arg = argv[i++]; | ||
330 | c = strchr (arg, ':'); | ||
331 | @@ -192,67 +327,7 @@ | ||
332 | |||
333 | *(c++) = 0; | ||
334 | |||
335 | - if (arg[0] == 0 || !strcmp (arg, "string")) | ||
336 | - type = DBUS_TYPE_STRING; | ||
337 | - else if (!strcmp (arg, "int32")) | ||
338 | - type = DBUS_TYPE_INT32; | ||
339 | - else if (!strcmp (arg, "uint32")) | ||
340 | - type = DBUS_TYPE_UINT32; | ||
341 | - else if (!strcmp (arg, "double")) | ||
342 | - type = DBUS_TYPE_DOUBLE; | ||
343 | - else if (!strcmp (arg, "byte")) | ||
344 | - type = DBUS_TYPE_BYTE; | ||
345 | - else if (!strcmp (arg, "boolean")) | ||
346 | - type = DBUS_TYPE_BOOLEAN; | ||
347 | - else | ||
348 | - { | ||
349 | - fprintf (stderr, "%s: Unknown type \"%s\"\n", argv[0], arg); | ||
350 | - exit (1); | ||
351 | - } | ||
352 | - | ||
353 | - /* FIXME - we are ignoring OOM returns on all these functions */ | ||
354 | - switch (type) | ||
355 | - { | ||
356 | - case DBUS_TYPE_BYTE: | ||
357 | - byte = strtoul (c, NULL, 0); | ||
358 | - dbus_message_iter_append_byte (&iter, byte); | ||
359 | - break; | ||
360 | - | ||
361 | - case DBUS_TYPE_DOUBLE: | ||
362 | - d = strtod (c, NULL); | ||
363 | - dbus_message_iter_append_double (&iter, d); | ||
364 | - break; | ||
365 | - | ||
366 | - case DBUS_TYPE_INT32: | ||
367 | - int32 = strtol (c, NULL, 0); | ||
368 | - dbus_message_iter_append_int32 (&iter, int32); | ||
369 | - break; | ||
370 | - | ||
371 | - case DBUS_TYPE_UINT32: | ||
372 | - uint32 = strtoul (c, NULL, 0); | ||
373 | - dbus_message_iter_append_uint32 (&iter, uint32); | ||
374 | - break; | ||
375 | - | ||
376 | - case DBUS_TYPE_STRING: | ||
377 | - dbus_message_iter_append_string (&iter, c); | ||
378 | - break; | ||
379 | - | ||
380 | - case DBUS_TYPE_BOOLEAN: | ||
381 | - if (strcmp(c, "true") == 0) | ||
382 | - dbus_message_iter_append_boolean (&iter, TRUE); | ||
383 | - else if (strcmp(c, "false") == 0) | ||
384 | - dbus_message_iter_append_boolean (&iter, FALSE); | ||
385 | - else | ||
386 | - { | ||
387 | - fprintf (stderr, "%s: Expected \"true\" or \"false\" instead of \"%s\"\n", argv[0], c); | ||
388 | - exit (1); | ||
389 | - } | ||
390 | - break; | ||
391 | - | ||
392 | - default: | ||
393 | - fprintf (stderr, "%s: Unsupported data type\n", argv[0]); | ||
394 | - exit (1); | ||
395 | - } | ||
396 | + append (argv, arg, c, &iter); | ||
397 | } | ||
398 | |||
399 | if (print_reply) | ||