summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/genericwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp64
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
@@ -4,4 +4,7 @@
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
@@ -25,4 +28,46 @@ Genericwrapper::~Genericwrapper()
25 cleanMimeCache(); 28 cleanMimeCache();
26} 29}
30QString 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
28void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) 73void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
@@ -243,15 +288,4 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg )
243} 288}
244 289
245QString 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
257QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 291QString Genericwrapper::parseAddressList( mailimf_address_list *list )
@@ -449,6 +483,12 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
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) {