kmail

kmfoldermaildir.h

Go to the documentation of this file.
00001 #ifndef kmfoldermaildir_h
00002 #define kmfoldermaildir_h
00003 
00004 #include "kmfolderindex.h"
00005 
00006 #include <kfileitem.h>
00007 
00008 #include <qguardedptr.h>
00009 
00010 class KMFolderMaildir;
00011 namespace KMail {
00012   class FolderJob;
00013   class MaildirJob;
00014   class AttachmentStrategy;
00015 }
00016 namespace KIO {
00017     class Job;
00018 }
00019 
00020 using KMail::FolderJob;
00021 using KMail::MaildirJob;
00022 using KMail::AttachmentStrategy;
00023 
00024 class KMFolderMaildir : public KMFolderIndex
00025 {
00026   Q_OBJECT
00027   friend class ::KMail::MaildirJob;
00028 public:
00032   KMFolderMaildir(KMFolder* folder, const char* name=0);
00033   virtual ~KMFolderMaildir();
00034 
00036   virtual KMFolderType folderType() const { return KMFolderTypeMaildir; }
00037 
00039   virtual DwString getDwString(int idx);
00040 
00043   virtual KMMessage* take(int idx);
00044 
00051   virtual int addMsg(KMMessage* msg, int* index_return = 0);
00052 
00054   virtual void removeMsg(int i, bool imapQuiet = FALSE);
00055   virtual void removeMsg(QPtrList<KMMessage> msgList, bool imapQuiet = FALSE)
00056   { return KMFolderIndex::removeMsg(msgList, imapQuiet); }
00057 
00058   // Called by KMMsgBase::setStatus when status of a message has changed
00059   // required to keep the number unread messages variable current.
00060   virtual void msgStatusChanged( const KMMsgStatus oldStatus,
00061                                  const KMMsgStatus newStatus,
00062                  int idx);
00063 
00069   virtual int open(const char *owner);
00070 
00071   virtual int canAccess();
00072 
00074   virtual void sync();
00075 
00078   virtual void reallyDoClose(const char *owner);
00079 
00086   static int createMaildirFolders( const QString & folderPath );
00087 
00088   static QString constructValidFileName( const QString & filename = QString(),
00089                                          KMMsgStatus status = KMMsgStatusNew );
00090 
00091   static bool removeFile( const QString & folderPath,
00092                           const QString & filename );
00093 
00095   virtual int create();
00096 
00099   int compact( unsigned int startIndex, int nbMessages, const QStringList& entryList, bool& done );
00100 
00103   virtual int compact( bool silent );
00104 
00106   virtual bool isReadOnly() const { return false; }
00107  
00109   virtual Q_INT64 doFolderSize() const;
00110 
00111 protected:
00112   virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder,
00113                                   QString partSpecifier, const AttachmentStrategy *as ) const;
00114   virtual FolderJob* doCreateJob( QPtrList<KMMessage>& msgList, const QString& sets,
00115                                   FolderJob::JobType jt, KMFolder *folder ) const;
00118   virtual KMMessage* readMsg(int idx);
00119 
00123   virtual int removeContents();
00124 
00128   virtual int expungeContents();
00129 
00133   virtual int createIndexFromContents();
00134 
00144   int addMsgInternal( KMMessage* msg, int* index_return = 0, bool stripUid=false );
00145 
00146 private slots:
00147   void slotDirSizeJobResult( KIO::Job* job );
00148 
00149 private:
00150   void readFileHeaderIntern(const QString& dir, const QString& file, KMMsgStatus status);
00151   QString moveInternal(const QString& oldLoc, const QString& newLoc, KMMsgInfo* mi);
00152   QString moveInternal(const QString& oldLoc, const QString& newLoc, QString& aFileName, KMMsgStatus status);
00153   bool removeFile(const QString& filename);
00154 
00160   virtual IndexStatus indexStatus();
00161 
00162   typedef QPair<QGuardedPtr<const KMFolderMaildir>,KFileItemList> DirSizeJobQueueEntry;
00163   static QValueList<DirSizeJobQueueEntry> s_DirSizeJobQueue;
00164 
00165   QStrList mIdxToFileList;
00166   int mIdxCount;
00167   mutable bool mCurrentlyCheckingFolderSize;
00168 };
00169 #endif /*kmfoldermaildir_h*/