From 3d3f9136af7a0c1ac89393640fbba98d50172d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20T=C5=91k=C3=A9s?= Date: Wed, 5 Sep 2012 19:36:52 +0300 Subject: [PATCH] Bug fix (issue 2) --- src/smtpclient.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/smtpclient.cpp b/src/smtpclient.cpp index 75a717c..ffa4e6f 100644 --- a/src/smtpclient.cpp +++ b/src/smtpclient.cpp @@ -380,23 +380,29 @@ void SmtpClient::quit() void SmtpClient::waitForResponse() throw (ResponseTimeoutException) { - if (!socket->waitForReadyRead(responseTimeout)) - { - emit smtpError(ResponseTimeoutError); - throw ResponseTimeoutException(); - } + do { + if (!socket->waitForReadyRead(responseTimeout)) + { + emit smtpError(ResponseTimeoutError); + throw ResponseTimeoutException(); + } - // Save the server's response - responseText = socket->readAll(); + while (socket->canReadLine()) { + // Save the server's response + responseText = socket->readLine(); - // Extract the respose code from the server's responce (first 3 digits) - responseCode = responseText.left(3).toInt(); + // Extract the respose code from the server's responce (first 3 digits) + responseCode = responseText.left(3).toInt(); - if (responseCode / 100 == 4) - emit smtpError(ServerError); + if (responseCode / 100 == 4) + emit smtpError(ServerError); - if (responseCode / 100 == 5) - emit smtpError(ClientError); + if (responseCode / 100 == 5) + emit smtpError(ClientError); + + if (responseText[3] == ' ') { return; } + } + } while (true); } void SmtpClient::sendMessage(const QString &text)