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 @@ -1,11 +1,14 @@ // CHANGED 2004-09-31 Lutz Rogowski #include "genericwrapper.h" #include <libetpan/libetpan.h> #include "mailtypes.h" +#include <kconfig.h> +#include <kglobal.h> +#include <kstandarddirs.h> using namespace Opie::Core; Genericwrapper::Genericwrapper() : AbstractMail() { @@ -21,12 +24,54 @@ Genericwrapper::~Genericwrapper() } if (m_storage) { mailstorage_free(m_storage); } 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) { if (!mime) { return; } @@ -239,23 +284,12 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg ) err = mailmessage_get_bodystructure(msg,&mime); QValueList<int>recList; traverseBody(body,msg,mime,recList); 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 ) { QString result( "" ); bool first = true; @@ -445,14 +479,20 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & mail->setTo(mailbox); } if (single_fields.fld_cc) 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)); ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; } if (single_fields.fld_reply_to) { |