summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-30 11:40:54 (UTC)
committer zautrix <zautrix>2004-10-30 11:40:54 (UTC)
commit632b43950f1ac2980c281eb8901d797deb0ba971 (patch) (unidiff)
tree72534bf865fbef61a29d5e8b2e65672c15b432c0
parent0057c2a8e90346583f606491730cae819d2313ac (diff)
downloadkdepimpi-632b43950f1ac2980c281eb8901d797deb0ba971.zip
kdepimpi-632b43950f1ac2980c281eb8901d797deb0ba971.tar.gz
kdepimpi-632b43950f1ac2980c281eb8901d797deb0ba971.tar.bz2
made ompi compiling on desktop
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kdepim-desktop.pro2
-rw-r--r--kmicromail/composemail.cpp13
-rw-r--r--kmicromail/kmicromail.pro77
-rw-r--r--kmicromail/libetpan/libetpan.pro274
-rw-r--r--kmicromail/libmailwrapper/generatemail.h5
-rw-r--r--kmicromail/libmailwrapper/libmailwrapper.pro64
-rw-r--r--kmicromail/libmailwrapper/mailwrapper.h2
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp22
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.h6
-rw-r--r--kmicromail/libmailwrapper/settings.h1
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp15
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.h2
-rw-r--r--kmicromail/libmailwrapper/storemail.h2
-rw-r--r--kmicromail/mainwindow.cpp4
-rw-r--r--kmicromail/mainwindow.h1
-rw-r--r--kmicromail/opiemail.cpp6
-rw-r--r--kmicromail/qpe/global.cpp12
-rw-r--r--kmicromail/qpe/global.h12
-rw-r--r--kmicromail/qpe/qpeapplication.h5
-rw-r--r--kmicromail/viewmail.cpp1
-rw-r--r--microkde/microkde.pro7
-rw-r--r--microkde/oprocess.cpp1
22 files changed, 496 insertions, 38 deletions
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro
index 5f964ef..6d04a45 100644
--- a/kdepim-desktop.pro
+++ b/kdepim-desktop.pro
@@ -1,6 +1,6 @@
1 1
2 2
3TEMPLATE = subdirs 3TEMPLATE = subdirs
4SUBDIRS = gammu/emb/common gammu/emb/gammu libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir kabc/plugins/file kabc/plugins/qtopia pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib pwmanager/pwmanager 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
5#kalarmd 5#kalarmd
6 6
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 8eb6d27..0cd0b23 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,496 +1,497 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3#include "composemail.h" 3#include "composemail.h"
4 4
5#include <libmailwrapper/smtpwrapper.h> 5#include <libmailwrapper/smtpwrapper.h>
6#include <libmailwrapper/storemail.h> 6#include <libmailwrapper/storemail.h>
7#include <libmailwrapper/abstractmail.h> 7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9 9
10/* OPIE */ 10/* OPIE */
11//#include <opie2/ofiledialog.h> 11//#include <opie2/ofiledialog.h>
12//#include <opie2/odebug.h> 12//#include <opie2/odebug.h>
13#include <kfiledialog.h> 13#include <kfiledialog.h>
14//#include <qpe/resource.h> 14//#include <qpe/resource.h>
15#include <qpe/global.h> 15#include <qpe/global.h>
16//#include <qpe/contact.h> 16//#include <qpe/contact.h>
17 17
18 18
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qcheckbox.h> 20#include <qcheckbox.h>
21#include <qiconset.h> 21#include <qiconset.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qmultilineedit.h> 25#include <qmultilineedit.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <kabc/addresseedialog.h> 29#include <kabc/addresseedialog.h>
30#include <kabc/stdaddressbook.h> 30#include <kabc/stdaddressbook.h>
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#ifdef DESKTOP_VERSION 32#ifdef DESKTOP_VERSION
33#include <qapplication.h>
33#include <kabc/addresseedialog.h> 34#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION 35#endif //DESKTOP_VERSION
36#include <libkdepim/externalapphandler.h>
37 37
38#include "koprefs.h" 38#include "koprefs.h"
39 39
40//using namespace Opie::Core; 40//using namespace Opie::Core;
41//using namespace Opie::Ui; 41//using namespace Opie::Ui;
42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal )
43 : ComposeMailUI( parent, name, modal ) 43 : ComposeMailUI( parent, name, modal )
44{ 44{
45 mPickLineEdit = 0; 45 mPickLineEdit = 0;
46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
48 settings = s; 48 settings = s;
49 m_replyid = ""; 49 m_replyid = "";
50 if ( KOPrefs::instance()->mUseKapi) { 50 if ( KOPrefs::instance()->mUseKapi) {
51 KConfig config( locateLocal("config", "kabcrc") ); 51 KConfig config( locateLocal("config", "kabcrc") );
52 config.setGroup( "General" ); 52 config.setGroup( "General" );
53 QString whoami_uid = config.readEntry( "WhoAmI" ); 53 QString whoami_uid = config.readEntry( "WhoAmI" );
54 54
55 if ( whoami_uid.isEmpty() ) { 55 if ( whoami_uid.isEmpty() ) {
56 QMessageBox::information( 0, i18n( "Hint" ), 56 QMessageBox::information( 0, i18n( "Hint" ),
57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
58 i18n( "Ok" ) ); 58 i18n( "Ok" ) );
59 59
60 60
61 fillSettings(); 61 fillSettings();
62 } else 62 } else
63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
64 64
65 65
66#ifdef DESKTOP_VERSION 66#ifdef DESKTOP_VERSION
67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
68 QStringList mails = con.emails(); 68 QStringList mails = con.emails();
69 QString defmail = con.preferredEmail(); 69 QString defmail = con.preferredEmail();
70 if ( mails.count() == 0) 70 if ( mails.count() == 0)
71 QMessageBox::information( 0, i18n( "Hint" ), 71 QMessageBox::information( 0, i18n( "Hint" ),
72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
73 i18n( "Ok" ) ); 73 i18n( "Ok" ) );
74 if (defmail.length()!=0) { 74 if (defmail.length()!=0) {
75 fromBox->insertItem(defmail); 75 fromBox->insertItem(defmail);
76 } 76 }
77 QStringList::ConstIterator sit = mails.begin(); 77 QStringList::ConstIterator sit = mails.begin();
78 for (;sit!=mails.end();++sit) { 78 for (;sit!=mails.end();++sit) {
79 if ( (*sit)==defmail) 79 if ( (*sit)==defmail)
80 continue; 80 continue;
81 fromBox->insertItem((*sit)); 81 fromBox->insertItem((*sit));
82 } 82 }
83 senderNameEdit->setText(con.formattedName()); 83 senderNameEdit->setText(con.formattedName());
84#endif 84#endif
85 85
86 } else { 86 } else {
87 fillSettings(); 87 fillSettings();
88 } 88 }
89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
90 90
91 attList->addColumn( i18n( "Name" ) ); 91 attList->addColumn( i18n( "Name" ) );
92 attList->addColumn( i18n( "Size" ) ); 92 attList->addColumn( i18n( "Size" ) );
93 QList<Account> accounts = settings->getAccounts(); 93 QList<Account> accounts = settings->getAccounts();
94 94
95 if ( QApplication::desktop()->width() < 320 ) 95 if ( QApplication::desktop()->width() < 320 )
96 smtpAccountBox->setMaximumWidth( 80 ); 96 smtpAccountBox->setMaximumWidth( 80 );
97 Account *it; 97 Account *it;
98 for ( it = accounts.first(); it; it = accounts.next() ) { 98 for ( it = accounts.first(); it; it = accounts.next() ) {
99 if ( it->getType()==MAILLIB::A_SMTP ) { 99 if ( it->getType()==MAILLIB::A_SMTP ) {
100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
101 smtpAccountBox->insertItem( smtp->getAccountName() ); 101 smtpAccountBox->insertItem( smtp->getAccountName() );
102 smtpAccounts.append( smtp ); 102 smtpAccounts.append( smtp );
103 } 103 }
104 } 104 }
105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
112 mMail = 0; 112 mMail = 0;
113 warnAttach = true; 113 warnAttach = true;
114 QIconSet icon; 114 QIconSet icon;
115 //icon = SmallIcon("fileexport"); 115 //icon = SmallIcon("fileexport");
116 icon = SmallIcon("filesave"); 116 icon = SmallIcon("filesave");
117 if ( QApplication::desktop()->width() < 320 ) 117 SaveButton->setIconSet (icon ) ;
118 if ( QApplication::desktop()->width() < 320 ) {
118 SaveButton->setText ("") ; 119 SaveButton->setText ("") ;
120 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
121 }
119 else 122 else
120 SaveButton->setText (i18n("Save")) ; 123 SaveButton->setText (i18n("Save"));
121 SaveButton->setIconSet (icon ) ;
122 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
123#ifndef DESKTOP_VERSION 124#ifndef DESKTOP_VERSION
124 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 125 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
125 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
126 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 127 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
127#endif 128#endif
128 message->setFont ( KOPrefs::instance()->mComposeFont ); 129 message->setFont ( KOPrefs::instance()->mComposeFont );
129 message->setWordWrap (QMultiLineEdit::WidgetWidth); 130 message->setWordWrap (QMultiLineEdit::WidgetWidth);
130 if ( smtpAccounts.count() > 0 ) { 131 if ( smtpAccounts.count() > 0 ) {
131 fillValues( smtpAccountBox->currentItem() ); 132 fillValues( smtpAccountBox->currentItem() );
132 } else { 133 } else {
133 QMessageBox::information( 0, i18n( "Problem" ), 134 QMessageBox::information( 0, i18n( "Problem" ),
134 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 135 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
135 i18n( "Ok" ) ); 136 i18n( "Ok" ) );
136 return; 137 return;
137 } 138 }
138 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 139 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
139 140
140 141
141} 142}
142 143
143void ComposeMail::fillSettings() 144void ComposeMail::fillSettings()
144{ 145{
145 if ( QApplication::desktop()->width() < 320 ) 146 if ( QApplication::desktop()->width() < 320 )
146 fromBox->setMaximumWidth( 100 ); 147 fromBox->setMaximumWidth( 100 );
147 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 148 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
148 QStringList::ConstIterator sit = mailList.begin(); 149 QStringList::ConstIterator sit = mailList.begin();
149 int pref = 0; 150 int pref = 0;
150 for (;sit!=mailList.end();++sit) { 151 for (;sit!=mailList.end();++sit) {
151 fromBox->insertItem((*sit)); 152 fromBox->insertItem((*sit));
152 } 153 }
153 senderNameEdit->setText(KOPrefs::instance()->mName); 154 senderNameEdit->setText(KOPrefs::instance()->mName);
154} 155}
155 156
156 157
157void ComposeMail::saveAsDraft() 158void ComposeMail::saveAsDraft()
158{ 159{
159 160
160 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 161 Opie::Core::OSmartPointer<Mail> mail= new Mail();
161 mail->setMail(fromBox->currentText()); 162 mail->setMail(fromBox->currentText());
162 mail->setTo( toLine->text() ); 163 mail->setTo( toLine->text() );
163 mail->setName(senderNameEdit->text()); 164 mail->setName(senderNameEdit->text());
164 mail->setCC( ccLine->text() ); 165 mail->setCC( ccLine->text() );
165 mail->setBCC( bccLine->text() ); 166 mail->setBCC( bccLine->text() );
166 mail->setReply( replyLine->text() ); 167 mail->setReply( replyLine->text() );
167 mail->setSubject( subjectLine->text() ); 168 mail->setSubject( subjectLine->text() );
168 if (!m_replyid.isEmpty()) { 169 if (!m_replyid.isEmpty()) {
169 QStringList ids; 170 QStringList ids;
170 ids.append(m_replyid); 171 ids.append(m_replyid);
171 mail->setInreply(ids); 172 mail->setInreply(ids);
172 } 173 }
173 QString txt = message->text(); 174 QString txt = message->text();
174 if ( !sigMultiLine->text().isEmpty() ) { 175 if ( !sigMultiLine->text().isEmpty() ) {
175 txt.append( "\n--\n" ); 176 txt.append( "\n--\n" );
176 txt.append( sigMultiLine->text() ); 177 txt.append( sigMultiLine->text() );
177 } 178 }
178 mail->setMessage( txt ); 179 mail->setMessage( txt );
179 180
180 /* only use the default drafts folder name! */ 181 /* only use the default drafts folder name! */
181 Storemail wrapper(AbstractMail::draftFolder()); 182 Storemail wrapper(AbstractMail::draftFolder());
182 wrapper.storeMail(mail); 183 wrapper.storeMail(mail);
183 184
184 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 185 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
185 /* attachments we will ignore! */ 186 /* attachments we will ignore! */
186 if ( it != 0 ) { 187 if ( it != 0 ) {
187 if ( warnAttach ) 188 if ( warnAttach )
188 QMessageBox::warning(0,i18n("Store message"), 189 QMessageBox::warning(0,i18n("Store message"),
189 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 190 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
190 warnAttach = false; 191 warnAttach = false;
191 } 192 }
192 setStatus( i18n("Mail saved as draft!") ); 193 setStatus( i18n("Mail saved as draft!") );
193} 194}
194void ComposeMail::clearStatus() 195void ComposeMail::clearStatus()
195{ 196{
196 topLevelWidget()->setCaption( i18n("Compose mail") ); 197 topLevelWidget()->setCaption( i18n("Compose mail") );
197} 198}
198void ComposeMail::setStatus( QString status ) 199void ComposeMail::setStatus( QString status )
199{ 200{
200 topLevelWidget()->setCaption( status ); 201 topLevelWidget()->setCaption( status );
201 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 202 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
202} 203}
203void ComposeMail::pickAddress( ) 204void ComposeMail::pickAddress( )
204{ 205{
205 206
206 QLineEdit *line = mPickLineEdit; 207 QLineEdit *line = mPickLineEdit;
207 if ( line == 0 ) 208 if ( line == 0 )
208 return; 209 return;
209#ifdef DESKTOP_VERSION 210#ifdef DESKTOP_VERSION
210 //qDebug(" ComposeMail::pickAddress "); 211 //qDebug(" ComposeMail::pickAddress ");
211 QString names ;//= AddressPicker::getNames(); 212 QString names ;//= AddressPicker::getNames();
212 213
213 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 214 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
214 uint i=0; 215 uint i=0;
215 for (i=0; i < list.count(); i++) { 216 for (i=0; i < list.count(); i++) {
216 if ( !list[i].preferredEmail().isEmpty()) { 217 if ( !list[i].preferredEmail().isEmpty()) {
217 if ( ! names.isEmpty() ) 218 if ( ! names.isEmpty() )
218 names+= ","; 219 names+= ",";
219 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 220 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
220 221
221 } 222 }
222 } 223 }
223 224
224 225
225 if ( line->text().isEmpty() ) { 226 if ( line->text().isEmpty() ) {
226 line->setText( names ); 227 line->setText( names );
227 } else if ( !names.isEmpty() ) { 228 } else if ( !names.isEmpty() ) {
228 line->setText( line->text() + ", " + names ); 229 line->setText( line->text() + ", " + names );
229 } 230 }
230#else 231#else
231 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 232 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
232 // the result should now arrive through method insertAttendees 233 // the result should now arrive through method insertAttendees
233#endif 234#endif
234} 235}
235//the map includes name/email pairs, that comes from Ka/Pi 236//the map includes name/email pairs, that comes from Ka/Pi
236void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 237void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
237{ 238{
238 //qDebug("ComposeMail::insertAttendees "); 239 //qDebug("ComposeMail::insertAttendees ");
239 raise(); 240 raise();
240 241
241 if ( mPickLineEdit == 0 ) { //whoami received 242 if ( mPickLineEdit == 0 ) { //whoami received
242 QString defmail = uidList[0]; 243 QString defmail = uidList[0];
243 if ( emailList.count() == 0 ) 244 if ( emailList.count() == 0 )
244 QMessageBox::information( 0, i18n( "Hint" ), 245 QMessageBox::information( 0, i18n( "Hint" ),
245 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 246 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
246 i18n( "Ok" ) ); 247 i18n( "Ok" ) );
247 if (defmail.length()!=0) { 248 if (defmail.length()!=0) {
248 fromBox->insertItem(defmail); 249 fromBox->insertItem(defmail);
249 } 250 }
250 QStringList::ConstIterator sit = emailList.begin(); 251 QStringList::ConstIterator sit = emailList.begin();
251 int pref = 0; 252 int pref = 0;
252 for (;sit!=emailList.end();++sit) { 253 for (;sit!=emailList.end();++sit) {
253 if ( (*sit)==defmail) 254 if ( (*sit)==defmail)
254 continue; 255 continue;
255 fromBox->insertItem((*sit)); 256 fromBox->insertItem((*sit));
256 } 257 }
257 senderNameEdit->setText(nameList[0]); 258 senderNameEdit->setText(nameList[0]);
258 return; 259 return;
259 } 260 }
260 QString names ; 261 QString names ;
261 QLineEdit *line = mPickLineEdit; 262 QLineEdit *line = mPickLineEdit;
262 if (uid == this->name()) 263 if (uid == this->name())
263 { 264 {
264 for ( int i = 0; i < nameList.count(); i++) 265 for ( int i = 0; i < nameList.count(); i++)
265 { 266 {
266 QString _name = nameList[i]; 267 QString _name = nameList[i];
267 QString _email = emailList[i]; 268 QString _email = emailList[i];
268 QString _uid = uidList[i]; 269 QString _uid = uidList[i];
269 if ( ! _email.isEmpty() ) { 270 if ( ! _email.isEmpty() ) {
270 if ( ! names.isEmpty() ) 271 if ( ! names.isEmpty() )
271 names+= ","; 272 names+= ",";
272 names+= "\""+_name +"\"<" +_email +">"; 273 names+= "\""+_name +"\"<" +_email +">";
273 } 274 }
274 } 275 }
275 } 276 }
276 if ( line->text().isEmpty() ) { 277 if ( line->text().isEmpty() ) {
277 line->setText( names ); 278 line->setText( names );
278 } else if ( !names.isEmpty() ) { 279 } else if ( !names.isEmpty() ) {
279 line->setText( line->text() + ", " + names ); 280 line->setText( line->text() + ", " + names );
280 } 281 }
281} 282}
282 283
283void ComposeMail::setTo( const QString & to ) 284void ComposeMail::setTo( const QString & to )
284{ 285{
285 toLine->setText( to ); 286 toLine->setText( to );
286} 287}
287 288
288void ComposeMail::setSubject( const QString & subject ) 289void ComposeMail::setSubject( const QString & subject )
289{ 290{
290 subjectLine->setText( subject ); 291 subjectLine->setText( subject );
291} 292}
292 293
293void ComposeMail::setInReplyTo( const QString & messageId ) 294void ComposeMail::setInReplyTo( const QString & messageId )
294{ 295{
295 m_replyid = messageId; 296 m_replyid = messageId;
296} 297}
297 298
298void ComposeMail::setMessage( const QString & text ) 299void ComposeMail::setMessage( const QString & text )
299{ 300{
300 message->setText( text ); 301 message->setText( text );
301} 302}
302 303
303 304
304void ComposeMail::pickAddressTo() 305void ComposeMail::pickAddressTo()
305{ 306{
306 mPickLineEdit = toLine; 307 mPickLineEdit = toLine;
307 pickAddress( ); 308 pickAddress( );
308} 309}
309 310
310void ComposeMail::pickAddressCC() 311void ComposeMail::pickAddressCC()
311{ 312{
312 mPickLineEdit = ccLine; 313 mPickLineEdit = ccLine;
313 pickAddress( ); 314 pickAddress( );
314} 315}
315 316
316void ComposeMail::pickAddressBCC() 317void ComposeMail::pickAddressBCC()
317{ 318{
318 mPickLineEdit = bccLine; 319 mPickLineEdit = bccLine;
319 pickAddress( ); 320 pickAddress( );
320} 321}
321 322
322void ComposeMail::pickAddressReply() 323void ComposeMail::pickAddressReply()
323{ 324{
324 mPickLineEdit = replyLine; 325 mPickLineEdit = replyLine;
325 pickAddress( ); 326 pickAddress( );
326} 327}
327 328
328void ComposeMail::fillValues( int ) 329void ComposeMail::fillValues( int )
329{ 330{
330#if 0 331#if 0
331 SMTPaccount *smtp = smtpAccounts.at( current ); 332 SMTPaccount *smtp = smtpAccounts.at( current );
332 ccLine->clear(); 333 ccLine->clear();
333 if ( smtp->getUseCC() ) { 334 if ( smtp->getUseCC() ) {
334 ccLine->setText( smtp->getCC() ); 335 ccLine->setText( smtp->getCC() );
335 } 336 }
336 bccLine->clear(); 337 bccLine->clear();
337 if ( smtp->getUseBCC() ) { 338 if ( smtp->getUseBCC() ) {
338 bccLine->setText( smtp->getBCC() ); 339 bccLine->setText( smtp->getBCC() );
339 } 340 }
340 replyLine->clear(); 341 replyLine->clear();
341 if ( smtp->getUseReply() ) { 342 if ( smtp->getUseReply() ) {
342 replyLine->setText( smtp->getReply() ); 343 replyLine->setText( smtp->getReply() );
343 } 344 }
344 sigMultiLine->setText( smtp->getSignature() ); 345 sigMultiLine->setText( smtp->getSignature() );
345#endif 346#endif
346} 347}
347 348
348void ComposeMail::slotAdjustColumns() 349void ComposeMail::slotAdjustColumns()
349{ 350{
350 int currPage = tabWidget->currentPageIndex(); 351 int currPage = tabWidget->currentPageIndex();
351 352
352 tabWidget->showPage( attachTab ); 353 tabWidget->showPage( attachTab );
353 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 354 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
354 attList->setColumnWidth( 1, 80 ); 355 attList->setColumnWidth( 1, 80 );
355 356
356 tabWidget->setCurrentPage( currPage ); 357 tabWidget->setCurrentPage( currPage );
357} 358}
358 359
359void ComposeMail::addAttachment() 360void ComposeMail::addAttachment()
360{ 361{
361 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 362 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
362 if ( !lnk.isEmpty() ) { 363 if ( !lnk.isEmpty() ) {
363 Attachment *att = new Attachment( lnk ); 364 Attachment *att = new Attachment( lnk );
364 (void) new AttachViewItem( attList, att ); 365 (void) new AttachViewItem( attList, att );
365 } 366 }
366} 367}
367 368
368void ComposeMail::removeAttachment() 369void ComposeMail::removeAttachment()
369{ 370{
370 if ( !attList->currentItem() ) { 371 if ( !attList->currentItem() ) {
371 QMessageBox::information( this, i18n( "Error" ), 372 QMessageBox::information( this, i18n( "Error" ),
372 i18n( "<p>Please select a File.</p>" ), 373 i18n( "<p>Please select a File.</p>" ),
373 i18n( "Ok" ) ); 374 i18n( "Ok" ) );
374 } else { 375 } else {
375 attList->takeItem( attList->currentItem() ); 376 attList->takeItem( attList->currentItem() );
376 } 377 }
377} 378}
378 379
379void ComposeMail::accept() 380void ComposeMail::accept()
380{ 381{
381 if ( smtpAccountBox->count() == 0 ) { 382 if ( smtpAccountBox->count() == 0 ) {
382 383
383 reject(); 384 reject();
384 return; 385 return;
385 } 386 }
386 387
387 if (! checkBoxLater->isChecked() ) { 388 if (! checkBoxLater->isChecked() ) {
388 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 389 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
389 i18n("Send this message?"), 390 i18n("Send this message?"),
390 i18n("Yes"), 391 i18n("Yes"),
391 i18n("Cancel")); 392 i18n("Cancel"));
392 393
393 if (yesno == 1) { 394 if (yesno == 1) {
394 return; 395 return;
395 } 396 }
396 } 397 }
397#if 0 398#if 0
398 odebug << "Sending Mail with " 399 odebug << "Sending Mail with "
399 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 400 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
400#endif 401#endif
401 Opie::Core::OSmartPointer<Mail> mail=new Mail; 402 Opie::Core::OSmartPointer<Mail> mail=new Mail;
402 403
403 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 404 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
404 mail->setMail(fromBox->currentText()); 405 mail->setMail(fromBox->currentText());
405 406
406 if ( !toLine->text().isEmpty() ) { 407 if ( !toLine->text().isEmpty() ) {
407 mail->setTo( toLine->text() ); 408 mail->setTo( toLine->text() );
408 } else { 409 } else {
409 QMessageBox::warning(0,i18n("Sending mail"), 410 QMessageBox::warning(0,i18n("Sending mail"),
410 i18n("No Receiver spezified" ) ); 411 i18n("No Receiver spezified" ) );
411 return; 412 return;
412 } 413 }
413 414
414 mail->setName(senderNameEdit->text()); 415 mail->setName(senderNameEdit->text());
415 mail->setCC( ccLine->text() ); 416 mail->setCC( ccLine->text() );
416 mail->setBCC( bccLine->text() ); 417 mail->setBCC( bccLine->text() );
417 mail->setReply( replyLine->text() ); 418 mail->setReply( replyLine->text() );
418 mail->setSubject( subjectLine->text() ); 419 mail->setSubject( subjectLine->text() );
419 if (!m_replyid.isEmpty()) { 420 if (!m_replyid.isEmpty()) {
420 QStringList ids; 421 QStringList ids;
421 ids.append(m_replyid); 422 ids.append(m_replyid);
422 mail->setInreply(ids); 423 mail->setInreply(ids);
423 } 424 }
424 QString txt = message->text(); 425 QString txt = message->text();
425 if ( !sigMultiLine->text().isEmpty() ) { 426 if ( !sigMultiLine->text().isEmpty() ) {
426 txt.append( "\n--\n" ); 427 txt.append( "\n--\n" );
427 txt.append( sigMultiLine->text() ); 428 txt.append( sigMultiLine->text() );
428 } 429 }
429 mail->setMessage( txt ); 430 mail->setMessage( txt );
430 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 431 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
431 while ( it != 0 ) { 432 while ( it != 0 ) {
432 mail->addAttachment( it->getAttachment() ); 433 mail->addAttachment( it->getAttachment() );
433 it = (AttachViewItem *) it->nextSibling(); 434 it = (AttachViewItem *) it->nextSibling();
434 } 435 }
435 436
436 SMTPwrapper wrapper( smtp ); 437 SMTPwrapper wrapper( smtp );
437 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 438 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
438 setStatus( tr ("Mail sent")); 439 setStatus( tr ("Mail sent"));
439 else { 440 else {
440 setStatus( tr ("Error: Something went wrong. Nothing sent")); 441 setStatus( tr ("Error: Something went wrong. Nothing sent"));
441 return; 442 return;
442 } 443 }
443 444
444 445
445 QDialog::accept(); 446 QDialog::accept();
446} 447}
447 448
448void ComposeMail::reject() 449void ComposeMail::reject()
449{ 450{
450 //qDebug("ComposeMail::reject() "); 451 //qDebug("ComposeMail::reject() ");
451 int yesno = QMessageBox::warning(0,i18n("Store message?"), 452 int yesno = QMessageBox::warning(0,i18n("Store message?"),
452 i18n("Store message into drafts?\n"), 453 i18n("Store message into drafts?\n"),
453 i18n("Yes"), 454 i18n("Yes"),
454 i18n("No")); 455 i18n("No"));
455 456
456 //qDebug("button %d ", yesno); 457 //qDebug("button %d ", yesno);
457 if (yesno == 0) { 458 if (yesno == 0) {
458 if ( toLine->text().isEmpty() ) { 459 if ( toLine->text().isEmpty() ) {
459 QMessageBox::warning(0,i18n("Sending mail"), 460 QMessageBox::warning(0,i18n("Sending mail"),
460 i18n("No Receiver spezified" ) ); 461 i18n("No Receiver spezified" ) );
461 return; 462 return;
462 } 463 }
463 saveAsDraft(); 464 saveAsDraft();
464 } 465 }
465 if (yesno == 2) { 466 if (yesno == 2) {
466 qDebug("return "); 467 qDebug("return ");
467 return; 468 return;
468 } 469 }
469 QDialog::reject(); 470 QDialog::reject();
470} 471}
471 472
472ComposeMail::~ComposeMail() 473ComposeMail::~ComposeMail()
473{ 474{
474} 475}
475 476
476void ComposeMail::reEditMail(const RecMailP&current) 477void ComposeMail::reEditMail(const RecMailP&current)
477{ 478{
478 RecMailP data = current; 479 RecMailP data = current;
479 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 480 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
480 subjectLine->setText( data->getSubject()); 481 subjectLine->setText( data->getSubject());
481 toLine->setText(data->To().join(",")); 482 toLine->setText(data->To().join(","));
482 ccLine->setText(data->CC().join(",")); 483 ccLine->setText(data->CC().join(","));
483 bccLine->setText(data->Bcc().join(",")); 484 bccLine->setText(data->Bcc().join(","));
484 replyLine->setText(data->Replyto()); 485 replyLine->setText(data->Replyto());
485} 486}
486 487
487AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 488AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
488 : QListViewItem( parent ) 489 : QListViewItem( parent )
489{ 490{
490 attachment = att; 491 attachment = att;
491 if ( !attachment->getPixmap().isNull() ) 492 if ( !attachment->getPixmap().isNull() )
492 setPixmap( 0,attachment->getPixmap() ); 493 setPixmap( 0,attachment->getPixmap() );
493 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 494 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
494 setText( 1, QString::number( att->getSize() ) ); 495 setText( 1, QString::number( att->getSize() ) );
495} 496}
496 497
diff --git a/kmicromail/kmicromail.pro b/kmicromail/kmicromail.pro
new file mode 100644
index 0000000..cd5a3c1
--- a/dev/null
+++ b/kmicromail/kmicromail.pro
@@ -0,0 +1,77 @@
1CONFIG += qt warn_on
2 TEMPLATE= app
3HEADERS = defines.h \
4 editaccounts.h \
5 composemail.h \
6 accountview.h \
7 accountitem.h \
8 mainwindow.h \
9 viewmail.h \
10 viewmailbase.h \
11 opiemail.h \
12 mailistviewitem.h \
13 settingsdialog.h \
14 statuswidget.h \
15 newmaildir.h \
16 selectstore.h \
17 selectsmtp.h \
18 nntpgroups.h \
19 koprefs.h \
20 koprefsdialog.h \
21 nntpgroupsdlg.h
22
23SOURCES = main.cpp \
24 opiemail.cpp \
25 mainwindow.cpp \
26 accountview.cpp \
27 accountitem.cpp \
28 composemail.cpp \
29 editaccounts.cpp \
30 viewmail.cpp \
31 viewmailbase.cpp \
32 mailistviewitem.cpp \
33 settingsdialog.cpp \
34 statuswidget.cpp \
35 newmaildir.cpp \
36 selectstore.cpp \
37 selectsmtp.cpp \
38 nntpgroups.cpp \
39 koprefs.cpp\
40 koprefsdialog.cpp\
41 nntpgroupsdlg.cpp
42
43INTERFACES = editaccountsui.ui \
44 selectmailtypeui.ui \
45 imapconfigui.ui \
46 pop3configui.ui \
47 nntpconfigui.ui \
48 smtpconfigui.ui \
49 composemailui.ui \
50 settingsdialogui.ui \
51 statuswidgetui.ui \
52 newmaildirui.ui \
53 selectstoreui.ui \
54 nntpgroupsui.ui
55
56
57INCLUDEPATH += . .. ../libkdepim ../microkde ../microkde/kdecore libetpan/include ../microkde/kdeui
58LIBS += -L../bin -lmicromailwrapper -lmicrolibetpan -lmicrokde -lssl -lcrypto -lmicrokdepim -lmicrokabc
59
60DESTDIR= ../bin
61TARGET = ompi
62
63DEFINES += DESKTOP_VERSION
64unix : {
65OBJECTS_DIR = obj/unix
66MOC_DIR = moc/unix
67}
68win32: {
69DEFINES += _WIN32_
70LIBS += mfc71u.lib
71QMAKE_LINK += /NODEFAULTLIB:LIBC
72#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
73#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
74OBJECTS_DIR = obj/win
75MOC_DIR = moc/win
76}
77
diff --git a/kmicromail/libetpan/libetpan.pro b/kmicromail/libetpan/libetpan.pro
new file mode 100644
index 0000000..dfafa07
--- a/dev/null
+++ b/kmicromail/libetpan/libetpan.pro
@@ -0,0 +1,274 @@
1######################################################################
2# Automatically generated by qmake (1.07a) Thu Jul 1 00:54:03 2004
3######################################################################
4
5TEMPLATE = lib
6 TARGET = microlibetpan
7
8OBJECTS_DIR = obj
9MOC_DIR = moc
10DESTDIR=../../bin
11
12DEPENDPATH += generic \
13 imap \
14 imf \
15 maildir \
16 mbox \
17 mh \
18 mime \
19 nntp \
20 pop3 \
21 smtp \
22 tests \
23 tools \
24 include/libetpan
25INCLUDEPATH += . \
26 generic \
27 include \
28 tools \
29 imf \
30 imap \
31 mime \
32 maildir \
33 mbox \
34 mh \
35 nntp \
36 pop3 \
37 smtp \
38 tests
39
40# Input
41HEADERS += generic/data_message_driver.h \
42 generic/generic_cache.h \
43 generic/generic_cache_types.h \
44 generic/imapdriver.h \
45 generic/imapdriver_cached.h \
46 generic/imapdriver_cached_message.h \
47 generic/imapdriver_message.h \
48 generic/imapdriver_tools.h \
49 generic/imapdriver_types.h \
50 generic/imapstorage.h \
51 generic/imfcache.h \
52 generic/libetpan.h \
53 generic/libetpan_version.h \
54 generic/maildirdriver.h \
55 generic/maildirdriver_cached.h \
56 generic/maildirdriver_cached_message.h \
57 generic/maildirdriver_message.h \
58 generic/maildirdriver_tools.h \
59 generic/maildirdriver_types.h \
60 generic/maildirstorage.h \
61 generic/maildriver.h \
62 generic/maildriver_errors.h \
63 generic/maildriver_tools.h \
64 generic/maildriver_types.h \
65 generic/maildriver_types_helper.h \
66 generic/mailfolder.h \
67 generic/mailmessage.h \
68 generic/mailmessage_tools.h \
69 generic/mailmessage_types.h \
70 generic/mailstorage.h \
71 generic/mailstorage_tools.h \
72 generic/mailstorage_types.h \
73 generic/mailthread.h \
74 generic/mailthread_types.h \
75 generic/mboxdriver.h \
76 generic/mboxdriver_cached.h \
77 generic/mboxdriver_cached_message.h \
78 generic/mboxdriver_message.h \
79 generic/mboxdriver_tools.h \
80 generic/mboxdriver_types.h \
81 generic/mboxstorage.h \
82 generic/mhdriver.h \
83 generic/mhdriver_cached.h \
84 generic/mhdriver_cached_message.h \
85 generic/mhdriver_message.h \
86 generic/mhdriver_tools.h \
87 generic/mhdriver_types.h \
88 generic/mhstorage.h \
89 generic/mime_message_driver.h \
90 generic/nntpdriver.h \
91 generic/nntpdriver_cached.h \
92 generic/nntpdriver_cached_message.h \
93 generic/nntpdriver_message.h \
94 generic/nntpdriver_tools.h \
95 generic/nntpdriver_types.h \
96 generic/nntpstorage.h \
97 generic/pop3driver.h \
98 generic/pop3driver_cached.h \
99 generic/pop3driver_cached_message.h \
100 generic/pop3driver_message.h \
101 generic/pop3driver_tools.h \
102 generic/pop3driver_types.h \
103 generic/pop3storage.h \
104 imap/mailimap.h \
105 imap/mailimap_helper.h \
106 imap/mailimap_keywords.h \
107 imap/mailimap_parser.h \
108 imap/mailimap_print.h \
109 imap/mailimap_sender.h \
110 imap/mailimap_socket.h \
111 imap/mailimap_ssl.h \
112 imap/mailimap_types.h \
113 imap/mailimap_types_helper.h \
114 imf/mailimf.h \
115 imf/mailimf_types.h \
116 imf/mailimf_types_helper.h \
117 imf/mailimf_write.h \
118 maildir/maildir.h \
119 maildir/maildir_types.h \
120 mbox/mailmbox.h \
121 mbox/mailmbox_parse.h \
122 mbox/mailmbox_types.h \
123 mh/mailmh.h \
124 mime/mailmime.h \
125 mime/mailmime_content.h \
126 mime/mailmime_decode.h \
127 mime/mailmime_disposition.h \
128 mime/mailmime_types.h \
129 mime/mailmime_types_helper.h \
130 mime/mailmime_write.h \
131 nntp/newsnntp.h \
132 nntp/newsnntp_socket.h \
133 nntp/newsnntp_ssl.h \
134 nntp/newsnntp_types.h \
135 pop3/mailpop3.h \
136 pop3/mailpop3_helper.h \
137 pop3/mailpop3_socket.h \
138 pop3/mailpop3_ssl.h \
139 pop3/mailpop3_types.h \
140 smtp/mailsmtp.h \
141 smtp/mailsmtp_helper.h \
142 smtp/mailsmtp_socket.h \
143 smtp/mailsmtp_ssl.h \
144 smtp/mailsmtp_types.h \
145 tools/base64.h \
146 tools/carray.h \
147 tools/charconv.h \
148 tools/chash.h \
149 tools/cinthash.h \
150 tools/clist.h \
151 tools/connect.h \
152 tools/hmac-md5.h \
153 tools/mail.h \
154 tools/mail_cache_db.h \
155 tools/mail_cache_db_types.h \
156 tools/maillock.h \
157 tools/mailstream.h \
158 tools/mailstream_helper.h \
159 tools/mailstream_low.h \
160 tools/mailstream_socket.h \
161 tools/mailstream_ssl.h \
162 tools/mailstream_types.h \
163 tools/mapping.h \
164 tools/md5.h \
165 tools/md5global.h \
166 tools/mmapstring.h \
167
168SOURCES += generic/data_message_driver.c \
169 generic/generic_cache.c \
170 generic/imapdriver.c \
171 generic/imapdriver_cached.c \
172 generic/imapdriver_cached_message.c \
173 generic/imapdriver_message.c \
174 generic/imapdriver_tools.c \
175 generic/imapstorage.c \
176 generic/imfcache.c \
177 generic/libetpan_version.c \
178 generic/maildirdriver.c \
179 generic/maildirdriver_cached.c \
180 generic/maildirdriver_cached_message.c \
181 generic/maildirdriver_message.c \
182 generic/maildirdriver_tools.c \
183 generic/maildirstorage.c \
184 generic/maildriver.c \
185 generic/maildriver_tools.c \
186 generic/maildriver_types.c \
187 generic/maildriver_types_helper.c \
188 generic/mailfolder.c \
189 generic/mailmessage.c \
190 generic/mailmessage_tools.c \
191 generic/mailmessage_types.c \
192 generic/mailstorage.c \
193 generic/mailstorage_tools.c \
194 generic/mailthread.c \
195 generic/mailthread_types.c \
196 generic/mboxdriver.c \
197 generic/mboxdriver_cached.c \
198 generic/mboxdriver_cached_message.c \
199 generic/mboxdriver_message.c \
200 generic/mboxdriver_tools.c \
201 generic/mboxstorage.c \
202 generic/mhdriver.c \
203 generic/mhdriver_cached.c \
204 generic/mhdriver_cached_message.c \
205 generic/mhdriver_message.c \
206 generic/mhdriver_tools.c \
207 generic/mhstorage.c \
208 generic/mime_message_driver.c \
209 generic/nntpdriver.c \
210 generic/nntpdriver_cached.c \
211 generic/nntpdriver_cached_message.c \
212 generic/nntpdriver_message.c \
213 generic/nntpdriver_tools.c \
214 generic/nntpstorage.c \
215 generic/pop3driver.c \
216 generic/pop3driver_cached.c \
217 generic/pop3driver_cached_message.c \
218 generic/pop3driver_message.c \
219 generic/pop3driver_tools.c \
220 generic/pop3storage.c \
221 imap/mailimap.c \
222 imap/mailimap_helper.c \
223 imap/mailimap_keywords.c \
224 imap/mailimap_parser.c \
225 imap/mailimap_print.c \
226 imap/mailimap_sender.c \
227 imap/mailimap_socket.c \
228 imap/mailimap_ssl.c \
229 imap/mailimap_types.c \
230 imap/mailimap_types_helper.c \
231 imf/mailimf.c \
232 imf/mailimf_types.c \
233 imf/mailimf_types_helper.c \
234 imf/mailimf_write.c \
235 maildir/maildir.c \
236 mbox/mailmbox.c \
237 mbox/mailmbox_parse.c \
238 mbox/mailmbox_types.c \
239 mh/mailmh.c \
240 mime/mailmime.c \
241 mime/mailmime_content.c \
242 mime/mailmime_decode.c \
243 mime/mailmime_disposition.c \
244 mime/mailmime_types.c \
245 mime/mailmime_types_helper.c \
246 mime/mailmime_write.c \
247 nntp/newsnntp.c \
248 nntp/newsnntp_socket.c \
249 nntp/newsnntp_ssl.c \
250 pop3/mailpop3.c \
251 pop3/mailpop3_helper.c \
252 pop3/mailpop3_socket.c \
253 pop3/mailpop3_ssl.c \
254 smtp/mailsmtp.c \
255 smtp/mailsmtp_helper.c \
256 smtp/mailsmtp_socket.c \
257 smtp/mailsmtp_ssl.c \
258 tools/base64.c \
259 tools/carray.c \
260 tools/charconv.c \
261 tools/chash.c \
262 tools/cinthash.c \
263 tools/clist.c \
264 tools/connect.c \
265 tools/mail_cache_db.c \
266 tools/maillock.c \
267 tools/mailstream.c \
268 tools/mailstream_helper.c \
269 tools/mailstream_low.c \
270 tools/mailstream_socket.c \
271 tools/mailstream_ssl.c \
272 tools/mapping.c \
273 tools/md5.c \
274 tools/mmapstring.c
diff --git a/kmicromail/libmailwrapper/generatemail.h b/kmicromail/libmailwrapper/generatemail.h
index a767b61..b9f8285 100644
--- a/kmicromail/libmailwrapper/generatemail.h
+++ b/kmicromail/libmailwrapper/generatemail.h
@@ -1,46 +1,47 @@
1#ifndef __GENERATE_MAIL_H 1#ifndef __GENERATE_MAIL_H
2#define __GENERATE_MAIL_H 2#define __GENERATE_MAIL_H
3 3
4#include <qpe/applnk.h> 4//#include <qpe/applnk.h>
5 5
6#include <qobject.h> 6#include <qobject.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8#include "mailwrapper.h"
8 9
9#include <opie2/osmartpointer.h> 10#include <opie2/osmartpointer.h>
10 11
11class Mail; 12class Mail;
12class RecMail; 13class RecMail;
13class Attachment; 14
14struct mailimf_fields; 15struct mailimf_fields;
15struct mailimf_field; 16struct mailimf_field;
16struct mailimf_mailbox; 17struct mailimf_mailbox;
17struct mailmime; 18struct mailmime;
18struct mailimf_address_list; 19struct mailimf_address_list;
19class progressMailSend; 20class progressMailSend;
20struct mailsmtp; 21struct mailsmtp;
21 22
22class Generatemail : public QObject 23class Generatemail : public QObject
23{ 24{
24 Q_OBJECT 25 Q_OBJECT
25public: 26public:
26 Generatemail(); 27 Generatemail();
27 virtual ~Generatemail(); 28 virtual ~Generatemail();
28 29
29protected: 30protected:
30 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 31 static void addRcpts( clist *list, mailimf_address_list *addr_list );
31 static char *getFrom( mailmime *mail ); 32 static char *getFrom( mailmime *mail );
32 static char *getFrom( mailimf_field *ffrom); 33 static char *getFrom( mailimf_field *ffrom);
33 static mailimf_field *getField( mailimf_fields *fields, int type ); 34 static mailimf_field *getField( mailimf_fields *fields, int type );
34 mailimf_address_list *parseAddresses(const QString&addr ); 35 mailimf_address_list *parseAddresses(const QString&addr );
35 void addFileParts( mailmime *message,const QList<Attachment>&files ); 36 void addFileParts( mailmime *message,const QList<Attachment>&files );
36 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 37 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
37 mailmime *buildTxtPart(const QString&str ); 38 mailmime *buildTxtPart(const QString&str );
38 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 39 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
39 mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); 40 mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail );
40 mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail ); 41 mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail );
41 clist *createRcptList( mailimf_fields *fields ); 42 clist *createRcptList( mailimf_fields *fields );
42 43
43 static const char* USER_AGENT; 44 static const char* USER_AGENT;
44}; 45};
45 46
46#endif 47#endif
diff --git a/kmicromail/libmailwrapper/libmailwrapper.pro b/kmicromail/libmailwrapper/libmailwrapper.pro
new file mode 100644
index 0000000..2b005d8
--- a/dev/null
+++ b/kmicromail/libmailwrapper/libmailwrapper.pro
@@ -0,0 +1,64 @@
1TEMPLATE = lib
2CONFIG += qt warn_on
3
4HEADERS = mailwrapper.h \
5 imapwrapper.h \
6 mailtypes.h \
7 pop3wrapper.h \
8 abstractmail.h \
9 smtpwrapper.h \
10 genericwrapper.h \
11 mboxwrapper.h \
12 settings.h \
13 logindialog.h \
14 sendmailprogress.h \
15 statusmail.h \
16 mhwrapper.h \
17 nntpwrapper.h \
18 generatemail.h \
19 storemail.h \
20 ../qpe/global.h
21
22SOURCES = imapwrapper.cpp \
23 mailwrapper.cpp \
24 mailtypes.cpp \
25 pop3wrapper.cpp \
26 abstractmail.cpp \
27 smtpwrapper.cpp \
28 genericwrapper.cpp \
29 mboxwrapper.cpp \
30 settings.cpp \
31 logindialog.cpp \
32 sendmailprogress.cpp \
33 statusmail.cpp \
34 mhwrapper.cpp \
35 nntpwrapper.cpp \
36 generatemail.cpp \
37 storemail.cpp \
38 ../qpe/global.cpp
39
40INTERFACES = logindialogui.ui \
41 sendmailprogressui.ui
42
43INCLUDEPATH += .. ../../microkde ../../microkde/kdecore ../libetpan/include
44LIBS += -lssl -lcrypto
45
46#-lqpe -letpan
47
48DESTDIR = ../../bin
49TARGET = micromailwrapper
50
51DEFINES += DESKTOP_VERSION
52unix : {
53OBJECTS_DIR = obj/unix
54MOC_DIR = moc/unix
55}
56win32: {
57DEFINES += _WIN32_
58LIBS += mfc71u.lib
59QMAKE_LINK += /NODEFAULTLIB:LIBC
60#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
61#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
62OBJECTS_DIR = obj/win
63MOC_DIR = moc/win
64}
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h
index 2ba908b..88f10da 100644
--- a/kmicromail/libmailwrapper/mailwrapper.h
+++ b/kmicromail/libmailwrapper/mailwrapper.h
@@ -1,128 +1,128 @@
1#ifndef MAILWRAPPER_H 1#ifndef MAILWRAPPER_H
2#define MAILWRAPPER_H 2#define MAILWRAPPER_H
3 3
4#include <qpe/applnk.h> 4//#include <qpe/applnk.h>
5 5
6#include <qbitarray.h> 6#include <qbitarray.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <qfileinfo.h> 8#include <qfileinfo.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10 10
11#include "settings.h" 11#include "settings.h"
12 12
13#include <opie2/osmartpointer.h> 13#include <opie2/osmartpointer.h>
14/* 14/*
15class Attachment 15class Attachment
16{ 16{
17public: 17public:
18 Attachment( DocLnk lnk ); 18 Attachment( DocLnk lnk );
19 virtual ~Attachment(){} 19 virtual ~Attachment(){}
20 const QString getFileName()const{ return doc.file(); } 20 const QString getFileName()const{ return doc.file(); }
21 const QString getName()const{ return doc.name(); } 21 const QString getName()const{ return doc.name(); }
22 const QString getMimeType()const{ return doc.type(); } 22 const QString getMimeType()const{ return doc.type(); }
23 const QPixmap getPixmap()const{ return doc.pixmap(); } 23 const QPixmap getPixmap()const{ return doc.pixmap(); }
24 const int getSize()const { return size; } 24 const int getSize()const { return size; }
25 DocLnk getDocLnk() { return doc; } 25 DocLnk getDocLnk() { return doc; }
26 26
27protected: 27protected:
28 DocLnk doc; 28 DocLnk doc;
29 int size; 29 int size;
30 30
31}; 31};
32*/ 32*/
33 33
34class Attachment 34class Attachment
35{ 35{
36public: 36public:
37 Attachment( QString lnk ); 37 Attachment( QString lnk );
38 virtual ~Attachment(){} 38 virtual ~Attachment(){}
39 const QString getFileName()const{ return doc; } 39 const QString getFileName()const{ return doc; }
40 const QString getName()const{ return QFileInfo( doc ).baseName (); } 40 const QString getName()const{ return QFileInfo( doc ).baseName (); }
41 const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } 41 const QString getMimeType()const{ return QFileInfo( doc ).extension(false); }
42 const QPixmap getPixmap()const{ return mPix; } 42 const QPixmap getPixmap()const{ return mPix; }
43 const int getSize()const { return size; } 43 const int getSize()const { return size; }
44 QString getDocLnk() { return doc; } 44 QString getDocLnk() { return doc; }
45 45
46protected: 46protected:
47 QPixmap mPix; 47 QPixmap mPix;
48 QString doc; 48 QString doc;
49 int size; 49 int size;
50 50
51}; 51};
52 52
53class Mail:public Opie::Core::ORefCount 53class Mail:public Opie::Core::ORefCount
54{ 54{
55public: 55public:
56 Mail(); 56 Mail();
57 /* Possible that this destructor must not be declared virtual 57 /* Possible that this destructor must not be declared virtual
58 * 'cause it seems that it will never have some child classes. 58 * 'cause it seems that it will never have some child classes.
59 * in this case this object will not get a virtual table -> memory and 59 * in this case this object will not get a virtual table -> memory and
60 * speed will be a little bit better? 60 * speed will be a little bit better?
61 */ 61 */
62 virtual ~Mail(){} 62 virtual ~Mail(){}
63 void addAttachment( Attachment *att ) { attList.append( att ); } 63 void addAttachment( Attachment *att ) { attList.append( att ); }
64 const QList<Attachment>& getAttachments()const { return attList; } 64 const QList<Attachment>& getAttachments()const { return attList; }
65 void removeAttachment( Attachment *att ) { attList.remove( att ); } 65 void removeAttachment( Attachment *att ) { attList.remove( att ); }
66 const QString&getName()const { return name; } 66 const QString&getName()const { return name; }
67 void setName( QString s ) { name = s; } 67 void setName( QString s ) { name = s; }
68 const QString&getMail()const{ return mail; } 68 const QString&getMail()const{ return mail; }
69 void setMail( const QString&s ) { mail = s; } 69 void setMail( const QString&s ) { mail = s; }
70 const QString&getTo()const{ return to; } 70 const QString&getTo()const{ return to; }
71 void setTo( const QString&s ) { to = s; } 71 void setTo( const QString&s ) { to = s; }
72 const QString&getCC()const{ return cc; } 72 const QString&getCC()const{ return cc; }
73 void setCC( const QString&s ) { cc = s; } 73 void setCC( const QString&s ) { cc = s; }
74 const QString&getBCC()const { return bcc; } 74 const QString&getBCC()const { return bcc; }
75 void setBCC( const QString&s ) { bcc = s; } 75 void setBCC( const QString&s ) { bcc = s; }
76 const QString&getMessage()const { return message; } 76 const QString&getMessage()const { return message; }
77 void setMessage( const QString&s ) { message = s; } 77 void setMessage( const QString&s ) { message = s; }
78 const QString&getSubject()const { return subject; } 78 const QString&getSubject()const { return subject; }
79 void setSubject( const QString&s ) { subject = s; } 79 void setSubject( const QString&s ) { subject = s; }
80 const QString&getReply()const{ return reply; } 80 const QString&getReply()const{ return reply; }
81 void setReply( const QString&a ) { reply = a; } 81 void setReply( const QString&a ) { reply = a; }
82 void setInreply(const QStringList&list){m_in_reply_to = list;} 82 void setInreply(const QStringList&list){m_in_reply_to = list;}
83 const QStringList&Inreply()const{return m_in_reply_to;} 83 const QStringList&Inreply()const{return m_in_reply_to;}
84 84
85private: 85private:
86 QList<Attachment> attList; 86 QList<Attachment> attList;
87 QString name, mail, to, cc, bcc, reply, subject, message; 87 QString name, mail, to, cc, bcc, reply, subject, message;
88 QStringList m_in_reply_to; 88 QStringList m_in_reply_to;
89}; 89};
90 90
91class Folder:public Opie::Core::ORefCount 91class Folder:public Opie::Core::ORefCount
92{ 92{
93public: 93public:
94 Folder( const QString&init_name,const QString&sep ); 94 Folder( const QString&init_name,const QString&sep );
95 virtual ~Folder(); 95 virtual ~Folder();
96 const QString&getDisplayName()const { return nameDisplay; } 96 const QString&getDisplayName()const { return nameDisplay; }
97 const QString&getName()const { return name; } 97 const QString&getName()const { return name; }
98 const QString&getPrefix()const{return prefix; } 98 const QString&getPrefix()const{return prefix; }
99 virtual bool may_select()const{return true;} 99 virtual bool may_select()const{return true;}
100 virtual bool no_inferior()const{return true;} 100 virtual bool no_inferior()const{return true;}
101 const QString&Separator()const; 101 const QString&Separator()const;
102 102
103protected: 103protected:
104 QString nameDisplay, name, separator,prefix; 104 QString nameDisplay, name, separator,prefix;
105}; 105};
106 106
107typedef Opie::Core::OSmartPointer<Folder> FolderP; 107typedef Opie::Core::OSmartPointer<Folder> FolderP;
108 108
109class MHFolder : public Folder 109class MHFolder : public Folder
110{ 110{
111public: 111public:
112 MHFolder(const QString&disp_name,const QString&mbox); 112 MHFolder(const QString&disp_name,const QString&mbox);
113 virtual ~MHFolder(); 113 virtual ~MHFolder();
114}; 114};
115 115
116class IMAPFolder : public Folder 116class IMAPFolder : public Folder
117{ 117{
118 public: 118 public:
119 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); 119 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
120 virtual ~IMAPFolder(); 120 virtual ~IMAPFolder();
121 virtual bool may_select()const{return m_MaySelect;} 121 virtual bool may_select()const{return m_MaySelect;}
122 virtual bool no_inferior()const{return m_NoInferior;} 122 virtual bool no_inferior()const{return m_NoInferior;}
123 static QString decodeFolderName( const QString &name ); 123 static QString decodeFolderName( const QString &name );
124 private: 124 private:
125 bool m_MaySelect,m_NoInferior; 125 bool m_MaySelect,m_NoInferior;
126}; 126};
127 127
128#endif 128#endif
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index f4133c0..de6d220 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -1,447 +1,441 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include "mhwrapper.h" 2#include "mhwrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include <libetpan/libetpan.h> 5#include <libetpan/libetpan.h>
6#include <qdir.h> 6#include <qdir.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qpe/global.h> 9#include <qpe/global.h>
10#include <oprocess.h>
11#include <klocale.h> 10#include <klocale.h>
12//#include <opie2/odebug.h> 11#include <kglobal.h>
12//#include <opie2/odebug.h>
13 13
14using namespace Opie::Core; 14using namespace Opie::Core;
15MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 15MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
16 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 16 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
17{ 17{
18 if (MHPath.length()>0) { 18 if (MHPath.length()>0) {
19 if (MHPath[MHPath.length()-1]=='/') { 19 if (MHPath[MHPath.length()-1]=='/') {
20 MHPath=MHPath.left(MHPath.length()-1); 20 MHPath=MHPath.left(MHPath.length()-1);
21 } 21 }
22 //odebug << MHPath << oendl; 22 //odebug << MHPath << oendl;
23 QDir dir(MHPath); 23 QDir dir(MHPath);
24 if (!dir.exists()) { 24 if (!dir.exists()) {
25 dir.mkdir(MHPath); 25 dir.mkdir(MHPath);
26 } 26 }
27 init_storage(); 27 init_storage();
28 } 28 }
29} 29}
30 30
31void MHwrapper::init_storage() 31void MHwrapper::init_storage()
32{ 32{
33 int r; 33 int r;
34 QString pre = MHPath; 34 QString pre = MHPath;
35 if (!m_storage) { 35 if (!m_storage) {
36 m_storage = mailstorage_new(NULL); 36 m_storage = mailstorage_new(NULL);
37 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); 37 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0);
38 if (r != MAIL_NO_ERROR) { 38 if (r != MAIL_NO_ERROR) {
39 qDebug(" error init storage "); 39 qDebug(" error init storage ");
40 mailstorage_free(m_storage); 40 mailstorage_free(m_storage);
41 m_storage = 0; 41 m_storage = 0;
42 return; 42 return;
43 } 43 }
44 } 44 }
45 r = mailstorage_connect(m_storage); 45 r = mailstorage_connect(m_storage);
46 if (r!=MAIL_NO_ERROR) { 46 if (r!=MAIL_NO_ERROR) {
47 qDebug("error connecting storage "); 47 qDebug("error connecting storage ");
48 mailstorage_free(m_storage); 48 mailstorage_free(m_storage);
49 m_storage = 0; 49 m_storage = 0;
50 } 50 }
51} 51}
52 52
53void MHwrapper::clean_storage() 53void MHwrapper::clean_storage()
54{ 54{
55 if (m_storage) { 55 if (m_storage) {
56 mailstorage_disconnect(m_storage); 56 mailstorage_disconnect(m_storage);
57 mailstorage_free(m_storage); 57 mailstorage_free(m_storage);
58 m_storage = 0; 58 m_storage = 0;
59 } 59 }
60} 60}
61 61
62MHwrapper::~MHwrapper() 62MHwrapper::~MHwrapper()
63{ 63{
64 clean_storage(); 64 clean_storage();
65} 65}
66 66
67void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) 67void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
68{ 68{
69 init_storage(); 69 init_storage();
70 if (!m_storage) { 70 if (!m_storage) {
71 return; 71 return;
72 } 72 }
73 QString f = buildPath(mailbox); 73 QString f = buildPath(mailbox);
74 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 74 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
75 if (r!=MAIL_NO_ERROR) { 75 if (r!=MAIL_NO_ERROR) {
76 qDebug("listMessages: error selecting folder! "); 76 qDebug("listMessages: error selecting folder! ");
77 return; 77 return;
78 } 78 }
79 parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); 79 parseList(target,m_storage->sto_session,f, false, maxSizeInKb );
80 Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); 80 Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count()));
81} 81}
82 82
83QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() 83QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
84{ 84{
85 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); 85 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
86 /* this is needed! */ 86 /* this is needed! */
87 if (m_storage) mailstorage_disconnect(m_storage); 87 if (m_storage) mailstorage_disconnect(m_storage);
88 init_storage(); 88 init_storage();
89 if (!m_storage) { 89 if (!m_storage) {
90 return folders; 90 return folders;
91 } 91 }
92 mail_list*flist = 0; 92 mail_list*flist = 0;
93 clistcell*current=0; 93 clistcell*current=0;
94 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 94 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
95 if (r != MAIL_NO_ERROR || !flist) { 95 if (r != MAIL_NO_ERROR || !flist) {
96 qDebug("error getting folder list "); 96 qDebug("error getting folder list ");
97 return folders; 97 return folders;
98 } 98 }
99 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { 99 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
100 QString t = (char*)current->data; 100 QString t = (char*)current->data;
101 t.replace(0,MHPath.length(),""); 101 t.replace(0,MHPath.length(),"");
102 folders->append(new MHFolder(t,MHPath)); 102 folders->append(new MHFolder(t,MHPath));
103 } 103 }
104 mail_list_free(flist); 104 mail_list_free(flist);
105 return folders; 105 return folders;
106} 106}
107 107
108void MHwrapper::deleteMail(const RecMailP&mail) 108void MHwrapper::deleteMail(const RecMailP&mail)
109{ 109{
110 init_storage(); 110 init_storage();
111 if (!m_storage) { 111 if (!m_storage) {
112 return; 112 return;
113 } 113 }
114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
115 if (r!=MAIL_NO_ERROR) { 115 if (r!=MAIL_NO_ERROR) {
116 qDebug("error selecting folder! "); 116 qDebug("error selecting folder! ");
117 return; 117 return;
118 } 118 }
119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
120 if (r != MAIL_NO_ERROR) { 120 if (r != MAIL_NO_ERROR) {
121 qDebug("error deleting mail "); 121 qDebug("error deleting mail ");
122 } 122 }
123} 123}
124 124
125void MHwrapper::answeredMail(const RecMailP&) 125void MHwrapper::answeredMail(const RecMailP&)
126{ 126{
127} 127}
128 128
129RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) 129RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
130{ 130{
131 RecBodyP body = new RecBody(); 131 RecBodyP body = new RecBody();
132 init_storage(); 132 init_storage();
133 if (!m_storage) { 133 if (!m_storage) {
134 return body; 134 return body;
135 } 135 }
136 mailmessage * msg; 136 mailmessage * msg;
137 char*data=0; 137 char*data=0;
138 138
139 /* mail should hold the complete path! */ 139 /* mail should hold the complete path! */
140 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 140 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
141 if (r != MAIL_NO_ERROR) { 141 if (r != MAIL_NO_ERROR) {
142 return body; 142 return body;
143 } 143 }
144 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 144 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
145 if (r != MAIL_NO_ERROR) { 145 if (r != MAIL_NO_ERROR) {
146 qDebug("Error fetching mail "); 146 qDebug("Error fetching mail ");
147 147
148 return body; 148 return body;
149 } 149 }
150 body = parseMail(msg); 150 body = parseMail(msg);
151 mailmessage_fetch_result_free(msg,data); 151 mailmessage_fetch_result_free(msg,data);
152 return body; 152 return body;
153} 153}
154 154
155void MHwrapper::mbox_progress( size_t current, size_t maximum ) 155void MHwrapper::mbox_progress( size_t current, size_t maximum )
156{ 156{
157 qDebug("MBox Progress %d of %d",current,maximum ); 157 qDebug("MBox Progress %d of %d",current,maximum );
158 //odebug << "MH " << current << " von " << maximum << "" << oendl; 158 //odebug << "MH " << current << " von " << maximum << "" << oendl;
159} 159}
160 160
161QString MHwrapper::buildPath(const QString&p) 161QString MHwrapper::buildPath(const QString&p)
162{ 162{
163 QString f=""; 163 QString f="";
164 if (p.length()==0||p=="/") 164 if (p.length()==0||p=="/")
165 return MHPath; 165 return MHPath;
166 if (!p.startsWith(MHPath)) { 166 if (!p.startsWith(MHPath)) {
167 f+=MHPath; 167 f+=MHPath;
168 } 168 }
169 if (!p.startsWith("/")) { 169 if (!p.startsWith("/")) {
170 f+="/"; 170 f+="/";
171 } 171 }
172 f+=p; 172 f+=p;
173 return f; 173 return f;
174} 174}
175 175
176int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) 176int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool )
177{ 177{
178 init_storage(); 178 init_storage();
179 if (!m_storage) { 179 if (!m_storage) {
180 return 0; 180 return 0;
181 } 181 }
182 QString f; 182 QString f;
183 if (!pfolder) { 183 if (!pfolder) {
184 // toplevel folder 184 // toplevel folder
185 f = buildPath(folder); 185 f = buildPath(folder);
186 } else { 186 } else {
187 f = pfolder->getName(); 187 f = pfolder->getName();
188 f+="/"; 188 f+="/";
189 f+=folder; 189 f+=folder;
190 } 190 }
191 191
192 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); 192 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
193 if (r != MAIL_NO_ERROR) { 193 if (r != MAIL_NO_ERROR) {
194 qDebug("error creating folder "); 194 qDebug("error creating folder ");
195 return 0; 195 return 0;
196 } 196 }
197 return 1; 197 return 1;
198} 198}
199 199
200void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) 200void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
201{ 201{
202 init_storage(); 202 init_storage();
203 if (!m_storage) { 203 if (!m_storage) {
204 return; 204 return;
205 } 205 }
206 QString f = buildPath(Folder); 206 QString f = buildPath(Folder);
207 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 207 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
208 if (r!=MAIL_NO_ERROR) { 208 if (r!=MAIL_NO_ERROR) {
209 qDebug("error selecting folder! "); 209 qDebug("error selecting folder! ");
210 return; 210 return;
211 } 211 }
212 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); 212 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
213 if (r!=MAIL_NO_ERROR) { 213 if (r!=MAIL_NO_ERROR) {
214 qDebug("error storing mail "); 214 qDebug("error storing mail ");
215 } 215 }
216 return; 216 return;
217} 217}
218 218
219encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) 219encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
220{ 220{
221 encodedString*result = 0; 221 encodedString*result = 0;
222 init_storage(); 222 init_storage();
223 if (!m_storage) { 223 if (!m_storage) {
224 return result; 224 return result;
225 } 225 }
226 mailmessage * msg = 0; 226 mailmessage * msg = 0;
227 char*data=0; 227 char*data=0;
228 size_t size; 228 size_t size;
229 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 229 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
230 if (r!=MAIL_NO_ERROR) { 230 if (r!=MAIL_NO_ERROR) {
231 qDebug("error selecting folder! "); 231 qDebug("error selecting folder! ");
232 return result; 232 return result;
233 } 233 }
234 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 234 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
235 if (r != MAIL_NO_ERROR) { 235 if (r != MAIL_NO_ERROR) {
236 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); 236 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber()));
237 return 0; 237 return 0;
238 } 238 }
239 r = mailmessage_fetch(msg,&data,&size); 239 r = mailmessage_fetch(msg,&data,&size);
240 if (r != MAIL_NO_ERROR) { 240 if (r != MAIL_NO_ERROR) {
241 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); 241 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber()));
242 if (msg) mailmessage_free(msg); 242 if (msg) mailmessage_free(msg);
243 return 0; 243 return 0;
244 } 244 }
245 result = new encodedString(data,size); 245 result = new encodedString(data,size);
246 if (msg) mailmessage_free(msg); 246 if (msg) mailmessage_free(msg);
247 return result; 247 return result;
248} 248}
249 249
250void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) 250void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
251{ 251{
252 QString f = buildPath(mailbox); 252 QString f = buildPath(mailbox);
253 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 253 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
254 if (r!=MAIL_NO_ERROR) { 254 if (r!=MAIL_NO_ERROR) {
255 qDebug("deleteMails: error selecting folder! "); 255 qDebug("deleteMails: error selecting folder! ");
256 return; 256 return;
257 } 257 }
258 QValueList<RecMailP>::ConstIterator it; 258 QValueList<RecMailP>::ConstIterator it;
259 for (it=target.begin(); it!=target.end();++it) { 259 for (it=target.begin(); it!=target.end();++it) {
260 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); 260 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber());
261 if (r != MAIL_NO_ERROR) { 261 if (r != MAIL_NO_ERROR) {
262 qDebug("error deleting mail "); 262 qDebug("error deleting mail ");
263 break; 263 break;
264 } 264 }
265 } 265 }
266} 266}
267 267
268int MHwrapper::deleteAllMail(const FolderP&tfolder) 268int MHwrapper::deleteAllMail(const FolderP&tfolder)
269{ 269{
270 init_storage(); 270 init_storage();
271 if (!m_storage) { 271 if (!m_storage) {
272 return 0; 272 return 0;
273 } 273 }
274 int res = 1; 274 int res = 1;
275 if (!tfolder) return 0; 275 if (!tfolder) return 0;
276 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 276 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
277 if (r!=MAIL_NO_ERROR) { 277 if (r!=MAIL_NO_ERROR) {
278 qDebug("error selecting folder! "); 278 qDebug("error selecting folder! ");
279 return 0; 279 return 0;
280 } 280 }
281 mailmessage_list*l=0; 281 mailmessage_list*l=0;
282 r = mailsession_get_messages_list(m_storage->sto_session,&l); 282 r = mailsession_get_messages_list(m_storage->sto_session,&l);
283 if (r != MAIL_NO_ERROR) { 283 if (r != MAIL_NO_ERROR) {
284 qDebug("Error message list "); 284 qDebug("Error message list ");
285 res = 0; 285 res = 0;
286 } 286 }
287 unsigned j = 0; 287 unsigned j = 0;
288 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 288 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
289 mailmessage * msg; 289 mailmessage * msg;
290 msg = (mailmessage*)carray_get(l->msg_tab, i); 290 msg = (mailmessage*)carray_get(l->msg_tab, i);
291 j = msg->msg_index; 291 j = msg->msg_index;
292 r = mailsession_remove_message(m_storage->sto_session,j); 292 r = mailsession_remove_message(m_storage->sto_session,j);
293 if (r != MAIL_NO_ERROR) { 293 if (r != MAIL_NO_ERROR) {
294 Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); 294 Global::statusMessage(i18n("Error deleting mail %1").arg(i+1));
295 res = 0; 295 res = 0;
296 break; 296 break;
297 } 297 }
298 } 298 }
299 if (l) mailmessage_list_free(l); 299 if (l) mailmessage_list_free(l);
300 return res; 300 return res;
301} 301}
302 302
303int MHwrapper::deleteMbox(const FolderP&tfolder) 303int MHwrapper::deleteMbox(const FolderP&tfolder)
304{ 304{
305 init_storage(); 305 init_storage();
306 if (!m_storage) { 306 if (!m_storage) {
307 return 0; 307 return 0;
308 } 308 }
309 if (!tfolder) return 0; 309 if (!tfolder) return 0;
310 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; 310 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0;
311 311
312 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 312 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
313 313
314 if (r != MAIL_NO_ERROR) { 314 if (r != MAIL_NO_ERROR) {
315 qDebug("error deleting mail box "); 315 qDebug("error deleting mail box ");
316 return 0; 316 return 0;
317 } 317 }
318 QString delDir = locateLocal( "apps", "kopiemail")+ "localmail";
319 qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() );
320#if 0
318 QString cmd = "rm -rf "+tfolder->getName(); 321 QString cmd = "rm -rf "+tfolder->getName();
319 QStringList command; 322 QStringList command;
320 command << "/bin/sh"; 323 command << "/bin/sh";
321 command << "-c"; 324 command << "-c";
322 command << cmd.latin1(); 325 command << cmd.latin1();
323 OProcess *process = new OProcess(); 326 OProcess *process = new OProcess();
324 327
328 /*
325 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), 329 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
326 this, SLOT( processEnded(Opie::Core::OProcess*))); 330 this, SLOT( processEnded(Opie::Core::OProcess*)));
327 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), 331 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
328 this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); 332 this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
329 333 */
330 *process << command; 334 *process << command;
331 removeMboxfailed = false; 335 removeMboxfailed = false;
332 if(!process->start(OProcess::Block, OProcess::All) ) { 336 if(!process->start(OProcess::Block, OProcess::All) ) {
333 qDebug("could not start process "); 337 qDebug("could not start process ");
334 return 0; 338 return 0;
335 } 339 }
340#endif
336 qDebug("mail box deleted "); 341 qDebug("mail box deleted ");
337 return 1; 342 return 1;
338} 343}
339 344
340void MHwrapper::processEnded(OProcess *p)
341{
342 if (p) delete p;
343}
344
345void MHwrapper::oprocessStderr(OProcess*, char *buffer, int )
346{
347 QString lineStr = buffer;
348 QMessageBox::warning( 0, i18n("Error"), lineStr ,i18n("Ok") );
349 removeMboxfailed = true;
350}
351 345
352void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 346void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
353{ 347{
354 init_storage(); 348 init_storage();
355 if (!m_storage) { 349 if (!m_storage) {
356 return; 350 return;
357 } 351 }
358 target_stat.message_count = 0; 352 target_stat.message_count = 0;
359 target_stat.message_unseen = 0; 353 target_stat.message_unseen = 0;
360 target_stat.message_recent = 0; 354 target_stat.message_recent = 0;
361 QString f = buildPath(mailbox); 355 QString f = buildPath(mailbox);
362 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, 356 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count,
363 &target_stat.message_recent,&target_stat.message_unseen); 357 &target_stat.message_recent,&target_stat.message_unseen);
364 if (r != MAIL_NO_ERROR) { 358 if (r != MAIL_NO_ERROR) {
365 Global::statusMessage(i18n("Error retrieving status")); 359 Global::statusMessage(i18n("Error retrieving status"));
366 } 360 }
367} 361}
368 362
369MAILLIB::ATYPE MHwrapper::getType()const 363MAILLIB::ATYPE MHwrapper::getType()const
370{ 364{
371 return MAILLIB::A_MH; 365 return MAILLIB::A_MH;
372} 366}
373 367
374const QString&MHwrapper::getName()const 368const QString&MHwrapper::getName()const
375{ 369{
376 return MHName; 370 return MHName;
377} 371}
378void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 372void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
379{ 373{
380 init_storage(); 374 init_storage();
381 if (!m_storage) { 375 if (!m_storage) {
382 return; 376 return;
383 } 377 }
384 if (targetWrapper != this) { 378 if (targetWrapper != this) {
385 qDebug("Using generic "); 379 qDebug("Using generic ");
386 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); 380 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit);
387 return; 381 return;
388 } 382 }
389 qDebug("Using internal routines for move/copy "); 383 qDebug("Using internal routines for move/copy ");
390 QString tf = buildPath(targetFolder); 384 QString tf = buildPath(targetFolder);
391 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 385 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
392 if (r != MAIL_NO_ERROR) { 386 if (r != MAIL_NO_ERROR) {
393 qDebug("Error selecting source mailbox "); 387 qDebug("Error selecting source mailbox ");
394 return; 388 return;
395 } 389 }
396 if (moveit) { 390 if (moveit) {
397 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 391 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
398 } else { 392 } else {
399 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 393 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
400 } 394 }
401 if (r != MAIL_NO_ERROR) { 395 if (r != MAIL_NO_ERROR) {
402 qDebug("Error copy/moving mail internal "); 396 qDebug("Error copy/moving mail internal ");
403 } 397 }
404} 398}
405 399
406void MHwrapper::mvcpAllMails(const FolderP&fromFolder, 400void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
407 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 401 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
408{ 402{
409 init_storage(); 403 init_storage();
410 if (!m_storage) { 404 if (!m_storage) {
411 return; 405 return;
412 } 406 }
413 if (targetWrapper != this) { 407 if (targetWrapper != this) {
414 qDebug("Using generic "); 408 qDebug("Using generic ");
415 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 409 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
416 return; 410 return;
417 } 411 }
418 if (!fromFolder) return; 412 if (!fromFolder) return;
419 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); 413 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1());
420 if (r!=MAIL_NO_ERROR) { 414 if (r!=MAIL_NO_ERROR) {
421 qDebug("error selecting source folder! "); 415 qDebug("error selecting source folder! ");
422 return; 416 return;
423 } 417 }
424 QString tf = buildPath(targetFolder); 418 QString tf = buildPath(targetFolder);
425 mailmessage_list*l=0; 419 mailmessage_list*l=0;
426 r = mailsession_get_messages_list(m_storage->sto_session,&l); 420 r = mailsession_get_messages_list(m_storage->sto_session,&l);
427 if (r != MAIL_NO_ERROR) { 421 if (r != MAIL_NO_ERROR) {
428 qDebug("Error message list "); 422 qDebug("Error message list ");
429 } 423 }
430 unsigned j = 0; 424 unsigned j = 0;
431 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { 425 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) {
432 mailmessage * msg; 426 mailmessage * msg;
433 msg = (mailmessage*)carray_get(l->msg_tab, i); 427 msg = (mailmessage*)carray_get(l->msg_tab, i);
434 j = msg->msg_index; 428 j = msg->msg_index;
435 if (moveit) { 429 if (moveit) {
436 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); 430 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1());
437 } else { 431 } else {
438 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); 432 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1());
439 } 433 }
440 if (r != MAIL_NO_ERROR) { 434 if (r != MAIL_NO_ERROR) {
441 qDebug("Error copy/moving mail interna "); 435 qDebug("Error copy/moving mail interna ");
442 436
443 break; 437 break;
444 } 438 }
445 } 439 }
446 if (l) mailmessage_list_free(l); 440 if (l) mailmessage_list_free(l);
447} 441}
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h
index d1b7d1f..87f8ca1 100644
--- a/kmicromail/libmailwrapper/mhwrapper.h
+++ b/kmicromail/libmailwrapper/mhwrapper.h
@@ -1,62 +1,58 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef __MH_WRAPPER_H 2#ifndef __MH_WRAPPER_H
3#define __MH_WRAPPER_H 3#define __MH_WRAPPER_H
4 4
5#include "maildefines.h" 5#include "maildefines.h"
6 6
7#include "genericwrapper.h" 7#include "genericwrapper.h"
8#include <qstring.h> 8#include <qstring.h>
9 9
10class encodedString; 10class encodedString;
11struct mailmbox_folder; 11struct mailmbox_folder;
12namespace Opie {namespace Core {class OProcess;}}
13
14class MHwrapper : public Genericwrapper 12class MHwrapper : public Genericwrapper
15{ 13{
16 Q_OBJECT 14 Q_OBJECT
17public: 15public:
18 MHwrapper(const QString & dir,const QString&name); 16 MHwrapper(const QString & dir,const QString&name);
19 virtual ~MHwrapper(); 17 virtual ~MHwrapper();
20 18
21 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); 19 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
22 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 20 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
23 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 21 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
24 22
25 virtual void deleteMail(const RecMailP&mail); 23 virtual void deleteMail(const RecMailP&mail);
26 virtual void answeredMail(const RecMailP&mail); 24 virtual void answeredMail(const RecMailP&mail);
27 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 25 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
28 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 26 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
29 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 27 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
30 28
31 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, 29 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
32 const QString&d="",bool s=false); 30 const QString&d="",bool s=false);
33 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); 31 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
34 32
35 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
36 34
37 virtual RecBodyP fetchBody( const RecMailP &mail ); 35 virtual RecBodyP fetchBody( const RecMailP &mail );
38 static void mbox_progress( size_t current, size_t maximum ); 36 static void mbox_progress( size_t current, size_t maximum );
39 37
40 virtual encodedString* fetchRawBody(const RecMailP&mail); 38 virtual encodedString* fetchRawBody(const RecMailP&mail);
41 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); 39 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target);
42 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 40 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
43 virtual MAILLIB::ATYPE getType()const; 41 virtual MAILLIB::ATYPE getType()const;
44 virtual const QString&getName()const; 42 virtual const QString&getName()const;
45 virtual Account* getAccount() { return 0; }; 43 virtual Account* getAccount() { return 0; };
46 44
47public slots: 45public slots:
48 /* for deleting maildirs we are using a system call */ 46
49 virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int );
50 virtual void processEnded(Opie::Core::OProcess *);
51protected: 47protected:
52 QString buildPath(const QString&p); 48 QString buildPath(const QString&p);
53 QString MHPath; 49 QString MHPath;
54 QString MHName; 50 QString MHName;
55 51
56 void init_storage(); 52 void init_storage();
57 void clean_storage(); 53 void clean_storage();
58 54
59 bool removeMboxfailed; 55 bool removeMboxfailed;
60}; 56};
61 57
62#endif 58#endif
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h
index 61051dd..79567ef 100644
--- a/kmicromail/libmailwrapper/settings.h
+++ b/kmicromail/libmailwrapper/settings.h
@@ -1,180 +1,181 @@
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 <qdatetime.h> 12#include <qdatetime.h>
12 13
13class Account 14class Account
14{ 15{
15 16
16public: 17public:
17 Account(); 18 Account();
18 virtual ~Account() {} 19 virtual ~Account() {}
19 20
20 void remove(); 21 void remove();
21 void setAccountName( QString name ) { accountName = name; } 22 void setAccountName( QString name ) { accountName = name; }
22 const QString&getAccountName()const{ return accountName; } 23 const QString&getAccountName()const{ return accountName; }
23 MAILLIB::ATYPE getType()const{ return type; } 24 MAILLIB::ATYPE getType()const{ return type; }
24 25
25 void setServer(const QString&str){ server = str; } 26 void setServer(const QString&str){ server = str; }
26 const QString&getServer()const{ return server; } 27 const QString&getServer()const{ return server; }
27 28
28 void setLocalFolder( QString name ) { localFolder = name; } 29 void setLocalFolder( QString name ) { localFolder = name; }
29 const QString& getLocalFolder()const{ return localFolder; } 30 const QString& getLocalFolder()const{ return localFolder; }
30 31
31 void setPort(const QString&str) { port = str; } 32 void setPort(const QString&str) { port = str; }
32 const QString&getPort()const{ return port; } 33 const QString&getPort()const{ return port; }
33 34
34 void setUser(const QString&str){ user = str; } 35 void setUser(const QString&str){ user = str; }
35 const QString&getUser()const{ return user; } 36 const QString&getUser()const{ return user; }
36 37
37 void setPassword(const QString&str) { password = str; } 38 void setPassword(const QString&str) { password = str; }
38 const QString&getPassword()const { return password; } 39 const QString&getPassword()const { return password; }
39 40
40 void setPasswordList(const QStringList &str); 41 void setPasswordList(const QStringList &str);
41 QStringList getPasswordList(); 42 QStringList getPasswordList();
42 43
43 void setSSL( bool b ) { ssl = b; } 44 void setSSL( bool b ) { ssl = b; }
44 bool getSSL() { return ssl; } 45 bool getSSL() { return ssl; }
45 46
46 void setConnectionType( int x ) { connectionType = x; } 47 void setConnectionType( int x ) { connectionType = x; }
47 int ConnectionType() { return connectionType; } 48 int ConnectionType() { return connectionType; }
48 49
49 void setMaxMailSize( int x ) { maxMailSize = x; } 50 void setMaxMailSize( int x ) { maxMailSize = x; }
50 int getMaxMailSize() { return maxMailSize; } 51 int getMaxMailSize() { return maxMailSize; }
51 52
52 void setOffline(bool b) {offline = b;} 53 void setOffline(bool b) {offline = b;}
53 bool getOffline()const{return offline;} 54 bool getOffline()const{return offline;}
54 55
55 bool getLeaveOnServer(){ return leaveOnServer;} 56 bool getLeaveOnServer(){ return leaveOnServer;}
56 void setLeaveOnServer(bool b){ leaveOnServer = b;} 57 void setLeaveOnServer(bool b){ leaveOnServer = b;}
57 58
58 virtual QString getFileName() { return accountName; } 59 virtual QString getFileName() { return accountName; }
59 virtual void read() { ; } 60 virtual void read() { ; }
60 virtual void save() { ; } 61 virtual void save() { ; }
61 62
62protected: 63protected:
63 QString accountName, server, port, user, password; 64 QString accountName, server, port, user, password;
64 bool ssl; 65 bool ssl;
65 int connectionType; 66 int connectionType;
66 bool offline; 67 bool offline;
67 MAILLIB::ATYPE type; 68 MAILLIB::ATYPE type;
68 QString localFolder; 69 QString localFolder;
69 int maxMailSize; 70 int maxMailSize;
70 QDateTime lastFetch; 71 QDateTime lastFetch;
71 bool leaveOnServer; 72 bool leaveOnServer;
72}; 73};
73 74
74class IMAPaccount : public Account 75class IMAPaccount : public Account
75{ 76{
76 77
77public: 78public:
78 IMAPaccount(); 79 IMAPaccount();
79 IMAPaccount( QString filename ); 80 IMAPaccount( QString filename );
80 81
81 static QString getUniqueFileName(); 82 static QString getUniqueFileName();
82 83
83 virtual void read(); 84 virtual void read();
84 virtual void save(); 85 virtual void save();
85 virtual QString getFileName(); 86 virtual QString getFileName();
86 87
87 void setPrefix(const QString&str) {prefix=str;} 88 void setPrefix(const QString&str) {prefix=str;}
88 const QString&getPrefix()const{return prefix;} 89 const QString&getPrefix()const{return prefix;}
89 90
90private: 91private:
91 QString file,prefix; 92 QString file,prefix;
92 93
93}; 94};
94 95
95class POP3account : public Account 96class POP3account : public Account
96{ 97{
97 98
98public: 99public:
99 POP3account(); 100 POP3account();
100 POP3account( QString filename ); 101 POP3account( QString filename );
101 102
102 static QString getUniqueFileName(); 103 static QString getUniqueFileName();
103 104
104 virtual void read(); 105 virtual void read();
105 virtual void save(); 106 virtual void save();
106 virtual QString getFileName(); 107 virtual QString getFileName();
107 108
108private: 109private:
109 QString file; 110 QString file;
110 111
111}; 112};
112 113
113class SMTPaccount : public Account 114class SMTPaccount : public Account
114{ 115{
115 116
116public: 117public:
117 SMTPaccount(); 118 SMTPaccount();
118 SMTPaccount( QString filename ); 119 SMTPaccount( QString filename );
119 120
120 static QString getUniqueFileName(); 121 static QString getUniqueFileName();
121 122
122 virtual void read(); 123 virtual void read();
123 virtual void save(); 124 virtual void save();
124 virtual QString getFileName(); 125 virtual QString getFileName();
125 126
126 void setLogin( bool b ) { login = b; } 127 void setLogin( bool b ) { login = b; }
127 bool getLogin() { return login; } 128 bool getLogin() { return login; }
128 129
129private: 130private:
130 QString file, name, mail, org, cc, bcc, reply, signature; 131 QString file, name, mail, org, cc, bcc, reply, signature;
131 bool useCC, useBCC, useReply, login; 132 bool useCC, useBCC, useReply, login;
132 133
133}; 134};
134 135
135class NNTPaccount : public Account 136class NNTPaccount : public Account
136{ 137{
137 138
138public: 139public:
139 NNTPaccount(); 140 NNTPaccount();
140 NNTPaccount( QString filename ); 141 NNTPaccount( QString filename );
141 142
142 static QString getUniqueFileName(); 143 static QString getUniqueFileName();
143 144
144 virtual void read(); 145 virtual void read();
145 virtual void save(); 146 virtual void save();
146 virtual QString getFileName(); 147 virtual QString getFileName();
147 148
148 void setLogin( bool b ) { login = b; } 149 void setLogin( bool b ) { login = b; }
149 bool getLogin() { return login; } 150 bool getLogin() { return login; }
150 151
151 void setGroups( QStringList list ) { subscribedGroups = list; } 152 void setGroups( QStringList list ) { subscribedGroups = list; }
152 QStringList getGroups() { return subscribedGroups; } 153 QStringList getGroups() { return subscribedGroups; }
153 154
154private: 155private:
155 QString file; 156 QString file;
156 bool login; 157 bool login;
157 QStringList subscribedGroups; 158 QStringList subscribedGroups;
158 159
159}; 160};
160 161
161class Settings : public QObject 162class Settings : public QObject
162{ 163{
163 Q_OBJECT 164 Q_OBJECT
164 165
165public: 166public:
166 Settings(); 167 Settings();
167 QList<Account> getAccounts(); 168 QList<Account> getAccounts();
168 void addAccount(Account *account); 169 void addAccount(Account *account);
169 void delAccount(Account *account); 170 void delAccount(Account *account);
170 void saveAccounts(); 171 void saveAccounts();
171 void readAccounts(); 172 void readAccounts();
172 static void checkDirectory(); 173 static void checkDirectory();
173 174
174private: 175private:
175 void updateAccounts(); 176 void updateAccounts();
176 QList<Account> accounts; 177 QList<Account> accounts;
177 178
178}; 179};
179 180
180#endif 181#endif
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index dee1477..eb07ef1 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -1,461 +1,466 @@
1#include "smtpwrapper.h" 1#include "smtpwrapper.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3#include "abstractmail.h" 3#include "abstractmail.h"
4#include "logindialog.h" 4#include "logindialog.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include "sendmailprogress.h" 6#include "sendmailprogress.h"
7 7
8//#include <opie2/odebug.h> 8//#include <opie2/odebug.h>
9//#include <qt.h> 9//#include <qt.h>
10#include <qapplication.h> 10#include <qapplication.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include <qpe/config.h> 13#ifndef DESKTOP_VERSION
14//#include <qpe/config.h>
14#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
15 16#endif
16#include <libetpan/libetpan.h> 17#include <libetpan/libetpan.h>
17#include <klocale.h> 18#include <klocale.h>
19#include <kglobal.h>
20#include <kconfig.h>
18 21
19 22
20using namespace Opie::Core; 23using namespace Opie::Core;
21progressMailSend*SMTPwrapper::sendProgress = 0; 24progressMailSend*SMTPwrapper::sendProgress = 0;
22 25
23SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) 26SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
24 : Generatemail() 27 : Generatemail()
25{ 28{
26 m_SmtpAccount = aSmtp; 29 m_SmtpAccount = aSmtp;
27 Config cfg( "mail" ); 30 KConfig cfg( locateLocal("config", "kopiemail" ) );
28 cfg.setGroup( "Status" ); 31 cfg.setGroup( "Status" );
29 m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); 32 m_queuedMail = cfg.readNumEntry( "outgoing", 0 );
30 emit queuedMails( m_queuedMail ); 33 emit queuedMails( m_queuedMail );
31 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); 34 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) );
32 m_smtp = 0; 35 m_smtp = 0;
33} 36}
34 37
35SMTPwrapper::~SMTPwrapper() 38SMTPwrapper::~SMTPwrapper()
36{ 39{
37 disc_server(); 40 disc_server();
38} 41}
39 42
40void SMTPwrapper::emitQCop( int queued ) { 43void SMTPwrapper::emitQCop( int queued ) {
44#ifndef DESKTOP_VERSION
41 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); 45 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
42 env << queued; 46 env << queued;
47#endif
43} 48}
44 49
45QString SMTPwrapper::mailsmtpError( int errnum ) { 50QString SMTPwrapper::mailsmtpError( int errnum ) {
46 switch ( errnum ) { 51 switch ( errnum ) {
47 case MAILSMTP_NO_ERROR: 52 case MAILSMTP_NO_ERROR:
48 return i18n( "No error" ); 53 return i18n( "No error" );
49 case MAILSMTP_ERROR_UNEXPECTED_CODE: 54 case MAILSMTP_ERROR_UNEXPECTED_CODE:
50 return i18n( "Unexpected error code" ); 55 return i18n( "Unexpected error code" );
51 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
52 return i18n( "Service not available" ); 57 return i18n( "Service not available" );
53 case MAILSMTP_ERROR_STREAM: 58 case MAILSMTP_ERROR_STREAM:
54 return i18n( "Stream error" ); 59 return i18n( "Stream error" );
55 case MAILSMTP_ERROR_HOSTNAME: 60 case MAILSMTP_ERROR_HOSTNAME:
56 return i18n( "gethostname() failed" ); 61 return i18n( "gethostname() failed" );
57 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 62 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
58 return i18n( "Not implemented" ); 63 return i18n( "Not implemented" );
59 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 64 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
60 return i18n( "Error, action not taken" ); 65 return i18n( "Error, action not taken" );
61 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 66 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
62 return i18n( "Data exceeds storage allocation" ); 67 return i18n( "Data exceeds storage allocation" );
63 case MAILSMTP_ERROR_IN_PROCESSING: 68 case MAILSMTP_ERROR_IN_PROCESSING:
64 return i18n( "Error in processing" ); 69 return i18n( "Error in processing" );
65 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: 70 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED:
66 return i18n( "Starttls not supported" ); 71 return i18n( "Starttls not supported" );
67 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 72 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
68 // return i18n( "Insufficient system storage" ); 73 // return i18n( "Insufficient system storage" );
69 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 74 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
70 return i18n( "Mailbox unavailable" ); 75 return i18n( "Mailbox unavailable" );
71 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 76 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
72 return i18n( "Mailbox name not allowed" ); 77 return i18n( "Mailbox name not allowed" );
73 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 78 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
74 return i18n( "Bad command sequence" ); 79 return i18n( "Bad command sequence" );
75 case MAILSMTP_ERROR_USER_NOT_LOCAL: 80 case MAILSMTP_ERROR_USER_NOT_LOCAL:
76 return i18n( "User not local" ); 81 return i18n( "User not local" );
77 case MAILSMTP_ERROR_TRANSACTION_FAILED: 82 case MAILSMTP_ERROR_TRANSACTION_FAILED:
78 return i18n( "Transaction failed" ); 83 return i18n( "Transaction failed" );
79 case MAILSMTP_ERROR_MEMORY: 84 case MAILSMTP_ERROR_MEMORY:
80 return i18n( "Memory error" ); 85 return i18n( "Memory error" );
81 case MAILSMTP_ERROR_CONNECTION_REFUSED: 86 case MAILSMTP_ERROR_CONNECTION_REFUSED:
82 return i18n( "Connection refused" ); 87 return i18n( "Connection refused" );
83 default: 88 default:
84 return i18n( "Unknown error code" ); 89 return i18n( "Unknown error code" );
85 } 90 }
86} 91}
87 92
88 93
89void SMTPwrapper::progress( size_t current, size_t maximum ) { 94void SMTPwrapper::progress( size_t current, size_t maximum ) {
90 if (SMTPwrapper::sendProgress) { 95 if (SMTPwrapper::sendProgress) {
91 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 96 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
92 qApp->processEvents(); 97 qApp->processEvents();
93 } 98 }
94} 99}
95 100
96void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { 101void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) {
97 if (!mail) 102 if (!mail)
98 return; 103 return;
99 QString localfolders = AbstractMail::defaultLocalfolder(); 104 QString localfolders = AbstractMail::defaultLocalfolder();
100 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 105 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
101 wrap->createMbox(box); 106 wrap->createMbox(box);
102 wrap->storeMessage(mail,length,box); 107 wrap->storeMessage(mail,length,box);
103 delete wrap; 108 delete wrap;
104} 109}
105 110
106bool SMTPwrapper::smtpSend( mailmime *mail,bool later) { 111bool SMTPwrapper::smtpSend( mailmime *mail,bool later) {
107 clist *rcpts = 0; 112 clist *rcpts = 0;
108 char *from, *data; 113 char *from, *data;
109 size_t size; 114 size_t size;
110 115
111 from = data = 0; 116 from = data = 0;
112 117
113 mailmessage * msg = 0; 118 mailmessage * msg = 0;
114 msg = mime_message_init(mail); 119 msg = mime_message_init(mail);
115 mime_message_set_tmpdir(msg,getenv( "HOME" )); 120 mime_message_set_tmpdir(msg,getenv( "HOME" ));
116 int r = mailmessage_fetch(msg,&data,&size); 121 int r = mailmessage_fetch(msg,&data,&size);
117 mime_message_detach_mime(msg); 122 mime_message_detach_mime(msg);
118 mailmessage_free(msg); 123 mailmessage_free(msg);
119 if (r != MAIL_NO_ERROR || !data) { 124 if (r != MAIL_NO_ERROR || !data) {
120 if (data) 125 if (data)
121 free(data); 126 free(data);
122 qDebug("Error fetching mime... "); 127 qDebug("Error fetching mime... ");
123 return false; 128 return false;
124 } 129 }
125 msg = 0; 130 msg = 0;
126 if (later) { 131 if (later) {
127 storeMail(data,size,"Outgoing"); 132 storeMail(data,size,"Outgoing");
128 if (data) 133 if (data)
129 free( data ); 134 free( data );
130 Config cfg( "mail" ); 135 KConfig cfg( locateLocal("config", "kopiemail" ) );
131 cfg.setGroup( "Status" ); 136 cfg.setGroup( "Status" );
132 cfg.writeEntry( "outgoing", ++m_queuedMail ); 137 cfg.writeEntry( "outgoing", ++m_queuedMail );
133 emit queuedMails( m_queuedMail ); 138 emit queuedMails( m_queuedMail );
134 return true; 139 return true;
135 } 140 }
136 from = getFrom( mail ); 141 from = getFrom( mail );
137 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 142 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
138 bool result = smtpSend(from,rcpts,data,size); 143 bool result = smtpSend(from,rcpts,data,size);
139 if (data) { 144 if (data) {
140 free(data); 145 free(data);
141 } 146 }
142 if (from) { 147 if (from) {
143 free(from); 148 free(from);
144 } 149 }
145 if (rcpts) 150 if (rcpts)
146 smtp_address_list_free( rcpts ); 151 smtp_address_list_free( rcpts );
147 return result; 152 return result;
148} 153}
149 154
150void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) 155void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
151{ 156{
152 if (data) { 157 if (data) {
153 storeMail(data,size,"Sendfailed"); 158 storeMail(data,size,"Sendfailed");
154 } 159 }
155 if (failuremessage) { 160 if (failuremessage) {
156 QMessageBox::critical(0,i18n("Error sending mail"), 161 QMessageBox::critical(0,i18n("Error sending mail"),
157 i18n("<center>%1</center>").arg(failuremessage)); 162 i18n("<center>%1</center>").arg(failuremessage));
158 } 163 }
159} 164}
160 165
161int SMTPwrapper::start_smtp_tls() 166int SMTPwrapper::start_smtp_tls()
162{ 167{
163 if (!m_smtp) { 168 if (!m_smtp) {
164 return MAILSMTP_ERROR_IN_PROCESSING; 169 return MAILSMTP_ERROR_IN_PROCESSING;
165 } 170 }
166 int err = mailesmtp_starttls(m_smtp); 171 int err = mailesmtp_starttls(m_smtp);
167 if (err != MAILSMTP_NO_ERROR) return err; 172 if (err != MAILSMTP_NO_ERROR) return err;
168 mailstream_low * low; 173 mailstream_low * low;
169 mailstream_low * new_low; 174 mailstream_low * new_low;
170 low = mailstream_get_low(m_smtp->stream); 175 low = mailstream_get_low(m_smtp->stream);
171 if (!low) { 176 if (!low) {
172 return MAILSMTP_ERROR_IN_PROCESSING; 177 return MAILSMTP_ERROR_IN_PROCESSING;
173 } 178 }
174 int fd = mailstream_low_get_fd(low); 179 int fd = mailstream_low_get_fd(low);
175 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 180 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
176 mailstream_low_free(low); 181 mailstream_low_free(low);
177 mailstream_set_low(m_smtp->stream, new_low); 182 mailstream_set_low(m_smtp->stream, new_low);
178 } else { 183 } else {
179 return MAILSMTP_ERROR_IN_PROCESSING; 184 return MAILSMTP_ERROR_IN_PROCESSING;
180 } 185 }
181 return err; 186 return err;
182} 187}
183 188
184void SMTPwrapper::connect_server() 189void SMTPwrapper::connect_server()
185{ 190{
186 QString server, user, pass; 191 QString server, user, pass;
187 bool ssl; 192 bool ssl;
188 uint16_t port; 193 uint16_t port;
189 ssl = false; 194 ssl = false;
190 bool try_tls = true; 195 bool try_tls = true;
191 bool force_tls=false; 196 bool force_tls=false;
192 QString failuretext = ""; 197 QString failuretext = "";
193 198
194 if (m_smtp || !m_SmtpAccount) { 199 if (m_smtp || !m_SmtpAccount) {
195 return; 200 return;
196 } 201 }
197 server = m_SmtpAccount->getServer(); 202 server = m_SmtpAccount->getServer();
198 if ( m_SmtpAccount->ConnectionType() == 2 ) { 203 if ( m_SmtpAccount->ConnectionType() == 2 ) {
199 ssl = true; 204 ssl = true;
200 try_tls = false; 205 try_tls = false;
201 } else if (m_SmtpAccount->ConnectionType() == 1) { 206 } else if (m_SmtpAccount->ConnectionType() == 1) {
202 force_tls = true; 207 force_tls = true;
203 } 208 }
204 int result = 1; 209 int result = 1;
205 port = m_SmtpAccount->getPort().toUInt(); 210 port = m_SmtpAccount->getPort().toUInt();
206 211
207 m_smtp = mailsmtp_new( 20, &progress ); 212 m_smtp = mailsmtp_new( 20, &progress );
208 if ( m_smtp == NULL ) { 213 if ( m_smtp == NULL ) {
209 /* no failure message cause this happens when problems with memory - than we 214 /* no failure message cause this happens when problems with memory - than we
210 we can not display any messagebox */ 215 we can not display any messagebox */
211 return; 216 return;
212 } 217 }
213 218
214 int err = MAILSMTP_NO_ERROR; 219 int err = MAILSMTP_NO_ERROR;
215 ; // odebug << "Servername " << server << " at port " << port << "" << oendl; 220 ; // odebug << "Servername " << server << " at port " << port << "" << oendl;
216 if ( ssl ) { 221 if ( ssl ) {
217 ; // odebug << "SSL session" << oendl; 222 ; // odebug << "SSL session" << oendl;
218 err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); 223 err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port );
219 } else { 224 } else {
220 ; // odebug << "No SSL session" << oendl; 225 ; // odebug << "No SSL session" << oendl;
221 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); 226 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port );
222 } 227 }
223 if ( err != MAILSMTP_NO_ERROR ) { 228 if ( err != MAILSMTP_NO_ERROR ) {
224 ; // odebug << "Error init connection" << oendl; 229 ; // odebug << "Error init connection" << oendl;
225 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); 230 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err));
226 result = 0; 231 result = 0;
227 } 232 }
228 233
229 /* switch to tls after init 'cause there it will send the ehlo */ 234 /* switch to tls after init 'cause there it will send the ehlo */
230 if (result) { 235 if (result) {
231 err = mailsmtp_init( m_smtp ); 236 err = mailsmtp_init( m_smtp );
232 if (err != MAILSMTP_NO_ERROR) { 237 if (err != MAILSMTP_NO_ERROR) {
233 result = 0; 238 result = 0;
234 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err)); 239 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err));
235 } 240 }
236 } 241 }
237 242
238 if (try_tls) { 243 if (try_tls) {
239 err = start_smtp_tls(); 244 err = start_smtp_tls();
240 if (err != MAILSMTP_NO_ERROR) { 245 if (err != MAILSMTP_NO_ERROR) {
241 try_tls = false; 246 try_tls = false;
242 } else { 247 } else {
243 err = mailesmtp_ehlo(m_smtp); 248 err = mailesmtp_ehlo(m_smtp);
244 } 249 }
245 } 250 }
246 251
247 if (!try_tls && force_tls) { 252 if (!try_tls && force_tls) {
248 result = 0; 253 result = 0;
249 failuretext = i18n("Error init SMTP tls: %1").arg(mailsmtpError(err)); 254 failuretext = i18n("Error init SMTP tls: %1").arg(mailsmtpError(err));
250 } 255 }
251 256
252 if (result==1 && m_SmtpAccount->getLogin() ) { 257 if (result==1 && m_SmtpAccount->getLogin() ) {
253 ; // odebug << "smtp with auth" << oendl; 258 ; // odebug << "smtp with auth" << oendl;
254 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 259 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
255 // get'em 260 // get'em
256 LoginDialog login( m_SmtpAccount->getUser(), 261 LoginDialog login( m_SmtpAccount->getUser(),
257 m_SmtpAccount->getPassword(), NULL, 0, true ); 262 m_SmtpAccount->getPassword(), NULL, 0, true );
258 login.show(); 263 login.show();
259 if ( QDialog::Accepted == login.exec() ) { 264 if ( QDialog::Accepted == login.exec() ) {
260 // ok 265 // ok
261 user = login.getUser(); 266 user = login.getUser();
262 pass = login.getPassword(); 267 pass = login.getPassword();
263 } else { 268 } else {
264 result = 0; 269 result = 0;
265 failuretext=i18n("Login aborted - storing mail to localfolder"); 270 failuretext=i18n("Login aborted - storing mail to localfolder");
266 } 271 }
267 } else { 272 } else {
268 user = m_SmtpAccount->getUser(); 273 user = m_SmtpAccount->getUser();
269 pass = m_SmtpAccount->getPassword(); 274 pass = m_SmtpAccount->getPassword();
270 } 275 }
271 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; 276 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
272 if (result) { 277 if (result) {
273 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); 278 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
274 if ( err == MAILSMTP_NO_ERROR ) { 279 if ( err == MAILSMTP_NO_ERROR ) {
275 ; // odebug << "auth ok" << oendl; 280 ; // odebug << "auth ok" << oendl;
276 } else { 281 } else {
277 failuretext = i18n("Authentification failed"); 282 failuretext = i18n("Authentification failed");
278 result = 0; 283 result = 0;
279 } 284 }
280 } 285 }
281 } 286 }
282} 287}
283 288
284void SMTPwrapper::disc_server() 289void SMTPwrapper::disc_server()
285{ 290{
286 if (m_smtp) { 291 if (m_smtp) {
287 mailsmtp_quit( m_smtp ); 292 mailsmtp_quit( m_smtp );
288 mailsmtp_free( m_smtp ); 293 mailsmtp_free( m_smtp );
289 m_smtp = 0; 294 m_smtp = 0;
290 } 295 }
291} 296}
292 297
293int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) 298int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
294{ 299{
295 int err,result; 300 int err,result;
296 QString failuretext = ""; 301 QString failuretext = "";
297 302
298 connect_server(); 303 connect_server();
299 304
300 result = 1; 305 result = 1;
301 if (m_smtp) { 306 if (m_smtp) {
302 err = mailsmtp_send( m_smtp, from, rcpts, data, size ); 307 err = mailsmtp_send( m_smtp, from, rcpts, data, size );
303 if ( err != MAILSMTP_NO_ERROR ) { 308 if ( err != MAILSMTP_NO_ERROR ) {
304 failuretext=i18n("Error sending mail: %1").arg(mailsmtpError(err)); 309 failuretext=i18n("Error sending mail: %1").arg(mailsmtpError(err));
305 result = 0; 310 result = 0;
306 } 311 }
307 } else { 312 } else {
308 result = 0; 313 result = 0;
309 } 314 }
310 315
311 if (!result) { 316 if (!result) {
312 storeFailedMail(data,size,failuretext); 317 storeFailedMail(data,size,failuretext);
313 } else { 318 } else {
314 ; // odebug << "Mail sent." << oendl; 319 ; // odebug << "Mail sent." << oendl;
315 storeMail(data,size,"Sent"); 320 storeMail(data,size,"Sent");
316 } 321 }
317 return result; 322 return result;
318} 323}
319 324
320bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) 325bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later )
321{ 326{
322 mailmime * mimeMail; 327 mailmime * mimeMail;
323 bool result = true; 328 bool result = true;
324 mimeMail = createMimeMail(mail ); 329 mimeMail = createMimeMail(mail );
325 if ( mimeMail == 0 ) { 330 if ( mimeMail == 0 ) {
326 qDebug("SMTP wrapper:Error creating mail! "); 331 qDebug("SMTP wrapper:Error creating mail! ");
327 return false; 332 return false;
328 } else { 333 } else {
329 sendProgress = new progressMailSend(); 334 sendProgress = new progressMailSend();
330 sendProgress->show(); 335 sendProgress->show();
331 sendProgress->setMaxMails(1); 336 sendProgress->setMaxMails(1);
332 result = smtpSend( mimeMail,later); 337 result = smtpSend( mimeMail,later);
333 ; // odebug << "Clean up done" << oendl; 338 ; // odebug << "Clean up done" << oendl;
334 sendProgress->hide(); 339 sendProgress->hide();
335 delete sendProgress; 340 delete sendProgress;
336 sendProgress = 0; 341 sendProgress = 0;
337 mailmime_free( mimeMail ); 342 mailmime_free( mimeMail );
338 } 343 }
339 return result; 344 return result;
340} 345}
341 346
342int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { 347int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
343 size_t curTok = 0; 348 size_t curTok = 0;
344 mailimf_fields *fields = 0; 349 mailimf_fields *fields = 0;
345 mailimf_field*ffrom = 0; 350 mailimf_field*ffrom = 0;
346 clist *rcpts = 0; 351 clist *rcpts = 0;
347 char*from = 0; 352 char*from = 0;
348 int res = 0; 353 int res = 0;
349 354
350 encodedString * data = wrap->fetchRawBody(which); 355 encodedString * data = wrap->fetchRawBody(which);
351 if (!data) 356 if (!data)
352 return 0; 357 return 0;
353 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); 358 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
354 if (err != MAILIMF_NO_ERROR) { 359 if (err != MAILIMF_NO_ERROR) {
355 delete data; 360 delete data;
356 delete wrap; 361 delete wrap;
357 return 0; 362 return 0;
358 } 363 }
359 364
360 rcpts = createRcptList( fields ); 365 rcpts = createRcptList( fields );
361 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 366 ffrom = getField(fields, MAILIMF_FIELD_FROM );
362 from = getFrom(ffrom); 367 from = getFrom(ffrom);
363 368
364 if (rcpts && from) { 369 if (rcpts && from) {
365 res = smtpSend(from,rcpts,data->Content(),data->Length()); 370 res = smtpSend(from,rcpts,data->Content(),data->Length());
366 } 371 }
367 if (fields) { 372 if (fields) {
368 mailimf_fields_free(fields); 373 mailimf_fields_free(fields);
369 fields = 0; 374 fields = 0;
370 } 375 }
371 if (data) { 376 if (data) {
372 delete data; 377 delete data;
373 } 378 }
374 if (from) { 379 if (from) {
375 free(from); 380 free(from);
376 } 381 }
377 if (rcpts) { 382 if (rcpts) {
378 smtp_address_list_free( rcpts ); 383 smtp_address_list_free( rcpts );
379 } 384 }
380 return res; 385 return res;
381} 386}
382 387
383/* this is a special fun */ 388/* this is a special fun */
384bool SMTPwrapper::flushOutbox() { 389bool SMTPwrapper::flushOutbox() {
385 bool returnValue = true; 390 bool returnValue = true;
386 391
387 ; // odebug << "Sending the queue" << oendl; 392 ; // odebug << "Sending the queue" << oendl;
388 if (!m_SmtpAccount) { 393 if (!m_SmtpAccount) {
389 ; // odebug << "No smtp account given" << oendl; 394 ; // odebug << "No smtp account given" << oendl;
390 return false; 395 return false;
391 } 396 }
392 397
393 bool reset_user_value = false; 398 bool reset_user_value = false;
394 QString localfolders = AbstractMail::defaultLocalfolder(); 399 QString localfolders = AbstractMail::defaultLocalfolder();
395 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 400 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
396 if (!wrap) { 401 if (!wrap) {
397 ; // odebug << "memory error" << oendl; 402 ; // odebug << "memory error" << oendl;
398 return false; 403 return false;
399 } 404 }
400 QString oldPw, oldUser; 405 QString oldPw, oldUser;
401 QValueList<RecMailP> mailsToSend; 406 QValueList<RecMailP> mailsToSend;
402 QValueList<RecMailP> mailsToRemove; 407 QValueList<RecMailP> mailsToRemove;
403 QString mbox("Outgoing"); 408 QString mbox("Outgoing");
404 wrap->listMessages(mbox,mailsToSend); 409 wrap->listMessages(mbox,mailsToSend);
405 if (mailsToSend.count()==0) { 410 if (mailsToSend.count()==0) {
406 delete wrap; 411 delete wrap;
407 ; // odebug << "No mails to send" << oendl; 412 ; // odebug << "No mails to send" << oendl;
408 return false; 413 return false;
409 } 414 }
410 415
411 oldPw = m_SmtpAccount->getPassword(); 416 oldPw = m_SmtpAccount->getPassword();
412 oldUser = m_SmtpAccount->getUser(); 417 oldUser = m_SmtpAccount->getUser();
413 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { 418 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) {
414 // get'em 419 // get'em
415 QString user,pass; 420 QString user,pass;
416 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); 421 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true );
417 login.show(); 422 login.show();
418 if ( QDialog::Accepted == login.exec() ) { 423 if ( QDialog::Accepted == login.exec() ) {
419 // ok 424 // ok
420 user = login.getUser().latin1(); 425 user = login.getUser().latin1();
421 pass = login.getPassword().latin1(); 426 pass = login.getPassword().latin1();
422 reset_user_value = true; 427 reset_user_value = true;
423 m_SmtpAccount->setUser(user); 428 m_SmtpAccount->setUser(user);
424 m_SmtpAccount->setPassword(pass); 429 m_SmtpAccount->setPassword(pass);
425 } else { 430 } else {
426 return true; 431 return true;
427 } 432 }
428 } 433 }
429 434
430 435
431 sendProgress = new progressMailSend(); 436 sendProgress = new progressMailSend();
432 sendProgress->show(); 437 sendProgress->show();
433 sendProgress->setMaxMails(mailsToSend.count()); 438 sendProgress->setMaxMails(mailsToSend.count());
434 439
435 while (mailsToSend.count()>0) { 440 while (mailsToSend.count()>0) {
436 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { 441 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) {
437 QMessageBox::critical(0,i18n("Error sending mail"), 442 QMessageBox::critical(0,i18n("Error sending mail"),
438 i18n("Error sending queued mail - breaking")); 443 i18n("Error sending queued mail - breaking"));
439 returnValue = false; 444 returnValue = false;
440 break; 445 break;
441 } 446 }
442 mailsToRemove.append((*mailsToSend.begin())); 447 mailsToRemove.append((*mailsToSend.begin()));
443 mailsToSend.remove(mailsToSend.begin()); 448 mailsToSend.remove(mailsToSend.begin());
444 sendProgress->setCurrentMails(mailsToRemove.count()); 449 sendProgress->setCurrentMails(mailsToRemove.count());
445 } 450 }
446 if (reset_user_value) { 451 if (reset_user_value) {
447 m_SmtpAccount->setUser(oldUser); 452 m_SmtpAccount->setUser(oldUser);
448 m_SmtpAccount->setPassword(oldPw); 453 m_SmtpAccount->setPassword(oldPw);
449 } 454 }
450 Config cfg( "mail" ); 455 KConfig cfg( locateLocal("config", "kopiemail" ) );
451 cfg.setGroup( "Status" ); 456 cfg.setGroup( "Status" );
452 m_queuedMail = 0; 457 m_queuedMail = 0;
453 cfg.writeEntry( "outgoing", m_queuedMail ); 458 cfg.writeEntry( "outgoing", m_queuedMail );
454 emit queuedMails( m_queuedMail ); 459 emit queuedMails( m_queuedMail );
455 sendProgress->hide(); 460 sendProgress->hide();
456 delete sendProgress; 461 delete sendProgress;
457 sendProgress = 0; 462 sendProgress = 0;
458 wrap->deleteMails(mbox,mailsToRemove); 463 wrap->deleteMails(mbox,mailsToRemove);
459 delete wrap; 464 delete wrap;
460 return returnValue; 465 return returnValue;
461} 466}
diff --git a/kmicromail/libmailwrapper/smtpwrapper.h b/kmicromail/libmailwrapper/smtpwrapper.h
index ec42b56..bdca000 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.h
+++ b/kmicromail/libmailwrapper/smtpwrapper.h
@@ -1,64 +1,64 @@
1// -*- Mode: C++; -*- 1// -*- Mode: C++; -*-
2#ifndef SMTPwrapper_H 2#ifndef SMTPwrapper_H
3#define SMTPwrapper_H 3#define SMTPwrapper_H
4 4
5#include <qpe/applnk.h> 5//#include <qpe/applnk.h>
6 6
7#include <qbitarray.h> 7#include <qbitarray.h>
8#include <qdatetime.h> 8#include <qdatetime.h>
9#include <libetpan/clist.h> 9#include <libetpan/clist.h>
10 10
11#include "settings.h" 11#include "settings.h"
12#include "generatemail.h" 12#include "generatemail.h"
13 13
14#include <opie2/osmartpointer.h> 14#include <opie2/osmartpointer.h>
15 15
16class SMTPaccount; 16class SMTPaccount;
17class AbstractMail; 17class AbstractMail;
18 18
19class SMTPwrapper : public Generatemail 19class SMTPwrapper : public Generatemail
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22 22
23public: 23public:
24 SMTPwrapper(SMTPaccount * aSmtp); 24 SMTPwrapper(SMTPaccount * aSmtp);
25 virtual ~SMTPwrapper(); 25 virtual ~SMTPwrapper();
26 bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false ); 26 bool sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false );
27 bool flushOutbox(); 27 bool flushOutbox();
28 28
29 static progressMailSend*sendProgress; 29 static progressMailSend*sendProgress;
30 virtual Account* getAccount() { return m_SmtpAccount; }; 30 virtual Account* getAccount() { return m_SmtpAccount; };
31 31
32signals: 32signals:
33 void queuedMails( int ); 33 void queuedMails( int );
34 34
35protected: 35protected:
36 mailsmtp *m_smtp; 36 mailsmtp *m_smtp;
37 SMTPaccount * m_SmtpAccount; 37 SMTPaccount * m_SmtpAccount;
38 38
39 void connect_server(); 39 void connect_server();
40 void disc_server(); 40 void disc_server();
41 int start_smtp_tls(); 41 int start_smtp_tls();
42 42
43 43
44 bool smtpSend( mailmime *mail,bool later); 44 bool smtpSend( mailmime *mail,bool later);
45 45
46 static void storeMail(const char*mail, size_t length, const QString&box); 46 static void storeMail(const char*mail, size_t length, const QString&box);
47 static QString mailsmtpError( int err ); 47 static QString mailsmtpError( int err );
48 static void progress( size_t current, size_t maximum ); 48 static void progress( size_t current, size_t maximum );
49 49
50 int smtpSend(char*from,clist*rcpts,const char*data,size_t size); 50 int smtpSend(char*from,clist*rcpts,const char*data,size_t size);
51 51
52 void storeMail(mailmime*mail, const QString&box); 52 void storeMail(mailmime*mail, const QString&box);
53 53
54 int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which); 54 int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which);
55 void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); 55 void storeFailedMail(const char*data,unsigned int size, const char*failuremessage);
56 56
57 int m_queuedMail; 57 int m_queuedMail;
58 58
59protected slots: 59protected slots:
60 void emitQCop( int queued ); 60 void emitQCop( int queued );
61 61
62}; 62};
63 63
64#endif 64#endif
diff --git a/kmicromail/libmailwrapper/storemail.h b/kmicromail/libmailwrapper/storemail.h
index 4433de0..e449f57 100644
--- a/kmicromail/libmailwrapper/storemail.h
+++ b/kmicromail/libmailwrapper/storemail.h
@@ -1,29 +1,29 @@
1#ifndef __STORE_MAIL_H 1#ifndef __STORE_MAIL_H
2#define __STORE_MAIL_H 2#define __STORE_MAIL_H
3 3
4#include <qpe/applnk.h> 4//#include <qpe/applnk.h>
5 5
6#include "generatemail.h" 6#include "generatemail.h"
7 7
8class Account; 8class Account;
9class Mail; 9class Mail;
10class AbstractMail; 10class AbstractMail;
11 11
12class Storemail : public Generatemail 12class Storemail : public Generatemail
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 Storemail(Account*aAccount,const QString&aFolder); 16 Storemail(Account*aAccount,const QString&aFolder);
17 Storemail(const QString&dir,const QString&aFolder); 17 Storemail(const QString&dir,const QString&aFolder);
18 Storemail(const QString&aFolder); 18 Storemail(const QString&aFolder);
19 virtual ~Storemail(); 19 virtual ~Storemail();
20 20
21 int storeMail(const Opie::Core::OSmartPointer<Mail>&mail); 21 int storeMail(const Opie::Core::OSmartPointer<Mail>&mail);
22 22
23protected: 23protected:
24 Account* m_Account; 24 Account* m_Account;
25 QString m_tfolder; 25 QString m_tfolder;
26 AbstractMail*wrapper; 26 AbstractMail*wrapper;
27}; 27};
28 28
29#endif 29#endif
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index c77345b..b19dbbe 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,303 +1,305 @@
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#ifndef DESKTOP_VERSION 12#ifdef DESKTOP_VERSION
13#include <qapplication.h>
14#else
13#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
14#endif 16#endif
15#include "defines.h" 17#include "defines.h"
16#include "mainwindow.h" 18#include "mainwindow.h"
17#include <KDGanttMinimizeSplitter.h> 19#include <KDGanttMinimizeSplitter.h>
18 20
19 21
20#include <kabc/stdaddressbook.h> 22#include <kabc/stdaddressbook.h>
21 23
22MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 24MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
23 : QMainWindow( parent, name ) //, flags ) 25 : QMainWindow( parent, name ) //, flags )
24{ 26{
25 setCaption( i18n( "KOpieMail/Pi" ) ); 27 setCaption( i18n( "KOpieMail/Pi" ) );
26 setToolBarsMovable( false ); 28 setToolBarsMovable( false );
27 //KABC::StdAddressBook::self(); 29 //KABC::StdAddressBook::self();
28 toolBar = new QToolBar( this ); 30 toolBar = new QToolBar( this );
29 menuBar = new QPEMenuBar( toolBar ); 31 menuBar = new QPEMenuBar( toolBar );
30 mailMenu = new QPopupMenu( menuBar ); 32 mailMenu = new QPopupMenu( menuBar );
31 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 33 menuBar->insertItem( i18n( "Mail" ), mailMenu );
32 settingsMenu = new QPopupMenu( menuBar ); 34 settingsMenu = new QPopupMenu( menuBar );
33 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 35 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
34 36
35 addToolBar( toolBar ); 37 addToolBar( toolBar );
36 toolBar->setHorizontalStretchable( true ); 38 toolBar->setHorizontalStretchable( true );
37 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 39 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
38 0, 0, this ); 40 0, 0, this );
39 connect(getMail, SIGNAL( activated() ), 41 connect(getMail, SIGNAL( activated() ),
40 SLOT( slotGetAllMail() ) ); 42 SLOT( slotGetAllMail() ) );
41 getMail->addTo( mailMenu ); 43 getMail->addTo( mailMenu );
42 44
43 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 45 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"),
44 0, 0, this ); 46 0, 0, this );
45 getMail->addTo( toolBar ); 47 getMail->addTo( toolBar );
46 getMail->addTo( mailMenu ); 48 getMail->addTo( mailMenu );
47 connect(getMail, SIGNAL( activated() ), 49 connect(getMail, SIGNAL( activated() ),
48 SLOT( slotGetMail() ) ); 50 SLOT( slotGetMail() ) );
49 51
50 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 52 composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"),
51 0, 0, this ); 53 0, 0, this );
52 composeMail->addTo( toolBar ); 54 composeMail->addTo( toolBar );
53 composeMail->addTo( mailMenu ); 55 composeMail->addTo( mailMenu );
54 56
55 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 57 sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") ,
56 0, 0, this ); 58 0, 0, this );
57 sendQueued->addTo( toolBar ); 59 sendQueued->addTo( toolBar );
58 sendQueued->addTo( mailMenu ); 60 sendQueued->addTo( mailMenu );
59 61
60 /* 62 /*
61 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 63 syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC,
62 0, 0, this ); 64 0, 0, this );
63 syncFolders->addTo( toolBar ); 65 syncFolders->addTo( toolBar );
64 syncFolders->addTo( mailMenu ); 66 syncFolders->addTo( mailMenu );
65 */ 67 */
66 68
67 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 69 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") ,
68 0, 0, this, 0, true ); 70 0, 0, this, 0, true );
69 showFolders->addTo( toolBar ); 71 showFolders->addTo( toolBar );
70 showFolders->addTo( mailMenu ); 72 showFolders->addTo( mailMenu );
71 showFolders->setOn( true ); 73 showFolders->setOn( true );
72 connect(showFolders, SIGNAL( toggled(bool) ), 74 connect(showFolders, SIGNAL( toggled(bool) ),
73 SLOT( slotShowFolders(bool) ) ); 75 SLOT( slotShowFolders(bool) ) );
74 76
75 /* 77 /*
76 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 78 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
77 0, 0, this ); 79 0, 0, this );
78 searchMails->addTo( toolBar ); 80 searchMails->addTo( toolBar );
79 searchMails->addTo( mailMenu ); 81 searchMails->addTo( mailMenu );
80 */ 82 */
81 83
82 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 84 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
83 deleteMails->addTo( toolBar ); 85 deleteMails->addTo( toolBar );
84 deleteMails->addTo( mailMenu ); 86 deleteMails->addTo( mailMenu );
85 connect( deleteMails, SIGNAL( activated() ), 87 connect( deleteMails, SIGNAL( activated() ),
86 SLOT( slotDeleteMail() ) ); 88 SLOT( slotDeleteMail() ) );
87 89
88 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 90 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
89 0, 0, this ); 91 0, 0, this );
90 editSettings->addTo( settingsMenu ); 92 editSettings->addTo( settingsMenu );
91 connect( editSettings, SIGNAL( activated() ), 93 connect( editSettings, SIGNAL( activated() ),
92 SLOT( slotEditSettings() ) ); 94 SLOT( slotEditSettings() ) );
93 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 95 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
94 0, 0, this ); 96 0, 0, this );
95 editAccounts->addTo( settingsMenu ); 97 editAccounts->addTo( settingsMenu );
96 98
97 //setCentralWidget( view ); 99 //setCentralWidget( view );
98 100
99 QVBox* wrapperBox = new QVBox( this ); 101 QVBox* wrapperBox = new QVBox( this );
100 setCentralWidget( wrapperBox ); 102 setCentralWidget( wrapperBox );
101 103
102 // QWidget *view = new QWidget( wrapperBox ); 104 // QWidget *view = new QWidget( wrapperBox );
103 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 105 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
104 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 106 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
105 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 107 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
106 108
107 folderView = new AccountView( split ); 109 folderView = new AccountView( split );
108 folderView->header()->hide(); 110 folderView->header()->hide();
109 folderView->setRootIsDecorated( false ); 111 folderView->setRootIsDecorated( false );
110 folderView->addColumn( i18n( "Mailbox" ) ); 112 folderView->addColumn( i18n( "Mailbox" ) );
111 113
112 //layout->addWidget( folderView ); 114 //layout->addWidget( folderView );
113 115
114 mailView = new QListView( split ); 116 mailView = new QListView( split );
115 mailView->addColumn( i18n( " " ) ); 117 mailView->addColumn( i18n( " " ) );
116 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 118 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
117 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 119 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
118 mailView->addColumn( i18n( "Size" ),QListView::Manual); 120 mailView->addColumn( i18n( "Size" ),QListView::Manual);
119 mailView->addColumn( i18n( "Date" ),QListView::Manual); 121 mailView->addColumn( i18n( "Date" ),QListView::Manual);
120 mailView->setAllColumnsShowFocus(true); 122 mailView->setAllColumnsShowFocus(true);
121 //mailView->setSorting(-1); 123 //mailView->setSorting(-1);
122 mailView->setRootIsDecorated( false ); 124 mailView->setRootIsDecorated( false );
123 statusWidget = new StatusWidget( wrapperBox ); 125 statusWidget = new StatusWidget( wrapperBox );
124 statusWidget->hide(); 126 statusWidget->hide();
125 127
126 //layout->addWidget( mailView ); 128 //layout->addWidget( mailView );
127 //layout->setStretchFactor( folderView, 1 ); 129 //layout->setStretchFactor( folderView, 1 );
128 //layout->setStretchFactor( mailView, 2 ); 130 //layout->setStretchFactor( mailView, 2 );
129 131
130 slotAdjustLayout(); 132 slotAdjustLayout();
131#ifndef DESKTOP_VERSION 133#ifndef DESKTOP_VERSION
132 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 134 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
133 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 135 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
134#endif 136#endif
135 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 137 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
136 SLOT( mailLeftClicked(QListViewItem*) ) ); 138 SLOT( mailLeftClicked(QListViewItem*) ) );
137 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 139 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
138 SLOT( mailLeftClicked(QListViewItem*) ) ); 140 SLOT( mailLeftClicked(QListViewItem*) ) );
139 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 141 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
140 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 142 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
141 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 143 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
142 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 144 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
143 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 145 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
144 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 146 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
145// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 147// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
146 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 148 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
147 //mailView->setMultiSelection ( true ); 149 //mailView->setMultiSelection ( true );
148 mailView->setSelectionMode( QListView::Extended ); 150 mailView->setSelectionMode( QListView::Extended );
149 QValueList<int> list; 151 QValueList<int> list;
150 int fw = 100; 152 int fw = 100;
151 if ( QApplication::desktop()->width() > 320 ) 153 if ( QApplication::desktop()->width() > 320 )
152 fw = 50; 154 fw = 50;
153 list.append( fw ); 155 list.append( fw );
154 list.append( 100 ); 156 list.append( 100 );
155 split->setSizes( list ); 157 split->setSizes( list );
156 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 158 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
157 mailView->setShowSortIndicator ( true ); 159 mailView->setShowSortIndicator ( true );
158 QLabel *spacer = new QLabel( toolBar ); 160 QLabel *spacer = new QLabel( toolBar );
159 spacer->setBackgroundMode( QWidget::PaletteButton ); 161 spacer->setBackgroundMode( QWidget::PaletteButton );
160 toolBar->setStretchableWidget( spacer ); 162 toolBar->setStretchableWidget( spacer );
161 163
162 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 164 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
163 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 165 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
164 if ( QApplication::desktop()->width() > 320 ) 166 if ( QApplication::desktop()->width() > 320 )
165 closeMail->addTo(toolBar); 167 closeMail->addTo(toolBar);
166 closeMail->addTo(mailMenu); 168 closeMail->addTo(mailMenu);
167 169
168 170
169 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 171 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
170 menuBar->insertItem( i18n( "Help" ), helpMenu ); 172 menuBar->insertItem( i18n( "Help" ), helpMenu );
171 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 173 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
172 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 174 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
173 li->addTo(helpMenu); 175 li->addTo(helpMenu);
174 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 176 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
175 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 177 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
176 li->addTo(helpMenu); 178 li->addTo(helpMenu);
177 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 179 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
178 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 180 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
179 li->addTo(helpMenu); 181 li->addTo(helpMenu);
180} 182}
181 183
182MainWindow::~MainWindow() 184MainWindow::~MainWindow()
183{ 185{
184} 186}
185 187
186void MainWindow::showLicence() 188void MainWindow::showLicence()
187{ 189{
188 KApplication::showLicence(); 190 KApplication::showLicence();
189} 191}
190void MainWindow::showAbout() 192void MainWindow::showAbout()
191{ 193{
192 QString version; 194 QString version;
193#include <../version> 195#include <../version>
194 196
195 QString cap = "About KOpieMail/Pi"; 197 QString cap = "About KOpieMail/Pi";
196 QString text =i18n("KOpieMail/Platform-independent\n") + 198 QString text =i18n("KOpieMail/Platform-independent\n") +
197 "(OM/Pi) " + version + " - " 199 "(OM/Pi) " + version + " - "
198 200
199#ifdef DESKTOP_VERSION 201#ifdef DESKTOP_VERSION
200 "Desktop Edition\n" 202 "Desktop Edition\n"
201#else 203#else
202 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 204 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
203#endif 205#endif
204 "www.pi-sync.net\n\n" 206 "www.pi-sync.net\n\n"
205 207
206 208
207 209
208"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 210"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
209 "KOpieMail/Pi is based on Opie Mail\n" 211 "KOpieMail/Pi is based on Opie Mail\n"
210 "Copyright (c) Rajko Albrecht and the Opie team\n" 212 "Copyright (c) Rajko Albrecht and the Opie team\n"
211 "KOpieMail/Pi is licensed under the GPL\n" 213 "KOpieMail/Pi is licensed under the GPL\n"
212 "\n" 214 "\n"
213 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 215 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
214 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 216 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
215 "libEtPan has its own licence - see LibEtPan licence\n"; 217 "libEtPan has its own licence - see LibEtPan licence\n";
216 218
217 KApplication::showText( cap, text ); 219 KApplication::showText( cap, text );
218} 220}
219void MainWindow::showEtpanLicence() 221void MainWindow::showEtpanLicence()
220{ 222{
221 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); 223 KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" );
222 224
223} 225}
224void MainWindow::appMessage(const QCString &, const QByteArray &) 226void MainWindow::appMessage(const QCString &, const QByteArray &)
225{ 227{
226 qDebug("appMessage implemented by subclass"); 228 qDebug("appMessage implemented by subclass");
227} 229}
228 230
229void MainWindow::slotAdjustLayout() { 231void MainWindow::slotAdjustLayout() {
230 232
231 /* 233 /*
232 QWidget *d = QApplication::desktop(); 234 QWidget *d = QApplication::desktop();
233 235
234 if ( d->width() < d->height() ) { 236 if ( d->width() < d->height() ) {
235 layout->setDirection( QBoxLayout::TopToBottom ); 237 layout->setDirection( QBoxLayout::TopToBottom );
236 } else { 238 } else {
237 layout->setDirection( QBoxLayout::LeftToRight ); 239 layout->setDirection( QBoxLayout::LeftToRight );
238 } 240 }
239 */ 241 */
240} 242}
241 243
242void MainWindow::slotAdjustColumns() 244void MainWindow::slotAdjustColumns()
243{ 245{
244 bool hidden = folderView->isHidden(); 246 bool hidden = folderView->isHidden();
245 if ( hidden ) folderView->show(); 247 if ( hidden ) folderView->show();
246 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 248 folderView->setColumnWidth( 0, folderView->visibleWidth() );
247 if ( hidden ) folderView->hide(); 249 if ( hidden ) folderView->hide();
248 250
249 mailView->setColumnWidth( 0, 10 ); 251 mailView->setColumnWidth( 0, 10 );
250 mailView->setColumnWidth( 1, 100 ); 252 mailView->setColumnWidth( 1, 100 );
251 mailView->setColumnWidth( 2, 100 ); 253 mailView->setColumnWidth( 2, 100 );
252 mailView->setColumnWidth( 3, 50 ); 254 mailView->setColumnWidth( 3, 50 );
253 mailView->setColumnWidth( 4, 120 ); 255 mailView->setColumnWidth( 4, 120 );
254} 256}
255 257
256void MainWindow::slotEditSettings() 258void MainWindow::slotEditSettings()
257{ 259{
258} 260}
259 261
260void MainWindow::slotShowFolders( bool ) 262void MainWindow::slotShowFolders( bool )
261{ 263{
262 qDebug("not implemented: "); 264 qDebug("not implemented: ");
263} 265}
264 266
265void MainWindow::refreshMailView(const QValueList<RecMailP>&) 267void MainWindow::refreshMailView(const QValueList<RecMailP>&)
266{ 268{
267 qDebug("not implemented: "); 269 qDebug("not implemented: ");
268} 270}
269 271
270void MainWindow::mailLeftClicked(QListViewItem * ) 272void MainWindow::mailLeftClicked(QListViewItem * )
271{ 273{
272 qDebug("not implemented: "); 274 qDebug("not implemented: ");
273} 275}
274 276
275void MainWindow::displayMail() 277void MainWindow::displayMail()
276{ 278{
277 qDebug("not implemented: "); 279 qDebug("not implemented: ");
278} 280}
279 281
280void MainWindow::slotDeleteMail() 282void MainWindow::slotDeleteMail()
281{ 283{
282 qDebug("not implemented: "); 284 qDebug("not implemented: ");
283} 285}
284 286
285void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 287void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
286{ 288{
287 qDebug("not implemented: "); 289 qDebug("not implemented: ");
288} 290}
289 291
290void MainWindow::slotSendQueued() 292void MainWindow::slotSendQueued()
291{ 293{
292 qDebug("not implemented: "); 294 qDebug("not implemented: ");
293} 295}
294 296
295void MainWindow::slotEditAccounts() 297void MainWindow::slotEditAccounts()
296{ 298{
297 qDebug("not implemented: "); 299 qDebug("not implemented: ");
298} 300}
299 301
300void MainWindow::slotComposeMail() 302void MainWindow::slotComposeMail()
301{ 303{
302 qDebug("not implemented: "); 304 qDebug("not implemented: ");
303} 305}
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h
index 35b9c8c..f5ab69b 100644
--- a/kmicromail/mainwindow.h
+++ b/kmicromail/mainwindow.h
@@ -1,67 +1,68 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#ifndef MAINWINDOW_H 3#ifndef MAINWINDOW_H
4#define MAINWINDOW_H 4#define MAINWINDOW_H
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qaction.h> 8#include <qaction.h>
9 9
10#include <qtoolbar.h> 10#include <qtoolbar.h>
11#ifdef DESKTOP_VERSION 11#ifdef DESKTOP_VERSION
12#include <qmenubar.h> 12#include <qmenubar.h>
13#define QPEMenuBar QMenuBar
13#else 14#else
14#include <qpe/qpemenubar.h> 15#include <qpe/qpemenubar.h>
15#endif 16#endif
16 17
17#include "accountview.h" 18#include "accountview.h"
18#include "statuswidget.h" 19#include "statuswidget.h"
19 20
20#include <libmailwrapper/mailtypes.h> 21#include <libmailwrapper/mailtypes.h>
21#include <opie2/osmartpointer.h> 22#include <opie2/osmartpointer.h>
22 23
23class RecMail; 24class RecMail;
24 25
25class MainWindow : public QMainWindow 26class MainWindow : public QMainWindow
26{ 27{
27 Q_OBJECT 28 Q_OBJECT
28 29
29public: 30public:
30 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 31 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
31 virtual ~MainWindow(); 32 virtual ~MainWindow();
32 33
33public slots: 34public slots:
34 virtual void slotAdjustColumns(); 35 virtual void slotAdjustColumns();
35 virtual void appMessage(const QCString &msg, const QByteArray &data); 36 virtual void appMessage(const QCString &msg, const QByteArray &data);
36 virtual void slotComposeMail(); 37 virtual void slotComposeMail();
37 38
38protected slots: 39protected slots:
39 virtual void slotSendQueued(); 40 virtual void slotSendQueued();
40 virtual void slotEditAccounts(); 41 virtual void slotEditAccounts();
41 virtual void slotShowFolders( bool show ); 42 virtual void slotShowFolders( bool show );
42 virtual void refreshMailView(const QValueList<RecMailP>&); 43 virtual void refreshMailView(const QValueList<RecMailP>&);
43 virtual void displayMail(); 44 virtual void displayMail();
44 virtual void slotGetMail() = 0; 45 virtual void slotGetMail() = 0;
45 virtual void slotGetAllMail() = 0; 46 virtual void slotGetAllMail() = 0;
46 virtual void slotDeleteMail(); 47 virtual void slotDeleteMail();
47 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 48 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
48 virtual void slotAdjustLayout(); 49 virtual void slotAdjustLayout();
49 virtual void slotEditSettings(); 50 virtual void slotEditSettings();
50 virtual void mailLeftClicked( QListViewItem * ); 51 virtual void mailLeftClicked( QListViewItem * );
51 void showLicence(); 52 void showLicence();
52 void showAbout(); 53 void showAbout();
53 void showEtpanLicence(); 54 void showEtpanLicence();
54 55
55protected: 56protected:
56 QToolBar *toolBar; 57 QToolBar *toolBar;
57 StatusWidget *statusWidget; 58 StatusWidget *statusWidget;
58 QPEMenuBar *menuBar; 59 QPEMenuBar *menuBar;
59 QPopupMenu *mailMenu, *settingsMenu; 60 QPopupMenu *mailMenu, *settingsMenu;
60 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 61 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
61 *editSettings, *editAccounts, *syncFolders; 62 *editSettings, *editAccounts, *syncFolders;
62 AccountView *folderView; 63 AccountView *folderView;
63 QListView *mailView; 64 QListView *mailView;
64 //QBoxLayout *layout; 65 //QBoxLayout *layout;
65}; 66};
66 67
67#endif 68#endif
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index a32983c..153c7c0 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,468 +1,474 @@
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 "settingsdialog.h" 4#include "settingsdialog.h"
5#include "opiemail.h" 5#include "opiemail.h"
6#include "editaccounts.h" 6#include "editaccounts.h"
7#include "composemail.h" 7#include "composemail.h"
8#include "mailistviewitem.h" 8#include "mailistviewitem.h"
9#include "viewmail.h" 9#include "viewmail.h"
10#include "selectstore.h" 10#include "selectstore.h"
11#include "selectsmtp.h" 11#include "selectsmtp.h"
12#include "accountitem.h" 12#include "accountitem.h"
13#include "koprefsdialog.h" 13#include "koprefsdialog.h"
14#include "klocale.h" 14#include "klocale.h"
15 15
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17#include <qtimer.h> 17#include <qtimer.h>
18#include <qcursor.h>
19#include <qregexp.h>
18#include <libkdepim/externalapphandler.h> 20#include <libkdepim/externalapphandler.h>
19#include <libkdepim/kpimglobalprefs.h> 21#include <libkdepim/kpimglobalprefs.h>
20 22
23#ifdef DESKTOP_VERSION
24#include <qapplication.h>
25#else
21#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#endif
22#include <libmailwrapper/smtpwrapper.h> 28#include <libmailwrapper/smtpwrapper.h>
23#include <libmailwrapper/mailtypes.h> 29#include <libmailwrapper/mailtypes.h>
24#include <libmailwrapper/abstractmail.h> 30#include <libmailwrapper/abstractmail.h>
25/* OPIE */ 31/* OPIE */
26//#include <qpe/resource.h> 32//#include <qpe/resource.h>
27//#include <qpe/qpeapplication.h> 33//#include <qpe/qpeapplication.h>
28 34
29/* QT */ 35/* QT */
30 36
31//using namespace Opie::Core; 37//using namespace Opie::Core;
32 38
33OpieMail::OpieMail( QWidget *parent, const char *name ) 39OpieMail::OpieMail( QWidget *parent, const char *name )
34 : MainWindow( parent, name) //, WStyle_ContextHelp ) 40 : MainWindow( parent, name) //, WStyle_ContextHelp )
35{ 41{
36 settings = new Settings(); 42 settings = new Settings();
37 43
38 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
39 45
40} 46}
41 47
42OpieMail::~OpieMail() 48OpieMail::~OpieMail()
43{ 49{
44 if (settings) delete settings; 50 if (settings) delete settings;
45} 51}
46 52
47void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
48{ 54{
49 55
50} 56}
51#include <stdlib.h> 57#include <stdlib.h>
52void OpieMail::message(const QCString &msg, const QByteArray &data) 58void OpieMail::message(const QCString &msg, const QByteArray &data)
53{ 59{
54 // copied from old mail2 60 // copied from old mail2
55 static int ii = 0; 61 static int ii = 0;
56 //qDebug("QCOP CALL ############################# %d ", ii); 62 //qDebug("QCOP CALL ############################# %d ", ii);
57 //QString mess ( msg ); 63 //QString mess ( msg );
58 //qDebug("Message = %s ",mess.latin1()); 64 //qDebug("Message = %s ",mess.latin1());
59 ++ii; 65 ++ii;
60 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
61 67
62 mPendingEmail = QString::null; 68 mPendingEmail = QString::null;
63 mPendingName = QString::null; 69 mPendingName = QString::null;
64 if (msg == "writeMail(QString,QString)") 70 if (msg == "writeMail(QString,QString)")
65 { 71 {
66 //qDebug("writeMail(QString,QString) "); 72 //qDebug("writeMail(QString,QString) ");
67 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
68 stream >> mPendingName >> mPendingEmail; 74 stream >> mPendingName >> mPendingEmail;
69 // removing the whitespaces at beginning and end is needed! 75 // removing the whitespaces at beginning and end is needed!
70 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
71 } 77 }
72 else if (msg == "newMail()") 78 else if (msg == "newMail()")
73 { 79 {
74 //qDebug("slotComposeMail() "); 80 //qDebug("slotComposeMail() ");
75 // 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
76 // 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
77 // 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
78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
79 // slotComposeMail(); 85 // slotComposeMail();
80 } 86 }
81 else if (msg == "newMail(QString)") 87 else if (msg == "newMail(QString)")
82 { 88 {
83 //qDebug(" newMail(QString)"); 89 //qDebug(" newMail(QString)");
84 QDataStream stream(data,IO_ReadOnly); 90 QDataStream stream(data,IO_ReadOnly);
85 stream >> mPendingName; 91 stream >> mPendingName;
86 // the format is 92 // the format is
87 // NAME <EMAIL>:SUBJECT 93 // NAME <EMAIL>:SUBJECT
88 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 94 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
89 } else { 95 } else {
90 mPendingData = data; 96 mPendingData = data;
91 mPendingMessage = msg; 97 mPendingMessage = msg;
92 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 98 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
93 } 99 }
94 100
95 //qDebug("END OpieMail::message "); 101 //qDebug("END OpieMail::message ");
96} 102}
97void OpieMail::slotExtAppHandler() 103void OpieMail::slotExtAppHandler()
98{ 104{
99 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 105 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
100} 106}
101void OpieMail::slotwriteMail2(const QString& namemail ) 107void OpieMail::slotwriteMail2(const QString& namemail )
102{ 108{
103 //qDebug("OpieMail::slotwriteMail2 "); 109 //qDebug("OpieMail::slotwriteMail2 ");
104 //qApp->processEvents(); 110 //qApp->processEvents();
105 ComposeMail compose( settings, this, 0, true ); 111 ComposeMail compose( settings, this, 0, true );
106 if ( !namemail.isEmpty() ) { 112 if ( !namemail.isEmpty() ) {
107 QString to = namemail; 113 QString to = namemail;
108 if ( namemail.find( " <") > 1 ) { 114 if ( namemail.find( " <") > 1 ) {
109 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 115 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
110 } else 116 } else
111 if ( namemail.find( "<") > 1 ) { 117 if ( namemail.find( "<") > 1 ) {
112 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 118 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
113 } 119 }
114 int sub = to.find( ">:"); 120 int sub = to.find( ">:");
115 if ( sub > 0 ) { 121 if ( sub > 0 ) {
116 compose.setTo( to.left(sub+1) ); 122 compose.setTo( to.left(sub+1) );
117 compose.setSubject( to.mid(sub+2) ); 123 compose.setSubject( to.mid(sub+2) );
118 } else 124 } else
119 compose.setTo( to ); 125 compose.setTo( to );
120 } 126 }
121 compose.slotAdjustColumns(); 127 compose.slotAdjustColumns();
122 compose.showMaximized(); 128 compose.showMaximized();
123 compose.exec(); 129 compose.exec();
124 raise(); 130 raise();
125 //qDebug("retttich "); 131 //qDebug("retttich ");
126} 132}
127void OpieMail::slotwriteMail(const QString&name,const QString&email) 133void OpieMail::slotwriteMail(const QString&name,const QString&email)
128{ 134{
129 // qDebug("OpieMail::slotwriteMail "); 135 // qDebug("OpieMail::slotwriteMail ");
130 ComposeMail compose( settings, this, 0, true ); 136 ComposeMail compose( settings, this, 0, true );
131 if (!email.isEmpty()) 137 if (!email.isEmpty())
132 { 138 {
133 if (!name.isEmpty()) 139 if (!name.isEmpty())
134 { 140 {
135 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 141 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
136 } 142 }
137 else 143 else
138 { 144 {
139 compose.setTo(email); 145 compose.setTo(email);
140 } 146 }
141 } 147 }
142 compose.slotAdjustColumns(); 148 compose.slotAdjustColumns();
143 compose.showMaximized(); 149 compose.showMaximized();
144 compose.exec(); 150 compose.exec();
145 raise(); 151 raise();
146} 152}
147 153
148void OpieMail::slotComposeMail() 154void OpieMail::slotComposeMail()
149{ 155{
150 if ( mPendingEmail == QString::null && mPendingName == QString::null) 156 if ( mPendingEmail == QString::null && mPendingName == QString::null)
151 slotwriteMail2( QString () ); 157 slotwriteMail2( QString () );
152 else { 158 else {
153 if ( mPendingEmail == QString::null ) 159 if ( mPendingEmail == QString::null )
154 slotwriteMail2( mPendingName ); 160 slotwriteMail2( mPendingName );
155 else 161 else
156 slotwriteMail( mPendingName, mPendingEmail ); 162 slotwriteMail( mPendingName, mPendingEmail );
157 } 163 }
158 //slotwriteMail(0l,0l); 164 //slotwriteMail(0l,0l);
159} 165}
160 166
161void OpieMail::slotSendQueued() 167void OpieMail::slotSendQueued()
162{ 168{
163 SMTPaccount *smtp = 0; 169 SMTPaccount *smtp = 0;
164 170
165 QList<Account> list = settings->getAccounts(); 171 QList<Account> list = settings->getAccounts();
166 QList<SMTPaccount> smtpList; 172 QList<SMTPaccount> smtpList;
167 smtpList.setAutoDelete(false); 173 smtpList.setAutoDelete(false);
168 Account *it; 174 Account *it;
169 for ( it = list.first(); it; it = list.next() ) 175 for ( it = list.first(); it; it = list.next() )
170 { 176 {
171 if ( it->getType() == MAILLIB::A_SMTP ) 177 if ( it->getType() == MAILLIB::A_SMTP )
172 { 178 {
173 smtp = static_cast<SMTPaccount *>(it); 179 smtp = static_cast<SMTPaccount *>(it);
174 smtpList.append(smtp); 180 smtpList.append(smtp);
175 } 181 }
176 } 182 }
177 if (smtpList.count()==0) 183 if (smtpList.count()==0)
178 { 184 {
179 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"));
180 return; 186 return;
181 } 187 }
182 if (smtpList.count()==1) 188 if (smtpList.count()==1)
183 { 189 {
184 smtp = smtpList.at(0); 190 smtp = smtpList.at(0);
185 } 191 }
186 else 192 else
187 { 193 {
188 smtp = 0; 194 smtp = 0;
189 selectsmtp selsmtp; 195 selectsmtp selsmtp;
190 selsmtp.setSelectionlist(&smtpList); 196 selsmtp.setSelectionlist(&smtpList);
191 selsmtp.showMaximized(); 197 selsmtp.showMaximized();
192 if ( selsmtp.exec() == QDialog::Accepted ) 198 if ( selsmtp.exec() == QDialog::Accepted )
193 { 199 {
194 smtp = selsmtp.selected_smtp(); 200 smtp = selsmtp.selected_smtp();
195 } 201 }
196 } 202 }
197 if (smtp) 203 if (smtp)
198 { 204 {
199 SMTPwrapper * wrap = new SMTPwrapper(smtp); 205 SMTPwrapper * wrap = new SMTPwrapper(smtp);
200 if ( wrap->flushOutbox() ) 206 if ( wrap->flushOutbox() )
201 { 207 {
202 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); 208 QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed"));
203 } 209 }
204 delete wrap; 210 delete wrap;
205 } 211 }
206} 212}
207 213
208void OpieMail::slotSearchMails() 214void OpieMail::slotSearchMails()
209{ 215{
210 qDebug("OpieMail::slotSearchMails():not implemented "); 216 qDebug("OpieMail::slotSearchMails():not implemented ");
211} 217}
212 218
213void OpieMail::slotEditSettings() 219void OpieMail::slotEditSettings()
214{ 220{
215#if 0 221#if 0
216 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 222 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
217 settingsDialog.showMaximized(); 223 settingsDialog.showMaximized();
218 settingsDialog.exec(); 224 settingsDialog.exec();
219#endif 225#endif
220 KOPrefsDialog settingsDialog( this, "koprefs", true ); 226 KOPrefsDialog settingsDialog( this, "koprefs", true );
221 settingsDialog.showMaximized(); 227 settingsDialog.showMaximized();
222 settingsDialog.exec(); 228 settingsDialog.exec();
223} 229}
224 230
225void OpieMail::slotEditAccounts() 231void OpieMail::slotEditAccounts()
226{ 232{
227 EditAccounts eaDialog( settings, this, 0, true ); 233 EditAccounts eaDialog( settings, this, 0, true );
228 eaDialog.slotAdjustColumns(); 234 eaDialog.slotAdjustColumns();
229 eaDialog.showMaximized(); 235 eaDialog.showMaximized();
230 eaDialog.exec(); 236 eaDialog.exec();
231 if ( settings ) delete settings; 237 if ( settings ) delete settings;
232 settings = new Settings(); 238 settings = new Settings();
233 239
234 folderView->populate( settings->getAccounts() ); 240 folderView->populate( settings->getAccounts() );
235} 241}
236 242
237void OpieMail::displayMail() 243void OpieMail::displayMail()
238{ 244{
239 QListViewItem*item = mailView->currentItem(); 245 QListViewItem*item = mailView->currentItem();
240 if (!item) return; 246 if (!item) return;
241 RecMailP mail = ((MailListViewItem*)item)->data(); 247 RecMailP mail = ((MailListViewItem*)item)->data();
242 RecBodyP body = folderView->fetchBody(mail); 248 RecBodyP body = folderView->fetchBody(mail);
243 ViewMail readMail( this,"", Qt::WType_Modal ); 249 ViewMail readMail( this,"", Qt::WType_Modal );
244 readMail.setBody( body ); 250 readMail.setBody( body );
245 readMail.setMail( mail ); 251 readMail.setMail( mail );
246 readMail.showMaximized(); 252 readMail.showMaximized();
247 readMail.exec(); 253 readMail.exec();
248 254
249 if ( readMail.deleted ) 255 if ( readMail.deleted )
250 { 256 {
251 folderView->refreshCurrent(); 257 folderView->refreshCurrent();
252 } 258 }
253 else 259 else
254 { 260 {
255 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 261 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
256 } 262 }
257} 263}
258void OpieMail::slotGetAllMail() 264void OpieMail::slotGetAllMail()
259{ 265{
260 QListViewItem * item = folderView->firstChild(); 266 QListViewItem * item = folderView->firstChild();
261 while ( item ){ 267 while ( item ){
262 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 268 ((AccountViewItem *)item)->contextMenuSelected( 101 );
263 item = item->nextSibling (); 269 item = item->nextSibling ();
264 } 270 }
265} 271}
266void OpieMail::slotGetMail() 272void OpieMail::slotGetMail()
267{ 273{
268 QListViewItem * item = folderView->currentItem(); 274 QListViewItem * item = folderView->currentItem();
269 if ( ! item ) return; 275 if ( ! item ) return;
270 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 276 ((AccountViewItem *)item)->contextMenuSelected( 101 );
271} 277}
272void OpieMail::slotDeleteMail() 278void OpieMail::slotDeleteMail()
273{ 279{
274 if (!mailView->currentItem()) return; 280 if (!mailView->currentItem()) return;
275 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 281 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
276 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 ) 282 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 )
277 { 283 {
278 mail->Wrapper()->deleteMail( mail ); 284 mail->Wrapper()->deleteMail( mail );
279 folderView->refreshCurrent(); 285 folderView->refreshCurrent();
280 } 286 }
281} 287}
282void OpieMail::slotDeleteAllMail() 288void OpieMail::slotDeleteAllMail()
283{ 289{
284 290
285 QValueList<RecMailP> t; 291 QValueList<RecMailP> t;
286 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 292 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
287 { 293 {
288 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 294 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
289 while ( item ) { 295 while ( item ) {
290 if ( item->isSelected() ) { 296 if ( item->isSelected() ) {
291 t.append( item->data() ); 297 t.append( item->data() );
292 } 298 }
293 item = (MailListViewItem*)item->nextSibling(); 299 item = (MailListViewItem*)item->nextSibling();
294 } 300 }
295 } 301 }
296 else 302 else
297 return; 303 return;
298 if ( t.count() == 0 ) 304 if ( t.count() == 0 )
299 return; 305 return;
300 RecMailP mail = t.first(); 306 RecMailP mail = t.first();
301 mail->Wrapper()->deleteMailList(t); 307 mail->Wrapper()->deleteMailList(t);
302 folderView->refreshCurrent(); 308 folderView->refreshCurrent();
303 309
304 310
305} 311}
306void OpieMail::clearSelection() 312void OpieMail::clearSelection()
307{ 313{
308 mailView->clearSelection(); 314 mailView->clearSelection();
309 315
310} 316}
311 317
312void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 318void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
313{ 319{
314 if (!mailView->currentItem()) return; 320 if (!mailView->currentItem()) return;
315 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 321 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
316 /* just the RIGHT button - or hold on pda */ 322 /* just the RIGHT button - or hold on pda */
317 if (button!=2) {return;} 323 if (button!=2) {return;}
318 if (!item) return; 324 if (!item) return;
319 QPopupMenu *m = new QPopupMenu(0); 325 QPopupMenu *m = new QPopupMenu(0);
320 if (m) 326 if (m)
321 { 327 {
322 if (mailtype==MAILLIB::A_NNTP) { 328 if (mailtype==MAILLIB::A_NNTP) {
323 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 329 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
324 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 330 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
325 m->insertSeparator(); 331 m->insertSeparator();
326 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 332 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
327 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 333 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
328 } else { 334 } else {
329 if (folderView->currentisDraft()) { 335 if (folderView->currentisDraft()) {
330 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 336 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
331 } 337 }
332 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 338 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
333 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 339 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
334 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 340 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
335 m->insertSeparator(); 341 m->insertSeparator();
336 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 342 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
337 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 343 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
338 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 344 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
339 } 345 }
340 m->setFocus(); 346 m->setFocus();
341 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 347 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
342 delete m; 348 delete m;
343 } 349 }
344} 350}
345 351
346void OpieMail::slotShowFolders( bool show ) 352void OpieMail::slotShowFolders( bool show )
347{ 353{
348 if ( show && folderView->isHidden() ) 354 if ( show && folderView->isHidden() )
349 { 355 {
350 folderView->show(); 356 folderView->show();
351 } 357 }
352 else if ( !show && !folderView->isHidden() ) 358 else if ( !show && !folderView->isHidden() )
353 { 359 {
354 folderView->hide(); 360 folderView->hide();
355 } 361 }
356} 362}
357 363
358void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 364void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
359{ 365{
360 MailListViewItem*item = 0; 366 MailListViewItem*item = 0;
361 mailView->clear(); 367 mailView->clear();
362 368
363 QValueList<RecMailP>::ConstIterator it; 369 QValueList<RecMailP>::ConstIterator it;
364 for (it = list.begin(); it != list.end();++it) 370 for (it = list.begin(); it != list.end();++it)
365 { 371 {
366 item = new MailListViewItem(mailView,item); 372 item = new MailListViewItem(mailView,item);
367 item->storeData((*it)); 373 item->storeData((*it));
368 item->showEntry(); 374 item->showEntry();
369 } 375 }
370} 376}
371 377
372void OpieMail::mailLeftClicked( QListViewItem *item ) 378void OpieMail::mailLeftClicked( QListViewItem *item )
373{ 379{
374 mailView->clearSelection(); 380 mailView->clearSelection();
375 /* just LEFT button - or tap with stylus on pda */ 381 /* just LEFT button - or tap with stylus on pda */
376 //if (button!=1) return; 382 //if (button!=1) return;
377 if (!item) return; 383 if (!item) return;
378 if (folderView->currentisDraft()) { 384 if (folderView->currentisDraft()) {
379 reEditMail(); 385 reEditMail();
380 } else { 386 } else {
381 displayMail(); 387 displayMail();
382 } 388 }
383} 389}
384 390
385void OpieMail::slotMoveCopyMail() 391void OpieMail::slotMoveCopyMail()
386{ 392{
387 if (!mailView->currentItem()) return; 393 if (!mailView->currentItem()) return;
388 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 394 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
389 AbstractMail*targetMail = 0; 395 AbstractMail*targetMail = 0;
390 QString targetFolder = ""; 396 QString targetFolder = "";
391 Selectstore sels; 397 Selectstore sels;
392 folderView->setupFolderselect(&sels); 398 folderView->setupFolderselect(&sels);
393 if (!sels.exec()) return; 399 if (!sels.exec()) return;
394 targetMail = sels.currentMail(); 400 targetMail = sels.currentMail();
395 targetFolder = sels.currentFolder(); 401 targetFolder = sels.currentFolder();
396 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 402 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
397 targetFolder.isEmpty()) 403 targetFolder.isEmpty())
398 { 404 {
399 return; 405 return;
400 } 406 }
401 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 407 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
402 { 408 {
403 QMessageBox::critical(0,i18n("Error creating new Folder"), 409 QMessageBox::critical(0,i18n("Error creating new Folder"),
404 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 410 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
405 return; 411 return;
406 } 412 }
407 sels.hide(); 413 sels.hide();
408 qApp->processEvents(); 414 qApp->processEvents();
409 // qDebug("hiding sels "); 415 // qDebug("hiding sels ");
410 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 416 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
411 folderView->refreshCurrent(); 417 folderView->refreshCurrent();
412} 418}
413 419
414void OpieMail::slotMoveCopyAllMail() 420void OpieMail::slotMoveCopyAllMail()
415{ 421{
416 422
417 if (!mailView->currentItem()) return; 423 if (!mailView->currentItem()) return;
418 QValueList<RecMailP> t; 424 QValueList<RecMailP> t;
419 // 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 ) 425 // 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 )
420 { 426 {
421 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 427 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
422 while ( item ) { 428 while ( item ) {
423 if ( item->isSelected() ) { 429 if ( item->isSelected() ) {
424 t.append( item->data() ); 430 t.append( item->data() );
425 } 431 }
426 item = (MailListViewItem*)item->nextSibling(); 432 item = (MailListViewItem*)item->nextSibling();
427 } 433 }
428 } 434 }
429 // else 435 // else
430 // return; 436 // return;
431 if ( t.count() == 0 ) 437 if ( t.count() == 0 )
432 return; 438 return;
433 RecMailP mail = t.first(); 439 RecMailP mail = t.first();
434 AbstractMail*targetMail = 0; 440 AbstractMail*targetMail = 0;
435 QString targetFolder = ""; 441 QString targetFolder = "";
436 Selectstore sels; 442 Selectstore sels;
437 folderView->setupFolderselect(&sels); 443 folderView->setupFolderselect(&sels);
438 if (!sels.exec()) return; 444 if (!sels.exec()) return;
439 targetMail = sels.currentMail(); 445 targetMail = sels.currentMail();
440 targetFolder = sels.currentFolder(); 446 targetFolder = sels.currentFolder();
441 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 447 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
442 targetFolder.isEmpty()) 448 targetFolder.isEmpty())
443 { 449 {
444 return; 450 return;
445 } 451 }
446 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 452 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
447 { 453 {
448 QMessageBox::critical(0,i18n("Error creating new Folder"), 454 QMessageBox::critical(0,i18n("Error creating new Folder"),
449 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 455 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
450 return; 456 return;
451 } 457 }
452 sels.hide(); 458 sels.hide();
453 qApp->processEvents(); 459 qApp->processEvents();
454 //qDebug("hiding sels "); 460 //qDebug("hiding sels ");
455 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 461 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
456 folderView->refreshCurrent(); 462 folderView->refreshCurrent();
457} 463}
458 464
459void OpieMail::reEditMail() 465void OpieMail::reEditMail()
460{ 466{
461 if (!mailView->currentItem()) return; 467 if (!mailView->currentItem()) return;
462 468
463 ComposeMail compose( settings, this, 0, true ); 469 ComposeMail compose( settings, this, 0, true );
464 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 470 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
465 compose.slotAdjustColumns(); 471 compose.slotAdjustColumns();
466 compose.showMaximized(); 472 compose.showMaximized();
467 compose.exec(); 473 compose.exec();
468} 474}
diff --git a/kmicromail/qpe/global.cpp b/kmicromail/qpe/global.cpp
new file mode 100644
index 0000000..f4c6f60
--- a/dev/null
+++ b/kmicromail/qpe/global.cpp
@@ -0,0 +1,12 @@
1
2#include "global.h"
3
4namespace Global{
5
6 void statusMessage(QString message)
7 {
8
9 qDebug("statusMessage %s ", message.latin1());
10 }
11}
12
diff --git a/kmicromail/qpe/global.h b/kmicromail/qpe/global.h
new file mode 100644
index 0000000..ecc5b1b
--- a/dev/null
+++ b/kmicromail/qpe/global.h
@@ -0,0 +1,12 @@
1#ifndef __GLOBAL_H__
2#define __GLOBAL_H__
3
4#include <qstring.h>
5
6namespace Global{
7
8 void statusMessage(QString message);
9
10}
11
12#endif
diff --git a/kmicromail/qpe/qpeapplication.h b/kmicromail/qpe/qpeapplication.h
new file mode 100644
index 0000000..0eadfd1
--- a/dev/null
+++ b/kmicromail/qpe/qpeapplication.h
@@ -0,0 +1,5 @@
1
2#include <qapplication.h>
3#include <qcursor.h>
4#include <qregexp.h>
5
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 7cf5c8e..0b4c322 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,532 +1,533 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include "composemail.h" 2#include "composemail.h"
3#include "viewmail.h" 3#include "viewmail.h"
4 4
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8#include <kapplication.h> 8#include <kapplication.h>
9 9
10/* OPIE */ 10/* OPIE */
11//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
12//#include <opie2/ofiledialog.h> 12//#include <opie2/ofiledialog.h>
13//#include <opie2/oimagescrollview.h> 13//#include <opie2/oimagescrollview.h>
14 14
15#include <kfiledialog.h> 15#include <kfiledialog.h>
16#include <kdialog.h> 16#include <kdialog.h>
17 17
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19 19
20/* QT */ 20/* QT */
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtextstream.h> 23#include <qtextstream.h>
24#include <qaction.h> 24#include <qaction.h>
25#include <qpopupmenu.h> 25#include <qpopupmenu.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include "koprefs.h" 28#include "koprefs.h"
29#include <klocale.h> 29#include <klocale.h>
30#include <kglobal.h>
30 31
31//using namespace Opie::Ui; 32//using namespace Opie::Ui;
32//using namespace Opie::Core; 33//using namespace Opie::Core;
33 34
34AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 35AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
35 const QString&fsize,int num,const QValueList<int>&path) 36 const QString&fsize,int num,const QValueList<int>&path)
36 : QListViewItem(parent,after),_partNum(num) 37 : QListViewItem(parent,after),_partNum(num)
37{ 38{
38 _path=path; 39 _path=path;
39 setText(0, mime); 40 setText(0, mime);
40 setText(1, desc); 41 setText(1, desc);
41 setText(2, file); 42 setText(2, file);
42 setText(3, fsize); 43 setText(3, fsize);
43} 44}
44 45
45AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 46AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
46 const QString&fsize,int num,const QValueList<int>&path) 47 const QString&fsize,int num,const QValueList<int>&path)
47 : QListViewItem(parent,after),_partNum(num) 48 : QListViewItem(parent,after),_partNum(num)
48{ 49{
49 _path=path; 50 _path=path;
50 setText(0, mime); 51 setText(0, mime);
51 setText(1, desc); 52 setText(1, desc);
52 setText(2, file); 53 setText(2, file);
53 setText(3, fsize); 54 setText(3, fsize);
54} 55}
55 56
56bool AttachItem::isParentof(const QValueList<int>&path) 57bool AttachItem::isParentof(const QValueList<int>&path)
57{ 58{
58 /* if not set, then no parent */ 59 /* if not set, then no parent */
59 if (path.count()==0||_path.count()==0) return false; 60 if (path.count()==0||_path.count()==0) return false;
60 /* the parent must have one digit less then a child */ 61 /* the parent must have one digit less then a child */
61 if (path.count()!=_path.count()+1) return false; 62 if (path.count()!=_path.count()+1) return false;
62 for (unsigned int i=0; i < _path.count();++i) 63 for (unsigned int i=0; i < _path.count();++i)
63 { 64 {
64 if (_path[i]!=path[i]) return false; 65 if (_path[i]!=path[i]) return false;
65 } 66 }
66 return true; 67 return true;
67} 68}
68 69
69AttachItem* ViewMail::searchParent(const QValueList<int>&path) 70AttachItem* ViewMail::searchParent(const QValueList<int>&path)
70{ 71{
71 QListViewItemIterator it( attachments ); 72 QListViewItemIterator it( attachments );
72 for ( ; it.current(); ++it ) 73 for ( ; it.current(); ++it )
73 { 74 {
74 AttachItem*ati = (AttachItem*)it.current(); 75 AttachItem*ati = (AttachItem*)it.current();
75 if (ati->isParentof(path)) return ati; 76 if (ati->isParentof(path)) return ati;
76 } 77 }
77 return 0; 78 return 0;
78} 79}
79 80
80AttachItem* ViewMail::lastChild(AttachItem*parent) 81AttachItem* ViewMail::lastChild(AttachItem*parent)
81{ 82{
82 if (!parent) return 0; 83 if (!parent) return 0;
83 AttachItem* item = (AttachItem*)parent->firstChild(); 84 AttachItem* item = (AttachItem*)parent->firstChild();
84 if (!item) return item; 85 if (!item) return item;
85 AttachItem*temp=0; 86 AttachItem*temp=0;
86 while( (temp=(AttachItem*)item->nextSibling())) 87 while( (temp=(AttachItem*)item->nextSibling()))
87 { 88 {
88 item = temp; 89 item = temp;
89 } 90 }
90 return item; 91 return item;
91} 92}
92 93
93void ViewMail::setBody(const RecBodyP&body ) 94void ViewMail::setBody(const RecBodyP&body )
94{ 95{
95 96
96 m_body = body; 97 m_body = body;
97 m_mail[2] = body->Bodytext(); 98 m_mail[2] = body->Bodytext();
98 attachbutton->setEnabled(body->Parts().count()>0); 99 attachbutton->setEnabled(body->Parts().count()>0);
99 attachments->setEnabled(body->Parts().count()>0); 100 attachments->setEnabled(body->Parts().count()>0);
100 if (body->Parts().count()==0) 101 if (body->Parts().count()==0)
101 { 102 {
102 return; 103 return;
103 } 104 }
104 AttachItem * curItem=0; 105 AttachItem * curItem=0;
105 AttachItem * parentItem = 0; 106 AttachItem * parentItem = 0;
106 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 107 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
107 QString desc,fsize; 108 QString desc,fsize;
108 double s = body->Description()->Size(); 109 double s = body->Description()->Size();
109 int w; 110 int w;
110 w=0; 111 w=0;
111 112
112 while (s>1024) 113 while (s>1024)
113 { 114 {
114 s/=1024; 115 s/=1024;
115 ++w; 116 ++w;
116 if (w>=2) break; 117 if (w>=2) break;
117 } 118 }
118 119
119 QString q=""; 120 QString q="";
120 switch(w) 121 switch(w)
121 { 122 {
122 case 1: 123 case 1:
123 q="k"; 124 q="k";
124 break; 125 break;
125 case 2: 126 case 2:
126 q="M"; 127 q="M";
127 break; 128 break;
128 default: 129 default:
129 break; 130 break;
130 } 131 }
131 132
132 { 133 {
133 /* I did not found a method to make a CONTENT reset on a QTextStream 134 /* I did not found a method to make a CONTENT reset on a QTextStream
134 so I use this construct that the stream will re-constructed in each 135 so I use this construct that the stream will re-constructed in each
135 loop. To let it work, the textstream is packed into a own area of 136 loop. To let it work, the textstream is packed into a own area of
136 code is it will be destructed after finishing its small job. 137 code is it will be destructed after finishing its small job.
137 */ 138 */
138 QTextOStream o(&fsize); 139 QTextOStream o(&fsize);
139 if (w>0) o.precision(2); else o.precision(0); 140 if (w>0) o.precision(2); else o.precision(0);
140 o.setf(QTextStream::fixed); 141 o.setf(QTextStream::fixed);
141 o << s << " " << q << "Byte"; 142 o << s << " " << q << "Byte";
142 } 143 }
143 144
144 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 145 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
145 QString filename = ""; 146 QString filename = "";
146 147
147 for (unsigned int i = 0; i < body->Parts().count();++i) 148 for (unsigned int i = 0; i < body->Parts().count();++i)
148 { 149 {
149 filename = ""; 150 filename = "";
150 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 151 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
151 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 152 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
152 for (;it!=body->Parts()[i]->Parameters().end();++it) 153 for (;it!=body->Parts()[i]->Parameters().end();++it)
153 { 154 {
154 if (it.key().lower()=="name") 155 if (it.key().lower()=="name")
155 { 156 {
156 filename=it.data(); 157 filename=it.data();
157 } 158 }
158 } 159 }
159 s = body->Parts()[i]->Size(); 160 s = body->Parts()[i]->Size();
160 w = 0; 161 w = 0;
161 while (s>1024) 162 while (s>1024)
162 { 163 {
163 s/=1024; 164 s/=1024;
164 ++w; 165 ++w;
165 if (w>=2) break; 166 if (w>=2) break;
166 } 167 }
167 switch(w) 168 switch(w)
168 { 169 {
169 case 1: 170 case 1:
170 q="k"; 171 q="k";
171 break; 172 break;
172 case 2: 173 case 2:
173 q="M"; 174 q="M";
174 break; 175 break;
175 default: 176 default:
176 q=""; 177 q="";
177 break; 178 break;
178 } 179 }
179 QTextOStream o(&fsize); 180 QTextOStream o(&fsize);
180 if (w>0) o.precision(2); else o.precision(0); 181 if (w>0) o.precision(2); else o.precision(0);
181 o.setf(QTextStream::fixed); 182 o.setf(QTextStream::fixed);
182 o << s << " " << q << "Byte"; 183 o << s << " " << q << "Byte";
183 desc = body->Parts()[i]->Description(); 184 desc = body->Parts()[i]->Description();
184 parentItem = searchParent(body->Parts()[i]->Positionlist()); 185 parentItem = searchParent(body->Parts()[i]->Positionlist());
185 if (parentItem) 186 if (parentItem)
186 { 187 {
187 AttachItem*temp = lastChild(parentItem); 188 AttachItem*temp = lastChild(parentItem);
188 if (temp) curItem = temp; 189 if (temp) curItem = temp;
189 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 190 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
190 attachments->setRootIsDecorated(true); 191 attachments->setRootIsDecorated(true);
191 curItem = parentItem; 192 curItem = parentItem;
192 } 193 }
193 else 194 else
194 { 195 {
195 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 196 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
196 } 197 }
197 } 198 }
198} 199}
199 200
200 201
201void ViewMail::slotShowHtml( bool state ) 202void ViewMail::slotShowHtml( bool state )
202{ 203{
203 m_showHtml = state; 204 m_showHtml = state;
204 setText(); 205 setText();
205} 206}
206 207
207void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 208void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
208{ 209{
209 if (!item ) 210 if (!item )
210 return; 211 return;
211 212
212 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 213 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
213 { 214 {
214 setText(); 215 setText();
215 return; 216 return;
216 } 217 }
217 QPopupMenu *menu = new QPopupMenu(); 218 QPopupMenu *menu = new QPopupMenu();
218 int ret=0; 219 int ret=0;
219 220
220 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 221 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
221 { 222 {
222 menu->insertItem( i18n( "Show Text" ), 1 ); 223 menu->insertItem( i18n( "Show Text" ), 1 );
223 } 224 }
224 if (item->text(0).left(6)=="image/") { 225 if (item->text(0).left(6)=="image/") {
225 menu->insertItem(i18n("Display image preview"),2); 226 menu->insertItem(i18n("Display image preview"),2);
226 } 227 }
227 menu->insertItem( i18n( "Save Attachment" ), 0 ); 228 menu->insertItem( i18n( "Save Attachment" ), 0 );
228 menu->insertSeparator(1); 229 menu->insertSeparator(1);
229 230
230 ret = menu->exec( point, 0 ); 231 ret = menu->exec( point, 0 );
231 232
232 switch(ret) 233 switch(ret)
233 { 234 {
234 case 0: 235 case 0:
235 { 236 {
236 //MimeTypes types; 237 //MimeTypes types;
237 //types.insert( "all", "*" ); 238 //types.insert( "all", "*" );
238 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 239 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
239 240
240 if( !str.isEmpty() ) 241 if( !str.isEmpty() )
241 { 242 {
242 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 243 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
243 if (content) 244 if (content)
244 { 245 {
245 QFile output(str); 246 QFile output(str);
246 output.open(IO_WriteOnly); 247 output.open(IO_WriteOnly);
247 output.writeBlock(content->Content(),content->Length()); 248 output.writeBlock(content->Content(),content->Length());
248 output.close(); 249 output.close();
249 delete content; 250 delete content;
250 } 251 }
251 } 252 }
252 } 253 }
253 break ; 254 break ;
254 255
255 case 2: 256 case 2:
256 { 257 {
257#ifdef DESKTOP_VERSION 258#ifdef DESKTOP_VERSION
258 QString tmpfile = locateLocal( "tmp", "opiemail-image"); 259 QString tmpfile = locateLocal( "tmp", "opiemail-image");
259#else 260#else
260 QString tmpfile = "/tmp/opiemail-image"; 261 QString tmpfile = "/tmp/opiemail-image";
261#endif 262#endif
262 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 263 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
263 if (content) { 264 if (content) {
264 QFile output(tmpfile); 265 QFile output(tmpfile);
265 output.open(IO_WriteOnly); 266 output.open(IO_WriteOnly);
266 output.writeBlock(content->Content(),content->Length()); 267 output.writeBlock(content->Content(),content->Length());
267 output.close(); 268 output.close();
268 delete content; 269 delete content;
269 MailImageDlg iview(""); 270 MailImageDlg iview("");
270 iview.setName(tmpfile); 271 iview.setName(tmpfile);
271 KApplication::execDialog(&iview); 272 KApplication::execDialog(&iview);
272 output.remove(); 273 output.remove();
273 } 274 }
274 } 275 }
275 break; 276 break;
276 case 1: 277 case 1:
277 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 278 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
278 { 279 {
279 setText(); 280 setText();
280 } 281 }
281 else 282 else
282 { 283 {
283 if ( m_recMail->Wrapper() != 0l ) 284 if ( m_recMail->Wrapper() != 0l )
284 { // make sure that there is a wrapper , even after delete or simular actions 285 { // make sure that there is a wrapper , even after delete or simular actions
285 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 286 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
286 } 287 }
287 } 288 }
288 break; 289 break;
289 } 290 }
290 delete menu; 291 delete menu;
291} 292}
292 293
293 294
294void ViewMail::setMail(const RecMailP&mail ) 295void ViewMail::setMail(const RecMailP&mail )
295{ 296{
296 297
297 m_recMail = mail; 298 m_recMail = mail;
298 299
299 m_mail[0] = mail->getFrom(); 300 m_mail[0] = mail->getFrom();
300 m_mail[1] = mail->getSubject(); 301 m_mail[1] = mail->getSubject();
301 m_mail[3] = mail->getDate(); 302 m_mail[3] = mail->getDate();
302 m_mail[4] = mail->Msgid(); 303 m_mail[4] = mail->Msgid();
303 304
304 m_mail2[0] = mail->To(); 305 m_mail2[0] = mail->To();
305 m_mail2[1] = mail->CC(); 306 m_mail2[1] = mail->CC();
306 m_mail2[2] = mail->Bcc(); 307 m_mail2[2] = mail->Bcc();
307 308
308 setText(); 309 setText();
309} 310}
310 311
311 312
312 313
313ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 314ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
314 : ViewMailBase(parent, name, fl), _inLoop(false) 315 : ViewMailBase(parent, name, fl), _inLoop(false)
315{ 316{
316 m_gotBody = false; 317 m_gotBody = false;
317 deleted = false; 318 deleted = false;
318 319
319 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 320 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
320 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 321 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
321 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 322 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
322 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 323 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
323 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 324 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
324 325
325 attachments->setEnabled(m_gotBody); 326 attachments->setEnabled(m_gotBody);
326 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 327 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
327 328
328 readConfig(); 329 readConfig();
329 attachments->setSorting(-1); 330 attachments->setSorting(-1);
330} 331}
331 332
332void ViewMail::readConfig() 333void ViewMail::readConfig()
333{ 334{
334 335
335 setFont ( KOPrefs::instance()->mReadFont ); 336 setFont ( KOPrefs::instance()->mReadFont );
336 m_showHtml = KOPrefs::instance()->mViewAsHtml; 337 m_showHtml = KOPrefs::instance()->mViewAsHtml;
337 showHtml->setOn( m_showHtml ); 338 showHtml->setOn( m_showHtml );
338} 339}
339 340
340void ViewMail::setText() 341void ViewMail::setText()
341{ 342{
342 343
343 QString toString; 344 QString toString;
344 QString ccString; 345 QString ccString;
345 QString bccString; 346 QString bccString;
346 347
347 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 348 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
348 { 349 {
349 toString += (*it); 350 toString += (*it);
350 } 351 }
351 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 352 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
352 { 353 {
353 ccString += (*it); 354 ccString += (*it);
354 } 355 }
355 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 356 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
356 { 357 {
357 bccString += (*it); 358 bccString += (*it);
358 } 359 }
359 360
360 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 361 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
361 362
362 m_mailHtml = "<html><body>" 363 m_mailHtml = "<html><body>"
363 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 364 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
364 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 365 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
365 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 366 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
366 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 367 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
367 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 368 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
368 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 369 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
369 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 370 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
370 "</td></tr></table><font>"; 371 "</td></tr></table><font>";
371 372
372 if ( !m_showHtml ) 373 if ( !m_showHtml )
373 { 374 {
374 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 375 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
375 } 376 }
376 else 377 else
377 { 378 {
378 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 379 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
379 } 380 }
380 // remove later in favor of a real handling 381 // remove later in favor of a real handling
381 m_gotBody = true; 382 m_gotBody = true;
382} 383}
383 384
384 385
385ViewMail::~ViewMail() 386ViewMail::~ViewMail()
386{ 387{
387 m_recMail->Wrapper()->cleanMimeCache(); 388 m_recMail->Wrapper()->cleanMimeCache();
388 hide(); 389 hide();
389} 390}
390 391
391void ViewMail::hide() 392void ViewMail::hide()
392{ 393{
393 QWidget::hide(); 394 QWidget::hide();
394 395
395 if (_inLoop) 396 if (_inLoop)
396 { 397 {
397 _inLoop = false; 398 _inLoop = false;
398 qApp->exit_loop(); 399 qApp->exit_loop();
399 400
400 } 401 }
401 402
402} 403}
403 404
404void ViewMail::exec() 405void ViewMail::exec()
405{ 406{
406 show(); 407 show();
407 408
408 if (!_inLoop) 409 if (!_inLoop)
409 { 410 {
410 _inLoop = true; 411 _inLoop = true;
411 qApp->enter_loop(); 412 qApp->enter_loop();
412 } 413 }
413 414
414} 415}
415 416
416QString ViewMail::deHtml(const QString &string) 417QString ViewMail::deHtml(const QString &string)
417{ 418{
418 QString string_ = string; 419 QString string_ = string;
419 string_.replace(QRegExp("&"), "&amp;"); 420 string_.replace(QRegExp("&"), "&amp;");
420 string_.replace(QRegExp("<"), "&lt;"); 421 string_.replace(QRegExp("<"), "&lt;");
421 string_.replace(QRegExp(">"), "&gt;"); 422 string_.replace(QRegExp(">"), "&gt;");
422 string_.replace(QRegExp("\\n"), "<br>"); 423 string_.replace(QRegExp("\\n"), "<br>");
423 return string_; 424 return string_;
424} 425}
425 426
426void ViewMail::slotReply() 427void ViewMail::slotReply()
427{ 428{
428 if (!m_gotBody) 429 if (!m_gotBody)
429 { 430 {
430 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); 431 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok"));
431 return; 432 return;
432 } 433 }
433 434
434 QString rtext; 435 QString rtext;
435 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 436 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
436 .arg( m_mail[0] ) 437 .arg( m_mail[0] )
437 .arg( m_mail[3] ); 438 .arg( m_mail[3] );
438 439
439 QString text = m_mail[2]; 440 QString text = m_mail[2];
440 QStringList lines = QStringList::split(QRegExp("\\n"), text); 441 QStringList lines = QStringList::split(QRegExp("\\n"), text);
441 QStringList::Iterator it; 442 QStringList::Iterator it;
442 for (it = lines.begin(); it != lines.end(); it++) 443 for (it = lines.begin(); it != lines.end(); it++)
443 { 444 {
444 rtext += "> " + *it + "\n"; 445 rtext += "> " + *it + "\n";
445 } 446 }
446 rtext += "\n"; 447 rtext += "\n";
447 448
448 QString prefix; 449 QString prefix;
449 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 450 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
450 else prefix = "Re: "; // no i18n on purpose 451 else prefix = "Re: "; // no i18n on purpose
451 452
452 Settings *settings = new Settings(); 453 Settings *settings = new Settings();
453 ComposeMail composer( settings ,this, 0, true); 454 ComposeMail composer( settings ,this, 0, true);
454 if (m_recMail->Replyto().isEmpty()) { 455 if (m_recMail->Replyto().isEmpty()) {
455 composer.setTo( m_recMail->getFrom()); 456 composer.setTo( m_recMail->getFrom());
456 } else { 457 } else {
457 composer.setTo( m_recMail->Replyto()); 458 composer.setTo( m_recMail->Replyto());
458 } 459 }
459 composer.setSubject( prefix + m_mail[1] ); 460 composer.setSubject( prefix + m_mail[1] );
460 composer.setMessage( rtext ); 461 composer.setMessage( rtext );
461 composer.setInReplyTo(m_recMail->Msgid()); 462 composer.setInReplyTo(m_recMail->Msgid());
462 463
463 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 464 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
464 { 465 {
465 m_recMail->Wrapper()->answeredMail(m_recMail); 466 m_recMail->Wrapper()->answeredMail(m_recMail);
466 } 467 }
467} 468}
468 469
469void ViewMail::slotForward() 470void ViewMail::slotForward()
470{ 471{
471 if (!m_gotBody) 472 if (!m_gotBody)
472 { 473 {
473 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); 474 QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok"));
474 return; 475 return;
475 } 476 }
476 477
477 QString ftext; 478 QString ftext;
478 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 479 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
479 .arg( m_mail[0] ); 480 .arg( m_mail[0] );
480 if (!m_mail[3].isNull()) 481 if (!m_mail[3].isNull())
481 ftext += QString("Date: %1\n") 482 ftext += QString("Date: %1\n")
482 .arg( m_mail[3] ); 483 .arg( m_mail[3] );
483 if (!m_mail[0].isNull()) 484 if (!m_mail[0].isNull())
484 ftext += QString("From: %1\n") 485 ftext += QString("From: %1\n")
485 .arg( m_mail[0] ); 486 .arg( m_mail[0] );
486 if (!m_mail[1].isNull()) 487 if (!m_mail[1].isNull())
487 ftext += QString("Subject: %1\n") 488 ftext += QString("Subject: %1\n")
488 .arg( m_mail[1] ); 489 .arg( m_mail[1] );
489 490
490 ftext += QString("\n%1\n") 491 ftext += QString("\n%1\n")
491 .arg( m_mail[2]); 492 .arg( m_mail[2]);
492 493
493 ftext += QString("----- End forwarded message -----\n"); 494 ftext += QString("----- End forwarded message -----\n");
494 495
495 Settings *settings = new Settings(); 496 Settings *settings = new Settings();
496 ComposeMail composer( settings ,this, 0, true); 497 ComposeMail composer( settings ,this, 0, true);
497 composer.setSubject( "Fwd: " + m_mail[1] ); 498 composer.setSubject( "Fwd: " + m_mail[1] );
498 composer.setMessage( ftext ); 499 composer.setMessage( ftext );
499 if ( QDialog::Accepted == KApplication::execDialog( &composer )) 500 if ( QDialog::Accepted == KApplication::execDialog( &composer ))
500 { 501 {
501 } 502 }
502} 503}
503 504
504void ViewMail::slotDeleteMail( ) 505void ViewMail::slotDeleteMail( )
505{ 506{
506 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 ) 507 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 )
507 { 508 {
508 m_recMail->Wrapper()->deleteMail( m_recMail ); 509 m_recMail->Wrapper()->deleteMail( m_recMail );
509 hide(); 510 hide();
510 deleted = true; 511 deleted = true;
511 } 512 }
512} 513}
513 514
514MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 515MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f)
515 : KDialog(parent,name,modal) 516 : KDialog(parent,name,modal)
516{ 517{
517 QVBoxLayout*dlglayout = new QVBoxLayout(this); 518 QVBoxLayout*dlglayout = new QVBoxLayout(this);
518 dlglayout->setSpacing(2); 519 dlglayout->setSpacing(2);
519 dlglayout->setMargin(1); 520 dlglayout->setMargin(1);
520 //m_imageview = new Opie::MM::OImageScrollView(this); 521 //m_imageview = new Opie::MM::OImageScrollView(this);
521 //dlglayout->addWidget(m_imageview); 522 //dlglayout->addWidget(m_imageview);
522} 523}
523 524
524MailImageDlg::~MailImageDlg() 525MailImageDlg::~MailImageDlg()
525{ 526{
526} 527}
527 528
528void MailImageDlg::setName(const QString&fname) 529void MailImageDlg::setName(const QString&fname)
529{ 530{
530 qDebug("viewmail.cpp: MailImageDlg::setName Pending"); 531 qDebug("viewmail.cpp: MailImageDlg::setName Pending");
531 // m_imageview->setImage(fname); 532 // m_imageview->setImage(fname);
532} 533}
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 21da158..6e75442 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -1,174 +1,179 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3#INCLUDEPATH += $(QTDIR)/include . 3#INCLUDEPATH += $(QTDIR)/include .
4#DEPENDPATH += $(QTDIR)/include 4#DEPENDPATH += $(QTDIR)/include
5INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio 5INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio
6#LIBS += -lqtcompat 6#LIBS += -lqtcompat
7 7
8 TARGET = microkde 8 TARGET = microkde
9DESTDIR= ../bin 9DESTDIR= ../bin
10DEFINES += DESKTOP_VERSION KDE_QT_ONLY 10DEFINES += DESKTOP_VERSION KDE_QT_ONLY
11unix : { 11unix : {
12OBJECTS_DIR = obj/unix 12OBJECTS_DIR = obj/unix
13MOC_DIR = moc/unix 13MOC_DIR = moc/unix
14} 14}
15win32: { 15win32: {
16DEFINES += _WIN32_ 16DEFINES += _WIN32_
17OBJECTS_DIR = obj/win 17OBJECTS_DIR = obj/win
18MOC_DIR = moc/win 18MOC_DIR = moc/win
19} 19}
20include( ../variables.pri ) 20include( ../variables.pri )
21 21
22 22
23 23
24HEADERS = \ 24HEADERS = \
25qlayoutengine_p.h \ 25qlayoutengine_p.h \
26KDGanttMinimizeSplitter.h \ 26KDGanttMinimizeSplitter.h \
27 kapplication.h \ 27 kapplication.h \
28 kaudioplayer.h \ 28 kaudioplayer.h \
29 kcalendarsystem.h \ 29 kcalendarsystem.h \
30 kcalendarsystemgregorian.h \ 30 kcalendarsystemgregorian.h \
31 kcolorbutton.h \ 31 kcolorbutton.h \
32 kcolordialog.h \ 32 kcolordialog.h \
33 kcombobox.h \ 33 kcombobox.h \
34 kconfig.h \ 34 kconfig.h \
35 kdatetbl.h \ 35 kdatetbl.h \
36 kdebug.h \ 36 kdebug.h \
37 kdialog.h \ 37 kdialog.h \
38 kdialogbase.h \ 38 kdialogbase.h \
39 keditlistbox.h \ 39 keditlistbox.h \
40 kemailsettings.h \ 40 kemailsettings.h \
41 kfiledialog.h \ 41 kfiledialog.h \
42 kfontdialog.h \ 42 kfontdialog.h \
43 kglobal.h \ 43 kglobal.h \
44 kglobalsettings.h \ 44 kglobalsettings.h \
45 kiconloader.h \ 45 kiconloader.h \
46 klineedit.h \ 46 klineedit.h \
47 klineeditdlg.h \ 47 klineeditdlg.h \
48 kmessagebox.h \ 48 kmessagebox.h \
49 knotifyclient.h \ 49 knotifyclient.h \
50 kprinter.h \ 50 kprinter.h \
51 kprocess.h \ 51 kprocess.h \
52 krestrictedline.h \ 52 krestrictedline.h \
53 krun.h \ 53 krun.h \
54 ksimpleconfig.h \ 54 ksimpleconfig.h \
55 kstaticdeleter.h \ 55 kstaticdeleter.h \
56 ksystemtray.h \ 56 ksystemtray.h \
57 ktempfile.h \ 57 ktempfile.h \
58 ktextedit.h \ 58 ktextedit.h \
59 kunload.h \ 59 kunload.h \
60 kurl.h \ 60 kurl.h \
61oprocctrl.h \
62oprocess.h \
63osmartpointer.h \
61 kdeui/kguiitem.h \ 64 kdeui/kguiitem.h \
62 kdeui/kcmodule.h \ 65 kdeui/kcmodule.h \
63 kdeui/kbuttonbox.h \ 66 kdeui/kbuttonbox.h \
64 kdeui/klistbox.h \ 67 kdeui/klistbox.h \
65 kdeui/klistview.h \ 68 kdeui/klistview.h \
66 kdeui/kjanuswidget.h \ 69 kdeui/kjanuswidget.h \
67 kdeui/kseparator.h \ 70 kdeui/kseparator.h \
68 kdeui/knuminput.h \ 71 kdeui/knuminput.h \
69 kdeui/knumvalidator.h \ 72 kdeui/knumvalidator.h \
70 kdeui/ksqueezedtextlabel.h \ 73 kdeui/ksqueezedtextlabel.h \
71 kio/job.h \ 74 kio/job.h \
72 kio/kio/kdirwatch.h \ 75 kio/kio/kdirwatch.h \
73 kio/kio/kdirwatch_p.h \ 76 kio/kio/kdirwatch_p.h \
74 kio/kfile/kurlrequester.h \ 77 kio/kfile/kurlrequester.h \
75 kresources/resource.h \ 78 kresources/resource.h \
76 kresources/factory.h \ 79 kresources/factory.h \
77 kresources/managerimpl.h \ 80 kresources/managerimpl.h \
78 kresources/manager.h \ 81 kresources/manager.h \
79 kresources/selectdialog.h \ 82 kresources/selectdialog.h \
80 kresources/configpage.h \ 83 kresources/configpage.h \
81 kresources/configwidget.h \ 84 kresources/configwidget.h \
82 kresources/configdialog.h \ 85 kresources/configdialog.h \
83 kresources/kcmkresources.h \ 86 kresources/kcmkresources.h \
84 kdecore/kmdcodec.h \ 87 kdecore/kmdcodec.h \
85 kdecore/kconfigbase.h \ 88 kdecore/kconfigbase.h \
86 kdecore/klocale.h \ 89 kdecore/klocale.h \
87 kdecore/kcatalogue.h \ 90 kdecore/kcatalogue.h \
88 kdecore/ksharedptr.h \ 91 kdecore/ksharedptr.h \
89 kdecore/kshell.h \ 92 kdecore/kshell.h \
90 kdecore/kstandarddirs.h \ 93 kdecore/kstandarddirs.h \
91 kdecore/kstringhandler.h \ 94 kdecore/kstringhandler.h \
92 kdecore/kshortcut.h \ 95 kdecore/kshortcut.h \
93 kutils/kcmultidialog.h \ 96 kutils/kcmultidialog.h \
94 kdeui/kxmlguiclient.h \ 97 kdeui/kxmlguiclient.h \
95 kdeui/kstdaction.h \ 98 kdeui/kstdaction.h \
96 kdeui/kmainwindow.h \ 99 kdeui/kmainwindow.h \
97 kdeui/ktoolbar.h \ 100 kdeui/ktoolbar.h \
98 kdeui/ktoolbarbutton.h \ 101 kdeui/ktoolbarbutton.h \
99 kdeui/ktoolbarhandler.h \ 102 kdeui/ktoolbarhandler.h \
100 kdeui/kaction.h \ 103 kdeui/kaction.h \
101 kdeui/kactionclasses.h \ 104 kdeui/kactionclasses.h \
102 kdeui/kactioncollection.h \ 105 kdeui/kactioncollection.h \
103 kdecore/kprefs.h \ 106 kdecore/kprefs.h \
104 kdecore/klibloader.h \ 107 kdecore/klibloader.h \
105 kidmanager.h 108 kidmanager.h
106 109
107 110
108# kdecore/klibloader.h \ 111# kdecore/klibloader.h \
109 112
110 113
111SOURCES = \ 114SOURCES = \
112KDGanttMinimizeSplitter.cpp \ 115KDGanttMinimizeSplitter.cpp \
113 kapplication.cpp \ 116 kapplication.cpp \
114 kcalendarsystem.cpp \ 117 kcalendarsystem.cpp \
115 kcalendarsystemgregorian.cpp \ 118 kcalendarsystemgregorian.cpp \
116 kcolorbutton.cpp \ 119 kcolorbutton.cpp \
117 kcolordialog.cpp \ 120 kcolordialog.cpp \
118 kconfig.cpp \ 121 kconfig.cpp \
119 kdatetbl.cpp \ 122 kdatetbl.cpp \
120 kdialog.cpp \ 123 kdialog.cpp \
121 kdialogbase.cpp \ 124 kdialogbase.cpp \
122 keditlistbox.cpp \ 125 keditlistbox.cpp \
123 kemailsettings.cpp \ 126 kemailsettings.cpp \
124 kfontdialog.cpp \ 127 kfontdialog.cpp \
125 kfiledialog.cpp \ 128 kfiledialog.cpp \
126 kglobal.cpp \ 129 kglobal.cpp \
127 kglobalsettings.cpp \ 130 kglobalsettings.cpp \
128 kiconloader.cpp \ 131 kiconloader.cpp \
129 kmessagebox.cpp \ 132 kmessagebox.cpp \
130 ktextedit.cpp \ 133 ktextedit.cpp \
131 kprocess.cpp \ 134 kprocess.cpp \
132 krun.cpp \ 135 krun.cpp \
133 ksystemtray.cpp \ 136 ksystemtray.cpp \
134 ktempfile.cpp \ 137 ktempfile.cpp \
135 kurl.cpp \ 138 kurl.cpp \
136 kdecore/kcatalogue.cpp \ 139 kdecore/kcatalogue.cpp \
137 kdecore/klocale.cpp \ 140 kdecore/klocale.cpp \
138 kdecore/kmdcodec.cpp \ 141 kdecore/kmdcodec.cpp \
139 kdecore/kshell.cpp \ 142 kdecore/kshell.cpp \
140 kdecore/kstandarddirs.cpp \ 143 kdecore/kstandarddirs.cpp \
141 kdecore/kstringhandler.cpp \ 144 kdecore/kstringhandler.cpp \
142 kdeui/kbuttonbox.cpp \ 145 kdeui/kbuttonbox.cpp \
143 kdeui/kcmodule.cpp \ 146 kdeui/kcmodule.cpp \
144 kdeui/kguiitem.cpp \ 147 kdeui/kguiitem.cpp \
145 kdeui/kjanuswidget.cpp \ 148 kdeui/kjanuswidget.cpp \
146 kdeui/klistbox.cpp \ 149 kdeui/klistbox.cpp \
147 kdeui/klistview.cpp \ 150 kdeui/klistview.cpp \
148 kdeui/knuminput.cpp \ 151 kdeui/knuminput.cpp \
149 kdeui/knumvalidator.cpp \ 152 kdeui/knumvalidator.cpp \
150 kdeui/kseparator.cpp \ 153 kdeui/kseparator.cpp \
151 kdeui/ksqueezedtextlabel.cpp \ 154 kdeui/ksqueezedtextlabel.cpp \
152 kio/kio/kdirwatch.cpp \ 155 kio/kio/kdirwatch.cpp \
153 kio/kfile/kurlrequester.cpp \ 156 kio/kfile/kurlrequester.cpp \
154 kresources/configpage.cpp \ 157 kresources/configpage.cpp \
155 kresources/configdialog.cpp \ 158 kresources/configdialog.cpp \
156 kresources/configwidget.cpp \ 159 kresources/configwidget.cpp \
157 kresources/factory.cpp \ 160 kresources/factory.cpp \
158 kresources/kcmkresources.cpp \ 161 kresources/kcmkresources.cpp \
159 kresources/managerimpl.cpp \ 162 kresources/managerimpl.cpp \
160 kresources/resource.cpp \ 163 kresources/resource.cpp \
161 kresources/selectdialog.cpp \ 164 kresources/selectdialog.cpp \
162 kutils/kcmultidialog.cpp \ 165 kutils/kcmultidialog.cpp \
163 kdeui/kaction.cpp \ 166 kdeui/kaction.cpp \
164 kdeui/kactionclasses.cpp \ 167 kdeui/kactionclasses.cpp \
165 kdeui/kactioncollection.cpp \ 168 kdeui/kactioncollection.cpp \
166 kdeui/kmainwindow.cpp \ 169 kdeui/kmainwindow.cpp \
167 kdeui/ktoolbar.cpp \ 170 kdeui/ktoolbar.cpp \
168 kdeui/ktoolbarbutton.cpp \ 171 kdeui/ktoolbarbutton.cpp \
169 kdeui/ktoolbarhandler.cpp \ 172 kdeui/ktoolbarhandler.cpp \
170 kdeui/kstdaction.cpp \ 173 kdeui/kstdaction.cpp \
171 kdeui/kxmlguiclient.cpp \ 174 kdeui/kxmlguiclient.cpp \
172 kdecore/kprefs.cpp \ 175 kdecore/kprefs.cpp \
173 kdecore/klibloader.cpp \ 176 kdecore/klibloader.cpp \
174 kidmanager.cpp 177 kidmanager.cpp \
178oprocctrl.cpp \
179oprocess.cpp
diff --git a/microkde/oprocess.cpp b/microkde/oprocess.cpp
index 95e3e4b..a935792 100644
--- a/microkde/oprocess.cpp
+++ b/microkde/oprocess.cpp
@@ -1,808 +1,809 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org>
4 and The Opie Team <opie-devel@handhelds.org> 4 and The Opie Team <opie-devel@handhelds.org>
5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) 5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
6 .=l. 6 .=l.
7          .>+-= 7          .>+-=
8_;:,     .>    :=|. This program is free software; you can 8_;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12- .   .-<_>     .<> Foundation; either version 2 of the License, 12- .   .-<_>     .<> Foundation; either version 2 of the License,
13    ._= =}       : or (at your option) any later version. 13    ._= =}       : or (at your option) any later version.
14   .%`+i>       _;_. 14   .%`+i>       _;_.
15   .i_,=:_.      -<s. This program is distributed in the hope that 15   .i_,=:_.      -<s. This program is distributed in the hope that
16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17   : ..    .:,     . . . without even the implied warranty of 17   : ..    .:,     . . . without even the implied warranty of
18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22:     =  ...= . :.=- 22:     =  ...= . :.=-
23-.   .:....=;==+<; You should have received a copy of the GNU 23-.   .:....=;==+<; You should have received a copy of the GNU
24 -_. . .   )=.  = Library General Public License along with 24 -_. . .   )=.  = Library General Public License along with
25   --        :-=` this library; see the file COPYING.LIB. 25   --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "oprocctrl.h" 31#include "oprocctrl.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <oprocess.h> 34#include <oprocess.h>
35 35
36/* QT */ 36/* QT */
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qregexp.h>
41#include <qsocketnotifier.h> 42#include <qsocketnotifier.h>
42#include <qtextstream.h> 43#include <qtextstream.h>
43 44
44/* STD */ 45/* STD */
45#include <errno.h> 46#include <errno.h>
46#include <fcntl.h> 47#include <fcntl.h>
47#include <pwd.h> 48#include <pwd.h>
48#include <stdlib.h> 49#include <stdlib.h>
49#include <signal.h> 50#include <signal.h>
50#include <stdio.h> 51#include <stdio.h>
51#include <string.h> 52#include <string.h>
52#include <sys/time.h> 53#include <sys/time.h>
53#include <sys/types.h> 54#include <sys/types.h>
54#include <sys/stat.h> 55#include <sys/stat.h>
55#include <sys/socket.h> 56#include <sys/socket.h>
56#include <unistd.h> 57#include <unistd.h>
57#ifdef HAVE_SYS_SELECT_H 58#ifdef HAVE_SYS_SELECT_H
58#include <sys/select.h> 59#include <sys/select.h>
59#endif 60#endif
60#ifdef HAVE_INITGROUPS 61#ifdef HAVE_INITGROUPS
61#include <grp.h> 62#include <grp.h>
62#endif 63#endif
63 64
64using namespace Opie::Core::Internal; 65using namespace Opie::Core::Internal;
65 66
66namespace Opie { 67namespace Opie {
67namespace Core { 68namespace Core {
68namespace Internal { 69namespace Internal {
69class OProcessPrivate 70class OProcessPrivate
70{ 71{
71public: 72public:
72 OProcessPrivate() : useShell( false ) 73 OProcessPrivate() : useShell( false )
73 { } 74 { }
74 75
75 bool useShell; 76 bool useShell;
76 QMap<QString, QString> env; 77 QMap<QString, QString> env;
77 QString wd; 78 QString wd;
78 QCString shell; 79 QCString shell;
79}; 80};
80} 81}
81 82
82OProcess::OProcess( QObject *parent, const char *name ) 83OProcess::OProcess( QObject *parent, const char *name )
83 : QObject( parent, name ) 84 : QObject( parent, name )
84{ 85{
85 init ( ); 86 init ( );
86} 87}
87 88
88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 89OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
89 : QObject( parent, name ) 90 : QObject( parent, name )
90{ 91{
91 init ( ); 92 init ( );
92 *this << arg0; 93 *this << arg0;
93} 94}
94 95
95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 96OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
96 : QObject( parent, name ) 97 : QObject( parent, name )
97{ 98{
98 init ( ); 99 init ( );
99 *this << args; 100 *this << args;
100} 101}
101 102
102void OProcess::init ( ) 103void OProcess::init ( )
103{ 104{
104 run_mode = NotifyOnExit; 105 run_mode = NotifyOnExit;
105 runs = false; 106 runs = false;
106 pid_ = 0; 107 pid_ = 0;
107 status = 0; 108 status = 0;
108 keepPrivs = false; 109 keepPrivs = false;
109 innot = 0; 110 innot = 0;
110 outnot = 0; 111 outnot = 0;
111 errnot = 0; 112 errnot = 0;
112 communication = NoCommunication; 113 communication = NoCommunication;
113 input_data = 0; 114 input_data = 0;
114 input_sent = 0; 115 input_sent = 0;
115 input_total = 0; 116 input_total = 0;
116 d = 0; 117 d = 0;
117 118
118 if ( 0 == OProcessController::theOProcessController ) 119 if ( 0 == OProcessController::theOProcessController )
119 { 120 {
120 ( void ) new OProcessController(); 121 ( void ) new OProcessController();
121 CHECK_PTR( OProcessController::theOProcessController ); 122 CHECK_PTR( OProcessController::theOProcessController );
122 } 123 }
123 124
124 OProcessController::theOProcessController->addOProcess( this ); 125 OProcessController::theOProcessController->addOProcess( this );
125 out[ 0 ] = out[ 1 ] = -1; 126 out[ 0 ] = out[ 1 ] = -1;
126 in[ 0 ] = in[ 1 ] = -1; 127 in[ 0 ] = in[ 1 ] = -1;
127 err[ 0 ] = err[ 1 ] = -1; 128 err[ 0 ] = err[ 1 ] = -1;
128} 129}
129 130
130void OProcess::setEnvironment( const QString &name, const QString &value ) 131void OProcess::setEnvironment( const QString &name, const QString &value )
131{ 132{
132 if ( !d ) 133 if ( !d )
133 d = new OProcessPrivate; 134 d = new OProcessPrivate;
134 d->env.insert( name, value ); 135 d->env.insert( name, value );
135} 136}
136 137
137void OProcess::setWorkingDirectory( const QString &dir ) 138void OProcess::setWorkingDirectory( const QString &dir )
138{ 139{
139 if ( !d ) 140 if ( !d )
140 d = new OProcessPrivate; 141 d = new OProcessPrivate;
141 d->wd = dir; 142 d->wd = dir;
142} 143}
143 144
144void OProcess::setupEnvironment() 145void OProcess::setupEnvironment()
145{ 146{
146 if ( d ) 147 if ( d )
147 { 148 {
148 QMap<QString, QString>::Iterator it; 149 QMap<QString, QString>::Iterator it;
149 for ( it = d->env.begin(); it != d->env.end(); ++it ) 150 for ( it = d->env.begin(); it != d->env.end(); ++it )
150 setenv( QFile::encodeName( it.key() ).data(), 151 setenv( QFile::encodeName( it.key() ).data(),
151 QFile::encodeName( it.data() ).data(), 1 ); 152 QFile::encodeName( it.data() ).data(), 1 );
152 if ( !d->wd.isEmpty() ) 153 if ( !d->wd.isEmpty() )
153 chdir( QFile::encodeName( d->wd ).data() ); 154 chdir( QFile::encodeName( d->wd ).data() );
154 } 155 }
155} 156}
156 157
157void OProcess::setRunPrivileged( bool keepPrivileges ) 158void OProcess::setRunPrivileged( bool keepPrivileges )
158{ 159{
159 keepPrivs = keepPrivileges; 160 keepPrivs = keepPrivileges;
160} 161}
161 162
162bool OProcess::runPrivileged() const 163bool OProcess::runPrivileged() const
163{ 164{
164 return keepPrivs; 165 return keepPrivs;
165} 166}
166 167
167OProcess::~OProcess() 168OProcess::~OProcess()
168{ 169{
169 // destroying the OProcess instance sends a SIGKILL to the 170 // destroying the OProcess instance sends a SIGKILL to the
170 // child process (if it is running) after removing it from the 171 // child process (if it is running) after removing it from the
171 // list of valid processes (if the process is not started as 172 // list of valid processes (if the process is not started as
172 // "DontCare") 173 // "DontCare")
173 174
174 OProcessController::theOProcessController->removeOProcess( this ); 175 OProcessController::theOProcessController->removeOProcess( this );
175 // this must happen before we kill the child 176 // this must happen before we kill the child
176 // TODO: block the signal while removing the current process from the process list 177 // TODO: block the signal while removing the current process from the process list
177 178
178 if ( runs && ( run_mode != DontCare ) ) 179 if ( runs && ( run_mode != DontCare ) )
179 kill( SIGKILL ); 180 kill( SIGKILL );
180 181
181 // Clean up open fd's and socket notifiers. 182 // Clean up open fd's and socket notifiers.
182 closeStdin(); 183 closeStdin();
183 closeStdout(); 184 closeStdout();
184 closeStderr(); 185 closeStderr();
185 186
186 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess 187 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess
187 delete d; 188 delete d;
188} 189}
189 190
190void OProcess::detach() 191void OProcess::detach()
191{ 192{
192 OProcessController::theOProcessController->removeOProcess( this ); 193 OProcessController::theOProcessController->removeOProcess( this );
193 194
194 runs = false; 195 runs = false;
195 pid_ = 0; 196 pid_ = 0;
196 197
197 // Clean up open fd's and socket notifiers. 198 // Clean up open fd's and socket notifiers.
198 closeStdin(); 199 closeStdin();
199 closeStdout(); 200 closeStdout();
200 closeStderr(); 201 closeStderr();
201} 202}
202 203
203bool OProcess::setExecutable( const QString& proc ) 204bool OProcess::setExecutable( const QString& proc )
204{ 205{
205 if ( runs ) 206 if ( runs )
206 return false; 207 return false;
207 208
208 if ( proc.isEmpty() ) 209 if ( proc.isEmpty() )
209 return false; 210 return false;
210 211
211 if ( !arguments.isEmpty() ) 212 if ( !arguments.isEmpty() )
212 arguments.remove( arguments.begin() ); 213 arguments.remove( arguments.begin() );
213 arguments.prepend( QFile::encodeName( proc ) ); 214 arguments.prepend( QFile::encodeName( proc ) );
214 215
215 return true; 216 return true;
216} 217}
217 218
218OProcess &OProcess::operator<<( const QStringList& args ) 219OProcess &OProcess::operator<<( const QStringList& args )
219{ 220{
220 QStringList::ConstIterator it = args.begin(); 221 QStringList::ConstIterator it = args.begin();
221 for ( ; it != args.end() ; ++it ) 222 for ( ; it != args.end() ; ++it )
222 arguments.append( QFile::encodeName( *it ) ); 223 arguments.append( QFile::encodeName( *it ) );
223 return *this; 224 return *this;
224} 225}
225 226
226OProcess &OProcess::operator<<( const QCString& arg ) 227OProcess &OProcess::operator<<( const QCString& arg )
227{ 228{
228 return operator<< ( arg.data() ); 229 return operator<< ( arg.data() );
229} 230}
230 231
231OProcess &OProcess::operator<<( const char* arg ) 232OProcess &OProcess::operator<<( const char* arg )
232{ 233{
233 arguments.append( arg ); 234 arguments.append( arg );
234 return *this; 235 return *this;
235} 236}
236 237
237OProcess &OProcess::operator<<( const QString& arg ) 238OProcess &OProcess::operator<<( const QString& arg )
238{ 239{
239 arguments.append( QFile::encodeName( arg ) ); 240 arguments.append( QFile::encodeName( arg ) );
240 return *this; 241 return *this;
241} 242}
242 243
243void OProcess::clearArguments() 244void OProcess::clearArguments()
244{ 245{
245 arguments.clear(); 246 arguments.clear();
246} 247}
247 248
248bool OProcess::start( RunMode runmode, Communication comm ) 249bool OProcess::start( RunMode runmode, Communication comm )
249{ 250{
250 uint i; 251 uint i;
251 uint n = arguments.count(); 252 uint n = arguments.count();
252 char **arglist; 253 char **arglist;
253 254
254 if ( runs || ( 0 == n ) ) 255 if ( runs || ( 0 == n ) )
255 { 256 {
256 return false; // cannot start a process that is already running 257 return false; // cannot start a process that is already running
257 // or if no executable has been assigned 258 // or if no executable has been assigned
258 } 259 }
259 run_mode = runmode; 260 run_mode = runmode;
260 status = 0; 261 status = 0;
261 262
262 QCString shellCmd; 263 QCString shellCmd;
263 if ( d && d->useShell ) 264 if ( d && d->useShell )
264 { 265 {
265 if ( d->shell.isEmpty() ) 266 if ( d->shell.isEmpty() )
266 { 267 {
267 qWarning( "Could not find a valid shell" ); 268 qWarning( "Could not find a valid shell" );
268 return false; 269 return false;
269 } 270 }
270 271
271 arglist = static_cast<char **>( malloc( ( 4 ) * sizeof( char * ) ) ); 272 arglist = static_cast<char **>( malloc( ( 4 ) * sizeof( char * ) ) );
272 for ( i = 0; i < n; i++ ) 273 for ( i = 0; i < n; i++ )
273 { 274 {
274 shellCmd += arguments[ i ]; 275 shellCmd += arguments[ i ];
275 shellCmd += " "; // CC: to separate the arguments 276 shellCmd += " "; // CC: to separate the arguments
276 } 277 }
277 278
278 arglist[ 0 ] = d->shell.data(); 279 arglist[ 0 ] = d->shell.data();
279 arglist[ 1 ] = ( char * ) "-c"; 280 arglist[ 1 ] = ( char * ) "-c";
280 arglist[ 2 ] = shellCmd.data(); 281 arglist[ 2 ] = shellCmd.data();
281 arglist[ 3 ] = 0; 282 arglist[ 3 ] = 0;
282 } 283 }
283 else 284 else
284 { 285 {
285 arglist = static_cast<char **>( malloc( ( n + 1 ) * sizeof( char * ) ) ); 286 arglist = static_cast<char **>( malloc( ( n + 1 ) * sizeof( char * ) ) );
286 for ( i = 0; i < n; i++ ) 287 for ( i = 0; i < n; i++ )
287 arglist[ i ] = arguments[ i ].data(); 288 arglist[ i ] = arguments[ i ].data();
288 arglist[ n ] = 0; 289 arglist[ n ] = 0;
289 } 290 }
290 291
291 if ( !setupCommunication( comm ) ) 292 if ( !setupCommunication( comm ) )
292 qWarning( "Could not setup Communication!" ); 293 qWarning( "Could not setup Communication!" );
293 294
294 // We do this in the parent because if we do it in the child process 295 // We do this in the parent because if we do it in the child process
295 // gdb gets confused when the application runs from gdb. 296 // gdb gets confused when the application runs from gdb.
296 uid_t uid = getuid(); 297 uid_t uid = getuid();
297 gid_t gid = getgid(); 298 gid_t gid = getgid();
298#ifdef HAVE_INITGROUPS 299#ifdef HAVE_INITGROUPS
299 300
300 struct passwd *pw = getpwuid( uid ); 301 struct passwd *pw = getpwuid( uid );
301#endif 302#endif
302 303
303 int fd[ 2 ]; 304 int fd[ 2 ];
304 if ( 0 > pipe( fd ) ) 305 if ( 0 > pipe( fd ) )
305 { 306 {
306 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue 307 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue
307 } 308 }
308 309
309 runs = true; 310 runs = true;
310 311
311 QApplication::flushX(); 312 QApplication::flushX();
312 313
313 // WABA: Note that we use fork() and not vfork() because 314 // WABA: Note that we use fork() and not vfork() because
314 // vfork() has unclear semantics and is not standardized. 315 // vfork() has unclear semantics and is not standardized.
315 pid_ = fork(); 316 pid_ = fork();
316 317
317 if ( 0 == pid_ ) 318 if ( 0 == pid_ )
318 { 319 {
319 if ( fd[ 0 ] ) 320 if ( fd[ 0 ] )
320 close( fd[ 0 ] ); 321 close( fd[ 0 ] );
321 if ( !runPrivileged() ) 322 if ( !runPrivileged() )
322 { 323 {
323 setgid( gid ); 324 setgid( gid );
324#if defined( HAVE_INITGROUPS) 325#if defined( HAVE_INITGROUPS)
325 326
326 if ( pw ) 327 if ( pw )
327 initgroups( pw->pw_name, pw->pw_gid ); 328 initgroups( pw->pw_name, pw->pw_gid );
328#endif 329#endif
329 330
330 setuid( uid ); 331 setuid( uid );
331 } 332 }
332 // The child process 333 // The child process
333 if ( !commSetupDoneC() ) 334 if ( !commSetupDoneC() )
334 qWarning( "Could not finish comm setup in child!" ); 335 qWarning( "Could not finish comm setup in child!" );
335 336
336 setupEnvironment(); 337 setupEnvironment();
337 338
338 // Matthias 339 // Matthias
339 if ( run_mode == DontCare ) 340 if ( run_mode == DontCare )
340 setpgid( 0, 0 ); 341 setpgid( 0, 0 );
341 // restore default SIGPIPE handler (Harri) 342 // restore default SIGPIPE handler (Harri)
342 struct sigaction act; 343 struct sigaction act;
343 sigemptyset( &( act.sa_mask ) ); 344 sigemptyset( &( act.sa_mask ) );
344 sigaddset( &( act.sa_mask ), SIGPIPE ); 345 sigaddset( &( act.sa_mask ), SIGPIPE );
345 act.sa_handler = SIG_DFL; 346 act.sa_handler = SIG_DFL;
346 act.sa_flags = 0; 347 act.sa_flags = 0;
347 sigaction( SIGPIPE, &act, 0L ); 348 sigaction( SIGPIPE, &act, 0L );
348 349
349 // We set the close on exec flag. 350 // We set the close on exec flag.
350 // Closing of fd[1] indicates that the execvp succeeded! 351 // Closing of fd[1] indicates that the execvp succeeded!
351 if ( fd[ 1 ] ) 352 if ( fd[ 1 ] )
352 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC ); 353 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC );
353 execvp( arglist[ 0 ], arglist ); 354 execvp( arglist[ 0 ], arglist );
354 char resultByte = 1; 355 char resultByte = 1;
355 if ( fd[ 1 ] ) 356 if ( fd[ 1 ] )
356 write( fd[ 1 ], &resultByte, 1 ); 357 write( fd[ 1 ], &resultByte, 1 );
357 _exit( -1 ); 358 _exit( -1 );
358 } 359 }
359 else if ( -1 == pid_ ) 360 else if ( -1 == pid_ )
360 { 361 {
361 // forking failed 362 // forking failed
362 363
363 runs = false; 364 runs = false;
364 free( arglist ); 365 free( arglist );
365 return false; 366 return false;
366 } 367 }
367 else 368 else
368 { 369 {
369 if ( fd[ 1 ] ) 370 if ( fd[ 1 ] )
370 close( fd[ 1 ] ); 371 close( fd[ 1 ] );
371 // the parent continues here 372 // the parent continues here
372 373
373 // Discard any data for stdin that might still be there 374 // Discard any data for stdin that might still be there
374 input_data = 0; 375 input_data = 0;
375 376
376 // Check whether client could be started. 377 // Check whether client could be started.
377 if ( fd[ 0 ] ) 378 if ( fd[ 0 ] )
378 for ( ;; ) 379 for ( ;; )
379 { 380 {
380 char resultByte; 381 char resultByte;
381 int n = ::read( fd[ 0 ], &resultByte, 1 ); 382 int n = ::read( fd[ 0 ], &resultByte, 1 );
382 if ( n == 1 ) 383 if ( n == 1 )
383 { 384 {
384 // Error 385 // Error
385 runs = false; 386 runs = false;
386 close( fd[ 0 ] ); 387 close( fd[ 0 ] );
387 free( arglist ); 388 free( arglist );
388 pid_ = 0; 389 pid_ = 0;
389 return false; 390 return false;
390 } 391 }
391 if ( n == -1 ) 392 if ( n == -1 )
392 { 393 {
393 if ( ( errno == ECHILD ) || ( errno == EINTR ) ) 394 if ( ( errno == ECHILD ) || ( errno == EINTR ) )
394 continue; // Ignore 395 continue; // Ignore
395 } 396 }
396 break; // success 397 break; // success
397 } 398 }
398 if ( fd[ 0 ] ) 399 if ( fd[ 0 ] )
399 close( fd[ 0 ] ); 400 close( fd[ 0 ] );
400 401
401 if ( !commSetupDoneP() ) // finish communication socket setup for the parent 402 if ( !commSetupDoneP() ) // finish communication socket setup for the parent
402 qWarning( "Could not finish comm setup in parent!" ); 403 qWarning( "Could not finish comm setup in parent!" );
403 404
404 if ( run_mode == Block ) 405 if ( run_mode == Block )
405 { 406 {
406 commClose(); 407 commClose();
407 408
408 // The SIGCHLD handler of the process controller will catch 409 // The SIGCHLD handler of the process controller will catch
409 // the exit and set the status 410 // the exit and set the status
410 while ( runs ) 411 while ( runs )
411 { 412 {
412 OProcessController::theOProcessController-> 413 OProcessController::theOProcessController->
413 slotDoHousekeeping( 0 ); 414 slotDoHousekeeping( 0 );
414 } 415 }
415 runs = FALSE; 416 runs = FALSE;
416 emit processExited( this ); 417 emit processExited( this );
417 } 418 }
418 } 419 }
419 free( arglist ); 420 free( arglist );
420 return true; 421 return true;
421} 422}
422 423
423 424
424 425
425bool OProcess::kill( int signo ) 426bool OProcess::kill( int signo )
426{ 427{
427 bool rv = false; 428 bool rv = false;
428 429
429 if ( 0 != pid_ ) 430 if ( 0 != pid_ )
430 rv = ( -1 != ::kill( pid_, signo ) ); 431 rv = ( -1 != ::kill( pid_, signo ) );
431 // probably store errno somewhere... 432 // probably store errno somewhere...
432 return rv; 433 return rv;
433} 434}
434 435
435bool OProcess::isRunning() const 436bool OProcess::isRunning() const
436{ 437{
437 return runs; 438 return runs;
438} 439}
439 440
440pid_t OProcess::pid() const 441pid_t OProcess::pid() const
441{ 442{
442 return pid_; 443 return pid_;
443} 444}
444 445
445bool OProcess::normalExit() const 446bool OProcess::normalExit() const
446{ 447{
447 int _status = status; 448 int _status = status;
448 return ( pid_ != 0 ) && ( !runs ) && ( WIFEXITED( ( _status ) ) ); 449 return ( pid_ != 0 ) && ( !runs ) && ( WIFEXITED( ( _status ) ) );
449} 450}
450 451
451int OProcess::exitStatus() const 452int OProcess::exitStatus() const
452{ 453{
453 int _status = status; 454 int _status = status;
454 return WEXITSTATUS( ( _status ) ); 455 return WEXITSTATUS( ( _status ) );
455} 456}
456 457
457bool OProcess::writeStdin( const char *buffer, int buflen ) 458bool OProcess::writeStdin( const char *buffer, int buflen )
458{ 459{
459 bool rv; 460 bool rv;
460 461
461 // if there is still data pending, writing new data 462 // if there is still data pending, writing new data
462 // to stdout is not allowed (since it could also confuse 463 // to stdout is not allowed (since it could also confuse
463 // kprocess... 464 // kprocess...
464 if ( 0 != input_data ) 465 if ( 0 != input_data )
465 return false; 466 return false;
466 467
467 if ( runs && ( communication & Stdin ) ) 468 if ( runs && ( communication & Stdin ) )
468 { 469 {
469 input_data = buffer; 470 input_data = buffer;
470 input_sent = 0; 471 input_sent = 0;
471 input_total = buflen; 472 input_total = buflen;
472 slotSendData( 0 ); 473 slotSendData( 0 );
473 innot->setEnabled( true ); 474 innot->setEnabled( true );
474 rv = true; 475 rv = true;
475 } 476 }
476 else 477 else
477 rv = false; 478 rv = false;
478 return rv; 479 return rv;
479} 480}
480 481
481void OProcess::flushStdin ( ) 482void OProcess::flushStdin ( )
482{ 483{
483 if ( !input_data || ( input_sent == input_total ) ) 484 if ( !input_data || ( input_sent == input_total ) )
484 return ; 485 return ;
485 486
486 int d1, d2; 487 int d1, d2;
487 488
488 do 489 do
489 { 490 {
490 d1 = input_total - input_sent; 491 d1 = input_total - input_sent;
491 slotSendData ( 0 ); 492 slotSendData ( 0 );
492 d2 = input_total - input_sent; 493 d2 = input_total - input_sent;
493 } 494 }
494 while ( d2 <= d1 ); 495 while ( d2 <= d1 );
495} 496}
496 497
497void OProcess::suspend() 498void OProcess::suspend()
498{ 499{
499 if ( ( communication & Stdout ) && outnot ) 500 if ( ( communication & Stdout ) && outnot )
500 outnot->setEnabled( false ); 501 outnot->setEnabled( false );
501} 502}
502 503
503void OProcess::resume() 504void OProcess::resume()
504{ 505{
505 if ( ( communication & Stdout ) && outnot ) 506 if ( ( communication & Stdout ) && outnot )
506 outnot->setEnabled( true ); 507 outnot->setEnabled( true );
507} 508}
508 509
509bool OProcess::closeStdin() 510bool OProcess::closeStdin()
510{ 511{
511 bool rv; 512 bool rv;
512 513
513 if ( communication & Stdin ) 514 if ( communication & Stdin )
514 { 515 {
515 communication = ( Communication ) ( communication & ~Stdin ); 516 communication = ( Communication ) ( communication & ~Stdin );
516 delete innot; 517 delete innot;
517 innot = 0; 518 innot = 0;
518 close( in[ 1 ] ); 519 close( in[ 1 ] );
519 rv = true; 520 rv = true;
520 } 521 }
521 else 522 else
522 rv = false; 523 rv = false;
523 return rv; 524 return rv;
524} 525}
525 526
526bool OProcess::closeStdout() 527bool OProcess::closeStdout()
527{ 528{
528 bool rv; 529 bool rv;
529 530
530 if ( communication & Stdout ) 531 if ( communication & Stdout )
531 { 532 {
532 communication = ( Communication ) ( communication & ~Stdout ); 533 communication = ( Communication ) ( communication & ~Stdout );
533 delete outnot; 534 delete outnot;
534 outnot = 0; 535 outnot = 0;
535 close( out[ 0 ] ); 536 close( out[ 0 ] );
536 rv = true; 537 rv = true;
537 } 538 }
538 else 539 else
539 rv = false; 540 rv = false;
540 return rv; 541 return rv;
541} 542}
542 543
543bool OProcess::closeStderr() 544bool OProcess::closeStderr()
544{ 545{
545 bool rv; 546 bool rv;
546 547
547 if ( communication & Stderr ) 548 if ( communication & Stderr )
548 { 549 {
549 communication = static_cast<Communication>( communication & ~Stderr ); 550 communication = static_cast<Communication>( communication & ~Stderr );
550 delete errnot; 551 delete errnot;
551 errnot = 0; 552 errnot = 0;
552 close( err[ 0 ] ); 553 close( err[ 0 ] );
553 rv = true; 554 rv = true;
554 } 555 }
555 else 556 else
556 rv = false; 557 rv = false;
557 return rv; 558 return rv;
558} 559}
559 560
560void OProcess::slotChildOutput( int fdno ) 561void OProcess::slotChildOutput( int fdno )
561{ 562{
562 if ( !childOutput( fdno ) ) 563 if ( !childOutput( fdno ) )
563 closeStdout(); 564 closeStdout();
564} 565}
565 566
566void OProcess::slotChildError( int fdno ) 567void OProcess::slotChildError( int fdno )
567{ 568{
568 if ( !childError( fdno ) ) 569 if ( !childError( fdno ) )
569 closeStderr(); 570 closeStderr();
570} 571}
571 572
572void OProcess::slotSendData( int ) 573void OProcess::slotSendData( int )
573{ 574{
574 if ( input_sent == input_total ) 575 if ( input_sent == input_total )
575 { 576 {
576 innot->setEnabled( false ); 577 innot->setEnabled( false );
577 input_data = 0; 578 input_data = 0;
578 emit wroteStdin( this ); 579 emit wroteStdin( this );
579 } 580 }
580 else 581 else
581 input_sent += ::write( in[ 1 ], input_data + input_sent, input_total - input_sent ); 582 input_sent += ::write( in[ 1 ], input_data + input_sent, input_total - input_sent );
582} 583}
583 584
584void OProcess::processHasExited( int state ) 585void OProcess::processHasExited( int state )
585{ 586{
586 if ( runs ) 587 if ( runs )
587 { 588 {
588 runs = false; 589 runs = false;
589 status = state; 590 status = state;
590 591
591 commClose(); // cleanup communication sockets 592 commClose(); // cleanup communication sockets
592 593
593 // also emit a signal if the process was run Blocking 594 // also emit a signal if the process was run Blocking
594 if ( DontCare != run_mode ) 595 if ( DontCare != run_mode )
595 { 596 {
596 emit processExited( this ); 597 emit processExited( this );
597 } 598 }
598 } 599 }
599} 600}
600 601
601int OProcess::childOutput( int fdno ) 602int OProcess::childOutput( int fdno )
602{ 603{
603 if ( communication & NoRead ) 604 if ( communication & NoRead )
604 { 605 {
605 int len = -1; 606 int len = -1;
606 emit receivedStdout( fdno, len ); 607 emit receivedStdout( fdno, len );
607 errno = 0; // Make sure errno doesn't read "EAGAIN" 608 errno = 0; // Make sure errno doesn't read "EAGAIN"
608 return len; 609 return len;
609 } 610 }
610 else 611 else
611 { 612 {
612 char buffer[ 1024 ]; 613 char buffer[ 1024 ];
613 int len; 614 int len;
614 615
615 len = ::read( fdno, buffer, 1024 ); 616 len = ::read( fdno, buffer, 1024 );
616 617
617 if ( 0 < len ) 618 if ( 0 < len )
618 { 619 {
619 emit receivedStdout( this, buffer, len ); 620 emit receivedStdout( this, buffer, len );
620 } 621 }
621 return len; 622 return len;
622 } 623 }
623} 624}
624 625
625int OProcess::childError( int fdno ) 626int OProcess::childError( int fdno )
626{ 627{
627 char buffer[ 1024 ]; 628 char buffer[ 1024 ];
628 int len; 629 int len;
629 630
630 len = ::read( fdno, buffer, 1024 ); 631 len = ::read( fdno, buffer, 1024 );
631 632
632 if ( 0 < len ) 633 if ( 0 < len )
633 emit receivedStderr( this, buffer, len ); 634 emit receivedStderr( this, buffer, len );
634 return len; 635 return len;
635} 636}
636 637
637int OProcess::setupCommunication( Communication comm ) 638int OProcess::setupCommunication( Communication comm )
638{ 639{
639 int ok; 640 int ok;
640 641
641 communication = comm; 642 communication = comm;
642 643
643 ok = 1; 644 ok = 1;
644 if ( comm & Stdin ) 645 if ( comm & Stdin )
645 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, in ) >= 0; 646 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, in ) >= 0;
646 647
647 if ( comm & Stdout ) 648 if ( comm & Stdout )
648 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, out ) >= 0; 649 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, out ) >= 0;
649 650
650 if ( comm & Stderr ) 651 if ( comm & Stderr )
651 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, err ) >= 0; 652 ok &= socketpair( AF_UNIX, SOCK_STREAM, 0, err ) >= 0;
652 653
653 return ok; 654 return ok;
654} 655}
655 656
656int OProcess::commSetupDoneP() 657int OProcess::commSetupDoneP()
657{ 658{
658 int ok = 1; 659 int ok = 1;
659 660
660 if ( communication != NoCommunication ) 661 if ( communication != NoCommunication )
661 { 662 {
662 if ( communication & Stdin ) 663 if ( communication & Stdin )
663 close( in[ 0 ] ); 664 close( in[ 0 ] );
664 if ( communication & Stdout ) 665 if ( communication & Stdout )
665 close( out[ 1 ] ); 666 close( out[ 1 ] );
666 if ( communication & Stderr ) 667 if ( communication & Stderr )
667 close( err[ 1 ] ); 668 close( err[ 1 ] );
668 669
669 // Don't create socket notifiers and set the sockets non-blocking if 670 // Don't create socket notifiers and set the sockets non-blocking if
670 // blocking is requested. 671 // blocking is requested.
671 if ( run_mode == Block ) 672 if ( run_mode == Block )
672 return ok; 673 return ok;
673 674
674 if ( communication & Stdin ) 675 if ( communication & Stdin )
675 { 676 {
676 // ok &= (-1 != fcntl(in[1], F_SETFL, O_NONBLOCK)); 677 // ok &= (-1 != fcntl(in[1], F_SETFL, O_NONBLOCK));
677 innot = new QSocketNotifier( in[ 1 ], QSocketNotifier::Write, this ); 678 innot = new QSocketNotifier( in[ 1 ], QSocketNotifier::Write, this );
678 CHECK_PTR( innot ); 679 CHECK_PTR( innot );
679 innot->setEnabled( false ); // will be enabled when data has to be sent 680 innot->setEnabled( false ); // will be enabled when data has to be sent
680 QObject::connect( innot, SIGNAL( activated(int) ), 681 QObject::connect( innot, SIGNAL( activated(int) ),
681 this, SLOT( slotSendData(int) ) ); 682 this, SLOT( slotSendData(int) ) );
682 } 683 }
683 684
684 if ( communication & Stdout ) 685 if ( communication & Stdout )
685 { 686 {
686 // ok &= (-1 != fcntl(out[0], F_SETFL, O_NONBLOCK)); 687 // ok &= (-1 != fcntl(out[0], F_SETFL, O_NONBLOCK));
687 outnot = new QSocketNotifier( out[ 0 ], QSocketNotifier::Read, this ); 688 outnot = new QSocketNotifier( out[ 0 ], QSocketNotifier::Read, this );
688 CHECK_PTR( outnot ); 689 CHECK_PTR( outnot );
689 QObject::connect( outnot, SIGNAL( activated(int) ), 690 QObject::connect( outnot, SIGNAL( activated(int) ),
690 this, SLOT( slotChildOutput(int) ) ); 691 this, SLOT( slotChildOutput(int) ) );
691 if ( communication & NoRead ) 692 if ( communication & NoRead )
692 suspend(); 693 suspend();
693 } 694 }
694 695
695 if ( communication & Stderr ) 696 if ( communication & Stderr )
696 { 697 {
697 // ok &= (-1 != fcntl(err[0], F_SETFL, O_NONBLOCK)); 698 // ok &= (-1 != fcntl(err[0], F_SETFL, O_NONBLOCK));
698 errnot = new QSocketNotifier( err[ 0 ], QSocketNotifier::Read, this ); 699 errnot = new QSocketNotifier( err[ 0 ], QSocketNotifier::Read, this );
699 CHECK_PTR( errnot ); 700 CHECK_PTR( errnot );
700 QObject::connect( errnot, SIGNAL( activated(int) ), 701 QObject::connect( errnot, SIGNAL( activated(int) ),
701 this, SLOT( slotChildError(int) ) ); 702 this, SLOT( slotChildError(int) ) );
702 } 703 }
703 } 704 }
704 return ok; 705 return ok;
705} 706}
706 707
707int OProcess::commSetupDoneC() 708int OProcess::commSetupDoneC()
708{ 709{
709 int ok = 1; 710 int ok = 1;
710 struct linger so; 711 struct linger so;
711 memset( &so, 0, sizeof( so ) ); 712 memset( &so, 0, sizeof( so ) );
712 713
713 if ( communication & Stdin ) 714 if ( communication & Stdin )
714 close( in[ 1 ] ); 715 close( in[ 1 ] );
715 if ( communication & Stdout ) 716 if ( communication & Stdout )
716 close( out[ 0 ] ); 717 close( out[ 0 ] );
717 if ( communication & Stderr ) 718 if ( communication & Stderr )
718 close( err[ 0 ] ); 719 close( err[ 0 ] );
719 720
720 if ( communication & Stdin ) 721 if ( communication & Stdin )
721 ok &= dup2( in[ 0 ], STDIN_FILENO ) != -1; 722 ok &= dup2( in[ 0 ], STDIN_FILENO ) != -1;
722 else 723 else
723 { 724 {
724 int null_fd = open( "/dev/null", O_RDONLY ); 725 int null_fd = open( "/dev/null", O_RDONLY );
725 ok &= dup2( null_fd, STDIN_FILENO ) != -1; 726 ok &= dup2( null_fd, STDIN_FILENO ) != -1;
726 close( null_fd ); 727 close( null_fd );
727 } 728 }
728 if ( communication & Stdout ) 729 if ( communication & Stdout )
729 { 730 {
730 ok &= dup2( out[ 1 ], STDOUT_FILENO ) != -1; 731 ok &= dup2( out[ 1 ], STDOUT_FILENO ) != -1;
731 ok &= !setsockopt( out[ 1 ], SOL_SOCKET, SO_LINGER, ( char* ) & so, sizeof( so ) ); 732 ok &= !setsockopt( out[ 1 ], SOL_SOCKET, SO_LINGER, ( char* ) & so, sizeof( so ) );
732 } 733 }
733 else 734 else
734 { 735 {
735 int null_fd = open( "/dev/null", O_WRONLY ); 736 int null_fd = open( "/dev/null", O_WRONLY );
736 ok &= dup2( null_fd, STDOUT_FILENO ) != -1; 737 ok &= dup2( null_fd, STDOUT_FILENO ) != -1;
737 close( null_fd ); 738 close( null_fd );
738 } 739 }
739 if ( communication & Stderr ) 740 if ( communication & Stderr )
740 { 741 {
741 ok &= dup2( err[ 1 ], STDERR_FILENO ) != -1; 742 ok &= dup2( err[ 1 ], STDERR_FILENO ) != -1;
742 ok &= !setsockopt( err[ 1 ], SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>( &so ), sizeof( so ) ); 743 ok &= !setsockopt( err[ 1 ], SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>( &so ), sizeof( so ) );
743 } 744 }
744 else 745 else
745 { 746 {
746 int null_fd = open( "/dev/null", O_WRONLY ); 747 int null_fd = open( "/dev/null", O_WRONLY );
747 ok &= dup2( null_fd, STDERR_FILENO ) != -1; 748 ok &= dup2( null_fd, STDERR_FILENO ) != -1;
748 close( null_fd ); 749 close( null_fd );
749 } 750 }
750 return ok; 751 return ok;
751} 752}
752 753
753void OProcess::commClose() 754void OProcess::commClose()
754{ 755{
755 if ( NoCommunication != communication ) 756 if ( NoCommunication != communication )
756 { 757 {
757 bool b_in = ( communication & Stdin ); 758 bool b_in = ( communication & Stdin );
758 bool b_out = ( communication & Stdout ); 759 bool b_out = ( communication & Stdout );
759 bool b_err = ( communication & Stderr ); 760 bool b_err = ( communication & Stderr );
760 if ( b_in ) 761 if ( b_in )
761 delete innot; 762 delete innot;
762 763
763 if ( b_out || b_err ) 764 if ( b_out || b_err )
764 { 765 {
765 // If both channels are being read we need to make sure that one socket buffer 766 // If both channels are being read we need to make sure that one socket buffer
766 // doesn't fill up whilst we are waiting for data on the other (causing a deadlock). 767 // doesn't fill up whilst we are waiting for data on the other (causing a deadlock).
767 // Hence we need to use select. 768 // Hence we need to use select.
768 769
769 // Once one or other of the channels has reached EOF (or given an error) go back 770 // Once one or other of the channels has reached EOF (or given an error) go back
770 // to the usual mechanism. 771 // to the usual mechanism.
771 772
772 int fds_ready = 1; 773 int fds_ready = 1;
773 fd_set rfds; 774 fd_set rfds;
774 775
775 int max_fd = 0; 776 int max_fd = 0;
776 if ( b_out ) 777 if ( b_out )
777 { 778 {
778 fcntl( out[ 0 ], F_SETFL, O_NONBLOCK ); 779 fcntl( out[ 0 ], F_SETFL, O_NONBLOCK );
779 if ( out[ 0 ] > max_fd ) 780 if ( out[ 0 ] > max_fd )
780 max_fd = out[ 0 ]; 781 max_fd = out[ 0 ];
781 delete outnot; 782 delete outnot;
782 outnot = 0; 783 outnot = 0;
783 } 784 }
784 if ( b_err ) 785 if ( b_err )
785 { 786 {
786 fcntl( err[ 0 ], F_SETFL, O_NONBLOCK ); 787 fcntl( err[ 0 ], F_SETFL, O_NONBLOCK );
787 if ( err[ 0 ] > max_fd ) 788 if ( err[ 0 ] > max_fd )
788 max_fd = err[ 0 ]; 789 max_fd = err[ 0 ];
789 delete errnot; 790 delete errnot;
790 errnot = 0; 791 errnot = 0;
791 } 792 }
792 793
793 794
794 while ( b_out || b_err ) 795 while ( b_out || b_err )
795 { 796 {
796 // * If the process is still running we block until we 797 // * If the process is still running we block until we
797 // receive data. (p_timeout = 0, no timeout) 798 // receive data. (p_timeout = 0, no timeout)
798 // * If the process has already exited, we only check 799 // * If the process has already exited, we only check
799 // the available data, we don't wait for more. 800 // the available data, we don't wait for more.
800 // (p_timeout = &timeout, timeout immediately) 801 // (p_timeout = &timeout, timeout immediately)
801 struct timeval timeout; 802 struct timeval timeout;
802 timeout.tv_sec = 0; 803 timeout.tv_sec = 0;
803 timeout.tv_usec = 0; 804 timeout.tv_usec = 0;
804 struct timeval *p_timeout = runs ? 0 : &timeout; 805 struct timeval *p_timeout = runs ? 0 : &timeout;
805 806
806 FD_ZERO( &rfds ); 807 FD_ZERO( &rfds );
807 if ( b_out ) 808 if ( b_out )
808 FD_SET( out[ 0 ], &rfds ); 809 FD_SET( out[ 0 ], &rfds );