summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar glerch <guido.lerch@gmail.com>2015-09-10 17:29:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-10 12:31:35 -0700
commit8e82e14b1ece64e0ecc87e6ff942605d4ed53ce7 (patch)
treed65885a059b67bbf72297fe37b1ad5d82a403574 /uemis-downloader.c
parente7fa81f9ea72068824547279ed838f17a28d2524 (diff)
downloadsubsurface-8e82e14b1ece64e0ecc87e6ff942605d4ed53ce7.tar.gz
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>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 9abdccaae..ca35a0960 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -892,8 +892,11 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
if (for_dive)
*for_dive = atoi(val);
} else if (!is_log && dive && !strcmp(tag, "divespot_id")) {
- dive->dive_site_uuid = create_dive_site("from Uemis", dive->when);
- track_divespot(val, dive->dc.diveid, dive->dive_site_uuid);
+ int divespot_id = atoi(val);
+ if (divespot_id != -1) {
+ dive->dive_site_uuid = create_dive_site("from Uemis", dive->when);
+ uemis_mark_divelocation(dive->dc.diveid, divespot_id, dive->dive_site_uuid);
+ }
#if UEMIS_DEBUG & 2
fprintf(debugfile, "Created divesite %d for diveid : %d\n", dive->dive_site_uuid, dive->dc.diveid);
#endif
@@ -1202,6 +1205,20 @@ const char *do_uemis_import(device_data_t *data)
fprintf(debugfile, "Matching divelog id %d from %s with dive details %d\n", dive->dc.diveid, dTime, iDiveToRead);
#endif
last_found_log_file_nr = dive_to_read;
+ int divespot_id = uemis_get_divespot_id_by_diveid(dive->dc.diveid);
+ if (load_uemis_divespot(mountpath, divespot_id)) {
+ struct dive_site *nds = get_dive_site_by_uuid(dive->dive_site_uuid);
+ struct dive_site *ods = NULL;
+ if (nds) {
+ (void)get_dive_site_uuid_by_name(nds->name, &ods);
+ if (ods) {
+ if (nds->uuid != ods->uuid) {
+ delete_dive_site(nds->uuid);
+ dive->dive_site_uuid = ods->uuid;
+ }
+ }
+ }
+ }
} else {
/* in this case we found a deleted file, so let's increment */
#if UEMIS_DEBUG & 2