Commit graph

12530 commits

Author SHA1 Message Date
Dirk Hohndel
e3ab1c0701 Update deco handling
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-30 18:17:21 -08:00
Dirk Hohndel
46b64d8e21 Add time stamp to the debugging printout of vendor specific samples
They are useful for debugging things in libdivecomputer and this way it's
easier to match the data to specific points in the dive profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30 17:53:51 -08:00
Dirk Hohndel
2581b3870f Make the tooltip text for gaschange events more informative
We now print out "air", "nn% O2", or "(nn/xx)" for trimix.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-29 11:44:11 -08:00
Dirk Hohndel
7aaa539afe Make sure the model is non-NULL before comparing with it
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-29 11:28:35 -08:00
Linus Torvalds
e862f7c343 Allow sorting dives by date - without the dive trips in the dive list
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-28 22:35:55 -08:00
Dirk Hohndel
2287dc87cf When libdivecomputer reports a DECOSTOP or DEEPSTOP, set ndl to 0
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-28 18:39:01 -08:00
Dirk Hohndel
fd983a0992 Don't store notes that are just one space on the Uemis
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-28 18:30:02 -08:00
Dirk Hohndel
0233239198 Correct the detection of existing dives in the Uemis downloader
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-28 18:23:19 -08:00
Linus Torvalds
020154215d Don't match existing dives by date if the dive computers are known to be 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-28 14:16:29 -08:00
Linus Torvalds
3b136f23ee Make add_dc_to_string() skip redundant entries
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-28 09:04:59 -08:00
Lubomir I. Ivanov
fc1bb0a32c Added some extra space for the "or" word when merging two strings
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-28 08:59:51 -08:00
Lubomir I. Ivanov
596b13e310 Free trip notes memory when deleting a trip
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-28 08:59:42 -08:00
Lubomir I. Ivanov
8bce372eb1 Don't allocate an intermediate buffer for most parsed xmlNode contents
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-28 08:58:44 -08:00
Dirk Hohndel
df613bf107 Support tank size information download from Atomic Aquatics Cobalt
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-28 08:53:16 -08:00
Dirk Hohndel
3872921ffe Divecomputer entries with deviceid 0 should be ignored for nicknames
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-28 06:36:47 -08:00
Dirk Hohndel
f6fb882337 Fix incorrect memory access in nickname handling
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-27 21:41:12 -08:00
Lubomir I. Ivanov
fd03fcd66d Clear redundant "description" when merging two cylinder types
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-27 08:15:25 -08:00
Lubomir I. Ivanov
310b05ac84 When a dive computer is deleted also clear its model
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-27 08:15:11 -08:00
Lubomir I. Ivanov
906fd400e7 Small changes in the memory management when dive-merging
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-27 08:08:59 -08:00
Lubomir I. Ivanov
cc3b87c044 Clear memory allocated for event names
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-27 08:05:18 -08:00
Dirk Hohndel
720d4c65e8 Fix crash when trip info changes across remember/restore tree state
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-26 19:44:01 -08:00
Dirk Hohndel
e726c9d65c Add settings section to XML file format and store dive computer IDs
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-26 16:46:21 -08:00
Dirk Hohndel
1bd6f72d31 Different is different from the same (fix silly bug in nickname handling)
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-23 09:06:23 -08:00
Dirk Hohndel
06cd494a2f Next improvement of the nickname code
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-22 21:38:07 -08:00
Lubomir I. Ivanov
267476e3fe Add some text in statistics.c for translation
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-22 20:21:59 -08:00
Lubomir I. Ivanov
8639e14835 Make it possible to translate strings containing subscript "2"
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-22 20:21:51 -08:00
Lubomir I. Ivanov
ba223798d3 Free some nickname related memory in gtk-gui.c
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-22 20:19:51 -08:00
Lubomir I. Ivanov
b10ebbda61 Fix some small memory leaks related to gtk_tree_model_get_path()
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-22 20:15:00 -08:00
Dirk Hohndel
50aa6d1afa Imrpove the nickname handling
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-22 20:14:34 -08:00
Dirk Hohndel
8d2abc05f6 Remove nickname from divecomputer data structure
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-21 20:58:47 -08:00
Dirk Hohndel
eb3e879030 Correctly calculate OTUs when pO2 is recorded in the samples
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-20 17:42:10 -08:00
Dirk Hohndel
75f6159a04 If no dives are selected, clear the stats widget
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-20 14:47:18 -10:00
Dirk Hohndel
8bbe24f485 Show which dives are covered by the statistics
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-20 14:32:39 -10:00
Sergey Starosek
db9810cd9b Initial Russian translation for Subsurface.
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-19 21:32:57 -10:00
Linus Torvalds
e897b95b62 Prevent bleeding deco/ndl for XML files without divecomputer entries
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-19 20:07:28 -10:00
Miika Turkia
f6bd9d1a14 Convert deco info from JDiveLog to Subsurface
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-19 20:04:22 -10:00
Linus Torvalds
d8fd8b2099 Add a "View next dive computer" menu item
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-17 08:29:39 -10:00
Dirk Hohndel
a691a8e5a3 Improve visual appearance of horizontal marker lines
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-16 22:05:11 -10:00
Lubomir I. Ivanov
33ae98c96f Attempt to free plot data entries in each call to create_plot_info()
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-16 16:00:09 -10:00
Lubomir I. Ivanov
5c65ed2390 Clear associated tooltip texts when calling expose_event()
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-16 15:57:25 -10:00
Lubomir I. Ivanov
5c58e1f868 Fixed some memory leaks related to subsurface_get_conf()
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-16 15:57:11 -10:00
Lubomir I. Ivanov
28cc67c9a1 Fixed a couple of memory leaks related to the download dialog
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-16 15:56:58 -10:00
Linus Torvalds
7b457d1b5c Properly remove redundant dive computer information
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-16 15:48:32 -10:00
Linus Torvalds
459696c90c Use dive ID for matching dives during downloads
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-16 15:48:09 -10:00
Linus Torvalds
73defa9a52 Use dive computer model/ID when trying to merge dives
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-16 15:46:54 -10:00
Lubomir I. Ivanov
92c15238b6 Make sure that the user entered nickname is never truncated
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-16 07:45:08 -10:00
Dirk Hohndel
2f9960f20b Deal with some trip issues when editing dive timestamps
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-15 21:01:29 -10:00
Lubomir I. Ivanov
be9d924cf8 Reserve enough memory when storing a DC's nickname
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-15 19:53:07 -10:00
Dirk Hohndel
371ace39b5 Fix possible crash in nickname code
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-14 07:34:14 -10:00
Dirk Hohndel
713a4fcff6 Add the ability to set a nickname for a dive computer
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-13 21:33:30 -10:00