23 #include <QTextStream>
27 #include <kstandarddirs.h>
28 #include <kservicetypetrader.h>
32 #include "private/dataengine_p.h"
33 #include "private/datacontainer_p.h"
39 class NullEngine :
public DataEngine
52 class DataEngineManagerPrivate
55 DataEngineManagerPrivate()
59 ~DataEngineManagerPrivate()
68 DataEngine *nullEngine()
71 nullEng =
new NullEngine;
81 class DataEngineManagerSingleton
84 DataEngineManager
self;
87 K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
91 return &privateDataEngineManagerSelf->
self;
94 DataEngineManager::DataEngineManager()
95 : d(new DataEngineManagerPrivate)
100 DataEngineManager::~DataEngineManager()
107 if (name.isEmpty()) {
108 return d->nullEngine();
111 Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
112 if (it != d->engines.constEnd()) {
118 return d->nullEngine();
123 Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
125 if (it != d->engines.constEnd()) {
133 return d->nullEngine();
137 d->engines[name] =
engine;
143 Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
145 if (it != d->engines.end()) {
149 if (!engine->d->isUsed()) {
150 d->engines.erase(it);
160 if (parentApp.isEmpty()) {
161 constraint.append(
"(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')");
163 constraint.append(
"[X-KDE-ParentApp] == '").append(parentApp).append(
"'");
169 foreach (
const KService::Ptr &service, offers) {
170 QString name = service->property(
"X-KDE-PluginInfo-Name").toString();
171 if (!name.isEmpty()) {
172 engines.append(name);
186 QString constraint = QString(
"[X-KDE-PluginInfo-Category] == '%1'").arg(category);
188 if (parentApp.isEmpty()) {
189 constraint.append(
" and not exist [X-KDE-ParentApp]");
191 constraint.append(
" and [X-KDE-ParentApp] == '").append(parentApp).append(
"'");
195 return KPluginInfo::fromServices(offers);
201 QString path = KGlobal::dirs()->locateLocal(
"appdata",
"plasma_dataenginemanager_log");
203 if (!f.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
204 kDebug() <<
"faild to open" << path;
210 QHashIterator<QString, DataEngine*> it(d->engines);
211 out <<
"================================== " << KGlobal::locale()->formatDateTime(QDateTime::currentDateTime()) << endl;
212 while (it.hasNext()) {
215 out <<
"DataEngine: " << it.key() <<
' ' << engine << endl;
216 out <<
" Claimed # of sources: " << engine->
sources().count() << endl;
217 out <<
" Actual # of sources: " << engine->
containerDict().count() << endl;
218 out << endl <<
" Source Details" << endl;
221 out <<
" * " << dc->objectName() << endl;
222 out <<
" Data count: " << dc->d->data.count() << endl;
226 out <<
" Direction Connections: " << directs <<
' ' << endl;
229 const int relays = dc->d->relays.count();
231 out <<
" Relays: " << dc->d->relays.count() << endl;
233 foreach (SignalRelay *relay, dc->d->relays) {
234 times.append(
' ').append(QString::number(relay->m_interval));
236 out <<
" Relay Timeouts: " << times <<
' ' << endl;
240 out << endl <<
"-----" << endl;
249 #include "dataenginemanager.moc"