Commit graph

1297 commits

Author SHA1 Message Date
jan Iversen
178c01baf5 core/settings: use instance() in qPref macros
use instance() instead of <class>::instance()

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
jan Iversen
a037578015 core/settings: change bestmixend to int, to allow qml to work
depth_t is a good struct in C, but bad in QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
jan Iversen
c0b78d69d9 core/settings: correct wrong emit in qPrefFacebook
Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
jan Iversen
2385f48c6a core/settings ... : remove qPref* includes in qPref.h
reduce number of includes by removing qPref* includes in qPref.h

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
jan Iversen
684e334fb6 core: declare cloud_status in qPrefCloudStorage
qml declaration of cloud_status (defined in pref.h) does not
belong in qPref.h but in qPrefCloudStorage

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:25:00 -07:00
jan Iversen
4d57b52062 core/tests: change short to int in pref.h
Simplify structure preferences by removing short. Update test cases to not
do (int).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:22:58 -07:00
jan Iversen
d0edc29636 core,tests: change qml register function
In order to address the C++ object directy in qml, a different
registration is needed.

qmlRegisterType, registers the C++ class, allowing qml code to inherit
from it and make qml objects. This is needed for graphical elemnets
like profile and map

setContentProperty, registers the C++ object, thus allowing signals to be
catched.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:22:58 -07:00
jan Iversen
a71afd31ee core: add auto registration to qPref*
Instead of having all register calls in subsurface-helper.cpp let
qPref.cpp handle all qPref registration, since they also need to be
different

update subsurface-helper and testqml accordingly.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:22:58 -07:00
jan Iversen
7940e45c4c core/settings: add missing empty line.
Standard is to have 1 empty line between functions

correct missing static in qPrefGeocoding.h

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:22:58 -07:00
jan Iversen
c72add5721 core/setting: change *_changed to *Changed for the sake of QML.
QML demands signals to be of the form
<name>Changed

Changing all of qPref

REMARK: this commit is not compileable, since it only change qPref and not
the rest of the system

Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11 17:22:58 -07:00
Jan Mulder
740fcce338 cleanup[6/6]: remove actual preferences
And finnaly, get rid of the definition in the overall struct.
And one usage of the preferences was still around.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Jan Mulder
19e8fa4eaf Cleanup[5/6]: remove unused preferences
Remove all the code to handle the preferences itself.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Jan Mulder
bb0ac5f778 cleanup[4/6], mobile: remove superfluous code from gpslocation
Despite the fast that this code is sitting in core, its used mainly
from mobile. In 987e221f8e, the buttons to interact with the GPS
webservice were deleted from the UI.  Now, delete all the code that
was used under these buttons.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Jan Mulder
cc72a606bb cleanup[3/6]: do not save the userid any more
Do not save the to be deleted prefences any more.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Jan Mulder
3c8506e1b8 cleanup[2/6]: remove set_userid()
This code is not used any more.

Signed-off-by: Jan Mlder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Jan Mulder
226161ee44 cleanup[1/6]: do not set userid/save_userid_local from storage
This the first of a set of cleanups related to the removal of 2
preferences: save_userid_local and userid. The commits are
ordered so that a sane running state remains, should a
bisect ever lands here.

Here, just read a git or XML logbook including the to be removed
preferences, as existing users can have this data sitting around.
The only thing done here is not to store the possibly read data
for the mentioned preferences.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11 15:38:20 -07:00
Dirk Hohndel
619a52635a prefs: use correct way to set the cloud storage password preference
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-10 16:26:49 -07:00
Dirk Hohndel
2b3f6c607b prefs: cloud_new_password is not a preference
It's a mamber of the cloud storage authentication class, used to hold the
proposed new password until the backend has accepted it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-10 16:26:49 -07:00
Dirk Hohndel
ae653703a5 prefs: git_local_only is not a preference
It's the current state of the app, so it should be a global variable, not a
preference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-10 16:26:49 -07:00
Berthold Stoeger
6e4a253896 Profile: fix SAC calculation for air dives
Commit f5b11daffd changed gasmix
arguments and return values to be passed by value instead of
using pointers.

Notably, get_gasmix() is fed a default-value and returns a
new value. In the old code, NULL was passed in in a first
loop iteration and non-NULL was always returned in the first
iteration. Thus, an equality comparison of passed-in an
returned gasmix would always fail in the first loop iteration.

The new code passed in air as default. Now if air was also
returned, then the matching gases were not calculated in
calculate_sac(). To revert to the old behavior, pass in
an invalid gasmix.

Moreover, give names to the invalid and air gasmixes.

Reported-by: tormento <turment@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-10 14:23:59 -07:00
Alexander Wilms
12d75001a0 Set desktop file name to avoid a broken icon under KDE Wayland
Signed-off-by: Alexander Wilms <f.alexander.wilms@gmail.com>
2018-09-09 18:44:40 -07:00
Miika Turkia
3c9897d247 DLF import: document deco event
These are Deco N2 Low/High and Deco He Low/High events. They all appear
to be recorded at the same time, different events at same second.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
Miika Turkia
dac90e3fde DLF import: comment measured He
Measured He is documented (in comment). Will need information if all
measurements are needed or just start/end. First case would be added to
dive prifle, possibly cluttering it, second would be extra data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
Miika Turkia
aae2403ddd DLF import: Record battery status
This will record the ending battery status to extra data. Would need
info from CCR divers whether this suffices or if we should record also
the starting volatage or even every single reading.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
jan Iversen
ee6b5643b5 core/settings: only sync values that are actually changed
Add a variable reflecting the current_state to all DISK_* macros, in order to
check if the original variable in struct preferences is changed.

Only save to disk if actually changed

[Dirk Hohndel: merged Jan's commit and renamed the variable and adjusted the
               commit message... but fundamentally the commit is still what Jan
               wrote, so he should get the credit]

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07 14:37:18 -07:00
Dirk Hohndel
2ecbea3d24 qPref: use helper function to ensure key/name grouping
We had a couple of instances of names being incorrectly merged with their
group, this should handle that better. It's a bit of a big hammer to use, but
it seems to work (and it makes it easy to then git grep for cases that don't
use the new helper function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07 14:37:18 -07:00
Berthold Stoeger
2bd0c2143e Cleanup: constify get_units()
get_units() returns a pointer to the units struct in the preferences.
Callers should not modify the preferences via this struct, therefore
make the return value point to const.

This is a small step in constifying the global preferences structure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-07 11:03:30 -07:00
Jan Mulder
2635673c3a Preferences: more missing /
subsurface_webservice_uid ends up in the wrong group due missing
/. Notice that this does not fix the issues I mentioned in #1648.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-07 07:39:35 -07:00
Linus Torvalds
56a77f0fa3 Garmin devices - like Shearwater - want random BLE addressing
We had a special-case for the Shearwater case, let's just make it
slightly more generic and add Garmin to the list of vendors that want a
random BLE address rather than a static one.

The Bluez model of having to state this explicitly - but not giving the
information to the user - is completely broken and this is all very
annoying, credit goes to Wojciech Więckowski for pointing this out.

Of course, right now we don't actually know how to parse the BLE stream
from the Garmin Descent, but with this (and some libdivecomputer
hackery) I actually get connected and start receiving data.  That we
then can't parse, but that's hopefully just a libdivecomputer update
away.

Pointed-out-by: Wojciech Więckowski <xplwowi@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-06 18:35:18 -07:00
jan Iversen
c03c2b5fd7 core/settings: add missing / in default_filename
Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-06 17:14:54 -07:00
jan Iversen
12fc3f1747 Revert "core/tests: add loadFromCloud var to qPrefCloudStorage"
This reverts commit b7a1bb670c.

Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-06 17:14:48 -07:00
Dirk Hohndel
e71b049498 qPref: only save settings that aren't the default
This brings us back to the previous behavior.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-06 16:13:44 -07:00
Linus Torvalds
5c2bca048f libdivecomputer: allow a "zero depth" deco stop depth
That just means that we're not in deco, the same way as giving a nonzero
NDL value does.  But if you don't have NDL, this is a much more
convenient way of saying "not in deco".

The Garmin Descent gives us stop information, but not necessarily NDL,
and really wants this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-03 13:29:40 -07:00
Linus Torvalds
faea11e4fb libdivecomputer: add support for DC_SAMPLE_TTS if it exists
libdivecomputer didn't use to have a TTS sample value, but we're adding
one, so add conditional support for it if it exists.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-03 13:29:40 -07:00
Lubomir I. Ivanov
6af67f541d core/windows.c: write logs to the user path
Writing logs to the path where the executable is located,
might not be possible if the current user doesn't have
permissions to write there.

Obtain the user path and write the log files to the
user path instead - e.g.:
c:\users\myuser\appdata\roaming\subsurface\subsurface_*.log

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-09-03 13:29:03 -07:00
Lubomir I. Ivanov
c47b6b672f code/windows.c: add method for converting from utf16 to utf8
Modify the funcion system_default_path_append() to
both receive and return wchar_t types.

Remove fallback in system_default_path_append()
as this is now redundant.

Add a function utf16_to_utf8() and use that
in places where system_default_path_append() needs
to be converted to utf8.

Move both utf16_to_utf8*() and utf8_to_utf16*()
near the top of the file.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-09-03 13:29:03 -07:00
Berthold Stoeger
19f7b5279a Cleanup: silence clang missing braces warning in core/color.cpp
C++11 initializer lists should be passed via {{ ... }}.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-01 11:31:18 -07:00
Berthold Stoeger
59a68fe9b5 Parser: split out name-comparison from match() function
The match() function in parse-xml.c calls a very specific callback,
which doesn't take a context-parameter. To be able to call other
callbacks, split out the actual name-comparison.

Moreover, remove the "plen" parameter, as this was called with
strlen(pattern) in all cases anyway. Replace the old logic which
potentially accessed a byte beyond the end of name with a simply
classical C-style loop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-30 13:32:09 -07:00
Berthold Stoeger
2de8e70ab0 Parser: move match() into core/parse-xml.c
The match() function compares a pattern with a name with
a twist: The name may either end in '\0' or '.'. If pattern
and name match, a parsing function is called on a buffer and
a destination value. The result of the parsing is not checked.

This seems awfully XML-specific and therefore move the function
from the general parse.c to the specialized parse-xml.c unit
and make it of local linkage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-30 13:32:09 -07:00
jan Iversen
1515b9496b core/settings: add missing load_* call in qPrefDisplay
Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-30 05:36:36 -07:00
jan Iversen
cf2ffdc432 core/settings: add README
Add simple explanation of how the program flow is.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-30 05:36:36 -07:00
Linus Torvalds
f59679320a parse "GPS" string fields and turn them into dive sites when downloading
Dive computers that do GPS can report their GPS data as one or more
string fields, and if the first tree letters of the description is
"GPS", then we'll take the string and turn it into a dive site for that
dive.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-29 21:40:19 -07:00
Dirk Hohndel
4bb72160a6 core: fix typo in preference name
In commit 1bc361b2ea ("core/tests: add uuidString to qPrefUpdateManager") a
typo was introduced for the preference name.

Reported-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-28 12:11:16 -07:00
Linus Torvalds
80fe8fb331 Add support for opening a DC_TRANSPORT_USBSTORAGE stream
This is part of the whole "let's support the notion of dive computers
being exported as USB storage devices" push.

With an older libdivecomputer, we'll just fall back on failing the
operation, but we still want to support the generic notion of
DC_TRANSPORT_USBSTORAGE since we have our own internal Uemis downloader.
That one won't ever get to the open phase, since it's caught earlier.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-27 22:11:05 -07:00
Linus Torvalds
270e9eccad Make device enumeration use the device transport data
This removes some special-case code for Uemis, replacing it with simply
passing in the device transport information.

This makes device enumeration work for the Garmin Descent (if it is
listed by libdivecomputer as a USB storage device, that is).

I don't actually do any of the libdivecomputer parsing yet, and only
have a stub for the Garmin Descent, but now the directory selection
works with that stub. The actual download obviously does not.

[Dirk Hohndel: removed obsolete FIXME from code]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-27 22:10:38 -07:00
Linus Torvalds
bb067b6ee4 Treat the "GARMIN" mount point exactly like the "UEMISSDA" one
The logic for finding a mount point for the Garmin FIT devices is
basically exactly the same as for the UEMISSDA, even if the rest of the
sequence is not the same.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-27 22:09:44 -07:00
Dirk Hohndel
eaf1bdbe5f Merge branch 'filter8' of https://github.com/bstoeger/subsurface 2018-08-25 11:58:27 -07:00
jan Iversen
5f4a040dd2 core/tests: add class var to qPrefGeneral
Add static class variables to qPrefGeneral
(and remove QSettings from desktop-widgets)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
b7a1bb670c core/tests: add loadFromCloud var to qPrefCloudStorage
Add special property loadFromCloud + mail to qPrefCloudStorage
this variable is used by qmlmanager.cpp

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
5dd0981961 core/tests: remove QSettings from testgitstorage
update testgitstorage.cpp to use qPrefProxy and qPrefCloudStorage
remove core/prefs-macros.h since it is unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00