Commit graph

707 commits

Author SHA1 Message Date
Miika Turkia
e18df84936 Hopefully fix Android build
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
b1b2638720 Move Cobalt and Divinglog DB parsing to parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
8be626d2c1 Move atoi_n to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
b3605de93e Move Shearwater DB parsing into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
568db03228 Move metric variable to parse.c
This is required when moving Shearwater DB parsing into parse-db.c

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
ddb9dba66c Move add_dive_site to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
1c6e189c2b Move Suunto DB imports into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
02c80a60b0 Refactore parse-xml.c into parse.c and parse-xml.c
This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Stefan Fuchs
8d2bc595c7 Code cleanup: Move index declarations into for loop
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
b17f1e2d30 Use MAX_SENSORS define everywhere
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
8a92484b0c Add debug function dump_cylinders
This function can be used to dump print all cylinder data.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
4e36b2509c Compile dump_tissues function only if needed based on define
Compile it only when DECO_CALC_DEBUG is defined.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
46004c39e2 Store and load the planner related depth info of a cylinder in logfile
Store cylinder.depth in XML files and in git storage.
This info is in fact the gas switch depth of a specific gas/cylinder
in the planner.
This change avoids the need of typing in a user specific depth value
again when replanning an existing planned dive.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 11:49:08 -08:00
Dirk Hohndel
dc67741e4f Update list of divecomputers supported in Subsurface-mobile
There was some whitespace change as well - this is straight from the
tool.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-26 22:20:52 -08:00
Stefan Fuchs
72318f2897 In strings start lower case in parenthesis
Start with lower case letter inside a parenthesis.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:41:28 -08:00
Stefan Fuchs
3d421584aa In planner.c remove unused variable o2break_done
Reported-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:40:04 -08:00
Robert C. Helling
088db5e12b Hand planner variables to profile
Pass the planner state struct to the profile computation so it can use
deco_time and first ceiling to display VPM-B ceiling.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Robert C. Helling
8e21a65653 Localize global planner state
For UI responsiveness, we need to be able to run the planner in the background. This needs the
planner state to be localized (and we need to pass a pointer around).

In order to not let too many lines overrun (and to save typing in the future)
I have renamed instances of struct deco_state to ds. Yes this should have gone
to a separate commit but I accidentally commit --amend'ed it.

Computing of planner variations is temporarily disabled.

Unlock the planner when returning early

So we don't deadlock in add dive and recreational mode (which
use the planner without actually planning).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Robert C. Helling
a9ceecc2e3 Run variations calculation in background
but there are still side effects and thus it crashes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Robert C. Helling
be6b50fce4 Add logic parentheses to make compiler happy
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Dirk Hohndel
e20e1aad0e Fix crash when dives have no dive site
get_dive_site_by_uuid() returns a NULL pointer in that case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-25 08:19:47 -08:00
Jan Mulder
64704d6e5a mobile: autocomplete location names
Add the capability to select the location name from a list, constructed
from the known dive sites in the logbook.

Fixes: #546

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-25 08:13:42 -08:00
Berthold Stoeger
4fb01dd766 Fix ownership issues in preferences code
Each preferences object owns its string members. In three cases, pointers
were copied instead of strings, leading to (in the best case) dangling
pointers if the user edited values:
1) In the GET_TXT macro in core/prefs-macros.h
2) In the PreferencesDialog::defaultsRequested() method
3) In main() of the mobile version

This patch fixes these issues, by using copy_string() or copy_prefs()
as appropriate.

The only reason that the old code didn't crash regularly is that the
default_prefs object was only used at startup and defaultsRequested()
is (at the moment?) dead code.

This patch also aligns the backslashes in core/pref.h and fixes a typo.
The declaration of copy_prefs() is moved to the core/prefs.h header.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 07:41:09 -08:00
Berthold Stoeger
cc5a56b275 Cleanup: remove unused extern declaration
Removes the extern declaration of edit_dive, which wasn't defined
anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 07:38:20 -08:00
Stefan Fuchs
f3c06279f1 Include stdbool.h also from prefs.h if included from C file
Currently not mandatory in our code because we never include
prefs.h from a C file today but for the future this could avoid confusion.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-24 07:56:10 -08:00
Stefan Fuchs
bd88306722 Change prefs.show_units_table to bool
Bool is the correct choice for this option.
int was used before because it was not clear to me how and if I can use
bool in this C file.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-24 07:56:10 -08:00
Berthold Stoeger
04f38d61d7 Clean up system_default_filename()
In the old implementation there were two static C-style strings, filename
and path, which were initialized to NULL and filled on first call of
the function (i.e. singletons).

There is no sense in having two static variables indicating whether
this function was called previously. Moreover, there is no point
in remembering filename accross function calls, because it is not
used once path is set to a non-NULL value.

Therefore, make the filename variable non-static and calculate it only on
first invocation (as indicated by a NULL path). Moreover, free() the filename
variable after its use to fix a memory leak of the old code.

The windows code is slightly different in that the temporary filename is
not dynamically allocated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-22 19:22:29 +01:00
Berthold Stoeger
7a99d7e5c3 Copy default filename string when assigning to default preferences
This tries to remove subtle ownership issues. When copying preferences
structures, the default filename is copied. But the default preferences
struct simply takes a pointer to a global string which is free()d in main().

Now, this is not strictly a bug because the free()ing of preferences
resources is not implemented. Yet, let's try to make this consistent.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-22 19:22:14 +01:00
Berthold Stoeger
a15682ee76 Make handling of booleans consistent on the C-side of preferences
Boolean settings were declared in pref.h randomly as bools and shorts.
Since the code relied anyway on bool being well-defined and identical
on the C- and C++-sides, turn all of them into bools. They use less
space and express intent more clearly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
dd8e4fae2a Make handling of booleans consistent on the C++-side of preferences
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
  showPo2
  showPn2
  showPhe
  saveUserIdLocal
  displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.

Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.

As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
e762fd2d41 Fix typo: successfull -> successful and succesfully -> successfully
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 10:01:15 +01:00
Jan Mulder
bde7caa621 Remove dead code
While investigating Qt 5.9.2 problems, I found this unused code.
Just remove it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-19 12:20:43 -08:00
Berthold Stoeger
ebb8e1dc27 Trivial: fix indentation
Fix an obvious indentation bug where one line more than intended
was indented.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-19 00:21:45 +01:00
Berthold Stoeger
6ae16b87d0 Constify strings in pref.h
Make all char * pointers in pref.h const to make it clear that these
strings are not mutable. This meant adding a number of (void *) casts
in calls to free(). Apart from being the right thing to do, this commit
makes the code more consistent, as many of the strings in pref.h were
already const.

While touching core/qthelper.cpp turn three instances of (void*) into
(void *).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-18 21:57:33 +01:00
Berthold Stoeger
1f651a7b83 Prevent annoying signed/unsigned comparison warning
Commit d6c013f303 introduced a cast to avoid a signed/unsigned
comparison warning for all translation units that included
core/dive.h.

Commit 1f8506ce64 then changed the definition of duration_t from
unsigned to signed, inverting the effect of d6c013f303.

Thus, revert d6c013f303 to allow compilation with -Wall without
flooding.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-18 21:50:43 +01:00
Berthold Stoeger
5ad6e168c6 Fix memory leaks in SettingsObjectWrapper.cpp
Free a bunch of C-style strings before assigning newly copied strings.
One case was particularly buggy:
  prefs.locale.use_system_language = copy_string(qPrintable(value));
Note that prefs.locale.use_system_language is a bool, which of course
always evaluates to true! Probably nobody noticed because a restart
is required when changing locale.

Moreover remove a few double-semicolons.
2017-11-17 15:32:38 +01:00
Berthold Stoeger
9ec7aa7fd7 Fix typo: LENGHT -> LENGTH 2017-11-17 15:29:42 +01:00
Linus Torvalds
7fa5fcfa1d Don't show cylinder pressures for other dive computers
Stefan Fuchs points out that sometimes you get cylinder duplication when
you merge dives, particularly with a planned dive.  For example, if we
had different manual pressures in the two different dives, the cylinders
will be kept separate.

But that also means that we don't want to plot the pressures from those
other cylinders that came from another dive and are now associated with
another dive computer.

Change the "seen" logic for the cylinder to ignore cylinders that are
only mentioned by other dive computers than the active one.

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-17 15:25:26 +01:00
Linus Torvalds
2e82a5d2ed Properly declare 'has_gaschange_event()' function
It's already used in core/gaspressures.c where it was declared
privately, and we'll have a new user in the profile code, so just
declare it in a proper header file like it should have been.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-17 15:25:26 +01:00
Linus Torvalds
8136c2d78b Clean up confusing code in setup_gas_sensor_pressure()
The "prev" cylinder can never be negative since commit 56c206d19f
("For more manual gas pressure details"), so remove stale code that
checks for a case that cannot happen any more.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-17 15:25:26 +01:00
Berthold Stoeger
aca4a3a4fa Introduce mode field in Bluetooth device selection dialog
Some BT devices support both, classical and LE, modes. Users could
choose either by prepending or removing "LE:" in the device address
field. After commit d23bd46a1b, the
device field is always disabled in Bluetooth mode.

Therefore, add a mode combo box to the Bluetooth device selection
dialog. In the default mode (auto), the old code path (based on
the Qt device flags) is used. The two other modes (force LE, force
classical) allow the user to force the preferred behavior.

This feature is meant as a stop-gap measure until a more refined
transport choice is implemented. Therefore, the value of the new
combo box is not saved in the settings, to avoid cluttering of
the preferences with soon to be obsolete entries.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-16 14:26:51 +01:00
Lubomir I. Ivanov
a8fbceac17 subsurface-startup: expose print_version() in the header
The Windows auto-verbose + log file creation if starting
from a non-terminal has the problem that the print_version()
call is never made becase 'verbose' is updated programatically
in windows.c and not by the user (by passing -v).

To work around the issue:
- move the windows console creation call before *everything* else
- then immediatelly install the message handler
- then see if 'verbose' is set and explicitly call print_version()

print_version() now also has a flag (version_printed), to avoid
printing the version multiple times, if the user decided to add
an extra -v to the Desktop shortcut.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-16 14:26:14 +01:00
Lubomir I. Ivanov
6161ca2083 windows.c: enable verbose level 1 for desktop usage
If the user has not started Subsurface from a terminal
make sure that verbosity is enabled (verbose = 1), so that
the log files are populated with information useful for
debugging.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-16 14:26:14 +01:00
Stefan Fuchs
72129289a8 During DC import reset cns, ndl, other values inbetween dives
Reset cns and heartbeat to 0
Reset ndl and bearing to -1

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
85d00d1e7c For surface samples init ndl and compass bearing from prev sample
This avoids printing useless info to the XML file.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
0895bccf49 libdivecomputer.c init sticky values for samples for current sample
When filling samples with values during DC import fill sticky values
like CNS, NDL, stoptime,... immediately into current sample.
Otherwise we will not fill the sticky values into the last sample
created.
Add two new sticky values: heartbeat and bearing

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 08:32:46 +01:00
Stefan Fuchs
a8d4ff308d New fixup function fixup_dc_ndl
Fixup the NDL value to '-1' at the very beginning of a dive.
Some dive computer report a NDL of 0 at the very beginning of a dive
and then only some 10 seconds later they report the correct value
like 240 min for the first time.
Translate this 0 at the beginning of a dive into our internal '-1'
for no info available.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13 20:50:10 -08:00
Stefan Fuchs
adbc71f9da Init every struct sample with default values
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13 20:50:10 -08:00
Stefan Fuchs
1f8506ce64 Display values in info box only if value is interesting
Type duration_t changed from uint to int.

Default value of '-1' introduced for some of the values in struct sample:
NDL used -1 as default.
Bearing uses -1 as default (no bearing set).

Display pXX, EAD, END, density, MOD only if values are larger than 0.

In profile don't display data from two first and two last plot_data
entries in info box.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13 20:50:10 -08:00
Berthold Stoeger
de81effb25 Make Bluetooth naming consistent
Currently, on Linux, after selecting a Bluetooth device the name of the
device is shown. On reopening the download dialog, on the other hand,
the address is shown. In the device selection dialog both are shown.

This patch changes the download dialog such that both, name and address,
are shown. The bulk of the patch introduces the name of the device in
the preferences and DCDeviceData. It has to be noted that DCDeviceData
is an encapsulation of the libdivecomputer device_data_t. Nevertheless,
the new Bluetooth-name field is, at the moment, not passed through to
libdivecomputer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-13 20:48:17 -08:00