author | zautrix <zautrix> | 2005-03-11 19:26:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-11 19:26:02 (UTC) |
commit | 1166a4797a91cedd5002a3513d5028c5e86016f0 (patch) (unidiff) | |
tree | 8e7443bc887a15dcf3852abd36e6e61f2e6bddad /kmicromail/libmailwrapper | |
parent | 71462ba8ef1803787bba6793f1adb85987eb57df (diff) | |
download | kdepimpi-1166a4797a91cedd5002a3513d5028c5e86016f0.zip kdepimpi-1166a4797a91cedd5002a3513d5028c5e86016f0.tar.gz kdepimpi-1166a4797a91cedd5002a3513d5028c5e86016f0.tar.bz2 |
better kopi export
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
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 | |||
@@ -151,322 +151,337 @@ bool SMTPwrapper::smtpSend( mailmime *mail,bool later) { | |||
151 | if (rcpts) | 151 | if (rcpts) |
152 | smtp_address_list_free( rcpts ); | 152 | smtp_address_list_free( rcpts ); |
153 | return result; | 153 | return result; |
154 | } | 154 | } |
155 | 155 | ||
156 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) | 156 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) |
157 | { | 157 | { |
158 | if (data) { | 158 | if (data) { |
159 | storeMail(data,size,"Sendfailed"); | 159 | storeMail(data,size,"Sendfailed"); |
160 | } | 160 | } |
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 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 209 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
210 | try_tls = true; | 210 | try_tls = true; |
211 | } | 211 | } |
212 | int result = 1; | 212 | int result = 1; |
213 | port = m_SmtpAccount->getPort().toUInt(); | 213 | port = m_SmtpAccount->getPort().toUInt(); |
214 | 214 | ||
215 | m_smtp = mailsmtp_new( 20, &progress ); | 215 | m_smtp = mailsmtp_new( 20, &progress ); |
216 | if ( m_smtp == NULL ) { | 216 | if ( m_smtp == NULL ) { |
217 | /* no failure message cause this happens when problems with memory - than we | 217 | /* no failure message cause this happens when problems with memory - than we |
218 | we can not display any messagebox */ | 218 | we can not display any messagebox */ |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | int err = MAILSMTP_NO_ERROR; | 222 | int err = MAILSMTP_NO_ERROR; |
223 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; | 223 | ; // odebug << "Servername " << server << " at port " << port << "" << oendl; |
224 | if ( ssl ) { | 224 | if ( ssl ) { |
225 | qDebug("smtp: ssl_connect "); | 225 | qDebug("smtp: ssl_connect "); |
226 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); | 226 | err = mailsmtp_ssl_connect( m_smtp, server.latin1(), port ); |
227 | } else { | 227 | } else { |
228 | ; // odebug << "No SSL session" << oendl; | 228 | ; // odebug << "No SSL session" << oendl; |
229 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); | 229 | err = mailsmtp_socket_connect( m_smtp, server.latin1(), port ); |
230 | } | 230 | } |
231 | if ( err != MAILSMTP_NO_ERROR ) { | 231 | if ( err != MAILSMTP_NO_ERROR ) { |
232 | qDebug("Error init SMTP connection" ); | 232 | qDebug("Error init SMTP connection" ); |
233 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); | 233 | failuretext = i18n("Error init SMTP connection:\n%1").arg(mailsmtpError(err)); |
234 | result = 0; | 234 | result = 0; |
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 |
267 | LoginDialog login( m_SmtpAccount->getUser(), | 269 | LoginDialog login( m_SmtpAccount->getUser(), |
268 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 270 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
269 | login.show(); | 271 | login.show(); |
270 | if ( QDialog::Accepted == login.exec() ) { | 272 | if ( QDialog::Accepted == login.exec() ) { |
271 | // ok | 273 | // ok |
272 | user = login.getUser(); | 274 | user = login.getUser(); |
273 | pass = login.getPassword(); | 275 | pass = login.getPassword(); |
274 | } else { | 276 | } else { |
275 | result = 0; | 277 | result = 0; |
276 | failuretext=i18n("Login aborted - \nstoring mail to localfolder"); | 278 | failuretext=i18n("Login aborted - \nstoring mail to localfolder"); |
277 | } | 279 | } |
278 | } else { | 280 | } else { |
279 | user = m_SmtpAccount->getUser(); | 281 | user = m_SmtpAccount->getUser(); |
280 | pass = m_SmtpAccount->getPassword(); | 282 | pass = m_SmtpAccount->getPassword(); |
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 | ||
295 | void SMTPwrapper::disc_server() | 301 | void 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 | ||
304 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | 310 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) |
305 | { | 311 | { |
306 | int err,result; | 312 | int err,result; |
307 | QString failuretext = ""; | 313 | QString failuretext = ""; |
308 | 314 | ||
309 | connect_server(); | 315 | connect_server(); |
310 | 316 | ||
311 | result = 1; | 317 | result = 1; |
312 | if (m_smtp) { | 318 | if (m_smtp) { |
313 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 319 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
314 | if ( err != MAILSMTP_NO_ERROR ) { | 320 | if ( err != MAILSMTP_NO_ERROR ) { |
315 | qDebug("Error sending mail"); | 321 | qDebug("Error sending mail"); |
316 | failuretext=i18n("Error sending mail:\n%1").arg(mailsmtpError(err)); | 322 | failuretext=i18n("Error sending mail:\n%1").arg(mailsmtpError(err)); |
317 | result = 0; | 323 | result = 0; |
318 | } | 324 | } |
319 | } else { | 325 | } else { |
320 | result = 0; | 326 | result = 0; |
321 | } | 327 | } |
322 | 328 | ||
323 | if (!result) { | 329 | if (!result) { |
324 | storeFailedMail(data,size,failuretext); | 330 | storeFailedMail(data,size,failuretext); |
325 | } else { | 331 | } else { |
326 | ; // odebug << "Mail sent." << oendl; | 332 | ; // odebug << "Mail sent." << oendl; |
327 | storeMail(data,size,"Sent"); | 333 | storeMail(data,size,"Sent"); |
328 | } | 334 | } |
329 | return result; | 335 | return result; |
330 | } | 336 | } |
331 | 337 | ||
332 | bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) | 338 | bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) |
333 | { | 339 | { |
334 | mailmime * mimeMail; | 340 | mailmime * mimeMail; |
335 | bool result = true; | 341 | bool result = true; |
336 | mimeMail = createMimeMail(mail ); | 342 | mimeMail = createMimeMail(mail ); |
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 | ||
354 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | 364 | int 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 | ||
362 | encodedString * data = wrap->fetchRawBody(which); | 372 | encodedString * data = wrap->fetchRawBody(which); |
363 | if (!data) | 373 | if (!data) |
364 | return 0; | 374 | return 0; |
365 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 375 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
366 | if (err != MAILIMF_NO_ERROR) { | 376 | if (err != MAILIMF_NO_ERROR) { |
367 | delete data; | 377 | delete data; |
368 | delete wrap; | 378 | delete wrap; |
369 | return 0; | 379 | return 0; |
370 | } | 380 | } |
371 | 381 | ||
372 | rcpts = createRcptList( fields ); | 382 | rcpts = createRcptList( fields ); |
373 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 383 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
374 | from = getFrom(ffrom); | 384 | from = getFrom(ffrom); |
375 | 385 | ||
376 | if (rcpts && from) { | 386 | if (rcpts && from) { |
377 | res = smtpSend(from,rcpts,data->Content(),data->Length()); | 387 | res = smtpSend(from,rcpts,data->Content(),data->Length()); |
378 | } | 388 | } |
379 | if (fields) { | 389 | if (fields) { |
380 | mailimf_fields_free(fields); | 390 | mailimf_fields_free(fields); |
381 | fields = 0; | 391 | fields = 0; |
382 | } | 392 | } |
383 | if (data) { | 393 | if (data) { |
384 | delete data; | 394 | delete data; |
385 | } | 395 | } |
386 | if (from) { | 396 | if (from) { |
387 | free(from); | 397 | free(from); |
388 | } | 398 | } |
389 | if (rcpts) { | 399 | if (rcpts) { |
390 | smtp_address_list_free( rcpts ); | 400 | smtp_address_list_free( rcpts ); |
391 | } | 401 | } |
392 | return res; | 402 | return res; |
393 | } | 403 | } |
394 | 404 | ||
395 | /* this is a special fun */ | 405 | /* this is a special fun */ |
396 | bool SMTPwrapper::flushOutbox() { | 406 | bool SMTPwrapper::flushOutbox() { |
397 | bool returnValue = true; | 407 | bool returnValue = true; |
398 | 408 | ||
399 | ; // odebug << "Sending the queue" << oendl; | 409 | ; // odebug << "Sending the queue" << oendl; |
400 | if (!m_SmtpAccount) { | 410 | if (!m_SmtpAccount) { |
401 | ; // odebug << "No smtp account given" << oendl; | 411 | ; // odebug << "No smtp account given" << oendl; |
402 | return false; | 412 | return false; |
403 | } | 413 | } |
404 | 414 | ||
405 | bool reset_user_value = false; | 415 | bool reset_user_value = false; |
406 | QString localfolders = AbstractMail::defaultLocalfolder(); | 416 | QString localfolders = AbstractMail::defaultLocalfolder(); |
407 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 417 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
408 | if (!wrap) { | 418 | if (!wrap) { |
409 | ; // odebug << "memory error" << oendl; | 419 | ; // odebug << "memory error" << oendl; |
410 | return false; | 420 | return false; |
411 | } | 421 | } |
412 | QString oldPw, oldUser; | 422 | QString oldPw, oldUser; |
413 | QValueList<RecMailP> mailsToSend; | 423 | QValueList<RecMailP> mailsToSend; |
414 | QValueList<RecMailP> mailsToRemove; | 424 | QValueList<RecMailP> mailsToRemove; |
415 | QString mbox("Outgoing"); | 425 | QString mbox("Outgoing"); |
416 | wrap->listMessages(mbox,mailsToSend); | 426 | wrap->listMessages(mbox,mailsToSend); |
417 | if (mailsToSend.count()==0) { | 427 | if (mailsToSend.count()==0) { |
418 | delete wrap; | 428 | delete wrap; |
419 | ; // odebug << "No mails to send" << oendl; | 429 | ; // odebug << "No mails to send" << oendl; |
420 | return false; | 430 | return false; |
421 | } | 431 | } |
422 | 432 | ||
423 | oldPw = m_SmtpAccount->getPassword(); | 433 | oldPw = m_SmtpAccount->getPassword(); |
424 | oldUser = m_SmtpAccount->getUser(); | 434 | oldUser = m_SmtpAccount->getUser(); |
425 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 435 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
426 | // get'em | 436 | // get'em |
427 | QString user,pass; | 437 | QString user,pass; |
428 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 438 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
429 | login.show(); | 439 | login.show(); |
430 | if ( QDialog::Accepted == login.exec() ) { | 440 | if ( QDialog::Accepted == login.exec() ) { |
431 | // ok | 441 | // ok |
432 | user = login.getUser().latin1(); | 442 | user = login.getUser().latin1(); |
433 | pass = login.getPassword().latin1(); | 443 | pass = login.getPassword().latin1(); |
434 | reset_user_value = true; | 444 | reset_user_value = true; |
435 | m_SmtpAccount->setUser(user); | 445 | m_SmtpAccount->setUser(user); |
436 | m_SmtpAccount->setPassword(pass); | 446 | m_SmtpAccount->setPassword(pass); |
437 | } else { | 447 | } else { |
438 | return true; | 448 | return true; |
439 | } | 449 | } |
440 | } | 450 | } |
441 | 451 | ||
442 | 452 | ||
443 | sendProgress = new progressMailSend(); | 453 | sendProgress = new progressMailSend(); |
444 | sendProgress->show(); | 454 | sendProgress->show(); |
445 | sendProgress->setMaxMails(mailsToSend.count()); | 455 | sendProgress->setMaxMails(mailsToSend.count()); |
446 | 456 | ||
447 | while (returnValue && mailsToSend.count()>0) { | 457 | while (returnValue && mailsToSend.count()>0) { |
448 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { | 458 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { |
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 | } |