summaryrefslogtreecommitdiffstats
path: root/examples/mailtransportresource/mailtransportresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-21 23:13:38 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-21 23:51:24 +0100
commit1d713d9e2dbaf27de9da087f9270d260dfc40c31 (patch)
tree666d8edd42e44df3eaa674a35b6e938b99c2f4b4 /examples/mailtransportresource/mailtransportresource.cpp
parent0adba61a00491b96dadaa6d4719cb46831356222 (diff)
downloadsink-1d713d9e2dbaf27de9da087f9270d260dfc40c31.tar.gz
sink-1d713d9e2dbaf27de9da087f9270d260dfc40c31.zip
Folded the SourceWriteback into the Synchronizer.
By concentrating all communication to the source in one place we get rid of several oddities. * Quite a bit of duplication since both need access to the synchronizationStore and the source. * We currently have an akward locking in place because both classes access the ync store. This is not easier to resolve cleanly. * The live of resource implementers becomes easier. * An implementation could elect to not use changereplay and always do a full sync... (maybe?)
Diffstat (limited to 'examples/mailtransportresource/mailtransportresource.cpp')
-rw-r--r--examples/mailtransportresource/mailtransportresource.cpp40
1 files changed, 11 insertions, 29 deletions
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp
index 3fe551a..0688af6 100644
--- a/examples/mailtransportresource/mailtransportresource.cpp
+++ b/examples/mailtransportresource/mailtransportresource.cpp
@@ -23,7 +23,6 @@
23#include "resourceconfig.h" 23#include "resourceconfig.h"
24#include "definitions.h" 24#include "definitions.h"
25#include "domainadaptor.h" 25#include "domainadaptor.h"
26#include "sourcewriteback.h"
27#include <QDir> 26#include <QDir>
28#include <QFileInfo> 27#include <QFileInfo>
29#include <QSettings> 28#include <QSettings>
@@ -45,30 +44,6 @@ SINK_DEBUG_AREA("mailtransportresource")
45 44
46using namespace Sink; 45using namespace Sink;
47 46
48//TODO fold into synchronizer
49class MailtransportWriteback : public Sink::SourceWriteBack
50{
51public:
52 MailtransportWriteback(const Sink::ResourceContext &resourceContext) : Sink::SourceWriteBack(resourceContext)
53 {
54
55 }
56
57 KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE
58 {
59 if (operation == Sink::Operation_Creation) {
60 SinkTrace() << "Dispatching message.";
61 // return send(mail, mSettings);
62 } else if (operation == Sink::Operation_Removal) {
63 } else if (operation == Sink::Operation_Modification) {
64 }
65 return KAsync::null<QByteArray>();
66 }
67
68public:
69 MailtransportResource::Settings mSettings;
70};
71
72class MailtransportSynchronizer : public Sink::Synchronizer { 47class MailtransportSynchronizer : public Sink::Synchronizer {
73public: 48public:
74 MailtransportSynchronizer(const Sink::ResourceContext &resourceContext) 49 MailtransportSynchronizer(const Sink::ResourceContext &resourceContext)
@@ -134,6 +109,17 @@ public:
134 }); 109 });
135 } 110 }
136 111
112 KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE
113 {
114 if (operation == Sink::Operation_Creation) {
115 SinkTrace() << "Dispatching message.";
116 // return send(mail, mSettings);
117 } else if (operation == Sink::Operation_Removal) {
118 } else if (operation == Sink::Operation_Modification) {
119 }
120 return KAsync::null<QByteArray>();
121 }
122
137public: 123public:
138 QByteArray mResourceInstanceIdentifier; 124 QByteArray mResourceInstanceIdentifier;
139 MailtransportResource::Settings mSettings; 125 MailtransportResource::Settings mSettings;
@@ -154,10 +140,6 @@ MailtransportResource::MailtransportResource(const Sink::ResourceContext &resour
154 synchronizer->mSettings = mSettings; 140 synchronizer->mSettings = mSettings;
155 setupSynchronizer(synchronizer); 141 setupSynchronizer(synchronizer);
156 142
157 auto changereplay = QSharedPointer<MailtransportWriteback>::create(resourceContext);
158 changereplay->mSettings = mSettings;
159 setupChangereplay(changereplay);
160
161 setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new MimeMessageMover << new MailPropertyExtractor); 143 setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new MimeMessageMover << new MailPropertyExtractor);
162} 144}
163 145