Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
maildirmessage.h
Go to the documentation of this file.
1
7#ifndef maildirmessage_h_included
8#define maildirmessage_h_included
9#include <string>
10#include <map>
11#include <vector>
12#include <exception>
13#include <iostream>
14#include <time.h>
15
16#include <stdio.h>
17#include <string.h>
18
19#include "message.h"
20#include "address.h"
21#include "mime.h"
22
23namespace Binc {
24
25 class Maildir;
26
37 class MaildirMessage : public Message {
38 public:
43 void setUID(unsigned int uid);
44
48 unsigned int getUID(void) const;
49
57 void setSize(unsigned int size);
58
67 unsigned int getSize(bool determine = false) const;
68
74 void setStdFlag(unsigned char flags);
75
79 void resetStdFlags(void);
80
84 unsigned char getStdFlags(void) const;
85
86 /*
87 */
88 void setCustomFlag(const std::string &flag);
89 void removeCustomFlag(const std::string &flag);
90 void resetCustomFlags(void);
91 std::vector<std::string> getCustomFlags(void) const;
92
98 void setInternalFlag(unsigned char flags);
99
105 void clearInternalFlag(unsigned char flags);
106
110 unsigned char getInternalFlags(void) const;
111
117 void setFlagsUnchanged(void);
118
123 bool hasFlagsChanged(void) const;
124
132 void setInternalDate(time_t internaldate);
133
138 time_t getInternalDate(void) const;
139
149 int readChunk(std::string &chunk);
150
158 bool appendChunk(const std::string &chunk);
159
163 void close(void);
164
169 void setExpunged(void);
170
174 void setUnExpunged(void);
175
180 bool isExpunged(void) const;
181
188 const std::string &getHeader(const std::string &header);
189
190 bool headerContains(const std::string &header,
191 const std::string &text);
192
193 bool bodyContains(const std::string &text);
194 bool textContains(const std::string &text);
195
196 bool printBodyStructure(bool extended = true) const;
197
198 bool printEnvelope(void) const;
199
200 bool printHeader(const std::string &section,
201 std::vector<std::string> headers,
202 bool includeHeaders = false,
203 unsigned int startOffset = 0,
204 unsigned int length = UINTMAX,
205 bool mime = false) const;
206
207 unsigned int getHeaderSize(const std::string &section,
208 std::vector<std::string> headers,
209 bool includeHeaders = false,
210 unsigned int startOffset = 0,
211 unsigned int length = UINTMAX,
212 bool mime = false) const;
213
214 bool printBody(const std::string &section = "",
215 unsigned int startOffset = 0,
216 unsigned int length = UINTMAX) const;
217 unsigned int getBodySize(const std::string &section,
218 unsigned int startOffset = 0,
219 unsigned int length = UINTMAX) const;
220
221 bool printDoc(unsigned int startOffset = 0,
222 unsigned int length = UINTMAX,
223 bool onlyText = false) const;
224
225 unsigned int getDocSize(unsigned int startOffset = 0,
226 unsigned int length = UINTMAX,
227 bool onlyText = false) const;
228
229 void setUnique(const std::string &s_in);
230 const std::string &getUnique(void) const;
231
232 //--
233 MaildirMessage(Maildir &home);
234 ~MaildirMessage(void);
235
236 friend class Maildir;
237
238 bool operator < (const MaildirMessage &a) const;
239
240 MaildirMessage(const MaildirMessage &copy);
242
243 enum Flags {
244 None = 0x00,
245 Expunged = 0x01,
249 Committed = 0x10,
250 CustomFlagsChanged = 0x20
251 };
252
253 protected:
254 bool parseFull(void) const;
255 bool parseHeaders(void) const;
256
257 std::string getFixedFilename(void) const;
258 std::string getFileName(void) const;
259
260 void setFile(int fd);
261 int getFile(void) const;
262
263 void setSafeName(const std::string &name);
264 const std::string &getSafeName(void) const;
265
266 private:
267 mutable int fd;
268 mutable MimeDocument *doc;
269 mutable unsigned char internalFlags;
270 mutable unsigned char stdflags;
271 mutable unsigned int uid;
272 mutable unsigned int size;
273 mutable std::string unique;
274 mutable std::string safeName;
275 time_t internaldate;
276
277 Maildir &home;
278 static std::string storage;
279 std::vector<std::string> *customFlags;
280 };
281
282 //------------------------------------------------------------------------
284 {
285 public:
287
292 };
293
294 static MaildirMessageCache &getInstance(void);
295
296 void removeStatus(const MaildirMessage *);
297 void addStatus(const MaildirMessage *, ParseStatus pstat);
298 ParseStatus getStatus(const MaildirMessage *) const;
299 void clear(void);
300
301 private:
303
304 mutable std::map<const MaildirMessage *, ParseStatus> statuses;
305 mutable std::deque<const MaildirMessage *> parsed;
306 };
307}
308
309#endif
Declaration of the Address class.
void addStatus(const MaildirMessage *, ParseStatus pstat)
static MaildirMessageCache & getInstance(void)
void removeStatus(const MaildirMessage *)
ParseStatus getStatus(const MaildirMessage *) const
The MaildirMessage class provides an interface for IMAP messages.
bool printBody(const std::string &section="", unsigned int startOffset=0, unsigned int length=UINTMAX) const
void setUnique(const std::string &s_in)
void setInternalDate(time_t internaldate)
bool appendChunk(const std::string &chunk)
unsigned int getBodySize(const std::string &section, unsigned int startOffset=0, unsigned int length=UINTMAX) const
const std::string & getHeader(const std::string &header)
bool parseHeaders(void) const
unsigned char getInternalFlags(void) const
void setFlagsUnchanged(void)
std::vector< std::string > getCustomFlags(void) const
void setUID(unsigned int uid)
int getFile(void) const
bool printDoc(unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const
void setCustomFlag(const std::string &flag)
bool printBodyStructure(bool extended=true) const
bool textContains(const std::string &text)
bool parseFull(void) const
bool printHeader(const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const
bool bodyContains(const std::string &text)
bool printEnvelope(void) const
std::string getFixedFilename(void) const
bool headerContains(const std::string &header, const std::string &text)
unsigned int getSize(bool determine=false) const
unsigned int getUID(void) const
const std::string & getSafeName(void) const
void setSize(unsigned int size)
unsigned int getDocSize(unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const
void setSafeName(const std::string &name)
void setInternalFlag(unsigned char flags)
std::string getFileName(void) const
const std::string & getUnique(void) const
bool isExpunged(void) const
unsigned char getStdFlags(void) const
void clearInternalFlag(unsigned char flags)
void setStdFlag(unsigned char flags)
MaildirMessage & operator=(const MaildirMessage &copy)
unsigned int getHeaderSize(const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const
int readChunk(std::string &chunk)
bool hasFlagsChanged(void) const
bool operator<(const MaildirMessage &a) const
void removeCustomFlag(const std::string &flag)
time_t getInternalDate(void) const
The Message class provides an interface for IMAP messages.
Definition: message.h:31
Declaration of the Message class.
#define UINTMAX
Definition: message.h:14
Declaration of main mime parser components.
Definition: bincimapd.cc:9