kmail
kmfiltermgr.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kmfiltermgr_h
00021 #define kmfiltermgr_h
00022
00023 #include "kmfilteraction.h"
00024 #include "kmfolder.h"
00025
00026 class KMFilter;
00027 class KMFilterDlg;
00028
00029 class KMFilterMgr: public QObject
00030 {
00031 Q_OBJECT
00032
00033 public:
00034 KMFilterMgr(bool popFilter = false);
00035 virtual ~KMFilterMgr();
00036
00038 void clear();
00039
00040 enum FilterSet { NoSet = 0x0, Inbound = 0x1, Outbound = 0x2, Explicit = 0x4,
00041 All = Inbound|Outbound|Explicit };
00042
00044 void readConfig(void);
00045
00047 void writeConfig(bool withSync=true);
00048
00052 void openDialog( QWidget *parent, bool checkForEmptyFilterList = true );
00053
00056 void createFilter( const QByteArray & field, const QString & value );
00057
00058 bool beginFiltering(KMMsgBase *msgBase) const;
00059 int moveMessage(KMMessage *msg) const;
00060 void endFiltering(KMMsgBase *msgBase) const;
00061
00067 bool atLeastOneFilterAppliesTo( unsigned int accountID ) const;
00068
00074 bool atLeastOneIncomingFilterAppliesTo( unsigned int accountID ) const;
00075
00079 bool atLeastOneOnlineImapFolderTarget();
00080
00083 const QString createUniqueName( const QString & name );
00084
00088 void appendFilters( const QList<KMFilter*> &filters,
00089 bool replaceIfNameExists = false );
00090
00093 void setFilters( const QList<KMFilter*> &filters );
00094
00096 const QList<KMFilter*> & filters() const { return mFilters; }
00097
00112 int process( KMMessage * msg, FilterSet aSet = Inbound,
00113 bool account = false, uint accountId = 0 );
00114
00119 int process( KMMessage * msg, const KMFilter * filter );
00120
00123 int process( quint32 serNum, const KMFilter * filter );
00124
00125 void cleanup();
00126
00129 void ref();
00135 void deref(bool force = false);
00136
00141 int tempOpenFolder(KMFolder* aFolder);
00142
00145 void beginUpdate() {}
00146
00148 void endUpdate();
00149
00151 #ifndef NDEBUG
00152 void dump() const;
00153 #endif
00154
00159 bool folderRemoved(KMFolder* aFolder, KMFolder* aNewFolder);
00160
00163 void folderCreated(KMFolder*) {}
00164
00166 void setShowLaterMsgs( bool show ) {
00167 mShowLater = show;
00168 }
00169
00171 bool showLaterMsgs() const {
00172 return mShowLater;
00173 }
00174 public slots:
00175 void slotFolderRemoved( KMFolder *aFolder );
00176
00177 signals:
00178 void filterListUpdated();
00179
00180 private:
00181 int processPop( KMMessage * msg ) const;
00183 bool isMatching( KMMessage * msg, const KMFilter * filter );
00184 bool isMatching( quint32 serNum, const KMFilter * filter );
00185
00186 QPointer<KMFilterDlg> mEditDialog;
00187 QVector<KMFolder *> mOpenFolders;
00188 QList<KMFilter *> mFilters;
00189 bool bPopFilter;
00190 bool mShowLater;
00191 bool mDirtyBufferedFolderTarget;
00192 bool mBufferedFolderTarget;
00193
00194 int mRefCount;
00195 };
00196
00197 #endif