summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-26 16:11:31 +0200
committerSimon Rettberg2018-07-26 16:11:31 +0200
commit0d1984357f9bc8aac671e8907208a8581a1f42db (patch)
tree09dd65975ff5e5074fdbc708504ab1d84b073c2b /src/client
parent[server] Cleanup and simplify SslServer (diff)
downloadpvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.tar.gz
pvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.tar.xz
pvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.zip
[*] Convert old C-Style casts
Primitive types now use type(x) instead of (type)x, pointers should use appropriate long versions
Diffstat (limited to 'src/client')
-rw-r--r--src/client/main.cpp2
-rw-r--r--src/client/net/serverconnection.cpp6
-rw-r--r--src/client/net/serverdiscovery.cpp14
-rw-r--r--src/client/vnc/vncthread.cpp8
4 files changed, 17 insertions, 13 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 61ca0e9..eefd0d8 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -9,7 +9,7 @@ int main(int argc, char** argv)
{
ClientApp app(argc, argv);
- qsrand((uint)QDateTime::currentMSecsSinceEpoch());
+ qsrand(uint(QDateTime::currentMSecsSinceEpoch()));
/* here we handle the arguments that were not handled by ClientApp */
for (QString a : app.arguments()) {
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp
index 6350418..ca19c76 100644
--- a/src/client/net/serverconnection.cpp
+++ b/src/client/net/serverconnection.cpp
@@ -33,7 +33,7 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons
SLOT(sslErrors(const QList<QSslError> &))
);
connect(_socket, &QSslSocket::peerVerifyError, [=](const QSslError &error) { qDebug() << "PVE:" << error.errorString(); });
- qDebug("Connecting to %s on port %d", host.toUtf8().data(), (int)port);
+ qDebug("Connecting to %s on port %d", host.toUtf8().data(), int(port));
_socket->ignoreSslErrors();
_socket->connectToHostEncrypted(host, port);
_timerId = startTimer(4000);
@@ -112,7 +112,7 @@ void ServerConnection::handleMsg()
emit stateChange(ConnectWindow::AwaitingChallengeResponse);
_myChallenge.resize(CHALLENGE_LEN);
for (int i = 0; i < CHALLENGE_LEN; ++i) {
- _myChallenge[i] = (char)(qrand() & 0xff);
+ _myChallenge[i] = char(qrand() & 0xff);
}
QByteArray serverChallenge(_fromServer.getFieldBytes(_CHALLENGE));
_toServer.reset();
@@ -407,7 +407,7 @@ void ServerConnection::sock_closed()
void ServerConnection::sock_error(QAbstractSocket::SocketError errcode)
{
- qDebug("Connection error: %d", (int)errcode);
+ qDebug("Connection error: %d", int(errcode));
this->disconnectFromServer();
}
diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp
index 799fcbe..1b29398 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) {
- quint16 port = (quint16)(16384 + qrand() % 32768);
+ quint16 port = quint16(16384 + qrand() % 32768);
if (_discoverySocket.bind(QHostAddress::AnyIPv4, 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] = (char)(qrand() & 0xff);
- _salt2[i] = (char)(qrand() & 0xff);
+ salt1[i] = char(qrand() & 0xff);
+ _salt2[i] = char(qrand() & 0xff);
}
_packet.reset();
_packet.setField(_HASH, genSha1(&_nameBytes, &salt1, &iplist));
@@ -154,7 +154,7 @@ void ServerDiscovery::onUdpReadyRead()
continue;
_packet.reset();
- if (_packet.readMessage(data, (quint32)size) != NM_READ_OK)
+ if (_packet.readMessage(data, quint32(size)) != NM_READ_OK)
continue;
// Valid packet, process it:
@@ -183,7 +183,11 @@ void ServerDiscovery::onUdpReadyRead()
<< addr.toString() + ":" + QString::fromUtf8(port) + "/" + _nameBytes;
// Tell that a server hs been found
- emit serverDetected(addr.toString(), (quint16)QString::fromUtf8(port).toInt(), _nameBytes, cert, (_mgrIP == addr));
+ bool ok = false;
+ const ushort iport = QString::fromUtf8(port).toUShort(&ok);
+ if (ok) {
+ emit serverDetected(addr.toString(), quint16(iport), _nameBytes, cert, (_mgrIP == addr));
+ }
// Stop the discovery
this->stop();
diff --git a/src/client/vnc/vncthread.cpp b/src/client/vnc/vncthread.cpp
index e399e9b..1a903d5 100644
--- a/src/client/vnc/vncthread.cpp
+++ b/src/client/vnc/vncthread.cpp
@@ -89,7 +89,7 @@ void VncThread::run()
_client->frameBuffer = nullptr;
// save this instance in vnc-struct for callbacks
- rfbClientSetClientData(_client, 0, this);
+ rfbClientSetClientData(_client, nullptr, this);
// start client
if (rfbInitClient(_client, nullptr, nullptr)) {
@@ -172,7 +172,7 @@ void VncThread::emitStarted()
*/
char* VncThread::passwdHandler(rfbClient *client)
{
- VncThread* t = (VncThread*)rfbClientGetClientData(client, 0);
+ VncThread* t = reinterpret_cast<VncThread*>(rfbClientGetClientData(client, nullptr));
return strdup(t->_passwd.toUtf8());
}
@@ -185,7 +185,7 @@ char* VncThread::passwdHandler(rfbClient *client)
*/
rfbBool VncThread::frameBufferHandler(rfbClient *client)
{
- VncThread *t = (VncThread*)rfbClientGetClientData(client, 0);
+ VncThread *t = reinterpret_cast<VncThread*>(rfbClientGetClientData(client, nullptr));
const int width = client->width, height = client->height, depth = 32;
const int size = width * height * (depth / 8);
qDebug("[%s] Remote desktop: %ix%ix%i", t->metaObject()->className(), width, height, depth);
@@ -201,7 +201,7 @@ rfbBool VncThread::frameBufferHandler(rfbClient *client)
::exit(1);
}
client->frameBuffer = t->_img->bits();
- memset(client->frameBuffer, '\0', (size_t)size);
+ memset(client->frameBuffer, '\0', size_t(size));
client->format.trueColour = 1;
client->format.bitsPerPixel = depth;
client->format.redShift = 16;