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

kmail

  • sources
  • kde-4.14
  • 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 QCheckBox;
40 class QBoxLayout;
41 class QListWidget;
42 
43 namespace MailCommon {
44 class FolderTreeWidget;
45 class FolderRequester;
46 }
47 
48 namespace KMail {
49 
50 class ASWizInfoPage;
51 class ASWizSpamRulesPage;
52 class ASWizVirusRulesPage;
53 class ASWizSummaryPage;
54 
55 //---------------------------------------------------------------------------
104 class AntiSpamWizard : public KAssistantDialog
105 {
106  Q_OBJECT
107 
108 public:
112  enum WizardMode { AntiSpam, AntiVirus };
113 
122  AntiSpamWizard( WizardMode mode,
123  QWidget * parent);
124 
125 protected:
131  class SpamToolConfig
132  {
133  public:
134  SpamToolConfig() {}
135  SpamToolConfig( const QString &toolId, int configVersion, int prio,
136  const QString &name, const QString &exec,
137  const QString &url, const QString &filter,
138  const QString &detection, const QString &spam,
139  const QString &ham,const QString &noSpam,
140  const QString &header, const QString &pattern,
141  const QString &pattern2, const QString &serverPattern,
142  bool detectionOnly, bool regExp, bool bayesFilter,
143  bool tristateDetection, WizardMode type );
144 
145  int getVersion() const { return mVersion; }
146  int getPrio() const { return mPrio; }
147  QString getId() const { return mId; }
148  QString getVisibleName() const { return mVisibleName; }
149  QString getExecutable() const { return mExecutable; }
150  QString getWhatsThisText() const { return mWhatsThisText; }
151  QString getFilterName() const { return mFilterName; }
152  QString getDetectCmd() const { return mDetectCmd; }
153  QString getSpamCmd() const { return mSpamCmd; }
154  QString getHamCmd() const { return mHamCmd; }
155  QString getNoSpamCmd() const { return mNoSpamCmd; }
156  QString getDetectionHeader() const { return mDetectionHeader; }
157  QString getDetectionPattern() const { return mDetectionPattern; }
158  QString getDetectionPattern2() const { return mDetectionPattern2; }
159  QString getServerPattern() const { return mServerPattern; }
160  bool isServerBased() const;
161  bool isDetectionOnly() const { return mDetectionOnly; }
162  bool isUseRegExp() const { return mUseRegExp; }
163  bool useBayesFilter() const { return mSupportsBayesFilter; }
164  bool hasTristateDetection() const { return mSupportsUnsure; }
165  WizardMode getType() const { return mType; }
166  // convenience methods for types
167  bool isSpamTool() const { return ( mType == AntiSpam ); }
168  bool isVirusTool() const { return ( mType == AntiVirus ); }
169 
170  private:
171  // used to identifiy configs for the same tool
172  QString mId;
173  // The version of the config data, used for merging and
174  // detecting newer configs
175  int mVersion;
176  // the priority of the tool in the list presented to the user
177  int mPrio;
178  // the name as shown by the checkbox in the dialog page
179  QString mVisibleName;
180  // the command to check the existence of the tool
181  QString mExecutable;
182  // the What's This help text (e.g. url for the tool)
183  QString mWhatsThisText;
184  // name for the created filter in the filter list
185  QString mFilterName;
186  // pipe through cmd used to detect spam messages
187  QString mDetectCmd;
188  // pipe through cmd to let the tool learn a spam message
189  QString mSpamCmd;
190  // pipe through cmd to let the tool learn a ham message
191  QString mHamCmd;
192  // pipe through cmd to let the tool delete the spam markup
193  QString mNoSpamCmd;
194  // by which header are messages marked as spam
195  QString mDetectionHeader;
196  // what header pattern is used to mark spam messages
197  QString mDetectionPattern;
198  // what header pattern is used to mark unsure messages
199  QString mDetectionPattern2;
200  // what header pattern is used in the account to check for a certain server
201  QString mServerPattern;
202  // filter cannot search actively but relies on pattern by regExp or contain rule
203  bool mDetectionOnly;
204  // filter searches for the pattern by regExp or contain rule
205  bool mUseRegExp;
206  // can the tool learn spam and ham, has it a bayesian algorithm
207  bool mSupportsBayesFilter;
208  // differentiate between ham, spam and a third "unsure" state
209  bool mSupportsUnsure;
210  // Is the tool AntiSpam or AntiVirus
211  WizardMode mType;
212  };
213 
219  class ConfigReader
220  {
221  public:
222  ConfigReader( WizardMode mode,
223  QList<SpamToolConfig> & configList );
224  ~ConfigReader( );
225 
226  QList<SpamToolConfig> & getToolList() { return mToolList; }
227 
228  void readAndMergeConfig();
229 
230  private:
231  QList<SpamToolConfig> & mToolList;
232  KSharedConfig::Ptr mConfig;
233  WizardMode mMode;
234 
235  SpamToolConfig readToolConfig( KConfigGroup & configGroup );
236  SpamToolConfig createDummyConfig();
237 
238  void mergeToolConfig(const SpamToolConfig &config );
239  void sortToolList();
240  };
241 
243  void accept();
244 
245 protected slots:
247  void checkProgramsSelections();
249  void checkVirusRulesSelections();
251  void checkToolAvailability();
253  void slotHelpClicked();
255  void slotBuildSummary();
256 
257 private:
258  /* Check for the availability of an executible along the PATH */
259  int checkForProgram( const QString &executable ) const;
260  /* generic checks if any option in a page is checked */
261  bool anyVirusOptionChecked() const;
262  /* convenience method calling the appropriate filter manager method */
263  const QString uniqueNameFor( const QString & name );
264  /* convenience method to sort out new and existing filters */
265  void sortFilterOnExistance( const QString & intendedFilterName,
266  QString & newFilters,
267  QString & replaceFilters );
268 
269  /* The pages in the wizard */
270  ASWizInfoPage * mInfoPage;
271  ASWizSpamRulesPage * mSpamRulesPage;
272  ASWizVirusRulesPage * mVirusRulesPage;
273  ASWizSummaryPage * mSummaryPage;
274 
275  KPageWidgetItem * mInfoPageItem;
276  KPageWidgetItem * mSpamRulesPageItem;
277  KPageWidgetItem * mVirusRulesPageItem;
278  KPageWidgetItem * mSummaryPageItem;
279 
280  /* The configured tools and it's settings to be used in the wizard. */
281  QList<SpamToolConfig> mToolList;
282 
283  /* Are any spam tools selected? */
284  bool mSpamToolsUsed;
285  /* Are any virus tools selected? */
286  bool mVirusToolsUsed;
287 
288  WizardMode mMode;
289 };
290 
291 
292 //---------------------------------------------------------------------------
293 class ASWizPage : public QWidget
294 {
295 public:
296  ASWizPage(QWidget *parent, const QString &name);
297 
298 protected:
299  QBoxLayout *mLayout;
300 };
301 
302 
303 //---------------------------------------------------------------------------
304 class ASWizInfoPage : public ASWizPage
305 {
306  Q_OBJECT
307 
308 public:
309  ASWizInfoPage( AntiSpamWizard::WizardMode mode,
310  QWidget *parent, const QString &name );
311 
312  void setScanProgressText( const QString &toolName );
313  void addAvailableTool( const QString &visibleName );
314  bool isProgramSelected( const QString &visibleName ) const;
315 
316 private slots:
317  void processSelectionChange();
318 
319 signals:
320  void selectionChanged();
321 
322 private:
323  QLabel *mScanProgressText;
324  QLabel *mSelectionHint;
325  QListWidget *mToolsList;
326 };
327 
328 //---------------------------------------------------------------------------
329 class ASWizSpamRulesPage : public ASWizPage
330 {
331  Q_OBJECT
332 
333 public:
334  ASWizSpamRulesPage(QWidget * parent, const QString &name);
335 
336  bool markAsReadSelected() const;
337  bool moveSpamSelected() const;
338  bool moveUnsureSelected() const;
339 
340  QString selectedUnsureCollectionName() const;
341  QString selectedUnsureCollectionId() const;
342 
343  void allowUnsureFolderSelection( bool enabled );
344  void allowMoveSpam( bool enabled );
345 
346  QString selectedSpamCollectionId() const;
347  QString selectedSpamCollectionName() const;
348 
349 protected:
350  Akonadi::Collection selectedSpamCollection() const;
351  Akonadi::Collection selectedUnsureCollection() const;
352 
353 private slots:
354  void processSelectionChange();
355  void processSelectionChange( const Akonadi::Collection & );
356 
357 signals:
358  void selectionChanged();
359 
360 private:
361  QCheckBox * mMarkRules;
362  QCheckBox * mMoveSpamRules;
363  QCheckBox * mMoveUnsureRules;
364  MailCommon::FolderRequester *mFolderReqForSpamFolder;
365  MailCommon::FolderRequester *mFolderReqForUnsureFolder;
366 };
367 
368 //-------------------------------------------------------------------------
369 class ASWizVirusRulesPage : public ASWizPage
370 {
371  Q_OBJECT
372 
373 public:
374  ASWizVirusRulesPage(QWidget * parent, const QString &name );
375 
376  bool pipeRulesSelected() const;
377  bool moveRulesSelected() const;
378  bool markReadRulesSelected() const;
379 
380  QString selectedFolderName() const;
381 
382 private slots:
383  void processSelectionChange();
384 signals:
385  void selectionChanged();
386 
387 private:
388  QCheckBox * mPipeRules;
389  QCheckBox * mMoveRules;
390  MailCommon::FolderTreeWidget *mFolderTree;
391  QCheckBox * mMarkRules;
392 };
393 
394 //---------------------------------------------------------------------------
395 class ASWizSummaryPage : public ASWizPage
396 {
397  Q_OBJECT
398 
399 public:
400  ASWizSummaryPage( QWidget * parent, const QString &name );
401 
402  void setSummaryText( const QString & text );
403 
404 private:
405  QLabel * mSummaryText;
406 };
407 
408 
409 } // namespace KMail
410 
411 #endif // KMAIL_ANTISPAMWIZARD_H
KMail::ASWizSpamRulesPage::selectedUnsureCollection
Akonadi::Collection selectedUnsureCollection() const
Definition: antispamwizard.cpp:1100
KMail::ASWizSummaryPage::setSummaryText
void setSummaryText(const QString &text)
Definition: antispamwizard.cpp:1254
KMail::ASWizSpamRulesPage::selectedUnsureCollectionName
QString selectedUnsureCollectionName() const
Definition: antispamwizard.cpp:1108
QWidget
KMail::ASWizInfoPage::addAvailableTool
void addAvailableTool(const QString &visibleName)
Definition: antispamwizard.cpp:973
KMail::ASWizSpamRulesPage::markAsReadSelected
bool markAsReadSelected() const
Definition: antispamwizard.cpp:1064
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:299
KMail::ASWizSpamRulesPage::selectedSpamCollectionName
QString selectedSpamCollectionName() const
Definition: antispamwizard.cpp:1086
KMail::AntiSpamWizard::SpamToolConfig::isVirusTool
bool isVirusTool() const
Definition: antispamwizard.h:168
KMail::AntiSpamWizard::SpamToolConfig::getServerPattern
QString getServerPattern() const
Definition: antispamwizard.h:159
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:112
KMail::AntiSpamWizard::SpamToolConfig::isServerBased
bool isServerBased() const
Definition: antispamwizard.cpp:719
KMail::AntiSpamWizard::ConfigReader::readAndMergeConfig
void readAndMergeConfig()
Definition: antispamwizard.cpp:742
KMail::AntiSpamWizard::SpamToolConfig::isUseRegExp
bool isUseRegExp() const
Definition: antispamwizard.h:162
KMail::AntiSpamWizard::SpamToolConfig::getDetectCmd
QString getDetectCmd() const
Definition: antispamwizard.h:152
KMail::AntiSpamWizard::SpamToolConfig::getDetectionHeader
QString getDetectionHeader() const
Definition: antispamwizard.h:156
KMail::ASWizSpamRulesPage::selectionChanged
void selectionChanged()
KMail::ASWizVirusRulesPage
Definition: antispamwizard.h:369
KMail::AntiSpamWizard::SpamToolConfig::useBayesFilter
bool useBayesFilter() const
Definition: antispamwizard.h:163
KMail::AntiSpamWizard::SpamToolConfig::getWhatsThisText
QString getWhatsThisText() const
Definition: antispamwizard.h:150
KMail::ASWizSummaryPage::ASWizSummaryPage
ASWizSummaryPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1242
QListWidget
KMail::ASWizPage
Definition: antispamwizard.h:293
KAssistantDialog
KMail::AntiSpamWizard::SpamToolConfig::getSpamCmd
QString getSpamCmd() const
Definition: antispamwizard.h:153
KMail::ASWizInfoPage
Definition: antispamwizard.h:304
QObject::name
const char * name() const
KMail::ASWizSpamRulesPage::moveUnsureSelected
bool moveUnsureSelected() const
Definition: antispamwizard.cpp:1076
QWidget::enabled
enabled
KMail::ASWizVirusRulesPage::selectionChanged
void selectionChanged()
KMail::AntiSpamWizard::SpamToolConfig::getHamCmd
QString getHamCmd() const
Definition: antispamwizard.h:154
KMail::AntiSpamWizard::ConfigReader::getToolList
QList< SpamToolConfig > & getToolList()
Definition: antispamwizard.h:226
QCheckBox
KMail::ASWizSpamRulesPage
Definition: antispamwizard.h:329
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:1227
KMail::AntiSpamWizard
KMail anti-spam wizard.
Definition: antispamwizard.h:104
KMail::ASWizVirusRulesPage::ASWizVirusRulesPage
ASWizVirusRulesPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1151
KMail::AntiSpamWizard::SpamToolConfig::getFilterName
QString getFilterName() const
Definition: antispamwizard.h:151
KMail::AntiSpamWizard::SpamToolConfig::getPrio
int getPrio() const
Definition: antispamwizard.h:146
KMail::AntiSpamWizard::SpamToolConfig::getNoSpamCmd
QString getNoSpamCmd() const
Definition: antispamwizard.h:155
KMail::AntiSpamWizard::SpamToolConfig::getVersion
int getVersion() const
Definition: antispamwizard.h:145
KMail::AntiSpamWizard::SpamToolConfig::getVisibleName
QString getVisibleName() const
Definition: antispamwizard.h:148
QString
KMail::AntiSpamWizard::SpamToolConfig::getDetectionPattern2
QString getDetectionPattern2() const
Definition: antispamwizard.h:158
QList
KMail::ASWizSummaryPage
Definition: antispamwizard.h:395
KMail::AntiSpamWizard::SpamToolConfig::isDetectionOnly
bool isDetectionOnly() const
Definition: antispamwizard.h:161
KMail::ASWizSpamRulesPage::selectedUnsureCollectionId
QString selectedUnsureCollectionId() const
Definition: antispamwizard.cpp:1113
KMail::AntiSpamWizard::SpamToolConfig::getExecutable
QString getExecutable() const
Definition: antispamwizard.h:149
KMail::ASWizVirusRulesPage::markReadRulesSelected
bool markReadRulesSelected() const
Definition: antispamwizard.cpp:1221
KMail::AntiSpamWizard::SpamToolConfig::isSpamTool
bool isSpamTool() const
Definition: antispamwizard.h:167
KMail::ASWizInfoPage::selectionChanged
void selectionChanged()
KMail::AntiSpamWizard::ConfigReader::~ConfigReader
~ConfigReader()
Definition: antispamwizard.cpp:737
KMail::AntiSpamWizard::ConfigReader::ConfigReader
ConfigReader(WizardMode mode, QList< SpamToolConfig > &configList)
Definition: antispamwizard.cpp:726
KMail::AntiSpamWizard::slotBuildSummary
void slotBuildSummary()
Create the summary text based on the current settings.
Definition: antispamwizard.cpp:588
KMail::AntiSpamWizard::SpamToolConfig::hasTristateDetection
bool hasTristateDetection() const
Definition: antispamwizard.h:164
KMail::AntiSpamWizard::SpamToolConfig::getId
QString getId() const
Definition: antispamwizard.h:147
KMail::AntiSpamWizard::SpamToolConfig::SpamToolConfig
SpamToolConfig()
Definition: antispamwizard.h:134
KMail::AntiSpamWizard::SpamToolConfig
Instances of this class store the settings for one tool as read from the config file.
Definition: antispamwizard.h:131
KMail::ASWizInfoPage::setScanProgressText
void setScanProgressText(const QString &toolName)
Definition: antispamwizard.cpp:967
KMail::AntiSpamWizard::SpamToolConfig::getType
WizardMode getType() const
Definition: antispamwizard.h:165
KMail::AntiSpamWizard::AntiSpam
Definition: antispamwizard.h:112
KMail::AntiSpamWizard::SpamToolConfig::getDetectionPattern
QString getDetectionPattern() const
Definition: antispamwizard.h:157
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:1133
KMail::ASWizInfoPage::isProgramSelected
bool isProgramSelected(const QString &visibleName) const
Definition: antispamwizard.cpp:987
KMail::ASWizSpamRulesPage::selectedSpamCollection
Akonadi::Collection selectedSpamCollection() const
Definition: antispamwizard.cpp:1091
KMail::AntiSpamWizard::ConfigReader
Instances of this class control reading the configuration of the anti-spam tools from global and user...
Definition: antispamwizard.h:219
KMail::ASWizSpamRulesPage::ASWizSpamRulesPage
ASWizSpamRulesPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:1001
KMail::ASWizSpamRulesPage::allowMoveSpam
void allowMoveSpam(bool enabled)
Definition: antispamwizard.cpp:1141
KMail::ASWizPage::ASWizPage
ASWizPage(QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:886
KMail::ASWizVirusRulesPage::pipeRulesSelected
bool pipeRulesSelected() const
Definition: antispamwizard.cpp:1210
QLabel
QObject::parent
QObject * parent() const
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:1216
QBoxLayout
KMail::AntiSpamWizard::AntiVirus
Definition: antispamwizard.h:112
KMail::ASWizSpamRulesPage::moveSpamSelected
bool moveSpamSelected() const
Definition: antispamwizard.cpp:1070
KMail::ASWizSpamRulesPage::selectedSpamCollectionId
QString selectedSpamCollectionId() const
Definition: antispamwizard.cpp:1081
KMail::ASWizInfoPage::ASWizInfoPage
ASWizInfoPage(AntiSpamWizard::WizardMode mode, QWidget *parent, const QString &name)
Definition: antispamwizard.cpp:912
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-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:32 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
  • pimprint

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