backupjob.h
00001 /* Copyright 2009 Klarälvdalens Datakonsult AB 00002 00003 This program is free software; you can redistribute it and/or 00004 modify it under the terms of the GNU General Public License as 00005 published by the Free Software Foundation; either version 2 of 00006 the License or (at your option) version 3 or any later version 00007 accepted by the membership of KDE e.V. (or its successor approved 00008 by the membership of KDE e.V.), which shall act as a proxy 00009 defined in Section 14 of version 3 of the license. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 #ifndef BACKUPJOB_H 00020 #define BACKUPJOB_H 00021 00022 #include <kurl.h> 00023 #include <tqptrlist.h> 00024 00025 #include <tqobject.h> 00026 00027 class KMFolder; 00028 class KMMessage; 00029 class KArchive; 00030 class KProcess; 00031 class TQWidget; 00032 00033 namespace KPIM { 00034 class ProgressItem; 00035 } 00036 00037 namespace KMail 00038 { 00039 class FolderJob; 00040 00048 class BackupJob : public TQObject 00049 { 00050 Q_OBJECT 00051 TQ_OBJECT 00052 00053 public: 00054 00055 // These enum values have to stay in sync with the format combobox of ArchiveFolderDialog! 00056 enum ArchiveType { Zip = 0, Tar = 1, TarBz2 = 2, TarGz = 3 }; 00057 00058 explicit BackupJob( TQWidget *parent = 0 ); 00059 ~BackupJob(); 00060 void setRootFolder( KMFolder *rootFolder ); 00061 void setSaveLocation( const KURL &savePath ); 00062 void setArchiveType( ArchiveType type ); 00063 void setDeleteFoldersAfterCompletion( bool deleteThem ); 00064 void start(); 00065 00066 private slots: 00067 00068 void messageRetrieved( KMMessage *message ); 00069 void folderJobFinished( KMail::FolderJob *job ); 00070 void processCurrentMessage(); 00071 void cancelJob(); 00072 00073 private: 00074 00075 void queueFolders( KMFolder *root ); 00076 void archiveNextFolder(); 00077 void archiveNextMessage(); 00078 TQString stripRootPath( const TQString &path ) const; 00079 bool hasChildren( KMFolder *folder ) const; 00080 void finish(); 00081 void abort( const TQString &errorMessage ); 00082 bool writeDirHelper( const TQString &directoryPath, const TQString &permissionPath ); 00083 00084 KURL mMailArchivePath; 00085 ArchiveType mArchiveType; 00086 KMFolder *mRootFolder; 00087 KArchive *mArchive; 00088 TQWidget *mParentWidget; 00089 bool mCurrentFolderOpen; 00090 int mArchivedMessages; 00091 uint mArchivedSize; 00092 KPIM::ProgressItem *mProgressItem; 00093 bool mAborted; 00094 bool mDeleteFoldersAfterCompletion; 00095 00096 // True if we obtained ownership of the kMMessage after calling getMsg(), since we need 00097 // to call ungetMsg() then. For that, we also remember the original index. 00098 bool mUnget; 00099 int mMessageIndex; 00100 00101 TQPtrList<KMFolder> mPendingFolders; 00102 KMFolder *mCurrentFolder; 00103 TQValueList<unsigned long> mPendingMessages; 00104 KMMessage *mCurrentMessage; 00105 FolderJob *mCurrentJob; 00106 }; 00107 00108 } 00109 00110 #endif