summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
AgeCommit message (Collapse)Author
2012-12-04Improve deco handling and add NDL supportGravatar Dirk Hohndel
This commit changes the code that was recently introduced to deal with deco ceilings. Instead of handling these through events we now store the ceiling (which in reality is the deepest deco stop with all known dive computers) and the stop time at that ceiling in the samples. This also adds support for NDL (non stop dive limit) which both dive computers that appear to give us ceiling / deco information appear to give us as well (when the diver isn't in deco). If the mouse hovers over the profile we now add support for displaying the NDL, the current deco obligation and (if we are able to tell from the data) whether we are at a safety stop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30Remove the hack to mark parsed XML files as downloadedGravatar Dirk Hohndel
This was necessary for the Uemis downloader when we used the SDA file format as intermediary data format and imported that as XML buffer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30Remove the ability to import Uemis SDA filesGravatar Dirk Hohndel
The downloader has been integrated into Subsurface for a while and with the recent change to no longer have it create the old style SDA files as intermediary format there is no need anymore to support that format in the XML parser. This deletes almost 300 lines of code. Yay! Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-26Simplify tripflags: remove tripflag_names[]Gravatar Linus Torvalds
This removes the tripflag name array, since it's not actually useful. The only information we ever save in the XML file is whether a dive is explicitly not supposed to ever be grouped with a trip ("NOTRIP"), and everything else is implicit. I'm going to simplify the trip flags further (possibly removing it entirely - like I did for dive trips already), and don't like having to maintain the tripflag_names[] array logic. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-26Remove 'when_from_file' field from dive tripGravatar Linus Torvalds
It had become a write-only field (apart from some now useless debugging) when simplifying the remove_autogen_trips() function. So remove it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Improve on divecomputer data handlingGravatar Linus Torvalds
This simplifies the vendor/product fields into just a single "model" string for the dive computer, since we can't really validly ever use it any other way anyway. Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex values that are unique for that particular dive computer model. For libdivecomputer, they are basically the first word of the SHA1 of the data that libdivecomputer gives us. (Trying to expose it in some other way is insane - different dive computers use different models for the ID, so don't try to do some kind of serial number or something like that) For the Uemis Zurich, which doesn't use the libdivecomputer import, we currently only set the model name. The computer does have some kind of device ID string, and we could/should just do the same "SHA1 over the ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so I'll let Dirk fix that up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Add basic divecomputer info setup with xml parsing and savingGravatar Linus Torvalds
This also knows how to save and restore multiple dive computers in the XML data, but there's no way to actually *create* that kind of information yet (nor do we display it). Tested by creating fake XML files with multiple dive computers by hand so far. The dive computer information right now contains (apart from the sample and event data that we've always had): - the vendor and product name of the dive computer - the date of the dive according to the dive computer (so if you change the dive date manually, the dive computer date stays around) Note that if the dive computer date matches the dive date, we won't bother saving the redundant information in the XML file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-24Fix error message (parsing weight here)Gravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Move events and samples into a 'struct divecomputer'Gravatar Linus Torvalds
For now we only have one fixed divecomputer associated with each dive, so this doesn't really change any current semantics. But it will make it easier for us to associate a dive with multiple dive computers. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Allocate dive samples separately from 'struct dive'Gravatar Linus Torvalds
We used to avoid some extra allocations by just allocating the dive samples as part of the 'struct dive' allocation itself, but that ends up complicating things, and will make it impossible to have multiple different sets of samples (for multiple dive computers). So stop doing it. Just allocate the dive samples array separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-21Fix "prefer download" behaviorGravatar Dirk Hohndel
When this was first implemented the assumption was that a downloaded dive that is to be merged with an existing dive would have the same time stamp. But as Linus pointed out even back then, this does fail if a dive has been merged with a download from a different dive computer before (think: download from computer a, then download same dive from b, then improve something in the parsing from computer a and try to redownload; the time stamp could have changed). This commit also fixes a silly omission in the merge_dives() function (which ended up ALWAYS prefering the downloaded dive) and finally implements the necessary changes to mark dives downloaded from a Uemis SDA as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-19Fix the XML gps parsing and saving when using non-US localesGravatar Linus Torvalds
The GPS parsing and saving was using sscanf and sprintf respecively, and since it is using floating point values (boo!) that affects both of them. In a C/US locale, we use a period for decimal values, while most European locales use a comma. We really should probably just fix things to use integer values (degrees and nanodegrees?) but this is the simplest fix/workaround for the issue. Probably nobody ever really noticed until I tested the Swedish locale for grins, since we don't have a good way to actually set the GPS coordinates yet. I've got a few dives with GPS information that I entered manually. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12Store and parse salinity and surface pressureGravatar Dirk Hohndel
In my excitement about extracting these from libdivecomputer I forgot to actually store them and then parse them again. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Simplify and clean up dive trip managementGravatar Linus Torvalds
This adds a couple of helper functions to manage dive trips ("add_dive_to_trip()" and "remove_dive_from_trip()") and makes those functions do the trip statistics maintenance (trip beginning times, number of dives, etc). This was needed because the dive merge cases for multiple dive computers showed some rather nasty special cases: especially if the new dive information has been loaded into an XML file with trips auto-generated, merging several of these kinds of xml files with multiple dives in several overlapping trips would completely confuse our previous code. In particular, auto-generated trips that had the exact same date as previous trips (because they were generated from the same dive computer) really confused the code that used the trip timestamp to manage the trips. Adding the helper functions allows us to get the general case right without having to have each piece of code that handles trip information having to bother about all the odd rules. It will eventually also allow us to make the dive trip data structures more logical: right now the dive trip list is largely designed around the odd gtk model handling, rather than some more higher-level conceptual relationship with the actual dives. But for now, this keeps all the data structures unchanged, and just modifies them using the new helper functions. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Fix default filename handling errorsGravatar Linus Torvalds
The default filename handling is broken in two different ways: (a) if we start subsurface with a non-existing file, we warn about the inability to read that file, and then we exit without setting the default filename. This is broken because it means that if the user (perhaps by mistake, by pressing ^S) now saves the file, he will overwrite the default filename, even though that was *not* the file we read, and *not* the file that subsurface was started with. So just set the default filename even for a failed file open. The exact same logic is true of a failed parse of an XML file that we successfully opened. We do *not* want to leave the old default filename in place just because the XML parsing failed, and possibly then overwriting some file that was never involved with that failure in the first place. So just get rid of all the logic to push the filename saving into the XML parsing layer, it has zero relevance at that point. (b) if we do replace the default filename with a NULL file, we need to set that even if we cannot do a strdup() on the NULL. This fixes both errors. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Fix cut and paste error in an error messageGravatar Dirk Hohndel
This has been around for a loooong time, I just happened to stamble across it when reading the code... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28Add support for visibility tracking and allow manual entry air tempGravatar Dirk Hohndel
Turns out we had a data field for visibility as a length unit - but never used it. I can never guess how much visibility we actually had on a dive - but I think most everyone can assign a rating between abysmal (zero stars, "I couldn't read my dive computer even right in front of my mask" - trust me, I had some of those dives) to amazing ("five stars, I could see farther than I though possible" - and I had one or two of those, too). So I changed this to an integer and am re-using the star infrastructure we have for the overall dive rating. When displaying this I was dismayed that we are running out of space in the "Dive Notes" notbook. So I moved this to the "Dive Info" notebook. This is not consistent and not logical. I think we need to revisit the notebooks and think about what we want to display where. While adding the infrastructure to manually enter the visibility I went ahead and added the ability to manually enter the air temperature as well (that was one of the things missing in the previous commit). Fixes #7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15Merge branch 'gettext'Gravatar Dirk Hohndel
Bring all the localization changes into master in preparation for Subsurface 2.1
2012-10-11Improve on the DivingLog importer a bitGravatar Linus Torvalds
This adds a few fields that we parse, but more importantly it also tries to dynamically decide if the sample temperatures and pressures are in imperial or metric units. Dirk suspects that DivingLog generally always does everything in metric, and the reason why he has crazy sample data in imperial units (both for pressure and temperature) may be due to a bug in the early Uemis importer for DivingLog. Which would actually make a lot more sense than DivingLog really being so insane on purpose. Anyway, Dirk's brother Jurgen seems to have everything in metric units, which would be much saner. Maybe we should throw away the support for insane DivingLog files entirely, since it is possible that the only use ever of the possible source of that bug was Dirk's use of the Uemis importer. But for now, we end up just guessing. Current guesses: - water temperature is below 32 dgC, so 32+ degrees is in Fahrenheit. - tank pressures are below 400 bar, so higher values than that must be psi. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11Conversion to gettext to allow localizationGravatar Dirk Hohndel
This is just the first step - convert the string literals, try to catch all the places where this isn't possible and the program needs to convert string constants at runtime (those are the N_ macros). Add a very rough first German localization so I can at least test what I have done. Seriously, I have never used a localized OS, so I am certain that I have many of the 'standard' translations wrong. Someone please take over :-) Major issues with this: - right now it hardcodes the search path for the message catalog to be ./locale - that's of course bogus, but it works well while doing initial testing. Once the tooling support is there we just should use the OS default. - even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets can't seem to agree) I went with UTF-8 as that is what Gtk appears to want to use internally. ISO-8859-15 encoded .mo files create funny looking artefacts instead of Umlaute. - no support at all in the Makefile - I was hoping someone with more experience in how to best set this up would contribute a good set of Makefile rules - likely this will help fix the first issue in that it will also install the .mo file(s) in the correct place(s) For now simply run msgfmt -c -o subsurface.mo deutsch.po to create the subsurface.mo file and then move it to ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo If you make changes to the sources and need to add new strings to be translated, this is what seems to work (again, should be tooled through the Makefile): xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c msgmerge -s -U po/deutsch.po subsurface-new.pot If you do this PLEASE do one commit that just has the new msgid as changes in line numbers create a TON of diff-noise. Do changes to translations in a SEPARATE commit. - no testing at all on Windows or Mac It builds on Windows :-) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-09A file that we import should never become the default file we save toGravatar Dirk Hohndel
Only files that are opened should be considered r/w. Files that are imported should be treated as if they were r/o. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30New XML format for saving divesGravatar Linus Torvalds
This patch makes the trips nest, and it also fixes the fact that you never saved the trip notes (you could edit it, but saving would throw it away). I did *not* change the indentation of the dives, so the trip stuff shows up the the beginning of the line, at the same level as the <dive> and <dives> thing. I think it's fairly readable xml, though, and we haven't really had proper "indentation shows nesting" anyway, since the top-level "<dives>" thing also didn't indent stuff inside of it. Anyway, the way I wrote it, it still parses your old "INTRIP" stuff etc, so as far as I know, it should happily read the old-style XML too. At least it seemed to work with your xml file that already had the old-style one (I haven't committed my divetrips, exactly because I didn't like the new format). It always saves in the new style, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29Fix a number of obvious memory leaksGravatar Dirk Hohndel
Just the result of cppcheck and valgrind... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-20Merge branch 'divetrip-rewrite' of git://github.com/torvalds/subsurfaceGravatar Linus Torvalds
Merge the dive trip rewrite by Dirk Hohndel. This just merges the dive trip changes with the timestamp handling changes. There were multiple small data conflicts, along with some newly added 'time_t' cases in the dive trip handling that needed to be converted to 'timestamp_t' along the way. * 'divetrip-rewrite' of git://github.com/torvalds/subsurface: Convert FIND_TRIP into function Partial rewrite of the dive trip code Check if trip is NULL before calling DIVE_TRIP
2012-09-19Partial rewrite of the dive trip codeGravatar Dirk Hohndel
This introduces a new data structure for dive trips - reuseing the struct dive just got way too messy. The dive_trip_t datastructure now allows the code to remember if the trip was auto generated or if its time stamp changed when dives where added to the trip during auto generation. The algorithm also distinguishes between dives that were intentionally added to a trip (either in an XML file or by adding them to trip in the UI) and dives that were added to trips via autogen. Saving dives that were added to trips via autogen makes that assignment "intentional". With this partial rewrite several of the oddities of the old code should be resolved - especially turning autogen on and off again should get the divelist back to the previous stage. Also, when dives are merged during file open or import we now try to pick the correct tripflag (instead of just ignoring the tripflag completely and resetting it to TF_NONE by mistake). Finally, the dive trip debugging code got more verbose and is trying harder to detect issues at the earliest time possible. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-19Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'Gravatar Linus Torvalds
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-18Call xmlCleanupParser only once - when we are done with libxmlGravatar Lubomir I. Ivanov
Calling xmlCleanupParser in parse-xml.c:parse_xml_buffer() caused massive memory corruption mostly affecting gtk's FileChooser dialogs and the application menu. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Correctly deal with empty XML filesGravatar Dirk Hohndel
Previously we could end up with a bogus dive with all zero data in it. Adding dives/test24.xml to be able to test that we handle this case correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10Change behavior for the existing filenameGravatar Dirk Hohndel
Previously we always picked the last file that was openend as the file name to save to. That seems counterintuitive when importing files or when opening multiple files. Especially if Subsurface was executed without a file on the command line and we are using the default file. Now we only remember a file name if it was the first one to ever be openend or if it was used in save-as. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-06Merge branch 'trip3' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
Pull trip manipulation branch from Dirk Hohndel: "I have added yet more of the requested features. I am not aware of any outstanding bugs or crashes (except for the Gtk problem that causes the import to crash for some people on Ubuntu and MacOS - but as I mentioned earlier, that bug has been around as long as the import file selector box)." * 'trip3' of git://git.hohndel.org/subsurface: Avoid duplicate dive_trip entries More trip manipulations: remove selected dives from trip Add ability to merge trip with trip below Use the infrastructure for moving dives in more places Correct the trip related test dives Fix crash when removing the first dive of a trip Correctly initialize the toggle state of the autogroup menu entry Fix copy_tree_node to no longer overwrite dive duration Add autogen menu command Fix a crash when changing sort column Use truth values with gboolean Allow modification and edits of trips Clean up macros and auxiliary functions Store time_t as long value
2012-09-05Avoid duplicate dive_trip entriesGravatar Dirk Hohndel
When inserting a trip into the dive_trip_list we already check for duplicate trips, but we still kept the additional dive_trip around. With this change we instead replace it with the existing one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03Make xml (and CSV) parsing use 'g_ascii_strtod()' rather than 'strtod()'Gravatar Linus Torvalds
GTK messes up the standard C library locales by default (instead of just taking locale information into account internally). Which breaks 'strtod()' and 'printf()' etc. Since they screwed that up, they then added helper functions for undoing that braindamage. Use it. I'd like to blame the GTK people, but the standard C libary people bear *some* responsibility for this. One of the reasons why people do not use "setlocale()" in many normal programs is exactly because it messes up core libc functionality - with number conversion being the main thing. Doing things like converting numbers in a locale-specific manner is something people do want to do, but not *always*. So the C library locale code should always had defaulted to C locale, with some *extra* marker (like a printf/scanf modifier) to say "print/scan in the current locale". Because many things absoilutely need to be non-localized. You don't want your internal file format to magically change just because you want to show things to the user in France, for example. Reported-by: Ivan Habunek <ivan.habunek@gmail.com> Root-caused-by: Jef Driesen <jefdriesen@telenet.be> Cc: Dirk Hohndel <dirk@hohndel.org> Cc: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-01Clean up macros and auxiliary functionsGravatar Dirk Hohndel
In preparation for the next stage of the trips handling this commit makes the macros used to access trips (and some frequently used variables for the tree and list models) more consistent. This also changes the way we display un-grouped dives in the dive list, i.e. dives that are not part of a dive trip. Their dive number is now printed bold. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27Merge branch 'trips' of git://git.hohndel.org/subsurfaceGravatar Linus Torvalds
Merge the initial 'track trips explicitly' code from Dirk Hohndel. Fix up trivial conflicts in save-xml.c due to the new 'is_attribute' flag. * 'trips' of git://git.hohndel.org/subsurface: Fix an issue with trips that have dives from multiple input files Some simple test dives for the trips code First cut of explicit trip tracking
2012-08-27Fix an issue with trips that have dives from multiple input filesGravatar Dirk Hohndel
The existing code didn't handle the case of different trips for the same date coming from different sources. It also got confused if the first dive processed (which is, chronologically, the last dive) happened to be a "NOTRIP" dive. This commit adds a bit of debugging infrastructure for the trip handling, too. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-27First cut of explicit trip trackingGravatar Dirk Hohndel
This code establishes the explicit trip data structures and loads and saves them in the XML data. No attempts are made to edit / modify the trips, yet. Loading XML files without trip data creates the trips based on timing as before. Saving out the same, unmodified data will create 'trip' entries in the XML file with a 'number' that reflects the number of dives in that trip. The trip tag also stores the beginning time of the first dive in the trip and the location of the trip (which we display in the summary entries in the UI). The logic allows for dives that aren't part of a dive trip. All other dives simply belong to the "previous" dive trip - i.e. the dive trip with the latest start time that is earlier or equal to the start time of this dive. This logic significantly simplifies the tracking of trips compared to other approaches that I have tried. The automatic grouping into trips now is an option that defaults to off (as it makes changes to the XML file - and people who don't want this feature shouldn't have trips added to their XML files that they then need to manually remove). For now you have to select this option, then exit the program and start it again. Still to do is to trigger the trip generation at run time. We also need a way to mark dives as not part of trips and to allow options to combine trips, split trips, edit trip location data, etc. The code has only had some limited testing when opening multiple files. The code is known to fail if a location name contains unquoted special characters like an "'". This commit also fixes a visual inconsistency in the preferences dialog where the font selector button didn't have a frame around it that told you what this option was about. Inspired-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-26Do some whitespace cleanupGravatar Linus Torvalds
The previous commit was a patch from Lubomir, which also had some whitespace fixes (to go with some new whitespace bugs to replace them) in it. I removed the whitespace changes from that patch (don't mix whitespace fixes with other fixes, unless they are on the same lines!) but decided to look for other whitespace issues, and this is the result. I left the non-C files alone, some of the spec and script files also have whitespace at the end of lines etc. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-17Import Divesuit information from DivingLog XML fileGravatar Dirk Hohndel
Trivial two-liner patch Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-14Add exposure protection trackingGravatar Dirk Hohndel
For simplicity and shortness, throughout subsurface exposure protection is simply referred to as "suit". Add the fields to the data structures, add the column to the dive_list and the preferences dialog (once again with it being turned invisible by default). Support loading and saving of the suit information. Display the suit information in the Dive Info pane (this may be a bit controversial as people could argue this should be in the Equipment pane) and allow editing of the suit info, with our usual support for completion and drop down lists to pick from. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-06-18Add tankpressure parsing for UDDF filesGravatar Linus Torvalds
David McNett sent me some example Cochran CAN file data, along with his UDDF exports of same. I still have absolutely no idea how to decode the CAN files (although the subsurface decrypting code seems to correctly decrypt the data, and I see binary patters rather than just noise), but at least I can make sure we parse the UDDF portion better. See also https://github.com/nugget/cochran2uddf for David's tool to convert the Cochran CSV exports into UDDF. Data-source: David McNett <nugget@macnugget.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-12Allow overriding the default xslt pathGravatar Linus Torvalds
It's very annoying to have to do "make install" to test a new xslt file, just because the default xslt path has the standard install path as the first entry. At the same time, we do want to default to just using the standard install location first. So to allow both testing, and having a nice sane default, just add support for a SUBSURFACE_XSLT_PATH environment variable that overrides the default one if it exists. So then you can just do SUBSURFACE_XSLT_PATH=xslt ./subsurface to run subsurface from inside the git tree itself, using the current files in the git xslt subdirectory. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-02Renumber dives when deleting a diveGravatar Linus Torvalds
... but only do it if the numbering of subsequent dives was consecutive to begin with. Note that we do accept unnumbered dives (and will stop the sequence check if we find one), but in order to renumber dives on delete, we require that starting with the dive we delete, the subsequent numbered dives have to be a nice incrementing series. If that is the case, then we fix up that numbering as we delete the dive. Put another way: if the dive numbering was an incrementing sequence before the delete, then it will be a sane incrementing sequence after it too. But if you had missing dives before the delete, we will turn the delete into just another missing dive. The basic rule is that we never renumber any dives unless that renumbering is "obviously correct". It's better to leave old numbers as-is (and expect that the user is going to do an explicit re-numbering operation) than it is to change dive numbers in a sequence that we don't understand. I do suspect that we should possibly check the dive number "backwards" too, but this doesn't do that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-04-02Add the ugliest 'delete dive' model everGravatar Linus Torvalds
This interface works the same way the "edit dive" menu item does: it's a text entry meny item on the dive text entries (ie buddy/divemaster/notes sections). Except you pick the "Delete" entry rather than the "Edit" entry. It kind of works, but it really is a pretty horrible interface. I'll need to add a top-level dive menu entry for just deleting all selected dives instead. And it would be good to be able to get a drop-down menu from the divelist instead of having to do it from the dive text entries, which is just insane. But that requires gtk work. I'm not quite ready to get back into that. Thus the "exact same insane interface as the explicit 'Edit' mode". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-23Merge branch 'weight' of git://subsurface.hohndel.org/subsurfaceGravatar Linus Torvalds
Pull weight management from Dirk Hohndel: "This is the fifth or sixth version of this code, I'm begining to lose track. I still struggle with the balance between code duplication and unnecessary indirectness and complexity. Maybe I'm just not finding the right level of abstraction. Maybe I'm just trying too hard. The code here is reasonably well tested. Works for me :-) It can import DivingLog xml files with weight systems and correctly parses those. It obviously can read and write weight systems in its own file format. It adds a KG/lbs unit default (and correctly stores that). The thing I still worry about is the code in equipment.c. You'll see that I tried to abstract things in a way that weight systems and cylinders share quite a bit of code - but there's more very similar code that isn't shared as my attempts to do so turned into ugly and hard to read code. It always felt like trying to write C++ in C..." * 'weight' of git://subsurface.hohndel.org/subsurface: Add weight system tracking Fix up some trivial conflicts due to various renaming of globals and simplification in function interfaces.
2012-03-24Add weight system trackingGravatar Dirk Hohndel
- supports multiple weight systems per dive - supports multiple weight system types - supports import of weight as tracked by DivingLog Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-26Split up file reading from 'parse-xml.c' into 'file.c'Gravatar Linus Torvalds
We're going to eventually import non-xml files too, so let's begin splitting the logic up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-05Avoiding some potentially confusing name space clashesGravatar Dirk Hohndel
We have local variables or function arguments with the same names as function static variables (or in one case, function arguments). While all the current code was correct, it could potentially cause confusion when chasing bugs or reviewing patches. This should make things clearer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05Oddly, finishing a sample doesn't require a sampleGravatar Dirk Hohndel
So let's not pass it around Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-30Move the gasmix cleanups from XML parsing to the generic dive fixup stageGravatar Linus Torvalds
Right now we do certain cylinder info operations only when importing from an XML file, which is wrong. In particular, we do the "is the gasmix air" or "what is the standard cylinder name" only at XML read time, which means that if you import a dive directly from the dive computer, it won't have the air sanitization or the proper default cylinder names. Of course, most dive computers don't actually save enough cylinder information for us to do the cylinder name lookup anyway, but some do. And all Nitrox-capable dive computers do have that O2 percentage that needs cleanup too. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-18parse-xml: read the file into memory separatelyGravatar Linus Torvalds
Using xmlParseFile() was simple, but I'm planning on extending the file parsing past just XML, since we want to be able to import other formats too. And quite frankly, that means that we'll want to read the file into memory to look at it before we start parsing it. We could decide do it by file extensions too, and I'll look at that approach as well, but regardless of how we do things it's almost certainly a good idea to do the file access in one place. The XML parsing might as well happen from a memory buffer instead anyway. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>