scripting fixes

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796423
This commit is contained in:
Aaron J. Seigo 2008-04-13 15:01:46 +00:00
parent 3e7d6cc024
commit f2fe39b435
2 changed files with 26 additions and 1 deletions

View File

@ -28,8 +28,10 @@
#include <KDebug> #include <KDebug>
#include <KPluginInfo> #include <KPluginInfo>
#include <KService> #include <KService>
#include <KStandardDirs>
#include "datacontainer.h" #include "datacontainer.h"
#include "package.h"
#include "scripting/dataenginescript.h" #include "scripting/dataenginescript.h"
namespace Plasma namespace Plasma
@ -45,7 +47,8 @@ class DataEngine::Private
minUpdateInterval(-1), minUpdateInterval(-1),
limit(0), limit(0),
valid(true), valid(true),
script(0) script(0),
package(0)
{ {
updateTimer = new QTimer(engine); updateTimer = new QTimer(engine);
updateTimer->setSingleShot(true); updateTimer->setSingleShot(true);
@ -64,10 +67,18 @@ class DataEngine::Private
QString language = dataEngineDescription.property("X-Plasma-Language").toString(); QString language = dataEngineDescription.property("X-Plasma-Language").toString();
if (!language.isEmpty()) { if (!language.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/engines/" + dataEngineDescription.pluginName() + "/");
PackageStructure::Ptr structure = Plasma::packageStructure(language, Plasma::RunnerComponent);
structure->setPath(path);
package = new Package(path, structure);
script = Plasma::loadScriptEngine(language, engine); script = Plasma::loadScriptEngine(language, engine);
if (!script) { if (!script) {
kDebug() << "Could not create a" << language << "ScriptEngine for the" kDebug() << "Could not create a" << language << "ScriptEngine for the"
<< dataEngineDescription.name() << "DataEngine."; << dataEngineDescription.name() << "DataEngine.";
delete package;
package = 0;
} }
} }
} }
@ -193,6 +204,7 @@ class DataEngine::Private
bool valid; bool valid;
DataEngineScript* script; DataEngineScript* script;
QString engineName; QString engineName;
Package *package;
}; };
@ -550,6 +562,11 @@ QString DataEngine::icon() const
return d->icon; return d->icon;
} }
const Package *DataEngine::package() const
{
return d->package;
}
void DataEngine::checkForUpdates() void DataEngine::checkForUpdates()
{ {
QHashIterator<QString, Plasma::DataContainer*> it(d->sources); QHashIterator<QString, Plasma::DataContainer*> it(d->sources);

View File

@ -35,6 +35,7 @@ namespace Plasma
class DataContainer; class DataContainer;
class DataEngineScript; class DataEngineScript;
class Package;
/** /**
* @class DataEngine * @class DataEngine
@ -221,6 +222,13 @@ class PLASMA_EXPORT DataEngine : public QObject
**/ **/
QString icon() const; QString icon() const;
/**
* Accessor for the associated Package object if any.
*
* @return the Package object, or 0 if none
**/
const Package* package() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
* Emitted when a new data source is created * Emitted when a new data source is created