kmail

kmfoldermbox.h
1 /*
2  * kmail: KDE mail client
3  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 #ifndef kmfoldermbox_h
21 #define kmfoldermbox_h
22 
23 #include "kmfolderindex.h"
24 #include "mboxjob.h"
25 
26 #include <sys/types.h> // for size_t
27 
28 namespace KMail {
29  class FolderJob;
30  class MboxJob;
31  class AttachmentStrategy;
32 }
33 using KMail::FolderJob;
34 using KMail::MboxJob;
35 using KMail::AttachmentStrategy;
36 
37 /* Mail folder.
38  * (description will be here).
39  *
40  * Accounts:
41  * The accounts (of KMail) that are fed into the folder are
42  * represented as the children of the folder. They are only stored here
43  * during runtime to have a reference for which accounts point to a
44  * specific folder.
45  */
46 
47 class KMFolderMbox : public KMFolderIndex
48 {
49  TQ_OBJECT
50 
51  friend class ::KMail::MboxJob;
52 public:
53 
54 
58  KMFolderMbox(KMFolder* folder, const char* name=0);
59  virtual ~KMFolderMbox();
60 
62  virtual KMFolderType folderType() const { return KMFolderTypeMbox; }
63 
65  DwString getDwString(int idx);
66 
73  virtual int addMsg( KMMessage* msg, int* index_return = 0 );
74 
80  virtual int open(const char *owner);
81 
83  virtual void reallyDoClose(const char *owner);
84 
85  virtual int canAccess();
86 
88  virtual void sync();
89 
91  virtual int create();
92 
95  virtual int compact( bool silent );
96 
99  int compact( unsigned int startIndex, int nbMessages, FILE* tmpFile, off_t& offs, bool& done );
100 
102  virtual bool isReadOnly() const { return mReadOnly; }
103 
105  bool isLocked() const { return mFilesLocked; }
106 
107  void setLockType( LockType ltype=FCNTL );
108 
109  void setProcmailLockFileName( const TQString& );
110 
111  static TQByteArray escapeFrom( const DwString & str );
112 
113  virtual IndexStatus indexStatus();
114 
116  virtual TQ_INT64 doFolderSize() const;
117 
118 protected:
119  virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder,
120  TQString partSpecifier, const AttachmentStrategy *as ) const;
121  virtual FolderJob* doCreateJob( TQPtrList<KMMessage>& msgList, const TQString& sets,
122  FolderJob::JobType jt, KMFolder *folder ) const;
125  virtual KMMessage* readMsg(int idx);
126 
130  virtual int createIndexFromContents();
131 
134  virtual int lock();
135 
138  virtual int unlock();
139 
143  virtual int removeContents();
144 
148  virtual int expungeContents();
149 
150 private:
151  FILE *mStream;
152  bool mFilesLocked; // TRUE if the files of the folder are locked (writable)
153  bool mReadOnly; // true if locking failed
154  LockType mLockType;
155  TQString mProcmailLockFileName;
156 };
157 
158 #endif // kmfoldermbox_h
A FolderStorage with an index for faster access to often used message properties.
Definition: kmfolderindex.h:37
virtual KMFolderType folderType() const
Returns the type of this folder.
Definition: folderstorage.h:96
virtual IndexStatus indexStatus()=0
Tests whether the contents of this folder is newer than the index.
virtual int expungeContents()=0
Called by KMFolder::expunge() to delete the actual contents.
virtual void sync()=0
fsync buffers to disk
virtual int removeContents()=0
Called by KMFolder::remove() to delete the actual contents.
virtual int create()=0
Create a new folder with the name of this object and open it.
virtual FolderJob * doCreateJob(KMMessage *msg, FolderJob::JobType jt, KMFolder *folder, TQString partSpecifier, const AttachmentStrategy *as) const =0
These two methods actually create the jobs.
virtual int compact(bool silent)=0
Remove deleted messages from the folder.
virtual int addMsg(KMMessage *msg, int *index_return=0)=0
Add the given message to the folder.
virtual int createIndexFromContents()=0
Create index file from messages file and fill the message-info list mMsgList.
virtual int canAccess()=0
Check folder for permissions Returns zero if readable and writable.
IndexStatus
This enum indicates the status of the index file.
Definition: kmfolderindex.h:50
virtual bool isReadOnly() const =0
Is the folder read-only?
This is a Mime Message.
Definition: kmmessage.h:67
virtual KMMessage * readMsg(int idx)=0
Load message from file and store it at given index.
folderdiaquotatab.h
Definition: aboutdata.cpp:40
virtual DwString getDwString(int idx)=0
Read a message and returns a DwString.
bool mFilesLocked
TRUE if the files of the folder are locked (writable)
virtual int open(const char *owner)=0
Open folder for access.
Mail folder.
Definition: kmfolder.h:68