00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "agentfactory.h"
00024 #include "servermanager.h"
00025 #include "servermanager_p.h"
00026
00027 #include <klocale.h>
00028
00029 #include <QtCore/QThread>
00030 #include <QtCore/QThreadStorage>
00031
00032 QThreadStorage<KComponentData*> s_agentComponentDatas;
00033
00034 using namespace Akonadi;
00035
00036 class Akonadi::AgentFactoryBasePrivate
00037 {
00038 public:
00039 QString catalogName;
00040 };
00041
00042 AgentFactoryBase::AgentFactoryBase( const char *catalogName, QObject *parent)
00043 : QObject( parent ), d( new AgentFactoryBasePrivate )
00044 {
00045 d->catalogName = QString::fromLatin1( catalogName );
00046 if ( !KGlobal::hasMainComponent() )
00047 new KComponentData( "AkonadiAgentServer", "libakonadi", KComponentData::RegisterAsMainComponent );
00048
00049 KGlobal::locale()->insertCatalog( d->catalogName );
00050
00051 Internal::setClientType( Internal::Agent );
00052 ServerManager::self();
00053 }
00054
00055 void AgentFactoryBase::createComponentData( const QString& identifier ) const
00056 {
00057 Q_ASSERT( !s_agentComponentDatas.hasLocalData() );
00058
00059 if ( QThread::currentThread() != QCoreApplication::instance()->thread() ) {
00060 s_agentComponentDatas.setLocalData( new KComponentData( identifier.toLatin1(), d->catalogName.toLatin1(),
00061 KComponentData::SkipMainComponentRegistration ) );
00062 } else {
00063 s_agentComponentDatas.setLocalData( new KComponentData( identifier.toLatin1(), d->catalogName.toLatin1() ) );
00064 }
00065 }
00066
00067 #include "agentfactory.moc"