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

kmail

kmfolder.h

Go to the documentation of this file.
00001 /* -*- mode: C++ -*-
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 #ifndef kmfolder_h
00021 #define kmfolder_h
00022 
00023 // for large file support
00024 
00025 #include "kmfoldernode.h"
00026 #include "kmfoldertype.h"
00027 #include "kmmsginfo.h"
00028 #include "kmglobal.h"
00029 #include "kmkernel.h"
00030 #include "folderjob.h"
00031 using KMail::FolderJob;
00032 #include "mailinglist-magic.h"
00033 using KMail::MailingList;
00034 //#include "kmaccount.h" // for AccountList
00035 class KMAccount;
00036 typedef QList<KMAccount*> AccountList;
00037 
00038 #include "mimelib/string.h"
00039 #include <kshortcut.h>
00040 
00041 #include <QList>
00042 
00043 
00044 #include <sys/types.h>
00045 #include <stdio.h>
00046 
00047 class KMMessage;
00048 class KMFolderDir;
00049 class FolderStorage;
00050 class KMFolderJob;
00051 
00052 namespace KMail {
00053    class AttachmentStrategy;
00054 }
00055 using KMail::AttachmentStrategy;
00056 
00057 typedef QList<quint32> SerNumList;
00058 
00069 class KMFolder: public KMFolderNode
00070 {
00071   Q_OBJECT
00072   friend class ::KMFolderJob;
00073 public:
00074 
00090   KMFolder( KMFolderDir* parent, const QString& name,
00091                 KMFolderType aFolderType, bool withIndex = true,
00092                 bool exportedSernums = true );
00093   ~KMFolder();
00094 
00096   bool isMainInbox() {
00097     return this == KMKernel::self()->inboxFolder();
00098   }
00100   bool isOutbox() {
00101     return this == KMKernel::self()->outboxFolder();
00102   }
00105   bool isSent() {
00106     return KMKernel::self()->folderIsSentMailFolder( this );
00107   }
00110   bool isTrash() {
00111     return KMKernel::self()->folderIsTrash( this );
00112   }
00115   bool isDrafts() {
00116     return KMKernel::self()->folderIsDrafts( this );
00117   }
00118 
00121   bool isTemplates() {
00122     return KMKernel::self()->folderIsTemplates( this );
00123   }
00124 
00125   void setAcctList( AccountList* list ) { mAcctList = list; }
00126   AccountList* acctList() { return mAcctList; }
00127 
00129   bool hasAccounts() const { return (mAcctList != 0); }
00130 
00132   void readConfig( KConfigGroup & config );
00133 
00135   void writeConfig( KConfigGroup & config ) const;
00136 
00137   FolderStorage* storage() { return mStorage; }
00139   const FolderStorage* storage() const { return mStorage; }
00140 
00142   KMFolderType folderType() const;
00143 
00145   QString fileName() const;
00146 
00148   QString location() const;
00149 
00151   virtual QString indexLocation() const;
00152 
00154   virtual QString idsLocation() const;
00155 
00157   virtual QString sortedLocation() const;
00158 
00160   QString subdirLocation() const;
00161 
00164   KMFolderDir* child() const
00165     { return mChild; }
00166 
00168   KMFolderDir* createChildFolder();
00169 
00171   void setChild( KMFolderDir* aChild );
00172 
00174   bool noContent() const;
00175 
00177   void setNoContent(bool aNoContent);
00178 
00180   bool noChildren() const;
00181 
00183   void setNoChildren(bool aNoChildren);
00184 
00186   KMMessage* getMsg(int idx);
00187 
00189   KMMsgInfo* unGetMsg(int idx);
00190 
00192   bool isMessage(int idx);
00193 
00195   DwString getDwString(int idx);
00196 
00200   void ignoreJobsForMessage( KMMessage* );
00201 
00206   FolderJob* createJob( KMMessage *msg, FolderJob::JobType jt = FolderJob::tGetMessage,
00207                         KMFolder *folder = 0, const QString &partSpecifier = QString(),
00208                         const AttachmentStrategy *as = 0 ) const;
00209   FolderJob* createJob( QList<KMMessage*>& msgList, const QString& sets,
00210                         FolderJob::JobType jt = FolderJob::tGetMessage,
00211                         KMFolder *folder = 0 ) const;
00212 
00217   const KMMsgBase* getMsgBase(int idx) const;
00218   KMMsgBase* getMsgBase(int idx);
00219 
00221   const KMMsgBase* operator[](int idx) const;
00222 
00224   KMMsgBase* operator[](int idx);
00225 
00228   KMMessage* take(int idx);
00229   void takeMessages(const QList<KMMessage*>& msgList);
00230 
00237   int addMsg(KMMessage* msg, int* index_return = 0);
00238 
00242   int addMsgKeepUID(KMMessage* msg, int* index_return = 0);
00243 
00248   int addMessages(QList<KMMessage*>&, QList<int>& index_return);
00249 
00252   void emitMsgAddedSignals(int idx);
00253 
00255   void removeMsg(int i, bool imapQuiet = false);
00256   void removeMessages(QList<KMMessage*> msgList, bool imapQuiet = false);
00257 
00260   int expungeOldMsg(int days);
00261 
00266   int moveMsg(KMMessage* msg, int* index_return = 0);
00267   int moveMsg(QList<KMMessage*>, int* index_return = 0);
00268 
00270   int find(const KMMsgBase* msg) const;
00271   int find( const KMMessage * msg ) const;
00272 
00274   int count(bool cache = false) const;
00275 
00277   int countUnread();
00278 
00281   int countUnreadRecursive();
00282 
00285   void msgStatusChanged( const MessageStatus& oldStatus,
00286                          const MessageStatus& newStatus,
00287                          int idx);
00288 
00294   int open( const char *owner );
00295 
00298   virtual bool canAccess() const;
00299 
00305   void close( const char *owner, bool force=false );
00306 
00308   void sync();
00309 
00311   bool isOpened() const;
00312 
00314   void markNewAsUnread();
00315 
00317   void markUnreadAsRead();
00318 
00323   void remove();
00324 
00328   int expunge();
00329 
00330   enum CompactOptions { CompactLater, CompactNow, CompactSilentlyNow };
00337   void compact( CompactOptions options );
00338 
00341   int rename(const QString& newName, KMFolderDir *aParent = 0);
00342 
00346   bool dirty() const;
00347 
00349   void setDirty(bool f);
00350 
00352   bool needsCompacting() const;
00353   void setNeedsCompacting(bool f);
00354 
00363   void quiet(bool beQuiet);
00364 
00366   bool isReadOnly() const;
00367 
00369   bool canDeleteMessages() const;
00370 
00375   bool isSystemFolder() const { return mIsSystemFolder; }
00376   void setSystemFolder(bool itIs) { mIsSystemFolder = itIs; }
00377 
00379   virtual QString label() const;
00380   void setLabel( const QString& l ) { mLabel = l; }
00381 
00383   virtual QString systemLabel() const { return mSystemLabel; }
00384   void setSystemLabel( const QString& l ) { mSystemLabel = l; }
00385 
00387   virtual QString prettyUrl() const;
00388 
00390   void setMailingListEnabled( bool enabled );
00391   bool isMailingListEnabled() const { return mMailingListEnabled; }
00392 
00393   void setMailingList( const MailingList& mlist );
00394   MailingList mailingList() const
00395   { return mMailingList; }
00396   QString mailingListPostAddress() const;
00397 
00400   void setUseDefaultIdentity( bool useDefaultIdentity );
00401   bool useDefaultIdentity() const { return mUseDefaultIdentity; }
00402 
00403   void setIdentity(uint identity);
00404   uint identity() const;
00405 
00407   QString whoField() const { return mWhoField; }
00408   void setWhoField(const QString& aWhoField);
00409 
00411   QString userWhoField(void) { return mUserWhoField; }
00412   void setUserWhoField(const QString &whoField,bool writeConfig=true);
00413 
00415   void correctUnreadMsgsCount();
00416 
00418   QString idString() const;
00419 
00423   void setAutoExpire(bool enabled);
00424 
00428   bool isAutoExpire() const { return mExpireMessages; }
00429 
00435   void setUnreadExpireAge(int age);
00436 
00441   void setUnreadExpireUnits(ExpireUnits units);
00442 
00448   void setReadExpireAge(int age);
00449 
00454   void setReadExpireUnits(ExpireUnits units);
00455 
00460   int getUnreadExpireAge() const { return mUnreadExpireAge; }
00461 
00466   int getReadExpireAge() const { return mReadExpireAge; }
00467 
00472   ExpireUnits getUnreadExpireUnits() const { return mUnreadExpireUnits; }
00473 
00478   ExpireUnits getReadExpireUnits() const { return mReadExpireUnits; }
00479 
00480   enum ExpireAction { ExpireDelete, ExpireMove };
00484   ExpireAction expireAction() const { return mExpireAction; }
00485   void setExpireAction( ExpireAction a );
00486 
00490   QString expireToFolderId() const { return mExpireToFolderId; }
00491   void setExpireToFolderId( const QString& id );
00492 
00497   void expireOldMessages( bool immediate );
00498 
00501   int writeIndex( bool createEmptyIndex = false );
00502 
00504   void setStatus(int idx, const MessageStatus& status, bool toggle=false);
00505 
00507   void setStatus(QList<int>& ids, const MessageStatus& status, bool toggle=false);
00508 
00510   bool useCustomIcons() const { return mUseCustomIcons; }
00511   void setUseCustomIcons(bool useCustomIcons) { mUseCustomIcons = useCustomIcons; }
00512   QString normalIconPath() const { return mNormalIconPath; }
00513   QString unreadIconPath() const { return mUnreadIconPath; }
00514   void setIconPaths(const QString &normalPath, const QString &unreadPath);
00515 
00516   void removeJobs();
00517 
00518   void daysToExpire( int& unreadDays, int& readDays );
00519 
00524   KMFolder* trashFolder() const;
00525 
00530   bool putRepliesInSameFolder() const { return mPutRepliesInSameFolder; }
00531   void setPutRepliesInSameFolder( bool b ) { mPutRepliesInSameFolder = b; }
00532 
00537   bool ignoreNewMail() const { return mIgnoreNewMail; }
00538   void setIgnoreNewMail( bool b ) { mIgnoreNewMail = b; }
00539 
00540   const KShortcut &shortcut() const { return mShortcut; }
00541   void setShortcut( const KShortcut& );
00542 
00544   bool isMoveable() const;
00545 
00549   bool moveInProgress() const { return mMoveInProgress; }
00550 
00552   void setMoveInProgress( bool b ) { mMoveInProgress = b; }
00553 
00554 signals:
00557   void changed();
00558 
00561   void closed();
00562 
00565   void cleared();
00566 
00569   void expunged( KMFolder* );
00570 
00572   void iconsChanged();
00573 
00575   void nameChanged();
00576 
00578   void shortcutChanged( KMFolder * );
00579 
00581   void msgRemoved(KMFolder*, quint32 sernum);
00582 
00584   void msgRemoved( int idx, const QString& msgIdMD5 );
00585   void msgRemoved(KMFolder*);
00586 
00588   void msgAdded(int idx);
00589   void msgAdded(KMFolder*, quint32 sernum);
00590 
00592   void msgChanged(KMFolder*, quint32 sernum, int delta);
00593 
00595   void msgHeaderChanged(KMFolder*, int);
00596 
00598   void statusMsg(const QString&);
00599 
00601   void numUnreadMsgsChanged( KMFolder* );
00602 
00604   void removed(KMFolder*, bool);
00605 
00607   void viewConfigChanged();
00608 
00610   void folderSizeChanged( KMFolder * );
00611 
00612 public slots:
00614   int updateIndex();
00615 
00618   void reallyAddMsg(KMMessage* aMsg);
00619 
00622   void reallyAddCopyOfMsg(KMMessage* aMsg);
00623 
00624 private slots:
00625 
00627   void slotContentsTypeChanged( KMail::FolderContentsType type );
00628 
00630   void slotFolderSizeChanged();
00631 
00635   void slotIdentitiesChanged();
00636 
00637 private:
00638   FolderStorage* mStorage;
00639   KMFolderDir* mChild;
00640   bool mIsSystemFolder;
00641   bool mHasIndex :1;
00642   bool mExportsSernums :1;
00643   bool mMoveInProgress :1;
00644 
00646   QString mLabel;
00647   QString mSystemLabel;
00648 
00650   bool         mExpireMessages;          // true if old messages are expired
00651   int          mUnreadExpireAge;         // Given in unreadExpireUnits
00652   int          mReadExpireAge;           // Given in readExpireUnits
00653   ExpireUnits  mUnreadExpireUnits;
00654   ExpireUnits  mReadExpireUnits;
00655   ExpireAction mExpireAction;
00656   QString      mExpireToFolderId;
00657 
00659   bool mUseCustomIcons;
00660   QString mNormalIconPath;
00661   QString mUnreadIconPath;
00662 
00664   bool                mMailingListEnabled;
00665   MailingList         mMailingList;
00666 
00667   AccountList* mAcctList;
00668 
00669   bool mUseDefaultIdentity;
00670   uint mIdentity;
00671 
00673   QString mWhoField, mUserWhoField;
00674 
00676   bool mPutRepliesInSameFolder;
00677 
00679   bool mIgnoreNewMail;
00680 
00682   KShortcut mShortcut;
00683 };
00684 
00690 class KMFolderOpener {
00691   KMFolder * mFolder;
00692   const char * const mOwner;
00693   int mOpenRc;
00694 
00695 public:
00696   KMFolderOpener( KMFolder *folder, const char *owner )
00697    : mFolder( folder )
00698    , mOwner( owner )
00699   {
00700     assert( folder ); //change if that's not what you want
00701     mOpenRc = folder->open( owner );
00702   }
00703 
00704   ~KMFolderOpener()
00705   {
00706     if ( !mOpenRc )
00707       mFolder->close( mOwner );
00708   }
00709 
00710   KMFolder * folder() const { return mFolder; }
00711   
00712   int openResult() const { return mOpenRc; }
00713   
00714 private:
00715   //we forbid construction on the heap as good as we can
00716   void * operator new( size_t size );
00717 };
00718 
00719 #endif /*kmfolder_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
  •   doc
  • 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