From c4fb2cdf439d3ab72638f24486c97f656ce3e3f1 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 19 Nov 2025 10:05:08 +0100 Subject: [PATCH 1/4] fix(migration): set the use of mono icons. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 3 +++ src/libsync/configfile.cpp | 2 -- src/libsync/configfile.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 176277ec8be8f..b941ca80f5ac2 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -294,6 +294,9 @@ bool AccountManager::restoreFromLegacySettings() configFile.setVfsEnabled(settings->value(ConfigFile::isVfsEnabledC, configFile.isVfsEnabled()).toBool()); configFile.setLaunchOnSystemStartup(settings->value(ConfigFile::launchOnSystemStartupC, configFile.launchOnSystemStartup()).toBool()); + const auto useMonoIcons = settings->value(ConfigFile::monoIconsC, configFile.monoIcons()).toBool(); + Theme::instance()->setSystrayUseMonoIcons(useMonoIcons); + configFile.setMonoIcons(useMonoIcons); configFile.setOptionalServerNotifications(settings->value(ConfigFile::optionalServerNotificationsC, configFile.optionalServerNotifications()).toBool()); configFile.setPromptDeleteFiles(settings->value(ConfigFile::promptDeleteC, diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index b0ba29ee007b7..105946a9c61c8 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -39,12 +39,10 @@ namespace { static constexpr char showMainDialogAsNormalWindowC[] = "showMainDialogAsNormalWindow"; static constexpr char showConfigBackupWarningC[] = "showConfigBackupWarning"; - static constexpr char remotePollIntervalC[] = "remotePollInterval"; static constexpr char forceSyncIntervalC[] = "forceSyncInterval"; static constexpr char fullLocalDiscoveryIntervalC[] = "fullLocalDiscoveryInterval"; static constexpr char notificationRefreshIntervalC[] = "notificationRefreshInterval"; -static constexpr char monoIconsC[] = "monoIcons"; static constexpr char deleteFilesThresholdC[] = "deleteFilesThreshold"; static constexpr char skipUpdateCheckC[] = "skipUpdateCheck"; static constexpr char updateCheckIntervalC[] = "updateCheckInterval"; diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 1b37d645882fd..5fbdf32f69318 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -274,6 +274,7 @@ class OWNCLOUDSYNC_EXPORT ConfigFile static constexpr char isVfsEnabledC[] = "isVfsEnabled"; static constexpr char launchOnSystemStartupC[] = "launchOnSystemStartup"; + static constexpr char monoIconsC[] = "monoIcons"; static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications"; static constexpr char promptDeleteC[] = "promptDeleteAllFiles"; static constexpr char showCallNotificationsC[] = "showCallNotifications"; From 93f17b713be412b78e6cf71b21510c196a81f126 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 19 Nov 2025 13:40:17 +0100 Subject: [PATCH 2/4] fix(migration): do not ovewrite account settings with global ones. - Move logic to migrate network/proxy settings to one place. - Do not overwrite account settings with global settings if the account proxy type was different of the default values. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 118 ++++++++++++++++++++++--------------- src/gui/accountmanager.h | 2 +- 2 files changed, 70 insertions(+), 50 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index b941ca80f5ac2..b126231b94822 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -139,8 +139,8 @@ AccountManager::AccountsRestoreResult AccountManager::restore(const bool alsoRes jar->restore(acc->cookieJarPath()); } addAccountState(accState); + migrateNetworkSettings(acc, *settings); settings->endGroup(); - moveNetworkSettingsFromGlobalToAccount(acc); } else { qCInfo(lcAccountManager) << "Account" << accountId << "is too new, ignoring"; _additionalBlockedAccountIds.insert(accountId); @@ -323,7 +323,8 @@ bool AccountManager::restoreFromLegacySettings() : ConfigFile::unbrandedAppName; const auto updaterGroupName = QString("%1/%2").arg(previousAppName, ConfigFile::autoUpdateCheckC); configFile.setAutoUpdateCheck(settings->value(updaterGroupName, configFile.autoUpdateCheck()).toBool(), {}); - // Network + + // Global Proxy and Network ClientProxy().saveProxyConfigurationFromSettings(*settings); configFile.setUseUploadLimit(settings->value(ConfigFile::useUploadLimitC, configFile.useUploadLimit()).toInt()); configFile.setUploadLimit(settings->value(ConfigFile::uploadLimitC, configFile.uploadLimit()).toInt()); @@ -342,8 +343,8 @@ bool AccountManager::restoreFromLegacySettings() continue; } addAccount(acc); + migrateNetworkSettings(acc, *settings); settings->endGroup(); - moveNetworkSettingsFromGlobalToAccount(acc); } configFile.cleanupGlobalNetworkConfiguration(); ClientProxy().cleanupGlobalNetworkConfiguration(); @@ -510,30 +511,74 @@ void AccountManager::saveAccountHelper(const AccountPtr &account, QSettings &set } } -void AccountManager::moveNetworkSettingsFromGlobalToAccount(const AccountPtr &account) +void AccountManager::migrateNetworkSettings(const AccountPtr &account, const QSettings &settings) { - ConfigFile configFile; - const auto hostname = configFile.proxyHostName(); - - if (!hostname.isEmpty()) { - account->setProxySettings(static_cast(configFile.proxyType()), - hostname, - configFile.proxyPort(), - configFile.proxyNeedsAuth(), - configFile.proxyUser(), - configFile.proxyPassword()); - } + // QSettings from old ConfigFile to new ConfigFile to Account + auto accountProxyType = settings.value(networkProxyTypeC).value(); + auto accountProxyHost = settings.value(networkProxyHostNameC).toString(); + auto accountProxyPort = settings.value(networkProxyPortC).toInt(); + auto accountProxyNeedsAuth = settings.value(networkProxyNeedsAuthC).toBool(); + auto accountProxyUser = settings.value(networkProxyUserC).toString(); - const auto useUploadLimit = configFile.useUploadLimit(); - const auto useDownloadLimit = configFile.useDownloadLimit(); - if (useUploadLimit == 0 && useDownloadLimit == 0) { - return; + ConfigFile configFile; + const auto globalProxyType = static_cast(configFile.proxyType()); + + // Check if any proxy was set in the global settings + const auto accountHasDefaultOrNoProxy = accountProxyType == QNetworkProxy::NoProxy + || accountProxyType == QNetworkProxy::DefaultProxy; + const auto globalHasDefinedProxy = globalProxyType != QNetworkProxy::NoProxy; + if (globalHasDefinedProxy && accountHasDefaultOrNoProxy) { + accountProxyType = globalProxyType; + accountProxyHost = configFile.proxyHostName(); + accountProxyPort = configFile.proxyPort(); + accountProxyNeedsAuth = configFile.proxyNeedsAuth(); + accountProxyUser = configFile.proxyUser(); + qCInfo(lcAccountManager) << "Account has no proxy set, using global proxy instead:" << accountProxyType; + } + account->setProxyType(accountProxyType); + account->setProxyHostName(accountProxyHost); + account->setProxyPort(accountProxyPort); + account->setProxyNeedsAuth(accountProxyNeedsAuth); + account->setProxyUser(accountProxyUser); + + // Global network settings vs User network settings + const auto globalUseUploadLimit = static_cast(configFile.useUploadLimit()); + const auto globalUseDownloadLimit = static_cast(configFile.useDownloadLimit()); + // User network settings + auto userUseUploadLimit = static_cast(settings.value(networkUploadLimitSettingC, + QVariant::fromValue(account->uploadLimitSetting())).toInt()); + auto userUploadLimit = settings.value(networkUploadLimitC, account->uploadLimit()).toInt(); + auto userUseDownloadLimit = static_cast(settings.value(networkDownloadLimitSettingC, + QVariant::fromValue(account->downloadLimitSetting())).toInt()); + auto userDownloadLimit = settings.value(networkDownloadLimitC, account->downloadLimit()).toInt(); + + // Override user settings with global settings if the global setting exists + const auto globalNetworkIsDefined = globalUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit; + const auto userNetworkIsNotDefined = [](Account::AccountNetworkTransferLimitSetting userNetworkLimit) -> bool { + return userNetworkLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit + || userNetworkLimit == Account::AccountNetworkTransferLimitSetting::NoLimit; + }; + if (globalNetworkIsDefined && userNetworkIsNotDefined(userUseUploadLimit)) { + userUseUploadLimit = globalUseUploadLimit; + userUploadLimit = configFile.uploadLimit(); + qCDebug(lcAccountManager) << "Overriding upload limit with global setting:" << userUseUploadLimit + << "- upload limit:" << userUploadLimit; + } + if (globalNetworkIsDefined && userNetworkIsNotDefined(userUseDownloadLimit)) { + userUseDownloadLimit = globalUseDownloadLimit; + userDownloadLimit = configFile.downloadLimit(); + qCDebug(lcAccountManager) << "Overriding download limit with global setting" << userUseDownloadLimit + << "- download limit:" << userDownloadLimit; + } + + if (userUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit) { + account->setUploadLimitSetting(userUseUploadLimit); + account->setUploadLimit(userUploadLimit); + } + if (userUseDownloadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit) { + account->setDownloadLimitSetting(userUseDownloadLimit); + account->setDownloadLimit(userDownloadLimit); } - - account->setUploadLimitSetting(static_cast(useUploadLimit)); - account->setUploadLimit(configFile.uploadLimit()); - account->setDownloadLimitSetting(static_cast(useDownloadLimit)); - account->setDownloadLimit(configFile.downloadLimit()); } AccountPtr AccountManager::loadAccountHelper(QSettings &settings) @@ -609,31 +654,6 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) } acc->setCredentials(CredentialsFactory::create(authType)); - { - auto accountProxyType = settings.value(networkProxyTypeC).value(); - auto accountProxyHost = settings.value(networkProxyHostNameC).toString(); - auto accountProxyPort = settings.value(networkProxyPortC).toInt(); - auto accountProxyNeedsAuth = settings.value(networkProxyNeedsAuthC).toBool(); - auto accountProxyUser = settings.value(networkProxyUserC).toString(); - const auto globalProxyType = settings.value(ClientProxy::proxyTypeC).value(); - qCDebug(lcAccountManager) << "Account proxy type:" << accountProxyType; - qCDebug(lcAccountManager) << "Global proxy type:" << globalProxyType; - if (accountProxyType == QNetworkProxy::NoProxy && globalProxyType != QNetworkProxy::NoProxy) { - accountProxyType = globalProxyType; - accountProxyHost = settings.value(ClientProxy::proxyHostC).toString(); - accountProxyPort = settings.value(ClientProxy::proxyPortC).toInt(); - accountProxyNeedsAuth = settings.value(ClientProxy::proxyNeedsAuthC).toBool(); - accountProxyUser = settings.value(ClientProxy::proxyUserC).toString(); - qCInfo(lcAccountManager) << "Account has no proxy set, using global proxy instead."; - } - - acc->setProxyType(accountProxyType); - acc->setProxyHostName(accountProxyHost); - acc->setProxyPort(accountProxyPort); - acc->setProxyNeedsAuth(accountProxyNeedsAuth); - acc->setProxyUser(accountProxyUser); - } - acc->setUploadLimitSetting( settings.value( networkUploadLimitSettingC, diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index ea597594d08ad..7a1efcdd515a7 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -113,7 +113,7 @@ public slots: // saving and loading Account to settings void saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials = true); AccountPtr loadAccountHelper(QSettings &settings); - void moveNetworkSettingsFromGlobalToAccount(const AccountPtr &account); + void migrateNetworkSettings(const AccountPtr &account, const QSettings &settings); bool restoreFromLegacySettings(); From 58d0a9d83332d8b0f6fff966e61a859225e96235 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 19 Nov 2025 21:15:59 +0100 Subject: [PATCH 3/4] fix(migration): check status of migration when fetching proxy password from keychain. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index b126231b94822..4abbeb2058e1b 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -667,8 +667,11 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) acc->setUploadLimit(settings.value(networkUploadLimitC).toInt()); acc->setDownloadLimit(settings.value(networkDownloadLimitC).toInt()); + ConfigFile configFile; const auto proxyPasswordKey = QString(acc->userIdAtHostWithPort() + networkProxyPasswordKeychainKeySuffixC); - const auto job = new QKeychain::ReadPasswordJob(Theme::instance()->appName(), this); + const auto appName = configFile.isUnbrandedToBrandedMigrationInProgress() ? ConfigFile::unbrandedAppName + : Theme::instance()->appName(); + const auto job = new QKeychain::ReadPasswordJob(appName, this); job->setKey(proxyPasswordKey); connect(job, &QKeychain::Job::finished, this, [acc](const QKeychain::Job *const incomingJob) { const auto incomingReadJob = qobject_cast(incomingJob); From 8407a0ead220078612daf70315be7870ced7522b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 20 Nov 2025 11:27:14 +0100 Subject: [PATCH 4/4] fix(migration): overwrite account settings only if it was using global settings. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 4abbeb2058e1b..9b8648fd42d28 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -46,6 +46,7 @@ constexpr auto serverVersionC = "serverVersion"; constexpr auto serverColorC = "serverColor"; constexpr auto serverTextColorC = "serverTextColor"; constexpr auto skipE2eeMetadataChecksumValidationC = "skipE2eeMetadataChecksumValidation"; +constexpr auto networkProxySettingC = "networkProxySetting"; constexpr auto networkProxyTypeC = "networkProxyType"; constexpr auto networkProxyHostNameC = "networkProxyHostName"; constexpr auto networkProxyPortC = "networkProxyPort"; @@ -520,28 +521,22 @@ void AccountManager::migrateNetworkSettings(const AccountPtr &account, const QSe auto accountProxyNeedsAuth = settings.value(networkProxyNeedsAuthC).toBool(); auto accountProxyUser = settings.value(networkProxyUserC).toString(); + // Override user settings with global settings if user is set to use global settings ConfigFile configFile; - const auto globalProxyType = static_cast(configFile.proxyType()); - - // Check if any proxy was set in the global settings - const auto accountHasDefaultOrNoProxy = accountProxyType == QNetworkProxy::NoProxy - || accountProxyType == QNetworkProxy::DefaultProxy; - const auto globalHasDefinedProxy = globalProxyType != QNetworkProxy::NoProxy; - if (globalHasDefinedProxy && accountHasDefaultOrNoProxy) { - accountProxyType = globalProxyType; + auto accountProxySetting = settings.value(networkProxySettingC).toInt(); + if (accountProxySetting == 0 && configFile.isMigrationInProgress()) { + accountProxyType = static_cast(configFile.proxyType()); accountProxyHost = configFile.proxyHostName(); accountProxyPort = configFile.proxyPort(); accountProxyNeedsAuth = configFile.proxyNeedsAuth(); accountProxyUser = configFile.proxyUser(); - qCInfo(lcAccountManager) << "Account has no proxy set, using global proxy instead:" << accountProxyType; + qCInfo(lcAccountManager) << "Account is using global settings:" << accountProxyType; } account->setProxyType(accountProxyType); account->setProxyHostName(accountProxyHost); account->setProxyPort(accountProxyPort); account->setProxyNeedsAuth(accountProxyNeedsAuth); account->setProxyUser(accountProxyUser); - - // Global network settings vs User network settings const auto globalUseUploadLimit = static_cast(configFile.useUploadLimit()); const auto globalUseDownloadLimit = static_cast(configFile.useDownloadLimit()); // User network settings @@ -551,26 +546,18 @@ void AccountManager::migrateNetworkSettings(const AccountPtr &account, const QSe auto userUseDownloadLimit = static_cast(settings.value(networkDownloadLimitSettingC, QVariant::fromValue(account->downloadLimitSetting())).toInt()); auto userDownloadLimit = settings.value(networkDownloadLimitC, account->downloadLimit()).toInt(); - - // Override user settings with global settings if the global setting exists - const auto globalNetworkIsDefined = globalUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit; - const auto userNetworkIsNotDefined = [](Account::AccountNetworkTransferLimitSetting userNetworkLimit) -> bool { - return userNetworkLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit - || userNetworkLimit == Account::AccountNetworkTransferLimitSetting::NoLimit; - }; - if (globalNetworkIsDefined && userNetworkIsNotDefined(userUseUploadLimit)) { + if (userUseUploadLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit) { userUseUploadLimit = globalUseUploadLimit; userUploadLimit = configFile.uploadLimit(); qCDebug(lcAccountManager) << "Overriding upload limit with global setting:" << userUseUploadLimit << "- upload limit:" << userUploadLimit; } - if (globalNetworkIsDefined && userNetworkIsNotDefined(userUseDownloadLimit)) { + if (userUseDownloadLimit == Account::AccountNetworkTransferLimitSetting::LegacyGlobalLimit) { userUseDownloadLimit = globalUseDownloadLimit; userDownloadLimit = configFile.downloadLimit(); qCDebug(lcAccountManager) << "Overriding download limit with global setting" << userUseDownloadLimit << "- download limit:" << userDownloadLimit; } - if (userUseUploadLimit != Account::AccountNetworkTransferLimitSetting::NoLimit) { account->setUploadLimitSetting(userUseUploadLimit); account->setUploadLimit(userUploadLimit);