Messagelib

dkimheaderparser.h
1/*
2 SPDX-FileCopyrightText: 2019-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
11#include <QByteArray>
12#include <QList>
13namespace MessageViewer
14{
15/**
16 * @brief The DKIMHeaderParser class
17 * @author Laurent Montel <montel@kde.org>
18 */
19class MESSAGEVIEWER_EXPORT DKIMHeaderParser
20{
21private:
22 struct Header {
23 QString headerName;
24 QString headerValue;
25 QByteArray codec;
26 [[nodiscard]] bool isValid() const
27 {
28 return !headerName.isEmpty();
29 }
30
31 [[nodiscard]] bool operator==(const Header &other) const
32 {
33 return other.headerName == headerName && other.headerValue == headerValue && other.codec == codec;
34 }
35 };
36
37public:
40 void parse();
41 void setHead(const QByteArray &head);
42
43 [[nodiscard]] QByteArray head() const;
44
45 [[nodiscard]] QString headerType(const QString &str);
46 [[nodiscard]] bool wasAlreadyParsed() const;
47 void setWasAlreadyParsed(bool wasAlreadyParsed);
48
49 [[nodiscard]] bool operator==(const DKIMHeaderParser &other) const;
50 [[nodiscard]] QList<DKIMHeaderParser::Header> listHeaders() const;
51
52private:
53 [[nodiscard]] MESSAGEVIEWER_NO_EXPORT static int findHeaderLineEnd(const QByteArray &src, int &dataBegin, bool *folded);
54 [[nodiscard]] MESSAGEVIEWER_NO_EXPORT MessageViewer::DKIMHeaderParser::Header
55 extractHeader(const QByteArray &head, const int headerStart, int &endOfFieldBody);
56 [[nodiscard]] MESSAGEVIEWER_NO_EXPORT static QByteArray unfoldHeader(const char *header, size_t headerSize);
57 QByteArray mHead;
59 bool mWasAlreadyParsed = false;
60};
61}
The DKIMHeaderParser class.
bool isEmpty() const const
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.