Commit graph

17359 commits

Author SHA1 Message Date
Berthold Stoeger
4bd217299a mobile/edit: don't add dive site twice to table
When editing a dive on mobile we might have to create a new
dive site. That site is added to the global dive site table
in the undo command. However, the code in QMLManager created
the dive site with create_dive_site*() functions, which already
adds it to the table. The undo command then added the dive
site again leading to a hang of the application.

To solve this problem, create new alloc_dive_site*()
functions that do the same as create_dive_site*()
but do not add it to the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17 14:05:24 -07:00
Dirk Hohndel
ccd024f0ee mobile/DC-download: select reasonable connection after rescanning
This seems to make more sense than to not select anything (which was the
previous behavior).
If the same connection is still available, select it again. Otherwise
pick the top connection (which is the right thing to do if the user has
just plugged in a USB device and refreshes the list -- that device will
show up as top entry).

Based on a suggestion by Christof Arnosti <charno@charno.ch>

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 13:59:18 -07:00
Dirk Hohndel
2abfd16a10 mobile/DC-download: show USB devices before BT/BLE
This makes sense because USB devices will only show up when connected,
while BT/BLE will get listed once they are paired, even if not currently
connected. So the higher likelihood of being the device a user is looking
for is for any USB devices that show up, so those should go first.

Suggested-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 13:59:18 -07:00
Berthold Stoeger
71f573da2a git: return strdup()ed empty string on error in pop_cstring
The pop_cstring() function is used by the git parser to
duplicate a quoted string. On error, it returns an empty
string literal. Since the caller expects a copied string
and takes ownership of that string, it will ultimately
be freed.

Concrete example: a log with erroneous cylinder data was opened
getting such an empty string literal as description. On closing or
syncing with the cloud, the dive is freed, leading to a free
of the string literal -> crash.

Return a copy of the empty string instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-16 10:57:12 -07:00
Dirk Hohndel
0a463aad36 Translation updates
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 08:48:21 -07:00
Dirk Hohndel
9236578734 translations: add missing plurals for en_US
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:37 -07:00
Dirk Hohndel
fe9a2ab5c3 Mobile user manual: some updates for Subsurface-mobile 3.0
This needs more work and especially new screen shots, but for now this
covers at least some of the most important changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
91a97e09e5 Update Subsurface-mobile version
I believe this deserves a major version number increment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
7719373f1a Android: remove legacy FTDI support
This works on almost no devices anymore and has been replaced by the USB
serial support for Android.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
2265a27912 android/usb: better memory management
Instead of relying on the std::vector staying unchanged and not freeing
its members, instead keep a copy of the object in our DCDeviceData class.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
0b72495413 android/usb: simply restart the download after receiving permission
If the user tries to download from a device that he hasn't given the app
permission to read from, Android will pop up a dialogue asking for that
permission. With this after giving the permission we continue (well,
technically, restart) the download which is likely the expected behavior.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
4619b4932e android/usb: refresh USB device list on entering download from DC
The usbRescan() code is smart enough not to duplicate entries that might
already be there. And with this the user doesn't have to manually tap
rescan if they didn't open Subsurface-mobile via the intent after a
device was plugged in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
ae537fc400 android: don't show /dev/ttyS* connection
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
87e12029f9 android/usb: remove "autoselect driver" option for unknown VID/PIDs
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ff2f199eed mobile UI: rescan button on DC Download page rescans BT/BLE/USB
This way even if a USB device wasn't added through an Android intent, we
still have a way to scan for it and select it. This is especially
important in case a user has a cable that we haven't seen yet (i.e. with
a VID/PID that we haven't added to Subsurface-mobile), but that
nevertheless works with the android usb serial drivers.

This also makes the flow a little more logical / consistent when
deciding which connections to show.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
274dbc2ebf mobile UI: remove special case for Atomic Aquatics
This dive computer hasn't been supported on Android in quite a while.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ae42b7ceb0 android/usb: stop adding the obsolete 'usb-serial' connection
The code that supported this has now been replaced by the USB device
selection code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
ec3a968df9 android/usb: pass in the UsbDevice when downloading
This finally allows us to download from not just the first device, but specifically
the device that the user picks.

Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
1495aa2dbf android/usb: show download page again after USB permission granted
If the user hadn't granted USB permissions, yet, we asynchronously get informed
once they did that. This ensures that the user gets taken back to the download
page once they approve.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
4cd453dc92 android/usb: parse the usbDevice when responding to intent
This vastly simplifies our handling of devive information as we simply use
what is already in the descriptor. This way we do not duplicate information
about USB devices in the QMLManager.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
b0eccec8ed android/usb: pass the usbDevice for intent handling
Instead of creating a string with all the object information, simply pass
the actual object to the C++ code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c19e3bd5ba android/usb: remove alternative way of scanning for devices
We now always create a list of usb devices that doesn't list a driver
for known devices, and adds multiple entries with each of the drivers
for devices that are unknown to us.

This removes some debugging output in the ..._open() function as well.

This could be combined with Christof's earlier commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c81854ca21 android/usb: add helper to recognize chipsets known to us
This will allow us to know when we can guess the driver.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
c2077992ff android/usb: guess the actual manufacturer and product
For a small number of dive computers we can actually figure out the
real information which we can then later show to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
d953c645e9 usb-serial-for-android: React to usb "permit granted" intent (stub)
When a user is downloading from a DC for the first time (without using
the "usb device connected" popup), the user is requested to grant
permission to use the USB device.

This is done asynchronously, thus the download is aborted. To be more
user-friendly, we now react to the intent with the "usb granted" result.
The plan here is to start the download again.

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
ce7d4d1ca6 usb-serial-for-android: More fields in device descriptor
As discussed in issue #2657, there are now more fields about the usb
device information in android_usb_serial_device_descriptor.

Additionally, the user-facing string now makes more sense:
"vendor [<bus# as integer>:<dev# as integer>]"
Where vendor is as reported by android, but shortened to 16 characters.

Examples:
FTDI [1:2]
Silicon Labs [1:4]

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
344f7861b4 usb-serial-for-android: Use correct format spezifier for size_t
Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-16 07:58:20 -07:00
Christof Arnosti
779b84bfa0 usb-serial-for-android: Use wakelock
Android takes some pretty hard measures to save power, including
shutting down the CPU. Since this can interfer with the download from an
usb serial device, we now use a wakelock to keep the CPU running during
download.

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Christof Arnosti
a34a81d120 android usb serial: Prepare device / driver select
This commit contains the serial_android_usb part of the changes proposed
in issue #2657.

What's implemented:
- A data structure that contains all the data that can be used to
  describe an usb device (including user-facing string).
- A function to get a list of all attached usb devices (optionally with
  selectable driver class).
- Changes in the serial_android_usb_open-function and in the Java part
  to use the information about the usb device and optionally selected
  driver when connecting.

This commit keeps compatibility with the current UI-Code in the case
that only one USB-Device is connected. If two devices are connected,
only the first one is tried.

There are still some small things to do:
- Change the user-facing string to something more descriptive.
- Parts which aren't uesd anymore when the UI-Part is implemented are
  simply marked as obsolete (to keep compatibility for now).

But generally it seems to work.

[Dirk Hohndel: some white space / coding style adjustments]

Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Dirk Hohndel
822b05bec4 mobile/download: only use device guess if no USB device plugged in
If we explicitly open the download page after the use plugged in a USB
device, don't try to use guesses from the BT/BLE pairings to populate
the device/connection dropdowns.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16 07:58:20 -07:00
Linus Torvalds
5e89d81d9d iostream: fix incorrect rfcomm error case when writing
This is the exact same case as the previous commit, just for the writing
side.

Once again, it's the subsurface rfcomm iostream code that can return
DC_STATUS_SUCCESS with a byte count of zero when something goes wrong
with the write.

And once again, our libdivecomputer iostream code didn't try to be
robust and protect itself from that case.

The fix is equivalent, although slightly simpler, since the write side
doesn't have the whole timeout issue.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-14 11:34:46 -07:00
Linus Torvalds
4ee4bbdb58 iostream: fix incorrect rfcomm error case when reading
We had two independent bugs here, both of which needed to fire for this
to cause a problem.  This fixes both of them.

The first bug was that our rfcomm code would return DC_STATUS_SUCCESS
with a zero-sized read when a timeout happened, or when the rfcomm
socket had disconnected.  That makes absolutely no sense.  We should
return DC_STATUS_TIMEOUT on timeout, and DC_STATUS_IO if the socket has
disconnected without any data.

The fix to this is to make the whole rfcomm iostream read logic much
simpler: there's no need to loop at all for partial results, because the
libdivecomputer iostream side will do the loop for us (and handle
partial results much better: it knows if the target backend can handle
those partial results or not).

The second bug was in our libdivecomputer iostream read() function,
which reacted very badly to this bad return value.  This updates our
libdivecomputer branch to one that is more careful about things.

Reported-by: linuxcrash <albin@mrty.ch>
Debugged-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-14 11:34:46 -07:00
Robert C. Helling
0acfa28d87 Make statistics window resizable on Mac
For some reason, the window needs an active maximize
button to be resizable on Mac.

Fixes #2671

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-12 11:48:27 -07:00
Berthold Stoeger
7387b10b29 cleanup: remove current_dive parameter from divesSelected signal
The diveListNotifier.divesSelected() signal is used to inform the
models of a selection change. It sent the current dive as a second
parameter. This is redundant, because the only sender of the signal
sets current_dive just before sending the signal. Remove the
parameter, which appears to be an artifact.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-12 07:09:01 -07:00
Berthold Stoeger
950ae951bc divetripmodel: change current dive if no dives are selected
The DiveTripModelTree::divesSelected() returned early if
no dives were selected. Thus, the current dive was not
updated. Remove the check for no dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-12 07:09:01 -07:00
Dirk Hohndel
ff68fd7c0c mobile/export: fix invalid reference
This just removes broken code. That file select dialog is still just a very
strange idea and should be revisited at some point.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
f2a8562b5d mobile UI: stop trying to play with opacity
Since we are switching between pages, the whole opacity mechanics make no
sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
84d45485fd mobile UI: remove duplicate StartPage
This was a merge error in the dive list rewrite and brought in a code block that
had moved, which caused issues with correctly switching to the dive list.

Calling setupActions() moves to the diveListView (where it really belongs).

Instead of messing with the visibility of components of the same page, we now
simply switch out the shown page.

Fixes #2667

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Dirk Hohndel
0d1510929f mobile UI: make user and log messages consistent for no cloud
A number of our messages were misleading in the no cloud case. This should help
to reduce confusion.

Adding the save_dives() call after creation of the repo appears to help us have
a valid repo in place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-12 07:07:48 -07:00
Robert C. Helling
285fa8acbc Grammar: replaces 'indexes' by 'indices'
Grammar-nazi ran

git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'

to prevent future wincing when reading the source code.

Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-11 08:26:30 -07:00
Christof Arnosti
cb28158b9a Add timestamps to libdivecomputer.log
Since I learned while trying to implement this that getting sub-second
resolution time in portable C99 is hard (especially for someone who is
used to the comfort of std::chrono and Howard Hinnants date library) the
timer-implemetation from libdivecomputer is now copied to the subsurface
source.

Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-10 17:42:54 -07:00
Dirk Hohndel
b6163804fd Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 14:07:59 -07:00
Dirk Hohndel
1b2db4e058 translation tooling: fix script to not include Kirigami strings
Not sure when it started doing that - we don't want those in our
translations, I believe.

Also, we appear to suddenly get problems with too many numerus lines
unless the existing translation is deleted, first. Very strange.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 14:07:42 -07:00
Dirk Hohndel
ca75177f0c Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 13:35:16 -07:00
Dirk Hohndel
e766423300 Android: stop trying to list only FTDI based serial DCs
Thanks to the new USB serial implementation also that complex special-casing
is no longer needed. This should do the right thing now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 13:27:43 -07:00
Dirk Hohndel
f4589583ef Android: remove USB devices we don't support
The HID devices and the Atomics Aquatics Cobalt cannot work on Android
right now. We should claim to support them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 13:27:43 -07:00
Dirk Hohndel
0212b1b9f7 undo infrastructure: improve undo command texts
For many of the commands it is fairly easy to add information that makes
it easier to figure out what actually happened. That's especially true
for commands operating on dives. Trip and dive site edits haven't been
given these more elaborate undo texts (yet).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
8ce4e10ccb cloud storage: add list of changes made to commit messages
This should make it easier to figure out what operations lead to the commit
that is written to git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
160d2ab071 core: make command texts available for C code
Create a C string (which the caller needs to free) with the executed commands
in this session.

The detour via the callback allows us to not make the corelib depend on the
commands, which is nice for tests, export-html, and smtk2ssrf.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00
Dirk Hohndel
626a149b7c undo infrastructure: collect the texts for the executed commands
This creates a single string with all the undo texts that are on the stack.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10 09:25:57 -07:00