34 #include "antispamconfig.h"
36 #include <kstaticdeleter.h>
37 #include <tdeconfig.h>
39 using namespace KMail;
42 static KStaticDeleter<AntiSpamConfig> antispamconfig_sd;
52 void AntiSpamConfig::readConfig()
55 TDEConfig config(
"kmail.antispamrc",
true );
56 config.setReadDefaults(
true );
57 TDEConfigGroup general( &config,
"General" );
58 unsigned int totalTools = general.readUnsignedNumEntry(
"tools", 0 );
59 for (
unsigned int i = 1; i <= totalTools; ++i ) {
60 TDEConfigGroup tool( &config, TQString(
"Spamtool #%1").arg( i ) );
61 if ( tool.hasKey(
"ScoreHeader" ) ) {
62 TQString name = tool.readEntry(
"ScoreName" );
63 TQCString header = tool.readEntry(
"ScoreHeader" ).latin1();
64 TQCString type = tool.readEntry(
"ScoreType" ).latin1();
65 TQString score = tool.readEntryUntranslated(
"ScoreValueRegexp" );
66 TQString threshold = tool.readEntryUntranslated(
"ScoreThresholdRegexp" );
68 if ( kasciistricmp( type.data(),
"bool" ) == 0 )
70 else if ( kasciistricmp( type.data(),
"decimal" ) == 0 )
72 else if ( kasciistricmp( type.data(),
"percentage" ) == 0 )
74 else if ( kasciistricmp( type.data(),
"adjusted" ) == 0 )
76 mAgents.append( SpamAgent( name, typeE, header, TQRegExp( score ),
77 TQRegExp( threshold ) ) );
84 TQStringList seenAgents;
86 SpamAgents::ConstIterator it( mAgents.begin() );
87 SpamAgents::ConstIterator end( mAgents.end() );
88 for ( ; it != end ; ++it ) {
89 const TQString agent( ( *it ).name() );
90 if ( seenAgents.find( agent ) == seenAgents.end() ) {
92 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)