edbus: Add Variant to Property set function

Patch by: José Roberto de Souza  <zehortigoza@profusion.mobi>



SVN revision: 80696
This commit is contained in:
José Roberto de Souza 2012-12-11 19:50:49 +00:00 committed by Lucas De Marchi
parent 53f9a1cafc
commit 851fcb14ff
3 changed files with 8 additions and 20 deletions

View File

@ -223,19 +223,12 @@ _properties_get(const EDBus_Service_Interface *iface, const char *propname, EDBu
}
static EDBus_Message *
_properties_set(const EDBus_Service_Interface *iface, const char *propname, const EDBus_Message *msg)
_properties_set(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *msg)
{
EDBus_Message *reply;
char *interface, *property, *type, *txt;
EDBus_Message_Iter *variant;
char *type, *txt;
if (!edbus_message_arguments_get(msg, "ssv", &interface, &property, &variant))
{
printf("Error on edbus_message_arguments_get()\n");
return NULL;
}
type = edbus_message_iter_signature_get(variant);
type = edbus_message_iter_signature_get(iter);
if (type[0] != 's')
{
reply = edbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidSignature",
@ -245,7 +238,7 @@ _properties_set(const EDBus_Service_Interface *iface, const char *propname, cons
}
reply = edbus_message_method_return_new(msg);
edbus_message_iter_arguments_get(variant, "s", &txt);
edbus_message_iter_arguments_get(iter, "s", &txt);
printf("Resp2 was set to: %s, previously was: %s\n", txt, resp2);
free(type);
free(resp2);

View File

@ -316,17 +316,12 @@ _cb_property_set(const EDBus_Service_Interface *piface, const EDBus_Message *msg
EDBus_Service_Interface *iface;
Property *prop;
EDBus_Message *reply;
EDBus_Message_Iter *main_iter;
EDBus_Message_Iter *variant;
EDBus_Property_Set_Cb setter = NULL;
main_iter = edbus_message_iter_get(msg);
if (!edbus_message_iter_get_and_next(main_iter, 's', &iface_name) ||
!edbus_message_iter_get_and_next(main_iter, 's', &propname))
if (!edbus_message_arguments_get(msg, "ssv", &iface_name, &propname, &variant))
return NULL;
dbus_message_iter_init(msg->dbus_msg,
&main_iter->dbus_iterator);
iface = eina_hash_find(obj->interfaces, iface_name);
if (!iface)
return edbus_message_error_new(msg, DBUS_ERROR_UNKNOWN_INTERFACE,
@ -346,7 +341,7 @@ _cb_property_set(const EDBus_Service_Interface *piface, const EDBus_Message *msg
return edbus_message_error_new(msg, DBUS_ERROR_PROPERTY_READ_ONLY,
"This property is read only");
reply = setter(iface, propname, msg);
reply = setter(iface, propname, variant, msg);
return reply;
}

View File

@ -59,7 +59,7 @@ typedef Eina_Bool (*EDBus_Property_Get_Cb)(const EDBus_Service_Interface *iface,
*
* @return Message of response, could be a simple method_return, error or NULL to send response later.
*/
typedef EDBus_Message *(*EDBus_Property_Set_Cb)(const EDBus_Service_Interface *iface, const char *propname, const EDBus_Message *input_msg);
typedef EDBus_Message *(*EDBus_Property_Set_Cb)(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *input_msg);
typedef struct _EDBus_Method
{