diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/client/clientapp/clientapp.h | 4 | ||||
-rw-r--r-- | src/client/connectwindow/connectwindow.cpp | 7 | ||||
-rw-r--r-- | src/client/net/serverconnection.cpp | 9 | ||||
-rw-r--r-- | src/client/net/serverconnection.h | 2 | ||||
-rw-r--r-- | src/client/net/serverdiscovery.cpp | 6 | ||||
-rw-r--r-- | src/client/vnc/vncserver.cpp | 8 | ||||
-rw-r--r-- | src/client/vnc/vncthread.h | 2 | ||||
-rw-r--r-- | src/client/vnc/vncwindow.cpp | 4 | ||||
-rw-r--r-- | src/server/clicklabel/clicklabel.cpp | 2 | ||||
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 2 | ||||
-rw-r--r-- | src/server/connectionframe/connectionframe.h | 4 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/server/net/certmanager.cpp | 2 | ||||
-rw-r--r-- | src/server/net/client.cpp | 7 | ||||
-rw-r--r-- | src/server/net/client.h | 20 | ||||
-rw-r--r-- | src/server/net/discoverylistener.cpp | 17 | ||||
-rw-r--r-- | src/server/net/sslserver.cpp | 4 | ||||
-rw-r--r-- | src/shared/networkmessage.cpp | 28 | ||||
-rw-r--r-- | src/shared/networkmessage.h | 6 |
20 files changed, 79 insertions, 72 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cb8cb3..af61455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) SET(CMAKE_BUILD_TYPE Debug) SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wunused -Wunreachable-code -pedantic") SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -std=c++0x") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Wextra -Wpedantic -std=c++0x -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wunsafe-loop-optimizations -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings") +# -Wshadow spams too much :/ SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x" ) # local cmake modules diff --git a/src/client/clientapp/clientapp.h b/src/client/clientapp/clientapp.h index dbfbc32..0f7cb5b 100644 --- a/src/client/clientapp/clientapp.h +++ b/src/client/clientapp/clientapp.h @@ -56,9 +56,9 @@ public: ConnectWindow* connectWindow() const { return _connectWindow; } - const bool isConfiguredAsManager() const { return _isManagerPc; } + bool isConfiguredAsManager() { return _isManagerPc; } - const bool isConnectedToLocalManager() const { return _connection != NULL && _connection->isLocalConnection(); } + bool isConnectedToLocalManager() { return _connection != NULL && _connection->isLocalConnection(); } private slots: diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp index 18ceb9c..b1f583a 100644 --- a/src/client/connectwindow/connectwindow.cpp +++ b/src/client/connectwindow/connectwindow.cpp @@ -114,6 +114,9 @@ void ConnectWindow::updateUserInterface() case InvalidSslHash: _ui->lblStatus->setText(tr("Invalid TLS hash: %1.").arg(_hashSslErrorCount)); break; + default: + _ui->lblStatus->setText(tr("Unknown state :-(")); + break; } } @@ -162,7 +165,7 @@ void ConnectWindow::doShow() * Gives the keyboard input focus to the input line. * @param event */ -void ConnectWindow::showEvent(QShowEvent* event) +void ConnectWindow::showEvent(QShowEvent* /* event */ ) { activateWindow(); raise(); @@ -341,7 +344,7 @@ void ConnectWindow::onComboBox_keyPressed(QKeyEvent* e) * If connection is closed set _pendingConnection = NULL. * @param connection */ -void ConnectWindow::onConnectionClosed(QObject* connection) +void ConnectWindow::onConnectionClosed(QObject* /* connection */ ) { _pendingConnection = NULL; } diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index 826cf06..e9cc72c 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -110,8 +110,9 @@ void ServerConnection::handleMsg() // Initial challenge request by server emit stateChange(ConnectWindow::AwaitingChallengeResponse); _myChallenge.resize(CHALLENGE_LEN); - for (int i = 0; i < CHALLENGE_LEN; ++i) - _myChallenge[i] = qrand() & 0xff; + for (int i = 0; i < CHALLENGE_LEN; ++i) { + _myChallenge[i] = (char)(qrand() & 0xff); + } QByteArray serverChallenge(_fromServer.getFieldBytes(_CHALLENGE)); _toServer.reset(); _toServer.setField(_ID, _CHALLENGE); @@ -141,13 +142,13 @@ void ServerConnection::handleMsg() return; } emit stateChange(ConnectWindow::LoggingIn); - char *user = getpwuid(getuid())->pw_name; + const char *user = getpwuid(getuid())->pw_name; if (user == NULL || *user == '\0') user = getenv("USER"); if (user == NULL || *user == '\0') user = getenv("USERNAME"); if (user == NULL || *user == '\0') - user = (char*)"Hans Affe"; + user = "Hans Affe"; _toServer.reset(); _toServer.setField(_ID, _LOGIN); _toServer.setField("HOST", QHostInfo::localHostName()); diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h index 17fa20a..9db9b02 100644 --- a/src/client/net/serverconnection.h +++ b/src/client/net/serverconnection.h @@ -36,7 +36,7 @@ public: ServerConnection(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect); void disconnectFromServer(); ~ServerConnection(); - const inline bool isConnected() const + inline bool isConnected() const { return _socket != NULL && _socket->state() == QAbstractSocket::ConnectedState; } diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp index 99a0dcd..5ca0eba 100644 --- a/src/client/net/serverdiscovery.cpp +++ b/src/client/net/serverdiscovery.cpp @@ -21,7 +21,7 @@ ServerDiscovery::ServerDiscovery(QObject *parent) /* Try to get a UDP port for server discovery */ int tries = 10; while (tries-- != 0) { - const quint16 port = (quint16)(qrand() % 10000) + 10000; + const quint16 port = (quint16)(qrand() % 10000 + 10000); if (_discoverySocket.bind(QHostAddress::Any, port)) break; if (tries == 0) @@ -98,8 +98,8 @@ void ServerDiscovery::doDiscovery() if (_salt2.size() < SALT_LEN) _salt2.resize(SALT_LEN); for (int i = 0; i < SALT_LEN; ++i) { - salt1[i] = qrand() & 0xff; - _salt2[i] = qrand() & 0xff; + salt1[i] = (char)(qrand() & 0xff); + _salt2[i] = (char)(qrand() & 0xff); } _packet.reset(); _packet.setField(_HASH, genSha1(&_nameBytes, &salt1, &iplist)); diff --git a/src/client/vnc/vncserver.cpp b/src/client/vnc/vncserver.cpp index 496a84d..165ba6d 100644 --- a/src/client/vnc/vncserver.cpp +++ b/src/client/vnc/vncserver.cpp @@ -34,7 +34,7 @@ static QString makePassword(int len = 10) { char pass[len]; for (int i = 0; i < len; ++i) - pass[i] = 43 + qrand() % 80; + pass[i] = (char)(43 + qrand() % 80); return QString::fromUtf8(pass, len); } @@ -167,7 +167,7 @@ void VncServer::stop() * after 3 seconds... * @param event */ -void VncServer::timerEvent(QTimerEvent *event) +void VncServer::timerEvent(QTimerEvent * /* event */ ) { // Error timeout (3s), tell server that vnc setup failed this->stop(); @@ -222,7 +222,7 @@ void VncServer::onStdErr() * @brief VncServer::onError * @param error */ -void VncServer::onError(QProcess::ProcessError error) +void VncServer::onError(QProcess::ProcessError /* error */ ) { this->stop(); emit started(0, _ropass, _rwpass); @@ -232,7 +232,7 @@ void VncServer::onError(QProcess::ProcessError error) * @brief VncServer::onFinished * @param exitCode */ -void VncServer::onFinished(int exitCode) +void VncServer::onFinished(int /* exitCode */ ) { this->stop(); emit started(0, _ropass, _rwpass); diff --git a/src/client/vnc/vncthread.h b/src/client/vnc/vncthread.h index a75ca0f..afdb92a 100644 --- a/src/client/vnc/vncthread.h +++ b/src/client/vnc/vncthread.h @@ -76,7 +76,7 @@ public: const QImage& getImage() const { if (_srcStepX > 1 || _srcStepY > 1) return _imgScaled; return _img; } const QSize& getSourceSize() const { return _clientSize; } const QString getDesktopName() const; - const bool isConnected() const { return _connected; } + bool isConnected() { return _connected; } void stop() { _run = false; } void setTargetSize(const QSize size); void run(); diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 8cd7534..b7690b8 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -92,7 +92,7 @@ void VncWindow::draw(const int x, const int y, const int w, const int h) * @param caption caption of window (only visible if not running in fullscreen mode) * @param clientId the ID of the client we're connecting to (echoed back to server, not used locally) */ -void VncWindow::open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb) +void VncWindow::open(const QString& host, int port, const QString& passwd, bool /* ro */ , bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb) { this->terminateVncThread(); _clientId = clientId; @@ -139,7 +139,7 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool * * @param e close event data */ -void VncWindow::closeEvent(QCloseEvent *e) +void VncWindow::closeEvent(QCloseEvent * /* e */ ) { qDebug("Closing VNC viewer window."); this->terminateVncThread(); diff --git a/src/server/clicklabel/clicklabel.cpp b/src/server/clicklabel/clicklabel.cpp index d4b25ee..d771e63 100644 --- a/src/server/clicklabel/clicklabel.cpp +++ b/src/server/clicklabel/clicklabel.cpp @@ -17,7 +17,7 @@ ClickLabel::ClickLabel(QWidget *parent) : QLabel(parent) * Emit Signal clicked(). * @param e */ -void ClickLabel::mouseReleaseEvent(QMouseEvent* e) +void ClickLabel::mouseReleaseEvent(QMouseEvent* /* e */ ) { emit clicked(); } diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index 205433b..85d2e32 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -319,7 +319,7 @@ void ConnectionFrame::paintEvent(QPaintEvent *event) * Handle timer event. * @param event */ -void ConnectionFrame::timerEvent(QTimerEvent* event) +void ConnectionFrame::timerEvent(QTimerEvent* /* event */ ) { if (_client == NULL) return; diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 2549ae8..7f338a8 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -61,13 +61,13 @@ public: const QPixmap& getFramePixmap() const { return _remoteScreen; } void assignClient(Client *client); void setSelection(bool selected); - const inline bool isSelected() const { return _isSelected; } + inline bool isSelected() { return _isSelected; } const QString& computerId() const { return _computerId; } void setComputerId(QString computerId) { if (_client != NULL) return; _computerId = computerId; updateLabels(); } Client* client() const { return _client; } - inline const bool isTutor() const { return _isTutor; } + inline bool isTutor() { return _isTutor; } void setTutor(bool b); protected: diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 87ecca4..0a77240 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -228,10 +228,10 @@ int distance(QPoint a, QPoint b) int distance(QPointF a, QPointF b) { - const int dx = a.x() - b.x(); - const int dy = a.y() - b.y(); - const int sum = dx * dx + dy * dy; - return sum; + const qreal dx = a.x() - b.x(); + const qreal dy = a.y() - b.y(); + const qreal sum = dx * dx + dy * dy; + return (int)sum; } /***************************************************************************//** @@ -300,12 +300,12 @@ endLoop: ; } endSearch: ; /* among all the free positions, find the closest */ - float min_distance = 1000000; + int min_distance = 1000000; QPoint bestPosition = QPoint(0, 0); for (QPoint freePos : freePositions) { const QPoint freePosPx( freePos.x() * getTileWidthPx(), freePos.y() * getTileHeightPx() ); - const float dist = distance(freePosPx, preferredPixels); + const int dist = distance(freePosPx, preferredPixels); if (dist < min_distance) { min_distance = dist; bestPosition = freePos; @@ -478,7 +478,7 @@ AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) * Resize event. * @param e */ -void MainWindow::resizeEvent(QResizeEvent* e) +void MainWindow::resizeEvent(QResizeEvent* /* e */ ) { if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100) { return; diff --git a/src/server/net/certmanager.cpp b/src/server/net/certmanager.cpp index 0121538..0f885da 100644 --- a/src/server/net/certmanager.cpp +++ b/src/server/net/certmanager.cpp @@ -42,7 +42,7 @@ bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &ce } QString certDir = QDir::homePath().append("/").append(CERTSTORAGE); if (!QDir::root().mkpath(certDir)) { - certDir = QString("/tmp/") + qrand() + "-" + qrand() + "/"; + certDir = QString("/tmp/") + QString::number(qrand()) + "-" + QString::number(qrand()) + "/"; QDir::root().mkpath(certDir); } QString certFile = certDir.append(name); diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 836d49b..1b0bbdb 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -43,8 +43,9 @@ Client::Client(QSslSocket* socket) : _socket(socket) this, SLOT(onDataArrival())); // Send challenge _challenge.resize(CHALLENGE_LEN); - for (int i = 0; i < CHALLENGE_LEN; ++i) - _challenge[i] = qrand() & 0xff; + for (int i = 0; i < CHALLENGE_LEN; ++i) { + _challenge[i] = (char)(qrand() & 0xff); + } NetworkMessage msgChlng; msgChlng.setField(_ID, _CHALLENGE); msgChlng.setField(_CHALLENGE, _challenge); @@ -169,7 +170,7 @@ void Client::handleMsg() const int port = _fromClient.getFieldString("PORT").toInt(); if (port <= 0) { if (_vncPort <= 0) { - qDebug() << "Starting VNC server on client" << _name << " (" << _socket->peerAddress().toString() + _vncPort << ") failed."; + qDebug() << "Starting VNC server on client" << _name << " (" << _socket->peerAddress().toString() << ":" << QString::number(_vncPort) << ") failed."; } else { qDebug() << "Client " << _name << " stopped its VNC server"; } diff --git a/src/server/net/client.h b/src/server/net/client.h index 81f5346..9bbc23f 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -30,19 +30,19 @@ public: ~Client(); // Getters - inline const bool isAuthed() const { return _authed == 2; } + inline bool isAuthed() { return _authed == 2; } inline const QString& name() const { return _name; } inline const QString& host() const { return _host; } inline const QString ip() const { return _socket->peerAddress().toString(); } - inline const int id() const { return _id; } - inline const bool isActiveVncClient() const { return _isActiveVncClient; } - inline const bool isActiveVncServer() const { return _vncPort > 0; } - inline const bool isLocked() const { return _locked; } - inline const int desiredProjectionSource() { return _desiredSource; } - inline const int projectionSource() const { return _projectionSource; } - inline const int isExamMode() const { return _isExamMode; } - inline const bool wantsAttention() const { return _wantsAttention; } - inline const void removeAttention() { if (!_wantsAttention) return; removeAttentionInternal(); } + inline int id() { return _id; } + inline bool isActiveVncClient() { return _isActiveVncClient; } + inline bool isActiveVncServer() { return _vncPort > 0; } + inline bool isLocked() { return _locked; } + inline int desiredProjectionSource() { return _desiredSource; } + inline int projectionSource() { return _projectionSource; } + inline int isExamMode() { return _isExamMode; } + inline bool wantsAttention() { return _wantsAttention; } + inline void removeAttention() { if (!_wantsAttention) return; removeAttentionInternal(); } // Setters inline void setTutor(bool enable) { _isTutor = enable; } diff --git a/src/server/net/discoverylistener.cpp b/src/server/net/discoverylistener.cpp index e8d286d..e37c81e 100644 --- a/src/server/net/discoverylistener.cpp +++ b/src/server/net/discoverylistener.cpp @@ -79,14 +79,14 @@ static quint16 hash(const QHostAddress& host) } else { // Durr? len = 2; - data[0] = (quint16)qrand(); - data[1] = (quint16)qrand(); + data[0] = (quint8)qrand(); + data[1] = (quint8)qrand(); } quint16 result = 0; quint16 mod = seed1; for (quint8 i = 0; i < len; ++i) { - result = ((result << 1) + data[i]) ^ mod; // because of the shift this algo is not suitable for len(input) > 8 - mod += seed2 + data[i]; + result = (quint16)(((result << 1) + data[i]) ^ mod); // because of the shift this algo is not suitable for len(input) > 8 + mod = (quint16)(mod + seed2 + data[i]); } return result; } @@ -99,15 +99,16 @@ static quint16 hash(const QHostAddress& host) * @brief Decrease packet counters per source IP in our "spam protection" table. * @param event */ -void DiscoveryListener::timerEvent(QTimerEvent* event) +void DiscoveryListener::timerEvent(QTimerEvent* /* event */ ) { for (int i = 0; i < SPAM_MODERATE_AT_ONCE; ++i) { if (++_counterResetPos >= SD_PACKET_TABLE_SIZE) _counterResetPos = 0; - if (_packetCounter[_counterResetPos] > 10) - _packetCounter[_counterResetPos] -= 10; - else if (_packetCounter[_counterResetPos] != 0) + if (_packetCounter[_counterResetPos] > 10) { + _packetCounter[_counterResetPos] = (quint8)(_packetCounter[_counterResetPos] - 10); + } else if (_packetCounter[_counterResetPos] != 0) { _packetCounter[_counterResetPos] = 0; + } } } diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp index f75f174..966ec5d 100644 --- a/src/server/net/sslserver.cpp +++ b/src/server/net/sslserver.cpp @@ -56,12 +56,12 @@ void SslServer::incomingConnection(int socketDescriptor) } } -void SslServer::sslErrors(const QList<QSslError> & errors) +void SslServer::sslErrors(const QList<QSslError> & /* errors */ ) { //qDebug("FIXME: SSL ERRORS on SERVER: %s", qPrintable(errors.begin()->errorString())); } -void SslServer::timerEvent(QTimerEvent* event) +void SslServer::timerEvent(QTimerEvent* /* event */ ) { // Remove all sockets marked for deletion while (!_delete.isEmpty()) { diff --git a/src/shared/networkmessage.cpp b/src/shared/networkmessage.cpp index 61a29ea..64e02e7 100644 --- a/src/shared/networkmessage.cpp +++ b/src/shared/networkmessage.cpp @@ -13,41 +13,41 @@ #define MAX_MSG_LEN 60000 #define BYTE_SWAP4(x) \ - (((x & 0xFF000000) >> 24) | \ - ((x & 0x00FF0000) >> 8) | \ - ((x & 0x0000FF00) << 8) | \ - ((x & 0x000000FF) << 24)) + ((((x) & 0xFF000000u) >> 24) | \ + (((x) & 0x00FF0000u) >> 8) | \ + (((x) & 0x0000FF00u) << 8) | \ + (((x) & 0x000000FFu) << 24)) #define BYTE_SWAP2(x) \ - (((x & 0xFF00) >> 8) | \ - ((x & 0x00FF) << 8)) + ((((x) & 0xFF00u) >> 8) | \ + (((x) & 0x00FFu) << 8)) static quint16 _htons(quint16 x) { if (QSysInfo::ByteOrder == QSysInfo::BigEndian) return x; - return BYTE_SWAP2(x); + return (quint16)BYTE_SWAP2(x); } static quint16 _ntohs(quint16 x) { if (QSysInfo::ByteOrder == QSysInfo::BigEndian) return x; - return BYTE_SWAP2(x); + return (quint16)BYTE_SWAP2(x); } static quint32 _htonl(quint32 x) { if (QSysInfo::ByteOrder == QSysInfo::BigEndian) return x; - return BYTE_SWAP4(x); + return (quint32)BYTE_SWAP4(x); } static quint32 _ntohl(quint32 x) { if (QSysInfo::ByteOrder == QSysInfo::BigEndian) return x; - return BYTE_SWAP4(x); + return (quint32)BYTE_SWAP4(x); } /* @@ -105,11 +105,11 @@ int NetworkMessage::readMessage(QAbstractSocket* socket) while (_bufferSize > _bufferPos && socket->bytesAvailable() > 0) { const qint64 ret = socket->read(_buffer + _bufferPos, _bufferSize - _bufferPos); //qDebug() << "Read " << ret << " bytes"; - if (ret < 0) { + if (ret < 0 || ret > (_bufferSize - _bufferPos)) { qDebug("Socket read failed (TCP), return code %d", (int)ret); return NM_READ_FAILED; } - _bufferPos += ret; + _bufferPos += (quint32)ret; //qDebug() << "Buffer has now " << _bufferPos << " of " << _bufferSize << " bytes"; } if (_bufferSize == _bufferPos) { @@ -200,9 +200,9 @@ bool NetworkMessage::writeMessage(QAbstractSocket * const socket) const qint64 ret = socket->write(_buffer + _bufferPos, _bufferSize - _bufferPos); if (ret == 0) return true; - if (ret < 0) + if (ret < 0 || ret > (_bufferSize - _bufferPos)) return false; - _bufferPos += ret; + _bufferPos += (quint32)ret; if (_bufferPos == _bufferSize) { _bufferPos = 0; _mode = 4; diff --git a/src/shared/networkmessage.h b/src/shared/networkmessage.h index 290e3b5..c072070 100644 --- a/src/shared/networkmessage.h +++ b/src/shared/networkmessage.h @@ -67,9 +67,9 @@ public: bool writeMessage(QAbstractSocket * const socket); bool writeMessage(QUdpSocket* socket, const QHostAddress& address, quint16 port); void reset() { _fields.clear(); _bufferSize = 0; _mode = 0; } - const bool readComplete() const { return _mode == 3; } - const bool writeComplete() const { return _mode == 4; } - const bool hasField(const QByteArray& key) const { return _fields.contains(key); } + bool readComplete() { return _mode == 3; } + bool writeComplete() { return _mode == 4; } + bool hasField(QByteArray& key) { return _fields.contains(key); } const QString getFieldString(const QByteArray& key) const { return QString::fromUtf8(_fields.value(key)); } const QByteArray getFieldBytes(const QByteArray& key) const { return _fields.value(key); } void setField(const QByteArray& key, const QByteArray& value) { if (_mode == 1 || _mode == 2) qFatal("setField called in bad state."); _fields.insert(key, value); _mode = 0; } |