Fix SCTP API according to Qt conventions

inDatagramMode() -> isInDatagramMode()
maxChannelCount -> maximumChannelCount

Change-Id: Ib64bf52cc3b40354927ee11e3f41d47e84c6d9c4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Friedemann Kleint 2016-11-21 10:57:25 +01:00
parent d207738245
commit 7920cfe46a
8 changed files with 52 additions and 52 deletions

View File

@ -66,7 +66,7 @@ Server::Server(QWidget *parent)
setWindowTitle(tr("Multi-stream Server"));
sctpServer = new QSctpServer(this);
sctpServer->setMaxChannelCount(NumberOfChannels);
sctpServer->setMaximumChannelCount(NumberOfChannels);
statusLabel = new QLabel;
QPushButton *quitButton = new QPushButton(tr("Quit"));

View File

@ -60,7 +60,7 @@
The most common way to use QSctpServer is to construct an object
and set the maximum number of channels that the server is
prepared to support, by calling setMaxChannelCount(). You can set
prepared to support, by calling setMaximumChannelCount(). You can set
the TCP emulation mode by passing a negative argument in this
call. Also, a special value of 0 (the default) indicates to use
the peer's value as the actual number of channels. The new incoming
@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
/*! \internal
*/
QSctpServerPrivate::QSctpServerPrivate()
: maxChannelCount(0)
: maximumChannelCount(0)
{
}
@ -119,7 +119,7 @@ void QSctpServerPrivate::configureCreatedSocket()
QTcpServerPrivate::configureCreatedSocket();
if (socketEngine)
socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption,
maxChannelCount == -1 ? 1 : maxChannelCount);
maximumChannelCount == -1 ? 1 : maximumChannelCount);
}
/*!
@ -128,7 +128,7 @@ void QSctpServerPrivate::configureCreatedSocket()
Sets the datagram operation mode. The \a parent argument is passed
to QObject's constructor.
\sa setMaxChannelCount(), listen(), setSocketDescriptor()
\sa setMaximumChannelCount(), listen(), setSocketDescriptor()
*/
QSctpServer::QSctpServer(QObject *parent)
: QTcpServer(QAbstractSocket::SctpSocket, *new QSctpServerPrivate, parent)
@ -159,19 +159,19 @@ QSctpServer::~QSctpServer()
Call this method only when QSctpServer is in UnconnectedState.
\sa maxChannelCount(), QSctpSocket
\sa maximumChannelCount(), QSctpSocket
*/
void QSctpServer::setMaxChannelCount(int count)
void QSctpServer::setMaximumChannelCount(int count)
{
Q_D(QSctpServer);
if (d->state != QAbstractSocket::UnconnectedState) {
qWarning("QSctpServer::setMaxChannelCount() is only allowed in UnconnectedState");
qWarning("QSctpServer::setMaximumChannelCount() is only allowed in UnconnectedState");
return;
}
#if defined(QSCTPSERVER_DEBUG)
qDebug("QSctpServer::setMaxChannelCount(%i)", count);
qDebug("QSctpServer::setMaximumChannelCount(%i)", count);
#endif
d->maxChannelCount = count;
d->maximumChannelCount = count;
}
/*!
@ -183,11 +183,11 @@ void QSctpServer::setMaxChannelCount(int count)
Returns -1, if QSctpServer running in TCP emulation mode.
\sa setMaxChannelCount()
\sa setMaximumChannelCount()
*/
int QSctpServer::maxChannelCount() const
int QSctpServer::maximumChannelCount() const
{
return d_func()->maxChannelCount;
return d_func()->maximumChannelCount;
}
/*! \reimp
@ -199,7 +199,7 @@ void QSctpServer::incomingConnection(qintptr socketDescriptor)
#endif
QSctpSocket *socket = new QSctpSocket(this);
socket->setMaxChannelCount(d_func()->maxChannelCount);
socket->setMaximumChannelCount(d_func()->maximumChannelCount);
socket->setSocketDescriptor(socketDescriptor);
addPendingConnection(socket);
}
@ -234,7 +234,7 @@ QSctpSocket *QSctpServer::nextPendingDatagramConnection()
QSctpSocket *socket = qobject_cast<QSctpSocket *>(i.next());
Q_ASSERT(socket);
if (socket->inDatagramMode()) {
if (socket->isInDatagramMode()) {
i.remove();
Q_ASSERT(d->socketEngine);
d->socketEngine->setReadNotificationEnabled(true);

View File

@ -57,8 +57,8 @@ public:
explicit QSctpServer(QObject *parent = nullptr);
virtual ~QSctpServer();
void setMaxChannelCount(int count);
int maxChannelCount() const;
void setMaximumChannelCount(int count);
int maximumChannelCount() const;
QSctpSocket *nextPendingDatagramConnection();

View File

@ -64,7 +64,7 @@ public:
QSctpServerPrivate();
virtual ~QSctpServerPrivate();
int maxChannelCount;
int maximumChannelCount;
void configureCreatedSocket() Q_DECL_OVERRIDE;
};

View File

@ -83,14 +83,14 @@
\endlist
To set a continuous byte stream mode, instantiate QSctpSocket and
call setMaxChannelCount() with a negative value. This gives the
call setMaximumChannelCount() with a negative value. This gives the
ability to use QSctpSocket as a regular buffered QTcpSocket. You
can call connectToHost() to initiate connection with endpoint,
write() to transmit and read() to receive data from the peer, but
you cannot distinguish message boundaries.
By default, QSctpSocket operates in datagram mode. Before
connecting, call setMaxChannelCount() to set the maximum number of
connecting, call setMaximumChannelCount() to set the maximum number of
channels that the application is prepared to support. This number
is a parameter negotiated with the remote endpoint and its value
can be bounded by the operating system. The default value of 0
@ -130,7 +130,7 @@ QT_BEGIN_NAMESPACE
/*! \internal
*/
QSctpSocketPrivate::QSctpSocketPrivate()
: maxChannelCount(0)
: maximumChannelCount(0)
{
}
@ -150,7 +150,7 @@ bool QSctpSocketPrivate::canReadNotification()
#endif
// Handle TCP emulation mode in the base implementation.
if (!q->inDatagramMode())
if (!q->isInDatagramMode())
return QTcpSocketPrivate::canReadNotification();
const int savedCurrentChannel = currentReadChannel;
@ -248,7 +248,7 @@ bool QSctpSocketPrivate::writeToSocket()
#endif
// Handle TCP emulation mode in the base implementation.
if (!q->inDatagramMode())
if (!q->isInDatagramMode())
return QTcpSocketPrivate::writeToSocket();
if (!socketEngine)
@ -331,7 +331,7 @@ void QSctpSocketPrivate::configureCreatedSocket()
{
if (socketEngine)
socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption,
maxChannelCount < 0 ? 1 : maxChannelCount);
maximumChannelCount < 0 ? 1 : maximumChannelCount);
}
/*!
@ -340,7 +340,7 @@ void QSctpSocketPrivate::configureCreatedSocket()
Sets the datagram operation mode. The \a parent argument is passed
to QObject's constructor.
\sa socketType(), setMaxChannelCount()
\sa socketType(), setMaximumChannelCount()
*/
QSctpSocket::QSctpSocket(QObject *parent)
: QTcpSocket(SctpSocket, *new QSctpSocketPrivate, parent)
@ -418,19 +418,19 @@ void QSctpSocket::disconnectFromHost()
Call this method only when QSctpSocket is in UnconnectedState.
\sa maxChannelCount(), readChannelCount(), writeChannelCount()
\sa maximumChannelCount(), readChannelCount(), writeChannelCount()
*/
void QSctpSocket::setMaxChannelCount(int count)
void QSctpSocket::setMaximumChannelCount(int count)
{
Q_D(QSctpSocket);
if (d->state != QAbstractSocket::UnconnectedState) {
qWarning("QSctpSocket::setMaxChannelCount() is only allowed in UnconnectedState");
qWarning("QSctpSocket::setMaximumChannelCount() is only allowed in UnconnectedState");
return;
}
#if defined(QSCTPSOCKET_DEBUG)
qDebug("QSctpSocket::setMaxChannelCount(%i)", count);
qDebug("QSctpSocket::setMaximumChannelCount(%i)", count);
#endif
d->maxChannelCount = qMax(count, -1);
d->maximumChannelCount = qMax(count, -1);
}
/*!
@ -443,22 +443,22 @@ void QSctpSocket::setMaxChannelCount(int count)
Returns -1 if QSctpSocket is running in continuous byte stream
mode.
\sa setMaxChannelCount(), readChannelCount(), writeChannelCount()
\sa setMaximumChannelCount(), readChannelCount(), writeChannelCount()
*/
int QSctpSocket::maxChannelCount() const
int QSctpSocket::maximumChannelCount() const
{
return d_func()->maxChannelCount;
return d_func()->maximumChannelCount;
}
/*!
Returns \c true if the socket is running in datagram mode.
\sa setMaxChannelCount()
\sa setMaximumChannelCount()
*/
bool QSctpSocket::inDatagramMode() const
bool QSctpSocket::isInDatagramMode() const
{
Q_D(const QSctpSocket);
return d->maxChannelCount != -1 && d->isBuffered;
return d->maximumChannelCount != -1 && d->isBuffered;
}
/*!
@ -471,13 +471,13 @@ bool QSctpSocket::inDatagramMode() const
On failure, returns a QNetworkDatagram that reports \l
{QNetworkDatagram::isValid()}{not valid}.
\sa writeDatagram(), inDatagramMode(), currentReadChannel()
\sa writeDatagram(), isInDatagramMode(), currentReadChannel()
*/
QNetworkDatagram QSctpSocket::readDatagram()
{
Q_D(QSctpSocket);
if (!isReadable() || !inDatagramMode()) {
if (!isReadable() || !isInDatagramMode()) {
qWarning("QSctpSocket::readDatagram(): operation is not permitted");
return QNetworkDatagram();
}
@ -507,14 +507,14 @@ QNetworkDatagram QSctpSocket::readDatagram()
Writes a \a datagram to the buffer of the current write channel.
Returns true on success; otherwise returns false.
\sa readDatagram(), inDatagramMode(), currentWriteChannel()
\sa readDatagram(), isInDatagramMode(), currentWriteChannel()
*/
bool QSctpSocket::writeDatagram(const QNetworkDatagram &datagram)
{
Q_D(QSctpSocket);
if (!isWritable() || d->state != QAbstractSocket::ConnectedState || !d->socketEngine
|| !d->socketEngine->isValid() || !inDatagramMode()) {
|| !d->socketEngine->isValid() || !isInDatagramMode()) {
qWarning("QSctpSocket::writeDatagram(): operation is not permitted");
return false;
}

View File

@ -59,9 +59,9 @@ public:
void close() Q_DECL_OVERRIDE;
void disconnectFromHost() Q_DECL_OVERRIDE;
void setMaxChannelCount(int count);
int maxChannelCount() const;
bool inDatagramMode() const;
void setMaximumChannelCount(int count);
int maximumChannelCount() const;
bool isInDatagramMode() const;
QNetworkDatagram readDatagram();
bool writeDatagram(const QNetworkDatagram &datagram);

View File

@ -74,7 +74,7 @@ public:
bool writeToSocket() Q_DECL_OVERRIDE;
QByteArray incomingDatagram;
int maxChannelCount;
int maximumChannelCount;
typedef std::deque<QIpPacketHeader> IpHeaderList;
QVector<IpHeaderList> readHeaders;

View File

@ -112,7 +112,7 @@ void tst_QSctpSocket::constructing()
QVERIFY(!socket.isOpen());
QVERIFY(!socket.isValid());
QCOMPARE(socket.socketType(), QAbstractSocket::SctpSocket);
QCOMPARE(socket.maxChannelCount(), 0);
QCOMPARE(socket.maximumChannelCount(), 0);
QCOMPARE(socket.readChannelCount(), 0);
QCOMPARE(socket.writeChannelCount(), 0);
@ -202,7 +202,7 @@ void tst_QSctpSocket::setSocketDescriptor()
{
QSctpServer server;
server.setMaxChannelCount(16);
server.setMaximumChannelCount(16);
QVERIFY(server.listen());
SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
@ -218,8 +218,8 @@ void tst_QSctpSocket::setSocketDescriptor()
QVERIFY(socket.waitForConnected(3000));
QVERIFY(server.waitForNewConnection(3000));
QCOMPARE(socket.readChannelCount(), server.maxChannelCount());
QVERIFY(socket.writeChannelCount() <= server.maxChannelCount());
QCOMPARE(socket.readChannelCount(), server.maximumChannelCount());
QVERIFY(socket.writeChannelCount() <= server.maximumChannelCount());
QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection();
QVERIFY(acceptedSocket);
@ -338,11 +338,11 @@ void tst_QSctpSocket::loop()
QSctpServer server;
server.setMaxChannelCount(10);
server.setMaximumChannelCount(10);
QVERIFY(server.listen());
QSctpSocket peter;
peter.setMaxChannelCount(10);
peter.setMaximumChannelCount(10);
peter.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(peter.waitForConnected(3000));
@ -389,11 +389,11 @@ void tst_QSctpSocket::loopInTCPMode()
QSctpServer server;
server.setMaxChannelCount(-1);
server.setMaximumChannelCount(-1);
QVERIFY(server.listen());
QSctpSocket peter;
peter.setMaxChannelCount(-1);
peter.setMaximumChannelCount(-1);
peter.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(peter.waitForConnected(3000));
QVERIFY(server.waitForNewConnection(3000));