Fixed build on windows

This commit is contained in:
Albert Vaca 2016-06-09 02:36:02 +02:00
parent e2c89794d9
commit 3177143439
5 changed files with 18 additions and 55 deletions

View file

@ -23,10 +23,12 @@
#include <core/core_debug.h> #include <core/core_debug.h>
#ifndef Q_OS_WIN
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#endif
#include "lanlinkprovider.h" #include "lanlinkprovider.h"

View file

@ -421,10 +421,6 @@ void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink)
void LanLinkProvider::configureSocket(QSslSocket* socket) void LanLinkProvider::configureSocket(QSslSocket* socket)
{ {
int fd = socket->socketDescriptor();
socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1));
// Setting supported ciphers manually // Setting supported ciphers manually
// Top 3 ciphers are for new Android devices, botton two are for old Android devices // 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 // 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->setLocalCertificate(KdeConnectConfig::instance()->certificate());
socket->setPrivateKey(KdeConnectConfig::instance()->privateKeyPath()); socket->setPrivateKey(KdeConnectConfig::instance()->privateKeyPath());
socket->setSocketOption(QAbstractSocket::KeepAliveOption, QVariant(1));
#ifdef TCP_KEEPIDLE #ifdef TCP_KEEPIDLE
// time to start sending keepalive packets (seconds) // time to start sending keepalive packets (seconds)
int maxIdle = 10; int maxIdle = 10;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle)); setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle));
#endif #endif
#ifdef TCP_KEEPINTVL #ifdef TCP_KEEPINTVL
// interval between keepalive packets after the initial period (seconds) // interval between keepalive packets after the initial period (seconds)
int interval = 5; int interval = 5;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)); setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
#endif #endif
#ifdef TCP_KEEPCNT #ifdef TCP_KEEPCNT
// number of missed keepalive packets before disconnecting // number of missed keepalive packets before disconnecting
int count = 3; int count = 3;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count)); setsockopt(socket->socketDescriptor(), IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count));
#endif #endif
} }

View file

@ -20,17 +20,19 @@
#include "core_debug.h" #include "core_debug.h"
#include <execinfo.h> #ifdef Q_OS_LINUX
#include <stdlib.h>
#include <execinfo.h> #include <execinfo.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#endif
void logBacktrace() void logBacktrace()
{ {
#ifdef Q_OS_LINUX
void *array[32]; void *array[32];
size_t size = backtrace (array, 32); size_t size = backtrace (array, 32);
char **strings = backtrace_symbols (array, size); char **strings = backtrace_symbols (array, size);
backtrace_symbols_fd(array, size, STDERR_FILENO); backtrace_symbols_fd(array, size, STDERR_FILENO);
free (strings); free (strings);
#endif
} }

View file

@ -7,7 +7,7 @@ include_directories(
) )
set(kdeconnect_libraries set(kdeconnect_libraries
kdeconnectcore kdeconnectcore
KF5::I18n KF5::I18n
KF5::KIOWidgets KF5::KIOWidgets
Qt5::DBus Qt5::DBus
@ -19,44 +19,12 @@ set(kdeconnect_libraries
ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries})
ecm_add_test(sendfiletest.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(networkpackagetests.cpp LINK_LIBRARIES ${kdeconnect_libraries})
ecm_add_test(testsocketlinereader.cpp TEST_NAME testsocketlinereader 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}) ecm_add_test(testsslsocketlinereader.cpp TEST_NAME testsslsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries})
ecm_add_test(kdeconnectconfigtest.cpp TEST_NAME kdeconnectconfigtest LINK_LIBRARIES ${kdeconnect_libraries})
set(testsslsocketlinereader_sources ecm_add_test(lanlinkprovidertest.cpp TEST_NAME lanlinkprovidertest LINK_LIBRARIES ${kdeconnect_libraries})
../core/backends/lan/server.cpp ecm_add_test(devicetest.cpp TEST_NAME devicetest LINK_LIBRARIES ${kdeconnect_libraries})
../core/backends/lan/socketlinereader.cpp ecm_add_test(downloadjobtest.cpp TEST_NAME downloadjobtest LINK_LIBRARIES ${kdeconnect_libraries})
)
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(testnotificationlistener.cpp ecm_add_test(testnotificationlistener.cpp
../plugins/sendnotifications/sendnotificationsplugin.cpp ../plugins/sendnotifications/sendnotificationsplugin.cpp
../plugins/sendnotifications/notificationslistener.cpp ../plugins/sendnotifications/notificationslistener.cpp

View file

@ -25,13 +25,6 @@
#include <QtTest> #include <QtTest>
#include <QtCrypto> #include <QtCrypto>
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); QTEST_GUILESS_MAIN(NetworkPackageTests);
void NetworkPackageTests::initTestCase() void NetworkPackageTests::initTestCase()