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

Add class wrapping the key usage flags

Require latest version of libkleo to avoid name clash with KeyUsage
enum.

GnuPG-bug-id: 5832
parent 60f5ac4f
......@@ -34,7 +34,7 @@ set(KF5_MIN_VERSION "5.94.0")
set(KIDENTITYMANAGEMENT_VERSION "5.20.40")
set(KMAILTRANSPORT_VERSION "5.20.40")
set(KMIME_VERSION "5.20.40")
set(LIBKLEO_VERSION "5.20.43")
set(LIBKLEO_VERSION "5.20.44")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.16.0")
......
/* -*- mode: c++; c-basic-offset:4 -*-
utils/keyusage.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QFlags>
namespace Kleo
{
class KeyUsage
{
public:
enum Flag {
Certify = 1,
Sign = 2,
Encrypt = 4,
Authenticate = 8,
};
Q_DECLARE_FLAGS(Flags, Flag)
KeyUsage()
{
}
explicit KeyUsage(Flags flags)
: mFlags{flags}
{
}
void setValue(Flags flags)
{
mFlags = flags;
}
Flags value() const
{
return mFlags;
}
void setCanAuthenticate(bool set)
{
mFlags.setFlag(Authenticate, set);
}
bool canAuthenticate() const
{
return mFlags & Authenticate;
}
void setCanCertify(bool set)
{
mFlags.setFlag(Certify, set);
}
bool canCertify() const
{
return mFlags & Certify;
}
void setCanEncrypt(bool set)
{
mFlags.setFlag(Encrypt, set);
}
bool canEncrypt() const
{
return mFlags & Encrypt;
}
void setCanSign(bool set)
{
mFlags.setFlag(Sign, set);
}
bool canSign() const
{
return mFlags & Sign;
}
private:
Flags mFlags;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyUsage::Flags)
}
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