Messagelib

dkimmanagerkey.h
1 /*
2  SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "messageviewer_export.h"
10 #include <KSharedConfig>
11 #include <QDateTime>
12 #include <QList>
13 #include <QObject>
14 namespace QCA
15 {
16 class Initializer;
17 }
18 namespace MessageViewer
19 {
20 /**
21  * @brief The KeyInfo struct
22  * @author Laurent Montel <montel@kde.org>
23  */
24 struct MESSAGEVIEWER_EXPORT KeyInfo {
25  KeyInfo() = default;
26 
27  KeyInfo(const QString &key, const QString &sel, const QString &dom, const QDateTime &storedAt = {}, const QDateTime &lastUsed = {})
28  : keyValue(key)
29  , selector(sel)
30  , domain(dom)
31  , storedAtDateTime(storedAt)
32  , lastUsedDateTime(lastUsed)
33  {
34  }
35 
36  QString keyValue;
37  QString selector;
38  QString domain;
39  QDateTime storedAtDateTime;
40  QDateTime lastUsedDateTime;
41  [[nodiscard]] bool operator==(const KeyInfo &) const;
42  [[nodiscard]] bool operator!=(const KeyInfo &) const;
43 };
44 
45 /**
46  * @brief The DKIMManagerKey class
47  * @author Laurent Montel <montel@kde.org>
48  */
49 class MESSAGEVIEWER_EXPORT DKIMManagerKey : public QObject
50 {
51  Q_OBJECT
52 public:
53  explicit DKIMManagerKey(QObject *parent = nullptr);
54  ~DKIMManagerKey() override;
55 
56  static DKIMManagerKey *self();
57 
58  void loadKeys();
59  void saveKeys(const QList<KeyInfo> &lst);
60 
61  void addKey(const KeyInfo &key);
62  void removeKey(const QString &key);
63 
64  [[nodiscard]] QList<KeyInfo> keys() const;
65 
66  void saveKeys();
67  [[nodiscard]] QString keyValue(const QString &selector, const QString &domain);
68 
69  void updateLastUsed(const QString &selector, const QString &domain);
70 
71 private:
72  [[nodiscard]] MESSAGEVIEWER_NO_EXPORT QStringList keyRecorderList(KSharedConfig::Ptr &config) const;
73  QList<KeyInfo> mKeys;
74  QCA::Initializer *const mQcaInitializer;
75 };
76 }
77 Q_DECLARE_TYPEINFO(MessageViewer::KeyInfo, Q_RELOCATABLE_TYPE);
78 Q_DECLARE_METATYPE(MessageViewer::KeyInfo)
79 MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::KeyInfo &t);
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
The KeyInfo struct.
The DKIMManagerKey class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.