kmail Library API Documentation

kmfoldercachedimap.h

00001 
00032 #ifndef kmfoldercachedimap_h
00033 #define kmfoldercachedimap_h
00034 
00035 #include <kdialogbase.h>
00036 #include <kstandarddirs.h>
00037 #include <qvaluelist.h>
00038 #include <qvaluevector.h>
00039 #include <qptrlist.h>
00040 #include <qdialog.h>
00041 
00042 #include "kmfoldermaildir.h"
00043 #include "kmfolderimap.h"
00044 #include "kmacctimap.h"
00045 #include "kmfoldertype.h"
00046 #include "folderjob.h"
00047 #include "cachedimapjob.h"
00048 #include "quotajobs.h"
00049 
00050 using KMail::FolderJob;
00051 using KMail::QuotaInfo;
00052 class KMAcctCachedImap;
00053 
00054 namespace KMail {
00055   class AttachmentStrategy;
00056   struct ACLListEntry;
00057 }
00058 using KMail::AttachmentStrategy;
00059 
00060 class DImapTroubleShootDialog : public KDialogBase
00061 {
00062   Q_OBJECT
00063 public:
00064   DImapTroubleShootDialog( QWidget* parent=0, const char* name=0 );
00065 
00066   static int run();
00067 
00068 private slots:
00069   void slotRebuildIndex();
00070   void slotRebuildCache();
00071 
00072 private:
00073   int rc;
00074 };
00075 
00076 class KMFolderCachedImap : public KMFolderMaildir
00077 {
00078   Q_OBJECT
00079 
00080 public:
00081   static QString cacheLocation() {
00082      return locateLocal("data", "kmail/dimap" );
00083   }
00084 
00088   KMFolderCachedImap(KMFolder* folder, const char* name=0);
00089   virtual ~KMFolderCachedImap();
00090 
00092   void initializeFrom( KMFolderCachedImap* parent );
00093 
00094   virtual void readConfig();
00095   virtual void writeConfig();
00096 
00097   void writeConfigKeysWhichShouldNotGetOverwrittenByReadConfig();
00098 
00100   virtual KMFolderType folderType() const { return KMFolderTypeCachedImap; }
00101 
00103   virtual void remove();
00104 
00106   virtual void serverSync( bool recurse );
00107 
00109   void resetSyncState();
00110 
00111   void checkUidValidity();
00112 
00113   enum imapState { imapNoInformation=0, imapInProgress=1, imapFinished=2 };
00114 
00115   virtual imapState getContentState() { return mContentState; }
00116   virtual void setContentState(imapState state) { mContentState = state; }
00117 
00118   virtual imapState getSubfolderState() { return mSubfolderState; }
00119   virtual void setSubfolderState(imapState state);
00120 
00122   void setImapPath(const QString &path);
00123   QString imapPath() const { return mImapPath; }
00124 
00126   void setLastUid( ulong uid );
00127   ulong lastUid();
00128 
00130   KMMsgBase* findByUID( ulong uid );
00131 
00133   void setUidValidity(const QString &validity) { mUidValidity = validity; }
00134   QString uidValidity() const { return mUidValidity; }
00135 
00138   void clearUidMap() { uidMap.clear(); }
00139 
00141   void setAccount(KMAcctCachedImap *acct);
00142   KMAcctCachedImap* account() const;
00143 
00145   QString uidCacheLocation() const;
00146 
00148   int readUidCache();
00149 
00151   int writeUidCache();
00152 
00154   int progress() const { return mProgress; }
00155 
00156   /* Reimplemented from KMFolder. Moving is not supported, so aParent must be 0 */
00157   virtual int rename(const QString& aName, KMFolderDir *aParent=0);
00158 
00159   /* Reimplemented from KMFolderMaildir */
00160   virtual KMMessage* take(int idx);
00161   /* Reimplemented from KMFolderMaildir */
00162   virtual int addMsg(KMMessage* msg, int* index_return = 0);
00163   /* internal version that doesn't remove the X-UID header */
00164   virtual int addMsgInternal(KMMessage* msg, bool, int* index_return = 0);
00165   virtual int addMsgKeepUID(KMMessage* msg, int* index_return = 0) {
00166     return addMsgInternal(msg, false, index_return);
00167   }
00168 
00169   /* Reimplemented from KMFolderMaildir */
00170   virtual void removeMsg(int i, bool imapQuiet = FALSE);
00171   virtual void removeMsg(QPtrList<KMMessage> msgList, bool imapQuiet = FALSE)
00172     { FolderStorage::removeMsg(msgList, imapQuiet); }
00173 
00175   bool isReadOnly() const { return KMFolderMaildir::isReadOnly() || mReadOnly; }
00176 
00180   void sendFolderComplete(bool success)
00181   { emit folderComplete(this, success); }
00182 
00186   void setSilentUpload( bool silent ) { mSilentUpload = silent; }
00187   bool silentUpload() { return mSilentUpload; }
00188 
00189   virtual int createIndexFromContents()
00190     { return KMFolderMaildir::createIndexFromContents(); }
00191 
00192   //virtual void holdSyncs( bool hold ) { mHoldSyncs = hold; }
00193 
00199   virtual bool listDirectory(bool secondStep = false);
00200 
00202   KMFolder* trashFolder() const;
00203 
00208   int userRights() const { return mUserRights; }
00209 
00211   void setUserRights( unsigned int userRights );
00212 
00222   const QuotaInfo quotaInfo() const { return mQuotaInfo; }
00223 
00225   typedef QValueVector<KMail::ACLListEntry> ACLList;
00226   const ACLList& aclList() const { return mACLList; }
00227 
00229   void setACLList( const ACLList& arr );
00230 
00231   // Reimplemented so the mStatusChangedLocally bool can be set
00232   virtual void setStatus( int id, KMMsgStatus status, bool toggle );
00233   virtual void setStatus( QValueList<int>& ids, KMMsgStatus status, bool toggle );
00234 
00235   QString annotationFolderType() const { return mAnnotationFolderType; }
00236 
00237   // For kmailicalifaceimpl only
00238   void updateAnnotationFolderType();
00239 
00248   enum IncidencesFor { IncForNobody, IncForAdmins, IncForReaders };
00249 
00250   IncidencesFor incidencesFor() const { return mIncidencesFor; }
00252   void setIncidencesFor( IncidencesFor incfor );
00253 
00254 protected slots:
00259   void slotListResult(const QStringList&, const QStringList&,
00260       const QStringList&, const QStringList&, const ImapAccountBase::jobData& );
00261 
00262   void slotGetMessagesData(KIO::Job * job, const QByteArray & data);
00263   void getMessagesResult(KMail::FolderJob *, bool lastSet);
00264   void slotGetLastMessagesResult(KMail::FolderJob *);
00265   void slotProgress(unsigned long done, unsigned long total);
00266   void slotPutProgress( unsigned long, unsigned long );
00267 
00268   //virtual void slotCheckValidityResult(KIO::Job * job);
00269   void slotSubFolderComplete(KMFolderCachedImap*, bool);
00270 
00271   // Connected to the imap account
00272   void slotConnectionResult( int errorCode, const QString& errorMsg );
00273 
00274   void slotCheckUidValidityResult( KMail::FolderJob* job );
00275   void slotGetAnnotationResult( KIO::Job* );
00276   void slotMultiUrlGetAnnotationResult( KIO::Job* );
00277   void slotSetAnnotationResult(KIO::Job *job);
00278   void slotReceivedUserRights( KMFolder* );
00279   void slotReceivedACL( KMFolder*, KIO::Job*, const KMail::ACLList& );
00280 
00281   void slotMultiSetACLResult(KIO::Job *);
00282   void slotACLChanged( const QString&, int );
00283   void slotAnnotationResult(const QString& entry, const QString& value, bool found);
00284   void slotAnnotationChanged( const QString& entry, const QString& attribute, const QString& value );
00285   void slotDeleteMessagesResult(KMail::FolderJob *);
00286   void slotImapStatusChanged(KMFolder* folder, const QString&, bool);
00287   void slotStorageQuotaResult( const QuotaInfo& );
00288   void slotQuotaResult( KIO::Job* job );
00289 
00290 protected:
00291   /* returns true if there were messages to delete
00292      on the server */
00293   bool deleteMessages();
00294   void listMessages();
00295   void uploadNewMessages();
00296   void uploadFlags();
00297   void createNewFolders();
00298 
00299   void listDirectory2();
00300   void createFoldersNewOnServerAndFinishListing( const QValueVector<int> foldersNewOnServer );
00301 
00302 
00305   virtual QValueList<unsigned long> findNewMessages();
00308   virtual QValueList<KMFolderCachedImap*> findNewFolders();
00309 
00311   virtual bool canRemoveFolder() const;
00312 
00314   virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder,
00315                                   QString partSpecifier, const AttachmentStrategy *as ) const;
00316   virtual FolderJob* doCreateJob( QPtrList<KMMessage>& msgList, const QString& sets,
00317                                   FolderJob::JobType jt, KMFolder *folder ) const;
00318 
00319   virtual void timerEvent( QTimerEvent* );
00320 
00321   /* update progress status */
00322   void newState( int progress, const QString& syncStatus );
00323 
00324 public slots:
00328   void slotSimpleData(KIO::Job * job, const QByteArray & data);
00329 
00333   void slotTroubleshoot();
00334 
00335 private slots:
00336   void serverSyncInternal();
00337   void slotIncreaseProgress();
00338   void slotUpdateLastUid();
00339   void slotFolderDeletionOnServerFinished();
00340 
00341 signals:
00342   void folderComplete(KMFolderCachedImap *folder, bool success);
00343   void listComplete( KMFolderCachedImap* );
00344 
00348   void syncState( int state, int number );
00349 
00350 private:
00351   void setReadOnly( bool readOnly );
00352   QString state2String( int state ) const;
00353   void deleteGhostMessages();
00354 
00356   enum {
00357     SYNC_STATE_INITIAL,
00358     SYNC_STATE_PUT_MESSAGES,
00359     SYNC_STATE_UPLOAD_FLAGS,
00360     SYNC_STATE_CREATE_SUBFOLDERS,
00361     SYNC_STATE_LIST_SUBFOLDERS,
00362     SYNC_STATE_LIST_SUBFOLDERS2,
00363     SYNC_STATE_DELETE_SUBFOLDERS,
00364     SYNC_STATE_LIST_MESSAGES,
00365     SYNC_STATE_DELETE_MESSAGES,
00366     SYNC_STATE_EXPUNGE_MESSAGES,
00367     SYNC_STATE_GET_MESSAGES,
00368     SYNC_STATE_HANDLE_INBOX,
00369     SYNC_STATE_GET_USERRIGHTS,
00370     SYNC_STATE_GET_ANNOTATIONS,
00371     SYNC_STATE_SET_ANNOTATIONS,
00372     SYNC_STATE_GET_ACLS,
00373     SYNC_STATE_SET_ACLS,
00374     SYNC_STATE_GET_QUOTA,
00375     SYNC_STATE_FIND_SUBFOLDERS,
00376     SYNC_STATE_SYNC_SUBFOLDERS,
00377     SYNC_STATE_CHECK_UIDVALIDITY,
00378     SYNC_STATE_RENAME_FOLDER
00379   } mSyncState;
00380 
00381   int mProgress;
00382   int mStatusFlagsJobs;
00383 
00384   QString mUidValidity;
00385   QString     mImapPath;
00386   imapState   mContentState, mSubfolderState;
00387   QStringList mSubfolderNames, mSubfolderPaths,
00388               mSubfolderMimeTypes, mSubfolderAttributes;
00389   QString     mAnnotationFolderType;
00390   IncidencesFor mIncidencesFor;
00391 
00392   bool        mHasInbox;
00393   bool        mIsSelected;
00394   bool        mCheckFlags;
00395   bool        mReadOnly;
00396   mutable QGuardedPtr<KMAcctCachedImap> mAccount;
00397 
00398   QIntDict<int> uidsOnServer;
00399   QValueList<ulong> uidsForDeletionOnServer;
00400   QValueList<KMail::CachedImapJob::MsgForDownload> mMsgsForDownload;
00401   QValueList<ulong> mUidsForDownload;
00402   QStringList       foldersForDeletionOnServer;
00403 
00404   QValueList<KMFolderCachedImap*> mSubfoldersForSync;
00405   KMFolderCachedImap* mCurrentSubfolder;
00406   QValueVector<int> mFoldersNewOnServer;
00407 
00411   QMap<ulong,int> uidMap;
00412   bool uidMapDirty;
00413   void reloadUidMap();
00414   int uidWriteTimer;
00415 
00425   ulong mLastUid;
00430   ulong mTentativeHighestUid;
00431 
00432   int mUserRights;
00433   ACLList mACLList;
00434 
00435   bool mSilentUpload;
00436   bool mFolderRemoved;
00437   //bool mHoldSyncs;
00438   bool mRecurse;
00439   bool mCreateInbox;
00444   bool mStatusChangedLocally;
00446   bool mAnnotationFolderTypeChanged;
00448   bool mIncidencesForChanged;
00449 
00450   QuotaInfo mQuotaInfo;
00451 };
00452 
00453 #endif /*kmfoldercachedimap_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 25 11:20:07 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003