Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
maildir.h
Go to the documentation of this file.
1
7#ifndef maildir_h_included
8#define maildir_h_included
9#include <string>
10#include <vector>
11#include <map>
12
13#include "mailbox.h"
14#include "maildirmessage.h"
15
16namespace Binc {
17 static const std::string CACHEFILEVERSION = "1.0.5";
18 static const std::string UIDVALFILEVERSION = "1.0.5";
19
20 //----------------------------------------------------------------------
21 class Lock {
22 public:
23 Lock(const std::string &path);
24 ~Lock();
25
26 private:
27 std::string lock;
28 };
29
30 //------------------------------------------------------------------------
32 public:
33 unsigned int uid;
34 std::string fileName;
35 };
36
37 //------------------------------------------------------------------------
39 {
40 private:
41 std::map<std::string, MaildirIndexItem> idx;
42
43 public:
44 void insert(const std::string &unique, unsigned int uid,
45 const std::string &fileName = "");
46 void remove(const std::string &unique);
47 void clear(void);
48 void clearFileNames(void);
49 void clearUids(void);
50 unsigned int getSize(void) const;
51 MaildirIndexItem *find(const std::string &unique);
52 };
53
54 //------------------------------------------------------------------------
55 class Maildir : public Mailbox {
56 public:
57 typedef std::map<unsigned int, MaildirMessage> MessageMap;
58
59 class iterator : public BaseIterator {
60 public:
61 iterator(void);
62 iterator(Maildir *home, MessageMap::iterator i,
63 const SequenceSet &bset,
64 unsigned int mod = INCLUDE_EXPUNGED | SQNR_MODE);
65 iterator(const iterator &copy);
66 ~iterator(void);
67
68 Message &operator *(void);
69 void operator ++(void);
70 bool operator ==(const BaseIterator &) const;
71 bool operator !=(const BaseIterator &) const;
72
73 iterator &operator =(const iterator &copy);
74
75 void erase(void);
76
77 friend class Maildir;
78
79 protected:
80 void reposition(void);
82
83 private:
84 Maildir *mailbox;
85 SequenceSet bset;
86 int mod;
87
88 MessageMap::iterator i;
89 unsigned int uidmax;
90 unsigned int sqnrmax;
91
92 iterator(iterator &external);
93 };
94
95 const std::string getTypeName(void) const;
96
97 Mailbox::iterator begin(const SequenceSet &bset, unsigned int mod = INCLUDE_EXPUNGED | SQNR_MODE) const;
98 Mailbox::iterator end(void) const;
99
100 unsigned int getMaxUid(void) const;
101 unsigned int getMaxSqnr(void) const;
102 unsigned int getUidValidity(void) const;
103 unsigned int getUidNext(void) const;
104
105 bool getUpdates(bool doscan, unsigned int type,
106 PendingUpdates &updates, bool forceScan);
107
108 const std::string &getPath(void) const;
109 void setPath(const std::string &path_in);
110
111 void bumpUidValidity(const std::string &) const;
112
113 unsigned int getStatusID(const std::string &) const;
114 bool getStatus(const std::string &, Status &) const;
115 void updateFlags(void);
116
117 bool isMailbox(const std::string &) const;
118 bool isMarked(const std::string &) const;
119 bool selectMailbox(const std::string &name, const std::string &s_in);
120 void closeMailbox(void);
121 void expungeMailbox(void);
122 bool createMailbox(const std::string &s, mode_t mode, uid_t owner = 0, gid_t group = 0, bool root = false);
123 bool deleteMailbox(const std::string &s);
124
125 Message *createMessage(const std::string &mbox, time_t idate = 0);
126 bool commitNewMessages(const std::string &mbox);
127 bool rollBackNewMessages(void);
128
129 bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname);
130
131 //--
132 Maildir(void);
133 ~Maildir(void);
134
135 friend class Maildir::iterator;
136 friend class MaildirMessage;
137
138 protected:
142 Error
143 };
144
146 bool writeCache(void);
147 bool scanFileNames(void) const;
148
153 };
154
155 ScanResult scan(bool forceScan = false);
156
157 MaildirMessage *get(const std::string &id);
158 void add(MaildirMessage &m);
159
160 private:
161 std::vector<MaildirMessage> newMessages;
162
163 unsigned int uidvalidity;
164 unsigned int uidnext;
165 bool selected;
166 std::string path;
167
168 mutable iterator beginIterator;
169 mutable iterator endIterator;
170
171 mutable bool firstscan;
172 mutable bool cacheRead;
173 mutable MaildirIndex index;
174 mutable MessageMap messages;
175
176 mutable unsigned int oldrecent;
177 mutable unsigned int oldexists;
178
179 mutable time_t old_bincimap_cache_st_mtime;
180 mutable time_t old_bincimap_cache_st_ctime;
181 mutable time_t old_cur_st_mtime;
182 mutable time_t old_cur_st_ctime;
183 mutable time_t old_new_st_mtime;
184 mutable time_t old_new_st_ctime;
185
186 mutable bool mailboxchanged;
187 };
188}
189
190#endif
@ INCLUDE_EXPUNGED
Definition: mailbox.h:68
void operator++(void)
Definition: maildir.cc:92
MaildirMessage & curMessage(void)
Definition: maildir.cc:80
Message & operator*(void)
Definition: maildir.cc:86
void reposition(void)
Definition: maildir.cc:113
iterator & operator=(const iterator &copy)
Definition: maildir.cc:62
bool operator!=(const BaseIterator &) const
Definition: maildir.cc:107
bool operator==(const BaseIterator &) const
Definition: maildir.cc:100
void bumpUidValidity(const std::string &) const
Definition: maildir.cc:282
const std::string getTypeName(void) const
Definition: maildir.cc:276
unsigned int getUidValidity(void) const
Definition: maildir.cc:495
~Maildir(void)
Definition: maildir.cc:190
void closeMailbox(void)
void add(MaildirMessage &m)
Definition: maildir.cc:770
unsigned int getStatusID(const std::string &) const
Definition: maildir.cc:310
bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname)
Definition: maildir.cc:687
Mailbox::iterator end(void) const
Definition: maildir.cc:156
void expungeMailbox(void)
bool writeCache(void)
bool createMailbox(const std::string &s, mode_t mode, uid_t owner=0, gid_t group=0, bool root=false)
bool commitNewMessages(const std::string &mbox)
Definition: maildir.cc:534
Maildir(void)
Definition: maildir.cc:178
ScanResult scan(bool forceScan=false)
Definition: maildir-scan.cc:70
unsigned int getMaxSqnr(void) const
Definition: maildir.cc:471
bool isMailbox(const std::string &) const
Definition: maildir.cc:263
bool selectMailbox(const std::string &name, const std::string &s_in)
void setPath(const std::string &path_in)
Definition: maildir.cc:195
bool deleteMailbox(const std::string &s)
bool scanFileNames(void) const
Message * createMessage(const std::string &mbox, time_t idate=0)
Definition: maildir.cc:507
ReadCacheResult readCache(void)
bool getUpdates(bool doscan, unsigned int type, PendingUpdates &updates, bool forceScan)
Definition: maildir.cc:201
unsigned int getMaxUid(void) const
Definition: maildir.cc:449
void updateFlags(void)
Mailbox::iterator begin(const SequenceSet &bset, unsigned int mod=INCLUDE_EXPUNGED|SQNR_MODE) const
Definition: maildir.cc:146
bool isMarked(const std::string &) const
Definition: maildir.cc:289
MaildirMessage * get(const std::string &id)
Definition: maildir.cc:756
@ TemporaryError
Definition: maildir.h:151
@ PermanentError
Definition: maildir.h:152
bool getStatus(const std::string &, Status &) const
Definition: maildir.cc:327
bool rollBackNewMessages(void)
Definition: maildir.cc:674
unsigned int getUidNext(void) const
Definition: maildir.cc:501
const std::string & getPath(void) const
std::map< unsigned int, MaildirMessage > MessageMap
Definition: maildir.h:57
void clearFileNames(void)
Definition: maildir.cc:834
void insert(const std::string &unique, unsigned int uid, const std::string &fileName="")
Definition: maildir.cc:786
void clearUids(void)
Definition: maildir.cc:826
unsigned int getSize(void) const
Definition: maildir.cc:780
MaildirIndexItem * find(const std::string &unique)
Definition: maildir.cc:810
void remove(const std::string &unique)
Definition: maildir.cc:802
void clear(void)
Definition: maildir.cc:820
unsigned int uid
Definition: maildir.h:33
std::string fileName
Definition: maildir.h:34
The MaildirMessage class provides an interface for IMAP messages.
The Message class provides an interface for IMAP messages.
Definition: message.h:31
Declaration of the Mailbox class (Mailbox is logical container)
Declaration of the MaildirMessage class.
Definition: bincimapd.cc:9