1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/** --------------------------------------------------------------------
* @file message.h
* @brief Declaration of the Message class.
* @author Andreas Aardal Hanssen
* @date 2002-2005
* ----------------------------------------------------------------- **/
#ifndef message_h_included
#define message_h_included
#include <string>
#include <vector>
#include <time.h>
#ifndef UINTMAX
#define UINTMAX ((unsigned int)-1)
#endif
namespace Binc {
/*!
\class Message
\brief The Message class provides an interface for
IMAP messages.
Mailbox independent operations and properties are available
through this interface.
This class is an abstract, and has no implementation.
\sa MaildirMessage
*/
class Message {
public:
/*!
Standard IMAP message flags.
*/
enum Flags {
F_NONE = 0x00, /*!< No flag is set */
F_SEEN = 0x01, /*!< The message has been seen */
F_ANSWERED = 0x02, /*!< The message has been answered */
F_DELETED = 0x04, /*!< The message is marked as deleted */
F_DRAFT = 0x08, /*!< The message is a draft */
F_RECENT = 0x10, /*!< The message arrived recently */
F_FLAGGED = 0x20, /*!< The message is flagged / important */
F_EXPUNGED = 0x40, /*!< The message has been expunged */
F_PASSED = 0x80 /*!< The message has been bounced */
};
virtual void setUID(unsigned int) = 0;
virtual unsigned int getUID(void) const = 0;
virtual void setSize(unsigned int) = 0;
virtual unsigned int getSize(bool render = false) const = 0;
virtual void setStdFlag(unsigned char) = 0;
virtual void resetStdFlags(void) = 0;
virtual unsigned char getStdFlags(void) const = 0;
virtual void setCustomFlag(const std::string &flag) = 0;
virtual void removeCustomFlag(const std::string &flag) = 0;
virtual void resetCustomFlags(void) = 0;
virtual std::vector<std::string> getCustomFlags(void) const = 0;
virtual void setFlagsUnchanged(void) = 0;
virtual bool hasFlagsChanged(void) const = 0;
virtual void setInternalDate(time_t) = 0;
virtual time_t getInternalDate(void) const = 0;
// virtual void rewind(void) = 0;
virtual int readChunk(std::string &) = 0;
virtual bool appendChunk(const std::string &) = 0;
virtual void close(void) = 0;
virtual void setExpunged(void) = 0;
virtual void setUnExpunged(void) = 0;
virtual bool isExpunged(void) const = 0;
virtual const std::string &getHeader(const std::string &header) = 0;
virtual bool headerContains(const std::string &header, const std::string &text) = 0;
virtual bool bodyContains(const std::string &text) = 0;
virtual bool textContains(const std::string &text) = 0;
virtual bool printBodyStructure(bool extended = true) const = 0;
virtual bool printEnvelope(void) const = 0;
virtual bool printHeader(const std::string §ion,
std::vector<std::string> headers,
bool includeHeaders = false,
unsigned int startOffset = 0,
unsigned int length = UINTMAX,
bool mime = false) const = 0;
virtual unsigned int getHeaderSize(const std::string §ion,
std::vector<std::string> headers,
bool includeHeaders = false,
unsigned int startOffset = 0,
unsigned int length = UINTMAX,
bool mime = false) const = 0;
virtual bool printBody(const std::string §ion,
unsigned int startOffset = 0,
unsigned int length = UINTMAX) const = 0;
virtual unsigned int getBodySize(const std::string §ion,
unsigned int startOffset = 0,
unsigned int length = UINTMAX) const = 0;
virtual bool printDoc(unsigned int startOffset = 0,
unsigned int length = UINTMAX,
bool onlyText = false) const = 0;
virtual unsigned int getDocSize(unsigned int startOffset = 0,
unsigned int length = UINTMAX,
bool onlyText = false) const = 0;
Message(void);
virtual ~Message(void);
void setLastError(const std::string &) const;
const std::string &getLastError(void) const;
private:
static std::string lastError;
};
inline Message::Message(void) {}
inline Message::~Message(void) {}
inline void Message::setLastError(const std::string &error) const
{
lastError = error;
}
inline const std::string &Message::getLastError(void) const
{
return lastError;
}
}
#endif
|