author | zautrix <zautrix> | 2005-03-16 15:51:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-16 15:51:58 (UTC) |
commit | fcfb235c813d3cfcf23ab905fe2fb159647bc911 (patch) (unidiff) | |
tree | 424721fc576e2b41ea22274e792e977fb54e52c4 | |
parent | b90787b3fd6cf859c80ddce0f1a2272c7565eec3 (diff) | |
download | kdepimpi-fcfb235c813d3cfcf23ab905fe2fb159647bc911.zip kdepimpi-fcfb235c813d3cfcf23ab905fe2fb159647bc911.tar.gz kdepimpi-fcfb235c813d3cfcf23ab905fe2fb159647bc911.tar.bz2 |
smtp fix
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.cpp | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index ed5c898..870985e 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -139,96 +139,99 @@ QString AbstractMail::draftFolder() | |||
139 | 139 | ||
140 | /* temporary - will be removed when implemented in all classes */ | 140 | /* temporary - will be removed when implemented in all classes */ |
141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
142 | { | 142 | { |
143 | } | 143 | } |
144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
145 | { | 145 | { |
146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
147 | // this is currently re-implemented in pop3wrapper and imapwrapper | 147 | // this is currently re-implemented in pop3wrapper and imapwrapper |
148 | int iii = 0; | 148 | int iii = 0; |
149 | int count = target.count(); | 149 | int count = target.count(); |
150 | QProgressBar wid ( count ); | 150 | QProgressBar wid ( count ); |
151 | wid.setCaption( i18n("Deleting ...")); | 151 | wid.setCaption( i18n("Deleting ...")); |
152 | wid.show(); | 152 | wid.show(); |
153 | while (iii < count ) { | 153 | while (iii < count ) { |
154 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 154 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
155 | wid.setProgress( iii ); | 155 | wid.setProgress( iii ); |
156 | wid.raise(); | 156 | wid.raise(); |
157 | qApp->processEvents(); | 157 | qApp->processEvents(); |
158 | RecMailP mail = (*target.at( iii )); | 158 | RecMailP mail = (*target.at( iii )); |
159 | deleteMail(mail); | 159 | deleteMail(mail); |
160 | ++iii; | 160 | ++iii; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) | 164 | void AbstractMail::downloadNewMails(const FolderP&fromFolder, AbstractMail*targetMail ) |
165 | { | 165 | { |
166 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); | 166 | //qDebug("AbstractMail::downloadNewMails %s ", fromFolder->getName().latin1()); |
167 | // get local folder | 167 | // get local folder |
168 | Account * acc = getAccount(); | 168 | Account * acc = getAccount(); |
169 | if ( !acc ) return; | 169 | if ( !acc ) return; |
170 | QString lfName = acc->getLocalFolder(); | 170 | QString lfName = acc->getLocalFolder(); |
171 | if ( lfName.isEmpty() ) | 171 | if ( lfName.isEmpty() ) |
172 | lfName = acc->getAccountName(); | 172 | lfName = acc->getAccountName(); |
173 | // create local folder | 173 | // create local folder |
174 | if ( !targetMail->createMbox(lfName)) | 174 | if ( !targetMail->createMbox(lfName)) |
175 | { | 175 | { |
176 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 176 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
177 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); | 177 | i18n("Error while creating new folder\n%1\n\nCancelling action.").arg(lfName)); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | QValueList<RecMailP> t; | 180 | QValueList<RecMailP> t; |
181 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); | 181 | listMessages(fromFolder->getName(),t,acc->getMaxMailSize() ); |
182 | if ( t.count() == 0 ) { | 182 | if ( t.count() == 0 ) { |
183 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); | 183 | qDebug("There are no new messages %s", fromFolder->getName().latin1()); |
184 | Global::statusMessage(i18n("There are no new messages")); | 184 | Global::statusMessage(i18n("There are no new messages")); |
185 | return; | 185 | return; |
186 | } | 186 | } |
187 | Global::statusMessage(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); | ||
188 | qDebug(i18n("%1 :Downloading mails..."). arg(acc->getAccountName())); | ||
189 | qApp->processEvents(); | ||
187 | QValueList<RecMailP> e; | 190 | QValueList<RecMailP> e; |
188 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); | 191 | targetMail->listMessages(lfName,e,acc->getMaxMailSize() ); |
189 | //qDebug("target has mails %d ", e.count()); | 192 | //qDebug("target has mails %d ", e.count()); |
190 | QValueList<RecMailP> n; | 193 | QValueList<RecMailP> n; |
191 | int iii = 0; | 194 | int iii = 0; |
192 | int count = t.count(); | 195 | int count = t.count(); |
193 | while (iii < count ) { | 196 | while (iii < count ) { |
194 | RecMailP r = (*t.at( iii )); | 197 | RecMailP r = (*t.at( iii )); |
195 | bool found = false; | 198 | bool found = false; |
196 | int jjj = 0; | 199 | int jjj = 0; |
197 | int countE = e.count(); | 200 | int countE = e.count(); |
198 | while (jjj < countE ) { | 201 | while (jjj < countE ) { |
199 | RecMailP re = (*e.at( jjj )); | 202 | RecMailP re = (*e.at( jjj )); |
200 | if ( re->isEqual(r) ) { | 203 | if ( re->isEqual(r) ) { |
201 | found = true; | 204 | found = true; |
202 | break; | 205 | break; |
203 | } | 206 | } |
204 | ++jjj; | 207 | ++jjj; |
205 | } | 208 | } |
206 | if ( !found ) { | 209 | if ( !found ) { |
207 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); | 210 | //qDebug("AAAdate *%s* ", r->isodate.latin1() ); |
208 | n.append( r ); | 211 | n.append( r ); |
209 | } | 212 | } |
210 | ++iii; | 213 | ++iii; |
211 | } | 214 | } |
212 | qDebug("Downloaded %d messages ",n.count() ); | 215 | qDebug("Downloaded %d messages ",n.count() ); |
213 | if ( n.count() == 0 ) { | 216 | if ( n.count() == 0 ) { |
214 | Global::statusMessage(i18n("There are no new messages")); | 217 | Global::statusMessage(i18n("There are no new messages")); |
215 | return; | 218 | return; |
216 | } | 219 | } |
217 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); | 220 | mvcpMailList( n,lfName,targetMail,!acc->getLeaveOnServer()); |
218 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); | 221 | Global::statusMessage(i18n("Downloaded %1 messages").arg(n.count())); |
219 | 222 | ||
220 | #if 0 | 223 | #if 0 |
221 | QValueList<RecMailP> t; | 224 | QValueList<RecMailP> t; |
222 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 225 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
223 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 226 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
224 | #endif | 227 | #endif |
225 | 228 | ||
226 | } | 229 | } |
227 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 230 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
228 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 231 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
229 | { | 232 | { |
230 | QValueList<RecMailP> t; | 233 | QValueList<RecMailP> t; |
231 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 234 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
232 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 235 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
233 | 236 | ||
234 | } | 237 | } |
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp index 845c71c..448a2e9 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.cpp +++ b/kmicromail/libmailwrapper/smtpwrapper.cpp | |||
@@ -161,144 +161,147 @@ void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char* | |||
161 | if (failuremessage) { | 161 | if (failuremessage) { |
162 | QMessageBox::critical(0,i18n("Error sending mail"), | 162 | QMessageBox::critical(0,i18n("Error sending mail"), |
163 | failuremessage); | 163 | failuremessage); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | int SMTPwrapper::start_smtp_tls() | 167 | int SMTPwrapper::start_smtp_tls() |
168 | { | 168 | { |
169 | if (!m_smtp) { | 169 | if (!m_smtp) { |
170 | return MAILSMTP_ERROR_IN_PROCESSING; | 170 | return MAILSMTP_ERROR_IN_PROCESSING; |
171 | } | 171 | } |
172 | int err = mailesmtp_starttls(m_smtp); | 172 | int err = mailesmtp_starttls(m_smtp); |
173 | if (err != MAILSMTP_NO_ERROR) return err; | 173 | if (err != MAILSMTP_NO_ERROR) return err; |
174 | mailstream_low * low; | 174 | mailstream_low * low; |
175 | mailstream_low * new_low; | 175 | mailstream_low * new_low; |
176 | low = mailstream_get_low(m_smtp->stream); | 176 | low = mailstream_get_low(m_smtp->stream); |
177 | if (!low) { | 177 | if (!low) { |
178 | return MAILSMTP_ERROR_IN_PROCESSING; | 178 | return MAILSMTP_ERROR_IN_PROCESSING; |
179 | } | 179 | } |
180 | int fd = mailstream_low_get_fd(low); | 180 | int fd = mailstream_low_get_fd(low); |
181 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 181 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
182 | mailstream_low_free(low); | 182 | mailstream_low_free(low); |
183 | mailstream_set_low(m_smtp->stream, new_low); | 183 | mailstream_set_low(m_smtp->stream, new_low); |
184 | } else { | 184 | } else { |
185 | return MAILSMTP_ERROR_IN_PROCESSING; | 185 | return MAILSMTP_ERROR_IN_PROCESSING; |
186 | } | 186 | } |
187 | return err; | 187 | return err; |
188 | } | 188 | } |
189 | 189 | ||
190 | void SMTPwrapper::connect_server() | 190 | void SMTPwrapper::connect_server() |
191 | { | 191 | { |
192 | QString server, user, pass; | 192 | QString server, user, pass; |
193 | bool ssl; | 193 | bool ssl; |
194 | uint16_t port; | 194 | uint16_t port; |
195 | ssl = false; | 195 | ssl = false; |
196 | bool try_tls = false; | 196 | bool try_tls = false; |
197 | bool force_tls=false; | 197 | bool force_tls=false; |
198 | QString failuretext = ""; | 198 | QString failuretext = ""; |
199 | 199 | ||
200 | if (m_smtp || !m_SmtpAccount) { | 200 | if (m_smtp || !m_SmtpAccount) { |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | server = m_SmtpAccount->getServer(); | 203 | server = m_SmtpAccount->getServer(); |
204 | if ( m_SmtpAccount->ConnectionType() == 3 ) { | 204 | if ( m_SmtpAccount->ConnectionType() == 3 ) { |
205 | ssl = true; | 205 | ssl = true; |
206 | try_tls = false; | 206 | try_tls = false; |
207 | } else if (m_SmtpAccount->ConnectionType() == 2) { | 207 | } else if (m_SmtpAccount->ConnectionType() == 2) { |
208 | force_tls = true; | 208 | force_tls = true; |
209 | try_tls = true; | ||
209 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 210 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
210 | try_tls = true; | 211 | try_tls = true; |
211 | } | 212 | } |
212 | int result = 1; | 213 | int result = 1; |
213 | port = m_SmtpAccount->getPort().toUInt(); | 214 | port = m_SmtpAccount->getPort().toUInt(); |
214 | 215 | ||
215 | m_smtp = mailsmtp_new( 20, &progress ); | 216 | m_smtp = mailsmtp_new( 20, &progress ); |
216 | if ( m_smtp == NULL ) { | 217 | if ( m_smtp == NULL ) { |
217 | /* no failure message cause this happens when problems with memory - than we | 218 | /* no failure message cause this happens when problems with memory - than we |
218 | we can not display any messagebox */ | 219 | we can not display any messagebox */ |
219 | return; | 220 | return; |
220 | } | 221 | } |
221 | 222 | ||
222 | int err = MAILSMTP_NO_ERROR; | 223 | int err = MAILSMTP_NO_ERROR; |
223 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; | 224 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; |
224 | if ( ssl ) { | 225 | if ( ssl ) { |
225 | qDebug("smtp: ssl_connect "); | 226 | qDebug("smtp: ssl_connect "); |
226 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); | 227 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); |
227 | } else { | 228 | } else { |
228 | ; // odebug << "No SSL session" << oendl; | 229 | ; // odebug << "No SSL session" << oendl; |
229 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); | 230 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); |
230 | } | 231 | } |
231 | if ( err != MAILSMTP_NO_ERROR ) { | 232 | if ( err != MAILSMTP_NO_ERROR ) { |
232 | qDebug("Error init SMTP connection" ); | 233 | qDebug("Error init SMTP connection" ); |
233 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); | 234 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); |
234 | result = 0; | 235 | result = 0; |
235 | } | 236 | } |
236 | 237 | ||
237 | qDebug("SMTP connection inited "); | 238 | qDebug("SMTP connection inited "); |
238 | /* switch to tls after init 'cause there it will send the ehlo */ | 239 | /* switch to tls after init 'cause there it will send the ehlo */ |
239 | if (result) { | 240 | if (result) { |
240 | err = mailsmtp_init( m_smtp ); | 241 | err = mailsmtp_init( m_smtp ); |
241 | if (err != MAILSMTP_NO_ERROR) { | 242 | if (err != MAILSMTP_NO_ERROR) { |
242 | result = 0; | 243 | result = 0; |
243 | qDebug("Error init SMTP connection "); | 244 | qDebug("Error init SMTP connection "); |
244 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); | 245 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); |
245 | } | 246 | } |
246 | } | 247 | } |
247 | if (result && try_tls) { | 248 | if (result && try_tls) { |
248 | qDebug("Smpt: Try tls "); | 249 | qDebug("Smpt: Try TLS... "); |
249 | err = start_smtp_tls(); | 250 | err = start_smtp_tls(); |
250 | if (err != MAILSMTP_NO_ERROR) { | 251 | if (err != MAILSMTP_NO_ERROR) { |
251 | try_tls = false; | 252 | try_tls = false; |
252 | qDebug("no tls "); | 253 | qDebug("Smpt: No TLS possible "); |
253 | } else { | 254 | } else { |
254 | err = mailesmtp_ehlo(m_smtp); | 255 | err = mailesmtp_ehlo(m_smtp); |
255 | if ( err != MAILSMTP_NO_ERROR ) | 256 | if ( err != MAILSMTP_NO_ERROR ) |
256 | result = 0; | 257 | result = 0; |
258 | else | ||
259 | qDebug("Smpt: Using TLS "); | ||
257 | } | 260 | } |
258 | } | 261 | } |
259 | //qDebug("mailesmtp_ehlo %d ",err ); | 262 | //qDebug("mailesmtp_ehlo %d ",err ); |
260 | if (!try_tls && force_tls) { | 263 | if (!try_tls && force_tls) { |
261 | result = 0; | 264 | result = 0; |
262 | failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err)); | 265 | failuretext = i18n("Error init SMTP tls:%1").arg(mailsmtpError(err)); |
263 | } | 266 | } |
264 | 267 | ||
265 | if (result==1 && m_SmtpAccount->getLogin() ) { | 268 | if (result==1 && m_SmtpAccount->getLogin() ) { |
266 | ; // odebug << "smtp with auth" << oendl; | 269 | ; // odebug << "smtp with auth" << oendl; |
267 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { | 270 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { |
268 | // get'em | 271 | // get'em |
269 | LoginDialog login( m_SmtpAccount->getUser(), | 272 | LoginDialog login( m_SmtpAccount->getUser(), |
270 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 273 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
271 | login.show(); | 274 | login.show(); |
272 | if ( QDialog::Accepted == login.exec() ) { | 275 | if ( QDialog::Accepted == login.exec() ) { |
273 | // ok | 276 | // ok |
274 | user = login.getUser(); | 277 | user = login.getUser(); |
275 | pass = login.getPassword(); | 278 | pass = login.getPassword(); |
276 | } else { | 279 | } else { |
277 | result = 0; | 280 | result = 0; |
278 | failuretext=i18n("Login aborted - \nstoring mail to localfolder"); | 281 | failuretext=i18n("Login aborted - \nstoring mail to localfolder"); |
279 | } | 282 | } |
280 | } else { | 283 | } else { |
281 | user = m_SmtpAccount->getUser(); | 284 | user = m_SmtpAccount->getUser(); |
282 | pass = m_SmtpAccount->getPassword(); | 285 | pass = m_SmtpAccount->getPassword(); |
283 | } | 286 | } |
284 | ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; | 287 | ; // odebug << "session->auth: " << m_smtp->auth << "" << oendl; |
285 | if (result) { | 288 | if (result) { |
286 | err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); | 289 | err = mailsmtp_auth( m_smtp, (char*)user.latin1(), (char*)pass.latin1() ); |
287 | if ( err == MAILSMTP_NO_ERROR ) { | 290 | if ( err == MAILSMTP_NO_ERROR ) { |
288 | qDebug("Smtp authentification ok "); | 291 | qDebug("Smtp authentification ok "); |
289 | } else { | 292 | } else { |
290 | failuretext = i18n("Authentification failed"); | 293 | failuretext = i18n("Authentification failed"); |
291 | result = 0; | 294 | result = 0; |
292 | } | 295 | } |
293 | } | 296 | } |
294 | } | 297 | } |
295 | if ( result == 0 ) { | 298 | if ( result == 0 ) { |
296 | mailsmtp_free(m_smtp); | 299 | mailsmtp_free(m_smtp); |
297 | m_smtp = 0; | 300 | m_smtp = 0; |
298 | } | 301 | } |
299 | } | 302 | } |
300 | 303 | ||
301 | void SMTPwrapper::disc_server() | 304 | void SMTPwrapper::disc_server() |
302 | { | 305 | { |
303 | if (m_smtp) { | 306 | if (m_smtp) { |
304 | mailsmtp_quit( m_smtp ); | 307 | mailsmtp_quit( m_smtp ); |