kmail Library API Documentation

kmfolderindex.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002  * Virtual base class for mail folder with .*.index style index
00003  *
00004  * Author: Don Sanders <sanders@kde.org>
00005  * License: GPL
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   //TODO:Have to get rid of this friend declaration and add necessary pure
00017   //virtuals to kmfolder.h so that KMMsgBase::parent() can be a plain KMFolder
00018   //rather than a KMFolderIndex. Need this for database indices.
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; // Index file was written with swapped byte order
00096   int mIndexSizeOfLong; // Index file was written with longs of this size
00097 };
00098 
00099 #endif /*kmfolderindex_h*/
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 Sat May 1 11:37:27 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003