diff --git a/antispamwizard.cpp b/antispamwizard.cpp index 72b023aac..bcc2df62d 100644 --- a/antispamwizard.cpp +++ b/antispamwizard.cpp @@ -421,7 +421,17 @@ void AntiSpamWizard::accept() classHamFilterActions->append( classHamFilterAction ); } } - KMSearchPattern* classHamFilterPattern = classHamFilter->pattern(); + for ( QList::iterator it = mToolList.begin(); + it != mToolList.end(); ++it ) { + if ( mInfoPage->isProgramSelected( (*it).getVisibleName() ) + && (*it).useBayesFilter() && !(*it).isDetectionOnly() ) + { + KMFilterAction* classHamFilterAction = dict.value( "filter app" )->create(); + classHamFilterAction->argsFromString( (*it).getNoSpamCmd() ); + classHamFilterActions->append( classHamFilterAction ); + } + } + KMSearchPattern* classHamFilterPattern = classHamFilter->pattern(); if ( replaceExistingFilters ) classHamFilterPattern->setName( i18n( "Classify as NOT spam" ) ); else @@ -654,15 +664,15 @@ void AntiSpamWizard::sortFilterOnExistance( AntiSpamWizard::SpamToolConfig::SpamToolConfig( QString toolId, int configVersion, int prio, QString name, QString exec, QString url, QString filter, QString detection, QString spam, QString ham, - QString header, QString pattern, QString pattern2, QString serverPattern, - bool detectionOnly, bool regExp, bool bayesFilter, bool tristateDetection, - WizardMode type ) + QString noSpam, QString header, QString pattern, QString pattern2, + QString serverPattern, bool detectionOnly, bool regExp, bool bayesFilter, + bool tristateDetection, WizardMode type ) : mId( toolId ), mVersion( configVersion ), mPrio( prio ), mVisibleName( name ), mExecutable( exec ), mWhatsThisText( url ), mFilterName( filter ), mDetectCmd( detection ), mSpamCmd( spam ), - mHamCmd( ham ), mDetectionHeader( header ), mDetectionPattern( pattern ), - mDetectionPattern2( pattern2 ), mServerPattern( serverPattern ), - mDetectionOnly( detectionOnly ), + mHamCmd( ham ), mNoSpamCmd( noSpam ), mDetectionHeader( header ), + mDetectionPattern( pattern ), mDetectionPattern2( pattern2 ), + mServerPattern( serverPattern ), mDetectionOnly( detectionOnly ), mUseRegExp( regExp ), mSupportsBayesFilter( bayesFilter ), mSupportsUnsure( tristateDetection ), mType( type ) { @@ -748,6 +758,7 @@ AntiSpamWizard::SpamToolConfig QString detectCmd = configGroup.readEntry( "PipeCmdDetect" ); QString spamCmd = configGroup.readEntry( "ExecCmdSpam" ); QString hamCmd = configGroup.readEntry( "ExecCmdHam" ); + QString noSpamCmd = configGroup.readEntry( "PipeCmdNoSpam" ); QString header = configGroup.readEntry( "DetectionHeader" ); QString pattern = configGroup.readEntry( "DetectionPattern" ); QString pattern2 = configGroup.readEntry( "DetectionPattern2" ); @@ -757,7 +768,7 @@ AntiSpamWizard::SpamToolConfig bool supportsBayes = configGroup.readEntry( "SupportsBayes", false ); bool supportsUnsure = configGroup.readEntry( "SupportsUnsure", false ); return SpamToolConfig( id, version, prio, name, executable, url, - filterName, detectCmd, spamCmd, hamCmd, + filterName, detectCmd, spamCmd, hamCmd, noSpamCmd, header, pattern, pattern2, serverPattern, detectionOnly, useRegExp, supportsBayes, supportsUnsure, mMode ); @@ -772,6 +783,7 @@ AntiSpamWizard::SpamToolConfig AntiSpamWizard::ConfigReader::createDummyConfig() "spamassassin -L", "sa-learn -L --spam --no-rebuild --single", "sa-learn -L --ham --no-rebuild --single", + "spamassassin -d", "X-Spam-Flag", "yes", "", "", false, false, true, false, AntiSpam ); } diff --git a/antispamwizard.h b/antispamwizard.h index ca020f880..6c2dd9d06 100644 --- a/antispamwizard.h +++ b/antispamwizard.h @@ -91,7 +91,8 @@ namespace KMail { PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn --spam --no-rebuild --single ExecCmdHam=sa-learn --ham --no-rebuild --single - DetectionHeader=X-Spam-Flag + PipeCmdNoSpam=spamassassin -d + DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= DetectionOnly=0 @@ -139,8 +140,8 @@ namespace KMail { SpamToolConfig( QString toolId, int configVersion, int prio, QString name, QString exec, QString url, QString filter, QString detection, QString spam, QString ham, - QString header, QString pattern, QString pattern2, - QString serverPattern, + QString noSpam, QString header, QString pattern, + QString pattern2, QString serverPattern, bool detectionOnly, bool regExp, bool bayesFilter, bool tristateDetection, WizardMode type ); @@ -154,6 +155,7 @@ namespace KMail { QString getDetectCmd() const { return mDetectCmd; } QString getSpamCmd() const { return mSpamCmd; } QString getHamCmd() const { return mHamCmd; } + QString getNoSpamCmd() const { return mNoSpamCmd; } QString getDetectionHeader() const { return mDetectionHeader; } QString getDetectionPattern() const { return mDetectionPattern; } QString getDetectionPattern2() const { return mDetectionPattern2; } @@ -190,7 +192,9 @@ namespace KMail { QString mSpamCmd; // pipe through cmd to let the tool learn a ham message QString mHamCmd; - // by which header are messages marked as spam + // pipe through cmd to let the tool delete the spam markup + QString mNoSpamCmd; + // by which header are messages marked as spam QString mDetectionHeader; // what header pattern is used to mark spam messages QString mDetectionPattern; diff --git a/kmail.antispamrc b/kmail.antispamrc index 06d8ddcff..a7157e02a 100644 --- a/kmail.antispamrc +++ b/kmail.antispamrc @@ -12,6 +12,7 @@ PipeFilterName=SpamAssassin Check PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn -L --spam --no-rebuild --single ExecCmdHam=sa-learn -L --ham --no-rebuild --single +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= @@ -36,6 +37,7 @@ PipeFilterName=Bogofilter Check PipeCmdDetect=bogofilter -p -e -u ExecCmdSpam=bogofilter -N -s ExecCmdHam=bogofilter -S -n +PipeCmdNoSpam= DetectionHeader=X-Bogosity DetectionPattern=(yes)|(spam\b) DetectionPattern2= @@ -60,6 +62,7 @@ PipeFilterName=Annoyance-Filter Check PipeCmdDetect=$HOME/.annoyance-filter/annoyance-filter --fread $HOME/.annoyance-filter/FastDict.bin --phrasemin 1 --phrasemax 2 --transcript - --test - ExecCmdSpam=$HOME/.annoyance-filter/annoyance-filter --read $HOME/.annoyance-filter/Dict.bin --phrasemin 1 --phrasemax 2 --junk - --prune --write $HOME/.annoyance-filter/Dict.bin --fwrite $HOME/.annoyance-filter/FastDict.bin 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 +PipeCmdNoSpam= DetectionHeader=X-Annoyance-Filter-Classification DetectionPattern=Junk DetectionPattern2= @@ -79,6 +82,7 @@ PipeFilterName= PipeCmdDetect= ExecCmdSpam= ExecCmdHam= +PipeCmdNoSpam= DetectionHeader=X-GMX-Antispam DetectionPattern=^[2345] DetectionPattern2= @@ -126,6 +130,7 @@ PipeFilterName=SpamAssassin Service Check PipeCmdDetect=spamc ExecCmdSpam=sa-learn -L --spam --no-rebuild --single ExecCmdHam=sa-learn -L --ham --no-rebuild --single +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= @@ -150,6 +155,7 @@ PipeFilterName=SpamAssassin Check PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn -L --spam --no-sync ExecCmdHam=sa-learn -L --ham --no-sync +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2=