20 #ifndef kmfoldersearch_h
21 #define kmfoldersearch_h
23 #include <tqguardedptr.h>
24 #include <tqvaluelist.h>
25 #include <tqvaluevector.h>
26 #include <tqvaluestack.h>
29 #include "folderstorage.h"
40 typedef TQValueList<TQ_UINT32> SerNumList;
43 class KMFolderSearchJob;
44 class KMIndexSearchTarget;
48 class AttachmentStrategy;
50 using KMail::AttachmentStrategy;
52 class KMSearch:
public TQObject
58 KMSearch(TQObject * parent = 0,
const char * name = 0);
61 bool write(TQString location)
const;
62 bool read(TQString location);
63 bool recursive()
const {
return mRecursive; }
64 void setRecursive(
bool recursive) {
if (running()) stop(); mRecursive = recursive; }
65 KMFolder* root()
const {
return mRoot; }
66 void setRoot(
KMFolder *folder) {
if (running()) stop(); mRoot = folder; }
67 bool inScope(
KMFolder* folder)
const;
72 bool running()
const {
return mRunning; }
74 int foundCount()
const {
return mFoundCount; }
75 int searchCount()
const {
return mSearchCount; }
76 TQString currentFolder()
const {
return mLastFolder; }
82 void found(TQ_UINT32 serNum);
83 void finished(
bool success);
86 void slotProcessNextBatch();
87 void slotSearchFolderResult(
KMFolder*, TQValueList<TQ_UINT32>,
91 friend class ::KMIndexSearchTarget;
92 void setRunning(
bool b) { mRunning = b; }
93 void setFoundCount(
int f) { mFoundCount = f; }
94 void setCurrentFolder(
const TQString &f) { mLastFolder = f; }
97 int mRemainingFolders;
98 bool mRecursive, mRunning, mIdle, mRunByIndex;
99 TQGuardedPtr<KMFolder> mRoot;
101 TQValueList<TQGuardedPtr<KMFolder> > mFolders, mOpenedFolders;
102 TQValueList<TQGuardedPtr<KMFolderImap> > mIncompleteFolders;
104 TQString mLastFolder;
107 TQTimer *mProcessNextBatchTimer;
114 friend class ::KMFolderSearchJob;
116 KMFolderSearch(
KMFolder* folder,
const char* name=0);
117 virtual ~KMFolderSearch();
120 virtual KMFolderType
folderType()
const {
return KMFolderTypeSearch; }
123 void setSearch(KMSearch *search);
125 const KMSearch*
search()
const;
127 void stopSearch() {
if (mSearch) mSearch->stop(); }
135 virtual bool isMoveable()
const {
return false; }
141 void executeSearch();
143 void searchFinished(
bool success);
145 void examineAddedMessage(
KMFolder *folder, TQ_UINT32 serNum);
147 void examineRemovedMessage(
KMFolder *folder, TQ_UINT32 serNum);
149 void examineChangedMessage(
KMFolder *folder, TQ_UINT32 serNum,
int delta);
151 void examineInvalidatedFolder(
KMFolder *folder);
153 void examineRemovedFolder(
KMFolder *folder);
155 void propagateHeaderChanged(
KMFolder *folder,
int idx);
160 void addSerNum(TQ_UINT32 serNum);
163 void removeSerNum(TQ_UINT32 serNum);
169 void slotSearchExamineMsgDone(
KMFolder*, TQ_UINT32 serNum,
175 virtual int open(
const char *owner);
178 virtual void reallyDoClose(
const char* owner);
182 virtual const KMMsgBase*
getMsgBase(
int idx)
const;
184 virtual int find(
const KMMsgBase* msg)
const;
186 virtual int writeIndex(
bool createEmptyIndex =
false );
188 TQ_UINT32 serNum(
int idx) {
return mSerNums[idx]; }
192 KMFolder *folder, TQString partSpecifier,
193 const AttachmentStrategy *as )
const;
194 virtual FolderJob*
doCreateJob(TQPtrList<KMMessage>& msgList,
const TQString& sets,
195 FolderJob::JobType jt,
KMFolder *folder)
const;
200 virtual int count(
bool cache =
false)
const;
201 virtual KMMsgBase* takeIndexEntry(
int idx);
202 virtual KMMsgInfo* setIndexEntry(
int idx,
KMMessage *msg);
203 virtual void clearIndex(
bool autoDelete=
true,
bool syncDict =
false);
204 virtual void truncateIndex();
207 TQValueVector<TQ_UINT32> mSerNums;
208 TQValueList<TQGuardedPtr<KMFolder> > mFolders;
209 TQValueStack<TQ_UINT32> mUnexaminedMessages;
212 bool mInvalid, mUnlinked;
214 TQTimer *mExecuteSearchTimer;
215 TQMap<const KMFolder*, unsigned int>mFoldersCurrentlyBeingSearched;
The FolderStorage class is the bass class for the storage related aspects of a collection of mail (a ...
virtual FolderJob * doCreateJob(KMMessage *msg, FolderJob::JobType jt, KMFolder *folder, TQString partSpecifier, const AttachmentStrategy *as) const =0
These two methods actually create the jobs.
virtual int create()=0
Create a new folder with the name of this object and open it.
virtual void ignoreJobsForMessage(KMMessage *)
Removes and deletes all jobs associated with the particular message.
virtual DwString getDwString(int idx)=0
Read a message and returns a DwString.
virtual int open(const char *owner)=0
Open folder for access.
virtual TQString indexLocation() const =0
Returns full path to index file.
virtual int count(bool cache=false) const
Number of messages in this folder.
virtual bool isMoveable() const
Returns true if this folder can be moved.
virtual int updateIndex()=0
Incrementally update the index if possible else call writeIndex.
virtual bool readIndex()=0
Read index file and fill the message-info list mMsgList.
virtual int find(const KMMsgBase *msg) const =0
Returns the index of the given message or -1 if not found.
virtual KMMessage * readMsg(int idx)=0
Load message from file and store it at given index.
virtual KMFolderType folderType() const
Returns the type of this folder.
virtual int expungeContents()=0
Called by KMFolder::expunge() to delete the actual contents.
virtual void tryReleasingFolder(KMFolder *)
Try releasing folder if possible, something is attempting an exclusive access to it.
virtual void search(const KMSearchPattern *)
Search for messages The end is signaled with searchDone()
virtual int removeContents()=0
Called by KMFolder::remove() to delete the actual contents.
virtual void sync()=0
fsync buffers to disk
virtual int addMsg(KMMessage *msg, int *index_return=0)=0
Add the given message to the folder.
virtual int canAccess()=0
Check folder for permissions Returns zero if readable and writable.
virtual bool isReadOnly() const =0
Is the folder read-only?
virtual KMMessage * getMsg(int idx)
Read message at given index.
virtual const KMMsgBase * getMsgBase(int idx) const =0
Provides access to the basic message fields that are also stored in the index.
virtual int writeIndex(bool createEmptyIndex=false)=0
Write index to index-file.
virtual int compact(bool silent)=0
Remove deleted messages from the folder.
This class is an abstraction of a search over messages.