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

kmail

folderstorage.h

Go to the documentation of this file.
00001 /*
00002     Virtual base class for mail storage.
00003 
00004     This file is part of KMail.
00005 
00006     Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk>
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021     Boston, MA 02110-1301, USA.
00022 
00023     In addition, as a special exception, the copyright holders give
00024     permission to link the code of this program with any edition of
00025     the Qt library by Trolltech AS, Norway (or with modified versions
00026     of Qt that use the same license as Qt), and distribute linked
00027     combinations including the two.  You must obey the GNU General
00028     Public License in all respects for all of the code used other than
00029     Qt.  If you modify this file, you may extend this exception to
00030     your version of the file, but you are not obligated to do so.  If
00031     you do not wish to do so, delete this exception statement from
00032     your version.
00033 */
00034 
00035 #ifndef FOLDERSTORAGE_H
00036 #define FOLDERSTORAGE_H
00037 
00038 // for large file support
00039 
00040 #include "kmfoldernode.h"
00041 #include "kmfoldertype.h"
00042 #include "kmmsginfo.h"
00043 #include "kmglobal.h"
00044 #include "folderjob.h"
00045 using KMail::FolderJob;
00046 
00047 #include <QList>
00048 #include <QByteArray>
00049 
00050 #include "mimelib/string.h"
00051 
00052 #include <sys/types.h>
00053 #include <stdio.h>
00054 
00055 class KMMessage;
00056 class KMAccount;
00057 class KMFolderDir;
00058 class KMMsgDict; // for the rDict manipulations
00059 class KMMsgDictREntry;
00060 class QTimer;
00061 class KMSearchPattern;
00062 
00063 namespace KMail {
00064    class AttachmentStrategy;
00065 }
00066 using KMail::AttachmentStrategy;
00067 
00068 typedef QList<quint32> SerNumList;
00069 
00081 class FolderStorage : public QObject
00082 {
00083   Q_OBJECT
00084 
00085 public:
00086 
00087 
00091   explicit FolderStorage( KMFolder* folder, const char* name=0 );
00092   virtual ~FolderStorage();
00093 
00094   KMFolder* folder() const { return mFolder; }
00095 
00097   virtual KMFolderType folderType() const { return KMFolderTypeUnknown; }
00098 
00100   virtual QString fileName() const;
00102   QString location() const;
00103 
00105   virtual QString indexLocation() const;
00106 
00108   virtual QString idsLocation() const;
00109 
00111   virtual QString sortedLocation() const;
00112 
00114   virtual bool noContent() const { return mNoContent; }
00115 
00117   virtual void setNoContent(bool aNoContent);
00118 
00120   virtual bool noChildren() const { return mNoChildren; }
00121 
00123   virtual void setNoChildren( bool aNoChildren );
00124 
00125   enum ChildrenState {
00126     HasChildren,
00127     HasNoChildren,
00128     ChildrenUnknown
00129   };
00132   virtual ChildrenState hasChildren() const { return mHasChildren; }
00133 
00135   virtual void setHasChildren( ChildrenState state )
00136     { mHasChildren = state; }
00137 
00139   virtual void updateChildrenState();
00140 
00142   virtual KMMessage* getMsg(int idx);
00143 
00145   virtual KMMsgInfo* unGetMsg(int idx);
00146 
00148   virtual bool isMessage(int idx);
00149 
00157   virtual KMMessage* readTemporaryMsg(int idx);
00158 
00160   virtual DwString getDwString(int idx) = 0;
00161 
00165   virtual void ignoreJobsForMessage( KMMessage* );
00166 
00171   virtual FolderJob* createJob( KMMessage *msg, FolderJob::JobType jt = FolderJob::tGetMessage,
00172                                 KMFolder *folder = 0, const QString &partSpecifier = QString(),
00173                                 const AttachmentStrategy *as = 0 ) const;
00174   virtual FolderJob* createJob( QList<KMMessage*>& msgList, const QString& sets,
00175                                 FolderJob::JobType jt = FolderJob::tGetMessage,
00176                                 KMFolder *folder = 0 ) const;
00177 
00182   virtual const KMMsgBase* getMsgBase(int idx) const = 0;
00183   virtual KMMsgBase* getMsgBase(int idx) = 0;
00184 
00186   virtual const KMMsgBase* operator[](int idx) const { return getMsgBase(idx); }
00187 
00189   virtual KMMsgBase* operator[](int idx) { return getMsgBase(idx); }
00190 
00193   virtual KMMessage* take(int idx);
00194   virtual void takeMessages(const QList<KMMessage*>& msgList);
00195 
00202   virtual int addMsg(KMMessage* msg, int* index_return = 0) = 0;
00203 
00207   virtual int addMsgKeepUID(KMMessage* msg, int* index_return = 0) {
00208     return addMsg(msg, index_return);
00209   }
00210 
00215   virtual int addMessages( QList<KMMessage*>&, QList<int>& index_return );
00216 
00219   void emitMsgAddedSignals(int idx);
00220 
00223   virtual bool canAddMsgNow(KMMessage* aMsg, int* aIndex_ret);
00224 
00226   virtual void removeMsg(int i, bool imapQuiet = false);
00227   virtual void removeMessages(const QList<KMMsgBase*>& msgList, bool imapQuiet = false);
00228   virtual void removeMessages(const QList<KMMessage*>& msgList, bool imapQuiet = false);
00229 
00232   virtual int expungeOldMsg(int days);
00233 
00238   virtual int moveMsg(KMMessage* msg, int* index_return = 0);
00239   virtual int moveMsg(QList<KMMessage*>, int* index_return = 0);
00240 
00242   virtual int find(const KMMsgBase* msg) const = 0;
00243   int find( const KMMessage * msg ) const;
00244 
00246   virtual int count(bool cache = false) const;
00247 
00249   virtual int countUnread();
00250 
00252   qint64 folderSize() const;
00253 
00256   virtual bool isCloseToQuota() const;
00257 
00260   virtual void msgStatusChanged( const MessageStatus& oldStatus,
00261                                  const MessageStatus& newStatus,
00262                                  int idx);
00263 
00270   virtual int open( const char *owner ) = 0;
00271 
00274   virtual bool canAccess() const = 0;
00275 
00280   virtual void close( const char *owner, bool force = false );
00281   virtual void reallyDoClose() = 0;
00282 
00285   virtual void tryReleasingFolder(KMFolder*) {}
00286 
00288   virtual void sync() = 0;
00289 
00291   bool isOpened() const { return (mOpenCount>0); }
00292 
00294   virtual void markNewAsUnread();
00295 
00297   virtual void markUnreadAsRead();
00298 
00302   virtual int create() = 0;
00303 
00308   virtual void remove();
00309 
00313   virtual int expunge();
00314 
00319   virtual int compact( bool silent ) = 0;
00320 
00323   virtual int rename(const QString& newName, KMFolderDir *aParent = 0);
00324 
00326   bool autoCreateIndex() const { return mAutoCreateIndex; }
00327 
00330   virtual void setAutoCreateIndex(bool);
00331 
00335   bool dirty() const { return mDirty; }
00336 
00338   void setDirty(bool f);
00339 
00341   bool needsCompacting() const { return needsCompact; }
00342   virtual void setNeedsCompacting(bool f) { needsCompact = f; }
00343 
00352   virtual void quiet(bool beQuiet);
00353 
00355   virtual bool isReadOnly() const = 0;
00356 
00358   virtual bool canDeleteMessages() const;
00359 
00361   QString label() const;
00362 
00364   virtual void correctUnreadMsgsCount();
00365 
00368   virtual int writeIndex( bool createEmptyIndex = false ) = 0;
00369 
00372   void registerWithMessageDict();
00373 
00376   void deregisterFromMessageDict();
00377 
00379   virtual void setStatus(int idx, const MessageStatus& status, bool toggle=false);
00380 
00382   virtual void setStatus(QList<int>& ids, const MessageStatus& status, bool toggle=false);
00383 
00384   void removeJobs();
00385 
00387   static QString dotEscape(const QString&);
00388 
00390   virtual void readConfig();
00391 
00393   virtual void writeConfig();
00394 
00399   virtual KMFolder* trashFolder() const { return 0; }
00400 
00405   void addJob( FolderJob* ) const;
00406 
00408   bool compactable() const { return mCompactable; }
00409 
00411   // If quiet is true, the KMailIcalIface is not informed of the changed.
00412   // That's useful for folder that are being copied around, should retain
00413   // their type, but not cause conflicts on copy because events are identical
00414   // in two folders.
00415   virtual void setContentsType( KMail::FolderContentsType type, bool quiet = false );
00417   KMail::FolderContentsType contentsType() const { return mContentsType; }
00418 
00423   virtual void search( const KMSearchPattern* );
00424 
00429   virtual void search( const KMSearchPattern*, quint32 serNum );
00430 
00432   virtual bool isMoveable() const;
00433 
00434   virtual KMAccount* account() const;
00435 
00436 signals:
00439   void changed();
00440 
00443   void cleared();
00444 
00447   void expunged( KMFolder* );
00448 
00450   void closed( KMFolder* );
00451 
00453   void invalidated( KMFolder* );
00454 
00456   void nameChanged();
00457 
00461   void locationChanged( const QString &, const QString & );
00462 
00465   void contentsTypeChanged( KMail::FolderContentsType type );
00466 
00468   void readOnlyChanged(KMFolder*);
00469 
00471   void noContentChanged();
00472 
00474   void msgRemoved(KMFolder*, quint32 sernum);
00475 
00477   void msgRemoved( int idx, const QString &msgIdMD5 );
00478   void msgRemoved( KMFolder* );
00479 
00481   void msgAdded(int idx);
00482   void msgAdded(KMFolder*, quint32 sernum);
00483 
00485   void msgChanged(KMFolder*, quint32 sernum, int delta);
00486 
00488   void msgHeaderChanged(KMFolder*, int);
00489 
00491   void statusMsg(const QString&);
00492 
00494   void numUnreadMsgsChanged( KMFolder* );
00495 
00497   void removed(KMFolder*, bool);
00498 
00504   void searchResult( KMFolder*, QList<quint32>,
00505                      const KMSearchPattern*, bool complete );
00506 
00511   void searchDone( KMFolder*, quint32, const KMSearchPattern*, bool );
00512 
00514   void folderSizeChanged();
00515 
00516 
00517 public slots:
00519   virtual int updateIndex() = 0;
00520 
00523   virtual void reallyAddMsg(KMMessage* aMsg);
00524 
00527   virtual void reallyAddCopyOfMsg(KMMessage* aMsg);
00528 
00530   void slotEmitChangedTimer();
00531 
00532 protected slots:
00533   virtual void removeJob( QObject* );
00534 
00536   void slotProcessNextSearchBatch();
00537 
00538 protected:
00539 
00545   virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder,
00546                                   const QString &partSpecifier, const AttachmentStrategy *as ) const = 0;
00547   virtual FolderJob* doCreateJob( QList<KMMessage*>& msgList, const QString& sets,
00548                                   FolderJob::JobType jt, KMFolder *folder ) const = 0;
00549 
00553   void headerOfMsgChanged(const KMMsgBase*, int idx);
00554 
00557   virtual KMMessage* readMsg(int idx) = 0;
00558 
00559   //--------- Message Dict manipulation
00560 friend class KMMsgDict;
00564   virtual void fillMessageDict() {}
00565 
00569   void readFolderIdsFile();
00570 
00572   int writeFolderIdsFile() const;
00573 
00575   int touchFolderIdsFile();
00576 
00578   int appendToFolderIdsFile( int idx = -1 );
00579 
00583   void setRDict(KMMsgDictREntry *rentry) const;
00584 
00586   KMMsgDictREntry *rDict() const { return mRDict; }
00587 
00588 
00591   void replaceMsgSerNum( unsigned long sernum, KMMsgBase* msg, int idx );
00592 
00596   void invalidateFolder();
00597 
00601   virtual int removeContents() = 0;
00602 
00606   virtual int expungeContents() = 0;
00607 
00609   virtual bool readIndex() = 0;
00610   virtual KMMsgBase* takeIndexEntry( int idx ) = 0;
00611   virtual KMMsgInfo* setIndexEntry( int idx, KMMessage *msg ) = 0;
00612   virtual void clearIndex(bool autoDelete=true, bool syncDict = false) = 0;
00613   virtual void truncateIndex() = 0;
00614 
00615   virtual qint64 doFolderSize() const { return 0; };
00616 
00619   virtual QString location(const QString& suffix) const;
00620 
00621   int mOpenCount;
00622   int mQuiet;
00623   bool mChanged :1;
00625   bool mAutoCreateIndex :1;
00628   bool mExportsSernums :1;
00630   bool mDirty :1;
00632   bool mFilesLocked :1;
00633 
00635   int mUnreadMsgs, mGuessedUnreadMsgs;
00636   int mTotalMsgs;
00637   qint64 mSize;
00638   bool mWriteConfigEnabled :1;
00640   bool needsCompact :1;
00642   bool mCompactable :1;
00643   bool mNoContent :1;
00644   bool mNoChildren :1;
00645   bool mConvertToUtf8 :1;
00646 
00648   mutable KMMsgDictREntry *mRDict;
00650   mutable QList<FolderJob*> mJobList;
00651 
00652   QTimer *mDirtyTimer;
00653   enum { mDirtyTimerInterval = 600000 }; // 10 minutes
00654 
00655   ChildrenState mHasChildren;
00656 
00658   KMail::FolderContentsType mContentsType;
00659 
00660   KMFolder* mFolder;
00661 
00662   QTimer * mEmitChangedTimer;
00663 
00664   int mCurrentSearchedMsg;
00665   const KMSearchPattern* mSearchPattern;
00666 };
00667 
00668 #endif // FOLDERSTORAGE_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
  • 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