Commit graph

1506 commits

Author SHA1 Message Date
Dirk Hohndel
3f261f56f3 Remove some unnecessary variable initializations
Not really bugs, just wasted. They clutter up the output of static
analysis with cppcheck.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 16:28:37 -08:00
Dirk Hohndel
3ab27e65e8 Removed unused structure definition in deco.c
Leftover from the initial implementation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 16:05:59 -08:00
Dirk Hohndel
39a79e0c46 Fix memory leak in set_dc_nickname
remember_dc() already does a strdup of the nickname.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 15:58:09 -08:00
Dirk Hohndel
27d51ce1d7 Fix potential uninitialized variable access
There are paths through this function that reach the comparison at the end
of it without trip_a and/or trip_b being initialized.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 15:56:34 -08:00
Henrik Brautaset Aronsen
b696c61389 Move get_units() to prefs.c
get_units() returns the current unit preference, thus it
belongs in prefs.c rather than gtk-gui.c

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 07:30:37 -08:00
Lubomir I. Ivanov
ff5a8b0650 windows.c: Add unicode support in subsurface_launch_for_uri()
subsurface_launch_for_uri() requires unicode support, using
ShellExecuteW() and also the passed UTF-8 buffer has to be translated
to UTF-16 beforehand. Once the ShellExecuteW() is done we release
the UTF-16 allocation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 07:29:26 -08:00
Lubomir I. Ivanov
7bb6108c34 Small fix for a possible crash in divelist.c
divelist.c:copy_tree_node():
pass the pointer "icon" to gtk_tree_store_set()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25 07:29:19 -08:00
Dirk Hohndel
29ae8cb131 Don't set a default filename when called with multiple filenames
The behavior is just too illogical - it's too easy to unintentionally
overwrite a file this way. The default filename is set if we have exactly
one filename on the command line or if we we open the default file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 20:01:18 -08:00
Linus Torvalds
7c26432186 Don't mark divelist changed for automated merges after all
The intention was good, and this was added in commit 4982389ca7 ("Fix
setting of the dive_table.preexisting logic"), but it turns out to not
be that great idea after all.

So the thinking is that merging two dives clearly changes the dive list,
and it really does.  At the same time, because it's an automated merge,
if you re-read the old XML file, you'll get it done again, so saving the
changes doesn't really *matter*.

And it turns out to be somewhat annoying with test dives: we have

 - dives/test23.xml:
    <dive number='23' tripflag='INTRIP' date='2011-12-02' time='6:00:00' duration='30:00 min'>
 - dives/test25.xml:
    <dive number='26' date='2011-12-02' time='6:00:00' duration='30:00 min'>

that merge automatically if you run subsurface on all the test dives
together.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 19:53:54 -08:00
Linus Torvalds
cb0d6d6eaf Fix overly complicated and fragile "same_cylinder" logic
The plot-info per-event 'same_cylinder' logic was fragile, and caused
us to not print the beginning pressure of the first cylinder.

In particular, there was a nasty interaction with not all plot entries
having pressures, and the whole logic that avoid some of the early
plot entries because they are fake entries that are just there to make
sure that we don't step off the edge of the world. When we then only
do certain things on the particular entries that don't have the same
cylinder as the last plot entry, things don't always happen like they
should.

Fix this by:

 - get rid of the computed "same_cylinder" state entirely. All the
cases where we use it, we might as well just look at what the last
cylinder we used was, and thus "same_cylinder" is just about testing
the current cylinder index against that last index.

 - get rid of some of the edge conditions by just writing the loops
more clearly, so that they simply don't have special cases. For
example, instead of setting some "last_pressure" for a cylinder at
cylinder changes, just set the damn thing on every single sample. The
last pressure will automatically be the pressure we set last! The code
is simpler and more straightforward.

So this simplifies the code and just makes it less fragile - it
doesn't matter if the cylinder change happens to happen at a sample
that doesn't have a pressure reading, for example, because we no
longer care so deeply about exactly which sample the cylinder change
happens at. As a result, the bug Mika noticed just goes away.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 19:12:28 -08:00
Dirk Hohndel
002fe45dfd Try to automate the version number used in the windows installer
This adds a Makefile target to create the .nsi file from a template and to
hopefully create the right strings to magically get the correct version
strings in the Windows installer

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 15:58:35 -08:00
Dirk Hohndel
87798b328e Add 2013 to the copyright line
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 15:11:13 -08:00
Linus Torvalds
f36693322c Include git revision in version number
This makes sure that it's easy to tell from the about box whether this is
a released version or a development build.

If it is compiled at the exact location of the tag, "git describe
--tags" will just return the tag-name. Otherwise it will return
something like this

    v2.1-393-ge03f31525aab

which means "v2.1 plus 393 commits, git SHA1 of tip is e03f31525aab",
which is a nice combination of git-readable (only the actual SHA1
matters) and human-readable (393 commits on top of v2.1).

And if you don't build from git sources, and don't have git installed,
it falls back on the old "v$(VERSION)" string.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 15:08:35 -08:00
Jan Schubert
50d0391dfb Centralization for Kelvin and Standardization to milliKelvin
This centralizes all occurrences of Kelvin to dive.h and standardizes all
usages to milliKelvin.

[Dirk Hohndel: renamed the constant plus minor white space cleanup]

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 15:00:52 -08:00
Dirk Hohndel
67d8891af5 Slight change to the parser to avoid false posititives
The webservice output uses 'name' as the tag for the dive location. This
was added to the parser as unqualified tag and without this change
test24.xml was suddenly recognized as a dive (the parser was triggering on
the program 'name' attribute). Name should only be recognized as a dive
location if it is indeed a child of dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 14:44:29 -08:00
Dirk Hohndel
51880785af Only display temperature graph if we have temperature data
Commit b625332ca5ff "Display even constant temperature graph" was a little
too aggressive. If we have no temperature data at all it caused us to plot
a temperature line for absolute zero...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 14:12:17 -08:00
Dirk Hohndel
1bcc8dd991 Add test dive for constant temperature
Making sure that this doesn't cause divisions by zero and that the scaling
and positioning doesn't get messed up by it (right now it doesn't look
great).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 13:19:16 -08:00
Miika Turkia
60d1c09a14 Display even constant temperature graph
Dive profile does not display the temperature graph, if we have a
constant temperature (e.g. only one reading at the start of the dive).
This patch draws the temperature graph even if max and min temperatures
are the same.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 13:14:53 -08:00
Dirk Hohndel
55296e9dad Remove unused variable for unit name in statistics calculations
The code was incorrect - and completely unnecessary.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 13:10:04 -08:00
Henrik Brautaset Aronsen
e3088930ab Use actual min and max temperatures in statistics.
The statistics page only used each dive's "watertemp" attribute,
regardless of actual higher/lower temperatures in the samples.  By
finding the actual max/min temperatures, the statistics page utilize
more "real" data, and look better even on single dives.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 13:00:03 -08:00
Linus Torvalds
b8efe709a8 Remove saving of dive computer nicnames in system config
We save the (more complete) dive computer information in the XML file
with serial numbers and firmware version if we know about them, so using
a complicated string in the system config was redundant and confusing.

So remove that code.

NOTE! Since the dive computer nicknames are now only saved if the XML
file is saved, we also mark the dive list "changed" when we edit the
nicknames.  That way we'll be prompted to save things before exiting,
even if we don't actually edit any actual dive data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 12:59:36 -08:00
Linus Torvalds
52050fdc92 Save all dive computer nicknames - whether used or not
We used to save dive computer information only if that dive computer was
actually used in any of the dives we saved.  But we can simplify the
code if we just always save any dive computers we know about.  And it
does allow for some usage cases where you have nicknames for other
peoples computers that you may not actively use, but you want to see if
you end up loading multiple XML files in one go.

So there's just no compelling reason to not just save all the info we
have.  And this will make it less painful to remove the "use system
config for dive computer nicknames", because you can also use this to
continue to gather dive computer info in a separate XML file if you want
to.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 12:59:31 -08:00
Lubomir I. Ivanov
9acb52b9ee Store/Retrieve last entered webservice UID to/from config.
We use subsurface_set_conf() subsurface_get_conf() to store
and recall the prefered UID for the download.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 12:07:45 -08:00
Dirk Hohndel
100c400809 Merge branch 'webservice-import'
Update maxdepth / duration that have moved into the divecomputer
structure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 12:05:16 -08:00
Henrik Brautaset Aronsen
d1262848d8 Fix compile error in planner.c
Linus seems to have been too eager in the dc refactoring: a diveplan
doesn't have a divecomputer.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 08:47:34 -08:00
Linus Torvalds
4982389ca7 Fix setting of the dive_table.preexisting logic
The 'preexisting' value is used for downloading dives: we want to add
new dives but, but then compare those new dives against the
preexisting ones before we start sorting things and possibly merging
them.

However, the value was only updated sporadically, resulting in it
having stale information in it.  Which would cause problems
particularly if you deleted dives, so that the preexisting value would
point past the actual existing values!

So just update it unconditionally in dive_list_update_dives(), which
anything that changes the dive list is supposed to call in order to
display the changes anyway.

Also, just for safety, when removing a dive, put NULL in the last dive
table location.  Nobody should ever access past the end anyway (this
is enforced by 'get_dive()') but there are places that access the dive
list table directly, and the libdivecomputer download was one of
those.  No reason to leave stale dive pointers possibly around for
uses like that.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 13:37:02 -08:00
Linus Torvalds
413b9026dd Fix temperature rounding issues
Temperatures can actually be negative, which means that rounding by
adding 0.5 and casting to 'int' is not correct.

We could use '(int)(rint(val))' instead, but the only place we care
about might as well just print out the floating point representation
with a precision of two digits instead.  So if you have a dive computer
that gives you the precision, you might see '3.5˚C' as the temperature.

Remove the helper functions that nobody uses and that get the rounding
wrong anyway.

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:39 -08:00
Linus Torvalds
aac44f9b07 Remove XML parsing special case temperature code
We had various hacky historical artifacts in our XML parsing, partly
from our legacy of parsing integer and floating point data separately
(we used to recognize certain import format differences based on whether
the data was in a floating point or integer format).  And partly from
trying to do a good job of importing crap from other dive log software.

Anyway, that actually meant that we refused to parse negative numbers,
and we ignored temperatures of zero because some diving log would do
that for missing values.

Both of these actually bit us when parsing our native XML.  Of course,
only crazy ice divers would ever notice.

Noticed by Henrik Brautaset Aronsen.

Reported-acked-and-tested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:37 -08:00
Linus Torvalds
b6c9301e58 Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure.  They are filled in by the dive
computer, and normally not edited.

NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details.  So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:33 -08:00
Dirk Hohndel
3e5a508b15 Ensure each dive has its own copy of the location text (UEMIS importer)
Since multiple dives can reference the same divesite we need to do the
strdup when the value gets assigned, not when it gets passed into the
helper function.

This also validates the location string as on my divecomputer there is an
invalid divespot 0 that has a corrupted UTF8 string as location name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 11:57:00 -08:00
Dirk Hohndel
c521aec884 Import and merge GPS data from the webservice
Dive locations marked (and named) via the companion app are downloaded
from the webservice, parsed and merged with the existing dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 11:53:42 -08:00
Lubomir I. Ivanov
b1db60ba47 divelist.c:icon_click_cb(): check if a GtkTreePath is found
In icon_click_cb() we need to check if a correct GtkTreePath is found
(using gtk_tree_view_get_path_at_pos()) before requesting a GtkTreeIter
for it.

Without this patch a bug is reproducible, where the user may click
outside of the GtkTreeView entries, but still in the GtkTreeView -
e.g. when only one entry is available.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 08:49:10 -08:00
Amit Chaudhuri
c149921df4 Fix crash when applying a non-edit of nicknames
As reported by Henrik, there was a crash lurking in edit_dc_nickname code.
Invoking the dialog and selecting apply without changes exposed it neatly.

This is a one line fix.

Signed off by Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 03:50:42 -08:00
Linus Torvalds
e618a245b9 Use proper helper functions for dive location and for_each_dive
This makes the code use the "dive_has_location()" function rather than
check the longitude and latitude directly.

It also uses "for_each_dive()" rather than open-coding it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 22:26:12 -08:00
Linus Torvalds
1f3024152c Satellite icon diet
[Dirk Hohndel: converted to png and .h]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 22:25:03 -08:00
Dirk Hohndel
714d5e2443 Fix crash when clicking on icon column in trip header entries
Silly oversight.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 20:44:27 -08:00
Linus Torvalds
9e0a316812 libdivecomputer: add air temperature fixups for Suunto
libdivecomputer doesn't actually seem to support air temperature
reporting at all, but at least for Suunto dive computers the air
temperature is recorded as the temperature for the first sample.

So since we already have vendor-specific libdivecomputer hacks, let's
just add that one as a rule.  It may be that other divecomputers do this
too, so this adds it as a generic concept - it's just that right now the
flag for "air temperature in first sample" is only set for Suunto dive
computers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 20:15:10 -08:00
Linus Torvalds
acd6dff4a8 Improve on the "prefer downloaded" dive computer model
It used to be that when you checked the "Prefer downloaded" checkmark,
we'd throw away *any* old dive computer data.  That was good, because it
allowed us to start from a clean slate when you had some old subsurface
data with questionable dive computer data.

However, it was a bit extreme, and it's really not what you want if you
already have (good) dive computer data from other dive computers.

So this modifies the logic a bit.  Instead of throwing away all old dive
computer data, the "Prefer downloaded" checkmark now means:

 - the newly downloaded data becomes the "primary" dive computer data
   (ie the first in the list)

 - if there was old dive computer data that *could* have been from this
   new dive computer (ie it didn't have model information, or it had a
   matching model but no device ID data), we throw that away

 - but any existing dive computer data from other dive computers is left.

This seems to be much closer to what we really would want for a new
"preferred" download.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 20:15:06 -08:00
Linus Torvalds
20ad07d4ac Fix suunto serial number confusion in libdivecomputer
libdivecomputer has started giving the Suunto serial numbers in a
different format, which means that we have the same device with two
different serial numbers, and then we need two different ways of turning
the numerical entity into a string.

Look at the number pattern to see figure out which version of the format
it is that libdivecomputer is reporting, and turn it back into the
original format so that we can reliably give the right string for it.
This also mean sthat the device ID stays the same regardless of
libdivecomputer version.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 20:15:01 -08:00
Dirk Hohndel
713c845e5a Add GPS icon to the location column for dive sites where we have GPS data
This replaces the really lame "italics text" from commit abe810ca1a29
("Mark locations that have GPS location data attached") with a marginally
less lame GPS icon.There's a reason why I am not making a living as
graphics artist. But I think this is a huge step forward from what we had
before...

The satellite.svg file is very loosely based on a different icon that I
found as public domain here http://www.clker.com/clipart-30400.html.
From that I created the PNG and then that was converted into the
GdkPixdata via gdk-pixbuf-csource; a rule for that was added to
the Makefile but commented out as I don't know if this tool will always be
available in the path. Having this icon included in the sources avoids
locating yet another icon file.

Better icons are certainly welcome!

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22 20:11:13 -08:00
Henrik Brautaset Aronsen
c02f1b88ab Add libsoup and osm-gps-map to Mac build instructions.
Also force py27-pygtk to use the quartz variant, since MacPorts
doesn't have variant dependency resolutions.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-21 09:52:03 -08:00
Dirk Hohndel
9e13655854 White space and coding style adjustments for gps.c
It's just nicer this way.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 20:28:37 -08:00
Dirk Hohndel
97ce7a3763 Fix map scrolling
The osm-gps-map default is to scroll-and-recenter around the mouse position.
That is BAT SHIT CRAZY. So this implements our own scroll handling instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 20:26:15 -08:00
Dirk Hohndel
3d248682ee Mark locations that have GPS location data attached
This is rather lame - we simply turn the location text into italics for those
dives where we have GPS location data. Underlining might be more natural, but
Gtk plays games with the underline attribute if the mouse hovers over text.

Ideally I would have prefered a little GPS logo next to the location text - but
I couldn't figure out how to do that without writing my own cell renderer which
seemed total overkill.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 17:32:55 -08:00
Dirk Hohndel
980ba9cb50 Reuse map windows
Instead of opening a new window / new map for every dive site we now have only
two windows / maps. One for the overview of all the dive sites, the other one
that is used to show the map for a specific dive site.

This also switches the position preference from CENTER to MOUSE - this way it's
less likely that the two map windows will be drawn exactly on top of each
other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-20 17:07:07 -08:00
Dirk Hohndel
4ea90fcb0b Add modules file for building prerequisites on MacOS X
This should allow the user to build osm-gps-map with jhbuild (all other
required components are already build by the jhbuild default modules).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-19 16:19:11 -08:00
Dirk Hohndel
5c2d1af5ec Add CFLAGS to build rule for webservice.o
Otherwise it won't compile on MacOS X

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-19 16:06:24 -08:00
Dirk Hohndel
ed11851ae3 Improve handling for old XML files in Uemis downloader
In order to work in the most expected ways for people who have used
a version of Subsurface that didn't store the deviceid in the divecomputer
we relax the testing for when a divecomputer entry is assumed to match the
current divecomputer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18 13:01:08 -08:00
Dirk Hohndel
0a8038dba4 Consistently use uint32_t for deviceid
There were a handful of places that incorrectly used signed values for the
deviceid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18 12:58:45 -08:00
Dirk Hohndel
62c4ec20c7 Fix potential crash with old XML files
A file with no divecomputer section in a dive can trigger a SEGV as cur_dc
could be NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18 10:39:25 -08:00