mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
dc887f6d0a
Not that it matters, but there seems to be no reason to allocate DiveImportedModel on the heap and no reason to leak it after the download has finished. Removes a artifactuous comment and fixes a typo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
36 lines
1 KiB
C++
36 lines
1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "qt-models/diveimportedmodel.h"
|
|
|
|
void cliDownloader(const char *vendor, const char *product, const char *device)
|
|
{
|
|
DiveImportedModel 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 assumptions - should all be configurable
|
|
data->setForceDownload(false);
|
|
data->setSaveLog(true);
|
|
data->setSaveDump(false);
|
|
|
|
diveImportedModel.startDownload();
|
|
diveImportedModel.waitForDownload();
|
|
diveImportedModel.recordDives();
|
|
}
|