summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
AgeCommit message (Collapse)Author
2013-03-26Check if DLD contains non-ascii charactersGravatar Miika Turkia
Valid divelogs.de export might contain non-ascii characters in CDATA fields as long as these characters are found in iso-8859-1. So we'll have to test to make sure the content is fully ascii before calling xmlStringLenDecodeEntities to decode possible character references. Acked-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18Generate heading event on DM4 importGravatar Miika Turkia
Previously the heading information was on bookmark event, but now we trigger a heading event when direction info is available. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-17Terminate decode at end of string and fix mem leakGravatar Miika Turkia
Seems that we have to NULL terminate the buffer for xmlStringLenDecodeEntitites() as otherwise we might end up having extra data at the end of returned buffer. (Somehow the length parameter is not respected always, even if it is the proper size returned by the zip_fread() - header_skip). Also free the buffer returned by xmlStringLenDecodeEntitites(). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-15Support divelogs.de exports that include Cyrillic charactersGravatar Miika Turkia
divelogs.de sends us XML files that explicitly state that they are in ISO-8859-1 encoding (which is true). These files contain the HTML encoded Cyrillic characters. Once we decode those characters the resulting file is actually UTF-8 encoded (which is a superset of ISO-8859-1). That seriously confuses libxml when it tries to parse things. So instead recognize divelogs.de files and skip the encoding declaration for them before decoding the HTML encoded non-ISO-8859-1 characters. This does show, however, that divelogs.de incorrectly truncates the encoded strings (at least in some sample data that I created the parsing throws errors because of that). Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Based-on-code-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-10.DLD generation for uploading to divelogs.deGravatar Miika Turkia
This generates a .DLD file of selected dives to be uploaded to divelogs.de. The actual upload functionality along with sensible user interface is still to be implemented. However, the resulting file from this patch is tested to work (as far as I can tell) using upload API of divelogs.de. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-08Use information from proper table on DM4 importGravatar Miika Turkia
Seems that DM4 has useless cylinder size data on global level and real data on DiveMixture table. So using the correct data instead of the global un-used value. Similarly the DiveMixture table contains cylinder pressures. However, it appears this information is available on DiveMixture table only in some cases. So we use start and end pressures from DM table if available, otherwise we use the global pressures. (My guess is that the DM table has the pressure info only when the pressure has dropped from the initial pressure reading that is reported in Dive table before the dive is considered to have started.) Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-08Sanity check on temperature valuesGravatar Dirk Hohndel
The range is still very wide (as we get both air and water temperatures), but it will at least eliminate some completely bogus outliers. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-08Warn about commas in floating point valuesGravatar Linus Torvalds
Localization could be causing floating point numbers to have a comma instead of a decimal point (in a file format that is really stupid). If we detect this we replace the comma with a decimal point instead, and try to re-parse the number, and see if we get further. The downside of that is that we're changing the buffer we get passed in. Nobody cares, but still, it's kind of ugly. It's simple, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-07Fix potentially broken white space truncation on certain Windows versionsGravatar Lubomir I. Ivanov
Testing the Planner in Subsurface on a Windows XP SP3 installation, shows corrupted UTF-8 strings in the case of Cyrillic locales, but possibly others as well. Instead limited to the Planner, this affects the entire application. After some examination it appears that <ctype>'s isspace() in MSVC on the tested version of Windows is broken for some UTF-8 characters, after enabling the user locale using: setlocale(LC_ALL, ""); For example, characters such as the Cyrillic capital "BE" are defined as: 0xD091, where isspace() for the first byte returns 0x08, which is the bytemask for C1_SPACE and the character is treated as space. After a byte is treated as space, it is usually discarded from a UTF-8 character/string, where if only one byte left, corrupting the entire string. In Subsurface, usages of string trimming are present in multiple locations, so to make this work try to use GLib's g_ascii_isspace(), which is a locale agnostic version of isspace(). Affected versions of Windows could be everything up to XP SP3, but not apparently Vista. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-07DM4 import pressure detection fixGravatar Miika Turkia
Seems that the database can contain either null or empty string when there is no pressure data available. Changing the pressureblob validation to reflect this new information. Since the temperature profile is binary data, we most likely should accept 0 as a valid value. My samples have null in this blob if there is no data so it seems to be different than the pressure blob. But of course there are no guarantees... Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-07More events from Suunto DM4 addedGravatar Miika Turkia
I got a few more events from a new sample database. Bookmark heading is now shown if such information is stored. Also the unknown events display the event number for easier identification. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-04Limited support for Suunto DM4 importGravatar Miika Turkia
Basic functionality is implemented but at least support for multiple cylinders is missing. Event/alarm support is only partial. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03Try to capture some more potential buffer overflows caused by localizationGravatar Dirk Hohndel
A couple of these could clearly cause a crash just like the one fixed by commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in size_data_funct()"). One would append user input to fixed length buffer without checking. We were hardcoding the (correct) max path length in macos.c - replaced by the actual OS constant. But the vast majority are just extremely generous guesses how long localized strings could possibly be. Yes, this commit is likely leaning towards overkill. But we have now been bitten by buffer overflow crashes twice that were caused by localization, so I tried to go through all of the code and identify every possible buffer that could be affected by this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26UDCF importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26Test divesGravatar Miika Turkia
On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25parse-xml.c: add parsing for DivingLog divetime and depthavgGravatar Dirk Hohndel
I have a sample file where the time is given as minutes.seconds instead of minutes:seconds. Fixes #69 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25Fix GPS import from divinglogGravatar Miika Turkia
Ticket #63 - divinglog 5.08 import issues This patch will include the GPS coordinates from divinglog. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25Mark some strings for translationGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24XSLT for UDDF importGravatar Miika Turkia
This XSLT imports the UDDF logs that I have received samples of. This includes kenzooid and Heinrichs Weikamp's DR5. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-22Flesh out the UDDF xml parsing a bit moreGravatar Linus Torvalds
Commit 28aba5a2062c ("Flesh out the UDDF xml parsing a bit more") improved on parsing UDDF files by teaching "percent()" to also handle pure fractions like UDDF uses. So in a UDDF file, an o2 value of "1.0" means "100%". But it turns out that I have a few dives with "1% He", and the "Turn fractions into percent" logic also turns that into 100%. So this makes the 'percent()' function a bit smarter. If it actually finds a percentage-sign after the number, it knows it is already percent, not a fraction. That disambiguates the two cases: "1.0" is 100%, but "1.0%" (note the explicit percentage sign) is 1%. So now our native format cannot get confused, because it generally tries to avoid naked numbers. Good choice. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-22Add correct XSLT search path for WindowsGravatar Dirk Hohndel
And report error if XSLT stylesheet not found Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-22Flesh out the UDDF xml parsing a bit moreGravatar Linus Torvalds
This uses the example UDDF file from Jan Schubert's Heinrichs Weikamp DR5 dives, and now parses the dive dates, the cylinder mixes and the gas switch events correctly (or at least partially). It's not perfect: the gas mix has an "id" field that we ignore, and instead we just depend on the cylinders being in order (which they seem to be). And I have rather limited test-cases, so maybe something else is messed up too. But for the six example dives I have, this gives reasonable data. Test-data-by: Jan Schubert <Jan.Schubert@gmx.li> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20parse-xml.c: fixed a small memory leak related to xmlGetProp()Gravatar Lubomir I. Ivanov
test_xslt_transforms(): xmlGetProp uses strdup(), so we have to clear the memory if a pointer is returned. xmlFree() doesn't seem very portable (strangly enought), so we use free(..) directly. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20Import divelogs.deGravatar Miika Turkia
This XSLT converts divelogs.de logs into Subsurface format. Data that is discarded: weather, water visibility, boat name. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-14Better handling of manually edited air temperatureGravatar Dirk Hohndel
We now load and save this in the XML file, we do the right thing when merging dives and show the edited air temperature in the Dive Info notebook when a divecomputer doesn't have an air temperature. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08Skip XSL transformation for old Subsurface formatGravatar Miika Turkia
Making sure the XSL transformation does not occur on Subsurface's old XML format. A deeper inspection on the XML content is required as MacDive and Subsurface (old format) have the same root element (dives). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07Import MacDive divelogsGravatar Miika Turkia
This XSLT converts MacDive logs into Subsurface format. It supports both the current version and the upcoming version of the log format. Conversion was not tested with Imperial units as no samples were available of such logs. Thus functionality with Imperial units is not guaranteed. Note that the gear inventory is currently discarded. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-01Recognize O2 percentage from MacDive importGravatar Henrik Brautaset Aronsen
MacDive use "o2percent" in its XML export Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-31Allow using two different tables to hold dives and gps locationsGravatar Dirk Hohndel
This only changes the infrastructure and actually loses functionality as it no longer does the simplistic "just treat the locations as dives and merge them". The new code that does something "smart" with the gps_location_table is yet to be written. But now we can use the XML parser to put the gps locations downloaded from the webservice into their own data structure. In the process I noticed that we never used the two delete functions in parse-xml.c and removed them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Make sure imported rating and visibility are within limits.Gravatar Henrik Brautaset Aronsen
The "visibility" value in MacDive XML files could be a random string, while it's a value of 0-5 in Subsurface. Importing an illegal value (such as "11m") resulted in a segfault from libpangocairo and an "Invalid UTF-8 string passed to pango_layout_set_text()". [Dirk Hohndel: fixed int * vs. int issue] Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28parse-xml: allow XML nodes with empty tag namesGravatar Linus Torvalds
They happen for CDATA content, where libxml2 turns the CDATA fields into a child of the parent entry, but without a name. Now, of course, any sane person would just want to use the CDATA as the string value of the parent itself, but libxml2 probably does this insanity for a reason. And the reason is probably that some misguided people want to *write* XML using libxml2, and then the stupid child node actually acts as a "now I want you to write this data as CDATA". Whatever the reason, let's just ignore it. We will just traverse such a nameless child and be happy, and we'll give the nameless child the name of the parent. Our XML node matching logic will then never see this insane nameless child at all, and doesn't have to care. Our whole XML parsing rule-of-thumb is to take the whole "be strict in what you output, but generous in what you accept" to its logical conclusion. Because we will literally accept almost anything, in any format. You can mix tags or attributes wildly, and youc an use CDATA or not as you see fit. We just don't care. We're the honeybadger of the divelog world. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28xml-parsing: accept 'sitelat' and 'sitelon' for GPS coordinatesGravatar Linus Torvalds
Are they ugly and insane tags? Yes. Are they used? Bingo. MacDive uses this lovely format for specifying dive site location. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28Be even more permissive in our date parsing logicGravatar Linus Torvalds
Not that we aren't already insanely permissive in parsing just about any random noise that could _possibly_ be construed as xml and turn it into a dive, this makes us even laxer. If somebody wants to have a <date> tag with both date and time, why the heck not? It's fine. And if it has just the date, that's fine too. And the date can be in any of several formats. We really don't care, the more permissive, the better. We strive to always write beautiful xml, but let's face it, not everybody else does. If we can turn random line noise into a dive, we should do so. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25Remove some unnecessary variable initializationsGravatar Dirk Hohndel
Not really bugs, just wasted. They clutter up the output of static analysis with cppcheck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Centralization for Kelvin and Standardization to milliKelvinGravatar Jan Schubert
This centralizes all occurrences of Kelvin to dive.h and standardizes all usages to milliKelvin. [Dirk Hohndel: renamed the constant plus minor white space cleanup] Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Slight change to the parser to avoid false posititivesGravatar Dirk Hohndel
The webservice output uses 'name' as the tag for the dive location. This was added to the parser as unqualified tag and without this change test24.xml was suddenly recognized as a dive (the parser was triggering on the program 'name' attribute). Name should only be recognized as a dive location if it is indeed a child of dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Remove saving of dive computer nicnames in system configGravatar Linus Torvalds
We save the (more complete) dive computer information in the XML file with serial numbers and firmware version if we know about them, so using a complicated string in the system config was redundant and confusing. So remove that code. NOTE! Since the dive computer nicknames are now only saved if the XML file is saved, we also mark the dive list "changed" when we edit the nicknames. That way we'll be prompted to save things before exiting, even if we don't actually edit any actual dive data. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Merge branch 'webservice-import'Gravatar Dirk Hohndel
Update maxdepth / duration that have moved into the divecomputer structure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Remove XML parsing special case temperature codeGravatar Linus Torvalds
We had various hacky historical artifacts in our XML parsing, partly from our legacy of parsing integer and floating point data separately (we used to recognize certain import format differences based on whether the data was in a floating point or integer format). And partly from trying to do a good job of importing crap from other dive log software. Anyway, that actually meant that we refused to parse negative numbers, and we ignored temperatures of zero because some diving log would do that for missing values. Both of these actually bit us when parsing our native XML. Of course, only crazy ice divers would ever notice. Noticed by Henrik Brautaset Aronsen. Reported-acked-and-tested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Move more dive computer filled data to the divecomputer structureGravatar Linus Torvalds
This moves the fields 'duration', 'surfacetime', 'maxdepth', 'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure' to the per-divecomputer data structure. They are filled in by the dive computer, and normally not edited. NOTE! All actual *use* of this data was then changed from dive->field to dive->dc.field programmatically with a shell-script and sed, and the result then edited for details. So while the XML save and restore code has been updated, all the displaying etc will currently always just show the first dive computer entry. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Import and merge GPS data from the webserviceGravatar Dirk Hohndel
Dive locations marked (and named) via the companion app are downloaded from the webservice, parsed and merged with the existing dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18Fix potential crash with old XML filesGravatar Dirk Hohndel
A file with no divecomputer section in a dive can trigger a SEGV as cur_dc could be NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-14Centralising and redefining values as integersGravatar Jan Schubert
This patch centralizes the definition for surface pressure, oxygen in air, (re)defines all such values as plain integers and adapts calculations. It eliminates 11 (!) occurrences of definitions for surface pressure and also a few for oxygen in air. It also rewrites the calculation for EAD, END and EADD using the new definitons, harmonizing it for OC and CC and fixes a bug for EADD OC calculation. And finally it removes the unneeded variable entry_ead in gtk-gui.c. Jan Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Split up preference data structure definition into 'pref.h'Gravatar Linus Torvalds
.. and rename the badly named 'output_units/input_units' variables. We used to have this confusing thing where we had two different units (input vs output) that *look* like they are mirror images, but in fact "output_units" was the user units, and "input_units" are the XML parsing units. So this renames them to be clearer. "output_units" is now just "units" (it's the units a user would ever see), and "input_units" is now "xml_parsing_units" and set by the XML file parsers to reflect the units of the parsed file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-09Assemble the actual Suunto serial numberGravatar Linus Torvalds
It turns out that the serial number returned by libdivecomputer isn't really the serial number as interpreted by the vendor. Those tend to be strings, but libdivecomputer gives us a 32bit number. Some experimenting showed that for the Suunto devies tested the serial number is encoded in that 32bit number: It so happens that the Suunto serial number strings are strings that have all numbers, but they aren't *one* number. They are four bytes representing two numbers each, and the "23500027" string is actually the four bytes 23 50 00 27 (0x17 0x32 0x00 0x1b). And libdivecomputer has incorrectly parsed those four bytes as one number, not as the encoded serial number string it is. So the value 389152795 is actually hex 0x1732001b, which is 0x17 0x32 0x00 0x1b, which is - 23 50 00 27. This should be done by libdivecomputer, but hey, in the meantime this at least shows the concept. And helps test the XML save/restore code. It depends on the two patches that create the whole "device.c" infrastructure, of course. With this, my dive file ends up having the settings section look like this: <divecomputerid model='Suunto Vyper Air' deviceid='d4629110' serial='01201094' firmware='1.1.22'/> <divecomputerid model='Suunto HelO2' deviceid='995dd566' serial='23500027' firmware='1.0.4'/> where the format of the firmware version is something I guessed at, but it was the obvious choice (again, it's byte-based, I'm ignoring the high byte that is zero for both of my Suuntos). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Remove autogroup from the preferences and store per file insteadGravatar Dirk Hohndel
Having two spots to toggle autogroup had always been a clear sign of insanity. The inconsistent ludicrous semantic of when we remembered the state of autogroup was even worse. This finally gets rid of that disaster and drops the autogroup setting from the preferences and makes it instead a per file property. When you save a file, it saves the state of the autogroup toggle. This seems much more useful - you may have files where you want to create trips by default. And others, where you don't. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30First step in cleaning up cylinder pressure sensor logicGravatar Linus Torvalds
This clarifies/changes the meaning of our "cylinderindex" entry in our samples. It has been rather confused, because different dive computers have done things differently, and the naming really hasn't helped. There are two totally different - and independent - cylinder "indexes": - the pressure sensor index, which indicates which cylinder the sensor data is from. - the "active cylinder" index, which indicates which cylinder we actually breathe from. These two values really are totally independent, and have nothing what-so-ever to do with each other. The sensor index may well be fixed: many dive computers only support a single pressure sensor (whether wireless or wired), and the sensor index is thus always zero. Other dive computers may support multiple pressure sensors, and the gas switch event may - or may not - indicate that the sensor changed too. A dive computer might give the sensor data for *all* cylinders it can read, regardless of which one is the one we're actively breathing. In fact, some dive computers might give sensor data for not just *your* cylinder, but your buddies. This patch renames "cylinderindex" in the samples as "sensor", making it quite clear that it's about which sensor index the pressure data in the sample is about. The way we figure out which is the currently active gas is with an explicit has change event. If a computer (like the Uemis Zurich) joins the two concepts together, then a sensor change should also create a gas switch event. This patch also changes the Uemis importer to do that. Finally, it should be noted that the plot info works totally separately from the sample data, and is about what we actually *display*, not about the sample pressures etc. In the plot info, the "cylinderindex" does in fact mean the currently active cylinder, and while it is initially set to match the sensor information from the samples, we then walk the gas change events and fix it up - and if the active cylinder differs from the sensor cylinder, we clear the sensor data. [Dirk Hohndel: this conflicted with some of my recent changes - I think I merged things correctly...] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Update deco handlingGravatar Dirk Hohndel
This commit makes deco handling in Subsurface more compatible with the way libdivecomputer creates the data. Previously we assumed that having a stopdepth or stoptime and no ndl meant that we were in deco. But libdivecomputer supports many dive computers that provide the deco state of the diver but with no information about the next stop or the time needed there. In order to be able to model this in Subsurface this adds an in_deco flag to the samples. This is only stored to the XML file when it changes so it doesn't add much overhead but will allow us to display some deco information on dive computers like the Atomic Aquatics Cobalt or many of the Suuntos (among others). The commit also removes the old event based deco code that was commented out already. And fixes the code so that the deco / ndl information is stored for the very last sample as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Don't allocate an intermediate buffer for most parsed xmlNode contentsGravatar Lubomir I. Ivanov
parse-xml.c: Instead of always allocating a buffer when parsing a node, only do so for "strings" in the utf8_string() function. Also move the whitespace trimming of node contents in there. This change also requires that most parsing functions don't free the passed buffer, as it will be part of memory allocated by libxml2. visit_one_node(), now also has a xmlIsBlankNode() check, where if 1 is returned, the node contains only whitespace or is empty and should not be processed. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-27Clear memory allocated for event namesGravatar Lubomir I. Ivanov
parse-xml.c: When parsing events, we allocate memory for the event 'name' attribute, but also have to free this memory eventually. Let's do that in event_end() right after add_event() is called. Fixes a long-running memory leak in the parser. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>