author | harlekin <harlekin> | 2003-12-08 16:57:54 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-08 16:57:54 (UTC) |
commit | 57bc0542cae3d106194c9318612fde304e8acfa7 (patch) (unidiff) | |
tree | e0cb233b51302ad2401534ee221cd16fc99d4817 /noncore | |
parent | e7b8b190e8c3081d20e33c512224f9a5b5baa20c (diff) | |
download | opie-57bc0542cae3d106194c9318612fde304e8acfa7.zip opie-57bc0542cae3d106194c9318612fde304e8acfa7.tar.gz opie-57bc0542cae3d106194c9318612fde304e8acfa7.tar.bz2 |
no idea how to comment that change
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 156 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 12 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 1 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 156 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 12 |
5 files changed, 168 insertions, 169 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 17bed65..13a3fd9 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -12,3 +12,3 @@ | |||
12 | #include "logindialog.h" | 12 | #include "logindialog.h" |
13 | #include "mail.h" | 13 | //#include "mail.h" |
14 | #include "defines.h" | 14 | #include "defines.h" |
@@ -16,5 +16,5 @@ | |||
16 | Attachment::Attachment( DocLnk lnk ) | 16 | Attachment::Attachment( DocLnk lnk ) |
17 | { | 17 | { |
18 | doc = lnk; | 18 | doc = lnk; |
19 | size = QFileInfo( doc.file() ).size(); | 19 | size = QFileInfo( doc.file() ).size(); |
20 | } | 20 | } |
@@ -25,4 +25,4 @@ Folder::Folder(const QString&tmp_name ) | |||
25 | nameDisplay = name; | 25 | nameDisplay = name; |
26 | 26 | ||
27 | for ( int pos = nameDisplay.find( '&' ); pos != -1; | 27 | for ( int pos = nameDisplay.find( '&' ); pos != -1; |
28 | pos = nameDisplay.find( '&' ) ) { | 28 | pos = nameDisplay.find( '&' ) ) { |
@@ -34,3 +34,3 @@ Folder::Folder(const QString&tmp_name ) | |||
34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); | 34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); |
35 | } else if ( str64.compare( "APY" ) == 0 ) { | 35 | } else if ( str64.compare( "APY" ) == 0 ) { |
36 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); | 36 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); |
@@ -92,3 +92,3 @@ mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail | |||
92 | { | 92 | { |
93 | return mailimf_mailbox_new( strdup( name.latin1() ), | 93 | return mailimf_mailbox_new( strdup( name.latin1() ), |
94 | strdup( mail.latin1() ) ); | 94 | strdup( mail.latin1() ) ); |
@@ -99,7 +99,7 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | |||
99 | mailimf_address_list *addresses; | 99 | mailimf_address_list *addresses; |
100 | 100 | ||
101 | if ( addr.isEmpty() ) return NULL; | 101 | if ( addr.isEmpty() ) return NULL; |
102 | 102 | ||
103 | addresses = mailimf_address_list_new_empty(); | 103 | addresses = mailimf_address_list_new_empty(); |
104 | 104 | ||
105 | QStringList list = QStringList::split( ',', addr ); | 105 | QStringList list = QStringList::split( ',', addr ); |
@@ -117,3 +117,3 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | return addresses; | 119 | return addresses; |
@@ -130,15 +130,15 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
130 | int err; | 130 | int err; |
131 | 131 | ||
132 | sender = newMailbox( mail->getName(), mail->getMail() ); | 132 | sender = newMailbox( mail->getName(), mail->getMail() ); |
133 | if ( sender == NULL ) goto err_free; | 133 | if ( sender == NULL ) goto err_free; |
134 | 134 | ||
135 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 135 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
136 | if ( fromBox == NULL ) goto err_free_sender; | 136 | if ( fromBox == NULL ) goto err_free_sender; |
137 | 137 | ||
138 | from = mailimf_mailbox_list_new_empty(); | 138 | from = mailimf_mailbox_list_new_empty(); |
139 | if ( from == NULL ) goto err_free_fromBox; | 139 | if ( from == NULL ) goto err_free_fromBox; |
140 | 140 | ||
141 | err = mailimf_mailbox_list_add( from, fromBox ); | 141 | err = mailimf_mailbox_list_add( from, fromBox ); |
142 | if ( err != MAILIMF_NO_ERROR ) goto err_free_from; | 142 | if ( err != MAILIMF_NO_ERROR ) goto err_free_from; |
143 | 143 | ||
144 | to = parseAddresses( mail->getTo() ); | 144 | to = parseAddresses( mail->getTo() ); |
@@ -153,3 +153,3 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
153 | if ( fields == NULL ) goto err_free_reply; | 153 | if ( fields == NULL ) goto err_free_reply; |
154 | 154 | ||
155 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 155 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
@@ -157,6 +157,6 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
157 | if ( xmailer == NULL ) goto err_free_fields; | 157 | if ( xmailer == NULL ) goto err_free_fields; |
158 | 158 | ||
159 | err = mailimf_fields_add( fields, xmailer ); | 159 | err = mailimf_fields_add( fields, xmailer ); |
160 | if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; | 160 | if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; |
161 | 161 | ||
162 | return fields; // Success :) | 162 | return fields; // Success :) |
@@ -193,19 +193,19 @@ mailmime *MailWrapper::buildTxtPart( QString str ) | |||
193 | int err; | 193 | int err; |
194 | 194 | ||
195 | param = mailmime_parameter_new( strdup( "charset" ), | 195 | param = mailmime_parameter_new( strdup( "charset" ), |
196 | strdup( "iso-8859-1" ) ); | 196 | strdup( "iso-8859-1" ) ); |
197 | if ( param == NULL ) goto err_free; | 197 | if ( param == NULL ) goto err_free; |
198 | 198 | ||
199 | content = mailmime_content_new_with_str( "text/plain" ); | 199 | content = mailmime_content_new_with_str( "text/plain" ); |
200 | if ( content == NULL ) goto err_free_param; | 200 | if ( content == NULL ) goto err_free_param; |
201 | 201 | ||
202 | err = clist_append( content->parameters, param ); | 202 | err = clist_append( content->parameters, param ); |
203 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; | 203 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; |
204 | 204 | ||
205 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); | 205 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); |
206 | if ( fields == NULL ) goto err_free_content; | 206 | if ( fields == NULL ) goto err_free_content; |
207 | 207 | ||
208 | txtPart = mailmime_new_empty( content, fields ); | 208 | txtPart = mailmime_new_empty( content, fields ); |
209 | if ( txtPart == NULL ) goto err_free_fields; | 209 | if ( txtPart == NULL ) goto err_free_fields; |
210 | 210 | ||
211 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); | 211 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); |
@@ -216,3 +216,3 @@ mailmime *MailWrapper::buildTxtPart( QString str ) | |||
216 | err_free_txtPart: | 216 | err_free_txtPart: |
217 | mailmime_free( txtPart ); | 217 | mailmime_free( txtPart ); |
218 | err_free_fields: | 218 | err_free_fields: |
@@ -220,3 +220,3 @@ err_free_fields: | |||
220 | err_free_content: | 220 | err_free_content: |
221 | mailmime_content_free( content ); | 221 | mailmime_content_free( content ); |
222 | err_free_param: | 222 | err_free_param: |
@@ -226,3 +226,3 @@ err_free: | |||
226 | qDebug( "buildTxtPart - error" ); | 226 | qDebug( "buildTxtPart - error" ); |
227 | 227 | ||
228 | return NULL; // Error :( | 228 | return NULL; // Error :( |
@@ -237,3 +237,3 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
237 | int err; | 237 | int err; |
238 | 238 | ||
239 | int pos = filename.findRev( '/' ); | 239 | int pos = filename.findRev( '/' ); |
@@ -243,16 +243,16 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
243 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain | 243 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain |
244 | 244 | ||
245 | fields = mailmime_fields_new_filename( | 245 | fields = mailmime_fields_new_filename( |
246 | MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, | 246 | MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, |
247 | MAILMIME_MECHANISM_BASE64 ); | 247 | MAILMIME_MECHANISM_BASE64 ); |
248 | if ( fields == NULL ) goto err_free; | 248 | if ( fields == NULL ) goto err_free; |
249 | 249 | ||
250 | content = mailmime_content_new_with_str( mime ); | 250 | content = mailmime_content_new_with_str( mime ); |
251 | if ( content == NULL ) goto err_free_fields; | 251 | if ( content == NULL ) goto err_free_fields; |
252 | 252 | ||
253 | if ( mimetype.compare( "text/plain" ) == 0 ) { | 253 | if ( mimetype.compare( "text/plain" ) == 0 ) { |
254 | param = mailmime_parameter_new( strdup( "charset" ), | 254 | param = mailmime_parameter_new( strdup( "charset" ), |
255 | strdup( "iso-8859-1" ) ); | 255 | strdup( "iso-8859-1" ) ); |
256 | if ( param == NULL ) goto err_free_content; | 256 | if ( param == NULL ) goto err_free_content; |
257 | 257 | ||
258 | err = clist_append( content->parameters, param ); | 258 | err = clist_append( content->parameters, param ); |
@@ -260,9 +260,9 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
260 | } | 260 | } |
261 | 261 | ||
262 | filePart = mailmime_new_empty( content, fields ); | 262 | filePart = mailmime_new_empty( content, fields ); |
263 | if ( filePart == NULL ) goto err_free_param; | 263 | if ( filePart == NULL ) goto err_free_param; |
264 | 264 | ||
265 | err = mailmime_set_body_file( filePart, file ); | 265 | err = mailmime_set_body_file( filePart, file ); |
266 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; | 266 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; |
267 | 267 | ||
268 | return filePart; // Success :) | 268 | return filePart; // Success :) |
@@ -282,3 +282,3 @@ err_free: | |||
282 | qDebug( "buildFilePart - error" ); | 282 | qDebug( "buildFilePart - error" ); |
283 | 283 | ||
284 | return NULL; // Error :( | 284 | return NULL; // Error :( |
@@ -291,3 +291,3 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) | |||
291 | qDebug( "Adding file" ); | 291 | qDebug( "Adding file" ); |
292 | mailmime *filePart; | 292 | mailmime *filePart; |
293 | int err; | 293 | int err; |
@@ -296,8 +296,8 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) | |||
296 | if ( filePart == NULL ) goto err_free; | 296 | if ( filePart == NULL ) goto err_free; |
297 | 297 | ||
298 | err = mailmime_smart_add_part( message, filePart ); | 298 | err = mailmime_smart_add_part( message, filePart ); |
299 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; | 299 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; |
300 | 300 | ||
301 | continue; // Success :) | 301 | continue; // Success :) |
302 | 302 | ||
303 | err_free_filePart: | 303 | err_free_filePart: |
@@ -318,6 +318,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) | |||
318 | if ( fields == NULL ) goto err_free; | 318 | if ( fields == NULL ) goto err_free; |
319 | 319 | ||
320 | message = mailmime_new_message_data( NULL ); | 320 | message = mailmime_new_message_data( NULL ); |
321 | if ( message == NULL ) goto err_free_fields; | 321 | if ( message == NULL ) goto err_free_fields; |
322 | 322 | ||
323 | mailmime_set_imf_fields( message, fields ); | 323 | mailmime_set_imf_fields( message, fields ); |
@@ -326,6 +326,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) | |||
326 | if ( txtPart == NULL ) goto err_free_message; | 326 | if ( txtPart == NULL ) goto err_free_message; |
327 | 327 | ||
328 | err = mailmime_smart_add_part( message, txtPart ); | 328 | err = mailmime_smart_add_part( message, txtPart ); |
329 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 329 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
330 | 330 | ||
331 | addFileParts( message, mail->getAttachments() ); | 331 | addFileParts( message, mail->getAttachments() ); |
@@ -359,3 +359,3 @@ mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) | |||
359 | } | 359 | } |
360 | 360 | ||
361 | return NULL; | 361 | return NULL; |
@@ -366,3 +366,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) | |||
366 | clistiter *it, *it2; | 366 | clistiter *it, *it2; |
367 | 367 | ||
368 | for ( it = clist_begin( addr_list->list ); it; it = it->next ) { | 368 | for ( it = clist_begin( addr_list->list ); it; it = it->next ) { |
@@ -370,3 +370,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) | |||
370 | addr = (mailimf_address *) it->data; | 370 | addr = (mailimf_address *) it->data; |
371 | 371 | ||
372 | if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { | 372 | if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { |
@@ -390,5 +390,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
390 | rcptList = esmtp_address_list_new(); | 390 | rcptList = esmtp_address_list_new(); |
391 | 391 | ||
392 | field = getField( fields, MAILIMF_FIELD_TO ); | 392 | field = getField( fields, MAILIMF_FIELD_TO ); |
393 | if ( field && (field->type == MAILIMF_FIELD_TO) | 393 | if ( field && (field->type == MAILIMF_FIELD_TO) |
394 | && field->field.to->addr_list ) { | 394 | && field->field.to->addr_list ) { |
@@ -396,3 +396,3 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | field = getField( fields, MAILIMF_FIELD_CC ); | 398 | field = getField( fields, MAILIMF_FIELD_CC ); |
@@ -402,5 +402,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
402 | } | 402 | } |
403 | 403 | ||
404 | field = getField( fields, MAILIMF_FIELD_BCC ); | 404 | field = getField( fields, MAILIMF_FIELD_BCC ); |
405 | if ( field && (field->type == MAILIMF_FIELD_BCC) | 405 | if ( field && (field->type == MAILIMF_FIELD_BCC) |
406 | && field->field.bcc->addr_list ) { | 406 | && field->field.bcc->addr_list ) { |
@@ -418,3 +418,3 @@ char *MailWrapper::getFrom( mailmime *mail ) | |||
418 | ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); | 418 | ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); |
419 | if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) | 419 | if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) |
420 | && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { | 420 | && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { |
@@ -428,3 +428,3 @@ char *MailWrapper::getFrom( mailmime *mail ) | |||
428 | 428 | ||
429 | return from; | 429 | return from; |
430 | } | 430 | } |
@@ -434,3 +434,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) | |||
434 | SMTPaccount *smtp; | 434 | SMTPaccount *smtp; |
435 | 435 | ||
436 | QList<Account> list = settings->getAccounts(); | 436 | QList<Account> list = settings->getAccounts(); |
@@ -447,3 +447,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) | |||
447 | } | 447 | } |
448 | 448 | ||
449 | return NULL; | 449 | return NULL; |
@@ -454,3 +454,3 @@ QString MailWrapper::getTmpFile() { | |||
454 | QString unique; | 454 | QString unique; |
455 | 455 | ||
456 | QDir dir( "/tmp" ); | 456 | QDir dir( "/tmp" ); |
@@ -462,3 +462,3 @@ QString MailWrapper::getTmpFile() { | |||
462 | } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); | 462 | } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); |
463 | 463 | ||
464 | return "/tmp/opiemail-tmp-" + unique; | 464 | return "/tmp/opiemail-tmp-" + unique; |
@@ -492,9 +492,9 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
492 | int fd, count = 0, total = 0; | 492 | int fd, count = 0, total = 0; |
493 | 493 | ||
494 | fd = open( file.latin1(), O_RDONLY, 0 ); | 494 | fd = open( file.latin1(), O_RDONLY, 0 ); |
495 | if ( fd == -1 ) return; | 495 | if ( fd == -1 ) return; |
496 | 496 | ||
497 | if ( fstat( fd, &st ) != 0 ) goto err_close; | 497 | if ( fstat( fd, &st ) != 0 ) goto err_close; |
498 | if ( !st.st_size ) goto err_close; | 498 | if ( !st.st_size ) goto err_close; |
499 | 499 | ||
500 | buf = (char *) malloc( st.st_size ); | 500 | buf = (char *) malloc( st.st_size ); |
@@ -510,3 +510,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
510 | *size = st.st_size; | 510 | *size = st.st_size; |
511 | 511 | ||
512 | close( fd ); | 512 | close( fd ); |
@@ -514,3 +514,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
514 | return; // Success :) | 514 | return; // Success :) |
515 | 515 | ||
516 | err_free: | 516 | err_free: |
@@ -535,3 +535,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
535 | uint16_t port; | 535 | uint16_t port; |
536 | 536 | ||
537 | 537 | ||
@@ -553,5 +553,5 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
553 | f.remove(); | 553 | f.remove(); |
554 | 554 | ||
555 | session = mailsmtp_new( 20, &progress ); | 555 | session = mailsmtp_new( 20, &progress ); |
556 | if ( session == NULL ) goto free_mem; | 556 | if ( session == NULL ) goto free_mem; |
557 | 557 | ||
@@ -569,5 +569,5 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
569 | if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; | 569 | if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; |
570 | 570 | ||
571 | qDebug( "INIT OK" ); | 571 | qDebug( "INIT OK" ); |
572 | 572 | ||
573 | if ( smtp->getLogin() ) { | 573 | if ( smtp->getLogin() ) { |
@@ -593,3 +593,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
593 | } | 593 | } |
594 | 594 | ||
595 | err = mailsmtp_send( session, from, rcpts, data, size ); | 595 | err = mailsmtp_send( session, from, rcpts, data, size ); |
@@ -598,3 +598,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
598 | qDebug( "Mail sent." ); | 598 | qDebug( "Mail sent." ); |
599 | 599 | ||
600 | free_con_session: | 600 | free_con_session: |
@@ -624,3 +624,3 @@ void MailWrapper::sendMail( Mail mail ) | |||
624 | mailmime_free( mimeMail ); | 624 | mailmime_free( mimeMail ); |
625 | } | 625 | } |
626 | } | 626 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 3de28a0..f45eab7 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -5,8 +5,8 @@ | |||
5 | 5 | ||
6 | #include <mailmime.h> | 6 | #include <libetpan/mailmime.h> |
7 | #include <mailimf.h> | 7 | #include <libetpan/mailimf.h> |
8 | #include <mailsmtp.h> | 8 | #include <libetpan/mailsmtp.h> |
9 | #include <mailimap.h> | 9 | #include <libetpan/mailimap.h> |
10 | #include <mailstorage.h> | 10 | #include <libetpan/mailstorage.h> |
11 | #include <maildriver.h> | 11 | #include <libetpan/maildriver.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index c913826..46a476d 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -35,3 +35,2 @@ INTERFACES = editaccountsui.ui \ | |||
35 | INCLUDEPATH += $(OPIEDIR)/include | 35 | INCLUDEPATH += $(OPIEDIR)/include |
36 | INCLUDEPATH += $(OPIEDIR)/include/libetpan | ||
37 | LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb | 36 | LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb |
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 17bed65..13a3fd9 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp | |||
@@ -12,3 +12,3 @@ | |||
12 | #include "logindialog.h" | 12 | #include "logindialog.h" |
13 | #include "mail.h" | 13 | //#include "mail.h" |
14 | #include "defines.h" | 14 | #include "defines.h" |
@@ -16,5 +16,5 @@ | |||
16 | Attachment::Attachment( DocLnk lnk ) | 16 | Attachment::Attachment( DocLnk lnk ) |
17 | { | 17 | { |
18 | doc = lnk; | 18 | doc = lnk; |
19 | size = QFileInfo( doc.file() ).size(); | 19 | size = QFileInfo( doc.file() ).size(); |
20 | } | 20 | } |
@@ -25,4 +25,4 @@ Folder::Folder(const QString&tmp_name ) | |||
25 | nameDisplay = name; | 25 | nameDisplay = name; |
26 | 26 | ||
27 | for ( int pos = nameDisplay.find( '&' ); pos != -1; | 27 | for ( int pos = nameDisplay.find( '&' ); pos != -1; |
28 | pos = nameDisplay.find( '&' ) ) { | 28 | pos = nameDisplay.find( '&' ) ) { |
@@ -34,3 +34,3 @@ Folder::Folder(const QString&tmp_name ) | |||
34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); | 34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); |
35 | } else if ( str64.compare( "APY" ) == 0 ) { | 35 | } else if ( str64.compare( "APY" ) == 0 ) { |
36 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); | 36 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); |
@@ -92,3 +92,3 @@ mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail | |||
92 | { | 92 | { |
93 | return mailimf_mailbox_new( strdup( name.latin1() ), | 93 | return mailimf_mailbox_new( strdup( name.latin1() ), |
94 | strdup( mail.latin1() ) ); | 94 | strdup( mail.latin1() ) ); |
@@ -99,7 +99,7 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | |||
99 | mailimf_address_list *addresses; | 99 | mailimf_address_list *addresses; |
100 | 100 | ||
101 | if ( addr.isEmpty() ) return NULL; | 101 | if ( addr.isEmpty() ) return NULL; |
102 | 102 | ||
103 | addresses = mailimf_address_list_new_empty(); | 103 | addresses = mailimf_address_list_new_empty(); |
104 | 104 | ||
105 | QStringList list = QStringList::split( ',', addr ); | 105 | QStringList list = QStringList::split( ',', addr ); |
@@ -117,3 +117,3 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | return addresses; | 119 | return addresses; |
@@ -130,15 +130,15 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
130 | int err; | 130 | int err; |
131 | 131 | ||
132 | sender = newMailbox( mail->getName(), mail->getMail() ); | 132 | sender = newMailbox( mail->getName(), mail->getMail() ); |
133 | if ( sender == NULL ) goto err_free; | 133 | if ( sender == NULL ) goto err_free; |
134 | 134 | ||
135 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 135 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
136 | if ( fromBox == NULL ) goto err_free_sender; | 136 | if ( fromBox == NULL ) goto err_free_sender; |
137 | 137 | ||
138 | from = mailimf_mailbox_list_new_empty(); | 138 | from = mailimf_mailbox_list_new_empty(); |
139 | if ( from == NULL ) goto err_free_fromBox; | 139 | if ( from == NULL ) goto err_free_fromBox; |
140 | 140 | ||
141 | err = mailimf_mailbox_list_add( from, fromBox ); | 141 | err = mailimf_mailbox_list_add( from, fromBox ); |
142 | if ( err != MAILIMF_NO_ERROR ) goto err_free_from; | 142 | if ( err != MAILIMF_NO_ERROR ) goto err_free_from; |
143 | 143 | ||
144 | to = parseAddresses( mail->getTo() ); | 144 | to = parseAddresses( mail->getTo() ); |
@@ -153,3 +153,3 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
153 | if ( fields == NULL ) goto err_free_reply; | 153 | if ( fields == NULL ) goto err_free_reply; |
154 | 154 | ||
155 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 155 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
@@ -157,6 +157,6 @@ mailimf_fields *MailWrapper::createImfFields( Mail *mail ) | |||
157 | if ( xmailer == NULL ) goto err_free_fields; | 157 | if ( xmailer == NULL ) goto err_free_fields; |
158 | 158 | ||
159 | err = mailimf_fields_add( fields, xmailer ); | 159 | err = mailimf_fields_add( fields, xmailer ); |
160 | if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; | 160 | if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; |
161 | 161 | ||
162 | return fields; // Success :) | 162 | return fields; // Success :) |
@@ -193,19 +193,19 @@ mailmime *MailWrapper::buildTxtPart( QString str ) | |||
193 | int err; | 193 | int err; |
194 | 194 | ||
195 | param = mailmime_parameter_new( strdup( "charset" ), | 195 | param = mailmime_parameter_new( strdup( "charset" ), |
196 | strdup( "iso-8859-1" ) ); | 196 | strdup( "iso-8859-1" ) ); |
197 | if ( param == NULL ) goto err_free; | 197 | if ( param == NULL ) goto err_free; |
198 | 198 | ||
199 | content = mailmime_content_new_with_str( "text/plain" ); | 199 | content = mailmime_content_new_with_str( "text/plain" ); |
200 | if ( content == NULL ) goto err_free_param; | 200 | if ( content == NULL ) goto err_free_param; |
201 | 201 | ||
202 | err = clist_append( content->parameters, param ); | 202 | err = clist_append( content->parameters, param ); |
203 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; | 203 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; |
204 | 204 | ||
205 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); | 205 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); |
206 | if ( fields == NULL ) goto err_free_content; | 206 | if ( fields == NULL ) goto err_free_content; |
207 | 207 | ||
208 | txtPart = mailmime_new_empty( content, fields ); | 208 | txtPart = mailmime_new_empty( content, fields ); |
209 | if ( txtPart == NULL ) goto err_free_fields; | 209 | if ( txtPart == NULL ) goto err_free_fields; |
210 | 210 | ||
211 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); | 211 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); |
@@ -216,3 +216,3 @@ mailmime *MailWrapper::buildTxtPart( QString str ) | |||
216 | err_free_txtPart: | 216 | err_free_txtPart: |
217 | mailmime_free( txtPart ); | 217 | mailmime_free( txtPart ); |
218 | err_free_fields: | 218 | err_free_fields: |
@@ -220,3 +220,3 @@ err_free_fields: | |||
220 | err_free_content: | 220 | err_free_content: |
221 | mailmime_content_free( content ); | 221 | mailmime_content_free( content ); |
222 | err_free_param: | 222 | err_free_param: |
@@ -226,3 +226,3 @@ err_free: | |||
226 | qDebug( "buildTxtPart - error" ); | 226 | qDebug( "buildTxtPart - error" ); |
227 | 227 | ||
228 | return NULL; // Error :( | 228 | return NULL; // Error :( |
@@ -237,3 +237,3 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
237 | int err; | 237 | int err; |
238 | 238 | ||
239 | int pos = filename.findRev( '/' ); | 239 | int pos = filename.findRev( '/' ); |
@@ -243,16 +243,16 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
243 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain | 243 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain |
244 | 244 | ||
245 | fields = mailmime_fields_new_filename( | 245 | fields = mailmime_fields_new_filename( |
246 | MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, | 246 | MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, |
247 | MAILMIME_MECHANISM_BASE64 ); | 247 | MAILMIME_MECHANISM_BASE64 ); |
248 | if ( fields == NULL ) goto err_free; | 248 | if ( fields == NULL ) goto err_free; |
249 | 249 | ||
250 | content = mailmime_content_new_with_str( mime ); | 250 | content = mailmime_content_new_with_str( mime ); |
251 | if ( content == NULL ) goto err_free_fields; | 251 | if ( content == NULL ) goto err_free_fields; |
252 | 252 | ||
253 | if ( mimetype.compare( "text/plain" ) == 0 ) { | 253 | if ( mimetype.compare( "text/plain" ) == 0 ) { |
254 | param = mailmime_parameter_new( strdup( "charset" ), | 254 | param = mailmime_parameter_new( strdup( "charset" ), |
255 | strdup( "iso-8859-1" ) ); | 255 | strdup( "iso-8859-1" ) ); |
256 | if ( param == NULL ) goto err_free_content; | 256 | if ( param == NULL ) goto err_free_content; |
257 | 257 | ||
258 | err = clist_append( content->parameters, param ); | 258 | err = clist_append( content->parameters, param ); |
@@ -260,9 +260,9 @@ mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) | |||
260 | } | 260 | } |
261 | 261 | ||
262 | filePart = mailmime_new_empty( content, fields ); | 262 | filePart = mailmime_new_empty( content, fields ); |
263 | if ( filePart == NULL ) goto err_free_param; | 263 | if ( filePart == NULL ) goto err_free_param; |
264 | 264 | ||
265 | err = mailmime_set_body_file( filePart, file ); | 265 | err = mailmime_set_body_file( filePart, file ); |
266 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; | 266 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; |
267 | 267 | ||
268 | return filePart; // Success :) | 268 | return filePart; // Success :) |
@@ -282,3 +282,3 @@ err_free: | |||
282 | qDebug( "buildFilePart - error" ); | 282 | qDebug( "buildFilePart - error" ); |
283 | 283 | ||
284 | return NULL; // Error :( | 284 | return NULL; // Error :( |
@@ -291,3 +291,3 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) | |||
291 | qDebug( "Adding file" ); | 291 | qDebug( "Adding file" ); |
292 | mailmime *filePart; | 292 | mailmime *filePart; |
293 | int err; | 293 | int err; |
@@ -296,8 +296,8 @@ void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) | |||
296 | if ( filePart == NULL ) goto err_free; | 296 | if ( filePart == NULL ) goto err_free; |
297 | 297 | ||
298 | err = mailmime_smart_add_part( message, filePart ); | 298 | err = mailmime_smart_add_part( message, filePart ); |
299 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; | 299 | if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; |
300 | 300 | ||
301 | continue; // Success :) | 301 | continue; // Success :) |
302 | 302 | ||
303 | err_free_filePart: | 303 | err_free_filePart: |
@@ -318,6 +318,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) | |||
318 | if ( fields == NULL ) goto err_free; | 318 | if ( fields == NULL ) goto err_free; |
319 | 319 | ||
320 | message = mailmime_new_message_data( NULL ); | 320 | message = mailmime_new_message_data( NULL ); |
321 | if ( message == NULL ) goto err_free_fields; | 321 | if ( message == NULL ) goto err_free_fields; |
322 | 322 | ||
323 | mailmime_set_imf_fields( message, fields ); | 323 | mailmime_set_imf_fields( message, fields ); |
@@ -326,6 +326,6 @@ mailmime *MailWrapper::createMimeMail( Mail *mail ) | |||
326 | if ( txtPart == NULL ) goto err_free_message; | 326 | if ( txtPart == NULL ) goto err_free_message; |
327 | 327 | ||
328 | err = mailmime_smart_add_part( message, txtPart ); | 328 | err = mailmime_smart_add_part( message, txtPart ); |
329 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 329 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
330 | 330 | ||
331 | addFileParts( message, mail->getAttachments() ); | 331 | addFileParts( message, mail->getAttachments() ); |
@@ -359,3 +359,3 @@ mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) | |||
359 | } | 359 | } |
360 | 360 | ||
361 | return NULL; | 361 | return NULL; |
@@ -366,3 +366,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) | |||
366 | clistiter *it, *it2; | 366 | clistiter *it, *it2; |
367 | 367 | ||
368 | for ( it = clist_begin( addr_list->list ); it; it = it->next ) { | 368 | for ( it = clist_begin( addr_list->list ); it; it = it->next ) { |
@@ -370,3 +370,3 @@ static void addRcpts( clist *list, mailimf_address_list *addr_list ) | |||
370 | addr = (mailimf_address *) it->data; | 370 | addr = (mailimf_address *) it->data; |
371 | 371 | ||
372 | if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { | 372 | if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { |
@@ -390,5 +390,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
390 | rcptList = esmtp_address_list_new(); | 390 | rcptList = esmtp_address_list_new(); |
391 | 391 | ||
392 | field = getField( fields, MAILIMF_FIELD_TO ); | 392 | field = getField( fields, MAILIMF_FIELD_TO ); |
393 | if ( field && (field->type == MAILIMF_FIELD_TO) | 393 | if ( field && (field->type == MAILIMF_FIELD_TO) |
394 | && field->field.to->addr_list ) { | 394 | && field->field.to->addr_list ) { |
@@ -396,3 +396,3 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | field = getField( fields, MAILIMF_FIELD_CC ); | 398 | field = getField( fields, MAILIMF_FIELD_CC ); |
@@ -402,5 +402,5 @@ clist *MailWrapper::createRcptList( mailimf_fields *fields ) | |||
402 | } | 402 | } |
403 | 403 | ||
404 | field = getField( fields, MAILIMF_FIELD_BCC ); | 404 | field = getField( fields, MAILIMF_FIELD_BCC ); |
405 | if ( field && (field->type == MAILIMF_FIELD_BCC) | 405 | if ( field && (field->type == MAILIMF_FIELD_BCC) |
406 | && field->field.bcc->addr_list ) { | 406 | && field->field.bcc->addr_list ) { |
@@ -418,3 +418,3 @@ char *MailWrapper::getFrom( mailmime *mail ) | |||
418 | ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); | 418 | ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); |
419 | if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) | 419 | if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) |
420 | && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { | 420 | && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { |
@@ -428,3 +428,3 @@ char *MailWrapper::getFrom( mailmime *mail ) | |||
428 | 428 | ||
429 | return from; | 429 | return from; |
430 | } | 430 | } |
@@ -434,3 +434,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) | |||
434 | SMTPaccount *smtp; | 434 | SMTPaccount *smtp; |
435 | 435 | ||
436 | QList<Account> list = settings->getAccounts(); | 436 | QList<Account> list = settings->getAccounts(); |
@@ -447,3 +447,3 @@ SMTPaccount *MailWrapper::getAccount( QString from ) | |||
447 | } | 447 | } |
448 | 448 | ||
449 | return NULL; | 449 | return NULL; |
@@ -454,3 +454,3 @@ QString MailWrapper::getTmpFile() { | |||
454 | QString unique; | 454 | QString unique; |
455 | 455 | ||
456 | QDir dir( "/tmp" ); | 456 | QDir dir( "/tmp" ); |
@@ -462,3 +462,3 @@ QString MailWrapper::getTmpFile() { | |||
462 | } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); | 462 | } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); |
463 | 463 | ||
464 | return "/tmp/opiemail-tmp-" + unique; | 464 | return "/tmp/opiemail-tmp-" + unique; |
@@ -492,9 +492,9 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
492 | int fd, count = 0, total = 0; | 492 | int fd, count = 0, total = 0; |
493 | 493 | ||
494 | fd = open( file.latin1(), O_RDONLY, 0 ); | 494 | fd = open( file.latin1(), O_RDONLY, 0 ); |
495 | if ( fd == -1 ) return; | 495 | if ( fd == -1 ) return; |
496 | 496 | ||
497 | if ( fstat( fd, &st ) != 0 ) goto err_close; | 497 | if ( fstat( fd, &st ) != 0 ) goto err_close; |
498 | if ( !st.st_size ) goto err_close; | 498 | if ( !st.st_size ) goto err_close; |
499 | 499 | ||
500 | buf = (char *) malloc( st.st_size ); | 500 | buf = (char *) malloc( st.st_size ); |
@@ -510,3 +510,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
510 | *size = st.st_size; | 510 | *size = st.st_size; |
511 | 511 | ||
512 | close( fd ); | 512 | close( fd ); |
@@ -514,3 +514,3 @@ void MailWrapper::readFromFile( QString file, char **data, size_t *size ) | |||
514 | return; // Success :) | 514 | return; // Success :) |
515 | 515 | ||
516 | err_free: | 516 | err_free: |
@@ -535,3 +535,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
535 | uint16_t port; | 535 | uint16_t port; |
536 | 536 | ||
537 | 537 | ||
@@ -553,5 +553,5 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
553 | f.remove(); | 553 | f.remove(); |
554 | 554 | ||
555 | session = mailsmtp_new( 20, &progress ); | 555 | session = mailsmtp_new( 20, &progress ); |
556 | if ( session == NULL ) goto free_mem; | 556 | if ( session == NULL ) goto free_mem; |
557 | 557 | ||
@@ -569,5 +569,5 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
569 | if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; | 569 | if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; |
570 | 570 | ||
571 | qDebug( "INIT OK" ); | 571 | qDebug( "INIT OK" ); |
572 | 572 | ||
573 | if ( smtp->getLogin() ) { | 573 | if ( smtp->getLogin() ) { |
@@ -593,3 +593,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
593 | } | 593 | } |
594 | 594 | ||
595 | err = mailsmtp_send( session, from, rcpts, data, size ); | 595 | err = mailsmtp_send( session, from, rcpts, data, size ); |
@@ -598,3 +598,3 @@ void MailWrapper::smtpSend( mailmime *mail ) | |||
598 | qDebug( "Mail sent." ); | 598 | qDebug( "Mail sent." ); |
599 | 599 | ||
600 | free_con_session: | 600 | free_con_session: |
@@ -624,3 +624,3 @@ void MailWrapper::sendMail( Mail mail ) | |||
624 | mailmime_free( mimeMail ); | 624 | mailmime_free( mimeMail ); |
625 | } | 625 | } |
626 | } | 626 | } |
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 3de28a0..f45eab7 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h | |||
@@ -5,8 +5,8 @@ | |||
5 | 5 | ||
6 | #include <mailmime.h> | 6 | #include <libetpan/mailmime.h> |
7 | #include <mailimf.h> | 7 | #include <libetpan/mailimf.h> |
8 | #include <mailsmtp.h> | 8 | #include <libetpan/mailsmtp.h> |
9 | #include <mailimap.h> | 9 | #include <libetpan/mailimap.h> |
10 | #include <mailstorage.h> | 10 | #include <libetpan/mailstorage.h> |
11 | #include <maildriver.h> | 11 | #include <libetpan/maildriver.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |