diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index f0a0c8d7..ec5597a0 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -477,7 +477,6 @@ install( Plasma/PackageStructure Plasma/PaintUtils Plasma/Plasma - Plasma/PluginLoader Plasma/PopupApplet Plasma/PushButton Plasma/QueryMatch diff --git a/includes/Plasma/PluginLoader b/includes/Plasma/PluginLoader deleted file mode 100644 index 670d80d4..00000000 --- a/includes/Plasma/PluginLoader +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/pluginloader.h" \ No newline at end of file diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index e5b71818..a1fd4079 100644 --- a/plasma/CMakeLists.txt +++ b/plasma/CMakeLists.txt @@ -43,7 +43,6 @@ set(plasma_LIB_SRCS extenders/extender.cpp extenders/extendergroup.cpp extenders/extenderitem.cpp - pluginloader.cpp paintutils.cpp framesvg.cpp plasma.cpp @@ -156,7 +155,6 @@ install( extenders/extender.h extenders/extendergroup.h extenders/extenderitem.h - pluginloader.h paintutils.h windoweffects.h framesvg.h diff --git a/plasma/applet.cpp b/plasma/applet.cpp index 6d39cd08..b9dcc4f8 100644 --- a/plasma/applet.cpp +++ b/plasma/applet.cpp @@ -41,7 +41,6 @@ #include "tooltipmanager.h" #include "wallpaper.h" #include "paintutils.h" -#include "pluginloader.h" #include "animations/animation.h" #include "private/applet_p.h" #include "private/applethandle_p.h" @@ -1953,7 +1952,21 @@ QString AppletPrivate::parentAppConstraint(const QString &parentApp) KPluginInfo::List Applet::listAppletInfo(const QString &category, const QString &parentApp) { - return PluginLoader::listAppletInfo(category, parentApp); + QString constraint = AppletPrivate::parentAppConstraint(parentApp); + + if (!category.isEmpty()) { + // specific category + constraint.append(" and [X-KDE-PluginInfo-Category] == '").append(category).append("'"); + if (category == "Miscellaneous") { + constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')"); + } + } + + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); + + //kDebug() << "Applet::listAppletInfo constraint was '" << constraint + // << "' which got us " << offers.count() << " matches"; + return KPluginInfo::fromServices(offers); } KPluginInfo::List Applet::listAppletInfoForMimetype(const QString &mimetype) @@ -2026,13 +2039,54 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly) Applet *Applet::load(const QString &appletName, uint appletId, const QVariantList &args) { - return PluginLoader::loadApplet(appletName, appletId, args); + if (appletName.isEmpty()) { + return nullptr; + } + + const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName); + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); + + if (offers.isEmpty()) { + offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); + } + + if (offers.count() > 1) { + kDebug() << "got more than one! blindly taking the first one"; + } + + if (offers.isEmpty()) { + kDebug() << "applet offers is empty for " << appletName; + return 0; + } + + KService::Ptr offer = offers.first(); + + if (appletId == 0) { + appletId = ++AppletPrivate::s_maxAppletId; + } + + QVariantList allArgs; + allArgs << offer->storageId() << appletId << args; + + Applet* applet = nullptr; + QString error; + if (appletName == "internal:extender") { + applet = new ExtenderApplet(nullptr, allArgs); + } else { + applet = offer->createInstance(nullptr, allArgs, &error); + } + + if (!applet) { + kWarning() << "Could not load applet" << appletName << "! reason given:" << error; + } + + return applet; } -Applet *Applet::load(const KPluginInfo &info, uint appletId, const QVariantList &args) +Applet* Applet::load(const KPluginInfo &info, uint appletId, const QVariantList &args) { if (!info.isValid()) { - return 0; + return nullptr; } return load(info.pluginName(), appletId, args); diff --git a/plasma/applet.h b/plasma/applet.h index 622de7f2..59133424 100644 --- a/plasma/applet.h +++ b/plasma/applet.h @@ -979,7 +979,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget friend class ContainmentPrivate; friend class AppletHandle; friend class AppletPrivate; - friend class PluginLoader; friend class PopupApplet; friend class PopupAppletPrivate; friend class AssociatedApplicationManager; diff --git a/plasma/pluginloader.cpp b/plasma/pluginloader.cpp deleted file mode 100644 index 89dc30e6..00000000 --- a/plasma/pluginloader.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2010 Ryan Rix - * - * 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. - */ - -#include "pluginloader.h" - -#include -#include -#include -#include -#include -#include - -#include "applet.h" -#include "abstractrunner.h" -#include "containment.h" -#include "popupapplet.h" -#include "private/applet_p.h" -#include "private/extenderapplet_p.h" - -namespace Plasma { - -Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVariantList &args) -{ - // the application-specific appletLoader failed to create an applet, here we try with our own logic. - if (name.isEmpty()) { - return 0; - } - - const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name); - KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); - - if (offers.isEmpty()) { - offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); - } - - /* if (offers.count() > 1) { - kDebug() << "hey! we got more than one! let's blindly take the first one"; - } */ - - if (offers.isEmpty()) { - kDebug() << "offers is empty for " << name; - return 0; - } - - KService::Ptr offer = offers.first(); - - if (appletId == 0) { - appletId = ++AppletPrivate::s_maxAppletId; - } - - QVariantList allArgs; - allArgs << offer->storageId() << appletId << args; - - Applet *applet = 0; - QString error; - if (name == "internal:extender") { - applet = new ExtenderApplet(0, allArgs); - } else { - applet = offer->createInstance(0, allArgs, &error); - } - - if (!applet) { - kWarning() << "Could not load applet" << name << "! reason given:" << error; - } - - return applet; -} - -AbstractRunner *PluginLoader::loadRunner(const QString &name) -{ - // FIXME: RunnerManager is all wrapped around runner loading; that should be sorted out - // and the actual plugin loading added here - return 0; -} - -KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QString &parentApp) -{ - QString constraint = AppletPrivate::parentAppConstraint(parentApp); - - if (!category.isEmpty()) { - // specific category - constraint.append(" and [X-KDE-PluginInfo-Category] == '").append(category).append("'"); - if (category == "Miscellaneous") { - constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')"); - } - } - - KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); - - //kDebug() << "Applet::listAppletInfo constraint was '" << constraint - // << "' which got us " << offers.count() << " matches"; - return KPluginInfo::fromServices(offers); -} - -KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp) -{ - QString constraint; - if (parentApp.isEmpty()) { - constraint.append("not exist [X-KDE-ParentApp]"); - } else { - constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); - } - - KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner", constraint); - return KPluginInfo::fromServices(offers); -} - -} // Plasma Namespace - diff --git a/plasma/pluginloader.h b/plasma/pluginloader.h deleted file mode 100644 index ec1c7c4b..00000000 --- a/plasma/pluginloader.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2010 by Ryan Rix - * - * 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 PLUGIN_LOADER_H -#define PLUGIN_LOADER_H - -#include -#include - -namespace Plasma { - -class Applet; -class AbstractRunner; - -//TODO: -// * add support for ContainmentActions plugins -// * add KPluginInfo listing support for Containments (already loaded via the applet loading code) - -/** - * This is an abstract base class which defines an interface to which Plasma's - * Applet Loading logic can communicate with a parent application. The plugin loader - * must be set before any plugins are loaded, otherwise (for safety reasons), the - * default PluginLoader implementation will be used. The reimplemented version should - * not do more than simply returning a loaded plugin. It should not init() it, and it should not - * hang on to it. The associated methods will be called only when a component of Plasma - * needs to load a _new_ plugin. - * - * @author Ryan Rix - * @since 4.6 - **/ -class PLASMA_EXPORT PluginLoader -{ -public: - /** - * Load an Applet plugin. - * - * @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 *loadApplet(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()); - - /** - * Load a Runner plugin - * - * @return the Runner that was loaded, or 0 on failure. - */ - static AbstractRunner *loadRunner(const QString &name); - - /** - * Returns a list of all known applets. - * - * @param category Only applets matchin this category will be returned. - * Useful in conjunction with knownCategories. - * If "Misc" is passed in, then applets without a - * Categories= entry are also returned. - * If an empty string is passed in, all applets are - * returned. - * @param parentApp the application to filter applets on. Uses the - * X-KDE-ParentApp entry (if any) in the plugin info. - * The default value of QString() will result in a - * list containing only applets not specifically - * registered to an application. - * @return list of applets - **/ - static KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString()); - - /** - * Returns a list of all known Runner implementations - * - * @param parentApp the application to filter applets on. Uses the - * X-KDE-ParentApp entry (if any) in the plugin info. - * The default value of QString() will result in a - * list containing only applets not specifically - * registered to an application. - * @return list of AbstractRunners - **/ - static KPluginInfo::List listRunnerInfo(const QString &parentApp = QString()); -}; - -} - -#endif diff --git a/plasma/runnermanager.cpp b/plasma/runnermanager.cpp index ec568ef6..ec7c6759 100644 --- a/plasma/runnermanager.cpp +++ b/plasma/runnermanager.cpp @@ -21,7 +21,6 @@ #include "runnermanager.h" #include "private/runnerjobs_p.h" -#include "pluginloader.h" #include "querymatch.h" #include @@ -224,21 +223,13 @@ public: return 0; } - AbstractRunner *runner = PluginLoader::loadRunner(service->property("X-KDE-PluginInfo-Name", QVariant::String).toString()); - - if (runner) { - runner->setParent(q); + QVariantList args; + args << service->storageId(); + QString error; + AbstractRunner *runner = service->createInstance(q, args, &error); + if (!runner) { + kWarning() << "Failed to load runner:" << service->name() << ". error reported:" << error; } else { - QVariantList args; - args << service->storageId(); - QString error; - runner = service->createInstance(q, args, &error); - if (!runner) { - kWarning() << "Failed to load runner:" << service->name() << ". error reported:" << error; - } - } - - if (runner) { kDebug() << "================= loading runner:" << service->name() << "================="; QObject::connect(runner, SIGNAL(matchingSuspended(bool)), q, SLOT(runnerMatchingSuspended(bool))); QMetaObject::invokeMethod(runner, "init"); @@ -512,7 +503,15 @@ QMimeData * RunnerManager::mimeDataForMatch(const QueryMatch &match) const KPluginInfo::List RunnerManager::listRunnerInfo(const QString &parentApp) { - return PluginLoader::listRunnerInfo(parentApp); + QString constraint; + if (parentApp.isEmpty()) { + constraint.append("not exist [X-KDE-ParentApp]"); + } else { + constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); + } + + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner", constraint); + return KPluginInfo::fromServices(offers); } void RunnerManager::setupMatchSession()