reis: add property support

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2021-08-26 10:23:44 +10:00
parent 7fc9498f1d
commit b77b9dc059
2 changed files with 41 additions and 0 deletions

View file

@ -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)
{

View file

@ -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.
*