From b77b9dc0597fa51babb8b9613d75fdec322513e3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 26 Aug 2021 10:23:44 +1000 Subject: [PATCH] reis: add property support Signed-off-by: Peter Hutterer --- src/libreis.c | 15 +++++++++++++++ src/libreis.h | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/libreis.c b/src/libreis.c index e242075..c07c714 100644 --- a/src/libreis.c +++ b/src/libreis.c @@ -82,6 +82,21 @@ reis_new(int eisfd) msg.msg_case = CLIENT_MESSAGE__MSG_##_type; \ msg._field = &_field +_public_ int +reis_set_property_with_permissions(struct reis *reis, + const char *name, const char *value, + uint32_t permissions) +{ + prepare_msg(PROPERTY, Property, property); + + property.name = (char*)name; + property.value = value ? (char*)value : ""; + property.permissions = permissions; + + int rc = send_msg(reis->eisfd, &msg); + return rc; +} + _public_ int reis_set_name(struct reis *reis, const char *name) { diff --git a/src/libreis.h b/src/libreis.h index b9ef718..3f0921f 100644 --- a/src/libreis.h +++ b/src/libreis.h @@ -51,6 +51,22 @@ enum reis_device_capability { REIS_DEVICE_CAP_ALL = ~0, }; +/** + * @enum reis_property_permission + * + * A set of masks for operations permitted on properties. Note that property + * permissions only affect the libreis client, the server has full access to the + * properties at any time. + */ +enum reis_property_permission { + REIS_PROPERTY_PERM_NONE = 0, + REIS_PROPERTY_PERM_READ = (1 << 0), + REIS_PROPERTY_PERM_WRITE = (1 << 1), + REIS_PROPERTY_PERM_DELETE = (1 << 2), + + REIS_PROPERTY_PERM_ALL = (REIS_PROPERTY_PERM_READ|REIS_PROPERTY_PERM_WRITE|REIS_PROPERTY_PERM_DELETE), +}; + /** * Create a new reis context based on the EIS connection at the other end of * @a eisfd. The EIS context does not need to be in any @@ -63,6 +79,16 @@ reis_new(int eisfd); struct reis * reis_unref(struct reis* reis); +/** + * See ei_property_set_with_permissions(), but the permissions are + * left as-is. If the property does not exist, it is created with permissions + * @ref REIS_PROPERTY_PERM_ALL. + */ +int +reis_set_property_with_permissions(struct reis *reis, + const char *property, const char *value, + uint32_t permission); + /** * Set the name for the client on this connection. *