diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 12:39:45 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 12:39:45 +0100 |
commit | d5b28efe4d7fc2a984243417d923ff5727234e94 (patch) | |
tree | 1546145760eb0fa2d8d606e3332e1bab92e63161 /common/genericresource.cpp | |
parent | 4922555a38af32fc94e56aeb208b9fda31dab1b2 (diff) | |
download | sink-d5b28efe4d7fc2a984243417d923ff5727234e94.tar.gz sink-d5b28efe4d7fc2a984243417d923ff5727234e94.zip |
Added bufferutils.h
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r-- | common/genericresource.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 892c3db..40e3add 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "index.h" | 12 | #include "index.h" |
13 | #include "log.h" | 13 | #include "log.h" |
14 | #include "definitions.h" | 14 | #include "definitions.h" |
15 | #include "bufferutils.h" | ||
15 | 16 | ||
16 | #include <QUuid> | 17 | #include <QUuid> |
17 | #include <QDataStream> | 18 | #include <QDataStream> |
@@ -301,11 +302,12 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c | |||
301 | if (Akonadi2::Commands::VerifyInspectionBuffer(verifier)) { | 302 | if (Akonadi2::Commands::VerifyInspectionBuffer(verifier)) { |
302 | auto buffer = Akonadi2::Commands::GetInspection(command); | 303 | auto buffer = Akonadi2::Commands::GetInspection(command); |
303 | int inspectionType = buffer->type(); | 304 | int inspectionType = buffer->type(); |
304 | QByteArray inspectionId = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer->id()->Data()), buffer->id()->size()); | 305 | |
305 | QByteArray entityId = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer->entityId()->Data()), buffer->entityId()->size()); | 306 | QByteArray inspectionId = BufferUtils::extractBuffer(buffer->id()); |
306 | QByteArray domainType = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer->domainType()->Data()), buffer->domainType()->size()); | 307 | QByteArray entityId = BufferUtils::extractBuffer(buffer->entityId()); |
307 | QByteArray property = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer->property()->Data()), buffer->property()->size()); | 308 | QByteArray domainType = BufferUtils::extractBuffer(buffer->domainType()); |
308 | QByteArray expectedValueString = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer->expectedValue()->Data()), buffer->expectedValue()->size()); | 309 | QByteArray property = BufferUtils::extractBuffer(buffer->property()); |
310 | QByteArray expectedValueString = BufferUtils::extractBuffer(buffer->expectedValue()); | ||
309 | QDataStream s(expectedValueString); | 311 | QDataStream s(expectedValueString); |
310 | QVariant expectedValue; | 312 | QVariant expectedValue; |
311 | s >> expectedValue; | 313 | s >> expectedValue; |
@@ -518,7 +520,7 @@ void GenericResource::createEntity(const QByteArray &akonadiId, const QByteArray | |||
518 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 520 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
519 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, entityId, type, delta, replayToSource); | 521 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, entityId, type, delta, replayToSource); |
520 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 522 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); |
521 | callback(QByteArray::fromRawData(reinterpret_cast<char const *>(fbb.GetBufferPointer()), fbb.GetSize())); | 523 | callback(BufferUtils::extractBuffer(fbb)); |
522 | } | 524 | } |
523 | 525 | ||
524 | void GenericResource::modifyEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) | 526 | void GenericResource::modifyEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) |
@@ -535,7 +537,7 @@ void GenericResource::modifyEntity(const QByteArray &akonadiId, qint64 revision, | |||
535 | //TODO removals | 537 | //TODO removals |
536 | auto location = Akonadi2::Commands::CreateModifyEntity(fbb, revision, entityId, 0, type, delta, replayToSource); | 538 | auto location = Akonadi2::Commands::CreateModifyEntity(fbb, revision, entityId, 0, type, delta, replayToSource); |
537 | Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); | 539 | Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); |
538 | callback(QByteArray::fromRawData(reinterpret_cast<char const *>(fbb.GetBufferPointer()), fbb.GetSize())); | 540 | callback(BufferUtils::extractBuffer(fbb)); |
539 | } | 541 | } |
540 | 542 | ||
541 | void GenericResource::deleteEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback) | 543 | void GenericResource::deleteEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback) |
@@ -548,7 +550,7 @@ void GenericResource::deleteEntity(const QByteArray &akonadiId, qint64 revision, | |||
548 | auto type = fbb.CreateString(bufferType.toStdString()); | 550 | auto type = fbb.CreateString(bufferType.toStdString()); |
549 | auto location = Akonadi2::Commands::CreateDeleteEntity(fbb, revision, entityId, type, replayToSource); | 551 | auto location = Akonadi2::Commands::CreateDeleteEntity(fbb, revision, entityId, type, replayToSource); |
550 | Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); | 552 | Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); |
551 | callback(QByteArray::fromRawData(reinterpret_cast<char const *>(fbb.GetBufferPointer()), fbb.GetSize())); | 553 | callback(BufferUtils::extractBuffer(fbb)); |
552 | } | 554 | } |
553 | 555 | ||
554 | void GenericResource::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction) | 556 | void GenericResource::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction) |