-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.h | 2 |
5 files changed, 59 insertions, 44 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 770e2b8..a7e4837 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -173,129 +173,129 @@ mailmime *SMTPwrapper::buildTxtPart(const QString&str ) | |||
173 | 173 | ||
174 | param = mailmime_parameter_new( strdup( "charset" ), | 174 | param = mailmime_parameter_new( strdup( "charset" ), |
175 | strdup( "iso-8859-1" ) ); | 175 | strdup( "iso-8859-1" ) ); |
176 | if ( param == NULL ) goto err_free; | 176 | if ( param == NULL ) goto err_free; |
177 | 177 | ||
178 | content = mailmime_content_new_with_str( "text/plain" ); | 178 | content = mailmime_content_new_with_str( "text/plain" ); |
179 | if ( content == NULL ) goto err_free_param; | 179 | if ( content == NULL ) goto err_free_param; |
180 | 180 | ||
181 | err = clist_append( content->ct_parameters, param ); | 181 | err = clist_append( content->ct_parameters, param ); |
182 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; | 182 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; |
183 | 183 | ||
184 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); | 184 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); |
185 | if ( fields == NULL ) goto err_free_content; | 185 | if ( fields == NULL ) goto err_free_content; |
186 | 186 | ||
187 | txtPart = mailmime_new_empty( content, fields ); | 187 | txtPart = mailmime_new_empty( content, fields ); |
188 | if ( txtPart == NULL ) goto err_free_fields; | 188 | if ( txtPart == NULL ) goto err_free_fields; |
189 | 189 | ||
190 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); | 190 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); |
191 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 191 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
192 | 192 | ||
193 | return txtPart; // Success :) | 193 | return txtPart; // Success :) |
194 | 194 | ||
195 | err_free_txtPart: | 195 | err_free_txtPart: |
196 | mailmime_free( txtPart ); | 196 | mailmime_free( txtPart ); |
197 | err_free_fields: | 197 | err_free_fields: |
198 | mailmime_fields_free( fields ); | 198 | mailmime_fields_free( fields ); |
199 | err_free_content: | 199 | err_free_content: |
200 | mailmime_content_free( content ); | 200 | mailmime_content_free( content ); |
201 | err_free_param: | 201 | err_free_param: |
202 | mailmime_parameter_free( param ); | 202 | mailmime_parameter_free( param ); |
203 | err_free: | 203 | err_free: |
204 | free( txt ); | 204 | free( txt ); |
205 | qDebug( "buildTxtPart - error" ); | 205 | qDebug( "buildTxtPart - error" ); |
206 | 206 | ||
207 | return NULL; // Error :( | 207 | return NULL; // Error :( |
208 | } | 208 | } |
209 | 209 | ||
210 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) | 210 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) |
211 | { | 211 | { |
212 | mailmime * filePart = 0; | 212 | mailmime * filePart = 0; |
213 | mailmime_fields * fields = 0; | 213 | mailmime_fields * fields = 0; |
214 | mailmime_content * content = 0; | 214 | mailmime_content * content = 0; |
215 | mailmime_parameter * param = 0; | 215 | mailmime_parameter * param = 0; |
216 | char*name = 0; | 216 | char*name = 0; |
217 | char*file = 0; | 217 | char*file = 0; |
218 | int err; | 218 | int err; |
219 | 219 | ||
220 | int pos = filename.findRev( '/' ); | 220 | int pos = filename.findRev( '/' ); |
221 | 221 | ||
222 | if (filename.length()>0) { | 222 | if (filename.length()>0) { |
223 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 223 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
224 | name = strdup( tmp.latin1() ); // just filename | 224 | name = strdup( tmp.latin1() ); // just filename |
225 | file = strdup( filename.latin1() ); // full name with path | 225 | file = strdup( filename.latin1() ); // full name with path |
226 | } | 226 | } |
227 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain | 227 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain |
228 | 228 | ||
229 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 229 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
230 | int mechanism = MAILMIME_MECHANISM_BASE64; | 230 | int mechanism = MAILMIME_MECHANISM_BASE64; |
231 | 231 | ||
232 | if ( mimetype.startsWith( "text/" ) ) { | 232 | if ( mimetype.startsWith( "text/" ) ) { |
233 | param = mailmime_parameter_new( strdup( "charset" ), | 233 | param = mailmime_parameter_new( strdup( "charset" ), |
234 | strdup( "iso-8859-1" ) ); | 234 | strdup( "iso-8859-1" ) ); |
235 | disptype = MAILMIME_DISPOSITION_TYPE_INLINE; | 235 | disptype = MAILMIME_DISPOSITION_TYPE_INLINE; |
236 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 236 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
237 | } | 237 | } |
238 | 238 | ||
239 | fields = mailmime_fields_new_filename( | 239 | fields = mailmime_fields_new_filename( |
240 | disptype, name, | 240 | disptype, name, |
241 | mechanism ); | 241 | mechanism ); |
242 | content = mailmime_content_new_with_str( mime ); | 242 | content = mailmime_content_new_with_str( mime ); |
243 | if (content!=0 && fields != 0) { | 243 | if (content!=0 && fields != 0) { |
244 | if (param) { | 244 | if (param) { |
245 | clist_append(content->ct_parameters,param); | 245 | clist_append(content->ct_parameters,param); |
246 | param = 0; | 246 | param = 0; |
247 | } | 247 | } |
248 | if (filename.length()>0) { | 248 | if (filename.length()>0) { |
249 | QFileInfo f(filename); | 249 | QFileInfo f(filename); |
250 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 250 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
251 | clist_append(content->ct_parameters,param); | 251 | clist_append(content->ct_parameters,param); |
252 | param = 0; | 252 | param = 0; |
253 | } | 253 | } |
254 | filePart = mailmime_new_empty( content, fields ); | 254 | filePart = mailmime_new_empty( content, fields ); |
255 | } | 255 | } |
256 | if (filePart) { | 256 | if (filePart) { |
257 | if (filename.length()>0) { | 257 | if (filename.length()>0) { |
258 | err = mailmime_set_body_file( filePart, file ); | 258 | err = mailmime_set_body_file( filePart, file ); |
259 | } else { | 259 | } else { |
260 | err = mailmime_set_body_text(filePart,strdup(TextContent.ascii()),TextContent.length()); | 260 | err = mailmime_set_body_text(filePart,strdup(TextContent.ascii()),TextContent.length()); |
261 | } | 261 | } |
262 | if (err != MAILIMF_NO_ERROR) { | 262 | if (err != MAILIMF_NO_ERROR) { |
263 | qDebug("Error setting body with file %s",file); | 263 | qDebug("Error setting body with file %s",file); |
264 | mailmime_free( filePart ); | 264 | mailmime_free( filePart ); |
265 | filePart = 0; | 265 | filePart = 0; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | if (!filePart) { | 269 | if (!filePart) { |
270 | if ( param != NULL ) { | 270 | if ( param != NULL ) { |
271 | mailmime_parameter_free( param ); | 271 | mailmime_parameter_free( param ); |
272 | } | 272 | } |
273 | if (content) { | 273 | if (content) { |
274 | mailmime_content_free( content ); | 274 | mailmime_content_free( content ); |
275 | } else { | 275 | } else { |
276 | if (mime) { | 276 | if (mime) { |
277 | free( mime ); | 277 | free( mime ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | if (fields) { | 280 | if (fields) { |
281 | mailmime_fields_free( fields ); | 281 | mailmime_fields_free( fields ); |
282 | } else { | 282 | } else { |
283 | if (name) { | 283 | if (name) { |
284 | free( name ); | 284 | free( name ); |
285 | } | 285 | } |
286 | if (file) { | 286 | if (file) { |
287 | free( file ); | 287 | free( file ); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | return filePart; // Success :) | 291 | return filePart; // Success :) |
292 | 292 | ||
293 | } | 293 | } |
294 | 294 | ||
295 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) | 295 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) |
296 | { | 296 | { |
297 | const Attachment *it; | 297 | const Attachment *it; |
298 | unsigned int count = files.count(); | 298 | unsigned int count = files.count(); |
299 | qDebug("List contains %i values",count); | 299 | qDebug("List contains %i values",count); |
300 | for ( unsigned int i = 0; i < count; ++i ) { | 300 | for ( unsigned int i = 0; i < count; ++i ) { |
301 | qDebug( "Adding file" ); | 301 | qDebug( "Adding file" ); |
@@ -503,235 +503,242 @@ void SMTPwrapper::writeToFile(const QString&file, mailmime *mail ) | |||
503 | } | 503 | } |
504 | 504 | ||
505 | void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) | 505 | void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) |
506 | { | 506 | { |
507 | 507 | ||
508 | QFile msg_cache(file); | 508 | QFile msg_cache(file); |
509 | QString msg = ""; | 509 | QString msg = ""; |
510 | msg_cache.open(IO_ReadOnly); | 510 | msg_cache.open(IO_ReadOnly); |
511 | char*message = new char[4096]; | 511 | char*message = new char[4096]; |
512 | memset(message,0,4096); | 512 | memset(message,0,4096); |
513 | while (msg_cache.readBlock(message,4095)>0) { | 513 | while (msg_cache.readBlock(message,4095)>0) { |
514 | msg+=message; | 514 | msg+=message; |
515 | memset(message,0,4096); | 515 | memset(message,0,4096); |
516 | } | 516 | } |
517 | delete message; | 517 | delete message; |
518 | *data = (char*)malloc(msg.length()+1*sizeof(char)); | 518 | *data = (char*)malloc(msg.length()+1*sizeof(char)); |
519 | memset(*data,0,msg.length()+1); | 519 | memset(*data,0,msg.length()+1); |
520 | memcpy(*data,msg.ascii(),msg.length()); | 520 | memcpy(*data,msg.ascii(),msg.length()); |
521 | *size=msg.length(); | 521 | *size=msg.length(); |
522 | } | 522 | } |
523 | 523 | ||
524 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 524 | void SMTPwrapper::progress( size_t current, size_t maximum ) |
525 | { | 525 | { |
526 | if (SMTPwrapper::sendProgress) { | 526 | if (SMTPwrapper::sendProgress) { |
527 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 527 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
528 | qApp->processEvents(); | 528 | qApp->processEvents(); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 532 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) |
533 | { | 533 | { |
534 | if (!mail) return; | 534 | if (!mail) return; |
535 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | 535 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); |
536 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 536 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
537 | wrap->storeMessage(mail,length,box); | 537 | wrap->storeMessage(mail,length,box); |
538 | delete wrap; | 538 | delete wrap; |
539 | } | 539 | } |
540 | 540 | ||
541 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 541 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) |
542 | { | 542 | { |
543 | clist *rcpts = 0; | 543 | clist *rcpts = 0; |
544 | char *from, *data; | 544 | char *from, *data; |
545 | size_t size; | 545 | size_t size; |
546 | 546 | ||
547 | if ( smtp == NULL ) { | 547 | if ( smtp == NULL ) { |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | from = data = 0; | 550 | from = data = 0; |
551 | 551 | ||
552 | QString file = getTmpFile(); | 552 | QString file = getTmpFile(); |
553 | writeToFile( file, mail ); | 553 | writeToFile( file, mail ); |
554 | readFromFile( file, &data, &size ); | 554 | readFromFile( file, &data, &size ); |
555 | QFile f( file ); | 555 | QFile f( file ); |
556 | f.remove(); | 556 | f.remove(); |
557 | 557 | ||
558 | if (later) { | 558 | if (later) { |
559 | storeMail(data,size,"Outgoing"); | 559 | storeMail(data,size,"Outgoing"); |
560 | if (data) free( data ); | 560 | if (data) free( data ); |
561 | return; | 561 | return; |
562 | } | 562 | } |
563 | from = getFrom( mail ); | 563 | from = getFrom( mail ); |
564 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 564 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
565 | smtpSend(from,rcpts,data,size,smtp); | 565 | smtpSend(from,rcpts,data,size,smtp); |
566 | } | 566 | } |
567 | 567 | ||
568 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) | 568 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) |
569 | { | 569 | { |
570 | char *server, *user, *pass; | 570 | char *server, *user, *pass; |
571 | bool ssl; | 571 | bool ssl; |
572 | uint16_t port; | 572 | uint16_t port; |
573 | mailsmtp *session; | 573 | mailsmtp *session; |
574 | int err,result; | 574 | int err,result; |
575 | 575 | ||
576 | result = 1; | 576 | result = 1; |
577 | server = user = pass = 0; | 577 | server = user = pass = 0; |
578 | server = strdup( smtp->getServer().latin1() ); | 578 | server = strdup( smtp->getServer().latin1() ); |
579 | ssl = smtp->getSSL(); | 579 | ssl = smtp->getSSL(); |
580 | port = smtp->getPort().toUInt(); | 580 | port = smtp->getPort().toUInt(); |
581 | 581 | ||
582 | session = mailsmtp_new( 20, &progress ); | 582 | session = mailsmtp_new( 20, &progress ); |
583 | if ( session == NULL ) goto free_mem; | 583 | if ( session == NULL ) goto free_mem; |
584 | 584 | ||
585 | qDebug( "Servername %s at port %i", server, port ); | 585 | qDebug( "Servername %s at port %i", server, port ); |
586 | if ( ssl ) { | 586 | if ( ssl ) { |
587 | qDebug( "SSL session" ); | 587 | qDebug( "SSL session" ); |
588 | err = mailsmtp_ssl_connect( session, server, port ); | 588 | err = mailsmtp_ssl_connect( session, server, port ); |
589 | } else { | 589 | } else { |
590 | qDebug( "No SSL session" ); | 590 | qDebug( "No SSL session" ); |
591 | err = mailsmtp_socket_connect( session, server, port ); | 591 | err = mailsmtp_socket_connect( session, server, port ); |
592 | } | 592 | } |
593 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} | 593 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} |
594 | 594 | ||
595 | err = mailsmtp_init( session ); | 595 | err = mailsmtp_init( session ); |
596 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 596 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
597 | 597 | ||
598 | qDebug( "INIT OK" ); | 598 | qDebug( "INIT OK" ); |
599 | 599 | ||
600 | if ( smtp->getLogin() ) { | 600 | if ( smtp->getLogin() ) { |
601 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { | 601 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { |
602 | // get'em | 602 | // get'em |
603 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); | 603 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); |
604 | login.show(); | 604 | login.show(); |
605 | if ( QDialog::Accepted == login.exec() ) { | 605 | if ( QDialog::Accepted == login.exec() ) { |
606 | // ok | 606 | // ok |
607 | user = strdup( login.getUser().latin1() ); | 607 | user = strdup( login.getUser().latin1() ); |
608 | pass = strdup( login.getPassword().latin1() ); | 608 | pass = strdup( login.getPassword().latin1() ); |
609 | } else { | 609 | } else { |
610 | result = 0; goto free_con_session; | 610 | result = 0; goto free_con_session; |
611 | } | 611 | } |
612 | } else { | 612 | } else { |
613 | user = strdup( smtp->getUser().latin1() ); | 613 | user = strdup( smtp->getUser().latin1() ); |
614 | pass = strdup( smtp->getPassword().latin1() ); | 614 | pass = strdup( smtp->getPassword().latin1() ); |
615 | } | 615 | } |
616 | qDebug( "session->auth: %i", session->auth); | 616 | qDebug( "session->auth: %i", session->auth); |
617 | err = mailsmtp_auth( session, user, pass ); | 617 | err = mailsmtp_auth( session, user, pass ); |
618 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 618 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
619 | qDebug( "Done auth!" ); | 619 | qDebug( "Done auth!" ); |
620 | } | 620 | } |
621 | 621 | ||
622 | err = mailsmtp_send( session, from, rcpts, data, size ); | 622 | err = mailsmtp_send( session, from, rcpts, data, size ); |
623 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 623 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
624 | 624 | ||
625 | qDebug( "Mail sent." ); | 625 | qDebug( "Mail sent." ); |
626 | storeMail(data,size,"Sent"); | 626 | storeMail(data,size,"Sent"); |
627 | 627 | ||
628 | free_con_session: | 628 | free_con_session: |
629 | mailsmtp_quit( session ); | 629 | mailsmtp_quit( session ); |
630 | free_mem_session: | 630 | free_mem_session: |
631 | mailsmtp_free( session ); | 631 | mailsmtp_free( session ); |
632 | free_mem: | 632 | free_mem: |
633 | if (rcpts) smtp_address_list_free( rcpts ); | 633 | if (rcpts) smtp_address_list_free( rcpts ); |
634 | if (data) free( data ); | 634 | if (data) free( data ); |
635 | if (server) free( server ); | 635 | if (server) free( server ); |
636 | if (from) free( from ); | 636 | if (from) free( from ); |
637 | if ( smtp->getLogin() ) { | 637 | if ( smtp->getLogin() ) { |
638 | free( user ); | 638 | free( user ); |
639 | free( pass ); | 639 | free( pass ); |
640 | } | 640 | } |
641 | return result; | 641 | return result; |
642 | } | 642 | } |
643 | 643 | ||
644 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) | 644 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) |
645 | { | 645 | { |
646 | mailmime * mimeMail; | 646 | mailmime * mimeMail; |
647 | 647 | ||
648 | SMTPaccount *smtp = getAccount(mail.getName()); | 648 | SMTPaccount *smtp = getAccount(mail.getName()); |
649 | 649 | ||
650 | mimeMail = createMimeMail(mail ); | 650 | mimeMail = createMimeMail(mail ); |
651 | if ( mimeMail == NULL ) { | 651 | if ( mimeMail == NULL ) { |
652 | qDebug( "sendMail: error creating mime mail" ); | 652 | qDebug( "sendMail: error creating mime mail" ); |
653 | } else { | 653 | } else { |
654 | sendProgress = new progressMailSend(); | 654 | sendProgress = new progressMailSend(); |
655 | // sendProgress->showMaximized(); | 655 | // sendProgress->showMaximized(); |
656 | sendProgress->show(); | 656 | sendProgress->show(); |
657 | sendProgress->setMaxMails(1); | 657 | sendProgress->setMaxMails(1); |
658 | smtpSend( mimeMail,later,smtp); | 658 | smtpSend( mimeMail,later,smtp); |
659 | mailmime_free( mimeMail ); | 659 | mailmime_free( mimeMail ); |
660 | qDebug("Clean up done"); | 660 | qDebug("Clean up done"); |
661 | sendProgress->hide(); | 661 | sendProgress->hide(); |
662 | delete sendProgress; | 662 | delete sendProgress; |
663 | sendProgress = 0; | 663 | sendProgress = 0; |
664 | } | 664 | } |
665 | } | 665 | } |
666 | 666 | ||
667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
668 | { | 668 | { |
669 | char*data = 0; | 669 | char*data = 0; |
670 | size_t length = 0; | 670 | size_t length = 0; |
671 | size_t curTok = 0; | 671 | size_t curTok = 0; |
672 | mailimf_fields *fields = 0; | 672 | mailimf_fields *fields = 0; |
673 | mailimf_field*ffrom = 0; | 673 | mailimf_field*ffrom = 0; |
674 | clist *rcpts = 0; | 674 | clist *rcpts = 0; |
675 | char*from = 0; | 675 | char*from = 0; |
676 | 676 | ||
677 | wrap->fetchRawBody(*which,&data,&length); | 677 | wrap->fetchRawBody(*which,&data,&length); |
678 | if (!data) return 0; | 678 | if (!data) return 0; |
679 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); | 679 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); |
680 | if (err != MAILIMF_NO_ERROR) { | 680 | if (err != MAILIMF_NO_ERROR) { |
681 | free(data); | 681 | free(data); |
682 | delete wrap; | 682 | delete wrap; |
683 | return 0; | 683 | return 0; |
684 | } | 684 | } |
685 | 685 | ||
686 | rcpts = createRcptList( fields ); | 686 | rcpts = createRcptList( fields ); |
687 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 687 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
688 | from = getFrom(ffrom); | 688 | from = getFrom(ffrom); |
689 | 689 | ||
690 | qDebug("Size: %i vs. %i",length,strlen(data)); | 690 | qDebug("Size: %i vs. %i",length,strlen(data)); |
691 | if (rcpts && from) { | 691 | if (rcpts && from) { |
692 | return smtpSend(from,rcpts,data,strlen(data),smtp ); | 692 | return smtpSend(from,rcpts,data,strlen(data),smtp ); |
693 | } | 693 | } |
694 | return 0; | 694 | return 0; |
695 | } | 695 | } |
696 | 696 | ||
697 | /* this is a special fun */ | 697 | /* this is a special fun */ |
698 | void SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 698 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
699 | { | 699 | { |
700 | if (!smtp) return; | 700 | bool returnValue = true; |
701 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | 701 | |
702 | if (!smtp) return false; | ||
703 | |||
704 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | ||
702 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 705 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
703 | if (!wrap) { | 706 | if (!wrap) { |
704 | qDebug("memory error"); | 707 | qDebug("memory error"); |
705 | return; | 708 | return false; |
706 | } | 709 | } |
707 | QList<RecMail> mailsToSend; | 710 | QList<RecMail> mailsToSend; |
708 | QList<RecMail> mailsToRemove; | 711 | QList<RecMail> mailsToRemove; |
709 | QString mbox("Outgoing"); | 712 | QString mbox("Outgoing"); |
710 | wrap->listMessages(mbox,mailsToSend); | 713 | wrap->listMessages(mbox,mailsToSend); |
711 | if (mailsToSend.count()==0) { | 714 | if (mailsToSend.count()==0) { |
712 | delete wrap; | 715 | delete wrap; |
713 | return; | 716 | return false; |
714 | } | 717 | } |
715 | mailsToSend.setAutoDelete(false); | 718 | mailsToSend.setAutoDelete(false); |
716 | sendProgress = new progressMailSend(); | 719 | sendProgress = new progressMailSend(); |
717 | // sendProgress->showMaximized(); | 720 | // sendProgress->showMaximized(); |
718 | sendProgress->show(); | 721 | sendProgress->show(); |
719 | sendProgress->setMaxMails(mailsToSend.count()); | 722 | sendProgress->setMaxMails(mailsToSend.count()); |
720 | 723 | ||
721 | while (mailsToSend.count()>0) { | 724 | while (mailsToSend.count()>0) { |
722 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { | 725 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { |
723 | QMessageBox::critical(0,tr("Error sending mail"), | 726 | QMessageBox::critical(0,tr("Error sending mail"), |
724 | tr("Error sending queued mail - breaking")); | 727 | tr("Error sending queued mail - breaking")); |
728 | |||
729 | returnValue = false; | ||
725 | break; | 730 | break; |
726 | } | 731 | } |
727 | mailsToRemove.append(mailsToSend.at(0)); | 732 | mailsToRemove.append(mailsToSend.at(0)); |
728 | mailsToSend.removeFirst(); | 733 | mailsToSend.removeFirst(); |
729 | sendProgress->setCurrentMails(mailsToRemove.count()); | 734 | sendProgress->setCurrentMails(mailsToRemove.count()); |
730 | } | 735 | } |
731 | sendProgress->hide(); | 736 | sendProgress->hide(); |
732 | delete sendProgress; | 737 | delete sendProgress; |
733 | sendProgress = 0; | 738 | sendProgress = 0; |
734 | wrap->deleteMails(mbox,mailsToRemove); | 739 | wrap->deleteMails(mbox,mailsToRemove); |
735 | mailsToSend.setAutoDelete(true); | 740 | mailsToSend.setAutoDelete(true); |
736 | delete wrap; | 741 | delete wrap; |
742 | return returnValue; | ||
743 | |||
737 | } | 744 | } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index baa353b..66180b7 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -1,65 +1,65 @@ | |||
1 | #ifndef SMTPwrapper_H | 1 | #ifndef SMTPwrapper_H |
2 | #define SMTPwrapper_H | 2 | #define SMTPwrapper_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class MBOXwrapper; | 13 | class MBOXwrapper; |
14 | class RecMail; | 14 | class RecMail; |
15 | class Attachment; | 15 | class Attachment; |
16 | struct mailimf_fields; | 16 | struct mailimf_fields; |
17 | struct mailimf_field; | 17 | struct mailimf_field; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailmime; | 19 | struct mailmime; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | class progressMailSend; | 21 | class progressMailSend; |
22 | 22 | ||
23 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | 26 | ||
27 | public: | 27 | public: |
28 | SMTPwrapper( Settings *s ); | 28 | SMTPwrapper( Settings *s ); |
29 | virtual ~SMTPwrapper(){} | 29 | virtual ~SMTPwrapper(){} |
30 | void sendMail(const Mail& mail,bool later=false ); | 30 | void sendMail(const Mail& mail,bool later=false ); |
31 | void flushOutbox(SMTPaccount*smtp); | 31 | bool flushOutbox(SMTPaccount*smtp); |
32 | 32 | ||
33 | static progressMailSend*sendProgress; | 33 | static progressMailSend*sendProgress; |
34 | protected: | 34 | protected: |
35 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 35 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
36 | mailimf_fields *createImfFields(const Mail &mail ); | 36 | mailimf_fields *createImfFields(const Mail &mail ); |
37 | mailmime *createMimeMail(const Mail&mail ); | 37 | mailmime *createMimeMail(const Mail&mail ); |
38 | 38 | ||
39 | mailimf_address_list *parseAddresses(const QString&addr ); | 39 | mailimf_address_list *parseAddresses(const QString&addr ); |
40 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 40 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
41 | mailmime *buildTxtPart(const QString&str ); | 41 | mailmime *buildTxtPart(const QString&str ); |
42 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 42 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
43 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); | 43 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); |
44 | clist *createRcptList( mailimf_fields *fields ); | 44 | clist *createRcptList( mailimf_fields *fields ); |
45 | SMTPaccount *getAccount(const QString&from ); | 45 | SMTPaccount *getAccount(const QString&from ); |
46 | void writeToFile(const QString&file, mailmime *mail ); | 46 | void writeToFile(const QString&file, mailmime *mail ); |
47 | void readFromFile(const QString&file, char **data, size_t *size ); | 47 | void readFromFile(const QString&file, char **data, size_t *size ); |
48 | 48 | ||
49 | static void storeMail(char*mail, size_t length, const QString&box); | 49 | static void storeMail(char*mail, size_t length, const QString&box); |
50 | static QString mailsmtpError( int err ); | 50 | static QString mailsmtpError( int err ); |
51 | static QString getTmpFile(); | 51 | static QString getTmpFile(); |
52 | static void progress( size_t current, size_t maximum ); | 52 | static void progress( size_t current, size_t maximum ); |
53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
54 | static char *getFrom( mailmime *mail ); | 54 | static char *getFrom( mailmime *mail ); |
55 | static char *getFrom( mailimf_field *ffrom); | 55 | static char *getFrom( mailimf_field *ffrom); |
56 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 56 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); | 57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); |
58 | 58 | ||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | #endif | 65 | #endif |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 833cac2..0dede90 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -23,76 +23,77 @@ OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | |||
23 | // copied from old mail2 | 23 | // copied from old mail2 |
24 | #if !defined(QT_NO_COP) | 24 | #if !defined(QT_NO_COP) |
25 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | 25 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), |
26 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 26 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
27 | #endif | 27 | #endif |
28 | } | 28 | } |
29 | 29 | ||
30 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 30 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
31 | { | 31 | { |
32 | // copied from old mail2 | 32 | // copied from old mail2 |
33 | // TODO: compose mail should get parameters of a recipient for starting | 33 | // TODO: compose mail should get parameters of a recipient for starting |
34 | // from addressbook. (qcop signal "writeMail(string,string)") | 34 | // from addressbook. (qcop signal "writeMail(string,string)") |
35 | if (msg == "writeMail(QString,QString)") { | 35 | if (msg == "writeMail(QString,QString)") { |
36 | QDataStream stream(data,IO_ReadOnly); | 36 | QDataStream stream(data,IO_ReadOnly); |
37 | QString name, email; | 37 | QString name, email; |
38 | stream >> name >> email; | 38 | stream >> name >> email; |
39 | slotComposeMail(); | 39 | slotComposeMail(); |
40 | } else if (msg == "newMail()") { | 40 | } else if (msg == "newMail()") { |
41 | slotComposeMail(); | 41 | slotComposeMail(); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | void OpieMail::slotComposeMail() | 45 | void OpieMail::slotComposeMail() |
46 | { | 46 | { |
47 | qDebug( "Compose Mail" ); | 47 | qDebug( "Compose Mail" ); |
48 | ComposeMail compose( settings, this, 0 , true ); | 48 | ComposeMail compose( settings, this, 0 , true ); |
49 | compose.showMaximized(); | 49 | compose.showMaximized(); |
50 | compose.slotAdjustColumns(); | 50 | compose.slotAdjustColumns(); |
51 | compose.exec(); | 51 | compose.exec(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void OpieMail::slotSendQueued() | 54 | void OpieMail::slotSendQueued() |
55 | { | 55 | { |
56 | qDebug( "Send Queued" ); | 56 | qDebug( "Send Queued" ); |
57 | SMTPaccount *smtp = 0; | 57 | SMTPaccount *smtp = 0; |
58 | 58 | ||
59 | QList<Account> list = settings->getAccounts(); | 59 | QList<Account> list = settings->getAccounts(); |
60 | Account *it; | 60 | Account *it; |
61 | // if (list.count()==1) { | 61 | // if (list.count()==1) { |
62 | for ( it = list.first(); it; it = list.next() ) { | 62 | for ( it = list.first(); it; it = list.next() ) { |
63 | if ( it->getType().compare( "SMTP" ) == 0 ) { | 63 | if ( it->getType().compare( "SMTP" ) == 0 ) { |
64 | smtp = static_cast<SMTPaccount *>(it); | 64 | smtp = static_cast<SMTPaccount *>(it); |
65 | break; | 65 | break; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | // } | 68 | // } |
69 | if (smtp) { | 69 | if (smtp) { |
70 | SMTPwrapper * wrap = new SMTPwrapper(settings); | 70 | SMTPwrapper * wrap = new SMTPwrapper(settings); |
71 | wrap->flushOutbox(smtp); | 71 | if ( wrap->flushOutbox(smtp) ) { |
72 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 72 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
73 | } | ||
73 | } | 74 | } |
74 | } | 75 | } |
75 | 76 | ||
76 | void OpieMail::slotSearchMails() | 77 | void OpieMail::slotSearchMails() |
77 | { | 78 | { |
78 | qDebug( "Search Mails" ); | 79 | qDebug( "Search Mails" ); |
79 | } | 80 | } |
80 | 81 | ||
81 | void OpieMail::slotEditSettings() | 82 | void OpieMail::slotEditSettings() |
82 | { | 83 | { |
83 | qDebug( "Edit Settings" ); | 84 | qDebug( "Edit Settings" ); |
84 | } | 85 | } |
85 | 86 | ||
86 | void OpieMail::slotEditAccounts() | 87 | void OpieMail::slotEditAccounts() |
87 | { | 88 | { |
88 | qDebug( "Edit Accounts" ); | 89 | qDebug( "Edit Accounts" ); |
89 | EditAccounts eaDialog( settings, this, 0, true ); | 90 | EditAccounts eaDialog( settings, this, 0, true ); |
90 | eaDialog.showMaximized(); | 91 | eaDialog.showMaximized(); |
91 | eaDialog.slotAdjustColumns(); | 92 | eaDialog.slotAdjustColumns(); |
92 | eaDialog.exec(); | 93 | eaDialog.exec(); |
93 | if ( settings ) delete settings; | 94 | if ( settings ) delete settings; |
94 | settings = new Settings(); | 95 | settings = new Settings(); |
95 | 96 | ||
96 | folderView->populate( settings->getAccounts() ); | 97 | folderView->populate( settings->getAccounts() ); |
97 | } | 98 | } |
98 | 99 | ||
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 770e2b8..a7e4837 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp | |||
@@ -173,129 +173,129 @@ mailmime *SMTPwrapper::buildTxtPart(const QString&str ) | |||
173 | 173 | ||
174 | param = mailmime_parameter_new( strdup( "charset" ), | 174 | param = mailmime_parameter_new( strdup( "charset" ), |
175 | strdup( "iso-8859-1" ) ); | 175 | strdup( "iso-8859-1" ) ); |
176 | if ( param == NULL ) goto err_free; | 176 | if ( param == NULL ) goto err_free; |
177 | 177 | ||
178 | content = mailmime_content_new_with_str( "text/plain" ); | 178 | content = mailmime_content_new_with_str( "text/plain" ); |
179 | if ( content == NULL ) goto err_free_param; | 179 | if ( content == NULL ) goto err_free_param; |
180 | 180 | ||
181 | err = clist_append( content->ct_parameters, param ); | 181 | err = clist_append( content->ct_parameters, param ); |
182 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; | 182 | if ( err != MAILIMF_NO_ERROR ) goto err_free_content; |
183 | 183 | ||
184 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); | 184 | fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); |
185 | if ( fields == NULL ) goto err_free_content; | 185 | if ( fields == NULL ) goto err_free_content; |
186 | 186 | ||
187 | txtPart = mailmime_new_empty( content, fields ); | 187 | txtPart = mailmime_new_empty( content, fields ); |
188 | if ( txtPart == NULL ) goto err_free_fields; | 188 | if ( txtPart == NULL ) goto err_free_fields; |
189 | 189 | ||
190 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); | 190 | err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); |
191 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 191 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
192 | 192 | ||
193 | return txtPart; // Success :) | 193 | return txtPart; // Success :) |
194 | 194 | ||
195 | err_free_txtPart: | 195 | err_free_txtPart: |
196 | mailmime_free( txtPart ); | 196 | mailmime_free( txtPart ); |
197 | err_free_fields: | 197 | err_free_fields: |
198 | mailmime_fields_free( fields ); | 198 | mailmime_fields_free( fields ); |
199 | err_free_content: | 199 | err_free_content: |
200 | mailmime_content_free( content ); | 200 | mailmime_content_free( content ); |
201 | err_free_param: | 201 | err_free_param: |
202 | mailmime_parameter_free( param ); | 202 | mailmime_parameter_free( param ); |
203 | err_free: | 203 | err_free: |
204 | free( txt ); | 204 | free( txt ); |
205 | qDebug( "buildTxtPart - error" ); | 205 | qDebug( "buildTxtPart - error" ); |
206 | 206 | ||
207 | return NULL; // Error :( | 207 | return NULL; // Error :( |
208 | } | 208 | } |
209 | 209 | ||
210 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) | 210 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) |
211 | { | 211 | { |
212 | mailmime * filePart = 0; | 212 | mailmime * filePart = 0; |
213 | mailmime_fields * fields = 0; | 213 | mailmime_fields * fields = 0; |
214 | mailmime_content * content = 0; | 214 | mailmime_content * content = 0; |
215 | mailmime_parameter * param = 0; | 215 | mailmime_parameter * param = 0; |
216 | char*name = 0; | 216 | char*name = 0; |
217 | char*file = 0; | 217 | char*file = 0; |
218 | int err; | 218 | int err; |
219 | 219 | ||
220 | int pos = filename.findRev( '/' ); | 220 | int pos = filename.findRev( '/' ); |
221 | 221 | ||
222 | if (filename.length()>0) { | 222 | if (filename.length()>0) { |
223 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 223 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
224 | name = strdup( tmp.latin1() ); // just filename | 224 | name = strdup( tmp.latin1() ); // just filename |
225 | file = strdup( filename.latin1() ); // full name with path | 225 | file = strdup( filename.latin1() ); // full name with path |
226 | } | 226 | } |
227 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain | 227 | char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain |
228 | 228 | ||
229 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 229 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
230 | int mechanism = MAILMIME_MECHANISM_BASE64; | 230 | int mechanism = MAILMIME_MECHANISM_BASE64; |
231 | 231 | ||
232 | if ( mimetype.startsWith( "text/" ) ) { | 232 | if ( mimetype.startsWith( "text/" ) ) { |
233 | param = mailmime_parameter_new( strdup( "charset" ), | 233 | param = mailmime_parameter_new( strdup( "charset" ), |
234 | strdup( "iso-8859-1" ) ); | 234 | strdup( "iso-8859-1" ) ); |
235 | disptype = MAILMIME_DISPOSITION_TYPE_INLINE; | 235 | disptype = MAILMIME_DISPOSITION_TYPE_INLINE; |
236 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 236 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
237 | } | 237 | } |
238 | 238 | ||
239 | fields = mailmime_fields_new_filename( | 239 | fields = mailmime_fields_new_filename( |
240 | disptype, name, | 240 | disptype, name, |
241 | mechanism ); | 241 | mechanism ); |
242 | content = mailmime_content_new_with_str( mime ); | 242 | content = mailmime_content_new_with_str( mime ); |
243 | if (content!=0 && fields != 0) { | 243 | if (content!=0 && fields != 0) { |
244 | if (param) { | 244 | if (param) { |
245 | clist_append(content->ct_parameters,param); | 245 | clist_append(content->ct_parameters,param); |
246 | param = 0; | 246 | param = 0; |
247 | } | 247 | } |
248 | if (filename.length()>0) { | 248 | if (filename.length()>0) { |
249 | QFileInfo f(filename); | 249 | QFileInfo f(filename); |
250 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 250 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
251 | clist_append(content->ct_parameters,param); | 251 | clist_append(content->ct_parameters,param); |
252 | param = 0; | 252 | param = 0; |
253 | } | 253 | } |
254 | filePart = mailmime_new_empty( content, fields ); | 254 | filePart = mailmime_new_empty( content, fields ); |
255 | } | 255 | } |
256 | if (filePart) { | 256 | if (filePart) { |
257 | if (filename.length()>0) { | 257 | if (filename.length()>0) { |
258 | err = mailmime_set_body_file( filePart, file ); | 258 | err = mailmime_set_body_file( filePart, file ); |
259 | } else { | 259 | } else { |
260 | err = mailmime_set_body_text(filePart,strdup(TextContent.ascii()),TextContent.length()); | 260 | err = mailmime_set_body_text(filePart,strdup(TextContent.ascii()),TextContent.length()); |
261 | } | 261 | } |
262 | if (err != MAILIMF_NO_ERROR) { | 262 | if (err != MAILIMF_NO_ERROR) { |
263 | qDebug("Error setting body with file %s",file); | 263 | qDebug("Error setting body with file %s",file); |
264 | mailmime_free( filePart ); | 264 | mailmime_free( filePart ); |
265 | filePart = 0; | 265 | filePart = 0; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | if (!filePart) { | 269 | if (!filePart) { |
270 | if ( param != NULL ) { | 270 | if ( param != NULL ) { |
271 | mailmime_parameter_free( param ); | 271 | mailmime_parameter_free( param ); |
272 | } | 272 | } |
273 | if (content) { | 273 | if (content) { |
274 | mailmime_content_free( content ); | 274 | mailmime_content_free( content ); |
275 | } else { | 275 | } else { |
276 | if (mime) { | 276 | if (mime) { |
277 | free( mime ); | 277 | free( mime ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | if (fields) { | 280 | if (fields) { |
281 | mailmime_fields_free( fields ); | 281 | mailmime_fields_free( fields ); |
282 | } else { | 282 | } else { |
283 | if (name) { | 283 | if (name) { |
284 | free( name ); | 284 | free( name ); |
285 | } | 285 | } |
286 | if (file) { | 286 | if (file) { |
287 | free( file ); | 287 | free( file ); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | return filePart; // Success :) | 291 | return filePart; // Success :) |
292 | 292 | ||
293 | } | 293 | } |
294 | 294 | ||
295 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) | 295 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) |
296 | { | 296 | { |
297 | const Attachment *it; | 297 | const Attachment *it; |
298 | unsigned int count = files.count(); | 298 | unsigned int count = files.count(); |
299 | qDebug("List contains %i values",count); | 299 | qDebug("List contains %i values",count); |
300 | for ( unsigned int i = 0; i < count; ++i ) { | 300 | for ( unsigned int i = 0; i < count; ++i ) { |
301 | qDebug( "Adding file" ); | 301 | qDebug( "Adding file" ); |
@@ -503,235 +503,242 @@ void SMTPwrapper::writeToFile(const QString&file, mailmime *mail ) | |||
503 | } | 503 | } |
504 | 504 | ||
505 | void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) | 505 | void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) |
506 | { | 506 | { |
507 | 507 | ||
508 | QFile msg_cache(file); | 508 | QFile msg_cache(file); |
509 | QString msg = ""; | 509 | QString msg = ""; |
510 | msg_cache.open(IO_ReadOnly); | 510 | msg_cache.open(IO_ReadOnly); |
511 | char*message = new char[4096]; | 511 | char*message = new char[4096]; |
512 | memset(message,0,4096); | 512 | memset(message,0,4096); |
513 | while (msg_cache.readBlock(message,4095)>0) { | 513 | while (msg_cache.readBlock(message,4095)>0) { |
514 | msg+=message; | 514 | msg+=message; |
515 | memset(message,0,4096); | 515 | memset(message,0,4096); |
516 | } | 516 | } |
517 | delete message; | 517 | delete message; |
518 | *data = (char*)malloc(msg.length()+1*sizeof(char)); | 518 | *data = (char*)malloc(msg.length()+1*sizeof(char)); |
519 | memset(*data,0,msg.length()+1); | 519 | memset(*data,0,msg.length()+1); |
520 | memcpy(*data,msg.ascii(),msg.length()); | 520 | memcpy(*data,msg.ascii(),msg.length()); |
521 | *size=msg.length(); | 521 | *size=msg.length(); |
522 | } | 522 | } |
523 | 523 | ||
524 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 524 | void SMTPwrapper::progress( size_t current, size_t maximum ) |
525 | { | 525 | { |
526 | if (SMTPwrapper::sendProgress) { | 526 | if (SMTPwrapper::sendProgress) { |
527 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 527 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
528 | qApp->processEvents(); | 528 | qApp->processEvents(); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 532 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) |
533 | { | 533 | { |
534 | if (!mail) return; | 534 | if (!mail) return; |
535 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | 535 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); |
536 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 536 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
537 | wrap->storeMessage(mail,length,box); | 537 | wrap->storeMessage(mail,length,box); |
538 | delete wrap; | 538 | delete wrap; |
539 | } | 539 | } |
540 | 540 | ||
541 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 541 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) |
542 | { | 542 | { |
543 | clist *rcpts = 0; | 543 | clist *rcpts = 0; |
544 | char *from, *data; | 544 | char *from, *data; |
545 | size_t size; | 545 | size_t size; |
546 | 546 | ||
547 | if ( smtp == NULL ) { | 547 | if ( smtp == NULL ) { |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | from = data = 0; | 550 | from = data = 0; |
551 | 551 | ||
552 | QString file = getTmpFile(); | 552 | QString file = getTmpFile(); |
553 | writeToFile( file, mail ); | 553 | writeToFile( file, mail ); |
554 | readFromFile( file, &data, &size ); | 554 | readFromFile( file, &data, &size ); |
555 | QFile f( file ); | 555 | QFile f( file ); |
556 | f.remove(); | 556 | f.remove(); |
557 | 557 | ||
558 | if (later) { | 558 | if (later) { |
559 | storeMail(data,size,"Outgoing"); | 559 | storeMail(data,size,"Outgoing"); |
560 | if (data) free( data ); | 560 | if (data) free( data ); |
561 | return; | 561 | return; |
562 | } | 562 | } |
563 | from = getFrom( mail ); | 563 | from = getFrom( mail ); |
564 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 564 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
565 | smtpSend(from,rcpts,data,size,smtp); | 565 | smtpSend(from,rcpts,data,size,smtp); |
566 | } | 566 | } |
567 | 567 | ||
568 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) | 568 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) |
569 | { | 569 | { |
570 | char *server, *user, *pass; | 570 | char *server, *user, *pass; |
571 | bool ssl; | 571 | bool ssl; |
572 | uint16_t port; | 572 | uint16_t port; |
573 | mailsmtp *session; | 573 | mailsmtp *session; |
574 | int err,result; | 574 | int err,result; |
575 | 575 | ||
576 | result = 1; | 576 | result = 1; |
577 | server = user = pass = 0; | 577 | server = user = pass = 0; |
578 | server = strdup( smtp->getServer().latin1() ); | 578 | server = strdup( smtp->getServer().latin1() ); |
579 | ssl = smtp->getSSL(); | 579 | ssl = smtp->getSSL(); |
580 | port = smtp->getPort().toUInt(); | 580 | port = smtp->getPort().toUInt(); |
581 | 581 | ||
582 | session = mailsmtp_new( 20, &progress ); | 582 | session = mailsmtp_new( 20, &progress ); |
583 | if ( session == NULL ) goto free_mem; | 583 | if ( session == NULL ) goto free_mem; |
584 | 584 | ||
585 | qDebug( "Servername %s at port %i", server, port ); | 585 | qDebug( "Servername %s at port %i", server, port ); |
586 | if ( ssl ) { | 586 | if ( ssl ) { |
587 | qDebug( "SSL session" ); | 587 | qDebug( "SSL session" ); |
588 | err = mailsmtp_ssl_connect( session, server, port ); | 588 | err = mailsmtp_ssl_connect( session, server, port ); |
589 | } else { | 589 | } else { |
590 | qDebug( "No SSL session" ); | 590 | qDebug( "No SSL session" ); |
591 | err = mailsmtp_socket_connect( session, server, port ); | 591 | err = mailsmtp_socket_connect( session, server, port ); |
592 | } | 592 | } |
593 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} | 593 | if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} |
594 | 594 | ||
595 | err = mailsmtp_init( session ); | 595 | err = mailsmtp_init( session ); |
596 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 596 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
597 | 597 | ||
598 | qDebug( "INIT OK" ); | 598 | qDebug( "INIT OK" ); |
599 | 599 | ||
600 | if ( smtp->getLogin() ) { | 600 | if ( smtp->getLogin() ) { |
601 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { | 601 | if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { |
602 | // get'em | 602 | // get'em |
603 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); | 603 | LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); |
604 | login.show(); | 604 | login.show(); |
605 | if ( QDialog::Accepted == login.exec() ) { | 605 | if ( QDialog::Accepted == login.exec() ) { |
606 | // ok | 606 | // ok |
607 | user = strdup( login.getUser().latin1() ); | 607 | user = strdup( login.getUser().latin1() ); |
608 | pass = strdup( login.getPassword().latin1() ); | 608 | pass = strdup( login.getPassword().latin1() ); |
609 | } else { | 609 | } else { |
610 | result = 0; goto free_con_session; | 610 | result = 0; goto free_con_session; |
611 | } | 611 | } |
612 | } else { | 612 | } else { |
613 | user = strdup( smtp->getUser().latin1() ); | 613 | user = strdup( smtp->getUser().latin1() ); |
614 | pass = strdup( smtp->getPassword().latin1() ); | 614 | pass = strdup( smtp->getPassword().latin1() ); |
615 | } | 615 | } |
616 | qDebug( "session->auth: %i", session->auth); | 616 | qDebug( "session->auth: %i", session->auth); |
617 | err = mailsmtp_auth( session, user, pass ); | 617 | err = mailsmtp_auth( session, user, pass ); |
618 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 618 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
619 | qDebug( "Done auth!" ); | 619 | qDebug( "Done auth!" ); |
620 | } | 620 | } |
621 | 621 | ||
622 | err = mailsmtp_send( session, from, rcpts, data, size ); | 622 | err = mailsmtp_send( session, from, rcpts, data, size ); |
623 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 623 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} |
624 | 624 | ||
625 | qDebug( "Mail sent." ); | 625 | qDebug( "Mail sent." ); |
626 | storeMail(data,size,"Sent"); | 626 | storeMail(data,size,"Sent"); |
627 | 627 | ||
628 | free_con_session: | 628 | free_con_session: |
629 | mailsmtp_quit( session ); | 629 | mailsmtp_quit( session ); |
630 | free_mem_session: | 630 | free_mem_session: |
631 | mailsmtp_free( session ); | 631 | mailsmtp_free( session ); |
632 | free_mem: | 632 | free_mem: |
633 | if (rcpts) smtp_address_list_free( rcpts ); | 633 | if (rcpts) smtp_address_list_free( rcpts ); |
634 | if (data) free( data ); | 634 | if (data) free( data ); |
635 | if (server) free( server ); | 635 | if (server) free( server ); |
636 | if (from) free( from ); | 636 | if (from) free( from ); |
637 | if ( smtp->getLogin() ) { | 637 | if ( smtp->getLogin() ) { |
638 | free( user ); | 638 | free( user ); |
639 | free( pass ); | 639 | free( pass ); |
640 | } | 640 | } |
641 | return result; | 641 | return result; |
642 | } | 642 | } |
643 | 643 | ||
644 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) | 644 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) |
645 | { | 645 | { |
646 | mailmime * mimeMail; | 646 | mailmime * mimeMail; |
647 | 647 | ||
648 | SMTPaccount *smtp = getAccount(mail.getName()); | 648 | SMTPaccount *smtp = getAccount(mail.getName()); |
649 | 649 | ||
650 | mimeMail = createMimeMail(mail ); | 650 | mimeMail = createMimeMail(mail ); |
651 | if ( mimeMail == NULL ) { | 651 | if ( mimeMail == NULL ) { |
652 | qDebug( "sendMail: error creating mime mail" ); | 652 | qDebug( "sendMail: error creating mime mail" ); |
653 | } else { | 653 | } else { |
654 | sendProgress = new progressMailSend(); | 654 | sendProgress = new progressMailSend(); |
655 | // sendProgress->showMaximized(); | 655 | // sendProgress->showMaximized(); |
656 | sendProgress->show(); | 656 | sendProgress->show(); |
657 | sendProgress->setMaxMails(1); | 657 | sendProgress->setMaxMails(1); |
658 | smtpSend( mimeMail,later,smtp); | 658 | smtpSend( mimeMail,later,smtp); |
659 | mailmime_free( mimeMail ); | 659 | mailmime_free( mimeMail ); |
660 | qDebug("Clean up done"); | 660 | qDebug("Clean up done"); |
661 | sendProgress->hide(); | 661 | sendProgress->hide(); |
662 | delete sendProgress; | 662 | delete sendProgress; |
663 | sendProgress = 0; | 663 | sendProgress = 0; |
664 | } | 664 | } |
665 | } | 665 | } |
666 | 666 | ||
667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
668 | { | 668 | { |
669 | char*data = 0; | 669 | char*data = 0; |
670 | size_t length = 0; | 670 | size_t length = 0; |
671 | size_t curTok = 0; | 671 | size_t curTok = 0; |
672 | mailimf_fields *fields = 0; | 672 | mailimf_fields *fields = 0; |
673 | mailimf_field*ffrom = 0; | 673 | mailimf_field*ffrom = 0; |
674 | clist *rcpts = 0; | 674 | clist *rcpts = 0; |
675 | char*from = 0; | 675 | char*from = 0; |
676 | 676 | ||
677 | wrap->fetchRawBody(*which,&data,&length); | 677 | wrap->fetchRawBody(*which,&data,&length); |
678 | if (!data) return 0; | 678 | if (!data) return 0; |
679 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); | 679 | int err = mailimf_fields_parse( data, length, &curTok, &fields ); |
680 | if (err != MAILIMF_NO_ERROR) { | 680 | if (err != MAILIMF_NO_ERROR) { |
681 | free(data); | 681 | free(data); |
682 | delete wrap; | 682 | delete wrap; |
683 | return 0; | 683 | return 0; |
684 | } | 684 | } |
685 | 685 | ||
686 | rcpts = createRcptList( fields ); | 686 | rcpts = createRcptList( fields ); |
687 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 687 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
688 | from = getFrom(ffrom); | 688 | from = getFrom(ffrom); |
689 | 689 | ||
690 | qDebug("Size: %i vs. %i",length,strlen(data)); | 690 | qDebug("Size: %i vs. %i",length,strlen(data)); |
691 | if (rcpts && from) { | 691 | if (rcpts && from) { |
692 | return smtpSend(from,rcpts,data,strlen(data),smtp ); | 692 | return smtpSend(from,rcpts,data,strlen(data),smtp ); |
693 | } | 693 | } |
694 | return 0; | 694 | return 0; |
695 | } | 695 | } |
696 | 696 | ||
697 | /* this is a special fun */ | 697 | /* this is a special fun */ |
698 | void SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 698 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
699 | { | 699 | { |
700 | if (!smtp) return; | 700 | bool returnValue = true; |
701 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | 701 | |
702 | if (!smtp) return false; | ||
703 | |||
704 | QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); | ||
702 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 705 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); |
703 | if (!wrap) { | 706 | if (!wrap) { |
704 | qDebug("memory error"); | 707 | qDebug("memory error"); |
705 | return; | 708 | return false; |
706 | } | 709 | } |
707 | QList<RecMail> mailsToSend; | 710 | QList<RecMail> mailsToSend; |
708 | QList<RecMail> mailsToRemove; | 711 | QList<RecMail> mailsToRemove; |
709 | QString mbox("Outgoing"); | 712 | QString mbox("Outgoing"); |
710 | wrap->listMessages(mbox,mailsToSend); | 713 | wrap->listMessages(mbox,mailsToSend); |
711 | if (mailsToSend.count()==0) { | 714 | if (mailsToSend.count()==0) { |
712 | delete wrap; | 715 | delete wrap; |
713 | return; | 716 | return false; |
714 | } | 717 | } |
715 | mailsToSend.setAutoDelete(false); | 718 | mailsToSend.setAutoDelete(false); |
716 | sendProgress = new progressMailSend(); | 719 | sendProgress = new progressMailSend(); |
717 | // sendProgress->showMaximized(); | 720 | // sendProgress->showMaximized(); |
718 | sendProgress->show(); | 721 | sendProgress->show(); |
719 | sendProgress->setMaxMails(mailsToSend.count()); | 722 | sendProgress->setMaxMails(mailsToSend.count()); |
720 | 723 | ||
721 | while (mailsToSend.count()>0) { | 724 | while (mailsToSend.count()>0) { |
722 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { | 725 | if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { |
723 | QMessageBox::critical(0,tr("Error sending mail"), | 726 | QMessageBox::critical(0,tr("Error sending mail"), |
724 | tr("Error sending queued mail - breaking")); | 727 | tr("Error sending queued mail - breaking")); |
728 | |||
729 | returnValue = false; | ||
725 | break; | 730 | break; |
726 | } | 731 | } |
727 | mailsToRemove.append(mailsToSend.at(0)); | 732 | mailsToRemove.append(mailsToSend.at(0)); |
728 | mailsToSend.removeFirst(); | 733 | mailsToSend.removeFirst(); |
729 | sendProgress->setCurrentMails(mailsToRemove.count()); | 734 | sendProgress->setCurrentMails(mailsToRemove.count()); |
730 | } | 735 | } |
731 | sendProgress->hide(); | 736 | sendProgress->hide(); |
732 | delete sendProgress; | 737 | delete sendProgress; |
733 | sendProgress = 0; | 738 | sendProgress = 0; |
734 | wrap->deleteMails(mbox,mailsToRemove); | 739 | wrap->deleteMails(mbox,mailsToRemove); |
735 | mailsToSend.setAutoDelete(true); | 740 | mailsToSend.setAutoDelete(true); |
736 | delete wrap; | 741 | delete wrap; |
742 | return returnValue; | ||
743 | |||
737 | } | 744 | } |
diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h index baa353b..66180b7 100644 --- a/noncore/net/mail/smtpwrapper.h +++ b/noncore/net/mail/smtpwrapper.h | |||
@@ -1,65 +1,65 @@ | |||
1 | #ifndef SMTPwrapper_H | 1 | #ifndef SMTPwrapper_H |
2 | #define SMTPwrapper_H | 2 | #define SMTPwrapper_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class MBOXwrapper; | 13 | class MBOXwrapper; |
14 | class RecMail; | 14 | class RecMail; |
15 | class Attachment; | 15 | class Attachment; |
16 | struct mailimf_fields; | 16 | struct mailimf_fields; |
17 | struct mailimf_field; | 17 | struct mailimf_field; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailmime; | 19 | struct mailmime; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | class progressMailSend; | 21 | class progressMailSend; |
22 | 22 | ||
23 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | 26 | ||
27 | public: | 27 | public: |
28 | SMTPwrapper( Settings *s ); | 28 | SMTPwrapper( Settings *s ); |
29 | virtual ~SMTPwrapper(){} | 29 | virtual ~SMTPwrapper(){} |
30 | void sendMail(const Mail& mail,bool later=false ); | 30 | void sendMail(const Mail& mail,bool later=false ); |
31 | void flushOutbox(SMTPaccount*smtp); | 31 | bool flushOutbox(SMTPaccount*smtp); |
32 | 32 | ||
33 | static progressMailSend*sendProgress; | 33 | static progressMailSend*sendProgress; |
34 | protected: | 34 | protected: |
35 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 35 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
36 | mailimf_fields *createImfFields(const Mail &mail ); | 36 | mailimf_fields *createImfFields(const Mail &mail ); |
37 | mailmime *createMimeMail(const Mail&mail ); | 37 | mailmime *createMimeMail(const Mail&mail ); |
38 | 38 | ||
39 | mailimf_address_list *parseAddresses(const QString&addr ); | 39 | mailimf_address_list *parseAddresses(const QString&addr ); |
40 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 40 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
41 | mailmime *buildTxtPart(const QString&str ); | 41 | mailmime *buildTxtPart(const QString&str ); |
42 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 42 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
43 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); | 43 | void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); |
44 | clist *createRcptList( mailimf_fields *fields ); | 44 | clist *createRcptList( mailimf_fields *fields ); |
45 | SMTPaccount *getAccount(const QString&from ); | 45 | SMTPaccount *getAccount(const QString&from ); |
46 | void writeToFile(const QString&file, mailmime *mail ); | 46 | void writeToFile(const QString&file, mailmime *mail ); |
47 | void readFromFile(const QString&file, char **data, size_t *size ); | 47 | void readFromFile(const QString&file, char **data, size_t *size ); |
48 | 48 | ||
49 | static void storeMail(char*mail, size_t length, const QString&box); | 49 | static void storeMail(char*mail, size_t length, const QString&box); |
50 | static QString mailsmtpError( int err ); | 50 | static QString mailsmtpError( int err ); |
51 | static QString getTmpFile(); | 51 | static QString getTmpFile(); |
52 | static void progress( size_t current, size_t maximum ); | 52 | static void progress( size_t current, size_t maximum ); |
53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
54 | static char *getFrom( mailmime *mail ); | 54 | static char *getFrom( mailmime *mail ); |
55 | static char *getFrom( mailimf_field *ffrom); | 55 | static char *getFrom( mailimf_field *ffrom); |
56 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 56 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); | 57 | int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); |
58 | 58 | ||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | #endif | 65 | #endif |