kmail

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