From 6129b80d8ffcf790297869d630719965239fbf64 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 6 Sep 2023 15:42:12 +0800 Subject: [PATCH] Enable file provider domains per the settings in the file provider domain manager Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderdomainmanager_mac.mm | 17 +++++++++++++++-- src/gui/macOS/fileprovidersettingscontroller.h | 1 + .../macOS/fileprovidersettingscontroller_mac.mm | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index 29b3ee244c27b..7bd41597d5300 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -19,6 +19,7 @@ #include "config.h" #include "fileproviderdomainmanager.h" +#include "fileprovidersettingscontroller.h" #include "pushnotifications.h" #include "gui/accountmanager.h" @@ -380,7 +381,8 @@ void signalEnumeratorChanged(const Account * const account) } } - QStringList configuredDomainIds() const { + QStringList configuredDomainIds() const + { return _registeredDomains.keys(); } @@ -431,9 +433,20 @@ QStringList configuredDomainIds() const { d->findExistingFileProviderDomains(); - for(auto &accountState : AccountManager::instance()->accounts()) { + const auto vfsEnabledAccounts = FileProviderSettingsController::instance()->vfsEnabledAccounts(); + auto domainsToRemove = d->configuredDomainIds(); + + for (const auto &accountUserIdAtHost : vfsEnabledAccounts) { + domainsToRemove.removeAll(accountUserIdAtHost); + + const auto accountState = AccountManager::instance()->accountFromUserId(accountUserIdAtHost); addFileProviderDomainForAccount(accountState.data()); } + + for (const auto &remainingDomainUserId : domainsToRemove) { + const auto accountState = AccountManager::instance()->accountFromUserId(remainingDomainUserId); + removeFileProviderDomainForAccount(accountState.data()); + } } void FileProviderDomainManager::addFileProviderDomainForAccount(const AccountState * const accountState) diff --git a/src/gui/macOS/fileprovidersettingscontroller.h b/src/gui/macOS/fileprovidersettingscontroller.h index 7b9d4fc5885df..880f13c359944 100644 --- a/src/gui/macOS/fileprovidersettingscontroller.h +++ b/src/gui/macOS/fileprovidersettingscontroller.h @@ -32,6 +32,7 @@ class FileProviderSettingsController : public QObject QWidget *const parent = nullptr, const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView); + [[nodiscard]] QStringList vfsEnabledAccounts() const; [[nodiscard]] Q_INVOKABLE bool vfsEnabledForAccount(const QString &userIdAtHost) const; public slots: diff --git a/src/gui/macOS/fileprovidersettingscontroller_mac.mm b/src/gui/macOS/fileprovidersettingscontroller_mac.mm index b9f3c5de71e0e..18dd0c115a0b0 100644 --- a/src/gui/macOS/fileprovidersettingscontroller_mac.mm +++ b/src/gui/macOS/fileprovidersettingscontroller_mac.mm @@ -183,6 +183,11 @@ void initialCheck() return settingsViewWidget; } +QStringList FileProviderSettingsController::vfsEnabledAccounts() const +{ + return d->enabledAccounts(); +} + bool FileProviderSettingsController::vfsEnabledForAccount(const QString &userIdAtHost) const { return d->vfsEnabledForAccount(userIdAtHost);