summaryrefslogtreecommitdiffstats
path: root/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-01-24 23:38:12 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-01-24 23:38:12 +0100
commit9b744da32e64d8a6cd342faba8fc3232884d60f2 (patch)
treea22558b6c869ba777292d3ce231222408614d5b3 /dummyresource/resourcefactory.cpp
parentb36ae2d0e0b0ee9865fdc7e628374853d160b55a (diff)
downloadsink-9b744da32e64d8a6cd342faba8fc3232884d60f2.tar.gz
sink-9b744da32e64d8a6cd342faba8fc3232884d60f2.zip
Uid index + query using that index.
...and a couple of other fixes.
Diffstat (limited to 'dummyresource/resourcefactory.cpp')
-rw-r--r--dummyresource/resourcefactory.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp
index 60a9cf6..18083cb 100644
--- a/dummyresource/resourcefactory.cpp
+++ b/dummyresource/resourcefactory.cpp
@@ -28,6 +28,7 @@
28#include "domainadaptor.h" 28#include "domainadaptor.h"
29#include "commands.h" 29#include "commands.h"
30#include "clientapi.h" 30#include "clientapi.h"
31#include "index.h"
31#include <QUuid> 32#include <QUuid>
32#include <assert.h> 33#include <assert.h>
33 34
@@ -261,8 +262,31 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
261 auto adaptor = eventFactory->createAdaptor(entity); 262 auto adaptor = eventFactory->createAdaptor(entity);
262 qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString(); 263 qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString();
263 }); 264 });
265
266 auto uidIndexer = new SimpleProcessor("uidIndexer", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) {
267 static Index uidIndex(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", "org.kde.dummy.index.uid", Akonadi2::Storage::ReadWrite);
268
269 auto adaptor = eventFactory->createAdaptor(entity);
270 const auto uid = adaptor->getProperty("uid");
271 if (uid.isValid()) {
272 uidIndex.add(uid.toByteArray(), state.key());
273 }
274
275 //TODO would this be worthwhile for performance reasons?
276 // flatbuffers::Verifier verifyer(entity.local()->Data(), entity.local()->size());
277 // if (!Akonadi2::Domain::Buffer::VerifyEventBuffer(verifyer)) {
278 // qWarning() << "invalid local buffer";
279 // return;
280 // }
281 // auto localEvent = Akonadi2::Domain::Buffer::GetEvent(entity.local()->Data());
282 // if (localEvent && localEvent->uid()) {
283 // qDebug() << "got uid: " << QByteArray::fromRawData(reinterpret_cast<const char *>(localEvent->uid()->Data()), localEvent->uid()->size());
284 // uidIndex.add(QByteArray::fromRawData(reinterpret_cast<const char *>(localEvent->uid()->Data()), localEvent->uid()->size()), state.key());
285 // }
286 });
287
264 //event is the entitytype and not the domain type 288 //event is the entitytype and not the domain type
265 pipeline->setPreprocessors("event", Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer); 289 pipeline->setPreprocessors("event", Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer << uidIndexer);
266 mProcessor = new Processor(pipeline, QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue); 290 mProcessor = new Processor(pipeline, QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue);
267 QObject::connect(mProcessor, &Processor::error, [this](int errorCode, const QString &msg) { onProcessorError(errorCode, msg); }); 291 QObject::connect(mProcessor, &Processor::error, [this](int errorCode, const QString &msg) { onProcessorError(errorCode, msg); });
268} 292}