kmail Library API Documentation

actionscheduler.h

00001 /*  Action Scheduler
00002 
00003     This file is part of KMail, the KDE mail client.
00004     Copyright (c) Don Sanders <sanders@kde.org>
00005 
00006     KMail is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU General Public License, version 2, as
00008     published by the Free Software Foundation.
00009 
00010     KMail is distributed in the hope that it will be useful, but
00011     WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019     In addition, as a special exception, the copyright holders give
00020     permission to link the code of this program with any edition of
00021     the Qt library by Trolltech AS, Norway (or with modified versions
00022     of Qt that use the same license as Qt), and distribute linked
00023     combinations including the two.  You must obey the GNU General
00024     Public License in all respects for all of the code used other than
00025     Qt.  If you modify this file, you may extend this exception to
00026     your version of the file, but you are not obligated to do so.  If
00027     you do not wish to do so, delete this exception statement from
00028     your version.
00029 */
00030 
00031 #ifndef actionscheduler_h
00032 #define actionscheduler_h
00033 
00034 #include "qobject.h"
00035 #include "qguardedptr.h"
00036 #include "qtimer.h"
00037 #include "kmfilteraction.h" // for KMFilterAction::ReturnCode
00038 #include "kmfilter.h"
00039 #include "kmfiltermgr.h" // KMFilterMgr::FilterSet
00040 class KMHeaders;
00041 
00042 /* A class for asynchronous filtering of messages */
00043 
00044 namespace KMail {
00045 
00046 class ActionScheduler : public QObject
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051   enum ReturnCode { ResultOk, ResultError, ResultCriticalError };
00052 
00053   ActionScheduler(KMFilterMgr::FilterSet set,
00054           QPtrList<KMFilter> filters,
00055                   KMHeaders *headers = 0,
00056           KMFolder *srcFolder = 0);
00057   ~ActionScheduler();
00058 
00061   void setAutoDestruct( bool );
00062 
00064   void setAlwaysMatch( bool );
00065 
00067   void setDefaultDestinationFolder( KMFolder* );
00068 
00070   void setSourceFolder( KMFolder* );
00071 
00075   void setFilterList( QPtrList<KMFilter> filters );
00076 
00078   void execFilters(const QValueList<Q_UINT32> serNums);
00079   void execFilters(const QPtrList<KMMsgBase> msgList);
00080   void execFilters(KMMsgBase* msgBase);
00081   void execFilters(Q_UINT32 serNum);
00082 
00083 signals:
00085   void result(ReturnCode);
00086 
00087 public slots:
00089   void actionMessage(KMFilterAction::ReturnCode = KMFilterAction::GoOn);
00090 
00091 private slots:
00092   KMMsgBase* messageBase(Q_UINT32 serNum);
00093   KMMessage* message(Q_UINT32 serNum);
00094   void finish();
00095 
00096   int tempOpenFolder(KMFolder* aFolder);
00097   void tempCloseFolders();
00098 
00099   //Fetching slots
00100   void fetchMessage();
00101   void messageFetched( KMMessage *msg );
00102   void msgAdded( KMFolder*, Q_UINT32 );
00103   void enqueue(Q_UINT32 serNum);
00104 
00105   //Filtering slots
00106   void processMessage();
00107   void messageRetrieved(KMMessage*);
00108   void filterMessage();
00109   void moveMessage();
00110   void moveMessageFinished(bool);
00111 
00112 private:
00113   static KMFolderMgr *tempFolderMgr;
00114   static int refCount, count;
00115   QValueListIterator<Q_UINT32> mMessageIt;
00116   QValueListIterator<KMFilter> mFilterIt;
00117   QValueList<Q_UINT32> mSerNums, mFetchSerNums;
00118   QValueList<QGuardedPtr<KMFolder> > mOpenFolders;
00119   QValueList<KMFilter> mFilters, mQueuedFilters;
00120   KMFilterAction* mFilterAction;
00121   KMFilterMgr::FilterSet mSet;
00122   KMHeaders *mHeaders;
00123   QGuardedPtr<KMFolder> mSrcFolder, mDestFolder;
00124   bool mExecuting, mExecutingLock, mFetchExecuting;
00125   bool mUnget, mFetchUnget;
00126   bool mIgnore;
00127   bool mFiltersAreQueued;
00128   bool mAutoDestruct;
00129   bool mAlwaysMatch;
00130   Q_UINT32 mOriginalSerNum;
00131   bool mDeleteSrcFolder;
00132   ReturnCode mResult;
00133   QTimer *finishTimer, *fetchMessageTimer, *tempCloseFoldersTimer;
00134   QTimer *processMessageTimer, *filterMessageTimer;
00135 };
00136 
00137 }
00138 
00139 #endif /*actionscheduler_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:13 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003