summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp2
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 4f48850..10b1013 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,223 +1,223 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#else 4#else
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qwindowsstyle.h> 6#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 7#include <qplatinumstyle.h>
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#endif 9#endif
10 10
11#include <kstandarddirs.h> 11#include <kstandarddirs.h>
12#include <qregexp.h> 12#include <qregexp.h>
13#include <kglobal.h> 13#include <kglobal.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <qdir.h> 15#include <qdir.h>
16#include "kaddressbookmain.h" 16#include "kaddressbookmain.h"
17#include "externalapphandler.h" 17#include "externalapphandler.h"
18 18
19int main( int argc, char **argv ) 19int main( int argc, char **argv )
20{ 20{
21#ifndef DESKTOP_VERSION 21#ifndef DESKTOP_VERSION
22 QPEApplication a( argc, argv ); 22 QPEApplication a( argc, argv );
23 a.setKeepRunning (); 23 a.setKeepRunning ();
24#else 24#else
25 QApplication a( argc, argv ); 25 QApplication a( argc, argv );
26 QApplication::setStyle( new QPlatinumStyle ()); 26 QApplication::setStyle( new QPlatinumStyle ());
27 QString hdir = QDir::homeDirPath(); 27 QString hdir = QDir::homeDirPath();
28 // there is a bug when creating dirs for WIN 98 28 // there is a bug when creating dirs for WIN 98
29 // it is difficult to fix, because we have no WIN 98 runnung 29 // it is difficult to fix, because we have no WIN 98 runnung
30 // such that we try it to create the dirs at startup here 30 // such that we try it to create the dirs at startup here
31 if ( hdir == "C:\\" ) { // win 98 or ME 31 if ( hdir == "C:\\" ) { // win 98 or ME
32 QDir app_dir; 32 QDir app_dir;
33 if ( !app_dir.exists("C:\\kdepim") ) 33 if ( !app_dir.exists("C:\\kdepim") )
34 app_dir.mkdir ("C:\\kdepim"); 34 app_dir.mkdir ("C:\\kdepim");
35 if ( !app_dir.exists("C:\\kdepim\\apps") ) 35 if ( !app_dir.exists("C:\\kdepim\\apps") )
36 app_dir.mkdir ("C:\\kdepim\\apps"); 36 app_dir.mkdir ("C:\\kdepim\\apps");
37 if ( !app_dir.exists("C:\\kdepim\\config") ) 37 if ( !app_dir.exists("C:\\kdepim\\config") )
38 app_dir.mkdir ("C:\\kdepim\\config"); 38 app_dir.mkdir ("C:\\kdepim\\config");
39 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 39 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
40 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 40 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
41 } 41 }
42#endif 42#endif
43 43
44 bool exitHelp = false; 44 bool exitHelp = false;
45 if ( argc > 1 ) { 45 if ( argc > 1 ) {
46 QString command = argv[1]; 46 QString command = argv[1];
47 if ( command == "-help" ){ 47 if ( command == "-help" ){
48 printf("KA/E command line commands:\n"); 48 printf("KA/E command line commands:\n");
49 printf(" no command: Start KA/E in usual way\n"); 49 printf(" no command: Start KA/E in usual way\n");
50 printf(" -help: This output\n"); 50 printf(" -help: This output\n");
51 printf(" KA/E is exiting now. Bye!\n"); 51 printf(" KA/E is exiting now. Bye!\n");
52 exitHelp = true; 52 exitHelp = true;
53 } 53 }
54 } 54 }
55 if ( ! exitHelp ) { 55 if ( ! exitHelp ) {
56 56
57 KGlobal::setAppName( "kaddressbook" ); 57 KGlobal::setAppName( "kaddressbook" );
58#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
59 if ( QApplication::desktop()->width() > 320 ) 59 if ( QApplication::desktop()->width() > 320 )
60 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 60 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
61 else 61 else
62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
63#else 63#else
64 QString fileName ; 64 QString fileName ;
65 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 65 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
66 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 66 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
67 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 67 QApplication::addLibraryPath ( qApp->applicationDirPath () );
68 68
69#endif 69#endif
70 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 70 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
71 KAddressBookMain m ; 71 KAddressBookMain m ;
72//US MainWindow m; 72//US MainWindow m;
73 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 73 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
74 74
75 { 75 {
76 KConfig kon ( locateLocal( "config", "korganizerrc" ) ); 76 KConfig kon ( locateLocal( "config", "korganizerrc" ) );
77 kon.setGroup("Locale"); 77 kon.setGroup("Locale");
78 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); 78 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) );
79 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); 79 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( "");
80 KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); 80 KGlobal::locale()->setHore24Format( !kon.readNumEntry( "PreferredTime",0 ) );
81 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 81 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
82 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); 82 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" );
83 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 83 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
84 kon.setGroup("Time & Date"); 84 kon.setGroup("Time & Date");
85 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), 85 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ),
86 kon.readNumEntry( "DaylightsavingStart", 90), 86 kon.readNumEntry( "DaylightsavingStart", 90),
87 kon.readNumEntry( "DaylightsavingEnd",304) ); 87 kon.readNumEntry( "DaylightsavingEnd",304) );
88 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); 88 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") );
89 } 89 }
90#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
91 a.showMainWidget( &m ); 91 a.showMainWidget( &m );
92#else 92#else
93 a.setMainWidget( &m ); 93 a.setMainWidget( &m );
94 m.resize (640, 480 ); 94 m.resize (640, 480 );
95 m.show(); 95 m.show();
96#endif 96#endif
97 a.exec(); 97 a.exec();
98 98
99 } 99 }
100 qDebug("KA: Bye! "); 100 qDebug("KA: Bye! ");
101} 101}
102 102
103/* 103/*
104#include <stdlib.h> 104#include <stdlib.h>
105 105
106#include <qstring.h> 106#include <qstring.h>
107 107
108#include <kabc/stdaddressbook.h> 108#include <kabc/stdaddressbook.h>
109#include <kaboutdata.h> 109#include <kaboutdata.h>
110#include <kcmdlineargs.h> 110#include <kcmdlineargs.h>
111#include <kcrash.h> 111#include <kcrash.h>
112#include <kdebug.h> 112#include <kdebug.h>
113#include <klocale.h> 113#include <klocale.h>
114#include <kstartupinfo.h> 114#include <kstartupinfo.h>
115#include <kuniqueapplication.h> 115#include <kuniqueapplication.h>
116#include <kwin.h> 116#include <kwin.h>
117 117
118#include "kaddressbookmain.h" 118#include "kaddressbookmain.h"
119#include "kabcore.h" 119#include "kabcore.h"
120 120
121extern "C" { 121extern "C" {
122 122
123void crashHandler( int ) 123void crashHandler( int )
124{ 124{
125 KABC::StdAddressBook::handleCrash(); 125 KABC::StdAddressBook::handleCrash();
126 ::exit( 0 ); 126 ::exit( 0 );
127} 127}
128 128
129} 129}
130 130
131class KAddressBookApp : public KUniqueApplication { 131class KAddressBookApp : public KUniqueApplication {
132 public: 132 public:
133 KAddressBookApp() : mMainWin( 0 ) {} 133 KAddressBookApp() : mMainWin( 0 ) {}
134 ~KAddressBookApp() {} 134 ~KAddressBookApp() {}
135 135
136 int newInstance(); 136 int newInstance();
137 137
138 private: 138 private:
139 KAddressBookMain *mMainWin; 139 KAddressBookMain *mMainWin;
140}; 140};
141 141
142int KAddressBookApp::newInstance() 142int KAddressBookApp::newInstance()
143{ 143{
144 if ( isRestored() ) { 144 if ( isRestored() ) {
145 // There can only be one main window 145 // There can only be one main window
146 if ( KMainWindow::canBeRestored( 1 ) ) { 146 if ( KMainWindow::canBeRestored( 1 ) ) {
147 mMainWin = new KAddressBookMain; 147 mMainWin = new KAddressBookMain;
148 mMainWin->show(); 148 mMainWin->show();
149 mMainWin->restore( 1 ); 149 mMainWin->restore( 1 );
150 } 150 }
151 } else { 151 } else {
152 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 152 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
153 153
154 QCString addrStr = args->getOption( "addr" ); 154 QCString addrStr = args->getOption( "addr" );
155 QCString uidStr = args->getOption( "uid" ); 155 QCString uidStr = args->getOption( "uid" );
156 QString addr; 156 QString addr;
157 QString uid; 157 QString uid;
158 if ( !addrStr.isEmpty() ) 158 if ( !addrStr.isEmpty() )
159 addr = QString::fromLocal8Bit( addrStr ); 159 addr = QString::fromLocal8Bit( addrStr );
160 if ( !uidStr.isEmpty() ) 160 if ( !uidStr.isEmpty() )
161 uid = QString::fromLocal8Bit( uidStr ); 161 uid = QString::fromLocal8Bit( uidStr );
162 162
163 163
164 if ( args->isSet( "editor-only" ) ) { 164 if ( args->isSet( "editor-only" ) ) {
165 if ( !mMainWin ) 165 if ( !mMainWin )
166 mMainWin = new KAddressBookMain; 166 mMainWin = new KAddressBookMain;
167 KStartupInfo::appStarted(); 167 KStartupInfo::appStarted();
168 mMainWin->hide(); 168 mMainWin->hide();
169 } else { 169 } else {
170 if ( mMainWin ) { 170 if ( mMainWin ) {
171 mMainWin->show(); 171 mMainWin->show();
172 KWin::setActiveWindow( mMainWin->winId() ); 172 KWin::setActiveWindow( mMainWin->winId() );
173 } else { 173 } else {
174 mMainWin = new KAddressBookMain; 174 mMainWin = new KAddressBookMain;
175 mMainWin->show(); 175 mMainWin->show();
176 } 176 }
177 } 177 }
178 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 178 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
179 if ( !addr.isEmpty() ) 179 if ( !addr.isEmpty() )
180 mMainWin->addEmail( addr ); 180 mMainWin->addEmail( addr );
181 181
182 if ( !uid.isEmpty() ) 182 if ( !uid.isEmpty() )
183 mMainWin->showContactEditor( uid ); 183 mMainWin->showContactEditor( uid );
184 if ( args->isSet( "new-contact" ) ) { 184 if ( args->isSet( "new-contact" ) ) {
185 mMainWin->newContact(); 185 mMainWin->newContact();
186 } 186 }
187 } 187 }
188 188
189 KCrash::setEmergencySaveFunction( crashHandler ); 189 KCrash::setEmergencySaveFunction( crashHandler );
190 190
191 return 0; 191 return 0;
192} 192}
193 193
194// the dummy argument is required, because KMail apparently sends an empty 194// the dummy argument is required, because KMail apparently sends an empty
195// argument. 195// argument.
196static KCmdLineOptions kmoptions[] = 196static KCmdLineOptions kmoptions[] =
197{ 197{
198 { "a", 0 , 0 }, 198 { "a", 0 , 0 },
199 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 199 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
200 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 200 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
201 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 201 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
202 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 202 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
203 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 203 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
204 { 0, 0, 0} 204 { 0, 0, 0}
205}; 205};
206 206
207int main( int argc, char *argv[] ) 207int main( int argc, char *argv[] )
208{ 208{
209 KLocale::setMainCatalogue( "kaddressbook" ); 209 KLocale::setMainCatalogue( "kaddressbook" );
210 210
211 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 211 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
212 KCmdLineArgs::addCmdLineOptions( kmoptions ); 212 KCmdLineArgs::addCmdLineOptions( kmoptions );
213 KUniqueApplication::addCmdLineOptions(); 213 KUniqueApplication::addCmdLineOptions();
214 214
215 if ( !KAddressBookApp::start() ) 215 if ( !KAddressBookApp::start() )
216 exit( 0 ); 216 exit( 0 );
217 217
218 KAddressBookApp app; 218 KAddressBookApp app;
219 KGlobal::locale()->insertCatalogue( "libkdepim" ); 219 KGlobal::locale()->insertCatalogue( "libkdepim" );
220 220
221 return app.exec(); 221 return app.exec();
222} 222}
223*/ 223*/
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index d99c6a3..09a6447 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -1,548 +1,548 @@
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> 6#include <kconfig.h>
7#include <kglobal.h> 7#include <kglobal.h>
8#include <kstandarddirs.h> 8#include <kstandarddirs.h>
9 9
10 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12Genericwrapper::Genericwrapper() 12Genericwrapper::Genericwrapper()
13 : AbstractMail() 13 : AbstractMail()
14{ 14{
15 bodyCache.clear(); 15 bodyCache.clear();
16 m_storage = 0; 16 m_storage = 0;
17 m_folder = 0; 17 m_folder = 0;
18} 18}
19 19
20Genericwrapper::~Genericwrapper() 20Genericwrapper::~Genericwrapper()
21{ 21{
22 if (m_folder) { 22 if (m_folder) {
23 mailfolder_free(m_folder); 23 mailfolder_free(m_folder);
24 } 24 }
25 if (m_storage) { 25 if (m_storage) {
26 mailstorage_free(m_storage); 26 mailstorage_free(m_storage);
27 } 27 }
28 cleanMimeCache(); 28 cleanMimeCache();
29} 29}
30const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) 30const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date )
31{ 31{
32 static bool init = false ; 32 static bool init = false ;
33 if ( ! init ) { 33 if ( ! init ) {
34 KConfig kon ( locateLocal( "config", "korganizerrc" ) ); 34 KConfig kon ( locateLocal( "config", "korganizerrc" ) );
35 kon.setGroup("Locale"); 35 kon.setGroup("Locale");
36 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); 36 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) );
37 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); 37 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( "");
38 KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); 38 KGlobal::locale()->setHore24Format( !kon.readNumEntry( "PreferredTime",0 ) );
39 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 39 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
40 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); 40 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" );
41 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 41 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
42 kon.setGroup("Time & Date"); 42 kon.setGroup("Time & Date");
43 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), 43 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ),
44 kon.readNumEntry( "DaylightsavingStart", 90), 44 kon.readNumEntry( "DaylightsavingStart", 90),
45 kon.readNumEntry( "DaylightsavingEnd",304) ); 45 kon.readNumEntry( "DaylightsavingEnd",304) );
46 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); 46 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") );
47 47
48 init = true; 48 init = true;
49 49
50 } 50 }
51 QDate da (date->dt_year,date->dt_month, date->dt_day ); 51 QDate da (date->dt_year,date->dt_month, date->dt_day );
52 QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); 52 QTime ti ( date->dt_hour, date->dt_min, date->dt_sec );
53 QDateTime dt ( da ,ti ); 53 QDateTime dt ( da ,ti );
54 int addsec = -date->dt_zone*36; 54 int addsec = -date->dt_zone*36;
55 //qDebug("adsec1 %d ",addsec ); 55 //qDebug("adsec1 %d ",addsec );
56 dt = dt.addSecs( addsec ); 56 dt = dt.addSecs( addsec );
57 int off = KGlobal::locale()->localTimeOffset( dt ); 57 int off = KGlobal::locale()->localTimeOffset( dt );
58 //qDebug("adsec2 %d ",off*60 ); 58 //qDebug("adsec2 %d ",off*60 );
59 59
60 dt = dt.addSecs( off*60 ); 60 dt = dt.addSecs( off*60 );
61 return dt; 61 return dt;
62#if 0 62#if 0
63 QString ret; 63 QString ret;
64 if ( dt.date() == QDate::currentDate () ) 64 if ( dt.date() == QDate::currentDate () )
65 ret = KGlobal::locale()->formatTime( dt.time(),true); 65 ret = KGlobal::locale()->formatTime( dt.time(),true);
66 66
67 else { 67 else {
68 ret = KGlobal::locale()->formatDateTime( dt,true,true); 68 ret = KGlobal::locale()->formatDateTime( dt,true,true);
69 } 69 }
70#endif 70#endif
71#if 0 71#if 0
72 if ( off < 0 ) 72 if ( off < 0 )
73 ret += " -"; 73 ret += " -";
74 else 74 else
75 ret += " +"; 75 ret += " +";
76 ret += QString::number( off / 60 ); 76 ret += QString::number( off / 60 );
77 ret += "h"; 77 ret += "h";
78#endif 78#endif
79#if 0 79#if 0
80 char tmp[23]; 80 char tmp[23];
81 81
82 // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 82 // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
83 // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 83 // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
84 snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", 84 snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i",
85 date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 85 date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
86 86
87 87
88 return QString( tmp ); 88 return QString( tmp );
89#endif 89#endif
90 //return ret; 90 //return ret;
91} 91}
92 92
93void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) 93void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
94{ 94{
95 if (!mime) { 95 if (!mime) {
96 return; 96 return;
97 } 97 }
98 mailmime_field*field = 0; 98 mailmime_field*field = 0;
99 mailmime_single_fields fields; 99 mailmime_single_fields fields;
100 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 100 memset(&fields, 0, sizeof(struct mailmime_single_fields));
101 if (mime->mm_mime_fields != NULL) { 101 if (mime->mm_mime_fields != NULL) {
102 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 102 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
103 mime->mm_content_type); 103 mime->mm_content_type);
104 } 104 }
105 105
106 mailmime_content*type = fields.fld_content; 106 mailmime_content*type = fields.fld_content;
107 clistcell*current; 107 clistcell*current;
108 if (!type) { 108 if (!type) {
109 target->setType("text"); 109 target->setType("text");
110 target->setSubtype("plain"); 110 target->setSubtype("plain");
111 } else { 111 } else {
112 target->setSubtype(type->ct_subtype); 112 target->setSubtype(type->ct_subtype);
113 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 113 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
114 case MAILMIME_DISCRETE_TYPE_TEXT: 114 case MAILMIME_DISCRETE_TYPE_TEXT:
115 target->setType("text"); 115 target->setType("text");
116 break; 116 break;
117 case MAILMIME_DISCRETE_TYPE_IMAGE: 117 case MAILMIME_DISCRETE_TYPE_IMAGE:
118 target->setType("image"); 118 target->setType("image");
119 break; 119 break;
120 case MAILMIME_DISCRETE_TYPE_AUDIO: 120 case MAILMIME_DISCRETE_TYPE_AUDIO:
121 target->setType("audio"); 121 target->setType("audio");
122 break; 122 break;
123 case MAILMIME_DISCRETE_TYPE_VIDEO: 123 case MAILMIME_DISCRETE_TYPE_VIDEO:
124 target->setType("video"); 124 target->setType("video");
125 break; 125 break;
126 case MAILMIME_DISCRETE_TYPE_APPLICATION: 126 case MAILMIME_DISCRETE_TYPE_APPLICATION:
127 target->setType("application"); 127 target->setType("application");
128 break; 128 break;
129 case MAILMIME_DISCRETE_TYPE_EXTENSION: 129 case MAILMIME_DISCRETE_TYPE_EXTENSION:
130 default: 130 default:
131 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 131 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
132 target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 132 target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
133 } 133 }
134 break; 134 break;
135 } 135 }
136 if (type->ct_parameters) { 136 if (type->ct_parameters) {
137 fillParameters(target,type->ct_parameters); 137 fillParameters(target,type->ct_parameters);
138 } 138 }
139 } 139 }
140 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 140 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
141 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 141 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
142 field = (mailmime_field*)current->data; 142 field = (mailmime_field*)current->data;
143 switch(field->fld_type) { 143 switch(field->fld_type) {
144 case MAILMIME_FIELD_TRANSFER_ENCODING: 144 case MAILMIME_FIELD_TRANSFER_ENCODING:
145 target->setEncoding(getencoding(field->fld_data.fld_encoding)); 145 target->setEncoding(getencoding(field->fld_data.fld_encoding));
146 break; 146 break;
147 case MAILMIME_FIELD_ID: 147 case MAILMIME_FIELD_ID:
148 target->setIdentifier(field->fld_data.fld_id); 148 target->setIdentifier(field->fld_data.fld_id);
149 break; 149 break;
150 case MAILMIME_FIELD_DESCRIPTION: 150 case MAILMIME_FIELD_DESCRIPTION:
151 target->setDescription(field->fld_data.fld_description); 151 target->setDescription(field->fld_data.fld_description);
152 break; 152 break;
153 default: 153 default:
154 break; 154 break;
155 } 155 }
156 } 156 }
157 } 157 }
158} 158}
159 159
160void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) 160void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
161{ 161{
162 if (!parameters) {return;} 162 if (!parameters) {return;}
163 clistcell*current=0; 163 clistcell*current=0;
164 mailmime_parameter*param; 164 mailmime_parameter*param;
165 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 165 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
166 param = (mailmime_parameter*)current->data; 166 param = (mailmime_parameter*)current->data;
167 if (param) { 167 if (param) {
168 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 168 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
169 } 169 }
170 } 170 }
171} 171}
172 172
173QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 173QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
174{ 174{
175 QString enc="7bit"; 175 QString enc="7bit";
176 if (!aEnc) return enc; 176 if (!aEnc) return enc;
177 switch(aEnc->enc_type) { 177 switch(aEnc->enc_type) {
178 case MAILMIME_MECHANISM_7BIT: 178 case MAILMIME_MECHANISM_7BIT:
179 enc = "7bit"; 179 enc = "7bit";
180 break; 180 break;
181 case MAILMIME_MECHANISM_8BIT: 181 case MAILMIME_MECHANISM_8BIT:
182 enc = "8bit"; 182 enc = "8bit";
183 break; 183 break;
184 case MAILMIME_MECHANISM_BINARY: 184 case MAILMIME_MECHANISM_BINARY:
185 enc = "binary"; 185 enc = "binary";
186 break; 186 break;
187 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 187 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
188 enc = "quoted-printable"; 188 enc = "quoted-printable";
189 break; 189 break;
190 case MAILMIME_MECHANISM_BASE64: 190 case MAILMIME_MECHANISM_BASE64:
191 enc = "base64"; 191 enc = "base64";
192 break; 192 break;
193 case MAILMIME_MECHANISM_TOKEN: 193 case MAILMIME_MECHANISM_TOKEN:
194 default: 194 default:
195 if (aEnc->enc_token) { 195 if (aEnc->enc_token) {
196 enc = QString(aEnc->enc_token); 196 enc = QString(aEnc->enc_token);
197 } 197 }
198 break; 198 break;
199 } 199 }
200 return enc; 200 return enc;
201} 201}
202 202
203void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 203void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
204{ 204{
205 if (current_rec >= 10) { 205 if (current_rec >= 10) {
206 ; // odebug << "too deep recursion!" << oendl; 206 ; // odebug << "too deep recursion!" << oendl;
207 } 207 }
208 if (!message || !mime) { 208 if (!message || !mime) {
209 return; 209 return;
210 } 210 }
211 int r; 211 int r;
212 char*data = 0; 212 char*data = 0;
213 size_t len; 213 size_t len;
214 clistiter * cur = 0; 214 clistiter * cur = 0;
215 QString b; 215 QString b;
216 RecPartP part = new RecPart(); 216 RecPartP part = new RecPart();
217 217
218 switch (mime->mm_type) { 218 switch (mime->mm_type) {
219 case MAILMIME_SINGLE: 219 case MAILMIME_SINGLE:
220 { 220 {
221 QValueList<int>countlist = recList; 221 QValueList<int>countlist = recList;
222 countlist.append(current_count); 222 countlist.append(current_count);
223 r = mailmessage_fetch_section(message,mime,&data,&len); 223 r = mailmessage_fetch_section(message,mime,&data,&len);
224 part->setSize(len); 224 part->setSize(len);
225 part->setPositionlist(countlist); 225 part->setPositionlist(countlist);
226 b = gen_attachment_id(); 226 b = gen_attachment_id();
227 part->setIdentifier(b); 227 part->setIdentifier(b);
228 fillSingleBody(part,message,mime); 228 fillSingleBody(part,message,mime);
229 if (part->Type()=="text" && target->Bodytext().isNull()) { 229 if (part->Type()=="text" && target->Bodytext().isNull()) {
230 encodedString*rs = new encodedString(); 230 encodedString*rs = new encodedString();
231 rs->setContent(data,len); 231 rs->setContent(data,len);
232 encodedString*res = decode_String(rs,part->Encoding()); 232 encodedString*res = decode_String(rs,part->Encoding());
233 if (countlist.count()>2) { 233 if (countlist.count()>2) {
234 bodyCache[b]=rs; 234 bodyCache[b]=rs;
235 target->addPart(part); 235 target->addPart(part);
236 } else { 236 } else {
237 delete rs; 237 delete rs;
238 } 238 }
239 b = QString(res->Content()); 239 b = QString(res->Content());
240 delete res; 240 delete res;
241 target->setBodytext(b); 241 target->setBodytext(b);
242 target->setDescription(part); 242 target->setDescription(part);
243 } else { 243 } else {
244 bodyCache[b]=new encodedString(data,len); 244 bodyCache[b]=new encodedString(data,len);
245 target->addPart(part); 245 target->addPart(part);
246 } 246 }
247 } 247 }
248 break; 248 break;
249 case MAILMIME_MULTIPLE: 249 case MAILMIME_MULTIPLE:
250 { 250 {
251 unsigned int ccount = 1; 251 unsigned int ccount = 1;
252 mailmime*cbody=0; 252 mailmime*cbody=0;
253 QValueList<int>countlist = recList; 253 QValueList<int>countlist = recList;
254 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 254 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
255 cbody = (mailmime*)clist_content(cur); 255 cbody = (mailmime*)clist_content(cur);
256 if (cbody->mm_type==MAILMIME_MULTIPLE) { 256 if (cbody->mm_type==MAILMIME_MULTIPLE) {
257 RecPartP targetPart = new RecPart(); 257 RecPartP targetPart = new RecPart();
258 targetPart->setType("multipart"); 258 targetPart->setType("multipart");
259 countlist.append(current_count); 259 countlist.append(current_count);
260 targetPart->setPositionlist(countlist); 260 targetPart->setPositionlist(countlist);
261 target->addPart(targetPart); 261 target->addPart(targetPart);
262 } 262 }
263 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 263 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
264 if (cbody->mm_type==MAILMIME_MULTIPLE) { 264 if (cbody->mm_type==MAILMIME_MULTIPLE) {
265 countlist = recList; 265 countlist = recList;
266 } 266 }
267 ++ccount; 267 ++ccount;
268 } 268 }
269 } 269 }
270 break; 270 break;
271 case MAILMIME_MESSAGE: 271 case MAILMIME_MESSAGE:
272 { 272 {
273 QValueList<int>countlist = recList; 273 QValueList<int>countlist = recList;
274 countlist.append(current_count); 274 countlist.append(current_count);
275 /* the own header is always at recursion 0 - we don't need that */ 275 /* the own header is always at recursion 0 - we don't need that */
276 if (current_rec > 0) { 276 if (current_rec > 0) {
277 part->setPositionlist(countlist); 277 part->setPositionlist(countlist);
278 r = mailmessage_fetch_section(message,mime,&data,&len); 278 r = mailmessage_fetch_section(message,mime,&data,&len);
279 part->setSize(len); 279 part->setSize(len);
280 part->setPositionlist(countlist); 280 part->setPositionlist(countlist);
281 b = gen_attachment_id(); 281 b = gen_attachment_id();
282 part->setIdentifier(b); 282 part->setIdentifier(b);
283 part->setType("message"); 283 part->setType("message");
284 part->setSubtype("rfc822"); 284 part->setSubtype("rfc822");
285 bodyCache[b]=new encodedString(data,len); 285 bodyCache[b]=new encodedString(data,len);
286 target->addPart(part); 286 target->addPart(part);
287 } 287 }
288 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 288 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
289 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 289 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
290 } 290 }
291 } 291 }
292 break; 292 break;
293 } 293 }
294} 294}
295 295
296RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 296RecBodyP Genericwrapper::parseMail( mailmessage * msg )
297{ 297{
298 int err = MAILIMF_NO_ERROR; 298 int err = MAILIMF_NO_ERROR;
299 mailmime_single_fields fields; 299 mailmime_single_fields fields;
300 /* is bound to msg and will be freed there */ 300 /* is bound to msg and will be freed there */
301 mailmime * mime=0; 301 mailmime * mime=0;
302 RecBodyP body = new RecBody(); 302 RecBodyP body = new RecBody();
303 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 303 memset(&fields, 0, sizeof(struct mailmime_single_fields));
304 err = mailmessage_get_bodystructure(msg,&mime); 304 err = mailmessage_get_bodystructure(msg,&mime);
305 QValueList<int>recList; 305 QValueList<int>recList;
306 traverseBody(body,msg,mime,recList); 306 traverseBody(body,msg,mime,recList);
307 return body; 307 return body;
308} 308}
309 309
310 310
311QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 311QString Genericwrapper::parseAddressList( mailimf_address_list *list )
312{ 312{
313 QString result( "" ); 313 QString result( "" );
314 314
315 bool first = true; 315 bool first = true;
316 if (list == 0) return result; 316 if (list == 0) return result;
317 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 317 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
318 mailimf_address *addr = (mailimf_address *) current->data; 318 mailimf_address *addr = (mailimf_address *) current->data;
319 319
320 if ( !first ) { 320 if ( !first ) {
321 result.append( "," ); 321 result.append( "," );
322 } else { 322 } else {
323 first = false; 323 first = false;
324 } 324 }
325 325
326 switch ( addr->ad_type ) { 326 switch ( addr->ad_type ) {
327 case MAILIMF_ADDRESS_MAILBOX: 327 case MAILIMF_ADDRESS_MAILBOX:
328 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 328 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
329 break; 329 break;
330 case MAILIMF_ADDRESS_GROUP: 330 case MAILIMF_ADDRESS_GROUP:
331 result.append( parseGroup( addr->ad_data.ad_group ) ); 331 result.append( parseGroup( addr->ad_data.ad_group ) );
332 break; 332 break;
333 default: 333 default:
334 ; // odebug << "Generic: unkown mailimf address type" << oendl; 334 ; // odebug << "Generic: unkown mailimf address type" << oendl;
335 break; 335 break;
336 } 336 }
337 } 337 }
338 338
339 return result; 339 return result;
340} 340}
341 341
342QString Genericwrapper::parseGroup( mailimf_group *group ) 342QString Genericwrapper::parseGroup( mailimf_group *group )
343{ 343{
344 QString result( "" ); 344 QString result( "" );
345 345
346 result.append( group->grp_display_name ); 346 result.append( group->grp_display_name );
347 result.append( ": " ); 347 result.append( ": " );
348 348
349 if ( group->grp_mb_list != NULL ) { 349 if ( group->grp_mb_list != NULL ) {
350 result.append( parseMailboxList( group->grp_mb_list ) ); 350 result.append( parseMailboxList( group->grp_mb_list ) );
351 } 351 }
352 352
353 result.append( ";" ); 353 result.append( ";" );
354 354
355 return result; 355 return result;
356} 356}
357 357
358QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 358QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
359{ 359{
360 QString result( "" ); 360 QString result( "" );
361 361
362 if ( box->mb_display_name == NULL ) { 362 if ( box->mb_display_name == NULL ) {
363 result.append( box->mb_addr_spec ); 363 result.append( box->mb_addr_spec );
364 } else { 364 } else {
365 result.append( convert_String(box->mb_display_name).latin1() ); 365 result.append( convert_String(box->mb_display_name).latin1() );
366 result.append( " <" ); 366 result.append( " <" );
367 result.append( box->mb_addr_spec ); 367 result.append( box->mb_addr_spec );
368 result.append( ">" ); 368 result.append( ">" );
369 } 369 }
370 370
371 return result; 371 return result;
372} 372}
373 373
374QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 374QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
375{ 375{
376 QString result( "" ); 376 QString result( "" );
377 377
378 bool first = true; 378 bool first = true;
379 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 379 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
380 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 380 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
381 381
382 if ( !first ) { 382 if ( !first ) {
383 result.append( "," ); 383 result.append( "," );
384 } else { 384 } else {
385 first = false; 385 first = false;
386 } 386 }
387 387
388 result.append( parseMailbox( box ) ); 388 result.append( parseMailbox( box ) );
389 } 389 }
390 390
391 return result; 391 return result;
392} 392}
393 393
394encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) 394encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part)
395{ 395{
396 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 396 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
397 if (it==bodyCache.end()) return new encodedString(); 397 if (it==bodyCache.end()) return new encodedString();
398 encodedString*t = decode_String(it.data(),part->Encoding()); 398 encodedString*t = decode_String(it.data(),part->Encoding());
399 return t; 399 return t;
400} 400}
401 401
402encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) 402encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part)
403{ 403{
404 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); 404 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
405 if (it==bodyCache.end()) return new encodedString(); 405 if (it==bodyCache.end()) return new encodedString();
406 encodedString*t = it.data(); 406 encodedString*t = it.data();
407 return t; 407 return t;
408} 408}
409 409
410QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 410QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
411{ 411{
412 encodedString*t = fetchDecodedPart(mail,part); 412 encodedString*t = fetchDecodedPart(mail,part);
413 QString text=t->Content(); 413 QString text=t->Content();
414 delete t; 414 delete t;
415 return text; 415 return text;
416} 416}
417 417
418void Genericwrapper::cleanMimeCache() 418void Genericwrapper::cleanMimeCache()
419{ 419{
420 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 420 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
421 for (;it!=bodyCache.end();++it) { 421 for (;it!=bodyCache.end();++it) {
422 encodedString*t = it.data(); 422 encodedString*t = it.data();
423 //it.setValue(0); 423 //it.setValue(0);
424 if (t) delete t; 424 if (t) delete t;
425 } 425 }
426 bodyCache.clear(); 426 bodyCache.clear();
427 ; // odebug << "Genericwrapper: cache cleaned" << oendl; 427 ; // odebug << "Genericwrapper: cache cleaned" << oendl;
428} 428}
429 429
430QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 430QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
431{ 431{
432 QStringList res; 432 QStringList res;
433 if (!in_replies || !in_replies->mid_list) return res; 433 if (!in_replies || !in_replies->mid_list) return res;
434 clistiter * current = 0; 434 clistiter * current = 0;
435 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 435 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
436 QString h((char*)current->data); 436 QString h((char*)current->data);
437 while (h.length()>0 && h[0]=='<') { 437 while (h.length()>0 && h[0]=='<') {
438 h.remove(0,1); 438 h.remove(0,1);
439 } 439 }
440 while (h.length()>0 && h[h.length()-1]=='>') { 440 while (h.length()>0 && h[h.length()-1]=='>') {
441 h.remove(h.length()-1,1); 441 h.remove(h.length()-1,1);
442 } 442 }
443 if (h.length()>0) { 443 if (h.length()>0) {
444 res.append(h); 444 res.append(h);
445 } 445 }
446 } 446 }
447 return res; 447 return res;
448} 448}
449 449
450void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) 450void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb)
451{ 451{
452 int r; 452 int r;
453 mailmessage_list * env_list = 0; 453 mailmessage_list * env_list = 0;
454 r = mailsession_get_messages_list(session,&env_list); 454 r = mailsession_get_messages_list(session,&env_list);
455 if (r != MAIL_NO_ERROR) { 455 if (r != MAIL_NO_ERROR) {
456 ; // odebug << "Error message list" << oendl; 456 ; // odebug << "Error message list" << oendl;
457 return; 457 return;
458 } 458 }
459 r = mailsession_get_envelopes_list(session, env_list); 459 r = mailsession_get_envelopes_list(session, env_list);
460 if (r != MAIL_NO_ERROR) { 460 if (r != MAIL_NO_ERROR) {
461 ; // odebug << "Error filling message list" << oendl; 461 ; // odebug << "Error filling message list" << oendl;
462 if (env_list) { 462 if (env_list) {
463 mailmessage_list_free(env_list); 463 mailmessage_list_free(env_list);
464 } 464 }
465 return; 465 return;
466 } 466 }
467 mailimf_references * refs = 0; 467 mailimf_references * refs = 0;
468 mailimf_in_reply_to * in_replies = 0; 468 mailimf_in_reply_to * in_replies = 0;
469 uint32_t i = 0; 469 uint32_t i = 0;
470 for(; i < carray_count(env_list->msg_tab) ; ++i) { 470 for(; i < carray_count(env_list->msg_tab) ; ++i) {
471 mailmessage * msg; 471 mailmessage * msg;
472 QBitArray mFlags(7); 472 QBitArray mFlags(7);
473 msg = (mailmessage*)carray_get(env_list->msg_tab, i); 473 msg = (mailmessage*)carray_get(env_list->msg_tab, i);
474 if (msg->msg_fields == NULL) { 474 if (msg->msg_fields == NULL) {
475 //; // odebug << "could not fetch envelope of message " << i << "" << oendl; 475 //; // odebug << "could not fetch envelope of message " << i << "" << oendl;
476 continue; 476 continue;
477 } 477 }
478 RecMailP mail = new RecMail(); 478 RecMailP mail = new RecMail();
479 mail->setWrapper(this); 479 mail->setWrapper(this);
480 mail_flags * flag_result = 0; 480 mail_flags * flag_result = 0;
481 r = mailmessage_get_flags(msg,&flag_result); 481 r = mailmessage_get_flags(msg,&flag_result);
482 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 482 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
483 mFlags.setBit(FLAG_SEEN); 483 mFlags.setBit(FLAG_SEEN);
484 } 484 }
485 mailimf_single_fields single_fields; 485 mailimf_single_fields single_fields;
486 mailimf_single_fields_init(&single_fields, msg->msg_fields); 486 mailimf_single_fields_init(&single_fields, msg->msg_fields);
487 mail->setMsgsize(msg->msg_size); 487 mail->setMsgsize(msg->msg_size);
488 mail->setFlags(mFlags); 488 mail->setFlags(mFlags);
489 mail->setMbox(mailbox); 489 mail->setMbox(mailbox);
490 mail->setNumber(msg->msg_index); 490 mail->setNumber(msg->msg_index);
491 if (single_fields.fld_subject) 491 if (single_fields.fld_subject)
492 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); 492 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
493 if (single_fields.fld_from) 493 if (single_fields.fld_from)
494 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); 494 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
495 if (!mbox_as_to) { 495 if (!mbox_as_to) {
496 if (single_fields.fld_to) 496 if (single_fields.fld_to)
497 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); 497 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
498 } else { 498 } else {
499 mail->setTo(mailbox); 499 mail->setTo(mailbox);
500 } 500 }
501 if (single_fields.fld_cc) 501 if (single_fields.fld_cc)
502 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); 502 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
503 if (single_fields.fld_bcc) 503 if (single_fields.fld_bcc)
504 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); 504 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
505 if (single_fields.fld_orig_date) { 505 if (single_fields.fld_orig_date) {
506 QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); 506 QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time );
507 QString ret; 507 QString ret;
508 if ( dt.date() == QDate::currentDate () ) 508 if ( dt.date() == QDate::currentDate () )
509 ret = KGlobal::locale()->formatTime( dt.time(),true); 509 ret = KGlobal::locale()->formatTime( dt.time(),true);
510 else { 510 else {
511 ret = KGlobal::locale()->formatDateTime( dt,true,true); 511 ret = KGlobal::locale()->formatDateTime( dt,true,true);
512 } 512 }
513 mail->setDate( ret ); 513 mail->setDate( ret );
514 char tmp[20]; 514 char tmp[20];
515 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", 515 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i",
516 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); 516 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() );
517 //qDebug(" iso %s ", tmp); 517 //qDebug(" iso %s ", tmp);
518 mail->setIsoDate( QString( tmp ) ); 518 mail->setIsoDate( QString( tmp ) );
519 } 519 }
520 // crashes when accessing pop3 account? 520 // crashes when accessing pop3 account?
521 if (single_fields.fld_message_id) { 521 if (single_fields.fld_message_id) {
522 mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 522 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
523 ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; 523 ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl;
524 } 524 }
525 if (single_fields.fld_reply_to) { 525 if (single_fields.fld_reply_to) {
526 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); 526 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
527 if (t.count()>0) { 527 if (t.count()>0) {
528 mail->setReplyto(t[0]); 528 mail->setReplyto(t[0]);
529 } 529 }
530 } 530 }
531#if 0 531#if 0
532 refs = single_fields.fld_references; 532 refs = single_fields.fld_references;
533 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 533 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
534 char * text = (char*)refs->mid_list->first->data; 534 char * text = (char*)refs->mid_list->first->data;
535 mail->setReplyto(QString(text)); 535 mail->setReplyto(QString(text));
536 } 536 }
537#endif 537#endif
538 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && 538 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
539 clist_count(single_fields.fld_in_reply_to->mid_list)) { 539 clist_count(single_fields.fld_in_reply_to->mid_list)) {
540 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); 540 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
541 } 541 }
542 if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) 542 if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 )
543 target.append(mail); 543 target.append(mail);
544 } 544 }
545 if (env_list) { 545 if (env_list) {
546 mailmessage_list_free(env_list); 546 mailmessage_list_free(env_list);
547 } 547 }
548} 548}