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

Add value class representing a group of keys

GnuPG-bug-id: 5175, 5238
parent 1ceb831d
......@@ -25,6 +25,7 @@ set(libkleo_core_SRCS
kleo/enum.cpp
kleo/kconfigbasedkeyfilter.cpp
kleo/keyfiltermanager.cpp
kleo/keygroup.cpp
kleo/keyresolver.cpp
kleo/kleoexception.cpp
kleo/oidmap.cpp
......@@ -136,6 +137,7 @@ ecm_generate_headers(libkleo_CamelCase_HEADERS
KConfigBasedKeyFilter
KeyFilter
KeyFilterManager
KeyGroup
KeyResolver
KleoException
OidMap
......
/*
kleo/keygroup.cpp
This file is part of libkleopatra, the KDE keymanagement library
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "keygroup.h"
#include <QString>
#include <gpgme++/key.h>
using namespace Kleo;
using namespace GpgME;
class KeyGroup::Private
{
public:
explicit Private(const QString &name, const std::vector<GpgME::Key> &keys);
QString name;
std::vector<Key> keys;
};
KeyGroup::Private::Private(const QString &name_, const std::vector<GpgME::Key> &keys_)
: name(name_)
, keys(keys_)
{
}
KeyGroup::KeyGroup()
: KeyGroup(QString(), {})
{
}
KeyGroup::~KeyGroup() = default;
KeyGroup::KeyGroup(const QString &name, const std::vector<GpgME::Key> &keys)
: d(new Private(name, keys))
{
}
KeyGroup::KeyGroup(const KeyGroup &other)
: d(new Private(*other.d))
{
}
KeyGroup &KeyGroup::operator=(const KeyGroup &other)
{
*d = *other.d;
return *this;
}
KeyGroup::KeyGroup(KeyGroup &&other) = default;
KeyGroup &KeyGroup::operator=(KeyGroup &&other) = default;
bool KeyGroup::isNull() const
{
return !d || d->name.isEmpty();
}
QString KeyGroup::name() const
{
return d ? d->name : QString();
}
std::vector<Key> Kleo::KeyGroup::keys() const
{
return d ? d->keys : std::vector<Key>();
}
/*
kleo/keygroup.h
This file is part of libkleopatra, the KDE keymanagement library
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef LIBKLEO_KEYGROUP_H
#define LIBKLEO_KEYGROUP_H
#include "kleo_export.h"
#include <memory>
#include <vector>
class QString;
namespace GpgME
{
class Key;
}
namespace Kleo
{
class KLEO_EXPORT KeyGroup
{
public:
KeyGroup();
~KeyGroup();
explicit KeyGroup(const QString &name, const std::vector<GpgME::Key> &keys);
KeyGroup(const KeyGroup &other);
KeyGroup &operator=(const KeyGroup &other);
KeyGroup(KeyGroup &&other);
KeyGroup &operator=(KeyGroup &&other);
bool isNull() const;
QString name() const;
std::vector<GpgME::Key> keys() const;
private:
class Private;
std::unique_ptr<Private> d;
};
}
#endif // LIBKLEO_KEYGROUP_H
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