1 /* -*- mode: C++; c-file-style: "gnu" -*-
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2004 Patrick Audley <paudley@blackcat.ca>
6 Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
8 KMail is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 KMail is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 In addition, as a special exception, the copyright holders give
23 permission to link the code of this program with any edition of
24 the Qt library by Trolltech AS, Norway (or with modified versions
25 of Qt that use the same license as Qt), and distribute linked
26 combinations including the two. You must obey the GNU General
27 Public License in all respects for all of the code used other than
28 Qt. If you modify this file, you may extend this exception to
29 your version of the file, but you are not obligated to do so. If
30 you do not wish to do so, delete this exception statement from
34 #ifndef __MESSAGEVIEWER_SPAMHEADERANALYZER_H__
35 #define __MESSAGEVIEWER_SPAMHEADERANALYZER_H__
37 #include <KMime/Message>
39 #include <QtCore/QString>
40 #include <QtCore/QVector>
42 namespace MessageViewer
{
46 uninitializedStructUsed
,
47 errorExtractingAgentString
,
48 couldNotConverScoreToFloat
,
49 couldNotConvertThresholdToFloatOrThresholdIsNegative
,
50 couldNotFindTheScoreField
,
51 couldNotFindTheThresholdField
,
52 couldNotConvertConfidenceToFloat
56 @short A simple tupel of error, agent, score, confidence and header.
58 The score returned is positive if no error has occurred.
59 error values indicate the following errors:
60 noError Spam Headers successfully parsed
61 uninitializedStructUsed Unintialized struct used
62 errorExtractingAgentString Error extracing agent string
63 couldNotConverScoreToFloat Couldn't convert score to float
64 couldNotConvertThresholdToFloatOrThresholdIsNegative Couldn't convert threshold to float or threshold is negative
65 couldNotFindTheScoreField Couldn't find the score field
66 couldNotFindTheThresholdField Couldn't find the threshold field
67 couldNotConvertConfidenceToFloat Couldn't convert confidence to float
72 SpamScore() : mScore( -2.0 ), mConfidence( -2.0 ) {}
73 SpamScore( const QString
& agent
, SpamError error
, float score
, float confidence
,
74 const QString
& header
, const QString
& cheader
)
75 : mAgent( agent
), mError( error
), mScore( score
), mConfidence( confidence
),
76 mHeader( header
), mConfidenceHeader( cheader
) {}
77 QString
agent() const { return mAgent
; }
78 float score() const { return mScore
; }
79 float confidence() const { return mConfidence
; }
80 SpamError
error() const { return mError
; }
81 QString
spamHeader() const { return mHeader
; }
82 QString
confidenceHeader() const { return mConfidenceHeader
; }
90 QString mConfidenceHeader
;
92 typedef QVector
<SpamScore
> SpamScores
;
96 @short Flyweight for analysing spam headers.
97 @author Patrick Audley <paudley@blackcat.ca>
99 class SpamHeaderAnalyzer
{
102 @short Extract scores from known anti-spam headers
103 @param message A KMime::Message to examine
104 @return A list of detected scores. See SpamScore
106 static SpamScores
getSpamScores( KMime::Message
*message
);
112 #endif // __SPAMHEADERANALYZER_H__