Diffstat (limited to 'noncore/net/mail/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 30c0707..7e03af9 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp | |||
@@ -4,12 +4,15 @@ | |||
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qt.h> | 8 | #include <qt.h> |
9 | 9 | ||
10 | #include <qpe/config.h> | ||
11 | #include <qpe/qcopenvelope_qws.h> | ||
12 | |||
10 | #include <libetpan/libetpan.h> | 13 | #include <libetpan/libetpan.h> |
11 | 14 | ||
12 | #include "smtpwrapper.h" | 15 | #include "smtpwrapper.h" |
13 | #include "mailwrapper.h" | 16 | #include "mailwrapper.h" |
14 | #include "mboxwrapper.h" | 17 | #include "mboxwrapper.h" |
15 | #include "logindialog.h" | 18 | #include "logindialog.h" |
@@ -20,12 +23,22 @@ | |||
20 | progressMailSend*SMTPwrapper::sendProgress = 0; | 23 | progressMailSend*SMTPwrapper::sendProgress = 0; |
21 | 24 | ||
22 | SMTPwrapper::SMTPwrapper( Settings *s ) | 25 | SMTPwrapper::SMTPwrapper( Settings *s ) |
23 | : QObject() | 26 | : QObject() |
24 | { | 27 | { |
25 | settings = s; | 28 | settings = s; |
29 | Config cfg( "mail" ); | ||
30 | cfg.setGroup( "Status" ); | ||
31 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | ||
32 | emit queuedMails( m_queuedMail ); | ||
33 | connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) ); | ||
34 | } | ||
35 | |||
36 | void SMTPwrapper::emitQCop( int queued ) { | ||
37 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | ||
38 | env << queued; | ||
26 | } | 39 | } |
27 | 40 | ||
28 | QString SMTPwrapper::mailsmtpError( int errnum ) | 41 | QString SMTPwrapper::mailsmtpError( int errnum ) |
29 | { | 42 | { |
30 | switch ( errnum ) { | 43 | switch ( errnum ) { |
31 | case MAILSMTP_NO_ERROR: | 44 | case MAILSMTP_NO_ERROR: |
@@ -245,13 +258,13 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety | |||
245 | 258 | ||
246 | if (filename.length()>0) { | 259 | if (filename.length()>0) { |
247 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 260 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
248 | name = strdup( tmp.latin1() ); // just filename | 261 | name = strdup( tmp.latin1() ); // just filename |
249 | file = strdup( filename.latin1() ); // full name with path | 262 | file = strdup( filename.latin1() ); // full name with path |
250 | } | 263 | } |
251 | 264 | ||
252 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 265 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
253 | int mechanism = MAILMIME_MECHANISM_BASE64; | 266 | int mechanism = MAILMIME_MECHANISM_BASE64; |
254 | 267 | ||
255 | if ( mimetype.startsWith( "text/" ) ) { | 268 | if ( mimetype.startsWith( "text/" ) ) { |
256 | param = mailmime_parameter_new( strdup( "charset" ), | 269 | param = mailmime_parameter_new( strdup( "charset" ), |
257 | strdup( "iso-8859-1" ) ); | 270 | strdup( "iso-8859-1" ) ); |
@@ -347,13 +360,13 @@ mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) | |||
347 | message = mailmime_new_message_data( NULL ); | 360 | message = mailmime_new_message_data( NULL ); |
348 | if ( message == NULL ) goto err_free_fields; | 361 | if ( message == NULL ) goto err_free_fields; |
349 | 362 | ||
350 | mailmime_set_imf_fields( message, fields ); | 363 | mailmime_set_imf_fields( message, fields ); |
351 | 364 | ||
352 | txtPart = buildTxtPart( mail.getMessage() ); | 365 | txtPart = buildTxtPart( mail.getMessage() ); |
353 | 366 | ||
354 | if ( txtPart == NULL ) goto err_free_message; | 367 | if ( txtPart == NULL ) goto err_free_message; |
355 | 368 | ||
356 | err = mailmime_smart_add_part( message, txtPart ); | 369 | err = mailmime_smart_add_part( message, txtPart ); |
357 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; | 370 | if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; |
358 | 371 | ||
359 | addFileParts( message, mail.getAttachments() ); | 372 | addFileParts( message, mail.getAttachments() ); |
@@ -486,13 +499,13 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
486 | size_t size; | 499 | size_t size; |
487 | 500 | ||
488 | if ( smtp == NULL ) { | 501 | if ( smtp == NULL ) { |
489 | return; | 502 | return; |
490 | } | 503 | } |
491 | from = data = 0; | 504 | from = data = 0; |
492 | 505 | ||
493 | mailmessage * msg = 0; | 506 | mailmessage * msg = 0; |
494 | msg = mime_message_init(mail); | 507 | msg = mime_message_init(mail); |
495 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 508 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
496 | int r = mailmessage_fetch(msg,&data,&size); | 509 | int r = mailmessage_fetch(msg,&data,&size); |
497 | mime_message_detach_mime(msg); | 510 | mime_message_detach_mime(msg); |
498 | mailmessage_free(msg); | 511 | mailmessage_free(msg); |
@@ -504,12 +517,16 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
504 | QString tmp = data; | 517 | QString tmp = data; |
505 | tmp.replace(QRegExp("\r+",true,false),""); | 518 | tmp.replace(QRegExp("\r+",true,false),""); |
506 | msg = 0; | 519 | msg = 0; |
507 | if (later) { | 520 | if (later) { |
508 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); | 521 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); |
509 | if (data) free( data ); | 522 | if (data) free( data ); |
523 | Config cfg( "mail" ); | ||
524 | cfg.setGroup( "Status" ); | ||
525 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | ||
526 | emit queuedMails( m_queuedMail ); | ||
510 | return; | 527 | return; |
511 | } | 528 | } |
512 | from = getFrom( mail ); | 529 | from = getFrom( mail ); |
513 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 530 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
514 | smtpSend(from,rcpts,data,size,smtp); | 531 | smtpSend(from,rcpts,data,size,smtp); |
515 | if (data) {free(data);} | 532 | if (data) {free(data);} |
@@ -650,13 +667,13 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
650 | if (fields) { | 667 | if (fields) { |
651 | mailimf_fields_free(fields); | 668 | mailimf_fields_free(fields); |
652 | fields = 0; | 669 | fields = 0; |
653 | } | 670 | } |
654 | if (data) { | 671 | if (data) { |
655 | free(data); | 672 | free(data); |
656 | } | 673 | } |
657 | if (from) { | 674 | if (from) { |
658 | free(from); | 675 | free(from); |
659 | } | 676 | } |
660 | if (rcpts) { | 677 | if (rcpts) { |
661 | smtp_address_list_free( rcpts ); | 678 | smtp_address_list_free( rcpts ); |
662 | } | 679 | } |
@@ -697,12 +714,17 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | |||
697 | break; | 714 | break; |
698 | } | 715 | } |
699 | mailsToRemove.append(mailsToSend.at(0)); | 716 | mailsToRemove.append(mailsToSend.at(0)); |
700 | mailsToSend.removeFirst(); | 717 | mailsToSend.removeFirst(); |
701 | sendProgress->setCurrentMails(mailsToRemove.count()); | 718 | sendProgress->setCurrentMails(mailsToRemove.count()); |
702 | } | 719 | } |
720 | Config cfg( "mail" ); | ||
721 | cfg.setGroup( "Status" ); | ||
722 | m_queuedMail = 0; | ||
723 | cfg.writeEntry( "outgoing", m_queuedMail ); | ||
724 | emit queuedMails( m_queuedMail ); | ||
703 | sendProgress->hide(); | 725 | sendProgress->hide(); |
704 | delete sendProgress; | 726 | delete sendProgress; |
705 | sendProgress = 0; | 727 | sendProgress = 0; |
706 | wrap->deleteMails(mbox,mailsToRemove); | 728 | wrap->deleteMails(mbox,mailsToRemove); |
707 | mailsToSend.setAutoDelete(true); | 729 | mailsToSend.setAutoDelete(true); |
708 | delete wrap; | 730 | delete wrap; |