From a547334afca38baae64e0f5774b1eb7f082a08e3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 12 Apr 2017 11:46:48 +0200 Subject: Allow the preprocessor to move and use in mailtransport --- .../mailtransportresource.cpp | 23 ++++++++++++---------- .../tests/mailtransporttest.cpp | 7 ++++--- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'examples/mailtransportresource') diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 8e5b22e..8a4ef92 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp @@ -66,18 +66,21 @@ public: return targetResource.identifier(); } - void modifiedEntity(const Sink::ApplicationDomain::ApplicationDomainType &oldEntity, Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE + virtual Result processModification(Type type, const ApplicationDomain::ApplicationDomainType ¤t, ApplicationDomain::ApplicationDomainType &diff) Q_DECL_OVERRIDE { - using namespace Sink::ApplicationDomain; - auto mail = newEntity.cast(); - if (mail.changedProperties().contains(Mail::Trash::name)) { - //Move back to regular resource - newEntity.setResource(getTargetResource()); - } else if (mail.changedProperties().contains(Mail::Draft::name)) { - //Move back to regular resource - newEntity.setResource(getTargetResource()); + if (type == Preprocessor::Modification) { + using namespace Sink::ApplicationDomain; + if (diff.changedProperties().contains(Mail::Trash::name)) { + //Move back to regular resource + diff.setResource(getTargetResource()); + return {MoveToResource}; + } else if (diff.changedProperties().contains(Mail::Draft::name)) { + //Move back to regular resource + diff.setResource(getTargetResource()); + return {MoveToResource}; + } } - //TODO this will only copy it back, but not yet move + return {NoAction}; } }; diff --git a/examples/mailtransportresource/tests/mailtransporttest.cpp b/examples/mailtransportresource/tests/mailtransporttest.cpp index a30fc20..e4cc447 100644 --- a/examples/mailtransportresource/tests/mailtransporttest.cpp +++ b/examples/mailtransportresource/tests/mailtransporttest.cpp @@ -47,7 +47,8 @@ private slots: void cleanup() { - VERIFYEXEC(ResourceControl::shutdown(mResourceInstanceIdentifier)); + VERIFYEXEC(Store::removeDataFromDisk(mResourceInstanceIdentifier)); + VERIFYEXEC(Store::removeDataFromDisk(mStorageResource)); } void init() @@ -107,8 +108,8 @@ private slots: VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); QTest::qWait(100); - // auto mailsInOutbox = Store::read(Query().resourceFilter(mResourceInstanceIdentifier)); - // QCOMPARE(mailsInOutbox.size(), 0); + auto mailsInOutbox = Store::read(Query().resourceFilter(mResourceInstanceIdentifier)); + QCOMPARE(mailsInOutbox.size(), 0); auto mailsInDrafts = Store::read(Query().resourceFilter(mStorageResource)); QCOMPARE(mailsInDrafts.size(), 1); -- cgit v1.2.3