33 #include "messageviewer/utils/kcursorsaver.h"
37 #include "folderrequester.h"
38 #include "foldertreewidget.h"
39 #include "foldertreeview.h"
40 #include "foldertreewidgetproxymodel.h"
41 #include "mailcommon/pop3settings.h"
42 #include "mailcommon/util/mailutil.h"
43 #include "pimcommon/imapresourcesettings.h"
44 #include "mailcommon/kernel/mailkernel.h"
45 #include "mailcommon/filter/mailfilter.h"
46 #include "mailcommon/filter/filteractions/filteraction.h"
47 #include "mailcommon/filter/filteractions/filteractiondict.h"
48 #include "mailcommon/filter/filtermanager.h"
50 #include "pimcommon/util/pimutil.h"
52 #include <Akonadi/AgentInstance>
56 #include <kiconloader.h>
59 #include <ktoolinvocation.h>
60 #include <kconfiggroup.h>
65 #include <QGridLayout>
66 #include <QHBoxLayout>
68 #include <QVBoxLayout>
70 #include <QListWidget>
72 using namespace KMail;
73 using namespace MailCommon;
91 kDebug() << endl <<
"Considered anti-spam tools:";
93 kDebug() << endl <<
"Considered anti-virus tools:";
97 kDebug() <<
"Predefined tool:" << (*it).getId();
98 kDebug() <<
"Config version:" << (*it).getVersion();
99 kDebug() <<
"Selection priority:" << (*it).getPrio();
100 kDebug() <<
"Displayed name:" << (*it).getVisibleName();
101 kDebug() <<
"Executable:" << (*it).getExecutable();
102 kDebug() <<
"WhatsThis URL:" << (*it).getWhatsThisText();
103 kDebug() <<
"Filter name:" << (*it).getFilterName();
104 kDebug() <<
"Detection command:" << (*it).getDetectCmd();
105 kDebug() <<
"Learn spam command:" << (*it).getSpamCmd();
106 kDebug() <<
"Learn ham command:" << (*it).getHamCmd();
107 kDebug() <<
"Detection header:" << (*it).getDetectionHeader();
108 kDebug() <<
"Detection pattern:" << (*it).getDetectionPattern();
109 kDebug() <<
"Use as RegExp:" << (*it).isUseRegExp();
110 kDebug() <<
"Supports Bayes Filter:" << (*it).useBayesFilter();
111 kDebug() <<
"Type:" << (*it).getType();
115 const bool isAntiSpam = (mMode ==
AntiSpam);
116 setWindowTitle( isAntiSpam ? i18n(
"Anti-Spam Wizard" )
117 : i18n(
"Anti-Virus Wizard" ) );
119 mInfoPageItem = addPage( mInfoPage,
121 ? i18n(
"Welcome to the KMail Anti-Spam Wizard" )
122 : i18n(
"Welcome to the KMail Anti-Virus Wizard" ) );
123 connect( mInfoPage, SIGNAL(selectionChanged()),
128 mSpamRulesPageItem = addPage( mSpamRulesPage, i18n(
"Options to fine-tune the handling of spam messages" ));
129 connect( mSpamRulesPage, SIGNAL(selectionChanged()),
133 mSummaryPageItem = addPage( mSummaryPage, i18n(
"Summary of changes to be made by this wizard" ) );
136 mVirusRulesPageItem = addPage( mVirusRulesPage, i18n(
"Options to fine-tune the handling of virus messages" ));
137 connect( mVirusRulesPage, SIGNAL(selectionChanged()),
141 connect(
this, SIGNAL(helpClicked()),
150 if ( mSpamRulesPage ) {
151 kDebug() <<
"Folder name for messages classified as spam is"
153 kDebug() <<
"Folder name for messages classified as unsure is"
156 if ( mVirusRulesPage ) {
157 kDebug() <<
"Folder name for viruses is"
161 FilterActionDict dict;
163 bool replaceExistingFilters =
false;
168 if ( !mVirusToolsUsed ) {
180 MailFilter* pipeFilter =
new MailFilter();
183 pipeFilterAction->argsFromString( (*it).getDetectCmd() );
184 pipeFilterActions->
append( pipeFilterAction );
185 SearchPattern* pipeFilterPattern = pipeFilter->pattern();
186 pipeFilterPattern->setName( uniqueNameFor( (*it).getFilterName() ) );
187 pipeFilterPattern->append( SearchRule::createInstance(
"<size>",
189 pipeFilter->setApplyOnOutbound(
false);
190 pipeFilter->setApplyOnInbound();
191 pipeFilter->setApplyOnExplicit();
192 pipeFilter->setStopProcessingHere(
false );
193 pipeFilter->setConfigureShortcut(
false );
195 filterList.
append( pipeFilter );
201 MailFilter* virusFilter =
new MailFilter();
205 virusFilterActions->
append( virusFilterAction1 );
207 FilterAction* virusFilterAction2 = dict.value(
QLatin1String(
"set status" ))->create();
209 virusFilterActions->
append( virusFilterAction2 );
211 SearchPattern* virusFilterPattern = virusFilter->pattern();
212 virusFilterPattern->setName( uniqueNameFor( i18n(
"Virus handling" ) ) );
213 virusFilterPattern->setOp( SearchPattern::OpOr );
216 it != endSpamTool; ++it ) {
218 if ( (*it).isVirusTool() ) {
219 const QByteArray header = (*it).getDetectionHeader().toLatin1();
220 const QString & pattern = (*it).getDetectionPattern();
221 if ( (*it).isUseRegExp() )
222 virusFilterPattern->
append(
223 SearchRule::createInstance( header,
224 SearchRule::FuncRegExp, pattern ) );
226 virusFilterPattern->
append(
227 SearchRule::createInstance( header,
228 SearchRule::FuncContains, pattern ) );
232 virusFilter->setApplyOnOutbound(
false);
233 virusFilter->setApplyOnInbound();
234 virusFilter->setApplyOnExplicit();
235 virusFilter->setStopProcessingHere(
true );
236 virusFilter->setConfigureShortcut(
false );
238 filterList.
append( virusFilter );
241 if ( !mSpamToolsUsed ) {
248 replaceExistingFilters =
true;
253 (*it).isSpamTool() && !(*it).isDetectionOnly() ) {
257 MailFilter* pipeFilter =
new MailFilter();
260 pipeFilterAction->argsFromString( (*it).getDetectCmd() );
261 pipeFilterActions->
append( pipeFilterAction );
262 SearchPattern* pipeFilterPattern = pipeFilter->pattern();
263 if ( replaceExistingFilters )
264 pipeFilterPattern->setName( (*it).getFilterName() );
266 pipeFilterPattern->setName( uniqueNameFor( (*it).getFilterName() ) );
267 pipeFilterPattern->append( SearchRule::createInstance(
"<size>",
269 pipeFilter->setApplyOnOutbound(
false);
270 pipeFilter->setApplyOnInbound();
271 pipeFilter->setApplyOnExplicit();
272 pipeFilter->setStopProcessingHere(
false );
273 pipeFilter->setConfigureShortcut(
false );
275 filterList.
append( pipeFilter );
280 MailFilter* spamFilter =
new MailFilter();
285 spamFilterActions->
append( spamFilterAction1 );
287 FilterAction* spamFilterAction2 = dict.value(
QLatin1String(
"set status") )->create();
289 spamFilterActions->
append( spamFilterAction2 );
291 FilterAction* spamFilterAction3 = dict.value(
QLatin1String(
"set status") )->create();
293 spamFilterActions->
append( spamFilterAction3 );
295 SearchPattern* spamFilterPattern = spamFilter->pattern();
296 if ( replaceExistingFilters )
297 spamFilterPattern->setName( i18n(
"Spam Handling" ) );
299 spamFilterPattern->setName( uniqueNameFor( i18n(
"Spam Handling" ) ) );
300 spamFilterPattern->setOp( SearchPattern::OpOr );
303 it != endToolList; ++it ) {
305 if ( (*it).isSpamTool() ) {
306 const QByteArray header = (*it).getDetectionHeader().toLatin1();
307 const QString & pattern = (*it).getDetectionPattern();
308 if ( (*it).isUseRegExp() )
309 spamFilterPattern->
append(
310 SearchRule::createInstance( header,
311 SearchRule::FuncRegExp, pattern ) );
313 spamFilterPattern->
append(
314 SearchRule::createInstance( header,
315 SearchRule::FuncContains, pattern ) );
319 spamFilter->setApplyOnOutbound(
false);
320 spamFilter->setApplyOnInbound();
321 spamFilter->setApplyOnExplicit();
322 spamFilter->setStopProcessingHere(
true );
323 spamFilter->setConfigureShortcut(
false );
324 filterList.
append( spamFilter );
328 bool atLeastOneUnsurePattern =
false;
329 MailFilter* unsureFilter =
new MailFilter();
331 FilterAction* unsureFilterAction1 = dict.
value(
QLatin1String(
"transfer") )->create();
333 unsureFilterActions->
append( unsureFilterAction1 );
334 SearchPattern* unsureFilterPattern = unsureFilter->pattern();
335 if ( replaceExistingFilters )
336 unsureFilterPattern->setName( i18n(
"Semi spam (unsure) handling" ) );
338 unsureFilterPattern->setName( uniqueNameFor( i18n(
"Semi spam (unsure) handling" ) ) );
339 unsureFilterPattern->setOp( SearchPattern::OpOr );
345 if ( (*it).isSpamTool() && (*it).hasTristateDetection())
347 atLeastOneUnsurePattern =
true;
348 const QByteArray header = (*it).getDetectionHeader().toLatin1();
349 const QString & pattern = (*it).getDetectionPattern2();
350 if ( (*it).isUseRegExp() )
351 unsureFilterPattern->
append(
352 SearchRule::createInstance( header,
353 SearchRule::FuncRegExp, pattern ) );
355 unsureFilterPattern->
append(
356 SearchRule::createInstance( header,
357 SearchRule::FuncContains, pattern ) );
361 unsureFilter->setApplyOnOutbound(
false);
362 unsureFilter->setApplyOnInbound();
363 unsureFilter->setApplyOnExplicit();
364 unsureFilter->setStopProcessingHere(
true );
365 unsureFilter->setConfigureShortcut(
false );
367 if ( atLeastOneUnsurePattern )
368 filterList.
append( unsureFilter );
374 MailFilter* classSpamFilter =
new MailFilter();
377 FilterAction* classSpamFilterActionFirst = dict.
value(
QLatin1String(
"set status") )->create();
378 classSpamFilterActionFirst->argsFromString(
QLatin1String(
"P") );
379 classSpamFilterActions->
append( classSpamFilterActionFirst );
382 it != endToolList2; ++it ) {
384 && (*it).useBayesFilter() && !(*it).isDetectionOnly() )
386 FilterAction* classSpamFilterAction = dict.
value(
QLatin1String(
"execute") )->create();
387 classSpamFilterAction->argsFromString( (*it).getSpamCmd() );
388 classSpamFilterActions->
append( classSpamFilterAction );
392 FilterAction* classSpamFilterActionLast = dict.value(
QLatin1String(
"transfer" ))->create();
394 classSpamFilterActions->
append( classSpamFilterActionLast );
397 SearchPattern* classSpamFilterPattern = classSpamFilter->pattern();
398 if ( replaceExistingFilters )
399 classSpamFilterPattern->setName( i18n(
"Classify as Spam" ) );
401 classSpamFilterPattern->setName( uniqueNameFor( i18n(
"Classify as Spam" ) ) );
402 classSpamFilterPattern->append( SearchRule::createInstance(
"<size>",
404 classSpamFilter->setApplyOnOutbound(
false);
405 classSpamFilter->setApplyOnInbound(
false );
406 classSpamFilter->setApplyOnExplicit(
false );
407 classSpamFilter->setStopProcessingHere(
true );
408 classSpamFilter->setConfigureShortcut(
true );
409 classSpamFilter->setConfigureToolbar(
true );
410 classSpamFilter->setToolbarName( i18n(
"Spam" ) );
411 filterList.
append( classSpamFilter );
414 MailFilter* classHamFilter =
new MailFilter();
415 classHamFilter->setIcon(
QLatin1String(
"mail-mark-notjunk") );
417 FilterAction* classHamFilterActionFirst = dict.
value(
QLatin1String(
"set status") )->create();
418 classHamFilterActionFirst->argsFromString(
QLatin1String(
"H") );
419 classHamFilterActions->
append( classHamFilterActionFirst );
420 end = mToolList.constEnd();
424 && (*it).useBayesFilter() && !(*it).isDetectionOnly() )
426 FilterAction* classHamFilterAction = dict.value(
QLatin1String(
"execute") )->create();
427 classHamFilterAction->argsFromString( (*it).getHamCmd() );
428 classHamFilterActions->
append( classHamFilterAction );
431 end = mToolList.constEnd();
435 && (*it).useBayesFilter() && !(*it).isDetectionOnly() )
437 FilterAction* classHamFilterAction = dict.value(
QLatin1String(
"filter app") )->create();
438 classHamFilterAction->argsFromString( (*it).getNoSpamCmd() );
439 classHamFilterActions->
append( classHamFilterAction );
442 SearchPattern* classHamFilterPattern = classHamFilter->pattern();
443 if ( replaceExistingFilters )
444 classHamFilterPattern->setName( i18n(
"Classify as NOT Spam" ) );
446 classHamFilterPattern->setName( uniqueNameFor( i18n(
"Classify as NOT Spam" ) ) );
447 classHamFilterPattern->append( SearchRule::createInstance(
"<size>",
449 classHamFilter->setApplyOnOutbound(
false);
450 classHamFilter->setApplyOnInbound(
false );
451 classHamFilter->setApplyOnExplicit(
false );
452 classHamFilter->setStopProcessingHere(
true );
453 classHamFilter->setConfigureShortcut(
true );
454 classHamFilter->setConfigureToolbar(
true );
455 classHamFilter->setToolbarName( i18n(
"Ham" ) );
456 filterList.
append( classHamFilter );
464 MailCommon::FilterManager::instance()->appendFilters( filterList, replaceExistingFilters );
472 bool supportUnsure =
false;
474 mSpamToolsUsed =
false;
475 mVirusToolsUsed =
false;
480 if ( (*it).isSpamTool() ) {
481 mSpamToolsUsed =
true;
482 if ( (*it).hasTristateDetection() )
483 supportUnsure =
true;
485 if ( (*it).isVirusTool() )
486 mVirusToolsUsed =
true;
488 if ( mSpamToolsUsed && mVirusToolsUsed && supportUnsure )
497 setAppropriate( mSpamRulesPageItem, mSpamToolsUsed );
498 setAppropriate( mSummaryPageItem, mSpamToolsUsed );
501 if ( mVirusToolsUsed )
503 setAppropriate( mVirusRulesPageItem, mVirusToolsUsed );
518 MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
524 const QString text( i18n(
"Scanning for %1...", (*it).getId() ) );
526 if ( (*it).isSpamTool() && (*it).isServerBased() ) {
528 const QString pattern = (*it).getServerPattern();
529 kDebug() <<
"Testing for server pattern:" << pattern;
530 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
531 foreach(
const Akonadi::AgentInstance& type, lst ) {
532 if ( type.status() == Akonadi::AgentInstance::Broken )
534 if ( PimCommon::Util::isImapResource(type.identifier()) ) {
535 OrgKdeAkonadiImapSettingsInterface *iface = PimCommon::Util::createImapSettingsInterface( type.identifier() );
536 if ( iface->isValid() ) {
537 const QString host = iface->imapServer();
545 else if ( type.identifier().contains( POP3_RESOURCE_IDENTIFIER ) ) {
546 OrgKdeAkonadiPOP3SettingsInterface *iface = MailCommon::Util::createPop3SettingsInterface( type.identifier() );
547 if ( iface->isValid() ) {
548 const QString host = iface->host();
560 qApp->processEvents( QEventLoop::ExcludeUserInputEvents, 200 );
561 if ( !checkForProgram( (*it).getExecutable() ) ) {
569 ? i18n(
"Scanning for anti-spam tools finished.")
570 : i18n(
"Scanning for anti-virus tools finished.") );
573 ? i18n(
"<p>Sorry, no spam detection tools have been found. "
574 "Install your spam detection software and "
575 "re-run this wizard.</p>")
576 : i18n(
"Scanning complete. No anti-virus tools found.") );
600 text = i18n(
"<p>Messages classified as spam are marked as read."
601 "<br />Spam messages are moved into the folder named <i>%1</i>.</p>"
604 text = i18n(
"<p>Messages classified as spam are marked as read."
605 "<br />Spam messages are not moved into a certain folder.</p>" );
609 text = i18n(
"<p>Messages classified as spam are not marked as read."
610 "<br />Spam messages are moved into the folder named <i>%1</i>.</p>"
613 text = i18n(
"<p>Messages classified as spam are not marked as read."
614 "<br />Spam messages are not moved into a certain folder.</p>" );
620 (*it).isSpamTool() && !(*it).isDetectionOnly() ) {
621 sortFilterOnExistance( (*it).getFilterName(), newFilters, replaceFilters );
624 sortFilterOnExistance( i18n(
"Spam Handling" ), newFilters, replaceFilters );
628 bool atLeastOneUnsurePattern =
false;
629 end = mToolList.constEnd();
633 if ( (*it).isSpamTool() && (*it).hasTristateDetection()) {
634 atLeastOneUnsurePattern =
true;
639 if ( atLeastOneUnsurePattern ) {
640 sortFilterOnExistance( i18n(
"Semi spam (unsure) handling" ),
641 newFilters, replaceFilters );
642 text += i18n(
"<p>The folder for messages classified as unsure (probably spam) is <i>%1</i>.</p>"
648 sortFilterOnExistance( i18n(
"Classify as Spam" ),
649 newFilters, replaceFilters );
650 sortFilterOnExistance( i18n(
"Classify as NOT Spam" ),
651 newFilters, replaceFilters );
655 text += i18n(
"<p>The wizard will create the following filters:<ul>%1</ul></p>"
657 if ( !replaceFilters.
isEmpty() )
658 text += i18n(
"<p>The wizard will replace the following filters:<ul>%1</ul></p>"
666 int AntiSpamWizard::checkForProgram(
const QString &executable )
const
668 kDebug() <<
"Testing for executable:" << executable;
670 process.setShellCommand( executable );
671 return process.execute ();
675 bool AntiSpamWizard::anyVirusOptionChecked()
const
682 const QString AntiSpamWizard::uniqueNameFor(
const QString & name )
684 return MailCommon::FilterManager::instance()->createUniqueFilterName( name );
688 void AntiSpamWizard::sortFilterOnExistance(
689 const QString & intendedFilterName,
692 if ( uniqueNameFor( intendedFilterName ) == intendedFilterName )
701 int configVersion,
int prio,
const QString &name,
const QString &exec,
705 const QString &serverPattern,
bool detectionOnly,
bool regExp,
706 bool bayesFilter,
bool tristateDetection,
WizardMode type )
707 : mId( toolId ), mVersion( configVersion ), mPrio( prio ),
708 mVisibleName( name ), mExecutable( exec ), mWhatsThisText( url ),
709 mFilterName( filter ), mDetectCmd( detection ), mSpamCmd( spam ),
710 mHamCmd( ham ), mNoSpamCmd( noSpam ), mDetectionHeader( header ),
711 mDetectionPattern( pattern ), mDetectionPattern2( pattern2 ),
712 mServerPattern( serverPattern ), mDetectionOnly( detectionOnly ),
713 mUseRegExp( regExp ), mSupportsBayesFilter( bayesFilter ),
714 mSupportsUnsure( tristateDetection ), mType( type )
721 return !mServerPattern.isEmpty();
728 : mToolList( configList ),
732 mConfig = KSharedConfig::openConfig(
QLatin1String(
"kmail.antispamrc") );
734 mConfig = KSharedConfig::openConfig(
QLatin1String(
"kmail.antivirusrc") );
748 mConfig->setReadDefaults(
true );
749 KConfigGroup general( mConfig,
"General" );
750 const int registeredTools = general.readEntry(
"tools", 0 );
751 for (
int i = 1; i <= registeredTools; ++i)
753 KConfigGroup toolConfig( mConfig, groupName.
arg( i ) );
754 if( !toolConfig.readEntry(
"HeadersOnly",
false ) )
755 mToolList.append( readToolConfig( toolConfig ) );
760 mConfig->setReadDefaults(
false );
761 KConfigGroup user_general( mConfig,
"General" );
762 const int user_registeredTools = user_general.readEntry(
"tools", 0 );
763 for (
int i = 1; i <= user_registeredTools; ++i)
765 KConfigGroup toolConfig( mConfig, groupName.
arg( i ) );
766 if( !toolConfig.readEntry(
"HeadersOnly",
false ) )
767 mergeToolConfig( readToolConfig( toolConfig ) );
773 if ( registeredTools < 1 && user_registeredTools < 1 )
774 mToolList.append( createDummyConfig() );
781 AntiSpamWizard::ConfigReader::readToolConfig( KConfigGroup & configGroup )
783 const QString id = configGroup.readEntry(
"Ident" );
784 const int version = configGroup.readEntry(
"Version", 0 );
786 kDebug() <<
"Found predefined tool:" << id;
787 kDebug() <<
"With config version :" << version;
789 const int prio = configGroup.readEntry(
"Priority", 1 );
790 const QString name = configGroup.readEntry(
"VisibleName" );
791 const QString executable = configGroup.readEntry(
"Executable" );
792 const QString url = configGroup.readEntry(
"URL" );
793 const QString filterName = configGroup.readEntry(
"PipeFilterName" );
794 const QString detectCmd = configGroup.readEntry(
"PipeCmdDetect" );
795 const QString spamCmd = configGroup.readEntry(
"ExecCmdSpam" );
796 const QString hamCmd = configGroup.readEntry(
"ExecCmdHam" );
797 const QString noSpamCmd = configGroup.readEntry(
"PipeCmdNoSpam" );
798 const QString header = configGroup.readEntry(
"DetectionHeader" );
799 const QString pattern = configGroup.readEntry(
"DetectionPattern" );
800 const QString pattern2 = configGroup.readEntry(
"DetectionPattern2" );
801 const QString serverPattern = configGroup.readEntry(
"ServerPattern" );
802 const bool detectionOnly = configGroup.readEntry(
"DetectionOnly",
false );
803 const bool useRegExp = configGroup.readEntry(
"UseRegExp",
false );
804 const bool supportsBayes = configGroup.readEntry(
"SupportsBayes",
false );
805 const bool supportsUnsure = configGroup.readEntry(
"SupportsUnsure",
false );
807 filterName, detectCmd, spamCmd, hamCmd, noSpamCmd,
808 header, pattern, pattern2, serverPattern,
809 detectionOnly, useRegExp,
810 supportsBayes, supportsUnsure, mMode );
824 false,
false,
true,
false,
AntiSpam );
835 kDebug() <<
"Check against tool:" << (*it).getId();
836 kDebug() <<
"Against version :" << (*it).getVersion();
838 if ( (*it).getId() == config.
getId() )
841 if ( (*it).getVersion() < config.
getVersion() )
844 kDebug() <<
"Replacing config ...";
846 mToolList.erase( it );
847 mToolList.append( config );
853 mToolList.append( config );
857 void AntiSpamWizard::ConfigReader::sortToolList()
860 SpamToolConfig config;
862 while ( !mToolList.isEmpty() ) {
868 if ( (*it).getPrio() > priority ) {
869 priority = (*it).getPrio();
875 mToolList.erase( highest );
880 mToolList.append( (*it) );
900 bannerLabel->
setPixmap( UserIcon(banner) );
904 bannerLabel->
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
907 sideLayout->
addItem(
new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
923 "The wizard will search for any tools to do spam detection\n"
924 "and setup KMail to work with them."
927 "<p>Here you can get some assistance in setting up KMail's filter "
928 "rules to use some commonly-known anti-virus tools.</p>"
929 "<p>The wizard can detect those tools on your computer as "
930 "well as create filter rules to classify messages using these "
931 "tools and to separate messages containing viruses. "
932 "The wizard will not take any existing filter "
933 "rules into consideration: it will always append the new rules.</p>"
934 "<p><b>Warning:</b> As KMail appears to be frozen during the scan of the "
935 "messages for viruses, you may encounter problems with "
936 "the responsiveness of KMail because anti-virus tool "
937 "operations are usually time consuming; please consider "
938 "deleting the filter rules created by the wizard to get "
939 "back to the former behavior.</p>"
945 mScanProgressText =
new QLabel(
this );
946 mScanProgressText->
clear();
958 this, SLOT(processSelectionChange()) );
960 mSelectionHint =
new QLabel(
this );
961 mSelectionHint->clear();
962 mSelectionHint->setWordWrap(
true );
969 mScanProgressText->
setText( toolName );
975 mToolsList->
addItem( visibleName );
981 mSelectionHint->
setText( i18n(
"<p>Please select the tools to be used "
982 "for the detection and go "
983 "to the next page.</p>") );
990 return (!foundItems.
isEmpty() && foundItems[0]->isSelected());
994 void ASWizInfoPage::processSelectionChange()
1007 mMarkRules =
new QCheckBox( i18n(
"&Mark detected spam messages as read"),
this );
1009 i18n(
"Mark messages which have been classified as spam as read.") );
1012 mMoveSpamRules =
new QCheckBox( i18n(
"Move &known spam to:"),
this );
1014 i18n(
"The default folder for spam messages is the trash folder, "
1015 "but you may change that in the folder view below.") );
1018 mFolderReqForSpamFolder =
new FolderRequester(
this );
1019 mFolderReqForSpamFolder->setCollection( CommonKernel->trashCollectionFolder() );
1020 mFolderReqForSpamFolder->setMustBeReadWrite(
true );
1021 mFolderReqForSpamFolder->setShowOutbox(
false );
1025 hLayout1->
addSpacing( KDialog::spacingHint() * 3 );
1026 hLayout1->
addWidget( mFolderReqForSpamFolder );
1028 mMoveUnsureRules =
new QCheckBox( i18n(
"Move &probable spam to:"),
this );
1030 i18n(
"The default folder is the inbox folder, but you may change that "
1031 "in the folder view below.<p>"
1032 "Not all tools support a classification as unsure. If you have not "
1033 "selected a capable tool, you cannot select a folder as well.</p>") );
1036 mFolderReqForUnsureFolder =
new FolderRequester(
this );
1037 mFolderReqForUnsureFolder->setCollection( CommonKernel->inboxCollectionFolder() );
1038 mFolderReqForUnsureFolder->setMustBeReadWrite(
true );
1039 mFolderReqForUnsureFolder->setShowOutbox(
false );
1043 hLayout2->
addSpacing( KDialog::spacingHint() * 3 );
1044 hLayout2->
addWidget( mFolderReqForUnsureFolder );
1048 connect( mMarkRules, SIGNAL(clicked()),
1049 this, SLOT(processSelectionChange()) );
1050 connect( mMoveSpamRules, SIGNAL(clicked()),
1051 this, SLOT(processSelectionChange()) );
1052 connect( mMoveUnsureRules, SIGNAL(clicked()),
1053 this, SLOT(processSelectionChange()) );
1054 connect( mFolderReqForSpamFolder, SIGNAL(folderChanged(Akonadi::Collection)),
1055 this, SLOT(processSelectionChange(Akonadi::Collection)) );
1056 connect( mFolderReqForUnsureFolder, SIGNAL(folderChanged(Akonadi::Collection)),
1057 this, SLOT(processSelectionChange(Akonadi::Collection)) );
1093 if ( mFolderReqForSpamFolder->hasCollection() )
1094 return mFolderReqForSpamFolder->collection();
1096 return CommonKernel->trashCollectionFolder();
1102 if ( mFolderReqForUnsureFolder->hasCollection() )
1103 return mFolderReqForUnsureFolder->collection();
1105 return CommonKernel->inboxCollectionFolder();
1119 void ASWizSpamRulesPage::processSelectionChange()
1121 mFolderReqForSpamFolder->setEnabled( mMoveSpamRules->
isChecked() );
1122 mFolderReqForUnsureFolder->setEnabled( mMoveUnsureRules->
isChecked() );
1127 void ASWizSpamRulesPage::processSelectionChange(
const Akonadi::Collection& )
1129 processSelectionChange();
1137 mFolderReqForUnsureFolder->setEnabled( enabled );
1138 mFolderReqForUnsureFolder->setVisible( enabled );
1158 mPipeRules =
new QCheckBox( i18n(
"Check messages using the anti-virus tools"),
this );
1160 i18n(
"Let the anti-virus tools check your messages. The wizard "
1161 "will create appropriate filters. The messages are usually "
1162 "marked by the tools so that following filters can react "
1163 "on this and, for example, move virus messages to a special folder.") );
1166 mMoveRules =
new QCheckBox( i18n(
"Move detected viral messages to the selected folder"),
this );
1168 i18n(
"A filter to detect messages classified as virus-infected and to move "
1169 "those messages into a predefined folder is created. The "
1170 "default folder is the trash folder, but you may change that "
1171 "in the folder view.") );
1174 mMarkRules =
new QCheckBox( i18n(
"Additionally, mark detected viral messages as read"),
this );
1177 i18n(
"Mark messages which have been classified as "
1178 "virus-infected as read, as well as moving them "
1179 "to the selected folder.") );
1181 FolderTreeWidget::TreeViewOptions opt = FolderTreeWidget::None;
1182 opt |= FolderTreeWidget::UseDistinctSelectionModel;
1184 FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModelOptions optReadableProxy = FolderTreeWidgetProxyModel::None;
1185 optReadableProxy |= FolderTreeWidgetProxyModel::HideVirtualFolder;
1186 optReadableProxy |= FolderTreeWidgetProxyModel::HideOutboxFolder;
1188 mFolderTree =
new FolderTreeWidget(
this, 0, opt, optReadableProxy );
1189 mFolderTree->readConfig();
1190 mFolderTree->folderTreeView()->expandAll();
1191 mFolderTree->folderTreeWidgetProxyModel()->setAccessRights( Akonadi::Collection::CanCreateCollection );
1193 mFolderTree->selectCollectionFolder( CommonKernel->trashCollectionFolder() );
1194 mFolderTree->folderTreeView()->setDragDropMode( QAbstractItemView::NoDragDrop );
1196 mFolderTree->disableContextMenuAndExtraColumn();
1199 connect( mPipeRules, SIGNAL(clicked()),
1200 this, SLOT(processSelectionChange()) );
1201 connect( mMoveRules, SIGNAL(clicked()),
1202 this, SLOT(processSelectionChange()) );
1203 connect( mMarkRules, SIGNAL(clicked()),
1204 this, SLOT(processSelectionChange()) );
1205 connect( mMoveRules, SIGNAL(toggled(
bool)),
1229 if ( mFolderTree->selectedCollection().isValid() )
1235 void ASWizVirusRulesPage::processSelectionChange()
1248 mSummaryText =
new QLabel(
this );
1256 mSummaryText->
setText( text );
Akonadi::Collection selectedUnsureCollection() const
void setSummaryText(const QString &text)
QString selectedUnsureCollectionName() const
QString & append(QChar ch)
void addAvailableTool(const QString &visibleName)
bool markAsReadSelected() const
void checkProgramsSelections()
Modify the status of the wizard to reflect the selection of spam tools.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QString selectedSpamCollectionName() const
QItemSelectionModel * selectionModel() const
virtual QByteArray text(quint32 serialNumber) const =0
void setFrameShape(Shape)
WizardMode
The wizard can be used for setting up anti-spam tools and for setting up anti-virus tools...
void setPixmap(const QPixmap &)
void readAndMergeConfig()
void setLayoutMode(LayoutMode mode)
ASWizSummaryPage(QWidget *parent, const QString &name)
void addSpacing(int size)
void setSpacing(int spacing)
bool moveUnsureSelected() const
QString number(int n, int base)
void append(const T &value)
QList< SpamToolConfig > & getToolList()
AntiSpamWizard(WizardMode mode, QWidget *parent)
Constructor that needs to initialize from the main folder tree of KMail.
virtual void addItem(QLayoutItem *item)
QString selectedFolderName() const
void setObjectName(const QString &name)
ASWizVirusRulesPage(QWidget *parent, const QString &name)
void setScaledContents(bool)
void setText(const QString &)
void setMargin(int margin)
QString selectedUnsureCollectionId() const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
bool markReadRulesSelected() const
void setFrameShadow(Shadow)
ConfigReader(WizardMode mode, QList< SpamToolConfig > &configList)
void slotBuildSummary()
Create the summary text based on the current settings.
void addStretch(int stretch)
void setScanProgressText(const QString &toolName)
void accept()
Evaluate the settings made and create the appropriate filter rules.
void allowUnsureFolderSelection(bool enabled)
bool isProgramSelected(const QString &visibleName) const
QString fromLatin1(const char *str, int size)
void setReadOnly(bool ro)
Akonadi::Collection selectedSpamCollection() const
void setBatchSize(int batchSize)
const_iterator constEnd() const
const_iterator constBegin() const
Instances of this class control reading the configuration of the anti-spam tools from global and user...
ASWizSpamRulesPage(QWidget *parent, const QString &name)
void allowMoveSpam(bool enabled)
ASWizPage(QWidget *parent, const QString &name)
bool pipeRulesSelected() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void slotHelpClicked()
Show a help topic.
void setText(const QString &text)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void checkVirusRulesSelections()
Modify the status of the wizard to reflect the selected functionality.
bool moveRulesSelected() const
void setWordWrap(bool on)
bool moveSpamSelected() const
void setSpacing(int spacing)
QString selectedSpamCollectionId() const
ASWizInfoPage(AntiSpamWizard::WizardMode mode, QWidget *parent, const QString &name)
void checkToolAvailability()
Check if the spam tools are available via the PATH.