downloader: first step to get instructions via CLI

This still doesn't do a thing, but at least it seems to get the
information closer to where we want it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-11-14 19:22:14 -08:00
parent 5a8db97819
commit 25d7c58c07
2 changed files with 23 additions and 3 deletions

View file

@ -189,6 +189,10 @@ static void print_help()
printf("\n --user=<test> Choose configuration space for user <test>"); printf("\n --user=<test> Choose configuration space for user <test>");
#ifdef SUBSURFACE_MOBILE_DESKTOP #ifdef SUBSURFACE_MOBILE_DESKTOP
printf("\n --testqml=<dir> Use QML files from <dir> instead of QML resources"); printf("\n --testqml=<dir> Use QML files from <dir> instead of QML resources");
#elif SUBSURFACE_DOWNLOADER
printf("\n --dc-vendor=vendor Set the dive computer to download from");
printf("\n --dc-product=product Set the dive computer to download from");
printf("\n --device=device Set the device to download from");
#endif #endif
printf("\n --cloud-timeout=<nr> Set timeout for cloud connection (0 < timeout < 60)\n\n"); printf("\n --cloud-timeout=<nr> Set timeout for cloud connection (0 < timeout < 60)\n\n");
} }
@ -248,7 +252,20 @@ void parse_argument(const char *arg)
++force_root; ++force_root;
return; return;
} }
#ifdef SUBSURFACE_MOBILE_DESKTOP #if SUBSURFACE_DOWNLOADER
if (strncmp(arg, "--dc-vendor=", sizeof("--dc-vendor=") - 1) == 0) {
prefs.dive_computer.vendor = strdup(arg + sizeof("--dc-vendor=") - 1);
return;
}
if (strncmp(arg, "--dc-product=", sizeof("--dc-product=") - 1) == 0) {
prefs.dive_computer.product = strdup(arg + sizeof("--dc-product=") - 1);
return;
}
if (strncmp(arg, "--device=", sizeof("--device=") - 1) == 0) {
prefs.dive_computer.device = strdup(arg + sizeof("--device=") - 1);
return;
}
#elif SUBSURFACE_MOBILE_DESKTOP
if (strncmp(arg, "--testqml=", sizeof("--testqml=") - 1) == 0) { if (strncmp(arg, "--testqml=", sizeof("--testqml=") - 1) == 0) {
testqml = malloc(strlen(arg) - sizeof("--testqml=") + 1); testqml = malloc(strlen(arg) - sizeof("--testqml=") + 1);
strcpy(testqml, arg + sizeof("--testqml=") - 1); strcpy(testqml, arg + sizeof("--testqml=") - 1);

View file

@ -8,6 +8,7 @@
#include "core/settings/qPref.h" #include "core/settings/qPref.h"
#include "core/tag.h" #include "core/tag.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/subsurface-string.h"
#include <QApplication> #include <QApplication>
#include <QLoggingCategory> #include <QLoggingCategory>
@ -85,8 +86,10 @@ int main(int argc, char **argv)
qDebug() << "loading dive data from" << files; qDebug() << "loading dive data from" << files;
print_files(); print_files();
if (!quit) { if (!quit) {
// do something if (!empty_string(prefs.dive_computer.vendor) && !empty_string(prefs.dive_computer.product) && !empty_string(prefs.dive_computer.device)) {
; // download from that dive computer
printf("Downloading dives from %s %s (via %s)\n", prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device);
}
} }
taglist_free(g_tag_list); taglist_free(g_tag_list);
parse_xml_exit(); parse_xml_exit();