summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-20 22:30:04 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-30 07:42:42 -0700
commit8bbb3dfe4241b200cc37420ed45d7303a99c8b27 (patch)
treeab70c58fc1510216da37f53932d16939f3d77f52
parente9ba8f0ff60144dd71bfb4e305a3a41dde2722f5 (diff)
downloadsubsurface-8bbb3dfe4241b200cc37420ed45d7303a99c8b27.tar.gz
Uemis downloader: allow continuing download by clicking Retry
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>
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp11
-rw-r--r--uemis-downloader.c9
-rw-r--r--uemis.h1
3 files changed, 20 insertions, 1 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index c7a48c46b..04c78b998 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -1,6 +1,9 @@
#include "downloadfromdivecomputer.h"
#include "helpers.h"
#include "mainwindow.h"
+#include "divelistview.h"
+#include "display.h"
+#include "uemis.h"
#include <QTimer>
#include <QFileDialog>
@@ -282,6 +285,14 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
diveImportedModel->clearTable();
clear_table(&downloadTable);
}
+ if (ui.vendor->currentText() == "Uemis") {
+ if (currentState == ERROR && downloadTable.nr > 0)
+ // let the uemis code know how far we've gotten
+ uemis_set_max_diveid_from_dialog(downloadTable.dives[downloadTable.nr - 1]->dc.diveid);
+ else
+ // fresh download, so only look at what's in the dive_table
+ uemis_set_max_diveid_from_dialog(0);
+ }
updateState(DOWNLOADING);
// you cannot cancel the dialog, just the download
diff --git a/uemis-downloader.c b/uemis-downloader.c
index adf555a7c..64fb1c6da 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -814,6 +814,13 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
return true;
}
+static int max_diveid_from_dialog;
+
+void uemis_set_max_diveid_from_dialog(int diveid)
+{
+ max_diveid_from_dialog = diveid;
+}
+
static char *uemis_get_divenr(char *deviceidstr)
{
uint32_t deviceid, maxdiveid = 0;
@@ -831,7 +838,7 @@ static char *uemis_get_divenr(char *deviceidstr)
maxdiveid = dc->diveid;
}
}
- snprintf(divenr, 10, "%d", maxdiveid);
+ snprintf(divenr, 10, "%d", maxdiveid > max_diveid_from_dialog ? maxdiveid : max_diveid_from_dialog);
return strdup(divenr);
}
diff --git a/uemis.h b/uemis.h
index 32c4bdc24..7a12b1ee9 100644
--- a/uemis.h
+++ b/uemis.h
@@ -16,6 +16,7 @@ void uemis_parse_divelog_binary(char *base64, void *divep);
int uemis_get_weight_unit(int diveid);
void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_t *latitude, degrees_t *longitude);
void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude);
+void uemis_set_max_diveid_from_dialog(int diveid);
typedef struct
{