Diffstat (limited to 'noncore/unsupported/mail2/composer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/composer.cpp | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index 1d793ee..72a7242 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp | |||
@@ -67,5 +67,4 @@ void Composer::exec() | |||
67 | { | 67 | { |
68 | show(); | 68 | show(); |
69 | |||
70 | if (!_inLoop) { | 69 | if (!_inLoop) { |
71 | _inLoop = true; | 70 | _inLoop = true; |
@@ -95,9 +94,5 @@ void Composer::slotResizing() | |||
95 | from->setMaximumWidth(width() - fromBox->width()); | 94 | from->setMaximumWidth(width() - fromBox->width()); |
96 | from->resize(width() - fromBox->width(), y()); | 95 | from->resize(width() - fromBox->width(), y()); |
97 | if (_sendQueued) | 96 | if (_sendQueued) slotSendQueued(); |
98 | { | ||
99 | slotSendQueued(); | ||
100 | close(); | ||
101 | } | ||
102 | } | 97 | } |
103 | 98 | ||
@@ -172,13 +167,13 @@ void Composer::slotSendQueued() | |||
172 | Config cfg( "mailqueue", Config::User ); | 167 | Config cfg( "mailqueue", Config::User ); |
173 | cfg.setGroup( "Settings" ); | 168 | cfg.setGroup( "Settings" ); |
174 | int count = cfg.readNumEntry( "count", 0 ); | 169 | _sendCount = 0; |
175 | // tille: should not be here | 170 | _sendError = 0; |
176 | // but no error checking for the moment | 171 | _toSend = cfg.readNumEntry( "count", 0 ); |
177 | cfg.writeEntry( "count", 0 ); | ||
178 | 172 | ||
173 | if (_toSend == 0) close(); | ||
179 | 174 | ||
180 | qDebug("%i messages to send", count); | 175 | qDebug("%i messages to send", _toSend); |
181 | QString str; | 176 | QString str; |
182 | for (int i=1;i<=count;i++) | 177 | for (int i=1;i<=_toSend;i++) |
183 | { | 178 | { |
184 | qDebug("sending message %i",i); | 179 | qDebug("sending message %i",i); |
@@ -250,11 +245,8 @@ void Composer::slotSendQueued() | |||
250 | SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); | 245 | SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); |
251 | 246 | ||
252 | connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); | 247 | connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); |
253 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); | 248 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &))); |
254 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); | 249 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); |
255 | 250 | ||
256 | qDebug("remove mail %i", i); | ||
257 | cfg.clearGroup(); | ||
258 | cfg.removeEntry( "Mail_" + QString::number(i) ); | ||
259 | } | 251 | } |
260 | } | 252 | } |
@@ -311,4 +303,12 @@ void Composer::slotSendError(const QString &error) | |||
311 | } | 303 | } |
312 | 304 | ||
305 | void Composer::slotSendQueuedError(const QString &error) | ||
306 | { | ||
307 | _sendError++; | ||
308 | qDebug("error send mail %i",_sendCount); | ||
309 | status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); | ||
310 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); | ||
311 | } | ||
312 | |||
313 | void Composer::slotSendFinished() | 313 | void Composer::slotSendFinished() |
314 | { | 314 | { |
@@ -319,4 +319,25 @@ void Composer::slotSendFinished() | |||
319 | } | 319 | } |
320 | 320 | ||
321 | void Composer::slotSendQueuedFinished() | ||
322 | { | ||
323 | |||
324 | _sendCount++; | ||
325 | qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); | ||
326 | if (_sendCount < _toSend) return; | ||
327 | if (_sendError == _toSend) close(); | ||
328 | QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok")); | ||
329 | Config cfg( "mailqueue", Config::User ); | ||
330 | cfg.setGroup( "Settings" ); | ||
331 | cfg.writeEntry( "count", 0 ); | ||
332 | for (int i=1;i<=_sendCount;i++) | ||
333 | { | ||
334 | cfg.setGroup( "Mail_" + QString::number(i) ); | ||
335 | qDebug("remove mail %i", i); | ||
336 | cfg.clearGroup(); | ||
337 | cfg.removeEntry( "Mail_" + QString::number(i) ); | ||
338 | } | ||
339 | close(); | ||
340 | } | ||
341 | |||
321 | void Composer::slotFillStuff() | 342 | void Composer::slotFillStuff() |
322 | { | 343 | { |