Commit graph

167 commits

Author SHA1 Message Date
Dirk Hohndel
420afeef57 Save XML: sort the dive sites by uuid
This makes it much easier to compare XML files written by Subsurface.
The order of the dive_site_table depended on the order in which they were
encountered. This makes it easier to eye-ball changes in XML files. And
allows the GitStorage test to pass.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:52 -07:00
Dirk Hohndel
a081ffe48e Always save taxonomy data, even if disabled in the prefs
Otherwise, if one of the systems used with cloud storage doesn't have the
preference for geo encoding enabled, the taxonomy data will be lost.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 11:05:07 -07:00
Salvador Cuñat
25f3038d40 RBT - Add save/load in xml file support
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30 07:43:16 -07:00
Dirk Hohndel
1dbb6071bd Add helper function that checks if a dive site is in use
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15 21:25:26 -07:00
Dirk Hohndel
bc8c54f1ee Rename enum values for taxonomy
This avoids confusion and namespace collisions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:22:31 -07:00
Dirk Hohndel
f7b7d4c2df Geo taxonomy: save and load the taxonomy data with XML
If taxonomy data are available we are switching a dive site entry from
single item with attributes to an item that has children. This is
backwards compatible and older versions will simply ignore the children.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 12:38:40 -07:00
Dirk Hohndel
b27538feba Move helper declarations into a better header file
This way the helpers can be more easily used by other modules.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 07:45:22 -07:00
Dirk Hohndel
de35c88683 Track minimum datafile version
Add infrastructure and helper functions to track minimum datafile version.
To make this information useful we need to keep the XML and git data
format versions in track moving forward.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 06:45:12 -07:00
Dirk Hohndel
9a22efb97b Move git related declarations into their own header file
Also change the name of the enum and make sure all the inner functions get
passed the remote transport information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
e21cae2d46 Cloud storage: sync the remote after save
This change once again tests if the remote can be reached. Even with a
fairly big data file and a medium speed internet connection the remote
sync is fast enough to call it nearly instantaneous. Maybe a couple of
seconds.

We may need more checks / different heuristics / warnings if the sync
didn't happen, etc. But for now this should allow more reasonable testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 13:56:23 -07:00
Dirk Hohndel
1ee447b5a9 When saving only selected dives, only include referenced dive computers
Since we should have far fewer dive computers than dives this straight
forward algorithm shouldn't cause any performance issues.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 09:29:04 -07:00
Dirk Hohndel
2365531c68 When saving only selected dives, only include referenced dive sites
The algorithm seems rather brute force; basically quadratic in the number
of dives, assuming we have about the same number of dive sites as dives
which seems a reasonable assumotion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 09:28:40 -07:00
Dirk Hohndel
e84d8624bb Add strndup.h header so we can use this useful function
It's missing on Windows... we had this helper in liquivision.c but since I
used the function in git-access.c I figured I should just turn it into a
little helper.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31 23:14:56 -07:00
Dirk Hohndel
f4677d7604 Rename helper function and make it global
save_one_dive_to_mb() is very useful (but there was a namespace collision
with another helper in save_git.c)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-28 11:27:36 -07:00
Robert C. Helling
b02bf002a6 Add hashes to images
Upon successfull reading an image file, this computes a SHA1 hash of the
image and saves it with the picture tag in the log file. When a file is
not successfully loaded (for example because the log was created on a
different computer) we look up the hash in a dictionary that maps hashes
to local file names.

That dictionary (actually two for both directions), is loaded on startup
and saved upon destruction of the main window.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27 06:29:44 +01:00
Miika Turkia
3580c546db Quote tags as attributes
We need to quote the tick char (') on tags as this is used as XML
attribute.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-17 14:07:15 -08:00
Henrik Brautaset Aronsen
b84c885a94 Get rid of double space after uuid in ssrf file
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15 06:01:22 -08:00
Dirk Hohndel
6820b13bd5 Don't store empty dive sites
And remove references to them from the dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 23:22:40 -08:00
Dirk Hohndel
d4f2b72148 Make special backup when switching XML versions
Since the last few dozen commits change the format in irreversible ways
and could therefore be destructive and lose data for testers of the
development version, let's try to be extra careful and create "special"
backup files that aren't overwritten by subsequent backups. At least this
way people can go back to the previous state.

Of course people using the git backend don't have to worry about this as
they always can go back to any earlier save.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 23:35:52 -08:00
Dirk Hohndel
4b15b9dfe9 Save and parse dive site structures to XML
Read and write divesite sections in the XML file.

Read divelogs of version 2 and create dive site structures on the fly.
Read version 3 files that have divesiteid instead of location / gps.

Saves version 3 files where dives no longer have location and gps but
instead refer to a divesiteid

The commit contains quite a few fprintf(stderr,...) in order to allow
better monitoring of the parsing / transforming of locations and gps to
dive sites. This will need to be removed later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Linus Torvalds
ddd0523bb4 git save format: Don't save redunant temperature sample data
The git sample loader will fill in temperature data from the previous
entry anyway, so saving repeated temperatures is just wasteful.

It turns out that commit 6cf3787a0e ("Remove code that zeroes out
duplicate oxygen sensor and temperature values") removed the explicit
redundant temperature removal in the dive fixup, which had hidden this
issue.

Cc: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-02 22:39:17 -08:00
Miika Turkia
5d68c7d4a1 Use unit selection for XSL transformation on CSV export
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31 12:12:20 -08:00
Dirk Hohndel
74f5842f0c Add second CSV export with dive details
This is intended to export all the details that someone might copy from a
paper logbook. We need a matching import template to make this simple.

This hasn't been well tested, I'm sure it will break when elements and
attributes are missing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-21 21:51:54 -08:00
Miika Turkia
6ef011a0f6 Quote picture file names when saving XML
Fixes #775

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-09 11:10:39 -07:00
Willem Ferguson
27d19b605b Save-XML: Correct bug in cylinder gas parameters
Correct a bug that I introduced previously.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>

From 45570d66ecf238aec8997f5d0c20c01dfe0aa4fa Mon Sep 17 00:00:00 2001
From: willem ferguson <willemferguson@zoology.up.ac.za>
Date: Fri, 21 Nov 2014 14:59:14 +0200
Subject: [PATCH] Save-XML: Correct bug in cylinder gas parameters

Correct a bug that I introduced previously

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 07:31:22 -08:00
Dirk Hohndel
2f7a7f3e6a Prevent garbage from being saved in the userid field
It seems that in some scenarios we end up with a string that isn't NUL
terminated and that results in garbage being stored as userid. This patch
is a little brute force but it fixes the problem even if a previous
version os Subsurface ended up adding other text to the end of the userid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 14:30:44 -08:00
willem ferguson
514a0e582a Fix issues in CCR handling
In commit 0d7c192e6e ("For CCR dives, the diluent cylinder is the
current cylinder") a few things got broken. This tries to undo those
changes and adds expanded XML output.

1) Calculate correct partial pressure of oxygen to be plotted on
   dive profile, taking into account the oxygen sensor data.
   Currently, erroneously, OC PO2 values are shown, due to an
   erroneous calling parameter to fill_pressures().
2) Read start and end cylinder pressured correctly.  some wrong
   assignments were done in file.c. This is now corrected and the correct
   cylinder pressures are shown in the equipment tab.
3) Write correct cylinder pressures to XML. Currently the data for
   the two cylinders are written to XML the wrong way round
   (diluent pressures = oxygen and vice versa).
4) Expand XML output:
   a) Write oxygen sensor data to XML
   b) Write no_of_02sensors to XML

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 08:57:21 +00:00
Robert C. Helling
0d7c192e6e For CCR dives, the diluent cylinder is the current cylinder
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the
diluent cylinder (rather than the O2 cylinder). This eliminates special
cases. Now, for CCR, we have to handle the O2 cylinder in addition
(rather than the diluent in addition).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 11:45:06 +00:00
Dirk Hohndel
23304f69c0 Load and save the dc type for CCR dives
Oddly we already had code to load this from XML, but nothing else.
This makes the load from XML work like the rest of our code and adds the
save to XML plus the load and save for the git format.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 23:20:39 +00:00
Dirk Hohndel
202c5cbfeb Save CCR cylinder use in XML and git
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 22:13:12 +00:00
Dirk Hohndel
d84f76ae14 Revert "Save cylinder pressure from samples"
This reverts commit 763dfef315.

I didn't pay enough attention when accepting this - it saves redundant
data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 09:40:53 -08:00
Miika Turkia
744e14b450 Save the diluent pressures to XML
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 06:04:58 -08:00
Miika Turkia
763dfef315 Save cylinder pressure from samples
If start and end cylinder pressure is not explicitly set for secondary
cylinders, we must store the start and end pressures from the
sample_{start,end} attribute. Faulty behavior is obvious at least when
importing Poseidon logs.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15 06:04:40 -08:00
Dirk Hohndel
d6b4109409 Load and save extra data in Subsurface XML format
Includes test dive to test missing attributes and the overall syntax.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 12:59:15 -08: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
df4e26c875 Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:45:37 -04:00
Sergey Starosek
b87a602265 Suppress XML preamble in CSV export
To obey <xsl:output omit-xml-declaration="yes"/> element
one should rely on libxslt to do its job instead of writing
document himself.

Discussion on this subject can be found at
http://comments.gmane.org/gmane.comp.gnome.lib.xslt/3839

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 09:14:27 -07:00
Anton Lundin
6b4dd8d597 Don't trust isspace() unless isascii() approves
We have seen isspace(0xC3) return true on windows so we need to do
something about this.

As a wise man said:
Using "isspace()" and friends on anything but the 0-127 range is just
fraught with danger, regardless of platform.

We remedy this by checking that isascii() says that its a 7-bit ascii
character, something isspace() knows how to handle

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 12:44:51 -07:00
Anton Lundin
848a5352c7 Add support divecomputer based TTS
Since earlier have we had support for our own calculated TTS. This adds
support for holding TTS values reported by a dive computer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 13:22:00 -07:00
Dirk Hohndel
f297d9f91e Fix picture loading
Signed vs unsigned comparisons are such a pain. Since we want offsets to
be +/- 30 minutes around the dive we need to allow negative offsets - but
duration_t was defined as uint32_t.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-08 12:29:06 -07:00
Dirk Hohndel
a26719c541 Picture handling: switch to stronger typed offset
Also change the on file XML to be even easier to read by making it a
duration as well (which gets us '32:34 min' instead of un-typed seconds).
This is backwards compatible, it will happily read what was written with
the previous commit).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 09:38:50 -07:00
Dirk Hohndel
1604299a5b Picture handling: change data structure to store offset instead timestamp
It makes no sense to store a 64bit time stamp with every picture. Even the
32bit offset (in seconds) from the dive start is WAY overkill. But
switching to that makes the code much more simple in a number of spots.
And makes what is saved to the XML file easier to read, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 17:17:49 -07:00
Tomaz Canabrava
0b5e1f700d Save the timestamp of the dive.
Save the timestamp of the dive if it exists in the data provided
by the exif library.

[Dirk Hohndel: fixed whitespace and format specifier]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 12:42:22 -07:00
Gehad elrobey
464a611d8d HTML: Better quoting to the export strings
Move the quote function to membuffer.c and adding wrappers that call
it from both xml and html exporters to get rid of redundancy.

Quote the location, buddy, suit, tags and notes This
prevents js code from crashing.

[Miika Turkia: minor whitespace and code fix]

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-06 10:08:09 -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
Tomaz Canabrava
58f2613dae Add photo saving for the XML backend.
This code correctly saves the added pictures on the xml backend.
next: git backend.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:38:36 -07:00
Anton Lundin
05d9cc409c Migrate code to for_each_dive and for_each_dc
[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
	       use for_each_dive (and use it correctly)") so I took the
	       pieces that I had missed]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 11:51:40 +09:00
Anton Lundin
84414baece Rewrite show_location to use membuffer primitives
This simplifies the logic and doesn't rely on show_utf8 to print empty
blocks.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 12:25:32 -07:00
Dirk Hohndel
a0a25554a7 Manually implement strndup
Mac and Windows don't appear to have that function, so just implement the
poor man's version by hand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 09:28:26 -07:00