From 4f77a9d91d5841771d27821ced76c7c6801790f5 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sun, 5 Dec 2021 16:22:22 +0100 Subject: AtmManager: Minor clean up --- src/client/QXmppAtmManager.cpp | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/client/QXmppAtmManager.cpp') diff --git a/src/client/QXmppAtmManager.cpp b/src/client/QXmppAtmManager.cpp index fb20f922..829daa20 100644 --- a/src/client/QXmppAtmManager.cpp +++ b/src/client/QXmppAtmManager.cpp @@ -373,31 +373,31 @@ QFuture QXmppAtmManager::handleMessage(const QXmppMessage &message) /// QFuture QXmppAtmManager::authenticate(const QString &encryption, const QMultiHash &keyIds) { + if (keyIds.isEmpty()) { + return makeReadyFuture(); + } + QFutureInterface interface(QFutureInterfaceBase::Started); - if (keyIds.isEmpty()) { - interface.reportFinished(); - } else { - auto future = m_trustStorage->setTrustLevel(encryption, keyIds, QXmppTrustStorage::Authenticated); - await(future, this, [=]() mutable { - await(m_trustStorage->securityPolicy(encryption), this, [=](const auto securityPolicy) mutable { - if (securityPolicy == QXmppTrustStorage::Toakafa) { - auto future = distrustAutomaticallyTrustedKeys(encryption, keyIds.uniqueKeys()); - await(future, this, [=]() mutable { - auto future = makePostponedTrustDecisions(encryption, keyIds.values()); - await(future, this, [=]() mutable { - interface.reportFinished(); - }); - }); - } else { + auto future = m_trustStorage->setTrustLevel(encryption, keyIds, QXmppTrustStorage::Authenticated); + await(future, this, [=]() mutable { + await(m_trustStorage->securityPolicy(encryption), this, [=](const auto securityPolicy) mutable { + if (securityPolicy == QXmppTrustStorage::Toakafa) { + auto future = distrustAutomaticallyTrustedKeys(encryption, keyIds.uniqueKeys()); + await(future, this, [=]() mutable { auto future = makePostponedTrustDecisions(encryption, keyIds.values()); await(future, this, [=]() mutable { interface.reportFinished(); }); - } - }); + }); + } else { + auto future = makePostponedTrustDecisions(encryption, keyIds.values()); + await(future, this, [=]() mutable { + interface.reportFinished(); + }); + } }); - } + }); return interface.future(); } @@ -410,19 +410,19 @@ QFuture QXmppAtmManager::authenticate(const QString &encryption, const QMu /// QFuture QXmppAtmManager::distrust(const QString &encryption, const QMultiHash &keyIds) { + if (keyIds.isEmpty()) { + return makeReadyFuture(); + } + QFutureInterface interface(QFutureInterfaceBase::Started); - if (keyIds.isEmpty()) { - interface.reportFinished(); - } else { - auto future = m_trustStorage->setTrustLevel(encryption, keyIds, QXmppTrustStorage::ManuallyDistrusted); + auto future = m_trustStorage->setTrustLevel(encryption, keyIds, QXmppTrustStorage::ManuallyDistrusted); + await(future, this, [=]() mutable { + auto future = m_trustStorage->removeKeysForPostponedTrustDecisions(encryption, keyIds.values()); await(future, this, [=]() mutable { - auto future = m_trustStorage->removeKeysForPostponedTrustDecisions(encryption, keyIds.values()); - await(future, this, [=]() mutable { - interface.reportFinished(); - }); + interface.reportFinished(); }); - } + }); return interface.future(); } -- cgit v1.2.3