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 --- common/pipeline.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'common/pipeline.cpp') diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 91437d4..019784e 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -269,7 +269,26 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) } foreach (const auto &processor, d->processors[bufferType]) { - processor->modifiedEntity(current, newEntity); + bool exitLoop = false; + const auto result = processor->processModification(Preprocessor::Modification, current, newEntity); + switch (result.action) { + case Preprocessor::MoveToResource: + isMove = true; + exitLoop = true; + break; + case Preprocessor::CopyToResource: + isMove = true; + exitLoop = true; + break; + case Preprocessor::DropModification: + SinkTraceCtx(d->logCtx) << "Dropping modification"; + return KAsync::error(0); + default: + break; + } + if (exitLoop) { + break; + } } //The entity is either being copied or moved @@ -378,6 +397,39 @@ void Preprocessor::finalizeBatch() { } +void Preprocessor::newEntity(ApplicationDomain::ApplicationDomainType &newEntity) +{ + +} + +void Preprocessor::modifiedEntity(const ApplicationDomain::ApplicationDomainType &oldEntity, ApplicationDomain::ApplicationDomainType &newEntity) +{ + +} + +void Preprocessor::deletedEntity(const ApplicationDomain::ApplicationDomainType &oldEntity) +{ + +} + +Preprocessor::Result Preprocessor::processModification(Type type, const ApplicationDomain::ApplicationDomainType ¤t, ApplicationDomain::ApplicationDomainType &diff) +{ + switch(type) { + case Creation: + newEntity(diff); + return {NoAction}; + case Modification: + modifiedEntity(current, diff); + return {NoAction}; + case Deletion: + deletedEntity(current); + return {NoAction}; + default: + break; + } + return {NoAction}; +} + QByteArray Preprocessor::resourceInstanceIdentifier() const { return d->resourceInstanceIdentifier; -- cgit v1.2.3