diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-06 19:31:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-06 19:31:31 +0100 |
commit | 20b76fc1fd539bf95b8cb0d0ea7044718ec99972 (patch) | |
tree | 03da4339c8879e4d45e0c5a903b6bfb410c4bf31 /common | |
parent | 62c7b07c0d62f8f03e22556bf62ed90d267c6d2e (diff) | |
download | sink-20b76fc1fd539bf95b8cb0d0ea7044718ec99972.tar.gz sink-20b76fc1fd539bf95b8cb0d0ea7044718ec99972.zip |
Move mail to sent folder after sending it
Diffstat (limited to 'common')
-rw-r--r-- | common/pipeline.cpp | 2 | ||||
-rw-r--r-- | common/synchronizer.cpp | 22 | ||||
-rw-r--r-- | common/synchronizer.h | 4 |
3 files changed, 15 insertions, 13 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 1620667..4ea43eb 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -258,7 +258,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
258 | return KAsync::error<qint64>(0); | 258 | return KAsync::error<qint64>(0); |
259 | } | 259 | } |
260 | 260 | ||
261 | auto newEntity = *ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<ApplicationDomain::ApplicationDomainType>(current, current.availableProperties()); | 261 | auto newEntity = *ApplicationDomain::ApplicationDomainType::getInMemoryCopy<ApplicationDomain::ApplicationDomainType>(current, current.availableProperties()); |
262 | 262 | ||
263 | // Apply diff | 263 | // Apply diff |
264 | for (const auto &property : changeset) { | 264 | for (const auto &property : changeset) { |
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 036288e..fec848f 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -82,7 +82,6 @@ void Synchronizer::createEntity(const QByteArray &sinkId, const QByteArray &buff | |||
82 | flatbuffers::FlatBufferBuilder entityFbb; | 82 | flatbuffers::FlatBufferBuilder entityFbb; |
83 | mResourceContext.adaptorFactory(bufferType).createBuffer(domainObject, entityFbb); | 83 | mResourceContext.adaptorFactory(bufferType).createBuffer(domainObject, entityFbb); |
84 | flatbuffers::FlatBufferBuilder fbb; | 84 | flatbuffers::FlatBufferBuilder fbb; |
85 | // This is the resource type and not the domain type | ||
86 | auto entityId = fbb.CreateString(sinkId.toStdString()); | 85 | auto entityId = fbb.CreateString(sinkId.toStdString()); |
87 | auto type = fbb.CreateString(bufferType.toStdString()); | 86 | auto type = fbb.CreateString(bufferType.toStdString()); |
88 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 87 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
@@ -91,7 +90,7 @@ void Synchronizer::createEntity(const QByteArray &sinkId, const QByteArray &buff | |||
91 | enqueueCommand(Sink::Commands::CreateEntityCommand, BufferUtils::extractBuffer(fbb)); | 90 | enqueueCommand(Sink::Commands::CreateEntityCommand, BufferUtils::extractBuffer(fbb)); |
92 | } | 91 | } |
93 | 92 | ||
94 | void Synchronizer::modifyEntity(const QByteArray &sinkId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject) | 93 | void Synchronizer::modifyEntity(const QByteArray &sinkId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, const QByteArray &newResource, bool remove) |
95 | { | 94 | { |
96 | // FIXME removals | 95 | // FIXME removals |
97 | QByteArrayList deletedProperties; | 96 | QByteArrayList deletedProperties; |
@@ -103,10 +102,10 @@ void Synchronizer::modifyEntity(const QByteArray &sinkId, qint64 revision, const | |||
103 | auto entityId = fbb.CreateString(sinkId.toStdString()); | 102 | auto entityId = fbb.CreateString(sinkId.toStdString()); |
104 | auto modifiedProperties = BufferUtils::toVector(fbb, domainObject.changedProperties()); | 103 | auto modifiedProperties = BufferUtils::toVector(fbb, domainObject.changedProperties()); |
105 | auto deletions = BufferUtils::toVector(fbb, deletedProperties); | 104 | auto deletions = BufferUtils::toVector(fbb, deletedProperties); |
106 | // This is the resource type and not the domain type | ||
107 | auto type = fbb.CreateString(bufferType.toStdString()); | 105 | auto type = fbb.CreateString(bufferType.toStdString()); |
108 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 106 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
109 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta, replayToSource, modifiedProperties); | 107 | auto resource = newResource.isEmpty() ? 0 : fbb.CreateString(newResource.constData()); |
108 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta, replayToSource, modifiedProperties, resource, remove); | ||
110 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); | 109 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); |
111 | enqueueCommand(Sink::Commands::ModifyEntityCommand, BufferUtils::extractBuffer(fbb)); | 110 | enqueueCommand(Sink::Commands::ModifyEntityCommand, BufferUtils::extractBuffer(fbb)); |
112 | } | 111 | } |
@@ -247,9 +246,9 @@ QByteArrayList Synchronizer::resolveFilter(const QueryBase::Comparator &filter) | |||
247 | } | 246 | } |
248 | 247 | ||
249 | template<typename DomainType> | 248 | template<typename DomainType> |
250 | void Synchronizer::modify(const DomainType &entity) | 249 | void Synchronizer::modify(const DomainType &entity, const QByteArray &newResource, bool remove) |
251 | { | 250 | { |
252 | modifyEntity(entity.identifier(), entity.revision(), ApplicationDomain::getTypeName<DomainType>(), entity); | 251 | modifyEntity(entity.identifier(), entity.revision(), ApplicationDomain::getTypeName<DomainType>(), entity, newResource, remove); |
253 | } | 252 | } |
254 | 253 | ||
255 | QList<Synchronizer::SyncRequest> Synchronizer::getSyncRequests(const Sink::QueryBase &query) | 254 | QList<Synchronizer::SyncRequest> Synchronizer::getSyncRequests(const Sink::QueryBase &query) |
@@ -483,9 +482,12 @@ bool Synchronizer::allChangesReplayed() | |||
483 | 482 | ||
484 | #define REGISTER_TYPE(T) \ | 483 | #define REGISTER_TYPE(T) \ |
485 | template void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray &remoteId, const T &entity, const QHash<QByteArray, Sink::Query::Comparator> &mergeCriteria); \ | 484 | template void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray &remoteId, const T &entity, const QHash<QByteArray, Sink::Query::Comparator> &mergeCriteria); \ |
486 | template void Synchronizer::modify(const T &entity); | 485 | template void Synchronizer::modify(const T &entity, const QByteArray &newResource, bool remove); |
486 | |||
487 | #define SINK_REGISTER_TYPES() \ | ||
488 | REGISTER_TYPE(ApplicationDomain::Event); \ | ||
489 | REGISTER_TYPE(ApplicationDomain::Mail); \ | ||
490 | REGISTER_TYPE(ApplicationDomain::Folder); \ | ||
487 | 491 | ||
488 | REGISTER_TYPE(ApplicationDomain::Event); | 492 | SINK_REGISTER_TYPES() |
489 | REGISTER_TYPE(ApplicationDomain::Mail); | ||
490 | REGISTER_TYPE(ApplicationDomain::Folder); | ||
491 | 493 | ||
diff --git a/common/synchronizer.h b/common/synchronizer.h index f9b834e..00b5fba 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h | |||
@@ -79,7 +79,7 @@ protected: | |||
79 | void enqueueCommand(int commandId, const QByteArray &data); | 79 | void enqueueCommand(int commandId, const QByteArray &data); |
80 | 80 | ||
81 | void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject); | 81 | void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject); |
82 | void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject); | 82 | void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, const QByteArray &newResource = QByteArray(), bool remove = false); |
83 | void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType); | 83 | void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType); |
84 | 84 | ||
85 | /** | 85 | /** |
@@ -109,7 +109,7 @@ protected: | |||
109 | // template <typename DomainType> | 109 | // template <typename DomainType> |
110 | // void create(const DomainType &entity); | 110 | // void create(const DomainType &entity); |
111 | template <typename DomainType> | 111 | template <typename DomainType> |
112 | void modify(const DomainType &entity); | 112 | void modify(const DomainType &entity, const QByteArray &newResource = QByteArray(), bool remove = false); |
113 | // template <typename DomainType> | 113 | // template <typename DomainType> |
114 | // void remove(const DomainType &entity); | 114 | // void remove(const DomainType &entity); |
115 | QByteArrayList resolveFilter(const QueryBase::Comparator &filter); | 115 | QByteArrayList resolveFilter(const QueryBase::Comparator &filter); |