1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
void MyThread::doSslConnect(const QByteArray &databyte)
{
socket_proxy = new QSslSocket();
if (!socket_proxy->supportsSsl()) {
emit appendSignalText("SSL is not supported by your version of Qt. You must obtain a version of Qt", Qt::red);
delete socket_proxy;
return;
}
connect(socket_proxy, SIGNAL(connected()),this, SLOT(connectedProxy()), Qt::DirectConnection);
connect(socket_proxy, SIGNAL(disconnected()),this, SLOT(disconnectedProxy()), Qt::DirectConnection);
connect(socket_proxy, SIGNAL(readyRead()),this, SLOT(readyReadProxySsl()), Qt::DirectConnection);
connect(socket_proxy, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)), Qt::DirectConnection);
connect( socket_proxy, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslError(const QList<QSslError> &)), Qt::DirectConnection );
connect(socket_proxy, SIGNAL(encrypted()), this, SLOT(ready()), Qt::DirectConnection );
connect(socket_proxy, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(SslModeChanged(QSslSocket::SslMode)), Qt::DirectConnection );
connect(socket_proxy, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(SslStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection );
socket_proxy->abort();
//Connect to host
socket_proxy->connectToHostEncrypted(QString(Hostname), Port.toInt());
if (!socket_proxy->waitForEncrypted(10000)) {
emit appendSignalText(tr("Encrypted data error: %1").arg(socket_proxy->errorString()), Qt::red);
return;
}
} |
Partager