summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-31 12:28:03 (UTC)
committer zautrix <zautrix>2004-10-31 12:28:03 (UTC)
commitbed831cc1a38d38a4c5b9329bf37b1c663142c23 (patch) (unidiff)
treedb12b81ea6cee0cac347c801798d759dfe24acfb
parent553bd9acf9879a77c5fa925155f73afbe8a9af41 (diff)
downloadkdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.zip
kdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.tar.gz
kdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.tar.bz2
ompi utf8 fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kdepim-desktop.pro6
-rw-r--r--kmicromail/composemail.cpp52
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp1
-rw-r--r--kmicromail/libmailwrapper/settings.cpp1
-rw-r--r--kmicromail/libmailwrapper/settings.h1
-rw-r--r--kmicromail/mailistviewitem.cpp4
-rw-r--r--kmicromail/mainwindow.cpp6
-rw-r--r--kmicromail/opiemail.cpp46
-rw-r--r--kmicromail/opiemail.h1
-rw-r--r--kmicromail/qpe/global.cpp6
-rw-r--r--kmicromail/qpe/qdialog.h4
-rw-r--r--kmicromail/qpe/qdialog_hacked.cpp6
-rw-r--r--kmicromail/viewmail.cpp35
13 files changed, 107 insertions, 62 deletions
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro
index 6d04a45..b0d60b7 100644
--- a/kdepim-desktop.pro
+++ b/kdepim-desktop.pro
@@ -1,6 +1,8 @@
1 1
2 2
3TEMPLATE = subdirs 3TEMPLATE = subdirs
4SUBDIRS = libical libkcal kabc libkdepim microkde kmicromail/libetpan kmicromail/libmailwrapper kmicromail korganizer kaddressbook kabc/plugins/file kabc/plugins/dir kabc/plugins/file kabc/plugins/qtopia gammu/emb/common gammu/emb/gammu pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib pwmanager/pwmanager 4SUBDIRS = libical libkcal kabc libkdepim microkde korganizer kaddressbook kabc/plugins/file kabc/plugins/dir kabc/plugins/file kabc/plugins/qtopia gammu/emb/common gammu/emb/gammu
5#kalarmd 5unix:{
6SUBDIRS += kmicromail/libetpan kmicromail/libmailwrapper kmicromail pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib pwmanager/pwmanager
7}
6 8
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 5945b7f..2dcbc75 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,503 +1,503 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3#include <kabc/addresseedialog.h> 3#include <kabc/addresseedialog.h>
4#include <kabc/stdaddressbook.h> 4#include <kabc/stdaddressbook.h>
5#include <kabc/addressee.h> 5#include <kabc/addressee.h>
6#ifdef DESKTOP_VERSION 6#ifdef DESKTOP_VERSION
7#include <qapplication.h> 7#include <qapplication.h>
8#include <kabc/addresseedialog.h> 8#include <kabc/addresseedialog.h>
9#endif //DESKTOP_VERSION 9#endif //DESKTOP_VERSION
10#include <libkdepim/externalapphandler.h> 10#include <libkdepim/externalapphandler.h>
11 11
12#include "koprefs.h" 12#include "koprefs.h"
13 13
14#ifdef MINIKDE_KDIALOG_H 14#ifdef MINIKDE_KDIALOG_H
15#undef MINIKDE_KDIALOG_H 15#undef MINIKDE_KDIALOG_H
16#endif 16#endif
17 17
18 18
19#include "composemail.h" 19#include "composemail.h"
20 20
21#include <libmailwrapper/smtpwrapper.h> 21#include <libmailwrapper/smtpwrapper.h>
22#include <libmailwrapper/storemail.h> 22#include <libmailwrapper/storemail.h>
23#include <libmailwrapper/abstractmail.h> 23#include <libmailwrapper/abstractmail.h>
24#include <libmailwrapper/mailtypes.h> 24#include <libmailwrapper/mailtypes.h>
25 25
26/* OPIE */ 26/* OPIE */
27//#include <opie2/ofiledialog.h> 27//#include <opie2/ofiledialog.h>
28//#include <opie2/odebug.h> 28//#include <opie2/odebug.h>
29#include <kfiledialog.h> 29#include <kfiledialog.h>
30//#include <qpe/resource.h> 30//#include <qpe/resource.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32//#include <qpe/contact.h> 32//#include <qpe/contact.h>
33 33
34 34
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qtimer.h> 38#include <qtimer.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qtabwidget.h> 43#include <qtabwidget.h>
44#include <qlistview.h> 44#include <qlistview.h>
45 45
46//using namespace Opie::Core; 46//using namespace Opie::Core;
47//using namespace Opie::Ui; 47//using namespace Opie::Ui;
48ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 48ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal )
49 : ComposeMailUI( parent, name, modal ) 49 : ComposeMailUI( parent, name, modal )
50{ 50{
51 mPickLineEdit = 0; 51 mPickLineEdit = 0;
52 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 52 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
53 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 53 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
54 settings = s; 54 settings = sett;
55 m_replyid = ""; 55 m_replyid = "";
56 if ( KOPrefs::instance()->mUseKapi) { 56 if ( KOPrefs::instance()->mUseKapi) {
57 KConfig config( locateLocal("config", "kabcrc") ); 57 KConfig config( locateLocal("config", "kabcrc") );
58 config.setGroup( "General" ); 58 config.setGroup( "General" );
59 QString whoami_uid = config.readEntry( "WhoAmI" ); 59 QString whoami_uid = config.readEntry( "WhoAmI" );
60 60
61 if ( whoami_uid.isEmpty() ) { 61 if ( whoami_uid.isEmpty() ) {
62 QMessageBox::information( 0, i18n( "Hint" ), 62 QMessageBox::information( 0, i18n( "Hint" ),
63 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 63 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
64 i18n( "Ok" ) ); 64 i18n( "Ok" ) );
65 65
66 66
67 fillSettings(); 67 fillSettings();
68 } else 68 } else
69 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 69 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
70 70
71 71
72#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
73 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 73 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
74 QStringList mails = con.emails(); 74 QStringList mails = con.emails();
75 QString defmail = con.preferredEmail(); 75 QString defmail = con.preferredEmail();
76 if ( mails.count() == 0) 76 if ( mails.count() == 0)
77 QMessageBox::information( 0, i18n( "Hint" ), 77 QMessageBox::information( 0, i18n( "Hint" ),
78 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 78 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
79 i18n( "Ok" ) ); 79 i18n( "Ok" ) );
80 if (defmail.length()!=0) { 80 if (defmail.length()!=0) {
81 fromBox->insertItem(defmail); 81 fromBox->insertItem(defmail);
82 } 82 }
83 QStringList::ConstIterator sit = mails.begin(); 83 QStringList::ConstIterator sit = mails.begin();
84 for (;sit!=mails.end();++sit) { 84 for (;sit!=mails.end();++sit) {
85 if ( (*sit)==defmail) 85 if ( (*sit)==defmail)
86 continue; 86 continue;
87 fromBox->insertItem((*sit)); 87 fromBox->insertItem((*sit));
88 } 88 }
89 senderNameEdit->setText(con.formattedName()); 89 senderNameEdit->setText(con.formattedName());
90#endif 90#endif
91 91
92 } else { 92 } else {
93 fillSettings(); 93 fillSettings();
94 } 94 }
95 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 95 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
96 96
97 attList->addColumn( i18n( "Name" ) ); 97 attList->addColumn( i18n( "Name" ) );
98 attList->addColumn( i18n( "Size" ) ); 98 attList->addColumn( i18n( "Size" ) );
99 QList<Account> accounts = settings->getAccounts(); 99 QList<Account> accounts = settings->getAccounts();
100 100
101 if ( QApplication::desktop()->width() < 320 ) 101 if ( QApplication::desktop()->width() < 320 )
102 smtpAccountBox->setMaximumWidth( 80 ); 102 smtpAccountBox->setMaximumWidth( 80 );
103 Account *it; 103 Account *it;
104 for ( it = accounts.first(); it; it = accounts.next() ) { 104 for ( it = accounts.first(); it; it = accounts.next() ) {
105 if ( it->getType()==MAILLIB::A_SMTP ) { 105 if ( it->getType()==MAILLIB::A_SMTP ) {
106 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 106 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
107 smtpAccountBox->insertItem( smtp->getAccountName() ); 107 smtpAccountBox->insertItem( smtp->getAccountName() );
108 smtpAccounts.append( smtp ); 108 smtpAccounts.append( smtp );
109 } 109 }
110 } 110 }
111 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 111 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
112 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 112 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
113 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 113 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
114 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 114 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
115 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 115 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
116 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 116 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
117 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 117 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
118 mMail = 0; 118 mMail = 0;
119 warnAttach = true; 119 warnAttach = true;
120 QIconSet icon; 120 QIconSet icon;
121 //icon = SmallIcon("fileexport"); 121 //icon = SmallIcon("fileexport");
122 icon = SmallIcon("filesave"); 122 icon = SmallIcon("filesave");
123 SaveButton->setIconSet (icon ) ; 123 SaveButton->setIconSet (icon ) ;
124 if ( QApplication::desktop()->width() < 320 ) { 124 if ( QApplication::desktop()->width() < 320 ) {
125 SaveButton->setText ("") ; 125 SaveButton->setText ("") ;
126 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; 126 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
127 } 127 }
128 else 128 else
129 SaveButton->setText (i18n("Save")); 129 SaveButton->setText (i18n("Save"));
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 131 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
132 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 132 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
133 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 133 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
134#endif 134#endif
135 message->setFont ( KOPrefs::instance()->mComposeFont ); 135 message->setFont ( KOPrefs::instance()->mComposeFont );
136 message->setWordWrap (QMultiLineEdit::WidgetWidth); 136 message->setWordWrap (QMultiLineEdit::WidgetWidth);
137 if ( smtpAccounts.count() > 0 ) { 137 if ( smtpAccounts.count() > 0 ) {
138 fillValues( smtpAccountBox->currentItem() ); 138 fillValues( smtpAccountBox->currentItem() );
139 } else { 139 } else {
140 QMessageBox::information( 0, i18n( "Problem" ), 140 QMessageBox::information( 0, i18n( "Problem" ),
141 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 141 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
142 i18n( "Ok" ) ); 142 i18n( "Ok" ) );
143 return; 143 return;
144 } 144 }
145 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 145 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
146 146
147 147
148} 148}
149 149
150void ComposeMail::fillSettings() 150void ComposeMail::fillSettings()
151{ 151{
152 if ( QApplication::desktop()->width() < 320 ) 152 if ( QApplication::desktop()->width() < 320 )
153 fromBox->setMaximumWidth( 100 ); 153 fromBox->setMaximumWidth( 100 );
154 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 154 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
155 QStringList::ConstIterator sit = mailList.begin(); 155 QStringList::ConstIterator sit = mailList.begin();
156 int pref = 0; 156 int pref = 0;
157 for (;sit!=mailList.end();++sit) { 157 for (;sit!=mailList.end();++sit) {
158 fromBox->insertItem((*sit)); 158 fromBox->insertItem((*sit));
159 } 159 }
160 senderNameEdit->setText(KOPrefs::instance()->mName); 160 senderNameEdit->setText(KOPrefs::instance()->mName);
161} 161}
162 162
163 163
164void ComposeMail::saveAsDraft() 164void ComposeMail::saveAsDraft()
165{ 165{
166 166
167 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 167 Opie::Core::OSmartPointer<Mail> mail= new Mail();
168 mail->setMail(fromBox->currentText()); 168 mail->setMail(fromBox->currentText().utf8 ());
169 mail->setTo( toLine->text() ); 169 mail->setTo( toLine->text().utf8 () );
170 mail->setName(senderNameEdit->text()); 170 mail->setName(senderNameEdit->text().utf8 ());
171 mail->setCC( ccLine->text() ); 171 mail->setCC( ccLine->text().utf8 () );
172 mail->setBCC( bccLine->text() ); 172 mail->setBCC( bccLine->text().utf8 () );
173 mail->setReply( replyLine->text() ); 173 mail->setReply( replyLine->text().utf8 () );
174 mail->setSubject( subjectLine->text() ); 174 mail->setSubject( subjectLine->text().utf8 () );
175 if (!m_replyid.isEmpty()) { 175 if (!m_replyid.isEmpty()) {
176 QStringList ids; 176 QStringList ids;
177 ids.append(m_replyid); 177 ids.append(m_replyid);
178 mail->setInreply(ids); 178 mail->setInreply(ids);
179 } 179 }
180 QString txt = message->text(); 180 QString txt = message->text().utf8 ();
181 if ( !sigMultiLine->text().isEmpty() ) { 181 if ( !sigMultiLine->text().isEmpty() ) {
182 txt.append( "\n--\n" ); 182 txt.append( "\n--\n" );
183 txt.append( sigMultiLine->text() ); 183 txt.append( sigMultiLine->text() );
184 } 184 }
185 mail->setMessage( txt ); 185 mail->setMessage( txt );
186 186
187 /* only use the default drafts folder name! */ 187 /* only use the default drafts folder name! */
188 Storemail wrapper(AbstractMail::draftFolder()); 188 Storemail wrapper(AbstractMail::draftFolder());
189 wrapper.storeMail(mail); 189 wrapper.storeMail(mail);
190 190
191 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 191 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
192 /* attachments we will ignore! */ 192 /* attachments we will ignore! */
193 if ( it != 0 ) { 193 if ( it != 0 ) {
194 if ( warnAttach ) 194 if ( warnAttach )
195 QMessageBox::warning(0,i18n("Store message"), 195 QMessageBox::warning(0,i18n("Store message"),
196 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 196 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
197 warnAttach = false; 197 warnAttach = false;
198 } 198 }
199 setStatus( i18n("Mail saved as draft!") ); 199 setStatus( i18n("Mail saved as draft!") );
200} 200}
201void ComposeMail::clearStatus() 201void ComposeMail::clearStatus()
202{ 202{
203 topLevelWidget()->setCaption( i18n("Compose mail") ); 203 topLevelWidget()->setCaption( i18n("Compose mail") );
204} 204}
205void ComposeMail::setStatus( QString status ) 205void ComposeMail::setStatus( QString status )
206{ 206{
207 topLevelWidget()->setCaption( status ); 207 topLevelWidget()->setCaption( status );
208 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 208 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
209} 209}
210void ComposeMail::pickAddress( ) 210void ComposeMail::pickAddress( )
211{ 211{
212 212
213 QLineEdit *line = mPickLineEdit; 213 QLineEdit *line = mPickLineEdit;
214 if ( line == 0 ) 214 if ( line == 0 )
215 return; 215 return;
216#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
217 //qDebug(" ComposeMail::pickAddress "); 217 //qDebug(" ComposeMail::pickAddress ");
218 QString names ;//= AddressPicker::getNames(); 218 QString names ;//= AddressPicker::getNames();
219 219
220 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 220 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
221 uint i=0; 221 uint i=0;
222 for (i=0; i < list.count(); i++) { 222 for (i=0; i < list.count(); i++) {
223 if ( !list[i].preferredEmail().isEmpty()) { 223 if ( !list[i].preferredEmail().isEmpty()) {
224 if ( ! names.isEmpty() ) 224 if ( ! names.isEmpty() )
225 names+= ","; 225 names+= ",";
226 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 226 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
227 227
228 } 228 }
229 } 229 }
230 230
231 231
232 if ( line->text().isEmpty() ) { 232 if ( line->text().isEmpty() ) {
233 line->setText( names ); 233 line->setText( names );
234 } else if ( !names.isEmpty() ) { 234 } else if ( !names.isEmpty() ) {
235 line->setText( line->text() + ", " + names ); 235 line->setText( line->text() + ", " + names );
236 } 236 }
237#else 237#else
238 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 238 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
239 // the result should now arrive through method insertAttendees 239 // the result should now arrive through method insertAttendees
240#endif 240#endif
241} 241}
242//the map includes name/email pairs, that comes from Ka/Pi 242//the map includes name/email pairs, that comes from Ka/Pi
243void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 243void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
244{ 244{
245 //qDebug("ComposeMail::insertAttendees "); 245 //qDebug("ComposeMail::insertAttendees ");
246 raise(); 246 raise();
247 247
248 if ( mPickLineEdit == 0 ) { //whoami received 248 if ( mPickLineEdit == 0 ) { //whoami received
249 QString defmail = uidList[0]; 249 QString defmail = uidList[0];
250 if ( emailList.count() == 0 ) 250 if ( emailList.count() == 0 )
251 QMessageBox::information( 0, i18n( "Hint" ), 251 QMessageBox::information( 0, i18n( "Hint" ),
252 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 252 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
253 i18n( "Ok" ) ); 253 i18n( "Ok" ) );
254 if (defmail.length()!=0) { 254 if (defmail.length()!=0) {
255 fromBox->insertItem(defmail); 255 fromBox->insertItem(defmail);
256 } 256 }
257 QStringList::ConstIterator sit = emailList.begin(); 257 QStringList::ConstIterator sit = emailList.begin();
258 int pref = 0; 258 int pref = 0;
259 for (;sit!=emailList.end();++sit) { 259 for (;sit!=emailList.end();++sit) {
260 if ( (*sit)==defmail) 260 if ( (*sit)==defmail)
261 continue; 261 continue;
262 fromBox->insertItem((*sit)); 262 fromBox->insertItem((*sit));
263 } 263 }
264 senderNameEdit->setText(nameList[0]); 264 senderNameEdit->setText(nameList[0]);
265 return; 265 return;
266 } 266 }
267 QString names ; 267 QString names ;
268 QLineEdit *line = mPickLineEdit; 268 QLineEdit *line = mPickLineEdit;
269 if (uid == this->name()) 269 if (uid == this->name())
270 { 270 {
271 for ( int i = 0; i < nameList.count(); i++) 271 for ( int i = 0; i < nameList.count(); i++)
272 { 272 {
273 QString _name = nameList[i]; 273 QString _name = nameList[i];
274 QString _email = emailList[i]; 274 QString _email = emailList[i];
275 QString _uid = uidList[i]; 275 QString _uid = uidList[i];
276 if ( ! _email.isEmpty() ) { 276 if ( ! _email.isEmpty() ) {
277 if ( ! names.isEmpty() ) 277 if ( ! names.isEmpty() )
278 names+= ","; 278 names+= ",";
279 names+= "\""+_name +"\"<" +_email +">"; 279 names+= "\""+_name +"\"<" +_email +">";
280 } 280 }
281 } 281 }
282 } 282 }
283 if ( line->text().isEmpty() ) { 283 if ( line->text().isEmpty() ) {
284 line->setText( names ); 284 line->setText( names );
285 } else if ( !names.isEmpty() ) { 285 } else if ( !names.isEmpty() ) {
286 line->setText( line->text() + ", " + names ); 286 line->setText( line->text() + ", " + names );
287 } 287 }
288} 288}
289 289
290void ComposeMail::setTo( const QString & to ) 290void ComposeMail::setTo( const QString & to )
291{ 291{
292 toLine->setText( to ); 292 toLine->setText( to );
293} 293}
294 294
295void ComposeMail::setSubject( const QString & subject ) 295void ComposeMail::setSubject( const QString & subject )
296{ 296{
297 subjectLine->setText( subject ); 297 subjectLine->setText( subject );
298} 298}
299 299
300void ComposeMail::setInReplyTo( const QString & messageId ) 300void ComposeMail::setInReplyTo( const QString & messageId )
301{ 301{
302 m_replyid = messageId; 302 m_replyid = messageId;
303} 303}
304 304
305void ComposeMail::setMessage( const QString & text ) 305void ComposeMail::setMessage( const QString & text )
306{ 306{
307 message->setText( text ); 307 message->setText( text );
308} 308}
309 309
310 310
311void ComposeMail::pickAddressTo() 311void ComposeMail::pickAddressTo()
312{ 312{
313 mPickLineEdit = toLine; 313 mPickLineEdit = toLine;
314 pickAddress( ); 314 pickAddress( );
315} 315}
316 316
317void ComposeMail::pickAddressCC() 317void ComposeMail::pickAddressCC()
318{ 318{
319 mPickLineEdit = ccLine; 319 mPickLineEdit = ccLine;
320 pickAddress( ); 320 pickAddress( );
321} 321}
322 322
323void ComposeMail::pickAddressBCC() 323void ComposeMail::pickAddressBCC()
324{ 324{
325 mPickLineEdit = bccLine; 325 mPickLineEdit = bccLine;
326 pickAddress( ); 326 pickAddress( );
327} 327}
328 328
329void ComposeMail::pickAddressReply() 329void ComposeMail::pickAddressReply()
330{ 330{
331 mPickLineEdit = replyLine; 331 mPickLineEdit = replyLine;
332 pickAddress( ); 332 pickAddress( );
333} 333}
334 334
335void ComposeMail::fillValues( int ) 335void ComposeMail::fillValues( int )
336{ 336{
337#if 0 337#if 0
338 SMTPaccount *smtp = smtpAccounts.at( current ); 338 SMTPaccount *smtp = smtpAccounts.at( current );
339 ccLine->clear(); 339 ccLine->clear();
340 if ( smtp->getUseCC() ) { 340 if ( smtp->getUseCC() ) {
341 ccLine->setText( smtp->getCC() ); 341 ccLine->setText( smtp->getCC() );
342 } 342 }
343 bccLine->clear(); 343 bccLine->clear();
344 if ( smtp->getUseBCC() ) { 344 if ( smtp->getUseBCC() ) {
345 bccLine->setText( smtp->getBCC() ); 345 bccLine->setText( smtp->getBCC() );
346 } 346 }
347 replyLine->clear(); 347 replyLine->clear();
348 if ( smtp->getUseReply() ) { 348 if ( smtp->getUseReply() ) {
349 replyLine->setText( smtp->getReply() ); 349 replyLine->setText( smtp->getReply() );
350 } 350 }
351 sigMultiLine->setText( smtp->getSignature() ); 351 sigMultiLine->setText( smtp->getSignature() );
352#endif 352#endif
353} 353}
354 354
355void ComposeMail::slotAdjustColumns() 355void ComposeMail::slotAdjustColumns()
356{ 356{
357 int currPage = tabWidget->currentPageIndex(); 357 int currPage = tabWidget->currentPageIndex();
358 358
359 tabWidget->showPage( attachTab ); 359 tabWidget->showPage( attachTab );
360 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 360 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
361 attList->setColumnWidth( 1, 80 ); 361 attList->setColumnWidth( 1, 80 );
362 362
363 tabWidget->setCurrentPage( currPage ); 363 tabWidget->setCurrentPage( currPage );
364} 364}
365 365
366void ComposeMail::addAttachment() 366void ComposeMail::addAttachment()
367{ 367{
368 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 368 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
369 if ( !lnk.isEmpty() ) { 369 if ( !lnk.isEmpty() ) {
370 Attachment *att = new Attachment( lnk ); 370 Attachment *att = new Attachment( lnk );
371 (void) new AttachViewItem( attList, att ); 371 (void) new AttachViewItem( attList, att );
372 } 372 }
373} 373}
374 374
375void ComposeMail::removeAttachment() 375void ComposeMail::removeAttachment()
376{ 376{
377 if ( !attList->currentItem() ) { 377 if ( !attList->currentItem() ) {
378 QMessageBox::information( this, i18n( "Error" ), 378 QMessageBox::information( this, i18n( "Error" ),
379 i18n( "<p>Please select a File.</p>" ), 379 i18n( "<p>Please select a File.</p>" ),
380 i18n( "Ok" ) ); 380 i18n( "Ok" ) );
381 } else { 381 } else {
382 attList->takeItem( attList->currentItem() ); 382 attList->takeItem( attList->currentItem() );
383 } 383 }
384} 384}
385 385
386void ComposeMail::accept() 386void ComposeMail::accept()
387{ 387{
388 if ( smtpAccountBox->count() == 0 ) { 388 if ( smtpAccountBox->count() == 0 ) {
389 389
390 reject(); 390 reject();
391 return; 391 return;
392 } 392 }
393 393
394 if (! checkBoxLater->isChecked() ) { 394 if (! checkBoxLater->isChecked() ) {
395 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 395 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
396 i18n("Send this message?"), 396 i18n("Send this message?"),
397 i18n("Yes"), 397 i18n("Yes"),
398 i18n("Cancel")); 398 i18n("Cancel"));
399 399
400 if (yesno == 1) { 400 if (yesno == 1) {
401 return; 401 return;
402 } 402 }
403 } 403 }
404#if 0 404#if 0
405 odebug << "Sending Mail with " 405 odebug << "Sending Mail with "
406 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 406 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
407#endif 407#endif
408 Opie::Core::OSmartPointer<Mail> mail=new Mail; 408 Opie::Core::OSmartPointer<Mail> mail=new Mail;
409 409
410 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 410 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
411 mail->setMail(fromBox->currentText()); 411 mail->setMail(fromBox->currentText().utf8 ());
412 412
413 if ( !toLine->text().isEmpty() ) { 413 if ( !toLine->text().isEmpty() ) {
414 mail->setTo( toLine->text() ); 414 mail->setTo( toLine->text().utf8 () );
415 } else { 415 } else {
416 QMessageBox::warning(0,i18n("Sending mail"), 416 QMessageBox::warning(0,i18n("Sending mail"),
417 i18n("No Receiver spezified" ) ); 417 i18n("No Receiver spezified" ) );
418 return; 418 return;
419 } 419 }
420 420
421 mail->setName(senderNameEdit->text()); 421 mail->setName(senderNameEdit->text().utf8 ());
422 mail->setCC( ccLine->text() ); 422 mail->setCC( ccLine->text().utf8 () );
423 mail->setBCC( bccLine->text() ); 423 mail->setBCC( bccLine->text().utf8 () );
424 mail->setReply( replyLine->text() ); 424 mail->setReply( replyLine->text().utf8 () );
425 mail->setSubject( subjectLine->text() ); 425 mail->setSubject( subjectLine->text().utf8 () );
426 if (!m_replyid.isEmpty()) { 426 if (!m_replyid.isEmpty()) {
427 QStringList ids; 427 QStringList ids;
428 ids.append(m_replyid); 428 ids.append(m_replyid.utf8 ());
429 mail->setInreply(ids); 429 mail->setInreply(ids);
430 } 430 }
431 QString txt = message->text(); 431 QString txt = message->text().utf8 ();
432 if ( !sigMultiLine->text().isEmpty() ) { 432 if ( !sigMultiLine->text().isEmpty() ) {
433 txt.append( "\n--\n" ); 433 txt.append( "\n--\n" );
434 txt.append( sigMultiLine->text() ); 434 txt.append( sigMultiLine->text().utf8 () );
435 } 435 }
436 mail->setMessage( txt ); 436 mail->setMessage( txt );
437 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 437 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
438 while ( it != 0 ) { 438 while ( it != 0 ) {
439 mail->addAttachment( it->getAttachment() ); 439 mail->addAttachment( it->getAttachment() );
440 it = (AttachViewItem *) it->nextSibling(); 440 it = (AttachViewItem *) it->nextSibling();
441 } 441 }
442 442
443 SMTPwrapper wrapper( smtp ); 443 SMTPwrapper wrapper( smtp );
444 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 444 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
445 setStatus( tr ("Mail sent")); 445 setStatus( tr ("Mail sent"));
446 else { 446 else {
447 setStatus( tr ("Error: Something went wrong. Nothing sent")); 447 setStatus( tr ("Error: Something went wrong. Nothing sent"));
448 return; 448 return;
449 } 449 }
450 450
451 451
452 QDialog::accept(); 452 QDialog::accept();
453} 453}
454 454
455void ComposeMail::reject() 455void ComposeMail::reject()
456{ 456{
457 //qDebug("ComposeMail::reject() "); 457 //qDebug("ComposeMail::reject() ");
458 int yesno = QMessageBox::warning(0,i18n("Store message?"), 458 int yesno = QMessageBox::warning(0,i18n("Store message?"),
459 i18n("Store message into drafts?\n"), 459 i18n("Store message into drafts?\n"),
460 i18n("Yes"), 460 i18n("Yes"),
461 i18n("No")); 461 i18n("No"));
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(data->Wrapper()->fetchBody(current)->Bodytext()); 486 message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() ));
487 subjectLine->setText( data->getSubject()); 487 subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() ));
488 toLine->setText(data->To().join(",")); 488 toLine->setText(QString::fromUtf8( data->To().join(",").latin1() ));
489 ccLine->setText(data->CC().join(",")); 489 ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() ));
490 bccLine->setText(data->Bcc().join(",")); 490 bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() ));
491 replyLine->setText(data->Replyto()); 491 replyLine->setText(QString::fromUtf8( data->Replyto().latin1() ));
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/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 110583f..ae667ec 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -1,1337 +1,1338 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include <stdlib.h> 2#include <stdlib.h>
3#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
4#include <qpe/global.h> 4#include <qpe/global.h>
5#include <qapplication.h> 5#include <qapplication.h>
6#include "imapwrapper.h" 6#include "imapwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8#include "logindialog.h" 8#include "logindialog.h"
9#include <qprogressbar.h> 9#include <qprogressbar.h>
10#include "genericwrapper.h" 10#include "genericwrapper.h"
11#include <kglobal.h> 11#include <kglobal.h>
12 12
13using namespace Opie::Core; 13using namespace Opie::Core;
14int IMAPwrapper::mMax = 0; 14int IMAPwrapper::mMax = 0;
15int IMAPwrapper::mCurrent = 0; 15int IMAPwrapper::mCurrent = 0;
16 16
17IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 17IMAPwrapper::IMAPwrapper( IMAPaccount *a )
18 : AbstractMail() 18 : AbstractMail()
19{ 19{
20 account = a; 20 account = a;
21 m_imap = 0; 21 m_imap = 0;
22 m_Lastmbox = ""; 22 m_Lastmbox = "";
23 mCurrent = 0; 23 mCurrent = 0;
24 mMax = 0; 24 mMax = 0;
25} 25}
26 26
27IMAPwrapper::~IMAPwrapper() 27IMAPwrapper::~IMAPwrapper()
28{ 28{
29 logout(); 29 logout();
30} 30}
31 31
32/* to avoid to often select statements in loops etc. 32/* to avoid to often select statements in loops etc.
33 we trust that we are logged in and connection is established!*/ 33 we trust that we are logged in and connection is established!*/
34int IMAPwrapper::selectMbox(const QString&mbox) 34int IMAPwrapper::selectMbox(const QString&mbox)
35{ 35{
36 if (mbox == m_Lastmbox) { 36 if (mbox == m_Lastmbox) {
37 return MAILIMAP_NO_ERROR; 37 return MAILIMAP_NO_ERROR;
38 } 38 }
39 int err = mailimap_select( m_imap, (char*)mbox.latin1()); 39 int err = mailimap_select( m_imap, (char*)mbox.latin1());
40 if ( err != MAILIMAP_NO_ERROR ) { 40 if ( err != MAILIMAP_NO_ERROR ) {
41 m_Lastmbox = ""; 41 m_Lastmbox = "";
42 return err; 42 return err;
43 } 43 }
44 m_Lastmbox = mbox; 44 m_Lastmbox = mbox;
45 return err; 45 return err;
46} 46}
47 47
48void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 48void IMAPwrapper::imap_progress( size_t current, size_t maximum )
49{ 49{
50 //qDebug("imap progress %d of %d ",current,maximum ); 50 //qDebug("imap progress %d of %d ",current,maximum );
51 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); 51 //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum));
52 //qApp->processEvents() 52 //qApp->processEvents()
53 static int last = 0; 53 static int last = 0;
54 if ( last != current ) 54 if ( last != current )
55 IMAPwrapper::progress(); 55 IMAPwrapper::progress();
56 last = current; 56 last = current;
57} 57}
58void IMAPwrapper::progress( QString m ) 58void IMAPwrapper::progress( QString m )
59{ 59{
60 60
61 static QString mProgrMess; 61 static QString mProgrMess;
62 if ( m != QString::null ) { 62 if ( m != QString::null ) {
63 mProgrMess = m; 63 mProgrMess = m;
64 mCurrent = 1; 64 mCurrent = 1;
65 return; 65 return;
66 } 66 }
67 QString mess; 67 QString mess;
68 //qDebug("progress "); 68 //qDebug("progress ");
69 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); 69 if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax);
70 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); 70 else mess = mProgrMess +i18n(" message %1").arg( mCurrent++);
71 Global::statusMessage(mess); 71 Global::statusMessage(mess);
72 //qDebug("Progress %s %s", mess.latin1(), m.latin1()); 72 //qDebug("Progress %s %s", mess.latin1(), m.latin1());
73 qApp->processEvents(); 73 qApp->processEvents();
74} 74}
75bool IMAPwrapper::start_tls(bool force_tls) 75bool IMAPwrapper::start_tls(bool force_tls)
76{ 76{
77 int err; 77 int err;
78 bool try_tls; 78 bool try_tls;
79 mailimap_capability_data * cap_data = 0; 79 mailimap_capability_data * cap_data = 0;
80 80
81 err = mailimap_capability(m_imap,&cap_data); 81 err = mailimap_capability(m_imap,&cap_data);
82 if (err != MAILIMAP_NO_ERROR) { 82 if (err != MAILIMAP_NO_ERROR) {
83 Global::statusMessage("error getting capabilities!"); 83 Global::statusMessage("error getting capabilities!");
84 return false; 84 return false;
85 } 85 }
86 clistiter * cur; 86 clistiter * cur;
87 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 87 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
88 struct mailimap_capability * cap; 88 struct mailimap_capability * cap;
89 cap = (struct mailimap_capability *)clist_content(cur); 89 cap = (struct mailimap_capability *)clist_content(cur);
90 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 90 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
91 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 91 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
92 try_tls = true; 92 try_tls = true;
93 break; 93 break;
94 } 94 }
95 } 95 }
96 } 96 }
97 if (cap_data) { 97 if (cap_data) {
98 mailimap_capability_data_free(cap_data); 98 mailimap_capability_data_free(cap_data);
99 } 99 }
100 if (try_tls) { 100 if (try_tls) {
101 err = mailimap_starttls(m_imap); 101 err = mailimap_starttls(m_imap);
102 if (err != MAILIMAP_NO_ERROR && force_tls) { 102 if (err != MAILIMAP_NO_ERROR && force_tls) {
103 Global::statusMessage(i18n("Server has no TLS support!")); 103 Global::statusMessage(i18n("Server has no TLS support!"));
104 try_tls = false; 104 try_tls = false;
105 } else { 105 } else {
106 mailstream_low * low; 106 mailstream_low * low;
107 mailstream_low * new_low; 107 mailstream_low * new_low;
108 low = mailstream_get_low(m_imap->imap_stream); 108 low = mailstream_get_low(m_imap->imap_stream);
109 if (!low) { 109 if (!low) {
110 try_tls = false; 110 try_tls = false;
111 } else { 111 } else {
112 int fd = mailstream_low_get_fd(low); 112 int fd = mailstream_low_get_fd(low);
113 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 113 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
114 mailstream_low_free(low); 114 mailstream_low_free(low);
115 mailstream_set_low(m_imap->imap_stream, new_low); 115 mailstream_set_low(m_imap->imap_stream, new_low);
116 } else { 116 } else {
117 try_tls = false; 117 try_tls = false;
118 } 118 }
119 } 119 }
120 } 120 }
121 } 121 }
122 return try_tls; 122 return try_tls;
123} 123}
124 124
125void IMAPwrapper::login() 125void IMAPwrapper::login()
126{ 126{
127 QString server, user, pass; 127 QString server, user, pass;
128 uint16_t port; 128 uint16_t port;
129 int err = MAILIMAP_NO_ERROR; 129 int err = MAILIMAP_NO_ERROR;
130 130
131 if (account->getOffline()) return; 131 if (account->getOffline()) return;
132 /* we are connected this moment */ 132 /* we are connected this moment */
133 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 133 /* TODO: setup a timer holding the line or if connection closed - delete the value */
134 if (m_imap) { 134 if (m_imap) {
135 err = mailimap_noop(m_imap); 135 err = mailimap_noop(m_imap);
136 if (err!=MAILIMAP_NO_ERROR) { 136 if (err!=MAILIMAP_NO_ERROR) {
137 logout(); 137 logout();
138 } else { 138 } else {
139 mailstream_flush(m_imap->imap_stream); 139 mailstream_flush(m_imap->imap_stream);
140 return; 140 return;
141 } 141 }
142 } 142 }
143 server = account->getServer(); 143 server = account->getServer();
144 port = account->getPort().toUInt(); 144 port = account->getPort().toUInt();
145 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 145 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
146 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 146 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
147 login.show(); 147 login.show();
148 if ( QDialog::Accepted == login.exec() ) { 148 if ( QDialog::Accepted == login.exec() ) {
149 // ok 149 // ok
150 user = login.getUser(); 150 user = login.getUser();
151 pass = login.getPassword(); 151 pass = login.getPassword();
152 } else { 152 } else {
153 // cancel 153 // cancel
154 return; 154 return;
155 } 155 }
156 } else { 156 } else {
157 user = account->getUser(); 157 user = account->getUser();
158 pass = account->getPassword(); 158 pass = account->getPassword();
159 } 159 }
160 160
161 m_imap = mailimap_new( 20, &imap_progress ); 161 m_imap = mailimap_new( 20, &imap_progress );
162 162
163 /* connect */ 163 /* connect */
164 bool ssl = false; 164 bool ssl = false;
165 bool try_tls = false; 165 bool try_tls = false;
166 bool force_tls = false; 166 bool force_tls = false;
167 167
168 if ( account->ConnectionType() == 2 ) { 168 if ( account->ConnectionType() == 2 ) {
169 ssl = true; 169 ssl = true;
170 } 170 }
171 if (account->ConnectionType()==1) { 171 if (account->ConnectionType()==1) {
172 force_tls = true; 172 force_tls = true;
173 } 173 }
174 174
175 if ( ssl ) { 175 if ( ssl ) {
176 qDebug("using ssl "); 176 qDebug("using ssl ");
177 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); 177 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port );
178 qDebug("back "); 178 qDebug("back ");
179 } else { 179 } else {
180 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); 180 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port );
181 } 181 }
182 182
183 if ( err != MAILIMAP_NO_ERROR && 183 if ( err != MAILIMAP_NO_ERROR &&
184 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 184 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
185 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 185 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
186 QString failure = ""; 186 QString failure = "";
187 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 187 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
188 failure="Connection refused"; 188 failure="Connection refused";
189 } else { 189 } else {
190 failure="Unknown failure"; 190 failure="Unknown failure";
191 } 191 }
192 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); 192 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure));
193 mailimap_free( m_imap ); 193 mailimap_free( m_imap );
194 m_imap = 0; 194 m_imap = 0;
195 return; 195 return;
196 } 196 }
197 197
198 if (!ssl) { 198 if (!ssl) {
199 try_tls = start_tls(force_tls); 199 try_tls = start_tls(force_tls);
200 } 200 }
201 201
202 bool ok = true; 202 bool ok = true;
203 if (force_tls && !try_tls) { 203 if (force_tls && !try_tls) {
204 Global::statusMessage(i18n("Server has no TLS support!")); 204 Global::statusMessage(i18n("Server has no TLS support!"));
205 ok = false; 205 ok = false;
206 } 206 }
207 207
208 208
209 /* login */ 209 /* login */
210 210
211 if (ok) { 211 if (ok) {
212 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); 212 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() );
213 if ( err != MAILIMAP_NO_ERROR ) { 213 if ( err != MAILIMAP_NO_ERROR ) {
214 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); 214 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response));
215 ok = false; 215 ok = false;
216 } 216 }
217 } 217 }
218 if (!ok) { 218 if (!ok) {
219 err = mailimap_close( m_imap ); 219 err = mailimap_close( m_imap );
220 mailimap_free( m_imap ); 220 mailimap_free( m_imap );
221 m_imap = 0; 221 m_imap = 0;
222 } 222 }
223} 223}
224 224
225void IMAPwrapper::logout() 225void IMAPwrapper::logout()
226{ 226{
227 int err = MAILIMAP_NO_ERROR; 227 int err = MAILIMAP_NO_ERROR;
228 if (!m_imap) return; 228 if (!m_imap) return;
229 err = mailimap_logout( m_imap ); 229 err = mailimap_logout( m_imap );
230 err = mailimap_close( m_imap ); 230 err = mailimap_close( m_imap );
231 mailimap_free( m_imap ); 231 mailimap_free( m_imap );
232 m_imap = 0; 232 m_imap = 0;
233 m_Lastmbox = ""; 233 m_Lastmbox = "";
234} 234}
235 235
236void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) 236void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
237{ 237{
238 238
239 int tryAgain = 1; 239 int tryAgain = 1;
240 while ( tryAgain >= 0 ) { 240 while ( tryAgain >= 0 ) {
241 int err = MAILIMAP_NO_ERROR; 241 int err = MAILIMAP_NO_ERROR;
242 clist *result = 0; 242 clist *result = 0;
243 clistcell *current; 243 clistcell *current;
244 mailimap_fetch_type *fetchType = 0; 244 mailimap_fetch_type *fetchType = 0;
245 mailimap_set *set = 0; 245 mailimap_set *set = 0;
246 246
247 login(); 247 login();
248 if (!m_imap) { 248 if (!m_imap) {
249 return; 249 return;
250 } 250 }
251 /* select mailbox READONLY for operations */ 251 /* select mailbox READONLY for operations */
252 err = selectMbox(mailbox); 252 err = selectMbox(mailbox);
253 if ( err != MAILIMAP_NO_ERROR ) { 253 if ( err != MAILIMAP_NO_ERROR ) {
254 return; 254 return;
255 } 255 }
256 256
257 int last = m_imap->imap_selection_info->sel_exists; 257 int last = m_imap->imap_selection_info->sel_exists;
258 258
259 if (last == 0) { 259 if (last == 0) {
260 Global::statusMessage(i18n("Mailbox has no mails")); 260 Global::statusMessage(i18n("Mailbox has no mails"));
261 return; 261 return;
262 } else { 262 } else {
263 } 263 }
264 progress( i18n("Fetch ")); 264 progress( i18n("Fetch "));
265 mMax = last; 265 mMax = last;
266 //qDebug("last %d ", last); 266 //qDebug("last %d ", last);
267 Global::statusMessage(i18n("Fetching header list")); 267 Global::statusMessage(i18n("Fetching header list"));
268 qApp->processEvents(); 268 qApp->processEvents();
269 /* the range has to start at 1!!! not with 0!!!! */ 269 /* the range has to start at 1!!! not with 0!!!! */
270 //LR the access to web.de imap server is no working with value 1 270 //LR the access to web.de imap server is no working with value 1
271 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); 271 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain );
272 set = mailimap_set_new_interval( tryAgain, last ); 272 set = mailimap_set_new_interval( tryAgain, last );
273 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 273 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
274 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 274 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
275 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 275 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
276 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 276 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
277 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 277 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
278 278
279 err = mailimap_fetch( m_imap, set, fetchType, &result ); 279 err = mailimap_fetch( m_imap, set, fetchType, &result );
280 mailimap_set_free( set ); 280 mailimap_set_free( set );
281 mailimap_fetch_type_free( fetchType ); 281 mailimap_fetch_type_free( fetchType );
282 282
283 QString date,subject,from; 283 QString date,subject,from;
284 284
285 if ( err == MAILIMAP_NO_ERROR ) { 285 if ( err == MAILIMAP_NO_ERROR ) {
286 tryAgain = -1; 286 tryAgain = -1;
287 mailimap_msg_att * msg_att; 287 mailimap_msg_att * msg_att;
288 int i = 0; 288 int i = 0;
289 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 289 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
290 ++i; 290 ++i;
291 //qDebug("iii %d ",i); 291 //qDebug("iii %d ",i);
292 msg_att = (mailimap_msg_att*)current->data; 292 msg_att = (mailimap_msg_att*)current->data;
293 RecMail*m = parse_list_result(msg_att); 293 RecMail*m = parse_list_result(msg_att);
294 if (m) { 294 if (m) {
295 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { 295 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) {
296 m->setNumber(i); 296 m->setNumber(i);
297 m->setMbox(mailbox); 297 m->setMbox(mailbox);
298 m->setWrapper(this); 298 m->setWrapper(this);
299 target.append(m); 299 target.append(m);
300 } 300 }
301 } 301 }
302 } 302 }
303 Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); 303 Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count()));
304 } else { 304 } else {
305 --tryAgain; 305 --tryAgain;
306 --tryAgain;//disabled tryagain by adding this line 306 --tryAgain;//disabled tryagain by adding this line
307 if ( tryAgain < 0 ) 307 if ( tryAgain < 0 )
308 Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); 308 Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response));
309 else 309 else
310 qDebug("try again... "); 310 qDebug("try again... ");
311 } 311 }
312 312
313 if (result) mailimap_fetch_list_free(result); 313 if (result) mailimap_fetch_list_free(result);
314 } 314 }
315} 315}
316 316
317QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 317QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
318{ 318{
319 const char *path, *mask; 319 const char *path, *mask;
320 int err = MAILIMAP_NO_ERROR; 320 int err = MAILIMAP_NO_ERROR;
321 clist *result = 0; 321 clist *result = 0;
322 clistcell *current = 0; 322 clistcell *current = 0;
323 clistcell*cur_flag = 0; 323 clistcell*cur_flag = 0;
324 mailimap_mbx_list_flags*bflags = 0; 324 mailimap_mbx_list_flags*bflags = 0;
325 325
326 QValueList<FolderP>* folders = new QValueList<FolderP>(); 326 QValueList<FolderP>* folders = new QValueList<FolderP>();
327 login(); 327 login();
328 if (!m_imap) { 328 if (!m_imap) {
329 return folders; 329 return folders;
330 } 330 }
331 331
332/* 332/*
333 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 333 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
334 * We must not forget to filter them out in next loop! 334 * We must not forget to filter them out in next loop!
335 * it seems like ugly code. and yes - it is ugly code. but the best way. 335 * it seems like ugly code. and yes - it is ugly code. but the best way.
336 */ 336 */
337 Global::statusMessage(i18n("Fetching folder list")); 337 Global::statusMessage(i18n("Fetching folder list"));
338 qApp->processEvents(); 338 qApp->processEvents();
339 QString temp; 339 QString temp;
340 mask = "INBOX" ; 340 mask = "INBOX" ;
341 mailimap_mailbox_list *list; 341 mailimap_mailbox_list *list;
342 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 342 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
343 QString del; 343 QString del;
344 bool selectable = true; 344 bool selectable = true;
345 bool no_inferiors = false; 345 bool no_inferiors = false;
346 if ( err == MAILIMAP_NO_ERROR ) { 346 if ( err == MAILIMAP_NO_ERROR ) {
347 current = result->first; 347 current = result->first;
348 for ( int i = result->count; i > 0; i-- ) { 348 for ( int i = result->count; i > 0; i-- ) {
349 list = (mailimap_mailbox_list *) current->data; 349 list = (mailimap_mailbox_list *) current->data;
350 // it is better use the deep copy mechanism of qt itself 350 // it is better use the deep copy mechanism of qt itself
351 // instead of using strdup! 351 // instead of using strdup!
352 temp = list->mb_name; 352 temp = list->mb_name;
353 del = list->mb_delimiter; 353 del = list->mb_delimiter;
354 current = current->next; 354 current = current->next;
355 if ( (bflags = list->mb_flag) ) { 355 if ( (bflags = list->mb_flag) ) {
356 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 356 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
357 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 357 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
358 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 358 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
359 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 359 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
360 no_inferiors = true; 360 no_inferiors = true;
361 } 361 }
362 } 362 }
363 } 363 }
364 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 364 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
365 } 365 }
366 } else { 366 } else {
367 qDebug("error fetching folders: "); 367 qDebug("error fetching folders: ");
368 368
369 } 369 }
370 mailimap_list_result_free( result ); 370 mailimap_list_result_free( result );
371 371
372/* 372/*
373 * second stage - get the other then inbox folders 373 * second stage - get the other then inbox folders
374 */ 374 */
375 mask = "*" ; 375 mask = "*" ;
376 path = account->getPrefix().latin1(); 376 path = account->getPrefix().latin1();
377 if (!path) path = ""; 377 if (!path) path = "";
378 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 378 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
379 if ( err == MAILIMAP_NO_ERROR ) { 379 if ( err == MAILIMAP_NO_ERROR ) {
380 current = result->first; 380 current = result->first;
381 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 381 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
382 no_inferiors = false; 382 no_inferiors = false;
383 list = (mailimap_mailbox_list *) current->data; 383 list = (mailimap_mailbox_list *) current->data;
384 // it is better use the deep copy mechanism of qt itself 384 // it is better use the deep copy mechanism of qt itself
385 // instead of using strdup! 385 // instead of using strdup!
386 temp = list->mb_name; 386 temp = list->mb_name;
387 if (temp.lower()=="inbox") 387 if (temp.lower()=="inbox")
388 continue; 388 continue;
389 if (temp.lower()==account->getPrefix().lower()) 389 if (temp.lower()==account->getPrefix().lower())
390 continue; 390 continue;
391 if ( (bflags = list->mb_flag) ) { 391 if ( (bflags = list->mb_flag) ) {
392 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 392 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
393 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 393 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
394 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 394 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
395 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 395 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
396 no_inferiors = true; 396 no_inferiors = true;
397 } 397 }
398 } 398 }
399 } 399 }
400 del = list->mb_delimiter; 400 del = list->mb_delimiter;
401 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 401 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
402 } 402 }
403 } else { 403 } else {
404 qDebug("error fetching folders "); 404 qDebug("error fetching folders ");
405 405
406 } 406 }
407 if (result) mailimap_list_result_free( result ); 407 if (result) mailimap_list_result_free( result );
408 return folders; 408 return folders;
409} 409}
410 410
411RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 411RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
412{ 412{
413 RecMail * m = 0; 413 RecMail * m = 0;
414 mailimap_msg_att_item *item=0; 414 mailimap_msg_att_item *item=0;
415 clistcell *current,*c,*cf; 415 clistcell *current,*c,*cf;
416 mailimap_msg_att_dynamic*flist; 416 mailimap_msg_att_dynamic*flist;
417 mailimap_flag_fetch*cflag; 417 mailimap_flag_fetch*cflag;
418 int size; 418 int size;
419 QBitArray mFlags(7); 419 QBitArray mFlags(7);
420 QStringList addresslist; 420 QStringList addresslist;
421 421
422 if (!m_att) { 422 if (!m_att) {
423 return m; 423 return m;
424 } 424 }
425 m = new RecMail(); 425 m = new RecMail();
426 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 426 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
427 current = c; 427 current = c;
428 size = 0; 428 size = 0;
429 item = (mailimap_msg_att_item*)current->data; 429 item = (mailimap_msg_att_item*)current->data;
430 if ( !item ) 430 if ( !item )
431 continue; 431 continue;
432 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 432 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
433 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 433 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
434 if (!flist || !flist->att_list) { 434 if (!flist || !flist->att_list) {
435 continue; 435 continue;
436 } 436 }
437 cf = flist->att_list->first; 437 cf = flist->att_list->first;
438 if( ! cf ) 438 if( ! cf )
439 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 439 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
440 cflag = (mailimap_flag_fetch*)cf->data; 440 cflag = (mailimap_flag_fetch*)cf->data;
441 if( ! cflag ) 441 if( ! cflag )
442 qDebug("imap:not cflag "); 442 qDebug("imap:not cflag ");
443 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 443 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
444 switch (cflag->fl_flag->fl_type) { 444 switch (cflag->fl_flag->fl_type) {
445 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 445 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
446 mFlags.setBit(FLAG_ANSWERED); 446 mFlags.setBit(FLAG_ANSWERED);
447 break; 447 break;
448 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 448 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
449 mFlags.setBit(FLAG_FLAGGED); 449 mFlags.setBit(FLAG_FLAGGED);
450 break; 450 break;
451 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 451 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
452 mFlags.setBit(FLAG_DELETED); 452 mFlags.setBit(FLAG_DELETED);
453 break; 453 break;
454 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 454 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
455 mFlags.setBit(FLAG_SEEN); 455 mFlags.setBit(FLAG_SEEN);
456 break; 456 break;
457 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 457 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
458 mFlags.setBit(FLAG_DRAFT); 458 mFlags.setBit(FLAG_DRAFT);
459 break; 459 break;
460 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 460 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
461 break; 461 break;
462 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 462 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
463 break; 463 break;
464 default: 464 default:
465 break; 465 break;
466 } 466 }
467 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 467 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
468 mFlags.setBit(FLAG_RECENT); 468 mFlags.setBit(FLAG_RECENT);
469 } 469 }
470 } 470 }
471 continue; 471 continue;
472 } 472 }
473 if ( item->att_data.att_static == NULL ) 473 if ( item->att_data.att_static == NULL )
474 continue; 474 continue;
475 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 475 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
476 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 476 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
477 if ( head == NULL ) 477 if ( head == NULL )
478 continue; 478 continue;
479 if ( head->env_date != NULL ) { 479 if ( head->env_date != NULL ) {
480 m->setDate(head->env_date); 480 m->setDate(head->env_date);
481 struct mailimf_date_time result; 481 struct mailimf_date_time result;
482 struct mailimf_date_time* date = &result; 482 struct mailimf_date_time* date = &result;
483 struct mailimf_date_time **re = &date; 483 struct mailimf_date_time **re = &date;
484 size_t length = m->getDate().length(); 484 size_t length = m->getDate().length();
485 size_t index = 0; 485 size_t index = 0;
486 if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { 486 if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) {
487 QDateTime dt = Genericwrapper::parseDateTime( date ); 487 QDateTime dt = Genericwrapper::parseDateTime( date );
488 QString ret; 488 QString ret;
489 if ( dt.date() == QDate::currentDate () ) 489 if ( dt.date() == QDate::currentDate () )
490 ret = KGlobal::locale()->formatTime( dt.time(),true); 490 ret = KGlobal::locale()->formatTime( dt.time(),true);
491 else { 491 else {
492 ret = KGlobal::locale()->formatDateTime( dt,true,true); 492 ret = KGlobal::locale()->formatDateTime( dt,true,true);
493 } 493 }
494 m->setDate( ret ); 494 m->setDate( ret );
495 char tmp[20]; 495 char tmp[20];
496 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", 496 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i",
497 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); 497 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() );
498 //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); 498 //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date);
499 m->setIsoDate( QString( tmp ) ); 499 m->setIsoDate( QString( tmp ) );
500 } else { 500 } else {
501 m->setIsoDate(head->env_date); 501 m->setIsoDate(head->env_date);
502 } 502 }
503 } 503 }
504 if ( head->env_subject != NULL ) 504 if ( head->env_subject != NULL )
505 m->setSubject(convert_String((const char*)head->env_subject)); 505 m->setSubject(convert_String((const char*)head->env_subject));
506 //m->setSubject(head->env_subject); 506 //m->setSubject(head->env_subject);
507 if (head->env_from!=NULL) { 507 if (head->env_from!=NULL) {
508 addresslist = address_list_to_stringlist(head->env_from->frm_list); 508 addresslist = address_list_to_stringlist(head->env_from->frm_list);
509 if (addresslist.count()) { 509 if (addresslist.count()) {
510 m->setFrom(addresslist.first()); 510 m->setFrom(addresslist.first());
511 } 511 }
512 } 512 }
513 if (head->env_to!=NULL) { 513 if (head->env_to!=NULL) {
514 addresslist = address_list_to_stringlist(head->env_to->to_list); 514 addresslist = address_list_to_stringlist(head->env_to->to_list);
515 m->setTo(addresslist); 515 m->setTo(addresslist);
516 } 516 }
517 if (head->env_cc!=NULL) { 517 if (head->env_cc!=NULL) {
518 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 518 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
519 m->setCC(addresslist); 519 m->setCC(addresslist);
520 } 520 }
521 if (head->env_bcc!=NULL) { 521 if (head->env_bcc!=NULL) {
522 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 522 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
523 m->setBcc(addresslist); 523 m->setBcc(addresslist);
524 } 524 }
525 /* reply to address, eg. email. */ 525 /* reply to address, eg. email. */
526 if (head->env_reply_to!=NULL) { 526 if (head->env_reply_to!=NULL) {
527 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 527 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
528 if (addresslist.count()) { 528 if (addresslist.count()) {
529 m->setReplyto(addresslist.first()); 529 m->setReplyto(addresslist.first());
530 } 530 }
531 } 531 }
532 if (head->env_in_reply_to!=NULL) { 532 if (head->env_in_reply_to!=NULL) {
533 QString h(head->env_in_reply_to); 533 QString h(head->env_in_reply_to);
534 while (h.length()>0 && h[0]=='<') { 534 while (h.length()>0 && h[0]=='<') {
535 h.remove(0,1); 535 h.remove(0,1);
536 } 536 }
537 while (h.length()>0 && h[h.length()-1]=='>') { 537 while (h.length()>0 && h[h.length()-1]=='>') {
538 h.remove(h.length()-1,1); 538 h.remove(h.length()-1,1);
539 } 539 }
540 if (h.length()>0) { 540 if (h.length()>0) {
541 m->setInreply(QStringList(h)); 541 m->setInreply(QStringList(h));
542 } 542 }
543 } 543 }
544 if (head->env_message_id != NULL) { 544 if (head->env_message_id != NULL) {
545 m->setMsgid(QString(head->env_message_id)); 545 m->setMsgid(QString(head->env_message_id));
546 } 546 }
547 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 547 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
548#if 0 548#if 0
549 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 549 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
550 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 550 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
551 qDebug("time %s ",da.toString().latin1() ); 551 qDebug("time %s ",da.toString().latin1() );
552#endif 552#endif
553 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 553 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
554 size = item->att_data.att_static->att_data.att_rfc822_size; 554 size = item->att_data.att_static->att_data.att_rfc822_size;
555 } 555 }
556 } 556 }
557 /* msg is already deleted */ 557 /* msg is already deleted */
558 if (mFlags.testBit(FLAG_DELETED) && m) { 558 if (mFlags.testBit(FLAG_DELETED) && m) {
559 delete m; 559 delete m;
560 m = 0; 560 m = 0;
561 } 561 }
562 if (m) { 562 if (m) {
563 m->setFlags(mFlags); 563 m->setFlags(mFlags);
564 m->setMsgsize(size); 564 m->setMsgsize(size);
565 } 565 }
566 return m; 566 return m;
567} 567}
568 568
569RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 569RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
570{ 570{
571 RecBodyP body = new RecBody(); 571 RecBodyP body = new RecBody();
572 const char *mb; 572 const char *mb;
573 int err = MAILIMAP_NO_ERROR; 573 int err = MAILIMAP_NO_ERROR;
574 clist *result = 0; 574 clist *result = 0;
575 clistcell *current; 575 clistcell *current;
576 mailimap_fetch_att *fetchAtt = 0; 576 mailimap_fetch_att *fetchAtt = 0;
577 mailimap_fetch_type *fetchType = 0; 577 mailimap_fetch_type *fetchType = 0;
578 mailimap_set *set = 0; 578 mailimap_set *set = 0;
579 mailimap_body*body_desc = 0; 579 mailimap_body*body_desc = 0;
580 580
581 mb = mail->getMbox().latin1(); 581 mb = mail->getMbox().latin1();
582 582
583 login(); 583 login();
584 if (!m_imap) { 584 if (!m_imap) {
585 return body; 585 return body;
586 } 586 }
587 err = selectMbox(mail->getMbox()); 587 err = selectMbox(mail->getMbox());
588 if ( err != MAILIMAP_NO_ERROR ) { 588 if ( err != MAILIMAP_NO_ERROR ) {
589 return body; 589 return body;
590 } 590 }
591 591
592 /* the range has to start at 1!!! not with 0!!!! */ 592 /* the range has to start at 1!!! not with 0!!!! */
593 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); 593 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
594 fetchAtt = mailimap_fetch_att_new_bodystructure(); 594 fetchAtt = mailimap_fetch_att_new_bodystructure();
595 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 595 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
596 err = mailimap_fetch( m_imap, set, fetchType, &result ); 596 err = mailimap_fetch( m_imap, set, fetchType, &result );
597 mailimap_set_free( set ); 597 mailimap_set_free( set );
598 mailimap_fetch_type_free( fetchType ); 598 mailimap_fetch_type_free( fetchType );
599 599
600 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 600 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
601 mailimap_msg_att * msg_att; 601 mailimap_msg_att * msg_att;
602 msg_att = (mailimap_msg_att*)current->data; 602 msg_att = (mailimap_msg_att*)current->data;
603 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 603 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
604 QValueList<int> path; 604 QValueList<int> path;
605 body_desc = item->att_data.att_static->att_data.att_body; 605 body_desc = item->att_data.att_static->att_data.att_body;
606 traverseBody(mail,body_desc,body,0,path); 606 traverseBody(mail,body_desc,body,0,path);
607 } else { 607 } else {
608 //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; 608 //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
609 } 609 }
610 if (result) mailimap_fetch_list_free(result); 610 if (result) mailimap_fetch_list_free(result);
611 return body; 611 return body;
612} 612}
613 613
614QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 614QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
615{ 615{
616 QStringList l; 616 QStringList l;
617 QString from; 617 QString from;
618 bool named_from; 618 bool named_from;
619 clistcell *current = NULL; 619 clistcell *current = NULL;
620 mailimap_address * current_address=NULL; 620 mailimap_address * current_address=NULL;
621 if (!list) { 621 if (!list) {
622 return l; 622 return l;
623 } 623 }
624 unsigned int count = 0; 624 unsigned int count = 0;
625 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 625 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
626 from = ""; 626 from = "";
627 named_from = false; 627 named_from = false;
628 current_address=(mailimap_address*)current->data; 628 current_address=(mailimap_address*)current->data;
629 if (current_address->ad_personal_name){ 629 if (current_address->ad_personal_name){
630 from+=convert_String((const char*)current_address->ad_personal_name); 630 from+=convert_String((const char*)current_address->ad_personal_name);
631 from+=" "; 631 from+=" ";
632 named_from = true; 632 named_from = true;
633 } 633 }
634 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 634 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
635 from+="<"; 635 from+="<";
636 } 636 }
637 if (current_address->ad_mailbox_name) { 637 if (current_address->ad_mailbox_name) {
638 from+=QString(current_address->ad_mailbox_name); 638 from+=QString(current_address->ad_mailbox_name);
639 from+="@"; 639 from+="@";
640 } 640 }
641 if (current_address->ad_host_name) { 641 if (current_address->ad_host_name) {
642 from+=QString(current_address->ad_host_name); 642 from+=QString(current_address->ad_host_name);
643 } 643 }
644 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 644 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
645 from+=">"; 645 from+=">";
646 } 646 }
647 l.append(QString(from)); 647 l.append(QString(from));
648 if (++count > 99) { 648 if (++count > 99) {
649 break; 649 break;
650 } 650 }
651 } 651 }
652 return l; 652 return l;
653} 653}
654 654
655encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) 655encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
656{ 656{
657 encodedString*res=new encodedString; 657 encodedString*res=new encodedString;
658 int err; 658 int err;
659 mailimap_fetch_type *fetchType; 659 mailimap_fetch_type *fetchType;
660 mailimap_set *set; 660 mailimap_set *set;
661 clistcell*current,*cur; 661 clistcell*current,*cur;
662 mailimap_section_part * section_part = 0; 662 mailimap_section_part * section_part = 0;
663 mailimap_section_spec * section_spec = 0; 663 mailimap_section_spec * section_spec = 0;
664 mailimap_section * section = 0; 664 mailimap_section * section = 0;
665 mailimap_fetch_att * fetch_att = 0; 665 mailimap_fetch_att * fetch_att = 0;
666 666
667 login(); 667 login();
668 if (!m_imap) { 668 if (!m_imap) {
669 return res; 669 return res;
670 } 670 }
671 if (!internal_call) { 671 if (!internal_call) {
672 err = selectMbox(mail->getMbox()); 672 err = selectMbox(mail->getMbox());
673 if ( err != MAILIMAP_NO_ERROR ) { 673 if ( err != MAILIMAP_NO_ERROR ) {
674 return res; 674 return res;
675 } 675 }
676 } 676 }
677 set = mailimap_set_new_single(mail->getNumber()); 677 set = mailimap_set_new_single(mail->getNumber());
678 678
679 clist*id_list = 0; 679 clist*id_list = 0;
680 680
681 /* if path == empty then its a request for the whole rfc822 mail and generates 681 /* if path == empty then its a request for the whole rfc822 mail and generates
682 a "fetch <id> (body[])" statement on imap server */ 682 a "fetch <id> (body[])" statement on imap server */
683 if (path.count()>0 ) { 683 if (path.count()>0 ) {
684 id_list = clist_new(); 684 id_list = clist_new();
685 for (unsigned j=0; j < path.count();++j) { 685 for (unsigned j=0; j < path.count();++j) {
686 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 686 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
687 *p_id = path[j]; 687 *p_id = path[j];
688 clist_append(id_list,p_id); 688 clist_append(id_list,p_id);
689 } 689 }
690 section_part = mailimap_section_part_new(id_list); 690 section_part = mailimap_section_part_new(id_list);
691 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 691 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
692 } 692 }
693 693
694 section = mailimap_section_new(section_spec); 694 section = mailimap_section_new(section_spec);
695 fetch_att = mailimap_fetch_att_new_body_section(section); 695 fetch_att = mailimap_fetch_att_new_body_section(section);
696 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 696 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
697 697
698 clist*result = 0; 698 clist*result = 0;
699 699
700 err = mailimap_fetch( m_imap, set, fetchType, &result ); 700 err = mailimap_fetch( m_imap, set, fetchType, &result );
701 mailimap_set_free( set ); 701 mailimap_set_free( set );
702 mailimap_fetch_type_free( fetchType ); 702 mailimap_fetch_type_free( fetchType );
703 703
704 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 704 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
705 mailimap_msg_att * msg_att; 705 mailimap_msg_att * msg_att;
706 msg_att = (mailimap_msg_att*)current->data; 706 msg_att = (mailimap_msg_att*)current->data;
707 mailimap_msg_att_item*msg_att_item; 707 mailimap_msg_att_item*msg_att_item;
708 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 708 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
709 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 709 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
710 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 710 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
711 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 711 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
712 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 712 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
713 /* detach - we take over the content */ 713 /* detach - we take over the content */
714 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 714 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
715 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); 715 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
716 } 716 }
717 } 717 }
718 } 718 }
719 } else { 719 } else {
720 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; 720 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
721 } 721 }
722 if (result) mailimap_fetch_list_free(result); 722 if (result) mailimap_fetch_list_free(result);
723 return res; 723 return res;
724} 724}
725 725
726/* current_recursion is for recursive calls. 726/* current_recursion is for recursive calls.
727 current_count means the position inside the internal loop! */ 727 current_count means the position inside the internal loop! */
728void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, 728void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
729 int current_recursion,QValueList<int>recList,int current_count) 729 int current_recursion,QValueList<int>recList,int current_count)
730{ 730{
731 if (!body || current_recursion>=10) { 731 if (!body || current_recursion>=10) {
732 return; 732 return;
733 } 733 }
734 switch (body->bd_type) { 734 switch (body->bd_type) {
735 case MAILIMAP_BODY_1PART: 735 case MAILIMAP_BODY_1PART:
736 { 736 {
737 QValueList<int>countlist = recList; 737 QValueList<int>countlist = recList;
738 countlist.append(current_count); 738 countlist.append(current_count);
739 RecPartP currentPart = new RecPart(); 739 RecPartP currentPart = new RecPart();
740 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 740 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
741 QString id(""); 741 QString id("");
742 currentPart->setPositionlist(countlist); 742 currentPart->setPositionlist(countlist);
743 for (unsigned int j = 0; j < countlist.count();++j) { 743 for (unsigned int j = 0; j < countlist.count();++j) {
744 id+=(j>0?" ":""); 744 id+=(j>0?" ":"");
745 id+=QString("%1").arg(countlist[j]); 745 id+=QString("%1").arg(countlist[j]);
746 } 746 }
747 //odebug << "ID = " << id.latin1() << "" << oendl; 747 //odebug << "ID = " << id.latin1() << "" << oendl;
748 currentPart->setIdentifier(id); 748 currentPart->setIdentifier(id);
749 fillSinglePart(currentPart,part1); 749 fillSinglePart(currentPart,part1);
750 /* important: Check for is NULL 'cause a body can be empty! 750 /* important: Check for is NULL 'cause a body can be empty!
751 And we put it only into the mail if it is the FIRST part */ 751 And we put it only into the mail if it is the FIRST part */
752 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 752 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
753 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 753 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
754 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
754 target_body->setDescription(currentPart); 755 target_body->setDescription(currentPart);
755 target_body->setBodytext(body_text); 756 target_body->setBodytext(body_text);
756 if (countlist.count()>1) { 757 if (countlist.count()>1) {
757 target_body->addPart(currentPart); 758 target_body->addPart(currentPart);
758 } 759 }
759 } else { 760 } else {
760 target_body->addPart(currentPart); 761 target_body->addPart(currentPart);
761 } 762 }
762 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 763 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
763 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 764 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
764 } 765 }
765 } 766 }
766 break; 767 break;
767 case MAILIMAP_BODY_MPART: 768 case MAILIMAP_BODY_MPART:
768 { 769 {
769 QValueList<int>countlist = recList; 770 QValueList<int>countlist = recList;
770 clistcell*current=0; 771 clistcell*current=0;
771 mailimap_body*current_body=0; 772 mailimap_body*current_body=0;
772 unsigned int ccount = 1; 773 unsigned int ccount = 1;
773 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 774 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
774 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 775 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
775 current_body = (mailimap_body*)current->data; 776 current_body = (mailimap_body*)current->data;
776 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 777 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
777 RecPartP targetPart = new RecPart(); 778 RecPartP targetPart = new RecPart();
778 targetPart->setType("multipart"); 779 targetPart->setType("multipart");
779 fillMultiPart(targetPart,mailDescription); 780 fillMultiPart(targetPart,mailDescription);
780 countlist.append(current_count); 781 countlist.append(current_count);
781 targetPart->setPositionlist(countlist); 782 targetPart->setPositionlist(countlist);
782 target_body->addPart(targetPart); 783 target_body->addPart(targetPart);
783 QString id(""); 784 QString id("");
784 for (unsigned int j = 0; j < countlist.count();++j) { 785 for (unsigned int j = 0; j < countlist.count();++j) {
785 id+=(j>0?" ":""); 786 id+=(j>0?" ":"");
786 id+=QString("%1").arg(countlist[j]); 787 id+=QString("%1").arg(countlist[j]);
787 } 788 }
788 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; 789 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
789 } 790 }
790 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 791 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
791 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 792 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
792 countlist = recList; 793 countlist = recList;
793 } 794 }
794 ++ccount; 795 ++ccount;
795 } 796 }
796 } 797 }
797 break; 798 break;
798 default: 799 default:
799 break; 800 break;
800 } 801 }
801} 802}
802 803
803void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) 804void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
804{ 805{
805 if (!Description) { 806 if (!Description) {
806 return; 807 return;
807 } 808 }
808 switch (Description->bd_type) { 809 switch (Description->bd_type) {
809 case MAILIMAP_BODY_TYPE_1PART_TEXT: 810 case MAILIMAP_BODY_TYPE_1PART_TEXT:
810 target_part->setType("text"); 811 target_part->setType("text");
811 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 812 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
812 break; 813 break;
813 case MAILIMAP_BODY_TYPE_1PART_BASIC: 814 case MAILIMAP_BODY_TYPE_1PART_BASIC:
814 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 815 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
815 break; 816 break;
816 case MAILIMAP_BODY_TYPE_1PART_MSG: 817 case MAILIMAP_BODY_TYPE_1PART_MSG:
817 target_part->setType("message"); 818 target_part->setType("message");
818 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 819 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
819 break; 820 break;
820 default: 821 default:
821 break; 822 break;
822 } 823 }
823} 824}
824 825
825void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) 826void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
826{ 827{
827 if (!which) { 828 if (!which) {
828 return; 829 return;
829 } 830 }
830 QString sub; 831 QString sub;
831 sub = which->bd_media_text; 832 sub = which->bd_media_text;
832 //odebug << "Type= text/" << which->bd_media_text << "" << oendl; 833 //odebug << "Type= text/" << which->bd_media_text << "" << oendl;
833 target_part->setSubtype(sub.lower()); 834 target_part->setSubtype(sub.lower());
834 target_part->setLines(which->bd_lines); 835 target_part->setLines(which->bd_lines);
835 fillBodyFields(target_part,which->bd_fields); 836 fillBodyFields(target_part,which->bd_fields);
836} 837}
837 838
838void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) 839void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
839{ 840{
840 if (!which) { 841 if (!which) {
841 return; 842 return;
842 } 843 }
843 target_part->setSubtype("rfc822"); 844 target_part->setSubtype("rfc822");
844 //odebug << "Message part" << oendl; 845 //odebug << "Message part" << oendl;
845 /* we set this type to text/plain */ 846 /* we set this type to text/plain */
846 target_part->setLines(which->bd_lines); 847 target_part->setLines(which->bd_lines);
847 fillBodyFields(target_part,which->bd_fields); 848 fillBodyFields(target_part,which->bd_fields);
848} 849}
849 850
850void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) 851void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
851{ 852{
852 if (!which) return; 853 if (!which) return;
853 QString sub = which->bd_media_subtype; 854 QString sub = which->bd_media_subtype;
854 target_part->setSubtype(sub.lower()); 855 target_part->setSubtype(sub.lower());
855 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 856 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
856 clistcell*cur = 0; 857 clistcell*cur = 0;
857 mailimap_single_body_fld_param*param=0; 858 mailimap_single_body_fld_param*param=0;
858 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 859 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
859 param = (mailimap_single_body_fld_param*)cur->data; 860 param = (mailimap_single_body_fld_param*)cur->data;
860 if (param) { 861 if (param) {
861 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 862 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
862 } 863 }
863 } 864 }
864 } 865 }
865} 866}
866 867
867void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) 868void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
868{ 869{
869 if (!which) { 870 if (!which) {
870 return; 871 return;
871 } 872 }
872 QString type,sub; 873 QString type,sub;
873 switch (which->bd_media_basic->med_type) { 874 switch (which->bd_media_basic->med_type) {
874 case MAILIMAP_MEDIA_BASIC_APPLICATION: 875 case MAILIMAP_MEDIA_BASIC_APPLICATION:
875 type = "application"; 876 type = "application";
876 break; 877 break;
877 case MAILIMAP_MEDIA_BASIC_AUDIO: 878 case MAILIMAP_MEDIA_BASIC_AUDIO:
878 type = "audio"; 879 type = "audio";
879 break; 880 break;
880 case MAILIMAP_MEDIA_BASIC_IMAGE: 881 case MAILIMAP_MEDIA_BASIC_IMAGE:
881 type = "image"; 882 type = "image";
882 break; 883 break;
883 case MAILIMAP_MEDIA_BASIC_MESSAGE: 884 case MAILIMAP_MEDIA_BASIC_MESSAGE:
884 type = "message"; 885 type = "message";
885 break; 886 break;
886 case MAILIMAP_MEDIA_BASIC_VIDEO: 887 case MAILIMAP_MEDIA_BASIC_VIDEO:
887 type = "video"; 888 type = "video";
888 break; 889 break;
889 case MAILIMAP_MEDIA_BASIC_OTHER: 890 case MAILIMAP_MEDIA_BASIC_OTHER:
890 default: 891 default:
891 if (which->bd_media_basic->med_basic_type) { 892 if (which->bd_media_basic->med_basic_type) {
892 type = which->bd_media_basic->med_basic_type; 893 type = which->bd_media_basic->med_basic_type;
893 } else { 894 } else {
894 type = ""; 895 type = "";
895 } 896 }
896 break; 897 break;
897 } 898 }
898 if (which->bd_media_basic->med_subtype) { 899 if (which->bd_media_basic->med_subtype) {
899 sub = which->bd_media_basic->med_subtype; 900 sub = which->bd_media_basic->med_subtype;
900 } else { 901 } else {
901 sub = ""; 902 sub = "";
902 } 903 }
903 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; 904 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
904 target_part->setType(type.lower()); 905 target_part->setType(type.lower());
905 target_part->setSubtype(sub.lower()); 906 target_part->setSubtype(sub.lower());
906 fillBodyFields(target_part,which->bd_fields); 907 fillBodyFields(target_part,which->bd_fields);
907} 908}
908 909
909void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) 910void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
910{ 911{
911 if (!which) return; 912 if (!which) return;
912 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 913 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
913 clistcell*cur; 914 clistcell*cur;
914 mailimap_single_body_fld_param*param=0; 915 mailimap_single_body_fld_param*param=0;
915 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 916 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
916 param = (mailimap_single_body_fld_param*)cur->data; 917 param = (mailimap_single_body_fld_param*)cur->data;
917 if (param) { 918 if (param) {
918 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 919 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
919 } 920 }
920 } 921 }
921 } 922 }
922 mailimap_body_fld_enc*enc = which->bd_encoding; 923 mailimap_body_fld_enc*enc = which->bd_encoding;
923 QString encoding(""); 924 QString encoding("");
924 switch (enc->enc_type) { 925 switch (enc->enc_type) {
925 case MAILIMAP_BODY_FLD_ENC_7BIT: 926 case MAILIMAP_BODY_FLD_ENC_7BIT:
926 encoding = "7bit"; 927 encoding = "7bit";
927 break; 928 break;
928 case MAILIMAP_BODY_FLD_ENC_8BIT: 929 case MAILIMAP_BODY_FLD_ENC_8BIT:
929 encoding = "8bit"; 930 encoding = "8bit";
930 break; 931 break;
931 case MAILIMAP_BODY_FLD_ENC_BINARY: 932 case MAILIMAP_BODY_FLD_ENC_BINARY:
932 encoding="binary"; 933 encoding="binary";
933 break; 934 break;
934 case MAILIMAP_BODY_FLD_ENC_BASE64: 935 case MAILIMAP_BODY_FLD_ENC_BASE64:
935 encoding="base64"; 936 encoding="base64";
936 break; 937 break;
937 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 938 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
938 encoding="quoted-printable"; 939 encoding="quoted-printable";
939 break; 940 break;
940 case MAILIMAP_BODY_FLD_ENC_OTHER: 941 case MAILIMAP_BODY_FLD_ENC_OTHER:
941 default: 942 default:
942 if (enc->enc_value) { 943 if (enc->enc_value) {
943 char*t=enc->enc_value; 944 char*t=enc->enc_value;
944 encoding=QString(enc->enc_value); 945 encoding=QString(enc->enc_value);
945 enc->enc_value=0L; 946 enc->enc_value=0L;
946 free(t); 947 free(t);
947 } 948 }
948 } 949 }
949 if (which->bd_description) { 950 if (which->bd_description) {
950 target_part->setDescription(QString(which->bd_description)); 951 target_part->setDescription(QString(which->bd_description));
951 } 952 }
952 target_part->setEncoding(encoding); 953 target_part->setEncoding(encoding);
953 target_part->setSize(which->bd_size); 954 target_part->setSize(which->bd_size);
954} 955}
955void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) 956void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
956{ 957{
957 //#if 0 958 //#if 0
958 mailimap_flag_list*flist; 959 mailimap_flag_list*flist;
959 mailimap_set *set; 960 mailimap_set *set;
960 mailimap_store_att_flags * store_flags; 961 mailimap_store_att_flags * store_flags;
961 int err; 962 int err;
962 login(); 963 login();
963 //#endif 964 //#endif
964 if (!m_imap) { 965 if (!m_imap) {
965 return; 966 return;
966 } 967 }
967 int iii = 0; 968 int iii = 0;
968 int count = target.count(); 969 int count = target.count();
969 // qDebug("imap remove count %d ", count); 970 // qDebug("imap remove count %d ", count);
970 971
971 972
972 mMax = count; 973 mMax = count;
973 progress( i18n("Delete")); 974 progress( i18n("Delete"));
974 975
975 QProgressBar wid ( count ); 976 QProgressBar wid ( count );
976 wid.setCaption( i18n("Deleting ...")); 977 wid.setCaption( i18n("Deleting ..."));
977 wid.show(); 978 wid.show();
978 while (iii < count ) { 979 while (iii < count ) {
979 Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); 980 Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count));
980 wid.setProgress( iii ); 981 wid.setProgress( iii );
981 wid.raise(); 982 wid.raise();
982 qApp->processEvents(); 983 qApp->processEvents();
983 RecMailP mail = (*target.at( iii )); 984 RecMailP mail = (*target.at( iii ));
984 //#if 0 985 //#if 0
985 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); 986 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() );
986 err = selectMbox(mail->getMbox()); 987 err = selectMbox(mail->getMbox());
987 if ( err != MAILIMAP_NO_ERROR ) { 988 if ( err != MAILIMAP_NO_ERROR ) {
988 return; 989 return;
989 } 990 }
990 flist = mailimap_flag_list_new_empty(); 991 flist = mailimap_flag_list_new_empty();
991 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 992 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
992 store_flags = mailimap_store_att_flags_new_set_flags(flist); 993 store_flags = mailimap_store_att_flags_new_set_flags(flist);
993 set = mailimap_set_new_single(mail->getNumber()); 994 set = mailimap_set_new_single(mail->getNumber());
994 err = mailimap_store(m_imap,set,store_flags); 995 err = mailimap_store(m_imap,set,store_flags);
995 mailimap_set_free( set ); 996 mailimap_set_free( set );
996 mailimap_store_att_flags_free(store_flags); 997 mailimap_store_att_flags_free(store_flags);
997 998
998 if (err != MAILIMAP_NO_ERROR) { 999 if (err != MAILIMAP_NO_ERROR) {
999 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 1000 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
1000 return; 1001 return;
1001 } 1002 }
1002 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1003 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1003 /* should we realy do that at this moment? */ 1004 /* should we realy do that at this moment? */
1004 1005
1005 // err = mailimap_expunge(m_imap); 1006 // err = mailimap_expunge(m_imap);
1006 //if (err != MAILIMAP_NO_ERROR) { 1007 //if (err != MAILIMAP_NO_ERROR) {
1007 // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); 1008 // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response));
1008 // } 1009 // }
1009 //#endif 1010 //#endif
1010 //deleteMail( mail); 1011 //deleteMail( mail);
1011 ++iii; 1012 ++iii;
1012 } 1013 }
1013 //qDebug("Deleting imap mails... "); 1014 //qDebug("Deleting imap mails... ");
1014 err = mailimap_expunge(m_imap); 1015 err = mailimap_expunge(m_imap);
1015 if (err != MAILIMAP_NO_ERROR) { 1016 if (err != MAILIMAP_NO_ERROR) {
1016 Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); 1017 Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response));
1017 } 1018 }
1018} 1019}
1019void IMAPwrapper::deleteMail(const RecMailP&mail) 1020void IMAPwrapper::deleteMail(const RecMailP&mail)
1020{ 1021{
1021 mailimap_flag_list*flist; 1022 mailimap_flag_list*flist;
1022 mailimap_set *set; 1023 mailimap_set *set;
1023 mailimap_store_att_flags * store_flags; 1024 mailimap_store_att_flags * store_flags;
1024 int err; 1025 int err;
1025 login(); 1026 login();
1026 if (!m_imap) { 1027 if (!m_imap) {
1027 return; 1028 return;
1028 } 1029 }
1029 err = selectMbox(mail->getMbox()); 1030 err = selectMbox(mail->getMbox());
1030 if ( err != MAILIMAP_NO_ERROR ) { 1031 if ( err != MAILIMAP_NO_ERROR ) {
1031 return; 1032 return;
1032 } 1033 }
1033 flist = mailimap_flag_list_new_empty(); 1034 flist = mailimap_flag_list_new_empty();
1034 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1035 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1035 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1036 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1036 set = mailimap_set_new_single(mail->getNumber()); 1037 set = mailimap_set_new_single(mail->getNumber());
1037 err = mailimap_store(m_imap,set,store_flags); 1038 err = mailimap_store(m_imap,set,store_flags);
1038 mailimap_set_free( set ); 1039 mailimap_set_free( set );
1039 mailimap_store_att_flags_free(store_flags); 1040 mailimap_store_att_flags_free(store_flags);
1040 1041
1041 if (err != MAILIMAP_NO_ERROR) { 1042 if (err != MAILIMAP_NO_ERROR) {
1042 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 1043 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
1043 return; 1044 return;
1044 } 1045 }
1045 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1046 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1046 /* should we realy do that at this moment? */ 1047 /* should we realy do that at this moment? */
1047 1048
1048 err = mailimap_expunge(m_imap); 1049 err = mailimap_expunge(m_imap);
1049 if (err != MAILIMAP_NO_ERROR) { 1050 if (err != MAILIMAP_NO_ERROR) {
1050 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); 1051 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response));
1051 } 1052 }
1052 //qDebug("IMAPwrapper::deleteMail 2"); 1053 //qDebug("IMAPwrapper::deleteMail 2");
1053 1054
1054} 1055}
1055 1056
1056void IMAPwrapper::answeredMail(const RecMailP&mail) 1057void IMAPwrapper::answeredMail(const RecMailP&mail)
1057{ 1058{
1058 mailimap_flag_list*flist; 1059 mailimap_flag_list*flist;
1059 mailimap_set *set; 1060 mailimap_set *set;
1060 mailimap_store_att_flags * store_flags; 1061 mailimap_store_att_flags * store_flags;
1061 int err; 1062 int err;
1062 login(); 1063 login();
1063 if (!m_imap) { 1064 if (!m_imap) {
1064 return; 1065 return;
1065 } 1066 }
1066 err = selectMbox(mail->getMbox()); 1067 err = selectMbox(mail->getMbox());
1067 if ( err != MAILIMAP_NO_ERROR ) { 1068 if ( err != MAILIMAP_NO_ERROR ) {
1068 return; 1069 return;
1069 } 1070 }
1070 flist = mailimap_flag_list_new_empty(); 1071 flist = mailimap_flag_list_new_empty();
1071 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 1072 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
1072 store_flags = mailimap_store_att_flags_new_add_flags(flist); 1073 store_flags = mailimap_store_att_flags_new_add_flags(flist);
1073 set = mailimap_set_new_single(mail->getNumber()); 1074 set = mailimap_set_new_single(mail->getNumber());
1074 err = mailimap_store(m_imap,set,store_flags); 1075 err = mailimap_store(m_imap,set,store_flags);
1075 mailimap_set_free( set ); 1076 mailimap_set_free( set );
1076 mailimap_store_att_flags_free(store_flags); 1077 mailimap_store_att_flags_free(store_flags);
1077 1078
1078 if (err != MAILIMAP_NO_ERROR) { 1079 if (err != MAILIMAP_NO_ERROR) {
1079 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; 1080 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
1080 return; 1081 return;
1081 } 1082 }
1082} 1083}
1083 1084
1084QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) 1085QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
1085{ 1086{
1086 QString body(""); 1087 QString body("");
1087 encodedString*res = fetchRawPart(mail,path,internal_call); 1088 encodedString*res = fetchRawPart(mail,path,internal_call);
1088 encodedString*r = decode_String(res,enc); 1089 encodedString*r = decode_String(res,enc);
1089 delete res; 1090 delete res;
1090 if (r) { 1091 if (r) {
1091 if (r->Length()>0) { 1092 if (r->Length()>0) {
1092 body = r->Content(); 1093 body = r->Content();
1093 } 1094 }
1094 delete r; 1095 delete r;
1095 } 1096 }
1096 return body; 1097 return body;
1097} 1098}
1098 1099
1099QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 1100QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
1100{ 1101{
1101 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); 1102 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
1102} 1103}
1103 1104
1104encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) 1105encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
1105{ 1106{
1106 encodedString*res = fetchRawPart(mail,part->Positionlist(),false); 1107 encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
1107 encodedString*r = decode_String(res,part->Encoding()); 1108 encodedString*r = decode_String(res,part->Encoding());
1108 delete res; 1109 delete res;
1109 return r; 1110 return r;
1110} 1111}
1111 1112
1112encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) 1113encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
1113{ 1114{
1114 return fetchRawPart(mail,part->Positionlist(),false); 1115 return fetchRawPart(mail,part->Positionlist(),false);
1115} 1116}
1116 1117
1117int IMAPwrapper::deleteAllMail(const FolderP&folder) 1118int IMAPwrapper::deleteAllMail(const FolderP&folder)
1118{ 1119{
1119 login(); 1120 login();
1120 if (!m_imap) { 1121 if (!m_imap) {
1121 return 0; 1122 return 0;
1122 } 1123 }
1123 mailimap_flag_list*flist; 1124 mailimap_flag_list*flist;
1124 mailimap_set *set; 1125 mailimap_set *set;
1125 mailimap_store_att_flags * store_flags; 1126 mailimap_store_att_flags * store_flags;
1126 int err = selectMbox(folder->getName()); 1127 int err = selectMbox(folder->getName());
1127 if ( err != MAILIMAP_NO_ERROR ) { 1128 if ( err != MAILIMAP_NO_ERROR ) {
1128 return 0; 1129 return 0;
1129 } 1130 }
1130 1131
1131 int last = m_imap->imap_selection_info->sel_exists; 1132 int last = m_imap->imap_selection_info->sel_exists;
1132 if (last == 0) { 1133 if (last == 0) {
1133 Global::statusMessage(i18n("Mailbox has no mails!")); 1134 Global::statusMessage(i18n("Mailbox has no mails!"));
1134 return 0; 1135 return 0;
1135 } 1136 }
1136 flist = mailimap_flag_list_new_empty(); 1137 flist = mailimap_flag_list_new_empty();
1137 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1138 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1138 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1139 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1139 set = mailimap_set_new_interval( 1, last ); 1140 set = mailimap_set_new_interval( 1, last );
1140 err = mailimap_store(m_imap,set,store_flags); 1141 err = mailimap_store(m_imap,set,store_flags);
1141 mailimap_set_free( set ); 1142 mailimap_set_free( set );
1142 mailimap_store_att_flags_free(store_flags); 1143 mailimap_store_att_flags_free(store_flags);
1143 if (err != MAILIMAP_NO_ERROR) { 1144 if (err != MAILIMAP_NO_ERROR) {
1144 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); 1145 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response));
1145 return 0; 1146 return 0;
1146 } 1147 }
1147 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1148 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1148 /* should we realy do that at this moment? */ 1149 /* should we realy do that at this moment? */
1149 err = mailimap_expunge(m_imap); 1150 err = mailimap_expunge(m_imap);
1150 if (err != MAILIMAP_NO_ERROR) { 1151 if (err != MAILIMAP_NO_ERROR) {
1151 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); 1152 Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response));
1152 return 0; 1153 return 0;
1153 } 1154 }
1154 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 1155 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
1155 return 1; 1156 return 1;
1156} 1157}
1157 1158
1158int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) 1159int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
1159{ 1160{
1160 if (folder.length()==0) return 0; 1161 if (folder.length()==0) return 0;
1161 login(); 1162 login();
1162 if (!m_imap) {return 0;} 1163 if (!m_imap) {return 0;}
1163 QString pre = account->getPrefix(); 1164 QString pre = account->getPrefix();
1164 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { 1165 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
1165 pre+=delemiter; 1166 pre+=delemiter;
1166 } 1167 }
1167 if (parentfolder) { 1168 if (parentfolder) {
1168 pre += parentfolder->getDisplayName()+delemiter; 1169 pre += parentfolder->getDisplayName()+delemiter;
1169 } 1170 }
1170 pre+=folder; 1171 pre+=folder;
1171 if (getsubfolder) { 1172 if (getsubfolder) {
1172 if (delemiter.length()>0) { 1173 if (delemiter.length()>0) {
1173 pre+=delemiter; 1174 pre+=delemiter;
1174 } else { 1175 } else {
1175 Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); 1176 Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre));
1176 return 0; 1177 return 0;
1177 } 1178 }
1178 } 1179 }
1179 // odebug << "Creating " << pre.latin1() << "" << oendl; 1180 // odebug << "Creating " << pre.latin1() << "" << oendl;
1180 int res = mailimap_create(m_imap,pre.latin1()); 1181 int res = mailimap_create(m_imap,pre.latin1());
1181 if (res != MAILIMAP_NO_ERROR) { 1182 if (res != MAILIMAP_NO_ERROR) {
1182 Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); 1183 Global::statusMessage(i18n("%1").arg(m_imap->imap_response));
1183 return 0; 1184 return 0;
1184 } 1185 }
1185 return 1; 1186 return 1;
1186} 1187}
1187 1188
1188int IMAPwrapper::deleteMbox(const FolderP&folder) 1189int IMAPwrapper::deleteMbox(const FolderP&folder)
1189{ 1190{
1190 if (!folder) return 0; 1191 if (!folder) return 0;
1191 login(); 1192 login();
1192 if (!m_imap) {return 0;} 1193 if (!m_imap) {return 0;}
1193 int res = mailimap_delete(m_imap,folder->getName()); 1194 int res = mailimap_delete(m_imap,folder->getName());
1194 if (res != MAILIMAP_NO_ERROR) { 1195 if (res != MAILIMAP_NO_ERROR) {
1195 Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); 1196 Global::statusMessage(i18n("%1").arg(m_imap->imap_response));
1196 return 0; 1197 return 0;
1197 } 1198 }
1198 return 1; 1199 return 1;
1199} 1200}
1200 1201
1201void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 1202void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
1202{ 1203{
1203 mailimap_status_att_list * att_list =0; 1204 mailimap_status_att_list * att_list =0;
1204 mailimap_mailbox_data_status * status=0; 1205 mailimap_mailbox_data_status * status=0;
1205 clistiter * cur = 0; 1206 clistiter * cur = 0;
1206 int r = 0; 1207 int r = 0;
1207 target_stat.message_count = 0; 1208 target_stat.message_count = 0;
1208 target_stat.message_unseen = 0; 1209 target_stat.message_unseen = 0;
1209 target_stat.message_recent = 0; 1210 target_stat.message_recent = 0;
1210 login(); 1211 login();
1211 if (!m_imap) { 1212 if (!m_imap) {
1212 return; 1213 return;
1213 } 1214 }
1214 att_list = mailimap_status_att_list_new_empty(); 1215 att_list = mailimap_status_att_list_new_empty();
1215 if (!att_list) return; 1216 if (!att_list) return;
1216 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); 1217 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
1217 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); 1218 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
1218 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); 1219 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
1219 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 1220 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
1220 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { 1221 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
1221 for (cur = clist_begin(status->st_info_list); 1222 for (cur = clist_begin(status->st_info_list);
1222 cur != NULL ; cur = clist_next(cur)) { 1223 cur != NULL ; cur = clist_next(cur)) {
1223 mailimap_status_info * status_info; 1224 mailimap_status_info * status_info;
1224 status_info = (mailimap_status_info *)clist_content(cur); 1225 status_info = (mailimap_status_info *)clist_content(cur);
1225 switch (status_info->st_att) { 1226 switch (status_info->st_att) {
1226 case MAILIMAP_STATUS_ATT_MESSAGES: 1227 case MAILIMAP_STATUS_ATT_MESSAGES:
1227 target_stat.message_count = status_info->st_value; 1228 target_stat.message_count = status_info->st_value;
1228 break; 1229 break;
1229 case MAILIMAP_STATUS_ATT_RECENT: 1230 case MAILIMAP_STATUS_ATT_RECENT:
1230 target_stat.message_recent = status_info->st_value; 1231 target_stat.message_recent = status_info->st_value;
1231 break; 1232 break;
1232 case MAILIMAP_STATUS_ATT_UNSEEN: 1233 case MAILIMAP_STATUS_ATT_UNSEEN:
1233 target_stat.message_unseen = status_info->st_value; 1234 target_stat.message_unseen = status_info->st_value;
1234 break; 1235 break;
1235 } 1236 }
1236 } 1237 }
1237 } else { 1238 } else {
1238 // odebug << "Error retrieving status" << oendl; 1239 // odebug << "Error retrieving status" << oendl;
1239 } 1240 }
1240 if (status) mailimap_mailbox_data_status_free(status); 1241 if (status) mailimap_mailbox_data_status_free(status);
1241 if (att_list) mailimap_status_att_list_free(att_list); 1242 if (att_list) mailimap_status_att_list_free(att_list);
1242} 1243}
1243 1244
1244void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 1245void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
1245{ 1246{
1246 login(); 1247 login();
1247 if (!m_imap) return; 1248 if (!m_imap) return;
1248 if (!msg) return; 1249 if (!msg) return;
1249 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); 1250 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
1250 if (r != MAILIMAP_NO_ERROR) { 1251 if (r != MAILIMAP_NO_ERROR) {
1251 Global::statusMessage("Error storing mail!"); 1252 Global::statusMessage("Error storing mail!");
1252 } 1253 }
1253} 1254}
1254 1255
1255MAILLIB::ATYPE IMAPwrapper::getType()const 1256MAILLIB::ATYPE IMAPwrapper::getType()const
1256{ 1257{
1257 return account->getType(); 1258 return account->getType();
1258} 1259}
1259 1260
1260const QString&IMAPwrapper::getName()const 1261const QString&IMAPwrapper::getName()const
1261{ 1262{
1262 // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; 1263 // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
1263 return account->getAccountName(); 1264 return account->getAccountName();
1264} 1265}
1265 1266
1266encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) 1267encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
1267{ 1268{
1268 // dummy 1269 // dummy
1269 QValueList<int> path; 1270 QValueList<int> path;
1270 return fetchRawPart(mail,path,false); 1271 return fetchRawPart(mail,path,false);
1271} 1272}
1272 1273
1273void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, 1274void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1274 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) 1275 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
1275{ 1276{
1276 if (targetWrapper != this || maxSizeInKb > 0 ) { 1277 if (targetWrapper != this || maxSizeInKb > 0 ) {
1277 mMax = 0; 1278 mMax = 0;
1278 progress( i18n("Copy")); 1279 progress( i18n("Copy"));
1279 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); 1280 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb);
1280 //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); 1281 //qDebug("IMAPwrapper::mvcpAllMails::Using generic");
1281 // odebug << "Using generic" << oendl; 1282 // odebug << "Using generic" << oendl;
1282 return; 1283 return;
1283 } 1284 }
1284 mailimap_set *set = 0; 1285 mailimap_set *set = 0;
1285 login(); 1286 login();
1286 if (!m_imap) { 1287 if (!m_imap) {
1287 return; 1288 return;
1288 } 1289 }
1289 int err = selectMbox(fromFolder->getName()); 1290 int err = selectMbox(fromFolder->getName());
1290 if ( err != MAILIMAP_NO_ERROR ) { 1291 if ( err != MAILIMAP_NO_ERROR ) {
1291 return; 1292 return;
1292 } 1293 }
1293 Global::statusMessage( i18n("Copying mails on server...") ); 1294 Global::statusMessage( i18n("Copying mails on server...") );
1294 int last = m_imap->imap_selection_info->sel_exists; 1295 int last = m_imap->imap_selection_info->sel_exists;
1295 set = mailimap_set_new_interval( 1, last ); 1296 set = mailimap_set_new_interval( 1, last );
1296 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1297 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1297 mailimap_set_free( set ); 1298 mailimap_set_free( set );
1298 if ( err != MAILIMAP_NO_ERROR ) { 1299 if ( err != MAILIMAP_NO_ERROR ) {
1299 QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); 1300 QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response);
1300 Global::statusMessage(error_msg); 1301 Global::statusMessage(error_msg);
1301 // odebug << error_msg << oendl; 1302 // odebug << error_msg << oendl;
1302 return; 1303 return;
1303 } 1304 }
1304 if (moveit) { 1305 if (moveit) {
1305 deleteAllMail(fromFolder); 1306 deleteAllMail(fromFolder);
1306 } 1307 }
1307} 1308}
1308 1309
1309void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1310void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1310{ 1311{
1311 if (targetWrapper != this) { 1312 if (targetWrapper != this) {
1312 // odebug << "Using generic" << oendl; 1313 // odebug << "Using generic" << oendl;
1313 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); 1314 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
1314 return; 1315 return;
1315 } 1316 }
1316 mailimap_set *set = 0; 1317 mailimap_set *set = 0;
1317 login(); 1318 login();
1318 if (!m_imap) { 1319 if (!m_imap) {
1319 return; 1320 return;
1320 } 1321 }
1321 int err = selectMbox(mail->getMbox()); 1322 int err = selectMbox(mail->getMbox());
1322 if ( err != MAILIMAP_NO_ERROR ) { 1323 if ( err != MAILIMAP_NO_ERROR ) {
1323 return; 1324 return;
1324 } 1325 }
1325 set = mailimap_set_new_single(mail->getNumber()); 1326 set = mailimap_set_new_single(mail->getNumber());
1326 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1327 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1327 mailimap_set_free( set ); 1328 mailimap_set_free( set );
1328 if ( err != MAILIMAP_NO_ERROR ) { 1329 if ( err != MAILIMAP_NO_ERROR ) {
1329 QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); 1330 QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response);
1330 Global::statusMessage(error_msg); 1331 Global::statusMessage(error_msg);
1331 // odebug << error_msg << oendl; 1332 // odebug << error_msg << oendl;
1332 return; 1333 return;
1333 } 1334 }
1334 if (moveit) { 1335 if (moveit) {
1335 deleteMail(mail); 1336 deleteMail(mail);
1336 } 1337 }
1337} 1338}
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp
index 40b5591..5d2c0ad 100644
--- a/kmicromail/libmailwrapper/settings.cpp
+++ b/kmicromail/libmailwrapper/settings.cpp
@@ -1,499 +1,500 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <qdir.h> 2#include <qdir.h>
3 3
4//#include <opie2/odebug.h> 4//#include <opie2/odebug.h>
5#include <kconfig.h> 5#include <kconfig.h>
6 6
7#include <kstandarddirs.h> 7#include <kstandarddirs.h>
8#include "settings.h" 8#include "settings.h"
9//#include "defines.h" 9//#include "defines.h"
10 10
11#define IMAP_PORT "143" 11#define IMAP_PORT "143"
12#define IMAP_SSL_PORT "993" 12#define IMAP_SSL_PORT "993"
13#define SMTP_PORT "25" 13#define SMTP_PORT "25"
14#define SMTP_SSL_PORT "465" 14#define SMTP_SSL_PORT "465"
15#define POP3_PORT "110" 15#define POP3_PORT "110"
16#define POP3_SSL_PORT "995" 16#define POP3_SSL_PORT "995"
17#define NNTP_PORT "119" 17#define NNTP_PORT "119"
18#define NNTP_SSL_PORT "563" 18#define NNTP_SSL_PORT "563"
19 19
20 20
21Settings::Settings() 21Settings::Settings()
22 : QObject() 22 : QObject()
23{ 23{
24 updateAccounts(); 24 updateAccounts();
25 //qDebug("++++++++++++++++++new settings ");
25} 26}
26 27
27void Settings::checkDirectory() 28void Settings::checkDirectory()
28{ 29{
29 return; 30 return;
30 locateLocal("data", "kopiemail" ); 31 locateLocal("data", "kopiemail" );
31 /* 32 /*
32 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 33 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
33 system( "mkdir -p $HOME/Applications/opiemail" ); 34 system( "mkdir -p $HOME/Applications/opiemail" );
34 qDebug("$HOME/Applications/opiemail created "); 35 qDebug("$HOME/Applications/opiemail created ");
35 } 36 }
36 */ 37 */
37} 38}
38 39
39QList<Account> Settings::getAccounts() 40QList<Account> Settings::getAccounts()
40{ 41{
41 return accounts; 42 return accounts;
42} 43}
43 44
44void Settings::addAccount( Account *account ) 45void Settings::addAccount( Account *account )
45{ 46{
46 accounts.append( account ); 47 accounts.append( account );
47} 48}
48 49
49void Settings::delAccount( Account *account ) 50void Settings::delAccount( Account *account )
50{ 51{
51 accounts.remove( account ); 52 accounts.remove( account );
52 account->remove(); 53 account->remove();
53} 54}
54 55
55void Settings::updateAccounts() 56void Settings::updateAccounts()
56{ 57{
57 accounts.clear(); 58 accounts.clear();
58 QDir dir( locateLocal("data", "kopiemail" ) ); 59 QDir dir( locateLocal("data", "kopiemail" ) );
59 QStringList::Iterator it; 60 QStringList::Iterator it;
60 61
61 QStringList imap = dir.entryList( "imap-*" ); 62 QStringList imap = dir.entryList( "imap-*" );
62 for ( it = imap.begin(); it != imap.end(); it++ ) { 63 for ( it = imap.begin(); it != imap.end(); it++ ) {
63 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 64 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
64 accounts.append( account ); 65 accounts.append( account );
65 } 66 }
66 67
67 QStringList pop3 = dir.entryList( "pop3-*" ); 68 QStringList pop3 = dir.entryList( "pop3-*" );
68 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 69 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
69 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 70 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
70 accounts.append( account ); 71 accounts.append( account );
71 } 72 }
72 73
73 QStringList smtp = dir.entryList( "smtp-*" ); 74 QStringList smtp = dir.entryList( "smtp-*" );
74 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 75 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
75 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 76 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
76 accounts.append( account ); 77 accounts.append( account );
77 } 78 }
78 79
79 QStringList nntp = dir.entryList( "nntp-*" ); 80 QStringList nntp = dir.entryList( "nntp-*" );
80 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 81 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
81 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 82 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
82 accounts.append( account ); 83 accounts.append( account );
83 } 84 }
84 85
85 readAccounts(); 86 readAccounts();
86} 87}
87 88
88void Settings::saveAccounts() 89void Settings::saveAccounts()
89{ 90{
90 checkDirectory(); 91 checkDirectory();
91 Account *it; 92 Account *it;
92 93
93 for ( it = accounts.first(); it; it = accounts.next() ) { 94 for ( it = accounts.first(); it; it = accounts.next() ) {
94 it->save(); 95 it->save();
95 } 96 }
96} 97}
97 98
98void Settings::readAccounts() 99void Settings::readAccounts()
99{ 100{
100 checkDirectory(); 101 checkDirectory();
101 Account *it; 102 Account *it;
102 103
103 for ( it = accounts.first(); it; it = accounts.next() ) { 104 for ( it = accounts.first(); it; it = accounts.next() ) {
104 it->read(); 105 it->read();
105 } 106 }
106} 107}
107 108
108Account::Account() 109Account::Account()
109{ 110{
110 accountName = "changeMe"; 111 accountName = "changeMe";
111 type = MAILLIB::A_UNDEFINED; 112 type = MAILLIB::A_UNDEFINED;
112 ssl = false; 113 ssl = false;
113 connectionType = 1; 114 connectionType = 1;
114 offline = false; 115 offline = false;
115 maxMailSize = 0; 116 maxMailSize = 0;
116 lastFetch; 117 lastFetch;
117 leaveOnServer = false; 118 leaveOnServer = false;
118} 119}
119 120
120void Account::remove() 121void Account::remove()
121{ 122{
122 QFile file( getFileName() ); 123 QFile file( getFileName() );
123 file.remove(); 124 file.remove();
124} 125}
125 126
126void Account::setPasswordList(const QStringList &str) 127void Account::setPasswordList(const QStringList &str)
127{ 128{
128 password = ""; 129 password = "";
129 int i; 130 int i;
130 for ( i = 0; i < str.count() ; ++i ) { 131 for ( i = 0; i < str.count() ; ++i ) {
131 QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); 132 QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3)));
132 password.append( c ); 133 password.append( c );
133 } 134 }
134 //qDebug("password %s ", password.latin1()); 135 //qDebug("password %s ", password.latin1());
135} 136}
136QStringList Account::getPasswordList() 137QStringList Account::getPasswordList()
137{ 138{
138 int i; 139 int i;
139 int len = password.length(); 140 int len = password.length();
140 QStringList str; 141 QStringList str;
141 142
142 for ( i = 0; i < len ; ++i ) { 143 for ( i = 0; i < len ; ++i ) {
143 int val = password.at(i).unicode()*(len-(i%3))+131; 144 int val = password.at(i).unicode()*(len-(i%3))+131;
144 str.append( QString::number( val ) ); 145 str.append( QString::number( val ) );
145 // qDebug("append %s ", str[i].latin1()); 146 // qDebug("append %s ", str[i].latin1());
146 } 147 }
147 return str; 148 return str;
148} 149}
149 150
150IMAPaccount::IMAPaccount() 151IMAPaccount::IMAPaccount()
151 : Account() 152 : Account()
152{ 153{
153 file = IMAPaccount::getUniqueFileName(); 154 file = IMAPaccount::getUniqueFileName();
154 accountName = "New IMAP Account"; 155 accountName = "New IMAP Account";
155 ssl = false; 156 ssl = false;
156 connectionType = 1; 157 connectionType = 1;
157 type = MAILLIB::A_IMAP; 158 type = MAILLIB::A_IMAP;
158 port = IMAP_PORT; 159 port = IMAP_PORT;
159} 160}
160 161
161IMAPaccount::IMAPaccount( QString filename ) 162IMAPaccount::IMAPaccount( QString filename )
162 : Account() 163 : Account()
163{ 164{
164 file = filename; 165 file = filename;
165 accountName = "New IMAP Account"; 166 accountName = "New IMAP Account";
166 ssl = false; 167 ssl = false;
167 connectionType = 1; 168 connectionType = 1;
168 type = MAILLIB::A_IMAP; 169 type = MAILLIB::A_IMAP;
169 port = IMAP_PORT; 170 port = IMAP_PORT;
170} 171}
171 172
172QString IMAPaccount::getUniqueFileName() 173QString IMAPaccount::getUniqueFileName()
173{ 174{
174 int num = 0; 175 int num = 0;
175 QString unique; 176 QString unique;
176 177
177 QDir dir( locateLocal("data", "kopiemail" ) ); 178 QDir dir( locateLocal("data", "kopiemail" ) );
178 179
179 QStringList imap = dir.entryList( "imap-*" ); 180 QStringList imap = dir.entryList( "imap-*" );
180 do { 181 do {
181 unique.setNum( num++ ); 182 unique.setNum( num++ );
182 } while ( imap.contains( "imap-" + unique ) > 0 ); 183 } while ( imap.contains( "imap-" + unique ) > 0 );
183 184
184 return unique; 185 return unique;
185} 186}
186 187
187void IMAPaccount::read() 188void IMAPaccount::read()
188{ 189{
189 KConfig *conf = new KConfig( getFileName() ); 190 KConfig *conf = new KConfig( getFileName() );
190 conf->setGroup( "IMAP Account" ); 191 conf->setGroup( "IMAP Account" );
191 accountName = conf->readEntry( "Account","" ); 192 accountName = conf->readEntry( "Account","" );
192 if (accountName.isNull()) accountName = ""; 193 if (accountName.isNull()) accountName = "";
193 server = conf->readEntry( "Server","" ); 194 server = conf->readEntry( "Server","" );
194 if (server.isNull()) server=""; 195 if (server.isNull()) server="";
195 port = conf->readEntry( "Port","" ); 196 port = conf->readEntry( "Port","" );
196 if (port.isNull()) port="143"; 197 if (port.isNull()) port="143";
197 connectionType = conf->readNumEntry( "ConnectionType" ); 198 connectionType = conf->readNumEntry( "ConnectionType" );
198 ssl = conf->readBoolEntry( "SSL",false ); 199 ssl = conf->readBoolEntry( "SSL",false );
199 user = conf->readEntry( "User","" ); 200 user = conf->readEntry( "User","" );
200 if (user.isNull()) user = ""; 201 if (user.isNull()) user = "";
201 //password = conf->readEntryCrypt( "Password","" ); 202 //password = conf->readEntryCrypt( "Password","" );
202 setPasswordList( conf->readListEntry( "FolderHistory")); 203 setPasswordList( conf->readListEntry( "FolderHistory"));
203 if (password.isNull()) password = ""; 204 if (password.isNull()) password = "";
204 prefix = conf->readEntry("MailPrefix",""); 205 prefix = conf->readEntry("MailPrefix","");
205 if (prefix.isNull()) prefix = ""; 206 if (prefix.isNull()) prefix = "";
206 offline = conf->readBoolEntry("Offline",false); 207 offline = conf->readBoolEntry("Offline",false);
207 localFolder = conf->readEntry( "LocalFolder" ); 208 localFolder = conf->readEntry( "LocalFolder" );
208 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 209 maxMailSize = conf->readNumEntry( "MaxSize",0 );
209 int lf = conf->readNumEntry( "LastFetch",0 ); 210 int lf = conf->readNumEntry( "LastFetch",0 );
210 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 211 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
211 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 212 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
212 if ( lf < 0 ) lf = 0; 213 if ( lf < 0 ) lf = 0;
213 lastFetch = dt.addSecs( lf ); 214 lastFetch = dt.addSecs( lf );
214 delete conf; 215 delete conf;
215} 216}
216 217
217void IMAPaccount::save() 218void IMAPaccount::save()
218{ 219{
219 220
220 Settings::checkDirectory(); 221 Settings::checkDirectory();
221 222
222 KConfig *conf = new KConfig( getFileName() ); 223 KConfig *conf = new KConfig( getFileName() );
223 conf->setGroup( "IMAP Account" ); 224 conf->setGroup( "IMAP Account" );
224 conf->writeEntry( "Account", accountName ); 225 conf->writeEntry( "Account", accountName );
225 conf->writeEntry( "Server", server ); 226 conf->writeEntry( "Server", server );
226 conf->writeEntry( "Port", port ); 227 conf->writeEntry( "Port", port );
227 conf->writeEntry( "SSL", ssl ); 228 conf->writeEntry( "SSL", ssl );
228 conf->writeEntry( "ConnectionType", connectionType ); 229 conf->writeEntry( "ConnectionType", connectionType );
229 conf->writeEntry( "User", user ); 230 conf->writeEntry( "User", user );
230 //conf->writeEntryCrypt( "Password", password ); 231 //conf->writeEntryCrypt( "Password", password );
231 conf->writeEntry( "FolderHistory",getPasswordList() ); 232 conf->writeEntry( "FolderHistory",getPasswordList() );
232 conf->writeEntry( "MailPrefix",prefix); 233 conf->writeEntry( "MailPrefix",prefix);
233 conf->writeEntry( "Offline",offline); 234 conf->writeEntry( "Offline",offline);
234 conf->writeEntry( "LocalFolder", localFolder ); 235 conf->writeEntry( "LocalFolder", localFolder );
235 conf->writeEntry( "MaxSize", maxMailSize ); 236 conf->writeEntry( "MaxSize", maxMailSize );
236 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 237 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
237 int lf = dt.secsTo ( lastFetch ); 238 int lf = dt.secsTo ( lastFetch );
238 conf->writeEntry( "LastFetch", lf ); 239 conf->writeEntry( "LastFetch", lf );
239 conf->writeEntry( "LeaveOnServer", leaveOnServer); 240 conf->writeEntry( "LeaveOnServer", leaveOnServer);
240 conf->sync(); 241 conf->sync();
241 delete conf; 242 delete conf;
242} 243}
243 244
244 245
245QString IMAPaccount::getFileName() 246QString IMAPaccount::getFileName()
246{ 247{
247 return locateLocal("data", "kopiemail" ) +"/imap-" + file; 248 return locateLocal("data", "kopiemail" ) +"/imap-" + file;
248} 249}
249 250
250POP3account::POP3account() 251POP3account::POP3account()
251 : Account() 252 : Account()
252{ 253{
253 file = POP3account::getUniqueFileName(); 254 file = POP3account::getUniqueFileName();
254 accountName = "New POP3 Account"; 255 accountName = "New POP3 Account";
255 ssl = false; 256 ssl = false;
256 connectionType = 1; 257 connectionType = 1;
257 type = MAILLIB::A_POP3; 258 type = MAILLIB::A_POP3;
258 port = POP3_PORT; 259 port = POP3_PORT;
259} 260}
260 261
261POP3account::POP3account( QString filename ) 262POP3account::POP3account( QString filename )
262 : Account() 263 : Account()
263{ 264{
264 file = filename; 265 file = filename;
265 accountName = "New POP3 Account"; 266 accountName = "New POP3 Account";
266 ssl = false; 267 ssl = false;
267 connectionType = 1; 268 connectionType = 1;
268 type = MAILLIB::A_POP3; 269 type = MAILLIB::A_POP3;
269 port = POP3_PORT; 270 port = POP3_PORT;
270} 271}
271 272
272QString POP3account::getUniqueFileName() 273QString POP3account::getUniqueFileName()
273{ 274{
274 int num = 0; 275 int num = 0;
275 QString unique; 276 QString unique;
276 277
277 QDir dir( locateLocal("data", "kopiemail" ) ); 278 QDir dir( locateLocal("data", "kopiemail" ) );
278 279
279 QStringList imap = dir.entryList( "pop3-*" ); 280 QStringList imap = dir.entryList( "pop3-*" );
280 do { 281 do {
281 unique.setNum( num++ ); 282 unique.setNum( num++ );
282 } while ( imap.contains( "pop3-" + unique ) > 0 ); 283 } while ( imap.contains( "pop3-" + unique ) > 0 );
283 284
284 return unique; 285 return unique;
285} 286}
286 287
287void POP3account::read() 288void POP3account::read()
288{ 289{
289 KConfig *conf = new KConfig( getFileName()); 290 KConfig *conf = new KConfig( getFileName());
290 conf->setGroup( "POP3 Account" ); 291 conf->setGroup( "POP3 Account" );
291 accountName = conf->readEntry( "Account" ); 292 accountName = conf->readEntry( "Account" );
292 server = conf->readEntry( "Server" ); 293 server = conf->readEntry( "Server" );
293 port = conf->readEntry( "Port" ); 294 port = conf->readEntry( "Port" );
294 ssl = conf->readBoolEntry( "SSL" ); 295 ssl = conf->readBoolEntry( "SSL" );
295 connectionType = conf->readNumEntry( "ConnectionType" ); 296 connectionType = conf->readNumEntry( "ConnectionType" );
296 user = conf->readEntry( "User" ); 297 user = conf->readEntry( "User" );
297 //password = conf->readEntryCrypt( "Password" ); 298 //password = conf->readEntryCrypt( "Password" );
298 setPasswordList( conf->readListEntry( "FolderHistory")); 299 setPasswordList( conf->readListEntry( "FolderHistory"));
299 offline = conf->readBoolEntry("Offline",false); 300 offline = conf->readBoolEntry("Offline",false);
300 localFolder = conf->readEntry( "LocalFolder" ); 301 localFolder = conf->readEntry( "LocalFolder" );
301 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 302 maxMailSize = conf->readNumEntry( "MaxSize",0 );
302 int lf = conf->readNumEntry( "LastFetch",0 ); 303 int lf = conf->readNumEntry( "LastFetch",0 );
303 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 304 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
304 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 305 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
305 lastFetch = dt.addSecs( lf ); 306 lastFetch = dt.addSecs( lf );
306 delete conf; 307 delete conf;
307} 308}
308 309
309void POP3account::save() 310void POP3account::save()
310{ 311{
311 Settings::checkDirectory(); 312 Settings::checkDirectory();
312 313
313 KConfig *conf = new KConfig( getFileName() ); 314 KConfig *conf = new KConfig( getFileName() );
314 conf->setGroup( "POP3 Account" ); 315 conf->setGroup( "POP3 Account" );
315 conf->writeEntry( "Account", accountName ); 316 conf->writeEntry( "Account", accountName );
316 conf->writeEntry( "Server", server ); 317 conf->writeEntry( "Server", server );
317 conf->writeEntry( "Port", port ); 318 conf->writeEntry( "Port", port );
318 conf->writeEntry( "SSL", ssl ); 319 conf->writeEntry( "SSL", ssl );
319 conf->writeEntry( "ConnectionType", connectionType ); 320 conf->writeEntry( "ConnectionType", connectionType );
320 conf->writeEntry( "User", user ); 321 conf->writeEntry( "User", user );
321 //conf->writeEntryCrypt( "Password", password ); 322 //conf->writeEntryCrypt( "Password", password );
322 conf->writeEntry( "FolderHistory",getPasswordList() ); 323 conf->writeEntry( "FolderHistory",getPasswordList() );
323 conf->writeEntry( "Offline",offline); 324 conf->writeEntry( "Offline",offline);
324 conf->writeEntry( "LocalFolder", localFolder ); 325 conf->writeEntry( "LocalFolder", localFolder );
325 conf->writeEntry( "MaxSize", maxMailSize ); 326 conf->writeEntry( "MaxSize", maxMailSize );
326 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 327 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
327 int lf = dt.secsTo ( lastFetch ); 328 int lf = dt.secsTo ( lastFetch );
328 conf->writeEntry( "LastFetch", lf ); 329 conf->writeEntry( "LastFetch", lf );
329 conf->writeEntry( "LeaveOnServer", leaveOnServer); 330 conf->writeEntry( "LeaveOnServer", leaveOnServer);
330 conf->sync(); 331 conf->sync();
331 delete conf; 332 delete conf;
332} 333}
333 334
334 335
335QString POP3account::getFileName() 336QString POP3account::getFileName()
336{ 337{
337 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 338 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
338} 339}
339 340
340SMTPaccount::SMTPaccount() 341SMTPaccount::SMTPaccount()
341 : Account() 342 : Account()
342{ 343{
343 file = SMTPaccount::getUniqueFileName(); 344 file = SMTPaccount::getUniqueFileName();
344 accountName = "New SMTP Account"; 345 accountName = "New SMTP Account";
345 ssl = false; 346 ssl = false;
346 connectionType = 1; 347 connectionType = 1;
347 login = false; 348 login = false;
348 useCC = false; 349 useCC = false;
349 useBCC = false; 350 useBCC = false;
350 useReply = false; 351 useReply = false;
351 type = MAILLIB::A_SMTP; 352 type = MAILLIB::A_SMTP;
352 port = SMTP_PORT; 353 port = SMTP_PORT;
353} 354}
354 355
355SMTPaccount::SMTPaccount( QString filename ) 356SMTPaccount::SMTPaccount( QString filename )
356 : Account() 357 : Account()
357{ 358{
358 file = filename; 359 file = filename;
359 accountName = "New SMTP Account"; 360 accountName = "New SMTP Account";
360 ssl = false; 361 ssl = false;
361 connectionType = 1; 362 connectionType = 1;
362 login = false; 363 login = false;
363 type = MAILLIB::A_SMTP; 364 type = MAILLIB::A_SMTP;
364 port = SMTP_PORT; 365 port = SMTP_PORT;
365} 366}
366 367
367QString SMTPaccount::getUniqueFileName() 368QString SMTPaccount::getUniqueFileName()
368{ 369{
369 int num = 0; 370 int num = 0;
370 QString unique; 371 QString unique;
371 372
372 QDir dir( locateLocal("data", "kopiemail" ) ); 373 QDir dir( locateLocal("data", "kopiemail" ) );
373 374
374 QStringList imap = dir.entryList( "smtp-*" ); 375 QStringList imap = dir.entryList( "smtp-*" );
375 do { 376 do {
376 unique.setNum( num++ ); 377 unique.setNum( num++ );
377 } while ( imap.contains( "smtp-" + unique ) > 0 ); 378 } while ( imap.contains( "smtp-" + unique ) > 0 );
378 379
379 return unique; 380 return unique;
380} 381}
381 382
382void SMTPaccount::read() 383void SMTPaccount::read()
383{ 384{
384 KConfig *conf = new KConfig( getFileName() ); 385 KConfig *conf = new KConfig( getFileName() );
385 conf->setGroup( "SMTP Account" ); 386 conf->setGroup( "SMTP Account" );
386 accountName = conf->readEntry( "Account" ); 387 accountName = conf->readEntry( "Account" );
387 server = conf->readEntry( "Server" ); 388 server = conf->readEntry( "Server" );
388 port = conf->readEntry( "Port" ); 389 port = conf->readEntry( "Port" );
389 ssl = conf->readBoolEntry( "SSL" ); 390 ssl = conf->readBoolEntry( "SSL" );
390 connectionType = conf->readNumEntry( "ConnectionType" ); 391 connectionType = conf->readNumEntry( "ConnectionType" );
391 login = conf->readBoolEntry( "Login" ); 392 login = conf->readBoolEntry( "Login" );
392 user = conf->readEntry( "User" ); 393 user = conf->readEntry( "User" );
393 //password = conf->readEntryCrypt( "Password" ); 394 //password = conf->readEntryCrypt( "Password" );
394 setPasswordList( conf->readListEntry( "FolderHistory")); 395 setPasswordList( conf->readListEntry( "FolderHistory"));
395 delete conf; 396 delete conf;
396} 397}
397 398
398void SMTPaccount::save() 399void SMTPaccount::save()
399{ 400{
400 Settings::checkDirectory(); 401 Settings::checkDirectory();
401 402
402 KConfig *conf = new KConfig( getFileName() ); 403 KConfig *conf = new KConfig( getFileName() );
403 conf->setGroup( "SMTP Account" ); 404 conf->setGroup( "SMTP Account" );
404 conf->writeEntry( "Account", accountName ); 405 conf->writeEntry( "Account", accountName );
405 conf->writeEntry( "Server", server ); 406 conf->writeEntry( "Server", server );
406 conf->writeEntry( "Port", port ); 407 conf->writeEntry( "Port", port );
407 conf->writeEntry( "SSL", ssl ); 408 conf->writeEntry( "SSL", ssl );
408 conf->writeEntry( "ConnectionType", connectionType ); 409 conf->writeEntry( "ConnectionType", connectionType );
409 conf->writeEntry( "Login", login ); 410 conf->writeEntry( "Login", login );
410 conf->writeEntry( "User", user ); 411 conf->writeEntry( "User", user );
411 //conf->writeEntryCrypt( "Password", password ); 412 //conf->writeEntryCrypt( "Password", password );
412 conf->writeEntry( "FolderHistory",getPasswordList() ); 413 conf->writeEntry( "FolderHistory",getPasswordList() );
413 conf->sync(); 414 conf->sync();
414 delete conf; 415 delete conf;
415} 416}
416 417
417 418
418QString SMTPaccount::getFileName() 419QString SMTPaccount::getFileName()
419{ 420{
420 return locateLocal("data", "kopiemail" ) +"/smtp-" + file; 421 return locateLocal("data", "kopiemail" ) +"/smtp-" + file;
421} 422}
422 423
423NNTPaccount::NNTPaccount() 424NNTPaccount::NNTPaccount()
424 : Account() 425 : Account()
425{ 426{
426 file = NNTPaccount::getUniqueFileName(); 427 file = NNTPaccount::getUniqueFileName();
427 accountName = "New NNTP Account"; 428 accountName = "New NNTP Account";
428 ssl = false; 429 ssl = false;
429 login = false; 430 login = false;
430 type = MAILLIB::A_NNTP; 431 type = MAILLIB::A_NNTP;
431 port = NNTP_PORT; 432 port = NNTP_PORT;
432} 433}
433 434
434NNTPaccount::NNTPaccount( QString filename ) 435NNTPaccount::NNTPaccount( QString filename )
435 : Account() 436 : Account()
436{ 437{
437 file = filename; 438 file = filename;
438 accountName = "New NNTP Account"; 439 accountName = "New NNTP Account";
439 ssl = false; 440 ssl = false;
440 login = false; 441 login = false;
441 type = MAILLIB::A_NNTP; 442 type = MAILLIB::A_NNTP;
442 port = NNTP_PORT; 443 port = NNTP_PORT;
443} 444}
444 445
445QString NNTPaccount::getUniqueFileName() 446QString NNTPaccount::getUniqueFileName()
446{ 447{
447 int num = 0; 448 int num = 0;
448 QString unique; 449 QString unique;
449 450
450 QDir dir( locateLocal("data", "kopiemail" ) ); 451 QDir dir( locateLocal("data", "kopiemail" ) );
451 452
452 QStringList imap = dir.entryList( "nntp-*" ); 453 QStringList imap = dir.entryList( "nntp-*" );
453 do { 454 do {
454 unique.setNum( num++ ); 455 unique.setNum( num++ );
455 } while ( imap.contains( "nntp-" + unique ) > 0 ); 456 } while ( imap.contains( "nntp-" + unique ) > 0 );
456 457
457 return unique; 458 return unique;
458} 459}
459 460
460void NNTPaccount::read() 461void NNTPaccount::read()
461{ 462{
462 KConfig *conf = new KConfig( getFileName() ); 463 KConfig *conf = new KConfig( getFileName() );
463 conf->setGroup( "NNTP Account" ); 464 conf->setGroup( "NNTP Account" );
464 accountName = conf->readEntry( "Account" ); 465 accountName = conf->readEntry( "Account" );
465 server = conf->readEntry( "Server" ); 466 server = conf->readEntry( "Server" );
466 port = conf->readEntry( "Port" ); 467 port = conf->readEntry( "Port" );
467 ssl = conf->readBoolEntry( "SSL" ); 468 ssl = conf->readBoolEntry( "SSL" );
468 login = conf->readBoolEntry( "Login" ); 469 login = conf->readBoolEntry( "Login" );
469 user = conf->readEntry( "User" ); 470 user = conf->readEntry( "User" );
470 //password = conf->readEntryCrypt( "Password" ); 471 //password = conf->readEntryCrypt( "Password" );
471 setPasswordList( conf->readListEntry( "FolderHistory")); 472 setPasswordList( conf->readListEntry( "FolderHistory"));
472 subscribedGroups = conf->readListEntry( "Subscribed"); 473 subscribedGroups = conf->readListEntry( "Subscribed");
473 delete conf; 474 delete conf;
474} 475}
475 476
476void NNTPaccount::save() 477void NNTPaccount::save()
477{ 478{
478 Settings::checkDirectory(); 479 Settings::checkDirectory();
479 480
480 KConfig *conf = new KConfig( getFileName() ); 481 KConfig *conf = new KConfig( getFileName() );
481 conf->setGroup( "NNTP Account" ); 482 conf->setGroup( "NNTP Account" );
482 conf->writeEntry( "Account", accountName ); 483 conf->writeEntry( "Account", accountName );
483 conf->writeEntry( "Server", server ); 484 conf->writeEntry( "Server", server );
484 conf->writeEntry( "Port", port ); 485 conf->writeEntry( "Port", port );
485 conf->writeEntry( "SSL", ssl ); 486 conf->writeEntry( "SSL", ssl );
486 conf->writeEntry( "Login", login ); 487 conf->writeEntry( "Login", login );
487 conf->writeEntry( "User", user ); 488 conf->writeEntry( "User", user );
488 //conf->writeEntryCrypt( "Password", password ); 489 //conf->writeEntryCrypt( "Password", password );
489 conf->writeEntry( "FolderHistory",getPasswordList() ); 490 conf->writeEntry( "FolderHistory",getPasswordList() );
490 conf->writeEntry( "Subscribed" , subscribedGroups ); 491 conf->writeEntry( "Subscribed" , subscribedGroups );
491 conf->sync(); 492 conf->sync();
492 delete conf; 493 delete conf;
493} 494}
494 495
495 496
496QString NNTPaccount::getFileName() 497QString NNTPaccount::getFileName()
497{ 498{
498 return locateLocal("data", "kopiemail" ) +"/nntp-" + file; 499 return locateLocal("data", "kopiemail" ) +"/nntp-" + file;
499} 500}
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h
index 79567ef..c996fe0 100644
--- a/kmicromail/libmailwrapper/settings.h
+++ b/kmicromail/libmailwrapper/settings.h
@@ -1,181 +1,182 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include "maildefines.h" 4#include "maildefines.h"
5 5
6/* OPIE */ 6/* OPIE */
7 7
8/* QT */ 8/* QT */
9#include <qobject.h> 9#include <qobject.h>
10#include <qlist.h> 10#include <qlist.h>
11#include <qstringlist.h> 11#include <qstringlist.h>
12#include <qdatetime.h> 12#include <qdatetime.h>
13 13
14class Account 14class Account
15{ 15{
16 16
17public: 17public:
18 Account(); 18 Account();
19 virtual ~Account() {} 19 virtual ~Account() {}
20 20
21 void remove(); 21 void remove();
22 void setAccountName( QString name ) { accountName = name; } 22 void setAccountName( QString name ) { accountName = name; }
23 const QString&getAccountName()const{ return accountName; } 23 const QString&getAccountName()const{ return accountName; }
24 MAILLIB::ATYPE getType()const{ return type; } 24 MAILLIB::ATYPE getType()const{ return type; }
25 25
26 void setServer(const QString&str){ server = str; } 26 void setServer(const QString&str){ server = str; }
27 const QString&getServer()const{ return server; } 27 const QString&getServer()const{ return server; }
28 28
29 void setLocalFolder( QString name ) { localFolder = name; } 29 void setLocalFolder( QString name ) { localFolder = name; }
30 const QString& getLocalFolder()const{ return localFolder; } 30 const QString& getLocalFolder()const{ return localFolder; }
31 31
32 void setPort(const QString&str) { port = str; } 32 void setPort(const QString&str) { port = str; }
33 const QString&getPort()const{ return port; } 33 const QString&getPort()const{ return port; }
34 34
35 void setUser(const QString&str){ user = str; } 35 void setUser(const QString&str){ user = str; }
36 const QString&getUser()const{ return user; } 36 const QString&getUser()const{ return user; }
37 37
38 void setPassword(const QString&str) { password = str; } 38 void setPassword(const QString&str) { password = str; }
39 const QString&getPassword()const { return password; } 39 const QString&getPassword()const { return password; }
40 40
41 void setPasswordList(const QStringList &str); 41 void setPasswordList(const QStringList &str);
42 QStringList getPasswordList(); 42 QStringList getPasswordList();
43 43
44 void setSSL( bool b ) { ssl = b; } 44 void setSSL( bool b ) { ssl = b; }
45 bool getSSL() { return ssl; } 45 bool getSSL() { return ssl; }
46 46
47 void setConnectionType( int x ) { connectionType = x; } 47 void setConnectionType( int x ) { connectionType = x; }
48 int ConnectionType() { return connectionType; } 48 int ConnectionType() { return connectionType; }
49 49
50 void setMaxMailSize( int x ) { maxMailSize = x; } 50 void setMaxMailSize( int x ) { maxMailSize = x; }
51 int getMaxMailSize() { return maxMailSize; } 51 int getMaxMailSize() { return maxMailSize; }
52 52
53 void setOffline(bool b) {offline = b;} 53 void setOffline(bool b) {offline = b;}
54 bool getOffline()const{return offline;} 54 bool getOffline()const{return offline;}
55 55
56 bool getLeaveOnServer(){ return leaveOnServer;} 56 bool getLeaveOnServer(){ return leaveOnServer;}
57 void setLeaveOnServer(bool b){ leaveOnServer = b;} 57 void setLeaveOnServer(bool b){ leaveOnServer = b;}
58 58
59 virtual QString getFileName() { return accountName; } 59 virtual QString getFileName() { return accountName; }
60 virtual void read() { ; } 60 virtual void read() { ; }
61 virtual void save() { ; } 61 virtual void save() { ; }
62 62
63protected: 63protected:
64 QString accountName, server, port, user, password; 64 QString accountName, server, port, user, password;
65 bool ssl; 65 bool ssl;
66 int connectionType; 66 int connectionType;
67 bool offline; 67 bool offline;
68 MAILLIB::ATYPE type; 68 MAILLIB::ATYPE type;
69 QString localFolder; 69 QString localFolder;
70 int maxMailSize; 70 int maxMailSize;
71 QDateTime lastFetch; 71 QDateTime lastFetch;
72 bool leaveOnServer; 72 bool leaveOnServer;
73}; 73};
74 74
75class IMAPaccount : public Account 75class IMAPaccount : public Account
76{ 76{
77 77
78public: 78public:
79 IMAPaccount(); 79 IMAPaccount();
80 IMAPaccount( QString filename ); 80 IMAPaccount( QString filename );
81 81
82 static QString getUniqueFileName(); 82 static QString getUniqueFileName();
83 83
84 virtual void read(); 84 virtual void read();
85 virtual void save(); 85 virtual void save();
86 virtual QString getFileName(); 86 virtual QString getFileName();
87 87
88 void setPrefix(const QString&str) {prefix=str;} 88 void setPrefix(const QString&str) {prefix=str;}
89 const QString&getPrefix()const{return prefix;} 89 const QString&getPrefix()const{return prefix;}
90 90
91private: 91private:
92 QString file,prefix; 92 QString file,prefix;
93 93
94}; 94};
95 95
96class POP3account : public Account 96class POP3account : public Account
97{ 97{
98 98
99public: 99public:
100 POP3account(); 100 POP3account();
101 POP3account( QString filename ); 101 POP3account( QString filename );
102 102
103 static QString getUniqueFileName(); 103 static QString getUniqueFileName();
104 104
105 virtual void read(); 105 virtual void read();
106 virtual void save(); 106 virtual void save();
107 virtual QString getFileName(); 107 virtual QString getFileName();
108 108
109private: 109private:
110 QString file; 110 QString file;
111 111
112}; 112};
113 113
114class SMTPaccount : public Account 114class SMTPaccount : public Account
115{ 115{
116 116
117public: 117public:
118 SMTPaccount(); 118 SMTPaccount();
119 SMTPaccount( QString filename ); 119 SMTPaccount( QString filename );
120 120
121 static QString getUniqueFileName(); 121 static QString getUniqueFileName();
122 122
123 virtual void read(); 123 virtual void read();
124 virtual void save(); 124 virtual void save();
125 virtual QString getFileName(); 125 virtual QString getFileName();
126 126
127 void setLogin( bool b ) { login = b; } 127 void setLogin( bool b ) { login = b; }
128 bool getLogin() { return login; } 128 bool getLogin() { return login; }
129 129
130private: 130private:
131 QString file, name, mail, org, cc, bcc, reply, signature; 131 QString file, name, mail, org, cc, bcc, reply, signature;
132 bool useCC, useBCC, useReply, login; 132 bool useCC, useBCC, useReply, login;
133 133
134}; 134};
135 135
136class NNTPaccount : public Account 136class NNTPaccount : public Account
137{ 137{
138 138
139public: 139public:
140 NNTPaccount(); 140 NNTPaccount();
141 NNTPaccount( QString filename ); 141 NNTPaccount( QString filename );
142 142
143 static QString getUniqueFileName(); 143 static QString getUniqueFileName();
144 144
145 virtual void read(); 145 virtual void read();
146 virtual void save(); 146 virtual void save();
147 virtual QString getFileName(); 147 virtual QString getFileName();
148 148
149 void setLogin( bool b ) { login = b; } 149 void setLogin( bool b ) { login = b; }
150 bool getLogin() { return login; } 150 bool getLogin() { return login; }
151 151
152 void setGroups( QStringList list ) { subscribedGroups = list; } 152 void setGroups( QStringList list ) { subscribedGroups = list; }
153 QStringList getGroups() { return subscribedGroups; } 153 QStringList getGroups() { return subscribedGroups; }
154 154
155private: 155private:
156 QString file; 156 QString file;
157 bool login; 157 bool login;
158 QStringList subscribedGroups; 158 QStringList subscribedGroups;
159 159
160}; 160};
161 161
162class Settings : public QObject 162class Settings : public QObject
163{ 163{
164 Q_OBJECT 164 Q_OBJECT
165 165
166public: 166public:
167 Settings(); 167 Settings();
168 //~Settings(){qDebug("-------------------settings "); };
168 QList<Account> getAccounts(); 169 QList<Account> getAccounts();
169 void addAccount(Account *account); 170 void addAccount(Account *account);
170 void delAccount(Account *account); 171 void delAccount(Account *account);
171 void saveAccounts(); 172 void saveAccounts();
172 void readAccounts(); 173 void readAccounts();
173 static void checkDirectory(); 174 static void checkDirectory();
174 175
175private: 176private:
176 void updateAccounts(); 177 void updateAccounts();
177 QList<Account> accounts; 178 QList<Account> accounts;
178 179
179}; 180};
180 181
181#endif 182#endif
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index 484a635..5ef5b6a 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -1,146 +1,146 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include "mailistviewitem.h" 2#include "mailistviewitem.h"
3#include <libmailwrapper/abstractmail.h> 3#include <libmailwrapper/abstractmail.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <kiconloader.h> 5#include <kiconloader.h>
6//#include <qpe/resource.h> 6//#include <qpe/resource.h>
7 7
8MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 8MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
9 :QListViewItem(parent,item),mail_data() 9 :QListViewItem(parent,item),mail_data()
10{ 10{
11} 11}
12 12
13void MailListViewItem::showEntry() 13void MailListViewItem::showEntry()
14{ 14{
15 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { 15 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
16 setPixmap( 0, SmallIcon ( "kmmsgreplied") ); 16 setPixmap( 0, SmallIcon ( "kmmsgreplied") );
17 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { 17 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
18 /* I think it looks nicer if there are not such a log of icons but only on mails 18 /* I think it looks nicer if there are not such a log of icons but only on mails
19 replied or new - Alwin*/ 19 replied or new - Alwin*/
20 //setPixmap( 0,SmallIcon ("kmmsgunseen") ); 20 //setPixmap( 0,SmallIcon ("kmmsgunseen") );
21 } else { 21 } else {
22 setPixmap( 0,SmallIcon ( "kmmsgnew") ); 22 setPixmap( 0,SmallIcon ( "kmmsgnew") );
23 } 23 }
24 double s = mail_data->Msgsize(); 24 double s = mail_data->Msgsize();
25 int w = 0; 25 int w = 0;
26 s/=1024; 26 s/=1024;
27 if (s>999.0) { 27 if (s>999.0) {
28 s/=1024.0; 28 s/=1024.0;
29 ++w; 29 ++w;
30 } 30 }
31 QString fsort; 31 QString fsort;
32 fsort.sprintf( "%.2f", s ); 32 fsort.sprintf( "%.2f", s );
33 QString fsize = QString::number( s, 'f', 2 ); 33 QString fsize = QString::number( s, 'f', 2 );
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,mail_data->getSubject()); 58 setText(1,QString::fromUtf8( mail_data->getSubject().latin1()));
59 setText(2,mail_data->getFrom()); 59 setText(2,QString::fromUtf8( mail_data->getFrom().latin1()));
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" )
84 so = "05"; 84 so = "05";
85 else if ( mon == "Jun" ) 85 else if ( mon == "Jun" )
86 so = "06"; 86 so = "06";
87 else if ( mon == "Jul" ) 87 else if ( mon == "Jul" )
88 so = "07"; 88 so = "07";
89 else if ( mon == "Aug" ) 89 else if ( mon == "Aug" )
90 so = "08"; 90 so = "08";
91 else if ( mon == "Sep" ) 91 else if ( mon == "Sep" )
92 so = "09"; 92 so = "09";
93 else if ( mon == "Oct" ) 93 else if ( mon == "Oct" )
94 so = "10"; 94 so = "10";
95 else if ( mon == "Nov" ) 95 else if ( mon == "Nov" )
96 so = "11"; 96 so = "11";
97 else if ( mon == "Dec" ) 97 else if ( mon == "Dec" )
98 so = "12"; 98 so = "12";
99 date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); 99 date = date.mid(7,4)+so+date.left(2)+date.mid(12,14);
100 } 100 }
101 //qDebug("insert Date %s ", date.latin1()); 101 //qDebug("insert Date %s ", date.latin1());
102 // if ( date.left(1) != "1" || date.left(1) != "2" ) 102 // if ( date.left(1) != "1" || date.left(1) != "2" )
103 // date = date.mid(5); 103 // date = date.mid(5);
104 mKeyMap.insert(4,date); 104 mKeyMap.insert(4,date);
105#endif 105#endif
106 mKeyMap.insert(4,mail_data->getIsoDate()); 106 mKeyMap.insert(4,mail_data->getIsoDate());
107 setText(4,mail_data->getDate()); 107 setText(4,mail_data->getDate());
108} 108}
109 109
110void MailListViewItem::storeData(const RecMailP&data) 110void MailListViewItem::storeData(const RecMailP&data)
111{ 111{
112 mail_data = data; 112 mail_data = data;
113} 113}
114void MailListViewItem::setSortKey(int column,const QString &key) 114void MailListViewItem::setSortKey(int column,const QString &key)
115{ 115{
116 mKeyMap.insert(column,key); 116 mKeyMap.insert(column,key);
117} 117}
118QString MailListViewItem::key(int column, bool) const 118QString MailListViewItem::key(int column, bool) const
119{ 119{
120 // to make is fast, we use here special cases 120 // to make is fast, we use here special cases
121 if ( column == 3 || column == 4 ) { 121 if ( column == 3 || column == 4 ) {
122 return *mKeyMap.find(column); 122 return *mKeyMap.find(column);
123 } 123 }
124 if ( column == 1 ) { 124 if ( column == 1 ) {
125 if ( text(1).left(4).lower() == "re: " ) 125 if ( text(1).left(4).lower() == "re: " )
126 return text(1).mid(4); 126 return text(1).mid(4);
127 127
128 } 128 }
129 return text(column); 129 return text(column);
130 /* 130 /*
131 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 131 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
132 if (it == mKeyMap.end()) return text(column); 132 if (it == mKeyMap.end()) return text(column);
133 else return *it; 133 else return *it;
134 */ 134 */
135} 135}
136 136
137const RecMailP& MailListViewItem::data()const 137const RecMailP& MailListViewItem::data()const
138{ 138{
139 return mail_data; 139 return mail_data;
140} 140}
141 141
142MAILLIB::ATYPE MailListViewItem::wrapperType() 142MAILLIB::ATYPE MailListViewItem::wrapperType()
143{ 143{
144 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; 144 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED;
145 return mail_data->Wrapper()->getType(); 145 return mail_data->Wrapper()->getType();
146} 146}
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 4115276..98eb9a5 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,308 +1,312 @@
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>
15extern QStatusBar* globalSstatusBarMainWindow;
14#else 16#else
15#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
16#endif 18#endif
17#include "defines.h" 19#include "defines.h"
18#include "mainwindow.h" 20#include "mainwindow.h"
19#include <KDGanttMinimizeSplitter.h> 21#include <KDGanttMinimizeSplitter.h>
20 22
21
22#include <kabc/stdaddressbook.h> 23#include <kabc/stdaddressbook.h>
23 24
24MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 25MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
25 : QMainWindow( parent, name ) //, flags ) 26 : QMainWindow( parent, name ) //, flags )
26{ 27{
28#ifdef DESKTOP_VERSION
29 globalSstatusBarMainWindow = statusBar();
30#endif
27 setCaption( i18n( "KOpieMail/Pi" ) ); 31 setCaption( i18n( "KOpieMail/Pi" ) );
28 setToolBarsMovable( false ); 32 setToolBarsMovable( false );
29 //KABC::StdAddressBook::self(); 33 //KABC::StdAddressBook::self();
30 toolBar = new QToolBar( this ); 34 toolBar = new QToolBar( this );
31 menuBar = new QPEMenuBar( toolBar ); 35 menuBar = new QPEMenuBar( toolBar );
32 mailMenu = new QPopupMenu( menuBar ); 36 mailMenu = new QPopupMenu( menuBar );
33 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 37 menuBar->insertItem( i18n( "Mail" ), mailMenu );
34 settingsMenu = new QPopupMenu( menuBar ); 38 settingsMenu = new QPopupMenu( menuBar );
35 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 39 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
36 40
37 addToolBar( toolBar ); 41 addToolBar( toolBar );
38 toolBar->setHorizontalStretchable( true ); 42 toolBar->setHorizontalStretchable( true );
39 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 43 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
40 0, 0, this ); 44 0, 0, this );
41 connect(getMail, SIGNAL( activated() ), 45 connect(getMail, SIGNAL( activated() ),
42 SLOT( slotGetAllMail() ) ); 46 SLOT( slotGetAllMail() ) );
43 getMail->addTo( mailMenu ); 47 getMail->addTo( mailMenu );
44 48
45 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 49 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"),
46 0, 0, this ); 50 0, 0, this );
47 getMail->addTo( toolBar ); 51 getMail->addTo( toolBar );
48 getMail->addTo( mailMenu ); 52 getMail->addTo( mailMenu );
49 connect(getMail, SIGNAL( activated() ), 53 connect(getMail, SIGNAL( activated() ),
50 SLOT( slotGetMail() ) ); 54 SLOT( slotGetMail() ) );
51 55
52 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 56 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"),
53 0, 0, this ); 57 0, 0, this );
54 composeMail->addTo( toolBar ); 58 composeMail->addTo( toolBar );
55 composeMail->addTo( mailMenu ); 59 composeMail->addTo( mailMenu );
56 60
57 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 61 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") ,
58 0, 0, this ); 62 0, 0, this );
59 sendQueued->addTo( toolBar ); 63 sendQueued->addTo( toolBar );
60 sendQueued->addTo( mailMenu ); 64 sendQueued->addTo( mailMenu );
61 65
62 /* 66 /*
63 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 67 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC,
64 0, 0, this ); 68 0, 0, this );
65 syncFolders->addTo( toolBar ); 69 syncFolders->addTo( toolBar );
66 syncFolders->addTo( mailMenu ); 70 syncFolders->addTo( mailMenu );
67 */ 71 */
68 72
69 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 73 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") ,
70 0, 0, this, 0, true ); 74 0, 0, this, 0, true );
71 showFolders->addTo( toolBar ); 75 showFolders->addTo( toolBar );
72 showFolders->addTo( mailMenu ); 76 showFolders->addTo( mailMenu );
73 showFolders->setOn( true ); 77 showFolders->setOn( true );
74 connect(showFolders, SIGNAL( toggled(bool) ), 78 connect(showFolders, SIGNAL( toggled(bool) ),
75 SLOT( slotShowFolders(bool) ) ); 79 SLOT( slotShowFolders(bool) ) );
76 80
77 /* 81 /*
78 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 82 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
79 0, 0, this ); 83 0, 0, this );
80 searchMails->addTo( toolBar ); 84 searchMails->addTo( toolBar );
81 searchMails->addTo( mailMenu ); 85 searchMails->addTo( mailMenu );
82 */ 86 */
83 87
84 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 88 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
85 deleteMails->addTo( toolBar ); 89 deleteMails->addTo( toolBar );
86 deleteMails->addTo( mailMenu ); 90 deleteMails->addTo( mailMenu );
87 connect( deleteMails, SIGNAL( activated() ), 91 connect( deleteMails, SIGNAL( activated() ),
88 SLOT( slotDeleteMail() ) ); 92 SLOT( slotDeleteMail() ) );
89 93
90 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 94 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
91 0, 0, this ); 95 0, 0, this );
92 editSettings->addTo( settingsMenu ); 96 editSettings->addTo( settingsMenu );
93 connect( editSettings, SIGNAL( activated() ), 97 connect( editSettings, SIGNAL( activated() ),
94 SLOT( slotEditSettings() ) ); 98 SLOT( slotEditSettings() ) );
95 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 99 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
96 0, 0, this ); 100 0, 0, this );
97 editAccounts->addTo( settingsMenu ); 101 editAccounts->addTo( settingsMenu );
98 102
99 //setCentralWidget( view ); 103 //setCentralWidget( view );
100 104
101 QVBox* wrapperBox = new QVBox( this ); 105 QVBox* wrapperBox = new QVBox( this );
102 setCentralWidget( wrapperBox ); 106 setCentralWidget( wrapperBox );
103 107
104 // QWidget *view = new QWidget( wrapperBox ); 108 // QWidget *view = new QWidget( wrapperBox );
105 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 109 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
106 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 110 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
107 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 111 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
108 112
109 folderView = new AccountView( split ); 113 folderView = new AccountView( split );
110 folderView->header()->hide(); 114 folderView->header()->hide();
111 folderView->setRootIsDecorated( false ); 115 folderView->setRootIsDecorated( false );
112 folderView->addColumn( i18n( "Mailbox" ) ); 116 folderView->addColumn( i18n( "Mailbox" ) );
113 117
114 //layout->addWidget( folderView ); 118 //layout->addWidget( folderView );
115 119
116 mailView = new QListView( split ); 120 mailView = new QListView( split );
117 mailView->addColumn( i18n( " " ) ); 121 mailView->addColumn( i18n( " " ) );
118 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 122 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
119 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 123 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
120 mailView->addColumn( i18n( "Size" ),QListView::Manual); 124 mailView->addColumn( i18n( "Size" ),QListView::Manual);
121 mailView->addColumn( i18n( "Date" ),QListView::Manual); 125 mailView->addColumn( i18n( "Date" ),QListView::Manual);
122 mailView->setAllColumnsShowFocus(true); 126 mailView->setAllColumnsShowFocus(true);
123 //mailView->setSorting(-1); 127 //mailView->setSorting(-1);
124 mailView->setRootIsDecorated( false ); 128 mailView->setRootIsDecorated( false );
125 statusWidget = new StatusWidget( wrapperBox ); 129 statusWidget = new StatusWidget( wrapperBox );
126 statusWidget->hide(); 130 statusWidget->hide();
127 131
128 //layout->addWidget( mailView ); 132 //layout->addWidget( mailView );
129 //layout->setStretchFactor( folderView, 1 ); 133 //layout->setStretchFactor( folderView, 1 );
130 //layout->setStretchFactor( mailView, 2 ); 134 //layout->setStretchFactor( mailView, 2 );
131 135
132 slotAdjustLayout(); 136 slotAdjustLayout();
133#ifndef DESKTOP_VERSION 137#ifndef DESKTOP_VERSION
134 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 138 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
135 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 139 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
136#endif 140#endif
137 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 141 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
138 SLOT( mailLeftClicked(QListViewItem*) ) ); 142 SLOT( mailLeftClicked(QListViewItem*) ) );
139 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 143 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
140 SLOT( mailLeftClicked(QListViewItem*) ) ); 144 SLOT( mailLeftClicked(QListViewItem*) ) );
141 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 145 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
142 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 146 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
143 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 147 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
144 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 148 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
145 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 149 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
146 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 150 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
147// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 151// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
148 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 152 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
149 //mailView->setMultiSelection ( true ); 153 //mailView->setMultiSelection ( true );
150 mailView->setSelectionMode( QListView::Extended ); 154 mailView->setSelectionMode( QListView::Extended );
151 QValueList<int> list; 155 QValueList<int> list;
152 int fw = 100; 156 int fw = 100;
153 if ( QApplication::desktop()->width() > 320 ) 157 if ( QApplication::desktop()->width() > 320 )
154 fw = 50; 158 fw = 50;
155 list.append( fw ); 159 list.append( fw );
156 list.append( 100 ); 160 list.append( 100 );
157 split->setSizes( list ); 161 split->setSizes( list );
158 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 162 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
159 mailView->setShowSortIndicator ( true ); 163 mailView->setShowSortIndicator ( true );
160 QLabel *spacer = new QLabel( toolBar ); 164 QLabel *spacer = new QLabel( toolBar );
161 spacer->setBackgroundMode( QWidget::PaletteButton ); 165 spacer->setBackgroundMode( QWidget::PaletteButton );
162 toolBar->setStretchableWidget( spacer ); 166 toolBar->setStretchableWidget( spacer );
163 167
164 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 168 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
165 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 169 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
166 if ( QApplication::desktop()->width() > 320 ) 170 if ( QApplication::desktop()->width() > 320 )
167 closeMail->addTo(toolBar); 171 closeMail->addTo(toolBar);
168 closeMail->addTo(mailMenu); 172 closeMail->addTo(mailMenu);
169 173
170 174
171 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 175 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
172 menuBar->insertItem( i18n( "Help" ), helpMenu ); 176 menuBar->insertItem( i18n( "Help" ), helpMenu );
173 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 177 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
174 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 178 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
175 li->addTo(helpMenu); 179 li->addTo(helpMenu);
176 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 180 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
177 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 181 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
178 li->addTo(helpMenu); 182 li->addTo(helpMenu);
179 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 183 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
180 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 184 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
181 li->addTo(helpMenu); 185 li->addTo(helpMenu);
182#ifdef DESKTOP_VERSION 186#ifdef DESKTOP_VERSION
183 resize ( 640, 480 ); 187 resize ( 640, 480 );
184#endif 188#endif
185} 189}
186 190
187MainWindow::~MainWindow() 191MainWindow::~MainWindow()
188{ 192{
189} 193}
190 194
191void MainWindow::showLicence() 195void MainWindow::showLicence()
192{ 196{
193 KApplication::showLicence(); 197 KApplication::showLicence();
194} 198}
195void MainWindow::showAbout() 199void MainWindow::showAbout()
196{ 200{
197 QString version; 201 QString version;
198#include <../version> 202#include <../version>
199 203
200 QString cap = "About KOpieMail/Pi"; 204 QString cap = "About KOpieMail/Pi";
201 QString text =i18n("KOpieMail/Platform-independent\n") + 205 QString text =i18n("KOpieMail/Platform-independent\n") +
202 "(OM/Pi) " + version + " - " 206 "(OM/Pi) " + version + " - "
203 207
204#ifdef DESKTOP_VERSION 208#ifdef DESKTOP_VERSION
205 "Desktop Edition\n" 209 "Desktop Edition\n"
206#else 210#else
207 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 211 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
208#endif 212#endif
209 "www.pi-sync.net\n\n" 213 "www.pi-sync.net\n\n"
210 214
211 215
212 216
213"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 217"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
214 "KOpieMail/Pi is based on Opie Mail\n" 218 "KOpieMail/Pi is based on Opie Mail\n"
215 "Copyright (c) Rajko Albrecht and the Opie team\n" 219 "Copyright (c) Rajko Albrecht and the Opie team\n"
216 "KOpieMail/Pi is licensed under the GPL\n" 220 "KOpieMail/Pi is licensed under the GPL\n"
217 "\n" 221 "\n"
218 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 222 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
219 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 223 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
220 "libEtPan has its own licence - see LibEtPan licence\n"; 224 "libEtPan has its own licence - see LibEtPan licence\n";
221 225
222 KApplication::showText( cap, text ); 226 KApplication::showText( cap, text );
223} 227}
224void MainWindow::showEtpanLicence() 228void MainWindow::showEtpanLicence()
225{ 229{
226 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); 230 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" );
227 231
228} 232}
229void MainWindow::appMessage(const QCString &, const QByteArray &) 233void MainWindow::appMessage(const QCString &, const QByteArray &)
230{ 234{
231 qDebug("appMessage implemented by subclass"); 235 qDebug("appMessage implemented by subclass");
232} 236}
233 237
234void MainWindow::slotAdjustLayout() { 238void MainWindow::slotAdjustLayout() {
235 239
236 /* 240 /*
237 QWidget *d = QApplication::desktop(); 241 QWidget *d = QApplication::desktop();
238 242
239 if ( d->width() < d->height() ) { 243 if ( d->width() < d->height() ) {
240 layout->setDirection( QBoxLayout::TopToBottom ); 244 layout->setDirection( QBoxLayout::TopToBottom );
241 } else { 245 } else {
242 layout->setDirection( QBoxLayout::LeftToRight ); 246 layout->setDirection( QBoxLayout::LeftToRight );
243 } 247 }
244 */ 248 */
245} 249}
246 250
247void MainWindow::slotAdjustColumns() 251void MainWindow::slotAdjustColumns()
248{ 252{
249 bool hidden = folderView->isHidden(); 253 bool hidden = folderView->isHidden();
250 if ( hidden ) folderView->show(); 254 if ( hidden ) folderView->show();
251 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 255 folderView->setColumnWidth( 0, folderView->visibleWidth() );
252 if ( hidden ) folderView->hide(); 256 if ( hidden ) folderView->hide();
253 257
254 mailView->setColumnWidth( 0, 10 ); 258 mailView->setColumnWidth( 0, 10 );
255 mailView->setColumnWidth( 1, 100 ); 259 mailView->setColumnWidth( 1, 100 );
256 mailView->setColumnWidth( 2, 100 ); 260 mailView->setColumnWidth( 2, 100 );
257 mailView->setColumnWidth( 3, 50 ); 261 mailView->setColumnWidth( 3, 50 );
258 mailView->setColumnWidth( 4, 120 ); 262 mailView->setColumnWidth( 4, 120 );
259} 263}
260 264
261void MainWindow::slotEditSettings() 265void MainWindow::slotEditSettings()
262{ 266{
263} 267}
264 268
265void MainWindow::slotShowFolders( bool ) 269void MainWindow::slotShowFolders( bool )
266{ 270{
267 qDebug("not implemented: "); 271 qDebug("not implemented: ");
268} 272}
269 273
270void MainWindow::refreshMailView(const QValueList<RecMailP>&) 274void MainWindow::refreshMailView(const QValueList<RecMailP>&)
271{ 275{
272 qDebug("not implemented: "); 276 qDebug("not implemented: ");
273} 277}
274 278
275void MainWindow::mailLeftClicked(QListViewItem * ) 279void MainWindow::mailLeftClicked(QListViewItem * )
276{ 280{
277 qDebug("not implemented: "); 281 qDebug("not implemented: ");
278} 282}
279 283
280void MainWindow::displayMail() 284void MainWindow::displayMail()
281{ 285{
282 qDebug("not implemented: "); 286 qDebug("not implemented: ");
283} 287}
284 288
285void MainWindow::slotDeleteMail() 289void MainWindow::slotDeleteMail()
286{ 290{
287 qDebug("not implemented: "); 291 qDebug("not implemented: ");
288} 292}
289 293
290void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 294void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
291{ 295{
292 qDebug("not implemented: "); 296 qDebug("not implemented: ");
293} 297}
294 298
295void MainWindow::slotSendQueued() 299void MainWindow::slotSendQueued()
296{ 300{
297 qDebug("not implemented: "); 301 qDebug("not implemented: ");
298} 302}
299 303
300void MainWindow::slotEditAccounts() 304void MainWindow::slotEditAccounts()
301{ 305{
302 qDebug("not implemented: "); 306 qDebug("not implemented: ");
303} 307}
304 308
305void MainWindow::slotComposeMail() 309void MainWindow::slotComposeMail()
306{ 310{
307 qDebug("not implemented: "); 311 qDebug("not implemented: ");
308} 312}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index ca3faaf..fe9df87 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,483 +1,529 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
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 26
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qapplication.h> 28#include <qapplication.h>
29#else 29#else
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#endif 31#endif
32#include <libmailwrapper/smtpwrapper.h> 32#include <libmailwrapper/smtpwrapper.h>
33#include <libmailwrapper/mailtypes.h> 33#include <libmailwrapper/mailtypes.h>
34#include <libmailwrapper/abstractmail.h> 34#include <libmailwrapper/abstractmail.h>
35 35
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38OpieMail::OpieMail( QWidget *parent, const char *name ) 38OpieMail::OpieMail( QWidget *parent, const char *name )
39 : MainWindow( parent, name) //, WStyle_ContextHelp ) 39 : MainWindow( parent, name) //, WStyle_ContextHelp )
40{ 40{
41 settings = new Settings(); 41 settings = new Settings();
42 42
43 setIcon(SmallIcon( "kmicromail" ) );
43 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
44 45
45} 46}
46 47
47OpieMail::~OpieMail() 48OpieMail::~OpieMail()
48{ 49{
49 if (settings) delete settings; 50 if (settings) delete settings;
50} 51}
51 52
52void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
53{ 54{
54 55
55} 56}
56#include <stdlib.h> 57#include <stdlib.h>
57void OpieMail::message(const QCString &msg, const QByteArray &data) 58void OpieMail::message(const QCString &msg, const QByteArray &data)
58{ 59{
59 // copied from old mail2 60 // copied from old mail2
60 static int ii = 0; 61 static int ii = 0;
61 //qDebug("QCOP CALL ############################# %d ", ii); 62 //qDebug("QCOP CALL ############################# %d ", ii);
62 //QString mess ( msg ); 63 //QString mess ( msg );
63 //qDebug("Message = %s ",mess.latin1()); 64 //qDebug("Message = %s ",mess.latin1());
64 ++ii; 65 ++ii;
65 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
66 67
67 mPendingEmail = QString::null; 68 mPendingEmail = QString::null;
68 mPendingName = QString::null; 69 mPendingName = QString::null;
69 if (msg == "writeMail(QString,QString)") 70 if (msg == "writeMail(QString,QString)")
70 { 71 {
71 //qDebug("writeMail(QString,QString) "); 72 //qDebug("writeMail(QString,QString) ");
72 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
73 stream >> mPendingName >> mPendingEmail; 74 stream >> mPendingName >> mPendingEmail;
74 // removing the whitespaces at beginning and end is needed! 75 // removing the whitespaces at beginning and end is needed!
75 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
76 } 77 }
77 else if (msg == "newMail()") 78 else if (msg == "newMail()")
78 { 79 {
79 //qDebug("slotComposeMail() "); 80 //qDebug("slotComposeMail() ");
80 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 81 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
81 // and a QCOP call does not like a processevents in his execution 82 // and a QCOP call does not like a processevents in his execution
82 // with the Qtimer we call slotComposeMail() after we reached the main event loop 83 // with the Qtimer we call slotComposeMail() after we reached the main event loop
83 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
84 // slotComposeMail(); 85 // slotComposeMail();
85 } 86 }
86 else if (msg == "newMail(QString)") 87 else if (msg == "newMail(QString)")
87 { 88 {
88 //qDebug(" newMail(QString)"); 89 //qDebug(" newMail(QString)");
89 QDataStream stream(data,IO_ReadOnly); 90 QDataStream stream(data,IO_ReadOnly);
90 stream >> mPendingName; 91 stream >> mPendingName;
91 // the format is 92 // the format is
92 // NAME <EMAIL>:SUBJECT 93 // NAME <EMAIL>:SUBJECT
93 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
94 } else { 95 } else {
95 mPendingData = data; 96 mPendingData = data;
96 mPendingMessage = msg; 97 mPendingMessage = msg;
97 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
98 } 99 }
99 100
100 //qDebug("END OpieMail::message "); 101 //qDebug("END OpieMail::message ");
101} 102}
102void OpieMail::slotExtAppHandler() 103void OpieMail::slotExtAppHandler()
103{ 104{
104 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
105} 106}
106void OpieMail::slotwriteMail2(const QString& namemail ) 107void OpieMail::slotwriteMail2(const QString& namemail )
107{ 108{
108 //qDebug("OpieMail::slotwriteMail2 "); 109 //qDebug("OpieMail::slotwriteMail2 ");
109 //qApp->processEvents(); 110 //qApp->processEvents();
110 ComposeMail compose( settings, this, 0, true ); 111 ComposeMail compose( settings, this, 0, true );
111 if ( !namemail.isEmpty() ) { 112 if ( !namemail.isEmpty() ) {
112 QString to = namemail; 113 QString to = namemail;
113 if ( namemail.find( " <") > 1 ) { 114 if ( namemail.find( " <") > 1 ) {
114 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
115 } else 116 } else
116 if ( namemail.find( "<") > 1 ) { 117 if ( namemail.find( "<") > 1 ) {
117 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
118 } 119 }
119 int sub = to.find( ">:"); 120 int sub = to.find( ">:");
120 if ( sub > 0 ) { 121 if ( sub > 0 ) {
121 compose.setTo( to.left(sub+1) ); 122 compose.setTo( to.left(sub+1) );
122 compose.setSubject( to.mid(sub+2) ); 123 compose.setSubject( to.mid(sub+2) );
123 } else 124 } else
124 compose.setTo( to ); 125 compose.setTo( to );
125 } 126 }
126 compose.slotAdjustColumns(); 127 compose.slotAdjustColumns();
127 compose.showMaximized(); 128 compose.showMaximized();
128 compose.exec(); 129 compose.exec();
129 raise(); 130 raise();
130 //qDebug("retttich "); 131 //qDebug("retttich ");
131} 132}
132void OpieMail::slotwriteMail(const QString&name,const QString&email) 133void OpieMail::slotwriteMail(const QString&name,const QString&email)
133{ 134{
134 // qDebug("OpieMail::slotwriteMail "); 135 // qDebug("OpieMail::slotwriteMail ");
135 ComposeMail compose( settings, this, 0, true ); 136 ComposeMail compose( settings, this, 0, true );
136 if (!email.isEmpty()) 137 if (!email.isEmpty())
137 { 138 {
138 if (!name.isEmpty()) 139 if (!name.isEmpty())
139 { 140 {
140 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 141 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
141 } 142 }
142 else 143 else
143 { 144 {
144 compose.setTo(email); 145 compose.setTo(email);
145 } 146 }
146 } 147 }
147 compose.slotAdjustColumns(); 148 compose.slotAdjustColumns();
148 compose.showMaximized(); 149 compose.showMaximized();
149 compose.exec(); 150 compose.exec();
150 raise(); 151 raise();
151} 152}
152 153
153void OpieMail::slotComposeMail() 154void OpieMail::slotComposeMail()
154{ 155{
155 if ( mPendingEmail == QString::null && mPendingName == QString::null) 156 if ( mPendingEmail == QString::null && mPendingName == QString::null)
156 slotwriteMail2( QString () ); 157 slotwriteMail2( QString () );
157 else { 158 else {
158 if ( mPendingEmail == QString::null ) 159 if ( mPendingEmail == QString::null )
159 slotwriteMail2( mPendingName ); 160 slotwriteMail2( mPendingName );
160 else 161 else
161 slotwriteMail( mPendingName, mPendingEmail ); 162 slotwriteMail( mPendingName, mPendingEmail );
162 } 163 }
163 //slotwriteMail(0l,0l); 164 //slotwriteMail(0l,0l);
164} 165}
165 166
166void OpieMail::slotSendQueued() 167void OpieMail::slotSendQueued()
167{ 168{
168 SMTPaccount *smtp = 0; 169 SMTPaccount *smtp = 0;
169 170
170 QList<Account> list = settings->getAccounts(); 171 QList<Account> list = settings->getAccounts();
171 QList<SMTPaccount> smtpList; 172 QList<SMTPaccount> smtpList;
172 smtpList.setAutoDelete(false); 173 smtpList.setAutoDelete(false);
173 Account *it; 174 Account *it;
174 for ( it = list.first(); it; it = list.next() ) 175 for ( it = list.first(); it; it = list.next() )
175 { 176 {
176 if ( it->getType() == MAILLIB::A_SMTP ) 177 if ( it->getType() == MAILLIB::A_SMTP )
177 { 178 {
178 smtp = static_cast<SMTPaccount *>(it); 179 smtp = static_cast<SMTPaccount *>(it);
179 smtpList.append(smtp); 180 smtpList.append(smtp);
180 } 181 }
181 } 182 }
182 if (smtpList.count()==0) 183 if (smtpList.count()==0)
183 { 184 {
184 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 185 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
185 return; 186 return;
186 } 187 }
187 if (smtpList.count()==1) 188 if (smtpList.count()==1)
188 { 189 {
189 smtp = smtpList.at(0); 190 smtp = smtpList.at(0);
190 } 191 }
191 else 192 else
192 { 193 {
193 smtp = 0; 194 smtp = 0;
194 selectsmtp selsmtp; 195 selectsmtp selsmtp;
195 selsmtp.setSelectionlist(&smtpList); 196 selsmtp.setSelectionlist(&smtpList);
196 selsmtp.showMaximized(); 197 selsmtp.showMaximized();
197 if ( selsmtp.exec() == QDialog::Accepted ) 198 if ( selsmtp.exec() == QDialog::Accepted )
198 { 199 {
199 smtp = selsmtp.selected_smtp(); 200 smtp = selsmtp.selected_smtp();
200 } 201 }
201 } 202 }
202 if (smtp) 203 if (smtp)
203 { 204 {
204 SMTPwrapper * wrap = new SMTPwrapper(smtp); 205 SMTPwrapper * wrap = new SMTPwrapper(smtp);
205 if ( wrap->flushOutbox() ) 206 if ( wrap->flushOutbox() )
206 { 207 {
207 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); 208 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed"));
208 } 209 }
209 delete wrap; 210 delete wrap;
210 } 211 }
211} 212}
212 213
213void OpieMail::slotSearchMails() 214void OpieMail::slotSearchMails()
214{ 215{
215 qDebug("OpieMail::slotSearchMails():not implemented "); 216 qDebug("OpieMail::slotSearchMails():not implemented ");
216} 217}
217 218
218void OpieMail::slotEditSettings() 219void OpieMail::slotEditSettings()
219{ 220{
220 221
221 KOPrefsDialog settingsDialog( this, "koprefs", true ); 222 KOPrefsDialog settingsDialog( this, "koprefs", true );
222#ifndef DESKTOP_VERSION 223#ifndef DESKTOP_VERSION
223 settingsDialog.showMaximized(); 224 settingsDialog.showMaximized();
224#endif 225#endif
225 settingsDialog.exec(); 226 settingsDialog.exec();
226 227
227 // KApplication::execDialog(settingsDialog); 228 // KApplication::execDialog(settingsDialog);
228} 229}
229 230
230void OpieMail::slotEditAccounts() 231void OpieMail::slotEditAccounts()
231{ 232{
232 EditAccounts eaDialog( settings, this, 0, true ); 233 EditAccounts eaDialog( settings, this, 0, true );
233 eaDialog.slotAdjustColumns(); 234 eaDialog.slotAdjustColumns();
234#ifndef DESKTOP_VERSION 235#ifndef DESKTOP_VERSION
235 eaDialog.showMaximized(); 236 eaDialog.showMaximized();
236#endif 237#endif
237 eaDialog.exec(); 238 eaDialog.exec();
238 if ( settings ) delete settings; 239 if ( settings ) delete settings;
239 settings = new Settings(); 240 settings = new Settings();
240 241
241 folderView->populate( settings->getAccounts() ); 242 folderView->populate( settings->getAccounts() );
242} 243}
244void OpieMail::replyMail()
245{
246
247 QListViewItem*item = mailView->currentItem();
248 if (!item) return;
249 RecMailP mail = ((MailListViewItem*)item)->data();
250 RecBodyP body = folderView->fetchBody(mail);
251
252 QString rtext;
253 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
254 .arg( QString::fromUtf8( mail->getFrom().latin1()))
255 .arg( QString::fromUtf8( mail->getDate().latin1() ));
256
257 QString text = QString::fromUtf8( body->Bodytext().latin1() );
258 QStringList lines = QStringList::split(QRegExp("\\n"), text);
259 QStringList::Iterator it;
260 for (it = lines.begin(); it != lines.end(); it++)
261 {
262 rtext += "> " + *it + "\n";
263 }
264 rtext += "\n";
243 265
266 QString prefix;
267 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
268 else prefix = "Re: "; // no i18n on purpose
269
270 Settings *settings = new Settings();
271 ComposeMail composer( settings ,this, 0, true);
272 if (mail->Replyto().isEmpty()) {
273 composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
274 } else {
275 composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
276 }
277 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
278 composer.setMessage( rtext );
279 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
280
281 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
282 {
283 mail->Wrapper()->answeredMail(mail);
284 }
285 delete settings;
286
287}
244void OpieMail::displayMail() 288void OpieMail::displayMail()
245{ 289{
246 QListViewItem*item = mailView->currentItem(); 290 QListViewItem*item = mailView->currentItem();
247 if (!item) return; 291 if (!item) return;
248 RecMailP mail = ((MailListViewItem*)item)->data(); 292 RecMailP mail = ((MailListViewItem*)item)->data();
249 RecBodyP body = folderView->fetchBody(mail); 293 RecBodyP body = folderView->fetchBody(mail);
250 ViewMail readMail( this,"", Qt::WType_Modal ); 294 ViewMail readMail( this,"", Qt::WType_Modal );
251 readMail.setBody( body ); 295 readMail.setBody( body );
252 readMail.setMail( mail ); 296 readMail.setMail( mail );
253#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
254 readMail.showMaximized(); 298 readMail.showMaximized();
255#else 299#else
256 readMail.resize( 640, 480); 300 readMail.resize( 640, 480);
257#endif 301#endif
258 readMail.exec(); 302 readMail.exec();
259 303
260 if ( readMail.deleted ) 304 if ( readMail.deleted )
261 { 305 {
262 folderView->refreshCurrent(); 306 folderView->refreshCurrent();
263 } 307 }
264 else 308 else
265 { 309 {
266 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 310 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
267 } 311 }
268} 312}
269void OpieMail::slotGetAllMail() 313void OpieMail::slotGetAllMail()
270{ 314{
271 QListViewItem * item = folderView->firstChild(); 315 QListViewItem * item = folderView->firstChild();
272 while ( item ){ 316 while ( item ){
273 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 317 ((AccountViewItem *)item)->contextMenuSelected( 101 );
274 item = item->nextSibling (); 318 item = item->nextSibling ();
275 } 319 }
276} 320}
277void OpieMail::slotGetMail() 321void OpieMail::slotGetMail()
278{ 322{
279 QListViewItem * item = folderView->currentItem(); 323 QListViewItem * item = folderView->currentItem();
280 if ( ! item ) return; 324 if ( ! item ) return;
281 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 325 ((AccountViewItem *)item)->contextMenuSelected( 101 );
282} 326}
283void OpieMail::slotDeleteMail() 327void OpieMail::slotDeleteMail()
284{ 328{
285 if (!mailView->currentItem()) return; 329 if (!mailView->currentItem()) return;
286 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 330 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
287 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 331 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
288 { 332 {
289 mail->Wrapper()->deleteMail( mail ); 333 mail->Wrapper()->deleteMail( mail );
290 folderView->refreshCurrent(); 334 folderView->refreshCurrent();
291 } 335 }
292} 336}
293void OpieMail::slotDeleteAllMail() 337void OpieMail::slotDeleteAllMail()
294{ 338{
295 339
296 QValueList<RecMailP> t; 340 QValueList<RecMailP> t;
297 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 341 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
298 { 342 {
299 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 343 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
300 while ( item ) { 344 while ( item ) {
301 if ( item->isSelected() ) { 345 if ( item->isSelected() ) {
302 t.append( item->data() ); 346 t.append( item->data() );
303 } 347 }
304 item = (MailListViewItem*)item->nextSibling(); 348 item = (MailListViewItem*)item->nextSibling();
305 } 349 }
306 } 350 }
307 else 351 else
308 return; 352 return;
309 if ( t.count() == 0 ) 353 if ( t.count() == 0 )
310 return; 354 return;
311 RecMailP mail = t.first(); 355 RecMailP mail = t.first();
312 mail->Wrapper()->deleteMailList(t); 356 mail->Wrapper()->deleteMailList(t);
313 folderView->refreshCurrent(); 357 folderView->refreshCurrent();
314 358
315 359
316} 360}
317void OpieMail::clearSelection() 361void OpieMail::clearSelection()
318{ 362{
319 mailView->clearSelection(); 363 mailView->clearSelection();
320 364
321} 365}
322 366
323void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 367void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
324{ 368{
325 if (!mailView->currentItem()) return; 369 if (!mailView->currentItem()) return;
326 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 370 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
327 /* just the RIGHT button - or hold on pda */ 371 /* just the RIGHT button - or hold on pda */
328 if (button!=2) {return;} 372 if (button!=2) {return;}
329 if (!item) return; 373 if (!item) return;
330 QPopupMenu *m = new QPopupMenu(0); 374 QPopupMenu *m = new QPopupMenu(0);
331 if (m) 375 if (m)
332 { 376 {
333 if (mailtype==MAILLIB::A_NNTP) { 377 if (mailtype==MAILLIB::A_NNTP) {
334 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 378 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
335 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 379 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
336 m->insertSeparator(); 380 m->insertSeparator();
337 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 381 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
338 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 382 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
339 } else { 383 } else {
340 if (folderView->currentisDraft()) { 384 if (folderView->currentisDraft()) {
341 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 385 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
342 } 386 }
387 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
388 m->insertSeparator();
343 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 389 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
344 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 390 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
345 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 391 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
346 m->insertSeparator(); 392 m->insertSeparator();
347 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 393 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
348 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 394 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
349 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 395 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
350 } 396 }
351 m->setFocus(); 397 m->setFocus();
352 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 398 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
353 delete m; 399 delete m;
354 } 400 }
355} 401}
356 402
357void OpieMail::slotShowFolders( bool show ) 403void OpieMail::slotShowFolders( bool show )
358{ 404{
359 if ( show && folderView->isHidden() ) 405 if ( show && folderView->isHidden() )
360 { 406 {
361 folderView->show(); 407 folderView->show();
362 } 408 }
363 else if ( !show && !folderView->isHidden() ) 409 else if ( !show && !folderView->isHidden() )
364 { 410 {
365 folderView->hide(); 411 folderView->hide();
366 } 412 }
367} 413}
368 414
369void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 415void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
370{ 416{
371 MailListViewItem*item = 0; 417 MailListViewItem*item = 0;
372 mailView->clear(); 418 mailView->clear();
373 419
374 QValueList<RecMailP>::ConstIterator it; 420 QValueList<RecMailP>::ConstIterator it;
375 for (it = list.begin(); it != list.end();++it) 421 for (it = list.begin(); it != list.end();++it)
376 { 422 {
377 item = new MailListViewItem(mailView,item); 423 item = new MailListViewItem(mailView,item);
378 item->storeData((*it)); 424 item->storeData((*it));
379 item->showEntry(); 425 item->showEntry();
380 } 426 }
381} 427}
382 428
383void OpieMail::mailLeftClicked( QListViewItem *item ) 429void OpieMail::mailLeftClicked( QListViewItem *item )
384{ 430{
385 mailView->clearSelection(); 431 mailView->clearSelection();
386 /* just LEFT button - or tap with stylus on pda */ 432 /* just LEFT button - or tap with stylus on pda */
387 //if (button!=1) return; 433 //if (button!=1) return;
388 if (!item) return; 434 if (!item) return;
389 if (folderView->currentisDraft()) { 435 if (folderView->currentisDraft()) {
390 reEditMail(); 436 reEditMail();
391 } else { 437 } else {
392 displayMail(); 438 displayMail();
393 } 439 }
394} 440}
395 441
396void OpieMail::slotMoveCopyMail() 442void OpieMail::slotMoveCopyMail()
397{ 443{
398 if (!mailView->currentItem()) return; 444 if (!mailView->currentItem()) return;
399 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 445 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
400 AbstractMail*targetMail = 0; 446 AbstractMail*targetMail = 0;
401 QString targetFolder = ""; 447 QString targetFolder = "";
402 Selectstore sels; 448 Selectstore sels;
403 folderView->setupFolderselect(&sels); 449 folderView->setupFolderselect(&sels);
404 if (!sels.exec()) return; 450 if (!sels.exec()) return;
405 targetMail = sels.currentMail(); 451 targetMail = sels.currentMail();
406 targetFolder = sels.currentFolder(); 452 targetFolder = sels.currentFolder();
407 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 453 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
408 targetFolder.isEmpty()) 454 targetFolder.isEmpty())
409 { 455 {
410 return; 456 return;
411 } 457 }
412 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 458 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
413 { 459 {
414 QMessageBox::critical(0,i18n("Error creating new Folder"), 460 QMessageBox::critical(0,i18n("Error creating new Folder"),
415 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 461 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
416 return; 462 return;
417 } 463 }
418 sels.hide(); 464 sels.hide();
419 qApp->processEvents(); 465 qApp->processEvents();
420 // qDebug("hiding sels "); 466 // qDebug("hiding sels ");
421 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 467 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
422 folderView->refreshCurrent(); 468 folderView->refreshCurrent();
423} 469}
424 470
425void OpieMail::slotMoveCopyAllMail() 471void OpieMail::slotMoveCopyAllMail()
426{ 472{
427 473
428 if (!mailView->currentItem()) return; 474 if (!mailView->currentItem()) return;
429 QValueList<RecMailP> t; 475 QValueList<RecMailP> t;
430 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 476 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
431 { 477 {
432 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 478 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
433 while ( item ) { 479 while ( item ) {
434 if ( item->isSelected() ) { 480 if ( item->isSelected() ) {
435 t.append( item->data() ); 481 t.append( item->data() );
436 } 482 }
437 item = (MailListViewItem*)item->nextSibling(); 483 item = (MailListViewItem*)item->nextSibling();
438 } 484 }
439 } 485 }
440 // else 486 // else
441 // return; 487 // return;
442 if ( t.count() == 0 ) 488 if ( t.count() == 0 )
443 return; 489 return;
444 RecMailP mail = t.first(); 490 RecMailP mail = t.first();
445 AbstractMail*targetMail = 0; 491 AbstractMail*targetMail = 0;
446 QString targetFolder = ""; 492 QString targetFolder = "";
447 Selectstore sels; 493 Selectstore sels;
448 folderView->setupFolderselect(&sels); 494 folderView->setupFolderselect(&sels);
449 if (!sels.exec()) return; 495 if (!sels.exec()) return;
450 targetMail = sels.currentMail(); 496 targetMail = sels.currentMail();
451 targetFolder = sels.currentFolder(); 497 targetFolder = sels.currentFolder();
452 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 498 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
453 targetFolder.isEmpty()) 499 targetFolder.isEmpty())
454 { 500 {
455 return; 501 return;
456 } 502 }
457 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 503 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
458 { 504 {
459 QMessageBox::critical(0,i18n("Error creating new Folder"), 505 QMessageBox::critical(0,i18n("Error creating new Folder"),
460 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 506 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
461 return; 507 return;
462 } 508 }
463 sels.hide(); 509 sels.hide();
464 qApp->processEvents(); 510 qApp->processEvents();
465 //qDebug("hiding sels "); 511 //qDebug("hiding sels ");
466 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 512 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
467 folderView->refreshCurrent(); 513 folderView->refreshCurrent();
468} 514}
469 515
470void OpieMail::reEditMail() 516void OpieMail::reEditMail()
471{ 517{
472 if (!mailView->currentItem()) return; 518 if (!mailView->currentItem()) return;
473 519
474 ComposeMail compose( settings, this, 0, true ); 520 ComposeMail compose( settings, this, 0, true );
475 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 521 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
476 compose.slotAdjustColumns(); 522 compose.slotAdjustColumns();
477#ifndef DESKTOP_VERSION 523#ifndef DESKTOP_VERSION
478 compose.showMaximized(); 524 compose.showMaximized();
479#else 525#else
480 compose.resize(640,480); 526 compose.resize(640,480);
481#endif 527#endif
482 compose.exec(); 528 compose.exec();
483} 529}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 9de95f8..44ab1ec 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -1,55 +1,56 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef OPIEMAIL_H 2#ifndef OPIEMAIL_H
3#define OPIEMAIL_H 3#define OPIEMAIL_H
4 4
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7 7
8#include <opie2/osmartpointer.h> 8#include <opie2/osmartpointer.h>
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10 10
11class OpieMail : public MainWindow 11class OpieMail : public MainWindow
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 OpieMail( QWidget *parent = 0, const char *name = 0 ); 16 OpieMail( QWidget *parent = 0, const char *name = 0 );
17 virtual ~OpieMail(); 17 virtual ~OpieMail();
18 static QString appName() { return QString::fromLatin1("kopiemail"); } 18 static QString appName() { return QString::fromLatin1("kopiemail"); }
19 19
20public slots: 20public slots:
21 virtual void slotwriteMail(const QString&name,const QString&email); 21 virtual void slotwriteMail(const QString&name,const QString&email);
22 virtual void slotwriteMail2(const QString&nameemail); 22 virtual void slotwriteMail2(const QString&nameemail);
23 virtual void slotComposeMail(); 23 virtual void slotComposeMail();
24 virtual void slotExtAppHandler(); 24 virtual void slotExtAppHandler();
25 virtual void appMessage(const QCString &msg, const QByteArray &data); 25 virtual void appMessage(const QCString &msg, const QByteArray &data);
26 virtual void message(const QCString &msg, const QByteArray &data); 26 virtual void message(const QCString &msg, const QByteArray &data);
27protected slots: 27protected slots:
28 virtual void slotSendQueued(); 28 virtual void slotSendQueued();
29 virtual void slotSearchMails(); 29 virtual void slotSearchMails();
30 virtual void slotEditSettings(); 30 virtual void slotEditSettings();
31 virtual void slotEditAccounts(); 31 virtual void slotEditAccounts();
32 virtual void displayMail(); 32 virtual void displayMail();
33 virtual void replyMail();
33 virtual void slotDeleteMail(); 34 virtual void slotDeleteMail();
34 virtual void slotGetMail(); 35 virtual void slotGetMail();
35 virtual void slotGetAllMail(); 36 virtual void slotGetAllMail();
36 virtual void slotDeleteAllMail(); 37 virtual void slotDeleteAllMail();
37 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 38 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
38 virtual void slotShowFolders( bool show ); 39 virtual void slotShowFolders( bool show );
39 virtual void refreshMailView(const QValueList<RecMailP>&); 40 virtual void refreshMailView(const QValueList<RecMailP>&);
40 virtual void mailLeftClicked( QListViewItem * ); 41 virtual void mailLeftClicked( QListViewItem * );
41 virtual void slotMoveCopyMail(); 42 virtual void slotMoveCopyMail();
42 virtual void slotMoveCopyAllMail(); 43 virtual void slotMoveCopyAllMail();
43 virtual void reEditMail(); 44 virtual void reEditMail();
44 void clearSelection(); 45 void clearSelection();
45 46
46private: 47private:
47 QString mPendingEmail; 48 QString mPendingEmail;
48 QString mPendingName; 49 QString mPendingName;
49 QByteArray mPendingData; 50 QByteArray mPendingData;
50 QCString mPendingMessage; 51 QCString mPendingMessage;
51 Settings *settings; 52 Settings *settings;
52 53
53}; 54};
54 55
55#endif 56#endif
diff --git a/kmicromail/qpe/global.cpp b/kmicromail/qpe/global.cpp
index f4c6f60..8314f23 100644
--- a/kmicromail/qpe/global.cpp
+++ b/kmicromail/qpe/global.cpp
@@ -1,12 +1,14 @@
1 1
2#include "global.h" 2#include "global.h"
3 3#include <qstatusbar.h>
4QStatusBar* globalSstatusBarMainWindow = 0;
4namespace Global{ 5namespace Global{
5 6
6 void statusMessage(QString message) 7 void statusMessage(QString message)
7 { 8 {
8 9 if ( globalSstatusBarMainWindow )
10 globalSstatusBarMainWindow->message( message,15000 );
9 qDebug("statusMessage %s ", message.latin1()); 11 qDebug("statusMessage %s ", message.latin1());
10 } 12 }
11} 13}
12 14
diff --git a/kmicromail/qpe/qdialog.h b/kmicromail/qpe/qdialog.h
index aafdf80..c63133d 100644
--- a/kmicromail/qpe/qdialog.h
+++ b/kmicromail/qpe/qdialog.h
@@ -1,33 +1,29 @@
1 1
2#ifndef MINIKDE_KDIALOG_H 2#ifndef MINIKDE_KDIALOG_H
3 3
4#ifndef DEFINE_QDIALOG_HACK 4#ifndef DEFINE_QDIALOG_HACK
5#define DEFINE_QDIALOG_HACK 5#define DEFINE_QDIALOG_HACK
6#warning call of include <qdialog.h> 6#warning call of include <qdialog.h>
7#warning including /usr/local/qt/include/qdialog.h 7#warning including /usr/local/qt/include/qdialog.h
8#warning if you get a compiling error 8#warning if you get a compiling error
9#warning please adjust your path here! 9#warning please adjust your path here!
10 10
11#include "/usr/local/qt/include/qdialog.h" 11#include "/usr/local/qt/include/qdialog.h"
12class QDialog_hacked : public QDialog 12class QDialog_hacked : public QDialog
13{ 13{
14 //Q__OBJECT 14 //Q__OBJECT
15 15
16 public: 16 public:
17 QDialog_hacked ( QWidget * parent=0, const char * name=0, bool modal=true, WFlags f=0 ); 17 QDialog_hacked ( QWidget * parent=0, const char * name=0, bool modal=true, WFlags f=0 );
18 18
19}; 19};
20 20
21#define QDialog QDialog_hacked 21#define QDialog QDialog_hacked
22 22
23#endif 23#endif
24 24
25#else 25#else
26#warning ******************************************
27#warning ******************************************
28#warning ******************************************
29#warning ******************************************
30#warning "/usr/local/qt/include/qdialog.h" for KDialog 26#warning "/usr/local/qt/include/qdialog.h" for KDialog
31#include "/usr/local/qt/include/qdialog.h" 27#include "/usr/local/qt/include/qdialog.h"
32 28
33#endif 29#endif
diff --git a/kmicromail/qpe/qdialog_hacked.cpp b/kmicromail/qpe/qdialog_hacked.cpp
index 3669312..0a34cec 100644
--- a/kmicromail/qpe/qdialog_hacked.cpp
+++ b/kmicromail/qpe/qdialog_hacked.cpp
@@ -1,31 +1,27 @@
1 1
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <klocale.h> 5#include <klocale.h>
6#ifdef QDialog 6#ifdef QDialog
7#undef QDialog 7#undef QDialog
8#endif 8#endif
9 QDialog_hacked::QDialog_hacked ( QWidget * parent, const char * name, bool modal, WFlags f ) 9 QDialog_hacked::QDialog_hacked ( QWidget * parent, const char * name, bool modal, WFlags f )
10 : QDialog( parent,name,modal, f) 10 : QDialog( parent,name,modal, f)
11 { 11 {
12 qDebug("******************** "); 12 qDebug("New hacked QDialog for ompi desktop");
13 qDebug("******************** ");
14 qDebug("******************** ");
15 qDebug("******************** ");
16 qDebug("New hacked QDialog for ompi ");
17 //QTimer::singleShot( 1, this,SLOT(addaddbuttons()) ); 13 //QTimer::singleShot( 1, this,SLOT(addaddbuttons()) );
18 14
19 setOrientation ( Vertical ); 15 setOrientation ( Vertical );
20 QHBox * hb = new QHBox ( this ); 16 QHBox * hb = new QHBox ( this );
21 QPushButton *ok = new QPushButton( i18n("OK"), hb ); 17 QPushButton *ok = new QPushButton( i18n("OK"), hb );
22 QPushButton *cancel = new QPushButton( i18n("Cancel"), hb ); 18 QPushButton *cancel = new QPushButton( i18n("Cancel"), hb );
23 setExtension ( hb ); 19 setExtension ( hb );
24 showExtension ( true ); 20 showExtension ( true );
25 connect ( ok, SIGNAL ( clicked()),this, SLOT (accept() ) ); 21 connect ( ok, SIGNAL ( clicked()),this, SLOT (accept() ) );
26 connect ( cancel, SIGNAL ( clicked()),this, SLOT (reject() ) ); 22 connect ( cancel, SIGNAL ( clicked()),this, SLOT (reject() ) );
27 //setWFlags(WStyle_MinMax ); 23 //setWFlags(WStyle_MinMax );
28 24
29 } 25 }
30 26
31 27
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index f1e0225..2093678 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,536 +1,531 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3 3
4 4
5#include <kfiledialog.h> 5#include <kfiledialog.h>
6#include "koprefs.h" 6#include "koprefs.h"
7#include <klocale.h> 7#include <klocale.h>
8#include <kglobal.h> 8#include <kglobal.h>
9#include <kapplication.h> 9#include <kapplication.h>
10 10
11#ifdef MINIKDE_KDIALOG_H 11#ifdef MINIKDE_KDIALOG_H
12#undef MINIKDE_KDIALOG_H 12#undef MINIKDE_KDIALOG_H
13#endif 13#endif
14 14
15#include "composemail.h" 15#include "composemail.h"
16#include "viewmail.h" 16#include "viewmail.h"
17 17
18#include <libmailwrapper/settings.h> 18#include <libmailwrapper/settings.h>
19#include <libmailwrapper/abstractmail.h> 19#include <libmailwrapper/abstractmail.h>
20#include <libmailwrapper/mailtypes.h> 20#include <libmailwrapper/mailtypes.h>
21 21
22#include <qdialog.h> 22#include <qdialog.h>
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26/* QT */ 26/* QT */
27#include <qtextbrowser.h> 27#include <qtextbrowser.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qaction.h> 30#include <qaction.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qlayout.h> 33#include <qlayout.h>
34 34
35//using namespace Opie::Ui; 35//using namespace Opie::Ui;
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
39 const QString&fsize,int num,const QValueList<int>&path) 39 const QString&fsize,int num,const QValueList<int>&path)
40 : QListViewItem(parent,after),_partNum(num) 40 : QListViewItem(parent,after),_partNum(num)
41{ 41{
42 _path=path; 42 _path=path;
43 setText(0, mime); 43 setText(0, mime);
44 setText(1, desc); 44 setText(1, desc);
45 setText(2, file); 45 setText(2, file);
46 setText(3, fsize); 46 setText(3, fsize);
47} 47}
48 48
49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
50 const QString&fsize,int num,const QValueList<int>&path) 50 const QString&fsize,int num,const QValueList<int>&path)
51 : QListViewItem(parent,after),_partNum(num) 51 : QListViewItem(parent,after),_partNum(num)
52{ 52{
53 _path=path; 53 _path=path;
54 setText(0, mime); 54 setText(0, mime);
55 setText(1, desc); 55 setText(1, desc);
56 setText(2, file); 56 setText(2, file);
57 setText(3, fsize); 57 setText(3, fsize);
58} 58}
59 59
60bool AttachItem::isParentof(const QValueList<int>&path) 60bool AttachItem::isParentof(const QValueList<int>&path)
61{ 61{
62 /* if not set, then no parent */ 62 /* if not set, then no parent */
63 if (path.count()==0||_path.count()==0) return false; 63 if (path.count()==0||_path.count()==0) return false;
64 /* the parent must have one digit less then a child */ 64 /* the parent must have one digit less then a child */
65 if (path.count()!=_path.count()+1) return false; 65 if (path.count()!=_path.count()+1) return false;
66 for (unsigned int i=0; i < _path.count();++i) 66 for (unsigned int i=0; i < _path.count();++i)
67 { 67 {
68 if (_path[i]!=path[i]) return false; 68 if (_path[i]!=path[i]) return false;
69 } 69 }
70 return true; 70 return true;
71} 71}
72 72
73AttachItem* ViewMail::searchParent(const QValueList<int>&path) 73AttachItem* ViewMail::searchParent(const QValueList<int>&path)
74{ 74{
75 QListViewItemIterator it( attachments ); 75 QListViewItemIterator it( attachments );
76 for ( ; it.current(); ++it ) 76 for ( ; it.current(); ++it )
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] = body->Bodytext(); 101 m_mail[2] = QString::fromUtf8( body->Bodytext().latin1() );
102 // qDebug("********text %s ",m_mail[2].latin1() );
102 attachbutton->setEnabled(body->Parts().count()>0); 103 attachbutton->setEnabled(body->Parts().count()>0);
103 attachments->setEnabled(body->Parts().count()>0); 104 attachments->setEnabled(body->Parts().count()>0);
104 if (body->Parts().count()==0) 105 if (body->Parts().count()==0)
105 { 106 {
106 return; 107 return;
107 } 108 }
108 AttachItem * curItem=0; 109 AttachItem * curItem=0;
109 AttachItem * parentItem = 0; 110 AttachItem * parentItem = 0;
110 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
111 QString desc,fsize; 112 QString desc,fsize;
112 double s = body->Description()->Size(); 113 double s = body->Description()->Size();
113 int w; 114 int w;
114 w=0; 115 w=0;
115 116
116 while (s>1024) 117 while (s>1024)
117 { 118 {
118 s/=1024; 119 s/=1024;
119 ++w; 120 ++w;
120 if (w>=2) break; 121 if (w>=2) break;
121 } 122 }
122 123
123 QString q=""; 124 QString q="";
124 switch(w) 125 switch(w)
125 { 126 {
126 case 1: 127 case 1:
127 q="k"; 128 q="k";
128 break; 129 break;
129 case 2: 130 case 2:
130 q="M"; 131 q="M";
131 break; 132 break;
132 default: 133 default:
133 break; 134 break;
134 } 135 }
135 136
136 { 137 {
137 /* I did not found a method to make a CONTENT reset on a QTextStream 138 /* I did not found a method to make a CONTENT reset on a QTextStream
138 so I use this construct that the stream will re-constructed in each 139 so I use this construct that the stream will re-constructed in each
139 loop. To let it work, the textstream is packed into a own area of 140 loop. To let it work, the textstream is packed into a own area of
140 code is it will be destructed after finishing its small job. 141 code is it will be destructed after finishing its small job.
141 */ 142 */
142 QTextOStream o(&fsize); 143 QTextOStream o(&fsize);
143 if (w>0) o.precision(2); else o.precision(0); 144 if (w>0) o.precision(2); else o.precision(0);
144 o.setf(QTextStream::fixed); 145 o.setf(QTextStream::fixed);
145 o << s << " " << q << "Byte"; 146 o << s << " " << q << "Byte";
146 } 147 }
147 148
148 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 149 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
149 QString filename = ""; 150 QString filename = "";
150 151
151 for (unsigned int i = 0; i < body->Parts().count();++i) 152 for (unsigned int i = 0; i < body->Parts().count();++i)
152 { 153 {
153 filename = ""; 154 filename = "";
154 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 155 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
155 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 156 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
156 for (;it!=body->Parts()[i]->Parameters().end();++it) 157 for (;it!=body->Parts()[i]->Parameters().end();++it)
157 { 158 {
158 if (it.key().lower()=="name") 159 if (it.key().lower()=="name")
159 { 160 {
160 filename=it.data(); 161 filename=it.data();
161 } 162 }
162 } 163 }
163 s = body->Parts()[i]->Size(); 164 s = body->Parts()[i]->Size();
164 w = 0; 165 w = 0;
165 while (s>1024) 166 while (s>1024)
166 { 167 {
167 s/=1024; 168 s/=1024;
168 ++w; 169 ++w;
169 if (w>=2) break; 170 if (w>=2) break;
170 } 171 }
171 switch(w) 172 switch(w)
172 { 173 {
173 case 1: 174 case 1:
174 q="k"; 175 q="k";
175 break; 176 break;
176 case 2: 177 case 2:
177 q="M"; 178 q="M";
178 break; 179 break;
179 default: 180 default:
180 q=""; 181 q="";
181 break; 182 break;
182 } 183 }
183 QTextOStream o(&fsize); 184 QTextOStream o(&fsize);
184 if (w>0) o.precision(2); else o.precision(0); 185 if (w>0) o.precision(2); else o.precision(0);
185 o.setf(QTextStream::fixed); 186 o.setf(QTextStream::fixed);
186 o << s << " " << q << "Byte"; 187 o << s << " " << q << "Byte";
187 desc = body->Parts()[i]->Description(); 188 desc = body->Parts()[i]->Description();
188 parentItem = searchParent(body->Parts()[i]->Positionlist()); 189 parentItem = searchParent(body->Parts()[i]->Positionlist());
189 if (parentItem) 190 if (parentItem)
190 { 191 {
191 AttachItem*temp = lastChild(parentItem); 192 AttachItem*temp = lastChild(parentItem);
192 if (temp) curItem = temp; 193 if (temp) curItem = temp;
193 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 194 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
194 attachments->setRootIsDecorated(true); 195 attachments->setRootIsDecorated(true);
195 curItem = parentItem; 196 curItem = parentItem;
196 } 197 }
197 else 198 else
198 { 199 {
199 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 200 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
200 } 201 }
201 } 202 }
202} 203}
203 204
204 205
205void ViewMail::slotShowHtml( bool state ) 206void ViewMail::slotShowHtml( bool state )
206{ 207{
207 m_showHtml = state; 208 m_showHtml = state;
208 setText(); 209 setText();
209} 210}
210 211
211void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 212void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
212{ 213{
213 if (!item ) 214 if (!item )
214 return; 215 return;
215 216
216 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 217 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
217 { 218 {
218 setText(); 219 setText();
219 return; 220 return;
220 } 221 }
221 QPopupMenu *menu = new QPopupMenu(); 222 QPopupMenu *menu = new QPopupMenu();
222 int ret=0; 223 int ret=0;
223 224
224 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 225 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
225 { 226 {
226 menu->insertItem( i18n( "Show Text" ), 1 ); 227 menu->insertItem( i18n( "Show Text" ), 1 );
227 } 228 }
228 if (item->text(0).left(6)=="image/") { 229 if (item->text(0).left(6)=="image/") {
229 menu->insertItem(i18n("Display image preview"),2); 230 menu->insertItem(i18n("Display image preview"),2);
230 } 231 }
231 menu->insertItem( i18n( "Save Attachment" ), 0 ); 232 menu->insertItem( i18n( "Save Attachment" ), 0 );
232 menu->insertSeparator(1); 233 menu->insertSeparator(1);
233 234
234 ret = menu->exec( point, 0 ); 235 ret = menu->exec( point, 0 );
235 236
236 switch(ret) 237 switch(ret)
237 { 238 {
238 case 0: 239 case 0:
239 { 240 {
240 //MimeTypes types; 241 //MimeTypes types;
241 //types.insert( "all", "*" ); 242 //types.insert( "all", "*" );
242 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 243 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
243 244
244 if( !str.isEmpty() ) 245 if( !str.isEmpty() )
245 { 246 {
246 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 247 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
247 if (content) 248 if (content)
248 { 249 {
249 QFile output(str); 250 QFile output(str);
250 output.open(IO_WriteOnly); 251 output.open(IO_WriteOnly);
251 output.writeBlock(content->Content(),content->Length()); 252 output.writeBlock(content->Content(),content->Length());
252 output.close(); 253 output.close();
253 delete content; 254 delete content;
254 } 255 }
255 } 256 }
256 } 257 }
257 break ; 258 break ;
258 259
259 case 2: 260 case 2:
260 { 261 {
261#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
262 QString tmpfile = locateLocal( "tmp", "opiemail-image"); 263 QString tmpfile = locateLocal( "tmp", "opiemail-image");
263#else 264#else
264 QString tmpfile = "/tmp/opiemail-image"; 265 QString tmpfile = "/tmp/opiemail-image";
265#endif 266#endif
266 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 267 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
267 if (content) { 268 if (content) {
268 QFile output(tmpfile); 269 QFile output(tmpfile);
269 output.open(IO_WriteOnly); 270 output.open(IO_WriteOnly);
270 output.writeBlock(content->Content(),content->Length()); 271 output.writeBlock(content->Content(),content->Length());
271 output.close(); 272 output.close();
272 delete content; 273 delete content;
273 MailImageDlg iview(""); 274 MailImageDlg iview("");
274 iview.setName(tmpfile); 275 iview.setName(tmpfile);
275 KApplication::execDialog(&iview); 276 KApplication::execDialog(&iview);
276 output.remove(); 277 output.remove();
277 } 278 }
278 } 279 }
279 break; 280 break;
280 case 1: 281 case 1:
281 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
282 { 283 {
283 setText(); 284 setText();
284 } 285 }
285 else 286 else
286 { 287 {
287 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
288 { // 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
289 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() ] ) );
290 } 291 }
291 } 292 }
292 break; 293 break;
293 } 294 }
294 delete menu; 295 delete menu;
295} 296}
296 297
297 298
298void ViewMail::setMail(const RecMailP&mail ) 299void ViewMail::setMail(const RecMailP&mail )
299{ 300{
300 301
301 m_recMail = mail; 302 m_recMail = mail;
302 303
303 m_mail[0] = mail->getFrom(); 304 m_mail[0] = QString::fromUtf8( mail->getFrom().latin1() );
304 m_mail[1] = mail->getSubject(); 305 m_mail[1] = QString::fromUtf8( mail->getSubject().latin1() );
305 m_mail[3] = mail->getDate(); 306 m_mail[3] = QString::fromUtf8( mail->getDate().latin1() );
306 m_mail[4] = mail->Msgid(); 307 m_mail[4] = QString::fromUtf8( mail->Msgid().latin1() );
307 308
308 m_mail2[0] = mail->To(); 309 m_mail2[0] = mail->To();
309 m_mail2[1] = mail->CC(); 310 m_mail2[1] = mail->CC();
310 m_mail2[2] = mail->Bcc(); 311 m_mail2[2] = mail->Bcc();
311 312
312 setText(); 313 setText();
313} 314}
314 315
315 316
316 317
317ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
318 : ViewMailBase(parent, name, fl), _inLoop(false) 319 : ViewMailBase(parent, name, fl), _inLoop(false)
319{ 320{
320 m_gotBody = false; 321 m_gotBody = false;
321 deleted = false; 322 deleted = false;
322 323
323 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 324 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
324 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 325 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
325 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
326 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
327 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
328 329
329 attachments->setEnabled(m_gotBody); 330 attachments->setEnabled(m_gotBody);
330 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) ) );
331 332
332 readConfig(); 333 readConfig();
333 attachments->setSorting(-1); 334 attachments->setSorting(-1);
334} 335}
335 336
336void ViewMail::readConfig() 337void ViewMail::readConfig()
337{ 338{
338 339
339 setFont ( KOPrefs::instance()->mReadFont ); 340 setFont ( KOPrefs::instance()->mReadFont );
340 m_showHtml = KOPrefs::instance()->mViewAsHtml; 341 m_showHtml = KOPrefs::instance()->mViewAsHtml;
341 showHtml->setOn( m_showHtml ); 342 showHtml->setOn( m_showHtml );
342} 343}
343 344
344void ViewMail::setText() 345void ViewMail::setText()
345{ 346{
346 347
347 QString toString; 348 QString toString;
348 QString ccString; 349 QString ccString;
349 QString bccString; 350 QString bccString;
350 351
351 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 352
352 { 353 toString = QString::fromUtf8(m_mail2[0].join(",").latin1());
353 toString += (*it); 354 ccString = QString::fromUtf8(m_mail2[1].join(",").latin1());
354 } 355 bccString = QString::fromUtf8(m_mail2[2].join(",").latin1());
355 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 356
356 {
357 ccString += (*it);
358 }
359 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
360 {
361 bccString += (*it);
362 }
363 357
364 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 358 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
365 359
366 m_mailHtml = "<html><body>" 360 m_mailHtml = "<html><body>"
367 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 361 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
368 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 362 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
369 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 363 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
370 "<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>"
371 "<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>" +
372 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 366 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
373 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 367 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
374 "</td></tr></table><font>"; 368 "</td></tr></table><font>";
375 369
376 if ( !m_showHtml ) 370 if ( !m_showHtml )
377 { 371 {
378 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 372 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
379 } 373 }
380 else 374 else
381 { 375 {
382 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 376 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
383 } 377 }
384 // remove later in favor of a real handling 378 // remove later in favor of a real handling
385 m_gotBody = true; 379 m_gotBody = true;
386} 380}
387 381
388 382
389ViewMail::~ViewMail() 383ViewMail::~ViewMail()
390{ 384{
391 m_recMail->Wrapper()->cleanMimeCache(); 385 m_recMail->Wrapper()->cleanMimeCache();
392 hide(); 386 hide();
393} 387}
394 388
395void ViewMail::hide() 389void ViewMail::hide()
396{ 390{
397 QWidget::hide(); 391 QWidget::hide();
398 392
399 if (_inLoop) 393 if (_inLoop)
400 { 394 {
401 _inLoop = false; 395 _inLoop = false;
402 qApp->exit_loop(); 396 qApp->exit_loop();
403 397
404 } 398 }
405 399
406} 400}
407 401
408void ViewMail::exec() 402void ViewMail::exec()
409{ 403{
410 show(); 404 show();
411 405
412 if (!_inLoop) 406 if (!_inLoop)
413 { 407 {
414 _inLoop = true; 408 _inLoop = true;
415 qApp->enter_loop(); 409 qApp->enter_loop();
416 } 410 }
417 411
418} 412}
419 413
420QString ViewMail::deHtml(const QString &string) 414QString ViewMail::deHtml(const QString &string)
421{ 415{
422 QString string_ = string; 416 QString string_ = string;
423 string_.replace(QRegExp("&"), "&amp;"); 417 string_.replace(QRegExp("&"), "&amp;");
424 string_.replace(QRegExp("<"), "&lt;"); 418 string_.replace(QRegExp("<"), "&lt;");
425 string_.replace(QRegExp(">"), "&gt;"); 419 string_.replace(QRegExp(">"), "&gt;");
426 string_.replace(QRegExp("\\n"), "<br>"); 420 string_.replace(QRegExp("\\n"), "<br>");
427 return string_; 421 return string_;
428} 422}
429 423
430void ViewMail::slotReply() 424void ViewMail::slotReply()
431{ 425{
432 if (!m_gotBody) 426 if (!m_gotBody)
433 { 427 {
434 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); 428 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok"));
435 return; 429 return;
436 } 430 }
437 431
438 QString rtext; 432 QString rtext;
439 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 433 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
440 .arg( m_mail[0] ) 434 .arg( m_mail[0] )
441 .arg( m_mail[3] ); 435 .arg( m_mail[3] );
442 436
443 QString text = m_mail[2]; 437 QString text = m_mail[2];
444 QStringList lines = QStringList::split(QRegExp("\\n"), text); 438 QStringList lines = QStringList::split(QRegExp("\\n"), text);
445 QStringList::Iterator it; 439 QStringList::Iterator it;
446 for (it = lines.begin(); it != lines.end(); it++) 440 for (it = lines.begin(); it != lines.end(); it++)
447 { 441 {
448 rtext += "> " + *it + "\n"; 442 rtext += "> " + *it + "\n";
449 } 443 }
450 rtext += "\n"; 444 rtext += "\n";
451 445
452 QString prefix; 446 QString prefix;
453 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 447 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
454 else prefix = "Re: "; // no i18n on purpose 448 else prefix = "Re: "; // no i18n on purpose
455 449
456 Settings *settings = new Settings(); 450 Settings *settings = new Settings();
457 ComposeMail composer( settings ,this, 0, true); 451 ComposeMail composer( settings ,this, 0, true);
458 if (m_recMail->Replyto().isEmpty()) { 452 if (m_recMail->Replyto().isEmpty()) {
459 composer.setTo( m_recMail->getFrom()); 453 composer.setTo( QString::fromUtf8( m_recMail->getFrom().latin1()));
460 } else { 454 } else {
461 composer.setTo( m_recMail->Replyto()); 455 composer.setTo( QString::fromUtf8( m_recMail->Replyto().latin1()));
462 } 456 }
463 composer.setSubject( prefix + m_mail[1] ); 457 composer.setSubject( prefix + m_mail[1] );
464 composer.setMessage( rtext ); 458 composer.setMessage( rtext );
465 composer.setInReplyTo(m_recMail->Msgid()); 459 composer.setInReplyTo(m_recMail->Msgid());
466 460
467 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 461 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
468 { 462 {
469 m_recMail->Wrapper()->answeredMail(m_recMail); 463 m_recMail->Wrapper()->answeredMail(m_recMail);
470 } 464 }
465 delete settings;
471} 466}
472 467
473void ViewMail::slotForward() 468void ViewMail::slotForward()
474{ 469{
475 if (!m_gotBody) 470 if (!m_gotBody)
476 { 471 {
477 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"));
478 return; 473 return;
479 } 474 }
480 475
481 QString ftext; 476 QString ftext;
482 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 477 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
483 .arg( m_mail[0] ); 478 .arg( m_mail[0] );
484 if (!m_mail[3].isNull()) 479 if (!m_mail[3].isNull())
485 ftext += QString("Date: %1\n") 480 ftext += QString("Date: %1\n")
486 .arg( m_mail[3] ); 481 .arg( m_mail[3] );
487 if (!m_mail[0].isNull()) 482 if (!m_mail[0].isNull())
488 ftext += QString("From: %1\n") 483 ftext += QString("From: %1\n")
489 .arg( m_mail[0] ); 484 .arg( m_mail[0] );
490 if (!m_mail[1].isNull()) 485 if (!m_mail[1].isNull())
491 ftext += QString("Subject: %1\n") 486 ftext += QString("Subject: %1\n")
492 .arg( m_mail[1] ); 487 .arg( m_mail[1] );
493 488
494 ftext += QString("\n%1\n") 489 ftext += QString("\n%1\n")
495 .arg( m_mail[2]); 490 .arg( m_mail[2]);
496 491
497 ftext += QString("----- End forwarded message -----\n"); 492 ftext += QString("----- End forwarded message -----\n");
498 493
499 Settings *settings = new Settings(); 494 Settings *settings = new Settings();
500 ComposeMail composer( settings ,this, 0, true); 495 ComposeMail composer( settings ,this, 0, true);
501 composer.setSubject( "Fwd: " + m_mail[1] ); 496 composer.setSubject( "Fwd: " + m_mail[1] );
502 composer.setMessage( ftext ); 497 composer.setMessage( ftext );
503 if ( QDialog::Accepted == KApplication::execDialog( &composer )) 498 if ( QDialog::Accepted == KApplication::execDialog( &composer ))
504 { 499 {
505 } 500 }
506} 501}
507 502
508void ViewMail::slotDeleteMail( ) 503void ViewMail::slotDeleteMail( )
509{ 504{
510 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 505 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
511 { 506 {
512 m_recMail->Wrapper()->deleteMail( m_recMail ); 507 m_recMail->Wrapper()->deleteMail( m_recMail );
513 hide(); 508 hide();
514 deleted = true; 509 deleted = true;
515 } 510 }
516} 511}
517 512
518MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 513MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f)
519 : QDialog(parent,name,modal) 514 : QDialog(parent,name,modal)
520{ 515{
521 QVBoxLayout*dlglayout = new QVBoxLayout(this); 516 QVBoxLayout*dlglayout = new QVBoxLayout(this);
522 dlglayout->setSpacing(2); 517 dlglayout->setSpacing(2);
523 dlglayout->setMargin(1); 518 dlglayout->setMargin(1);
524 //m_imageview = new Opie::MM::OImageScrollView(this); 519 //m_imageview = new Opie::MM::OImageScrollView(this);
525 //dlglayout->addWidget(m_imageview); 520 //dlglayout->addWidget(m_imageview);
526} 521}
527 522
528MailImageDlg::~MailImageDlg() 523MailImageDlg::~MailImageDlg()
529{ 524{
530} 525}
531 526
532void MailImageDlg::setName(const QString&fname) 527void MailImageDlg::setName(const QString&fname)
533{ 528{
534 qDebug("viewmail.cpp: MailImageDlg::setName Pending"); 529 qDebug("viewmail.cpp: MailImageDlg::setName Pending");
535 // m_imageview->setImage(fname); 530 // m_imageview->setImage(fname);
536} 531}