Akonadi
7 #include "resourcemanager.h"
8 #include "resourcemanageradaptor.h"
9 #include "storage/datastore.h"
10 #include "storage/transaction.h"
13 #include <private/capabilities_p.h>
14 #include <shared/akranges.h>
16 #include <QDBusConnection>
18 using namespace Akonadi::Server;
19 using namespace AkRanges;
21 ResourceManager::ResourceManager(
Tracer &tracer)
24 new ResourceManagerAdaptor(
this);
28 void ResourceManager::addResourceInstance(
const QString &name,
const QStringList &capabilities)
30 Transaction transaction(DataStore::self(), QStringLiteral(
"ADD RESOURCE INSTANCE"));
31 Resource resource = Resource::retrieveByName(name);
32 if (resource.isValid()) {
33 mTracer.error(
"ResourceManager", QStringLiteral(
"Resource '%1' already exists.").arg(name));
40 if (!resource.insert()) {
41 mTracer.error(
"ResourceManager", QStringLiteral(
"Could not create resource '%1'.").arg(name));
46 void ResourceManager::removeResourceInstance(
const QString &name)
49 Resource resource = Resource::retrieveByName(name);
50 if (resource.isValid()) {
51 resource.collections() | Actions::forEach([](Collection col) {
52 DataStore::self()->cleanupCollection(col);
60 QStringList ResourceManager::resourceInstances()
const
62 return Resource::retrieveAll() | Views::transform(&
Resource::name) | Actions::toQList;
65 #include "moc_resourcemanager.cpp"
Helper class for DataStore transaction handling.
The global tracer instance where all akonadi components can send their tracing information to.
bool registerObject(const QString &path, QObject *object, QDBusConnection::RegisterOptions options)
QDBusConnection sessionBus()
void setName(QString value)
Capabilities capabilities()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Oct 3 2023 04:02:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.