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.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index a64a168..5206220 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -187,35 +187,35 @@ void ViewMail::setBody(const RecBodyP&body )
187 } 187 }
188 else 188 else
189 { 189 {
190 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 190 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
191 } 191 }
192 } 192 }
193} 193}
194 194
195 195
196void ViewMail::slotShowHtml( bool state ) 196void ViewMail::slotShowHtml( bool state )
197{ 197{
198 m_showHtml = state; 198 m_showHtml = state;
199 setText(); 199 setMainText();
200} 200}
201 201
202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 202void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
203{ 203{
204 if (!item ) 204 if (!item )
205 return; 205 return;
206 206
207 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 207 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
208 { 208 {
209 setText(); 209 setMainText();
210 return; 210 return;
211 } 211 }
212 QPopupMenu *menu = new QPopupMenu(); 212 QPopupMenu *menu = new QPopupMenu();
213 int ret=0; 213 int ret=0;
214 214
215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 215 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
216 { 216 {
217 menu->insertItem( tr( "Show Text" ), 1 ); 217 menu->insertItem( tr( "Show Text" ), 1 );
218 } 218 }
219 if (item->text(0).left(6)=="image/") { 219 if (item->text(0).left(6)=="image/") {
220 menu->insertItem(tr("Display image preview"),2); 220 menu->insertItem(tr("Display image preview"),2);
221 } 221 }
@@ -241,24 +241,33 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
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 if (m_lastimagepart== (( AttachItem* )item )->Partnumber()) {
254 if (m_lastdlg) {
255 setUpdatesEnabled(false);
256 browser->hide();
257 m_lastdlg->show();
258 setUpdatesEnabled(true);
259 return;
260 }
261 }
253 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); 262 QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++);
254 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 263 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
255 if (content && content->Length()) { 264 if (content && content->Length()) {
256 QFile output(tmpfile); 265 QFile output(tmpfile);
257 output.open(IO_WriteOnly); 266 output.open(IO_WriteOnly);
258 output.writeBlock(content->Content(),content->Length()); 267 output.writeBlock(content->Content(),content->Length());
259 output.close(); 268 output.close();
260 delete content; 269 delete content;
261 if (!m_PicsInline) { 270 if (!m_PicsInline) {
262 MailImageDlg iview(""); 271 MailImageDlg iview("");
263 iview.setName(tmpfile); 272 iview.setName(tmpfile);
264 QPEApplication::execDialog(&iview); 273 QPEApplication::execDialog(&iview);
@@ -267,120 +276,136 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
267 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false); 276 m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false);
268 m_lastdlg->setAutoScale(true); 277 m_lastdlg->setAutoScale(true);
269 } 278 }
270 //m_lastdlg->setImage(""); 279 //m_lastdlg->setImage("");
271 m_lastdlg->setImage(tmpfile); 280 m_lastdlg->setImage(tmpfile);
272 browser->hide(); 281 browser->hide();
273 m_lastdlg->show(); 282 m_lastdlg->show();
274 } 283 }
275 output.remove(); 284 output.remove();
276 } else { 285 } else {
277 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); 286 QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment"));
278 } 287 }
288 m_lastimagepart=(( AttachItem* )item )->Partnumber();
279 } 289 }
280 break; 290 break;
281 case 1: 291 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 292 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 293 {
284 setText(); 294 setMainText();
285 } 295 }
286 else 296 else
287 { 297 {
288 if ( m_recMail->Wrapper() != 0l ) 298 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 299 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 300 if (m_lastdlg) {
301 m_lastdlg->hide();
302 browser->show();
303 }
304 if (m_lasttextpart == ( ( AttachItem* )item )->Partnumber() ) return;
305 m_lasttextpart = ( ( AttachItem* )item )->Partnumber();
306 QString s = m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );;
307 if (item->text(0).right(4)!="html") {
308 s = QString("<html><body>\n<font face=fixed>%1</font></body></html>").arg(QStyleSheet::convertFromPlainText(s));
309 }
310 browser->setText(s);
291 } 311 }
292 } 312 }
293 break; 313 break;
294 } 314 }
295 delete menu; 315 delete menu;
296} 316}
297 317
298 318
299void ViewMail::setMail(const RecMailP&mail ) 319void ViewMail::setMail(const RecMailP&mail )
300{ 320{
301 321
302 m_recMail = mail; 322 m_recMail = mail;
303 323
304 m_mail[0] = mail->getFrom(); 324 m_mail[0] = mail->getFrom();
305 m_mail[1] = mail->getSubject(); 325 m_mail[1] = mail->getSubject();
306 m_mail[3] = mail->getStringDate(); 326 m_mail[3] = mail->getStringDate();
307 m_mail[4] = mail->Msgid(); 327 m_mail[4] = mail->Msgid();
308 328
309 m_mail2[0] = mail->To(); 329 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 330 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 331 m_mail2[2] = mail->Bcc();
312 332
313 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); 333 setCaption(tr("E-Mail by %1").arg( m_mail[0] ) );
314 setText(); 334 setMainText();
315} 335}
316 336
317 337
318 338
319ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 339ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
320 : ViewMailBase(parent, name, fl), _inLoop(false) 340 : ViewMailBase(parent, name, fl), _inLoop(false)
321{ 341{
322 m_gotBody = false; 342 m_gotBody = false;
323 deleted = false; 343 deleted = false;
324 344
325 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 345 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
326 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 346 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
327 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 347 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
328 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 348 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
329 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); 349 connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) );
330 350
331 attachments->setEnabled(m_gotBody); 351 attachments->setEnabled(m_gotBody);
332 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) ) );
333 m_lastdlg = 0; 353 m_lastdlg = 0;
334 _icounter = 0; 354 _icounter = 0;
355 m_lastimagepart = -1;
356 m_lasttextpart = -2;
335 357
336 readConfig(); 358 readConfig();
337 attachments->setSorting(-1); 359 attachments->setSorting(-1);
338} 360}
339 361
340void ViewMail::slotImageInline(bool how) 362void ViewMail::slotImageInline(bool how)
341{ 363{
342 Config cfg( "mail" ); 364 Config cfg( "mail" );
343 cfg.writeEntry( "showPicsInline", how); 365 cfg.writeEntry( "showPicsInline", how);
344 m_PicsInline = how; 366 m_PicsInline = how;
345 if (m_lastdlg&&!how) { 367 if (m_lastdlg&&!how) {
346 browser->show(); 368 browser->show();
347 m_lastdlg->hide(); 369 m_lastdlg->hide();
348 m_lastdlg->reparent(0,QPoint(0,0),false); 370 m_lastdlg->reparent(0,QPoint(0,0),false);
349 delete m_lastdlg; 371 delete m_lastdlg;
350 m_lastdlg = 0; 372 m_lastdlg = 0;
373 m_lastimagepart = -1;
351 } 374 }
352} 375}
353 376
354void ViewMail::readConfig() 377void ViewMail::readConfig()
355{ 378{
356 Config cfg( "mail" ); 379 Config cfg( "mail" );
357 cfg.setGroup( "Settings" ); 380 cfg.setGroup( "Settings" );
358 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 381 m_showHtml = cfg.readBoolEntry( "showHtml", false );
359 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); 382 m_PicsInline = cfg.readBoolEntry( "showPicsInline", true );
360 showPicsInline->setOn(m_PicsInline); 383 showPicsInline->setOn(m_PicsInline);
361 showHtml->setOn( m_showHtml ); 384 showHtml->setOn( m_showHtml );
362} 385}
363 386
364void ViewMail::setText() 387void ViewMail::setMainText()
365{ 388{
366 QString toString; 389 QString toString;
367 QString ccString; 390 QString ccString;
368 QString bccString; 391 QString bccString;
369 QString mailHtml; 392 QString mailHtml;
370 393
371 if (m_lastdlg) { 394 if (m_lastdlg) {
372 m_lastdlg->hide(); 395 m_lastdlg->hide();
373 } 396 }
374 browser->show(); 397 browser->show();
398 if (m_lasttextpart == -1) return;
399 m_lasttextpart = -1;
375 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 400 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
376 { 401 {
377 toString += (*it); 402 toString += (*it);
378 } 403 }
379 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 404 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
380 { 405 {
381 ccString += (*it); 406 ccString += (*it);
382 } 407 }
383 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 408 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
384 { 409 {
385 bccString += (*it); 410 bccString += (*it);
386 } 411 }