-rw-r--r-- | kmicromail/opiemail.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index c20c7ce..ec192ea 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -174,270 +174,286 @@ void OpieMail::slotSendQueued() | |||
174 | { | 174 | { |
175 | SMTPaccount *smtp = 0; | 175 | SMTPaccount *smtp = 0; |
176 | 176 | ||
177 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
178 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
179 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
180 | Account *it; | 180 | Account *it; |
181 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
182 | { | 182 | { |
183 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
184 | { | 184 | { |
185 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
186 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
190 | { | 190 | { |
191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
195 | return; | 195 | return; |
196 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
197 | { | 197 | { |
198 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | { | 201 | { |
202 | smtp = 0; | 202 | smtp = 0; |
203 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
204 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
205 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
206 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
207 | #endif | 207 | #endif |
208 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
209 | { | 209 | { |
210 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | if (smtp) | 213 | if (smtp) |
214 | { | 214 | { |
215 | 215 | ||
216 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
218 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
219 | { | 219 | { |
220 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
221 | } | 221 | } |
222 | delete wrap; | 222 | delete wrap; |
223 | } | 223 | } |
224 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
225 | } | 225 | } |
226 | 226 | ||
227 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
228 | { | 228 | { |
229 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
230 | } | 230 | } |
231 | 231 | ||
232 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
233 | { | 233 | { |
234 | 234 | ||
235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
236 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
237 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
238 | #endif | 238 | #endif |
239 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
240 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
242 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
246 | { | 246 | { |
247 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
248 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
249 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
250 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
251 | #endif | 251 | #endif |
252 | eaDialog.exec(); | 252 | eaDialog.exec(); |
253 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
254 | settings = new Settings(); | 254 | settings = new Settings(); |
255 | 255 | ||
256 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
257 | } | 257 | } |
258 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
259 | { | 259 | { |
260 | 260 | ||
261 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
262 | if (!item) return; | 262 | if (!item) return; |
263 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
264 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
265 | 265 | ||
266 | QString rtext; | 266 | QString rtext; |
267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
268 | .arg( mail->getFrom()) | 268 | .arg( mail->getFrom()) |
269 | .arg( mail->getDate()); | 269 | .arg( mail->getDate()); |
270 | 270 | ||
271 | QString text = body->Bodytext(); | 271 | QString text = body->Bodytext(); |
272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
273 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
274 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
275 | { | 275 | { |
276 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
277 | } | 277 | } |
278 | rtext += "\n"; | 278 | rtext += "\n"; |
279 | 279 | ||
280 | QString prefix; | 280 | QString prefix; |
281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
282 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
283 | 283 | ||
284 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
285 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
286 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
287 | composer.setTo( mail->getFrom()); | 287 | composer.setTo( mail->getFrom()); |
288 | } else { | 288 | } else { |
289 | composer.setTo( mail->Replyto()); | 289 | composer.setTo( mail->Replyto()); |
290 | } | 290 | } |
291 | composer.setSubject( prefix + mail->getSubject()); | 291 | composer.setSubject( prefix + mail->getSubject()); |
292 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
293 | composer.setInReplyTo( mail->Msgid()); | 293 | composer.setInReplyTo( mail->Msgid()); |
294 | composer.setCharset( body->getCharset() ); | 294 | composer.setCharset( body->getCharset() ); |
295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
296 | { | 296 | { |
297 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
298 | } | 298 | } |
299 | delete settings; | 299 | delete settings; |
300 | 300 | ||
301 | } | 301 | } |
302 | void OpieMail::displayNextMail(ViewMail * vm) | ||
303 | { | ||
304 | QListViewItem*item = mailView->currentItem(); | ||
305 | if (!item) return; | ||
306 | item = item->itemBelow(); | ||
307 | if (!item) { | ||
308 | vm->setCaption(i18n("End of List" )); | ||
309 | return; | ||
310 | } | ||
311 | mailView->setCurrentItem(item); | ||
312 | RecMailP mail = ((MailListViewItem*)item)->data(); | ||
313 | RecBodyP body = folderView->fetchBody(mail); | ||
314 | vm->setBody( body ); | ||
315 | vm->setMail( mail ); | ||
316 | } | ||
302 | void OpieMail::displayMail() | 317 | void OpieMail::displayMail() |
303 | { | 318 | { |
304 | QListViewItem*item = mailView->currentItem(); | 319 | QListViewItem*item = mailView->currentItem(); |
305 | if (!item) return; | 320 | if (!item) return; |
306 | RecMailP mail = ((MailListViewItem*)item)->data(); | 321 | RecMailP mail = ((MailListViewItem*)item)->data(); |
307 | RecBodyP body = folderView->fetchBody(mail); | 322 | RecBodyP body = folderView->fetchBody(mail); |
308 | ViewMail readMail( this,"", Qt::WType_Modal ); | 323 | ViewMail readMail( this,"", Qt::WType_Modal ); |
309 | readMail.setBody( body ); | 324 | readMail.setBody( body ); |
310 | readMail.setMail( mail ); | 325 | readMail.setMail( mail ); |
311 | #ifndef DESKTOP_VERSION | 326 | #ifndef DESKTOP_VERSION |
312 | readMail.showMaximized(); | 327 | readMail.showMaximized(); |
313 | #else | 328 | #else |
314 | readMail.resize( 640, 480); | 329 | readMail.resize( 640, 480); |
315 | #endif | 330 | #endif |
331 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | ||
316 | readMail.exec(); | 332 | readMail.exec(); |
317 | 333 | ||
318 | if ( readMail.deleted ) | 334 | if ( readMail.deleted ) |
319 | { | 335 | { |
320 | folderView->refreshCurrent(); | 336 | folderView->refreshCurrent(); |
321 | } | 337 | } |
322 | else | 338 | else |
323 | { | 339 | { |
324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 340 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
325 | } | 341 | } |
326 | } | 342 | } |
327 | void OpieMail::slotGetAllMail() | 343 | void OpieMail::slotGetAllMail() |
328 | { | 344 | { |
329 | QListViewItem * item = folderView->firstChild(); | 345 | QListViewItem * item = folderView->firstChild(); |
330 | while ( item ){ | 346 | while ( item ){ |
331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 347 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
332 | item = item->nextSibling (); | 348 | item = item->nextSibling (); |
333 | } | 349 | } |
334 | } | 350 | } |
335 | void OpieMail::slotGetMail() | 351 | void OpieMail::slotGetMail() |
336 | { | 352 | { |
337 | QListViewItem * item = folderView->currentItem(); | 353 | QListViewItem * item = folderView->currentItem(); |
338 | if ( ! item ) return; | 354 | if ( ! item ) return; |
339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 355 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
340 | } | 356 | } |
341 | void OpieMail::slotDeleteMail() | 357 | void OpieMail::slotDeleteMail() |
342 | { | 358 | { |
343 | if (!mailView->currentItem()) return; | 359 | if (!mailView->currentItem()) return; |
344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 360 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
345 | 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 ) | 361 | 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 ) |
346 | { | 362 | { |
347 | mail->Wrapper()->deleteMail( mail ); | 363 | mail->Wrapper()->deleteMail( mail ); |
348 | folderView->refreshCurrent(); | 364 | folderView->refreshCurrent(); |
349 | } | 365 | } |
350 | } | 366 | } |
351 | void OpieMail::slotDeleteAllMail() | 367 | void OpieMail::slotDeleteAllMail() |
352 | { | 368 | { |
353 | 369 | ||
354 | QValueList<RecMailP> t; | 370 | QValueList<RecMailP> t; |
355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 371 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
356 | { | 372 | { |
357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 373 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
358 | while ( item ) { | 374 | while ( item ) { |
359 | if ( item->isSelected() ) { | 375 | if ( item->isSelected() ) { |
360 | t.append( item->data() ); | 376 | t.append( item->data() ); |
361 | } | 377 | } |
362 | item = (MailListViewItem*)item->nextSibling(); | 378 | item = (MailListViewItem*)item->nextSibling(); |
363 | } | 379 | } |
364 | } | 380 | } |
365 | else | 381 | else |
366 | return; | 382 | return; |
367 | if ( t.count() == 0 ) | 383 | if ( t.count() == 0 ) |
368 | return; | 384 | return; |
369 | RecMailP mail = t.first(); | 385 | RecMailP mail = t.first(); |
370 | mail->Wrapper()->deleteMailList(t); | 386 | mail->Wrapper()->deleteMailList(t); |
371 | folderView->refreshCurrent(); | 387 | folderView->refreshCurrent(); |
372 | 388 | ||
373 | 389 | ||
374 | } | 390 | } |
375 | void OpieMail::clearSelection() | 391 | void OpieMail::clearSelection() |
376 | { | 392 | { |
377 | mailView->clearSelection(); | 393 | mailView->clearSelection(); |
378 | 394 | ||
379 | } | 395 | } |
380 | 396 | ||
381 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 397 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
382 | { | 398 | { |
383 | if (!mailView->currentItem()) return; | 399 | if (!mailView->currentItem()) return; |
384 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 400 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
385 | /* just the RIGHT button - or hold on pda */ | 401 | /* just the RIGHT button - or hold on pda */ |
386 | if (button!=2) {return;} | 402 | if (button!=2) {return;} |
387 | if (!item) return; | 403 | if (!item) return; |
388 | QPopupMenu *m = new QPopupMenu(0); | 404 | QPopupMenu *m = new QPopupMenu(0); |
389 | if (m) | 405 | if (m) |
390 | { | 406 | { |
391 | if (mailtype==MAILLIB::A_NNTP) { | 407 | if (mailtype==MAILLIB::A_NNTP) { |
392 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 408 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
393 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 409 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
394 | m->insertSeparator(); | 410 | m->insertSeparator(); |
395 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 411 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
396 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 412 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
397 | } else { | 413 | } else { |
398 | if (folderView->currentisDraft()) { | 414 | if (folderView->currentisDraft()) { |
399 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 415 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
400 | } | 416 | } |
401 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 417 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
402 | m->insertSeparator(); | 418 | m->insertSeparator(); |
403 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 419 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
404 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 420 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
405 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 421 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
406 | m->insertSeparator(); | 422 | m->insertSeparator(); |
407 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 423 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
408 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 424 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
409 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 425 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
410 | } | 426 | } |
411 | m->setFocus(); | 427 | m->setFocus(); |
412 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 428 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
413 | delete m; | 429 | delete m; |
414 | } | 430 | } |
415 | } | 431 | } |
416 | 432 | ||
417 | void OpieMail::slotShowFolders( bool show ) | 433 | void OpieMail::slotShowFolders( bool show ) |
418 | { | 434 | { |
419 | if ( show && folderView->isHidden() ) | 435 | if ( show && folderView->isHidden() ) |
420 | { | 436 | { |
421 | folderView->show(); | 437 | folderView->show(); |
422 | } | 438 | } |
423 | else if ( !show && !folderView->isHidden() ) | 439 | else if ( !show && !folderView->isHidden() ) |
424 | { | 440 | { |
425 | folderView->hide(); | 441 | folderView->hide(); |
426 | } | 442 | } |
427 | } | 443 | } |
428 | 444 | ||
429 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 445 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
430 | { | 446 | { |
431 | MailListViewItem*item = 0; | 447 | MailListViewItem*item = 0; |
432 | mailView->clear(); | 448 | mailView->clear(); |
433 | 449 | ||
434 | QValueList<RecMailP>::ConstIterator it; | 450 | QValueList<RecMailP>::ConstIterator it; |
435 | for (it = list.begin(); it != list.end();++it) | 451 | for (it = list.begin(); it != list.end();++it) |
436 | { | 452 | { |
437 | item = new MailListViewItem(mailView,item); | 453 | item = new MailListViewItem(mailView,item); |
438 | item->storeData((*it)); | 454 | item->storeData((*it)); |
439 | item->showEntry(); | 455 | item->showEntry(); |
440 | } | 456 | } |
441 | mailView->setSorting ( 4, false ); | 457 | mailView->setSorting ( 4, false ); |
442 | } | 458 | } |
443 | 459 | ||