summaryrefslogtreecommitdiffstats
path: root/common/genericresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-30 13:43:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-30 13:43:31 +0200
commit01adeefb24bf72f1015e93aa5f075f93f56d94da (patch)
treeee6d204a47f246688202b4a3a9eb0db23b462f7f /common/genericresource.cpp
parent07572b25af45c41a82eb8ddfdecf18e58958788b (diff)
downloadsink-01adeefb24bf72f1015e93aa5f075f93f56d94da.tar.gz
sink-01adeefb24bf72f1015e93aa5f075f93f56d94da.zip
Made the pipeline an implementation detail of the resource.
This removes one dependency from the Listener and will allow us to test the Listener better.
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r--common/genericresource.cpp17
1 files changed, 6 insertions, 11 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
155GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier) 155GenericResource::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
164GenericResource::~GenericResource() 168GenericResource::~GenericResource()
165{ 169{
166
167}
168
169void 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
177void GenericResource::onProcessorError(int errorCode, const QString &errorMessage) 172void 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
198void GenericResource::processCommand(int commandId, const QByteArray &data, Akonadi2::Pipeline *pipeline) 193void 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).