Commit Graph

52 Commits (a8d864144299c95d4ba760a7d1b2bdab37edb298)

Author SHA1 Message Date
Peter Hutterer 5d53ec8005 Bubble up the width/height from the protocol to the dbus interface
Fixes #135
2019-07-15 09:38:19 +02:00
Peter Hutterer b16a16abde Add a SyncState signal to the DBus interface
Propagated whenever we start talking to the device (and then again when we
stop). The purpose of this signal is merely that a UI can show e.g. a progress
bar while we're talking to the device to ensure the user something is
happening.

Fixes #138
2019-07-15 09:38:19 +02:00
Peter Hutterer caf1264952 dbus: add file format version negotiation for the JSON data
Export the supported versions in a Manager property and require the client to
request a specific version in GetJSONData. Without that, the server could
never update the format and clients would have to support every single
historical version to make sure they can run against any version server.

Fixes #98
2018-02-19 11:17:18 +10:00
Peter Hutterer d4ea6e3938 dbus: change the JSON timestamp argument to 64 bit
Because we're totally going to ship tuhi in embedded devices that are going to
be in use until after 2038 when time resets to zero, the world goes big bang
and the only survivers will be 64-bit species. Or something like that. Either
way, the API documentation already said so anyway and the DrawingsAvailable
property is already 64 bit too.

Semi-confusingly: the dbus 64 bit unsigned type is 't', it doesn't stand for
'timestamp'.
2018-02-19 11:16:27 +10:00
Benjamin Tissoires d4dd672b2f live-mode: properly pack the fds over DBus
Keeping this one as a separate commit, so we can use it as a future
reference.
2018-02-14 06:23:25 +10:00
Benjamin Tissoires 1a6d0205df tuhi: hook up live mode
Currently just enable/disable live mode.
The int parameter is doomed to be an opened fd to the uhid node
2018-02-14 06:23:25 +10:00
Peter Hutterer 30620dfbf0 tuhi: when a device toggles 'registered', send out the required signal
Related to #80
2018-02-13 14:51:40 +01:00
Benjamin Tissoires 00fbff37ab dbus: fix signal name exported in the dbus introspection
We are using ListeningStopped, not ListenComplete
2018-02-06 15:17:27 +01:00
Peter Hutterer 5e82d1b378 Rename "pair" to "register"
"pair" is alrady taken by Bluetooth and since we have a bluetooth device here,
it can cause confusion. Use "register" instead, with an explanation in the
README for the more paranoid of us.

Fixes #67
2018-02-02 09:23:08 +01:00
Benjamin Tissoires fc219e4c57 janitor: silence deprecated warnings
While running the app in flatpak, there are a few deprecation warnings
coming in:
PyGIDeprecationWarning: GObject.SIGNAL_RUN_FIRST is deprecated;
	use GObject.SignalFlags.RUN_FIRST instead
PyGIDeprecationWarning: GObject.property is deprecated;
	use GObject.Property instead
PyGIDeprecationWarning: GObject.MainLoop is deprecated;
	use GLib.MainLoop instead
2018-02-02 10:46:47 +10:00
Peter Hutterer 31e1f2ad3b Export the Bluez device's object path
Rather than proxying all metadata (name, address, ...) add a reference to the
bluez device instead.

Fixes #60
2018-02-01 10:13:39 +10:00
Peter Hutterer e647e20426 Export the battery level/charge state 2018-01-30 18:53:55 +10:00
Benjamin Tissoires 9f118bbe15 janitor: convert double quotes into single quotes
Let's the developers of tuhi to consume more energy in their monitor
to light up more pixel when displaying single quotes whereas double
quotes.

It also makes the whole bit more uniform.

Fixes #32
2018-01-29 21:18:06 +10:00
Benjamin Tissoires 04f25a0a38 drop .format(), switch to f{} everywhere
and change some double quotes into single quotes when encountering them.

It's a new project, so force use of Python 3.6 right now

Fixes #29
2018-01-29 21:18:06 +10:00
Peter Hutterer ab385bd981 dbus: update the listening property, not the internal variable
Otherwise the PropertiesChanged never gets sent
2018-01-25 16:02:34 +10:00
Peter Hutterer 7a31a994fb dbus: return the drawings as array of timestamps
As we're planning to cache the data locally, the timestamps are a
unique-enough way that makes it possible to access a specific drawing.
And this way we can also delete some drawings without all other indices
shifting around.

Fixes #16
2018-01-25 14:55:10 +10:00
Peter Hutterer 80d214c78f Split the Drawing class out into a separate module
No point having multiple implementations of what a drawing is. Let's have it
in one module.
2018-01-25 14:55:10 +10:00
Peter Hutterer 3d516530c6 wacom: throw the exception (if any) to the "done" handler
Attach an errno to all exceptions, so we can bubble that up to the client
and display a message.

Fixes #24
2018-01-25 14:55:10 +10:00
Peter Hutterer 2fd781974f dbus: pass the bus name lost signal up to tuhi
If we're losing the bus name (i.e. we can't get it on startup) there really
isn't much we can do other than fail miserably. But in passing signals around
we can't do exceptions, so we have to move the mainloop to Tuhi so we can
quit() it on error.

Fixes #25
2018-01-25 09:18:59 +10:00
Peter Hutterer cae296e030 dbus: don't unset the searching client until we received the signal from tuhi
The API requires us to send the signal after stop
2018-01-25 09:18:59 +10:00
Peter Hutterer 1e31e6cba7 dbus: add a helper for sending signals 2018-01-25 09:18:59 +10:00
Peter Hutterer ba7c62fc0c dbus: add helper for properties changed signal 2018-01-25 09:18:47 +10:00
Peter Hutterer 584925a0d9 dbus: add a DBus base object
Currently just handling some properties that are common, but will do other
things soon.
2018-01-24 21:40:42 +10:00
Peter Hutterer 1a6071b93d dbus: use self.objpath instead of the hardcoded BASE_PATH in the manager 2018-01-24 21:39:56 +10:00
Peter Hutterer cfa4aca2df dbus: limit StartSearch to one client only
Basically copied from the device's Listening approach.

While it's possible to have multiple clients searching at the same time it's a
niche case and the effort at fixing the race conditions that come from that is
likely not worth the effort.

Let's add multiple simultaneous clients when we have a real need for it.
2018-01-24 19:23:20 +10:00
Peter Hutterer cce63d267b dbus: stop discovery when the searching client disappears
This is the single-client version only, we can deal with multiple clients
later.

Fixes #21
2018-01-24 19:23:20 +10:00
Peter Hutterer 5e32dc4872 dbus: don't update self.paired unless it changes
TuhDevice.paired is set on every device update (RSSI changes!) and that sends
a GObject.notify() for the property. Filter those, otherwise
we're just spamming dbus with PropertiesChanged notify events even
though nothing has actually changed.
2018-01-23 14:57:00 +10:00
Peter Hutterer 63ba0462ea dbus: send out PropertiesChanged when we update the drawings 2018-01-23 14:22:33 +10:00
Benjamin Tissoires ea890958d6 Start discovery mode when one device requests it
We need to check when the discovery stops (timeout from StartSearch)
if we should keep the discover one or not.
2018-01-23 14:22:33 +10:00
Benjamin Tissoires a51663342f dbus: keep track of the senders of the StartListening() method
If the sender disappear, we should stop listening for incoming events.

We match the Start/StopListening() that way, but if a client forgets
to call StopListening() before leaving and some data are being retrieved,
it's not our problem.
2018-01-23 14:22:33 +10:00
Benjamin Tissoires e3fff4015a implement a basic Start/StopListening
This implements the ListeningStopped signal (especially the EAGAIN if we're
already listening) but does not yet actually trigger the listening on the
device.

There is still no timeout, and no signal gets emitted.
The current way of testing this is:
- call StartListening() on the DBus device
- start discovery on the adapter by some other mean
- press the button on the device -> the sync will happen
- call StopDiscovery()
- press the button on the device -> the sync will *not* happen
2018-01-23 14:22:33 +10:00
Peter Hutterer 010c651d6f dbus: add a __repr__ for the TuhiDBusDevice
And remove a now obsolete debugging statement, this was just put there to
debug the PropertyChanged code
2018-01-23 14:22:33 +10:00
Peter Hutterer d3192dc070 dbus: Send out a PropertyChanged event when a device is paired
Just updating the array isn't enough, we need to bubble up the property
change and then manually send the PropertyChanged event
2018-01-22 17:14:37 +10:00
Peter Hutterer daac6e6d96 dbus: drop the "paired" flag from create_device
We can get this from the device now
2018-01-22 17:14:37 +10:00
Peter Hutterer a2fd3cd8d1 dbus: on StartSearch(), emit PairableDevice signals for already known devices
If we created a device before StartSearch was called, we need to manually
send the signal to make sure the client sees it.
2018-01-22 15:25:34 +10:00
Peter Hutterer 0b7f756ba0 dbus: add the device's Address to the introspection XML
Code was already there, but the XML was missing the address
2018-01-22 15:24:56 +10:00
Benjamin Tissoires f6d09d7086 dbus: fix timeout error if the index is invalid
If the index is not valid, a python exception was raised, and the dbus
message was left without and answer.

Coincidentally, this matches the documentation
2018-01-20 12:37:50 +10:00
Peter Hutterer d4405cc1ef Hook up a ButtonPressRequired signal
When the nordic communication requires us to notify the user to press the
button, emit a signal and pass that up.
2018-01-19 13:40:26 +10:00
Peter Hutterer aa1a5e6689 Revamp the pairing process and rename to Search
The previous process had a problem: the device object didn't exist until after
pairing was complete. But to pair we need some user interaction (press button
on device) and thus the ability to send notifications from the device to the
dbus client at the right time. This wasn't possible with the previous
approach.

The new approach:
* renames Start/StopPairing to Start/StopSearch to indicate we're just
  searching, not pairing in the manager
* creates a org.freedesktop.tuhi1.Device object when a suitable device is
  found. That object is not in Manager.Devices, it's "hidden" unless you know
  the object path.
* Sends a PairableDevice signal with the new device's object path
* Requires the client to call Pair() on the device
* If the timeout expires without pairing, the device is removed again
2018-01-19 13:40:26 +10:00
Benjamin Tissoires 06e8d69e9d Implement pairing of a new device
This includes the new pairing code for the Spark which is slightly different
to the one from the Slate
2018-01-19 13:40:26 +10:00
Peter Hutterer aa1820e21c Send out the PairableDevice signal when we have a device 2018-01-19 11:15:12 +10:00
Peter Hutterer 43b1c4057c dbus: implement StartPairing/StopPairing on the manager
Triggers a StartDiscovery()/StopDiscovery() on the bluetooth adapters, but
with a fixed timeout of 30s.
2018-01-19 11:07:25 +10:00
Peter Hutterer 5f5ce71aef dbus: properly return from Listen()
If we don't do the dbus dance for returning a value here, we get a timeout
eventually.
2018-01-17 13:41:35 +01:00
Peter Hutterer f9756a71ce Add commandline arguments to enable verbose mode
Create a logger hierarchy, that way we only need to set the root logger to
DEBUG and the rest goes along with it.
2018-01-17 13:41:35 +01:00
Peter Hutterer 3a23610e08 Connect the WacomDevice drawings to the TuhiDrawings
And fixing a few issues with pressure, etc. on the way
2018-01-15 16:15:35 +10:00
Peter Hutterer cf68ebc9ce tuhi: create a TuhiDevice as glue object between front and backends 2018-01-15 16:15:33 +10:00
Peter Hutterer b7ce16fd38 dbus: remove the now-obsolete main() method 2018-01-15 16:14:19 +10:00
Peter Hutterer f293ef6e14 dbus: use the logging class too 2018-01-15 16:14:11 +10:00
Peter Hutterer c4b0807c3c dbusserver: emit the bus-name-owned when we have the bus
And rename from 'owned' to 'acquired', that's better english
2018-01-15 09:14:29 +10:00
Benjamin Tissoires af42bc1b27 dbusserver.py: fix flake8 warnings
./tuhi/dbusserver.py:55:1: E302 expected 2 blank lines, found 1
./tuhi/dbusserver.py:75:17: E126 continuation line over-indented for hanging indent
./tuhi/dbusserver.py:77:29: E203 whitespace before ':'
./tuhi/dbusserver.py:155:13: E126 continuation line over-indented for hanging indent
./tuhi/dbusserver.py:156:17: E131 continuation line unaligned for hanging indent

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-01-12 20:23:47 +01:00