author | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
commit | e3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff) | |
tree | 162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libmailwrapper/mailtypes.cpp | |
parent | 2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff) | |
download | kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2 |
Initial revision
Diffstat (limited to 'kmicromail/libmailwrapper/mailtypes.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 399 |
1 files changed, 399 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp new file mode 100644 index 0000000..d43bdc6 --- a/dev/null +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -0,0 +1,399 @@ | |||
1 | #include "mailtypes.h" | ||
2 | |||
3 | //#include <opie2/odebug.h> | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | |||
7 | using namespace Opie::Core; | ||
8 | RecMail::RecMail() | ||
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | ||
10 | { | ||
11 | init(); | ||
12 | } | ||
13 | |||
14 | RecMail::RecMail(const RecMail&old) | ||
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | ||
16 | { | ||
17 | init(); | ||
18 | copy_old(old); | ||
19 | // odebug << "Copy constructor RecMail" << oendl; | ||
20 | } | ||
21 | |||
22 | RecMail::~RecMail() | ||
23 | { | ||
24 | wrapper = 0; | ||
25 | } | ||
26 | |||
27 | void RecMail::copy_old(const RecMail&old) | ||
28 | { | ||
29 | subject = old.subject; | ||
30 | date = old.date; | ||
31 | mbox = old.mbox; | ||
32 | msg_id = old.msg_id; | ||
33 | msg_size = old.msg_size; | ||
34 | msg_number = old.msg_number; | ||
35 | from = old.from; | ||
36 | msg_flags = old.msg_flags; | ||
37 | to = old.to; | ||
38 | cc = old.cc; | ||
39 | bcc = old.bcc; | ||
40 | wrapper = old.wrapper; | ||
41 | in_reply_to = old.in_reply_to; | ||
42 | references = old.references; | ||
43 | replyto = old.replyto; | ||
44 | } | ||
45 | |||
46 | void RecMail::init() | ||
47 | { | ||
48 | to.clear(); | ||
49 | cc.clear(); | ||
50 | bcc.clear(); | ||
51 | in_reply_to.clear(); | ||
52 | references.clear(); | ||
53 | wrapper = 0; | ||
54 | } | ||
55 | |||
56 | void RecMail::setWrapper(AbstractMail*awrapper) | ||
57 | { | ||
58 | wrapper = awrapper; | ||
59 | } | ||
60 | |||
61 | AbstractMail* RecMail::Wrapper() | ||
62 | { | ||
63 | return wrapper; | ||
64 | } | ||
65 | |||
66 | void RecMail::setTo(const QStringList&list) | ||
67 | { | ||
68 | to = list; | ||
69 | } | ||
70 | |||
71 | const QStringList&RecMail::To()const | ||
72 | { | ||
73 | return to; | ||
74 | } | ||
75 | |||
76 | void RecMail::setCC(const QStringList&list) | ||
77 | { | ||
78 | cc = list; | ||
79 | } | ||
80 | |||
81 | const QStringList&RecMail::CC()const | ||
82 | { | ||
83 | return cc; | ||
84 | } | ||
85 | |||
86 | void RecMail::setBcc(const QStringList&list) | ||
87 | { | ||
88 | bcc = list; | ||
89 | } | ||
90 | |||
91 | const QStringList& RecMail::Bcc()const | ||
92 | { | ||
93 | return bcc; | ||
94 | } | ||
95 | |||
96 | void RecMail::setInreply(const QStringList&list) | ||
97 | { | ||
98 | in_reply_to = list; | ||
99 | } | ||
100 | |||
101 | const QStringList& RecMail::Inreply()const | ||
102 | { | ||
103 | return in_reply_to; | ||
104 | } | ||
105 | |||
106 | void RecMail::setReferences(const QStringList&list) | ||
107 | { | ||
108 | references = list; | ||
109 | } | ||
110 | |||
111 | const QStringList& RecMail::References()const | ||
112 | { | ||
113 | return references; | ||
114 | } | ||
115 | |||
116 | RecPart::RecPart() | ||
117 | : Opie::Core::ORefCount(), | ||
118 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | ||
119 | { | ||
120 | m_Parameters.clear(); | ||
121 | m_poslist.clear(); | ||
122 | } | ||
123 | |||
124 | RecPart::RecPart(const RecPart&old) | ||
125 | : Opie::Core::ORefCount(), | ||
126 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | ||
127 | { | ||
128 | m_type = old.m_type; | ||
129 | m_subtype = old.m_subtype; | ||
130 | m_identifier = old.m_identifier; | ||
131 | m_encoding = old.m_encoding; | ||
132 | m_description = old.m_description; | ||
133 | m_lines = old.m_lines; | ||
134 | m_size = old.m_size; | ||
135 | m_Parameters = old.m_Parameters; | ||
136 | m_poslist = old.m_poslist; | ||
137 | // odebug << "RecPart copy constructor" << oendl; | ||
138 | } | ||
139 | |||
140 | RecPart::~RecPart() | ||
141 | { | ||
142 | } | ||
143 | |||
144 | void RecPart::setSize(unsigned int size) | ||
145 | { | ||
146 | m_size = size; | ||
147 | } | ||
148 | |||
149 | const unsigned int RecPart::Size()const | ||
150 | { | ||
151 | return m_size; | ||
152 | } | ||
153 | |||
154 | void RecPart::setLines(unsigned int lines) | ||
155 | { | ||
156 | m_lines = lines; | ||
157 | } | ||
158 | |||
159 | const unsigned int RecPart::Lines()const | ||
160 | { | ||
161 | return m_lines; | ||
162 | } | ||
163 | |||
164 | const QString& RecPart::Type()const | ||
165 | { | ||
166 | return m_type; | ||
167 | } | ||
168 | |||
169 | void RecPart::setType(const QString&type) | ||
170 | { | ||
171 | m_type = type; | ||
172 | } | ||
173 | |||
174 | const QString& RecPart::Subtype()const | ||
175 | { | ||
176 | return m_subtype; | ||
177 | } | ||
178 | |||
179 | void RecPart::setSubtype(const QString&subtype) | ||
180 | { | ||
181 | m_subtype = subtype; | ||
182 | } | ||
183 | |||
184 | const QString& RecPart::Identifier()const | ||
185 | { | ||
186 | return m_identifier; | ||
187 | } | ||
188 | |||
189 | void RecPart::setIdentifier(const QString&identifier) | ||
190 | { | ||
191 | m_identifier = identifier; | ||
192 | } | ||
193 | |||
194 | const QString& RecPart::Encoding()const | ||
195 | { | ||
196 | return m_encoding; | ||
197 | } | ||
198 | |||
199 | void RecPart::setEncoding(const QString&encoding) | ||
200 | { | ||
201 | m_encoding = encoding; | ||
202 | } | ||
203 | |||
204 | const QString& RecPart::Description()const | ||
205 | { | ||
206 | return m_description; | ||
207 | } | ||
208 | |||
209 | void RecPart::setDescription(const QString&desc) | ||
210 | { | ||
211 | m_description = desc; | ||
212 | } | ||
213 | |||
214 | void RecPart::setParameters(const part_plist_t&list) | ||
215 | { | ||
216 | m_Parameters = list; | ||
217 | } | ||
218 | |||
219 | const part_plist_t& RecPart::Parameters()const | ||
220 | { | ||
221 | return m_Parameters; | ||
222 | } | ||
223 | |||
224 | void RecPart::addParameter(const QString&key,const QString&value) | ||
225 | { | ||
226 | m_Parameters[key]=value; | ||
227 | } | ||
228 | |||
229 | const QString RecPart::searchParamter(const QString&key)const | ||
230 | { | ||
231 | QString value(""); | ||
232 | part_plist_t::ConstIterator it = m_Parameters.find(key); | ||
233 | if (it != m_Parameters.end()) { | ||
234 | value = it.data(); | ||
235 | } | ||
236 | return value; | ||
237 | } | ||
238 | |||
239 | void RecPart::setPositionlist(const QValueList<int>&poslist) | ||
240 | { | ||
241 | m_poslist = poslist; | ||
242 | } | ||
243 | |||
244 | const QValueList<int>& RecPart::Positionlist()const | ||
245 | { | ||
246 | return m_poslist; | ||
247 | } | ||
248 | |||
249 | RecBody::RecBody() | ||
250 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) | ||
251 | { | ||
252 | m_PartsList.clear(); | ||
253 | } | ||
254 | |||
255 | RecBody::RecBody(const RecBody&old) | ||
256 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | ||
257 | { | ||
258 | m_BodyText = old.m_BodyText; | ||
259 | m_PartsList = old.m_PartsList; | ||
260 | m_description = old.m_description; | ||
261 | // odebug << "Recbody copy constructor" << oendl; | ||
262 | } | ||
263 | |||
264 | RecBody::~RecBody() | ||
265 | { | ||
266 | } | ||
267 | |||
268 | void RecBody::setBodytext(const QString&bodyText) | ||
269 | { | ||
270 | m_BodyText = bodyText; | ||
271 | } | ||
272 | |||
273 | const QString& RecBody::Bodytext()const | ||
274 | { | ||
275 | return m_BodyText; | ||
276 | } | ||
277 | |||
278 | void RecBody::setParts(const QValueList<RecPartP>&parts) | ||
279 | { | ||
280 | m_PartsList.clear(); | ||
281 | m_PartsList = parts; | ||
282 | } | ||
283 | |||
284 | const QValueList<RecPartP>& RecBody::Parts()const | ||
285 | { | ||
286 | return m_PartsList; | ||
287 | } | ||
288 | |||
289 | void RecBody::addPart(const RecPartP& part) | ||
290 | { | ||
291 | m_PartsList.append(part); | ||
292 | } | ||
293 | |||
294 | void RecBody::setDescription(const RecPartP&des) | ||
295 | { | ||
296 | m_description = des; | ||
297 | } | ||
298 | |||
299 | const RecPartP& RecBody::Description()const | ||
300 | { | ||
301 | return m_description; | ||
302 | } | ||
303 | |||
304 | /* handling encoded content */ | ||
305 | encodedString::encodedString() | ||
306 | { | ||
307 | init(); | ||
308 | } | ||
309 | |||
310 | encodedString::encodedString(const char*nContent,unsigned int nSize) | ||
311 | { | ||
312 | init(); | ||
313 | setContent(nContent,nSize); | ||
314 | } | ||
315 | |||
316 | encodedString::encodedString(char*nContent,unsigned int nSize) | ||
317 | { | ||
318 | init(); | ||
319 | setContent(nContent,nSize); | ||
320 | } | ||
321 | |||
322 | encodedString::encodedString(const encodedString&old) | ||
323 | { | ||
324 | init(); | ||
325 | copy_old(old); | ||
326 | // odebug << "encodedeString: copy constructor!" << oendl; | ||
327 | } | ||
328 | |||
329 | encodedString& encodedString::operator=(const encodedString&old) | ||
330 | { | ||
331 | init(); | ||
332 | copy_old(old); | ||
333 | // odebug << "encodedString: assign operator!" << oendl; | ||
334 | return *this; | ||
335 | } | ||
336 | |||
337 | encodedString::~encodedString() | ||
338 | { | ||
339 | clean(); | ||
340 | } | ||
341 | |||
342 | void encodedString::init() | ||
343 | { | ||
344 | content = 0; | ||
345 | size = 0; | ||
346 | } | ||
347 | |||
348 | void encodedString::clean() | ||
349 | { | ||
350 | if (content) { | ||
351 | free(content); | ||
352 | } | ||
353 | content = 0; | ||
354 | size = 0; | ||
355 | } | ||
356 | |||
357 | void encodedString::copy_old(const encodedString&old) | ||
358 | { | ||
359 | clean(); | ||
360 | if (old.size>0 && old.content) { | ||
361 | content = (char*)malloc(old.size*sizeof(char)); | ||
362 | memcpy(content,old.content,size); | ||
363 | size = old.size; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | const char*encodedString::Content()const | ||
368 | { | ||
369 | return content; | ||
370 | } | ||
371 | |||
372 | const int encodedString::Length()const | ||
373 | { | ||
374 | return size; | ||
375 | } | ||
376 | |||
377 | void encodedString::setContent(const char*nContent,int nSize) | ||
378 | { | ||
379 | if (nSize>0 && nContent) { | ||
380 | content = (char*)malloc(nSize*sizeof(char)); | ||
381 | memcpy(content,nContent,nSize); | ||
382 | size = nSize; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | void encodedString::setContent(char*nContent,int nSize) | ||
387 | { | ||
388 | content = nContent; | ||
389 | size = nSize; | ||
390 | } | ||
391 | |||
392 | folderStat&folderStat::operator=(const folderStat&old) | ||
393 | { | ||
394 | message_count = old.message_count; | ||
395 | message_unseen = old.message_unseen; | ||
396 | message_recent = old.message_recent; | ||
397 | return *this; | ||
398 | } | ||
399 | |||