kmail

kmfiltermgr.h

00001 /*
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 #ifndef kmfiltermgr_h
00021 #define kmfiltermgr_h
00022 
00023 #include "kmfilteraction.h" // for KMFilterAction::ReturnCode
00024 #include "kmfolder.h"
00025 
00026 #include <qguardedptr.h>
00027 #include <qobject.h>
00028 
00029 class KMFilter;
00030 class KMFilterDlg;
00031 template <typename T> class QValueVector;
00032 template <typename T> class QValueList;
00033 
00034 class KMFilterMgr: public QObject
00035 {
00036   Q_OBJECT
00037 
00038 public:
00039   KMFilterMgr(bool popFilter = false);
00040   virtual ~KMFilterMgr();
00041 
00043   void clear();
00044 
00045   enum FilterSet { NoSet = 0x0, Inbound = 0x1, Outbound = 0x2, Explicit = 0x4,
00046            All = Inbound|Outbound|Explicit };
00047 
00049   void readConfig(void);
00050 
00052   void writeConfig(bool withSync=TRUE);
00053 
00057   void openDialog( QWidget *parent, bool checkForEmptyFilterList = true );
00058 
00061   void createFilter( const QCString & field, const QString & value );
00062 
00063   bool beginFiltering(KMMsgBase *msgBase) const;
00064   int moveMessage(KMMessage *msg) const;
00065   void endFiltering(KMMsgBase *msgBase) const;
00066 
00072   bool atLeastOneFilterAppliesTo( unsigned int accountID ) const;
00078   bool atLeastOneIncomingFilterAppliesTo( unsigned int accountID ) const;
00082   bool atLeastOneOnlineImapFolderTarget();
00083 
00086   const QString createUniqueName( const QString & name );
00087 
00091   void appendFilters( const QValueList<KMFilter*> &filters,
00092                       bool replaceIfNameExists = false );
00093 
00096   void setFilters( const QValueList<KMFilter*> &filters );
00097 
00099   const QValueList<KMFilter*> & filters() const { return mFilters; }
00100 
00115   int process( KMMessage * msg, FilterSet aSet = Inbound, 
00116            bool account = false, uint accountId = 0 );
00117 
00120   int process( KMMessage * msg, const KMFilter * filter );
00121 
00122   void cleanup();
00125   void ref();
00131   void deref(bool force = false);
00132 
00137   int tempOpenFolder(KMFolder* aFolder);
00138 
00141   void beginUpdate() {}
00142 
00144   void endUpdate();
00145 
00147 #ifndef NDEBUG
00148   void dump() const;
00149 #endif
00150 
00155   bool folderRemoved(KMFolder* aFolder, KMFolder* aNewFolder);
00156 
00159   void folderCreated(KMFolder*) {}
00160 
00162   void setShowLaterMsgs( bool show ) {
00163     mShowLater = show;
00164   }
00165 
00167   bool showLaterMsgs() const {
00168     return mShowLater;
00169   }
00170 public slots:
00171   void slotFolderRemoved( KMFolder *aFolder );
00172 
00173 signals:
00174   void filterListUpdated();
00175 
00176 private:
00177   int processPop( KMMessage * msg ) const;
00178 
00179   QGuardedPtr<KMFilterDlg> mEditDialog;
00180   QValueVector<KMFolder *> mOpenFolders;
00181   QValueList<KMFilter *> mFilters;
00182   bool bPopFilter;
00183   bool mShowLater;
00184   bool mDirtyBufferedFolderTarget;
00185   bool mBufferedFolderTarget;
00186 
00187   int mRefCount;
00188 };
00189 
00190 #endif /*kmfiltermgr_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys