kmail

kmacctcachedimap.h

Go to the documentation of this file.
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   void killJobsForItem(KMFolderTreeItem * fti);
00082 
00086   virtual void killAllJobs( bool disconnectSlave=false );
00087 
00091   virtual void cancelMailCheck();
00092 
00096   virtual void setImapFolder(KMFolderCachedImap *);
00097   KMFolderCachedImap* imapFolder() const { return mFolder; }
00098 
00099   virtual void readConfig( /*const*/ KConfig/*Base*/ & config );
00100   virtual void writeConfig( KConfig/*Base*/ & config ) /*const*/;
00101 
00105   virtual void invalidateIMAPFolders();
00106   virtual void invalidateIMAPFolders( KMFolderCachedImap* );
00107 
00111   void addDeletedFolder( KMFolder* folder );
00112 
00117   void addDeletedFolder( const QString& imapPath );
00118 
00122   bool isDeletedFolder( const QString& subFolderPath ) const;
00123 
00127   bool isPreviouslyDeletedFolder( const QString& subFolderPath ) const;
00128 
00132   QStringList deletedFolderPaths( const QString& subFolderPath ) const;
00133 
00137   void removeDeletedFolder( const QString& subFolderPath );
00138 
00142   void addRenamedFolder( const QString& subFolderPath,
00143                          const QString& oldLabel, const QString& newName );
00144 
00149   void removeRenamedFolder( const QString& subFolderPath );
00150 
00151   struct RenamedFolder {
00152     RenamedFolder() {} // for QMap
00153     RenamedFolder( const QString& oldLabel, const QString& newName )
00154       : mOldLabel( oldLabel ), mNewName( newName ) {}
00155     QString mOldLabel;
00156     QString mNewName;
00157   };
00158 
00162   QString renamedFolder( const QString& imapPath ) const;
00166   const QMap<QString, RenamedFolder>& renamedFolders() const { return mRenamedFolders; }
00167 
00171   void addUnreadMsgCount( const KMFolderCachedImap *folder, int countUnread );
00172 
00176   void addLastUnreadMsgCount( const KMFolderCachedImap *folder,
00177                               int countLastUnread );
00178 
00182   virtual FolderStorage* const rootFolder() const;
00183   
00185   bool annotationCheckPassed(){ return mAnnotationCheckPassed;};
00186   void setAnnotationCheckPassed( bool a ){ mAnnotationCheckPassed = a; };
00187 
00189   enum GroupwareType
00190   {
00191     GroupwareNone,     
00192     GroupwareKolab,    
00193     GroupwareScalix    
00194   };
00195 
00196   void setGroupwareType( GroupwareType type ){ mGroupwareType = type; }
00197   GroupwareType groupwareType() const { return mGroupwareType; }
00198 
00199   void setSentCustomLoginCommand( bool value ){ mSentCustomLoginCommand = value; }
00200   bool sentCustomLoginCommand() const { return mSentCustomLoginCommand; }
00201 
00202 protected:
00203   friend class ::AccountManager;
00204   KMAcctCachedImap(AccountManager* owner, const QString& accountName, uint id);
00205 
00206 protected slots:
00208   void postProcessNewMail(KMFolderCachedImap*, bool);
00209 
00210   void slotProgressItemCanceled( KPIM::ProgressItem* );
00211 
00212   virtual void slotCheckQueuedFolders();
00213 
00214 private:
00215   QValueList<KMFolderCachedImap*> killAllJobsInternal( bool disconnectSlave );
00216   void processNewMail( KMFolderCachedImap* folder, bool recurse );
00217 
00218 private:
00219   QPtrList<CachedImapJob> mJobList;
00220   KMFolderCachedImap *mFolder;
00221   QStringList mDeletedFolders; // folders deleted in this session
00222   QStringList mPreviouslyDeletedFolders; // folders deleted in a previous session
00223   QMap<QString, RenamedFolder> mRenamedFolders;
00224   bool mAnnotationCheckPassed;
00225 
00226   GroupwareType mGroupwareType;
00227   bool mSentCustomLoginCommand;
00228 };
00229 
00230 #endif /*KMAcctCachedImap_h*/