summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp12
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp21
2 files changed, 27 insertions, 6 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index 49049f6..2c0f2d8 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -338,33 +338,35 @@ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name,
338 ComboBox1->insertItem( "Connect on secure port", 2 ); 338 ComboBox1->insertItem( "Connect on secure port", 2 );
339 ComboBox1->insertItem( "Run command instead", 3 ); 339 ComboBox1->insertItem( "Run command instead", 3 );
340 CommandEdit->hide(); 340 CommandEdit->hide();
341 fillValues(); 341 fillValues();
342 // ComboBox1->setCurrentItem( data->ConnectionType() ); 342 // ComboBox1->setCurrentItem( data->ConnectionType() );
343} 343}
344 344
345void IMAPconfig::slotConnectionToggle( int index ) 345void IMAPconfig::slotConnectionToggle( int index )
346{ 346{
347 if ( index == 2 ) 347 if ( index == 2 )
348 { 348 {
349 portLine->setText( IMAP_SSL_PORT ); 349 portLine->setText( IMAP_SSL_PORT );
350 CommandEdit->hide();
350 } 351 }
351 else if ( index == 3 ) 352 else if ( index == 3 )
352 { 353 {
353 portLine->setText( IMAP_PORT ); 354 portLine->setText( IMAP_PORT );
354 CommandEdit->show(); 355 CommandEdit->show();
355 } 356 }
356 else 357 else
357 { 358 {
358 portLine->setText( IMAP_PORT ); 359 portLine->setText( IMAP_PORT );
360 CommandEdit->hide();
359 } 361 }
360} 362}
361 363
362void IMAPconfig::fillValues() 364void IMAPconfig::fillValues()
363{ 365{
364 accountLine->setText( data->getAccountName() ); 366 accountLine->setText( data->getAccountName() );
365 serverLine->setText( data->getServer() ); 367 serverLine->setText( data->getServer() );
366 portLine->setText( data->getPort() ); 368 portLine->setText( data->getPort() );
367 ComboBox1->setCurrentItem( data->ConnectionType() ); 369 ComboBox1->setCurrentItem( data->ConnectionType() );
368 userLine->setText( data->getUser() ); 370 userLine->setText( data->getUser() );
369 passLine->setText( data->getPassword() ); 371 passLine->setText( data->getPassword() );
370 prefixLine->setText(data->getPrefix()); 372 prefixLine->setText(data->getPrefix());
@@ -419,33 +421,35 @@ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name,
419 ComboBox1->insertItem( "Run command instead", 3 ); 421 ComboBox1->insertItem( "Run command instead", 3 );
420 CommandEdit->hide(); 422 CommandEdit->hide();
421 fillValues(); 423 fillValues();
422 //ComboBox1->setCurrentItem( data->ConnectionType() ); 424 //ComboBox1->setCurrentItem( data->ConnectionType() );
423} 425}
424 426
425void POP3config::slotConnectionToggle( int index ) 427void POP3config::slotConnectionToggle( int index )
426{ 428{
427 // 2 is ssl connection 429 // 2 is ssl connection
428 if ( index == 2 ) 430 if ( index == 2 )
429 { 431 {
430 portLine->setText( POP3_SSL_PORT ); 432 portLine->setText( POP3_SSL_PORT );
433 CommandEdit->hide();
431 } 434 }
432 else if ( index == 3 ) 435 else if ( index == 3 )
433 { 436 {
434 portLine->setText( POP3_PORT ); 437 portLine->setText( POP3_PORT );
435 CommandEdit->show(); 438 CommandEdit->show();
436 } 439 }
437 else 440 else
438 { 441 {
439 portLine->setText( POP3_PORT ); 442 portLine->setText( POP3_PORT );
443 CommandEdit->hide();
440 } 444 }
441} 445}
442 446
443void POP3config::fillValues() 447void POP3config::fillValues()
444{ 448{
445 accountLine->setText( data->getAccountName() ); 449 accountLine->setText( data->getAccountName() );
446 serverLine->setText( data->getServer() ); 450 serverLine->setText( data->getServer() );
447 portLine->setText( data->getPort() ); 451 portLine->setText( data->getPort() );
448 ComboBox1->setCurrentItem( data->ConnectionType() ); 452 ComboBox1->setCurrentItem( data->ConnectionType() );
449 userLine->setText( data->getUser() ); 453 userLine->setText( data->getUser() );
450 passLine->setText( data->getPassword() ); 454 passLine->setText( data->getPassword() );
451 localFolder->setText( data->getLocalFolder() ); 455 localFolder->setText( data->getLocalFolder() );
@@ -511,37 +515,39 @@ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name,
511 fillValues(); 515 fillValues();
512 //ComboBox1->setCurrentItem( data->ConnectionType() ); 516 //ComboBox1->setCurrentItem( data->ConnectionType() );
513} 517}
514void SMTPconfig::chooseSig() 518void SMTPconfig::chooseSig()
515{ 519{
516 QString lnk = KFileDialog::getOpenFileName( "", "Choose Signatur File", this ); 520 QString lnk = KFileDialog::getOpenFileName( "", "Choose Signatur File", this );
517 if ( !lnk.isEmpty() ) { 521 if ( !lnk.isEmpty() ) {
518 SignaturEdit->setText( lnk ); 522 SignaturEdit->setText( lnk );
519 } 523 }
520} 524}
521void SMTPconfig::slotConnectionToggle( int index ) 525void SMTPconfig::slotConnectionToggle( int index )
522{ 526{
523 // 2 is ssl connection 527 // 3 is ssl connection
524 if ( index == 2 ) 528 if ( index == 3 )
525 { 529 {
526 portLine->setText( SMTP_SSL_PORT ); 530 portLine->setText( SMTP_SSL_PORT );
531 CommandEdit->hide();
527 } 532 }
528 else if ( index == 3 ) 533 else if ( index == 4 )
529 { 534 {
530 portLine->setText( SMTP_PORT ); 535 portLine->setText( SMTP_PORT );
531 CommandEdit->show(); 536 CommandEdit->show();
532 } 537 }
533 else 538 else
534 { 539 {
535 portLine->setText( SMTP_PORT ); 540 portLine->setText( SMTP_PORT );
541 CommandEdit->hide();
536 } 542 }
537} 543}
538 544
539void SMTPconfig::fillValues() 545void SMTPconfig::fillValues()
540{ 546{
541 accountLine->setText( data->getAccountName() ); 547 accountLine->setText( data->getAccountName() );
542 serverLine->setText( data->getServer() ); 548 serverLine->setText( data->getServer() );
543 portLine->setText( data->getPort() ); 549 portLine->setText( data->getPort() );
544 ComboBox1->setCurrentItem( data->ConnectionType() ); 550 ComboBox1->setCurrentItem( data->ConnectionType() );
545 loginBox->setChecked( data->getLogin() ); 551 loginBox->setChecked( data->getLogin() );
546 userLine->setText( data->getUser() ); 552 userLine->setText( data->getUser() );
547 passLine->setText( data->getPassword() ); 553 passLine->setText( data->getPassword() );
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index 872a460..845c71c 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -235,32 +235,34 @@ void SMTPwrapper::connect_server()
235 } 235 }
236 236
237 qDebug("SMTP connection inited "); 237 qDebug("SMTP connection inited ");
238 /* switch to tls after init 'cause there it will send the ehlo */ 238 /* switch to tls after init 'cause there it will send the ehlo */
239 if (result) { 239 if (result) {
240 err = mailsmtp_init( m_smtp ); 240 err = mailsmtp_init( m_smtp );
241 if (err != MAILSMTP_NO_ERROR) { 241 if (err != MAILSMTP_NO_ERROR) {
242 result = 0; 242 result = 0;
243 qDebug("Error init SMTP connection "); 243 qDebug("Error init SMTP connection ");
244 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); 244 failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err));
245 } 245 }
246 } 246 }
247 if (try_tls) { 247 if (result && try_tls) {
248 qDebug("Smpt: Try tls "); 248 qDebug("Smpt: Try tls ");
249 err = start_smtp_tls(); 249 err = start_smtp_tls();
250 if (err != MAILSMTP_NO_ERROR) { 250 if (err != MAILSMTP_NO_ERROR) {
251 try_tls = false; 251 try_tls = false;
252 qDebug("no tls "); 252 qDebug("no tls ");
253 } else { 253 } else {
254 err = mailesmtp_ehlo(m_smtp); 254 err = mailesmtp_ehlo(m_smtp);
255 if ( err != MAILSMTP_NO_ERROR )
256 result = 0;
255 } 257 }
256 } 258 }
257 //qDebug("mailesmtp_ehlo %d ",err ); 259 //qDebug("mailesmtp_ehlo %d ",err );
258 if (!try_tls && force_tls) { 260 if (!try_tls && force_tls) {
259 result = 0; 261 result = 0;
260 failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err)); 262 failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err));
261 } 263 }
262 264
263 if (result==1 && m_SmtpAccount->getLogin() ) { 265 if (result==1 && m_SmtpAccount->getLogin() ) {
264 ; // odebug << "smtp with auth" << oendl; 266 ; // odebug << "smtp with auth" << oendl;
265 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 267 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
266 // get'em 268 // get'em
@@ -281,24 +283,28 @@ void SMTPwrapper::connect_server()
281 } 283 }
282 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; 284 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
283 if (result) { 285 if (result) {
284 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); 286 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
285 if ( err == MAILSMTP_NO_ERROR ) { 287 if ( err == MAILSMTP_NO_ERROR ) {
286 qDebug("Smtp authentification ok "); 288 qDebug("Smtp authentification ok ");
287 } else { 289 } else {
288 failuretext = i18n("Authentification failed"); 290 failuretext = i18n("Authentification failed");
289 result = 0; 291 result = 0;
290 } 292 }
291 } 293 }
292 } 294 }
295 if ( result == 0 ) {
296 mailsmtp_free(m_smtp);
297 m_smtp = 0;
298 }
293} 299}
294 300
295void SMTPwrapper::disc_server() 301void SMTPwrapper::disc_server()
296{ 302{
297 if (m_smtp) { 303 if (m_smtp) {
298 mailsmtp_quit( m_smtp ); 304 mailsmtp_quit( m_smtp );
299 mailsmtp_free( m_smtp ); 305 mailsmtp_free( m_smtp );
300 m_smtp = 0; 306 m_smtp = 0;
301 } 307 }
302} 308}
303 309
304int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) 310int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
@@ -337,25 +343,29 @@ bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later
337 if ( mimeMail == 0 ) { 343 if ( mimeMail == 0 ) {
338 qDebug("SMTP wrapper:Error creating mail! "); 344 qDebug("SMTP wrapper:Error creating mail! ");
339 return false; 345 return false;
340 } else { 346 } else {
341 sendProgress = new progressMailSend(); 347 sendProgress = new progressMailSend();
342 sendProgress->show(); 348 sendProgress->show();
343 sendProgress->setMaxMails(1); 349 sendProgress->setMaxMails(1);
344 result = smtpSend( mimeMail,later); 350 result = smtpSend( mimeMail,later);
345 ; // odebug << "Clean up done" << oendl; 351 ; // odebug << "Clean up done" << oendl;
346 sendProgress->hide(); 352 sendProgress->hide();
347 delete sendProgress; 353 delete sendProgress;
348 sendProgress = 0; 354 sendProgress = 0;
349 mailmime_free( mimeMail ); 355 mailmime_free( mimeMail );
356 if ( m_smtp ) {
357 mailsmtp_free(m_smtp);
358 m_smtp = 0;
359 }
350 } 360 }
351 return result; 361 return result;
352} 362}
353 363
354int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { 364int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
355 size_t curTok = 0; 365 size_t curTok = 0;
356 mailimf_fields *fields = 0; 366 mailimf_fields *fields = 0;
357 mailimf_field*ffrom = 0; 367 mailimf_field*ffrom = 0;
358 clist *rcpts = 0; 368 clist *rcpts = 0;
359 char*from = 0; 369 char*from = 0;
360 int res = 0; 370 int res = 0;
361 371
@@ -449,24 +459,29 @@ bool SMTPwrapper::flushOutbox() {
449 QMessageBox::critical(0,i18n("Error sending mail"), 459 QMessageBox::critical(0,i18n("Error sending mail"),
450 i18n("Error sending queued mail.\nBreaking.")); 460 i18n("Error sending queued mail.\nBreaking."));
451 returnValue = false; 461 returnValue = false;
452 } 462 }
453 mailsToRemove.append((*mailsToSend.begin())); 463 mailsToRemove.append((*mailsToSend.begin()));
454 mailsToSend.remove(mailsToSend.begin()); 464 mailsToSend.remove(mailsToSend.begin());
455 sendProgress->setCurrentMails(mailsToRemove.count()); 465 sendProgress->setCurrentMails(mailsToRemove.count());
456 } 466 }
457 if (reset_user_value) { 467 if (reset_user_value) {
458 m_SmtpAccount->setUser(oldUser); 468 m_SmtpAccount->setUser(oldUser);
459 m_SmtpAccount->setPassword(oldPw); 469 m_SmtpAccount->setPassword(oldPw);
460 } 470 }
471
461 KConfig cfg( locateLocal("config", "kopiemailrc" ) ); 472 KConfig cfg( locateLocal("config", "kopiemailrc" ) );
462 cfg.setGroup( "Status" ); 473 cfg.setGroup( "Status" );
463 m_queuedMail = mailsToSend.count(); 474 m_queuedMail = mailsToSend.count();
464 cfg.writeEntry( "outgoing", m_queuedMail ); 475 cfg.writeEntry( "outgoing", m_queuedMail );
465 emit queuedMails( m_queuedMail ); 476 emit queuedMails( m_queuedMail );
466 sendProgress->hide(); 477 sendProgress->hide();
467 delete sendProgress; 478 delete sendProgress;
468 sendProgress = 0; 479 sendProgress = 0;
469 wrap->deleteMails(mbox,mailsToRemove); 480 wrap->deleteMails(mbox,mailsToRemove);
470 delete wrap; 481 delete wrap;
482 if ( m_smtp ) {
483 mailsmtp_free(m_smtp);
484 m_smtp = 0;
485 }
471 return returnValue; 486 return returnValue;
472} 487}