author | tille <tille> | 2002-06-18 23:53:27 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-18 23:53:27 (UTC) |
commit | 14881bb4baf3ac470a135bdde6ffb115c91ea124 (patch) (side-by-side diff) | |
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 @@ -57,25 +57,24 @@ void Composer::hide() { QWidget::hide(); if (_inLoop) { _inLoop = false; qApp->exit_loop(); } } void Composer::exec() { show(); - if (!_inLoop) { _inLoop = true; qApp->enter_loop(); } } void Composer::setSendMail(SendMail &sendMail) { to->setText(sendMail.to()); cc->setText(sendMail.cc()); bcc->setText(sendMail.bcc()); subject->setText(sendMail.subject()); @@ -85,29 +84,25 @@ void Composer::setSendMail(SendMail &sendMail) QValueList<Attachment> attachments = sendMail.attachments(); QValueList<Attachment>::Iterator it; for (it = attachments.begin(); it != attachments.end(); it++) { (void) new AttachViewItem(attachView, *it); if (attachView->isHidden()) attachView->show(); } } void Composer::slotResizing() { from->setMaximumWidth(width() - fromBox->width()); from->resize(width() - fromBox->width(), y()); - if (_sendQueued) - { - slotSendQueued(); - close(); - } + if (_sendQueued) slotSendQueued(); } void Composer::slotPopupHandler(int itemid) { if (attachView->currentItem() == NULL) { QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); return; } if (itemid == POPUP_ATTACH_RENAME) { QString tmp = Rename::rename(attachView->currentItem()->text(0), this); if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); @@ -162,33 +157,33 @@ void Composer::slotSendMail() SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); } void Composer::slotSendQueued() { qDebug("Sending queued messages"); Config cfg( "mailqueue", Config::User ); cfg.setGroup( "Settings" ); - int count = cfg.readNumEntry( "count", 0 ); - // tille: should not be here - // but no error checking for the moment - cfg.writeEntry( "count", 0 ); + _sendCount = 0; + _sendError = 0; + _toSend = cfg.readNumEntry( "count", 0 ); + if (_toSend == 0) close(); - qDebug("%i messages to send", count); + qDebug("%i messages to send", _toSend); QString str; - for (int i=1;i<=count;i++) + for (int i=1;i<=_toSend;i++) { qDebug("sending message %i",i); cfg.setGroup( "Mail_" + QString::number(i) ); SendMail smail; str = cfg.readEntry("from"); qDebug("setFrom %s",str.latin1()); smail.setFrom( str ); str = cfg.readEntry("reply"); qDebug("setReplyTo %s",str.latin1()); smail.setReplyTo( str ); QString toAdr = cfg.readEntry("to"); qDebug("to %s",toAdr.latin1()); @@ -240,31 +235,28 @@ void Composer::slotSendQueued() qDebug("putting mail together"); QString header, message; MailFactory::genMail(header, message, smail, this); if (header.isNull() || message.isNull()) continue;//return; // Aborted. // abort->setEnabled(true); qDebug("Sending to %s",toAdr.latin1()); SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); - connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); - connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); + connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); + connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &))); connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); - qDebug("remove mail %i", i); - cfg.clearGroup(); - cfg.removeEntry( "Mail_" + QString::number(i) ); } } void Composer::slotQueueMail() { if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); return; } Config cfg( "mailqueue", Config::User ); @@ -301,32 +293,61 @@ void Composer::slotQueueMail() } QMessageBox::information(this, tr("Success"), tr("<p>The mail was queued successfully.</p><p>The queue contains ")+QString::number(count)+tr(" mails.</p>"), tr("Ok")); } void Composer::slotSendError(const QString &error) { status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); } +void Composer::slotSendQueuedError(const QString &error) +{ + _sendError++; + qDebug("error send mail %i",_sendCount); + status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); + QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); +} + void Composer::slotSendFinished() { QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); status->setText(QString(0)); abort->setEnabled(false); } +void Composer::slotSendQueuedFinished() +{ + + _sendCount++; + qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); + if (_sendCount < _toSend) return; + if (_sendError == _toSend) close(); + 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")); + Config cfg( "mailqueue", Config::User ); + cfg.setGroup( "Settings" ); + cfg.writeEntry( "count", 0 ); + for (int i=1;i<=_sendCount;i++) + { + cfg.setGroup( "Mail_" + QString::number(i) ); + qDebug("remove mail %i", i); + cfg.clearGroup(); + cfg.removeEntry( "Mail_" + QString::number(i) ); + } + close(); +} + void Composer::slotFillStuff() { QValueList<Account> accounts = ConfigFile::getAccounts(); int i = 0; QValueList<Account>::Iterator it; for (it = accounts.begin(); it != accounts.end(); it++) { if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { if (!(*it).realName().isEmpty()) from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); else from->insertItem((*it).email()); |