34 #include "antispamconfig.h"
36 #include <kasciistricmp.h>
38 #include <kstaticdeleter.h>
41 using namespace KMail;
44 static KStaticDeleter<AntiSpamConfig> antispamconfig_sd;
54 void AntiSpamConfig::readConfig()
57 KConfig config(
"kmail.antispamrc",
true );
58 config.setReadDefaults(
true );
59 KConfigGroup general( &config,
"General" );
60 unsigned int totalTools = general.readUnsignedNumEntry(
"tools", 0 );
61 for (
unsigned int i = 1; i <= totalTools; ++i ) {
62 KConfigGroup 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 );