summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/smtpwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/smtpwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index dee1477..eb07ef1 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -1,54 +1,59 @@
1#include "smtpwrapper.h" 1#include "smtpwrapper.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3#include "abstractmail.h" 3#include "abstractmail.h"
4#include "logindialog.h" 4#include "logindialog.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include "sendmailprogress.h" 6#include "sendmailprogress.h"
7 7
8//#include <opie2/odebug.h> 8//#include <opie2/odebug.h>
9//#include <qt.h> 9//#include <qt.h>
10#include <qapplication.h> 10#include <qapplication.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include <qpe/config.h> 13#ifndef DESKTOP_VERSION
14//#include <qpe/config.h>
14#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
15 16#endif
16#include <libetpan/libetpan.h> 17#include <libetpan/libetpan.h>
17#include <klocale.h> 18#include <klocale.h>
19#include <kglobal.h>
20#include <kconfig.h>
18 21
19 22
20using namespace Opie::Core; 23using namespace Opie::Core;
21progressMailSend*SMTPwrapper::sendProgress = 0; 24progressMailSend*SMTPwrapper::sendProgress = 0;
22 25
23SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) 26SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
24 : Generatemail() 27 : Generatemail()
25{ 28{
26 m_SmtpAccount = aSmtp; 29 m_SmtpAccount = aSmtp;
27 Config cfg( "mail" ); 30 KConfig cfg( locateLocal("config", "kopiemail" ) );
28 cfg.setGroup( "Status" ); 31 cfg.setGroup( "Status" );
29 m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); 32 m_queuedMail = cfg.readNumEntry( "outgoing", 0 );
30 emit queuedMails( m_queuedMail ); 33 emit queuedMails( m_queuedMail );
31 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); 34 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) );
32 m_smtp = 0; 35 m_smtp = 0;
33} 36}
34 37
35SMTPwrapper::~SMTPwrapper() 38SMTPwrapper::~SMTPwrapper()
36{ 39{
37 disc_server(); 40 disc_server();
38} 41}
39 42
40void SMTPwrapper::emitQCop( int queued ) { 43void SMTPwrapper::emitQCop( int queued ) {
44#ifndef DESKTOP_VERSION
41 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); 45 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
42 env << queued; 46 env << queued;
47#endif
43} 48}
44 49
45QString SMTPwrapper::mailsmtpError( int errnum ) { 50QString SMTPwrapper::mailsmtpError( int errnum ) {
46 switch ( errnum ) { 51 switch ( errnum ) {
47 case MAILSMTP_NO_ERROR: 52 case MAILSMTP_NO_ERROR:
48 return i18n( "No error" ); 53 return i18n( "No error" );
49 case MAILSMTP_ERROR_UNEXPECTED_CODE: 54 case MAILSMTP_ERROR_UNEXPECTED_CODE:
50 return i18n( "Unexpected error code" ); 55 return i18n( "Unexpected error code" );
51 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
52 return i18n( "Service not available" ); 57 return i18n( "Service not available" );
53 case MAILSMTP_ERROR_STREAM: 58 case MAILSMTP_ERROR_STREAM:
54 return i18n( "Stream error" ); 59 return i18n( "Stream error" );
@@ -118,25 +123,25 @@ bool SMTPwrapper::smtpSend( mailmime *mail,bool later) {
118 mailmessage_free(msg); 123 mailmessage_free(msg);
119 if (r != MAIL_NO_ERROR || !data) { 124 if (r != MAIL_NO_ERROR || !data) {
120 if (data) 125 if (data)
121 free(data); 126 free(data);
122 qDebug("Error fetching mime... "); 127 qDebug("Error fetching mime... ");
123 return false; 128 return false;
124 } 129 }
125 msg = 0; 130 msg = 0;
126 if (later) { 131 if (later) {
127 storeMail(data,size,"Outgoing"); 132 storeMail(data,size,"Outgoing");
128 if (data) 133 if (data)
129 free( data ); 134 free( data );
130 Config cfg( "mail" ); 135 KConfig cfg( locateLocal("config", "kopiemail" ) );
131 cfg.setGroup( "Status" ); 136 cfg.setGroup( "Status" );
132 cfg.writeEntry( "outgoing", ++m_queuedMail ); 137 cfg.writeEntry( "outgoing", ++m_queuedMail );
133 emit queuedMails( m_queuedMail ); 138 emit queuedMails( m_queuedMail );
134 return true; 139 return true;
135 } 140 }
136 from = getFrom( mail ); 141 from = getFrom( mail );
137 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 142 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
138 bool result = smtpSend(from,rcpts,data,size); 143 bool result = smtpSend(from,rcpts,data,size);
139 if (data) { 144 if (data) {
140 free(data); 145 free(data);
141 } 146 }
142 if (from) { 147 if (from) {
@@ -438,24 +443,24 @@ bool SMTPwrapper::flushOutbox() {
438 i18n("Error sending queued mail - breaking")); 443 i18n("Error sending queued mail - breaking"));
439 returnValue = false; 444 returnValue = false;
440 break; 445 break;
441 } 446 }
442 mailsToRemove.append((*mailsToSend.begin())); 447 mailsToRemove.append((*mailsToSend.begin()));
443 mailsToSend.remove(mailsToSend.begin()); 448 mailsToSend.remove(mailsToSend.begin());
444 sendProgress->setCurrentMails(mailsToRemove.count()); 449 sendProgress->setCurrentMails(mailsToRemove.count());
445 } 450 }
446 if (reset_user_value) { 451 if (reset_user_value) {
447 m_SmtpAccount->setUser(oldUser); 452 m_SmtpAccount->setUser(oldUser);
448 m_SmtpAccount->setPassword(oldPw); 453 m_SmtpAccount->setPassword(oldPw);
449 } 454 }
450 Config cfg( "mail" ); 455 KConfig cfg( locateLocal("config", "kopiemail" ) );
451 cfg.setGroup( "Status" ); 456 cfg.setGroup( "Status" );
452 m_queuedMail = 0; 457 m_queuedMail = 0;
453 cfg.writeEntry( "outgoing", m_queuedMail ); 458 cfg.writeEntry( "outgoing", m_queuedMail );
454 emit queuedMails( m_queuedMail ); 459 emit queuedMails( m_queuedMail );
455 sendProgress->hide(); 460 sendProgress->hide();
456 delete sendProgress; 461 delete sendProgress;
457 sendProgress = 0; 462 sendProgress = 0;
458 wrap->deleteMails(mbox,mailsToRemove); 463 wrap->deleteMails(mbox,mailsToRemove);
459 delete wrap; 464 delete wrap;
460 return returnValue; 465 return returnValue;
461} 466}