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
15namespace MessageViewer
16{
17/**
18 * @brief The KeyInfo struct
19 * @author Laurent Montel <montel@kde.org>
20 */
21struct MESSAGEVIEWER_EXPORT KeyInfo {
22 KeyInfo() = default;
23
24 KeyInfo(const QString &key, const QString &sel, const QString &dom, const QDateTime &storedAt = {}, const QDateTime &lastUsed = {})
25 : keyValue(key)
26 , selector(sel)
27 , domain(dom)
28 , storedAtDateTime(storedAt)
29 , lastUsedDateTime(lastUsed)
30 {
31 }
32
33 QString keyValue;
34 QString selector;
35 QString domain;
36 QDateTime storedAtDateTime;
37 QDateTime lastUsedDateTime;
38 [[nodiscard]] bool operator==(const KeyInfo &) const;
39 [[nodiscard]] bool operator!=(const KeyInfo &) const;
40};
41
42/**
43 * @brief The DKIMManagerKey class
44 * @author Laurent Montel <montel@kde.org>
45 */
46class MESSAGEVIEWER_EXPORT DKIMManagerKey : public QObject
47{
48 Q_OBJECT
49public:
50 ~DKIMManagerKey() override;
51
52 static DKIMManagerKey *self();
53
54 void loadKeys();
55 void saveKeys(const QList<KeyInfo> &lst);
56
57 void addKey(const KeyInfo &key);
58 void removeKey(const QString &key);
59
60 [[nodiscard]] QList<KeyInfo> keys() const;
61
62 void saveKeys();
63 [[nodiscard]] QString keyValue(const QString &selector, const QString &domain);
64
65 void updateLastUsed(const QString &selector, const QString &domain);
66
67private:
68 explicit DKIMManagerKey(QObject *parent = nullptr);
69 [[nodiscard]] MESSAGEVIEWER_NO_EXPORT QStringList keyRecorderList(KSharedConfig::Ptr &config) const;
70 QList<KeyInfo> mKeys;
71};
72}
73Q_DECLARE_TYPEINFO(MessageViewer::KeyInfo, Q_RELOCATABLE_TYPE);
74Q_DECLARE_METATYPE(MessageViewer::KeyInfo)
75MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::KeyInfo &t);
The DKIMManagerKey class.
The KeyInfo struct.
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.