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 @@ -28,2 +28,3 @@ public: virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; + virtual encodedString* fetchRawBody(const RecMail&mail)=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 @@ -468,2 +468,6 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> clistcell*current,*cur; + mailimap_section_part * section_part = 0; + mailimap_section_spec * section_spec = 0; + mailimap_section * section = 0; + mailimap_fetch_att * fetch_att = 0; @@ -482,13 +486,20 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> set = mailimap_set_new_single(mail.getNumber()); - clist*id_list=clist_new(); - for (unsigned j=0; j < path.count();++j) { - uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); - *p_id = path[j]; - clist_append(id_list,p_id); - } - mailimap_section_part * section_part = mailimap_section_part_new(id_list); - mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); - mailimap_section * section = mailimap_section_new(section_spec); - mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); + clist*id_list = 0; + + /* if path == empty then its a request for the whole rfc822 mail and generates + a "fetch <id> (body[])" statement on imap server */ + if (path.count()>0 ) { + id_list = clist_new(); + for (unsigned j=0; j < path.count();++j) { + uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); + *p_id = path[j]; + clist_append(id_list,p_id); + } + section_part = mailimap_section_part_new(id_list); + section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); + } + + section = mailimap_section_new(section_spec); + fetch_att = mailimap_fetch_att_new_body_section(section); fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); @@ -957,20 +968,24 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); - for (cur = clist_begin(status->st_info_list); - cur != NULL ; cur = clist_next(cur)) { - mailimap_status_info * status_info; - status_info = (mailimap_status_info *)clist_content(cur); - switch (status_info->st_att) { - case MAILIMAP_STATUS_ATT_MESSAGES: - target_stat.message_count = status_info->st_value; - break; - case MAILIMAP_STATUS_ATT_RECENT: - target_stat.message_recent = status_info->st_value; - break; - case MAILIMAP_STATUS_ATT_UNSEEN: - target_stat.message_unseen = status_info->st_value; - break; + if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { + for (cur = clist_begin(status->st_info_list); + cur != NULL ; cur = clist_next(cur)) { + mailimap_status_info * status_info; + status_info = (mailimap_status_info *)clist_content(cur); + switch (status_info->st_att) { + case MAILIMAP_STATUS_ATT_MESSAGES: + target_stat.message_count = status_info->st_value; + break; + case MAILIMAP_STATUS_ATT_RECENT: + target_stat.message_recent = status_info->st_value; + break; + case MAILIMAP_STATUS_ATT_UNSEEN: + target_stat.message_unseen = status_info->st_value; + break; + } } + } else { + qDebug("Error retrieving status"); } - mailimap_mailbox_data_status_free(status); - mailimap_status_att_list_free(att_list); + if (status) mailimap_mailbox_data_status_free(status); + if (att_list) mailimap_status_att_list_free(att_list); } @@ -992 +1007,8 @@ const QString&IMAPwrapper::getType()const } + +encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) +{ + // dummy + QValueList<int> path; + return fetchRawPart(mail,path,false); +} 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 @@ -38,2 +38,3 @@ public: virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); + virtual encodedString* fetchRawBody(const RecMail&mail); 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 @@ -174,3 +174,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde -void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) +encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) { @@ -192,3 +192,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) mailstorage_free(storage); - return; + return 0; } @@ -199,3 +199,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) mailstorage_free(storage); - return; + return 0; } @@ -207,6 +207,6 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) mailmessage_free(msg); - return; + return 0; } - *target = data; - *length = size; + encodedString*result = new encodedString(data,size); + mailfolder_free(folder); @@ -214,2 +214,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) mailmessage_free(msg); + return result; } 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 @@ -8,2 +8,3 @@ class RecMail; class RecBody; +class encodedString; struct mailmbox_folder; @@ -32,3 +33,3 @@ public: - virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); + virtual encodedString* fetchRawBody(const RecMail&mail); virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); 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 @@ -230,8 +230,15 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) -void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) +encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { + char*target=0; + size_t length=0; + encodedString*res = 0; mailmessage * mailmsg = 0; int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); - err = mailmessage_fetch(mailmsg,target,length); + err = mailmessage_fetch(mailmsg,&target,&length); if (mailmsg) mailmessage_free(mailmsg); + if (target) { + res = new encodedString(target,length); + } + return res; } 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 @@ -7,2 +7,3 @@ +class encodedString; struct mailstorage; @@ -28,3 +29,3 @@ public: virtual RecBody fetchBody( const RecMail &mail ); - virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); + virtual encodedString* fetchRawBody(const RecMail&mail); virtual void logout(); 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 @@ -487,3 +487,3 @@ void SMTPwrapper::progress( size_t current, size_t maximum ) -void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) +void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { @@ -538,3 +538,3 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) -int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) +int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) { @@ -642,4 +642,2 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) { - char*data = 0; - size_t length = 0; size_t curTok = 0; @@ -651,7 +649,7 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) - wrap->fetchRawBody(*which,&data,&length); + encodedString * data = wrap->fetchRawBody(*which); if (!data) return 0; - int err = mailimf_fields_parse( data, length, &curTok, &fields ); + int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); if (err != MAILIMF_NO_ERROR) { - free(data); + delete data; delete wrap; @@ -664,5 +662,4 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) - qDebug("Size: %i vs. %i",length,strlen(data)); if (rcpts && from) { - res = smtpSend(from,rcpts,data,length,smtp ); + res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp ); } @@ -673,3 +670,3 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) if (data) { - free(data); + delete data; } 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 @@ -49,3 +49,3 @@ protected: - static void storeMail(char*mail, size_t length, const QString&box); + static void storeMail(const char*mail, size_t length, const QString&box); static QString mailsmtpError( int err ); @@ -56,3 +56,3 @@ protected: static mailimf_field *getField( mailimf_fields *fields, int type ); - int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); + int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); |