aboutsummaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
AgeCommit message (Collapse)Author
2015-06-24Uemis downloader: create the req.txt file if it went missingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22Better error handlingGravatar Dirk Hohndel
Most of these will likely have no big impact, but it's better not to just ignore them as they could lead to crashes. Uemis downloader: if lseek fails, return 0 Uemis downloader: consistently check for failure to open req.txt Zip file handling: dup could fail Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Uemis downloader: open returns -1 on errorGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Fix a number of resource leaksGravatar Dirk Hohndel
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-05-21Merge branch 'v4.4-branch' into newmasterGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30Uemis downloader: better error reportingGravatar Dirk Hohndel
Tell the user if Subsurface can't write to the req.txt file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-30Uemis downloader: adjust the threshold for stopping downloadsGravatar Dirk Hohndel
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-30Uemis downloader: download additional dive data after every batchGravatar Dirk Hohndel
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-30Uemis downloader: get the right values set before bailingGravatar Dirk Hohndel
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-30Uemis downloader: even with an empty divelist, check where to startGravatar Dirk Hohndel
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-30Uemis downloader: allow continuing download by clicking RetryGravatar Dirk Hohndel
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-30uemis-downloader - arguments in wrong orderGravatar Marcos CARDINOT
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-21Uemis downloader: adjust the threshold for stopping downloadsGravatar Dirk Hohndel
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-21Uemis downloader: download additional dive data after every batchGravatar Dirk Hohndel
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-21Uemis downloader: get the right values set before bailingGravatar Dirk Hohndel
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-20Uemis downloader: even with an empty divelist, check where to startGravatar Dirk Hohndel
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-20Uemis downloader: allow continuing download by clicking RetryGravatar Dirk Hohndel
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-20Uemis downloader: avoid double freeGravatar Dirk Hohndel
A well intentioned attempt in commit ff860b3c044a ("uemis-downloader - resource leaks") to fix resource leaks actually introduced a bug. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-24Clean req.txt file pathGravatar Claudiu Olteanu
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-19uemis-downloader - arguments in wrong orderGravatar Marcos CARDINOT
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-19uemis-downloader - resource leaksGravatar Marcos CARDINOT
Some resources are not being freed. Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Change UEMIS infrastructure to use dive sitesGravatar Dirk Hohndel
Which is actually much more natural to the way the UEMIS stores things... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-25Typos: capitalization in uemis-downloader.cGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09Now use our table when downloading from the dive computerGravatar Dirk Hohndel
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>
2014-11-25Match agreed captalisation styleGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12Teach uemis downloader about downloading into private tripsGravatar Linus Torvalds
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-12Pass the whole 'device_data_t' to the uemis downloaderGravatar Linus Torvalds
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-08-17Uemis downloader: show the timestamp for dives while downloadingGravatar Dirk Hohndel
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-05-20Migrate code to for_each_dive and for_each_dcGravatar Anton Lundin
[Dirk Hohndel: this overlapped with my commit 09e7c61feeea ("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-20Consistently use for_each_dive (and use it correctly)Gravatar Dirk Hohndel
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-13rename 'get_dive_by_diveid' to 'get_dive_by_uemis_diveid'Gravatar Tomaz Canabrava
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-12Uemis downloader: fix corner caseGravatar Dirk Hohndel
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-07Fix stupid typoGravatar Dirk Hohndel
Yeah, that doesn't work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Uemis downloader: handle more corner casesGravatar Dirk Hohndel
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-01Fix Uemis SDA downloadGravatar Dirk Hohndel
Stupid typo in commit e1a1c218 broke the Uemis download. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06Don't leak file descriptor in the error caseGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05Uemis downloader: don't ignore return values from fs operationsGravatar Dirk Hohndel
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-03Remove pointless assignmentsGravatar Dirk Hohndel
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-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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-12Use "rint()" instead of rounding manually with "+ 0.5"Gravatar Linus Torvalds
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-01-16Convert the C code to using stdbool and true/falseGravatar Anton Lundin
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>
2013-12-19Files: use the new opendir() wrapperGravatar Lubomir I. Ivanov
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-19Files: use the new open() wrappersGravatar Lubomir I. Ivanov
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-11uiemis-downloader.c: fix preceding limit checkGravatar Lubomir I. Ivanov
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-11Plug potential memory leak in process_raw_bufferGravatar Anton Lundin
Free temporary buffer before returning. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09Don't access a NULL pathGravatar Dirk Hohndel
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-07Fix stupid off by one errorGravatar Dirk Hohndel
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-10-09Next step towards working translationsGravatar Dirk Hohndel
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-07Next round of code removal and header cleanupGravatar Dirk Hohndel
None of this is used anywhere Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Make Windows cross compile againGravatar Dirk Hohndel
But this is broken as the utf8/utf16 conversions in windows.c are gone without glib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>