Messagelib

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

KDE's Doxygen guidelines are available online.