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
This commit is contained in:
Alejandro Martinez
2025-02-19 18:12:28 -03:00
parent 1baa3db27e
commit 559c8fd1d2
3 changed files with 12 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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 == "") {

View File

@@ -378,6 +378,7 @@
//Dropbox oauth keys
#define GC_DROPBOX_TOKEN "<athlete-private>dropbox/token"
#define GC_DROPBOX_FOLDER "<athlete-private>dropbox/folder"
#define GC_DROPBOX_FORMAT "<athlete-private>dropbox/format"
//Withings
#define GC_WITHINGS_TOKEN "<athlete-private>withings_token"