kmail

compactionjob.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 David Faure <faure@kde.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; version 2 of the License
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00016  *
00017  *  In addition, as a special exception, the copyright holders give
00018  *  permission to link the code of this program with any edition of
00019  *  the Qt library by Trolltech AS, Norway (or with modified versions
00020  *  of Qt that use the same license as Qt), and distribute linked
00021  *  combinations including the two.  You must obey the GNU General
00022  *  Public License in all respects for all of the code used other than
00023  *  Qt.  If you modify this file, you may extend this exception to
00024  *  your version of the file, but you are not obligated to do so.  If
00025  *  you do not wish to do so, delete this exception statement from
00026  *  your version.
00027  */
00028 #ifndef COMPACTIONJOB_H
00029 #define COMPACTIONJOB_H
00030 
00031 #include "jobscheduler.h"
00032 #include <qstringlist.h>
00033 
00034 namespace KMail {
00035 
00039 class MboxCompactionJob : public ScheduledJob
00040 {
00041   Q_OBJECT
00042 public:
00044   MboxCompactionJob( KMFolder* folder, bool immediate );
00045   virtual ~MboxCompactionJob();
00046 
00047   int executeNow( bool silent );
00048   virtual void execute() { executeNow( false ); }
00049   virtual void kill();
00050 
00051 private slots:
00052   void slotDoWork();
00053 
00054 private:
00055   // Real folder location, != location in case of symlinks
00056   QString realLocation() const;
00057   void done( int rc );
00058 
00059 private:
00060   QTimer mTimer;
00061   QString mTempName;
00062   FILE *mTmpFile;
00063   off_t mOffset;
00064   int mCurrentIndex;
00065   bool mFolderOpen;
00066   bool mSilent;
00067 };
00068 
00072 class MaildirCompactionJob : public ScheduledJob
00073 {
00074   Q_OBJECT
00075 public:
00077   MaildirCompactionJob( KMFolder* folder, bool immediate );
00078   virtual ~MaildirCompactionJob();
00079 
00080   int executeNow( bool silent );
00081   virtual void execute() { executeNow( false ); }
00082   virtual void kill();
00083 
00084 private slots:
00085   void slotDoWork();
00086 
00087 private:
00088   void done( int rc );
00089 
00090 private:
00091   QTimer mTimer;
00092   QStringList mEntryList;
00093   int mCurrentIndex;
00094   bool mFolderOpen;
00095   bool mSilent;
00096 };
00097 
00099 class ScheduledCompactionTask : public ScheduledTask
00100 {
00101 public:
00104   ScheduledCompactionTask( KMFolder* folder, bool immediate )
00105     : ScheduledTask( folder, immediate ) {}
00106   virtual ~ScheduledCompactionTask() {}
00107   virtual ScheduledJob* run();
00108   virtual int taskTypeId() const { return 2; }
00109 };
00110 
00111 } // namespace
00112 
00113 #endif /* COMPACTIONJOB_H */
00114