diff --git a/antispamwizard.cpp b/antispamwizard.cpp index c5414e1af..3dc5949cb 100644 --- a/antispamwizard.cpp +++ b/antispamwizard.cpp @@ -218,7 +218,8 @@ void AntiSpamWizard::accept() for ( QValueListIterator 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 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 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 ); } diff --git a/antispamwizard.h b/antispamwizard.h index ba18db5f2..e25181954 100644 --- a/antispamwizard.h +++ b/antispamwizard.h @@ -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 diff --git a/kmail.antispamrc b/kmail.antispamrc index b1e586d4a..1ed7e1439 100644 --- a/kmail.antispamrc +++ b/kmail.antispamrc @@ -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