Messagelib

dkimheaderparser.h
1 /*
2  SPDX-FileCopyrightText: 2019-2021 Laurent Montel <[email protected]>
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 <QVector>
13 namespace MessageViewer
14 {
15 /**
16  * @brief The DKIMHeaderParser class
17  * @author Laurent Montel <[email protected]>
18  */
19 class MESSAGEVIEWER_EXPORT DKIMHeaderParser
20 {
21 private:
22  struct Header {
23  QString headerName;
24  QString headerValue;
25  QByteArray codec;
26  Q_REQUIRED_RESULT bool isValid() const
27  {
28  return !headerName.isEmpty();
29  }
30 
31  Q_REQUIRED_RESULT bool operator==(const Header &other) const
32  {
33  return other.headerName == headerName && other.headerValue == headerValue && other.codec == codec;
34  }
35  };
36 
37 public:
40  void parse();
41  void setHead(const QByteArray &head);
42 
43  Q_REQUIRED_RESULT QByteArray head() const;
44 
45  Q_REQUIRED_RESULT QString headerType(const QString &str);
46  Q_REQUIRED_RESULT bool wasAlreadyParsed() const;
47  void setWasAlreadyParsed(bool wasAlreadyParsed);
48 
49  Q_REQUIRED_RESULT bool operator==(const DKIMHeaderParser &other) const;
50  Q_REQUIRED_RESULT QVector<DKIMHeaderParser::Header> listHeaders() const;
51 
52 private:
53  Q_REQUIRED_RESULT static int findHeaderLineEnd(const QByteArray &src, int &dataBegin, bool *folded);
54  Q_REQUIRED_RESULT MessageViewer::DKIMHeaderParser::Header extractHeader(const QByteArray &head, const int headerStart, int &endOfFieldBody);
55  Q_REQUIRED_RESULT static QByteArray unfoldHeader(const char *header, size_t headerSize);
56  QByteArray mHead;
58  bool mWasAlreadyParsed = false;
59 };
60 }
The DKIMHeaderParser class.
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Dec 2 2021 23:06:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.