Diffstat (limited to 'noncore/net/mail/libmailwrapper/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index afc5618..86673aa 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -303,53 +303,53 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | |||
303 | result = 0; | 303 | result = 0; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (!result) { | 306 | if (!result) { |
307 | storeFailedMail(data,size,failuretext); | 307 | storeFailedMail(data,size,failuretext); |
308 | } else { | 308 | } else { |
309 | qDebug( "Mail sent." ); | 309 | qDebug( "Mail sent." ); |
310 | storeMail(data,size,"Sent"); | 310 | storeMail(data,size,"Sent"); |
311 | } | 311 | } |
312 | return result; | 312 | return result; |
313 | } | 313 | } |
314 | 314 | ||
315 | void SMTPwrapper::sendMail(const Opie::osmart_pointer<Mail>&mail,bool later ) | 315 | void SMTPwrapper::sendMail(const Opie::OSmartPointer<Mail>&mail,bool later ) |
316 | { | 316 | { |
317 | mailmime * mimeMail; | 317 | mailmime * mimeMail; |
318 | 318 | ||
319 | mimeMail = createMimeMail(mail ); | 319 | mimeMail = createMimeMail(mail ); |
320 | if ( mimeMail == NULL ) { | 320 | if ( mimeMail == NULL ) { |
321 | qDebug( "sendMail: error creating mime mail" ); | 321 | qDebug( "sendMail: error creating mime mail" ); |
322 | } else { | 322 | } else { |
323 | sendProgress = new progressMailSend(); | 323 | sendProgress = new progressMailSend(); |
324 | sendProgress->show(); | 324 | sendProgress->show(); |
325 | sendProgress->setMaxMails(1); | 325 | sendProgress->setMaxMails(1); |
326 | smtpSend( mimeMail,later); | 326 | smtpSend( mimeMail,later); |
327 | qDebug("Clean up done"); | 327 | qDebug("Clean up done"); |
328 | sendProgress->hide(); | 328 | sendProgress->hide(); |
329 | delete sendProgress; | 329 | delete sendProgress; |
330 | sendProgress = 0; | 330 | sendProgress = 0; |
331 | mailmime_free( mimeMail ); | 331 | mailmime_free( mimeMail ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { | 335 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { |
336 | size_t curTok = 0; | 336 | size_t curTok = 0; |
337 | mailimf_fields *fields = 0; | 337 | mailimf_fields *fields = 0; |
338 | mailimf_field*ffrom = 0; | 338 | mailimf_field*ffrom = 0; |
339 | clist *rcpts = 0; | 339 | clist *rcpts = 0; |
340 | char*from = 0; | 340 | char*from = 0; |
341 | int res = 0; | 341 | int res = 0; |
342 | 342 | ||
343 | encodedString * data = wrap->fetchRawBody(*which); | 343 | encodedString * data = wrap->fetchRawBody(which); |
344 | if (!data) | 344 | if (!data) |
345 | return 0; | 345 | return 0; |
346 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 346 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
347 | if (err != MAILIMF_NO_ERROR) { | 347 | if (err != MAILIMF_NO_ERROR) { |
348 | delete data; | 348 | delete data; |
349 | delete wrap; | 349 | delete wrap; |
350 | return 0; | 350 | return 0; |
351 | } | 351 | } |
352 | 352 | ||
353 | rcpts = createRcptList( fields ); | 353 | rcpts = createRcptList( fields ); |
354 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 354 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
355 | from = getFrom(ffrom); | 355 | from = getFrom(ffrom); |
@@ -382,26 +382,26 @@ bool SMTPwrapper::flushOutbox() { | |||
382 | qDebug("No smtp account given"); | 382 | qDebug("No smtp account given"); |
383 | return false; | 383 | return false; |
384 | } | 384 | } |
385 | 385 | ||
386 | bool reset_user_value = false; | 386 | bool reset_user_value = false; |
387 | QString localfolders = AbstractMail::defaultLocalfolder(); | 387 | QString localfolders = AbstractMail::defaultLocalfolder(); |
388 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 388 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
389 | if (!wrap) { | 389 | if (!wrap) { |
390 | qDebug("memory error"); | 390 | qDebug("memory error"); |
391 | return false; | 391 | return false; |
392 | } | 392 | } |
393 | QString oldPw, oldUser; | 393 | QString oldPw, oldUser; |
394 | QList<RecMail> mailsToSend; | 394 | QValueList<RecMailP> mailsToSend; |
395 | QList<RecMail> mailsToRemove; | 395 | QValueList<RecMailP> mailsToRemove; |
396 | QString mbox("Outgoing"); | 396 | QString mbox("Outgoing"); |
397 | wrap->listMessages(mbox,mailsToSend); | 397 | wrap->listMessages(mbox,mailsToSend); |
398 | if (mailsToSend.count()==0) { | 398 | if (mailsToSend.count()==0) { |
399 | delete wrap; | 399 | delete wrap; |
400 | qDebug("No mails to send"); | 400 | qDebug("No mails to send"); |
401 | return false; | 401 | return false; |
402 | } | 402 | } |
403 | 403 | ||
404 | oldPw = m_SmtpAccount->getPassword(); | 404 | oldPw = m_SmtpAccount->getPassword(); |
405 | oldUser = m_SmtpAccount->getUser(); | 405 | oldUser = m_SmtpAccount->getUser(); |
406 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 406 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
407 | // get'em | 407 | // get'em |
@@ -412,45 +412,43 @@ bool SMTPwrapper::flushOutbox() { | |||
412 | // ok | 412 | // ok |
413 | user = login.getUser().latin1(); | 413 | user = login.getUser().latin1(); |
414 | pass = login.getPassword().latin1(); | 414 | pass = login.getPassword().latin1(); |
415 | reset_user_value = true; | 415 | reset_user_value = true; |
416 | m_SmtpAccount->setUser(user); | 416 | m_SmtpAccount->setUser(user); |
417 | m_SmtpAccount->setPassword(pass); | 417 | m_SmtpAccount->setPassword(pass); |
418 | } else { | 418 | } else { |
419 | return true; | 419 | return true; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | mailsToSend.setAutoDelete(false); | ||
425 | sendProgress = new progressMailSend(); | 424 | sendProgress = new progressMailSend(); |
426 | sendProgress->show(); | 425 | sendProgress->show(); |
427 | sendProgress->setMaxMails(mailsToSend.count()); | 426 | sendProgress->setMaxMails(mailsToSend.count()); |
428 | 427 | ||
429 | while (mailsToSend.count()>0) { | 428 | while (mailsToSend.count()>0) { |
430 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { | 429 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { |
431 | QMessageBox::critical(0,tr("Error sending mail"), | 430 | QMessageBox::critical(0,tr("Error sending mail"), |
432 | tr("Error sending queued mail - breaking")); | 431 | tr("Error sending queued mail - breaking")); |
433 | returnValue = false; | 432 | returnValue = false; |
434 | break; | 433 | break; |
435 | } | 434 | } |
436 | mailsToRemove.append(mailsToSend.at(0)); | 435 | mailsToRemove.append((*mailsToSend.begin())); |
437 | mailsToSend.removeFirst(); | 436 | mailsToSend.remove(mailsToSend.begin()); |
438 | sendProgress->setCurrentMails(mailsToRemove.count()); | 437 | sendProgress->setCurrentMails(mailsToRemove.count()); |
439 | } | 438 | } |
440 | if (reset_user_value) { | 439 | if (reset_user_value) { |
441 | m_SmtpAccount->setUser(oldUser); | 440 | m_SmtpAccount->setUser(oldUser); |
442 | m_SmtpAccount->setPassword(oldPw); | 441 | m_SmtpAccount->setPassword(oldPw); |
443 | } | 442 | } |
444 | Config cfg( "mail" ); | 443 | Config cfg( "mail" ); |
445 | cfg.setGroup( "Status" ); | 444 | cfg.setGroup( "Status" ); |
446 | m_queuedMail = 0; | 445 | m_queuedMail = 0; |
447 | cfg.writeEntry( "outgoing", m_queuedMail ); | 446 | cfg.writeEntry( "outgoing", m_queuedMail ); |
448 | emit queuedMails( m_queuedMail ); | 447 | emit queuedMails( m_queuedMail ); |
449 | sendProgress->hide(); | 448 | sendProgress->hide(); |
450 | delete sendProgress; | 449 | delete sendProgress; |
451 | sendProgress = 0; | 450 | sendProgress = 0; |
452 | wrap->deleteMails(mbox,mailsToRemove); | 451 | wrap->deleteMails(mbox,mailsToRemove); |
453 | mailsToSend.setAutoDelete(true); | ||
454 | delete wrap; | 452 | delete wrap; |
455 | return returnValue; | 453 | return returnValue; |
456 | } | 454 | } |