Commit aadcb73b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add enum for authentication result method

parent f0847e3a
......@@ -80,6 +80,16 @@ public:
};
Q_ENUM(DKIMWarning)
enum class AuthenticationMethod : int {
Unknown = 0,
Dkim = 1,
Spf = 2,
Dmarc = 3,
Dkimatps = 4,
};
Q_ENUM(AuthenticationMethod)
struct CheckSignatureResult {
Q_REQUIRED_RESULT bool isValid() const;
......@@ -95,6 +105,7 @@ public:
QString fromEmail;
struct AuthenticationResult {
QString errorStr;
QString methodStr; // Use enum ?
Q_REQUIRED_RESULT bool operator==(const AuthenticationResult &other) const;
......
......@@ -18,6 +18,7 @@
*/
#include "dkimutil.h"
#include "messageviewer_dkimcheckerdebug.h"
#include <QRegularExpression>
#include <QCryptographicHash>
......@@ -162,3 +163,32 @@ QString MessageViewer::DKIMUtil::defaultConfigFileName()
{
return QStringLiteral("dkimsettingsrc");
}
QString MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod method)
{
QString methodStr;
switch (method) {
case MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Unknown:
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Undefined type";
break;
case MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkim:
methodStr = QStringLiteral("dkim");
break;
case MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Spf:
methodStr = QStringLiteral("spf");
break;
case MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dmarc:
methodStr = QStringLiteral("dmarc");
break;
case MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkimatps:
methodStr = QStringLiteral("dkim-atps");
break;
}
return methodStr;
}
MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod MessageViewer::DKIMUtil::convertAuthenticationMethodToString(const QString &str)
{
//TODO
return {};
}
......@@ -21,6 +21,7 @@
#define DKIMUTIL_H
#include <QString>
#include <QCryptographicHash>
#include "dkimchecksignaturejob.h"
#include "messageviewer_private_export.h"
namespace MessageViewer {
namespace DKIMUtil {
......@@ -33,6 +34,8 @@ MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString cleanString(QString str);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString emailDomain(const QString &emailDomain);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString emailSubDomain(const QString &emailDomain);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString defaultConfigFileName();
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString convertAuthenticationMethodEnumToString(DKIMCheckSignatureJob::AuthenticationMethod);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT DKIMCheckSignatureJob::AuthenticationMethod convertAuthenticationMethodToString(const QString &str);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment