-rw-r--r-- | kmicromail/viewmail.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 6e560d7..32a3b7c 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -160,193 +160,197 @@ void ViewMail::setBody(const RecBodyP&body ) | |||
160 | while (s>1024) | 160 | while (s>1024) |
161 | { | 161 | { |
162 | s/=1024; | 162 | s/=1024; |
163 | ++w; | 163 | ++w; |
164 | if (w>=2) break; | 164 | if (w>=2) break; |
165 | } | 165 | } |
166 | switch(w) | 166 | switch(w) |
167 | { | 167 | { |
168 | case 1: | 168 | case 1: |
169 | q="k"; | 169 | q="k"; |
170 | break; | 170 | break; |
171 | case 2: | 171 | case 2: |
172 | q="M"; | 172 | q="M"; |
173 | break; | 173 | break; |
174 | default: | 174 | default: |
175 | q=""; | 175 | q=""; |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | QTextOStream o(&fsize); | 178 | QTextOStream o(&fsize); |
179 | if (w>0) o.precision(2); else o.precision(0); | 179 | if (w>0) o.precision(2); else o.precision(0); |
180 | o.setf(QTextStream::fixed); | 180 | o.setf(QTextStream::fixed); |
181 | o << s << " " << q << "Byte"; | 181 | o << s << " " << q << "Byte"; |
182 | desc = body->Parts()[i]->Description(); | 182 | desc = body->Parts()[i]->Description(); |
183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
184 | if (parentItem) | 184 | if (parentItem) |
185 | { | 185 | { |
186 | AttachItem*temp = lastChild(parentItem); | 186 | AttachItem*temp = lastChild(parentItem); |
187 | if (temp) curItem = temp; | 187 | if (temp) curItem = temp; |
188 | 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()); |
189 | attachments->setRootIsDecorated(true); | 189 | attachments->setRootIsDecorated(true); |
190 | curItem = parentItem; | 190 | curItem = parentItem; |
191 | } | 191 | } |
192 | else | 192 | else |
193 | { | 193 | { |
194 | 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()); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | void ViewMail::slotShowHtml( bool state ) | 200 | void ViewMail::slotShowHtml( bool state ) |
201 | { | 201 | { |
202 | m_showHtml = state; | 202 | m_showHtml = state; |
203 | setText(); | 203 | setText(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
207 | { | 207 | { |
208 | if (!item ) | 208 | if (!item ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
212 | { | 212 | { |
213 | setText(); | 213 | setText(); |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | QPopupMenu *menu = new QPopupMenu(); | 216 | QPopupMenu *menu = new QPopupMenu(); |
217 | int ret=0; | 217 | int ret=0; |
218 | 218 | ||
219 | 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" ) |
220 | { | 220 | { |
221 | menu->insertItem( tr( "Show Text" ), 1 ); | 221 | menu->insertItem( tr( "Show Text" ), 1 ); |
222 | } | 222 | } |
223 | if (item->text(0).left(6)=="image/") { | 223 | if (item->text(0).left(6)=="image/") { |
224 | menu->insertItem(tr("Display image preview"),2); | 224 | menu->insertItem(tr("Display image preview"),2); |
225 | } | 225 | } |
226 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 226 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
227 | menu->insertSeparator(1); | 227 | menu->insertSeparator(1); |
228 | 228 | ||
229 | ret = menu->exec( point, 0 ); | 229 | ret = menu->exec( point, 0 ); |
230 | 230 | ||
231 | switch(ret) | 231 | switch(ret) |
232 | { | 232 | { |
233 | case 0: | 233 | case 0: |
234 | { | 234 | { |
235 | //MimeTypes types; | 235 | //MimeTypes types; |
236 | //types.insert( "all", "*" ); | 236 | //types.insert( "all", "*" ); |
237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
238 | 238 | ||
239 | if( !str.isEmpty() ) | 239 | if( !str.isEmpty() ) |
240 | { | 240 | { |
241 | 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() ] ); |
242 | if (content) | 242 | if (content) |
243 | { | 243 | { |
244 | QFile output(str); | 244 | QFile output(str); |
245 | output.open(IO_WriteOnly); | 245 | output.open(IO_WriteOnly); |
246 | output.writeBlock(content->Content(),content->Length()); | 246 | output.writeBlock(content->Content(),content->Length()); |
247 | output.close(); | 247 | output.close(); |
248 | delete content; | 248 | delete content; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | break ; | 252 | break ; |
253 | 253 | ||
254 | case 2: | 254 | case 2: |
255 | { | 255 | { |
256 | #ifdef DESKTOP_VERSION | ||
257 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | ||
258 | #else | ||
256 | QString tmpfile = "/tmp/opiemail-image"; | 259 | QString tmpfile = "/tmp/opiemail-image"; |
260 | #endif | ||
257 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 261 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
258 | if (content) { | 262 | if (content) { |
259 | QFile output(tmpfile); | 263 | QFile output(tmpfile); |
260 | output.open(IO_WriteOnly); | 264 | output.open(IO_WriteOnly); |
261 | output.writeBlock(content->Content(),content->Length()); | 265 | output.writeBlock(content->Content(),content->Length()); |
262 | output.close(); | 266 | output.close(); |
263 | delete content; | 267 | delete content; |
264 | MailImageDlg iview(""); | 268 | MailImageDlg iview(""); |
265 | iview.setName(tmpfile); | 269 | iview.setName(tmpfile); |
266 | KApplication::execDialog(&iview); | 270 | KApplication::execDialog(&iview); |
267 | output.remove(); | 271 | output.remove(); |
268 | } | 272 | } |
269 | } | 273 | } |
270 | break; | 274 | break; |
271 | case 1: | 275 | case 1: |
272 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 276 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
273 | { | 277 | { |
274 | setText(); | 278 | setText(); |
275 | } | 279 | } |
276 | else | 280 | else |
277 | { | 281 | { |
278 | if ( m_recMail->Wrapper() != 0l ) | 282 | if ( m_recMail->Wrapper() != 0l ) |
279 | { // make sure that there is a wrapper , even after delete or simular actions | 283 | { // make sure that there is a wrapper , even after delete or simular actions |
280 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 284 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
281 | } | 285 | } |
282 | } | 286 | } |
283 | break; | 287 | break; |
284 | } | 288 | } |
285 | delete menu; | 289 | delete menu; |
286 | } | 290 | } |
287 | 291 | ||
288 | 292 | ||
289 | void ViewMail::setMail(const RecMailP&mail ) | 293 | void ViewMail::setMail(const RecMailP&mail ) |
290 | { | 294 | { |
291 | 295 | ||
292 | m_recMail = mail; | 296 | m_recMail = mail; |
293 | 297 | ||
294 | m_mail[0] = mail->getFrom(); | 298 | m_mail[0] = mail->getFrom(); |
295 | m_mail[1] = mail->getSubject(); | 299 | m_mail[1] = mail->getSubject(); |
296 | m_mail[3] = mail->getDate(); | 300 | m_mail[3] = mail->getDate(); |
297 | m_mail[4] = mail->Msgid(); | 301 | m_mail[4] = mail->Msgid(); |
298 | 302 | ||
299 | m_mail2[0] = mail->To(); | 303 | m_mail2[0] = mail->To(); |
300 | m_mail2[1] = mail->CC(); | 304 | m_mail2[1] = mail->CC(); |
301 | m_mail2[2] = mail->Bcc(); | 305 | m_mail2[2] = mail->Bcc(); |
302 | 306 | ||
303 | setText(); | 307 | setText(); |
304 | } | 308 | } |
305 | 309 | ||
306 | 310 | ||
307 | 311 | ||
308 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 312 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
309 | : ViewMailBase(parent, name, fl), _inLoop(false) | 313 | : ViewMailBase(parent, name, fl), _inLoop(false) |
310 | { | 314 | { |
311 | m_gotBody = false; | 315 | m_gotBody = false; |
312 | deleted = false; | 316 | deleted = false; |
313 | 317 | ||
314 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 318 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
315 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 319 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
316 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 320 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
317 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 321 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
318 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 322 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
319 | 323 | ||
320 | attachments->setEnabled(m_gotBody); | 324 | attachments->setEnabled(m_gotBody); |
321 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 325 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
322 | 326 | ||
323 | readConfig(); | 327 | readConfig(); |
324 | attachments->setSorting(-1); | 328 | attachments->setSorting(-1); |
325 | } | 329 | } |
326 | 330 | ||
327 | void ViewMail::readConfig() | 331 | void ViewMail::readConfig() |
328 | { | 332 | { |
329 | 333 | ||
330 | setFont ( KOPrefs::instance()->mReadFont ); | 334 | setFont ( KOPrefs::instance()->mReadFont ); |
331 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 335 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
332 | showHtml->setOn( m_showHtml ); | 336 | showHtml->setOn( m_showHtml ); |
333 | } | 337 | } |
334 | 338 | ||
335 | void ViewMail::setText() | 339 | void ViewMail::setText() |
336 | { | 340 | { |
337 | 341 | ||
338 | QString toString; | 342 | QString toString; |
339 | QString ccString; | 343 | QString ccString; |
340 | QString bccString; | 344 | QString bccString; |
341 | 345 | ||
342 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 346 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
343 | { | 347 | { |
344 | toString += (*it); | 348 | toString += (*it); |
345 | } | 349 | } |
346 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 350 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
347 | { | 351 | { |
348 | ccString += (*it); | 352 | ccString += (*it); |
349 | } | 353 | } |
350 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 354 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
351 | { | 355 | { |
352 | bccString += (*it); | 356 | bccString += (*it); |