author | alwin <alwin> | 2004-10-25 22:34:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-25 22:34:15 (UTC) |
commit | 9e97864f04686ca8fc672de950cbbef4ff6a5ec6 (patch) (unidiff) | |
tree | 7aa5b07b4bb6fce77844d7883d947100a1ae3759 | |
parent | d29de6d360b0570c12778beea9f654a8fcdbe3c7 (diff) | |
download | opie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.zip opie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.tar.gz opie-9e97864f04686ca8fc672de950cbbef4ff6a5ec6.tar.bz2 |
fixed the problem with displaying date/time of a mail
usage of helper class
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 3 |
2 files changed, 5 insertions, 16 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index fe75a15..56efa0b 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,37 +1,37 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | #include <opie2/oapplication.h> | 4 | #include <opie2/oapplication.h> |
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | 6 | ||
7 | #include "imapwrapper.h" | 7 | #include "imapwrapper.h" |
8 | #include "mailtypes.h" | 8 | #include "mailtypes.h" |
9 | #include "logindialog.h" | 9 | #include "logindialog.h" |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
13 | : AbstractMail() | 13 | : AbstractMail(),MailStatics() |
14 | { | 14 | { |
15 | account = a; | 15 | account = a; |
16 | m_imap = 0; | 16 | m_imap = 0; |
17 | m_Lastmbox = ""; | 17 | m_Lastmbox = ""; |
18 | } | 18 | } |
19 | 19 | ||
20 | IMAPwrapper::~IMAPwrapper() | 20 | IMAPwrapper::~IMAPwrapper() |
21 | { | 21 | { |
22 | logout(); | 22 | logout(); |
23 | } | 23 | } |
24 | 24 | ||
25 | /* to avoid to often select statements in loops etc. | 25 | /* to avoid to often select statements in loops etc. |
26 | we trust that we are logged in and connection is established!*/ | 26 | we trust that we are logged in and connection is established!*/ |
27 | int IMAPwrapper::selectMbox(const QString&mbox) | 27 | int IMAPwrapper::selectMbox(const QString&mbox) |
28 | { | 28 | { |
29 | if (mbox == m_Lastmbox) { | 29 | if (mbox == m_Lastmbox) { |
30 | return MAILIMAP_NO_ERROR; | 30 | return MAILIMAP_NO_ERROR; |
31 | } | 31 | } |
32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
33 | if ( err != MAILIMAP_NO_ERROR ) { | 33 | if ( err != MAILIMAP_NO_ERROR ) { |
34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; | 34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; |
35 | m_Lastmbox = ""; | 35 | m_Lastmbox = ""; |
36 | return err; | 36 | return err; |
37 | } | 37 | } |
@@ -403,104 +403,92 @@ 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(head->env_date); | 427 | m->setDate(parseDateTime(head->env_date)); |
428 | m->setSubject(convert_String((const char*)head->env_subject)); | 428 | m->setSubject(convert_String((const char*)head->env_subject)); |
429 | //m->setSubject(head->env_subject); | ||
430 | if (head->env_from!=NULL) { | 429 | if (head->env_from!=NULL) { |
431 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 430 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
432 | if (addresslist.count()) { | 431 | if (addresslist.count()) { |
433 | m->setFrom(addresslist.first()); | 432 | m->setFrom(addresslist.first()); |
434 | } | 433 | } |
435 | } | 434 | } |
436 | if (head->env_to!=NULL) { | 435 | if (head->env_to!=NULL) { |
437 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 436 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
438 | m->setTo(addresslist); | 437 | m->setTo(addresslist); |
439 | } | 438 | } |
440 | if (head->env_cc!=NULL) { | 439 | if (head->env_cc!=NULL) { |
441 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 440 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
442 | m->setCC(addresslist); | 441 | m->setCC(addresslist); |
443 | } | 442 | } |
444 | if (head->env_bcc!=NULL) { | 443 | if (head->env_bcc!=NULL) { |
445 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 444 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
446 | m->setBcc(addresslist); | 445 | m->setBcc(addresslist); |
447 | } | 446 | } |
448 | /* reply to address, eg. email. */ | 447 | /* reply to address, eg. email. */ |
449 | if (head->env_reply_to!=NULL) { | 448 | if (head->env_reply_to!=NULL) { |
450 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 449 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
451 | if (addresslist.count()) { | 450 | if (addresslist.count()) { |
452 | m->setReplyto(addresslist.first()); | 451 | m->setReplyto(addresslist.first()); |
453 | } | 452 | } |
454 | } | 453 | } |
455 | if (head->env_in_reply_to!=NULL) { | 454 | if (head->env_in_reply_to!=NULL) { |
456 | QString h(head->env_in_reply_to); | 455 | QString h(head->env_in_reply_to); |
457 | while (h.length()>0 && h[0]=='<') { | 456 | while (h.length()>0 && h[0]=='<') { |
458 | h.remove(0,1); | 457 | h.remove(0,1); |
459 | } | 458 | } |
460 | while (h.length()>0 && h[h.length()-1]=='>') { | 459 | while (h.length()>0 && h[h.length()-1]=='>') { |
461 | h.remove(h.length()-1,1); | 460 | h.remove(h.length()-1,1); |
462 | } | 461 | } |
463 | if (h.length()>0) { | 462 | if (h.length()>0) { |
464 | m->setInreply(QStringList(h)); | 463 | m->setInreply(QStringList(h)); |
465 | } | 464 | } |
466 | } | 465 | } |
467 | if (head->env_message_id) { | 466 | if (head->env_message_id) { |
468 | m->setMsgid(QString(head->env_message_id)); | 467 | m->setMsgid(QString(head->env_message_id)); |
469 | } | 468 | } |
470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 469 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
471 | #if 0 | 470 | // not used this moment |
472 | mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date; | ||
473 | if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0; | ||
474 | //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | ||
475 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | ||
476 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | ||
477 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
478 | m->setDate(timestring); | ||
479 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | ||
480 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; | ||
481 | odebug << da.toString() << oendl; | ||
482 | #endif | ||
483 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 471 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
484 | //size = item->att_data.att_static->att_data.att_rfc822_size; | 472 | //size = item->att_data.att_static->att_data.att_rfc822_size; |
485 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); | 473 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); |
486 | } | 474 | } |
487 | } | 475 | } |
488 | /* msg is already deleted */ | 476 | /* msg is already deleted */ |
489 | if (mFlags.testBit(FLAG_DELETED) && m) { | 477 | if (mFlags.testBit(FLAG_DELETED) && m) { |
490 | delete m; | 478 | delete m; |
491 | m = 0; | 479 | m = 0; |
492 | } | 480 | } |
493 | if (m) { | 481 | if (m) { |
494 | m->setFlags(mFlags); | 482 | m->setFlags(mFlags); |
495 | } | 483 | } |
496 | return m; | 484 | return m; |
497 | } | 485 | } |
498 | 486 | ||
499 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 487 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
500 | { | 488 | { |
501 | RecBodyP body = new RecBody(); | 489 | RecBodyP body = new RecBody(); |
502 | const char *mb; | 490 | const char *mb; |
503 | int err = MAILIMAP_NO_ERROR; | 491 | int err = MAILIMAP_NO_ERROR; |
504 | clist *result = 0; | 492 | clist *result = 0; |
505 | clistcell *current; | 493 | clistcell *current; |
506 | mailimap_fetch_att *fetchAtt = 0; | 494 | mailimap_fetch_att *fetchAtt = 0; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index e56605a..5efcfc9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,44 +1,45 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "abstractmail.h" | 6 | #include "abstractmail.h" |
7 | #include "mailstatics.h" | ||
7 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
8 | 9 | ||
9 | struct mailimap; | 10 | struct mailimap; |
10 | struct mailimap_body; | 11 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 12 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 13 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 14 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 15 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 16 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 17 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 18 | struct mailimap_msg_att; |
18 | class encodedString; | 19 | class encodedString; |
19 | 20 | ||
20 | class IMAPwrapper : public AbstractMail | 21 | class IMAPwrapper : public AbstractMail,public MailStatics |
21 | { | 22 | { |
22 | Q_OBJECT | 23 | Q_OBJECT |
23 | public: | 24 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 25 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 26 | virtual ~IMAPwrapper(); |
26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 27 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); | 28 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 29 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 30 | ||
30 | virtual void deleteMail(const RecMailP&mail); | 31 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMailP&mail); | 32 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); | 33 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 35 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 36 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 37 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
37 | 38 | ||
38 | virtual RecBodyP fetchBody(const RecMailP&mail); | 39 | virtual RecBodyP fetchBody(const RecMailP&mail); |
39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); | 40 | virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); |
40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); | 41 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); |
41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); | 42 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); |
42 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 43 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
43 | 44 | ||
44 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, | 45 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |