kmail
kmfolderindex.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kmfolderindex_h
00021 #define kmfolderindex_h
00022
00023 #include "folderstorage.h"
00024 #include "kmmsglist.h"
00025
00037 class KMFolderIndex: public FolderStorage
00038 {
00039 Q_OBJECT
00040
00041
00042
00043 friend class ::KMMsgBase;
00044 public:
00045
00049 enum IndexStatus { IndexOk,
00050 IndexMissing,
00051 IndexTooOld
00052 };
00053
00057 KMFolderIndex(KMFolder* folder, const char* name=0);
00058 virtual ~KMFolderIndex();
00059 virtual int count(bool cache = false) const;
00060
00061 virtual KMMsgBase* takeIndexEntry( int idx ) { return mMsgList.take( idx ); }
00062 virtual KMMsgInfo* setIndexEntry( int idx, KMMessage *msg );
00063 virtual void clearIndex(bool autoDelete=true, bool syncDict = false);
00064 virtual void truncateIndex();
00065
00066 virtual const KMMsgBase* getMsgBase(int idx) const { return mMsgList[idx]; }
00067 virtual KMMsgBase* getMsgBase(int idx) { return mMsgList[idx]; }
00068
00069 virtual int find(const KMMsgBase* msg) const { return mMsgList.find((KMMsgBase*)msg); }
00070 int find( const KMMessage * msg ) const { return FolderStorage::find( msg ); }
00071
00073 int serialIndexId() const { return mIndexId; }
00074
00075 uchar *indexStreamBasePtr() { return mIndexStreamPtr; }
00076
00077 bool indexSwapByteOrder() { return mIndexSwapByteOrder; }
00078 int indexSizeOfLong() { return mIndexSizeOfLong; }
00079
00080 virtual QString indexLocation() const;
00081 virtual int writeIndex( bool createEmptyIndex = false );
00082
00083 void recreateIndex( bool readIndexAfterwards = true );
00084
00085 public slots:
00087 virtual int updateIndex();
00088
00089 protected:
00090 bool readIndex();
00091
00093 bool readIndexHeader(int *gv=0);
00094
00098 virtual int createIndexFromContents() = 0;
00099
00100 bool updateIndexStreamPtr(bool just_close=FALSE);
00101
00108 virtual IndexStatus indexStatus() = 0;
00109
00114 virtual void fillMessageDict();
00115
00117 FILE* mIndexStream;
00119 KMMsgList mMsgList;
00120
00122 off_t mHeaderOffset;
00123
00124 uchar *mIndexStreamPtr;
00125 int mIndexStreamPtrLength, mIndexId;
00126 bool mIndexSwapByteOrder;
00127 int mIndexSizeOfLong;
00128
00129 private:
00130 void updateInvitationAndAddressFieldsFromContents();
00131
00132 };
00133
00134 #endif
|