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

Add helper to check that a user ID belongs to a key

GnuPG-bug-id: 6115
parent 16cf9a3b
......@@ -115,3 +115,8 @@ bool Kleo::userCanRevokeCertifications(const GpgME::UserID &userId)
return userCanRevokeCertification(certification) == CertificationCanBeRevoked;
});
}
bool Kleo::userIDBelongsToKey(const GpgME::UserID &userID, const GpgME::Key &key)
{
return !qstricmp(userID.parent().primaryFingerprint(), key.primaryFingerprint());
}
......@@ -88,4 +88,19 @@ CertificationRevocationFeasibility userCanRevokeCertification(const GpgME::UserI
*/
bool userCanRevokeCertifications(const GpgME::UserID &userId);
/**
* Returns true, if the user ID \p userID belongs to the key \p key.
*/
bool userIDBelongsToKey(const GpgME::UserID &userID, const GpgME::Key &key);
/**
* Returns a unary predicate to check if a user ID belongs to the key \p key.
*/
inline auto userIDBelongsToKey(const GpgME::Key &key)
{
return [key](const GpgME::UserID &userID) {
return userIDBelongsToKey(userID, key);
};
}
}
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