1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 13:04:23 +00:00

Merge pull request #5549 from briankendall/smtp_ssl_bug_fixes

Fixes bug where sending email could silently fail
This commit is contained in:
sledgehammer999 2016-08-25 20:45:11 -05:00 committed by GitHub
commit d411d8b3a1
3 changed files with 24 additions and 0 deletions

View File

@ -97,6 +97,13 @@ Smtp::Smtp(QObject *parent)
, m_useSsl(false) , m_useSsl(false)
, m_authType(AuthPlain) , m_authType(AuthPlain)
{ {
static bool needToRegisterMetaType = true;
if (needToRegisterMetaType) {
qRegisterMetaType<QAbstractSocket::SocketError>();
needToRegisterMetaType = false;
}
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
m_socket = new QSslSocket(this); m_socket = new QSslSocket(this);
#else #else
@ -105,6 +112,7 @@ Smtp::Smtp(QObject *parent)
connect(m_socket, SIGNAL(readyRead()), SLOT(readyRead())); connect(m_socket, SIGNAL(readyRead()), SLOT(readyRead()));
connect(m_socket, SIGNAL(disconnected()), SLOT(deleteLater())); connect(m_socket, SIGNAL(disconnected()), SLOT(deleteLater()));
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError)));
// Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html) // Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html)
Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex() Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex()
@ -525,3 +533,11 @@ QString Smtp::getCurrentDateTime() const
QString ret = weekDayStr + ", " + dayStr + " " + monthStr + " " + yearStr + " " + timeStr + " " + timeOffsetStr; QString ret = weekDayStr + ", " + dayStr + " " + monthStr + " " + yearStr + " " + timeStr + " " + timeOffsetStr;
return ret; return ret;
} }
void Smtp::error(QAbstractSocket::SocketError socketError)
{
// Getting a remote host closed error is apparently normal, even when successfully sending
// an email
if (socketError != QAbstractSocket::RemoteHostClosedError)
logError(m_socket->errorString());
}

View File

@ -39,6 +39,8 @@
#include <QObject> #include <QObject>
#include <QByteArray> #include <QByteArray>
#include <QHash> #include <QHash>
#include <QAbstractSocket>
#include <QMetaType>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTextStream; class QTextStream;
@ -64,6 +66,7 @@ namespace Net
private slots: private slots:
void readyRead(); void readyRead();
void error(QAbstractSocket::SocketError socketError);
private: private:
enum States enum States
@ -123,4 +126,8 @@ namespace Net
}; };
} }
#ifndef QBT_USES_QT5
Q_DECLARE_METATYPE(QAbstractSocket::SocketError)
#endif
#endif #endif

View File

@ -149,6 +149,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
#if defined(QT_NO_OPENSSL) #if defined(QT_NO_OPENSSL)
m_ui->checkWebUiHttps->setVisible(false); m_ui->checkWebUiHttps->setVisible(false);
m_ui->checkSmtpSSL->setVisible(false);
#endif #endif
#ifndef Q_OS_WIN #ifndef Q_OS_WIN