Commit graph

94 commits

Author SHA1 Message Date
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Dirk Hohndel
00b1469658 Merge branch 'v4.4-branch' into newmaster
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-21 13:45:25 -07:00
Dirk Hohndel
f647e3cf1e Uemis downloader: better error reporting
Tell the user if Subsurface can't write to the req.txt file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 15:33:16 -07:00
Dirk Hohndel
dad7181eff Uemis downloader: adjust the threshold for stopping downloads
A complete batch of divelog and dive data takes about 20% of the available
space (depending on how long those dives are). This is a hack and I can
see this potentially going wrong, but the alternative is to be even more
conservative and that has its own set of problems as it causes us to need
more "unplug, wait, plug in again and restart" cycles.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:44:11 -07:00
Dirk Hohndel
7643d4ea7b Uemis downloader: download additional dive data after every batch
This looks like a fairly big change but it mostly just moves a block of
code inside an earlier loop and adjust a few variables around it.

The completely broken and insane Uemis download protocol distributes data
across different "databases" on the dive computer. The "divelogs" are
downloaded in batches of 10 (most of the time), and with this change every
time one of those batches is downloaded we straight away get the matching
"dive" entries.

Hopefully this will avoid having the download abort (for lack of space)
before all components are loaded.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:44:02 -07:00
Dirk Hohndel
122111402d Uemis downloader: get the right values set before bailing
This caused us to not read the auxiliary information for up to the last
ten dives that were downloaded from the SDA.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:43:49 -07:00
Dirk Hohndel
c2c574aad5 Uemis downloader: even with an empty divelist, check where to start
If the user hits retry from within the download dialog, the dive list
might still be empty but we still have to look for the best point to
restart.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:43:31 -07:00
Dirk Hohndel
8bbb3dfe42 Uemis downloader: allow continuing download by clicking Retry
When we run out of space in the Uemis filesystem we return an error. The
user could reasonably unplug the SDA, insert it again and then retry to
continue the download (that's what we tell them to do). In that case we
need to make sure we start at the correct dive otherwise the same dives
keep getting downloaded over and over again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:42:42 -07:00
Marcos CARDINOT
3255a8e607 uemis-downloader - arguments in wrong order
method's signature: void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude)

Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30 07:41:03 -07:00
Dirk Hohndel
f33a11bc8a Uemis downloader: adjust the threshold for stopping downloads
A complete batch of divelog and dive data takes about 20% of the available
space (depending on how long those dives are). This is a hack and I can
see this potentially going wrong, but the alternative is to be even more
conservative and that has its own set of problems as it causes us to need
more "unplug, wait, plug in again and restart" cycles.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-21 21:18:43 -07:00
Dirk Hohndel
df9f233eed Uemis downloader: download additional dive data after every batch
This looks like a fairly big change but it mostly just moves a block of
code inside an earlier loop and adjust a few variables around it.

The completely broken and insane Uemis download protocol distributes data
across different "databases" on the dive computer. The "divelogs" are
downloaded in batches of 10 (most of the time), and with this change every
time one of those batches is downloaded we straight away get the matching
"dive" entries.

Hopefully this will avoid having the download abort (for lack of space)
before all components are loaded.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-21 20:29:20 -07:00
Dirk Hohndel
7101386cb6 Uemis downloader: get the right values set before bailing
This caused us to not read the auxiliary information for up to the last
ten dives that were downloaded from the SDA.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-21 19:31:05 -07:00
Dirk Hohndel
136282f88a Uemis downloader: even with an empty divelist, check where to start
If the user hits retry from within the download dialog, the dive list
might still be empty but we still have to look for the best point to
restart.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-20 23:28:44 -07:00
Dirk Hohndel
79f15e913b Uemis downloader: allow continuing download by clicking Retry
When we run out of space in the Uemis filesystem we return an error. The
user could reasonably unplug the SDA, insert it again and then retry to
continue the download (that's what we tell them to do). In that case we
need to make sure we start at the correct dive otherwise the same dives
keep getting downloaded over and over again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-20 23:28:04 -07:00
Dirk Hohndel
3fb5f84e11 Uemis downloader: avoid double free
A well intentioned attempt in commit ff860b3c04 ("uemis-downloader -
resource leaks") to fix resource leaks actually introduced a bug.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-20 21:35:54 -07:00
Claudiu Olteanu
c46bbf3b5e Clean req.txt file path
This patch cleans the path allocated for req.txt file path.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-24 09:46:46 -07:00
Marcos CARDINOT
b31e192da1 uemis-downloader - arguments in wrong order
method's signature: void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude)

Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-19 13:48:21 -07:00
Marcos CARDINOT
ff860b3c04 uemis-downloader - resource leaks
Some resources are not being freed.

Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-19 13:46:37 -07:00
Dirk Hohndel
d032c2a5c5 Change UEMIS infrastructure to use dive sites
Which is actually much more natural to the way the UEMIS stores things...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:45:47 -08:00
Lubomir I. Ivanov
5e7be3000f Typos: capitalization in uemis-downloader.c
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-25 07:17:04 -08:00
Dirk Hohndel
7357633905 Now use our table when downloading from the dive computer
We pass a different table to libdivecomputer (and the uemis code) and have
that table filled. And then we simply copy the dives from that table into
the real dive_table when the user accepts the download.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Tim Wootton
93d59c22d7 Match agreed captalisation style
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:57:33 -08:00
Linus Torvalds
b47e0658cf Teach uemis downloader about downloading into private trips
Now that we pass in the full device_data_t information, we can look at
the "create_private_dive" flag and decide just how to record newly
downloaded dives properly.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:35:45 -04:00
Linus Torvalds
a7e1e7fee1 Pass the whole 'device_data_t' to the uemis downloader
Not only does it make it look more like the libdivecomputer downloaders,
but the uemis downloader needs it in order to support all the flags we
have.  Notably "download into private trip".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:34:46 -04:00
Dirk Hohndel
8856ccea10 Uemis downloader: show the timestamp for dives while downloading
If we can easily decode the start time of the dive that is currently being
parsed (i.e., if the information doesn't happen to straddle a block
boundary) then show that in the dialog's progress bar.
Make the explanatory text before it shorter so there's enough space.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-17 16:44:43 -05:00
Anton Lundin
05d9cc409c Migrate code to for_each_dive and for_each_dc
[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
	       use for_each_dive (and use it correctly)") so I took the
	       pieces that I had missed]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 11:51:40 +09:00
Dirk Hohndel
09e7c61fee Consistently use for_each_dive (and use it correctly)
The way the macro is written there is no need to test the dive against
NULL before dereferencing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 06:37:19 +09:00
Tomaz Canabrava
e1971e9425 rename 'get_dive_by_diveid' to 'get_dive_by_uemis_diveid'
A bit longer, but we had a function named get_dive_by_diveid
and another one named getDiveByDiveid that did completely
different things, it was too easy to hit the wrong one..

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:21:35 +09:00
Dirk Hohndel
f692c39ac7 Uemis downloader: fix corner case
When we first get an invalid dive info and then, once we decremented the
offset, get a valid one but for the wrong dive and then try to calculate
the correct offset, we need to keep the existing offset in mind.

What a horrid design. Thanks, UEMIS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-12 00:45:52 -07:00
Dirk Hohndel
704c2cb225 Fix stupid typo
Yeah, that doesn't work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 11:15:39 -07:00
Dirk Hohndel
83f0aefa5c Uemis downloader: handle more corner cases
After receiving another report of the Uemis downloader failing I tried to
make it more robust when unexpected things happen. The data structures
returned by the SDA are rather convoluted and not all relationships are
fully understood.

This makes sure we don't try to parse invalid dive entries, we only read
dive entries if we actually got new divelog entries, we only read dive
sites if at least one was referenced and we use a much more patient (and
hopefully, much more robust) algorithm to figure out which dive entry
corresponds to the new divelog entries.

What a pain.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 14:36:55 -07:00
Dirk Hohndel
c71d258024 Fix Uemis SDA download
Stupid typo in commit e1a1c218 broke the Uemis download.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 14:14:50 -07:00
Dirk Hohndel
20d9cf19d7 Don't leak file descriptor in the error case
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06 14:11:59 -08:00
Dirk Hohndel
e1a1c218c4 Uemis downloader: don't ignore return values from fs operations
In most cases the existing code might have done the right thing, but some
of the hard to reproduce errors might actually stem from the fact that we
have intermittend fs errors. Maybe this addresses things?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05 18:54:39 -08:00
Dirk Hohndel
d24d2288f3 Remove pointless assignments
tissue_tolerance wasn't used after it was assigned.
type was overwritten after it was assigned.
serial was overwritten after the last /= 100.
event is assigned in the for loop.
clear isn't used after the assignment

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 21:40:56 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Anton Lundin
33391a77e9 Convert the C code to using stdbool and true/false
Earlier we converted the C++ code to using true/false, and this converts
the C code to using the same style.

We already depended on stdbool.h in subsurfacestartup.[ch], and we build
with -std=gnu99 so nobody could build subsurface without a c99 compiler.

[Dirk Hohndel: small change suggested by Thiago Macieira: don't include
               stdbool.h for C++]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:34:50 +07:00
Lubomir I. Ivanov
a351bbde24 Files: use the new opendir() wrapper
This is a separate patch because it required more changes
and branches due to how opendir() works on win32
with the separate struct type _WDIR and the according _w...
methods for it.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:27 -08:00
Lubomir I. Ivanov
fbff6127ac Files: use the new open() wrappers
Adds use of everything from the new wrappers(), but the
opendir() one.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19 07:28:21 -08:00
Lubomir I. Ivanov
fe882ea58e uiemis-downloader.c: fix preceding limit check
next_segment():
The iterator limit check (i < size - 1) should precede
the indexing (buf[i]).

Reported by the program cppcheck.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 16:29:58 +01:00
Anton Lundin
ef3a51f6ee Plug potential memory leak in process_raw_buffer
Free temporary buffer before returning.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 03:13:30 +01:00
Dirk Hohndel
7ba5566073 Don't access a NULL path
This can happen if the Uemis is not correctly connected, but the user
still has the path set (as default DC most likely) and tries to start a
download.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 15:56:53 +09:00
Dirk Hohndel
9052035548 Fix stupid off by one error
This was missing the space for the \0 character so the paths were one byte
short.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-07 13:06:06 +09:00
Dirk Hohndel
193d20c479 Next step towards working translations
This may seem like a really odd change - but with this change the Qt tools
can correctly parse the C files (and qt-gui.cpp) and get the context for
the translatable strings right.

It's not super-pretty (I'll admit that _("string literal") is much easier
on the eye than translate("gettextFromC", "string literal") ) but I think
this will be the price of success.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 22:51:59 -07:00
Dirk Hohndel
2627ea927d Next round of code removal and header cleanup
None of this is used anywhere

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07 16:55:43 -07:00
Dirk Hohndel
475e058d40 Make Windows cross compile again
But this is broken as the utf8/utf16 conversions in windows.c are gone
without glib.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 21:04:25 -07:00
Dirk Hohndel
34db6dc2be Delete code and files that are no longer used
Most of this is Gtk related, some of it is helpers that we don't need
anymore. I love the diffstat.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 17:32:50 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00