Messagelib

dmarcmanager.cpp
1/*
2 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dmarcmanager.h"
8#include "dkimutil.h"
9#include <KConfigGroup>
10#include <KSharedConfig>
11using namespace MessageViewer;
12DMARCManager::DMARCManager()
13{
14 loadNoServerKeys();
15}
16
17DMARCManager::~DMARCManager()
18{
19 saveNoServerKeys();
20}
21
22DMARCManager *DMARCManager::self()
23{
24 static DMARCManager s_self;
25 return &s_self;
26}
27
28bool DMARCManager::isNoDMarcServerAddress(const QString &address) const
29{
30 return mNoDMarcServer.contains(address);
31}
32
33void DMARCManager::addNoDMarcServerAddress(const QString &address)
34{
35 if (!mNoDMarcServer.contains(address)) {
36 mNoDMarcServer.append(address);
37 }
38}
39
40void DMARCManager::saveNoServerKeys()
41{
42 const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
43 KConfigGroup grp(config, QStringLiteral("NoExistingDmarcServer"));
44 grp.writeEntry("AddressList", mNoDMarcServer);
45}
46
47void DMARCManager::loadNoServerKeys()
48{
49 const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
50 KConfigGroup grp(config, QStringLiteral("NoExistingDmarcServer"));
51 mNoDMarcServer = grp.readEntry("AddressList", QStringList());
52}
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
void append(QList< T > &&value)
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.