34#include "antispamconfig.h"
36#include <kasciistricmp.h>
38#include <kstaticdeleter.h>
44static KStaticDeleter<AntiSpamConfig> antispamconfig_sd;
54void AntiSpamConfig::readConfig()
57 TDEConfig config(
"kmail.antispamrc",
true );
58 config.setReadDefaults(
true );
59 TDEConfigGroup general( &config,
"General" );
60 unsigned int totalTools = general.readUnsignedNumEntry(
"tools", 0 );
61 for (
unsigned int i = 1; i <= totalTools; ++i ) {
62 TDEConfigGroup tool( &config, TQString(
"Spamtool #%1").arg( i ) );
63 if ( tool.hasKey(
"ScoreHeader" ) ) {
64 TQString name = tool.readEntry(
"ScoreName" );
65 TQCString header = tool.readEntry(
"ScoreHeader" ).latin1();
66 TQCString type = tool.readEntry(
"ScoreType" ).latin1();
67 TQString score = tool.readEntryUntranslated(
"ScoreValueRegexp" );
68 TQString threshold = tool.readEntryUntranslated(
"ScoreThresholdRegexp" );
70 if ( kasciistricmp( type.data(),
"bool" ) == 0 )
72 else if ( kasciistricmp( type.data(),
"decimal" ) == 0 )
74 else if ( kasciistricmp( type.data(),
"percentage" ) == 0 )
76 else if ( kasciistricmp( type.data(),
"adjusted" ) == 0 )
78 mAgents.append( SpamAgent( name, typeE, header, TQRegExp( score ),
79 TQRegExp( threshold ) ) );
86 TQStringList seenAgents;
88 SpamAgents::ConstIterator it( mAgents.begin() );
89 SpamAgents::ConstIterator end( mAgents.end() );
90 for ( ; it != end ; ++it ) {
91 const TQString agent( ( *it ).name() );
92 if ( seenAgents.find( agent ) == seenAgents.end() ) {
94 seenAgents.append( agent );
Singleton to manage loading the kmail.antispamrc file.
const SpamAgents agents() const
Returns a list of all agents found on the system.
const SpamAgents uniqueAgents() const
Returns a list of unique agents, found on the system.
SpamAgentTypes
Valid types of SpamAgent.
@ SpamAgentFloatLarge
For straight percentages between 0.0 and 100.0.
@ SpamAgentBool
Simple Yes or No (Razor)
@ SpamAgentFloat
For straight percentages between 0.0 and 1.0 (BogoFilter)
@ SpamAgentNone
Invalid SpamAgent, skip this agent.
@ SpamAgentAdjustedFloat
Use this when we need to compare against a threshold (SpamAssasssin)