32#ifndef kmfoldercachedimap_h 
   33#define kmfoldercachedimap_h 
   35#include <kdialogbase.h> 
   36#include <tdestandarddirs.h> 
   37#include <tqvaluelist.h> 
   38#include <tqvaluevector.h> 
   42#include "kmfoldermaildir.h" 
   43#include "kmfolderimap.h" 
   44#include "kmacctcachedimap.h" 
   45#include "kmfoldertype.h" 
   47#include "cachedimapjob.h" 
   52using KMail::FolderJob;
 
   53using KMail::QuotaInfo;
 
   60  class AttachmentStrategy;
 
   61  class ImapAccountBase;
 
   64using KMail::AttachmentStrategy;
 
   66class DImapTroubleShootDialog : 
public KDialogBase
 
   71  enum SelectedOperation {
 
   79  DImapTroubleShootDialog( TQWidget* parent=0, 
const char* name=0 );
 
   87  TQRadioButton *mIndexButton, *mCacheButton;
 
   88  TQComboBox *mIndexScope;
 
   89  TQButtonGroup *mButtonGroup;
 
   93class KMFolderCachedImap : 
public KMFolderMaildir
 
   99  static TQString cacheLocation() {
 
  100     return locateLocal(
"data", 
"kmail/dimap" );
 
  106  KMFolderCachedImap(
KMFolder* folder, 
const char* name=0);
 
  107  virtual ~KMFolderCachedImap();
 
  110  void reallyDoClose(
const char* owner);
 
  113  void initializeFrom( KMFolderCachedImap* parent );
 
  115  virtual void readConfig();
 
  116  virtual void writeConfig();
 
  118  void writeConfigKeysWhichShouldNotGetOverwrittenByReadConfig();
 
  121  virtual KMFolderType folderType()
 const { 
return KMFolderTypeCachedImap; }
 
  124  virtual int create();
 
  127  virtual void remove();
 
  130  virtual void serverSync( 
bool recurse, 
bool quotaOnly = 
false );
 
  133  void resetSyncState( );
 
  138  void setAlarmsBlocked( 
bool blocked );
 
  140  bool alarmsBlocked() 
const;
 
  142  void checkUidValidity();
 
  144  enum imapState { imapNoInformation=0, imapInProgress=1, imapFinished=2 };
 
  146  virtual imapState getContentState()
 const { 
return mContentState; }
 
  147  virtual void setContentState(imapState state) { mContentState = state; }
 
  149  virtual imapState getSubfolderState() { 
return mSubfolderState; }
 
  150  virtual void setSubfolderState(imapState state);
 
  153  void setImapPath(
const TQString &path);
 
  154  TQString imapPath()
 const { 
return mImapPath; }
 
  157  void setLastUid( ulong uid );
 
  161  KMMsgBase* findByUID( ulong uid );
 
  164  void setUidValidity(
const TQString &validity) { mUidValidity = validity; }
 
  165  TQString uidValidity()
 const { 
return mUidValidity; }
 
  169  void clearUidMap() { uidMap.clear(); }
 
  172  void setAccount(KMAcctCachedImap *acct);
 
  173  KMAcctCachedImap* account() 
const;
 
  176  TQString uidCacheLocation() 
const;
 
  185  int progress()
 const { 
return mProgress; }
 
  188  virtual int rename(
const TQString& aName, 
KMFolderDir *aParent=0);
 
  202  void takeTemporarily( 
int idx );
 
  207  virtual int addMsgInternal(
KMMessage* msg, 
bool, 
int* index_return = 0);
 
  208  virtual int addMsgKeepUID(
KMMessage* msg, 
int* index_return = 0) {
 
  209    return addMsgInternal(msg, 
false, index_return);
 
  213  virtual void removeMsg(
int i, 
bool imapQuiet = 
false);
 
  214  virtual void removeMsg( 
const TQPtrList<KMMsgBase> & msgList, 
bool imapQuiet = 
false)
 
  218  bool isReadOnly()
 const { 
return KMFolderMaildir::isReadOnly() || mReadOnly; }
 
  219  bool canDeleteMessages() 
const;
 
  225  void sendFolderComplete(
bool success)
 
  226  { emit folderComplete(
this, success); }
 
  231  void setSilentUpload( 
bool silent ) { mSilentUpload = silent; }
 
  232  bool silentUpload() { 
return mSilentUpload; }
 
  234  virtual int createIndexFromContents() {
 
  235    const int result = KMFolderMaildir::createIndexFromContents();
 
  240  int createIndexFromContentsRecursive();
 
  249  virtual bool listDirectory();
 
  251  virtual void listNamespaces();
 
  261  int userRights()
 const { 
return mUserRights; }
 
  276  const QuotaInfo quotaInfo()
 const { 
return mQuotaInfo; }
 
  277  void setQuotaInfo( 
const QuotaInfo & );
 
  280  typedef TQValueVector<KMail::ACLListEntry> ACLList;
 
  281  const ACLList& aclList()
 const { 
return mACLList; }
 
  285  void setACLList( 
const ACLList& arr );
 
  288  virtual void setStatus( 
int id, KMMsgStatus status, 
bool toggle );
 
  289  virtual void setStatus( TQValueList<int>& ids, KMMsgStatus status, 
bool toggle );
 
  291  TQString annotationFolderType()
 const { 
return mAnnotationFolderType; }
 
  294  void updateAnnotationFolderType();
 
  304  enum IncidencesFor { IncForNobody, IncForAdmins, IncForReaders };
 
  306  IncidencesFor incidencesFor()
 const { 
return mIncidencesFor; }
 
  308  void setIncidencesFor( IncidencesFor incfor );
 
  311  bool sharedSeenFlags()
 const { 
return mSharedSeenFlags; }
 
  313  void setSharedSeenFlags( 
bool b );
 
  316  virtual bool isMoveable() 
const;
 
  322  TQStringList namespacesToList() { 
return mNamespacesToList; }
 
  323  void setNamespacesToList( TQStringList list ) { mNamespacesToList = list; }
 
  329  const TQString& imapPathForCreation() { 
return mImapPathCreation; }
 
  330  void setImapPathForCreation( 
const TQString& path ) { mImapPathCreation = path; }
 
  333  bool isCloseToQuota() 
const;
 
  336  int permanentFlags()
 const { 
return mPermanentFlags; }
 
  339  TQString folderAttributes()
 const { 
return mFolderAttributes; }
 
  341  virtual bool mailCheckInProgress() 
const;
 
  344  void slotGetMessagesData(TDEIO::Job * job, 
const TQByteArray & data);
 
  345  void getMessagesResult(KMail::FolderJob *, 
bool lastSet);
 
  346  void slotGetLastMessagesResult(KMail::FolderJob *);
 
  347  void slotProgress(
unsigned long done, 
unsigned long total);
 
  348  void slotPutProgress( 
unsigned long, 
unsigned long );
 
  351  void slotSubFolderComplete(KMFolderCachedImap*, 
bool);
 
  352  void slotSubFolderCloseToQuotaChanged();
 
  355  void slotConnectionResult( 
int errorCode, 
const TQString& errorMsg );
 
  357  void slotCheckUidValidityResult( KMail::FolderJob* job );
 
  358  void slotPermanentFlags( 
int flags );
 
  359  void slotTestAnnotationResult(TDEIO::Job *job);
 
  360  void slotGetAnnotationResult( TDEIO::Job* );
 
  361  void slotMultiUrlGetAnnotationResult( TDEIO::Job* );
 
  362  void slotSetAnnotationResult(TDEIO::Job *job);
 
  363  void slotReceivedUserRights( 
KMFolder* );
 
  364  void slotReceivedACL( 
KMFolder*, TDEIO::Job*, 
const KMail::ACLList& );
 
  366  void slotMultiSetACLResult(TDEIO::Job *);
 
  367  void slotACLChanged( 
const TQString&, 
int );
 
  368  void slotAnnotationResult(
const TQString& entry, 
const TQString& value, 
bool found);
 
  369  void slotAnnotationChanged( 
const TQString& entry, 
const TQString& attribute, 
const TQString& value );
 
  370  void slotDeleteMessagesResult(KMail::FolderJob *);
 
  371  void slotImapStatusChanged(
KMFolder* folder, 
const TQString&, 
bool);
 
  372  void slotStorageQuotaResult( 
const QuotaInfo& );
 
  373  void slotQuotaResult( TDEIO::Job* job );
 
  378  bool deleteMessages();
 
  380  void uploadNewMessages();
 
  382  void uploadSeenFlags();
 
  383  void createNewFolders();
 
  385  void listDirectory2();
 
  386  void createFoldersNewOnServerAndFinishListing( 
const TQValueVector<int> foldersNewOnServer );
 
  391  virtual TQValueList<unsigned long> findNewMessages();
 
  394  virtual TQValueList<KMFolderCachedImap*> findNewFolders();
 
  397  virtual bool canRemoveFolder() 
const;
 
  400  virtual FolderJob* doCreateJob( 
KMMessage *msg, FolderJob::JobType jt, 
KMFolder *folder,
 
  401                                  TQString partSpecifier, 
const AttachmentStrategy *as ) 
const;
 
  402  virtual FolderJob* doCreateJob( TQPtrList<KMMessage>& msgList, 
const TQString& sets,
 
  403                                  FolderJob::JobType jt, 
KMFolder *folder ) 
const;
 
  405  virtual void timerEvent( TQTimerEvent* );
 
  408  void newState( 
int progress, 
const TQString& syncStatus );
 
  411  KMFolderCachedImap* findParent( 
const TQString& path, 
const TQString& name );
 
  419  void slotSimpleData(TDEIO::Job * job, 
const TQByteArray & data);
 
  424  void slotTroubleshoot();
 
  430  void slotListResult( 
const TQStringList&, 
const TQStringList&,
 
  431      const TQStringList&, 
const TQStringList&, 
const ImapAccountBase::jobData& );
 
  437  void slotCheckNamespace( 
const TQStringList&, 
const TQStringList&,
 
  438      const TQStringList&, 
const TQStringList&, 
const ImapAccountBase::jobData& );
 
  441  void serverSyncInternal();
 
  442  void slotIncreaseProgress();
 
  443  void slotUpdateLastUid();
 
  444  void slotFolderDeletionOnServerFinished();
 
  445  void slotRescueDone( KMCommand* command );
 
  446  void slotRenameFolderFinished();
 
  449  void folderComplete(KMFolderCachedImap *folder, 
bool success);
 
  450  void listComplete( KMFolderCachedImap* );
 
  455  void closeToQuotaChanged();
 
  458  void setReadOnly( 
bool readOnly );
 
  459  TQString state2String( 
int state ) 
const;
 
  460  void rememberDeletion( 
int );
 
  465  KMCommand* rescueUnsyncedMessages();
 
  467  void rescueUnsyncedMessagesAndDeleteFolder( 
KMFolder *folder, 
bool root = 
true );
 
  473  void disconnectSubFolderSignals();
 
  480  void syncNextSubFolder( 
bool secondSync );
 
  485  void buildSubFolderList();
 
  490    SYNC_STATE_TEST_ANNOTATIONS,
 
  491    SYNC_STATE_PUT_MESSAGES,
 
  492    SYNC_STATE_UPLOAD_FLAGS,
 
  493    SYNC_STATE_CREATE_SUBFOLDERS,
 
  494    SYNC_STATE_LIST_NAMESPACES,
 
  495    SYNC_STATE_LIST_SUBFOLDERS,
 
  496    SYNC_STATE_LIST_SUBFOLDERS2,
 
  497    SYNC_STATE_DELETE_SUBFOLDERS,
 
  498    SYNC_STATE_LIST_MESSAGES,
 
  499    SYNC_STATE_DELETE_MESSAGES,
 
  500    SYNC_STATE_EXPUNGE_MESSAGES,
 
  501    SYNC_STATE_GET_MESSAGES,
 
  502    SYNC_STATE_HANDLE_INBOX,
 
  503    SYNC_STATE_GET_USERRIGHTS,
 
  504    SYNC_STATE_GET_ANNOTATIONS,
 
  505    SYNC_STATE_SET_ANNOTATIONS,
 
  508    SYNC_STATE_GET_QUOTA,
 
  509    SYNC_STATE_FIND_SUBFOLDERS,
 
  510    SYNC_STATE_SYNC_SUBFOLDERS,
 
  511    SYNC_STATE_CHECK_UIDVALIDITY,
 
  512    SYNC_STATE_RENAME_FOLDER,
 
  514    SYNC_STATE_GET_SUBFOLDER_QUOTA
 
  518  int mStatusFlagsJobs;
 
  520  TQString mUidValidity;
 
  522  imapState   mContentState, mSubfolderState;
 
  523  TQStringList mSubfolderNames, mSubfolderPaths,
 
  524              mSubfolderMimeTypes, mSubfolderAttributes;
 
  525  TQString     mFolderAttributes;
 
  526  TQString     mAnnotationFolderType;
 
  527  IncidencesFor mIncidencesFor;
 
  528  bool mSharedSeenFlags;
 
  534  mutable TQGuardedPtr<KMAcctCachedImap> mAccount;
 
  536  TQIntDict<int> uidsOnServer;
 
  537  TQValueList<ulong> uidsForDeletionOnServer;
 
  538  TQValueList<KMail::CachedImapJob::MsgForDownload> mMsgsForDownload;
 
  539  TQValueList<ulong> mUidsForDownload;
 
  540  TQStringList       foldersForDeletionOnServer;
 
  542  TQValueList< TQGuardedPtr<KMFolderCachedImap> > mSubfoldersForSync;
 
  543  KMFolderCachedImap* mCurrentSubfolder;
 
  548  TQMap<ulong,int> uidMap;
 
  567  ulong mTentativeHighestUid;
 
  572  bool mFoundAnIMAPDigest;
 
  574  int mUserRights, mOldUserRights;
 
  586  bool mAnnotationFolderTypeChanged;
 
  588  bool mIncidencesForChanged;
 
  590  bool mSharedSeenFlagsChanged;
 
  598  std::set<ulong> mUIDsOfLocallyChangedStatuses;
 
  604  bool mStatusChangedLocally;
 
  606  TQStringList mNamespacesToList;
 
  607  int mNamespacesToCheck;
 
  608  bool mPersonalNamespacesCheckDone;
 
  609  TQString mImapPathCreation;
 
  611  QuotaInfo mQuotaInfo;
 
  615  bool mSomeSubFolderCloseToQuotaChanged;
 
  617  TQMap<ulong,void*> mDeletedUIDsSinceLastSync;
 
  620  TQValueList<KMFolder*> mToBeDeletedAfterRescue;
 
  621  int mRescueCommandCount;
 
  623  TQValueList< TQGuardedPtr<KMFolderCachedImap> > mNewlyCreatedSubfolders;
 
virtual void removeMsg(int i, bool imapQuiet=false)
Remove (first occurrence of) given message from the folder.
 
virtual int addMsg(TQPtrList< KMMessage > &, TQValueList< int > &index_return)
Adds the given messages to the folder.
 
KMail list that manages the contents of one directory that may contain folders and/or other directori...