File indexing completed on 2022-09-27 16:37:28

0001 /*
0002  * SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  */
0007 
0008 #include "job.h"
0009 #include "symmydebug.h"
0010 
0011 #include <QTimer>
0012 
0013 #include <QGpgME/Job>
0014 
0015 namespace Symmy
0016 {
0017 
0018 Job::Job(const QString &passphrase)
0019     : KJob {}
0020     , m_passphrase {passphrase}
0021 {
0022 }
0023 
0024 Job::~Job()
0025 {
0026 }
0027 
0028 char *Job::getPassphrase(const char *, const char *, bool, bool &)
0029 {
0030     char *ret;
0031     gpgrt_asprintf(&ret, "%s", qUtf8Printable(passphrase()));
0032     return ret;
0033 }
0034 
0035 void Job::start()
0036 {
0037     QTimer::singleShot(0, this, &Job::doWork);
0038 }
0039 
0040 bool Job::doKill()
0041 {
0042     if (m_job.isNull()) {
0043         return false;
0044     }
0045 
0046     qCDebug(SYMMY) << "Going to stop" << m_job->metaObject()->className();
0047     m_job->slotCancel();
0048     return true;
0049 }
0050 
0051 void Job::setJob(QGpgME::Job *job)
0052 {
0053     m_job = job;
0054 }
0055 
0056 QString Job::passphrase() const
0057 {
0058     return m_passphrase;
0059 }
0060 
0061 }