Make file tasks restartable

Restarting file tasks makes sense when we offer to import / certify
certificates from the file result view.
parent b88b06b5
......@@ -364,7 +364,6 @@ void AutoDecryptVerifyFilesController::cancel()
void AutoDecryptVerifyFilesController::doTaskDone(const Task *task, const std::shared_ptr<const Task::Result> &result)
{
assert(task);
assert(task == d->m_runningTask.get());
Q_UNUSED(task);
// We could just delete the tasks here, but we can't use
......
......@@ -200,7 +200,6 @@ void DecryptVerifyFilesController::Private::slotWizardCanceled()
void DecryptVerifyFilesController::doTaskDone(const Task *task, const std::shared_ptr<const Task::Result> &result)
{
assert(task);
assert(task == d->m_runningTask.get());
Q_UNUSED(task);
// We could just delete the tasks here, but we can't use
......
......@@ -1030,6 +1030,16 @@ void DecryptVerifyTask::cancel()
}
static void ensureIOOpen(QIODevice *input, QIODevice *output)
{
if (input && !input->isOpen()) {
input->open(QIODevice::ReadOnly);
}
if (output && !output->isOpen()) {
output->open(QIODevice::WriteOnly);
}
}
void DecryptVerifyTask::doStart()
{
kleo_assert(d->m_backend);
......@@ -1037,6 +1047,7 @@ void DecryptVerifyTask::doStart()
QGpgME::DecryptVerifyJob *const job = d->m_backend->decryptVerifyJob();
kleo_assert(job);
d->registerJob(job);
ensureIOOpen(d->m_input->ioDevice().get(), d->m_output->ioDevice().get());
job->start(d->m_input->ioDevice(), d->m_output->ioDevice());
} catch (const GpgME::Exception &e) {
d->emitResult(fromDecryptVerifyResult(e.error(), QString::fromLocal8Bit(e.what()), AuditLog()));
......@@ -1193,6 +1204,7 @@ void DecryptTask::doStart()
QGpgME::DecryptJob *const job = d->m_backend->decryptJob();
kleo_assert(job);
d->registerJob(job);
ensureIOOpen(d->m_input->ioDevice().get(), d->m_output->ioDevice().get());
job->start(d->m_input->ioDevice(), d->m_output->ioDevice());
} catch (const GpgME::Exception &e) {
d->emitResult(fromDecryptResult(e.error(), QString::fromLocal8Bit(e.what()), AuditLog()));
......@@ -1347,6 +1359,7 @@ void VerifyOpaqueTask::doStart()
QGpgME::VerifyOpaqueJob *const job = d->m_backend->verifyOpaqueJob();
kleo_assert(job);
d->registerJob(job);
ensureIOOpen(d->m_input->ioDevice().get(), d->m_output ? d->m_output->ioDevice().get() : nullptr);
job->start(d->m_input->ioDevice(), d->m_output ? d->m_output->ioDevice() : std::shared_ptr<QIODevice>());
} catch (const GpgME::Exception &e) {
d->emitResult(fromVerifyOpaqueResult(e.error(), QString::fromLocal8Bit(e.what()), AuditLog()));
......@@ -1500,6 +1513,8 @@ void VerifyDetachedTask::doStart()
QGpgME::VerifyDetachedJob *const job = d->m_backend->verifyDetachedJob();
kleo_assert(job);
d->registerJob(job);
ensureIOOpen(d->m_input->ioDevice().get(), nullptr);
ensureIOOpen(d->m_signedData->ioDevice().get(), nullptr);
job->start(d->m_input->ioDevice(), d->m_signedData->ioDevice());
} catch (const GpgME::Exception &e) {
d->emitResult(fromVerifyDetachedResult(e.error(), QString::fromLocal8Bit(e.what()), AuditLog()));
......
......@@ -133,7 +133,6 @@ void DecryptVerifyFilesDialog::allDone()
Q_ASSERT(m_tasks);
m_progressBar->setRange(0, 100);
m_progressBar->setValue(100);
m_tasks.reset();
Q_FOREACH (const QString &i, m_progressLabelByTag.keys()) {
if (!i.isEmpty()) {
m_progressLabelByTag.value(i)->setText(i18n("%1: All operations completed.", i));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment