зеркало из https://github.com/nextcloud/desktop.git
Run poll timer for enumerator signalling to notify accounts without push notifications in FileProviderDomainManager
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
bb2718824c
Коммит
017de893f0
|
@ -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;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#include "configfile.h"
|
||||
#import <FileProvider/FileProvider.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче