kmail Library API Documentation

kmfolder.h

00001 /* -*- mode: C++ -*-
00002  * Virtual base class for mail folder
00003  *
00004  * Author: Stefan Taferner <taferner@kde.org>
00005  * This code is under GPL
00006  *
00007  */
00008 #ifndef kmfolder_h
00009 #define kmfolder_h
00010 
00011 // for large file support
00012 #include <config.h>
00013 
00014 #include "kmfoldernode.h"
00015 #include "kmfoldertype.h"
00016 #include "kmmsginfo.h"
00017 #include "kmglobal.h"
00018 #include "folderjob.h"
00019 using KMail::FolderJob;
00020 #include "mailinglist-magic.h"
00021 using KMail::MailingList;
00022 
00023 #include "mimelib/string.h"
00024 
00025 #include <qptrvector.h>
00026 #include <sys/types.h>
00027 #include <stdio.h>
00028 
00029 class KMMessage;
00030 class KMFolderDir;
00031 class KMAcctList;
00032 class KMMsgDict;
00033 class KMMsgDictREntry;
00034 class QTimer;
00035 class FolderStorage;
00036 class KMFolderTreeItem;
00037 
00038 namespace KMail {
00039    class AttachmentStrategy;
00040 }
00041 using KMail::AttachmentStrategy;
00042 
00043 typedef QValueList<Q_UINT32> SerNumList;
00044 
00055 class KMFolder: public KMFolderNode
00056 {
00057   Q_OBJECT
00058   friend class KMFolderJob;
00059 public:
00060 
00061 
00065   KMFolder( KMFolderDir* parent, const QString& name,
00066             KMFolderType aFolderType );
00067   ~KMFolder();
00068 
00070   void readConfig( KConfig* config );
00071 
00073   void writeConfig( KConfig* config ) const;
00074 
00075   FolderStorage* storage() { return mStorage; }
00077   const FolderStorage* storage() const { return mStorage; }
00078 
00080   KMFolderType folderType() const;
00081 
00083   QString fileName() const;
00084 
00086   QString location() const;
00087 
00089   QString indexLocation() const;
00090 
00092   QString subdirLocation() const;
00093 
00096   KMFolderDir* child() const
00097     { return mChild; }
00098 
00100   KMFolderDir* createChildFolder();
00101 
00103   void setChild( KMFolderDir* aChild );
00104 
00106   bool noContent() const;
00107 
00109   void setNoContent(bool aNoContent);
00110 
00112   bool noChildren() const;
00113 
00115   void setNoChildren(bool aNoChildren);
00116 
00118   KMMessage* getMsg(int idx);
00119 
00121   KMMsgInfo* unGetMsg(int idx);
00122 
00124   bool isMessage(int idx);
00125 
00127   QCString& getMsgString(int idx, QCString& mDest);
00128 
00130   DwString getDwString(int idx);
00131 
00135   void ignoreJobsForMessage( KMMessage* );
00136 
00141   FolderJob* createJob( KMMessage *msg, FolderJob::JobType jt = FolderJob::tGetMessage,
00142                         KMFolder *folder = 0, QString partSpecifier = QString::null,
00143                         const AttachmentStrategy *as = 0 ) const;
00144   FolderJob* createJob( QPtrList<KMMessage>& msgList, const QString& sets,
00145                         FolderJob::JobType jt = FolderJob::tGetMessage,
00146                         KMFolder *folder = 0 ) const;
00147 
00152   const KMMsgBase* getMsgBase(int idx) const;
00153   KMMsgBase* getMsgBase(int idx);
00154 
00156   const KMMsgBase* operator[](int idx) const;
00157 
00159   KMMsgBase* operator[](int idx);
00160 
00163   KMMessage* take(int idx);
00164   void take(QPtrList<KMMessage> msgList);
00165 
00172   int addMsg(KMMessage* msg, int* index_return = 0);
00173 
00177   int addMsgKeepUID(KMMessage* msg, int* index_return = 0);
00178 
00181   void emitMsgAddedSignals(int idx);
00182 
00184   void removeMsg(int i, bool imapQuiet = FALSE);
00185   void removeMsg(QPtrList<KMMessage> msgList, bool imapQuiet = FALSE);
00186 
00189   int expungeOldMsg(int days);
00190 
00195   int moveMsg(KMMessage* msg, int* index_return = 0);
00196   int moveMsg(QPtrList<KMMessage>, int* index_return = 0);
00197 
00199   int find(const KMMsgBase* msg) const;
00200   int find( const KMMessage * msg ) const;
00201 
00203   int count(bool cache = false) const;
00204 
00206   int countUnread();
00207 
00210   int countUnreadRecursive();
00211 
00214   void msgStatusChanged( const KMMsgStatus oldStatus,
00215                          const KMMsgStatus newStatus,
00216                          int idx);
00217 
00223   int open();
00224 
00227   int canAccess();
00228 
00231   void close(bool force=FALSE);
00232 
00234   void sync();
00235 
00237   bool isOpened() const;
00238 
00240   void markNewAsUnread();
00241 
00243   void markUnreadAsRead();
00244 
00248   int create(bool imap = FALSE);
00249 
00254   void remove();
00255 
00259   int expunge();
00260 
00261   enum CompactOptions { CompactLater, CompactNow, CompactSilentlyNow };
00268   void compact( CompactOptions options );
00269 
00272   int rename(const QString& newName, KMFolderDir *aParent = 0);
00273 
00275   bool autoCreateIndex() const;
00276 
00279   void setAutoCreateIndex(bool);
00280 
00284   bool dirty() const;
00285 
00287   void setDirty(bool f);
00288 
00290   bool needsCompacting() const;
00291   void setNeedsCompacting(bool f);
00292 
00301   void quiet(bool beQuiet);
00302 
00304   bool isReadOnly() const;
00305 
00310   bool isSystemFolder() const { return mIsSystemFolder; }
00311   void setSystemFolder(bool itIs) { mIsSystemFolder=itIs; }
00312 
00314   virtual QString label() const;
00315   void setLabel( const QString& l ) { mLabel = l; }
00316 
00318   virtual QString systemLabel() const { return mSystemLabel; }
00319   void setSystemLabel( const QString& l ) { mSystemLabel = l; }
00320 
00322   virtual QString prettyURL() const;
00323 
00325   const char* type() const;
00326 
00328   bool hasAccounts() const;
00329 
00331   void setMailingListEnabled( bool enabled );
00332   bool isMailingListEnabled() const { return mMailingListEnabled; }
00333 
00334   void setMailingList( const MailingList& mlist );
00335   MailingList mailingList() const
00336   { return mMailingList; }
00337   QString mailingListPostAddress() const;
00338 
00339   void setIdentity(uint identity);
00340   uint identity() const { return mIdentity; }
00341 
00343   QString whoField() const { return mWhoField; }
00344   void setWhoField(const QString& aWhoField);
00345 
00347   QString userWhoField(void) { return mUserWhoField; }
00348   void setUserWhoField(const QString &whoField,bool writeConfig=true);
00349 
00351   void correctUnreadMsgsCount();
00352 
00354   QString idString() const;
00355 
00359   void setAutoExpire(bool enabled);
00360 
00364   bool isAutoExpire() const { return mExpireMessages; }
00365 
00371   void setUnreadExpireAge(int age);
00372 
00377   void setUnreadExpireUnits(ExpireUnits units);
00378 
00384   void setReadExpireAge(int age);
00385 
00390   void setReadExpireUnits(ExpireUnits units);
00391 
00396   int getUnreadExpireAge() const { return mUnreadExpireAge; }
00397 
00402   int getReadExpireAge() const { return mReadExpireAge; }
00403 
00408   ExpireUnits getUnreadExpireUnits() const { return mUnreadExpireUnits; }
00409 
00414   ExpireUnits getReadExpireUnits() const { return mReadExpireUnits; }
00415 
00416   enum ExpireAction { ExpireDelete, ExpireMove };
00420   ExpireAction expireAction() const { return mExpireAction; }
00421   void setExpireAction( ExpireAction a );
00422 
00426   QString expireToFolderId() const { return mExpireToFolderId; }
00427   void setExpireToFolderId( const QString& id );
00428 
00433   void expireOldMessages( bool immediate );
00434 
00437   int writeIndex( bool createEmptyIndex = false );
00438 
00441   void fillMsgDict(KMMsgDict *dict);
00442 
00444   int writeMsgDict(KMMsgDict *dict = 0);
00445 
00447   int touchMsgDict();
00448 
00450   int appendtoMsgDict(int idx = -1);
00451 
00453   void setRDict(KMMsgDictREntry *rentry);
00454 
00456   KMMsgDictREntry *rDict() const;
00457 
00459   void setStatus(int idx, KMMsgStatus status, bool toggle=false);
00460 
00462   void setStatus(QValueList<int>& ids, KMMsgStatus status, bool toggle=false);
00463 
00465   bool useCustomIcons() const { return mUseCustomIcons; }
00466   void setUseCustomIcons(bool useCustomIcons) { mUseCustomIcons = useCustomIcons; }
00467   QString normalIconPath() const { return mNormalIconPath; }
00468   QString unreadIconPath() const { return mUnreadIconPath; }
00469   void setIconPaths(const QString &normalPath, const QString &unreadPath);
00470 
00471   void removeJobs();
00472 
00476   static size_t crlf2lf( char* str, const size_t strLen );
00477 
00478   void daysToExpire( int& unreadDays, int& readDays );
00479 
00484   KMFolder* trashFolder() const;
00485 
00490   bool putRepliesInSameFolder() const { return mPutRepliesInSameFolder; }
00491   void setPutRepliesInSameFolder( bool b ) { mPutRepliesInSameFolder = b; }
00492 
00497   bool ignoreNewMail() const { return mIgnoreNewMail; }
00498   void setIgnoreNewMail( bool b ) { mIgnoreNewMail = b; }
00499 
00500 signals:
00503   void changed();
00504 
00507   void cleared();
00508 
00511   void expunged( KMFolder* );
00512 
00514   void iconsChanged();
00515 
00517   void nameChanged();
00518 
00520   void msgRemoved(KMFolder*, Q_UINT32 sernum);
00521 
00523   void msgRemoved(int idx,QString msgIdMD5, QString strippedSubjMD5);
00524   void msgRemoved(KMFolder*);
00525 
00527   void msgAdded(int idx);
00528   void msgAdded(KMFolder*, Q_UINT32 sernum);
00529 
00531   void msgChanged(KMFolder*, Q_UINT32 sernum, int delta);
00532 
00534   void msgHeaderChanged(KMFolder*, int);
00535 
00537   void statusMsg(const QString&);
00538 
00540   void numUnreadMsgsChanged( KMFolder* );
00541 
00543   void removed(KMFolder*, bool);
00544 
00545 public slots:
00547   int updateIndex();
00548 
00551   void reallyAddMsg(KMMessage* aMsg);
00552 
00555   void reallyAddCopyOfMsg(KMMessage* aMsg);
00556 
00557 private:
00558   FolderStorage* mStorage;
00559   KMFolderDir* mParent;
00560   KMFolderDir* mChild;
00561   bool mIsSystemFolder;
00562 
00564   QString mLabel;
00565   QString mSystemLabel;
00566 
00568   bool         mExpireMessages;          // TRUE if old messages are expired
00569   int          mUnreadExpireAge;         // Given in unreadExpireUnits
00570   int          mReadExpireAge;           // Given in readExpireUnits
00571   ExpireUnits  mUnreadExpireUnits;
00572   ExpireUnits  mReadExpireUnits;
00573   ExpireAction mExpireAction;
00574   QString      mExpireToFolderId;
00575 
00577   bool mUseCustomIcons;
00578   QString mNormalIconPath;
00579   QString mUnreadIconPath;
00580 
00582   bool                mMailingListEnabled;
00583   MailingList         mMailingList;
00584 
00585   uint mIdentity;
00586 
00588   QString mWhoField, mUserWhoField;
00589 
00591   bool mPutRepliesInSameFolder;
00592 
00594   bool mIgnoreNewMail;
00595 };
00596 
00597 #endif /*kmfolder_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 Mon Apr 4 04:48:26 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003