kmail

cachedimapjob.h

Go to the documentation of this file.
00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002  *
00003  *  This file is part of KMail, the KDE mail client.
00004  *  Copyright (c) 2002-2003  Bo Thorsen <bo@sonofthor.dk>
00005  *                2002-2003  Steffen Hansen <hansen@kde.org>
00006  *                2002-2003  Zack Rusin <zack@kde.org>
00007  *
00008  *  KMail is free software; you can redistribute it and/or modify it
00009  *  under the terms of the GNU General Public License, version 2, as
00010  *  published by the Free Software Foundation.
00011  *
00012  *  KMail is distributed in the hope that it will be useful, but
00013  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  *  In addition, as a special exception, the copyright holders give
00022  *  permission to link the code of this program with any edition of
00023  *  the Qt library by Trolltech AS, Norway (or with modified versions
00024  *  of Qt that use the same license as Qt), and distribute linked
00025  *  combinations including the two.  You must obey the GNU General
00026  *  Public License in all respects for all of the code used other than
00027  *  Qt.  If you modify this file, you may extend this exception to
00028  *  your version of the file, but you are not obligated to do so.  If
00029  *  you do not wish to do so, delete this exception statement from
00030  *  your version.
00031  *
00032  *  In addition, as a special exception, the copyright holders give
00033  *  permission to link the code of this program with any edition of
00034  *  the Qt library by Trolltech AS, Norway (or with modified versions
00035  *  of Qt that use the same license as Qt), and distribute linked
00036  *  combinations including the two.  You must obey the GNU General
00037  *  Public License in all respects for all of the code used other than
00038  *  Qt.  If you modify this file, you may extend this exception to
00039  *  your version of the file, but you are not obligated to do so.  If
00040  *  you do not wish to do so, delete this exception statement from
00041  *  your version.
00042  */
00043 
00044 #ifndef CACHEDIMAPJOB_H
00045 #define CACHEDIMAPJOB_H
00046 
00047 #include "folderjob.h"
00048 #include <kio/job.h>
00049 #include <kio/global.h>
00050 
00051 #include <qptrlist.h>
00052 #include <qvaluelist.h>
00053 #include <qcstring.h>
00054 
00055 class KMFolderCachedImap;
00056 class KMAcctCachedImap;
00057 class KMMessage;
00058 
00059 namespace KMail {
00060 
00061 class CachedImapJob : public FolderJob {
00062   Q_OBJECT
00063 public:
00065   struct MsgForDownload {
00066     MsgForDownload() : uid(0),flags(0),size(0) {} // for QValueList only
00067     MsgForDownload( ulong _uid, int _flags, ulong _size )
00068       : uid(_uid), flags(_flags), size(_size) {}
00069     ulong uid;
00070     int flags;
00071     ulong size;
00072   };
00073 
00074   // Get messages
00075   CachedImapJob( const QValueList<MsgForDownload>& msgs,
00076                  JobType type = tGetMessage, KMFolderCachedImap* folder = 0 );
00077   // Put messages
00078   CachedImapJob( const QPtrList<KMMessage>& msgs,
00079                  JobType type, KMFolderCachedImap* folder=0 );
00080   CachedImapJob( const QValueList<unsigned long>& msgs,
00081                  JobType type, KMFolderCachedImap* folder=0 );
00082   // Add sub folders
00083   CachedImapJob( const QValueList<KMFolderCachedImap*>& folders,
00084                  JobType type = tAddSubfolders,
00085                  KMFolderCachedImap* folder = 0 );
00086   // Rename folder
00087   CachedImapJob( const QString& string1, JobType type,
00088                  KMFolderCachedImap* folder );
00089   // Delete folders or messages
00090   CachedImapJob( const QStringList& foldersOrMsgs, JobType type,
00091                  KMFolderCachedImap* folder );
00092   // Other jobs (list messages,expunge folder, check uid validity)
00093   CachedImapJob( JobType type, KMFolderCachedImap* folder );
00094 
00095   virtual ~CachedImapJob();
00096 
00097   void setParentFolder( const KMFolderCachedImap* parent );
00098 
00099 signals:
00100   // only emitted for uid validity checking jobs with PERMANENTFLAGS responses
00101   void permanentFlags( int flags );
00102 
00103 protected:
00104   virtual void execute();
00105   void expungeFolder();
00106   void checkUidValidity();
00107   void renameFolder( const QString &newName );
00108   void listMessages();
00109 
00110 protected slots:
00111   virtual void slotGetNextMessage( KIO::Job *job = 0 );
00112   virtual void slotAddNextSubfolder( KIO::Job *job = 0 );
00113   virtual void slotPutNextMessage();
00114   virtual void slotPutMessageDataReq( KIO::Job *job, QByteArray &data );
00115   virtual void slotPutMessageResult( KIO::Job *job );
00116   virtual void slotPutMessageInfoData(KIO::Job *, const QString &data);
00117   virtual void slotExpungeResult( KIO::Job *job );
00118   virtual void slotDeleteNextFolder( KIO::Job *job = 0 );
00119   virtual void slotCheckUidValidityResult( KIO::Job *job );
00120   virtual void slotRenameFolderResult( KIO::Job *job );
00121   virtual void slotListMessagesResult( KIO::Job * job );
00122   void slotDeleteNextMessages( KIO::Job* job = 0 );
00123   void slotProcessedSize( KIO::Job *, KIO::filesize_t processed );
00124 
00125 private:
00126   KMFolderCachedImap *mFolder;
00127   KMAcctCachedImap   *mAccount;
00128   QValueList<KMFolderCachedImap*> mFolderList;
00129   QValueList<MsgForDownload> mMsgsForDownload;
00130   QValueList<unsigned long> mSerNumMsgList;
00131   ulong mSentBytes; // previous messages
00132   ulong mTotalBytes;
00133   QStringList mFoldersOrMessages; // Folder deletion: path list. Message deletion: sets of uids
00134   KMMessage* mMsg;
00135   QString mString; // Used as uids and as rename target
00136   KMFolderCachedImap *mParentFolder;
00137 };
00138 
00139 }
00140 
00141 #endif