author | alwin <alwin> | 2003-12-28 17:32:43 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 17:32:43 (UTC) |
commit | 696a2dcfcb65fbb24b709bbae0a18a7854e2d72c (patch) (side-by-side diff) | |
tree | e813c9508881796cf999e9c25c05e4482c6fd9e8 /noncore/net/mail/smtpwrapper.cpp | |
parent | b900cad9c050c2d5963228a2191e13053457ef1d (diff) | |
download | opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.zip opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.tar.gz opie-696a2dcfcb65fbb24b709bbae0a18a7854e2d72c.tar.bz2 |
reduced to the max...
- from address isn't setup any longer within the smtp account (it makes realy no
sense, a smtp account describes the connection to a smtp server, not the
identity of the sender)
- from address is taken from the personal info of the addressbook (thats why this
info exists). Of course the user can change it when sending an email.
- user can select a from with a selection of the mails given in their personal
infos.
- in addresspicker: use "<Firstname> <Lastname>" instead of "Filename"
- settings ui: switched of the part within the smtp accounts describing the
identitiy of user
ToDo: a dialog setting up a default signature
Diffstat (limited to 'noncore/net/mail/smtpwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 54 |
1 files changed, 19 insertions, 35 deletions
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 521cd0a..30c0707 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp @@ -119,27 +119,27 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) qDebug( *it ); } else { qDebug( "Parse success! %s",(*it).latin1()); } } return addresses; } mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { mailimf_fields *fields; mailimf_field *xmailer; - mailimf_mailbox *sender, *fromBox; - mailimf_mailbox_list *from; - mailimf_address_list *to, *cc, *bcc, *reply; + mailimf_mailbox *sender=0,*fromBox=0; + mailimf_mailbox_list *from=0; + mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; char *subject = strdup( mail.getSubject().latin1() ); int err; sender = newMailbox( mail.getName(), mail.getMail() ); if ( sender == NULL ) goto err_free; fromBox = newMailbox( mail.getName(), mail.getMail() ); if ( fromBox == NULL ) goto err_free_sender; from = mailimf_mailbox_list_new_empty(); if ( from == NULL ) goto err_free_fromBox; @@ -158,64 +158,64 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) if ( fields == NULL ) goto err_free_reply; xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), strdup( USER_AGENT ) ); if ( xmailer == NULL ) goto err_free_fields; err = mailimf_fields_add( fields, xmailer ); if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; return fields; // Success :) err_free_xmailer: - mailimf_field_free( xmailer ); + if (xmailer) mailimf_field_free( xmailer ); err_free_fields: - mailimf_fields_free( fields ); + if (fields) mailimf_fields_free( fields ); err_free_reply: - mailimf_address_list_free( reply ); - mailimf_address_list_free( bcc ); - mailimf_address_list_free( cc ); - mailimf_address_list_free( to ); + if (reply) mailimf_address_list_free( reply ); + if (bcc) mailimf_address_list_free( bcc ); + if (cc) mailimf_address_list_free( cc ); + if (to) mailimf_address_list_free( to ); err_free_from: - mailimf_mailbox_list_free( from ); + if (from) mailimf_mailbox_list_free( from ); err_free_fromBox: mailimf_mailbox_free( fromBox ); err_free_sender: - mailimf_mailbox_free( sender ); + if (sender) mailimf_mailbox_free( sender ); err_free: - free( subject ); + if (subject) free( subject ); qDebug( "createImfFields - error" ); return NULL; // Error :( } mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { mailmime *txtPart; mailmime_fields *fields; mailmime_content *content; mailmime_parameter *param; int err; param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); if ( param == NULL ) goto err_free; content = mailmime_content_new_with_str( "text/plain" ); if ( content == NULL ) goto err_free_param; err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); + fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); if ( txtPart == NULL ) goto err_free_fields; err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; return txtPart; // Success :) err_free_txtPart: mailmime_free( txtPart ); @@ -453,44 +453,24 @@ 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; ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); return getFrom(ffrom); } -SMTPaccount *SMTPwrapper::getAccount(const QString&name ) -{ - SMTPaccount *smtp; - - QList<Account> list = settings->getAccounts(); - Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast<SMTPaccount *>(it); - if ( smtp->getName()== name ) { - qDebug( "SMTPaccount found for" ); - qDebug( name ); - return smtp; - } - } - } - - return NULL; -} - void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { SMTPwrapper::sendProgress->setSingleMail(current, maximum ); qApp->processEvents(); } } void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) { if (!mail) return; QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); @@ -604,30 +584,34 @@ free_con_session: mailsmtp_quit( session ); free_mem_session: mailsmtp_free( session ); free_mem: if (server) free( server ); if ( smtp->getLogin() ) { free( user ); free( pass ); } return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) { mailmime * mimeMail; - SMTPaccount *smtp = getAccount(mail.getName()); + SMTPaccount *smtp = aSmtp; + if (!later && !smtp) { + qDebug("Didn't get any send method - giving up"); + return; + } mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "sendMail: error creating mime mail" ); } else { sendProgress = new progressMailSend(); sendProgress->show(); sendProgress->setMaxMails(1); smtpSend( mimeMail,later,smtp); qDebug("Clean up done"); sendProgress->hide(); delete sendProgress; sendProgress = 0; |