Messagelib
7 #include "dkimmanagerkey.h"
10 #include <KConfigGroup>
11 #include <QRegularExpression>
13 using namespace MessageViewer;
14 DKIMManagerKey::DKIMManagerKey(
QObject *parent)
16 , mQcaInitializer(new QCA::Initializer(QCA::
Practical, 64))
21 DKIMManagerKey::~DKIMManagerKey()
23 delete mQcaInitializer;
35 for (
const KeyInfo &keyInfo : std::as_const(mKeys)) {
36 if (keyInfo.selector == selector && keyInfo.domain == domain) {
37 return keyInfo.keyValue;
43 void DKIMManagerKey::updateLastUsed(
const QString &selector,
const QString &domain)
45 for (
const KeyInfo &keyInfo : std::as_const(mKeys)) {
46 if (keyInfo.selector == selector && keyInfo.domain == domain) {
55 void DKIMManagerKey::addKey(
const KeyInfo &key)
58 for (
const KeyInfo &keyInfo : keys) {
59 if (keyInfo.selector == key.selector && keyInfo.domain == key.domain) {
60 mKeys.removeAll(keyInfo);
66 void DKIMManagerKey::removeKey(
const QString &key)
68 for (
const KeyInfo &keyInfo : std::as_const(mKeys)) {
69 if (keyInfo.keyValue == key) {
70 mKeys.removeAll(keyInfo);
81 QStringList DKIMManagerKey::keyRecorderList(KSharedConfig::Ptr &config)
const
88 void DKIMManagerKey::loadKeys()
91 const QStringList keyGroups = keyRecorderList(config);
94 for (
const QString &groupName : keyGroups) {
104 mKeys.append(
KeyInfo{key, selector, domain, storedAt, lastUsed});
108 void DKIMManagerKey::saveKeys()
110 KSharedConfig::Ptr
config;
111 const QStringList filterGroups = keyRecorderList(config);
113 for (
const QString &group : filterGroups) {
114 config->deleteGroup(group);
116 for (
int i = 0, total = mKeys.count(); i < total; ++i) {
117 const QString groupName = QStringLiteral(
"DKIM Key Record #%1").
arg(i);
119 const KeyInfo &info = mKeys.at(i);
120 group.
writeEntry(QStringLiteral(
"Selector"), info.selector);
121 group.
writeEntry(QStringLiteral(
"Domain"), info.domain);
122 group.
writeEntry(QStringLiteral(
"Key"), info.keyValue);
134 bool KeyInfo::operator==(
const KeyInfo &other)
const
136 return keyValue == other.keyValue && selector == other.selector && domain == other.domain;
139 bool KeyInfo::operator!=(
const KeyInfo &other)
const
141 return !(operator==(other));
146 d <<
" keyvalue " << t.keyValue;
147 d <<
" selector " << t.selector;
148 d <<
" domain " << t.domain;
149 d <<
" storedAtDateTime " << t.storedAtDateTime;
150 d <<
" lastUsedDateTime " << t.lastUsedDateTime;
QString readEntry(const char *key, const char *aDefault=nullptr) const
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QDateTime currentDateTime()
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The DKIMManagerKey class.
QDateTime fromString(const QString &string, Qt::DateFormat format)
KSharedConfigPtr config()
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isValid() const const
QString toString(Qt::DateFormat format) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:14 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.