Add a whitelist to loadRunners, change canBeConfigured to isConfigurable

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=739989
This commit is contained in:
Ryan P. Bitanga 2007-11-22 09:08:58 +00:00
parent 2fbb4b5fee
commit 72a3b2b68b
2 changed files with 23 additions and 21 deletions

View File

@ -58,12 +58,12 @@ void AbstractRunner::createMatchOptions(QWidget *parent)
Q_UNUSED(parent) Q_UNUSED(parent)
} }
bool AbstractRunner::canBeConfigured() bool AbstractRunner::isConfigurable()
{ {
return d->hasConfig; return d->hasConfig;
} }
void AbstractRunner::setCanBeConfigured(bool hasConfig) void AbstractRunner::setIsConfigurable(bool hasConfig)
{ {
d->hasConfig = hasConfig; d->hasConfig = hasConfig;
} }
@ -78,7 +78,7 @@ void AbstractRunner::exec(Plasma::SearchAction *action)
Q_UNUSED(action) Q_UNUSED(action)
} }
AbstractRunner::List AbstractRunner::loadRunners(QObject* parent) AbstractRunner::List AbstractRunner::loadRunners(QObject* parent, const QStringList& whitelist)
{ {
List firstRunners; List firstRunners;
List runners; List runners;
@ -87,20 +87,22 @@ AbstractRunner::List AbstractRunner::loadRunners(QObject* parent)
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner"); KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner");
QString error; QString error;
foreach (KService::Ptr service, offers) { foreach (KService::Ptr service, offers) {
AbstractRunner* runner = service->createInstance<AbstractRunner>(parent, QVariantList(), &error); if( whitelist.empty() || whitelist.contains( service->name() ) ) {
if (runner) { AbstractRunner* runner = service->createInstance<AbstractRunner>(parent, QVariantList(), &error);
//kDebug() << "loaded runner : " << service->name(); if (runner) {
QString phase = service->property("X-Plasma-RunnerPhase").toString(); //kDebug() << "loaded runner : " << service->name();
if (phase == "last") { QString phase = service->property("X-Plasma-RunnerPhase").toString();
lastRunners.append(runner); if (phase == "last") {
} else if (phase == "first") { lastRunners.append(runner);
firstRunners.append(runner); } else if (phase == "first") {
} else { firstRunners.append(runner);
runners.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;
} }
} }

View File

@ -44,10 +44,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/** /**
* Static method is called to load and get a list available of Runners. * 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 * this constructor can not be called directly. Rather a subclass must
* be created * be created
*/ */
@ -90,10 +90,10 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/** /**
* If the runner itself has configuration options, this method returns true * 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 * a widget displaying the options the user can interact with to modify
* the behaviour of what happens when a given match is selected. * 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 * Sets whether or not the runner has configuration options itself
*/ */
void setCanBeConfigured(bool canBeConfigured); void setIsConfigurable(bool canBeConfigured);
private: private:
class Private; class Private;