summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2012-04-06 21:38:01 +0200
committerLennart Poettering <lennart@poettering.net>2012-04-10 22:41:20 +0200
commitc57c09eed40704363256149e7b50582a68de6162 (patch)
tree3122329c601c5f86b02820efdb84858e27bbe2f0
parent9612f07cbf2b0ec54c5dc6ed7e521e181cc3612d (diff)
dbus: add generic DEFINE_BUS_PROPERTY_SET_ENUM() macro for enum properties
The defined function can be used as BusPropertySetCallback.
-rw-r--r--src/dbus-common.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/dbus-common.h b/src/dbus-common.h
index 1dc0f591d0..892d1297fe 100644
--- a/src/dbus-common.h
+++ b/src/dbus-common.h
@@ -160,6 +160,21 @@ int bus_property_append_long(DBusMessageIter *i, const char *property, void *dat
return 0; \
}
+#define DEFINE_BUS_PROPERTY_SET_ENUM(function,name,type) \
+ int function(DBusMessageIter *i, const char *property, void *data) { \
+ const char *value; \
+ type *field = data; \
+ \
+ assert(i); \
+ assert(property); \
+ \
+ dbus_message_iter_get_basic(i, &value); \
+ \
+ *field = name##_from_string(value); \
+ \
+ return 0; \
+ }
+
const char *bus_errno_to_dbus(int error);
DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties);