From 584fc9ae45da46a7d84611c61ff14c43377f4e32 Mon Sep 17 00:00:00 2001 From: Eric Springer Date: Wed, 29 Jun 2011 19:33:50 +1000 Subject: Return ConfigurationError if no greeting received in 20 seconds --- CHANGES | 3 +++ src/plugins/messageservices/smtp/smtpclient.cpp | 18 ++++++++++++++++++ src/plugins/messageservices/smtp/smtpclient.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/CHANGES b/CHANGES index e12e4905..c7dceb3c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Latest Changes --------------- +201126 + * Fixes: NB#195729 ConfigurationError not shown when account is configured with wrong settings + 201125 * Fixes: NB#215942 Traditional Chinese character is corrupted in mailbox * Fixes: NB#232541 Invitations not displayed in the message viewer for Gmail diff --git a/src/plugins/messageservices/smtp/smtpclient.cpp b/src/plugins/messageservices/smtp/smtpclient.cpp index 274ff64b..50d05d76 100644 --- a/src/plugins/messageservices/smtp/smtpclient.cpp +++ b/src/plugins/messageservices/smtp/smtpclient.cpp @@ -108,6 +108,7 @@ SmtpClient::SmtpClient(QObject* parent) , temporaryFile(0) , waitingForBytes(0) , notUsingAuth(false) + , authTimeout(0) { connect(QMailStore::instance(), SIGNAL(accountsUpdated(const QMailAccountIdList&)), this, SLOT(accountsUpdated(const QMailAccountIdList&))); @@ -117,6 +118,7 @@ SmtpClient::~SmtpClient() { delete transport; delete temporaryFile; + delete authTimeout; } void SmtpClient::accountsUpdated(const QMailAccountIdList &ids) @@ -245,6 +247,13 @@ QMailServiceAction::Status::ErrorCode SmtpClient::addMail(const QMailMessage& ma void SmtpClient::connected(QMailTransport::EncryptType encryptType) { + authTimeout = new QTimer; + authTimeout->setSingleShot(true); + const int twentySeconds = 20 * 1000; + connect(authTimeout, SIGNAL(timeout()), this, SLOT(authExpired())); + authTimeout->setInterval(twentySeconds); + authTimeout->start(); + SmtpConfiguration smtpCfg(config); if (smtpCfg.smtpEncryption() == encryptType) { qMailLog(SMTP) << "Connected" << flush; @@ -332,6 +341,8 @@ void SmtpClient::incomingData() notUsingAuth = false; } } + delete authTimeout; + authTimeout = 0; if (outstandingResponses > 0) { --outstandingResponses; @@ -907,6 +918,13 @@ void SmtpClient::sendMoreData(qint64 bytesWritten) //qMailLog(SMTP) << "Body: sent a" << bytes << "byte block"; } +void SmtpClient::authExpired() +{ + status = Done; + operationFailed(QMailServiceAction::Status::ErrConfiguration, tr("Have not received any greeting from SMTP server, probably configuration error")); + return; +} + void SmtpClient::stopTransferring() { if (temporaryFile) diff --git a/src/plugins/messageservices/smtp/smtpclient.h b/src/plugins/messageservices/smtp/smtpclient.h index c52c261a..008ed345 100644 --- a/src/plugins/messageservices/smtp/smtpclient.h +++ b/src/plugins/messageservices/smtp/smtpclient.h @@ -96,6 +96,7 @@ protected slots: private slots: void sendMoreData(qint64); + void authExpired(); private: void sendCommand(const char *data, int len = -1); @@ -146,6 +147,8 @@ private: QString bufferedResponse; bool notUsingAuth; + + QTimer *authTimeout; }; #endif -- cgit v1.2.3