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

Make userHasCertificationKey() helper available elsewhere

GnuPG-bug-id: 6102
parent 60498cda
......@@ -212,13 +212,6 @@ void InfoField::onActionChanged()
namespace
{
static bool userHasCertificationKey() {
const auto secretKeys = KeyCache::instance()->secretKeys();
return Kleo::any_of(secretKeys, [](const auto &k) {
return (k.protocol() == GpgME::OpenPGP) && canCreateCertifications(k);
});
}
std::vector<GpgME::UserID> selectedUserIDs(const QTreeWidget *treeWidget) {
if (!treeWidget) {
return {};
......
......@@ -10,6 +10,9 @@
#include "keys.h"
#include <Libkleo/Algorithm>
#include <Libkleo/KeyCache>
#include <QByteArray>
// needed for GPGME_VERSION_NUMBER
......@@ -77,3 +80,11 @@ bool Kleo::isSecretKeyStoredInKeyRing(const GpgME::Key &key)
{
return key.subkey(0).isSecret() && !key.subkey(0).isCardKey();
}
bool Kleo::userHasCertificationKey()
{
const auto secretKeys = KeyCache::instance()->secretKeys();
return Kleo::any_of(secretKeys, [](const auto &k) {
return (k.protocol() == GpgME::OpenPGP) && canCreateCertifications(k);
});
}
......@@ -58,4 +58,12 @@ bool canRevokeUserID(const GpgME::UserID &userId);
*/
bool isSecretKeyStoredInKeyRing(const GpgME::Key &key);
/**
* Returns true if any keys suitable for certifying user IDs are available in
* the keyring or on a smart card.
*
* \sa canCreateCertifications
*/
bool userHasCertificationKey();
}
Supports Markdown
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