Commit graph

695 commits

Author SHA1 Message Date
Peter Hutterer
cc7a8cb95e ei: make more ei_queue* functions semi-public for consistency
And drop the ei_add_seat() indirection.
2023-03-03 11:27:01 +10:00
Peter Hutterer
03d7f96ddd eis: remove some indirection from the device event handling
Now that we only have one nice hook as entry point for those events,
let's move (and harden) the code there.
2023-03-03 11:26:51 +10:00
Peter Hutterer
876e4044ab eis: error out if we're in the wrong state to start/stop emulating 2023-03-03 11:22:09 +10:00
Peter Hutterer
83b4902d9f ei: error out if we're in the wrong device state for emulating 2023-03-03 11:22:09 +10:00
Peter Hutterer
d698ed2f75 ei: remove some indirection from device events
Now that we only have one nice hook as entry point for those events,
let's move (and harden) the code there.
2023-03-03 11:22:09 +10:00
Peter Hutterer
1846223991 eis: add eis_client_disconnect_with_reason
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-03-03 11:22:09 +10:00
Peter Hutterer
8a2dd03a3f ei: reject a device with capabilities unknown to us
Untested because we cannot really trigger this code path with libeis.
2023-03-03 11:22:09 +10:00
Peter Hutterer
1a21c4854b ei: better protocol checking for invalid messages 2023-03-03 11:22:09 +10:00
Peter Hutterer
dd5bc6b6e7 proto: add a bunch of error reasons for debugging 2023-03-03 11:22:09 +10:00
Peter Hutterer
55a12f5cae Remove unused macro 2023-03-03 11:22:09 +10:00
Peter Hutterer
e67a0a7777 brei: add the brei_result object and bubble it up as error case
Add a new simple object "brei_result" that maps to the protocol-type
reason + explanation. That object is now returned instead of the errno,
giving us better debugging options.

This changes the dispatcher functions from returning an int to returning
a brei_result instead (default NULL for success). A helper function for
converting a neg errno to a result is provided for convenience for now,
eventually all these paths should deal with things correctly.
2023-03-03 11:22:08 +10:00
Peter Hutterer
579f0d07d2 Add a brei-proto.h generated header file
This will be needed to have access to the various disconnect reasons in
brei-shared.c.
2023-03-03 11:21:26 +10:00
Peter Hutterer
5631b54b96 eis: pass the disconnect reason around when disconnecting a client
No real functional changes right now, but allows for future multiple errors
2023-03-03 11:21:26 +10:00
Peter Hutterer
8a52cbbe10 scanner: detect duplicates in the XML file 2023-03-03 11:21:26 +10:00
Peter Hutterer
5ee9f738a8 proto: document what a "protocol violation" means 2023-03-03 11:21:26 +10:00
Peter Hutterer
e07d4638d5 scanner: drop the Argument.argtype in favour of DBus-type bindings
This was a brei-specifc implementation detail that is not really needed,
we can use the single-character dbus-style bindings.
2023-03-03 11:21:26 +10:00
Peter Hutterer
f500a1cd43 scanner: expand the help description 2023-03-03 11:21:26 +10:00
Peter Hutterer
1e4d273cd4 scanner: add the "camel" jinja filter
For conversion into CamelCase
2023-03-03 11:21:26 +10:00
Peter Hutterer
8979802893 scanner: rename to ei-scanner 2023-03-03 11:21:26 +10:00
Peter Hutterer
1bc7e2ad05 eis: send out the ei_callback interface version after setup.Done
This is currently the only interface that requires client-created
objects, so the client needs to know which version it can use. Let's
send it to them before the connection object.
2023-03-03 11:21:26 +10:00
Peter Hutterer
03bc5a1d6d ei: handle server-sent interface versions correctly
When we receive a ei_connection_setup.interface_version event, update
the supported version number for that interface to the correct minimum.
2023-03-03 11:21:26 +10:00
Peter Hutterer
027f85e195 proto: switch connection_setup.version to mirror interface_version requests
For most interfaces, the client announcing its supported version is
sufficient - the objects are all created server-side. For some
interfaces (ei_connection_setup and ei_callback right now) the client
needs to know the server-supported version.

So let's switch the current ei_connection_setup.version event (used to
negotiate ei_connection_setup's version) to a generic
`interface_version` event. This way our EIS implementation can
eventually send a version for ei_callback as well.
2023-03-03 11:21:26 +10:00
Peter Hutterer
0dba8769d4 ei: remove unused server_version and client_version fields 2023-03-03 11:21:26 +10:00
Peter Hutterer
7a2629fe42 meson.build: drop the protocol version
This is no longer applicable now that we have interfaces of varying
versions.
2023-03-03 11:21:26 +10:00
Peter Hutterer
273eda39ca Move the C proto templates to the src directory
These are very specific to libei/libeis, so let's not leave them
somewhere where they look like official bindings or something.
2023-03-03 11:21:26 +10:00
Peter Hutterer
29cf354de6 scanner: drop the Target class, push to templates
The Target was specific to libei/libeis, it resolved to "ei" or
"eis_client" depending on which component we were building. But that's
specific to our C implementation here, so let's push it into our C
implementation templates.
2023-03-03 11:21:26 +10:00
Peter Hutterer
e0d0c1af61 eis: require ei_seat and ei_devices
A client that skips on announcing those will get connected and
immediately disconnected again. There's no point to libei if you support
neither of those (at least for now).
2023-03-03 11:21:26 +10:00
Peter Hutterer
df99fc923b proto: if the target object no longer exists, don't send events/requests 2023-03-03 11:21:26 +10:00
Peter Hutterer
86dced2c40 eis: make ei_connection/callback/pingpong required interfaces
v1 of ei_connection requires callback and pingpong, so let's make all
three required and disconnect a client that doesn't support those.
2023-03-03 11:21:26 +10:00
Peter Hutterer
a80b19bb2c eis: immediately disconnect a client without the ei_connection interface
No point going through the setup here, just disconnect immediately.
2023-03-03 11:21:26 +10:00
Peter Hutterer
619b83220d eis: drop the device->id now that it's all protocol-wrapped 2023-03-03 11:21:26 +10:00
Peter Hutterer
6ed610e30e Split the ping/pong request into its own interface
Leave the ei_callback as-is and instead add ei_pingpong for the same
thing initiated by the server. The interface is otherwise identical but
for the direction it is supposed to flow.

This reduces the possibility of a client accidentally sending a
request when it is supposed to handle an event or vice versa.
2023-03-03 11:21:26 +10:00
Peter Hutterer
f41cc91599 proto: add a ping/pong request
This is effectively the same as connection.sync, but goes the other way.
This adds the ei_callback.done request.

In libeis this is (currently) enforced immediately after sending the
connection object. Not required there and makes the code a bit messier
but this way we can ensure that any client library handles that part of
the code.
2023-03-03 11:21:26 +10:00
Peter Hutterer
50013b4b3c protocol: fix a typo 2023-03-03 11:21:26 +10:00
Peter Hutterer
e84ddd1471 eis: drop the seat when the client requests it 2023-03-03 11:21:26 +10:00
Peter Hutterer
b481eff34c eis: only allow the available caps to bind to a seat
A client binding with caps >= the seat's current version will get
disconnected now.
2023-03-03 11:21:26 +10:00
Peter Hutterer
ea8df6402a scanner: handle since tags in enum values 2023-03-03 11:21:26 +10:00
Peter Hutterer
8c85b8fc1f protocol: add ei_connection.invalid_object
This event is to notify the client that an object used in a request was
unknown. This allows the client to work around race conditions like
binding to a seat that was removed.

This is currently the server-side only which is probably enough for now.
The only client-side created objects we have are the callbacks.
2023-03-03 11:21:26 +10:00
Peter Hutterer
f6cfe9803c scanner: make the invalid type message a bit easier to identify 2023-03-03 11:21:26 +10:00
Peter Hutterer
34889d4803 scanner: pass the component through as well
For the cases where we have to add "ei" or "eis" in a random place in
the template.
2023-03-03 11:21:26 +10:00
Peter Hutterer
d84ddd51e5 protocol: complete documentation for the protocol XML file 2023-03-03 11:21:26 +10:00
Peter Hutterer
a590537c8a protocol: mark the various destroyed events as destructors 2023-03-03 11:21:26 +10:00
Peter Hutterer
0a8501d882 protocol: mark the disconnected event as destructor 2023-03-03 11:21:26 +10:00
Peter Hutterer
cfbb906358 protocol: rename type to context_type
type is a reserved keyword in many languages, let's not make this harder
to use than necessary
2023-03-03 11:21:26 +10:00
Peter Hutterer
bf77479c6a protocol: rename the interface request to interface_version
More descriptive this way
2023-03-03 11:21:26 +10:00
Peter Hutterer
9e731ddf04 scanner: parse the type="destructor" attribute on requests/events 2023-03-03 11:21:26 +10:00
Peter Hutterer
2e4d984819 eis: don't send seat events unless the client supports ei_seat 2023-03-03 11:21:26 +10:00
Peter Hutterer
20e425a48d scanner: add the camel_name property to our messages
This allows for templating into EiConnectionSetup and the like
2023-03-03 11:21:26 +10:00
Peter Hutterer
58b430039a eis: destroy the eis_connection immediately after sending disconnect
Requests the client sent on the connection after disconnect
will thus be ignored.
2023-03-03 11:21:26 +10:00
Peter Hutterer
a0b2cfffa9 scanner: switch to a two-run parsing of the XML file
On the first run we extract the interfaces only, on the second run all
the rest. This allows us to pass the interface to the Argument where
appropriate.
2023-03-03 11:21:26 +10:00