This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gokdriveclient. commit 9bc85850eab23eca6510c9de3e6baf9fdf2d0bba Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Thu Jan 21 12:59:27 2021 -0600 use zlib library to decompress compressed strings instead of built in QT function. --- client.cpp | 38 +++++++++++++++++++++++++++++++------- client.h | 1 + debian/changelog | 1 + debian/control | 1 + x2gokdriveclient.pro | 2 ++ xcbclip.cpp | 7 +------ 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/client.cpp b/client.cpp index 370b104..7deb0bb 100644 --- a/client.cpp +++ b/client.cpp @@ -57,6 +57,7 @@ #include <xcbclip.h> #endif +#include <zlib.h> X2GoCursor::X2GoCursor(uint16_t width, uint16_t height, uint16_t xhot, uint16_t yhot, uint32_t serialNumber, uint32_t dataSize) { @@ -869,6 +870,34 @@ void Client::getSelectionBuffer() } +QByteArray Client::zuncompress(const char* data, uint compressed_size, uint size) +{ + unsigned char* out=new unsigned char [size]; + + z_stream stream; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + + stream.avail_in = compressed_size; + stream.next_in = (unsigned char*)data; + stream.avail_out = size; + stream.next_out = out; + + inflateInit(&stream); + inflate(&stream, Z_NO_FLUSH); + inflateEnd(&stream); + + if(!stream.total_out || stream.total_out != size) + { + qDebug()<<"zlib decompression error, "<<"output size: "<<stream.total_out<<", expected: "<<size; + } + QByteArray ba( (const char*)out, size); + delete[] out; + return ba; +} + + #ifndef Q_OS_LINUX void Client::setInputSelectionData(SelectionType, SelectionMime mime, bool firstChunk, bool lastChunk, uint32_t compressed, uint size, char* data, bool notify) { @@ -888,14 +917,9 @@ void Client::setInputSelectionData(SelectionType, SelectionMime mime, bool first selData.append(data,size); else { - QByteArray ba; - ba.append((char*) &size, 4); - ba.append(data, compressed); - total_compressed+=compressed; - - selData.append(qUncompress(ba)); - // qDebug()<<"uncompress from "<<compressed<<" to "<<size; + inputSelection[selection].selData.append(Client::zuncompress(data, compressed, size)); +// qDebug()<<"uncompress from "<<compressed<<" to "<<size; } if(lastChunk ) diff --git a/client.h b/client.h index a947653..f830905 100644 --- a/client.h +++ b/client.h @@ -170,6 +170,7 @@ public: void requestSelectionFromServer(SelectionType sel); void send_selnotify_to_server(SelectionType selection, SelectionMime mime); int max_chunk(); + static QByteArray zuncompress(const char* data, uint compressed_size, uint size); public slots: void sendOutputSelChunk(); diff --git a/debian/changelog b/debian/changelog index 05d71ff..c8362cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,5 +27,6 @@ x2gokdriveclient (0.0.0.1-0x2go1) UNRELEASED; urgency=medium - give server some time for initialization before sending version. - support sending and recieving selections on demand. Support reading and writing INCR properties. - include xcb/xproto.h header + - use zlib library to decompress compressed strings instead of built in QT function. -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Tue, 04 Jun 2019 11:10:43 +0200 diff --git a/debian/control b/debian/control index 80c4090..5a7ef64 100644 --- a/debian/control +++ b/debian/control @@ -14,6 +14,7 @@ Build-Depends: libqt5x11extras5-dev, libxcb1-dev, libxcb-xfixes0-dev, + zlib1g-dev Standards-Version: 4.3.0 Homepage: https://code.x2go.org/releases/source/x2gokdriveclient Vcs-Git: git://code.x2go.org/x2gokdriveclient.git diff --git a/x2gokdriveclient.pro b/x2gokdriveclient.pro index 32f89a5..e106f41 100644 --- a/x2gokdriveclient.pro +++ b/x2gokdriveclient.pro @@ -27,3 +27,5 @@ linux { SOURCES += xcbclip.cpp HEADERS += xcbclip.h } + +LIBS += -lz diff --git a/xcbclip.cpp b/xcbclip.cpp index 34cf6c2..c5a9c51 100644 --- a/xcbclip.cpp +++ b/xcbclip.cpp @@ -805,13 +805,8 @@ void XCBClip::setInputSelectionData(SelectionType selection, SelectionMime mime, inputSelection[selection].selData.append(data,size); else { - QByteArray ba; - ba.append((char*) &size, 4); - ba.append(data, compressed); - total_compressed+=compressed; - - inputSelection[selection].selData.append(qUncompress(ba)); + inputSelection[selection].selData.append(Client::zuncompress(data, compressed, size)); // qDebug()<<"uncompress from "<<compressed<<" to "<<size; } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git