kmail

kmfilter.h
1/*
2 * kmail: KDE mail client
3 * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef kmfilter_h
21#define kmfilter_h
22
23#include "kmsearchpattern.h"
24#include "kmpopheaders.h"
25
26#include <tdeshortcut.h>
27
28#include <tqptrlist.h>
29
30class TQString;
31class TDEConfig;
32class KMMessage;
33class KMFilterAction;
34class KMFolder;
35
36// maximum number of filter actions per filter
37const int FILTER_MAX_ACTIONS = 8;
38
39
40class KMFilter
41{
42public:
54 enum ReturnCode { NoResult, GoOn, CriticalError };
55
65 enum AccountType { All, ButImap, Checked };
66
70 KMFilter( TDEConfig* aConfig=0 , bool popFilter = false);
71
73 KMFilter( const KMFilter & other );
74
76 ~KMFilter() {}
77
79 TQString name() const {
80 return mPattern.name();
81 }
82
94 ReturnCode execActions( KMMessage* msg, bool& stopIt ) const ;
95
98 bool requiresBody(KMMsgBase* msgBase);
99
101 KMPopFilterAction action();
102
104 void setAction(const KMPopFilterAction aAction);
105
110 void writeConfig( TDEConfig* config ) const;
111
116 void readConfig( TDEConfig* config );
117
119 void purify();
120
122 bool isEmpty() const;
123
127 TQPtrList<KMFilterAction>* actions() { return &mActions; }
128
130 const TQPtrList<KMFilterAction>* actions() const { return &mActions; }
131
135 KMSearchPattern* pattern() { return &mPattern; }
136
140 const KMSearchPattern* pattern() const { return &mPattern; }
141
146 void setApplyOnOutbound( bool aApply=true ) { bApplyOnOutbound = aApply; }
147
152 bool applyOnOutbound() const { return bApplyOnOutbound; }
153
158 void setApplyOnInbound( bool aApply=true ) { bApplyOnInbound = aApply; }
159
164 bool applyOnInbound() const { return bApplyOnInbound; }
165
170 void setApplyOnExplicit( bool aApply=true ) { bApplyOnExplicit = aApply; }
171
176 bool applyOnExplicit() const { return bApplyOnExplicit; }
177
185 void setApplicability( AccountType aApply=All ) { mApplicability = aApply; }
186
193 AccountType applicability() const { return mApplicability; }
194
201 void setApplyOnAccount( uint id, bool aApply=true );
202
207 bool applyOnAccount( uint id ) const;
208
209 void setStopProcessingHere( bool aStop ) { bStopProcessingHere = aStop; }
210 bool stopProcessingHere() const { return bStopProcessingHere; }
211
214 void setConfigureShortcut( bool aShort ) {
215 bConfigureShortcut = aShort;
216 bConfigureToolbar = bConfigureToolbar && bConfigureShortcut;
217 }
218
223 bool configureShortcut() const { return bConfigureShortcut; }
224
229 void setConfigureToolbar( bool aTool ) {
230 bConfigureToolbar = aTool && bConfigureShortcut;
231 }
232
237 bool configureToolbar() const { return bConfigureToolbar; }
238
243 void setShortcut( const TDEShortcut & shortcut ) { mShortcut = shortcut; };
244
248 const TDEShortcut & shortcut() const { return mShortcut; }
249
254 void setIcon( TQString icon ) { mIcon = icon; }
255
259 TQString icon() const { return mIcon; }
260
268 bool folderRemoved( KMFolder* aFolder, KMFolder* aNewFolder );
269
273#ifndef NDEBUG
274 const TQString asString() const;
275#endif
276
278 bool isPopFilter() const {
279 return bPopFilter;
280 }
281
286 void setAutoNaming( bool useAutomaticNames ) {
287 bAutoNaming = useAutomaticNames;
288 }
289
292 bool isAutoNaming() const { return bAutoNaming; }
293
294private:
295 KMSearchPattern mPattern;
296 TQPtrList<KMFilterAction> mActions;
297 TQValueList<int> mAccounts;
298 KMPopFilterAction mAction;
299 TQString mIcon;
300 TDEShortcut mShortcut;
301 bool bPopFilter : 1;
302 bool bApplyOnInbound : 1;
303 bool bApplyOnOutbound : 1;
304 bool bApplyOnExplicit : 1;
305 bool bStopProcessingHere : 1;
306 bool bConfigureShortcut : 1;
307 bool bConfigureToolbar : 1;
308 bool bAutoNaming : 1;
309 AccountType mApplicability;
310};
311
312#endif /*kmfilter_h*/
Abstract base class for KMail's filter actions.
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
This class is an abstraction of a search over messages.