author | harlekin <harlekin> | 2003-12-08 16:57:54 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-08 16:57:54 (UTC) |
commit | 57bc0542cae3d106194c9318612fde304e8acfa7 (patch) (side-by-side diff) | |
tree | e0cb233b51302ad2401534ee221cd16fc99d4817 /noncore/net/mail/mailwrapper.cpp | |
parent | e7b8b190e8c3081d20e33c512224f9a5b5baa20c (diff) | |
download | opie-57bc0542cae3d106194c9318612fde304e8acfa7.zip opie-57bc0542cae3d106194c9318612fde304e8acfa7.tar.gz opie-57bc0542cae3d106194c9318612fde304e8acfa7.tar.bz2 |
no idea how to comment that change
Diffstat (limited to 'noncore/net/mail/mailwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 17bed65..13a3fd9 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp @@ -12,3 +12,3 @@ #include "logindialog.h" -#include "mail.h" +//#include "mail.h" #include "defines.h" @@ -16,5 +16,5 @@ Attachment::Attachment( DocLnk lnk ) -{ - doc = lnk; - size = QFileInfo( doc.file() ).size(); +{ + doc = lnk; + size = QFileInfo( doc.file() ).size(); } @@ -25,4 +25,4 @@ Folder::Folder(const QString&tmp_name ) nameDisplay = name; - - for ( int pos = nameDisplay.find( '&' ); pos != -1; + + for ( int pos = nameDisplay.find( '&' ); pos != -1; pos = nameDisplay.find( '&' ) ) { @@ -34,3 +34,3 @@ Folder::Folder(const QString&tmp_name ) nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); - } else if ( str64.compare( "APY" ) == 0 ) { + } else if ( str64.compare( "APY" ) == 0 ) { nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); @@ -92,3 +92,3 @@ mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail { - return mailimf_mailbox_new( strdup( name.latin1() ), + return mailimf_mailbox_new( strdup( name.latin1() ), strdup( mail.latin1() ) ); @@ -99,7 +99,7 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) mailimf_address_list *addresses; - + if ( addr.isEmpty() ) return NULL; - + addresses = mailimf_address_list_new_empty(); - + QStringList list = QStringList::split( ',', addr ); @@ -117,3 +117,3 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) } - + return addresses; @@ -130,15 +130,15 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 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; - + err = mailimf_mailbox_list_add( from, fromBox ); if ( err != MAILIMF_NO_ERROR ) goto err_free_from; - + to = parseAddresses( mail->getTo() ); @@ -153,3 +153,3 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) if ( fields == NULL ) goto err_free_reply; - + xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), @@ -157,6 +157,6 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 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 :) @@ -193,19 +193,19 @@ mailmime *MailWrapper::buildTxtPart( QString str ) int err; - - param = mailmime_parameter_new( strdup( "charset" ), + + 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->parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - + 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, txt, strlen( txt ) ); @@ -216,3 +216,3 @@ mailmime *MailWrapper::buildTxtPart( QString str ) err_free_txtPart: - mailmime_free( txtPart ); + mailmime_free( txtPart ); err_free_fields: @@ -220,3 +220,3 @@ err_free_fields: err_free_content: - mailmime_content_free( content ); + mailmime_content_free( content ); err_free_param: @@ -226,3 +226,3 @@ err_free: qDebug( "buildTxtPart - error" ); - + return NULL; // Error :( @@ -237,3 +237,3 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) int err; - + int pos = filename.findRev( '/' ); @@ -243,16 +243,16 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain - - fields = mailmime_fields_new_filename( - MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, + + fields = mailmime_fields_new_filename( + MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, MAILMIME_MECHANISM_BASE64 ); if ( fields == NULL ) goto err_free; - + content = mailmime_content_new_with_str( mime ); if ( content == NULL ) goto err_free_fields; - + if ( mimetype.compare( "text/plain" ) == 0 ) { - param = mailmime_parameter_new( strdup( "charset" ), + param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); if ( param == NULL ) goto err_free_content; - + err = clist_append( content->parameters, param ); @@ -260,9 +260,9 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) } - + filePart = mailmime_new_empty( content, fields ); if ( filePart == NULL ) goto err_free_param; - + err = mailmime_set_body_file( filePart, file ); if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; - + return filePart; // Success :) @@ -282,3 +282,3 @@ err_free: qDebug( "buildFilePart - error" ); - + return NULL; // Error :( @@ -291,3 +291,3 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) qDebug( "Adding file" ); - mailmime *filePart; + mailmime *filePart; int err; @@ -296,8 +296,8 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) if ( filePart == NULL ) goto err_free; - + err = mailmime_smart_add_part( message, filePart ); if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; - - continue; // Success :) - + + continue; // Success :) + err_free_filePart: @@ -318,6 +318,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) if ( fields == NULL ) goto err_free; - + message = mailmime_new_message_data( NULL ); if ( message == NULL ) goto err_free_fields; - + mailmime_set_imf_fields( message, fields ); @@ -326,6 +326,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) if ( txtPart == NULL ) goto err_free_message; - + err = mailmime_smart_add_part( message, txtPart ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; - + addFileParts( message, mail->getAttachments() ); @@ -359,3 +359,3 @@ mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) } - + return NULL; @@ -366,3 +366,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) clistiter *it, *it2; - + for ( it = clist_begin( addr_list->list ); it; it = it->next ) { @@ -370,3 +370,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) addr = (mailimf_address *) it->data; - + if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { @@ -390,5 +390,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) rcptList = esmtp_address_list_new(); - + field = getField( fields, MAILIMF_FIELD_TO ); - if ( field && (field->type == MAILIMF_FIELD_TO) + if ( field && (field->type == MAILIMF_FIELD_TO) && field->field.to->addr_list ) { @@ -396,3 +396,3 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) } - + field = getField( fields, MAILIMF_FIELD_CC ); @@ -402,5 +402,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) } - + field = getField( fields, MAILIMF_FIELD_BCC ); - if ( field && (field->type == MAILIMF_FIELD_BCC) + if ( field && (field->type == MAILIMF_FIELD_BCC) && field->field.bcc->addr_list ) { @@ -418,3 +418,3 @@ char *MailWrapper::getFrom( mailmime *mail ) ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); - if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) + if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { @@ -428,3 +428,3 @@ char *MailWrapper::getFrom( mailmime *mail ) - return from; + return from; } @@ -434,3 +434,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) SMTPaccount *smtp; - + QList<Account> list = settings->getAccounts(); @@ -447,3 +447,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) } - + return NULL; @@ -454,3 +454,3 @@ QString MailWrapper::getTmpFile() { QString unique; - + QDir dir( "/tmp" ); @@ -462,3 +462,3 @@ QString MailWrapper::getTmpFile() { } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); - + return "/tmp/opiemail-tmp-" + unique; @@ -492,9 +492,9 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) int fd, count = 0, total = 0; - + fd = open( file.latin1(), O_RDONLY, 0 ); if ( fd == -1 ) return; - + if ( fstat( fd, &st ) != 0 ) goto err_close; if ( !st.st_size ) goto err_close; - + buf = (char *) malloc( st.st_size ); @@ -510,3 +510,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) *size = st.st_size; - + close( fd ); @@ -514,3 +514,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) return; // Success :) - + err_free: @@ -535,3 +535,3 @@ void MailWrapper::smtpSend( mailmime *mail ) uint16_t port; - + @@ -553,5 +553,5 @@ void MailWrapper::smtpSend( mailmime *mail ) f.remove(); - + session = mailsmtp_new( 20, &progress ); - if ( session == NULL ) goto free_mem; + if ( session == NULL ) goto free_mem; @@ -569,5 +569,5 @@ void MailWrapper::smtpSend( mailmime *mail ) if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; - + qDebug( "INIT OK" ); - + if ( smtp->getLogin() ) { @@ -593,3 +593,3 @@ void MailWrapper::smtpSend( mailmime *mail ) } - + err = mailsmtp_send( session, from, rcpts, data, size ); @@ -598,3 +598,3 @@ void MailWrapper::smtpSend( mailmime *mail ) qDebug( "Mail sent." ); - + free_con_session: @@ -624,3 +624,3 @@ void MailWrapper::sendMail( Mail mail ) mailmime_free( mimeMail ); - } + } } |