00001
00002
00003
00004
00005
00006
00007
#ifndef kmfolderindex_h
00008
#define kmfolderindex_h
00009
00010
#include "kmfolder.h"
00011
#include "kmmsglist.h"
00012
00013
class KMFolderIndex:
public KMFolder
00014 {
00015 Q_OBJECT
00016
00017
00018
00019
friend class KMMsgBase;
00020
public:
00021
00025
enum IndexStatus { IndexOk,
00026 IndexMissing,
00027 IndexTooOld
00028 };
00029
00033 KMFolderIndex(
KMFolderDir* parent=0,
const QString& name=QString::null);
00034
virtual ~KMFolderIndex();
00035
virtual int count(
bool cache =
false)
const;
00036
00037
virtual KMMsgBase* takeIndexEntry(
int idx ) {
return mMsgList.take( idx ); }
00038
virtual KMMsgInfo* setIndexEntry(
int idx, KMMessage *msg );
00039
virtual void clearIndex(
bool autoDelete=
true,
bool syncDict =
false);
00040
virtual void fillDictFromIndex(KMMsgDict *dict);
00041
virtual void truncateIndex();
00042
00043
virtual const KMMsgBase* getMsgBase(
int idx)
const {
return mMsgList[idx]; }
00044
virtual KMMsgBase* getMsgBase(
int idx) {
return mMsgList[idx]; }
00045
00046
virtual int find(
const KMMsgBase* msg)
const {
return mMsgList.find((KMMsgBase*)msg); }
00047
int find(
const KMMessage * msg )
const {
return KMFolder::find( msg ); }
00048
00050
int serialIndexId()
const {
return mIndexId; }
00051
00052 uchar *indexStreamBasePtr() {
return mIndexStreamPtr; }
00053
00054
bool indexSwapByteOrder() {
return mIndexSwapByteOrder; }
00055
int indexSizeOfLong() {
return mIndexSizeOfLong; }
00056
00057
virtual QString
indexLocation() const;
00058 virtual
int writeIndex(
bool createEmptyIndex = false );
00059
00060 public slots:
00062 virtual
int updateIndex();
00063
00064 protected:
00065
bool readIndex();
00066
00068
bool readIndexHeader(
int *gv=0);
00069
00073 virtual
int createIndexFromContents() = 0;
00074
00075
bool updateIndexStreamPtr(
bool just_close=FALSE);
00076
00083 virtual IndexStatus indexStatus() = 0;
00084
00086 FILE* mIndexStream;
00088 KMMsgList mMsgList;
00089
00091 off_t mHeaderOffset;
00092
00093 uchar *mIndexStreamPtr;
00094
int mIndexStreamPtrLength, mIndexId;
00095
bool mIndexSwapByteOrder;
00096
int mIndexSizeOfLong;
00097 };
00098
00099 #endif