kmail
searchjob.h
00001 /* 00002 * Copyright (c) 2004 Carsten Burghardt <burghardt@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; version 2 of the License 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00016 * 00017 * In addition, as a special exception, the copyright holders give 00018 * permission to link the code of this program with any edition of 00019 * the TQt library by Trolltech AS, Norway (or with modified versions 00020 * of TQt that use the same license as TQt), and distribute linked 00021 * combinations including the two. You must obey the GNU General 00022 * Public License in all respects for all of the code used other than 00023 * TQt. If you modify this file, you may extend this exception to 00024 * your version of the file, but you are not obligated to do so. If 00025 * you do not wish to do so, delete this exception statement from 00026 * your version. 00027 */ 00028 #ifndef SEARCHJOB_H 00029 #define SEARCHJOB_H 00030 00031 #include <tqstringlist.h> 00032 #include "folderjob.h" 00033 00034 class KMFolderImap; 00035 class KMSearchPattern; 00036 class KURL; 00037 00038 namespace TDEIO { 00039 class Job; 00040 } 00041 00042 namespace KPIM { 00043 class ProgressItem; 00044 } 00045 00046 namespace KMail { 00047 00048 class ImapAccountBase; 00049 00053 class SearchJob : public FolderJob 00054 { 00055 Q_OBJECT 00056 00057 public: 00065 SearchJob( KMFolderImap* folder, ImapAccountBase* account, 00066 const KMSearchPattern* pattern, TQ_UINT32 serNum = 0 ); 00067 00068 virtual ~SearchJob(); 00069 00070 // Execute 00071 virtual void execute(); 00072 00073 protected: 00074 // searches the complete folder with the pattern 00075 void searchCompleteFolder(); 00076 00077 // checks a single message with the pattern 00078 void searchSingleMessage(); 00079 00080 // creates an imap search command 00081 TQString searchStringFromPattern( const KMSearchPattern* ); 00082 00083 // returns true if all uids can be mapped to sernums 00084 bool canMapAllUIDs(); 00085 00086 // if we need to download messages 00087 bool needsDownload(); 00088 00089 protected slots: 00090 // search the folder 00091 // is called when all uids can be mapped to sernums 00092 void slotSearchFolder(); 00093 00094 // processes the server answer 00095 void slotSearchData( TDEIO::Job* job, const TQString& data ); 00096 00097 // message is downloaded and searched 00098 void slotSearchMessageArrived( KMMessage* msg ); 00099 00100 // error handling for all cases 00101 void slotSearchResult( TDEIO::Job *job ); 00102 00103 // imap search result from a single message 00104 void slotSearchDataSingleMessage( TDEIO::Job* job, const TQString& data ); 00105 00106 // the user cancelled the search progress 00107 void slotAbortSearch( KPIM::ProgressItem* item ); 00108 00109 signals: 00110 // emitted when a list of matching serial numbers was found 00111 void searchDone( TQValueList<TQ_UINT32>, const KMSearchPattern*, bool complete ); 00112 00113 // emitted when a single message (identified by the serial number) was checked 00114 void searchDone( TQ_UINT32, const KMSearchPattern*, bool matches ); 00115 00116 protected: 00117 KMFolderImap* mFolder; 00118 ImapAccountBase* mAccount; 00119 const KMSearchPattern* mSearchPattern; 00120 KMSearchPattern* mLocalSearchPattern; 00121 TQ_UINT32 mSerNum; 00122 // saves the results of the imap search 00123 TQStringList mImapSearchHits; 00124 // collects the serial numbers from imap and local search 00125 TQValueList<TQ_UINT32> mSearchSerNums; 00126 // the remaining messages that have to be downloaded for local search 00127 uint mRemainingMsgs; 00128 // progress item for local searches 00129 KPIM::ProgressItem *mProgress; 00130 bool mUngetCurrentMsg; 00131 00132 }; 00133 00134 } // namespace 00135 00136 #endif /* SEARCHJOB_H */ 00137