Commit graph

17947 commits

Author SHA1 Message Date
Dirk Hohndel
c87e028602 core/bluetooth: stop discovery once the dive computer has been found
There is no need to continue to look, and at least with the Shearwater
Peregrine having the scan run while we are trying to discover characteristics
appeared to cause issues.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
ba3efae6e8 macOS/bluetooth: remove the forced rescan
I can no longer reproduce the case where this rescan was necessary.
So let's remove it as it causes additional wait time for BT/BLE users on macOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
adeade5581 core/BLE: correct the reference for the Shearwater characteristic
They use that same UUID on the Peregrine as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
b3c88d4def core/BLE: detect Sherwater Peregrine
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Berthold Stoeger
fe3021b88a cleanup: consistently use get_cylinder() accessor
get_cylinder(d, i) is more readable than d->cylinders.cylinders[i].
Moreover, it does bound checking and is more flexible with respect to
changing the core data structures. Most places already used this accessor,
but some still accessed the cylinders directly.

This patch unifies the accesses by consistently switching to get_cylinder().
The affected code is in C++ and accesses the cylinder as reference or
object, whereas the get_cylinder() function is C and returns a pointer.
This results in funky looking "*get_cylinder(d, i)" expressions.
Arguably still better than the original.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-08-21 08:48:22 -07:00
Linus Torvalds
efc1b4f31a Update to current libdivecomputer
The libdivecomputer internals changed for USB devices, and now we need
to scan the USB devices before calling libdivecomputer.  That's the same
pattern as for USBHID and IRDA, so let's just regularize this all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-21 08:47:08 -07:00
Berthold Stoeger
4d15f8ee33 cleanup: remove obsolete logic in getFormattedCylinder()
getFormattedCylinder() is a helper function to format a list
of cylinders. It had that weird logic that it would skip
cylinders without description unless it is the first, which
would instead be written as "unkown".

The reason was the old statically sized cylinder array,
where it wasn't clear if a cylinder was actually in use.

This became obsolete when switching to a variable size
cylinder array. Firstly, all cylinders in the array were added
by the user. Secondly, we now also support dives without
cylinders, i.e. the first cylinder is not any different from
the rest.

Thus, remove the logic and format any cylinder without
description as being of type "unknown".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-08-21 08:40:56 -07:00
Dirk Hohndel
2c878ea6b6 mobile: update version to 3.0.13
Quite a few little changes lately that all deserve a new nobile app
release, and each release requires an updated version number.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-18 13:23:35 -07:00
Dirk Hohndel
cadfec26ab Android: update target SDK version to 29
This will be required for Android updates over the next few weeks.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-18 13:22:11 -07:00
Dirk Hohndel
cc5ae1911b core/bt-discovery: recognize BT names of four more dive computers
This adds the Oceanic Veo 4.0 & Pro Plus 4, the Sherwood Wisdom 4 and the
Tecdiving DiveComputer.eu to our list of known names.

The Oceanic Pro Plus X detection is simply moved to have the other names
in a more logical order.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-18 12:56:04 -07:00
Berthold Stoeger
f24fe10765 core: fix dive renumbering logic on import
0249e12 split up the dive import logic in multiple steps. Thereby,
the one of the conditions for renumbering the imported dives (is
the last old dive numbered) got messed up: The first number of the
new dive was compared to the total number of old dives, which makes
no sense.

- Simply check for the number of the last existing dive (if any).
- Don't remember the number of old dives - the original table is
  not modified anyway.

Fixes #2731

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-08-17 13:21:49 -07:00
Dirk Hohndel
9ae2a8bf7a mobile: update version to 3.0.12
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:40:28 -07:00
Dirk Hohndel
d1de3f77ee Update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Dirk Hohndel
21d70cbeb1 mobile/cleanup: use local variable to simplify code
The old code wasn't wrong, and likely the compiler turned this into something
that wasn't really terrible... but yeah, 5 unnecessary calls to a helper
function just bugged me. And I think the new code is much easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Dirk Hohndel
5299d8291d core/localized-parsing: correctly handle group and decimal separator
We are usually showing pressures with localized group separator. And we made a
total mess out of things when then re-parsing those values. This caused us to
ignore start and end pressures in Subsurface-mobile when those were entered in
psi and included a group separator:

2,900psi was turned into 2.900psi which we then rounded to 0 mbar.

This fixes the problem by asking Qt to do the right thing instead of doing
stupid separator magic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Dirk Hohndel
ebcfb46d8c mobile/dive-edit: fix incorrect handling of multi tank gas mixes
A silly copy and paste error caused us to overwrite the gas mixes for
all the tanks with the gas mix in the first tank.

Fixes #2913

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Linus Torvalds
77a11400a1 Fix event merging when merging dives
The merge_events() function was subtly and not-so-subtly broken in a
couple of ways:

 - in commit 8c2383b49 ("Undo: don't modify source-dives on merge"), we
   stopped walking the event list after we merged the first event from a
   dive when the other dive computer had run out of events.

   In particular, this meant that when merging consecutive dives, the
   second dive only had the first event copied over to the merged dive.

   This happened because the original code just moved the whole old list
   over when there was nothing left from the other dive, so the old code
   didn't need to iterate over the event list. The new code didn't
   realize that the pointer movement used to copy the whole rest of the
   list, and also stopped iterating.

   In all fairness, the new code did get the time offset right, which
   the old code didn't. So this was always buggy.

 - similarly, the "avoid redundant gas changes" case was not handled for
   the "we ran out of events for the other dive computer" case.

This fixes both issues.

Cc: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-15 09:46:19 -07:00
Salvador Cuñat
e3a158624b smtk-import: Workaround segfault in mdbtools memcpy call
Smtk2ssrf has a segfault which matches quite well glibc's
CVE-2019-6488 (except for the x32 part).
It came from a call to memcpy in mdb_ole_read() func, used to get the
header and the profile of a dive from the database.
May be it could be fixed in libmdb but Mdbtools project has been stalled
for the past 5 years so ...

The segfault seems to be triggered by an empty profile in the first dive
in the database (a pretty common case in older Aladin DCs due to their
little memmory). The only special thing here is the fact it's the first
dive in the database structure (not the first by its index).

We can avoid the crash if we don't call mdb_ole_read_full() func on zero
sized profile field.

The problem here is we can't get the size of the fields and build the
MdbColumn in the same roud.  Happily we just need the MdbColumn struct
for the dive profile and header.  So, we can change the previous approach
using MdbColumns through almost all functions to a simpler one using the
already bounded strings by smtk_open_table() and just using the
col[n]->bind_pointer in the main function where the columns are built to
be used by mdb_ole_read_full().

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-08-13 10:02:12 -07:00
Salvador Cuñat
45812da046 smtk-import: Fix build script
Subsurface build needs install-root path to link libdc

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-08-13 10:02:12 -07:00
Robert C. Helling
73151ca1d9 smtk2ssrf Perl script: Add some error reporting
So far, if the conversion process failed, we simply returned
an empty file. Now, we report that something's wrong.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-08-08 14:16:54 +02:00
Dirk Hohndel
6a706a7000 mobile: update version to 3.0.11
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-29 07:56:21 -07:00
Dirk Hohndel
01d4e59710 core: detect McLean Extreme dive computer as BLE device
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-27 07:50:54 -07:00
Dirk Hohndel
ff32737157 update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14 10:57:10 -07:00
Dirk Hohndel
4ec62441c1 mobile/download: don't allow download without connection set
It appears that multi line attributes silently fail. Without this change, the Download
button is enabled if vendor and product are chosen, even if there isn't a connection
selected. With this change (having all three conditions on the same line) the code
works as expected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14 10:57:10 -07:00
Dirk Hohndel
a4295a3e9f core/BLE: add detection of Scubapro Aladin A1
This was supported in libdivecomputer, but not recognized as dive computer by
our core BLE code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14 09:12:31 -07:00
Dirk Hohndel
693aeadf3c mobile: update version to 3.0.10
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11 12:17:46 -07:00
Dirk Hohndel
f059adb639 helper functions: remove timestamp argument from gettiemzoneoffset()
The last user of that argument has been removed.

(a random whitespace fix snuck in with this)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11 12:00:10 -07:00
Dirk Hohndel
7acb229b4a mobile/location-service: stop using broken adjustment function
gettimezoneoffset() returns incorrect values when called with a time_t.
Since we only accept the value here if it is within 5 minutes of 'now',
using the current timezone offset is a fair approximation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11 11:57:54 -07:00
Dirk Hohndel
9d2449c5c3 mobile/location-service: fix timezone issue in GPS timestamps
For some reason we suddenly started logging the GPS fixes in UTC instead
of local time. Which caused the matching algorithm to fail (unless you
happened to be diving in UTC). Unclear what broke this, but this seems
like an easy enough fix, since the GPS fix being reported is by
definition "right around now". So using gettimezoneoffset() with the
current time seems "good enough".

I don't know when gettimezoneoffset() with an argument got broken, TBH.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-11 11:47:43 -07:00
Robert C. Helling
912e1faaf2 Make MND display depend on O2 narcotic preference
A while ago, we introduced a preference whether O2 should
be considered narcotic. We used this when computing
best mix or when entering the He content via MND. But
we forgot to make the displayed MND depend on this
preference. This patch add this.

Fixes #2895

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-07-11 10:37:49 -07:00
Berthold Stoeger
4ec88aa564 profile: fix displaying of profiles with multiple pressure sensors
When removing the MAX_CYLINDERS restriction, the layout of the
pressure readings was changed from a (cylinder,sample) to a
(sample,cylinder) scheme. I.e. previously there were one cylinder
block for each sample, then one sample block for one cylinder.

However, after populating the samples, the array size was reduced
to the actual number of used samples. With the new layout this
breaks indexing. Therefore, restore the old layout.

Fixes #2887

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-07-02 09:27:50 -07:00
Linus Torvalds
628c7c8f13 Fix dive merging with multiple cylinders
We did something really horribly wrong when merging cylinders.  It's
been broken since commit 7c9f46a ("Core: remove MAX_CYLINDERS
restriction"), and used some really strange logic.

This rewrites the logic to be (I think) a bit more easy to understand.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-29 10:44:01 -07:00
Linus Torvalds
ac533a6433 Add support for the Oceans S1 and McLean Extreme
This updates libdivecomputer to support the Oceans S1 and McLean Extreme
divecomputers.

It also adds the Oceans S1 to the list of dive computers we reconize by
bluetooth name.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-25 12:56:12 -07:00
Paul Buxton
68b651e494 build-system/mxe: use the new container image
[Dirk Hohndel: switched back to our docker hub repo]

Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-25 11:00:51 -07:00
Paul Buxton
a753845d5a build-system/MXE: build with more up to date MXE tools.
- use hidapi grantlee and mdbtools from MXE
- update MXE version to use QT 5.15, and pull in libzstd and  CMake 3.17.3
- fix linking of winmm on windows build with new mxe
- add some instructions on building the container
- add some new dependancies from QT 5.15 to the packaging
- add a patch to MXE to Build qtconnectivity with native-win32-bluetooth

[Dirk Hohndel: small refactor]

Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-25 11:00:51 -07:00
Dirk Hohndel
edc1499e91 pull latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-20 10:52:32 -07:00
Dirk Hohndel
2f460277f4 update README and ReleaseNotes for 4.9,6
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-20 10:51:48 -07:00
Dirk Hohndel
ce1582581b core: fix compile issue with older g++
Having the full list of all members in the exact order should be enough to get
g++ to accept the named initializers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-18 09:05:13 -07:00
Linus Torvalds
7f0ee3d8e2 core: fix libdivecomputer dc_custom callbacks structures
The last time those changed, we forgot to update serial_ftdi. In that change
set_latency had been removed from libdivecomputer and poll and ioctl had been
added. This caused the callbacks to no longer be aligned correctly and the
functions were called with the wrong arguments through the wrong function
pointers, leading to crashes.

Instead of the fragile assumptions about order and type of function pointers,
use named initializers. And while we are at it, fix that for the bluetooth
implementation as well.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-18 09:05:13 -07:00
Berthold Stoeger
14c37ba733 cleanup: remove indirection when passing arguments to parser functions
For unknown reasons, the dive site and trip to be parsed into were
passed as pointers to pointers. A simple pointer seems to be enough,
since the object is not allocated by the function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-06-16 08:20:53 -07:00
Dirk Hohndel
b013611707 Update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
5ff08598ca mobile: show sync state in menu plate
This seems like the easiest way to show the state without disrupting the UI
elsewhere. Directly below the email address used for cloud storage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
3a409c51ea mobile: add status text for cloud sync state
This allows the mobile UI to reflect the three states that the dive list can be
in:
- changes that haven't been written to local storage
- there potentially are changes in local storage that were not synced with the cloud
- dive list is in sync with cloud storage

The last state could be misleading if the user access the cloud from a
different device and makes changes to the cloud storage from there, but from
the point of view of this device, the states are consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
01de67a5a6 mobile: track if we have changes that aren't synced to cloud
If we haven't connected at all to the cloud server we assume that there are
local changes. And whenever we save changes only locally, we also set that
flag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
8b478a969d git-storage: add global flag to indicate successful cloud sync
This may seem like a bit heavy handed as it adds more global state, but given
the number of ways in which attempts to sync with the cloud can fail it seems
much more reliable to claim success in the spots where we actually know that we
have successfully synced with the remote server. Transporting that information
back through the various call chains turned out to be very disruptive and ugly,
so I went with global state instead.

Whenever we access cloud storage (or any git repo), we always first check if it
actually is a git repo by calling is_git_repository() - so this is the perfect
spot to initialize the variable to false.

And there are only two spots where we either clone the remote repo
(create_local_repo()) or update the remote with the (potentially merged) local
changes (check_remote_status()). So those are the two places where we set the
variable to true.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
fe9e33ccac git storage: significantly expand logging to stderr
In many cases we did not log the issues the code ran into to stderr which made
remote debugging user problems much harder. This hopefully will help with that.

Since I was looking at the code, I also made the existing messages more
consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Berthold Stoeger
23e8839182 download: don't warn on unknown gasmixes
Apparently libdivecomputer can return DC_GASMIX_UNKNOWN when
fetching tank info with
  dc_parser_get_field(parser, DC_FIELD_TANK, i, &tank);
This caused emission of a warning, which was annoying users.
Disable the warning in that case.

Fixes #2866

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-06-13 15:55:35 -07:00
Gaetan Bisson
56c6cd06c9 Fix includes for building against Qt-5.15
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
2020-06-13 14:00:05 +02:00
Dirk Hohndel
52eefa7561 pull latest translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-12 12:44:56 -07:00
Dirk Hohndel
bea898c077 Update ReleaseNotes and README for 4.9.5
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-12 12:43:51 -07:00