File indexing completed on 2024-05-19 05:37:49

0001 /*
0002     SPDX-FileCopyrightText: 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #include "jobaction.h"
0008 
0009 #include <QDebug>
0010 #include <kio/global.h>
0011 #include <klocalizedstring.h>
0012 
0013 void JobAction::start()
0014 {
0015     qDebug() << "Trying to perform the action" << operationName();
0016 
0017     if (!m_job) {
0018         setErrorText(i18nc("%1 is the subject (can be anything) upon which the job is performed", "The JobView for %1 cannot be found", destination()));
0019         setError(-1);
0020         emitResult();
0021         return;
0022     }
0023 
0024     // TODO: check with capabilities before performing actions.
0025     if (operationName() == QLatin1String("resume")) {
0026         m_job->resume();
0027     } else if (operationName() == QLatin1String("suspend")) {
0028         m_job->suspend();
0029     } else if (operationName() == QLatin1String("stop")) {
0030         m_job->kill();
0031     }
0032 
0033     emitResult();
0034 }