Messagelib

spamheaderanalyzer.h
1/*
2 spamheaderanalyzer.h
3
4 This file is part of KMail, the KDE mail client.
5 SPDX-FileCopyrightText: 2004 Patrick Audley <paudley@blackcat.ca>
6 SPDX-FileCopyrightText: 2004 Ingo Kloecker <kloecker@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include <QList>
14#include <QString>
15namespace KMime
16{
17class Message;
18}
19namespace MessageViewer
20{
21enum SpamError {
22 noError,
23 uninitializedStructUsed,
24 errorExtractingAgentString,
25 couldNotConverScoreToFloat,
26 couldNotConvertThresholdToFloatOrThresholdIsNegative,
27 couldNotFindTheScoreField,
28 couldNotFindTheThresholdField,
29 couldNotConvertConfidenceToFloat
30};
31
32/**
33 @short A simple tuple of error, agent, score, confidence and header.
34
35 The score returned is positive if no error has occurred.
36 error values indicate the following errors:
37 noError Spam Headers successfully parsed
38 uninitializedStructUsed Uninitialized struct used
39 errorExtractingAgentString Error extracting agent string
40 couldNotConverScoreToFloat Couldn't convert score to float
41 couldNotConvertThresholdToFloatOrThresholdIsNegative Couldn't convert threshold to float or threshold is negative
42 couldNotFindTheScoreField Couldn't find the score field
43 couldNotFindTheThresholdField Couldn't find the threshold field
44 couldNotConvertConfidenceToFloat Couldn't convert confidence to float
45*/
47{
48public:
49 SpamScore()
50 : mError(noError)
51 , mScore(-2.0)
52 , mConfidence(-2.0)
53 {
54 }
55
56 SpamScore(const QString &agent, SpamError error, float score, float confidence, const QString &header, const QString &cheader)
57 : mAgent(agent)
58 , mError(error)
59 , mScore(score)
60 , mConfidence(confidence)
61 , mHeader(header)
62 , mConfidenceHeader(cheader)
63 {
64 }
65
66 [[nodiscard]] QString agent() const
67 {
68 return mAgent;
69 }
70
71 [[nodiscard]] float score() const
72 {
73 return mScore;
74 }
75
76 [[nodiscard]] float confidence() const
77 {
78 return mConfidence;
79 }
80
81 [[nodiscard]] SpamError error() const
82 {
83 return mError;
84 }
85
86 [[nodiscard]] QString spamHeader() const
87 {
88 return mHeader;
89 }
90
91 [[nodiscard]] QString confidenceHeader() const
92 {
93 return mConfidenceHeader;
94 }
95
96private:
97 QString mAgent;
98 SpamError mError;
99 float mScore;
100 float mConfidence;
101 QString mHeader;
102 QString mConfidenceHeader;
103};
105
106/**
107 @short Flyweight for analysing spam headers.
108 @author Patrick Audley <paudley@blackcat.ca>
109 */
111{
112public:
113 /**
114 @short Extract scores from known anti-spam headers
115 @param message A KMime::Message to examine
116 @return A list of detected scores. See SpamScore
117 */
118 static SpamScores getSpamScores(KMime::Message *message);
119};
120}
Flyweight for analysing spam headers.
static SpamScores getSpamScores(KMime::Message *message)
Extract scores from known anti-spam headers.
A simple tuple of error, agent, score, confidence and header.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.