diff options
Diffstat (limited to 'examples/mailtransportresource/mailtransportresource.cpp')
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 3ce9476..9a22c41 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <pipeline.h> | 41 | #include <pipeline.h> |
42 | #include <mailpreprocessor.h> | 42 | #include <mailpreprocessor.h> |
43 | #include <indexupdater.h> | 43 | #include <indexupdater.h> |
44 | #include <adaptorfactoryregistry.h> | ||
44 | 45 | ||
45 | #define ENTITY_TYPE_MAIL "mail" | 46 | #define ENTITY_TYPE_MAIL "mail" |
46 | 47 | ||
@@ -52,7 +53,7 @@ using namespace Sink; | |||
52 | class MailtransportWriteback : public Sink::SourceWriteBack | 53 | class MailtransportWriteback : public Sink::SourceWriteBack |
53 | { | 54 | { |
54 | public: | 55 | public: |
55 | MailtransportWriteback(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier) : Sink::SourceWriteBack(resourceType, resourceInstanceIdentifier) | 56 | MailtransportWriteback(const Sink::ResourceContext &resourceContext) : Sink::SourceWriteBack(resourceContext) |
56 | { | 57 | { |
57 | 58 | ||
58 | } | 59 | } |
@@ -74,9 +75,9 @@ public: | |||
74 | 75 | ||
75 | class MailtransportSynchronizer : public Sink::Synchronizer { | 76 | class MailtransportSynchronizer : public Sink::Synchronizer { |
76 | public: | 77 | public: |
77 | MailtransportSynchronizer(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier) | 78 | MailtransportSynchronizer(const Sink::ResourceContext &resourceContext) |
78 | : Sink::Synchronizer(resourceType, resourceInstanceIdentifier), | 79 | : Sink::Synchronizer(resourceContext), |
79 | mResourceInstanceIdentifier(resourceInstanceIdentifier) | 80 | mResourceInstanceIdentifier(resourceContext.instanceId()) |
80 | { | 81 | { |
81 | 82 | ||
82 | } | 83 | } |
@@ -112,10 +113,9 @@ public: | |||
112 | { | 113 | { |
113 | SinkLog() << " Synchronizing"; | 114 | SinkLog() << " Synchronizing"; |
114 | return KAsync::start<void>([this](KAsync::Future<void> future) { | 115 | return KAsync::start<void>([this](KAsync::Future<void> future) { |
115 | Sink::Query query; | ||
116 | QList<ApplicationDomain::Mail> toSend; | 116 | QList<ApplicationDomain::Mail> toSend; |
117 | SinkLog() << " Looking for mail"; | 117 | SinkLog() << " Looking for mail"; |
118 | store().reader<ApplicationDomain::Mail>().query(query, [&](const ApplicationDomain::Mail &mail) -> bool { | 118 | store().readAll<ApplicationDomain::Mail>([&](const ApplicationDomain::Mail &mail) -> bool { |
119 | SinkTrace() << "Found mail: " << mail.identifier(); | 119 | SinkTrace() << "Found mail: " << mail.identifier(); |
120 | if (!mail.getSent()) { | 120 | if (!mail.getSent()) { |
121 | toSend << mail; | 121 | toSend << mail; |
@@ -143,10 +143,10 @@ public: | |||
143 | MailtransportResource::Settings mSettings; | 143 | MailtransportResource::Settings mSettings; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | MailtransportResource::MailtransportResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline) | 146 | MailtransportResource::MailtransportResource(const Sink::ResourceContext &resourceContext, const QSharedPointer<Sink::Pipeline> &pipeline) |
147 | : Sink::GenericResource(PLUGIN_NAME, instanceIdentifier, pipeline) | 147 | : Sink::GenericResource(resourceContext, pipeline) |
148 | { | 148 | { |
149 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); | 149 | auto config = ResourceConfig::getConfiguration(resourceContext.instanceId()); |
150 | mSettings = {config.value("server").toString(), | 150 | mSettings = {config.value("server").toString(), |
151 | config.value("username").toString(), | 151 | config.value("username").toString(), |
152 | config.value("cacert").toString(), | 152 | config.value("cacert").toString(), |
@@ -154,11 +154,11 @@ MailtransportResource::MailtransportResource(const QByteArray &instanceIdentifie | |||
154 | config.value("testmode").toBool() | 154 | config.value("testmode").toBool() |
155 | }; | 155 | }; |
156 | 156 | ||
157 | auto synchronizer = QSharedPointer<MailtransportSynchronizer>::create(PLUGIN_NAME, instanceIdentifier); | 157 | auto synchronizer = QSharedPointer<MailtransportSynchronizer>::create(resourceContext); |
158 | synchronizer->mSettings = mSettings; | 158 | synchronizer->mSettings = mSettings; |
159 | setupSynchronizer(synchronizer); | 159 | setupSynchronizer(synchronizer); |
160 | 160 | ||
161 | auto changereplay = QSharedPointer<MailtransportWriteback>::create(PLUGIN_NAME, instanceIdentifier); | 161 | auto changereplay = QSharedPointer<MailtransportWriteback>::create(resourceContext); |
162 | changereplay->mSettings = mSettings; | 162 | changereplay->mSettings = mSettings; |
163 | setupChangereplay(changereplay); | 163 | setupChangereplay(changereplay); |
164 | 164 | ||
@@ -168,14 +168,14 @@ MailtransportResource::MailtransportResource(const QByteArray &instanceIdentifie | |||
168 | void MailtransportResource::removeFromDisk(const QByteArray &instanceIdentifier) | 168 | void MailtransportResource::removeFromDisk(const QByteArray &instanceIdentifier) |
169 | { | 169 | { |
170 | GenericResource::removeFromDisk(instanceIdentifier); | 170 | GenericResource::removeFromDisk(instanceIdentifier); |
171 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronization", Sink::Storage::ReadWrite).removeFromDisk(); | 171 | Sink::Storage::DataStore(Sink::storageLocation(), instanceIdentifier + ".synchronization", Sink::Storage::DataStore::ReadWrite).removeFromDisk(); |
172 | } | 172 | } |
173 | 173 | ||
174 | KAsync::Job<void> MailtransportResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | 174 | KAsync::Job<void> MailtransportResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) |
175 | { | 175 | { |
176 | if (domainType == ENTITY_TYPE_MAIL) { | 176 | if (domainType == ENTITY_TYPE_MAIL) { |
177 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { | 177 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { |
178 | auto path = resourceStorageLocation(mResourceInstanceIdentifier) + "/test/" + entityId; | 178 | auto path = resourceStorageLocation(mResourceContext.instanceId()) + "/test/" + entityId; |
179 | if (QFileInfo::exists(path)) { | 179 | if (QFileInfo::exists(path)) { |
180 | return KAsync::null<void>(); | 180 | return KAsync::null<void>(); |
181 | } | 181 | } |
@@ -191,14 +191,14 @@ MailtransportResourceFactory::MailtransportResourceFactory(QObject *parent) | |||
191 | 191 | ||
192 | } | 192 | } |
193 | 193 | ||
194 | Sink::Resource *MailtransportResourceFactory::createResource(const QByteArray &instanceIdentifier) | 194 | Sink::Resource *MailtransportResourceFactory::createResource(const Sink::ResourceContext &context) |
195 | { | 195 | { |
196 | return new MailtransportResource(instanceIdentifier); | 196 | return new MailtransportResource(context); |
197 | } | 197 | } |
198 | 198 | ||
199 | void MailtransportResourceFactory::registerFacades(Sink::FacadeFactory &factory) | 199 | void MailtransportResourceFactory::registerFacades(Sink::FacadeFactory &factory) |
200 | { | 200 | { |
201 | factory.registerFacade<ApplicationDomain::Mail, DefaultFacade<ApplicationDomain::Mail, DomainTypeAdaptorFactory<ApplicationDomain::Mail>>>(PLUGIN_NAME); | 201 | factory.registerFacade<ApplicationDomain::Mail, DefaultFacade<ApplicationDomain::Mail>>(PLUGIN_NAME); |
202 | } | 202 | } |
203 | 203 | ||
204 | void MailtransportResourceFactory::registerAdaptorFactories(Sink::AdaptorFactoryRegistry ®istry) | 204 | void MailtransportResourceFactory::registerAdaptorFactories(Sink::AdaptorFactoryRegistry ®istry) |