Akonadi

agentfactory.cpp
1/*
2 This file is part of akonadiresources.
3
4 SPDX-FileCopyrightText: 2006 Till Adam <adam@kde.org>
5 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "agentfactory.h"
11#include "servermanager.h"
12#include "servermanager_p.h"
13
14#include <KGlobal>
15#include <KLocalizedString>
16
17#include <QThread>
18#include <QThreadStorage>
19
20QThreadStorage<KComponentData *> s_agentComponentDatas;
21
22using namespace Akonadi;
23
24class Akonadi::AgentFactoryBasePrivate
25{
26public:
27 QString catalogName;
28};
29
30AgentFactoryBase::AgentFactoryBase(const char *catalogName, QObject *parent)
31 : QObject(parent)
32 , d(new AgentFactoryBasePrivate)
33{
34 d->catalogName = QString::fromLatin1(catalogName);
35 if (!KGlobal::hasMainComponent()) {
36 new KComponentData("AkonadiAgentServer", "libakonadi", KComponentData::RegisterAsMainComponent);
37 }
39
40 Internal::setClientType(Internal::Agent);
41 ServerManager::self(); // make sure it's created in the main thread
42}
43
44AgentFactoryBase::~AgentFactoryBase() = default;
45
46void AgentFactoryBase::createComponentData(const QString &identifier) const
47{
48 Q_ASSERT(!s_agentComponentDatas.hasLocalData());
49
51 s_agentComponentDatas.setLocalData(
52 new KComponentData(ServerManager::addNamespace(identifier).toLatin1(), d->catalogName.toLatin1(), KComponentData::SkipMainComponentRegistration));
53 } else {
54 s_agentComponentDatas.setLocalData(new KComponentData(ServerManager::addNamespace(identifier).toLatin1(), d->catalogName.toLatin1()));
55 }
56}
57
58#include "moc_agentfactory.cpp"
AgentFactoryBase(const char *catalogName, QObject *parent=nullptr)
Creates a new agent factory.
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with '_' as separator).
static ServerManager * self()
Returns the singleton instance of this class, for connecting to its signals.
static void setApplicationDomain(const QByteArray &domain)
Helper integration between Akonadi and Qt.
QCoreApplication * instance()
QThread * thread() const const
QString fromLatin1(QByteArrayView str)
QThread * currentThread()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.