summaryrefslogtreecommitdiffabout
path: root/kmicromail/viewmail.cpp
Unidiff
Diffstat (limited to 'kmicromail/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/viewmail.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 703711d..67b77f8 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -1,526 +1,527 @@
1// CHANGED 2004-08-06 Lutz Rogowski
1#include "composemail.h" 2#include "composemail.h"
2#include "viewmail.h" 3#include "viewmail.h"
3 4
4#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
5#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
6#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
7#include <kapplication.h> 8#include <kapplication.h>
8 9
9/* OPIE */ 10/* OPIE */
10//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
11//#include <opie2/ofiledialog.h> 12//#include <opie2/ofiledialog.h>
12//#include <opie2/oimagescrollview.h> 13//#include <opie2/oimagescrollview.h>
13 14
14#include <kfiledialog.h> 15#include <kfiledialog.h>
15#include <kdialog.h> 16#include <kdialog.h>
16 17
17#include <qpe/config.h> 18#include <qpe/config.h>
18#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
19 20
20/* QT */ 21/* QT */
21#include <qtextbrowser.h> 22#include <qtextbrowser.h>
22#include <qmessagebox.h> 23#include <qmessagebox.h>
23#include <qtextstream.h> 24#include <qtextstream.h>
24#include <qaction.h> 25#include <qaction.h>
25#include <qpopupmenu.h> 26#include <qpopupmenu.h>
26#include <qfile.h> 27#include <qfile.h>
27#include <qlayout.h> 28#include <qlayout.h>
28 29
29//using namespace Opie::Ui; 30//using namespace Opie::Ui;
30//using namespace Opie::Core; 31//using namespace Opie::Core;
31 32
32AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 33AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 34 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 35 : QListViewItem(parent,after),_partNum(num)
35{ 36{
36 _path=path; 37 _path=path;
37 setText(0, mime); 38 setText(0, mime);
38 setText(1, desc); 39 setText(1, desc);
39 setText(2, file); 40 setText(2, file);
40 setText(3, fsize); 41 setText(3, fsize);
41} 42}
42 43
43AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 44AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
44 const QString&fsize,int num,const QValueList<int>&path) 45 const QString&fsize,int num,const QValueList<int>&path)
45 : QListViewItem(parent,after),_partNum(num) 46 : QListViewItem(parent,after),_partNum(num)
46{ 47{
47 _path=path; 48 _path=path;
48 setText(0, mime); 49 setText(0, mime);
49 setText(1, desc); 50 setText(1, desc);
50 setText(2, file); 51 setText(2, file);
51 setText(3, fsize); 52 setText(3, fsize);
52} 53}
53 54
54bool AttachItem::isParentof(const QValueList<int>&path) 55bool AttachItem::isParentof(const QValueList<int>&path)
55{ 56{
56 /* if not set, then no parent */ 57 /* if not set, then no parent */
57 if (path.count()==0||_path.count()==0) return false; 58 if (path.count()==0||_path.count()==0) return false;
58 /* the parent must have one digit less then a child */ 59 /* the parent must have one digit less then a child */
59 if (path.count()!=_path.count()+1) return false; 60 if (path.count()!=_path.count()+1) return false;
60 for (unsigned int i=0; i < _path.count();++i) 61 for (unsigned int i=0; i < _path.count();++i)
61 { 62 {
62 if (_path[i]!=path[i]) return false; 63 if (_path[i]!=path[i]) return false;
63 } 64 }
64 return true; 65 return true;
65} 66}
66 67
67AttachItem* ViewMail::searchParent(const QValueList<int>&path) 68AttachItem* ViewMail::searchParent(const QValueList<int>&path)
68{ 69{
69 QListViewItemIterator it( attachments ); 70 QListViewItemIterator it( attachments );
70 for ( ; it.current(); ++it ) 71 for ( ; it.current(); ++it )
71 { 72 {
72 AttachItem*ati = (AttachItem*)it.current(); 73 AttachItem*ati = (AttachItem*)it.current();
73 if (ati->isParentof(path)) return ati; 74 if (ati->isParentof(path)) return ati;
74 } 75 }
75 return 0; 76 return 0;
76} 77}
77 78
78AttachItem* ViewMail::lastChild(AttachItem*parent) 79AttachItem* ViewMail::lastChild(AttachItem*parent)
79{ 80{
80 if (!parent) return 0; 81 if (!parent) return 0;
81 AttachItem* item = (AttachItem*)parent->firstChild(); 82 AttachItem* item = (AttachItem*)parent->firstChild();
82 if (!item) return item; 83 if (!item) return item;
83 AttachItem*temp=0; 84 AttachItem*temp=0;
84 while( (temp=(AttachItem*)item->nextSibling())) 85 while( (temp=(AttachItem*)item->nextSibling()))
85 { 86 {
86 item = temp; 87 item = temp;
87 } 88 }
88 return item; 89 return item;
89} 90}
90 91
91void ViewMail::setBody(const RecBodyP&body ) 92void ViewMail::setBody(const RecBodyP&body )
92{ 93{
93 94
94 m_body = body; 95 m_body = body;
95 m_mail[2] = body->Bodytext(); 96 m_mail[2] = body->Bodytext();
96 attachbutton->setEnabled(body->Parts().count()>0); 97 attachbutton->setEnabled(body->Parts().count()>0);
97 attachments->setEnabled(body->Parts().count()>0); 98 attachments->setEnabled(body->Parts().count()>0);
98 if (body->Parts().count()==0) 99 if (body->Parts().count()==0)
99 { 100 {
100 return; 101 return;
101 } 102 }
102 AttachItem * curItem=0; 103 AttachItem * curItem=0;
103 AttachItem * parentItem = 0; 104 AttachItem * parentItem = 0;
104 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 105 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
105 QString desc,fsize; 106 QString desc,fsize;
106 double s = body->Description()->Size(); 107 double s = body->Description()->Size();
107 int w; 108 int w;
108 w=0; 109 w=0;
109 110
110 while (s>1024) 111 while (s>1024)
111 { 112 {
112 s/=1024; 113 s/=1024;
113 ++w; 114 ++w;
114 if (w>=2) break; 115 if (w>=2) break;
115 } 116 }
116 117
117 QString q=""; 118 QString q="";
118 switch(w) 119 switch(w)
119 { 120 {
120 case 1: 121 case 1:
121 q="k"; 122 q="k";
122 break; 123 break;
123 case 2: 124 case 2:
124 q="M"; 125 q="M";
125 break; 126 break;
126 default: 127 default:
127 break; 128 break;
128 } 129 }
129 130
130 { 131 {
131 /* I did not found a method to make a CONTENT reset on a QTextStream 132 /* I did not found a method to make a CONTENT reset on a QTextStream
132 so I use this construct that the stream will re-constructed in each 133 so I use this construct that the stream will re-constructed in each
133 loop. To let it work, the textstream is packed into a own area of 134 loop. To let it work, the textstream is packed into a own area of
134 code is it will be destructed after finishing its small job. 135 code is it will be destructed after finishing its small job.
135 */ 136 */
136 QTextOStream o(&fsize); 137 QTextOStream o(&fsize);
137 if (w>0) o.precision(2); else o.precision(0); 138 if (w>0) o.precision(2); else o.precision(0);
138 o.setf(QTextStream::fixed); 139 o.setf(QTextStream::fixed);
139 o << s << " " << q << "Byte"; 140 o << s << " " << q << "Byte";
140 } 141 }
141 142
142 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 143 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
143 QString filename = ""; 144 QString filename = "";
144 145
145 for (unsigned int i = 0; i < body->Parts().count();++i) 146 for (unsigned int i = 0; i < body->Parts().count();++i)
146 { 147 {
147 filename = ""; 148 filename = "";
148 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 149 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
149 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 150 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
150 for (;it!=body->Parts()[i]->Parameters().end();++it) 151 for (;it!=body->Parts()[i]->Parameters().end();++it)
151 { 152 {
152 if (it.key().lower()=="name") 153 if (it.key().lower()=="name")
153 { 154 {
154 filename=it.data(); 155 filename=it.data();
155 } 156 }
156 } 157 }
157 s = body->Parts()[i]->Size(); 158 s = body->Parts()[i]->Size();
158 w = 0; 159 w = 0;
159 while (s>1024) 160 while (s>1024)
160 { 161 {
161 s/=1024; 162 s/=1024;
162 ++w; 163 ++w;
163 if (w>=2) break; 164 if (w>=2) break;
164 } 165 }
165 switch(w) 166 switch(w)
166 { 167 {
167 case 1: 168 case 1:
168 q="k"; 169 q="k";
169 break; 170 break;
170 case 2: 171 case 2:
171 q="M"; 172 q="M";
172 break; 173 break;
173 default: 174 default:
174 q=""; 175 q="";
175 break; 176 break;
176 } 177 }
177 QTextOStream o(&fsize); 178 QTextOStream o(&fsize);
178 if (w>0) o.precision(2); else o.precision(0); 179 if (w>0) o.precision(2); else o.precision(0);
179 o.setf(QTextStream::fixed); 180 o.setf(QTextStream::fixed);
180 o << s << " " << q << "Byte"; 181 o << s << " " << q << "Byte";
181 desc = body->Parts()[i]->Description(); 182 desc = body->Parts()[i]->Description();
182 parentItem = searchParent(body->Parts()[i]->Positionlist()); 183 parentItem = searchParent(body->Parts()[i]->Positionlist());
183 if (parentItem) 184 if (parentItem)
184 { 185 {
185 AttachItem*temp = lastChild(parentItem); 186 AttachItem*temp = lastChild(parentItem);
186 if (temp) curItem = temp; 187 if (temp) curItem = temp;
187 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 188 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
188 attachments->setRootIsDecorated(true); 189 attachments->setRootIsDecorated(true);
189 curItem = parentItem; 190 curItem = parentItem;
190 } 191 }
191 else 192 else
192 { 193 {
193 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 194 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
194 } 195 }
195 } 196 }
196} 197}
197 198
198 199
199void ViewMail::slotShowHtml( bool state ) 200void ViewMail::slotShowHtml( bool state )
200{ 201{
201 m_showHtml = state; 202 m_showHtml = state;
202 setText(); 203 setText();
203} 204}
204 205
205void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 206void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
206{ 207{
207 if (!item ) 208 if (!item )
208 return; 209 return;
209 210
210 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 211 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
211 { 212 {
212 setText(); 213 setText();
213 return; 214 return;
214 } 215 }
215 QPopupMenu *menu = new QPopupMenu(); 216 QPopupMenu *menu = new QPopupMenu();
216 int ret=0; 217 int ret=0;
217 218
218 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 219 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
219 { 220 {
220 menu->insertItem( tr( "Show Text" ), 1 ); 221 menu->insertItem( tr( "Show Text" ), 1 );
221 } 222 }
222 if (item->text(0).left(6)=="image/") { 223 if (item->text(0).left(6)=="image/") {
223 menu->insertItem(tr("Display image preview"),2); 224 menu->insertItem(tr("Display image preview"),2);
224 } 225 }
225 menu->insertItem( tr( "Save Attachment" ), 0 ); 226 menu->insertItem( tr( "Save Attachment" ), 0 );
226 menu->insertSeparator(1); 227 menu->insertSeparator(1);
227 228
228 ret = menu->exec( point, 0 ); 229 ret = menu->exec( point, 0 );
229 230
230 switch(ret) 231 switch(ret)
231 { 232 {
232 case 0: 233 case 0:
233 { 234 {
234 //MimeTypes types; 235 //MimeTypes types;
235 //types.insert( "all", "*" ); 236 //types.insert( "all", "*" );
236 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 237 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
237 238
238 if( !str.isEmpty() ) 239 if( !str.isEmpty() )
239 { 240 {
240 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 241 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
241 if (content) 242 if (content)
242 { 243 {
243 QFile output(str); 244 QFile output(str);
244 output.open(IO_WriteOnly); 245 output.open(IO_WriteOnly);
245 output.writeBlock(content->Content(),content->Length()); 246 output.writeBlock(content->Content(),content->Length());
246 output.close(); 247 output.close();
247 delete content; 248 delete content;
248 } 249 }
249 } 250 }
250 } 251 }
251 break ; 252 break ;
252 253
253 case 2: 254 case 2:
254 { 255 {
255 QString tmpfile = "/tmp/opiemail-image"; 256 QString tmpfile = "/tmp/opiemail-image";
256 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 257 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
257 if (content) { 258 if (content) {
258 QFile output(tmpfile); 259 QFile output(tmpfile);
259 output.open(IO_WriteOnly); 260 output.open(IO_WriteOnly);
260 output.writeBlock(content->Content(),content->Length()); 261 output.writeBlock(content->Content(),content->Length());
261 output.close(); 262 output.close();
262 delete content; 263 delete content;
263 MailImageDlg iview(""); 264 MailImageDlg iview("");
264 iview.setName(tmpfile); 265 iview.setName(tmpfile);
265 KApplication::execDialog(&iview); 266 KApplication::execDialog(&iview);
266 output.remove(); 267 output.remove();
267 } 268 }
268 } 269 }
269 break; 270 break;
270 case 1: 271 case 1:
271 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 272 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
272 { 273 {
273 setText(); 274 setText();
274 } 275 }
275 else 276 else
276 { 277 {
277 if ( m_recMail->Wrapper() != 0l ) 278 if ( m_recMail->Wrapper() != 0l )
278 { // make sure that there is a wrapper , even after delete or simular actions 279 { // make sure that there is a wrapper , even after delete or simular actions
279 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 280 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
280 } 281 }
281 } 282 }
282 break; 283 break;
283 } 284 }
284 delete menu; 285 delete menu;
285} 286}
286 287
287 288
288void ViewMail::setMail(const RecMailP&mail ) 289void ViewMail::setMail(const RecMailP&mail )
289{ 290{
290 291
291 m_recMail = mail; 292 m_recMail = mail;
292 293
293 m_mail[0] = mail->getFrom(); 294 m_mail[0] = mail->getFrom();
294 m_mail[1] = mail->getSubject(); 295 m_mail[1] = mail->getSubject();
295 m_mail[3] = mail->getDate(); 296 m_mail[3] = mail->getDate();
296 m_mail[4] = mail->Msgid(); 297 m_mail[4] = mail->Msgid();
297 298
298 m_mail2[0] = mail->To(); 299 m_mail2[0] = mail->To();
299 m_mail2[1] = mail->CC(); 300 m_mail2[1] = mail->CC();
300 m_mail2[2] = mail->Bcc(); 301 m_mail2[2] = mail->Bcc();
301 302
302 setText(); 303 setText();
303} 304}
304 305
305 306
306 307
307ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 308ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
308 : ViewMailBase(parent, name, fl), _inLoop(false) 309 : ViewMailBase(parent, name, fl), _inLoop(false)
309{ 310{
310 m_gotBody = false; 311 m_gotBody = false;
311 deleted = false; 312 deleted = false;
312 313
313 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 314 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
314 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 315 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
315 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 316 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
316 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 317 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
317 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 318 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
318 319
319 attachments->setEnabled(m_gotBody); 320 attachments->setEnabled(m_gotBody);
320 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 321 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
321 322
322 readConfig(); 323 readConfig();
323 attachments->setSorting(-1); 324 attachments->setSorting(-1);
324} 325}
325 326
326void ViewMail::readConfig() 327void ViewMail::readConfig()
327{ 328{
328 Config cfg( "mail" ); 329 Config cfg( "mail" );
329 cfg.setGroup( "Settings" ); 330 cfg.setGroup( "Settings" );
330 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 331 m_showHtml = cfg.readBoolEntry( "showHtml", false );
331 showHtml->setOn( m_showHtml ); 332 showHtml->setOn( m_showHtml );
332} 333}
333 334
334void ViewMail::setText() 335void ViewMail::setText()
335{ 336{
336 337
337 QString toString; 338 QString toString;
338 QString ccString; 339 QString ccString;
339 QString bccString; 340 QString bccString;
340 341
341 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 342 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
342 { 343 {
343 toString += (*it); 344 toString += (*it);
344 } 345 }
345 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 346 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
346 { 347 {
347 ccString += (*it); 348 ccString += (*it);
348 } 349 }
349 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 350 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
350 { 351 {
351 bccString += (*it); 352 bccString += (*it);
352 } 353 }
353 354
354 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); 355 setCaption( tr("E-Mail by %1").arg( m_mail[0] ) );
355 356
356 m_mailHtml = "<html><body>" 357 m_mailHtml = "<html><body>"
357 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 358 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
358 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 359 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
359 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 360 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
360 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 361 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
361 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 362 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
362 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 363 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
363 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 364 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
364 "</td></tr></table><font face=fixed>"; 365 "</td></tr></table><font face=fixed>";
365 366
366 if ( !m_showHtml ) 367 if ( !m_showHtml )
367 { 368 {
368 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 369 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
369 } 370 }
370 else 371 else
371 { 372 {
372 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 373 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
373 } 374 }
374 // remove later in favor of a real handling 375 // remove later in favor of a real handling
375 m_gotBody = true; 376 m_gotBody = true;
376} 377}
377 378
378 379
379ViewMail::~ViewMail() 380ViewMail::~ViewMail()
380{ 381{
381 m_recMail->Wrapper()->cleanMimeCache(); 382 m_recMail->Wrapper()->cleanMimeCache();
382 hide(); 383 hide();
383} 384}
384 385
385void ViewMail::hide() 386void ViewMail::hide()
386{ 387{
387 QWidget::hide(); 388 QWidget::hide();
388 389
389 if (_inLoop) 390 if (_inLoop)
390 { 391 {
391 _inLoop = false; 392 _inLoop = false;
392 qApp->exit_loop(); 393 qApp->exit_loop();
393 394
394 } 395 }
395 396
396} 397}
397 398
398void ViewMail::exec() 399void ViewMail::exec()
399{ 400{
400 show(); 401 show();
401 402
402 if (!_inLoop) 403 if (!_inLoop)
403 { 404 {
404 _inLoop = true; 405 _inLoop = true;
405 qApp->enter_loop(); 406 qApp->enter_loop();
406 } 407 }
407 408
408} 409}
409 410
410QString ViewMail::deHtml(const QString &string) 411QString ViewMail::deHtml(const QString &string)
411{ 412{
412 QString string_ = string; 413 QString string_ = string;
413 string_.replace(QRegExp("&"), "&amp;"); 414 string_.replace(QRegExp("&"), "&amp;");
414 string_.replace(QRegExp("<"), "&lt;"); 415 string_.replace(QRegExp("<"), "&lt;");
415 string_.replace(QRegExp(">"), "&gt;"); 416 string_.replace(QRegExp(">"), "&gt;");
416 string_.replace(QRegExp("\\n"), "<br>"); 417 string_.replace(QRegExp("\\n"), "<br>");
417 return string_; 418 return string_;
418} 419}
419 420
420void ViewMail::slotReply() 421void ViewMail::slotReply()
421{ 422{
422 if (!m_gotBody) 423 if (!m_gotBody)
423 { 424 {
424 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 425 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
425 return; 426 return;
426 } 427 }
427 428
428 QString rtext; 429 QString rtext;
429 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 430 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
430 .arg( m_mail[0] ) 431 .arg( m_mail[0] )
431 .arg( m_mail[3] ); 432 .arg( m_mail[3] );
432 433
433 QString text = m_mail[2]; 434 QString text = m_mail[2];
434 QStringList lines = QStringList::split(QRegExp("\\n"), text); 435 QStringList lines = QStringList::split(QRegExp("\\n"), text);
435 QStringList::Iterator it; 436 QStringList::Iterator it;
436 for (it = lines.begin(); it != lines.end(); it++) 437 for (it = lines.begin(); it != lines.end(); it++)
437 { 438 {
438 rtext += "> " + *it + "\n"; 439 rtext += "> " + *it + "\n";
439 } 440 }
440 rtext += "\n"; 441 rtext += "\n";
441 442
442 QString prefix; 443 QString prefix;
443 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 444 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
444 else prefix = "Re: "; // no i18n on purpose 445 else prefix = "Re: "; // no i18n on purpose
445 446
446 Settings *settings = new Settings(); 447 Settings *settings = new Settings();
447 ComposeMail composer( settings ,this, 0, true); 448 ComposeMail composer( settings ,this, 0, true);
448 if (m_recMail->Replyto().isEmpty()) { 449 if (m_recMail->Replyto().isEmpty()) {
449 composer.setTo( m_recMail->getFrom()); 450 composer.setTo( m_recMail->getFrom());
450 } else { 451 } else {
451 composer.setTo( m_recMail->Replyto()); 452 composer.setTo( m_recMail->Replyto());
452 } 453 }
453 composer.setSubject( prefix + m_mail[1] ); 454 composer.setSubject( prefix + m_mail[1] );
454 composer.setMessage( rtext ); 455 composer.setMessage( rtext );
455 composer.setInReplyTo(m_recMail->Msgid()); 456 composer.setInReplyTo(m_recMail->Msgid());
456 457
457 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 458 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
458 { 459 {
459 m_recMail->Wrapper()->answeredMail(m_recMail); 460 m_recMail->Wrapper()->answeredMail(m_recMail);
460 } 461 }
461} 462}
462 463
463void ViewMail::slotForward() 464void ViewMail::slotForward()
464{ 465{
465 if (!m_gotBody) 466 if (!m_gotBody)
466 { 467 {
467 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 468 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
468 return; 469 return;
469 } 470 }
470 471
471 QString ftext; 472 QString ftext;
472 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 473 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
473 .arg( m_mail[0] ); 474 .arg( m_mail[0] );
474 if (!m_mail[3].isNull()) 475 if (!m_mail[3].isNull())
475 ftext += QString("Date: %1\n") 476 ftext += QString("Date: %1\n")
476 .arg( m_mail[3] ); 477 .arg( m_mail[3] );
477 if (!m_mail[0].isNull()) 478 if (!m_mail[0].isNull())
478 ftext += QString("From: %1\n") 479 ftext += QString("From: %1\n")
479 .arg( m_mail[0] ); 480 .arg( m_mail[0] );
480 if (!m_mail[1].isNull()) 481 if (!m_mail[1].isNull())
481 ftext += QString("Subject: %1\n") 482 ftext += QString("Subject: %1\n")
482 .arg( m_mail[1] ); 483 .arg( m_mail[1] );
483 484
484 ftext += QString("\n%1\n") 485 ftext += QString("\n%1\n")
485 .arg( m_mail[2]); 486 .arg( m_mail[2]);
486 487
487 ftext += QString("----- End forwarded message -----\n"); 488 ftext += QString("----- End forwarded message -----\n");
488 489
489 Settings *settings = new Settings(); 490 Settings *settings = new Settings();
490 ComposeMail composer( settings ,this, 0, true); 491 ComposeMail composer( settings ,this, 0, true);
491 composer.setSubject( "Fwd: " + m_mail[1] ); 492 composer.setSubject( "Fwd: " + m_mail[1] );
492 composer.setMessage( ftext ); 493 composer.setMessage( ftext );
493 if ( QDialog::Accepted == KApplication::execDialog( &composer )) 494 if ( QDialog::Accepted == KApplication::execDialog( &composer ))
494 { 495 {
495 } 496 }
496} 497}
497 498
498void ViewMail::slotDeleteMail( ) 499void ViewMail::slotDeleteMail( )
499{ 500{
500 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 ) 501 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 )
501 { 502 {
502 m_recMail->Wrapper()->deleteMail( m_recMail ); 503 m_recMail->Wrapper()->deleteMail( m_recMail );
503 hide(); 504 hide();
504 deleted = true; 505 deleted = true;
505 } 506 }
506} 507}
507 508
508MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 509MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f)
509 : KDialog(parent,name,modal) 510 : KDialog(parent,name,modal)
510{ 511{
511 QVBoxLayout*dlglayout = new QVBoxLayout(this); 512 QVBoxLayout*dlglayout = new QVBoxLayout(this);
512 dlglayout->setSpacing(2); 513 dlglayout->setSpacing(2);
513 dlglayout->setMargin(1); 514 dlglayout->setMargin(1);
514 //m_imageview = new Opie::MM::OImageScrollView(this); 515 //m_imageview = new Opie::MM::OImageScrollView(this);
515 //dlglayout->addWidget(m_imageview); 516 //dlglayout->addWidget(m_imageview);
516} 517}
517 518
518MailImageDlg::~MailImageDlg() 519MailImageDlg::~MailImageDlg()
519{ 520{
520} 521}
521 522
522void MailImageDlg::setName(const QString&fname) 523void MailImageDlg::setName(const QString&fname)
523{ 524{
524 qDebug("viewmail.cpp: MailImageDlg::setName Pending"); 525 qDebug("viewmail.cpp: MailImageDlg::setName Pending");
525 // m_imageview->setImage(fname); 526 // m_imageview->setImage(fname);
526} 527}