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

Add compatibility helper for new CryptoConfig::entry() overload

GnuPG-bug-id: 5217
parent b782b9fd
......@@ -43,6 +43,7 @@ set(libkleo_core_SRCS
utils/gnupg.cpp
utils/gnupg-registry.c
utils/hex.cpp
utils/compat.cpp
)
ecm_qt_declare_logging_category(libkleo_core_SRCS HEADER libkleo_debug.h IDENTIFIER LIBKLEO_LOG CATEGORY_NAME org.kde.pim.libkleo
DESCRIPTION "libkleo (kleo_core)"
......@@ -171,6 +172,7 @@ ecm_generate_headers(libkleo_CamelCase_utils_HEADERS
FileSystemWatcher
Formatting
GnuPG
Compat
REQUIRED_HEADERS libkleo_utils_HEADERS
PREFIX Libkleo
RELATIVE utils
......
/*
utils/compat.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 "compat.h"
#include <QGpgME/CryptoConfig>
#include <gpgme++/gpgmepp_version.h>
#if GPGMEPP_VERSION >= 0x10F02 // 1.15.2
# define CRYPTOCONFIG_HAS_GROUPLESS_ENTRY_OVERLOAD
#endif
using namespace QGpgME;
QGpgME::CryptoConfigEntry *Kleo::getCryptoConfigEntry(const CryptoConfig *config, const char *componentName, const char *entryName)
{
#ifdef CRYPTOCONFIG_HAS_GROUPLESS_ENTRY_OVERLOAD
return config->entry(QString::fromLatin1(componentName), QString::fromLatin1(entryName));
#else
const CryptoConfigComponent *const comp = config->component(QString::fromLatin1(componentName));
const QStringList groupNames = comp->groupList();
for (const auto &groupName : groupNames) {
const CryptoConfigGroup *const group = comp ? comp->group(groupName) : nullptr;
if (CryptoConfigEntry *const entry = group->entry(QString::fromLatin1(entryName))) {
return entry;
}
}
return nullptr;
#endif
}
/*
utils/compat.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_COMPAT_H
#define LIBKLEO_COMPAT_H
#include "kleo_export.h"
namespace QGpgME
{
class CryptoConfig;
class CryptoConfigEntry;
}
namespace Kleo
{
KLEO_EXPORT QGpgME::CryptoConfigEntry *getCryptoConfigEntry(const QGpgME::CryptoConfig *config, const char *componentName, const char *entryName);
}
#endif // LIBKLEO_COMPAT_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