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>
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>
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>
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>
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>
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>
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>
Showing the depth scale all the way to the bottom of the profile plot
looks strange when there are partial pressure graphs down there. So
instead we only plot down to the next marker below the maximum depth of
the actual dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I foolishly changed visible_columns in both the (ill-named) cns branch and
master...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Conflicts:
divelist.c
gtk-gui.c
profile.c
Early in the libdivecomputer 0.3 development cycle Jef and I implemented
deco and ndl as events. That wasn't a wise design choice and we agreed to
switch this to be instead new sample types which makes much more sense
(and is much more aligned with the way we are handling them inside
Subsurface). So this commit tracks the change in libdivecomputer. Since
this happened during the development cycle there isn't a way to detect
this at compile time - so you need to make sure you have a matching
version of libdivecomputer when compiling Subsurface.
To make this easier: this commit of Subsurface requires a libdivecomputer
version that includes the libdivecomputer commit d5d44c1e0ffd "Convert
decostop / ndl to samples".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This splits the dive time, depth, pressure and temperature maxima and
minima setup from the per-dive-computer "create_plot_info()" function
into one setup function that walks _all_ the dive computers, so that we
have a global maxima and minima.
That way the graph scaling we set up will now fit the data from all dive
computers rather than just the particular one we are plotting. So if
you switch back-and-forth between computers, the scale (which is defined
by the extremes) remains the same.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We either pick the CNS reported by the dive computer at the end of the
dive, or the maximum of that and the CNS values in the samples, if any.
As usual, this column in the dive list defaults to off and it is
controlled by a setting in the tec page of the preferences.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This can cause some fun unintended side effects - especially when the dive
is part of a trip and the new date/time moves this into a different trip.
Instead, trips get split and the overall result is consistent, but a bit
unexpected.
But since this is designed to help people right after a dive import in
case the clock on the dive computer was wrong, my guess is this won't ever
be a problem for actual users.
Fixes ticket 18
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows you to open the preference dialog, play with settings and see
their effect right away. Press OK and you keep them, press Cancel and you
are back to the previous state. As it should be.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.
Fixes#21
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add info of the used tanks, which isn't displayed by the
dive plot, with a new function.
The relative width and height are fixed in print(), so the function needs:
- Modify the font size depending on the number of tanks.
- As it uses translations, return to the original coords when ends.
Modify print() acordingly with the new function.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create a function show_dive_header() and show_dive_notes() as a first step
to introduce other infos in diferent funcs.
Modify print() acordingly to the new funcs.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were responding to the wrong Quit signal on MacOS. The one we picked
was the one that basically told us "it's too late to stop me, I'm
quitting". I switched this to the one asking "should I prevent the app
from quitting" and now we can indeed cancel the Quit, regardless which
method was used to close the app.
Also removes to unused variables.
Fixes#22
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead provide a scale on the right in a highly transparent grey and rely
on the tooltip available with mouse-over to pinpoint the value at certain
spots with much better accuracy.
Fixes#30
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some dive computers appear to tell us the gas used in a gaschange event
right at the beginning of the dive. We arbitrary have a cut-off that says
"a gas change in the first 30 seconds shouldn't get a marker".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Regardless what the dive computer tells us, don't believe that pO2 was
higher than the ambient pressure. This gives much more realistic values.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This now takes the He percentage into account when matching tanks. Given
the encoding of fO2 and fHe in the GASCHANGE2 event, we can simply mask
and shift as if we have a GASCHANGE2 event and things will automatically
work correctly for the regular GASCHANGE event.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows things to work for dive computers like the OSTC that give us
setpoint information in the sample, but not constant pO2 readings.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Tec divers seem to like a little bit more precision - and the dive
computers certainly provide it (or we can calculate it).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).
Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.
At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We check the pointers that are part of this structure for NULL before
accessing them - but that means we need to zero out the structure for this
to work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When analyzing the buffer that is handed to the first_object_id function
we carefully check to make sure that we don't read past the end of the
input buffer but there was still one code path that could have us do just
that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous commit 871d7ae0cdf5 "Add option to make ceiling visually
stand out more in the profile" contained not one but two stupid cut and
paste bugs. I cannot begin to explain how this could have worked when I
first tested it.
Reported-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While having the background "come down" seemed like a good visualization
of the ceiling, some divers appear to prefer something more dramatic. This
adds an option to the Tec Settings to have the ceiling shown in red
instead of the default background color.
Suggested-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way they don't clash with the dive computer model information that
was added by commit a23ec27ca7bb "Add dive computer name to the dive
plot".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and then allocate just the plot-info entry array dynamically.
We want to have a longer lifetime for the basic plot_info data
structure, because we want to do computer selection and maximum
time/depth/temperature computations *before* we start plotting anything,
and before we allocate the plot entry array.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I want to have some way to show multiple dive computers, so start off by
adding the name of the current one. So if we change dive computers,
we'll see it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
From 178a3f0d6d5112f76943fec5f8c1c1f3b173a7f4 Mon Sep 17 00:00:00 2001
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 7 Dec 2012 09:34:18 -0800
Subject: [PATCH 2/2] Tune the dive joining surface event insert code
So this makes us do surface events only if the samples are more than one
minute apart, and are shallow enough (randomly selected at 5m).
We can add more heuristics. Maybe we should compare the 1-minute sample
time limit of the previous sample to the time to the sample before that:
if some computer (or manually entered dive) has a long time between
*all* samples, we'd make the cut-off time longer.
Baby steps.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This doesn't really change the logic of the merging, but it does mean
that the end result tends to be less unexpected: when downloading dives
that end up being merged with pre-existing dives (because you have
multiple dive computers, for example), the newly downloaded dive data
will tend to be appended to the old dive data, rather than showing up
first.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of just taking the vendors and products for the supported
divecomputers in the order libdivecomputer provides them to us we sort
them as we add them to our list of lists. While doing this we also track
the longest product name and try to make sure that the combobox for the
product is set to a fixed width that's wider then the longest product
name.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Loading these two XML files created a divelist with two trips that each
started at the same time but that were NOT linked together (because the
code in insert_trip detected that they started at the same time). Since
the trips were not linked together, trying to then merge those two trips
from the UI got us into an infinite loop, trying to move a dive from one
trip into the same trip (as the code couldn't find the trip that wasn't
linked into the dive_trip_list).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code did not move the dives that are part of the second trip
to the first trip (and forgot to keep the 'better' notes as well).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Handle the case where we have no divecomputer information.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>