summaryrefslogtreecommitdiffstats
path: root/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dummyresource/resourcefactory.cpp')
-rw-r--r--dummyresource/resourcefactory.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp
index 3180b9a..aefd66f 100644
--- a/dummyresource/resourcefactory.cpp
+++ b/dummyresource/resourcefactory.cpp
@@ -67,15 +67,6 @@ protected:
67 QString mId; 67 QString mId;
68}; 68};
69 69
70// template <typename DomainType>
71// class SimpleReadOnlyProcessor : public SimpleProcessor<DomainType>
72// {
73// public:
74// using SimpleProcessor::SimpleProcessor;
75// void process(Akonadi2::PipelineState state) {
76// mFunction();
77// }
78// };
79 70
80 71
81static std::string createEvent() 72static std::string createEvent()
@@ -123,6 +114,7 @@ public:
123 { 114 {
124 for (auto queue : mCommandQueues) { 115 for (auto queue : mCommandQueues) {
125 bool ret = connect(queue, &MessageQueue::messageReady, this, &Processor::process); 116 bool ret = connect(queue, &MessageQueue::messageReady, this, &Processor::process);
117 Q_UNUSED(ret);
126 Q_ASSERT(ret); 118 Q_ASSERT(ret);
127 } 119 }
128 } 120 }
@@ -184,7 +176,7 @@ private slots:
184 future.setFinished(); 176 future.setFinished();
185 }, 177 },
186 [this, messageQueueCallback, whileCallback](int errorCode, const QString &errorMessage) { 178 [this, messageQueueCallback, whileCallback](int errorCode, const QString &errorMessage) {
187 qDebug() << "Error while creating entity: " << errorCode << errorMessage; 179 qWarning() << "Error while creating entity: " << errorCode << errorMessage;
188 emit error(errorCode, errorMessage); 180 emit error(errorCode, errorMessage);
189 messageQueueCallback(true); 181 messageQueueCallback(true);
190 whileCallback(false); 182 whileCallback(false);
@@ -200,7 +192,6 @@ private slots:
200 } 192 }
201 }, 193 },
202 [whileCallback](const MessageQueue::Error &error) { 194 [whileCallback](const MessageQueue::Error &error) {
203 qDebug() << "no more messages in queue";
204 whileCallback(true); 195 whileCallback(true);
205 }); 196 });
206 }, 197 },
@@ -260,7 +251,7 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
260 //Eventually the order should be self configuring, for now it's hardcoded. 251 //Eventually the order should be self configuring, for now it's hardcoded.
261 auto eventIndexer = new SimpleProcessor("summaryprocessor", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { 252 auto eventIndexer = new SimpleProcessor("summaryprocessor", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) {
262 auto adaptor = eventFactory->createAdaptor(entity); 253 auto adaptor = eventFactory->createAdaptor(entity);
263 qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString(); 254 // qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString();
264 }); 255 });
265 256
266 auto uidIndexer = new SimpleProcessor("uidIndexer", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { 257 auto uidIndexer = new SimpleProcessor("uidIndexer", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) {
@@ -293,7 +284,7 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
293 284
294void DummyResource::onProcessorError(int errorCode, const QString &errorMessage) 285void DummyResource::onProcessorError(int errorCode, const QString &errorMessage)
295{ 286{
296 qDebug() << "Received error from Processor: " << errorCode << errorMessage; 287 qWarning() << "Received error from Processor: " << errorCode << errorMessage;
297 mError = errorCode; 288 mError = errorCode;
298} 289}
299 290
@@ -340,7 +331,6 @@ void DummyResource::enqueueCommand(MessageQueue &mq, int commandId, const QByteA
340 331
341Async::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline) 332Async::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline)
342{ 333{
343 qDebug() << "synchronizeWithSource";
344 return Async::start<void>([this, pipeline](Async::Future<void> &f) { 334 return Async::start<void>([this, pipeline](Async::Future<void> &f) {
345 //TODO use a read-only transaction during the complete sync to sync against a defined revision 335 //TODO use a read-only transaction during the complete sync to sync against a defined revision
346 auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy"); 336 auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy");
@@ -387,7 +377,6 @@ Async::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeli
387 } 377 }
388 } 378 }
389 //TODO find items to remove 379 //TODO find items to remove
390 qDebug() << "sync complete";
391 f.setFinished(); 380 f.setFinished();
392 }); 381 });
393} 382}
@@ -399,9 +388,11 @@ Async::Job<void> DummyResource::processAllMessages()
399 //TODO: report errors while processing sync? 388 //TODO: report errors while processing sync?
400 //TODO: also check user-queue? 389 //TODO: also check user-queue?
401 if (mSynchronizerQueue.isEmpty()) { 390 if (mSynchronizerQueue.isEmpty()) {
391 qDebug() << "synchronizer queue is empty";
402 f.setFinished(); 392 f.setFinished();
403 } else { 393 } else {
404 QObject::connect(&mSynchronizerQueue, &MessageQueue::drained, [&f]() { 394 QObject::connect(&mSynchronizerQueue, &MessageQueue::drained, [&f]() {
395 qDebug() << "synchronizer queue drained";
405 f.setFinished(); 396 f.setFinished();
406 }); 397 });
407 } 398 }
@@ -410,7 +401,6 @@ Async::Job<void> DummyResource::processAllMessages()
410 401
411void DummyResource::processCommand(int commandId, const QByteArray &data, uint size, Akonadi2::Pipeline *pipeline) 402void DummyResource::processCommand(int commandId, const QByteArray &data, uint size, Akonadi2::Pipeline *pipeline)
412{ 403{
413 qDebug() << "processCommand";
414 //TODO instead of copying the command including the full entity first into the command queue, we could directly 404 //TODO instead of copying the command including the full entity first into the command queue, we could directly
415 //create a new revision, only pushing a handle into the commandqueue with the relevant changeset (for changereplay). 405 //create a new revision, only pushing a handle into the commandqueue with the relevant changeset (for changereplay).
416 //The problem is that we then require write access from multiple threads (or even processes to avoid sending the full entity over the wire). 406 //The problem is that we then require write access from multiple threads (or even processes to avoid sending the full entity over the wire).