summaryrefslogtreecommitdiffstats
path: root/save-xml.c
AgeCommit message (Collapse)Author
2015-10-08Ignore geolookups without valueGravatar Miika Turkia
It seems that geolookups might return null for some values. This will result in corrupted XML as show_utf8 does not terminate the current tag if t->value is empty. So let's just skip the geo data that is missing the value. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04Print paths to internal files in verbose modeGravatar Robert C. Helling
When run with -v option, this prints local file names like the path to the local git repository and the hash file. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04Dive_sites-Notes shouldn't be stored as attributeGravatar Salvador Cuñat
If so, some formatting chars (like "\n") will be dropped while parsing. This could be pretty annoying for a user who tries to keep notes other than a simple text, e.g. if the site is a wreck, may be interesting to have some data shown like: ... Max. Depth = 60 m Min. Depth = 40 m Prow: bla, bla, bla. Stern: bla, bla, bla. ... instead of a single text line. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> ACKed-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-28Don't save unused, auto-create dive sitesGravatar Dirk Hohndel
Normally the auto-created sites that are used when downloading GPS data from the webservice that aren't associated with a dive will immediately discarded. But if such a site is used for a dive but then the user changes their mind and uses another site for that dive (for example because they had a previous dive at that spot and decided they liked that one better after all), then the dive site can stick around as an orphan. Having orphan dive site may make sense for named dive sites that for some reason are no longer used but may be used again in the future, but having an auto-named orphaned dive site in the data file seems silly. So let's remove them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-08Only store dive site uuid in dive if the dive site existsGravatar Dirk Hohndel
Don't store stale uuids. As a side effect this makes it easy to remove dive sites from the XML file (or the git repository) when duplicates have been added for some reason and the user wants to restart from scratch. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Save XML: sort the dive sites by uuidGravatar Dirk Hohndel
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-20Always save taxonomy data, even if disabled in the prefsGravatar Dirk Hohndel
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-07-30RBT - Add save/load in xml file supportGravatar Salvador Cuñat
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15Add helper function that checks if a dive site is in useGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02Rename enum values for taxonomyGravatar Dirk Hohndel
This avoids confusion and namespace collisions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01Geo taxonomy: save and load the taxonomy data with XMLGravatar Dirk Hohndel
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-06-21Move helper declarations into a better header fileGravatar Dirk Hohndel
This way the helpers can be more easily used by other modules. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Track minimum datafile versionGravatar Dirk Hohndel
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-13Move git related declarations into their own header fileGravatar Dirk Hohndel
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-12Cloud storage: sync the remote after saveGravatar Dirk Hohndel
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-10When saving only selected dives, only include referenced dive computersGravatar Dirk Hohndel
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-10When saving only selected dives, only include referenced dive sitesGravatar Dirk Hohndel
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-05-31Add strndup.h header so we can use this useful functionGravatar Dirk Hohndel
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-04-28Rename helper function and make it globalGravatar Dirk Hohndel
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-02-27Add hashes to imagesGravatar Robert C. Helling
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-17Quote tags as attributesGravatar Miika Turkia
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-15Get rid of double space after uuid in ssrf fileGravatar Henrik Brautaset Aronsen
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Don't store empty dive sitesGravatar Dirk Hohndel
And remove references to them from the dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Make special backup when switching XML versionsGravatar Dirk Hohndel
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-12Save and parse dive site structures to XMLGravatar Dirk Hohndel
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-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... 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-02git save format: Don't save redunant temperature sample dataGravatar Linus Torvalds
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 6cf3787a0ed1 ("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>
2014-12-31Use unit selection for XSL transformation on CSV exportGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-21Add second CSV export with dive detailsGravatar Dirk Hohndel
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-09Quote picture file names when saving XMLGravatar Miika Turkia
Fixes #775 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21Save-XML: Correct bug in cylinder gas parametersGravatar Willem Ferguson
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-20Prevent garbage from being saved in the userid fieldGravatar Dirk Hohndel
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-18Fix issues in CCR handlingGravatar willem ferguson
In commit 0d7c192e6edc ("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-17For CCR dives, the diluent cylinder is the current cylinderGravatar Robert C. Helling
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-16Load and save the dc type for CCR divesGravatar Dirk Hohndel
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-16Save CCR cylinder use in XML and gitGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15Revert "Save cylinder pressure from samples"Gravatar Dirk Hohndel
This reverts commit 763dfef31573fdda9c5a4e26cb3446f53f704fea. I didn't pay enough attention when accepting this - it saves redundant data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15Save the diluent pressures to XMLGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-15Save cylinder pressure from samplesGravatar Miika Turkia
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-07Load and save extra data in Subsurface XML formatGravatar Dirk Hohndel
Includes test dive to test missing attributes and the overall syntax. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19Make planner work again for CCR divesGravatar Robert C. Helling
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-12Start sanitizing gaschange event informationGravatar Linus Torvalds
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-07-16Suppress XML preamble in CSV exportGravatar Sergey Starosek
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-10Don't trust isspace() unless isascii() approvesGravatar Anton Lundin
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-09Add support divecomputer based TTSGravatar Anton Lundin
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-08Fix picture loadingGravatar Dirk Hohndel
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-06-09Picture handling: switch to stronger typed offsetGravatar Dirk Hohndel
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-08Picture handling: change data structure to store offset instead timestampGravatar Dirk Hohndel
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-08Save the timestamp of the dive.Gravatar Tomaz Canabrava
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-06HTML: Better quoting to the export stringsGravatar Gehad elrobey
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>