implement package support
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796112
This commit is contained in:
parent
99c036a212
commit
40866fc443
@ -25,8 +25,10 @@
|
|||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KPluginInfo>
|
#include <KPluginInfo>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
|
#include <KStandardDirs>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "package.h"
|
||||||
#include "scripting/runnerscript.h"
|
#include "scripting/runnerscript.h"
|
||||||
#include "searchcontext.h"
|
#include "searchcontext.h"
|
||||||
|
|
||||||
@ -36,6 +38,37 @@ namespace Plasma
|
|||||||
class AbstractRunner::Private
|
class AbstractRunner::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Private(AbstractRunner* r, KService::Ptr service)
|
||||||
|
: priority(NormalPriority),
|
||||||
|
speed(NormalSpeed),
|
||||||
|
script(0),
|
||||||
|
runnerDescription(service),
|
||||||
|
runner(r),
|
||||||
|
fastRuns(0),
|
||||||
|
package(0)
|
||||||
|
{
|
||||||
|
if (runnerDescription.isValid()) {
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool hasMatchOptions;
|
bool hasMatchOptions;
|
||||||
bool hasConfig;
|
bool hasConfig;
|
||||||
Priority priority;
|
Priority priority;
|
||||||
@ -45,29 +78,7 @@ class AbstractRunner::Private
|
|||||||
AbstractRunner* runner;
|
AbstractRunner* runner;
|
||||||
QTime runtime;
|
QTime runtime;
|
||||||
int fastRuns;
|
int fastRuns;
|
||||||
|
Package *package;
|
||||||
Private(AbstractRunner* r, KService::Ptr service)
|
|
||||||
: priority(NormalPriority),
|
|
||||||
speed(NormalSpeed),
|
|
||||||
script(0),
|
|
||||||
runnerDescription(service),
|
|
||||||
runner(r),
|
|
||||||
fastRuns(0)
|
|
||||||
{
|
|
||||||
if (runnerDescription.isValid()) {
|
|
||||||
QString language = runnerDescription.property("X-Plasma-Language").toString();
|
|
||||||
|
|
||||||
if (!language.isEmpty()) {
|
|
||||||
script = Plasma::loadScriptEngine(language, runner);
|
|
||||||
if (!script) {
|
|
||||||
kDebug() << "Could not create a" << language << "ScriptEngine for the"
|
|
||||||
<< runnerDescription.name() << "Runner.";
|
|
||||||
} else {
|
|
||||||
QTimer::singleShot(0, runner, SLOT(init()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static QMutex bigLock;
|
static QMutex bigLock;
|
||||||
};
|
};
|
||||||
@ -221,6 +232,11 @@ QString AbstractRunner::runnerName() const
|
|||||||
return d->runnerDescription.property("X-Plasma-RunnerName").toString();
|
return d->runnerDescription.property("X-Plasma-RunnerName").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Package* AbstractRunner::package() const
|
||||||
|
{
|
||||||
|
return d->package;
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractRunner::init()
|
void AbstractRunner::init()
|
||||||
{
|
{
|
||||||
if (d->script) {
|
if (d->script) {
|
||||||
|
@ -36,6 +36,7 @@ class KCompletion;
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Package;
|
||||||
class RunnerScript;
|
class RunnerScript;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,6 +169,14 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
|||||||
*/
|
*/
|
||||||
QString runnerName() const;
|
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:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the the runner has options for matches
|
* Sets whether or not the the runner has options for matches
|
||||||
|
Loading…
Reference in New Issue
Block a user