Commit graph

21 commits

Author SHA1 Message Date
Peter Hutterer
b6f477fb96 util-object: split macro to generate unref into one two
One macro that also defines the cleanup function, one macro that only
defines the unref. This is required for any place where we want to
use cleanup from multiple source files - like the test suite.
2022-03-03 05:41:15 +00:00
Peter Hutterer
46681e2855 Add SPDX identifiers to all source files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-03 00:27:36 +00:00
Peter Hutterer
5f2afdf806 Fix a bunch of compiler warnings
Most are signed vs unsigned, the remaining ones are an unused
variables/functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-01 23:28:49 +00:00
David Redondo
befbf2005c Free lockfile path
Signed-off-by: David Redondo <kde@david-redondo.de>
2021-12-05 23:14:54 +00:00
Peter Hutterer
014c0ce081 eis: use a lockfile to determine whether we can remove the old socket
Same approach as libwayland-server

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-18 09:10:43 +10:00
Peter Hutterer
225e001c55 eis: close the socket fd on error
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-08-18 08:54:02 +10:00
Peter Hutterer
ab386f3cdb util: add an _unref_ cleanup + declaration function
To cut down on the boilerplate, an unref-able struct variable can now be
declared as
   _unref_(type) *name = NULL;
which is the equivalent of
   _cleanup_(type_unrefp) struct type *name = NULL;

Let's see how that style ends up reading.

This means we can get rid of the custom _cleanup_foo_ functions everywhere, no
need for all the extra #defines etc. A somewhat special case is systemd which
defines the various unrefp functions for us in the headers, so we can use them
directly.

OBJECT_IMPLEMENT_UNREF now also creates the unrefp function for this object -
this of course conflicts where DECLARE_UNREF_CLEANUP_FUNC is in scope. Not a
problem so far, let's see how we go.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:17:16 +10:00
Peter Hutterer
3c464186c6 util: allow source_remove(NULL)
Removing a non-existing source has the desired effect after all - the source
won't generate events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-16 14:07:23 +10:00
Peter Hutterer
e6acbdfa31 eis: include util-object for the socket backend
For correctness, it's pulled in by one of the other headers anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-16 14:07:12 +10:00
Peter Hutterer
31800cf870 util: make the OBJECT_IMPLEMENT_CREATE no longer static by default
Better for consistency with the other functions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-15 23:23:51 +00:00
Peter Hutterer
f3a60ca6b3 Fix maybe-uninitialized warnings
Building with a releaes build reshuffles things so this ends causing potential
issues. Initialize to NULL to avoid around this.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 16:07:54 +10:00
Peter Hutterer
355093cc1b libeis: replace the logger utility with a custom logger handling
The logger utilities are useful for quick prototyping, but we've reached the
point where we need the "proper" implementation of a log handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-20 14:44:38 +10:00
Peter Hutterer
92737f7762 libeis: fix a crasher if the socket is removed before a listener starts
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 14:46:20 +10:00
Peter Hutterer
9c2c912353 util: change the sources API to source_new and sink_add_source
This is a more explicit API that makes it more obvious where the ref/unref
calls need to go. The sink now has two refs to the sources as well (epoll data
pointer and the list) which means a caller cannot just source_unref() anymore
without removing a source. Since this is how we've been using it anyway - meh.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 14:46:20 +10:00
Peter Hutterer
35d676e7f7 libeis: fix the client ref handling and move the list to the eis context
Let the context take care of adding the device so we have better separation
here. Removal isn't handled in a special way because any list node can remove
itself safel anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 11:37:51 +10:00
Peter Hutterer
d017eb1a91 Fix the sources ref handling again
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 09:41:37 +10:00
Peter Hutterer
ba9b0bb903 eis: implement an fd backend
Caller opens the socket, passes it to eis, done.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:19:03 +10:00
Peter Hutterer
69448e247c libeis: rename to eis_setup_backend_socket()
Now that the backend is more of an implementation detail, namespace for
eis_setup_backend_foo()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
d2ecf43abd libeis: switch to a single eis_new() function
The main reason for having different functions to create the initial context
was so we can nest the eis struct inside the context-specific struct. That
shouldn't leak into the API though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-06 15:12:19 +10:00
Peter Hutterer
1bdca21772 libeis: remove the socket on exit
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 15:38:40 +10:00
Peter Hutterer
f7a24b2fbd Add the minimal implementation for a UNIX socket libeis server
This is the minimum framework to support new clients, added devices and
pointer relative motion events. It's missing a bunch of checks and
verification, most of the server hooks aren't there yet, the only
implementation is a UNIX socket and the protocol is plain text (but at least
the last two makes it netcat-compatible).

Protocol is plain text for now and interaction is like this (S is server, C is client):
S: hello
C: connect myclientname
S: connected
C: add 2 4
S: accept 2
C: rel 2 -1 1
C: rel 2 5 4

Where the last two lines are: add device with id 2 and capability mask 0x4,
send a relative pointer motion event for device 2 with coordinates -1/1, then
5/4.

The implementation relies heavily on some abstraction and macros galore, see
the various util-* files. These are largely copied from libinput, with a few
parts removed and a few other parts added.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-28 19:33:34 +10:00