Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 7267bcb..ce694d5 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,44 +1,46 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <libmailwrapper/settings.h> | 4 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 5 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 6 | #include <libmailwrapper/mailtypes.h> |
8 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | #include <opie2/ofiledialog.h> | 10 | #include <opie2/ofiledialog.h> |
11 | #include <opie2/oimagescrollview.h> | ||
11 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
12 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
13 | 14 | ||
14 | /* QT */ | 15 | /* QT */ |
15 | #include <qtextbrowser.h> | 16 | #include <qtextbrowser.h> |
16 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
17 | #include <qtextstream.h> | 18 | #include <qtextstream.h> |
18 | #include <qaction.h> | 19 | #include <qaction.h> |
19 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
20 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qlayout.h> | ||
21 | 23 | ||
22 | using namespace Opie::Ui; | 24 | using namespace Opie::Ui; |
23 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
24 | 26 | ||
25 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 27 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
26 | const QString&fsize,int num,const QValueList<int>&path) | 28 | const QString&fsize,int num,const QValueList<int>&path) |
27 | : QListViewItem(parent,after),_partNum(num) | 29 | : QListViewItem(parent,after),_partNum(num) |
28 | { | 30 | { |
29 | _path=path; | 31 | _path=path; |
30 | setText(0, mime); | 32 | setText(0, mime); |
31 | setText(1, desc); | 33 | setText(1, desc); |
32 | setText(2, file); | 34 | setText(2, file); |
33 | setText(3, fsize); | 35 | setText(3, fsize); |
34 | } | 36 | } |
35 | 37 | ||
36 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 38 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
37 | const QString&fsize,int num,const QValueList<int>&path) | 39 | const QString&fsize,int num,const QValueList<int>&path) |
38 | : QListViewItem(parent,after),_partNum(num) | 40 | : QListViewItem(parent,after),_partNum(num) |
39 | { | 41 | { |
40 | _path=path; | 42 | _path=path; |
41 | setText(0, mime); | 43 | setText(0, mime); |
42 | setText(1, desc); | 44 | setText(1, desc); |
43 | setText(2, file); | 45 | setText(2, file); |
44 | setText(3, fsize); | 46 | setText(3, fsize); |
@@ -192,77 +194,97 @@ void ViewMail::setBody(const RecBodyP&body ) | |||
192 | 194 | ||
193 | void ViewMail::slotShowHtml( bool state ) | 195 | void ViewMail::slotShowHtml( bool state ) |
194 | { | 196 | { |
195 | m_showHtml = state; | 197 | m_showHtml = state; |
196 | setText(); | 198 | setText(); |
197 | } | 199 | } |
198 | 200 | ||
199 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 201 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
200 | { | 202 | { |
201 | if (!item ) | 203 | if (!item ) |
202 | return; | 204 | return; |
203 | 205 | ||
204 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 206 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
205 | { | 207 | { |
206 | setText(); | 208 | setText(); |
207 | return; | 209 | return; |
208 | } | 210 | } |
209 | QPopupMenu *menu = new QPopupMenu(); | 211 | QPopupMenu *menu = new QPopupMenu(); |
210 | int ret=0; | 212 | int ret=0; |
211 | 213 | ||
212 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 214 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
213 | { | 215 | { |
214 | menu->insertItem( tr( "Show Text" ), 1 ); | 216 | menu->insertItem( tr( "Show Text" ), 1 ); |
215 | } | 217 | } |
218 | if (item->text(0).left(6)=="image/") { | ||
219 | menu->insertItem(tr("Display image preview"),2); | ||
220 | } | ||
216 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 221 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
217 | menu->insertSeparator(1); | 222 | menu->insertSeparator(1); |
218 | 223 | ||
219 | ret = menu->exec( point, 0 ); | 224 | ret = menu->exec( point, 0 ); |
220 | 225 | ||
221 | switch(ret) | 226 | switch(ret) |
222 | { | 227 | { |
223 | case 0: | 228 | case 0: |
224 | { | 229 | { |
225 | MimeTypes types; | 230 | MimeTypes types; |
226 | types.insert( "all", "*" ); | 231 | types.insert( "all", "*" ); |
227 | QString str = OFileDialog::getSaveFileName( 1, | 232 | QString str = OFileDialog::getSaveFileName( 1, |
228 | "/", item->text( 2 ) , types, 0 ); | 233 | "/", item->text( 2 ) , types, 0 ); |
229 | 234 | ||
230 | if( !str.isEmpty() ) | 235 | if( !str.isEmpty() ) |
231 | { | 236 | { |
232 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 237 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
233 | if (content) | 238 | if (content) |
234 | { | 239 | { |
235 | QFile output(str); | 240 | QFile output(str); |
236 | output.open(IO_WriteOnly); | 241 | output.open(IO_WriteOnly); |
237 | output.writeBlock(content->Content(),content->Length()); | 242 | output.writeBlock(content->Content(),content->Length()); |
238 | output.close(); | 243 | output.close(); |
239 | delete content; | 244 | delete content; |
240 | } | 245 | } |
241 | } | 246 | } |
242 | } | 247 | } |
243 | break ; | 248 | break ; |
244 | 249 | ||
250 | case 2: | ||
251 | { | ||
252 | QString tmpfile = "/tmp/opiemail-image"; | ||
253 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | ||
254 | if (content) { | ||
255 | QFile output(tmpfile); | ||
256 | output.open(IO_WriteOnly); | ||
257 | output.writeBlock(content->Content(),content->Length()); | ||
258 | output.close(); | ||
259 | delete content; | ||
260 | MailImageDlg iview(""); | ||
261 | iview.setName(tmpfile); | ||
262 | QPEApplication::execDialog(&iview); | ||
263 | output.remove(); | ||
264 | } | ||
265 | } | ||
266 | break; | ||
245 | case 1: | 267 | case 1: |
246 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 268 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
247 | { | 269 | { |
248 | setText(); | 270 | setText(); |
249 | } | 271 | } |
250 | else | 272 | else |
251 | { | 273 | { |
252 | if ( m_recMail->Wrapper() != 0l ) | 274 | if ( m_recMail->Wrapper() != 0l ) |
253 | { // make sure that there is a wrapper , even after delete or simular actions | 275 | { // make sure that there is a wrapper , even after delete or simular actions |
254 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 276 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
255 | } | 277 | } |
256 | } | 278 | } |
257 | break; | 279 | break; |
258 | } | 280 | } |
259 | delete menu; | 281 | delete menu; |
260 | } | 282 | } |
261 | 283 | ||
262 | 284 | ||
263 | void ViewMail::setMail(const RecMailP&mail ) | 285 | void ViewMail::setMail(const RecMailP&mail ) |
264 | { | 286 | { |
265 | 287 | ||
266 | m_recMail = mail; | 288 | m_recMail = mail; |
267 | 289 | ||
268 | m_mail[0] = mail->getFrom(); | 290 | m_mail[0] = mail->getFrom(); |
@@ -457,24 +479,43 @@ void ViewMail::slotForward() | |||
457 | 479 | ||
458 | ftext += QString("\n%1\n") | 480 | ftext += QString("\n%1\n") |
459 | .arg( m_mail[2]); | 481 | .arg( m_mail[2]); |
460 | 482 | ||
461 | ftext += QString("----- End forwarded message -----\n"); | 483 | ftext += QString("----- End forwarded message -----\n"); |
462 | 484 | ||
463 | Settings *settings = new Settings(); | 485 | Settings *settings = new Settings(); |
464 | ComposeMail composer( settings ,this, 0, true); | 486 | ComposeMail composer( settings ,this, 0, true); |
465 | composer.setSubject( "Fwd: " + m_mail[1] ); | 487 | composer.setSubject( "Fwd: " + m_mail[1] ); |
466 | composer.setMessage( ftext ); | 488 | composer.setMessage( ftext ); |
467 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) | 489 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
468 | { | 490 | { |
469 | } | 491 | } |
470 | } | 492 | } |
471 | 493 | ||
472 | void ViewMail::slotDeleteMail( ) | 494 | void ViewMail::slotDeleteMail( ) |
473 | { | 495 | { |
474 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 496 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
475 | { | 497 | { |
476 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 498 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
477 | hide(); | 499 | hide(); |
478 | deleted = true; | 500 | deleted = true; |
479 | } | 501 | } |
480 | } | 502 | } |
503 | |||
504 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | ||
505 | : Opie::Ui::ODialog(parent,name,modal,f) | ||
506 | { | ||
507 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | ||
508 | dlglayout->setSpacing(2); | ||
509 | dlglayout->setMargin(1); | ||
510 | m_imageview = new Opie::MM::OImageScrollView(this); | ||
511 | dlglayout->addWidget(m_imageview); | ||
512 | } | ||
513 | |||
514 | MailImageDlg::~MailImageDlg() | ||
515 | { | ||
516 | } | ||
517 | |||
518 | void MailImageDlg::setName(const QString&fname) | ||
519 | { | ||
520 | m_imageview->setImage(fname); | ||
521 | } | ||