summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/genericwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (ignore 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
@@ -1,11 +1,14 @@
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
8using namespace Opie::Core; 11using namespace Opie::Core;
9Genericwrapper::Genericwrapper() 12Genericwrapper::Genericwrapper()
10 : AbstractMail() 13 : AbstractMail()
11{ 14{
@@ -21,12 +24,54 @@ Genericwrapper::~Genericwrapper()
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}
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)
29{ 74{
30 if (!mime) { 75 if (!mime) {
31 return; 76 return;
32 } 77 }
@@ -239,23 +284,12 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg )
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
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 )
258{ 292{
259 QString result( "" ); 293 QString result( "" );
260 294
261 bool first = true; 295 bool first = true;
@@ -445,14 +479,20 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
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) {