-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailstatics.cpp | 25 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailstatics.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 11 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 |
10 files changed, 81 insertions, 46 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 703235d..0ac842d 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -259,211 +259,211 @@ QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | switch ( addr->ad_type ) { | 261 | switch ( addr->ad_type ) { |
262 | case MAILIMF_ADDRESS_MAILBOX: | 262 | case MAILIMF_ADDRESS_MAILBOX: |
263 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 263 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
264 | break; | 264 | break; |
265 | case MAILIMF_ADDRESS_GROUP: | 265 | case MAILIMF_ADDRESS_GROUP: |
266 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 266 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
267 | break; | 267 | break; |
268 | default: | 268 | default: |
269 | odebug << "Generic: unkown mailimf address type" << oendl; | 269 | odebug << "Generic: unkown mailimf address type" << oendl; |
270 | break; | 270 | break; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | return result; | 274 | return result; |
275 | } | 275 | } |
276 | 276 | ||
277 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 277 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
278 | { | 278 | { |
279 | QString result( "" ); | 279 | QString result( "" ); |
280 | 280 | ||
281 | result.append( group->grp_display_name ); | 281 | result.append( group->grp_display_name ); |
282 | result.append( ": " ); | 282 | result.append( ": " ); |
283 | 283 | ||
284 | if ( group->grp_mb_list != NULL ) { | 284 | if ( group->grp_mb_list != NULL ) { |
285 | result.append( parseMailboxList( group->grp_mb_list ) ); | 285 | result.append( parseMailboxList( group->grp_mb_list ) ); |
286 | } | 286 | } |
287 | 287 | ||
288 | result.append( ";" ); | 288 | result.append( ";" ); |
289 | 289 | ||
290 | return result; | 290 | return result; |
291 | } | 291 | } |
292 | 292 | ||
293 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 293 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
294 | { | 294 | { |
295 | QString result( "" ); | 295 | QString result( "" ); |
296 | 296 | ||
297 | if ( box->mb_display_name == NULL ) { | 297 | if ( box->mb_display_name == NULL ) { |
298 | result.append( box->mb_addr_spec ); | 298 | result.append( box->mb_addr_spec ); |
299 | } else { | 299 | } else { |
300 | result.append( convert_String(box->mb_display_name).latin1() ); | 300 | result.append( convert_String(box->mb_display_name).latin1() ); |
301 | result.append( " <" ); | 301 | result.append( " <" ); |
302 | result.append( box->mb_addr_spec ); | 302 | result.append( box->mb_addr_spec ); |
303 | result.append( ">" ); | 303 | result.append( ">" ); |
304 | } | 304 | } |
305 | 305 | ||
306 | return result; | 306 | return result; |
307 | } | 307 | } |
308 | 308 | ||
309 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 309 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
310 | { | 310 | { |
311 | QString result( "" ); | 311 | QString result( "" ); |
312 | 312 | ||
313 | bool first = true; | 313 | bool first = true; |
314 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 314 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
315 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 315 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
316 | 316 | ||
317 | if ( !first ) { | 317 | if ( !first ) { |
318 | result.append( "," ); | 318 | result.append( "," ); |
319 | } else { | 319 | } else { |
320 | first = false; | 320 | first = false; |
321 | } | 321 | } |
322 | 322 | ||
323 | result.append( parseMailbox( box ) ); | 323 | result.append( parseMailbox( box ) ); |
324 | } | 324 | } |
325 | 325 | ||
326 | return result; | 326 | return result; |
327 | } | 327 | } |
328 | 328 | ||
329 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 329 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
330 | { | 330 | { |
331 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 331 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
332 | if (it==bodyCache.end()) return new encodedString(); | 332 | if (it==bodyCache.end()) return new encodedString(); |
333 | encodedString*t = decode_String(it.data(),part->Encoding()); | 333 | encodedString*t = decode_String(it.data(),part->Encoding()); |
334 | return t; | 334 | return t; |
335 | } | 335 | } |
336 | 336 | ||
337 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 337 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
338 | { | 338 | { |
339 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 339 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
340 | if (it==bodyCache.end()) return new encodedString(); | 340 | if (it==bodyCache.end()) return new encodedString(); |
341 | encodedString*t = it.data(); | 341 | encodedString*t = it.data(); |
342 | return t; | 342 | return t; |
343 | } | 343 | } |
344 | 344 | ||
345 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 345 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
346 | { | 346 | { |
347 | encodedString*t = fetchDecodedPart(mail,part); | 347 | encodedString*t = fetchDecodedPart(mail,part); |
348 | QString text=t->Content(); | 348 | QString text=t->Content(); |
349 | delete t; | 349 | delete t; |
350 | return text; | 350 | return text; |
351 | } | 351 | } |
352 | 352 | ||
353 | void Genericwrapper::cleanMimeCache() | 353 | void Genericwrapper::cleanMimeCache() |
354 | { | 354 | { |
355 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 355 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
356 | for (;it!=bodyCache.end();++it) { | 356 | for (;it!=bodyCache.end();++it) { |
357 | encodedString*t = it.data(); | 357 | encodedString*t = it.data(); |
358 | //it.setValue(0); | 358 | //it.setValue(0); |
359 | if (t) delete t; | 359 | if (t) delete t; |
360 | } | 360 | } |
361 | bodyCache.clear(); | 361 | bodyCache.clear(); |
362 | odebug << "Genericwrapper: cache cleaned" << oendl; | 362 | odebug << "Genericwrapper: cache cleaned" << oendl; |
363 | } | 363 | } |
364 | 364 | ||
365 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 365 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
366 | { | 366 | { |
367 | QStringList res; | 367 | QStringList res; |
368 | if (!in_replies || !in_replies->mid_list) return res; | 368 | if (!in_replies || !in_replies->mid_list) return res; |
369 | clistiter * current = 0; | 369 | clistiter * current = 0; |
370 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 370 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
371 | QString h((char*)current->data); | 371 | QString h((char*)current->data); |
372 | while (h.length()>0 && h[0]=='<') { | 372 | while (h.length()>0 && h[0]=='<') { |
373 | h.remove(0,1); | 373 | h.remove(0,1); |
374 | } | 374 | } |
375 | while (h.length()>0 && h[h.length()-1]=='>') { | 375 | while (h.length()>0 && h[h.length()-1]=='>') { |
376 | h.remove(h.length()-1,1); | 376 | h.remove(h.length()-1,1); |
377 | } | 377 | } |
378 | if (h.length()>0) { | 378 | if (h.length()>0) { |
379 | res.append(h); | 379 | res.append(h); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | return res; | 382 | return res; |
383 | } | 383 | } |
384 | 384 | ||
385 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 385 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
386 | { | 386 | { |
387 | int r; | 387 | int r,toffset; |
388 | mailmessage_list * env_list = 0; | 388 | mailmessage_list * env_list = 0; |
389 | r = mailsession_get_messages_list(session,&env_list); | 389 | r = mailsession_get_messages_list(session,&env_list); |
390 | if (r != MAIL_NO_ERROR) { | 390 | if (r != MAIL_NO_ERROR) { |
391 | odebug << "Error message list" << oendl; | 391 | odebug << "Error message list" << oendl; |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | r = mailsession_get_envelopes_list(session, env_list); | 394 | r = mailsession_get_envelopes_list(session, env_list); |
395 | if (r != MAIL_NO_ERROR) { | 395 | if (r != MAIL_NO_ERROR) { |
396 | odebug << "Error filling message list" << oendl; | 396 | odebug << "Error filling message list" << oendl; |
397 | if (env_list) { | 397 | if (env_list) { |
398 | mailmessage_list_free(env_list); | 398 | mailmessage_list_free(env_list); |
399 | } | 399 | } |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | mailimf_references * refs = 0; | 402 | mailimf_references * refs = 0; |
403 | mailimf_in_reply_to * in_replies = 0; | 403 | mailimf_in_reply_to * in_replies = 0; |
404 | uint32_t i = 0; | 404 | uint32_t i = 0; |
405 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 405 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
406 | mailmessage * msg; | 406 | mailmessage * msg; |
407 | QBitArray mFlags(7); | 407 | QBitArray mFlags(7); |
408 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 408 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
409 | if (msg->msg_fields == NULL) { | 409 | if (msg->msg_fields == NULL) { |
410 | //odebug << "could not fetch envelope of message " << i << "" << oendl; | 410 | //odebug << "could not fetch envelope of message " << i << "" << oendl; |
411 | continue; | 411 | continue; |
412 | } | 412 | } |
413 | RecMailP mail = new RecMail(); | 413 | RecMailP mail = new RecMail(); |
414 | mail->setWrapper(this); | 414 | mail->setWrapper(this); |
415 | mail_flags * flag_result = 0; | 415 | mail_flags * flag_result = 0; |
416 | r = mailmessage_get_flags(msg,&flag_result); | 416 | r = mailmessage_get_flags(msg,&flag_result); |
417 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 417 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
418 | mFlags.setBit(FLAG_SEEN); | 418 | mFlags.setBit(FLAG_SEEN); |
419 | } | 419 | } |
420 | mailimf_single_fields single_fields; | 420 | mailimf_single_fields single_fields; |
421 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 421 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
422 | mail->setMsgsize(msg->msg_size); | 422 | mail->setMsgsize(msg->msg_size); |
423 | mail->setFlags(mFlags); | 423 | mail->setFlags(mFlags); |
424 | mail->setMbox(mailbox); | 424 | mail->setMbox(mailbox); |
425 | mail->setNumber(msg->msg_index); | 425 | mail->setNumber(msg->msg_index); |
426 | if (single_fields.fld_subject) | 426 | if (single_fields.fld_subject) |
427 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 427 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
428 | if (single_fields.fld_from) | 428 | if (single_fields.fld_from) |
429 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 429 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
430 | if (!mbox_as_to) { | 430 | if (!mbox_as_to) { |
431 | if (single_fields.fld_to) | 431 | if (single_fields.fld_to) |
432 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 432 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
433 | } else { | 433 | } else { |
434 | mail->setTo(mailbox); | 434 | mail->setTo(mailbox); |
435 | } | 435 | } |
436 | if (single_fields.fld_cc) | 436 | if (single_fields.fld_cc) |
437 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 437 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
438 | if (single_fields.fld_bcc) | 438 | if (single_fields.fld_bcc) |
439 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 439 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
440 | if (single_fields.fld_orig_date) | 440 | if (single_fields.fld_orig_date) { |
441 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 441 | QDateTime d = parseDateTime( single_fields.fld_orig_date->dt_date_time,toffset); |
442 | // crashes when accessing pop3 account? | 442 | mail->setDate( d,toffset ); |
443 | } | ||
443 | if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { | 444 | if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { |
444 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 445 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
445 | } | 446 | } |
446 | |||
447 | if (single_fields.fld_reply_to) { | 447 | if (single_fields.fld_reply_to) { |
448 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 448 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
449 | if (t.count()>0) { | 449 | if (t.count()>0) { |
450 | mail->setReplyto(t[0]); | 450 | mail->setReplyto(t[0]); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | #if 0 | 453 | #if 0 |
454 | refs = single_fields.fld_references; | 454 | refs = single_fields.fld_references; |
455 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 455 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
456 | char * text = (char*)refs->mid_list->first->data; | 456 | char * text = (char*)refs->mid_list->first->data; |
457 | mail->setReplyto(QString(text)); | 457 | mail->setReplyto(QString(text)); |
458 | } | 458 | } |
459 | #endif | 459 | #endif |
460 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 460 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
461 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 461 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
462 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 462 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
463 | } | 463 | } |
464 | target.append(mail); | 464 | target.append(mail); |
465 | } | 465 | } |
466 | if (env_list) { | 466 | if (env_list) { |
467 | mailmessage_list_free(env_list); | 467 | mailmessage_list_free(env_list); |
468 | } | 468 | } |
469 | } | 469 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 56efa0b..8e5212b 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -247,309 +247,310 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
247 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 247 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
248 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 248 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
249 | */ | 249 | */ |
250 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 250 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
251 | mailimap_set_free( set ); | 251 | mailimap_set_free( set ); |
252 | mailimap_fetch_type_free( fetchType ); | 252 | mailimap_fetch_type_free( fetchType ); |
253 | 253 | ||
254 | QString date,subject,from; | 254 | QString date,subject,from; |
255 | 255 | ||
256 | if ( err == MAILIMAP_NO_ERROR ) { | 256 | if ( err == MAILIMAP_NO_ERROR ) { |
257 | mailimap_msg_att * msg_att; | 257 | mailimap_msg_att * msg_att; |
258 | int i = 0; | 258 | int i = 0; |
259 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 259 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
260 | ++i; | 260 | ++i; |
261 | msg_att = (mailimap_msg_att*)current->data; | 261 | msg_att = (mailimap_msg_att*)current->data; |
262 | RecMail*m = parse_list_result(msg_att); | 262 | RecMail*m = parse_list_result(msg_att); |
263 | if (m) { | 263 | if (m) { |
264 | m->setNumber(i); | 264 | m->setNumber(i); |
265 | m->setMbox(mailbox); | 265 | m->setMbox(mailbox); |
266 | m->setWrapper(this); | 266 | m->setWrapper(this); |
267 | target.append(m); | 267 | target.append(m); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 270 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
271 | } else { | 271 | } else { |
272 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 272 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
273 | } | 273 | } |
274 | if (result) mailimap_fetch_list_free(result); | 274 | if (result) mailimap_fetch_list_free(result); |
275 | } | 275 | } |
276 | 276 | ||
277 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 277 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
278 | { | 278 | { |
279 | const char *path, *mask; | 279 | const char *path, *mask; |
280 | int err = MAILIMAP_NO_ERROR; | 280 | int err = MAILIMAP_NO_ERROR; |
281 | clist *result = 0; | 281 | clist *result = 0; |
282 | clistcell *current = 0; | 282 | clistcell *current = 0; |
283 | clistcell*cur_flag = 0; | 283 | clistcell*cur_flag = 0; |
284 | mailimap_mbx_list_flags*bflags = 0; | 284 | mailimap_mbx_list_flags*bflags = 0; |
285 | 285 | ||
286 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 286 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
287 | login(); | 287 | login(); |
288 | if (!m_imap) { | 288 | if (!m_imap) { |
289 | return folders; | 289 | return folders; |
290 | } | 290 | } |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 293 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
294 | * We must not forget to filter them out in next loop! | 294 | * We must not forget to filter them out in next loop! |
295 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 295 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
296 | */ | 296 | */ |
297 | QString temp; | 297 | QString temp; |
298 | mask = "INBOX" ; | 298 | mask = "INBOX" ; |
299 | mailimap_mailbox_list *list; | 299 | mailimap_mailbox_list *list; |
300 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 300 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
301 | QString del; | 301 | QString del; |
302 | bool selectable = true; | 302 | bool selectable = true; |
303 | bool no_inferiors = false; | 303 | bool no_inferiors = false; |
304 | if ( err == MAILIMAP_NO_ERROR ) { | 304 | if ( err == MAILIMAP_NO_ERROR ) { |
305 | current = result->first; | 305 | current = result->first; |
306 | for ( int i = result->count; i > 0; i-- ) { | 306 | for ( int i = result->count; i > 0; i-- ) { |
307 | list = (mailimap_mailbox_list *) current->data; | 307 | list = (mailimap_mailbox_list *) current->data; |
308 | // it is better use the deep copy mechanism of qt itself | 308 | // it is better use the deep copy mechanism of qt itself |
309 | // instead of using strdup! | 309 | // instead of using strdup! |
310 | temp = list->mb_name; | 310 | temp = list->mb_name; |
311 | del = list->mb_delimiter; | 311 | del = list->mb_delimiter; |
312 | current = current->next; | 312 | current = current->next; |
313 | if ( (bflags = list->mb_flag) ) { | 313 | if ( (bflags = list->mb_flag) ) { |
314 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 314 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
315 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 315 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
316 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 316 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
317 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 317 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
318 | no_inferiors = true; | 318 | no_inferiors = true; |
319 | } | 319 | } |
320 | } | 320 | } |
321 | } | 321 | } |
322 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 322 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
323 | } | 323 | } |
324 | } else { | 324 | } else { |
325 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; | 325 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; |
326 | } | 326 | } |
327 | mailimap_list_result_free( result ); | 327 | mailimap_list_result_free( result ); |
328 | 328 | ||
329 | /* | 329 | /* |
330 | * second stage - get the other then inbox folders | 330 | * second stage - get the other then inbox folders |
331 | */ | 331 | */ |
332 | mask = "*" ; | 332 | mask = "*" ; |
333 | path = account->getPrefix().latin1(); | 333 | path = account->getPrefix().latin1(); |
334 | if (!path) path = ""; | 334 | if (!path) path = ""; |
335 | odebug << path << oendl; | 335 | odebug << path << oendl; |
336 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 336 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
337 | if ( err == MAILIMAP_NO_ERROR ) { | 337 | if ( err == MAILIMAP_NO_ERROR ) { |
338 | current = result->first; | 338 | current = result->first; |
339 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 339 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
340 | no_inferiors = false; | 340 | no_inferiors = false; |
341 | list = (mailimap_mailbox_list *) current->data; | 341 | list = (mailimap_mailbox_list *) current->data; |
342 | // it is better use the deep copy mechanism of qt itself | 342 | // it is better use the deep copy mechanism of qt itself |
343 | // instead of using strdup! | 343 | // instead of using strdup! |
344 | temp = list->mb_name; | 344 | temp = list->mb_name; |
345 | if (temp.lower()=="inbox") | 345 | if (temp.lower()=="inbox") |
346 | continue; | 346 | continue; |
347 | if (temp.lower()==account->getPrefix().lower()) | 347 | if (temp.lower()==account->getPrefix().lower()) |
348 | continue; | 348 | continue; |
349 | if ( (bflags = list->mb_flag) ) { | 349 | if ( (bflags = list->mb_flag) ) { |
350 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 350 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
351 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 351 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
352 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 352 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
353 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 353 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
354 | no_inferiors = true; | 354 | no_inferiors = true; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
358 | del = list->mb_delimiter; | 358 | del = list->mb_delimiter; |
359 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 359 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
360 | } | 360 | } |
361 | } else { | 361 | } else { |
362 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; | 362 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; |
363 | } | 363 | } |
364 | if (result) mailimap_list_result_free( result ); | 364 | if (result) mailimap_list_result_free( result ); |
365 | return folders; | 365 | return folders; |
366 | } | 366 | } |
367 | 367 | ||
368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
369 | { | 369 | { |
370 | RecMail * m = 0; | 370 | RecMail * m = 0; |
371 | mailimap_msg_att_item *item=0; | 371 | mailimap_msg_att_item *item=0; |
372 | clistcell *current,*c,*cf; | 372 | clistcell *current,*c,*cf; |
373 | mailimap_msg_att_dynamic*flist; | 373 | mailimap_msg_att_dynamic*flist; |
374 | mailimap_flag_fetch*cflag; | 374 | mailimap_flag_fetch*cflag; |
375 | int size; | 375 | int size,toffset; |
376 | QBitArray mFlags(7); | 376 | QBitArray mFlags(7); |
377 | QStringList addresslist; | 377 | QStringList addresslist; |
378 | 378 | ||
379 | if (!m_att) { | 379 | if (!m_att) { |
380 | return m; | 380 | return m; |
381 | } | 381 | } |
382 | size = 0; | 382 | size = 0; |
383 | m = new RecMail(); | 383 | m = new RecMail(); |
384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
385 | current = c; | 385 | current = c; |
386 | item = (mailimap_msg_att_item*)current->data; | 386 | item = (mailimap_msg_att_item*)current->data; |
387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
388 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 388 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
389 | if (!flist->att_list) { | 389 | if (!flist->att_list) { |
390 | continue; | 390 | continue; |
391 | } | 391 | } |
392 | cf = flist->att_list->first; | 392 | cf = flist->att_list->first; |
393 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 393 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
394 | cflag = (mailimap_flag_fetch*)cf->data; | 394 | cflag = (mailimap_flag_fetch*)cf->data; |
395 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 395 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
396 | switch (cflag->fl_flag->fl_type) { | 396 | switch (cflag->fl_flag->fl_type) { |
397 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 397 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
398 | mFlags.setBit(FLAG_ANSWERED); | 398 | mFlags.setBit(FLAG_ANSWERED); |
399 | break; | 399 | break; |
400 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 400 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
401 | mFlags.setBit(FLAG_FLAGGED); | 401 | mFlags.setBit(FLAG_FLAGGED); |
402 | break; | 402 | break; |
403 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 403 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
404 | mFlags.setBit(FLAG_DELETED); | 404 | mFlags.setBit(FLAG_DELETED); |
405 | break; | 405 | break; |
406 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 406 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
407 | mFlags.setBit(FLAG_SEEN); | 407 | mFlags.setBit(FLAG_SEEN); |
408 | break; | 408 | break; |
409 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 409 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
410 | mFlags.setBit(FLAG_DRAFT); | 410 | mFlags.setBit(FLAG_DRAFT); |
411 | break; | 411 | break; |
412 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 412 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
413 | break; | 413 | break; |
414 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 414 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
415 | break; | 415 | break; |
416 | default: | 416 | default: |
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 419 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
420 | mFlags.setBit(FLAG_RECENT); | 420 | mFlags.setBit(FLAG_RECENT); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | continue; | 423 | continue; |
424 | } | 424 | } |
425 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 425 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
426 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 426 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
427 | m->setDate(parseDateTime(head->env_date)); | 427 | QDateTime d = parseDateTime(head->env_date,toffset); |
428 | m->setDate(d,toffset); | ||
428 | m->setSubject(convert_String((const char*)head->env_subject)); | 429 | m->setSubject(convert_String((const char*)head->env_subject)); |
429 | if (head->env_from!=NULL) { | 430 | if (head->env_from!=NULL) { |
430 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 431 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
431 | if (addresslist.count()) { | 432 | if (addresslist.count()) { |
432 | m->setFrom(addresslist.first()); | 433 | m->setFrom(addresslist.first()); |
433 | } | 434 | } |
434 | } | 435 | } |
435 | if (head->env_to!=NULL) { | 436 | if (head->env_to!=NULL) { |
436 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 437 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
437 | m->setTo(addresslist); | 438 | m->setTo(addresslist); |
438 | } | 439 | } |
439 | if (head->env_cc!=NULL) { | 440 | if (head->env_cc!=NULL) { |
440 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 441 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
441 | m->setCC(addresslist); | 442 | m->setCC(addresslist); |
442 | } | 443 | } |
443 | if (head->env_bcc!=NULL) { | 444 | if (head->env_bcc!=NULL) { |
444 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 445 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
445 | m->setBcc(addresslist); | 446 | m->setBcc(addresslist); |
446 | } | 447 | } |
447 | /* reply to address, eg. email. */ | 448 | /* reply to address, eg. email. */ |
448 | if (head->env_reply_to!=NULL) { | 449 | if (head->env_reply_to!=NULL) { |
449 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 450 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
450 | if (addresslist.count()) { | 451 | if (addresslist.count()) { |
451 | m->setReplyto(addresslist.first()); | 452 | m->setReplyto(addresslist.first()); |
452 | } | 453 | } |
453 | } | 454 | } |
454 | if (head->env_in_reply_to!=NULL) { | 455 | if (head->env_in_reply_to!=NULL) { |
455 | QString h(head->env_in_reply_to); | 456 | QString h(head->env_in_reply_to); |
456 | while (h.length()>0 && h[0]=='<') { | 457 | while (h.length()>0 && h[0]=='<') { |
457 | h.remove(0,1); | 458 | h.remove(0,1); |
458 | } | 459 | } |
459 | while (h.length()>0 && h[h.length()-1]=='>') { | 460 | while (h.length()>0 && h[h.length()-1]=='>') { |
460 | h.remove(h.length()-1,1); | 461 | h.remove(h.length()-1,1); |
461 | } | 462 | } |
462 | if (h.length()>0) { | 463 | if (h.length()>0) { |
463 | m->setInreply(QStringList(h)); | 464 | m->setInreply(QStringList(h)); |
464 | } | 465 | } |
465 | } | 466 | } |
466 | if (head->env_message_id) { | 467 | if (head->env_message_id) { |
467 | m->setMsgid(QString(head->env_message_id)); | 468 | m->setMsgid(QString(head->env_message_id)); |
468 | } | 469 | } |
469 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
470 | // not used this moment | 471 | // not used this moment |
471 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 472 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
472 | //size = item->att_data.att_static->att_data.att_rfc822_size; | 473 | //size = item->att_data.att_static->att_data.att_rfc822_size; |
473 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); | 474 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); |
474 | } | 475 | } |
475 | } | 476 | } |
476 | /* msg is already deleted */ | 477 | /* msg is already deleted */ |
477 | if (mFlags.testBit(FLAG_DELETED) && m) { | 478 | if (mFlags.testBit(FLAG_DELETED) && m) { |
478 | delete m; | 479 | delete m; |
479 | m = 0; | 480 | m = 0; |
480 | } | 481 | } |
481 | if (m) { | 482 | if (m) { |
482 | m->setFlags(mFlags); | 483 | m->setFlags(mFlags); |
483 | } | 484 | } |
484 | return m; | 485 | return m; |
485 | } | 486 | } |
486 | 487 | ||
487 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 488 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
488 | { | 489 | { |
489 | RecBodyP body = new RecBody(); | 490 | RecBodyP body = new RecBody(); |
490 | const char *mb; | 491 | const char *mb; |
491 | int err = MAILIMAP_NO_ERROR; | 492 | int err = MAILIMAP_NO_ERROR; |
492 | clist *result = 0; | 493 | clist *result = 0; |
493 | clistcell *current; | 494 | clistcell *current; |
494 | mailimap_fetch_att *fetchAtt = 0; | 495 | mailimap_fetch_att *fetchAtt = 0; |
495 | mailimap_fetch_type *fetchType = 0; | 496 | mailimap_fetch_type *fetchType = 0; |
496 | mailimap_set *set = 0; | 497 | mailimap_set *set = 0; |
497 | mailimap_body*body_desc = 0; | 498 | mailimap_body*body_desc = 0; |
498 | 499 | ||
499 | mb = mail->getMbox().latin1(); | 500 | mb = mail->getMbox().latin1(); |
500 | 501 | ||
501 | login(); | 502 | login(); |
502 | if (!m_imap) { | 503 | if (!m_imap) { |
503 | return body; | 504 | return body; |
504 | } | 505 | } |
505 | err = selectMbox(mail->getMbox()); | 506 | err = selectMbox(mail->getMbox()); |
506 | if ( err != MAILIMAP_NO_ERROR ) { | 507 | if ( err != MAILIMAP_NO_ERROR ) { |
507 | return body; | 508 | return body; |
508 | } | 509 | } |
509 | 510 | ||
510 | /* the range has to start at 1!!! not with 0!!!! */ | 511 | /* the range has to start at 1!!! not with 0!!!! */ |
511 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 512 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
512 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 513 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
513 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 514 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
514 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 515 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
515 | mailimap_set_free( set ); | 516 | mailimap_set_free( set ); |
516 | mailimap_fetch_type_free( fetchType ); | 517 | mailimap_fetch_type_free( fetchType ); |
517 | 518 | ||
518 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 519 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
519 | mailimap_msg_att * msg_att; | 520 | mailimap_msg_att * msg_att; |
520 | msg_att = (mailimap_msg_att*)current->data; | 521 | msg_att = (mailimap_msg_att*)current->data; |
521 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 522 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
522 | QValueList<int> path; | 523 | QValueList<int> path; |
523 | body_desc = item->att_data.att_static->att_data.att_body; | 524 | body_desc = item->att_data.att_static->att_data.att_body; |
524 | traverseBody(mail,body_desc,body,0,path); | 525 | traverseBody(mail,body_desc,body,0,path); |
525 | } else { | 526 | } else { |
526 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 527 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
527 | } | 528 | } |
528 | if (result) mailimap_fetch_list_free(result); | 529 | if (result) mailimap_fetch_list_free(result); |
529 | return body; | 530 | return body; |
530 | } | 531 | } |
531 | 532 | ||
532 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 533 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
533 | { | 534 | { |
534 | QStringList l; | 535 | QStringList l; |
535 | QString from; | 536 | QString from; |
536 | bool named_from; | 537 | bool named_from; |
537 | clistcell *current = NULL; | 538 | clistcell *current = NULL; |
538 | mailimap_address * current_address=NULL; | 539 | mailimap_address * current_address=NULL; |
539 | if (!list) { | 540 | if (!list) { |
540 | return l; | 541 | return l; |
541 | } | 542 | } |
542 | unsigned int count = 0; | 543 | unsigned int count = 0; |
543 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 544 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
544 | from = ""; | 545 | from = ""; |
545 | named_from = false; | 546 | named_from = false; |
546 | current_address=(mailimap_address*)current->data; | 547 | current_address=(mailimap_address*)current->data; |
547 | if (current_address->ad_personal_name){ | 548 | if (current_address->ad_personal_name){ |
548 | from+=convert_String((const char*)current_address->ad_personal_name); | 549 | from+=convert_String((const char*)current_address->ad_personal_name); |
549 | from+=" "; | 550 | from+=" "; |
550 | named_from = true; | 551 | named_from = true; |
551 | } | 552 | } |
552 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 553 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
553 | from+="<"; | 554 | from+="<"; |
554 | } | 555 | } |
555 | if (current_address->ad_mailbox_name) { | 556 | if (current_address->ad_mailbox_name) { |
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.cpp b/noncore/net/mail/libmailwrapper/mailstatics.cpp index 4878dc9..033ec28 100644 --- a/noncore/net/mail/libmailwrapper/mailstatics.cpp +++ b/noncore/net/mail/libmailwrapper/mailstatics.cpp | |||
@@ -1,29 +1,30 @@ | |||
1 | #include "mailstatics.h" | 1 | #include "mailstatics.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/timestring.h> | 3 | //#include <qpe/timestring.h> |
4 | 4 | ||
5 | QString MailStatics::parseDateTime(const mailimf_date_time *date ) | 5 | QDateTime MailStatics::parseDateTime(const mailimf_date_time *date,int&offset ) |
6 | { | 6 | { |
7 | if (!date) return ""; | 7 | offset = 0; |
8 | if (!date) { | ||
9 | return QDateTime(); | ||
10 | } | ||
8 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | 11 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); |
9 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | 12 | offset = date->dt_zone; |
10 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | 13 | return da; |
11 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
12 | return timestring; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | QString MailStatics::parseDateTime(const char*date) | 16 | QDateTime MailStatics::parseDateTime(const char*date,int&offset) |
16 | { | 17 | { |
17 | mailimf_date_time * date_time; | 18 | mailimf_date_time * date_time=0; |
18 | QString d = ""; | 19 | QDateTime d; |
19 | size_t cur_tok = 0; | 20 | size_t cur_tok = 0; |
20 | if (!date) return d; | 21 | if (!date) return d; |
21 | int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time); | 22 | int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time); |
22 | if (r==MAILIMF_NO_ERROR) { | 23 | if (r==MAILIMF_NO_ERROR) { |
23 | d = parseDateTime(date_time); | 24 | d = parseDateTime(date_time,offset); |
24 | } | 25 | } |
25 | if (date_time) { | 26 | if (date_time) { |
26 | mailimf_date_time_free(date_time); | 27 | mailimf_date_time_free(date_time); |
27 | } | 28 | } |
28 | return d; | 29 | return d; |
29 | } \ No newline at end of file | 30 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.h b/noncore/net/mail/libmailwrapper/mailstatics.h index 841d14d..c714ead 100644 --- a/noncore/net/mail/libmailwrapper/mailstatics.h +++ b/noncore/net/mail/libmailwrapper/mailstatics.h | |||
@@ -1,19 +1,19 @@ | |||
1 | #ifndef __MAIL_STATICS_H | 1 | #ifndef __MAIL_STATICS_H |
2 | #define __MAIL_STATICS_H | 2 | #define __MAIL_STATICS_H |
3 | 3 | ||
4 | #include <qdatetime.h> | 4 | #include <qdatetime.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | struct mailimf_date_time; | 7 | struct mailimf_date_time; |
8 | 8 | ||
9 | class MailStatics | 9 | class MailStatics |
10 | { | 10 | { |
11 | protected: | 11 | protected: |
12 | static QString parseDateTime(const mailimf_date_time * date); | 12 | static QDateTime parseDateTime(const mailimf_date_time * date,int&offset); |
13 | static QString parseDateTime(const char*date); | 13 | static QDateTime parseDateTime(const char*date,int&offset); |
14 | MailStatics(){}; | 14 | MailStatics(){}; |
15 | virtual ~MailStatics(){}; | 15 | virtual ~MailStatics(){}; |
16 | public: | 16 | public: |
17 | }; | 17 | }; |
18 | 18 | ||
19 | #endif | 19 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index d4395a2..b009b75 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,399 +1,411 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | 3 | #include <opie2/odebug.h> |
4 | #include <qpe/timestring.h> | ||
4 | 5 | ||
5 | #include <stdlib.h> | 6 | #include <stdlib.h> |
6 | 7 | ||
7 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 9 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 10 | :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7),maildate(),date("") |
10 | { | 11 | { |
11 | init(); | 12 | init(); |
12 | } | 13 | } |
13 | 14 | ||
14 | RecMail::RecMail(const RecMail&old) | 15 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 16 | :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7),maildate(),date("") |
16 | { | 17 | { |
17 | init(); | 18 | init(); |
18 | copy_old(old); | 19 | copy_old(old); |
19 | odebug << "Copy constructor RecMail" << oendl; | 20 | odebug << "Copy constructor RecMail" << oendl; |
20 | } | 21 | } |
21 | 22 | ||
22 | RecMail::~RecMail() | 23 | RecMail::~RecMail() |
23 | { | 24 | { |
24 | wrapper = 0; | 25 | wrapper = 0; |
25 | } | 26 | } |
26 | 27 | ||
27 | void RecMail::copy_old(const RecMail&old) | 28 | void RecMail::copy_old(const RecMail&old) |
28 | { | 29 | { |
29 | subject = old.subject; | 30 | subject = old.subject; |
31 | maildate = old.maildate; | ||
30 | date = old.date; | 32 | date = old.date; |
31 | mbox = old.mbox; | 33 | mbox = old.mbox; |
32 | msg_id = old.msg_id; | 34 | msg_id = old.msg_id; |
33 | msg_size = old.msg_size; | 35 | msg_size = old.msg_size; |
34 | msg_number = old.msg_number; | 36 | msg_number = old.msg_number; |
35 | from = old.from; | 37 | from = old.from; |
36 | msg_flags = old.msg_flags; | 38 | msg_flags = old.msg_flags; |
37 | to = old.to; | 39 | to = old.to; |
38 | cc = old.cc; | 40 | cc = old.cc; |
39 | bcc = old.bcc; | 41 | bcc = old.bcc; |
40 | wrapper = old.wrapper; | 42 | wrapper = old.wrapper; |
41 | in_reply_to = old.in_reply_to; | 43 | in_reply_to = old.in_reply_to; |
42 | references = old.references; | 44 | references = old.references; |
43 | replyto = old.replyto; | 45 | replyto = old.replyto; |
44 | } | 46 | } |
45 | 47 | ||
46 | void RecMail::init() | 48 | void RecMail::init() |
47 | { | 49 | { |
48 | to.clear(); | 50 | to.clear(); |
49 | cc.clear(); | 51 | cc.clear(); |
50 | bcc.clear(); | 52 | bcc.clear(); |
51 | in_reply_to.clear(); | 53 | in_reply_to.clear(); |
52 | references.clear(); | 54 | references.clear(); |
53 | wrapper = 0; | 55 | wrapper = 0; |
54 | } | 56 | } |
55 | 57 | ||
58 | void RecMail::setDate( const QDateTime&a,int offset) | ||
59 | { | ||
60 | QString timestring = TimeString::numberDateString(a.date())+" "; | ||
61 | timestring+=TimeString::timeString(a.time()); | ||
62 | if (offset > 0) { | ||
63 | timestring.sprintf(timestring+" %+05i",offset); | ||
64 | } | ||
65 | date = timestring; | ||
66 | maildate = a; | ||
67 | } | ||
68 | |||
56 | void RecMail::setWrapper(AbstractMail*awrapper) | 69 | void RecMail::setWrapper(AbstractMail*awrapper) |
57 | { | 70 | { |
58 | wrapper = awrapper; | 71 | wrapper = awrapper; |
59 | } | 72 | } |
60 | 73 | ||
61 | AbstractMail* RecMail::Wrapper() | 74 | AbstractMail* RecMail::Wrapper() |
62 | { | 75 | { |
63 | return wrapper; | 76 | return wrapper; |
64 | } | 77 | } |
65 | 78 | ||
66 | void RecMail::setTo(const QStringList&list) | 79 | void RecMail::setTo(const QStringList&list) |
67 | { | 80 | { |
68 | to = list; | 81 | to = list; |
69 | } | 82 | } |
70 | 83 | ||
71 | const QStringList&RecMail::To()const | 84 | const QStringList&RecMail::To()const |
72 | { | 85 | { |
73 | return to; | 86 | return to; |
74 | } | 87 | } |
75 | 88 | ||
76 | void RecMail::setCC(const QStringList&list) | 89 | void RecMail::setCC(const QStringList&list) |
77 | { | 90 | { |
78 | cc = list; | 91 | cc = list; |
79 | } | 92 | } |
80 | 93 | ||
81 | const QStringList&RecMail::CC()const | 94 | const QStringList&RecMail::CC()const |
82 | { | 95 | { |
83 | return cc; | 96 | return cc; |
84 | } | 97 | } |
85 | 98 | ||
86 | void RecMail::setBcc(const QStringList&list) | 99 | void RecMail::setBcc(const QStringList&list) |
87 | { | 100 | { |
88 | bcc = list; | 101 | bcc = list; |
89 | } | 102 | } |
90 | 103 | ||
91 | const QStringList& RecMail::Bcc()const | 104 | const QStringList& RecMail::Bcc()const |
92 | { | 105 | { |
93 | return bcc; | 106 | return bcc; |
94 | } | 107 | } |
95 | 108 | ||
96 | void RecMail::setInreply(const QStringList&list) | 109 | void RecMail::setInreply(const QStringList&list) |
97 | { | 110 | { |
98 | in_reply_to = list; | 111 | in_reply_to = list; |
99 | } | 112 | } |
100 | 113 | ||
101 | const QStringList& RecMail::Inreply()const | 114 | const QStringList& RecMail::Inreply()const |
102 | { | 115 | { |
103 | return in_reply_to; | 116 | return in_reply_to; |
104 | } | 117 | } |
105 | 118 | ||
106 | void RecMail::setReferences(const QStringList&list) | 119 | void RecMail::setReferences(const QStringList&list) |
107 | { | 120 | { |
108 | references = list; | 121 | references = list; |
109 | } | 122 | } |
110 | 123 | ||
111 | const QStringList& RecMail::References()const | 124 | const QStringList& RecMail::References()const |
112 | { | 125 | { |
113 | return references; | 126 | return references; |
114 | } | 127 | } |
115 | 128 | ||
116 | RecPart::RecPart() | 129 | RecPart::RecPart() |
117 | : Opie::Core::ORefCount(), | 130 | : Opie::Core::ORefCount(), |
118 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 131 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
119 | { | 132 | { |
120 | m_Parameters.clear(); | 133 | m_Parameters.clear(); |
121 | m_poslist.clear(); | 134 | m_poslist.clear(); |
122 | } | 135 | } |
123 | 136 | ||
124 | RecPart::RecPart(const RecPart&old) | 137 | RecPart::RecPart(const RecPart&old) |
125 | : Opie::Core::ORefCount(), | 138 | : Opie::Core::ORefCount(), |
126 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 139 | m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
127 | { | 140 | { |
128 | m_type = old.m_type; | 141 | m_type = old.m_type; |
129 | m_subtype = old.m_subtype; | 142 | m_subtype = old.m_subtype; |
130 | m_identifier = old.m_identifier; | 143 | m_identifier = old.m_identifier; |
131 | m_encoding = old.m_encoding; | 144 | m_encoding = old.m_encoding; |
132 | m_description = old.m_description; | 145 | m_description = old.m_description; |
133 | m_lines = old.m_lines; | 146 | m_lines = old.m_lines; |
134 | m_size = old.m_size; | 147 | m_size = old.m_size; |
135 | m_Parameters = old.m_Parameters; | 148 | m_Parameters = old.m_Parameters; |
136 | m_poslist = old.m_poslist; | 149 | m_poslist = old.m_poslist; |
137 | odebug << "RecPart copy constructor" << oendl; | 150 | odebug << "RecPart copy constructor" << oendl; |
138 | } | 151 | } |
139 | 152 | ||
140 | RecPart::~RecPart() | 153 | RecPart::~RecPart() |
141 | { | 154 | { |
142 | } | 155 | } |
143 | 156 | ||
144 | void RecPart::setSize(unsigned int size) | 157 | void RecPart::setSize(unsigned int size) |
145 | { | 158 | { |
146 | m_size = size; | 159 | m_size = size; |
147 | } | 160 | } |
148 | 161 | ||
149 | const unsigned int RecPart::Size()const | 162 | const unsigned int RecPart::Size()const |
150 | { | 163 | { |
151 | return m_size; | 164 | return m_size; |
152 | } | 165 | } |
153 | 166 | ||
154 | void RecPart::setLines(unsigned int lines) | 167 | void RecPart::setLines(unsigned int lines) |
155 | { | 168 | { |
156 | m_lines = lines; | 169 | m_lines = lines; |
157 | } | 170 | } |
158 | 171 | ||
159 | const unsigned int RecPart::Lines()const | 172 | const unsigned int RecPart::Lines()const |
160 | { | 173 | { |
161 | return m_lines; | 174 | return m_lines; |
162 | } | 175 | } |
163 | 176 | ||
164 | const QString& RecPart::Type()const | 177 | const QString& RecPart::Type()const |
165 | { | 178 | { |
166 | return m_type; | 179 | return m_type; |
167 | } | 180 | } |
168 | 181 | ||
169 | void RecPart::setType(const QString&type) | 182 | void RecPart::setType(const QString&type) |
170 | { | 183 | { |
171 | m_type = type; | 184 | m_type = type; |
172 | } | 185 | } |
173 | 186 | ||
174 | const QString& RecPart::Subtype()const | 187 | const QString& RecPart::Subtype()const |
175 | { | 188 | { |
176 | return m_subtype; | 189 | return m_subtype; |
177 | } | 190 | } |
178 | 191 | ||
179 | void RecPart::setSubtype(const QString&subtype) | 192 | void RecPart::setSubtype(const QString&subtype) |
180 | { | 193 | { |
181 | m_subtype = subtype; | 194 | m_subtype = subtype; |
182 | } | 195 | } |
183 | 196 | ||
184 | const QString& RecPart::Identifier()const | 197 | const QString& RecPart::Identifier()const |
185 | { | 198 | { |
186 | return m_identifier; | 199 | return m_identifier; |
187 | } | 200 | } |
188 | 201 | ||
189 | void RecPart::setIdentifier(const QString&identifier) | 202 | void RecPart::setIdentifier(const QString&identifier) |
190 | { | 203 | { |
191 | m_identifier = identifier; | 204 | m_identifier = identifier; |
192 | } | 205 | } |
193 | 206 | ||
194 | const QString& RecPart::Encoding()const | 207 | const QString& RecPart::Encoding()const |
195 | { | 208 | { |
196 | return m_encoding; | 209 | return m_encoding; |
197 | } | 210 | } |
198 | 211 | ||
199 | void RecPart::setEncoding(const QString&encoding) | 212 | void RecPart::setEncoding(const QString&encoding) |
200 | { | 213 | { |
201 | m_encoding = encoding; | 214 | m_encoding = encoding; |
202 | } | 215 | } |
203 | 216 | ||
204 | const QString& RecPart::Description()const | 217 | const QString& RecPart::Description()const |
205 | { | 218 | { |
206 | return m_description; | 219 | return m_description; |
207 | } | 220 | } |
208 | 221 | ||
209 | void RecPart::setDescription(const QString&desc) | 222 | void RecPart::setDescription(const QString&desc) |
210 | { | 223 | { |
211 | m_description = desc; | 224 | m_description = desc; |
212 | } | 225 | } |
213 | 226 | ||
214 | void RecPart::setParameters(const part_plist_t&list) | 227 | void RecPart::setParameters(const part_plist_t&list) |
215 | { | 228 | { |
216 | m_Parameters = list; | 229 | m_Parameters = list; |
217 | } | 230 | } |
218 | 231 | ||
219 | const part_plist_t& RecPart::Parameters()const | 232 | const part_plist_t& RecPart::Parameters()const |
220 | { | 233 | { |
221 | return m_Parameters; | 234 | return m_Parameters; |
222 | } | 235 | } |
223 | 236 | ||
224 | void RecPart::addParameter(const QString&key,const QString&value) | 237 | void RecPart::addParameter(const QString&key,const QString&value) |
225 | { | 238 | { |
226 | m_Parameters[key]=value; | 239 | m_Parameters[key]=value; |
227 | } | 240 | } |
228 | 241 | ||
229 | const QString RecPart::searchParamter(const QString&key)const | 242 | const QString RecPart::searchParamter(const QString&key)const |
230 | { | 243 | { |
231 | QString value(""); | 244 | QString value(""); |
232 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 245 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
233 | if (it != m_Parameters.end()) { | 246 | if (it != m_Parameters.end()) { |
234 | value = it.data(); | 247 | value = it.data(); |
235 | } | 248 | } |
236 | return value; | 249 | return value; |
237 | } | 250 | } |
238 | 251 | ||
239 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 252 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
240 | { | 253 | { |
241 | m_poslist = poslist; | 254 | m_poslist = poslist; |
242 | } | 255 | } |
243 | 256 | ||
244 | const QValueList<int>& RecPart::Positionlist()const | 257 | const QValueList<int>& RecPart::Positionlist()const |
245 | { | 258 | { |
246 | return m_poslist; | 259 | return m_poslist; |
247 | } | 260 | } |
248 | 261 | ||
249 | RecBody::RecBody() | 262 | RecBody::RecBody() |
250 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) | 263 | : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) |
251 | { | 264 | { |
252 | m_PartsList.clear(); | 265 | m_PartsList.clear(); |
253 | } | 266 | } |
254 | 267 | ||
255 | RecBody::RecBody(const RecBody&old) | 268 | RecBody::RecBody(const RecBody&old) |
256 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) | 269 | :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) |
257 | { | 270 | { |
258 | m_BodyText = old.m_BodyText; | 271 | m_BodyText = old.m_BodyText; |
259 | m_PartsList = old.m_PartsList; | 272 | m_PartsList = old.m_PartsList; |
260 | m_description = old.m_description; | 273 | m_description = old.m_description; |
261 | odebug << "Recbody copy constructor" << oendl; | 274 | odebug << "Recbody copy constructor" << oendl; |
262 | } | 275 | } |
263 | 276 | ||
264 | RecBody::~RecBody() | 277 | RecBody::~RecBody() |
265 | { | 278 | { |
266 | } | 279 | } |
267 | 280 | ||
268 | void RecBody::setBodytext(const QString&bodyText) | 281 | void RecBody::setBodytext(const QString&bodyText) |
269 | { | 282 | { |
270 | m_BodyText = bodyText; | 283 | m_BodyText = bodyText; |
271 | } | 284 | } |
272 | 285 | ||
273 | const QString& RecBody::Bodytext()const | 286 | const QString& RecBody::Bodytext()const |
274 | { | 287 | { |
275 | return m_BodyText; | 288 | return m_BodyText; |
276 | } | 289 | } |
277 | 290 | ||
278 | void RecBody::setParts(const QValueList<RecPartP>&parts) | 291 | void RecBody::setParts(const QValueList<RecPartP>&parts) |
279 | { | 292 | { |
280 | m_PartsList.clear(); | 293 | m_PartsList.clear(); |
281 | m_PartsList = parts; | 294 | m_PartsList = parts; |
282 | } | 295 | } |
283 | 296 | ||
284 | const QValueList<RecPartP>& RecBody::Parts()const | 297 | const QValueList<RecPartP>& RecBody::Parts()const |
285 | { | 298 | { |
286 | return m_PartsList; | 299 | return m_PartsList; |
287 | } | 300 | } |
288 | 301 | ||
289 | void RecBody::addPart(const RecPartP& part) | 302 | void RecBody::addPart(const RecPartP& part) |
290 | { | 303 | { |
291 | m_PartsList.append(part); | 304 | m_PartsList.append(part); |
292 | } | 305 | } |
293 | 306 | ||
294 | void RecBody::setDescription(const RecPartP&des) | 307 | void RecBody::setDescription(const RecPartP&des) |
295 | { | 308 | { |
296 | m_description = des; | 309 | m_description = des; |
297 | } | 310 | } |
298 | 311 | ||
299 | const RecPartP& RecBody::Description()const | 312 | const RecPartP& RecBody::Description()const |
300 | { | 313 | { |
301 | return m_description; | 314 | return m_description; |
302 | } | 315 | } |
303 | 316 | ||
304 | /* handling encoded content */ | 317 | /* handling encoded content */ |
305 | encodedString::encodedString() | 318 | encodedString::encodedString() |
306 | { | 319 | { |
307 | init(); | 320 | init(); |
308 | } | 321 | } |
309 | 322 | ||
310 | encodedString::encodedString(const char*nContent,unsigned int nSize) | 323 | encodedString::encodedString(const char*nContent,unsigned int nSize) |
311 | { | 324 | { |
312 | init(); | 325 | init(); |
313 | setContent(nContent,nSize); | 326 | setContent(nContent,nSize); |
314 | } | 327 | } |
315 | 328 | ||
316 | encodedString::encodedString(char*nContent,unsigned int nSize) | 329 | encodedString::encodedString(char*nContent,unsigned int nSize) |
317 | { | 330 | { |
318 | init(); | 331 | init(); |
319 | setContent(nContent,nSize); | 332 | setContent(nContent,nSize); |
320 | } | 333 | } |
321 | 334 | ||
322 | encodedString::encodedString(const encodedString&old) | 335 | encodedString::encodedString(const encodedString&old) |
323 | { | 336 | { |
324 | init(); | 337 | init(); |
325 | copy_old(old); | 338 | copy_old(old); |
326 | odebug << "encodedeString: copy constructor!" << oendl; | 339 | odebug << "encodedeString: copy constructor!" << oendl; |
327 | } | 340 | } |
328 | 341 | ||
329 | encodedString& encodedString::operator=(const encodedString&old) | 342 | encodedString& encodedString::operator=(const encodedString&old) |
330 | { | 343 | { |
331 | init(); | 344 | init(); |
332 | copy_old(old); | 345 | copy_old(old); |
333 | odebug << "encodedString: assign operator!" << oendl; | 346 | odebug << "encodedString: assign operator!" << oendl; |
334 | return *this; | 347 | return *this; |
335 | } | 348 | } |
336 | 349 | ||
337 | encodedString::~encodedString() | 350 | encodedString::~encodedString() |
338 | { | 351 | { |
339 | clean(); | 352 | clean(); |
340 | } | 353 | } |
341 | 354 | ||
342 | void encodedString::init() | 355 | void encodedString::init() |
343 | { | 356 | { |
344 | content = 0; | 357 | content = 0; |
345 | size = 0; | 358 | size = 0; |
346 | } | 359 | } |
347 | 360 | ||
348 | void encodedString::clean() | 361 | void encodedString::clean() |
349 | { | 362 | { |
350 | if (content) { | 363 | if (content) { |
351 | free(content); | 364 | free(content); |
352 | } | 365 | } |
353 | content = 0; | 366 | content = 0; |
354 | size = 0; | 367 | size = 0; |
355 | } | 368 | } |
356 | 369 | ||
357 | void encodedString::copy_old(const encodedString&old) | 370 | void encodedString::copy_old(const encodedString&old) |
358 | { | 371 | { |
359 | clean(); | 372 | clean(); |
360 | if (old.size>0 && old.content) { | 373 | if (old.size>0 && old.content) { |
361 | content = (char*)malloc(old.size*sizeof(char)); | 374 | content = (char*)malloc(old.size*sizeof(char)); |
362 | memcpy(content,old.content,size); | 375 | memcpy(content,old.content,size); |
363 | size = old.size; | 376 | size = old.size; |
364 | } | 377 | } |
365 | } | 378 | } |
366 | 379 | ||
367 | const char*encodedString::Content()const | 380 | const char*encodedString::Content()const |
368 | { | 381 | { |
369 | return content; | 382 | return content; |
370 | } | 383 | } |
371 | 384 | ||
372 | const int encodedString::Length()const | 385 | const int encodedString::Length()const |
373 | { | 386 | { |
374 | return size; | 387 | return size; |
375 | } | 388 | } |
376 | 389 | ||
377 | void encodedString::setContent(const char*nContent,int nSize) | 390 | void encodedString::setContent(const char*nContent,int nSize) |
378 | { | 391 | { |
379 | if (nSize>0 && nContent) { | 392 | if (nSize>0 && nContent) { |
380 | content = (char*)malloc(nSize*sizeof(char)); | 393 | content = (char*)malloc(nSize*sizeof(char)); |
381 | memcpy(content,nContent,nSize); | 394 | memcpy(content,nContent,nSize); |
382 | size = nSize; | 395 | size = nSize; |
383 | } | 396 | } |
384 | } | 397 | } |
385 | 398 | ||
386 | void encodedString::setContent(char*nContent,int nSize) | 399 | void encodedString::setContent(char*nContent,int nSize) |
387 | { | 400 | { |
388 | content = nContent; | 401 | content = nContent; |
389 | size = nSize; | 402 | size = nSize; |
390 | } | 403 | } |
391 | 404 | ||
392 | folderStat&folderStat::operator=(const folderStat&old) | 405 | folderStat&folderStat::operator=(const folderStat&old) |
393 | { | 406 | { |
394 | message_count = old.message_count; | 407 | message_count = old.message_count; |
395 | message_unseen = old.message_unseen; | 408 | message_unseen = old.message_unseen; |
396 | message_recent = old.message_recent; | 409 | message_recent = old.message_recent; |
397 | return *this; | 410 | return *this; |
398 | } | 411 | } |
399 | |||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index c317880..272514c 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,206 +1,211 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | #include <qdatetime.h> | ||
18 | 19 | ||
19 | class AbstractMail; | 20 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 21 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 22 | /* Attention! |
22 | From programmers point of view it would make sense to | 23 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 24 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 25 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 26 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 27 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 28 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 29 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 30 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 31 | get the body. Same words for the attachments. |
31 | */ | 32 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 33 | class RecMail:public Opie::Core::ORefCount |
33 | { | 34 | { |
34 | public: | 35 | public: |
35 | RecMail(); | 36 | RecMail(); |
36 | RecMail(const RecMail&old); | 37 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 38 | virtual ~RecMail(); |
38 | 39 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | ||
42 | void setDate( const QString&a ) { date = a; } | ||
43 | const QString&getFrom()const{ return from; } | 42 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 43 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 44 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 45 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 46 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 47 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 48 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 49 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 50 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 51 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 52 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 53 | const unsigned int Msgsize()const{return msg_size;} |
55 | 54 | ||
56 | 55 | ||
57 | void setTo(const QStringList&list); | 56 | void setTo(const QStringList&list); |
58 | const QStringList&To()const; | 57 | const QStringList&To()const; |
59 | void setCC(const QStringList&list); | 58 | void setCC(const QStringList&list); |
60 | const QStringList&CC()const; | 59 | const QStringList&CC()const; |
61 | void setBcc(const QStringList&list); | 60 | void setBcc(const QStringList&list); |
62 | const QStringList&Bcc()const; | 61 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 62 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 63 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 64 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 65 | const QStringList&References()const; |
67 | 66 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 67 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 68 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 69 | ||
71 | void setWrapper(AbstractMail*wrapper); | 70 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 71 | AbstractMail* Wrapper(); |
73 | 72 | ||
73 | const QDateTime&getDate()const{ return maildate; } | ||
74 | const QString&getStringDate()const{return date;} | ||
75 | void setDate( const QDateTime&a,int offset=0 ); | ||
76 | |||
74 | protected: | 77 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 78 | QString subject,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 79 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 80 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 81 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 82 | AbstractMail*wrapper; |
80 | void init(); | 83 | void init(); |
81 | void copy_old(const RecMail&old); | 84 | void copy_old(const RecMail&old); |
85 | QDateTime maildate; | ||
86 | QString date; | ||
82 | }; | 87 | }; |
83 | 88 | ||
84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 89 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 90 | typedef QMap<QString,QString> part_plist_t; |
86 | 91 | ||
87 | class RecPart:public Opie::Core::ORefCount | 92 | class RecPart:public Opie::Core::ORefCount |
88 | { | 93 | { |
89 | protected: | 94 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 95 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 96 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 97 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 98 | /* describes the position in the mail */ |
94 | QValueList<int> m_poslist; | 99 | QValueList<int> m_poslist; |
95 | 100 | ||
96 | public: | 101 | public: |
97 | RecPart(); | 102 | RecPart(); |
98 | RecPart(const RecPart&); | 103 | RecPart(const RecPart&); |
99 | virtual ~RecPart(); | 104 | virtual ~RecPart(); |
100 | 105 | ||
101 | const QString&Type()const; | 106 | const QString&Type()const; |
102 | void setType(const QString&type); | 107 | void setType(const QString&type); |
103 | const QString&Subtype()const; | 108 | const QString&Subtype()const; |
104 | void setSubtype(const QString&subtype); | 109 | void setSubtype(const QString&subtype); |
105 | const QString&Identifier()const; | 110 | const QString&Identifier()const; |
106 | void setIdentifier(const QString&identifier); | 111 | void setIdentifier(const QString&identifier); |
107 | const QString&Encoding()const; | 112 | const QString&Encoding()const; |
108 | void setEncoding(const QString&encoding); | 113 | void setEncoding(const QString&encoding); |
109 | const QString&Description()const; | 114 | const QString&Description()const; |
110 | void setDescription(const QString&desc); | 115 | void setDescription(const QString&desc); |
111 | void setLines(unsigned int lines); | 116 | void setLines(unsigned int lines); |
112 | const unsigned int Lines()const; | 117 | const unsigned int Lines()const; |
113 | void setSize(unsigned int size); | 118 | void setSize(unsigned int size); |
114 | const unsigned int Size()const; | 119 | const unsigned int Size()const; |
115 | 120 | ||
116 | 121 | ||
117 | void setParameters(const part_plist_t&list); | 122 | void setParameters(const part_plist_t&list); |
118 | const part_plist_t&Parameters()const; | 123 | const part_plist_t&Parameters()const; |
119 | void addParameter(const QString&key,const QString&value); | 124 | void addParameter(const QString&key,const QString&value); |
120 | const QString searchParamter(const QString&key)const; | 125 | const QString searchParamter(const QString&key)const; |
121 | void setPositionlist(const QValueList<int>&poslist); | 126 | void setPositionlist(const QValueList<int>&poslist); |
122 | const QValueList<int>& Positionlist()const; | 127 | const QValueList<int>& Positionlist()const; |
123 | }; | 128 | }; |
124 | 129 | ||
125 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; | 130 | typedef Opie::Core::OSmartPointer<RecPart> RecPartP; |
126 | 131 | ||
127 | class RecBody:public Opie::Core::ORefCount | 132 | class RecBody:public Opie::Core::ORefCount |
128 | { | 133 | { |
129 | protected: | 134 | protected: |
130 | QString m_BodyText; | 135 | QString m_BodyText; |
131 | QValueList<RecPartP> m_PartsList; | 136 | QValueList<RecPartP> m_PartsList; |
132 | RecPartP m_description; | 137 | RecPartP m_description; |
133 | 138 | ||
134 | public: | 139 | public: |
135 | RecBody(); | 140 | RecBody(); |
136 | RecBody(const RecBody&old); | 141 | RecBody(const RecBody&old); |
137 | virtual ~RecBody(); | 142 | virtual ~RecBody(); |
138 | void setBodytext(const QString&); | 143 | void setBodytext(const QString&); |
139 | const QString& Bodytext()const; | 144 | const QString& Bodytext()const; |
140 | 145 | ||
141 | void setDescription(const RecPartP&des); | 146 | void setDescription(const RecPartP&des); |
142 | const RecPartP& Description()const; | 147 | const RecPartP& Description()const; |
143 | 148 | ||
144 | void setParts(const QValueList<RecPartP>&parts); | 149 | void setParts(const QValueList<RecPartP>&parts); |
145 | const QValueList<RecPartP>& Parts()const; | 150 | const QValueList<RecPartP>& Parts()const; |
146 | void addPart(const RecPartP&part); | 151 | void addPart(const RecPartP&part); |
147 | }; | 152 | }; |
148 | 153 | ||
149 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; | 154 | typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; |
150 | 155 | ||
151 | class encodedString | 156 | class encodedString |
152 | { | 157 | { |
153 | public: | 158 | public: |
154 | encodedString(); | 159 | encodedString(); |
155 | /* | 160 | /* |
156 | creates an new content string. | 161 | creates an new content string. |
157 | it makes a deep copy of it! | 162 | it makes a deep copy of it! |
158 | */ | 163 | */ |
159 | encodedString(const char*nContent,unsigned int length); | 164 | encodedString(const char*nContent,unsigned int length); |
160 | /* | 165 | /* |
161 | Take over the nContent. Means: it will just copy the pointer, not the content. | 166 | Take over the nContent. Means: it will just copy the pointer, not the content. |
162 | so make sure: No one else frees the string, the string has allocated with | 167 | so make sure: No one else frees the string, the string has allocated with |
163 | malloc for compatibility with c-based libs | 168 | malloc for compatibility with c-based libs |
164 | */ | 169 | */ |
165 | encodedString(char*nContent,unsigned int nSize); | 170 | encodedString(char*nContent,unsigned int nSize); |
166 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 171 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
167 | encodedString(const encodedString&old); | 172 | encodedString(const encodedString&old); |
168 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 173 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
169 | encodedString& operator=(const encodedString&old); | 174 | encodedString& operator=(const encodedString&old); |
170 | /* destructor - cleans the content */ | 175 | /* destructor - cleans the content */ |
171 | virtual ~encodedString(); | 176 | virtual ~encodedString(); |
172 | 177 | ||
173 | /* returns a pointer to the content - do not delete yoursel! */ | 178 | /* returns a pointer to the content - do not delete yoursel! */ |
174 | const char*Content()const; | 179 | const char*Content()const; |
175 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 180 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
176 | const int Length()const; | 181 | const int Length()const; |
177 | 182 | ||
178 | /* | 183 | /* |
179 | makes a deep copy of nContent! | 184 | makes a deep copy of nContent! |
180 | */ | 185 | */ |
181 | void setContent(const char*nContent,int nSize); | 186 | void setContent(const char*nContent,int nSize); |
182 | /* | 187 | /* |
183 | Take over the nContent. Means: it will just copy the pointer, not the content. | 188 | Take over the nContent. Means: it will just copy the pointer, not the content. |
184 | so make sure: No one else frees the string, the string has allocated with | 189 | so make sure: No one else frees the string, the string has allocated with |
185 | malloc for compatibility with c-based libs | 190 | malloc for compatibility with c-based libs |
186 | */ | 191 | */ |
187 | void setContent(char*nContent,int nSize); | 192 | void setContent(char*nContent,int nSize); |
188 | 193 | ||
189 | protected: | 194 | protected: |
190 | char * content; | 195 | char * content; |
191 | unsigned int size; | 196 | unsigned int size; |
192 | 197 | ||
193 | void init(); | 198 | void init(); |
194 | void copy_old(const encodedString&old); | 199 | void copy_old(const encodedString&old); |
195 | void clean(); | 200 | void clean(); |
196 | }; | 201 | }; |
197 | 202 | ||
198 | struct folderStat | 203 | struct folderStat |
199 | { | 204 | { |
200 | unsigned int message_count; | 205 | unsigned int message_count; |
201 | unsigned int message_unseen; | 206 | unsigned int message_unseen; |
202 | unsigned int message_recent; | 207 | unsigned int message_recent; |
203 | folderStat&operator=(const folderStat&old); | 208 | folderStat&operator=(const folderStat&old); |
204 | }; | 209 | }; |
205 | 210 | ||
206 | #endif | 211 | #endif |
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp index 0b926da..d3a0723 100644 --- a/noncore/net/mail/mailistviewitem.cpp +++ b/noncore/net/mail/mailistviewitem.cpp | |||
@@ -1,72 +1,86 @@ | |||
1 | #include "mailistviewitem.h" | 1 | #include "mailistviewitem.h" |
2 | #include <libmailwrapper/abstractmail.h> | 2 | #include <libmailwrapper/abstractmail.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/timestring.h> | ||
5 | 6 | ||
6 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 7 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
7 | :QListViewItem(parent,item),mail_data() | 8 | :QListViewItem(parent,item),mail_data() |
8 | { | 9 | { |
9 | } | 10 | } |
10 | 11 | ||
11 | void MailListViewItem::showEntry() | 12 | void MailListViewItem::showEntry() |
12 | { | 13 | { |
13 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 14 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
14 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | 15 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); |
15 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 16 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
16 | /* I think it looks nicer if there are not such a log of icons but only on mails | 17 | /* I think it looks nicer if there are not such a lot of icons but only on mails |
17 | replied or new - Alwin*/ | 18 | replied or new - Alwin*/ |
18 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | 19 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); |
19 | } else { | 20 | } else { |
20 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | 21 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); |
21 | } | 22 | } |
22 | double s = mail_data->Msgsize(); | 23 | double s = mail_data->Msgsize(); |
23 | int w; | 24 | int w; |
24 | w=0; | 25 | w=0; |
25 | 26 | ||
26 | while (s>1024) { | 27 | while (s>1024) { |
27 | s/=1024; | 28 | s/=1024; |
28 | ++w; | 29 | ++w; |
29 | if (w>=2) break; | 30 | if (w>=2) break; |
30 | } | 31 | } |
31 | 32 | ||
32 | QString q=""; | 33 | QString q=""; |
33 | QString fsize=""; | 34 | QString fsize=""; |
34 | switch(w) { | 35 | switch(w) { |
35 | case 1: | 36 | case 1: |
36 | q="k"; | 37 | q="k"; |
37 | break; | 38 | break; |
38 | case 2: | 39 | case 2: |
39 | q="M"; | 40 | q="M"; |
40 | break; | 41 | break; |
41 | default: | 42 | default: |
42 | break; | 43 | break; |
43 | } | 44 | } |
44 | 45 | ||
45 | { | 46 | { |
46 | QTextOStream o(&fsize); | 47 | QTextOStream o(&fsize); |
47 | if (w>0) o.precision(2); else o.precision(0); | 48 | if (w>0) o.precision(2); else o.precision(0); |
48 | o.setf(QTextStream::fixed); | 49 | o.setf(QTextStream::fixed); |
49 | o << s << " " << q << "Byte"; | 50 | o << s << " " << q << "Byte"; |
50 | } | 51 | } |
51 | |||
52 | setText(1,mail_data->getSubject()); | 52 | setText(1,mail_data->getSubject()); |
53 | setText(2,mail_data->getFrom()); | 53 | setText(2,mail_data->getFrom()); |
54 | setText(3,fsize); | 54 | setText(3,fsize); |
55 | setText(4,mail_data->getDate()); | 55 | setText(4,mail_data->getStringDate()); |
56 | } | ||
57 | |||
58 | QString MailListViewItem::key(int col,bool) const | ||
59 | { | ||
60 | QString temp; | ||
61 | if (col == 4) { | ||
62 | temp.sprintf( "%08d",QDateTime().secsTo(mail_data->getDate())); | ||
63 | return temp; | ||
64 | } | ||
65 | if (col == 3) { | ||
66 | temp.sprintf( "%020d",mail_data->Msgsize()); | ||
67 | return temp; | ||
68 | } | ||
69 | return text(col); | ||
56 | } | 70 | } |
57 | 71 | ||
58 | void MailListViewItem::storeData(const RecMailP&data) | 72 | void MailListViewItem::storeData(const RecMailP&data) |
59 | { | 73 | { |
60 | mail_data = data; | 74 | mail_data = data; |
61 | } | 75 | } |
62 | 76 | ||
63 | const RecMailP& MailListViewItem::data()const | 77 | const RecMailP& MailListViewItem::data()const |
64 | { | 78 | { |
65 | return mail_data; | 79 | return mail_data; |
66 | } | 80 | } |
67 | 81 | ||
68 | MAILLIB::ATYPE MailListViewItem::wrapperType() | 82 | MAILLIB::ATYPE MailListViewItem::wrapperType() |
69 | { | 83 | { |
70 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; | 84 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; |
71 | return mail_data->Wrapper()->getType(); | 85 | return mail_data->Wrapper()->getType(); |
72 | } | 86 | } |
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index d953d83..ce64ca9 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h | |||
@@ -1,23 +1,24 @@ | |||
1 | #ifndef __MAILLISTVIEWITEM_H | 1 | #ifndef __MAILLISTVIEWITEM_H |
2 | #define __MAILLISTVIEWITEM_H | 2 | #define __MAILLISTVIEWITEM_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <libmailwrapper/mailtypes.h> | 5 | #include <libmailwrapper/mailtypes.h> |
6 | #include <libmailwrapper/maildefines.h> | 6 | #include <libmailwrapper/maildefines.h> |
7 | 7 | ||
8 | class MailListViewItem:public QListViewItem | 8 | class MailListViewItem:public QListViewItem |
9 | { | 9 | { |
10 | public: | 10 | public: |
11 | MailListViewItem(QListView * parent, MailListViewItem * after ); | 11 | MailListViewItem(QListView * parent, MailListViewItem * after ); |
12 | virtual ~MailListViewItem(){} | 12 | virtual ~MailListViewItem(){} |
13 | 13 | ||
14 | void storeData(const RecMailP&data); | 14 | void storeData(const RecMailP&data); |
15 | const RecMailP&data()const; | 15 | const RecMailP&data()const; |
16 | void showEntry(); | 16 | void showEntry(); |
17 | MAILLIB::ATYPE wrapperType(); | 17 | MAILLIB::ATYPE wrapperType(); |
18 | 18 | ||
19 | virtual QString key(int col,bool) const; | ||
19 | protected: | 20 | protected: |
20 | RecMailP mail_data; | 21 | RecMailP mail_data; |
21 | }; | 22 | }; |
22 | 23 | ||
23 | #endif | 24 | #endif |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 6252fc2..c115b32 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,218 +1,219 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | #include "defines.h" | 10 | #include "defines.h" |
11 | #include "mainwindow.h" | 11 | #include "mainwindow.h" |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | 14 | ||
15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
16 | : QMainWindow( parent, name, flags ) | 16 | : QMainWindow( parent, name, flags ) |
17 | { | 17 | { |
18 | 18 | ||
19 | setCaption( tr( "Mail" ) ); | 19 | setCaption( tr( "Mail" ) ); |
20 | setToolBarsMovable( false ); | 20 | setToolBarsMovable( false ); |
21 | 21 | ||
22 | toolBar = new QToolBar( this ); | 22 | toolBar = new QToolBar( this ); |
23 | menuBar = new QMenuBar( toolBar ); | 23 | menuBar = new QMenuBar( toolBar ); |
24 | mailMenu = new QPopupMenu( menuBar ); | 24 | mailMenu = new QPopupMenu( menuBar ); |
25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
26 | settingsMenu = new QPopupMenu( menuBar ); | 26 | settingsMenu = new QPopupMenu( menuBar ); |
27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
28 | 28 | ||
29 | addToolBar( toolBar ); | 29 | addToolBar( toolBar ); |
30 | toolBar->setHorizontalStretchable( true ); | 30 | toolBar->setHorizontalStretchable( true ); |
31 | 31 | ||
32 | QLabel *spacer = new QLabel( toolBar ); | 32 | QLabel *spacer = new QLabel( toolBar ); |
33 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 33 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
34 | toolBar->setStretchableWidget( spacer ); | 34 | toolBar->setStretchableWidget( spacer ); |
35 | 35 | ||
36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
37 | 0, 0, this ); | 37 | 0, 0, this ); |
38 | composeMail->addTo( toolBar ); | 38 | composeMail->addTo( toolBar ); |
39 | composeMail->addTo( mailMenu ); | 39 | composeMail->addTo( mailMenu ); |
40 | 40 | ||
41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
42 | 0, 0, this ); | 42 | 0, 0, this ); |
43 | sendQueued->addTo( toolBar ); | 43 | sendQueued->addTo( toolBar ); |
44 | sendQueued->addTo( mailMenu ); | 44 | sendQueued->addTo( mailMenu ); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
48 | 0, 0, this ); | 48 | 0, 0, this ); |
49 | syncFolders->addTo( toolBar ); | 49 | syncFolders->addTo( toolBar ); |
50 | syncFolders->addTo( mailMenu ); | 50 | syncFolders->addTo( mailMenu ); |
51 | */ | 51 | */ |
52 | 52 | ||
53 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 53 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
54 | 0, 0, this, 0, true ); | 54 | 0, 0, this, 0, true ); |
55 | showFolders->addTo( toolBar ); | 55 | showFolders->addTo( toolBar ); |
56 | showFolders->addTo( mailMenu ); | 56 | showFolders->addTo( mailMenu ); |
57 | showFolders->setOn( true ); | 57 | showFolders->setOn( true ); |
58 | connect(showFolders, SIGNAL( toggled(bool) ), | 58 | connect(showFolders, SIGNAL( toggled(bool) ), |
59 | SLOT( slotShowFolders(bool) ) ); | 59 | SLOT( slotShowFolders(bool) ) ); |
60 | 60 | ||
61 | /* | 61 | /* |
62 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), | 62 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), |
63 | 0, 0, this ); | 63 | 0, 0, this ); |
64 | searchMails->addTo( toolBar ); | 64 | searchMails->addTo( toolBar ); |
65 | searchMails->addTo( mailMenu ); | 65 | searchMails->addTo( mailMenu ); |
66 | */ | 66 | */ |
67 | 67 | ||
68 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); | 68 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); |
69 | deleteMails->addTo( toolBar ); | 69 | deleteMails->addTo( toolBar ); |
70 | deleteMails->addTo( mailMenu ); | 70 | deleteMails->addTo( mailMenu ); |
71 | connect( deleteMails, SIGNAL( activated() ), | 71 | connect( deleteMails, SIGNAL( activated() ), |
72 | SLOT( slotDeleteMail() ) ); | 72 | SLOT( slotDeleteMail() ) ); |
73 | 73 | ||
74 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , | 74 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
75 | 0, 0, this ); | 75 | 0, 0, this ); |
76 | editSettings->addTo( settingsMenu ); | 76 | editSettings->addTo( settingsMenu ); |
77 | connect( editSettings, SIGNAL( activated() ), | 77 | connect( editSettings, SIGNAL( activated() ), |
78 | SLOT( slotEditSettings() ) ); | 78 | SLOT( slotEditSettings() ) ); |
79 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , | 79 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , |
80 | 0, 0, this ); | 80 | 0, 0, this ); |
81 | editAccounts->addTo( settingsMenu ); | 81 | editAccounts->addTo( settingsMenu ); |
82 | 82 | ||
83 | //setCentralWidget( view ); | 83 | //setCentralWidget( view ); |
84 | 84 | ||
85 | QVBox* wrapperBox = new QVBox( this ); | 85 | QVBox* wrapperBox = new QVBox( this ); |
86 | setCentralWidget( wrapperBox ); | 86 | setCentralWidget( wrapperBox ); |
87 | 87 | ||
88 | QWidget *view = new QWidget( wrapperBox ); | 88 | QWidget *view = new QWidget( wrapperBox ); |
89 | 89 | ||
90 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 90 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
91 | 91 | ||
92 | folderView = new AccountView( view ); | 92 | folderView = new AccountView( view ); |
93 | folderView->header()->hide(); | 93 | folderView->header()->hide(); |
94 | folderView->setRootIsDecorated( true ); | 94 | folderView->setRootIsDecorated( true ); |
95 | folderView->addColumn( tr( "Mailbox" ) ); | 95 | folderView->addColumn( tr( "Mailbox" ) ); |
96 | 96 | ||
97 | layout->addWidget( folderView ); | 97 | layout->addWidget( folderView ); |
98 | 98 | ||
99 | mailView = new QListView( view ); | 99 | mailView = new QListView( view ); |
100 | mailView->addColumn( "" ); | 100 | mailView->addColumn( "" ); |
101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
103 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 103 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
104 | mailView->addColumn( tr( "Date" )); | 104 | mailView->addColumn( tr( "Date" )); |
105 | mailView->setAllColumnsShowFocus(true); | 105 | mailView->setAllColumnsShowFocus(true); |
106 | mailView->setSorting(-1); | 106 | mailView->setShowSortIndicator(true); |
107 | mailView->setSorting(4,false); | ||
107 | 108 | ||
108 | statusWidget = new StatusWidget( wrapperBox ); | 109 | statusWidget = new StatusWidget( wrapperBox ); |
109 | statusWidget->hide(); | 110 | statusWidget->hide(); |
110 | 111 | ||
111 | layout->addWidget( mailView ); | 112 | layout->addWidget( mailView ); |
112 | layout->setStretchFactor( folderView, 1 ); | 113 | layout->setStretchFactor( folderView, 1 ); |
113 | layout->setStretchFactor( mailView, 2 ); | 114 | layout->setStretchFactor( mailView, 2 ); |
114 | 115 | ||
115 | slotAdjustLayout(); | 116 | slotAdjustLayout(); |
116 | 117 | ||
117 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 118 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
118 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 119 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
119 | 120 | ||
120 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, | 121 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, |
121 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); | 122 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); |
122 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 123 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
123 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 124 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
124 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 125 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
125 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 126 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
126 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 127 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
127 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 128 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
128 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 129 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
129 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 130 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
130 | // Added by Stefan Eilers to allow starting by addressbook.. | 131 | // Added by Stefan Eilers to allow starting by addressbook.. |
131 | // copied from old mail2 | 132 | // copied from old mail2 |
132 | #if !defined(QT_NO_COP) | 133 | #if !defined(QT_NO_COP) |
133 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 134 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
134 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 135 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
135 | #endif | 136 | #endif |
136 | 137 | ||
137 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 138 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
138 | } | 139 | } |
139 | 140 | ||
140 | MainWindow::~MainWindow() | 141 | MainWindow::~MainWindow() |
141 | { | 142 | { |
142 | } | 143 | } |
143 | 144 | ||
144 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 145 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
145 | { | 146 | { |
146 | odebug << "appMessage not reached" << oendl; | 147 | odebug << "appMessage not reached" << oendl; |
147 | } | 148 | } |
148 | 149 | ||
149 | void MainWindow::slotAdjustLayout() { | 150 | void MainWindow::slotAdjustLayout() { |
150 | 151 | ||
151 | QWidget *d = QApplication::desktop(); | 152 | QWidget *d = QApplication::desktop(); |
152 | 153 | ||
153 | if ( d->width() < d->height() ) { | 154 | if ( d->width() < d->height() ) { |
154 | layout->setDirection( QBoxLayout::TopToBottom ); | 155 | layout->setDirection( QBoxLayout::TopToBottom ); |
155 | } else { | 156 | } else { |
156 | layout->setDirection( QBoxLayout::LeftToRight ); | 157 | layout->setDirection( QBoxLayout::LeftToRight ); |
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | void MainWindow::slotAdjustColumns() | 161 | void MainWindow::slotAdjustColumns() |
161 | { | 162 | { |
162 | bool hidden = folderView->isHidden(); | 163 | bool hidden = folderView->isHidden(); |
163 | if ( hidden ) folderView->show(); | 164 | if ( hidden ) folderView->show(); |
164 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 165 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
165 | if ( hidden ) folderView->hide(); | 166 | if ( hidden ) folderView->hide(); |
166 | 167 | ||
167 | mailView->setColumnWidth( 0, 10 ); | 168 | mailView->setColumnWidth( 0, 10 ); |
168 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 169 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
169 | mailView->setColumnWidth( 2, 80 ); | 170 | mailView->setColumnWidth( 2, 80 ); |
170 | mailView->setColumnWidth( 3, 50 ); | 171 | mailView->setColumnWidth( 3, 50 ); |
171 | mailView->setColumnWidth( 4, 50 ); | 172 | mailView->setColumnWidth( 4, 50 ); |
172 | } | 173 | } |
173 | 174 | ||
174 | void MainWindow::slotEditSettings() | 175 | void MainWindow::slotEditSettings() |
175 | { | 176 | { |
176 | } | 177 | } |
177 | 178 | ||
178 | void MainWindow::slotShowFolders( bool ) | 179 | void MainWindow::slotShowFolders( bool ) |
179 | { | 180 | { |
180 | odebug << "slotShowFolders not reached" << oendl; | 181 | odebug << "slotShowFolders not reached" << oendl; |
181 | } | 182 | } |
182 | 183 | ||
183 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 184 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
184 | { | 185 | { |
185 | odebug << "refreshMailView not reached" << oendl; | 186 | odebug << "refreshMailView not reached" << oendl; |
186 | } | 187 | } |
187 | 188 | ||
188 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | 189 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) |
189 | { | 190 | { |
190 | odebug << "mailLeftClicked not reached" << oendl; | 191 | odebug << "mailLeftClicked not reached" << oendl; |
191 | } | 192 | } |
192 | 193 | ||
193 | void MainWindow::displayMail() | 194 | void MainWindow::displayMail() |
194 | { | 195 | { |
195 | odebug << "displayMail not reached" << oendl; | 196 | odebug << "displayMail not reached" << oendl; |
196 | } | 197 | } |
197 | 198 | ||
198 | void MainWindow::slotDeleteMail() | 199 | void MainWindow::slotDeleteMail() |
199 | { | 200 | { |
200 | odebug << "deleteMail not reached" << oendl; | 201 | odebug << "deleteMail not reached" << oendl; |
201 | } | 202 | } |
202 | 203 | ||
203 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 204 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
204 | { | 205 | { |
205 | odebug << "mailHold not reached" << oendl; | 206 | odebug << "mailHold not reached" << oendl; |
206 | } | 207 | } |
207 | 208 | ||
208 | void MainWindow::slotSendQueued() | 209 | void MainWindow::slotSendQueued() |
209 | { | 210 | { |
210 | } | 211 | } |
211 | 212 | ||
212 | void MainWindow::slotEditAccounts() | 213 | void MainWindow::slotEditAccounts() |
213 | { | 214 | { |
214 | } | 215 | } |
215 | 216 | ||
216 | void MainWindow::slotComposeMail() | 217 | void MainWindow::slotComposeMail() |
217 | { | 218 | { |
218 | } | 219 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index ce694d5..d5f9b7f 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -19,402 +19,402 @@ | |||
19 | #include <qaction.h> | 19 | #include <qaction.h> |
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | 23 | ||
24 | using namespace Opie::Ui; | 24 | using namespace Opie::Ui; |
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 27 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
28 | const QString&fsize,int num,const QValueList<int>&path) | 28 | const QString&fsize,int num,const QValueList<int>&path) |
29 | : QListViewItem(parent,after),_partNum(num) | 29 | : QListViewItem(parent,after),_partNum(num) |
30 | { | 30 | { |
31 | _path=path; | 31 | _path=path; |
32 | setText(0, mime); | 32 | setText(0, mime); |
33 | setText(1, desc); | 33 | setText(1, desc); |
34 | setText(2, file); | 34 | setText(2, file); |
35 | setText(3, fsize); | 35 | setText(3, fsize); |
36 | } | 36 | } |
37 | 37 | ||
38 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 38 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
39 | const QString&fsize,int num,const QValueList<int>&path) | 39 | const QString&fsize,int num,const QValueList<int>&path) |
40 | : QListViewItem(parent,after),_partNum(num) | 40 | : QListViewItem(parent,after),_partNum(num) |
41 | { | 41 | { |
42 | _path=path; | 42 | _path=path; |
43 | setText(0, mime); | 43 | setText(0, mime); |
44 | setText(1, desc); | 44 | setText(1, desc); |
45 | setText(2, file); | 45 | setText(2, file); |
46 | setText(3, fsize); | 46 | setText(3, fsize); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool AttachItem::isParentof(const QValueList<int>&path) | 49 | bool AttachItem::isParentof(const QValueList<int>&path) |
50 | { | 50 | { |
51 | /* if not set, then no parent */ | 51 | /* if not set, then no parent */ |
52 | if (path.count()==0||_path.count()==0) return false; | 52 | if (path.count()==0||_path.count()==0) return false; |
53 | /* the parent must have one digit less then a child */ | 53 | /* the parent must have one digit less then a child */ |
54 | if (path.count()!=_path.count()+1) return false; | 54 | if (path.count()!=_path.count()+1) return false; |
55 | for (unsigned int i=0; i < _path.count();++i) | 55 | for (unsigned int i=0; i < _path.count();++i) |
56 | { | 56 | { |
57 | if (_path[i]!=path[i]) return false; | 57 | if (_path[i]!=path[i]) return false; |
58 | } | 58 | } |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 62 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
63 | { | 63 | { |
64 | QListViewItemIterator it( attachments ); | 64 | QListViewItemIterator it( attachments ); |
65 | for ( ; it.current(); ++it ) | 65 | for ( ; it.current(); ++it ) |
66 | { | 66 | { |
67 | AttachItem*ati = (AttachItem*)it.current(); | 67 | AttachItem*ati = (AttachItem*)it.current(); |
68 | if (ati->isParentof(path)) return ati; | 68 | if (ati->isParentof(path)) return ati; |
69 | } | 69 | } |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 73 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
74 | { | 74 | { |
75 | if (!parent) return 0; | 75 | if (!parent) return 0; |
76 | AttachItem* item = (AttachItem*)parent->firstChild(); | 76 | AttachItem* item = (AttachItem*)parent->firstChild(); |
77 | if (!item) return item; | 77 | if (!item) return item; |
78 | AttachItem*temp=0; | 78 | AttachItem*temp=0; |
79 | while( (temp=(AttachItem*)item->nextSibling())) | 79 | while( (temp=(AttachItem*)item->nextSibling())) |
80 | { | 80 | { |
81 | item = temp; | 81 | item = temp; |
82 | } | 82 | } |
83 | return item; | 83 | return item; |
84 | } | 84 | } |
85 | 85 | ||
86 | void ViewMail::setBody(const RecBodyP&body ) | 86 | void ViewMail::setBody(const RecBodyP&body ) |
87 | { | 87 | { |
88 | 88 | ||
89 | m_body = body; | 89 | m_body = body; |
90 | m_mail[2] = body->Bodytext(); | 90 | m_mail[2] = body->Bodytext(); |
91 | attachbutton->setEnabled(body->Parts().count()>0); | 91 | attachbutton->setEnabled(body->Parts().count()>0); |
92 | attachments->setEnabled(body->Parts().count()>0); | 92 | attachments->setEnabled(body->Parts().count()>0); |
93 | if (body->Parts().count()==0) | 93 | if (body->Parts().count()==0) |
94 | { | 94 | { |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | AttachItem * curItem=0; | 97 | AttachItem * curItem=0; |
98 | AttachItem * parentItem = 0; | 98 | AttachItem * parentItem = 0; |
99 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 99 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
100 | QString desc,fsize; | 100 | QString desc,fsize; |
101 | double s = body->Description()->Size(); | 101 | double s = body->Description()->Size(); |
102 | int w; | 102 | int w; |
103 | w=0; | 103 | w=0; |
104 | 104 | ||
105 | while (s>1024) | 105 | while (s>1024) |
106 | { | 106 | { |
107 | s/=1024; | 107 | s/=1024; |
108 | ++w; | 108 | ++w; |
109 | if (w>=2) break; | 109 | if (w>=2) break; |
110 | } | 110 | } |
111 | 111 | ||
112 | QString q=""; | 112 | QString q=""; |
113 | switch(w) | 113 | switch(w) |
114 | { | 114 | { |
115 | case 1: | 115 | case 1: |
116 | q="k"; | 116 | q="k"; |
117 | break; | 117 | break; |
118 | case 2: | 118 | case 2: |
119 | q="M"; | 119 | q="M"; |
120 | break; | 120 | break; |
121 | default: | 121 | default: |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | 124 | ||
125 | { | 125 | { |
126 | /* I did not found a method to make a CONTENT reset on a QTextStream | 126 | /* I did not found a method to make a CONTENT reset on a QTextStream |
127 | so I use this construct that the stream will re-constructed in each | 127 | so I use this construct that the stream will re-constructed in each |
128 | loop. To let it work, the textstream is packed into a own area of | 128 | loop. To let it work, the textstream is packed into a own area of |
129 | code is it will be destructed after finishing its small job. | 129 | code is it will be destructed after finishing its small job. |
130 | */ | 130 | */ |
131 | QTextOStream o(&fsize); | 131 | QTextOStream o(&fsize); |
132 | if (w>0) o.precision(2); else o.precision(0); | 132 | if (w>0) o.precision(2); else o.precision(0); |
133 | o.setf(QTextStream::fixed); | 133 | o.setf(QTextStream::fixed); |
134 | o << s << " " << q << "Byte"; | 134 | o << s << " " << q << "Byte"; |
135 | } | 135 | } |
136 | 136 | ||
137 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 137 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
138 | QString filename = ""; | 138 | QString filename = ""; |
139 | 139 | ||
140 | for (unsigned int i = 0; i < body->Parts().count();++i) | 140 | for (unsigned int i = 0; i < body->Parts().count();++i) |
141 | { | 141 | { |
142 | filename = ""; | 142 | filename = ""; |
143 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 143 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
144 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 144 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
145 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 145 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
146 | { | 146 | { |
147 | odebug << it.key() << oendl; | 147 | odebug << it.key() << oendl; |
148 | if (it.key().lower()=="name") | 148 | if (it.key().lower()=="name") |
149 | { | 149 | { |
150 | filename=it.data(); | 150 | filename=it.data(); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | s = body->Parts()[i]->Size(); | 153 | s = body->Parts()[i]->Size(); |
154 | w = 0; | 154 | w = 0; |
155 | while (s>1024) | 155 | while (s>1024) |
156 | { | 156 | { |
157 | s/=1024; | 157 | s/=1024; |
158 | ++w; | 158 | ++w; |
159 | if (w>=2) break; | 159 | if (w>=2) break; |
160 | } | 160 | } |
161 | switch(w) | 161 | switch(w) |
162 | { | 162 | { |
163 | case 1: | 163 | case 1: |
164 | q="k"; | 164 | q="k"; |
165 | break; | 165 | break; |
166 | case 2: | 166 | case 2: |
167 | q="M"; | 167 | q="M"; |
168 | break; | 168 | break; |
169 | default: | 169 | default: |
170 | q=""; | 170 | q=""; |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | QTextOStream o(&fsize); | 173 | QTextOStream o(&fsize); |
174 | if (w>0) o.precision(2); else o.precision(0); | 174 | if (w>0) o.precision(2); else o.precision(0); |
175 | o.setf(QTextStream::fixed); | 175 | o.setf(QTextStream::fixed); |
176 | o << s << " " << q << "Byte"; | 176 | o << s << " " << q << "Byte"; |
177 | desc = body->Parts()[i]->Description(); | 177 | desc = body->Parts()[i]->Description(); |
178 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 178 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
179 | if (parentItem) | 179 | if (parentItem) |
180 | { | 180 | { |
181 | AttachItem*temp = lastChild(parentItem); | 181 | AttachItem*temp = lastChild(parentItem); |
182 | if (temp) curItem = temp; | 182 | if (temp) curItem = temp; |
183 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 183 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
184 | attachments->setRootIsDecorated(true); | 184 | attachments->setRootIsDecorated(true); |
185 | curItem = parentItem; | 185 | curItem = parentItem; |
186 | } | 186 | } |
187 | else | 187 | else |
188 | { | 188 | { |
189 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 189 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | void ViewMail::slotShowHtml( bool state ) | 195 | void ViewMail::slotShowHtml( bool state ) |
196 | { | 196 | { |
197 | m_showHtml = state; | 197 | m_showHtml = state; |
198 | setText(); | 198 | setText(); |
199 | } | 199 | } |
200 | 200 | ||
201 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 201 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
202 | { | 202 | { |
203 | if (!item ) | 203 | if (!item ) |
204 | return; | 204 | return; |
205 | 205 | ||
206 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 206 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
207 | { | 207 | { |
208 | setText(); | 208 | setText(); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | QPopupMenu *menu = new QPopupMenu(); | 211 | QPopupMenu *menu = new QPopupMenu(); |
212 | int ret=0; | 212 | int ret=0; |
213 | 213 | ||
214 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 214 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
215 | { | 215 | { |
216 | menu->insertItem( tr( "Show Text" ), 1 ); | 216 | menu->insertItem( tr( "Show Text" ), 1 ); |
217 | } | 217 | } |
218 | if (item->text(0).left(6)=="image/") { | 218 | if (item->text(0).left(6)=="image/") { |
219 | menu->insertItem(tr("Display image preview"),2); | 219 | menu->insertItem(tr("Display image preview"),2); |
220 | } | 220 | } |
221 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 221 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
222 | menu->insertSeparator(1); | 222 | menu->insertSeparator(1); |
223 | 223 | ||
224 | ret = menu->exec( point, 0 ); | 224 | ret = menu->exec( point, 0 ); |
225 | 225 | ||
226 | switch(ret) | 226 | switch(ret) |
227 | { | 227 | { |
228 | case 0: | 228 | case 0: |
229 | { | 229 | { |
230 | MimeTypes types; | 230 | MimeTypes types; |
231 | types.insert( "all", "*" ); | 231 | types.insert( "all", "*" ); |
232 | QString str = OFileDialog::getSaveFileName( 1, | 232 | QString str = OFileDialog::getSaveFileName( 1, |
233 | "/", item->text( 2 ) , types, 0 ); | 233 | "/", item->text( 2 ) , types, 0 ); |
234 | 234 | ||
235 | if( !str.isEmpty() ) | 235 | if( !str.isEmpty() ) |
236 | { | 236 | { |
237 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 237 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
238 | if (content) | 238 | if (content) |
239 | { | 239 | { |
240 | QFile output(str); | 240 | QFile output(str); |
241 | output.open(IO_WriteOnly); | 241 | output.open(IO_WriteOnly); |
242 | output.writeBlock(content->Content(),content->Length()); | 242 | output.writeBlock(content->Content(),content->Length()); |
243 | output.close(); | 243 | output.close(); |
244 | delete content; | 244 | delete content; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | break ; | 248 | break ; |
249 | 249 | ||
250 | case 2: | 250 | case 2: |
251 | { | 251 | { |
252 | QString tmpfile = "/tmp/opiemail-image"; | 252 | QString tmpfile = "/tmp/opiemail-image"; |
253 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 253 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
254 | if (content) { | 254 | if (content) { |
255 | QFile output(tmpfile); | 255 | QFile output(tmpfile); |
256 | output.open(IO_WriteOnly); | 256 | output.open(IO_WriteOnly); |
257 | output.writeBlock(content->Content(),content->Length()); | 257 | output.writeBlock(content->Content(),content->Length()); |
258 | output.close(); | 258 | output.close(); |
259 | delete content; | 259 | delete content; |
260 | MailImageDlg iview(""); | 260 | MailImageDlg iview(""); |
261 | iview.setName(tmpfile); | 261 | iview.setName(tmpfile); |
262 | QPEApplication::execDialog(&iview); | 262 | QPEApplication::execDialog(&iview); |
263 | output.remove(); | 263 | output.remove(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | break; | 266 | break; |
267 | case 1: | 267 | case 1: |
268 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 268 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
269 | { | 269 | { |
270 | setText(); | 270 | setText(); |
271 | } | 271 | } |
272 | else | 272 | else |
273 | { | 273 | { |
274 | if ( m_recMail->Wrapper() != 0l ) | 274 | if ( m_recMail->Wrapper() != 0l ) |
275 | { // make sure that there is a wrapper , even after delete or simular actions | 275 | { // make sure that there is a wrapper , even after delete or simular actions |
276 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 276 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | break; | 279 | break; |
280 | } | 280 | } |
281 | delete menu; | 281 | delete menu; |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void ViewMail::setMail(const RecMailP&mail ) | 285 | void ViewMail::setMail(const RecMailP&mail ) |
286 | { | 286 | { |
287 | 287 | ||
288 | m_recMail = mail; | 288 | m_recMail = mail; |
289 | 289 | ||
290 | m_mail[0] = mail->getFrom(); | 290 | m_mail[0] = mail->getFrom(); |
291 | m_mail[1] = mail->getSubject(); | 291 | m_mail[1] = mail->getSubject(); |
292 | m_mail[3] = mail->getDate(); | 292 | m_mail[3] = mail->getStringDate(); |
293 | m_mail[4] = mail->Msgid(); | 293 | m_mail[4] = mail->Msgid(); |
294 | 294 | ||
295 | m_mail2[0] = mail->To(); | 295 | m_mail2[0] = mail->To(); |
296 | m_mail2[1] = mail->CC(); | 296 | m_mail2[1] = mail->CC(); |
297 | m_mail2[2] = mail->Bcc(); | 297 | m_mail2[2] = mail->Bcc(); |
298 | 298 | ||
299 | setText(); | 299 | setText(); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 304 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
305 | : ViewMailBase(parent, name, fl), _inLoop(false) | 305 | : ViewMailBase(parent, name, fl), _inLoop(false) |
306 | { | 306 | { |
307 | m_gotBody = false; | 307 | m_gotBody = false; |
308 | deleted = false; | 308 | deleted = false; |
309 | 309 | ||
310 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 310 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
311 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 311 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
312 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 312 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
313 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 313 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
314 | 314 | ||
315 | attachments->setEnabled(m_gotBody); | 315 | attachments->setEnabled(m_gotBody); |
316 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 316 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
317 | 317 | ||
318 | readConfig(); | 318 | readConfig(); |
319 | attachments->setSorting(-1); | 319 | attachments->setSorting(-1); |
320 | } | 320 | } |
321 | 321 | ||
322 | void ViewMail::readConfig() | 322 | void ViewMail::readConfig() |
323 | { | 323 | { |
324 | Config cfg( "mail" ); | 324 | Config cfg( "mail" ); |
325 | cfg.setGroup( "Settings" ); | 325 | cfg.setGroup( "Settings" ); |
326 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 326 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
327 | showHtml->setOn( m_showHtml ); | 327 | showHtml->setOn( m_showHtml ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void ViewMail::setText() | 330 | void ViewMail::setText() |
331 | { | 331 | { |
332 | 332 | ||
333 | QString toString; | 333 | QString toString; |
334 | QString ccString; | 334 | QString ccString; |
335 | QString bccString; | 335 | QString bccString; |
336 | 336 | ||
337 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 337 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
338 | { | 338 | { |
339 | toString += (*it); | 339 | toString += (*it); |
340 | } | 340 | } |
341 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 341 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
342 | { | 342 | { |
343 | ccString += (*it); | 343 | ccString += (*it); |
344 | } | 344 | } |
345 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 345 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
346 | { | 346 | { |
347 | bccString += (*it); | 347 | bccString += (*it); |
348 | } | 348 | } |
349 | 349 | ||
350 | setCaption( caption().arg( m_mail[0] ) ); | 350 | setCaption( caption().arg( m_mail[0] ) ); |
351 | 351 | ||
352 | m_mailHtml = "<html><body>" | 352 | m_mailHtml = "<html><body>" |
353 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 353 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
354 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 354 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
355 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 355 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
356 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 356 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
357 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 357 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
358 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 358 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
359 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 359 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
360 | "</td></tr></table><font face=fixed>"; | 360 | "</td></tr></table><font face=fixed>"; |
361 | 361 | ||
362 | if ( !m_showHtml ) | 362 | if ( !m_showHtml ) |
363 | { | 363 | { |
364 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 364 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
365 | } | 365 | } |
366 | else | 366 | else |
367 | { | 367 | { |
368 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 368 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
369 | } | 369 | } |
370 | // remove later in favor of a real handling | 370 | // remove later in favor of a real handling |
371 | m_gotBody = true; | 371 | m_gotBody = true; |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | ViewMail::~ViewMail() | 375 | ViewMail::~ViewMail() |
376 | { | 376 | { |
377 | m_recMail->Wrapper()->cleanMimeCache(); | 377 | m_recMail->Wrapper()->cleanMimeCache(); |
378 | hide(); | 378 | hide(); |
379 | } | 379 | } |
380 | 380 | ||
381 | void ViewMail::hide() | 381 | void ViewMail::hide() |
382 | { | 382 | { |
383 | QWidget::hide(); | 383 | QWidget::hide(); |
384 | 384 | ||
385 | if (_inLoop) | 385 | if (_inLoop) |
386 | { | 386 | { |
387 | _inLoop = false; | 387 | _inLoop = false; |
388 | qApp->exit_loop(); | 388 | qApp->exit_loop(); |
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | } | 392 | } |
393 | 393 | ||
394 | void ViewMail::exec() | 394 | void ViewMail::exec() |
395 | { | 395 | { |
396 | show(); | 396 | show(); |
397 | 397 | ||
398 | if (!_inLoop) | 398 | if (!_inLoop) |
399 | { | 399 | { |
400 | _inLoop = true; | 400 | _inLoop = true; |
401 | qApp->enter_loop(); | 401 | qApp->enter_loop(); |
402 | } | 402 | } |
403 | 403 | ||
404 | } | 404 | } |
405 | 405 | ||
406 | QString ViewMail::deHtml(const QString &string) | 406 | QString ViewMail::deHtml(const QString &string) |
407 | { | 407 | { |
408 | QString string_ = string; | 408 | QString string_ = string; |
409 | string_.replace(QRegExp("&"), "&"); | 409 | string_.replace(QRegExp("&"), "&"); |
410 | string_.replace(QRegExp("<"), "<"); | 410 | string_.replace(QRegExp("<"), "<"); |
411 | string_.replace(QRegExp(">"), ">"); | 411 | string_.replace(QRegExp(">"), ">"); |
412 | string_.replace(QRegExp("\\n"), "<br>"); | 412 | string_.replace(QRegExp("\\n"), "<br>"); |
413 | return string_; | 413 | return string_; |
414 | } | 414 | } |
415 | 415 | ||
416 | void ViewMail::slotReply() | 416 | void ViewMail::slotReply() |
417 | { | 417 | { |
418 | if (!m_gotBody) | 418 | if (!m_gotBody) |
419 | { | 419 | { |
420 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 420 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |