From 31771434390a0bc8d18149b2991be2bca317019e Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 9 Jun 2016 02:36:02 +0200 Subject: [PATCH] Fixed build on windows --- core/backends/lan/downloadjob.cpp | 2 ++ core/backends/lan/lanlinkprovider.cpp | 12 +++---- core/core_debug.cpp | 6 ++-- tests/CMakeLists.txt | 46 ++++----------------------- tests/networkpackagetests.cpp | 7 ---- 5 files changed, 18 insertions(+), 55 deletions(-) diff --git a/core/backends/lan/downloadjob.cpp b/core/backends/lan/downloadjob.cpp index 921d0b4ea..f23eb06ea 100644 --- a/core/backends/lan/downloadjob.cpp +++ b/core/backends/lan/downloadjob.cpp @@ -23,10 +23,12 @@ #include +#ifndef Q_OS_WIN #include #include #include #include +#endif #include "lanlinkprovider.h" diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 38afcca91..505b73a2a 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -421,10 +421,6 @@ void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink) void LanLinkProvider::configureSocket(QSslSocket* socket) { - int fd = socket->socketDescriptor(); - - socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1)); - // Setting supported ciphers manually // Top 3 ciphers are for new Android devices, botton two are for old Android devices // FIXME : These cipher suites should be checked whether they are supported or not on device @@ -444,22 +440,24 @@ void LanLinkProvider::configureSocket(QSslSocket* socket) socket->setLocalCertificate(KdeConnectConfig::instance()->certificate()); socket->setPrivateKey(KdeConnectConfig::instance()->privateKeyPath()); + socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1)); + #ifdef TCP_KEEPIDLE // time to start sending keepalive packets (seconds) int maxIdle = 10; - setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle)); + setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle)); #endif #ifdef TCP_KEEPINTVL // interval between keepalive packets after the initial period (seconds) int interval = 5; - setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)); + setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)); #endif #ifdef TCP_KEEPCNT // number of missed keepalive packets before disconnecting int count = 3; - setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count)); + setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count)); #endif } diff --git a/core/core_debug.cpp b/core/core_debug.cpp index 6fcf80742..7dbdc3740 100644 --- a/core/core_debug.cpp +++ b/core/core_debug.cpp @@ -20,17 +20,19 @@ #include "core_debug.h" -#include -#include +#ifdef Q_OS_LINUX #include #include #include +#endif void logBacktrace() { +#ifdef Q_OS_LINUX void *array[32]; size_t size = backtrace (array, 32); char **strings = backtrace_symbols (array, size); backtrace_symbols_fd(array, size, STDERR_FILENO); free (strings); +#endif } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6b6e66114..783228321 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,7 @@ include_directories( ) set(kdeconnect_libraries - kdeconnectcore + kdeconnectcore KF5::I18n KF5::KIOWidgets Qt5::DBus @@ -19,44 +19,12 @@ set(kdeconnect_libraries ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(sendfiletest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(networkpackagetests.cpp LINK_LIBRARIES ${kdeconnect_libraries}) - -ecm_add_test(testsocketlinereader.cpp ../core/backends/lan/socketlinereader.cpp ../core/backends/lan/server.cpp TEST_NAME testsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) - -set(testsslsocketlinereader_sources - ../core/backends/lan/server.cpp - ../core/backends/lan/socketlinereader.cpp -) -ecm_add_test(testsslsocketlinereader.cpp ${testsslsocketlinereader_sources} TEST_NAME testsslsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) - -set(kdeconnectconfigtest_sources - ../core/backends/devicelink.cpp - ../core/backends/pairinghandler.cpp - ../core/dbushelper.cpp - ../core/device.cpp - ../core/pluginloader.cpp -) -ecm_add_test(kdeconnectconfigtest.cpp ${kdeconnectconfigtest_sources} TEST_NAME kdeconnectconfigtest LINK_LIBRARIES ${kdeconnect_libraries}) - -set(lanlinkprovidertest_sources - ../core/backends/devicelink.cpp - ../core/backends/lan/downloadjob.cpp - ../core/backends/lan/landevicelink.cpp - ../core/backends/lan/lanlinkprovider.cpp - ../core/backends/lan/lanpairinghandler.cpp - ../core/backends/lan/server.cpp - ../core/backends/lan/socketlinereader.cpp - ../core/backends/lan/uploadjob.cpp - ../core/backends/linkprovider.cpp - ../core/backends/pairinghandler.cpp - ../core/device.cpp - ../core/pluginloader.cpp - ../core/core_debug.cpp -) -ecm_add_test(lanlinkprovidertest.cpp ${lanlinkprovidertest_sources} TEST_NAME lanlinkprovidertest LINK_LIBRARIES ${kdeconnect_libraries}) - -ecm_add_test(devicetest.cpp ${lanlinkprovidertest_sources} TEST_NAME devicetest LINK_LIBRARIES ${kdeconnect_libraries}) - -ecm_add_test(downloadjobtest.cpp ../core/backends/lan/downloadjob.cpp TEST_NAME downloadjobtest LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(testsocketlinereader.cpp TEST_NAME testsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(testsslsocketlinereader.cpp TEST_NAME testsslsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(kdeconnectconfigtest.cpp TEST_NAME kdeconnectconfigtest LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(lanlinkprovidertest.cpp TEST_NAME lanlinkprovidertest LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(devicetest.cpp TEST_NAME devicetest LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(downloadjobtest.cpp TEST_NAME downloadjobtest LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(testnotificationlistener.cpp ../plugins/sendnotifications/sendnotificationsplugin.cpp ../plugins/sendnotifications/notificationslistener.cpp diff --git a/tests/networkpackagetests.cpp b/tests/networkpackagetests.cpp index 8f8d283e2..815080f75 100644 --- a/tests/networkpackagetests.cpp +++ b/tests/networkpackagetests.cpp @@ -25,13 +25,6 @@ #include #include -static void initEnv() -{ - // Force LC_TIME=C to make sure longMonthName returns as en_US. - setenv("LC_TIME", "C", 1); -} -Q_CONSTRUCTOR_FUNCTION(initEnv) - QTEST_GUILESS_MAIN(NetworkPackageTests); void NetworkPackageTests::initTestCase()