From 15d75183c2eacc1aa38ccbc554f92aa6452d5cec Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 19:43:31 +0200 Subject: [PATCH 01/21] Check if server has valid subcription. Signed-off-by: Camila Ayres --- src/libsync/capabilities.cpp | 5 +++++ src/libsync/capabilities.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index ee9ff332cc90f..a1d815dcf89db 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -388,6 +388,11 @@ bool Capabilities::groupFoldersAvailable() const return _capabilities[QStringLiteral("groupfolders")].toMap().value(QStringLiteral("hasGroupFolders"), false).toBool(); } +bool Capabilities::serverHasValidSubscription() const +{ + return _capabilities[QStringLiteral("support")].toMap().value(QStringLiteral("hasValidSubscription"), false).toBool(); +} + QStringList Capabilities::blacklistedFiles() const { return _capabilities["files"].toMap()["blacklisted_files"].toStringList(); diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index 110b507751600..cdc7e110133ab 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -173,6 +173,8 @@ class OWNCLOUDSYNC_EXPORT Capabilities [[nodiscard]] bool groupFoldersAvailable() const; + [[nodiscard]] bool serverHasValidSubscription() const; + // Direct Editing void addDirectEditor(DirectEditor* directEditor); DirectEditor* getDirectEditorForMimetype(const QMimeType &mimeType); From e0d737768023fb6038987683e83f9023a85bbb5b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 20:24:17 +0200 Subject: [PATCH 02/21] Add general config setting for server hasValidSubscription. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 13 +++++++++++++ src/libsync/configfile.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 59629f91caec0..16f114b6acc55 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -112,6 +112,7 @@ static constexpr char certPasswd[] = "http_certificatePasswd"; static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; static constexpr char defaultUpdateChannelName[] = "stable"; +static constexpr char serverHasValidSubscriptionC[] = "serverHasValidSubscription"; } namespace OCC { @@ -1176,6 +1177,18 @@ void ConfigFile::setLaunchOnSystemStartup(const bool autostart) settings.setValue(QLatin1String(launchOnSystemStartupC), autostart); } +bool ConfigFile::serverHasValidSubscription() +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(serverHasValidSubscriptionC), false).toBool(); +} + +void ConfigFile::setServerHasValidSubscription(const bool valid) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(serverHasValidSubscriptionC), valid); +} + Q_GLOBAL_STATIC(QString, g_configFileName) std::unique_ptr ConfigFile::settingsWithGroup(const QString &group, QObject *parent) diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 6b10a8f2fd1fe..aaf641064eb18 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -227,6 +227,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] bool launchOnSystemStartup() const; void setLaunchOnSystemStartup(const bool autostart); + [[nodiscard]] bool serverHasValidSubscription(); + void setServerHasValidSubscription(const bool valid); + /** Returns a new settings pre-set in a specific group. The Settings will be created with the given parent. If no parent is specified, the caller must destroy the settings */ static std::unique_ptr settingsWithGroup(const QString &group, QObject *parent = nullptr); From 7fa03788831c2c6b023ef3b1d7ad9bae3f62637d Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 20:48:41 +0200 Subject: [PATCH 03/21] Add user specific setting for server hasValidScriptionValue. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 8a2f3bb38f696..fd82c6ffc9f72 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -61,6 +61,8 @@ constexpr auto legacyCfgFileNameC = "owncloud.cfg"; // The maximum versions that this client can read constexpr auto maxAccountsVersion = 2; constexpr auto maxAccountVersion = 1; + +constexpr auto serverHasValidSubscriptionC = "serverHasValidSubscription"; } @@ -321,6 +323,10 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion); settings.setValue(QLatin1String(serverColorC), acc->_serverColor); settings.setValue(QLatin1String(serverTextColorC), acc->_serverTextColor); + + // TODO: serverHasValidSubscription is per user or general? + settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->capabilities().serverHasValidSubscription()); + if (!acc->_skipE2eeMetadataChecksumValidation) { settings.remove(QLatin1String(skipE2eeMetadataChecksumValidationC)); } else { From a4c114e658f62864c770f5282b02819a4fb3a78f Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 20:50:37 +0200 Subject: [PATCH 04/21] Update server hasValidSubscription if capabilities change for account. Signed-off-by: Camila Ayres --- src/libsync/account.cpp | 11 +++++++++++ src/libsync/account.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 2bd4fdd2e9b53..b3e997c2c076f 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -689,6 +689,7 @@ void Account::setCapabilities(const QVariantMap &caps) _capabilities = Capabilities(caps); updateServerColors(); + updateServerSubcription(); emit capabilitiesChanged(); @@ -1068,4 +1069,14 @@ void Account::setAskUserForMnemonic(const bool ask) emit askUserForMnemonicChanged(); } +void Account::updateServerSubcription() +{ + ConfigFile currentConfig; + if (const auto serverHasValidSubscription = _capabilities.serverHasValidSubscription(); + serverHasValidSubscription != currentConfig.serverHasValidSubscription()) { + currentConfig.setServerHasValidSubscription(serverHasValidSubscription); + } +} + + } // namespace OCC diff --git a/src/libsync/account.h b/src/libsync/account.h index b00be5ab092d8..1a5afc4091ca1 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -335,6 +335,8 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject [[nodiscard]] bool askUserForMnemonic() const; + void updateServerSubcription(); + public slots: /// Used when forgetting credentials void clearQNAMCache(); From ee032827a13067917c7a3eec369258510f8ee792 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 20:52:11 +0200 Subject: [PATCH 05/21] List enterprise update channel when available. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index bb91fb61abdee..4bd3a88d86346 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -282,6 +282,10 @@ void GeneralSettings::loadMiscSettings() #if defined(BUILD_UPDATER) auto validUpdateChannels = cfgFile.validUpdateChannels(); + if (const auto serverHasValidSubscription = cfgFile.serverHasValidSubscription(); + serverHasValidSubscription) { + validUpdateChannels << QStringLiteral("enterprise"); + } _ui->updateChannel->addItems(validUpdateChannels); const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel()); _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); @@ -359,6 +363,10 @@ void GeneralSettings::slotUpdateChannelChanged() return tr("daily"); } + if (channel == QStringLiteral("enterprise")) { + return tr("enterprise"); + } + return QString{}; }; @@ -370,6 +378,9 @@ void GeneralSettings::slotUpdateChannelChanged() case 2: return QStringLiteral("daily"); break; + case 3: + return QStringLiteral("enterprise"); + break; default: return QStringLiteral("stable"); } From e4b70c4037f486d89d1f50346820f80b47ea24ba Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 21:26:25 +0200 Subject: [PATCH 06/21] Extend Capabilities tests. Signed-off-by: Camila Ayres --- test/testcapabilities.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testcapabilities.cpp b/test/testcapabilities.cpp index d63a0fc07edbf..e673a0a2956d2 100644 --- a/test/testcapabilities.cpp +++ b/test/testcapabilities.cpp @@ -282,6 +282,20 @@ private slots: QCOMPARE(filesLockAvailable, true); } + + void testSupport_hasValidSubscription_returnTrue() + { + QVariantMap supportMap; + supportMap["hasValidSubscription"] = "true"; + + QVariantMap capabilitiesMap; + capabilitiesMap["support"] = supportMap; + + const auto &capabilities = OCC::Capabilities(capabilitiesMap); + const auto serverHasValidSubscription = capabilities.serverHasValidSubscription(); + + QCOMPARE(serverHasValidSubscription, true); + } }; QTEST_GUILESS_MAIN(TestCapabilities) From e8b823670cee2ab2f62e3245d4a4610b7614a445 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 21:32:16 +0200 Subject: [PATCH 07/21] Do not show enterprise channel for branded clients. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 4bd3a88d86346..ec72444fecc70 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -283,7 +283,7 @@ void GeneralSettings::loadMiscSettings() #if defined(BUILD_UPDATER) auto validUpdateChannels = cfgFile.validUpdateChannels(); if (const auto serverHasValidSubscription = cfgFile.serverHasValidSubscription(); - serverHasValidSubscription) { + serverHasValidSubscription && !Theme::instance()->isBranded()) { validUpdateChannels << QStringLiteral("enterprise"); } _ui->updateChannel->addItems(validUpdateChannels); From aa239cd7bd7cf7d79eb17ea7a5b67472faf2a9fb Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 21:42:19 +0200 Subject: [PATCH 08/21] Add enterprise explanation to message shown when user changes update channel. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index ec72444fecc70..3c29f9c8a61ad 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -398,6 +398,7 @@ void GeneralSettings::slotUpdateChannelChanged() "- stable: contains tested versions considered reliable\n" "- beta: contains versions with new features that may not be tested thoroughly\n" "- daily: contains versions created daily only for testing and development\n\n" + "- enterprise: contains stable versions for customers.\n\n" "Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version."), QMessageBox::NoButton, this); From 4de91cba23e4424431f73108d2f5fbc75a740d1f Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 22:14:00 +0200 Subject: [PATCH 09/21] NextcloudDev is not a branded client. Signed-off-by: Camila Ayres --- src/libsync/theme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index b20ef2a6798af..b3afdee9ae9f3 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -117,7 +117,7 @@ QString Theme::statusHeaderText(SyncResult::Status status) const bool Theme::isBranded() const { - return appNameGUI() != QStringLiteral("Nextcloud"); + return (appNameGUI() != QStringLiteral("Nextcloud") && appNameGUI() != QStringLiteral("NextcloudDev")); } QString Theme::appNameGUI() const From 0274cd912b9d6192391c38775953e1a7a592f725 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 3 Jun 2024 22:14:55 +0200 Subject: [PATCH 10/21] Only list enterprise for customers not running branded clients. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 3c29f9c8a61ad..939e349aa2346 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -391,6 +391,7 @@ void GeneralSettings::slotUpdateChannelChanged() return; } + const auto enterprise = _ui->updateChannel->count() > 3 ? "- enterprise: contains stable versions for customers.\n" : ""; auto msgBox = new QMessageBox( QMessageBox::Warning, tr("Changing update channel?"), @@ -398,8 +399,8 @@ void GeneralSettings::slotUpdateChannelChanged() "- stable: contains tested versions considered reliable\n" "- beta: contains versions with new features that may not be tested thoroughly\n" "- daily: contains versions created daily only for testing and development\n\n" - "- enterprise: contains stable versions for customers.\n\n" - "Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version."), + "%1\n" + "Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version.").arg(enterprise), QMessageBox::NoButton, this); const auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole); From 4884fbee874ee8cce62f31f1faf31310e151ee4b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 3 Jul 2024 15:13:55 +0200 Subject: [PATCH 11/21] Add desktopEnterpriseChannel to the capabilities check. Signed-off-by: Camila Ayres --- src/libsync/capabilities.cpp | 6 ++++++ src/libsync/capabilities.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index a1d815dcf89db..143608b30082f 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -13,6 +13,7 @@ */ #include "capabilities.h" +#include "configfile.h" #include #include @@ -393,6 +394,11 @@ bool Capabilities::serverHasValidSubscription() const return _capabilities[QStringLiteral("support")].toMap().value(QStringLiteral("hasValidSubscription"), false).toBool(); } +QString Capabilities::desktopEnterpriseChannel() const +{ + return _capabilities[QStringLiteral("support")].toMap().value(QStringLiteral("desktopEnterpriseChannel"), ConfigFile().defaultUpdateChannel()).toString(); +} + QStringList Capabilities::blacklistedFiles() const { return _capabilities["files"].toMap()["blacklisted_files"].toStringList(); diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index cdc7e110133ab..ca2cb7190c4b4 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -174,6 +174,7 @@ class OWNCLOUDSYNC_EXPORT Capabilities [[nodiscard]] bool groupFoldersAvailable() const; [[nodiscard]] bool serverHasValidSubscription() const; + [[nodiscard]] QString desktopEnterpriseChannel() const; // Direct Editing void addDirectEditor(DirectEditor* directEditor); From 615805dd03a11ef0abd1ae030c5bddd2af2d150b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 3 Jul 2024 15:14:53 +0200 Subject: [PATCH 12/21] Save desktopEnterpriseChannel value in the config file. The default should be what is returned by defaultUpdateChannel() when desktopEnterpriseChannel is not available. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 16 +++++++++++++++- src/libsync/configfile.h | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 16f114b6acc55..9d16d07f729e5 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -113,6 +113,7 @@ static constexpr char certPasswd[] = "http_certificatePasswd"; static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; static constexpr char defaultUpdateChannelName[] = "stable"; static constexpr char serverHasValidSubscriptionC[] = "serverHasValidSubscription"; +static constexpr char desktopEnterpriseChannelName[] = "desktopEnterpriseChannel"; } namespace OCC { @@ -1177,7 +1178,7 @@ void ConfigFile::setLaunchOnSystemStartup(const bool autostart) settings.setValue(QLatin1String(launchOnSystemStartupC), autostart); } -bool ConfigFile::serverHasValidSubscription() +bool ConfigFile::serverHasValidSubscription() const { QSettings settings(configFile(), QSettings::IniFormat); return settings.value(QLatin1String(serverHasValidSubscriptionC), false).toBool(); @@ -1189,6 +1190,19 @@ void ConfigFile::setServerHasValidSubscription(const bool valid) settings.setValue(QLatin1String(serverHasValidSubscriptionC), valid); } +QString ConfigFile::desktopEnterpriseChannel() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(desktopEnterpriseChannelName), defaultUpdateChannel()).toString(); +} + +void ConfigFile::setDesktopEnterpriseChannel(const QString &channel) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(desktopEnterpriseChannelName), channel); +} + + Q_GLOBAL_STATIC(QString, g_configFileName) std::unique_ptr ConfigFile::settingsWithGroup(const QString &group, QObject *parent) diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index aaf641064eb18..6eb38d0cc5e75 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -227,9 +227,12 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] bool launchOnSystemStartup() const; void setLaunchOnSystemStartup(const bool autostart); - [[nodiscard]] bool serverHasValidSubscription(); + [[nodiscard]] bool serverHasValidSubscription() const; void setServerHasValidSubscription(const bool valid); + [[nodiscard]] QString desktopEnterpriseChannel() const; + void setDesktopEnterpriseChannel(const QString &channel); + /** Returns a new settings pre-set in a specific group. The Settings will be created with the given parent. If no parent is specified, the caller must destroy the settings */ static std::unique_ptr settingsWithGroup(const QString &group, QObject *parent = nullptr); From 0663282b2b13d77535109fb8e76df8e127a72e3a Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 3 Jul 2024 15:16:56 +0200 Subject: [PATCH 13/21] Update desktopEnterpriseChannel value when capabilities change. Signed-off-by: Camila Ayres --- src/libsync/account.cpp | 10 ++++++++++ src/libsync/account.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index b3e997c2c076f..1a05650edad37 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -690,6 +690,7 @@ void Account::setCapabilities(const QVariantMap &caps) updateServerColors(); updateServerSubcription(); + updateDesktopEnterpriseChannel(); emit capabilitiesChanged(); @@ -1078,5 +1079,14 @@ void Account::updateServerSubcription() } } +void Account::updateDesktopEnterpriseChannel() +{ + ConfigFile currentConfig; + if (const auto desktopEnterpriseChannel = _capabilities.desktopEnterpriseChannel(); + desktopEnterpriseChannel != currentConfig.desktopEnterpriseChannel()) { + currentConfig.setDesktopEnterpriseChannel(desktopEnterpriseChannel); + } +} + } // namespace OCC diff --git a/src/libsync/account.h b/src/libsync/account.h index 1a5afc4091ca1..ea371c8ede21e 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -336,6 +336,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject [[nodiscard]] bool askUserForMnemonic() const; void updateServerSubcription(); + void updateDesktopEnterpriseChannel(); public slots: /// Used when forgetting credentials From e51324dc9a7ddf77eaaa03dc64deeeb4e84664a0 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 3 Jul 2024 16:06:48 +0200 Subject: [PATCH 14/21] Fix the logic to determine update channels available, default value and what info to show the user. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 12 +++++------- src/libsync/configfile.cpp | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 939e349aa2346..31d968344f2f2 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -281,11 +281,7 @@ void GeneralSettings::loadMiscSettings() _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); #if defined(BUILD_UPDATER) - auto validUpdateChannels = cfgFile.validUpdateChannels(); - if (const auto serverHasValidSubscription = cfgFile.serverHasValidSubscription(); - serverHasValidSubscription && !Theme::instance()->isBranded()) { - validUpdateChannels << QStringLiteral("enterprise"); - } + const auto validUpdateChannels = cfgFile.validUpdateChannels(); _ui->updateChannel->addItems(validUpdateChannels); const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel()); _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0); @@ -386,12 +382,14 @@ void GeneralSettings::slotUpdateChannelChanged() } }; + ConfigFile configFile; const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex()); - if (channel == ConfigFile().currentUpdateChannel()) { + if (channel == configFile.currentUpdateChannel()) { return; } - const auto enterprise = _ui->updateChannel->count() > 3 ? "- enterprise: contains stable versions for customers.\n" : ""; + const auto enterprise = configFile.validUpdateChannels().contains("enterprise") ? "- enterprise: contains stable versions for customers.\n" + : ""; auto msgBox = new QMessageBox( QMessageBox::Warning, tr("Changing update channel?"), diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 9d16d07f729e5..6834edc90bcb6 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -110,8 +110,9 @@ static constexpr char forceLoginV2C[] = "forceLoginV2"; static constexpr char certPath[] = "http_certificatePath"; static constexpr char certPasswd[] = "http_certificatePasswd"; -static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; -static constexpr char defaultUpdateChannelName[] = "stable"; +static const QStringList defaultUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; +static constexpr QString defaultUpdateChannelName = "stable"; +static constexpr char defaultEnterpriseChannel[] = "enterprise"; static constexpr char serverHasValidSubscriptionC[] = "serverHasValidSubscription"; static constexpr char desktopEnterpriseChannelName[] = "desktopEnterpriseChannel"; } @@ -691,18 +692,32 @@ int ConfigFile::updateSegment() const QStringList ConfigFile::validUpdateChannels() const { - return validUpdateChannelsList; + auto updateChannelsList = defaultUpdateChannelsList; + if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { + updateChannelsList << defaultEnterpriseChannel; + } + + return updateChannelsList; } QString ConfigFile::defaultUpdateChannel() const { + auto defaultUpdateChannel = defaultUpdateChannelName; + if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { + if (const auto serverChannel = desktopEnterpriseChannel(); + validUpdateChannels().contains(serverChannel)) { + qCWarning(lcConfigFile()) << "Enforcing update channel" << serverChannel << "because that is the desktop enterprise channel returned by the server."; + defaultUpdateChannel = serverChannel; + } + } + if (const auto currentVersionSuffix = Theme::instance()->versionSuffix(); validUpdateChannels().contains(currentVersionSuffix)) { qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client."; - return currentVersionSuffix; + defaultUpdateChannel = currentVersionSuffix; } - return defaultUpdateChannelName; + return defaultUpdateChannel; } QString ConfigFile::currentUpdateChannel() const From 52e15ff92e7484ea83da57b12d6ce1517978dd4e Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 3 Jul 2024 23:31:53 +0200 Subject: [PATCH 15/21] Separate the list of valid update channels for enterprise and non-enterprise. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 6834edc90bcb6..8cc87e61668f0 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -110,11 +110,13 @@ static constexpr char forceLoginV2C[] = "forceLoginV2"; static constexpr char certPath[] = "http_certificatePath"; static constexpr char certPasswd[] = "http_certificatePasswd"; -static const QStringList defaultUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; -static constexpr QString defaultUpdateChannelName = "stable"; -static constexpr char defaultEnterpriseChannel[] = "enterprise"; static constexpr char serverHasValidSubscriptionC[] = "serverHasValidSubscription"; static constexpr char desktopEnterpriseChannelName[] = "desktopEnterpriseChannel"; + +static const QStringList defaultUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") }; +static const QString defaultUpdateChannelName = "stable"; +static const QStringList enterpriseUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("enterprise") }; +static const QString defaultEnterpriseChannel = "enterprise"; } namespace OCC { @@ -692,32 +694,30 @@ int ConfigFile::updateSegment() const QStringList ConfigFile::validUpdateChannels() const { - auto updateChannelsList = defaultUpdateChannelsList; if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { - updateChannelsList << defaultEnterpriseChannel; + return enterpriseUpdateChannelsList; } - return updateChannelsList; + return defaultUpdateChannelsList; } QString ConfigFile::defaultUpdateChannel() const { - auto defaultUpdateChannel = defaultUpdateChannelName; if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { if (const auto serverChannel = desktopEnterpriseChannel(); validUpdateChannels().contains(serverChannel)) { qCWarning(lcConfigFile()) << "Enforcing update channel" << serverChannel << "because that is the desktop enterprise channel returned by the server."; - defaultUpdateChannel = serverChannel; + return serverChannel; } } if (const auto currentVersionSuffix = Theme::instance()->versionSuffix(); validUpdateChannels().contains(currentVersionSuffix)) { qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client."; - defaultUpdateChannel = currentVersionSuffix; + return currentVersionSuffix; } - return defaultUpdateChannel; + return defaultUpdateChannelName; } QString ConfigFile::currentUpdateChannel() const @@ -738,7 +738,7 @@ void ConfigFile::setUpdateChannel(const QString &channel) if (!validUpdateChannels().contains(channel)) { qCWarning(lcConfigFile()) << "Received invalid update channel:" << channel - << "can only accept 'stable', 'beta' or 'daily'. Ignoring."; + << "can only accept" << validUpdateChannels() << ". Ignoring."; return; } From dd5e18e8c57de8848fbee10669078bd1ece48af2 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 00:00:11 +0200 Subject: [PATCH 16/21] If the client is branded the default update channel is stable. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 8cc87e61668f0..7b5a789b87f51 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -694,7 +694,13 @@ int ConfigFile::updateSegment() const QStringList ConfigFile::validUpdateChannels() const { - if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { + const auto isBranded = Theme::instance()->isBranded(); + + if (isBranded) { + return { defaultUpdateChannelName }; + } + + if (serverHasValidSubscription()) { return enterpriseUpdateChannelsList; } @@ -703,7 +709,8 @@ QStringList ConfigFile::validUpdateChannels() const QString ConfigFile::defaultUpdateChannel() const { - if (serverHasValidSubscription() && !Theme::instance()->isBranded()) { + const auto isBranded = Theme::instance()->isBranded(); + if (serverHasValidSubscription() && !isBranded) { if (const auto serverChannel = desktopEnterpriseChannel(); validUpdateChannels().contains(serverChannel)) { qCWarning(lcConfigFile()) << "Enforcing update channel" << serverChannel << "because that is the desktop enterprise channel returned by the server."; @@ -712,11 +719,12 @@ QString ConfigFile::defaultUpdateChannel() const } if (const auto currentVersionSuffix = Theme::instance()->versionSuffix(); - validUpdateChannels().contains(currentVersionSuffix)) { + validUpdateChannels().contains(currentVersionSuffix) && !isBranded) { qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client."; return currentVersionSuffix; } + qCWarning(lcConfigFile()) << "Enforcing default update channel" << defaultUpdateChannelName; return defaultUpdateChannelName; } From ee3f2dd1f6b1e727d8a8561c88cc97296660b262 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 00:21:31 +0200 Subject: [PATCH 17/21] Extend capabilities test to include desktopEnterpriseChannel check. Signed-off-by: Camila Ayres --- test/testcapabilities.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testcapabilities.cpp b/test/testcapabilities.cpp index e673a0a2956d2..050c8c6f0516e 100644 --- a/test/testcapabilities.cpp +++ b/test/testcapabilities.cpp @@ -296,6 +296,21 @@ private slots: QCOMPARE(serverHasValidSubscription, true); } + + void testSupport_desktopEnterpriseChannel_returnString() + { + QVariantMap supportMap; + const auto defaultChannel = "stable"; + supportMap["desktopEnterpriseChannel"] = defaultChannel; + + QVariantMap capabilitiesMap; + capabilitiesMap["support"] = supportMap; + + const auto &capabilities = OCC::Capabilities(capabilitiesMap); + const auto enterpriseChannel = capabilities.desktopEnterpriseChannel(); + + QCOMPARE(enterpriseChannel, defaultChannel); + } }; QTEST_GUILESS_MAIN(TestCapabilities) From 7d27c53b3b097bc60bd24c1d497a0ec8aaa920b2 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 09:34:26 +0200 Subject: [PATCH 18/21] Remove resolved TO DO comment. Subscription and channel are supposed to be a general setting, not per user. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index fd82c6ffc9f72..9a11314ce21c0 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -323,8 +323,6 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion); settings.setValue(QLatin1String(serverColorC), acc->_serverColor); settings.setValue(QLatin1String(serverTextColorC), acc->_serverTextColor); - - // TODO: serverHasValidSubscription is per user or general? settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->capabilities().serverHasValidSubscription()); if (!acc->_skipE2eeMetadataChecksumValidation) { From cdd940f66903bee63f8b93354168892d5f032c80 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 09:44:29 +0200 Subject: [PATCH 19/21] Remove const from POD in method declaration. Signed-off-by: Camila Ayres --- src/libsync/configfile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 6eb38d0cc5e75..86963df53d904 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -228,7 +228,7 @@ class OWNCLOUDSYNC_EXPORT ConfigFile void setLaunchOnSystemStartup(const bool autostart); [[nodiscard]] bool serverHasValidSubscription() const; - void setServerHasValidSubscription(const bool valid); + void setServerHasValidSubscription(bool valid); [[nodiscard]] QString desktopEnterpriseChannel() const; void setDesktopEnterpriseChannel(const QString &channel); From bc05dc8a18d7410cdf1233b53bf61d5056b148d0 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 09:50:53 +0200 Subject: [PATCH 20/21] Use NEXTCLOUD_DEV to check if client is branded instead of checking for string. Signed-off-by: Camila Ayres --- src/libsync/theme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index b3afdee9ae9f3..3702ed1bc1a3c 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -117,7 +117,7 @@ QString Theme::statusHeaderText(SyncResult::Status status) const bool Theme::isBranded() const { - return (appNameGUI() != QStringLiteral("Nextcloud") && appNameGUI() != QStringLiteral("NextcloudDev")); + return (appNameGUI() != QStringLiteral("Nextcloud") && NEXTCLOUD_DEV == 0); } QString Theme::appNameGUI() const From 9bd4ef1b83e1e7a93bc3017f01980e02ab739dfa Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 4 Jul 2024 09:54:22 +0200 Subject: [PATCH 21/21] Translate enterprise channel explanation string. Signed-off-by: Camila Ayres --- src/gui/generalsettings.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 31d968344f2f2..2b91b4bc89ac2 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -388,7 +388,8 @@ void GeneralSettings::slotUpdateChannelChanged() return; } - const auto enterprise = configFile.validUpdateChannels().contains("enterprise") ? "- enterprise: contains stable versions for customers.\n" + const auto enterprise = configFile.validUpdateChannels().contains("enterprise") ? tr("- enterprise: contains stable versions for customers.\n", + "description of enterprise update channel for enterprise customers") : ""; auto msgBox = new QMessageBox( QMessageBox::Warning, @@ -396,7 +397,7 @@ void GeneralSettings::slotUpdateChannelChanged() tr("The channel determines which upgrades will be offered to install:\n" "- stable: contains tested versions considered reliable\n" "- beta: contains versions with new features that may not be tested thoroughly\n" - "- daily: contains versions created daily only for testing and development\n\n" + "- daily: contains versions created daily only for testing and development\n" "%1\n" "Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version.").arg(enterprise), QMessageBox::NoButton,