mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
25d7c58c07
commit
31f0741ecc
2 changed files with 42 additions and 0 deletions
|
@ -20,6 +20,10 @@ if(FTDISUPPORT)
|
|||
set(SERIAL_FTDI serial_ftdi.c)
|
||||
endif()
|
||||
|
||||
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DownloaderExecutable")
|
||||
set(DOWNLOADER cli-downloader.cpp)
|
||||
endif()
|
||||
|
||||
if(BTSUPPORT)
|
||||
add_definitions(-DBT_SUPPORT)
|
||||
set(BT_SRC_FILES desktop-widgets/btdeviceselectiondialog.cpp)
|
||||
|
@ -252,6 +256,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
${SERIAL_FTDI}
|
||||
${PLATFORM_SRC}
|
||||
${BT_CORE_SRC_FILES}
|
||||
${DOWNLOADER}
|
||||
)
|
||||
source_group("Subsurface Core" FILES ${SUBSURFACE_CORE_LIB_SRCS})
|
||||
|
||||
|
|
37
core/cli-downloader.cpp
Normal file
37
core/cli-downloader.cpp
Normal file
|
@ -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();
|
||||
}
|
Loading…
Reference in a new issue