Commit graph

495 commits

Author SHA1 Message Date
Peter Hutterer
086f96a702 proto: split up message length and opcode again
Now that we have 64 bit integers on the wire and 64 bit object IDs,
we're already different to the Wayland protocol. So we might as well get
the full length and split message length and opcode again to make header
parsing and composing simpler.

This effectively reverts commit bf45a7182cb2f4c13f11e141fc846244d3ac6212.
2023-03-03 11:27:01 +10:00
Peter Hutterer
ba51f434a6 proto: switch object ids to 64 bits 2023-03-03 11:27:01 +10:00
Peter Hutterer
d4980d8579 brei: abstract string handling in a struct
Makes the code a bit easier to read and understand than the previous
offset mangling.
2023-03-03 11:27:01 +10:00
Peter Hutterer
d686d4e281 brei: factor out header size for the unit tests 2023-03-03 11:27:01 +10:00
Peter Hutterer
960bb6db26 util: add a strlen0 helper function
Same as strlen() + 1, but handles NULL and avoids typos by forgetting
the +1 in all the sites we need to call it.
2023-03-03 11:27:01 +10:00
Peter Hutterer
0ef1bb95d4 ei: remove obsolete device->id 2023-03-03 11:27:01 +10:00
Peter Hutterer
c998bae33f Remove obsolete declaration 2023-03-03 11:27:01 +10:00
Peter Hutterer
1e0796f432 Remove now-obsolete proto files 2023-03-03 11:27:01 +10:00
Peter Hutterer
b309798bf1 Switch object ids to use the object_id_t typedef 2023-03-03 11:27:01 +10:00
Peter Hutterer
8ea6b81f40 Change the ei_device_capability values to match the protocol
In the protocol this is a bitmask, let's make it the same in the
interface to avoid confusion in the implementation.
2023-03-03 11:27:01 +10:00
Peter Hutterer
2338e19aab ei: correct arguments to the invalid object log message 2023-03-03 11:27:01 +10:00
Peter Hutterer
c832ce3ddc protocol: split the handshake version negotiation from the other interfaces
Previously, we'd send one interface_version event for "ei_handshake"
immediately but all others after the client requests handshake.finish.
This was too confusing to document and not clear how it would work, so
let's make this simpler by splitting it up.

There is now a handshake_version event from the server, sent immediately
on connection that denotes the maximum version number for the interface.
And a handshake_version request from the client which must be the first
one by the client.
2023-03-03 11:27:01 +10:00
Peter Hutterer
35f5fa102c proto: rename ei_connection_setup to ei_handshake
This is a better name for the initial handshake and easier to
distinguish from the ei_connection this way too.

Suggested by Jonas Ådahl.
2023-03-03 11:27:01 +10:00
Peter Hutterer
38dc5dc72f proto: shift the capabilities down by one
These were previously (1 << cap) for convenience but that results in the
capability mask on the wire starting at 2 - which is a bit awkward.

Lets shift them down by one so we start the mask at 1.
2023-03-03 11:27:01 +10:00
Peter Hutterer
47467bfe0e proto: rename connection_setup.done to .finish
Avoids ambiguity with the .done events from e.g. the seat or the device.
2023-03-03 11:27:01 +10:00
Peter Hutterer
0897722493 proto: drop the seat caps and cross-reference device caps instead 2023-03-03 11:27:01 +10:00
Jonas Ådahl
eecf69af48 protocol: Make timestamps a single 64 bit argument
With 64 bit integers on the wire, we don't need to split timestamps in
milliseconds and microsecond parts.
2023-03-03 11:27:01 +10:00
Jonas Ådahl
03c0ab73dd protocol: Add support for 64 bit integers on the wire
This is useful for e.g. not having to split timestamps.
2023-03-03 11:27:01 +10:00
Peter Hutterer
d319c3a725 protocol: rename "type" arguments and events
Type is a reserved keyword in many languages, let's make this easier for
those.
2023-03-03 11:27:01 +10:00
Peter Hutterer
658a861c2a proto: add a serial number to the modifiers event 2023-03-03 11:27:01 +10:00
Peter Hutterer
5f69ee2417 proto: switch to use the Wayland message header
No real functional changes, this just changes the message header to be
header = [object_id, msglen << 16 | opcode].

The only difference to the wayland protocol is now the fixed vs float
but otherwise tools that can print/debug/mangle the wayland protocol
should be easily adjustable for this protocol too..
2023-03-03 11:27:01 +10:00
Peter Hutterer
30b9fec787 util: add iobuf_prepend() 2023-03-03 11:27:01 +10:00
Peter Hutterer
e5b37dedc8 protocol: add serial numbers to the various destroy events
This should allow EIS to track whether events that were sent before or
after a destruction of a resource.
2023-03-03 11:27:01 +10:00
Peter Hutterer
cc0a06aed6 scanner: rename to as_c_arg and c_type for the c-specific functions 2023-03-03 11:27:01 +10:00
Peter Hutterer
1c9ce9b680 Add serial numbers to the protocol
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-03-03 11:27:01 +10:00
Peter Hutterer
845f990883 protocol: change the context type enum to start at 1
This avoids future bugs for treating this as a boolean field.
2023-03-03 11:27:01 +10:00
Peter Hutterer
403e40597d Replace remaining errno-based errors to proper brei_results 2023-03-03 11:27:01 +10:00
Peter Hutterer
a6565fd86b brei: change the various errors to PROTOCOL 2023-03-03 11:27:01 +10:00
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
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
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
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
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
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