aboutsummaryrefslogtreecommitdiffstats
path: root/parse-xml.c
AgeCommit message (Collapse)Author
2015-09-08Better import of libdivecomputer universal xmlGravatar Anton Lundin
This teaches subsurface how to understand more fields in the xml that libdivecomputers's universal tool generates. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Capitalistion of GPSGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-30Fix subtle bug in dive site import from V2 fileGravatar Dirk Hohndel
Assume your V2 file contains two locations with different name but identical GPS location. "Blue Corner" and "Blue Corner, Palau". And you have many dives there. When reading a V2 file the GPS is read first and a dive site is looked up based on that. Let's assume the lookup by gps finds "Blue Corner, Palau". Now every time we get the "Blue Corner" site in the V2 file we look up the GPS, get "Blue Corner, Palau" as dive site, then read the name "Blue Corner" and say "oops, different site" and create a new one. Resulting in several dive sites named "Blue Corner" with identical GPS but different UUID (as we add the dive time into the SHA for the deterministic UUID). With this commit, if we have a dive site that matches the GPS but has a different name, we check if we happen to have an exact match for the dive site information from the XML file (and use it, if we have it) before creating a new dive site. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Make created dive site uuid deterministicGravatar Dirk Hohndel
Having random uuids seemed like a good idea, but there are several situations where they really cause problems. One is merging dive file imports from V2 logfiles. Another is testing such imports. Instead of making the uuid random we now hash the name and add the timestamp of the first dive associated with this dive site to the hash (first in this context is "first encountered" with no guarantee that it is the chronologically first). This way V2 imports create deterministic uuids but uuid conflicts are still extremely unlikely, even if the user has multiple dive sites with the same name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-09Fix bit shift on Suunto DB importGravatar Miika Turkia
Let's do the bit shift properly and not by block size. Fixes #906 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-03Divinglog import: ignore unsupported cylindersGravatar Miika Turkia
Subsurface supports currently 8 cylinders, thus we should not attempt to add more. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> 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-24Allow creating new dive site with specific uuidGravatar Miika Turkia
Test cases require deterministic results and thus we should allow uuid to be specified when needed. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-24Cobalt import: use find or create divesiteGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-24Divinglog import: find or create divesiteGravatar Miika Turkia
We obviously should lookup if the dive site already exist before creating a new one. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-23Divinglog import: fix maximum depthGravatar Miika Turkia
Max depth is recorded in floating point in metadata. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17Divinglog import: update O2sensors and dive modeGravatar Miika Turkia
This is my best guess, and I have no sample logs that would prove my assumption. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17Divinglog import: added setpointGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17Divinglog import: add cns valueGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17Divinglog import: ppo2 sensor readingsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Divinglog import: stop (deco) time addedGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Divinglog import: include NDL informationGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Divinglog import: show stop depth / ceilingGravatar Miika Turkia
This shows the ceiling as stored by Divinglog. (I am not sure if it is DC reported ceiling, or just a calculated one.) Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Divinglog import: include heartbeat infoGravatar Miika Turkia
Note, that this patch is not tested with real data as I do not have log that would include heartbeat available. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-13Fix memory handling for taxonomy dataGravatar Dirk Hohndel
The way we freed things and cleared out the variables potentially left dangling data behind and could end up calling free on garbage data, leading to random crashes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: generate gaschange eventsGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: adding pressure samplesGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: grab information for cylinder 0Gravatar Miika Turkia
Cylinder 0 is stored on the Logbook table along with other dive metadata (not in Tank table). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: use dive ID as identifierGravatar Miika Turkia
Since mapping cylinders requires use of dive ID, we might as well use the ID to map the profile also. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: get cylinder informationGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: import temperature graphGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: add workload warningGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: deco stop ignored event addedGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: ascent warning addedGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: RBT warning event addedGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: in deco?Gravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: parse depth from databaseGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: import a bit more data from DBGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12Divinglog import: basic dive info for DB importGravatar Miika Turkia
This parses the basic metadata of a dive when importing Divinglog database. (Discarding deleted dives is my best guess as I do not have that in my sample dive.) Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02More debug message cleanupGravatar Dirk Hohndel
Remove several very noise messages on dive site handling (this seems to work well now, so I think we can remove most of them - a couple were left that indicate actual issues). And also remove all the calls to "translate" when outputting data to stderr. Error messages that indicate issues where the user will basically have to come and ask the developers for help shouldn't be localized. They should be in English to make it easier for us to figure out what's going on. 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-22Do not mess with dive location automaticallyGravatar Tomaz Canabrava
This might be what the user wanted, but also might not be it. So wait for the user to request it manually. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Fix missing curly braces that change control flowGravatar Dirk Hohndel
Indentation thankfully is not the same as scope. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Prevent null dereferenceGravatar Dirk Hohndel
In each case there are scenarios where we would have dereferenced NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Fix a number of resource leaksGravatar Dirk Hohndel
Free memory returned from parse_mkvi_value() Free memory returned from printGPSCoords() Free memory allocated in added_list and removed_list Free memory allocated when adding suffix to dive site name Free memory allocated in cache_deco_state() Free memory allocated in build_filename() Free memory allocated in get_utf8() Free memory allocated in alloc_dive() Free memory allocated as cache but never used 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-17We don't really need a long to count the dive sitesGravatar Dirk Hohndel
At least I hope not. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16Remove all the no longer necessary code that aborts read of first V2 fileGravatar Dirk Hohndel
This was a poorly implemented hack when we executed the reverse geo lookup in the main thread and opening a V2 file could take a very long time. We need to do the "Welcome" message quite differently. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10Add "additional name" to the correct dive siteGravatar Dirk Hohndel
Adding the name to its own dive site was kind of silly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10When parsing V2 XML files try to be smarter when creating dive sitesGravatar Dirk Hohndel
Two "locations" from a V2 file are the same site if they have the same name AND if their GPS coordinates are within 20 meters of each other. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09Create unique dive sites when downloading from webserviceGravatar Dirk Hohndel
The Subsurface Webservice (as backend for the companion app) will usually send a lot of gps fixes encoded as dives, all with the same dive site name. When parsing the XML file it sends we need to make the dive site names unique so that we can then match them to the existing dives. The fake dives with all the dives sites will all be discarded, but without creating the unique dive sites we can't successfully add the GPS coordinates to the existing dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-02Support for changed DM5 sample blobGravatar Miika Turkia
Block size for sample is now variable, so detect the version and parse proper blocks. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28Add explicit casts to silence compiler warningsGravatar Robert C. Helling
clang complais when converting (char *) to (unsigned char *), so tell it it's fine. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-21Fix typoGravatar Paul-Erik Törrönen
Loockup -> Lookup Signed-off-by: Paul-Erik Törrönen <poltsi@777-team.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>