From a5cc87c837254e8a5f0ddd258f018604a1124a3a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 30 Jan 2023 09:29:35 +1000 Subject: [PATCH] Purge the properties from the protocol The primary use-case for these properties in libei itself was to send some fixed information (pid, cmdline and conection type). In the portal case, these can be obtained out-of-band via the portal. In the non-portal case these can be obtained from the socket itself (fetch pid, look up /proc/pid/cmdline) which is just as reliable as trusting whatever libei sends. The only other use-case for the properties was the activation id in the InputCapture::Activated portal signal. This can be achieved with a serial in the START_EMULATING event. --- meson.build | 2 - proto/ei.proto | 14 -- src/libei-event.c | 34 ---- src/libei-private.h | 28 --- src/libei-property.c | 173 ----------------- src/libei-proto.c | 21 --- src/libei-proto.h | 6 - src/libei.c | 77 -------- src/libei.h | 114 ----------- src/libeis-client.c | 45 ----- src/libeis-event.c | 33 ---- src/libeis-private.h | 26 --- src/libeis-property.c | 185 ------------------ src/libeis-proto.c | 21 --- src/libeis-proto.h | 4 - src/libeis.c | 14 -- src/libeis.h | 93 --------- test/eierpecken.c | 6 - test/test-ei.c | 409 ---------------------------------------- tools/ei-debug-events.c | 17 -- tools/ei-demo-client.c | 6 - tools/eis-demo-server.c | 13 +- 22 files changed, 2 insertions(+), 1339 deletions(-) delete mode 100644 src/libei-property.c delete mode 100644 src/libeis-property.c diff --git a/meson.build b/meson.build index 1e8203c..d815d93 100644 --- a/meson.build +++ b/meson.build @@ -93,7 +93,6 @@ src_libei = files( 'src/libei-seat.c', 'src/libei-socket.c', 'src/libei-fd.c', - 'src/libei-property.c', 'src/libei-proto.h', 'src/libei-proto.c', 'src/libei-region.c', @@ -137,7 +136,6 @@ src_libeis = files( 'src/libeis-device.c', 'src/libeis-event.c', 'src/libeis-log.c', - 'src/libeis-property.c', 'src/libeis-region.c', 'src/libeis-seat.c', 'src/libeis-socket.c', diff --git a/proto/ei.proto b/proto/ei.proto index 4cb801f..c6d60ef 100644 --- a/proto/ei.proto +++ b/proto/ei.proto @@ -144,12 +144,6 @@ message Frame { uint64 timestamp = 2; } -message SetProperty { - string name = 1; - string value = 2; - fixed32 permissions = 3; -} - message ClientMessage { oneof msg { /* Client setup and configuration */ @@ -158,7 +152,6 @@ message ClientMessage { Disconnect disconnect = 3; BindSeat bind_seat = 4; CloseDevice close_device = 6; - SetProperty set_property = 9; GetVersion get_version = 10; /* Events */ @@ -203,12 +196,6 @@ message Connected { message Disconnected { } -message Property { - string name = 1; - string value = 2; - fixed32 permissions = 3; -} - message SeatAdded { fixed32 seatid = 1; fixed32 capabilities = 2; @@ -284,7 +271,6 @@ message ServerMessage { DeviceResumed device_resumed = 11; DevicePaused device_paused = 12; KeyboardModifiers keyboard_modifiers = 13; - Property property = 14; Version version = 15; /* Events */ diff --git a/src/libei-event.c b/src/libei-event.c index 2b809d1..437bdc0 100644 --- a/src/libei-event.c +++ b/src/libei-event.c @@ -49,7 +49,6 @@ ei_event_type_to_string(enum ei_event_type type) CASE_RETURN_STRING(EI_EVENT_DEVICE_PAUSED); CASE_RETURN_STRING(EI_EVENT_DEVICE_RESUMED); CASE_RETURN_STRING(EI_EVENT_KEYBOARD_MODIFIERS); - CASE_RETURN_STRING(EI_EVENT_PROPERTY); CASE_RETURN_STRING(EI_EVENT_FRAME); CASE_RETURN_STRING(EI_EVENT_DEVICE_START_EMULATING); CASE_RETURN_STRING(EI_EVENT_DEVICE_STOP_EMULATING); @@ -82,11 +81,6 @@ ei_event_destroy(struct ei_event *event) case EI_EVENT_DEVICE_PAUSED: case EI_EVENT_DEVICE_RESUMED: case EI_EVENT_KEYBOARD_MODIFIERS: - break; - case EI_EVENT_PROPERTY: - free(event->prop.name); - free(event->prop.value); - break; case EI_EVENT_FRAME: case EI_EVENT_DEVICE_START_EMULATING: case EI_EVENT_DEVICE_STOP_EMULATING: @@ -202,34 +196,6 @@ ei_event_keyboard_get_xkb_group(struct ei_event *event) return event->modifiers.group; } -_public_ const char * -ei_event_property_get_name(struct ei_event *event) -{ - require_event_type(event, NULL, - EI_EVENT_PROPERTY); - - return event->prop.name; -} - -_public_ const char * -ei_event_property_get_value(struct ei_event *event) -{ - require_event_type(event, NULL, - EI_EVENT_PROPERTY); - - return event->prop.value; -} - -_public_ uint32_t -ei_event_property_get_permissions(struct ei_event *event) -{ - require_event_type(event, 0, - EI_EVENT_PROPERTY); - - return event->prop.permissions; -} - - _public_ double ei_event_pointer_get_dx(struct ei_event *event) { diff --git a/src/libei-private.h b/src/libei-private.h index 10e04fa..f8a459f 100644 --- a/src/libei-private.h +++ b/src/libei-private.h @@ -60,8 +60,6 @@ struct ei { struct list seats; char *name; - struct list properties; - struct { ei_log_handler handler; enum ei_log_priority priority; @@ -190,11 +188,6 @@ struct ei_event { union { struct ei_xkb_modifiers modifiers; - struct { - char *name; - char *value; - uint32_t permissions; - } prop; struct { double dx, dy; /* relative motion */ double absx, absy; /* absolute motion */ @@ -215,24 +208,6 @@ struct ei_event { }; }; -struct ei_property { - struct object object; - struct list link; - char *name; - char *value; - uint32_t permissions; -}; - -struct ei_property * -ei_property_unref(struct ei_property *prop); - -struct ei_property * -ei_find_property(struct ei *ei, const char *name); - -int -ei_property_update(struct ei *ei, const char *name, - const char *value, uint32_t permissions); - struct ei_event * ei_event_new(struct ei *ei); @@ -267,9 +242,6 @@ ei_seat_remove(struct ei_seat *seat); void ei_seat_drop(struct ei_seat *seat); -int -ei_send_property(struct ei *ei, const char *name, const char *value, uint32_t permissions); - int ei_send_seat_bind(struct ei_seat *seat, uint32_t capabilities); diff --git a/src/libei-property.c b/src/libei-property.c deleted file mode 100644 index c44f152..0000000 --- a/src/libei-property.c +++ /dev/null @@ -1,173 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/* - * Copyright © 2021 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include "config.h" - -#include - -#include "util-strings.h" -#include "util-object.h" - -#include "libei-private.h" - -static void -ei_property_destroy(struct ei_property *prop) -{ - list_remove(&prop->link); - free(prop->name); - free(prop->value); -} - -static -OBJECT_IMPLEMENT_CREATE(ei_property); -OBJECT_IMPLEMENT_UNREF_CLEANUP(ei_property); - - -#define _PERM(p_, mask_) (((p_) & (mask_)) == (mask_)) -#define PERM_R(p_) _PERM((p_)->permissions, EI_PROPERTY_PERM_READ) -#define PERM_RW(p_) _PERM((p_)->permissions, EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE) -#define PERM_RD(p_) _PERM((p_)->permissions, EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_DELETE) - -struct ei_property * -ei_find_property(struct ei *ei, const char *name) -{ - struct ei_property *prop; - list_for_each(prop, &ei->properties, link) { - if (streq(prop->name, name)) { - return prop; - } - } - - return NULL; -} - -static struct ei_property * -ei_property_new(struct ei *ei, const char *name, - const char *value, uint32_t permissions) -{ - struct ei_property *prop = ei_property_create(NULL); - - prop->name = xstrdup(name); - prop->value = xstrdup(value); - prop->permissions = permissions & EI_PROPERTY_PERM_ALL; - - /* Initial ref is owned by this list */ - list_append(&ei->properties, &prop->link); - - return prop; -} - -static int -ei_property_delete(struct ei *ei, struct ei_property *prop) -{ - if (!PERM_RD(prop)) - return -EACCES; - - free(prop->value); - prop->value = NULL; - ei_property_unref(prop); - - return 0; -} - -static int -ei_property_change(struct ei *ei, struct ei_property *prop, - const char *value, uint32_t permissions) -{ - if (!PERM_RW(prop)) - return -EACCES; - - if (prop->value != value) { - free(prop->value); - prop->value = xstrdup(value); - } - prop->permissions = permissions; - - return 0; -} - -int -ei_property_update(struct ei *ei, const char *name, - const char *value, uint32_t permissions) -{ - struct ei_property *prop = ei_find_property(ei, name); - int rc = 0; - - if (!prop) { - ei_property_new(ei, name, value, permissions); - } else if (value) { - rc = ei_property_change(ei, prop, value, permissions); - } else { - rc = ei_property_delete(ei, prop); - } - - return rc; -} - -_public_ int -ei_property_set_with_permissions(struct ei *ei, const char *name, const char *value, - uint32_t permissions) -{ - if (strstartswith(name, "ei.") || strstartswith(name, "eis.")) - return -EACCES; - - struct ei_property *prop = ei_find_property(ei, name); - if (prop && permissions && (prop->permissions | permissions) != prop->permissions) - return -EPERM; - - int rc = ei_property_update(ei, name, value, permissions); - if (rc == 0) - ei_send_property(ei, name, value, permissions); - - return rc; -} - -_public_ int -ei_property_set(struct ei *ei, const char *name, const char *value) -{ - uint32_t permissions = EI_PROPERTY_PERM_ALL; - struct ei_property *prop = ei_find_property(ei, name); - - if (prop) - permissions = prop->permissions; - - return ei_property_set_with_permissions(ei, name, value, permissions); -} - -_public_ uint32_t -ei_property_get_permissions(struct ei *ei, const char *name) -{ - struct ei_property *prop = ei_find_property(ei, name); - - return (prop && PERM_R(prop)) ? prop->permissions : 0; -} - -_public_ const char * -ei_property_get(struct ei *ei, const char *name) -{ - struct ei_property *prop = ei_find_property(ei, name); - - return (prop && PERM_R(prop)) ? prop->value : NULL; -} diff --git a/src/libei-proto.c b/src/libei-proto.c index 936ac14..15c33ba 100644 --- a/src/libei-proto.c +++ b/src/libei-proto.c @@ -128,12 +128,6 @@ ei_proto_handle_message(struct ei *ei, rc = call(device_paused, ei, proto->device_paused->deviceid); break; - case SERVER_MESSAGE__MSG_PROPERTY: - rc = call(property, ei, - proto->property->name, - proto->property->value[0] ? proto->property->value : NULL, - proto->property->permissions); - break; case SERVER_MESSAGE__MSG_VERSION: rc = call(version, ei, proto->version->version); break; @@ -242,7 +236,6 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error) MSG_STRING_CASE(DISCONNECT); MSG_STRING_CASE(BIND_SEAT); MSG_STRING_CASE(CLOSE_DEVICE); - MSG_STRING_CASE(SET_PROPERTY); MSG_STRING_CASE(GET_VERSION); /* events */ MSG_STRING_CASE(START_EMULATING); @@ -529,25 +522,11 @@ ei_proto_send_frame(struct ei_device *device, uint64_t time) return ei_proto_send_msg(ei_device_get_context(device), &msg); } -static int -ei_proto_send_set_property(struct ei *ei, const char *name, - const char *value, uint32_t permissions) -{ - prepare_msg(SET_PROPERTY, SetProperty, set_property); - - set_property.name = (char*)name; - set_property.value = value ? (char*)value : ""; - set_property.permissions = permissions; - - return ei_proto_send_msg(ei, &msg); -} - static const struct ei_proto_requests requests = { .connect = ei_proto_send_connect, .connect_done = ei_proto_send_connect_done, .disconnect = ei_proto_send_disconnect, .bind_seat = ei_proto_send_bind_seat, - .set_property = ei_proto_send_set_property, .close_device = ei_proto_send_close_device, .get_version = ei_proto_send_get_version, diff --git a/src/libei-proto.h b/src/libei-proto.h index b5815c9..b5aca18 100644 --- a/src/libei-proto.h +++ b/src/libei-proto.h @@ -55,9 +55,6 @@ struct ei_proto_interface { int (*keyboard_modifiers)(struct ei *ei, uint32_t deviceid, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group); - int (*property)(struct ei *ei, - const char *name, const char *value, - uint32_t permissions); int (*version)(struct ei *ei, uint32_t version); /* events */ @@ -103,9 +100,6 @@ struct ei_proto_requests { uint32_t tid, double x, double y); int (*touch_up)(struct ei_device *device, uint32_t tid); int (*frame)(struct ei_device *device, uint64_t time); - int (*set_property)(struct ei *ei, - const char *name, const char *value, - uint32_t permissions); }; int diff --git a/src/libei.c b/src/libei.c index 668bda8..2884871 100644 --- a/src/libei.c +++ b/src/libei.c @@ -46,7 +46,6 @@ #include "brei-shared.h" _Static_assert(sizeof(enum ei_device_capability) == sizeof(int), "Invalid enum size"); -_Static_assert(sizeof(enum ei_property_permission) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum ei_keymap_type) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum ei_event_type) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum ei_log_priority) == sizeof(int), "Invalid enum size"); @@ -95,11 +94,6 @@ ei_destroy(struct ei *ei) ei->backend = NULL; sink_unref(ei->sink); free(ei->name); - - struct ei_property *prop; - list_for_each_safe(prop, &ei->properties, link) { - ei_property_unref(prop); - } } static @@ -116,28 +110,6 @@ OBJECT_IMPLEMENT_GETTER(ei, user_data, void *); DEFINE_UNREF_CLEANUP_FUNC(ei_device); DEFINE_UNREF_CLEANUP_FUNC(ei_region); -static void -set_prop_cmdline(struct ei *ei) -{ - _cleanup_free_ char *cmdline = cmdline_as_str(); - ei_property_update(ei, "ei.application.cmdline", cmdline, EI_PROPERTY_PERM_NONE); -} - -static void -set_prop_pid(struct ei *ei) -{ - char pid[64]; - - xsnprintf(pid, sizeof(pid), "%d", getpid()); - ei_property_update(ei, "ei.application.pid", pid, EI_PROPERTY_PERM_NONE); -} - -static void -set_prop_type(struct ei *ei) -{ - ei_property_update(ei, "ei.connection.type", "socket", EI_PROPERTY_PERM_NONE); -} - static struct ei * ei_create_context(bool is_sender, void *user_data) { @@ -147,7 +119,6 @@ ei_create_context(bool is_sender, void *user_data) ei->requests = ei_proto_get_requests(); list_init(&ei->event_queue); list_init(&ei->seats); - list_init(&ei->properties); ei_log_set_handler(ei, NULL); ei_log_set_priority(ei, EI_LOG_PRIORITY_INFO); @@ -159,10 +130,6 @@ ei_create_context(bool is_sender, void *user_data) ei->backend = NULL; ei->is_sender = is_sender; - set_prop_pid(ei); - set_prop_cmdline(ei); - set_prop_type(ei); - return steal(&ei); } @@ -427,19 +394,6 @@ queue_keyboard_modifiers_event(struct ei_device *device, queue_event(ei, e); } -static void -queue_property_event(struct ei *ei, const char *name, - const char *value, uint32_t permissions) -{ - struct ei_event *e = ei_event_new(ei); - e->type = EI_EVENT_PROPERTY; - e->prop.name = xstrdup(name); - e->prop.value = xstrdup(value); - e->prop.permissions = permissions; - - queue_event(ei, e); -} - void ei_queue_frame_event(struct ei_device *device, uint64_t time) { @@ -813,17 +767,6 @@ handle_msg_keyboard_modifiers(struct ei *ei, uint32_t deviceid, return 0; } -static int -handle_msg_property(struct ei *ei, const char *name, const char *value, - uint32_t permissions) -{ - int rc = ei_property_update(ei, name, value, permissions); - if (rc == 0) - queue_property_event(ei, name, value, permissions); - - return 0; -} - static int handle_msg_device_removed(struct ei *ei, uint32_t deviceid) { @@ -866,19 +809,6 @@ handle_msg_device_paused(struct ei *ei, uint32_t deviceid) return 0; } -int -ei_send_property(struct ei *ei, const char *name, const char *value, uint32_t permissions) -{ - /* properties before CONNECTED_DONE are handled in a custom way */ - if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED) - return 0; - - int rc = ei->requests->set_property(ei, name, value, permissions); - if (rc) - ei_disconnect(ei); - return rc; -} - int ei_send_close_device(struct ei_device *device) { @@ -1412,7 +1342,6 @@ static const struct ei_proto_interface intf_state_connected = { .device_keymap = handle_msg_device_keymap, .device_done = handle_msg_device_added_done, .keyboard_modifiers = handle_msg_keyboard_modifiers, - .property = handle_msg_property, .version = handle_msg_version, /* events */ @@ -1516,12 +1445,6 @@ ei_finish_set_connection(struct ei *ei, uint32_t version) { int rc = ei->requests->connect(ei, version); - struct ei_property *prop; - list_for_each_safe(prop, &ei->properties, link) { - if (rc == 0) - rc = ei->requests->set_property(ei, prop->name, prop->value, prop->permissions); - } - if (rc == 0) { rc = ei->requests->connect_done(ei); } diff --git a/src/libei.h b/src/libei.h index 5fa45af..cae4c1a 100644 --- a/src/libei.h +++ b/src/libei.h @@ -177,22 +177,6 @@ enum ei_device_capability { EI_DEVICE_CAP_TOUCH, }; -/** - * @enum ei_property_permission - * - * A set of masks for operations permitted on properties. Note that property - * permissions only affect the libei client, the server has full access to the - * properties at any time. - */ -enum ei_property_permission { - EI_PROPERTY_PERM_NONE = 0, - EI_PROPERTY_PERM_READ = (1 << 0), - EI_PROPERTY_PERM_WRITE = (1 << 1), - EI_PROPERTY_PERM_DELETE = (1 << 2), - - EI_PROPERTY_PERM_ALL = (EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE|EI_PROPERTY_PERM_DELETE), -}; - /** * @enum ei_keymap_type * @@ -230,14 +214,6 @@ enum ei_event_type { */ EI_EVENT_DISCONNECT, - /** - * The server has added, removed, or changed a property. - * - * This event is not generated for properties without the @ref - * EI_PROPERTY_PERM_READ set. - */ - EI_EVENT_PROPERTY, - /** * The server has added a seat available to this client. * @@ -483,62 +459,6 @@ ei_log_get_priority(const struct ei *ei); void ei_configure_name(struct ei * ei, const char *name); -/** - * 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 EI_PROPERTY_PERM_ALL. - */ -int -ei_property_set(struct ei *ei, const char *property, const char *value); - -/** - * Change, create or delete a property. - * - * - If the property does not yet exist, it is created with the given @ref - * ei_property_permission. - * - If the property exists and @a value is not NULL and the @ref - * EI_PROPERTY_PERM_WRITE permission is set on the property, the value is changed - * to the new value and the property's permissions are updated to the given - * permission. - * - If the property exists and @a value is NULL and the @ref - * EI_PROPERTY_PERM_WRITE and @ref EI_PROPERTY_PERM_DELETE permission is set - * on the property, the property is deleted. - * - * Note that property permissions only apply to the libei client, they do not - * apply to the EIS server which can read, modify and delete any property - * regardless of permissions. - * - * Permissions can only be reduced, not increased and the permissions applied - * to the property are always the binary AND of @a permissions and the - * existing permissions for this property (if any). - * - * Properties beginning with "ei." and "eis." are reserved for use by the - * library and cannot be created and/or modified. - * - * @return 0 on success or a negative errno on failure - * @retval -EACCESS The client does not have sufficient permissions for this - * operation - * @retval -EPERM The permissions mask is too loose - */ -int -ei_property_set_with_permissions(struct ei *ei, const char *property, - const char *value, uint32_t permission); - -/** - * Return the permissions mask for the given property. If the property does - * not exist or does not have the @ref EI_PROPERTY_PERM_READ permission, - * this function returns zero. - */ -uint32_t -ei_property_get_permissions(struct ei *ei, const char *property); - -/** - * Return the value of the given property or NULL if the property is not set - * or does not have the @ref EI_PROPERTY_PERM_READ permission. - */ -const char * -ei_property_get(struct ei *ei, const char *property); - /** * Set this ei context to use the socket backend. The ei context will * connect to the socket at the given path and initiate the conversation @@ -1434,40 +1354,6 @@ ei_touch_get_device(struct ei_touch *touch); struct ei_seat * ei_event_get_seat(struct ei_event *event); -/** - * For an event of type @ref EI_EVENT_PROPERTY, get the property name - * that has changed. - */ -const char * -ei_event_property_get_name(struct ei_event *event); - -/** - * For an event of type @ref EI_EVENT_PROPERTY, get the new property - * value (at the time of the event). - * - * A property value of NULL indicates the property has been deleted. - * - * Note that the property value as seen in the event and the property value on - * the ei context as returned by ei_property_get() may differ. The latter - * always reflects the current state of the property while the event contains - * the value of the property at the time of the event. - */ -const char * -ei_event_property_get_value(struct ei_event *event); - -/** - * For an event of type @ref EI_EVENT_PROPERTY, get the permissions of the - * property (at the time of the event). - * - * Note that the property permissions as seen in the event and the property - * permissiosn on the ei context as returned by ei_property_get_permissions() - * may differ. The latter always reflects the current state of the property - * while the event contains the permissions of the property at the time of the - * event. - */ -uint32_t -ei_event_property_get_permissions(struct ei_event *event); - /** * For an event of type @ref EI_EVENT_POINTER_MOTION return the relative x * movement in logical pixels or mm, depending on the device type. diff --git a/src/libeis-client.c b/src/libeis-client.c index d20c262..1f8cd9a 100644 --- a/src/libeis-client.c +++ b/src/libeis-client.c @@ -51,11 +51,6 @@ eis_client_destroy(struct eis_client *client) source_remove(client->source); source_unref(client->source); list_remove(&client->link); - - struct eis_property *prop; - list_for_each_safe(prop, &client->properties, link) { - eis_property_unref(prop); - } } static @@ -222,17 +217,6 @@ client_send_keyboard_modifiers(struct eis_client *client, struct eis_device *dev return eis->requests->keyboard_modifiers(device, mods); } -static int -client_send_property(struct eis_client *client, struct eis_property *property) -{ - struct eis *eis = eis_client_get_context(client); - - if ((property->permissions & EIS_PROPERTY_PERM_READ) == 0) - return 0; - - return eis->requests->property(client, property->name, property->value, property->permissions); -} - _public_ void eis_client_connect(struct eis_client *client) { @@ -253,11 +237,6 @@ eis_client_connect(struct eis_client *client) eis_client_disconnect(client); } else { client->state = EIS_CLIENT_STATE_CONNECTED; - - struct eis_property *prop; - - list_for_each(prop, &client->properties, link) - client_send_property(client, prop); } } @@ -533,27 +512,6 @@ client_msg_disconnect(struct eis_client *client) return -ECANCELED; } -static int -client_msg_set_property(struct eis_client *client, - const char *name, const char *value, - uint32_t permissions) -{ - eis_property_update_from_client(client, name, value, permissions); - - return 0; -} - -static int -client_msg_set_property_with_event(struct eis_client *client, - const char *name, const char *value, - uint32_t permissions) -{ - int rc = client_msg_set_property(client, name, value, permissions); - if (rc == 0) - eis_queue_property_event(client, name, value, permissions); - return rc; -} - static int client_msg_get_version(struct eis_client *client) { @@ -562,7 +520,6 @@ client_msg_get_version(struct eis_client *client) static const struct eis_proto_interface intf_state_new = { .connect = client_msg_connect, - .set_property = client_msg_set_property, .connect_done = client_msg_connect_done, .disconnect = client_msg_disconnect, .get_version = client_msg_get_version, @@ -576,7 +533,6 @@ static const struct eis_proto_interface intf_state_connecting = { static const struct eis_proto_interface intf_state_connected = { .disconnect = client_msg_disconnect, - .set_property = client_msg_set_property_with_event, .bind_seat = client_msg_bind_seat, .close_device = client_msg_close_device, .get_version = client_msg_get_version, @@ -660,7 +616,6 @@ eis_client_new(struct eis *eis, int fd) client->id = ++client_id; list_init(&client->seats); list_init(&client->seats_pending); - list_init(&client->properties); struct source *s = source_new(fd, client_dispatch, client); int rc = sink_add_source(eis->sink, s); diff --git a/src/libeis-event.c b/src/libeis-event.c index 40e9931..81e6d44 100644 --- a/src/libeis-event.c +++ b/src/libeis-event.c @@ -58,11 +58,6 @@ eis_event_destroy(struct eis_event *event) case EIS_EVENT_FRAME: handled = true; break; - case EIS_EVENT_CLIENT_PROPERTY: - handled = true; - free(event->prop.name); - free(event->prop.value); - break; } if (!handled) @@ -392,31 +387,3 @@ eis_event_touch_get_y(struct eis_event *event) return event->touch.y; } - -_public_ const char * -eis_event_property_get_name(struct eis_event *event) -{ - require_event_type(event, NULL, - EIS_EVENT_CLIENT_PROPERTY); - - return event->prop.name; -} - -_public_ const char * -eis_event_property_get_value(struct eis_event *event) -{ - require_event_type(event, NULL, - EIS_EVENT_CLIENT_PROPERTY); - - return event->prop.value; -} - -_public_ uint32_t -eis_event_property_get_permissions(struct eis_event *event) -{ - require_event_type(event, 0, - EIS_EVENT_CLIENT_PROPERTY); - - return event->prop.permissions; -} - diff --git a/src/libeis-private.h b/src/libeis-private.h index 082f9ab..fa65b86 100644 --- a/src/libeis-private.h +++ b/src/libeis-private.h @@ -78,8 +78,6 @@ struct eis_client { struct list seats; struct list seats_pending; - struct list properties; - struct { uint32_t cap_allow_mask; } restrictions; @@ -200,11 +198,6 @@ struct eis_event { uint32_t touchid; double x, y; } touch; - struct { - char *name; - char *value; - uint32_t permissions; - } prop; }; }; @@ -225,21 +218,6 @@ struct eis_xkb_modifiers { uint32_t group; }; -struct eis_property { - struct object object; - struct list link; - char *name; - char *value; - uint32_t permissions; -}; - -struct eis_property * -eis_property_unref(struct eis_property *prop); - -void -eis_property_update_from_client(struct eis_client *client, const char *name, - const char *value, uint32_t permissions); - void eis_init_object(struct eis *eis, struct object *parent); @@ -365,10 +343,6 @@ eis_queue_connect_event(struct eis_client *client); void eis_queue_disconnect_event(struct eis_client *client); -void -eis_queue_property_event(struct eis_client *client, const char *name, - const char *value, uint32_t permissions); - void eis_queue_seat_bind_event(struct eis_seat *seat, uint32_t capabilities); diff --git a/src/libeis-property.c b/src/libeis-property.c deleted file mode 100644 index 122d41e..0000000 --- a/src/libeis-property.c +++ /dev/null @@ -1,185 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/* - * Copyright © 2021 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -#include "config.h" - -#include - -#include "util-strings.h" -#include "util-object.h" - -#include "libeis-private.h" -#include "libeis-proto.h" - -static void -eis_property_destroy(struct eis_property *prop) -{ - list_remove(&prop->link); - free(prop->name); - free(prop->value); -} - -static -OBJECT_IMPLEMENT_CREATE(eis_property); -OBJECT_IMPLEMENT_UNREF_CLEANUP(eis_property); - -#define _PERM(p_, mask_) (((p_) & (mask_)) == (mask_)) -#define PERM_R(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ) -#define PERM_RW(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ|EIS_PROPERTY_PERM_WRITE) -#define PERM_RD(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ|EIS_PROPERTY_PERM_DELETE) - -static struct eis_property * -eis_property_find(struct eis_client *client, const char *name) -{ - struct eis_property *prop; - list_for_each(prop, &client->properties, link) { - if (streq(prop->name, name)) { - return prop; - } - } - - return NULL; -} - -static struct eis_property * -eis_client_property_new(struct eis_client *client, const char *name, - const char *value, uint32_t permissions) -{ - assert(name); - assert(value); - - struct eis_property *prop = eis_property_create(NULL); - prop->name = xstrdup(name); - prop->value = xstrdup(value); - prop->permissions = permissions & EIS_PROPERTY_PERM_ALL; - - /* initial ref is owned by this list */ - list_append(&client->properties, &prop->link); - - return prop; -} - -static void -eis_property_delete(struct eis_client *client, struct eis_property *prop) -{ - eis_property_unref(prop); -} - -static void -eis_property_change(struct eis_client *client, struct eis_property *prop, - const char *value, uint32_t permissions) -{ - if (prop->value != value) { - free(prop->value); - prop->value = xstrdup(value); - } - prop->permissions = permissions; -} - -void -eis_property_update_from_client(struct eis_client *client, const char *name, - const char *value, uint32_t permissions) -{ - - /* Client can't set eis. namespace properties */ - if (strstartswith(name, "eis.")) - return; - - struct eis_property *prop = eis_property_find(client, name); - if (!prop) { - eis_client_property_new(client, name, value, permissions); - return; - } - - if (!PERM_RW(prop)) - return; - - if (!value) { - if (PERM_RD(prop)) - eis_property_delete(client, prop); - return; - } - - /* Permissions can only be lowered by the client */ - permissions = prop->permissions & permissions; - eis_property_change(client, prop, value, permissions); -} - -static void -eis_property_update(struct eis_client *client, const char *name, - const char *value, uint32_t permissions) -{ - struct eis_property *prop = eis_property_find(client, name); - - if (!prop) { - eis_client_property_new(client, name, value, permissions); - } else if (value) { - eis_property_change(client, prop, value, permissions); - } else { - eis_property_delete(client, prop); - } -} - -_public_ void -eis_client_property_set_with_permissions(struct eis_client *client, const char *name, - const char *value, uint32_t permissions) -{ - if (strstartswith(name, "ei.") || strstartswith(name, "eis.")) - return; - - eis_property_update(client, name, value, permissions); - - /* We should have a check to see if anything actually changed, but meh */ - struct eis *eis = eis_client_get_context(client); - eis->requests->property(client, name, value, permissions); -} - -_public_ void -eis_client_property_set(struct eis_client *client, const char *name, const char *value) -{ - uint32_t permissions = EIS_PROPERTY_PERM_ALL; - struct eis_property *prop = eis_property_find(client, name); - - if (prop) - permissions = prop->permissions; - - return eis_client_property_set_with_permissions(client, name, value, permissions); -} - -_public_ uint32_t -eis_client_property_get_permissions(struct eis_client *client, const char *name) -{ - struct eis_property *prop = eis_property_find(client, name); - - return prop ? prop->permissions : 0; -} - -_public_ const char * -eis_client_property_get(struct eis_client *client, const char *name) -{ - struct eis_property *prop = eis_property_find(client, name); - - return prop ? prop->value : NULL; -} diff --git a/src/libeis-proto.c b/src/libeis-proto.c index decee4e..cc09032 100644 --- a/src/libeis-proto.c +++ b/src/libeis-proto.c @@ -65,7 +65,6 @@ log_wire_message(struct eis *eis, const ServerMessage *msg) MSG_STRING_CASE(DEVICE_RESUMED); MSG_STRING_CASE(DEVICE_PAUSED); MSG_STRING_CASE(KEYBOARD_MODIFIERS); - MSG_STRING_CASE(PROPERTY); MSG_STRING_CASE(VERSION); /* events */ MSG_STRING_CASE(START_EMULATING); @@ -277,20 +276,6 @@ eis_proto_send_device_resumed(struct eis_device *device) return eis_proto_send_msg(eis_device_get_client(device), &msg); } -static int -eis_proto_send_property(struct eis_client *client, const char *name, - const char *value, uint32_t permissions) -{ - - prepare_msg(PROPERTY, Property, property); - - property.name = (char*)name; - property.value = (char*)value; - property.permissions = permissions; - - return eis_proto_send_msg(client, &msg); -} - static int eis_proto_send_start_emulating(struct eis_device *device, uint32_t deviceid) { @@ -466,7 +451,6 @@ static const struct eis_proto_requests requests = { .device_done = eis_proto_send_device_done, .device_region = eis_proto_send_device_region, .keyboard_modifiers = eis_proto_send_keyboard_modifiers, - .property = eis_proto_send_property, .version = eis_proto_send_version, /* events */ @@ -534,11 +518,6 @@ eis_proto_handle_message(struct eis_client *client, rc = call(close_device, client, proto->close_device->deviceid); break; - case CLIENT_MESSAGE__MSG_SET_PROPERTY: - rc = call(set_property, client, proto->set_property->name, - proto->set_property->value[0] ? proto->set_property->value : NULL, - proto->set_property->permissions); - break; case CLIENT_MESSAGE__MSG_GET_VERSION: rc = call(get_version, client); break; diff --git a/src/libeis-proto.h b/src/libeis-proto.h index b15407b..ac6faa4 100644 --- a/src/libeis-proto.h +++ b/src/libeis-proto.h @@ -42,8 +42,6 @@ struct eis_proto_interface { int (*bind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap); int (*unbind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap); int (*close_device)(struct eis_client *client, uint32_t deviceid); - int (*set_property)(struct eis_client *client, const char *name, - const char *value, uint32_t permissions); int (*get_version)(struct eis_client *client); /* events */ int (*start_emulating)(struct eis_client *client, uint32_t deviceid); @@ -78,8 +76,6 @@ struct eis_proto_requests { const struct eis_region *region); int (*keyboard_modifiers)(struct eis_device *device, const struct eis_xkb_modifiers *mods); - int (*property)(struct eis_client *client, const char *name, - const char *value, uint32_t permissions); int (*version)(struct eis_client *client, uint32_t version); /* events */ diff --git a/src/libeis.c b/src/libeis.c index d8c0896..8a8d0eb 100644 --- a/src/libeis.c +++ b/src/libeis.c @@ -40,7 +40,6 @@ #include "libeis-private.h" _Static_assert(sizeof(enum eis_device_capability) == sizeof(int), "Invalid enum size"); -_Static_assert(sizeof(enum eis_property_permission) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum eis_keymap_type) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum eis_event_type) == sizeof(int), "Invalid enum size"); _Static_assert(sizeof(enum eis_log_priority) == sizeof(int), "Invalid enum size"); @@ -113,7 +112,6 @@ eis_event_type_to_string(enum eis_event_type type) switch(type) { CASE_RETURN_STRING(EIS_EVENT_CLIENT_CONNECT); CASE_RETURN_STRING(EIS_EVENT_CLIENT_DISCONNECT); - CASE_RETURN_STRING(EIS_EVENT_CLIENT_PROPERTY); CASE_RETURN_STRING(EIS_EVENT_SEAT_BIND); CASE_RETURN_STRING(EIS_EVENT_DEVICE_CLOSED); CASE_RETURN_STRING(EIS_EVENT_DEVICE_START_EMULATING); @@ -232,18 +230,6 @@ eis_queue_disconnect_event(struct eis_client *client) eis_queue_event(e); } -void -eis_queue_property_event(struct eis_client *client, const char *name, const char *value, - uint32_t permissions) -{ - struct eis_event *e = eis_event_new_for_client(client); - e->type = EIS_EVENT_CLIENT_PROPERTY; - e->prop.name = xstrdup(name); - e->prop.value = xstrdup(value); - e->prop.permissions = permissions; - eis_queue_event(e); -} - void eis_queue_seat_bind_event(struct eis_seat *seat, uint32_t capabilities) { diff --git a/src/libeis.h b/src/libeis.h index e47e007..3c11e32 100644 --- a/src/libeis.h +++ b/src/libeis.h @@ -125,22 +125,6 @@ enum eis_device_capability { EIS_DEVICE_CAP_TOUCH, }; -/** - * @enum eis_property_permission - * - * A set of masks for operations permitted on properties. Note that property - * permissions only affect the libei client, the server has full access to the - * properties at any time. - */ -enum eis_property_permission { - EIS_PROPERTY_PERM_NONE = 0, - EIS_PROPERTY_PERM_READ = (1 << 0), - EIS_PROPERTY_PERM_WRITE = (1 << 1), - EIS_PROPERTY_PERM_DELETE = (1 << 2), - - EIS_PROPERTY_PERM_ALL = (EIS_PROPERTY_PERM_READ|EIS_PROPERTY_PERM_WRITE|EIS_PROPERTY_PERM_DELETE), -}; - enum eis_keymap_type { EIS_KEYMAP_TYPE_XKB = 1, }; @@ -159,11 +143,6 @@ enum eis_event_type { */ EIS_EVENT_CLIENT_DISCONNECT, - /** - * A client property has been added, changed, or deleted. - */ - EIS_EVENT_CLIENT_PROPERTY, - /** * The client wants to bind or unbind a capability on this seat. * Devices associated with this seat should be sent to the client or @@ -354,55 +333,6 @@ eis_set_user_data(struct eis *eis, void *user_data); bool eis_client_is_sender(struct eis_client *client); -/** - * See eis_client_property_set_with_permissions(), but the permissions are - * left as-is. If the property does not exist, it is created with permissions - * @ref EIS_PROPERTY_PERM_ALL. - */ -void -eis_client_property_set(struct eis_client *client, const char *property, const char *value); - -/** - * Change, create or delete a property. - * - * - If the property does not yet exist, it is created with the given @ref - * eis_property_permission. - * - If the property exists and @a value is not NULL, the value is changed to - * the new value. - * - If the property exists and @a value is NULL, the property is deleted. - * - * If the property is not deleted, the permissions are updated to the given @a - * permissions. - * - * Properties should use a name in the form "namespace.name" or - * "namespace.name.subname". Two namespaces are reserved for use by this - * library: "eis.*" and "ei.*". Attempting to change a property within that - * namespace will be silently ignored. - */ -void -eis_client_property_set_with_permissions(struct eis_client *client, - const char *property, const char *value, - uint32_t permission); - -/** - * Return the permissions mask for the given property. If the property does - * not exist, this function returns zero. - */ -uint32_t -eis_client_property_get_permissions(struct eis_client *client, const char *propert); - -/** - * Return the value of the given property or NULL if the property is not set. - * - * The following property names are automatically set by libei: - * - "ei.application.pid" - the PID of the libei process - * - "ei.application.cmdline" - The first element of `/proc/$pid/cmdline` of - * the libei process - * - */ -const char * -eis_client_property_get(struct eis_client *client, const char *property); - /** * Returns true if the client is allowed this capability. */ @@ -614,29 +544,6 @@ eis_event_get_type(struct eis_event *event); struct eis_client * eis_event_get_client(struct eis_event *event); -/** - * For an event of type @ref EIS_EVENT_CLIENT_PROPERTY, get the property name - * that has changed. - */ -const char * -eis_event_property_get_name(struct eis_event *event); - -/** - * For an event of type @ref EIS_EVENT_CLIENT_PROPERTY, get the new property - * value (at the time of the event). - * - * A property value of NULL indicates the property has been deleted. - */ -const char * -eis_event_property_get_value(struct eis_event *event); - -/** - * For an event of type @ref EIS_EVENT_CLIENT_PROPERTY, get the permissions - * of the property (at the time of the event). - */ -uint32_t -eis_event_property_get_permissions(struct eis_event *event); - struct eis_seat * eis_event_get_seat(struct eis_event *event); diff --git a/test/eierpecken.c b/test/eierpecken.c index 6f757b3..0afd145 100644 --- a/test/eierpecken.c +++ b/test/eierpecken.c @@ -744,8 +744,6 @@ _peck_dispatch_eis(struct peck *peck, int lineno) if (flag_is_set(peck->eis_behavior, PECK_EIS_BEHAVIOR_HANDLE_STOP_EMULATING)) process_event = tristate_yes; break; - case EIS_EVENT_CLIENT_PROPERTY: - break; case EIS_EVENT_POINTER_MOTION: case EIS_EVENT_POINTER_MOTION_ABSOLUTE: case EIS_EVENT_POINTER_BUTTON: @@ -892,8 +890,6 @@ _peck_dispatch_ei(struct peck *peck, int lineno) case EI_EVENT_DEVICE_START_EMULATING: case EI_EVENT_DEVICE_STOP_EMULATING: break; - case EI_EVENT_PROPERTY: - break; case EI_EVENT_POINTER_MOTION: case EI_EVENT_POINTER_MOTION_ABSOLUTE: case EI_EVENT_POINTER_BUTTON: @@ -1186,7 +1182,6 @@ peck_ei_event_type_name(enum ei_event_type type) CASE_STRING(DEVICE_PAUSED); CASE_STRING(DEVICE_RESUMED); CASE_STRING(KEYBOARD_MODIFIERS); - CASE_STRING(PROPERTY); CASE_STRING(FRAME); CASE_STRING(DEVICE_START_EMULATING); CASE_STRING(DEVICE_STOP_EMULATING); @@ -1221,7 +1216,6 @@ peck_eis_event_type_name(enum eis_event_type type) switch (type) { CASE_STRING(CLIENT_CONNECT); CASE_STRING(CLIENT_DISCONNECT); - CASE_STRING(CLIENT_PROPERTY); CASE_STRING(SEAT_BIND); CASE_STRING(DEVICE_CLOSED); CASE_STRING(DEVICE_START_EMULATING); diff --git a/test/test-ei.c b/test/test-ei.c index 9321248..51bc13b 100644 --- a/test/test-ei.c +++ b/test/test-ei.c @@ -48,415 +48,6 @@ MUNIT_TEST(test_ei_ref_unref) return MUNIT_OK; } -MUNIT_TEST(test_ei_initial_properties) -{ - _unref_(peck) *peck = peck_new(); - char pid[64]; - _cleanup_free_ char *cmdline = cmdline_as_str(); - - xsnprintf(pid, sizeof(pid), "%i", getpid()); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE); - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *connect = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_CONNECT); - struct eis_client *client = eis_event_get_client(connect); - - const char *pidprop = eis_client_property_get(client, "ei.application.pid"); - munit_assert_ptr_not_null(pidprop); - munit_assert_string_equal(pidprop, pid); - - const char *cmdprop = eis_client_property_get(client, "ei.application.cmdline"); - munit_assert_ptr_not_null(cmdprop); - munit_assert_string_equal(cmdprop, cmdline); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_client(peck) { - ei_property_set(ei, "foo.bar", "value"); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e); - const char *value = eis_event_property_get_value(e); - - munit_assert_string_equal(name, "foo.bar"); - munit_assert_string_equal(value, "value"); - } - - with_client(peck) { - int rc = ei_property_set(ei, "foo.bar", "newval"); - munit_assert_int(rc, ==, 0); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e); - const char *value = eis_event_property_get_value(e); - - munit_assert_string_equal(name, "foo.bar"); - munit_assert_string_equal(value, "newval"); - } - - with_client(peck) { - int rc = ei_property_set(ei, "foo.bar", NULL); - munit_assert_int(rc, ==, 0); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e); - const char *value = eis_event_property_get_value(e); - - munit_assert_string_equal(name, "foo.bar"); - munit_assert_ptr_null(value); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_reserved) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_client(peck) { - int rc; - - rc = ei_property_set(ei, "ei.bar", "value"); - munit_assert_int(rc, ==, -EACCES); - - rc = ei_property_set(ei, "eis.bar", "value"); - munit_assert_int(rc, ==, -EACCES); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - peck_assert_no_eis_events(eis); - } - - peck_dispatch_until_stable(peck); - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_permissions) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_client(peck) { - ei_property_set_with_permissions(ei, "cannot.delete", "v1", - EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE); - ei_property_set_with_permissions(ei, "cannot.write", "v2", - EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_DELETE); - ei_property_set_with_permissions(ei, "cannot.read", "v3", - EI_PROPERTY_PERM_DELETE|EI_PROPERTY_PERM_WRITE); - - const char *value; - int rc; - - /* can't delete but we can write to it */ - value = ei_property_get(ei, "cannot.delete"); - munit_assert_string_equal(value, "v1"); - rc = ei_property_set(ei, "cannot.delete", NULL); - munit_assert_int(rc, ==, -EACCES); - value = ei_property_get(ei, "cannot.delete"); - munit_assert_string_equal(value, "v1"); - rc = ei_property_set(ei, "cannot.delete", "newv1"); - munit_assert_int(rc, ==, 0); - value = ei_property_get(ei, "cannot.delete"); - munit_assert_string_equal(value, "newv1"); - - /* can't modify it but we can delete it */ - value = ei_property_get(ei, "cannot.write"); - munit_assert_string_equal(value, "v2"); - rc = ei_property_set(ei, "cannot.write", "newv2"); - munit_assert_int(rc, ==, -EACCES); - value = ei_property_get(ei, "cannot.write"); - munit_assert_string_equal(value, "v2"); - rc = ei_property_set(ei, "cannot.write", NULL); - munit_assert_int(rc, ==, 0); - value = ei_property_get(ei, "cannot.write"); - munit_assert_ptr_equal(value, NULL); - - value = ei_property_get(ei, "cannot.read"); - munit_assert_ptr_equal(value, NULL); - rc = ei_property_set(ei, "cannot.read", "newv3"); - munit_assert_int(rc, ==, -EACCES); - value = ei_property_get(ei, "cannot.read"); - munit_assert_ptr_equal(value, NULL); - rc = ei_property_set(ei, "cannot.read", NULL); - munit_assert_int(rc, ==, -EACCES); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_permissions_drop) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_client(peck) { - int rc; - ei_property_set_with_permissions(ei, "test.perms", "v1", - EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE|EI_PROPERTY_PERM_DELETE); - - /* downgrading permissions, can't delete anymore */ - rc = ei_property_set_with_permissions(ei, "test.perms", "v1", - EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE); - munit_assert_int(rc, ==, 0); - rc = ei_property_set(ei, "test.perms", NULL); - munit_assert_int(rc, ==, -EACCES); - - /* upgrading permissions should fail */ - rc = ei_property_set_with_permissions(ei, "test.perms", "v1", - EI_PROPERTY_PERM_READ|EI_PROPERTY_PERM_WRITE|EI_PROPERTY_PERM_DELETE); - munit_assert_int(rc, ==, -EPERM); - - /* Drop the write permission */ - rc = ei_property_set_with_permissions(ei, "test.perms", "v1", - EI_PROPERTY_PERM_READ); - munit_assert_int(rc, ==, 0); - rc = ei_property_set(ei, "test.perms", "new value"); - munit_assert_int(rc, ==, -EACCES); - - /* We need write permissions to change the permissions */ - rc = ei_property_set_with_permissions(ei, "test.perms", "v1", - EI_PROPERTY_PERM_NONE); - munit_assert_int(rc, ==, -EACCES); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_events) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_client(peck) { - ei_property_set(ei, "test.events", "v1"); - ei_property_set(ei, "test.events", "v2"); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e1 = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e1); - const char *value = eis_event_property_get_value(e1); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v1"); - - struct eis_client *client = eis_event_get_client(e1); - const char *propval = eis_client_property_get(client, "test.events"); - /* - * This probably needs fixing: because we processed the second - * event already, the actual property value is different to - * our current event value. - */ - munit_assert_string_equal(propval, "v2"); - - _unref_(eis_event) *e2 = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - name = eis_event_property_get_name(e2); - value = eis_event_property_get_value(e2); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v2"); - } - - /* delete it */ - with_client(peck) { - ei_property_set(ei, "test.events", "v3"); - ei_property_set(ei, "test.events", NULL); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e3 = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e3); - const char *value = eis_event_property_get_value(e3); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v3"); - - struct eis_client *client = eis_event_get_client(e3); - const char *propval = eis_client_property_get(client, "test.events"); - /* - * This probably needs fixing: because we processed the second - * event already, the actual property value is different to - * our current event value. - */ - munit_assert_ptr_null(propval); - - _unref_(eis_event) *e4 = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - name = eis_event_property_get_name(e4); - value = eis_event_property_get_value(e4); - munit_assert_string_equal(name, "test.events"); - munit_assert_ptr_null(value); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_events_server) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_server(peck) { - struct eis_client *client = peck_eis_get_default_client(peck); - eis_client_property_set(client, "test.events", "v1"); - eis_client_property_set(client, "test.events", "v2"); - } - - peck_dispatch_until_stable(peck); - - with_client(peck) { - _unref_(ei_event) *e1 = - peck_ei_next_event(ei, EI_EVENT_PROPERTY); - const char *name = ei_event_property_get_name(e1); - const char *value = ei_event_property_get_value(e1); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v1"); - - const char *propval = ei_property_get(ei, "test.events"); - /* - * This probably needs fixing: because we processed the second - * event already, the actual property value is different to - * our current event value. - */ - munit_assert_string_equal(propval, "v2"); - - _unref_(ei_event) *e2 = - peck_ei_next_event(ei, EI_EVENT_PROPERTY); - name = ei_event_property_get_name(e2); - value = ei_event_property_get_value(e2); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v2"); - } - - /* delete it */ - with_server(peck) { - struct eis_client *client = peck_eis_get_default_client(peck); - eis_client_property_set(client, "test.events", "v3"); - eis_client_property_set(client, "test.events", NULL); - } - - peck_dispatch_until_stable(peck); - - with_client(peck) { - _unref_(ei_event) *e3 = - peck_ei_next_event(ei, EI_EVENT_PROPERTY); - const char *name = ei_event_property_get_name(e3); - const char *value = ei_event_property_get_value(e3); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "v3"); - - const char *propval = ei_property_get(ei, "test.events"); - /* - * This probably needs fixing: because we processed the second - * event already, the actual property value is different to - * our current event value. - */ - munit_assert_ptr_null(propval); - - _unref_(ei_event) *e4 = - peck_ei_next_event(ei, EI_EVENT_PROPERTY); - name = ei_event_property_get_name(e4); - value = ei_event_property_get_value(e4); - munit_assert_string_equal(name, "test.events"); - munit_assert_ptr_null(value); - } - - return MUNIT_OK; -} - -MUNIT_TEST(test_ei_properties_events_pingpong) -{ - _unref_(peck) *peck = peck_new(); - - peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); - peck_dispatch_until_stable(peck); - - with_server(peck) { - struct eis_client *client = peck_eis_get_default_client(peck); - eis_client_property_set(client, "test.events", "ping"); - } - - peck_dispatch_until_stable(peck); - - with_client(peck) { - _unref_(ei_event) *e = - peck_ei_next_event(ei, EI_EVENT_PROPERTY); - const char *name = ei_event_property_get_name(e); - const char *value = ei_event_property_get_value(e); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "ping"); - - const char *propval = ei_property_get(ei, "test.events"); - munit_assert_string_equal(propval, "ping"); - - ei_property_set(ei, "test.events", "pong"); - propval = ei_property_get(ei, "test.events"); - munit_assert_string_equal(propval, "pong"); - } - - peck_dispatch_until_stable(peck); - - with_server(peck) { - _unref_(eis_event) *e = - peck_eis_next_event(eis, EIS_EVENT_CLIENT_PROPERTY); - const char *name = eis_event_property_get_name(e); - const char *value = eis_event_property_get_value(e); - munit_assert_string_equal(name, "test.events"); - munit_assert_string_equal(value, "pong"); - - struct eis_client *client = eis_event_get_client(e); - const char *propval = eis_client_property_get(client, "test.events"); - munit_assert_string_equal(propval, "pong"); - } - - return MUNIT_OK; -} - MUNIT_TEST(test_ei_disconnect_immediately) { _unref_(peck) *peck = peck_new(); diff --git a/tools/ei-debug-events.c b/tools/ei-debug-events.c index 69c5d5b..35ea2f9 100644 --- a/tools/ei-debug-events.c +++ b/tools/ei-debug-events.c @@ -95,7 +95,6 @@ event_type(enum ei_event_type type) CASE_RETURN_STRING(EI_EVENT_DEVICE_PAUSED); CASE_RETURN_STRING(EI_EVENT_DEVICE_RESUMED); CASE_RETURN_STRING(EI_EVENT_KEYBOARD_MODIFIERS); - CASE_RETURN_STRING(EI_EVENT_PROPERTY); CASE_RETURN_STRING(EI_EVENT_FRAME); CASE_RETURN_STRING(EI_EVENT_DEVICE_START_EMULATING); CASE_RETURN_STRING(EI_EVENT_DEVICE_STOP_EMULATING); @@ -132,19 +131,6 @@ print_event_header(struct ei_event *event) printf("- type: %s\n", type); } -static void -print_property_event(struct ei_event *event) -{ - uint32_t perms = ei_event_property_get_permissions(event); - - printf(" property: %s\n", ei_event_property_get_name(event)); - printf(" value: %s\n", ei_event_property_get_value(event)); - printf(" perms: %c%c%c\n", - perms & EI_PROPERTY_PERM_READ ? 'r' : '-', - perms & EI_PROPERTY_PERM_WRITE ? 'w' : '-', - perms & EI_PROPERTY_PERM_DELETE ? 'd' : '-'); -} - static void print_seat_event(struct ei_event *event) { @@ -436,9 +422,6 @@ int main(int argc, char **argv) break; case EI_EVENT_DISCONNECT: goto finished; - case EI_EVENT_PROPERTY: - print_property_event(e); - break; case EI_EVENT_SEAT_ADDED: ei_seat_bind_capability(seat, EI_DEVICE_CAP_POINTER); ei_seat_has_capability(seat, EI_DEVICE_CAP_POINTER_ABSOLUTE); diff --git a/tools/ei-demo-client.c b/tools/ei-demo-client.c index 7c1d080..4916104 100644 --- a/tools/ei-demo-client.c +++ b/tools/ei-demo-client.c @@ -383,12 +383,6 @@ int main(int argc, char **argv) colorprint("our device was removed\n"); break; } - case EI_EVENT_PROPERTY: - { - colorprint("Property %s: %s\n", ei_event_property_get_name(e), - ei_event_property_get_value(e)); - break; - } case EI_EVENT_FRAME: break; case EI_EVENT_DEVICE_START_EMULATING: diff --git a/tools/eis-demo-server.c b/tools/eis-demo-server.c index 2279f65..a7f07fa 100644 --- a/tools/eis-demo-server.c +++ b/tools/eis-demo-server.c @@ -279,14 +279,10 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server, case EIS_EVENT_CLIENT_CONNECT: { struct eis_client *client = eis_event_get_client(e); - const char *pid = eis_client_property_get(client, "ei.application.pid"); - const char *cmdline = eis_client_property_get(client, "ei.application.cmdline"); - const char *ctype = eis_client_property_get(client, "ei.connection.type"); bool is_sender = eis_client_is_sender(client); - colorprint("new %s client: %s (pid %s, '%s'), connected via %s\n", + colorprint("new %s client: %s\n", is_sender ? "sender" : "receiver", - eis_client_get_name(client), - pid, cmdline, ctype); + eis_client_get_name(client)); eis_demo_client_new(server, client); @@ -435,11 +431,6 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server, case EIS_EVENT_FRAME: /* nothing to do, we're not fancy enough to accumulate events properly */ break; - case EIS_EVENT_CLIENT_PROPERTY: - { - colorprint("Property: %s: %s\n", eis_event_property_get_name(e), eis_event_property_get_value(e)); - } - break; default: abort(); }