• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • antispam-virus
antispamwizard.h
Go to the documentation of this file.
1 /* -*- mode: C++ -*-
2  This file is part of KMail.
3  Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
4 
5  KMail is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License, version 2, as
7  published by the Free Software Foundation.
8 
9  KMail is distributed in the hope that it will be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 
18  In addition, as a special exception, the copyright holders give
19  permission to link the code of this program with any edition of
20  the Qt library by Trolltech AS, Norway (or with modified versions
21  of Qt that use the same license as Qt), and distribute linked
22  combinations including the two. You must obey the GNU General
23  Public License in all respects for all of the code used other than
24  Qt. If you modify this file, you may extend this exception to
25  your version of the file, but you are not obligated to do so. If
26  you do not wish to do so, delete this exception statement from
27  your version.
28 */
29 #ifndef KMAIL_ANTISPAMWIZARD_H
30 #define KMAIL_ANTISPAMWIZARD_H
31 
32 #include <KAssistantDialog>
33 #include <KSharedConfig>
34 
35 #include <QList>
36 #include <akonadi/collection.h>
37 
38 class QLabel;
39 class QTextEdit;
40 class QCheckBox;
41 class QBoxLayout;
42 class QListWidget;
43 
44 namespace MailCommon {
45 class FolderTreeWidget;
46 class FolderRequester;
47 }
48 
49 namespace KMail {
50 
51 class ASWizInfoPage;
52 class ASWizSpamRulesPage;
53 class ASWizVirusRulesPage;
54 class ASWizSummaryPage;
55 
56 //---------------------------------------------------------------------------
105 class AntiSpamWizard : public KAssistantDialog
106 {
107  Q_OBJECT
108 
109 public:
113  enum WizardMode { AntiSpam, AntiVirus };
114 
123  AntiSpamWizard( WizardMode mode,
124  QWidget * parent);
125 
126 protected:
132  class SpamToolConfig
133  {
134  public:
135  SpamToolConfig() {}
136  SpamToolConfig( const QString &toolId, int configVersion, int prio,
137  const QString &name, const QString &exec,
138  const QString &url, const QString &filter,
139  const QString &detection, const QString &spam,
140  const QString &ham,const QString &noSpam,
141  const QString &header, const QString &pattern,
142  const QString &pattern2, const QString &serverPattern,
143  bool detectionOnly, bool regExp, bool bayesFilter,
144  bool tristateDetection, WizardMode type );
145 
146  int getVersion() const { return mVersion; }
147  int getPrio() const { return mPrio; }
148  QString getId() const { return mId; }
149  QString getVisibleName() const { return mVisibleName; }
150  QString getExecutable() const { return mExecutable; }
151  QString getWhatsThisText() const { return mWhatsThisText; }
152  QString getFilterName() const { return mFilterName; }
153  QString getDetectCmd() const { return mDetectCmd; }
154  QString getSpamCmd() const { return mSpamCmd; }
155  QString getHamCmd() const { return mHamCmd; }
156  QString getNoSpamCmd() const { return mNoSpamCmd; }
157  QString getDetectionHeader() const { return mDetectionHeader; }
158  QString getDetectionPattern() const { return mDetectionPattern; }
159  QString getDetectionPattern2() const { return mDetectionPattern2; }
160  QString getServerPattern() const { return mServerPattern; }
161  bool isServerBased() const;
162  bool isDetectionOnly() const { return mDetectionOnly; }
163  bool isUseRegExp() const { return mUseRegExp; }
164  bool useBayesFilter() const { return mSupportsBayesFilter; }
165  bool hasTristateDetection() const { return mSupportsUnsure; }
166  WizardMode getType() const { return mType; }
167  // convenience methods for types
168  bool isSpamTool() const { return ( mType == AntiSpam ); }
169  bool isVirusTool() const { return ( mType == AntiVirus ); }
170 
171  private:
172  // used to identifiy configs for the same tool
173  QString mId;
174  // The version of the config data, used for merging and
175  // detecting newer configs
176  int mVersion;
177  // the priority of the tool in the list presented to the user
178  int mPrio;
179  // the name as shown by the checkbox in the dialog page
180  QString mVisibleName;
181  // the command to check the existence of the tool
182  QString mExecutable;
183  // the What's This help text (e.g. url for the tool)
184  QString mWhatsThisText;
185  // name for the created filter in the filter list
186  QString mFilterName;
187  // pipe through cmd used to detect spam messages
188  QString mDetectCmd;
189  // pipe through cmd to let the tool learn a spam message
190  QString mSpamCmd;
191  // pipe through cmd to let the tool learn a ham message
192  QString mHamCmd;
193  // pipe through cmd to let the tool delete the spam markup
194  QString mNoSpamCmd;
195  // by which header are messages marked as spam
196  QString mDetectionHeader;
197  // what header pattern is used to mark spam messages
198  QString mDetectionPattern;
199  // what header pattern is used to mark unsure messages
200  QString mDetectionPattern2;
201  // what header pattern is used in the account to check for a certain server
202  QString mServerPattern;
203  // filter cannot search actively but relies on pattern by regExp or contain rule
204  bool mDetectionOnly;
205  // filter searches for the pattern by regExp or contain rule
206  bool mUseRegExp;
207  // can the tool learn spam and ham, has it a bayesian algorithm
208  bool mSupportsBayesFilter;
209  // differentiate between ham, spam and a third "unsure" state
210  bool mSupportsUnsure;
211  // Is the tool AntiSpam or AntiVirus
212  WizardMode mType;
213  };
214 
220  class ConfigReader
221  {
222  public:
223  ConfigReader( WizardMode mode,
224  QList<SpamToolConfig> & configList );
225  ~ConfigReader( );
226 
227  QList<SpamToolConfig> & getToolList() { return mToolList; }
228 
229  void readAndMergeConfig();
230 
231  private:
232  QList<SpamToolConfig> & mToolList;
233  KSharedConfig::Ptr mConfig;
234  WizardMode mMode;
235 
236  SpamToolConfig readToolConfig( KConfigGroup & configGroup );
237  SpamToolConfig createDummyConfig();
238 
239  void mergeToolConfig(const SpamToolConfig &config );
240  void sortToolList();
241  };
242 
244  void accept();
245 
246 protected slots:
248  void checkProgramsSelections();
250  void checkVirusRulesSelections();
252  void checkToolAvailability();
254  void slotHelpClicked();
256  void slotBuildSummary();
257 
258 private:
259  /* Check for the availability of an executible along the PATH */
260  int checkForProgram( const QString &executable ) const;
261  /* generic checks if any option in a page is checked */
262  bool anyVirusOptionChecked() const;
263  /* convenience method calling the appropriate filter manager method */
264  const QString uniqueNameFor( const QString & name );
265  /* convenience method to sort out new and existing filters */
266  void sortFilterOnExistance( const QString & intendedFilterName,
267  QString & newFilters,
268  QString & replaceFilters );
269 
270  /* The pages in the wizard */
271  ASWizInfoPage * mInfoPage;
272  ASWizSpamRulesPage * mSpamRulesPage;
273  ASWizVirusRulesPage * mVirusRulesPage;
274  ASWizSummaryPage * mSummaryPage;
275 
276  KPageWidgetItem * mInfoPageItem;
277  KPageWidgetItem * mSpamRulesPageItem;
278  KPageWidgetItem * mVirusRulesPageItem;
279  KPageWidgetItem * mSummaryPageItem;
280 
281  /* The configured tools and it's settings to be used in the wizard. */
282  QList<SpamToolConfig> mToolList;
283 
284  /* Are any spam tools selected? */
285  bool mSpamToolsUsed;
286  /* Are any virus tools selected? */
287  bool mVirusToolsUsed;
288 
289  WizardMode mMode;
290 };
291 
292 
293 //---------------------------------------------------------------------------
294 class ASWizPage : public QWidget
295 {
296 public:
297  ASWizPage(QWidget *parent, const QString &name,
298  const QString *bannerName = 0);
299 
300 protected:
301  QBoxLayout *mLayout;
302 private:
303  QLabel *mBannerLabel;
304 };
305 
306 
307 //---------------------------------------------------------------------------
308 class ASWizInfoPage : public ASWizPage
309 {
310  Q_OBJECT
311 
312 public:
313  ASWizInfoPage( AntiSpamWizard::WizardMode mode,
314  QWidget *parent, const QString &name );
315 
316  void setScanProgressText( const QString &toolName );
317  void addAvailableTool( const QString &visibleName );
318  bool isProgramSelected( const QString &visibleName ) const;
319 
320 private slots:
321  void processSelectionChange();
322 
323 signals:
324  void selectionChanged();
325 
326 private:
327  QTextEdit *mIntroText;
328  QLabel *mScanProgressText;
329  QLabel *mSelectionHint;
330  QListWidget *mToolsList;
331 };
332 
333 //---------------------------------------------------------------------------
334 class ASWizSpamRulesPage : public ASWizPage
335 {
336  Q_OBJECT
337 
338 public:
339  ASWizSpamRulesPage(QWidget * parent, const QString &name);
340 
341  bool markAsReadSelected() const;
342  bool moveSpamSelected() const;
343  bool moveUnsureSelected() const;
344 
345  QString selectedUnsureCollectionName() const;
346  QString selectedUnsureCollectionId() const;
347 
348  void allowUnsureFolderSelection( bool enabled );
349  void allowMoveSpam( bool enabled );
350 
351  QString selectedSpamCollectionId() const;
352  QString selectedSpamCollectionName() const;
353 
354 protected:
355  Akonadi::Collection selectedSpamCollection() const;
356  Akonadi::Collection selectedUnsureCollection() const;
357 
358 private slots:
359  void processSelectionChange();
360  void processSelectionChange( const Akonadi::Collection & );
361 
362 signals:
363  void selectionChanged();
364 
365 private:
366  QCheckBox * mMarkRules;
367  QCheckBox * mMoveSpamRules;
368  QCheckBox * mMoveUnsureRules;
369  MailCommon::FolderRequester *mFolderReqForSpamFolder;
370  MailCommon::FolderRequester *mFolderReqForUnsureFolder;
371 };
372 
373 //-------------------------------------------------------------------------
374 class ASWizVirusRulesPage : public ASWizPage
375 {
376  Q_OBJECT
377 
378 public:
379  ASWizVirusRulesPage(QWidget * parent, const QString &name );
380 
381  bool pipeRulesSelected() const;
382  bool moveRulesSelected() const;
383  bool markReadRulesSelected() const;
384 
385  QString selectedFolderName() const;
386 
387 private slots:
388  void processSelectionChange();
389 signals:
390  void selectionChanged();
391 
392 private:
393  QCheckBox * mPipeRules;
394  QCheckBox * mMoveRules;
395  MailCommon::FolderTreeWidget *mFolderTree;
396  QCheckBox * mMarkRules;
397 };
398 
399 //---------------------------------------------------------------------------
400 class ASWizSummaryPage : public ASWizPage
401 {
402  Q_OBJECT
403 
404 public:
405  ASWizSummaryPage( QWidget * parent, const QString &name );
406 
407  void setSummaryText( const QString & text );
408 
409 private:
410  QLabel * mSummaryText;
411 };
412 
413 
414 } // namespace KMail
415 
416 #endif // KMAIL_ANTISPAMWIZARD_H
KMail::ASWizSpamRulesPage::selectedUnsureCollection
Akonadi::Collection selectedUnsureCollection() const
Definition: antispamwizard.cpp:1106
KMail::ASWizSummaryPage::setSummaryText
void setSummaryText(const QString &text)
Definition: antispamwizard.cpp:1260
KMail::ASWizSpamRulesPage::selectedUnsureCollectionName
QString selectedUnsureCollectionName() const
Definition: antispamwizard.cpp:1114
KMail::ASWizPage::ASWizPage
ASWizPage(QWidget *parent, const QString &name, const QString *bannerName=0)
Definition: antispamwizard.cpp:889
KMail::ASWizInfoPage::addAvailableTool
void addAvailableTool(const QString &visibleName)
Definition: antispamwizard.cpp:979
KMail::ASWizSpamRulesPage::markAsReadSelected
bool markAsReadSelected() const
Definition: antispamwizard.cpp:1070
KMail::AntiSpamWizard::checkProgramsSelections
void checkProgramsSelections()
Modify the status of the wizard to reflect the selection of spam tools.
Definition: antispamwizard.cpp:470
KMail::ASWizPage::mLayout
QBoxLayout * mLayout
Definition: antispamwizard.h:301
KMail::ASWizSpamRulesPage::selectedSpamCollectionName
QString selectedSpamCollectionName() const
Definition: antispamwizard.cpp:1092
KMail::AntiSpamWizard::SpamToolConfig::isVirusTool
bool isVirusTool() const
Definition: antispamwizard.h:169
KMail::AntiSpamWizard::SpamToolConfig::getServerPattern
QString getServerPattern() const
Definition: antispamwizard.h:160
text
virtual QByteArray text(quint32 serialNumber) const =0
KMail::AntiSpamWizard::WizardMode
WizardMode
The wizard can be used for setting up anti-spam tools and for setting up anti-virus tools...
Definition: antispamwizard.h:113
KMail::AntiSpamWizard::SpamToolConfig::isServerBased
bool isServerBased() const
Definition: antispamwizard.cpp:722
QWidget
KMail::AntiSpamWizard::ConfigReader::readAndMergeConfig
void readAndMergeConfig()
Definition: antispamwizard.cpp:745
KMail::AntiSpamWizard::SpamToolConfig::isUseRegExp
bool isUseRegExp() const
Definition: antispamwizard.h:163
QListWidget
KMail::AntiSpamWizard::SpamToolConfig::getDetectCmd
QString getDetectCmd() const
Definition: antispamwizard.h:153
KMail::AntiSpamWizard::SpamToolConfig::getDetectionHeader
QString getDetectionHeader() const
Definition: antispamwizard.h:157
KMail::ASWizSpamRulesPage::selectionChanged
void selectionChanged()
KMail::ASWizVirusRulesPage
Definition: antispamwizard.h:374
KMail::AntiSpamWizard::SpamToolConfig::useBayesFilter
bool useBayesFilter() const
Definition: antispamwizard.h:164
KMail::AntiSpamWizard::SpamToolConfig::getWhatsThisText
QString getWhatsThisText() const
Definition: antispamwizard.h:151
KMail::ASWizSummaryPage::ASWizSummaryPage
ASWizSummaryPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1248
KMail::ASWizPage
Definition: antispamwizard.h:294
KAssistantDialog
KMail::AntiSpamWizard::SpamToolConfig::getSpamCmd
QString getSpamCmd() const
Definition: antispamwizard.h:154
KMail::ASWizInfoPage
Definition: antispamwizard.h:308
KMail::ASWizSpamRulesPage::moveUnsureSelected
bool moveUnsureSelected() const
Definition: antispamwizard.cpp:1082
KMail::ASWizVirusRulesPage::selectionChanged
void selectionChanged()
KMail::AntiSpamWizard::SpamToolConfig::getHamCmd
QString getHamCmd() const
Definition: antispamwizard.h:155
KMail::AntiSpamWizard::ConfigReader::getToolList
QList< SpamToolConfig > & getToolList()
Definition: antispamwizard.h:227
KMail::ASWizSpamRulesPage
Definition: antispamwizard.h:334
KMail::AntiSpamWizard::AntiSpamWizard
AntiSpamWizard(WizardMode mode, QWidget *parent)
Constructor that needs to initialize from the main folder tree of KMail.
Definition: antispamwizard.cpp:75
KMail::ASWizVirusRulesPage::selectedFolderName
QString selectedFolderName() const
Definition: antispamwizard.cpp:1233
KMail::AntiSpamWizard
KMail anti-spam wizard.
Definition: antispamwizard.h:105
KMail::ASWizVirusRulesPage::ASWizVirusRulesPage
ASWizVirusRulesPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1157
KMail::AntiSpamWizard::SpamToolConfig::getFilterName
QString getFilterName() const
Definition: antispamwizard.h:152
KMail::AntiSpamWizard::SpamToolConfig::getPrio
int getPrio() const
Definition: antispamwizard.h:147
KMail::AntiSpamWizard::SpamToolConfig::getNoSpamCmd
QString getNoSpamCmd() const
Definition: antispamwizard.h:156
KMail::AntiSpamWizard::SpamToolConfig::getVersion
int getVersion() const
Definition: antispamwizard.h:146
KMail::AntiSpamWizard::SpamToolConfig::getVisibleName
QString getVisibleName() const
Definition: antispamwizard.h:149
KMail::AntiSpamWizard::SpamToolConfig::getDetectionPattern2
QString getDetectionPattern2() const
Definition: antispamwizard.h:159
KMail::ASWizSummaryPage
Definition: antispamwizard.h:400
KMail::AntiSpamWizard::SpamToolConfig::isDetectionOnly
bool isDetectionOnly() const
Definition: antispamwizard.h:162
KMail::ASWizSpamRulesPage::selectedUnsureCollectionId
QString selectedUnsureCollectionId() const
Definition: antispamwizard.cpp:1119
KMail::AntiSpamWizard::SpamToolConfig::getExecutable
QString getExecutable() const
Definition: antispamwizard.h:150
KMail::ASWizVirusRulesPage::markReadRulesSelected
bool markReadRulesSelected() const
Definition: antispamwizard.cpp:1227
KMail::AntiSpamWizard::SpamToolConfig::isSpamTool
bool isSpamTool() const
Definition: antispamwizard.h:168
KMail::ASWizInfoPage::selectionChanged
void selectionChanged()
KMail::AntiSpamWizard::ConfigReader::~ConfigReader
~ConfigReader()
Definition: antispamwizard.cpp:740
KMail::AntiSpamWizard::ConfigReader::ConfigReader
ConfigReader(WizardMode mode, QList< SpamToolConfig > &configList)
Definition: antispamwizard.cpp:729
KMail::AntiSpamWizard::slotBuildSummary
void slotBuildSummary()
Create the summary text based on the current settings.
Definition: antispamwizard.cpp:591
KMail::AntiSpamWizard::SpamToolConfig::hasTristateDetection
bool hasTristateDetection() const
Definition: antispamwizard.h:165
KMail::AntiSpamWizard::SpamToolConfig::getId
QString getId() const
Definition: antispamwizard.h:148
KMail::AntiSpamWizard::SpamToolConfig::SpamToolConfig
SpamToolConfig()
Definition: antispamwizard.h:135
QLabel
KMail::AntiSpamWizard::SpamToolConfig
Instances of this class store the settings for one tool as read from the config file.
Definition: antispamwizard.h:132
KMail::ASWizInfoPage::setScanProgressText
void setScanProgressText(const QString &toolName)
Definition: antispamwizard.cpp:973
KMail::AntiSpamWizard::SpamToolConfig::getType
WizardMode getType() const
Definition: antispamwizard.h:166
KMail::AntiSpamWizard::AntiSpam
Definition: antispamwizard.h:113
KMail::AntiSpamWizard::SpamToolConfig::getDetectionPattern
QString getDetectionPattern() const
Definition: antispamwizard.h:158
KMail::AntiSpamWizard::accept
void accept()
Evaluate the settings made and create the appropriate filter rules.
Definition: antispamwizard.cpp:148
KMail::ASWizSpamRulesPage::allowUnsureFolderSelection
void allowUnsureFolderSelection(bool enabled)
Definition: antispamwizard.cpp:1139
KMail::ASWizInfoPage::isProgramSelected
bool isProgramSelected(const QString &visibleName) const
Definition: antispamwizard.cpp:993
KMail::ASWizSpamRulesPage::selectedSpamCollection
Akonadi::Collection selectedSpamCollection() const
Definition: antispamwizard.cpp:1097
KMail::AntiSpamWizard::ConfigReader
Instances of this class control reading the configuration of the anti-spam tools from global and user...
Definition: antispamwizard.h:220
KMail::ASWizSpamRulesPage::ASWizSpamRulesPage
ASWizSpamRulesPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1007
KMail::ASWizSpamRulesPage::allowMoveSpam
void allowMoveSpam(bool enabled)
Definition: antispamwizard.cpp:1147
KMail::ASWizVirusRulesPage::pipeRulesSelected
bool pipeRulesSelected() const
Definition: antispamwizard.cpp:1216
KMail::AntiSpamWizard::slotHelpClicked
void slotHelpClicked()
Show a help topic.
Definition: antispamwizard.cpp:582
KMail::AntiSpamWizard::checkVirusRulesSelections
void checkVirusRulesSelections()
Modify the status of the wizard to reflect the selected functionality.
Definition: antispamwizard.cpp:508
KMail::ASWizVirusRulesPage::moveRulesSelected
bool moveRulesSelected() const
Definition: antispamwizard.cpp:1222
KMail::AntiSpamWizard::AntiVirus
Definition: antispamwizard.h:113
KMail::ASWizSpamRulesPage::moveSpamSelected
bool moveSpamSelected() const
Definition: antispamwizard.cpp:1076
KMail::ASWizSpamRulesPage::selectedSpamCollectionId
QString selectedSpamCollectionId() const
Definition: antispamwizard.cpp:1087
QList
KMail::ASWizInfoPage::ASWizInfoPage
ASWizInfoPage(AntiSpamWizard::WizardMode mode, QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:918
KMail::AntiSpamWizard::checkToolAvailability
void checkToolAvailability()
Check if the spam tools are available via the PATH.
Definition: antispamwizard.cpp:514
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal