Commit 53810860 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Add protocol and type of import to the import results

This makes it more easy to perform special post-processing of OpenPGP keys
and X.509 certificates imported from a local source (file, clipboard)
or an external source, i.e. a keyserver.

GnuPG-bug-id: 5638
parent 836adc09
......@@ -128,7 +128,7 @@ void ImportCertificateFromFileCommand::doStart()
QFile in(fn);
if (!in.open(QIODevice::ReadOnly)) {
d->error(i18n("Could not open file %1 for reading: %2", in.fileName(), in.errorString()), i18n("Certificate Import Failed"));
d->importResult({fn, ImportResult{}});
d->importResult({fn, GpgME::UnknownProtocol, ImportType::Local, ImportResult{}});
continue;
}
const auto data = in.readAll();
......
......@@ -442,7 +442,7 @@ void ImportCertificatesCommand::Private::importResult(const ImportResult &result
const auto job = *it;
jobs.erase(std::remove(std::begin(jobs), std::end(jobs), job), std::end(jobs));
importResult({job.id, result});
importResult({job.id, job.protocol, job.type, result});
}
void ImportCertificatesCommand::Private::importResult(const ImportResultData &result)
......@@ -628,7 +628,7 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
error(i18n("The type of this certificate (%1) is not supported by this Kleopatra installation.",
Formatting::displayName(protocol)),
i18n("Certificate Import Failed"));
importResult({id, ImportResult{}});
importResult({id, protocol, ImportType::Local, ImportResult{}});
return;
}
......@@ -640,9 +640,9 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
q, &Command::progress);
const GpgME::Error err = job->start(data);
if (err.code()) {
importResult({id, ImportResult{err}});
importResult({id, protocol, ImportType::Local, ImportResult{err}});
} else {
jobs.push_back({id, job.release()});
jobs.push_back({id, protocol, ImportType::Local, job.release()});
}
}
......@@ -670,7 +670,7 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
error(i18n("The type of this certificate (%1) is not supported by this Kleopatra installation.",
Formatting::displayName(protocol)),
i18n("Certificate Import Failed"));
importResult({id, ImportResult{}});
importResult({id, protocol, ImportType::External, ImportResult{}});
return;
}
......@@ -682,9 +682,9 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
q, &Command::progress);
const GpgME::Error err = job->start(keys);
if (err.code()) {
importResult({id, ImportResult{err}});
importResult({id, protocol, ImportType::External, ImportResult{err}});
} else {
jobs.push_back({id, job.release()});
jobs.push_back({id, protocol, ImportType::External, job.release()});
}
}
......
......@@ -37,9 +37,17 @@ class KeyCacheAutoRefreshSuspension;
class QByteArray;
enum class ImportType
{
Local,
External,
};
struct ImportJobData
{
QString id;
GpgME::Protocol protocol;
ImportType type;
QGpgME::AbstractImportJob *job;
};
......@@ -48,6 +56,8 @@ bool operator==(const ImportJobData &lhs, const ImportJobData &rhs);
struct ImportResultData
{
QString id;
GpgME::Protocol protocol;
ImportType type;
GpgME::ImportResult result;
};
......
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