diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c5a5d7..7bb6d7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,93 +1,95 @@ cmake_minimum_required(VERSION 3.0) # KDE Application Version, managed by release script set (KDE_APPLICATIONS_VERSION_MAJOR "19") set (KDE_APPLICATIONS_VERSION_MINOR "03") set (KDE_APPLICATIONS_VERSION_MICRO "70") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(krfb VERSION ${KDE_APPLICATIONS_VERSION}) set(QT_MIN_VERSION 5.6.0) set(KF5_MIN_VERSION 5.31.0) find_package(ECM ${KF5_MIN_VERSION} NO_MODULE REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMAddAppIcon) include(ECMSetupVersion) include(FeatureSummary) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core DBus Widgets X11Extras) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n Completion Config CoreAddons Crash DBusAddons DNSSD DocTools Notifications Wallet WidgetsAddons XmlGui ) find_package(X11 REQUIRED) find_package(XCB REQUIRED COMPONENTS XCB RENDER SHAPE XFIXES DAMAGE SHM IMAGE ) if(WIN32) set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES}) set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES}) endif(WIN32) add_definitions( -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050600 -DQT_USE_FAST_OPERATOR_PLUS + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_BYTEARRAY -DQT_STRICT_ITERATORS -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT ) include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ) find_package(LibVNCServer REQUIRED) ecm_setup_version(PROJECT VARIABLE_PREFIX KRFB VERSION_HEADER "krfb_version.h") include_directories ("${CMAKE_CURRENT_BINARY_DIR}/krfb" "${CMAKE_CURRENT_SOURCE_DIR}/krfb" "${CMAKE_CURRENT_SOURCE_DIR}/krfb/ui" ) if(Q_WS_X11) if(NOT X11_XTest_FOUND) message(FATAL_ERROR "krfb requires the libXtst (https://xorg.freedesktop.org) to be built") endif(NOT X11_XTest_FOUND) endif(Q_WS_X11) add_subdirectory(krfb) add_subdirectory(framebuffers) add_subdirectory(doc) add_subdirectory(icons) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/krfb/rfbclient.cpp b/krfb/rfbclient.cpp index 28775db..16cb764 100644 --- a/krfb/rfbclient.cpp +++ b/krfb/rfbclient.cpp @@ -1,230 +1,230 @@ /* Copyright (C) 2009-2010 Collabora Ltd @author George Goldberg @author George Kiagiadakis Copyright (C) 2007 Alessandro Praduroux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #include "rfbclient.h" #include "connectiondialog.h" #include "krfbconfig.h" #include "sockethelpers.h" #include "events.h" #include #include #include #include //for bzero() struct RfbClient::Private { Private(rfbClientPtr client) : controlEnabled(KrfbConfig::allowDesktopControl()), client(client) {} bool controlEnabled; rfbClientPtr client; QSocketNotifier *notifier; QString remoteAddressString; }; RfbClient::RfbClient(rfbClientPtr client, QObject* parent) : QObject(parent), d(new Private(client)) { d->remoteAddressString = peerAddress(d->client->sock) + ':' + QString::number(peerPort(d->client->sock)); d->notifier = new QSocketNotifier(client->sock, QSocketNotifier::Read, this); d->notifier->setEnabled(false); connect(d->notifier, &QSocketNotifier::activated, this, &RfbClient::onSocketActivated); } RfbClient::~RfbClient() { //qDebug(); delete d; } QString RfbClient::name() const { return d->remoteAddressString; } //static bool RfbClient::controlCanBeEnabled() { return KrfbConfig::allowDesktopControl(); } bool RfbClient::controlEnabled() const { return d->controlEnabled; } void RfbClient::setControlEnabled(bool enabled) { if (controlCanBeEnabled() && d->controlEnabled != enabled) { d->controlEnabled = enabled; Q_EMIT controlEnabledChanged(enabled); } } bool RfbClient::isOnHold() const { return d->client->onHold ? true : false; } void RfbClient::setOnHold(bool onHold) { if (isOnHold() != onHold) { d->client->onHold = onHold; d->notifier->setEnabled(!onHold); Q_EMIT holdStatusChanged(onHold); } } void RfbClient::closeConnection() { d->notifier->setEnabled(false); rfbCloseClient(d->client); rfbClientConnectionGone(d->client); } rfbClientPtr RfbClient::getRfbClientPtr() { return d->client; } void RfbClient::handleKeyboardEvent(bool down, rfbKeySym keySym) { if (d->controlEnabled) { EventHandler::handleKeyboard(down, keySym); } } void RfbClient::handleMouseEvent(int buttonMask, int x, int y) { if (d->controlEnabled) { EventHandler::handlePointer(buttonMask, x, y); } } void RfbClient::onSocketActivated() { //Process not only one, but all pending messages. //poll() idea/code copied from vino: // Copyright (C) 2003 Sun Microsystems, Inc. // License: GPL v2 or later struct pollfd pollfd = { d->client->sock, POLLIN|POLLPRI, 0 }; while(poll(&pollfd, 1, 0) == 1) { rfbProcessClientMessage(d->client); //This is how we handle disconnection. //if rfbProcessClientMessage() finds out that it can't read the socket, //it closes it and sets it to -1. So, we just have to check this here //and call rfbClientConnectionGone() if necessary. This will call //the clientGoneHook which in turn will remove this RfbClient instance //from the server manager and will call deleteLater() to delete it if (d->client->sock == -1) { //qDebug() << "disconnected from socket signal"; d->notifier->setEnabled(false); rfbClientConnectionGone(d->client); break; } } } void RfbClient::update() { rfbUpdateClient(d->client); //This is how we handle disconnection. //if rfbUpdateClient() finds out that it can't write to the socket, //it closes it and sets it to -1. So, we just have to check this here //and call rfbClientConnectionGone() if necessary. This will call //the clientGoneHook which in turn will remove this RfbClient instance //from the server manager and will call deleteLater() to delete it if (d->client->sock == -1) { //qDebug() << "disconnected during update"; d->notifier->setEnabled(false); rfbClientConnectionGone(d->client); } } //************* PendingRfbClient::PendingRfbClient(rfbClientPtr client, QObject *parent) : QObject(parent), m_rfbClient(client) { m_rfbClient->clientData = this; } PendingRfbClient::~PendingRfbClient() {} void PendingRfbClient::accept(RfbClient *newClient) { //qDebug() << "accepted connection"; m_rfbClient->clientData = newClient; newClient->setOnHold(false); Q_EMIT finished(newClient); deleteLater(); } static void clientGoneHookNoop(rfbClientPtr cl) { Q_UNUSED(cl); } void PendingRfbClient::reject() { //qDebug() << "refused connection"; //override the clientGoneHook that was previously set by RfbServer m_rfbClient->clientGoneHook = clientGoneHookNoop; rfbCloseClient(m_rfbClient); rfbClientConnectionGone(m_rfbClient); Q_EMIT finished(nullptr); deleteLater(); } bool PendingRfbClient::checkPassword(const QByteArray & encryptedPassword) { Q_UNUSED(encryptedPassword); return m_rfbClient->screen->authPasswdData == (void*)nullptr; } bool PendingRfbClient::vncAuthCheckPassword(const QByteArray& password, const QByteArray& encryptedPassword) const { if (password.isEmpty() && encryptedPassword.isEmpty()) { return true; } char passwd[MAXPWLEN]; unsigned char challenge[CHALLENGESIZE]; memcpy(challenge, m_rfbClient->authChallenge, CHALLENGESIZE); bzero(passwd, MAXPWLEN); if (!password.isEmpty()) { - strncpy(passwd, password, + strncpy(passwd, password.constData(), (MAXPWLEN <= password.size()) ? MAXPWLEN : password.size()); } rfbEncryptBytes(challenge, passwd); - return memcmp(challenge, encryptedPassword, encryptedPassword.size()) == 0; + return memcmp(challenge, encryptedPassword.constData(), encryptedPassword.size()) == 0; }