Diffstat (limited to 'kmicromail/libmailwrapper/generatemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp index 49315ba..32311d7 100644 --- a/kmicromail/libmailwrapper/generatemail.cpp +++ b/kmicromail/libmailwrapper/generatemail.cpp @@ -1,28 +1,28 @@ #include "generatemail.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> //#include <qt.h> #include <stdlib.h> #include <qfileinfo.h> using namespace Opie::Core; -const char* Generatemail::USER_AGENT="OpieMail v0.6"; +const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; Generatemail::Generatemail() { } Generatemail::~Generatemail() { } void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { clistiter *it, *it2; for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { mailimf_address *addr; addr = (mailimf_address *) it->data; @@ -119,33 +119,32 @@ mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { if ( err != MAILIMF_NO_ERROR ) { qDebug(" Error parsing"); // *it } else { } } return addresses; } mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { mailmime * filePart = 0; mailmime_fields * fields = 0; mailmime_content * content = 0; mailmime_parameter * param = 0; char*name = 0; char*file = 0; int err; - int pos = filename.findRev( '/' ); if (filename.length()>0) { QString tmp = filename.right( filename.length() - ( pos + 1 ) ); name = strdup( tmp.latin1() ); // just filename file = strdup( filename.latin1() ); // full name with path } int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; int mechanism = MAILMIME_MECHANISM_BASE64; if ( mimetype.startsWith( "text/" ) ) { param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; } @@ -158,33 +157,33 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet if (param) { clist_append(content->ct_parameters,param); param = 0; } if (filename.length()>0) { QFileInfo f(filename); param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); clist_append(content->ct_parameters,param); param = 0; } filePart = mailmime_new_empty( content, fields ); } if (filePart) { if (filename.length()>0) { err = mailmime_set_body_file( filePart, file ); } else { - err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); + err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length()); } if (err != MAILIMF_NO_ERROR) { qDebug("Error setting body with file "); mailmime_free( filePart ); filePart = 0; } } if (!filePart) { if ( param != NULL ) { mailmime_parameter_free( param ); } if (content) { mailmime_content_free( content ); } if (fields) { @@ -214,55 +213,57 @@ void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files if ( filePart == NULL ) { continue; } err = mailmime_smart_add_part( message, filePart ); if ( err != MAILIMF_NO_ERROR ) { mailmime_free( filePart ); } } } mailmime *Generatemail::buildTxtPart(const QString&str ) { mailmime *txtPart; mailmime_fields *fields; mailmime_content *content; mailmime_parameter *param; int err; - + QCString __str; 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_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() ); + { + __str = str.utf8(); + err = mailmime_set_body_text( txtPart, __str.data(), __str.length() ); + } if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; return txtPart; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_fields: mailmime_fields_free( fields ); err_free_content: mailmime_content_free( content ); err_free_param: mailmime_parameter_free( param ); err_free: ; |