diff --git a/autotests/libs/CMakeLists.txt b/autotests/libs/CMakeLists.txt --- a/autotests/libs/CMakeLists.txt +++ b/autotests/libs/CMakeLists.txt @@ -159,7 +159,6 @@ add_akonadi_isolated_test(SOURCE cachetest.cpp) add_akonadi_isolated_test(SOURCE collectionjobtest.cpp) add_akonadi_isolated_test(SOURCE collectionmodifytest.cpp) -add_akonadi_isolated_test(SOURCE referencetest.cpp) # FIXME: This is very unstable on Jenkins #add_akonadi_isolated_test(servermanagertest.cpp) diff --git a/autotests/libs/collectionjobtest.h b/autotests/libs/collectionjobtest.h --- a/autotests/libs/collectionjobtest.h +++ b/autotests/libs/collectionjobtest.h @@ -54,7 +54,6 @@ void testAncestorRetrieval(); void testAncestorAttributeRetrieval(); void testListPreference(); - void testReference(); }; #endif diff --git a/autotests/libs/collectionjobtest.cpp b/autotests/libs/collectionjobtest.cpp --- a/autotests/libs/collectionjobtest.cpp +++ b/autotests/libs/collectionjobtest.cpp @@ -903,54 +903,4 @@ AKVERIFYEXEC(deleteJob); } -void CollectionJobTest::testReference() -{ - Akonadi::Collection baseCol; - { - baseCol.setParentCollection(Akonadi::Collection(res1ColId)); - baseCol.setName(QStringLiteral("base")); - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(baseCol); - AKVERIFYEXEC(create); - baseCol = create->collection(); - } - - { - Akonadi::Collection col; - col.setParentCollection(baseCol); - col.setName(QStringLiteral("referenced")); - col.setEnabled(false); - { - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(col); - AKVERIFYEXEC(create); - CollectionFetchJob *job = new CollectionFetchJob(create->collection(), CollectionFetchJob::Base); - AKVERIFYEXEC(job); - col = job->collections().first(); - } - { - col.setReferenced(true); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col); - AKVERIFYEXEC(modify); - CollectionFetchJob *job = new CollectionFetchJob(col, CollectionFetchJob::Base); - AKVERIFYEXEC(job); - Akonadi::Collection result = job->collections().first(); - QCOMPARE(result.enabled(), false); - QCOMPARE(result.referenced(), true); - } - { - col.setReferenced(false); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col); - AKVERIFYEXEC(modify); - CollectionFetchJob *job = new CollectionFetchJob(col, CollectionFetchJob::Base); - AKVERIFYEXEC(job); - Akonadi::Collection result = job->collections().first(); - QCOMPARE(result.enabled(), false); - QCOMPARE(result.referenced(), false); - } - } - - //Cleanup - CollectionDeleteJob *deleteJob = new CollectionDeleteJob(baseCol); - AKVERIFYEXEC(deleteJob); -} - #include "collectionjobtest.moc" diff --git a/autotests/libs/etmpopulationtest.cpp b/autotests/libs/etmpopulationtest.cpp --- a/autotests/libs/etmpopulationtest.cpp +++ b/autotests/libs/etmpopulationtest.cpp @@ -139,9 +139,7 @@ void testAddMonitoringCollections(); void testRemoveMonitoringCollections(); void testDisplayFilter(); - void testReferenceCollection(); void testLoadingOfHiddenCollection(); - void testSwitchFromReferenceToEnabled(); private: Collection res; @@ -319,50 +317,6 @@ AKVERIFYEXEC(deleteJob); } -void EtmPopulationTest::testReferenceCollection() -{ - Collection col5 = createCollection(QStringLiteral("col5"), monitorCol, false); - QVERIFY(col5.isValid()); - - ChangeRecorder *changeRecorder = new ChangeRecorder(this); - InspectableETM *model = new InspectableETM(changeRecorder, this); - model->setItemPopulationStrategy(EntityTreeModel::ImmediatePopulation); - model->setCollectionFetchStrategy(EntityTreeModel::FetchCollectionsRecursive); - model->setListFilter(Akonadi::CollectionFetchScope::Display); - - QTRY_VERIFY(model->isFullyPopulated()); - QVERIFY(!getIndex(QStringLiteral("col5"), model).isValid()); - //Check that this random other collection is actually available - QVERIFY(getIndex(QStringLiteral("col1"), model).isValid()); - - ModelSignalSpy spy(*model); - - //Reference the collection and it should appear in the model - model->setCollectionReferenced(col5, true); - - QTRY_VERIFY(getIndex(QStringLiteral("col5"), model).isValid()); - QTRY_VERIFY(getIndex(QStringLiteral("col5"), model).data(Akonadi::EntityTreeModel::IsPopulatedRole).toBool()); - //Check that this random other collection is still available - QVERIFY(getIndex(QStringLiteral("col1"), model).isValid()); - //Verify the etms collection has been updated accordingly - QTRY_VERIFY(getIndex(QStringLiteral("col5"), model).data(Akonadi::EntityTreeModel::CollectionRole).value().referenced()); - - //Ensure all signals have been delivered to the spy - QTest::qWait(0); - QCOMPARE(spy.mSignals.count(QStringLiteral("rowsInserted")), 1); - //Signals for data-changed signal from the referencing - QCOMPARE(spy.mSignals.count(QStringLiteral("dataChanged")), 2); - - //Dereference the collection and it should disappear again - model->setCollectionReferenced(col5, false); - QTRY_VERIFY(!getIndex(QStringLiteral("col5"), model).isValid()); - //Check that this random other collection is still available - QVERIFY(getIndex(QStringLiteral("col1"), model).isValid()); - - Akonadi::CollectionDeleteJob *deleteJob = new Akonadi::CollectionDeleteJob(col5); - AKVERIFYEXEC(deleteJob); -} - /* * Col5 and it's ancestors should be included although the ancestors don't match the mimetype filter. */ @@ -384,34 +338,6 @@ AKVERIFYEXEC(deleteJob); } -void EtmPopulationTest::testSwitchFromReferenceToEnabled() -{ - Collection col5 = createCollection(QStringLiteral("col5"), monitorCol, false, QStringList() << QStringLiteral("application/test") << Collection::mimeType()); - QVERIFY(col5.isValid()); - Collection col6 = createCollection(QStringLiteral("col6"), col5, true, QStringList() << QStringLiteral("application/test")); - QVERIFY(col6.isValid()); - - ChangeRecorder *changeRecorder = new ChangeRecorder(this); - InspectableETM *model = new InspectableETM(changeRecorder, this); - model->setItemPopulationStrategy(EntityTreeModel::ImmediatePopulation); - model->setCollectionFetchStrategy(EntityTreeModel::FetchCollectionsRecursive); - model->setListFilter(Akonadi::CollectionFetchScope::Display); - QTRY_VERIFY(model->isFullyPopulated()); - model->setCollectionReferenced(col5, true); - QTRY_VERIFY(getIndex(QStringLiteral("col5"), model).data(Akonadi::EntityTreeModel::CollectionRole).value().referenced()); - - //Dereference and enable the collection - col5.setEnabled(true); - model->setCollectionReferenced(col5, false); - - //Index and child should stay in model since both are enabled - QVERIFY(getIndex(QStringLiteral("col5"), model).isValid()); - QVERIFY(getIndex(QStringLiteral("col6"), model).isValid()); - - Akonadi::CollectionDeleteJob *deleteJob = new Akonadi::CollectionDeleteJob(col5); - AKVERIFYEXEC(deleteJob); -} - #include "etmpopulationtest.moc" QTEST_AKONADIMAIN(EtmPopulationTest) diff --git a/autotests/libs/referencetest.h b/autotests/libs/referencetest.h deleted file mode 100644 --- a/autotests/libs/referencetest.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (c) 2006 Volker Krause - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef REFERENCETEST_H -#define REFERENCETEST_H - -#include - -class ReferenceTest : public QObject -{ - Q_OBJECT -private Q_SLOTS: - void initTestCase(); - void testReference(); - void testReferenceFromMultiSession(); -}; - -#endif diff --git a/autotests/libs/referencetest.cpp b/autotests/libs/referencetest.cpp deleted file mode 100644 --- a/autotests/libs/referencetest.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (c) 2006 Volker Krause - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "referencetest.h" - -#include - -#include -#include "test_utils.h" - -#include "agentmanager.h" -#include "agentinstance.h" -#include "cachepolicy.h" -#include "collection.h" -#include "collectioncreatejob.h" -#include "collectiondeletejob.h" -#include "collectionfetchjob.h" -#include "collectionmodifyjob.h" -#include "control.h" -#include "item.h" -#include "collectionfetchscope.h" -#include "session.h" -#include "monitor.h" - -using namespace Akonadi; - -QTEST_AKONADIMAIN(ReferenceTest) - -void ReferenceTest::initTestCase() -{ - qRegisterMetaType(); - AkonadiTest::checkTestIsIsolated(); - Control::start(); - AkonadiTest::setAllResourcesOffline(); -} - -static Collection::Id res1ColId = 6; // -1; - -void ReferenceTest::testReference() -{ - Akonadi::Collection baseCol; - { - baseCol.setParentCollection(Akonadi::Collection(res1ColId)); - baseCol.setName(QStringLiteral("base")); - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(baseCol); - AKVERIFYEXEC(create); - baseCol = create->collection(); - } - - { - Akonadi::Collection col; - col.setParentCollection(baseCol); - col.setName(QStringLiteral("referenced")); - col.setEnabled(false); - { - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(col); - AKVERIFYEXEC(create); - CollectionFetchJob *job = new CollectionFetchJob(create->collection(), CollectionFetchJob::Base); - AKVERIFYEXEC(job); - col = job->collections().first(); - } - { - col.setReferenced(true); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col); - AKVERIFYEXEC(modify); - CollectionFetchJob *job = new CollectionFetchJob(col, CollectionFetchJob::Base); - AKVERIFYEXEC(job); - Akonadi::Collection result = job->collections().first(); - QCOMPARE(result.enabled(), false); - QCOMPARE(result.referenced(), true); - } - { - col.setReferenced(false); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col); - AKVERIFYEXEC(modify); - CollectionFetchJob *job = new CollectionFetchJob(col, CollectionFetchJob::Base); - AKVERIFYEXEC(job); - Akonadi::Collection result = job->collections().first(); - QCOMPARE(result.enabled(), false); - QCOMPARE(result.referenced(), false); - } - } - - //Cleanup - CollectionDeleteJob *deleteJob = new CollectionDeleteJob(baseCol); - AKVERIFYEXEC(deleteJob); -} - -void ReferenceTest::testReferenceFromMultiSession() -{ - Akonadi::Collection baseCol; - { - baseCol.setParentCollection(Akonadi::Collection(res1ColId)); - baseCol.setName(QStringLiteral("base")); - baseCol.setEnabled(false); - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(baseCol); - AKVERIFYEXEC(create); - baseCol = create->collection(); - } - - { - Akonadi::Collection col; - col.setParentCollection(baseCol); - col.setName(QStringLiteral("referenced")); - col.setEnabled(false); - { - Akonadi::CollectionCreateJob *create = new Akonadi::CollectionCreateJob(col); - AKVERIFYEXEC(create); - CollectionFetchJob *job = new CollectionFetchJob(create->collection(), CollectionFetchJob::Base); - AKVERIFYEXEC(job); - col = job->collections().first(); - } - - Akonadi::Session *session1 = new Akonadi::Session("session1"); - Akonadi::Monitor *monitor1 = new Akonadi::Monitor(); - monitor1->setSession(session1); - monitor1->setCollectionMonitored(Collection::root()); - - Akonadi::Session *session2 = new Akonadi::Session("session2"); - Akonadi::Monitor *monitor2 = new Akonadi::Monitor(); - monitor2->setSession(session2); - monitor2->setCollectionMonitored(Collection::root()); - - //Reference in first session and ensure second session is not affected - { - QSignalSpy cmodspy1(monitor1, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - QSignalSpy cmodspy2(monitor2, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - - col.setReferenced(true); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col, session1); - AKVERIFYEXEC(modify); - - //We want a signal only in the session that referenced the collection - QSignalSpy spyMonitor1(monitor1, SIGNAL(collectionChanged(Akonadi::Collection))); - QVERIFY(spyMonitor1.wait()); - - QTest::qWait(100); - QCOMPARE(cmodspy1.count(), 1); - QCOMPARE(cmodspy2.count(), 0); - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session1); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 1); - } - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session2); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 0); - } - } - //Reference in second session and ensure first session is not affected - { - QSignalSpy cmodspy1(monitor1, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - QSignalSpy cmodspy2(monitor2, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - - col.setReferenced(true); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col, session2); - AKVERIFYEXEC(modify); - - //We want a signal only in the session that referenced the collection - QSignalSpy spyMonitor2(monitor2, SIGNAL(collectionChanged(Akonadi::Collection))); - QVERIFY(spyMonitor2.wait()); - - QTest::qWait(100); - //FIXME The first session still gets the notification since it has the session referenced - QCOMPARE(cmodspy1.count(), 1); - QCOMPARE(cmodspy2.count(), 1); - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session1); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 1); - } - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session2); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 1); - } - } - { - QSignalSpy cmodspy1(monitor1, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - QSignalSpy cmodspy2(monitor2, SIGNAL(collectionChanged(Akonadi::Collection,QSet))); - col.setReferenced(false); - Akonadi::CollectionModifyJob *modify = new Akonadi::CollectionModifyJob(col, session1); - AKVERIFYEXEC(modify); - - //We want a signal only in the session that referenced the collection - QSignalSpy spyMonitor1(monitor1, SIGNAL(collectionChanged(Akonadi::Collection))); - QVERIFY(spyMonitor1.wait()); - - QTest::qWait(100); - QCOMPARE(cmodspy1.count(), 1); - //FIXME here we still get a notification for dereferenced because we don't filter correctly - QCOMPARE(cmodspy2.count(), 1); - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session1); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 0); - } - - { - CollectionFetchJob *job = new CollectionFetchJob(baseCol, CollectionFetchJob::Recursive, session2); - job->fetchScope().setListFilter(CollectionFetchScope::Display); - AKVERIFYEXEC(job); - QCOMPARE(job->collections().size(), 1); - } - } - } - - //Cleanup - CollectionDeleteJob *deleteJob = new CollectionDeleteJob(baseCol); - AKVERIFYEXEC(deleteJob); -} diff --git a/autotests/server/CMakeLists.txt b/autotests/server/CMakeLists.txt --- a/autotests/server/CMakeLists.txt +++ b/autotests/server/CMakeLists.txt @@ -101,7 +101,6 @@ add_server_test(collectioncreatehandlertest.cpp) add_server_test(collectionfetchhandlertest.cpp) add_server_test(collectionmodifyhandlertest.cpp) -add_server_test(collectionreferencetest.cpp) add_server_test(searchtest.cpp akonadiprivate) add_server_test(relationhandlertest.cpp akonadiprivate) add_server_test(taghandlertest.cpp akonadiprivate) diff --git a/autotests/server/collectionreferencetest.cpp b/autotests/server/collectionreferencetest.cpp deleted file mode 100644 --- a/autotests/server/collectionreferencetest.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - Copyright (c) 2014 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include - -#include - -#include "fakeakonadiserver.h" -#include "fakedatastore.h" -#include -#include "entities.h" -#include "collectionreferencemanager.h" -#include "dbinitializer.h" - -#include - -#include - -using namespace Akonadi; -using namespace Akonadi::Server; - -Q_DECLARE_METATYPE(Collection::List) - -class CollectionReferenceTest : public QObject -{ - Q_OBJECT - - DbInitializer initializer; - -public: - CollectionReferenceTest() - { - FakeAkonadiServer::instance()->setPopulateDb(false); - FakeAkonadiServer::instance()->init(); - - initializer.createResource("testresource"); - initializer.createCollection("col1"); - Collection col2 = initializer.createCollection("col2"); - col2.setEnabled(false); - col2.update(); - } - - ~CollectionReferenceTest() - { - FakeAkonadiServer::instance()->quit(); - } - -private Q_SLOTS: - void testModify_data() - { - QTest::addColumn("scenarios"); - QTest::addColumn("expectedNotifications"); - - auto notificationTemplate = Protocol::CollectionChangeNotificationPtr::create(); - notificationTemplate->setOperation(Protocol::CollectionChangeNotification::Modify); - notificationTemplate->setParentCollection(0); - notificationTemplate->setResource("testresource"); - notificationTemplate->setSessionId(FakeAkonadiServer::instanceName().toLatin1()); - Protocol::FetchCollectionsResponse collection; - collection.setId(initializer.collection("col2").id()); - collection.setRemoteId(QStringLiteral("col2")); - collection.setRemoteRevision(QStringLiteral("")); - notificationTemplate->setCollection(std::move(collection)); - - { - auto cmd = Protocol::FetchCollectionsCommandPtr::create(); - cmd->setDepth(Protocol::FetchCollectionsCommand::AllCollections); - cmd->setResource(QStringLiteral("testresource")); - cmd->setEnabled(true); - - TestScenario::List scenarios; - scenarios << FakeAkonadiServer::loginScenario() - << TestScenario::create(5, TestScenario::ClientCmd, cmd) - << TestScenario::create(5, TestScenario::ServerCmd, initializer.listResponse(initializer.collection("col1"))) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchCollectionsResponsePtr::create()); - QTest::newRow("list before referenced first level") << scenarios << Protocol::ChangeNotificationList(); - } - - { - auto cmd = Protocol::ModifyCollectionCommandPtr::create(initializer.collection("col2").id()); - cmd->setReferenced(true); - - TestScenario::List scenarios; - scenarios << FakeAkonadiServer::loginScenario() - << TestScenario::create(5, TestScenario::ClientCmd, cmd) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyCollectionResponsePtr::create()); - - auto notification = Protocol::CollectionChangeNotificationPtr::create(*notificationTemplate); - notification->setChangedParts(QSet() << "REFERENCED"); - - QTest::newRow("reference") << scenarios << (Protocol::ChangeNotificationList() << notification); - } - - { - auto cmd = Protocol::ModifyCollectionCommandPtr::create(initializer.collection("col2").id()); - cmd->setReferenced(true); - - auto listCmd = Protocol::FetchCollectionsCommandPtr::create(initializer.collection("col2").id()); - listCmd->setDepth(Protocol::FetchCollectionsCommand::BaseCollection); - listCmd->setEnabled(true); - - Collection col2 = initializer.collection("col2"); - col2.setReferenced(true); - TestScenario::List scenarios; - scenarios << FakeAkonadiServer::loginScenario() - << TestScenario::create(5, TestScenario::ClientCmd, cmd) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyCollectionResponsePtr::create()) - << TestScenario::create(6, TestScenario::ClientCmd, listCmd) - << TestScenario::create(6, TestScenario::ServerCmd, initializer.listResponse(col2)) - << TestScenario::create(6, TestScenario::ServerCmd, Protocol::FetchCollectionsResponsePtr::create()); - - auto notification = Protocol::CollectionChangeNotificationPtr::create(*notificationTemplate); - notification->setChangedParts(QSet() << "REFERENCED"); - - QTest::newRow("list referenced base") << scenarios << (Protocol::ChangeNotificationList() << notification); - } - { - auto cmd = Protocol::ModifyCollectionCommandPtr::create(initializer.collection("col2").id()); - cmd->setReferenced(true); - - auto listCmd = Protocol::FetchCollectionsCommandPtr::create(); - listCmd->setResource(QStringLiteral("testresource")); - listCmd->setEnabled(true); - listCmd->setDepth(Protocol::FetchCollectionsCommand::ParentCollection); - - Collection col2 = initializer.collection("col2"); - col2.setReferenced(true); - TestScenario::List scenarios; - scenarios << FakeAkonadiServer::loginScenario() - << TestScenario::create(5, TestScenario::ClientCmd, cmd) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyCollectionResponsePtr::create()) - << TestScenario::create(6, TestScenario::ClientCmd, listCmd) - << TestScenario::create(6, TestScenario::ServerCmd, initializer.listResponse(initializer.collection("col1"))) - << TestScenario::create(6, TestScenario::ServerCmd, initializer.listResponse(col2)) - << TestScenario::create(6, TestScenario::ServerCmd, Protocol::FetchCollectionsResponsePtr::create()); - - auto notification = Protocol::CollectionChangeNotificationPtr::create(*notificationTemplate); - notification->setChangedParts(QSet() << "REFERENCED"); - - QTest::newRow("list referenced first level") << scenarios << (Protocol::ChangeNotificationList() << notification); - } - { - auto cmd1 = Protocol::ModifyCollectionCommandPtr::create(initializer.collection("col2").id()); - cmd1->setReferenced(true); - - auto cmd2 = Protocol::ModifyCollectionCommandPtr::create(initializer.collection("col2").id()); - cmd2->setReferenced(false); - - TestScenario::List scenarios; - scenarios << FakeAkonadiServer::loginScenario() - << TestScenario::create(5, TestScenario::ClientCmd, cmd1) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyCollectionResponsePtr::create()) - << TestScenario::create(6, TestScenario::ClientCmd, cmd2) - << TestScenario::create(6, TestScenario::ServerCmd, Protocol::ModifyCollectionResponsePtr::create()); - - auto notification = Protocol::CollectionChangeNotificationPtr::create(*notificationTemplate); - notification->setChangedParts(QSet() << "REFERENCED"); - - QTest::newRow("dereference") << scenarios << (Protocol::ChangeNotificationList() << notification << notification); - } - } - - void testModify() - { - QFETCH(TestScenario::List, scenarios); - QFETCH(Protocol::ChangeNotificationList, expectedNotifications); - - // Clean all references from previous run - CollectionReferenceManager::cleanup(); - - FakeAkonadiServer::instance()->setScenarios(scenarios); - FakeAkonadiServer::instance()->runTest(); - - auto notificationSpy = FakeAkonadiServer::instance()->notificationSpy(); - if (expectedNotifications.isEmpty()) { - QTRY_VERIFY(notificationSpy->isEmpty() || notificationSpy->takeFirst().first().value().isEmpty()); - } else { - Protocol::ChangeNotificationList receivedNotifications; - for (int q = 0; q < notificationSpy->size(); q++) { - //Only one notify call - QCOMPARE(notificationSpy->first().count(), 1); - const Protocol::ChangeNotificationList n = notificationSpy->first().first().value(); - for (int i = 0; i < n.size(); i++) { - receivedNotifications.append(n.at(i)); - } - } - QCOMPARE(receivedNotifications.size(), expectedNotifications.count()); - for (int i = 0; i < expectedNotifications.size(); i++) { - QCOMPARE(*receivedNotifications.at(i), *expectedNotifications.at(i)); - } - } - } - - void testReferenceCollection() - { - Collection col = initializer.createCollection("testReferenceCollection"); - - CollectionReferenceManager::instance()->referenceCollection("testReferenceCollectionSession", col, true); - QVERIFY(CollectionReferenceManager::instance()->isReferenced(col.id())); - QVERIFY(CollectionReferenceManager::instance()->isReferenced(col.id(), "testReferenceCollectionSession")); - - CollectionReferenceManager::instance()->referenceCollection("foobar", col, false); - QVERIFY(CollectionReferenceManager::instance()->isReferenced(col.id())); - QVERIFY(CollectionReferenceManager::instance()->isReferenced(col.id(), "testReferenceCollectionSession")); - - CollectionReferenceManager::instance()->referenceCollection("testReferenceCollectionSession", col, false); - QVERIFY(!CollectionReferenceManager::instance()->isReferenced(col.id())); - QVERIFY(!CollectionReferenceManager::instance()->isReferenced(col.id(), "testReferenceCollectionSession")); - QVERIFY(col.remove()); - } - - void testSessionClosed() - { - Collection col = initializer.createCollection("testSessionCollection"); - col.setReferenced(true); - QVERIFY(col.update()); - CollectionReferenceManager::instance()->referenceCollection("testSessionClosedSession", col, true); - CollectionReferenceManager::instance()->referenceCollection("testSessionClosedSession2", col, true); - - //Remove first session - CollectionReferenceManager::instance()->removeSession("testSessionClosedSession2"); - QVERIFY(Collection::retrieveById(col.id()).referenced()); - QVERIFY(!CollectionReferenceManager::instance()->isReferenced(col.id(), "testSessionClosedSession2")); - QVERIFY(CollectionReferenceManager::instance()->isReferenced(col.id(), "testSessionClosedSession")); - - CollectionReferenceManager::instance()->removeSession("testSessionClosedSession"); - QVERIFY(!Collection::retrieveById(col.id()).referenced()); - QVERIFY(!CollectionReferenceManager::instance()->isReferenced(col.id(), "testSessionClosedSession")); - - QVERIFY(col.remove()); - } - - void testCleanup() - { - Collection col = initializer.createCollection("testCleanupCollection"); - col.setReferenced(true); - QVERIFY(col.update()); - - CollectionReferenceManager::cleanup(); - QVERIFY(!Collection::retrieveById(col.id()).referenced()); - - QVERIFY(col.remove()); - } - -}; - -AKTEST_FAKESERVER_MAIN(CollectionReferenceTest) - -#include "collectionreferencetest.moc" diff --git a/autotests/server/dbinitializer.cpp b/autotests/server/dbinitializer.cpp --- a/autotests/server/dbinitializer.cpp +++ b/autotests/server/dbinitializer.cpp @@ -165,7 +165,6 @@ ancs.push_back(Akonadi::Protocol::Ancestor(0)); resp->setAncestors(ancs); } - resp->setReferenced(col.referenced()); resp->setEnabled(col.enabled()); resp->setDisplayPref(static_cast(col.displayPref())); resp->setSyncPref(static_cast(col.syncPref())); diff --git a/src/agentbase/resourcebase.cpp b/src/agentbase/resourcebase.cpp --- a/src/agentbase/resourcebase.cpp +++ b/src/agentbase/resourcebase.cpp @@ -1312,7 +1312,7 @@ const Collection::List list = static_cast(job)->collections(); for (const Collection &collection : list) { //We also get collections that should not be synced but are part of the tree. - if (collection.shouldList(Collection::ListSync) || collection.referenced()) { + if (collection.shouldList(Collection::ListSync)) { if (mScheduleAttributeSyncBeforeCollectionSync) { scheduler->scheduleAttributesSync(collection); } diff --git a/src/core/changerecorderjournal.cpp b/src/core/changerecorderjournal.cpp --- a/src/core/changerecorderjournal.cpp +++ b/src/core/changerecorderjournal.cpp @@ -623,8 +623,7 @@ collection.setSyncPref(tristate); stream >> reinterpret_cast(tristate); collection.setIndexPref(tristate); - stream >> b; - collection.setReferenced(b); + stream >> b; // read the deprecated "isReferenced" value stream >> b; collection.setIsVirtual(b); @@ -716,7 +715,7 @@ stream << static_cast(col.displayPref()); stream << static_cast(col.syncPref()); stream << static_cast(col.indexPref()); - stream << col.referenced(); + stream << false; // write the deprecated "isReferenced" value stream << col.isVirtual(); diff --git a/src/core/collection.h b/src/core/collection.h --- a/src/core/collection.h +++ b/src/core/collection.h @@ -520,24 +520,6 @@ */ void setShouldList(ListPurpose purpose, bool shouldList); - /** - * Sets a collection to be referenced. - * - * A referenced collection is temporarily shown and synchronized even when disabled. - * A reference is only valid for the duration of a session, and is automatically removed afterwards. - * - * Referenced collections are only visible if explicitly monitored in the ETM. - * - * @since 4.14 - */ - void setReferenced(bool referenced); - - /** - * Returns the referenced state of the collection. - * @since 4.14 - */ - Q_REQUIRED_RESULT bool referenced() const; - /** * Set during sync to indicate that the provided parts are only default values; * @since 4.15 diff --git a/src/core/collection.cpp b/src/core/collection.cpp --- a/src/core/collection.cpp +++ b/src/core/collection.cpp @@ -415,7 +415,7 @@ bool Collection::shouldList(Collection::ListPurpose purpose) const { if (localListPreference(purpose) == ListDefault) { - return enabled() || referenced(); + return enabled(); } return (localListPreference(purpose) == ListEnabled); } @@ -429,17 +429,6 @@ } } -void Collection::setReferenced(bool referenced) -{ - d_ptr->referencedChanged = true; - d_ptr->referenced = referenced; -} - -bool Collection::referenced() const -{ - return d_ptr->referenced; -} - void Collection::setKeepLocalChanges(const QSet &parts) { d_ptr->keepLocalChanges = parts; diff --git a/src/core/collection_p.h b/src/core/collection_p.h --- a/src/core/collection_p.h +++ b/src/core/collection_p.h @@ -45,8 +45,6 @@ , listPreferenceChanged(false) , enabled(true) , enabledChanged(false) - , referenced(false) - , referencedChanged(false) , contentTypesChanged(false) , cachePolicyChanged(false) , isVirtual(false) @@ -80,8 +78,6 @@ syncPreference = other.syncPreference; indexPreference = other.indexPreference; listPreferenceChanged = other.listPreferenceChanged; - referenced = other.referenced; - referencedChanged = other.referencedChanged; keepLocalChanges = other.keepLocalChanges; } @@ -96,7 +92,6 @@ cachePolicyChanged = false; enabledChanged = false; listPreferenceChanged = false; - referencedChanged = false; mAttributeStorage.resetChangeLog(); } @@ -114,8 +109,6 @@ bool listPreferenceChanged: 1; bool enabled: 1; bool enabledChanged: 1; - bool referenced: 1; - bool referencedChanged: 1; bool contentTypesChanged: 1; bool cachePolicyChanged: 1; bool isVirtual: 1; diff --git a/src/core/jobs/collectionmodifyjob.cpp b/src/core/jobs/collectionmodifyjob.cpp --- a/src/core/jobs/collectionmodifyjob.cpp +++ b/src/core/jobs/collectionmodifyjob.cpp @@ -97,9 +97,6 @@ cmd->setSyncPref(ProtocolHelper::listPreference(d->mCollection.localListPreference(Collection::ListSync))); cmd->setIndexPref(ProtocolHelper::listPreference(d->mCollection.localListPreference(Collection::ListIndex))); } - if (d->mCollection.d_ptr->referencedChanged) { - cmd->setReferenced(d->mCollection.referenced()); - } if (d->mCollection.d_ptr->mAttributeStorage.hasModifiedAttributes()) { cmd->setAttributes(ProtocolHelper::attributesToProtocol(d->mCollection.d_ptr->mAttributeStorage.modifiedAttributes())); } diff --git a/src/core/models/entitytreemodel.h b/src/core/models/entitytreemodel.h --- a/src/core/models/entitytreemodel.h +++ b/src/core/models/entitytreemodel.h @@ -451,15 +451,6 @@ */ void setCollectionMonitored(const Akonadi::Collection &col, bool monitored = true); - /** - * References a collection and starts to monitor it. - * - * Use this to temporarily include a collection that is not enabled. - * - * @since 4.14 - */ - void setCollectionReferenced(const Akonadi::Collection &col, bool referenced = true); - /** * Sets the item population @p strategy of the model. */ diff --git a/src/core/models/entitytreemodel.cpp b/src/core/models/entitytreemodel.cpp --- a/src/core/models/entitytreemodel.cpp +++ b/src/core/models/entitytreemodel.cpp @@ -114,15 +114,6 @@ d->m_monitor->setCollectionMonitored(col, monitored); } -void EntityTreeModel::setCollectionReferenced(const Akonadi::Collection &col, bool referenced) -{ - Q_D(EntityTreeModel); - Akonadi::Collection referencedCollection = col; - referencedCollection.setReferenced(referenced); - //We have to use the same session as the monitor, so the monitor can fetch the collection afterwards - new Akonadi::CollectionModifyJob(referencedCollection, d->m_monitor->session()); -} - bool EntityTreeModel::systemEntitiesShown() const { Q_D(const EntityTreeModel); diff --git a/src/core/models/entitytreemodel_p.cpp b/src/core/models/entitytreemodel_p.cpp --- a/src/core/models/entitytreemodel_p.cpp +++ b/src/core/models/entitytreemodel_p.cpp @@ -789,7 +789,7 @@ } if (m_listFilter == CollectionFetchScope::Enabled) { - if (!collection.enabled() && !collection.referenced()) { + if (!collection.enabled()) { return false; } } else if (m_listFilter == CollectionFetchScope::Display) { diff --git a/src/core/protocolhelper.cpp b/src/core/protocolhelper.cpp --- a/src/core/protocolhelper.cpp +++ b/src/core/protocolhelper.cpp @@ -237,7 +237,6 @@ collection.setLocalListPreference(Collection::ListDisplay, parsePreference(data.displayPref())); collection.setLocalListPreference(Collection::ListIndex, parsePreference(data.indexPref())); collection.setLocalListPreference(Collection::ListSync, parsePreference(data.syncPref())); - collection.setReferenced(data.referenced()); if (!data.searchQuery().isEmpty()) { auto attr = collection.attribute(Collection::AddIfMissing); diff --git a/src/private/protocol.xml b/src/private/protocol.xml --- a/src/private/protocol.xml +++ b/src/private/protocol.xml @@ -1,5 +1,5 @@ - + @@ -531,7 +531,6 @@ - @@ -550,7 +549,6 @@ - @@ -607,9 +605,6 @@ - - - diff --git a/src/private/protocol_p.h b/src/private/protocol_p.h --- a/src/private/protocol_p.h +++ b/src/private/protocol_p.h @@ -615,7 +615,6 @@ #define AKONADI_PARAM_PLD "PLD:" #define AKONADI_PARAM_PLD_RFC822 "PLD:RFC822" #define AKONADI_PARAM_RECURSIVE "RECURSIVE" -#define AKONADI_PARAM_REFERENCED "REFERENCED" #define AKONADI_PARAM_REMOTE "REMOTE" #define AKONADI_PARAM_REMOTEID "REMOTEID" #define AKONADI_PARAM_REMOTEREVISION "REMOTEREVISION" diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -50,7 +50,6 @@ handler.cpp handlerhelper.cpp intervalcheck.cpp - collectionreferencemanager.cpp handler/collectioncopyhandler.cpp handler/collectioncreatehandler.cpp handler/collectiondeletehandler.cpp diff --git a/src/server/akonadi.cpp b/src/server/akonadi.cpp --- a/src/server/akonadi.cpp +++ b/src/server/akonadi.cpp @@ -40,8 +40,6 @@ #include "search/searchtaskmanager.h" #include "aklocalserver.h" -#include "collectionreferencemanager.h" - #include #include #include @@ -227,9 +225,6 @@ // operation was interrupted... db->unhideAllPimItems(); - // Cleanup referenced collections from the last run - CollectionReferenceManager::cleanup(); - // We are ready, now register org.freedesktop.Akonadi service to DBus and // the fun can begin if (!QDBusConnection::sessionBus().registerService(DBus::serviceName(DBus::Server))) { diff --git a/src/server/collectionreferencemanager.h b/src/server/collectionreferencemanager.h deleted file mode 100644 --- a/src/server/collectionreferencemanager.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (c) 2014 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#ifndef COLLECTIONREFERENCEMANAGER_H -#define COLLECTIONREFERENCEMANAGER_H - -#include "storage/entity.h" -#include "entities.h" -#include - -namespace Akonadi -{ -namespace Server -{ - -class CollectionReferenceManager -{ -public: - static CollectionReferenceManager *instance(); - - void referenceCollection(const QByteArray &sessionId, const Collection &collection, bool reference); - void removeSession(const QByteArray &sessionId); - bool isReferenced(Collection::Id collection) const; - bool isReferenced(Collection::Id collection, const QByteArray &sessionId) const; - - static void cleanup(); - -private: - CollectionReferenceManager(); - void expireCollectionIfNecessary(Collection::Id collection); - - QMultiHash mReferenceMap; - static CollectionReferenceManager *s_instance; - mutable QMutex mReferenceLock; -}; - -} -} - -#endif diff --git a/src/server/collectionreferencemanager.cpp b/src/server/collectionreferencemanager.cpp deleted file mode 100644 --- a/src/server/collectionreferencemanager.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (c) 2014 Christian Mollekopf - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "collectionreferencemanager.h" -#include "akonadi.h" -#include "akonadiserver_debug.h" -#include "cachecleaner.h" -#include "storage/selectquerybuilder.h" - -using namespace Akonadi; -using namespace Akonadi::Server; - -CollectionReferenceManager *CollectionReferenceManager::s_instance = nullptr; - -CollectionReferenceManager::CollectionReferenceManager() - : mReferenceLock(QMutex::Recursive) -{ -} - -CollectionReferenceManager *CollectionReferenceManager::instance() -{ - static QMutex s_instanceLock; - QMutexLocker locker(&s_instanceLock); - if (!s_instance) { - s_instance = new CollectionReferenceManager(); - } - return s_instance; -} - -void CollectionReferenceManager::referenceCollection(const QByteArray &sessionId, const Collection &collection, bool reference) -{ - QMutexLocker locker(&mReferenceLock); - if (reference) { - if (!mReferenceMap.contains(collection.id(), sessionId)) { - mReferenceMap.insert(collection.id(), sessionId); - } - } else { - mReferenceMap.remove(collection.id(), sessionId); - expireCollectionIfNecessary(collection.id()); - } -} - -void CollectionReferenceManager::removeSession(const QByteArray &sessionId) -{ - QMutexLocker locker(&mReferenceLock); - const QList lstCol = mReferenceMap.keys(sessionId); - for (Collection::Id col : lstCol ) { - mReferenceMap.remove(col, sessionId); - expireCollectionIfNecessary(col); - if (!isReferenced(col)) { - Collection collection = Collection::retrieveById(col); - collection.setReferenced(false); - collection.update(); - } - } -} - -bool CollectionReferenceManager::isReferenced(Collection::Id collection) const -{ - QMutexLocker locker(&mReferenceLock); - return mReferenceMap.contains(collection); -} - -bool CollectionReferenceManager::isReferenced(Collection::Id collection, const QByteArray &sessionId) const -{ - QMutexLocker locker(&mReferenceLock); - return mReferenceMap.contains(collection, sessionId); -} - -void CollectionReferenceManager::expireCollectionIfNecessary(Collection::Id collection) -{ - QMutexLocker locker(&mReferenceLock); - if (!isReferenced(collection)) { - if (AkonadiServer::instance()->cacheCleaner()) { - AkonadiServer::instance()->cacheCleaner()->collectionChanged(collection); - } - } -} - -void CollectionReferenceManager::cleanup() -{ - SelectQueryBuilder qb; - qb.addValueCondition(Collection::referencedColumn(), Query::Equals, true); - if (!qb.exec()) { - qCCritical(AKONADISERVER_LOG) << "Failed to execute collection reference cleanup query."; - return; - } - const QVector colVect = qb.result(); - for (Collection col : colVect) { - col.setReferenced(false); - col.update(); - if (AkonadiServer::instance()->cacheCleaner()) { - AkonadiServer::instance()->cacheCleaner()->collectionChanged(col.id()); - } - } - QMutexLocker locker(&instance()->mReferenceLock); - instance()->mReferenceMap.clear(); -} diff --git a/src/server/collectionscheduler.cpp b/src/server/collectionscheduler.cpp --- a/src/server/collectionscheduler.cpp +++ b/src/server/collectionscheduler.cpp @@ -301,7 +301,6 @@ andCondition.addValueCondition(Collection::syncPrefFullColumnName(), Query::Equals, (int)Akonadi::Tristate::Undefined); andCondition.addValueCondition(Collection::enabledFullColumnName(), Query::Equals, true); orCondition.addCondition(andCondition); - orCondition.addValueCondition(Collection::referencedFullColumnName(), Query::Equals, true); qb.addCondition(orCondition); if (!qb.exec()) { qCWarning(AKONADISERVER_LOG) << "Failed to query initial collections for scheduler!"; diff --git a/src/server/connection.h b/src/server/connection.h --- a/src/server/connection.h +++ b/src/server/connection.h @@ -46,7 +46,6 @@ class Response; class DataStore; class Collection; -class CollectionReferenceManager; /** An Connection represents one connection of a client to the server. @@ -60,8 +59,6 @@ virtual DataStore *storageBackend(); - CollectionReferenceManager *collectionReferenceManager(); - CommandContext *context() const; /** diff --git a/src/server/connection.cpp b/src/server/connection.cpp --- a/src/server/connection.cpp +++ b/src/server/connection.cpp @@ -33,7 +33,6 @@ #include "notificationmanager.h" #include "tracer.h" -#include "collectionreferencemanager.h" #include @@ -121,7 +120,6 @@ } Tracer::self()->endConnection(m_identifier, QString()); - collectionReferenceManager()->removeSession(m_sessionId); delete m_socket; m_socket = nullptr; @@ -154,11 +152,6 @@ return m_backend; } -CollectionReferenceManager *Connection::collectionReferenceManager() -{ - return CollectionReferenceManager::instance(); -} - Connection::~Connection() { quitThread(); diff --git a/src/server/handler/collectionfetchhandler.cpp b/src/server/handler/collectionfetchhandler.cpp --- a/src/server/handler/collectionfetchhandler.cpp +++ b/src/server/handler/collectionfetchhandler.cpp @@ -23,7 +23,6 @@ #include "connection.h" #include "handlerhelper.h" -#include "collectionreferencemanager.h" #include "storage/datastore.h" #include "storage/selectquerybuilder.h" #include "storage/collectionqueryhelper.h" @@ -82,15 +81,6 @@ ++it; } - // We need the reference and enabled status, to not need to request the server multiple times. - // Mostly interesting for ancestors for i.e. updates provided by the monitor. - const bool isReferenced = connection()->collectionReferenceManager()->isReferenced(col.id(), connection()->sessionId()); - if (isReferenced) { - CollectionAttribute attr; - attr.setType(AKONADI_PARAM_REFERENCED); - attr.setValue("TRUE"); - attributes << attr; - } { CollectionAttribute attr; attr.setType(AKONADI_PARAM_ENABLED); @@ -106,11 +96,6 @@ const QStringList &mimeTypes, const CollectionAttribute::List &attributes) { - const bool isReferencedFromSession = connection()->collectionReferenceManager()->isReferenced(root.id(), connection()->sessionId()); - //We always expose referenced collections to the resource as referenced (although it's a different session) - //Otherwise syncing wouldn't work. - const bool resourceIsSynchronizing = root.referenced() && mCollectionsToSynchronize && connection()->context()->resource().isValid(); - QStack ancestorAttributes; //backwards compatibility, collectionToByteArray will automatically fall-back to id + remoteid if (!mAncestorAttributes.isEmpty()) { @@ -127,7 +112,6 @@ sendResponse(HandlerHelper::fetchCollectionsResponse(dummy, attributes, mIncludeStatistics, mAncestorDepth, ancestors, ancestorAttributes, - isReferencedFromSession || resourceIsSynchronizing, mimeTypes)); } @@ -139,7 +123,6 @@ andCondition.addValueCondition(column, Query::Equals, (int)Collection::Undefined); andCondition.addValueCondition(Collection::enabledFullColumnName(), Query::Equals, true); orCondition.addCondition(andCondition); - orCondition.addValueCondition(Collection::referencedFullColumnName(), Query::Equals, true); return orCondition; } @@ -242,7 +225,6 @@ * * First all collections that match the given criteria are queried * * We then filter the false positives: * ** all collections out that are not part of the tree we asked for are filtered - * ** all collections that are referenced but not by this session or by the owning resource are filtered * * Finally we complete the tree by adding missing collections * * Mimetypes and attributes are also retrieved in single queries to avoid spawning two queries per collection (the N+1 problem). @@ -279,10 +261,7 @@ } else if (mCollectionsToIndex) { qb.addCondition(filterCondition(Collection::indexPrefFullColumnName())); } else if (mEnabledCollections) { - Query::Condition orCondition(Query::Or); - orCondition.addValueCondition(Collection::enabledFullColumnName(), Query::Equals, true); - orCondition.addValueCondition(Collection::referencedFullColumnName(), Query::Equals, true); - qb.addCondition(orCondition); + qb.addValueCondition(Collection::enabledFullColumnName(), Query::Equals, true); } if (mResource.isValid()) { qb.addValueCondition(Collection::resourceIdFullColumnName(), Query::Equals, mResource.id()); @@ -334,19 +313,6 @@ continue; } } - - //If we matched referenced collections we need to ensure the collection was referenced from this session - const bool isReferencedFromSession = connection()->collectionReferenceManager()->isReferenced(it->id(), connection()->sessionId()); - //The collection is referenced, but not from this session. We need to reevaluate the filter condition - if (it->referenced() && !isReferencedFromSession) { - //Don't include the collection when only looking for enabled collections. - //However, a referenced collection should be still synchronized by the resource, so we exclude this case. - if (!checkFilterCondition(*it) && !(mCollectionsToSynchronize && connection()->context()->resource().isValid())) { - it = mCollections.erase(it); - continue; - } - } - ++it; } } diff --git a/src/server/handler/collectionmodifyhandler.cpp b/src/server/handler/collectionmodifyhandler.cpp --- a/src/server/handler/collectionmodifyhandler.cpp +++ b/src/server/handler/collectionmodifyhandler.cpp @@ -23,7 +23,6 @@ #include "connection.h" #include "handlerhelper.h" #include "cachecleaner.h" -#include "collectionreferencemanager.h" #include "intervalcheck.h" #include "storage/datastore.h" #include "storage/transaction.h" @@ -64,7 +63,6 @@ DataStore *db = connection()->storageBackend(); Transaction transaction(db, QStringLiteral("MODIFY")); QList changes; - bool referencedChanged = false; if (cmd.modifiedParts() & Protocol::ModifyCollectionCommand::MimeTypes) { QStringList mts = cmd.mimeTypes(); @@ -224,19 +222,6 @@ } } - if (cmd.modifiedParts() & Protocol::ModifyCollectionCommand::Referenced) { - const bool wasReferencedFromSession = connection()->collectionReferenceManager()->isReferenced(collection.id(), connection()->sessionId()); - connection()->collectionReferenceManager()->referenceCollection(connection()->sessionId(), collection, cmd.referenced()); - const bool referenced = connection()->collectionReferenceManager()->isReferenced(collection.id()); - if (cmd.referenced() != wasReferencedFromSession) { - changes.append(AKONADI_PARAM_REFERENCED); - } - if (referenced != collection.referenced()) { - referencedChanged = true; - collection.setReferenced(referenced); - } - } - if (cmd.modifiedParts() & Protocol::ModifyCollectionCommand::RemovedAttributes) { Q_FOREACH (const QByteArray &attr, cmd.removedAttributes()) { if (db->removeCollectionAttribute(collection, attr)) { @@ -285,10 +270,6 @@ if (collection.hasPendingChanges() && !collection.update()) { return failureResponse("Unable to update collection"); } - //This must be after the collection was updated in the db. The resource will immediately request a copy of the collection. - if (AkonadiServer::instance()->intervalChecker() && collection.referenced() && referencedChanged) { - AkonadiServer::instance()->intervalChecker()->requestCollectionSync(collection); - } db->notificationCollector()->collectionChanged(collection, changes); //For backwards compatibility. Must be after the changed notification (otherwise the compression removes it). if (changes.contains(AKONADI_PARAM_ENABLED)) { diff --git a/src/server/handlerhelper.h b/src/server/handlerhelper.h --- a/src/server/handlerhelper.h +++ b/src/server/handlerhelper.h @@ -90,7 +90,6 @@ int ancestorDepth = 0, const QStack &ancestors = QStack(), const QStack &ancestorAttributes = QStack(), - bool isReferenced = false, const QStringList &mimeTypes = QStringList()); /** diff --git a/src/server/handlerhelper.cpp b/src/server/handlerhelper.cpp --- a/src/server/handlerhelper.cpp +++ b/src/server/handlerhelper.cpp @@ -103,16 +103,15 @@ } return fetchCollectionsResponse(col, col.attributes(), false, 0, QStack(), - QStack(), false, mimeTypes); + QStack(), mimeTypes); } Protocol::FetchCollectionsResponse HandlerHelper::fetchCollectionsResponse(const Collection &col, const CollectionAttribute::List &attrs, bool includeStatistics, int ancestorDepth, const QStack &ancestors, const QStack &ancestorAttributes, - bool isReferenced, const QStringList &mimeTypes) { Protocol::FetchCollectionsResponse response; @@ -156,7 +155,6 @@ response.setAncestors(ancestorList); } - response.setReferenced(isReferenced); response.setEnabled(col.enabled()); response.setDisplayPref(static_cast(col.displayPref())); response.setSyncPref(static_cast(col.syncPref())); diff --git a/src/server/notificationsubscriber.cpp b/src/server/notificationsubscriber.cpp --- a/src/server/notificationsubscriber.cpp +++ b/src/server/notificationsubscriber.cpp @@ -20,7 +20,6 @@ #include "notificationsubscriber.h" #include "akonadiserver_debug.h" #include "notificationmanager.h" -#include "collectionreferencemanager.h" #include "aggregatedfetchscope.h" #include "utils.h" @@ -398,22 +397,6 @@ return false; } - if (CollectionReferenceManager::instance()->isReferenced(msg.parentCollection())) { - //We always want notifications that affect the parent resource (like an item added to a referenced collection) - const bool notificationForParentResource = (mSession == msg.resource()); - const bool accepts = mExclusive - || isCollectionMonitored(msg.parentCollection()) - || isMoveDestinationResourceMonitored(msg) - || notificationForParentResource; - TRACE_NTF("ACCEPTS ITEM: parent col referenced" - << "exclusive:" << mExclusive << "," - << "parent monitored:" << isCollectionMonitored(msg.parentCollection()) << "," - << "destination monitored:" << isMoveDestinationResourceMonitored(msg) << "," - << "ntf for parent resource:" << notificationForParentResource << ":" - << "ACCEPTED:" << accepts); - return accepts; - } - if (mAllMonitored) { TRACE_NTF("ACCEPTS ITEM: all monitored"); return true; @@ -489,25 +472,8 @@ return true; } - //Deliver the notification if referenced from this session - if (CollectionReferenceManager::instance()->isReferenced(collection.id(), mSession)) { - return true; - } - - //Exclusive subscribers still want the notification - if (mExclusive && CollectionReferenceManager::instance()->isReferenced(collection.id())) { - return true; - } - - //The session belonging to this monitor referenced or dereferenced the collection. We always want this notification. - //The referencemanager no longer holds a reference, so we have to check this way. - if (msg.changedParts().contains(AKONADI_PARAM_REFERENCED) && mSession == msg.sessionId()) { - return true; - } - - // If the collection is not referenced, monitored or the subscriber is not - // exclusive (i.e. if we got here), then the subscriber does not care about - // this one, so drop it + // If the subscriber is not exclusive (i.e. if we got here), then the subscriber does + // not care about this one, so drop it return false; } @@ -678,20 +644,6 @@ } } -Protocol::CollectionChangeNotificationPtr NotificationSubscriber::customizeCollection(const Protocol::CollectionChangeNotificationPtr &ntf) -{ - const bool isReferencedFromSession = CollectionReferenceManager::instance()->isReferenced(ntf->collection().id(), mSession); - if (isReferencedFromSession != ntf->collection().referenced()) { - auto copy = Protocol::CollectionChangeNotificationPtr::create(*ntf); - auto copyCol = ntf->collection(); - copyCol.setReferenced(isReferencedFromSession); - copy->setCollection(std::move(copyCol)); - return copy; - } - - return ntf; -} - bool NotificationSubscriber::notify(const Protocol::ChangeNotificationPtr ¬ification) { // Guard against this object being deleted while we are waiting for the lock @@ -702,12 +654,8 @@ } if (acceptsNotification(*notification)) { - auto ntf = notification; - if (ntf->type() == Protocol::Command::CollectionChangeNotification) { - ntf = customizeCollection(notification.staticCast()); - } QMetaObject::invokeMethod(this, "writeNotification", Qt::QueuedConnection, - Q_ARG(Akonadi::Protocol::ChangeNotificationPtr, ntf)); + Q_ARG(Akonadi::Protocol::ChangeNotificationPtr, notification)); return true; } return false; diff --git a/src/server/preprocessormanager.cpp b/src/server/preprocessormanager.cpp --- a/src/server/preprocessormanager.cpp +++ b/src/server/preprocessormanager.cpp @@ -29,8 +29,6 @@ #include "storage/datastore.h" #include "tracer.h" -#include "collectionreferencemanager.h" - #include "preprocessormanageradaptor.h" namespace Akonadi @@ -230,8 +228,8 @@ Q_ASSERT_X(item.hidden(), "PreprocessorManager::beginHandleItem()", "The item you pass to this function should be hidden!"); #endif - if (mPreprocessorChain.isEmpty() || CollectionReferenceManager::instance()->isReferenced(item.collectionId())) { - // No preprocessors at all or referenced collection: immediately end handling the item. + if (mPreprocessorChain.isEmpty()) { + // No preprocessors at all: immediately end handling the item. lockedEndHandleItem(item.id()); return; } diff --git a/src/server/storage/akonadidb.xml b/src/server/storage/akonadidb.xml --- a/src/server/storage/akonadidb.xml +++ b/src/server/storage/akonadidb.xml @@ -67,7 +67,7 @@ Contains the schema version of the database. - + @@ -95,7 +95,6 @@ - diff --git a/src/server/storage/notificationcollector.cpp b/src/server/storage/notificationcollector.cpp --- a/src/server/storage/notificationcollector.cpp +++ b/src/server/storage/notificationcollector.cpp @@ -155,7 +155,7 @@ if (auto checker = AkonadiServer::instance()->intervalChecker()) { checker->collectionChanged(collection.id()); } - if (changes.contains(AKONADI_PARAM_ENABLED) || changes.contains(AKONADI_PARAM_REFERENCED)) { + if (changes.contains(AKONADI_PARAM_ENABLED)) { CollectionStatistics::self()->invalidateCollection(collection); } collectionNotification(Protocol::CollectionChangeNotification::Modify, collection, collection.parentId(), @@ -407,7 +407,7 @@ for (const auto &mt : mts) { mimeTypes.push_back(mt.name()); } - msgCollection = HandlerHelper::fetchCollectionsResponse(col, {}, false, 0, {}, {}, false, mimeTypes); + msgCollection = HandlerHelper::fetchCollectionsResponse(col, {}, false, 0, {}, {}, mimeTypes); } // Get up-to-date statistics if (fetchScope->fetchStatistics()) {