[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepimlibs/akonadi
From: Tobias Koenig <tokoe () kde ! org>
Date: 2008-03-31 21:22:36
Message-ID: 1206998556.420063.4882.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 792355 by tokoe:
Hide AgentManager::createInstance in private class to encourage the
developers to use the fool-proof AgentInstanceCreateJob instead.
M +2 -1 agentinstancecreatejob.cpp
M +9 -9 agentmanager.cpp
M +1 -8 agentmanager.h
M +5 -0 agentmanager_p.h
M +7 -6 tests/resourcetest.cpp
--- trunk/KDE/kdepimlibs/akonadi/agentinstancecreatejob.cpp #792354:792355
@@ -19,6 +19,7 @@
#include "agentinstancecreatejob.h"
#include "agentmanager.h"
+#include "agentmanager_p.h"
#include "agentinstance.h"
@@ -113,7 +114,7 @@
void AgentInstanceCreateJob::start()
{
- d->agentInstance = AgentManager::self()->createInstance( d->agentType );
+ d->agentInstance = AgentManager::self()->d->createInstance( d->agentType );
if ( !d->agentInstance.isValid() ) {
setError( KJob::UserDefinedError );
setErrorText( i18n("Unable to create agent instance." ) );
--- trunk/KDE/kdepimlibs/akonadi/agentmanager.cpp #792354:792355
@@ -30,6 +30,15 @@
using namespace Akonadi;
+AgentInstance AgentManagerPrivate::createInstance( const AgentType &type )
+{
+ const QString &identifier = mManager->createAgentInstance( type.identifier() );
+ if ( identifier.isEmpty() )
+ return AgentInstance();
+
+ return fillAgentInstanceLight( identifier );
+}
+
void AgentManagerPrivate::agentTypeAdded( const QString &identifier )
{
const AgentType type = fillAgentType( identifier );
@@ -244,15 +253,6 @@
return d->mInstances.value( identifier );
}
-AgentInstance AgentManager::createInstance( const AgentType &type )
-{
- const QString &identifier = d->mManager->createAgentInstance( type.identifier() );
- if ( identifier.isEmpty() )
- return AgentInstance();
-
- return d->fillAgentInstanceLight( identifier );
-}
-
void AgentManager::removeInstance( const AgentInstance &instance )
{
d->mManager->removeAgentInstance( instance.identifier() );
--- trunk/KDE/kdepimlibs/akonadi/agentmanager.h #792354:792355
@@ -42,6 +42,7 @@
class AKONADI_EXPORT AgentManager : public QObject
{
friend class AgentInstance;
+ friend class AgentInstanceCreateJob;
friend class AgentManagerPrivate;
Q_OBJECT
@@ -80,14 +81,6 @@
AgentInstance instance( const QString &identififer ) const;
/**
- * Creates a new agent instance of the given agent @p type.
- *
- * @return The new agent instance if created successfully,
- * an invalid agent instance otherwise.
- */
- AgentInstance createInstance( const AgentType &type );
-
- /**
* Removes the given agent @p instance.
*/
void removeInstance( const AgentInstance &instance );
--- trunk/KDE/kdepimlibs/akonadi/agentmanager_p.h #792354:792355
@@ -41,6 +41,11 @@
{
}
+ /*
+ * Used by AgentInstanceCreateJob
+ */
+ AgentInstance createInstance( const AgentType &type );
+
void agentTypeAdded( const QString& );
void agentTypeRemoved( const QString& );
void agentInstanceAdded( const QString& );
--- trunk/KDE/kdepimlibs/akonadi/tests/resourcetest.cpp #792354:792355
@@ -38,9 +38,6 @@
QSignalSpy spyRemoveInstance( AgentManager::self(), \
SIGNAL(instanceRemoved(AgentInstance)) ); QVERIFY( spyRemoveInstance.isValid() );
- AgentInstance instance = AgentManager::self()->createInstance( \
AgentManager::self()->type( "non_existing_resource" ) );
- QVERIFY( !instance.isValid() );
-
AgentType type = AgentManager::self()->type( "akonadi_knut_resource" );
QVERIFY( type.isValid() );
@@ -48,7 +45,7 @@
AgentInstanceCreateJob *job = new AgentInstanceCreateJob( type );
QVERIFY( job->exec() );
- instance = job->instance();
+ AgentInstance instance = job->instance();
QVERIFY( instance.isValid() );
QTest::qWait( 2000 );
@@ -73,13 +70,17 @@
void testIllegalResourceManagement()
{
- AgentInstance instance = AgentManager::self()->createInstance( \
AgentManager::self()->type( "non_existing_resource" ) ); + \
AgentInstanceCreateJob *job = new AgentInstanceCreateJob( AgentManager::self()->type( \
"non_existing_resource" ) ); + QVERIFY( job->exec() );
+ AgentInstance instance = job->instance();
QVERIFY( !instance.isValid() );
// unique agent
const AgentType type = AgentManager::self()->type( \
"akonadi_mailthreader_agent" ); QVERIFY( type.isValid() );
- instance = AgentManager::self()->createInstance( type );
+ job = new AgentInstanceCreateJob( type );
+ QVERIFY( job->exec() );
+ instance = job->instance();
QVERIFY( !instance.isValid() );
}
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic