8#include "messageviewer_dkimcheckerdebug.h"
10using namespace MessageViewer;
11DMARCInfo::DMARCInfo() =
default;
13bool DMARCInfo::parseDMARC(
const QString &key)
16 qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) <<
"Error: key empty";
19 QString cleanKey = key;
20 cleanKey.
replace(QLatin1StringView(
"; "), QLatin1StringView(
";"));
22 for (
int i = 0; i < items.
count(); ++i) {
23 const QString elem = items.
at(i).trimmed();
24 if (elem.
startsWith(QLatin1StringView(
"v="))) {
31 }
else if (elem.
startsWith(QLatin1StringView(
"r="))) {
39 }
else if (elem.
startsWith(QLatin1StringView(
"p="))) {
62 }
else if (elem.
startsWith(QLatin1StringView(
"ptc="))) {
80 mPercentage = QStringView(elem).right(elem.
length() - 4).toInt();
81 }
else if (elem.
startsWith(QLatin1StringView(
"sp="))) {
94 if (mAdkim.isEmpty() && mVersion == QLatin1StringView(
"DMARC1")) {
95 mAdkim = QLatin1Char(
'r');
101QString DMARCInfo::version()
const
106void DMARCInfo::setVersion(
const QString &version)
111QString DMARCInfo::adkim()
const
116void DMARCInfo::setAdkim(
const QString &adkim)
121QString DMARCInfo::policy()
const
126void DMARCInfo::setPolicy(
const QString &policy)
131int DMARCInfo::percentage()
const
136void DMARCInfo::setPercentage(
int percentage)
138 mPercentage = percentage;
141QString DMARCInfo::subDomainPolicy()
const
143 return mSubDomainPolicy;
146void DMARCInfo::setSubDomainPolicy(
const QString &subDomainPolicy)
148 mSubDomainPolicy = subDomainPolicy;
151bool DMARCInfo::operator==(
const DMARCInfo &other)
const
153 return mVersion == other.version() && mAdkim == other.adkim() && mPolicy == other.policy() && mSubDomainPolicy == other.subDomainPolicy()
154 && mPercentage == other.percentage();
159 d <<
" mVersion " << t.version();
160 d <<
" mAdkim " << t.adkim();
161 d <<
" mPolicy " << t.policy();
162 d <<
" mSubDomainPolicy " << t.subDomainPolicy();
163 d <<
" mPercentage " << t.percentage();
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
qsizetype length() const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString right(qsizetype n) const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const