author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kmicromail/libmailwrapper/mailtypes.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'kmicromail/libmailwrapper/mailtypes.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index 70a0ab5..84ccf9f 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,101 +1,103 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | //Added by qt3to4: | ||
7 | #include <Q3ValueList> | ||
6 | 8 | ||
7 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 10 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 11 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 12 | { |
11 | init(); | 13 | init(); |
12 | } | 14 | } |
13 | 15 | ||
14 | RecMail::RecMail(const RecMail&old) | 16 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 17 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 18 | { |
17 | init(); | 19 | init(); |
18 | copy_old(old); | 20 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 21 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 22 | } |
21 | 23 | ||
22 | RecMail::~RecMail() | 24 | RecMail::~RecMail() |
23 | { | 25 | { |
24 | wrapper = 0; | 26 | wrapper = 0; |
25 | } | 27 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | 28 | static bool stringCompareRec( const QString& s1, const QString& s2 ) |
27 | { | 29 | { |
28 | if ( s1.isEmpty() && s2.isEmpty() ) | 30 | if ( s1.isEmpty() && s2.isEmpty() ) |
29 | return true; | 31 | return true; |
30 | return s1 == s2; | 32 | return s1 == s2; |
31 | } | 33 | } |
32 | #if 0 | 34 | #if 0 |
33 | QString RecMail::MsgsizeString() const | 35 | QString RecMail::MsgsizeString() const |
34 | { | 36 | { |
35 | 37 | ||
36 | double s = msg_size; | 38 | double s = msg_size; |
37 | int w = 0; | 39 | int w = 0; |
38 | s/=1024; | 40 | s/=1024; |
39 | if (s>999.0) { | 41 | if (s>999.0) { |
40 | s/=1024.0; | 42 | s/=1024.0; |
41 | ++w; | 43 | ++w; |
42 | } | 44 | } |
43 | QString fsize = QString::number( s, 'f', 2 ); | 45 | QString fsize = QString::number( s, 'f', 2 ); |
44 | if ( w == 0 ) { | 46 | if ( w == 0 ) { |
45 | fsize += "kB" ; | 47 | fsize += "kB" ; |
46 | } else | 48 | } else |
47 | fsize += "MB" ; | 49 | fsize += "MB" ; |
48 | return fsize; | 50 | return fsize; |
49 | } | 51 | } |
50 | #endif | 52 | #endif |
51 | bool RecMail::isEqual( RecMail* r1 ) | 53 | bool RecMail::isEqual( RecMail* r1 ) |
52 | { | 54 | { |
53 | if ( !stringCompareRec( isodate, r1->isodate ) ) { | 55 | if ( !stringCompareRec( isodate, r1->isodate ) ) { |
54 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | 56 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
55 | return false; | 57 | return false; |
56 | } | 58 | } |
57 | if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { | 59 | if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { |
58 | //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); | 60 | //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); |
59 | return false; | 61 | return false; |
60 | } | 62 | } |
61 | 63 | ||
62 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | 64 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
63 | if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { | 65 | if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { |
64 | if ( r1->from.find ( from ) < 0 ) { | 66 | if ( r1->from.find ( from ) < 0 ) { |
65 | if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { | 67 | if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { |
66 | //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); | 68 | //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); |
67 | return false; | 69 | return false; |
68 | } | 70 | } |
69 | } | 71 | } |
70 | } | 72 | } |
71 | 73 | ||
72 | return true; | 74 | return true; |
73 | } | 75 | } |
74 | void RecMail::copy_old(const RecMail&old) | 76 | void RecMail::copy_old(const RecMail&old) |
75 | { | 77 | { |
76 | subject = old.subject; | 78 | subject = old.subject; |
77 | date = old.date; | 79 | date = old.date; |
78 | mbox = old.mbox; | 80 | mbox = old.mbox; |
79 | msg_id = old.msg_id; | 81 | msg_id = old.msg_id; |
80 | msg_size = old.msg_size; | 82 | msg_size = old.msg_size; |
81 | msg_number = old.msg_number; | 83 | msg_number = old.msg_number; |
82 | from = old.from; | 84 | from = old.from; |
83 | msg_flags = old.msg_flags; | 85 | msg_flags = old.msg_flags; |
84 | to = old.to; | 86 | to = old.to; |
85 | cc = old.cc; | 87 | cc = old.cc; |
86 | bcc = old.bcc; | 88 | bcc = old.bcc; |
87 | wrapper = old.wrapper; | 89 | wrapper = old.wrapper; |
88 | in_reply_to = old.in_reply_to; | 90 | in_reply_to = old.in_reply_to; |
89 | references = old.references; | 91 | references = old.references; |
90 | replyto = old.replyto; | 92 | replyto = old.replyto; |
91 | } | 93 | } |
92 | 94 | ||
93 | void RecMail::init() | 95 | void RecMail::init() |
94 | { | 96 | { |
95 | to.clear(); | 97 | to.clear(); |
96 | cc.clear(); | 98 | cc.clear(); |
97 | bcc.clear(); | 99 | bcc.clear(); |
98 | in_reply_to.clear(); | 100 | in_reply_to.clear(); |
99 | references.clear(); | 101 | references.clear(); |
100 | wrapper = 0; | 102 | wrapper = 0; |
101 | } | 103 | } |
@@ -190,239 +192,239 @@ RecPart::~RecPart() | |||
190 | 192 | ||
191 | void RecPart::setSize(unsigned int size) | 193 | void RecPart::setSize(unsigned int size) |
192 | { | 194 | { |
193 | m_size = size; | 195 | m_size = size; |
194 | } | 196 | } |
195 | 197 | ||
196 | const unsigned int RecPart::Size()const | 198 | const unsigned int RecPart::Size()const |
197 | { | 199 | { |
198 | return m_size; | 200 | return m_size; |
199 | } | 201 | } |
200 | 202 | ||
201 | void RecPart::setLines(unsigned int lines) | 203 | void RecPart::setLines(unsigned int lines) |
202 | { | 204 | { |
203 | m_lines = lines; | 205 | m_lines = lines; |
204 | } | 206 | } |
205 | 207 | ||
206 | const unsigned int RecPart::Lines()const | 208 | const unsigned int RecPart::Lines()const |
207 | { | 209 | { |
208 | return m_lines; | 210 | return m_lines; |
209 | } | 211 | } |
210 | 212 | ||
211 | const QString& RecPart::Type()const | 213 | const QString& RecPart::Type()const |
212 | { | 214 | { |
213 | return m_type; | 215 | return m_type; |
214 | } | 216 | } |
215 | 217 | ||
216 | void RecPart::setType(const QString&type) | 218 | void RecPart::setType(const QString&type) |
217 | { | 219 | { |
218 | m_type = type; | 220 | m_type = type; |
219 | } | 221 | } |
220 | 222 | ||
221 | const QString& RecPart::Subtype()const | 223 | const QString& RecPart::Subtype()const |
222 | { | 224 | { |
223 | return m_subtype; | 225 | return m_subtype; |
224 | } | 226 | } |
225 | 227 | ||
226 | void RecPart::setSubtype(const QString&subtype) | 228 | void RecPart::setSubtype(const QString&subtype) |
227 | { | 229 | { |
228 | m_subtype = subtype; | 230 | m_subtype = subtype; |
229 | } | 231 | } |
230 | 232 | ||
231 | const QString& RecPart::Identifier()const | 233 | const QString& RecPart::Identifier()const |
232 | { | 234 | { |
233 | return m_identifier; | 235 | return m_identifier; |
234 | } | 236 | } |
235 | 237 | ||
236 | void RecPart::setIdentifier(const QString&identifier) | 238 | void RecPart::setIdentifier(const QString&identifier) |
237 | { | 239 | { |
238 | m_identifier = identifier; | 240 | m_identifier = identifier; |
239 | } | 241 | } |
240 | 242 | ||
241 | const QString& RecPart::Encoding()const | 243 | const QString& RecPart::Encoding()const |
242 | { | 244 | { |
243 | return m_encoding; | 245 | return m_encoding; |
244 | } | 246 | } |
245 | 247 | ||
246 | void RecPart::setEncoding(const QString&encoding) | 248 | void RecPart::setEncoding(const QString&encoding) |
247 | { | 249 | { |
248 | m_encoding = encoding; | 250 | m_encoding = encoding; |
249 | } | 251 | } |
250 | 252 | ||
251 | const QString& RecPart::Description()const | 253 | const QString& RecPart::Description()const |
252 | { | 254 | { |
253 | return m_description; | 255 | return m_description; |
254 | } | 256 | } |
255 | 257 | ||
256 | void RecPart::setDescription(const QString&desc) | 258 | void RecPart::setDescription(const QString&desc) |
257 | { | 259 | { |
258 | m_description = desc; | 260 | m_description = desc; |
259 | } | 261 | } |
260 | 262 | ||
261 | void RecPart::setParameters(const part_plist_t&list) | 263 | void RecPart::setParameters(const part_plist_t&list) |
262 | { | 264 | { |
263 | m_Parameters = list; | 265 | m_Parameters = list; |
264 | } | 266 | } |
265 | 267 | ||
266 | const part_plist_t& RecPart::Parameters()const | 268 | const part_plist_t& RecPart::Parameters()const |
267 | { | 269 | { |
268 | return m_Parameters; | 270 | return m_Parameters; |
269 | } | 271 | } |
270 | 272 | ||
271 | void RecPart::addParameter(const QString&key,const QString&value) | 273 | void RecPart::addParameter(const QString&key,const QString&value) |
272 | { | 274 | { |
273 | m_Parameters[key]=value; | 275 | m_Parameters[key]=value; |
274 | } | 276 | } |
275 | 277 | ||
276 | const QString RecPart::searchParamter(const QString&key)const | 278 | const QString RecPart::searchParamter(const QString&key)const |
277 | { | 279 | { |
278 | QString value(""); | 280 | QString value(""); |
279 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 281 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
280 | if (it != m_Parameters.end()) { | 282 | if (it != m_Parameters.end()) { |
281 | value = it.data(); | 283 | value = it.data(); |
282 | } | 284 | } |
283 | return value; | 285 | return value; |
284 | } | 286 | } |
285 | 287 | ||
286 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 288 | void RecPart::setPositionlist(const Q3ValueList<int>&poslist) |
287 | { | 289 | { |
288 | m_poslist = poslist; | 290 | m_poslist = poslist; |
289 | } | 291 | } |
290 | 292 | ||
291 | const QValueList<int>& RecPart::Positionlist()const | 293 | const Q3ValueList<int>& RecPart::Positionlist()const |
292 | { | 294 | { |
293 | return m_poslist; | 295 | return m_poslist; |
294 | } | 296 | } |
295 | 297 | ||
296 | RecBody::RecBody() | 298 | RecBody::RecBody() |
297 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) | 299 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) |
298 | { | 300 | { |
299 | m_PartsList.clear(); | 301 | m_PartsList.clear(); |
300 | } | 302 | } |
301 | 303 | ||
302 | RecBody::RecBody(const RecBody&old) | 304 | RecBody::RecBody(const RecBody&old) |
303 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | 305 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) |
304 | { | 306 | { |
305 | m_BodyText = old.m_BodyText; | 307 | m_BodyText = old.m_BodyText; |
306 | m_PartsList = old.m_PartsList; | 308 | m_PartsList = old.m_PartsList; |
307 | m_description = old.m_description; | 309 | m_description = old.m_description; |
308 | mCharset = old.mCharset; | 310 | mCharset = old.mCharset; |
309 | // odebug << "Recbody copy constructor" << oendl; | 311 | // odebug << "Recbody copy constructor" << oendl; |
310 | } | 312 | } |
311 | 313 | ||
312 | RecBody::~RecBody() | 314 | RecBody::~RecBody() |
313 | { | 315 | { |
314 | } | 316 | } |
315 | 317 | ||
316 | void RecBody::setBodytext(const QString&bodyText) | 318 | void RecBody::setBodytext(const QString&bodyText) |
317 | { | 319 | { |
318 | m_BodyText = bodyText; | 320 | m_BodyText = bodyText; |
319 | } | 321 | } |
320 | 322 | ||
321 | const QString& RecBody::Bodytext()const | 323 | const QString& RecBody::Bodytext()const |
322 | { | 324 | { |
323 | return m_BodyText; | 325 | return m_BodyText; |
324 | } | 326 | } |
325 | 327 | ||
326 | void RecBody::setParts(const QValueList<RecPartP>&parts) | 328 | void RecBody::setParts(const Q3ValueList<RecPartP>&parts) |
327 | { | 329 | { |
328 | m_PartsList.clear(); | 330 | m_PartsList.clear(); |
329 | m_PartsList = parts; | 331 | m_PartsList = parts; |
330 | } | 332 | } |
331 | 333 | ||
332 | const QValueList<RecPartP>& RecBody::Parts()const | 334 | const Q3ValueList<RecPartP>& RecBody::Parts()const |
333 | { | 335 | { |
334 | return m_PartsList; | 336 | return m_PartsList; |
335 | } | 337 | } |
336 | 338 | ||
337 | void RecBody::addPart(const RecPartP& part) | 339 | void RecBody::addPart(const RecPartP& part) |
338 | { | 340 | { |
339 | m_PartsList.append(part); | 341 | m_PartsList.append(part); |
340 | } | 342 | } |
341 | 343 | ||
342 | void RecBody::setDescription(const RecPartP&des) | 344 | void RecBody::setDescription(const RecPartP&des) |
343 | { | 345 | { |
344 | m_description = des; | 346 | m_description = des; |
345 | } | 347 | } |
346 | 348 | ||
347 | const RecPartP& RecBody::Description()const | 349 | const RecPartP& RecBody::Description()const |
348 | { | 350 | { |
349 | return m_description; | 351 | return m_description; |
350 | } | 352 | } |
351 | 353 | ||
352 | void RecBody::setCharset(const QString& str) | 354 | void RecBody::setCharset(const QString& str) |
353 | { | 355 | { |
354 | mCharset = str; | 356 | mCharset = str; |
355 | } | 357 | } |
356 | 358 | ||
357 | QString RecBody::getCharset()const | 359 | QString RecBody::getCharset()const |
358 | { | 360 | { |
359 | return mCharset; | 361 | return mCharset; |
360 | } | 362 | } |
361 | 363 | ||
362 | /* handling encoded content */ | 364 | /* handling encoded content */ |
363 | encodedString::encodedString() | 365 | encodedString::encodedString() |
364 | { | 366 | { |
365 | init(); | 367 | init(); |
366 | } | 368 | } |
367 | 369 | ||
368 | encodedString::encodedString(const char*nContent,unsigned int nSize) | 370 | encodedString::encodedString(const char*nContent,unsigned int nSize) |
369 | { | 371 | { |
370 | init(); | 372 | init(); |
371 | setContent(nContent,nSize); | 373 | setContent(nContent,nSize); |
372 | } | 374 | } |
373 | 375 | ||
374 | encodedString::encodedString(char*nContent,unsigned int nSize) | 376 | encodedString::encodedString(char*nContent,unsigned int nSize) |
375 | { | 377 | { |
376 | init(); | 378 | init(); |
377 | setContent(nContent,nSize); | 379 | setContent(nContent,nSize); |
378 | } | 380 | } |
379 | 381 | ||
380 | encodedString::encodedString(const encodedString&old) | 382 | encodedString::encodedString(const encodedString&old) |
381 | { | 383 | { |
382 | init(); | 384 | init(); |
383 | copy_old(old); | 385 | copy_old(old); |
384 | // odebug << "encodedeString: copy constructor!" << oendl; | 386 | // odebug << "encodedeString: copy constructor!" << oendl; |
385 | } | 387 | } |
386 | 388 | ||
387 | encodedString& encodedString::operator=(const encodedString&old) | 389 | encodedString& encodedString::operator=(const encodedString&old) |
388 | { | 390 | { |
389 | init(); | 391 | init(); |
390 | copy_old(old); | 392 | copy_old(old); |
391 | // odebug << "encodedString: assign operator!" << oendl; | 393 | // odebug << "encodedString: assign operator!" << oendl; |
392 | return *this; | 394 | return *this; |
393 | } | 395 | } |
394 | 396 | ||
395 | encodedString::~encodedString() | 397 | encodedString::~encodedString() |
396 | { | 398 | { |
397 | clean(); | 399 | clean(); |
398 | } | 400 | } |
399 | 401 | ||
400 | void encodedString::init() | 402 | void encodedString::init() |
401 | { | 403 | { |
402 | content = 0; | 404 | content = 0; |
403 | size = 0; | 405 | size = 0; |
404 | } | 406 | } |
405 | 407 | ||
406 | void encodedString::clean() | 408 | void encodedString::clean() |
407 | { | 409 | { |
408 | if (content) { | 410 | if (content) { |
409 | free(content); | 411 | free(content); |
410 | } | 412 | } |
411 | content = 0; | 413 | content = 0; |
412 | size = 0; | 414 | size = 0; |
413 | } | 415 | } |
414 | 416 | ||
415 | void encodedString::copy_old(const encodedString&old) | 417 | void encodedString::copy_old(const encodedString&old) |
416 | { | 418 | { |
417 | clean(); | 419 | clean(); |
418 | if (old.size>0 && old.content) { | 420 | if (old.size>0 && old.content) { |
419 | content = (char*)malloc(old.size*sizeof(char)); | 421 | content = (char*)malloc(old.size*sizeof(char)); |
420 | memcpy(content,old.content,size); | 422 | memcpy(content,old.content,size); |
421 | size = old.size; | 423 | size = old.size; |
422 | } | 424 | } |
423 | } | 425 | } |
424 | 426 | ||
425 | const char*encodedString::Content()const | 427 | const char*encodedString::Content()const |
426 | { | 428 | { |
427 | return content; | 429 | return content; |
428 | } | 430 | } |