summaryrefslogtreecommitdiffstats
path: root/src/client/vnc/vncthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/vnc/vncthread.cpp')
-rw-r--r--src/client/vnc/vncthread.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/client/vnc/vncthread.cpp b/src/client/vnc/vncthread.cpp
index 1a903d5..0e98cfe 100644
--- a/src/client/vnc/vncthread.cpp
+++ b/src/client/vnc/vncthread.cpp
@@ -17,8 +17,10 @@
*/
#include "vncthread.h"
-#include <QPainter>
+#include "../../shared/util.h"
+#include <QPainter>
+#include <utility>
#include <netinet/tcp.h>
/**
@@ -29,15 +31,15 @@
* @param passwd The password of the VNC server
* @param quality The desired quality level for the VNC stream
*/
-VncThread::VncThread(QString host, int port, QString passwd, int quality) :
- QThread(), _run(true), _started(false)
+VncThread::VncThread(QString host, int port, QString passwd, int quality)
+ : QThread()
+ , _host(std::move(host))
+ , _port(port)
+ , _passwd(std::move(passwd))
+ , _quality(quality)
+ , _run(true)
+ , _started(false)
{
- _host = host;
- _port = port;
- _passwd = passwd;
- _quality = quality;
- _client = nullptr;
- _connected = false;
moveToThread(this);
}
@@ -74,7 +76,7 @@ void VncThread::run()
// setup network
for (int retry = 0; retry < 5 && _run; ++retry) {
- this->msleep(1 + qrand() % 60);
+ msleep(1 + slxrand() % 60);
if (!_run)
break;
_client = rfbGetClient(8, 3, 4);
@@ -100,7 +102,7 @@ void VncThread::run()
if (!_run)
break;
// error, let's try again
- this->msleep(10 + qrand() % 50);
+ msleep(10 + slxrand() % 50);
}
if (_client != nullptr) {
qDebug("[%s] Connection successful!", metaObject()->className());
@@ -125,7 +127,7 @@ void VncThread::run()
_connected = false;
emit projectionStopped();
while (_run)
- this->msleep(100);
+ msleep(100);
qDebug("[%s] VNC client stopped.", metaObject()->className());
}
@@ -134,10 +136,10 @@ void VncThread::run()
*
* @return Name of the remote desktop
*/
-const QString VncThread::getDesktopName() const
+QString VncThread::getDesktopName() const
{
if (_client == nullptr || _client->desktopName == nullptr)
- return QString();
+ return {};
return QString(_client->desktopName);
}
@@ -172,7 +174,7 @@ void VncThread::emitStarted()
*/
char* VncThread::passwdHandler(rfbClient *client)
{
- VncThread* t = reinterpret_cast<VncThread*>(rfbClientGetClientData(client, nullptr));
+ auto* t = reinterpret_cast<VncThread*>(rfbClientGetClientData(client, nullptr));
return strdup(t->_passwd.toUtf8());
}
@@ -185,7 +187,7 @@ char* VncThread::passwdHandler(rfbClient *client)
*/
rfbBool VncThread::frameBufferHandler(rfbClient *client)
{
- VncThread *t = reinterpret_cast<VncThread*>(rfbClientGetClientData(client, nullptr));
+ auto *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);
@@ -196,8 +198,8 @@ rfbBool VncThread::frameBufferHandler(rfbClient *client)
}
t->_img = QSharedPointer<QImage>(new QImage(width, height, QImage::Format_RGB32));
- if (size > t->_img->byteCount()) {
- qDebug() << "Fatal: Created image too small:" << t->_img->byteCount() << "<" << size;
+ if (size > t->_img->sizeInBytes()) {
+ qDebug() << "Fatal: Created image too small:" << t->_img->sizeInBytes() << "<" << size;
::exit(1);
}
client->frameBuffer = t->_img->bits();
@@ -260,6 +262,6 @@ rfbBool VncThread::frameBufferHandler(rfbClient *client)
*/
void VncThread::updateImage(rfbClient* client, int x, int y, int w, int h)
{
- VncThread* t = (VncThread*)rfbClientGetClientData(client, 0);
+ auto* t = (VncThread*)rfbClientGetClientData(client, 0);
t->processImageUpdate(x, y, w, h);
}