From: Claudio Cambra Date: Mon, 13 Mar 2023 17:02:34 +0000 (+0100) Subject: Run poll timer for enumerator signalling to notify accounts without push notification... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~96^2^2~55^2~111 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=017de893f0d50f5eb27dc25da1fa27e4ed8edc08;p=nextcloud-desktop.git Run poll timer for enumerator signalling to notify accounts without push notifications in FileProviderDomainManager Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderdomainmanager.h b/src/gui/macOS/fileproviderdomainmanager.h index e96f34707..b175e621a 100644 --- a/src/gui/macOS/fileproviderdomainmanager.h +++ b/src/gui/macOS/fileproviderdomainmanager.h @@ -44,9 +44,13 @@ private slots: void setupPushNotificationsForAccount(const OCC::Account * const account); void signalEnumeratorChanged(const OCC::Account * const account); - void slotAccountStateChanged(const AccountState * const accountState); + void slotAccountStateChanged(const OCC::AccountState * const accountState); + void slotEnumeratorSignallingTimerTimeout(); private: + // Starts regular enumerator signalling if no push notifications available + QTimer _enumeratorSignallingTimer; + explicit FileProviderDomainManager(QObject * const parent = nullptr); static FileProviderDomainManager *_instance; class Private; diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index cf2f470a1..22c440941 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -12,6 +12,7 @@ * for more details. */ +#include "configfile.h" #import #include @@ -435,6 +436,13 @@ FileProviderDomainManager::FileProviderDomainManager(QObject * const parent) { d.reset(new FileProviderDomainManager::Private()); + ConfigFile cfg; + std::chrono::milliseconds polltime = cfg.remotePollInterval(); + _enumeratorSignallingTimer.setInterval(polltime.count()); + connect(&_enumeratorSignallingTimer, &QTimer::timeout, + this, &FileProviderDomainManager::slotEnumeratorSignallingTimerTimeout); + _enumeratorSignallingTimer.start(); + setupFileProviderDomains(); connect(AccountManager::instance(), &AccountManager::accountAdded, @@ -596,6 +604,23 @@ void FileProviderDomainManager::slotAccountStateChanged(const AccountState * con } } +void FileProviderDomainManager::slotEnumeratorSignallingTimerTimeout() +{ + 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()); + } + } +} + } // namespace Mac } // namespace OCC