Commit graph

17867 commits

Author SHA1 Message Date
Robert C. Helling
52aa7d83b6 Increase event icon size in print mode
When plotting the profile in higher resolution for export,
increase the icon size in the same way.

This is commented out for the mobile version as that
uses printMode for profile display.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:18 -07:00
Robert C. Helling
c6fa415880 Improve resolution of profile export
The way we export the profile image (as direct export but
also used for printing) is that we render the profile
from the screen to a Pixmap and save that to a file. Unfortunately
this results in very bad resultion and a blurred image.

This is an attempt to improve that situation but it's still far
from perfect: Rather than a QPixmap and grab, I now use a QImage
(where I can set the size) and render, and indeed the picture resolution
(when vied at fixed size) get's better this way. The disadvantage
is that icons get smaller at the same rate und so
there is a natural limit on how big we can get. Maybe somebody
with better Qt knowledge can take off from here. In my opinion
this is already a step in the right direction.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:17 -07:00
Robert C. Helling
8f6d054140 Set printer resolution
You need a better resolution to plot a picture with high resolution...

Connection done with a lambda expression thanks to @dirkhh.

Signed-off-by: Robert C. Helling <helling@atdotde.de> (+1 squashed commit)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:16 -07:00
Dirk Hohndel
02a4aa927e build-system: update Ubuntu distros that we build for
Eoan no longer accepts builds, Groovy Gorilla will be the next one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:43:24 -07:00
Salvador Cuñat
158c3c0b0e datatrak.c: return const string for tank type
As Berthold points out, this string shouldn't be modifiable.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-09-03 11:38:13 -07:00
Salvador Cuñat
080a7f1a17 datatrak.c: Do not duplicate string as it's not being freed
It is cloned later by add_cloned_cylinder(), anyway.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-09-03 11:38:13 -07:00
Salvador Cuñat
c9c38394c0 datatrak.c: use two_bytes_to_int() to get little endian values
And use memcmp() call to avoid conversion + comparison.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-09-03 11:38:13 -07:00
Salvador Cuñat
80ff092533 datatrak.c - Do not return unsigned negative values
We don't really expect to get Nº of dives greater than the biggest
integer value.

Signed-off-by: Salvador Cuñat <salvador,cunat@gmail.com>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-09-03 11:38:13 -07:00
Salvador Cuñat
c888a1727e DataTrak import: Add support for WLog extensions.
WLog is a Win32 based ancient shareware program whose target was:
1) fully support divelogs coming from DataTrak (DOS or Win)
2) fill some meaningful data which wasn't supported by Uwatec software
3) have a more user-friendly GUI than Datatrak had
The problem achieving goals 1) and 2) at the same time was solved by
adding a complementary file with .add extension and - mandatory - same
base name than .log file (including directory tree).

This .add file has a fixed structure composed of a 12 bytes header,
including file type check and Nº of dives following; then a fixed 850
bytes size for each dive in the log file. Data fields size and position
are fixed inside these blocks and heavily zero padded, so they are easy
to parse.

A serious restriction imposed to the WLog user was *Do not edit the logs
with other software than Wlog*; this was due the order of dives in .log
file being the same than the order of dives in .add file. Thought you
could show a WLog divelog in Datatrak, editing it resulted in mixing all
extended data for dives following the edited one.
Thus, we have to trust files are correct and is to the user ensure this
is so. If extended data are mangled, they are mangled in WLog too and we
are not trying to fix the mess, just importing.

On the technical side, we try to be smart about tank names as neither
DataTrak nor WLog record them. So we just take the first tank in users
list matching the volume recorded in WLog.
For weights we add a translatable "unknown" string as an empty string
results in weight not being shown in subsurface-mobile (which could be a
reportable issue, BTW).

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2020-09-03 11:38:13 -07:00
Michael Werle
37ae5a7d83 [Bug #2930] Fix crash bug in LocationInformationWidget
If a user exits the LocationInformationWidget (Edit  Dive Site)
while a reverseGeocode lookup is in progress, the object's
diveSite variable is set to null.

When the reverseGeocode lookup completes, this variable is
dereferenced causing an application crash.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-09-03 08:59:08 +02:00
Robert C. Helling
7e82205e9b Planner: Properly initialize salinity
When the dive has no explicity salinity, our conversion
between pressure and depth assumed salt water. Make this
explicity by using the corresponding macro.

When the planner starts and no salinity is set explicity,
set the water type chooser to salt water to reflect
our default assumption.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-09-02 09:43:38 -07:00
Michael Werle
f5ba42e933 Add an "Edit Gas Change" right-click option.
This new option allows a user to select a new destination tank for an
existing "Gas Change" event. This is useful when Subsurface's heuristics
get tanks wrong after an import from a divecomputer. The use-case arose
from sidemount divers with air-integrated transmitters as well as carrying
a deco tank.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-08-26 07:11:49 -07:00
Robert C. Helling
e946ce98fe Planner: enforce minimal segement duration
You cannot be at two depths at the same time (and it confuses
the planner). So give yourself at least 10 seconds.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-24 08:31:40 -07:00
Robert C. Helling
6ad55cd63b cleanup: fix compiler warning
... at least for llvm.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-24 08:31:38 -07:00
Robert C. Helling
62d87e9d25 Planner: handle zero length segments when replanning
When setting up a dive for replanning, we ignored zero length segments as those
tend to be generated by gas changes. But it is possible to enter those in the
planner and the replanning should not ignore those. So be
more clever about gas changes. Let's add 10 seconds so we are not at two depths
at the same time and help since add_stop also does not like zero length
segments (it thinks we are trying to replace a waypoint).

Fixes #2901

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-24 08:30:00 -07:00
Dirk Hohndel
c5b1fd9f53 core/BLE: don't insist on pairing of pure BLE devices
Most (all?) BLE dive computers actually don't need to be paired, and some
apparently can't be paired. So let's not enforce that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
14f47c627d Add CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
334aa80bfe Update libdivecomputer to recognize Shearwater Peregrine
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
91557f79cd core/BLE: delay characteristics discovery until service discovery complete
While this code was added as I was trying to work through issues with a BLE
stack that turned out to be broken, the failure behavior of that device showed
that Qt doesn't like it when we start discovering the details of
characteristics while it is still busy discovering services.

So instead of handling the services as we find them, let's instead wait until
we are done discovering services and then discover the details for all those
services.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Dirk Hohndel
f74328df0b core/BLE: provide state and error updates during BLE discovery
This simply helps us see some possible errors while trying to talk to a device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
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