Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 3e4293b..1caa375 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -128,25 +128,25 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | |||
128 | default: | 128 | default: |
129 | if (aEnc->enc_token) { | 129 | if (aEnc->enc_token) { |
130 | enc = QString(aEnc->enc_token); | 130 | enc = QString(aEnc->enc_token); |
131 | } | 131 | } |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | return enc; | 134 | return enc; |
135 | } | 135 | } |
136 | 136 | ||
137 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 137 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
138 | { | 138 | { |
139 | if (current_rec >= 10) { | 139 | if (current_rec >= 10) { |
140 | odebug << "too deep recursion!" << oendl; | 140 | odebug << "too deep recursion!" << oendl; |
141 | } | 141 | } |
142 | if (!message || !mime) { | 142 | if (!message || !mime) { |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | int r; | 145 | int r; |
146 | char*data = 0; | 146 | char*data = 0; |
147 | size_t len; | 147 | size_t len; |
148 | clistiter * cur = 0; | 148 | clistiter * cur = 0; |
149 | QString b; | 149 | QString b; |
150 | RecPartP part = new RecPart(); | 150 | RecPartP part = new RecPart(); |
151 | 151 | ||
152 | switch (mime->mm_type) { | 152 | switch (mime->mm_type) { |
@@ -265,25 +265,25 @@ QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | |||
265 | } else { | 265 | } else { |
266 | first = false; | 266 | first = false; |
267 | } | 267 | } |
268 | 268 | ||
269 | switch ( addr->ad_type ) { | 269 | switch ( addr->ad_type ) { |
270 | case MAILIMF_ADDRESS_MAILBOX: | 270 | case MAILIMF_ADDRESS_MAILBOX: |
271 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 271 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
272 | break; | 272 | break; |
273 | case MAILIMF_ADDRESS_GROUP: | 273 | case MAILIMF_ADDRESS_GROUP: |
274 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 274 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
275 | break; | 275 | break; |
276 | default: | 276 | default: |
277 | odebug << "Generic: unkown mailimf address type" << oendl; | 277 | odebug << "Generic: unkown mailimf address type" << oendl; |
278 | break; | 278 | break; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | return result; | 282 | return result; |
283 | } | 283 | } |
284 | 284 | ||
285 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 285 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
286 | { | 286 | { |
287 | QString result( "" ); | 287 | QString result( "" ); |
288 | 288 | ||
289 | result.append( group->grp_display_name ); | 289 | result.append( group->grp_display_name ); |
@@ -358,25 +358,25 @@ QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | |||
358 | return text; | 358 | return text; |
359 | } | 359 | } |
360 | 360 | ||
361 | void Genericwrapper::cleanMimeCache() | 361 | void Genericwrapper::cleanMimeCache() |
362 | { | 362 | { |
363 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 363 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
364 | for (;it!=bodyCache.end();++it) { | 364 | for (;it!=bodyCache.end();++it) { |
365 | encodedString*t = it.data(); | 365 | encodedString*t = it.data(); |
366 | //it.setValue(0); | 366 | //it.setValue(0); |
367 | if (t) delete t; | 367 | if (t) delete t; |
368 | } | 368 | } |
369 | bodyCache.clear(); | 369 | bodyCache.clear(); |
370 | odebug << "Genericwrapper: cache cleaned" << oendl; | 370 | odebug << "Genericwrapper: cache cleaned" << oendl; |
371 | } | 371 | } |
372 | 372 | ||
373 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 373 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
374 | { | 374 | { |
375 | QStringList res; | 375 | QStringList res; |
376 | if (!in_replies || !in_replies->mid_list) return res; | 376 | if (!in_replies || !in_replies->mid_list) return res; |
377 | clistiter * current = 0; | 377 | clistiter * current = 0; |
378 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 378 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
379 | QString h((char*)current->data); | 379 | QString h((char*)current->data); |
380 | while (h.length()>0 && h[0]=='<') { | 380 | while (h.length()>0 && h[0]=='<') { |
381 | h.remove(0,1); | 381 | h.remove(0,1); |
382 | } | 382 | } |
@@ -387,44 +387,44 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | |||
387 | res.append(h); | 387 | res.append(h); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | return res; | 390 | return res; |
391 | } | 391 | } |
392 | 392 | ||
393 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 393 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
394 | { | 394 | { |
395 | int r; | 395 | int r; |
396 | mailmessage_list * env_list = 0; | 396 | mailmessage_list * env_list = 0; |
397 | r = mailsession_get_messages_list(session,&env_list); | 397 | r = mailsession_get_messages_list(session,&env_list); |
398 | if (r != MAIL_NO_ERROR) { | 398 | if (r != MAIL_NO_ERROR) { |
399 | odebug << "Error message list" << oendl; | 399 | odebug << "Error message list" << oendl; |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | r = mailsession_get_envelopes_list(session, env_list); | 402 | r = mailsession_get_envelopes_list(session, env_list); |
403 | if (r != MAIL_NO_ERROR) { | 403 | if (r != MAIL_NO_ERROR) { |
404 | odebug << "Error filling message list" << oendl; | 404 | odebug << "Error filling message list" << oendl; |
405 | if (env_list) { | 405 | if (env_list) { |
406 | mailmessage_list_free(env_list); | 406 | mailmessage_list_free(env_list); |
407 | } | 407 | } |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | mailimf_references * refs = 0; | 410 | mailimf_references * refs = 0; |
411 | mailimf_in_reply_to * in_replies = 0; | 411 | mailimf_in_reply_to * in_replies = 0; |
412 | uint32_t i = 0; | 412 | uint32_t i = 0; |
413 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 413 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
414 | mailmessage * msg; | 414 | mailmessage * msg; |
415 | QBitArray mFlags(7); | 415 | QBitArray mFlags(7); |
416 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 416 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
417 | if (msg->msg_fields == NULL) { | 417 | if (msg->msg_fields == NULL) { |
418 | //odebug << "could not fetch envelope of message " << i << "" << oendl; | 418 | //odebug << "could not fetch envelope of message " << i << "" << oendl; |
419 | continue; | 419 | continue; |
420 | } | 420 | } |
421 | RecMailP mail = new RecMail(); | 421 | RecMailP mail = new RecMail(); |
422 | mail->setWrapper(this); | 422 | mail->setWrapper(this); |
423 | mail_flags * flag_result = 0; | 423 | mail_flags * flag_result = 0; |
424 | r = mailmessage_get_flags(msg,&flag_result); | 424 | r = mailmessage_get_flags(msg,&flag_result); |
425 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 425 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
426 | mFlags.setBit(FLAG_SEEN); | 426 | mFlags.setBit(FLAG_SEEN); |
427 | } | 427 | } |
428 | mailimf_single_fields single_fields; | 428 | mailimf_single_fields single_fields; |
429 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 429 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
430 | mail->setMsgsize(msg->msg_size); | 430 | mail->setMsgsize(msg->msg_size); |
@@ -439,27 +439,26 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & | |||
439 | if (single_fields.fld_to) | 439 | if (single_fields.fld_to) |
440 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 440 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
441 | } else { | 441 | } else { |
442 | mail->setTo(mailbox); | 442 | mail->setTo(mailbox); |
443 | } | 443 | } |
444 | if (single_fields.fld_cc) | 444 | if (single_fields.fld_cc) |
445 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 445 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
446 | if (single_fields.fld_bcc) | 446 | if (single_fields.fld_bcc) |
447 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 447 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
448 | if (single_fields.fld_orig_date) | 448 | if (single_fields.fld_orig_date) |
449 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 449 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
450 | // crashes when accessing pop3 account? | 450 | // crashes when accessing pop3 account? |
451 | if (single_fields.fld_message_id->mid_value) { | 451 | if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { |
452 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 452 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
453 | odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | ||
454 | } | 453 | } |
455 | 454 | ||
456 | if (single_fields.fld_reply_to) { | 455 | if (single_fields.fld_reply_to) { |
457 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 456 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
458 | if (t.count()>0) { | 457 | if (t.count()>0) { |
459 | mail->setReplyto(t[0]); | 458 | mail->setReplyto(t[0]); |
460 | } | 459 | } |
461 | } | 460 | } |
462 | #if 0 | 461 | #if 0 |
463 | refs = single_fields.fld_references; | 462 | refs = single_fields.fld_references; |
464 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 463 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
465 | char * text = (char*)refs->mid_list->first->data; | 464 | char * text = (char*)refs->mid_list->first->data; |