Make (dis)connectTo(From)Host virtual in QAbstractSocket.

Change-Id: Ib1dfae4031f00fb331108152a259f6a2756381c9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jonas M. Gastal 2011-12-29 12:47:21 -02:00 committed by Qt by Nokia
parent f74c49bbaf
commit 4669d657d2
5 changed files with 16 additions and 50 deletions

4
dist/changes-5.0.0 vendored
View File

@ -149,6 +149,10 @@ information about a particular change.
* On Windows, QProcess::ForwardedChannels will not forward the output of GUI
applications anymore, if they do not create a console.
- QAbstractSocket's connectToHost() and disconnectFromHost() are now virtual and
connectToHostImplementation() and disconnectFromHostImplementation() don't exist.
****************************************************************************
* General *
****************************************************************************

View File

@ -1468,27 +1468,6 @@ bool QAbstractSocket::isValid() const
void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
OpenMode openMode,
NetworkLayerProtocol protocol)
{
Q_D(QAbstractSocket);
d->preferredNetworkLayerProtocol = protocol;
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)
@ -1505,6 +1484,7 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
return;
}
d->preferredNetworkLayerProtocol = protocol;
d->hostName = hostName;
d->port = port;
d->state = UnconnectedState;
@ -2620,17 +2600,6 @@ void QAbstractSocket::close()
\sa connectToHost()
*/
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)

View File

@ -131,10 +131,9 @@ public:
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
// ### Qt 5: Make connectToHost() and disconnectFromHost() virtual.
void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
void disconnectFromHost();
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
virtual void disconnectFromHost();
bool isValid() const;
@ -196,10 +195,6 @@ Q_SIGNALS:
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);

View File

@ -1733,16 +1733,16 @@ void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
/*!
\internal
*/
void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 port,
OpenMode openMode)
void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode openMode, NetworkLayerProtocol protocol)
{
Q_D(QSslSocket);
d->preferredNetworkLayerProtocol = protocol;
if (!d->initialized)
d->init();
d->initialized = false;
#ifdef QSSLSOCKET_DEBUG
qDebug() << "QSslSocket::connectToHostImplementation("
qDebug() << "QSslSocket::connectToHost("
<< hostName << ',' << port << ',' << openMode << ')';
#endif
if (!d->plainSocket) {
@ -1762,11 +1762,11 @@ void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 po
/*!
\internal
*/
void QSslSocket::disconnectFromHostImplementation()
void QSslSocket::disconnectFromHost()
{
Q_D(QSslSocket);
#ifdef QSSLSOCKET_DEBUG
qDebug() << "QSslSocket::disconnectFromHostImplementation()";
qDebug() << "QSslSocket::disconnectFromHost()";
#endif
if (!d->plainSocket)
return;

View File

@ -90,6 +90,9 @@ public:
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
OpenMode openMode = ReadWrite);
void connectToHost(const QString &hostName, quint16 port, OpenMode openMode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
void disconnectFromHost();
// ### Qt 5: Make virtual
void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
QVariant socketOption(QAbstractSocket::SocketOption option);
@ -193,11 +196,6 @@ Q_SIGNALS:
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);