~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kmail/kmfoldermaildir.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef kmfoldermaildir_h
2
 
#define kmfoldermaildir_h
3
 
 
4
 
#include "kmfolderindex.h"
5
 
 
6
 
#include <QList>
7
 
 
8
 
class KJob;
9
 
 
10
 
class KMFolderMaildir;
11
 
namespace KMail {
12
 
  class FolderJob;
13
 
  class MaildirJob;
14
 
  class AttachmentStrategy;
15
 
}
16
 
 
17
 
using KMail::FolderJob;
18
 
using KMail::MaildirJob;
19
 
using KMail::AttachmentStrategy;
20
 
 
21
 
class KMFolderMaildir : public KMFolderIndex
22
 
{
23
 
  Q_OBJECT
24
 
  friend class ::KMail::MaildirJob;
25
 
public:
26
 
  /** Usually a parent is given. But in some cases there is no
27
 
    fitting parent object available. Then the name of the folder
28
 
    is used as the absolute path to the folder file. */
29
 
  explicit KMFolderMaildir(KMFolder* folder, const char* name=0);
30
 
  virtual ~KMFolderMaildir();
31
 
 
32
 
  /** Returns the type of this folder */
33
 
  virtual KMFolderType folderType() const { return KMFolderTypeMaildir; }
34
 
 
35
 
  /** Read a message and return it as a string */
36
 
  virtual DwString getDwString(int idx);
37
 
 
38
 
  /** Detach message from this folder. Usable to call addMsg() afterwards.
39
 
    Loads the message if it is not loaded up to now. */
40
 
  virtual KMMessage* take(int idx);
41
 
 
42
 
  /** Add the given message to the folder. Usually the message
43
 
    is added at the end of the folder. Returns zero on success and
44
 
    an errno error code on failure. The index of the new message
45
 
    is stored in index_return if given.
46
 
    Please note that the message is added as is to the folder and the folder
47
 
    takes ownership of the message (deleting it in the destructor).*/
48
 
  virtual int addMsg(KMMessage* msg, int* index_return = 0);
49
 
 
50
 
  /** Remove (first occurrence of) given message from the folder. */
51
 
  virtual void removeMsg(int i, bool imapQuiet = false);
52
 
 
53
 
  // Called by KMMsgBase::setStatus when status of a message has changed
54
 
  // required to keep the number unread messages variable current.
55
 
  virtual void msgStatusChanged( const MessageStatus& oldStatus,
56
 
                                 const MessageStatus& newStatus,
57
 
                                 int idx);
58
 
 
59
 
  /** Open folder for access.
60
 
    Does nothing if the folder is already opened. To reopen a folder
61
 
    call close() first.
62
 
    Returns zero on success and an error code equal to the c-library
63
 
    fopen call otherwise (errno). */
64
 
  virtual int open( const char *owner );
65
 
 
66
 
  virtual bool canAccess() const;
67
 
 
68
 
  /** fsync buffers to disk */
69
 
  virtual void sync();
70
 
 
71
 
  /** Close folder. If force is true the files are closed even if
72
 
    others still use it (e.g. other mail reader windows). */
73
 
  virtual void reallyDoClose();
74
 
 
75
 
  /** Create the necessary folders for a maildir folder. Usually you will
76
 
      want to use create() instead.
77
 
 
78
 
      @param folderPath the full path of the folder as returned by location()
79
 
      @return 0 on success and an error code (cf. man 3 errno) otherwise
80
 
   */
81
 
  static int createMaildirFolders( const QString & folderPath );
82
 
 
83
 
  static QString constructValidFileName( const QString & filename = QString(),
84
 
                                         const MessageStatus & status = MessageStatus::statusNew() );
85
 
 
86
 
  static bool removeFile( const QString & folderPath,
87
 
                          const QString & filename );
88
 
 
89
 
  /** @reimpl  */
90
 
  virtual int create();
91
 
 
92
 
  /** Remove some deleted messages from the folder. Returns zero on success
93
 
    and an errno on failure. This is only for use from MaildirCompactionJob. */
94
 
  int compact( int startIndex, int nbMessages, const QStringList& entryList, bool& done );
95
 
 
96
 
  /** Remove deleted messages from the folder. Returns zero on success
97
 
    and an errno on failure. */
98
 
  virtual int compact( bool silent );
99
 
 
100
 
  /** Is the folder read-only? */
101
 
  virtual bool isReadOnly() const { return false; }
102
 
 
103
 
  /** reimp */
104
 
  virtual qint64 doFolderSize() const;
105
 
 
106
 
  /** Create index file from messages file and fill the message-info list
107
 
      mMsgList. Returns 0 on success and an errno value (see fopen) on
108
 
      failure. */
109
 
  virtual int createIndexFromContents();
110
 
 
111
 
protected:
112
 
  virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt, KMFolder *folder,
113
 
                                  const QString &partSpecifier, const AttachmentStrategy *as ) const;
114
 
  virtual FolderJob* doCreateJob( QList<KMMessage*>& msgList, const QString& sets,
115
 
                                  FolderJob::JobType jt, KMFolder *folder ) const;
116
 
  /** Load message from file and store it at given index. Returns 0
117
 
    on failure. */
118
 
  virtual KMMessage* readMsg(int idx);
119
 
 
120
 
  /** Called by KMFolder::remove() to delete the actual contents.
121
 
    At the time of the call the folder has already been closed, and
122
 
    the various index files deleted.  Returns 0 on success. */
123
 
  virtual int removeContents();
124
 
 
125
 
  /** Called by KMFolder::expunge() to delete the actual contents.
126
 
    At the time of the call the folder has already been closed, and
127
 
    the various index files deleted.  Returns 0 on success. */
128
 
  virtual int expungeContents();
129
 
 
130
 
  /**
131
 
   * Internal helper called by addMsg. If stripUid is true it will remove any
132
 
   * uid headers and uid index setting before writing. KMFolderCachedImap needs this
133
 
   * but can't do it itself, since the final take() which removes the original mail
134
 
   * from the source folder, in moves, needs to happen after the adding, for safety
135
 
   * reasons, but needs the uid, in case the source folder was an imap folder, to
136
 
   * delete the original.
137
 
   * TODO: Avoid this by moving the take() out of the addMsg() methods and moving it
138
 
   * into the KMMoveCommand, where it can safely happen at a much higher level. */
139
 
  int addMsgInternal( KMMessage* msg, int* index_return = 0, bool stripUid=false );
140
 
 
141
 
private slots:
142
 
  void slotDirSizeJobResult( KJob* job );
143
 
 
144
 
private:
145
 
  void readFileHeaderIntern( const QString& dir, const QString& file,
146
 
                             MessageStatus& status);
147
 
  QString moveInternal( const QString& oldLoc, const QString& newLoc,
148
 
                        KMMsgInfo* mi);
149
 
  QString moveInternal( const QString& oldLoc, const QString& newLoc,
150
 
                        QString& aFileName, const MessageStatus& status );
151
 
  bool removeFile( const QString& filename );
152
 
 
153
 
  /** Tests whether the contents of this folder is newer than the index.
154
 
      Returns IndexTooOld if the index is older than the contents.
155
 
      Returns IndexMissing if there is no index.
156
 
      Returns IndexOk if the index is not older than the contents.
157
 
  */
158
 
  virtual IndexStatus indexStatus();
159
 
 
160
 
  int mIdxCount;
161
 
  mutable bool mCurrentlyCheckingFolderSize;
162
 
};
163
 
#endif /*kmfoldermaildir_h*/