summaryrefslogtreecommitdiff
path: root/legacy/edbus
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2012-09-21 22:44:17 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-09-21 22:44:17 +0000
commit9de9bccb9a5423631db9bb0e257f854a0d41ab43 (patch)
tree5169236b3cd14cded1befef19d821fed92c94826 /legacy/edbus
parent3cf641890617f51b39886476e5dd1bd10117ca0a (diff)
edbus: Add example of 2 containners at same level.
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 77007
Diffstat (limited to 'legacy/edbus')
-rw-r--r--legacy/edbus/src/examples/complex_types.c23
-rw-r--r--legacy/edbus/src/examples/complex_types_server.c34
2 files changed, 57 insertions, 0 deletions
diff --git a/legacy/edbus/src/examples/complex_types.c b/legacy/edbus/src/examples/complex_types.c
index 4cdcf211d7..b9aef034aa 100644
--- a/legacy/edbus/src/examples/complex_types.c
+++ b/legacy/edbus/src/examples/complex_types.c
@@ -186,6 +186,7 @@ main(void)
186 EDBus_Proxy *test2_proxy; 186 EDBus_Proxy *test2_proxy;
187 EDBus_Pending *pending; 187 EDBus_Pending *pending;
188 EDBus_Message_Iter *iter, *array_of_string, *variant; 188 EDBus_Message_Iter *iter, *array_of_string, *variant;
189 EDBus_Message_Iter *array_itr, *structure;
189 EDBus_Message *msg; 190 EDBus_Message *msg;
190 int size_of_array = 5; 191 int size_of_array = 5;
191 const char *array[5] = { "aaaa", "bbbb", "cccc", "dddd", "eeee" }; 192 const char *array[5] = { "aaaa", "bbbb", "cccc", "dddd", "eeee" };
@@ -234,6 +235,28 @@ main(void)
234 pending = edbus_proxy_send(test2_proxy, msg, on_send_variant, NULL, -1); 235 pending = edbus_proxy_send(test2_proxy, msg, on_send_variant, NULL, -1);
235 edbus_message_unref(msg); 236 edbus_message_unref(msg);
236 237
238 msg = edbus_proxy_method_call_new(test2_proxy, "DoubleContainner");
239 iter = edbus_message_iter_get(msg);
240 /**
241 * edbus_message_iterator_arguments_set(itr, "a(ii)a(ii)", &array_itr, &array_itr2);
242 * this will cause a error, we could not open another container until
243 * we close the first one
244 */
245 array_itr = edbus_message_iter_container_new(iter, 'a', "(ii)");
246 edbus_message_iter_arguments_set(array_itr, "(ii)", &structure);
247 for (i = 0; i < 5; i++)
248 edbus_message_iter_arguments_set(structure, "ii", i, i*i);
249 edbus_message_iter_container_close(array_itr, structure);
250 edbus_message_iter_container_close(iter, array_itr);
251 array_itr = edbus_message_iter_container_new(iter, 'a', "(ii)");
252 edbus_message_iter_arguments_set(array_itr, "(ii)", &structure);
253 for (i = 0; i < 7; i++)
254 edbus_message_iter_arguments_set(structure, "ii", i, i*i*i);
255 edbus_message_iter_container_close(array_itr, structure);
256 edbus_message_iter_container_close(iter, array_itr);
257 edbus_proxy_send(test2_proxy, msg, NULL, NULL, -1);
258 edbus_message_unref(msg);
259
237 pending = edbus_proxy_call(test2_proxy, "SendArrayInt", on_send_array_int, NULL, 260 pending = edbus_proxy_call(test2_proxy, "SendArrayInt", on_send_array_int, NULL,
238 -1 , ""); 261 -1 , "");
239 262
diff --git a/legacy/edbus/src/examples/complex_types_server.c b/legacy/edbus/src/examples/complex_types_server.c
index 5acd50e52f..acf3dfae95 100644
--- a/legacy/edbus/src/examples/complex_types_server.c
+++ b/legacy/edbus/src/examples/complex_types_server.c
@@ -170,6 +170,36 @@ _plus_one(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
170} 170}
171 171
172static EDBus_Message * 172static EDBus_Message *
173_double_container(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
174{
175 EDBus_Message_Iter *array1, *array2, *structure;
176 int num1, num2;
177 EDBus_Message *reply = edbus_message_method_return_new(msg);
178
179 if (!edbus_message_arguments_get(msg, "a(ii)a(ii)", &array1, &array2))
180 {
181 printf("Error on edbus_message_arguments_get()\n");
182 return NULL;
183 }
184
185 printf("DoubleCountainer\nArray1:\n");
186 while (edbus_message_iter_get_and_next(array1, 'r', &structure))
187 {
188 edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
189 printf("1 %d - 2 %d\n", num1, num2);
190 }
191
192 printf("Array2:\n");
193 while (edbus_message_iter_get_and_next(array2, 'r', &structure))
194 {
195 edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
196 printf("1 %d - 2 %d\n", num1, num2);
197 }
198 printf("\n");
199 return reply;
200}
201
202static EDBus_Message *
173_properties_get(const EDBus_Service_Interface *iface, const EDBus_Message *msg) 203_properties_get(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
174{ 204{
175 EDBus_Message *reply; 205 EDBus_Message *reply;
@@ -282,6 +312,10 @@ static const EDBus_Method methods[] = {
282 "PlusOne", EDBUS_ARGS({"i", "integer"}), 312 "PlusOne", EDBUS_ARGS({"i", "integer"}),
283 EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one, 0 313 EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one, 0
284 }, 314 },
315 {
316 "DoubleContainner", EDBUS_ARGS({"a(ii)", "array1"}, {"a(ii)", "array2"}),
317 EDBUS_ARGS({"", ""}), _double_container, 0
318 },
285 { } 319 { }
286}; 320};
287 321