diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index cb32a2167..76173f700 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -186,7 +186,7 @@ Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject * if (applet()) { const QString scopedName = applet()->pluginName() + ":" + name; if (!AnimationScriptEngine::isAnimationRegistered(scopedName)) { - KConfig conf(applet()->package()->path() + "/metadata.desktop", KConfig::SimpleConfig); + KConfig conf(applet()->package().path() + "/metadata.desktop", KConfig::SimpleConfig); KConfigGroup animConf(&conf, "Animations"); QString file; foreach (const QString &possibleFile, animConf.keyList()) { @@ -201,7 +201,7 @@ Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject * return 0; } - const QString path = applet()->package()->filePath("animations", file); + const QString path = applet()->package().filePath("animations", file); if (path.isEmpty()) { kDebug() << "file path was empty for" << file; return 0; @@ -234,10 +234,10 @@ DataEngine *AppletScript::dataEngine(const QString &engine) const QString AppletScript::mainScript() const { Q_ASSERT(d->applet); - return d->applet->package()->filePath("mainscript"); + return d->applet->package().filePath("mainscript"); } -const Package *AppletScript::package() const +Package AppletScript::package() const { Q_ASSERT(d->applet); return d->applet->package(); diff --git a/scripting/appletscript.h b/scripting/appletscript.h index 9d1c78b84..7153f8a7a 100644 --- a/scripting/appletscript.h +++ b/scripting/appletscript.h @@ -210,7 +210,7 @@ protected: * be used to request resources, such as images and * interface files. */ - const Package *package() const; + Package package() const; /** * @return the KPluginInfo associated with this plasmoid diff --git a/scripting/dataenginescript.cpp b/scripting/dataenginescript.cpp index 316bb249c..099d37870 100644 --- a/scripting/dataenginescript.cpp +++ b/scripting/dataenginescript.cpp @@ -79,10 +79,10 @@ Service *DataEngineScript::serviceForSource(const QString &source) QString DataEngineScript::mainScript() const { Q_ASSERT(d->dataEngine); - return d->dataEngine->package()->filePath("mainscript"); + return d->dataEngine->package().filePath("mainscript"); } -const Package *DataEngineScript::package() const +Package DataEngineScript::package() const { Q_ASSERT(d->dataEngine); return d->dataEngine->package(); diff --git a/scripting/dataenginescript.h b/scripting/dataenginescript.h index b5ed3ec45..ffec5c101 100644 --- a/scripting/dataenginescript.h +++ b/scripting/dataenginescript.h @@ -109,7 +109,7 @@ protected: * be used to request resources, such as images and * interface files. */ - const Package *package() const; + Package package() const; /** * @return the KPluginInfo associated with this plasmoid diff --git a/scripting/runnerscript.cpp b/scripting/runnerscript.cpp index d85f49e83..672903cb2 100644 --- a/scripting/runnerscript.cpp +++ b/scripting/runnerscript.cpp @@ -171,9 +171,9 @@ void RunnerScript::setSyntaxes(const QList &syns) } } -const Package *RunnerScript::package() const +Package RunnerScript::package() const { - return d->runner ? d->runner->package() : 0; + return d->runner ? d->runner->package() : Package(); } KPluginInfo RunnerScript::description() const @@ -183,11 +183,7 @@ KPluginInfo RunnerScript::description() const QString RunnerScript::mainScript() const { - if (!package()) { - return QString(); - } else { - return package()->filePath("mainscript"); - } + return package().filePath("mainscript"); } } // Plasma namespace diff --git a/scripting/runnerscript.h b/scripting/runnerscript.h index 44db891b0..5348b81e2 100644 --- a/scripting/runnerscript.h +++ b/scripting/runnerscript.h @@ -94,7 +94,7 @@ protected: * be used to request resources, such as images and * interface files. */ - const Package *package() const; + Package package() const; /** * @return the KPluginInfo associated with this plasmoid diff --git a/scripting/scriptengine.cpp b/scripting/scriptengine.cpp index 3ca5ee1b6..61c5668f6 100644 --- a/scripting/scriptengine.cpp +++ b/scripting/scriptengine.cpp @@ -32,8 +32,6 @@ #include "scripting/runnerscript.h" #include "scripting/wallpaperscript.h" -#include "private/packages_p.h" - namespace Plasma { @@ -53,9 +51,9 @@ bool ScriptEngine::init() return true; } -const Package *ScriptEngine::package() const +Package ScriptEngine::package() const { - return 0; + return Package(); } QString ScriptEngine::mainScript() const @@ -225,8 +223,7 @@ DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngi RunnerScript *loadScriptEngine(const QString &language, AbstractRunner *runner) { - RunnerScript *engine = - static_cast(loadEngine(language, RunnerComponent, runner)); + RunnerScript *engine = static_cast(loadEngine(language, RunnerComponent, runner)); if (engine) { engine->setRunner(runner); @@ -247,44 +244,6 @@ WallpaperScript *loadScriptEngine(const QString &language, Wallpaper *wallpaper) return engine; } -PackageStructure::Ptr defaultPackageStructure(ComponentType type) -{ - switch (type) { - case AppletComponent: - case WallpaperComponent: - case RunnerComponent: - return PackageStructure::Ptr(new PlasmoidPackage()); - break; - case DataEngineComponent: - return PackageStructure::Ptr(new DataEnginePackage()); - break; - default: - // TODO: we don't have any special structures for other components yet - break; - } - - return PackageStructure::Ptr(new PackageStructure()); -} - -PackageStructure::Ptr packageStructure(const QString &language, ComponentType type) -{ - KService::List offers = engineOffers(language, type); - - if (offers.isEmpty()) { - return defaultPackageStructure(type); - } - - KService::Ptr offer = offers.first(); - QString packageFormat = offer->property("X-Plasma-PackageFormat").toString(); - - if (packageFormat.isEmpty()) { - return defaultPackageStructure(type); - } else { - PackageStructure::Ptr structure = PackageStructure::load(packageFormat); - return structure; - } -} - } // namespace Plasma #include diff --git a/scripting/scriptengine.h b/scripting/scriptengine.h index ed9acb6f9..a839964d5 100644 --- a/scripting/scriptengine.h +++ b/scripting/scriptengine.h @@ -20,8 +20,8 @@ #ifndef PLASMA_SCRIPTENGINE_H #define PLASMA_SCRIPTENGINE_H +#include #include -#include #include #include @@ -42,7 +42,6 @@ class DataEngineScript; class RunnerScript; class Wallpaper; class WallpaperScript; -class Package; class ScriptEnginePrivate; /** @@ -50,16 +49,6 @@ class ScriptEnginePrivate; * * @short The base class for scripting interfaces to be used in loading * plasmoids of a given language. - * - * All ScriptEngines should export as consistent an interface as possible - * so that the learning curve is limited. In particular, the following - * API should be made available in the script environment: - * - * TODO: define the actual scripting APIas ... - * PlasmaApplet - the applet of this plasmoid - * LoadUserInterface(String uiFile) - loads and returns a given UI file - * LoadImage - loads an image resource out of the plasmoid's package - * PlasmaSvg - creates and returns an Svg file **/ class PLASMA_EXPORT ScriptEngine : public QObject @@ -87,7 +76,7 @@ protected: * be used to request resources, such as images and * interface files. */ - virtual const Package *package() const; + virtual Package package() const; private: ScriptEnginePrivate *const d; @@ -140,14 +129,6 @@ PLASMA_EXPORT RunnerScript *loadScriptEngine(const QString &language, AbstractRu **/ PLASMA_EXPORT WallpaperScript *loadScriptEngine(const QString &language, Wallpaper *wallpaper); -/** - * Loads an appropriate PackageStructure for the given language and type - * - * @param language the language to load the PackageStructure for - * @param type the component type - * @return a guarded PackageStructure pointer - */ -PLASMA_EXPORT PackageStructure::Ptr packageStructure(const QString &language, ComponentType type); } // namespace Plasma diff --git a/scripting/wallpaperscript.cpp b/scripting/wallpaperscript.cpp index 0f5c348c9..e716a8701 100644 --- a/scripting/wallpaperscript.cpp +++ b/scripting/wallpaperscript.cpp @@ -57,10 +57,10 @@ Wallpaper *WallpaperScript::wallpaper() const QString WallpaperScript::mainScript() const { Q_ASSERT(d->wallpaper); - return d->wallpaper->package()->filePath("mainscript"); + return d->wallpaper->package().filePath("mainscript"); } -const Package *WallpaperScript::package() const +Package WallpaperScript::package() const { Q_ASSERT(d->wallpaper); return d->wallpaper->package(); diff --git a/scripting/wallpaperscript.h b/scripting/wallpaperscript.h index 1f57789c8..c61041ec6 100644 --- a/scripting/wallpaperscript.h +++ b/scripting/wallpaperscript.h @@ -153,7 +153,7 @@ protected: * be used to request resources, such as images and * interface files. */ - const Package *package() const; + Package package() const; /** * @return the KPluginInfo associated with this wallpaper