summaryrefslogtreecommitdiff
authoralwin <alwin>2004-10-26 01:08:58 (UTC)
committer alwin <alwin>2004-10-26 01:08:58 (UTC)
commitcd3245ade209b4672ab5c51003aa66b5908c67a1 (patch) (unidiff)
treedfd4246557ff5d8804204387660de7e0afbd4032
parent9e97864f04686ca8fc672de950cbbef4ff6a5ec6 (diff)
downloadopie-cd3245ade209b4672ab5c51003aa66b5908c67a1.zip
opie-cd3245ade209b4672ab5c51003aa66b5908c67a1.tar.gz
opie-cd3245ade209b4672ab5c51003aa66b5908c67a1.tar.bz2
Resolved a feature request:
unique display of date-time of a mail maillist now sorted for mail-date as default, user can switch sort order to all other items (subject, author, size)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp10
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/mailstatics.cpp25
-rw-r--r--noncore/net/mail/libmailwrapper/mailstatics.h4
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp28
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h11
-rw-r--r--noncore/net/mail/mailistviewitem.cpp20
-rw-r--r--noncore/net/mail/mailistviewitem.h1
-rw-r--r--noncore/net/mail/mainwindow.cpp17
-rw-r--r--noncore/net/mail/viewmail.cpp6
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
@@ -363,49 +363,49 @@ void Genericwrapper::cleanMimeCache()
363} 363}
364 364
365QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 365QStringList 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
385void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) 385void 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;
@@ -416,54 +416,54 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
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
@@ -351,49 +351,49 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
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
368RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 368RecMail*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;
@@ -403,49 +403,50 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
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());
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
5QString MailStatics::parseDateTime(const mailimf_date_time *date ) 5QDateTime 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
15QString MailStatics::parseDateTime(const char*date) 16QDateTime 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
7struct mailimf_date_time; 7struct mailimf_date_time;
8 8
9class MailStatics 9class MailStatics
10{ 10{
11protected: 11protected:
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(){};
16public: 16public:
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,79 +1,92 @@
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
7using namespace Opie::Core; 8using namespace Opie::Core;
8RecMail::RecMail() 9RecMail::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
14RecMail::RecMail(const RecMail&old) 15RecMail::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
22RecMail::~RecMail() 23RecMail::~RecMail()
23{ 24{
24 wrapper = 0; 25 wrapper = 0;
25} 26}
26 27
27void RecMail::copy_old(const RecMail&old) 28void 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
46void RecMail::init() 48void 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
58void 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
56void RecMail::setWrapper(AbstractMail*awrapper) 69void RecMail::setWrapper(AbstractMail*awrapper)
57{ 70{
58 wrapper = awrapper; 71 wrapper = awrapper;
59} 72}
60 73
61AbstractMail* RecMail::Wrapper() 74AbstractMail* RecMail::Wrapper()
62{ 75{
63 return wrapper; 76 return wrapper;
64} 77}
65 78
66void RecMail::setTo(const QStringList&list) 79void RecMail::setTo(const QStringList&list)
67{ 80{
68 to = list; 81 to = list;
69} 82}
70 83
71const QStringList&RecMail::To()const 84const QStringList&RecMail::To()const
72{ 85{
73 return to; 86 return to;
74} 87}
75 88
76void RecMail::setCC(const QStringList&list) 89void RecMail::setCC(const QStringList&list)
77{ 90{
78 cc = list; 91 cc = list;
79} 92}
@@ -113,49 +126,49 @@ const QStringList& RecMail::References()const
113 return references; 126 return references;
114} 127}
115 128
116RecPart::RecPart() 129RecPart::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
124RecPart::RecPart(const RecPart&old) 137RecPart::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
140RecPart::~RecPart() 153RecPart::~RecPart()
141{ 154{
142} 155}
143 156
144void RecPart::setSize(unsigned int size) 157void RecPart::setSize(unsigned int size)
145{ 158{
146 m_size = size; 159 m_size = size;
147} 160}
148 161
149const unsigned int RecPart::Size()const 162const unsigned int RecPart::Size()const
150{ 163{
151 return m_size; 164 return m_size;
152} 165}
153 166
154void RecPart::setLines(unsigned int lines) 167void RecPart::setLines(unsigned int lines)
155{ 168{
156 m_lines = lines; 169 m_lines = lines;
157} 170}
158 171
159const unsigned int RecPart::Lines()const 172const unsigned int RecPart::Lines()const
160{ 173{
161 return m_lines; 174 return m_lines;
@@ -237,49 +250,49 @@ const QString RecPart::searchParamter(const QString&key)const
237} 250}
238 251
239void RecPart::setPositionlist(const QValueList<int>&poslist) 252void RecPart::setPositionlist(const QValueList<int>&poslist)
240{ 253{
241 m_poslist = poslist; 254 m_poslist = poslist;
242} 255}
243 256
244const QValueList<int>& RecPart::Positionlist()const 257const QValueList<int>& RecPart::Positionlist()const
245{ 258{
246 return m_poslist; 259 return m_poslist;
247} 260}
248 261
249RecBody::RecBody() 262RecBody::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
255RecBody::RecBody(const RecBody&old) 268RecBody::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
264RecBody::~RecBody() 277RecBody::~RecBody()
265{ 278{
266} 279}
267 280
268void RecBody::setBodytext(const QString&bodyText) 281void RecBody::setBodytext(const QString&bodyText)
269{ 282{
270 m_BodyText = bodyText; 283 m_BodyText = bodyText;
271} 284}
272 285
273const QString& RecBody::Bodytext()const 286const QString& RecBody::Bodytext()const
274{ 287{
275 return m_BodyText; 288 return m_BodyText;
276} 289}
277 290
278void RecBody::setParts(const QValueList<RecPartP>&parts) 291void 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
284const QValueList<RecPartP>& RecBody::Parts()const 297const QValueList<RecPartP>& RecBody::Parts()const
285{ 298{
@@ -302,56 +315,56 @@ const RecPartP& RecBody::Description()const
302} 315}
303 316
304/* handling encoded content */ 317/* handling encoded content */
305encodedString::encodedString() 318encodedString::encodedString()
306{ 319{
307 init(); 320 init();
308} 321}
309 322
310encodedString::encodedString(const char*nContent,unsigned int nSize) 323encodedString::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
316encodedString::encodedString(char*nContent,unsigned int nSize) 329encodedString::encodedString(char*nContent,unsigned int nSize)
317{ 330{
318 init(); 331 init();
319 setContent(nContent,nSize); 332 setContent(nContent,nSize);
320} 333}
321 334
322encodedString::encodedString(const encodedString&old) 335encodedString::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
329encodedString& encodedString::operator=(const encodedString&old) 342encodedString& 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
337encodedString::~encodedString() 350encodedString::~encodedString()
338{ 351{
339 clean(); 352 clean();
340} 353}
341 354
342void encodedString::init() 355void encodedString::init()
343{ 356{
344 content = 0; 357 content = 0;
345 size = 0; 358 size = 0;
346} 359}
347 360
348void encodedString::clean() 361void 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
357void encodedString::copy_old(const encodedString&old) 370void encodedString::copy_old(const encodedString&old)
@@ -375,25 +388,24 @@ const int encodedString::Length()const
375} 388}
376 389
377void encodedString::setContent(const char*nContent,int nSize) 390void 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
386void encodedString::setContent(char*nContent,int nSize) 399void encodedString::setContent(char*nContent,int nSize)
387{ 400{
388 content = nContent; 401 content = nContent;
389 size = nSize; 402 size = nSize;
390} 403}
391 404
392folderStat&folderStat::operator=(const folderStat&old) 405folderStat&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,105 +1,110 @@
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
19class AbstractMail; 20class 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*/
32class RecMail:public Opie::Core::ORefCount 33class RecMail:public Opie::Core::ORefCount
33{ 34{
34public: 35public:
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
74protected: 77protected:
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
84typedef Opie::Core::OSmartPointer<RecMail> RecMailP; 89typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
85typedef QMap<QString,QString> part_plist_t; 90typedef QMap<QString,QString> part_plist_t;
86 91
87class RecPart:public Opie::Core::ORefCount 92class RecPart:public Opie::Core::ORefCount
88{ 93{
89protected: 94protected:
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
96public: 101public:
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;
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
6MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 7MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
7 :QListViewItem(parent,item),mail_data() 8 :QListViewItem(parent,item),mail_data()
8{ 9{
9} 10}
10 11
11void MailListViewItem::showEntry() 12void 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
58QString 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
58void MailListViewItem::storeData(const RecMailP&data) 72void MailListViewItem::storeData(const RecMailP&data)
59{ 73{
60 mail_data = data; 74 mail_data = data;
61} 75}
62 76
63const RecMailP& MailListViewItem::data()const 77const RecMailP& MailListViewItem::data()const
64{ 78{
65 return mail_data; 79 return mail_data;
66} 80}
67 81
68MAILLIB::ATYPE MailListViewItem::wrapperType() 82MAILLIB::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
8class MailListViewItem:public QListViewItem 8class MailListViewItem:public QListViewItem
9{ 9{
10public: 10public:
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;
19protected: 20protected:
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
@@ -82,137 +82,138 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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
140MainWindow::~MainWindow() 141MainWindow::~MainWindow()
141{ 142{
142} 143}
143 144
144void MainWindow::appMessage(const QCString &, const QByteArray &) 145void MainWindow::appMessage(const QCString &, const QByteArray &)
145{ 146{
146 odebug << "appMessage not reached" << oendl; 147 odebug << "appMessage not reached" << oendl;
147} 148}
148 149
149void MainWindow::slotAdjustLayout() { 150void 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
160void MainWindow::slotAdjustColumns() 161void 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
174void MainWindow::slotEditSettings() 175void MainWindow::slotEditSettings()
175{ 176{
176} 177}
177 178
178void MainWindow::slotShowFolders( bool ) 179void MainWindow::slotShowFolders( bool )
179{ 180{
180 odebug << "slotShowFolders not reached" << oendl; 181 odebug << "slotShowFolders not reached" << oendl;
181} 182}
182 183
183void MainWindow::refreshMailView(const QValueList<RecMailP>&) 184void MainWindow::refreshMailView(const QValueList<RecMailP>&)
184{ 185{
185 odebug << "refreshMailView not reached" << oendl; 186 odebug << "refreshMailView not reached" << oendl;
186} 187}
187 188
188void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) 189void 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
193void MainWindow::displayMail() 194void MainWindow::displayMail()
194{ 195{
195 odebug << "displayMail not reached" << oendl; 196 odebug << "displayMail not reached" << oendl;
196} 197}
197 198
198void MainWindow::slotDeleteMail() 199void MainWindow::slotDeleteMail()
199{ 200{
200 odebug << "deleteMail not reached" << oendl; 201 odebug << "deleteMail not reached" << oendl;
201} 202}
202 203
203void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 204void 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
208void MainWindow::slotSendQueued() 209void MainWindow::slotSendQueued()
209{ 210{
210} 211}
211 212
212void MainWindow::slotEditAccounts() 213void MainWindow::slotEditAccounts()
213{ 214{
214} 215}
215 216
216void MainWindow::slotComposeMail() 217void 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
@@ -123,49 +123,49 @@ void ViewMail::setBody(const RecBodyP&body )
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;
@@ -226,91 +226,91 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
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
285void ViewMail::setMail(const RecMailP&mail ) 285void 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
304ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 304ViewMail::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) ) );