kmail

backupjob.h
1 /* Copyright 2009 Klarälvdalens Datakonsult AB
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of
6  the License or (at your option) version 3 or any later version
7  accepted by the membership of KDE e.V. (or its successor approved
8  by the membership of KDE e.V.), which shall act as a proxy
9  defined in Section 14 of version 3 of the license.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef BACKUPJOB_H
20 #define BACKUPJOB_H
21 
22 #include <kurl.h>
23 #include <tqptrlist.h>
24 
25 #include <tqobject.h>
26 
27 class KMFolder;
28 class KMMessage;
29 class KArchive;
30 class TDEProcess;
31 class TQWidget;
32 
33 namespace KPIM {
34  class ProgressItem;
35 }
36 
37 namespace KMail
38 {
39  class FolderJob;
40 
48 class BackupJob : public TQObject
49 {
50  TQ_OBJECT
51 
52 
53  public:
54 
55  // These enum values have to stay in sync with the format combobox of ArchiveFolderDialog!
56  enum ArchiveType { Zip = 0, Tar = 1, TarBz2 = 2, TarGz = 3 };
57 
58  explicit BackupJob( TQWidget *parent = 0 );
59  ~BackupJob();
60  void setRootFolder( KMFolder *rootFolder );
61  void setSaveLocation( const KURL &savePath );
62  void setArchiveType( ArchiveType type );
63  void setDeleteFoldersAfterCompletion( bool deleteThem );
64  void start();
65 
66  private slots:
67 
68  void messageRetrieved( KMMessage *message );
69  void folderJobFinished( KMail::FolderJob *job );
70  void processCurrentMessage();
71  void cancelJob();
72 
73  private:
74 
75  void queueFolders( KMFolder *root );
76  void archiveNextFolder();
77  void archiveNextMessage();
78  TQString stripRootPath( const TQString &path ) const;
79  bool hasChildren( KMFolder *folder ) const;
80  void finish();
81  void abort( const TQString &errorMessage );
82  bool writeDirHelper( const TQString &directoryPath, const TQString &permissionPath );
83 
84  KURL mMailArchivePath;
85  ArchiveType mArchiveType;
86  KMFolder *mRootFolder;
87  KArchive *mArchive;
88  TQWidget *mParentWidget;
89  bool mCurrentFolderOpen;
90  int mArchivedMessages;
91  uint mArchivedSize;
92  KPIM::ProgressItem *mProgressItem;
93  bool mAborted;
94  bool mDeleteFoldersAfterCompletion;
95 
96  // True if we obtained ownership of the kMMessage after calling getMsg(), since we need
97  // to call ungetMsg() then. For that, we also remember the original index.
98  bool mUnget;
99  int mMessageIndex;
100 
101  TQPtrList<KMFolder> mPendingFolders;
102  KMFolder *mCurrentFolder;
103  TQValueList<unsigned long> mPendingMessages;
104  KMMessage *mCurrentMessage;
105  FolderJob *mCurrentJob;
106 };
107 
108 }
109 
110 #endif
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
Writes an entire folder structure to an archive file.
Definition: backupjob.h:49
folderdiaquotatab.h
Definition: aboutdata.cpp:40