kmail Library API Documentation

antispamwizard.h

00001 /* -*- mode: C++ -*- 00002 This file is part of KMail. 00003 Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de> 00004 00005 KMail is free software; you can redistribute it and/or modify it 00006 under the terms of the GNU General Public License, version 2, as 00007 published by the Free Software Foundation. 00008 00009 KMail is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 In addition, as a special exception, the copyright holders give 00019 permission to link the code of this program with any edition of 00020 the Qt library by Trolltech AS, Norway (or with modified versions 00021 of Qt that use the same license as Qt), and distribute linked 00022 combinations including the two. You must obey the GNU General 00023 Public License in all respects for all of the code used other than 00024 Qt. If you modify this file, you may extend this exception to 00025 your version of the file, but you are not obligated to do so. If 00026 you do not wish to do so, delete this exception statement from 00027 your version. 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 // convinience methods for types 00154 bool isSpamTool() const { return ( mType == AntiSpam ); } 00155 bool isVirusTool() const { return ( mType == AntiVirus ); } 00156 00157 private: 00158 // used to identifiy configs for the same tool 00159 QString mId; 00160 // The version of the config data, used for merging and 00161 // detecting newer configs 00162 int mVersion; 00163 // the name as shown by the checkbox in the dialog page 00164 QString mVisibleName; 00165 // the command to check the existance of the tool 00166 QString mExecutable; 00167 // the What's This help text (e.g. url for the tool) 00168 QString mWhatsThisText; 00169 // name for the created filter in the filter list 00170 QString mFilterName; 00171 // pipe through cmd used to detect spam messages 00172 QString mDetectCmd; 00173 // pipe through cmd to let the tool learn a spam message 00174 QString mSpamCmd; 00175 // pipe through cmd to let the tool learn a ham message 00176 QString mHamCmd; 00177 // by which header are messages marked as spam 00178 QString mDetectionHeader; 00179 // what header pattern is used to mark spam messages 00180 QString mDetectionPattern; 00181 // filter searches for the pattern by regExp or contain rule 00182 bool mUseRegExp; 00183 // can the tool learn spam and ham, has it a bayesian algorithm 00184 bool mSupportsBayesFilter; 00185 // Is the tool AntiSpam or AntiVirus 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 /* generic checks if any option in a page is checked */ 00229 bool anySpamOptionChecked(); 00230 bool anyVirusOptionChecked(); 00231 00232 /* The pages in the wizard */ 00233 ASWizInfoPage * mInfoPage; 00234 ASWizProgramsPage * mProgramsPage; 00235 ASWizSpamRulesPage * mSpamRulesPage; 00236 ASWizVirusRulesPage * mVirusRulesPage; 00237 00238 /* The configured tools and it's settings to be used in the wizard. */ 00239 QValueList<SpamToolConfig> mToolList; 00240 00241 /* The action collection where the filter menu action is searched in */ 00242 KActionCollection * mActionCollection; 00243 00244 /* Are any spam tools selected? */ 00245 bool mSpamToolsUsed; 00246 /* Are any virus tools selected? */ 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 } // namespace KMail 00350 00351 #endif // KMAIL_ANTISPAMWIZARD_H
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:43 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003