All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] dbus-service: Allow property setters to return errors
@ 2016-07-08 15:55 Andrew Zaborowski
  2016-07-08 15:55 ` [PATCH 2/3] examples: Update dbus-service example use of setter api Andrew Zaborowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Zaborowski @ 2016-07-08 15:55 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]

Allow the property setter functions to synchronously return a message
pointer if they need to return an error.  On success complete still
needs to be called because the NULL return value couls also mean that
the setter will complete asynchronously.
---
 ell/dbus-service.c | 21 +++++++++++++++------
 ell/dbus-service.h |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index 44baaaf..deffc07 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -1180,6 +1180,7 @@ static struct l_dbus_message *old_set_property(struct l_dbus *dbus,
 	const struct _dbus_property *property;
 	struct l_dbus_message_iter variant;
 	struct _dbus_object_tree *tree = _dbus_get_tree(dbus);
+	struct l_dbus_message *reply;
 
 	interface = l_hashmap_lookup(tree->interfaces,
 					l_dbus_message_get_interface(message));
@@ -1207,10 +1208,13 @@ static struct l_dbus_message *old_set_property(struct l_dbus *dbus,
 						"Property %s is read-only",
 						property_name);
 
-	property->setter(dbus, l_dbus_message_ref(message), &variant,
-				set_property_complete, user_data);
+	reply = property->setter(dbus, l_dbus_message_ref(message), &variant,
+					set_property_complete, user_data);
 
-	return NULL;
+	if (reply)
+		l_dbus_message_unref(message);
+
+	return reply;
 }
 
 static struct l_dbus_message *old_get_properties(struct l_dbus *dbus,
@@ -1729,6 +1733,7 @@ static struct l_dbus_message *properties_set(struct l_dbus *dbus,
 	struct l_dbus_message_iter variant;
 	struct _dbus_object_tree *tree = _dbus_get_tree(dbus);
 	const struct object_node *object;
+	struct l_dbus_message *reply;
 
 	if (!l_dbus_message_get_arguments(message, "ssv", &interface_name,
 						&property_name, &variant))
@@ -1774,10 +1779,14 @@ static struct l_dbus_message *properties_set(struct l_dbus *dbus,
 						"Object has no interface %s",
 						interface_name);
 
-	property->setter(dbus, l_dbus_message_ref(message), &variant,
-				properties_set_complete, instance->user_data);
+	reply = property->setter(dbus, l_dbus_message_ref(message), &variant,
+					properties_set_complete,
+					instance->user_data);
 
-	return NULL;
+	if (reply)
+		l_dbus_message_unref(message);
+
+	return reply;
 }
 
 static struct l_dbus_message *properties_get_all(struct l_dbus *dbus,
diff --git a/ell/dbus-service.h b/ell/dbus-service.h
index 2243b99..153bb3a 100644
--- a/ell/dbus-service.h
+++ b/ell/dbus-service.h
@@ -56,7 +56,7 @@ typedef void (*l_dbus_property_complete_cb_t) (struct l_dbus *,
 						struct l_dbus_message *,
 						struct l_dbus_message *error);
 
-typedef void (*l_dbus_property_set_cb_t) (struct l_dbus *,
+typedef struct l_dbus_message *(*l_dbus_property_set_cb_t) (struct l_dbus *,
 					struct l_dbus_message *message,
 					struct l_dbus_message_iter *new_value,
 					l_dbus_property_complete_cb_t complete,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-08 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-08 15:55 [PATCH 1/3] dbus-service: Allow property setters to return errors Andrew Zaborowski
2016-07-08 15:55 ` [PATCH 2/3] examples: Update dbus-service example use of setter api Andrew Zaborowski
2016-07-08 15:55 ` [PATCH 3/3] unit: Update the uses of dbus property " Andrew Zaborowski
2016-07-08 17:41 ` [PATCH 1/3] dbus-service: Allow property setters to return errors Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.