2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* 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 "servicejob.h"
|
2011-04-28 22:45:19 +02:00
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <plasma/private/servicejob_p.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest,
|
2011-05-26 19:01:44 +02:00
|
|
|
const QString &op, const QHash<QString, QVariant> ¶ms)
|
2008-11-04 00:08:39 +01:00
|
|
|
: q(owner),
|
|
|
|
destination(dest),
|
|
|
|
operation(op),
|
2011-04-28 22:45:19 +02:00
|
|
|
parameters(params),
|
|
|
|
m_allowAutoStart(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceJobPrivate::preventAutoStart()
|
2009-09-02 04:27:16 +02:00
|
|
|
{
|
2011-04-28 22:45:19 +02:00
|
|
|
m_allowAutoStart = false;
|
2009-09-02 04:27:16 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-04-28 18:01:16 +02:00
|
|
|
void ServiceJobPrivate::autoStart()
|
2009-09-02 04:27:16 +02:00
|
|
|
{
|
2011-04-28 22:45:19 +02:00
|
|
|
if (m_allowAutoStart) {
|
2012-09-23 11:23:35 +02:00
|
|
|
m_allowAutoStart = false;
|
|
|
|
|
|
|
|
if (q->isAutoDelete()) {
|
|
|
|
// by checking for isAutoDelete, we prevent autostarting when
|
|
|
|
// exec() is called or when the job owner has "taken control"
|
|
|
|
// of the job by requesting it not be autodeleted
|
|
|
|
q->start();
|
|
|
|
}
|
2011-04-28 22:45:19 +02:00
|
|
|
}
|
2009-09-02 04:27:16 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
ServiceJob::ServiceJob(const QString &destination, const QString &operation,
|
2011-05-26 19:01:44 +02:00
|
|
|
const QHash<QString, QVariant> ¶meters, QObject *parent)
|
2008-11-04 00:08:39 +01:00
|
|
|
: KJob(parent),
|
|
|
|
d(new ServiceJobPrivate(this, destination, operation, parameters))
|
|
|
|
{
|
2011-04-28 22:45:19 +02:00
|
|
|
connect(this, SIGNAL(finished(KJob*)), this, SLOT(preventAutoStart()));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ServiceJob::~ServiceJob()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ServiceJob::destination() const
|
|
|
|
{
|
|
|
|
return d->destination;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ServiceJob::operationName() const
|
|
|
|
{
|
|
|
|
return d->operation;
|
|
|
|
}
|
|
|
|
|
2011-05-26 19:01:44 +02:00
|
|
|
QHash<QString, QVariant> ServiceJob::parameters() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
return d->parameters;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant ServiceJob::result() const
|
|
|
|
{
|
|
|
|
return d->result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceJob::setResult(const QVariant &result)
|
|
|
|
{
|
|
|
|
d->result = result;
|
|
|
|
emitResult();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceJob::start()
|
|
|
|
{
|
|
|
|
setResult(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
|
2012-02-08 23:33:03 +01:00
|
|
|
|
|
|
|
#include "moc_servicejob.cpp"
|