From: Claudio Cambra Date: Tue, 16 Apr 2024 18:06:30 +0000 (+0800) Subject: Remove client-side push notification handling for file provider extension in favour... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~45^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=86e7ded16349eb8dcb131f0ce501ee7f8e1c88a1;p=nextcloud-desktop.git Remove client-side push notification handling for file provider extension in favour of simply using NCFPK remote change observer Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderdomainmanager.h b/src/gui/macOS/fileproviderdomainmanager.h index 8de3fc1f2..dcb1f9f60 100644 --- a/src/gui/macOS/fileproviderdomainmanager.h +++ b/src/gui/macOS/fileproviderdomainmanager.h @@ -49,17 +49,10 @@ private slots: void disconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState, const QString &reason); void reconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState); - void trySetupPushNotificationsForAccount(const OCC::Account * const account); - void setupPushNotificationsForAccount(const OCC::Account * const account); void signalEnumeratorChanged(const OCC::Account * const account); - void slotAccountStateChanged(const OCC::AccountState * const accountState); - void slotEnumeratorSignallingTimerTimeout(); private: - // Starts regular enumerator signalling if no push notifications available - QTimer _enumeratorSignallingTimer; - class MacImplementation; std::unique_ptr d; }; diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index 331c44df5..6e59f621a 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -20,7 +20,6 @@ #include "config.h" #include "fileproviderdomainmanager.h" #include "fileprovidersettingscontroller.h" -#include "pushnotifications.h" #include "gui/accountmanager.h" #include "libsync/account.h" @@ -67,14 +66,6 @@ QString accountIdFromDomain(NSFileProviderDomain * const domain) return accountIdFromDomainId(domain.identifier); } -bool accountFilesPushNotificationsReady(const OCC::AccountPtr &account) -{ - const auto pushNotifications = account->pushNotifications(); - const auto pushNotificationsCapability = account->capabilities().availablePushNotifications() & OCC::PushNotificationType::Files; - - return pushNotificationsCapability && pushNotifications && pushNotifications->isReady(); -} - } namespace OCC { @@ -420,11 +411,6 @@ FileProviderDomainManager::~FileProviderDomainManager() = default; void FileProviderDomainManager::start() { ConfigFile cfg; - std::chrono::milliseconds polltime = cfg.remotePollInterval(); - _enumeratorSignallingTimer.setInterval(polltime.count()); - connect(&_enumeratorSignallingTimer, &QTimer::timeout, - this, &FileProviderDomainManager::slotEnumeratorSignallingTimerTimeout); - _enumeratorSignallingTimer.start(); setupFileProviderDomains(); @@ -498,54 +484,6 @@ void FileProviderDomainManager::addFileProviderDomainForAccount(const AccountSta connect(accountState, &AccountState::stateChanged, this, [this, accountState] { slotAccountStateChanged(accountState); }); - - // Setup push notifications - const auto accountCapabilities = account->capabilities().isValid(); - if (!accountCapabilities) { - connect(account.get(), &Account::capabilitiesChanged, this, [this, account] { - trySetupPushNotificationsForAccount(account.get()); - }); - return; - } - - trySetupPushNotificationsForAccount(account.get()); -} - -void FileProviderDomainManager::trySetupPushNotificationsForAccount(const Account * const account) -{ - if (!d) { - return; - } - - Q_ASSERT(account); - - const auto pushNotifications = account->pushNotifications(); - const auto pushNotificationsCapability = account->capabilities().availablePushNotifications() & PushNotificationType::Files; - - if (pushNotificationsCapability && pushNotifications && pushNotifications->isReady()) { - qCDebug(lcMacFileProviderDomainManager) << "Push notifications already ready, connecting them to enumerator signalling." - << account->displayName(); - setupPushNotificationsForAccount(account); - } else if (pushNotificationsCapability) { - qCDebug(lcMacFileProviderDomainManager) << "Push notifications not yet ready, will connect to signalling when ready." - << account->displayName(); - connect(account, &Account::pushNotificationsReady, this, &FileProviderDomainManager::setupPushNotificationsForAccount); - } -} - -void FileProviderDomainManager::setupPushNotificationsForAccount(const Account * const account) -{ - if (!d) { - return; - } - - Q_ASSERT(account); - - qCDebug(lcMacFileProviderDomainManager) << "Setting up push notifications for file provider domain for account:" - << account->displayName(); - - connect(account->pushNotifications(), &PushNotifications::filesChanged, this, &FileProviderDomainManager::signalEnumeratorChanged); - disconnect(account, &Account::pushNotificationsReady, this, &FileProviderDomainManager::setupPushNotificationsForAccount); } void FileProviderDomainManager::signalEnumeratorChanged(const Account * const account) @@ -569,13 +507,6 @@ void FileProviderDomainManager::removeFileProviderDomainForAccount(const Account Q_ASSERT(account); d->removeFileProviderDomain(accountState); - - if (accountFilesPushNotificationsReady(account)) { - const auto pushNotifications = account->pushNotifications(); - disconnect(pushNotifications, &PushNotifications::filesChanged, this, &FileProviderDomainManager::signalEnumeratorChanged); - } else if (const auto hasFilesPushNotificationsCapability = account->capabilities().availablePushNotifications() & PushNotificationType::Files) { - disconnect(account.get(), &Account::pushNotificationsReady, this, &FileProviderDomainManager::setupPushNotificationsForAccount); - } } void FileProviderDomainManager::disconnectFileProviderDomainForAccount(const AccountState * const accountState, const QString &reason) @@ -639,27 +570,6 @@ void FileProviderDomainManager::slotAccountStateChanged(const AccountState * con } } -void FileProviderDomainManager::slotEnumeratorSignallingTimerTimeout() -{ - if (!d) { - return; - } - - qCDebug(lcMacFileProviderDomainManager) << "Enumerator signalling timer timed out, notifying domains for accounts without push notifications"; - - const auto registeredDomainIds = d->configuredDomainIds(); - for (const auto &domainId : registeredDomainIds) { - const auto accountUserId = accountIdFromDomainId(domainId); - const auto accountState = AccountManager::instance()->accountFromUserId(accountUserId); - const auto account = accountState->account(); - - if (!accountFilesPushNotificationsReady(account)) { - qCDebug(lcMacFileProviderDomainManager) << "Notifying domain for account:" << account->userIdAtHostWithPort(); - d->signalEnumeratorChanged(account.get()); - } - } -} - AccountStatePtr FileProviderDomainManager::accountStateFromFileProviderDomainIdentifier(const QString &domainIdentifier) { if (domainIdentifier.isEmpty()) {