summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/generatemail.cpp
Side-by-side diff
Diffstat (limited to 'kmicromail/libmailwrapper/generatemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/generatemail.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp
index 2d213fe..ddad21b 100644
--- a/kmicromail/libmailwrapper/generatemail.cpp
+++ b/kmicromail/libmailwrapper/generatemail.cpp
@@ -1,73 +1,75 @@
#include "generatemail.h"
#include "mailwrapper.h"
#include <libetpan/libetpan.h>
//#include <qt.h>
#include <stdlib.h>
#include <qfileinfo.h>
+//Added by qt3to4:
+#include <Q3CString>
using namespace Opie::Core;
const char* Generatemail::USER_AGENT="KOpieMail 33 1/3";
Generatemail::Generatemail()
{
mCharset = "iso-8859-1";
}
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;
if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
} else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
mailimf_mailbox *mbox;
mbox = (mailimf_mailbox *) it2->data;
esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
}
}
}
}
char *Generatemail::getFrom( mailimf_field *ffrom) {
char *from = NULL;
if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
&& ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
clistiter *it;
for ( it = clist_begin( cl ); it; it = it->next ) {
mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
from = strdup( mb->mb_addr_spec );
}
}
return from;
}
char *Generatemail::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);
}
mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) {
mailimf_field *field;
clistiter *it;
it = clist_begin( fields->fld_list );
while ( it ) {
field = (mailimf_field *) it->data;
if ( field->fld_type == type ) {
return field;
@@ -167,153 +169,153 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet
}
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.utf8().data()),TextContent.utf8().length());
//err = mailmime_set_body_text(filePart,strdup( TextContent.latin1()),TextContent.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) {
mailmime_fields_free( fields );
} else {
if (name) {
free( name );
}
if (file) {
free( file );
}
}
}
return filePart; // Success :)
}
void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) {
const Attachment *it;
unsigned int count = files.count();
for ( unsigned int i = 0; i < count; ++i ) {
mailmime *filePart;
int err;
it = ((QList<Attachment>)files).at(i);
filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
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;
+ Q3CString __str;
//qDebug(" Generatemail::buildTxtPart %s", str.latin1());
param = mailmime_parameter_new( strdup( "charset" ),
strdup( mCharset.latin1() ) );
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;
{
//__str = str.utf8();
- __str = QCString (str.latin1());
+ __str = Q3CString (str.latin1());
err = mailmime_set_body_text( txtPart, strdup(__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:
;
return NULL; // Error :(
}
mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) {
return mailimf_mailbox_new( strdup( name.latin1() ),
strdup( mail.latin1() ) );
}
mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail )
{
mailimf_fields *fields = NULL;
mailimf_field *xmailer = NULL;
mailimf_mailbox *sender=0,*fromBox=0;
mailimf_mailbox_list *from=0;
mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
clist*in_reply_to = 0;
char *subject = strdup( mail->getSubject().latin1() );
int err;
int res = 1;
sender = newMailbox( mail->getName(), mail->getMail() );
if ( sender == NULL ) {
res = 0;
}
if (res) {
fromBox = newMailbox( mail->getName(), mail->getMail() );
}
if ( fromBox == NULL ) {
res = 0;
}
if (res) {
from = mailimf_mailbox_list_new_empty();
}
if ( from == NULL ) {
res = 0;
}
if (res && from) {
err = mailimf_mailbox_list_add( from, fromBox );
if ( err != MAILIMF_NO_ERROR ) {
res = 0;
}
}