Backport r950340 | aacid | 2009-04-06 23:21:18 +0200 (Mon, 06 Apr 2009) | 4 lines
[kdepim.git] / kmail / spamheaderanalyzer.h
blobc82ef22f14971d128fe0d7b3264bd11d8b876bc5
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 /**
45 @short A simple tupel of agent, score, confidence and header.
47 The score returned is positive if no error has occurred.
48 Negative values indicate the following errors:
49 -1.0 Unintialized struct used
50 -2.0 Error extracing agent string
51 -3.0 Couldn't convert score to float
52 -4.0 Couldn't convert threshold to float or threshold is negative
53 -5.0 Couldn't find the score field
54 -6.0 Couldn't find the threshold field
56 class SpamScore {
57 public:
58 SpamScore() : mScore( -2.0 ), mConfidence( -2.0 ) {}
59 SpamScore( const QString & agent, float score, float confidence,
60 const QString & header, const QString & cheader )
61 : mAgent( agent ), mScore( score ), mConfidence( confidence ),
62 mHeader( header ), mConfidenceHeader( cheader ) {}
63 QString agent() const { return mAgent; }
64 float score() const { return mScore; }
65 float confidence() const { return mConfidence; }
66 QString spamHeader() const { return mHeader; }
67 QString confidenceHeader() const { return mConfidenceHeader; }
69 private:
70 QString mAgent;
71 float mScore;
72 float mConfidence;
73 QString mHeader;
74 QString mConfidenceHeader;
76 typedef QList<SpamScore> SpamScores;
77 typedef QList<SpamScore>::Iterator SpamScoresIterator;
80 /**
81 @short Flyweight for analysing spam headers.
82 @author Patrick Audley <paudley@blackcat.ca>
84 class SpamHeaderAnalyzer {
85 public:
86 /**
87 @short Extract scores from known anti-spam headers
88 @param message A KMMessage to examine
89 @return A list of detected scores. See SpamScore
91 static SpamScores getSpamScores( const KMMessage *message );
94 } // namespace KMail
96 #endif // __KMAIL_SPAMHEADERANALYZER_H__