Build with clang.
[kdepim.git] / mailcommon / filterlog.h
bloba582d5ebe927e9b51721e698884341a86582952a
1 /*
2 This file is part of KMail.
3 Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
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.
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.
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
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.
29 #ifndef MAILCOMMON_FILTERLOG_H
30 #define MAILCOMMON_FILTERLOG_H
32 #include <QObject>
33 #include <QStringList>
34 #include <QTextDocument>
36 #include "mailcommon_export.h"
38 namespace MailCommon {
40 /**
41 * @short KMail Filter Log Collector.
43 * The filter log helps to collect log information about the
44 * filter process in KMail. It's implemented as singleton,
45 * so it's easy to direct pieces of information to a unique
46 * instance.
47 * It's possible to activate / deactivate logging. All
48 * collected log information can get thrown away, the
49 * next added log entry is the first one until another
50 * clearing.
51 * A signal is emitted whenever a new logentry is added,
52 * when the log was cleared or any log state was changed.
54 * @author Andreas Gungl <a.gungl@gmx.de>
56 class MAILCOMMON_EXPORT FilterLog : public QObject
58 Q_OBJECT
60 public:
61 /**
62 * Destroys the filter log.
64 virtual ~FilterLog();
66 /**
67 * Returns the single global instance of the filter log.
69 static FilterLog* instance();
71 /**
72 * Describes the type of content that will be logged.
74 enum ContentType
76 Meta = 1, ///< Log all meta data.
77 PatternDescription = 2, ///< Log all pattern description.
78 RuleResult = 4, ///< Log all rule matching results.
79 PatternResult = 8, ///< Log all pattern matching results.
80 AppliedAction = 16 ///< Log all applied actions.
83 /**
84 * Sets whether the filter log is currently @p active.
86 void setLogging( bool active );
88 /**
89 * Returns whether the filter log is currently active.
91 bool isLogging() const;
93 /**
94 * Sets the maximum @p size of the log in bytes.
96 void setMaxLogSize( long size = -1 );
98 /**
99 * Returns the maximum size of the log in bytes.
101 long maxLogSize() const;
104 * Sets whether a given content @p type will be @p enabled for logging.
106 void setContentTypeEnabled( ContentType type, bool enabled );
109 * Returns whether the given content @p type is enabled for logging.
111 bool isContentTypeEnabled( ContentType type ) const;
114 * Adds the given log @p entry under the given content @p type to the log.
116 void add( const QString &entry, ContentType type );
119 * Adds a separator line to the log.
121 void addSeparator();
124 * Clears the log.
126 void clear();
129 * Returns the list of log entries.
131 QStringList logEntries() const;
134 * Saves the log to the file with the given @p fileName.
136 * @return @c true on success or @c false on failure.
138 bool saveToFile( const QString &fileName ) const;
141 * Returns an escaped version of the log which can be used
142 * in a HTML document.
144 static QString recode( const QString &plain );
147 * Dumps the log to console. Used for debugging.
149 void dump();
151 Q_SIGNALS:
153 * This signal is emitted whenever a new @p entry has been added to the log.
155 void logEntryAdded( const QString &entry );
158 * This signal is emitted whenever the log has shrinked.
160 void logShrinked();
163 * This signal is emitted whenever the activity of the filter log has been changed.
165 void logStateChanged();
167 private:
168 //@cond PRIVATE
169 FilterLog();
171 class Private;
172 Private* const d;
173 //@endcond
178 #endif