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()) {
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(
"'");
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(
"'");
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;
221 out <<
" Actual # of sources: " << engine->
containerDict().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"