35 #ifndef FOLDERSTORAGE_H 36 #define FOLDERSTORAGE_H 41 #include "kmfoldernode.h" 42 #include "kmfoldertype.h" 43 #include "kmmsginfo.h" 45 #include "folderjob.h" 46 using KMail::FolderJob;
48 #include "mimelib/string.h" 50 #include <sys/types.h> 57 class KMMsgDictREntry;
62 class AttachmentStrategy;
64 using KMail::AttachmentStrategy;
66 typedef TQValueList<TQ_UINT32> SerNumList;
93 KMFolder* folder()
const {
return mFolder; }
96 virtual KMFolderType
folderType()
const {
return KMFolderTypeUnknown; }
99 virtual TQString fileName()
const;
101 TQString location()
const;
104 virtual TQString indexLocation()
const = 0;
110 virtual void setNoContent(
bool aNoContent);
116 virtual void setNoChildren(
bool aNoChildren );
125 virtual ChildrenState
hasChildren()
const {
return mHasChildren; }
129 { mHasChildren = state; }
132 virtual void updateChildrenState();
138 virtual KMMsgInfo* unGetMsg(
int idx);
141 virtual bool isMessage(
int idx);
147 virtual KMMessage* readTemporaryMsg(
int idx);
150 virtual DwString getDwString(
int idx) = 0;
155 virtual void ignoreJobsForMessage(
KMMessage* );
161 virtual FolderJob* createJob(
KMMessage *msg, FolderJob::JobType jt = FolderJob::tGetMessage,
162 KMFolder *folder = 0, TQString partSpecifier = TQString(),
163 const AttachmentStrategy *as = 0 )
const;
164 virtual FolderJob* createJob( TQPtrList<KMMessage>& msgList,
const TQString& sets,
165 FolderJob::JobType jt = FolderJob::tGetMessage,
172 virtual const KMMsgBase* getMsgBase(
int idx)
const = 0;
173 virtual KMMsgBase* getMsgBase(
int idx) = 0;
176 virtual const KMMsgBase*
operator[](
int idx)
const {
return getMsgBase(idx); }
179 virtual KMMsgBase*
operator[](
int idx) {
return getMsgBase(idx); }
184 virtual void take(TQPtrList<KMMessage> msgList);
192 virtual int addMsg(
KMMessage* msg,
int* index_return = 0) = 0;
198 return addMsg(msg, index_return);
205 virtual int addMsg( TQPtrList<KMMessage>&, TQValueList<int>& index_return );
209 void emitMsgAddedSignals(
int idx);
213 virtual bool canAddMsgNow(
KMMessage* aMsg,
int* aIndex_ret);
216 virtual void removeMsg(
int i,
bool imapQuiet =
false);
217 virtual void removeMsg(
const TQPtrList<KMMsgBase>& msgList,
bool imapQuiet =
false);
218 virtual void removeMsg(
const TQPtrList<KMMessage>& msgList,
bool imapQuiet =
false);
222 virtual int expungeOldMsg(
int days);
228 virtual int moveMsg(
KMMessage* msg,
int* index_return = 0);
229 virtual int moveMsg(TQPtrList<KMMessage>,
int* index_return = 0);
232 virtual int find(
const KMMsgBase* msg)
const = 0;
236 virtual int count(
bool cache =
false)
const;
239 virtual int countUnread();
242 TQ_INT64 folderSize()
const;
246 virtual bool isCloseToQuota()
const;
250 virtual void msgStatusChanged(
const KMMsgStatus oldStatus,
251 const KMMsgStatus newStatus,
259 virtual int open(
const char* owner) = 0;
263 virtual int canAccess() = 0;
268 void close(
const char* owner,
bool force=
false);
269 virtual void reallyDoClose(
const char* owner) = 0;
276 virtual void sync() = 0;
282 virtual void markNewAsUnread();
285 virtual void markUnreadAsRead();
290 virtual int create() = 0;
296 virtual void remove();
301 virtual int expunge();
307 virtual int compact(
bool silent ) = 0;
311 virtual int rename(
const TQString& newName,
KMFolderDir *aParent = 0);
318 virtual void setAutoCreateIndex(
bool);
323 bool dirty()
const {
return mDirty; }
326 void setDirty(
bool f);
330 virtual void setNeedsCompacting(
bool f) { needsCompact = f; }
340 virtual void quiet(
bool beQuiet);
343 virtual bool isReadOnly()
const = 0;
346 virtual bool canDeleteMessages()
const;
349 TQString label()
const;
352 virtual void correctUnreadMsgsCount();
356 virtual int writeIndex(
bool createEmptyIndex =
false ) = 0;
360 void registerWithMessageDict();
364 void deregisterFromMessageDict();
367 virtual void setStatus(
int idx, KMMsgStatus status,
bool toggle=
false);
370 virtual void setStatus(TQValueList<int>& ids, KMMsgStatus status,
bool toggle=
false);
375 static TQString dotEscape(
const TQString&);
378 virtual void readConfig();
381 virtual void writeConfig();
393 void addJob( FolderJob* )
const;
402 virtual void setContentsType( KMail::FolderContentsType type,
bool quiet =
false );
404 KMail::FolderContentsType
contentsType()
const {
return mContentsType; }
419 virtual bool isMoveable()
const;
421 virtual KMAccount* account()
const;
423 virtual bool mailCheckInProgress()
const;
450 void locationChanged(
const TQString &,
const TQString & );
454 void contentsTypeChanged( KMail::FolderContentsType type );
460 void noContentChanged();
463 void msgRemoved(
KMFolder*, TQ_UINT32 sernum);
466 void msgRemoved(
int idx, TQString msgIdMD5 );
470 void msgAdded(
int idx);
471 void msgAdded(
KMFolder*, TQ_UINT32 sernum);
474 void msgChanged(
KMFolder*, TQ_UINT32 sernum,
int delta);
477 void msgHeaderChanged(
KMFolder*,
int);
480 void statusMsg(
const TQString&);
483 void numUnreadMsgsChanged(
KMFolder* );
493 void searchResult(
KMFolder*, TQValueList<TQ_UINT32>,
503 void folderSizeChanged();
509 void syncStateChanged();
513 virtual int updateIndex() = 0;
517 virtual void reallyAddMsg(
KMMessage* aMsg);
521 virtual void reallyAddCopyOfMsg(
KMMessage* aMsg);
524 void slotEmitChangedTimer();
527 virtual void removeJob( TQObject* );
530 void slotProcessNextSearchBatch();
539 virtual FolderJob* doCreateJob(
KMMessage *msg, FolderJob::JobType jt,
KMFolder *folder,
540 TQString partSpecifier,
const AttachmentStrategy *as )
const = 0;
541 virtual FolderJob* doCreateJob( TQPtrList<KMMessage>& msgList,
const TQString& sets,
542 FolderJob::JobType jt,
KMFolder *folder )
const = 0;
547 void headerOfMsgChanged(
const KMMsgBase*,
int idx);
563 void readFolderIdsFile();
566 int writeFolderIdsFile()
const;
569 int touchFolderIdsFile();
572 int appendToFolderIdsFile(
int idx = -1 );
577 void setRDict(KMMsgDictREntry *rentry)
const;
580 KMMsgDictREntry *
rDict()
const {
return mRDict; }
585 void replaceMsgSerNum(
unsigned long sernum, KMMsgBase* msg,
int idx );
590 void invalidateFolder();
595 virtual int removeContents() = 0;
600 virtual int expungeContents() = 0;
603 virtual bool readIndex() = 0;
604 virtual KMMsgBase* takeIndexEntry(
int idx ) = 0;
605 virtual KMMsgInfo* setIndexEntry(
int idx,
KMMessage *msg ) = 0;
606 virtual void clearIndex(
bool autoDelete=
true,
bool syncDict =
false) = 0;
607 virtual void truncateIndex() = 0;
609 virtual TQ_INT64 doFolderSize()
const {
return 0; };
628 bool mWriteConfigEnabled :1;
635 bool mConvertToUtf8 :1;
642 TQTimer *mDirtyTimer;
643 enum { mDirtyTimerInterval = 600000 };
645 ChildrenState mHasChildren;
652 TQTimer * mEmitChangedTimer;
654 int mCurrentSearchedMsg;
658 #endif // FOLDERSTORAGE_H This class is an abstraction of a search over messages.
bool dirty() const
Returns true if the table of contents is dirty.
KMail::FolderContentsType contentsType() const
bool needsCompact
sven: true if on destruct folder needs to be compacted.
virtual void tryReleasingFolder(KMFolder *)
Try releasing folder if possible, something is attempting an exclusive access to it.
KMMsgDictREntry * mRDict
Points at the reverse dictionary for this folder.
TQPtrList< FolderJob > mJobList
List of jobs created by this folder.
virtual KMMsgBase * operator[](int idx)
Same as getMsgBase(int).
virtual KMFolder * trashFolder() const
If this folder has a special trash folder set, return it.
virtual void setHasChildren(ChildrenState state)
Specify if the folder has children.
virtual KMFolderType folderType() const
Returns the type of this folder.
bool mDirty
if the index is dirty it will be recreated upon close()
bool needsCompacting() const
Returns true if the folder contains deleted messages.
virtual ChildrenState hasChildren() const
Returns if the folder has children, has no children or we don't know.
bool isOpened() const
Test if folder is opened, i.e.
bool mAutoCreateIndex
is the automatic creation of a index file allowed ?
virtual int addMsgKeepUID(KMMessage *msg, int *index_return=0)
(Note(bo): This needs to be fixed better at a later point.) This is overridden by dIMAP because addMs...
KMail list that manages the contents of one directory that may contain folders and/or other directori...
virtual bool noChildren() const
Returns, if the folder can't have children.
bool mFilesLocked
true if the files of the folder are locked (writable)
KMail::FolderContentsType mContentsType
Type of contents in this folder.
virtual bool noContent() const
Returns, if the folder can't contain mails, but only subfolder.
int mUnreadMsgs
number of unread messages, -1 if not yet set
The FolderStorage class is the bass class for the storage related aspects of a collection of mail (a ...
bool mCompactable
false if index file is out of sync with mbox file
virtual void fillMessageDict()
Inserts messages into the message dictionary.
bool compactable() const
false if index file is out of sync with mbox file
virtual const KMMsgBase * operator[](int idx) const
Same as getMsgBase(int).
KMMsgDictREntry * rDict() const
Returns the reverse-dictionary for this folder.
bool autoCreateIndex() const
Returns true if a table of contents file is automatically created.
KMail message dictionary.
bool mExportsSernums
Has this storage exported its serial numbers to the global message dict for lookup?