downloader: save downloaded dives

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2020-11-27 21:32:40 +01:00 committed by Dirk Hohndel
parent 5e34531e32
commit 40311362f3
3 changed files with 14 additions and 1 deletions

View file

@ -37,4 +37,5 @@ void cliDownloader(const char *vendor, const char *product, const char *device)
// before we start, remember where the dive_table ended
diveImportedModel->startDownload();
diveImportedModel->waitForDownload();
diveImportedModel->recordDives();
}

View file

@ -147,6 +147,7 @@ void DiveImportedModel::startDownload()
void DiveImportedModel::waitForDownload()
{
thread.wait();
downloadThreadFinished();
}
std::tuple<struct dive_table, struct dive_site_table, struct device_table> DiveImportedModel::consumeTables()

View file

@ -9,6 +9,8 @@
#include "core/tag.h"
#include "core/dive.h"
#include "core/subsurface-string.h"
#include "core/file.h"
#include "core/trip.h"
#include <QApplication>
#include <QLoggingCategory>
@ -37,6 +39,12 @@ int main(int argc, char **argv)
QStringList files;
QStringList importedFiles;
QStringList arguments = QCoreApplication::arguments();
struct dive_table dive_table = empty_dive_table;
struct dive_site_table sites = empty_dive_site_table;
struct device_table devices;
struct filter_preset_table presets;
const char *default_directory = system_default_directory();
const char *default_filename = system_default_filename();
@ -83,8 +91,10 @@ int main(int argc, char **argv)
}
}
filesOnCommandLine = !files.isEmpty() || !importedFiles.isEmpty();
if (!files.isEmpty())
if (!files.isEmpty()) {
qDebug() << "loading dive data from" << files;
parse_file(qPrintable(files.first()), &dive_table, &trip_table, &sites, &devices, &presets);
}
print_files();
if (!quit) {
if (!empty_string(prefs.dive_computer.vendor) && !empty_string(prefs.dive_computer.product) && !empty_string(prefs.dive_computer.device)) {
@ -93,6 +103,7 @@ int main(int argc, char **argv)
cliDownloader(prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device);
}
}
save_dives(qPrintable(files.first()));
taglist_free(g_tag_list);
parse_xml_exit();
free((void *)default_directory);