kmail
antispamwizard.h00001
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 "simplefoldertree.h"
00033
00034 #include <kconfig.h>
00035 #include <klistbox.h>
00036 #include <kwizard.h>
00037
00038 #include <tqcheckbox.h>
00039 #include <tqdict.h>
00040 #include <tqlayout.h>
00041
00042 class KActionCollection;
00043 class KMFolder;
00044 class KMFolderTree;
00045 class TQLabel;
00046
00047 namespace KMail {
00048
00049 class FolderRequester;
00050
00051 class ASWizInfoPage;
00052 class ASWizSpamRulesPage;
00053 class ASWizVirusRulesPage;
00054 class ASWizSummaryPage;
00055
00056
00104 class AntiSpamWizard : public KWizard
00105 {
00106 Q_OBJECT
00107
00108 public:
00112 enum WizardMode { AntiSpam, AntiVirus };
00113
00122 AntiSpamWizard( WizardMode mode,
00123 TQWidget * parent, KMFolderTree * mainFolderTree );
00124
00125 protected:
00131 class SpamToolConfig
00132 {
00133 public:
00134 SpamToolConfig() {}
00135 SpamToolConfig( TQString toolId, int configVersion, int prio,
00136 TQString name, TQString exec, TQString url, TQString filter,
00137 TQString detection, TQString spam, TQString ham,
00138 TQString header, TQString pattern, TQString pattern2,
00139 TQString serverPattern,
00140 bool detectionOnly, bool regExp, bool bayesFilter,
00141 bool tristateDetection, WizardMode type );
00142
00143 int getVersion() const { return mVersion; }
00144 int getPrio() const { return mPrio; }
00145 TQString getId() const { return mId; }
00146 TQString getVisibleName() const { return mVisibleName; }
00147 TQString getExecutable() const { return mExecutable; }
00148 TQString getWhatsThisText() const { return mWhatsThisText; }
00149 TQString getFilterName() const { return mFilterName; }
00150 TQString getDetectCmd() const { return mDetectCmd; }
00151 TQString getSpamCmd() const { return mSpamCmd; }
00152 TQString getHamCmd() const { return mHamCmd; }
00153 TQString getDetectionHeader() const { return mDetectionHeader; }
00154 TQString getDetectionPattern() const { return mDetectionPattern; }
00155 TQString getDetectionPattern2() const { return mDetectionPattern2; }
00156 TQString getServerPattern() const { return mServerPattern; }
00157 bool isServerBased() const;
00158 bool isDetectionOnly() const { return mDetectionOnly; }
00159 bool isUseRegExp() const { return mUseRegExp; }
00160 bool useBayesFilter() const { return mSupportsBayesFilter; }
00161 bool hasTristateDetection() const { return mSupportsUnsure; }
00162 WizardMode getType() const { return mType; }
00163
00164 bool isSpamTool() const { return ( mType == AntiSpam ); }
00165 bool isVirusTool() const { return ( mType == AntiVirus ); }
00166
00167 private:
00168
00169 TQString mId;
00170
00171
00172 int mVersion;
00173
00174 int mPrio;
00175
00176 TQString mVisibleName;
00177
00178 TQString mExecutable;
00179
00180 TQString mWhatsThisText;
00181
00182 TQString mFilterName;
00183
00184 TQString mDetectCmd;
00185
00186 TQString mSpamCmd;
00187
00188 TQString mHamCmd;
00189
00190 TQString mDetectionHeader;
00191
00192 TQString mDetectionPattern;
00193
00194 TQString mDetectionPattern2;
00195
00196 TQString mServerPattern;
00197
00198 bool mDetectionOnly;
00199
00200 bool mUseRegExp;
00201
00202 bool mSupportsBayesFilter;
00203
00204 bool mSupportsUnsure;
00205
00206 WizardMode mType;
00207 };
00208
00214 class ConfigReader
00215 {
00216 public:
00217 ConfigReader( WizardMode mode,
00218 TQValueList<SpamToolConfig> & configList );
00219 ~ConfigReader( );
00220
00221 TQValueList<SpamToolConfig> & getToolList() { return mToolList; }
00222
00223 void readAndMergeConfig();
00224
00225 private:
00226 TQValueList<SpamToolConfig> & mToolList;
00227 KConfig *mConfig;
00228 WizardMode mMode;
00229
00230 SpamToolConfig readToolConfig( KConfigGroup & configGroup );
00231 SpamToolConfig createDummyConfig();
00232
00233 void mergeToolConfig( SpamToolConfig config );
00234 void sortToolList();
00235 };
00236
00238 void accept();
00239
00240 protected slots:
00242 void checkProgramsSelections();
00244 void checkVirusRulesSelections();
00246 void checkToolAvailability();
00248 void slotHelpClicked();
00250 void slotBuildSummary();
00251
00252 private:
00253
00254 int checkForProgram( const TQString &executable );
00255
00256 bool anyVirusOptionChecked();
00257
00258 const TQString uniqueNameFor( const TQString & name );
00259
00260 void sortFilterOnExistance( const TQString & intendedFilterName,
00261 TQString & newFilters,
00262 TQString & replaceFilters );
00263
00264
00265 ASWizInfoPage * mInfoPage;
00266 ASWizSpamRulesPage * mSpamRulesPage;
00267 ASWizVirusRulesPage * mVirusRulesPage;
00268 ASWizSummaryPage * mSummaryPage;
00269
00270
00271 TQValueList<SpamToolConfig> mToolList;
00272
00273
00274 bool mSpamToolsUsed;
00275
00276 bool mVirusToolsUsed;
00277
00278 WizardMode mMode;
00279 };
00280
00281
00282
00283 class ASWizPage : public QWidget
00284 {
00285 public:
00286 ASWizPage( TQWidget *parent, const char *name,
00287 const TQString *bannerName = 0);
00288
00289 protected:
00290 TQBoxLayout *mLayout;
00291
00292 private:
00293 TQLabel *mBannerLabel;
00294 };
00295
00296
00297
00298 class ASWizInfoPage : public ASWizPage
00299 {
00300 Q_OBJECT
00301
00302 public:
00303 ASWizInfoPage( AntiSpamWizard::WizardMode mode,
00304 TQWidget *parent, const char *name );
00305
00306 void setScanProgressText( const TQString &toolName );
00307 void addAvailableTool( const TQString &visibleName );
00308 bool isProgramSelected( const TQString &visibleName );
00309
00310 private slots:
00311 void processSelectionChange();
00312
00313 signals:
00314 void selectionChanged();
00315
00316 private:
00317 TQLabel *mIntroText;
00318 TQLabel *mScanProgressText;
00319 TQLabel *mSelectionHint;
00320 KListBox *mToolsList;
00321 };
00322
00323
00324 class ASWizSpamRulesPage : public ASWizPage
00325 {
00326 Q_OBJECT
00327
00328 public:
00329 ASWizSpamRulesPage( TQWidget * parent, const char * name, KMFolderTree * mainFolderTree );
00330
00331 bool markAsReadSelected() const;
00332 bool moveSpamSelected() const;
00333 bool moveUnsureSelected() const;
00334
00335 TQString selectedSpamFolderName() const;
00336 TQString selectedUnsureFolderName() const;
00337
00338 void allowUnsureFolderSelection( bool enabled );
00339
00340 private slots:
00341 void processSelectionChange();
00342 void processSelectionChange( KMFolder* );
00343
00344 signals:
00345 void selectionChanged();
00346
00347 private:
00348 TQCheckBox * mMarkRules;
00349 TQCheckBox * mMoveSpamRules;
00350 TQCheckBox * mMoveUnsureRules;
00351 FolderRequester *mFolderReqForSpamFolder;
00352 FolderRequester *mFolderReqForUnsureFolder;
00353 };
00354
00355
00356 class ASWizVirusRulesPage : public ASWizPage
00357 {
00358 Q_OBJECT
00359
00360 public:
00361 ASWizVirusRulesPage( TQWidget * parent, const char * name, KMFolderTree * mainFolderTree );
00362
00363 bool pipeRulesSelected() const;
00364 bool moveRulesSelected() const;
00365 bool markReadRulesSelected() const;
00366
00367 TQString selectedFolderName() const;
00368
00369 private slots:
00370 void processSelectionChange();
00371 signals:
00372 void selectionChanged();
00373
00374 private:
00375 TQCheckBox * mPipeRules;
00376 TQCheckBox * mMoveRules;
00377 SimpleFolderTree *mFolderTree;
00378 TQCheckBox * mMarkRules;
00379 };
00380
00381
00382 class ASWizSummaryPage : public ASWizPage
00383 {
00384 Q_OBJECT
00385
00386 public:
00387 ASWizSummaryPage( TQWidget * parent, const char * name );
00388
00389 void setSummaryText( const TQString & text );
00390
00391 private:
00392 TQLabel * mSummaryText;
00393 };
00394
00395
00396 }
00397
00398 #endif // KMAIL_ANTISPAMWIZARD_H
|