maildirjob.cpp
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 #ifdef HAVE_CONFIG_H 00031 #include <config.h> 00032 #endif 00033 00034 #include "maildirjob.h" 00035 00036 #include "kmfoldermaildir.h" 00037 #include "kmfolder.h" 00038 00039 #include <tdeapplication.h> 00040 #include <kdebug.h> 00041 00042 #include <tqtimer.h> 00043 #include <tqdatetime.h> 00044 00045 namespace KMail { 00046 00047 00048 //----------------------------------------------------------------------------- 00049 MaildirJob::MaildirJob( KMMessage *msg, JobType jt , KMFolder *folder ) 00050 : FolderJob( msg, jt, folder ), mParentFolder( 0 ) 00051 { 00052 } 00053 00054 //----------------------------------------------------------------------------- 00055 MaildirJob::MaildirJob( TQPtrList<KMMessage>& msgList, const TQString& sets, 00056 JobType jt , KMFolder *folder ) 00057 : FolderJob( msgList, sets, jt, folder ), mParentFolder( 0 ) 00058 { 00059 } 00060 00061 //----------------------------------------------------------------------------- 00062 MaildirJob::~MaildirJob() 00063 { 00064 } 00065 00066 //----------------------------------------------------------------------------- 00067 void MaildirJob::setParentFolder( const KMFolderMaildir* parent ) 00068 { 00069 mParentFolder = const_cast<KMFolderMaildir*>( parent ); 00070 } 00071 00072 00073 00074 //----------------------------------------------------------------------------- 00075 void MaildirJob::execute() 00076 { 00077 TQTimer::singleShot( 0, this, TQT_SLOT(startJob()) ); 00078 } 00079 00080 //----------------------------------------------------------------------------- 00081 void MaildirJob::startJob() 00082 { 00083 switch( mType ) { 00084 case tGetMessage: 00085 { 00086 KMMessage* msg = mMsgList.first(); 00087 if ( msg ) { 00088 msg->setComplete( true ); 00089 emit messageRetrieved( msg ); 00090 } 00091 } 00092 break; 00093 case tDeleteMessage: 00094 { 00095 static_cast<KMFolder*>(mParentFolder->folder())->removeMsg( mMsgList ); 00096 } 00097 break; 00098 case tPutMessage: 00099 { 00100 mParentFolder->addMsg( mMsgList.first() ); 00101 emit messageStored( mMsgList.first() ); 00102 } 00103 break; 00104 case tCopyMessage: 00105 case tCreateFolder: 00106 case tGetFolder: 00107 case tListMessages: 00108 kdDebug(5006)<<k_funcinfo<<"### Serious problem! "<<endl; 00109 break; 00110 default: 00111 break; 00112 } 00113 //OK, we're done 00114 //delete this; 00115 deleteLater(); 00116 } 00117 00118 } 00119 00120 #include "maildirjob.moc"