void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
OpenMode openMode)
{
- QMetaObject::invokeMethod(this, "connectToHostImplementation",
- Qt::DirectConnection,
- Q_ARG(QString, hostName),
- Q_ARG(quint16, port),
- Q_ARG(OpenMode, openMode));
-}
-
-/*!
- \since 4.1
-
- Contains the implementation of connectToHost().
-
- Attempts to make a connection to \a hostName on the given \a
- port. The socket is opened in the given \a openMode.
-*/
-void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint16 port,
- OpenMode openMode)
-{
Q_D(QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::connectToHost(\"%s\", %i, %i)...", qPrintable(hostName), port,
OpenMode openMode)
{
Q_D(QAbstractSocket);
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->setSocketDescriptor(socketDescriptor, socketState, openMode);
-
d->resetSocketLayer();
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
if (!d->socketEngine) {
*/
void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
{
- if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
- sslSocket->setSocketOption(option, value);
- return;
- }
-
if (!d_func()->socketEngine)
return;
*/
QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
{
- if (QSslSocket *sslSocket = qobject_cast<QSslSocket*>(this)) {
- return sslSocket->socketOption(option);
- }
-
if (!d_func()->socketEngine)
return QVariant();
return true;
}
- // Manual polymorphism; this function is not virtual, but has an overload
- // in QSslSocket.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->waitForConnected(msecs);
-
bool wasPendingClose = d->pendingClose;
d->pendingClose = false;
QElapsedTimer stopWatch;
bool QAbstractSocket::waitForDisconnected(int msecs)
{
Q_D(QAbstractSocket);
- // Manual polymorphism; this function is not virtual, but has an overload
- // in QSslSocket.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->waitForDisconnected(msecs);
-
// require calling connectToHost() before waitForDisconnected()
if (state() == UnconnectedState) {
qWarning("QAbstractSocket::waitForDisconnected() is not allowed in UnconnectedState");
#endif
if (d->state == UnconnectedState)
return;
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
- socket->abort();
- return;
- }
if (d->connectTimer) {
d->connectTimer->stop();
delete d->connectTimer;
bool QAbstractSocket::flush()
{
Q_D(QAbstractSocket);
- // Manual polymorphism; flush() isn't virtual, but QSslSocket overloads
- // it.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->flush();
Q_CHECK_SOCKETENGINE(false);
return d->flush();
}
*/
void QAbstractSocket::disconnectFromHost()
{
- QMetaObject::invokeMethod(this, "disconnectFromHostImplementation",
- Qt::DirectConnection);
-}
-
-/*!
- \since 4.1
-
- Contains the implementation of disconnectFromHost().
-*/
-void QAbstractSocket::disconnectFromHostImplementation()
-{
Q_D(QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::disconnectFromHost()");
void QAbstractSocket::setReadBufferSize(qint64 size)
{
Q_D(QAbstractSocket);
-
- // Manual polymorphism; setReadBufferSize() isn't virtual, but QSslSocket overloads
- // it.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
- socket->setReadBufferSize(size);
- return;
- }
-
if (d->readBufferMaxSize == size)
return;
d->readBufferMaxSize = size;
QAbstractSocket(SocketType socketType, QObject *parent);
virtual ~QAbstractSocket();
- // ### Qt 5: Make connectToHost() and disconnectFromHost() virtual.
- void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
- void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
- void disconnectFromHost();
+ virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
+ virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
+ virtual void disconnectFromHost();
bool isValid() const;
QHostAddress peerAddress() const;
QString peerName() const;
- // ### Qt 5: Make setReadBufferSize() virtual
qint64 readBufferSize() const;
- void setReadBufferSize(qint64 size);
+ virtual void setReadBufferSize(qint64 size);
- void abort();
+ virtual void abort();
- // ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
int socketDescriptor() const;
- bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
- OpenMode openMode = ReadWrite);
+ virtual bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
+ OpenMode openMode = ReadWrite);
- // ### Qt 5: Make virtual?
- void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
- QVariant socketOption(QAbstractSocket::SocketOption option);
+ virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
+ virtual QVariant socketOption(QAbstractSocket::SocketOption option);
SocketType socketType() const;
SocketState state() const;
void close();
bool isSequential() const;
bool atEnd() const;
- bool flush();
+
+ virtual bool flush();
// for synchronous access
- // ### Qt 5: Make waitForConnected() and waitForDisconnected() virtual.
- bool waitForConnected(int msecs = 30000);
+ virtual bool waitForConnected(int msecs = 30000);
bool waitForReadyRead(int msecs = 30000);
bool waitForBytesWritten(int msecs = 30000);
- bool waitForDisconnected(int msecs = 30000);
+ virtual bool waitForDisconnected(int msecs = 30000);
#ifndef QT_NO_NETWORKPROXY
void setProxy(const QNetworkProxy &networkProxy);
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
#endif
-protected Q_SLOTS:
- void connectToHostImplementation(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
- void disconnectFromHostImplementation();
-
protected:
qint64 readData(char *data, qint64 maxlen);
qint64 readLineData(char *data, qint64 maxlen);
/*!
\internal
*/
-void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 port,
- OpenMode openMode)
+void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode openMode)
{
Q_D(QSslSocket);
if (!d->initialized)
d->initialized = false;
#ifdef QSSLSOCKET_DEBUG
- qDebug() << "QSslSocket::connectToHostImplementation("
+ qDebug() << "QSslSocket::connectToHost("
<< hostName << ',' << port << ',' << openMode << ')';
#endif
if (!d->plainSocket) {
/*!
\internal
*/
-void QSslSocket::disconnectFromHostImplementation()
+void QSslSocket::disconnectFromHost()
{
Q_D(QSslSocket);
#ifdef QSSLSOCKET_DEBUG
- qDebug() << "QSslSocket::disconnectFromHostImplementation()";
+ qDebug() << "QSslSocket::disconnectFromHost()";
#endif
if (!d->plainSocket)
return;
QSslSocket(QObject *parent = Q_NULLPTR);
~QSslSocket();
+ virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
+ virtual void disconnectFromHost();
+
// Autostarting the SSL client handshake.
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite);
void modeChanged(QSslSocket::SslMode newMode);
void encryptedBytesWritten(qint64 totalBytes);
-protected Q_SLOTS:
- void connectToHostImplementation(const QString &hostName, quint16 port,
- OpenMode openMode);
- void disconnectFromHostImplementation();
-
protected:
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);