Commit graph

143 commits

Author SHA1 Message Date
Tomaz Canabrava
4c0156e3d5 Move all core-functionality to subsurface-core
And adapt a new CMakeLists.txt file for it. On the way I've also
found out that we where double-compilling a few files. I've also
set the subsurface-core as a include_path but that was just to
reduce the noise on this commit, since I plan to remove it from
the include path to make it obligatory to specify something like

 include "subsurface-core/dive.h"

for the header files. Since the app is growing quite a bit we ended
up having a few different files with almost same name that did
similar things, I want to kill that (for instance Dive.h, dive.h,
PrintDive.h and such).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30 10:36:48 -07:00
Guido Lerch
07b4878c52 Uemis fix for Ubuntu
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-22 07:10:26 +09:00
Dirk Hohndel
df51171352 Avoid possible NULL pointer dereference
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-10-01 22:02:01 -04:00
Guido Lerch
fc420927ff Uemis downloader: display message if no dives to download
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-27 06:43:17 -04:00
Linus Torvalds
e4d2092f33 Uemis downloader: start downloading using the correct dive ID
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-19 21:30:33 -07:00
Linus Torvalds
ad0806406b Uemis downloader: avoid NULL pointer dereference
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-19 21:30:02 -07:00
Dirk Hohndel
ca6f2c238a Uemis downloader: minor coding style changes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18 13:16:57 -07:00
Dirk Hohndel
07a2514d9f Uemis downloader: don't try to download divespots that weren't set
This should cut down on redundant calls to download divespot #0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-18 13:16:57 -07:00
Guido Lerch
69c5e9adc2 Uemis downloader: reduce the amount of dive stops to be read
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-18 13:16:45 -07:00
glerch
2d376de68d Uemis downloader: fix algorithm to find matching dive details
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-17 08:33:11 -07:00
glerch
15049c3e06 Uemis downloader: code cleanup
Removing an unused variable

Signed-off-by: glerch <guido.lerch@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-16 07:36:30 -07:00
glerch
e8ae51b876 Uuemis downloader: make sure import reacts to cancel
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-16 07:35:28 -07:00
glerch
9d56165fd1 Uemis downloader: new memory calculation
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-15 09:12:06 -07:00
glerch
4d7338fd50 Uemis - fixup debugging
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-15 06:49:39 -07:00
glerch
ebf26e067d Uemis - bugfix wrong variable addressing
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-14 13:35:29 -07:00
glerch
277dbf2a67 Uemis downloader: more code restructuring
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-14 13:22:35 -07:00
glerch
9921f32f80 Uemis downloader: code restructuring
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-14 13:21:14 -07:00
glerch
29d43531d2 Uemis bugfix
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-14 07:35:01 -07:00
glerch
30f81949a0 Uemis downloader: code optimization
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-11 10:29:49 -07:00
glerch
4e64b327f3 Uemis downloader: cleaning up debug bits
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-11 09:21:59 -07:00
glerch
dc02a7aa6d Uemis downloader: remove memory leaks
Found more memory leaks

Signed-off-by: glerch <guido.lerch@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-10 12:33:49 -07:00
glerch
6504d97ca8 Uemis downloader: assure empty divespots are not added
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-10 12:33:22 -07:00
glerch
1aa941e754 Uemis downloader: remove code not needed anymore
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-10 12:32:23 -07:00
glerch
8e82e14b1e Uemis downloader: new logic for divespots
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-10 12:31:35 -07:00
glerch
e7fa81f9ea Uemis downloader: deleting code because of design change
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-10 12:30:29 -07:00
glerch
b4f9d2786d Uemis downloader: new routine to load divespots
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-10 12:30:24 -07:00
glerch
bd00c6b83b Uemis downloader: fix bug when creating dive site
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-10 12:26:51 -07:00
Miika Turkia
404cfec7dc Fix another memory leak on uemis downloader
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09 21:35:20 -07:00
Miika Turkia
dbbf23ed51 Fix memory leak on uemis downloader
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09 21:35:18 -07:00
Miika Turkia
33c9cc60ef Initialize variable before use
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09 21:34:01 -07:00
Dirk Hohndel
708fd2fe84 Two small string changes
Reported by Ettore Atalan on Trnasifex.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09 02:53:30 -07:00
Lubomir I. Ivanov
bb4e34003c Uemis downloader: don't use unknown type u_int32_t
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-08 10:10:23 -07:00
glerch
4f3a9ba583 Uemis downloader: code cleanup
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-07 17:43:37 -07:00
glerch
0790dfdad5 Uemis downloader: original dive number support
- 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-07 17:43:12 -07:00
glerch
e77d9cbd55 Uemis downloader: multiple buddy support
- 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-07 17:42:57 -07:00
Guido Lerch
5f3093e02b Uemis downloader: change download logic
- 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-06 07:33:12 -07:00
Guido Lerch
9d5fe3af60 Uemis downloader: add helper function to dump buffer
[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-05 11:29:13 -07:00
Guido Lerch
fa56d5d136 Uemis downloader: add heler function to delete dive
[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-05 11:29:13 -07:00
Guido Lerch
040caaa00b Uemis downloader: parse dive_no as well
[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-05 11:29:13 -07:00
Guido Lerch
ff0859ff21 Uemis downloader: add helper function to estimate memory needs
[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-05 11:29:13 -07:00
Guido Lerch
4ba5dd85d4 Uemis downloader: parse_divespot should return if it was successful
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-05 11:29:12 -07:00
Guido Lerch
b7f5871e59 Uemis downloader: add constant for maximum number of ANS files
[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-05 11:28:57 -07:00
Guido Lerch
8647f95953 Uemis downloader: fix and move helper function
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-05 11:27:50 -07:00
Guido Lerch
a547ee0ff2 Uemis downloader: various changes to the debugging output
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-05 11:27:50 -07:00
Guido Lerch
3a074b61d1 Uemis downloader: small whitespace change
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-09-05 11:27:12 -07:00
Dirk Hohndel
e03b553e80 Make created dive site uuid deterministic
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-08-25 10:43:48 -07:00
Dirk Hohndel
e49355dc45 Uemis downloader: create the req.txt file if it went missing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-24 20:59:49 -07:00
Dirk Hohndel
90f20f4c76 Better error handling
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-22 10:57:56 -07:00
Dirk Hohndel
83a5778f62 Uemis downloader: open returns -1 on error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:16:23 -07:00
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