Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index c3a1627..d99c6a3 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -6,101 +6,109 @@ | |||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | static bool init = false ; | 32 | static bool init = false ; |
33 | if ( ! init ) { | 33 | if ( ! init ) { |
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | 34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); |
35 | kon.setGroup("Locale"); | 35 | kon.setGroup("Locale"); |
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | 36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); |
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | 37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); |
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | 38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); |
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); | 40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); |
41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
42 | kon.setGroup("Time & Date"); | 42 | kon.setGroup("Time & Date"); |
43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | 43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), |
44 | kon.readNumEntry( "DaylightsavingStart", 90), | 44 | kon.readNumEntry( "DaylightsavingStart", 90), |
45 | kon.readNumEntry( "DaylightsavingEnd",304) ); | 45 | kon.readNumEntry( "DaylightsavingEnd",304) ); |
46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | 46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); |
47 | 47 | ||
48 | init = true; | 48 | init = true; |
49 | 49 | ||
50 | } | 50 | } |
51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
53 | QDateTime dt ( da ,ti ); | 53 | QDateTime dt ( da ,ti ); |
54 | int addsec = -date->dt_zone*36; | ||
55 | //qDebug("adsec1 %d ",addsec ); | ||
56 | dt = dt.addSecs( addsec ); | ||
54 | int off = KGlobal::locale()->localTimeOffset( dt ); | 57 | int off = KGlobal::locale()->localTimeOffset( dt ); |
55 | //dt = dt.addSecs( off*60 ); | 58 | //qDebug("adsec2 %d ",off*60 ); |
59 | |||
60 | dt = dt.addSecs( off*60 ); | ||
61 | return dt; | ||
62 | #if 0 | ||
56 | QString ret; | 63 | QString ret; |
57 | if ( da == QDate::currentDate () ) | 64 | if ( dt.date() == QDate::currentDate () ) |
58 | ret = KGlobal::locale()->formatTime( ti,true); | 65 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
59 | 66 | ||
60 | else { | 67 | else { |
61 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 68 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
62 | } | 69 | } |
70 | #endif | ||
63 | #if 0 | 71 | #if 0 |
64 | if ( off < 0 ) | 72 | if ( off < 0 ) |
65 | ret += " -"; | 73 | ret += " -"; |
66 | else | 74 | else |
67 | ret += " +"; | 75 | ret += " +"; |
68 | ret += QString::number( off / 60 ); | 76 | ret += QString::number( off / 60 ); |
69 | ret += "h"; | 77 | ret += "h"; |
70 | #endif | 78 | #endif |
71 | #if 0 | 79 | #if 0 |
72 | char tmp[23]; | 80 | char tmp[23]; |
73 | 81 | ||
74 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 82 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
75 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 83 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
76 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 84 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
77 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 85 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
78 | 86 | ||
79 | 87 | ||
80 | return QString( tmp ); | 88 | return QString( tmp ); |
81 | #endif | 89 | #endif |
82 | return ret; | 90 | //return ret; |
83 | } | 91 | } |
84 | 92 | ||
85 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 93 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
86 | { | 94 | { |
87 | if (!mime) { | 95 | if (!mime) { |
88 | return; | 96 | return; |
89 | } | 97 | } |
90 | mailmime_field*field = 0; | 98 | mailmime_field*field = 0; |
91 | mailmime_single_fields fields; | 99 | mailmime_single_fields fields; |
92 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 100 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
93 | if (mime->mm_mime_fields != NULL) { | 101 | if (mime->mm_mime_fields != NULL) { |
94 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 102 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
95 | mime->mm_content_type); | 103 | mime->mm_content_type); |
96 | } | 104 | } |
97 | 105 | ||
98 | mailmime_content*type = fields.fld_content; | 106 | mailmime_content*type = fields.fld_content; |
99 | clistcell*current; | 107 | clistcell*current; |
100 | if (!type) { | 108 | if (!type) { |
101 | target->setType("text"); | 109 | target->setType("text"); |
102 | target->setSubtype("plain"); | 110 | target->setSubtype("plain"); |
103 | } else { | 111 | } else { |
104 | target->setSubtype(type->ct_subtype); | 112 | target->setSubtype(type->ct_subtype); |
105 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 113 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
106 | case MAILMIME_DISCRETE_TYPE_TEXT: | 114 | case MAILMIME_DISCRETE_TYPE_TEXT: |
@@ -474,53 +482,60 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & | |||
474 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 482 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
475 | mFlags.setBit(FLAG_SEEN); | 483 | mFlags.setBit(FLAG_SEEN); |
476 | } | 484 | } |
477 | mailimf_single_fields single_fields; | 485 | mailimf_single_fields single_fields; |
478 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 486 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
479 | mail->setMsgsize(msg->msg_size); | 487 | mail->setMsgsize(msg->msg_size); |
480 | mail->setFlags(mFlags); | 488 | mail->setFlags(mFlags); |
481 | mail->setMbox(mailbox); | 489 | mail->setMbox(mailbox); |
482 | mail->setNumber(msg->msg_index); | 490 | mail->setNumber(msg->msg_index); |
483 | if (single_fields.fld_subject) | 491 | if (single_fields.fld_subject) |
484 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 492 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
485 | if (single_fields.fld_from) | 493 | if (single_fields.fld_from) |
486 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 494 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
487 | if (!mbox_as_to) { | 495 | if (!mbox_as_to) { |
488 | if (single_fields.fld_to) | 496 | if (single_fields.fld_to) |
489 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 497 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
490 | } else { | 498 | } else { |
491 | mail->setTo(mailbox); | 499 | mail->setTo(mailbox); |
492 | } | 500 | } |
493 | if (single_fields.fld_cc) | 501 | if (single_fields.fld_cc) |
494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 502 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
495 | if (single_fields.fld_bcc) | 503 | if (single_fields.fld_bcc) |
496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 504 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
497 | if (single_fields.fld_orig_date) { | 505 | if (single_fields.fld_orig_date) { |
498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 506 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); |
499 | char tmp[23]; | 507 | QString ret; |
500 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | 508 | if ( dt.date() == QDate::currentDate () ) |
501 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | 509 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
502 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 510 | else { |
511 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
512 | } | ||
513 | mail->setDate( ret ); | ||
514 | char tmp[20]; | ||
515 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | ||
516 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | ||
517 | //qDebug(" iso %s ", tmp); | ||
503 | mail->setIsoDate( QString( tmp ) ); | 518 | mail->setIsoDate( QString( tmp ) ); |
504 | } | 519 | } |
505 | // crashes when accessing pop3 account? | 520 | // crashes when accessing pop3 account? |
506 | if (single_fields.fld_message_id) { | 521 | if (single_fields.fld_message_id) { |
507 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 522 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
508 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 523 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
509 | } | 524 | } |
510 | if (single_fields.fld_reply_to) { | 525 | if (single_fields.fld_reply_to) { |
511 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 526 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
512 | if (t.count()>0) { | 527 | if (t.count()>0) { |
513 | mail->setReplyto(t[0]); | 528 | mail->setReplyto(t[0]); |
514 | } | 529 | } |
515 | } | 530 | } |
516 | #if 0 | 531 | #if 0 |
517 | refs = single_fields.fld_references; | 532 | refs = single_fields.fld_references; |
518 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 533 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
519 | char * text = (char*)refs->mid_list->first->data; | 534 | char * text = (char*)refs->mid_list->first->data; |
520 | mail->setReplyto(QString(text)); | 535 | mail->setReplyto(QString(text)); |
521 | } | 536 | } |
522 | #endif | 537 | #endif |
523 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 538 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
524 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 539 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
525 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 540 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
526 | } | 541 | } |