From 559c8fd1d2645227e87f8d63e98f9f8241dd2047 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Date: Wed, 19 Feb 2025 18:12:28 -0300 Subject: [PATCH] Dropbox cloud service - Add format parameter The format parameter allows to choose between JSON, FIT, TCX, PWX and CSV as the filetype to be used for the service instance. Default is JSON for backward compatibility and because it is the only format preserving all data. The use case is for coaches downloading FIT files from athletes Dropbox folders. Fixes #2710 --- src/Cloud/CloudService.cpp | 4 ++-- src/Cloud/Dropbox.cpp | 9 +++++++++ src/Core/Settings.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Cloud/CloudService.cpp b/src/Cloud/CloudService.cpp index 17e55d431..893786ac8 100644 --- a/src/Cloud/CloudService.cpp +++ b/src/Cloud/CloudService.cpp @@ -236,8 +236,8 @@ RideFile * CloudService::uncompressRide(QByteArray *data, QString name, QStringList &errors) { // make sure its named as we expect - if ((downloadCompression== zip && !name.endsWith(".json.zip")) || - (downloadCompression== gzip && !name.endsWith(".json.gz"))) { + if ((downloadCompression== zip && !name.endsWith(".zip")) || + (downloadCompression== gzip && !name.endsWith(".gz"))) { errors << tr("expected compressed activity file."); return NULL; } diff --git a/src/Cloud/Dropbox.cpp b/src/Cloud/Dropbox.cpp index e263c95f8..26b8071f7 100644 --- a/src/Cloud/Dropbox.cpp +++ b/src/Cloud/Dropbox.cpp @@ -31,6 +31,7 @@ Dropbox::Dropbox(Context *context) : CloudService(context), context(context), ro // config settings.insert(OAuthToken, GC_DROPBOX_TOKEN); settings.insert(Folder, GC_DROPBOX_FOLDER); + settings.insert(Combo1, QString("%1::Format::JSON::FIT::TCX::PWX::CSV").arg(GC_DROPBOX_FORMAT)); } Dropbox::~Dropbox() { @@ -41,6 +42,14 @@ Dropbox::~Dropbox() { bool Dropbox::open(QStringList &errors) { + // User selected file format, defaults to JSON + const QString format = getSetting(GC_DROPBOX_FORMAT, "JSON").toString(); + if (format == "JSON") filetype = uploadType::JSON; + else if (format == "FIT") filetype = uploadType::FIT; + else if (format == "TCX") filetype = uploadType::TCX; + else if (format == "PWX") filetype = uploadType::PWX; + else if (format == "CSV") filetype = uploadType::CSV; + // do we have a token QString token = getSetting(GC_DROPBOX_TOKEN, "").toString(); if (token == "") { diff --git a/src/Core/Settings.h b/src/Core/Settings.h index f8e6e528d..a6c7b0559 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -378,6 +378,7 @@ //Dropbox oauth keys #define GC_DROPBOX_TOKEN "dropbox/token" #define GC_DROPBOX_FOLDER "dropbox/folder" +#define GC_DROPBOX_FORMAT "dropbox/format" //Withings #define GC_WITHINGS_TOKEN "withings_token"