diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-12 11:46:48 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-12 11:46:48 +0200 |
commit | a547334afca38baae64e0f5774b1eb7f082a08e3 (patch) | |
tree | 667ad75cb4aa1652c79f6ceab8422d0d9848113e /examples | |
parent | dc33cea58f4b920f60648e81379c58bd62861b9b (diff) | |
download | sink-a547334afca38baae64e0f5774b1eb7f082a08e3.tar.gz sink-a547334afca38baae64e0f5774b1eb7f082a08e3.zip |
Allow the preprocessor to move and use in mailtransport
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 23 | ||||
-rw-r--r-- | examples/mailtransportresource/tests/mailtransporttest.cpp | 7 |
2 files changed, 17 insertions, 13 deletions
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: | |||
66 | return targetResource.identifier(); | 66 | return targetResource.identifier(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void modifiedEntity(const Sink::ApplicationDomain::ApplicationDomainType &oldEntity, Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE | 69 | virtual Result processModification(Type type, const ApplicationDomain::ApplicationDomainType ¤t, ApplicationDomain::ApplicationDomainType &diff) Q_DECL_OVERRIDE |
70 | { | 70 | { |
71 | using namespace Sink::ApplicationDomain; | 71 | if (type == Preprocessor::Modification) { |
72 | auto mail = newEntity.cast<Mail>(); | 72 | using namespace Sink::ApplicationDomain; |
73 | if (mail.changedProperties().contains(Mail::Trash::name)) { | 73 | if (diff.changedProperties().contains(Mail::Trash::name)) { |
74 | //Move back to regular resource | 74 | //Move back to regular resource |
75 | newEntity.setResource(getTargetResource()); | 75 | diff.setResource(getTargetResource()); |
76 | } else if (mail.changedProperties().contains(Mail::Draft::name)) { | 76 | return {MoveToResource}; |
77 | //Move back to regular resource | 77 | } else if (diff.changedProperties().contains(Mail::Draft::name)) { |
78 | newEntity.setResource(getTargetResource()); | 78 | //Move back to regular resource |
79 | diff.setResource(getTargetResource()); | ||
80 | return {MoveToResource}; | ||
81 | } | ||
79 | } | 82 | } |
80 | //TODO this will only copy it back, but not yet move | 83 | return {NoAction}; |
81 | } | 84 | } |
82 | }; | 85 | }; |
83 | 86 | ||
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: | |||
47 | 47 | ||
48 | void cleanup() | 48 | void cleanup() |
49 | { | 49 | { |
50 | VERIFYEXEC(ResourceControl::shutdown(mResourceInstanceIdentifier)); | 50 | VERIFYEXEC(Store::removeDataFromDisk(mResourceInstanceIdentifier)); |
51 | VERIFYEXEC(Store::removeDataFromDisk(mStorageResource)); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | void init() | 54 | void init() |
@@ -107,8 +108,8 @@ private slots: | |||
107 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 108 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
108 | 109 | ||
109 | QTest::qWait(100); | 110 | QTest::qWait(100); |
110 | // auto mailsInOutbox = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mResourceInstanceIdentifier)); | 111 | auto mailsInOutbox = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mResourceInstanceIdentifier)); |
111 | // QCOMPARE(mailsInOutbox.size(), 0); | 112 | QCOMPARE(mailsInOutbox.size(), 0); |
112 | 113 | ||
113 | auto mailsInDrafts = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mStorageResource)); | 114 | auto mailsInDrafts = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mStorageResource)); |
114 | QCOMPARE(mailsInDrafts.size(), 1); | 115 | QCOMPARE(mailsInDrafts.size(), 1); |