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