From 7daeec83233c522980d5e477fee82045de57f77d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 12 Jan 2017 11:45:15 +0100 Subject: syncThen is no longer necessary --- common/changereplay.cpp | 2 +- common/commandprocessor.cpp | 12 +++---- common/messagequeue.cpp | 2 +- common/pipeline.cpp | 2 +- common/queryrunner.cpp | 4 +-- common/resourcecontrol.cpp | 4 +-- common/store.cpp | 2 +- common/synchronizer.cpp | 8 ++--- examples/imapresource/imapresource.cpp | 40 +++++++++++----------- examples/imapresource/imapserverproxy.cpp | 14 ++++---- examples/maildirresource/maildirresource.cpp | 4 +-- .../mailtransportresource.cpp | 2 +- sinksh/syntax_modules/sink_sync.cpp | 2 +- tests/accountstest.cpp | 8 ++--- tests/clientapitest.cpp | 2 +- tests/mailsynctest.cpp | 28 +++++++-------- tests/mailtest.cpp | 18 +++++----- tests/mailthreadtest.cpp | 2 +- tests/resourcecommunicationtest.cpp | 6 ++-- 19 files changed, 81 insertions(+), 81 deletions(-) diff --git a/common/changereplay.cpp b/common/changereplay.cpp index 5d5afbb..224fb25 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp @@ -151,7 +151,7 @@ KAsync::Job ChangeReplay::replayNextRevision() return KAsync::value(KAsync::Break); }); })) - .syncThen([this, lastReplayedRevision]() { + .then([this, lastReplayedRevision]() { recordReplayedRevision(*lastReplayedRevision); mMainStoreTransaction.abort(); if (ChangeReplay::allChangesReplayed()) { diff --git a/common/commandprocessor.cpp b/common/commandprocessor.cpp index 7cd4a5f..87a120b 100644 --- a/common/commandprocessor.cpp +++ b/common/commandprocessor.cpp @@ -169,7 +169,7 @@ void CommandProcessor::process() } mProcessingLock = true; auto job = processPipeline() - .syncThen([this]() { + .then([this]() { mProcessingLock = false; if (messagesToProcessAvailable()) { process(); @@ -193,10 +193,10 @@ KAsync::Job CommandProcessor::processQueuedCommand(const Sink::QueuedCom case Sink::Commands::InspectionCommand: Q_ASSERT(mInspector); return mInspector->processCommand(data, size) - .syncThen([]() { return -1; }); + .then(KAsync::value(-1)); case Sink::Commands::FlushCommand: return flush(data, size) - .syncThen([]() { return -1; }); + .then(KAsync::value(-1)); default: return KAsync::error(-1, "Unhandled command"); } @@ -234,7 +234,7 @@ KAsync::Job CommandProcessor::processQueue(MessageQueue *queue) [this, time](const QByteArray &data) -> KAsync::Job { time->start(); return processQueuedCommand(data) - .syncThen([this, time](qint64 createdRevision) { + .then([this, time](qint64 createdRevision) { SinkTraceCtx(mLogCtx) << "Created revision " << createdRevision << ". Processing took: " << Log::TraceTime(time->elapsed()); }); }) @@ -251,7 +251,7 @@ KAsync::Job CommandProcessor::processQueue(MessageQueue *queue) } }); })) - .syncThen([this](const KAsync::Error &) { mPipeline->commit(); }); + .then([this](const KAsync::Error &) { mPipeline->commit(); }); } KAsync::Job CommandProcessor::processPipeline() @@ -273,7 +273,7 @@ KAsync::Job CommandProcessor::processPipeline() auto queue = it->next(); return processQueue(queue) - .syncThen([this, time, it]() { + .then([this, time, it]() { SinkTraceCtx(mLogCtx) << "Queue processed." << Log::TraceTime(time->elapsed()); if (it->hasNext()) { return KAsync::Continue; diff --git a/common/messagequeue.cpp b/common/messagequeue.cpp index 0fcbf99..6e79d89 100644 --- a/common/messagequeue.cpp +++ b/common/messagequeue.cpp @@ -108,7 +108,7 @@ KAsync::Job MessageQueue::dequeueBatch(int maxBatchSize, const std::functi // Trace() << "Waiting on " << waitCondition.size() << " results"; KAsync::waitForCompletion(waitCondition) - .syncThen([this, resultCount, &future]() { + .then([this, resultCount, &future]() { processRemovals(); if (*resultCount == 0) { future.setFinished(); diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 4cb5f21..32f6454 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -279,7 +279,7 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) SinkTraceCtx(d->logCtx) << "Moving entity to new resource " << newEntity.identifier() << newEntity.resourceInstanceIdentifier() << targetResource; auto job = TypeHelper{bufferType}.operator(), ApplicationDomain::ApplicationDomainType&>(newEntity); - job = job.syncThen([this, current, isMove, targetResource, bufferType](const KAsync::Error &error) { + job = job.then([this, current, isMove, targetResource, bufferType](const KAsync::Error &error) { if (!error) { SinkTraceCtx(d->logCtx) << "Move of " << current.identifier() << "was successfull"; if (isMove) { diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index f1e21f4..6730894 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp @@ -94,7 +94,7 @@ QueryRunner::QueryRunner(const Sink::Query &query, const Sink::Resou const auto newRevisionAndReplayedEntities = worker.executeInitialQuery(query, parent, *resultProvider, offset, batchSize); return newRevisionAndReplayedEntities; }) - .template syncThen([this, parentId, query, parent, resultProvider, guardPtr](const ReplayResult &newRevisionAndReplayedEntities) { + .template then([this, parentId, query, parent, resultProvider, guardPtr](const ReplayResult &newRevisionAndReplayedEntities) { if (!guardPtr) { qWarning() << "The parent object is already gone"; return; @@ -124,7 +124,7 @@ QueryRunner::QueryRunner(const Sink::Query &query, const Sink::Resou const auto newRevisionAndReplayedEntities = worker.executeIncrementalQuery(query, *resultProvider); return newRevisionAndReplayedEntities; }) - .template syncThen([query, this, resultProvider, guardPtr](const ReplayResult &newRevisionAndReplayedEntities) { + .template then([query, this, resultProvider, guardPtr](const ReplayResult &newRevisionAndReplayedEntities) { if (!guardPtr) { qWarning() << "The parent object is already gone"; return; diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp index c1fbf06..b24c902 100644 --- a/common/resourcecontrol.cpp +++ b/common/resourcecontrol.cpp @@ -64,7 +64,7 @@ KAsync::Job ResourceControl::shutdown(const QByteArray &identifier) future.setFinished(); } }); - }).syncThen([time] { + }).then([time] { SinkTrace() << "Shutdown complete." << Log::TraceTime(time->elapsed()); }); }); @@ -77,7 +77,7 @@ KAsync::Job ResourceControl::start(const QByteArray &identifier) time->start(); auto resourceAccess = ResourceAccessFactory::instance().getAccess(identifier, ResourceConfig::getResourceType(identifier)); resourceAccess->open(); - return resourceAccess->sendCommand(Sink::Commands::PingCommand).addToContext(resourceAccess).syncThen([time]() { SinkTrace() << "Start complete." << Log::TraceTime(time->elapsed()); }); + return resourceAccess->sendCommand(Sink::Commands::PingCommand).addToContext(resourceAccess).then([time]() { SinkTrace() << "Start complete." << Log::TraceTime(time->elapsed()); }); } KAsync::Job ResourceControl::flushMessageQueue(const QByteArrayList &resourceIdentifier) diff --git a/common/store.cpp b/common/store.cpp index 38445e5..b4ef2b7 100644 --- a/common/store.cpp +++ b/common/store.cpp @@ -263,7 +263,7 @@ KAsync::Job Store::removeDataFromDisk(const QByteArray &identifier) future.setFinished(); } }) - .syncThen([time]() { + .then([time]() { SinkTrace() << "Remove from disk complete." << Log::TraceTime(time->elapsed()); }); } diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index a4e64c9..bb1a3f4 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -286,7 +286,7 @@ KAsync::Job Synchronizer::processSyncQueue() while (!mSyncRequestQueue.isEmpty()) { auto request = mSyncRequestQueue.takeFirst(); if (request.requestType == Synchronizer::SyncRequest::Synchronization) { - job = job.syncThen([this, request] { + job = job.then([this, request] { Sink::Notification n; n.id = request.requestId; n.type = Notification::Status; @@ -294,7 +294,7 @@ KAsync::Job Synchronizer::processSyncQueue() n.code = ApplicationDomain::BusyStatus; emit notify(n); SinkLogCtx(mLogCtx) << "Synchronizing " << request.query; - }).then(synchronizeWithSource(request.query)).syncThen([this] { + }).then(synchronizeWithSource(request.query)).then([this] { //Commit after every request, so implementations only have to commit more if they add a lot of data. commit(); }).then([this, request](const KAsync::Error &error) { @@ -431,7 +431,7 @@ KAsync::Job Synchronizer::replay(const QByteArray &type, const QByteArray job = replay(mail, operation, oldRemoteId, modifiedProperties); } - return job.syncThen([this, operation, type, uid, oldRemoteId](const QByteArray &remoteId) { + return job.then([this, operation, type, uid, oldRemoteId](const QByteArray &remoteId) { if (operation == Sink::Operation_Creation) { SinkTrace() << "Replayed creation with remote id: " << remoteId; if (remoteId.isEmpty()) { @@ -453,7 +453,7 @@ KAsync::Job Synchronizer::replay(const QByteArray &type, const QByteArray SinkError() << "Unkown operation" << operation; } }) - .syncThen([this](const KAsync::Error &error) { + .then([this](const KAsync::Error &error) { if (error) { SinkWarning() << "Failed to replay change: " << error.errorMessage; } diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index a204f4c..c608b04 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -116,7 +116,7 @@ public: if (!parentFolderRid.isEmpty()) { folder.setParent(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, parentFolderRid)); } - createOrModify(ApplicationDomain::getTypeName, remoteId, folder); + createOrModify(ApplicationDomain::getTypeName(), remoteId, folder); return remoteId; } @@ -244,14 +244,14 @@ public: modify(ENTITY_TYPE_MAIL, remoteId, mail); }) - .syncThen([=](const SelectResult &selectResult) { + .then([=](const SelectResult &selectResult) { SinkLogCtx(mLogCtx) << "Flags updated. New changedsince value: " << selectResult.highestModSequence; syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); }); } else { //We hit this path on initial sync and simply record the current changedsince value return imap->select(imap->mailboxFromFolder(folder)) - .syncThen([=](const SelectResult &selectResult) { + .then([=](const SelectResult &selectResult) { SinkLogCtx(mLogCtx) << "No flags to update. New changedsince value: " << selectResult.highestModSequence; syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); }); @@ -303,7 +303,7 @@ public: commit(); } }) - .syncThen([=]() { + .then([=]() { SinkLogCtx(mLogCtx) << "UIDMAX: " << *maxUid << folder.path(); if (*maxUid > 0) { syncStore().writeValue(folderRemoteId, "uidnext", QByteArray::number(*maxUid)); @@ -345,7 +345,7 @@ public: } }); }) - .syncThen([=]() { + .then([=]() { SinkLogCtx(mLogCtx) << "Headers fetched: " << folder.path(); syncStore().writeValue(folderRemoteId, "headersFetched", "true"); commit(); @@ -359,7 +359,7 @@ public: //Finally remove messages that are no longer existing on the server. .then([=]() { //TODO do an examine with QRESYNC and remove VANISHED messages if supported instead - return imap->fetchUids(folder).syncThen>([=](const QVector &uids) { + return imap->fetchUids(folder).then([=](const QVector &uids) { SinkTraceCtx(mLogCtx) << "Syncing removals: " << folder.path(); synchronizeRemovals(folderRemoteId, uids.toList().toSet()); commit(); @@ -425,7 +425,7 @@ public: .onError([](const KAsync::Error &error) { SinkWarning() << "Folder list sync failed."; }) - .syncThen>([folderList]() { return *folderList; } ); + .then([folderList]() { return *folderList; } ); } } @@ -439,7 +439,7 @@ public: return imap->fetchFolders([folderList](const Folder &folder) { *folderList << folder; }) - .syncThen([this, folderList]() { + .then([this, folderList]() { synchronizeFolders(*folderList); }); }) @@ -537,7 +537,7 @@ public: QDateTime internalDate = mail.getDate(); job = login.then(imap->append(mailbox, content, flags, internalDate)) .addToContext(imap) - .syncThen([mail](qint64 uid) { + .then([mail](qint64 uid) { const auto remoteId = assembleMailRid(mail, uid); SinkTrace() << "Finished creating a new mail: " << remoteId; return remoteId; @@ -550,7 +550,7 @@ public: KIMAP2::ImapSet set; set.add(uid); job = login.then(imap->remove(mailbox, set)) - .syncThen([imap, oldRemoteId] { + .then([imap, oldRemoteId] { SinkTrace() << "Finished removing a mail: " << oldRemoteId; return QByteArray(); }); @@ -586,7 +586,7 @@ public: job = login.then(imap->select(mailbox)) .addToContext(imap) .then(imap->storeFlags(set, flags)) - .syncThen([=] { + .then([=] { SinkTrace() << "Finished modifying mail"; return oldRemoteId; }); @@ -616,13 +616,13 @@ public: SinkTrace() << "Creating a new folder: " << parentFolder << folder.getName(); auto rid = QSharedPointer::create(); auto createFolder = login.then(imap->createSubfolder(parentFolder, folder.getName())) - .syncThen([imap, rid](const QString &createdFolder) { + .then([imap, rid](const QString &createdFolder) { SinkTrace() << "Finished creating a new folder: " << createdFolder; *rid = createdFolder.toUtf8(); }); if (folder.getSpecialPurpose().isEmpty()) { return createFolder - .syncThen([rid](){ + .then([rid](){ return *rid; }); } else { //We try to merge special purpose folders first @@ -644,13 +644,13 @@ public: } SinkTrace() << "No match found for merging, creating a new folder"; return imap->createSubfolder(parentFolder, folder.getName()) - .syncThen([imap, rid](const QString &createdFolder) { + .then([imap, rid](const QString &createdFolder) { SinkTrace() << "Finished creating a new folder: " << createdFolder; *rid = createdFolder.toUtf8(); }); }) - .syncThen([rid](){ + .then([rid](){ return *rid; }); return mergeJob; @@ -658,7 +658,7 @@ public: } else if (operation == Sink::Operation_Removal) { SinkTrace() << "Removing a folder: " << oldRemoteId; return login.then(imap->remove(oldRemoteId)) - .syncThen([oldRemoteId, imap]() { + .then([oldRemoteId, imap]() { SinkTrace() << "Finished removing a folder: " << oldRemoteId; return QByteArray(); }); @@ -666,11 +666,11 @@ public: SinkTrace() << "Renaming a folder: " << oldRemoteId << folder.getName(); auto rid = QSharedPointer::create(); return login.then(imap->renameSubfolder(oldRemoteId, folder.getName())) - .syncThen([imap, rid](const QString &createdFolder) { + .then([imap, rid](const QString &createdFolder) { SinkTrace() << "Finished renaming a folder: " << createdFolder; *rid = createdFolder.toUtf8(); }) - .syncThen([rid](){ + .then([rid](){ return *rid; }); } @@ -731,7 +731,7 @@ protected: SinkTrace() << "as:" << mUser; auto inspectionJob = imap->login(mUser, mPassword) .then(imap->select(folderRemoteId)) - .syncThen([](Imap::SelectResult){}) + .then([](Imap::SelectResult){}) .then(imap->fetch(set, scope, [imap, messageByUid](const Imap::Message &message) { messageByUid->insert(message.uid, message); })); @@ -792,7 +792,7 @@ protected: auto imap = QSharedPointer::create(mServer, mPort); auto messageByUid = QSharedPointer>::create(); return imap->login(mUser, mPassword) - .then(imap->select(remoteId).syncThen([](){})) + .then(imap->select(remoteId).then([](){})) .then(imap->fetch(set, scope, [=](const Imap::Message message) { messageByUid->insert(message.uid, message); })) diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index c16021e..a98483b 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -130,7 +130,7 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString }); auto namespaceJob = new KIMAP2::NamespaceJob(mSession); - return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen([this](){ + return runJob(loginJob).then(runJob(capabilitiesJob)).then([this](){ SinkTrace() << "Supported capabilities: " << mCapabilities; QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; for (const auto &requiredExtension : requiredExtensions) { @@ -139,7 +139,7 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString //TODO fail the job } } - }).then(runJob(namespaceJob)).syncThen([this, namespaceJob] { + }).then(runJob(namespaceJob)).then([this, namespaceJob] { for (const auto &ns :namespaceJob->personalNamespaces()) { mPersonalNamespaces << ns.name; mPersonalNamespaceSeparator = ns.separator; @@ -324,7 +324,7 @@ KAsync::Job> ImapServerProxy::fetchHeaders(const QString &mailbo list->append(result.uid); }) - .syncThen>([list](){ + .then([list](){ return *list; }); } @@ -378,7 +378,7 @@ KAsync::Job ImapServerProxy::createSubfolder(const QString &parentMailb } SinkTrace() << "Creating subfolder: " << *folder; return create(*folder) - .syncThen([=]() { + .then([=]() { return *folder; }); }); @@ -393,7 +393,7 @@ KAsync::Job ImapServerProxy::renameSubfolder(const QString &oldMailbox, auto folder = QSharedPointer::create(parts.join(mPersonalNamespaceSeparator) + mPersonalNamespaceSeparator + newName); SinkTrace() << "Renaming subfolder: " << oldMailbox << *folder; return rename(oldMailbox, *folder) - .syncThen([=]() { + .then([=]() { return *folder; }); }); @@ -436,7 +436,7 @@ KAsync::Job ImapServerProxy::fetchFlags(const Folder &folder, cons scope.mode = KIMAP2::FetchJob::FetchScope::Flags; scope.changedSince = changedsince; - return fetch(set, scope, callback).syncThen([selectResult] { + return fetch(set, scope, callback).then([selectResult] { return selectResult; }); }); @@ -503,7 +503,7 @@ KAsync::Job ImapServerProxy::fetchMessages(const Folder &folder, const QVe callback(message); }); }) - .syncThen([time]() { + .then([time]() { SinkTrace() << "The fetch took: " << Sink::Log::TraceTime(time->elapsed()); }); } diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 6ddb5d2..3d299b4 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp @@ -369,11 +369,11 @@ public: }); if (query.type() == ApplicationDomain::getTypeName()) { - job = job.syncThen([this] { + job = job.then([this] { synchronizeFolders(); }); } else if (query.type() == ApplicationDomain::getTypeName()) { - job = job.syncThen([this, query] { + job = job.then([this, query] { QStringList folders; if (query.hasFilter()) { auto folderFilter = query.getFilter(); diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index e475139..a4622f3 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp @@ -118,7 +118,7 @@ public: }); }); } - job = job.syncThen([&future](const KAsync::Error &) { + job = job.then([&future](const KAsync::Error &) { future.setFinished(); }); job.exec(); diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index f90f055..250cd75 100644 --- a/sinksh/syntax_modules/sink_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp @@ -54,7 +54,7 @@ bool sync(const QStringList &args, State &state) QTimer::singleShot(0, [query, state]() { Sink::Store::synchronize(query) .then(Sink::ResourceControl::flushMessageQueue(query.getResourceFilter().ids)) - .syncThen([state](const KAsync::Error &error) { + .then([state](const KAsync::Error &error) { if (error) { state.printLine("Synchronization failed!"); } else { diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index cce5c7b..0ab18ef 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp @@ -39,7 +39,7 @@ private slots: account.setIcon(accountIcon); Store::create(account).exec().waitForFinished(); - Store::fetchAll(Query()).syncThen>([&](const QList &accounts) { + Store::fetchAll(Query()).then([&](const QList &accounts) { QCOMPARE(accounts.size(), 1); auto account = accounts.first(); QCOMPARE(account->getAccountType(), QString("maildir")); @@ -60,7 +60,7 @@ private slots: Store::create(resource).exec().waitForFinished(); - Store::fetchAll(Query()).syncThen>([&](const QList &resources) { + Store::fetchAll(Query()).then([&](const QList &resources) { QCOMPARE(resources.size(), 1); auto resource = resources.first(); QCOMPARE(resource->getResourceType(), QByteArray("sink.mailtransport")); @@ -74,7 +74,7 @@ private slots: identity.setAccount(account.identifier()); Store::create(identity).exec().waitForFinished(); - Store::fetchAll(Query()).syncThen>([&](const QList &identities) { + Store::fetchAll(Query()).then([&](const QList &identities) { QCOMPARE(identities.size(), 1); QCOMPARE(identities.first()->getName(), smtpServer); QCOMPARE(identities.first()->getAddress(), smtpUsername); @@ -85,7 +85,7 @@ private slots: Store::remove(resource).exec().waitForFinished(); - Store::fetchAll(Query()).syncThen>([](const QList &resources) { + Store::fetchAll(Query()).then([](const QList &resources) { QCOMPARE(resources.size(), 0); }) .exec().waitForFinished(); diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 544b981..8fc76df 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp @@ -276,7 +276,7 @@ private slots: bool gotValue = false; auto result = Sink::Store::fetchOne(query) - .syncThen([&gotValue](const Sink::ApplicationDomain::Event &event) { gotValue = true; }) + .then([&gotValue](const Sink::ApplicationDomain::Event &event) { gotValue = true; }) .exec(); result.waitForFinished(); QVERIFY(!result.errorCode()); diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp index 96a2daa..d3b0fe3 100644 --- a/tests/mailsynctest.cpp +++ b/tests/mailsynctest.cpp @@ -68,7 +68,7 @@ void MailSyncTest::testListFolders() //First figure out how many folders we have by default { auto job = Store::fetchAll(Query()) - .syncThen>([&](const QList &folders) { + .then([&](const QList &folders) { QStringList names; for (const auto &folder : folders) { names << folder->getName(); @@ -87,7 +87,7 @@ void MailSyncTest::testListFolders() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([=](const QList &folders) { + auto job = Store::fetchAll(query).then([=](const QList &folders) { QStringList names; QHash specialPurposeFolders; for (const auto &folder : folders) { @@ -128,7 +128,7 @@ void MailSyncTest::testListNewFolder() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &folders) { + auto job = Store::fetchAll(query).then([](const QList &folders) { QStringList names; for (const auto &folder : folders) { names << folder->getName(); @@ -153,7 +153,7 @@ void MailSyncTest::testListRemovedFolder() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &folders) { + auto job = Store::fetchAll(query).then([](const QList &folders) { QStringList names; for (const auto &folder : folders) { names << folder->getName(); @@ -178,7 +178,7 @@ void MailSyncTest::testListFolderHierarchy() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([=](const QList &folders) { + auto job = Store::fetchAll(query).then([=](const QList &folders) { QHash map; for (const auto &folder : folders) { map.insert(folder->getName(), folder); @@ -221,7 +221,7 @@ void MailSyncTest::testListNewSubFolder() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &folders) { + auto job = Store::fetchAll(query).then([](const QList &folders) { QStringList names; for (const auto &folder : folders) { names << folder->getName(); @@ -249,7 +249,7 @@ void MailSyncTest::testListRemovedSubFolder() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &folders) { + auto job = Store::fetchAll(query).then([](const QList &folders) { QStringList names; for (const auto &folder : folders) { names << folder->getName(); @@ -269,7 +269,7 @@ void MailSyncTest::testListMails() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 1); QVERIFY(mails.first()->getSubject().startsWith(QString("[Nepomuk] Jenkins build is still unstable"))); const auto data = mails.first()->getMimeMessage(); @@ -298,7 +298,7 @@ void MailSyncTest::testResyncMails() VERIFYEXEC(Store::synchronize(query)); VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 1); }); VERIFYEXEC(job); @@ -323,7 +323,7 @@ void MailSyncTest::testFetchNewRemovedMessages() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 2); }); VERIFYEXEC(job); @@ -335,7 +335,7 @@ void MailSyncTest::testFetchNewRemovedMessages() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 1); }); VERIFYEXEC(job); @@ -358,7 +358,7 @@ void MailSyncTest::testFlagChange() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 0); }); VERIFYEXEC(job); @@ -371,7 +371,7 @@ void MailSyncTest::testFlagChange() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { - auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + auto job = Store::fetchAll(query).then([](const QList &mails) { QCOMPARE(mails.size(), 1); QVERIFY(mails.first()->getImportant()); }); @@ -387,7 +387,7 @@ void MailSyncTest::testSyncSingleFolder() Folder::Ptr folder; { - auto job = Store::fetchAll(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter("test")).template syncThen>([&](const QList &folders) { + auto job = Store::fetchAll(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter("test")).template then([&](const QList &folders) { QCOMPARE(folders.size(), 1); folder = folders.first(); }); diff --git a/tests/mailtest.cpp b/tests/mailtest.cpp index fe28cde..c51fc56 100644 --- a/tests/mailtest.cpp +++ b/tests/mailtest.cpp @@ -67,7 +67,7 @@ void MailTest::testCreateModifyDeleteFolder() //First figure out how many folders we have by default { auto job = Store::fetchAll(Query()) - .syncThen>([&](const QList &folders) { + .then([&](const QList &folders) { baseCount = folders.size(); }); VERIFYEXEC(job); @@ -84,7 +84,7 @@ void MailTest::testCreateModifyDeleteFolder() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request()) - .syncThen>([=](const QList &folders) { + .then([=](const QList &folders) { QCOMPARE(folders.size(), baseCount + 1); QHash foldersByName; for (const auto &folder : folders) { @@ -110,7 +110,7 @@ void MailTest::testCreateModifyDeleteFolder() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request()) - .syncThen>([=](const QList &folders) { + .then([=](const QList &folders) { QCOMPARE(folders.size(), baseCount + 1); QHash foldersByName; for (const auto &folder : folders) { @@ -131,7 +131,7 @@ void MailTest::testCreateModifyDeleteFolder() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request()) - .syncThen>([=](const QList &folders) { + .then([=](const QList &folders) { QCOMPARE(folders.size(), baseCount); }); VERIFYEXEC(job); @@ -161,7 +161,7 @@ void MailTest::testCreateModifyDeleteMail() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request().request()) - .syncThen>([=](const QList &mails) { + .then([=](const QList &mails) { QCOMPARE(mails.size(), 1); auto mail = *mails.first(); QCOMPARE(mail.getSubject(), subject); @@ -190,7 +190,7 @@ void MailTest::testCreateModifyDeleteMail() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request().request()) - .syncThen>([=](const QList &mails) { + .then([=](const QList &mails) { QCOMPARE(mails.size(), 1); auto mail = *mails.first(); QCOMPARE(mail.getSubject(), subject2); @@ -212,7 +212,7 @@ void MailTest::testCreateModifyDeleteMail() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request()) - .syncThen>([=](const QList &mails) { + .then([=](const QList &mails) { QCOMPARE(mails.size(), 0); }); VERIFYEXEC(job); @@ -248,7 +248,7 @@ void MailTest::testMoveMail() Mail modifiedMail; { auto job = Store::fetchAll(Query().request().request().request()) - .syncThen>([=, &modifiedMail](const QList &mails) { + .then([=, &modifiedMail](const QList &mails) { QCOMPARE(mails.size(), 1); auto mail = *mails.first(); modifiedMail = mail; @@ -267,7 +267,7 @@ void MailTest::testMoveMail() VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); { auto job = Store::fetchAll(Query().request().request().request()) - .syncThen>([=](const QList &mails) { + .then([=](const QList &mails) { QCOMPARE(mails.size(), 1); auto mail = *mails.first(); QCOMPARE(mail.getFolder(), folder1.identifier()); diff --git a/tests/mailthreadtest.cpp b/tests/mailthreadtest.cpp index 3684514..82f9331 100644 --- a/tests/mailthreadtest.cpp +++ b/tests/mailthreadtest.cpp @@ -179,7 +179,7 @@ void MailThreadTest::testIndexInMixedOrder() /* VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); */ /* { */ /* auto job = Store::fetchAll(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name)) */ - /* .syncThen>([=](const QList &mails) { */ + /* .then([=](const QList &mails) { */ /* QCOMPARE(mails.size(), 0); */ /* }); */ /* VERIFYEXEC(job); */ diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp index 201db53..7beafc7 100644 --- a/tests/resourcecommunicationtest.cpp +++ b/tests/resourcecommunicationtest.cpp @@ -51,7 +51,7 @@ private slots: int errors = 0; for (int i = 0; i < count; i++) { auto result = resourceAccess.sendCommand(Sink::Commands::PingCommand) - .syncThen([&resourceAccess, &errors, &complete](const KAsync::Error &error) { + .then([&resourceAccess, &errors, &complete](const KAsync::Error &error) { complete++; if (error) { qWarning() << error.errorMessage; @@ -77,7 +77,7 @@ private slots: int errors = 0; for (int i = 0; i < count; i++) { resourceAccess.sendCommand(Sink::Commands::PingCommand) - .syncThen([&resourceAccess, &errors, &complete](const KAsync::Error &error) { + .then([&resourceAccess, &errors, &complete](const KAsync::Error &error) { complete++; if (error) { qWarning() << error.errorMessage; @@ -104,7 +104,7 @@ private slots: auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resourceIdentifier, ""); weakRef = resourceAccess.toWeakRef(); resourceAccess->open(); - resourceAccess->sendCommand(Sink::Commands::PingCommand).syncThen([resourceAccess]() { qDebug() << "Ping complete"; }).exec(); + resourceAccess->sendCommand(Sink::Commands::PingCommand).then([resourceAccess]() { qDebug() << "Ping complete"; }).exec(); } QVERIFY(weakRef.toStrongRef()); QTRY_VERIFY(!weakRef.toStrongRef()); -- cgit v1.2.3