Branch 'feature/remoterelationsync' - akonadi/resourcebase.cpp akonadi/resourcebase.h akonadi/resourcescheduler.cpp akonadi/resourcescheduler_p.h

Aaron Seigo seigo at kolabsys.com
Tue Nov 11 12:33:05 CET 2014


 akonadi/resourcebase.cpp      |   25 ++++++++++++++++++++++++-
 akonadi/resourcebase.h        |   12 ++++++++++++
 akonadi/resourcescheduler.cpp |   16 ++++++++++++++++
 akonadi/resourcescheduler_p.h |    3 +++
 4 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit f04624638951df75dbb2c571a0fa7db8d0d8f940
Author: Aaron Seigo <aseigo at kde.org>
Date:   Tue Nov 11 12:31:26 2014 +0100

    split tag and relation syncing
    
    this simplifies the queuing and task completion notification, even
    if it is less efficient for kolab

diff --git a/akonadi/resourcebase.cpp b/akonadi/resourcebase.cpp
index 0de70f3..ba0919d 100644
--- a/akonadi/resourcebase.cpp
+++ b/akonadi/resourcebase.cpp
@@ -149,6 +149,7 @@ public:
     void slotCollectionListForAttributesDone(KJob *job);
     void slotCollectionAttributesSyncDone(KJob *job);
     void slotSynchronizeTags();
+    void slotSynchronizeRelations();
     void slotAttributeRetrievalCollectionFetchDone(KJob *job);
 
     void slotItemSyncDone(KJob *job);
@@ -491,6 +492,8 @@ ResourceBase::ResourceBase(const QString &id)
             SLOT(slotSynchronizeCollectionAttributes(Akonadi::Collection)));
     connect(d->scheduler, SIGNAL(executeTagSync()),
             SLOT(slotSynchronizeTags()));
+    connect(d->scheduler, SIGNAL(executeRelationSync()),
+            SLOT(slotSynchronizeRelations()));
     connect(d->scheduler, SIGNAL(executeItemFetch(Akonadi::Item,QSet<QByteArray>)),
             SLOT(slotPrepareItemRetrieval(Akonadi::Item)));
     connect(d->scheduler, SIGNAL(executeResourceCollectionDeletion()),
@@ -987,6 +990,12 @@ void ResourceBasePrivate::slotSynchronizeTags()
     QMetaObject::invokeMethod(q, "retrieveTags");
 }
 
+void ResourceBasePrivate::slotSynchronizeRelations()
+{
+    Q_Q(ResourceBase);
+    QMetaObject::invokeMethod(q, "retrieveRelations");
+}
+
 void ResourceBasePrivate::slotPrepareItemRetrieval(const Akonadi::Item &item)
 {
     Q_Q(ResourceBase);
@@ -1100,6 +1109,11 @@ void ResourceBase::synchronizeTags()
     d_func()->scheduler->scheduleTagSync();
 }
 
+void ResourceBase::synchronizeRelations()
+{
+    d_func()->scheduler->scheduleRelationSync();
+}
+
 void ResourceBase::cancelTask()
 {
     Q_D(ResourceBase);
@@ -1329,6 +1343,12 @@ void ResourceBase::retrieveTags()
     d->scheduler->taskDone();
 }
 
+void ResourceBase::retrieveRelations()
+{
+    Q_D(ResourceBase);
+    d->scheduler->taskDone();
+}
+
 void Akonadi::ResourceBase::abortActivity()
 {
 }
@@ -1405,12 +1425,14 @@ void ResourceBasePrivate::slotTagSyncDone(KJob *job)
             emit q->error(job->errorString());
         }
     }
+
+    scheduler->taskDone();
 }
 
 void ResourceBase::relationsRetrieved(const Relation::List &relations)
 {
     Q_D(ResourceBase);
-    Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncTags ||
+    Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncRelations ||
                d->scheduler->currentTask().type == ResourceScheduler::SyncAll ||
                d->scheduler->currentTask().type == ResourceScheduler::Custom,
                "ResourceBase::relationsRetrieved()",
@@ -1433,6 +1455,7 @@ void ResourceBasePrivate::slotRelationSyncDone(KJob *job)
             emit q->error(job->errorString());
         }
     }
+
     scheduler->taskDone();
 }
 
diff --git a/akonadi/resourcebase.h b/akonadi/resourcebase.h
index cb59938..a18e2ae 100644
--- a/akonadi/resourcebase.h
+++ b/akonadi/resourcebase.h
@@ -277,6 +277,12 @@ protected Q_SLOTS:
     virtual void retrieveTags();
 
     /**
+     * Retreive all relations from the backend
+     * @see relationsRetrieved()
+     */
+    virtual void retrieveRelations();
+
+    /**
      * Retrieve the attributes of a single collection from the backend. The
      * collection to retrieve attributes for is provided as @p collection.
      * Add the attributes parts and call collectionAttributesRetrieved()
@@ -661,6 +667,11 @@ protected:
     void synchronizeTags();
 
     /**
+     * Refetches Relations.
+     */
+    void synchronizeRelations();
+
+    /**
      * Stops the execution of the current task and continues with the next one.
      */
     void cancelTask();
@@ -814,6 +825,7 @@ private:
     Q_PRIVATE_SLOT(d_func(), void slotTagSyncDone(KJob *))
     Q_PRIVATE_SLOT(d_func(), void slotRelationSyncDone(KJob *job))
     Q_PRIVATE_SLOT(d_func(), void slotSynchronizeTags())
+    Q_PRIVATE_SLOT(d_func(), void slotSynchronizeRelations())
     Q_PRIVATE_SLOT(d_func(), void slotItemRetrievalCollectionFetchDone(KJob *));
     Q_PRIVATE_SLOT(d_func(), void slotAttributeRetrievalCollectionFetchDone(KJob *));
 };
diff --git a/akonadi/resourcescheduler.cpp b/akonadi/resourcescheduler.cpp
index b46d23d..93078e5 100644
--- a/akonadi/resourcescheduler.cpp
+++ b/akonadi/resourcescheduler.cpp
@@ -80,6 +80,18 @@ void ResourceScheduler::scheduleTagSync()
   scheduleNext();
 }
 
+void ResourceScheduler::scheduleRelationSync()
+{
+  Task t;
+  t.type = SyncRelations;
+  TaskList& queue = queueForTaskType( t.type );
+  if ( queue.contains( t ) || mCurrentTask == t )
+    return;
+  queue << t;
+  signalTaskToTracker( t, "SyncRelations" );
+  scheduleNext();
+}
+
 void ResourceScheduler::scheduleSync(const Collection & col)
 {
   Task t;
@@ -354,6 +366,9 @@ void ResourceScheduler::executeNext()
     case SyncCollectionTreeDone:
       emit collectionTreeSyncComplete();
       break;
+    case SyncRelations:
+      emit executeRelationSync();
+      break;
     case Custom:
     {
       const QByteArray methodSig = mCurrentTask.methodName + "(QVariant)";
@@ -560,6 +575,7 @@ static const char s_taskTypes[][27] = {
       "InvalideCacheForCollection",
       "SyncAllDone",
       "SyncCollectionTreeDone",
+      "SyncRelations",
       "Custom"
 };
 
diff --git a/akonadi/resourcescheduler_p.h b/akonadi/resourcescheduler_p.h
index 676a7f4..f17d9ea 100644
--- a/akonadi/resourcescheduler_p.h
+++ b/akonadi/resourcescheduler_p.h
@@ -62,6 +62,7 @@ public:
         InvalideCacheForCollection,
         SyncAllDone,
         SyncCollectionTreeDone,
+        SyncRelations,
         Custom
     };
 
@@ -124,6 +125,7 @@ public:
     void scheduleAttributesSync(const Collection &collection);
 
     void scheduleTagSync();
+    void scheduleRelationSync();
 
     /**
       Schedules fetching of a single PIM item.
@@ -231,6 +233,7 @@ Q_SIGNALS:
     void executeCollectionSync(const Akonadi::Collection &col);
     void executeCollectionTreeSync();
     void executeTagSync();
+    void executeRelationSync();
     void executeItemFetch(const Akonadi::Item &item, const QSet<QByteArray> &parts);
     void executeResourceCollectionDeletion();
     void executeCacheInvalidation(const Akonadi::Collection &collection);




More information about the commits mailing list