diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-30 13:43:31 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-30 13:43:31 +0200 |
commit | 01adeefb24bf72f1015e93aa5f075f93f56d94da (patch) | |
tree | ee6d204a47f246688202b4a3a9eb0db23b462f7f /common/genericresource.cpp | |
parent | 07572b25af45c41a82eb8ddfdecf18e58958788b (diff) | |
download | sink-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.cpp | 17 |
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 | ||
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). |