2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
2009-01-22 15:23:34 +01:00
|
|
|
* Copyright (C) 2007, 2009 Ryan P. Bitanga <ryan.bitanga@gmail.com>
|
|
|
|
* Copyright (C) 2008 Jordi Polo <mumismo@gmail.com>
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* 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 "runnermanager.h"
|
|
|
|
|
2010-04-29 07:57:34 +02:00
|
|
|
#include "config-plasma.h"
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
2008-11-04 03:04:34 +01:00
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kplugininfo.h>
|
|
|
|
#include <kservicetypetrader.h>
|
|
|
|
#include <kstandarddirs.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2010-04-29 07:57:34 +02:00
|
|
|
#ifndef PLASMA_NO_SOLID
|
2008-11-04 03:04:34 +01:00
|
|
|
#include <solid/device.h>
|
|
|
|
#include <solid/deviceinterface.h>
|
2010-04-29 07:57:34 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2008-11-04 03:55:37 +01:00
|
|
|
#include <Weaver/DebuggingAids.h>
|
2009-11-25 02:54:44 +01:00
|
|
|
#include <Weaver/State.h>
|
2008-11-04 03:55:37 +01:00
|
|
|
#include <Weaver/Thread.h>
|
|
|
|
#include <Weaver/ThreadWeaver.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-11-25 02:54:44 +01:00
|
|
|
#include "private/runnerjobs_p.h"
|
2010-07-28 20:19:00 +02:00
|
|
|
#include "pluginloader.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
#include "querymatch.h"
|
|
|
|
|
|
|
|
using ThreadWeaver::Weaver;
|
|
|
|
using ThreadWeaver::Job;
|
|
|
|
|
2010-02-17 19:26:28 +01:00
|
|
|
//#define MEASURE_PREPTIME
|
2010-02-09 00:39:05 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* RunnerManager::Private class
|
|
|
|
*
|
|
|
|
*****************************************************/
|
|
|
|
class RunnerManagerPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RunnerManagerPrivate(RunnerManager *parent)
|
|
|
|
: q(parent),
|
2009-07-28 05:36:06 +02:00
|
|
|
deferredRun(0),
|
2009-11-25 23:31:56 +01:00
|
|
|
currentSingleRunner(0),
|
2009-07-30 20:14:40 +02:00
|
|
|
prepped(false),
|
2009-11-26 02:52:23 +01:00
|
|
|
allRunnersPrepped(false),
|
|
|
|
singleRunnerPrepped(false),
|
|
|
|
teardownRequested(false),
|
|
|
|
singleMode(false),
|
|
|
|
singleRunnerWasLoaded(false)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
matchChangeTimer.setSingleShot(true);
|
2009-02-11 12:16:09 +01:00
|
|
|
delayTimer.setSingleShot(true);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
QObject::connect(&matchChangeTimer, SIGNAL(timeout()), q, SLOT(matchesChanged()));
|
|
|
|
QObject::connect(&context, SIGNAL(matchesChanged()), q, SLOT(scheduleMatchesChanged()));
|
2009-02-11 12:16:09 +01:00
|
|
|
QObject::connect(&delayTimer, SIGNAL(timeout()), q, SLOT(unblockJobs()));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-05-13 21:18:30 +02:00
|
|
|
~RunnerManagerPrivate()
|
|
|
|
{
|
2009-09-08 00:36:04 +02:00
|
|
|
KConfigGroup config = configGroup();
|
2009-05-13 22:51:03 +02:00
|
|
|
context.save(config);
|
2009-05-13 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void scheduleMatchesChanged()
|
|
|
|
{
|
2010-05-19 06:22:18 +02:00
|
|
|
matchChangeTimer.start(100);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void matchesChanged()
|
|
|
|
{
|
|
|
|
emit q->matchesChanged(context.matches());
|
|
|
|
}
|
|
|
|
|
2009-09-08 00:36:04 +02:00
|
|
|
void loadConfiguration()
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2009-09-08 00:36:04 +02:00
|
|
|
KConfigGroup config = configGroup();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
//The number of threads used scales with the number of processors.
|
2010-04-29 07:57:34 +02:00
|
|
|
#ifndef PLASMA_NO_SOLID
|
2008-11-04 00:08:39 +01:00
|
|
|
const int numProcs =
|
|
|
|
qMax(Solid::Device::listFromType(Solid::DeviceInterface::Processor).count(), 1);
|
2010-04-29 07:57:34 +02:00
|
|
|
#else
|
|
|
|
const int numProcs = 1;
|
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
//This entry allows to define a hard upper limit independent of the number of processors.
|
|
|
|
const int maxThreads = config.readEntry("maxThreads", 16);
|
|
|
|
const int numThreads = qMin(maxThreads, 2 + ((numProcs - 1) * 2));
|
|
|
|
//kDebug() << "setting up" << numThreads << "threads for" << numProcs << "processors";
|
2009-03-12 23:04:01 +01:00
|
|
|
if (numThreads > Weaver::instance()->maximumNumberOfThreads()) {
|
|
|
|
Weaver::instance()->setMaximumNumberOfThreads(numThreads);
|
|
|
|
}
|
2009-01-22 15:23:34 +01:00
|
|
|
// Limit the number of instances of a single normal speed runner and all of the slow runners
|
|
|
|
// to half the number of threads
|
|
|
|
const int cap = qMax(2, numThreads/2);
|
|
|
|
DefaultRunnerPolicy::instance().setCap(cap);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-05-13 22:51:03 +02:00
|
|
|
context.restore(config);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-09-08 00:36:04 +02:00
|
|
|
KConfigGroup configGroup()
|
|
|
|
{
|
|
|
|
return conf.isValid() ? conf : KConfigGroup(KGlobal::config(), "PlasmaRunnerManager");
|
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
void clearSingleRunner()
|
2009-11-25 23:31:56 +01:00
|
|
|
{
|
2009-11-26 02:52:23 +01:00
|
|
|
if (singleRunnerWasLoaded) {
|
|
|
|
delete currentSingleRunner;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
currentSingleRunner = 0;
|
2009-11-26 02:52:23 +01:00
|
|
|
}
|
2009-11-25 23:31:56 +01:00
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
void loadSingleRunner()
|
|
|
|
{
|
2009-12-13 15:13:00 +01:00
|
|
|
if (!singleMode || singleModeRunnerId.isEmpty()) {
|
2009-11-26 02:52:23 +01:00
|
|
|
clearSingleRunner();
|
|
|
|
return;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
if (currentSingleRunner) {
|
|
|
|
if (currentSingleRunner->id() == singleModeRunnerId) {
|
|
|
|
return;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
2009-11-26 02:52:23 +01:00
|
|
|
|
|
|
|
clearSingleRunner();
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
AbstractRunner *loadedRunner = q->runner(singleModeRunnerId);
|
|
|
|
if (loadedRunner) {
|
|
|
|
singleRunnerWasLoaded = false;
|
|
|
|
currentSingleRunner = loadedRunner;
|
|
|
|
return;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner", QString("[X-KDE-PluginInfo-Name] == '%1'").arg(singleModeRunnerId));
|
|
|
|
if (!offers.isEmpty()) {
|
|
|
|
const KService::Ptr &service = offers[0];
|
2010-03-23 23:43:34 +01:00
|
|
|
currentSingleRunner = loadInstalledRunner(service);
|
2009-11-26 02:52:23 +01:00
|
|
|
|
|
|
|
if (currentSingleRunner) {
|
|
|
|
emit currentSingleRunner->prepare();
|
|
|
|
singleRunnerWasLoaded = true;
|
|
|
|
}
|
|
|
|
}
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void loadRunners()
|
|
|
|
{
|
2009-09-08 00:36:04 +02:00
|
|
|
KConfigGroup config = configGroup();
|
2010-07-28 20:19:00 +02:00
|
|
|
KPluginInfo::List offers = RunnerManager::listRunnerInfo();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-10-14 07:50:17 +02:00
|
|
|
const bool loadAll = config.readEntry("loadAll", false);
|
2011-11-22 12:20:14 +01:00
|
|
|
const QStringList whiteList = config.readEntry("pluginWhiteList", QStringList());
|
2009-10-14 07:50:17 +02:00
|
|
|
const bool noWhiteList = whiteList.isEmpty();
|
|
|
|
KConfigGroup pluginConf;
|
|
|
|
if (conf.isValid()) {
|
|
|
|
pluginConf = KConfigGroup(&conf, "Plugins");
|
|
|
|
} else {
|
|
|
|
pluginConf = KConfigGroup(KGlobal::config(), "Plugins");
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-12-13 15:57:06 +01:00
|
|
|
advertiseSingleRunnerIds.clear();
|
2009-11-25 23:31:56 +01:00
|
|
|
|
2011-11-22 12:17:06 +01:00
|
|
|
QSet<AbstractRunner *> deadRunners;
|
2010-07-28 20:19:00 +02:00
|
|
|
QMutableListIterator<KPluginInfo> it(offers);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
KPluginInfo &description = it.next();
|
2008-11-04 00:08:39 +01:00
|
|
|
//kDebug() << "Loading runner: " << service->name() << service->storageId();
|
2010-07-28 20:19:00 +02:00
|
|
|
QString tryExec = description.property("TryExec").toString();
|
2009-03-30 05:41:11 +02:00
|
|
|
//kDebug() << "TryExec is" << tryExec;
|
2008-11-04 00:08:39 +01:00
|
|
|
if (!tryExec.isEmpty() && KStandardDirs::findExe(tryExec).isEmpty()) {
|
|
|
|
// we don't actually have this application!
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-03-23 23:43:34 +01:00
|
|
|
const QString runnerName = description.pluginName();
|
2009-09-08 00:36:04 +02:00
|
|
|
description.load(pluginConf);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-10-14 07:50:17 +02:00
|
|
|
const bool loaded = runners.contains(runnerName);
|
2011-11-22 12:20:14 +01:00
|
|
|
const bool selected = loadAll || (description.isPluginEnabled() && (noWhiteList || whiteList.contains(runnerName)));
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2010-07-28 20:19:00 +02:00
|
|
|
const bool singleQueryModeEnabled = description.property("X-Plasma-AdvertiseSingleRunnerQueryMode").toBool();
|
2009-11-25 10:37:47 +01:00
|
|
|
|
2009-11-25 23:31:56 +01:00
|
|
|
if (singleQueryModeEnabled) {
|
2009-12-13 15:57:06 +01:00
|
|
|
advertiseSingleRunnerIds.insert(runnerName, description.name());
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-10-14 07:50:17 +02:00
|
|
|
//kDebug() << loadAll << description.isPluginEnabled() << noWhiteList << whiteList.contains(runnerName);
|
2008-11-04 00:08:39 +01:00
|
|
|
if (selected) {
|
|
|
|
if (!loaded) {
|
2010-07-28 20:19:00 +02:00
|
|
|
AbstractRunner *runner = loadInstalledRunner(description.service());
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
if (runner) {
|
|
|
|
runners.insert(runnerName, runner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (loaded) {
|
|
|
|
//Remove runner
|
2011-11-22 12:17:06 +01:00
|
|
|
deadRunners.insert(runners.take(runnerName));
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2008-11-04 00:08:39 +01:00
|
|
|
kDebug() << "Removing runner: " << runnerName;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2011-11-22 12:17:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!deadRunners.isEmpty()) {
|
|
|
|
QSet<FindMatchesJob *> deadJobs;
|
|
|
|
foreach (FindMatchesJob *job, searchJobs) {
|
|
|
|
if (deadRunners.contains(job->runner())) {
|
|
|
|
QObject::disconnect(job, SIGNAL(done(ThreadWeaver::Job*)), q, SLOT(jobDone(ThreadWeaver::Job*)));
|
|
|
|
searchJobs.remove(job);
|
|
|
|
deadJobs.insert(job);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (FindMatchesJob *job, oldSearchJobs) {
|
|
|
|
if (deadRunners.contains(job->runner())) {
|
|
|
|
oldSearchJobs.remove(job);
|
|
|
|
deadJobs.insert(job);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deadJobs.isEmpty()) {
|
|
|
|
qDeleteAll(deadRunners);
|
|
|
|
} else {
|
|
|
|
new DelayedJobCleaner(deadJobs, deadRunners);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2008-11-04 00:08:39 +01:00
|
|
|
kDebug() << "All runners loaded, total:" << runners.count();
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2010-03-23 23:43:34 +01:00
|
|
|
AbstractRunner *loadInstalledRunner(const KService::Ptr service)
|
|
|
|
{
|
2010-07-28 20:19:00 +02:00
|
|
|
if (!service) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-19 21:53:03 +02:00
|
|
|
AbstractRunner *runner = PluginLoader::self()->loadRunner(service->property("X-KDE-PluginInfo-Name", QVariant::String).toString());
|
2010-07-28 20:19:00 +02:00
|
|
|
|
|
|
|
if (runner) {
|
|
|
|
runner->setParent(q);
|
|
|
|
} else {
|
|
|
|
const QString api = service->property("X-Plasma-API").toString();
|
|
|
|
|
|
|
|
if (api.isEmpty()) {
|
|
|
|
QVariantList args;
|
|
|
|
args << service->storageId();
|
|
|
|
if (Plasma::isPluginVersionCompatible(KPluginLoader(*service).pluginVersion())) {
|
|
|
|
QString error;
|
|
|
|
runner = service->createInstance<AbstractRunner>(q, args, &error);
|
|
|
|
if (!runner) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2010-07-28 20:19:00 +02:00
|
|
|
kDebug() << "Failed to load runner:" << service->name() << ". error reported:" << error;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-07-28 20:19:00 +02:00
|
|
|
}
|
2010-03-23 23:43:34 +01:00
|
|
|
}
|
2010-07-28 20:19:00 +02:00
|
|
|
} else {
|
|
|
|
//kDebug() << "got a script runner known as" << api;
|
|
|
|
runner = new AbstractRunner(service, q);
|
2010-03-23 23:43:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runner) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2010-03-23 23:43:34 +01:00
|
|
|
kDebug() << "================= loading runner:" << service->name() << "=================";
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-03 00:18:03 +02:00
|
|
|
QObject::connect(runner, SIGNAL(matchingSuspended(bool)), q, SLOT(runnerMatchingSuspended(bool)));
|
2011-05-20 09:01:36 +02:00
|
|
|
runner->init();
|
2010-03-23 23:43:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return runner;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void jobDone(ThreadWeaver::Job *job)
|
|
|
|
{
|
2009-03-12 23:01:22 +01:00
|
|
|
FindMatchesJob *runJob = dynamic_cast<FindMatchesJob *>(job);
|
2009-03-12 21:25:52 +01:00
|
|
|
|
|
|
|
if (!runJob) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (deferredRun.isEnabled() && runJob->runner() == deferredRun.runner()) {
|
|
|
|
//kDebug() << "job actually done, running now **************";
|
2009-03-03 03:07:19 +01:00
|
|
|
QueryMatch tmpRun = deferredRun;
|
2009-10-09 11:33:20 +02:00
|
|
|
deferredRun = QueryMatch(0);
|
2009-03-03 03:07:19 +01:00
|
|
|
tmpRun.run(context);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
2009-03-12 19:53:22 +01:00
|
|
|
|
|
|
|
searchJobs.remove(runJob);
|
|
|
|
oldSearchJobs.remove(runJob);
|
2009-10-09 11:33:20 +02:00
|
|
|
runJob->deleteLater();
|
2009-03-12 19:53:22 +01:00
|
|
|
|
|
|
|
if (searchJobs.isEmpty() && context.matches().isEmpty()) {
|
|
|
|
// we finished our run, and there are no valid matches, and so no
|
|
|
|
// signal will have been sent out. so we need to emit the signal
|
|
|
|
// ourselves here
|
|
|
|
emit q->matchesChanged(context.matches());
|
|
|
|
}
|
2009-07-30 20:14:40 +02:00
|
|
|
|
|
|
|
checkTearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkTearDown()
|
|
|
|
{
|
|
|
|
//kDebug() << prepped << teardownRequested << searchJobs.count() << oldSearchJobs.count();
|
|
|
|
|
|
|
|
if (!prepped || !teardownRequested) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-25 02:54:44 +01:00
|
|
|
if (Weaver::instance()->isIdle()) {
|
|
|
|
qDeleteAll(searchJobs);
|
|
|
|
searchJobs.clear();
|
|
|
|
qDeleteAll(oldSearchJobs);
|
|
|
|
oldSearchJobs.clear();
|
|
|
|
}
|
|
|
|
|
2009-07-30 20:14:40 +02:00
|
|
|
if (searchJobs.isEmpty() && oldSearchJobs.isEmpty()) {
|
2009-11-26 02:52:23 +01:00
|
|
|
if (allRunnersPrepped) {
|
|
|
|
foreach (AbstractRunner *runner, runners) {
|
|
|
|
emit runner->teardown();
|
|
|
|
}
|
|
|
|
|
|
|
|
allRunnersPrepped = false;
|
2009-07-30 20:14:40 +02:00
|
|
|
}
|
2009-11-26 02:52:23 +01:00
|
|
|
|
|
|
|
if (singleRunnerPrepped) {
|
|
|
|
if (currentSingleRunner) {
|
|
|
|
emit currentSingleRunner->teardown();
|
|
|
|
}
|
|
|
|
|
|
|
|
singleRunnerPrepped = false;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
2009-07-30 20:14:40 +02:00
|
|
|
|
2010-01-16 02:20:35 +01:00
|
|
|
emit q->queryFinished();
|
|
|
|
|
2009-07-30 20:14:40 +02:00
|
|
|
prepped = false;
|
|
|
|
teardownRequested = false;
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-02-11 12:16:09 +01:00
|
|
|
void unblockJobs()
|
|
|
|
{
|
|
|
|
// WORKAROUND: Queue an empty job to force ThreadWeaver to awaken threads
|
2009-11-25 02:54:44 +01:00
|
|
|
if (searchJobs.isEmpty() && Weaver::instance()->isIdle()) {
|
|
|
|
qDeleteAll(oldSearchJobs);
|
|
|
|
oldSearchJobs.clear();
|
|
|
|
checkTearDown();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-11 12:16:09 +01:00
|
|
|
DummyJob *dummy = new DummyJob(q);
|
|
|
|
Weaver::instance()->enqueue(dummy);
|
|
|
|
QObject::connect(dummy, SIGNAL(done(ThreadWeaver::Job*)), dummy, SLOT(deleteLater()));
|
|
|
|
}
|
|
|
|
|
2010-09-03 00:18:03 +02:00
|
|
|
void runnerMatchingSuspended(bool suspended)
|
|
|
|
{
|
|
|
|
if (suspended || !prepped || teardownRequested) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AbstractRunner *runner = qobject_cast<AbstractRunner *>(q->sender());
|
|
|
|
|
|
|
|
if (runner) {
|
|
|
|
startJob(runner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void startJob(AbstractRunner *runner)
|
|
|
|
{
|
|
|
|
if ((runner->ignoredTypes() & context.type()) == 0) {
|
|
|
|
FindMatchesJob *job = new FindMatchesJob(runner, &context, Weaver::instance());
|
|
|
|
QObject::connect(job, SIGNAL(done(ThreadWeaver::Job*)), q, SLOT(jobDone(ThreadWeaver::Job*)));
|
|
|
|
if (runner->speed() == AbstractRunner::SlowSpeed) {
|
|
|
|
job->setDelayTimer(&delayTimer);
|
|
|
|
}
|
|
|
|
Weaver::instance()->enqueue(job);
|
|
|
|
searchJobs.insert(job);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-11 12:16:09 +01:00
|
|
|
// Delay in ms before slow runners are allowed to run
|
|
|
|
static const int slowRunDelay = 400;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
RunnerManager *q;
|
|
|
|
QueryMatch deferredRun;
|
|
|
|
RunnerContext context;
|
|
|
|
QTimer matchChangeTimer;
|
2009-02-11 12:16:09 +01:00
|
|
|
QTimer delayTimer; // Timer to control when to run slow runners
|
2008-11-04 00:08:39 +01:00
|
|
|
QHash<QString, AbstractRunner*> runners;
|
2009-12-13 15:57:06 +01:00
|
|
|
QHash<QString, QString> advertiseSingleRunnerIds;
|
2009-11-25 23:31:56 +01:00
|
|
|
AbstractRunner* currentSingleRunner;
|
2009-03-12 19:53:22 +01:00
|
|
|
QSet<FindMatchesJob*> searchJobs;
|
|
|
|
QSet<FindMatchesJob*> oldSearchJobs;
|
2009-09-08 00:36:04 +02:00
|
|
|
KConfigGroup conf;
|
2009-11-26 02:52:23 +01:00
|
|
|
QString singleModeRunnerId;
|
2009-07-28 05:36:06 +02:00
|
|
|
bool loadAll : 1;
|
|
|
|
bool prepped : 1;
|
2009-11-26 02:52:23 +01:00
|
|
|
bool allRunnersPrepped : 1;
|
|
|
|
bool singleRunnerPrepped : 1;
|
2009-07-30 20:14:40 +02:00
|
|
|
bool teardownRequested : 1;
|
2009-11-26 02:52:23 +01:00
|
|
|
bool singleMode : 1;
|
|
|
|
bool singleRunnerWasLoaded : 1;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* RunnerManager::Public class
|
|
|
|
*
|
|
|
|
*****************************************************/
|
|
|
|
RunnerManager::RunnerManager(QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new RunnerManagerPrivate(this))
|
|
|
|
{
|
2009-09-08 00:36:04 +02:00
|
|
|
d->loadConfiguration();
|
2008-11-04 00:08:39 +01:00
|
|
|
//ThreadWeaver::setDebugLevel(true, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
RunnerManager::RunnerManager(KConfigGroup &c, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new RunnerManagerPrivate(this))
|
|
|
|
{
|
|
|
|
// Should this be really needed? Maybe d->loadConfiguration(c) would make
|
|
|
|
// more sense.
|
2009-09-08 00:36:04 +02:00
|
|
|
d->conf = KConfigGroup(&c, "PlasmaRunnerManager");
|
|
|
|
d->loadConfiguration();
|
2008-11-04 00:08:39 +01:00
|
|
|
//ThreadWeaver::setDebugLevel(true, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
RunnerManager::~RunnerManager()
|
|
|
|
{
|
2009-03-13 00:25:45 +01:00
|
|
|
if (!qApp->closingDown() && (!d->searchJobs.isEmpty() || !d->oldSearchJobs.isEmpty())) {
|
2011-11-22 12:17:06 +01:00
|
|
|
new DelayedJobCleaner(d->searchJobs + d->oldSearchJobs);
|
2009-03-12 21:25:52 +01:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::reloadConfiguration()
|
|
|
|
{
|
2009-09-08 00:36:04 +02:00
|
|
|
d->loadConfiguration();
|
2008-11-04 00:08:39 +01:00
|
|
|
d->loadRunners();
|
|
|
|
}
|
|
|
|
|
2009-09-08 00:36:04 +02:00
|
|
|
void RunnerManager::setAllowedRunners(const QStringList &runners)
|
|
|
|
{
|
|
|
|
KConfigGroup config = d->configGroup();
|
2009-09-11 00:26:14 +02:00
|
|
|
config.writeEntry("pluginWhiteList", runners);
|
2011-11-22 12:17:06 +01:00
|
|
|
|
|
|
|
if (!d->runners.isEmpty()) {
|
|
|
|
// this has been called with runners already created. so let's do an instant reload
|
|
|
|
d->loadRunners();
|
|
|
|
}
|
2009-09-08 00:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList RunnerManager::allowedRunners() const
|
|
|
|
{
|
|
|
|
KConfigGroup config = d->configGroup();
|
2009-09-11 00:26:14 +02:00
|
|
|
return config.readEntry("pluginWhiteList", QStringList());
|
2009-09-08 00:36:04 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 23:43:34 +01:00
|
|
|
void RunnerManager::loadRunner(const KService::Ptr service)
|
|
|
|
{
|
|
|
|
KPluginInfo description(service);
|
|
|
|
const QString runnerName = description.pluginName();
|
|
|
|
if (!runnerName.isEmpty() && !d->runners.contains(runnerName)) {
|
|
|
|
AbstractRunner *runner = d->loadInstalledRunner(service);
|
|
|
|
if (runner) {
|
|
|
|
d->runners.insert(runnerName, runner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::loadRunner(const QString &path)
|
|
|
|
{
|
|
|
|
if (!d->runners.contains(path)) {
|
|
|
|
AbstractRunner *runner = new AbstractRunner(this, path);
|
2010-09-03 00:18:03 +02:00
|
|
|
connect(runner, SIGNAL(matchingSuspended(bool)), this, SLOT(runnerMatchingSuspended(bool)));
|
2010-07-28 20:19:00 +02:00
|
|
|
d->runners.insert(path, runner);
|
2010-03-23 23:43:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-22 15:23:34 +01:00
|
|
|
AbstractRunner* RunnerManager::runner(const QString &name) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
if (d->runners.isEmpty()) {
|
|
|
|
d->loadRunners();
|
|
|
|
}
|
|
|
|
|
2008-12-11 03:50:06 +01:00
|
|
|
return d->runners.value(name, 0);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
AbstractRunner *RunnerManager::singleModeRunner() const
|
|
|
|
{
|
|
|
|
return d->currentSingleRunner;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::setSingleModeRunnerId(const QString &id)
|
|
|
|
{
|
|
|
|
d->singleModeRunnerId = id;
|
|
|
|
d->loadSingleRunner();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString RunnerManager::singleModeRunnerId() const
|
2009-11-25 23:31:56 +01:00
|
|
|
{
|
2009-11-26 02:52:23 +01:00
|
|
|
return d->singleModeRunnerId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RunnerManager::singleMode() const
|
|
|
|
{
|
|
|
|
return d->singleMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::setSingleMode(bool singleMode)
|
|
|
|
{
|
|
|
|
if (d->singleMode == singleMode) {
|
|
|
|
return;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 03:38:16 +01:00
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
Plasma::AbstractRunner *prevSingleRunner = d->currentSingleRunner;
|
|
|
|
d->singleMode = singleMode;
|
|
|
|
d->loadSingleRunner();
|
|
|
|
d->singleMode = d->currentSingleRunner;
|
|
|
|
|
|
|
|
if (prevSingleRunner != d->currentSingleRunner) {
|
|
|
|
if (d->prepped) {
|
|
|
|
matchSessionComplete();
|
2009-11-26 03:38:16 +01:00
|
|
|
|
|
|
|
if (d->singleMode) {
|
|
|
|
setupMatchSession();
|
|
|
|
}
|
2009-11-26 02:52:23 +01:00
|
|
|
}
|
|
|
|
}
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
2009-03-25 02:08:08 +01:00
|
|
|
QList<AbstractRunner *> RunnerManager::runners() const
|
|
|
|
{
|
|
|
|
return d->runners.values();
|
|
|
|
}
|
|
|
|
|
2009-12-13 15:57:06 +01:00
|
|
|
QStringList RunnerManager::singleModeAdvertisedRunnerIds() const
|
2009-11-25 23:31:56 +01:00
|
|
|
{
|
2009-12-13 15:57:06 +01:00
|
|
|
return d->advertiseSingleRunnerIds.keys();
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString RunnerManager::runnerName(const QString &id) const
|
2009-11-25 10:37:47 +01:00
|
|
|
{
|
2009-11-25 23:31:56 +01:00
|
|
|
if (runner(id)) {
|
|
|
|
return runner(id)->name();
|
|
|
|
} else {
|
2009-12-13 15:57:06 +01:00
|
|
|
return d->advertiseSingleRunnerIds.value(id, QString());
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
2009-11-25 10:37:47 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 15:23:34 +01:00
|
|
|
RunnerContext* RunnerManager::searchContext() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
return &d->context;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Reordering is here so data is not reordered till strictly needed
|
|
|
|
QList<QueryMatch> RunnerManager::matches() const
|
|
|
|
{
|
|
|
|
return d->context.matches();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::run(const QString &id)
|
|
|
|
{
|
|
|
|
run(d->context.match(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::run(const QueryMatch &match)
|
|
|
|
{
|
|
|
|
if (!match.isEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: this function is not const as it may be used for learning
|
|
|
|
AbstractRunner *runner = match.runner();
|
|
|
|
|
|
|
|
foreach (FindMatchesJob *job, d->searchJobs) {
|
2009-03-12 19:53:22 +01:00
|
|
|
if (job->runner() == runner && !job->isFinished()) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2009-03-12 19:53:22 +01:00
|
|
|
kDebug() << "deferred run";
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
d->deferredRun = match;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->deferredRun.isValid()) {
|
|
|
|
d->deferredRun = QueryMatch(0);
|
2009-03-03 09:02:13 +01:00
|
|
|
}
|
2009-03-03 03:07:19 +01:00
|
|
|
|
2009-05-13 21:18:30 +02:00
|
|
|
d->context.run(match);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
|
|
|
{
|
|
|
|
AbstractRunner *runner = match.runner();
|
|
|
|
if (runner) {
|
|
|
|
return runner->actionsForMatch(match);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QList<QAction*>();
|
|
|
|
}
|
|
|
|
|
2010-02-21 18:06:10 +01:00
|
|
|
QMimeData * RunnerManager::mimeDataForMatch(const QString &id) const
|
|
|
|
{
|
|
|
|
return mimeDataForMatch(d->context.match(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMimeData * RunnerManager::mimeDataForMatch(const QueryMatch &match) const
|
|
|
|
{
|
|
|
|
AbstractRunner *runner = match.runner();
|
2011-05-20 09:01:36 +02:00
|
|
|
if (runner) {
|
|
|
|
return runner->mimeDataForMatch(match);
|
2010-02-21 18:06:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-28 20:19:00 +02:00
|
|
|
KPluginInfo::List RunnerManager::listRunnerInfo(const QString &parentApp)
|
|
|
|
{
|
2011-07-19 21:53:03 +02:00
|
|
|
return PluginLoader::self()->listRunnerInfo(parentApp);
|
2010-07-28 20:19:00 +02:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:36:06 +02:00
|
|
|
void RunnerManager::setupMatchSession()
|
|
|
|
{
|
2009-07-30 20:14:40 +02:00
|
|
|
d->teardownRequested = false;
|
|
|
|
|
2009-07-28 05:36:06 +02:00
|
|
|
if (d->prepped) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-28 12:03:16 +02:00
|
|
|
d->prepped = true;
|
2009-11-26 02:52:23 +01:00
|
|
|
if (d->singleMode) {
|
|
|
|
if (d->currentSingleRunner) {
|
|
|
|
emit d->currentSingleRunner->prepare();
|
|
|
|
d->singleRunnerPrepped = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (AbstractRunner *runner, d->runners) {
|
2010-02-09 00:39:05 +01:00
|
|
|
#ifdef MEASURE_PREPTIME
|
|
|
|
QTime t;
|
|
|
|
t.start();
|
|
|
|
#endif
|
2009-11-26 02:52:23 +01:00
|
|
|
emit runner->prepare();
|
2010-02-09 00:39:05 +01:00
|
|
|
#ifdef MEASURE_PREPTIME
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2010-02-09 00:39:05 +01:00
|
|
|
kDebug() << t.elapsed() << runner->name();
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-02-09 00:39:05 +01:00
|
|
|
#endif
|
2009-11-26 02:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
d->allRunnersPrepped = true;
|
2009-11-25 23:31:56 +01:00
|
|
|
}
|
2009-07-28 05:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::matchSessionComplete()
|
|
|
|
{
|
|
|
|
if (!d->prepped) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-30 20:14:40 +02:00
|
|
|
d->teardownRequested = true;
|
|
|
|
d->checkTearDown();
|
2009-07-28 05:36:06 +02:00
|
|
|
}
|
|
|
|
|
2009-02-01 14:59:09 +01:00
|
|
|
void RunnerManager::launchQuery(const QString &term)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2009-02-01 14:59:09 +01:00
|
|
|
launchQuery(term, QString());
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-04-03 19:12:53 +02:00
|
|
|
void RunnerManager::launchQuery(const QString &untrimmedTerm, const QString &runnerName)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2009-07-28 05:36:06 +02:00
|
|
|
setupMatchSession();
|
2009-04-03 19:12:53 +02:00
|
|
|
QString term = untrimmedTerm.trimmed();
|
|
|
|
|
2009-12-13 14:49:22 +01:00
|
|
|
setSingleModeRunnerId(runnerName);
|
|
|
|
setSingleMode(!runnerName.isEmpty());
|
2009-11-25 10:37:47 +01:00
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
if (term.isEmpty()) {
|
|
|
|
if (d->singleMode && d->currentSingleRunner && d->currentSingleRunner->defaultSyntax()) {
|
|
|
|
term = d->currentSingleRunner->defaultSyntax()->exampleQueries().first().remove(QRegExp(":q:"));
|
|
|
|
} else {
|
|
|
|
reset();
|
|
|
|
return;
|
|
|
|
}
|
2009-11-25 10:37:47 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 02:52:23 +01:00
|
|
|
if (d->context.query() == term) {
|
|
|
|
// we already are searching for this!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->singleMode && !d->currentSingleRunner) {
|
2008-11-04 00:08:39 +01:00
|
|
|
reset();
|
2009-02-01 14:59:09 +01:00
|
|
|
return;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-10-01 02:58:24 +02:00
|
|
|
if (d->runners.isEmpty()) {
|
|
|
|
d->loadRunners();
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
reset();
|
|
|
|
// kDebug() << "runners searching for" << term << "on" << runnerName;
|
|
|
|
d->context.setQuery(term);
|
|
|
|
|
2010-04-04 20:15:51 +02:00
|
|
|
QHash<QString, AbstractRunner*> runable;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
//if the name is not empty we will launch only the specified runner
|
2009-11-26 02:52:23 +01:00
|
|
|
if (d->singleMode && d->currentSingleRunner) {
|
2010-04-04 20:15:51 +02:00
|
|
|
runable.insert(QString(), d->currentSingleRunner);
|
2009-11-25 10:37:47 +01:00
|
|
|
d->context.setSingleRunnerQueryMode(true);
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
2010-04-04 20:15:51 +02:00
|
|
|
runable = d->runners;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (Plasma::AbstractRunner *r, runable) {
|
2010-09-03 00:18:03 +02:00
|
|
|
if (r->isMatchingSuspended()) {
|
|
|
|
continue;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
2010-09-03 00:18:03 +02:00
|
|
|
|
|
|
|
d->startJob(r);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
2009-11-26 02:52:23 +01:00
|
|
|
|
2009-02-11 12:16:09 +01:00
|
|
|
// Start timer to unblock slow runners
|
|
|
|
d->delayTimer.start(RunnerManagerPrivate::slowRunDelay);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RunnerManager::execQuery(const QString &term)
|
|
|
|
{
|
|
|
|
return execQuery(term, QString());
|
|
|
|
}
|
|
|
|
|
2009-04-03 19:12:53 +02:00
|
|
|
bool RunnerManager::execQuery(const QString &untrimmedTerm, const QString &runnerName)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2009-04-03 19:12:53 +02:00
|
|
|
QString term = untrimmedTerm.trimmed();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (term.isEmpty()) {
|
|
|
|
reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-10-01 02:58:24 +02:00
|
|
|
if (d->runners.isEmpty()) {
|
|
|
|
d->loadRunners();
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (d->context.query() == term) {
|
|
|
|
// we already are searching for this!
|
|
|
|
emit matchesChanged(d->context.matches());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
reset();
|
|
|
|
//kDebug() << "executing query about " << term << "on" << runnerName;
|
|
|
|
d->context.setQuery(term);
|
|
|
|
AbstractRunner *r = runner(runnerName);
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
//kDebug() << "failed to find the runner";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((r->ignoredTypes() & d->context.type()) != 0) {
|
|
|
|
//kDebug() << "ignored!";
|
|
|
|
return false;
|
|
|
|
}
|
2009-03-12 19:53:22 +01:00
|
|
|
|
2009-03-05 07:02:11 +01:00
|
|
|
r->performMatch(d->context);
|
2008-11-04 00:08:39 +01:00
|
|
|
//kDebug() << "succeeded with" << d->context.matches().count() << "results";
|
|
|
|
emit matchesChanged(d->context.matches());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString RunnerManager::query() const
|
|
|
|
{
|
|
|
|
return d->context.query();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunnerManager::reset()
|
|
|
|
{
|
|
|
|
// If ThreadWeaver is idle, it is safe to clear previous jobs
|
|
|
|
if (Weaver::instance()->isIdle()) {
|
|
|
|
qDeleteAll(d->searchJobs);
|
2009-03-12 19:53:22 +01:00
|
|
|
qDeleteAll(d->oldSearchJobs);
|
2009-03-12 19:54:57 +01:00
|
|
|
d->oldSearchJobs.clear();
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
Weaver::instance()->dequeue();
|
2009-03-12 19:53:22 +01:00
|
|
|
d->oldSearchJobs += d->searchJobs;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 19:53:22 +01:00
|
|
|
d->searchJobs.clear();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (d->deferredRun.isEnabled()) {
|
|
|
|
//kDebug() << "job actually done, running now **************";
|
2009-03-03 03:07:19 +01:00
|
|
|
QueryMatch tmpRun = d->deferredRun;
|
2008-11-04 00:08:39 +01:00
|
|
|
d->deferredRun = QueryMatch(0);
|
2009-03-03 03:07:19 +01:00
|
|
|
tmpRun.run(d->context);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
d->context.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
2012-02-08 23:33:03 +01:00
|
|
|
|
|
|
|
#include "moc_runnermanager.cpp"
|