kmail

#include <kmfolderindex.h>

Inheritance diagram for KMFolderIndex:
FolderStorage

Public Types

enum  IndexStatus { IndexOk , IndexMissing , IndexCorrupt , IndexTooOld }
 
- Public Types inherited from FolderStorage
enum  ChildrenState { HasChildren , HasNoChildren , ChildrenUnknown }
 

Public Slots

virtual int updateIndex ()
 
- Public Slots inherited from FolderStorage
virtual int updateIndex ()=0
 
virtual void reallyAddMsg (KMMessage *aMsg)
 
virtual void reallyAddCopyOfMsg (KMMessage *aMsg)
 
void slotEmitChangedTimer ()
 

Public Member Functions

 KMFolderIndex (KMFolder *folder, const char *name=0)
 
virtual int count (bool cache=false) const
 
virtual KMMsgBase * takeIndexEntry (int idx)
 
virtual KMMsgInfo * setIndexEntry (int idx, KMMessage *msg)
 
virtual void clearIndex (bool autoDelete=true, bool syncDict=false)
 
virtual void truncateIndex ()
 
virtual const KMMsgBase * getMsgBase (int idx) const
 
virtual KMMsgBase * getMsgBase (int idx)
 
virtual int find (const KMMsgBase *msg) const
 
int find (const KMMessage *msg) const
 
int serialIndexId () const
 
uchar * indexStreamBasePtr ()
 
bool indexSwapByteOrder ()
 
int indexSizeOfLong ()
 
virtual TQString indexLocation () const
 
virtual int writeIndex (bool createEmptyIndex=false)
 
void recreateIndex (bool readIndexAfterwards=true)
 
void silentlyRecreateIndex ()
 
virtual IndexStatus indexStatus ()=0
 
- Public Member Functions inherited from FolderStorage
 FolderStorage (KMFolder *folder, const char *name=0)
 
KMFolderfolder () const
 
virtual KMFolderType folderType () const
 
virtual TQString fileName () const
 
TQString location () const
 
virtual bool noContent () const
 
virtual void setNoContent (bool aNoContent)
 
virtual bool noChildren () const
 
virtual void setNoChildren (bool aNoChildren)
 
virtual ChildrenState hasChildren () const
 
virtual void setHasChildren (ChildrenState state)
 
virtual void updateChildrenState ()
 
virtual KMMessagegetMsg (int idx)
 
virtual KMMsgInfo * unGetMsg (int idx)
 
virtual bool isMessage (int idx)
 
virtual KMMessagereadTemporaryMsg (int idx)
 
virtual DwString getDwString (int idx)=0
 
virtual void ignoreJobsForMessage (KMMessage *)
 
virtual FolderJob * createJob (KMMessage *msg, FolderJob::JobType jt=FolderJob::tGetMessage, KMFolder *folder=0, TQString partSpecifier=TQString(), const AttachmentStrategy *as=0) const
 
virtual FolderJob * createJob (TQPtrList< KMMessage > &msgList, const TQString &sets, FolderJob::JobType jt=FolderJob::tGetMessage, KMFolder *folder=0) const
 
virtual const KMMsgBase * operator[] (int idx) const
 
virtual KMMsgBase * operator[] (int idx)
 
virtual KMMessagetake (int idx)
 
virtual void take (TQPtrList< KMMessage > msgList)
 
virtual int addMsg (KMMessage *msg, int *index_return=0)=0
 
virtual int addMsgKeepUID (KMMessage *msg, int *index_return=0)
 
virtual int addMsg (TQPtrList< KMMessage > &, TQValueList< int > &index_return)
 
void emitMsgAddedSignals (int idx)
 
virtual bool canAddMsgNow (KMMessage *aMsg, int *aIndex_ret)
 
virtual void removeMsg (int i, bool imapQuiet=false)
 
virtual void removeMsg (const TQPtrList< KMMsgBase > &msgList, bool imapQuiet=false)
 
virtual void removeMsg (const TQPtrList< KMMessage > &msgList, bool imapQuiet=false)
 
virtual int expungeOldMsg (int days)
 
virtual int moveMsg (KMMessage *msg, int *index_return=0)
 
virtual int moveMsg (TQPtrList< KMMessage >, int *index_return=0)
 
int find (const KMMessage *msg) const
 
virtual int countUnread ()
 
TQ_INT64 folderSize () const
 
virtual bool isCloseToQuota () const
 
virtual void msgStatusChanged (const KMMsgStatus oldStatus, const KMMsgStatus newStatus, int idx)
 
virtual int open (const char *owner)=0
 
virtual int canAccess ()=0
 
void close (const char *owner, bool force=false)
 
virtual void reallyDoClose (const char *owner)=0
 
virtual void tryReleasingFolder (KMFolder *)
 
virtual void sync ()=0
 
bool isOpened () const
 
virtual void markNewAsUnread ()
 
virtual void markUnreadAsRead ()
 
virtual int create ()=0
 
virtual void remove ()
 
virtual int expunge ()
 
virtual int compact (bool silent)=0
 
virtual int rename (const TQString &newName, KMFolderDir *aParent=0)
 
bool autoCreateIndex () const
 
virtual void setAutoCreateIndex (bool)
 
bool dirty () const
 
void setDirty (bool f)
 
bool needsCompacting () const
 
virtual void setNeedsCompacting (bool f)
 
virtual void quiet (bool beQuiet)
 
virtual bool isReadOnly () const =0
 
virtual bool canDeleteMessages () const
 
TQString label () const
 
virtual void correctUnreadMsgsCount ()
 
void registerWithMessageDict ()
 
void deregisterFromMessageDict ()
 
virtual void setStatus (int idx, KMMsgStatus status, bool toggle=false)
 
virtual void setStatus (TQValueList< int > &ids, KMMsgStatus status, bool toggle=false)
 
void removeJobs ()
 
virtual void readConfig ()
 
virtual void writeConfig ()
 
virtual KMFoldertrashFolder () const
 
void addJob (FolderJob *) const
 
bool compactable () const
 
virtual void setContentsType (KMail::FolderContentsType type, bool quiet=false)
 
KMail::FolderContentsType contentsType () const
 
virtual void search (const KMSearchPattern *)
 
virtual void search (const KMSearchPattern *, TQ_UINT32 serNum)
 
virtual bool isMoveable () const
 
virtual KMAccount * account () const
 
virtual bool mailCheckInProgress () const
 

Protected Member Functions

bool readIndex ()
 
bool readIndexHeader (int *gv=0)
 
virtual int createIndexFromContents ()=0
 
bool updateIndexStreamPtr (bool just_close=FALSE)
 
virtual void fillMessageDict ()
 
- Protected Member Functions inherited from FolderStorage
virtual FolderJob * doCreateJob (KMMessage *msg, FolderJob::JobType jt, KMFolder *folder, TQString partSpecifier, const AttachmentStrategy *as) const =0
 
virtual FolderJob * doCreateJob (TQPtrList< KMMessage > &msgList, const TQString &sets, FolderJob::JobType jt, KMFolder *folder) const =0
 
void headerOfMsgChanged (const KMMsgBase *, int idx)
 
virtual KMMessagereadMsg (int idx)=0
 
void readFolderIdsFile ()
 
int writeFolderIdsFile () const
 
int touchFolderIdsFile ()
 
int appendToFolderIdsFile (int idx=-1)
 
void setRDict (KMMsgDictREntry *rentry) const
 
KMMsgDictREntry * rDict () const
 
void replaceMsgSerNum (unsigned long sernum, KMMsgBase *msg, int idx)
 
void invalidateFolder ()
 
virtual int removeContents ()=0
 
virtual int expungeContents ()=0
 
virtual TQ_INT64 doFolderSize () const
 

Protected Attributes

FILE * mIndexStream
 
KMMsgList mMsgList
 
off_t mHeaderOffset
 
uchar * mIndexStreamPtr
 
int mIndexStreamPtrLength
 
int mIndexId
 
bool mIndexSwapByteOrder
 
int mIndexSizeOfLong
 
- Protected Attributes inherited from FolderStorage
int mOpenCount
 
int mQuiet
 
bool mChanged:1
 
bool mAutoCreateIndex:1
 
bool mExportsSernums:1
 
bool mDirty:1
 
bool mFilesLocked:1
 
int mUnreadMsgs
 
int mGuessedUnreadMsgs
 
int mTotalMsgs
 
TQ_INT64 mSize
 
bool mWriteConfigEnabled:1
 
bool needsCompact:1
 
bool mCompactable:1
 
bool mNoContent:1
 
bool mNoChildren:1
 
bool mConvertToUtf8:1
 
KMMsgDictREntry * mRDict
 
TQPtrList< FolderJob > mJobList
 
TQTimer * mDirtyTimer
 
ChildrenState mHasChildren
 
KMail::FolderContentsType mContentsType
 
KMFoldermFolder
 
TQTimer * mEmitChangedTimer
 
int mCurrentSearchedMsg
 
const KMSearchPatternmSearchPattern
 

Friends

class ::KMMsgBase
 

Additional Inherited Members

- Signals inherited from FolderStorage
void changed ()
 
void cleared ()
 
void expunged (KMFolder *)
 
void closed (KMFolder *)
 
void invalidated (KMFolder *)
 
void nameChanged ()
 
void locationChanged (const TQString &, const TQString &)
 
void contentsTypeChanged (KMail::FolderContentsType type)
 
void readOnlyChanged (KMFolder *)
 
void noContentChanged ()
 
void msgRemoved (KMFolder *, TQ_UINT32 sernum)
 
void msgRemoved (int idx, TQString msgIdMD5)
 
void msgRemoved (KMFolder *)
 
void msgAdded (int idx)
 
void msgAdded (KMFolder *, TQ_UINT32 sernum)
 
void msgChanged (KMFolder *, TQ_UINT32 sernum, int delta)
 
void msgHeaderChanged (KMFolder *, int)
 
void statusMsg (const TQString &)
 
void numUnreadMsgsChanged (KMFolder *)
 
void removed (KMFolder *, bool)
 
void searchResult (KMFolder *, TQValueList< TQ_UINT32 >, const KMSearchPattern *, bool complete)
 
void searchDone (KMFolder *, TQ_UINT32, const KMSearchPattern *, bool)
 
void folderSizeChanged ()
 
void syncStateChanged ()
 
- Static Public Member Functions inherited from FolderStorage
static TQString dotEscape (const TQString &)
 
- Protected Types inherited from FolderStorage
enum  { mDirtyTimerInterval = 600000 }
 
- Protected Slots inherited from FolderStorage
virtual void removeJob (TQObject *)
 
void slotProcessNextSearchBatch ()
 

Detailed Description

A FolderStorage with an index for faster access to often used message properties.

This class represents a message store which has an index for providing fast access to often used message properties, namely those displayed in the list of messages (KMHeaders).

Author
Don Sanders sande.nosp@m.rs@k.nosp@m.de.or.nosp@m.g

Definition at line 37 of file kmfolderindex.h.

Member Enumeration Documentation

◆ IndexStatus

This enum indicates the status of the index file.

It's returned by indexStatus().

Definition at line 50 of file kmfolderindex.h.

Constructor & Destructor Documentation

◆ KMFolderIndex()

KMFolderIndex::KMFolderIndex ( KMFolder folder,
const char *  name = 0 
)

Usually a parent is given.

But in some cases there is no fitting parent object available. Then the name of the folder is used as the absolute path to the folder file.

Definition at line 77 of file kmfolderindex.cpp.

Member Function Documentation

◆ count()

int KMFolderIndex::count ( bool  cache = false) const
virtual

Number of messages in this folder.

Reimplemented from FolderStorage.

Definition at line 324 of file kmfolderindex.cpp.

◆ createIndexFromContents()

virtual int KMFolderIndex::createIndexFromContents ( )
protectedpure virtual

Create index file from messages file and fill the message-info list mMsgList.

Returns 0 on success and an errno value (see fopen) on failure.

◆ fillMessageDict()

void KMFolderIndex::fillMessageDict ( )
protectedvirtual

Inserts messages into the message dictionary by iterating over the message list.

The messages will get new serial numbers. This is only used on newly appeared folders, where there is no .ids file yet, or when that has been invalidated.

Reimplemented from FolderStorage.

Definition at line 502 of file kmfolderindex.cpp.

◆ find()

virtual int KMFolderIndex::find ( const KMMsgBase *  msg) const
inlinevirtual

Returns the index of the given message or -1 if not found.

Implements FolderStorage.

Definition at line 71 of file kmfolderindex.h.

◆ getMsgBase()

virtual const KMMsgBase* KMFolderIndex::getMsgBase ( int  idx) const
inlinevirtual

Provides access to the basic message fields that are also stored in the index.

Whenever you only need subject, from, date, status you should use this method instead of getMsg() because getMsg() will load the message if necessary and this method does not.

Implements FolderStorage.

Definition at line 68 of file kmfolderindex.h.

◆ indexLocation()

TQString KMFolderIndex::indexLocation ( ) const
virtual

Returns full path to index file.

Implements FolderStorage.

Definition at line 95 of file kmfolderindex.cpp.

◆ indexStatus()

KMFolderIndex::IndexStatus KMFolderIndex::indexStatus ( )
pure virtual

Tests whether the contents of this folder is newer than the index.

Should return IndexTooOld if the index is older than the contents. Should return IndexMissing if there is contents but no index. Should return IndexOk if the folder doesn't exist anymore "physically" or if the index is not older than the contents.

Definition at line 470 of file kmfolderindex.cpp.

◆ readIndex()

bool KMFolderIndex::readIndex ( )
protectedvirtual

Read index file and fill the message-info list mMsgList.

Implements FolderStorage.

Definition at line 218 of file kmfolderindex.cpp.

◆ readIndexHeader()

bool KMFolderIndex::readIndexHeader ( int *  gv = 0)
protected

Read index header.

Called from within readIndex().

Definition at line 333 of file kmfolderindex.cpp.

◆ serialIndexId()

int KMFolderIndex::serialIndexId ( ) const
inline

Registered unique serial number for the index file.

Definition at line 75 of file kmfolderindex.h.

◆ updateIndex

int KMFolderIndex::updateIndex ( )
virtualslot

Incrementally update the index if possible else call writeIndex.

Definition at line 109 of file kmfolderindex.cpp.

◆ writeIndex()

int KMFolderIndex::writeIndex ( bool  createEmptyIndex = false)
virtual

Write index to index-file.

Returns 0 on success and errno error on failure.

Implements FolderStorage.

Definition at line 129 of file kmfolderindex.cpp.

Member Data Documentation

◆ mHeaderOffset

off_t KMFolderIndex::mHeaderOffset
protected

offset of header of index file

Definition at line 125 of file kmfolderindex.h.

◆ mIndexStream

FILE* KMFolderIndex::mIndexStream
protected

table of contents file

Definition at line 120 of file kmfolderindex.h.

◆ mMsgList

KMMsgList KMFolderIndex::mMsgList
protected

list of index entries or messages

Definition at line 122 of file kmfolderindex.h.


The documentation for this class was generated from the following files: