• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
agentfactory.cpp
1 /*
2  This file is part of akonadiresources.
3 
4  Copyright (c) 2006 Till Adam <adam@kde.org>
5  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "agentfactory.h"
24 #include "servermanager.h"
25 #include "servermanager_p.h"
26 
27 #include <klocale.h>
28 #include <klocalizedstring.h>
29 #include <kglobal.h>
30 
31 #include <QtCore/QThread>
32 #include <QtCore/QThreadStorage>
33 
34 QThreadStorage<KComponentData *> s_agentComponentDatas;
35 
36 using namespace Akonadi;
37 
38 class Akonadi::AgentFactoryBasePrivate
39 {
40 public:
41  QString catalogName;
42 };
43 
44 AgentFactoryBase::AgentFactoryBase(const char *catalogName, QObject *parent)
45  : QObject(parent)
46  , d(new AgentFactoryBasePrivate)
47 {
48  d->catalogName = QString::fromLatin1(catalogName);
49  if (!KGlobal::hasMainComponent()) {
50  new KComponentData("AkonadiAgentServer", "libakonadi", KComponentData::RegisterAsMainComponent);
51  }
52 
53  KGlobal::locale()->insertCatalog(d->catalogName);
54 
55  Internal::setClientType(Internal::Agent);
56  ServerManager::self(); // make sure it's created in the main thread
57 }
58 
59 AgentFactoryBase::~AgentFactoryBase()
60 {
61  delete d;
62 }
63 
64 void AgentFactoryBase::createComponentData(const QString &identifier) const
65 {
66  Q_ASSERT(!s_agentComponentDatas.hasLocalData());
67 
68  if (QThread::currentThread() != QCoreApplication::instance()->thread()) {
69  s_agentComponentDatas.setLocalData(new KComponentData(ServerManager::addNamespace(identifier).toLatin1(), d->catalogName.toLatin1(),
70  KComponentData::SkipMainComponentRegistration));
71  } else {
72  s_agentComponentDatas.setLocalData(new KComponentData(ServerManager::addNamespace(identifier).toLatin1(), d->catalogName.toLatin1()));
73  }
74 }
Akonadi::ServerManager::self
static ServerManager * self()
Returns the singleton instance of this class, for connecting to its signals.
Definition: servermanager.cpp:161
QObject::thread
QThread * thread() const
QThreadStorage::setLocalData
void setLocalData(T data)
Akonadi::AgentFactoryBase::AgentFactoryBase
AgentFactoryBase(const char *catalogName, QObject *parent=0)
Creates a new agent factory.
Definition: agentfactory.cpp:44
QThreadStorage::hasLocalData
bool hasLocalData() const
QObject
QCoreApplication::instance
QCoreApplication * instance()
QString
QThreadStorage
QThread::currentThread
QThread * currentThread()
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Akonadi::ServerManager::addNamespace
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with '_' as separator).
Definition: servermanager.cpp:337
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal