summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
AgeCommit message (Collapse)Author
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>
2013-10-06Delete code and files that are no longer usedGravatar Dirk Hohndel
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-06Trying to switch to Qt translationGravatar Dirk Hohndel
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06First steps towards removing glib dependenciesGravatar Dirk Hohndel
- 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-07-04Fix Uemis Zurich downloadsGravatar Linus Torvalds
Commit 48ba01b807cc ("Enable downloads from the UEMIS Zurich") mistakenly switched the meaning of the "force_download" argument when it moved from "struct argument_block" to being a direct argument. This fixes it right back. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-24Enable downloads from the UEMIS ZurichGravatar Dirk Hohndel
This behaves somewhat differently from the Gtk version - still needs more investigation. But at least now it's hooked in. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Remove the majority of the Gtk related codeGravatar Dirk Hohndel
- rip all Gtk code from qt-gui.cpp - don't compile Gtk specific files - don't link against Gtk libraries - don't compile modules we don't use at all (yet) - use #if USE_GTK_UI on the remaining files to disable Gtk related parts - disable the non-functional Cochran support while I'm at it Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07Fix some of the gcc-4.8 warningsGravatar Dirk Hohndel
Most of the warnings are IMHO false positives: e.g.: an enum variable is initialized in a switch statement that has a case for each possible enum value - yet gcc 4.8 warns that it could be used uninitialized; or: two variables are initialized together in the code - second one of them is previously initialized to -1 at declaration time, both are initialized in an if (second one == -1) clause - so they are guaranteed to both be initialized... I did not "fix" those as the code is actually correct. But there are three spots where it catches things that could indeed go wrong (with odd input data in one of them). This commit also adds a check to only call g_type_init() for older versions of glib as in newer ones it is deprecated. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06Separate Gtk related code from core logic: divelistGravatar Dirk Hohndel
This is simplistic & brute force: any function that touches Gtk related data structures is moved to divelist-gtk.c, everything else stays in divelist.c. Header files have been adjusted so that this still compiles and appears to work. More thought is needed to truly abstract this out, but this seems to be a good point to commit this change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03Try to capture some more potential buffer overflows caused by localizationGravatar Dirk Hohndel
A couple of these could clearly cause a crash just like the one fixed by commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in size_data_funct()"). One would append user input to fixed length buffer without checking. We were hardcoding the (correct) max path length in macos.c - replaced by the actual OS constant. But the vast majority are just extremely generous guesses how long localized strings could possibly be. Yes, this commit is likely leaning towards overkill. But we have now been bitten by buffer overflow crashes twice that were caused by localization, so I tried to go through all of the code and identify every possible buffer that could be affected by this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08Fix Uemis downloader to download all matching dive infomrationGravatar Dirk Hohndel
The Uemis SDA returns the data for each dive from several different databases. And oddly, the getDive data uses a different key than the getDivelog data. We have always compensated for that by looking up the correct key and applying the data to that dive, but unfortunately we didn't adjust the loop to correctly retrieve the getDive data for the dives that were downloaded. So depending on how big the offset between those two keys was we wouldn't get all of the necessary data. With this change we try one, calculate the offset and then restart the loop. Insane, but appears to be the only way to make this work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-04Fix minor translation tool issue in Uemis downloaderGravatar Dirk Hohndel
If any component of the suit information downloaded from the Uemis SDA is "" we would replace that by the POT information when running the software in a different locale. So only add this text (and translate this text) if it is != "". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Massive cleanupGravatar Dirk Hohndel
Mostly coding style and whitespace changes plus making lots of functions static that have no need to be extern. This also helped find a bit of code that is actually no longer used. This should have absolutely no functional impact - all changes should be purely cosmetic. But it removes a bunch of lines of code and makes the rest easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>