Diffstat (limited to 'noncore/unsupported/mail2/composer.cpp') (more/less context) (show 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 | |||
@@ -63,13 +63,12 @@ void Composer::hide() | |||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | void Composer::exec() | 66 | void Composer::exec() |
67 | { | 67 | { |
68 | show(); | 68 | show(); |
69 | |||
70 | if (!_inLoop) { | 69 | if (!_inLoop) { |
71 | _inLoop = true; | 70 | _inLoop = true; |
72 | qApp->enter_loop(); | 71 | qApp->enter_loop(); |
73 | } | 72 | } |
74 | } | 73 | } |
75 | 74 | ||
@@ -91,17 +90,13 @@ void Composer::setSendMail(SendMail &sendMail) | |||
91 | } | 90 | } |
92 | 91 | ||
93 | void Composer::slotResizing() | 92 | void Composer::slotResizing() |
94 | { | 93 | { |
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 | ||
104 | void Composer::slotPopupHandler(int itemid) | 99 | void Composer::slotPopupHandler(int itemid) |
105 | { | 100 | { |
106 | if (attachView->currentItem() == NULL) { | 101 | if (attachView->currentItem() == NULL) { |
107 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); | 102 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); |
@@ -168,21 +163,21 @@ void Composer::slotSendMail() | |||
168 | void Composer::slotSendQueued() | 163 | void Composer::slotSendQueued() |
169 | { | 164 | { |
170 | 165 | ||
171 | qDebug("Sending queued messages"); | 166 | qDebug("Sending queued messages"); |
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); |
185 | cfg.setGroup( "Mail_" + QString::number(i) ); | 180 | cfg.setGroup( "Mail_" + QString::number(i) ); |
186 | SendMail smail; | 181 | SendMail smail; |
187 | str = cfg.readEntry("from"); | 182 | str = cfg.readEntry("from"); |
188 | qDebug("setFrom %s",str.latin1()); | 183 | qDebug("setFrom %s",str.latin1()); |
@@ -246,19 +241,16 @@ void Composer::slotSendQueued() | |||
246 | 241 | ||
247 | // abort->setEnabled(true); | 242 | // abort->setEnabled(true); |
248 | 243 | ||
249 | qDebug("Sending to %s",toAdr.latin1()); | 244 | qDebug("Sending to %s",toAdr.latin1()); |
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 | } |
261 | 253 | ||
262 | void Composer::slotQueueMail() | 254 | void Composer::slotQueueMail() |
263 | { | 255 | { |
264 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { | 256 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { |
@@ -307,20 +299,49 @@ void Composer::slotQueueMail() | |||
307 | void Composer::slotSendError(const QString &error) | 299 | void Composer::slotSendError(const QString &error) |
308 | { | 300 | { |
309 | status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); | 301 | 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")); | 302 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); |
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 | { |
315 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); | 315 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); |
316 | 316 | ||
317 | status->setText(QString(0)); | 317 | status->setText(QString(0)); |
318 | abort->setEnabled(false); | 318 | abort->setEnabled(false); |
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 | { |
323 | QValueList<Account> accounts = ConfigFile::getAccounts(); | 344 | QValueList<Account> accounts = ConfigFile::getAccounts(); |
324 | int i = 0; | 345 | int i = 0; |
325 | 346 | ||
326 | QValueList<Account>::Iterator it; | 347 | QValueList<Account>::Iterator it; |