File indexing completed on 2023-10-01 04:11:45
0001 /* 0002 SPDX-FileCopyrightText: 2008 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "servicejob.h" 0008 0009 #include <QDebug> 0010 0011 #include "private/servicejob_p.h" 0012 0013 namespace Plasma 0014 { 0015 ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, const QString &op, const QVariantMap ¶ms) 0016 : q(owner) 0017 , destination(dest) 0018 , operation(op) 0019 , parameters(params) 0020 , m_allowAutoStart(true) 0021 { 0022 } 0023 0024 void ServiceJobPrivate::preventAutoStart() 0025 { 0026 m_allowAutoStart = false; 0027 } 0028 0029 void ServiceJobPrivate::autoStart() 0030 { 0031 if (m_allowAutoStart) { 0032 m_allowAutoStart = false; 0033 0034 if (q->isAutoDelete()) { 0035 // by checking for isAutoDelete, we prevent autostarting when 0036 // exec() is called or when the job owner has "taken control" 0037 // of the job by requesting it not be autodeleted 0038 q->start(); 0039 } 0040 } 0041 } 0042 0043 ServiceJob::ServiceJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent) 0044 : KJob(parent) 0045 , d(new ServiceJobPrivate(this, destination, operation, parameters)) 0046 { 0047 connect(this, SIGNAL(finished(KJob *)), this, SLOT(preventAutoStart())); 0048 } 0049 0050 ServiceJob::~ServiceJob() 0051 { 0052 delete d; 0053 } 0054 0055 QString ServiceJob::destination() const 0056 { 0057 return d->destination; 0058 } 0059 0060 QString ServiceJob::operationName() const 0061 { 0062 return d->operation; 0063 } 0064 0065 QVariantMap ServiceJob::parameters() const 0066 { 0067 return d->parameters; 0068 } 0069 0070 QVariant ServiceJob::result() const 0071 { 0072 return d->result; 0073 } 0074 0075 void ServiceJob::setResult(const QVariant &result) 0076 { 0077 d->result = result; 0078 emitResult(); 0079 } 0080 0081 void ServiceJob::start() 0082 { 0083 setResult(false); 0084 } 0085 0086 } // namespace Plasma 0087 0088 #include "moc_servicejob.cpp"