author | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
commit | 32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff) | |
tree | 8856a90d505df8dc3afa0d72541f27cb68913a0d /kmicromail/libmailwrapper/imapwrapper.cpp | |
parent | d7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff) | |
download | kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2 |
Mail enhancements
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 6faa524..5441a9b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,57 +1,58 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | ||
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | int IMAPwrapper::mMax = 0; | 13 | int IMAPwrapper::mMax = 0; |
13 | int IMAPwrapper::mCurrent = 0; | 14 | int IMAPwrapper::mCurrent = 0; |
14 | 15 | ||
15 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
16 | : AbstractMail() | 17 | : AbstractMail() |
17 | { | 18 | { |
18 | account = a; | 19 | account = a; |
19 | m_imap = 0; | 20 | m_imap = 0; |
20 | m_Lastmbox = ""; | 21 | m_Lastmbox = ""; |
21 | mCurrent = 0; | 22 | mCurrent = 0; |
22 | mMax = 0; | 23 | mMax = 0; |
23 | } | 24 | } |
24 | 25 | ||
25 | IMAPwrapper::~IMAPwrapper() | 26 | IMAPwrapper::~IMAPwrapper() |
26 | { | 27 | { |
27 | logout(); | 28 | logout(); |
28 | } | 29 | } |
29 | 30 | ||
30 | /* to avoid to often select statements in loops etc. | 31 | /* to avoid to often select statements in loops etc. |
31 | we trust that we are logged in and connection is established!*/ | 32 | we trust that we are logged in and connection is established!*/ |
32 | int IMAPwrapper::selectMbox(const QString&mbox) | 33 | int IMAPwrapper::selectMbox(const QString&mbox) |
33 | { | 34 | { |
34 | if (mbox == m_Lastmbox) { | 35 | if (mbox == m_Lastmbox) { |
35 | return MAILIMAP_NO_ERROR; | 36 | return MAILIMAP_NO_ERROR; |
36 | } | 37 | } |
37 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
38 | if ( err != MAILIMAP_NO_ERROR ) { | 39 | if ( err != MAILIMAP_NO_ERROR ) { |
39 | m_Lastmbox = ""; | 40 | m_Lastmbox = ""; |
40 | return err; | 41 | return err; |
41 | } | 42 | } |
42 | m_Lastmbox = mbox; | 43 | m_Lastmbox = mbox; |
43 | return err; | 44 | return err; |
44 | } | 45 | } |
45 | 46 | ||
46 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
47 | { | 48 | { |
48 | //qDebug("imap progress %d of %d ",current,maximum ); | 49 | //qDebug("imap progress %d of %d ",current,maximum ); |
49 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
50 | //qApp->processEvents() | 51 | //qApp->processEvents() |
51 | static int last = 0; | 52 | static int last = 0; |
52 | if ( last != current ) | 53 | if ( last != current ) |
53 | IMAPwrapper::progress(); | 54 | IMAPwrapper::progress(); |
54 | last = current; | 55 | last = current; |
55 | } | 56 | } |
56 | void IMAPwrapper::progress( QString m ) | 57 | void IMAPwrapper::progress( QString m ) |
57 | { | 58 | { |
@@ -411,98 +412,113 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
411 | continue; | 412 | continue; |
412 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
413 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
414 | if (!flist || !flist->att_list) { | 415 | if (!flist || !flist->att_list) { |
415 | continue; | 416 | continue; |
416 | } | 417 | } |
417 | cf = flist->att_list->first; | 418 | cf = flist->att_list->first; |
418 | if( ! cf ) | 419 | if( ! cf ) |
419 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
420 | cflag = (mailimap_flag_fetch*)cf->data; | 421 | cflag = (mailimap_flag_fetch*)cf->data; |
421 | if( ! cflag ) | 422 | if( ! cflag ) |
422 | qDebug("imap:not cflag "); | 423 | qDebug("imap:not cflag "); |
423 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
424 | switch (cflag->fl_flag->fl_type) { | 425 | switch (cflag->fl_flag->fl_type) { |
425 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
426 | mFlags.setBit(FLAG_ANSWERED); | 427 | mFlags.setBit(FLAG_ANSWERED); |
427 | break; | 428 | break; |
428 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
429 | mFlags.setBit(FLAG_FLAGGED); | 430 | mFlags.setBit(FLAG_FLAGGED); |
430 | break; | 431 | break; |
431 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
432 | mFlags.setBit(FLAG_DELETED); | 433 | mFlags.setBit(FLAG_DELETED); |
433 | break; | 434 | break; |
434 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
435 | mFlags.setBit(FLAG_SEEN); | 436 | mFlags.setBit(FLAG_SEEN); |
436 | break; | 437 | break; |
437 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
438 | mFlags.setBit(FLAG_DRAFT); | 439 | mFlags.setBit(FLAG_DRAFT); |
439 | break; | 440 | break; |
440 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
441 | break; | 442 | break; |
442 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
443 | break; | 444 | break; |
444 | default: | 445 | default: |
445 | break; | 446 | break; |
446 | } | 447 | } |
447 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
448 | mFlags.setBit(FLAG_RECENT); | 449 | mFlags.setBit(FLAG_RECENT); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | continue; | 452 | continue; |
452 | } | 453 | } |
453 | if ( item->att_data.att_static == NULL ) | 454 | if ( item->att_data.att_static == NULL ) |
454 | continue; | 455 | continue; |
455 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
456 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
457 | if ( head == NULL ) | 458 | if ( head == NULL ) |
458 | continue; | 459 | continue; |
459 | if ( head->env_date != NULL ) | 460 | if ( head->env_date != NULL ) { |
460 | m->setDate(head->env_date); | 461 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | ||
463 | struct mailimf_date_time* date = &result; | ||
464 | struct mailimf_date_time **re = &date; | ||
465 | size_t length = m->getDate().length(); | ||
466 | size_t index = 0; | ||
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | ||
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | ||
469 | char tmp[23]; | ||
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
472 | m->setIsoDate( QString( tmp ) ); | ||
473 | } else { | ||
474 | m->setIsoDate(head->env_date); | ||
475 | } | ||
476 | } | ||
461 | if ( head->env_subject != NULL ) | 477 | if ( head->env_subject != NULL ) |
462 | m->setSubject(convert_String((const char*)head->env_subject)); | 478 | m->setSubject(convert_String((const char*)head->env_subject)); |
463 | //m->setSubject(head->env_subject); | 479 | //m->setSubject(head->env_subject); |
464 | if (head->env_from!=NULL) { | 480 | if (head->env_from!=NULL) { |
465 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
466 | if (addresslist.count()) { | 482 | if (addresslist.count()) { |
467 | m->setFrom(addresslist.first()); | 483 | m->setFrom(addresslist.first()); |
468 | } | 484 | } |
469 | } | 485 | } |
470 | if (head->env_to!=NULL) { | 486 | if (head->env_to!=NULL) { |
471 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 487 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
472 | m->setTo(addresslist); | 488 | m->setTo(addresslist); |
473 | } | 489 | } |
474 | if (head->env_cc!=NULL) { | 490 | if (head->env_cc!=NULL) { |
475 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
476 | m->setCC(addresslist); | 492 | m->setCC(addresslist); |
477 | } | 493 | } |
478 | if (head->env_bcc!=NULL) { | 494 | if (head->env_bcc!=NULL) { |
479 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
480 | m->setBcc(addresslist); | 496 | m->setBcc(addresslist); |
481 | } | 497 | } |
482 | /* reply to address, eg. email. */ | 498 | /* reply to address, eg. email. */ |
483 | if (head->env_reply_to!=NULL) { | 499 | if (head->env_reply_to!=NULL) { |
484 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
485 | if (addresslist.count()) { | 501 | if (addresslist.count()) { |
486 | m->setReplyto(addresslist.first()); | 502 | m->setReplyto(addresslist.first()); |
487 | } | 503 | } |
488 | } | 504 | } |
489 | if (head->env_in_reply_to!=NULL) { | 505 | if (head->env_in_reply_to!=NULL) { |
490 | QString h(head->env_in_reply_to); | 506 | QString h(head->env_in_reply_to); |
491 | while (h.length()>0 && h[0]=='<') { | 507 | while (h.length()>0 && h[0]=='<') { |
492 | h.remove(0,1); | 508 | h.remove(0,1); |
493 | } | 509 | } |
494 | while (h.length()>0 && h[h.length()-1]=='>') { | 510 | while (h.length()>0 && h[h.length()-1]=='>') { |
495 | h.remove(h.length()-1,1); | 511 | h.remove(h.length()-1,1); |
496 | } | 512 | } |
497 | if (h.length()>0) { | 513 | if (h.length()>0) { |
498 | m->setInreply(QStringList(h)); | 514 | m->setInreply(QStringList(h)); |
499 | } | 515 | } |
500 | } | 516 | } |
501 | if (head->env_message_id != NULL) { | 517 | if (head->env_message_id != NULL) { |
502 | m->setMsgid(QString(head->env_message_id)); | 518 | m->setMsgid(QString(head->env_message_id)); |
503 | } | 519 | } |
504 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
505 | #if 0 | 521 | #if 0 |
506 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
507 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
508 | qDebug("time %s ",da.toString().latin1() ); | 524 | qDebug("time %s ",da.toString().latin1() ); |