antispamwizard.h
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 ~ConfigReader( );
00200 QValueList<SpamToolConfig> & getToolList() { return mToolList; }
00201
00202 void readAndMergeConfig();
00203
00204 private:
00205 QValueList<SpamToolConfig> & mToolList;
00206 KConfig *mConfig;
00207 WizardMode mMode;
00208
00209 SpamToolConfig readToolConfig( KConfigGroup & configGroup );
00210 SpamToolConfig createDummyConfig();
00211
00212 void mergeToolConfig( SpamToolConfig config );
00213 };
00214
00215
00216 protected slots:
00218 void checkProgramsSelections();
00220 void checkSpamRulesSelections();
00222 void checkVirusRulesSelections();
00224 void checkToolAvailability();
00226 void slotHelpClicked();
00227
00228 private:
00229
00230 bool anySpamOptionChecked();
00231 bool anyVirusOptionChecked();
00232
00233
00234 ASWizInfoPage * mInfoPage;
00235 ASWizProgramsPage * mProgramsPage;
00236 ASWizSpamRulesPage * mSpamRulesPage;
00237 ASWizVirusRulesPage * mVirusRulesPage;
00238
00239
00240 QValueList<SpamToolConfig> mToolList;
00241
00242
00243 KActionCollection * mActionCollection;
00244
00245
00246 bool mSpamToolsUsed;
00247
00248 bool mVirusToolsUsed;
00249
00250 WizardMode mMode;
00251 };
00252
00253
00254
00255
00256
00257 class ASWizInfoPage : public QWidget
00258 {
00259 public:
00260 ASWizInfoPage( AntiSpamWizard::WizardMode mode,
00261 QWidget *parent, const char *name );
00262
00263 void setScanProgressText( const QString &toolName );
00264
00265 private:
00266 QLabel *mIntroText;
00267 QLabel *mScanProgressText;
00268 };
00269
00270
00271 class ASWizProgramsPage : public QWidget
00272 {
00273 Q_OBJECT
00274
00275 public:
00276 ASWizProgramsPage( QWidget *parent, const char *name,
00277 QStringList &checkBoxTextList,
00278 QStringList &checkBoxWhatsThisList );
00279
00280 bool isProgramSelected( const QString &visibleName );
00281 void setProgramAsFound( const QString &visibleName, bool found );
00282
00283 private slots:
00284 void processSelectionChange();
00285
00286 signals:
00287 void selectionChanged();
00288
00289 private:
00290 QDict<QCheckBox> mProgramDict;
00291 };
00292
00293
00294 class ASWizSpamRulesPage : public QWidget
00295 {
00296 Q_OBJECT
00297
00298 public:
00299 ASWizSpamRulesPage( QWidget * parent, const char * name, KMFolderTree * mainFolderTree );
00300
00301 bool pipeRulesSelected() const;
00302 bool classifyRulesSelected() const;
00303 bool moveRulesSelected() const;
00304 bool markReadRulesSelected() const;
00305
00306 QString selectedFolderName() const;
00307 void allowClassification( bool enabled );
00308
00309 private slots:
00310 void processSelectionChange();
00311
00312 signals:
00313 void selectionChanged();
00314
00315 private:
00316 QCheckBox * mPipeRules;
00317 QCheckBox * mClassifyRules;
00318 QCheckBox * mMoveRules;
00319 SimpleFolderTree *mFolderTree;
00320 QCheckBox * mMarkRules;
00321 };
00322
00323
00324 class ASWizVirusRulesPage : public QWidget
00325 {
00326 Q_OBJECT
00327
00328 public:
00329 ASWizVirusRulesPage( QWidget * parent, const char * name, KMFolderTree * mainFolderTree );
00330
00331 bool pipeRulesSelected() const;
00332 bool moveRulesSelected() const;
00333 bool markReadRulesSelected() const;
00334
00335 QString selectedFolderName() const;
00336
00337 private slots:
00338 void processSelectionChange();
00339 signals:
00340 void selectionChanged();
00341
00342 private:
00343 QCheckBox * mPipeRules;
00344 QCheckBox * mMoveRules;
00345 SimpleFolderTree *mFolderTree;
00346 QCheckBox * mMarkRules;
00347 };
00348
00349
00350 }
00351
00352 #endif // KMAIL_ANTISPAMWIZARD_H
This file is part of the documentation for kmail Library Version 3.3.2.