From e354df7172efbe25e94f1c6ae5516912dad1d114 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 20 Jul 2018 15:41:45 +0200 Subject: [server] Resize thumbs server side on mismatch The server requests the appropriate size thumbnail from the client so no bandwidth will be wasted. However, due to privacy concerns, the client might actually send a thumb that's smaller than requested, resulting in a tiny thumbnail on the server with huge gray borders. The server will now scale up the image in those cases. We'd actually also scale the image down now if it were too large, but this doesn't happen under normal circumstances. --- src/server/net/client.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/server/net/client.cpp') diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 0dd8783..c11cb63 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -104,7 +104,7 @@ void Client::removeAttentionInternal() } /******************************************************************************/ -void Client::requestThumb(const int width, const int height) +void Client::requestThumb(const QSize& size) { if (_socket->state() != QAbstractSocket::ConnectedState) { qDebug("requestThumb called in bad state"); @@ -112,8 +112,8 @@ void Client::requestThumb(const int width, const int height) } NetworkMessage msgTmb; msgTmb.setField(_ID, _THUMB); - msgTmb.setField(_X, QString::number(width)); - msgTmb.setField(_Y, QString::number(height)); + msgTmb.setField(_X, QString::number(size.width())); + msgTmb.setField(_Y, QString::number(size.height())); msgTmb.writeMessage(_socket); } @@ -154,16 +154,15 @@ void Client::handleMsg() if (_authed == 2) { // Following messages are only valid of the client is already authenticated if (id == _THUMB) { - QPixmap pixmap; - const QByteArray& rawImage = _fromClient.getFieldBytes("IMG"); + QImage image; + _rawRemoteScreen = _fromClient.getFieldBytes("IMG"); /* size 0 means the client is in exam-mode and therefore doesn't send any thumbnail */ - if (rawImage.size() > 0) { - if (!pixmap.loadFromData(rawImage)) { + if (_rawRemoteScreen.size() > 0) { + if (!image.loadFromData(_rawRemoteScreen)) { qDebug("Could not decode thumbnail image from client."); return; } - _rawRemoteScreen = QByteArray(rawImage); - emit thumbUpdated(this, pixmap, rawImage); + emit thumbUpdated(this, image); } } else if (id == _VNCSERVER) { // Client tells about startup of vnc server -- cgit v1.2.3-55-g7522