Commit graph

125 commits

Author SHA1 Message Date
Lubomir I. Ivanov
4096383fb5 Add subsurface_access()
For our usage the method will acept UTF-8 paths,
which are converted to UTF-16 on Win32.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-13 11:58:59 -08:00
Salvo 'LtWorf' Tomaselli
e024a5b207 Shows an error about wrong permissions
If an import fails, the permissions of the device are tested and an
error message that mentions permissions is shown to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12 14:41:27 -08:00
Dirk Hohndel
b51710c01e Remove leftover code for directly parsing Cobalt tank sizes
This should have been ripped out as part of commit 4be7604634 ("Use
libdivecomputer tank size when available").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11 01:43:20 -08:00
Dirk Hohndel
5c69f94bca Fix getting tank information from libdivecomputer
Silly type made us always get tank 0. So tanks 1 through n where wrong
(and repeating tank 0 instead).

Reported-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11 01:41:08 -08:00
Dirk Hohndel
fd997c1b15 Fix previous commit to compile with older versions of libdivecomputer
That was silly :-(

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 23:03:10 -08:00
Dirk Hohndel
4be7604634 Use libdivecomputer tank size when available
If the gasmix of a tank is not the matching gasmix in the list of
gasmixes, issue a warning (as so far we assume those are always in sync).

This patch removes our own parsing of the sizes because Subsurface 4.3
will require libdivecomputer 0.5 so this should be enabled by the time the
next release comes out, so let's just drop the redundant code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 22:26:18 -08:00
Anton Lundin
df42f78486 Add support for libdivecomputer DC_FIELD_DIVEMODE
libdivecomputer recently gained a api for telling us which mode the
divecomputer was running in, so this uses that to tell us if it was a OC
or CCR dive.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:20:38 -08:00
Anton Lundin
42d3ed0431 Move calculate_string_hash into DC_FIELD_STRING
The calculate_string_hash is only used if DC_FIELD_STRING is defined, so
this removes a warning for everybody who doesn't build against a
libdivecomputer with DC_FIELD_STRING support.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:20:04 -08:00
Dirk Hohndel
082e59ea72 Add support for libdivecomputer's new TEMPERATURE fields
Parse air temperature and water temperature if available from the dive
computer. Subsurface happily tracks the temperatures in the dive samples,
but for water temperature in the header ("overall" water temperature) we
currently support only one field. So I ordered the code so that if it is
available, the minimum water temperature will be used, absent a minimum
water temperature we use the maximum water temperature.

Side note:
Since the libdivecomputer maintainer disagrees with the Subsurface
developers regarding a sane way to allow a consumer of his library to
detect if a feature is supported in a particular commit of the library,
the way we decide whether to build this code or not is decidedly hacky.
DC_GASMIX_UNKNOWN happens to be a #define we can check that was added
right around the time the temperature support was added. Sadly there is
no #define that we could check to see if temperature fields are supported.
How insane is that...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 22:55:38 -08:00
Linus Torvalds
0a27978014 Use the new DC_FIELD_STRING callback if it exists
This recognizes recognize some strigns (serial number and firmware
version), and the ones that it doesn't recognize it adds as extra data
using Dirk's new interface.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 20:55:18 -08:00
Linus Torvalds
46809bac4f Make it possible to have samples without depth from libdivecomputer
Normally, all samples have depths associated with them, and most dive
computers likely don't even have the concept of a sample without a depth.

However, the new Suunto EON Steel definitely has samples with just time
updates (and perhaps other data, like events) and no depth at all.  We
get unhappy about that, and interpret it as having a zero depth.  Which
doesn't look very nice.

This just makes all samples default to the same depth as the previous
sample.  For normal samples with a depth value, that will just override
that default.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-20 18:10:23 -07:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Linus Torvalds
5b14ed16ac Add "download into private trip" dialog checkmark
This adds a checkbox for the divecomputer download dialog that allows you
to tell the download to put the newly downloaded dives into a trip of
their own. That in turn will disable the dive merging with any existing
dives, which means that you will not mix up your newly downloaded dives
with any old dives.

That, in turn, is very convenient of you know that some of the dives were
done by other divers (or from testing that happened during servicing etc),
or the dive dates etc were wrong because the dive computer date had reset
due to battery changes etc.

Once you have all the dives in a private trip of their own, you can then
fix them up (delete dives you don't want to merge etc), and then after all
the data is ok you might want to merge the cleaned-up results with
previous trips etc, and then manually ask subsurface to merge the dives or
whatever.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 22:40:14 -06:00
Dirk Hohndel
9d801c663f Only show libdivecomputer "unlikely gas" warning once
Fixes #696

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 06:19:31 -07:00
Dirk Hohndel
2ad433671f Use Qt date localization instead of translated strings
This gets us consistent date format everywhere. The reordering of month
name and day of the month didn't work correctly on Windows, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03 13:02:32 -07:00
Dirk Hohndel
6ab95af9ac Don't silently ignore suspcious data from libdivecomputer
Otherwise possible bugs in libdivecomputer won't get reported and fixed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 07:15:40 -07:00
Anton Lundin
692ad31ad3 Don't ignore actual diveable mixes
Fist is really obvious. I quite regularly decompress using pure O2.
It's as good a last decompression gas as you get.

The second is a bit harder. There are very few that dive with 80%+ helium
in their mixes but they exist, and there are real weirdos that dive
heliox, so they are actual diveable gases too.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 14:55:21 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Dirk Hohndel
4a1b9312f3 Don't check for tank size information only on first tank
commit d681bdcb63 ("Only use default cylinder for first one") has a
stupid bug in that it only calls get_tanksize for the first tank. That's
of course completely bogus.

Thanks to Linus for catching this.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 13:46:35 -07:00
Dirk Hohndel
d681bdcb63 Only use default cylinder for first one
When downloading from a divecomputer it makes little sense to assume that
all tanks are the default cylinder.

There's a good case to be made for having a default first cylinder (you
always dive with your own cylinder, or you are always on a dive boat with
AL80 tanks), but in multi-cylinder situations this is much more likely to
cause unintended harm; for example for those dive computers that always
report their maximum number of cylinders, even if some of them aren't
used.  Here setting a default cylinder turns those entries from obviously
empty into something that appears to have meaning (i.e., cylinder type is
filled in) even though this was just a default added by Subsurface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 13:16:03 -07:00
Dirk Hohndel
b6bbfdcc5f Avoid calling free on uninitialized dive variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-08 17:27:33 -08:00
Dirk Hohndel
8ab1fa3983 Fix memory leak when parsing a dive fails
We had all these repetitive calls to dc_parser_destroy but didn't free the
already allocated dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06 15:36:46 -08:00
Dirk Hohndel
1b103c5c69 Another small tweak to whitespace tool
clang-format doesn't appear to reindent multi line #define statements
correctly - so this hopefully will clean those up.

The included whitespace corrections to the code should stay in place when
using the updated tool.

This includes cleaning up some multi-line comments that were messed up the
last time around as well as a few other minor changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05 13:02:23 -08:00
Dirk Hohndel
d24d2288f3 Remove pointless assignments
tissue_tolerance wasn't used after it was assigned.
type was overwritten after it was assigned.
serial was overwritten after the last /= 100.
event is assigned in the for loop.
clear isn't used after the assignment

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 21:40:56 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Danilo Cesar Lemes de Paula
0e6d893dae set the download progress bar to zero after a download
Before that, the behaviour was that in case of an error or a
re-download, the progress bar would appear for a few milliseconds with
the old value.

Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26 09:00:19 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Linus Torvalds
7ae05b4f71 Fix default value for missing surface pressure from divecomputer
We should *not* default to the incorrect "1 bar".  Instead, we should
leave the resuling pressure at 0 mbar, which leaves visual entries empty
and uses the default surface pressure for calculations.

Reported-by: Pedro Neves <nevesdiver@gmail.com>
Cc: Patrick Valsecchi <patrick@thus.ch>
Cc: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:46 -08:00
Linus Torvalds
22f66501ac Add support for heartrate and bearing information in samples
libdivecomputer already supports this, but we didn't save it.

Tested-by: Oscar Isoz <jan.oscar.isoz@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:03:24 -08:00
Dirk Hohndel
eac2642f8e Fix the semantics of the dive_cb
Libdivecomputer wants us to return true if it should continue to loop over
the dives and false if we want to stop. Don't pass errors back.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 11:42:19 -08:00
Anton Lundin
33391a77e9 Convert the C code to using stdbool and true/false
Earlier we converted the C++ code to using true/false, and this converts
the C code to using the same style.

We already depended on stdbool.h in subsurfacestartup.[ch], and we build
with -std=gnu99 so nobody could build subsurface without a c99 compiler.

[Dirk Hohndel: small change suggested by Thiago Macieira: don't include
               stdbool.h for C++]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:34:50 +07:00
Jef Driesen
58f6a01a22 Write the event data to the libdivecomputer log.
For some devices, the event data contains important data that is
required for parsing the dives, but which is not present in the full
memory dump.

Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:42 +08:00
Lubomir I. Ivanov
4d8168cc57 libdivecomputer.c: Try not to pass NULL to fopen()
C99 7.1.4, says nothing about passing NULL to fopen(),
which means that it isn't portable and there are no guaranties
that the return will be a NULL pointer or that that a library
implementation will not assert or SYSSEGV in the middle of the
fopen() branch.

libdivecomputer.c's 'dumpfile_name' and 'logfile_name' could
cause problems in that regard.

A possible fix for #411

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 05:53:05 +08:00
Dirk Hohndel
d42cc5a40c Enable libdivecomputer log or dump from the UI
Pick filenames for these functions as they are selected.
Use the windows-safe fopen function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 16:26:00 -08:00
Jef Driesen
ca1947f3cf Support downloading memory dumps.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 09:57:14 -08:00
Jef Driesen
60d85de292 Enable diagnostic logging from libdivecomputer.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 09:57:10 -08:00
Jef Driesen
badce21b24 Remove an unnecessary function call.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24 09:57:04 -08:00
Anton Lundin
0812d2def2 Add some sanity checks
If first sample is not a DC_SAMPLE_TIME, we would have bin dereferencing
a null pointer.
This might actually never happen, unless we talk to a really weird dc,
but this makes the static analyzer happier.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 03:13:30 +01:00
Dirk Hohndel
6a579dc9c0 Add comment for "below floor" event
This one is a tough one for translators.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-29 11:27:41 -08:00
Anton Lundin
3fd39a7a87 Remove some constants and use helpers instead
We have allot of helpers, use them instead of local variants.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27 08:30:12 -08:00
Dirk Hohndel
03a0678b00 Use a default tank when populating tank data after download
This is super-simplistic and also is kinda wrong. It forces all tanks that
haven't been specified by the DC (so far only Atomics Aquatics Cobalt and
UEMIS Zurich (which doesn't even use libdivecomputer) to be AL80. Just as
we used AL80 as default for manually adding tanks.

Obviously this needs to become an option where the user can pick.

See #145

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-23 22:00:39 -08:00
Dirk Hohndel
193d20c479 Next step towards working translations
This may seem like a really odd change - but with this change the Qt tools
can correctly parse the C files (and qt-gui.cpp) and get the context for
the translatable strings right.

It's not super-pretty (I'll admit that _("string literal") is much easier
on the eye than translate("gettextFromC", "string literal") ) but I think
this will be the price of success.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 22:51:59 -07:00
Patrick Valsecchi
a13992a44b Fixed conversion error when downloading salinity from DC
libdivecomputer doesn't give the salinity in kg/l, but in g/l and
subsurface works with g/10l. So the salinity was too big by a factor
of 1000.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08 06:16:06 -07:00
Dirk Hohndel
34db6dc2be Delete code and files that are no longer used
Most of this is Gtk related, some of it is helpers that we don't need
anymore. I love the diffstat.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 17:32:50 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00
Patrick Valsecchi
b79a8ec386 Importing salinity and atmospheric pressure from DC.
One cannot expect #ifdef to work with enum values. So the code for
getting the salinity was basically never compiled in. And it was
putting it in the wrong location anyway (in the dive struct instead
of the divecomputer struct where it is expected).

I took the opportunity to add the reading of the atmospheric pressure
as well.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 09:40:45 -07:00
Michael Andreen
169d9e9c01 Identify below floor event type properly.
This event is on when accumulating deco time. Once you reach the floor
deco time will start decreasing and the event will stop. Going below the
floor again will re-activate the event.

Also identify event type 13 in DM4 imports as airtime.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-19 13:31:31 -05:00
Anton Lundin
89cb73cb2f ifdef out includes when we build without gtk
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-07 22:22:50 +02:00
Dirk Hohndel
29b242c703 Converting the device_info list into a Qt data structure
This data structure was quite fragile and made 'undo' when editing
rather hard to implement. So instead I decided to turn this into a
QMultiMap which seemed like the ideal data structure for it.

This map holds all the dive computer related data indexed by the model. As
QMultiMap it allows multiple entries per key (model string) and
disambiguates between them with the deviceId.

This commit turned out much larger than I wanted. But I didn't manage to
find a clean way to break it up and make the pieces make sense.

So this brings back the Ok / Cancel button for the dive computer edit
dialog. And it makes those two buttons actually do the right thing (which
is what started this whole process). For this to work we simply copy the
map to a working copy and do all edits on that one - and then copy that
over the 'real' map when we accept the changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 00:24:28 -07:00