kmail Library API Documentation

kmmsgindex.h

00001 /* Message indexing 00002 * 00003 * Author: Sam Magnuson <zachsman@wiw.org> 00004 * This code is under GPL 00005 * 00006 */ 00007 #ifndef kmmsgindex_h 00008 #define kmmsgindex_h 00009 00010 #include "kmfolder.h" 00011 00012 #include <qmap.h> 00013 #include <qobject.h> 00014 #include <qstring.h> 00015 #include <qintdict.h> 00016 #include <qdatetime.h> 00017 #include <qvaluelist.h> 00018 #include <qvaluestack.h> 00019 #include <qguardedptr.h> 00020 00021 class KMMsgIndexRef; 00022 class KMIndexSearchTarget; 00023 class KMSearchPattern; 00024 class KMSearchRule; 00025 class KMSearch; 00026 00027 class KMMsgIndex : public QObject 00028 { 00029 Q_OBJECT 00030 enum { INDEX_IDLE, INDEX_RESTORE, INDEX_CREATE } mIndexState; 00031 QValueList<QGuardedPtr<KMFolder> > mOpenedFolders; 00032 00033 //book-keeping 00034 struct { 00035 int fd; 00036 Q_INT32 count, used, indexed, removed; 00037 KMMsgIndexRef *ref; 00038 QString loc; 00039 } mTermIndex; 00040 struct { 00041 int fd; 00042 QString loc; 00043 QMap<QCString, int> body; 00044 struct { 00045 int next_hnum; 00046 QMap<QCString, Q_UINT16> header_lookup; 00047 QMap<Q_UINT16, QMap<QCString, int> > headers; 00048 } h; 00049 } mTermTOC; 00050 struct { 00051 int fd; 00052 QString loc; 00053 QIntDict<void> known; 00054 } mTermProcessed; 00055 00056 //state information 00057 struct { 00058 int timer_id; 00059 QValueStack<Q_UINT32> serNums; 00060 QValueStack<QGuardedPtr<KMFolder> > folders; 00061 //these are used for partial creates.. 00062 } create; 00063 struct { 00064 int timer_id; 00065 bool reading_processed, restart_index; 00066 } restore; 00067 int delay_cnt; 00068 QTime mLastSearch; //when last index lookup was performed 00069 QIntDict<KMIndexSearchTarget> mActiveSearches; //for async search 00070 00071 public: 00072 KMMsgIndex(QObject *parent=NULL, const char *name=NULL); 00073 ~KMMsgIndex() { reset(); } 00074 00075 void init(); 00076 void remove(); 00077 00078 bool canHandleQuery(KMSearchRule *); 00079 bool canHandleQuery(KMSearchPattern *); 00080 QValueList<Q_UINT32> query(KMSearchRule *, bool full_phrase_search=TRUE); 00081 QValueList<Q_UINT32> query(KMSearchPattern *, bool full_phras_search=TRUE); 00082 00083 //convenient.. 00084 bool startQuery(KMSearch *); 00085 bool stopQuery(KMSearch *); 00086 bool stopQuery(int id) { return mActiveSearches.remove(id); } 00087 00088 //force the cleanup.. 00089 void cleanUp(); 00090 00091 private: 00092 //internal 00093 bool recreateIndex(); 00094 void readIndex(); 00095 void syncIndex(); 00096 00097 void flush(); 00098 void reset(bool =TRUE); 00099 00100 bool createState(bool =TRUE); 00101 bool restoreState(bool =TRUE); 00102 00103 int addBucket(int, Q_UINT32); 00104 QValueList<Q_UINT32> find(QString, bool, KMSearchRule *, bool =FALSE, 00105 Q_UINT16 =0); 00106 void values(int, int, QValueList<Q_UINT32> &); 00107 void values(int, int, QIntDict<void> &); 00108 00109 int processMsg(Q_UINT32); 00110 bool addHeaderTerm(Q_UINT16, const char *, uchar, Q_UINT32); 00111 bool addBodyTerm(const char *, uchar, Q_UINT32); 00112 int allocTermChunk(int); 00113 00114 bool isTimeForClean(); 00115 bool isKillTerm(const char *, uchar); 00116 bool isKillHeader(const char *, uchar); 00117 00118 protected: 00119 void timerEvent(QTimerEvent *); 00120 00121 private slots: 00122 void slotAddMsg(KMFolder *, Q_UINT32); 00123 void slotRemoveMsg(KMFolder *, Q_UINT32); 00124 }; 00125 00126 class KMIndexSearchTarget : public QObject 00127 { 00128 Q_OBJECT 00129 int mId; 00130 bool mVerifyResult; 00131 QValueList<QGuardedPtr<KMFolder> > mOpenedFolders; 00132 QValueStack<Q_UINT32> mSearchResult; 00133 QGuardedPtr<KMSearch> mSearch; 00134 public: 00135 KMIndexSearchTarget(KMSearch *); 00136 ~KMIndexSearchTarget(); 00137 00138 void stop(bool stop_search=TRUE) { 00139 if(stop_search && mSearch) 00140 emit proxyFinished(true); 00141 mSearch = NULL; 00142 } 00143 KMSearch *search() const { return mSearch; } 00144 int id() const { return mId; } 00145 00146 protected: 00147 void timerEvent(QTimerEvent *); 00148 00149 signals: 00150 void proxyFound(Q_UINT32); 00151 void proxyFinished(bool); 00152 }; 00153 00154 #endif /* __KMMSGINDEX_H__ */ 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:52:47 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003