From: Kurt Pattyn Date: Mon, 26 Aug 2013 11:01:22 +0000 (+0200) Subject: Made accessor methods const; made serverName parameter const in QWebSocket X-Git-Tag: v5.3.0-alpha1~254 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7145281bf5cfe57f05e7bb85aa280100f6ceebc;p=contrib%2Fqtwebsockets.git Made accessor methods const; made serverName parameter const in QWebSocket --- diff --git a/src/qwebsocket.cpp b/src/qwebsocket.cpp index 822d4a2..b42984c 100644 --- a/src/qwebsocket.cpp +++ b/src/qwebsocket.cpp @@ -186,7 +186,7 @@ const quint64 FRAME_SIZE_IN_BYTES = 512 * 512 * 2; //maximum size of a frame whe * (The \a origin is not required for non-web browser clients (see RFC 6455)). * \note Currently only V13 (RFC 6455) is supported */ -QWebSocket::QWebSocket(QString origin, QWebSocketProtocol::Version version, QObject *parent) : +QWebSocket::QWebSocket(const QString &origin, QWebSocketProtocol::Version version, QObject *parent) : QObject(parent), d_ptr(new QWebSocketPrivate(origin, version, this, this)) { @@ -317,7 +317,7 @@ void QWebSocket::ping() /*! \brief Returns the version the socket is currently using */ -QWebSocketProtocol::Version QWebSocket::version() +QWebSocketProtocol::Version QWebSocket::version() const { return d_ptr->version(); } @@ -325,7 +325,7 @@ QWebSocketProtocol::Version QWebSocket::version() /*! \brief Returns the name of the resource currently accessed. */ -QString QWebSocket::resourceName() +QString QWebSocket::resourceName() const { return d_ptr->resourceName(); } @@ -333,7 +333,7 @@ QString QWebSocket::resourceName() /*! \brief Returns the url the socket is connected to or will connect to. */ -QUrl QWebSocket::requestUrl() +QUrl QWebSocket::requestUrl() const { return d_ptr->requestUrl(); } @@ -341,7 +341,7 @@ QUrl QWebSocket::requestUrl() /*! \brief Returns the current origin */ -QString QWebSocket::origin() +QString QWebSocket::origin() const { return d_ptr->origin(); } @@ -349,7 +349,7 @@ QString QWebSocket::origin() /*! \brief Returns the currently used protocol. */ -QString QWebSocket::protocol() +QString QWebSocket::protocol() const { return d_ptr->protocol(); } @@ -357,7 +357,7 @@ QString QWebSocket::protocol() /*! \brief Returns the currently used extension. */ -QString QWebSocket::extension() +QString QWebSocket::extension() const { return d_ptr->extension(); } @@ -542,7 +542,7 @@ QVariant QWebSocket::socketOption(QAbstractSocket::SocketOption option) /*! Returns true if the QWebSocket is valid. */ -bool QWebSocket::isValid() +bool QWebSocket::isValid() const { return d_ptr->isValid(); } diff --git a/src/qwebsocket.h b/src/qwebsocket.h index d244783..faf489a 100644 --- a/src/qwebsocket.h +++ b/src/qwebsocket.h @@ -40,14 +40,14 @@ class Q_WEBSOCKETS_EXPORT QWebSocket:public QObject Q_OBJECT public: - explicit QWebSocket(QString origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::V_LATEST, QObject *parent = 0); + explicit QWebSocket(const QString &origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::V_LATEST, QObject *parent = 0); virtual ~QWebSocket(); void abort(); QAbstractSocket::SocketError error() const; QString errorString() const; bool flush(); - bool isValid(); + bool isValid() const; QHostAddress localAddress() const; quint16 localPort() const; QAbstractSocket::PauseModes pauseMode() const; @@ -71,12 +71,12 @@ public: bool waitForConnected(int msecs = 30000); bool waitForDisconnected(int msecs = 30000); - QWebSocketProtocol::Version version(); - QString resourceName(); - QUrl requestUrl(); - QString origin(); - QString protocol(); - QString extension(); + QWebSocketProtocol::Version version() const; + QString resourceName() const; + QUrl requestUrl() const; + QString origin() const; + QString protocol() const; + QString extension() const; qint64 write(const char *message); //send data as text qint64 write(const char *message, qint64 maxSize); //send data as text diff --git a/src/qwebsocket_p.cpp b/src/qwebsocket_p.cpp index 2126a75..962fb83 100644 --- a/src/qwebsocket_p.cpp +++ b/src/qwebsocket_p.cpp @@ -45,7 +45,7 @@ const quint64 FRAME_SIZE_IN_BYTES = 512 * 512 * 2; //maximum size of a frame whe /*! \internal */ -QWebSocketPrivate::QWebSocketPrivate(QString origin, QWebSocketProtocol::Version version, QWebSocket *pWebSocket, QObject *parent) : +QWebSocketPrivate::QWebSocketPrivate(const QString &origin, QWebSocketProtocol::Version version, QWebSocket *pWebSocket, QObject *parent) : QObject(parent), q_ptr(pWebSocket), m_pSocket(new QTcpSocket(this)), @@ -386,7 +386,7 @@ void QWebSocketPrivate::releaseConnections(const QTcpSocket *pTcpSocket) /*! \internal */ -QWebSocketProtocol::Version QWebSocketPrivate::version() +QWebSocketProtocol::Version QWebSocketPrivate::version() const { return m_version; } @@ -394,7 +394,7 @@ QWebSocketProtocol::Version QWebSocketPrivate::version() /*! \internal */ -QString QWebSocketPrivate::resourceName() +QString QWebSocketPrivate::resourceName() const { return m_resourceName; } @@ -402,7 +402,7 @@ QString QWebSocketPrivate::resourceName() /*! \internal */ -QUrl QWebSocketPrivate::requestUrl() +QUrl QWebSocketPrivate::requestUrl() const { return m_requestUrl; } @@ -410,7 +410,7 @@ QUrl QWebSocketPrivate::requestUrl() /*! \internal */ -QString QWebSocketPrivate::origin() +QString QWebSocketPrivate::origin() const { return m_origin; } @@ -418,7 +418,7 @@ QString QWebSocketPrivate::origin() /*! \internal */ -QString QWebSocketPrivate::protocol() +QString QWebSocketPrivate::protocol() const { return m_protocol; } @@ -426,7 +426,7 @@ QString QWebSocketPrivate::protocol() /*! \internal */ -QString QWebSocketPrivate::extension() +QString QWebSocketPrivate::extension() const { return m_extension; } @@ -1203,7 +1203,7 @@ QVariant QWebSocketPrivate::socketOption(QAbstractSocket::SocketOption option) /*! \internal */ -bool QWebSocketPrivate::isValid() +bool QWebSocketPrivate::isValid() const { bool valid = false; if (m_pSocket) diff --git a/src/qwebsocket_p.h b/src/qwebsocket_p.h index 83278ac..5843381 100644 --- a/src/qwebsocket_p.h +++ b/src/qwebsocket_p.h @@ -53,7 +53,7 @@ class QWebSocketPrivate:public QObject Q_OBJECT public: - explicit QWebSocketPrivate(QString origin, + explicit QWebSocketPrivate(const QString &origin, QWebSocketProtocol::Version version, QWebSocket * const pWebSocket, QObject *parent = 0); @@ -63,7 +63,7 @@ public: QAbstractSocket::SocketError error() const; QString errorString() const; bool flush(); - bool isValid(); + bool isValid() const; QHostAddress localAddress() const; quint16 localPort() const; QAbstractSocket::PauseModes pauseMode() const; @@ -85,12 +85,12 @@ public: bool waitForConnected(int msecs = 30000); bool waitForDisconnected(int msecs = 30000); - QWebSocketProtocol::Version version(); - QString resourceName(); - QUrl requestUrl(); - QString origin(); - QString protocol(); - QString extension(); + QWebSocketProtocol::Version version() const; + QString resourceName() const; + QUrl requestUrl() const; + QString origin() const; + QString protocol() const; + QString extension() const; qint64 write(const char *message); //send data as text qint64 write(const char *message, qint64 maxSize); //send data as text @@ -172,7 +172,6 @@ private: DataProcessor m_dataProcessor; - friend class QWebSocketServerPrivate; friend class QWebSocket; };