summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/smtpwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index d5a528c..dee1477 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -11,12 +11,13 @@
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qpe/qcopenvelope_qws.h> 14#include <qpe/qcopenvelope_qws.h>
15 15
16#include <libetpan/libetpan.h> 16#include <libetpan/libetpan.h>
17#include <klocale.h>
17 18
18 19
19using namespace Opie::Core; 20using namespace Opie::Core;
20progressMailSend*SMTPwrapper::sendProgress = 0; 21progressMailSend*SMTPwrapper::sendProgress = 0;
21 22
22SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) 23SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
@@ -41,49 +42,49 @@ void SMTPwrapper::emitQCop( int queued ) {
41 env << queued; 42 env << queued;
42} 43}
43 44
44QString SMTPwrapper::mailsmtpError( int errnum ) { 45QString SMTPwrapper::mailsmtpError( int errnum ) {
45 switch ( errnum ) { 46 switch ( errnum ) {
46 case MAILSMTP_NO_ERROR: 47 case MAILSMTP_NO_ERROR:
47 return tr( "No error" ); 48 return i18n( "No error" );
48 case MAILSMTP_ERROR_UNEXPECTED_CODE: 49 case MAILSMTP_ERROR_UNEXPECTED_CODE:
49 return tr( "Unexpected error code" ); 50 return i18n( "Unexpected error code" );
50 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 51 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
51 return tr( "Service not available" ); 52 return i18n( "Service not available" );
52 case MAILSMTP_ERROR_STREAM: 53 case MAILSMTP_ERROR_STREAM:
53 return tr( "Stream error" ); 54 return i18n( "Stream error" );
54 case MAILSMTP_ERROR_HOSTNAME: 55 case MAILSMTP_ERROR_HOSTNAME:
55 return tr( "gethostname() failed" ); 56 return i18n( "gethostname() failed" );
56 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 57 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
57 return tr( "Not implemented" ); 58 return i18n( "Not implemented" );
58 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 59 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
59 return tr( "Error, action not taken" ); 60 return i18n( "Error, action not taken" );
60 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 61 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
61 return tr( "Data exceeds storage allocation" ); 62 return i18n( "Data exceeds storage allocation" );
62 case MAILSMTP_ERROR_IN_PROCESSING: 63 case MAILSMTP_ERROR_IN_PROCESSING:
63 return tr( "Error in processing" ); 64 return i18n( "Error in processing" );
64 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: 65 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED:
65 return tr( "Starttls not supported" ); 66 return i18n( "Starttls not supported" );
66 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 67 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
67 // return tr( "Insufficient system storage" ); 68 // return i18n( "Insufficient system storage" );
68 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 69 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
69 return tr( "Mailbox unavailable" ); 70 return i18n( "Mailbox unavailable" );
70 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 71 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
71 return tr( "Mailbox name not allowed" ); 72 return i18n( "Mailbox name not allowed" );
72 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 73 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
73 return tr( "Bad command sequence" ); 74 return i18n( "Bad command sequence" );
74 case MAILSMTP_ERROR_USER_NOT_LOCAL: 75 case MAILSMTP_ERROR_USER_NOT_LOCAL:
75 return tr( "User not local" ); 76 return i18n( "User not local" );
76 case MAILSMTP_ERROR_TRANSACTION_FAILED: 77 case MAILSMTP_ERROR_TRANSACTION_FAILED:
77 return tr( "Transaction failed" ); 78 return i18n( "Transaction failed" );
78 case MAILSMTP_ERROR_MEMORY: 79 case MAILSMTP_ERROR_MEMORY:
79 return tr( "Memory error" ); 80 return i18n( "Memory error" );
80 case MAILSMTP_ERROR_CONNECTION_REFUSED: 81 case MAILSMTP_ERROR_CONNECTION_REFUSED:
81 return tr( "Connection refused" ); 82 return i18n( "Connection refused" );
82 default: 83 default:
83 return tr( "Unknown error code" ); 84 return i18n( "Unknown error code" );
84 } 85 }
85} 86}
86 87
87 88
88void SMTPwrapper::progress( size_t current, size_t maximum ) { 89void SMTPwrapper::progress( size_t current, size_t maximum ) {
89 if (SMTPwrapper::sendProgress) { 90 if (SMTPwrapper::sendProgress) {
@@ -149,14 +150,14 @@ bool SMTPwrapper::smtpSend( mailmime *mail,bool later) {
149void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) 150void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
150{ 151{
151 if (data) { 152 if (data) {
152 storeMail(data,size,"Sendfailed"); 153 storeMail(data,size,"Sendfailed");
153 } 154 }
154 if (failuremessage) { 155 if (failuremessage) {
155 QMessageBox::critical(0,tr("Error sending mail"), 156 QMessageBox::critical(0,i18n("Error sending mail"),
156 tr("<center>%1</center>").arg(failuremessage)); 157 i18n("<center>%1</center>").arg(failuremessage));
157 } 158 }
158} 159}
159 160
160int SMTPwrapper::start_smtp_tls() 161int SMTPwrapper::start_smtp_tls()
161{ 162{
162 if (!m_smtp) { 163 if (!m_smtp) {
@@ -218,22 +219,22 @@ void SMTPwrapper::connect_server()
218 } else { 219 } else {
219 ; // odebug << "No SSL session" << oendl; 220 ; // odebug << "No SSL session" << oendl;
220 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); 221 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port );
221 } 222 }
222 if ( err != MAILSMTP_NO_ERROR ) { 223 if ( err != MAILSMTP_NO_ERROR ) {
223 ; // odebug << "Error init connection" << oendl; 224 ; // odebug << "Error init connection" << oendl;
224 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); 225 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err));
225 result = 0; 226 result = 0;
226 } 227 }
227 228
228 /* switch to tls after init 'cause there it will send the ehlo */ 229 /* switch to tls after init 'cause there it will send the ehlo */
229 if (result) { 230 if (result) {
230 err = mailsmtp_init( m_smtp ); 231 err = mailsmtp_init( m_smtp );
231 if (err != MAILSMTP_NO_ERROR) { 232 if (err != MAILSMTP_NO_ERROR) {
232 result = 0; 233 result = 0;
233 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); 234 failuretext = i18n("Error init SMTP connection: %1").arg(mailsmtpError(err));
234 } 235 }
235 } 236 }
236 237
237 if (try_tls) { 238 if (try_tls) {
238 err = start_smtp_tls(); 239 err = start_smtp_tls();
239 if (err != MAILSMTP_NO_ERROR) { 240 if (err != MAILSMTP_NO_ERROR) {
@@ -242,13 +243,13 @@ void SMTPwrapper::connect_server()
242 err = mailesmtp_ehlo(m_smtp); 243 err = mailesmtp_ehlo(m_smtp);
243 } 244 }
244 } 245 }
245 246
246 if (!try_tls && force_tls) { 247 if (!try_tls && force_tls) {
247 result = 0; 248 result = 0;
248 failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); 249 failuretext = i18n("Error init SMTP tls: %1").arg(mailsmtpError(err));
249 } 250 }
250 251
251 if (result==1 && m_SmtpAccount->getLogin() ) { 252 if (result==1 && m_SmtpAccount->getLogin() ) {
252 ; // odebug << "smtp with auth" << oendl; 253 ; // odebug << "smtp with auth" << oendl;
253 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 254 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
254 // get'em 255 // get'em
@@ -258,25 +259,25 @@ void SMTPwrapper::connect_server()
258 if ( QDialog::Accepted == login.exec() ) { 259 if ( QDialog::Accepted == login.exec() ) {
259 // ok 260 // ok
260 user = login.getUser(); 261 user = login.getUser();
261 pass = login.getPassword(); 262 pass = login.getPassword();
262 } else { 263 } else {
263 result = 0; 264 result = 0;
264 failuretext=tr("Login aborted - storing mail to localfolder"); 265 failuretext=i18n("Login aborted - storing mail to localfolder");
265 } 266 }
266 } else { 267 } else {
267 user = m_SmtpAccount->getUser(); 268 user = m_SmtpAccount->getUser();
268 pass = m_SmtpAccount->getPassword(); 269 pass = m_SmtpAccount->getPassword();
269 } 270 }
270 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; 271 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
271 if (result) { 272 if (result) {
272 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); 273 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
273 if ( err == MAILSMTP_NO_ERROR ) { 274 if ( err == MAILSMTP_NO_ERROR ) {
274 ; // odebug << "auth ok" << oendl; 275 ; // odebug << "auth ok" << oendl;
275 } else { 276 } else {
276 failuretext = tr("Authentification failed"); 277 failuretext = i18n("Authentification failed");
277 result = 0; 278 result = 0;
278 } 279 }
279 } 280 }
280 } 281 }
281} 282}
282 283
@@ -297,13 +298,13 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
297 connect_server(); 298 connect_server();
298 299
299 result = 1; 300 result = 1;
300 if (m_smtp) { 301 if (m_smtp) {
301 err = mailsmtp_send( m_smtp, from, rcpts, data, size ); 302 err = mailsmtp_send( m_smtp, from, rcpts, data, size );
302 if ( err != MAILSMTP_NO_ERROR ) { 303 if ( err != MAILSMTP_NO_ERROR ) {
303 failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); 304 failuretext=i18n("Error sending mail: %1").arg(mailsmtpError(err));
304 result = 0; 305 result = 0;
305 } 306 }
306 } else { 307 } else {
307 result = 0; 308 result = 0;
308 } 309 }
309 310
@@ -430,14 +431,14 @@ bool SMTPwrapper::flushOutbox() {
430 sendProgress = new progressMailSend(); 431 sendProgress = new progressMailSend();
431 sendProgress->show(); 432 sendProgress->show();
432 sendProgress->setMaxMails(mailsToSend.count()); 433 sendProgress->setMaxMails(mailsToSend.count());
433 434
434 while (mailsToSend.count()>0) { 435 while (mailsToSend.count()>0) {
435 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { 436 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) {
436 QMessageBox::critical(0,tr("Error sending mail"), 437 QMessageBox::critical(0,i18n("Error sending mail"),
437 tr("Error sending queued mail - breaking")); 438 i18n("Error sending queued mail - breaking"));
438 returnValue = false; 439 returnValue = false;
439 break; 440 break;
440 } 441 }
441 mailsToRemove.append((*mailsToSend.begin())); 442 mailsToRemove.append((*mailsToSend.begin()));
442 mailsToSend.remove(mailsToSend.begin()); 443 mailsToSend.remove(mailsToSend.begin());
443 sendProgress->setCurrentMails(mailsToRemove.count()); 444 sendProgress->setCurrentMails(mailsToRemove.count());