Messagelib

antispamconfig.h
1 /*
2  antispamconfig.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_ANTISPAMCONFIG_H
12 #define MESSAGEVIEWER_ANTISPAMCONFIG_H
13 
14 #include <QRegExp>
15 #include <QVector>
16 #include "messageviewer_export.h"
17 
18 class QString;
19 
20 namespace MessageViewer {
22 enum SpamAgentTypes {
23  SpamAgentNone,
24  SpamAgentBool,
25  SpamAgentFloat,
26  SpamAgentFloatLarge,
27  SpamAgentAdjustedFloat
28 };
29 
30 class SpamAgent
31 {
32 public:
33  SpamAgent() : mType(SpamAgentNone)
34  {
35  }
36 
37  SpamAgent(const QString &name, SpamAgentTypes type, const QByteArray &field, const QByteArray &cfield, const QRegExp &score, const QRegExp &threshold, const QRegExp &confidence)
38  : mName(name)
39  , mType(type)
40  , mField(field)
41  , mConfidenceField(cfield)
42  , mScore(score)
43  , mThreshold(threshold)
44  , mConfidence(confidence)
45  {
46  }
47 
48  Q_REQUIRED_RESULT QString name() const
49  {
50  return mName;
51  }
52 
53  Q_REQUIRED_RESULT SpamAgentTypes scoreType() const
54  {
55  return mType;
56  }
57 
58  Q_REQUIRED_RESULT QByteArray header() const
59  {
60  return mField;
61  }
62 
63  Q_REQUIRED_RESULT QByteArray confidenceHeader() const
64  {
65  return mConfidenceField;
66  }
67 
68  Q_REQUIRED_RESULT QRegExp scorePattern() const
69  {
70  return mScore;
71  }
72 
73  Q_REQUIRED_RESULT QRegExp thresholdPattern() const
74  {
75  return mThreshold;
76  }
77 
78  Q_REQUIRED_RESULT QRegExp confidencePattern() const
79  {
80  return mConfidence;
81  }
82 
83 private:
84  QString mName;
85  SpamAgentTypes mType;
86  QByteArray mField;
87  QByteArray mConfidenceField;
88  QRegExp mScore;
89  QRegExp mThreshold;
90  QRegExp mConfidence;
91 };
92 typedef QVector<SpamAgent> SpamAgents;
93 
94 class AntiSpamConfigSingletonProvider;
95 
106 {
107  friend class AntiSpamConfigSingletonProvider;
108 private:
109  AntiSpamConfig();
110 
111 public:
112  ~AntiSpamConfig();
113 
114  static AntiSpamConfig *instance();
115 
120  const SpamAgents agents() const;
121 
127  const SpamAgents uniqueAgents() const;
128 
129 private:
130  SpamAgents mAgents;
131 
132  void readConfig();
133 };
134 }
135 
136 #endif // MESSAGEVIEWER_ANTISPAMCONFIG_H
QString name(const QVariant &location)
Singleton to manage loading the kmail.antispamrc file.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jul 6 2020 23:12:22 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.