From 78284e0963d93e3e0f85e2165013412580a3b8c1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 14 Jan 2016 18:52:04 +0100 Subject: Got rid of all uses of Query::syncOnDemand and Query::processAll --- akonadish/akonadish_utils.cpp | 2 -- akonadish/syntax_modules/akonadi_count.cpp | 2 -- akonadish/syntax_modules/akonadi_list.cpp | 2 -- akonadish/syntax_modules/akonadi_stat.cpp | 2 -- akonadish/syntax_modules/akonadi_sync.cpp | 2 -- common/clientapi.cpp | 2 +- examples/client/main.cpp | 3 -- tests/dummyresourcebenchmark.cpp | 6 +--- tests/dummyresourcetest.cpp | 28 +++++------------- tests/maildirresourcetest.cpp | 47 ++++++++++++------------------ tests/modelinteractivitytest.cpp | 4 +-- tests/querytest.cpp | 31 ++++---------------- 12 files changed, 35 insertions(+), 96 deletions(-) diff --git a/akonadish/akonadish_utils.cpp b/akonadish/akonadish_utils.cpp index 140c741..27a863d 100644 --- a/akonadish/akonadish_utils.cpp +++ b/akonadish/akonadish_utils.cpp @@ -77,8 +77,6 @@ QStringList resourceIds(State &state) { QStringList resources; Akonadi2::Query query; - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = false; auto model = AkonadishUtils::loadModel("resource", query); diff --git a/akonadish/syntax_modules/akonadi_count.cpp b/akonadish/syntax_modules/akonadi_count.cpp index 5acdcdd..bb1cd19 100644 --- a/akonadish/syntax_modules/akonadi_count.cpp +++ b/akonadish/syntax_modules/akonadi_count.cpp @@ -53,8 +53,6 @@ bool count(const QStringList &args, State &state) for (const auto &res : resources) { query.resources << res.toLatin1(); } - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = false; auto model = AkonadishUtils::loadModel(type, query); diff --git a/akonadish/syntax_modules/akonadi_list.cpp b/akonadish/syntax_modules/akonadi_list.cpp index 82f13b5..7709d3b 100644 --- a/akonadish/syntax_modules/akonadi_list.cpp +++ b/akonadish/syntax_modules/akonadi_list.cpp @@ -58,8 +58,6 @@ bool list(const QStringList &args, State &state) for (const auto &res : resources) { query.resources << res.toLatin1(); } - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = false; QTime time; diff --git a/akonadish/syntax_modules/akonadi_stat.cpp b/akonadish/syntax_modules/akonadi_stat.cpp index 9270f9d..d10556f 100644 --- a/akonadish/syntax_modules/akonadi_stat.cpp +++ b/akonadish/syntax_modules/akonadi_stat.cpp @@ -69,8 +69,6 @@ void statResources(const QStringList &resources, const State &state) bool statAllResources(State &state) { Akonadi2::Query query; - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = false; auto model = AkonadishUtils::loadModel("resource", query); diff --git a/akonadish/syntax_modules/akonadi_sync.cpp b/akonadish/syntax_modules/akonadi_sync.cpp index 03abbb4..0c994d0 100644 --- a/akonadish/syntax_modules/akonadi_sync.cpp +++ b/akonadish/syntax_modules/akonadi_sync.cpp @@ -43,8 +43,6 @@ bool sync(const QStringList &args, State &state) for (const auto &res : args) { query.resources << res.toLatin1(); } - query.syncOnDemand = true; - query.processAll = true; QTimer::singleShot(0, [query, state]() { Akonadi2::Store::synchronize(query).then([state]() { diff --git a/common/clientapi.cpp b/common/clientapi.cpp index ffaa57b..5c0bcb8 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -204,7 +204,7 @@ KAsync::Job Store::synchronize(const Akonadi2::Query &query) Trace() << "Synchronizing " << resource; auto resourceAccess = QSharedPointer::create(resource); resourceAccess->open(); - resourceAccess->synchronizeResource(query.syncOnDemand, query.processAll).then([&future, resourceAccess]() { + resourceAccess->synchronizeResource(true, false).then([&future, resourceAccess]() { future.setFinished(); }).exec(); }) diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 127fd2f..6660f86 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -120,7 +120,6 @@ public: QObject::connect(syncButton, &QPushButton::pressed, []() { Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = true; Akonadi2::Store::synchronize(query).exec(); }); @@ -198,8 +197,6 @@ int main(int argc, char *argv[]) for (const auto &res : resources) { query.resources << res.toLatin1(); } - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = true; if (type == "folder") { query.parentProperty = "parent"; diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index aad86c0..c52eee3 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp @@ -92,9 +92,7 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); } auto allProcessedTime = time.elapsed(); @@ -123,8 +121,6 @@ private Q_SLOTS: time.start(); Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = false; query.propertyFilter.insert("uid", "testuid"); auto model = Akonadi2::Store::loadModel(query); diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 0e1f382..72a24b6 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -62,11 +62,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); query.propertyFilter.insert("uid", "testuid"); auto model = Akonadi2::Store::loadModel(query); @@ -88,11 +86,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); query.propertyFilter.insert("uid", "testuid"); @@ -118,11 +114,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); query.propertyFilter.insert("summary", "summaryValue2"); @@ -153,11 +147,10 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = true; - query.processAll = true; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); @@ -171,11 +164,10 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = true; - query.processAll = true; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); @@ -195,12 +187,10 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.propertyFilter.insert("uid", "testuid"); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //Test create Akonadi2::ApplicationDomain::Event event2; @@ -219,7 +209,7 @@ private Q_SLOTS: Akonadi2::Store::modify(event2).exec().waitForFinished(); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //Test modify { @@ -234,7 +224,7 @@ private Q_SLOTS: Akonadi2::Store::remove(event2).exec().waitForFinished(); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //Test remove { @@ -249,8 +239,6 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.liveQuery = true; query.propertyFilter.insert("uid", "testuid"); diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index b61190d..3e07d93 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp @@ -87,11 +87,10 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -102,12 +101,11 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; query.parentProperty = "parent"; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -124,10 +122,8 @@ private Q_SLOTS: using namespace Akonadi2::ApplicationDomain; //Ensure all local data is processed auto query = Query::ResourceFilter("org.kde.maildir.instance1"); - query.processAll = true; - query.syncOnDemand = true; Store::synchronize(query).exec().waitForFinished(); - // Store::flushMessageQueues(Query::ResourceFilter("org.kde.maildir.instance1")).exec().waitForFinished(); + Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto result = Store::fetchOne( Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") ) @@ -150,11 +146,10 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; - query.syncOnDemand = true; - query.processAll = true; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto mailModel = Akonadi2::Store::loadModel(query); QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -170,12 +165,11 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; query.requestedProperties << "name"; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto targetPath = tempDir.path() + "/maildir1/"; QDir dir(targetPath); @@ -183,6 +177,7 @@ private Q_SLOTS: //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -194,15 +189,15 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; query.requestedProperties << "folder" << "subject"; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto mailModel = Akonadi2::Store::loadModel(query); QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -213,12 +208,11 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; query.requestedProperties << "folder" << "subject"; //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; QFile file(targetPath); @@ -226,6 +220,7 @@ private Q_SLOTS: //Ensure all local data is processed Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto mailModel = Akonadi2::Store::loadModel(query); QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -236,11 +231,9 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); folder.setProperty("name", "testCreateFolder"); @@ -248,7 +241,7 @@ private Q_SLOTS: Akonadi2::Store::create(folder).exec().waitForFinished(); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; QFileInfo file(targetPath); @@ -260,15 +253,13 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = false; - query.processAll = true; auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); folder.setProperty("name", "testCreateFolder"); Akonadi2::Store::create(folder).exec().waitForFinished(); - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); QTRY_VERIFY(QFileInfo(targetPath).exists()); Akonadi2::Query folderQuery; @@ -280,7 +271,7 @@ private Q_SLOTS: auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value(); Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); QTRY_VERIFY(!QFileInfo(targetPath).exists()); } @@ -288,11 +279,9 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); mail.setProperty("name", "testCreateMail"); @@ -300,7 +289,7 @@ private Q_SLOTS: Akonadi2::Store::create(mail).exec().waitForFinished(); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto targetPath = tempDir.path() + "/maildir1/new"; QDir dir(targetPath); @@ -312,9 +301,8 @@ private Q_SLOTS: { Akonadi2::Query query; query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); Akonadi2::Query folderQuery; folderQuery.resources << "org.kde.maildir.instance1"; @@ -334,6 +322,7 @@ private Q_SLOTS: Akonadi2::Store::remove(*mail).exec().waitForFinished(); Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast(0)); } diff --git a/tests/modelinteractivitytest.cpp b/tests/modelinteractivitytest.cpp index 52db932..59c2c6f 100644 --- a/tests/modelinteractivitytest.cpp +++ b/tests/modelinteractivitytest.cpp @@ -73,11 +73,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.liveQuery = true; - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //Test QTime time; diff --git a/tests/querytest.cpp b/tests/querytest.cpp index e09f7a4..f9344cd 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -48,8 +48,6 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "foobar"; - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = true; //We fetch before the data is available and rely on the live query mechanism to deliver the actual data @@ -70,8 +68,6 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = true; //We fetch before the data is available and rely on the live query mechanism to deliver the actual data @@ -91,12 +87,10 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.liveQuery = false; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data auto model = Akonadi2::Store::loadModel(query); @@ -150,8 +144,6 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = false; query.liveQuery = true; //We fetch before the data is available and rely on the live query mechanism to deliver the actual data @@ -171,11 +163,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -192,12 +182,10 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.parentProperty = "parent"; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data auto model = Akonadi2::Store::loadModel(query); @@ -222,13 +210,11 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; query.liveQuery = false; query.propertyFilter.insert("uid", "test1"); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //We fetch before the data is available and rely on the live query mechanism to deliver the actual data auto model = Akonadi2::Store::loadModel(query); @@ -246,11 +232,9 @@ private Q_SLOTS: Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); @@ -268,13 +252,10 @@ private Q_SLOTS: //Test Akonadi2::Query query; query.resources << "org.kde.dummy.instance1"; - query.syncOnDemand = false; - query.processAll = true; - query.liveQuery = false; query.propertyFilter.insert("folder", folderEntity->identifier()); //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); + Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); //We fetch before the data is available and rely on the live query mechanism to deliver the actual data auto model = Akonadi2::Store::loadModel(query); -- cgit v1.2.3