kmail Library API Documentation

kmfoldersearch.h

00001 /* Dynamic search folder 00002 * 00003 * Author: Don Sanders <sanders@kde.org> 00004 * License: GPL 00005 */ 00006 #ifndef kmfoldersearch_h 00007 #define kmfoldersearch_h 00008 00009 #include <qguardedptr.h> 00010 #include <qvaluelist.h> 00011 #include <qvaluevector.h> 00012 #include <qvaluestack.h> 00013 #include "kmfolder.h" 00014 00024 typedef QValueList<Q_UINT32> SerNumList; 00025 class KMSearchPattern; 00026 class KMFolderImap; 00027 class QTimer; 00028 00029 namespace KMail { 00030 class AttachmentStrategy; 00031 } 00032 using KMail::AttachmentStrategy; 00033 00034 class KMSearch: public QObject 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 KMSearch(QObject * parent = 0, const char * name = 0); 00040 ~KMSearch(); 00041 00042 bool write(QString location) const; 00043 bool read(QString location); 00044 bool recursive() const { return mRecursive; } 00045 void setRecursive(bool recursive) { if (running()) stop(); mRecursive = recursive; } 00046 KMFolder* root() const { return mRoot; } 00047 void setRoot(KMFolder *folder) { if (running()) stop(); mRoot = folder; } 00048 bool inScope(KMFolder* folder) const; 00049 //Takes ownership of @searchPattern 00050 void setSearchPattern(KMSearchPattern *searchPattern); 00051 KMSearchPattern* searchPattern() const { return mSearchPattern; } 00052 void start(); 00053 bool running() const { return mRunning; } 00054 void stop(); 00055 int foundCount() const { return mFoundCount; } 00056 int searchedCount() const { return mSearchedCount; } 00057 QString currentFolder() const { return mLastFolder; } 00058 00059 signals: 00060 void found(Q_UINT32 serNum); 00061 void finished(bool success); 00062 00063 protected slots: 00064 void slotProcessNextBatch(); 00065 void slotFolderComplete(KMFolderImap *folder, bool success); 00066 00067 protected: 00068 friend class KMIndexSearchTarget; 00069 void setRunning(bool b) { mRunning = b; } 00070 void setFoundCount(int f) { mFoundCount = f; } 00071 void setSearchedCount(int f) { mSearchedCount = f; } 00072 void setCurrentFolder(const QString &f) { mLastFolder = f; } 00073 00074 private: 00075 int mRemainingMessages; 00076 int mRemainingFolders; 00077 bool mRecursive, mRunning, mIdle, mRunByIndex; 00078 QGuardedPtr<KMFolder> mRoot; 00079 KMSearchPattern* mSearchPattern; 00080 QValueList<QGuardedPtr<KMFolder> > mFolders, mOpenedFolders; 00081 QValueList<QGuardedPtr<KMFolderImap> > mIncompleteFolders; 00082 SerNumList mSerNums; 00083 QString mLastFolder; 00084 int mSearchedCount, mFoundCount; 00085 QTimer *mProcessNextBatchTimer; 00086 }; 00087 00088 class KMFolderSearch: public KMFolder 00089 { 00090 Q_OBJECT 00091 friend class KMFolderSearchJob; 00092 public: 00093 KMFolderSearch(KMFolderDir* parent=0, const QString& name=QString::null); 00094 virtual ~KMFolderSearch(); 00095 00097 virtual KMFolderType folderType() const { return KMFolderTypeSearch; } 00098 00099 // Sets and runs the search used by the folder 00100 void setSearch(KMSearch *search); 00101 // Returns the current search used by the folder 00102 const KMSearch* search() const; 00103 // Stops the current search 00104 void stopSearch() { if (mSearch) mSearch->stop(); } 00105 00106 virtual KMMessage* getMsg(int idx); 00107 virtual void ignoreJobsForMessage( KMMessage* ); 00108 00109 protected slots: 00110 // Reads search definition for this folder and creates a KMSearch 00111 bool readSearch(); 00112 // Runs the current search again 00113 void executeSearch(); 00114 // Called when the search is finished 00115 void searchFinished(bool success); 00116 // Look at a new message and if it matches search() add it to the cache 00117 void examineAddedMessage(KMFolder *folder, Q_UINT32 serNum); 00118 // Look at all new messages in a completed (imap) folder 00119 void examineCompletedFolder(KMFolderImap *folder, bool success); 00120 // Look at a removed message and remove it from the cache 00121 void examineRemovedMessage(KMFolder *folder, Q_UINT32 serNum); 00122 // Look at a message whose status has changed 00123 void examineChangedMessage(KMFolder *folder, Q_UINT32 serNum, int delta); 00124 // The serial numbers for a folder have been invalidated, deal with it 00125 void examineInvalidatedFolder(KMFolder *folder); 00126 // A folder has been deleted, deal with it 00127 void examineRemovedFolder(KMFolder *folder); 00128 // Propagate the msgHeaderChanged signal 00129 void propagateHeaderChanged(KMFolder *folder, int idx); 00130 00131 public slots: 00132 // Appends the serial number to the cached list of messages that match 00133 // the search for this folder 00134 void addSerNum(Q_UINT32 serNum); 00135 // Removes the serial number from the cached list of messages that match 00136 // the search for this folder 00137 void removeSerNum(Q_UINT32 serNum); 00138 00140 virtual int updateIndex(); 00141 00142 public: 00143 //See base class for documentation 00144 virtual QCString& getMsgString(int idx, QCString& mDest); 00145 virtual int addMsg(KMMessage* msg, int* index_return = 0); 00146 virtual int open(); 00147 virtual int canAccess(); 00148 virtual void sync(); 00149 virtual void close(bool force=FALSE); 00150 virtual int create(bool imap = FALSE); 00151 virtual int compact(); 00152 virtual bool isReadOnly() const; 00153 virtual QCString protocol() const { return "search"; } 00154 virtual const KMMsgBase* getMsgBase(int idx) const; 00155 virtual KMMsgBase* getMsgBase(int idx); 00156 virtual int find(const KMMsgBase* msg) const; 00157 virtual QString indexLocation() const; 00158 virtual int writeIndex( bool createEmptyIndex = false ); 00159 DwString getDwString(int idx); 00160 Q_UINT32 serNum(int idx) { return mSerNums[idx]; } 00161 00162 protected: 00163 virtual FolderJob* doCreateJob(KMMessage *msg, FolderJob::JobType jt, 00164 KMFolder *folder, QString partSpecifier, 00165 const AttachmentStrategy *as ) const; 00166 virtual FolderJob* doCreateJob(QPtrList<KMMessage>& msgList, const QString& sets, 00167 FolderJob::JobType jt, KMFolder *folder) const; 00168 virtual KMMessage* readMsg(int idx); 00169 virtual bool readIndex(); 00170 virtual int removeContents(); 00171 virtual int expungeContents(); 00172 virtual int count(bool cache = false) const; 00173 virtual KMMsgBase* takeIndexEntry(int idx); 00174 virtual KMMsgInfo* setIndexEntry(int idx, KMMessage *msg); 00175 virtual void clearIndex(bool autoDelete=true, bool syncDict = false); 00176 virtual void fillDictFromIndex(KMMsgDict*); 00177 virtual void truncateIndex(); 00178 00179 private: 00180 QValueVector<Q_UINT32> mSerNums; 00181 QValueList<QGuardedPtr<KMFolder> > mFolders; 00182 QValueStack<Q_UINT32> mUnexaminedMessages; 00183 FILE *mIdsStream; 00184 KMSearch *mSearch; 00185 bool mInvalid, mUnlinked; 00186 bool mTempOpened; 00187 QTimer *mExecuteSearchTimer; 00188 }; 00189 #endif /*kmfoldersearch_h*/ 00190
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 Wed Jul 28 23:58:01 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003