Plasma
servicejob.cpp
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "servicejob.h" 00021 00022 #include <kdebug.h> 00023 00024 #include <plasma/private/servicejob_p.h> 00025 00026 namespace Plasma 00027 { 00028 00029 ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, 00030 const QString &op, const QMap<QString, QVariant> ¶ms) 00031 : q(owner), 00032 destination(dest), 00033 operation(op), 00034 parameters(params), 00035 m_allowAutoStart(true) 00036 { 00037 } 00038 00039 void ServiceJobPrivate::preventAutoStart() 00040 { 00041 m_allowAutoStart = false; 00042 } 00043 00044 void ServiceJobPrivate::autoStart() 00045 { 00046 if (m_allowAutoStart) { 00047 q->start(); 00048 } 00049 } 00050 00051 ServiceJob::ServiceJob(const QString &destination, const QString &operation, 00052 const QMap<QString, QVariant> ¶meters, QObject *parent) 00053 : KJob(parent), 00054 d(new ServiceJobPrivate(this, destination, operation, parameters)) 00055 { 00056 connect(this, SIGNAL(finished(KJob*)), this, SLOT(preventAutoStart())); 00057 } 00058 00059 ServiceJob::~ServiceJob() 00060 { 00061 delete d; 00062 } 00063 00064 QString ServiceJob::destination() const 00065 { 00066 return d->destination; 00067 } 00068 00069 QString ServiceJob::operationName() const 00070 { 00071 return d->operation; 00072 } 00073 00074 QMap<QString, QVariant> ServiceJob::parameters() const 00075 { 00076 return d->parameters; 00077 } 00078 00079 Credentials ServiceJob::identity() const 00080 { 00081 return d->identity; 00082 } 00083 00084 QVariant ServiceJob::result() const 00085 { 00086 return d->result; 00087 } 00088 00089 void ServiceJob::setResult(const QVariant &result) 00090 { 00091 d->result = result; 00092 emitResult(); 00093 } 00094 00095 void ServiceJob::start() 00096 { 00097 setResult(false); 00098 } 00099 00100 } // namespace Plasma 00101 00102 #include "servicejob.moc" 00103
KDE 4.7 API Reference