From 72a3b2b68b47fd9edd5b06d5a7ecba2d06e16a16 Mon Sep 17 00:00:00 2001 From: "Ryan P. Bitanga" Date: Thu, 22 Nov 2007 09:08:58 +0000 Subject: [PATCH] Add a whitelist to loadRunners, change canBeConfigured to isConfigurable svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=739989 --- abstractrunner.cpp | 34 ++++++++++++++++++---------------- abstractrunner.h | 10 +++++----- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/abstractrunner.cpp b/abstractrunner.cpp index 38ccdbca4..f40c235bf 100644 --- a/abstractrunner.cpp +++ b/abstractrunner.cpp @@ -58,12 +58,12 @@ void AbstractRunner::createMatchOptions(QWidget *parent) Q_UNUSED(parent) } -bool AbstractRunner::canBeConfigured() +bool AbstractRunner::isConfigurable() { return d->hasConfig; } -void AbstractRunner::setCanBeConfigured(bool hasConfig) +void AbstractRunner::setIsConfigurable(bool hasConfig) { d->hasConfig = hasConfig; } @@ -78,7 +78,7 @@ void AbstractRunner::exec(Plasma::SearchAction *action) Q_UNUSED(action) } -AbstractRunner::List AbstractRunner::loadRunners(QObject* parent) +AbstractRunner::List AbstractRunner::loadRunners(QObject* parent, const QStringList& whitelist) { List firstRunners; List runners; @@ -87,20 +87,22 @@ AbstractRunner::List AbstractRunner::loadRunners(QObject* parent) KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner"); QString error; foreach (KService::Ptr service, offers) { - AbstractRunner* runner = service->createInstance(parent, QVariantList(), &error); - if (runner) { - //kDebug() << "loaded runner : " << service->name(); - QString phase = service->property("X-Plasma-RunnerPhase").toString(); - if (phase == "last") { - lastRunners.append(runner); - } else if (phase == "first") { - firstRunners.append(runner); - } else { - runners.append(runner); + if( whitelist.empty() || whitelist.contains( service->name() ) ) { + AbstractRunner* runner = service->createInstance(parent, QVariantList(), &error); + if (runner) { + //kDebug() << "loaded runner : " << service->name(); + QString phase = service->property("X-Plasma-RunnerPhase").toString(); + if (phase == "last") { + lastRunners.append(runner); + } else if (phase == "first") { + firstRunners.append(runner); + } else { + runners.append(runner); + } + } + else { + kDebug() << "failed to load runner : " << service->name() << ". error reported: " << error; } - } - else { - kDebug() << "failed to load runner : " << service->name() << ". error reported: " << error; } } diff --git a/abstractrunner.h b/abstractrunner.h index 3b290457b..aad8790aa 100644 --- a/abstractrunner.h +++ b/abstractrunner.h @@ -44,10 +44,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject /** * Static method is called to load and get a list available of Runners. */ - static List loadRunners(QObject* parent); + static List loadRunners(QObject* parent, const QStringList& whitelist = QStringList() ); /** - * Constrcuts an Runner object. Since AbstractRunner has pure virtuals, + * Constructs a Runner object. Since AbstractRunner has pure virtuals, * this constructor can not be called directly. Rather a subclass must * be created */ @@ -90,10 +90,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject /** * If the runner itself has configuration options, this method returns true */ - bool canBeConfigured(); + bool isConfigurable(); /** - * If canBeConfigured() returns true, this method may to get + * If isConfigurable() returns true, this method may to get * a widget displaying the options the user can interact with to modify * the behaviour of what happens when a given match is selected. * @@ -116,7 +116,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject /** * Sets whether or not the runner has configuration options itself */ - void setCanBeConfigured(bool canBeConfigured); + void setIsConfigurable(bool canBeConfigured); private: class Private;