From 35898d57f1bfa526d643119cdcba8988af42ff49 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 19 Jul 2011 22:04:22 +0200 Subject: [PATCH] get rid of all Class:load(..) methods, use PluginLoader directrly. --apiBloat; --- abstractrunner.cpp | 8 ++++---- applet.cpp | 16 +--------------- applet.h | 32 -------------------------------- containment.cpp | 2 +- corona.cpp | 9 +++++---- dataengine.cpp | 5 +++-- extenders/extender.cpp | 3 ++- package.cpp | 5 ----- package.h | 10 ---------- pluginloader.h | 1 + remote/accessappletjob.cpp | 22 ++++++++++++---------- service.cpp | 11 ----------- service.h | 22 ---------------------- 13 files changed, 29 insertions(+), 117 deletions(-) diff --git a/abstractrunner.cpp b/abstractrunner.cpp index 53985de20..ac28cb679 100644 --- a/abstractrunner.cpp +++ b/abstractrunner.cpp @@ -33,10 +33,10 @@ #include #include -#include -#include - +#include "package.h" +#include "pluginloader.h" #include "private/abstractrunner_p.h" +#include "querymatch.h" #include "runnercontext.h" #include "scripting/runnerscript.h" @@ -415,7 +415,7 @@ void AbstractRunnerPrivate::prepScripting(const QString &path, const QString &ap return; } - package = new Package(Plasma::Package::load("Plasma/Runner", api)); + package = new Package(PluginLoader::self()->loadPackage("Plasma/Runner", api)); package->setPath(path); if (!package->isValid()) { diff --git a/applet.cpp b/applet.cpp index 709002a06..41aee9c75 100644 --- a/applet.cpp +++ b/applet.cpp @@ -2307,20 +2307,6 @@ Applet *Applet::loadPlasmoid(const QString &path, uint appletId, const QVariantL return 0; } -Applet *Applet::load(const QString &appletName, uint appletId, const QVariantList &args) -{ - return PluginLoader::self()->loadApplet(appletName, appletId, args); -} - -Applet *Applet::load(const KPluginInfo &info, uint appletId, const QVariantList &args) -{ - if (!info.isValid()) { - return 0; - } - - return load(info.pluginName(), appletId, args); -} - QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value) { QVariant ret = QGraphicsWidget::itemChange(change, value); @@ -2645,7 +2631,7 @@ void AppletPrivate::init(const QString &packagePath) } - package = new Package(Package::load("Plasma/Applet", api)); + package = new Package(PluginLoader::self()->loadPackage("Plasma/Applet", api)); // find where the Package is QString path = packagePath; diff --git a/applet.h b/applet.h index d37d2814e..5f4c12da3 100644 --- a/applet.h +++ b/applet.h @@ -337,38 +337,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget static Applet *loadPlasmoid(const QString &path, uint appletId = 0, const QVariantList &args = QVariantList()); - /** - * Attempts to load an applet - * - * Returns a pointer to the applet if successful. - * The caller takes responsibility for the applet, including - * deleting it when no longer needed. - * - * @param name the plugin name, as returned by KPluginInfo::pluginName() - * @param appletId unique ID to assign the applet, or zero to have one - * assigned automatically. - * @param args to send the applet extra arguments - * @return a pointer to the loaded applet, or 0 on load failure - **/ - static Applet *load(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()); - - /** - * Attempts to load an applet - * - * Returns a pointer to the applet if successful. - * The caller takes responsibility for the applet, including - * deleting it when no longer needed. - * - * @param info KPluginInfo object for the desired applet - * @param appletId unique ID to assign the applet, or zero to have one - * assigned automatically. - * @param args to send the applet extra arguments - * @return a pointer to the loaded applet, or 0 on load failure - **/ - static Applet *load(const KPluginInfo &info, uint appletId = 0, - const QVariantList &args = QVariantList()); - /** * Get the category of the given applet * diff --git a/containment.cpp b/containment.cpp index 54495d80a..e344c6f85 100644 --- a/containment.cpp +++ b/containment.cpp @@ -2165,7 +2165,7 @@ Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &a v->setCursor(Qt::BusyCursor); } - Applet *applet = Applet::load(name, id, args); + Applet *applet = PluginLoader::self()->loadApplet(name, id, args); if (v) { v->unsetCursor(); } diff --git a/corona.cpp b/corona.cpp index acd429190..85a0bd5fd 100644 --- a/corona.cpp +++ b/corona.cpp @@ -41,16 +41,17 @@ #include #include -#include "animator.h" +#include "abstractdialogmanager.h" #include "abstracttoolbox.h" +#include "animator.h" #include "containment.h" #include "containmentactionspluginsconfig.h" -#include "view.h" +#include "pluginloader.h" #include "private/animator_p.h" #include "private/applet_p.h" #include "private/containment_p.h" #include "tooltipmanager.h" -#include "abstractdialogmanager.h" +#include "view.h" using namespace Plasma; @@ -910,7 +911,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi bool loadingNull = pluginName == "null"; if (!loadingNull) { - applet = Applet::load(pluginName, id, args); + applet = PluginLoader::self()->loadApplet(pluginName, id, args); containment = dynamic_cast(applet); } diff --git a/dataengine.cpp b/dataengine.cpp index 1cd964d7e..641dca4ce 100644 --- a/dataengine.cpp +++ b/dataengine.cpp @@ -34,6 +34,7 @@ #include "datacontainer.h" #include "package.h" +#include "pluginloader.h" #include "remote/authorizationmanager.h" #include "remote/authorizationmanager_p.h" #include "service.h" @@ -438,7 +439,7 @@ Service* DataEngine::createDefaultService(QObject *parent) { QVariantList args; args << QVariant::fromValue(this); - return Service::load(d->serviceName, args, parent); + return PluginLoader::self()->loadService(d->serviceName, args, parent); } void DataEnginePrivate::publish(AnnouncementMethods methods, const QString &name) @@ -541,7 +542,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info) const QString path = KStandardDirs::locate("data", "plasma/dataengines/" + dataEngineDescription.pluginName() + '/'); - package = new Package(Package::load("Plasma/DataEngine", api)); + package = new Package(PluginLoader::self()->loadPackage("Plasma/DataEngine", api)); package->setPath(path); if (package->isValid()) { diff --git a/extenders/extender.cpp b/extenders/extender.cpp index 74de8c9f7..1ae51ca5c 100644 --- a/extenders/extender.cpp +++ b/extenders/extender.cpp @@ -35,6 +35,7 @@ #include "extenderitem.h" #include "framesvg.h" #include "paintutils.h" +#include "pluginloader.h" #include "popupapplet.h" #include "svg.h" #include "theme.h" @@ -777,7 +778,7 @@ void ExtenderPrivate::loadExtenderItems() //detachables. if (!sourceApplet) { kDebug() << "creating a temporary applet as factory"; - sourceApplet = Applet::load(appletName); + sourceApplet = PluginLoader::self()->loadApplet(appletName); temporarySourceApplet = true; //TODO: maybe add an option to applet to indicate that it shouldn't be deleted after //having used it as factory. diff --git a/package.cpp b/package.cpp index a9d767e73..daec84cc5 100644 --- a/package.cpp +++ b/package.cpp @@ -116,11 +116,6 @@ bool removeFolder(QString folderPath) #endif // PLASMA_NO_KIO -Package Package::load(const QString &packageFormat, const QString &specialization) -{ - return PluginLoader::self()->loadPackage(packageFormat, specialization); -} - Package::Package(PackageStructure *structure) : d(new PackagePrivate()) { diff --git a/package.h b/package.h index 344bc13da..7421a72ce 100644 --- a/package.h +++ b/package.h @@ -76,16 +76,6 @@ class PackageStructure; class PLASMA_EXPORT Package { public: - /** - * Loads a package format by name. - * - * @param format If not empty, attempts to locate the given format, either - * from built-ins or via plugins. - * @param specialization used to find script extensions for the given format, e.g. "QML" for "Plasma/Applet" - * @return a package that matches the format, if available, or an invalid package if not - */ - static Package load(const QString &format, const QString &specialization = QString()); - /** * Default constructor * diff --git a/pluginloader.h b/pluginloader.h index 092117af5..a1490b638 100644 --- a/pluginloader.h +++ b/pluginloader.h @@ -36,6 +36,7 @@ class Service; class PluginLoaderPrivate; //TODO: +// * add loadWallpaper // * add KPluginInfo listing support for Containments (already loaded via the applet loading code) /** diff --git a/remote/accessappletjob.cpp b/remote/accessappletjob.cpp index a356a3c2b..ff5b40346 100644 --- a/remote/accessappletjob.cpp +++ b/remote/accessappletjob.cpp @@ -19,20 +19,22 @@ #include "accessappletjob.h" -#include "service.h" -#include "servicejob.h" -#include "applet.h" +#include + +#include +#include +#include +#include +#include #include "config-plasma.h" -#include -#include -#include -#include -#include +#include "applet.h" #include "package.h" -#include +#include "pluginloader.h" #include "private/applet_p.h" +#include "service.h" +#include "servicejob.h" namespace Plasma { @@ -74,7 +76,7 @@ public: QString pluginName = job->result().toString(); kDebug() << "Server responded with a pluginname, trying to load: " << pluginName; - applet = Applet::load(pluginName); + applet = PluginLoader::self()->loadApplet(pluginName); if (applet) { applet->d->remoteLocation = location; } else { diff --git a/service.cpp b/service.cpp index 4f468540d..e95079a91 100644 --- a/service.cpp +++ b/service.cpp @@ -64,17 +64,6 @@ Service::~Service() delete d; } -Service *Service::load(const QString &name, QObject *parent) -{ - QVariantList args; - return load(name, args, parent); -} - -Service *Service::load(const QString &name, const QVariantList &args, QObject *parent) -{ - return PluginLoader::self()->loadService(name, args, parent); -} - Service *Service::access(const KUrl &url, QObject *parent) { return new RemoteService(parent, url); diff --git a/service.h b/service.h index b5b1c87e3..0be82f134 100644 --- a/service.h +++ b/service.h @@ -101,28 +101,6 @@ public: */ ~Service(); - /** - * Used to load a given service from a plugin. - * - * @param name the plugin name of the service to load - * @param args a list of arguments to supply to the service plugin when loading it - * @param parent the parent object, if any, for the service - * - * @return a Service object, guaranteed to be not null. - * @since 4.5 - */ - static Service *load(const QString &name, const QVariantList &args, QObject *parent = 0); - - /** - * Used to load a given service from a plugin. - * - * @param name the plugin name of the service to load - * @param parent the parent object, if any, for the service - * - * @return a Service object, guaranteed to be not null. - */ - static Service *load(const QString &name, QObject *parent = 0); - /** * Used to access a service from an url. Always check for the signal serviceReady() that fires * when this service is actually ready for use.