Diffstat (limited to 'kmicromail/libmailwrapper/generatemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.cpp | 6 |
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,41 +1,43 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
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 | //Added by qt3to4: | ||
11 | #include <Q3CString> | ||
10 | 12 | ||
11 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
12 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; | 14 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; |
13 | 15 | ||
14 | Generatemail::Generatemail() | 16 | Generatemail::Generatemail() |
15 | { | 17 | { |
16 | mCharset = "iso-8859-1"; | 18 | mCharset = "iso-8859-1"; |
17 | } | 19 | } |
18 | 20 | ||
19 | Generatemail::~Generatemail() | 21 | Generatemail::~Generatemail() |
20 | { | 22 | { |
21 | } | 23 | } |
22 | 24 | ||
23 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 25 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
24 | clistiter *it, *it2; | 26 | clistiter *it, *it2; |
25 | 27 | ||
26 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 28 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
27 | mailimf_address *addr; | 29 | mailimf_address *addr; |
28 | addr = (mailimf_address *) it->data; | 30 | addr = (mailimf_address *) it->data; |
29 | 31 | ||
30 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 32 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
31 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 33 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
32 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 34 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
33 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 35 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
34 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 36 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
35 | mailimf_mailbox *mbox; | 37 | mailimf_mailbox *mbox; |
36 | mbox = (mailimf_mailbox *) it2->data; | 38 | mbox = (mailimf_mailbox *) it2->data; |
37 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 39 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
38 | } | 40 | } |
39 | } | 41 | } |
40 | } | 42 | } |
41 | } | 43 | } |
@@ -199,89 +201,89 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet | |||
199 | } | 201 | } |
200 | } | 202 | } |
201 | } | 203 | } |
202 | return filePart; // Success :) | 204 | return filePart; // Success :) |
203 | 205 | ||
204 | } | 206 | } |
205 | 207 | ||
206 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 208 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
207 | const Attachment *it; | 209 | const Attachment *it; |
208 | unsigned int count = files.count(); | 210 | unsigned int count = files.count(); |
209 | for ( unsigned int i = 0; i < count; ++i ) { | 211 | for ( unsigned int i = 0; i < count; ++i ) { |
210 | mailmime *filePart; | 212 | mailmime *filePart; |
211 | int err; | 213 | int err; |
212 | it = ((QList<Attachment>)files).at(i); | 214 | it = ((QList<Attachment>)files).at(i); |
213 | 215 | ||
214 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 216 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
215 | if ( filePart == NULL ) { | 217 | if ( filePart == NULL ) { |
216 | continue; | 218 | continue; |
217 | } | 219 | } |
218 | err = mailmime_smart_add_part( message, filePart ); | 220 | err = mailmime_smart_add_part( message, filePart ); |
219 | if ( err != MAILIMF_NO_ERROR ) { | 221 | if ( err != MAILIMF_NO_ERROR ) { |
220 | mailmime_free( filePart ); | 222 | mailmime_free( filePart ); |
221 | } | 223 | } |
222 | } | 224 | } |
223 | } | 225 | } |
224 | 226 | ||
225 | mailmime *Generatemail::buildTxtPart(const QString&str ) { | 227 | mailmime *Generatemail::buildTxtPart(const QString&str ) { |
226 | mailmime *txtPart; | 228 | mailmime *txtPart; |
227 | mailmime_fields *fields; | 229 | mailmime_fields *fields; |
228 | mailmime_content *content; | 230 | mailmime_content *content; |
229 | mailmime_parameter *param; | 231 | mailmime_parameter *param; |
230 | int err; | 232 | int err; |
231 | QCString __str; | 233 | Q3CString __str; |
232 | //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); | 234 | //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); |
233 | param = mailmime_parameter_new( strdup( "charset" ), | 235 | param = mailmime_parameter_new( strdup( "charset" ), |
234 | strdup( mCharset.latin1() ) ); | 236 | strdup( mCharset.latin1() ) ); |
235 | if ( param == NULL ) | 237 | if ( param == NULL ) |
236 | goto err_free; | 238 | goto err_free; |
237 | 239 | ||
238 | content = mailmime_content_new_with_str( "text/plain" ); | 240 | content = mailmime_content_new_with_str( "text/plain" ); |
239 | if ( content == NULL ) | 241 | if ( content == NULL ) |
240 | goto err_free_param; | 242 | goto err_free_param; |
241 | 243 | ||
242 | err = clist_append( content->ct_parameters, param ); | 244 | err = clist_append( content->ct_parameters, param ); |
243 | if ( err != MAILIMF_NO_ERROR ) | 245 | if ( err != MAILIMF_NO_ERROR ) |
244 | goto err_free_content; | 246 | goto err_free_content; |
245 | 247 | ||
246 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 248 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
247 | if ( fields == NULL ) | 249 | if ( fields == NULL ) |
248 | goto err_free_content; | 250 | goto err_free_content; |
249 | 251 | ||
250 | txtPart = mailmime_new_empty( content, fields ); | 252 | txtPart = mailmime_new_empty( content, fields ); |
251 | if ( txtPart == NULL ) | 253 | if ( txtPart == NULL ) |
252 | goto err_free_fields; | 254 | goto err_free_fields; |
253 | { | 255 | { |
254 | //__str = str.utf8(); | 256 | //__str = str.utf8(); |
255 | __str = QCString (str.latin1()); | 257 | __str = Q3CString (str.latin1()); |
256 | err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); | 258 | err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); |
257 | } | 259 | } |
258 | if ( err != MAILIMF_NO_ERROR ) | 260 | if ( err != MAILIMF_NO_ERROR ) |
259 | goto err_free_txtPart; | 261 | goto err_free_txtPart; |
260 | 262 | ||
261 | return txtPart; // Success :) | 263 | return txtPart; // Success :) |
262 | 264 | ||
263 | err_free_txtPart: | 265 | err_free_txtPart: |
264 | mailmime_free( txtPart ); | 266 | mailmime_free( txtPart ); |
265 | err_free_fields: | 267 | err_free_fields: |
266 | mailmime_fields_free( fields ); | 268 | mailmime_fields_free( fields ); |
267 | err_free_content: | 269 | err_free_content: |
268 | mailmime_content_free( content ); | 270 | mailmime_content_free( content ); |
269 | err_free_param: | 271 | err_free_param: |
270 | mailmime_parameter_free( param ); | 272 | mailmime_parameter_free( param ); |
271 | err_free: | 273 | err_free: |
272 | ; | 274 | ; |
273 | 275 | ||
274 | return NULL; // Error :( | 276 | return NULL; // Error :( |
275 | } | 277 | } |
276 | 278 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 279 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 280 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 281 | strdup( mail.latin1() ) ); |
280 | } | 282 | } |
281 | 283 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) | 284 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) |
283 | { | 285 | { |
284 | mailimf_fields *fields = NULL; | 286 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | 287 | mailimf_field *xmailer = NULL; |
286 | mailimf_mailbox *sender=0,*fromBox=0; | 288 | mailimf_mailbox *sender=0,*fromBox=0; |
287 | mailimf_mailbox_list *from=0; | 289 | mailimf_mailbox_list *from=0; |