summaryrefslogtreecommitdiff
path: root/noncore/net/mail/viewmail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/viewmail.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp151
1 files changed, 97 insertions, 54 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 99965d4..f015228 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1 +1,15 @@
1#include "composemail.h"
2#include "viewmail.h"
3#include "accountview.h"
4
5/* OPIE */
6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h>
9
10#include <opie2/ofiledialog.h>
11#include <qpe/config.h>
12#include <qpe/qpeapplication.h>
13
14/* QT */
1#include <qtextbrowser.h> 15#include <qtextbrowser.h>
@@ -9,13 +23,2 @@
9 23
10#include <qpe/config.h>
11
12#include <opie2/ofiledialog.h>
13
14#include <libmailwrapper/settings.h>
15#include "composemail.h"
16#include "viewmail.h"
17#include <libmailwrapper/abstractmail.h>
18#include "accountview.h"
19#include <libmailwrapper/mailtypes.h>
20
21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 24AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
@@ -48,3 +51,4 @@ bool AttachItem::isParentof(const QValueList<int>&path)
48 if (path.count()!=_path.count()+1) return false; 51 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) { 52 for (unsigned int i=0; i < _path.count();++i)
53 {
50 if (_path[i]!=path[i]) return false; 54 if (_path[i]!=path[i]) return false;
@@ -57,3 +61,4 @@ AttachItem* ViewMail::searchParent(const QValueList<int>&path)
57 QListViewItemIterator it( attachments ); 61 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) { 62 for ( ; it.current(); ++it )
63 {
59 AttachItem*ati = (AttachItem*)it.current(); 64 AttachItem*ati = (AttachItem*)it.current();
@@ -70,3 +75,4 @@ AttachItem* ViewMail::lastChild(AttachItem*parent)
70 AttachItem*temp=0; 75 AttachItem*temp=0;
71 while( (temp=(AttachItem*)item->nextSibling())) { 76 while( (temp=(AttachItem*)item->nextSibling()))
77 {
72 item = temp; 78 item = temp;
@@ -76,3 +82,4 @@ AttachItem* ViewMail::lastChild(AttachItem*parent)
76 82
77void ViewMail::setBody( RecBody body ) { 83void ViewMail::setBody( RecBody body )
84{
78 85
@@ -82,3 +89,4 @@ attachbutton->setEnabled(body.Parts().count()>0);
82attachments->setEnabled(body.Parts().count()>0); 89attachments->setEnabled(body.Parts().count()>0);
83if (body.Parts().count()==0) { 90 if (body.Parts().count()==0)
91 {
84 return; 92 return;
@@ -93,3 +101,4 @@ w=0;
93 101
94while (s>1024) { 102 while (s>1024)
103 {
95 s/=1024; 104 s/=1024;
@@ -100,3 +109,4 @@ while (s>1024) {
100QString q=""; 109QString q="";
101switch(w) { 110 switch(w)
111 {
102case 1: 112case 1:
@@ -126,8 +136,11 @@ QString filename = "";
126 136
127for (unsigned int i = 0; i < body.Parts().count();++i) { 137 for (unsigned int i = 0; i < body.Parts().count();++i)
138 {
128 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 139 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
129 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 140 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
130 for (;it!=body.Parts()[i].Parameters().end();++it) { 141 for (;it!=body.Parts()[i].Parameters().end();++it)
142 {
131 qDebug(it.key()); 143 qDebug(it.key());
132 if (it.key().lower()=="name") { 144 if (it.key().lower()=="name")
145 {
133 filename=it.data(); 146 filename=it.data();
@@ -137,3 +150,4 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
137 w = 0; 150 w = 0;
138 while (s>1024) { 151 while (s>1024)
152 {
139 s/=1024; 153 s/=1024;
@@ -142,3 +156,4 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
142 } 156 }
143 switch(w) { 157 switch(w)
158 {
144 case 1: 159 case 1:
@@ -159,3 +174,4 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
159 parentItem = searchParent(body.Parts()[i].Positionlist()); 174 parentItem = searchParent(body.Parts()[i].Positionlist());
160 if (parentItem) { 175 if (parentItem)
176 {
161 AttachItem*temp = lastChild(parentItem); 177 AttachItem*temp = lastChild(parentItem);
@@ -165,3 +181,5 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
165 curItem = parentItem; 181 curItem = parentItem;
166 } else { 182 }
183 else
184 {
167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 185 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
@@ -172,3 +190,4 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
172 190
173void ViewMail::slotShowHtml( bool state ) { 191void ViewMail::slotShowHtml( bool state )
192{
174 m_showHtml = state; 193 m_showHtml = state;
@@ -177,3 +196,4 @@ void ViewMail::slotShowHtml( bool state ) {
177 196
178void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { 197void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
198{
179 if (!item ) 199 if (!item )
@@ -181,3 +201,4 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
181 201
182 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 202 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
203 {
183 setText(); 204 setText();
@@ -188,3 +209,4 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
188 209
189 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { 210 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
211 {
190 menu->insertItem( tr( "Show Text" ), 1 ); 212 menu->insertItem( tr( "Show Text" ), 1 );
@@ -196,5 +218,7 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
196 218
197 switch(ret) { 219 switch(ret)
220 {
198 case 0: 221 case 0:
199 { MimeTypes types; 222 {
223 MimeTypes types;
200 types.insert( "all", "*" ); 224 types.insert( "all", "*" );
@@ -203,5 +227,7 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
203 227
204 if( !str.isEmpty() ) { 228 if( !str.isEmpty() )
229 {
205 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 230 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
206 if (content) { 231 if (content)
232 {
207 QFile output(str); 233 QFile output(str);
@@ -217,6 +243,10 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
217 case 1: 243 case 1:
218 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 244 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
245 {
219 setText(); 246 setText();
220 } else { 247 }
221 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 248 else
249 {
250 if ( m_recMail.Wrapper() != 0l )
251 { // make sure that there is a wrapper , even after delete or simular actions
222 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 252 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
@@ -230,3 +260,4 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
230 260
231void ViewMail::setMail( RecMail mail ) { 261void ViewMail::setMail( RecMail mail )
262{
232 263
@@ -266,3 +297,4 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
266 297
267void ViewMail::readConfig() { 298void ViewMail::readConfig()
299{
268 Config cfg( "mail" ); 300 Config cfg( "mail" );
@@ -280,9 +312,12 @@ void ViewMail::setText()
280 312
281 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 313 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
314 {
282 toString += (*it); 315 toString += (*it);
283 } 316 }
284 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 317 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
318 {
285 ccString += (*it); 319 ccString += (*it);
286 } 320 }
287 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 321 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
322 {
288 bccString += (*it); 323 bccString += (*it);
@@ -302,5 +337,8 @@ void ViewMail::setText()
302 337
303 if ( !m_showHtml ) { 338 if ( !m_showHtml )
339 {
304 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 340 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
305 } else { 341 }
342 else
343 {
306 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 344 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
@@ -322,3 +360,4 @@ void ViewMail::hide()
322 360
323 if (_inLoop) { 361 if (_inLoop)
362 {
324 _inLoop = false; 363 _inLoop = false;
@@ -334,3 +373,4 @@ void ViewMail::exec()
334 373
335 if (!_inLoop) { 374 if (!_inLoop)
375 {
336 _inLoop = true; 376 _inLoop = true;
@@ -353,3 +393,4 @@ void ViewMail::slotReply()
353{ 393{
354 if (!m_gotBody) { 394 if (!m_gotBody)
395 {
355 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 396 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
@@ -366,3 +407,4 @@ void ViewMail::slotReply()
366 QStringList::Iterator it; 407 QStringList::Iterator it;
367 for (it = lines.begin(); it != lines.end(); it++) { 408 for (it = lines.begin(); it != lines.end(); it++)
409 {
368 rtext += "> " + *it + "\n"; 410 rtext += "> " + *it + "\n";
@@ -380,4 +422,4 @@ void ViewMail::slotReply()
380 composer.setMessage( rtext ); 422 composer.setMessage( rtext );
381 composer.showMaximized(); 423 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
382 if ( QDialog::Accepted==composer.exec()) { 424 {
383 m_recMail.Wrapper()->answeredMail(m_recMail); 425 m_recMail.Wrapper()->answeredMail(m_recMail);
@@ -388,3 +430,4 @@ void ViewMail::slotForward()
388{ 430{
389 if (!m_gotBody) { 431 if (!m_gotBody)
432 {
390 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 433 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
@@ -415,5 +458,4 @@ void ViewMail::slotForward()
415 composer.setMessage( ftext ); 458 composer.setMessage( ftext );
416 composer.showMaximized(); 459 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ))
417 if ( QDialog::Accepted==composer.exec()) { 460 {
418
419 } 461 }
@@ -423,3 +465,4 @@ void ViewMail::slotDeleteMail( )
423{ 465{
424 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 ) { 466 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 )
467 {
425 m_recMail.Wrapper()->deleteMail( m_recMail ); 468 m_recMail.Wrapper()->deleteMail( m_recMail );