kmail

antispamconfig.h

Go to the documentation of this file.
00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002     antispamconfig.h
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) 2004 Patrick Audley <paudley@blackcat.ca>
00006     Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
00007 
00008     KMail is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     KMail is distributed in the hope that it will be useful, but
00014     WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 
00022     In addition, as a special exception, the copyright holders give
00023     permission to link the code of this program with any edition of
00024     the Qt library by Trolltech AS, Norway (or with modified versions
00025     of Qt that use the same license as Qt), and distribute linked
00026     combinations including the two.  You must obey the GNU General
00027     Public License in all respects for all of the code used other than
00028     Qt.  If you modify this file, you may extend this exception to
00029     your version of the file, but you are not obligated to do so.  If
00030     you do not wish to do so, delete this exception statement from
00031     your version.
00032 */
00033 
00034 #ifndef __KMAIL_ANTISPAMCONFIG_H__
00035 #define __KMAIL_ANTISPAMCONFIG_H__
00036 
00037 #include <qvaluelist.h>
00038 #include <qregexp.h>
00039 
00040 class QString;
00041 class QCString;
00042 
00043 namespace KMail {
00044 
00046   typedef enum {
00047     SpamAgentNone,          
00048     SpamAgentBool,          
00049     SpamAgentFloat,         
00050     SpamAgentFloatLarge,    
00051     SpamAgentAdjustedFloat  
00052   } SpamAgentTypes;
00053 
00054   class SpamAgent {
00055   public:
00056     SpamAgent() : mType( SpamAgentNone ) {}
00057     SpamAgent( const QString & name, SpamAgentTypes type, const QCString & field,
00058                const QRegExp & score, const QRegExp & threshold )
00059       : mName( name ), mType( type ), mField( field ),
00060         mScore( score ), mThreshold( threshold ) {}
00061 
00062     QString name() const { return mName; }
00063     SpamAgentTypes scoreType() const { return mType; }
00064     QCString header() const { return mField; }
00065     QRegExp scorePattern() const { return mScore; }
00066     QRegExp thresholdPattern() const { return mThreshold; }
00067 
00068   private:
00069     QString mName;
00070     SpamAgentTypes mType;
00071     QCString mField;
00072     QRegExp mScore;
00073     QRegExp mThreshold;
00074   };
00075   typedef QValueList<SpamAgent> SpamAgents;
00076   typedef QValueListIterator<SpamAgent> SpamAgentsIterator;
00077 
00087   class AntiSpamConfig {
00088   private:
00089     static AntiSpamConfig * sSelf;
00090 
00091     AntiSpamConfig() {}
00092 
00093   public:
00094     ~AntiSpamConfig() {}
00095 
00096     static AntiSpamConfig * instance();
00097 
00102     const SpamAgents agents() const { return mAgents; }
00103     SpamAgents agents() { return mAgents; }
00104 
00110     const SpamAgents uniqueAgents() const;
00111 
00112   private:
00113     SpamAgents mAgents;
00114 
00115     void readConfig();
00116   };
00117 
00118 } // namespace KMail
00119 
00120 #endif // __KMAIL_ANTISPAMCONFIG_H__