Diffstat (limited to 'noncore/net/mail/libmailwrapper/generatemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/generatemail.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index 4f7ec0c..cb7ccc0 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -234,97 +234,97 @@ mailmime *Generatemail::buildTxtPart(const QString&str ) { | |||
234 | int err; | 234 | int err; |
235 | 235 | ||
236 | param = mailmime_parameter_new( strdup( "charset" ), | 236 | param = mailmime_parameter_new( strdup( "charset" ), |
237 | strdup( "iso-8859-1" ) ); | 237 | strdup( "iso-8859-1" ) ); |
238 | if ( param == NULL ) | 238 | if ( param == NULL ) |
239 | goto err_free; | 239 | goto err_free; |
240 | 240 | ||
241 | content = mailmime_content_new_with_str( "text/plain" ); | 241 | content = mailmime_content_new_with_str( "text/plain" ); |
242 | if ( content == NULL ) | 242 | if ( content == NULL ) |
243 | goto err_free_param; | 243 | goto err_free_param; |
244 | 244 | ||
245 | err = clist_append( content->ct_parameters, param ); | 245 | err = clist_append( content->ct_parameters, param ); |
246 | if ( err != MAILIMF_NO_ERROR ) | 246 | if ( err != MAILIMF_NO_ERROR ) |
247 | goto err_free_content; | 247 | goto err_free_content; |
248 | 248 | ||
249 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 249 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
250 | if ( fields == NULL ) | 250 | if ( fields == NULL ) |
251 | goto err_free_content; | 251 | goto err_free_content; |
252 | 252 | ||
253 | txtPart = mailmime_new_empty( content, fields ); | 253 | txtPart = mailmime_new_empty( content, fields ); |
254 | if ( txtPart == NULL ) | 254 | if ( txtPart == NULL ) |
255 | goto err_free_fields; | 255 | goto err_free_fields; |
256 | 256 | ||
257 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); | 257 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); |
258 | if ( err != MAILIMF_NO_ERROR ) | 258 | if ( err != MAILIMF_NO_ERROR ) |
259 | goto err_free_txtPart; | 259 | goto err_free_txtPart; |
260 | 260 | ||
261 | return txtPart; // Success :) | 261 | return txtPart; // Success :) |
262 | 262 | ||
263 | err_free_txtPart: | 263 | err_free_txtPart: |
264 | mailmime_free( txtPart ); | 264 | mailmime_free( txtPart ); |
265 | err_free_fields: | 265 | err_free_fields: |
266 | mailmime_fields_free( fields ); | 266 | mailmime_fields_free( fields ); |
267 | err_free_content: | 267 | err_free_content: |
268 | mailmime_content_free( content ); | 268 | mailmime_content_free( content ); |
269 | err_free_param: | 269 | err_free_param: |
270 | mailmime_parameter_free( param ); | 270 | mailmime_parameter_free( param ); |
271 | err_free: | 271 | err_free: |
272 | qDebug( "buildTxtPart - error" ); | 272 | qDebug( "buildTxtPart - error" ); |
273 | 273 | ||
274 | return NULL; // Error :( | 274 | return NULL; // Error :( |
275 | } | 275 | } |
276 | 276 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 278 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 279 | strdup( mail.latin1() ) ); |
280 | } | 280 | } |
281 | 281 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&mail ) | 282 | mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&mail ) |
283 | { | 283 | { |
284 | mailimf_fields *fields = NULL; | 284 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | 285 | mailimf_field *xmailer = NULL; |
286 | mailimf_mailbox *sender=0,*fromBox=0; | 286 | mailimf_mailbox *sender=0,*fromBox=0; |
287 | mailimf_mailbox_list *from=0; | 287 | mailimf_mailbox_list *from=0; |
288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
289 | clist*in_reply_to = 0; | 289 | clist*in_reply_to = 0; |
290 | char *subject = strdup( mail->getSubject().latin1() ); | 290 | char *subject = strdup( mail->getSubject().latin1() ); |
291 | int err; | 291 | int err; |
292 | int res = 1; | 292 | int res = 1; |
293 | 293 | ||
294 | sender = newMailbox( mail->getName(), mail->getMail() ); | 294 | sender = newMailbox( mail->getName(), mail->getMail() ); |
295 | if ( sender == NULL ) { | 295 | if ( sender == NULL ) { |
296 | res = 0; | 296 | res = 0; |
297 | } | 297 | } |
298 | 298 | ||
299 | if (res) { | 299 | if (res) { |
300 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 300 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
301 | } | 301 | } |
302 | if ( fromBox == NULL ) { | 302 | if ( fromBox == NULL ) { |
303 | res = 0; | 303 | res = 0; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (res) { | 306 | if (res) { |
307 | from = mailimf_mailbox_list_new_empty(); | 307 | from = mailimf_mailbox_list_new_empty(); |
308 | } | 308 | } |
309 | if ( from == NULL ) { | 309 | if ( from == NULL ) { |
310 | res = 0; | 310 | res = 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | if (res && from) { | 313 | if (res && from) { |
314 | err = mailimf_mailbox_list_add( from, fromBox ); | 314 | err = mailimf_mailbox_list_add( from, fromBox ); |
315 | if ( err != MAILIMF_NO_ERROR ) { | 315 | if ( err != MAILIMF_NO_ERROR ) { |
316 | res = 0; | 316 | res = 0; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | if (res) to = parseAddresses( mail->getTo() ); | 320 | if (res) to = parseAddresses( mail->getTo() ); |
321 | if (res) cc = parseAddresses( mail->getCC() ); | 321 | if (res) cc = parseAddresses( mail->getCC() ); |
322 | if (res) bcc = parseAddresses( mail->getBCC() ); | 322 | if (res) bcc = parseAddresses( mail->getBCC() ); |
323 | if (res) reply = parseAddresses( mail->getReply() ); | 323 | if (res) reply = parseAddresses( mail->getReply() ); |
324 | 324 | ||
325 | if (res && mail->Inreply().count()>0) { | 325 | if (res && mail->Inreply().count()>0) { |
326 | in_reply_to = clist_new(); | 326 | in_reply_to = clist_new(); |
327 | char*c_reply; | 327 | char*c_reply; |
328 | unsigned int nsize = 0; | 328 | unsigned int nsize = 0; |
329 | for (QStringList::ConstIterator it=mail->Inreply().begin(); | 329 | for (QStringList::ConstIterator it=mail->Inreply().begin(); |
330 | it != mail->Inreply().end();++it) { | 330 | it != mail->Inreply().end();++it) { |
@@ -354,97 +354,97 @@ mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&m | |||
354 | if ( fields == NULL ) { | 354 | if ( fields == NULL ) { |
355 | qDebug("Error creating mailimf fields"); | 355 | qDebug("Error creating mailimf fields"); |
356 | res = 0; | 356 | res = 0; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 359 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
360 | strdup( USER_AGENT ) ); | 360 | strdup( USER_AGENT ) ); |
361 | if ( xmailer == NULL ) { | 361 | if ( xmailer == NULL ) { |
362 | res = 0; | 362 | res = 0; |
363 | } else { | 363 | } else { |
364 | err = mailimf_fields_add( fields, xmailer ); | 364 | err = mailimf_fields_add( fields, xmailer ); |
365 | if ( err != MAILIMF_NO_ERROR ) { | 365 | if ( err != MAILIMF_NO_ERROR ) { |
366 | res = 0; | 366 | res = 0; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | if (!res ) { | 369 | if (!res ) { |
370 | if (xmailer) { | 370 | if (xmailer) { |
371 | mailimf_field_free( xmailer ); | 371 | mailimf_field_free( xmailer ); |
372 | xmailer = NULL; | 372 | xmailer = NULL; |
373 | } | 373 | } |
374 | if (fields) { | 374 | if (fields) { |
375 | mailimf_fields_free( fields ); | 375 | mailimf_fields_free( fields ); |
376 | fields = NULL; | 376 | fields = NULL; |
377 | } else { | 377 | } else { |
378 | if (reply) | 378 | if (reply) |
379 | mailimf_address_list_free( reply ); | 379 | mailimf_address_list_free( reply ); |
380 | if (bcc) | 380 | if (bcc) |
381 | mailimf_address_list_free( bcc ); | 381 | mailimf_address_list_free( bcc ); |
382 | if (cc) | 382 | if (cc) |
383 | mailimf_address_list_free( cc ); | 383 | mailimf_address_list_free( cc ); |
384 | if (to) | 384 | if (to) |
385 | mailimf_address_list_free( to ); | 385 | mailimf_address_list_free( to ); |
386 | if (fromBox) { | 386 | if (fromBox) { |
387 | mailimf_mailbox_free( fromBox ); | 387 | mailimf_mailbox_free( fromBox ); |
388 | } else if (from) { | 388 | } else if (from) { |
389 | mailimf_mailbox_list_free( from ); | 389 | mailimf_mailbox_list_free( from ); |
390 | } | 390 | } |
391 | if (sender) { | 391 | if (sender) { |
392 | mailimf_mailbox_free( sender ); | 392 | mailimf_mailbox_free( sender ); |
393 | } | 393 | } |
394 | if (subject) { | 394 | if (subject) { |
395 | free( subject ); | 395 | free( subject ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | return fields; | 399 | return fields; |
400 | } | 400 | } |
401 | 401 | ||
402 | mailmime *Generatemail::createMimeMail(const Opie::osmart_pointer<Mail> &mail ) { | 402 | mailmime *Generatemail::createMimeMail(const Opie::OSmartPointer<Mail> &mail ) { |
403 | mailmime *message, *txtPart; | 403 | mailmime *message, *txtPart; |
404 | mailimf_fields *fields; | 404 | mailimf_fields *fields; |
405 | int err; | 405 | int err; |
406 | 406 | ||
407 | fields = createImfFields( mail ); | 407 | fields = createImfFields( mail ); |
408 | if ( fields == NULL ) | 408 | if ( fields == NULL ) |
409 | goto err_free; | 409 | goto err_free; |
410 | 410 | ||
411 | message = mailmime_new_message_data( NULL ); | 411 | message = mailmime_new_message_data( NULL ); |
412 | if ( message == NULL ) | 412 | if ( message == NULL ) |
413 | goto err_free_fields; | 413 | goto err_free_fields; |
414 | 414 | ||
415 | mailmime_set_imf_fields( message, fields ); | 415 | mailmime_set_imf_fields( message, fields ); |
416 | 416 | ||
417 | txtPart = buildTxtPart( mail->getMessage() ); | 417 | txtPart = buildTxtPart( mail->getMessage() ); |
418 | 418 | ||
419 | if ( txtPart == NULL ) | 419 | if ( txtPart == NULL ) |
420 | goto err_free_message; | 420 | goto err_free_message; |
421 | 421 | ||
422 | err = mailmime_smart_add_part( message, txtPart ); | 422 | err = mailmime_smart_add_part( message, txtPart ); |
423 | if ( err != MAILIMF_NO_ERROR ) | 423 | if ( err != MAILIMF_NO_ERROR ) |
424 | goto err_free_txtPart; | 424 | goto err_free_txtPart; |
425 | 425 | ||
426 | addFileParts( message, mail->getAttachments() ); | 426 | addFileParts( message, mail->getAttachments() ); |
427 | 427 | ||
428 | return message; // Success :) | 428 | return message; // Success :) |
429 | 429 | ||
430 | err_free_txtPart: | 430 | err_free_txtPart: |
431 | mailmime_free( txtPart ); | 431 | mailmime_free( txtPart ); |
432 | err_free_message: | 432 | err_free_message: |
433 | mailmime_free( message ); | 433 | mailmime_free( message ); |
434 | err_free_fields: | 434 | err_free_fields: |
435 | mailimf_fields_free( fields ); | 435 | mailimf_fields_free( fields ); |
436 | err_free: | 436 | err_free: |
437 | qDebug( "createMimeMail: error" ); | 437 | qDebug( "createMimeMail: error" ); |
438 | 438 | ||
439 | return NULL; // Error :( | 439 | return NULL; // Error :( |
440 | } | 440 | } |
441 | 441 | ||
442 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { | 442 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { |
443 | clist *rcptList; | 443 | clist *rcptList; |
444 | mailimf_field *field; | 444 | mailimf_field *field; |
445 | 445 | ||
446 | rcptList = esmtp_address_list_new(); | 446 | rcptList = esmtp_address_list_new(); |
447 | 447 | ||
448 | field = getField( fields, MAILIMF_FIELD_TO ); | 448 | field = getField( fields, MAILIMF_FIELD_TO ); |
449 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 449 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |
450 | && field->fld_data.fld_to->to_addr_list ) { | 450 | && field->fld_data.fld_to->to_addr_list ) { |