summaryrefslogtreecommitdiff
path: root/noncore/net/mail/viewmail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp46
1 files changed, 41 insertions, 5 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d2f1584..a64a168 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -229,60 +229,73 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
229 case 0: 229 case 0:
230 { 230 {
231 MimeTypes types; 231 MimeTypes types;
232 types.insert( "all", "*" ); 232 types.insert( "all", "*" );
233 QString str = OFileDialog::getSaveFileName( 1, 233 QString str = OFileDialog::getSaveFileName( 1,
234 "/", item->text( 2 ) , types, 0 ); 234 "/", item->text( 2 ) , types, 0 );
235 235
236 if( !str.isEmpty() ) 236 if( !str.isEmpty() )
237 { 237 {
238 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 238 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
239 if (content) 239 if (content)
240 { 240 {
241 QFile output(str); 241 QFile output(str);
242 output.open(IO_WriteOnly); 242 output.open(IO_WriteOnly);
243 output.writeBlock(content->Content(),content->Length()); 243 output.writeBlock(content->Content(),content->Length());
244 output.close(); 244 output.close();
245 delete content; 245 delete content;
246 } 246 }
247 } 247 }
248 } 248 }
249 break ; 249 break ;
250 250
251 case 2: 251 case 2:
252 { 252 {
253 QString tmpfile = "/tmp/opiemail-image"; 253 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++);
254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
255 if (content) { 255 if (content && content->Length()) {
256 QFile output(tmpfile); 256 QFile output(tmpfile);
257 output.open(IO_WriteOnly); 257 output.open(IO_WriteOnly);
258 output.writeBlock(content->Content(),content->Length()); 258 output.writeBlock(content->Content(),content->Length());
259 output.close(); 259 output.close();
260 delete content; 260 delete content;
261 MailImageDlg iview(""); 261 if (!m_PicsInline) {
262 iview.setName(tmpfile); 262 MailImageDlg iview("");
263 QPEApplication::execDialog(&iview); 263 iview.setName(tmpfile);
264 QPEApplication::execDialog(&iview);
265 } else {
266 if (!m_lastdlg) {
267 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false);
268 m_lastdlg->setAutoScale(true);
269 }
270 //m_lastdlg->setImage("");
271 m_lastdlg->setImage(tmpfile);
272 browser->hide();
273 m_lastdlg->show();
274 }
264 output.remove(); 275 output.remove();
276 } else {
277 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
265 } 278 }
266 } 279 }
267 break; 280 break;
268 case 1: 281 case 1:
269 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
270 { 283 {
271 setText(); 284 setText();
272 } 285 }
273 else 286 else
274 { 287 {
275 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
276 { // make sure that there is a wrapper , even after delete or simular actions 289 { // make sure that there is a wrapper , even after delete or simular actions
277 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
278 } 291 }
279 } 292 }
280 break; 293 break;
281 } 294 }
282 delete menu; 295 delete menu;
283} 296}
284 297
285 298
286void ViewMail::setMail(const RecMailP&mail ) 299void ViewMail::setMail(const RecMailP&mail )
287{ 300{
288 301
@@ -292,71 +305,94 @@ void ViewMail::setMail(const RecMailP&mail )
292 m_mail[1] = mail->getSubject(); 305 m_mail[1] = mail->getSubject();
293 m_mail[3] = mail->getStringDate(); 306 m_mail[3] = mail->getStringDate();
294 m_mail[4] = mail->Msgid(); 307 m_mail[4] = mail->Msgid();
295 308
296 m_mail2[0] = mail->To(); 309 m_mail2[0] = mail->To();
297 m_mail2[1] = mail->CC(); 310 m_mail2[1] = mail->CC();
298 m_mail2[2] = mail->Bcc(); 311 m_mail2[2] = mail->Bcc();
299 312
300 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); 313 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
301 setText(); 314 setText();
302} 315}
303 316
304 317
305 318
306ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 319ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
307 : ViewMailBase(parent, name, fl), _inLoop(false) 320 : ViewMailBase(parent, name, fl), _inLoop(false)
308{ 321{
309 m_gotBody = false; 322 m_gotBody = false;
310 deleted = false; 323 deleted = false;
311 324
312 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 325 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
313 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 326 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
314 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 327 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
315 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 328 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
329 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
316 330
317 attachments->setEnabled(m_gotBody); 331 attachments->setEnabled(m_gotBody);
318 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 m_lastdlg = 0;
334 _icounter = 0;
319 335
320 readConfig(); 336 readConfig();
321 attachments->setSorting(-1); 337 attachments->setSorting(-1);
322} 338}
323 339
340void ViewMail::slotImageInline(bool how)
341{
342 Config cfg( "mail" );
343 cfg.writeEntry( "showPicsInline", how);
344 m_PicsInline = how;
345 if (m_lastdlg&&!how) {
346 browser->show();
347 m_lastdlg->hide();
348 m_lastdlg->reparent(0,QPoint(0,0),false);
349 delete m_lastdlg;
350 m_lastdlg = 0;
351 }
352}
353
324void ViewMail::readConfig() 354void ViewMail::readConfig()
325{ 355{
326 Config cfg( "mail" ); 356 Config cfg( "mail" );
327 cfg.setGroup( "Settings" ); 357 cfg.setGroup( "Settings" );
328 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 358 m_showHtml = cfg.readBoolEntry( "showHtml", false );
359 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true );
360 showPicsInline->setOn(m_PicsInline);
329 showHtml->setOn( m_showHtml ); 361 showHtml->setOn( m_showHtml );
330} 362}
331 363
332void ViewMail::setText() 364void ViewMail::setText()
333{ 365{
334 QString toString; 366 QString toString;
335 QString ccString; 367 QString ccString;
336 QString bccString; 368 QString bccString;
337 QString mailHtml; 369 QString mailHtml;
338 370
371 if (m_lastdlg) {
372 m_lastdlg->hide();
373 }
374 browser->show();
339 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 375 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
340 { 376 {
341 toString += (*it); 377 toString += (*it);
342 } 378 }
343 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 379 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
344 { 380 {
345 ccString += (*it); 381 ccString += (*it);
346 } 382 }
347 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 383 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
348 { 384 {
349 bccString += (*it); 385 bccString += (*it);
350 } 386 }
351 browser->setTextFormat(Qt::RichText); 387 browser->setTextFormat(Qt::RichText);
352 mailHtml = "<html><body>" 388 mailHtml = "<html><body>"
353 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 389 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
354 "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>" 390 "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>"
355 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 391 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
356 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 392 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
357 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 393 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
358 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 394 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
359 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 395 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
360 "</td></tr></table>"; 396 "</td></tr></table>";
361 if ( !m_showHtml ) { 397 if ( !m_showHtml ) {
362 browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" ); 398 browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" );