diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-05 10:24:21 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-05 10:24:21 -0800 |
commit | 1e074f3fb2a933ec5cadb0129cb1d71f8be351c3 (patch) | |
tree | 0a9bcc1158acfb6835a25c2e8eb4456b5336f8de /uemis-downloader.c | |
parent | 0141b69d0a64ae05dcf5380f2fb7d2dd0eb39efe (diff) | |
download | subsurface-1e074f3fb2a933ec5cadb0129cb1d71f8be351c3.tar.gz |
Pick up dive numbers from Uemis SDA when starting with empty data file
This is improving a bit more on commit d2dd0eb39efe "When starting with an
empty data file and downloading dives, number them" by providing a better
starting number when a user downloads dives from a Uemis SDA into an empty
data file.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r-- | uemis-downloader.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c index d3a3c28d9..449ae55ee 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -603,7 +603,7 @@ static void parse_tag(struct dive *dive, char *tag, char *val) * index into yet another data store that we read out later. In order to * correctly populate the location and gps data from that we need to remember * the adresses of those fields for every dive that references the divespot. */ -static void process_raw_buffer(int deviceid, char *inbuf, char **max_divenr) +static void process_raw_buffer(int deviceid, char *inbuf, char **max_divenr, gboolean keep_number) { char *buf = strdup(inbuf); char *tp, *bp, *tag, *type, *val; @@ -664,6 +664,8 @@ static void process_raw_buffer(int deviceid, char *inbuf, char **max_divenr) free(*max_divenr); *max_divenr = strdup(val); dive->dc.diveid = atoi(val); + if (keep_number) + dive->number = atoi(val); } else if (!log && ! strcmp(tag, "logfilenr")) { /* this one tells us which dive we are adding data to */ dive = get_dive_by_diveid(atoi(val), deviceid); @@ -721,8 +723,10 @@ static char *do_uemis_download(struct argument_block *args) char *deviceid = NULL; char *result = NULL; char *endptr; - gboolean success; + gboolean success, keep_number = FALSE; + if (dive_table.nr == 0) + keep_number = TRUE; uemis_info("Init Communication"); if (! uemis_init(mountpath)) return _("Uemis init failed"); @@ -756,7 +760,7 @@ static char *do_uemis_download(struct argument_block *args) success = uemis_get_answer(mountpath, "getDivelogs", 3, 0, &result); /* process the buffer we have assembled */ if (mbuf) - process_raw_buffer(deviceidnr, mbuf, &newmax); + process_raw_buffer(deviceidnr, mbuf, &newmax, keep_number); /* if the user clicked cancel, exit gracefully */ if (import_thread_cancelled) goto bail; @@ -784,7 +788,7 @@ static char *do_uemis_download(struct argument_block *args) param_buff[2] = objectid; success = uemis_get_answer(mountpath, "getDive", 3, 0, &result); if (mbuf) - process_raw_buffer(deviceidnr, mbuf, &newmax); + process_raw_buffer(deviceidnr, mbuf, &newmax, FALSE); if (!success || import_thread_cancelled) break; } |