author | alwin <alwin> | 2004-01-06 22:30:50 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-06 22:30:50 (UTC) |
commit | a545ea9b957c14bdf9d8aa20e64457b64841ce7f (patch) (unidiff) | |
tree | aae2cd99718cd0378bf0a53613e2a663d2dd2add | |
parent | a24b39a49ac49d2d3b0f2ff53f0f3b7839447d6e (diff) | |
download | opie-a545ea9b957c14bdf9d8aa20e64457b64841ce7f.zip opie-a545ea9b957c14bdf9d8aa20e64457b64841ce7f.tar.gz opie-a545ea9b957c14bdf9d8aa20e64457b64841ce7f.tar.bz2 |
some more debug infos
memleaks fixed
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 00181ff..4764b77 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -517,119 +517,117 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
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,const 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 | const 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 = 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 | } |
564 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} | 564 | if ( err != MAILSMTP_NO_ERROR ) {qDebug("Error init connection");result = 0;goto free_mem_session;} |
565 | 565 | ||
566 | err = mailsmtp_init( session ); | 566 | err = mailsmtp_init( session ); |
567 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 567 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
568 | 568 | ||
569 | qDebug( "INIT OK" ); | 569 | qDebug( "INIT OK" ); |
570 | 570 | ||
571 | if ( smtp->getLogin() ) { | 571 | if ( smtp->getLogin() ) { |
572 | qDebug("smtp with auth"); | ||
572 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { | 573 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { |
573 | // get'em | 574 | // get'em |
574 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); | 575 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); |
575 | login.show(); | 576 | login.show(); |
576 | if ( QDialog::Accepted == login.exec() ) { | 577 | if ( QDialog::Accepted == login.exec() ) { |
577 | // ok | 578 | // ok |
578 | user = strdup( login.getUser().latin1() ); | 579 | user = login.getUser().latin1(); |
579 | pass = strdup( login.getPassword().latin1() ); | 580 | pass = login.getPassword().latin1(); |
580 | } else { | 581 | } else { |
581 | result = 0; goto free_con_session; | 582 | result = 0; goto free_con_session; |
582 | } | 583 | } |
583 | } else { | 584 | } else { |
584 | user = strdup( smtp->getUser().latin1() ); | 585 | user = smtp->getUser().latin1(); |
585 | pass = strdup( smtp->getPassword().latin1() ); | 586 | pass = smtp->getPassword().latin1(); |
586 | } | 587 | } |
587 | qDebug( "session->auth: %i", session->auth); | 588 | qDebug( "session->auth: %i", session->auth); |
588 | err = mailsmtp_auth( session, user, pass ); | 589 | err = mailsmtp_auth( session, (char*)user, (char*)pass ); |
589 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 590 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
590 | qDebug( "Done auth!" ); | 591 | qDebug( "Done auth!" ); |
592 | } else { | ||
593 | qDebug("SMTP without auth"); | ||
591 | } | 594 | } |
592 | 595 | ||
593 | err = mailsmtp_send( session, from, rcpts, data, size ); | 596 | err = mailsmtp_send( session, from, rcpts, data, size ); |
594 | if ( err != MAILSMTP_NO_ERROR ) { | 597 | if ( err != MAILSMTP_NO_ERROR ) { |
595 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); | 598 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); |
596 | result = 0; goto free_con_session; | 599 | result = 0; goto free_con_session; |
597 | } | 600 | } |
598 | 601 | ||
599 | qDebug( "Mail sent." ); | 602 | qDebug( "Mail sent." ); |
600 | storeMail(data,size,"Sent"); | 603 | storeMail(data,size,"Sent"); |
601 | 604 | ||
602 | free_con_session: | 605 | free_con_session: |
603 | mailsmtp_quit( session ); | 606 | mailsmtp_quit( session ); |
604 | free_mem_session: | 607 | free_mem_session: |
605 | mailsmtp_free( session ); | 608 | mailsmtp_free( session ); |
606 | free_mem: | 609 | free_mem: |
607 | if (server) free( server ); | ||
608 | if ( smtp->getLogin() ) { | ||
609 | free( user ); | ||
610 | free( pass ); | ||
611 | } | ||
612 | return result; | 610 | return result; |
613 | } | 611 | } |
614 | 612 | ||
615 | void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) | 613 | void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) |
616 | { | 614 | { |
617 | mailmime * mimeMail; | 615 | mailmime * mimeMail; |
618 | 616 | ||
619 | SMTPaccount *smtp = aSmtp; | 617 | SMTPaccount *smtp = aSmtp; |
620 | 618 | ||
621 | if (!later && !smtp) { | 619 | if (!later && !smtp) { |
622 | qDebug("Didn't get any send method - giving up"); | 620 | qDebug("Didn't get any send method - giving up"); |
623 | return; | 621 | return; |
624 | } | 622 | } |
625 | mimeMail = createMimeMail(mail ); | 623 | mimeMail = createMimeMail(mail ); |
626 | if ( mimeMail == NULL ) { | 624 | if ( mimeMail == NULL ) { |
627 | qDebug( "sendMail: error creating mime mail" ); | 625 | qDebug( "sendMail: error creating mime mail" ); |
628 | } else { | 626 | } else { |
629 | sendProgress = new progressMailSend(); | 627 | sendProgress = new progressMailSend(); |
630 | sendProgress->show(); | 628 | sendProgress->show(); |
631 | sendProgress->setMaxMails(1); | 629 | sendProgress->setMaxMails(1); |
632 | smtpSend( mimeMail,later,smtp); | 630 | smtpSend( mimeMail,later,smtp); |
633 | qDebug("Clean up done"); | 631 | qDebug("Clean up done"); |
634 | sendProgress->hide(); | 632 | sendProgress->hide(); |
635 | delete sendProgress; | 633 | delete sendProgress; |