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 <[email protected]>
6  SPDX-FileCopyrightText: 2004 Ingo Kloecker <[email protected]>
7 
8  SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
9 */
10 
11 #ifndef MESSAGEVIEWER_SPAMHEADERANALYZER_H
12 #define MESSAGEVIEWER_SPAMHEADERANALYZER_H
13 
14 #include <KMime/Message>
15 
16 #include <QString>
17 #include <QVector>
18 
19 namespace MessageViewer {
20 enum SpamError {
21  noError,
22  uninitializedStructUsed,
23  errorExtractingAgentString,
24  couldNotConverScoreToFloat,
25  couldNotConvertThresholdToFloatOrThresholdIsNegative,
26  couldNotFindTheScoreField,
27  couldNotFindTheThresholdField,
28  couldNotConvertConfidenceToFloat
29 };
30 
45 class SpamScore
46 {
47 public:
48 
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  Q_REQUIRED_RESULT QString agent() const
67  {
68  return mAgent;
69  }
70 
71  Q_REQUIRED_RESULT float score() const
72  {
73  return mScore;
74  }
75 
76  Q_REQUIRED_RESULT float confidence() const
77  {
78  return mConfidence;
79  }
80 
81  Q_REQUIRED_RESULT SpamError error() const
82  {
83  return mError;
84  }
85 
86  Q_REQUIRED_RESULT QString spamHeader() const
87  {
88  return mHeader;
89  }
90 
91  Q_REQUIRED_RESULT QString confidenceHeader() const
92  {
93  return mConfidenceHeader;
94  }
95 
96 private:
97  QString mAgent;
98  SpamError mError;
99  float mScore;
100  float mConfidence;
101  QString mHeader;
102  QString mConfidenceHeader;
103 };
105 
111 {
112 public:
118  static SpamScores getSpamScores(KMime::Message *message);
119 };
120 }
121 
122 #endif // SPAMHEADERANALYZER_H
Flyweight for analysing spam headers.
A simple tuple of error, agent, score, confidence and header.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 14 2020 23:13:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.