• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

KMFolderIndex Class Reference

#include <kmfolderindex.h>

Inheritance diagram for KMFolderIndex:

Inheritance graph
[legend]

List of all members.


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 <sanders@kde.org>

Definition at line 43 of file kmfolderindex.h.


Public Types

enum  IndexStatus { IndexOk, IndexMissing, IndexTooOld }
enum  OpenInternalOption { NoOptions = 0x0, CheckIfIndexTooOld = 0x1, CreateIndexFromContentsWhenReadIndexFailed = 0x2 }

Public Slots

int updateIndex (bool aboutToClose)
virtual int updateIndex ()

Public Member Functions

void addToSerialCache () const
virtual void clearIndex (bool autoDelete=true, bool syncDict=false)
virtual int count (bool cache=false) const
int find (const KMMessage *msg) const
virtual int find (const KMMsgBase *msg) const
virtual KMMsgBase * getMsgBase (int idx)
virtual const KMMsgBase * getMsgBase (int idx) const
int indexSizeOfLong ()
uchar * indexStreamBasePtr ()
size_t indexStreamLength () const
bool indexSwapByteOrder ()
 KMFolderIndex (KMFolder *folder, const char *name=0)
bool recreateIndex ()
int serialIndexId () const
virtual KMMsgInfo * setIndexEntry (int idx, KMMessage *msg)
virtual KMMsgBase * takeIndexEntry (int idx)
virtual void truncateIndex ()
virtual int writeIndex (bool createEmptyIndex=false)
virtual ~KMFolderIndex ()

Protected Member Functions

virtual int createIndexFromContents ()=0
int createInternal ()
virtual void fillMessageDict ()
virtual IndexStatus indexStatus ()=0
int openInternal (OpenInternalOptions options)
bool readIndex ()
bool readIndexHeader (int *gv=0)
bool updateIndexStreamPtr (bool just_close=false)
int writeMessages (KMMsgBase *msg, bool flush, FILE *indexStream)
int writeMessages (KMMsgBase *msg, bool flush=true)

Protected Attributes

off_t mHeaderOffset
int mIndexId
int mIndexSizeOfLong
FILE * mIndexStream
uchar * mIndexStreamPtr
size_t mIndexStreamPtrLength
bool mIndexSwapByteOrder
KMMsgList mMsgList

Member Enumeration Documentation

enum KMFolderIndex::IndexStatus

This enum indicates the status of the index file.

It's returned by indexStatus().

Enumerator:
IndexOk 
IndexMissing 
IndexTooOld 

Definition at line 55 of file kmfolderindex.h.

enum KMFolderIndex::OpenInternalOption

options for openInternal()

Enumerator:
NoOptions 
CheckIfIndexTooOld 
CreateIndexFromContentsWhenReadIndexFailed 

Definition at line 116 of file kmfolderindex.h.


Constructor & Destructor Documentation

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

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 29 of file kmfolderindex.cpp.

KMFolderIndex::~KMFolderIndex (  )  [virtual]

Definition at line 42 of file kmfolderindex.cpp.


Member Function Documentation

void KMFolderIndex::addToSerialCache (  )  const

Adds all messages of this folder to the serial number cache (by calling MessageProperty::setSerialCache for each message).

This makes subsequent calls to KMMsgBase::getMsgSerNum() much faster since the serial number is already in the cache.

The folder needs to be open for this.

Definition at line 199 of file kmfolderindex_common.cpp.

void KMFolderIndex::clearIndex ( bool  autoDelete = true,
bool  syncDict = false 
) [virtual]

Implements FolderStorage.

Definition at line 439 of file kmfolderindex.cpp.

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

Number of messages in this folder.

Reimplemented from FolderStorage.

Definition at line 281 of file kmfolderindex.cpp.

virtual int KMFolderIndex::createIndexFromContents (  )  [protected, pure 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.

Implemented in KMFolderCachedImap, KMFolderMaildir, and KMFolderMbox.

int KMFolderIndex::createInternal (  )  [protected]

Creates index stream (or database).

Called by KMFolderMaildir::create() and KMFolderMbox::create().

Definition at line 163 of file kmfolderindex_common.cpp.

void KMFolderIndex::fillMessageDict (  )  [protected, virtual]

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 455 of file kmfolderindex.cpp.

int KMFolderIndex::find ( const KMMessage *  msg  )  const [inline]

Reimplemented from FolderStorage.

Definition at line 79 of file kmfolderindex.h.

virtual int KMFolderIndex::find ( const KMMsgBase *  msg  )  const [inline, virtual]

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

Implements FolderStorage.

Definition at line 75 of file kmfolderindex.h.

virtual KMMsgBase* KMFolderIndex::getMsgBase ( int  idx  )  [inline, virtual]

Implements FolderStorage.

Definition at line 73 of file kmfolderindex.h.

virtual const KMMsgBase* KMFolderIndex::getMsgBase ( int  idx  )  const [inline, virtual]

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 72 of file kmfolderindex.h.

int KMFolderIndex::indexSizeOfLong (  )  [inline]

Definition at line 108 of file kmfolderindex.h.

KMFolderIndex::IndexStatus KMFolderIndex::indexStatus (  )  [protected, 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.

Implemented in KMFolderMbox.

Definition at line 426 of file kmfolderindex.cpp.

uchar* KMFolderIndex::indexStreamBasePtr (  )  [inline]

If we have mmap(2), then we have a pointer to the mmap()ed index file; return a pointer to the memory region containing the file.

Definition at line 100 of file kmfolderindex.h.

size_t KMFolderIndex::indexStreamLength (  )  const [inline]

If we have mmap(2), then we know the size of the index file.

Return it. 0 if we don't have mmap(2).

Definition at line 105 of file kmfolderindex.h.

bool KMFolderIndex::indexSwapByteOrder (  )  [inline]

Definition at line 107 of file kmfolderindex.h.

int KMFolderIndex::openInternal ( OpenInternalOptions  options  )  [protected]

Opens index stream (or database) without creating it.

If checkIfIndexTooOld is true, message "The index of folder .. seems to be out of date" is displayed. Called by KMFolderMaildir::open() and KMFolderMbox::open().

Definition at line 77 of file kmfolderindex_common.cpp.

bool KMFolderIndex::readIndex (  )  [protected, virtual]

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

Implements FolderStorage.

Definition at line 195 of file kmfolderindex.cpp.

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

Read index header.

Called from within readIndex().

Definition at line 290 of file kmfolderindex.cpp.

bool KMFolderIndex::recreateIndex (  ) 

Definition at line 476 of file kmfolderindex.cpp.

int KMFolderIndex::serialIndexId (  )  const [inline]

Registered unique serial number for the index file.

Definition at line 93 of file kmfolderindex.h.

KMMsgInfo * KMFolderIndex::setIndexEntry ( int  idx,
KMMessage *  msg 
) [virtual]

Implements FolderStorage.

Definition at line 468 of file kmfolderindex.cpp.

KMMsgBase * KMFolderIndex::takeIndexEntry ( int  idx  )  [virtual]

Implements FolderStorage.

Definition at line 523 of file kmfolderindex.cpp.

void KMFolderIndex::truncateIndex (  )  [virtual]

Implements FolderStorage.

Definition at line 445 of file kmfolderindex.cpp.

int KMFolderIndex::updateIndex ( bool  aboutToClose  )  [slot]

Definition at line 46 of file kmfolderindex.cpp.

virtual int KMFolderIndex::updateIndex (  )  [inline, virtual, slot]

Incrementally update the index if possible else call writeIndex.

Implements FolderStorage.

Definition at line 125 of file kmfolderindex.h.

bool KMFolderIndex::updateIndexStreamPtr ( bool  just_close = false  )  [protected]

Definition at line 372 of file kmfolderindex.cpp.

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 66 of file kmfolderindex.cpp.

int KMFolderIndex::writeMessages ( KMMsgBase *  msg,
bool  flush,
FILE *  indexStream 
) [protected]

Definition at line 488 of file kmfolderindex.cpp.

int KMFolderIndex::writeMessages ( KMMsgBase *  msg,
bool  flush = true 
) [protected]

Writes messages to the index.

The stream is flushed if flush is true. If msg is 0, all mesages from mMsgList are written, else only is written.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 518 of file kmfolderindex.cpp.


Member Data Documentation

off_t KMFolderIndex::mHeaderOffset [protected]

offset of header of index file

Definition at line 208 of file kmfolderindex.h.

int KMFolderIndex::mIndexId [protected]

Definition at line 216 of file kmfolderindex.h.

int KMFolderIndex::mIndexSizeOfLong [protected]

Definition at line 213 of file kmfolderindex.h.

FILE* KMFolderIndex::mIndexStream [protected]

table of contents file

Definition at line 206 of file kmfolderindex.h.

uchar* KMFolderIndex::mIndexStreamPtr [protected]

Definition at line 209 of file kmfolderindex.h.

size_t KMFolderIndex::mIndexStreamPtrLength [protected]

Definition at line 210 of file kmfolderindex.h.

bool KMFolderIndex::mIndexSwapByteOrder [protected]

Definition at line 212 of file kmfolderindex.h.

KMMsgList KMFolderIndex::mMsgList [protected]

list of index entries or messages

Definition at line 173 of file kmfolderindex.h.


The documentation for this class was generated from the following files:
  • kmfolderindex.h
  • kmfolderindex.cpp
  • kmfolderindex_common.cpp
  • kmfolderindex_sqlite.cpp

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal