• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

kmfoldercachedimap.h

Go to the documentation of this file.
00001 /*
00002  *  kmfoldercachedimap.cpp
00003  *
00004  *  Copyright (c) 2002-2004 Bo Thorsen <bo@sonofthor.dk>
00005  *  Copyright (c) 2002-2003 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; version 2 of the License
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  *  In addition, as a special exception, the copyright holders give
00021  *  permission to link the code of this program with any edition of
00022  *  the Qt library by Trolltech AS, Norway (or with modified versions
00023  *  of Qt that use the same license as Qt), and distribute linked
00024  *  combinations including the two.  You must obey the GNU General
00025  *  Public License in all respects for all of the code used other than
00026  *  Qt.  If you modify this file, you may extend this exception to
00027  *  your version of the file, but you are not obligated to do so.  If
00028  *  you do not wish to do so, delete this exception statement from
00029  *  your version.
00030  */
00031 
00032 #ifndef kmfoldercachedimap_h
00033 #define kmfoldercachedimap_h
00034 
00035 #include "kmfoldermaildir.h"
00036 #include "kmfolderimap.h"
00037 #include "kmacctcachedimap.h"
00038 #include "kmfoldertype.h"
00039 #include "folderjob.h"
00040 #include "cachedimapjob.h"
00041 #include "quotajobs.h"
00042 
00043 #include <kdialog.h>
00044 #include <kstandarddirs.h>
00045 
00046 #include <QDialog>
00047 #include <QList>
00048 #include <QTimerEvent>
00049 
00050 using KMail::FolderJob;
00051 using KMail::QuotaInfo;
00052 class KMCommand;
00053 
00054 class QComboBox;
00055 class QRadioButton;
00056 
00057 namespace KMail {
00058   class AttachmentStrategy;
00059   class ImapAccountBase;
00060   struct ACLListEntry;
00061 }
00062 using KMail::AttachmentStrategy;
00063 
00064 class DImapTroubleShootDialog : public KDialog
00065 {
00066   Q_OBJECT
00067   public:
00068     enum SelectedOperation {
00069       None = -1,
00070       ReindexCurrent = 0,
00071       ReindexRecursive = 1,
00072       ReindexAll = 2,
00073       RefreshCache
00074     };
00075 
00076     DImapTroubleShootDialog( QWidget *parent=0 );
00077 
00078     static int run();
00079 
00080   private slots:
00081     void slotDone();
00082 
00083   private:
00084     QRadioButton *mIndexButton, *mCacheButton;
00085     QComboBox *mIndexScope;
00086     int rc;
00087 };
00088 
00089 class KMFolderCachedImap : public KMFolderMaildir
00090 {
00091   Q_OBJECT
00092 
00093   public:
00094     static QString cacheLocation() {
00095       return KStandardDirs::locateLocal("data", "kmail/dimap" );
00096     }
00097 
00103     explicit KMFolderCachedImap( KMFolder *folder, const char *name=0 );
00104     virtual ~KMFolderCachedImap();
00105 
00109     void initializeFrom( KMFolderCachedImap *parent );
00110 
00112     void reallyDoClose();
00113 
00114     virtual void readConfig();
00115     virtual void writeConfig();
00116 
00117     void writeConfigKeysWhichShouldNotGetOverwrittenByReadConfig();
00118 
00122     virtual KMFolderType folderType() const { return KMFolderTypeCachedImap; }
00123 
00125     virtual int create();
00126 
00130     virtual void remove();
00131 
00135     virtual void serverSync( bool recurse );
00136 
00140     void resetSyncState();
00141 
00145     void setAlarmsBlocked( bool blocked );
00146 
00148     bool alarmsBlocked() const;
00149 
00150     void checkUidValidity();
00151 
00152     enum imapState {
00153       imapNoInformation=0,
00154       imapInProgress=1,
00155       imapFinished=2
00156     };
00157 
00158     virtual imapState getContentState() { return mContentState; }
00159     virtual void setContentState( imapState state ) { mContentState = state; }
00160 
00161     virtual imapState getSubfolderState() { return mSubfolderState; }
00162     virtual void setSubfolderState( imapState state );
00163 
00167     void setImapPath( const QString &path );
00168     QString imapPath() const { return mImapPath; }
00169 
00173     void setLastUid( ulong uid );
00174     ulong lastUid();
00175 
00180     KMMsgBase *findByUID( ulong uid );
00181 
00185     void setUidValidity( const QString &validity ) { mUidValidity = validity; }
00186     QString uidValidity() const { return mUidValidity; }
00187 
00192     void clearUidMap() { uidMap.clear(); }
00193 
00197     void setAccount( KMAcctCachedImap *acct );
00198 
00203     KMAcctCachedImap *account() const;
00204 
00208     QString uidCacheLocation() const;
00209 
00213     int readUidCache();
00214 
00218     int writeUidCache();
00219 
00223     int progress() const { return mProgress; }
00224 
00226     virtual int rename( const QString &aName, KMFolderDir *aParent = 0 );
00227 
00229     virtual KMMessage *take( int idx );
00230     bool canDeleteMessages() const;
00231 
00233     virtual int addMsg( KMMessage *msg, int *index_return = 0 );
00234 
00235 
00239     virtual int addMsgInternal( KMMessage *msg, bool, int *index_return = 0 );
00240     virtual int addMsgKeepUID( KMMessage *msg, int *index_return = 0 ) {
00241       return addMsgInternal( msg, false, index_return );
00242     }
00243 
00245     virtual void removeMsg( int i, bool imapQuiet = false );
00246 
00250     bool isReadOnly() const {
00251       return KMFolderMaildir::isReadOnly() || mReadOnly;
00252     }
00253 
00257     void sendFolderComplete( bool success ) {
00258       emit folderComplete( this, success );
00259     }
00260 
00264     void setSilentUpload( bool silent ) {
00265       mSilentUpload = silent;
00266     }
00267     bool silentUpload() { return mSilentUpload; }
00268 
00269     virtual int createIndexFromContents() {
00270       return KMFolderMaildir::createIndexFromContents();
00271     }
00272 
00273     int createIndexFromContentsRecursive();
00274 
00280     virtual bool listDirectory();
00281 
00282     virtual void listNamespaces();
00283 
00287     KMFolder *trashFolder() const;
00288 
00293     int userRights() const { return mUserRights; }
00294   void setQuotaInfo( const QuotaInfo & );
00295 
00299     void setUserRights( unsigned int userRights );
00300 
00310     const QuotaInfo quotaInfo() const { return mQuotaInfo; }
00311 
00315     typedef QVector<KMail::ACLListEntry> ACLList;
00316     const ACLList &aclList() const { return mACLList; }
00317 
00321     void setACLList( const ACLList &arr );
00322 
00324     virtual void setStatus( int id, const MessageStatus &status, bool toggle );
00325     virtual void setStatus( QList<int> &ids, const MessageStatus &status, bool toggle );
00326 
00327     QString annotationFolderType() const { return mAnnotationFolderType; }
00328 
00330     void updateAnnotationFolderType();
00331 
00338     enum IncidencesFor {
00339       IncForNobody, 
00340       IncForAdmins, 
00341       IncForReaders 
00342     };
00343 
00344     IncidencesFor incidencesFor() const { return mIncidencesFor; }
00345     void setIncidencesFor( IncidencesFor incfor );
00346 
00350     virtual bool isMoveable() const;
00351 
00356     QStringList namespacesToList() { return mNamespacesToList; }
00357     void setNamespacesToList( QStringList list ) { mNamespacesToList = list; }
00358 
00360     bool isCloseToQuota() const;
00361 
00363     int permanentFlags() const { return mPermanentFlags; }
00364 
00369     const QString &imapPathForCreation() { return mImapPathCreation; }
00370     void setImapPathForCreation( const QString &path ) { mImapPathCreation = path; }
00371 
00372     QString folderAttributes() const { return mFolderAttributes; }
00373 
00374   protected slots:
00375     void slotGetMessagesData( KIO::Job *job, const QByteArray &data );
00376     void getMessagesResult( KMail::FolderJob *job, bool lastSet );
00377     void slotGetLastMessagesResult( KMail::FolderJob *job );
00378     void slotProgress( unsigned long done, unsigned long total );
00379     void slotPutProgress( unsigned long, unsigned long );
00380 
00381     void slotSubFolderComplete( KMFolderCachedImap*, bool );
00382 
00387     void slotConnectionResult( int errorCode, const QString &errorMsg );
00388 
00389     void slotPermanentFlags( int flags );
00390     void slotCheckUidValidityResult( KMail::FolderJob *job );
00391     void slotTestAnnotationResult( KJob *job );
00392     void slotGetAnnotationResult( KJob *job );
00393     void slotMultiUrlGetAnnotationResult( KJob *job );
00394     void slotSetAnnotationResult( KJob *job );
00395     void slotReceivedUserRights( KMFolder *folder );
00396     void slotReceivedACL( KMFolder *folder, KIO::Job *job, const KMail::ACLList&arr );
00397 
00398     void slotMultiSetACLResult( KJob *job );
00399     void slotACLChanged( const QString&, int );
00400     void slotAnnotationResult( const QString &entry, const QString &value,
00401                                bool found );
00402     void slotAnnotationChanged( const QString &entry, const QString &attribute,
00403                                 const QString &value );
00404     void slotDeleteMessagesResult( KMail::FolderJob *job );
00405     void slotImapStatusChanged( KMFolder *folder, const QString&, bool );
00406     void slotStorageQuotaResult( const QuotaInfo &info );
00407     void slotQuotaResult( KJob *job );
00408 
00409   protected:
00413     bool deleteMessages();
00414 
00418     void listMessages();
00419 
00420     void uploadNewMessages();
00421     void uploadFlags();
00422     void uploadSeenFlags();
00423     void createNewFolders();
00424 
00429     void listDirectory2();
00430 
00431     void createFoldersNewOnServerAndFinishListing( const QVector<int> foldersNewOnServer );
00432 
00437     virtual QList<unsigned long> findNewMessages();
00438 
00443     virtual QList<KMFolderCachedImap*> findNewFolders();
00444 
00448     virtual bool canRemoveFolder() const;
00449 
00451     virtual FolderJob *doCreateJob( KMMessage *msg, FolderJob::JobType jt,
00452                                     KMFolder *folder,
00453                                     const QString &partSpecifier,
00454                                     const AttachmentStrategy *as ) const;
00455     virtual FolderJob *doCreateJob( QList<KMMessage*> &msgList,
00456                                     const QString &sets, FolderJob::JobType jt,
00457                                     KMFolder *folder ) const;
00458 
00459     virtual void timerEvent( QTimerEvent *e );
00460 
00464     void newState( int progress, const QString &syncStatus );
00465 
00469     KMFolderCachedImap *findParent( const QString &path, const QString &name );
00470 
00471 public slots:
00475   void slotSimpleData(KIO::Job * job, const QByteArray & data);
00476 
00480     void slotTroubleshoot();
00481 
00485     void slotListResult( const QStringList &folderNames,
00486                          const QStringList &folderPaths,
00487                          const QStringList &folderMimeTypes,
00488                          const QStringList &folderAttributes,
00489                          const ImapAccountBase::jobData &jobData );
00490 
00494     void slotCheckNamespace( const QStringList &folderNames,
00495                              const QStringList &folderPaths,
00496                              const QStringList &folderMimeTypes,
00497                              const QStringList &folderAttributes,
00498                              const ImapAccountBase::jobData &jobData );
00499 
00500   private slots:
00501     void serverSyncInternal();
00502     void slotIncreaseProgress();
00503     void slotUpdateLastUid();
00504     void slotFolderDeletionOnServerFinished();
00505   void slotRescueDone( KMCommand* command );
00506 
00507   signals:
00508     void folderComplete( KMFolderCachedImap *folder, bool success );
00509     void listComplete( KMFolderCachedImap *folder );
00510 
00515     void syncState( int state, int number );
00516 
00517   private:
00518     void setReadOnly( bool readOnly );
00519     QString state2String( int state ) const;
00524   KMCommand* rescueUnsyncedMessages();
00526   void rescueUnsyncedMessagesAndDeleteFolder( KMFolder *folder, bool root = true );
00527 
00529     enum {
00530       SYNC_STATE_INITIAL,
00531       SYNC_STATE_TEST_ANNOTATIONS,
00532       SYNC_STATE_PUT_MESSAGES,
00533       SYNC_STATE_UPLOAD_FLAGS,
00534       SYNC_STATE_CREATE_SUBFOLDERS,
00535       SYNC_STATE_LIST_NAMESPACES,
00536       SYNC_STATE_LIST_SUBFOLDERS,
00537       SYNC_STATE_LIST_SUBFOLDERS2,
00538       SYNC_STATE_DELETE_SUBFOLDERS,
00539       SYNC_STATE_LIST_MESSAGES,
00540       SYNC_STATE_DELETE_MESSAGES,
00541       SYNC_STATE_EXPUNGE_MESSAGES,
00542       SYNC_STATE_GET_MESSAGES,
00543       SYNC_STATE_HANDLE_INBOX,
00544       SYNC_STATE_GET_USERRIGHTS,
00545       SYNC_STATE_GET_ANNOTATIONS,
00546       SYNC_STATE_SET_ANNOTATIONS,
00547       SYNC_STATE_GET_ACLS,
00548       SYNC_STATE_SET_ACLS,
00549       SYNC_STATE_GET_QUOTA,
00550       SYNC_STATE_FIND_SUBFOLDERS,
00551       SYNC_STATE_SYNC_SUBFOLDERS,
00552       SYNC_STATE_CHECK_UIDVALIDITY,
00553       SYNC_STATE_RENAME_FOLDER
00554     } mSyncState;
00555   void rememberDeletion( int );
00556 
00557     int mProgress;
00558     int mStatusFlagsJobs;
00559 
00560     QString mUidValidity;
00561     QString     mImapPath;
00562     imapState   mContentState, mSubfolderState;
00563     QStringList mSubfolderNames, mSubfolderPaths,
00564       mSubfolderMimeTypes, mSubfolderAttributes;
00565     QString     mFolderAttributes;
00566     QString     mAnnotationFolderType;
00567     IncidencesFor mIncidencesFor;
00568 
00569     bool        mHasInbox;
00570     bool        mIsSelected;
00571     bool        mCheckFlags;
00572     bool        mReadOnly;
00573     mutable QPointer<KMAcctCachedImap> mAccount;
00574 
00575     QSet<ulong> uidsOnServer;
00576 
00577     QList<ulong> uidsForDeletionOnServer;
00578     QList<KMail::CachedImapJob::MsgForDownload> mMsgsForDownload;
00579     QList<ulong> mUidsForDownload;
00580     QStringList       foldersForDeletionOnServer;
00581 
00582     QList<KMFolderCachedImap*> mSubfoldersForSync;
00583     KMFolderCachedImap *mCurrentSubfolder;
00584 
00590     QMap<ulong,int> uidMap;
00591     bool uidMapDirty;
00592     void reloadUidMap();
00593     int uidWriteTimer;
00594 
00606     ulong mLastUid;
00607 
00614     ulong mTentativeHighestUid;
00615 
00619     bool mFoundAnIMAPDigest;
00620 
00621     int mUserRights, mOldUserRights;
00622     ACLList mACLList;
00623 
00624     bool mSilentUpload;
00625     bool mFolderRemoved;
00626     bool mRecurse;
00627 
00634     bool mStatusChangedLocally;
00635 
00640     bool mAnnotationFolderTypeChanged;
00641 
00646     bool mIncidencesForChanged;
00647 
00648     QStringList mNamespacesToList;
00649     int mNamespacesToCheck;
00650     bool mPersonalNamespacesCheckDone;
00651     QString mImapPathCreation;
00652 
00653     QuotaInfo mQuotaInfo;
00654     bool mAlarmsBlocked;
00655 
00656     QList<KMFolder*> mToBeDeletedAfterRescue;
00657     int mRescueCommandCount;
00658 
00659   int mPermanentFlags;
00660   QMap<ulong,void*> mDeletedUIDsSinceLastSync;
00661 };
00662 
00663 #endif /*kmfoldercachedimap_h*/

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal