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) | |||
438 | 438 | ||
439 | return from; | 439 | return from; |
440 | } | 440 | } |
441 | 441 | ||
442 | char *SMTPwrapper::getFrom( mailmime *mail ) | 442 | char *SMTPwrapper::getFrom( mailmime *mail ) |
443 | { | 443 | { |
444 | /* no need to delete - its just a pointer to structure content */ | ||
444 | mailimf_field *ffrom = 0; | 445 | mailimf_field *ffrom = 0; |
446 | char*f = 0; | ||
445 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 447 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
446 | return getFrom(ffrom); | 448 | return getFrom(ffrom); |
447 | } | 449 | } |
448 | 450 | ||
449 | SMTPaccount *SMTPwrapper::getAccount(const QString&name ) | 451 | SMTPaccount *SMTPwrapper::getAccount(const QString&name ) |
450 | { | 452 | { |
@@ -560,12 +562,15 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
560 | if (data) free( data ); | 562 | if (data) free( data ); |
561 | return; | 563 | return; |
562 | } | 564 | } |
563 | from = getFrom( mail ); | 565 | from = getFrom( mail ); |
564 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 566 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
565 | smtpSend(from,rcpts,data,size,smtp); | 567 | smtpSend(from,rcpts,data,size,smtp); |
568 | if (data) {free(data);} | ||
569 | if (from) {free(from);} | ||
570 | if (rcpts) smtp_address_list_free( rcpts ); | ||
566 | } | 571 | } |
567 | 572 | ||
568 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) | 573 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) |
569 | { | 574 | { |
570 | char *server, *user, *pass; | 575 | char *server, *user, *pass; |
571 | bool ssl; | 576 | bool ssl; |
@@ -627,16 +632,13 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou | |||
627 | 632 | ||
628 | free_con_session: | 633 | free_con_session: |
629 | mailsmtp_quit( session ); | 634 | mailsmtp_quit( session ); |
630 | free_mem_session: | 635 | free_mem_session: |
631 | mailsmtp_free( session ); | 636 | mailsmtp_free( session ); |
632 | free_mem: | 637 | free_mem: |
633 | if (rcpts) smtp_address_list_free( rcpts ); | ||
634 | if (data) free( data ); | ||
635 | if (server) free( server ); | 638 | if (server) free( server ); |
636 | if (from) free( from ); | ||
637 | if ( smtp->getLogin() ) { | 639 | if ( smtp->getLogin() ) { |
638 | free( user ); | 640 | free( user ); |
639 | free( pass ); | 641 | free( pass ); |
640 | } | 642 | } |
641 | return result; | 643 | return result; |
642 | } | 644 | } |
@@ -649,13 +651,12 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later ) | |||
649 | 651 | ||
650 | mimeMail = createMimeMail(mail ); | 652 | mimeMail = createMimeMail(mail ); |
651 | if ( mimeMail == NULL ) { | 653 | if ( mimeMail == NULL ) { |
652 | qDebug( "sendMail: error creating mime mail" ); | 654 | qDebug( "sendMail: error creating mime mail" ); |
653 | } else { | 655 | } else { |
654 | sendProgress = new progressMailSend(); | 656 | sendProgress = new progressMailSend(); |
655 | // sendProgress->showMaximized(); | ||
656 | sendProgress->show(); | 657 | sendProgress->show(); |
657 | sendProgress->setMaxMails(1); | 658 | sendProgress->setMaxMails(1); |
658 | smtpSend( mimeMail,later,smtp); | 659 | smtpSend( mimeMail,later,smtp); |
659 | mailmime_free( mimeMail ); | 660 | mailmime_free( mimeMail ); |
660 | qDebug("Clean up done"); | 661 | qDebug("Clean up done"); |
661 | sendProgress->hide(); | 662 | sendProgress->hide(); |
@@ -670,12 +671,13 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
670 | size_t length = 0; | 671 | size_t length = 0; |
671 | size_t curTok = 0; | 672 | size_t curTok = 0; |
672 | mailimf_fields *fields = 0; | 673 | mailimf_fields *fields = 0; |
673 | mailimf_field*ffrom = 0; | 674 | mailimf_field*ffrom = 0; |
674 | clist *rcpts = 0; | 675 | clist *rcpts = 0; |
675 | char*from = 0; | 676 | char*from = 0; |
677 | int res = 0; | ||
676 | 678 | ||
677 | wrap->fetchRawBody(*which,&data,&length); | 679 | wrap->fetchRawBody(*which,&data,&length); |
678 | if (!data) return 0; | 680 | if (!data) return 0; |
679 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); | 681 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); |
680 | if (err != MAILIMF_NO_ERROR) { | 682 | if (err != MAILIMF_NO_ERROR) { |
681 | free(data); | 683 | free(data); |
@@ -686,15 +688,28 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
686 | rcpts = createRcptList( fields ); | 688 | rcpts = createRcptList( fields ); |
687 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 689 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
688 | from = getFrom(ffrom); | 690 | from = getFrom(ffrom); |
689 | 691 | ||
690 | qDebug("Size: %i vs. %i",length,strlen(data)); | 692 | qDebug("Size: %i vs. %i",length,strlen(data)); |
691 | if (rcpts && from) { | 693 | if (rcpts && from) { |
692 | return smtpSend(from,rcpts,data,strlen(data),smtp ); | 694 | res = smtpSend(from,rcpts,data,length,smtp ); |
693 | } | 695 | } |
694 | return 0; | 696 | if (fields) { |
697 | mailimf_fields_free(fields); | ||
698 | fields = 0; | ||
699 | } | ||
700 | if (data) { | ||
701 | free(data); | ||
702 | } | ||
703 | if (from) { | ||
704 | free(from); | ||
705 | } | ||
706 | if (rcpts) { | ||
707 | smtp_address_list_free( rcpts ); | ||
708 | } | ||
709 | return res; | ||
695 | } | 710 | } |
696 | 711 | ||
697 | /* this is a special fun */ | 712 | /* this is a special fun */ |
698 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 713 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
699 | { | 714 | { |
700 | bool returnValue = true; | 715 | bool returnValue = true; |
@@ -714,15 +729,14 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | |||
714 | if (mailsToSend.count()==0) { | 729 | if (mailsToSend.count()==0) { |
715 | delete wrap; | 730 | delete wrap; |
716 | return false; | 731 | return false; |
717 | } | 732 | } |
718 | mailsToSend.setAutoDelete(false); | 733 | mailsToSend.setAutoDelete(false); |
719 | sendProgress = new progressMailSend(); | 734 | sendProgress = new progressMailSend(); |
720 | // sendProgress->showMaximized(); | 735 | sendProgress->show(); |
721 | sendProgress->show(); | 736 | sendProgress->setMaxMails(mailsToSend.count()); |
722 | sendProgress->setMaxMails(mailsToSend.count()); | ||
723 | 737 | ||
724 | while (mailsToSend.count()>0) { | 738 | while (mailsToSend.count()>0) { |
725 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { | 739 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { |
726 | QMessageBox::critical(0,tr("Error sending mail"), | 740 | QMessageBox::critical(0,tr("Error sending mail"), |
727 | tr("Error sending queued mail - breaking")); | 741 | tr("Error sending queued mail - breaking")); |
728 | 742 | ||
@@ -737,8 +751,7 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | |||
737 | delete sendProgress; | 751 | delete sendProgress; |
738 | sendProgress = 0; | 752 | sendProgress = 0; |
739 | wrap->deleteMails(mbox,mailsToRemove); | 753 | wrap->deleteMails(mbox,mailsToRemove); |
740 | mailsToSend.setAutoDelete(true); | 754 | mailsToSend.setAutoDelete(true); |
741 | delete wrap; | 755 | delete wrap; |
742 | return returnValue; | 756 | return returnValue; |
743 | |||
744 | } | 757 | } |