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

Use same protocol for key lookup as for key selection

Restrict the key lookup triggered from the certificate selection dialog
to the protocol set for the certificate selection.

GnuPG-bug-id: 5688
parent 20653bdc
Pipeline #100876 passed with stage
in 14 minutes and 42 seconds
......@@ -186,6 +186,16 @@ LookupCertificatesCommand::~LookupCertificatesCommand()
qCDebug(KLEOPATRA_LOG);
}
void LookupCertificatesCommand::setProtocol(GpgME::Protocol protocol)
{
d->protocol = protocol;
}
GpgME::Protocol LookupCertificatesCommand::protocol() const
{
return d->protocol;
}
void LookupCertificatesCommand::doStart()
{
......
......@@ -11,6 +11,8 @@
#include <commands/importcertificatescommand.h>
#include <gpgme++/global.h>
namespace Kleo
{
namespace Commands
......@@ -25,6 +27,9 @@ public:
explicit LookupCertificatesCommand(const QString &fingerPrint, KeyListController *parent);
~LookupCertificatesCommand() override;
void setProtocol(GpgME::Protocol protocol);
GpgME::Protocol protocol() const;
private:
void doStart() override;
void doCancel() override;
......
......@@ -67,6 +67,21 @@ CertificateSelectionDialog::Option CertificateSelectionDialog::optionsFromProtoc
}
}
namespace
{
auto protocolFromOptions(CertificateSelectionDialog::Options options)
{
switch (options & CertificateSelectionDialog::AnyFormat) {
case CertificateSelectionDialog::OpenPGPFormat:
return GpgME::OpenPGP;
case CertificateSelectionDialog::CMSFormat:
return GpgME::CMS;
default:
return GpgME::UnknownProtocol;
}
}
}
class CertificateSelectionDialog::Private
{
friend class ::Kleo::Dialogs::CertificateSelectionDialog;
......@@ -85,15 +100,14 @@ private:
{
auto cmd = new NewCertificateCommand(nullptr);
cmd->setParentWidget(q);
if ((options & AnyFormat) != AnyFormat) {
cmd->setProtocol((options & OpenPGPFormat) ? OpenPGP : CMS);
}
cmd->setProtocol(protocolFromOptions(options));
cmd->start();
}
void lookup()
{
Command *const cmd = new LookupCertificatesCommand(nullptr);
const auto cmd = new LookupCertificatesCommand(nullptr);
cmd->setParentWidget(q);
cmd->setProtocol(protocolFromOptions(options));
cmd->start();
}
void manageGroups()
......
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