-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 | |||
@@ -93,13 +93,13 @@ bool IMAPwrapper::start_tls(bool force_tls) | |||
93 | } | 93 | } |
94 | return try_tls; | 94 | return try_tls; |
95 | } | 95 | } |
96 | 96 | ||
97 | void IMAPwrapper::login() | 97 | void IMAPwrapper::login() |
98 | { | 98 | { |
99 | const char *server, *user, *pass; | 99 | QString server, user, pass; |
100 | uint16_t port; | 100 | uint16_t port; |
101 | int err = MAILIMAP_NO_ERROR; | 101 | int err = MAILIMAP_NO_ERROR; |
102 | 102 | ||
103 | if (account->getOffline()) return; | 103 | if (account->getOffline()) return; |
104 | /* we are connected this moment */ | 104 | /* we are connected this moment */ |
105 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 105 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
@@ -109,28 +109,28 @@ void IMAPwrapper::login() | |||
109 | logout(); | 109 | logout(); |
110 | } else { | 110 | } else { |
111 | mailstream_flush(m_imap->imap_stream); | 111 | mailstream_flush(m_imap->imap_stream); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | server = account->getServer().latin1(); | 115 | server = account->getServer(); |
116 | port = account->getPort().toUInt(); | 116 | port = account->getPort().toUInt(); |
117 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 117 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
118 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 118 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
119 | login.show(); | 119 | login.show(); |
120 | if ( QDialog::Accepted == login.exec() ) { | 120 | if ( QDialog::Accepted == login.exec() ) { |
121 | // ok | 121 | // ok |
122 | user = login.getUser().latin1(); | 122 | user = login.getUser(); |
123 | pass = login.getPassword().latin1(); | 123 | pass = login.getPassword(); |
124 | } else { | 124 | } else { |
125 | // cancel | 125 | // cancel |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | } else { | 128 | } else { |
129 | user = account->getUser().latin1(); | 129 | user = account->getUser(); |
130 | pass = account->getPassword().latin1(); | 130 | pass = account->getPassword(); |
131 | } | 131 | } |
132 | 132 | ||
133 | m_imap = mailimap_new( 20, &imap_progress ); | 133 | m_imap = mailimap_new( 20, &imap_progress ); |
134 | 134 | ||
135 | /* connect */ | 135 | /* connect */ |
136 | bool ssl = false; | 136 | bool ssl = false; |
@@ -143,15 +143,15 @@ void IMAPwrapper::login() | |||
143 | if (account->ConnectionType()==1) { | 143 | if (account->ConnectionType()==1) { |
144 | force_tls = true; | 144 | force_tls = true; |
145 | } | 145 | } |
146 | 146 | ||
147 | if ( ssl ) { | 147 | if ( ssl ) { |
148 | qDebug("using ssl "); | 148 | qDebug("using ssl "); |
149 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 149 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
150 | } else { | 150 | } else { |
151 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 151 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
152 | } | 152 | } |
153 | 153 | ||
154 | if ( err != MAILIMAP_NO_ERROR && | 154 | if ( err != MAILIMAP_NO_ERROR && |
155 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 155 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
156 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 156 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
157 | QString failure = ""; | 157 | QString failure = ""; |
@@ -177,13 +177,13 @@ void IMAPwrapper::login() | |||
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | /* login */ | 180 | /* login */ |
181 | 181 | ||
182 | if (ok) { | 182 | if (ok) { |
183 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 183 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
184 | if ( err != MAILIMAP_NO_ERROR ) { | 184 | if ( err != MAILIMAP_NO_ERROR ) { |
185 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 185 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
186 | ok = false; | 186 | ok = false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | if (!ok) { | 189 | if (!ok) { |
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 | |||
@@ -114,46 +114,37 @@ void NNTPwrapper::login() | |||
114 | if (account->getOffline()) | 114 | if (account->getOffline()) |
115 | return; | 115 | return; |
116 | /* we'll hold the line */ | 116 | /* we'll hold the line */ |
117 | if ( m_nntp != NULL ) | 117 | if ( m_nntp != NULL ) |
118 | return; | 118 | return; |
119 | 119 | ||
120 | const char *server, *user, *pass; | 120 | QString server; |
121 | QString User,Pass; | 121 | QString User,Pass; |
122 | uint16_t port; | 122 | uint16_t port; |
123 | int err = NEWSNNTP_NO_ERROR; | 123 | int err = NEWSNNTP_NO_ERROR; |
124 | 124 | ||
125 | server = account->getServer().latin1(); | 125 | server = account->getServer(); |
126 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
127 | 127 | ||
128 | user = pass = 0; | ||
129 | |||
130 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
131 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
132 | login.show(); | 130 | login.show(); |
133 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
134 | // ok | 132 | // ok |
135 | User = login.getUser().latin1(); | 133 | User = login.getUser(); |
136 | Pass = login.getPassword().latin1(); | 134 | Pass = login.getPassword(); |
137 | } else { | 135 | } else { |
138 | // cancel | 136 | // cancel |
139 | ; // << "NNTP: Login canceled" << oendl; | 137 | ; // << "NNTP: Login canceled" << oendl; |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | } else { | 140 | } else { |
143 | User = account->getUser().latin1(); | 141 | User = account->getUser(); |
144 | Pass = account->getPassword().latin1(); | 142 | Pass = account->getPassword(); |
145 | } | 143 | } |
146 | 144 | ||
147 | if (User.isEmpty()) { | ||
148 | user=0; | ||
149 | pass = 0; | ||
150 | } else { | ||
151 | user=User.latin1(); | ||
152 | pass=Pass.latin1(); | ||
153 | } | ||
154 | // bool ssl = account->getSSL(); | 145 | // bool ssl = account->getSSL(); |
155 | 146 | ||
156 | m_nntp=mailstorage_new(NULL); | 147 | m_nntp=mailstorage_new(NULL); |
157 | 148 | ||
158 | int conntypeset = account->ConnectionType(); | 149 | int conntypeset = account->ConnectionType(); |
159 | int conntype = 0; | 150 | int conntype = 0; |
@@ -164,14 +155,14 @@ void NNTPwrapper::login() | |||
164 | } else if ( conntypeset == 1 ) { | 155 | } else if ( conntypeset == 1 ) { |
165 | conntype = CONNECTION_TYPE_STARTTLS; | 156 | conntype = CONNECTION_TYPE_STARTTLS; |
166 | } else if ( conntypeset == 0 ) { | 157 | } else if ( conntypeset == 0 ) { |
167 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 158 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
168 | } | 159 | } |
169 | 160 | ||
170 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 161 | nntp_mailstorage_init(m_nntp,(char*)server.latin1(), port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
171 | (char*)user,(char*)pass,0,0,0); | 162 | (char*)User.latin1(),(char*)Pass.latin1(),0,0,0); |
172 | 163 | ||
173 | err = mailstorage_connect( m_nntp ); | 164 | err = mailstorage_connect( m_nntp ); |
174 | 165 | ||
175 | if (err != NEWSNNTP_NO_ERROR) { | 166 | if (err != NEWSNNTP_NO_ERROR) { |
176 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 167 | ; // << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
177 | // Global::statusMessage(tr("Error initializing folder")); | 168 | // Global::statusMessage(tr("Error initializing folder")); |
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 | |||
@@ -115,40 +115,39 @@ void POP3wrapper::login() | |||
115 | if (account->getOffline()) | 115 | if (account->getOffline()) |
116 | return; | 116 | return; |
117 | /* we'll hold the line */ | 117 | /* we'll hold the line */ |
118 | if ( m_pop3 != NULL ) | 118 | if ( m_pop3 != NULL ) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | const char *server, *user, *pass; | 121 | QString server,user, pass; |
122 | uint16_t port; | 122 | uint16_t port; |
123 | int err = MAILPOP3_NO_ERROR; | 123 | int err = MAILPOP3_NO_ERROR; |
124 | 124 | ||
125 | server = account->getServer().latin1(); | 125 | server = account->getServer().latin1(); |
126 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
127 | 127 | ||
128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 130 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 132 | // ok |
133 | user = login.getUser().latin1(); | 133 | qDebug("ok "); |
134 | pass = login.getPassword().latin1(); | 134 | user = login.getUser(); |
135 | pass = login.getPassword(); | ||
135 | } else { | 136 | } else { |
136 | // cancel | 137 | // cancel |
137 | ; // odebug << "POP3: Login canceled" << oendl; | 138 | ; // odebug << "POP3: Login canceled" << oendl; |
138 | return; | 139 | return; |
139 | } | 140 | } |
140 | } else { | 141 | } else { |
141 | user = account->getUser().latin1(); | 142 | user = account->getUser(); |
142 | pass = account->getPassword().latin1(); | 143 | pass = account->getPassword(); |
143 | } | 144 | } |
144 | |||
145 | // bool ssl = account->getSSL(); | 145 | // bool ssl = account->getSSL(); |
146 | 146 | ||
147 | m_pop3=mailstorage_new(NULL); | 147 | m_pop3=mailstorage_new(NULL); |
148 | |||
149 | int conntypeset = account->ConnectionType(); | 148 | int conntypeset = account->ConnectionType(); |
150 | int conntype = 0; | 149 | int conntype = 0; |
151 | if ( conntypeset == 3 ) { | 150 | if ( conntypeset == 3 ) { |
152 | conntype = CONNECTION_TYPE_COMMAND; | 151 | conntype = CONNECTION_TYPE_COMMAND; |
153 | } else if ( conntypeset == 2 ) { | 152 | } else if ( conntypeset == 2 ) { |
154 | conntype = CONNECTION_TYPE_TLS; | 153 | conntype = CONNECTION_TYPE_TLS; |
@@ -157,15 +156,14 @@ void POP3wrapper::login() | |||
157 | } else if ( conntypeset == 0 ) { | 156 | } else if ( conntypeset == 0 ) { |
158 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
159 | } | 158 | } |
160 | 159 | ||
161 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
162 | 161 | ||
163 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
164 | (char*)user,(char*)pass,0,0,0); | 163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); |
165 | |||
166 | 164 | ||
167 | err = mailstorage_connect(m_pop3); | 165 | err = mailstorage_connect(m_pop3); |
168 | if (err != MAIL_NO_ERROR) { | 166 | if (err != MAIL_NO_ERROR) { |
169 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
170 | Global::statusMessage(tr("Error initializing folder")); | 168 | Global::statusMessage(tr("Error initializing folder")); |
171 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
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 | |||
@@ -179,25 +179,24 @@ int SMTPwrapper::start_smtp_tls() | |||
179 | } | 179 | } |
180 | return err; | 180 | return err; |
181 | } | 181 | } |
182 | 182 | ||
183 | void SMTPwrapper::connect_server() | 183 | void 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 | } |
@@ -212,16 +211,16 @@ void SMTPwrapper::connect_server() | |||
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 | } |
@@ -255,25 +254,25 @@ void SMTPwrapper::connect_server() | |||
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 | } |