Don't offer to restart a Running (=busy) agent, it won't work.
[kdepim.git] / messageviewer / antispamconfig.h
blob2cb3f9e212cbaad306875c4b2a71ee6f739af7a3
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 antispamconfig.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 __MESSAGEVIEWER_ANTISPAMCONFIG_H__
35 #define __MESSAGEVIEWER_ANTISPAMCONFIG_H__
37 #include <QtCore/QRegExp>
38 #include <QtCore/QVector>
39 #include "messageviewer_export.h"
41 class QString;
43 namespace MessageViewer {
45 /// Valid types of SpamAgent
46 enum SpamAgentTypes {
47 SpamAgentNone, //!< Invalid SpamAgent, skip this agent
48 SpamAgentBool, //!< Simple Yes or No (Razor)
49 SpamAgentFloat, //!< For straight percentages between 0.0 and 1.0 (BogoFilter)
50 SpamAgentFloatLarge, //!< For straight percentages between 0.0 and 100.0
51 SpamAgentAdjustedFloat //!< Use this when we need to compare against a threshold (SpamAssasssin)
54 class SpamAgent
56 public:
57 SpamAgent() : mType( SpamAgentNone ) {}
58 SpamAgent( const QString & name, SpamAgentTypes type, const QByteArray & field, const QByteArray & cfield,
59 const QRegExp & score, const QRegExp & threshold, const QRegExp & confidence )
60 : mName( name ), mType( type ), mField( field ), mConfidenceField( cfield ),
61 mScore( score ), mThreshold( threshold ), mConfidence( confidence ) {}
63 QString name() const { return mName; }
64 SpamAgentTypes scoreType() const { return mType; }
65 QByteArray header() const { return mField; }
66 QByteArray confidenceHeader() const { return mConfidenceField; }
67 QRegExp scorePattern() const { return mScore; }
68 QRegExp thresholdPattern() const { return mThreshold; }
69 QRegExp confidencePattern() const { return mConfidence; }
71 private:
72 QString mName;
73 SpamAgentTypes mType;
74 QByteArray mField;
75 QByteArray mConfidenceField;
76 QRegExp mScore;
77 QRegExp mThreshold;
78 QRegExp mConfidence;
80 typedef QVector<SpamAgent> SpamAgents;
82 class AntiSpamConfigSingletonProvider;
84 /**
85 @short Singleton to manage loading the kmail.antispamrc file.
86 @author Patrick Audley <paudley@blackcat.ca>
88 Use of this config-manager class is straight forward. Since it
89 is a singleton object, all you have to do is obtain an instance
90 by calling @p SpamConfig::instance() and use any of the
91 public member functions.
93 class MESSAGEVIEWER_EXPORT AntiSpamConfig {
94 friend class AntiSpamConfigSingletonProvider;
95 private:
96 AntiSpamConfig();
98 public:
99 ~AntiSpamConfig();
101 static AntiSpamConfig * instance();
104 * Returns a list of all agents found on the system. This
105 * might list SA twice, if both the C and the Perl version are present.
107 const SpamAgents agents() const { return mAgents; }
108 SpamAgents agents() { return mAgents; }
111 * Returns a list of unique agents, found on the system. SpamAssassin will
112 * only be listed once, even if both the C and the Perl version are
113 * installed.
115 const SpamAgents uniqueAgents() const;
117 private:
118 SpamAgents mAgents;
120 void readConfig();
125 #endif // __MESSAGEVIEWER_ANTISPAMCONFIG_H__