2
* Copyright 2005 by Aaron Seigo <aseigo@kde.org>
3
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
4
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Library General Public License as
8
* published by the Free Software Foundation; either version 2, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details
16
* You should have received a copy of the GNU Library General Public
17
* License along with this program; if not, write to the
18
* Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "dataengineconsumer_p.h"
24
#include <QtCore/QSet>
28
#include <plasma/dataenginemanager.h>
29
#include <plasma/servicejob.h>
34
ServiceMonitor::ServiceMonitor(DataEngineConsumer *consumer)
35
: m_consumer(consumer)
39
ServiceMonitor::~ServiceMonitor()
43
void ServiceMonitor::slotJobFinished(Plasma::ServiceJob *job)
45
kDebug() << "engine ready!";
46
QString engineName = job->parameters()["EngineName"].toString();
47
QString location = job->destination();
48
QPair<QString, QString> pair(location, engineName);
49
kDebug() << "pair = " << pair;
50
if (!m_consumer->m_remoteEngines.contains(pair)) {
51
kDebug() << "engine does not exist yet!";
53
KUrl engineLocation(location);
54
engineLocation.setFileName(job->result().toString());
55
kDebug() << "setting location : "
56
<< engineLocation.prettyUrl();
57
// m_consumer->m_remoteEngines[pair]->setLocation(engineLocation);
61
void ServiceMonitor::slotServiceReady(Plasma::Service *plasmoidService)
63
kDebug() << "service ready!";
64
if (!m_consumer->m_engineNameForService.contains(plasmoidService)) {
65
kDebug() << "no engine name for service!";
66
kDebug() << "amount of services in map: " << m_consumer->m_engineNameForService.count();
68
kDebug() << "value = " << m_consumer->m_engineNameForService.value(plasmoidService);
71
kDebug() << "requesting dataengine!";
72
KConfigGroup op = plasmoidService->operationDescription("DataEngine");
73
op.writeEntry("EngineName", m_consumer->m_engineNameForService.value(plasmoidService));
74
plasmoidService->startOperationCall(op);
75
connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob*)),
76
this, SLOT(slotJobFinished(Plasma::ServiceJob*)));
79
DataEngineConsumer::DataEngineConsumer()
80
: m_monitor(new ServiceMonitor(this))
84
DataEngineConsumer::~DataEngineConsumer()
86
foreach (const QString &engine, m_loadedEngines) {
87
DataEngineManager::self()->unloadEngine(engine);
93
DataEngine *DataEngineConsumer::dataEngine(const QString &name)
95
if (m_loadedEngines.contains(name)) {
96
return DataEngineManager::self()->engine(name);
99
DataEngine *engine = DataEngineManager::self()->loadEngine(name);
100
if (engine->isValid()) {
101
m_loadedEngines.insert(name);
107
DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QString &name)
113
} // namespace Plasma
115
#include "dataengineconsumer_p.moc"