Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 9614d53..2b04847 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,13 +1,16 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | ||
7 | #include <kglobal.h> | ||
8 | #include <kstandarddirs.h> | ||
6 | 9 | ||
7 | 10 | ||
8 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
9 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
10 | : AbstractMail() | 13 | : AbstractMail() |
11 | { | 14 | { |
12 | bodyCache.clear(); | 15 | bodyCache.clear(); |
13 | m_storage = 0; | 16 | m_storage = 0; |
@@ -19,16 +22,58 @@ Genericwrapper::~Genericwrapper() | |||
19 | if (m_folder) { | 22 | if (m_folder) { |
20 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
21 | } | 24 | } |
22 | if (m_storage) { | 25 | if (m_storage) { |
23 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
24 | } | 27 | } |
25 | cleanMimeCache(); | 28 | cleanMimeCache(); |
26 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
31 | { | ||
32 | static bool init = false ; | ||
33 | if ( ! init ) { | ||
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | ||
35 | kon.setGroup("Locale"); | ||
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | ||
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | ||
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | ||
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | ||
40 | kon.setGroup("Time & Date"); | ||
41 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | ||
42 | kon.readNumEntry( "DaylightsavingStart", 90), | ||
43 | kon.readNumEntry( "DaylightsavingEnd",304) ); | ||
44 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | ||
45 | |||
46 | init = true; | ||
47 | |||
48 | } | ||
49 | QDateTime dt (QDate(date->dt_year,date->dt_month, date->dt_day ),QTime(date->dt_hour, date->dt_min, date->dt_sec ) ); | ||
50 | int off = KGlobal::locale()->localTimeOffset( dt ); | ||
51 | dt = dt.addSecs( off*60 ); | ||
52 | QString ret = KGlobal::locale()->formatDateTime( dt,true,true); | ||
53 | if ( off < 0 ) | ||
54 | ret += " -"; | ||
55 | else | ||
56 | ret += " +"; | ||
57 | ret += QString::number( off / 60 ); | ||
58 | ret += "h"; | ||
59 | #if 0 | ||
60 | char tmp[23]; | ||
61 | |||
62 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
63 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
64 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
65 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
66 | |||
67 | |||
68 | return QString( tmp ); | ||
69 | #endif | ||
70 | return ret; | ||
71 | } | ||
27 | 72 | ||
28 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 73 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
29 | { | 74 | { |
30 | if (!mime) { | 75 | if (!mime) { |
31 | return; | 76 | return; |
32 | } | 77 | } |
33 | mailmime_field*field = 0; | 78 | mailmime_field*field = 0; |
34 | mailmime_single_fields fields; | 79 | mailmime_single_fields fields; |
@@ -237,27 +282,16 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | |||
237 | RecBodyP body = new RecBody(); | 282 | RecBodyP body = new RecBody(); |
238 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 283 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
239 | err = mailmessage_get_bodystructure(msg,&mime); | 284 | err = mailmessage_get_bodystructure(msg,&mime); |
240 | QValueList<int>recList; | 285 | QValueList<int>recList; |
241 | traverseBody(body,msg,mime,recList); | 286 | traverseBody(body,msg,mime,recList); |
242 | return body; | 287 | return body; |
243 | } | 288 | } |
244 | 289 | ||
245 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | ||
246 | { | ||
247 | char tmp[23]; | ||
248 | |||
249 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | ||
250 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
251 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | ||
252 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
253 | |||
254 | return QString( tmp ); | ||
255 | } | ||
256 | 290 | ||
257 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 291 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
258 | { | 292 | { |
259 | QString result( "" ); | 293 | QString result( "" ); |
260 | 294 | ||
261 | bool first = true; | 295 | bool first = true; |
262 | if (list == 0) return result; | 296 | if (list == 0) return result; |
263 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 297 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
@@ -443,18 +477,24 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & | |||
443 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 477 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
444 | } else { | 478 | } else { |
445 | mail->setTo(mailbox); | 479 | mail->setTo(mailbox); |
446 | } | 480 | } |
447 | if (single_fields.fld_cc) | 481 | if (single_fields.fld_cc) |
448 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 482 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
449 | if (single_fields.fld_bcc) | 483 | if (single_fields.fld_bcc) |
450 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 484 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
451 | if (single_fields.fld_orig_date) | 485 | if (single_fields.fld_orig_date) { |
452 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 486 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
487 | char tmp[23]; | ||
488 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | ||
489 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
490 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
491 | mail->setIsoDate( QString( tmp ) ); | ||
492 | } | ||
453 | // crashes when accessing pop3 account? | 493 | // crashes when accessing pop3 account? |
454 | if (single_fields.fld_message_id) { | 494 | if (single_fields.fld_message_id) { |
455 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 495 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
456 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 496 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
457 | } | 497 | } |
458 | if (single_fields.fld_reply_to) { | 498 | if (single_fields.fld_reply_to) { |
459 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 499 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
460 | if (t.count()>0) { | 500 | if (t.count()>0) { |