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/synchronizer.cpp | |
parent | 62c7b07c0d62f8f03e22556bf62ed90d267c6d2e (diff) | |
download | sink-20b76fc1fd539bf95b8cb0d0ea7044718ec99972.tar.gz sink-20b76fc1fd539bf95b8cb0d0ea7044718ec99972.zip |
Move mail to sent folder after sending it
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r-- | common/synchronizer.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
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 | ||