aboutsummaryrefslogtreecommitdiffstats
path: root/core/cli-downloader.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-11-14 19:44:06 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-03 13:26:55 -0800
commit31f0741ecc0013cd361683e7fad9bf2c8c166a13 (patch)
tree84c429abc20c46e7f8340389725b3ee21ec2aee1 /core/cli-downloader.cpp
parent25d7c58c07fc4b0bf3bc188f540a4ac66f6cd233 (diff)
downloadsubsurface-31f0741ecc0013cd361683e7fad9bf2c8c166a13.tar.gz
downloader: first outline of downloading dives from a device
This is of course not functional at all, but it gives a first idea of what we will need to do in this code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/cli-downloader.cpp')
-rw-r--r--core/cli-downloader.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/cli-downloader.cpp b/core/cli-downloader.cpp
new file mode 100644
index 000000000..b4a8854aa
--- /dev/null
+++ b/core/cli-downloader.cpp
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "qt-models/diveimportedmodel.h"
+
+#include <QObject>
+#include <QUndoStack>
+
+extern "C"
+void cliDownloader(const char *vendor, const char *product, const char *device)
+{
+ DiveImportedModel *diveImportedModel = new DiveImportedModel();
+ DiveImportedModel::connect(diveImportedModel, &DiveImportedModel::downloadFinished, [] {
+ // do something useful at the end of the download
+ });
+
+ auto data = diveImportedModel->thread.data();
+ data->setVendor(vendor);
+ data->setProduct(product);
+ if (data->vendor() == "Uemis") {
+ char *colon;
+ char *devname = strdup(device);
+ if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
+ *(colon + 2) = '\0';
+ fprintf(stderr, "shortened devname to \"%s\"", devname);
+ }
+ data->setDevName(devname);
+ } else {
+ data->setDevName(device);
+ }
+
+ // some assumptiond - should all be configurable
+ data->setForceDownload(false);
+ data->setSaveLog(false);
+ data->setSaveDump(false);
+
+ // before we start, remember where the dive_table ended
+ diveImportedModel->startDownload();
+}