[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepimlibs] akonadi: Until now one can trigger collection tree
From: Frank Osterfeld <frank.osterfeld () kdab ! com>
Date: 2011-09-23 7:53:43
Message-ID: 20110923075343.6B554A607A () git ! kde ! org
[Download RAW message or body]
Git commit d95bbc06b1ac9536e834e91eb15e088eb9df6751 by Frank Osterfeld.
Committed on 22/09/2011 at 18:15.
Pushed by osterfeld into branch 'master'.
Until now one can trigger collection tree synchronization via \
AgentInstance::synchronizeCollectionTree(), but there is no way to receive its \
result, as ResourceSynchronizationJob only supports full synchronization. Add a flag \
to ResourceSynchronizationJob to support also collection tree synchronization.
M +4 -0 akonadi/resourcebase.cpp
M +7 -0 akonadi/resourcebase.h
M +15 -0 akonadi/resourcescheduler.cpp
M +7 -0 akonadi/resourcescheduler_p.h
M +31 -6 akonadi/resourcesynchronizationjob.cpp
M +16 -0 akonadi/resourcesynchronizationjob.h
http://commits.kde.org/kdepimlibs/d95bbc06b1ac9536e834e91eb15e088eb9df6751
diff --git a/akonadi/resourcebase.cpp b/akonadi/resourcebase.cpp
index 359911f..f268f7c 100644
--- a/akonadi/resourcebase.cpp
+++ b/akonadi/resourcebase.cpp
@@ -316,11 +316,13 @@ ResourceBase::ResourceBase( const QString & id )
connect( d->scheduler, SIGNAL(executeChangeReplay()),
d->mChangeRecorder, SLOT(replayNext()) );
connect( d->scheduler, SIGNAL(fullSyncComplete()), SIGNAL(synchronized()) );
+ connect( d->scheduler, SIGNAL(collectionTreeSyncComplete()), \
SIGNAL(collectionTreeSynchronized()) ); connect( d->mChangeRecorder, \
SIGNAL(nothingToReplay()), d->scheduler, SLOT(taskDone()) ); connect( \
d->mChangeRecorder, SIGNAL(collectionRemoved(Akonadi::Collection)), d->scheduler, \
SLOT(collectionRemoved(Akonadi::Collection)) ); connect( this, \
SIGNAL(abortRequested()), this, SLOT(slotAbortRequested()) ); connect( this, \
SIGNAL(synchronized()), d->scheduler, SLOT(taskDone()) ); + connect( this, \
SIGNAL(collectionTreeSynchronized()), d->scheduler, SLOT(taskDone()) ); connect( \
this, SIGNAL(agentNameChanged(QString)), this, SIGNAL(nameChanged(QString)) );
@@ -643,6 +645,8 @@ void ResourceBasePrivate::slotCollectionSyncDone( KJob * job )
list->fetchScope().setResource( mId );
q->connect( list, SIGNAL(result(KJob*)), q, SLOT(slotLocalListDone(KJob*)) );
return;
+ } else if ( scheduler->currentTask().type == \
ResourceScheduler::SyncCollectionTree ) { + \
scheduler->scheduleCollectionTreeSyncCompletion(); }
}
scheduler->taskDone();
diff --git a/akonadi/resourcebase.h b/akonadi/resourcebase.h
index 2e5ca9e..8e1b55e 100644
--- a/akonadi/resourcebase.h
+++ b/akonadi/resourcebase.h
@@ -233,6 +233,13 @@ class AKONADI_EXPORT ResourceBase : public AgentBase
*/
void attributesSynchronized( qlonglong collectionId );
+ /**
+ * Emitted when a collection tree synchronization has been completed.
+ *
+ * @since 4.8
+ */
+ void collectionTreeSynchronized();
+
protected Q_SLOTS:
/**
* Retrieve the collection tree from the remote server and supply it via
diff --git a/akonadi/resourcescheduler.cpp b/akonadi/resourcescheduler.cpp
index e6ae827..ebb0f04 100644
--- a/akonadi/resourcescheduler.cpp
+++ b/akonadi/resourcescheduler.cpp
@@ -171,6 +171,17 @@ void Akonadi::ResourceScheduler::scheduleFullSyncCompletion()
scheduleNext();
}
+void Akonadi::ResourceScheduler::scheduleCollectionTreeSyncCompletion()
+{
+ Task t;
+ t.type = SyncCollectionTreeDone;
+ TaskList& queue = queueForTaskType( t.type );
+ // no compression here, all this does is emitting a D-Bus signal anyway, and \
compression can trigger races on the receiver side with the signal being lost + \
queue << t; + signalTaskToTracker( t, "SyncCollectionTreeDone" );
+ scheduleNext();
+}
+
void Akonadi::ResourceScheduler::scheduleCustomTask( QObject *receiver, const char* \
methodName, const QVariant &argument, ResourceBase::SchedulePriority priority ) {
Task t;
@@ -305,6 +316,9 @@ void ResourceScheduler::executeNext()
case SyncAllDone:
emit fullSyncComplete();
break;
+ case SyncCollectionTreeDone:
+ emit collectionTreeSyncComplete();
+ break;
case Custom:
{
const QByteArray methodSig = mCurrentTask.methodName + "(QVariant)";
@@ -478,6 +492,7 @@ static const char s_taskTypes[][27] = {
"DeleteResourceCollection",
"InvalideCacheForCollection",
"SyncAllDone",
+ "SyncCollectionTreeDone",
"Custom"
};
diff --git a/akonadi/resourcescheduler_p.h b/akonadi/resourcescheduler_p.h
index 1f2c176..31bc50f 100644
--- a/akonadi/resourcescheduler_p.h
+++ b/akonadi/resourcescheduler_p.h
@@ -57,6 +57,7 @@ class ResourceScheduler : public QObject
DeleteResourceCollection,
InvalideCacheForCollection,
SyncAllDone,
+ SyncCollectionTreeDone,
Custom
};
@@ -139,6 +140,11 @@ class ResourceScheduler : public QObject
void scheduleFullSyncCompletion();
/**
+ Insert collection tree synchronization completion marker into the task queue.
+ */
+ void scheduleCollectionTreeSyncCompletion();
+
+ /**
Insert a custom task.
@param methodName The method name, without signature, do not use the SLOT() \
macro
*/
@@ -208,6 +214,7 @@ class ResourceScheduler : public QObject
void executeResourceCollectionDeletion();
void executeCacheInvalidation( const Akonadi::Collection &collection );
void executeChangeReplay();
+ void collectionTreeSyncComplete();
void fullSyncComplete();
void status( int status, const QString &message = QString() );
diff --git a/akonadi/resourcesynchronizationjob.cpp \
b/akonadi/resourcesynchronizationjob.cpp index b5f677d..3f186a9 100644
--- a/akonadi/resourcesynchronizationjob.cpp
+++ b/akonadi/resourcesynchronizationjob.cpp
@@ -39,7 +39,8 @@ class ResourceSynchronizationJobPrivate : public KJobPrivateBase
q( parent ),
interface( 0 ),
safetyTimer( 0 ),
- timeoutCount( 0 )
+ timeoutCount( 0 ),
+ collectionTreeOnly( false )
{}
void doStart();
@@ -49,6 +50,7 @@ class ResourceSynchronizationJobPrivate : public KJobPrivateBase
QDBusInterface* interface;
QTimer* safetyTimer;
int timeoutCount;
+ bool collectionTreeOnly;
static int timeoutCountLimit;
void slotSynchronized();
@@ -78,6 +80,16 @@ void ResourceSynchronizationJob::start()
d->start();
}
+bool ResourceSynchronizationJob::collectionTreeOnly() const
+{
+ return d->collectionTreeOnly;
+}
+
+void ResourceSynchronizationJob::setCollectionTreeOnly( bool b )
+{
+ d->collectionTreeOnly = b;
+}
+
void ResourceSynchronizationJobPrivate::doStart()
{
if ( !instance.isValid() ) {
@@ -91,10 +103,17 @@ void ResourceSynchronizationJobPrivate::doStart()
QString::fromLatin1( "/" ),
QString::fromLatin1( \
"org.freedesktop.Akonadi.Resource" ),
DBusConnectionPool::threadConnection(), this );
- connect( interface, SIGNAL(synchronized()), q, SLOT(slotSynchronized()) );
+ if ( collectionTreeOnly )
+ connect( interface, SIGNAL(collectionTreeSynchronized()), q, \
SLOT(slotSynchronized()) ); + else
+ connect( interface, SIGNAL(synchronized()), q, SLOT(slotSynchronized()) );
if ( interface->isValid() ) {
- instance.synchronize();
+ if ( collectionTreeOnly )
+ instance.synchronizeCollectionTree();
+ else
+ instance.synchronize();
+
safetyTimer->start();
} else {
q->setError( KJob::UserDefinedError );
@@ -106,7 +125,10 @@ void ResourceSynchronizationJobPrivate::doStart()
void ResourceSynchronizationJobPrivate::slotSynchronized()
{
- q->disconnect( interface, SIGNAL(synchronized()), q, SLOT(slotSynchronized()) );
+ if ( collectionTreeOnly )
+ q->disconnect( interface, SIGNAL(collectionTreeSynchronized()), q, \
SLOT(slotSynchronized()) ); + else
+ q->disconnect( interface, SIGNAL(synchronized()), q, SLOT(slotSynchronized()) );
safetyTimer->stop();
q->emitResult();
}
@@ -125,9 +147,12 @@ void ResourceSynchronizationJobPrivate::slotTimeout()
}
if ( instance.status() == AgentInstance::Idle ) {
- // try again, we might have lost the synchronized() signal
+ // try again, we might have lost the synchronized()/synchronizedCollectionTree() \
signal kDebug() << "trying again to sync resource" << instance.identifier();
- instance.synchronize();
+ if ( collectionTreeOnly )
+ instance.synchronizeCollectionTree();
+ else
+ instance.synchronize();
}
}
diff --git a/akonadi/resourcesynchronizationjob.h \
b/akonadi/resourcesynchronizationjob.h index b8e5abd..679438e 100644
--- a/akonadi/resourcesynchronizationjob.h
+++ b/akonadi/resourcesynchronizationjob.h
@@ -74,6 +74,22 @@ class AKONADI_EXPORT ResourceSynchronizationJob : public KJob
~ResourceSynchronizationJob();
/**
+ * Returns whether a full synchronization will be done, or just the collection \
tree (without items). + * The default is @p false, i.e. a full sync will be \
requested. + *
+ * @since 4.8
+ */
+ bool collectionTreeOnly() const;
+
+ /**
+ * Sets the collectionTreeOnly property.
+ *
+ * @param collectionTreeOnly If set, only the collection tree will be \
synchronized. + * @since 4.8
+ */
+ void setCollectionTreeOnly( bool collectionTreeOnly );
+
+ /**
* Returns the resource that has been synchronized.
*/
AgentInstance resource() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic