2008-01-25 01:04:03 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_RUNNERSCRIPT_H
|
|
|
|
#define PLASMA_RUNNERSCRIPT_H
|
|
|
|
|
2008-03-14 00:35:06 +01:00
|
|
|
#include <KDE/KGenericFactory>
|
2008-02-26 06:07:15 +01:00
|
|
|
|
2008-01-25 01:04:03 +01:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
#include <plasma/scripting/scriptengine.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class AbstractRunner;
|
2008-05-01 20:40:10 +02:00
|
|
|
class RunnerContext;
|
2008-05-02 20:46:05 +02:00
|
|
|
class QueryMatch;
|
2008-01-25 01:04:03 +01:00
|
|
|
|
|
|
|
class PLASMA_EXPORT RunnerScript : public ScriptEngine
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor for a RunnerScript.
|
|
|
|
* Subclasses should not attempt to access the Plasma::AbstractRunner
|
|
|
|
* associated with this RunnerScript in the constructor. All
|
|
|
|
* such set up that requires the AbstractRunner itself should be done
|
|
|
|
* in the init() method.
|
|
|
|
*/
|
|
|
|
explicit RunnerScript(QObject *parent = 0);
|
|
|
|
~RunnerScript();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Plasma::AbstractRunner associated with this RunnerScript
|
|
|
|
*/
|
|
|
|
void setRunner(AbstractRunner *runner);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Plasma::AbstractRunner associated with this script component
|
|
|
|
*/
|
|
|
|
AbstractRunner* runner() const;
|
|
|
|
|
2008-02-04 05:41:40 +01:00
|
|
|
/**
|
2008-05-02 20:46:05 +02:00
|
|
|
* Called when the script should create QueryMatch instances through
|
2008-05-01 20:40:10 +02:00
|
|
|
* RunnerContext::addInformationalMatch, RunnerContext::addExactMatch, and
|
|
|
|
* RunnerContext::addPossibleMatch.
|
2008-02-04 05:41:40 +01:00
|
|
|
*/
|
2008-05-01 20:40:10 +02:00
|
|
|
virtual void match(Plasma::RunnerContext *search);
|
2008-02-04 05:41:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called whenever an exact or possible match associated with this
|
|
|
|
* runner is triggered.
|
|
|
|
*/
|
2008-05-02 20:46:05 +02:00
|
|
|
virtual void run(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action);
|
2008-02-04 05:41:40 +01:00
|
|
|
|
2008-04-27 15:52:59 +02:00
|
|
|
protected:
|
2008-04-13 16:41:52 +02:00
|
|
|
/**
|
|
|
|
* @return absolute path to the main script file for this plasmoid
|
|
|
|
*/
|
|
|
|
QString mainScript() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the Package associated with this plasmoid which can
|
|
|
|
* be used to request resources, such as images and
|
|
|
|
* interface files.
|
|
|
|
*/
|
|
|
|
const Package* package() const;
|
|
|
|
|
2008-01-25 01:04:03 +01:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define K_EXPORT_PLASMA_RUNNERSCRIPTENGINE(libname, classname) \
|
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
|
|
|
K_EXPORT_PLUGIN(factory("plasma_runnerscriptengine_" #libname))
|
|
|
|
|
|
|
|
} //Plasma namespace
|
|
|
|
|
|
|
|
#endif
|