kmail

importjob.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 IMPORTJOB_H
20 #define IMPORTJOB_H
21 
22 #include <kurl.h>
23 
24 #include <tqobject.h>
25 #include <tqvaluelist.h>
26 #include <tqptrlist.h>
27 
28 #include <sys/types.h>
29 
30 class TQWidget;
31 class KArchive;
32 class KArchiveDirectory;
33 class KArchiveFile;
34 class KMFolder;
35 class KMMessage;
36 
37 namespace KPIM
38 {
39  class ProgressItem;
40 }
41 
42 namespace KMail
43 {
44  class FolderJob;
45 
52 class ImportJob : public TQObject
53 {
54  TQ_OBJECT
55 
56 
57  public:
58 
59  explicit ImportJob( TQWidget *parentWidget = 0 );
60  ~ImportJob();
61  void start();
62  void setFile( const KURL &archiveFile );
63  void setRootFolder( KMFolder *rootFolder );
64 
65  private slots:
66 
67  void importNextMessage();
68  void cancelJob();
69  void messagePutResult( KMail::FolderJob *job );
70 
71  private:
72 
73  struct Folder
74  {
75  KMFolder *parent;
76  const KArchiveDirectory *archiveDir;
77  };
78 
79  struct Messages
80  {
81  KMFolder *parent;
82  TQPtrList<KArchiveFile> files;
83  };
84 
85  void finish();
86  void abort( const TQString &errorMessage );
87  void queueFolders();
88  void importNextDirectory();
89  KMFolder* createSubFolder( KMFolder *parent, const TQString &folderName, mode_t permissions );
90  KMFolder* getOrCreateSubFolder( KMFolder *parentFolder, const TQString &subFolderName,
91  mode_t subFolderPermissions );
92  void enqueueMessages( const KArchiveDirectory *dir, KMFolder *folder );
93  void messageAdded();
94 
95  KArchive *mArchive;
96 
97  // The root folder which the user has selected as the folder to which everything should be
98  // imported
99  KMFolder *mRootFolder;
100 
101  TQWidget *mParentWidget;
102  KURL mArchiveFile;
103  int mNumberOfImportedMessages;
104 
105  // List of archive folders with their corresponding KMail parent folder that are awaiting
106  // processing
107  TQValueList<Folder> mQueuedDirectories;
108 
109  // List of list of messages and their parent folders which are awaiting processing
110  TQValueList<Messages> mQueuedMessages;
111 
112  // The folder to which we are currently importing messages
113  KMFolder *mCurrentFolder;
114 
115  // The message which is currently being added
116  KMMessage *mCurrentMessage;
117 
118  // The archive file of the current message that is being added
119  KArchiveFile *mCurrentMessageFile;
120 
121  KPIM::ProgressItem *mProgressItem;
122  bool mAborted;
123 };
124 
125 }
126 
127 #endif
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
Imports an archive that was previously backed up with an BackupJob.
Definition: importjob.h:53
folderdiaquotatab.h
Definition: aboutdata.cpp:40