summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-10-21 14:21:16 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-10-21 14:21:16 +0200
commit12cc3f612c3ebe9522f98c808f9d7115d8e222ce (patch)
tree8dd53dd441d8577b9d72289748a72cf76acd4cca
parent264fb692ccd122e53c7592a26447ed8281179c8b (diff)
downloadsink-12cc3f612c3ebe9522f98c808f9d7115d8e222ce.tar.gz
sink-12cc3f612c3ebe9522f98c808f9d7115d8e222ce.zip
Cleanup
-rw-r--r--common/domainadaptor.h4
-rw-r--r--common/facade.h11
-rw-r--r--common/genericresource.cpp3
-rw-r--r--common/log.cpp2
-rw-r--r--common/pipeline.cpp1
-rw-r--r--common/pipeline.h2
-rw-r--r--common/resource.h12
-rw-r--r--examples/dummyresource/resourcefactory.cpp1
8 files changed, 24 insertions, 12 deletions
diff --git a/common/domainadaptor.h b/common/domainadaptor.h
index 4943cc0..e881b9a 100644
--- a/common/domainadaptor.h
+++ b/common/domainadaptor.h
@@ -173,13 +173,13 @@ public:
173 { 173 {
174 flatbuffers::FlatBufferBuilder localFbb; 174 flatbuffers::FlatBufferBuilder localFbb;
175 if (mLocalWriteMapper) { 175 if (mLocalWriteMapper) {
176 Trace() << "Creating local buffer part"; 176 // Trace() << "Creating local buffer part";
177 createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mLocalWriteMapper); 177 createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mLocalWriteMapper);
178 } 178 }
179 179
180 flatbuffers::FlatBufferBuilder resFbb; 180 flatbuffers::FlatBufferBuilder resFbb;
181 if (mResourceWriteMapper) { 181 if (mResourceWriteMapper) {
182 Trace() << "Creating resouce buffer part"; 182 // Trace() << "Creating resouce buffer part";
183 createBufferPartBuffer<ResourceBuffer, ResourceBuilder>(domainObject, resFbb, *mResourceWriteMapper); 183 createBufferPartBuffer<ResourceBuffer, ResourceBuilder>(domainObject, resFbb, *mResourceWriteMapper);
184 } 184 }
185 185
diff --git a/common/facade.h b/common/facade.h
index 0ddc205..13734f0 100644
--- a/common/facade.h
+++ b/common/facade.h
@@ -271,7 +271,7 @@ public:
271 } 271 }
272 272
273 //We have to capture the runner to keep it alive 273 //We have to capture the runner to keep it alive
274 return synchronizeResource(query.syncOnDemand, query.processAll).template then<void>([runner](KAsync::Future<void> &future) { 274 return synchronizeResource(query).template then<void>([runner](KAsync::Future<void> &future) {
275 runner->run().then<void>([&future]() { 275 runner->run().then<void>([&future]() {
276 future.setFinished(); 276 future.setFinished();
277 }).exec(); 277 }).exec();
@@ -281,19 +281,18 @@ public:
281 }); 281 });
282 } 282 }
283 283
284protected: 284private:
285 KAsync::Job<void> synchronizeResource(bool sync, bool processAll) 285 KAsync::Job<void> synchronizeResource(const Akonadi2::Query &query)
286 { 286 {
287 //TODO check if a sync is necessary 287 //TODO check if a sync is necessary
288 //TODO Only sync what was requested 288 //TODO Only sync what was requested
289 //TODO timeout 289 //TODO timeout
290 if (sync || processAll) { 290 if (query.syncOnDemand || query.processAll) {
291 return mResourceAccess->synchronizeResource(sync, processAll); 291 return mResourceAccess->synchronizeResource(query.syncOnDemand, query.processAll);
292 } 292 }
293 return KAsync::null<void>(); 293 return KAsync::null<void>();
294 } 294 }
295 295
296private:
297 virtual KAsync::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider, qint64 oldRevision) 296 virtual KAsync::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider, qint64 oldRevision)
298 { 297 {
299 return KAsync::start<qint64>([=]() -> qint64 { 298 return KAsync::start<qint64>([=]() -> qint64 {
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index 8ae20ed..dcae43d 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -26,7 +26,7 @@ public:
26 26
27 typedef std::function<KAsync::Job<void>(const QByteArray &type, const QByteArray &key, const QByteArray &value)> ReplayFunction; 27 typedef std::function<KAsync::Job<void>(const QByteArray &type, const QByteArray &key, const QByteArray &value)> ReplayFunction;
28 28
29 ChangeReplay(const QString &resourceName, const ReplayFunction replayFunction) 29 ChangeReplay(const QString &resourceName, const ReplayFunction &replayFunction)
30 : mStorage(storageLocation(), resourceName, Storage::ReadOnly), 30 : mStorage(storageLocation(), resourceName, Storage::ReadOnly),
31 mChangeReplayStore(storageLocation(), resourceName + ".changereplay", Storage::ReadWrite), 31 mChangeReplayStore(storageLocation(), resourceName + ".changereplay", Storage::ReadWrite),
32 mReplayFunction(replayFunction) 32 mReplayFunction(replayFunction)
@@ -224,6 +224,7 @@ private slots:
224 KAsync::Job<void> processPipeline() 224 KAsync::Job<void> processPipeline()
225 { 225 {
226 mPipeline->startTransaction(); 226 mPipeline->startTransaction();
227 Trace() << "Cleaning up from " << mPipeline->cleanedUpRevision() + 1 << " to " << mLowerBoundRevision;
227 for (qint64 revision = mPipeline->cleanedUpRevision() + 1; revision <= mLowerBoundRevision; revision++) { 228 for (qint64 revision = mPipeline->cleanedUpRevision() + 1; revision <= mLowerBoundRevision; revision++) {
228 mPipeline->cleanupRevision(revision); 229 mPipeline->cleanupRevision(revision);
229 } 230 }
diff --git a/common/log.cpp b/common/log.cpp
index 25102dd..c33c700 100644
--- a/common/log.cpp
+++ b/common/log.cpp
@@ -187,7 +187,7 @@ QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* f
187 } 187 }
188 if (showLocation) { 188 if (showLocation) {
189 output += QString(" %3").arg(function); 189 output += QString(" %3").arg(function);
190 /*debug << file << ":" << line */ 190 output += QString("%1:%2").arg(file).arg(line);
191 } 191 }
192 output += ":"; 192 output += ":";
193 193
diff --git a/common/pipeline.cpp b/common/pipeline.cpp
index 9816129..15d2401 100644
--- a/common/pipeline.cpp
+++ b/common/pipeline.cpp
@@ -518,7 +518,6 @@ void PipelineState::step()
518 518
519void PipelineState::processingCompleted(Preprocessor *filter) 519void PipelineState::processingCompleted(Preprocessor *filter)
520{ 520{
521 //TODO record processing progress
522 if (d->pipeline && filter == d->filterIt.peekPrevious()) { 521 if (d->pipeline && filter == d->filterIt.peekPrevious()) {
523 d->idle = true; 522 d->idle = true;
524 d->pipeline->pipelineStepped(*this); 523 d->pipeline->pipelineStepped(*this);
diff --git a/common/pipeline.h b/common/pipeline.h
index 837c18a..c8d9ddc 100644
--- a/common/pipeline.h
+++ b/common/pipeline.h
@@ -164,7 +164,7 @@ public:
164 }); 164 });
165 } 165 }
166 166
167 QString id() const 167 QString id() const Q_DECL_OVERRIDE
168 { 168 {
169 return mId; 169 return mId;
170 } 170 }
diff --git a/common/resource.h b/common/resource.h
index 33805ca..4ed21b5 100644
--- a/common/resource.h
+++ b/common/resource.h
@@ -37,8 +37,20 @@ public:
37 virtual ~Resource(); 37 virtual ~Resource();
38 38
39 virtual void processCommand(int commandId, const QByteArray &data); 39 virtual void processCommand(int commandId, const QByteArray &data);
40
41 /**
42 * Execute synchronization with the source.
43 */
40 virtual KAsync::Job<void> synchronizeWithSource(); 44 virtual KAsync::Job<void> synchronizeWithSource();
45
46 /**
47 * Process all internal messages, thus ensuring the store is up to date and no pending modifications are left.
48 */
41 virtual KAsync::Job<void> processAllMessages(); 49 virtual KAsync::Job<void> processAllMessages();
50
51 /**
52 * Set the lowest revision that is still referenced by external clients.
53 */
42 virtual void setLowerBoundRevision(qint64 revision); 54 virtual void setLowerBoundRevision(qint64 revision);
43 55
44Q_SIGNALS: 56Q_SIGNALS:
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index 0e4c3af..8e6bd42 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -154,6 +154,7 @@ void DummyResource::synchronize(const QString &bufferType, const QMap<QString, Q
154 154
155KAsync::Job<void> DummyResource::synchronizeWithSource() 155KAsync::Job<void> DummyResource::synchronizeWithSource()
156{ 156{
157 Log() << " Synchronizing";
157 return KAsync::start<void>([this](KAsync::Future<void> &f) { 158 return KAsync::start<void>([this](KAsync::Future<void> &f) {
158 auto transaction = Akonadi2::Storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly).createTransaction(Akonadi2::Storage::ReadOnly); 159 auto transaction = Akonadi2::Storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly).createTransaction(Akonadi2::Storage::ReadOnly);
159 160