-rw-r--r-- | noncore/net/mail/ProgrammersDoc/ReceivingMails.dia | bin | 3031 -> 3086 bytes | |||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 164 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 164 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 33 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 33 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 8 |
9 files changed, 220 insertions, 202 deletions
diff --git a/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia b/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia index dcef8c8..08c6434 100644 --- a/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia +++ b/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia | |||
Binary files differ | |||
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 725dcc9..5ce140e 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -217,15 +217,12 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
217 | mailimap_msg_att_dynamic*flist; | 217 | mailimap_msg_att_dynamic*flist; |
218 | mailimap_flag_fetch*cflag; | 218 | mailimap_flag_fetch*cflag; |
219 | QBitArray mFlags(7); | 219 | QBitArray mFlags(7); |
220 | QStringList addresslist; | ||
220 | 221 | ||
221 | if (!m_att) { | 222 | if (!m_att) { |
222 | return m; | 223 | return m; |
223 | } | 224 | } |
224 | 225 | ||
225 | #if 0 | ||
226 | MAILIMAP_FLAG_KEYWORD, /* keyword flag */ | ||
227 | MAILIMAP_FLAG_EXTENSION, /* \extension flag */ | ||
228 | #endif | ||
229 | c = clist_begin(m_att->list); | 226 | c = clist_begin(m_att->list); |
230 | while ( c ) { | 227 | while ( c ) { |
231 | current = c; | 228 | current = c; |
@@ -276,39 +273,32 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
276 | mailimap_envelope * head = item->msg_att_static->env; | 273 | mailimap_envelope * head = item->msg_att_static->env; |
277 | date = head->date; | 274 | date = head->date; |
278 | subject = head->subject; | 275 | subject = head->subject; |
279 | if (head->from!=NULL) | 276 | m = new RecMail(); |
280 | current_from = head->from->list->first; | 277 | if (head->from!=NULL) { |
281 | while (current_from != NULL) { | 278 | addresslist = address_list_to_stringlist(head->from->list); |
282 | from = ""; | 279 | if (addresslist.count()) { |
283 | named_from = false; | 280 | from = addresslist.first(); |
284 | current_address=(mailimap_address*)current_from->data; | ||
285 | current_from = current_from->next; | ||
286 | if (current_address->personal_name){ | ||
287 | from+=QString(current_address->personal_name); | ||
288 | from+=" "; | ||
289 | named_from = true; | ||
290 | } | 281 | } |
291 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
292 | from+="<"; | ||
293 | } | 282 | } |
294 | if (current_address->mailbox_name) { | 283 | if (head->to!=NULL) { |
295 | from+=QString(current_address->mailbox_name); | 284 | addresslist = address_list_to_stringlist(head->to->list); |
296 | from+="@"; | 285 | m->setTo(addresslist); |
297 | } | 286 | } |
298 | if (current_address->host_name) { | 287 | if (head->cc!=NULL) { |
299 | from+=QString(current_address->host_name); | 288 | addresslist = address_list_to_stringlist(head->cc->list); |
289 | m->setCC(addresslist); | ||
300 | } | 290 | } |
301 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 291 | if (head->bcc!=NULL) { |
302 | from+=">"; | 292 | addresslist = address_list_to_stringlist(head->bcc->list); |
293 | m->setBcc(addresslist); | ||
303 | } | 294 | } |
304 | } | ||
305 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s", | ||
306 | from.latin1(), | ||
307 | subject.latin1(),date.latin1()); | ||
308 | m = new RecMail(); | ||
309 | m->setSubject(subject); | 295 | m->setSubject(subject); |
310 | m->setFrom(from); | 296 | m->setFrom(from); |
311 | m->setDate(date); | 297 | m->setDate(date); |
298 | m->setMsgid(QString(head->message_id)); | ||
299 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s", | ||
300 | from.latin1(), | ||
301 | subject.latin1(),date.latin1(),m->Msgid().latin1()); | ||
312 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 302 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
313 | mailimap_date_time*d = item->msg_att_static->internal_date; | 303 | mailimap_date_time*d = item->msg_att_static->internal_date; |
314 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); | 304 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); |
@@ -329,64 +319,9 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
329 | return m; | 319 | return m; |
330 | } | 320 | } |
331 | 321 | ||
332 | #if 1 | ||
333 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 322 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
334 | { | 323 | { |
335 | RecBody body; | 324 | RecBody body; |
336 | QString body_text; | ||
337 | |||
338 | const char *mb; | ||
339 | int err = MAILIMAP_NO_ERROR; | ||
340 | clist *result; | ||
341 | clistcell *current; | ||
342 | mailimap_fetch_att *fetchAtt; | ||
343 | mailimap_fetch_type *fetchType; | ||
344 | mailimap_set *set; | ||
345 | |||
346 | mb = mail.getMbox().latin1(); | ||
347 | |||
348 | login(); | ||
349 | if (!m_imap) { | ||
350 | return body; | ||
351 | } | ||
352 | /* select mailbox READONLY for operations */ | ||
353 | err = mailimap_examine( m_imap, (char*)mb); | ||
354 | if ( err != MAILIMAP_NO_ERROR ) { | ||
355 | qDebug("error selecting mailbox: %s",m_imap->response); | ||
356 | logout(); | ||
357 | return body; | ||
358 | } | ||
359 | result = clist_new(); | ||
360 | /* the range has to start at 1!!! not with 0!!!! */ | ||
361 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
362 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | ||
363 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
364 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
365 | mailimap_set_free( set ); | ||
366 | mailimap_fetch_type_free( fetchType ); | ||
367 | |||
368 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
369 | mailimap_msg_att * msg_att; | ||
370 | msg_att = (mailimap_msg_att*)current->data; | ||
371 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
372 | |||
373 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | ||
374 | body_text = item->msg_att_static->rfc822_text; | ||
375 | body.setBodytext(body_text); | ||
376 | } | ||
377 | } else { | ||
378 | qDebug("error fetching text: %s",m_imap->response); | ||
379 | } | ||
380 | |||
381 | clist_free(result); | ||
382 | logout(); | ||
383 | return body; | ||
384 | } | ||
385 | |||
386 | #else | ||
387 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
388 | { | ||
389 | QString body = ""; | ||
390 | const char *mb; | 325 | const char *mb; |
391 | int err = MAILIMAP_NO_ERROR; | 326 | int err = MAILIMAP_NO_ERROR; |
392 | clist *result; | 327 | clist *result; |
@@ -424,7 +359,7 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
424 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 359 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
425 | body_desc = item->msg_att_static->body; | 360 | body_desc = item->msg_att_static->body; |
426 | if (body_desc->type==MAILIMAP_BODY_1PART) { | 361 | if (body_desc->type==MAILIMAP_BODY_1PART) { |
427 | body = searchBodyText(mail,body_desc->body_1part); | 362 | searchBodyText(mail,body_desc->body_1part,body); |
428 | } else { | 363 | } else { |
429 | } | 364 | } |
430 | 365 | ||
@@ -436,28 +371,26 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
436 | logout(); | 371 | logout(); |
437 | return body; | 372 | return body; |
438 | } | 373 | } |
439 | #endif | ||
440 | 374 | ||
441 | QString IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription) | 375 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
442 | { | 376 | { |
443 | QString Body=""; | ||
444 | if (!mailDescription) { | 377 | if (!mailDescription) { |
445 | return Body; | 378 | return; |
446 | } | 379 | } |
447 | switch (mailDescription->type) { | 380 | switch (mailDescription->type) { |
448 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 381 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
449 | return getPlainBody(mail); | 382 | fillPlainBody(mail,target_body,mailDescription->body_type_text); |
450 | break; | 383 | break; |
451 | default: | 384 | default: |
452 | break; | 385 | break; |
453 | } | 386 | } |
454 | return Body; | 387 | return; |
455 | } | 388 | } |
456 | 389 | ||
457 | QString IMAPwrapper::getPlainBody(const RecMail&mail) | 390 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body) |
458 | { | 391 | { |
459 | QString body = ""; | ||
460 | const char *mb; | 392 | const char *mb; |
393 | QString body=""; | ||
461 | int err = MAILIMAP_NO_ERROR; | 394 | int err = MAILIMAP_NO_ERROR; |
462 | clist *result; | 395 | clist *result; |
463 | clistcell *current; | 396 | clistcell *current; |
@@ -468,8 +401,9 @@ QString IMAPwrapper::getPlainBody(const RecMail&mail) | |||
468 | mb = mail.getMbox().latin1(); | 401 | mb = mail.getMbox().latin1(); |
469 | 402 | ||
470 | if (!m_imap) { | 403 | if (!m_imap) { |
471 | return body; | 404 | return; |
472 | } | 405 | } |
406 | |||
473 | result = clist_new(); | 407 | result = clist_new(); |
474 | /* the range has to start at 1!!! not with 0!!!! */ | 408 | /* the range has to start at 1!!! not with 0!!!! */ |
475 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 409 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
@@ -490,5 +424,45 @@ QString IMAPwrapper::getPlainBody(const RecMail&mail) | |||
490 | qDebug("error fetching text: %s",m_imap->response); | 424 | qDebug("error fetching text: %s",m_imap->response); |
491 | } | 425 | } |
492 | clist_free(result); | 426 | clist_free(result); |
493 | return body; | 427 | target_body.setBodytext(body); |
428 | return; | ||
429 | } | ||
430 | |||
431 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | ||
432 | { | ||
433 | QStringList l; | ||
434 | QString from; | ||
435 | bool named_from; | ||
436 | clistcell *current = NULL; | ||
437 | mailimap_address * current_address=NULL; | ||
438 | if (!list) { | ||
439 | return l; | ||
440 | } | ||
441 | current = clist_begin(list); | ||
442 | while (current!= NULL) { | ||
443 | from = ""; | ||
444 | named_from = false; | ||
445 | current_address=(mailimap_address*)current->data; | ||
446 | current = current->next; | ||
447 | if (current_address->personal_name){ | ||
448 | from+=QString(current_address->personal_name); | ||
449 | from+=" "; | ||
450 | named_from = true; | ||
451 | } | ||
452 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
453 | from+="<"; | ||
454 | } | ||
455 | if (current_address->mailbox_name) { | ||
456 | from+=QString(current_address->mailbox_name); | ||
457 | from+="@"; | ||
458 | } | ||
459 | if (current_address->host_name) { | ||
460 | from+=QString(current_address->host_name); | ||
461 | } | ||
462 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
463 | from+=">"; | ||
464 | } | ||
465 | l.append(QString(from)); | ||
466 | } | ||
467 | return l; | ||
494 | } | 468 | } |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 1423faf..6565896 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | ||
9 | class RecMail; | 10 | class RecMail; |
10 | class RecBody; | 11 | class RecBody; |
11 | 12 | ||
@@ -25,8 +26,9 @@ protected: | |||
25 | RecMail*parse_list_result(mailimap_msg_att*); | 26 | RecMail*parse_list_result(mailimap_msg_att*); |
26 | void login(); | 27 | void login(); |
27 | void logout(); | 28 | void logout(); |
28 | QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription); | 29 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
29 | QString getPlainBody(const RecMail&mail); | 30 | void fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body); |
31 | QStringList address_list_to_stringlist(clist*list); | ||
30 | 32 | ||
31 | private: | 33 | private: |
32 | IMAPaccount *account; | 34 | IMAPaccount *account; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 725dcc9..5ce140e 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -217,15 +217,12 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
217 | mailimap_msg_att_dynamic*flist; | 217 | mailimap_msg_att_dynamic*flist; |
218 | mailimap_flag_fetch*cflag; | 218 | mailimap_flag_fetch*cflag; |
219 | QBitArray mFlags(7); | 219 | QBitArray mFlags(7); |
220 | QStringList addresslist; | ||
220 | 221 | ||
221 | if (!m_att) { | 222 | if (!m_att) { |
222 | return m; | 223 | return m; |
223 | } | 224 | } |
224 | 225 | ||
225 | #if 0 | ||
226 | MAILIMAP_FLAG_KEYWORD, /* keyword flag */ | ||
227 | MAILIMAP_FLAG_EXTENSION, /* \extension flag */ | ||
228 | #endif | ||
229 | c = clist_begin(m_att->list); | 226 | c = clist_begin(m_att->list); |
230 | while ( c ) { | 227 | while ( c ) { |
231 | current = c; | 228 | current = c; |
@@ -276,39 +273,32 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
276 | mailimap_envelope * head = item->msg_att_static->env; | 273 | mailimap_envelope * head = item->msg_att_static->env; |
277 | date = head->date; | 274 | date = head->date; |
278 | subject = head->subject; | 275 | subject = head->subject; |
279 | if (head->from!=NULL) | 276 | m = new RecMail(); |
280 | current_from = head->from->list->first; | 277 | if (head->from!=NULL) { |
281 | while (current_from != NULL) { | 278 | addresslist = address_list_to_stringlist(head->from->list); |
282 | from = ""; | 279 | if (addresslist.count()) { |
283 | named_from = false; | 280 | from = addresslist.first(); |
284 | current_address=(mailimap_address*)current_from->data; | ||
285 | current_from = current_from->next; | ||
286 | if (current_address->personal_name){ | ||
287 | from+=QString(current_address->personal_name); | ||
288 | from+=" "; | ||
289 | named_from = true; | ||
290 | } | 281 | } |
291 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
292 | from+="<"; | ||
293 | } | 282 | } |
294 | if (current_address->mailbox_name) { | 283 | if (head->to!=NULL) { |
295 | from+=QString(current_address->mailbox_name); | 284 | addresslist = address_list_to_stringlist(head->to->list); |
296 | from+="@"; | 285 | m->setTo(addresslist); |
297 | } | 286 | } |
298 | if (current_address->host_name) { | 287 | if (head->cc!=NULL) { |
299 | from+=QString(current_address->host_name); | 288 | addresslist = address_list_to_stringlist(head->cc->list); |
289 | m->setCC(addresslist); | ||
300 | } | 290 | } |
301 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 291 | if (head->bcc!=NULL) { |
302 | from+=">"; | 292 | addresslist = address_list_to_stringlist(head->bcc->list); |
293 | m->setBcc(addresslist); | ||
303 | } | 294 | } |
304 | } | ||
305 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s", | ||
306 | from.latin1(), | ||
307 | subject.latin1(),date.latin1()); | ||
308 | m = new RecMail(); | ||
309 | m->setSubject(subject); | 295 | m->setSubject(subject); |
310 | m->setFrom(from); | 296 | m->setFrom(from); |
311 | m->setDate(date); | 297 | m->setDate(date); |
298 | m->setMsgid(QString(head->message_id)); | ||
299 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s", | ||
300 | from.latin1(), | ||
301 | subject.latin1(),date.latin1(),m->Msgid().latin1()); | ||
312 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 302 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
313 | mailimap_date_time*d = item->msg_att_static->internal_date; | 303 | mailimap_date_time*d = item->msg_att_static->internal_date; |
314 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); | 304 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); |
@@ -329,64 +319,9 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
329 | return m; | 319 | return m; |
330 | } | 320 | } |
331 | 321 | ||
332 | #if 1 | ||
333 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 322 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
334 | { | 323 | { |
335 | RecBody body; | 324 | RecBody body; |
336 | QString body_text; | ||
337 | |||
338 | const char *mb; | ||
339 | int err = MAILIMAP_NO_ERROR; | ||
340 | clist *result; | ||
341 | clistcell *current; | ||
342 | mailimap_fetch_att *fetchAtt; | ||
343 | mailimap_fetch_type *fetchType; | ||
344 | mailimap_set *set; | ||
345 | |||
346 | mb = mail.getMbox().latin1(); | ||
347 | |||
348 | login(); | ||
349 | if (!m_imap) { | ||
350 | return body; | ||
351 | } | ||
352 | /* select mailbox READONLY for operations */ | ||
353 | err = mailimap_examine( m_imap, (char*)mb); | ||
354 | if ( err != MAILIMAP_NO_ERROR ) { | ||
355 | qDebug("error selecting mailbox: %s",m_imap->response); | ||
356 | logout(); | ||
357 | return body; | ||
358 | } | ||
359 | result = clist_new(); | ||
360 | /* the range has to start at 1!!! not with 0!!!! */ | ||
361 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | ||
362 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | ||
363 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
364 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
365 | mailimap_set_free( set ); | ||
366 | mailimap_fetch_type_free( fetchType ); | ||
367 | |||
368 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
369 | mailimap_msg_att * msg_att; | ||
370 | msg_att = (mailimap_msg_att*)current->data; | ||
371 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | ||
372 | |||
373 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | ||
374 | body_text = item->msg_att_static->rfc822_text; | ||
375 | body.setBodytext(body_text); | ||
376 | } | ||
377 | } else { | ||
378 | qDebug("error fetching text: %s",m_imap->response); | ||
379 | } | ||
380 | |||
381 | clist_free(result); | ||
382 | logout(); | ||
383 | return body; | ||
384 | } | ||
385 | |||
386 | #else | ||
387 | QString IMAPwrapper::fetchBody(const RecMail&mail) | ||
388 | { | ||
389 | QString body = ""; | ||
390 | const char *mb; | 325 | const char *mb; |
391 | int err = MAILIMAP_NO_ERROR; | 326 | int err = MAILIMAP_NO_ERROR; |
392 | clist *result; | 327 | clist *result; |
@@ -424,7 +359,7 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
424 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 359 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; |
425 | body_desc = item->msg_att_static->body; | 360 | body_desc = item->msg_att_static->body; |
426 | if (body_desc->type==MAILIMAP_BODY_1PART) { | 361 | if (body_desc->type==MAILIMAP_BODY_1PART) { |
427 | body = searchBodyText(mail,body_desc->body_1part); | 362 | searchBodyText(mail,body_desc->body_1part,body); |
428 | } else { | 363 | } else { |
429 | } | 364 | } |
430 | 365 | ||
@@ -436,28 +371,26 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) | |||
436 | logout(); | 371 | logout(); |
437 | return body; | 372 | return body; |
438 | } | 373 | } |
439 | #endif | ||
440 | 374 | ||
441 | QString IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription) | 375 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
442 | { | 376 | { |
443 | QString Body=""; | ||
444 | if (!mailDescription) { | 377 | if (!mailDescription) { |
445 | return Body; | 378 | return; |
446 | } | 379 | } |
447 | switch (mailDescription->type) { | 380 | switch (mailDescription->type) { |
448 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 381 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
449 | return getPlainBody(mail); | 382 | fillPlainBody(mail,target_body,mailDescription->body_type_text); |
450 | break; | 383 | break; |
451 | default: | 384 | default: |
452 | break; | 385 | break; |
453 | } | 386 | } |
454 | return Body; | 387 | return; |
455 | } | 388 | } |
456 | 389 | ||
457 | QString IMAPwrapper::getPlainBody(const RecMail&mail) | 390 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body) |
458 | { | 391 | { |
459 | QString body = ""; | ||
460 | const char *mb; | 392 | const char *mb; |
393 | QString body=""; | ||
461 | int err = MAILIMAP_NO_ERROR; | 394 | int err = MAILIMAP_NO_ERROR; |
462 | clist *result; | 395 | clist *result; |
463 | clistcell *current; | 396 | clistcell *current; |
@@ -468,8 +401,9 @@ QString IMAPwrapper::getPlainBody(const RecMail&mail) | |||
468 | mb = mail.getMbox().latin1(); | 401 | mb = mail.getMbox().latin1(); |
469 | 402 | ||
470 | if (!m_imap) { | 403 | if (!m_imap) { |
471 | return body; | 404 | return; |
472 | } | 405 | } |
406 | |||
473 | result = clist_new(); | 407 | result = clist_new(); |
474 | /* the range has to start at 1!!! not with 0!!!! */ | 408 | /* the range has to start at 1!!! not with 0!!!! */ |
475 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 409 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
@@ -490,5 +424,45 @@ QString IMAPwrapper::getPlainBody(const RecMail&mail) | |||
490 | qDebug("error fetching text: %s",m_imap->response); | 424 | qDebug("error fetching text: %s",m_imap->response); |
491 | } | 425 | } |
492 | clist_free(result); | 426 | clist_free(result); |
493 | return body; | 427 | target_body.setBodytext(body); |
428 | return; | ||
429 | } | ||
430 | |||
431 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | ||
432 | { | ||
433 | QStringList l; | ||
434 | QString from; | ||
435 | bool named_from; | ||
436 | clistcell *current = NULL; | ||
437 | mailimap_address * current_address=NULL; | ||
438 | if (!list) { | ||
439 | return l; | ||
440 | } | ||
441 | current = clist_begin(list); | ||
442 | while (current!= NULL) { | ||
443 | from = ""; | ||
444 | named_from = false; | ||
445 | current_address=(mailimap_address*)current->data; | ||
446 | current = current->next; | ||
447 | if (current_address->personal_name){ | ||
448 | from+=QString(current_address->personal_name); | ||
449 | from+=" "; | ||
450 | named_from = true; | ||
451 | } | ||
452 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
453 | from+="<"; | ||
454 | } | ||
455 | if (current_address->mailbox_name) { | ||
456 | from+=QString(current_address->mailbox_name); | ||
457 | from+="@"; | ||
458 | } | ||
459 | if (current_address->host_name) { | ||
460 | from+=QString(current_address->host_name); | ||
461 | } | ||
462 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | ||
463 | from+=">"; | ||
464 | } | ||
465 | l.append(QString(from)); | ||
466 | } | ||
467 | return l; | ||
494 | } | 468 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 1423faf..6565896 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | ||
9 | class RecMail; | 10 | class RecMail; |
10 | class RecBody; | 11 | class RecBody; |
11 | 12 | ||
@@ -25,8 +26,9 @@ protected: | |||
25 | RecMail*parse_list_result(mailimap_msg_att*); | 26 | RecMail*parse_list_result(mailimap_msg_att*); |
26 | void login(); | 27 | void login(); |
27 | void logout(); | 28 | void logout(); |
28 | QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription); | 29 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
29 | QString getPlainBody(const RecMail&mail); | 30 | void fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body); |
31 | QStringList address_list_to_stringlist(clist*list); | ||
30 | 32 | ||
31 | private: | 33 | private: |
32 | IMAPaccount *account; | 34 | IMAPaccount *account; |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 9f2c9e3..f9e5794 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -2,8 +2,38 @@ | |||
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | 5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | ||
8 | } | ||
9 | |||
10 | RecMail::RecMail(const RecMail&old) | ||
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | ||
12 | { | ||
13 | init(); | ||
14 | copy_old(old); | ||
15 | qDebug("Copy constructor RecMail"); | ||
16 | } | ||
17 | |||
18 | void RecMail::copy_old(const RecMail&old) | ||
19 | { | ||
20 | subject = old.subject; | ||
21 | date = old.date; | ||
22 | mbox = old.mbox; | ||
23 | msg_id = old.msg_id; | ||
24 | msg_number = old.msg_number; | ||
25 | from = old.from; | ||
26 | msg_flags = old.msg_flags; | ||
27 | to = old.to; | ||
28 | cc = old.cc; | ||
29 | bcc = old.bcc; | ||
30 | } | ||
31 | |||
32 | void RecMail::init() | ||
33 | { | ||
34 | to.clear(); | ||
35 | cc.clear(); | ||
36 | bcc.clear(); | ||
7 | } | 37 | } |
8 | 38 | ||
9 | void RecMail::setTo(const QStringList&list) | 39 | void RecMail::setTo(const QStringList&list) |
@@ -36,7 +66,6 @@ const QStringList& RecMail::Bcc()const | |||
36 | return bcc; | 66 | return bcc; |
37 | } | 67 | } |
38 | 68 | ||
39 | |||
40 | RecPart::RecPart() | 69 | RecPart::RecPart() |
41 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") | 70 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") |
42 | { | 71 | { |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index bb6a483..c8d533a 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -29,6 +29,7 @@ class RecMail | |||
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | RecMail(); | 31 | RecMail(); |
32 | RecMail(const RecMail&old); | ||
32 | virtual ~RecMail(){} | 33 | virtual ~RecMail(){} |
33 | 34 | ||
34 | const int getNumber()const{return msg_number;} | 35 | const int getNumber()const{return msg_number;} |
@@ -41,6 +42,8 @@ public: | |||
41 | void setSubject( const QString&s ) { subject = s; } | 42 | void setSubject( const QString&s ) { subject = s; } |
42 | const QString&getMbox()const{return mbox;} | 43 | const QString&getMbox()const{return mbox;} |
43 | void setMbox(const QString&box){mbox = box;} | 44 | void setMbox(const QString&box){mbox = box;} |
45 | void setMsgid(const QString&id){msg_id=id;} | ||
46 | const QString&Msgid()const{return msg_id;} | ||
44 | 47 | ||
45 | void setTo(const QStringList&list); | 48 | void setTo(const QStringList&list); |
46 | const QStringList&To()const; | 49 | const QStringList&To()const; |
@@ -48,15 +51,16 @@ public: | |||
48 | const QStringList&CC()const; | 51 | const QStringList&CC()const; |
49 | void setBcc(const QStringList&list); | 52 | void setBcc(const QStringList&list); |
50 | const QStringList&Bcc()const; | 53 | const QStringList&Bcc()const; |
51 | |||
52 | const QBitArray&getFlags()const{return msg_flags;} | 54 | const QBitArray&getFlags()const{return msg_flags;} |
53 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 55 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
54 | 56 | ||
55 | protected: | 57 | protected: |
56 | QString subject,date,from,mbox; | 58 | QString subject,date,from,mbox,msg_id; |
57 | int msg_number; | 59 | int msg_number; |
58 | QBitArray msg_flags; | 60 | QBitArray msg_flags; |
59 | QStringList to,cc,bcc; | 61 | QStringList to,cc,bcc; |
62 | void init(); | ||
63 | void copy_old(const RecMail&old); | ||
60 | }; | 64 | }; |
61 | 65 | ||
62 | class RecPart | 66 | class RecPart |
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 9f2c9e3..f9e5794 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -2,8 +2,38 @@ | |||
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) | 5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | ||
8 | } | ||
9 | |||
10 | RecMail::RecMail(const RecMail&old) | ||
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | ||
12 | { | ||
13 | init(); | ||
14 | copy_old(old); | ||
15 | qDebug("Copy constructor RecMail"); | ||
16 | } | ||
17 | |||
18 | void RecMail::copy_old(const RecMail&old) | ||
19 | { | ||
20 | subject = old.subject; | ||
21 | date = old.date; | ||
22 | mbox = old.mbox; | ||
23 | msg_id = old.msg_id; | ||
24 | msg_number = old.msg_number; | ||
25 | from = old.from; | ||
26 | msg_flags = old.msg_flags; | ||
27 | to = old.to; | ||
28 | cc = old.cc; | ||
29 | bcc = old.bcc; | ||
30 | } | ||
31 | |||
32 | void RecMail::init() | ||
33 | { | ||
34 | to.clear(); | ||
35 | cc.clear(); | ||
36 | bcc.clear(); | ||
7 | } | 37 | } |
8 | 38 | ||
9 | void RecMail::setTo(const QStringList&list) | 39 | void RecMail::setTo(const QStringList&list) |
@@ -36,7 +66,6 @@ const QStringList& RecMail::Bcc()const | |||
36 | return bcc; | 66 | return bcc; |
37 | } | 67 | } |
38 | 68 | ||
39 | |||
40 | RecPart::RecPart() | 69 | RecPart::RecPart() |
41 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") | 70 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") |
42 | { | 71 | { |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index bb6a483..c8d533a 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -29,6 +29,7 @@ class RecMail | |||
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | RecMail(); | 31 | RecMail(); |
32 | RecMail(const RecMail&old); | ||
32 | virtual ~RecMail(){} | 33 | virtual ~RecMail(){} |
33 | 34 | ||
34 | const int getNumber()const{return msg_number;} | 35 | const int getNumber()const{return msg_number;} |
@@ -41,6 +42,8 @@ public: | |||
41 | void setSubject( const QString&s ) { subject = s; } | 42 | void setSubject( const QString&s ) { subject = s; } |
42 | const QString&getMbox()const{return mbox;} | 43 | const QString&getMbox()const{return mbox;} |
43 | void setMbox(const QString&box){mbox = box;} | 44 | void setMbox(const QString&box){mbox = box;} |
45 | void setMsgid(const QString&id){msg_id=id;} | ||
46 | const QString&Msgid()const{return msg_id;} | ||
44 | 47 | ||
45 | void setTo(const QStringList&list); | 48 | void setTo(const QStringList&list); |
46 | const QStringList&To()const; | 49 | const QStringList&To()const; |
@@ -48,15 +51,16 @@ public: | |||
48 | const QStringList&CC()const; | 51 | const QStringList&CC()const; |
49 | void setBcc(const QStringList&list); | 52 | void setBcc(const QStringList&list); |
50 | const QStringList&Bcc()const; | 53 | const QStringList&Bcc()const; |
51 | |||
52 | const QBitArray&getFlags()const{return msg_flags;} | 54 | const QBitArray&getFlags()const{return msg_flags;} |
53 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 55 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
54 | 56 | ||
55 | protected: | 57 | protected: |
56 | QString subject,date,from,mbox; | 58 | QString subject,date,from,mbox,msg_id; |
57 | int msg_number; | 59 | int msg_number; |
58 | QBitArray msg_flags; | 60 | QBitArray msg_flags; |
59 | QStringList to,cc,bcc; | 61 | QStringList to,cc,bcc; |
62 | void init(); | ||
63 | void copy_old(const RecMail&old); | ||
60 | }; | 64 | }; |
61 | 65 | ||
62 | class RecPart | 66 | class RecPart |