author | alwin <alwin> | 2003-12-24 01:29:43 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-24 01:29:43 (UTC) |
commit | 242f7a04e3e4963a5606ac603d54a4f115de4a04 (patch) (unidiff) | |
tree | dd8578fbc812791dd7e5026a28710a8313cf5cf8 | |
parent | 7c720aabcad9b325dbf9910493e3c9fa1d63805e (diff) | |
download | opie-242f7a04e3e4963a5606ac603d54a4f115de4a04.zip opie-242f7a04e3e4963a5606ac603d54a4f115de4a04.tar.gz opie-242f7a04e3e4963a5606ac603d54a4f115de4a04.tar.bz2 |
tried to implement a progress dialog when sending mails. It doesn't work
(dialog will show but makes no updates, when using qApp->progressEvents(x)
dialog hides)
I don't know why - and I giving up for the moment.
-rw-r--r-- | noncore/net/mail/libmailwrapper/sendmailprogress.cpp | 48 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/sendmailprogress.h | 19 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/sendmailprogressui.ui | 110 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 16 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 9 | ||||
-rw-r--r-- | noncore/net/mail/sendmailprogress.cpp | 48 | ||||
-rw-r--r-- | noncore/net/mail/sendmailprogress.h | 19 | ||||
-rw-r--r-- | noncore/net/mail/sendmailprogressui.ui | 110 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 16 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.h | 4 |
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 | |||
6 | progressMailSend::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 | |||
11 | progressMailSend::~progressMailSend() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | void progressMailSend::setMaxMails(unsigned int aMaxMails) | ||
16 | { | ||
17 | m_max_mail = aMaxMails; | ||
18 | allMailProgressBar->setTotalSteps(aMaxMails); | ||
19 | setMails(); | ||
20 | } | ||
21 | |||
22 | void progressMailSend::setCurrentMails(unsigned int aCurrent) | ||
23 | { | ||
24 | m_current_mail = aCurrent; | ||
25 | allMailProgressBar->setProgress(aCurrent); | ||
26 | setMails(); | ||
27 | } | ||
28 | |||
29 | void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax) | ||
30 | { | ||
31 | m_current_single = aCurrent; | ||
32 | m_max_single = aMax; | ||
33 | setSingle(); | ||
34 | } | ||
35 | |||
36 | void 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 | |||
44 | void 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 | |||
3 | class progressMailSend:public progressMailSendUI | ||
4 | { | ||
5 | Q_OBJECT | ||
6 | public: | ||
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 | |||
15 | protected: | ||
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 | |||
@@ -12,12 +12,15 @@ | |||
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 | |||
20 | progressMailSend*SMTPwrapper::sendProgress = 0; | ||
18 | 21 | ||
19 | SMTPwrapper::SMTPwrapper( Settings *s ) | 22 | SMTPwrapper::SMTPwrapper( Settings *s ) |
20 | : QObject() | 23 | : QObject() |
21 | { | 24 | { |
22 | settings = s; | 25 | settings = s; |
23 | } | 26 | } |
@@ -517,13 +520,16 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) | |||
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 | ||
521 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 524 | void 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 | ||
526 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 532 | void 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/"); |
@@ -642,15 +648,22 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later ) | |||
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 | ||
654 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
655 | { | 668 | { |
656 | char*data = 0; | 669 | char*data = 0; |
@@ -670,12 +683,13 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
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 | } |
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 | |||
@@ -15,23 +15,25 @@ 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 | 22 | ||
22 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
23 | { | 24 | { |
24 | Q_OBJECT | 25 | Q_OBJECT |
25 | 26 | ||
26 | public: | 27 | public: |
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; | ||
32 | protected: | 34 | protected: |
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 ); |
@@ -49,13 +51,13 @@ protected: | |||
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 | }; |
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 | |||
@@ -17,13 +17,14 @@ HEADERS = defines.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 | ||
25 | SOURCES = main.cpp \ | 26 | SOURCES = 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 \ |
@@ -39,25 +40,27 @@ SOURCES = main.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 | ||
47 | INTERFACES = editaccountsui.ui \ | 49 | INTERFACES = 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 | ||
59 | INCLUDEPATH += $(OPIEDIR)/include | 62 | INCLUDEPATH += $(OPIEDIR)/include |
60 | 63 | ||
61 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 64 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
62 | contains( CONFTEST, y ){ | 65 | contains( CONFTEST, y ){ |
63 | LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv | 66 | LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv |
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 | |||
6 | progressMailSend::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 | |||
11 | progressMailSend::~progressMailSend() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | void progressMailSend::setMaxMails(unsigned int aMaxMails) | ||
16 | { | ||
17 | m_max_mail = aMaxMails; | ||
18 | allMailProgressBar->setTotalSteps(aMaxMails); | ||
19 | setMails(); | ||
20 | } | ||
21 | |||
22 | void progressMailSend::setCurrentMails(unsigned int aCurrent) | ||
23 | { | ||
24 | m_current_mail = aCurrent; | ||
25 | allMailProgressBar->setProgress(aCurrent); | ||
26 | setMails(); | ||
27 | } | ||
28 | |||
29 | void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax) | ||
30 | { | ||
31 | m_current_single = aCurrent; | ||
32 | m_max_single = aMax; | ||
33 | setSingle(); | ||
34 | } | ||
35 | |||
36 | void 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 | |||
44 | void 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 | |||
3 | class progressMailSend:public progressMailSendUI | ||
4 | { | ||
5 | Q_OBJECT | ||
6 | public: | ||
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 | |||
15 | protected: | ||
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 | |||
@@ -12,12 +12,15 @@ | |||
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 | |||
20 | progressMailSend*SMTPwrapper::sendProgress = 0; | ||
18 | 21 | ||
19 | SMTPwrapper::SMTPwrapper( Settings *s ) | 22 | SMTPwrapper::SMTPwrapper( Settings *s ) |
20 | : QObject() | 23 | : QObject() |
21 | { | 24 | { |
22 | settings = s; | 25 | settings = s; |
23 | } | 26 | } |
@@ -517,13 +520,16 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) | |||
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 | ||
521 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 524 | void 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 | ||
526 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 532 | void 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/"); |
@@ -642,15 +648,22 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later ) | |||
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 | ||
654 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 667 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) |
655 | { | 668 | { |
656 | char*data = 0; | 669 | char*data = 0; |
@@ -670,12 +683,13 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
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 | } |
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 | |||
@@ -15,23 +15,25 @@ 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 | 22 | ||
22 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
23 | { | 24 | { |
24 | Q_OBJECT | 25 | Q_OBJECT |
25 | 26 | ||
26 | public: | 27 | public: |
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; | ||
32 | protected: | 34 | protected: |
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 ); |
@@ -49,13 +51,13 @@ protected: | |||
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 | }; |