summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Ceuppens <steven.ceuppens@icloud.com>2013-09-29 19:21:55 +0200
committerSteven Ceuppens <steven.ceuppens@icloud.com>2013-09-29 19:35:14 +0200
commitf0201e3f6c01c409bb562f1b02f841a2385f8fe6 (patch)
tree35ad5d99b19fcd3e71f566974812de7042168946
parent0abe9a2cd72b26c59edc4f42994725d0dfed1827 (diff)
downloadqtwebsockets-f0201e3f6c01c409bb562f1b02f841a2385f8fe6.tar.gz
update class & filenames
Change-Id: Idd2caa074f2f3feba99714bf6927ca879809ad47 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
-rw-r--r--src/websockets/qwebsocket.h4
-rw-r--r--src/websockets/qwebsocket_p.cpp8
-rw-r--r--src/websockets/qwebsocket_p.h17
-rw-r--r--src/websockets/qwebsocketcorsauthenticator.cpp (renamed from src/websockets/qcorsauthenticator.cpp)34
-rw-r--r--src/websockets/qwebsocketcorsauthenticator.h (renamed from src/websockets/qcorsauthenticator.h)24
-rw-r--r--src/websockets/qwebsocketcorsauthenticator_p.h (renamed from src/websockets/qcorsauthenticator_p.h)12
-rw-r--r--src/websockets/qwebsocketdataprocessor_p.cpp (renamed from src/websockets/dataprocessor_p.cpp)72
-rw-r--r--src/websockets/qwebsocketdataprocessor_p.h (renamed from src/websockets/dataprocessor_p.h)19
-rw-r--r--src/websockets/qwebsockethandshakerequest_p.cpp (renamed from src/websockets/handshakerequest_p.cpp)36
-rw-r--r--src/websockets/qwebsockethandshakerequest_p.h (renamed from src/websockets/handshakerequest_p.h)19
-rw-r--r--src/websockets/qwebsockethandshakeresponse_p.cpp (renamed from src/websockets/handshakeresponse_p.cpp)26
-rw-r--r--src/websockets/qwebsockethandshakeresponse_p.h (renamed from src/websockets/handshakeresponse_p.h)21
-rw-r--r--src/websockets/qwebsocketserver.h8
-rw-r--r--src/websockets/qwebsocketserver_p.cpp12
-rw-r--r--src/websockets/qwebsocketserver_p.h3
-rw-r--r--src/websockets/websockets.pro24
16 files changed, 168 insertions, 171 deletions
diff --git a/src/websockets/qwebsocket.h b/src/websockets/qwebsocket.h
index cffc87d..320abb7 100644
--- a/src/websockets/qwebsocket.h
+++ b/src/websockets/qwebsocket.h
@@ -38,6 +38,8 @@ class QWebSocketPrivate;
class Q_WEBSOCKETS_EXPORT QWebSocket:public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocket)
+ Q_DECLARE_PRIVATE(QWebSocket)
public:
explicit QWebSocket(const QString &origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::V_LATEST, QObject *parent = 0);
@@ -105,8 +107,6 @@ Q_SIGNALS:
void pong(quint64 elapsedTime, QByteArray payload);
private:
- Q_DISABLE_COPY(QWebSocket)
- Q_DECLARE_PRIVATE(QWebSocket)
QWebSocket(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QObject *parent = 0);
QWebSocketPrivate * const d_ptr;
};
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 1b37481..bbf4748 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "qwebsocket.h"
#include "qwebsocket_p.h"
-#include "handshakerequest_p.h"
-#include "handshakeresponse_p.h"
+#include "qwebsockethandshakerequest_p.h"
+#include "qwebsockethandshakeresponse_p.h"
#include <QUrl>
#include <QTcpSocket>
#include <QByteArray>
@@ -184,8 +184,8 @@ qint64 QWebSocketPrivate::write(const QByteArray &data)
\internal
*/
QWebSocket *QWebSocketPrivate::upgradeFrom(QTcpSocket *pTcpSocket,
- const HandshakeRequest &request,
- const HandshakeResponse &response,
+ const QWebSocketHandshakeRequest &request,
+ const QWebSocketHandshakeResponse &response,
QObject *parent)
{
QWebSocket *pWebSocket = new QWebSocket(pTcpSocket, response.getAcceptedVersion(), parent);
diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h
index e4cd657..605642b 100644
--- a/src/websockets/qwebsocket_p.h
+++ b/src/websockets/qwebsocket_p.h
@@ -39,18 +39,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <QTime>
#include "qwebsocketsglobal.h"
#include "qwebsocketprotocol.h"
-#include "dataprocessor_p.h"
+#include "qwebsocketdataprocessor_p.h"
QT_BEGIN_NAMESPACE
-class HandshakeRequest;
-class HandshakeResponse;
+class QWebSocketHandshakeRequest;
+class QWebSocketHandshakeResponse;
class QTcpSocket;
class QWebSocket;
class QWebSocketPrivate:public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocketPrivate)
+ Q_DECLARE_PUBLIC(QWebSocket)
public:
explicit QWebSocketPrivate(const QString &origin,
@@ -111,9 +113,6 @@ private Q_SLOTS:
void processStateChanged(QAbstractSocket::SocketState socketState);
private:
- Q_DISABLE_COPY(QWebSocketPrivate)
- Q_DECLARE_PUBLIC(QWebSocket)
-
QWebSocket * const q_ptr;
QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QWebSocket *pWebSocket, QObject *parent = 0);
@@ -143,8 +142,8 @@ private:
QByteArray key);
static QWebSocket *upgradeFrom(QTcpSocket *tcpSocket,
- const HandshakeRequest &request,
- const HandshakeResponse &response,
+ const QWebSocketHandshakeRequest &request,
+ const QWebSocketHandshakeResponse &response,
QObject *parent = 0);
quint32 generateMaskingKey() const;
@@ -173,7 +172,7 @@ private:
QTime m_pingTimer;
- DataProcessor m_dataProcessor;
+ QWebSocketDataProcessor m_dataProcessor;
friend class QWebSocketServerPrivate;
};
diff --git a/src/websockets/qcorsauthenticator.cpp b/src/websockets/qwebsocketcorsauthenticator.cpp
index 5c7e581..b6e7266 100644
--- a/src/websockets/qcorsauthenticator.cpp
+++ b/src/websockets/qwebsocketcorsauthenticator.cpp
@@ -38,15 +38,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\sa QWebSocketServer
*/
-#include "qcorsauthenticator.h"
-#include "qcorsauthenticator_p.h"
+#include "qwebsocketcorsauthenticator.h"
+#include "qwebsocketcorsauthenticator_p.h"
QT_BEGIN_NAMESPACE
/*!
\internal
*/
-QCorsAuthenticatorPrivate::QCorsAuthenticatorPrivate(const QString &origin, bool allowed) :
+QWebSocketCorsAuthenticatorPrivate::QWebSocketCorsAuthenticatorPrivate(const QString &origin, bool allowed) :
m_origin(origin),
m_isAllowed(allowed)
{}
@@ -54,22 +54,22 @@ QCorsAuthenticatorPrivate::QCorsAuthenticatorPrivate(const QString &origin, bool
/*!
\internal
*/
-QCorsAuthenticatorPrivate::~QCorsAuthenticatorPrivate()
+QWebSocketCorsAuthenticatorPrivate::~QWebSocketCorsAuthenticatorPrivate()
{}
/*!
Constructs a new QCorsAuthencator object with the given \a origin.
\note By default, allowed() returns true. This means that per default every origin is accepted.
*/
-QCorsAuthenticator::QCorsAuthenticator(const QString &origin) :
- d_ptr(new QCorsAuthenticatorPrivate(origin, true)) //all origins are per default allowed
+QWebSocketCorsAuthenticator::QWebSocketCorsAuthenticator(const QString &origin) :
+ d_ptr(new QWebSocketCorsAuthenticatorPrivate(origin, true)) //all origins are per default allowed
{
}
/*!
Destructs the object
*/
-QCorsAuthenticator::~QCorsAuthenticator()
+QWebSocketCorsAuthenticator::~QWebSocketCorsAuthenticator()
{
if (d_ptr)
{
@@ -80,17 +80,17 @@ QCorsAuthenticator::~QCorsAuthenticator()
/*!
Constructs a coy of \a other
*/
-QCorsAuthenticator::QCorsAuthenticator(const QCorsAuthenticator &other) :
- d_ptr(new QCorsAuthenticatorPrivate(other.d_ptr->m_origin, other.d_ptr->m_isAllowed))
+QWebSocketCorsAuthenticator::QWebSocketCorsAuthenticator(const QWebSocketCorsAuthenticator &other) :
+ d_ptr(new QWebSocketCorsAuthenticatorPrivate(other.d_ptr->m_origin, other.d_ptr->m_isAllowed))
{
}
/*!
Assigns \a other to this authenticator object
*/
-QCorsAuthenticator &QCorsAuthenticator::operator =(const QCorsAuthenticator &other)
+QWebSocketCorsAuthenticator &QWebSocketCorsAuthenticator::operator =(const QWebSocketCorsAuthenticator &other)
{
- Q_D(QCorsAuthenticator);
+ Q_D(QWebSocketCorsAuthenticator);
if (this != &other)
{
d->m_origin = other.d_ptr->m_origin;
@@ -102,9 +102,9 @@ QCorsAuthenticator &QCorsAuthenticator::operator =(const QCorsAuthenticator &oth
/*!
Returns the origin this autenticator is handling about.
*/
-QString QCorsAuthenticator::origin() const
+QString QWebSocketCorsAuthenticator::origin() const
{
- Q_D(const QCorsAuthenticator);
+ Q_D(const QWebSocketCorsAuthenticator);
return d->m_origin;
}
@@ -114,9 +114,9 @@ QString QCorsAuthenticator::origin() const
\note By default, all origins are accepted.
*/
-void QCorsAuthenticator::setAllowed(bool allowed)
+void QWebSocketCorsAuthenticator::setAllowed(bool allowed)
{
- Q_D(QCorsAuthenticator);
+ Q_D(QWebSocketCorsAuthenticator);
d->m_isAllowed = allowed;
}
@@ -125,8 +125,8 @@ void QCorsAuthenticator::setAllowed(bool allowed)
\note By default, all origins are accepted.
*/
-bool QCorsAuthenticator::allowed() const
+bool QWebSocketCorsAuthenticator::allowed() const
{
- Q_D(const QCorsAuthenticator);
+ Q_D(const QWebSocketCorsAuthenticator);
return d->m_isAllowed;
}
diff --git a/src/websockets/qcorsauthenticator.h b/src/websockets/qwebsocketcorsauthenticator.h
index acf997a..7f3bbd1 100644
--- a/src/websockets/qcorsauthenticator.h
+++ b/src/websockets/qwebsocketcorsauthenticator.h
@@ -16,23 +16,25 @@ You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef QCORSAUTHENTICATOR_H
-#define QCORSAUTHENTICATOR_H
+#ifndef QWEBSOCKETCORSAUTHENTICATOR_H
+#define QWEBSOCKETCORSAUTHENTICATOR_H
#include "qwebsocketsglobal.h"
QT_BEGIN_NAMESPACE
-class QCorsAuthenticatorPrivate;
+class QWebSocketCorsAuthenticatorPrivate;
-class Q_WEBSOCKETS_EXPORT QCorsAuthenticator
+class Q_WEBSOCKETS_EXPORT QWebSocketCorsAuthenticator
{
+ Q_DECLARE_PRIVATE(QWebSocketCorsAuthenticator)
+
public:
- QCorsAuthenticator(const QString &origin);
- ~QCorsAuthenticator();
- QCorsAuthenticator(const QCorsAuthenticator &other);
+ QWebSocketCorsAuthenticator(const QString &origin);
+ ~QWebSocketCorsAuthenticator();
+ QWebSocketCorsAuthenticator(const QWebSocketCorsAuthenticator &other);
- QCorsAuthenticator &operator =(const QCorsAuthenticator &other);
+ QWebSocketCorsAuthenticator &operator =(const QWebSocketCorsAuthenticator &other);
QString origin() const;
@@ -40,9 +42,7 @@ public:
bool allowed() const;
private:
- Q_DECLARE_PRIVATE(QCorsAuthenticator)
-
- QCorsAuthenticatorPrivate * const d_ptr;
+ QWebSocketCorsAuthenticatorPrivate * const d_ptr;
};
-#endif // QCORSAUTHENTICATOR_H
+#endif // QWEBSOCKETCORSAUTHENTICATOR_H
diff --git a/src/websockets/qcorsauthenticator_p.h b/src/websockets/qwebsocketcorsauthenticator_p.h
index ee218dc..62d58e6 100644
--- a/src/websockets/qcorsauthenticator_p.h
+++ b/src/websockets/qwebsocketcorsauthenticator_p.h
@@ -1,5 +1,5 @@
-#ifndef QCORSAUTHENTICATOR_P_H
-#define QCORSAUTHENTICATOR_P_H
+#ifndef QWEBSOCKETCORSAUTHENTICATOR_P_H
+#define QWEBSOCKETCORSAUTHENTICATOR_P_H
#include <qglobal.h> //for QT_BEGIN_NAMESPACE
#include <QString>
@@ -16,14 +16,14 @@
//
QT_BEGIN_NAMESPACE
-class QCorsAuthenticatorPrivate
+class QWebSocketCorsAuthenticatorPrivate
{
public:
- QCorsAuthenticatorPrivate(const QString &origin, bool allowed);
- ~QCorsAuthenticatorPrivate();
+ QWebSocketCorsAuthenticatorPrivate(const QString &origin, bool allowed);
+ ~QWebSocketCorsAuthenticatorPrivate();
QString m_origin;
bool m_isAllowed;
};
-#endif // QCORSAUTHENTICATOR_P_H
+#endif // QWEBSOCKETCORSAUTHENTICATOR_P_H
diff --git a/src/websockets/dataprocessor_p.cpp b/src/websockets/qwebsocketdataprocessor_p.cpp
index f666ab3..f5c9c61 100644
--- a/src/websockets/dataprocessor_p.cpp
+++ b/src/websockets/qwebsocketdataprocessor_p.cpp
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\internal
*/
-#include "dataprocessor_p.h"
+#include "qwebsocketdataprocessor_p.h"
#include "qwebsocketprotocol.h"
#include <QIODevice>
#include <QtEndian>
@@ -56,13 +56,13 @@ const quint64 MAX_MESSAGE_SIZE_IN_BYTES = INT_MAX - 1;
\sa DataProcessor()
\internal
*/
-class Frame
+class QWebSocketFrame
{
public:
- Frame();
- Frame(const Frame &other);
+ QWebSocketFrame();
+ QWebSocketFrame(const QWebSocketFrame &other);
- const Frame &operator =(const Frame &other);
+ const QWebSocketFrame &operator =(const QWebSocketFrame &other);
QWebSocketProtocol::CloseCode getCloseCode() const;
QString getCloseReason() const;
@@ -82,7 +82,7 @@ public:
bool isValid() const;
- static Frame readFrame(QIODevice *pIoDevice);
+ static QWebSocketFrame readFrame(QIODevice *pIoDevice);
private:
QWebSocketProtocol::CloseCode m_closeCode;
@@ -117,7 +117,7 @@ private:
/*!
\internal
*/
-Frame::Frame() :
+QWebSocketFrame::QWebSocketFrame() :
m_closeCode(QWebSocketProtocol::CC_NORMAL),
m_closeReason(),
m_isFinalFrame(true),
@@ -135,7 +135,7 @@ Frame::Frame() :
/*!
\internal
*/
-Frame::Frame(const Frame &other) :
+QWebSocketFrame::QWebSocketFrame(const QWebSocketFrame &other) :
m_closeCode(other.m_closeCode),
m_closeReason(other.m_closeReason),
m_isFinalFrame(other.m_isFinalFrame),
@@ -153,7 +153,7 @@ Frame::Frame(const Frame &other) :
/*!
\internal
*/
-const Frame &Frame::operator =(const Frame &other)
+const QWebSocketFrame &QWebSocketFrame::operator =(const QWebSocketFrame &other)
{
m_closeCode = other.m_closeCode;
m_closeReason = other.m_closeReason;
@@ -173,7 +173,7 @@ const Frame &Frame::operator =(const Frame &other)
/*!
\internal
*/
-QWebSocketProtocol::CloseCode Frame::getCloseCode() const
+QWebSocketProtocol::CloseCode QWebSocketFrame::getCloseCode() const
{
return m_closeCode;
}
@@ -181,7 +181,7 @@ QWebSocketProtocol::CloseCode Frame::getCloseCode() const
/*!
\internal
*/
-QString Frame::getCloseReason() const
+QString QWebSocketFrame::getCloseReason() const
{
return m_closeReason;
}
@@ -189,7 +189,7 @@ QString Frame::getCloseReason() const
/*!
\internal
*/
-bool Frame::isFinalFrame() const
+bool QWebSocketFrame::isFinalFrame() const
{
return m_isFinalFrame;
}
@@ -197,7 +197,7 @@ bool Frame::isFinalFrame() const
/*!
\internal
*/
-bool Frame::isControlFrame() const
+bool QWebSocketFrame::isControlFrame() const
{
return (m_opCode & 0x08) == 0x08;
}
@@ -205,7 +205,7 @@ bool Frame::isControlFrame() const
/*!
\internal
*/
-bool Frame::isDataFrame() const
+bool QWebSocketFrame::isDataFrame() const
{
return !isControlFrame();
}
@@ -213,7 +213,7 @@ bool Frame::isDataFrame() const
/*!
\internal
*/
-bool Frame::isContinuationFrame() const
+bool QWebSocketFrame::isContinuationFrame() const
{
return isDataFrame() && (m_opCode == QWebSocketProtocol::OC_CONTINUE);
}
@@ -221,7 +221,7 @@ bool Frame::isContinuationFrame() const
/*!
\internal
*/
-bool Frame::hasMask() const
+bool QWebSocketFrame::hasMask() const
{
return m_mask != 0;
}
@@ -229,7 +229,7 @@ bool Frame::hasMask() const
/*!
\internal
*/
-quint32 Frame::getMask() const
+quint32 QWebSocketFrame::getMask() const
{
return m_mask;
}
@@ -237,7 +237,7 @@ quint32 Frame::getMask() const
/*!
\internal
*/
-int Frame::getRsv1() const
+int QWebSocketFrame::getRsv1() const
{
return m_rsv1;
}
@@ -245,7 +245,7 @@ int Frame::getRsv1() const
/*!
\internal
*/
-int Frame::getRsv2() const
+int QWebSocketFrame::getRsv2() const
{
return m_rsv2;
}
@@ -253,7 +253,7 @@ int Frame::getRsv2() const
/*!
\internal
*/
-int Frame::getRsv3() const
+int QWebSocketFrame::getRsv3() const
{
return m_rsv3;
}
@@ -261,7 +261,7 @@ int Frame::getRsv3() const
/*!
\internal
*/
-QWebSocketProtocol::OpCode Frame::getOpCode() const
+QWebSocketProtocol::OpCode QWebSocketFrame::getOpCode() const
{
return m_opCode;
}
@@ -269,7 +269,7 @@ QWebSocketProtocol::OpCode Frame::getOpCode() const
/*!
\internal
*/
-QByteArray Frame::getPayload() const
+QByteArray QWebSocketFrame::getPayload() const
{
return m_payload;
}
@@ -277,7 +277,7 @@ QByteArray Frame::getPayload() const
/*!
\internal
*/
-void Frame::clear()
+void QWebSocketFrame::clear()
{
m_closeCode = QWebSocketProtocol::CC_NORMAL;
m_closeReason.clear();
@@ -295,7 +295,7 @@ void Frame::clear()
/*!
\internal
*/
-bool Frame::isValid() const
+bool QWebSocketFrame::isValid() const
{
return m_isValid;
}
@@ -305,11 +305,11 @@ bool Frame::isValid() const
/*!
\internal
*/
-Frame Frame::readFrame(QIODevice *pIoDevice)
+QWebSocketFrame QWebSocketFrame::readFrame(QIODevice *pIoDevice)
{
bool isDone = false;
qint64 bytesRead = 0;
- Frame frame;
+ QWebSocketFrame frame;
quint64 dataWaitSize = 0;
ProcessingState processingState = PS_READ_HEADER;
ProcessingState returnState = PS_READ_HEADER;
@@ -543,7 +543,7 @@ Frame Frame::readFrame(QIODevice *pIoDevice)
/*!
\internal
*/
-void Frame::setError(QWebSocketProtocol::CloseCode code, QString closeReason)
+void QWebSocketFrame::setError(QWebSocketProtocol::CloseCode code, QString closeReason)
{
clear();
m_closeCode = code;
@@ -554,7 +554,7 @@ void Frame::setError(QWebSocketProtocol::CloseCode code, QString closeReason)
/*!
\internal
*/
-bool Frame::checkValidity()
+bool QWebSocketFrame::checkValidity()
{
if (!isValid())
{
@@ -592,7 +592,7 @@ bool Frame::checkValidity()
/*!
\internal
*/
-DataProcessor::DataProcessor(QObject *parent) :
+QWebSocketDataProcessor::QWebSocketDataProcessor(QObject *parent) :
QObject(parent),
m_processingState(PS_READ_HEADER),
m_isFinalFrame(false),
@@ -613,7 +613,7 @@ DataProcessor::DataProcessor(QObject *parent) :
/*!
\internal
*/
-DataProcessor::~DataProcessor()
+QWebSocketDataProcessor::~QWebSocketDataProcessor()
{
clear();
if (m_pConverterState)
@@ -626,7 +626,7 @@ DataProcessor::~DataProcessor()
/*!
\internal
*/
-quint64 DataProcessor::maxMessageSize()
+quint64 QWebSocketDataProcessor::maxMessageSize()
{
return MAX_MESSAGE_SIZE_IN_BYTES;
}
@@ -634,7 +634,7 @@ quint64 DataProcessor::maxMessageSize()
/*!
\internal
*/
-quint64 DataProcessor::maxFrameSize()
+quint64 QWebSocketDataProcessor::maxFrameSize()
{
return MAX_FRAME_SIZE_IN_BYTES;
}
@@ -642,13 +642,13 @@ quint64 DataProcessor::maxFrameSize()
/*!
\internal
*/
-void DataProcessor::process(QIODevice *pIoDevice)
+void QWebSocketDataProcessor::process(QIODevice *pIoDevice)
{
bool isDone = false;
while (!isDone)
{
- Frame frame = Frame::readFrame(pIoDevice);
+ QWebSocketFrame frame = QWebSocketFrame::readFrame(pIoDevice);
if (frame.isValid())
{
if (frame.isControlFrame())
@@ -731,7 +731,7 @@ void DataProcessor::process(QIODevice *pIoDevice)
/*!
\internal
*/
-void DataProcessor::clear()
+void QWebSocketDataProcessor::clear()
{
m_processingState = PS_READ_HEADER;
m_isFinalFrame = false;
@@ -759,7 +759,7 @@ void DataProcessor::clear()
/*!
\internal
*/
-bool DataProcessor::processControlFrame(const Frame &frame)
+bool QWebSocketDataProcessor::processControlFrame(const QWebSocketFrame &frame)
{
bool mustStopProcessing = false;
switch (frame.getOpCode())
diff --git a/src/websockets/dataprocessor_p.h b/src/websockets/qwebsocketdataprocessor_p.h
index d2d1dcb..30dfd15 100644
--- a/src/websockets/dataprocessor_p.h
+++ b/src/websockets/qwebsocketdataprocessor_p.h
@@ -17,8 +17,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef DATAPROCESSOR_P_H
-#define DATAPROCESSOR_P_H
+#ifndef QWEBSOCKETDATAPROCESSOR_P_H
+#define QWEBSOCKETDATAPROCESSOR_P_H
//
// W A R N I N G
@@ -40,18 +40,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
QT_BEGIN_NAMESPACE
class QIODevice;
-class Frame;
+class QWebSocketFrame;
/*!
\internal
The DataProcessor class reads and interprets incoming websocket messages, and emits appropriate signals.
*/
-class DataProcessor: public QObject
+class QWebSocketDataProcessor: public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocketDataProcessor)
+
public:
- explicit DataProcessor(QObject *parent = 0);
- virtual ~DataProcessor();
+ explicit QWebSocketDataProcessor(QObject *parent = 0);
+ virtual ~QWebSocketDataProcessor();
static quint64 maxMessageSize();
static quint64 maxFrameSize();
@@ -71,7 +73,6 @@ public Q_SLOTS:
void clear();
private:
- Q_DISABLE_COPY(DataProcessor)
enum
{
PS_READ_HEADER,
@@ -94,9 +95,9 @@ private:
QTextCodec::ConverterState *m_pConverterState;
QTextCodec *m_pTextCodec;
- bool processControlFrame(const Frame &frame);
+ bool processControlFrame(const QWebSocketFrame &frame);
};
QT_END_NAMESPACE
-#endif // DATAPROCESSOR_P_H
+#endif // QWEBSOCKETDATAPROCESSOR_P_H
diff --git a/src/websockets/handshakerequest_p.cpp b/src/websockets/qwebsockethandshakerequest_p.cpp
index 132ff6a..86b3223 100644
--- a/src/websockets/handshakerequest_p.cpp
+++ b/src/websockets/qwebsockethandshakerequest_p.cpp
@@ -17,7 +17,7 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "handshakerequest_p.h"
+#include "qwebsockethandshakerequest_p.h"
#include <QString>
#include <QMap>
#include <QTextStream>
@@ -31,7 +31,7 @@ QT_BEGIN_NAMESPACE
/*!
\internal
*/
-HandshakeRequest::HandshakeRequest(int port, bool isSecure) :
+QWebSocketHandshakeRequest::QWebSocketHandshakeRequest(int port, bool isSecure) :
m_port(port),
m_isSecure(isSecure),
m_isValid(false),
@@ -48,14 +48,14 @@ HandshakeRequest::HandshakeRequest(int port, bool isSecure) :
/*!
\internal
*/
-HandshakeRequest::~HandshakeRequest()
+QWebSocketHandshakeRequest::~QWebSocketHandshakeRequest()
{
}
/*!
\internal
*/
-void HandshakeRequest::clear()
+void QWebSocketHandshakeRequest::clear()
{
m_port = -1;
m_isSecure = false;
@@ -72,7 +72,7 @@ void HandshakeRequest::clear()
/*!
\internal
*/
-int HandshakeRequest::getPort() const
+int QWebSocketHandshakeRequest::getPort() const
{
return m_requestUrl.port(m_port);
}
@@ -80,7 +80,7 @@ int HandshakeRequest::getPort() const
/*!
\internal
*/
-bool HandshakeRequest::isSecure() const
+bool QWebSocketHandshakeRequest::isSecure() const
{
return m_isSecure;
}
@@ -88,7 +88,7 @@ bool HandshakeRequest::isSecure() const
/*!
\internal
*/
-bool HandshakeRequest::isValid() const
+bool QWebSocketHandshakeRequest::isValid() const
{
return m_isValid;
}
@@ -96,7 +96,7 @@ bool HandshakeRequest::isValid() const
/*!
\internal
*/
-QMap<QString, QString> HandshakeRequest::getHeaders() const
+QMap<QString, QString> QWebSocketHandshakeRequest::getHeaders() const
{
return m_headers;
}
@@ -104,7 +104,7 @@ QMap<QString, QString> HandshakeRequest::getHeaders() const
/*!
\internal
*/
-QList<QWebSocketProtocol::Version> HandshakeRequest::getVersions() const
+QList<QWebSocketProtocol::Version> QWebSocketHandshakeRequest::getVersions() const
{
return m_versions;
}
@@ -112,7 +112,7 @@ QList<QWebSocketProtocol::Version> HandshakeRequest::getVersions() const
/*!
\internal
*/
-QString HandshakeRequest::getResourceName() const
+QString QWebSocketHandshakeRequest::getResourceName() const
{
return m_requestUrl.path();
}
@@ -120,7 +120,7 @@ QString HandshakeRequest::getResourceName() const
/*!
\internal
*/
-QString HandshakeRequest::getKey() const
+QString QWebSocketHandshakeRequest::getKey() const
{
return m_key;
}
@@ -128,7 +128,7 @@ QString HandshakeRequest::getKey() const
/*!
\internal
*/
-QString HandshakeRequest::getHost() const
+QString QWebSocketHandshakeRequest::getHost() const
{
return m_requestUrl.host();
}
@@ -136,7 +136,7 @@ QString HandshakeRequest::getHost() const
/*!
\internal
*/
-QString HandshakeRequest::getOrigin() const
+QString QWebSocketHandshakeRequest::getOrigin() const
{
return m_origin;
}
@@ -144,7 +144,7 @@ QString HandshakeRequest::getOrigin() const
/*!
\internal
*/
-QList<QString> HandshakeRequest::getProtocols() const
+QList<QString> QWebSocketHandshakeRequest::getProtocols() const
{
return m_protocols;
}
@@ -152,7 +152,7 @@ QList<QString> HandshakeRequest::getProtocols() const
/*!
\internal
*/
-QList<QString> HandshakeRequest::getExtensions() const
+QList<QString> QWebSocketHandshakeRequest::getExtensions() const
{
return m_extensions;
}
@@ -160,7 +160,7 @@ QList<QString> HandshakeRequest::getExtensions() const
/*!
\internal
*/
-QUrl HandshakeRequest::getRequestUrl() const
+QUrl QWebSocketHandshakeRequest::getRequestUrl() const
{
return m_requestUrl;
}
@@ -168,7 +168,7 @@ QUrl HandshakeRequest::getRequestUrl() const
/*!
\internal
*/
-QTextStream &HandshakeRequest::readFromStream(QTextStream &textStream)
+QTextStream &QWebSocketHandshakeRequest::readFromStream(QTextStream &textStream)
{
m_isValid = false;
clear();
@@ -262,7 +262,7 @@ QTextStream &HandshakeRequest::readFromStream(QTextStream &textStream)
/*!
\internal
*/
-QTextStream &operator >>(QTextStream &stream, HandshakeRequest &request)
+QTextStream &operator >>(QTextStream &stream, QWebSocketHandshakeRequest &request)
{
return request.readFromStream(stream);
}
diff --git a/src/websockets/handshakerequest_p.h b/src/websockets/qwebsockethandshakerequest_p.h
index c2cc154..1684670 100644
--- a/src/websockets/handshakerequest_p.h
+++ b/src/websockets/qwebsockethandshakerequest_p.h
@@ -17,8 +17,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef HANDSHAKEREQUEST_P_H
-#define HANDSHAKEREQUEST_P_H
+#ifndef QWEBSOCKETHANDSHAKEREQUEST_P_H
+#define QWEBSOCKETHANDSHAKEREQUEST_P_H
//
// W A R N I N G
// -------------
@@ -42,11 +42,13 @@ QT_BEGIN_NAMESPACE
class QTextStream;
-class HandshakeRequest
+class QWebSocketHandshakeRequest
{
+ Q_DISABLE_COPY(QWebSocketHandshakeRequest)
+
public:
- HandshakeRequest(int port, bool isSecure);
- virtual ~HandshakeRequest();
+ QWebSocketHandshakeRequest(int port, bool isSecure);
+ virtual ~QWebSocketHandshakeRequest();
void clear();
@@ -64,9 +66,8 @@ public:
QString getHost() const;
private:
- Q_DISABLE_COPY(HandshakeRequest)
QTextStream &readFromStream(QTextStream &textStream);
- friend QTextStream &operator >>(QTextStream &stream, HandshakeRequest &request);
+ friend QTextStream &operator >>(QTextStream &stream, QWebSocketHandshakeRequest &request);
int m_port;
bool m_isSecure;
@@ -80,8 +81,8 @@ private:
QUrl m_requestUrl;
};
-QTextStream &operator >>(QTextStream &stream, HandshakeRequest &request);
+QTextStream &operator >>(QTextStream &stream, QWebSocketHandshakeRequest &request);
QT_END_NAMESPACE
-#endif // HANDSHAKEREQUEST_P_H
+#endif // QWEBSOCKETHANDSHAKEREQUEST_P_H
diff --git a/src/websockets/handshakeresponse_p.cpp b/src/websockets/qwebsockethandshakeresponse_p.cpp
index 1713b45..4beaeed 100644
--- a/src/websockets/handshakeresponse_p.cpp
+++ b/src/websockets/qwebsockethandshakeresponse_p.cpp
@@ -17,8 +17,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "handshakeresponse_p.h"
-#include "handshakerequest_p.h"
+#include "qwebsockethandshakeresponse_p.h"
+#include "qwebsockethandshakerequest_p.h"
#include <QString>
#include <QTextStream>
#include <QByteArray>
@@ -34,7 +34,7 @@ QT_BEGIN_NAMESPACE
/*!
\internal
*/
-HandshakeResponse::HandshakeResponse(const HandshakeRequest &request,
+QWebSocketHandshakeResponse::QWebSocketHandshakeResponse(const QWebSocketHandshakeRequest &request,
const QString &serverName,
bool isOriginAllowed,
const QList<QWebSocketProtocol::Version> &supportedVersions,
@@ -54,14 +54,14 @@ HandshakeResponse::HandshakeResponse(const HandshakeRequest &request,
/*!
\internal
*/
-HandshakeResponse::~HandshakeResponse()
+QWebSocketHandshakeResponse::~QWebSocketHandshakeResponse()
{
}
/*!
\internal
*/
-bool HandshakeResponse::isValid() const
+bool QWebSocketHandshakeResponse::isValid() const
{
return m_isValid;
}
@@ -69,7 +69,7 @@ bool HandshakeResponse::isValid() const
/*!
\internal
*/
-bool HandshakeResponse::canUpgrade() const
+bool QWebSocketHandshakeResponse::canUpgrade() const
{
return m_isValid && m_canUpgrade;
}
@@ -77,7 +77,7 @@ bool HandshakeResponse::canUpgrade() const
/*!
\internal
*/
-QString HandshakeResponse::getAcceptedProtocol() const
+QString QWebSocketHandshakeResponse::getAcceptedProtocol() const
{
return m_acceptedProtocol;
}
@@ -85,7 +85,7 @@ QString HandshakeResponse::getAcceptedProtocol() const
/*!
\internal
*/
-QString HandshakeResponse::calculateAcceptKey(const QString &key) const
+QString QWebSocketHandshakeResponse::calculateAcceptKey(const QString &key) const
{
const QString tmpKey = key % QStringLiteral("258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); //the UID comes from RFC6455
const QByteArray hash = QCryptographicHash::hash(tmpKey.toLatin1(), QCryptographicHash::Sha1);
@@ -95,7 +95,7 @@ QString HandshakeResponse::calculateAcceptKey(const QString &key) const
/*!
\internal
*/
-QString HandshakeResponse::getHandshakeResponse(const HandshakeRequest &request,
+QString QWebSocketHandshakeResponse::getHandshakeResponse(const QWebSocketHandshakeRequest &request,
const QString &serverName,
bool isOriginAllowed,
const QList<QWebSocketProtocol::Version> &supportedVersions,
@@ -180,7 +180,7 @@ QString HandshakeResponse::getHandshakeResponse(const HandshakeRequest &request,
/*!
\internal
*/
-QTextStream &HandshakeResponse::writeToStream(QTextStream &textStream) const
+QTextStream &QWebSocketHandshakeResponse::writeToStream(QTextStream &textStream) const
{
if (!m_response.isEmpty())
{
@@ -196,7 +196,7 @@ QTextStream &HandshakeResponse::writeToStream(QTextStream &textStream) const
/*!
\internal
*/
-QTextStream &operator <<(QTextStream &stream, const HandshakeResponse &response)
+QTextStream &operator <<(QTextStream &stream, const QWebSocketHandshakeResponse &response)
{
return response.writeToStream(stream);
}
@@ -204,7 +204,7 @@ QTextStream &operator <<(QTextStream &stream, const HandshakeResponse &response)
/*!
\internal
*/
-QWebSocketProtocol::Version HandshakeResponse::getAcceptedVersion() const
+QWebSocketProtocol::Version QWebSocketHandshakeResponse::getAcceptedVersion() const
{
return m_acceptedVersion;
}
@@ -212,7 +212,7 @@ QWebSocketProtocol::Version HandshakeResponse::getAcceptedVersion() const
/*!
\internal
*/
-QString HandshakeResponse::getAcceptedExtension() const
+QString QWebSocketHandshakeResponse::getAcceptedExtension() const
{
return m_acceptedExtension;
}
diff --git a/src/websockets/handshakeresponse_p.h b/src/websockets/qwebsockethandshakeresponse_p.h
index 7b1179b..1299047 100644
--- a/src/websockets/handshakeresponse_p.h
+++ b/src/websockets/qwebsockethandshakeresponse_p.h
@@ -17,8 +17,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef HANDSHAKERESPONSE_P_H
-#define HANDSHAKERESPONSE_P_H
+#ifndef QWEBSOCKETHANDSHAKERESPONSE_P_H
+#define QWEBSOCKETHANDSHAKERESPONSE_P_H
//
// W A R N I N G
// -------------
@@ -35,22 +35,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
QT_BEGIN_NAMESPACE
-class HandshakeRequest;
+class QWebSocketHandshakeRequest;
class QString;
class QTextStream;
-class HandshakeResponse:public QObject
+class QWebSocketHandshakeResponse:public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocketHandshakeResponse)
+
public:
- HandshakeResponse(const HandshakeRequest &request,
+ QWebSocketHandshakeResponse(const QWebSocketHandshakeRequest &request,
const QString &serverName,
bool isOriginAllowed,
const QList<QWebSocketProtocol::Version> &supportedVersions,
const QList<QString> &supportedProtocols,
const QList<QString> &supportedExtensions);
- virtual ~HandshakeResponse();
+ virtual ~QWebSocketHandshakeResponse();
bool isValid() const;
bool canUpgrade() const;
@@ -63,7 +65,6 @@ public Q_SLOTS:
Q_SIGNALS:
private:
- Q_DISABLE_COPY(HandshakeResponse)
bool m_isValid;
bool m_canUpgrade;
QString m_response;
@@ -72,7 +73,7 @@ private:
QWebSocketProtocol::Version m_acceptedVersion;
QString calculateAcceptKey(const QString &key) const;
- QString getHandshakeResponse(const HandshakeRequest &request,
+ QString getHandshakeResponse(const QWebSocketHandshakeRequest &request,
const QString &serverName,
bool isOriginAllowed,
const QList<QWebSocketProtocol::Version> &supportedVersions,
@@ -80,9 +81,9 @@ private:
const QList<QString> &supportedExtensions);
QTextStream &writeToStream(QTextStream &textStream) const;
- friend QTextStream &operator <<(QTextStream &stream, const HandshakeResponse &response);
+ friend QTextStream &operator <<(QTextStream &stream, const QWebSocketHandshakeResponse &response);
};
QT_END_NAMESPACE
-#endif // HANDSHAKERESPONSE_P_H
+#endif // QWEBSOCKETHANDSHAKERESPONSE_P_H
diff --git a/src/websockets/qwebsocketserver.h b/src/websockets/qwebsocketserver.h
index 6579b53..3dc3379 100644
--- a/src/websockets/qwebsocketserver.h
+++ b/src/websockets/qwebsocketserver.h
@@ -30,11 +30,13 @@ QT_BEGIN_NAMESPACE
class QWebSocketServerPrivate;
class QWebSocket;
-class QCorsAuthenticator;
+class QWebSocketCorsAuthenticator;
class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocketServer)
+ Q_DECLARE_PRIVATE(QWebSocketServer)
public:
explicit QWebSocketServer(const QString &serverName, QObject *parent = 0);
@@ -78,12 +80,10 @@ public:
Q_SIGNALS:
void acceptError(QAbstractSocket::SocketError socketError);
- void originAuthenticationRequired(QCorsAuthenticator *pAuthenticator);
+ void originAuthenticationRequired(QWebSocketCorsAuthenticator *pAuthenticator);
void newConnection();
private:
- Q_DISABLE_COPY(QWebSocketServer)
- Q_DECLARE_PRIVATE(QWebSocketServer)
QWebSocketServerPrivate * const d_ptr;
};
diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp
index 8e4bc7b..47796c2 100644
--- a/src/websockets/qwebsocketserver_p.cpp
+++ b/src/websockets/qwebsocketserver_p.cpp
@@ -23,11 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "qwebsocketserver.h"
#include "qwebsocketserver_p.h"
#include "qwebsocketprotocol.h"
-#include "handshakerequest_p.h"
-#include "handshakeresponse_p.h"
+#include "qwebsockethandshakerequest_p.h"
+#include "qwebsockethandshakeresponse_p.h"
#include "qwebsocket.h"
#include "qwebsocket_p.h"
-#include "qcorsauthenticator.h"
+#include "qwebsocketcorsauthenticator.h"
QT_BEGIN_NAMESPACE
@@ -298,14 +298,14 @@ void QWebSocketServerPrivate::handshakeReceived()
{
bool success = false;
bool isSecure = false;
- HandshakeRequest request(pTcpSocket->peerPort(), isSecure);
+ QWebSocketHandshakeRequest request(pTcpSocket->peerPort(), isSecure);
QTextStream textStream(pTcpSocket);
textStream >> request;
- QCorsAuthenticator corsAuthenticator(request.getOrigin());
+ QWebSocketCorsAuthenticator corsAuthenticator(request.getOrigin());
Q_EMIT q->originAuthenticationRequired(&corsAuthenticator);
- HandshakeResponse response(request,
+ QWebSocketHandshakeResponse response(request,
m_serverName,
corsAuthenticator.allowed(),
supportedVersions(),
diff --git a/src/websockets/qwebsocketserver_p.h b/src/websockets/qwebsocketserver_p.h
index 081ecec..6d84160 100644
--- a/src/websockets/qwebsocketserver_p.h
+++ b/src/websockets/qwebsocketserver_p.h
@@ -44,6 +44,8 @@ class QWebSocketServer;
class QWebSocketServerPrivate : public QObject
{
Q_OBJECT
+ Q_DISABLE_COPY(QWebSocketServerPrivate)
+ Q_DECLARE_PUBLIC(QWebSocketServer)
public:
explicit QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer, QObject *parent = 0);
@@ -86,7 +88,6 @@ private Q_SLOTS:
void handshakeReceived();
private:
- Q_DECLARE_PUBLIC(QWebSocketServer)
QWebSocketServer * const q_ptr;
QTcpServer *m_pTcpServer;
diff --git a/src/websockets/websockets.pro b/src/websockets/websockets.pro
index 69ddc9c..7d0f4a2 100644
--- a/src/websockets/websockets.pro
+++ b/src/websockets/websockets.pro
@@ -15,15 +15,15 @@ PUBLIC_HEADERS += \
$$PWD/qwebsocketserver.h \
$$PWD/qwebsocketprotocol.h \
$$PWD/qwebsocketsglobal.h \
- $$PWD/qcorsauthenticator.h
+ $$PWD/qwebsocketcorsauthenticator.h
PRIVATE_HEADERS += \
$$PWD/qwebsocket_p.h \
$$PWD/qwebsocketserver_p.h \
- $$PWD/handshakerequest_p.h \
- $$PWD/handshakeresponse_p.h \
- $$PWD/dataprocessor_p.h \
- $$PWD/qcorsauthenticator_p.h
+ $$PWD/qwebsockethandshakerequest_p.h \
+ $$PWD/qwebsockethandshakeresponse_p.h \
+ $$PWD/qwebsocketdataprocessor_p.h \
+ $$PWD/qwebsocketcorsauthenticator_p.h
SOURCES += \
$$PWD/qwebsocket.cpp \
@@ -31,15 +31,9 @@ SOURCES += \
$$PWD/qwebsocketserver.cpp \
$$PWD/qwebsocketserver_p.cpp \
$$PWD/qwebsocketprotocol.cpp \
- $$PWD/handshakerequest_p.cpp \
- $$PWD/handshakeresponse_p.cpp \
- $$PWD/dataprocessor_p.cpp \
- $$PWD/qcorsauthenticator.cpp
+ $$PWD/qwebsockethandshakerequest_p.cpp \
+ $$PWD/qwebsockethandshakeresponse_p.cpp \
+ $$PWD/qwebsocketdataprocessor_p.cpp \
+ $$PWD/qwebsocketcorsauthenticator.cpp
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
-
-#mac:QMAKE_FRAMEWORK_BUNDLE_NAME = $$TARGET
-#mac:QMAKE_CXXFLAGS += -Wall -Werror -Wextra
-
-
-