Only fall back to miniz if we don't find zlib on the system. Distro
packagers like this much more, and we use code that has seen much
more testing. Incidentally, we've already had one case where miniz was
really slow on a 32 bit box.
Still keeping miniz as fallback for the rare platform/build box that
doesn't ship zlib, since waiting a few seconds for compressing the
backlog is still probably better than transmitting a few MB of extra
data...
endif(QT_LRELEASE_EXECUTABLE)
endif(QT_LRELEASE_EXECUTABLE)
+# zlib for compression, however we can always fall back to miniz
+find_package(ZLIB)
+if(ZLIB_FOUND)
+ message(STATUS "Using system zlib for compression")
+ add_definitions(-DHAVE_ZLIB)
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${ZLIB_LIBRARIES})
+else()
+ message(STATUS "zlib NOT found, using bundled miniz for compression")
+ if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+ message(STATUS "WARNING: This may be slow on 32 bit systems!")
+ endif()
+endif()
+
+
# Execinfo is needed for generating backtraces
find_package(ExecInfo)
if(EXECINFO_FOUND)
# Execinfo is needed for generating backtraces
find_package(ExecInfo)
if(EXECINFO_FOUND)
if(STATIC)
link_directories(${QT_PLUGINS_DIR}/imageformats)
if(STATIC)
link_directories(${QT_PLUGINS_DIR}/imageformats)
- set(CLIENT_LIBS ${CLIENT_LIBS} qjpeg qgif)
+ set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} qjpeg qgif)
endif(STATIC)
endif(BUILD_GUI)
endif(STATIC)
endif(BUILD_GUI)
set_target_properties(quasselcore PROPERTIES
COMPILE_FLAGS "-DBUILD_CORE ${QUASSEL_QT_COMPILEFLAGS}"
OUTPUT_NAME ../quasselcore)
set_target_properties(quasselcore PROPERTIES
COMPILE_FLAGS "-DBUILD_CORE ${QUASSEL_QT_COMPILEFLAGS}"
OUTPUT_NAME ../quasselcore)
- target_link_libraries(quasselcore mod_core mod_common
+ target_link_libraries(quasselcore mod_core mod_common ${COMMON_LIBRARIES}
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
install(TARGETS quasselcore RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_CORE)
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES})
install(TARGETS quasselcore RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_CORE)
set_target_properties(quasselclient PROPERTIES
COMPILE_FLAGS "-DBUILD_QTUI ${QUASSEL_QT_COMPILEFLAGS} ${CLIENT_COMPILE_FLAGS}"
OUTPUT_NAME ../quasselclient)
set_target_properties(quasselclient PROPERTIES
COMPILE_FLAGS "-DBUILD_QTUI ${QUASSEL_QT_COMPILEFLAGS} ${CLIENT_COMPILE_FLAGS}"
OUTPUT_NAME ../quasselclient)
- target_link_libraries(quasselclient ${LINK_KDE} mod_qtui mod_uisupport mod_client mod_common ${CLIENT_LIBS}
+ target_link_libraries(quasselclient ${LINK_KDE} mod_qtui mod_uisupport mod_client mod_common ${COMMON_LIBRARIES}
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${CLIENT_LIBRARIES})
install(TARGETS quasselclient RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_QTCLIENT)
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${CLIENT_LIBRARIES})
install(TARGETS quasselclient RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_QTCLIENT)
set_target_properties(quassel PROPERTIES
COMPILE_FLAGS "-DBUILD_MONO ${QUASSEL_QT_COMPILEFLAGS} ${CLIENT_COMPILE_FLAGS}"
OUTPUT_NAME ../quassel)
set_target_properties(quassel PROPERTIES
COMPILE_FLAGS "-DBUILD_MONO ${QUASSEL_QT_COMPILEFLAGS} ${CLIENT_COMPILE_FLAGS}"
OUTPUT_NAME ../quassel)
- target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${CLIENT_LIBS}
+ target_link_libraries(quassel mod_qtui mod_uisupport mod_client mod_core mod_common ${COMMON_LIBRARIES}
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${CLIENT_LIBRARIES})
install(TARGETS quassel RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_MONO)
${QUASSEL_QT_LIBRARIES} ${QUASSEL_SSL_LIBRARIES} ${CLIENT_LIBRARIES})
install(TARGETS quassel RUNTIME DESTINATION ${BIN_INSTALL_DIR})
endif(WANT_MONO)
protocols/datastream/datastreampeer.cpp
protocols/legacy/legacypeer.cpp
protocols/datastream/datastreampeer.cpp
protocols/legacy/legacypeer.cpp
-
- ../../3rdparty/miniz/miniz.c
set(HEADERS ${HEADERS} keyevent.h)
endif(HAVE_QCA2)
set(HEADERS ${HEADERS} keyevent.h)
endif(HAVE_QCA2)
+if(NOT HAVE_ZLIB)
+ set(SOURCES ${SOURCES} ../../3rdparty/miniz/miniz.c)
+endif(NOT HAVE_ZLIB)
+
if(APPLE)
set(SOURCES ${SOURCES} mac_utils.cpp)
set(HEADERS ${HEADERS} mac_utils.h)
if(APPLE)
set(SOURCES ${SOURCES} mac_utils.cpp)
set(HEADERS ${HEADERS} mac_utils.h)
#include <QTcpSocket>
#include <QTimer>
#include <QTcpSocket>
#include <QTimer>
-#define MINIZ_HEADER_FILE_ONLY
-#include "../../3rdparty/miniz/miniz.c"
+#ifdef HAVE_ZLIB
+# include <zlib.h>
+#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!
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!
_readBuffer.resize(_readBuffer.size() + ioBufferSize);
_inputBuffer.append(_socket->read(ioBufferSize - _inputBuffer.size()));
_readBuffer.resize(_readBuffer.size() + ioBufferSize);
_inputBuffer.append(_socket->read(ioBufferSize - _inputBuffer.size()));
- _inflater->next_in = reinterpret_cast<const unsigned char *>(_inputBuffer.constData());
+ _inflater->next_in = reinterpret_cast<unsigned char *>(_inputBuffer.data());
_inflater->avail_in = _inputBuffer.size();
_inflater->next_out = reinterpret_cast<unsigned char *>(_readBuffer.data() + _readBuffer.size() - ioBufferSize);
_inflater->avail_out = ioBufferSize;
_inflater->avail_in = _inputBuffer.size();
_inflater->next_out = reinterpret_cast<unsigned char *>(_readBuffer.data() + _readBuffer.size() - ioBufferSize);
_inflater->avail_out = ioBufferSize;
int status = inflate(_inflater, Z_SYNC_FLUSH); // get as much data as possible
// adjust input and output buffers
int status = inflate(_inflater, Z_SYNC_FLUSH); // get as much data as possible
// adjust input and output buffers
- _readBuffer.resize(_inflater->next_out - reinterpret_cast<const unsigned char *>(_readBuffer.constData()));
+ _readBuffer.resize(_inflater->next_out - reinterpret_cast<unsigned char *>(_readBuffer.data()));
if (_inflater->avail_in > 0)
memmove(_inputBuffer.data(), _inflater->next_in, _inflater->avail_in);
_inputBuffer.resize(_inflater->avail_in);
if (_inflater->avail_in > 0)
memmove(_inputBuffer.data(), _inflater->next_in, _inflater->avail_in);
_inputBuffer.resize(_inflater->avail_in);
- _deflater->next_in = reinterpret_cast<const unsigned char *>(_writeBuffer.constData());
+ _deflater->next_in = reinterpret_cast<unsigned char *>(_writeBuffer.data());
_deflater->avail_in = _writeBuffer.size();
int status;
_deflater->avail_in = _writeBuffer.size();
int status;
-typedef struct mz_stream_s *z_streamp;
+#ifdef HAVE_ZLIB
+ typedef struct z_stream_s *z_streamp;
+#else
+ typedef struct mz_stream_s *z_streamp;
+#endif
class Compressor : public QObject
{
class Compressor : public QObject
{