From 755dc2e8d8e4258e2a1fd63b3ed3f7775f66fffa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kundr=C3=A1t?= Date: Fri, 26 Oct 2012 18:15:51 +0200 Subject: [PATCH] MSA: better progress indication for mail submission via sendmail-compatible interface - react to QProcess starting - show progress for each written byte (that was there even before) - one more step for further waiting for delivery --- src/MSA/Sendmail.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/MSA/Sendmail.cpp b/src/MSA/Sendmail.cpp index 224451d7..c5a94614 100644 --- a/src/MSA/Sendmail.cpp +++ b/src/MSA/Sendmail.cpp @@ -42,7 +42,9 @@ Sendmail::~Sendmail() void Sendmail::sendMail(const QByteArray &from, const QList &to, const QByteArray &data) { - emit progressMax(data.size()); + // first +1 for the process startup + // second +1 for waiting for the result + emit progressMax(data.size() + 2); emit progress(0); QStringList myArgs = args; myArgs << "-f" << from; @@ -64,6 +66,9 @@ void Sendmail::cancel() void Sendmail::handleStarted() { + // The process has started already -> +1 + emit progress(1); + emit sending(); proc->write(dataToSend); proc->closeWriteChannel(); @@ -78,11 +83,15 @@ void Sendmail::handleError(QProcess::ProcessError e) void Sendmail::handleBytesWritten(qint64 bytes) { writtenSoFar += bytes; - emit progress(writtenSoFar); + // +1 due to starting at one + emit progress(writtenSoFar + 1); } void Sendmail::handleFinished(const int exitCode) { + // that's the last one + emit progressMax(dataToSend.size() + 2); + if (exitCode == 0) { emit sent(); return; -- 2.11.4.GIT