#define BUS "org.Enlightenment"
#define PATH "/org/enlightenment"
#define INTERFACE "org.enlightenment.Test"
-#define NTESTS 7
-
-static int i = 0;
-static EDBus_Signal_Handler *sh;
+#define NTESTS 8
static void
_on_alive(void *context, const EDBus_Message *msg)
}
static void
-_on_alive2(void *context, const EDBus_Message *msg)
-{
- printf("Alive2\n\n");
- i++;
- if (i == 2)
- edbus_signal_handler_unref(sh);
-}
-
-static void
_on_hello(void *context, const EDBus_Message *msg)
{
- char *txt;
-
+ const char *txt;
if (edbus_message_arguments_get(msg, "s", &txt))
printf("%s\n", txt);
}
test(void)
{
static int n = 0;
-
n++;
- if (n == NTESTS)
+ if (n >= NTESTS)
printf("Passed in all tests\n");
+ else
+ printf("Passed in %d/%d tests\n", n, NTESTS);
}
static void
}
printf("%s\n", str);
-}
-
-static void
-on_name_owner_changed2(void *data, const char *bus, const char *old_id, const char *new_id)
-{
- printf("2 - Bus=%s | old=%s | new=%s\n", bus, old_id, new_id);
+ test();
}
static void
}
static Eina_Bool
-add_name_owner2(void *data)
+finish(void *data)
{
- EDBus_Connection *conn = data;
- edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed2,
- NULL, EINA_TRUE);
- return EINA_FALSE;
+ ecore_main_loop_quit();
+ return ECORE_CALLBACK_CANCEL;
}
int
obj = edbus_object_get(conn, BUS, PATH);
proxy = edbus_proxy_get(obj, INTERFACE);
edbus_proxy_signal_handler_add(proxy, "Alive", _on_alive, NULL);
- sh = edbus_proxy_signal_handler_add(proxy, "Alive", _on_alive2, NULL);
edbus_proxy_signal_handler_add(proxy, "Hello", _on_hello, NULL);
edbus_proxy_call(proxy, "SendBool", _on_send_bool, NULL, -1, "b", bool_value);
edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed,
conn, EINA_TRUE);
- ecore_timer_add(3, add_name_owner2, conn);
+ ecore_timer_add(30, finish, NULL);
ecore_main_loop_begin();
- edbus_name_owner_changed_callback_del(conn, BUS, on_name_owner_changed, conn);
- edbus_name_owner_changed_callback_del(conn, BUS, on_name_owner_changed2,
- NULL);
edbus_connection_unref(conn);
edbus_shutdown();
{
EDBus_Message *reply = edbus_message_method_return_new(msg);
EDBus_Message_Iter *array;
- char *txt;
+ const char *txt;
- printf("receiveArray\n");
+ printf("- receiveArray\n");
if (!edbus_message_arguments_get(msg, "as", &array))
{
printf("Error on edbus_message_arguments_get()\n");
while (edbus_message_iter_get_and_next(array, 's', &txt))
printf("%s\n", txt);
-
- printf("\n");
+ printf("}\n\n");
return reply;
}
_receive_array_of_string_int_with_size(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
{
EDBus_Message *reply = edbus_message_method_return_new(msg);
- EDBus_Message_Iter *array;
- EDBus_Message_Iter *struct_si;
+ EDBus_Message_Iter *array, *struct_si;
int size, i = 0;
- printf("receiveArrayOfStringIntWithSize\n");
+ printf("- receiveArrayOfStringIntWithSize\n{\n");
if (!edbus_message_arguments_get(msg, "ia(si)", &size, &array))
{
printf("Error on edbus_message_arguments_get()\n");
while (edbus_message_iter_get_and_next(array, 'r', &struct_si))
{
- char *txt;
+ const char *txt;
int num;
-
if (!edbus_message_iter_arguments_get(struct_si, "si", &txt, &num))
{
printf("Error on edbus_message_arguments_get()\n");
i++;
}
printf("size in msg %d | size read %d\n", size, i);
- printf("\n");
+ printf("}\n\n");
return reply;
}
EDBus_Message_Iter *variant;
char *type;
- printf("sendVariantData\n");
+ printf("- sendVariantData\n{\n");
if (!edbus_message_arguments_get(msg, "v", &variant))
{
printf("Error on edbus_message_arguments_get()\n");
}
type = edbus_message_iter_signature_get(variant);
- if (type[1] || type[0] == 'v')
+ if (type[1])
{
printf("It is a complex type, not handle yet.\n");
free(type);
}
}
- printf("\n");
+ printf("}\n\n");
free(type);
return reply;
EDBus_Message_Iter *iter, *array;
int i;
- printf("sendArrayInt\n\n");
+ printf("- sendArrayInt\n\n");
iter = edbus_message_iter_get(reply);
array = edbus_message_iter_container_new(iter, 'a', "i");
EDBus_Message *reply = edbus_message_method_return_new(msg);
int num;
- printf("plusOne\n\n");
+ printf("- plusOne\n\n");
if (!edbus_message_arguments_get(msg, "i", &num))
{
printf("Error on edbus_message_arguments_get()\n");
return NULL;
}
- printf("DoubleCountainer\nArray1:\n");
+ printf("DoubleCountainer\n{\nArray1:\n");
while (edbus_message_iter_get_and_next(array1, 'r', &structure))
{
edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
edbus_message_iter_arguments_get(structure, "ii", &num1, &num2);
printf("1 %d - 2 %d\n", num1, num2);
}
- printf("\n");
+ printf("}\n\n");
return reply;
}
if (type[0] != 's')
{
reply = edbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidSignature",
- "Invalid type.");
+ "Invalid type.");
free(type);
return reply;
}
static const EDBus_Method methods[] = {
{
"ReceiveArray", EDBUS_ARGS({"as", "array_of_strings"}),
- NULL, _receive_array, 0
+ NULL, _receive_array
},
{
"ReceiveArrayOfStringIntWithSize",
},
{
"SendVariantData", EDBUS_ARGS({"v", "variant_data"}),
- NULL, _send_variant, 0
+ NULL, _send_variant
},
{
"SendArrayInt", NULL,
},
{
"SendArray", NULL, EDBUS_ARGS({"as", "array_string"}),
- _send_array, 0
+ _send_array
},
{
"PlusOne", EDBUS_ARGS({"i", "integer"}),
- EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one, 0
+ EDBUS_ARGS({"i", "integer_plus_one"}), _plus_one
},
{
"DoubleContainner", EDBUS_ARGS({"a(ii)", "array1"}, {"a(ii)", "array2"}),
- NULL, _double_container, 0
+ NULL, _double_container
},
{ }
};
static const EDBus_Property properties[] = {
{ "Resp2", "s", NULL, _properties_set },
- { "text", "s", NULL, NULL },
- { "int32", "i", NULL, NULL },
- { "st", "(ss)", NULL, NULL},
+ { "text", "s" },
+ { "int32", "i" },
+ { "st", "(ss)" },
{ }
};
EDBus_Service_Interface *iface = data;
edbus_service_property_changed(iface, "int32");
edbus_service_property_invalidate_set(iface, "Resp2", EINA_TRUE);
- return EINA_TRUE;
+ return ECORE_CALLBACK_RENEW;
}
static void
#define PATH_TEST_SON "/org/enlightenment/son"
#define INTERFACE "org.enlightenment.Test"
-EDBus_Connection *conn;
+static EDBus_Connection *conn;
static EDBus_Message *
_hello(const EDBus_Service_Interface *iface, const EDBus_Message *message)
_send_string(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
{
EDBus_Message *reply = edbus_message_method_return_new(msg);
- char *txt;
+ const char *txt;
if (!edbus_message_arguments_get(msg, "s", &txt))
printf("edbus_message_arguments_get() error\n");
edbus_message_arguments_set(reply, "s", txt);
EDBus_Message *reply = edbus_message_method_return_new(msg);
printf("Received a call to AsyncTest.\n");
printf("Response will be send in 5 seconds.\n");
- ecore_timer_add (5, _resp_async, reply);
+ ecore_timer_add(5, _resp_async, reply);
return NULL;
}
static const EDBus_Method methods[] = {
{
"Hello", NULL, EDBUS_ARGS({"s", "message"}),
- _hello, 0
+ _hello
},
{
"Quit", NULL, NULL,
_quit, EDBUS_METHOD_FLAG_DEPRECATED
},
{ "SendBool", EDBUS_ARGS({"b", "bool"}), EDBUS_ARGS({"b", "bool"}),
- _send_bool, 0
+ _send_bool
},
{ "SendByte", EDBUS_ARGS({"y", "byte"}), EDBUS_ARGS({"y", "byte"}),
- _send_byte, 0
+ _send_byte
},
{ "SendUint32", EDBUS_ARGS({"u", "uint32"}), EDBUS_ARGS({"u", "uint32"}),
- _send_uint32, 0
+ _send_uint32
},
{ "SendInt32", EDBUS_ARGS({"i", "int32"}), EDBUS_ARGS({"i", "int32"}),
- _send_int32, 0
+ _send_int32
},
{ "SendInt16", EDBUS_ARGS({"n", "int16"}), EDBUS_ARGS({"n", "int16"}),
- _send_int16, 0
+ _send_int16
},
{ "SendDouble", EDBUS_ARGS({"d", "double"}), EDBUS_ARGS({"d", "double"}),
- _send_double, 0
+ _send_double
},
{ "SendString", EDBUS_ARGS({"s", "string"}), EDBUS_ARGS({"s", "string"}),
- _send_string, 0
+ _send_string
},
{ "AsyncTest", NULL, EDBUS_ARGS({"s", "text"}),
- _async_test, 0
+ _async_test
},
{ }
};