Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
57033773
Commit
57033773
authored
Aug 02, 2022
by
Ingo Klöcker
Browse files
Make userHasCertificationKey() helper available elsewhere
GnuPG-bug-id: 6102
parent
60498cda
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/dialogs/certificatedetailswidget.cpp
View file @
57033773
...
...
@@ -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
{};
...
...
src/utils/keys.cpp
View file @
57033773
...
...
@@ -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
);
});
}
src/utils/keys.h
View file @
57033773
...
...
@@ -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
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment