-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.cpp | 25 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.cpp | 19 |
4 files changed, 34 insertions, 46 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 11d3343..021633b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -87,77 +87,77 @@ bool IMAPwrapper::start_tls(bool force_tls) mailstream_set_low(m_imap->imap_stream, new_low); } else { try_tls = false; } } } } return try_tls; } void IMAPwrapper::login() { - const char *server, *user, *pass; + QString server, user, pass; uint16_t port; int err = MAILIMAP_NO_ERROR; if (account->getOffline()) return; /* we are connected this moment */ /* TODO: setup a timer holding the line or if connection closed - delete the value */ if (m_imap) { err = mailimap_noop(m_imap); if (err!=MAILIMAP_NO_ERROR) { logout(); } else { mailstream_flush(m_imap->imap_stream); return; } } - server = account->getServer().latin1(); + server = account->getServer(); port = account->getPort().toUInt(); if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - user = login.getUser().latin1(); - pass = login.getPassword().latin1(); + user = login.getUser(); + pass = login.getPassword(); } else { // cancel return; } } else { - user = account->getUser().latin1(); - pass = account->getPassword().latin1(); + user = account->getUser(); + pass = account->getPassword(); } m_imap = mailimap_new( 20, &imap_progress ); /* connect */ bool ssl = false; bool try_tls = false; bool force_tls = false; if ( account->ConnectionType() == 2 ) { ssl = true; } if (account->ConnectionType()==1) { force_tls = true; } if ( ssl ) { qDebug("using ssl "); - err = mailimap_ssl_connect( m_imap, (char*)server, port ); + err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); } else { - err = mailimap_socket_connect( m_imap, (char*)server, port ); + err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); } if ( err != MAILIMAP_NO_ERROR && err != MAILIMAP_NO_ERROR_AUTHENTICATED && err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { QString failure = ""; if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { failure="Connection refused"; } else { failure="Unknown failure"; } Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); @@ -171,25 +171,25 @@ void IMAPwrapper::login() } bool ok = true; if (force_tls && !try_tls) { Global::statusMessage(tr("Server has no TLS support!")); ok = false; } /* login */ if (ok) { - err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); + err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); if ( err != MAILIMAP_NO_ERROR ) { Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); ok = false; } } if (!ok) { err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } } diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index f5d7f16..93cd2b5 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp @@ -108,76 +108,67 @@ void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSm mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); } void NNTPwrapper::login() { if (account->getOffline()) return; /* we'll hold the line */ if ( m_nntp != NULL ) return; - const char *server, *user, *pass; + QString server; QString User,Pass; uint16_t port; int err = NEWSNNTP_NO_ERROR; - server = account->getServer().latin1(); + server = account->getServer(); port = account->getPort().toUInt(); - user = pass = 0; - if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - User = login.getUser().latin1(); - Pass = login.getPassword().latin1(); + User = login.getUser(); + Pass = login.getPassword(); } else { // cancel ; // << "NNTP: Login canceled" << oendl; return; } } else { - User = account->getUser().latin1(); - Pass = account->getPassword().latin1(); + User = account->getUser(); + Pass = account->getPassword(); } - if (User.isEmpty()) { - user=0; - pass = 0; - } else { - user=User.latin1(); - pass=Pass.latin1(); - } // bool ssl = account->getSSL(); m_nntp=mailstorage_new(NULL); int conntypeset = account->ConnectionType(); int conntype = 0; if ( conntypeset == 3 ) { conntype = CONNECTION_TYPE_COMMAND; } else if ( conntypeset == 2 ) { conntype = CONNECTION_TYPE_TLS; } else if ( conntypeset == 1 ) { conntype = CONNECTION_TYPE_STARTTLS; } else if ( conntypeset == 0 ) { conntype = CONNECTION_TYPE_TRY_STARTTLS; } - nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, - (char*)user,(char*)pass,0,0,0); + nntp_mailstorage_init(m_nntp,(char*)server.latin1(), port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, + (char*)User.latin1(),(char*)Pass.latin1(),0,0,0); err = mailstorage_connect( m_nntp ); if (err != NEWSNNTP_NO_ERROR) { ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; // Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_nntp); m_nntp = 0; } else { mailsession * session = m_nntp->sto_session; newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 0e6612c..f430121 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp @@ -109,69 +109,67 @@ void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPoi parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); } void POP3wrapper::login() { if (account->getOffline()) return; /* we'll hold the line */ if ( m_pop3 != NULL ) return; - const char *server, *user, *pass; + QString server,user, pass; uint16_t port; int err = MAILPOP3_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - user = login.getUser().latin1(); - pass = login.getPassword().latin1(); + qDebug("ok "); + user = login.getUser(); + pass = login.getPassword(); } else { // cancel ; // odebug << "POP3: Login canceled" << oendl; return; } } else { - user = account->getUser().latin1(); - pass = account->getPassword().latin1(); + user = account->getUser(); + pass = account->getPassword(); } - // bool ssl = account->getSSL(); m_pop3=mailstorage_new(NULL); - int conntypeset = account->ConnectionType(); int conntype = 0; if ( conntypeset == 3 ) { conntype = CONNECTION_TYPE_COMMAND; } else if ( conntypeset == 2 ) { conntype = CONNECTION_TYPE_TLS; } else if ( conntypeset == 1 ) { conntype = CONNECTION_TYPE_STARTTLS; } else if ( conntypeset == 0 ) { conntype = CONNECTION_TYPE_TRY_STARTTLS; } //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); - pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, - (char*)user,(char*)pass,0,0,0); - + pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, + (char*)user.latin1(),(char*)pass.latin1(),0,0,0); err = mailstorage_connect(m_pop3); if (err != MAIL_NO_ERROR) { ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_pop3); m_pop3 = 0; } else { mailsession * session = m_pop3->sto_session; mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; if (mail) { mail->pop3_progr_fun = &pop3_progress; diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp index 6a1b505..d5a528c 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.cpp +++ b/kmicromail/libmailwrapper/smtpwrapper.cpp @@ -173,61 +173,60 @@ int SMTPwrapper::start_smtp_tls() int fd = mailstream_low_get_fd(low); if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { mailstream_low_free(low); mailstream_set_low(m_smtp->stream, new_low); } else { return MAILSMTP_ERROR_IN_PROCESSING; } return err; } void SMTPwrapper::connect_server() { - const char *server, *user, *pass; + QString server, user, pass; bool ssl; uint16_t port; ssl = false; bool try_tls = true; bool force_tls=false; - server = user = pass = 0; QString failuretext = ""; if (m_smtp || !m_SmtpAccount) { return; } - server = m_SmtpAccount->getServer().latin1(); + server = m_SmtpAccount->getServer(); if ( m_SmtpAccount->ConnectionType() == 2 ) { ssl = true; try_tls = false; } else if (m_SmtpAccount->ConnectionType() == 1) { force_tls = true; } int result = 1; port = m_SmtpAccount->getPort().toUInt(); m_smtp = mailsmtp_new( 20, &progress ); if ( m_smtp == NULL ) { /* no failure message cause this happens when problems with memory - than we we can not display any messagebox */ return; } int err = MAILSMTP_NO_ERROR; ; // odebug << "Servername " << server << " at port " << port << "" << oendl; if ( ssl ) { ; // odebug << "SSL session" << oendl; - err = mailsmtp_ssl_connect( m_smtp, server, port ); + err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); } else { ; // odebug << "No SSL session" << oendl; - err = mailsmtp_socket_connect( m_smtp, server, port ); + err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); } if ( err != MAILSMTP_NO_ERROR ) { ; // odebug << "Error init connection" << oendl; failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); result = 0; } /* switch to tls after init 'cause there it will send the ehlo */ if (result) { err = mailsmtp_init( m_smtp ); if (err != MAILSMTP_NO_ERROR) { result = 0; @@ -249,37 +248,37 @@ void SMTPwrapper::connect_server() failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); } if (result==1 && m_SmtpAccount->getLogin() ) { ; // odebug << "smtp with auth" << oendl; if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { // get'em LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - user = login.getUser().latin1(); - pass = login.getPassword().latin1(); + user = login.getUser(); + pass = login.getPassword(); } else { result = 0; failuretext=tr("Login aborted - storing mail to localfolder"); } } else { - user = m_SmtpAccount->getUser().latin1(); - pass = m_SmtpAccount->getPassword().latin1(); + user = m_SmtpAccount->getUser(); + pass = m_SmtpAccount->getPassword(); } ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; if (result) { - err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); + err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); if ( err == MAILSMTP_NO_ERROR ) { ; // odebug << "auth ok" << oendl; } else { failuretext = tr("Authentification failed"); result = 0; } } } } void SMTPwrapper::disc_server() { |