X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompressor.cpp;h=816f26c8519784b3ea147acf5fd11ef360753473;hp=1d2233ac896c5363255c1476cb937184a2b3a360;hb=6eefdfc697067d184a589fc8a231b16316c09106;hpb=f64d4eec4bba63ececdece95f5c73b0ac550acd4 diff --git a/src/common/compressor.cpp b/src/common/compressor.cpp index 1d2233ac..816f26c8 100644 --- a/src/common/compressor.cpp +++ b/src/common/compressor.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,13 +23,6 @@ #include #include -#ifdef HAVE_ZLIB -# include -#else -# define MINIZ_HEADER_FILE_ONLY -# include "../../3rdparty/miniz/miniz.c" -#endif - const int maxBufferSize = 64 * 1024 * 1024; // protect us from zip bombs const int ioBufferSize = 64 * 1024; // chunk size for inflate/deflate; should not be too large as we preallocate that space! @@ -37,10 +30,10 @@ Compressor::Compressor(QTcpSocket *socket, Compressor::CompressionLevel level, Q : QObject(parent), _socket(socket), _level(level), - _inflater(0), - _deflater(0) + _inflater(nullptr), + _deflater(nullptr) { - connect(socket, SIGNAL(readyRead()), SLOT(readData())); + connect(socket, &QIODevice::readyRead, this, &Compressor::readData); bool ok = true; if (level != NoCompression) @@ -48,14 +41,14 @@ Compressor::Compressor(QTcpSocket *socket, Compressor::CompressionLevel level, Q if (!ok) { // something went wrong during initialization... but we can only emit an error after RemotePeer has connected its signal - QTimer::singleShot(0, this, SIGNAL(error())); + QTimer::singleShot(0, this, [this]() { emit error(); }); return; } // It's possible that more data has already arrived during the handshake, so readyRead() wouldn't be triggered. // However, we want to give RemotePeer a chance to connect to our signals, so trigger this asynchronously. if (socket->bytesAvailable()) - QTimer::singleShot(0, this, SLOT(readData())); + QTimer::singleShot(0, this, &Compressor::readData); } @@ -97,7 +90,7 @@ bool Compressor::initStreams() _deflater = new z_stream; memset(_deflater, 0, sizeof(z_stream)); if (Z_OK != deflateInit(_deflater, zlevel)) { - qWarning() << "Could not intialize the deflate stream!"; + qWarning() << "Could not initialize the deflate stream!"; return false; } @@ -133,7 +126,7 @@ qint64 Compressor::read(char *data, qint64 maxSize) // If there's still data left in the socket buffer, make sure to schedule a read if (_socket->bytesAvailable()) - QTimer::singleShot(0, this, SLOT(readData())); + QTimer::singleShot(0, this, &Compressor::readData); return n; } @@ -243,7 +236,7 @@ void Compressor::writeData() return; } - if (_deflater->avail_out == ioBufferSize) + if (_deflater->avail_out == static_cast(ioBufferSize)) continue; // nothing to write here if (!_socket->write(_outputBuffer.constData(), ioBufferSize - _deflater->avail_out)) {