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_DATAENGINESCRIPT_H
|
|
|
|
#define PLASMA_DATAENGINESCRIPT_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 DataEngine;
|
2008-07-01 20:56:43 +02:00
|
|
|
class DataEngineScriptPrivate;
|
2008-01-25 01:04:03 +01:00
|
|
|
|
|
|
|
class PLASMA_EXPORT DataEngineScript : public ScriptEngine
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor for a DataEngineScript.
|
|
|
|
* Subclasses should not attempt to access the Plasma::DataEngine
|
|
|
|
* associated with this DataEngineScript in the constructor. All
|
|
|
|
* such set up that requires the DataEngine itself should be done
|
|
|
|
* in the init() method.
|
|
|
|
*/
|
|
|
|
explicit DataEngineScript(QObject *parent = 0);
|
|
|
|
~DataEngineScript();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Plasma::DataEngine associated with this DataEngineScript
|
|
|
|
*/
|
|
|
|
void setDataEngine(DataEngine *dataEngine);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Plasma::DataEngine associated with this script component
|
|
|
|
*/
|
|
|
|
DataEngine* dataEngine() const;
|
|
|
|
|
2008-02-04 05:41:40 +01:00
|
|
|
/**
|
|
|
|
* Called when the script should create a source that does not currently
|
|
|
|
* exist.
|
|
|
|
*
|
|
|
|
* @param name the name of the source that should be created
|
|
|
|
* @return true if a DataContainer was set up, false otherwise
|
|
|
|
*/
|
2008-04-26 14:59:44 +02:00
|
|
|
virtual bool sourceRequestEvent(const QString &name);
|
2008-02-04 05:41:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the script should refresh the data contained in a given
|
|
|
|
* source.
|
|
|
|
*
|
|
|
|
* @param source the name of the source that should be updated
|
|
|
|
* @return true if the data was changed, or false if there was no
|
|
|
|
* change or if the change will occur later
|
|
|
|
**/
|
2008-04-26 14:59:44 +02:00
|
|
|
virtual bool updateSourceEvent(const QString& source);
|
2008-02-04 05:41:40 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void setData(const QString& source, const QString& key,
|
|
|
|
const QVariant& value);
|
|
|
|
void setData(const QString &source, const QVariant &value);
|
2008-04-26 14:12:37 +02:00
|
|
|
void removeAllData(const QString& source);
|
2008-02-04 05:41:40 +01:00
|
|
|
void removeData(const QString& source, const QString& key);
|
2008-04-25 18:17:33 +02:00
|
|
|
void setMaxSourceCount(uint limit);
|
2008-04-24 04:21:22 +02:00
|
|
|
void setMinimumPollingInterval(int minimumMs);
|
|
|
|
int minimumPollingInterval() const;
|
|
|
|
void setPollingInterval(uint frequency);
|
2008-04-26 14:30:42 +02:00
|
|
|
void removeAllSources();
|
2008-02-04 05:41:40 +01:00
|
|
|
|
2008-01-25 01:04:03 +01:00
|
|
|
private:
|
2008-07-01 20:56:43 +02:00
|
|
|
DataEngineScriptPrivate * const d;
|
2008-01-25 01:04:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) \
|
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
|
|
|
K_EXPORT_PLUGIN(factory("plasma_dataenginescriptengine_" #libname))
|
|
|
|
|
|
|
|
} //Plasma namespace
|
|
|
|
|
|
|
|
#endif
|