kmail

importjob.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 IMPORTJOB_H
00020 #define IMPORTJOB_H
00021 
00022 #include <kurl.h>
00023 
00024 #include <qobject.h>
00025 #include <qvaluelist.h>
00026 #include <qptrlist.h>
00027 
00028 #include <sys/types.h>
00029 
00030 class QWidget;
00031 class KArchive;
00032 class KArchiveDirectory;
00033 class KArchiveFile;
00034 class KMFolder;
00035 
00036 namespace KPIM
00037 {
00038   class ProgressItem;
00039 }
00040 
00041 namespace KMail
00042 {
00043 
00050 class ImportJob : public QObject
00051 {
00052   Q_OBJECT
00053 
00054   public:
00055 
00056     explicit ImportJob( QWidget *parentWidget = 0 );
00057     ~ImportJob();
00058     void start();
00059     void setFile( const KURL &archiveFile );
00060     void setRootFolder( KMFolder *rootFolder );
00061 
00062   private slots:
00063 
00064     void importNextMessage();
00065     void cancelJob();
00066 
00067   private:
00068 
00069     struct Folder
00070     {
00071       KMFolder *parent;
00072       const KArchiveDirectory *archiveDir;
00073     };
00074 
00075     struct Messages
00076     {
00077       KMFolder *parent;
00078       QPtrList<KArchiveFile> files;
00079     };
00080 
00081     void finish();
00082     void abort( const QString &errorMessage );
00083     void queueFolders();
00084     void importNextDirectory();
00085     KMFolder* createSubFolder( KMFolder *parent, const QString &folderName, mode_t permissions );
00086     KMFolder* getOrCreateSubFolder( KMFolder *parentFolder, const QString &subFolderName,
00087                                     mode_t subFolderPermissions );
00088     void enqueueMessages( const KArchiveDirectory *dir, KMFolder *folder );
00089 
00090     KArchive *mArchive;
00091 
00092     // The root folder which the user has selected as the folder to which everything should be
00093     // imported
00094     KMFolder *mRootFolder;
00095 
00096     QWidget *mParentWidget;
00097     KURL mArchiveFile;
00098     int mNumberOfImportedMessages;
00099 
00100     // List of archive folders with their corresponding KMail parent folder that are awaiting
00101     // processing
00102     QValueList<Folder> mQueuedDirectories;
00103 
00104     // List of list of messages and their parent folders which are awaiting processing
00105     QValueList<Messages> mQueuedMessages;
00106 
00107     // The folder to which we are currently importing messages
00108     KMFolder *mCurrentFolder;
00109 
00110     KPIM::ProgressItem *mProgressItem;
00111     bool mAborted;
00112 };
00113 
00114 }
00115 
00116 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys