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