summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
AgeCommit message (Collapse)Author
2015-12-06Uemis downloader: handle yet another corner caseGravatar Dirk Hohndel
If we looking for dive details and are trying to guess the offset between object_id and logfilenr, we need to treat logfilenr 0 as special - it means we read past the end of the list of stored dives and need to walk backwards. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: ignore leading junk in the dataGravatar Dirk Hohndel
One user's debug log shows valid data, only not in the format we've seen before (with the response starting with '{'). Instead he gets a repeat of the second word in the response to processSync prepended to the expected output. So let's skip the data until the first '{'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: don't leak memoryGravatar Dirk Hohndel
Don't just clear out the buffer pointer, free the memory, first. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: more debug outputGravatar Dirk Hohndel
Once again compile time enabled. I guess it would be nice to turn this into a logfile (just like we have with the libdivecomputer backends). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: recover if dive info is completely missingGravatar Dirk Hohndel
I user had a Uemis that had a dive log entry for a certain internal id but no dive info for it. This appeared to be one of those dreaded dives when the Uemis decides to start a dive at the end of a flight and then stays in dive mode until it runs out of battery. Anyway, if we see a number above and a number below, just give up and move on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: deal with a whole block of deleted divesGravatar Dirk Hohndel
If every dive in a download block from the Uemis was deleted we kept downloading that same block of dives. With this we remember how far we got even if the dives ended up being deleted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06Uemis downloader: print some information on stderr in verbose modeGravatar Dirk Hohndel
On the Mac the info on the download dialog isn't shown. So print it on stderr as well when in verbose mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22Uemis fix for UbuntuGravatar Guido Lerch
Fixing a bug preventing to download files on Ubuntu. On Ubuntu some files are recognized as DIR and not as regular files. This is a fix that works but most lilely does not address the root cause which would need an expert to look at.. Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-01Avoid possible NULL pointer dereferenceGravatar Dirk Hohndel
This makes the code more robust in case the Uemis returns random or non-sensical data. It's unlikely the user has a billion dives or that the Uemis returns such a number. That's no reason not to handle this case without crashing. Coverity CID 1325289 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-27Uemis downloader: display message if no dives to downloadGravatar Guido Lerch
Display an error message if no new dives are there for download. [Dirk Hohndel: small adjustment to the message] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-19Uemis downloader: start downloading using the correct dive IDGravatar Linus Torvalds
The logic to pick the initial dive ID for the uemis downloader was very confused, and did not work at all when restarting a download when the Uemis filled up, and the "Force download all dives" flag was set. It also required a rather odd Uemis-specific callback from the download UI because of how it picked the initial ID. This changes the logic to just look at the list of downloaded dives when restarting, which simplifies the logic a lot, gets rid of the odd special callback, and also means that the whole "Force download" issue just goes away. It seems to work now. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-19Uemis downloader: avoid NULL pointer dereferenceGravatar Linus Torvalds
The Uemis downloader blindly just did a strstr on 'nds->name', even if there wasn't necessarily a dive location at all. Add the proper NULL pointer checks. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18Uemis downloader: minor coding style changesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18Uemis downloader: don't try to download divespots that weren't setGravatar Dirk Hohndel
This should cut down on redundant calls to download divespot #0. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18Uemis downloader: reduce the amount of dive stops to be readGravatar Guido Lerch
Changing the logic to check if a divespot was already read in this round of reading in dives. Signed-off-by: Guido Lerch <glerch@Guidos-MacBook-Air.local> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-17Uemis downloader: fix algorithm to find matching dive detailsGravatar glerch
Implemented suggestion from Dirk on how to deal with dive details not being found. Also cleaned up some unused variables, got rid of the last_log_file_nr because it's not needed anymore. One thing in question I still need to check is whether we really need to decrease the dive_to_read if we find deleted dive details, this is still in but I dont think it's really needed. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-16Uemis downloader: code cleanupGravatar glerch
Removing an unused variable Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-16Uuemis downloader: make sure import reacts to cancelGravatar glerch
Fixed a bug where the import did not react on the cancel button by adding the check into the helper function as well. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-15Uemis downloader: new memory calculationGravatar glerch
New calculation doing better UEMIS memory handling leading into more dives being loaded at the same time while assuring we are not overrunning the memory. Also added the dialog message back, this was actually a bug I missed introduced in one of the earlier patches Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-15Uemis - fixup debuggingGravatar glerch
No actualy code changes, just some small chnages within the debugging such as removing reference from my /User/glerch/ home dir etc. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-14Uemis - bugfix wrong variable addressingGravatar glerch
Made a mistage when adressing a referenced variable Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-14Uemis downloader: more code restructuringGravatar glerch
Another helper function to make things easier to read - but actually even this helper is still quite complex so I'm not done yet as I'd like to simplyfy this even further. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-14Uemis downloader: code restructuringGravatar glerch
In order to make the code more readable and easier to debug, this moves a logical block into its own function. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-14Uemis bugfixGravatar glerch
Fixed a bug in do_uemis_download when cleaning up delted dives. My test for valid dives was wrong. now counting the nr of dives in the download table. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-11Uemis downloader: code optimizationGravatar glerch
Cleaned up the code in do_uemis_import, this way it should run a little faster as I am doing the check if the returned divespot is valid at an earlier point Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-11Uemis downloader: cleaning up debug bitsGravatar glerch
At some point I would like to understand the logic behind the debug bits, so I am not messing around with them. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: remove memory leaksGravatar glerch
Found more memory leaks Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: assure empty divespots are not addedGravatar glerch
If the load_uemis_divespot returns false we must assure we delete the divespot that was created during process_raw_buffer Also added some comments Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: remove code not needed anymoreGravatar glerch
Cleaning up track_uemis_divespot because this function is not needed anymore. As I am loading the divespots now within do_uemis_import, I also adjusted the memory calculation - this is not completed yet. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: new logic for divespotsGravatar glerch
Changed the do_uemis_import to load divespots right after matching the dive details. Logic implemented to verify that we are not duplicating divespots by comparing the uuid from get_dive_site_by_uuid(dive->dive_site_uuid) with the one from get_dive_site_uuid_by_name Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: deleting code because of design changeGravatar glerch
Deleting unnecessary code to support future design change coming with the next patch Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: new routine to load divespotsGravatar glerch
Added load_uemis_divespot. This will be used later in do_uemis_import to improve the amount of divespots that must be loaded actually. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10Uemis downloader: fix bug when creating dive siteGravatar glerch
Use dive->when when creating a dive site instead of time(NULL) as Dirk suggested Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Fix another memory leak on uemis downloaderGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Fix memory leak on uemis downloaderGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Initialize variable before useGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Two small string changesGravatar Dirk Hohndel
Reported by Ettore Atalan on Trnasifex. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-08Uemis downloader: don't use unknown type u_int32_tGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-07Uemis downloader: code cleanupGravatar glerch
Do some cleanup of the code, there might be more of that as I am still learning the Uemis code Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-07Uemis downloader: original dive number supportGravatar glerch
- enabled capturing of the original Uemis dive number - previousely the object_id was passed to dive as dive number - I am using a workaround (not nice but effective) by parsing the dive_no out of a copy of inbuf before the object_id is parsed. The reason why is that the dive_no comes before the object_id hence the normal parsing would miss it. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-07Uemis downloader: multiple buddy supportGravatar glerch
- changed the uemis_add_string to support a delimiter in parameter 3 - passing each nickname to the parse_tag function appending dive->buddy with concatentated nicknames separaed by comma Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-06Uemis downloader: change download logicGravatar Guido Lerch
- change the way how dive logs are mapped to dive details in do_uemis_import() - dives deleted on the Uemis will not be downloaded anymore (added function uemis_delete_dive_by_diveid) - change the way the memory consumption was checked to acknowledge very large files (trying to predic on how many more files fit into the buffer by calculating an average consumbtion over each divelogs block) - minimal design change to support the above [Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: add helper function to dump bufferGravatar Guido Lerch
[Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: add heler function to delete diveGravatar Guido Lerch
[Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: parse dive_no as wellGravatar Guido Lerch
[Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: add helper function to estimate memory needsGravatar Guido Lerch
[Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: parse_divespot should return if it was successfulGravatar Guido Lerch
But sadly the code then doesn't actually use that return value, so this is not quite perfect, yet. [Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: add constant for maximum number of ANS filesGravatar Guido Lerch
[Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: fix and move helper functionGravatar Guido Lerch
This function is only used in the Uemis downloader, and it got broken when we switched to using a separate table for the downloaded dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: various changes to the debugging outputGravatar Guido Lerch
This shouldn't change any of the actualy code, except when it comes to debugging output. [Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>