summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/sendmailprogress.cpp48
-rw-r--r--noncore/net/mail/libmailwrapper/sendmailprogress.h19
-rw-r--r--noncore/net/mail/libmailwrapper/sendmailprogressui.ui110
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp16
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
-rw-r--r--noncore/net/mail/mail.pro9
-rw-r--r--noncore/net/mail/sendmailprogress.cpp48
-rw-r--r--noncore/net/mail/sendmailprogress.h19
-rw-r--r--noncore/net/mail/sendmailprogressui.ui110
-rw-r--r--noncore/net/mail/smtpwrapper.cpp16
-rw-r--r--noncore/net/mail/smtpwrapper.h4
11 files changed, 396 insertions, 7 deletions
diff --git a/noncore/net/mail/libmailwrapper/sendmailprogress.cpp b/noncore/net/mail/libmailwrapper/sendmailprogress.cpp
new file mode 100644
index 0000000..13ddd37
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/sendmailprogress.cpp
@@ -0,0 +1,48 @@
1#include "sendmailprogress.h"
2#include <qprogressbar.h>
3#include <qlabel.h>
4#include <qstring.h>
5
6progressMailSend::progressMailSend(QWidget*parent, const char * name)
7 :progressMailSendUI(parent,name,false),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0)
8{
9}
10
11progressMailSend::~progressMailSend()
12{
13}
14
15void progressMailSend::setMaxMails(unsigned int aMaxMails)
16{
17 m_max_mail = aMaxMails;
18 allMailProgressBar->setTotalSteps(aMaxMails);
19 setMails();
20}
21
22void progressMailSend::setCurrentMails(unsigned int aCurrent)
23{
24 m_current_mail = aCurrent;
25 allMailProgressBar->setProgress(aCurrent);
26 setMails();
27}
28
29void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax)
30{
31 m_current_single = aCurrent;
32 m_max_single = aMax;
33 setSingle();
34}
35
36void progressMailSend::setSingle()
37{
38 QString text = QString(tr("%1 of %2 bytes send")).arg(m_current_single).arg(m_max_single);
39 singleMailLabel->setText(text);
40 singleMailProgressBar->setTotalSteps(m_max_single);
41 singleMailProgressBar->setProgress(m_current_single);
42}
43
44void progressMailSend::setMails()
45{
46 QString text = QString(tr("Sending mail %1 of %2")).arg(m_current_single+1).arg(m_max_single);
47 allMailLabel->setText(text);
48}
diff --git a/noncore/net/mail/libmailwrapper/sendmailprogress.h b/noncore/net/mail/libmailwrapper/sendmailprogress.h
new file mode 100644
index 0000000..5b7d33b
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/sendmailprogress.h
@@ -0,0 +1,19 @@
1#include "sendmailprogressui.h"
2
3class progressMailSend:public progressMailSendUI
4{
5 Q_OBJECT
6public:
7 progressMailSend(QWidget*parent = 0, const char * name = 0);
8 ~progressMailSend();
9
10 void setMaxMails(unsigned int aMaxMails);
11 void setCurrentMails(unsigned int aCurrent);
12
13 void setSingleMail(unsigned int aCurrent,unsigned int aMax);
14
15protected:
16 unsigned m_current_mail,m_current_single,m_max_mail,m_max_single;
17 void setSingle();
18 void setMails();
19};
diff --git a/noncore/net/mail/libmailwrapper/sendmailprogressui.ui b/noncore/net/mail/libmailwrapper/sendmailprogressui.ui
new file mode 100644
index 0000000..b90b088
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/sendmailprogressui.ui
@@ -0,0 +1,110 @@
1<!DOCTYPE UI><UI>
2<class>progressMailSendUI</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>progressMailSendUI</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>316</width>
15 <height>266</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Sending mail</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <widget>
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>singleMailLabel</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>Progress of mail</string>
46 </property>
47 <property stdset="1">
48 <name>alignment</name>
49 <set>AlignCenter</set>
50 </property>
51 <property>
52 <name>hAlign</name>
53 </property>
54 </widget>
55 <widget>
56 <class>QProgressBar</class>
57 <property stdset="1">
58 <name>name</name>
59 <cstring>singleMailProgressBar</cstring>
60 </property>
61 </widget>
62 <widget>
63 <class>QLabel</class>
64 <property stdset="1">
65 <name>name</name>
66 <cstring>allMailLabel</cstring>
67 </property>
68 <property stdset="1">
69 <name>text</name>
70 <string>Sending mail</string>
71 </property>
72 <property stdset="1">
73 <name>alignment</name>
74 <set>AlignCenter</set>
75 </property>
76 <property>
77 <name>hAlign</name>
78 </property>
79 </widget>
80 <widget>
81 <class>QProgressBar</class>
82 <property stdset="1">
83 <name>name</name>
84 <cstring>allMailProgressBar</cstring>
85 </property>
86 </widget>
87 <spacer>
88 <property>
89 <name>name</name>
90 <cstring>Spacer6</cstring>
91 </property>
92 <property stdset="1">
93 <name>orientation</name>
94 <enum>Vertical</enum>
95 </property>
96 <property stdset="1">
97 <name>sizeType</name>
98 <enum>Expanding</enum>
99 </property>
100 <property>
101 <name>sizeHint</name>
102 <size>
103 <width>20</width>
104 <height>20</height>
105 </size>
106 </property>
107 </spacer>
108 </vbox>
109</widget>
110</UI>
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index b81a87f..53c0af5 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -6,24 +6,27 @@
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 <libetpan/libetpan.h> 10#include <libetpan/libetpan.h>
11 11
12#include "smtpwrapper.h" 12#include "smtpwrapper.h"
13#include "mailwrapper.h" 13#include "mailwrapper.h"
14#include "mboxwrapper.h" 14#include "mboxwrapper.h"
15#include "logindialog.h" 15#include "logindialog.h"
16#include "mailtypes.h" 16#include "mailtypes.h"
17#include "defines.h" 17#include "defines.h"
18#include "sendmailprogress.h"
19
20progressMailSend*SMTPwrapper::sendProgress = 0;
18 21
19SMTPwrapper::SMTPwrapper( Settings *s ) 22SMTPwrapper::SMTPwrapper( Settings *s )
20 : QObject() 23 : QObject()
21{ 24{
22 settings = s; 25 settings = s;
23} 26}
24 27
25QString SMTPwrapper::mailsmtpError( int errnum ) 28QString SMTPwrapper::mailsmtpError( int errnum )
26{ 29{
27 switch ( errnum ) { 30 switch ( errnum ) {
28 case MAILSMTP_NO_ERROR: 31 case MAILSMTP_NO_ERROR:
29 return tr( "No error" ); 32 return tr( "No error" );
@@ -511,25 +514,28 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size )
511 msg+=message; 514 msg+=message;
512 memset(message,0,4096); 515 memset(message,0,4096);
513 } 516 }
514 delete message; 517 delete message;
515 *data = (char*)malloc(msg.length()+1*sizeof(char)); 518 *data = (char*)malloc(msg.length()+1*sizeof(char));
516 memset(*data,0,msg.length()+1); 519 memset(*data,0,msg.length()+1);
517 memcpy(*data,msg.ascii(),msg.length()); 520 memcpy(*data,msg.ascii(),msg.length());
518 *size=msg.length(); 521 *size=msg.length();
519} 522}
520 523
521void SMTPwrapper::progress( size_t current, size_t maximum ) 524void SMTPwrapper::progress( size_t current, size_t maximum )
522{ 525{
523// qDebug( "Current: %i of %i", current, maximum ); 526 if (SMTPwrapper::sendProgress) {
527 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
528 qDebug("%u of %u",current,maximum);
529 }
524} 530}
525 531
526void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 532void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
527{ 533{
528 if (!mail) return; 534 if (!mail) return;
529 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 535 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
530 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 536 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
531 wrap->storeMessage(mail,length,box); 537 wrap->storeMessage(mail,length,box);
532 delete wrap; 538 delete wrap;
533} 539}
534 540
535void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 541void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
@@ -636,27 +642,34 @@ free_mem:
636} 642}
637 643
638void SMTPwrapper::sendMail(const Mail&mail,bool later ) 644void SMTPwrapper::sendMail(const Mail&mail,bool later )
639{ 645{
640 mailmime * mimeMail; 646 mailmime * mimeMail;
641 647
642 SMTPaccount *smtp = getAccount(mail.getName()); 648 SMTPaccount *smtp = getAccount(mail.getName());
643 649
644 mimeMail = createMimeMail(mail ); 650 mimeMail = createMimeMail(mail );
645 if ( mimeMail == NULL ) { 651 if ( mimeMail == NULL ) {
646 qDebug( "sendMail: error creating mime mail" ); 652 qDebug( "sendMail: error creating mime mail" );
647 } else { 653 } else {
654 sendProgress = new progressMailSend();
655 sendProgress->showMaximized();
656 sendProgress->show();
657 qApp->processEvents(10);
648 smtpSend( mimeMail,later,smtp); 658 smtpSend( mimeMail,later,smtp);
649 mailmime_free( mimeMail ); 659 mailmime_free( mimeMail );
650 qDebug("Clean up done"); 660 qDebug("Clean up done");
661 sendProgress->hide();
662 delete sendProgress;
663 sendProgress = 0;
651 } 664 }
652} 665}
653 666
654int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 667int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
655{ 668{
656 char*data = 0; 669 char*data = 0;
657 size_t length = 0; 670 size_t length = 0;
658 size_t curTok = 0; 671 size_t curTok = 0;
659 mailimf_fields *fields = 0; 672 mailimf_fields *fields = 0;
660 mailimf_field*ffrom = 0; 673 mailimf_field*ffrom = 0;
661 clist *rcpts = 0; 674 clist *rcpts = 0;
662 char*from = 0; 675 char*from = 0;
@@ -664,24 +677,25 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
664 wrap->fetchRawBody(*which,&data,&length); 677 wrap->fetchRawBody(*which,&data,&length);
665 if (!data) return 0; 678 if (!data) return 0;
666 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 679 int err = mailimf_fields_parse( data, length, &curTok, &fields );
667 if (err != MAILIMF_NO_ERROR) { 680 if (err != MAILIMF_NO_ERROR) {
668 free(data); 681 free(data);
669 delete wrap; 682 delete wrap;
670 return 0; 683 return 0;
671 } 684 }
672 685
673 rcpts = createRcptList( fields ); 686 rcpts = createRcptList( fields );
674 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 687 ffrom = getField(fields, MAILIMF_FIELD_FROM );
675 from = getFrom(ffrom); 688 from = getFrom(ffrom);
689
676 qDebug("Size: %i vs. %i",length,strlen(data)); 690 qDebug("Size: %i vs. %i",length,strlen(data));
677 if (rcpts && from) { 691 if (rcpts && from) {
678 return smtpSend(from,rcpts,data,strlen(data),smtp ); 692 return smtpSend(from,rcpts,data,strlen(data),smtp );
679 } 693 }
680 return 0; 694 return 0;
681} 695}
682 696
683/* this is a special fun */ 697/* this is a special fun */
684void SMTPwrapper::flushOutbox(SMTPaccount*smtp) 698void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
685{ 699{
686 if (!smtp) return; 700 if (!smtp) return;
687 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 701 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index c0dcc11..baa353b 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -9,55 +9,57 @@
9 9
10#include "settings.h" 10#include "settings.h"
11 11
12class Mail; 12class Mail;
13class MBOXwrapper; 13class MBOXwrapper;
14class RecMail; 14class RecMail;
15class Attachment; 15class Attachment;
16struct mailimf_fields; 16struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend;
21 22
22class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
23{ 24{
24 Q_OBJECT 25 Q_OBJECT
25 26
26public: 27public:
27 SMTPwrapper( Settings *s ); 28 SMTPwrapper( Settings *s );
28 virtual ~SMTPwrapper(){} 29 virtual ~SMTPwrapper(){}
29 void sendMail(const Mail& mail,bool later=false ); 30 void sendMail(const Mail& mail,bool later=false );
30 void flushOutbox(SMTPaccount*smtp); 31 void flushOutbox(SMTPaccount*smtp);
31 32
33 static progressMailSend*sendProgress;
32protected: 34protected:
33 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
34 mailimf_fields *createImfFields(const Mail &mail ); 36 mailimf_fields *createImfFields(const Mail &mail );
35 mailmime *createMimeMail(const Mail&mail ); 37 mailmime *createMimeMail(const Mail&mail );
36 38
37 mailimf_address_list *parseAddresses(const QString&addr ); 39 mailimf_address_list *parseAddresses(const QString&addr );
38 void addFileParts( mailmime *message,const QList<Attachment>&files ); 40 void addFileParts( mailmime *message,const QList<Attachment>&files );
39 mailmime *buildTxtPart(const QString&str ); 41 mailmime *buildTxtPart(const QString&str );
40 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
41 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); 43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
42 clist *createRcptList( mailimf_fields *fields ); 44 clist *createRcptList( mailimf_fields *fields );
43 SMTPaccount *getAccount(const QString&from ); 45 SMTPaccount *getAccount(const QString&from );
44 void writeToFile(const QString&file, mailmime *mail ); 46 void writeToFile(const QString&file, mailmime *mail );
45 void readFromFile(const QString&file, char **data, size_t *size ); 47 void readFromFile(const QString&file, char **data, size_t *size );
46 48
47 static void storeMail(char*mail, size_t length, const QString&box); 49 static void storeMail(char*mail, size_t length, const QString&box);
48 static QString mailsmtpError( int err ); 50 static QString mailsmtpError( int err );
49 static QString getTmpFile(); 51 static QString getTmpFile();
50 static void progress( size_t current, size_t maximum ); 52 static void progress( size_t current, size_t maximum );
51 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 53 static void addRcpts( clist *list, mailimf_address_list *addr_list );
52 static char *getFrom( mailmime *mail ); 54 static char *getFrom( mailmime *mail );
53 static char *getFrom( mailimf_field *ffrom); 55 static char *getFrom( mailimf_field *ffrom);
54 static mailimf_field *getField( mailimf_fields *fields, int type ); 56 static mailimf_field *getField( mailimf_fields *fields, int type );
55 static 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 );
56 58
57 void storeMail(mailmime*mail, const QString&box); 59 void storeMail(mailmime*mail, const QString&box);
58 Settings *settings; 60 Settings *settings;
59 61
60 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); 62 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
61}; 63};
62 64
63#endif 65#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index dd3c337..ea5fb58 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -11,59 +11,62 @@ HEADERS = defines.h \
11 viewmail.h \ 11 viewmail.h \
12 viewmailbase.h \ 12 viewmailbase.h \
13 opiemail.h \ 13 opiemail.h \
14 imapwrapper.h \ 14 imapwrapper.h \
15 mailtypes.h \ 15 mailtypes.h \
16 mailistviewitem.h \ 16 mailistviewitem.h \
17 pop3wrapper.h \ 17 pop3wrapper.h \
18 abstractmail.h \ 18 abstractmail.h \
19 settingsdialog.h \ 19 settingsdialog.h \
20 statuswidget.h \ 20 statuswidget.h \
21 smtpwrapper.h \ 21 smtpwrapper.h \
22 genericwrapper.h \ 22 genericwrapper.h \
23 mboxwrapper.h 23 mboxwrapper.h \
24 sendmailprogress.h
24 25
25SOURCES = main.cpp \ 26SOURCES = main.cpp \
26 opiemail.cpp \ 27 opiemail.cpp \
27 mainwindow.cpp \ 28 mainwindow.cpp \
28 accountview.cpp \ 29 accountview.cpp \
29 composemail.cpp \ 30 composemail.cpp \
30 mailwrapper.cpp \ 31 mailwrapper.cpp \
31 imapwrapper.cpp \ 32 imapwrapper.cpp \
32 addresspicker.cpp \ 33 addresspicker.cpp \
33 editaccounts.cpp \ 34 editaccounts.cpp \
34 logindialog.cpp \ 35 logindialog.cpp \
35 viewmail.cpp \ 36 viewmail.cpp \
36 viewmailbase.cpp \ 37 viewmailbase.cpp \
37 settings.cpp \ 38 settings.cpp \
38 mailtypes.cpp \ 39 mailtypes.cpp \
39 pop3wrapper.cpp \ 40 pop3wrapper.cpp \
40 abstractmail.cpp \ 41 abstractmail.cpp \
41 settingsdialog.cpp \ 42 settingsdialog.cpp \
42 statuswidget.cpp \ 43 statuswidget.cpp \
43 smtpwrapper.cpp \ 44 smtpwrapper.cpp \
44 genericwrapper.cpp \ 45 genericwrapper.cpp \
45 mboxwrapper.cpp 46 mboxwrapper.cpp \
47 sendmailprogress.cpp
46 48
47INTERFACES = editaccountsui.ui \ 49INTERFACES = editaccountsui.ui \
48 selectmailtypeui.ui \ 50 selectmailtypeui.ui \
49 imapconfigui.ui \ 51 imapconfigui.ui \
50 pop3configui.ui \ 52 pop3configui.ui \
51 nntpconfigui.ui \ 53 nntpconfigui.ui \
52 smtpconfigui.ui \ 54 smtpconfigui.ui \
53 addresspickerui.ui \ 55 addresspickerui.ui \
54 logindialogui.ui \ 56 logindialogui.ui \
55 composemailui.ui \ 57 composemailui.ui \
56 settingsdialogui.ui \ 58 settingsdialogui.ui \
57 statuswidgetui.ui 59 statuswidgetui.ui \
60 sendmailprogressui.ui
58 61
59INCLUDEPATH += $(OPIEDIR)/include 62INCLUDEPATH += $(OPIEDIR)/include
60 63
61CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 64CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
62contains( CONFTEST, y ){ 65contains( CONFTEST, y ){
63 LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv 66 LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv
64}else{ 67}else{
65 LIBS += -lqpe -letpan -lssl -lcrypto -lopie 68 LIBS += -lqpe -letpan -lssl -lcrypto -lopie
66} 69}
67 70
68TARGET = opiemail 71TARGET = opiemail
69 72
diff --git a/noncore/net/mail/sendmailprogress.cpp b/noncore/net/mail/sendmailprogress.cpp
new file mode 100644
index 0000000..13ddd37
--- a/dev/null
+++ b/noncore/net/mail/sendmailprogress.cpp
@@ -0,0 +1,48 @@
1#include "sendmailprogress.h"
2#include <qprogressbar.h>
3#include <qlabel.h>
4#include <qstring.h>
5
6progressMailSend::progressMailSend(QWidget*parent, const char * name)
7 :progressMailSendUI(parent,name,false),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0)
8{
9}
10
11progressMailSend::~progressMailSend()
12{
13}
14
15void progressMailSend::setMaxMails(unsigned int aMaxMails)
16{
17 m_max_mail = aMaxMails;
18 allMailProgressBar->setTotalSteps(aMaxMails);
19 setMails();
20}
21
22void progressMailSend::setCurrentMails(unsigned int aCurrent)
23{
24 m_current_mail = aCurrent;
25 allMailProgressBar->setProgress(aCurrent);
26 setMails();
27}
28
29void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax)
30{
31 m_current_single = aCurrent;
32 m_max_single = aMax;
33 setSingle();
34}
35
36void progressMailSend::setSingle()
37{
38 QString text = QString(tr("%1 of %2 bytes send")).arg(m_current_single).arg(m_max_single);
39 singleMailLabel->setText(text);
40 singleMailProgressBar->setTotalSteps(m_max_single);
41 singleMailProgressBar->setProgress(m_current_single);
42}
43
44void progressMailSend::setMails()
45{
46 QString text = QString(tr("Sending mail %1 of %2")).arg(m_current_single+1).arg(m_max_single);
47 allMailLabel->setText(text);
48}
diff --git a/noncore/net/mail/sendmailprogress.h b/noncore/net/mail/sendmailprogress.h
new file mode 100644
index 0000000..5b7d33b
--- a/dev/null
+++ b/noncore/net/mail/sendmailprogress.h
@@ -0,0 +1,19 @@
1#include "sendmailprogressui.h"
2
3class progressMailSend:public progressMailSendUI
4{
5 Q_OBJECT
6public:
7 progressMailSend(QWidget*parent = 0, const char * name = 0);
8 ~progressMailSend();
9
10 void setMaxMails(unsigned int aMaxMails);
11 void setCurrentMails(unsigned int aCurrent);
12
13 void setSingleMail(unsigned int aCurrent,unsigned int aMax);
14
15protected:
16 unsigned m_current_mail,m_current_single,m_max_mail,m_max_single;
17 void setSingle();
18 void setMails();
19};
diff --git a/noncore/net/mail/sendmailprogressui.ui b/noncore/net/mail/sendmailprogressui.ui
new file mode 100644
index 0000000..b90b088
--- a/dev/null
+++ b/noncore/net/mail/sendmailprogressui.ui
@@ -0,0 +1,110 @@
1<!DOCTYPE UI><UI>
2<class>progressMailSendUI</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>progressMailSendUI</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>316</width>
15 <height>266</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Sending mail</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <widget>
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>singleMailLabel</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>Progress of mail</string>
46 </property>
47 <property stdset="1">
48 <name>alignment</name>
49 <set>AlignCenter</set>
50 </property>
51 <property>
52 <name>hAlign</name>
53 </property>
54 </widget>
55 <widget>
56 <class>QProgressBar</class>
57 <property stdset="1">
58 <name>name</name>
59 <cstring>singleMailProgressBar</cstring>
60 </property>
61 </widget>
62 <widget>
63 <class>QLabel</class>
64 <property stdset="1">
65 <name>name</name>
66 <cstring>allMailLabel</cstring>
67 </property>
68 <property stdset="1">
69 <name>text</name>
70 <string>Sending mail</string>
71 </property>
72 <property stdset="1">
73 <name>alignment</name>
74 <set>AlignCenter</set>
75 </property>
76 <property>
77 <name>hAlign</name>
78 </property>
79 </widget>
80 <widget>
81 <class>QProgressBar</class>
82 <property stdset="1">
83 <name>name</name>
84 <cstring>allMailProgressBar</cstring>
85 </property>
86 </widget>
87 <spacer>
88 <property>
89 <name>name</name>
90 <cstring>Spacer6</cstring>
91 </property>
92 <property stdset="1">
93 <name>orientation</name>
94 <enum>Vertical</enum>
95 </property>
96 <property stdset="1">
97 <name>sizeType</name>
98 <enum>Expanding</enum>
99 </property>
100 <property>
101 <name>sizeHint</name>
102 <size>
103 <width>20</width>
104 <height>20</height>
105 </size>
106 </property>
107 </spacer>
108 </vbox>
109</widget>
110</UI>
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp
index b81a87f..53c0af5 100644
--- a/noncore/net/mail/smtpwrapper.cpp
+++ b/noncore/net/mail/smtpwrapper.cpp
@@ -6,24 +6,27 @@
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 <libetpan/libetpan.h> 10#include <libetpan/libetpan.h>
11 11
12#include "smtpwrapper.h" 12#include "smtpwrapper.h"
13#include "mailwrapper.h" 13#include "mailwrapper.h"
14#include "mboxwrapper.h" 14#include "mboxwrapper.h"
15#include "logindialog.h" 15#include "logindialog.h"
16#include "mailtypes.h" 16#include "mailtypes.h"
17#include "defines.h" 17#include "defines.h"
18#include "sendmailprogress.h"
19
20progressMailSend*SMTPwrapper::sendProgress = 0;
18 21
19SMTPwrapper::SMTPwrapper( Settings *s ) 22SMTPwrapper::SMTPwrapper( Settings *s )
20 : QObject() 23 : QObject()
21{ 24{
22 settings = s; 25 settings = s;
23} 26}
24 27
25QString SMTPwrapper::mailsmtpError( int errnum ) 28QString SMTPwrapper::mailsmtpError( int errnum )
26{ 29{
27 switch ( errnum ) { 30 switch ( errnum ) {
28 case MAILSMTP_NO_ERROR: 31 case MAILSMTP_NO_ERROR:
29 return tr( "No error" ); 32 return tr( "No error" );
@@ -511,25 +514,28 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size )
511 msg+=message; 514 msg+=message;
512 memset(message,0,4096); 515 memset(message,0,4096);
513 } 516 }
514 delete message; 517 delete message;
515 *data = (char*)malloc(msg.length()+1*sizeof(char)); 518 *data = (char*)malloc(msg.length()+1*sizeof(char));
516 memset(*data,0,msg.length()+1); 519 memset(*data,0,msg.length()+1);
517 memcpy(*data,msg.ascii(),msg.length()); 520 memcpy(*data,msg.ascii(),msg.length());
518 *size=msg.length(); 521 *size=msg.length();
519} 522}
520 523
521void SMTPwrapper::progress( size_t current, size_t maximum ) 524void SMTPwrapper::progress( size_t current, size_t maximum )
522{ 525{
523// qDebug( "Current: %i of %i", current, maximum ); 526 if (SMTPwrapper::sendProgress) {
527 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
528 qDebug("%u of %u",current,maximum);
529 }
524} 530}
525 531
526void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 532void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
527{ 533{
528 if (!mail) return; 534 if (!mail) return;
529 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 535 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
530 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 536 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
531 wrap->storeMessage(mail,length,box); 537 wrap->storeMessage(mail,length,box);
532 delete wrap; 538 delete wrap;
533} 539}
534 540
535void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 541void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
@@ -636,27 +642,34 @@ free_mem:
636} 642}
637 643
638void SMTPwrapper::sendMail(const Mail&mail,bool later ) 644void SMTPwrapper::sendMail(const Mail&mail,bool later )
639{ 645{
640 mailmime * mimeMail; 646 mailmime * mimeMail;
641 647
642 SMTPaccount *smtp = getAccount(mail.getName()); 648 SMTPaccount *smtp = getAccount(mail.getName());
643 649
644 mimeMail = createMimeMail(mail ); 650 mimeMail = createMimeMail(mail );
645 if ( mimeMail == NULL ) { 651 if ( mimeMail == NULL ) {
646 qDebug( "sendMail: error creating mime mail" ); 652 qDebug( "sendMail: error creating mime mail" );
647 } else { 653 } else {
654 sendProgress = new progressMailSend();
655 sendProgress->showMaximized();
656 sendProgress->show();
657 qApp->processEvents(10);
648 smtpSend( mimeMail,later,smtp); 658 smtpSend( mimeMail,later,smtp);
649 mailmime_free( mimeMail ); 659 mailmime_free( mimeMail );
650 qDebug("Clean up done"); 660 qDebug("Clean up done");
661 sendProgress->hide();
662 delete sendProgress;
663 sendProgress = 0;
651 } 664 }
652} 665}
653 666
654int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 667int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
655{ 668{
656 char*data = 0; 669 char*data = 0;
657 size_t length = 0; 670 size_t length = 0;
658 size_t curTok = 0; 671 size_t curTok = 0;
659 mailimf_fields *fields = 0; 672 mailimf_fields *fields = 0;
660 mailimf_field*ffrom = 0; 673 mailimf_field*ffrom = 0;
661 clist *rcpts = 0; 674 clist *rcpts = 0;
662 char*from = 0; 675 char*from = 0;
@@ -664,24 +677,25 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
664 wrap->fetchRawBody(*which,&data,&length); 677 wrap->fetchRawBody(*which,&data,&length);
665 if (!data) return 0; 678 if (!data) return 0;
666 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 679 int err = mailimf_fields_parse( data, length, &curTok, &fields );
667 if (err != MAILIMF_NO_ERROR) { 680 if (err != MAILIMF_NO_ERROR) {
668 free(data); 681 free(data);
669 delete wrap; 682 delete wrap;
670 return 0; 683 return 0;
671 } 684 }
672 685
673 rcpts = createRcptList( fields ); 686 rcpts = createRcptList( fields );
674 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 687 ffrom = getField(fields, MAILIMF_FIELD_FROM );
675 from = getFrom(ffrom); 688 from = getFrom(ffrom);
689
676 qDebug("Size: %i vs. %i",length,strlen(data)); 690 qDebug("Size: %i vs. %i",length,strlen(data));
677 if (rcpts && from) { 691 if (rcpts && from) {
678 return smtpSend(from,rcpts,data,strlen(data),smtp ); 692 return smtpSend(from,rcpts,data,strlen(data),smtp );
679 } 693 }
680 return 0; 694 return 0;
681} 695}
682 696
683/* this is a special fun */ 697/* this is a special fun */
684void SMTPwrapper::flushOutbox(SMTPaccount*smtp) 698void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
685{ 699{
686 if (!smtp) return; 700 if (!smtp) return;
687 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 701 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h
index c0dcc11..baa353b 100644
--- a/noncore/net/mail/smtpwrapper.h
+++ b/noncore/net/mail/smtpwrapper.h
@@ -9,55 +9,57 @@
9 9
10#include "settings.h" 10#include "settings.h"
11 11
12class Mail; 12class Mail;
13class MBOXwrapper; 13class MBOXwrapper;
14class RecMail; 14class RecMail;
15class Attachment; 15class Attachment;
16struct mailimf_fields; 16struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend;
21 22
22class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
23{ 24{
24 Q_OBJECT 25 Q_OBJECT
25 26
26public: 27public:
27 SMTPwrapper( Settings *s ); 28 SMTPwrapper( Settings *s );
28 virtual ~SMTPwrapper(){} 29 virtual ~SMTPwrapper(){}
29 void sendMail(const Mail& mail,bool later=false ); 30 void sendMail(const Mail& mail,bool later=false );
30 void flushOutbox(SMTPaccount*smtp); 31 void flushOutbox(SMTPaccount*smtp);
31 32
33 static progressMailSend*sendProgress;
32protected: 34protected:
33 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
34 mailimf_fields *createImfFields(const Mail &mail ); 36 mailimf_fields *createImfFields(const Mail &mail );
35 mailmime *createMimeMail(const Mail&mail ); 37 mailmime *createMimeMail(const Mail&mail );
36 38
37 mailimf_address_list *parseAddresses(const QString&addr ); 39 mailimf_address_list *parseAddresses(const QString&addr );
38 void addFileParts( mailmime *message,const QList<Attachment>&files ); 40 void addFileParts( mailmime *message,const QList<Attachment>&files );
39 mailmime *buildTxtPart(const QString&str ); 41 mailmime *buildTxtPart(const QString&str );
40 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
41 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); 43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
42 clist *createRcptList( mailimf_fields *fields ); 44 clist *createRcptList( mailimf_fields *fields );
43 SMTPaccount *getAccount(const QString&from ); 45 SMTPaccount *getAccount(const QString&from );
44 void writeToFile(const QString&file, mailmime *mail ); 46 void writeToFile(const QString&file, mailmime *mail );
45 void readFromFile(const QString&file, char **data, size_t *size ); 47 void readFromFile(const QString&file, char **data, size_t *size );
46 48
47 static void storeMail(char*mail, size_t length, const QString&box); 49 static void storeMail(char*mail, size_t length, const QString&box);
48 static QString mailsmtpError( int err ); 50 static QString mailsmtpError( int err );
49 static QString getTmpFile(); 51 static QString getTmpFile();
50 static void progress( size_t current, size_t maximum ); 52 static void progress( size_t current, size_t maximum );
51 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 53 static void addRcpts( clist *list, mailimf_address_list *addr_list );
52 static char *getFrom( mailmime *mail ); 54 static char *getFrom( mailmime *mail );
53 static char *getFrom( mailimf_field *ffrom); 55 static char *getFrom( mailimf_field *ffrom);
54 static mailimf_field *getField( mailimf_fields *fields, int type ); 56 static mailimf_field *getField( mailimf_fields *fields, int type );
55 static 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 );
56 58
57 void storeMail(mailmime*mail, const QString&box); 59 void storeMail(mailmime*mail, const QString&box);
58 Settings *settings; 60 Settings *settings;
59 61
60 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); 62 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
61}; 63};
62 64
63#endif 65#endif