Plasma
Go to the documentation of this file.
23 #include <QTextStream>
27 #include <kstandarddirs.h>
28 #include <kservicetypetrader.h>
32 #include "private/componentinstaller_p.h"
33 #include "private/dataengine_p.h"
34 #include "private/datacontainer_p.h"
40 class NullEngine :
public DataEngine
53 class DataEngineManagerPrivate
56 DataEngineManagerPrivate()
60 ~DataEngineManagerPrivate()
69 DataEngine *nullEngine()
72 nullEng =
new NullEngine;
82 class DataEngineManagerSingleton
85 DataEngineManager
self;
88 K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
92 return &privateDataEngineManagerSelf->
self;
95 DataEngineManager::DataEngineManager()
96 : d(new DataEngineManagerPrivate)
101 DataEngineManager::~DataEngineManager()
108 if (name.isEmpty()) {
109 return d->nullEngine();
112 Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
113 if (it != d->engines.constEnd()) {
119 return d->nullEngine();
124 Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
126 if (it != d->engines.constEnd()) {
135 ComponentInstaller::self()->installMissingComponent(
"dataengine", name);
137 return d->nullEngine();
141 d->engines[name] =
engine;
147 Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
149 if (it != d->engines.end()) {
153 if (!
engine->d->isUsed()) {
154 d->engines.erase(it);
164 if (parentApp.isEmpty()) {
165 constraint.append(
"(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')");
167 constraint.append(
"[X-KDE-ParentApp] == '").append(parentApp).append(
"'");
170 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/DataEngine", constraint);
173 foreach (
const KService::Ptr &service, offers) {
174 QString name = service->property(
"X-KDE-PluginInfo-Name").toString();
175 if (!name.isEmpty()) {
176 engines.append(name);
190 QString constraint = QString(
"[X-KDE-PluginInfo-Category] == '%1'").arg(category);
192 if (parentApp.isEmpty()) {
193 constraint.append(
" and not exist [X-KDE-ParentApp]");
195 constraint.append(
" and [X-KDE-ParentApp] == '").append(parentApp).append(
"'");
198 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/DataEngine", constraint);
199 return KPluginInfo::fromServices(offers);
205 QString path = KGlobal::dirs()->locateLocal(
"appdata",
"plasma_dataenginemanager_log");
207 if (!f.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
208 kDebug() <<
"faild to open" << path;
214 QHashIterator<QString, DataEngine*> it(d->engines);
215 out <<
"================================== " << KGlobal::locale()->formatDateTime(QDateTime::currentDateTime()) << endl;
216 while (it.hasNext()) {
219 out <<
"DataEngine: " << it.key() <<
' ' <<
engine << endl;
220 out <<
" Claimed # of sources: " <<
engine->
sources().count() << endl;
222 out << endl <<
" Source Details" << endl;
225 out <<
" * " << dc->objectName() << endl;
226 out <<
" Data count: " << dc->d->data.count() << endl;
230 out <<
" Direction Connections: " << directs <<
' ' << endl;
233 const int relays = dc->d->relays.count();
235 out <<
" Relays: " << dc->d->relays.count() << endl;
237 foreach (SignalRelay *relay, dc->d->relays) {
238 times.append(
' ').append(QString::number(relay->m_interval));
240 out <<
" Relay Timeouts: " << times <<
' ' << endl;
244 out << endl <<
"-----" << endl;
253 #include "dataenginemanager.moc"
Data provider for plasmoids (Plasma plugins)
QHash< QString, QVariant > Data
Namespace for everything in libplasma.
void unloadEngine(const QString &name)
Decreases the reference count on the engine.
virtual void init()
This method is called when the DataEngine is started.
Plasma::DataEngine * engine(const QString &name) const
Returns a data engine object if one is loaded and available.
static QStringList listAllEngines(const QString &parentApp=QString())
static DataEngineManager * self()
Singleton pattern accessor.
KPluginInfo::List listDataEngineInfo(const QString &parentApp=QString())
Returns a list of all known DataEngines.
DataEngine loader and life time manager.
static KPluginInfo::List listEngineInfoByCategory(const QString &category, const QString &parentApp=QString())
Returns a list of all known DataEngines filtering by category.
static KPluginInfo::List listEngineInfo(const QString &parentApp=QString())
Returns a list of all known DataEngines.
DataEngine(QObject *parent=0, KService::Ptr service=KService::Ptr(0))
Constructor.
DataEngine * loadDataEngine(const QString &name)
Load a DataEngine plugin.
static PluginLoader * pluginLoader()
Return the active plugin loader.
Plasma::DataEngine * loadEngine(const QString &name)
Loads a data engine and increases the reference count on it.
A set of data exported via a DataEngine.
QHash< QString, DataEngine * > Dict
void timerEvent(QTimerEvent *event)
Reimplemented from QObject.
void setValid(bool valid)
Sets whether or not this engine is valid, e.g.
SourceDict containerDict() const
bool isStorageEnabled() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jan 19 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.