summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/composer.cpp
Side-by-side diff
Diffstat (limited to 'noncore/unsupported/mail2/composer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index 03dacae..52ebbdd 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -119,183 +119,188 @@ void Composer::slotPopupHandler(int itemid)
void Composer::slotSendMail()
{
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;
}
SendMail smail;
smail.setFrom(from->currentText());
smail.setReplyTo(replyto->text());
smail.setTo(to->text());
smail.setCc(cc->text());
smail.setBcc(bcc->text());
smail.setSubject(subject->text());
smail.setMessage(message->text());
smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
smail.setAccount(accountsLoaded[from->currentItem()]);
if (priority->currentItem() == POPUP_PRIO_LOW) {
smail.setPriority("Low"); // No i18n on purpose
} else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
smail.setPriority("Normal"); // No i18n on purpose
} else if (priority->currentItem() == POPUP_PRIO_HIGH) {
smail.setPriority("High"); // No i18n on purpose
}
QValueList<Attachment> attachments;
QListViewItem *item;
for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
attachments.append(((AttachViewItem *)item)->attachment());
}
smail.setAttachments(attachments);
QString header, message;
MailFactory::genMail(header, message, smail, this);
if (header.isNull() || message.isNull()) return; // Aborted.
abort->setEnabled(true);
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()
{
-
+ int effSendCount = 0;
qDebug("Sending queued messages");
Config cfg( "mailqueue", Config::User );
cfg.setGroup( "Settings" );
_sendCount = 0;
_sendError = 0;
_toSend = cfg.readNumEntry( "count", 0 );
if (_toSend == 0) close();
qDebug("%i messages to send", _toSend);
QString str;
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());
smail.setTo( toAdr ); //to->text());
str = cfg.readEntry("cc");
qDebug("setCc %s",str.latin1());
smail.setCc( str ); //cc->text());
smail.setBcc( cfg.readEntry("bcc") ); //bcc->text());
str = cfg.readEntry("subject");
qDebug("setSubject %s",str.latin1());
smail.setSubject( str ); //subject->text());
str = cfg.readEntryCrypt("message");
qDebug("setMessage %s",str.latin1());
smail.setMessage( str ); //message->text());
smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true);
qDebug("setting account [%i]",cfg.readNumEntry("account"));
Account accnt = accountsLoaded[ cfg.readNumEntry("account") ];
smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]);
int prio = cfg.readNumEntry( "priority" );
qDebug("setting priority %i",prio);
if (prio == POPUP_PRIO_LOW) {
smail.setPriority("Low"); // No i18n on purpose
} else if (prio == POPUP_PRIO_NORMAL) {
smail.setPriority("Normal"); // No i18n on purpose
} else if (prio == POPUP_PRIO_HIGH) {
smail.setPriority("High"); // No i18n on purpose
}
QValueList<Attachment> attachments;
Attachment a;
QString an;
int ac = cfg.readNumEntry( "attachments", 0 );
qDebug("%i Attachments",ac);
for (int j = 0; i < ac; ac++) {
an = "Attachment_" + QString::number( j );
qDebug(an.latin1());
a.setFileName(cfg.readEntry( an + "fileName" ));
a.setNewName(cfg.readEntry( an + "newName" ));
a.setDescription(cfg.readEntry( an + "description" ));
a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) );
attachments.append( a );
}
smail.setAttachments(attachments);
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);
-
+ effSendCount++;
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 &)));
}
+ if (effSendCount < _toSend)
+ {
+ _toSend = effSendCount;
+ QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok"));
+ }
}
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 );
cfg.setGroup( "Settings" );
int count = cfg.readNumEntry( "count", 0 );
count++;
cfg.writeEntry( "count", count );
qDebug("queueing mail %i",count);
cfg.setGroup( "Mail_" + QString::number( count ));
cfg.writeEntry( "from", from->currentText() );
cfg.writeEntry( "reply", replyto->text());
cfg.writeEntry( "to", to->text());
cfg.writeEntry( "cc", cc->text());
cfg.writeEntry( "bcc", bcc->text());
cfg.writeEntry( "subject", subject->text());
cfg.writeEntryCrypt( "message", message->text());
cfg.writeEntry( "mime", attachView->childCount() == 0 );
cfg.writeEntry( "account", from->currentItem());
cfg.writeEntry( "priority", priority->currentItem() );
cfg.writeEntry( "attachments", attachView->childCount() );
Attachment a;
QListViewItem *item;
QString an;
int i = 0;
for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
a = ((AttachViewItem *)item)->attachment();
an = "Attachment_" + QString::number( i++ );
cfg.writeEntry( an + "fileName", a.fileName() );
cfg.writeEntry( an + "newName", a.newName() );
cfg.writeEntry( an + "description", a.description() );
cfg.writeEntry( an + "docLnk", a.docLnk().file() );
}
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)