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