krop's commit fixes my problem in a better way, reverting
[kdepim.git] / kmail / spamheaderanalyzer.h
blobc5de4122994fbadfd6cbdb803cb1ec28ae194d00
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 spamheaderanalyzer.h
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
31 your version.
34 #ifndef __KMAIL_SPAMHEADERANALYZER_H__
35 #define __KMAIL_SPAMHEADERANALYZER_H__
38 class QString;
39 class KMMessage;
40 #include <QString>
41 #include <QList>
42 namespace KMail {
44 typedef enum {
45 noError,
46 uninitializedStructUsed,
47 errorExtractingAgentString,
48 couldNotConverScoreToFloat,
49 couldNotConvertThresholdToFloatOrThresholdIsNegative,
50 couldNotFindTheScoreField,
51 couldNotFindTheThresholdField,
52 couldNotConvertConfidenceToFloat
53 } SpamError;
55 /**
56 @short A simple tuple 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 succesfully 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
69 class SpamScore {
70 public:
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; }
84 private:
85 QString mAgent;
86 SpamError mError;
87 float mScore;
88 float mConfidence;
89 QString mHeader;
90 QString mConfidenceHeader;
92 typedef QList<SpamScore> SpamScores;
93 typedef QList<SpamScore>::Iterator SpamScoresIterator;
96 /**
97 @short Flyweight for analysing spam headers.
98 @author Patrick Audley <paudley@blackcat.ca>
100 class SpamHeaderAnalyzer {
101 public:
103 @short Extract scores from known anti-spam headers
104 @param message A KMMessage to examine
105 @return A list of detected scores. See SpamScore
107 static SpamScores getSpamScores( const KMMessage *message );
110 } // namespace KMail
112 #endif // __KMAIL_SPAMHEADERANALYZER_H__