kmail

kmacctcachedimap.h

00001 /*
00002  *  kmacctcachedimap.h
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
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 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 KMAcctCachedImap_h
00033 #define KMAcctCachedImap_h
00034 
00035 #include "imapaccountbase.h"
00036 
00037 #include <qguardedptr.h>
00038 
00039 class KMFolderCachedImap;
00040 class KMFolderTreeItem;
00041 class KMFolder;
00042 namespace KMail {
00043   class FolderJob;
00044   class ImapJob;
00045   class CachedImapJob;
00046 }
00047 using KMail::ImapJob;
00048 using KMail::CachedImapJob;
00049 
00050 namespace KIO {
00051   class Job;
00052 }
00053 
00054 class KMAcctCachedImap: public KMail::ImapAccountBase
00055 {
00056   Q_OBJECT
00057   friend class ::KMail::ImapJob;
00058   friend class ::KMail::CachedImapJob;
00059 
00060 public:
00061   virtual ~KMAcctCachedImap();
00062   virtual void init();
00063 
00065   virtual void pseudoAssign( const KMAccount * a );
00066 
00070   virtual void setAutoExpunge(bool);
00071 
00075   virtual QString type() const;
00076   virtual void processNewMail( bool interactive );
00077 
00081   virtual void killAllJobs( bool disconnectSlave=false );
00082 
00086   virtual void cancelMailCheck();
00087 
00091   virtual void setImapFolder(KMFolderCachedImap *);
00092   KMFolderCachedImap* imapFolder() const { return mFolder; }
00093 
00094   virtual void readConfig( /*const*/ KConfig/*Base*/ & config );
00095   virtual void writeConfig( KConfig/*Base*/ & config ) /*const*/;
00096 
00100   virtual void invalidateIMAPFolders();
00101   virtual void invalidateIMAPFolders( KMFolderCachedImap* );
00102 
00106   void addDeletedFolder( KMFolder* folder );
00107 
00112   void addDeletedFolder( const QString& imapPath );
00113 
00117   bool isDeletedFolder( const QString& subFolderPath ) const;
00118 
00122   bool isPreviouslyDeletedFolder( const QString& subFolderPath ) const;
00123 
00127   QStringList deletedFolderPaths( const QString& subFolderPath ) const;
00128 
00132   void removeDeletedFolder( const QString& subFolderPath );
00133 
00137   void addRenamedFolder( const QString& subFolderPath,
00138                          const QString& oldLabel, const QString& newName );
00139 
00144   void removeRenamedFolder( const QString& subFolderPath );
00145 
00146   struct RenamedFolder {
00147     RenamedFolder() {} // for QMap
00148     RenamedFolder( const QString& oldLabel, const QString& newName )
00149       : mOldLabel( oldLabel ), mNewName( newName ) {}
00150     QString mOldLabel;
00151     QString mNewName;
00152   };
00153 
00157   QString renamedFolder( const QString& imapPath ) const;
00161   const QMap<QString, RenamedFolder>& renamedFolders() const { return mRenamedFolders; }
00162 
00166   void addUnreadMsgCount( const KMFolderCachedImap *folder, int countUnread );
00167 
00171   void addLastUnreadMsgCount( const KMFolderCachedImap *folder,
00172                               int countLastUnread );
00173 
00177   virtual FolderStorage* rootFolder() const;
00178   
00180   bool annotationCheckPassed(){ return mAnnotationCheckPassed;};
00181   void setAnnotationCheckPassed( bool a ){ mAnnotationCheckPassed = a; };
00182 
00184   enum GroupwareType
00185   {
00186     GroupwareNone,     
00187     GroupwareKolab,    
00188     GroupwareScalix    
00189   };
00190 
00191   void setGroupwareType( GroupwareType type ){ mGroupwareType = type; }
00192   GroupwareType groupwareType() const { return mGroupwareType; }
00193 
00194   void setSentCustomLoginCommand( bool value ){ mSentCustomLoginCommand = value; }
00195   bool sentCustomLoginCommand() const { return mSentCustomLoginCommand; }
00196 
00197 protected:
00198   friend class ::AccountManager;
00199   KMAcctCachedImap(AccountManager* owner, const QString& accountName, uint id);
00200 
00201 protected slots:
00203   void postProcessNewMail(KMFolderCachedImap*, bool);
00204 
00205   void slotProgressItemCanceled( KPIM::ProgressItem* );
00206 
00207   virtual void slotCheckQueuedFolders();
00208 
00209 private:
00210   QValueList<KMFolderCachedImap*> killAllJobsInternal( bool disconnectSlave );
00211   void processNewMail( KMFolderCachedImap* folder, bool recurse );
00212 
00213 private:
00214   QPtrList<CachedImapJob> mJobList;
00215   KMFolderCachedImap *mFolder;
00216   QStringList mDeletedFolders; // folders deleted in this session
00217   QStringList mPreviouslyDeletedFolders; // folders deleted in a previous session
00218   QMap<QString, RenamedFolder> mRenamedFolders;
00219   bool mAnnotationCheckPassed;
00220 
00221   GroupwareType mGroupwareType;
00222   bool mSentCustomLoginCommand;
00223 };
00224 
00225 #endif /*KMAcctCachedImap_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys