Branch 'kolab/integration/4.13.0' - 3 commits - akonadi/resourcebase.cpp akonadi/resourcebase.h
Christian Mollekopf
mollekopf at kolabsys.com
Sun Oct 19 19:23:07 CEST 2014
akonadi/resourcebase.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++--
akonadi/resourcebase.h | 18 +++++++++++++
2 files changed, 79 insertions(+), 2 deletions(-)
New commits:
commit 5dac316d7180a086ef209969fb13233ef7896646
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Sat Oct 18 16:09:21 2014 +0200
ResourceBase: allow inserting an attribute sync before every sync.
diff --git a/akonadi/resourcebase.cpp b/akonadi/resourcebase.cpp
index ab65c3a..5b10981 100644
--- a/akonadi/resourcebase.cpp
+++ b/akonadi/resourcebase.cpp
@@ -84,6 +84,7 @@ public:
, mDisableAutomaticItemDeliveryDone(false)
, mItemSyncBatchSize(10)
, mCurrentCollectionFetchJob(0)
+ , mScheduleAttributeSyncBeforeCollectionSync(false)
{
Internal::setClientType(Internal::Resource);
mStatusMessage = defaultReadyMessage();
@@ -455,6 +456,7 @@ public:
int mItemSyncBatchSize;
QSet<QByteArray> mKeepLocalCollectionChanges;
KJob *mCurrentCollectionFetchJob;
+ bool mScheduleAttributeSyncBeforeCollectionSync;
};
ResourceBase::ResourceBase(const QString &id)
@@ -946,6 +948,12 @@ void ResourceBase::setItemSyncBatchSize(int batchSize)
d->mItemSyncBatchSize = batchSize;
}
+void ResourceBase::setScheduleAttributeSyncBeforeItemSync(bool enable)
+{
+ Q_D(ResourceBase);
+ d->mScheduleAttributeSyncBeforeCollectionSync = enable;
+}
+
void ResourceBasePrivate::slotSynchronizeCollectionAttributes(const Collection &col)
{
Q_Q(ResourceBase);
@@ -1161,6 +1169,9 @@ void ResourceBasePrivate::slotCollectionListDone(KJob *job)
Q_FOREACH (const Collection &collection, list) {
//We also get collections that should not be synced but are part of the tree.
if (collection.shouldList(Collection::ListSync) || collection.referenced()) {
+ if (mScheduleAttributeSyncBeforeCollectionSync) {
+ scheduler->scheduleAttributesSync(collection);
+ }
scheduler->scheduleSync(collection);
}
}
diff --git a/akonadi/resourcebase.h b/akonadi/resourcebase.h
index a9926f6..40bda13 100644
--- a/akonadi/resourcebase.h
+++ b/akonadi/resourcebase.h
@@ -325,6 +325,14 @@ protected Q_SLOTS:
void setItemSyncBatchSize(int batchSize);
/**
+ * Set to true to scheudle an attribute sync before every item sync.
+ * The default is false.
+ *
+ * @since 4.15
+ */
+ void setScheduleAttributeSyncBeforeItemSync(bool);
+
+ /**
* Retrieve a single item from the backend. The item to retrieve is provided as @p item.
* Add the requested payload parts and call itemRetrieved() when done.
* @param item The empty item whose payload should be retrieved. Use this object when delivering
commit db01cec05cb0b9a90bf86531dfb109ddc25a40f2
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Sat Oct 18 16:08:53 2014 +0200
ResourceBase: Allow to directly append a task without waiting for a collectionfetch.
diff --git a/akonadi/resourcebase.cpp b/akonadi/resourcebase.cpp
index e696687..ab65c3a 100644
--- a/akonadi/resourcebase.cpp
+++ b/akonadi/resourcebase.cpp
@@ -1169,6 +1169,12 @@ void ResourceBasePrivate::slotCollectionListDone(KJob *job)
}
}
+void ResourceBase::synchronizeCollectionAttributes(const Akonadi::Collection &col)
+{
+ Q_D(ResourceBase);
+ d->scheduler->scheduleAttributesSync(col);
+}
+
void ResourceBase::synchronizeCollectionAttributes(qint64 collectionId)
{
CollectionFetchJob *job = new CollectionFetchJob(Collection(collectionId), CollectionFetchJob::Base);
diff --git a/akonadi/resourcebase.h b/akonadi/resourcebase.h
index 790767f..a9926f6 100644
--- a/akonadi/resourcebase.h
+++ b/akonadi/resourcebase.h
@@ -634,6 +634,14 @@ protected:
void synchronizeCollectionAttributes(qint64 id);
/**
+ * Synchronizes the collection attributes.
+ *
+ * @param col The id of the collection to synchronize
+ * @since 4.15
+ */
+ void synchronizeCollectionAttributes(const Akonadi::Collection &col);
+
+ /**
* Refetches the Collections.
*/
void synchronizeCollectionTree();
commit 02e871392d5ded461934bea4b25c1137ca944c34
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Sat Oct 18 15:32:19 2014 +0200
ResourceBase: fetch collections again before item sync and attribute sync.
Otherwise we potentially use outdated attributes during the sync.
diff --git a/akonadi/resourcebase.cpp b/akonadi/resourcebase.cpp
index 5568560..e696687 100644
--- a/akonadi/resourcebase.cpp
+++ b/akonadi/resourcebase.cpp
@@ -83,6 +83,7 @@ public:
, mAutomaticProgressReporting(true)
, mDisableAutomaticItemDeliveryDone(false)
, mItemSyncBatchSize(10)
+ , mCurrentCollectionFetchJob(0)
{
Internal::setClientType(Internal::Resource);
mStatusMessage = defaultReadyMessage();
@@ -139,11 +140,13 @@ public:
void slotCollectionSyncDone(KJob *job);
void slotLocalListDone(KJob *job);
void slotSynchronizeCollection(const Collection &col);
+ void slotItemRetrievalCollectionFetchDone(KJob *job);
void slotCollectionListDone(KJob *job);
void slotSynchronizeCollectionAttributes(const Collection &col);
void slotCollectionListForAttributesDone(KJob *job);
void slotCollectionAttributesSyncDone(KJob *job);
void slotSynchronizeTags();
+ void slotAttributeRetrievalCollectionFetchDone(KJob *job);
void slotItemSyncDone(KJob *job);
@@ -451,6 +454,7 @@ public:
QPointer<RecursiveMover> m_recursiveMover;
int mItemSyncBatchSize;
QSet<QByteArray> mKeepLocalCollectionChanges;
+ KJob *mCurrentCollectionFetchJob;
};
ResourceBase::ResourceBase(const QString &id)
@@ -906,13 +910,30 @@ void ResourceBasePrivate::slotSynchronizeCollection(const Collection &col)
if (mAutomaticProgressReporting) {
emit q->status(AgentBase::Running, i18nc("@info:status", "Syncing folder '%1'", currentCollection.displayName()));
}
- q->retrieveItems(currentCollection);
+
+ Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(col, CollectionFetchJob::Base, this);
+ fetchJob->setFetchScope(q->changeRecorder()->collectionFetchScope());
+ connect(fetchJob, SIGNAL(result(KJob*)), q, SLOT(slotItemRetrievalCollectionFetchDone(KJob*)));
+ mCurrentCollectionFetchJob = fetchJob;
return;
}
}
scheduler->taskDone();
}
+void ResourceBasePrivate::slotItemRetrievalCollectionFetchDone(KJob *job)
+{
+ Q_Q(ResourceBase);
+ mCurrentCollectionFetchJob = 0;
+ if (job->error()) {
+ kWarning() << "Failed to retrieve collection for sync: " << job->errorString();
+ q->cancelTask(i18n("Failed to retrieve collection for sync."));
+ return;
+ }
+ Akonadi::CollectionFetchJob *fetchJob = static_cast<Akonadi::CollectionFetchJob*>(job);
+ q->retrieveItems(fetchJob->collections().first());
+}
+
int ResourceBase::itemSyncBatchSize() const
{
Q_D(const ResourceBase);
@@ -928,7 +949,24 @@ void ResourceBase::setItemSyncBatchSize(int batchSize)
void ResourceBasePrivate::slotSynchronizeCollectionAttributes(const Collection &col)
{
Q_Q(ResourceBase);
- QMetaObject::invokeMethod(q, "retrieveCollectionAttributes", Q_ARG(Akonadi::Collection, col));
+ Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(col, CollectionFetchJob::Base, this);
+ fetchJob->setFetchScope(q->changeRecorder()->collectionFetchScope());
+ connect(fetchJob, SIGNAL(result(KJob*)), q, SLOT(slotAttributeRetrievalCollectionFetchDone(KJob*)));
+ Q_ASSERT(!mCurrentCollectionFetchJob);
+ mCurrentCollectionFetchJob = fetchJob;
+}
+
+void ResourceBasePrivate::slotAttributeRetrievalCollectionFetchDone(KJob *job)
+{
+ mCurrentCollectionFetchJob = 0;
+ Q_Q(ResourceBase);
+ if (job->error()) {
+ kWarning() << "Failed to retrieve collection for attribute sync: " << job->errorString();
+ q->cancelTask(i18n("Failed to retrieve collection for attribute sync."));
+ return;
+ }
+ Akonadi::CollectionFetchJob *fetchJob = static_cast<Akonadi::CollectionFetchJob*>(job);
+ QMetaObject::invokeMethod(q, "retrieveCollectionAttributes", Q_ARG(Akonadi::Collection, fetchJob->collections().first()));
}
void ResourceBasePrivate::slotSynchronizeTags()
@@ -1053,6 +1091,10 @@ void ResourceBase::synchronizeTags()
void ResourceBase::cancelTask()
{
Q_D(ResourceBase);
+ if (d->mCurrentCollectionFetchJob) {
+ d->mCurrentCollectionFetchJob->kill();
+ d->mCurrentCollectionFetchJob = 0;
+ }
switch (d->scheduler->currentTask().type) {
case ResourceScheduler::FetchItem:
itemRetrieved(Item()); // sends the error reply and
diff --git a/akonadi/resourcebase.h b/akonadi/resourcebase.h
index 9e56afc..790767f 100644
--- a/akonadi/resourcebase.h
+++ b/akonadi/resourcebase.h
@@ -796,6 +796,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void slotRecursiveMoveReplayResult(KJob *))
Q_PRIVATE_SLOT(d_func(), void slotTagSyncDone(KJob *))
Q_PRIVATE_SLOT(d_func(), void slotSynchronizeTags())
+ Q_PRIVATE_SLOT(d_func(), void slotItemRetrievalCollectionFetchDone(KJob *));
+ Q_PRIVATE_SLOT(d_func(), void slotAttributeRetrievalCollectionFetchDone(KJob *));
};
}
More information about the commits
mailing list