Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (ignore 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 @@ -3,6 +3,9 @@ #include <libetpan/libetpan.h> #include "mailtypes.h" +#include <kconfig.h> +#include <kglobal.h> +#include <kstandarddirs.h> using namespace Opie::Core; @@ -24,6 +27,48 @@ Genericwrapper::~Genericwrapper() } cleanMimeCache(); } +QString Genericwrapper::parseDateTime( mailimf_date_time *date ) +{ + static bool init = false ; + if ( ! init ) { + KConfig kon ( locateLocal( "config", "korganizerrc" ) ); + kon.setGroup("Locale"); + KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); + QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); + KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); + KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); + kon.setGroup("Time & Date"); + KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), + kon.readNumEntry( "DaylightsavingStart", 90), + kon.readNumEntry( "DaylightsavingEnd",304) ); + KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); + + init = true; + + } + QDateTime dt (QDate(date->dt_year,date->dt_month, date->dt_day ),QTime(date->dt_hour, date->dt_min, date->dt_sec ) ); + int off = KGlobal::locale()->localTimeOffset( dt ); + dt = dt.addSecs( off*60 ); + QString ret = KGlobal::locale()->formatDateTime( dt,true,true); + if ( off < 0 ) + ret += " -"; + else + ret += " +"; + ret += QString::number( off / 60 ); + ret += "h"; +#if 0 + char tmp[23]; + + // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", + // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", + date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + + + return QString( tmp ); +#endif + return ret; +} void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) { @@ -242,17 +287,6 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg ) return body; } -QString Genericwrapper::parseDateTime( mailimf_date_time *date ) -{ - char tmp[23]; - - // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", - // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); - snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", - date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); - - return QString( tmp ); -} QString Genericwrapper::parseAddressList( mailimf_address_list *list ) { @@ -448,8 +482,14 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); - if (single_fields.fld_orig_date) + if (single_fields.fld_orig_date) { mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); + char tmp[23]; + struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; + snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", + date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); + mail->setIsoDate( QString( tmp ) ); + } // crashes when accessing pop3 account? if (single_fields.fld_message_id) { mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |