Commit graph

1145 commits

Author SHA1 Message Date
Willem Ferguson
c1d04ef7dc Simplify bailout events in the dive log
I removed the special event type that has been used for bailout events.
Bailout events are now just bookmarks with a specific name "e.g. OC,
CCR, PSCR). This removes a case where a segmentation error occurred
when trying to remove a bailout event from the dive profile.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
27a0542220 Implement bailout outside of the dive planner
This is the second step for implementing bailout. The indirect
calls to fill_pressures through add_segment() (in deco.c) are
addressed. Bailout is now fully implemented in the dive log but
not in the dive planner.
1) The parameters to add_segment() are changed to take a
   divemode as the second last parameter, and not a *dive.
2) Call to add_segment() in profile.c and in divelist.c are
   adapted. In divelist.c some calls to add_segment were left
   using dc-> divemode instead of possible bailout. This appears
   tp be the most appropriate route.
3) The functions get_divemode_from_time() and get_next_divemodechange()
   in dive.c have had some small changes.
4) The calls to get_segment(0 in planner.c were changed to reflect
   the new parameter list, but not updated to reflect bailout. This
   is the next step.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Willem Ferguson
cf377beb2e Incorporate bailout events in CCR & PSCR gas calculations.
This is a first step to interpret bailout events.
1) The event structures have a new attribute: divemode.
   Currently interpreted dive modes are OC, CCR, PSCR.
2) When doing fill_pressures(), the calculation is aware
   of divemode. When divemode is OC (==bailout), then
   the appropriate calculations of gas pressures are done.
3) Two new functions get_next_divemodechange() and
   get_divemode_at_time() are created to find divemode
   changes in the events linked list and to determine
   the dive mode at any point during the dive.
4) fill_pressures gets a small amendment to facilitate
   the correct calculations, depending on divemode.
The cases where fill_pressures() is used *outside the planner*
are changed. The result is that, for dives with bailout, the
correct gas pressures are shown on the dive profile. The
deco for bailout dives is not yet correct. This is the
next step.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Dirk Hohndel
826c01d0a0 Core: don't inline rarely used function
This is only used by one caller and there doesn't appear to be a reason
to inline it in the first place.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
543cefa61e Android: build fix
On other OSs this compiles fine without adding this header, but Android
is special...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
ea83b5ed37 Core: remove dive.h from files that don't need it
Of course, quite a few of them indirectly get it through other header
files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
be64f6f3c0 Small whitespace cleanup
Stumbled across this when Qt Creator re-saved the file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
d33e3b22fc Dive pictures: refactor image downloader
Instead of generating one ImageDownloader object per image to be
downloaded and running every image download in a separate worker
thread, use one global ImageDownloader object owned by the UI thread.

The images are downloaded using event based IO (as probably was the
intention of the QNetworkManager class).

User-visible change: after download from the internet, the thumbnail
is shown without having to change dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
19fa2966ef Dive pictures: Import camera icon
Import a camera icon from the KDE breeze theme, which is licensed
under the LGPL. Use this icon to display not-yet-loaded images
in the photos tab and the profile.

Source: https://github.com/KDE/breeze-icons

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
b450c155fd Dive pictures: Move thumbnail-size to Thumbnailer class
The size of the to-be-created thumbnails was passed from DivePictureModel
to Thumbnailer. This became more and more bothersome, because the size
had to be stored with the request. Calling from Thumbnailer into
DivePictureModel was not an option, since this is not linked to all tests.
Therefore, move these functions to the Thumbnailer class.

Since the maximum thumbnail size is now known to the thumbnailer, the
dummy and failure images can be precalculated, which makes switching
between dives faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
3967b1fd4d Dive pictures: Introduce thumbnailer class
Create a new class, which performs all thumbnailing code.
This is mostly code reshuffling. Thumbnails are extracted
either from a cache or thumbnail calculation is started in
a worker thread.

Since getHashedImage() is called from a worker thread it
makes no sense to call subfunctions in yet another worker
thread. Remove these calls.

In contrast to the previous code, on error the background
thread produces a failure image, but it is not yet shown.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
f60343eebb Dive pictures: replace picture struct by QString
In imagedownloader.cpp the only thing we need from the picture struct
is the filename. Therefore, use QStrings instead of the picture struct.
This simplifies memory management.

Remove the clone_picture() function, which is not needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
5d372cfda3 Dive pictures: turn SHashedImage class into getHashedImage() function
SHashedImage was a subclass of QImage, which fetched the image according
to the filename hashes. Turn this into a function, as this is much more
idiomatic and flexible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
e811c7306d Dive pictures: Convert thumbnailHash to individual files
On startup, convert an old-style thumbnailHash to individual
thumbnail files. Show a modal progress bar while doing so.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
6618c9ebfc Dive pictures: save thumbnails to individual files
The old code loaded all thumbnails into memory at once. This does
not scale to logs with thousands of pictures. Therefore, save
the pictures to individual files and only load the currently
needed pictures.

Currently, this will make changing switching between dives slower,
because the thumbnails are loaded from disk. In the future, it
is planned to do this in a background thread without blocking
the user interface.

A notable difference to the old code: Thumbnails are now indexed
by the image-hash (i.e. the content of the raw image) and not
by the filename of the image. Thus, different paths to the same
image should only be saved once.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Dirk Hohndel
2d253c71ff Add Qt header so Q_OS_xxx macros work
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12 21:09:14 -07:00
Dirk Hohndel
adf3d945e1 DC transport debugging messages
Show the transport types we support for each of the supported dive computers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12 21:09:14 -07:00
Dirk Hohndel
cef6dff762 BLE: add EON Core and Mares Bluelink to detection
Detection isn't required, but it makes things easier.  For the Mares dive
computers we only see the Bluelink, so we can't tell which dive computer is
connected to it. We guess "Quad", but the user can pick a different one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11 22:18:19 -07:00
Dirk Hohndel
e6cb98ea4b iOS: only DC_TRANSPORT_BLE is supported
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11 21:32:04 -07:00
Berthold Stoeger
ac1ec486ae Planner: Unify final ascent rates in plan() and fake_dc()
When generating fake profiles for manually entered dives, fake_dc() and
plan() used different final ascent rates of 5 m/min and 4.5 m/min,
respectively. This led to dives that were 6 seconds longer than entered
by the user and to confusion. See #554.

Therefore, use the same ascent rate taken from the preferences field
flag.ascratelast6m in both cases.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 21:17:22 +03:00
Willem Ferguson
70bb4c145b Fix CCR setpoint display bug
1) The connection for the display of CCR-setpoint o2SetpointGasItem
   was erroneous, being connected to partialpressuregasSettings. It
   is now correctly connected to technicalDetailsSettings.
2) The colour of the setpoint graph is changed from PO2_ALERT (red) to
   an orange colour in order to show setpoint in red only when it
   exceeds 1.6. This emphasises the visibility of red parts of the
   gas pressure graphs whenever gas limits are exceeed.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-07 13:56:23 +02:00
Berthold Stoeger
fc7cb09b37 Planner: Correctly fill out last_manual_time in fake_dc()
By not filling out this value, entering of manual dives was broken
for dive lengths starting with a digit 5 or higher.

Fixes #1211

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 13:11:53 +03:00
Berthold Stoeger
920ff15f71 Planner: don't return static data in fake_dc()
fake_dc() used to return a statically allocated dc with statically
allocated samples. This is of course a questionable practice in
the light of multi-threading / resource ownership. Once these
problems were recognized, the parameter "alloc" was added. If set
to true, the function would still return a statically allocated
dc, but heap-allocated samples, which could then be copied in
a different dc.

All in all an ownership nightmare and a recipie for disaster.
The returned static dc was only used as a pointer to the samples
anyway. There are four callers of fake_dc() and they all have access
to a dc-structure without samples. Therefore, change the semantics
of fake_dc() to fill out the passed in dc. If the caller does
not care about the samples, it can simply reset the sample number
to zero after work.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 13:11:53 +03:00
Robert C. Helling
d75f7474c7 When looking for gas change events only use those
This function looks for the last gas change before a
given time. We should initialize it with a gaschange
event as we might later use this event to read a
gasmix from it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-04-29 22:50:10 +03:00
Willem Ferguson
81a812539c Plot OC-pO2 graph for SCR dives
This commit allows plotting the OC-equivalent pO2 graph for PSCR
dives. This happens in both the cases where there is no external
O2-monitoring AND when there is external pO2 monitoring. The
calculations are only done for PSCR dives and is achieved as
follows:

1) Within plot-info create a pressure-t called OC_pO2 in
   profile.h and populate this variable with the open-circuit
   pO2 values in profile.c.
2) Create a new partialPressureGasItem ocpo2GasItem in
   profilewidget2.h and, in profilewidget2.cpp, initialise it
   to read the plot-info OC_pO2 values and enable its
   display by using the setVisible method. The
   diveplotdatamodel was also touched in order to achieve
   this.
3) Create a pref button that controls the display of OC-pO2 for SCR dives
4) Change the colour of the OC-pO2 grpah to orange
5) Change the connection of the crr_OC_pO2 signal to be appropriate
6) rename the OC_pO2 attribute to scr_OC-pO2

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-28 20:11:22 +03:00
Dirk Hohndel
e9fd4cb7dc Android: correctly detect the different BT device types
The previous code would not add the non-LE address for dual stack
devices. Unfortunately, even with this fix we still don't get the
correct result for the dual stack Shearwater Petrel 2 that I have
for testing as Android incorrectly reports it as a BLE-only device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 16:02:17 -07:00
Dirk Hohndel
028299193a Create one function to determine the supported transports
This should make sure we create a consistent view based on all the
information available.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
5faa167e9f libdc transport debugging
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
ea7a7c6b24 QML UI: add supported dive computers to log file
In a more compact format than before.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
36749b28d9 Redesign the flow for checking supported DCs on Android
Only filter against the hard coded list if no other supported transports
are available for a dive computer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
0cacb06d80 Use libdc information about supported transports
For example, even on platforms that support libusb, libdivecomputer
might be compiled without such support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Linus Torvalds
901991afbe Do a better job of picking which transport to use
If the user specified bluetooth, we really should pick bluetooth, not
probe and possibly fall back to something else.

We should also honor the users choice of BLE vs classic BT.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-27 11:52:13 -07:00
Anton Lundin
fd359f5a88 Configure ostc3: Remove obsoleted setting
In firmware version 2.97 the setting 0x38, SETPOINT FALLBACK, has bin
obsoleted and we get a error when trying to write to it.

This removes this setting.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-04-27 21:33:47 +03:00
Dirk Hohndel
b930c39ead Compile fix when compiling without BLE enabled
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-25 07:56:19 -07:00
Dirk Hohndel
c5e4086820 Only offer dive computers with supported transports
On Android we still need to do more filtering as only some of the USB
divecomputers are supported. But on iOS this takes care of it without
the hard coded list.

Additionally, if built without BT or BLE support, the corresponding dive
computers are no longer shown (e.g. Perdix AI on Windows).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-24 18:02:51 -07:00
Linus Torvalds
c60d2ec3e3 use libdivecomputer 'fingerprint' to avoid downloading extra data
This opportunistically uses a cache of 'fingerprints' for already
downloaded dives.

As we download data from a dive computer, we save the fingerprint and
dive ID of the most recent dive in a per-divecopmputer fingerprint cache
file.

The next time we download from that dive computer, we will load the
cache file for that dive computer if it exists, verify that we still
have the dive that is referenced in that cachefile, and if so use the
fingerprint to let libdivecomputer potentially stop downloading dives
early.

This doesn't much matter for most dive computers, but some (like the
Scubapro G2) are not able to download one dive at a time, and need the
fingerprint to avoid doing a full dump.  That is particularly noticeable
over bluetooth, where a full dump can be very slow.

NOTE! The fingerprint cache is a separate entity from the dive log
itself.  Unlike the dive log, it doesn't synchronize over the cloud, so
if you download using different clients (say, your phone and your
laptop), the fingerprint cache entries are per device.

So you may still end up downloading dives you already have, because the
fingerprint code basically only works to avoid duplicate downloads on
the same installation.

Also, note that we only have a cache of one single entry per dive
computer and downloader, so if you download dives and then don't save
the end result, the fingerprint will now point to a dive that you don't
actually have in your dive list.  As a result, next time you download,
the fingerprint won't match any existing dive, and we'll resort to the
old non-optimized behavior.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Linus Torvalds
acc343834a Actually tie in the new libdivecomputer IO model to open the dive computer device
This creates a new libdivecomputer_device_open() helper, and makes
downloading and configuration use it to open the dive computer device
using the proper protocol.

The IRDA case was tested by Sébastien Dugué - I had initially left it
undone believing that "nobody uses IRDA".

Reported-and-tested-by: Sébastien Dugué <sebastien.dugue.subsurface@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Linus Torvalds
13f5c75ac4 Convert our custom IO model to new libdivecomputer IO model
This converts our old custom IO model to the new model that
libdivecomputer introduced.  This is partly based on Jef's rough patch
to make things build, with further work by me.

The FTDI code is temporarily disabled here, because it will need to be
integrated with the new way of opening devices.

The ble_serial code goes away entirely, since now libdivecomputer knows
about BLE transport natively, and doesn't need to have any serial
wrapper around it.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Berthold Stoeger
529d407933 Cleanup: Make local function waitFor() of static linkage
Moreover, remove it from the `extern "C"` block, since extern/static
is oxymoronic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19 15:08:12 +03:00
Berthold Stoeger
8f4604ead8 Coding style: remove superfluous semicolons
Remove a semicolon after Q_OBJECT and a few others after the closing
braces of while loops.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19 15:08:12 +03:00
Dirk Hohndel
40755987ed Qt: don't use member function that requires Qt 5.8
This should have been caught by our build check, but it turns out that
that one isn't correctly reflected in its Travis status.

Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-15 14:46:56 -07:00
Dirk Hohndel
6a51c14365 DiveObjectHelper: expose number of dives in a trip
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 17:39:40 -07:00
Dirk Hohndel
1de4321ca1 GPS: untangle the timestamp comparison
And calculate the correct time since last fix.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:38:19 -07:00
Dirk Hohndel
ca3be8f376 GPS: add signal to show that a new fix has been acquired
This way if we don't have a current enough position we can wait for a
current fix to be acquired.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
82a3d2be95 QML UI: better debug messages for getting current location
Also, show GPS refresh interval in seconds; it's confusing if this is
reported in ms.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
f693678235 iOS: create our own OS support file
Up until now we just reused the macos.c file for convenience, hard coding a
specific file path that may or may not work on iOS.  Instead get the preferred
path from Qt and for this we need to be able to call into Qt, so this needs to
be a C++ file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:43 -07:00
Dirk Hohndel
d931652f69 BLE debug: show more packages
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Dirk Hohndel
874cba1116 Mobile: add Mares BLE dive computers
Technically, these aren't BLE, these are just the three devices that
are supported by the Mares Bluelink Pro Bluetooth download dongle.

While we are at it, admit that this code is no longer automatically
created but instead maintained by hand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Dirk Hohndel
d15a0bc277 Fix typos
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Robert C. Helling
ece714556f Look for actual isobaric counter diffusion
Identify segements that fullfill the folllowing criteria for
the leading compartment:

He is off-gasing while N2 is on-gasing
Overall there is on-gasing

Add a line to the info box for those segments

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-04-11 21:15:38 +02:00
Berthold Stoeger
71d1e78db2 Cleanup: Fix memory leak in plannernotes.c
dive->notes was overwritten without free()ing the old buffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
a4834e198d Cleanup: fix "unsave" snprintf()s in plannernotes.c
The planner notes were constructed using a sequence of
  len += snprintf(buf, buflen - len, ...);
calls. This will fail once len > buflen, because the second parameter
of snprintf is unsigned. Note that snprintf returns the number of
bytes that would have been written if it weren't truncated.

Fix this by using membuffer with put_format()/put_string() and
asprintf_loc().

Fixes #1155.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
f7b2355ced Cleanup: unconstify results of two functions
get_dive_date_c_string() and get_current_date() return copied strings.
Make this explicit by returning non-const pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
44bcc5a307 Cleanup: make local functions in core/plannernotes.c of static linkage
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Jeremie Guichard
5d96d4af0c Add usage documentation for membuffer helper functions
Added a comment block on top of membuffer.h describing common usage
of membuffer helper functions

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-10 08:18:32 -07:00
Berthold Stoeger
8b0055d15c Cleanup: remove unused function get_selected_dives_text()
The only caller was removed in commit c3f07b9f81.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-10 08:16:33 -07:00
Berthold Stoeger
bbacdf94e3 Cleanup: Slightly shorten code in vqasprintf_loc()
Move duplicate code, which reads '*' arguments from va_list into
parse_fmt_int() function. To pass pointers-to-va_list, the va_list
has to be copied first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-09 11:29:43 -07:00
Berthold Stoeger
5afe1a53d8 Cleanup: Move *_loc formatting functions into new format.cpp file
qthelper.cpp is already quite voluminous. Move the recently
introduced localized versions of (v)snprintf() and put_format()
into their own translation unit.

Moreover, adopt C-style semantics for asprintf_loc(). This function
will be used to remove fixed-size buffers in core/plannernotes.c.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-09 11:29:43 -07:00
Jeremie Guichard
7753352e62 Change taglist_get_tagstring to support 'unlimited' tag list size
Previous taglist_get_tagstring signature/implementation did not allow
handling of cases where inputted buffer could not contain all tags.
New implementation allocates buffer based on pre-computed size allowing to
insert all tags in the returned string.

Added get_taglist_string in qthelper to handle conversion to QString
Added TestTagList with tests for taglist_get_tagstring

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-09 07:59:51 -07:00
Miika Turkia
b28e3db7f1 Temperature 0x7F appears to mean no reading
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Miika Turkia
6cfbe10bc3 Handle int and float temperatures
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Miika Turkia
e04dadc378 Explicitly mark DM4 conversion
Same as default branch, but as 0x01 appears to be converted from DM4 to
DM5, let's just be explicit about it.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Miika Turkia
06a2f36a62 Start to describe DM5 sampleBlob
Currently the best guess of sampleBlob format. Unfortunately there seems
to be some version of DM that stores the temperature in different
location that I have not been able to figure out yet. Note that some
version of DM does not utilize sampleBlob but specific blobs for each
value (temperature, pressure, ...).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Berthold Stoeger
b01c9328b4 Dive pictures: extract timestamp from MP4 and related formats
Parse MP4s and related video files and extract the creation timestamp
from the "mdhd" (media header) atom.

Introduce helper function templates to extract arbitrary-length
unsigned integers in big-endian format from file or memory.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01 16:04:48 +03:00
Berthold Stoeger
66b71c60a0 Dive pictures: use get_metadata() in dive_create_picture()
Thus, metadata has to be only read once and the picture_load_exif_data()
function can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01 16:04:48 +03:00
Berthold Stoeger
9b2482aca9 Dive pictures: Move metadata functions into own translation unit
Move all metadata function into new core/metadata.cpp file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01 16:04:48 +03:00
Berthold Stoeger
d9df8c3f47 Debug: Error reporting for SHashedImage loading
Overwrite QImage::load() in SHashedImage so that we can perform better
error reporting.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01 15:59:46 +03:00
Berthold Stoeger
376b737891 Debug: sprinkle debug messages in thumbnailing code
To ease trouble-shooting of the picture thumbnailer add a number
of debug- and info-messages.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-04-01 15:59:46 +03:00
Dirk Hohndel
99bc940551 Use older API to remove dependency on Qt 5.8 or newer
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-22 07:40:32 -07:00
Dirk Hohndel
78937ce572 iOS: build fix
Otherwise the moc build fails.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-22 07:33:33 -07:00
Stefan Fuchs
b38eb45b29 Profile heartrate: Nicer min/max values and tic distance
Correct a bug in finding the minimum heartrate.

Use the minimum and maximum heartrate value to set min/max and
tic distance for the heartrate axis in the profile.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-19 15:44:02 -07:00
Berthold Stoeger
c896938f7a Dive pictures: If EXIF data couldn't be parsed, use creation date
This is a preparation for supporting videos. Some video formats may
not possess such meta data, or we may not yet be able to parse them.
In such a case, use the file creation date.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-19 13:14:54 -07:00
Berthold Stoeger
d9b502f0c7 Dive pictures: Don't read whole file for parsing EXIF data
This is a preparation for video support. We don't want to read a whole
potentially multi-GB file into memory just to detect that it isn't a
JPEG. Especially since at the moment EXIF metadata are parsed twice,
once for GPS, once for timestamp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-19 13:14:36 -07:00
Berthold Stoeger
2105d3c7d0 Cleanup: consistently use toUtf8() instead of toLocal8Bit()
These do the same, since the text-codex is set to UTF-8 on startup.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
d1572a8d95 Cleanup: introduce copy_qstring() function
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
Replace constructs of the kind
  s.toUtf8().data(),
  s.toUtf8().constData(),
  s.toLocal8Bit().data(),
  s.toLocal8Bit.constData() or
  qUtf8Printable(s)
by
  qPrintable(s).

This is concise, consistent and - in principle - more performant than
the .data() versions.

Sadly, owing to a suboptimal implementation, qPrintable(s) currently
is a pessimization compared to s.toUtf8().data(). A fix is scheduled for
new Qt versions: https://codereview.qt-project.org/#/c/221331/

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
4e44fe7598 Cleanup: constify string arguments in core/dive.c
Make arguments to set_informational_units(), set_git_prefs(),
set_userid(), dive_remove_picture() and update_event_name()
"const char *" for consistency with the rest of core/dive.c.

This will allow replacing toUtf8().data() with the constData()
version in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
6f2169488a Cleanup: Set text encoding to UTF-8 for all platforms.
This was only done explicitly for Windows. Other platforms were
implicitly supposed to be UTF-8.

Suggested-by: Lubomir I. Ivanov <neolit123@gmail.com>

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Dirk Hohndel
f799c9ca3f Subsurface-mobile: Add OSTC 2 TR as support dive computer
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14 01:03:31 -07:00
Linus Torvalds
f5e2a17e7d Subsurface update for upstream libdivecomputer changes
So because I merged with upstream libdivecomputer, and it no longer does
the "halfduplex emulation" thing in the IO layer, and instead does it in
the only Suunto backend that needed it, that also affected our custom IO
layer in subsurface.

Sure, I could have left a dummy interface and left subsurface with some
ugly dead code, but it's really better to just get rid of the code.

So when Dirk pulls in the libdivecomputer updates from

    https://github.com/torvalds/libdc-for-dirk.git Subsurface-branch

this patch to remove the halfduplex code in subsurface is also needed.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-13 22:34:57 -07:00
Anton Lundin
8de887c8ee Treat a PSCR dive with sensors more like a CCR dive
PSCR dives with o2 sensors are more like CCR dives. The math is exactly
the same, its just a different diluent and a different po2.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-03-13 18:54:16 +02:00
Anton Lundin
b48eb47178 Fix up CCR/PSCR dives with sensors values without no_o2sensors
This introduces a fixup function that walks all the samples and
populates the no_o2sensors if its zero and supposed to be something
else.

There is a bug somewhere which Willem hit, causing this to never be set.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-03-13 18:54:16 +02:00
Anton Lundin
15b6953438 Use the current dive mode instead of constant
In the if case above, we already conclude its a OC dive, but its cleaner
to actually pass the current mode instead of a hard coded value.

This also makes the code less prune to future bugs.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-03-13 18:54:16 +02:00
Lubomir I. Ivanov
2317fed9b6 DiveObjectHelper: add dive_site_uuid()
The map widget on the mobile version requires that
a dive object from a model has a dive_site uuid.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-11 11:40:12 -07:00
Stefan Fuchs
5d32fd0723 Cosmetic modifications in profile delta sample string
Consistently do not use a space between value and unit.
Consistently do not use a space between "name:" and value.
Add "/min" for SAC rate.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-06 13:06:52 +02:00
Berthold Stoeger
bdc470a80e Cleanup: Remove hash field from picture-structure
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.

Therefore, make this explicit by removing the hash field from the
picture structure.

Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
e5dcd9fc16 Cleanup: pass QString and QByteArray const-refs to qthelper functions
Passing of QStrings and QByteArrays was inconsistent in qthelper.cpp.
Unify to passing const-references. Passing by value is no big deal, since
QString and QByteArray do copy-on-write "optimization". Nevertheless, let's
keep it as consistent and effective as possible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
f5eafe2a71 Cleanup: Fold add_hash() call into learnHash() function
learnHash() was always called in conjunction with add_hash(). The
pattern was that a local filename and a hash were connected in
the hash-to-filename and the filename-to-hash maps. Then, the
original picture-filename or url were registered in the filename-to-hash
map.

This commit changes learnHash() to take three parameters (original-filename,
local-filename and hash) and do all of the above. The new code is
simpler because no dummy picture struct has to be generated in
DiveListView::loadImageFromURL().

The tests were extended to check for all hash<->filename associations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
b750a48f0f Cleanup: Don't store hash in picture struct in learnHash()
learnHash() is called either on a local picture structure
[DiveListView::loadImageFromURL()] or on a cloned picture structure
[ImageDownloader::saveImage()]. In neither case the picture structure
is passed to the frontend. Therefore, storing the new hash in the
picture struct is not necessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
83b2870648 Cleanup: Don't call learnHash() in hashPicture()
hashPicture() calls hashFile(), which calls add_hash(). add_hash()
updates the filename-to-hash and hash-to-filename maps. Therefore,
there is no point in calling learnHash() in hashPicture(), which
updates the filename-to-hash map.

Note that learnHash() updates the picture-struct with the new hash,
but since hashPicture() works on a cloned picture-struct, which
is free()d in hashPicture(), these changes are lost anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
a0d02bacf3 Cleanup: remove updateHash() function
updateHash() and hashPicture() did the same thing, with the exception
that hashPicture() marked the dive list as changed if a hash changed.
This seems like a good idea in any case, therefore always use
hashPicture().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
f8835751dc Cleanup: Make helper function haveHash() of static linkage
The function is only used in the qthelper.cpp translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
eaff0ddee7 core/imagedownloader.cpp: Use signal to exit eventloop
Don't do busy-waiting.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
907c07ce50 core/imagedownloader.cpp: Use implicit default constructor of QImage
No point in move-constructing from a different default constructed
QImage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
117f4a0d7d core/imagedownloader.cpp: remove recursion
If loading from hash failed in the saveImage() slot(!) it would
recurse into loadFromUrl(), which would generate a new network
reply. Very scary and a (small) wonder that it worked.

Let's try to make this all more explicit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
54d56a74aa core/imagedownloader.cpp: Make the manager object local to load()
The QNetworkAccessManager is only used in the load() function. No
point in it being a subobject.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
2803b7d385 core/imagedownloader.cpp: Simplify deletion of objects
1) Destroying the QNetworkManager seems like a bug: this was a
subobject of ImageDonwloader. It's mysterious how this didn't
crash.

2) Instead of calling deleteLater() on the reply object, simply
delete it after completion.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
c1cd2e0f02 core/imagedownloader.cpp: Fix memory leak
A cloned picture struct would not be freed if the filename was already
in the queued-for-download set.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Stefan Fuchs
aacc688670 Use correct numeric format based on selected locale (Qt domain part)
This changes the numeric format of many values printed to the UI to
reflect the correct numeric format of the selected locale:
- dot or comma as decimal separator
- comma or dot as thousands separator

In the Qt domain the `L` flag is used case specific mostly
in qthelper.cpp.
Then the helper functions get_xxx_string() are used more consistently.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05 16:28:18 +01:00
Berthold Stoeger
18c034ea37 Localization: implement *_loc() functions in plannernotes.c
Replace snprintf() and put_format() by snprintf_loc() and
put_format_loc(), respectively to localize formatting of
integers and floats.

Acked-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 16:23:55 +01:00
Berthold Stoeger
57c3e43df9 Localization: implement *_loc() functions in profile.c
Replace snprintf() and put_format() by snprintf_loc() and
put_format_loc(), respectively to localize formatting of
integers and floats.

Acked-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 16:23:55 +01:00
Berthold Stoeger
bec3e80683 Localization: Make Qt's locale-aware formatting accessible from C
This commit introduces functions:
 - QString asprintf_loc(const char *cformat, ...);
 - int snprintf_loc(char *dst, size_t size, const char *cformat, ...);
 - put_format_loc(struct membuffer *, const char *fmt, ...);
and their va_arg equivalents, which use Qt's QString::arg() formatting
options to render the strings.

The snprintf_loc() function takes care not to truncate multi-byte
UTF-8 encodings. Thus, on overflow, the resulting string might be
shorter than size-1.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 16:23:55 +01:00
Stefan Fuchs
1723db9d0b Configure DC dialog: Add a few missing translations
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05 16:19:49 +01:00
Oliver Schwaneberg
0ca52f868e Choose water presets from a qcombobox in planner, custom value possible
Add a combo box for water types with defaults for fresh water, sea water
and the EN 13319. All values taken from units.h, where EN 13319 was added
beforehand.
Custom values can be entered through a spinbox.
Also changed "Salinity" in TapDiveInformation.ui to "Water type".

Translation required!

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-03-02 08:38:22 -08:00
Berthold Stoeger
0fa6422a04 Warning Fix: add missing include to core/parse-xml.c
Fallout from commit #cd5e17cf79c2f1eb896efd0436c103221de446ae

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-02 02:46:31 +02:00
Stefan Fuchs
4cbf8b87a3 Updated strategy for removing cylinders
Change the strategy when to allow cylinder removal from a dive:
- Not remove when cylinder has gas switch events, in any other cases
  allow removal
- Remove this whole "cylinder with same gas" thing being a criteria
  for cylinder removal

When removing a cylinder which has corresponding pressure info in
samples, also remove this pressure info from the samples.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-27 09:17:57 +01:00
Berthold Stoeger
cd5e17cf79 Cleanup: Unify qthelper.h and qthelperfromc.h
Since all qt-helpers are defined in qthelper.cpp, there seems to be
no reason to have two include files. By unifying the two files,
duplication and inconsistencies are removed. The C++-only part is
simply compiled away with #ifdefs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 19:06:02 +02:00
Berthold Stoeger
7bd860f2b7 Cleanup: Use QString as parameter for [get|save]BtDeviceInfo()
Each callsite of saveBtDeviceInfo() has a QString, which is converted
to a C-string, passed and immediately converted back. Remove these
conversions by taking a reference to QString directly.

getBtDeviceInfo() is not as clear. Here, the callsite has a C-string
handed down from libdivecomputer. Nevertheless, pass a reference of
QString here as well. Firstly, for reasons of symmetry. Secondly,
to avoid multiple conversions in the getBtDeviceInfo() functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 08:52:34 +01:00
Stefan Fuchs
d9c0df0142 Correctly suppress display of ICD table if prefs.show_icd is false
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-25 02:04:30 +02:00
Stefan Fuchs
b5b5d619be For prefs option show_icd add missing call for loading
Add the missing call to load the prefs option show_icd in function
SettingsObjectWrapper::load()

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-25 02:04:30 +02:00
Stefan Fuchs
4d377926e0 Whitespace cleanup in core/divelogexportlogic.cpp
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24 11:45:17 -08:00
Stefan Fuchs
862e121532 Correct comments for struct temperature_t value range
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24 11:45:17 -08:00
Stefan Fuchs
ca4ccadcc4 Use duration_t for total_sac_time in struct stats_t
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24 11:45:17 -08:00
Stefan Fuchs
95a23cf470 Use temperature_t for temperatures in struct stats_t
Use struct temperature_t for temperatures in struct stats_t and
use get_temperature_string() when printing these temperatures for
statistics and HTML export.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24 11:45:17 -08:00
Stefan Fuchs
f08e24d65b Exit add_plan_to_notes() in plannernotes.c always via label finished
Replace an early "return" in add_plan_to_notes() with a "goto finished;"
This was the initial idea of doing it plus it fixes a potential memory
leak (missing free for icdbuffer).

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-22 21:48:46 +02:00
Robert C. Helling
818ab36b24 Indicate direction of transition in verbatim plan
Replace "Transition to" by "Ascent to" or "Descend to"

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-20 14:29:31 +01:00
Berthold Stoeger
5c248d91cd Coding-style: remove superfluous parentheses
Mostly replace "return (expression);" by "return expression;" and one
case of "function((parameter))" by "function(parameter)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 19:38:52 -08:00
Berthold Stoeger
d5d830eac0 Cleanup: Save hash from filename-to-hash map to git repository
This unifies behavior of XML & git saving. Now, in both cases, the
picture hash is extracted from the filename-to-hash map instead of
using the picture structure.

This seems more robust, because the picture structure is not necessarily
updated by learnHash(). The latter may operate on a copy of the picture
structure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 11:06:30 -08:00
Berthold Stoeger
e880948d73 Cleanup: return copied string from hashstring()
The following statement in the hashstring() function:
  return hashOf[QString(filename)].toHex().data();
returns data of the temporary QByteArray generated by toHex().
Thus, the caller will access released memory, which could lead to
data corruption.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 11:06:30 -08:00
Berthold Stoeger
9ca7cf0f1e Cleanup: remove outdated TODO item
report_error() automatically pushes error messages. No need for a
separate signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12 11:11:34 -08:00
Berthold Stoeger
7fedc5931a Cleanup: remove declaration of get_error_string()
This function was removed in #8f81a22e7f26729cc2f4902ba7db8f696314539f.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12 11:11:34 -08:00
Lubomir I. Ivanov
2b4115d712 dump_tissues: fix missing 'struct deco_state' argument
With DECO_CALC_DEBUG != 0, divelist.c and profile.c have calls
to dump_tissues() without passing a 'struct deco_state' argument.

Fixes #1105

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-02-12 07:48:34 +01:00
Robert C. Helling
920aa613c9 Add a preference to turn on ICD warnings
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-10 10:26:34 +01:00
Berthold Stoeger
fe133e2cca Cleanup: unserialize loading of pictures
The images to load are kept in a set to avoid multiple loading of
the same picture. The set was protected with a mutex.

Problem: the mutex was not released before loading the picture,
effectively serializing the loading of pictures.

Therefore unlock the mutex once the set is updated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07 09:44:43 +01:00
Berthold Stoeger
4c84c0baf1 Cleanup: remove unused typedef
The type SHashedFilename defined in core/imagedownloader.h was not
used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07 09:44:43 +01:00
Berthold Stoeger
9986ce25d7 Cleanup: Make local helpers and variables of static linkage
In core/imagedownloader.cpp the helpers cloudImageUrl() and loadPicture()
are made of static linkage.

The global variables queuedPictures and pictureQueueMutex were moved
into the loadPicture() function, because they are used only there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07 09:44:43 +01:00
Oliver Schwaneberg
eb38a64149 Do not remove seconds from duration input field
This change deals with issue #554.
If you enter a dive duration manually, the cell renderer cuts the seconds
away when the changes are saved. I added the helper "render_seconds_to_string"
as a counterpart to "parseDurationToSeconds". The helper keeps the seconds,
if not null. The rendering of the cell is done at two places in the code,
so I think it is cleaner to add a dedicated method for it.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-02-04 13:40:02 -08:00
Stefan Fuchs
b5ce06c8b9 Free various struct membuffer in different functions
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-02 11:29:55 -08:00
Willem Ferguson
5416fc7afb Print icd data only when it is really needed
Reduce the impact and visibility of icd calculations by writing
the data to the planner output only in cases where gas switches
involve:

1) ascent
2) helium is used as part of breathing gas
3) gas switch results in an increase in partial pressure of nitrogen.

Coding change:

1) The code for writing the header of the icd table as well as
   the inclusion of the data in the planner output is made
   conditional on the above three requirements. This involves
   moving the code that writes the table header into the
   function that writes an icd data item to buffer.
2) Manipulation of a boolean variable that controls writing
   of the table header to buffer and that also determines
   whether any icd results should be inluded in the planner
   results.
3) Reorganise comments so that there are not multiple tabs between
   the code and the start of a comment.

Correct type and insert braces where important

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-02-02 13:14:09 +01:00
Jan Mulder
494ad26540 mobile cleanup: restyle construction of locationlist
See also e6e1473e6. The construction of the locationlist
was not the same as the 3 previous lists, and it needs
the inclusion of a new model file (divelocationmodel.cpp)
in the mobile app. In addition, as the mobile app is mainly
interested in a simple stringList (model) to populate a HintsText
field (or maybe later a combobox), this stringlist is added
to the model, to easy interfacing with QML.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
83259008e7 mobile cleanup: unduplicate code and do not loop over dives (3)
See e6e1473e6. Exact same commit but here for the
list of divemaster. The careful reader will spot a
small addition to the clearDetailsEdit() QML function.
Two more field are cleared.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
572fc47071 mobile cleanup: unduplicate code and do not loop over dives (2)
See e6e1473e6. Exact same commit but here for the
list of buddies.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Jan Mulder
fed2c5b6a1 mobile cleanup: unduplicate code and do not loop over dives (1)
This is the first of a set of commits that are (very) similar.
It appeared that a number of more or less static lists, which are
constructed by a loop over all dives in the logbook, were executed
when changing focus to a next dive. For example, the in this
commit addressed list of used dive suits.

What was wrong was that the suitList was linked to a dive. There
is only a need to construct the list of used suits when data is
changed (and obviously, once on startup of the app). Further, it
appeared that a lot of code was duplicated and that we can use
(in this case) the same code from the desktop completionmodels.cpp.

Basically, this commit involves the following changes:
- include completionmodels.cpp in mobile and desktop (so move
it from the desktop only category to the generic category).
- remove double code from DiveObjectHelper.cpp
- Do not differentiate in the init phase and the normal refresh
of the list
- the per dive logic is now only the getting of a previously
constructed list (in init or update of the divelist).

There are no visible changes in the UI, other than a better
performance when scrolling over dive details.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Oliver Schwaneberg
728e007c5c uemis: code refactoring
- Variable max_deleted_seen had no effect and is removed.
- Results of read/write operations are evaluated to assert success
  and to prevent compiler warnings.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31 14:47:47 +01:00
Berthold Stoeger
8f81a22e7f Make report_error() reentrant
Remove the global error buffer and pass the error string directly
to the frontend. The frontend is then responsible for accumulating
errors.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Oliver Schwaneberg
5a9faf2fea uemis: Fix mapping of object_ids to dive numbers
When performing a factory reset to an uemis, the object_ids within the divelog
will not be reset. Nevertheless, the dive numbers are reset to 1.
So, the first log will have a positive offset n to the first dive number.
The uemis-downloader used the object_id from the logs as a start point for
getDive, if dives were already synced before. This causes the sync to stall.
I prevent this by subtracting the lowest object_id from the requested before
using it as dive number.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31 14:46:30 +01:00
Oliver Schwaneberg
8accd08715 uemis: speed up synchronisation of same divesites
uemis-downloader downloads the dive spot for each dive, even if the same
location was already downloaded before within the ongoing synchronization run.
I modified the function "get_uemis_divespot" to remember all requested
divespot_ids and their mapping to uuids.

New helper functions:
    - static void erase_divespot_mapping()
    - static void add_to_divespot_mapping(int divespot_id,
                                          uint32_t dive_site_uuid)
    - static bool is_divespot_mappable(int divespot_id)
    - static uint32_t get_dive_site_uuid_by_divespot_id(int divespot_id)
    The memory leak is removed through the call of erade_divespot_mapping().

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-27 12:23:47 -08:00
Robert C. Helling
c6d626c618 Limit recreational dives to 6 hours
Otherwise, with large gradient factors, one can have infinite NDL
which result in an infinite loop when no gas is set.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-26 07:04:45 +01:00
Willem Ferguson
b9ac89574e Planner: print icd information at 0.1 resolution
The gas fractions (in %) are now printed at a resolution of 0.1%
and not at 0.01% as previously.

The string in the info box that provides icd data is reformatted
so that the info-box is as narrow as possible.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-24 22:03:42 +01:00
Jan Mulder
2c8693f468 Do not add double ConnectionList items
Refuse to add a ConnectionList row, when the row is already
there. This, obviously, prevents double items.

Fixes: #1069

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-24 16:19:09 +01:00
Robert C. Helling
c89cfcccbe Only give ICD warning if pN2 increases
as otherwise there are warning on the descent.

The ICD line in the info box is generated for all
gas switches with decreasing He content.

Also change the presentation in the info box to align it
with the notes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-21 15:24:46 +01:00
Stefan Fuchs
c866b82f35 Planner notes min gas: Remove incorrect line wrap inside printf string
With old code the tabs at the start of the second line were incorrectly
added to the string.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
81e9b230ca Planner notes ICD: Format HTML with DIV, do table title differently
In the planner notes format the HTML for different sections with
div tags.

Put the table title for the ICD table outside the table because then the
alignment looks a little bit nicer.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
d3bcf02bbc Planner notes ICD: Coding style change only
Avoid the need for a char array for the "old_gas_name" by passing
two pointers to the gasmixes to the add_icd_entry function and
calling helper function gasname() there twice.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
e408e32ed6 Planner notes ICD: Print correct runtime for gaschange
If a gaschange happens at the beginning of a segment, currently the
wrong runtime (end of segment time) is printed in the ICD table.

This is corrected here.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Willem Ferguson
f2fe389abd Move function isobaric_counterdiffusion()
Move the above function from plannernotes.c to dive.c so that
it is available to be called from the dive log part of the
software, and not only from the planner. The following was done:

1) Edit the comment above the code to make it more accurate
2) Move the structure icd_data to dive.h
3) Create an external reference in dive.h for the above function
4) Copy the body of isobaric_counterdiffusion() to dive.c

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-20 10:10:09 +01:00
Willem Ferguson
f072f78c29 Implement ICD calculations in planner output
This patch implements the calculation and printing of icd parameters
in the dive planner output. It does:
1) icd parameters are calculated following the rule-of-fifths for
   OC trimix dives. For each gas change on the ascent that involves
   helium, the change in gas composition as well as the change in
   partial pressures are shown. If rule-of-fifths is exceeded, a
   warning message is prinetd.
2) An independent function is provided that in principle enables
   calculation of icd paramaters outside of the context of the
   dive planner.

Further updates to icd calculations

These changes respond to #1047. Code style conventions have been
improved. The ICD table is now also printed when the planner is
set to verbatim mode. The code that created the html icd results
has been moved to a function. This does not make the code more
efficient (many parameters passed) but it makes the code more clean.

Free a new dynamic variable (old_gas_name)

Stylistic changes to new code in plannernotes.c

Changes in comments to explain some of the changes I made.
Preparation of comments and functioning of isobaric_counterdiffusion()
and its dependent data structure for possible transfer to dive.c
and dive.h after finalisation and merging of the present PR.
Smaller stylistic changes to conform to our coding rules.

The several comments and suggestions during github review
(@atdotde, @leolit123, @sfuchs79) are incorporated.

Fixed up mis-aligned comments and text descriptions by replacing
tab characters with space characters, thereby hard-forcing
alignment of indented lines of text.

Remove parameter *dive from function isobaric_counterdiffusion().

Improve a few constructs to conform to our style rules.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19 19:43:16 +02:00
Willem Ferguson
9a8bab21c9 Improve profile display in planner
This patch allows the planner to save the last manually-entered
dive planner point of a dive plan. When the plan has been saved
and re-opened for edit, the time of the last-entered dive planner
point is used to ensure that dive planning continues from the same
point in the profile as was when the original dive plan was saved.
Mechanism:

1) In dive.h, create a new dc attribute dc->last_manual_time
   with data type of duration_t.
2) In diveplanner.c, ensure that the last manually-entered
   dive planner point is saved in dc->last_manual_time.
3) In save-xml.c, create a new XML attribute for the <divecomputer>
   element, named last-manual-time. For dive plans, the element would
   now look like:
   <divecomputer model='planned dive' last-manual-time='31:17 min'>
4) In parse-xml.c, insert code that recognises the last-manual-time
   XML attribute, reads the time value and assigns this time to
   dc->last_manual_time.
5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive,
   insert code that sets the appropriate boolean value to dp->entered
   by comparing newtime (i.e. time of dp) with dc->last_manual_time.
6) Diveplannermodel.cpp also accepts profile data from normal dives in
   the dive log, whether hand-entered or loaded from dive computer. It
   looks like the reduction of dive points for dives with >100 points
   continues to work ok.
The result is that when a dive plan is saved with manually entered
points up to e.g. 10 minutes into the dive, it can be re-opened for edit
in the dive planner and the planner re-creates the plan with manually
entered points up to 10 minutes. The rest of the points are "soft"
points, shaped by the deco calculations of the planner.

Improvements: Improve code for profile display in dive planner

This responds to #1052.
Change load-git.c and save-git.c so that the last-manual-time is
also saved in the git-format dive log.

Several stylistic changes in text for consistent C source code.

Improvement of dive planner profile display:

Do some simplification of my alterations to diveplannermodel.cpp

Two small style changes in planner.c and diveplannermodel.cpp
as requested ny @neolit123

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19 12:38:11 +02:00
Berthold Stoeger
7594e7ca7f Unify username handling of remote git repositories
The username was extracted from https:// urls but not from ssh://
urls. Unify this by extracting the username from any remote url.
This is done with regard to unifying the file handling in the
frontend.

For this approach to work, the credential callback of the ssh://
transport had to be adapted. It now also supports username/password
in addition to private-key authentication.

Currently, the only way the user can use the username/password
authentication is by deleting a potential public key.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19 09:45:08 +02:00
Berthold Stoeger
5a767ce964 Support non-https:// repositories for saving
On saving to a remote git repository, the transport was set to https://,
which broke saving to ssh:// repositories. Instead determine the
transport from the remote url.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19 09:45:08 +02:00
Berthold Stoeger
cec642b4d2 Create local cache and push to remote for any remote repository
This used to be done only for cloud repositories.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19 09:45:08 +02:00
Berthold Stoeger
0b0eacce30 Check cloudserver availability only for cloud repositories
The check used to be done for any https:// repository.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19 09:45:08 +02:00
Berthold Stoeger
b188f00587 Factor out counting of authentication attempts into function
Moreover, make the maximum number of authentication attempts a
const variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19 09:45:08 +02:00
Jan Mulder
88658bd9e3 Use different preference file for mobile
This is a change mainly for developers working on both mobile and
desktop application. As the current setup is that all preferences
are stored in one file (Subsurface.conf), for both mobile and desktop,
the unwary developer might get confused that the things tested on
mobile-on-desktop are not working on mobile-on-device. As we share
a lot of code between the desktop and the mobile code, also
our fairly extensive set of preferences play a significant role
in the inner workings of our applications.

So, this commit introduces an own preferences file for mobile
(on desktop) resulting in the preferences between the plain
desktop apllication now invisible to the mobile-on-desktop
application and vise versa. Making the mobile-on-desktop a
much more realistic test plaform for mobile development.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-19 09:39:07 +02:00
Oliver Schwaneberg
af89698d64 Checking for ACK for getDive.
get_matching_dive does not check if the DC wrote an acknowledgement for the requested dive.
As result, the sync stalls if dive number 0 is not available.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-19 09:27:32 +02:00
Jan Mulder
65caddb294 code cleanup: translators are not global
Un-globalize unused global variables.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-18 17:36:31 +02:00
Berthold Stoeger
2d24dceafa Use format_string() in core/git_access.c
Since this helper-function exists, we might just use it. A subtle
reuse of a buffer (string of second use was known to be shorter than
string of first use) was replaced by a separate allocation.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-17 21:45:48 +02:00
Berthold Stoeger
daede13571 Fix leak(s) in core/git-access.c
The libgit2 functions git_cred_ssh_key_new() and git_cred_userpass_plaintext_new()
copy their arguments. Therefore, free the string arguments or don't
copy them in the first place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-13 21:55:33 +01:00
Willem Ferguson
082def8162 Fix indentations for plannernotes.c
The last 2 commits have now been squashed.
S Fuchs's comment on line 315 has been fixed

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-11 21:47:04 +01:00
Berthold Stoeger
c44224ed29 Move always true ++lineptr out of while-condition
In core/file.c move ++lineptr out of the while condition
  !empty_string(lineptr) && (lineptr = strchr(lineptr, '\n') && ++lineptr
since it always evaluates to true.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Berthold Stoeger
6a07ccbad2 Use helper function empty_string() instead of manual checks
For code consistency, substitute boolean expressions:
 s && *s     -> !empty_string(s)
 s && s[0]   -> !empty_string(s)
 !s || !*s   ->  empty_string(s)
 !s || !s[0] ->  empty_string(s)

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Berthold Stoeger
e85ecdd925 Introduce helper function empty_string()
There are ca. 50 constructs of the kind
  same_string(s, "")
to test for empty or null strings. Replace them by the new helper
function empty_string().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Berthold Stoeger
86ef9fce75 Change return code of string comparison functions to bool
These functions were returning 0 or 1 anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Berthold Stoeger
85ac3106e6 Typo: indice -> index
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Jan Mulder
0096284a8e cleanup: fix possbile buffer overrun
No reason to mess around with a 5 byte buffer when we have a
proper buffer available to receive a possibly 8 byte output
based on the format string. And silences compiler warning.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
3e2caa468e cleanup: initilize local variable
Silence compiler warning by correctly initializing local variable.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
0bb1a82127 GpsLocation::clearGpsData() is only used in SUBSURFACE_MOBILE
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
5faf3f9410 Unused code: has_hr_data()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
b7a6b7c6be Unused code: report_message()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
1c03075f24 Unused code: remove taglist_contains_all()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
dc54b4aaeb Unused code: remove weightsystems_equal()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
b2c7a4cf1d Unused code: weekday()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
3cd3653972 Unused code: remove taglist_equal()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
768f0db991 Unused code: remove shift_times()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
c69ea1de1b Unused code: remove trip_has_selected_dives()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Jan Mulder
69b922dc72 Unused code: remove PluginManager::socialNetworkIntegrationPlugins()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Berthold Stoeger
099662023c Move resetting of current file out of clear_dive_file_data()
This is the only case where C-code sets the current file.
Remove this call for a better separation of C-backend and
C++-frontend parts.

There were four callers of clear_dive_file_data(). Two of them
would call set_filename() anyway. For the remaining two add an
explicit call to set_filename().

This commit fixes a bug introduced in commit b3901aa8f9:
The cloud-online menu entry was still enabled after "closing" the
cloud storage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 12:01:04 +01:00
Berthold Stoeger
35b5b9282f Enter offline mode if sync with cloud failed
In case syncing with the online repository failed, enter offline mode.
This reflects the message sent to the user ("working with local copy").

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 12:00:42 +01:00
Berthold Stoeger
afeb2e3652 Make a few functions of static linkage
Make functions in core/file.c, core/parse.c and core/import-csv.c
that were not used outside their translation unit of static linkage.

parse_date is moved from core/file.c to core/import-csv.c, since it
is used only there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 09:52:55 +02:00
Berthold Stoeger
fa5865a566 Remove unused function parse_mkvi_buffer()
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 09:52:55 +02:00
Miika Turkia
e531c04b8d Remove obsolete error/debug messages
The used parse_dl7_new_line function already prints an error / debug
message so these are unnecessary.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
6a2ea71a36 Parse water temperature from ZDT
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
5e9e6625d0 Function to look for new line on DL7 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
9cf013235c Use dynamic indexing instead of hard coded
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
d23600eb9e Add support for air temp on DL7 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
f91f16a4b6 Dummy parse empty dives
Easiest way to get dives without profiles in, is to just parse empty csv
tags.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
9d65c5bcdd Stricter check we get dive profile
We should get either dive trailer or dive profile immediately after
header. Thus make sure that is the case.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
62d9728ebe Ignore empty dives
This is first step towards parsing "empty" dives properly. I.e. now the
updated test dive parses properly.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
b808723f9c Refactor CSV import
Move CSV import related functions into import-csv.c.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Berthold Stoeger
59526e948a Remove cloud_background_sync preferences option
The preferences flag cloud_background_sync used to be used heavily in
the mobile code, but is not used there anymore. Now, it is accessed
only in one place, but does not do what it actually says: If it is off,
the remote storage is not synced on save (but will be synced on next
load).

Syncing on save can also be prevented by unchecking the "Cloud online"
menu checkbox. Since the latter seems more logical and general
(support for non-cloud remote git repositories), remove the cloud_background_sync
option.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
fd5a521b94 Sync with any remote git repository
Sync with remote git repository, even if this isn't the cloud storage.
There seems to be no point in remote git repositories if they aren't
synced.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
b0fc718f65 Trivial: remove redundant declarations of downloadTable
downloadTable was declared twice in "dive.h". Remove one occurence.

Moreover, "uemis-downloader.c" also declared downloadTable. This can
likewise be removed, because "uemis-downloader.c" indirectly includes
"dive.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 09:21:33 +01:00
Jan Mulder
74eb7b21a8 Remove unused urls
They are unused, and a relic from earlier plans.
Just remove.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 09:21:16 +01:00
Jan Mulder
e762d2a23e core: free() in a safe way, reverse geolookup unstability
A simple one line change that solves (for me) numerous hard crashes
when adding geo tags by reverse lookup from the dive site edit
screen. This is one of those crashes that is might not be
reproducible on any platform, or even between different builds
on one platform.

This said, I found that the free() on line 99 of divesitehelpers.cpp
tried to free pointers to random data, ie. not pointing to valid
taxonomy category strings. And those pointers where simply caused by
freeing the string earlier, and leaving the pointer around. So, this
change is nothing more than setting the just freed pointer to NULL,
to allow free() to be called later safely.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-05 09:03:25 -08:00
Berthold Stoeger
c4c57b287e Increase size of name_buffer to fit any integer
In libdivecomputer.c, name_buffer is formatted with calls like
 snprintf(name_buffer, 9, "%d cuft", rounded_size);
This works fine in the regular case, but it generates compiler
warnings, since theoretically the integer might produce up to
11 digits, leading to a truncation of the string.

Increasing the size of name_buffer to 17 chars silences these
warnings. This may seem like pointless warning-silencing.
Nevertheless, in the case of invalid data, it might make debugging
easier since, in the above case, the "cuft" is never truncated.
In total, it seems that this is a benign change with potential,
though in a very unlikely case, positive effects.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-05 00:29:20 +01:00
Berthold Stoeger
90ba4e5dca Don't define cur_setting in header file
The object cur_setting was defined in core/pref.h. Instead, declare
it as extern and define it in core/parse.c. This silences a compiler
warning, since inclusion of core/pref.h would define the object, which
was then left unused in tests/testparse.cpp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-05 00:29:20 +01:00
Berthold Stoeger
5960718075 parse-xml.c: add get_bool() function
The boolean "autogroup" was parsed as an integer. In principle OK, but
let's make the type more explicit by introducing a get_bool() function.

Suggested-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Berthold Stoeger
956cb53cd5 Turn autogroup from short into bool
All users of autogroup are clearly expecting a boolean value, so
let the type reflect this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Berthold Stoeger
e414e0b334 mark_divelist_changed(): only update title if necessary
Only change the title if the changed status was updated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00