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