Messagelib

dkiminfo.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 <QObject>
11#include <QString>
12#include <QStringList>
13namespace MessageViewer
14{
15/**
16 * @brief The DKIMInfo class
17 * @author Laurent Montel <montel@kde.org>
18 */
19class MESSAGEVIEWER_EXPORT DKIMInfo
20{
21 Q_GADGET
22public:
23 DKIMInfo();
24
25 enum CanonicalizationType : uint8_t {
26 Unknown,
27 Simple,
28 Relaxed,
29 };
30 enum class HashingAlgorithmType : uint8_t {
31 Any,
32 Sha1,
33 Sha256,
34 Unknown,
35 };
36 Q_ENUM(HashingAlgorithmType)
37
38 [[nodiscard]] bool parseDKIM(const QString &header);
39
40 [[nodiscard]] int version() const;
41 void setVersion(int version);
42
43 [[nodiscard]] HashingAlgorithmType hashingAlgorithm() const;
44 void setHashingAlgorithm(DKIMInfo::HashingAlgorithmType type);
45
46 [[nodiscard]] QString domain() const;
47 void setDomain(const QString &domain);
48
49 [[nodiscard]] QString selector() const;
50 void setSelector(const QString &selector);
51
52 [[nodiscard]] QString bodyHash() const;
53 void setBodyHash(const QString &bodyHash);
54
55 [[nodiscard]] bool isValid() const;
56
57 [[nodiscard]] QStringList listSignedHeader() const;
58 void setListSignedHeader(const QStringList &listSignedHeader);
59
60 [[nodiscard]] QString signingAlgorithm() const;
61 void setSigningAlgorithm(const QString &signingAlgorithm);
62
63 [[nodiscard]] qint64 signatureTimeStamp() const;
64 void setSignatureTimeStamp(qint64 signatureTimeStamp);
65
66 [[nodiscard]] QString query() const;
67 void setQuery(const QString &query);
68
69 [[nodiscard]] qint64 expireTime() const;
70 void setExpireTime(qint64 expireTime);
71
72 [[nodiscard]] QString signature() const;
73 void setSignature(const QString &signature);
74
75 [[nodiscard]] QString agentOrUserIdentifier() const;
76 void setAgentOrUserIdentifier(const QString &agentOrUserIdentifier);
77
78 [[nodiscard]] int bodyLengthCount() const;
79 void setBodyLengthCount(int bodyLengthCount);
80
81 [[nodiscard]] CanonicalizationType headerCanonization() const;
82 void setHeaderCanonization(CanonicalizationType headerCanonization);
83
84 [[nodiscard]] CanonicalizationType bodyCanonization() const;
85 void setBodyCanonization(CanonicalizationType bodyCanonization);
86
87 [[nodiscard]] bool operator==(const DKIMInfo &other) const;
88
89 [[nodiscard]] QStringList copiedHeaderField() const;
90 void setCopiedHeaderField(const QStringList &copiedHeaderField);
91
92 [[nodiscard]] QString iDomain() const;
93 void setIDomain(const QString &iDomain);
94
95private:
96 MESSAGEVIEWER_NO_EXPORT void parseCanonicalization(const QString &str);
97 MESSAGEVIEWER_NO_EXPORT void parseAlgorithm(const QString &str);
98 HashingAlgorithmType mHashingAlgorithm = HashingAlgorithmType::Any;
99 QString mSigningAlgorithm;
100 QString mDomain;
101 QString mSelector;
102 QString mBodyHash;
103 QString mQuery;
104 QString mSignature;
105 QString mAgentOrUserIdentifier;
106 QString mIDomain;
107 QStringList mListSignedHeader;
108 QStringList mCopiedHeaderField; // Default is empty
109 qint64 mSignatureTimeStamp = -1;
110 qint64 mExpireTime = -1;
111 int mVersion = -1;
112 int mBodyLengthCount = -1;
113 CanonicalizationType mHeaderCanonization = Unknown;
114 CanonicalizationType mBodyCanonization = Unknown;
115};
116}
117MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::DKIMInfo &t);
The DKIMInfo class.
Definition dkiminfo.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.