• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
dataengineconsumer.cpp
Go to the documentation of this file.
1 /*
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>
5  *
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.
10  *
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
15  *
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.
20  */
21 
22 #include "dataengineconsumer_p.h"
23 
24 #include <QtCore/QSet>
25 
26 #include <kdebug.h>
27 
28 #include <plasma/dataenginemanager.h>
29 #include <plasma/servicejob.h>
30 
31 namespace Plasma
32 {
33 
34 ServiceMonitor::ServiceMonitor(DataEngineConsumer *consumer)
35  : m_consumer(consumer)
36 {
37 }
38 
39 ServiceMonitor::~ServiceMonitor()
40 {
41 }
42 
43 void ServiceMonitor::slotJobFinished(Plasma::ServiceJob *job)
44 {
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!";
52  } else {
53  KUrl engineLocation(location);
54  engineLocation.setFileName(job->result().toString());
55  //kDebug() << "setting location : " << engineLocation.prettyUrl();
56  // m_consumer->m_remoteEngines[pair]->setLocation(engineLocation);
57  }
58 }
59 
60 void ServiceMonitor::slotServiceReady(Plasma::Service *plasmoidService)
61 {
62  //kDebug() << "service ready!";
63  if (!m_consumer->m_engineNameForService.contains(plasmoidService)) {
64  kDebug() << "no engine name for service!";
65  kDebug() << "amount of services in map: " << m_consumer->m_engineNameForService.count();
66  } else {
67  //kDebug() << "value = " << m_consumer->m_engineNameForService.value(plasmoidService);
68  }
69 
70  //kDebug() << "requesting dataengine!";
71  KConfigGroup op = plasmoidService->operationDescription("DataEngine");
72  op.writeEntry("EngineName", m_consumer->m_engineNameForService.value(plasmoidService));
73  plasmoidService->startOperationCall(op);
74  connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob*)),
75  this, SLOT(slotJobFinished(Plasma::ServiceJob*)));
76 }
77 
78 DataEngineConsumer::DataEngineConsumer()
79  : m_monitor(new ServiceMonitor(this))
80 {
81 }
82 
83 DataEngineConsumer::~DataEngineConsumer()
84 {
85  foreach (const QString &engine, m_loadedEngines) {
86  DataEngineManager::self()->unloadEngine(engine);
87  }
88 
89  delete m_monitor;
90 }
91 
92 void DataEngineConsumer::finishedWithEngine(const QString &name)
93 {
94  if (m_loadedEngines.contains(name)) {
95  DataEngineManager::self()->unloadEngine(name);
96  }
97 }
98 
99 DataEngine *DataEngineConsumer::dataEngine(const QString &name)
100 {
101  if (m_loadedEngines.contains(name)) {
102  return DataEngineManager::self()->engine(name);
103  }
104 
105  DataEngine *engine = DataEngineManager::self()->loadEngine(name);
106  if (engine->isValid()) {
107  m_loadedEngines.insert(name);
108  }
109 
110  return engine;
111 }
112 
113 DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QString &name)
114 {
115  Q_UNUSED(location);
116  Q_UNUSED(name);
117  return 0;
118 }
119 
120 
121 } // namespace Plasma
122 
123 #include "dataengineconsumer_p.moc"
124 
125 
Plasma::ServiceMonitor::slotServiceReady
void slotServiceReady(Plasma::Service *service)
Definition: dataengineconsumer.cpp:60
Plasma::ServiceMonitor::ServiceMonitor
ServiceMonitor(DataEngineConsumer *consumer)
Definition: dataengineconsumer.cpp:34
Plasma::DataEngineConsumer::DataEngineConsumer
DataEngineConsumer()
Definition: dataengineconsumer.cpp:78
QMap::contains
bool contains(const Key &key) const
Plasma::ServiceMonitor::slotJobFinished
void slotJobFinished(Plasma::ServiceJob *job)
Definition: dataengineconsumer.cpp:43
Plasma::DataEngineConsumer::remoteDataEngine
DataEngine * remoteDataEngine(const KUrl &location, const QString &name)
Definition: dataengineconsumer.cpp:113
QSet::insert
const_iterator insert(const T &value)
Plasma::ServiceMonitor
Definition: dataengineconsumer_p.h:38
Plasma::ServiceMonitor::~ServiceMonitor
~ServiceMonitor()
Definition: dataengineconsumer.cpp:39
Plasma::DataEngineConsumer::finishedWithEngine
void finishedWithEngine(const QString &name)
Definition: dataengineconsumer.cpp:92
Plasma::DataEngineConsumer::~DataEngineConsumer
~DataEngineConsumer()
Definition: dataengineconsumer.cpp:83
QString
Plasma::DataEngineConsumer::dataEngine
DataEngine * dataEngine(const QString &name)
Definition: dataengineconsumer.cpp:99
QPair
QSet::contains
bool contains(const T &value) const
dataengineconsumer_p.h
Plasma::DataEngineConsumer
Definition: dataengineconsumer_p.h:53
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QMap::count
int count(const Key &key) const
QMap::value
const T value(const Key &key) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

Skip menu "PlasmaCore"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal