Messagelib

dmarcmanager.cpp
1 /*
2  SPDX-FileCopyrightText: 2020-2021 Laurent Montel <[email protected]>
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>
11 using namespace MessageViewer;
12 DMARCManager::DMARCManager()
13 {
14  loadNoServerKeys();
15 }
16 
17 DMARCManager::~DMARCManager()
18 {
19  saveNoServerKeys();
20 }
21 
22 DMARCManager *DMARCManager::self()
23 {
24  static DMARCManager s_self;
25  return &s_self;
26 }
27 
28 bool DMARCManager::isNoDMarcServerAddress(const QString &address) const
29 {
30  return mNoDMarcServer.contains(address);
31 }
32 
33 void DMARCManager::addNoDMarcServerAddress(const QString &address)
34 {
35  if (!mNoDMarcServer.contains(address)) {
36  mNoDMarcServer.append(address);
37  }
38 }
39 
40 void DMARCManager::saveNoServerKeys()
41 {
42  const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
43  KConfigGroup grp(config, "NoExistingDmarcServer");
44  grp.writeEntry("AddressList", mNoDMarcServer);
45 }
46 
47 void DMARCManager::loadNoServerKeys()
48 {
49  const KSharedConfig::Ptr &config = KSharedConfig::openConfig(MessageViewer::DKIMUtil::defaultConfigFileName(), KConfig::NoGlobals);
50  KConfigGroup grp(config, "NoExistingDmarcServer");
51  mNoDMarcServer = grp.readEntry("AddressList", QStringList());
52 }
KSharedConfigPtr config()
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.