forked from enlightenment/efl
edbus: Add example of 2 containners at same level.
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 77007
This commit is contained in:
parent
3cf6418906
commit
9de9bccb9a
|
@ -186,6 +186,7 @@ main(void)
|
||||||
EDBus_Proxy *test2_proxy;
|
EDBus_Proxy *test2_proxy;
|
||||||
EDBus_Pending *pending;
|
EDBus_Pending *pending;
|
||||||
EDBus_Message_Iter *iter, *array_of_string, *variant;
|
EDBus_Message_Iter *iter, *array_of_string, *variant;
|
||||||
|
EDBus_Message_Iter *array_itr, *structure;
|
||||||
EDBus_Message *msg;
|
EDBus_Message *msg;
|
||||||
int size_of_array = 5;
|
int size_of_array = 5;
|
||||||
const char *array[5] = { "aaaa", "bbbb", "cccc", "dddd", "eeee" };
|
const char *array[5] = { "aaaa", "bbbb", "cccc", "dddd", "eeee" };
|
||||||
|
@ -234,6 +235,28 @@ main(void)
|
||||||
pending = edbus_proxy_send(test2_proxy, msg, on_send_variant, NULL, -1);
|
pending = edbus_proxy_send(test2_proxy, msg, on_send_variant, NULL, -1);
|
||||||
edbus_message_unref(msg);
|
edbus_message_unref(msg);
|
||||||
|
|
||||||
|
msg = edbus_proxy_method_call_new(test2_proxy, "DoubleContainner");
|
||||||
|
iter = edbus_message_iter_get(msg);
|
||||||
|
/**
|
||||||
|
* edbus_message_iterator_arguments_set(itr, "a(ii)a(ii)", &array_itr, &array_itr2);
|
||||||
|
* this will cause a error, we could not open another container until
|
||||||
|
* we close the first one
|
||||||
|
*/
|
||||||
|
array_itr = edbus_message_iter_container_new(iter, 'a', "(ii)");
|
||||||
|
edbus_message_iter_arguments_set(array_itr, "(ii)", &structure);
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
edbus_message_iter_arguments_set(structure, "ii", i, i*i);
|
||||||
|
edbus_message_iter_container_close(array_itr, structure);
|
||||||
|
edbus_message_iter_container_close(iter, array_itr);
|
||||||
|
array_itr = edbus_message_iter_container_new(iter, 'a', "(ii)");
|
||||||
|
edbus_message_iter_arguments_set(array_itr, "(ii)", &structure);
|
||||||
|
for (i = 0; i < 7; i++)
|
||||||
|
edbus_message_iter_arguments_set(structure, "ii", i, i*i*i);
|
||||||
|
edbus_message_iter_container_close(array_itr, structure);
|
||||||
|
edbus_message_iter_container_close(iter, array_itr);
|
||||||
|
edbus_proxy_send(test2_proxy, msg, NULL, NULL, -1);
|
||||||
|
edbus_message_unref(msg);
|
||||||
|
|
||||||
pending = edbus_proxy_call(test2_proxy, "SendArrayInt", on_send_array_int, NULL,
|
pending = edbus_proxy_call(test2_proxy, "SendArrayInt", on_send_array_int, NULL,
|
||||||
-1 , "");
|
-1 , "");
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,36 @@ _plus_one(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDBus_Message *
|
||||||
|
_double_container(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
|
||||||
|
{
|
||||||
|
EDBus_Message_Iter *array1, *array2, *structure;
|
||||||
|
int num1, num2;
|
||||||
|
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||||
|
|
||||||
|
if (!edbus_message_arguments_get(msg, "a(ii)a(ii)", &array1, &array2))
|
||||||
|
{
|
||||||
|
printf("Error on edbus_message_arguments_get()\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("DoubleCountainer\nArray1:\n");
|
||||||
|
while (edbus_message_iter_get_and_next(array1, 'r', &structure))
|
||||||
|
{
|
||||||
|
edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
|
||||||
|
printf("1 %d - 2 %d\n", num1, num2);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Array2:\n");
|
||||||
|
while (edbus_message_iter_get_and_next(array2, 'r', &structure))
|
||||||
|
{
|
||||||
|
edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
|
||||||
|
printf("1 %d - 2 %d\n", num1, num2);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return reply;
|
||||||
|
}
|
||||||
|
|
||||||
static EDBus_Message *
|
static EDBus_Message *
|
||||||
_properties_get(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
|
_properties_get(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
|
||||||
{
|
{
|
||||||
|
@ -282,6 +312,10 @@ static const EDBus_Method methods[] = {
|
||||||
"PlusOne", EDBUS_ARGS({"i", "integer"}),
|
"PlusOne", EDBUS_ARGS({"i", "integer"}),
|
||||||
EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one, 0
|
EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one, 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"DoubleContainner", EDBUS_ARGS({"a(ii)", "array1"}, {"a(ii)", "array2"}),
|
||||||
|
EDBUS_ARGS({"", ""}), _double_container, 0
|
||||||
|
},
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue