diff options
-rw-r--r-- | common/genericresource.cpp | 17 | ||||
-rw-r--r-- | common/genericresource.h | 9 | ||||
-rw-r--r-- | common/listener.cpp | 8 | ||||
-rw-r--r-- | common/listener.h | 1 | ||||
-rw-r--r-- | common/resource.cpp | 15 | ||||
-rw-r--r-- | common/resource.h | 8 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 17 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.h | 5 | ||||
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 11 | ||||
-rw-r--r-- | tests/dummyresourcetest.cpp | 8 | ||||
-rw-r--r-- | tests/genericresourcetest.cpp | 22 |
11 files changed, 46 insertions, 75 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 99d1aaa..4dd73b3 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -152,26 +152,21 @@ private: | |||
152 | }; | 152 | }; |
153 | 153 | ||
154 | 154 | ||
155 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier) | 155 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) |
156 | : Akonadi2::Resource(), | 156 | : Akonadi2::Resource(), |
157 | mUserQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".userqueue"), | 157 | mUserQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".userqueue"), |
158 | mSynchronizerQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".synchronizerqueue"), | 158 | mSynchronizerQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".synchronizerqueue"), |
159 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | 159 | mResourceInstanceIdentifier(resourceInstanceIdentifier), |
160 | mPipeline(pipeline ? pipeline : QSharedPointer<Akonadi2::Pipeline>::create(resourceInstanceIdentifier)), | ||
160 | mError(0) | 161 | mError(0) |
161 | { | 162 | { |
163 | mProcessor = new Processor(mPipeline.data(), QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue); | ||
164 | QObject::connect(mProcessor, &Processor::error, [this](int errorCode, const QString &msg) { onProcessorError(errorCode, msg); }); | ||
165 | QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); | ||
162 | } | 166 | } |
163 | 167 | ||
164 | GenericResource::~GenericResource() | 168 | GenericResource::~GenericResource() |
165 | { | 169 | { |
166 | |||
167 | } | ||
168 | |||
169 | void GenericResource::configurePipeline(Akonadi2::Pipeline *pipeline) | ||
170 | { | ||
171 | //TODO figure out lifetime of the processor | ||
172 | mProcessor = new Processor(pipeline, QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue); | ||
173 | QObject::connect(mProcessor, &Processor::error, [this](int errorCode, const QString &msg) { onProcessorError(errorCode, msg); }); | ||
174 | QObject::connect(pipeline, &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); | ||
175 | } | 170 | } |
176 | 171 | ||
177 | void GenericResource::onProcessorError(int errorCode, const QString &errorMessage) | 172 | void GenericResource::onProcessorError(int errorCode, const QString &errorMessage) |
@@ -195,7 +190,7 @@ void GenericResource::enqueueCommand(MessageQueue &mq, int commandId, const QByt | |||
195 | mq.enqueue(m_fbb.GetBufferPointer(), m_fbb.GetSize()); | 190 | mq.enqueue(m_fbb.GetBufferPointer(), m_fbb.GetSize()); |
196 | } | 191 | } |
197 | 192 | ||
198 | void GenericResource::processCommand(int commandId, const QByteArray &data, Akonadi2::Pipeline *pipeline) | 193 | void GenericResource::processCommand(int commandId, const QByteArray &data) |
199 | { | 194 | { |
200 | //TODO instead of copying the command including the full entity first into the command queue, we could directly | 195 | //TODO instead of copying the command including the full entity first into the command queue, we could directly |
201 | //create a new revision, only pushing a handle into the commandqueue with the relevant changeset (for changereplay). | 196 | //create a new revision, only pushing a handle into the commandqueue with the relevant changeset (for changereplay). |
diff --git a/common/genericresource.h b/common/genericresource.h index e9d5d59..4a285ea 100644 --- a/common/genericresource.h +++ b/common/genericresource.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <akonadi2common_export.h> | 22 | #include <akonadi2common_export.h> |
23 | #include <resource.h> | 23 | #include <resource.h> |
24 | #include <messagequeue.h> | 24 | #include <messagequeue.h> |
25 | #include <flatbuffers/flatbuffers.h> | ||
25 | 26 | ||
26 | class Processor; | 27 | class Processor; |
27 | 28 | ||
@@ -34,14 +35,13 @@ namespace Akonadi2 | |||
34 | class AKONADI2COMMON_EXPORT GenericResource : public Resource | 35 | class AKONADI2COMMON_EXPORT GenericResource : public Resource |
35 | { | 36 | { |
36 | public: | 37 | public: |
37 | GenericResource(const QByteArray &resourceInstanceIdentifier); | 38 | GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline = QSharedPointer<Pipeline>()); |
38 | virtual ~GenericResource(); | 39 | virtual ~GenericResource(); |
39 | 40 | ||
40 | virtual void processCommand(int commandId, const QByteArray &data, Pipeline *pipeline) Q_DECL_OVERRIDE; | 41 | virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE; |
41 | virtual KAsync::Job<void> synchronizeWithSource(Pipeline *pipeline) Q_DECL_OVERRIDE = 0; | 42 | virtual KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE = 0; |
42 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; | 43 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; |
43 | 44 | ||
44 | virtual void configurePipeline(Pipeline *pipeline) Q_DECL_OVERRIDE; | ||
45 | int error() const; | 45 | int error() const; |
46 | 46 | ||
47 | protected: | 47 | protected: |
@@ -51,6 +51,7 @@ protected: | |||
51 | MessageQueue mUserQueue; | 51 | MessageQueue mUserQueue; |
52 | MessageQueue mSynchronizerQueue; | 52 | MessageQueue mSynchronizerQueue; |
53 | QByteArray mResourceInstanceIdentifier; | 53 | QByteArray mResourceInstanceIdentifier; |
54 | QSharedPointer<Pipeline> mPipeline; | ||
54 | 55 | ||
55 | private: | 56 | private: |
56 | Processor *mProcessor; | 57 | Processor *mProcessor; |
diff --git a/common/listener.cpp b/common/listener.cpp index 2e2e98e..8ec9b3e 100644 --- a/common/listener.cpp +++ b/common/listener.cpp | |||
@@ -41,7 +41,6 @@ Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent | |||
41 | m_resourceName(Akonadi2::Store::resourceName(resourceInstanceIdentifier)), | 41 | m_resourceName(Akonadi2::Store::resourceName(resourceInstanceIdentifier)), |
42 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), | 42 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), |
43 | m_resource(0), | 43 | m_resource(0), |
44 | m_pipeline(new Akonadi2::Pipeline(resourceInstanceIdentifier, parent)), | ||
45 | m_clientBufferProcessesTimer(new QTimer(this)), | 44 | m_clientBufferProcessesTimer(new QTimer(this)), |
46 | m_messageId(0) | 45 | m_messageId(0) |
47 | { | 46 | { |
@@ -226,7 +225,7 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
226 | } | 225 | } |
227 | auto job = KAsync::null<void>(); | 226 | auto job = KAsync::null<void>(); |
228 | if (buffer->sourceSync()) { | 227 | if (buffer->sourceSync()) { |
229 | job = m_resource->synchronizeWithSource(m_pipeline); | 228 | job = m_resource->synchronizeWithSource(); |
230 | } | 229 | } |
231 | if (buffer->localSync()) { | 230 | if (buffer->localSync()) { |
232 | job = job.then<void>(m_resource->processAllMessages()); | 231 | job = job.then<void>(m_resource->processAllMessages()); |
@@ -247,7 +246,7 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
247 | Log() << "\tCommand id " << messageId << " of type \"" << Akonadi2::Commands::name(commandId) << "\" from " << client.name; | 246 | Log() << "\tCommand id " << messageId << " of type \"" << Akonadi2::Commands::name(commandId) << "\" from " << client.name; |
248 | loadResource(); | 247 | loadResource(); |
249 | if (m_resource) { | 248 | if (m_resource) { |
250 | m_resource->processCommand(commandId, commandBuffer, m_pipeline); | 249 | m_resource->processCommand(commandId, commandBuffer); |
251 | } | 250 | } |
252 | break; | 251 | break; |
253 | case Akonadi2::Commands::ShutdownCommand: | 252 | case Akonadi2::Commands::ShutdownCommand: |
@@ -261,7 +260,7 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
261 | Log() << QString("\tReceived custom command from %1: ").arg(client.name) << commandId; | 260 | Log() << QString("\tReceived custom command from %1: ").arg(client.name) << commandId; |
262 | loadResource(); | 261 | loadResource(); |
263 | if (m_resource) { | 262 | if (m_resource) { |
264 | m_resource->processCommand(commandId, commandBuffer, m_pipeline); | 263 | m_resource->processCommand(commandId, commandBuffer); |
265 | } | 264 | } |
266 | } else { | 265 | } else { |
267 | Warning() << QString("\tReceived invalid command from %1: ").arg(client.name) << commandId; | 266 | Warning() << QString("\tReceived invalid command from %1: ").arg(client.name) << commandId; |
@@ -367,7 +366,6 @@ void Listener::loadResource() | |||
367 | m_resource = resourceFactory->createResource(m_resourceInstanceIdentifier); | 366 | m_resource = resourceFactory->createResource(m_resourceInstanceIdentifier); |
368 | Log() << QString("Resource factory: %1").arg((qlonglong)resourceFactory); | 367 | Log() << QString("Resource factory: %1").arg((qlonglong)resourceFactory); |
369 | Log() << QString("\tResource: %1").arg((qlonglong)m_resource); | 368 | Log() << QString("\tResource: %1").arg((qlonglong)m_resource); |
370 | m_resource->configurePipeline(m_pipeline); | ||
371 | connect(m_resource, &Akonadi2::Resource::revisionUpdated, | 369 | connect(m_resource, &Akonadi2::Resource::revisionUpdated, |
372 | this, &Listener::refreshRevision); | 370 | this, &Listener::refreshRevision); |
373 | } else { | 371 | } else { |
diff --git a/common/listener.h b/common/listener.h index 649c3ed..0d19823 100644 --- a/common/listener.h +++ b/common/listener.h | |||
@@ -92,7 +92,6 @@ private: | |||
92 | const QByteArray m_resourceName; | 92 | const QByteArray m_resourceName; |
93 | const QByteArray m_resourceInstanceIdentifier; | 93 | const QByteArray m_resourceInstanceIdentifier; |
94 | Akonadi2::Resource *m_resource; | 94 | Akonadi2::Resource *m_resource; |
95 | Akonadi2::Pipeline *m_pipeline; | ||
96 | QTimer *m_clientBufferProcessesTimer; | 95 | QTimer *m_clientBufferProcessesTimer; |
97 | QTimer *m_checkConnectionsTimer; | 96 | QTimer *m_checkConnectionsTimer; |
98 | int m_messageId; | 97 | int m_messageId; |
diff --git a/common/resource.cpp b/common/resource.cpp index 68a237c..2a86df5 100644 --- a/common/resource.cpp +++ b/common/resource.cpp | |||
@@ -40,24 +40,15 @@ Resource::~Resource() | |||
40 | //delete d; | 40 | //delete d; |
41 | } | 41 | } |
42 | 42 | ||
43 | void Resource::configurePipeline(Pipeline *pipeline) | 43 | void Resource::processCommand(int commandId, const QByteArray &data) |
44 | { | ||
45 | |||
46 | } | ||
47 | |||
48 | void Resource::processCommand(int commandId, const QByteArray &data, Pipeline *pipeline) | ||
49 | { | 44 | { |
50 | Q_UNUSED(commandId) | 45 | Q_UNUSED(commandId) |
51 | Q_UNUSED(data) | 46 | Q_UNUSED(data) |
52 | Q_UNUSED(pipeline) | ||
53 | pipeline->null(); | ||
54 | } | 47 | } |
55 | 48 | ||
56 | KAsync::Job<void> Resource::synchronizeWithSource(Pipeline *pipeline) | 49 | KAsync::Job<void> Resource::synchronizeWithSource() |
57 | { | 50 | { |
58 | return KAsync::start<void>([pipeline](KAsync::Future<void> &f) { | 51 | return KAsync::null<void>(); |
59 | pipeline->null(); | ||
60 | }); | ||
61 | } | 52 | } |
62 | 53 | ||
63 | KAsync::Job<void> Resource::processAllMessages() | 54 | KAsync::Job<void> Resource::processAllMessages() |
diff --git a/common/resource.h b/common/resource.h index 9f657f7..a51e12d 100644 --- a/common/resource.h +++ b/common/resource.h | |||
@@ -20,12 +20,12 @@ | |||
20 | 20 | ||
21 | #include <akonadi2common_export.h> | 21 | #include <akonadi2common_export.h> |
22 | #include <clientapi.h> | 22 | #include <clientapi.h> |
23 | #include <pipeline.h> | ||
24 | 23 | ||
25 | #include <Async/Async> | 24 | #include <Async/Async> |
26 | 25 | ||
27 | namespace Akonadi2 | 26 | namespace Akonadi2 |
28 | { | 27 | { |
28 | class Pipeline; | ||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Resource interface | 31 | * Resource interface |
@@ -37,12 +37,10 @@ public: | |||
37 | Resource(); | 37 | Resource(); |
38 | virtual ~Resource(); | 38 | virtual ~Resource(); |
39 | 39 | ||
40 | virtual void processCommand(int commandId, const QByteArray &data, Pipeline *pipeline); | 40 | virtual void processCommand(int commandId, const QByteArray &data); |
41 | virtual KAsync::Job<void> synchronizeWithSource(Pipeline *pipeline); | 41 | virtual KAsync::Job<void> synchronizeWithSource(); |
42 | virtual KAsync::Job<void> processAllMessages(); | 42 | virtual KAsync::Job<void> processAllMessages(); |
43 | 43 | ||
44 | virtual void configurePipeline(Pipeline *pipeline); | ||
45 | |||
46 | Q_SIGNALS: | 44 | Q_SIGNALS: |
47 | void revisionUpdated(qint64); | 45 | void revisionUpdated(qint64); |
48 | 46 | ||
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index c7a3eef..e9bf6cd 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -35,12 +35,8 @@ | |||
35 | //This is the resources entity type, and not the domain type | 35 | //This is the resources entity type, and not the domain type |
36 | #define ENTITY_TYPE_EVENT "event" | 36 | #define ENTITY_TYPE_EVENT "event" |
37 | 37 | ||
38 | DummyResource::DummyResource(const QByteArray &instanceIdentifier) | 38 | DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline) |
39 | : Akonadi2::GenericResource(instanceIdentifier) | 39 | : Akonadi2::GenericResource(instanceIdentifier, pipeline) |
40 | { | ||
41 | } | ||
42 | |||
43 | void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) | ||
44 | { | 40 | { |
45 | auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create(); | 41 | auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create(); |
46 | const auto resourceIdentifier = mResourceInstanceIdentifier; | 42 | const auto resourceIdentifier = mResourceInstanceIdentifier; |
@@ -57,15 +53,14 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) | |||
57 | } | 53 | } |
58 | }); | 54 | }); |
59 | 55 | ||
60 | pipeline->setPreprocessors(ENTITY_TYPE_EVENT, Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer); | 56 | mPipeline->setPreprocessors(ENTITY_TYPE_EVENT, Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer); |
61 | pipeline->setAdaptorFactory(ENTITY_TYPE_EVENT, eventFactory); | 57 | mPipeline->setAdaptorFactory(ENTITY_TYPE_EVENT, eventFactory); |
62 | //TODO cleanup indexes during removal | 58 | //TODO cleanup indexes during removal |
63 | GenericResource::configurePipeline(pipeline); | ||
64 | } | 59 | } |
65 | 60 | ||
66 | KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline) | 61 | KAsync::Job<void> DummyResource::synchronizeWithSource() |
67 | { | 62 | { |
68 | return KAsync::start<void>([this, pipeline](KAsync::Future<void> &f) { | 63 | return KAsync::start<void>([this](KAsync::Future<void> &f) { |
69 | //TODO start transaction on index | 64 | //TODO start transaction on index |
70 | Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); | 65 | Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); |
71 | 66 | ||
diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index f2362bc..4baafa7 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h | |||
@@ -32,9 +32,8 @@ | |||
32 | class DummyResource : public Akonadi2::GenericResource | 32 | class DummyResource : public Akonadi2::GenericResource |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | DummyResource(const QByteArray &instanceIdentifier); | 35 | DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); |
36 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE; | 36 | KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE; |
37 | void configurePipeline(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE; | ||
38 | }; | 37 | }; |
39 | 38 | ||
40 | class DummyResourceFactory : public Akonadi2::ResourceFactory | 39 | class DummyResourceFactory : public Akonadi2::ResourceFactory |
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index 7d40779..4c649a9 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -8,11 +8,13 @@ | |||
8 | #include "commands.h" | 8 | #include "commands.h" |
9 | #include "entitybuffer.h" | 9 | #include "entitybuffer.h" |
10 | #include "synclistresult.h" | 10 | #include "synclistresult.h" |
11 | #include "pipeline.h" | ||
11 | 12 | ||
12 | #include "event_generated.h" | 13 | #include "event_generated.h" |
13 | #include "entity_generated.h" | 14 | #include "entity_generated.h" |
14 | #include "metadata_generated.h" | 15 | #include "metadata_generated.h" |
15 | #include "createentity_generated.h" | 16 | #include "createentity_generated.h" |
17 | |||
16 | #include <iostream> | 18 | #include <iostream> |
17 | 19 | ||
18 | static void removeFromDisk(const QString &name) | 20 | static void removeFromDisk(const QString &name) |
@@ -94,10 +96,9 @@ private Q_SLOTS: | |||
94 | time.start(); | 96 | time.start(); |
95 | int num = 10000; | 97 | int num = 10000; |
96 | 98 | ||
97 | Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); | 99 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); |
98 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); | 100 | QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated())); |
99 | DummyResource resource("org.kde.dummy.instance1"); | 101 | DummyResource resource("org.kde.dummy.instance1", pipeline); |
100 | resource.configurePipeline(&pipeline); | ||
101 | 102 | ||
102 | flatbuffers::FlatBufferBuilder eventFbb; | 103 | flatbuffers::FlatBufferBuilder eventFbb; |
103 | eventFbb.Clear(); | 104 | eventFbb.Clear(); |
@@ -133,7 +134,7 @@ private Q_SLOTS: | |||
133 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 134 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
134 | 135 | ||
135 | for (int i = 0; i < num; i++) { | 136 | for (int i = 0; i < num; i++) { |
136 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); | 137 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); |
137 | } | 138 | } |
138 | auto appendTime = time.elapsed(); | 139 | auto appendTime = time.elapsed(); |
139 | 140 | ||
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 10cd7e3..1a4d6ca 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "commands.h" | 12 | #include "commands.h" |
13 | #include "entitybuffer.h" | 13 | #include "entitybuffer.h" |
14 | #include "resourceconfig.h" | 14 | #include "resourceconfig.h" |
15 | #include "pipeline.h" | ||
15 | 16 | ||
16 | static void removeFromDisk(const QString &name) | 17 | static void removeFromDisk(const QString &name) |
17 | { | 18 | { |
@@ -133,10 +134,9 @@ private Q_SLOTS: | |||
133 | 134 | ||
134 | void testResourceSync() | 135 | void testResourceSync() |
135 | { | 136 | { |
136 | Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); | 137 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); |
137 | DummyResource resource("org.kde.dummy.instance1"); | 138 | DummyResource resource("org.kde.dummy.instance1", pipeline); |
138 | resource.configurePipeline(&pipeline); | 139 | auto job = resource.synchronizeWithSource(); |
139 | auto job = resource.synchronizeWithSource(&pipeline); | ||
140 | //TODO pass in optional timeout? | 140 | //TODO pass in optional timeout? |
141 | auto future = job.exec(); | 141 | auto future = job.exec(); |
142 | future.waitForFinished(); | 142 | future.waitForFinished(); |
diff --git a/tests/genericresourcetest.cpp b/tests/genericresourcetest.cpp index 0b9a5c1..b6f629a 100644 --- a/tests/genericresourcetest.cpp +++ b/tests/genericresourcetest.cpp | |||
@@ -14,20 +14,15 @@ | |||
14 | class TestResource : public Akonadi2::GenericResource | 14 | class TestResource : public Akonadi2::GenericResource |
15 | { | 15 | { |
16 | public: | 16 | public: |
17 | TestResource(const QByteArray &instanceIdentifier) | 17 | TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Akonadi2::Pipeline> pipeline) |
18 | : Akonadi2::GenericResource(instanceIdentifier) | 18 | : Akonadi2::GenericResource(instanceIdentifier, pipeline) |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE | 22 | KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE |
23 | { | 23 | { |
24 | return KAsync::null<void>(); | 24 | return KAsync::null<void>(); |
25 | } | 25 | } |
26 | |||
27 | void configurePipeline(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE | ||
28 | { | ||
29 | GenericResource::configurePipeline(pipeline); | ||
30 | } | ||
31 | }; | 26 | }; |
32 | 27 | ||
33 | 28 | ||
@@ -89,12 +84,11 @@ private Q_SLOTS: | |||
89 | } | 84 | } |
90 | 85 | ||
91 | //Actual test | 86 | //Actual test |
92 | Akonadi2::Pipeline pipeline("org.kde.test.instance1"); | 87 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); |
93 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated(qint64))); | 88 | QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated(qint64))); |
94 | TestResource resource("org.kde.test.instance1"); | 89 | TestResource resource("org.kde.test.instance1", pipeline); |
95 | resource.configurePipeline(&pipeline); | 90 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); |
96 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); | 91 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); |
97 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); | ||
98 | 92 | ||
99 | QVERIFY(revisionSpy.isValid()); | 93 | QVERIFY(revisionSpy.isValid()); |
100 | QTRY_COMPARE(revisionSpy.count(), 2); | 94 | QTRY_COMPARE(revisionSpy.count(), 2); |