• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

actionscheduler.h

Go to the documentation of this file.
00001 /*  -*- mode: C++ -*-
00002     Action Scheduler
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) Don Sanders <sanders@kde.org>
00006 
00007     KMail is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMail is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this program with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #ifndef actionscheduler_h
00033 #define actionscheduler_h
00034 
00035 #include "kmfilteraction.h" // for KMFilterAction::ReturnCode
00036 #include "kmfilter.h"
00037 #include "kmfiltermgr.h" // KMFilterMgr::FilterSet
00038 #include "kmcommands.h"
00039 
00040 #include <QList>
00041 #include <QTime>
00042 
00043 class KMHeaders;
00044 
00045 namespace KMail {
00046 
00047 /* A class for asynchronous filtering of messages */
00048 class ActionScheduler : public QObject
00049 {
00050   Q_OBJECT
00051 
00052 public:
00053   enum ReturnCode { ResultOk, ResultError, ResultCriticalError };
00054 
00055   ActionScheduler(KMFilterMgr::FilterSet set,
00056           QList<KMFilter*> filters,
00057                   KMHeaders *headers = 0,
00058           KMFolder *srcFolder = 0);
00059   ~ActionScheduler();
00060 
00063   void setAutoDestruct( bool );
00064 
00066   void setAlwaysMatch( bool );
00067 
00069   void setDefaultDestinationFolder( KMFolder* );
00070 
00072   void setSourceFolder( KMFolder* );
00073 
00077   void setFilterList( QList<KMFilter*> filters );
00078 
00080   void setAccountId( uint id  ) { mAccountId = id; mAccount = true; }
00081 
00083   void clearAccountId() { mAccountId = 0; mAccount = false; }
00084 
00086   void execFilters(const QList<quint32> serNums);
00087   void execFilters(const QList<KMMsgBase*> msgList);
00088   void execFilters(KMMsgBase* msgBase);
00089   void execFilters(quint32 serNum);
00090 
00091   static QString debug();
00092   static bool isEnabled();
00093 
00098   bool ignoreChanges( bool ignore );
00099 
00100 signals:
00102   void result(ReturnCode);
00103   void filtered(quint32);
00104 
00105 public slots:
00107   void actionMessage(KMFilterAction::ReturnCode = KMFilterAction::GoOn);
00108 
00110   void copyMessageFinished( KMCommand *command );
00111 
00112 private slots:
00113   KMMsgBase* messageBase(quint32 serNum);
00114   KMMessage* message(quint32 serNum);
00115   void finish();
00116 
00117   void folderClosedOrExpunged();
00118 
00119   int tempOpenFolder(KMFolder* aFolder);
00120   void tempCloseFolders();
00121 
00122   //Fetching slots
00123   void fetchMessage();
00124   void messageFetched( KMMessage *msg );
00125   void msgAdded( KMFolder*, quint32 );
00126   void enqueue(quint32 serNum);
00127 
00128   //Filtering slots
00129   void processMessage();
00130   void messageRetrieved(KMMessage*);
00131   void filterMessage();
00132   void moveMessage();
00133   void moveMessageFinished( KMCommand *command );
00134   void timeOut();
00135   void fetchTimeOut();
00136 
00137 private:
00138   static QList<ActionScheduler*> *schedulerList; // for debugging
00139   static KMFolderMgr *tempFolderMgr;
00140   static int refCount, count;
00141   static bool sEnabled, sEnabledChecked;
00142 
00143   // Iterates over the messages in mSerNums, describes which message is being
00144   // filtered currently.
00145   // In processMessage(), this iterator is set to the next message which is available
00146   // for processing (thus processMessage() is called once for every message).
00147   QList<quint32>::Iterator mMessageIt;
00148 
00149   // Iterates over all available filters. Used in filterMessage(), which is
00150   // called once for every filter.
00151   QList<KMFilter*>::iterator mFilterIt;
00152 
00153   // Iterates over all filter actions of the current filter. Used in
00154   // actionMessage(), which is called once for every filter action.
00155   QList<KMFilterAction*>::iterator mFilterActionIt;
00156 
00157   // List of serial numbers of message that are in the temporary filter folder
00158   // and await processing.
00159   // Serial numbers are added as soon as new messages are added to the temp folder,
00160   // and removed as soon as the message is moved back to the original
00161   // source folder (or the target folder if specified in a filter action).
00162   QList<quint32> mSerNums;
00163 
00164   // List of serial numbers of messages that need to be fetched from the orginal
00165   // source folder.
00166   // Once they are fetched, the messages are copied into the temporary filter folder.
00167   // Serial numbers are added when execFilters() is called by the user, and
00168   // removed as soon as the message is fetched from the original source folder.
00169   QList<quint32> mFetchSerNums;
00170 
00171   QList<QPointer<KMFolder> > mOpenFolders;
00172   QList<KMFilter*> mFilters, mQueuedFilters;
00173   KMFilterAction* mFilterAction;
00174   KMFilterMgr::FilterSet mSet;
00175   KMHeaders *mHeaders;
00176   QPointer<KMFolder> mSrcFolder, mDestFolder;
00177   bool mExecuting, mExecutingLock, mFetchExecuting;
00178   bool mUnget, mFetchUnget;
00179   bool mIgnore;
00180   bool mFiltersAreQueued;
00181   bool mAutoDestruct;
00182   bool mAlwaysMatch;
00183   bool mAccount;
00184   uint mAccountId;
00185   quint32 mOriginalSerNum;
00186   bool mDeleteSrcFolder;
00187   ReturnCode mResult;
00188   QTimer *finishTimer, *fetchMessageTimer, *tempCloseFoldersTimer;
00189   QTimer *processMessageTimer, *filterMessageTimer;
00190   QTimer *timeOutTimer, *fetchTimeOutTimer;
00191   QTime timeOutTime, fetchTimeOutTime;
00192   KMCommand *lastCommand;
00193   FolderJob *lastJob;
00194 };
00195 
00196 }
00197 
00198 #endif /*actionscheduler_h*/

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal