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

kmail

FolderStorage Class Reference

#include <folderstorage.h>

Inheritance diagram for FolderStorage:

Inheritance graph
[legend]

List of all members.


Detailed Description

The FolderStorage class is the bass class for the storage related aspects of a collection of mail (a folder).

Accounts

The accounts (of KMail) that are fed into the folder are represented as the children of the folder. They are only stored here during runtime to have a reference for which accounts point to a specific folder.

Definition at line 81 of file folderstorage.h.


Public Types

enum  ChildrenState { HasChildren, HasNoChildren, ChildrenUnknown }

Public Slots

virtual void reallyAddCopyOfMsg (KMMessage *aMsg)
virtual void reallyAddMsg (KMMessage *aMsg)
void slotEmitChangedTimer ()
virtual int updateIndex ()=0

Signals

void changed ()
void cleared ()
void closed (KMFolder *)
void contentsTypeChanged (KMail::FolderContentsType type)
void expunged (KMFolder *)
void folderSizeChanged ()
void invalidated (KMFolder *)
void locationChanged (const QString &, const QString &)
void msgAdded (KMFolder *, quint32 sernum)
void msgAdded (int idx)
void msgChanged (KMFolder *, quint32 sernum, int delta)
void msgHeaderChanged (KMFolder *, int)
void msgRemoved (KMFolder *)
void msgRemoved (int idx, const QString &msgIdMD5)
void msgRemoved (KMFolder *, quint32 sernum)
void nameChanged ()
void numUnreadMsgsChanged (KMFolder *)
void readOnlyChanged (KMFolder *)
void removed (KMFolder *, bool)
void searchDone (KMFolder *, quint32, const KMSearchPattern *, bool)
void searchResult (KMFolder *, QList< quint32 >, const KMSearchPattern *, bool complete)
void statusMsg (const QString &)

Public Member Functions

virtual KMAccount * account () const
void addJob (FolderJob *) const
virtual int addMessages (QList< KMMessage * > &, QList< int > &index_return)
virtual int addMsg (KMMessage *msg, int *index_return=0)=0
virtual int addMsgKeepUID (KMMessage *msg, int *index_return=0)
bool autoCreateIndex () const
virtual bool canAccess () const =0
virtual bool canAddMsgNow (KMMessage *aMsg, int *aIndex_ret)
virtual void close (const char *owner, bool force=false)=0
virtual int compact (bool silent)=0
bool compactable () const
KMail::FolderContentsType contentsType () const
virtual void correctUnreadMsgsCount ()
virtual int count (bool cache=false) const
virtual int countUnread ()
virtual int create ()=0
virtual FolderJob * createJob (QList< KMMessage * > &msgList, const QString &sets, FolderJob::JobType jt=FolderJob::tGetMessage, KMFolder *folder=0) const
virtual FolderJob * createJob (KMMessage *msg, FolderJob::JobType jt=FolderJob::tGetMessage, KMFolder *folder=0, const QString &partSpecifier=QString(), const AttachmentStrategy *as=0) const
void deregisterFromMessageDict ()
bool dirty () const
void emitMsgAddedSignals (int idx)
virtual int expunge ()
virtual int expungeOldMsg (int days)
virtual QString fileName () const
int find (const KMMessage *msg) const
virtual int find (const KMMsgBase *msg) const =0
KMFolder * folder () const
qint64 folderSize () const
 FolderStorage (KMFolder *folder, const char *name=0)
virtual KMFolderType folderType () const
virtual DwString getDwString (int idx)=0
virtual KMMessage * getMsg (int idx)
virtual KMMsgBase * getMsgBase (int idx)=0
virtual const KMMsgBase * getMsgBase (int idx) const =0
virtual ChildrenState hasChildren () const
virtual QString idsLocation () const
virtual void ignoreJobsForMessage (KMMessage *)
virtual QString indexLocation () const
virtual bool isCloseToQuota () const
virtual bool isMessage (int idx)
virtual bool isMoveable () const
bool isOpened () const
virtual bool isReadOnly () const =0
QString label () const
QString location () const
virtual void markNewAsUnread ()
virtual void markUnreadAsRead ()
virtual int moveMsg (QList< KMMessage * >, int *index_return=0)
virtual int moveMsg (KMMessage *msg, int *index_return=0)
virtual void msgStatusChanged (const MessageStatus &oldStatus, const MessageStatus &newStatus, int idx)
bool needsCompacting () const
virtual bool noChildren () const
virtual bool noContent () const
virtual int open (const char *owner)=0
virtual KMMsgBase * operator[] (int idx)
virtual const KMMsgBase * operator[] (int idx) const
virtual void quiet (bool beQuiet)
virtual void readConfig ()
virtual KMMessage * readTemporaryMsg (int idx)
void registerWithMessageDict ()
virtual void remove ()
void removeJobs ()
virtual void removeMessages (const QList< KMMessage * > &msgList, bool imapQuiet=false)
virtual void removeMessages (const QList< KMMsgBase * > &msgList, bool imapQuiet=false)
virtual void removeMsg (int i, bool imapQuiet=false)
virtual int rename (const QString &newName, KMFolderDir *aParent=0)
virtual void search (const KMSearchPattern *, quint32 serNum)
virtual void search (const KMSearchPattern *)
virtual void setAutoCreateIndex (bool)
virtual void setContentsType (KMail::FolderContentsType type, bool quiet=false)
void setDirty (bool f)
virtual void setHasChildren (ChildrenState state)
virtual void setNeedsCompacting (bool f)
virtual void setNoChildren (bool aNoChildren)
virtual void setNoContent (bool aNoContent)
virtual void setStatus (QList< int > &ids, const MessageStatus &status, bool toggle=false)
virtual void setStatus (int idx, const MessageStatus &status, bool toggle=false)
virtual QString sortedLocation () const
virtual void sync ()=0
virtual KMMessage * take (int idx)
virtual void takeMessages (const QList< KMMessage * > &msgList)
virtual KMFolder * trashFolder () const
virtual void tryReleasingFolder (KMFolder *)
virtual KMMsgInfo * unGetMsg (int idx)
virtual void updateChildrenState ()
virtual void writeConfig ()
virtual int writeIndex (bool createEmptyIndex=false)=0
virtual ~FolderStorage ()

Static Public Member Functions

static QString dotEscape (const QString &)

Protected Types

enum  { mDirtyTimerInterval = 600000 }

Protected Slots

virtual void removeJob (QObject *)
void slotProcessNextSearchBatch ()

Protected Member Functions

int appendToFolderIdsFile (int idx=-1)
virtual void clearIndex (bool autoDelete=true, bool syncDict=false)=0
virtual FolderJob * doCreateJob (QList< KMMessage * > &msgList, const QString &sets, FolderJob::JobType jt, KMFolder *folder) const =0
virtual FolderJob * doCreateJob (KMMessage *msg, FolderJob::JobType jt, KMFolder *folder, const QString &partSpecifier, const AttachmentStrategy *as) const =0
virtual qint64 doFolderSize () const
virtual int expungeContents ()=0
virtual void fillMessageDict ()
void headerOfMsgChanged (const KMMsgBase *, int idx)
void invalidateFolder ()
virtual QString location (const QString &suffix) const
KMMsgDictREntry * rDict () const
void readFolderIdsFile ()
virtual bool readIndex ()=0
virtual KMMessage * readMsg (int idx)=0
virtual int removeContents ()=0
void replaceMsgSerNum (unsigned long sernum, KMMsgBase *msg, int idx)
virtual KMMsgInfo * setIndexEntry (int idx, KMMessage *msg)=0
void setRDict (KMMsgDictREntry *rentry) const
virtual KMMsgBase * takeIndexEntry (int idx)=0
int touchFolderIdsFile ()
virtual void truncateIndex ()=0
int writeFolderIdsFile () const

Protected Attributes

bool mAutoCreateIndex:1
bool mChanged:1
bool mCompactable:1
KMail::FolderContentsType mContentsType
bool mConvertToUtf8:1
int mCurrentSearchedMsg
bool mDirty:1
QTimer * mDirtyTimer
QTimer * mEmitChangedTimer
bool mExportsSernums:1
bool mFilesLocked:1
KMFolder * mFolder
int mGuessedUnreadMsgs
ChildrenState mHasChildren
QList< FolderJob * > mJobList
bool mNoChildren:1
bool mNoContent:1
int mOpenCount
int mQuiet
KMMsgDictREntry * mRDict
const KMSearchPattern * mSearchPattern
qint64 mSize
int mTotalMsgs
int mUnreadMsgs
bool mWriteConfigEnabled:1
bool needsCompact:1

Member Enumeration Documentation

anonymous enum [protected]

Enumerator:
mDirtyTimerInterval 

Definition at line 647 of file folderstorage.h.

enum FolderStorage::ChildrenState

Enumerator:
HasChildren 
HasNoChildren 
ChildrenUnknown 

Definition at line 126 of file folderstorage.h.


Constructor & Destructor Documentation

FolderStorage::FolderStorage ( 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 66 of file folderstorage.cpp.

FolderStorage::~FolderStorage (  )  [virtual]

Definition at line 96 of file folderstorage.cpp.


Member Function Documentation

KMAccount * FolderStorage::account (  )  const [virtual]

Reimplemented in KMFolderCachedImap, and KMFolderImap.

Definition at line 1191 of file folderstorage.cpp.

void FolderStorage::addJob ( FolderJob *   )  const

Add job for this folder.

This is done automatically by createJob. This method is public only for other kind of FolderJob like ExpireJob.

int FolderStorage::addMessages ( QList< KMMessage * > &  msgList,
QList< int > &  index_return 
) [virtual]

Adds the given messages to the folder.

Behaviour is identical to addMsg(msg)

Definition at line 1169 of file folderstorage.cpp.

virtual int FolderStorage::addMsg ( KMMessage *  msg,
int *  index_return = 0 
) [pure virtual]

Add the given message to the folder.

Usually the message is added at the end of the folder. Returns zero on success and an errno error code on failure. The index of the new message is stored in index_return if given. Please note that the message is added as is to the folder and the folder takes ownership of the message (deleting it in the destructor).

Implemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

virtual int FolderStorage::addMsgKeepUID ( KMMessage *  msg,
int *  index_return = 0 
) [inline, virtual]

(Note(bo): This needs to be fixed better at a later point.

) This is overridden by dIMAP because addMsg strips the X-UID header from the mail.

Reimplemented in KMFolderCachedImap.

Definition at line 208 of file folderstorage.h.

int FolderStorage::appendToFolderIdsFile ( int  idx = -1  )  [protected]

Append message to end of message serial number file.

Definition at line 1021 of file folderstorage.cpp.

bool FolderStorage::autoCreateIndex (  )  const [inline]

Returns true if a table of contents file is automatically created.

Definition at line 326 of file folderstorage.h.

virtual bool FolderStorage::canAccess (  )  const [pure virtual]

Check folder for permissions.

Returns:
true if readable and writable.

Implemented in KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

bool FolderStorage::canAddMsgNow ( KMMessage *  aMsg,
int *  aIndex_ret 
) [virtual]

Returns false, if the message has to be retrieved from an IMAP account first.

In this case this function does this and cares for the rest

Definition at line 294 of file folderstorage.cpp.

void FolderStorage::changed (  )  [signal]

Emitted when the status, name, or associated accounts of this folder changed.

void FolderStorage::cleared (  )  [signal]

Emitted when the contents of a folder have been cleared (new search in a search folder, for example).

virtual void FolderStorage::clearIndex ( bool  autoDelete = true,
bool  syncDict = false 
) [protected, pure virtual]

Implemented in KMFolderIndex, and KMFolderSearch.

virtual void FolderStorage::close ( const char *  owner,
bool  force = false 
) [pure virtual]

Close folder.

If force is true the files are closed even if If force is TRUE the files are closed regardless of reference count, and the reference count will be set to zero. owner is for debugging.

Implemented in KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

void FolderStorage::closed ( KMFolder *   )  [signal]

Emitted when the folder was closed and ticket owners have to reopen.

virtual int FolderStorage::compact ( bool  silent  )  [pure virtual]

Remove deleted messages from the folder.

Returns zero on success and an errno on failure. A statusbar message will inform the user that the compaction worked, unless silent is set.

Implemented in KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

bool FolderStorage::compactable (  )  const [inline]

false if index file is out of sync with mbox file

Definition at line 405 of file folderstorage.h.

KMail::FolderContentsType FolderStorage::contentsType (  )  const [inline]

Returns:
the type of contents held in this folder (mail, calendar, etc.)

Definition at line 414 of file folderstorage.h.

void FolderStorage::contentsTypeChanged ( KMail::FolderContentsType  type  )  [signal]

Emitted when the contents type (calendar, mail, tasks, .

.) of the folderstorage changes.

void FolderStorage::correctUnreadMsgsCount (  )  [virtual]

A cludge to help make sure the count of unread messges is kept in sync.

Definition at line 965 of file folderstorage.cpp.

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

Number of messages in this folder.

Reimplemented in KMFolderIndex, and KMFolderSearch.

Definition at line 827 of file folderstorage.cpp.

int FolderStorage::countUnread (  )  [virtual]

Number of new or unread messages in this folder.

Definition at line 836 of file folderstorage.cpp.

virtual int FolderStorage::create (  )  [pure virtual]

Create a new folder with the name of this object and open it.

Returns zero on success and an error code equal to the c-library fopen call otherwise.

Implemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

FolderJob * FolderStorage::createJob ( QList< KMMessage * > &  msgList,
const QString &  sets,
FolderJob::JobType  jt = FolderJob::tGetMessage,
KMFolder *  folder = 0 
) const [virtual]

Definition at line 590 of file folderstorage.cpp.

virtual FolderJob* FolderStorage::createJob ( KMMessage *  msg,
FolderJob::JobType  jt = FolderJob::tGetMessage,
KMFolder *  folder = 0,
const QString &  partSpecifier = QString(),
const AttachmentStrategy *  as = 0 
) const [virtual]

These methods create respective FolderJob (You should derive FolderJob for each derived KMFolder).

void FolderStorage::deregisterFromMessageDict (  ) 

Triggers deregistration from the message dict, which will cause the dict to ask the FolderStorage to write the relevant data structures to disk.

Definition at line 978 of file folderstorage.cpp.

bool FolderStorage::dirty (  )  const [inline]

Returns true if the table of contents is dirty.

This happens when a message is deleted from the folder. The toc will then be re-created when the folder is closed.

Definition at line 335 of file folderstorage.h.

virtual FolderJob* FolderStorage::doCreateJob ( QList< KMMessage * > &  msgList,
const QString &  sets,
FolderJob::JobType  jt,
KMFolder *  folder 
) const [protected, pure virtual]

Implemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

virtual FolderJob* FolderStorage::doCreateJob ( KMMessage *  msg,
FolderJob::JobType  jt,
KMFolder *  folder,
const QString &  partSpecifier,
const AttachmentStrategy *  as 
) const [protected, pure virtual]

These two methods actually create the jobs.

They have to be implemented in all folders.

See also:
createJob

Implemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

virtual qint64 FolderStorage::doFolderSize (  )  const [inline, protected, virtual]

Reimplemented in KMFolderMaildir, and KMFolderMbox.

Definition at line 609 of file folderstorage.h.

QString FolderStorage::dotEscape ( const QString &  aStr  )  [static]

Escape a leading dot.

Definition at line 106 of file folderstorage.cpp.

void FolderStorage::emitMsgAddedSignals ( int  idx  ) 

Called by derived classes implementation of addMsg.

Emits msgAdded signals

Restart always the timer or not. BTW we get a kmheaders refresh each 3 seg.?

Definition at line 277 of file folderstorage.cpp.

int FolderStorage::expunge (  )  [virtual]

Delete entire folder.

Forces a close *but* opens the folder again afterwards. Returns errno(3) error code or zero on success. see KMFolder::expungeContents

Definition at line 783 of file folderstorage.cpp.

virtual int FolderStorage::expungeContents (  )  [protected, pure virtual]

Called by KMFolder::expunge() to delete the actual contents.

At the time of the call the folder has already been closed, and the various index files deleted. Returns 0 on success.

Implemented in KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

void FolderStorage::expunged ( KMFolder *   )  [signal]

Emitted after an expunge.

If not quiet, changed() will be emmitted first.

int FolderStorage::expungeOldMsg ( int  days  )  [virtual]

Delete messages in the folder that are older than days.

Return the number of deleted messages.

Definition at line 247 of file folderstorage.cpp.

QString FolderStorage::fileName (  )  const [virtual]

Returns the filename of the folder (reimplemented in KMFolderImap).

Reimplemented in KMFolderImap.

Definition at line 136 of file folderstorage.cpp.

virtual void FolderStorage::fillMessageDict (  )  [inline, protected, virtual]

Inserts messages into the message dictionary.

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 in KMFolderIndex.

Definition at line 558 of file folderstorage.h.

int FolderStorage::find ( const KMMessage *  msg  )  const

Reimplemented in KMFolderIndex.

Definition at line 346 of file folderstorage.cpp.

virtual int FolderStorage::find ( const KMMsgBase *  msg  )  const [pure virtual]

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

Implemented in KMFolderIndex, and KMFolderSearch.

KMFolder* FolderStorage::folder ( void   )  const [inline]

Definition at line 94 of file folderstorage.h.

qint64 FolderStorage::folderSize (  )  const

Total size of the contents of this folder.

Definition at line 857 of file folderstorage.cpp.

void FolderStorage::folderSizeChanged (  )  [signal]

Emitted when the folder's size changes.

virtual KMFolderType FolderStorage::folderType (  )  const [inline, virtual]

Returns the type of this folder.

Reimplemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

Definition at line 97 of file folderstorage.h.

virtual DwString FolderStorage::getDwString ( int  idx  )  [pure virtual]

Read a message and returns a DwString.

Implemented in KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

KMMessage * FolderStorage::getMsg ( int  idx  )  [virtual]

Read message at given index.

Indexing starts at zero

Reimplemented in KMFolderImap, and KMFolderSearch.

Definition at line 473 of file folderstorage.cpp.

virtual KMMsgBase* FolderStorage::getMsgBase ( int  idx  )  [pure virtual]

Implemented in KMFolderIndex, and KMFolderSearch.

virtual const KMMsgBase* FolderStorage::getMsgBase ( int  idx  )  const [pure 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.

Implemented in KMFolderIndex, and KMFolderSearch.

virtual ChildrenState FolderStorage::hasChildren (  )  const [inline, virtual]

Returns if the folder has children, has no children or we don't know.

Definition at line 133 of file folderstorage.h.

void FolderStorage::headerOfMsgChanged ( const KMMsgBase *  aMsg,
int  idx 
) [protected]

Tell the folder that a header field that is usually used for the index (subject, from, .

..) has changed of given message. This method is usually called from within KMMessage::setSubject/set...

Definition at line 906 of file folderstorage.cpp.

QString FolderStorage::idsLocation (  )  const [virtual]

Returns full path to 'ids' file.

Definition at line 1219 of file folderstorage.cpp.

void FolderStorage::ignoreJobsForMessage ( KMMessage *  msg  )  [virtual]

Removes and deletes all jobs associated with the particular message.

Reimplemented in KMFolderImap, and KMFolderSearch.

Definition at line 1072 of file folderstorage.cpp.

QString FolderStorage::indexLocation (  )  const [virtual]

Returns full path to index file.

Reimplemented in KMFolderSearch.

Definition at line 1210 of file folderstorage.cpp.

void FolderStorage::invalidated ( KMFolder *   )  [signal]

Emitted when the serial numbers of this folder were invalidated.

void FolderStorage::invalidateFolder (  )  [protected]

Called when serial numbers for a folder are invalidated, invalidates/recreates data structures dependent on the serial numbers for this folder.

Definition at line 995 of file folderstorage.cpp.

bool FolderStorage::isCloseToQuota (  )  const [virtual]

Return whether the folder is close to its quota limit, which can be reflected in the UI.

Reimplemented in KMFolderCachedImap.

Definition at line 868 of file folderstorage.cpp.

bool FolderStorage::isMessage ( int  idx  )  [virtual]

Checks if the message is already "gotten" with getMsg.

Definition at line 570 of file folderstorage.cpp.

bool FolderStorage::isMoveable (  )  const [virtual]

Returns true if this folder can be moved.

Reimplemented in KMFolderCachedImap, KMFolderImap, and KMFolderSearch.

Definition at line 1185 of file folderstorage.cpp.

bool FolderStorage::isOpened (  )  const [inline]

Test if folder is opened, i.e.

its reference count is greater than zero.

Definition at line 291 of file folderstorage.h.

virtual bool FolderStorage::isReadOnly (  )  const [pure virtual]

Is the folder read-only?

Implemented in KMFolderCachedImap, KMFolderImap, KMFolderMaildir, KMFolderMbox, and KMFolderSearch.

QString FolderStorage::label (  )  const

Returns the label of the folder for visualization.

Definition at line 822 of file folderstorage.cpp.

QString FolderStorage::location ( const QString &  suffix  )  const [protected, virtual]

Returns full path to .index, .index.ids or .index.sorted file (depending on suffix).

The former path (in case of mmap-based implementation) is returned when suffix is empty.

Definition at line 1196 of file folderstorage.cpp.

QString FolderStorage::location (  )  const

Returns full path to folder file.

Definition at line 126 of file folderstorage.cpp.

void FolderStorage::locationChanged ( const QString &  ,