-rw-r--r-- | kmicromail/viewmail.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 767a369..726f540 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -252,258 +252,261 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
252 | 252 | ||
253 | ret = menu->exec( point, 0 ); | 253 | ret = menu->exec( point, 0 ); |
254 | 254 | ||
255 | switch(ret) | 255 | switch(ret) |
256 | { | 256 | { |
257 | case 0: | 257 | case 0: |
258 | { | 258 | { |
259 | //MimeTypes types; | 259 | //MimeTypes types; |
260 | //types.insert( "all", "*" ); | 260 | //types.insert( "all", "*" ); |
261 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 261 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
262 | 262 | ||
263 | if( !str.isEmpty() ) | 263 | if( !str.isEmpty() ) |
264 | { | 264 | { |
265 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 265 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
266 | if (content) | 266 | if (content) |
267 | { | 267 | { |
268 | QFile output(str); | 268 | QFile output(str); |
269 | output.open(IO_WriteOnly); | 269 | output.open(IO_WriteOnly); |
270 | output.writeBlock(content->Content(),content->Length()); | 270 | output.writeBlock(content->Content(),content->Length()); |
271 | output.close(); | 271 | output.close(); |
272 | delete content; | 272 | delete content; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | break ; | 276 | break ; |
277 | 277 | ||
278 | case 2: | 278 | case 2: |
279 | { | 279 | { |
280 | #ifdef DESKTOP_VERSION | 280 | #ifdef DESKTOP_VERSION |
281 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | 281 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); |
282 | #else | 282 | #else |
283 | QString tmpfile = "/tmp/opiemail-image"; | 283 | QString tmpfile = "/tmp/opiemail-image"; |
284 | #endif | 284 | #endif |
285 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 285 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
286 | if (content) { | 286 | if (content) { |
287 | QFile output(tmpfile); | 287 | QFile output(tmpfile); |
288 | output.open(IO_WriteOnly); | 288 | output.open(IO_WriteOnly); |
289 | output.writeBlock(content->Content(),content->Length()); | 289 | output.writeBlock(content->Content(),content->Length()); |
290 | output.close(); | 290 | output.close(); |
291 | delete content; | 291 | delete content; |
292 | MailImageDlg iview(""); | 292 | MailImageDlg iview(""); |
293 | iview.setName(tmpfile); | 293 | iview.setName(tmpfile); |
294 | KApplication::execDialog(&iview); | 294 | KApplication::execDialog(&iview); |
295 | output.remove(); | 295 | output.remove(); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | break; | 298 | break; |
299 | case 1: | 299 | case 1: |
300 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 300 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
301 | { | 301 | { |
302 | setText(); | 302 | setText(); |
303 | } | 303 | } |
304 | else | 304 | else |
305 | { | 305 | { |
306 | if ( m_recMail->Wrapper() != 0l ) | 306 | if ( m_recMail->Wrapper() != 0l ) |
307 | { // make sure that there is a wrapper , even after delete or simular actions | 307 | { // make sure that there is a wrapper , even after delete or simular actions |
308 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 308 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
309 | } | 309 | } |
310 | } | 310 | } |
311 | break; | 311 | break; |
312 | } | 312 | } |
313 | delete menu; | 313 | delete menu; |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void ViewMail::setMail(const RecMailP&mail ) | 317 | void ViewMail::setMail(const RecMailP&mail ) |
318 | { | 318 | { |
319 | 319 | ||
320 | m_recMail = mail; | 320 | m_recMail = mail; |
321 | 321 | ||
322 | m_mail[0] = mail->getFrom(); | 322 | m_mail[0] = mail->getFrom(); |
323 | m_mail[1] = mail->getSubject(); | 323 | m_mail[1] = mail->getSubject(); |
324 | m_mail[3] = mail->getDate(); | 324 | m_mail[3] = mail->getDate(); |
325 | m_mail[4] = mail->Msgid(); | 325 | m_mail[4] = mail->Msgid(); |
326 | 326 | ||
327 | m_mail2[0] = mail->To(); | 327 | m_mail2[0] = mail->To(); |
328 | m_mail2[1] = mail->CC(); | 328 | m_mail2[1] = mail->CC(); |
329 | m_mail2[2] = mail->Bcc(); | 329 | m_mail2[2] = mail->Bcc(); |
330 | 330 | ||
331 | setText(); | 331 | setText(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | 335 | ||
336 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 336 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
337 | : ViewMailBase(parent, name, fl), _inLoop(false) | 337 | : ViewMailBase(parent, name, fl), _inLoop(false) |
338 | { | 338 | { |
339 | m_gotBody = false; | 339 | m_gotBody = false; |
340 | deleted = false; | 340 | deleted = false; |
341 | sourceOn = false; | 341 | sourceOn = false; |
342 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 342 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
343 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 343 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
344 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 344 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
345 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 345 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
346 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 346 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
347 | connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); | 347 | connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); |
348 | connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) ); | 348 | connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) ); |
349 | connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) ); | 349 | connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) ); |
350 | 350 | ||
351 | attachments->setEnabled(m_gotBody); | 351 | attachments->setEnabled(m_gotBody); |
352 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 352 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
353 | 353 | ||
354 | readConfig(); | 354 | readConfig(); |
355 | attachments->setSorting(-1); | 355 | attachments->setSorting(-1); |
356 | } | 356 | } |
357 | 357 | ||
358 | void ViewMail::readConfig() | 358 | void ViewMail::readConfig() |
359 | { | 359 | { |
360 | 360 | ||
361 | setFont ( KOPrefs::instance()->mReadFont ); | 361 | setFont ( KOPrefs::instance()->mReadFont ); |
362 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 362 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
363 | showHtml->setOn( m_showHtml ); | 363 | showHtml->setOn( m_showHtml ); |
364 | } | 364 | } |
365 | 365 | ||
366 | void ViewMail::setText() | 366 | void ViewMail::setText() |
367 | { | 367 | { |
368 | 368 | ||
369 | viewSource->setText(i18n("View Source")); | 369 | viewSource->setText(i18n("View Source")); |
370 | sourceOn = false; | 370 | sourceOn = false; |
371 | QString toString; | 371 | QString toString; |
372 | QString ccString; | 372 | QString ccString; |
373 | QString bccString; | 373 | QString bccString; |
374 | 374 | ||
375 | 375 | ||
376 | toString = m_mail2[0].join(","); | 376 | toString = m_mail2[0].join(","); |
377 | ccString = m_mail2[1].join(","); | 377 | ccString = m_mail2[1].join(","); |
378 | bccString = m_mail2[2].join(","); | 378 | bccString = m_mail2[2].join(","); |
379 | 379 | ||
380 | 380 | #ifdef DESKTOP_VERSION | |
381 | setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); | 381 | setCaption( i18n("Size: ")+m_recMail->MsgsizeString()+" - "+i18n("E-Mail by %1").arg( m_mail[0] ) ); |
382 | #else | ||
383 | setCaption( m_recMail->MsgsizeString()+" - "+m_mail[0] ); | ||
384 | #endif | ||
382 | 385 | ||
383 | m_mailHtml = "<html><body>" | 386 | m_mailHtml = "<html><body>" |
384 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 387 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
385 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 388 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
386 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 389 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
387 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 390 | "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
388 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 391 | "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
389 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 392 | i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
390 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + | 393 | "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + |
391 | "</td></tr></table><font>"; | 394 | "</td></tr></table><font>"; |
392 | 395 | ||
393 | if ( !m_showHtml ) | 396 | if ( !m_showHtml ) |
394 | { | 397 | { |
395 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 398 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
396 | } | 399 | } |
397 | else | 400 | else |
398 | { | 401 | { |
399 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 402 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
400 | } | 403 | } |
401 | // remove later in favor of a real handling | 404 | // remove later in favor of a real handling |
402 | m_gotBody = true; | 405 | m_gotBody = true; |
403 | } | 406 | } |
404 | 407 | ||
405 | 408 | ||
406 | ViewMail::~ViewMail() | 409 | ViewMail::~ViewMail() |
407 | { | 410 | { |
408 | m_recMail->Wrapper()->cleanMimeCache(); | 411 | m_recMail->Wrapper()->cleanMimeCache(); |
409 | hide(); | 412 | hide(); |
410 | } | 413 | } |
411 | 414 | ||
412 | void ViewMail::hide() | 415 | void ViewMail::hide() |
413 | { | 416 | { |
414 | QWidget::hide(); | 417 | QWidget::hide(); |
415 | 418 | ||
416 | if (_inLoop) | 419 | if (_inLoop) |
417 | { | 420 | { |
418 | _inLoop = false; | 421 | _inLoop = false; |
419 | qApp->exit_loop(); | 422 | qApp->exit_loop(); |
420 | 423 | ||
421 | } | 424 | } |
422 | 425 | ||
423 | } | 426 | } |
424 | 427 | ||
425 | void ViewMail::exec() | 428 | void ViewMail::exec() |
426 | { | 429 | { |
427 | show(); | 430 | show(); |
428 | 431 | ||
429 | if (!_inLoop) | 432 | if (!_inLoop) |
430 | { | 433 | { |
431 | _inLoop = true; | 434 | _inLoop = true; |
432 | qApp->enter_loop(); | 435 | qApp->enter_loop(); |
433 | } | 436 | } |
434 | 437 | ||
435 | } | 438 | } |
436 | 439 | ||
437 | QString ViewMail::deHtml(const QString &string) | 440 | QString ViewMail::deHtml(const QString &string) |
438 | { | 441 | { |
439 | QString string_ = string; | 442 | QString string_ = string; |
440 | string_.replace(QRegExp("&"), "&"); | 443 | string_.replace(QRegExp("&"), "&"); |
441 | string_.replace(QRegExp("<"), "<"); | 444 | string_.replace(QRegExp("<"), "<"); |
442 | string_.replace(QRegExp(">"), ">"); | 445 | string_.replace(QRegExp(">"), ">"); |
443 | string_.replace(QRegExp("\\n"), "<br>"); | 446 | string_.replace(QRegExp("\\n"), "<br>"); |
444 | return string_; | 447 | return string_; |
445 | } | 448 | } |
446 | 449 | ||
447 | void ViewMail::slotReply() | 450 | void ViewMail::slotReply() |
448 | { | 451 | { |
449 | if (!m_gotBody) | 452 | if (!m_gotBody) |
450 | { | 453 | { |
451 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); | 454 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
452 | return; | 455 | return; |
453 | } | 456 | } |
454 | 457 | ||
455 | QString rtext; | 458 | QString rtext; |
456 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 459 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
457 | .arg( m_mail[0] ) | 460 | .arg( m_mail[0] ) |
458 | .arg( m_mail[3] ); | 461 | .arg( m_mail[3] ); |
459 | 462 | ||
460 | QString text = m_mail[2]; | 463 | QString text = m_mail[2]; |
461 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 464 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
462 | QStringList::Iterator it; | 465 | QStringList::Iterator it; |
463 | for (it = lines.begin(); it != lines.end(); it++) | 466 | for (it = lines.begin(); it != lines.end(); it++) |
464 | { | 467 | { |
465 | rtext += "> " + *it + "\n"; | 468 | rtext += "> " + *it + "\n"; |
466 | } | 469 | } |
467 | rtext += "\n"; | 470 | rtext += "\n"; |
468 | 471 | ||
469 | QString prefix; | 472 | QString prefix; |
470 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 473 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
471 | else prefix = "Re: "; // no i18n on purpose | 474 | else prefix = "Re: "; // no i18n on purpose |
472 | 475 | ||
473 | Settings *settings = new Settings(); | 476 | Settings *settings = new Settings(); |
474 | ComposeMail composer( settings ,this, 0, true); | 477 | ComposeMail composer( settings ,this, 0, true); |
475 | if (m_recMail->Replyto().isEmpty()) { | 478 | if (m_recMail->Replyto().isEmpty()) { |
476 | composer.setTo(m_recMail->getFrom()); | 479 | composer.setTo(m_recMail->getFrom()); |
477 | } else { | 480 | } else { |
478 | composer.setTo(m_recMail->Replyto()); | 481 | composer.setTo(m_recMail->Replyto()); |
479 | } | 482 | } |
480 | composer.setSubject( prefix + m_mail[1] ); | 483 | composer.setSubject( prefix + m_mail[1] ); |
481 | composer.setMessage( rtext ); | 484 | composer.setMessage( rtext ); |
482 | composer.setInReplyTo(m_recMail->Msgid()); | 485 | composer.setInReplyTo(m_recMail->Msgid()); |
483 | composer.setCharset( m_body->getCharset() ); | 486 | composer.setCharset( m_body->getCharset() ); |
484 | 487 | ||
485 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 488 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
486 | { | 489 | { |
487 | m_recMail->Wrapper()->answeredMail(m_recMail); | 490 | m_recMail->Wrapper()->answeredMail(m_recMail); |
488 | } | 491 | } |
489 | delete settings; | 492 | delete settings; |
490 | } | 493 | } |
491 | 494 | ||
492 | void ViewMail::slotForward() | 495 | void ViewMail::slotForward() |
493 | { | 496 | { |
494 | if (!m_gotBody) | 497 | if (!m_gotBody) |
495 | { | 498 | { |
496 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); | 499 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
497 | return; | 500 | return; |
498 | } | 501 | } |
499 | 502 | ||
500 | QString ftext; | 503 | QString ftext; |
501 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 504 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
502 | .arg( m_mail[0] ); | 505 | .arg( m_mail[0] ); |
503 | if (!m_mail[3].isNull()) | 506 | if (!m_mail[3].isNull()) |
504 | ftext += QString("Date: %1\n") | 507 | ftext += QString("Date: %1\n") |
505 | .arg( m_mail[3] ); | 508 | .arg( m_mail[3] ); |
506 | if (!m_mail[0].isNull()) | 509 | if (!m_mail[0].isNull()) |
507 | ftext += QString("From: %1\n") | 510 | ftext += QString("From: %1\n") |
508 | .arg( m_mail[0] ); | 511 | .arg( m_mail[0] ); |
509 | if (!m_mail[1].isNull()) | 512 | if (!m_mail[1].isNull()) |