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

Add convenience helper for getting url list crypto config entry

GnuPG-bug-id: 5672
parent f9cc52bb
......@@ -40,10 +40,10 @@ int Kleo::getCryptoConfigIntValue(const char *componentName, const char *entryNa
return defaultValue;
}
const CryptoConfigEntry *const entry = getCryptoConfigEntry(config, componentName, entryName);
if (!entry || entry->argType() != CryptoConfigEntry::ArgType_Int) {
return defaultValue;
if (entry && entry->argType() == CryptoConfigEntry::ArgType_Int) {
return entry->intValue();
}
return entry->intValue();
return defaultValue;
}
QString Kleo::getCryptoConfigStringValue(const char *componentName, const char *entryName)
......@@ -63,10 +63,25 @@ QString Kleo::getCryptoConfigStringValue(const char *componentName, const char *
return {};
}
const CryptoConfigEntry *const entry = getCryptoConfigEntry(config, componentName, entryName);
if (!entry || entry->argType() != CryptoConfigEntry::ArgType_String) {
return QString();
if (entry && entry->argType() == CryptoConfigEntry::ArgType_String) {
return entry->stringValue();
}
return {};
}
QList<QUrl> Kleo::getCryptoConfigUrlList(const char *componentName, const char *entryName)
{
const CryptoConfig *const config = cryptoConfig();
if (!config) {
return {};
}
const CryptoConfigEntry *const entry = getCryptoConfigEntry(config, componentName, entryName);
if (entry && entry->isList()
&& (entry->argType() == CryptoConfigEntry::ArgType_LDAPURL
|| entry->argType() == CryptoConfigEntry::ArgType_Path)) {
return entry->urlValueList();
}
return entry->stringValue();
return {};
}
void Kleo::Private::setFakeCryptoConfigIntValue(const std::string &componentName, const std::string &entryName, int fakeValue)
......
......@@ -12,7 +12,10 @@
#include "kleo_export.h"
#include <QList>
class QString;
class QUrl;
namespace Kleo
{
......@@ -21,4 +24,6 @@ KLEO_EXPORT int getCryptoConfigIntValue(const char *componentName, const char *e
KLEO_EXPORT QString getCryptoConfigStringValue(const char *componentName, const char *entryName);
KLEO_EXPORT QList<QUrl> getCryptoConfigUrlList(const char *componentName, const char *entryName);
}
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