kmail
searchjob.h
Go to the documentation of this file.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 Qt library by Trolltech AS, Norway (or with modified versions 00020 * of Qt that use the same license as Qt), 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 * Qt. 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 <qstringlist.h> 00032 #include "folderjob.h" 00033 00034 class KMFolderImap; 00035 class KMSearchPattern; 00036 class KURL; 00037 00038 namespace KIO { 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 public: 00064 SearchJob( KMFolderImap* folder, ImapAccountBase* account, 00065 const KMSearchPattern* pattern, Q_UINT32 serNum = 0 ); 00066 00067 virtual ~SearchJob(); 00068 00069 // Execute 00070 virtual void execute(); 00071 00072 protected: 00073 // searches the complete folder with the pattern 00074 void searchCompleteFolder(); 00075 00076 // checks a single message with the pattern 00077 void searchSingleMessage(); 00078 00079 // creates an imap search command 00080 QString searchStringFromPattern( const KMSearchPattern* ); 00081 00082 // returns true if all uids can be mapped to sernums 00083 bool canMapAllUIDs(); 00084 00085 // if we need to download messages 00086 bool needsDownload(); 00087 00088 protected slots: 00089 // search the folder 00090 // is called when all uids can be mapped to sernums 00091 void slotSearchFolder(); 00092 00093 // processes the server answer 00094 void slotSearchData( KIO::Job* job, const QString& data ); 00095 00096 // message is downloaded and searched 00097 void slotSearchMessageArrived( KMMessage* msg ); 00098 00099 // error handling for all cases 00100 void slotSearchResult( KIO::Job *job ); 00101 00102 // imap search result from a single message 00103 void slotSearchDataSingleMessage( KIO::Job* job, const QString& data ); 00104 00105 // the user cancelled the search progress 00106 void slotAbortSearch( KPIM::ProgressItem* item ); 00107 00108 signals: 00109 // emitted when a list of matching serial numbers was found 00110 void searchDone( QValueList<Q_UINT32>, const KMSearchPattern*, bool complete ); 00111 00112 // emitted when a single message (identified by the serial number) was checked 00113 void searchDone( Q_UINT32, const KMSearchPattern*, bool matches ); 00114 00115 protected: 00116 KMFolderImap* mFolder; 00117 ImapAccountBase* mAccount; 00118 const KMSearchPattern* mSearchPattern; 00119 KMSearchPattern* mLocalSearchPattern; 00120 Q_UINT32 mSerNum; 00121 // saves the results of the imap search 00122 QStringList mImapSearchHits; 00123 // collects the serial numbers from imap and local search 00124 QValueList<Q_UINT32> mSearchSerNums; 00125 // the remaining messages that have to be downloaded for local search 00126 uint mRemainingMsgs; 00127 // progress item for local searches 00128 KPIM::ProgressItem *mProgress; 00129 bool mUngetCurrentMsg; 00130 00131 }; 00132 00133 } // namespace 00134 00135 #endif /* SEARCHJOB_H */ 00136