Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-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 |
5 files changed, 195 insertions, 2 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 | |||
@@ -15,6 +15,9 @@ | |||
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() |
@@ -520,7 +523,10 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size ) | |||
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) |
@@ -645,9 +651,16 @@ void SMTPwrapper::sendMail(const Mail&mail,bool later ) | |||
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 | ||
@@ -673,6 +686,7 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
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 ); |
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 | |||
@@ -18,6 +18,7 @@ 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 | { |
@@ -29,6 +30,7 @@ public: | |||
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 ); |
@@ -52,7 +54,7 @@ protected: | |||
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; |