From 637515f2a91adeb2bfd3f1cafc69552658039fe1 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sun, 13 Apr 2008 14:37:10 +0000 Subject: [PATCH] changes that were lost in the merge svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796407 --- abstractrunner.cpp | 50 ++++++++++++++++++++++++++++++---------------- abstractrunner.h | 9 +++++++++ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/abstractrunner.cpp b/abstractrunner.cpp index ce2515925..afb66f578 100644 --- a/abstractrunner.cpp +++ b/abstractrunner.cpp @@ -25,8 +25,10 @@ #include #include #include +#include #include +#include "package.h" #include "scripting/runnerscript.h" #include "searchcontext.h" @@ -35,33 +37,31 @@ namespace Plasma class AbstractRunner::Private { - public: - bool hasMatchOptions; - bool hasConfig; - Priority priority; - Speed speed; - RunnerScript* script; - KPluginInfo runnerDescription; - AbstractRunner* runner; - QTime runtime; - int fastRuns; - +public: Private(AbstractRunner* r, KService::Ptr service) : priority(NormalPriority), speed(NormalSpeed), script(0), runnerDescription(service), runner(r), - fastRuns(0) + fastRuns(0), + package(0) { if (runnerDescription.isValid()) { - QString language = runnerDescription.property("X-Plasma-Language").toString(); - + const QString language = runnerDescription.property("X-Plasma-Language").toString(); if (!language.isEmpty()) { + const QString path = KStandardDirs::locate("data", + "plasma/runners/" + runnerDescription.pluginName() + "/"); + PackageStructure::Ptr structure = Plasma::packageStructure(language, Plasma::RunnerComponent); + structure->setPath(path); + package = new Package(path, structure); + script = Plasma::loadScriptEngine(language, runner); if (!script) { kDebug() << "Could not create a" << language << "ScriptEngine for the" << runnerDescription.name() << "Runner."; + delete package; + package = 0; } else { QTimer::singleShot(0, runner, SLOT(init())); } @@ -69,14 +69,25 @@ class AbstractRunner::Private } } + bool hasMatchOptions; + bool hasConfig; + Priority priority; + Speed speed; + RunnerScript* script; + KPluginInfo runnerDescription; + AbstractRunner* runner; + QTime runtime; + int fastRuns; + Package *package; + static QMutex bigLock; }; QMutex AbstractRunner::Private::bigLock; -AbstractRunner::AbstractRunner(QObject* parent, const QString& serviceId) - : QObject(parent), - d(new Private(this, KService::serviceByStorageId(serviceId))) + AbstractRunner::AbstractRunner(QObject* parent, const QString& serviceId) +: QObject(parent), + d(new Private(this, KService::serviceByStorageId(serviceId))) { } @@ -221,6 +232,11 @@ QString AbstractRunner::runnerName() const return d->runnerDescription.property("X-Plasma-RunnerName").toString(); } +const Package* AbstractRunner::package() const +{ + return d->package; +} + void AbstractRunner::init() { if (d->script) { diff --git a/abstractrunner.h b/abstractrunner.h index a708ff852..d83ba0768 100644 --- a/abstractrunner.h +++ b/abstractrunner.h @@ -36,6 +36,7 @@ class KCompletion; namespace Plasma { +class Package; class RunnerScript; /** @@ -168,6 +169,14 @@ class PLASMA_EXPORT AbstractRunner : public QObject */ QString runnerName() const; + /** + * Accessor for the associated Package object if any. + * Generally, only Plasmoids come in a Package. + * + * @return the Package object, or 0 if none + **/ + const Package* package() const; + protected: /** * Sets whether or not the the runner has options for matches