summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/generatemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/generatemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/generatemail.cpp13
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
@@ -4,17 +4,17 @@
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5 5
6//#include <qt.h> 6//#include <qt.h>
7 7
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qfileinfo.h> 9#include <qfileinfo.h>
10 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12const char* Generatemail::USER_AGENT="OpieMail v0.6"; 12const char* Generatemail::USER_AGENT="KOpieMail 33 1/3";
13 13
14Generatemail::Generatemail() 14Generatemail::Generatemail()
15{ 15{
16} 16}
17 17
18Generatemail::~Generatemail() 18Generatemail::~Generatemail()
19{ 19{
20} 20}
@@ -127,17 +127,16 @@ mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) {
127mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { 127mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) {
128 mailmime * filePart = 0; 128 mailmime * filePart = 0;
129 mailmime_fields * fields = 0; 129 mailmime_fields * fields = 0;
130 mailmime_content * content = 0; 130 mailmime_content * content = 0;
131 mailmime_parameter * param = 0; 131 mailmime_parameter * param = 0;
132 char*name = 0; 132 char*name = 0;
133 char*file = 0; 133 char*file = 0;
134 int err; 134 int err;
135
136 int pos = filename.findRev( '/' ); 135 int pos = filename.findRev( '/' );
137 136
138 if (filename.length()>0) { 137 if (filename.length()>0) {
139 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 138 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
140 name = strdup( tmp.latin1() ); // just filename 139 name = strdup( tmp.latin1() ); // just filename
141 file = strdup( filename.latin1() ); // full name with path 140 file = strdup( filename.latin1() ); // full name with path
142 } 141 }
143 142
@@ -166,17 +165,17 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet
166 param = 0; 165 param = 0;
167 } 166 }
168 filePart = mailmime_new_empty( content, fields ); 167 filePart = mailmime_new_empty( content, fields );
169 } 168 }
170 if (filePart) { 169 if (filePart) {
171 if (filename.length()>0) { 170 if (filename.length()>0) {
172 err = mailmime_set_body_file( filePart, file ); 171 err = mailmime_set_body_file( filePart, file );
173 } else { 172 } else {
174 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); 173 err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length());
175 } 174 }
176 if (err != MAILIMF_NO_ERROR) { 175 if (err != MAILIMF_NO_ERROR) {
177 qDebug("Error setting body with file "); 176 qDebug("Error setting body with file ");
178 mailmime_free( filePart ); 177 mailmime_free( filePart );
179 filePart = 0; 178 filePart = 0;
180 } 179 }
181 } 180 }
182 181
@@ -222,17 +221,17 @@ void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files
222} 221}
223 222
224mailmime *Generatemail::buildTxtPart(const QString&str ) { 223mailmime *Generatemail::buildTxtPart(const QString&str ) {
225 mailmime *txtPart; 224 mailmime *txtPart;
226 mailmime_fields *fields; 225 mailmime_fields *fields;
227 mailmime_content *content; 226 mailmime_content *content;
228 mailmime_parameter *param; 227 mailmime_parameter *param;
229 int err; 228 int err;
230 229 QCString __str;
231 param = mailmime_parameter_new( strdup( "charset" ), 230 param = mailmime_parameter_new( strdup( "charset" ),
232 strdup( "iso-8859-1" ) ); 231 strdup( "iso-8859-1" ) );
233 if ( param == NULL ) 232 if ( param == NULL )
234 goto err_free; 233 goto err_free;
235 234
236 content = mailmime_content_new_with_str( "text/plain" ); 235 content = mailmime_content_new_with_str( "text/plain" );
237 if ( content == NULL ) 236 if ( content == NULL )
238 goto err_free_param; 237 goto err_free_param;
@@ -243,18 +242,20 @@ mailmime *Generatemail::buildTxtPart(const QString&str ) {
243 242
244 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); 243 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
245 if ( fields == NULL ) 244 if ( fields == NULL )
246 goto err_free_content; 245 goto err_free_content;
247 246
248 txtPart = mailmime_new_empty( content, fields ); 247 txtPart = mailmime_new_empty( content, fields );
249 if ( txtPart == NULL ) 248 if ( txtPart == NULL )
250 goto err_free_fields; 249 goto err_free_fields;
251 250 {
252 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); 251 __str = str.utf8();
252 err = mailmime_set_body_text( txtPart, __str.data(), __str.length() );
253 }
253 if ( err != MAILIMF_NO_ERROR ) 254 if ( err != MAILIMF_NO_ERROR )
254 goto err_free_txtPart; 255 goto err_free_txtPart;
255 256
256 return txtPart; // Success :) 257 return txtPart; // Success :)
257 258
258err_free_txtPart: 259err_free_txtPart:
259 mailmime_free( txtPart ); 260 mailmime_free( txtPart );
260err_free_fields: 261err_free_fields: