File indexing completed on 2025-03-09 04:54:28

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "messageviewer_private_export.h"
0010 #include <QDebug>
0011 #include <QString>
0012 namespace MessageViewer
0013 {
0014 class MESSAGEVIEWER_TESTS_EXPORT DKIMAuthenticationStatusInfo
0015 {
0016 public:
0017     DKIMAuthenticationStatusInfo();
0018 
0019     struct AuthStatusInfo {
0020         struct Property {
0021             QString type;
0022             QString value;
0023             [[nodiscard]] bool isValid() const
0024             {
0025                 return !type.isEmpty() && !value.isEmpty();
0026             }
0027 
0028             [[nodiscard]] bool operator==(const Property &other) const
0029             {
0030                 return other.type == type && other.value == value;
0031             }
0032         };
0033 
0034         QString method;
0035         QString result;
0036         QString reason;
0037         int methodVersion = -1;
0038 
0039         // Add Properties
0040         QList<Property> smtp;
0041         QList<Property> header;
0042         QList<Property> body;
0043         QList<Property> policy;
0044 
0045         [[nodiscard]] bool operator==(const AuthStatusInfo &other) const;
0046         [[nodiscard]] bool isValid() const;
0047     };
0048 
0049     [[nodiscard]] QString authservId() const;
0050     void setAuthservId(const QString &authservId);
0051 
0052     [[nodiscard]] bool parseAuthenticationStatus(const QString &key, bool relaxingParsing);
0053 
0054     [[nodiscard]] int authVersion() const;
0055     void setAuthVersion(int authVersion);
0056 
0057     [[nodiscard]] QString reasonSpec() const;
0058     void setReasonSpec(const QString &reasonSpec);
0059 
0060     [[nodiscard]] bool operator==(const DKIMAuthenticationStatusInfo &other) const;
0061 
0062     [[nodiscard]] QList<AuthStatusInfo> listAuthStatusInfo() const;
0063     void setListAuthStatusInfo(const QList<AuthStatusInfo> &listAuthStatusInfo);
0064 
0065 private:
0066     [[nodiscard]] AuthStatusInfo parseAuthResultInfo(QString &valueKey, bool relaxingParsing);
0067     QList<AuthStatusInfo> mListAuthStatusInfo;
0068     QString mAuthservId;
0069     QString mReasonSpec;
0070     int mAuthVersion = -1;
0071 };
0072 }
0073 Q_DECLARE_METATYPE(MessageViewer::DKIMAuthenticationStatusInfo)
0074 Q_DECLARE_TYPEINFO(MessageViewer::DKIMAuthenticationStatusInfo::AuthStatusInfo, Q_RELOCATABLE_TYPE);
0075 MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::DKIMAuthenticationStatusInfo &t);