00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
#ifndef KMAIL_ANTISPAMWIZARD_H
00030
#define KMAIL_ANTISPAMWIZARD_H
00031
00032
#include <kconfig.h>
00033
#include <kwizard.h>
00034
00035
#include <qcheckbox.h>
00036
#include <qdict.h>
00037
00038
class KActionCollection;
00039
class KMFolderTree;
00040
class QLabel;
00041
00042
namespace KMail {
00043
00044
class SimpleFolderTree;
00045
00046
class ASWizInfoPage;
00047
class ASWizProgramsPage;
00048
class ASWizSpamRulesPage;
00049
class ASWizVirusRulesPage;
00050
00051
00094 class AntiSpamWizard :
public KWizard
00095 {
00096 Q_OBJECT
00097
00098
public:
00102 enum WizardMode { AntiSpam, AntiVirus };
00103
00115
AntiSpamWizard( WizardMode mode,
00116
QWidget * parent, KMFolderTree * mainFolderTree,
00117 KActionCollection * collection );
00118
00119
protected:
00121
void accept();
00123
int checkForProgram(
QString executable );
00129 class SpamToolConfig
00130 {
00131
public:
00132
SpamToolConfig() {}
00133
SpamToolConfig(
QString toolId,
int configVersion,
00134
QString name,
QString exec,
QString url,
QString filter,
00135
QString detection,
QString spam,
QString ham,
00136
QString header,
QString pattern,
bool regExp,
00137
bool bayesFilter, WizardMode type );
00138
00139
int getVersion()
const {
return mVersion; }
00140
QString getId()
const {
return mId; }
00141
QString getVisibleName()
const {
return mVisibleName; }
00142
QString getExecutable()
const {
return mExecutable; }
00143
QString getWhatsThisText()
const {
return mWhatsThisText; }
00144
QString getFilterName()
const {
return mFilterName; }
00145
QString getDetectCmd()
const {
return mDetectCmd; }
00146
QString getSpamCmd()
const {
return mSpamCmd; }
00147
QString getHamCmd()
const {
return mHamCmd; }
00148
QString getDetectionHeader()
const {
return mDetectionHeader; }
00149
QString getDetectionPattern()
const {
return mDetectionPattern; }
00150
bool isUseRegExp()
const {
return mUseRegExp; }
00151
bool useBayesFilter()
const {
return mSupportsBayesFilter; }
00152 WizardMode getType()
const {
return mType; }
00153
00154
bool isSpamTool()
const {
return ( mType == AntiSpam ); }
00155
bool isVirusTool()
const {
return ( mType == AntiVirus ); }
00156
00157
private:
00158
00159
QString mId;
00160
00161
00162
int mVersion;
00163
00164
QString mVisibleName;
00165
00166
QString mExecutable;
00167
00168
QString mWhatsThisText;
00169
00170
QString mFilterName;
00171
00172
QString mDetectCmd;
00173
00174
QString mSpamCmd;
00175
00176
QString mHamCmd;
00177
00178
QString mDetectionHeader;
00179
00180
QString mDetectionPattern;
00181
00182
bool mUseRegExp;
00183
00184
bool mSupportsBayesFilter;
00185
00186 WizardMode mType;
00187 };
00193 class ConfigReader
00194 {
00195
public:
00196
ConfigReader( WizardMode mode,
00197
QValueList<SpamToolConfig> & configList );
00198
00199
QValueList<SpamToolConfig> & getToolList() {
return mToolList; }
00200
00201
void readAndMergeConfig();
00202
00203
private:
00204
QValueList<SpamToolConfig> & mToolList;
00205 KConfig *mConfig;
00206 WizardMode mMode;
00207
00208
SpamToolConfig readToolConfig( KConfigGroup & configGroup );
00209
SpamToolConfig createDummyConfig();
00210
00211
void mergeToolConfig(
SpamToolConfig config );
00212 };
00213
00214
00215
protected slots:
00217
void checkProgramsSelections();
00219
void checkSpamRulesSelections();
00221
void checkVirusRulesSelections();
00223
void checkToolAvailability();
00225
void slotHelpClicked();
00226
00227
private:
00228
00229
bool anySpamOptionChecked();
00230
bool anyVirusOptionChecked();
00231
00232
00233 ASWizInfoPage * mInfoPage;
00234 ASWizProgramsPage * mProgramsPage;
00235 ASWizSpamRulesPage * mSpamRulesPage;
00236 ASWizVirusRulesPage * mVirusRulesPage;
00237
00238
00239
QValueList<SpamToolConfig> mToolList;
00240
00241
00242 KActionCollection * mActionCollection;
00243
00244
00245
bool mSpamToolsUsed;
00246
00247
bool mVirusToolsUsed;
00248
00249
WizardMode mMode;
00250 };
00251
00252
00253
00254
00255
00256
class ASWizInfoPage :
public QWidget
00257 {
00258
public:
00259 ASWizInfoPage( AntiSpamWizard::WizardMode mode,
00260
QWidget *parent,
const char *name );
00261
00262
void setScanProgressText(
const QString &toolName );
00263
00264
private:
00265
QLabel *mIntroText;
00266
QLabel *mScanProgressText;
00267 };
00268
00269
00270
class ASWizProgramsPage :
public QWidget
00271 {
00272 Q_OBJECT
00273
00274
public:
00275 ASWizProgramsPage(
QWidget *parent,
const char *name,
00276
QStringList &checkBoxTextList,
00277
QStringList &checkBoxWhatsThisList );
00278
00279
bool isProgramSelected(
const QString &visibleName );
00280
void setProgramAsFound(
const QString &visibleName,
bool found );
00281
00282
private slots:
00283
void processSelectionChange();
00284
00285 signals:
00286
void selectionChanged();
00287
00288
private:
00289
QDict<QCheckBox> mProgramDict;
00290 };
00291
00292
00293
class ASWizSpamRulesPage :
public QWidget
00294 {
00295 Q_OBJECT
00296
00297
public:
00298 ASWizSpamRulesPage(
QWidget * parent,
const char * name, KMFolderTree * mainFolderTree );
00299
00300
bool pipeRulesSelected() const;
00301
bool classifyRulesSelected() const;
00302
bool moveRulesSelected() const;
00303
bool markReadRulesSelected() const;
00304
00305
QString selectedFolderName() const;
00306
void allowClassification(
bool enabled );
00307
00308 private slots:
00309
void processSelectionChange();
00310
00311 signals:
00312
void selectionChanged();
00313
00314 private:
00315
QCheckBox * mPipeRules;
00316
QCheckBox * mClassifyRules;
00317
QCheckBox * mMoveRules;
00318 SimpleFolderTree *mFolderTree;
00319
QCheckBox * mMarkRules;
00320 };
00321
00322
00323 class ASWizVirusRulesPage : public
QWidget
00324 {
00325 Q_OBJECT
00326
00327
public:
00328 ASWizVirusRulesPage( QWidget * parent,
const char * name, KMFolderTree * mainFolderTree );
00329
00330
bool pipeRulesSelected() const;
00331
bool moveRulesSelected() const;
00332
bool markReadRulesSelected() const;
00333
00334
QString selectedFolderName() const;
00335
00336 private slots:
00337
void processSelectionChange();
00338 signals:
00339
void selectionChanged();
00340
00341 private:
00342
QCheckBox * mPipeRules;
00343
QCheckBox * mMoveRules;
00344 SimpleFolderTree *mFolderTree;
00345
QCheckBox * mMarkRules;
00346 };
00347
00348
00349 }
00350
00351 #endif