aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2012-11-16 13:06:53 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-16 13:06:53 +0000
commit7c2d19fce28928e5cb5e146b7f8f17e305ee5482 (patch)
treee7d6de3ae7ad21bf5a6bb8f7452328738383ff10
parentevas: cleanup (diff)
downloadefl-7c2d19fce28928e5cb5e146b7f8f17e305ee5482.tar.gz
edbus: Add input message to get property function
Without this message, it's not possible for user create the error message. Also update the docs to clarify usage of the Get/Set callbacks. Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 79380
-rw-r--r--legacy/edbus/src/examples/complex_types_server.c2
-rw-r--r--legacy/edbus/src/lib/edbus_service.c21
-rw-r--r--legacy/edbus/src/lib/edbus_service.h29
3 files changed, 39 insertions, 13 deletions
diff --git a/legacy/edbus/src/examples/complex_types_server.c b/legacy/edbus/src/examples/complex_types_server.c
index 26633d924d..5ba149f51c 100644
--- a/legacy/edbus/src/examples/complex_types_server.c
+++ b/legacy/edbus/src/examples/complex_types_server.c
@@ -203,7 +203,7 @@ _double_container(const EDBus_Service_Interface *iface, const EDBus_Message *msg
}
static Eina_Bool
-_properties_get(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, EDBus_Message **error)
+_properties_get(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *request_msg, EDBus_Message **error)
{
printf("Properties_get - %s\n", propname);
if (!strcmp(propname, "Resp2"))
diff --git a/legacy/edbus/src/lib/edbus_service.c b/legacy/edbus/src/lib/edbus_service.c
index 2df6e6e630..54f21b2b42 100644
--- a/legacy/edbus/src/lib/edbus_service.c
+++ b/legacy/edbus/src/lib/edbus_service.c
@@ -216,7 +216,7 @@ _cb_property_get(const EDBus_Service_Interface *piface, const EDBus_Message *msg
variant = edbus_message_iter_container_new(main_iter, 'v',
prop->property->type);
- ret = getter(iface, propname, variant, &error_reply);
+ ret = getter(iface, propname, variant, msg, &error_reply);
if (ret)
{
@@ -282,7 +282,7 @@ _cb_property_getall(const EDBus_Service_Interface *piface, const EDBus_Message *
var = edbus_message_iter_container_new(entry, 'v',
prop->property->type);
- ret = getter(iface, prop->property->name, var, &error_reply);
+ ret = getter(iface, prop->property->name, var, msg, &error_reply);
if (!ret)
{
@@ -1034,7 +1034,7 @@ _idler_propschanged(void *data)
while ((prop = eina_array_pop(iface->props_changed)))
{
EDBus_Message_Iter *entry, *var;
- EDBus_Message *error_reply;
+ EDBus_Message *error_reply = NULL;
Eina_Bool ret;
EDBus_Property_Get_Cb getter = NULL;
@@ -1057,17 +1057,16 @@ _idler_propschanged(void *data)
var = edbus_message_iter_container_new(entry, 'v',
prop->property->type);
- ret = getter(iface, prop->property->name, var, &error_reply);
-
+ ret = getter(iface, prop->property->name, var, NULL, &error_reply);
if (!ret)
{
- const char *errorname, *errormsg;
- if (error_reply &&
- edbus_message_error_get(error_reply, &errorname, &errormsg))
- ERR("%s %s", errorname, errormsg);
-
edbus_message_unref(msg);
- if (error_reply) edbus_message_unref(error_reply);
+ if (error_reply)
+ {
+ ERR("Error reply was set without pass any input message.");
+ edbus_message_unref(error_reply);
+ }
+ ERR("Getter of property %s returned error.", prop->property->name);
goto error;
}
diff --git a/legacy/edbus/src/lib/edbus_service.h b/legacy/edbus/src/lib/edbus_service.h
index d20700316f..415c366668 100644
--- a/legacy/edbus/src/lib/edbus_service.h
+++ b/legacy/edbus/src/lib/edbus_service.h
@@ -31,7 +31,34 @@ typedef struct _EDBus_Arg_Info
typedef struct _EDBus_Service_Interface EDBus_Service_Interface;
typedef EDBus_Message * (*EDBus_Method_Cb)(const EDBus_Service_Interface *iface, const EDBus_Message *message);
-typedef Eina_Bool (*EDBus_Property_Get_Cb)(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, EDBus_Message **error);
+/**
+ * Callback function to append property value to message.
+ *
+ * @param iface interface of property
+ * @param propname name of property
+ * @param iter variant iterator in which value must be appended
+ * @param request_msg message that request property
+ * @param error if a error happen you must set a message error to be send caller
+ *
+ * @return EINA_TRUE if success
+ *
+ * @note request_msg and error arguments are only different from NULL when a
+ * client request a property with Properties.Get or Properties.GetAll. Upon
+ * calls to edbus_service_property_changed(), this callback will also be called.
+ * It's a mistake to return an error in this case because if a property changed,
+ * it must have a new value set and it should be able to be read.
+ */
+typedef Eina_Bool (*EDBus_Property_Get_Cb)(const EDBus_Service_Interface *iface, const char *propname, EDBus_Message_Iter *iter, const EDBus_Message *request_msg, EDBus_Message **error);
+
+/**
+ * Callback function to set property value from message.
+ *
+ * @param iface interface of property
+ * @param propname name of property
+ * @param input_msg message call where you have to get value
+ *
+ * @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 struct _EDBus_Method