cachedimapjob.h
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 TQt library by Trolltech AS, Norway (or with modified versions 00024 * of TQt that use the same license as TQt), 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 * TQt. 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 TQt library by Trolltech AS, Norway (or with modified versions 00035 * of TQt that use the same license as TQt), 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 * TQt. 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 <tqptrlist.h> 00052 #include <tqvaluelist.h> 00053 #include <tqcstring.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 TQ_OBJECT 00064 public: 00066 struct MsgForDownload { 00067 MsgForDownload() : uid(0),flags(0),size(0) {} // for TQValueList only 00068 MsgForDownload( ulong _uid, int _flags, ulong _size ) 00069 : uid(_uid), flags(_flags), size(_size) {} 00070 ulong uid; 00071 int flags; 00072 ulong size; 00073 }; 00074 00075 // Get messages 00076 CachedImapJob( const TQValueList<MsgForDownload>& msgs, 00077 JobType type = tGetMessage, KMFolderCachedImap* folder = 0 ); 00078 // Put messages 00079 CachedImapJob( const TQPtrList<KMMessage>& msgs, 00080 JobType type, KMFolderCachedImap* folder=0 ); 00081 CachedImapJob( const TQValueList<unsigned long>& msgs, 00082 JobType type, KMFolderCachedImap* folder=0 ); 00083 // Add sub folders 00084 CachedImapJob( const TQValueList<KMFolderCachedImap*>& folders, 00085 JobType type = tAddSubfolders, 00086 KMFolderCachedImap* folder = 0 ); 00087 // Rename folder 00088 CachedImapJob( const TQString& string1, JobType type, 00089 KMFolderCachedImap* folder ); 00090 // Delete folders or messages 00091 CachedImapJob( const TQStringList& foldersOrMsgs, JobType type, 00092 KMFolderCachedImap* folder ); 00093 // Other jobs (list messages,expunge folder, check uid validity) 00094 CachedImapJob( JobType type, KMFolderCachedImap* folder ); 00095 00096 virtual ~CachedImapJob(); 00097 00098 void setParentFolder( const KMFolderCachedImap* parent ); 00099 00100 signals: 00101 // only emitted for uid validity checking jobs with PERMANENTFLAGS responses 00102 void permanentFlags( int flags ); 00103 00104 protected: 00105 virtual void execute(); 00106 void expungeFolder(); 00107 void checkUidValidity(); 00108 void renameFolder( const TQString &newName ); 00109 void listMessages(); 00110 00111 protected slots: 00112 virtual void slotGetNextMessage( KIO::Job *job = 0 ); 00113 virtual void slotAddNextSubfolder( KIO::Job *job = 0 ); 00114 virtual void slotPutNextMessage(); 00115 virtual void slotPutMessageDataReq( KIO::Job *job, TQByteArray &data ); 00116 virtual void slotPutMessageResult( KIO::Job *job ); 00117 virtual void slotPutMessageInfoData(KIO::Job *, const TQString &data); 00118 virtual void slotExpungeResult( KIO::Job *job ); 00119 virtual void slotDeleteNextFolder( KIO::Job *job = 0 ); 00120 virtual void slotCheckUidValidityResult( KIO::Job *job ); 00121 virtual void slotRenameFolderResult( KIO::Job *job ); 00122 virtual void slotListMessagesResult( KIO::Job * job ); 00123 void slotDeleteNextMessages( KIO::Job* job = 0 ); 00124 void slotProcessedSize( KIO::Job *, KIO::filesize_t processed ); 00125 void slotSubscribtionChange1Done( const TQString&, bool ); 00126 void slotSubscribtionChange2Done( const TQString&, bool ); 00127 void slotSubscribtionChange1Failed( const TQString &errorMessage ); 00128 void slotSubscribtionChange2Failed( const TQString &errorMessage ); 00129 00130 private: 00131 00132 void renameOnDisk(); 00133 void revertLabelChange(); 00134 00135 KMFolderCachedImap *mFolder; 00136 KMAcctCachedImap *mAccount; 00137 TQValueList<KMFolderCachedImap*> mFolderList; 00138 TQValueList<MsgForDownload> mMsgsForDownload; 00139 TQValueList<unsigned long> mSerNumMsgList; 00140 ulong mSentBytes; // previous messages 00141 ulong mTotalBytes; 00142 TQStringList mFoldersOrMessages; // Folder deletion: path list. Message deletion: sets of uids 00143 KMMessage* mMsg; 00144 TQString mString; // Used as uids and as rename target 00145 TQString mOldImapPath, mNewImapPath, mNewName; // used for renaming 00146 KMFolderCachedImap *mParentFolder; 00147 }; 00148 00149 } 00150 00151 #endif