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>
14namespace QCA
15{
16class Initializer;
17}
18namespace MessageViewer
19{
20/**
21 * @brief The KeyInfo struct
22 * @author Laurent Montel <montel@kde.org>
23 */
24struct 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 */
49class MESSAGEVIEWER_EXPORT DKIMManagerKey : public QObject
50{
51 Q_OBJECT
52public:
53 ~DKIMManagerKey() override;
54
55 static DKIMManagerKey *self();
56
57 void loadKeys();
58 void saveKeys(const QList<KeyInfo> &lst);
59
60 void addKey(const KeyInfo &key);
61 void removeKey(const QString &key);
62
63 [[nodiscard]] QList<KeyInfo> keys() const;
64
65 void saveKeys();
66 [[nodiscard]] QString keyValue(const QString &selector, const QString &domain);
67
68 void updateLastUsed(const QString &selector, const QString &domain);
69
70private:
71 explicit DKIMManagerKey(QObject *parent = nullptr);
72 [[nodiscard]] MESSAGEVIEWER_NO_EXPORT QStringList keyRecorderList(KSharedConfig::Ptr &config) const;
73 QList<KeyInfo> mKeys;
74 QCA::Initializer *const mQcaInitializer;
75};
76}
77Q_DECLARE_TYPEINFO(MessageViewer::KeyInfo, Q_RELOCATABLE_TYPE);
78Q_DECLARE_METATYPE(MessageViewer::KeyInfo)
79MESSAGEVIEWER_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 Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.