folderjob.h
00001 /* -*- mode: C++; c-file-style: "gnu" -*- 00002 * 00003 * This file is part of KMail, the KDE mail client. 00004 * Copyright (c) 2003 Zack Rusin <zack@kde.org> 00005 * 00006 * KMail is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License, version 2, as 00008 * published by the Free Software Foundation. 00009 * 00010 * KMail is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * In addition, as a special exception, the copyright holders give 00020 * permission to link the code of this program with any edition of 00021 * the TQt library by Trolltech AS, Norway (or with modified versions 00022 * of TQt that use the same license as TQt), and distribute linked 00023 * combinations including the two. You must obey the GNU General 00024 * Public License in all respects for all of the code used other than 00025 * TQt. If you modify this file, you may extend this exception to 00026 * your version of the file, but you are not obligated to do so. If 00027 * you do not wish to do so, delete this exception statement from 00028 * your version. 00029 */ 00030 00031 #ifndef FOLDERJOB_H 00032 #define FOLDERJOB_H 00033 00034 #include "kmmessage.h" 00035 00036 #include <tqobject.h> 00037 #include <tqptrlist.h> 00038 #include <tqstring.h> 00039 00040 class KMFolder; 00041 00042 namespace KMail { 00043 00044 class FolderJob : public TQObject 00045 { 00046 Q_OBJECT 00047 TQ_OBJECT 00048 00049 public: 00050 enum JobType { tListMessages, tGetFolder, tCreateFolder, tExpungeFolder, 00051 tDeleteMessage, tGetMessage, tPutMessage, tAddSubfolders, 00052 tDeleteFolders, tCheckUidValidity, tRenameFolder, 00053 tCopyMessage, tMoveMessage, tOther /* used by subclasses */ }; 00058 FolderJob( KMMessage *msg, JobType jt = tGetMessage, KMFolder *folder = 0, 00059 TQString partSpecifier = TQString() ); 00060 00066 FolderJob( const TQPtrList<KMMessage>& msgList, const TQString& sets, 00067 JobType jt = tGetMessage, KMFolder *folder = 0 ); 00073 FolderJob( JobType jt ); 00074 virtual ~FolderJob(); 00075 00076 TQPtrList<KMMessage> msgList() const; 00080 void start(); 00081 00087 virtual void kill(); 00088 00093 int error() const { return mErrorCode; } 00094 00098 bool isCancellable() const { return mCancellable; } 00099 00106 void setCancellable( bool b ) { mCancellable = b; } 00107 00108 void setPassiveDestructor( bool passive ) { mPassiveDestructor = passive; } 00109 bool passiveDestructor() { return mPassiveDestructor; } 00110 00111 signals: 00116 void messageRetrieved( KMMessage * ); 00117 00121 void messageUpdated( KMMessage *, TQString ); 00122 00127 void messageStored( KMMessage * ); 00128 00134 void messageCopied( TQPtrList<KMMessage> ); 00135 00141 void messageCopied( KMMessage * ); 00142 00146 void finished(); 00147 00154 void result( KMail::FolderJob* job ); 00155 00161 void progress( unsigned long bytesDownloaded, unsigned long bytesTotal ); 00162 00163 private: 00164 void init(); 00165 00166 protected: 00171 virtual void execute()=0; 00172 00173 TQPtrList<KMMessage> mMsgList; 00174 JobType mType; 00175 TQString mSets; 00176 KMFolder* mSrcFolder; 00177 KMFolder* mDestFolder; 00178 TQString mPartSpecifier; 00179 int mErrorCode; 00180 00181 //finished() won't be emitted when this is set 00182 bool mPassiveDestructor; 00183 bool mStarted; 00184 bool mCancellable; 00185 }; 00186 00187 } 00188 00189 #endif