24 #ifndef kmfolderimap_h
25 #define kmfolderimap_h
28 #include "kmacctimap.h"
29 #include "kmfoldermbox.h"
30 #include "kmmsgbase.h"
32 #include "tdeio/job.h"
33 #include "tdeio/global.h"
35 #include <kstandarddirs.h>
37 #include <tqintdict.h>
39 template<
typename T>
class TQPtrList;
40 template<
typename T>
class TQValueList;
42 class KMFolderTreeItem;
49 class AttachmentStrategy;
50 class ImapAccountBase;
55 using KMail::FolderJob;
57 using KMail::AttachmentStrategy;
58 using KMail::ImapAccountBase;
59 using KPIM::ProgressItem;
64 KMMsgMetaData(KMMsgStatus aStatus)
65 :mStatus(aStatus), mSerNum(0) {}
66 KMMsgMetaData(KMMsgStatus aStatus, TQ_UINT32 aSerNum)
67 :mStatus(aStatus), mSerNum(aSerNum) {}
69 KMMsgStatus status()
const {
return mStatus; }
70 TQ_UINT32 serNum()
const {
return mSerNum; }
78 class KMFolderImap :
public KMFolderMbox
82 friend class ::KMail::ImapJob;
85 static TQString cacheLocation() {
86 return locateLocal(
"data",
"kmail/imap" );
90 imapNoInformation = 0,
91 imapListingInProgress = 1,
92 imapDownloadInProgress = 2,
96 virtual imapState getContentState()
const {
return mContentState; }
97 virtual void setContentState(imapState state) { mContentState = state; }
99 virtual imapState getSubfolderState() {
return mSubfolderState; }
100 virtual void setSubfolderState(imapState state);
105 KMFolderImap(
KMFolder* folder,
const char* name=0);
106 virtual ~KMFolderImap();
109 virtual KMFolderType folderType()
const {
return KMFolderTypeImap; }
113 void setImapPath(
const TQString &path );
114 TQString imapPath()
const {
return mImapPath; }
120 void setUidValidity(
const TQString &validity) { mUidValidity = validity; }
121 TQString uidValidity() {
return mUidValidity; }
124 void setAccount(KMAcctImap *acct);
125 KMAcctImap* account()
const;
128 virtual void removeMsg(
int i,
bool quiet = FALSE);
129 virtual void removeMsg(
const TQPtrList<KMMessage>& msgList,
bool quiet = FALSE);
131 virtual int rename(
const TQString& newName,
KMFolderDir *aParent = 0 );
134 virtual void remove();
140 virtual void writeConfig();
143 virtual void readConfig();
150 virtual bool listDirectory();
155 void getFolder(
bool force = FALSE);
160 void getAndCheckFolder(
bool force = FALSE);
174 void createFolder(
const TQString &name,
175 const TQString& imapPath = TQString(),
bool askUser =
true);
181 void deleteMessage(
const TQPtrList<KMMessage>& msgList);
187 virtual void setStatus(
int idx, KMMsgStatus status,
bool toggle);
192 virtual void setStatus(TQValueList<int>& _ids, KMMsgStatus status,
bool toggle);
195 static TQStringList makeSets( TQValueList<ulong>&,
bool sort =
true);
196 static TQStringList makeSets(
const TQStringList&,
bool sort =
true);
199 static TQPtrList<KMMessage> splitMessageList(
const TQString& set,
200 TQPtrList<KMMessage>& msgList);
203 void getUids(TQValueList<int>& ids, TQValueList<ulong>& uids);
206 void getUids(
const TQPtrList<KMMessage>& msgList, TQValueList<ulong>& uids);
211 void expungeFolder(KMFolderImap * aFolder,
bool quiet);
213 virtual int compact(
bool ) { expungeFolder(
this,
false);
return 0; };
218 void sendFolderComplete(
bool success)
219 { emit folderComplete(
this, success); }
225 bool processNewMail(
bool interactive);
231 void setSelected(
bool selected) { mIsSelected = selected; }
232 bool isSelected() {
return mIsSelected; }
237 static TQString encodeFileName(
const TQString &);
238 static TQString decodeFileName(
const TQString &);
239 static TQTextCodec * utf7Codec();
244 static TQString statusToFlags(KMMsgStatus status,
int supportedFalgs);
249 virtual TQString fileName()
const {
250 return encodeFileName( KMFolderMbox::fileName() ); }
255 ulong serNumForUID( ulong uid );
261 void saveMsgMetaData(
KMMessage* msg, ulong uid = 0 );
266 static TQValueList<ulong> splitSets(
const TQString);
268 virtual void ignoreJobsForMessage(
KMMessage* );
273 bool includeInMailCheck() {
return mCheckMail; }
274 void setIncludeInMailCheck(
bool check );
277 virtual int create();
280 virtual bool isAutoExpire()
const {
return false; }
283 virtual void reallyDoClose(
const char* owner);
285 void setCheckingValidity(
bool val ) { mCheckingValidity = val; }
295 void setAlreadyRemoved(
bool removed);
298 bool isReadOnly()
const {
return KMFolderMbox::isReadOnly() || mReadOnly; }
299 bool canDeleteMessages()
const;
306 unsigned int userRights()
const {
return mUserRights; }
321 virtual bool isMoveable()
const;
324 void initializeFrom( KMFolderImap* parent, TQString path, TQString mimeType );
327 int permanentFlags()
const {
return mPermanentFlags; }
329 virtual bool mailCheckInProgress()
const;
332 void folderComplete(KMFolderImap *folder,
bool success);
337 void deleted(KMFolderImap*);
342 void directoryListingFinished(KMFolderImap*);
349 void folderCreationResult(
const TQString &name,
bool success );
354 virtual void addMsgQuiet(TQPtrList<KMMessage>);
362 virtual int addMsg(
KMMessage* msg,
int* index_return = 0);
363 virtual int addMsg(TQPtrList<KMMessage>&, TQValueList<int>& index_return);
366 void copyMsg(TQPtrList<KMMessage>& msgList);
372 virtual void take(TQPtrList<KMMessage>);
377 void slotSimpleData(TDEIO::Job * job,
const TQByteArray & data);
383 static void flagsToStatus(KMMsgBase *msg,
int flags,
bool newMsg = TRUE,
int supportedFalgs = 31 );
389 static void seenFlagToStatus( KMMsgBase *msg,
int flags,
bool newMsg =
true );
394 void slotCopyMsgResult( KMail::FolderJob* job );
399 void slotSearchDone( TQValueList<TQ_UINT32> serNums,
406 void slotSearchDone( TQ_UINT32 serNum,
const KMSearchPattern* pattern,
bool matches );
412 void slotListResult(
const TQStringList&,
const TQStringList&,
413 const TQStringList&,
const TQStringList&,
const ImapAccountBase::jobData& );
419 void slotCheckNamespace(
const TQStringList&,
const TQStringList&,
420 const TQStringList&,
const TQStringList&,
const ImapAccountBase::jobData& );
423 virtual FolderJob* doCreateJob(
KMMessage *msg, FolderJob::JobType jt,
424 KMFolder *folder, TQString partSpecifier,
425 const AttachmentStrategy *as )
const;
426 virtual FolderJob* doCreateJob( TQPtrList<KMMessage>& msgList,
const TQString& sets,
427 FolderJob::JobType jt,
KMFolder *folder )
const;
429 void getMessagesResult(TDEIO::Job * job,
bool lastSet);
434 virtual int expungeContents();
436 void setChildrenState( TQString attributes );
442 KMFolderImap* findParent(
const TQString& path,
const TQString& name );
445 void checkFolders(
const TQStringList& folderNames,
const TQString& ns );
447 void finishMailCheck(
const char *func, imapState state );
454 void checkValidity();
455 void slotCheckValidityResult(TDEIO::Job * job);
460 void reallyGetFolder(
const TQString &startUid = TQString());
465 void slotListFolderResult(TDEIO::Job * job);
466 void slotListFolderEntries(TDEIO::Job * job,
const TDEIO::UDSEntryList & uds);
471 void slotGetMessagesResult(TDEIO::Job * job);
472 void slotGetLastMessagesResult(TDEIO::Job * job);
473 void slotGetMessagesData(TDEIO::Job * job,
const TQByteArray & data);
478 void slotCreateFolderResult(TDEIO::Job * job);
483 void slotRemoveFolderResult(TDEIO::Job *job);
488 void slotStatResult(TDEIO::Job *job);
494 void slotCompleteMailCheckProgress();
499 void slotProcessNewMail(
int errorCode,
const TQString& errorMsg );
506 void slotCreatePendingFolders(
int errorCode,
const TQString& errorMsg );
511 void slotListNamespaces();
516 imapState mContentState, mSubfolderState;
521 mutable TQGuardedPtr<KMAcctImap> mAccount;
523 TQString mUidValidity;
524 unsigned int mUserRights;
529 bool mCheckingValidity;
531 TQIntDict<KMMsgMetaData> mUidMetaDataMap;
533 TQDict<KMMsgMetaData> mMetaDataMap;
535 bool mAlreadyRemoved;
537 TQGuardedPtr<ProgressItem> mMailCheckProgressItem;
539 ProgressItem *mListDirProgressItem;
541 ProgressItem *mAddMessageProgressItem;
543 TQStringList mFoldersPendingCreation;
549 bool mUploadAllFlags;
KMail list that manages the contents of one directory that may contain folders and/or other directori...
This class is an abstraction of a search over messages.