1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/*
Action Scheduler
This file is part of KMail, the KDE mail client.
Copyright (c) Don Sanders <[email protected]>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the TQt library by Trolltech AS, Norway (or with modified versions
of TQt that use the same license as TQt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
TQt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef actionscheduler_h
#define actionscheduler_h
#include "kmfilteraction.h" // for KMFilterAction::ReturnCode
#include "kmfilter.h"
#include "kmfiltermgr.h" // KMFilterMgr::FilterSet
#include "kmcommands.h"
#include <tqobject.h>
#include <tqguardedptr.h>
#include <tqtimer.h>
class KMHeaders;
namespace KMail {
/* A class for asynchronous filtering of messages */
class ActionScheduler : public TQObject
{
Q_OBJECT
public:
enum ReturnCode { ResultOk, ResultError, ResultCriticalError };
ActionScheduler(KMFilterMgr::FilterSet set,
TQValueList<KMFilter*> filters,
KMHeaders *headers = 0,
KMFolder *srcFolder = 0);
~ActionScheduler();
/** The action scheduler will be deleted after the finish signal is emitted
if this property is set to true */
void setAutoDestruct( bool );
/** Apply all filters even if they don't match */
void setAlwaysMatch( bool );
/** Set a default folder to move messages into */
void setDefaultDestinationFolder( KMFolder* );
/** Set a folder to monitor for new messages to filter */
void setSourceFolder( KMFolder* );
/** Set a list of filters to work with
The current list will not be updated until the queue
of messages left to process is empty */
void setFilterList( TQValueList<KMFilter*> filters );
/** Set the id of the account associated with this scheduler */
void setAccountId( uint id ) { mAccountId = id; mAccount = true; }
/** Clear the id of the account associated with this scheduler */
void clearAccountId() { mAccountId = 0; mAccount = false; }
/** Queue a message for filtering */
void execFilters(const TQValueList<TQ_UINT32> serNums);
void execFilters(const TQPtrList<KMMsgBase> msgList);
void execFilters(KMMsgBase* msgBase);
void execFilters(TQ_UINT32 serNum);
static TQString debug();
static bool isEnabled();
/** Allow or deny manipulations on the message to be filtered.
This is needed when using pipe-through filters, because the
changes made by the filter have to be written back.
The old value before applying the new value is returned. */
bool ignoreChanges( bool ignore );
signals:
/** Emitted when filtering is completed */
void result(ReturnCode);
void filtered(TQ_UINT32);
public slots:
/** Called back by asynchronous actions when they have completed */
void actionMessage(KMFilterAction::ReturnCode = KMFilterAction::GoOn);
/** Called back by asynchronous copy actions when they have completed */
void copyMessageFinished( KMCommand *command );
private slots:
KMMsgBase* messageBase(TQ_UINT32 serNum);
KMMessage* message(TQ_UINT32 serNum);
void finish();
void folderClosedOrExpunged();
int tempOpenFolder(KMFolder* aFolder);
void tempCloseFolders();
//Fetching slots
void fetchMessage();
void messageFetched( KMMessage *msg );
void msgAdded( KMFolder*, TQ_UINT32 );
void enqueue(TQ_UINT32 serNum);
//Filtering slots
void processMessage();
void messageRetrieved(KMMessage*);
void filterMessage();
void moveMessage();
void moveMessageFinished( KMCommand *command );
void timeOut();
void fetchTimeOut();
private:
static TQValueList<ActionScheduler*> *schedulerList; // for debugging
static KMFolderMgr *tempFolderMgr;
static int refCount, count;
static bool sEnabled, sEnabledChecked;
TQValueListIterator<TQ_UINT32> mMessageIt;
TQValueListIterator<KMFilter> mFilterIt;
TQValueList<TQ_UINT32> mSerNums, mFetchSerNums;
TQValueList<TQGuardedPtr<KMFolder> > mOpenFolders;
TQValueList<KMFilter> mFilters, mQueuedFilters;
KMFilterAction* mFilterAction;
KMFilterMgr::FilterSet mSet;
KMHeaders *mHeaders;
TQGuardedPtr<KMFolder> mSrcFolder, mDestFolder;
bool mExecuting, mExecutingLock, mFetchExecuting;
bool mUnget, mFetchUnget;
bool mIgnore;
bool mFiltersAreQueued;
bool mAutoDestruct;
bool mAlwaysMatch;
bool mAccount;
uint mAccountId;
TQ_UINT32 mOriginalSerNum;
bool mDeleteSrcFolder;
ReturnCode mResult;
TQTimer *finishTimer, *fetchMessageTimer, *tempCloseFoldersTimer;
TQTimer *processMessageTimer, *filterMessageTimer;
TQTimer *timeOutTimer, *fetchTimeOutTimer;
TQTime timeOutTime, fetchTimeOutTime;
KMCommand *lastCommand;
FolderJob *lastJob;
};
}
#endif /*actionscheduler_h*/
|