Skip to content

Commit

Permalink
Enable file provider domains per the settings in the file provider do…
Browse files Browse the repository at this point in the history
…main manager

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Sep 6, 2023
1 parent d008f22 commit 6129b80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/gui/macOS/fileproviderdomainmanager_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "config.h"
#include "fileproviderdomainmanager.h"
#include "fileprovidersettingscontroller.h"
#include "pushnotifications.h"

#include "gui/accountmanager.h"
Expand Down Expand Up @@ -380,7 +381,8 @@ void signalEnumeratorChanged(const Account * const account)
}
}

QStringList configuredDomainIds() const {
QStringList configuredDomainIds() const
{
return _registeredDomains.keys();
}

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/gui/macOS/fileprovidersettingscontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/gui/macOS/fileprovidersettingscontroller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6129b80

Please sign in to comment.