summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 4436ad6..8ac3451 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -119,256 +119,261 @@ void OpieMail::slotExtAppHandler()
119} 119}
120void OpieMail::slotwriteMail2(const QString& namemail ) 120void OpieMail::slotwriteMail2(const QString& namemail )
121{ 121{
122 //qDebug("OpieMail::slotwriteMail2 "); 122 //qDebug("OpieMail::slotwriteMail2 ");
123 //qApp->processEvents(); 123 //qApp->processEvents();
124 ComposeMail compose( settings, this, 0, true ); 124 ComposeMail compose( settings, this, 0, true );
125 if ( !namemail.isEmpty() ) { 125 if ( !namemail.isEmpty() ) {
126 QString to = namemail; 126 QString to = namemail;
127 if ( namemail.find( " <") > 1 ) { 127 if ( namemail.find( " <") > 1 ) {
128 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 128 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
129 } else 129 } else
130 if ( namemail.find( "<") > 1 ) { 130 if ( namemail.find( "<") > 1 ) {
131 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 131 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
132 } 132 }
133 int sub = to.find( ">:"); 133 int sub = to.find( ">:");
134 if ( sub > 0 ) { 134 if ( sub > 0 ) {
135 compose.setTo( to.left(sub+1) ); 135 compose.setTo( to.left(sub+1) );
136 compose.setSubject( to.mid(sub+2) ); 136 compose.setSubject( to.mid(sub+2) );
137 } else 137 } else
138 compose.setTo( to ); 138 compose.setTo( to );
139 } 139 }
140 compose.slotAdjustColumns(); 140 compose.slotAdjustColumns();
141#ifndef DESKTOP_VERSION 141#ifndef DESKTOP_VERSION
142 compose.showMaximized(); 142 compose.showMaximized();
143#endif 143#endif
144 mCurrentComposer = &compose; 144 mCurrentComposer = &compose;
145 compose.exec(); 145 compose.exec();
146 mCurrentComposer = 0; 146 mCurrentComposer = 0;
147 folderView->refreshOutgoing(); 147 folderView->refreshOutgoing();
148 raise(); 148 raise();
149 //qDebug("retttich "); 149 //qDebug("retttich ");
150} 150}
151void OpieMail::slotwriteMail(const QString&name,const QString&email) 151void OpieMail::slotwriteMail(const QString&name,const QString&email)
152{ 152{
153 // qDebug("OpieMail::slotwriteMail "); 153 // qDebug("OpieMail::slotwriteMail ");
154 ComposeMail compose( settings, this, 0, true ); 154 ComposeMail compose( settings, this, 0, true );
155 if (!email.isEmpty()) 155 if (!email.isEmpty())
156 { 156 {
157 if (!name.isEmpty()) 157 if (!name.isEmpty())
158 { 158 {
159 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 159 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
160 } 160 }
161 else 161 else
162 { 162 {
163 compose.setTo(email); 163 compose.setTo(email);
164 } 164 }
165 } 165 }
166 compose.slotAdjustColumns(); 166 compose.slotAdjustColumns();
167#ifndef DESKTOP_VERSION 167#ifndef DESKTOP_VERSION
168 compose.showMaximized(); 168 compose.showMaximized();
169#endif 169#endif
170 170
171 mCurrentComposer = &compose; 171 mCurrentComposer = &compose;
172 compose.exec(); 172 compose.exec();
173 mCurrentComposer = 0; 173 mCurrentComposer = 0;
174 folderView->refreshOutgoing(); 174 folderView->refreshOutgoing();
175 raise(); 175 raise();
176} 176}
177 177
178void OpieMail::slotComposeMail() 178void OpieMail::slotComposeMail()
179{ 179{
180 if ( mPendingEmail == QString::null && mPendingName == QString::null) 180 if ( mPendingEmail == QString::null && mPendingName == QString::null)
181 slotwriteMail2( QString () ); 181 slotwriteMail2( QString () );
182 else { 182 else {
183 if ( mPendingEmail == QString::null ) 183 if ( mPendingEmail == QString::null )
184 slotwriteMail2( mPendingName ); 184 slotwriteMail2( mPendingName );
185 else 185 else
186 slotwriteMail( mPendingName, mPendingEmail ); 186 slotwriteMail( mPendingName, mPendingEmail );
187 } 187 }
188 //slotwriteMail(0l,0l); 188 //slotwriteMail(0l,0l);
189} 189}
190 190
191void OpieMail::slotSendQueued() 191void OpieMail::slotSendQueued()
192{ 192{
193 SMTPaccount *smtp = 0; 193 SMTPaccount *smtp = 0;
194 194
195 QList<Account> list = settings->getAccounts(); 195 QList<Account> list = settings->getAccounts();
196 QList<SMTPaccount> smtpList; 196 QList<SMTPaccount> smtpList;
197 smtpList.setAutoDelete(false); 197 smtpList.setAutoDelete(false);
198 Account *it; 198 Account *it;
199 for ( it = list.first(); it; it = list.next() ) 199 for ( it = list.first(); it; it = list.next() )
200 { 200 {
201 if ( it->getType() == MAILLIB::A_SMTP ) 201 if ( it->getType() == MAILLIB::A_SMTP )
202 { 202 {
203 smtp = static_cast<SMTPaccount *>(it); 203 smtp = static_cast<SMTPaccount *>(it);
204 smtpList.append(smtp); 204 smtpList.append(smtp);
205 } 205 }
206 } 206 }
207 if (smtpList.count()==0) 207 if (smtpList.count()==0)
208 { 208 {
209 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); 209 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n"));
210 return; 210 return;
211 } 211 }
212 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 212 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
213 return; 213 return;
214 if (smtpList.count()==1) 214 if (smtpList.count()==1)
215 { 215 {
216 smtp = smtpList.at(0); 216 smtp = smtpList.at(0);
217 } 217 }
218 else 218 else
219 { 219 {
220 smtp = 0; 220 smtp = 0;
221 selectsmtp selsmtp; 221 selectsmtp selsmtp;
222 selsmtp.setSelectionlist(&smtpList); 222 selsmtp.setSelectionlist(&smtpList);
223 selsmtp.resize( selsmtp.sizeHint() ); 223 selsmtp.resize( selsmtp.sizeHint() );
224 if ( selsmtp.exec() == QDialog::Accepted ) 224 if ( selsmtp.exec() == QDialog::Accepted )
225 { 225 {
226 smtp = selsmtp.selected_smtp(); 226 smtp = selsmtp.selected_smtp();
227 } 227 }
228 } 228 }
229 if (smtp) 229 if (smtp)
230 { 230 {
231 231
232 Global::statusMessage("Sending mails...!"); 232 Global::statusMessage("Sending mails...!");
233 SMTPwrapper * wrap = new SMTPwrapper(smtp); 233 SMTPwrapper * wrap = new SMTPwrapper(smtp);
234 if ( wrap->flushOutbox() ) 234 if ( wrap->flushOutbox() )
235 { 235 {
236 Global::statusMessage("Mails sent!"); 236 Global::statusMessage("Mails sent!");
237 } 237 }
238 delete wrap; 238 delete wrap;
239 } 239 }
240 folderView->refreshOutgoing(); 240 folderView->refreshOutgoing();
241} 241}
242 242
243void OpieMail::slotSearchMails() 243void OpieMail::slotSearchMails()
244{ 244{
245 qDebug("OpieMail::slotSearchMails():not implemented "); 245 qDebug("OpieMail::slotSearchMails():not implemented ");
246} 246}
247void OpieMail::slotEditGlobalSettings()
248{
249 KPimPrefsGlobalDialog gc ( this );
250 gc.exec();
251}
247 252
248void OpieMail::slotEditSettings() 253void OpieMail::slotEditSettings()
249{ 254{
250 255
251 KOPrefsDialog settingsDialog( this, "koprefs", true ); 256 KOPrefsDialog settingsDialog( this, "koprefs", true );
252#ifndef DESKTOP_VERSION 257#ifndef DESKTOP_VERSION
253 settingsDialog.showMaximized(); 258 settingsDialog.showMaximized();
254#endif 259#endif
255 settingsDialog.exec(); 260 settingsDialog.exec();
256 261
257 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 262 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
258 // KApplication::execDialog(settingsDialog); 263 // KApplication::execDialog(settingsDialog);
259} 264}
260 265
261void OpieMail::slotEditAccounts() 266void OpieMail::slotEditAccounts()
262{ 267{
263 EditAccounts eaDialog( settings, this, 0, true ); 268 EditAccounts eaDialog( settings, this, 0, true );
264 eaDialog.slotAdjustColumns(); 269 eaDialog.slotAdjustColumns();
265#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
266 eaDialog.showMaximized(); 271 eaDialog.showMaximized();
267#endif 272#endif
268 eaDialog.exec(); 273 eaDialog.exec();
269 if ( settings ) delete settings; 274 if ( settings ) delete settings;
270 settings = new Settings(); 275 settings = new Settings();
271 276
272 folderView->populate( settings->getAccounts() ); 277 folderView->populate( settings->getAccounts() );
273} 278}
274void OpieMail::replyMail() 279void OpieMail::replyMail()
275{ 280{
276 281
277 QListViewItem*item = mailView->currentItem(); 282 QListViewItem*item = mailView->currentItem();
278 if (!item) return; 283 if (!item) return;
279 RecMailP mail = ((MailListViewItem*)item)->data(); 284 RecMailP mail = ((MailListViewItem*)item)->data();
280 RecBodyP body = folderView->fetchBody(mail); 285 RecBodyP body = folderView->fetchBody(mail);
281 286
282 QString rtext; 287 QString rtext;
283 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 288 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
284 .arg( mail->getFrom()) 289 .arg( mail->getFrom())
285 .arg( mail->getDate()); 290 .arg( mail->getDate());
286 291
287 QString text = body->Bodytext(); 292 QString text = body->Bodytext();
288 QStringList lines = QStringList::split(QRegExp("\\n"), text); 293 QStringList lines = QStringList::split(QRegExp("\\n"), text);
289 QStringList::Iterator it; 294 QStringList::Iterator it;
290 for (it = lines.begin(); it != lines.end(); it++) 295 for (it = lines.begin(); it != lines.end(); it++)
291 { 296 {
292 rtext += "> " + *it + "\n"; 297 rtext += "> " + *it + "\n";
293 } 298 }
294 rtext += "\n"; 299 rtext += "\n";
295 300
296 QString prefix; 301 QString prefix;
297 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 302 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
298 else prefix = "Re: "; // no i18n on purpose 303 else prefix = "Re: "; // no i18n on purpose
299 304
300 Settings *settings = new Settings(); 305 Settings *settings = new Settings();
301 ComposeMail composer( settings ,this, 0, true); 306 ComposeMail composer( settings ,this, 0, true);
302 if (mail->Replyto().isEmpty()) { 307 if (mail->Replyto().isEmpty()) {
303 composer.setTo( mail->getFrom()); 308 composer.setTo( mail->getFrom());
304 } else { 309 } else {
305 composer.setTo( mail->Replyto()); 310 composer.setTo( mail->Replyto());
306 } 311 }
307 composer.setSubject( prefix + mail->getSubject()); 312 composer.setSubject( prefix + mail->getSubject());
308 composer.setMessage( rtext ); 313 composer.setMessage( rtext );
309 composer.setInReplyTo( mail->Msgid()); 314 composer.setInReplyTo( mail->Msgid());
310 composer.setCharset( body->getCharset() ); 315 composer.setCharset( body->getCharset() );
311 316
312 mCurrentComposer = &composer; 317 mCurrentComposer = &composer;
313 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 318 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
314 { 319 {
315 mail->Wrapper()->answeredMail(mail); 320 mail->Wrapper()->answeredMail(mail);
316 } 321 }
317 mCurrentComposer = 0; 322 mCurrentComposer = 0;
318 folderView->refreshOutgoing(); 323 folderView->refreshOutgoing();
319 delete settings; 324 delete settings;
320 325
321} 326}
322void OpieMail::closeViewMail(ViewMail * vm) 327void OpieMail::closeViewMail(ViewMail * vm)
323{ 328{
324 vm->hide(); 329 vm->hide();
325} 330}
326 331
327void OpieMail::slotDownloadMail( ) 332void OpieMail::slotDownloadMail( )
328{ 333{
329 QListViewItem*item = mailView->currentItem(); 334 QListViewItem*item = mailView->currentItem();
330 if (!item ) { 335 if (!item ) {
331 Global::statusMessage("Error: No item slected!"); 336 Global::statusMessage("Error: No item slected!");
332 return; 337 return;
333 } 338 }
334 RecMailP mail = ((MailListViewItem*)item)->data(); 339 RecMailP mail = ((MailListViewItem*)item)->data();
335 Account * acc = mail->Wrapper()->getAccount(); 340 Account * acc = mail->Wrapper()->getAccount();
336 if ( !acc ) { 341 if ( !acc ) {
337 Global::statusMessage("Mail is already stored locally!"); 342 Global::statusMessage("Mail is already stored locally!");
338 return; 343 return;
339 } 344 }
340 QString lfName = acc->getLocalFolder(); 345 QString lfName = acc->getLocalFolder();
341 //qDebug("local folder " + lfName ); 346 //qDebug("local folder " + lfName );
342 if ( lfName.isEmpty() ) 347 if ( lfName.isEmpty() )
343 lfName = acc->getAccountName(); 348 lfName = acc->getAccountName();
344 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); 349 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
345 //qDebug("target %d %d ",targetMail,mail->Wrapper() ); 350 //qDebug("target %d %d ",targetMail,mail->Wrapper() );
346 if ( targetMail == mail->Wrapper() ) { 351 if ( targetMail == mail->Wrapper() ) {
347 Global::statusMessage("Mail is already locally stored!"); 352 Global::statusMessage("Mail is already locally stored!");
348 return; 353 return;
349 } 354 }
350 if ( !targetMail->createMbox(lfName)) { 355 if ( !targetMail->createMbox(lfName)) {
351 Global::statusMessage("Error creating folder!"); 356 Global::statusMessage("Error creating folder!");
352 return; 357 return;
353 } 358 }
354 Global::statusMessage("Fetching mail...please wait!"); 359 Global::statusMessage("Fetching mail...please wait!");
355 qApp->processEvents(); 360 qApp->processEvents();
356 encodedString*st = 0; 361 encodedString*st = 0;
357 st = mail->Wrapper()->fetchRawBody(mail); 362 st = mail->Wrapper()->fetchRawBody(mail);
358 if ( st ) { 363 if ( st ) {
359 targetMail->storeMessage(st->Content(),st->Length(),lfName); 364 targetMail->storeMessage(st->Content(),st->Length(),lfName);
360 Global::statusMessage("Mail stored in "+ lfName); 365 Global::statusMessage("Mail stored in "+ lfName);
361 delete st; 366 delete st;
362 } else { 367 } else {
363 Global::statusMessage("Error: Cannot fetch mail!"); 368 Global::statusMessage("Error: Cannot fetch mail!");
364 } 369 }
365} 370}
366 371
367 372
368void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) 373void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
369{ 374{
370 QListViewItem*item = mailView->currentItem(); 375 QListViewItem*item = mailView->currentItem();
371 if (!item ) { 376 if (!item ) {
372 closeViewMail(vm); 377 closeViewMail(vm);
373 return; 378 return;
374 } 379 }