Diffstat (limited to 'noncore/net/mail/libmailwrapper/smtpwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index e2cea7a..ba78c3b 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -106,25 +106,25 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later) { | |||
106 | 106 | ||
107 | from = data = 0; | 107 | from = data = 0; |
108 | 108 | ||
109 | mailmessage * msg = 0; | 109 | mailmessage * msg = 0; |
110 | msg = mime_message_init(mail); | 110 | msg = mime_message_init(mail); |
111 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 111 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
112 | int r = mailmessage_fetch(msg,&data,&size); | 112 | int r = mailmessage_fetch(msg,&data,&size); |
113 | mime_message_detach_mime(msg); | 113 | mime_message_detach_mime(msg); |
114 | mailmessage_free(msg); | 114 | mailmessage_free(msg); |
115 | if (r != MAIL_NO_ERROR || !data) { | 115 | if (r != MAIL_NO_ERROR || !data) { |
116 | if (data) | 116 | if (data) |
117 | free(data); | 117 | free(data); |
118 | qDebug("Error fetching mime..."); | 118 | odebug << "Error fetching mime..." << oendl; |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | msg = 0; | 121 | msg = 0; |
122 | if (later) { | 122 | if (later) { |
123 | storeMail(data,size,"Outgoing"); | 123 | storeMail(data,size,"Outgoing"); |
124 | if (data) | 124 | if (data) |
125 | free( data ); | 125 | free( data ); |
126 | Config cfg( "mail" ); | 126 | Config cfg( "mail" ); |
127 | cfg.setGroup( "Status" ); | 127 | cfg.setGroup( "Status" ); |
128 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 128 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
129 | emit queuedMails( m_queuedMail ); | 129 | emit queuedMails( m_queuedMail ); |
130 | return; | 130 | return; |
@@ -199,34 +199,34 @@ void SMTPwrapper::connect_server() | |||
199 | } | 199 | } |
200 | int result = 1; | 200 | int result = 1; |
201 | port = m_SmtpAccount->getPort().toUInt(); | 201 | port = m_SmtpAccount->getPort().toUInt(); |
202 | 202 | ||
203 | m_smtp = mailsmtp_new( 20, &progress ); | 203 | m_smtp = mailsmtp_new( 20, &progress ); |
204 | if ( m_smtp == NULL ) { | 204 | if ( m_smtp == NULL ) { |
205 | /* no failure message cause this happens when problems with memory - than we | 205 | /* no failure message cause this happens when problems with memory - than we |
206 | we can not display any messagebox */ | 206 | we can not display any messagebox */ |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | int err = MAILSMTP_NO_ERROR; | 210 | int err = MAILSMTP_NO_ERROR; |
211 | qDebug( "Servername %s at port %i", server, port ); | 211 | odebug << "Servername " << server << " at port " << port << "" << oendl; |
212 | if ( ssl ) { | 212 | if ( ssl ) { |
213 | qDebug( "SSL session" ); | 213 | odebug << "SSL session" << oendl; |
214 | err = mailsmtp_ssl_connect( m_smtp, server, port ); | 214 | err = mailsmtp_ssl_connect( m_smtp, server, port ); |
215 | } else { | 215 | } else { |
216 | qDebug( "No SSL session" ); | 216 | odebug << "No SSL session" << oendl; |
217 | err = mailsmtp_socket_connect( m_smtp, server, port ); | 217 | err = mailsmtp_socket_connect( m_smtp, server, port ); |
218 | } | 218 | } |
219 | if ( err != MAILSMTP_NO_ERROR ) { | 219 | if ( err != MAILSMTP_NO_ERROR ) { |
220 | qDebug("Error init connection"); | 220 | odebug << "Error init connection" << oendl; |
221 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 221 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
222 | result = 0; | 222 | result = 0; |
223 | } | 223 | } |
224 | 224 | ||
225 | /* switch to tls after init 'cause there it will send the ehlo */ | 225 | /* switch to tls after init 'cause there it will send the ehlo */ |
226 | if (result) { | 226 | if (result) { |
227 | err = mailsmtp_init( m_smtp ); | 227 | err = mailsmtp_init( m_smtp ); |
228 | if (err != MAILSMTP_NO_ERROR) { | 228 | if (err != MAILSMTP_NO_ERROR) { |
229 | result = 0; | 229 | result = 0; |
230 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 230 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
231 | } | 231 | } |
232 | } | 232 | } |
@@ -237,47 +237,47 @@ void SMTPwrapper::connect_server() | |||
237 | try_tls = false; | 237 | try_tls = false; |
238 | } else { | 238 | } else { |
239 | err = mailesmtp_ehlo(m_smtp); | 239 | err = mailesmtp_ehlo(m_smtp); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | if (!try_tls && force_tls) { | 243 | if (!try_tls && force_tls) { |
244 | result = 0; | 244 | result = 0; |
245 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); | 245 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); |
246 | } | 246 | } |
247 | 247 | ||
248 | if (result==1 && m_SmtpAccount->getLogin() ) { | 248 | if (result==1 && m_SmtpAccount->getLogin() ) { |
249 | qDebug("smtp with auth"); | 249 | odebug << "smtp with auth" << oendl; |
250 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { | 250 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { |
251 | // get'em | 251 | // get'em |
252 | LoginDialog login( m_SmtpAccount->getUser(), | 252 | LoginDialog login( m_SmtpAccount->getUser(), |
253 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 253 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
254 | login.show(); | 254 | login.show(); |
255 | if ( QDialog::Accepted == login.exec() ) { | 255 | if ( QDialog::Accepted == login.exec() ) { |
256 | // ok | 256 | // ok |
257 | user = login.getUser().latin1(); | 257 | user = login.getUser().latin1(); |
258 | pass = login.getPassword().latin1(); | 258 | pass = login.getPassword().latin1(); |
259 | } else { | 259 | } else { |
260 | result = 0; | 260 | result = 0; |
261 | failuretext=tr("Login aborted - storing mail to localfolder"); | 261 | failuretext=tr("Login aborted - storing mail to localfolder"); |
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | user = m_SmtpAccount->getUser().latin1(); | 264 | user = m_SmtpAccount->getUser().latin1(); |
265 | pass = m_SmtpAccount->getPassword().latin1(); | 265 | pass = m_SmtpAccount->getPassword().latin1(); |
266 | } | 266 | } |
267 | qDebug( "session->auth: %i", m_smtp->auth); | 267 | odebug << "session->auth: " << m_smtp->auth << "" << oendl; |
268 | if (result) { | 268 | if (result) { |
269 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); | 269 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); |
270 | if ( err == MAILSMTP_NO_ERROR ) { | 270 | if ( err == MAILSMTP_NO_ERROR ) { |
271 | qDebug("auth ok"); | 271 | odebug << "auth ok" << oendl; |
272 | } else { | 272 | } else { |
273 | failuretext = tr("Authentification failed"); | 273 | failuretext = tr("Authentification failed"); |
274 | result = 0; | 274 | result = 0; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | void SMTPwrapper::disc_server() | 280 | void SMTPwrapper::disc_server() |
281 | { | 281 | { |
282 | if (m_smtp) { | 282 | if (m_smtp) { |
283 | mailsmtp_quit( m_smtp ); | 283 | mailsmtp_quit( m_smtp ); |
@@ -298,43 +298,43 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | |||
298 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 298 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
299 | if ( err != MAILSMTP_NO_ERROR ) { | 299 | if ( err != MAILSMTP_NO_ERROR ) { |
300 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 300 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); |
301 | result = 0; | 301 | result = 0; |
302 | } | 302 | } |
303 | } else { | 303 | } else { |
304 | result = 0; | 304 | result = 0; |
305 | } | 305 | } |
306 | 306 | ||
307 | if (!result) { | 307 | if (!result) { |
308 | storeFailedMail(data,size,failuretext); | 308 | storeFailedMail(data,size,failuretext); |
309 | } else { | 309 | } else { |
310 | qDebug( "Mail sent." ); | 310 | odebug << "Mail sent." << oendl; |
311 | storeMail(data,size,"Sent"); | 311 | storeMail(data,size,"Sent"); |
312 | } | 312 | } |
313 | return result; | 313 | return result; |
314 | } | 314 | } |
315 | 315 | ||
316 | void SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) | 316 | void SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) |
317 | { | 317 | { |
318 | mailmime * mimeMail; | 318 | mailmime * mimeMail; |
319 | 319 | ||
320 | mimeMail = createMimeMail(mail ); | 320 | mimeMail = createMimeMail(mail ); |
321 | if ( mimeMail == NULL ) { | 321 | if ( mimeMail == NULL ) { |
322 | qDebug( "sendMail: error creating mime mail" ); | 322 | odebug << "sendMail: error creating mime mail" << oendl; |
323 | } else { | 323 | } else { |
324 | sendProgress = new progressMailSend(); | 324 | sendProgress = new progressMailSend(); |
325 | sendProgress->show(); | 325 | sendProgress->show(); |
326 | sendProgress->setMaxMails(1); | 326 | sendProgress->setMaxMails(1); |
327 | smtpSend( mimeMail,later); | 327 | smtpSend( mimeMail,later); |
328 | qDebug("Clean up done"); | 328 | odebug << "Clean up done" << oendl; |
329 | sendProgress->hide(); | 329 | sendProgress->hide(); |
330 | delete sendProgress; | 330 | delete sendProgress; |
331 | sendProgress = 0; | 331 | sendProgress = 0; |
332 | mailmime_free( mimeMail ); | 332 | mailmime_free( mimeMail ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | 336 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { |
337 | size_t curTok = 0; | 337 | size_t curTok = 0; |
338 | mailimf_fields *fields = 0; | 338 | mailimf_fields *fields = 0; |
339 | mailimf_field*ffrom = 0; | 339 | mailimf_field*ffrom = 0; |
340 | clist *rcpts = 0; | 340 | clist *rcpts = 0; |
@@ -369,45 +369,45 @@ int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | |||
369 | free(from); | 369 | free(from); |
370 | } | 370 | } |
371 | if (rcpts) { | 371 | if (rcpts) { |
372 | smtp_address_list_free( rcpts ); | 372 | smtp_address_list_free( rcpts ); |
373 | } | 373 | } |
374 | return res; | 374 | return res; |
375 | } | 375 | } |
376 | 376 | ||
377 | /* this is a special fun */ | 377 | /* this is a special fun */ |
378 | bool SMTPwrapper::flushOutbox() { | 378 | bool SMTPwrapper::flushOutbox() { |
379 | bool returnValue = true; | 379 | bool returnValue = true; |
380 | 380 | ||
381 | qDebug("Sending the queue"); | 381 | odebug << "Sending the queue" << oendl; |
382 | if (!m_SmtpAccount) { | 382 | if (!m_SmtpAccount) { |
383 | qDebug("No smtp account given"); | 383 | odebug << "No smtp account given" << oendl; |
384 | return false; | 384 | return false; |
385 | } | 385 | } |
386 | 386 | ||
387 | bool reset_user_value = false; | 387 | bool reset_user_value = false; |
388 | QString localfolders = AbstractMail::defaultLocalfolder(); | 388 | QString localfolders = AbstractMail::defaultLocalfolder(); |
389 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 389 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
390 | if (!wrap) { | 390 | if (!wrap) { |
391 | qDebug("memory error"); | 391 | odebug << "memory error" << oendl; |
392 | return false; | 392 | return false; |
393 | } | 393 | } |
394 | QString oldPw, oldUser; | 394 | QString oldPw, oldUser; |
395 | QValueList<RecMailP> mailsToSend; | 395 | QValueList<RecMailP> mailsToSend; |
396 | QValueList<RecMailP> mailsToRemove; | 396 | QValueList<RecMailP> mailsToRemove; |
397 | QString mbox("Outgoing"); | 397 | QString mbox("Outgoing"); |
398 | wrap->listMessages(mbox,mailsToSend); | 398 | wrap->listMessages(mbox,mailsToSend); |
399 | if (mailsToSend.count()==0) { | 399 | if (mailsToSend.count()==0) { |
400 | delete wrap; | 400 | delete wrap; |
401 | qDebug("No mails to send"); | 401 | odebug << "No mails to send" << oendl; |
402 | return false; | 402 | return false; |
403 | } | 403 | } |
404 | 404 | ||
405 | oldPw = m_SmtpAccount->getPassword(); | 405 | oldPw = m_SmtpAccount->getPassword(); |
406 | oldUser = m_SmtpAccount->getUser(); | 406 | oldUser = m_SmtpAccount->getUser(); |
407 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 407 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
408 | // get'em | 408 | // get'em |
409 | QString user,pass; | 409 | QString user,pass; |
410 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 410 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
411 | login.show(); | 411 | login.show(); |
412 | if ( QDialog::Accepted == login.exec() ) { | 412 | if ( QDialog::Accepted == login.exec() ) { |
413 | // ok | 413 | // ok |