Commit c6458d14 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code

parent fc686c0c
Pipeline #22346 passed with stage
in 42 minutes and 51 seconds
......@@ -80,11 +80,18 @@ QVector<KeyInfo> DKIMManagerKey::keys() const
return mKeys;
}
void DKIMManagerKey::loadKeys()
QStringList DKIMManagerKey::keyRecorderList(KSharedConfig::Ptr &config) const
{
const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
const QStringList keyGroups
= config->groupList().filter(QRegularExpression(QStringLiteral("DKIM Key Record #\\d+")));
return keyGroups;
}
void DKIMManagerKey::loadKeys()
{
KSharedConfig::Ptr config;
const QStringList keyGroups = keyRecorderList(config);
mKeys.clear();
for (const QString &groupName : keyGroups) {
......@@ -98,9 +105,8 @@ void DKIMManagerKey::loadKeys()
void DKIMManagerKey::saveKeys()
{
const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
const QStringList filterGroups
= config->groupList().filter(QRegularExpression(QStringLiteral("DKIM Key Record #\\d+")));
KSharedConfig::Ptr config;
const QStringList filterGroups = keyRecorderList(config);
for (const QString &group : filterGroups) {
config->deleteGroup(group);
......
......@@ -24,6 +24,7 @@
#include "messageviewer_export.h"
#include "config-messageviewer.h"
#include <QVector>
#include <KSharedConfig>
namespace QCA {
class Initializer;
}
......@@ -75,6 +76,7 @@ public:
void saveKeys();
Q_REQUIRED_RESULT QString keyValue(const QString &selector, const QString &domain);
private:
Q_REQUIRED_RESULT QStringList keyRecorderList(KSharedConfig::Ptr &config) const;
QVector<KeyInfo> mKeys;
QCA::Initializer *mQcaInitializer = nullptr;
};
......
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