Akonadi

agentfactory.cpp
1 /*
2  This file is part of akonadiresources.
3 
4  SPDX-FileCopyrightText: 2006 Till Adam <[email protected]>
5  SPDX-FileCopyrightText: 2007 Volker Krause <[email protected]>
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 
20 QThreadStorage<KComponentData *> s_agentComponentDatas;
21 
22 using namespace Akonadi;
23 
24 class Akonadi::AgentFactoryBasePrivate
25 {
26 public:
27  QString catalogName;
28 };
29 
30 AgentFactoryBase::AgentFactoryBase(const char *catalogName, QObject *parent)
31  : QObject(parent)
32  , d(new AgentFactoryBasePrivate)
33 {
34  d->catalogName = QString::fromLatin1(catalogName);
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 
44 AgentFactoryBase::~AgentFactoryBase() = default;
45 
46 void 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"
static ServerManager * self()
Returns the singleton instance of this class, for connecting to its signals.
AgentFactoryBase(const char *catalogName, QObject *parent=nullptr)
Creates a new agent factory.
QThread * thread() const const
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with '_' as separator).
QCoreApplication * instance()
bool hasMainComponent()
QThread * currentThread()
QString fromLatin1(const char *str, int size)
static void setApplicationDomain(const char *domain)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:05:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.