summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/smtpwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/smtpwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp19
1 files changed, 9 insertions, 10 deletions
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()
173 int fd = mailstream_low_get_fd(low); 173 int fd = mailstream_low_get_fd(low);
174 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 174 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
175 mailstream_low_free(low); 175 mailstream_low_free(low);
176 mailstream_set_low(m_smtp->stream, new_low); 176 mailstream_set_low(m_smtp->stream, new_low);
177 } else { 177 } else {
178 return MAILSMTP_ERROR_IN_PROCESSING; 178 return MAILSMTP_ERROR_IN_PROCESSING;
179 } 179 }
180 return err; 180 return err;
181} 181}
182 182
183void SMTPwrapper::connect_server() 183void SMTPwrapper::connect_server()
184{ 184{
185 const char *server, *user, *pass; 185 QString server, user, pass;
186 bool ssl; 186 bool ssl;
187 uint16_t port; 187 uint16_t port;
188 ssl = false; 188 ssl = false;
189 bool try_tls = true; 189 bool try_tls = true;
190 bool force_tls=false; 190 bool force_tls=false;
191 server = user = pass = 0;
192 QString failuretext = ""; 191 QString failuretext = "";
193 192
194 if (m_smtp || !m_SmtpAccount) { 193 if (m_smtp || !m_SmtpAccount) {
195 return; 194 return;
196 } 195 }
197 server = m_SmtpAccount->getServer().latin1(); 196 server = m_SmtpAccount->getServer();
198 if ( m_SmtpAccount->ConnectionType() == 2 ) { 197 if ( m_SmtpAccount->ConnectionType() == 2 ) {
199 ssl = true; 198 ssl = true;
200 try_tls = false; 199 try_tls = false;
201 } else if (m_SmtpAccount->ConnectionType() == 1) { 200 } else if (m_SmtpAccount->ConnectionType() == 1) {
202 force_tls = true; 201 force_tls = true;
203 } 202 }
204 int result = 1; 203 int result = 1;
205 port = m_SmtpAccount->getPort().toUInt(); 204 port = m_SmtpAccount->getPort().toUInt();
206 205
207 m_smtp = mailsmtp_new( 20, &progress ); 206 m_smtp = mailsmtp_new( 20, &progress );
208 if ( m_smtp == NULL ) { 207 if ( m_smtp == NULL ) {
209 /* no failure message cause this happens when problems with memory - than we 208 /* no failure message cause this happens when problems with memory - than we
210 we can not display any messagebox */ 209 we can not display any messagebox */
211 return; 210 return;
212 } 211 }
213 212
214 int err = MAILSMTP_NO_ERROR; 213 int err = MAILSMTP_NO_ERROR;
215 ; // odebug << "Servername " << server << " at port " << port << "" << oendl; 214 ; // odebug << "Servername " << server << " at port " << port << "" << oendl;
216 if ( ssl ) { 215 if ( ssl ) {
217 ; // odebug << "SSL session" << oendl; 216 ; // odebug << "SSL session" << oendl;
218 err = mailsmtp_ssl_connect( m_smtp, server, port ); 217 err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port );
219 } else { 218 } else {
220 ; // odebug << "No SSL session" << oendl; 219 ; // odebug << "No SSL session" << oendl;
221 err = mailsmtp_socket_connect( m_smtp, server, port ); 220 err = mailsmtp_socket_connect( m_smtp, server.latin1(), port );
222 } 221 }
223 if ( err != MAILSMTP_NO_ERROR ) { 222 if ( err != MAILSMTP_NO_ERROR ) {
224 ; // odebug << "Error init connection" << oendl; 223 ; // odebug << "Error init connection" << oendl;
225 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); 224 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
226 result = 0; 225 result = 0;
227 } 226 }
228 227
229 /* switch to tls after init 'cause there it will send the ehlo */ 228 /* switch to tls after init 'cause there it will send the ehlo */
230 if (result) { 229 if (result) {
231 err = mailsmtp_init( m_smtp ); 230 err = mailsmtp_init( m_smtp );
232 if (err != MAILSMTP_NO_ERROR) { 231 if (err != MAILSMTP_NO_ERROR) {
233 result = 0; 232 result = 0;
@@ -249,37 +248,37 @@ void SMTPwrapper::connect_server()
249 failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); 248 failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err));
250 } 249 }
251 250
252 if (result==1 && m_SmtpAccount->getLogin() ) { 251 if (result==1 && m_SmtpAccount->getLogin() ) {
253 ; // odebug << "smtp with auth" << oendl; 252 ; // odebug << "smtp with auth" << oendl;
254 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 253 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
255 // get'em 254 // get'em
256 LoginDialog login( m_SmtpAccount->getUser(), 255 LoginDialog login( m_SmtpAccount->getUser(),
257 m_SmtpAccount->getPassword(), NULL, 0, true ); 256 m_SmtpAccount->getPassword(), NULL, 0, true );
258 login.show(); 257 login.show();
259 if ( QDialog::Accepted == login.exec() ) { 258 if ( QDialog::Accepted == login.exec() ) {
260 // ok 259 // ok
261 user = login.getUser().latin1(); 260 user = login.getUser();
262 pass = login.getPassword().latin1(); 261 pass = login.getPassword();
263 } else { 262 } else {
264 result = 0; 263 result = 0;
265 failuretext=tr("Login aborted - storing mail to localfolder"); 264 failuretext=tr("Login aborted - storing mail to localfolder");
266 } 265 }
267 } else { 266 } else {
268 user = m_SmtpAccount->getUser().latin1(); 267 user = m_SmtpAccount->getUser();
269 pass = m_SmtpAccount->getPassword().latin1(); 268 pass = m_SmtpAccount->getPassword();
270 } 269 }
271 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; 270 ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl;
272 if (result) { 271 if (result) {
273 err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); 272 err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() );
274 if ( err == MAILSMTP_NO_ERROR ) { 273 if ( err == MAILSMTP_NO_ERROR ) {
275 ; // odebug << "auth ok" << oendl; 274 ; // odebug << "auth ok" << oendl;
276 } else { 275 } else {
277 failuretext = tr("Authentification failed"); 276 failuretext = tr("Authentification failed");
278 result = 0; 277 result = 0;
279 } 278 }
280 } 279 }
281 } 280 }
282} 281}
283 282
284void SMTPwrapper::disc_server() 283void SMTPwrapper::disc_server()
285{ 284{