diff options
author | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-10-13 13:01:40 +0200 |
---|---|---|
committer | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-10-13 16:57:49 +0200 |
commit | 5afb5326cb0392ad9537e1086b4699f6f6f09bf6 (patch) | |
tree | bcc081f8cc4f3b9ce5158a54c8191e6367e3f1da | |
parent | 363914a13099b410efece8cfd9556f770ed97906 (diff) | |
download | qtwebsockets-5afb5326cb0392ad9537e1086b4699f6f6f09bf6.tar.gz |
Renamed getter methods to be Qt compliant
Renamed all getXXX() methods in QWebSocketFrame to XXX() methods to be Qt compliant.
Change-Id: Iea47bcf1772a755f303065ff12d07b0ba99d4aac
Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com>
-rw-r--r-- | src/websockets/qwebsocketdataprocessor_p.cpp | 22 | ||||
-rw-r--r-- | src/websockets/qwebsocketframe_p.cpp | 16 | ||||
-rw-r--r-- | src/websockets/qwebsocketframe_p.h | 25 | ||||
-rw-r--r-- | tests/auto/websocketframe/tst_websocketframe.cpp | 2 |
4 files changed, 35 insertions, 30 deletions
diff --git a/src/websockets/qwebsocketdataprocessor_p.cpp b/src/websockets/qwebsocketdataprocessor_p.cpp index e6b6852..b77615a 100644 --- a/src/websockets/qwebsocketdataprocessor_p.cpp +++ b/src/websockets/qwebsocketdataprocessor_p.cpp @@ -123,11 +123,11 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice) } if (!frame.isContinuationFrame()) { - m_opCode = frame.getOpCode(); + m_opCode = frame.opCode(); m_isFragmented = !frame.isFinalFrame(); } quint64 messageLength = (quint64)(m_opCode == QWebSocketProtocol::OC_TEXT) ? m_textMessage.length() : m_binaryMessage.length(); - if ((messageLength + quint64(frame.getPayload().length())) > MAX_MESSAGE_SIZE_IN_BYTES) + if ((messageLength + quint64(frame.payload().length())) > MAX_MESSAGE_SIZE_IN_BYTES) { clear(); Q_EMIT errorEncountered(QWebSocketProtocol::CC_TOO_MUCH_DATA, tr("Received message is too big.")); @@ -136,7 +136,7 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice) if (m_opCode == QWebSocketProtocol::OC_TEXT) { - QString frameTxt = m_pTextCodec->toUnicode(frame.getPayload().constData(), frame.getPayload().size(), m_pConverterState); + QString frameTxt = m_pTextCodec->toUnicode(frame.payload().constData(), frame.payload().size(), m_pConverterState); bool failed = (m_pConverterState->invalidChars != 0) || (frame.isFinalFrame() && (m_pConverterState->remainingChars != 0)); if (failed) { @@ -152,8 +152,8 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice) } else { - m_binaryMessage.append(frame.getPayload()); - Q_EMIT binaryFrameReceived(frame.getPayload(), frame.isFinalFrame()); + m_binaryMessage.append(frame.payload()); + Q_EMIT binaryFrameReceived(frame.payload(), frame.isFinalFrame()); } if (frame.isFinalFrame()) @@ -173,7 +173,7 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice) } else { - Q_EMIT errorEncountered(frame.getCloseCode(), frame.getCloseReason()); + Q_EMIT errorEncountered(frame.closeCode(), frame.closeReason()); clear(); isDone = true; } @@ -214,23 +214,23 @@ void QWebSocketDataProcessor::clear() bool QWebSocketDataProcessor::processControlFrame(const QWebSocketFrame &frame) { bool mustStopProcessing = true; //control frames never expect additional frames to be processed - switch (frame.getOpCode()) + switch (frame.opCode()) { case QWebSocketProtocol::OC_PING: { - Q_EMIT pingReceived(frame.getPayload()); + Q_EMIT pingReceived(frame.payload()); break; } case QWebSocketProtocol::OC_PONG: { - Q_EMIT pongReceived(frame.getPayload()); + Q_EMIT pongReceived(frame.payload()); break; } case QWebSocketProtocol::OC_CLOSE: { quint16 closeCode = QWebSocketProtocol::CC_NORMAL; QString closeReason; - QByteArray payload = frame.getPayload(); + QByteArray payload = frame.payload(); if (payload.size() == 1) //size is either 0 (no close code and no reason) or >= 2 (at least a close code of 2 bytes) { closeCode = QWebSocketProtocol::CC_PROTOCOL_ERROR; @@ -283,7 +283,7 @@ bool QWebSocketDataProcessor::processControlFrame(const QWebSocketFrame &frame) } default: { - qDebug() << "DataProcessor::processControlFrame: Invalid opcode detected:" << static_cast<int>(frame.getOpCode()); + qDebug() << "DataProcessor::processControlFrame: Invalid opcode detected:" << static_cast<int>(frame.opCode()); //Do nothing break; } diff --git a/src/websockets/qwebsocketframe_p.cpp b/src/websockets/qwebsocketframe_p.cpp index 3c8a3a9..577a894 100644 --- a/src/websockets/qwebsocketframe_p.cpp +++ b/src/websockets/qwebsocketframe_p.cpp @@ -94,7 +94,7 @@ const QWebSocketFrame &QWebSocketFrame::operator =(const QWebSocketFrame &other) /*! \internal */ -QWebSocketProtocol::CloseCode QWebSocketFrame::getCloseCode() const +QWebSocketProtocol::CloseCode QWebSocketFrame::closeCode() const { return m_closeCode; } @@ -102,7 +102,7 @@ QWebSocketProtocol::CloseCode QWebSocketFrame::getCloseCode() const /*! \internal */ -QString QWebSocketFrame::getCloseReason() const +QString QWebSocketFrame::closeReason() const { return m_closeReason; } @@ -150,7 +150,7 @@ bool QWebSocketFrame::hasMask() const /*! \internal */ -quint32 QWebSocketFrame::getMask() const +quint32 QWebSocketFrame::mask() const { return m_mask; } @@ -158,7 +158,7 @@ quint32 QWebSocketFrame::getMask() const /*! \internal */ -int QWebSocketFrame::getRsv1() const +int QWebSocketFrame::rsv1() const { return m_rsv1; } @@ -166,7 +166,7 @@ int QWebSocketFrame::getRsv1() const /*! \internal */ -int QWebSocketFrame::getRsv2() const +int QWebSocketFrame::rsv2() const { return m_rsv2; } @@ -174,7 +174,7 @@ int QWebSocketFrame::getRsv2() const /*! \internal */ -int QWebSocketFrame::getRsv3() const +int QWebSocketFrame::rsv3() const { return m_rsv3; } @@ -182,7 +182,7 @@ int QWebSocketFrame::getRsv3() const /*! \internal */ -QWebSocketProtocol::OpCode QWebSocketFrame::getOpCode() const +QWebSocketProtocol::OpCode QWebSocketFrame::opCode() const { return m_opCode; } @@ -190,7 +190,7 @@ QWebSocketProtocol::OpCode QWebSocketFrame::getOpCode() const /*! \internal */ -QByteArray QWebSocketFrame::getPayload() const +QByteArray QWebSocketFrame::payload() const { return m_payload; } diff --git a/src/websockets/qwebsocketframe_p.h b/src/websockets/qwebsocketframe_p.h index 5dc0957..e1c9e3e 100644 --- a/src/websockets/qwebsocketframe_p.h +++ b/src/websockets/qwebsocketframe_p.h @@ -20,12 +20,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #ifndef QWEBSOCKETFRAME_P_H #define QWEBSOCKETFRAME_P_H -#include "qwebsocketprotocol.h" +#include <QString> +#include <QByteArray> +#include <limits.h> -#include <QIODevice> +#include "qwebsocketprotocol.h" +#include "qwebsockets_global.h" QT_BEGIN_NAMESPACE +class QIODevice; + const quint64 MAX_FRAME_SIZE_IN_BYTES = INT_MAX - 1; const quint64 MAX_MESSAGE_SIZE_IN_BYTES = INT_MAX - 1; @@ -37,19 +42,19 @@ public: const QWebSocketFrame &operator =(const QWebSocketFrame &other); - QWebSocketProtocol::CloseCode getCloseCode() const; - QString getCloseReason() const; + QWebSocketProtocol::CloseCode closeCode() const; + QString closeReason() const; bool isFinalFrame() const; bool isControlFrame() const; bool isDataFrame() const; bool isContinuationFrame() const; bool hasMask() const; - quint32 getMask() const; //returns 0 if no mask - int getRsv1() const; - int getRsv2() const; - int getRsv3() const; - QWebSocketProtocol::OpCode getOpCode() const; - QByteArray getPayload() const; + quint32 mask() const; //returns 0 if no mask + int rsv1() const; + int rsv2() const; + int rsv3() const; + QWebSocketProtocol::OpCode opCode() const; + QByteArray payload() const; void clear(); //resets all member variables, and invalidates the object diff --git a/tests/auto/websocketframe/tst_websocketframe.cpp b/tests/auto/websocketframe/tst_websocketframe.cpp index e08307b..bd38c65 100644 --- a/tests/auto/websocketframe/tst_websocketframe.cpp +++ b/tests/auto/websocketframe/tst_websocketframe.cpp @@ -84,7 +84,7 @@ void tst_WebSocketFrame::tst_initialization() { QWebSocketFrame frame; QVERIFY(!frame.isValid()); - QCOMPARE(frame.getPayload().length(), 0); + QCOMPARE(frame.payload().length(), 0); } QTEST_MAIN(tst_WebSocketFrame) |