aboutsummaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
AgeCommit message (Collapse)Author
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>
2015-09-05Uemis downloader: small whitespace changeGravatar Guido Lerch
This makes the comments line up more nicely and fixes some other random issues in preparation for the following changes. [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-08-25Make created dive site uuid deterministicGravatar Dirk Hohndel
Having random uuids seemed like a good idea, but there are several situations where they really cause problems. One is merging dive file imports from V2 logfiles. Another is testing such imports. Instead of making the uuid random we now hash the name and add the timestamp of the first dive associated with this dive site to the hash (first in this context is "first encountered" with no guarantee that it is the chronologically first). This way V2 imports create deterministic uuids but uuid conflicts are still extremely unlikely, even if the user has multiple dive sites with the same name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>