зеркало из https://github.com/nextcloud/desktop.git
Merge pull request #7350 from nextcloud/bugfix/updatechannels
Bugfix update channels
This commit is contained in:
Коммит
eb50768efb
|
@ -338,7 +338,7 @@ 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);
|
||||
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->capabilities().serverHasValidSubscription());
|
||||
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->serverHasValidSubscription());
|
||||
|
||||
if (!acc->_skipE2eeMetadataChecksumValidation) {
|
||||
settings.remove(QLatin1String(skipE2eeMetadataChecksumValidationC));
|
||||
|
@ -611,10 +611,30 @@ void AccountManager::deleteAccount(OCC::AccountState *account)
|
|||
|
||||
account->account()->deleteAppToken();
|
||||
|
||||
// clean up config from subscriptions if the account removed was the only with valid subscription
|
||||
if (account->account()->serverHasValidSubscription()) {
|
||||
updateServerHasValidSubscriptionConfig();
|
||||
}
|
||||
|
||||
emit accountSyncConnectionRemoved(account);
|
||||
emit accountRemoved(account);
|
||||
}
|
||||
|
||||
void AccountManager::updateServerHasValidSubscriptionConfig()
|
||||
{
|
||||
auto serverHasValidSubscription = false;
|
||||
for (const auto &account : _accounts) {
|
||||
if (!account->account()->serverHasValidSubscription()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
serverHasValidSubscription = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ConfigFile().setServerHasValidSubscription(serverHasValidSubscription);
|
||||
}
|
||||
|
||||
AccountPtr AccountManager::createAccount()
|
||||
{
|
||||
const auto acc = Account::create();
|
||||
|
@ -670,10 +690,17 @@ void AccountManager::addAccountState(AccountState *const accountState)
|
|||
Q_ASSERT(accountState->account());
|
||||
|
||||
QObject::connect(accountState->account().data(), &Account::wantsAccountSaved, this, &AccountManager::saveAccount);
|
||||
QObject::connect(accountState->account().data(), &Account::capabilitiesChanged, this, &AccountManager::capabilitiesChanged);
|
||||
|
||||
AccountStatePtr ptr(accountState);
|
||||
_accounts << ptr;
|
||||
ptr->trySignIn();
|
||||
|
||||
// update config subscriptions if the account added is the only with valid subscription
|
||||
if (accountState->account()->serverHasValidSubscription() && !ConfigFile().serverHasValidSubscription()) {
|
||||
updateServerHasValidSubscriptionConfig();
|
||||
}
|
||||
|
||||
emit accountAdded(accountState);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ signals:
|
|||
void accountSyncConnectionRemoved(OCC::AccountState *account);
|
||||
void removeAccountFolders(OCC::AccountState *account);
|
||||
void forceLegacyImportChanged();
|
||||
void capabilitiesChanged();
|
||||
|
||||
private:
|
||||
// saving and loading Account to settings
|
||||
|
@ -128,6 +129,9 @@ private:
|
|||
// Adds an account to the tracked list, emitting accountAdded()
|
||||
void addAccountState(AccountState *const accountState);
|
||||
|
||||
// update config serverHasValidSubscription when accounts list changes
|
||||
void updateServerHasValidSubscriptionConfig();
|
||||
|
||||
AccountManager() = default;
|
||||
QList<AccountStatePtr> _accounts;
|
||||
/// Account ids from settings that weren't read
|
||||
|
|
|
@ -244,6 +244,10 @@ GeneralSettings::GeneralSettings(QWidget *parent)
|
|||
// accountAdded means the wizard was finished and the wizard might change some options.
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings);
|
||||
|
||||
#if defined(BUILD_UPDATER)
|
||||
loadUpdateChannelsList();
|
||||
#endif
|
||||
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
|
@ -284,18 +288,22 @@ void GeneralSettings::loadMiscSettings()
|
|||
_ui->stopExistingFolderNowBigSyncCheckBox->setChecked(_ui->existingFolderLimitCheckBox->isChecked() && cfgFile.stopSyncingExistingFoldersOverLimit());
|
||||
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
|
||||
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
|
||||
|
||||
#if defined(BUILD_UPDATER)
|
||||
const auto validUpdateChannels = cfgFile.validUpdateChannels();
|
||||
_ui->updateChannel->clear();
|
||||
_ui->updateChannel->addItems(validUpdateChannels);
|
||||
const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel());
|
||||
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0);
|
||||
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(BUILD_UPDATER)
|
||||
void GeneralSettings::loadUpdateChannelsList() {
|
||||
ConfigFile cfgFile;
|
||||
const auto validUpdateChannels = cfgFile.validUpdateChannels();
|
||||
if (_currentUpdateChannelList.isEmpty() || (_currentUpdateChannelList != validUpdateChannels && !cfgFile.serverHasValidSubscription())) {
|
||||
_currentUpdateChannelList = validUpdateChannels;
|
||||
_ui->updateChannel->clear();
|
||||
_ui->updateChannel->addItems(_currentUpdateChannelList);
|
||||
const auto currentUpdateChannelIndex = _currentUpdateChannelList.indexOf(cfgFile.currentUpdateChannel());
|
||||
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1 ? currentUpdateChannelIndex : 0);
|
||||
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettings::slotUpdateInfo()
|
||||
{
|
||||
ConfigFile config;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
namespace OCC {
|
||||
class IgnoreListEditor;
|
||||
class SyncLogDialog;
|
||||
class AccountState;
|
||||
|
||||
namespace Ui {
|
||||
class GeneralSettings;
|
||||
|
@ -43,6 +44,9 @@ public:
|
|||
|
||||
public slots:
|
||||
void slotStyleChanged();
|
||||
#if defined(BUILD_UPDATER)
|
||||
void loadUpdateChannelsList();
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
void saveMiscSettings();
|
||||
|
@ -67,6 +71,7 @@ private:
|
|||
Ui::GeneralSettings *_ui;
|
||||
QPointer<IgnoreListEditor> _ignoreEditor;
|
||||
bool _currentlyLoading = false;
|
||||
QStringList _currentUpdateChannelList;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -128,6 +128,12 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
|
|||
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
|
||||
connect(this, &SettingsDialog::styleChanged, generalSettings, &GeneralSettings::slotStyleChanged);
|
||||
|
||||
#if defined(BUILD_UPDATER)
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded, generalSettings, &GeneralSettings::loadUpdateChannelsList);
|
||||
connect(AccountManager::instance(), &AccountManager::accountRemoved, generalSettings, &GeneralSettings::loadUpdateChannelsList);
|
||||
connect(AccountManager::instance(), &AccountManager::capabilitiesChanged, generalSettings, &GeneralSettings::loadUpdateChannelsList);
|
||||
#endif
|
||||
|
||||
QAction *networkAction = createColorAwareAction(QLatin1String(":/client/theme/network.svg"), tr("Network"));
|
||||
_actionGroup->addAction(networkAction);
|
||||
_toolBar->addAction(networkAction);
|
||||
|
@ -137,8 +143,9 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
|
|||
_actionGroupWidgets.insert(generalAction, generalSettings);
|
||||
_actionGroupWidgets.insert(networkAction, networkSettings);
|
||||
|
||||
foreach(auto ai, AccountManager::instance()->accounts()) {
|
||||
accountAdded(ai.data());
|
||||
const auto accountsList = AccountManager::instance()->accounts();
|
||||
for (const auto &account : accountsList) {
|
||||
accountAdded(account.data());
|
||||
}
|
||||
|
||||
QTimer::singleShot(1, this, &SettingsDialog::showFirstPage);
|
||||
|
|
|
@ -1076,13 +1076,26 @@ void Account::setAskUserForMnemonic(const bool ask)
|
|||
emit askUserForMnemonicChanged();
|
||||
}
|
||||
|
||||
bool Account::serverHasValidSubscription() const
|
||||
{
|
||||
return _serverHasValidSubscription;
|
||||
}
|
||||
|
||||
void Account::setServerHasValidSubscription(bool valid)
|
||||
{
|
||||
_serverHasValidSubscription = valid;
|
||||
}
|
||||
|
||||
void Account::updateServerSubcription()
|
||||
{
|
||||
ConfigFile currentConfig;
|
||||
if (const auto serverHasValidSubscription = _capabilities.serverHasValidSubscription();
|
||||
serverHasValidSubscription != currentConfig.serverHasValidSubscription()) {
|
||||
currentConfig.setServerHasValidSubscription(serverHasValidSubscription);
|
||||
const auto capabilityValidSubscription = _capabilities.serverHasValidSubscription();
|
||||
const auto configValidSubscription = currentConfig.serverHasValidSubscription();
|
||||
if (capabilityValidSubscription != configValidSubscription && !configValidSubscription) {
|
||||
currentConfig.setServerHasValidSubscription(capabilityValidSubscription);
|
||||
}
|
||||
|
||||
setServerHasValidSubscription(capabilityValidSubscription);
|
||||
}
|
||||
|
||||
void Account::updateDesktopEnterpriseChannel()
|
||||
|
|
|
@ -409,6 +409,9 @@ public:
|
|||
[[nodiscard]] unsigned int downloadLimit() const;
|
||||
void setDownloadLimit(unsigned int kbytes);
|
||||
|
||||
[[nodiscard]] bool serverHasValidSubscription() const;
|
||||
void setServerHasValidSubscription(bool valid);
|
||||
|
||||
public slots:
|
||||
/// Used when forgetting credentials
|
||||
void clearQNAMCache();
|
||||
|
@ -553,6 +556,8 @@ private:
|
|||
unsigned int _uploadLimit = 0;
|
||||
unsigned int _downloadLimit = 0;
|
||||
|
||||
bool _serverHasValidSubscription = false;
|
||||
|
||||
/* IMPORTANT - remove later - FIXME MS@2019-12-07 -->
|
||||
* TODO: For "Log out" & "Remove account": Remove client CA certs and KEY!
|
||||
*
|
||||
|
|
|
@ -707,32 +707,25 @@ QString ConfigFile::defaultUpdateChannel() const
|
|||
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.";
|
||||
qCWarning(lcConfigFile()) << "Default update channel is" << serverChannel << "because that is the desktop enterprise channel returned by the server.";
|
||||
return serverChannel;
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto currentVersionSuffix = Theme::instance()->versionSuffix();
|
||||
validUpdateChannels().contains(currentVersionSuffix) && !isBranded) {
|
||||
qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client.";
|
||||
qCWarning(lcConfigFile()) << "Default update channel is" << currentVersionSuffix << "because of the version suffix of the current client.";
|
||||
return currentVersionSuffix;
|
||||
}
|
||||
|
||||
qCWarning(lcConfigFile()) << "Enforcing default update channel" << defaultUpdateChannelName;
|
||||
qCWarning(lcConfigFile()) << "Default update channel is" << defaultUpdateChannelName;
|
||||
return defaultUpdateChannelName;
|
||||
}
|
||||
|
||||
QString ConfigFile::currentUpdateChannel() const
|
||||
{
|
||||
auto updateChannel = defaultUpdateChannel();
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
if (const auto configUpdateChannel = settings.value(QLatin1String(updateChannelC), updateChannel).toString();
|
||||
validUpdateChannels().contains(configUpdateChannel)) {
|
||||
qCWarning(lcConfigFile()) << "Config file has a valid update channel:" << configUpdateChannel;
|
||||
updateChannel = configUpdateChannel;
|
||||
}
|
||||
|
||||
return updateChannel;
|
||||
return settings.value(QLatin1String(updateChannelC), defaultUpdateChannel()).toString();
|
||||
}
|
||||
|
||||
void ConfigFile::setUpdateChannel(const QString &channel)
|
||||
|
|
Загрузка…
Ссылка в новой задаче