From eac59a79d8e9589ccc3f1c8879478fd1b9502eef Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 22 Nov 2020 17:31:05 -0800 Subject: build-system/downloader: cli-downloader isn't part of the core It's part of the main excutable / helper and needs to be linked before all of our support libraries. Signed-off-by: Dirk Hohndel --- cli-downloader.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cli-downloader.cpp (limited to 'cli-downloader.cpp') diff --git a/cli-downloader.cpp b/cli-downloader.cpp new file mode 100644 index 000000000..77053c0c7 --- /dev/null +++ b/cli-downloader.cpp @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "qt-models/diveimportedmodel.h" + +#include +#include + + +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 + printf("Finished\n"); + }); + + auto data = diveImportedModel->thread.data(); + data->setVendor(vendor); + data->setProduct(product); + data->setBluetoothMode(false); + 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(true); + data->setSaveDump(false); + + // before we start, remember where the dive_table ended + diveImportedModel->startDownload(); +} -- cgit v1.2.3-70-g09d2