aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2012-12-29Make sure the model is non-NULL before comparing with itGravatar Dirk Hohndel
In commit 194a05b18911 "Correct the detection of existing dives in the Uemis downloader" I forgot to add that check before calling strcmp. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Allow sorting dives by date - without the dive trips in the dive listGravatar Linus Torvalds
We used to enable dive trips whenever we sorted by date, which can be a bit annoying. Sometimes you really just want to sort all your dives by date, without necessarily seeing the trip data. So this changes the default sort to be the "dive number" table, and then does *not* actually sort by the dive number, but instead enables the trips, and then sorts the result by date. So the "dive number" column - which used to be non-sortable - becomes semantically equivalent to the old date column sorting. And now sorting by date makes it act like sorting by depth or any other attribute - we hide the dive trip tree, and just show the plain list of dives (sorted by date, obviously). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28When libdivecomputer reports a DECOSTOP or DEEPSTOP, set ndl to 0Gravatar Dirk Hohndel
Without this deco could be mistaken as safety stop (in the case where between two samples we go from a positive ndl to suddenly having a stop - so we never reach ndl of 0) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Don't store notes that are just one space on the UemisGravatar Dirk Hohndel
Sometimes the Uemis appears to return " " as notes instead of no notes. This patch filters this out (otherwise redownloading divecomputers can cause silly things like notes that say "(existing note) or ( )" ) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Correct the detection of existing dives in the Uemis downloaderGravatar Dirk Hohndel
This didn't take multiple divecomputers into account and didn't compare the model as well as the deviceid to match a divecomputer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Don't match existing dives by date if the dive computers are known to be ↵Gravatar Linus Torvalds
different When downloading from a dive computer, we fall back on matching the exact date of the dive if we can't tell whether we already have that exact dive computer data some other way. However, if you have multiple dive computers and they are sufficiently well synchronized, they might actually have the exact same date, despite the fact that we do want to download both dive computers. We do check the dive start to the exact second, so this sounds unlikely, but with dive computers rounding time to the next minute etc, it's not as unlikely as you'd think. Dirk hit it. So when we match against date, do check that the dive computer might actually be one we've already downloaded from. If we have full model information, we can dismiss the "match date" logic. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Make add_dc_to_string() skip redundant entriesGravatar Linus Torvalds
There is no point writing out divecomputer nicknames that do not exist (or that match the dive computer model), so don't. Also, make the function to do this static to save-xml.c, which is the only user (I initially didn't _find_ the function to create the XML string because it was illogically hidden in gtk-gui.c), and change the calling convention to be more direct (pass in a string and return a result, rather than modify a "pointer to string"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Added some extra space for the "or" word when merging two stringsGravatar Lubomir I. Ivanov
dive.c:merge_text(): When "or" is translated into other languages it may be longer than 2 letters, therefore there is a need for a slightly larger buffer to be reserved. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Free trip notes memory when deleting a tripGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> 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-28Support tank size information download from Atomic Aquatics CobaltGravatar Dirk Hohndel
This should really be done in libdivecomputer, but that can't happen until the API there gets extended to support tank sizes. So for now with this code we manually parse the raw dive data (if downloaded via libdivecomputer from a Cobalt) and setup the tank size ourselves. This had relatively limited testing so far. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28Divecomputer entries with deviceid 0 should be ignored for nicknamesGravatar Dirk Hohndel
Those only come from a number of development versions of Subsurface that didn't include the deviceid in the divecomputer entry. There is no way of telling different dive computers (of the same model) apart, so assigning a nickname to such an entry then creates incorrect output when loading an XML file from someone else (e.g. Linus and I both have a Uemis SDA and both may have entries for our own SDA with deviceid 0; then the nickname Subsurface shows for any Uemis SDA entry with a deviceid of 0 depends on whether I last loaded his XML file or mine; that makes no sense). This should only affect the develoers who stored XML files with one of the development version of Subsurface that didn't store deviceids. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-27Fix incorrect memory access in nickname handlingGravatar Dirk Hohndel
There was one code path where we didn't strdup the nickname - and this got triggered when parsing XML files with divecomputerid entries for dive computers that were already in the config. The nickname is then replaced with the nickname from the parser - and that memory is later reused... We should cleanup that nickname, anyway, and that also takes care of making sure we have our own copy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-27Clear redundant "description" when merging two cylinder typesGravatar Lubomir I. Ivanov
dive.c: merge_cyclinder_type() can cause a small memory leak if two cylinder types are about to be merged, but the redundant one has a "description" string allocated. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-27When a dive computer is deleted also clear its modelGravatar Lubomir I. Ivanov
dive.c: A dive computer may have its model allocated in memory. Let's clear that as well when calling free_dc(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-27Small changes in the memory management when dive-mergingGravatar Lubomir I. Ivanov
This patch makes a couple of modifications: 1) divelist.c:delete_single_dive() now tries to free all memory associated with a dive, such as the string values for divemaster, location, notes & etc. 2) dive.c:merge_text(), now always makes a copy in memory for the returned string - either combined or one of the two which are passed to the function. The reason for the above two changes is that when (say) importing the same data over and over, technically a merge will occur for the contained dives, but mapped pointers can go out of scope. main.c:report_dives() calls try_to_merge() and if succeeds the two dives that were merged are deleted from the table. when we delete a dive, we now make sure all string data is cleared with it, but also in the actual merge itself, which precedes, copies of the merged texts are made (with merge_text()), so that the new, resulted dive has his own text allocations. 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>
2012-12-26Fix crash when trip info changes across remember/restore tree stateGravatar Dirk Hohndel
Interesting crash. Importing a file gets us to a stage where we have a trip tree note with a date that doesn't exist as trip date. That's clearly bogus. And in import_files() we assume that all is still fine and try to restore the old expanded / selected state for the various trips. There is clearly a bigger issue here, this patch at least prevents the actual crash from happening by making sure the pointer is non-NULL before dereferencing it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-26Add settings section to XML file format and store dive computer IDsGravatar Dirk Hohndel
We only store the model/deviceid/nickname for those dive computers that are mentioned in the XML file. This should make the XML files nicely selfcontained. This also changes the code to consistently use model & deviceid to identify a dive computer. The deviceid is NOT guaranteed to be collision free between different libdivecomputer backends... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-23Different is different from the same (fix silly bug in nickname handling)Gravatar Dirk Hohndel
Trying to simplify the API for nickname handling I went a bit too far. We indeed need to different API calls, one that returns an entry in the nicknamelist for the deviceid that we have. And one that looks if there is an entry for a different deviceid but the same model that we have. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Next improvement of the nickname codeGravatar Dirk Hohndel
Now it is able to replace nicknames for existing entries (which will be needed by the yet to be written UI). This commit fixes a couple issues with the previous code: - a potential SIGSEGV with malformed config entries - missing closing parenthesis in the dialog box text Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Add some text in statistics.c for translationGravatar Lubomir I. Ivanov
Some UI texts were missing translation, such as: "for selected dive" "for all dives" Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Make it possible to translate strings containing subscript "2"Gravatar Lubomir I. Ivanov
The "Tec settings" dialog contains some strings with the subscript "2" character, which have to be translated. While the "2" is part of the string xgettext doesn't seem to recognize such. To trick it we use a temporary buffer and c-format: sprintf(utf8_buf, _("Show pO%s graph"), UTF8_SUBSCRIPT_2); button = gtk_check_button_new_with_label(utf8_buf); Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Free some nickname related memory in gtk-gui.cGravatar Lubomir I. Ivanov
init_ui(): We add the char pointer "conf_copy" and free it afterwards, since once "next_token" is changed it no longer points to the allocated heap location the mapper returned. [Dirk Hohndel: original patch rewritten to have better variable names and to match the recent changes to this code] Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Fix some small memory leaks related to gtk_tree_model_get_path()Gravatar Lubomir I. Ivanov
From the GTK docs on gtk_tree_model_get_path(): "Returns a newly-created GtkTreePath referenced by iter. This path should be freed with gtk_tree_path_free()." Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-22Imrpove the nickname handlingGravatar Dirk Hohndel
We now store the model information together with the deviceid and nickname in order to be able to check if we have a record for any dive computer with the same model (as that now triggers our nickname dialog). This changes the format of the config entries for nicknames - the best solution might be to just delete those and start again. What is still missing is the code to store the nicknames in the XML file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-21Remove nickname from divecomputer data structureGravatar Dirk Hohndel
Having it there with the model information seemed to make sense but on second thought it's the wrong spot to keep that information, especially since we were storing it in the XML file in every single dive. This change removes the nickname member from the divecomputer and makes the rest of the code reasonably self consistent. It does not add much of the new code for the new design to handle nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-20Correctly calculate OTUs when pO2 is recorded in the samplesGravatar Dirk Hohndel
This will normally happen for CCR dives with a set pO2. The old calculations was only valid for OC dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-20If no dives are selected, clear the stats widgetGravatar Dirk Hohndel
Previously we had lots of zeros and some non-sensical data displayed (the temp values were actually not zeroed out). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-20Show which dives are covered by the statisticsGravatar Dirk Hohndel
If all selected dives appear to have numbers that make sense, assemble a string that lists the selected dives (and try to be smart about finding ranges) and display those in the frame of the statistics widget. The code sets an arbitrary length limit on that list of dive numbers and tries to be smart about creating an ellipsis if necessary. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-19Initial Russian translation for Subsurface.Gravatar Sergey Starosek
Some acronyms (SAC, OLF, OTU) were not translated since there's no settled/common ones in russian. Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-19Prevent bleeding deco/ndl for XML files without divecomputer entriesGravatar Linus Torvalds
Miika's xslt patch creates correct XML data without divecomputer entries. What happens is that the stop information at xml parse time is only cleared by the divecomputer entries, so if the XML lacks them, we will bleed stop data from one dive to the next. This patch makes sure that the deco/ndl information is cleared even if the dive has no divecomputer entry. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-19Convert deco info from JDiveLog to SubsurfaceGravatar Miika Turkia
This patch correctly converts the available deco data from JDiveLog files. In order for this to work correctly the next patch from Linus is needed as well. Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-17Add a "View next dive computer" menu itemGravatar Linus Torvalds
This adds the capability to actually view all your dive computers, by adding a menu item under "Log"->"View"->"Next DC" to show the next dive computer. Realistically, if you actually commonly use this, you'd use the accelerator shortcut. Which right now is Ctrl-C ("C for Computer"), which is probably a horrible choice. I really would want to have nice "next/prev dive" accelerators too, because the cursor keys don't work very well with the gtk focus issues. Being able to switch between dives would also make the "just the dive profile, maam" view (ctrl-2) much more useful. The prev/next dive in the profile view should probably be done with a keyboard action callback, which also avoids some of the limitations of accelerators (ie you can make any key do the action). Some gtk person, please? Anyway, this commit only does the dive computer choice thing, and only using the accelerators. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Improve visual appearance of horizontal marker linesGravatar Dirk Hohndel
This changes two things to improve the appearance of the profile: - the partial pressure scale is now in 0.5 increments if the total is <= 4 and in 1.0 increments if it is > 4. - the depth marker lines end slightly below the depth chart so that we no longer have overlap between the depth scale and the partial pressure scale. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Attempt to free plot data entries in each call to create_plot_info()Gravatar Lubomir I. Ivanov
In profile.c:create_plot_info(), store the last address in which memory was allocated for the plot data entries in the static variable "last_pi_entry". If "last_pi_entry" isn't a NULL pointer in each call to create_plot_info(), free memory at that address. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Clear associated tooltip texts when calling expose_event()Gravatar Lubomir I. Ivanov
In gtk-gui.c:expose_event(), right before clearing the list of tooltips, we also want to free memory for the associated texts for each one of them. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Fixed some memory leaks related to subsurface_get_conf()Gravatar Lubomir I. Ivanov
In gtk-gui.c:init() we retrieve the configuration values for PO2, PN2, PHE thresholds but have to also free the values once done parsing with sscanf(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Fixed a couple of memory leaks related to the download dialogGravatar Lubomir I. Ivanov
In render_dc_vendor() and render_dc_product(), there is no need to allocate memory for the texts that are about to be added in the combo box trees. Most GTK widgets seem to make copies of the passed text to them, using g_strdup() and automatically release said memory when a widget is destroyed. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Properly remove redundant dive computer informationGravatar Linus Torvalds
We had logic to remove duplicate dive computer information after merging dives, but it didn't actually work. Why? Because we had used the 'res' dive computer pointer to traverse the list of dive computers, so it no longer actually pointed to the first dive computer in the result list any more, and so the "remove redundant" code only removed redundant dive computers from a limited and incomplete list. Oops. Also, before checking the whole event and sample list, check if it's the exact same dive computer using our new "match_one_dc()" helper function, and don't even bother checking for sample details if it is. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Use dive ID for matching dives during downloadsGravatar Linus Torvalds
If we have a dive computer model and dive ID, use that to match newly downloaded dives against the existing dives. Otherwise fall back to "exact date match" again, like we've always done. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Use dive computer model/ID when trying to merge divesGravatar Linus Torvalds
If we havd divecomputer model and dive ID information available, use that to match existing dives when trying to merge them. Otherwise fall back to the fuzzy time-based merging logic. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Make sure that the user entered nickname is never truncatedGravatar Lubomir I. Ivanov
If the sizes of the two char buffers in set_dc_nickname() (nickname) and remember_dc() (buffer) are at least twice the size of the allowed maximum number of characters (sizeof(gunichar) = 2) set by gtk_entry_set_max_length() for the user nickname, no truncation will accur then calling snprintf() and cleanedup_nickname() on said buffers. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-15Deal with some trip issues when editing dive timestampsGravatar Dirk Hohndel
The idea behind editing timestamps had of course been the typical "oops, I forgot to set my time correctly" which shifts a dive (or a few of them) by a few hours but keeps the overall order of dives the same). But reasonable people might argue that they can envision a scenario where more dramatic changes are being made. And we need to deal with the impact this has on dive trips. Here we handle a couple of simple cases: - this is the only dive in a trip; just update the trip (this can still cause problems if the new time is in the middle of an existing trip). - this dives moves before the start of the trip it is in; let's remove it from that trip (this response is a bit simplistic - but as I tried to say, I don't expect this to be a common use case; and removing it at least doesn't lead to entirely unexpected behavior). - this dive moves past the end of this trip into the range of a different trip (in this case we remove the dive from the current trip and allow it to interrupt the trip it is moving into). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-15Reserve enough memory when storing a DC's nicknameGravatar Lubomir I. Ivanov
in gtk-gui.c: The input text field in set_dc_nickname() has a limit of 68 unicode characters, which are 136 bytes. In remember_dc(), to make sure that this nickname, the deviceid (4 bytes) and also the extra characters (",{}") always fit wihout truncation (from snprintf) in the allocated stack buffer, we increase the size of the buffer to 256 bytes. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-14Fix possible crash in nickname codeGravatar Dirk Hohndel
Silly typo, but this is the better solution, anyway. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>` Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-13Add the ability to set a nickname for a dive computerGravatar Dirk Hohndel
We maintain a list of dive computers that we know about (by deviceid) and their nicknames in our config. If the user downloads dive from a dive computer that we haven't seen before, we give them the option to set a nickname for that dive computer. That nickname is displayed in the profile (and stored in the XML file, assuming it is not the same as the model). This implementation attempts to make sure that it correctly deals with utf8 nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-12Change the empty product model to be index 0Gravatar Dirk Hohndel
A vendor of -1 indicates that we should have no product selection in the dive download dialog. Having the empty product model be the last made it hard to keep the correct index for that empty model around (and we got it wrong by default). With this change the product models are offset by one, so the unset vendor (-1) turns into index 0 which is where we now store the empty model. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-12Ensure default dive computer strings can be freedGravatar Dirk Hohndel
We don't want to directly use the strings returned to us from libdivecomputer. Fixes bug 34 Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11Add crypto library to Windows installer fileGravatar Dirk Hohndel
This dependency was brought in by commit 3e51d56f87a3 "Improve on divecomputer data handling". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>