kmail Library API Documentation

kmfoldercachedimap.h

00001 00021 #ifndef kmfoldercachedimap_h 00022 #define kmfoldercachedimap_h 00023 00024 #include <kdialogbase.h> 00025 #include <qvaluelist.h> 00026 #include <qptrlist.h> 00027 #include <qdialog.h> 00028 00029 #include "kmfoldermaildir.h" 00030 #include "kmfolderimap.h" 00031 #include "kmacctimap.h" 00032 #include "kmfoldertype.h" 00033 #include "folderjob.h" 00034 #include "cachedimapjob.h" 00035 00036 using KMail::FolderJob; 00037 class KMAcctCachedImap; 00038 00039 namespace KMail { 00040 class AttachmentStrategy; 00041 } 00042 using KMail::AttachmentStrategy; 00043 00044 class DImapTroubleShootDialog : public KDialogBase 00045 { 00046 Q_OBJECT 00047 public: 00048 DImapTroubleShootDialog( QWidget* parent=0, const char* name=0 ); 00049 00050 static int run(); 00051 00052 private slots: 00053 void slotRebuildIndex(); 00054 void slotRebuildCache(); 00055 00056 private: 00057 int rc; 00058 }; 00059 00060 class KMFolderCachedImap : public KMFolderMaildir 00061 { 00062 Q_OBJECT 00063 public: 00067 KMFolderCachedImap(KMFolderDir* parent=0, const QString& name=QString::null); 00068 virtual ~KMFolderCachedImap(); 00069 00071 virtual KMFolderType folderType() const { return KMFolderTypeCachedImap; } 00072 00074 virtual int remove(); 00075 00077 virtual void serverSync( bool suppressDialog ); 00078 00080 void resetSyncState() { mSyncState = SYNC_STATE_INITIAL; } 00081 00082 virtual void checkUidValidity(); 00083 00084 enum imapState { imapNoInformation=0, imapInProgress=1, imapFinished=2 }; 00085 00086 virtual imapState getContentState() { return mContentState; } 00087 virtual void setContentState(imapState state) { mContentState = state; } 00088 00089 virtual imapState getSubfolderState() { return mSubfolderState; } 00090 virtual void setSubfolderState(imapState state) { mSubfolderState = state; } 00091 00092 virtual QCString protocol() const { return "cachedimap"; } 00093 00095 void setImapPath(const QString &path) { mImapPath = path; } 00096 QString imapPath() { return mImapPath; } 00097 00099 void setLastUid( ulong uid ); 00100 ulong lastUid(); 00101 00103 KMMessage* findByUID( ulong uid ); 00104 00106 void setUidValidity(const QString &validity) { mUidValidity = validity; } 00107 QString uidValidity() const { return mUidValidity; } 00108 00110 void setAccount(KMAcctCachedImap *acct); 00111 KMAcctCachedImap* account(); 00112 00114 QString uidCacheLocation() const; 00115 00117 int readUidCache(); 00118 00120 int writeUidCache(); 00121 00123 int progress() const { return mProgress; } 00124 00125 /* Reimplemented from KMFolder. Moving is not supported, so aParent must be 0 */ 00126 virtual int rename(const QString& aName, KMFolderDir *aParent=0); 00127 00128 /* Reimplemented from KMFolderMaildir */ 00129 virtual KMMessage* take(int idx); 00130 /* Reimplemented from KMFolderMaildir */ 00131 virtual int addMsg(KMMessage* msg, int* index_return = 0); 00132 /* internal version that doesn't remove the X-UID header */ 00133 virtual int addMsgInternal(KMMessage* msg, bool, int* index_return = 0); 00134 virtual int addMsgKeepUID(KMMessage* msg, int* index_return = 0) { 00135 return addMsgInternal(msg, false, index_return); 00136 } 00137 00138 /* Reimplemented from KMFolderMaildir */ 00139 virtual void removeMsg(int i, bool imapQuiet = FALSE); 00140 virtual void removeMsg(QPtrList<KMMessage> msgList, bool imapQuiet = FALSE) 00141 { KMFolder::removeMsg(msgList, imapQuiet); } 00142 00143 /* Utility methods: */ 00144 static QStringList makeSets(QStringList& uids, bool sort); 00145 static QStringList makeSets(QValueList<ulong>& uids, bool sort); 00146 00150 void sendFolderComplete(bool success) 00151 { emit folderComplete(this, success); } 00152 00153 static void flagsToStatus(KMMsgBase *msg, int flags, bool newMsg = TRUE); 00157 static QCString statusToFlags(KMMsgStatus status); 00158 00162 void setSilentUpload( bool silent ) { mSilentUpload = silent; } 00163 bool silentUpload() { return mSilentUpload; } 00164 00165 virtual int createIndexFromContents() 00166 { return KMFolderMaildir::createIndexFromContents(); } 00167 00168 // Mark for resync 00169 void resync() { mResync = true; } 00170 00171 virtual void holdSyncs( bool hold ) { mHoldSyncs = hold; } 00172 00173 void removeRightAway() { mRemoveRightAway = true; } 00174 00179 bool listDirectory(); 00180 00181 protected slots: 00185 void slotListEntries(KIO::Job * job, const KIO::UDSEntryList & uds); 00189 void slotListResult(KIO::Job * job); 00190 00191 void slotGetMessagesData(KIO::Job * job, const QByteArray & data); 00192 void getMessagesResult(KIO::Job * job, bool lastSet); 00193 void slotGetMessagesResult(KIO::Job * job); 00194 void slotGetLastMessagesResult(KIO::Job * job); 00195 void slotProgress(unsigned long done, unsigned long total); 00196 00197 //virtual void slotCheckValidityResult(KIO::Job * job); 00198 virtual void listMessages(); 00199 virtual void uploadNewMessages(); 00200 /* returns true if there were messages to delete 00201 on the server */ 00202 virtual bool deleteMessages(); 00203 virtual void createNewFolders(); 00204 00205 // Connected to the imap account 00206 void slotConnectionResult( int errorCode ); 00207 00208 protected: 00209 void listDirectory2(); 00210 00211 00214 virtual QValueList<unsigned long> findNewMessages(); 00217 virtual QValueList<KMFolderCachedImap*> findNewFolders(); 00218 00220 virtual bool canRemoveFolder() const; 00221 00223 virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder, 00224 QString partSpecifier, const AttachmentStrategy *as ) const; 00225 virtual FolderJob* doCreateJob( QPtrList<KMMessage>& msgList, const QString& sets, 00226 FolderJob::JobType jt, KMFolder *folder ) const; 00227 00228 virtual void timerEvent( QTimerEvent* ); 00229 00230 public slots: 00234 void slotSimpleData(KIO::Job * job, const QByteArray & data); 00235 00239 void slotTroubleshoot(); 00240 00244 void processNewMail(); 00245 00246 private slots: 00247 void serverSyncInternal(); 00248 00249 signals: 00250 void folderComplete(KMFolderCachedImap *folder, bool success); 00251 void listComplete( KMFolderCachedImap* ); 00252 00253 void listMessagesComplete(); 00254 00255 /* emitted at each state */ 00256 void newState( const QString& folderName, int progressLevel, const QString& syncStatus ); 00257 00261 void syncState( int state, int number ); 00262 00263 private: 00264 00266 enum { 00267 SYNC_STATE_INITIAL, 00268 SYNC_STATE_PUT_MESSAGES, 00269 SYNC_STATE_CREATE_SUBFOLDERS, 00270 SYNC_STATE_LIST_SUBFOLDERS, 00271 SYNC_STATE_LIST_SUBFOLDERS2, 00272 SYNC_STATE_DELETE_SUBFOLDERS, 00273 SYNC_STATE_LIST_MESSAGES, 00274 SYNC_STATE_DELETE_MESSAGES, 00275 SYNC_STATE_EXPUNGE_MESSAGES, 00276 SYNC_STATE_GET_MESSAGES, 00277 SYNC_STATE_HANDLE_INBOX, 00278 SYNC_STATE_FIND_SUBFOLDERS, 00279 SYNC_STATE_SYNC_SUBFOLDERS, 00280 SYNC_STATE_CHECK_UIDVALIDITY 00281 } mSyncState; 00282 00283 int mProgress; 00284 00285 QString mUidValidity; 00286 QString mImapPath; 00287 imapState mContentState, mSubfolderState; 00288 QStringList mSubfolderNames, mSubfolderPaths, mSubfolderMimeTypes; 00289 00290 bool mHasInbox; 00291 bool mIsSelected; 00292 bool mCheckFlags; 00293 bool mReadOnly; 00294 QGuardedPtr<KMAcctCachedImap> mAccount; 00295 00296 QValueList<ulong> uidsOnServer; 00297 QValueList<ulong> uidsForDeletionOnServer; 00298 QValueList<KMail::CachedImapJob::MsgForDownload> mMsgsForDownload; 00299 QValueList<ulong> mUidsForDownload; 00300 QStringList foldersForDeletionOnServer; 00301 00302 QValueList<KMFolderCachedImap*> mSubfoldersForSync; 00303 KMFolderCachedImap* mCurrentSubfolder; 00304 00305 /* Mapping uid ->index 00306 Keep updated in addMsg, take and removeMsg */ 00307 QMap<ulong,int> uidMap; 00308 bool uidMapDirty; 00309 ulong mLastUid; 00310 int uidWriteTimer; 00311 void reloadUidMap(); 00312 00313 QString state2String( int state ) const; 00314 bool mIsConnected; 00315 00316 bool mSilentUpload; 00317 bool mFolderRemoved; 00318 bool mResync; 00319 bool mSuppressDialog; 00320 bool mHoldSyncs; 00321 bool mRemoveRightAway; 00322 }; 00323 00324 #endif /*kmfoldercachedimap_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003