Diffstat (limited to 'noncore/net/mail/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index a7e4837..21992b4 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp @@ -438,13 +438,15 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom) return from; } char *SMTPwrapper::getFrom( mailmime *mail ) { + /* no need to delete - its just a pointer to structure content */ mailimf_field *ffrom = 0; + char*f = 0; ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); return getFrom(ffrom); } SMTPaccount *SMTPwrapper::getAccount(const QString&name ) { @@ -560,12 +562,15 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) if (data) free( data ); return; } from = getFrom( mail ); rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); smtpSend(from,rcpts,data,size,smtp); + if (data) {free(data);} + if (from) {free(from);} + if (rcpts) smtp_address_list_free( rcpts ); } int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) { char *server, *user, *pass; bool ssl; @@ -627,16 +632,13 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou free_con_session: mailsmtp_quit( session ); free_mem_session: mailsmtp_free( session ); free_mem: - if (rcpts) smtp_address_list_free( rcpts ); - if (data) free( data ); if (server) free( server ); - if (from) free( from ); if ( smtp->getLogin() ) { free( user ); free( pass ); } return result; } @@ -649,13 +651,12 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later ) mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "sendMail: error creating mime mail" ); } else { sendProgress = new progressMailSend(); -// sendProgress->showMaximized(); sendProgress->show(); sendProgress->setMaxMails(1); smtpSend( mimeMail,later,smtp); mailmime_free( mimeMail ); qDebug("Clean up done"); sendProgress->hide(); @@ -670,12 +671,13 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) size_t length = 0; size_t curTok = 0; mailimf_fields *fields = 0; mailimf_field*ffrom = 0; clist *rcpts = 0; char*from = 0; + int res = 0; wrap->fetchRawBody(*which,&data,&length); if (!data) return 0; int err = mailimf_fields_parse( data, length, &curTok, &fields ); if (err != MAILIMF_NO_ERROR) { free(data); @@ -686,15 +688,28 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) rcpts = createRcptList( fields ); ffrom = getField(fields, MAILIMF_FIELD_FROM ); from = getFrom(ffrom); qDebug("Size: %i vs. %i",length,strlen(data)); if (rcpts && from) { - return smtpSend(from,rcpts,data,strlen(data),smtp ); + res = smtpSend(from,rcpts,data,length,smtp ); } - return 0; + if (fields) { + mailimf_fields_free(fields); + fields = 0; + } + if (data) { + free(data); + } + if (from) { + free(from); + } + if (rcpts) { + smtp_address_list_free( rcpts ); + } + return res; } /* this is a special fun */ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) { bool returnValue = true; @@ -714,15 +729,14 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) if (mailsToSend.count()==0) { delete wrap; return false; } mailsToSend.setAutoDelete(false); sendProgress = new progressMailSend(); -// sendProgress->showMaximized(); - sendProgress->show(); - sendProgress->setMaxMails(mailsToSend.count()); + sendProgress->show(); + sendProgress->setMaxMails(mailsToSend.count()); while (mailsToSend.count()>0) { if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { QMessageBox::critical(0,tr("Error sending mail"), tr("Error sending queued mail - breaking")); @@ -737,8 +751,7 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) delete sendProgress; sendProgress = 0; wrap->deleteMails(mbox,mailsToRemove); mailsToSend.setAutoDelete(true); delete wrap; return returnValue; - } |