Diffstat (limited to 'noncore/net/mail/libmailwrapper/genericwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index eb2c031..137a6ef 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -30,13 +30,13 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
30 | mailmime_single_fields fields; | 30 | mailmime_single_fields fields; |
31 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 31 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
32 | if (mime->mm_mime_fields != NULL) { | 32 | if (mime->mm_mime_fields != NULL) { |
33 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 33 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
34 | mime->mm_content_type); | 34 | mime->mm_content_type); |
35 | } | 35 | } |
36 | 36 | ||
37 | mailmime_content*type = fields.fld_content; | 37 | mailmime_content*type = fields.fld_content; |
38 | clistcell*current; | 38 | clistcell*current; |
39 | if (!type) { | 39 | if (!type) { |
40 | target.setType("text"); | 40 | target.setType("text"); |
41 | target.setSubtype("plain"); | 41 | target.setSubtype("plain"); |
42 | } else { | 42 | } else { |
@@ -142,13 +142,13 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
142 | int r; | 142 | int r; |
143 | char*data = 0; | 143 | char*data = 0; |
144 | size_t len; | 144 | size_t len; |
145 | clistiter * cur = 0; | 145 | clistiter * cur = 0; |
146 | QString b; | 146 | QString b; |
147 | RecPart part; | 147 | RecPart part; |
148 | 148 | ||
149 | switch (mime->mm_type) { | 149 | switch (mime->mm_type) { |
150 | case MAILMIME_SINGLE: | 150 | case MAILMIME_SINGLE: |
151 | { | 151 | { |
152 | QValueList<int>countlist = recList; | 152 | QValueList<int>countlist = recList; |
153 | countlist.append(current_count); | 153 | countlist.append(current_count); |
154 | r = mailmessage_fetch_section(message,mime,&data,&len); | 154 | r = mailmessage_fetch_section(message,mime,&data,&len); |
@@ -238,28 +238,28 @@ RecBody Genericwrapper::parseMail( mailmessage * msg ) | |||
238 | return body; | 238 | return body; |
239 | } | 239 | } |
240 | 240 | ||
241 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 241 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
242 | { | 242 | { |
243 | char tmp[23]; | 243 | char tmp[23]; |
244 | 244 | ||
245 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 245 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
246 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 246 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
247 | 247 | ||
248 | return QString( tmp ); | 248 | return QString( tmp ); |
249 | } | 249 | } |
250 | 250 | ||
251 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 251 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
252 | { | 252 | { |
253 | QString result( "" ); | 253 | QString result( "" ); |
254 | 254 | ||
255 | bool first = true; | 255 | bool first = true; |
256 | if (list == 0) return result; | 256 | if (list == 0) return result; |
257 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 257 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
258 | mailimf_address *addr = (mailimf_address *) current->data; | 258 | mailimf_address *addr = (mailimf_address *) current->data; |
259 | 259 | ||
260 | if ( !first ) { | 260 | if ( !first ) { |
261 | result.append( "," ); | 261 | result.append( "," ); |
262 | } else { | 262 | } else { |
263 | first = false; | 263 | first = false; |
264 | } | 264 | } |
265 | 265 | ||
@@ -272,13 +272,13 @@ QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | |||
272 | break; | 272 | break; |
273 | default: | 273 | default: |
274 | qDebug( "Generic: unkown mailimf address type" ); | 274 | qDebug( "Generic: unkown mailimf address type" ); |
275 | break; | 275 | break; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | return result; | 279 | return result; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 282 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
283 | { | 283 | { |
284 | QString result( "" ); | 284 | QString result( "" ); |
@@ -288,13 +288,13 @@ QString Genericwrapper::parseGroup( mailimf_group *group ) | |||
288 | 288 | ||
289 | if ( group->grp_mb_list != NULL ) { | 289 | if ( group->grp_mb_list != NULL ) { |
290 | result.append( parseMailboxList( group->grp_mb_list ) ); | 290 | result.append( parseMailboxList( group->grp_mb_list ) ); |
291 | } | 291 | } |
292 | 292 | ||
293 | result.append( ";" ); | 293 | result.append( ";" ); |
294 | 294 | ||
295 | return result; | 295 | return result; |
296 | } | 296 | } |
297 | 297 | ||
298 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 298 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
299 | { | 299 | { |
300 | QString result( "" ); | 300 | QString result( "" ); |
@@ -304,13 +304,13 @@ QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | |||
304 | } else { | 304 | } else { |
305 | result.append( convert_String(box->mb_display_name).latin1() ); | 305 | result.append( convert_String(box->mb_display_name).latin1() ); |
306 | result.append( " <" ); | 306 | result.append( " <" ); |
307 | result.append( box->mb_addr_spec ); | 307 | result.append( box->mb_addr_spec ); |
308 | result.append( ">" ); | 308 | result.append( ">" ); |
309 | } | 309 | } |
310 | 310 | ||
311 | return result; | 311 | return result; |
312 | } | 312 | } |
313 | 313 | ||
314 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 314 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
315 | { | 315 | { |
316 | QString result( "" ); | 316 | QString result( "" ); |
@@ -321,16 +321,16 @@ QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | |||
321 | 321 | ||
322 | if ( !first ) { | 322 | if ( !first ) { |
323 | result.append( "," ); | 323 | result.append( "," ); |
324 | } else { | 324 | } else { |
325 | first = false; | 325 | first = false; |
326 | } | 326 | } |
327 | 327 | ||
328 | result.append( parseMailbox( box ) ); | 328 | result.append( parseMailbox( box ) ); |
329 | } | 329 | } |
330 | 330 | ||
331 | return result; | 331 | return result; |
332 | } | 332 | } |
333 | 333 | ||
334 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) | 334 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) |
335 | { | 335 | { |
336 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 336 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
@@ -364,12 +364,32 @@ void Genericwrapper::cleanMimeCache() | |||
364 | if (t) delete t; | 364 | if (t) delete t; |
365 | } | 365 | } |
366 | bodyCache.clear(); | 366 | bodyCache.clear(); |
367 | qDebug("Genericwrapper: cache cleaned"); | 367 | qDebug("Genericwrapper: cache cleaned"); |
368 | } | 368 | } |
369 | 369 | ||
370 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | ||
371 | { | ||
372 | QStringList res; | ||
373 | if (!in_replies || !in_replies->mid_list) return res; | ||
374 | clistiter * current = 0; | ||
375 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | ||
376 | QString h((char*)current->data); | ||
377 | while (h.length()>0 && h[0]=='<') { | ||
378 | h.remove(0,1); | ||
379 | } | ||
380 | while (h.length()>0 && h[h.length()-1]=='>') { | ||
381 | h.remove(h.length()-1,1); | ||
382 | } | ||
383 | if (h.length()>0) { | ||
384 | res.append(h); | ||
385 | } | ||
386 | } | ||
387 | return res; | ||
388 | } | ||
389 | |||
370 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 390 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
371 | { | 391 | { |
372 | int r; | 392 | int r; |
373 | mailmessage_list * env_list = 0; | 393 | mailmessage_list * env_list = 0; |
374 | r = mailsession_get_messages_list(session,&env_list); | 394 | r = mailsession_get_messages_list(session,&env_list); |
375 | if (r != MAIL_NO_ERROR) { | 395 | if (r != MAIL_NO_ERROR) { |
@@ -381,13 +401,14 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const | |||
381 | qDebug("Error filling message list"); | 401 | qDebug("Error filling message list"); |
382 | if (env_list) { | 402 | if (env_list) { |
383 | mailmessage_list_free(env_list); | 403 | mailmessage_list_free(env_list); |
384 | } | 404 | } |
385 | return; | 405 | return; |
386 | } | 406 | } |
387 | mailimf_references * refs; | 407 | mailimf_references * refs = 0; |
408 | mailimf_in_reply_to * in_replies = 0; | ||
388 | uint32_t i = 0; | 409 | uint32_t i = 0; |
389 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 410 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
390 | mailmessage * msg; | 411 | mailmessage * msg; |
391 | QBitArray mFlags(7); | 412 | QBitArray mFlags(7); |
392 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 413 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
393 | if (msg->msg_fields == NULL) { | 414 | if (msg->msg_fields == NULL) { |
@@ -423,19 +444,24 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const | |||
423 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 444 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
424 | if (single_fields.fld_orig_date) | 445 | if (single_fields.fld_orig_date) |
425 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 446 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
426 | // crashes when accessing pop3 account? | 447 | // crashes when accessing pop3 account? |
427 | if (single_fields.fld_message_id->mid_value) { | 448 | if (single_fields.fld_message_id->mid_value) { |
428 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 449 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
429 | qDebug("Msqgid == %s",mail->Msgid().latin1()); | 450 | qDebug("Msgid == %s",mail->Msgid().latin1()); |
430 | } | 451 | } |
452 | |||
431 | refs = single_fields.fld_references; | 453 | refs = single_fields.fld_references; |
432 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 454 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
433 | char * text = (char*)refs->mid_list->first->data; | 455 | char * text = (char*)refs->mid_list->first->data; |
434 | mail->setReplyto(QString(text)); | 456 | mail->setReplyto(QString(text)); |
435 | } | 457 | } |
458 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | ||
459 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | ||
460 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | ||
461 | } | ||
436 | target.append(mail); | 462 | target.append(mail); |
437 | } | 463 | } |
438 | if (env_list) { | 464 | if (env_list) { |
439 | mailmessage_list_free(env_list); | 465 | mailmessage_list_free(env_list); |
440 | } | 466 | } |
441 | } | 467 | } |