Improvement of the anti-spam wizard: It's now possible to

define rules which consider filter results from the provider's
side. I've defined GMX as an example. Everybody is invited
to provide additinal definitions in kmail.antispamrc

svn path=/trunk/kdepim/; revision=360201
wilder-work
Andreas Gungl 22 years ago
parent 386f269967
commit e8ead80a9b
  1. 21
      antispamwizard.cpp
  2. 8
      antispamwizard.h
  3. 21
      kmail.antispamrc

@ -218,7 +218,8 @@ void AntiSpamWizard::accept()
for ( QValueListIterator<SpamToolConfig> it = mToolList.begin();
it != mToolList.end(); ++it ) {
if ( mProgramsPage->isProgramSelected( (*it).getVisibleName() ) &&
( mSpamRulesPage->pipeRulesSelected() && (*it).isSpamTool() ) )
( mSpamRulesPage->pipeRulesSelected() && (*it).isSpamTool() &&
!(*it).isDetectionOnly() ) )
{
// pipe messages through the anti-spam tools,
// one single filter for each tool
@ -301,7 +302,7 @@ void AntiSpamWizard::accept()
for ( QValueListIterator<SpamToolConfig> it = mToolList.begin();
it != mToolList.end(); ++it ) {
if ( mProgramsPage->isProgramSelected( (*it).getVisibleName() )
&& (*it).useBayesFilter() )
&& (*it).useBayesFilter() && !(*it).isDetectionOnly() )
{
KMFilterAction* classSpamFilterAction = dict["execute"]->create();
classSpamFilterAction->argsFromString( (*it).getSpamCmd() );
@ -334,7 +335,7 @@ void AntiSpamWizard::accept()
for ( QValueListIterator<SpamToolConfig> it = mToolList.begin();
it != mToolList.end(); ++it ) {
if ( mProgramsPage->isProgramSelected( (*it).getVisibleName() )
&& (*it).useBayesFilter() )
&& (*it).useBayesFilter() && !(*it).isDetectionOnly() )
{
KMFilterAction* classHamFilterAction = dict["execute"]->create();
classHamFilterAction->argsFromString( (*it).getHamCmd() );
@ -483,12 +484,14 @@ const QString AntiSpamWizard::uniqueNameFor( const QString & name )
AntiSpamWizard::SpamToolConfig::SpamToolConfig(QString toolId,
int configVersion,QString name, QString exec,
QString url, QString filter, QString detection, QString spam, QString ham,
QString header, QString pattern, bool regExp, bool bayesFilter, WizardMode type)
QString header, QString pattern, bool detectionOnly, bool regExp,
bool bayesFilter, WizardMode type)
: mId( toolId ), mVersion( configVersion ),
mVisibleName( name ), mExecutable( exec ), mWhatsThisText( url ),
mFilterName( filter ), mDetectCmd( detection ), mSpamCmd( spam ),
mHamCmd( ham ), mDetectionHeader( header ), mDetectionPattern( pattern ),
mUseRegExp( regExp ), mSupportsBayesFilter( bayesFilter ), mType( type )
mDetectionOnly( detectionOnly ), mUseRegExp( regExp ),
mSupportsBayesFilter( bayesFilter ), mType( type )
{
}
@ -564,11 +567,13 @@ AntiSpamWizard::SpamToolConfig
QString hamCmd = configGroup.readEntry( "ExecCmdHam" );
QString header = configGroup.readEntry( "DetectionHeader" );
QString pattern = configGroup.readEntry( "DetectionPattern" );
bool useRegExp = configGroup.readBoolEntry( "UseRegExp" );
bool detectionOnly = configGroup.readBoolEntry( "DetectionOnly", false );
bool useRegExp = configGroup.readBoolEntry( "UseRegExp" );
bool supportsBayes = configGroup.readBoolEntry( "SupportsBayes", false );
return SpamToolConfig( id, version, name, executable, url,
filterName, detectCmd, spamCmd, hamCmd,
header, pattern, useRegExp, supportsBayes, mMode );
header, pattern, detectionOnly, useRegExp,
supportsBayes, mMode );
}
@ -581,7 +586,7 @@ AntiSpamWizard::SpamToolConfig AntiSpamWizard::ConfigReader::createDummyConfig()
"sa-learn -L --spam --no-rebuild --single",
"sa-learn -L --ham --no-rebuild --single",
"X-Spam-Flag", "yes",
false, true, AntiSpam );
false, false, true, AntiSpam );
}

@ -83,6 +83,7 @@ namespace KMail {
ExecCmdHam=sa-learn --ham --no-rebuild --single
DetectionHeader=X-Spam-Flag
DetectionPattern=yes
DetectionOnly=0
UseRegExp=0
SupportsBayes=1
type=spam
@ -129,8 +130,8 @@ namespace KMail {
SpamToolConfig( QString toolId, int configVersion,
QString name, QString exec, QString url, QString filter,
QString detection, QString spam, QString ham,
QString header, QString pattern, bool regExp,
bool bayesFilter, WizardMode type );
QString header, QString pattern, bool detectionOnly,
bool regExp, bool bayesFilter, WizardMode type );
int getVersion() const { return mVersion; }
QString getId() const { return mId; }
@ -143,6 +144,7 @@ namespace KMail {
QString getHamCmd() const { return mHamCmd; }
QString getDetectionHeader() const { return mDetectionHeader; }
QString getDetectionPattern() const { return mDetectionPattern; }
bool isDetectionOnly() const { return mDetectionOnly; }
bool isUseRegExp() const { return mUseRegExp; }
bool useBayesFilter() const { return mSupportsBayesFilter; }
WizardMode getType() const { return mType; }
@ -174,6 +176,8 @@ namespace KMail {
QString mDetectionHeader;
// what header pattern is used to mark spam messages
QString mDetectionPattern;
// filter cannot search actively but relies on pattern by regExp or contain rule
bool mDetectionOnly;
// filter searches for the pattern by regExp or contain rule
bool mUseRegExp;
// can the tool learn spam and ham, has it a bayesian algorithm

@ -1,5 +1,5 @@
[General]
tools=3
tools=4
[Spamtool #1]
Ident=spamassassin
@ -13,6 +13,7 @@ ExecCmdSpam=sa-learn -L --spam --no-rebuild --single
ExecCmdHam=sa-learn -L --ham --no-rebuild --single
DetectionHeader=X-Spam-Flag
DetectionPattern=yes
DetectionOnly=0
UseRegExp=0
SupportsBayes=1
@ -28,6 +29,7 @@ ExecCmdSpam=bogofilter -N -s
ExecCmdHam=bogofilter -S -n
DetectionHeader=X-Bogosity
DetectionPattern=yes
DetectionOnly=0
UseRegExp=0
SupportsBayes=1
@ -43,5 +45,22 @@ ExecCmdSpam=$HOME/.annoyance-filter/annoyance-filter --read $HOME/.annoyance-fil
ExecCmdHam=$HOME/.annoyance-filter/annoyance-filter --read $HOME/.annoyance-filter/Dict.bin --phrasemin 1 --phrasemax 2 --mail - --prune --write $HOME/.annoyance-filter/Dict.bin --fwrite $HOME/.annoyance-filter/FastDict.bin
DetectionHeader=X-Annoyance-Filter-Classification
DetectionPattern=Junk
DetectionOnly=0
UseRegExp=0
SupportsBayes=1
[Spamtool #4]
Ident=gmx-antispam
Version=1
VisibleName=&GMX Spam Filter
Executable=echo
URL=http://www.gmx.net/de/produkte/virenschutz/index.html
PipeFilterName=
PipeCmdDetect=
ExecCmdSpam=
ExecCmdHam=
DetectionHeader=X-GMX-Antispam
DetectionPattern=^[2345]
DetectionOnly=1
UseRegExp=1
SupportsBayes=0

Loading…
Cancel
Save