printf("resp2=%s\n", resp2);
free(type);
- edbus_proxy_property_set(proxy, "Resp2", 's', "lalala", set_property_resp2, NULL);
+ edbus_proxy_property_set(proxy, "Resp2", "s", &"lalala", set_property_resp2, NULL);
+ edbus_proxy_property_set(proxy, "int32", "i", (void*)(intptr_t)99, set_property_resp2, NULL);
}
static void
static EDBus_Message *
_properties_set(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *msg)
{
- EDBus_Message *reply;
- char *type, *txt;
+ char *type;
type = edbus_message_iter_signature_get(iter);
- if (type[0] != 's')
+
+ if (!strcmp(propname, "int32"))
{
- reply = edbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidSignature",
- "Invalid type.");
- free(type);
- return reply;
+ int num;
+ if (type[0] != 'i')
+ goto invalid_signature;
+ edbus_message_iter_arguments_get(iter, "i", &num);
+ printf("int32 was set to: %d, previously was: %d\n", num, int32);
+ int32 = num;
+ }
+ else if (!strcmp(propname, "Resp2"))
+ {
+ const char *txt;
+ if (type[0] != 's')
+ goto invalid_signature;
+ edbus_message_iter_arguments_get(iter, "s", &txt);
+ printf("Resp2 was set to: %s, previously was: %s\n", txt, resp2);
+ free(resp2);
+ resp2 = strdup(txt);
}
-
- reply = edbus_message_method_return_new(msg);
- edbus_message_iter_arguments_get(iter, "s", &txt);
- printf("Resp2 was set to: %s, previously was: %s\n", txt, resp2);
free(type);
- free(resp2);
- resp2 = strdup(txt);
- edbus_service_property_changed(iface, propname);
+ return edbus_message_method_return_new(msg);
- return reply;
+invalid_signature:
+ free(type);
+ return edbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidSignature",
+ "Invalid type.");
}
static const EDBus_Method methods[] = {
static const EDBus_Property properties[] = {
{ "Resp2", "s", NULL, _properties_set },
{ "text", "s" },
- { "int32", "i" },
+ { "int32", "i", NULL, _properties_set },
{ "st", "(ss)" },
{ }
};
unsigned int reply;
EDBus_Service_Interface *iface = data;
- resp2 = malloc(sizeof(char) * 5);
- strcpy(resp2, "test");
-
if (edbus_message_error_get(msg, NULL, NULL))
{
printf("error on on_name_request\n");
conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION);
+ resp2 = malloc(sizeof(char) * 5);
+ strcpy(resp2, "test");
iface = edbus_service_interface_register(conn, PATH, &iface_desc);
edbus_name_request(conn, BUS, EDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE,
on_name_request, iface);
EAPI void edbus_proxy_properties_monitor(EDBus_Proxy *proxy, Eina_Bool enable) EINA_ARG_NONNULL(1);
EAPI EDBus_Pending *edbus_proxy_property_get(EDBus_Proxy *proxy, const char *name, EDBus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI EDBus_Pending *edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, char type, const void *value, EDBus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 4);
+EAPI EDBus_Pending *edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, const char *sig, const void *value, EDBus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3, 4);
EAPI EDBus_Pending *edbus_proxy_property_get_all(EDBus_Proxy *proxy, EDBus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2);
EAPI EDBus_Signal_Handler *edbus_proxy_properties_changed_callback_add(EDBus_Proxy *proxy, EDBus_Signal_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2);
}
EAPI EDBus_Pending *
-edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, char type, const void *value, EDBus_Message_Cb cb, const void *data)
+edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, const char *sig, const void *value, EDBus_Message_Cb cb, const void *data)
{
EDBus_Message *msg;
EDBus_Message_Iter *iter, *variant;
EDBus_Pending *pending;
- char sig[2];
+
EDBUS_PROXY_CHECK_RETVAL(proxy, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sig, NULL);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(dbus_signature_validate_single(sig, NULL), NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
- if (!dbus_type_is_basic(type))
- {
- ERR("Only basic types may be set using edbus_proxy_property_set()");
- return NULL;
- }
-
- sig[0] = type;
- sig[1] = 0;
msg = edbus_proxy_method_call_new(proxy->obj->properties, "Set");
iter = edbus_message_iter_get(msg);
edbus_message_iter_basic_append(iter, 's', proxy->interface);
edbus_message_iter_basic_append(iter, 's', name);
variant = edbus_message_iter_container_new(iter, 'v', sig);
- edbus_message_iter_basic_append(variant, type, value);
+ if (dbus_type_is_basic(sig[0]))
+ dbus_message_iter_append_basic(&variant->dbus_iterator, sig[0], &value);
+ else
+ {
+ if (!_message_iter_from_eina_value_struct(sig, variant, value))
+ {
+ edbus_message_unref(msg);
+ return NULL;
+ }
+ }
edbus_message_iter_container_close(iter, variant);
pending = edbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);