author | alwin <alwin> | 2004-01-05 22:21:41 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-05 22:21:41 (UTC) |
commit | c8d0dd53a75b7142a5ce924e4afbea77b86e56b0 (patch) (unidiff) | |
tree | 2845e68c4a3ee0daa7f732a29fefd81d47c90f9d /noncore/net/mail/libmailwrapper | |
parent | 07278dd6ba68e3ff55d22acc76a28956b06d5d9c (diff) | |
download | opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.zip opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.tar.gz opie-c8d0dd53a75b7142a5ce924e4afbea77b86e56b0.tar.bz2 |
bugfix in imapwrapper
storemail for all possible mail-accounts
raw body fetch in all wrappers
unified public interface
dialog for selecting a target mailbox started
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 |
9 files changed, 79 insertions, 48 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 7c060db..9770991 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -5,48 +5,49 @@ | |||
5 | #include "settings.h" | 5 | #include "settings.h" |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | struct folderStat; | 14 | struct folderStat; |
15 | 15 | ||
16 | class AbstractMail:public QObject | 16 | class AbstractMail:public QObject |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | AbstractMail(){}; | 20 | AbstractMail(){}; |
21 | virtual ~AbstractMail(){} | 21 | virtual ~AbstractMail(){} |
22 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
25 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | ||
29 | 30 | ||
30 | virtual void deleteMail(const RecMail&mail)=0; | 31 | virtual void deleteMail(const RecMail&mail)=0; |
31 | virtual void answeredMail(const RecMail&mail)=0; | 32 | virtual void answeredMail(const RecMail&mail)=0; |
32 | virtual int deleteAllMail(const Folder*)=0; | 33 | virtual int deleteAllMail(const Folder*)=0; |
33 | virtual int deleteMbox(const Folder*)=0; | 34 | virtual int deleteMbox(const Folder*)=0; |
34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
35 | 36 | ||
36 | virtual void cleanMimeCache(){}; | 37 | virtual void cleanMimeCache(){}; |
37 | /* mail box methods */ | 38 | /* mail box methods */ |
38 | /* parameter is the box to create. | 39 | /* parameter is the box to create. |
39 | * if the implementing subclass has prefixes, | 40 | * if the implementing subclass has prefixes, |
40 | * them has to be appended automatic. | 41 | * them has to be appended automatic. |
41 | */ | 42 | */ |
42 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
43 | virtual void logout()=0; | 44 | virtual void logout()=0; |
44 | 45 | ||
45 | static AbstractMail* getWrapper(IMAPaccount *a); | 46 | static AbstractMail* getWrapper(IMAPaccount *a); |
46 | static AbstractMail* getWrapper(POP3account *a); | 47 | static AbstractMail* getWrapper(POP3account *a); |
47 | /* mbox only! */ | 48 | /* mbox only! */ |
48 | static AbstractMail* getWrapper(const QString&a); | 49 | static AbstractMail* getWrapper(const QString&a); |
49 | 50 | ||
50 | static QString defaultLocalfolder(); | 51 | static QString defaultLocalfolder(); |
51 | 52 | ||
52 | virtual const QString&getType()const=0; | 53 | virtual const QString&getType()const=0; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 95b317a..d252159 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -445,73 +445,84 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
445 | from+="@"; | 445 | from+="@"; |
446 | } | 446 | } |
447 | if (current_address->ad_host_name) { | 447 | if (current_address->ad_host_name) { |
448 | from+=QString(current_address->ad_host_name); | 448 | from+=QString(current_address->ad_host_name); |
449 | } | 449 | } |
450 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 450 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
451 | from+=">"; | 451 | from+=">"; |
452 | } | 452 | } |
453 | l.append(QString(from)); | 453 | l.append(QString(from)); |
454 | if (++count > 99) { | 454 | if (++count > 99) { |
455 | break; | 455 | break; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | return l; | 458 | return l; |
459 | } | 459 | } |
460 | 460 | ||
461 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 461 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
462 | { | 462 | { |
463 | encodedString*res=new encodedString; | 463 | encodedString*res=new encodedString; |
464 | const char*mb; | 464 | const char*mb; |
465 | int err; | 465 | int err; |
466 | mailimap_fetch_type *fetchType; | 466 | mailimap_fetch_type *fetchType; |
467 | mailimap_set *set; | 467 | mailimap_set *set; |
468 | clistcell*current,*cur; | 468 | clistcell*current,*cur; |
469 | mailimap_section_part * section_part = 0; | ||
470 | mailimap_section_spec * section_spec = 0; | ||
471 | mailimap_section * section = 0; | ||
472 | mailimap_fetch_att * fetch_att = 0; | ||
469 | 473 | ||
470 | login(); | 474 | login(); |
471 | if (!m_imap) { | 475 | if (!m_imap) { |
472 | return res; | 476 | return res; |
473 | } | 477 | } |
474 | if (!internal_call) { | 478 | if (!internal_call) { |
475 | mb = mail.getMbox().latin1(); | 479 | mb = mail.getMbox().latin1(); |
476 | err = mailimap_select( m_imap, (char*)mb); | 480 | err = mailimap_select( m_imap, (char*)mb); |
477 | if ( err != MAILIMAP_NO_ERROR ) { | 481 | if ( err != MAILIMAP_NO_ERROR ) { |
478 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 482 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
479 | return res; | 483 | return res; |
480 | } | 484 | } |
481 | } | 485 | } |
482 | set = mailimap_set_new_single(mail.getNumber()); | 486 | set = mailimap_set_new_single(mail.getNumber()); |
483 | clist*id_list=clist_new(); | ||
484 | for (unsigned j=0; j < path.count();++j) { | ||
485 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | ||
486 | *p_id = path[j]; | ||
487 | clist_append(id_list,p_id); | ||
488 | } | ||
489 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | ||
490 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | ||
491 | mailimap_section * section = mailimap_section_new(section_spec); | ||
492 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | ||
493 | 487 | ||
488 | clist*id_list = 0; | ||
489 | |||
490 | /* if path == empty then its a request for the whole rfc822 mail and generates | ||
491 | a "fetch <id> (body[])" statement on imap server */ | ||
492 | if (path.count()>0 ) { | ||
493 | id_list = clist_new(); | ||
494 | for (unsigned j=0; j < path.count();++j) { | ||
495 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | ||
496 | *p_id = path[j]; | ||
497 | clist_append(id_list,p_id); | ||
498 | } | ||
499 | section_part = mailimap_section_part_new(id_list); | ||
500 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | ||
501 | } | ||
502 | |||
503 | section = mailimap_section_new(section_spec); | ||
504 | fetch_att = mailimap_fetch_att_new_body_section(section); | ||
494 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 505 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
495 | 506 | ||
496 | clist*result = 0; | 507 | clist*result = 0; |
497 | 508 | ||
498 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 509 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
499 | mailimap_set_free( set ); | 510 | mailimap_set_free( set ); |
500 | mailimap_fetch_type_free( fetchType ); | 511 | mailimap_fetch_type_free( fetchType ); |
501 | 512 | ||
502 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 513 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
503 | mailimap_msg_att * msg_att; | 514 | mailimap_msg_att * msg_att; |
504 | msg_att = (mailimap_msg_att*)current->data; | 515 | msg_att = (mailimap_msg_att*)current->data; |
505 | mailimap_msg_att_item*msg_att_item; | 516 | mailimap_msg_att_item*msg_att_item; |
506 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 517 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
507 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 518 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
508 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 519 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
509 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 520 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
510 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 521 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
511 | /* detach - we take over the content */ | 522 | /* detach - we take over the content */ |
512 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 523 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
513 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 524 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
514 | } | 525 | } |
515 | } | 526 | } |
516 | } | 527 | } |
517 | } else { | 528 | } else { |
@@ -934,59 +945,70 @@ int IMAPwrapper::deleteMbox(const Folder*folder) | |||
934 | } | 945 | } |
935 | return 1; | 946 | return 1; |
936 | } | 947 | } |
937 | 948 | ||
938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 949 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
939 | { | 950 | { |
940 | mailimap_status_att_list * att_list =0; | 951 | mailimap_status_att_list * att_list =0; |
941 | mailimap_mailbox_data_status * status=0; | 952 | mailimap_mailbox_data_status * status=0; |
942 | clistiter * cur = 0; | 953 | clistiter * cur = 0; |
943 | int r = 0; | 954 | int r = 0; |
944 | int res = 0; | 955 | int res = 0; |
945 | target_stat.message_count = 0; | 956 | target_stat.message_count = 0; |
946 | target_stat.message_unseen = 0; | 957 | target_stat.message_unseen = 0; |
947 | target_stat.message_recent = 0; | 958 | target_stat.message_recent = 0; |
948 | login(); | 959 | login(); |
949 | if (!m_imap) { | 960 | if (!m_imap) { |
950 | return; | 961 | return; |
951 | } | 962 | } |
952 | att_list = mailimap_status_att_list_new_empty(); | 963 | att_list = mailimap_status_att_list_new_empty(); |
953 | if (!att_list) return; | 964 | if (!att_list) return; |
954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 965 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 966 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 967 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 968 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
958 | for (cur = clist_begin(status->st_info_list); | 969 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
959 | cur != NULL ; cur = clist_next(cur)) { | 970 | for (cur = clist_begin(status->st_info_list); |
960 | mailimap_status_info * status_info; | 971 | cur != NULL ; cur = clist_next(cur)) { |
961 | status_info = (mailimap_status_info *)clist_content(cur); | 972 | mailimap_status_info * status_info; |
962 | switch (status_info->st_att) { | 973 | status_info = (mailimap_status_info *)clist_content(cur); |
963 | case MAILIMAP_STATUS_ATT_MESSAGES: | 974 | switch (status_info->st_att) { |
964 | target_stat.message_count = status_info->st_value; | 975 | case MAILIMAP_STATUS_ATT_MESSAGES: |
965 | break; | 976 | target_stat.message_count = status_info->st_value; |
966 | case MAILIMAP_STATUS_ATT_RECENT: | 977 | break; |
967 | target_stat.message_recent = status_info->st_value; | 978 | case MAILIMAP_STATUS_ATT_RECENT: |
968 | break; | 979 | target_stat.message_recent = status_info->st_value; |
969 | case MAILIMAP_STATUS_ATT_UNSEEN: | 980 | break; |
970 | target_stat.message_unseen = status_info->st_value; | 981 | case MAILIMAP_STATUS_ATT_UNSEEN: |
971 | break; | 982 | target_stat.message_unseen = status_info->st_value; |
983 | break; | ||
984 | } | ||
972 | } | 985 | } |
986 | } else { | ||
987 | qDebug("Error retrieving status"); | ||
973 | } | 988 | } |
974 | mailimap_mailbox_data_status_free(status); | 989 | if (status) mailimap_mailbox_data_status_free(status); |
975 | mailimap_status_att_list_free(att_list); | 990 | if (att_list) mailimap_status_att_list_free(att_list); |
976 | } | 991 | } |
977 | 992 | ||
978 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 993 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
979 | { | 994 | { |
980 | login(); | 995 | login(); |
981 | if (!m_imap) return; | 996 | if (!m_imap) return; |
982 | if (!msg) return; | 997 | if (!msg) return; |
983 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 998 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
984 | if (r != MAILIMAP_NO_ERROR) { | 999 | if (r != MAILIMAP_NO_ERROR) { |
985 | Global::statusMessage("Error storing mail!"); | 1000 | Global::statusMessage("Error storing mail!"); |
986 | } | 1001 | } |
987 | } | 1002 | } |
988 | 1003 | ||
989 | const QString&IMAPwrapper::getType()const | 1004 | const QString&IMAPwrapper::getType()const |
990 | { | 1005 | { |
991 | return account->getType(); | 1006 | return account->getType(); |
992 | } | 1007 | } |
1008 | |||
1009 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | ||
1010 | { | ||
1011 | // dummy | ||
1012 | QValueList<int> path; | ||
1013 | return fetchRawPart(mail,path,false); | ||
1014 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 6a9c411..b246f58 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -15,48 +15,49 @@ struct mailimap_body_type_msg; | |||
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | 34 | ||
35 | virtual RecBody fetchBody(const RecMail&mail); | 35 | virtual RecBody fetchBody(const RecMail&mail); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchRawBody(const RecMail&mail); | ||
39 | 40 | ||
40 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
41 | virtual int deleteMbox(const Folder*folder); | 42 | virtual int deleteMbox(const Folder*folder); |
42 | 43 | ||
43 | static void imap_progress( size_t current, size_t maximum ); | 44 | static void imap_progress( size_t current, size_t maximum ); |
44 | 45 | ||
45 | virtual void logout(); | 46 | virtual void logout(); |
46 | virtual const QString&getType()const; | 47 | virtual const QString&getType()const; |
47 | protected: | 48 | protected: |
48 | RecMail*parse_list_result(mailimap_msg_att*); | 49 | RecMail*parse_list_result(mailimap_msg_att*); |
49 | void login(); | 50 | void login(); |
50 | 51 | ||
51 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 52 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
52 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 53 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
53 | 54 | ||
54 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 55 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
55 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 56 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
56 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 57 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
57 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 58 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
58 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 59 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
59 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 60 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
60 | 61 | ||
61 | /* just helpers */ | 62 | /* just helpers */ |
62 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 63 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 60f7507..3a0b30a 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -151,88 +151,89 @@ int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bo | |||
151 | Global::statusMessage(tr("Error init folder")); | 151 | Global::statusMessage(tr("Error init folder")); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | if (f) mailmbox_done(f); | 154 | if (f) mailmbox_done(f); |
155 | return 1; | 155 | return 1; |
156 | } | 156 | } |
157 | 157 | ||
158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 158 | void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
159 | { | 159 | { |
160 | QString p = MBOXPath+"/"; | 160 | QString p = MBOXPath+"/"; |
161 | p+=folder; | 161 | p+=folder; |
162 | mailmbox_folder*f = 0; | 162 | mailmbox_folder*f = 0; |
163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 163 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
164 | if (r != MAIL_NO_ERROR) { | 164 | if (r != MAIL_NO_ERROR) { |
165 | Global::statusMessage(tr("Error init folder")); | 165 | Global::statusMessage(tr("Error init folder")); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | r = mailmbox_append_message(f,msg,length); | 168 | r = mailmbox_append_message(f,msg,length); |
169 | if (r != MAIL_NO_ERROR) { | 169 | if (r != MAIL_NO_ERROR) { |
170 | Global::statusMessage(tr("Error writing to message folder")); | 170 | Global::statusMessage(tr("Error writing to message folder")); |
171 | } | 171 | } |
172 | mailmbox_done(f); | 172 | mailmbox_done(f); |
173 | } | 173 | } |
174 | 174 | ||
175 | void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 175 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) |
176 | { | 176 | { |
177 | RecBody body; | 177 | RecBody body; |
178 | mailstorage*storage = mailstorage_new(NULL); | 178 | mailstorage*storage = mailstorage_new(NULL); |
179 | QString p = MBOXPath+"/"; | 179 | QString p = MBOXPath+"/"; |
180 | p+=mail.getMbox(); | 180 | p+=mail.getMbox(); |
181 | mailmessage * msg; | 181 | mailmessage * msg; |
182 | char*data=0; | 182 | char*data=0; |
183 | size_t size; | 183 | size_t size; |
184 | 184 | ||
185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 185 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
186 | mailfolder*folder; | 186 | mailfolder*folder; |
187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 187 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
188 | r = mailfolder_connect(folder); | 188 | r = mailfolder_connect(folder); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | Global::statusMessage(tr("Error initializing mbox")); | 190 | Global::statusMessage(tr("Error initializing mbox")); |
191 | mailfolder_free(folder); | 191 | mailfolder_free(folder); |
192 | mailstorage_free(storage); | 192 | mailstorage_free(storage); |
193 | return; | 193 | return 0; |
194 | } | 194 | } |
195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 195 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
196 | if (r != MAIL_NO_ERROR) { | 196 | if (r != MAIL_NO_ERROR) { |
197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 197 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
198 | mailfolder_free(folder); | 198 | mailfolder_free(folder); |
199 | mailstorage_free(storage); | 199 | mailstorage_free(storage); |
200 | return; | 200 | return 0; |
201 | } | 201 | } |
202 | r = mailmessage_fetch(msg,&data,&size); | 202 | r = mailmessage_fetch(msg,&data,&size); |
203 | if (r != MAIL_NO_ERROR) { | 203 | if (r != MAIL_NO_ERROR) { |
204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 204 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); |
205 | mailfolder_free(folder); | 205 | mailfolder_free(folder); |
206 | mailstorage_free(storage); | 206 | mailstorage_free(storage); |
207 | mailmessage_free(msg); | 207 | mailmessage_free(msg); |
208 | return; | 208 | return 0; |
209 | } | 209 | } |
210 | *target = data; | 210 | encodedString*result = new encodedString(data,size); |
211 | *length = size; | 211 | |
212 | mailfolder_free(folder); | 212 | mailfolder_free(folder); |
213 | mailstorage_free(storage); | 213 | mailstorage_free(storage); |
214 | mailmessage_free(msg); | 214 | mailmessage_free(msg); |
215 | return result; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 218 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
218 | { | 219 | { |
219 | QString p = MBOXPath+"/"; | 220 | QString p = MBOXPath+"/"; |
220 | p+=mailbox; | 221 | p+=mailbox; |
221 | mailmbox_folder*f = 0; | 222 | mailmbox_folder*f = 0; |
222 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 223 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
223 | if (r != MAIL_NO_ERROR) { | 224 | if (r != MAIL_NO_ERROR) { |
224 | qDebug("Error init folder"); | 225 | qDebug("Error init folder"); |
225 | return; | 226 | return; |
226 | } | 227 | } |
227 | deleteMails(f,target); | 228 | deleteMails(f,target); |
228 | mailmbox_done(f); | 229 | mailmbox_done(f); |
229 | } | 230 | } |
230 | 231 | ||
231 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 232 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
232 | { | 233 | { |
233 | if (!f) return; | 234 | if (!f) return; |
234 | int r; | 235 | int r; |
235 | for (unsigned int i=0; i < target.count();++i) { | 236 | for (unsigned int i=0; i < target.count();++i) { |
236 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 237 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
237 | if (r!=MAILMBOX_NO_ERROR) { | 238 | if (r!=MAILMBOX_NO_ERROR) { |
238 | qDebug("error delete mail"); | 239 | qDebug("error delete mail"); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index f97fce2..2794014 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,44 +1,45 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | ||
9 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
10 | 11 | ||
11 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
12 | { | 13 | { |
13 | Q_OBJECT | 14 | Q_OBJECT |
14 | public: | 15 | public: |
15 | MBOXwrapper(const QString & dir); | 16 | MBOXwrapper(const QString & dir); |
16 | virtual ~MBOXwrapper(); | 17 | virtual ~MBOXwrapper(); |
17 | 18 | ||
18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
19 | virtual QList<Folder>* listFolders(); | 20 | virtual QList<Folder>* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 22 | ||
22 | virtual void deleteMail(const RecMail&mail); | 23 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 24 | virtual void answeredMail(const RecMail&mail); |
24 | 25 | ||
25 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 26 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
26 | virtual int deleteMbox(const Folder*); | 27 | virtual int deleteMbox(const Folder*); |
27 | 28 | ||
28 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
29 | 30 | ||
30 | virtual RecBody fetchBody( const RecMail &mail ); | 31 | virtual RecBody fetchBody( const RecMail &mail ); |
31 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
32 | 33 | ||
33 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
34 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 35 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
35 | virtual int deleteAllMail(const Folder*); | 36 | virtual int deleteAllMail(const Folder*); |
36 | virtual const QString&getType()const; | 37 | virtual const QString&getType()const; |
37 | 38 | ||
38 | protected: | 39 | protected: |
39 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 40 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
40 | QString MBOXPath; | 41 | QString MBOXPath; |
41 | static const QString wrapperType; | 42 | static const QString wrapperType; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | #endif | 45 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 45408dd..72c145b 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -207,36 +207,43 @@ int POP3wrapper::deleteAllMail(const Folder*) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | for (unsigned int i = 0; i < result; ++i) { | 209 | for (unsigned int i = 0; i < result; ++i) { |
210 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 210 | err = mailsession_remove_message(m_folder->fld_session,i+1); |
211 | if (err != MAIL_NO_ERROR) { | 211 | if (err != MAIL_NO_ERROR) { |
212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
213 | res=0; | 213 | res=0; |
214 | } | 214 | } |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | return res; | 217 | return res; |
218 | } | 218 | } |
219 | 219 | ||
220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | 220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) |
221 | { | 221 | { |
222 | login(); | 222 | login(); |
223 | target_stat.message_count = 0; | 223 | target_stat.message_count = 0; |
224 | target_stat.message_unseen = 0; | 224 | target_stat.message_unseen = 0; |
225 | target_stat.message_recent = 0; | 225 | target_stat.message_recent = 0; |
226 | if (!m_pop3) return; | 226 | if (!m_pop3) return; |
227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | 227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, |
228 | &target_stat.message_recent,&target_stat.message_unseen); | 228 | &target_stat.message_recent,&target_stat.message_unseen); |
229 | } | 229 | } |
230 | 230 | ||
231 | void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | 231 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) |
232 | { | 232 | { |
233 | char*target=0; | ||
234 | size_t length=0; | ||
235 | encodedString*res = 0; | ||
233 | mailmessage * mailmsg = 0; | 236 | mailmessage * mailmsg = 0; |
234 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | 237 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); |
235 | err = mailmessage_fetch(mailmsg,target,length); | 238 | err = mailmessage_fetch(mailmsg,&target,&length); |
236 | if (mailmsg) mailmessage_free(mailmsg); | 239 | if (mailmsg) mailmessage_free(mailmsg); |
240 | if (target) { | ||
241 | res = new encodedString(target,length); | ||
242 | } | ||
243 | return res; | ||
237 | } | 244 | } |
238 | 245 | ||
239 | const QString&POP3wrapper::getType()const | 246 | const QString&POP3wrapper::getType()const |
240 | { | 247 | { |
241 | return account->getType(); | 248 | return account->getType(); |
242 | } | 249 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b7e8f27..f0307b6 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,41 +1,42 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | class encodedString; | ||
8 | struct mailstorage; | 9 | struct mailstorage; |
9 | struct mailfolder; | 10 | struct mailfolder; |
10 | 11 | ||
11 | class POP3wrapper : public Genericwrapper | 12 | class POP3wrapper : public Genericwrapper |
12 | { | 13 | { |
13 | Q_OBJECT | 14 | Q_OBJECT |
14 | 15 | ||
15 | public: | 16 | public: |
16 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
17 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
18 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
21 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 24 | ||
24 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMail&mail); |
26 | virtual int deleteAllMail(const Folder*); | 27 | virtual int deleteAllMail(const Folder*); |
27 | 28 | ||
28 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
29 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
30 | virtual void logout(); | 31 | virtual void logout(); |
31 | virtual const QString&getType()const; | 32 | virtual const QString&getType()const; |
32 | static void pop3_progress( size_t current, size_t maximum ); | 33 | static void pop3_progress( size_t current, size_t maximum ); |
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | void login(); | 36 | void login(); |
36 | POP3account *account; | 37 | POP3account *account; |
37 | mailstorage*m_pop3; | 38 | mailstorage*m_pop3; |
38 | mailfolder*m_folder; | 39 | mailfolder*m_folder; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index e054365..00181ff 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -464,49 +464,49 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom) | |||
464 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 464 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
465 | from = strdup( mb->mb_addr_spec ); | 465 | from = strdup( mb->mb_addr_spec ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | return from; | 469 | return from; |
470 | } | 470 | } |
471 | 471 | ||
472 | char *SMTPwrapper::getFrom( mailmime *mail ) | 472 | char *SMTPwrapper::getFrom( mailmime *mail ) |
473 | { | 473 | { |
474 | /* no need to delete - its just a pointer to structure content */ | 474 | /* no need to delete - its just a pointer to structure content */ |
475 | mailimf_field *ffrom = 0; | 475 | mailimf_field *ffrom = 0; |
476 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 476 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
477 | return getFrom(ffrom); | 477 | return getFrom(ffrom); |
478 | } | 478 | } |
479 | 479 | ||
480 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 480 | void SMTPwrapper::progress( size_t current, size_t maximum ) |
481 | { | 481 | { |
482 | if (SMTPwrapper::sendProgress) { | 482 | if (SMTPwrapper::sendProgress) { |
483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
484 | qApp->processEvents(); | 484 | qApp->processEvents(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 488 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) |
489 | { | 489 | { |
490 | if (!mail) return; | 490 | if (!mail) return; |
491 | QString localfolders = AbstractMail::defaultLocalfolder(); | 491 | QString localfolders = AbstractMail::defaultLocalfolder(); |
492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
493 | wrap->storeMessage(mail,length,box); | 493 | wrap->storeMessage(mail,length,box); |
494 | delete wrap; | 494 | delete wrap; |
495 | } | 495 | } |
496 | 496 | ||
497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) |
498 | { | 498 | { |
499 | clist *rcpts = 0; | 499 | clist *rcpts = 0; |
500 | char *from, *data; | 500 | char *from, *data; |
501 | size_t size; | 501 | size_t size; |
502 | 502 | ||
503 | if ( smtp == NULL ) { | 503 | if ( smtp == NULL ) { |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | from = data = 0; | 506 | from = data = 0; |
507 | 507 | ||
508 | mailmessage * msg = 0; | 508 | mailmessage * msg = 0; |
509 | msg = mime_message_init(mail); | 509 | msg = mime_message_init(mail); |
510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
511 | int r = mailmessage_fetch(msg,&data,&size); | 511 | int r = mailmessage_fetch(msg,&data,&size); |
512 | mime_message_detach_mime(msg); | 512 | mime_message_detach_mime(msg); |
@@ -515,49 +515,49 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
515 | if (data) free(data); | 515 | if (data) free(data); |
516 | qDebug("Error fetching mime..."); | 516 | qDebug("Error fetching mime..."); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | QString tmp = data; | 519 | QString tmp = data; |
520 | tmp.replace(QRegExp("\r+",true,false),""); | 520 | tmp.replace(QRegExp("\r+",true,false),""); |
521 | msg = 0; | 521 | msg = 0; |
522 | if (later) { | 522 | if (later) { |
523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); | 523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); |
524 | if (data) free( data ); | 524 | if (data) free( data ); |
525 | Config cfg( "mail" ); | 525 | Config cfg( "mail" ); |
526 | cfg.setGroup( "Status" ); | 526 | cfg.setGroup( "Status" ); |
527 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 527 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
528 | emit queuedMails( m_queuedMail ); | 528 | emit queuedMails( m_queuedMail ); |
529 | return; | 529 | return; |
530 | } | 530 | } |
531 | from = getFrom( mail ); | 531 | from = getFrom( mail ); |
532 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 532 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
533 | smtpSend(from,rcpts,data,size,smtp); | 533 | smtpSend(from,rcpts,data,size,smtp); |
534 | if (data) {free(data);} | 534 | if (data) {free(data);} |
535 | if (from) {free(from);} | 535 | if (from) {free(from);} |
536 | if (rcpts) smtp_address_list_free( rcpts ); | 536 | if (rcpts) smtp_address_list_free( rcpts ); |
537 | } | 537 | } |
538 | 538 | ||
539 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) | 539 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) |
540 | { | 540 | { |
541 | char *server, *user, *pass; | 541 | char *server, *user, *pass; |
542 | bool ssl; | 542 | bool ssl; |
543 | uint16_t port; | 543 | uint16_t port; |
544 | mailsmtp *session; | 544 | mailsmtp *session; |
545 | int err,result; | 545 | int err,result; |
546 | 546 | ||
547 | result = 1; | 547 | result = 1; |
548 | server = user = pass = 0; | 548 | server = user = pass = 0; |
549 | server = strdup( smtp->getServer().latin1() ); | 549 | server = strdup( smtp->getServer().latin1() ); |
550 | ssl = smtp->getSSL(); | 550 | ssl = smtp->getSSL(); |
551 | port = smtp->getPort().toUInt(); | 551 | port = smtp->getPort().toUInt(); |
552 | 552 | ||
553 | session = mailsmtp_new( 20, &progress ); | 553 | session = mailsmtp_new( 20, &progress ); |
554 | if ( session == NULL ) goto free_mem; | 554 | if ( session == NULL ) goto free_mem; |
555 | 555 | ||
556 | qDebug( "Servername %s at port %i", server, port ); | 556 | qDebug( "Servername %s at port %i", server, port ); |
557 | if ( ssl ) { | 557 | if ( ssl ) { |
558 | qDebug( "SSL session" ); | 558 | qDebug( "SSL session" ); |
559 | err = mailsmtp_ssl_connect( session, server, port ); | 559 | err = mailsmtp_ssl_connect( session, server, port ); |
560 | } else { | 560 | } else { |
561 | qDebug( "No SSL session" ); | 561 | qDebug( "No SSL session" ); |
562 | err = mailsmtp_socket_connect( session, server, port ); | 562 | err = mailsmtp_socket_connect( session, server, port ); |
563 | } | 563 | } |
@@ -619,80 +619,77 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) | |||
619 | SMTPaccount *smtp = aSmtp; | 619 | SMTPaccount *smtp = aSmtp; |
620 | 620 | ||
621 | if (!later && !smtp) { | 621 | if (!later && !smtp) { |
622 | qDebug("Didn't get any send method - giving up"); | 622 | qDebug("Didn't get any send method - giving up"); |
623 | return; | 623 | return; |
624 | } | 624 | } |
625 | mimeMail = createMimeMail(mail ); | 625 | mimeMail = createMimeMail(mail ); |
626 | if ( mimeMail == NULL ) { | 626 | if ( mimeMail == NULL ) { |
627 | qDebug( "sendMail: error creating mime mail" ); | 627 | qDebug( "sendMail: error creating mime mail" ); |
628 | } else { | 628 | } else { |
629 | sendProgress = new progressMailSend(); | 629 | sendProgress = new progressMailSend(); |
630 | sendProgress->show(); | 630 | sendProgress->show(); |
631 | sendProgress->setMaxMails(1); | 631 | sendProgress->setMaxMails(1); |
632 | smtpSend( mimeMail,later,smtp); | 632 | smtpSend( mimeMail,later,smtp); |
633 | qDebug("Clean up done"); | 633 | qDebug("Clean up done"); |
634 | sendProgress->hide(); | 634 | sendProgress->hide(); |
635 | delete sendProgress; | 635 | delete sendProgress; |
636 | sendProgress = 0; | 636 | sendProgress = 0; |
637 | mailmime_free( mimeMail ); | 637 | mailmime_free( mimeMail ); |
638 | } | 638 | } |
639 | } | 639 | } |
640 | 640 | ||
641 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 641 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
642 | { | 642 | { |
643 | char*data = 0; | ||
644 | size_t length = 0; | ||
645 | size_t curTok = 0; | 643 | size_t curTok = 0; |
646 | mailimf_fields *fields = 0; | 644 | mailimf_fields *fields = 0; |
647 | mailimf_field*ffrom = 0; | 645 | mailimf_field*ffrom = 0; |
648 | clist *rcpts = 0; | 646 | clist *rcpts = 0; |
649 | char*from = 0; | 647 | char*from = 0; |
650 | int res = 0; | 648 | int res = 0; |
651 | 649 | ||
652 | wrap->fetchRawBody(*which,&data,&length); | 650 | encodedString * data = wrap->fetchRawBody(*which); |
653 | if (!data) return 0; | 651 | if (!data) return 0; |
654 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); | 652 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
655 | if (err != MAILIMF_NO_ERROR) { | 653 | if (err != MAILIMF_NO_ERROR) { |
656 | free(data); | 654 | delete data; |
657 | delete wrap; | 655 | delete wrap; |
658 | return 0; | 656 | return 0; |
659 | } | 657 | } |
660 | 658 | ||
661 | rcpts = createRcptList( fields ); | 659 | rcpts = createRcptList( fields ); |
662 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 660 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
663 | from = getFrom(ffrom); | 661 | from = getFrom(ffrom); |
664 | 662 | ||
665 | qDebug("Size: %i vs. %i",length,strlen(data)); | ||
666 | if (rcpts && from) { | 663 | if (rcpts && from) { |
667 | res = smtpSend(from,rcpts,data,length,smtp ); | 664 | res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp ); |
668 | } | 665 | } |
669 | if (fields) { | 666 | if (fields) { |
670 | mailimf_fields_free(fields); | 667 | mailimf_fields_free(fields); |
671 | fields = 0; | 668 | fields = 0; |
672 | } | 669 | } |
673 | if (data) { | 670 | if (data) { |
674 | free(data); | 671 | delete data; |
675 | } | 672 | } |
676 | if (from) { | 673 | if (from) { |
677 | free(from); | 674 | free(from); |
678 | } | 675 | } |
679 | if (rcpts) { | 676 | if (rcpts) { |
680 | smtp_address_list_free( rcpts ); | 677 | smtp_address_list_free( rcpts ); |
681 | } | 678 | } |
682 | return res; | 679 | return res; |
683 | } | 680 | } |
684 | 681 | ||
685 | /* this is a special fun */ | 682 | /* this is a special fun */ |
686 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 683 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
687 | { | 684 | { |
688 | bool returnValue = true; | 685 | bool returnValue = true; |
689 | 686 | ||
690 | if (!smtp) return false; | 687 | if (!smtp) return false; |
691 | 688 | ||
692 | QString localfolders = AbstractMail::defaultLocalfolder(); | 689 | QString localfolders = AbstractMail::defaultLocalfolder(); |
693 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 690 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
694 | if (!wrap) { | 691 | if (!wrap) { |
695 | qDebug("memory error"); | 692 | qDebug("memory error"); |
696 | return false; | 693 | return false; |
697 | } | 694 | } |
698 | QList<RecMail> mailsToSend; | 695 | QList<RecMail> mailsToSend; |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 4a4352f..04fc4b0 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -26,47 +26,47 @@ class SMTPwrapper : public QObject | |||
26 | 26 | ||
27 | public: | 27 | public: |
28 | SMTPwrapper( Settings *s ); | 28 | SMTPwrapper( Settings *s ); |
29 | virtual ~SMTPwrapper(){} | 29 | virtual ~SMTPwrapper(){} |
30 | void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); | 30 | void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); |
31 | bool flushOutbox(SMTPaccount*smtp); | 31 | bool flushOutbox(SMTPaccount*smtp); |
32 | 32 | ||
33 | static progressMailSend*sendProgress; | 33 | static progressMailSend*sendProgress; |
34 | 34 | ||
35 | signals: | 35 | signals: |
36 | void queuedMails( int ); | 36 | void queuedMails( int ); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
40 | mailimf_fields *createImfFields(const Mail &mail ); | 40 | mailimf_fields *createImfFields(const Mail &mail ); |
41 | mailmime *createMimeMail(const Mail&mail ); | 41 | mailmime *createMimeMail(const Mail&mail ); |
42 | 42 | ||
43 | mailimf_address_list *parseAddresses(const QString&addr ); | 43 | mailimf_address_list *parseAddresses(const QString&addr ); |
44 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 44 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
45 | mailmime *buildTxtPart(const QString&str ); | 45 | mailmime *buildTxtPart(const QString&str ); |
46 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 46 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
47 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); | 47 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); |
48 | clist *createRcptList( mailimf_fields *fields ); | 48 | clist *createRcptList( mailimf_fields *fields ); |
49 | 49 | ||
50 | static void storeMail(char*mail, size_t length, const QString&box); | 50 | static void storeMail(const char*mail, size_t length, const QString&box); |
51 | static QString mailsmtpError( int err ); | 51 | static QString mailsmtpError( int err ); |
52 | static void progress( size_t current, size_t maximum ); | 52 | static void progress( size_t current, size_t maximum ); |
53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
54 | static char *getFrom( mailmime *mail ); | 54 | static char *getFrom( mailmime *mail ); |
55 | static char *getFrom( mailimf_field *ffrom); | 55 | static char *getFrom( mailimf_field *ffrom); |
56 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 56 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); | 57 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); |
58 | 58 | ||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); |
63 | 63 | ||
64 | int m_queuedMail; | 64 | int m_queuedMail; |
65 | static const char* USER_AGENT; | 65 | static const char* USER_AGENT; |
66 | 66 | ||
67 | protected slots: | 67 | protected slots: |
68 | void emitQCop( int queued ); | 68 | void emitQCop( int queued ); |
69 | 69 | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | #endif | 72 | #endif |