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