26 const SpamAgents agents = AntiSpamConfig::instance()->uniqueAgents();
27 SpamAgents::const_iterator end(agents.
constEnd());
28 for (SpamAgents::const_iterator it = agents.
constBegin(); it != end; ++it) {
31 SpamError spamError = noError;
34 if ((*it).scoreType() == SpamAgentNone) {
51 bool scoreValid =
false;
53 if ((*it).scoreType() != SpamAgentBool) {
65 spamError = couldNotFindTheScoreField;
66 qCDebug(MESSAGEVIEWER_LOG) <<
"Score could not be extracted from header '" << mField <<
"'";
68 bool floatValid =
false;
69 switch ((*it).scoreType()) {
71 spamError = errorExtractingAgentString;
75 if ((*it).scorePattern().match(mField).hasMatch()) {
83 score = scoreString.
toFloat(&floatValid);
85 spamError = couldNotConverScoreToFloat;
86 qCDebug(MESSAGEVIEWER_LOG) <<
"Score (" << scoreString <<
") is no number";
92 case SpamAgentFloatLarge:
93 score = scoreString.
toFloat(&floatValid);
95 spamError = couldNotConverScoreToFloat;
96 qCDebug(MESSAGEVIEWER_LOG) <<
"Score (" << scoreString <<
") is no number";
100 case SpamAgentAdjustedFloat:
101 score = scoreString.
toFloat(&floatValid);
103 spamError = couldNotConverScoreToFloat;
104 qCDebug(MESSAGEVIEWER_LOG) <<
"Score (" << scoreString <<
") is no number";
112 thresholdString = thresholdPattern.
match(mField).
captured(1);
114 spamError = couldNotFindTheThresholdField;
115 qCDebug(MESSAGEVIEWER_LOG) <<
"Threshold could not be extracted from header '" << mField <<
"'";
118 const float threshold = thresholdString.
toFloat(&floatValid);
119 if (!floatValid || (threshold <= 0.0)) {
120 spamError = couldNotConvertThresholdToFloatOrThresholdIsNegative;
121 qCDebug(MESSAGEVIEWER_LOG) <<
"Threshold (" << thresholdString <<
") is no"
122 <<
"number or is negative";
131 }
else if (score > threshold) {
134 score = score / threshold * 100.0;
140 float confidence = -2.0;
141 QString confidenceString = QStringLiteral(
"-2.0");
142 bool confidenceValid =
false;
144 const QByteArray confidenceHeaderName = (*it).confidenceHeader();
146 if (!confidenceHeaderName.
isEmpty()) {
156 confidence = confidenceString.
toFloat(&confidenceValid);
157 if (!confidenceValid) {
158 spamError = couldNotConvertConfidenceToFloat;
159 qCDebug(MESSAGEVIEWER_LOG) <<
"Unable to convert confidence to float:" << confidenceString;
164 scores.
append(
SpamScore((*it).name(), spamError, score, confidence * 100, mField, mCField));