author | tille <tille> | 2002-06-18 23:53:27 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-18 23:53:27 (UTC) |
commit | 14881bb4baf3ac470a135bdde6ffb115c91ea124 (patch) (unidiff) | |
tree | 6d088cdacd769076e64496abe6b9043168b75928 /noncore/unsupported/mail2/composer.cpp | |
parent | f2ecc05c1156ae0f99ea0528646609d63eaa84c0 (diff) | |
download | opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.zip opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.tar.gz opie-14881bb4baf3ac470a135bdde6ffb115c91ea124.tar.bz2 |
added menu and fix send queued
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 | |||
@@ -66,7 +66,6 @@ void Composer::hide() | |||
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(); |
@@ -94,11 +93,7 @@ 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) |
@@ -171,15 +166,15 @@ void Composer::slotSendQueued() | |||
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) ); |
@@ -249,13 +244,10 @@ void Composer::slotSendQueued() | |||
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 | ||
@@ -310,6 +302,14 @@ void Composer::slotSendError(const QString &error) | |||
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")); |
@@ -318,6 +318,27 @@ void Composer::slotSendFinished() | |||
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(); |