summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2004-11-06 23:30:02 (UTC)
committer zautrix <zautrix>2004-11-06 23:30:02 (UTC)
commit023e0e82dd8bf6421d12492a2dd25534fc43ad31 (patch) (unidiff)
treecf0533e3ccc642cb57a41953f184f457fa5365ba /kmicromail
parentf8841c92d5251f713eb7a025af8fdee52de45b3d (diff)
downloadkdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.zip
kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.gz
kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.bz2
many ompi fixes
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp12
-rw-r--r--kmicromail/koprefs.cpp7
-rw-r--r--kmicromail/koprefs.h5
-rw-r--r--kmicromail/koprefsdialog.cpp19
-rw-r--r--kmicromail/koprefsdialog.h1
-rw-r--r--kmicromail/libetpan/mime/mailmime_decode.c203
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp9
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp16
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp19
-rw-r--r--kmicromail/libmailwrapper/mboxwrapper.cpp1
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp1
-rw-r--r--kmicromail/mailistviewitem.cpp4
-rw-r--r--kmicromail/mainwindow.cpp45
-rw-r--r--kmicromail/mainwindow.h3
-rw-r--r--kmicromail/opiemail.cpp16
-rw-r--r--kmicromail/viewmail.cpp20
16 files changed, 244 insertions, 137 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 2dcbc75..f44100b 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -462,42 +462,42 @@ void ComposeMail::reject()
462 462
463 //qDebug("button %d ", yesno); 463 //qDebug("button %d ", yesno);
464 if (yesno == 0) { 464 if (yesno == 0) {
465 if ( toLine->text().isEmpty() ) { 465 if ( toLine->text().isEmpty() ) {
466 QMessageBox::warning(0,i18n("Sending mail"), 466 QMessageBox::warning(0,i18n("Sending mail"),
467 i18n("No Receiver spezified" ) ); 467 i18n("No Receiver spezified" ) );
468 return; 468 return;
469 } 469 }
470 saveAsDraft(); 470 saveAsDraft();
471 } 471 }
472 if (yesno == 2) { 472 if (yesno == 2) {
473 qDebug("return "); 473 qDebug("return ");
474 return; 474 return;
475 } 475 }
476 QDialog::reject(); 476 QDialog::reject();
477} 477}
478 478
479ComposeMail::~ComposeMail() 479ComposeMail::~ComposeMail()
480{ 480{
481} 481}
482 482
483void ComposeMail::reEditMail(const RecMailP&current) 483void ComposeMail::reEditMail(const RecMailP&current)
484{ 484{
485 RecMailP data = current; 485 RecMailP data = current;
486 message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() )); 486 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
487 subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() )); 487 subjectLine->setText( data->getSubject());
488 toLine->setText(QString::fromUtf8( data->To().join(",").latin1() )); 488 toLine->setText(data->To().join(","));
489 ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() )); 489 ccLine->setText(data->CC().join(","));
490 bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() )); 490 bccLine->setText(data->Bcc().join(","));
491 replyLine->setText(QString::fromUtf8( data->Replyto().latin1() )); 491 replyLine->setText(data->Replyto());
492} 492}
493 493
494AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 494AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
495 : QListViewItem( parent ) 495 : QListViewItem( parent )
496{ 496{
497 attachment = att; 497 attachment = att;
498 if ( !attachment->getPixmap().isNull() ) 498 if ( !attachment->getPixmap().isNull() )
499 setPixmap( 0,attachment->getPixmap() ); 499 setPixmap( 0,attachment->getPixmap() );
500 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 500 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
501 setText( 1, QString::number( att->getSize() ) ); 501 setText( 1, QString::number( att->getSize() ) );
502} 502}
503 503
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp
index 8143b6f..342bbf3 100644
--- a/kmicromail/koprefs.cpp
+++ b/kmicromail/koprefs.cpp
@@ -36,87 +36,90 @@
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44 44
45#include "koprefs.h" 45#include "koprefs.h"
46#include "mainwindow.h" 46#include "mainwindow.h"
47 47
48 48
49KOPrefs *KOPrefs::mInstance = 0; 49KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 50static KStaticDeleter<KOPrefs> insd;
51 51
52KOPrefs::KOPrefs() : 52KOPrefs::KOPrefs() :
53 KPimPrefs("kopiemailrc") 53 KPimPrefs("kopiemailrc")
54{ 54{
55 mAppFont = QFont("helvetica",12); 55 mAppFont = QFont("helvetica",12);
56 mComposeFont = QFont("helvetica",12); 56 mComposeFont = QFont("helvetica",12);
57 mReadFont = QFont("helvetica",12); 57 mReadFont = QFont("helvetica",12);
58 58
59 KPrefs::setCurrentGroup("General"); 59 KPrefs::setCurrentGroup("General");
60 addItemString("SendCodec",&mSendCodec,i18n ("userdefined") );
60 addItemString("SenderName",&mName,i18n ("Please set at") ); 61 addItemString("SenderName",&mName,i18n ("Please set at") );
61 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); 62 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") );
62 addItemBool("ViewMailAsHtml",&mViewAsHtml,false); 63 addItemBool("ViewMailAsHtml",&mViewAsHtml,false);
63 addItemBool("SendMailLater",&mSendLater,true); 64 addItemBool("SendMailLater",&mSendLater,true);
64 addItemBool("UseKapi",&mUseKapi,false); 65 addItemBool("UseKapi",&mUseKapi,false);
66 addItemInt("CurrentCodec",&mCurrentCodec,0);
65 67
66 KPrefs::setCurrentGroup("Fonts"); 68 KPrefs::setCurrentGroup("Fonts");
67 addItemFont("Application Font",&mAppFont); 69 addItemFont("Application Font",&mAppFont);
68 addItemFont("Compose Font",&mComposeFont); 70 addItemFont("Compose Font",&mComposeFont);
69 addItemFont("Read Font",&mReadFont); 71 addItemFont("Read Font",&mReadFont);
70 fillMailDefaults(); 72 fillMailDefaults();
71 73 isDirty = false;
72} 74}
73 75
74 76
75KOPrefs::~KOPrefs() 77KOPrefs::~KOPrefs()
76{ 78{
79 if ( isDirty )
80 writeConfig();
77 if (mInstance == this) 81 if (mInstance == this)
78 mInstance = insd.setObject(0); 82 mInstance = insd.setObject(0);
79 83
80} 84}
81 85
82 86
83KOPrefs *KOPrefs::instance() 87KOPrefs *KOPrefs::instance()
84{ 88{
85 if (!mInstance) { 89 if (!mInstance) {
86 mInstance = insd.setObject(new KOPrefs()); 90 mInstance = insd.setObject(new KOPrefs());
87 mInstance->readConfig(); 91 mInstance->readConfig();
88 } 92 }
89 93
90 return mInstance; 94 return mInstance;
91} 95}
92 96
93void KOPrefs::usrSetDefaults() 97void KOPrefs::usrSetDefaults()
94{ 98{
95 99
96} 100}
97 101
98void KOPrefs::fillMailDefaults() 102void KOPrefs::fillMailDefaults()
99{ 103{
100 if (mName.isEmpty()) mName = i18n ("Please set at"); 104 if (mName.isEmpty()) mName = i18n ("Please set at");
101 if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB"); 105 if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB");
102} 106}
103 107
104void KOPrefs::usrReadConfig() 108void KOPrefs::usrReadConfig()
105{ 109{
106 110
107 KPimPrefs::usrReadConfig(); 111 KPimPrefs::usrReadConfig();
108} 112}
109 113
110 114
111void KOPrefs::usrWriteConfig() 115void KOPrefs::usrWriteConfig()
112{ 116{
113
114 KPimPrefs::usrWriteConfig(); 117 KPimPrefs::usrWriteConfig();
115} 118}
116 119
117 120
118 121
119KConfig* KOPrefs::getConfig() 122KConfig* KOPrefs::getConfig()
120{ 123{
121 return config(); 124 return config();
122} 125}
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h
index f0a4463..91f3fa3 100644
--- a/kmicromail/koprefs.h
+++ b/kmicromail/koprefs.h
@@ -47,31 +47,34 @@ class KOPrefs : public KPimPrefs
47 void usrReadConfig(); 47 void usrReadConfig();
48 48
49 /** Write preferences to config file */ 49 /** Write preferences to config file */
50 void usrWriteConfig(); 50 void usrWriteConfig();
51 void setCategoryDefaults(){;}; 51 void setCategoryDefaults(){;};
52 52
53 protected: 53 protected:
54 54
55 /** Fill empty mail fields with default values. */ 55 /** Fill empty mail fields with default values. */
56 void fillMailDefaults(); 56 void fillMailDefaults();
57 57
58 private: 58 private:
59 /** Constructor disabled for public. Use instance() to create a KOPrefs 59 /** Constructor disabled for public. Use instance() to create a KOPrefs
60 object. */ 60 object. */
61 KOPrefs(); 61 KOPrefs();
62 62
63 static KOPrefs *mInstance; 63 static KOPrefs *mInstance;
64 public: 64 public:
65 // preferences data 65 // preferences data
66 KConfig* getConfig(); 66 KConfig* getConfig();
67 QFont mAppFont; 67 QFont mAppFont;
68 QFont mComposeFont; 68 QFont mComposeFont;
69 QFont mReadFont; 69 QFont mReadFont;
70 QString mName; 70 QString mName;
71 QString mSendCodec;
71 QString mEmail; 72 QString mEmail;
72 bool mSendLater, mViewAsHtml, mUseKapi; 73 QString mCurrentCodeName;
74 int mCurrentCodec;
75 bool mSendLater, mViewAsHtml, mUseKapi, isDirty;
73 private: 76 private:
74 77
75}; 78};
76 79
77#endif 80#endif
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp
index c878fc9..4abf859 100644
--- a/kmicromail/koprefsdialog.cpp
+++ b/kmicromail/koprefsdialog.cpp
@@ -120,109 +120,114 @@ void KOPrefsDialog::setupMainTab()
120 topLayout->addWidget(mNameLabel,0,0); 120 topLayout->addWidget(mNameLabel,0,0);
121 topLayout->addWidget(mNameEdit,0,1); 121 topLayout->addWidget(mNameEdit,0,1);
122 122
123 mEmailEdit = new QLineEdit(topFrame); 123 mEmailEdit = new QLineEdit(topFrame);
124 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 124 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
125 topLayout->addWidget(mEmailLabel,1,0); 125 topLayout->addWidget(mEmailLabel,1,0);
126 topLayout->addWidget(mEmailEdit,1,1); 126 topLayout->addWidget(mEmailEdit,1,1);
127 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); 127 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame);
128 topLayout->addMultiCellWidget(lab,2,2,0,1); 128 topLayout->addMultiCellWidget(lab,2,2,0,1);
129 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), 129 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"),
130 &(KOPrefs::instance()->mUseKapi),topFrame); 130 &(KOPrefs::instance()->mUseKapi),topFrame);
131 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); 131 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1);
132} 132}
133 133
134void KOPrefsDialog::setupMailTab() 134void KOPrefsDialog::setupMailTab()
135{ 135{
136 QFrame *topFrame = addPage(i18n("Mail"),0,0); 136 QFrame *topFrame = addPage(i18n("Mail"),0,0);
137 137
138 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 138 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
139 topLayout->setSpacing(spacingHint()); 139 topLayout->setSpacing(spacingHint());
140 topLayout->setMargin(marginHint()); 140 topLayout->setMargin(marginHint());
141 141
142 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), 142 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"),
143 &(KOPrefs::instance()->mViewAsHtml),topFrame); 143 &(KOPrefs::instance()->mViewAsHtml),topFrame);
144 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); 144 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1);
145 145
146 146
147 ttt = addWidBool(i18n("Send mails later"), 147 ttt = addWidBool(i18n("Send mails later"),
148 &(KOPrefs::instance()->mSendLater),topFrame); 148 &(KOPrefs::instance()->mSendLater),topFrame);
149 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); 149 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1);
150 150 mCodecEdit = new QLineEdit(topFrame);
151 topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1);
152 topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1);
153 topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1);
151 154
152} 155}
153void KOPrefsDialog::setupFontsTab() 156void KOPrefsDialog::setupFontsTab()
154{ 157{
155 158
156 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 159 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
157 // DesktopIcon("fonts",KIcon::SizeMedium)); 160 // DesktopIcon("fonts",KIcon::SizeMedium));
158 161
159 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 162 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
160 topLayout->setSpacing(1); 163 topLayout->setSpacing(1);
161 topLayout->setMargin(3); 164 topLayout->setMargin(3);
162 KPrefsDialogWidFont * tVFont; 165 KPrefsDialogWidFont * tVFont;
163 int i = 0; 166 int i = 0;
164 KPrefsDialogWidFont *timeLabelsFont = 167 KPrefsDialogWidFont *timeLabelsFont =
165 addWidFont(i18n("OK"),i18n("Application(nr)"), 168 addWidFont(i18n("OK"),i18n("Application(nr)"),
166 &(KOPrefs::instance()->mAppFont),topFrame); 169 &(KOPrefs::instance()->mAppFont),topFrame);
167 topLayout->addWidget(timeLabelsFont->label(),i,0); 170 topLayout->addWidget(timeLabelsFont->label(),i,0);
168 topLayout->addWidget(timeLabelsFont->preview(),i,1); 171 topLayout->addWidget(timeLabelsFont->preview(),i,1);
169 topLayout->addWidget(timeLabelsFont->button(),i,2); 172 topLayout->addWidget(timeLabelsFont->button(),i,2);
170 ++i; 173 ++i;
171 174
172 175
173 timeLabelsFont = 176 timeLabelsFont =
174 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), 177 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"),
175 &(KOPrefs::instance()->mComposeFont),topFrame); 178 &(KOPrefs::instance()->mComposeFont),topFrame);
176 topLayout->addWidget(timeLabelsFont->label(),i,0); 179 topLayout->addWidget(timeLabelsFont->label(),i,0);
177 topLayout->addWidget(timeLabelsFont->preview(),i,1); 180 topLayout->addWidget(timeLabelsFont->preview(),i,1);
178 topLayout->addWidget(timeLabelsFont->button(),i,2); 181 topLayout->addWidget(timeLabelsFont->button(),i,2);
179 ++i; 182 ++i;
180 183
181 KPrefsDialogWidFont *timeBarFont = 184 KPrefsDialogWidFont *timeBarFont =
182 addWidFont(i18n("Hello"),i18n("Read mail:"), 185 addWidFont(i18n("Hello"),i18n("Read mail:"),
183 &(KOPrefs::instance()->mReadFont),topFrame); 186 &(KOPrefs::instance()->mReadFont),topFrame);
184 topLayout->addWidget(timeBarFont->label(),i,0); 187 topLayout->addWidget(timeBarFont->label(),i,0);
185 topLayout->addWidget(timeBarFont->preview(),i,1); 188 topLayout->addWidget(timeBarFont->preview(),i,1);
186 topLayout->addWidget(timeBarFont->button(),i,2); 189 topLayout->addWidget(timeBarFont->button(),i,2);
187 ++i; 190 ++i;
188 191
189 topLayout->setColStretch(1,1); 192 topLayout->setColStretch(1,1);
190 topLayout->setRowStretch(4,1); 193 topLayout->setRowStretch(4,1);
191 194
192} 195}
193void KOPrefsDialog::usrReadConfig() 196void KOPrefsDialog::usrReadConfig()
194{ 197{
195 198
196 mNameEdit->setText(KOPrefs::instance()->mName); 199 mNameEdit->setText(KOPrefs::instance()->mName);
197 mEmailEdit->setText(KOPrefs::instance()->mEmail); 200 mEmailEdit->setText(KOPrefs::instance()->mEmail);
201 mCodecEdit->setText(KOPrefs::instance()->mSendCodec);
198 kdelibcfg->readConfig(); 202 kdelibcfg->readConfig();
199} 203}
200void KOPrefsDialog::usrWriteConfig() 204void KOPrefsDialog::usrWriteConfig()
201{ 205{
202 KOPrefs::instance()->mName = mNameEdit->text(); 206 KOPrefs::instance()->mName = mNameEdit->text();
203 KOPrefs::instance()->mEmail = mEmailEdit->text(); 207 KOPrefs::instance()->mEmail = mEmailEdit->text();
204 kdelibcfg->writeConfig(); 208 KOPrefs::instance()->mSendCodec = mCodecEdit->text();
209 kdelibcfg->writeConfig();
205 210
206 211
207} 212}
208 213
209#if 0 214#if 0
210void KOPrefsDialog::setupLocaleDateTab() 215void KOPrefsDialog::setupLocaleDateTab()
211{ 216{
212QFrame *topFrame = addPage(i18n("Date Format"),0,0); 217QFrame *topFrame = addPage(i18n("Date Format"),0,0);
213 QGridLayout *topLayout = new QGridLayout(topFrame,3,2); 218 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
214 topLayout->setSpacing(spacingHint()); 219 topLayout->setSpacing(spacingHint());
215 topLayout->setMargin(marginHint()); 220 topLayout->setMargin(marginHint());
216 int iii = 0; 221 int iii = 0;
217 222
218 223
219 KPrefsWidRadios *syncPrefsGroup = 224 KPrefsWidRadios *syncPrefsGroup =
220 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); 225 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
221 QString format; 226 QString format;
222 if ( QApplication::desktop()->width() < 480 ) 227 if ( QApplication::desktop()->width() < 480 )
223 format = "(%d.%m.%Y)"; 228 format = "(%d.%m.%Y)";
224 else 229 else
225 format = "(%d.%m.%Y|%A %d %B %Y)"; 230 format = "(%d.%m.%Y|%A %d %B %Y)";
226 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 231 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
227 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
228 format = "(%m.%d.%Y)"; 233 format = "(%m.%d.%Y)";
diff --git a/kmicromail/koprefsdialog.h b/kmicromail/koprefsdialog.h
index 615574b..a0416ae 100644
--- a/kmicromail/koprefsdialog.h
+++ b/kmicromail/koprefsdialog.h
@@ -42,48 +42,49 @@ class QComboBox;
42class QLineEdit; 42class QLineEdit;
43class QStringList; 43class QStringList;
44 44
45/** Dialog to change the korganizer configuration. 45/** Dialog to change the korganizer configuration.
46 */ 46 */
47class KOPrefsDialog : public KPrefsDialog 47class KOPrefsDialog : public KPrefsDialog
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 /** Initialize dialog and pages */ 51 /** Initialize dialog and pages */
52 KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 52 KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
53 ~KOPrefsDialog(); 53 ~KOPrefsDialog();
54 54
55protected: 55protected:
56 void usrReadConfig(); 56 void usrReadConfig();
57 void usrWriteConfig(); 57 void usrWriteConfig();
58 58
59 void setupMainTab(); 59 void setupMainTab();
60 void setupGlobalTab(); 60 void setupGlobalTab();
61 void setupMailTab(); 61 void setupMailTab();
62 void setupFontsTab(); 62 void setupFontsTab();
63 private: 63 private:
64 KDEPIMConfigWidget* kdelibcfg; 64 KDEPIMConfigWidget* kdelibcfg;
65 QLineEdit *mNameEdit; 65 QLineEdit *mNameEdit;
66 QLineEdit *mCodecEdit;
66 QLineEdit *mEmailEdit; 67 QLineEdit *mEmailEdit;
67 QLabel *mNameLabel; 68 QLabel *mNameLabel;
68 QLabel *mEmailLabel; 69 QLabel *mEmailLabel;
69#if 0 70#if 0
70 /* 71 /*
71 public slots: 72 public slots:
72 void showPrinterTab(); 73 void showPrinterTab();
73 74
74 75
75 void updateCategories(); 76 void updateCategories();
76 void showSyncPage(); 77 void showSyncPage();
77 protected slots: 78 protected slots:
78 void selectSoundFile(); 79 void selectSoundFile();
79 void setCategoryColor(); 80 void setCategoryColor();
80 void updateCategoryColor(); 81 void updateCategoryColor();
81 void updateTimezoneOffset( int ); 82 void updateTimezoneOffset( int );
82 83
83 84
84 void warningExperimental(bool on); 85 void warningExperimental(bool on);
85 void warningGroupScheduling(); 86 void warningGroupScheduling();
86 void warningProjectView(); 87 void warningProjectView();
87 88
88 void toggleEmailSettings(bool); 89 void toggleEmailSettings(bool);
89 90
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c
index dbaeb68..b2ab0f7 100644
--- a/kmicromail/libetpan/mime/mailmime_decode.c
+++ b/kmicromail/libetpan/mime/mailmime_decode.c
@@ -96,150 +96,165 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
96 size_t * index, const char * tocode, 96 size_t * index, const char * tocode,
97 char ** result) 97 char ** result)
98{ 98{
99 MMAPString * gphrase; 99 MMAPString * gphrase;
100 struct mailmime_encoded_word * word; 100 struct mailmime_encoded_word * word;
101 int first; 101 int first;
102 size_t cur_token; 102 size_t cur_token;
103 int r; 103 int r;
104 int res; 104 int res;
105 char * str; 105 char * str;
106 char * wordutf8; 106 char * wordutf8;
107 int type; 107 int type;
108 108
109 cur_token = * index; 109 cur_token = * index;
110 110
111 gphrase = mmap_string_new(""); 111 gphrase = mmap_string_new("");
112 if (gphrase == NULL) { 112 if (gphrase == NULL) {
113 res = MAILIMF_ERROR_MEMORY; 113 res = MAILIMF_ERROR_MEMORY;
114 goto err; 114 goto err;
115 } 115 }
116 116
117 first = TRUE; 117 first = TRUE;
118 118
119 type = TYPE_ERROR; /* XXX - removes a gcc warning */ 119 type = TYPE_ERROR; /* XXX - removes a gcc warning */
120 // LUTZ add
121 int appendNewLine = FALSE;
122 while (1) { //while
120 123
121 while (1) { 124 r = mailmime_encoded_word_parse(message, length, &cur_token, &word);
122 125 if (r == MAILIMF_NO_ERROR) {
123 r = mailmime_encoded_word_parse(message, length, &cur_token, &word); 126 if (!first) {
124 if (r == MAILIMF_NO_ERROR) { 127 if (type != TYPE_ENCODED_WORD) {
125 if (!first) { 128 if (mmap_string_append_c(gphrase, ' ') == NULL) {
126 if (type != TYPE_ENCODED_WORD) { 129 mailmime_encoded_word_free(word);
127 if (mmap_string_append_c(gphrase, ' ') == NULL) { 130 res = MAILIMF_ERROR_MEMORY;
128 mailmime_encoded_word_free(word); 131 goto free;
129 res = MAILIMF_ERROR_MEMORY; 132 }
130 goto free; 133 }
131 } 134 }
132 } 135 type = TYPE_ENCODED_WORD;
133 } 136 wordutf8 = NULL;
134 type = TYPE_ENCODED_WORD; 137 r = charconv(tocode, word->wd_charset, word->wd_text,
135 wordutf8 = NULL; 138 strlen(word->wd_text), &wordutf8);
136 r = charconv(tocode, word->wd_charset, word->wd_text, 139 switch (r) {
137 strlen(word->wd_text), &wordutf8); 140 case MAIL_CHARCONV_ERROR_MEMORY:
138 switch (r) { 141 mailmime_encoded_word_free(word);
139 case MAIL_CHARCONV_ERROR_MEMORY: 142 res = MAILIMF_ERROR_MEMORY;
140 mailmime_encoded_word_free(word); 143 goto free;
141 res = MAILIMF_ERROR_MEMORY; 144
142 goto free; 145 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
143 146 case MAIL_CHARCONV_ERROR_CONV:
144 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: 147 mailmime_encoded_word_free(word);
145 case MAIL_CHARCONV_ERROR_CONV: 148 res = MAILIMF_ERROR_PARSE;
146 mailmime_encoded_word_free(word); 149 goto free;
147 res = MAILIMF_ERROR_PARSE; 150 }
148 goto free;
149 }
150 151
151 if (wordutf8 != NULL) { 152 if (wordutf8 != NULL) {
152 if (mmap_string_append(gphrase, wordutf8) == NULL) { 153 if (mmap_string_append(gphrase, wordutf8) == NULL) {
154 mailmime_encoded_word_free(word);
155 free(wordutf8);
156 res = MAILIMF_ERROR_MEMORY;
157 goto free;
158 }
159 free(wordutf8);
160 }
153 mailmime_encoded_word_free(word); 161 mailmime_encoded_word_free(word);
154 free(wordutf8); 162 first = FALSE;
155 res = MAILIMF_ERROR_MEMORY; 163 }
164 else if (r == MAILIMF_ERROR_PARSE) {
165 /* do nothing */
166 }
167 else {
168 res = r;
156 goto free; 169 goto free;
157 }
158 free(wordutf8);
159 } 170 }
160 mailmime_encoded_word_free(word);
161 first = FALSE;
162 }
163 else if (r == MAILIMF_ERROR_PARSE) {
164 /* do nothing */
165 }
166 else {
167 res = r;
168 goto free;
169 }
170
171 if (r == MAILIMF_ERROR_PARSE) {
172 char * raw_word;
173 171
174 r = mailmime_non_encoded_word_parse(message, length, 172 if (r == MAILIMF_ERROR_PARSE) {
175 &cur_token, &raw_word); 173 char * raw_word;
176 if (r == MAILIMF_NO_ERROR) { 174
177 if (!first) { 175 r = mailmime_non_encoded_word_parse(message, length,
178 if (mmap_string_append_c(gphrase, ' ') == NULL) { 176 &cur_token, &raw_word);
179 free(raw_word); 177 if (r == MAILIMF_NO_ERROR) {
180 res = MAILIMF_ERROR_MEMORY; 178 if (!first) {
181 goto free; 179 if (mmap_string_append_c(gphrase, ' ') == NULL) {
182 } 180 free(raw_word);
183 } 181 res = MAILIMF_ERROR_MEMORY;
184 type = TYPE_WORD; 182 goto free;
183 }
184 }
185 type = TYPE_WORD;
185 186
186 wordutf8 = NULL; 187 wordutf8 = NULL;
187 r = charconv(tocode, default_fromcode, raw_word, 188 r = charconv(tocode, default_fromcode, raw_word,
188 strlen(raw_word), &wordutf8); 189 strlen(raw_word), &wordutf8);
189 190
190 switch (r) { 191 switch (r) {
191 case MAIL_CHARCONV_ERROR_MEMORY: 192 case MAIL_CHARCONV_ERROR_MEMORY:
192 free(raw_word); 193 free(raw_word);
193 res = MAILIMF_ERROR_MEMORY; 194 res = MAILIMF_ERROR_MEMORY;
194 goto free; 195 goto free;
195 196
196 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: 197 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
197 case MAIL_CHARCONV_ERROR_CONV: 198 case MAIL_CHARCONV_ERROR_CONV:
198 free(raw_word); 199 free(raw_word);
199 res = MAILIMF_ERROR_PARSE; 200 res = MAILIMF_ERROR_PARSE;
200 goto free; 201 goto free;
201 } 202 }
202 203 // LUTZ add
203 if (mmap_string_append(gphrase, wordutf8) == NULL) { 204 if ( appendNewLine ) {
204 free(wordutf8); 205 appendNewLine = FALSE;
205 free(raw_word); 206 if (mmap_string_append(gphrase, "\n") == NULL) {
206 res = MAILIMF_ERROR_MEMORY; 207 free(wordutf8);
207 goto free; 208 free(raw_word);
208 } 209 res = MAILIMF_ERROR_MEMORY;
209 // LUTZ fix 210 goto free;
210 free(wordutf8); 211 }
211 free(raw_word); 212 }
212 first = FALSE; 213 //fprintf(stderr,"append *%s* \n",wordutf8 );
214 if (mmap_string_append(gphrase, wordutf8) == NULL) {
215 free(wordutf8);
216 free(raw_word);
217 res = MAILIMF_ERROR_MEMORY;
218 goto free;
219 }
220 // LUTZ fix
221 free(wordutf8);
222 free(raw_word);
223 first = FALSE;
224 }
225 else if (r == MAILIMF_ERROR_PARSE) {
226 // LUTZ add
227 if ( cur_token >= length )
228 break;
229 ++cur_token;
230 appendNewLine = TRUE;
231 }
232 else {
233 res = r;
234 goto free;
235 }
213 } 236 }
214 else if (r == MAILIMF_ERROR_PARSE) {
215 break;
216 }
217 else {
218 res = r;
219 goto free;
220 }
221 }
222 } 237 }
223 238
224 if (first) { 239 if (first) {
225 res = MAILIMF_ERROR_PARSE; 240 res = MAILIMF_ERROR_PARSE;
226 goto free; 241 goto free;
227 } 242 }
228 243
229 str = strdup(gphrase->str); 244 str = strdup(gphrase->str);
230 if (str == NULL) { 245 if (str == NULL) {
231 res = MAILIMF_ERROR_MEMORY; 246 res = MAILIMF_ERROR_MEMORY;
232 goto free; 247 goto free;
233 } 248 }
234 mmap_string_free(gphrase); 249 mmap_string_free(gphrase);
235 250
236 * result = str; 251 * result = str;
237 * index = cur_token; 252 * index = cur_token;
238 253
239 return MAILIMF_NO_ERROR; 254 return MAILIMF_NO_ERROR;
240 255
241 free: 256 free:
242 mmap_string_free(gphrase); 257 mmap_string_free(gphrase);
243 err: 258 err:
244 return res; 259 return res;
245} 260}
@@ -266,50 +281,50 @@ mailmime_non_encoded_word_parse(const char * message, size_t length,
266 281
267 begin = cur_token; 282 begin = cur_token;
268 283
269 end = FALSE; 284 end = FALSE;
270 while (1) { 285 while (1) {
271 if (cur_token >= length) 286 if (cur_token >= length)
272 break; 287 break;
273 288
274 switch (message[cur_token]) { 289 switch (message[cur_token]) {
275 case ' ': 290 case ' ':
276 case '\t': 291 case '\t':
277 case '\r': 292 case '\r':
278 case '\n': 293 case '\n':
279 end = TRUE; 294 end = TRUE;
280 break; 295 break;
281 } 296 }
282 297
283 if (end) 298 if (end)
284 break; 299 break;
285 300
286 cur_token ++; 301 cur_token ++;
287 } 302 }
288 303
289 if (cur_token - begin == 0) { 304 if (cur_token - begin == 0) {
290 res = MAILIMF_ERROR_PARSE; 305 res = MAILIMF_ERROR_PARSE;
291 goto err; 306 goto err;
292 } 307 }
293 308
294 text = malloc(cur_token - begin + 1); 309 text = malloc(cur_token - begin + 1);
295 if (text == NULL) { 310 if (text == NULL) {
296 res = MAILIMF_ERROR_MEMORY; 311 res = MAILIMF_ERROR_MEMORY;
297 goto err; 312 goto err;
298 } 313 }
299 314
300 memcpy(text, message + begin, cur_token - begin); 315 memcpy(text, message + begin, cur_token - begin);
301 text[cur_token - begin] = '\0'; 316 text[cur_token - begin] = '\0';
302 317
303 * index = cur_token; 318 * index = cur_token;
304 * result = text; 319 * result = text;
305 320
306 return MAILIMF_NO_ERROR; 321 return MAILIMF_NO_ERROR;
307 322
308 err: 323 err:
309 return res; 324 return res;
310} 325}
311 326
312static int mailmime_encoded_word_parse(const char * message, size_t length, 327static int mailmime_encoded_word_parse(const char * message, size_t length,
313 size_t * index, 328 size_t * index,
314 struct mailmime_encoded_word ** result) 329 struct mailmime_encoded_word ** result)
315{ 330{
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 8ee112c..ed5c898 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -55,72 +55,73 @@ AbstractMail* AbstractMail::getWrapper(Account*a)
55 break; 55 break;
56 default: 56 default:
57 return 0; 57 return 0;
58 } 58 }
59} 59}
60 60
61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
62{ 62{
63 // odebug << "Decode string start" << oendl; 63 // odebug << "Decode string start" << oendl;
64 char*result_text; 64 char*result_text;
65 size_t index = 0; 65 size_t index = 0;
66 /* reset for recursive use! */ 66 /* reset for recursive use! */
67 size_t target_length = 0; 67 size_t target_length = 0;
68 result_text = 0; 68 result_text = 0;
69 int mimetype = MAILMIME_MECHANISM_7BIT; 69 int mimetype = MAILMIME_MECHANISM_7BIT;
70 if (enc.lower()=="quoted-printable") { 70 if (enc.lower()=="quoted-printable") {
71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
72 } else if (enc.lower()=="base64") { 72 } else if (enc.lower()=="base64") {
73 mimetype = MAILMIME_MECHANISM_BASE64; 73 mimetype = MAILMIME_MECHANISM_BASE64;
74 } else if (enc.lower()=="8bit") { 74 } else if (enc.lower()=="8bit") {
75 mimetype = MAILMIME_MECHANISM_8BIT; 75 mimetype = MAILMIME_MECHANISM_8BIT;
76 } else if (enc.lower()=="binary") { 76 } else if (enc.lower()=="binary") {
77 mimetype = MAILMIME_MECHANISM_BINARY; 77 mimetype = MAILMIME_MECHANISM_BINARY;
78 } 78 }
79
80 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 79 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
81 &result_text,&target_length); 80 &result_text,&target_length);
82 81
83 encodedString* result = new encodedString(); 82 encodedString* result = new encodedString();
84 if (err == MAILIMF_NO_ERROR) { 83 if (err == MAILIMF_NO_ERROR) {
85 result->setContent(result_text,target_length); 84 result->setContent(result_text,target_length);
86 } 85 }
87 //odebug << "Decode string finished" << oendl; 86 //odebug << "Decode string finished" << oendl;
88 return result; 87 return result;
89} 88}
90 89
91QString AbstractMail::convert_String(const char*text) 90QString AbstractMail::convert_String(const char*text)
92{ 91{
93 size_t index = 0; 92 size_t index = 0;
94 char*res = 0; 93 char*res = 0;
95 int err = MAILIMF_NO_ERROR; 94 int err = MAILIMF_NO_ERROR;
96 95
97 QString result(text); 96 QString result(text);
98 97 //qDebug("convert_String %s ", text);
98 //err = mailmime_encoded_phrase_parse("iso-8859-1",
99 // text, strlen(text),&index, "iso-8859-1",&res);
99 err = mailmime_encoded_phrase_parse("iso-8859-1", 100 err = mailmime_encoded_phrase_parse("iso-8859-1",
100 text, strlen(text),&index, "iso-8859-1",&res); 101 text, strlen(text),&index, "utf-8",&res);
101 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 102 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
102 result = QString(res); 103 result = QString::fromUtf8(res);
103 } 104 }
104 //qDebug("convert_String:%s ",result.latin1() ); 105 //qDebug("convert_String:%s ",result.latin1() );
105 if (res) free(res); 106 if (res) free(res);
106 return result; 107 return result;
107} 108}
108 109
109/* cp & paste from launcher */ 110/* cp & paste from launcher */
110QString AbstractMail::gen_attachment_id() 111QString AbstractMail::gen_attachment_id()
111{ 112{
112 QFile file( "/proc/sys/kernel/random/uuid" ); 113 QFile file( "/proc/sys/kernel/random/uuid" );
113 if (!file.open(IO_ReadOnly ) ) 114 if (!file.open(IO_ReadOnly ) )
114 return QString::null; 115 return QString::null;
115 116
116 QTextStream stream(&file); 117 QTextStream stream(&file);
117 118
118 return "{" + stream.read().stripWhiteSpace() + "}"; 119 return "{" + stream.read().stripWhiteSpace() + "}";
119} 120}
120 121
121int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 122int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
122{ 123{
123 return 0; 124 return 0;
124} 125}
125 126
126QString AbstractMail::defaultLocalfolder() 127QString AbstractMail::defaultLocalfolder()
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index d89a5f9..49227dd 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -199,48 +199,62 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
199 199
200 switch (mime->mm_type) { 200 switch (mime->mm_type) {
201 case MAILMIME_SINGLE: 201 case MAILMIME_SINGLE:
202 { 202 {
203 QValueList<int>countlist = recList; 203 QValueList<int>countlist = recList;
204 countlist.append(current_count); 204 countlist.append(current_count);
205 r = mailmessage_fetch_section(message,mime,&data,&len); 205 r = mailmessage_fetch_section(message,mime,&data,&len);
206 part->setSize(len); 206 part->setSize(len);
207 part->setPositionlist(countlist); 207 part->setPositionlist(countlist);
208 b = gen_attachment_id(); 208 b = gen_attachment_id();
209 part->setIdentifier(b); 209 part->setIdentifier(b);
210 fillSingleBody(part,message,mime); 210 fillSingleBody(part,message,mime);
211 if (part->Type()=="text" && target->Bodytext().isNull()) { 211 if (part->Type()=="text" && target->Bodytext().isNull()) {
212 encodedString*rs = new encodedString(); 212 encodedString*rs = new encodedString();
213 rs->setContent(data,len); 213 rs->setContent(data,len);
214 encodedString*res = decode_String(rs,part->Encoding()); 214 encodedString*res = decode_String(rs,part->Encoding());
215 if (countlist.count()>2) { 215 if (countlist.count()>2) {
216 bodyCache[b]=rs; 216 bodyCache[b]=rs;
217 target->addPart(part); 217 target->addPart(part);
218 } else { 218 } else {
219 delete rs; 219 delete rs;
220 } 220 }
221 b = QString(res->Content()); 221 b = QString(res->Content());
222 delete res; 222 delete res;
223 size_t index = 0;
224 char*resu = 0;
225 int err = MAILIMF_NO_ERROR;
226 QString charset = part->searchParamter( "charset");
227 qDebug("CHARSET %s ",charset.latin1() );
228 if ( !charset.isEmpty() ) {
229 err = mailmime_encoded_phrase_parse(charset.latin1(),
230 b.latin1(), b.length(),&index, "utf-8",&resu);
231 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) {
232 //qDebug("res %d %s ", index, resu);
233 b = QString::fromUtf8(resu);
234 }
235 if (resu) free(resu);
236 }
223 target->setBodytext(b); 237 target->setBodytext(b);
224 target->setDescription(part); 238 target->setDescription(part);
225 } else { 239 } else {
226 bodyCache[b]=new encodedString(data,len); 240 bodyCache[b]=new encodedString(data,len);
227 target->addPart(part); 241 target->addPart(part);
228 } 242 }
229 } 243 }
230 break; 244 break;
231 case MAILMIME_MULTIPLE: 245 case MAILMIME_MULTIPLE:
232 { 246 {
233 unsigned int ccount = 1; 247 unsigned int ccount = 1;
234 mailmime*cbody=0; 248 mailmime*cbody=0;
235 QValueList<int>countlist = recList; 249 QValueList<int>countlist = recList;
236 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 250 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
237 cbody = (mailmime*)clist_content(cur); 251 cbody = (mailmime*)clist_content(cur);
238 if (cbody->mm_type==MAILMIME_MULTIPLE) { 252 if (cbody->mm_type==MAILMIME_MULTIPLE) {
239 RecPartP targetPart = new RecPart(); 253 RecPartP targetPart = new RecPart();
240 targetPart->setType("multipart"); 254 targetPart->setType("multipart");
241 countlist.append(current_count); 255 countlist.append(current_count);
242 targetPart->setPositionlist(countlist); 256 targetPart->setPositionlist(countlist);
243 target->addPart(targetPart); 257 target->addPart(targetPart);
244 } 258 }
245 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 259 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
246 if (cbody->mm_type==MAILMIME_MULTIPLE) { 260 if (cbody->mm_type==MAILMIME_MULTIPLE) {
@@ -323,49 +337,49 @@ QString Genericwrapper::parseAddressList( mailimf_address_list *list )
323 337
324QString Genericwrapper::parseGroup( mailimf_group *group ) 338QString Genericwrapper::parseGroup( mailimf_group *group )
325{ 339{
326 QString result( "" ); 340 QString result( "" );
327 341
328 result.append( group->grp_display_name ); 342 result.append( group->grp_display_name );
329 result.append( ": " ); 343 result.append( ": " );
330 344
331 if ( group->grp_mb_list != NULL ) { 345 if ( group->grp_mb_list != NULL ) {
332 result.append( parseMailboxList( group->grp_mb_list ) ); 346 result.append( parseMailboxList( group->grp_mb_list ) );
333 } 347 }
334 348
335 result.append( ";" ); 349 result.append( ";" );
336 350
337 return result; 351 return result;
338} 352}
339 353
340QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 354QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
341{ 355{
342 QString result( "" ); 356 QString result( "" );
343 357
344 if ( box->mb_display_name == NULL ) { 358 if ( box->mb_display_name == NULL ) {
345 result.append( box->mb_addr_spec ); 359 result.append( box->mb_addr_spec );
346 } else { 360 } else {
347 result.append( convert_String(box->mb_display_name).latin1() ); 361 result.append( convert_String(box->mb_display_name) );
348 result.append( " <" ); 362 result.append( " <" );
349 result.append( box->mb_addr_spec ); 363 result.append( box->mb_addr_spec );
350 result.append( ">" ); 364 result.append( ">" );
351 } 365 }
352 366
353 return result; 367 return result;
354} 368}
355 369
356QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 370QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
357{ 371{
358 QString result( "" ); 372 QString result( "" );
359 373
360 bool first = true; 374 bool first = true;
361 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 375 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
362 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 376 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
363 377
364 if ( !first ) { 378 if ( !first ) {
365 result.append( "," ); 379 result.append( "," );
366 } else { 380 } else {
367 first = false; 381 first = false;
368 } 382 }
369 383
370 result.append( parseMailbox( box ) ); 384 result.append( parseMailbox( box ) );
371 } 385 }
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d90a8d2..eb2b47d 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -731,48 +731,67 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
731{ 731{
732 if (!body || current_recursion>=10) { 732 if (!body || current_recursion>=10) {
733 return; 733 return;
734 } 734 }
735 switch (body->bd_type) { 735 switch (body->bd_type) {
736 case MAILIMAP_BODY_1PART: 736 case MAILIMAP_BODY_1PART:
737 { 737 {
738 QValueList<int>countlist = recList; 738 QValueList<int>countlist = recList;
739 countlist.append(current_count); 739 countlist.append(current_count);
740 RecPartP currentPart = new RecPart(); 740 RecPartP currentPart = new RecPart();
741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
742 QString id(""); 742 QString id("");
743 currentPart->setPositionlist(countlist); 743 currentPart->setPositionlist(countlist);
744 for (unsigned int j = 0; j < countlist.count();++j) { 744 for (unsigned int j = 0; j < countlist.count();++j) {
745 id+=(j>0?" ":""); 745 id+=(j>0?" ":"");
746 id+=QString("%1").arg(countlist[j]); 746 id+=QString("%1").arg(countlist[j]);
747 } 747 }
748 //odebug << "ID = " << id.latin1() << "" << oendl; 748 //odebug << "ID = " << id.latin1() << "" << oendl;
749 currentPart->setIdentifier(id); 749 currentPart->setIdentifier(id);
750 fillSinglePart(currentPart,part1); 750 fillSinglePart(currentPart,part1);
751 /* important: Check for is NULL 'cause a body can be empty! 751 /* important: Check for is NULL 'cause a body can be empty!
752 And we put it only into the mail if it is the FIRST part */ 752 And we put it only into the mail if it is the FIRST part */
753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
755
756 size_t index = 0;
757 char*res = 0;
758 int err = MAILIMF_NO_ERROR;
759
760 QString charset = currentPart->searchParamter( "charset");
761 qDebug("CHARSET %s ",charset.latin1() );
762 //if ( false ) {
763 if ( !charset.isEmpty() ) {
764 //err = mailmime_encoded_phrase_parse("iso-8859-1",
765 // text, strlen(text),&index, "iso-8859-1",&res);
766 err = mailmime_encoded_phrase_parse(charset.latin1(),
767 body_text.latin1(), body_text.length(),&index, "utf-8",&res);
768 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
769 //qDebug("res %d %s ", index, res);
770 body_text = QString::fromUtf8(res);
771 }
772 if (res) free(res);
773 }
755 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); 774 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
756 target_body->setDescription(currentPart); 775 target_body->setDescription(currentPart);
757 target_body->setBodytext(body_text); 776 target_body->setBodytext(body_text);
758 if (countlist.count()>1) { 777 if (countlist.count()>1) {
759 target_body->addPart(currentPart); 778 target_body->addPart(currentPart);
760 } 779 }
761 } else { 780 } else {
762 target_body->addPart(currentPart); 781 target_body->addPart(currentPart);
763 } 782 }
764 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 783 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
765 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 784 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
766 } 785 }
767 } 786 }
768 break; 787 break;
769 case MAILIMAP_BODY_MPART: 788 case MAILIMAP_BODY_MPART:
770 { 789 {
771 QValueList<int>countlist = recList; 790 QValueList<int>countlist = recList;
772 clistcell*current=0; 791 clistcell*current=0;
773 mailimap_body*current_body=0; 792 mailimap_body*current_body=0;
774 unsigned int ccount = 1; 793 unsigned int ccount = 1;
775 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 794 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
776 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 795 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
777 current_body = (mailimap_body*)current->data; 796 current_body = (mailimap_body*)current->data;
778 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 797 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp
index 0cdbae4..87f8c8a 100644
--- a/kmicromail/libmailwrapper/mboxwrapper.cpp
+++ b/kmicromail/libmailwrapper/mboxwrapper.cpp
@@ -104,48 +104,49 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail )
104 mailfolder*folder; 104 mailfolder*folder;
105 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 105 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
106 r = mailfolder_connect(folder); 106 r = mailfolder_connect(folder);
107 if (r != MAIL_NO_ERROR) { 107 if (r != MAIL_NO_ERROR) {
108 ; // << "Error initializing mbox" << oendl; 108 ; // << "Error initializing mbox" << oendl;
109 mailfolder_free(folder); 109 mailfolder_free(folder);
110 mailstorage_free(storage); 110 mailstorage_free(storage);
111 return body; 111 return body;
112 } 112 }
113 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); 113 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
114 if (r != MAIL_NO_ERROR) { 114 if (r != MAIL_NO_ERROR) {
115 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; 115 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl;
116 mailfolder_free(folder); 116 mailfolder_free(folder);
117 mailstorage_free(storage); 117 mailstorage_free(storage);
118 return body; 118 return body;
119 } 119 }
120 r = mailmessage_fetch(msg,&data,&size); 120 r = mailmessage_fetch(msg,&data,&size);
121 if (r != MAIL_NO_ERROR) { 121 if (r != MAIL_NO_ERROR) {
122 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; 122 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl;
123 mailfolder_free(folder); 123 mailfolder_free(folder);
124 mailstorage_free(storage); 124 mailstorage_free(storage);
125 mailmessage_free(msg); 125 mailmessage_free(msg);
126 return body; 126 return body;
127 } 127 }
128 qDebug("MBOXwrapper::fetchBody ");
128 body = parseMail(msg); 129 body = parseMail(msg);
129 mailmessage_fetch_result_free(msg,data); 130 mailmessage_fetch_result_free(msg,data);
130 mailfolder_free(folder); 131 mailfolder_free(folder);
131 mailstorage_free(storage); 132 mailstorage_free(storage);
132 133
133 return body; 134 return body;
134} 135}
135 136
136void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) 137void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
137{ 138{
138 ; // << "MBOX " << current << " von " << maximum << "" << oendl; 139 ; // << "MBOX " << current << " von " << maximum << "" << oendl;
139} 140}
140 141
141int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) 142int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool )
142{ 143{
143 QString p = MBOXPath+"/"; 144 QString p = MBOXPath+"/";
144 p+=folder; 145 p+=folder;
145 QFileInfo fi(p); 146 QFileInfo fi(p);
146 if (fi.exists()) { 147 if (fi.exists()) {
147 Global::statusMessage(i18n("Mailbox exists.")); 148 Global::statusMessage(i18n("Mailbox exists."));
148 return 0; 149 return 0;
149 } 150 }
150 mailmbox_folder*f = 0; 151 mailmbox_folder*f = 0;
151 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { 152 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 90b5d23..982d7a6 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -107,48 +107,49 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
107 107
108void MHwrapper::deleteMail(const RecMailP&mail) 108void MHwrapper::deleteMail(const RecMailP&mail)
109{ 109{
110 init_storage(); 110 init_storage();
111 if (!m_storage) { 111 if (!m_storage) {
112 return; 112 return;
113 } 113 }
114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
115 if (r!=MAIL_NO_ERROR) { 115 if (r!=MAIL_NO_ERROR) {
116 qDebug("error selecting folder! "); 116 qDebug("error selecting folder! ");
117 return; 117 return;
118 } 118 }
119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
120 if (r != MAIL_NO_ERROR) { 120 if (r != MAIL_NO_ERROR) {
121 qDebug("error deleting mail "); 121 qDebug("error deleting mail ");
122 } 122 }
123} 123}
124 124
125void MHwrapper::answeredMail(const RecMailP&) 125void MHwrapper::answeredMail(const RecMailP&)
126{ 126{
127} 127}
128 128
129RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) 129RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
130{ 130{
131 qDebug("MHwrapper::fetchBody ");
131 RecBodyP body = new RecBody(); 132 RecBodyP body = new RecBody();
132 init_storage(); 133 init_storage();
133 if (!m_storage) { 134 if (!m_storage) {
134 return body; 135 return body;
135 } 136 }
136 mailmessage * msg; 137 mailmessage * msg;
137 char*data=0; 138 char*data=0;
138 139
139 /* mail should hold the complete path! */ 140 /* mail should hold the complete path! */
140 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 141 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
141 if (r != MAIL_NO_ERROR) { 142 if (r != MAIL_NO_ERROR) {
142 return body; 143 return body;
143 } 144 }
144 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 145 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
145 if (r != MAIL_NO_ERROR) { 146 if (r != MAIL_NO_ERROR) {
146 qDebug("Error fetching mail "); 147 qDebug("Error fetching mail ");
147 148
148 return body; 149 return body;
149 } 150 }
150 body = parseMail(msg); 151 body = parseMail(msg);
151 mailmessage_fetch_result_free(msg,data); 152 mailmessage_fetch_result_free(msg,data);
152 return body; 153 return body;
153} 154}
154 155
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index 5ef5b6a..484a635 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -34,50 +34,50 @@ void MailListViewItem::showEntry()
34 // 1.23 34 // 1.23
35 // 11.23 35 // 11.23
36 // 111.23 36 // 111.23
37 // 999.23 maxlen 37 // 999.23 maxlen
38 switch(fsize.length() ) { 38 switch(fsize.length() ) {
39 case 4: 39 case 4:
40 fsort = "00" + fsize ; 40 fsort = "00" + fsize ;
41 break; 41 break;
42 case 5: 42 case 5:
43 fsort = "0" + fsize ; 43 fsort = "0" + fsize ;
44 break; 44 break;
45 default: 45 default:
46 fsort = fsize ; 46 fsort = fsize ;
47 break; 47 break;
48 48
49 } 49 }
50 if ( w == 0 ) { 50 if ( w == 0 ) {
51 setText(3, fsize + "kB" ); 51 setText(3, fsize + "kB" );
52 mKeyMap.insert(3, "k" + fsort); 52 mKeyMap.insert(3, "k" + fsort);
53 //setText(3, "kB" + fsort ); // test only 53 //setText(3, "kB" + fsort ); // test only
54 } else { 54 } else {
55 //setText(3, fsize + "MB"); 55 //setText(3, fsize + "MB");
56 mKeyMap.insert(3, "M" +fsort ); 56 mKeyMap.insert(3, "M" +fsort );
57 } 57 }
58 setText(1,QString::fromUtf8( mail_data->getSubject().latin1())); 58 setText(1,mail_data->getSubject());
59 setText(2,QString::fromUtf8( mail_data->getFrom().latin1())); 59 setText(2,mail_data->getFrom());
60#if 0 60#if 0
61 QString date = mail_data->getDate(); 61 QString date = mail_data->getDate();
62 62
63 int kom = date.find( ",")+2; 63 int kom = date.find( ",")+2;
64 if ( kom == 1 ) 64 if ( kom == 1 )
65 kom = 0; 65 kom = 0;
66 if ( date.mid(kom,1) == " ") 66 if ( date.mid(kom,1) == " ")
67 ++kom; 67 ++kom;
68 if ( date.mid(kom+1,1) == " " ) 68 if ( date.mid(kom+1,1) == " " )
69 date = "0" + date.mid( kom ); 69 date = "0" + date.mid( kom );
70 else if ( kom ) 70 else if ( kom )
71 date = date.mid( kom ); 71 date = date.mid( kom );
72 if ( kom || date.mid(2,1 ) == " ") { 72 if ( kom || date.mid(2,1 ) == " ") {
73 QString mon = date.mid(3,3); 73 QString mon = date.mid(3,3);
74 QString so = 00; 74 QString so = 00;
75 if ( mon == "Jan" ) 75 if ( mon == "Jan" )
76 so = "01"; 76 so = "01";
77 else if ( mon == "Feb" ) 77 else if ( mon == "Feb" )
78 so = "02"; 78 so = "02";
79 else if ( mon == "Mar" ) 79 else if ( mon == "Mar" )
80 so = "03"; 80 so = "03";
81 else if ( mon == "Apr" ) 81 else if ( mon == "Apr" )
82 so = "04"; 82 so = "04";
83 else if ( mon == "May" ) 83 else if ( mon == "May" )
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 98eb9a5..3013931 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,47 +1,48 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qvbox.h> 4#include <qvbox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlayout.h> 7#include <qlayout.h>
8//#include <kdialog.h> 8//#include <kdialog.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10#include <kapplication.h> 10#include <kapplication.h>
11 11
12#ifdef DESKTOP_VERSION 12#ifdef DESKTOP_VERSION
13#include <qapplication.h> 13#include <qapplication.h>
14#include <qstatusbar.h> 14#include <qstatusbar.h>
15#include <kabc/stdaddressbook.h>
15extern QStatusBar* globalSstatusBarMainWindow; 16extern QStatusBar* globalSstatusBarMainWindow;
16#else 17#else
17#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
18#endif 19#endif
19#include "defines.h" 20#include "defines.h"
20#include "mainwindow.h" 21#include "mainwindow.h"
21#include <KDGanttMinimizeSplitter.h> 22#include <KDGanttMinimizeSplitter.h>
22 23
23#include <kabc/stdaddressbook.h> 24#include "koprefs.h"
24 25
25MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
26 : QMainWindow( parent, name ) //, flags ) 27 : QMainWindow( parent, name ) //, flags )
27{ 28{
28#ifdef DESKTOP_VERSION 29#ifdef DESKTOP_VERSION
29 globalSstatusBarMainWindow = statusBar(); 30 globalSstatusBarMainWindow = statusBar();
30#endif 31#endif
31 setCaption( i18n( "KOpieMail/Pi" ) ); 32 setCaption( i18n( "KOpieMail/Pi" ) );
32 setToolBarsMovable( false ); 33 setToolBarsMovable( false );
33 //KABC::StdAddressBook::self(); 34 //KABC::StdAddressBook::self();
34 toolBar = new QToolBar( this ); 35 toolBar = new QToolBar( this );
35 menuBar = new QPEMenuBar( toolBar ); 36 menuBar = new QPEMenuBar( toolBar );
36 mailMenu = new QPopupMenu( menuBar ); 37 mailMenu = new QPopupMenu( menuBar );
37 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 38 menuBar->insertItem( i18n( "Mail" ), mailMenu );
38 settingsMenu = new QPopupMenu( menuBar ); 39 settingsMenu = new QPopupMenu( menuBar );
39 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 40 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
40 41
41 addToolBar( toolBar ); 42 addToolBar( toolBar );
42 toolBar->setHorizontalStretchable( true ); 43 toolBar->setHorizontalStretchable( true );
43 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 44 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
44 0, 0, this ); 45 0, 0, this );
45 connect(getMail, SIGNAL( activated() ), 46 connect(getMail, SIGNAL( activated() ),
46 SLOT( slotGetAllMail() ) ); 47 SLOT( slotGetAllMail() ) );
47 getMail->addTo( mailMenu ); 48 getMail->addTo( mailMenu );
@@ -78,49 +79,56 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
78 connect(showFolders, SIGNAL( toggled(bool) ), 79 connect(showFolders, SIGNAL( toggled(bool) ),
79 SLOT( slotShowFolders(bool) ) ); 80 SLOT( slotShowFolders(bool) ) );
80 81
81 /* 82 /*
82 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 83 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
83 0, 0, this ); 84 0, 0, this );
84 searchMails->addTo( toolBar ); 85 searchMails->addTo( toolBar );
85 searchMails->addTo( mailMenu ); 86 searchMails->addTo( mailMenu );
86 */ 87 */
87 88
88 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 89 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
89 deleteMails->addTo( toolBar ); 90 deleteMails->addTo( toolBar );
90 deleteMails->addTo( mailMenu ); 91 deleteMails->addTo( mailMenu );
91 connect( deleteMails, SIGNAL( activated() ), 92 connect( deleteMails, SIGNAL( activated() ),
92 SLOT( slotDeleteMail() ) ); 93 SLOT( slotDeleteMail() ) );
93 94
94 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 95 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
95 0, 0, this ); 96 0, 0, this );
96 editSettings->addTo( settingsMenu ); 97 editSettings->addTo( settingsMenu );
97 connect( editSettings, SIGNAL( activated() ), 98 connect( editSettings, SIGNAL( activated() ),
98 SLOT( slotEditSettings() ) ); 99 SLOT( slotEditSettings() ) );
99 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 100 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
100 0, 0, this ); 101 0, 0, this );
101 editAccounts->addTo( settingsMenu ); 102 editAccounts->addTo( settingsMenu );
102 103 codecMenu = new QPopupMenu( menuBar );
104 codecMenu->insertItem( "Western (iso-8859-1)",0,0);
105 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1);
106 codecMenu->insertItem( "Western (iso-8859-15)",2,2);
107 codecMenu->insertItem( "Chinese (big-5)",3,3);
108 codecMenu->insertItem( "Unicode (utf-8)",4,4);
109 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5);
110 settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu);
103 //setCentralWidget( view ); 111 //setCentralWidget( view );
104 112
105 QVBox* wrapperBox = new QVBox( this ); 113 QVBox* wrapperBox = new QVBox( this );
106 setCentralWidget( wrapperBox ); 114 setCentralWidget( wrapperBox );
107 115
108 // QWidget *view = new QWidget( wrapperBox ); 116 // QWidget *view = new QWidget( wrapperBox );
109 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 117 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
110 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 118 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
111 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 119 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
112 120
113 folderView = new AccountView( split ); 121 folderView = new AccountView( split );
114 folderView->header()->hide(); 122 folderView->header()->hide();
115 folderView->setRootIsDecorated( false ); 123 folderView->setRootIsDecorated( false );
116 folderView->addColumn( i18n( "Mailbox" ) ); 124 folderView->addColumn( i18n( "Mailbox" ) );
117 125
118 //layout->addWidget( folderView ); 126 //layout->addWidget( folderView );
119 127
120 mailView = new QListView( split ); 128 mailView = new QListView( split );
121 mailView->addColumn( i18n( " " ) ); 129 mailView->addColumn( i18n( " " ) );
122 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 130 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
123 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 131 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
124 mailView->addColumn( i18n( "Size" ),QListView::Manual); 132 mailView->addColumn( i18n( "Size" ),QListView::Manual);
125 mailView->addColumn( i18n( "Date" ),QListView::Manual); 133 mailView->addColumn( i18n( "Date" ),QListView::Manual);
126 mailView->setAllColumnsShowFocus(true); 134 mailView->setAllColumnsShowFocus(true);
@@ -162,57 +170,90 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
162 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 170 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
163 mailView->setShowSortIndicator ( true ); 171 mailView->setShowSortIndicator ( true );
164 QLabel *spacer = new QLabel( toolBar ); 172 QLabel *spacer = new QLabel( toolBar );
165 spacer->setBackgroundMode( QWidget::PaletteButton ); 173 spacer->setBackgroundMode( QWidget::PaletteButton );
166 toolBar->setStretchableWidget( spacer ); 174 toolBar->setStretchableWidget( spacer );
167 175
168 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 176 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
169 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 177 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
170 if ( QApplication::desktop()->width() > 320 ) 178 if ( QApplication::desktop()->width() > 320 )
171 closeMail->addTo(toolBar); 179 closeMail->addTo(toolBar);
172 closeMail->addTo(mailMenu); 180 closeMail->addTo(mailMenu);
173 181
174 182
175 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 183 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
176 menuBar->insertItem( i18n( "Help" ), helpMenu ); 184 menuBar->insertItem( i18n( "Help" ), helpMenu );
177 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 185 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
178 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 186 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
179 li->addTo(helpMenu); 187 li->addTo(helpMenu);
180 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 188 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
181 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 189 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
182 li->addTo(helpMenu); 190 li->addTo(helpMenu);
183 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 191 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
184 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 192 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
185 li->addTo(helpMenu); 193 li->addTo(helpMenu);
194 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) );
195 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
186#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
187 resize ( 640, 480 ); 197 resize ( 640, 480 );
188#endif 198#endif
189} 199}
190 200
191MainWindow::~MainWindow() 201MainWindow::~MainWindow()
192{ 202{
193} 203}
194 204
205void MainWindow::slotSetCodec( int codec )
206{
207 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false );
208 //qDebug("codec %d ", codec);
209 KOPrefs::instance()->mCurrentCodec = codec;
210 KOPrefs::instance()->isDirty = true;
211 QString name;
212 switch ( codec ) {
213 case 0:
214 name = "iso-8859-1";
215 break;
216 case 1:
217 name = "iso-8859-5";
218 break;
219 case 2:
220 name = "iso-8859-15";
221 break;
222 case 3:
223 name = "big-5";
224 break;
225 case 4:
226 name = "utf-8";
227 break;
228 case 5:
229 name = KOPrefs::instance()->mSendCodec.lower();
230 break;
231 }
232 KOPrefs::instance()->mCurrentCodeName = name ;
233 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")");
234 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true );
235}
195void MainWindow::showLicence() 236void MainWindow::showLicence()
196{ 237{
197 KApplication::showLicence(); 238 KApplication::showLicence();
198} 239}
199void MainWindow::showAbout() 240void MainWindow::showAbout()
200{ 241{
201 QString version; 242 QString version;
202#include <../version> 243#include <../version>
203 244
204 QString cap = "About KOpieMail/Pi"; 245 QString cap = "About KOpieMail/Pi";
205 QString text =i18n("KOpieMail/Platform-independent\n") + 246 QString text =i18n("KOpieMail/Platform-independent\n") +
206 "(OM/Pi) " + version + " - " 247 "(OM/Pi) " + version + " - "
207 248
208#ifdef DESKTOP_VERSION 249#ifdef DESKTOP_VERSION
209 "Desktop Edition\n" 250 "Desktop Edition\n"
210#else 251#else
211 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 252 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
212#endif 253#endif
213 "www.pi-sync.net\n\n" 254 "www.pi-sync.net\n\n"
214 255
215 256
216 257
217"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 258"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
218 "KOpieMail/Pi is based on Opie Mail\n" 259 "KOpieMail/Pi is based on Opie Mail\n"
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h
index f5ab69b..d0a5caf 100644
--- a/kmicromail/mainwindow.h
+++ b/kmicromail/mainwindow.h
@@ -24,45 +24,46 @@
24class RecMail; 24class RecMail;
25 25
26class MainWindow : public QMainWindow 26class MainWindow : public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 31 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
32 virtual ~MainWindow(); 32 virtual ~MainWindow();
33 33
34public slots: 34public slots:
35 virtual void slotAdjustColumns(); 35 virtual void slotAdjustColumns();
36 virtual void appMessage(const QCString &msg, const QByteArray &data); 36 virtual void appMessage(const QCString &msg, const QByteArray &data);
37 virtual void slotComposeMail(); 37 virtual void slotComposeMail();
38 38
39protected slots: 39protected slots:
40 virtual void slotSendQueued(); 40 virtual void slotSendQueued();
41 virtual void slotEditAccounts(); 41 virtual void slotEditAccounts();
42 virtual void slotShowFolders( bool show ); 42 virtual void slotShowFolders( bool show );
43 virtual void refreshMailView(const QValueList<RecMailP>&); 43 virtual void refreshMailView(const QValueList<RecMailP>&);
44 virtual void displayMail(); 44 virtual void displayMail();
45 virtual void slotGetMail() = 0; 45 virtual void slotGetMail() = 0;
46 virtual void slotGetAllMail() = 0; 46 virtual void slotGetAllMail() = 0;
47 virtual void slotDeleteMail(); 47 virtual void slotDeleteMail();
48 virtual void slotSetCodec(int);
48 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 49 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
49 virtual void slotAdjustLayout(); 50 virtual void slotAdjustLayout();
50 virtual void slotEditSettings(); 51 virtual void slotEditSettings();
51 virtual void mailLeftClicked( QListViewItem * ); 52 virtual void mailLeftClicked( QListViewItem * );
52 void showLicence(); 53 void showLicence();
53 void showAbout(); 54 void showAbout();
54 void showEtpanLicence(); 55 void showEtpanLicence();
55 56
56protected: 57protected:
57 QToolBar *toolBar; 58 QToolBar *toolBar;
58 StatusWidget *statusWidget; 59 StatusWidget *statusWidget;
59 QPEMenuBar *menuBar; 60 QPEMenuBar *menuBar;
60 QPopupMenu *mailMenu, *settingsMenu; 61 QPopupMenu *mailMenu, *settingsMenu, *codecMenu;
61 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 62 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
62 *editSettings, *editAccounts, *syncFolders; 63 *editSettings, *editAccounts, *syncFolders;
63 AccountView *folderView; 64 AccountView *folderView;
64 QListView *mailView; 65 QListView *mailView;
65 //QBoxLayout *layout; 66 //QBoxLayout *layout;
66}; 67};
67 68
68#endif 69#endif
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index af5376f..18a5600 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -12,48 +12,49 @@
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27 27
28#ifdef DESKTOP_VERSION 28#ifdef DESKTOP_VERSION
29#include <qapplication.h> 29#include <qapplication.h>
30#else 30#else
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#endif 32#endif
33#include <libmailwrapper/smtpwrapper.h> 33#include <libmailwrapper/smtpwrapper.h>
34#include <libmailwrapper/mailtypes.h> 34#include <libmailwrapper/mailtypes.h>
35#include <libmailwrapper/abstractmail.h> 35#include <libmailwrapper/abstractmail.h>
36#include "koprefs.h"
36 37
37//using namespace Opie::Core; 38//using namespace Opie::Core;
38 39
39OpieMail::OpieMail( QWidget *parent, const char *name ) 40OpieMail::OpieMail( QWidget *parent, const char *name )
40 : MainWindow( parent, name) //, WStyle_ContextHelp ) 41 : MainWindow( parent, name) //, WStyle_ContextHelp )
41{ 42{
42 settings = new Settings(); 43 settings = new Settings();
43 44
44 setIcon(SmallIcon( "kmicromail" ) ); 45 setIcon(SmallIcon( "kmicromail" ) );
45 folderView->populate( settings->getAccounts() ); 46 folderView->populate( settings->getAccounts() );
46 47
47} 48}
48 49
49OpieMail::~OpieMail() 50OpieMail::~OpieMail()
50{ 51{
51 if (settings) delete settings; 52 if (settings) delete settings;
52} 53}
53 54
54void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 55void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
55{ 56{
56 57
57} 58}
58#include <stdlib.h> 59#include <stdlib.h>
59void OpieMail::message(const QCString &msg, const QByteArray &data) 60void OpieMail::message(const QCString &msg, const QByteArray &data)
@@ -216,100 +217,101 @@ void OpieMail::slotSendQueued()
216 SMTPwrapper * wrap = new SMTPwrapper(smtp); 217 SMTPwrapper * wrap = new SMTPwrapper(smtp);
217 if ( wrap->flushOutbox() ) 218 if ( wrap->flushOutbox() )
218 { 219 {
219 Global::statusMessage("Mails sent!"); 220 Global::statusMessage("Mails sent!");
220 } 221 }
221 delete wrap; 222 delete wrap;
222 } 223 }
223 // pending refresh list view, if outgoing is displayed 224 // pending refresh list view, if outgoing is displayed
224} 225}
225 226
226void OpieMail::slotSearchMails() 227void OpieMail::slotSearchMails()
227{ 228{
228 qDebug("OpieMail::slotSearchMails():not implemented "); 229 qDebug("OpieMail::slotSearchMails():not implemented ");
229} 230}
230 231
231void OpieMail::slotEditSettings() 232void OpieMail::slotEditSettings()
232{ 233{
233 234
234 KOPrefsDialog settingsDialog( this, "koprefs", true ); 235 KOPrefsDialog settingsDialog( this, "koprefs", true );
235#ifndef DESKTOP_VERSION 236#ifndef DESKTOP_VERSION
236 settingsDialog.showMaximized(); 237 settingsDialog.showMaximized();
237#endif 238#endif
238 settingsDialog.exec(); 239 settingsDialog.exec();
239 240
241 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
240 // KApplication::execDialog(settingsDialog); 242 // KApplication::execDialog(settingsDialog);
241} 243}
242 244
243void OpieMail::slotEditAccounts() 245void OpieMail::slotEditAccounts()
244{ 246{
245 EditAccounts eaDialog( settings, this, 0, true ); 247 EditAccounts eaDialog( settings, this, 0, true );
246 eaDialog.slotAdjustColumns(); 248 eaDialog.slotAdjustColumns();
247#ifndef DESKTOP_VERSION 249#ifndef DESKTOP_VERSION
248 eaDialog.showMaximized(); 250 eaDialog.showMaximized();
249#endif 251#endif
250 eaDialog.exec(); 252 eaDialog.exec();
251 if ( settings ) delete settings; 253 if ( settings ) delete settings;
252 settings = new Settings(); 254 settings = new Settings();
253 255
254 folderView->populate( settings->getAccounts() ); 256 folderView->populate( settings->getAccounts() );
255} 257}
256void OpieMail::replyMail() 258void OpieMail::replyMail()
257{ 259{
258 260
259 QListViewItem*item = mailView->currentItem(); 261 QListViewItem*item = mailView->currentItem();
260 if (!item) return; 262 if (!item) return;
261 RecMailP mail = ((MailListViewItem*)item)->data(); 263 RecMailP mail = ((MailListViewItem*)item)->data();
262 RecBodyP body = folderView->fetchBody(mail); 264 RecBodyP body = folderView->fetchBody(mail);
263 265
264 QString rtext; 266 QString rtext;
265 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 267 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
266 .arg( QString::fromUtf8( mail->getFrom().latin1())) 268 .arg( mail->getFrom())
267 .arg( QString::fromUtf8( mail->getDate().latin1() )); 269 .arg( mail->getDate());
268 270
269 QString text = QString::fromUtf8( body->Bodytext().latin1() ); 271 QString text = body->Bodytext();
270 QStringList lines = QStringList::split(QRegExp("\\n"), text); 272 QStringList lines = QStringList::split(QRegExp("\\n"), text);
271 QStringList::Iterator it; 273 QStringList::Iterator it;
272 for (it = lines.begin(); it != lines.end(); it++) 274 for (it = lines.begin(); it != lines.end(); it++)
273 { 275 {
274 rtext += "> " + *it + "\n"; 276 rtext += "> " + *it + "\n";
275 } 277 }
276 rtext += "\n"; 278 rtext += "\n";
277 279
278 QString prefix; 280 QString prefix;
279 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 281 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
280 else prefix = "Re: "; // no i18n on purpose 282 else prefix = "Re: "; // no i18n on purpose
281 283
282 Settings *settings = new Settings(); 284 Settings *settings = new Settings();
283 ComposeMail composer( settings ,this, 0, true); 285 ComposeMail composer( settings ,this, 0, true);
284 if (mail->Replyto().isEmpty()) { 286 if (mail->Replyto().isEmpty()) {
285 composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); 287 composer.setTo( mail->getFrom());
286 } else { 288 } else {
287 composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); 289 composer.setTo( mail->Replyto());
288 } 290 }
289 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); 291 composer.setSubject( prefix + mail->getSubject());
290 composer.setMessage( rtext ); 292 composer.setMessage( rtext );
291 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); 293 composer.setInReplyTo( mail->Msgid());
292 294
293 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 295 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
294 { 296 {
295 mail->Wrapper()->answeredMail(mail); 297 mail->Wrapper()->answeredMail(mail);
296 } 298 }
297 delete settings; 299 delete settings;
298 300
299} 301}
300void OpieMail::displayMail() 302void OpieMail::displayMail()
301{ 303{
302 QListViewItem*item = mailView->currentItem(); 304 QListViewItem*item = mailView->currentItem();
303 if (!item) return; 305 if (!item) return;
304 RecMailP mail = ((MailListViewItem*)item)->data(); 306 RecMailP mail = ((MailListViewItem*)item)->data();
305 RecBodyP body = folderView->fetchBody(mail); 307 RecBodyP body = folderView->fetchBody(mail);
306 ViewMail readMail( this,"", Qt::WType_Modal ); 308 ViewMail readMail( this,"", Qt::WType_Modal );
307 readMail.setBody( body ); 309 readMail.setBody( body );
308 readMail.setMail( mail ); 310 readMail.setMail( mail );
309#ifndef DESKTOP_VERSION 311#ifndef DESKTOP_VERSION
310 readMail.showMaximized(); 312 readMail.showMaximized();
311#else 313#else
312 readMail.resize( 640, 480); 314 readMail.resize( 640, 480);
313#endif 315#endif
314 readMail.exec(); 316 readMail.exec();
315 317
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 2093678..4883231 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -77,49 +77,49 @@ AttachItem* ViewMail::searchParent(const QValueList<int>&path)
77 { 77 {
78 AttachItem*ati = (AttachItem*)it.current(); 78 AttachItem*ati = (AttachItem*)it.current();
79 if (ati->isParentof(path)) return ati; 79 if (ati->isParentof(path)) return ati;
80 } 80 }
81 return 0; 81 return 0;
82} 82}
83 83
84AttachItem* ViewMail::lastChild(AttachItem*parent) 84AttachItem* ViewMail::lastChild(AttachItem*parent)
85{ 85{
86 if (!parent) return 0; 86 if (!parent) return 0;
87 AttachItem* item = (AttachItem*)parent->firstChild(); 87 AttachItem* item = (AttachItem*)parent->firstChild();
88 if (!item) return item; 88 if (!item) return item;
89 AttachItem*temp=0; 89 AttachItem*temp=0;
90 while( (temp=(AttachItem*)item->nextSibling())) 90 while( (temp=(AttachItem*)item->nextSibling()))
91 { 91 {
92 item = temp; 92 item = temp;
93 } 93 }
94 return item; 94 return item;
95} 95}
96 96
97void ViewMail::setBody(const RecBodyP&body ) 97void ViewMail::setBody(const RecBodyP&body )
98{ 98{
99 99
100 m_body = body; 100 m_body = body;
101 m_mail[2] = QString::fromUtf8( body->Bodytext().latin1() ); 101 m_mail[2] = body->Bodytext();
102 // qDebug("********text %s ",m_mail[2].latin1() ); 102 // qDebug("********text %s ",m_mail[2].latin1() );
103 attachbutton->setEnabled(body->Parts().count()>0); 103 attachbutton->setEnabled(body->Parts().count()>0);
104 attachments->setEnabled(body->Parts().count()>0); 104 attachments->setEnabled(body->Parts().count()>0);
105 if (body->Parts().count()==0) 105 if (body->Parts().count()==0)
106 { 106 {
107 return; 107 return;
108 } 108 }
109 AttachItem * curItem=0; 109 AttachItem * curItem=0;
110 AttachItem * parentItem = 0; 110 AttachItem * parentItem = 0;
111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
112 QString desc,fsize; 112 QString desc,fsize;
113 double s = body->Description()->Size(); 113 double s = body->Description()->Size();
114 int w; 114 int w;
115 w=0; 115 w=0;
116 116
117 while (s>1024) 117 while (s>1024)
118 { 118 {
119 s/=1024; 119 s/=1024;
120 ++w; 120 ++w;
121 if (w>=2) break; 121 if (w>=2) break;
122 } 122 }
123 123
124 QString q=""; 124 QString q="";
125 switch(w) 125 switch(w)
@@ -280,100 +280,100 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
280 break; 280 break;
281 case 1: 281 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 283 {
284 setText(); 284 setText();
285 } 285 }
286 else 286 else
287 { 287 {
288 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 289 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
291 } 291 }
292 } 292 }
293 break; 293 break;
294 } 294 }
295 delete menu; 295 delete menu;
296} 296}
297 297
298 298
299void ViewMail::setMail(const RecMailP&mail ) 299void ViewMail::setMail(const RecMailP&mail )
300{ 300{
301 301
302 m_recMail = mail; 302 m_recMail = mail;
303 303
304 m_mail[0] = QString::fromUtf8( mail->getFrom().latin1() ); 304 m_mail[0] = mail->getFrom();
305 m_mail[1] = QString::fromUtf8( mail->getSubject().latin1() ); 305 m_mail[1] = mail->getSubject();
306 m_mail[3] = QString::fromUtf8( mail->getDate().latin1() ); 306 m_mail[3] = mail->getDate();
307 m_mail[4] = QString::fromUtf8( mail->Msgid().latin1() ); 307 m_mail[4] = mail->Msgid();
308 308
309 m_mail2[0] = mail->To(); 309 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 310 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 311 m_mail2[2] = mail->Bcc();
312 312
313 setText(); 313 setText();
314} 314}
315 315
316 316
317 317
318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
319 : ViewMailBase(parent, name, fl), _inLoop(false) 319 : ViewMailBase(parent, name, fl), _inLoop(false)
320{ 320{
321 m_gotBody = false; 321 m_gotBody = false;
322 deleted = false; 322 deleted = false;
323 323
324 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 324 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
325 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 325 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
329 329
330 attachments->setEnabled(m_gotBody); 330 attachments->setEnabled(m_gotBody);
331 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 331 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
332 332
333 readConfig(); 333 readConfig();
334 attachments->setSorting(-1); 334 attachments->setSorting(-1);
335} 335}
336 336
337void ViewMail::readConfig() 337void ViewMail::readConfig()
338{ 338{
339 339
340 setFont ( KOPrefs::instance()->mReadFont ); 340 setFont ( KOPrefs::instance()->mReadFont );
341 m_showHtml = KOPrefs::instance()->mViewAsHtml; 341 m_showHtml = KOPrefs::instance()->mViewAsHtml;
342 showHtml->setOn( m_showHtml ); 342 showHtml->setOn( m_showHtml );
343} 343}
344 344
345void ViewMail::setText() 345void ViewMail::setText()
346{ 346{
347 347
348 QString toString; 348 QString toString;
349 QString ccString; 349 QString ccString;
350 QString bccString; 350 QString bccString;
351 351
352 352
353 toString = QString::fromUtf8(m_mail2[0].join(",").latin1()); 353 toString = m_mail2[0].join(",");
354 ccString = QString::fromUtf8(m_mail2[1].join(",").latin1()); 354 ccString = m_mail2[1].join(",");
355 bccString = QString::fromUtf8(m_mail2[2].join(",").latin1()); 355 bccString = m_mail2[2].join(",");
356 356
357 357
358 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 358 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
359 359
360 m_mailHtml = "<html><body>" 360 m_mailHtml = "<html><body>"
361 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 361 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
362 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 362 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
363 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 363 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
364 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 364 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
365 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 365 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
366 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 366 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
367 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 367 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
368 "</td></tr></table><font>"; 368 "</td></tr></table><font>";
369 369
370 if ( !m_showHtml ) 370 if ( !m_showHtml )
371 { 371 {
372 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 372 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
373 } 373 }
374 else 374 else
375 { 375 {
376 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 376 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
377 } 377 }
378 // remove later in favor of a real handling 378 // remove later in favor of a real handling
379 m_gotBody = true; 379 m_gotBody = true;
@@ -429,51 +429,51 @@ void ViewMail::slotReply()
429 return; 429 return;
430 } 430 }
431 431
432 QString rtext; 432 QString rtext;
433 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 433 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
434 .arg( m_mail[0] ) 434 .arg( m_mail[0] )
435 .arg( m_mail[3] ); 435 .arg( m_mail[3] );
436 436
437 QString text = m_mail[2]; 437 QString text = m_mail[2];
438 QStringList lines = QStringList::split(QRegExp("\\n"), text); 438 QStringList lines = QStringList::split(QRegExp("\\n"), text);
439 QStringList::Iterator it; 439 QStringList::Iterator it;
440 for (it = lines.begin(); it != lines.end(); it++) 440 for (it = lines.begin(); it != lines.end(); it++)
441 { 441 {
442 rtext += "> " + *it + "\n"; 442 rtext += "> " + *it + "\n";
443 } 443 }
444 rtext += "\n"; 444 rtext += "\n";
445 445
446 QString prefix; 446 QString prefix;
447 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 447 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
448 else prefix = "Re: "; // no i18n on purpose 448 else prefix = "Re: "; // no i18n on purpose
449 449
450 Settings *settings = new Settings(); 450 Settings *settings = new Settings();
451 ComposeMail composer( settings ,this, 0, true); 451 ComposeMail composer( settings ,this, 0, true);
452 if (m_recMail->Replyto().isEmpty()) { 452 if (m_recMail->Replyto().isEmpty()) {
453 composer.setTo( QString::fromUtf8( m_recMail->getFrom().latin1())); 453 composer.setTo(m_recMail->getFrom());
454 } else { 454 } else {
455 composer.setTo( QString::fromUtf8( m_recMail->Replyto().latin1())); 455 composer.setTo(m_recMail->Replyto());
456 } 456 }
457 composer.setSubject( prefix + m_mail[1] ); 457 composer.setSubject( prefix + m_mail[1] );
458 composer.setMessage( rtext ); 458 composer.setMessage( rtext );
459 composer.setInReplyTo(m_recMail->Msgid()); 459 composer.setInReplyTo(m_recMail->Msgid());
460 460
461 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 461 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
462 { 462 {
463 m_recMail->Wrapper()->answeredMail(m_recMail); 463 m_recMail->Wrapper()->answeredMail(m_recMail);
464 } 464 }
465 delete settings; 465 delete settings;
466} 466}
467 467
468void ViewMail::slotForward() 468void ViewMail::slotForward()
469{ 469{
470 if (!m_gotBody) 470 if (!m_gotBody)
471 { 471 {
472 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); 472 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok"));
473 return; 473 return;
474 } 474 }
475 475
476 QString ftext; 476 QString ftext;
477 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 477 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
478 .arg( m_mail[0] ); 478 .arg( m_mail[0] );
479 if (!m_mail[3].isNull()) 479 if (!m_mail[3].isNull())