diff --git a/local-test-freerdp-delta-01/afc-freerdp/CMakeCPack.cmake b/local-test-freerdp-delta-01/afc-freerdp/CMakeCPack.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d28454ff2b63eaf413c0231a471b123169bef94c --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/CMakeCPack.cmake @@ -0,0 +1,98 @@ +# Generate .txt license file for CPack (PackageMaker requires a file extension) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt @ONLY) + +# Workaround to remove c++ compiler macros and defines for Eclipse. +# If c++ macros/defines are set __cplusplus is also set which causes +# problems when compiling freerdp/jni. To prevent this problem we set the macros to "". + +if(ANDROID AND CMAKE_EXTRA_GENERATOR STREQUAL "Eclipse CDT4") + set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "") + message(STATUS "Disabled CXX system defines for eclipse (workaround).") +endif() + +set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;/\\\\.gitignore;/CMakeCache.txt") + +if(NOT WIN32) + if(APPLE AND (NOT IOS)) + + if(WITH_SERVER) + set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "mfreerdp-server") + endif() + endif() + + if(WITH_X11) + set(CPACK_PACKAGE_EXECUTABLES "xfreerdp") + + if(WITH_SERVER) + set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "xfreerdp-server") + endif() + endif() +endif() + +set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +set(CPACK_TOPLEVEL_TAG "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + +string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_lower) +set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}-${CPACK_SYSTEM_NAME}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}-${CPACK_SYSTEM_NAME}") + +set(CPACK_PACKAGE_NAME "FreeRDP") +set(CPACK_PACKAGE_VENDOR "FreeRDP") +set(CPACK_PACKAGE_VERSION ${FREERDP_VERSION_FULL}) +set(CPACK_PACKAGE_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${FREERDP_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${FREERDP_VERSION_REVISION}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FreeRDP: A Remote Desktop Protocol Implementation") + +set(CPACK_PACKAGE_CONTACT "Marc-Andre Moreau") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "marcandre.moreau@gmail.com") +set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) + +set(CPACK_PACKAGE_INSTALL_DIRECTORY "FreeRDP") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") + +set(CPACK_NSIS_MODIFY_PATH ON) +set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/resources\\\\FreeRDP_Install.bmp") +set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/resources\\\\FreeRDP_Icon_96px.ico") +set(CPACK_NSIS_MUI_UNICON "${PROJECT_SOURCE_DIR}/resource\\\\FreeRDP_Icon_96px.ico") + +set(CPACK_COMPONENTS_ALL client server libraries headers symbols tools) + +if(MSVC) + string(FIND ${CMAKE_MSVC_RUNTIME_LIBRARY} "DLL" IS_SHARED) + + if(NOT IS_SHARED STREQUAL "-1") + set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) + include(InstallRequiredSystemLibraries) + + install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries) + endif() +endif() + +set(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client") +set(CPACK_COMPONENT_CLIENT_GROUP "Applications") + +set(CPACK_COMPONENT_SERVER_DISPLAY_NAME "Server") +set(CPACK_COMPONENT_SERVER_GROUP "Applications") + +set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_LIBRARIES_GROUP "Runtime") + +set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Headers") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") + +set(CPACK_COMPONENT_SYMBOLS_DISPLAY_NAME "Symbols") +set(CPACK_COMPONENT_SYMBOLS_GROUP "Development") + +set(CPACK_COMPONENT_TOOLS_DISPLAY_NAME "Tools") +set(CPACK_COMPONENT_TOOLS_GROUP "Applications") + +set(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Runtime") +set(CPACK_COMPONENT_GROUP_APPLICATIONS_DESCRIPTION "Applications") +set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Development") + +configure_file("${PROJECT_SOURCE_DIR}/CMakeCPackOptions.cmake.in" "${PROJECT_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) +set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CMakeCPackOptions.cmake") + +include(CPack) diff --git a/local-test-freerdp-delta-01/afc-freerdp/CMakeCPackOptions.cmake.in b/local-test-freerdp-delta-01/afc-freerdp/CMakeCPackOptions.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..826eaa10d46c2af5bca7348f8643f6995f803c13 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/CMakeCPackOptions.cmake.in @@ -0,0 +1,10 @@ +# This file is configured at cmake time, and loaded at cpack time. +# To pass variables to cpack from cmake, they must be configured in this file. + +if("${CPACK_GENERATOR}" STREQUAL "PackageMaker") + if(CMAKE_PACKAGE_QTGUI) + set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications") + else() + set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr") + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..af4b3cef3b82d4e47a849413f35d58cd56b84611 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/CMakeLists.txt @@ -0,0 +1,600 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 HP Development Company, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.13) + +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() +project(FreeRDP LANGUAGES C) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS ON) + +add_custom_target(fuzzers COMMENT "Build fuzzers") + +if(NOT DEFINED VENDOR) + set(VENDOR "FreeRDP" CACHE STRING "FreeRDP package vendor") +endif() + +if(NOT DEFINED PRODUCT) + set(PRODUCT "FreeRDP" CACHE STRING "FreeRDP package name") +endif() + +if(NOT DEFINED FREERDP_VENDOR) + set(FREERDP_VENDOR 1) +endif() + +if(NOT WIN32 AND NOT ANDROID) + if(APPLE) + set(OPT_DEFAULT_VAL OFF) + else() + set(OPT_DEFAULT_VAL ON) + endif() + option(WITH_X11 "build X11 client/server" ${OPT_DEFAULT_VAL}) +endif() + +# Enable coverity related pragma definitions +if(COVERITY_BUILD) + add_compile_definitions(COVERITY_BUILD) +endif() + +# Include our extra modules +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/) + +# Check for cmake compatibility (enable/disable features) +include(CheckCmakeCompat) + +# Include cmake modules +if(WITH_CLANG_FORMAT) + include(ClangFormat) +endif() + +include(CompilerFlags) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckStructHasMember) +include(TestBigEndian) +include(CompilerDetect) + +include(FindFeature) +include(ShowCMakeVars) +include(ConfigOptions) +include(FeatureSummary) +include(CheckCCompilerFlag) +include(CMakePackageConfigHelpers) +include(InstallFreeRDPMan) +include(GetGitRevisionDescription) +include(SetFreeRDPCMakeInstallDir) +include(Doxygen) + +# Soname versioning +set(BUILD_NUMBER 0) +if($ENV{BUILD_NUMBER}) + set(BUILD_NUMBER $ENV{BUILD_NUMBER}) +endif() + +set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)") +set(RAW_VERSION_STRING "3.11.2-dev0") +if(EXISTS "${PROJECT_SOURCE_DIR}/.source_tag") + file(READ ${PROJECT_SOURCE_DIR}/.source_tag RAW_VERSION_STRING) +elseif(USE_VERSION_FROM_GIT_TAG) + git_get_exact_tag(_GIT_TAG --tags --always) + if(NOT ${_GIT_TAG} STREQUAL "n/a") + string(REGEX MATCH ${VERSION_REGEX} FOUND_TAG "${_GIT_TAG}") + if(FOUND_TAG) + set(RAW_VERSION_STRING ${_GIT_TAG}) + endif() + endif() +endif() +string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING) + +string(REGEX REPLACE "${VERSION_REGEX}" "\\2" FREERDP_VERSION_MAJOR "${RAW_VERSION_STRING}") +string(REGEX REPLACE "${VERSION_REGEX}" "\\3" FREERDP_VERSION_MINOR "${RAW_VERSION_STRING}") +string(REGEX REPLACE "${VERSION_REGEX}" "\\4" FREERDP_VERSION_REVISION "${RAW_VERSION_STRING}") +string(REGEX REPLACE "${VERSION_REGEX}" "\\5" FREERDP_VERSION_SUFFIX "${RAW_VERSION_STRING}") + +set(FREERDP_API_VERSION "${FREERDP_VERSION_MAJOR}") +set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}.${FREERDP_VERSION_REVISION}") +if(FREERDP_VERSION_SUFFIX) + set(FREERDP_VERSION_FULL "${FREERDP_VERSION}-${FREERDP_VERSION_SUFFIX}") +else() + set(FREERDP_VERSION_FULL "${FREERDP_VERSION}") +endif() +message("FREERDP_VERSION=${FREERDP_VERSION_FULL}") + +if(EXISTS "${PROJECT_SOURCE_DIR}/.source_version") + file(READ ${PROJECT_SOURCE_DIR}/.source_version GIT_REVISION) + + string(STRIP ${GIT_REVISION} GIT_REVISION) +elseif(USE_VERSION_FROM_GIT_TAG) + git_get_exact_tag(GIT_REVISION --tags --always) + + if(${GIT_REVISION} STREQUAL "n/a") + git_rev_parse(GIT_REVISION --short) + endif() +endif() + +if(NOT GIT_REVISION) + set(GIT_REVISION ${FREERDP_VERSION}) +endif() + +message(STATUS "Git Revision ${GIT_REVISION}") + +# MSVC compatibility with system headers +add_compile_definitions(NONAMELESSUNION) + +# Make the detected version available as default version for all subprojects +set(FREERDP_DEFAULT_PROJECT_VERSION ${FREERDP_VERSION} CACHE STRING INTERNAL) + +set(FREERDP_MAJOR_DIR "freerdp${FREERDP_VERSION_MAJOR}") +set(FREERDP_INCLUDE_DIR "include/${FREERDP_MAJOR_DIR}/") + +option(WITH_SMARTCARD_EMULATE "Emulate smartcards instead of redirecting readers" ON) +if(WITH_SMARTCARD_EMULATE) + add_compile_definitions(WITH_SMARTCARD_EMULATE) + find_package(ZLIB REQUIRED) +endif() + +option(WITH_FREERDP_DEPRECATED "Build FreeRDP deprecated symbols" OFF) +if(WITH_FREERDP_DEPRECATED) + add_compile_definitions(WITH_FREERDP_DEPRECATED) +endif() + +option(WITH_FREERDP_DEPRECATED_COMMANDLINE "Build FreeRDP deprecated command line options" OFF) +if(WITH_FREERDP_DEPRECATED_COMMANDLINE) + add_compile_definitions(WITH_FREERDP_DEPRECATED_COMMANDLINE) +endif() + +# Make paths absolute +if(CMAKE_INSTALL_PREFIX) + get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) +endif() +if(FREERDP_EXTERNAL_PATH) + get_filename_component(FREERDP_EXTERNAL_PATH "${FREERDP_EXTERNAL_PATH}" ABSOLUTE) +endif() + +# Allow to search the host machine for git/ccache +if(CMAKE_CROSSCOMPILING) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +endif(CMAKE_CROSSCOMPILING) + +find_program(CCACHE ccache) +if(CCACHE AND WITH_CCACHE) + if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE}) + endif(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER) +endif(CCACHE AND WITH_CCACHE) + +if(CMAKE_CROSSCOMPILING) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +endif(CMAKE_CROSSCOMPILING) +# /Allow to search the host machine for git/ccache + +# Turn on solution folders (2.8.4+) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +option(CTEST_OUTPUT_ON_FAILURE ON "show verbose output on CTest failures") +if(BUILD_TESTING_INTERNAL) + set(EXPORT_ALL_SYMBOLS ON CACHE BOOL "testing default" FORCE) + add_compile_definitions(BUILD_TESTING_INTERNAL) +elseif(BUILD_TESTING) + set(EXPORT_ALL_SYMBOLS OFF CACHE BOOL "testing default" FORCE) +endif() + +include(ExportAllSymbols) + +set(THREAD_PREFER_PTHREAD_FLAG TRUE) + +if(NOT IOS) + find_package(Threads REQUIRED) +endif() + +if(WIN32) + add_compile_definitions(UNICODE _UNICODE) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_definitions(WIN32_LEAN_AND_MEAN) + add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS) + + set(CMAKE_DL_LIBS "") + set(CMAKE_USE_RELATIVE_PATH ON) + string(TIMESTAMP RC_VERSION_YEAR "%Y") + + if(NOT DEFINED CMAKE_WINDOWS_VERSION) + set(CMAKE_WINDOWS_VERSION "WIN7") + endif() + + if(CMAKE_WINDOWS_VERSION STREQUAL "WINXP") + add_compile_definitions(WINVER=0x0501 _WIN32_WINNT=0x0501) + elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN7") + add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601) + elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN8") + add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602) + elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN10") + add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00) + endif() + + # Set product and vendor for dll and exe version information. + set(RC_VERSION_VENDOR ${VENDOR}) + set(RC_VERSION_PRODUCT ${PRODUCT}) + set(RC_VERSION_PATCH ${BUILD_NUMBER}) + set(RC_VERSION_DESCRIPTION + "${FREERDP_VERSION_FULL} ${GIT_REVISION} ${CMAKE_WINDOWS_VERSION} ${CMAKE_SYSTEM_PROCESSOR}" + ) + + if(FREERDP_EXTERNAL_SSL_PATH) + set(OPENSSL_ROOT_DIR ${FREERDP_EXTERNAL_SSL_PATH}) + endif() +endif() + +add_compile_definitions(FREERDP_EXPORTS) + +# Mac OS X +if(APPLE) + if(IOS) + if(NOT FREERDP_IOS_EXTERNAL_SSL_PATH) + message( + STATUS + "FREERDP_IOS_EXTERNAL_SSL_PATH not set! Required if openssl is not found in the iOS SDK (which usually isn't" + ) + endif() + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${FREERDP_IOS_EXTERNAL_SSL_PATH}) + set_property(GLOBAL PROPERTY XCODE_ATTRIBUTE_SKIP_INSTALL YES) + endif(IOS) + + # Temporarily disabled, causes the cmake script to be reexecuted, causing the compilation to fail. + # Workaround: specify the parameter in the command-line + # if(WITH_CLANG) + # set(CMAKE_C_COMPILER "clang") + # endif() + + if(WITH_VERBOSE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -v") + endif() +endif(APPLE) + +# Android +if(ANDROID) + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ANDROID_LIBRARY_USE_LIB64_PATHS}) + + if(ANDROID_ABI STREQUAL arm64-v8a) + include(CheckCCompilerFlag) + check_c_compiler_flag("-mfloat-abi=softfp" ABI_SOFTFP_SUPPORTED) + + if(ABI_SOFTFP_SUPPORTED) + # https://github.com/android/ndk/issues/910 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + endif() + endif() + + add_compile_definitions("$<$:NDK_DEBUG=1>") + + # NOTE: Manually add -gdwarf-3, as newer toolchains default to -gdwarf-4, + # which is not supported by the gdbserver binary shipped with + # the android NDK (tested with r9b) + add_compile_options("$<$:-gdwarf-3>") + add_link_options(-llog) + + # CMAKE_PREFIX_PATH detection is broken in most Android toolchain files + # Append it to CMAKE_FIND_ROOT_PATH and avoid potential duplicates + list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}) + list(REMOVE_DUPLICATES CMAKE_FIND_ROOT_PATH) + + if(NOT FREERDP_EXTERNAL_PATH) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external/") + set(FREERDP_EXTERNAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/") + else() + message(STATUS "FREERDP_EXTERNAL_PATH not set!") + endif() + endif() + + list(APPEND CMAKE_INCLUDE_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/include) + list(APPEND CMAKE_LIBRARY_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + + if(WITH_GPROF) + configure_file( + ${PROJECT_SOURCE_DIR}/scripts/gprof_generate.sh.in ${PROJECT_BINARY_DIR}/scripts/gprof_generate.sh @ONLY + ) + endif(WITH_GPROF) +endif() + +if(UNIX OR CYGWIN) + set(WAYLAND_FEATURE_TYPE "RECOMMENDED") +else() + set(WAYLAND_FEATURE_TYPE "DISABLED") +endif() + +if(WITH_PCSC_WINPR) + find_package(PCSCWinPR) +endif() + +set(WAYLAND_FEATURE_PURPOSE "Wayland") +set(WAYLAND_FEATURE_DESCRIPTION "Wayland client") + +set(OPENSSL_FEATURE_TYPE "REQUIRED") +set(OPENSSL_FEATURE_PURPOSE "cryptography") +set(OPENSSL_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions") + +set(MBEDTLS_FEATURE_TYPE "OPTIONAL") +set(MBEDTLS_FEATURE_PURPOSE "cryptography") +set(MBEDTLS_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions") + +set(PCSC_FEATURE_TYPE "RECOMMENDED") +set(PCSC_FEATURE_PURPOSE "smart card") +set(PCSC_FEATURE_DESCRIPTION "smart card device redirection") + +set(OPENH264_FEATURE_TYPE "OPTIONAL") +set(OPENH264_FEATURE_PURPOSE "codec") +set(OPENH264_FEATURE_DESCRIPTION "use OpenH264 library") + +set(OPENCL_FEATURE_TYPE "OPTIONAL") +set(OPENCL_FEATURE_PURPOSE "codec") +set(OPENCL_FEATURE_DESCRIPTION "use OpenCL library") + +set(GSM_FEATURE_TYPE "OPTIONAL") +set(GSM_FEATURE_PURPOSE "codec") +set(GSM_FEATURE_DESCRIPTION "GSM audio codec library") + +set(LAME_FEATURE_TYPE "OPTIONAL") +set(LAME_FEATURE_PURPOSE "codec") +set(LAME_FEATURE_DESCRIPTION "lame MP3 audio codec library") + +set(FAAD2_FEATURE_TYPE "OPTIONAL") +set(FAAD2_FEATURE_PURPOSE "codec") +set(FAAD2_FEATURE_DESCRIPTION "FAAD2 AAC audio codec library") + +set(FAAC_FEATURE_TYPE "OPTIONAL") +set(FAAC_FEATURE_PURPOSE "codec") +set(FAAC_FEATURE_DESCRIPTION "FAAC AAC audio codec library") + +set(SOXR_FEATURE_TYPE "OPTIONAL") +set(SOXR_FEATURE_PURPOSE "codec") +set(SOXR_FEATURE_DESCRIPTION "SOX audio resample library") + +if(WIN32) + set(WAYLAND_FEATURE_TYPE "DISABLED") + set(PCSC_FEATURE_TYPE "DISABLED") +endif() + +if(APPLE) + set(WAYLAND_FEATURE_TYPE "DISABLED") + if(IOS) + set(PCSC_FEATURE_TYPE "DISABLED") + endif() +endif() + +if(ANDROID) + set(WAYLAND_FEATURE_TYPE "DISABLED") + set(PCSC_FEATURE_TYPE "DISABLED") +endif() + +find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION}) + +option(WITH_LIBRESSL "build with LibreSSL" OFF) +if(WITH_LIBRESSL) + find_package(LibreSSL REQUIRED) + include_directories(SYSTEM ${LibreSSL_INCLUDE_DIRS}) + set(OPENSSL_INCLUDE_DIR ${LIBRESSL_INCLUDE_DIR}) + set(OPENSSL_LIBRARIES ${LIBRESSL_LIBRARIES}) + set(OPENSSL_CRYPTO_LIBRARIES ${LIBRESSL_LIBRARIES}) + set(WITH_OPENSSL ON) + set(OPENSSL_FOUND ON) + add_compile_definitions("WITH_LIBRESSL") + add_compile_definitions("WITH_OPENSSL") +else() + find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION}) + find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION}) +endif() + +find_feature(PCSC ${PCSC_FEATURE_TYPE} ${PCSC_FEATURE_PURPOSE} ${PCSC_FEATURE_DESCRIPTION}) + +if(WITH_DSP_FFMPEG OR WITH_VIDEO_FFMPEG OR WITH_FFMPEG) + find_package(FFmpeg REQUIRED COMPONENTS AVUTIL AVCODEC) +endif() + +find_feature(OpenH264 ${OPENH264_FEATURE_TYPE} ${OPENH264_FEATURE_PURPOSE} ${OPENH264_FEATURE_DESCRIPTION}) +find_feature(OpenCL ${OPENCL_FEATURE_TYPE} ${OPENCL_FEATURE_PURPOSE} ${OPENCL_FEATURE_DESCRIPTION}) +find_feature(GSM ${GSM_FEATURE_TYPE} ${GSM_FEATURE_PURPOSE} ${GSM_FEATURE_DESCRIPTION}) +find_feature(LAME ${LAME_FEATURE_TYPE} ${LAME_FEATURE_PURPOSE} ${LAME_FEATURE_DESCRIPTION}) +find_feature(FAAD2 ${FAAD2_FEATURE_TYPE} ${FAAD2_FEATURE_PURPOSE} ${FAAD2_FEATURE_DESCRIPTION}) +find_feature(FAAC ${FAAC_FEATURE_TYPE} ${FAAC_FEATURE_PURPOSE} ${FAAC_FEATURE_DESCRIPTION}) +find_feature(soxr ${SOXR_FEATURE_TYPE} ${SOXR_FEATURE_PURPOSE} ${SOXR_FEATURE_DESCRIPTION}) + +if(WITH_OPENH264 AND NOT WITH_OPENH264_LOADING) + option(WITH_OPENH264_LOADING "Use LoadLibrary to load openh264 at runtime" OFF) +endif(WITH_OPENH264 AND NOT WITH_OPENH264_LOADING) + +# Version check, if we have detected FFMPEG but the version is too old +# deactivate it as sound backend. +if(WITH_DSP_FFMPEG) + if(AVCODEC_VERSION VERSION_LESS "57.48.101") + message( + WARNING + "FFmpeg version detected (${AVCODEC_VERSION}) is too old. (Require at least 57.48.101 for sound). Deactivating" + ) + set(WITH_DSP_FFMPEG OFF) + endif() +endif(WITH_DSP_FFMPEG) + +if(WITH_OPENH264 AND NOT OPENH264_FOUND) + message(FATAL_ERROR "OpenH264 support requested but not detected") +endif() +set(WITH_OPENH264 ${OPENH264_FOUND}) + +if(OPENSSL_FOUND) + add_compile_definitions("WITH_OPENSSL") + message(STATUS "Using OpenSSL Version: ${OPENSSL_VERSION}") + include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) +endif() + +if(MBEDTLS_FOUND) + add_compile_definitions("WITH_MBEDTLS") +endif() + +if(WITH_OPENH264 OR WITH_MEDIA_FOUNDATION OR WITH_VIDEO_FFMPEG OR WITH_MEDIACODEC) + set(WITH_GFX_H264 ON) +else() + set(WITH_GFX_H264 OFF) +endif() + +# Android expects all libraries to be loadable +# without paths. +if(ANDROID OR WIN32 OR MAC_BUNDLE) + set(PLUGIN_ABS_PATHS_DEFAULT OFF) +else() + set(PLUGIN_ABS_PATHS_DEFAULT ON) +endif() +option(WITH_ABSOLUTE_PLUGIN_LOAD_PATHS "Load plugins with absolute paths" ${PLUGIN_ABS_PATHS_DEFAULT}) + +if(NOT WITH_ABSOLUTE_PLUGIN_LOAD_PATHS) + set(FREERDP_DATA_PATH "share") + if(NOT FREERDP_INSTALL_PREFIX) + set(FREERDP_INSTALL_PREFIX ".") + endif() + set(FREERDP_LIBRARY_PATH ".") + set(FREERDP_PLUGIN_PATH ".") +else() + set(FREERDP_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/${FREERDP_MAJOR_DIR}") + if(NOT FREERDP_INSTALL_PREFIX) + set(FREERDP_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + endif() + set(FREERDP_LIBRARY_PATH "${CMAKE_INSTALL_LIBDIR}") + if(WIN32) + set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_BINDIR}/${FREERDP_MAJOR_DIR}") + else() + set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/${FREERDP_MAJOR_DIR}") + endif() +endif() +set(FREERDP_ADDIN_PATH "${FREERDP_PLUGIN_PATH}") + +# Path to put extensions +set(FREERDP_EXTENSION_POSTFIX "${FREERDP_MAJOR_DIR}/extensions") +set(FREERDP_EXTENSION_REL_PATH "${CMAKE_INSTALL_LIBDIR}/${FREERDP_EXTENSION_POSTFIX}") +set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${FREERDP_EXTENSION_POSTFIX}") + +# Proxy plugins path +if(NOT DEFINED PROXY_PLUGINDIR) + message("using default plugins location") + set(FREERDP_PROXY_PLUGINDIR "${FREERDP_PLUGIN_PATH}/proxy/") +else() + set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}") +endif() + +# Unit Tests + +include(CTest) + +if(BUILD_TESTING_INTERNAL OR BUILD_TESTING) + enable_testing() + + if(MSVC) + set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + else() + set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing") + endif() +endif() + +include(CommonConfigOptions) + +if(FREERDP_UNIFIED_BUILD) + add_subdirectory(winpr) + if(WITH_WAYLAND) + add_subdirectory(uwac) + endif() + if(WITH_SERVER) + option(WITH_RDTK "build rdtk toolkit" ON) + if(WITH_RDTK) + add_subdirectory(rdtk) + endif() + endif() + + include_directories(${PROJECT_SOURCE_DIR}/winpr/include) + include_directories(${PROJECT_BINARY_DIR}/winpr/include) +else() + find_package(WinPR 3 REQUIRED) + include_directories(SYSTEM ${WinPR_INCLUDE_DIR}) +endif() + +option(WITH_AAD "Compile with support for Azure AD authentication" ${WITH_WINPR_JSON}) + +# Include directories +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) + +# Sub-directories + +if(WITH_THIRD_PARTY) + add_subdirectory(third-party) + if(NOT "${THIRD_PARTY_INCLUDES}" STREQUAL "") + include_directories(SYSTEM ${THIRD_PARTY_INCLUDES}) + endif() +endif() + +add_subdirectory(libfreerdp) + +if(WITH_CHANNELS) + add_subdirectory(channels) +endif() + +if(WITH_CLIENT_COMMON OR WITH_CLIENT) + add_subdirectory(client) +endif() + +if(WITH_SERVER) + add_subdirectory(server) +endif() + +# Packaging + +set(CMAKE_CPACK_INCLUDE_FILE "CMakeCPack.cmake") + +if(NOT (VENDOR MATCHES "FreeRDP")) + if(DEFINED CLIENT_VENDOR_PATH) + if(EXISTS "${PROJECT_SOURCE_DIR}/${CLIENT_VENDOR_PATH}/CMakeCPack.cmake") + set(CMAKE_CPACK_INCLUDE_FILE "${CLIENT_VENDOR_PATH}/CMakeCPack.cmake") + endif() + endif() +endif() + +#message("VENDOR: ${VENDOR} CLIENT_VENDOR_PATH: ${CLIENT_VENDOR_PATH} CMAKE_CPACK_INCLUDE_FILE: ${CMAKE_CPACK_INCLUDE_FILE}") + +set(FREERDP_BUILD_CONFIG_LIST "") +get_cmake_property(res VARIABLES) +foreach(var ${res}) + if(var MATCHES "^WITH_*|^BUILD_TESTING*|^WINPR_HAVE_*") + list(APPEND FREERDP_BUILD_CONFIG_LIST "${var}=${${var}}") + endif() +endforeach() +string(REPLACE ";" " " FREERDP_BUILD_CONFIG "${FREERDP_BUILD_CONFIG_LIST}") + +add_subdirectory(include) + +include(${CMAKE_CPACK_INCLUDE_FILE}) + +message(STATUS "Intrinsic path configuration:") +#ShowCMakeVars("^CMAKE_INSTALL_PREFIX") +#ShowCMakeVars("^CMAKE_INSTALL_LIBDIR") +showcmakevars("^FREERDP_INSTALL_PREFIX|^FREERDP_LIBRARY_PATH|^FREERDP_PLUGIN_PATH") +showcmakevars("^FREERDP_ADDIN_PATH|^FREERDP_EXTENSION_PATH|^FREERDP_PROXY_PLUGINDIR") diff --git a/local-test-freerdp-delta-01/afc-freerdp/ChangeLog b/local-test-freerdp-delta-01/afc-freerdp/ChangeLog new file mode 100644 index 0000000000000000000000000000000000000000..8766a4ab862ebd63aae610885b2c5cd801bc9683 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/ChangeLog @@ -0,0 +1,622 @@ +# 2025-02-07 Version 3.11.1 + +A bugfix release addressing two regressions reported against 3.11.0 + +Noteworthy changes: + * Fix a segfault when passing /pth (#11138) + * Fix a regression in planar codec (#11136) + +For a complete and detailed change log since the last release run: +git log 3.11.1...3.11.0 + +# 2025-02-06 Version 3.11.0 + +A new release with bugfixes and code cleanups as well as a few nifty little +features that will improve your meetings. + +Noteworthy changes: + * Updated android client to more recent gradle (#11105, #11110) + * Fix cmake clean target (#109 + * SDL3 bugfixes and API updates (#11092, #11093, #11128) + * Fix keyboard mapping, add working japanese and korean types, deprecate + obsolete functions (#10989, #11035, #11011, #11074, #11037) + * Fix timezone mapping and iteration (#11077, #11079, #11080, #11083) + * Fix YUV reverse filter for AVC444 modes (#11045, #11063, #11066, #11081, #11086, + #11087) + * Fix H.264 encoder wrapper issues (#11117, #11121, #11078) + * MS-RDPECAM: Support for H.264 encoding with VA-API (#10887) + * Fix various CMake, build script and github workflow issues (#10992, #10996, + #11020, #11031, #11030, #11062, #11064, #11069, #11073, #11123, #11109, + #11120, #11053, #11089) + * [codec,planar] fix decoder regression (#11033) + * [client,cmdline] fix vmconnect checks (#11051) + * Fix multi-monitor related checks (#11095) + * Fix various compiler and clang-tidy warnings (#10953, #11003, #11004, + #11007, #11016, #11018, #11019, #11021, #11017, #11000, #11023, #11024, + #11026, #11002, #11028, #11001, #11029, #10999, #11006, #11034, #10998, + #11044, #11050, #11052, #11057, #11059, #11065, #11067, #11068, #11060, + #11071, #11085, #11088, #11099, #11102, #11108, #11124, #11126, #11129, + #11130) + +New Contributors + * @chewi made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11004 + * @gpotter2 made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11016 + * @vmpn made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11092 + +For a complete and detailed change log since the last release run: +git log 3.11.0...3.10.3 + + +# 2024-12-17 Version 3.10.3 + +Follow up release to 3.10.2, as we've discovered a few bugs after release. + +Noteworthy changes: + * Fix usage of GetComputerNameExA (#10988) + * Fix cmake clean target (#10990) + +For a complete and detailed change log since the last release run: +git log 3.10.3...3.10.2 + +# 2024-12-16 Version 3.10.2 + +Follow up release to 3.10.1, as we've discovered a few bugs during release +tests. + +Noteworthy changes: + * Fix initializing ComputerName setting (#10985) + * Fix some warnings and possible leaks (#10985) + +For a complete and detailed change log since the last release run: +git log 3.10.2...3.10.1 + +# 2024-12-16 Version 3.10.1 + +We're happy to present a new release of FreeRDP. +This release contains a few fixes for bugs revealed by checks introduced +with 3.10.0 + +Noteworthy Changes: + * Add FreeBSD as architecture build to our ci (#10980 and others) + * Fix empty include directory creation (#10981) + * fix SIMD detection (#10968) + * improve settings unit test coverage (#10966) + * fix sending server redirection PDU (#10963) + * fix return and use of GetComputerNameA (#10962) + +For a complete and detailed change log since the last release run: +git log 3.10.1...3.10.0 + +# 2024-12-12 Version 3.10.0 + +We're happy to present a new release of FreeRDP. +This one contains some more code cleanups (we've addressed lots of clang-tidy +warnings) as well as some highly anticipated new features and bugfixes. + +So, what is new: +* Enforce use of a supported build type (#10777) +* Enable FDK-AAC support for nightly packages (#10875, #10781) +* Better AAD/AVD support (#10796) +* Build system updates (#10844) +* Enforce spell checking (#10881) +* Split unit tests so a subset can be run during package build (#10776) +* We're shipping a .desktop file now (#10465) +* Build scripts for nightly packages (#10835, #10783) + +Noteworthy changes: +* Fix wStream API bugs (#10885) +* Autoreconnect fixes (#10915) +* Fix monitor layout checks (#10905) +* Enforce code formatting for CMake files (#10895) +* Enable SIMD optimizations by default (#10894) +* WinPR types not based on stdint.h et al (#10754) +* Improve code assertions (#10768) +* Code cleanups (#10763, #10914) + +For a complete and detailed change log since the last release run: +git log 3.10.0...3.9.0 + + +# 2024-10-21 Version 3.9.0 + +We're proud to present the newest release of FreeRDP. +This one brings some major code cleanup (we've addressed lots of clang-tidy +warnings) as well as some highly anticipated new features. +We also did update the API documentation quite a bit (still incomplete though, +help always welcome ;)) + +So, what is new: +* Support for RDPEAR (remote credential guard) /remoteGuard option for non windows clients +* Global configuration file support, allowing to configure certificate + accept/ignore/... default settings for all users +* Simplified manpage generation, eliminates docbook and xmlto dependencies + speeding up builds +* New API for client channels to run tasks on RDP thread +* New extended transport layer API +* RDPECAM MJPEG support +* the first updates of timezone definitions from our automated ci + +Noteworthy changes: +* Fix bugs in SSE4.1/AVX2 image copy (#10720) +* Add warnings for invalid monitor settings during connect (#10672) +* Fix ALSA microphone support (#10664) +* Fix modal windows in RAILS mode (#10629) +* Update experimental SDL3 client (SDL3 API should now have been stabilized, + various pull requests) +* Fix keyboard layouts, the external JSON did miss a few (#10639) + +For a complete and detailed change log since the last release run: +git log 3.9.0...3.8.0 + +# 2024-08-30 Version 3.8.0 + +This is a bugfix release. Due to additional exports required by a bugfix the minor version was incremented + +Noteworthy changes: +* Reduce number of warnings on CI build (make dependency includes SYSTEM) (#10509) +* Fix possible crashes with P11 certificate parsing (#10462, #10463) +* Various clipboard related fixes (#10472, #10476, #10477, #10480, #10484) +* Fix a race condition on DesktopResize (xfreerdp) (#10488) +* Improve certificate warnings (#10489) +* Try all possible resolved IP addresses for a DNS name on connect (#10491) +* Fix an issue with GFX SolidFill alpha data (#10498) +* Various fixes for SDL clients (#10504, #10492, #10471) +* Fix serial and parallel redirection crashes (#10510) +* Fix android build issues with NDK 27 (#10529) +* Improve performance of some WinPR primitives (#10528) +* Fix an issue with autoreconnect (#10523) +* Support ssh-askpass like password reading (#10516) +* Lots of code cleanups to reduce clang-tidy warnings (#10531, #10525, #10521, #10520, #10519, #10518) + +For a complete and detailed change log since the last release run: +git log 3.8.0...3.7.0 + +# 2024-08-08 Version 3.7.0 + +This release has accumulated quite a number of changes. Along bugfixes for 3.6.3 it also +contains a number of improvements for distributors: + +* Support for FDK-AAC for sound and microphone redirection (activate with -DWITH_FDK_AAC=ON build option) + This allows enabling the AAC compression that do not ship faad2 and/or faac +* Support keyboard layouts as JSON resources (activate with -DWITH_KEYBOARD_LAYOUT_FROM_FILE=ON build option, + also requires JSON support) + This allows editing keyboard layouts for existing releases should the need arise +* Support timezones as JSON resources (activate with -DWITH_TIMEZONE_FROM_FILE=ON -DWITH_TIMEZONE_COMPILED=OFF build options, + also requires JSON support) + Allows reading the mapping between IANA and windows timezones from a JSON file, allowing easier updates without recompile +* Improve shadow server compatibility with windows 11 24H2 RDP client + Windows 7 RFX and bitmap updates with multiple rectangles have been deactivated, so adjust shadow to not send such. + +Noteworthy changes: +* Fix ActionScript parameter (#10423) +* Support keyboard layouts as JSON resource (#10394) +* Support timezones as JSON resource and command line argument (#10428 #10393 #10391) +* Deactivate AsyncUpdate (#10402) +* Compatibility fixes for shadow with windows 11 24H2 (#10455 #10422 #10420 #10416) +* Fix SDL client autoreconnect (#10390) +* Fix xfreerdp clipboard locking (#10385) +* Improve logging (#10426 #10441) +* Improve warnings and code checks (#10381 #10401 #10403 #10405 #10406 #10410 #10421 #10454) +* Support FDK-AAC (#10372) +* Fix drive redirection state transitions (#10367 #10374) +* Support mth:// routing token (#10366) +* Ignore unsupported SetThreadPriority (#10363) +* Fix reported documentation and code typos (#10365 #10368 #10370 #10369 #10431 #10446) + +For a complete and detailed change log since the last release run: +git log 3.7.0...3.6.3 + +# 2024-07-08 Version 3.6.3 + +Bugfix release for 3.6.2 issues reported + +Noteworthy changes: +* fix a graphics regression (#10352) +* workaround for a protocol bug of older FreeRDP based servers (#10358) +* fix possible NULL dereference in command line parser (#10348) +* fix intrinsics detection (#10346, #10350) + +For a complete and detailed change log since the last release run: +git log 3.6.3...3.6.2 + + +# 2024-07-04 Version 3.6.2 + +Bugfix release for 3.6.1 issues detected during release tests + +Noteworthy changes: +* Fix xfreerdp and sdl-freerdp manpage names (accidentally changed name) +* Fix crash of wfreerdp + +For a complete and detailed change log since the last release run: +git log 3.6.2...3.6.1 + + +# 2024-07-04 Version 3.6.1 + +Bugfix release for 3.6.0 + +Noteworthy changes: +* Fix missing dependency for ci abi-checker +* Fix build WITH_SSE2/WITH_NEON: only enable support if the compiler + also defines symbols that suggest support. +* Fix incomplete changelog for 3.6.0: + * Improved image copy (#10208) + * Experimental [MS-RDPECAM] support by @oleg0421 (#10258) + * Improved primitives (#10304) + * Connection timeout for HTTP gateway transport (#10288) + +For a complete and detailed change log since the last release run: +git log 3.6.1...3.6.0 + + +# 2024-07-03 Version 3.6.0 + +With this release we did improve decoder speed so you should notice a significant +speed improvement with progressive and other gfx codecs. +We've also eliminated a couple of issues along the way, so an update +is highly recommended. + +Noteworthy changes: +* Improved command line failure logging (#10333) +* p11-kit support (#10081) +* json-c support (#10183) +* (experimental) SDL3 port SDL client (#10195) +* New option '/gfx:frame-ack:off' for connection delay testing (#10214) +* improved decoder speed (#10222, #10235) +* xfreerdp floatbar hide bug (#10237) +* winpr-makecert month bug (#10236) +* kerberos kdcUrl check fixes (#10238) +* timezone updates (#10120, #10144, #10170) +* fixed a capability protocol violation bug (#10132) +* fix SDL client dialog bug terminating on credential dialog (#10134) +* some more oss-fuzz issues (#10126, #10141, #10148, #10161, #10239) +* rails popup window fixes (#10160) + + +For a complete and detailed change log since the last release run: +git log 3.6.0...3.5.1 + + +# 2024-04-22 Version 3.5.1 + +This release eliminates a bunch of issues detected during oss-fuzz runs. +The test coverage was increased and detected issues eliminates, so an update +is highly recommended. + +Noteworthy changes: +* Lots of fixes for oss-fuzz reports +* Timezone detection fixes (#10106) +* SDL key remapping support (#10103) +* Improved help (#10099) +* FreeBSD epoll detection fix (#10097) + +For a complete and detailed change log since the last release run: +git log 3.5.1...3.5.0 + +# 2024-04-16 Version 3.5.0 + +This release focus is on squashing bugs. +The improved test coverage and ci builds revealed a number of previously +unnoticed issues we have addressed and we also got a report from +Evgeny Legerov of Kaspersky Lab identifying a number of out of bound reads +in decoder components and one very nasty out of bound write. + +CVE: +CVE-2024-32041 [Low[ OutOfBound Read in zgfx_decompress_segment +CVE-2024-32039 [Moderate] Integer overflow & OutOfBound Write in clear_decompress_residual_data +CVE-2024-32040 [Low] integer underflow in nsc_rle_decode +CVE-2024-32458 [Low] OutOfBound Read in planar_skip_plane_rle +CVE-2024-32459 [Low] OutOfBound Read in ncrush_decompress +CVE-2024-32460 [Low] OutOfBound Read in interleaved_decompress + +Noteworthy changes: +* location channel support #9981, #9984, #10065 +* bugfixes for report from Evgeny Legerov of Kaspersky Lab #10077 +* fuzzer tests from Evgeny Legerov of Kaspersky Lab #10078 +* bugfixes for coverty scanner #10066, #10068, #10069, #10070, #10075 +* clipboard and generic locking fixes #10076 +* split autoreconnect support from enabling it #10063 +* various nightly and workflow fixes #10064, #10058, #10062 +* always set wm-class to app_id #10051 +* refactored and simplified CMake #10046, #10047 +* fix relative mouse event sending #10010 +* improve and unify check for APIs used (POSIX, win32, mac, ...) #9995 +* fix termination for gateway connections #9985 +* fix drivestoredirect RDP file setting, ignore invalid #9989 +* drop IPP support #10038 + +For a complete and detailed change log since the last release run: +git log 3.5.0...3.4.0 + +# 2024-03-14 Version 3.4.0 + +This release concentrates on improving test coverage and ci builds. +Some usability issues and inconvenient API functions were fixed on the way. + +New features have been introduced (stub for location channel) + +Noteworthy changes: +* fix a bug in RAIL mode not activating window focus (#9973) +* improve logging (#9969, #9943) +* OpenSSL <= 1.1.1 build fixes (#9897) +* improved help (#9899, #9905) +* improved MINGW support (#9914, #9915, #9919, #9964, #9965, #9920) +* fix right control ungrab for xfreerdp (#9960) +* fix RPATH option settings (#9963) +* fix SDL client screen updates (#9962, #9954) +* fix issues with childSession under windows (#9961, #9956, #9922) +* fix xfreerdp crash with +auth-only (#9947) +* fix windows printer channel (#9934) +* add support to enforce gateway policy (#9942) +* improve big endian support (#9927) +* ignore empty proxy environment variables (#9929) +* improve quoting support for command line (#9912) + +For a complete and detailed change log since the last release run: +git log 3.4.0...3.3.0 + + +# 2024-02-22 Version 3.3.0 + +This release concentrates on code cleanup and overall quality improvements. +Some usability issues and inconvenient API functions were fixed on the way. + +New features have been introduced (better image clipboard) but that stays +deactivated by default as we´re in a stable series. + +Check the new CMake options: +* PLUGIN_ABS_PATHS_DEFAULT disables loading of external channels from all + but a specified absolute plugin directory defined by FREERDP_PLUGIN_PATH +* WINPR_UTILS_IMAGE_PNG enables PNG support with libpng in winpr image/clipboard +* WITH_LODEPNG enables PNG support with lodepng library in winpr image/clipboard +* WINPR_UTILS_IMAGE_WEBP enables WEBP support in winpr image/clipboard +* WINPR_UTILS_IMAGE_JPEG enables JPEG support in winpr image/clipboard +* USE_EXECINFO enables or disables backtrace support with execinfo +* WITH_WEBVIEW now defaults to OFF on windows, apple and android (not implemented) + +Noteworthy changes: +* Improved image clipboard (xfreerdp, wlfreerdp) (#9873, #9826) +* Improved SDL client (#9875, #9887, #9883, #9878, #9792) +* Allow plugin loader to only use absolute paths (#9809) +* Improved TLS channel binding (#9838) +* Add GCC/clang attribute malloc wrapper WINPR_ATTR_MALLOC (#9863) +* Major clang-tidy code cleanups and bugfixes (#9799, #9834) +* Provide some defaults for wObject functions (#9799) +* Fix a bug in shadow with GFX breaking mstsc (#9818) +* Improved manpages and help (#9813, #9804) +* Blocking mode via transport IO interface (#9793) + +For a complete and detailed change log since the last release run: +git log 3.3.0...3.2.0 + +# 2024-01-19 Version 3.2.0 + +This release mostly addresses issues reported since the last release. +Fixing some usablity and build issues as well as adding API functions +that are needed from external projects + +Noteworthy changes: +* Fix proxy module load check (#9777) +* Improve kerberos error logging (#9771) +* Improve mac client keyboard handling (#9767) +* Add option to run client dynamic channel synchronous (#9764) +* Move huge struct to heap (#9763) +* Improved failure logging of license module (#9759) +* Improve server side gfx logging (#9757) +* Print shadow server help with printf instead of WLog (#9756) +* Fix SDL client timer initialization (#9754) +* Fix server peer message parsing (#9751) +* Enable NEON instructions if __ARM_NEON is defined (#9748) +* Add new proxy config file option TlsSecLevel (#9741) +* Improve android and mac os build scripts (#9735) +* Do not disable wayland support on BSD (#9730) +* Fix issues with assistance file parsing (#9727, #9728) +* Keyboard handling fixes for wayland client (#9725) +* Fix relative pkg-config file paths (#9720) +* Add new transport IO callback GetPublicKey (#9719) +* Fix wayland client scaling (#9715) + +For a complete and detailed change log since the last release run: +git log 3.2.0...3.1.0 + +# 2023-12-22 Version 3.1.0 + +A new 3.1.0 minor release for the new 3.0.0 series. +This contains bugfixes, adds (better) support for libressl and mbedtls and +brings a bunch of improvements for the SDL client. + +This comes with a price though, we now (optionally) require SDL_image if you +want to build the sdl-client + +Since there are multiple new features, some new files (man pages) and new +optional dependencies we´ve directly incremented the minor version. + +New CMake options: +* SDL_USE_COMPILED_RESOURCES (default ON) builds fonts and images into SDL + client. Set to OFF to install these resources as files. (was already part of + 3.0.0, but worth mentioning here) +* WITH_SDL_IMAGE_DIALOGS (default OFF) Show some nice icons for SDL client + connection dialogs. Requires SDL_image for build. +* WITH_BINARY_VERSIONING (default OFF) Similar as for libraries the binaries, + manpages and resource locations created by FreeRDP project are postfixed + with the API version. Recommended if packagers want to install the package + alongside FreeRDP 2 without conflicts. +* RDTK_FORCE_STATIC_BUILD (default OFF) Build and link RDTK statically into + shadow server. Recommended for packagers as this library is not really used + outside of FreeRDP-shadow. +* UWAC_FORCE_STATIC_BUILD (default OFF) Build and link UWAC statically into + wlfreerdp. Recommended for packagers as this library is not really used + outside of wlfreerdp. + +Noteworthy changes: +* Fix a nasty bug with relative mouse movement (#9677) +* LibreSSL support enhancements (#9691, #9670) +* mbedTLS support enhancements (#9662) +* Improve building on mac OS (#9641) +* New and improved manpages (#9690, #9650) +* Unify CMake common options, add (optional) binary versioning and allow + building rdtk and uwac as static dependencies (#9695) +* SDL client improvements (#9693, #9657, #9659, #9683, #9680, #9657, #9664, + #9656) + +For a complete and detailed change log since the last release run: +git log 3.1.0...3.0.0 + +# 2023-12-12 Version 3.0.0 + +Final 3.0.0 release just a little over two weeks after the last 3.0.0-rc0. +This contains bugfixes, drops some legacy code, implements a small feature +request and adds some improvements to the build system. + +Most notably is the new PreventInSourceBuilds.cmake which does exactly what +the name implies, it aborts builds where source equals build directory. +If you can not use out of source tree builds for some reason, you can +circumvent this measure with the CMake setting -DALLOW_IN_SOURCE_BUILD=ON + +Noteworthy changes: +* add support for AF_VSOCK #9561 +* xfreerdp drop X11 GDI implementation #9492 +* fixed connection freeze with childSession #9594 +* fixed relative mouse input issues #9608 +* fixed issues with drive redirection #9610 +* simplified mac build #9601 +* fixed TSMF to build again #9603 +* fixed command line /gfx parsing bug #9598 +* prevent in source tree build #9550 +* fixed various issues with settings #9595, #9596 +* add E2K cpu support in WinPR #9599 +* fixed wfreerdp DPI settings when used as embedded window #9593 +* android add mouse hover support #9495 + +For a complete and detailed change log since the last release run: +git log 3.0.0..3.0.0-rc0 + +# 2023-11-27 Version 3.0.0-rc0 + +Nearly 2 months of testing, bugfixing and API refinements later we´re +happy to announce the first release candidate for FreeRDP 3.0 +The API should now be considered stable and only minor changes (if at all) +will happen from this point on, so every project using FreeRDP can check +compatibility with upcoming 3.0 + +Noteworthy changes: +* Updated rdpSettings API #9465: + * getter/setter now use enum types for keys (generates compiler warnings for mismatch) + * Refined functions (added missing, dropped problematic ones) + * prepared opaque settings (direct struct access now deprecated) +* Server side [MS-RDPEL] channel #9471 +* Relative mouse movement support #9459 +* relocatable pkg-config files (enable with -DPKG_CONFIG_RELOCATABLE=ON, #9453) +* cliprdr dropped support for fuse2 (#9453) +* added support for uriparser for clipboard file:// parsing (#9455) +* aFreeRDP translation for traditional chinese (zh-rTW) added (#9450) +* fixed sdl-freerdp crash on credential dialog (#9455) +* fixed sdl-freerdp alt+tab in fullscreen (#9442) +* added /connect-child-session option (WIN32 only, #9427) +* fix rfx-image codec setup (#9425) +* added missing cmake configuration for winpr-tools (#9453) +* cleaned up cmake configuration files, dropped no longer required ones (#9455) +* fixed x11 keyboard layout detection (#9433) +* add missing API calls for server implementation (tested against ogon, #9453) +* keep dynamic channels in a hash table instead of a list (#9448) +* keep TSCredentials in server peer instance (#9430) +* fix FFMPEG/AAC encoding (#9576) +* support remote credential guard (#9574) +* fix printing on mac os 14 (#9569) +* improve RPC gateway support (#9508) +* add opus audio support for gnome-remote-desktop (#9575) +* server side handling of mouse cursor channel [MS-RDPEMSC] (#9513) + +For a complete and detailed change log since the last release run: +git log 3.0.0-rc0..3.0.0-beta4 + +# 2023-09-31 Version 3.0.0-beta4 + +Noteworthy changes: +* Improved and fixed AVD authentication, now allows retries for + machines just starting up +* Improve RDP file parser, prepare new fields used by AVD +* Fixed and improved pen support in multitouch implementation (xfreerdp) +* Lots of smaller code and leak cleanups + +For a complete and detailed change log since the last release run: +git log 3.0.0-beta4..3.0.0-beta3 + +# 2023-08-31 Version 3.0.0-beta3 + +Noteworthy changes: +* fix xfreerdp keyboard on mac os +* Various crashes and input check fixes +* Improved logging of autodetect, redirection and fastpath failures +* Smartcard emulation now selectable at runtime +* Allow certificates without a subject to pass client checks +* Fix FindFirstFile issues on android +* Add FREERDP_ENTRY_POINT to silence -Wmissing-prototypes warnings for + library entry points +* Add WINPR_RESTRICT to enable restrict (C99) or __restring (MSVC) + keywords for compiler +* Fix support for older OpenSSL versions + +For a complete and detailed change log since the last release run: +git log 3.0.0-beta3..3.0.0-beta2 + +# 2023-08-03 Version 3.0.0-beta2 + +Noteworthy changes: +* Update CMake defaults, now all features are enabled by default with a platform + independent option if multiple are available. +* SDL client: (basic) multimonitor support +* SDL client: fix dialog cleanup order (crash fix) +* clipboard: fix FUSE shutdown crash +* fixed drive redirection: FindNextFile did miss some files/directories +* improved AAD support: honor rdp file options +* improved (gateway) http failure logging +* improved shadow server error handling +* improved CMake configuration (using find_dependency) +* updated timezone definitions +* mbedTLS build fixed +* improved MINGW build support + +For a complete and detailed change log since the last release run: +git log 3.0.0-beta2..3.0.0-beta1 + +# 2023-07-21 Version 3.0.0-beta1 + +We are pleased to announce the first beta release for the next stable 3.0 +series of FreeRDP. It has been a huge endeavour to implement all the new +shiny bells and whistles as well as clean up the code base and we´re still +ironing out some smaller glitches. +This is the first API breaking change since the 2.0 series and there are +some adjustments to be made for existing applications. +See https://github.com/FreeRDP/FreeRDP/wiki/FreeRDP3-migration-notes for +help (still incomplete) + +Noteworthy changes: +* Support for AAD/AVD authentication +* Support for websocket transport +* Support smartcard authentication (TLS and NLA) +* Full smartcard emulation support (login with certificate + key) +* Rewritten proxy, new module API +* New reference client based on SDL2 (work in progress) +* Rewritten logging, now parsing issues are all writing to the log so + that issues with protocol incompatibilities can be easier analyzed + by just turning on logging +* Full OpenSSL 3 support +* Internal implementations for RC4, MD4 and MD5 (required for non critical + parts in RDP but not part of more recent SSL libraries) +* Updated RDP protocol support +* Improved xfreerdp remote app support +* Reworked internal state machine for both client and server implementations +* Server implementations can now make use of connect-time network autodetection +* Improved clipboard handling, now also support server-to-client file transfer + (currently xfreerdp only) +* EnhancedRemoteApp support: Utilizing the more modern standard allows remote + apps with less glitches and window shadows +* Added client- and server-side handling for RDSTLS +* Support for the graphics redirection channel + +For a complete and detailed change log since the last release run: +git log 3.0.0-beta1..2.10.0 + + diff --git a/local-test-freerdp-delta-01/afc-freerdp/LICENSE b/local-test-freerdp-delta-01/afc-freerdp/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/local-test-freerdp-delta-01/afc-freerdp/README.md b/local-test-freerdp-delta-01/afc-freerdp/README.md new file mode 100644 index 0000000000000000000000000000000000000000..303b093ebbda79e47161b162d8c7b1d1b3917266 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/README.md @@ -0,0 +1,44 @@ +# FreeRDP: A Remote Desktop Protocol Implementation + +FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released under the Apache license. +Enjoy the freedom of using your software wherever you want, the way you want it, in a world where +interoperability can finally liberate your computing experience. + +## Code Quality Status + +[![abi-checker](https://github.com/FreeRDP/FreeRDP/actions/workflows/abi-checker.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/abi-checker.yml) +[![clang-tidy-review](https://github.com/FreeRDP/FreeRDP/actions/workflows/clang-tidy.yml/badge.svg?event=pull_request_target)](https://github.com/FreeRDP/FreeRDP/actions/workflows/clang-tidy.yml) +[![CodeQL](https://github.com/FreeRDP/FreeRDP/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/codeql-analysis.yml) +[![mingw-builder](https://github.com/FreeRDP/FreeRDP/actions/workflows/mingw.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/mingw.yml) +[![[arm,ppc,ricsv] architecture builds](https://github.com/FreeRDP/FreeRDP/actions/workflows/alt-architectures.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/alt-architectures.yml) +[![[freebsd] architecture builds](https://github.com/FreeRDP/FreeRDP/actions/workflows/freebsd.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/freebsd.yml) +[![coverity](https://scan.coverity.com/projects/616/badge.svg)](https://scan.coverity.com/projects/freerdp) + +## Resources + +Project website: https://www.freerdp.com/ +Issue tracker: https://github.com/FreeRDP/FreeRDP/issues +Sources: https://github.com/FreeRDP/FreeRDP/ +Downloads: https://pub.freerdp.com/releases/ +Wiki: https://github.com/FreeRDP/FreeRDP/wiki +API documentation: https://pub.freerdp.com/api/ + +Security policy: https://github.com/FreeRDP/FreeRDP/security/policy + +Matrix room : #FreeRDP:matrix.org (main) +XMPP channel: #FreeRDP#matrix.org@matrix.org (bridged) +IRC channel : #freerdp @ irc.oftc.net (bridged) +Mailing list: https://lists.sourceforge.net/lists/listinfo/freerdp-devel + +## Microsoft Open Specifications + +Information regarding the Microsoft Open Specifications can be found at: +https://www.microsoft.com/openspecifications/ + +A list of reference documentation is maintained here: +https://github.com/FreeRDP/FreeRDP/wiki/Reference-Documentation + +## Compilation + +Instructions on how to get started compiling FreeRDP can be found on the wiki: +https://github.com/FreeRDP/FreeRDP/wiki/Compilation diff --git a/local-test-freerdp-delta-01/afc-freerdp/SECURITY.md b/local-test-freerdp-delta-01/afc-freerdp/SECURITY.md new file mode 100644 index 0000000000000000000000000000000000000000..be4373e7cfabdeeeede9a795d97306c9d7800627 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/SECURITY.md @@ -0,0 +1,114 @@ +# FreeRDP Security Policies and Procedures + +This document describes the security policy and procedures for the [FreeRDP Project](https://github.com/FreeRDP/FreeRDP). +The following topics are covered: + + * [Supported Versions](#supported-versions) + * [Reporting a Vulnerability](#reporting-a-vulnerability) + * [Disclosure Procedure](#disclosure-procedure) + + +## Supported versions + +Security is very important for us therefore we try to provide security updates and support for +the latest stable version as well as for the development branch. +Since our development branch is, like the protocol itself, a moving target we won't request CVEs for issues that are *only* found on the development branch. + +The following table shows the currently supported versions: + +| Version | Branch | Supported | +| ------- |--------------| ------------------ | +| < 2.0.0 | stable-1.x | :x: | +| 2.x.x | stable-2.0 | :heavy_check_mark: | +| 3.x.x | stable-3.0 | :white_check_mark: | +| - | master | :white_check_mark: | + + +## Reporting a vulnerability + +**IMPORTANT**: Please, do not file security vulnerabilities as public issues on GitHub + +In advance: **Thank you** for reporting a security vulnerability and making FreeRDP more stable! We really appreciate your effort. +Please let us know who we should give the credit or attributions to. + + +If you have found a security vulnerability in FreeRDP you can either directly open an [Advisory on GitHub](https://github.com/FreeRDP/FreeRDP/security/advisories/new)[^1] or send us an email to mailto:security@freerdp.com + +In case of an email you can use the [FreeRDP security team GPG key](#reporting-gpg-key) for encrypted communication. + +Once we receive a report we will review it and respond as soon as possible. + +### + + +## Disclosure procedure + +When the FreeRDP team receives a report one of the team members will be assigned as primary contact. +The primary contact will do all further communications and coordinate the fix and release process. + +How your report will be handled: + +* When a report is received we will acknowledge the reception and review the reported issue(s) as soon as possible. +* Once confirmed we will determine the affected versions. If not reported via GitHub a [security advisory draft on GitHub](https://github.com/FreeRDP/FreeRDP/security/advisories) will be created for any issue. If it applies we will request a CVE. +* On a private branch we will fix the issue and check the code for any potential similar problem. +* After the fix is validated we will create and publish a new release for all supported versions and publish the advisories. + +## Reporting GPG key + +FreeRDP's security reporting public gpg key https://pub.freerdp.com/FreeRDP-security-team.pub.asc + +``` +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBGBz+jsBEADaIM94hYfn/xDzncQwXl7/q6+06+ssqO3iUGqFr+0EPS+HxRjD +BeKjVRSkuo0+QLQoZgCwkoltEj1xRWNqCTDMA+oZkZH8L82eqCnUQqgCOyNWAVMH +6u6ValiZH3ruYxergBBHhyR4Ot2ia0xWN8MKTp+emLpzQ7goimGMo0mxR5FiDAdb +QKz1q5bgs3bb2pLpERNF+z13OS10Mzk1zdr++1pov5PWOTBRKmvBtPJKswmDpb0y +jQGeeqBFZwKzx0n6BTzDZtkqzTwvGhbm9Sb+qO0IO66IV8zQhPG/JUfDkByd6mX9 +Ykke0gxoRx54XqoRwZGNydOxMN6g3Oj1+ioWisltYLs/SzW20f3AMCoTeYyfjKtf +01refrA3aRfhDctvW5/s2LP0OEG2P/yQYXiGhK6uVxShz3Oa5dhFwiS8G63omZRH +AEqSk46EhAbbT4xfZ/Np209rhis4KW40cMMpI0F+XpyfT05ZQD6ytHTPgWTxv/OF +G9zy2ysT0kq+t+Hb+1RWQUq/2Dz9Lf6xLZPgqtyzg8xiFxZ4i1kf/VDWa3M76zn3 +qMcj3SPOxKY//wW70jCxf44yD38NvSa1M2Sz/K/RJKWkRWP/jhV1UHYusbzCmsvm +M9JkknNMJvGIjBDjHEVy6dlTaHQoHDY+Me9gsrEX0ZS9xXgAiB2IupabEwARAQAB +tEJGcmVlUkRQIFNlY3VyaXR5IFRlYW0gKGh0dHBzOi8vZnJlZXJkcC5jb20pIDxz +ZWN1cml0eUBmcmVlcmRwLmNvbT6JAk4EEwEKADgWIQRvuAE0sDt7JnxXu0o3Ibww +YbfjNAUCYHP6OwIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRA3IbwwYbfj +NPviD/43NLg7YfjAlvj5GipSmgelLwlIA+L/qbrf4NAB+NZ9oqp3bBdj4e5gZmiI +zd6bkANCqk21YiOE31medUfy+nfBQFVvj0oUg1X16C6RaIX5qA3Dwt5qBwKmDkT5 +j7JlxUS6Eluiau67ePiDYu2Wbp0qYuAmNUNL+Y2NCO9UJiy0Oq6YVXS971D5lC+a +SX0x9pizmFV3zro+l6/3kHTVbPednfX99yz9SZge64aWXo3MXVN8JD0lR3+92l99 +XsFDc+lGeR4azLFIqXC4Cr5Lbk34Hw/VwUC32xxFUaJ2ZmV3pA8bhCtBSxSmxnHS +H3hoBaD1WpuApbW8Psx6qsgoaSUdWsjluA4eQ5afJBf9O2NlT1mim5MAINY4PbWP +o4zq3p1ABVTzuB8tsGA9o6DeYVUUrj7lCv9STdGRhm0472BDkp/gvKMBoPgg3Qez +kvGKK7iVy8R/BOPjh9wP1art5JLVsralXGHA/5Ceid4ojKFzGIC9g3lnAPh+T/eM +duyY9XH4un1r73r6DRqUoczSfHYbxhKxWt0cRNdIadcXXusMPV/w4J4j55WcLrBE +5nopp/prJ5bYegUvRRrwVSFwLDxkE2dh68Zvlh5VWXIPFge0RPEAijYWR5qR2z+/ +VHgPYmliOnWFJN1rzekmWjKFtg5A57FkZyk3cp5x0/2xAX+TIbkCDQRgc/o7ARAA +vw53CoVkMzBlisSEETNdEKQMaiQ8BtbC438v/b1mOOeoE0YCfSW7RyflA/TXHOah +db0s3v/Kk2xmbjeMS9IJXlWviKKnOVMrMZvtJdQ4EKfqc5EpxNx7OiEofA/7n7Xs +1YEt6KjYaM/vgANl9HA2UXzqSFiRhkWjj1WA7vhqCWUArpAMGeCDYab2BBfp6Z4f +W9178N2vHH+Hh/uBwGUDnShU38GH8Nstkdcyw5puiJqNQBfZ1Fz9luzutp6zAgHz +WzobeRPZCCXs7CfxcvpkFS0ctOteQtIRIfP+jbDnldMmClQ87UVcKv0pCCJkMLNk +YUCMAb2UC2boCIf0omeeque4+FOphcO4+R/8jc6cYlQpgwUg2/IwBEEnCqtvo3qu +k6uzONhfWZPtUdJd158MGKGTogXVXGzoGzxIrKkZ4W1VuuMiEmhIQZO8e7/4Iz4a +Zp4qQXI8rsmNJN3lB5a7MWgrZ8mjllYRdfiTEvfQ+PiQqnG6PEHZ82om9kp555gs +15UqhjHAqRRtfXzQvZko0ngAxxZNVFPwK8LnxkyEPClRBC5eV3ljI8cvCfnWD01q +rCzSlSafFHCEUEQOhOrf/bBbXPkYTJw2KlumH5w9R6xQWgqneiD/+Qmqdclzdn36 +Pgbhyu6uSNZehbx5ptt/EM66JSAW7Q7W6Qnz5PNnHgEAEQEAAYkCNgQYAQoAIBYh +BG+4ATSwO3smfFe7SjchvDBht+M0BQJgc/o7AhsMAAoJEDchvDBht+M0JYUQALlV +dwmk6ZFq5dq0utWgutysL47b30BhYwNMVe0/6UW4h4TYaW6B3f58X7ik7EdYciyR +68eYfwKGhuv/y90QaGXJMU13XHpoInSaHQRhn5M/GkN16DBXdBok70Fh9Gx89Zhs +VKF3qwIVx5AO5CwrVA6F/iOiUEW31xiT7VFkbW1Cfl5H+M6nVXSR1bOdmxTObTz7 +CEeJMOVrZs36hVLMWLqZF0igVebO2AsDOY63fy/9MLn8ynCHhnAMvsm9ULWuFzGj +OsJezChduaHqPkopgwihe7jthUn4qWjABbbzKkS6HLBpGAfCzUun+lMpvIEUf+EJ +bpk7gj9xDEP6y96tV/dCeWb4p8N8webR8nVgsRxoEnfIdCkoB80iZGOzKfYYnvdz +ngs8MIL6dC4Nc1/t9ECV4O/w4uwIH65nC1ay0YOK/O/j2SEfnVHQmAuOsgTz+pBn +u6DIA2HsBzFdOCljtf3m4AeAaTbL7MBSDceApqg0lcrhjclqHJo1aJh3M6aVm3gq +yUt7y26Hkh/vYEJwW4gqRho4gb7BvjTZh5LUbrjmRtexFQ1eWM82u23yYS2L+y2Y +ejSKIKmJhXHqsgCVGYw5woZEEMzgpkoIWYG/Eoy+oVuU02QITh/Uc5VRsA9DuwSV +Vw2F8gu/fHiadawxWIhUH+plFVQZc1KwgPcIMW3S +=O0kP +-----END PGP PUBLIC KEY BLOCK----- +``` +[^1]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability diff --git a/local-test-freerdp-delta-01/afc-freerdp/channels/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/channels/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c95b386c498043bc4c826f9ca1225501a695f4f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/channels/CMakeLists.txt @@ -0,0 +1,285 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(CMakeParseArguments) +include(CMakeDependentOption) + +macro(define_channel_options) + set(PREFIX "CHANNEL") + + cmake_parse_arguments( + ${PREFIX} "" "NAME;TYPE;DESCRIPTION;SPECIFICATIONS;DEFAULT;CLIENT_DEFAULT;SERVER_DEFAULT" "" ${ARGN} + ) + + string(TOUPPER "CHANNEL_${CHANNEL_NAME}" CHANNEL_OPTION) + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" CHANNEL_CLIENT_OPTION) + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" CHANNEL_SERVER_OPTION) + string(TOUPPER "${CHANNEL_TYPE}" CHANNEL_TYPE) + + if(CHANNEL_DEFAULT) + set(OPTION_DEFAULT ${CHANNEL_DEFAULT}) + elseif(CHANNEL_CLIENT_OPTION OR CHANNEL_SERVER_OPTION) + set(OPTION_DEFAULT "ON") + endif() + + set(CHANNEL_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel") + set(CHANNEL_CLIENT_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel client") + set(CHANNEL_SERVER_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel server") + + if("${CHANNEL_TYPE}" STREQUAL "DYNAMIC") + cmake_dependent_option(${CHANNEL_OPTION} "${CHANNEL_OPTION_DOC}" ${CHANNEL_DEFAULT} "CHANNEL_DRDYNVC" OFF) + else() + option(${CHANNEL_OPTION} "${CHANNEL_OPTION_DOC}" ${CHANNEL_DEFAULT}) + endif() + + cmake_dependent_option( + ${CHANNEL_CLIENT_OPTION} "${CHANNEL_CLIENT_OPTION_DOC}" ${CHANNEL_CLIENT_DEFAULT} "${CHANNEL_OPTION}" OFF + ) + + cmake_dependent_option( + ${CHANNEL_SERVER_OPTION} "${CHANNEL_SERVER_OPTION_DOC}" ${CHANNEL_SERVER_DEFAULT} "${CHANNEL_OPTION}" OFF + ) +endmacro(define_channel_options) + +macro(define_channel _channel_name) + set(CHANNEL_NAME ${_channel_name}) + set(MODULE_NAME ${CHANNEL_NAME}) + string(TOUPPER "CHANNEL_${CHANNEL_NAME}" MODULE_PREFIX) +endmacro(define_channel) + +macro(define_channel_client _channel_name) + set(CHANNEL_NAME ${_channel_name}) + set(MODULE_NAME "${CHANNEL_NAME}-client") + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX) +endmacro(define_channel_client) + +macro(define_channel_server _channel_name) + set(CHANNEL_NAME ${_channel_name}) + set(MODULE_NAME "${CHANNEL_NAME}-server") + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" MODULE_PREFIX) +endmacro(define_channel_server) + +macro(define_channel_client_subsystem _channel_name _subsystem _type) + set(CHANNEL_NAME ${_channel_name}) + set(CHANNEL_SUBSYSTEM ${_subsystem}) + string(LENGTH "${_type}" _type_length) + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" CHANNEL_PREFIX) + if(_type_length GREATER 0) + set(SUBSYSTEM_TYPE ${_type}) + set(MODULE_NAME "${CHANNEL_NAME}-client-${CHANNEL_SUBSYSTEM}-${SUBSYSTEM_TYPE}") + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT_${CHANNEL_SUBSYSTEM}_${SUBSYSTEM_TYPE}" MODULE_PREFIX) + else() + set(MODULE_NAME "${CHANNEL_NAME}-client-${CHANNEL_SUBSYSTEM}") + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT_${CHANNEL_SUBSYSTEM}" MODULE_PREFIX) + endif() +endmacro(define_channel_client_subsystem) + +macro(define_channel_server_subsystem _channel_name _subsystem _type) + set(CHANNEL_NAME ${_channel_name}) + set(CHANNEL_SUBSYSTEM ${_subsystem}) + set(MODULE_NAME "${CHANNEL_NAME}-server-${CHANNEL_SUBSYSTEM}") + string(TOUPPER "CHANNEL_${CHANNEL_NAME}_server_${CHANNEL_SUBSYSTEM}" MODULE_PREFIX) +endmacro(define_channel_server_subsystem) + +macro(add_channel_client _channel_prefix _channel_name) + if(${_channel_prefix}_CLIENT) + add_subdirectory(client) + if(${${_channel_prefix}_CLIENT_STATIC}) + set(CHANNEL_STATIC_CLIENT_MODULES ${CHANNEL_STATIC_CLIENT_MODULES} ${_channel_prefix} PARENT_SCOPE) + set(${_channel_prefix}_CLIENT_NAME ${${_channel_prefix}_CLIENT_NAME} PARENT_SCOPE) + set(${_channel_prefix}_CLIENT_CHANNEL ${${_channel_prefix}_CLIENT_CHANNEL} PARENT_SCOPE) + set(${_channel_prefix}_CLIENT_ENTRY ${${_channel_prefix}_CLIENT_ENTRY} PARENT_SCOPE) + set(CHANNEL_STATIC_CLIENT_ENTRIES ${CHANNEL_STATIC_CLIENT_ENTRIES} ${${_channel_prefix}_CLIENT_ENTRY} + PARENT_SCOPE + ) + endif() + endif() +endmacro(add_channel_client) + +macro(add_channel_server _channel_prefix _channel_name) + if(${_channel_prefix}_SERVER) + add_subdirectory(server) + if(${${_channel_prefix}_SERVER_STATIC}) + set(CHANNEL_STATIC_SERVER_MODULES ${CHANNEL_STATIC_SERVER_MODULES} ${_channel_prefix} PARENT_SCOPE) + set(${_channel_prefix}_SERVER_NAME ${${_channel_prefix}_SERVER_NAME} PARENT_SCOPE) + set(${_channel_prefix}_SERVER_CHANNEL ${${_channel_prefix}_SERVER_CHANNEL} PARENT_SCOPE) + set(${_channel_prefix}_SERVER_ENTRY ${${_channel_prefix}_SERVER_ENTRY} PARENT_SCOPE) + set(CHANNEL_STATIC_SERVER_ENTRIES ${CHANNEL_STATIC_SERVER_ENTRIES} ${${_channel_prefix}_SERVER_ENTRY} + PARENT_SCOPE + ) + endif() + endif() +endmacro(add_channel_server) + +macro(add_channel_client_subsystem _channel_prefix _channel_name _subsystem _type) + add_subdirectory(${_subsystem}) + set(_channel_module_name "${_channel_name}-client") + string(LENGTH "${_type}" _type_length) + if(_type_length GREATER 0) + string(TOUPPER "CHANNEL_${_channel_name}_CLIENT_${_subsystem}_${_type}" _subsystem_prefix) + else() + string(TOUPPER "CHANNEL_${_channel_name}_CLIENT_${_subsystem}" _subsystem_prefix) + endif() + if(${${_subsystem_prefix}_STATIC}) + get_target_property(CHANNEL_SUBSYSTEMS ${_channel_module_name} SUBSYSTEMS) + if(_type_length GREATER 0) + set(SUBSYSTEMS ${SUBSYSTEMS} "${_subsystem}-${_type}") + else() + set(SUBSYSTEMS ${SUBSYSTEMS} ${_subsystem}) + endif() + set_target_properties(${_channel_module_name} PROPERTIES SUBSYSTEMS "${SUBSYSTEMS}") + endif() +endmacro(add_channel_client_subsystem) + +macro(channel_install _targets _destination _export_target) + if(NOT BUILD_SHARED_LIBS) + foreach(_target_name IN ITEMS ${_targets}) + target_include_directories(${_target_name} INTERFACE $) + endforeach() + install(TARGETS ${_targets} DESTINATION ${_destination} EXPORT ${_export_target}) + endif() +endmacro(channel_install) + +macro(server_channel_install _targets _destination) + channel_install(${_targets} ${_destination} "FreeRDP-ServerTargets") +endmacro(server_channel_install) + +macro(client_channel_install _targets _destination) + channel_install(${_targets} ${_destination} "FreeRDP-ClientTargets") +endmacro(client_channel_install) + +macro(add_channel_client_library _module_prefix _module_name _channel_name _dynamic _entry) + set(_lnk_dir ${${_module_prefix}_LINK_DIRS}) + if(NOT "${_lnk_dir}" STREQUAL "") + link_directories(${_lnk_dir}) + endif() + + set(${_module_prefix}_STATIC ON PARENT_SCOPE) + set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE) + set(${_module_prefix}_CHANNEL ${_channel_name} PARENT_SCOPE) + set(${_module_prefix}_ENTRY ${_entry} PARENT_SCOPE) + + add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS}) + set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client") + + if(${_module_prefix}_LIBS) + target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) + endif() + client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) +endmacro(add_channel_client_library) + +macro( + add_channel_client_subsystem_library + _module_prefix + _module_name + _channel_name + _type + _dynamic + _entry +) + set(_lnk_dir ${${_module_prefix}_LINK_DIRS}) + if(NOT "${_lnk_dir}" STREQUAL "") + link_directories(${_lnk_dir}) + endif() + + set(${_module_prefix}_STATIC ON PARENT_SCOPE) + set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE) + set(${_module_prefix}_TYPE ${_type} PARENT_SCOPE) + + add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS}) + set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${_channel_name}/Client/Subsystem/${CHANNEL_SUBSYSTEM}") + + if(${_module_prefix}_LIBS) + target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) + endif() + client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) +endmacro(add_channel_client_subsystem_library) + +macro(add_channel_server_library _module_prefix _module_name _channel_name _dynamic _entry) + set(_lnk_dir ${${_module_prefix}_LINK_DIRS}) + if(NOT "${_lnk_dir}" STREQUAL "") + link_directories(${_lnk_dir}) + endif() + + set(${_module_prefix}_STATIC ON PARENT_SCOPE) + set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE) + set(${_module_prefix}_CHANNEL ${_channel_name} PARENT_SCOPE) + set(${_module_prefix}_ENTRY ${_entry} PARENT_SCOPE) + + add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS}) + set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server") + + if(${_module_prefix}_LIBS) + target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) + endif() + server_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) +endmacro(add_channel_server_library) + +set(FILENAME "ChannelOptions.cmake") +file(GLOB FILEPATHS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${FILENAME}") + +# We need special treatment for drdynvc: +# It needs to be the first entry so that every +# dynamic channel has the dependent options available. +set(DRDYNVC_MATCH "") + +foreach(FILEPATH ${FILEPATHS}) + if(${FILEPATH} MATCHES "^([^/]*)drdynvc/+${FILENAME}") + set(DRDYNVC_MATCH ${FILEPATH}) + endif() +endforeach() + +if(NOT "${DRDYNVC_MATCH}" STREQUAL "") + list(REMOVE_ITEM FILEPATHS ${DRDYNVC_MATCH}) + list(APPEND FILEPATHS ${DRDYNVC_MATCH}) + list(REVERSE FILEPATHS) # list PREPEND is not available on old CMake3 +endif() + +foreach(FILEPATH ${FILEPATHS}) + if(${FILEPATH} MATCHES "^([^/]*)/+${FILENAME}") + string(REGEX REPLACE "^([^/]*)/+${FILENAME}" "\\1" DIR ${FILEPATH}) + set(CHANNEL_OPTION) + include(${FILEPATH}) + if(${CHANNEL_OPTION}) + set(CHANNEL_MESSAGE "Adding ${CHANNEL_TYPE} channel") + if(${CHANNEL_CLIENT_OPTION}) + set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} client") + endif() + if(${CHANNEL_SERVER_OPTION}) + set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} server") + endif() + set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} \"${CHANNEL_NAME}\"") + set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE}: ${CHANNEL_DESCRIPTION}") + message(STATUS "${CHANNEL_MESSAGE}") + add_subdirectory(${DIR}) + endif() + endif() +endforeach(FILEPATH) + +if(WITH_CHANNELS) + if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) + set(FREERDP_CHANNELS_CLIENT_SRCS ${FREERDP_CHANNELS_CLIENT_SRCS} PARENT_SCOPE) + set(FREERDP_CHANNELS_CLIENT_LIBS ${FREERDP_CHANNELS_CLIENT_LIBS} PARENT_SCOPE) + endif() + + if(WITH_SERVER_CHANNELS) + add_subdirectory(server) + set(FREERDP_CHANNELS_SERVER_SRCS ${FREERDP_CHANNELS_SERVER_SRCS} PARENT_SCOPE) + set(FREERDP_CHANNELS_SERVER_LIBS ${FREERDP_CHANNELS_SERVER_LIBS} PARENT_SCOPE) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/client/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..761c6247f09cfb121fbe0a3f36164e74af0b1718 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/CMakeLists.txt @@ -0,0 +1,126 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP Clients +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Clients + +include(CMakeDependentOption) +include(InstallFreeRDPDesktop) + +if(WITH_CLIENT_COMMON) + add_subdirectory(common) +endif() + +if(FREERDP_VENDOR AND WITH_CLIENT) + if(WIN32 AND NOT UWP) + add_subdirectory(Windows) + else() + if(WITH_SAMPLE) + add_subdirectory(Sample) + endif() + endif() + + if(WITH_CLIENT_SDL) + add_subdirectory(SDL) + endif() + + if(WITH_X11) + add_subdirectory(X11) + endif() + + if(WITH_WAYLAND AND WAYLAND_FOUND) + add_subdirectory(Wayland) + endif() + + if(APPLE) + if(IOS) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS") + message(STATUS "Adding iOS client") + add_subdirectory(iOS) + endif() + else() + option(WITH_CLIENT_MAC "Build native mac client" ON) + if(WITH_CLIENT_MAC) + add_subdirectory(Mac) + endif() + endif() + endif() + + if(ANDROID) + message(STATUS "Android client module is built with Android Studio project") + endif() +endif() + +# Pick up other clients +if(WITH_CLIENT) + set(FILENAME "ModuleOptions.cmake") + file(GLOB FILEPATHS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${FILENAME}") + + foreach(FILEPATH ${FILEPATHS}) + if(${FILEPATH} MATCHES "^([^/]*)/+${FILENAME}") + string(REGEX REPLACE "^([^/]*)/+${FILENAME}" "\\1" FREERDP_CLIENT ${FILEPATH}) + set(FREERDP_CLIENT_ENABLED 0) + include(${FILEPATH}) + if(FREERDP_CLIENT_ENABLED) + if(NOT (${FREERDP_CLIENT_VENDOR} MATCHES "FreeRDP")) + list(APPEND FREERDP_EXTRA_CLIENTS ${FREERDP_CLIENT}) + if(${FREERDP_CLIENT_VENDOR} MATCHES "${VENDOR}") + set(CLIENT_VENDOR_PATH "client/${FREERDP_CLIENT}" PARENT_SCOPE) + endif() + endif() + endif() + endif() + endforeach() + + foreach(FREERDP_CLIENT ${FREERDP_EXTRA_CLIENTS}) + add_subdirectory(${FREERDP_CLIENT}) + endforeach() +endif() + +if(WITH_FUSE) + list(APPEND FREERDP_CLIENT_PC_PRIVATE_LIBS "-lfuse3") +endif() + +list(JOIN FREERDP_CLIENT_PC_PRIVATE_LIBS " " FREERDP_CLIENT_PC_PRIVATE_LIBS) +include(pkg-config-install-prefix) +cleaning_configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/freerdp-client.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc @ONLY +) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc + DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR} +) + +export(PACKAGE freerdp-client) + +setfreerdpcmakeinstalldir(FREERDP_CLIENT_CMAKE_INSTALL_DIR "FreeRDP-Client${FREERDP_VERSION_MAJOR}") + +configure_package_config_file( + FreeRDP-ClientConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfig.cmake + INSTALL_DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR} PATH_VARS FREERDP_INCLUDE_DIR +) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfigVersion.cmake VERSION ${FREERDP_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfigVersion.cmake + DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR} +) + +install(EXPORT FreeRDP-ClientTargets DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR}) diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/FreeRDP-ClientConfig.cmake.in b/local-test-freerdp-delta-01/afc-freerdp/client/FreeRDP-ClientConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..409dbed4ada0a2aa2d3a0a280ab59291dd98c124 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/FreeRDP-ClientConfig.cmake.in @@ -0,0 +1,16 @@ +include(CMakeFindDependencyMacro) +find_dependency(WinPR @FREERDP_VERSION@) +find_dependency(FreeRDP @FREERDP_VERSION@) +if("@WITH_SMARTCARD_EMULATE@") + find_dependency(ZLIB) +endif() + +@PACKAGE_INIT@ + +set(FreeRDP-Client_VERSION_MAJOR "@FREERDP_VERSION_MAJOR@") +set(FreeRDP-Client_VERSION_MINOR "@FREERDP_VERSION_MINOR@") +set(FreeRDP-Client_VERSION_REVISION "@FREERDP_VERSION_REVISION@") + +set_and_check(FreeRDP-Client_INCLUDE_DIR "@PACKAGE_FREERDP_INCLUDE_DIR@") + +include("${CMAKE_CURRENT_LIST_DIR}/FreeRDP-ClientTargets.cmake") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/SDL/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/client/SDL/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd67ec593328e8003d480b1389b3e0f0da5f2607 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/SDL/CMakeLists.txt @@ -0,0 +1,104 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP SDL Client +# +# Copyright 2024 Armin Novak +# Copyright 2024 Thincast Technologies GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +cmake_minimum_required(VERSION 3.13) + +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() +if(NOT FREERDP_DEFAULT_PROJECT_VERSION) + set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0") +endif() + +project(sdl-freerdp LANGUAGES CXX VERSION ${FREERDP_DEFAULT_PROJECT_VERSION}) + +message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/) +include(CommonConfigOptions) + +include(ConfigureFreeRDP) +include(CXXCompilerFlags) + +option(WITH_DEBUG_SDL_EVENTS "[dangerous, not for release builds!] Debug SDL events" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_SDL_KBD_EVENTS "[dangerous, not for release builds!] Debug SDL keyboard events" + ${DEFAULT_DEBUG_OPTION} +) +option(WITH_WIN_CONSOLE "Build ${PROJECT_NAME} with console support" ON) +option(WITH_SDL_LINK_SHARED "link SDL dynamic or static" ON) + +if(WITH_WIN_CONSOLE) + set(WIN32_GUI_FLAG "TRUE") +else() + set(WIN32_GUI_FLAG "WIN32") +endif() + +if(WITH_DEBUG_SDL_EVENTS) + add_compile_definitions(WITH_DEBUG_SDL_EVENTS) +endif() +if(WITH_DEBUG_SDL_KBD_EVENTS) + add_compile_definitions(WITH_DEBUG_SDL_KBD_EVENTS) +endif() + +include(CMakeDependentOption) + +# Require 2.0.20 for ubuntu 22.04. +# older versions do not have the SDL2::SDL2 et al targets +find_package(SDL2 2.0.20) +find_package(SDL3) + +cmake_dependent_option(WITH_CLIENT_SDL_VERSIONED "append sdl version to client binaries" OFF WITH_CLIENT_SDL OFF) +cmake_dependent_option( + WITH_CLIENT_SDL2 "[experimental] build experimental SDL2 client" ${SDL2_FOUND} WITH_CLIENT_SDL OFF +) +cmake_dependent_option( + WITH_CLIENT_SDL3 "[experimental] build experimental SDL3 client" ${SDL3_FOUND} WITH_CLIENT_SDL OFF +) + +if(WITH_CLIENT_SDL2 AND WITH_CLIENT_SDL3) + message("Building both, SDL2 and SDL3 clients, forcing WITH_CLIENT_SDL_VERSIONED=ON") + set(WITH_CLIENT_SDL_VERSIONED ON) +endif() + +if(NOT SDL2_FOUND AND NOT SDL3_FOUND) + message(WARNING "No SDL library detected, giving up. Install SDL2 or SDL3 development package to fix") +endif() + +if((WITH_CLIENT_SDL2 AND SDL2_FOUND) OR (WITH_CLIENT_SDL3 AND SDL3_FOUND)) + add_subdirectory(common) + include_directories(common) +endif() + +if(WITH_CLIENT_SDL2) + if(SDL2_FOUND) + add_subdirectory(SDL2) + else() + message(WARNING "SDL2 requested but not found, continuing build without SDL2 client") + endif() +endif() + +if(WITH_CLIENT_SDL3) + if(SDL3_FOUND) + add_subdirectory(SDL3) + else() + message(WARNING "SDL3 requested but not found, continuing build without SDL3 client") + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4783ca6b92183e29276b62676afa563a7a63c937 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/CMakeLists.txt @@ -0,0 +1,48 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP Sample UI cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +cmake_minimum_required(VERSION 3.13) + +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() +if(NOT FREERDP_DEFAULT_PROJECT_VERSION) + set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0") +endif() + +project(sfreerdp LANGUAGES C VERSION ${FREERDP_DEFAULT_PROJECT_VERSION}) + +message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}") + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS ON) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/) +include(CommonConfigOptions) + +include(ConfigureFreeRDP) + +set(SRCS tf_channels.c tf_channels.h tf_freerdp.h tf_freerdp.c) + +addtargetwithresourcefile(${PROJECT_NAME} TRUE "${PROJECT_VERSION}" SRCS) + +set(LIBS freerdp-client freerdp winpr) +target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS}) + +set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/Sample") +install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) +install_freerdp_desktop("${PROJECT_NAME}") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/ModuleOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/ModuleOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1594cfed9eb953ac7a9033fc727645aaf7c3b78e --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/ModuleOptions.cmake @@ -0,0 +1,3 @@ +set(FREERDP_CLIENT_NAME "sfreerdp") +set(FREERDP_CLIENT_PLATFORM "Sample") +set(FREERDP_CLIENT_VENDOR "FreeRDP") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.c b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.c new file mode 100644 index 0000000000000000000000000000000000000000..efd451d5e854f7ff8b4ce17446635b968a02267a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.c @@ -0,0 +1,73 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Sample Client Channels + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "tf_channels.h" +#include "tf_freerdp.h" + +void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e) +{ + tfContext* tf = (tfContext*)context; + + WINPR_ASSERT(tf); + WINPR_ASSERT(e); + + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + { + } + else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + { + CliprdrClientContext* clip = (CliprdrClientContext*)e->pInterface; + WINPR_ASSERT(clip); + clip->custom = context; + } + else + freerdp_client_OnChannelConnectedEventHandler(&tf->common, e); +} + +void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) +{ + tfContext* tf = (tfContext*)context; + + WINPR_ASSERT(tf); + WINPR_ASSERT(e); + + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + { + } + else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + { + CliprdrClientContext* clip = (CliprdrClientContext*)e->pInterface; + WINPR_ASSERT(clip); + clip->custom = NULL; + } + else + freerdp_client_OnChannelDisconnectedEventHandler(&tf->common, e); +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.h b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.h new file mode 100644 index 0000000000000000000000000000000000000000..d00a5c2f0223d22064053fc36bfec48e44bcb0a4 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_channels.h @@ -0,0 +1,33 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Sample Client Channels + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_SAMPLE_CHANNELS_H +#define FREERDP_CLIENT_SAMPLE_CHANNELS_H + +#include +#include + +int tf_on_channel_connected(freerdp* instance, const char* name, void* pInterface); +int tf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface); + +void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e); +void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e); + +#endif /* FREERDP_CLIENT_SAMPLE_CHANNELS_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.c b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.c new file mode 100644 index 0000000000000000000000000000000000000000..7915635def08da6de8cb313443aa8e0a10631303 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.c @@ -0,0 +1,417 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP Test UI + * + * Copyright 2011 Marc-Andre Moreau + * Copyright 2016,2018 Armin Novak + * Copyright 2016,2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "tf_channels.h" +#include "tf_freerdp.h" + +#define TAG CLIENT_TAG("sample") + +/* This function is called whenever a new frame starts. + * It can be used to reset invalidated areas. */ +static BOOL tf_begin_paint(rdpContext* context) +{ + rdpGdi* gdi = NULL; + + WINPR_ASSERT(context); + + gdi = context->gdi; + WINPR_ASSERT(gdi); + WINPR_ASSERT(gdi->primary); + WINPR_ASSERT(gdi->primary->hdc); + WINPR_ASSERT(gdi->primary->hdc->hwnd); + WINPR_ASSERT(gdi->primary->hdc->hwnd->invalid); + gdi->primary->hdc->hwnd->invalid->null = TRUE; + return TRUE; +} + +/* This function is called when the library completed composing a new + * frame. Read out the changed areas and blit them to your output device. + * The image buffer will have the format specified by gdi_init + */ +static BOOL tf_end_paint(rdpContext* context) +{ + rdpGdi* gdi = NULL; + + WINPR_ASSERT(context); + + gdi = context->gdi; + WINPR_ASSERT(gdi); + WINPR_ASSERT(gdi->primary); + WINPR_ASSERT(gdi->primary->hdc); + WINPR_ASSERT(gdi->primary->hdc->hwnd); + WINPR_ASSERT(gdi->primary->hdc->hwnd->invalid); + + if (gdi->primary->hdc->hwnd->invalid->null) + return TRUE; + + return TRUE; +} + +static BOOL tf_desktop_resize(rdpContext* context) +{ + rdpGdi* gdi = NULL; + rdpSettings* settings = NULL; + + WINPR_ASSERT(context); + + settings = context->settings; + WINPR_ASSERT(settings); + + gdi = context->gdi; + return gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); +} + +/* This function is called to output a System BEEP */ +static BOOL tf_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound) +{ + /* TODO: Implement */ + WINPR_UNUSED(context); + WINPR_UNUSED(play_sound); + return TRUE; +} + +/* This function is called to update the keyboard indocator LED */ +static BOOL tf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags) +{ + /* TODO: Set local keyboard indicator LED status */ + WINPR_UNUSED(context); + WINPR_UNUSED(led_flags); + return TRUE; +} + +/* This function is called to set the IME state */ +static BOOL tf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState, + UINT32 imeConvMode) +{ + if (!context) + return FALSE; + + WLog_WARN(TAG, + "KeyboardSetImeStatus(unitId=%04" PRIx16 ", imeState=%08" PRIx32 + ", imeConvMode=%08" PRIx32 ") ignored", + imeId, imeState, imeConvMode); + return TRUE; +} + +/* Called before a connection is established. + * Set all configuration options to support and load channels here. */ +static BOOL tf_pre_connect(freerdp* instance) +{ + rdpSettings* settings = NULL; + + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + + settings = instance->context->settings; + WINPR_ASSERT(settings); + + /* If the callbacks provide the PEM all certificate options can be extracted, otherwise + * only the certificate fingerprint is available. */ + if (!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, TRUE)) + return FALSE; + + /* Optional OS identifier sent to server */ + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER)) + return FALSE; + /* OrderSupport is initialized at this point. + * Only override it if you plan to implement custom order + * callbacks or deactivate certain features. */ + /* Register the channel listeners. + * They are required to set up / tear down channels if they are loaded. */ + PubSub_SubscribeChannelConnected(instance->context->pubSub, tf_OnChannelConnectedEventHandler); + PubSub_SubscribeChannelDisconnected(instance->context->pubSub, + tf_OnChannelDisconnectedEventHandler); + + /* TODO: Any code your client requires */ + return TRUE; +} + +/* Called after a RDP connection was successfully established. + * Settings might have changed during negotiation of client / server feature + * support. + * + * Set up local framebuffers and paing callbacks. + * If required, register pointer callbacks to change the local mouse cursor + * when hovering over the RDP window + */ +static BOOL tf_post_connect(freerdp* instance) +{ + rdpContext* context = NULL; + + if (!gdi_init(instance, PIXEL_FORMAT_XRGB32)) + return FALSE; + + context = instance->context; + WINPR_ASSERT(context); + WINPR_ASSERT(context->update); + + /* With this setting we disable all graphics processing in the library. + * + * This allows low resource (client) protocol parsing. + */ + if (!freerdp_settings_set_bool(context->settings, FreeRDP_DeactivateClientDecoding, TRUE)) + return FALSE; + + context->update->BeginPaint = tf_begin_paint; + context->update->EndPaint = tf_end_paint; + context->update->PlaySound = tf_play_sound; + context->update->DesktopResize = tf_desktop_resize; + context->update->SetKeyboardIndicators = tf_keyboard_set_indicators; + context->update->SetKeyboardImeStatus = tf_keyboard_set_ime_status; + return TRUE; +} + +/* This function is called whether a session ends by failure or success. + * Clean up everything allocated by pre_connect and post_connect. + */ +static void tf_post_disconnect(freerdp* instance) +{ + tfContext* context = NULL; + + if (!instance) + return; + + if (!instance->context) + return; + + context = (tfContext*)instance->context; + PubSub_UnsubscribeChannelConnected(instance->context->pubSub, + tf_OnChannelConnectedEventHandler); + PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub, + tf_OnChannelDisconnectedEventHandler); + gdi_free(instance); + /* TODO : Clean up custom stuff */ + WINPR_UNUSED(context); +} + +/* RDP main loop. + * Connects RDP, loops while running and handles event and dispatch, cleans up + * after the connection ends. */ +static DWORD WINAPI tf_client_thread_proc(LPVOID arg) +{ + freerdp* instance = (freerdp*)arg; + DWORD nCount = 0; + DWORD status = 0; + DWORD result = 0; + HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 }; + BOOL rc = freerdp_connect(instance); + + WINPR_ASSERT(instance->context); + WINPR_ASSERT(instance->context->settings); + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_AuthenticationOnly)) + { + result = freerdp_get_last_error(instance->context); + freerdp_abort_connect_context(instance->context); + WLog_ERR(TAG, "Authentication only, exit status 0x%08" PRIx32 "", result); + goto disconnect; + } + + if (!rc) + { + result = freerdp_get_last_error(instance->context); + WLog_ERR(TAG, "connection failure 0x%08" PRIx32, result); + return result; + } + + while (!freerdp_shall_disconnect_context(instance->context)) + { + nCount = freerdp_get_event_handles(instance->context, handles, ARRAYSIZE(handles)); + + if (nCount == 0) + { + WLog_ERR(TAG, "freerdp_get_event_handles failed"); + break; + } + + status = WaitForMultipleObjects(nCount, handles, FALSE, 100); + + if (status == WAIT_FAILED) + { + WLog_ERR(TAG, "WaitForMultipleObjects failed with %" PRIu32 "", status); + break; + } + + if (!freerdp_check_event_handles(instance->context)) + { + if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SUCCESS) + WLog_ERR(TAG, "Failed to check FreeRDP event handles"); + + break; + } + } + +disconnect: + freerdp_disconnect(instance); + return result; +} + +/* Optional global initializer. + * Here we just register a signal handler to print out stack traces + * if available. */ +static BOOL tf_client_global_init(void) +{ + if (freerdp_handle_signals() != 0) + return FALSE; + + return TRUE; +} + +/* Optional global tear down */ +static void tf_client_global_uninit(void) +{ +} + +static int tf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type) +{ + tfContext* tf = NULL; + const char* str_data = freerdp_get_logon_error_info_data(data); + const char* str_type = freerdp_get_logon_error_info_type(type); + + if (!instance || !instance->context) + return -1; + + tf = (tfContext*)instance->context; + WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type); + WINPR_UNUSED(tf); + + return 1; +} + +static BOOL tf_client_new(freerdp* instance, rdpContext* context) +{ + tfContext* tf = (tfContext*)context; + + if (!instance || !context) + return FALSE; + + instance->PreConnect = tf_pre_connect; + instance->PostConnect = tf_post_connect; + instance->PostDisconnect = tf_post_disconnect; + instance->LogonErrorInfo = tf_logon_error_info; + /* TODO: Client display set up */ + WINPR_UNUSED(tf); + return TRUE; +} + +static void tf_client_free(freerdp* instance, rdpContext* context) +{ + tfContext* tf = (tfContext*)instance->context; + + if (!context) + return; + + /* TODO: Client display tear down */ + WINPR_UNUSED(tf); +} + +static int tf_client_start(rdpContext* context) +{ + /* TODO: Start client related stuff */ + WINPR_UNUSED(context); + return 0; +} + +static int tf_client_stop(rdpContext* context) +{ + /* TODO: Stop client related stuff */ + WINPR_UNUSED(context); + return 0; +} + +static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) +{ + WINPR_ASSERT(pEntryPoints); + + ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS)); + pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION; + pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1); + pEntryPoints->GlobalInit = tf_client_global_init; + pEntryPoints->GlobalUninit = tf_client_global_uninit; + pEntryPoints->ContextSize = sizeof(tfContext); + pEntryPoints->ClientNew = tf_client_new; + pEntryPoints->ClientFree = tf_client_free; + pEntryPoints->ClientStart = tf_client_start; + pEntryPoints->ClientStop = tf_client_stop; + return 0; +} + +int main(int argc, char* argv[]) +{ + int rc = -1; + RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 }; + + RdpClientEntry(&clientEntryPoints); + rdpContext* context = freerdp_client_context_new(&clientEntryPoints); + + if (!context) + goto fail; + + const int status = + freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE); + if (status) + { + rc = freerdp_client_settings_command_line_status_print(context->settings, status, argc, + argv); + goto fail; + } + + if (!stream_dump_register_handlers(context, CONNECTION_STATE_MCS_CREATE_REQUEST, FALSE)) + goto fail; + + if (freerdp_client_start(context) != 0) + goto fail; + + const DWORD res = tf_client_thread_proc(context->instance); + rc = (int)res; + + if (freerdp_client_stop(context) != 0) + rc = -1; + +fail: + freerdp_client_context_free(context); + return rc; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.h b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.h new file mode 100644 index 0000000000000000000000000000000000000000..c9b52951b847f01a86b04d30276ec701e88ccff8 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Sample/tf_freerdp.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Sample Client + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_SAMPLE_H +#define FREERDP_CLIENT_SAMPLE_H + +#include +#include +#include +#include +#include + +typedef struct +{ + rdpClientContext common; + + /* Channels */ +} tfContext; + +#endif /* FREERDP_CLIENT_SAMPLE_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a237a59969d560ce5893bef7e575fa2b91a4dd9 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/CMakeLists.txt @@ -0,0 +1,56 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP Wayland Client cmake build script +# +# Copyright 2014 Manuel Bachmann +# Copyright 2015 David Fort +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "wlfreerdp") +set(MODULE_PREFIX "FREERDP_CLIENT_WAYLAND") + +include_directories(SYSTEM ${WAYLAND_INCLUDE_DIR}) + +set(${MODULE_PREFIX}_SRCS + wlfreerdp.c + wlfreerdp.h + wlf_disp.c + wlf_disp.h + wlf_pointer.c + wlf_pointer.h + wlf_input.c + wlf_input.h + wlf_cliprdr.c + wlf_cliprdr.h + wlf_channels.c + wlf_channels.h +) + +if(FREERDP_UNIFIED_BUILD) + include_directories(${PROJECT_SOURCE_DIR}/uwac/include) + include_directories(${PROJECT_BINARY_DIR}/uwac/include) +else() + find_package(uwac 0 REQUIRED) + include_directories(SYSTEM ${UWAC_INCLUDE_DIR}) +endif() + +list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client freerdp uwac) + +addtargetwithresourcefile(${MODULE_NAME} TRUE ${FREERDP_VERSION} ${MODULE_PREFIX}_SRCS) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Wayland") +generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.c new file mode 100644 index 0000000000000000000000000000000000000000..3a11407e92ec3899447f218116a031dbda4bd4aa --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.c @@ -0,0 +1,79 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Client Channels + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +#include "wlf_channels.h" +#include "wlf_cliprdr.h" +#include "wlf_disp.h" +#include "wlfreerdp.h" + +void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e) +{ + wlfContext* wlf = (wlfContext*)context; + + WINPR_ASSERT(wlf); + WINPR_ASSERT(e); + + if (FALSE) + { + } + else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + { + } + else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + { + wlf_cliprdr_init(wlf->clipboard, (CliprdrClientContext*)e->pInterface); + } + else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) + { + wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface); + } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); +} + +void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) +{ + wlfContext* wlf = (wlfContext*)context; + + WINPR_ASSERT(wlf); + WINPR_ASSERT(e); + + if (FALSE) + { + } + else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + { + } + else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + { + wlf_cliprdr_uninit(wlf->clipboard, (CliprdrClientContext*)e->pInterface); + } + else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) + { + wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface); + } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.h new file mode 100644 index 0000000000000000000000000000000000000000..e8760316b150a6fe944fdb4a0bf42f76bb4b5c9e --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_channels.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Client Channels + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WAYLAND_CHANNELS_H +#define FREERDP_CLIENT_WAYLAND_CHANNELS_H + +#include +#include +#include +#include +#include +#include +#include + +int wlf_on_channel_connected(freerdp* instance, const char* name, void* pInterface); +int wlf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface); + +void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e); +void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e); + +#endif /* FREERDP_CLIENT_WAYLAND_CHANNELS_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.c new file mode 100644 index 0000000000000000000000000000000000000000..1be612b13a4f683c6f51dab150fcd590549b550f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.c @@ -0,0 +1,1018 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Clipboard Redirection + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "wlf_cliprdr.h" + +#define TAG CLIENT_TAG("wayland.cliprdr") + +#define mime_text_plain "text/plain" +// NOLINTNEXTLINE(bugprone-suspicious-missing-comma) +static const char mime_text_utf8[] = mime_text_plain ";charset=utf-8"; + +// NOLINTNEXTLINE(bugprone-suspicious-missing-comma) +static const char* mime_text[] = { mime_text_plain, mime_text_utf8, "UTF8_STRING", + "COMPOUND_TEXT", "TEXT", "STRING" }; + +static const char mime_png[] = "image/png"; +static const char mime_webp[] = "image/webp"; +static const char mime_jpg[] = "image/jpeg"; +static const char mime_tiff[] = "image/tiff"; +static const char mime_uri_list[] = "text/uri-list"; +static const char mime_html[] = "text/html"; + +#define BMP_MIME_LIST "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-win-bitmap" +static const char* mime_bitmap[] = { BMP_MIME_LIST }; +static const char* mime_image[] = { mime_png, mime_webp, mime_jpg, mime_tiff, BMP_MIME_LIST }; + +static const char mime_gnome_copied_files[] = "x-special/gnome-copied-files"; +static const char mime_mate_copied_files[] = "x-special/mate-copied-files"; + +static const char type_FileGroupDescriptorW[] = "FileGroupDescriptorW"; +static const char type_HtmlFormat[] = "HTML Format"; + +typedef struct +{ + FILE* responseFile; + UINT32 responseFormat; + char* responseMime; +} wlf_request; + +typedef struct +{ + const FILE* responseFile; + UINT32 responseFormat; + const char* responseMime; +} wlf_const_request; + +struct wlf_clipboard +{ + wlfContext* wfc; + rdpChannels* channels; + CliprdrClientContext* context; + wLog* log; + + UwacSeat* seat; + wClipboard* system; + + size_t numClientFormats; + CLIPRDR_FORMAT* clientFormats; + + size_t numServerFormats; + CLIPRDR_FORMAT* serverFormats; + + BOOL sync; + + CRITICAL_SECTION lock; + CliprdrFileContext* file; + + wQueue* request_queue; +}; + +static void wlf_request_free(void* rq) +{ + wlf_request* request = rq; + if (request) + { + free(request->responseMime); + if (request->responseFile) + (void)fclose(request->responseFile); + } + free(request); +} + +static wlf_request* wlf_request_new(void) +{ + return calloc(1, sizeof(wlf_request)); +} + +static void* wlf_request_clone(const void* oth) +{ + const wlf_request* other = (const wlf_request*)oth; + wlf_request* copy = wlf_request_new(); + if (!copy) + return NULL; + *copy = *other; + if (other->responseMime) + { + copy->responseMime = _strdup(other->responseMime); + if (!copy->responseMime) + goto fail; + } + return copy; +fail: + wlf_request_free(copy); + return NULL; +} + +static BOOL wlf_mime_is_file(const char* mime) +{ + if (strncmp(mime_uri_list, mime, sizeof(mime_uri_list)) == 0) + return TRUE; + if (strncmp(mime_gnome_copied_files, mime, sizeof(mime_gnome_copied_files)) == 0) + return TRUE; + if (strncmp(mime_mate_copied_files, mime, sizeof(mime_mate_copied_files)) == 0) + return TRUE; + return FALSE; +} + +static BOOL wlf_mime_is_text(const char* mime) +{ + for (size_t x = 0; x < ARRAYSIZE(mime_text); x++) + { + if (strcmp(mime, mime_text[x]) == 0) + return TRUE; + } + + return FALSE; +} + +static BOOL wlf_mime_is_image(const char* mime) +{ + for (size_t x = 0; x < ARRAYSIZE(mime_image); x++) + { + if (strcmp(mime, mime_image[x]) == 0) + return TRUE; + } + + return FALSE; +} + +static BOOL wlf_mime_is_html(const char* mime) +{ + if (strcmp(mime, mime_html) == 0) + return TRUE; + + return FALSE; +} + +static void wlf_cliprdr_free_server_formats(wfClipboard* clipboard) +{ + if (clipboard && clipboard->serverFormats) + { + for (size_t j = 0; j < clipboard->numServerFormats; j++) + { + CLIPRDR_FORMAT* format = &clipboard->serverFormats[j]; + free(format->formatName); + } + + free(clipboard->serverFormats); + clipboard->serverFormats = NULL; + clipboard->numServerFormats = 0; + } + + if (clipboard) + UwacClipboardOfferDestroy(clipboard->seat); +} + +static void wlf_cliprdr_free_client_formats(wfClipboard* clipboard) +{ + if (clipboard && clipboard->numClientFormats) + { + for (size_t j = 0; j < clipboard->numClientFormats; j++) + { + CLIPRDR_FORMAT* format = &clipboard->clientFormats[j]; + free(format->formatName); + } + + free(clipboard->clientFormats); + clipboard->clientFormats = NULL; + clipboard->numClientFormats = 0; + } + + if (clipboard) + UwacClipboardOfferDestroy(clipboard->seat); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_send_client_format_list(wfClipboard* clipboard) +{ + WINPR_ASSERT(clipboard); + + const CLIPRDR_FORMAT_LIST formatList = { .common.msgFlags = 0, + .numFormats = (UINT32)clipboard->numClientFormats, + .formats = clipboard->clientFormats, + .common.msgType = CB_FORMAT_LIST }; + + cliprdr_file_context_clear(clipboard->file); + + WLog_VRB(TAG, "-------------- client format list [%" PRIu32 "] ------------------", + formatList.numFormats); + for (UINT32 x = 0; x < formatList.numFormats; x++) + { + const CLIPRDR_FORMAT* format = &formatList.formats[x]; + WLog_VRB(TAG, "client announces %" PRIu32 " [%s][%s]", format->formatId, + ClipboardGetFormatIdString(format->formatId), format->formatName); + } + WINPR_ASSERT(clipboard->context); + WINPR_ASSERT(clipboard->context->ClientFormatList); + return clipboard->context->ClientFormatList(clipboard->context, &formatList); +} + +static void wfl_cliprdr_add_client_format_id(wfClipboard* clipboard, UINT32 formatId) +{ + CLIPRDR_FORMAT* format = NULL; + const char* name = ClipboardGetFormatName(clipboard->system, formatId); + + for (size_t x = 0; x < clipboard->numClientFormats; x++) + { + format = &clipboard->clientFormats[x]; + + if (format->formatId == formatId) + return; + } + + format = realloc(clipboard->clientFormats, + (clipboard->numClientFormats + 1) * sizeof(CLIPRDR_FORMAT)); + + if (!format) + return; + + clipboard->clientFormats = format; + format = &clipboard->clientFormats[clipboard->numClientFormats++]; + format->formatId = formatId; + format->formatName = NULL; + + if (name && (formatId >= CF_MAX)) + format->formatName = _strdup(name); +} + +static BOOL wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mime) +{ + WINPR_ASSERT(mime); + ClipboardLock(clipboard->system); + if (wlf_mime_is_html(mime)) + { + UINT32 formatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat); + wfl_cliprdr_add_client_format_id(clipboard, formatId); + } + else if (wlf_mime_is_text(mime)) + { + wfl_cliprdr_add_client_format_id(clipboard, CF_TEXT); + wfl_cliprdr_add_client_format_id(clipboard, CF_OEMTEXT); + wfl_cliprdr_add_client_format_id(clipboard, CF_UNICODETEXT); + } + else if (wlf_mime_is_image(mime)) + { + for (size_t x = 0; x < ARRAYSIZE(mime_image); x++) + { + const char* mime_bmp = mime_image[x]; + UINT32 formatId = ClipboardGetFormatId(clipboard->system, mime_bmp); + if (formatId != 0) + wfl_cliprdr_add_client_format_id(clipboard, formatId); + } + wfl_cliprdr_add_client_format_id(clipboard, CF_DIB); + wfl_cliprdr_add_client_format_id(clipboard, CF_TIFF); + } + else if (wlf_mime_is_file(mime)) + { + const UINT32 fileFormatId = + ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW); + wfl_cliprdr_add_client_format_id(clipboard, fileFormatId); + } + + ClipboardUnlock(clipboard->system); + if (wlf_cliprdr_send_client_format_list(clipboard) != CHANNEL_RC_OK) + return FALSE; + return TRUE; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_const_request* rq) +{ + WINPR_ASSERT(rq); + + CLIPRDR_FORMAT_DATA_REQUEST request = { .requestedFormatId = rq->responseFormat }; + + if (!Queue_Enqueue(clipboard->request_queue, rq)) + return ERROR_INTERNAL_ERROR; + + WINPR_ASSERT(clipboard); + WINPR_ASSERT(clipboard->context); + WINPR_ASSERT(clipboard->context->ClientFormatDataRequest); + return clipboard->context->ClientFormatDataRequest(clipboard->context, &request); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* data, size_t size) +{ + CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 }; + + if (size > UINT32_MAX) + return ERROR_INVALID_PARAMETER; + + response.common.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL; + response.common.dataLen = (UINT32)size; + response.requestedFormatData = data; + + WINPR_ASSERT(clipboard); + WINPR_ASSERT(clipboard->context); + WINPR_ASSERT(clipboard->context->ClientFormatDataResponse); + return clipboard->context->ClientFormatDataResponse(clipboard->context, &response); +} + +BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event) +{ + if (!clipboard || !event) + return FALSE; + + if (!clipboard->context) + return TRUE; + + switch (event->type) + { + case UWAC_EVENT_CLIPBOARD_AVAILABLE: + clipboard->seat = event->seat; + return TRUE; + + case UWAC_EVENT_CLIPBOARD_OFFER: + WLog_Print(clipboard->log, WLOG_DEBUG, "client announces mime %s", event->mime); + return wlf_cliprdr_add_client_format(clipboard, event->mime); + + case UWAC_EVENT_CLIPBOARD_SELECT: + WLog_Print(clipboard->log, WLOG_DEBUG, "client announces new data"); + wlf_cliprdr_free_client_formats(clipboard); + return TRUE; + + default: + return FALSE; + } +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard) +{ + WINPR_ASSERT(clipboard); + + CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = { + .capabilitySetType = CB_CAPSTYPE_GENERAL, + .capabilitySetLength = 12, + .version = CB_CAPS_VERSION_2, + .generalFlags = + CB_USE_LONG_FORMAT_NAMES | cliprdr_file_context_current_flags(clipboard->file) + }; + CLIPRDR_CAPABILITIES capabilities = { .cCapabilitiesSets = 1, + .capabilitySets = + (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet) }; + + WINPR_ASSERT(clipboard); + WINPR_ASSERT(clipboard->context); + WINPR_ASSERT(clipboard->context->ClientCapabilities); + return clipboard->context->ClientCapabilities(clipboard->context, &capabilities); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard, BOOL status) +{ + const CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse = { + .common.msgType = CB_FORMAT_LIST_RESPONSE, + .common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL, + .common.dataLen = 0 + }; + WINPR_ASSERT(clipboard); + WINPR_ASSERT(clipboard->context); + WINPR_ASSERT(clipboard->context->ClientFormatListResponse); + return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_monitor_ready(CliprdrClientContext* context, + const CLIPRDR_MONITOR_READY* monitorReady) +{ + UINT ret = 0; + + WINPR_UNUSED(monitorReady); + WINPR_ASSERT(context); + WINPR_ASSERT(monitorReady); + + wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom); + WINPR_ASSERT(clipboard); + + if ((ret = wlf_cliprdr_send_client_capabilities(clipboard)) != CHANNEL_RC_OK) + return ret; + + if ((ret = wlf_cliprdr_send_client_format_list(clipboard)) != CHANNEL_RC_OK) + return ret; + + clipboard->sync = TRUE; + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_server_capabilities(CliprdrClientContext* context, + const CLIPRDR_CAPABILITIES* capabilities) +{ + WINPR_ASSERT(context); + WINPR_ASSERT(capabilities); + + const BYTE* capsPtr = (const BYTE*)capabilities->capabilitySets; + WINPR_ASSERT(capsPtr); + + wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom); + WINPR_ASSERT(clipboard); + + if (!cliprdr_file_context_remote_set_flags(clipboard->file, 0)) + return ERROR_INTERNAL_ERROR; + + for (UINT32 i = 0; i < capabilities->cCapabilitiesSets; i++) + { + const CLIPRDR_CAPABILITY_SET* caps = (const CLIPRDR_CAPABILITY_SET*)capsPtr; + + if (caps->capabilitySetType == CB_CAPSTYPE_GENERAL) + { + const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps = + (const CLIPRDR_GENERAL_CAPABILITY_SET*)caps; + + if (!cliprdr_file_context_remote_set_flags(clipboard->file, generalCaps->generalFlags)) + return ERROR_INTERNAL_ERROR; + } + + capsPtr += caps->capabilitySetLength; + } + + return CHANNEL_RC_OK; +} + +static UINT32 wlf_get_server_format_id(const wfClipboard* clipboard, const char* name) +{ + WINPR_ASSERT(clipboard); + WINPR_ASSERT(name); + + for (UINT32 x = 0; x < clipboard->numServerFormats; x++) + { + const CLIPRDR_FORMAT* format = &clipboard->serverFormats[x]; + if (!format->formatName) + continue; + if (strcmp(name, format->formatName) == 0) + return format->formatId; + } + return 0; +} + +static const char* wlf_get_server_format_name(const wfClipboard* clipboard, UINT32 formatId) +{ + WINPR_ASSERT(clipboard); + + for (UINT32 x = 0; x < clipboard->numServerFormats; x++) + { + const CLIPRDR_FORMAT* format = &clipboard->serverFormats[x]; + if (format->formatId == formatId) + return format->formatName; + } + return NULL; +} + +static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char* mime, int fd) +{ + wfClipboard* clipboard = (wfClipboard*)context; + WINPR_UNUSED(seat); + + EnterCriticalSection(&clipboard->lock); + + wlf_const_request request = { 0 }; + if (wlf_mime_is_html(mime)) + { + request.responseMime = mime_html; + request.responseFormat = wlf_get_server_format_id(clipboard, type_HtmlFormat); + } + else if (wlf_mime_is_file(mime)) + { + request.responseMime = mime; + request.responseFormat = wlf_get_server_format_id(clipboard, type_FileGroupDescriptorW); + } + else if (wlf_mime_is_text(mime)) + { + request.responseMime = mime_text_plain; + request.responseFormat = CF_UNICODETEXT; + } + else if (wlf_mime_is_image(mime)) + { + request.responseMime = mime; + if (strcmp(mime, mime_tiff) == 0) + request.responseFormat = CF_TIFF; + else + request.responseFormat = CF_DIB; + } + + if (request.responseMime != NULL) + { + request.responseFile = fdopen(fd, "w"); + + if (request.responseFile) + wlf_cliprdr_send_data_request(clipboard, &request); + else + WLog_Print(clipboard->log, WLOG_ERROR, + "failed to open clipboard file descriptor for MIME %s", + request.responseMime); + } + + LeaveCriticalSection(&clipboard->lock); +} + +static void wlf_cliprdr_cancel_data(UwacSeat* seat, void* context) +{ + wfClipboard* clipboard = (wfClipboard*)context; + + WINPR_UNUSED(seat); + WINPR_ASSERT(clipboard); + cliprdr_file_context_clear(clipboard->file); +} + +/** + * Called when the clipboard changes server side. + * + * Clear the local clipboard offer and replace it with a new one + * that announces the formats we get listed here. + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context, + const CLIPRDR_FORMAT_LIST* formatList) +{ + BOOL html = FALSE; + BOOL text = FALSE; + BOOL image = FALSE; + BOOL file = FALSE; + + if (!context || !context->custom) + return ERROR_INVALID_PARAMETER; + + wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom); + WINPR_ASSERT(clipboard); + + wlf_cliprdr_free_server_formats(clipboard); + cliprdr_file_context_clear(clipboard->file); + + if (!(clipboard->serverFormats = + (CLIPRDR_FORMAT*)calloc(formatList->numFormats, sizeof(CLIPRDR_FORMAT)))) + { + WLog_Print(clipboard->log, WLOG_ERROR, + "failed to allocate %" PRIuz " CLIPRDR_FORMAT structs", + clipboard->numServerFormats); + return CHANNEL_RC_NO_MEMORY; + } + + clipboard->numServerFormats = formatList->numFormats; + + if (!clipboard->seat) + { + WLog_Print(clipboard->log, WLOG_ERROR, + "clipboard->seat=NULL, check your client implementation"); + return ERROR_INTERNAL_ERROR; + } + + for (UINT32 i = 0; i < formatList->numFormats; i++) + { + const CLIPRDR_FORMAT* format = &formatList->formats[i]; + CLIPRDR_FORMAT* srvFormat = &clipboard->serverFormats[i]; + srvFormat->formatId = format->formatId; + + if (format->formatName) + { + srvFormat->formatName = _strdup(format->formatName); + + if (!srvFormat->formatName) + { + wlf_cliprdr_free_server_formats(clipboard); + return CHANNEL_RC_NO_MEMORY; + } + } + + if (format->formatName) + { + if (strcmp(format->formatName, type_HtmlFormat) == 0) + { + text = TRUE; + html = TRUE; + } + else if (strcmp(format->formatName, type_FileGroupDescriptorW) == 0) + { + file = TRUE; + text = TRUE; + } + } + else + { + switch (format->formatId) + { + case CF_TEXT: + case CF_OEMTEXT: + case CF_UNICODETEXT: + text = TRUE; + break; + + case CF_DIB: + image = TRUE; + break; + + default: + break; + } + } + } + + if (html) + { + UwacClipboardOfferCreate(clipboard->seat, mime_html); + } + + if (file && cliprdr_file_context_has_local_support(clipboard->file)) + { + UwacClipboardOfferCreate(clipboard->seat, mime_uri_list); + UwacClipboardOfferCreate(clipboard->seat, mime_gnome_copied_files); + UwacClipboardOfferCreate(clipboard->seat, mime_mate_copied_files); + } + + if (text) + { + for (size_t x = 0; x < ARRAYSIZE(mime_text); x++) + UwacClipboardOfferCreate(clipboard->seat, mime_text[x]); + } + + if (image) + { + for (size_t x = 0; x < ARRAYSIZE(mime_image); x++) + UwacClipboardOfferCreate(clipboard->seat, mime_image[x]); + } + + UwacClipboardOfferAnnounce(clipboard->seat, clipboard, wlf_cliprdr_transfer_data, + wlf_cliprdr_cancel_data); + return wlf_cliprdr_send_client_format_list_response(clipboard, TRUE); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wlf_cliprdr_server_format_list_response(CliprdrClientContext* context, + const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse) +{ + WINPR_ASSERT(context); + WINPR_ASSERT(formatListResponse); + + if (formatListResponse->common.msgFlags & CB_RESPONSE_FAIL) + WLog_WARN(TAG, "format list update failed"); + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wlf_cliprdr_server_format_data_request(CliprdrClientContext* context, + const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest) +{ + UINT rc = CHANNEL_RC_OK; + char* data = NULL; + size_t size = 0; + const char* mime = NULL; + UINT32 formatId = 0; + UINT32 localFormatId = 0; + wfClipboard* clipboard = 0; + + UINT32 dsize = 0; + BYTE* ddata = NULL; + + WINPR_ASSERT(context); + WINPR_ASSERT(formatDataRequest); + + localFormatId = formatId = formatDataRequest->requestedFormatId; + clipboard = cliprdr_file_context_get_context(context->custom); + WINPR_ASSERT(clipboard); + + ClipboardLock(clipboard->system); + const UINT32 fileFormatId = ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW); + const UINT32 htmlFormatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat); + + switch (formatId) + { + case CF_TEXT: + case CF_OEMTEXT: + case CF_UNICODETEXT: + localFormatId = ClipboardGetFormatId(clipboard->system, mime_text_plain); + mime = mime_text_utf8; + break; + + case CF_DIB: + case CF_DIBV5: + mime = mime_bitmap[0]; + break; + + case CF_TIFF: + mime = mime_tiff; + break; + + default: + if (formatId == fileFormatId) + { + localFormatId = ClipboardGetFormatId(clipboard->system, mime_uri_list); + mime = mime_uri_list; + } + else if (formatId == htmlFormatId) + { + localFormatId = ClipboardGetFormatId(clipboard->system, mime_html); + mime = mime_html; + } + else + goto fail; + break; + } + + data = UwacClipboardDataGet(clipboard->seat, mime, &size); + + if (!data || (size > UINT32_MAX)) + goto fail; + + if (fileFormatId == formatId) + { + if (!cliprdr_file_context_update_client_data(clipboard->file, data, size)) + goto fail; + } + + const BOOL res = ClipboardSetData(clipboard->system, localFormatId, data, (UINT32)size); + free(data); + + UINT32 len = 0; + data = NULL; + if (res) + data = ClipboardGetData(clipboard->system, formatId, &len); + + if (!res || !data) + goto fail; + + if (fileFormatId == formatId) + { + const UINT32 flags = cliprdr_file_context_remote_get_flags(clipboard->file); + const UINT32 error = cliprdr_serialize_file_list_ex( + flags, (const FILEDESCRIPTORW*)data, len / sizeof(FILEDESCRIPTORW), &ddata, &dsize); + if (error) + goto fail; + } +fail: + ClipboardUnlock(clipboard->system); + rc = wlf_cliprdr_send_data_response(clipboard, ddata, dsize); + free(data); + return rc; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wlf_cliprdr_server_format_data_response(CliprdrClientContext* context, + const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse) +{ + UINT rc = ERROR_INTERNAL_ERROR; + + WINPR_ASSERT(context); + WINPR_ASSERT(formatDataResponse); + + const UINT32 size = formatDataResponse->common.dataLen; + const BYTE* data = formatDataResponse->requestedFormatData; + + wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom); + WINPR_ASSERT(clipboard); + + wlf_request* request = Queue_Dequeue(clipboard->request_queue); + if (!request) + goto fail; + + rc = CHANNEL_RC_OK; + if (formatDataResponse->common.msgFlags & CB_RESPONSE_FAIL) + { + WLog_WARN(TAG, "clipboard data request for format %" PRIu32 " [%s], mime %s failed", + request->responseFormat, ClipboardGetFormatIdString(request->responseFormat), + request->responseMime); + goto fail; + } + rc = ERROR_INTERNAL_ERROR; + + ClipboardLock(clipboard->system); + EnterCriticalSection(&clipboard->lock); + + BYTE* cdata = NULL; + UINT32 srcFormatId = 0; + UINT32 dstFormatId = 0; + switch (request->responseFormat) + { + case CF_TEXT: + case CF_OEMTEXT: + case CF_UNICODETEXT: + srcFormatId = request->responseFormat; + dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime); + break; + + case CF_DIB: + case CF_DIBV5: + srcFormatId = request->responseFormat; + dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime); + break; + + default: + { + const char* name = wlf_get_server_format_name(clipboard, request->responseFormat); + if (name) + { + if (strcmp(type_FileGroupDescriptorW, name) == 0) + { + srcFormatId = + ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW); + dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime); + + if (!cliprdr_file_context_update_server_data(clipboard->file, clipboard->system, + data, size)) + goto unlock; + } + else if (strcmp(type_HtmlFormat, name) == 0) + { + srcFormatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat); + dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime); + } + } + } + break; + } + + UINT32 len = 0; + + const BOOL sres = ClipboardSetData(clipboard->system, srcFormatId, data, size); + if (sres) + cdata = ClipboardGetData(clipboard->system, dstFormatId, &len); + + if (!sres || !cdata) + goto unlock; + + if (request->responseFile) + { + const size_t res = fwrite(cdata, 1, len, request->responseFile); + if (res == len) + rc = CHANNEL_RC_OK; + } + else + rc = CHANNEL_RC_OK; + +unlock: + free(cdata); + ClipboardUnlock(clipboard->system); + LeaveCriticalSection(&clipboard->lock); +fail: + wlf_request_free(request); + return rc; +} + +wfClipboard* wlf_clipboard_new(wlfContext* wfc) +{ + rdpChannels* channels = NULL; + wfClipboard* clipboard = NULL; + + WINPR_ASSERT(wfc); + + clipboard = (wfClipboard*)calloc(1, sizeof(wfClipboard)); + + if (!clipboard) + goto fail; + + InitializeCriticalSection(&clipboard->lock); + clipboard->wfc = wfc; + channels = wfc->common.context.channels; + clipboard->log = WLog_Get(TAG); + clipboard->channels = channels; + clipboard->system = ClipboardCreate(); + if (!clipboard->system) + goto fail; + + clipboard->file = cliprdr_file_context_new(clipboard); + if (!clipboard->file) + goto fail; + + if (!cliprdr_file_context_set_locally_available(clipboard->file, TRUE)) + goto fail; + + clipboard->request_queue = Queue_New(TRUE, -1, -1); + if (!clipboard->request_queue) + goto fail; + + wObject* obj = Queue_Object(clipboard->request_queue); + WINPR_ASSERT(obj); + obj->fnObjectFree = wlf_request_free; + obj->fnObjectNew = wlf_request_clone; + + return clipboard; + +fail: + wlf_clipboard_free(clipboard); + return NULL; +} + +void wlf_clipboard_free(wfClipboard* clipboard) +{ + if (!clipboard) + return; + + cliprdr_file_context_free(clipboard->file); + + wlf_cliprdr_free_server_formats(clipboard); + wlf_cliprdr_free_client_formats(clipboard); + ClipboardDestroy(clipboard->system); + + EnterCriticalSection(&clipboard->lock); + + Queue_Free(clipboard->request_queue); + LeaveCriticalSection(&clipboard->lock); + DeleteCriticalSection(&clipboard->lock); + free(clipboard); +} + +BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr) +{ + WINPR_ASSERT(clipboard); + WINPR_ASSERT(cliprdr); + + clipboard->context = cliprdr; + cliprdr->MonitorReady = wlf_cliprdr_monitor_ready; + cliprdr->ServerCapabilities = wlf_cliprdr_server_capabilities; + cliprdr->ServerFormatList = wlf_cliprdr_server_format_list; + cliprdr->ServerFormatListResponse = wlf_cliprdr_server_format_list_response; + cliprdr->ServerFormatDataRequest = wlf_cliprdr_server_format_data_request; + cliprdr->ServerFormatDataResponse = wlf_cliprdr_server_format_data_response; + + return cliprdr_file_context_init(clipboard->file, cliprdr); +} + +BOOL wlf_cliprdr_uninit(wfClipboard* clipboard, CliprdrClientContext* cliprdr) +{ + WINPR_ASSERT(clipboard); + if (!cliprdr_file_context_uninit(clipboard->file, cliprdr)) + return FALSE; + + if (cliprdr) + cliprdr->custom = NULL; + + return TRUE; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.h new file mode 100644 index 0000000000000000000000000000000000000000..07d58bcff9a8b8c99478caf69a312eaf0e40c7b5 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_cliprdr.h @@ -0,0 +1,36 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Clipboard Redirection + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WAYLAND_CLIPRDR_H +#define FREERDP_CLIENT_WAYLAND_CLIPRDR_H + +#include "wlfreerdp.h" + +#include + +wfClipboard* wlf_clipboard_new(wlfContext* wfc); +void wlf_clipboard_free(wfClipboard* clipboard); + +BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr); +BOOL wlf_cliprdr_uninit(wfClipboard* clipboard, CliprdrClientContext* cliprdr); + +BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event); + +#endif /* FREERDP_CLIENT_WAYLAND_CLIPRDR_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.c new file mode 100644 index 0000000000000000000000000000000000000000..741d7113bcbbd89a647e01106579e3570eb79908 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.c @@ -0,0 +1,458 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Display Control Channel + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "wlf_disp.h" + +#define TAG CLIENT_TAG("wayland.disp") + +#define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */ + +struct s_wlfDispContext +{ + wlfContext* wlc; + DispClientContext* disp; + BOOL haveXRandr; + int eventBase, errorBase; + int lastSentWidth, lastSentHeight; + UINT64 lastSentDate; + int targetWidth, targetHeight; + BOOL activated; + BOOL waitingResize; + BOOL fullscreen; + UINT16 lastSentDesktopOrientation; + UINT32 lastSentDesktopScaleFactor; + UINT32 lastSentDeviceScaleFactor; +}; + +static UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, + size_t nmonitors); + +static BOOL wlf_disp_settings_changed(wlfDispContext* wlfDisp) +{ + rdpSettings* settings = NULL; + + WINPR_ASSERT(wlfDisp); + WINPR_ASSERT(wlfDisp->wlc); + + settings = wlfDisp->wlc->common.context.settings; + WINPR_ASSERT(settings); + + if (wlfDisp->lastSentWidth != wlfDisp->targetWidth) + return TRUE; + + if (wlfDisp->lastSentHeight != wlfDisp->targetHeight) + return TRUE; + + if (wlfDisp->lastSentDesktopOrientation != + freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation)) + return TRUE; + + if (wlfDisp->lastSentDesktopScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor)) + return TRUE; + + if (wlfDisp->lastSentDeviceScaleFactor != + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor)) + return TRUE; + + if (wlfDisp->fullscreen != wlfDisp->wlc->fullscreen) + return TRUE; + + return FALSE; +} + +static BOOL wlf_update_last_sent(wlfDispContext* wlfDisp) +{ + rdpSettings* settings = NULL; + + WINPR_ASSERT(wlfDisp); + WINPR_ASSERT(wlfDisp->wlc); + + settings = wlfDisp->wlc->common.context.settings; + WINPR_ASSERT(settings); + + wlfDisp->lastSentWidth = wlfDisp->targetWidth; + wlfDisp->lastSentHeight = wlfDisp->targetHeight; + wlfDisp->lastSentDesktopOrientation = + freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + wlfDisp->lastSentDesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + wlfDisp->lastSentDeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); + wlfDisp->fullscreen = wlfDisp->wlc->fullscreen; + return TRUE; +} + +static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp) +{ + DISPLAY_CONTROL_MONITOR_LAYOUT layout; + wlfContext* wlc = NULL; + rdpSettings* settings = NULL; + + if (!wlfDisp || !wlfDisp->wlc) + return FALSE; + + wlc = wlfDisp->wlc; + settings = wlc->common.context.settings; + + if (!settings) + return FALSE; + + if (!wlfDisp->activated || !wlfDisp->disp) + return TRUE; + + if (GetTickCount64() - wlfDisp->lastSentDate < RESIZE_MIN_DELAY) + return TRUE; + + wlfDisp->lastSentDate = GetTickCount64(); + + if (!wlf_disp_settings_changed(wlfDisp)) + return TRUE; + + /* TODO: Multimonitor support for wayland + if (wlc->fullscreen && (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount > 0)) + { + if (wlf_disp_sendLayout(wlfDisp->disp, setings->MonitorDefArray, + freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) != + CHANNEL_RC_OK) return FALSE; + } + else + */ + { + wlfDisp->waitingResize = TRUE; + layout.Flags = DISPLAY_CONTROL_MONITOR_PRIMARY; + layout.Top = layout.Left = 0; + layout.Width = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth); + layout.Height = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight); + layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation); + layout.DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); + layout.PhysicalWidth = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth); + layout.PhysicalHeight = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight); + + if (IFCALLRESULT(CHANNEL_RC_OK, wlfDisp->disp->SendMonitorLayout, wlfDisp->disp, 1, + &layout) != CHANNEL_RC_OK) + return FALSE; + } + return wlf_update_last_sent(wlfDisp); +} + +static BOOL wlf_disp_set_window_resizable(wlfDispContext* wlfDisp) +{ +#if 0 // TODO +#endif + return TRUE; +} + +static BOOL wlf_disp_check_context(void* context, wlfContext** ppwlc, wlfDispContext** ppwlfDisp, + rdpSettings** ppSettings) +{ + wlfContext* wlc = NULL; + + if (!context) + return FALSE; + + wlc = (wlfContext*)context; + + if (!(wlc->disp)) + return FALSE; + + if (!wlc->common.context.settings) + return FALSE; + + *ppwlc = wlc; + *ppwlfDisp = wlc->disp; + *ppSettings = wlc->common.context.settings; + return TRUE; +} + +static void wlf_disp_OnActivated(void* context, const ActivatedEventArgs* e) +{ + wlfContext* wlc = NULL; + wlfDispContext* wlfDisp = NULL; + rdpSettings* settings = NULL; + + if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings)) + return; + + wlfDisp->waitingResize = FALSE; + + if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) + { + wlf_disp_set_window_resizable(wlfDisp); + + if (e->firstActivation) + return; + + wlf_disp_sendResize(wlfDisp); + } +} + +static void wlf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs* e) +{ + wlfContext* wlc = NULL; + wlfDispContext* wlfDisp = NULL; + rdpSettings* settings = NULL; + + WINPR_UNUSED(e); + if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings)) + return; + + wlfDisp->waitingResize = FALSE; + + if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) + { + wlf_disp_set_window_resizable(wlfDisp); + wlf_disp_sendResize(wlfDisp); + } +} + +static void wlf_disp_OnTimer(void* context, const TimerEventArgs* e) +{ + wlfContext* wlc = NULL; + wlfDispContext* wlfDisp = NULL; + rdpSettings* settings = NULL; + + WINPR_UNUSED(e); + if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings)) + return; + + if (!wlfDisp->activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) + return; + + wlf_disp_sendResize(wlfDisp); +} + +wlfDispContext* wlf_disp_new(wlfContext* wlc) +{ + wlfDispContext* ret = NULL; + wPubSub* pubSub = NULL; + rdpSettings* settings = NULL; + + if (!wlc || !wlc->common.context.settings || !wlc->common.context.pubSub) + return NULL; + + settings = wlc->common.context.settings; + pubSub = wlc->common.context.pubSub; + ret = calloc(1, sizeof(wlfDispContext)); + + if (!ret) + return NULL; + + ret->wlc = wlc; + ret->lastSentWidth = ret->targetWidth = + WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)); + ret->lastSentHeight = ret->targetHeight = + WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); + PubSub_SubscribeActivated(pubSub, wlf_disp_OnActivated); + PubSub_SubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset); + PubSub_SubscribeTimer(pubSub, wlf_disp_OnTimer); + return ret; +} + +void wlf_disp_free(wlfDispContext* disp) +{ + if (!disp) + return; + + if (disp->wlc) + { + wPubSub* pubSub = disp->wlc->common.context.pubSub; + PubSub_UnsubscribeActivated(pubSub, wlf_disp_OnActivated); + PubSub_UnsubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset); + PubSub_UnsubscribeTimer(pubSub, wlf_disp_OnTimer); + } + + free(disp); +} + +UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, size_t nmonitors) +{ + UINT ret = CHANNEL_RC_OK; + DISPLAY_CONTROL_MONITOR_LAYOUT* layouts = NULL; + wlfDispContext* wlfDisp = NULL; + rdpSettings* settings = NULL; + + WINPR_ASSERT(disp); + WINPR_ASSERT(monitors); + WINPR_ASSERT(nmonitors > 0); + WINPR_ASSERT(nmonitors <= UINT32_MAX); + + wlfDisp = (wlfDispContext*)disp->custom; + WINPR_ASSERT(wlfDisp); + WINPR_ASSERT(wlfDisp->wlc); + + settings = wlfDisp->wlc->common.context.settings; + WINPR_ASSERT(settings); + + layouts = calloc(nmonitors, sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT)); + + if (!layouts) + return CHANNEL_RC_NO_MEMORY; + + for (size_t i = 0; i < nmonitors; i++) + { + const rdpMonitor* monitor = &monitors[i]; + DISPLAY_CONTROL_MONITOR_LAYOUT* layout = &layouts[i]; + + layout->Flags = (monitor->is_primary ? DISPLAY_CONTROL_MONITOR_PRIMARY : 0); + layout->Left = monitor->x; + layout->Top = monitor->y; + layout->Width = WINPR_ASSERTING_INT_CAST(UINT32, monitor->width); + layout->Height = WINPR_ASSERTING_INT_CAST(UINT32, monitor->height); + layout->Orientation = ORIENTATION_LANDSCAPE; + layout->PhysicalWidth = monitor->attributes.physicalWidth; + layout->PhysicalHeight = monitor->attributes.physicalHeight; + + switch (monitor->attributes.orientation) + { + case 90: + layout->Orientation = ORIENTATION_PORTRAIT; + break; + + case 180: + layout->Orientation = ORIENTATION_LANDSCAPE_FLIPPED; + break; + + case 270: + layout->Orientation = ORIENTATION_PORTRAIT_FLIPPED; + break; + + case 0: + default: + /* MS-RDPEDISP - 2.2.2.2.1: + * Orientation (4 bytes): A 32-bit unsigned integer that specifies the + * orientation of the monitor in degrees. Valid values are 0, 90, 180 + * or 270 + * + * So we default to ORIENTATION_LANDSCAPE + */ + layout->Orientation = ORIENTATION_LANDSCAPE; + break; + } + + layout->DesktopScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); + layout->DeviceScaleFactor = + freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); + } + + ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, (UINT32)nmonitors, layouts); + free(layouts); + return ret; +} + +BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height) +{ + if (!disp) + return FALSE; + + disp->targetWidth = width; + disp->targetHeight = height; + return wlf_disp_sendResize(disp); +} + +static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors, + UINT32 maxMonitorAreaFactorA, UINT32 maxMonitorAreaFactorB) +{ + /* we're called only if dynamic resolution update is activated */ + wlfDispContext* wlfDisp = NULL; + rdpSettings* settings = NULL; + + WINPR_ASSERT(disp); + + wlfDisp = (wlfDispContext*)disp->custom; + WINPR_ASSERT(wlfDisp); + WINPR_ASSERT(wlfDisp->wlc); + + settings = wlfDisp->wlc->common.context.settings; + WINPR_ASSERT(settings); + + WLog_DBG(TAG, + "DisplayControlCapsPdu: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32 + " MaxMonitorAreaFactorB: %" PRIu32 "", + maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB); + wlfDisp->activated = TRUE; + + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) + return CHANNEL_RC_OK; + + WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable"); + return wlf_disp_set_window_resizable(wlfDisp) ? CHANNEL_RC_OK : CHANNEL_RC_NO_MEMORY; +} + +BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp) +{ + rdpSettings* settings = NULL; + + if (!wlfDisp || !wlfDisp->wlc || !disp) + return FALSE; + + settings = wlfDisp->wlc->common.context.settings; + + if (!settings) + return FALSE; + + wlfDisp->disp = disp; + disp->custom = (void*)wlfDisp; + + if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) + { + disp->DisplayControlCaps = wlf_DisplayControlCaps; + } + + return TRUE; +} + +BOOL wlf_disp_uninit(wlfDispContext* wlfDisp, DispClientContext* disp) +{ + if (!wlfDisp || !disp) + return FALSE; + + wlfDisp->disp = NULL; + return TRUE; +} + +int wlf_list_monitors(wlfContext* wlc) +{ + uint32_t nmonitors = UwacDisplayGetNbOutputs(wlc->display); + + for (uint32_t i = 0; i < nmonitors; i++) + { + const UwacOutput* monitor = + UwacDisplayGetOutput(wlc->display, WINPR_ASSERTING_INT_CAST(int, i)); + UwacSize resolution; + UwacPosition pos; + + if (!monitor) + continue; + UwacOutputGetPosition(monitor, &pos); + UwacOutputGetResolution(monitor, &resolution); + + printf(" %s [%u] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, resolution.width, + resolution.height, pos.x, pos.y); + } + + return 0; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.h new file mode 100644 index 0000000000000000000000000000000000000000..36fa27c7b21b59b572c870a7c9c4a05196cc9ae5 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_disp.h @@ -0,0 +1,38 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Display Control Channel + * + * Copyright 2018 Armin Novak + * Copyright 2018 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FREERDP_CLIENT_WAYLAND_DISP_H +#define FREERDP_CLIENT_WAYLAND_DISP_H + +#include +#include + +#include "wlfreerdp.h" + +FREERDP_API BOOL wlf_disp_init(wlfDispContext* xfDisp, DispClientContext* disp); +FREERDP_API BOOL wlf_disp_uninit(wlfDispContext* xfDisp, DispClientContext* disp); + +wlfDispContext* wlf_disp_new(wlfContext* wlc); +void wlf_disp_free(wlfDispContext* disp); +BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height); +void wlf_disp_resized(wlfDispContext* disp); + +int wlf_list_monitors(wlfContext* wlc); + +#endif /* FREERDP_CLIENT_WAYLAND_DISP_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.c new file mode 100644 index 0000000000000000000000000000000000000000..b56d0a9a9fb89de96155491b42e2edbf7e21723d --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.c @@ -0,0 +1,455 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Input + * + * Copyright 2014 Manuel Bachmann + * Copyright 2015 David Fort + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#include +#include + +#include +#include +#if defined(CHANNEL_RDPEI_CLIENT) +#include +#endif +#include + +#include "wlfreerdp.h" +#include "wlf_input.h" + +static BOOL scale_signed_coordinates(rdpContext* context, int32_t* x, int32_t* y, + BOOL fromLocalToRDP) +{ + BOOL rc = 0; + UINT32 ux = 0; + UINT32 uy = 0; + WINPR_ASSERT(context); + WINPR_ASSERT(x); + WINPR_ASSERT(y); + WINPR_ASSERT(*x >= 0); + WINPR_ASSERT(*y >= 0); + + ux = (UINT32)*x; + uy = (UINT32)*y; + rc = wlf_scale_coordinates(context, &ux, &uy, fromLocalToRDP); + WINPR_ASSERT(ux < INT32_MAX); + WINPR_ASSERT(uy < INT32_MAX); + *x = (int32_t)ux; + *y = (int32_t)uy; + return rc; +} + +BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev) +{ + uint32_t x = 0; + uint32_t y = 0; + rdpClientContext* cctx = NULL; + + if (!instance || !ev) + return FALSE; + + x = ev->x; + y = ev->y; + + if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + cctx = (rdpClientContext*)instance->context; + return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE, + WINPR_ASSERTING_INT_CAST(int, x), + WINPR_ASSERTING_INT_CAST(int, y)); +} + +BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev) +{ + rdpClientContext* cctx = NULL; + + if (!instance || !ev) + return FALSE; + + cctx = (rdpClientContext*)instance->context; + WINPR_ASSERT(cctx); + + uint32_t x = ev->x; + uint32_t y = ev->y; + + if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE, + WINPR_ASSERTING_INT_CAST(int32_t, x), + WINPR_ASSERTING_INT_CAST(int32_t, y)); +} + +BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev) +{ + rdpClientContext* cctx = NULL; + UINT16 flags = 0; + UINT16 xflags = 0; + + if (!instance || !ev) + return FALSE; + + cctx = (rdpClientContext*)instance->context; + WINPR_ASSERT(cctx); + + uint32_t x = ev->x; + uint32_t y = ev->y; + + if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + if (ev->state == WL_POINTER_BUTTON_STATE_PRESSED) + { + flags |= PTR_FLAGS_DOWN; + xflags |= PTR_XFLAGS_DOWN; + } + + switch (ev->button) + { + case BTN_LEFT: + flags |= PTR_FLAGS_BUTTON1; + break; + + case BTN_RIGHT: + flags |= PTR_FLAGS_BUTTON2; + break; + + case BTN_MIDDLE: + flags |= PTR_FLAGS_BUTTON3; + break; + + case BTN_SIDE: + xflags |= PTR_XFLAGS_BUTTON1; + break; + + case BTN_EXTRA: + xflags |= PTR_XFLAGS_BUTTON2; + break; + + default: + return TRUE; + } + + const INT32 cx = WINPR_ASSERTING_INT_CAST(int32_t, x); + const INT32 cy = WINPR_ASSERTING_INT_CAST(int32_t, y); + + if ((flags & ~PTR_FLAGS_DOWN) != 0) + return freerdp_client_send_button_event(cctx, FALSE, flags, cx, cy); + + if ((xflags & ~PTR_XFLAGS_DOWN) != 0) + return freerdp_client_send_extended_button_event(cctx, FALSE, xflags, cx, cy); + + return FALSE; +} + +BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev) +{ + wlfContext* context = NULL; + if (!instance || !instance->context || !ev) + return FALSE; + + context = (wlfContext*)instance->context; + return ArrayList_Append(context->events, ev); +} + +BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev) +{ + wlfContext* context = NULL; + if (!instance || !instance->context || !ev) + return FALSE; + + context = (wlfContext*)instance->context; + return ArrayList_Append(context->events, ev); +} + +static BOOL wlf_handle_wheel(freerdp* instance, uint32_t x, uint32_t y, uint32_t axis, + int32_t value) +{ + rdpClientContext* cctx = NULL; + UINT16 flags = 0; + int32_t direction = 0; + uint32_t avalue = (uint32_t)abs(value); + + WINPR_ASSERT(instance); + + cctx = (rdpClientContext*)instance->context; + WINPR_ASSERT(cctx); + + if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + direction = value; + switch (axis) + { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + flags |= PTR_FLAGS_WHEEL; + if (direction > 0) + flags |= PTR_FLAGS_WHEEL_NEGATIVE; + break; + + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + flags |= PTR_FLAGS_HWHEEL; + if (direction < 0) + flags |= PTR_FLAGS_WHEEL_NEGATIVE; + break; + + default: + return FALSE; + } + + /* Wheel rotation steps: + * + * positive: 0 ... 0xFF -> slow ... fast + * negative: 0 ... 0xFF -> fast ... slow + */ + + while (avalue > 0) + { + const UINT16 cval = (avalue > 0xFF) ? 0xFF : (UINT16)avalue; + UINT16 cflags = flags | cval; + /* Convert negative values to 9bit twos complement */ + if (flags & PTR_FLAGS_WHEEL_NEGATIVE) + cflags = (flags & 0xFF00) | (0x100 - cval); + if (!freerdp_client_send_wheel_event(cctx, cflags)) + return FALSE; + + avalue -= cval; + } + return TRUE; +} + +BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev) +{ + BOOL success = TRUE; + BOOL handle = FALSE; + wlfContext* context = NULL; + enum wl_pointer_axis_source source = WL_POINTER_AXIS_SOURCE_CONTINUOUS; + + if (!instance || !ev || !instance->context) + return FALSE; + + context = (wlfContext*)instance->context; + + for (size_t x = 0; x < ArrayList_Count(context->events); x++) + { + UwacEvent* cev = ArrayList_GetItem(context->events, x); + if (!cev) + continue; + if (cev->type == UWAC_EVENT_POINTER_SOURCE) + { + handle = TRUE; + source = cev->mouse_source.axis_source; + } + } + + /* We need source events to determine how to interpret the data */ + if (handle) + { + for (size_t x = 0; x < ArrayList_Count(context->events); x++) + { + UwacEvent* cev = ArrayList_GetItem(context->events, x); + if (!cev) + continue; + + switch (source) + { + /* If we have a mouse wheel, just use discrete data */ + case WL_POINTER_AXIS_SOURCE_WHEEL: +#if defined(WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION) + case WL_POINTER_AXIS_SOURCE_WHEEL_TILT: +#endif + if (cev->type == UWAC_EVENT_POINTER_AXIS_DISCRETE) + { + /* Get the number of steps, multiply by default step width of 120 */ + int32_t val = cev->mouse_axis.value * 0x78; + /* No wheel event received, success! */ + if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y, + cev->mouse_axis.axis, val)) + success = FALSE; + } + break; + /* If we have a touch pad we get actual data, scale */ + case WL_POINTER_AXIS_SOURCE_FINGER: + case WL_POINTER_AXIS_SOURCE_CONTINUOUS: + if (cev->type == UWAC_EVENT_POINTER_AXIS) + { + double dval = wl_fixed_to_double(cev->mouse_axis.value); + int32_t val = (int32_t)(dval * 0x78 / 10.0); + if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y, + cev->mouse_axis.axis, val)) + success = FALSE; + } + break; + default: + break; + } + } + } + ArrayList_Clear(context->events); + return success; +} + +BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev) +{ + wlfContext* context = NULL; + if (!instance || !instance->context || !ev) + return FALSE; + + context = (wlfContext*)instance->context; + return ArrayList_Append(context->events, ev); +} + +BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev) +{ + if (!instance || !ev) + return FALSE; + + WINPR_ASSERT(instance->context); + wlfContext* ctx = (wlfContext*)instance->context; + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard) && + ev->raw_key == KEY_RIGHTCTRL) + wlf_handle_ungrab_key(instance, ev); + + rdpInput* input = instance->context->input; + + const DWORD vc = GetVirtualKeyCodeFromKeycode(ev->raw_key, WINPR_KEYCODE_TYPE_EVDEV); + const DWORD sc = GetVirtualScanCodeFromVirtualKeyCode(vc, WINPR_KBD_TYPE_IBM_ENHANCED); + const DWORD rdp_scancode = freerdp_keyboard_remap_key(ctx->remap_table, sc); + + if (rdp_scancode == RDP_SCANCODE_UNKNOWN) + return TRUE; + + return freerdp_input_send_keyboard_event_ex(input, ev->pressed, ev->repeated, rdp_scancode); +} + +BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev) +{ + wlfContext* context = NULL; + if (!instance || !instance->context || !ev) + return FALSE; + + context = (wlfContext*)instance->context; + + return UwacSeatInhibitShortcuts(context->seat, false) == UWAC_SUCCESS; +} + +BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev) +{ + if (!instance || !ev) + return FALSE; + + ((wlfContext*)instance->context)->focusing = TRUE; + return TRUE; +} + +BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev) +{ + rdpInput* input = NULL; + UINT16 syncFlags = 0; + wlfContext* wlf = NULL; + + if (!instance || !ev) + return FALSE; + + wlf = (wlfContext*)instance->context; + WINPR_ASSERT(wlf); + + input = instance->context->input; + WINPR_ASSERT(input); + + syncFlags = 0; + + if (ev->modifiers & UWAC_MOD_CAPS_MASK) + syncFlags |= KBD_SYNC_CAPS_LOCK; + if (ev->modifiers & UWAC_MOD_NUM_MASK) + syncFlags |= KBD_SYNC_NUM_LOCK; + + if (!wlf->focusing) + return TRUE; + + ((wlfContext*)instance->context)->focusing = FALSE; + + return freerdp_input_send_focus_in_event(input, syncFlags) && + freerdp_client_send_button_event(&wlf->common, FALSE, PTR_FLAGS_MOVE, 0, 0); +} + +BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev) +{ + int32_t x = 0; + int32_t y = 0; + + WINPR_ASSERT(instance); + WINPR_ASSERT(ev); + + wlfContext* wlf = (wlfContext*)instance->context; + WINPR_ASSERT(wlf); + + x = ev->x; + y = ev->y; + + if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_UP, ev->id, 0, x, y); +} + +BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev) +{ + int32_t x = 0; + int32_t y = 0; + + WINPR_ASSERT(instance); + WINPR_ASSERT(ev); + + wlfContext* wlf = (wlfContext*)instance->context; + WINPR_ASSERT(wlf); + + x = ev->x; + y = ev->y; + + if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_DOWN, ev->id, 0, x, y); +} + +BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev) +{ + int32_t x = 0; + int32_t y = 0; + + WINPR_ASSERT(instance); + WINPR_ASSERT(ev); + + wlfContext* wlf = (wlfContext*)instance->context; + WINPR_ASSERT(wlf); + + x = ev->x; + y = ev->y; + + if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) + return FALSE; + + return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_MOTION, 0, + WINPR_ASSERTING_INT_CAST(uint32_t, ev->id), x, y); +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.h new file mode 100644 index 0000000000000000000000000000000000000000..0d4f5efa25581930cc2b90f7539c99f52e08c22f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_input.h @@ -0,0 +1,45 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Input + * + * Copyright 2014 Manuel Bachmann + * Copyright 2015 David Fort + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WAYLAND_INPUT_H +#define FREERDP_CLIENT_WAYLAND_INPUT_H + +#include +#include +#include +#include + +BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev); +BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev); +BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev); +BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev); +BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev); +BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev); +BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev); +BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev); +BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev); +BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev); + +BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev); +BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev); +BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev); +BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev); + +#endif /* FREERDP_CLIENT_WAYLAND_INPUT_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.c new file mode 100644 index 0000000000000000000000000000000000000000..eebc4ba198276ab6dc1b96d39218bb94cc9dbbaa --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.c @@ -0,0 +1,167 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Mouse Pointer + * + * Copyright 2019 Armin Novak + * Copyright 2019 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "wlf_pointer.h" +#include "wlfreerdp.h" + +#define TAG CLIENT_TAG("wayland.pointer") + +typedef struct +{ + rdpPointer pointer; + size_t size; + void* data; +} wlfPointer; + +static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer) +{ + wlfPointer* ptr = (wlfPointer*)pointer; + + if (!ptr) + return FALSE; + + ptr->size = 4ULL * pointer->width * pointer->height; + ptr->data = winpr_aligned_malloc(ptr->size, 16); + + if (!ptr->data) + return FALSE; + + if (!freerdp_image_copy_from_pointer_data( + ptr->data, PIXEL_FORMAT_BGRA32, 0, 0, 0, pointer->width, pointer->height, + pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData, + pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette)) + { + winpr_aligned_free(ptr->data); + return FALSE; + } + + return TRUE; +} + +static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer) +{ + wlfPointer* ptr = (wlfPointer*)pointer; + WINPR_UNUSED(context); + + if (ptr) + winpr_aligned_free(ptr->data); +} + +static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer) +{ + wlfContext* wlf = (wlfContext*)context; + wlfPointer* ptr = (wlfPointer*)pointer; + void* data = NULL; + UINT32 w = 0; + UINT32 h = 0; + UINT32 x = 0; + UINT32 y = 0; + size_t size = 0; + UwacReturnCode rc = UWAC_ERROR_INTERNAL; + BOOL res = FALSE; + RECTANGLE_16 area; + + if (!wlf || !wlf->seat) + return FALSE; + + x = pointer->xPos; + y = pointer->yPos; + w = pointer->width; + h = pointer->height; + + if (!wlf_scale_coordinates(context, &x, &y, FALSE) || + !wlf_scale_coordinates(context, &w, &h, FALSE)) + return FALSE; + + size = 4ULL * w * h; + data = malloc(size); + + if (!data) + return FALSE; + + area.top = 0; + area.left = 0; + area.right = (UINT16)pointer->width; + area.bottom = (UINT16)pointer->height; + + if (!wlf_copy_image(ptr->data, 4ULL * pointer->width, pointer->width, pointer->height, data, + 4ULL * w, w, h, &area, + freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))) + goto fail; + + rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y); + + if (rc == UWAC_SUCCESS) + res = TRUE; + +fail: + free(data); + return res; +} + +static BOOL wlf_Pointer_SetNull(rdpContext* context) +{ + wlfContext* wlf = (wlfContext*)context; + + if (!wlf || !wlf->seat) + return FALSE; + + if (UwacSeatSetMouseCursor(wlf->seat, NULL, 0, 0, 0, 0, 0) != UWAC_SUCCESS) + return FALSE; + + return TRUE; +} + +static BOOL wlf_Pointer_SetDefault(rdpContext* context) +{ + wlfContext* wlf = (wlfContext*)context; + + if (!wlf || !wlf->seat) + return FALSE; + + if (UwacSeatSetMouseCursor(wlf->seat, NULL, 1, 0, 0, 0, 0) != UWAC_SUCCESS) + return FALSE; + + return TRUE; +} + +static BOOL wlf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) +{ + // TODO + WLog_WARN(TAG, "not implemented"); + return TRUE; +} + +BOOL wlf_register_pointer(rdpGraphics* graphics) +{ + rdpPointer pointer = { 0 }; + + pointer.size = sizeof(wlfPointer); + pointer.New = wlf_Pointer_New; + pointer.Free = wlf_Pointer_Free; + pointer.Set = wlf_Pointer_Set; + pointer.SetNull = wlf_Pointer_SetNull; + pointer.SetDefault = wlf_Pointer_SetDefault; + pointer.SetPosition = wlf_Pointer_SetPosition; + graphics_register_pointer(graphics, &pointer); + return TRUE; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.h new file mode 100644 index 0000000000000000000000000000000000000000..8ae82e1d5778d57862db5f5698ded0cc642754ae --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlf_pointer.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Mouse Pointer + * + * Copyright 2019 Armin Novak + * Copyright 2019 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WAYLAND_POINTER_H +#define FREERDP_CLIENT_WAYLAND_POINTER_H + +#include + +BOOL wlf_register_pointer(rdpGraphics* graphics); + +#endif /* FREERDP_CLIENT_WAYLAND_POINTER_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.1.in b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.1.in new file mode 100644 index 0000000000000000000000000000000000000000..ee4041289d97d1e345ed32ee77e0cf304a0d74f8 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.1.in @@ -0,0 +1,38 @@ +.de URL +\\$2 \(laURL: \\$1 \(ra\\$3 +.. +.if \n[.g] .mso www.tmac +.TH @MANPAGE_NAME@ 1 2017-01-12 "@FREERDP_VERSION_FULL@" "FreeRDP" +.SH NAME +@MANPAGE_NAME@ \- FreeRDP wayland client +.SH SYNOPSIS +.B @MANPAGE_NAME@ +[file] +[\fIdefault_client_options\fP] +[\fB/v\fP:[:port]] +[\fB/version\fP] +[\fB/help\fP] +.SH DESCRIPTION +.B @MANPAGE_NAME@ +is a wayland Remote Desktop Protocol (RDP) client which is part of the FreeRDP project. A RDP server is built-in to many editions of Windows.. Alternative servers included ogon, gnome-remote-desktop, xrdp and VRDP (VirtualBox). +.SH OPTIONS +The wayland client also supports a lot of the \fIdefault client options\fP which are not described here. For details on those see the xfreerdp(1) man page. +.IP \fB/v:\fP\fI[:port]\fP +The server hostname or IP, and optionally the port, to connect to. +.IP /version +Print the version and exit. +.IP /help +Print the help and exit. +.SH EXIT STATUS +.TP +.B 0 +Successful program execution. +.TP +.B not 0 +On failure. + +.SH SEE ALSO +xfreerdp(1) wlog(7) + +.SH AUTHOR +FreeRDP diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.c b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.c new file mode 100644 index 0000000000000000000000000000000000000000..15d71f258816aae96b152aaee002517dacc08b43 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.c @@ -0,0 +1,815 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Client + * + * Copyright 2014 Manuel Bachmann + * Copyright 2016 Thincast Technologies GmbH + * Copyright 2016 Armin Novak + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "wlfreerdp.h" +#include "wlf_input.h" +#include "wlf_cliprdr.h" +#include "wlf_disp.h" +#include "wlf_channels.h" +#include "wlf_pointer.h" + +#define TAG CLIENT_TAG("wayland") + +static BOOL wl_update_buffer(wlfContext* context_w, INT32 ix, INT32 iy, INT32 iw, INT32 ih) +{ + BOOL res = FALSE; + rdpGdi* gdi = NULL; + char* data = NULL; + UwacSize geometry = { 0 }; + size_t stride = 0; + UwacReturnCode rc = UWAC_ERROR_INTERNAL; + RECTANGLE_16 area = { 0 }; + + if (!context_w) + return FALSE; + + if ((ix < 0) || (iy < 0) || (iw < 0) || (ih < 0)) + return FALSE; + + EnterCriticalSection(&context_w->critical); + UINT32 x = WINPR_ASSERTING_INT_CAST(UINT16, ix); + UINT32 y = WINPR_ASSERTING_INT_CAST(UINT16, iy); + UINT32 w = WINPR_ASSERTING_INT_CAST(UINT16, iw); + UINT32 h = WINPR_ASSERTING_INT_CAST(UINT16, ih); + rc = UwacWindowGetDrawingBufferGeometry(context_w->window, &geometry, &stride); + data = UwacWindowGetDrawingBuffer(context_w->window); + + if (!data || (rc != UWAC_SUCCESS)) + goto fail; + + gdi = context_w->common.context.gdi; + + if (!gdi) + goto fail; + + /* Ignore output if the surface size does not match. */ + if (((INT64)x > geometry.width) || ((INT64)y > geometry.height)) + { + res = TRUE; + goto fail; + } + + area.left = WINPR_ASSERTING_INT_CAST(UINT16, x); + area.top = WINPR_ASSERTING_INT_CAST(UINT16, y); + area.right = WINPR_ASSERTING_INT_CAST(UINT16, x + w); + area.bottom = WINPR_ASSERTING_INT_CAST(UINT16, y + h); + + if (!wlf_copy_image( + gdi->primary_buffer, gdi->stride, WINPR_ASSERTING_INT_CAST(size_t, gdi->width), + WINPR_ASSERTING_INT_CAST(size_t, gdi->height), data, stride, + WINPR_ASSERTING_INT_CAST(size_t, geometry.width), + WINPR_ASSERTING_INT_CAST(size_t, geometry.height), &area, + freerdp_settings_get_bool(context_w->common.context.settings, FreeRDP_SmartSizing))) + goto fail; + + if (!wlf_scale_coordinates(&context_w->common.context, &x, &y, FALSE)) + goto fail; + + if (!wlf_scale_coordinates(&context_w->common.context, &w, &h, FALSE)) + goto fail; + + if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS) + goto fail; + + if (UwacWindowSubmitBuffer(context_w->window, false) != UWAC_SUCCESS) + goto fail; + + res = TRUE; +fail: + LeaveCriticalSection(&context_w->critical); + return res; +} + +static BOOL wl_end_paint(rdpContext* context) +{ + rdpGdi* gdi = NULL; + wlfContext* context_w = NULL; + INT32 x = 0; + INT32 y = 0; + INT32 w = 0; + INT32 h = 0; + + if (!context || !context->gdi || !context->gdi->primary) + return FALSE; + + gdi = context->gdi; + + if (gdi->primary->hdc->hwnd->invalid->null) + return TRUE; + + x = gdi->primary->hdc->hwnd->invalid->x; + y = gdi->primary->hdc->hwnd->invalid->y; + w = gdi->primary->hdc->hwnd->invalid->w; + h = gdi->primary->hdc->hwnd->invalid->h; + context_w = (wlfContext*)context; + if (!wl_update_buffer(context_w, x, y, w, h)) + { + return FALSE; + } + + gdi->primary->hdc->hwnd->invalid->null = TRUE; + gdi->primary->hdc->hwnd->ninvalid = 0; + return TRUE; +} + +static BOOL wl_refresh_display(wlfContext* context) +{ + rdpGdi* gdi = NULL; + + if (!context || !context->common.context.gdi) + return FALSE; + + gdi = context->common.context.gdi; + return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); +} + +static BOOL wl_resize_display(rdpContext* context) +{ + wlfContext* wlc = (wlfContext*)context; + rdpGdi* gdi = context->gdi; + rdpSettings* settings = context->settings; + + if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))) + return FALSE; + + return wl_refresh_display(wlc); +} + +static BOOL wl_pre_connect(freerdp* instance) +{ + rdpSettings* settings = NULL; + wlfContext* context = NULL; + const UwacOutput* output = NULL; + UwacSize resolution; + + if (!instance) + return FALSE; + + context = (wlfContext*)instance->context; + WINPR_ASSERT(context); + + settings = instance->context->settings; + WINPR_ASSERT(settings); + + if (!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, TRUE)) + return FALSE; + + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_WAYLAND)) + return FALSE; + PubSub_SubscribeChannelConnected(instance->context->pubSub, wlf_OnChannelConnectedEventHandler); + PubSub_SubscribeChannelDisconnected(instance->context->pubSub, + wlf_OnChannelDisconnectedEventHandler); + + if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)) + { + // Use the resolution of the first display output + output = UwacDisplayGetOutput(context->display, 0); + + if ((output != NULL) && (UwacOutputGetResolution(output, &resolution) == UWAC_SUCCESS)) + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, + (UINT32)resolution.width)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, + (UINT32)resolution.height)) + return FALSE; + } + else + { + WLog_WARN(TAG, "Failed to get output resolution! Check your display settings"); + } + } + + return TRUE; +} + +static BOOL wl_post_connect(freerdp* instance) +{ + if (!instance || !instance->context) + return FALSE; + + wlfContext* context = (wlfContext*)instance->context; + WINPR_ASSERT(context); + + rdpSettings* settings = instance->context->settings; + WINPR_ASSERT(settings); + + const char* title = "FreeRDP"; + const char* wtitle = freerdp_settings_get_string(settings, FreeRDP_WindowTitle); + if (wtitle) + title = wtitle; + + const char* app_id = "wlfreerdp"; + const char* wmclass = freerdp_settings_get_string(settings, FreeRDP_WmClass); + if (wmclass) + app_id = wmclass; + + if (!gdi_init(instance, PIXEL_FORMAT_BGRA32)) + return FALSE; + + rdpGdi* gdi = instance->context->gdi; + + if (!gdi || (gdi->width < 0) || (gdi->height < 0)) + return FALSE; + + if (!wlf_register_pointer(instance->context->graphics)) + return FALSE; + + UINT32 w = (UINT32)gdi->width; + UINT32 h = (UINT32)gdi->height; + + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !context->fullscreen) + { + const UINT32 sw = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); + if (sw > 0) + w = sw; + + const UINT32 sh = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); + if (sh > 0) + h = sh; + } + + context->window = UwacCreateWindowShm(context->display, w, h, WL_SHM_FORMAT_XRGB8888); + + if (!context->window) + return FALSE; + + UwacWindowSetFullscreenState( + context->window, NULL, + freerdp_settings_get_bool(instance->context->settings, FreeRDP_Fullscreen)); + UwacWindowSetTitle(context->window, title); + UwacWindowSetAppId(context->window, app_id); + UwacWindowSetOpaqueRegion(context->window, 0, 0, w, h); + instance->context->update->EndPaint = wl_end_paint; + instance->context->update->DesktopResize = wl_resize_display; + const char* KeyboardRemappingList = + freerdp_settings_get_string(instance->context->settings, FreeRDP_KeyboardRemappingList); + + context->remap_table = freerdp_keyboard_remap_string_to_list(KeyboardRemappingList); + if (!context->remap_table) + return FALSE; + + if (!(context->disp = wlf_disp_new(context))) + return FALSE; + + context->clipboard = wlf_clipboard_new(context); + + if (!context->clipboard) + return FALSE; + + return wl_refresh_display(context); +} + +static void wl_post_disconnect(freerdp* instance) +{ + if (!instance) + return; + + if (!instance->context) + return; + + wlfContext* context = (wlfContext*)instance->context; + gdi_free(instance); + wlf_clipboard_free(context->clipboard); + wlf_disp_free(context->disp); + + if (context->window) + UwacDestroyWindow(&context->window); + freerdp_keyboard_remap_free(context->remap_table); + context->remap_table = NULL; +} + +static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) +{ + UwacEvent event; + wlfContext* context = NULL; + + if (UwacDisplayDispatch(display, 1) < 0) + return FALSE; + + context = (wlfContext*)instance->context; + + while (UwacHasEvent(display)) + { + if (UwacNextEvent(display, &event) != UWAC_SUCCESS) + return FALSE; + + /*printf("UWAC event type %d\n", event.type);*/ + switch (event.type) + { + case UWAC_EVENT_NEW_SEAT: + context->seat = event.seat_new.seat; + break; + + case UWAC_EVENT_REMOVED_SEAT: + context->seat = NULL; + break; + + case UWAC_EVENT_FRAME_DONE: + { + EnterCriticalSection(&context->critical); + UwacReturnCode r = UwacWindowSubmitBuffer(context->window, false); + LeaveCriticalSection(&context->critical); + if (r != UWAC_SUCCESS) + return FALSE; + } + break; + + case UWAC_EVENT_POINTER_ENTER: + if (!wlf_handle_pointer_enter(instance, &event.mouse_enter_leave)) + return FALSE; + + break; + + case UWAC_EVENT_POINTER_MOTION: + if (!wlf_handle_pointer_motion(instance, &event.mouse_motion)) + return FALSE; + + break; + + case UWAC_EVENT_POINTER_BUTTONS: + if (!wlf_handle_pointer_buttons(instance, &event.mouse_button)) + return FALSE; + + break; + + case UWAC_EVENT_POINTER_AXIS: + if (!wlf_handle_pointer_axis(instance, &event.mouse_axis)) + return FALSE; + break; + + case UWAC_EVENT_POINTER_AXIS_DISCRETE: + if (!wlf_handle_pointer_axis_discrete(instance, &event.mouse_axis)) + return FALSE; + break; + + case UWAC_EVENT_POINTER_FRAME: + if (!wlf_handle_pointer_frame(instance, &event.mouse_frame)) + return FALSE; + break; + case UWAC_EVENT_POINTER_SOURCE: + if (!wlf_handle_pointer_source(instance, &event.mouse_source)) + return FALSE; + break; + + case UWAC_EVENT_KEY: + if (!wlf_handle_key(instance, &event.key)) + return FALSE; + + break; + + case UWAC_EVENT_TOUCH_UP: + if (!wlf_handle_touch_up(instance, &event.touchUp)) + return FALSE; + + break; + + case UWAC_EVENT_TOUCH_DOWN: + if (!wlf_handle_touch_down(instance, &event.touchDown)) + return FALSE; + + break; + + case UWAC_EVENT_TOUCH_MOTION: + if (!wlf_handle_touch_motion(instance, &event.touchMotion)) + return FALSE; + + break; + + case UWAC_EVENT_KEYBOARD_ENTER: + if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard)) + UwacSeatInhibitShortcuts(event.keyboard_enter_leave.seat, true); + + if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave)) + return FALSE; + + break; + + case UWAC_EVENT_KEYBOARD_MODIFIERS: + if (!wlf_keyboard_modifiers(instance, &event.keyboard_modifiers)) + return FALSE; + + break; + + case UWAC_EVENT_CONFIGURE: + if (!wlf_disp_handle_configure(context->disp, event.configure.width, + event.configure.height)) + return FALSE; + + if (!wl_refresh_display(context)) + return FALSE; + + break; + + case UWAC_EVENT_CLIPBOARD_AVAILABLE: + case UWAC_EVENT_CLIPBOARD_OFFER: + case UWAC_EVENT_CLIPBOARD_SELECT: + if (!wlf_cliprdr_handle_event(context->clipboard, &event.clipboard)) + return FALSE; + + break; + + case UWAC_EVENT_CLOSE: + context->closed = TRUE; + + break; + + default: + break; + } + } + + return TRUE; +} + +static BOOL handle_window_events(freerdp* instance) +{ + if (!instance) + return FALSE; + + return TRUE; +} + +static int wlfreerdp_run(freerdp* instance) +{ + wlfContext* context = NULL; + HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 }; + DWORD status = WAIT_ABANDONED; + HANDLE timer = NULL; + LARGE_INTEGER due = { 0 }; + + TimerEventArgs timerEvent; + EventArgsInit(&timerEvent, "xfreerdp"); + + if (!instance) + return -1; + + context = (wlfContext*)instance->context; + + if (!context) + return -1; + + if (!freerdp_connect(instance)) + { + WLog_Print(context->log, WLOG_ERROR, "Failed to connect"); + return -1; + } + + timer = CreateWaitableTimerA(NULL, FALSE, "mainloop-periodic-timer"); + + if (!timer) + { + WLog_ERR(TAG, "failed to create timer"); + goto disconnect; + } + + due.QuadPart = 0; + + if (!SetWaitableTimer(timer, &due, 20, NULL, NULL, FALSE)) + { + goto disconnect; + } + + while (!freerdp_shall_disconnect_context(instance->context)) + { + DWORD count = 0; + handles[count++] = timer; + handles[count++] = context->displayHandle; + count += freerdp_get_event_handles(instance->context, &handles[count], + ARRAYSIZE(handles) - count); + + if (count <= 2) + { + WLog_Print(context->log, WLOG_ERROR, "Failed to get FreeRDP file descriptor"); + break; + } + + status = WaitForMultipleObjects(count, handles, FALSE, INFINITE); + + if (WAIT_FAILED == status) + { + WLog_Print(context->log, WLOG_ERROR, "WaitForMultipleObjects failed"); + break; + } + + if (!handle_uwac_events(instance, context->display)) + { + WLog_Print(context->log, WLOG_ERROR, "error handling UWAC events"); + break; + } + + if (context->closed) + { + WLog_Print(context->log, WLOG_INFO, "Closed from Wayland"); + break; + } + + if (freerdp_check_event_handles(instance->context) != TRUE) + { + if (client_auto_reconnect_ex(instance, handle_window_events)) + continue; + else + { + /* + * Indicate an unsuccessful connection attempt if reconnect + * did not succeed and no other error was specified. + */ + if (freerdp_error_info(instance) == 0) + status = 42; + } + + if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SUCCESS) + WLog_Print(context->log, WLOG_ERROR, "Failed to check FreeRDP file descriptor"); + + break; + } + + if ((status != WAIT_TIMEOUT) && (status == WAIT_OBJECT_0)) + { + timerEvent.now = GetTickCount64(); + PubSub_OnTimer(context->common.context.pubSub, context, &timerEvent); + } + } + +disconnect: + if (timer) + (void)CloseHandle(timer); + freerdp_disconnect(instance); + return WINPR_ASSERTING_INT_CAST(int, status); +} + +static BOOL wlf_client_global_init(void) +{ + // NOLINTNEXTLINE(concurrency-mt-unsafe) + (void)setlocale(LC_ALL, ""); + + if (freerdp_handle_signals() != 0) + return FALSE; + + return TRUE; +} + +static void wlf_client_global_uninit(void) +{ +} + +static int wlf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type) +{ + wlfContext* wlf = NULL; + const char* str_data = freerdp_get_logon_error_info_data(data); + const char* str_type = freerdp_get_logon_error_info_type(type); + + if (!instance || !instance->context) + return -1; + + wlf = (wlfContext*)instance->context; + WLog_Print(wlf->log, WLOG_INFO, "Logon Error Info %s [%s]", str_data, str_type); + return 1; +} + +static void wlf_client_free(freerdp* instance, rdpContext* context) +{ + wlfContext* wlf = (wlfContext*)instance->context; + + if (!context) + return; + + if (wlf->display) + UwacCloseDisplay(&wlf->display); + + if (wlf->displayHandle) + (void)CloseHandle(wlf->displayHandle); + ArrayList_Free(wlf->events); + DeleteCriticalSection(&wlf->critical); +} + +static void* uwac_event_clone(const void* val) +{ + UwacEvent* copy = NULL; + const UwacEvent* ev = (const UwacEvent*)val; + + copy = calloc(1, sizeof(UwacEvent)); + if (!copy) + return NULL; + *copy = *ev; + return copy; +} + +static BOOL wlf_client_new(freerdp* instance, rdpContext* context) +{ + wObject* obj = NULL; + UwacReturnCode status = UWAC_ERROR_INTERNAL; + wlfContext* wfl = (wlfContext*)context; + + if (!instance || !context) + return FALSE; + + instance->PreConnect = wl_pre_connect; + instance->PostConnect = wl_post_connect; + instance->PostDisconnect = wl_post_disconnect; + instance->LogonErrorInfo = wlf_logon_error_info; + wfl->log = WLog_Get(TAG); + wfl->display = UwacOpenDisplay(NULL, &status); + + if (!wfl->display || (status != UWAC_SUCCESS) || !wfl->log) + return FALSE; + + wfl->displayHandle = CreateFileDescriptorEvent(NULL, FALSE, FALSE, + UwacDisplayGetFd(wfl->display), WINPR_FD_READ); + + if (!wfl->displayHandle) + return FALSE; + + wfl->events = ArrayList_New(FALSE); + if (!wfl->events) + return FALSE; + + obj = ArrayList_Object(wfl->events); + obj->fnObjectNew = uwac_event_clone; + obj->fnObjectFree = free; + + InitializeCriticalSection(&wfl->critical); + + return TRUE; +} + +static int wfl_client_start(rdpContext* context) +{ + WINPR_UNUSED(context); + return 0; +} + +static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) +{ + WINPR_ASSERT(pEntryPoints); + ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS)); + pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION; + pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1); + pEntryPoints->GlobalInit = wlf_client_global_init; + pEntryPoints->GlobalUninit = wlf_client_global_uninit; + pEntryPoints->ContextSize = sizeof(wlfContext); + pEntryPoints->ClientNew = wlf_client_new; + pEntryPoints->ClientFree = wlf_client_free; + pEntryPoints->ClientStart = wfl_client_start; + pEntryPoints->ClientStop = freerdp_client_common_stop; + return 0; +} + +int main(int argc, char* argv[]) +{ + int rc = -1; + int status = 0; + RDP_CLIENT_ENTRY_POINTS clientEntryPoints; + rdpContext* context = NULL; + rdpSettings* settings = NULL; + wlfContext* wlc = NULL; + + freerdp_client_warn_deprecated(argc, argv); + + RdpClientEntry(&clientEntryPoints); + context = freerdp_client_context_new(&clientEntryPoints); + if (!context) + goto fail; + wlc = (wlfContext*)context; + settings = context->settings; + + status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE); + if (status) + { + rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv); + + if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors)) + wlf_list_monitors(wlc); + + goto fail; + } + + if (freerdp_client_start(context) != 0) + goto fail; + + rc = wlfreerdp_run(context->instance); + + if (freerdp_client_stop(context) != 0) + rc = -1; + +fail: + freerdp_client_context_free(context); + return rc; +} + +BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst, + size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area, + BOOL scale) +{ + BOOL rc = FALSE; + + if (!src || !dst || !area) + return FALSE; + + if (scale) + { + WINPR_ASSERT(dstStride <= UINT32_MAX); + WINPR_ASSERT(dstWidth <= UINT32_MAX); + WINPR_ASSERT(dstHeight <= UINT32_MAX); + WINPR_ASSERT(srcStride <= UINT32_MAX); + WINPR_ASSERT(srcWidth <= UINT32_MAX); + WINPR_ASSERT(srcHeight <= UINT32_MAX); + return freerdp_image_scale(dst, PIXEL_FORMAT_BGRA32, (UINT32)dstStride, 0, 0, + (UINT32)dstWidth, (UINT32)dstHeight, src, PIXEL_FORMAT_BGRA32, + (UINT32)srcStride, 0, 0, (UINT32)srcWidth, (UINT32)srcHeight); + } + else + { + const size_t baseSrcOffset = 1ULL * area->top * srcStride + 4ULL * area->left; + const size_t baseDstOffset = 1ULL * area->top * dstStride + 4ULL * area->left; + const size_t width = MIN((size_t)area->right - area->left, dstWidth - area->left); + const size_t height = MIN((size_t)area->bottom - area->top, dstHeight - area->top); + const BYTE* psrc = (const BYTE*)src; + BYTE* pdst = (BYTE*)dst; + + for (size_t i = 0; i < height; i++) + { + const size_t srcOffset = i * srcStride + baseSrcOffset; + const size_t dstOffset = i * dstStride + baseDstOffset; + memcpy(&pdst[dstOffset], &psrc[srcOffset], width * 4); + } + + rc = TRUE; + } + + return rc; +} + +BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP) +{ + wlfContext* wlf = (wlfContext*)context; + UwacSize geometry = { 0 }; + + if (!context || !px || !py || !context->gdi) + return FALSE; + + if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)) + return TRUE; + + rdpGdi* gdi = context->gdi; + + if (UwacWindowGetDrawingBufferGeometry(wlf->window, &geometry, NULL) != UWAC_SUCCESS) + return FALSE; + + const double sx = 1.0 * geometry.width / (double)gdi->width; + const double sy = 1.0 * geometry.height / (double)gdi->height; + + if (!fromLocalToRDP) + { + *px *= (UINT32)lround(sx); + *py *= (UINT32)lround(sy); + } + else + { + *px /= (UINT32)lround(sx); + *py /= (UINT32)lround(sy); + } + + return TRUE; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.h b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.h new file mode 100644 index 0000000000000000000000000000000000000000..b4724341853d2a3aa8f98d8ee6e34991e4dbdece --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Wayland/wlfreerdp.h @@ -0,0 +1,61 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Wayland Client + * + * Copyright 2014 Manuel Bachmann + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WAYLAND_FREERDP_H +#define FREERDP_CLIENT_WAYLAND_FREERDP_H + +#include +#include +#include +#include +#include +#include +#include + +typedef struct wlf_clipboard wfClipboard; +typedef struct s_wlfDispContext wlfDispContext; + +typedef struct +{ + rdpClientContext common; + + UwacDisplay* display; + HANDLE displayHandle; + UwacWindow* window; + UwacSeat* seat; + + BOOL fullscreen; + BOOL closed; + BOOL focusing; + + /* Channels */ + wfClipboard* clipboard; + wlfDispContext* disp; + wLog* log; + CRITICAL_SECTION critical; + wArrayList* events; + FREERDP_REMAP_TABLE* remap_table; +} wlfContext; + +BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP); +BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst, + size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area, + BOOL scale); + +#endif /* FREERDP_CLIENT_WAYLAND_FREERDP_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/ModuleOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/ModuleOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ec9bf511b93c4a3136021c923cfcadbd3aa4fff4 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/ModuleOptions.cmake @@ -0,0 +1,3 @@ +set(FREERDP_CLIENT_NAME "wfreerdp") +set(FREERDP_CLIENT_PLATFORM "Windows") +set(FREERDP_CLIENT_VENDOR "FreeRDP") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_channels.h b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_channels.h new file mode 100644 index 0000000000000000000000000000000000000000..8676310625c359e3ced8e9a84519e0d4ff1bc9d5 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_channels.h @@ -0,0 +1,36 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2014 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WIN_CHANNELS_H +#define FREERDP_CLIENT_WIN_CHANNELS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wf_client.h" + +void wf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e); +void wf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e); + +#endif /* FREERDP_CLIENT_WIN_CHANNELS_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.c b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.c new file mode 100644 index 0000000000000000000000000000000000000000..fc6d68f7a8012af31f0f14a9774439d68aab4601 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.c @@ -0,0 +1,1490 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Client + * + * Copyright 2009-2011 Jay Sorg + * Copyright 2010-2011 Vic Lee + * Copyright 2010-2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_PROGRESS_BAR +#include +#endif + +#ifdef WITH_WINDOWS_CERT_STORE +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "wf_gdi.h" +#include "wf_rail.h" +#include "wf_channels.h" +#include "wf_graphics.h" + +#include "resource/resource.h" + +#define TAG CLIENT_TAG("windows") + +#define WM_FREERDP_SHOWWINDOW (WM_USER + 100) + +static BOOL wf_has_console(void) +{ +#ifdef WITH_WIN_CONSOLE + int file = _fileno(stdin); + int tty = _isatty(file); +#else + int file = -1; + int tty = 0; +#endif + + WLog_INFO(TAG, "Detected stdin=%d -> %s mode", file, tty ? "console" : "gui"); + return tty; +} + +static BOOL wf_end_paint(rdpContext* context) +{ + rdpGdi* gdi; + int ninvalid; + RECT updateRect; + HGDI_RGN cinvalid; + REGION16 invalidRegion; + RECTANGLE_16 invalidRect; + const RECTANGLE_16* extents; + wfContext* wfc = (wfContext*)context; + gdi = context->gdi; + ninvalid = gdi->primary->hdc->hwnd->ninvalid; + cinvalid = gdi->primary->hdc->hwnd->cinvalid; + + if (ninvalid < 1) + return TRUE; + + region16_init(&invalidRegion); + + for (int i = 0; i < ninvalid; i++) + { + invalidRect.left = cinvalid[i].x; + invalidRect.top = cinvalid[i].y; + invalidRect.right = cinvalid[i].x + cinvalid[i].w; + invalidRect.bottom = cinvalid[i].y + cinvalid[i].h; + region16_union_rect(&invalidRegion, &invalidRegion, &invalidRect); + } + + if (!region16_is_empty(&invalidRegion)) + { + extents = region16_extents(&invalidRegion); + updateRect.left = extents->left; + updateRect.top = extents->top; + updateRect.right = extents->right; + updateRect.bottom = extents->bottom; + + wf_scale_rect(wfc, &updateRect); + + InvalidateRect(wfc->hwnd, &updateRect, FALSE); + + if (wfc->rail) + wf_rail_invalidate_region(wfc, &invalidRegion); + } + + region16_uninit(&invalidRegion); + + if (!wfc->is_shown) + { + wfc->is_shown = TRUE; + +#ifdef WITH_PROGRESS_BAR + if (wfc->taskBarList) + { + wfc->taskBarList->lpVtbl->SetProgressState(wfc->taskBarList, wfc->hwnd, + TBPF_NOPROGRESS); + } +#endif + + PostMessage(wfc->hwnd, WM_FREERDP_SHOWWINDOW, 0, 0); + WLog_INFO(TAG, "Window is shown!"); + } + return TRUE; +} + +static BOOL wf_begin_paint(rdpContext* context) +{ + HGDI_DC hdc; + + if (!context || !context->gdi || !context->gdi->primary || !context->gdi->primary->hdc) + return FALSE; + + hdc = context->gdi->primary->hdc; + + if (!hdc || !hdc->hwnd || !hdc->hwnd->invalid) + return FALSE; + + hdc->hwnd->invalid->null = TRUE; + hdc->hwnd->ninvalid = 0; + return TRUE; +} + +static BOOL wf_desktop_resize(rdpContext* context) +{ + BOOL same; + RECT rect; + rdpSettings* settings; + wfContext* wfc = (wfContext*)context; + + if (!context || !context->settings) + return FALSE; + + settings = context->settings; + + if (wfc->primary) + { + same = (wfc->primary == wfc->drawing) ? TRUE : FALSE; + wf_image_free(wfc->primary); + wfc->primary = + wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), + context->gdi->dstFormat, NULL); + } + + if (!gdi_resize_ex(context->gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), 0, + context->gdi->dstFormat, wfc->primary->pdata, NULL)) + return FALSE; + + if (same) + wfc->drawing = wfc->primary; + + if (wfc->fullscreen != TRUE) + { + if (wfc->hwnd && !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)) + SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y, + SWP_NOMOVE); + } + else + { + wf_update_offset(wfc); + GetWindowRect(wfc->hwnd, &rect); + InvalidateRect(wfc->hwnd, &rect, TRUE); + } + + return TRUE; +} + +static BOOL wf_pre_connect(freerdp* instance) +{ + UINT32 rc; + wfContext* wfc; + UINT32 desktopWidth; + UINT32 desktopHeight; + rdpContext* context; + rdpSettings* settings; + + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + WINPR_ASSERT(instance->context->settings); + + context = instance->context; + wfc = (wfContext*)instance->context; + settings = context->settings; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_WINDOWS)) + return FALSE; + if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_WINDOWS_NT)) + return FALSE; + wfc->fullscreen = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen); + wfc->fullscreen_toggle = freerdp_settings_get_bool(settings, FreeRDP_ToggleFullscreen); + desktopWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + desktopHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + + if (wfc->percentscreen > 0) + { + desktopWidth = (GetSystemMetrics(SM_CXSCREEN) * wfc->percentscreen) / 100; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth)) + return FALSE; + desktopHeight = (GetSystemMetrics(SM_CYSCREEN) * wfc->percentscreen) / 100; + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight)) + return FALSE; + } + + if (wfc->fullscreen) + { + if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon)) + { + desktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); + desktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + } + else + { + desktopWidth = GetSystemMetrics(SM_CXSCREEN); + desktopHeight = GetSystemMetrics(SM_CYSCREEN); + } + } + + /* FIXME: desktopWidth has a limitation that it should be divisible by 4, + * otherwise the screen will crash when connecting to an XP desktop.*/ + desktopWidth = (desktopWidth + 3) & (~3); + + if (desktopWidth != freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth)) + return FALSE; + } + + if (desktopHeight != freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight)) + return FALSE; + } + + rc = freerdp_keyboard_init(freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout)); + if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, rc)) + return FALSE; + PubSub_SubscribeChannelConnected(instance->context->pubSub, wf_OnChannelConnectedEventHandler); + PubSub_SubscribeChannelDisconnected(instance->context->pubSub, + wf_OnChannelDisconnectedEventHandler); + return TRUE; +} + +static void wf_append_item_to_system_menu(HMENU hMenu, UINT fMask, UINT wID, const wchar_t* text, + wfContext* wfc) +{ + MENUITEMINFO item_info = { 0 }; + item_info.fMask = fMask; + item_info.cbSize = sizeof(MENUITEMINFO); + item_info.wID = wID; + item_info.fType = MFT_STRING; + item_info.dwTypeData = _wcsdup(text); + item_info.cch = (UINT)_wcslen(text); + if (wfc) + item_info.dwItemData = (ULONG_PTR)wfc; + InsertMenuItem(hMenu, wfc->systemMenuInsertPosition++, TRUE, &item_info); +} + +static void wf_add_system_menu(wfContext* wfc) +{ + HMENU hMenu; + + if (wfc->fullscreen && !wfc->fullscreen_toggle) + { + return; + } + + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_DynamicResolutionUpdate)) + { + return; + } + + hMenu = GetSystemMenu(wfc->hwnd, FALSE); + + wf_append_item_to_system_menu(hMenu, + MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_DATA, + SYSCOMMAND_ID_SMARTSIZING, L"Smart sizing", wfc); + + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing)) + { + CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, MF_CHECKED); + } + + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_RemoteAssistanceMode)) + wf_append_item_to_system_menu(hMenu, MIIM_FTYPE | MIIM_ID | MIIM_STRING, + SYSCOMMAND_ID_REQUEST_CONTROL, L"Request control", wfc); +} + +static WCHAR* wf_window_get_title(rdpSettings* settings) +{ + BOOL port; + WCHAR* windowTitle = NULL; + size_t size; + WCHAR prefix[] = L"FreeRDP:"; + + if (!settings) + return NULL; + + const char* name = freerdp_settings_get_string(settings, FreeRDP_ServerHostname); + + if (freerdp_settings_get_string(settings, FreeRDP_WindowTitle)) + return ConvertUtf8ToWCharAlloc(freerdp_settings_get_string(settings, FreeRDP_WindowTitle), + NULL); + + port = (freerdp_settings_get_uint32(settings, FreeRDP_ServerPort) != 3389); + size = strlen(name) + 16 + wcslen(prefix); + windowTitle = calloc(size, sizeof(WCHAR)); + + if (!windowTitle) + return NULL; + + if (!port) + _snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S", prefix, name); + else + _snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S:%u", prefix, name, + freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)); + + return windowTitle; +} + +static BOOL wf_post_connect(freerdp* instance) +{ + rdpGdi* gdi; + DWORD dwStyle; + rdpCache* cache; + wfContext* wfc; + rdpContext* context; + rdpSettings* settings; + EmbedWindowEventArgs e; + const UINT32 format = PIXEL_FORMAT_BGRX32; + + WINPR_ASSERT(instance); + + context = instance->context; + WINPR_ASSERT(context); + + settings = context->settings; + WINPR_ASSERT(settings); + + wfc = (wfContext*)instance->context; + WINPR_ASSERT(wfc); + + wfc->primary = + wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), format, NULL); + + if (!gdi_init_ex(instance, format, 0, wfc->primary->pdata, NULL)) + return FALSE; + + cache = instance->context->cache; + WINPR_ASSERT(cache); + + gdi = instance->context->gdi; + + if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi)) + { + wf_gdi_register_update_callbacks(context->update); + } + + wfc->window_title = wf_window_get_title(settings); + + if (!wfc->window_title) + return FALSE; + + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) + { + if (!freerdp_settings_set_bool(settings, FreeRDP_Decorations, FALSE)) + return FALSE; + } + + if (wfc->fullscreen) + dwStyle = WS_POPUP; + else if (!freerdp_settings_get_bool(settings, FreeRDP_Decorations)) + dwStyle = WS_CHILD | WS_BORDER; + else + dwStyle = + WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; + + if (!wfc->hwnd) + { + wfc->hwnd = CreateWindowEx(0, wfc->wndClassName, wfc->window_title, dwStyle, 0, 0, 0, 0, + wfc->hWndParent, NULL, wfc->hInstance, NULL); + SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR)wfc); + } + + wf_resize_window(wfc); + wf_add_system_menu(wfc); + BitBlt(wfc->primary->hdc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), NULL, 0, 0, BLACKNESS); + wfc->drawing = wfc->primary; + EventArgsInit(&e, "wfreerdp"); + e.embed = FALSE; + e.handle = (void*)wfc->hwnd; + PubSub_OnEmbedWindow(context->pubSub, context, &e); +#ifdef WITH_PROGRESS_BAR + if (wfc->taskBarList) + { + ShowWindow(wfc->hwnd, SW_SHOWMINIMIZED); + wfc->taskBarList->lpVtbl->SetProgressState(wfc->taskBarList, wfc->hwnd, TBPF_INDETERMINATE); + } +#endif + UpdateWindow(wfc->hwnd); + context->update->BeginPaint = wf_begin_paint; + context->update->DesktopResize = wf_desktop_resize; + context->update->EndPaint = wf_end_paint; + wf_register_pointer(context->graphics); + + wfc->floatbar = wf_floatbar_new(wfc, wfc->hInstance, + freerdp_settings_get_uint32(settings, FreeRDP_Floatbar)); + return TRUE; +} + +static void wf_post_disconnect(freerdp* instance) +{ + wfContext* wfc; + + if (!instance || !instance->context) + return; + + wfc = (wfContext*)instance->context; + free(wfc->window_title); +} + +static CREDUI_INFOW wfUiInfo = { sizeof(CREDUI_INFOW), NULL, L"Enter your credentials", + L"Remote Desktop Security", NULL }; + +static BOOL wf_authenticate_ex(freerdp* instance, char** username, char** password, char** domain, + rdp_auth_reason reason) +{ + wfContext* wfc; + BOOL fSave; + DWORD status; + DWORD dwFlags; + WCHAR UserNameW[CREDUI_MAX_USERNAME_LENGTH + 1] = { 0 }; + WCHAR UserW[CREDUI_MAX_USERNAME_LENGTH + 1] = { 0 }; + WCHAR DomainW[CREDUI_MAX_DOMAIN_TARGET_LENGTH + 1] = { 0 }; + WCHAR PasswordW[CREDUI_MAX_PASSWORD_LENGTH + 1] = { 0 }; + + WINPR_ASSERT(instance); + WINPR_ASSERT(instance->context); + WINPR_ASSERT(instance->context->settings); + + wfc = (wfContext*)instance->context; + WINPR_ASSERT(wfc); + + WINPR_ASSERT(username); + WINPR_ASSERT(domain); + WINPR_ASSERT(password); + + const WCHAR auth[] = L"Target credentials requested"; + const WCHAR authPin[] = L"PIN requested"; + const WCHAR gwAuth[] = L"Gateway credentials requested"; + const WCHAR* titleW = auth; + + fSave = FALSE; + dwFlags = CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_EXCLUDE_CERTIFICATES | + CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS; + switch (reason) + { + case AUTH_NLA: + break; + case AUTH_TLS: + case AUTH_RDP: + if ((*username) && (*password)) + return TRUE; + break; + case AUTH_SMARTCARD_PIN: + dwFlags &= ~CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS; + dwFlags |= CREDUI_FLAGS_PASSWORD_ONLY_OK | CREDUI_FLAGS_KEEP_USERNAME; + titleW = authPin; + if (*password) + return TRUE; + if (!(*username)) + *username = _strdup("PIN"); + break; + case GW_AUTH_HTTP: + case GW_AUTH_RDG: + case GW_AUTH_RPC: + titleW = gwAuth; + break; + default: + return FALSE; + } + + if (*username) + { + (void)ConvertUtf8ToWChar(*username, UserNameW, ARRAYSIZE(UserNameW)); + (void)ConvertUtf8ToWChar(*username, UserW, ARRAYSIZE(UserW)); + } + + if (*password) + (void)ConvertUtf8ToWChar(*password, PasswordW, ARRAYSIZE(PasswordW)); + + if (*domain) + (void)ConvertUtf8ToWChar(*domain, DomainW, ARRAYSIZE(DomainW)); + + if (_wcsnlen(PasswordW, ARRAYSIZE(PasswordW)) == 0) + { + if (!wfc->isConsole && + freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin)) + WLog_ERR(TAG, "Flag for stdin read present but stdin is redirected; using GUI"); + if (wfc->isConsole && + freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin)) + status = CredUICmdLinePromptForCredentialsW(titleW, NULL, 0, UserNameW, + ARRAYSIZE(UserNameW), PasswordW, + ARRAYSIZE(PasswordW), &fSave, dwFlags); + else + status = CredUIPromptForCredentialsW(&wfUiInfo, titleW, NULL, 0, UserNameW, + ARRAYSIZE(UserNameW), PasswordW, + ARRAYSIZE(PasswordW), &fSave, dwFlags); + if (status != NO_ERROR) + { + WLog_ERR(TAG, "CredUIPromptForCredentials unexpected status: 0x%08lX", status); + return FALSE; + } + + if ((dwFlags & CREDUI_FLAGS_KEEP_USERNAME) == 0) + { + status = CredUIParseUserNameW(UserNameW, UserW, ARRAYSIZE(UserW), DomainW, + ARRAYSIZE(DomainW)); + if (status != NO_ERROR) + { + CHAR User[CREDUI_MAX_USERNAME_LENGTH + 1] = { 0 }; + CHAR UserName[CREDUI_MAX_USERNAME_LENGTH + 1] = { 0 }; + CHAR Domain[CREDUI_MAX_DOMAIN_TARGET_LENGTH + 1] = { 0 }; + + (void)ConvertWCharNToUtf8(UserNameW, ARRAYSIZE(UserNameW), UserName, + ARRAYSIZE(UserName)); + (void)ConvertWCharNToUtf8(UserW, ARRAYSIZE(UserW), User, ARRAYSIZE(User)); + (void)ConvertWCharNToUtf8(DomainW, ARRAYSIZE(DomainW), Domain, ARRAYSIZE(Domain)); + WLog_ERR(TAG, "Failed to parse UserName: %s into User: %s Domain: %s", UserName, + User, Domain); + return FALSE; + } + } + } + + *username = ConvertWCharNToUtf8Alloc(UserW, ARRAYSIZE(UserW), NULL); + if (!(*username)) + { + WLog_ERR(TAG, "ConvertWCharNToUtf8Alloc failed", status); + return FALSE; + } + + if (_wcsnlen(DomainW, ARRAYSIZE(DomainW)) > 0) + *domain = ConvertWCharNToUtf8Alloc(DomainW, ARRAYSIZE(DomainW), NULL); + else + *domain = _strdup("\0"); + + if (!(*domain)) + { + free(*username); + WLog_ERR(TAG, "strdup failed", status); + return FALSE; + } + + *password = ConvertWCharNToUtf8Alloc(PasswordW, ARRAYSIZE(PasswordW), NULL); + if (!(*password)) + { + free(*username); + free(*domain); + return FALSE; + } + + return TRUE; +} + +static WCHAR* wf_format_text(const WCHAR* fmt, ...) +{ + int rc; + size_t size = 0; + WCHAR* buffer = NULL; + + do + { + WCHAR* tmp; + va_list ap; + va_start(ap, fmt); + rc = _vsnwprintf(buffer, size, fmt, ap); + va_end(ap); + if (rc <= 0) + goto fail; + + if ((size_t)rc < size) + return buffer; + + size = (size_t)rc + 1; + tmp = realloc(buffer, size * sizeof(WCHAR)); + if (!tmp) + goto fail; + + buffer = tmp; + } while (TRUE); + +fail: + free(buffer); + return NULL; +} + +#ifdef WITH_WINDOWS_CERT_STORE +/* https://stackoverflow.com/questions/1231178/load-an-pem-encoded-x-509-certificate-into-windows-cryptoapi/3803333#3803333 + */ +/* https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/Win7Samples/security/cryptoapi/peertrust/cpp/peertrust.cpp + */ +/* https://stackoverflow.com/questions/7340504/whats-the-correct-way-to-verify-an-ssl-certificate-in-win32 + */ + +static void wf_report_error(char* wszMessage, DWORD dwErrCode) +{ + LPSTR pwszMsgBuf = NULL; + + if (NULL != wszMessage && 0 != *wszMessage) + { + WLog_ERR(TAG, "%s", wszMessage); + } + + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, // Location of message + // definition ignored + dwErrCode, // Message identifier for + // the requested message + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Language identifier for + // the requested message + (LPSTR)&pwszMsgBuf, // Buffer that receives + // the formatted message + 0, // Size of output buffer + // not needed as allocate + // buffer flag is set + NULL // Array of insert values + ); + + if (NULL != pwszMsgBuf) + { + WLog_ERR(TAG, "Error: 0x%08x (%d) %s", dwErrCode, dwErrCode, pwszMsgBuf); + LocalFree(pwszMsgBuf); + } + else + { + WLog_ERR(TAG, "Error: 0x%08x (%d)", dwErrCode, dwErrCode); + } +} + +static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char* subject, + const char* issuer, const char* fingerprint) +{ + HRESULT hr = CRYPT_E_NOT_FOUND; + + DWORD dwChainFlags = CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT; + PCCERT_CONTEXT pCert = NULL; + HCERTCHAINENGINE hChainEngine = NULL; + PCCERT_CHAIN_CONTEXT pChainContext = NULL; + + CERT_ENHKEY_USAGE EnhkeyUsage = { 0 }; + CERT_USAGE_MATCH CertUsage = { 0 }; + CERT_CHAIN_PARA ChainPara = { 0 }; + CERT_CHAIN_POLICY_PARA ChainPolicy = { 0 }; + CERT_CHAIN_POLICY_STATUS PolicyStatus = { 0 }; + CERT_CHAIN_ENGINE_CONFIG EngineConfig = { 0 }; + + DWORD derPubKeyLen = strlen(fingerprint); + char* derPubKey = calloc(derPubKeyLen, sizeof(char)); + if (NULL == derPubKey) + { + WLog_ERR(TAG, "Could not allocate derPubKey"); + goto CleanUp; + } + + /* + * Convert from PEM format to DER format - removes header and footer and decodes from base64 + */ + if (!CryptStringToBinaryA(fingerprint, 0, CRYPT_STRING_BASE64HEADER, derPubKey, &derPubKeyLen, + NULL, NULL)) + { + WLog_ERR(TAG, "CryptStringToBinary failed. Err: %d", GetLastError()); + goto CleanUp; + } + + //--------------------------------------------------------- + // Initialize data structures for chain building. + + EnhkeyUsage.cUsageIdentifier = 0; + EnhkeyUsage.rgpszUsageIdentifier = NULL; + + CertUsage.dwType = USAGE_MATCH_TYPE_AND; + CertUsage.Usage = EnhkeyUsage; + + ChainPara.cbSize = sizeof(ChainPara); + ChainPara.RequestedUsage = CertUsage; + + ChainPolicy.cbSize = sizeof(ChainPolicy); + + PolicyStatus.cbSize = sizeof(PolicyStatus); + + EngineConfig.cbSize = sizeof(EngineConfig); + EngineConfig.dwUrlRetrievalTimeout = 0; + + pCert = CertCreateCertificateContext(X509_ASN_ENCODING, derPubKey, derPubKeyLen); + if (NULL == pCert) + { + WLog_ERR(TAG, "FAILED: Certificate could not be parsed."); + goto CleanUp; + } + + dwChainFlags |= CERT_CHAIN_ENABLE_PEER_TRUST; + + // When this flag is set, end entity certificates in the + // Trusted People store are trusted without doing any chain building + // This optimizes the chain building process. + + //--------------------------------------------------------- + // Create chain engine. + + if (!CertCreateCertificateChainEngine(&EngineConfig, &hChainEngine)) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto CleanUp; + } + + //------------------------------------------------------------------- + // Build a chain using CertGetCertificateChain + + if (!CertGetCertificateChain(hChainEngine, // use the default chain engine + pCert, // pointer to the end certificate + NULL, // use the default time + NULL, // search no additional stores + &ChainPara, // use AND logic and enhanced key usage + // as indicated in the ChainPara + // data structure + dwChainFlags, + NULL, // currently reserved + &pChainContext)) // return a pointer to the chain created + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto CleanUp; + } + + //--------------------------------------------------------------- + // Verify that the chain complies with policy + + if (!CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, // use the base policy + pChainContext, // pointer to the chain + &ChainPolicy, + &PolicyStatus)) // return a pointer to the policy status + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto CleanUp; + } + + if (PolicyStatus.dwError != S_OK) + { + wf_report_error("CertVerifyCertificateChainPolicy: Chain Status", PolicyStatus.dwError); + hr = PolicyStatus.dwError; + // Instruction: If the PolicyStatus.dwError is CRYPT_E_NO_REVOCATION_CHECK or + // CRYPT_E_REVOCATION_OFFLINE, it indicates errors in obtaining + // revocation information. These can be ignored since the retrieval of + // revocation information depends on network availability + + if (PolicyStatus.dwError == CRYPT_E_NO_REVOCATION_CHECK || + PolicyStatus.dwError == CRYPT_E_REVOCATION_OFFLINE) + { + hr = S_OK; + } + + goto CleanUp; + } + + WLog_INFO(TAG, "CertVerifyCertificateChainPolicy succeeded for %s (%s) issued by %s", + common_name, subject, issuer); + + hr = S_OK; +CleanUp: + + if (FAILED(hr)) + { + WLog_INFO(TAG, "CertVerifyCertificateChainPolicy failed for %s (%s) issued by %s", + common_name, subject, issuer); + wf_report_error(NULL, hr); + } + + free(derPubKey); + + if (NULL != pChainContext) + { + CertFreeCertificateChain(pChainContext); + } + + if (NULL != hChainEngine) + { + CertFreeCertificateChainEngine(hChainEngine); + } + + if (NULL != pCert) + { + CertFreeCertificateContext(pCert); + } + + return (DWORD)hr; +} +#endif + +static DWORD wf_cli_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port, + const char* common_name, const char* subject, + const char* issuer, const char* fingerprint, DWORD flags) +{ +#ifdef WITH_WINDOWS_CERT_STORE + if (flags & VERIFY_CERT_FLAG_FP_IS_PEM && !(flags & VERIFY_CERT_FLAG_MISMATCH)) + { + if (wf_is_x509_certificate_trusted(common_name, subject, issuer, fingerprint) == S_OK) + { + return 2; + } + } +#endif + + return client_cli_verify_certificate_ex(instance, host, port, common_name, subject, issuer, + fingerprint, flags); +} + +static DWORD wf_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port, + const char* common_name, const char* subject, + const char* issuer, const char* fingerprint, DWORD flags) +{ + WCHAR* buffer; + WCHAR* caption; + int what = IDCANCEL; + +#ifdef WITH_WINDOWS_CERT_STORE + if (flags & VERIFY_CERT_FLAG_FP_IS_PEM && !(flags & VERIFY_CERT_FLAG_MISMATCH)) + { + if (wf_is_x509_certificate_trusted(common_name, subject, issuer, fingerprint) == S_OK) + { + return 2; + } + } +#endif + + buffer = wf_format_text( + L"Certificate details:\n" + L"\tCommonName: %S\n" + L"\tSubject: %S\n" + L"\tIssuer: %S\n" + L"\tThumbprint: %S\n" + L"\tHostMismatch: %S\n" + L"\n" + L"The above X.509 certificate could not be verified, possibly because you do not have " + L"the CA certificate in your certificate store, or the certificate has expired. " + L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n" + L"\n" + L"YES\tAccept permanently\n" + L"NO\tAccept for this session only\n" + L"CANCEL\tAbort connection\n", + common_name, subject, issuer, fingerprint, + flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No"); + caption = wf_format_text(L"Verify certificate for %S:%hu", host, port); + + WINPR_UNUSED(instance); + + if (!buffer || !caption) + goto fail; + + what = MessageBoxW(NULL, buffer, caption, MB_YESNOCANCEL); +fail: + free(buffer); + free(caption); + + /* return 1 to accept and store a certificate, 2 to accept + * a certificate only for this session, 0 otherwise */ + switch (what) + { + case IDYES: + return 1; + case IDNO: + return 2; + default: + return 0; + } +} + +static DWORD wf_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port, + const char* common_name, const char* subject, + const char* issuer, const char* new_fingerprint, + const char* old_subject, const char* old_issuer, + const char* old_fingerprint, DWORD flags) +{ + WCHAR* buffer; + WCHAR* caption; + int what = IDCANCEL; + + buffer = wf_format_text( + L"New Certificate details:\n" + L"\tCommonName: %S\n" + L"\tSubject: %S\n" + L"\tIssuer: %S\n" + L"\tThumbprint: %S\n" + L"\tHostMismatch: %S\n" + L"\n" + L"Old Certificate details:\n" + L"\tSubject: %S\n" + L"\tIssuer: %S\n" + L"\tThumbprint: %S" + L"The above X.509 certificate could not be verified, possibly because you do not have " + L"the CA certificate in your certificate store, or the certificate has expired. " + L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n" + L"\n" + L"YES\tAccept permanently\n" + L"NO\tAccept for this session only\n" + L"CANCEL\tAbort connection\n", + common_name, subject, issuer, new_fingerprint, + flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No", old_subject, old_issuer, old_fingerprint); + caption = wf_format_text(L"Verify certificate change for %S:%hu", host, port); + + WINPR_UNUSED(instance); + if (!buffer || !caption) + goto fail; + + what = MessageBoxW(NULL, buffer, caption, MB_YESNOCANCEL); +fail: + free(buffer); + free(caption); + + /* return 1 to accept and store a certificate, 2 to accept + * a certificate only for this session, 0 otherwise */ + switch (what) + { + case IDYES: + return 1; + case IDNO: + return 2; + default: + return 0; + } +} + +static BOOL wf_present_gateway_message(freerdp* instance, UINT32 type, BOOL isDisplayMandatory, + BOOL isConsentMandatory, size_t length, const WCHAR* message) +{ + if (!isDisplayMandatory && !isConsentMandatory) + return TRUE; + + /* special handling for consent messages (show modal dialog) */ + if (type == GATEWAY_MESSAGE_CONSENT && isConsentMandatory) + { + int mbRes; + WCHAR* msg; + + msg = wf_format_text(L"%.*s\n\nI understand and agree to the terms of this policy", length, + message); + mbRes = MessageBoxW(NULL, msg, L"Consent Message", MB_YESNO); + free(msg); + + if (mbRes != IDYES) + return FALSE; + } + else + return client_cli_present_gateway_message(instance, type, isDisplayMandatory, + isConsentMandatory, length, message); + + return TRUE; +} + +static DWORD WINAPI wf_client_thread(LPVOID lpParam) +{ + MSG msg = { 0 }; + int width = 0; + int height = 0; + BOOL msg_ret = FALSE; + int quit_msg = 0; + DWORD error = 0; + + freerdp* instance = (freerdp*)lpParam; + WINPR_ASSERT(instance); + + if (!freerdp_connect(instance)) + goto end; + + rdpContext* context = instance->context; + WINPR_ASSERT(context); + + wfContext* wfc = (wfContext*)instance->context; + WINPR_ASSERT(wfc); + + rdpChannels* channels = context->channels; + WINPR_ASSERT(channels); + + rdpSettings* settings = context->settings; + WINPR_ASSERT(settings); + + while (!freerdp_shall_disconnect_context(instance->context)) + { + HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 }; + DWORD nCount = 0; + + if (freerdp_focus_required(instance)) + { + wf_event_focus_in(wfc); + wf_event_focus_in(wfc); + } + + { + DWORD tmp = freerdp_get_event_handles(context, &handles[nCount], 64 - nCount); + + if (tmp == 0) + { + WLog_ERR(TAG, "freerdp_get_event_handles failed"); + break; + } + + nCount += tmp; + } + + DWORD status = MsgWaitForMultipleObjectsEx(nCount, handles, 5 * 1000, QS_ALLINPUT, + MWMO_ALERTABLE | MWMO_INPUTAVAILABLE); + if (status == WAIT_FAILED) + { + WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%08lX", GetLastError()); + break; + } + + { + if (!freerdp_check_event_handles(context)) + { + if (client_auto_reconnect(instance)) + continue; + + WLog_ERR(TAG, "Failed to check FreeRDP file descriptor"); + break; + } + } + + if (freerdp_shall_disconnect_context(instance->context)) + break; + + quit_msg = FALSE; + + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) + { + msg_ret = GetMessage(&msg, NULL, 0, 0); + + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) + { + if ((msg.message == WM_SETFOCUS) && (msg.lParam == 1)) + { + PostMessage(wfc->hwnd, WM_SETFOCUS, 0, 0); + } + else if ((msg.message == WM_KILLFOCUS) && (msg.lParam == 1)) + { + PostMessage(wfc->hwnd, WM_KILLFOCUS, 0, 0); + } + } + + switch (msg.message) + { + case WM_SIZE: + { + width = LOWORD(msg.lParam); + height = HIWORD(msg.lParam); + SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); + break; + } + case WM_FREERDP_SHOWWINDOW: + { + ShowWindow(wfc->hwnd, SW_NORMAL); + break; + } + default: + break; + } + + if ((msg_ret == 0) || (msg_ret == -1)) + { + quit_msg = TRUE; + break; + } + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + if (quit_msg) + break; + } + + /* cleanup */ + freerdp_disconnect(instance); + +end: + error = freerdp_get_last_error(instance->context); + WLog_DBG(TAG, "Main thread exited with %" PRIu32, error); + ExitThread(error); + return error; +} + +static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam) +{ + MSG msg; + BOOL status; + wfContext* wfc; + HHOOK hook_handle; + wfc = (wfContext*)lpParam; + WINPR_ASSERT(NULL != wfc); + hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance, 0); + + if (hook_handle) + { + while ((status = GetMessage(&msg, NULL, 0, 0)) != 0) + { + if (status == -1) + { + WLog_ERR(TAG, "keyboard thread error getting message"); + break; + } + else + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + UnhookWindowsHookEx(hook_handle); + } + else + { + WLog_ERR(TAG, "failed to install keyboard hook"); + } + + WLog_DBG(TAG, "Keyboard thread exited."); + ExitThread(0); + return 0; +} + +int freerdp_client_set_window_size(wfContext* wfc, int width, int height) +{ + WLog_DBG(TAG, "freerdp_client_set_window_size %d, %d", width, height); + + if ((width != wfc->client_width) || (height != wfc->client_height)) + { + PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED, + ((UINT)height << 16) | (UINT)width); + } + + return 0; +} + +void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_height) +{ + const rdpSettings* settings; + WINPR_ASSERT(wfc); + + settings = wfc->common.context.settings; + WINPR_ASSERT(settings); + + if (wfc->disablewindowtracking) + return; + + // prevent infinite message loop + wfc->disablewindowtracking = TRUE; + + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || + freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) + { + wfc->xCurrentScroll = 0; + wfc->yCurrentScroll = 0; + + if (wfc->xScrollVisible || wfc->yScrollVisible) + { + if (ShowScrollBar(wfc->hwnd, SB_BOTH, FALSE)) + { + wfc->xScrollVisible = FALSE; + wfc->yScrollVisible = FALSE; + } + } + } + else + { + SCROLLINFO si; + BOOL horiz = wfc->xScrollVisible; + BOOL vert = wfc->yScrollVisible; + + if (!horiz && client_width < freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) + { + horiz = TRUE; + } + else if (horiz && + client_width >= + freerdp_settings_get_uint32( + settings, FreeRDP_DesktopWidth) /* - GetSystemMetrics(SM_CXVSCROLL)*/) + { + horiz = FALSE; + } + + if (!vert && client_height < freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) + { + vert = TRUE; + } + else if (vert && + client_height >= + freerdp_settings_get_uint32( + settings, FreeRDP_DesktopHeight) /* - GetSystemMetrics(SM_CYHSCROLL)*/) + { + vert = FALSE; + } + + if (horiz == vert && (horiz != wfc->xScrollVisible && vert != wfc->yScrollVisible)) + { + if (ShowScrollBar(wfc->hwnd, SB_BOTH, horiz)) + { + wfc->xScrollVisible = horiz; + wfc->yScrollVisible = vert; + } + } + + if (horiz != wfc->xScrollVisible) + { + if (ShowScrollBar(wfc->hwnd, SB_HORZ, horiz)) + { + wfc->xScrollVisible = horiz; + } + } + + if (vert != wfc->yScrollVisible) + { + if (ShowScrollBar(wfc->hwnd, SB_VERT, vert)) + { + wfc->yScrollVisible = vert; + } + } + + if (horiz) + { + // The horizontal scrolling range is defined by + // (bitmap_width) - (client_width). The current horizontal + // scroll value remains within the horizontal scrolling range. + wfc->xMaxScroll = + MAX(freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) - client_width, 0); + wfc->xCurrentScroll = MIN(wfc->xCurrentScroll, wfc->xMaxScroll); + si.cbSize = sizeof(si); + si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; + si.nMin = wfc->xMinScroll; + si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + si.nPage = client_width; + si.nPos = wfc->xCurrentScroll; + SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE); + } + + if (vert) + { + // The vertical scrolling range is defined by + // (bitmap_height) - (client_height). The current vertical + // scroll value remains within the vertical scrolling range. + wfc->yMaxScroll = MAX( + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) - client_height, 0); + wfc->yCurrentScroll = MIN(wfc->yCurrentScroll, wfc->yMaxScroll); + si.cbSize = sizeof(si); + si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; + si.nMin = wfc->yMinScroll; + si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + si.nPage = client_height; + si.nPos = wfc->yCurrentScroll; + SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE); + } + } + + wfc->disablewindowtracking = FALSE; + wf_update_canvas_diff(wfc); +} + +static BOOL wfreerdp_client_global_init(void) +{ + WSADATA wsaData; + + WSAStartup(0x101, &wsaData); + + freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0); + + return TRUE; +} + +static void wfreerdp_client_global_uninit(void) +{ + WSACleanup(); +} + +static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context) +{ + wfContext* wfc = (wfContext*)context; + if (!wfc) + return FALSE; + + // AttachConsole and stdin do not work well. + // Use GUI input dialogs instead of command line ones. + wfc->isConsole = wf_has_console(); + + if (!(wfreerdp_client_global_init())) + return FALSE; + + WINPR_ASSERT(instance); + instance->PreConnect = wf_pre_connect; + instance->PostConnect = wf_post_connect; + instance->PostDisconnect = wf_post_disconnect; + instance->AuthenticateEx = wf_authenticate_ex; + +#ifdef WITH_WINDOWS_CERT_STORE + if (!freerdp_settings_set_bool(context->settings, FreeRDP_CertificateCallbackPreferPEM, TRUE)) + return FALSE; +#endif + + if (!wfc->isConsole) + { + instance->VerifyCertificateEx = wf_verify_certificate_ex; + instance->VerifyChangedCertificateEx = wf_verify_changed_certificate_ex; + instance->PresentGatewayMessage = wf_present_gateway_message; + } + +#ifdef WITH_PROGRESS_BAR + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_ALL, &IID_ITaskbarList3, + (void**)&wfc->taskBarList); +#endif + + return TRUE; +} + +static void wfreerdp_client_free(freerdp* instance, rdpContext* context) +{ + WINPR_UNUSED(instance); + if (!context) + return; + +#ifdef WITH_PROGRESS_BAR + CoUninitialize(); +#endif +} + +static int wfreerdp_client_start(rdpContext* context) +{ + wfContext* wfc = (wfContext*)context; + + WINPR_ASSERT(context); + WINPR_ASSERT(context->settings); + + freerdp* instance = context->instance; + WINPR_ASSERT(instance); + + rdpSettings* settings = context->settings; + WINPR_ASSERT(settings); + + HINSTANCE hInstance = GetModuleHandle(NULL); + HWND hWndParent = (HWND)freerdp_settings_get_uint64(settings, FreeRDP_ParentWindowId); + if (!freerdp_settings_set_bool(settings, FreeRDP_EmbeddedWindow, (hWndParent) ? TRUE : FALSE)) + return -1; + + wfc->hWndParent = hWndParent; + + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) + { + typedef UINT(WINAPI * GetDpiForWindow_t)(HWND hwnd); + typedef BOOL(WINAPI * SetProcessDPIAware_t)(void); + + HMODULE module = GetModuleHandle(_T("User32")); + if (module) + { + GetDpiForWindow_t pGetDpiForWindow = + GetProcAddressAs(module, "GetDpiForWindow", GetDpiForWindow_t); + SetProcessDPIAware_t pSetProcessDPIAware = + GetProcAddressAs(module, "SetProcessDPIAware", SetProcessDPIAware_t); + if (pGetDpiForWindow && pSetProcessDPIAware) + { + const UINT dpiAwareness = pGetDpiForWindow(hWndParent); + if (dpiAwareness != USER_DEFAULT_SCREEN_DPI) + pSetProcessDPIAware(); + } + FreeLibrary(module); + } + } + + /* initial windows system item position where we will insert new menu item + * after default 5 items (restore, move, size, minimize, maximize) + * gets incremented each time wf_append_item_to_system_menu is called + * or maybe could use GetMenuItemCount() to get initial item count ? */ + wfc->systemMenuInsertPosition = 6; + + wfc->hInstance = hInstance; + wfc->cursor = LoadCursor(NULL, IDC_ARROW); + wfc->icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); + wfc->wndClassName = _tcsdup(_T("FreeRDP")); + wfc->wndClass.cbSize = sizeof(WNDCLASSEX); + wfc->wndClass.style = CS_HREDRAW | CS_VREDRAW; + wfc->wndClass.lpfnWndProc = wf_event_proc; + wfc->wndClass.cbClsExtra = 0; + wfc->wndClass.cbWndExtra = 0; + wfc->wndClass.hCursor = NULL; + wfc->wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wfc->wndClass.lpszMenuName = NULL; + wfc->wndClass.lpszClassName = wfc->wndClassName; + wfc->wndClass.hInstance = hInstance; + wfc->wndClass.hIcon = wfc->icon; + wfc->wndClass.hIconSm = wfc->icon; + RegisterClassEx(&(wfc->wndClass)); + wfc->keyboardThread = + CreateThread(NULL, 0, wf_keyboard_thread, (void*)wfc, 0, &wfc->keyboardThreadId); + + if (!wfc->keyboardThread) + return -1; + + wfc->common.thread = + CreateThread(NULL, 0, wf_client_thread, (void*)instance, 0, &wfc->mainThreadId); + + if (!wfc->common.thread) + return -1; + + return 0; +} + +static int wfreerdp_client_stop(rdpContext* context) +{ + int rc; + wfContext* wfc = (wfContext*)context; + + WINPR_ASSERT(wfc); + PostThreadMessage(wfc->mainThreadId, WM_QUIT, 0, 0); + rc = freerdp_client_common_stop(context); + wfc->mainThreadId = 0; + + if (wfc->keyboardThread) + { + PostThreadMessage(wfc->keyboardThreadId, WM_QUIT, 0, 0); + (void)WaitForSingleObject(wfc->keyboardThread, INFINITE); + (void)CloseHandle(wfc->keyboardThread); + wfc->keyboardThread = NULL; + wfc->keyboardThreadId = 0; + } + + return 0; +} + +int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) +{ + pEntryPoints->Version = 1; + pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1); + pEntryPoints->GlobalInit = wfreerdp_client_global_init; + pEntryPoints->GlobalUninit = wfreerdp_client_global_uninit; + pEntryPoints->ContextSize = sizeof(wfContext); + pEntryPoints->ClientNew = wfreerdp_client_new; + pEntryPoints->ClientFree = wfreerdp_client_free; + pEntryPoints->ClientStart = wfreerdp_client_start; + pEntryPoints->ClientStop = wfreerdp_client_stop; + return 0; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.h b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.h new file mode 100644 index 0000000000000000000000000000000000000000..85261765a91583485d7ff5aae1d88c3fe2d05e06 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_client.h @@ -0,0 +1,158 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Client + * + * Copyright 2009-2011 Jay Sorg + * Copyright 2010-2011 Vic Lee + * Copyright 2010-2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WIN_INTERFACE_H +#define FREERDP_CLIENT_WIN_INTERFACE_H + +#include + +#include + +#ifdef WITH_PROGRESS_BAR +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "wf_channels.h" +#include "wf_floatbar.h" +#include "wf_event.h" +#include "wf_cliprdr.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +// System menu constants +#define SYSCOMMAND_ID_SMARTSIZING 1000 +#define SYSCOMMAND_ID_REQUEST_CONTROL 1001 + + typedef struct + { + rdpBitmap _bitmap; + HDC hdc; + HBITMAP bitmap; + HBITMAP org_bitmap; + BYTE* pdata; + } wfBitmap; + + typedef struct + { + rdpPointer pointer; + HCURSOR cursor; + } wfPointer; + + struct wf_context + { + rdpClientContext common; + + int offset_x; + int offset_y; + int fullscreen_toggle; + int fullscreen; + int percentscreen; + WCHAR* window_title; + int client_x; + int client_y; + int client_width; + int client_height; + + HANDLE keyboardThread; + + HICON icon; + HWND hWndParent; + HINSTANCE hInstance; + WNDCLASSEX wndClass; + LPCTSTR wndClassName; + HCURSOR hDefaultCursor; + + UINT systemMenuInsertPosition; + + HWND hwnd; + BOOL is_shown; + ITaskbarList3* taskBarList; + POINT diff; + + wfBitmap* primary; + wfBitmap* drawing; + HCURSOR cursor; + HBRUSH brush; + HBRUSH org_brush; + RECT update_rect; + RECT scale_update_rect; + + DWORD mainThreadId; + DWORD keyboardThreadId; + + rdpFile* connectionRdpFile; + + BOOL disablewindowtracking; + + BOOL updating_scrollbars; + BOOL xScrollVisible; + int xMinScroll; + int xCurrentScroll; + int xMaxScroll; + + BOOL yScrollVisible; + int yMinScroll; + int yCurrentScroll; + int yMaxScroll; + + void* clipboard; + CliprdrClientContext* cliprdr; + + wfFloatBar* floatbar; + + RailClientContext* rail; + wHashTable* railWindows; + BOOL isConsole; + + DispClientContext* disp; + UINT64 lastSentDate; + BOOL wasMaximized; + }; + + /** + * Client Interface + */ + + FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints); + FREERDP_API int freerdp_client_set_window_size(wfContext* wfc, int width, int height); + FREERDP_API void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_height); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_CLIENT_WIN_INTERFACE_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.c b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.c new file mode 100644 index 0000000000000000000000000000000000000000..beddce8f934d86b8980788a3741f68ff5bf101b7 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.c @@ -0,0 +1,2549 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Clipboard Redirection + * + * Copyright 2012 Jason Champion + * Copyright 2014 Marc-Andre Moreau + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 DI (FH) Martin Haimberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#define CINTERFACE +#define COBJMACROS + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include "wf_cliprdr.h" + +#define TAG CLIENT_TAG("windows") + +#ifdef WITH_DEBUG_CLIPRDR +#define DEBUG_CLIPRDR(...) WLog_DBG(TAG, __VA_ARGS__) +#else +#define DEBUG_CLIPRDR(...) \ + do \ + { \ + } while (0) +#endif + +typedef BOOL(WINAPI* fnAddClipboardFormatListener)(HWND hwnd); +typedef BOOL(WINAPI* fnRemoveClipboardFormatListener)(HWND hwnd); +typedef BOOL(WINAPI* fnGetUpdatedClipboardFormats)(PUINT lpuiFormats, UINT cFormats, + PUINT pcFormatsOut); + +typedef struct +{ + UINT32 remote_format_id; + UINT32 local_format_id; + WCHAR* name; +} formatMapping; + +typedef struct +{ + IEnumFORMATETC iEnumFORMATETC; + + LONG m_lRefCount; + LONG m_nIndex; + LONG m_nNumFormats; + FORMATETC* m_pFormatEtc; +} CliprdrEnumFORMATETC; + +typedef struct +{ + IStream iStream; + + LONG m_lRefCount; + ULONG m_lIndex; + ULARGE_INTEGER m_lSize; + ULARGE_INTEGER m_lOffset; + FILEDESCRIPTORW m_Dsc; + void* m_pData; +} CliprdrStream; + +typedef struct +{ + IDataObject iDataObject; + + LONG m_lRefCount; + FORMATETC* m_pFormatEtc; + STGMEDIUM* m_pStgMedium; + ULONG m_nNumFormats; + ULONG m_nStreams; + IStream** m_pStream; + void* m_pData; +} CliprdrDataObject; + +typedef struct +{ + wfContext* wfc; + rdpChannels* channels; + CliprdrClientContext* context; + + BOOL sync; + UINT32 capabilities; + + size_t map_size; + size_t map_capacity; + formatMapping* format_mappings; + + UINT32 requestedFormatId; + + HWND hwnd; + HANDLE hmem; + HANDLE thread; + HANDLE response_data_event; + + LPDATAOBJECT data_obj; + ULONG req_fsize; + char* req_fdata; + HANDLE req_fevent; + + size_t nFiles; + size_t file_array_size; + WCHAR** file_names; + FILEDESCRIPTORW** fileDescriptor; + + BOOL legacyApi; + HMODULE hUser32; + HWND hWndNextViewer; + fnAddClipboardFormatListener AddClipboardFormatListener; + fnRemoveClipboardFormatListener RemoveClipboardFormatListener; + fnGetUpdatedClipboardFormats GetUpdatedClipboardFormats; +} wfClipboard; + +#define WM_CLIPRDR_MESSAGE (WM_USER + 156) +#define OLE_SETCLIPBOARD 1 + +static BOOL wf_create_file_obj(wfClipboard* cliprdrrdr, IDataObject** ppDataObject); +static void wf_destroy_file_obj(IDataObject* instance); +static UINT32 get_remote_format_id(wfClipboard* clipboard, UINT32 local_format); +static UINT cliprdr_send_data_request(wfClipboard* clipboard, UINT32 format); +static UINT cliprdr_send_lock(wfClipboard* clipboard); +static UINT cliprdr_send_unlock(wfClipboard* clipboard); +static UINT cliprdr_send_request_filecontents(wfClipboard* clipboard, const void* streamid, + ULONG index, UINT32 flag, UINT64 position, + ULONG request); + +static void CliprdrDataObject_Delete(CliprdrDataObject* instance); + +static CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pFormatEtc); +static void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance); + +static void CliprdrStream_Delete(CliprdrStream* instance); + +static BOOL try_open_clipboard(HWND hwnd) +{ + for (size_t x = 0; x < 10; x++) + { + if (OpenClipboard(hwnd)) + return TRUE; + Sleep(10); + } + return FALSE; +} + +/** + * IStream + */ + +static HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream* This, REFIID riid, + void** ppvObject) +{ + if (IsEqualIID(riid, &IID_IStream) || IsEqualIID(riid, &IID_IUnknown)) + { + IStream_AddRef(This); + *ppvObject = This; + return S_OK; + } + else + { + *ppvObject = 0; + return E_NOINTERFACE; + } +} + +static ULONG STDMETHODCALLTYPE CliprdrStream_AddRef(IStream* This) +{ + CliprdrStream* instance = (CliprdrStream*)This; + + if (!instance) + return 0; + + return InterlockedIncrement(&instance->m_lRefCount); +} + +static ULONG STDMETHODCALLTYPE CliprdrStream_Release(IStream* This) +{ + LONG count; + CliprdrStream* instance = (CliprdrStream*)This; + + if (!instance) + return 0; + + count = InterlockedDecrement(&instance->m_lRefCount); + + if (count == 0) + { + CliprdrStream_Delete(instance); + return 0; + } + else + { + return count; + } +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream* This, void* pv, ULONG cb, + ULONG* pcbRead) +{ + int ret; + CliprdrStream* instance = (CliprdrStream*)This; + wfClipboard* clipboard; + + if (!pv || !pcbRead || !instance) + return E_INVALIDARG; + + clipboard = (wfClipboard*)instance->m_pData; + *pcbRead = 0; + + if (instance->m_lOffset.QuadPart >= instance->m_lSize.QuadPart) + return S_FALSE; + + ret = cliprdr_send_request_filecontents(clipboard, (void*)This, instance->m_lIndex, + FILECONTENTS_RANGE, instance->m_lOffset.QuadPart, cb); + + if (ret < 0) + return E_FAIL; + + if (clipboard->req_fdata) + { + CopyMemory(pv, clipboard->req_fdata, clipboard->req_fsize); + free(clipboard->req_fdata); + } + + *pcbRead = clipboard->req_fsize; + instance->m_lOffset.QuadPart += clipboard->req_fsize; + + if (clipboard->req_fsize < cb) + return S_FALSE; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream* This, const void* pv, ULONG cb, + ULONG* pcbWritten) +{ + (void)This; + (void)pv; + (void)cb; + (void)pcbWritten; + return STG_E_ACCESSDENIED; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream* This, LARGE_INTEGER dlibMove, + DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) +{ + ULONGLONG newoffset; + CliprdrStream* instance = (CliprdrStream*)This; + + if (!instance) + return E_INVALIDARG; + + newoffset = instance->m_lOffset.QuadPart; + + switch (dwOrigin) + { + case STREAM_SEEK_SET: + newoffset = dlibMove.QuadPart; + break; + + case STREAM_SEEK_CUR: + newoffset += dlibMove.QuadPart; + break; + + case STREAM_SEEK_END: + newoffset = instance->m_lSize.QuadPart + dlibMove.QuadPart; + break; + + default: + return E_INVALIDARG; + } + + if (newoffset < 0 || newoffset >= instance->m_lSize.QuadPart) + return E_FAIL; + + instance->m_lOffset.QuadPart = newoffset; + + if (plibNewPosition) + plibNewPosition->QuadPart = instance->m_lOffset.QuadPart; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_SetSize(IStream* This, ULARGE_INTEGER libNewSize) +{ + (void)This; + (void)libNewSize; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream* This, IStream* pstm, + ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, + ULARGE_INTEGER* pcbWritten) +{ + (void)This; + (void)pstm; + (void)cb; + (void)pcbRead; + (void)pcbWritten; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Commit(IStream* This, DWORD grfCommitFlags) +{ + (void)This; + (void)grfCommitFlags; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Revert(IStream* This) +{ + (void)This; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream* This, ULARGE_INTEGER libOffset, + ULARGE_INTEGER cb, DWORD dwLockType) +{ + (void)This; + (void)libOffset; + (void)cb; + (void)dwLockType; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream* This, ULARGE_INTEGER libOffset, + ULARGE_INTEGER cb, DWORD dwLockType) +{ + (void)This; + (void)libOffset; + (void)cb; + (void)dwLockType; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream* This, STATSTG* pstatstg, + DWORD grfStatFlag) +{ + CliprdrStream* instance = (CliprdrStream*)This; + + if (!instance) + return E_INVALIDARG; + + if (pstatstg == NULL) + return STG_E_INVALIDPOINTER; + + ZeroMemory(pstatstg, sizeof(STATSTG)); + + switch (grfStatFlag) + { + case STATFLAG_DEFAULT: + return STG_E_INSUFFICIENTMEMORY; + + case STATFLAG_NONAME: + pstatstg->cbSize.QuadPart = instance->m_lSize.QuadPart; + pstatstg->grfLocksSupported = LOCK_EXCLUSIVE; + pstatstg->grfMode = GENERIC_READ; + pstatstg->grfStateBits = 0; + pstatstg->type = STGTY_STREAM; + break; + + case STATFLAG_NOOPEN: + return STG_E_INVALIDFLAG; + + default: + return STG_E_INVALIDFLAG; + } + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream* This, IStream** ppstm) +{ + (void)This; + (void)ppstm; + return E_NOTIMPL; +} + +static CliprdrStream* CliprdrStream_New(ULONG index, void* pData, const FILEDESCRIPTORW* dsc) +{ + IStream* iStream; + BOOL success = FALSE; + BOOL isDir = FALSE; + CliprdrStream* instance; + wfClipboard* clipboard = (wfClipboard*)pData; + instance = (CliprdrStream*)calloc(1, sizeof(CliprdrStream)); + + if (instance) + { + instance->m_Dsc = *dsc; + iStream = &instance->iStream; + iStream->lpVtbl = (IStreamVtbl*)calloc(1, sizeof(IStreamVtbl)); + + if (iStream->lpVtbl) + { + iStream->lpVtbl->QueryInterface = CliprdrStream_QueryInterface; + iStream->lpVtbl->AddRef = CliprdrStream_AddRef; + iStream->lpVtbl->Release = CliprdrStream_Release; + iStream->lpVtbl->Read = CliprdrStream_Read; + iStream->lpVtbl->Write = CliprdrStream_Write; + iStream->lpVtbl->Seek = CliprdrStream_Seek; + iStream->lpVtbl->SetSize = CliprdrStream_SetSize; + iStream->lpVtbl->CopyTo = CliprdrStream_CopyTo; + iStream->lpVtbl->Commit = CliprdrStream_Commit; + iStream->lpVtbl->Revert = CliprdrStream_Revert; + iStream->lpVtbl->LockRegion = CliprdrStream_LockRegion; + iStream->lpVtbl->UnlockRegion = CliprdrStream_UnlockRegion; + iStream->lpVtbl->Stat = CliprdrStream_Stat; + iStream->lpVtbl->Clone = CliprdrStream_Clone; + instance->m_lRefCount = 1; + instance->m_lIndex = index; + instance->m_pData = pData; + instance->m_lOffset.QuadPart = 0; + + if (instance->m_Dsc.dwFlags & FD_ATTRIBUTES) + { + if (instance->m_Dsc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + isDir = TRUE; + } + + if (((instance->m_Dsc.dwFlags & FD_FILESIZE) == 0) && !isDir) + { + /* get content size of this stream */ + if (cliprdr_send_request_filecontents(clipboard, (void*)instance, + instance->m_lIndex, FILECONTENTS_SIZE, 0, + 8) == CHANNEL_RC_OK) + { + success = TRUE; + } + + instance->m_lSize.QuadPart = *((LONGLONG*)clipboard->req_fdata); + free(clipboard->req_fdata); + } + else + { + instance->m_lSize.QuadPart = + ((UINT64)instance->m_Dsc.nFileSizeHigh << 32) | instance->m_Dsc.nFileSizeLow; + success = TRUE; + } + } + } + + if (!success) + { + CliprdrStream_Delete(instance); + instance = NULL; + } + + return instance; +} + +void CliprdrStream_Delete(CliprdrStream* instance) +{ + if (instance) + { + free(instance->iStream.lpVtbl); + free(instance); + } +} + +/** + * IDataObject + */ + +static LONG cliprdr_lookup_format(CliprdrDataObject* instance, FORMATETC* pFormatEtc) +{ + if (!instance || !pFormatEtc) + return -1; + + for (ULONG i = 0; i < instance->m_nNumFormats; i++) + { + if ((pFormatEtc->tymed & instance->m_pFormatEtc[i].tymed) && + pFormatEtc->cfFormat == instance->m_pFormatEtc[i].cfFormat && + pFormatEtc->dwAspect & instance->m_pFormatEtc[i].dwAspect) + { + return (LONG)i; + } + } + + return -1; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(IDataObject* This, REFIID riid, + void** ppvObject) +{ + (void)This; + + if (!ppvObject) + return E_INVALIDARG; + + if (IsEqualIID(riid, &IID_IDataObject) || IsEqualIID(riid, &IID_IUnknown)) + { + IDataObject_AddRef(This); + *ppvObject = This; + return S_OK; + } + else + { + *ppvObject = 0; + return E_NOINTERFACE; + } +} + +static ULONG STDMETHODCALLTYPE CliprdrDataObject_AddRef(IDataObject* This) +{ + CliprdrDataObject* instance = (CliprdrDataObject*)This; + + if (!instance) + return E_INVALIDARG; + + return InterlockedIncrement(&instance->m_lRefCount); +} + +static ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject* This) +{ + LONG count; + CliprdrDataObject* instance = (CliprdrDataObject*)This; + + if (!instance) + return E_INVALIDARG; + + count = InterlockedDecrement(&instance->m_lRefCount); + + if (count == 0) + { + CliprdrDataObject_Delete(instance); + return 0; + } + else + return count; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject* This, FORMATETC* pFormatEtc, + STGMEDIUM* pMedium) +{ + LONG idx; + CliprdrDataObject* instance = (CliprdrDataObject*)This; + wfClipboard* clipboard; + + if (!pFormatEtc || !pMedium || !instance) + return E_INVALIDARG; + + clipboard = (wfClipboard*)instance->m_pData; + + if (!clipboard) + return E_INVALIDARG; + + if ((idx = cliprdr_lookup_format(instance, pFormatEtc)) == -1) + return DV_E_FORMATETC; + + pMedium->tymed = instance->m_pFormatEtc[idx].tymed; + pMedium->pUnkForRelease = 0; + + if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)) + { + FILEGROUPDESCRIPTOR* dsc; + DWORD remote = get_remote_format_id(clipboard, instance->m_pFormatEtc[idx].cfFormat); + + if (cliprdr_send_data_request(clipboard, remote) != 0) + return E_UNEXPECTED; + + pMedium->u.hGlobal = clipboard->hmem; + /* points to a FILEGROUPDESCRIPTOR structure */ + /* GlobalLock returns a pointer to the first byte of the memory block, + * in which is a FILEGROUPDESCRIPTOR structure, whose first UINT member + * is the number of FILEDESCRIPTOR's */ + dsc = (FILEGROUPDESCRIPTOR*)GlobalLock(clipboard->hmem); + instance->m_nStreams = dsc->cItems; + GlobalUnlock(clipboard->hmem); + + if (instance->m_nStreams > 0) + { + if (!instance->m_pStream) + { + instance->m_pStream = (LPSTREAM*)calloc(instance->m_nStreams, sizeof(LPSTREAM)); + + if (instance->m_pStream) + { + for (ULONG i = 0; i < instance->m_nStreams; i++) + { + instance->m_pStream[i] = + (IStream*)CliprdrStream_New(i, clipboard, &dsc->fgd[i]); + + if (!instance->m_pStream[i]) + return E_OUTOFMEMORY; + } + } + } + } + + if (!instance->m_pStream) + { + if (clipboard->hmem) + { + GlobalFree(clipboard->hmem); + clipboard->hmem = NULL; + } + + pMedium->u.hGlobal = NULL; + return E_OUTOFMEMORY; + } + } + else if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(CFSTR_FILECONTENTS)) + { + if ((pFormatEtc->lindex >= 0) && ((ULONG)pFormatEtc->lindex < instance->m_nStreams)) + { + pMedium->u.pstm = instance->m_pStream[pFormatEtc->lindex]; + IDataObject_AddRef(instance->m_pStream[pFormatEtc->lindex]); + } + else + return E_INVALIDARG; + } + else + return E_UNEXPECTED; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(IDataObject* This, + FORMATETC* pformatetc, + STGMEDIUM* pmedium) +{ + (void)This; + (void)pformatetc; + (void)pmedium; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(IDataObject* This, + FORMATETC* pformatetc) +{ + CliprdrDataObject* instance = (CliprdrDataObject*)This; + + if (!pformatetc) + return E_INVALIDARG; + + if (cliprdr_lookup_format(instance, pformatetc) == -1) + return DV_E_FORMATETC; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(IDataObject* This, + FORMATETC* pformatectIn, + FORMATETC* pformatetcOut) +{ + (void)This; + (void)pformatectIn; + + if (!pformatetcOut) + return E_INVALIDARG; + + pformatetcOut->ptd = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(IDataObject* This, FORMATETC* pformatetc, + STGMEDIUM* pmedium, BOOL fRelease) +{ + (void)This; + (void)pformatetc; + (void)pmedium; + (void)fRelease; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(IDataObject* This, + DWORD dwDirection, + IEnumFORMATETC** ppenumFormatEtc) +{ + CliprdrDataObject* instance = (CliprdrDataObject*)This; + + if (!instance || !ppenumFormatEtc) + return E_INVALIDARG; + + if (dwDirection == DATADIR_GET) + { + *ppenumFormatEtc = (IEnumFORMATETC*)CliprdrEnumFORMATETC_New(instance->m_nNumFormats, + instance->m_pFormatEtc); + return (*ppenumFormatEtc) ? S_OK : E_OUTOFMEMORY; + } + else + { + return E_NOTIMPL; + } +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(IDataObject* This, FORMATETC* pformatetc, + DWORD advf, IAdviseSink* pAdvSink, + DWORD* pdwConnection) +{ + (void)This; + (void)pformatetc; + (void)advf; + (void)pAdvSink; + (void)pdwConnection; + return OLE_E_ADVISENOTSUPPORTED; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DUnadvise(IDataObject* This, DWORD dwConnection) +{ + (void)This; + (void)dwConnection; + return OLE_E_ADVISENOTSUPPORTED; +} + +static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(IDataObject* This, + IEnumSTATDATA** ppenumAdvise) +{ + (void)This; + (void)ppenumAdvise; + return OLE_E_ADVISENOTSUPPORTED; +} + +static CliprdrDataObject* CliprdrDataObject_New(FORMATETC* fmtetc, STGMEDIUM* stgmed, ULONG count, + void* data) +{ + CliprdrDataObject* instance; + IDataObject* iDataObject; + instance = (CliprdrDataObject*)calloc(1, sizeof(CliprdrDataObject)); + + if (!instance) + goto error; + + iDataObject = &instance->iDataObject; + iDataObject->lpVtbl = (IDataObjectVtbl*)calloc(1, sizeof(IDataObjectVtbl)); + + if (!iDataObject->lpVtbl) + goto error; + + iDataObject->lpVtbl->QueryInterface = CliprdrDataObject_QueryInterface; + iDataObject->lpVtbl->AddRef = CliprdrDataObject_AddRef; + iDataObject->lpVtbl->Release = CliprdrDataObject_Release; + iDataObject->lpVtbl->GetData = CliprdrDataObject_GetData; + iDataObject->lpVtbl->GetDataHere = CliprdrDataObject_GetDataHere; + iDataObject->lpVtbl->QueryGetData = CliprdrDataObject_QueryGetData; + iDataObject->lpVtbl->GetCanonicalFormatEtc = CliprdrDataObject_GetCanonicalFormatEtc; + iDataObject->lpVtbl->SetData = CliprdrDataObject_SetData; + iDataObject->lpVtbl->EnumFormatEtc = CliprdrDataObject_EnumFormatEtc; + iDataObject->lpVtbl->DAdvise = CliprdrDataObject_DAdvise; + iDataObject->lpVtbl->DUnadvise = CliprdrDataObject_DUnadvise; + iDataObject->lpVtbl->EnumDAdvise = CliprdrDataObject_EnumDAdvise; + instance->m_lRefCount = 1; + instance->m_nNumFormats = count; + instance->m_pData = data; + instance->m_nStreams = 0; + instance->m_pStream = NULL; + + if (count > 0) + { + instance->m_pFormatEtc = (FORMATETC*)calloc(count, sizeof(FORMATETC)); + + if (!instance->m_pFormatEtc) + goto error; + + instance->m_pStgMedium = (STGMEDIUM*)calloc(count, sizeof(STGMEDIUM)); + + if (!instance->m_pStgMedium) + goto error; + + for (ULONG i = 0; i < count; i++) + { + instance->m_pFormatEtc[i] = fmtetc[i]; + instance->m_pStgMedium[i] = stgmed[i]; + } + } + + return instance; +error: + CliprdrDataObject_Delete(instance); + return NULL; +} + +void CliprdrDataObject_Delete(CliprdrDataObject* instance) +{ + if (instance) + { + free(instance->iDataObject.lpVtbl); + free(instance->m_pFormatEtc); + free(instance->m_pStgMedium); + + if (instance->m_pStream) + { + for (ULONG i = 0; i < instance->m_nStreams; i++) + CliprdrStream_Release(instance->m_pStream[i]); + + free(instance->m_pStream); + } + + free(instance); + } +} + +static BOOL wf_create_file_obj(wfClipboard* clipboard, IDataObject** ppDataObject) +{ + FORMATETC fmtetc[2] = { 0 }; + STGMEDIUM stgmeds[2] = { 0 }; + + if (!ppDataObject) + return FALSE; + + fmtetc[0].cfFormat = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW); + fmtetc[0].dwAspect = DVASPECT_CONTENT; + + fmtetc[0].tymed = TYMED_HGLOBAL; + stgmeds[0].tymed = TYMED_HGLOBAL; + + fmtetc[1].cfFormat = RegisterClipboardFormat(CFSTR_FILECONTENTS); + fmtetc[1].dwAspect = DVASPECT_CONTENT; + + fmtetc[1].tymed = TYMED_ISTREAM; + stgmeds[1].tymed = TYMED_ISTREAM; + + *ppDataObject = (IDataObject*)CliprdrDataObject_New(fmtetc, stgmeds, 2, clipboard); + return (*ppDataObject) ? TRUE : FALSE; +} + +static void wf_destroy_file_obj(IDataObject* instance) +{ + if (instance) + IDataObject_Release(instance); +} + +/** + * IEnumFORMATETC + */ + +static void cliprdr_format_deep_copy(FORMATETC* dest, FORMATETC* source) +{ + *dest = *source; + + if (source->ptd) + { + dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE)); + + if (dest->ptd) + *(dest->ptd) = *(source->ptd); + } +} + +static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(IEnumFORMATETC* This, + REFIID riid, void** ppvObject) +{ + (void)This; + + if (IsEqualIID(riid, &IID_IEnumFORMATETC) || IsEqualIID(riid, &IID_IUnknown)) + { + IEnumFORMATETC_AddRef(This); + *ppvObject = This; + return S_OK; + } + else + { + *ppvObject = 0; + return E_NOINTERFACE; + } +} + +static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_AddRef(IEnumFORMATETC* This) +{ + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance) + return 0; + + return InterlockedIncrement(&instance->m_lRefCount); +} + +static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(IEnumFORMATETC* This) +{ + LONG count; + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance) + return 0; + + count = InterlockedDecrement(&instance->m_lRefCount); + + if (count == 0) + { + CliprdrEnumFORMATETC_Delete(instance); + return 0; + } + else + { + return count; + } +} + +static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC* This, ULONG celt, + FORMATETC* rgelt, ULONG* pceltFetched) +{ + ULONG copied = 0; + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance || !celt || !rgelt) + return E_INVALIDARG; + + while ((instance->m_nIndex < instance->m_nNumFormats) && (copied < celt)) + { + cliprdr_format_deep_copy(&rgelt[copied++], &instance->m_pFormatEtc[instance->m_nIndex++]); + } + + if (pceltFetched != 0) + *pceltFetched = copied; + + return (copied == celt) ? S_OK : E_FAIL; +} + +static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Skip(IEnumFORMATETC* This, ULONG celt) +{ + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance) + return E_INVALIDARG; + + if (instance->m_nIndex + (LONG)celt > instance->m_nNumFormats) + return E_FAIL; + + instance->m_nIndex += celt; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(IEnumFORMATETC* This) +{ + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance) + return E_INVALIDARG; + + instance->m_nIndex = 0; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(IEnumFORMATETC* This, + IEnumFORMATETC** ppEnum) +{ + CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This; + + if (!instance || !ppEnum) + return E_INVALIDARG; + + *ppEnum = + (IEnumFORMATETC*)CliprdrEnumFORMATETC_New(instance->m_nNumFormats, instance->m_pFormatEtc); + + if (!*ppEnum) + return E_OUTOFMEMORY; + + ((CliprdrEnumFORMATETC*)*ppEnum)->m_nIndex = instance->m_nIndex; + return S_OK; +} + +CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pFormatEtc) +{ + CliprdrEnumFORMATETC* instance; + IEnumFORMATETC* iEnumFORMATETC; + + if ((nFormats != 0) && !pFormatEtc) + return NULL; + + instance = (CliprdrEnumFORMATETC*)calloc(1, sizeof(CliprdrEnumFORMATETC)); + + if (!instance) + goto error; + + iEnumFORMATETC = &instance->iEnumFORMATETC; + iEnumFORMATETC->lpVtbl = (IEnumFORMATETCVtbl*)calloc(1, sizeof(IEnumFORMATETCVtbl)); + + if (!iEnumFORMATETC->lpVtbl) + goto error; + + iEnumFORMATETC->lpVtbl->QueryInterface = CliprdrEnumFORMATETC_QueryInterface; + iEnumFORMATETC->lpVtbl->AddRef = CliprdrEnumFORMATETC_AddRef; + iEnumFORMATETC->lpVtbl->Release = CliprdrEnumFORMATETC_Release; + iEnumFORMATETC->lpVtbl->Next = CliprdrEnumFORMATETC_Next; + iEnumFORMATETC->lpVtbl->Skip = CliprdrEnumFORMATETC_Skip; + iEnumFORMATETC->lpVtbl->Reset = CliprdrEnumFORMATETC_Reset; + iEnumFORMATETC->lpVtbl->Clone = CliprdrEnumFORMATETC_Clone; + instance->m_lRefCount = 1; + instance->m_nIndex = 0; + instance->m_nNumFormats = nFormats; + + if (nFormats > 0) + { + instance->m_pFormatEtc = (FORMATETC*)calloc(nFormats, sizeof(FORMATETC)); + + if (!instance->m_pFormatEtc) + goto error; + + for (ULONG i = 0; i < nFormats; i++) + cliprdr_format_deep_copy(&instance->m_pFormatEtc[i], &pFormatEtc[i]); + } + + return instance; +error: + CliprdrEnumFORMATETC_Delete(instance); + return NULL; +} + +void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance) +{ + if (instance) + { + free(instance->iEnumFORMATETC.lpVtbl); + + if (instance->m_pFormatEtc) + { + for (LONG i = 0; i < instance->m_nNumFormats; i++) + { + if (instance->m_pFormatEtc[i].ptd) + CoTaskMemFree(instance->m_pFormatEtc[i].ptd); + } + + free(instance->m_pFormatEtc); + } + + free(instance); + } +} + +/***********************************************************************************/ + +static UINT32 get_local_format_id_by_name(wfClipboard* clipboard, const TCHAR* format_name) +{ + formatMapping* map; + WCHAR* unicode_name; +#if !defined(UNICODE) + size_t size; +#endif + + if (!clipboard || !format_name) + return 0; + +#if defined(UNICODE) + unicode_name = _wcsdup(format_name); +#else + size = _tcslen(format_name); + unicode_name = calloc(size + 1, sizeof(WCHAR)); + + if (!unicode_name) + return 0; + + MultiByteToWideChar(CP_OEMCP, 0, format_name, strlen(format_name), unicode_name, size); +#endif + + if (!unicode_name) + return 0; + + for (size_t i = 0; i < clipboard->map_size; i++) + { + map = &clipboard->format_mappings[i]; + + if (map->name) + { + if (wcscmp(map->name, unicode_name) == 0) + { + free(unicode_name); + return map->local_format_id; + } + } + } + + free(unicode_name); + return 0; +} + +static INLINE BOOL file_transferring(wfClipboard* clipboard) +{ + return get_local_format_id_by_name(clipboard, CFSTR_FILEDESCRIPTORW) ? TRUE : FALSE; +} + +static UINT32 get_remote_format_id(wfClipboard* clipboard, UINT32 local_format) +{ + formatMapping* map; + + if (!clipboard) + return 0; + + for (UINT32 i = 0; i < clipboard->map_size; i++) + { + map = &clipboard->format_mappings[i]; + + if (map->local_format_id == local_format) + return map->remote_format_id; + } + + return local_format; +} + +static void map_ensure_capacity(wfClipboard* clipboard) +{ + if (!clipboard) + return; + + if (clipboard->map_size >= clipboard->map_capacity) + { + size_t new_size; + formatMapping* new_map; + new_size = clipboard->map_capacity * 2; + new_map = + (formatMapping*)realloc(clipboard->format_mappings, sizeof(formatMapping) * new_size); + + if (!new_map) + return; + + clipboard->format_mappings = new_map; + clipboard->map_capacity = new_size; + } +} + +static BOOL clear_format_map(wfClipboard* clipboard) +{ + formatMapping* map; + + if (!clipboard) + return FALSE; + + if (clipboard->format_mappings) + { + for (size_t i = 0; i < clipboard->map_capacity; i++) + { + map = &clipboard->format_mappings[i]; + map->remote_format_id = 0; + map->local_format_id = 0; + free(map->name); + map->name = NULL; + } + } + + clipboard->map_size = 0; + return TRUE; +} + +static UINT cliprdr_send_tempdir(wfClipboard* clipboard) +{ + CLIPRDR_TEMP_DIRECTORY tempDirectory; + + if (!clipboard) + return -1; + + if (GetEnvironmentVariableA("TEMP", tempDirectory.szTempDir, sizeof(tempDirectory.szTempDir)) == + 0) + return -1; + + return clipboard->context->TempDirectory(clipboard->context, &tempDirectory); +} + +static BOOL cliprdr_GetUpdatedClipboardFormats(wfClipboard* clipboard, PUINT lpuiFormats, + UINT cFormats, PUINT pcFormatsOut) +{ + UINT index = 0; + UINT format = 0; + BOOL clipboardOpen = FALSE; + + if (!clipboard->legacyApi) + return clipboard->GetUpdatedClipboardFormats(lpuiFormats, cFormats, pcFormatsOut); + + clipboardOpen = try_open_clipboard(clipboard->hwnd); + + if (!clipboardOpen) + { + *pcFormatsOut = 0; + return TRUE; /* Other app holding clipboard */ + } + + while (index < cFormats) + { + format = EnumClipboardFormats(format); + + if (!format) + break; + + lpuiFormats[index] = format; + index++; + } + + *pcFormatsOut = index; + CloseClipboard(); + return TRUE; +} + +static UINT cliprdr_send_format_list(wfClipboard* clipboard) +{ + UINT rc; + int count = 0; + UINT32 numFormats = 0; + UINT32 formatId = 0; + char formatName[1024]; + CLIPRDR_FORMAT* formats = NULL; + CLIPRDR_FORMAT_LIST formatList = { 0 }; + + if (!clipboard) + return ERROR_INTERNAL_ERROR; + + /* Ignore if other app is holding clipboard */ + if (try_open_clipboard(clipboard->hwnd)) + { + count = CountClipboardFormats(); + numFormats = (UINT32)count; + formats = (CLIPRDR_FORMAT*)calloc(numFormats, sizeof(CLIPRDR_FORMAT)); + + if (!formats) + { + CloseClipboard(); + return CHANNEL_RC_NO_MEMORY; + } + + { + UINT32 index = 0; + + if (IsClipboardFormatAvailable(CF_HDROP)) + { + formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW); + formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILECONTENTS); + } + else + { + while ((formatId = EnumClipboardFormats(formatId)) != 0) + formats[index++].formatId = formatId; + } + + numFormats = index; + } + + if (!CloseClipboard()) + { + free(formats); + return ERROR_INTERNAL_ERROR; + } + + for (UINT index = 0; index < numFormats; index++) + { + if (GetClipboardFormatNameA(formats[index].formatId, formatName, sizeof(formatName))) + { + formats[index].formatName = _strdup(formatName); + } + } + } + + formatList.numFormats = numFormats; + formatList.formats = formats; + formatList.common.msgType = CB_FORMAT_LIST; + rc = clipboard->context->ClientFormatList(clipboard->context, &formatList); + + for (UINT index = 0; index < numFormats; index++) + free(formats[index].formatName); + + free(formats); + return rc; +} + +static UINT cliprdr_send_data_request(wfClipboard* clipboard, UINT32 formatId) +{ + UINT rc; + UINT32 remoteFormatId; + CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest; + + if (!clipboard || !clipboard->context || !clipboard->context->ClientFormatDataRequest) + return ERROR_INTERNAL_ERROR; + + remoteFormatId = get_remote_format_id(clipboard, formatId); + + formatDataRequest.requestedFormatId = remoteFormatId; + clipboard->requestedFormatId = formatId; + rc = clipboard->context->ClientFormatDataRequest(clipboard->context, &formatDataRequest); + + if (WaitForSingleObject(clipboard->response_data_event, INFINITE) != WAIT_OBJECT_0) + rc = ERROR_INTERNAL_ERROR; + else if (!ResetEvent(clipboard->response_data_event)) + rc = ERROR_INTERNAL_ERROR; + + return rc; +} + +UINT cliprdr_send_request_filecontents(wfClipboard* clipboard, const void* streamid, ULONG index, + UINT32 flag, UINT64 position, ULONG nreq) +{ + UINT rc; + CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest; + + if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsRequest) + return ERROR_INTERNAL_ERROR; + + fileContentsRequest.streamId = (UINT32)(ULONG_PTR)streamid; + fileContentsRequest.listIndex = index; + fileContentsRequest.dwFlags = flag; + fileContentsRequest.nPositionLow = position & 0xFFFFFFFF; + fileContentsRequest.nPositionHigh = (position >> 32) & 0xFFFFFFFF; + fileContentsRequest.cbRequested = nreq; + fileContentsRequest.clipDataId = 0; + fileContentsRequest.common.msgFlags = 0; + rc = clipboard->context->ClientFileContentsRequest(clipboard->context, &fileContentsRequest); + + if (WaitForSingleObject(clipboard->req_fevent, INFINITE) != WAIT_OBJECT_0) + rc = ERROR_INTERNAL_ERROR; + else if (!ResetEvent(clipboard->req_fevent)) + rc = ERROR_INTERNAL_ERROR; + + return rc; +} + +static UINT cliprdr_send_response_filecontents(wfClipboard* clipboard, UINT32 streamId, UINT32 size, + BYTE* data) +{ + CLIPRDR_FILE_CONTENTS_RESPONSE fileContentsResponse; + + if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsResponse) + return ERROR_INTERNAL_ERROR; + + fileContentsResponse.streamId = streamId; + fileContentsResponse.cbRequested = size; + fileContentsResponse.requestedData = data; + fileContentsResponse.common.msgFlags = CB_RESPONSE_OK; + return clipboard->context->ClientFileContentsResponse(clipboard->context, + &fileContentsResponse); +} + +static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + static wfClipboard* clipboard = NULL; + + switch (Msg) + { + case WM_CREATE: + DEBUG_CLIPRDR("info: WM_CREATE"); + clipboard = (wfClipboard*)((CREATESTRUCT*)lParam)->lpCreateParams; + clipboard->hwnd = hWnd; + + if (!clipboard->legacyApi) + clipboard->AddClipboardFormatListener(hWnd); + else + clipboard->hWndNextViewer = SetClipboardViewer(hWnd); + + break; + + case WM_CLOSE: + DEBUG_CLIPRDR("info: WM_CLOSE"); + + if (!clipboard->legacyApi) + clipboard->RemoveClipboardFormatListener(hWnd); + + break; + + case WM_DESTROY: + if (clipboard->legacyApi) + ChangeClipboardChain(hWnd, clipboard->hWndNextViewer); + + break; + + case WM_CLIPBOARDUPDATE: + DEBUG_CLIPRDR("info: WM_CLIPBOARDUPDATE"); + + if (clipboard->sync) + { + if ((GetClipboardOwner() != clipboard->hwnd) && + (S_FALSE == OleIsCurrentClipboard(clipboard->data_obj))) + { + if (clipboard->hmem) + { + GlobalFree(clipboard->hmem); + clipboard->hmem = NULL; + } + + cliprdr_send_format_list(clipboard); + } + } + + break; + + case WM_RENDERALLFORMATS: + DEBUG_CLIPRDR("info: WM_RENDERALLFORMATS"); + + /* discard all contexts in clipboard */ + if (!try_open_clipboard(clipboard->hwnd)) + { + DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError()); + break; + } + + EmptyClipboard(); + CloseClipboard(); + break; + + case WM_RENDERFORMAT: + DEBUG_CLIPRDR("info: WM_RENDERFORMAT"); + + if (cliprdr_send_data_request(clipboard, (UINT32)wParam) != 0) + { + DEBUG_CLIPRDR("error: cliprdr_send_data_request failed."); + break; + } + + if (!SetClipboardData((UINT)wParam, clipboard->hmem)) + { + DEBUG_CLIPRDR("SetClipboardData failed with 0x%x", GetLastError()); + + if (clipboard->hmem) + { + GlobalFree(clipboard->hmem); + clipboard->hmem = NULL; + } + } + + /* Note: GlobalFree() is not needed when success */ + break; + + case WM_DRAWCLIPBOARD: + if (clipboard->legacyApi) + { + if ((GetClipboardOwner() != clipboard->hwnd) && + (S_FALSE == OleIsCurrentClipboard(clipboard->data_obj))) + { + cliprdr_send_format_list(clipboard); + } + + SendMessage(clipboard->hWndNextViewer, Msg, wParam, lParam); + } + + break; + + case WM_CHANGECBCHAIN: + if (clipboard->legacyApi) + { + HWND hWndCurrViewer = (HWND)wParam; + HWND hWndNextViewer = (HWND)lParam; + + if (hWndCurrViewer == clipboard->hWndNextViewer) + clipboard->hWndNextViewer = hWndNextViewer; + else if (clipboard->hWndNextViewer) + SendMessage(clipboard->hWndNextViewer, Msg, wParam, lParam); + } + + break; + + case WM_CLIPRDR_MESSAGE: + DEBUG_CLIPRDR("info: WM_CLIPRDR_MESSAGE"); + + switch (wParam) + { + case OLE_SETCLIPBOARD: + DEBUG_CLIPRDR("info: OLE_SETCLIPBOARD"); + + if (wf_create_file_obj(clipboard, &clipboard->data_obj)) + { + if (OleSetClipboard(clipboard->data_obj) != S_OK) + { + wf_destroy_file_obj(clipboard->data_obj); + clipboard->data_obj = NULL; + } + } + + break; + + default: + break; + } + + break; + + case WM_DESTROYCLIPBOARD: + case WM_ASKCBFORMATNAME: + case WM_HSCROLLCLIPBOARD: + case WM_PAINTCLIPBOARD: + case WM_SIZECLIPBOARD: + case WM_VSCROLLCLIPBOARD: + default: + return DefWindowProc(hWnd, Msg, wParam, lParam); + } + + return 0; +} + +static int create_cliprdr_window(wfClipboard* clipboard) +{ + WNDCLASSEX wnd_cls = { 0 }; + + wnd_cls.cbSize = sizeof(WNDCLASSEX); + wnd_cls.style = CS_OWNDC; + wnd_cls.lpfnWndProc = cliprdr_proc; + wnd_cls.cbClsExtra = 0; + wnd_cls.cbWndExtra = 0; + wnd_cls.hIcon = NULL; + wnd_cls.hCursor = NULL; + wnd_cls.hbrBackground = NULL; + wnd_cls.lpszMenuName = NULL; + wnd_cls.lpszClassName = _T("ClipboardHiddenMessageProcessor"); + wnd_cls.hInstance = GetModuleHandle(NULL); + wnd_cls.hIconSm = NULL; + RegisterClassEx(&wnd_cls); + clipboard->hwnd = + CreateWindowEx(WS_EX_LEFT, _T("ClipboardHiddenMessageProcessor"), _T("rdpclip"), 0, 0, 0, 0, + 0, HWND_MESSAGE, NULL, GetModuleHandle(NULL), clipboard); + + if (!clipboard->hwnd) + { + DEBUG_CLIPRDR("error: CreateWindowEx failed with %x.", GetLastError()); + return -1; + } + + return 0; +} + +static DWORD WINAPI cliprdr_thread_func(LPVOID arg) +{ + int ret; + MSG msg; + BOOL mcode; + wfClipboard* clipboard = (wfClipboard*)arg; + OleInitialize(0); + + if ((ret = create_cliprdr_window(clipboard)) != 0) + { + OleUninitialize(); + DEBUG_CLIPRDR("error: create clipboard window failed."); + return 0; + } + + while ((mcode = GetMessage(&msg, 0, 0, 0)) != 0) + { + if (mcode == -1) + { + DEBUG_CLIPRDR("error: clipboard thread GetMessage failed."); + break; + } + else + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + OleUninitialize(); + return 0; +} + +static void clear_file_array(wfClipboard* clipboard) +{ + if (!clipboard) + return; + + /* clear file_names array */ + if (clipboard->file_names) + { + for (size_t i = 0; i < clipboard->nFiles; i++) + { + free(clipboard->file_names[i]); + clipboard->file_names[i] = NULL; + } + + free(clipboard->file_names); + clipboard->file_names = NULL; + } + + /* clear fileDescriptor array */ + if (clipboard->fileDescriptor) + { + for (size_t i = 0; i < clipboard->nFiles; i++) + { + free(clipboard->fileDescriptor[i]); + clipboard->fileDescriptor[i] = NULL; + } + + free(clipboard->fileDescriptor); + clipboard->fileDescriptor = NULL; + } + + clipboard->file_array_size = 0; + clipboard->nFiles = 0; +} + +static BOOL wf_cliprdr_get_file_contents(WCHAR* file_name, BYTE* buffer, LONG positionLow, + LONG positionHigh, DWORD nRequested, DWORD* puSize) +{ + BOOL res = FALSE; + HANDLE hFile; + DWORD nGet, rc; + + if (!file_name || !buffer || !puSize) + { + WLog_ERR(TAG, "get file contents Invalid Arguments."); + return FALSE; + } + + hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + return FALSE; + + rc = SetFilePointer(hFile, positionLow, &positionHigh, FILE_BEGIN); + + if (rc == INVALID_SET_FILE_POINTER) + goto error; + + if (!ReadFile(hFile, buffer, nRequested, &nGet, NULL)) + { + DEBUG_CLIPRDR("ReadFile failed with 0x%08lX.", GetLastError()); + goto error; + } + + res = TRUE; +error: + + if (!CloseHandle(hFile)) + res = FALSE; + + if (res) + *puSize = nGet; + + return res; +} + +/* path_name has a '\' at the end. e.g. c:\newfolder\, file_name is c:\newfolder\new.txt */ +static FILEDESCRIPTORW* wf_cliprdr_get_file_descriptor(WCHAR* file_name, size_t pathLen) +{ + HANDLE hFile; + FILEDESCRIPTORW* fd; + fd = (FILEDESCRIPTORW*)calloc(1, sizeof(FILEDESCRIPTORW)); + + if (!fd) + return NULL; + + hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + free(fd); + return NULL; + } + + fd->dwFlags = FD_ATTRIBUTES | FD_FILESIZE | FD_WRITESTIME | FD_PROGRESSUI; + fd->dwFileAttributes = GetFileAttributes(file_name); + + if (!GetFileTime(hFile, NULL, NULL, &fd->ftLastWriteTime)) + { + fd->dwFlags &= ~FD_WRITESTIME; + } + + fd->nFileSizeLow = GetFileSize(hFile, &fd->nFileSizeHigh); + wcscpy_s(fd->cFileName, sizeof(fd->cFileName) / 2, file_name + pathLen); + (void)CloseHandle(hFile); + return fd; +} + +static BOOL wf_cliprdr_array_ensure_capacity(wfClipboard* clipboard) +{ + if (!clipboard) + return FALSE; + + if (clipboard->nFiles == clipboard->file_array_size) + { + size_t new_size; + FILEDESCRIPTORW** new_fd; + WCHAR** new_name; + new_size = (clipboard->file_array_size + 1) * 2; + new_fd = (FILEDESCRIPTORW**)realloc(clipboard->fileDescriptor, + new_size * sizeof(FILEDESCRIPTORW*)); + + if (new_fd) + clipboard->fileDescriptor = new_fd; + + new_name = (WCHAR**)realloc(clipboard->file_names, new_size * sizeof(WCHAR*)); + + if (new_name) + clipboard->file_names = new_name; + + if (!new_fd || !new_name) + return FALSE; + + clipboard->file_array_size = new_size; + } + + return TRUE; +} + +static BOOL wf_cliprdr_add_to_file_arrays(wfClipboard* clipboard, WCHAR* full_file_name, + size_t pathLen) +{ + if (!wf_cliprdr_array_ensure_capacity(clipboard)) + return FALSE; + + /* add to name array */ + clipboard->file_names[clipboard->nFiles] = (LPWSTR)malloc(MAX_PATH * 2); + + if (!clipboard->file_names[clipboard->nFiles]) + return FALSE; + + wcscpy_s(clipboard->file_names[clipboard->nFiles], MAX_PATH, full_file_name); + /* add to descriptor array */ + clipboard->fileDescriptor[clipboard->nFiles] = + wf_cliprdr_get_file_descriptor(full_file_name, pathLen); + + if (!clipboard->fileDescriptor[clipboard->nFiles]) + { + free(clipboard->file_names[clipboard->nFiles]); + return FALSE; + } + + clipboard->nFiles++; + return TRUE; +} + +static BOOL wf_cliprdr_traverse_directory(wfClipboard* clipboard, WCHAR* Dir, size_t pathLen) +{ + HANDLE hFind; + WCHAR DirSpec[MAX_PATH]; + WIN32_FIND_DATA FindFileData; + + if (!clipboard || !Dir) + return FALSE; + + StringCchCopy(DirSpec, MAX_PATH, Dir); + StringCchCat(DirSpec, MAX_PATH, TEXT("\\*")); + hFind = FindFirstFile(DirSpec, &FindFileData); + + if (hFind == INVALID_HANDLE_VALUE) + { + DEBUG_CLIPRDR("FindFirstFile failed with 0x%x.", GetLastError()); + return FALSE; + } + + while (FindNextFile(hFind, &FindFileData)) + { + if ((((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) && + (wcscmp(FindFileData.cFileName, _T(".")) == 0)) || + (wcscmp(FindFileData.cFileName, _T("..")) == 0)) + { + continue; + } + + if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + { + WCHAR DirAdd[MAX_PATH]; + StringCchCopy(DirAdd, MAX_PATH, Dir); + StringCchCat(DirAdd, MAX_PATH, _T("\\")); + StringCchCat(DirAdd, MAX_PATH, FindFileData.cFileName); + + if (!wf_cliprdr_add_to_file_arrays(clipboard, DirAdd, pathLen)) + return FALSE; + + if (!wf_cliprdr_traverse_directory(clipboard, DirAdd, pathLen)) + return FALSE; + } + else + { + WCHAR fileName[MAX_PATH]; + StringCchCopy(fileName, MAX_PATH, Dir); + StringCchCat(fileName, MAX_PATH, _T("\\")); + StringCchCat(fileName, MAX_PATH, FindFileData.cFileName); + + if (!wf_cliprdr_add_to_file_arrays(clipboard, fileName, pathLen)) + return FALSE; + } + } + + FindClose(hFind); + return TRUE; +} + +static UINT wf_cliprdr_send_client_capabilities(wfClipboard* clipboard) +{ + CLIPRDR_CAPABILITIES capabilities; + CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet; + + if (!clipboard || !clipboard->context || !clipboard->context->ClientCapabilities) + return ERROR_INTERNAL_ERROR; + + capabilities.cCapabilitiesSets = 1; + capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet); + generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL; + generalCapabilitySet.capabilitySetLength = 12; + generalCapabilitySet.version = CB_CAPS_VERSION_2; + generalCapabilitySet.generalFlags = + CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS; + return clipboard->context->ClientCapabilities(clipboard->context, &capabilities); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_cliprdr_monitor_ready(CliprdrClientContext* context, + const CLIPRDR_MONITOR_READY* monitorReady) +{ + UINT rc; + wfClipboard* clipboard = (wfClipboard*)context->custom; + + if (!context || !monitorReady) + return ERROR_INTERNAL_ERROR; + + clipboard->sync = TRUE; + rc = wf_cliprdr_send_client_capabilities(clipboard); + + if (rc != CHANNEL_RC_OK) + return rc; + + return cliprdr_send_format_list(clipboard); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_cliprdr_server_capabilities(CliprdrClientContext* context, + const CLIPRDR_CAPABILITIES* capabilities) +{ + CLIPRDR_CAPABILITY_SET* capabilitySet; + wfClipboard* clipboard = (wfClipboard*)context->custom; + + if (!context || !capabilities) + return ERROR_INTERNAL_ERROR; + + for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++) + { + capabilitySet = &(capabilities->capabilitySets[index]); + + if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) && + (capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN)) + { + CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet = + (CLIPRDR_GENERAL_CAPABILITY_SET*)capabilitySet; + clipboard->capabilities = generalCapabilitySet->generalFlags; + break; + } + } + + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context, + const CLIPRDR_FORMAT_LIST* formatList) +{ + UINT rc = ERROR_INTERNAL_ERROR; + formatMapping* mapping; + CLIPRDR_FORMAT* format; + wfClipboard* clipboard = (wfClipboard*)context->custom; + + if (!clear_format_map(clipboard)) + return ERROR_INTERNAL_ERROR; + + for (UINT32 i = 0; i < formatList->numFormats; i++) + { + format = &(formatList->formats[i]); + mapping = &(clipboard->format_mappings[i]); + mapping->remote_format_id = format->formatId; + + if (format->formatName) + { + mapping->name = ConvertUtf8ToWCharAlloc(format->formatName, NULL); + + if (mapping->name) + mapping->local_format_id = RegisterClipboardFormatW((LPWSTR)mapping->name); + } + else + { + mapping->name = NULL; + mapping->local_format_id = mapping->remote_format_id; + } + + clipboard->map_size++; + map_ensure_capacity(clipboard); + } + + if (file_transferring(clipboard)) + { + if (PostMessage(clipboard->hwnd, WM_CLIPRDR_MESSAGE, OLE_SETCLIPBOARD, 0)) + rc = CHANNEL_RC_OK; + } + else + { + if (!try_open_clipboard(clipboard->hwnd)) + return CHANNEL_RC_OK; /* Ignore, other app holding clipboard */ + + if (EmptyClipboard()) + { + for (UINT32 i = 0; i < (UINT32)clipboard->map_size; i++) + SetClipboardData(clipboard->format_mappings[i].local_format_id, NULL); + + rc = CHANNEL_RC_OK; + } + + if (!CloseClipboard() && GetLastError()) + return ERROR_INTERNAL_ERROR; + } + + return rc; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_format_list_response(CliprdrClientContext* context, + const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse) +{ + (void)context; + (void)formatListResponse; + + if (formatListResponse->common.msgFlags != CB_RESPONSE_OK) + WLog_WARN(TAG, "format list update failed"); + + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_lock_clipboard_data(CliprdrClientContext* context, + const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData) +{ + (void)context; + (void)lockClipboardData; + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* context, + const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData) +{ + (void)context; + (void)unlockClipboardData; + return CHANNEL_RC_OK; +} + +static BOOL wf_cliprdr_process_filename(wfClipboard* clipboard, WCHAR* wFileName, size_t str_len) +{ + size_t pathLen; + size_t offset = str_len; + + if (!clipboard || !wFileName) + return FALSE; + + /* find the last '\' in full file name */ + while (offset > 0) + { + if (wFileName[offset] == L'\\') + break; + else + offset--; + } + + pathLen = offset + 1; + + if (!wf_cliprdr_add_to_file_arrays(clipboard, wFileName, pathLen)) + return FALSE; + + if ((clipboard->fileDescriptor[clipboard->nFiles - 1]->dwFileAttributes & + FILE_ATTRIBUTE_DIRECTORY) != 0) + { + /* this is a directory */ + if (!wf_cliprdr_traverse_directory(clipboard, wFileName, pathLen)) + return FALSE; + } + + return TRUE; +} + +static SSIZE_T wf_cliprdr_tryopen(wfClipboard* clipboard, UINT32 requestedFormatId, BYTE** pData) +{ + SSIZE_T rc = -1; + WINPR_ASSERT(clipboard); + WINPR_ASSERT(pData); + + *pData = NULL; + + /* Ignore if other app is holding the clipboard */ + if (!try_open_clipboard(clipboard->hwnd)) + return 0; + + HANDLE hClipdata = GetClipboardData(requestedFormatId); + + if (!hClipdata) + goto fail; + + char* globlemem = (char*)GlobalLock(hClipdata); + const SSIZE_T size = GlobalSize(hClipdata); + if (size <= 0) + goto unlock; + + BYTE* buff = malloc(size); + if (buff == NULL) + goto fail; + CopyMemory(buff, globlemem, size); + *pData = buff; + rc = size; + +unlock: + GlobalUnlock(hClipdata); + +fail: + CloseClipboard(); + + return rc; +} + +static SSIZE_T wf_cliprdr_get_filedescriptor(wfClipboard* clipboard, BYTE** pData) +{ + WINPR_ASSERT(clipboard); + WINPR_ASSERT(pData); + + SSIZE_T rc = -1; + LPDATAOBJECT dataObj = NULL; + FORMATETC format_etc = { 0 }; + STGMEDIUM stg_medium = { 0 }; + + *pData = NULL; + + HRESULT result = OleGetClipboard(&dataObj); + if (FAILED(result)) + return -1; + + /* get DROPFILES struct from OLE */ + format_etc.cfFormat = CF_HDROP; + format_etc.tymed = TYMED_HGLOBAL; + format_etc.dwAspect = 1; + format_etc.lindex = -1; + result = IDataObject_GetData(dataObj, &format_etc, &stg_medium); + + if (FAILED(result)) + { + DEBUG_CLIPRDR("dataObj->GetData failed."); + goto exit; + } + + HGLOBAL hdl = stg_medium.u.hGlobal; + DROPFILES* dropFiles = (DROPFILES*)GlobalLock(hdl); + + if (!dropFiles) + { + ReleaseStgMedium(&stg_medium); + clipboard->nFiles = 0; + goto exit; + } + + clear_file_array(clipboard); + + if (dropFiles->fWide) + { + /* dropFiles contains file names */ + size_t len = 0; + for (WCHAR* wFileName = (WCHAR*)((char*)dropFiles + dropFiles->pFiles); + (len = wcslen(wFileName)) > 0; wFileName += len + 1) + { + wf_cliprdr_process_filename(clipboard, wFileName, wcslen(wFileName)); + } + } + else + { + size_t len = 0; + for (char* p = (char*)((char*)dropFiles + dropFiles->pFiles); (len = strlen(p)) > 0; + p += len + 1, clipboard->nFiles++) + { + const int cchWideChar = MultiByteToWideChar(CP_ACP, MB_COMPOSITE, p, len, NULL, 0); + WCHAR* wFileName = (LPWSTR)calloc(cchWideChar, sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, MB_COMPOSITE, p, len, wFileName, cchWideChar); + wf_cliprdr_process_filename(clipboard, wFileName, cchWideChar); + free(wFileName); + } + } + + GlobalUnlock(hdl); + ReleaseStgMedium(&stg_medium); +exit: +{ + const size_t size = 4ull + clipboard->nFiles * sizeof(FILEDESCRIPTORW); + FILEGROUPDESCRIPTORW* groupDsc = (FILEGROUPDESCRIPTORW*)calloc(size, 1); + + if (groupDsc) + { + groupDsc->cItems = clipboard->nFiles; + + for (size_t i = 0; i < clipboard->nFiles; i++) + { + if (clipboard->fileDescriptor[i]) + groupDsc->fgd[i] = *clipboard->fileDescriptor[i]; + } + + *pData = (BYTE*)groupDsc; + rc = size; + } +} + + IDataObject_Release(dataObj); + return rc; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_format_data_request(CliprdrClientContext* context, + const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest) +{ + CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 }; + + if (!context || !formatDataRequest) + return ERROR_INTERNAL_ERROR; + + wfClipboard* clipboard = (wfClipboard*)context->custom; + + if (!clipboard) + return ERROR_INTERNAL_ERROR; + + const UINT32 requestedFormatId = formatDataRequest->requestedFormatId; + + if (requestedFormatId == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)) + { + const SSIZE_T res = wf_cliprdr_get_filedescriptor(clipboard, &response.requestedFormatData); + if (res > 0) + response.common.dataLen = (UINT32)res; + } + else + { + const SSIZE_T res = + wf_cliprdr_tryopen(clipboard, requestedFormatId, &response.requestedFormatData); + if (res > 0) + response.common.dataLen = (UINT32)res; + } + + response.common.msgFlags = CB_RESPONSE_OK; + + const UINT rc = clipboard->context->ClientFormatDataResponse(clipboard->context, &response); + free(response.requestedFormatData); + return rc; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_format_data_response(CliprdrClientContext* context, + const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse) +{ + BYTE* data; + HANDLE hMem; + wfClipboard* clipboard; + + if (!context || !formatDataResponse) + return ERROR_INTERNAL_ERROR; + + clipboard = (wfClipboard*)context->custom; + + if (!clipboard) + return ERROR_INTERNAL_ERROR; + + if (formatDataResponse->common.msgFlags != CB_RESPONSE_OK) + { + clipboard->hmem = NULL; + + if (!SetEvent(clipboard->response_data_event)) + return ERROR_INTERNAL_ERROR; + + return CHANNEL_RC_OK; + } + + hMem = GlobalAlloc(GMEM_MOVEABLE, formatDataResponse->common.dataLen); + + if (!hMem) + return ERROR_INTERNAL_ERROR; + + data = (BYTE*)GlobalLock(hMem); + + if (!data) + { + GlobalFree(hMem); + return ERROR_INTERNAL_ERROR; + } + + CopyMemory(data, formatDataResponse->requestedFormatData, formatDataResponse->common.dataLen); + + if (!GlobalUnlock(hMem) && GetLastError()) + { + GlobalFree(hMem); + return ERROR_INTERNAL_ERROR; + } + + clipboard->hmem = hMem; + + if (!SetEvent(clipboard->response_data_event)) + return ERROR_INTERNAL_ERROR; + + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_file_contents_request(CliprdrClientContext* context, + const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest) +{ + DWORD uSize = 0; + BYTE* pData = NULL; + HRESULT hRet = S_OK; + FORMATETC vFormatEtc = { 0 }; + LPDATAOBJECT pDataObj = NULL; + STGMEDIUM vStgMedium = { 0 }; + BOOL bIsStreamFile = TRUE; + static LPSTREAM pStreamStc = NULL; + static UINT32 uStreamIdStc = 0; + wfClipboard* clipboard; + UINT rc = ERROR_INTERNAL_ERROR; + UINT sRc; + UINT32 cbRequested; + + if (!context || !fileContentsRequest) + return ERROR_INTERNAL_ERROR; + + clipboard = (wfClipboard*)context->custom; + + if (!clipboard) + return ERROR_INTERNAL_ERROR; + + cbRequested = fileContentsRequest->cbRequested; + if (fileContentsRequest->dwFlags == FILECONTENTS_SIZE) + cbRequested = sizeof(UINT64); + + pData = (BYTE*)calloc(1, cbRequested); + + if (!pData) + goto error; + + hRet = OleGetClipboard(&pDataObj); + + if (FAILED(hRet)) + { + WLog_ERR(TAG, "filecontents: get ole clipboard failed."); + goto error; + } + + vFormatEtc.cfFormat = RegisterClipboardFormat(CFSTR_FILECONTENTS); + vFormatEtc.tymed = TYMED_ISTREAM; + vFormatEtc.dwAspect = 1; + vFormatEtc.lindex = fileContentsRequest->listIndex; + vFormatEtc.ptd = NULL; + + if ((uStreamIdStc != fileContentsRequest->streamId) || !pStreamStc) + { + LPENUMFORMATETC pEnumFormatEtc; + ULONG CeltFetched; + FORMATETC vFormatEtc2; + + if (pStreamStc) + { + IStream_Release(pStreamStc); + pStreamStc = NULL; + } + + bIsStreamFile = FALSE; + hRet = IDataObject_EnumFormatEtc(pDataObj, DATADIR_GET, &pEnumFormatEtc); + + if (hRet == S_OK) + { + do + { + hRet = IEnumFORMATETC_Next(pEnumFormatEtc, 1, &vFormatEtc2, &CeltFetched); + + if (hRet == S_OK) + { + if (vFormatEtc2.cfFormat == RegisterClipboardFormat(CFSTR_FILECONTENTS)) + { + hRet = IDataObject_GetData(pDataObj, &vFormatEtc, &vStgMedium); + + if (hRet == S_OK) + { + pStreamStc = vStgMedium.u.pstm; + uStreamIdStc = fileContentsRequest->streamId; + bIsStreamFile = TRUE; + } + + break; + } + } + } while (hRet == S_OK); + } + } + + if (bIsStreamFile == TRUE) + { + if (fileContentsRequest->dwFlags == FILECONTENTS_SIZE) + { + STATSTG vStatStg = { 0 }; + hRet = IStream_Stat(pStreamStc, &vStatStg, STATFLAG_NONAME); + + if (hRet == S_OK) + { + *((UINT32*)&pData[0]) = vStatStg.cbSize.QuadPart & 0xFFFFFFFF; + *((UINT32*)&pData[4]) = (vStatStg.cbSize.QuadPart >> 32) & 0xFFFFFFFF; + uSize = cbRequested; + } + } + else if (fileContentsRequest->dwFlags == FILECONTENTS_RANGE) + { + LARGE_INTEGER dlibMove; + ULARGE_INTEGER dlibNewPosition; + dlibMove.QuadPart = (INT64)(((UINT64)fileContentsRequest->nPositionHigh << 32) | + fileContentsRequest->nPositionLow); + hRet = IStream_Seek(pStreamStc, dlibMove, STREAM_SEEK_SET, &dlibNewPosition); + + if (SUCCEEDED(hRet)) + hRet = IStream_Read(pStreamStc, pData, cbRequested, (PULONG)&uSize); + } + } + else + { + if (fileContentsRequest->dwFlags == FILECONTENTS_SIZE) + { + if (clipboard->nFiles <= fileContentsRequest->listIndex) + goto error; + *((UINT32*)&pData[0]) = + clipboard->fileDescriptor[fileContentsRequest->listIndex]->nFileSizeLow; + *((UINT32*)&pData[4]) = + clipboard->fileDescriptor[fileContentsRequest->listIndex]->nFileSizeHigh; + uSize = cbRequested; + } + else if (fileContentsRequest->dwFlags == FILECONTENTS_RANGE) + { + BOOL bRet; + if (clipboard->nFiles <= fileContentsRequest->listIndex) + goto error; + bRet = wf_cliprdr_get_file_contents( + clipboard->file_names[fileContentsRequest->listIndex], pData, + fileContentsRequest->nPositionLow, fileContentsRequest->nPositionHigh, cbRequested, + &uSize); + + if (bRet == FALSE) + { + WLog_ERR(TAG, "get file contents failed."); + uSize = 0; + goto error; + } + } + } + + rc = CHANNEL_RC_OK; +error: + + if (pDataObj) + IDataObject_Release(pDataObj); + + if (uSize == 0) + { + free(pData); + pData = NULL; + } + + sRc = + cliprdr_send_response_filecontents(clipboard, fileContentsRequest->streamId, uSize, pData); + free(pData); + + if (sRc != CHANNEL_RC_OK) + return sRc; + + return rc; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT +wf_cliprdr_server_file_contents_response(CliprdrClientContext* context, + const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse) +{ + wfClipboard* clipboard; + + if (!context || !fileContentsResponse) + return ERROR_INTERNAL_ERROR; + + if (fileContentsResponse->common.msgFlags != CB_RESPONSE_OK) + return E_FAIL; + + clipboard = (wfClipboard*)context->custom; + + if (!clipboard) + return ERROR_INTERNAL_ERROR; + + clipboard->req_fsize = fileContentsResponse->cbRequested; + clipboard->req_fdata = (char*)malloc(fileContentsResponse->cbRequested); + + if (!clipboard->req_fdata) + return ERROR_INTERNAL_ERROR; + + CopyMemory(clipboard->req_fdata, fileContentsResponse->requestedData, + fileContentsResponse->cbRequested); + + if (!SetEvent(clipboard->req_fevent)) + { + free(clipboard->req_fdata); + return ERROR_INTERNAL_ERROR; + } + + return CHANNEL_RC_OK; +} + +BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr) +{ + wfClipboard* clipboard; + rdpContext* context = (rdpContext*)wfc; + + if (!context || !cliprdr) + return FALSE; + + wfc->clipboard = (wfClipboard*)calloc(1, sizeof(wfClipboard)); + + if (!wfc->clipboard) + return FALSE; + + clipboard = wfc->clipboard; + clipboard->wfc = wfc; + clipboard->context = cliprdr; + clipboard->channels = context->channels; + clipboard->sync = FALSE; + clipboard->map_capacity = 32; + clipboard->map_size = 0; + clipboard->hUser32 = LoadLibraryA("user32.dll"); + + if (clipboard->hUser32) + { + clipboard->AddClipboardFormatListener = GetProcAddressAs( + clipboard->hUser32, "AddClipboardFormatListener", fnAddClipboardFormatListener); + clipboard->RemoveClipboardFormatListener = GetProcAddressAs( + clipboard->hUser32, "RemoveClipboardFormatListener", fnRemoveClipboardFormatListener); + clipboard->GetUpdatedClipboardFormats = GetProcAddressAs( + clipboard->hUser32, "GetUpdatedClipboardFormats", fnGetUpdatedClipboardFormats); + } + + if (!(clipboard->hUser32 && clipboard->AddClipboardFormatListener && + clipboard->RemoveClipboardFormatListener && clipboard->GetUpdatedClipboardFormats)) + clipboard->legacyApi = TRUE; + + if (!(clipboard->format_mappings = + (formatMapping*)calloc(clipboard->map_capacity, sizeof(formatMapping)))) + goto error; + + if (!(clipboard->response_data_event = CreateEvent(NULL, TRUE, FALSE, NULL))) + goto error; + + if (!(clipboard->req_fevent = CreateEvent(NULL, TRUE, FALSE, NULL))) + goto error; + + if (!(clipboard->thread = CreateThread(NULL, 0, cliprdr_thread_func, clipboard, 0, NULL))) + goto error; + + cliprdr->MonitorReady = wf_cliprdr_monitor_ready; + cliprdr->ServerCapabilities = wf_cliprdr_server_capabilities; + cliprdr->ServerFormatList = wf_cliprdr_server_format_list; + cliprdr->ServerFormatListResponse = wf_cliprdr_server_format_list_response; + cliprdr->ServerLockClipboardData = wf_cliprdr_server_lock_clipboard_data; + cliprdr->ServerUnlockClipboardData = wf_cliprdr_server_unlock_clipboard_data; + cliprdr->ServerFormatDataRequest = wf_cliprdr_server_format_data_request; + cliprdr->ServerFormatDataResponse = wf_cliprdr_server_format_data_response; + cliprdr->ServerFileContentsRequest = wf_cliprdr_server_file_contents_request; + cliprdr->ServerFileContentsResponse = wf_cliprdr_server_file_contents_response; + cliprdr->custom = (void*)wfc->clipboard; + return TRUE; +error: + wf_cliprdr_uninit(wfc, cliprdr); + return FALSE; +} + +BOOL wf_cliprdr_uninit(wfContext* wfc, CliprdrClientContext* cliprdr) +{ + wfClipboard* clipboard; + + if (!wfc || !cliprdr) + return FALSE; + + clipboard = wfc->clipboard; + + if (!clipboard) + return FALSE; + + cliprdr->custom = NULL; + + if (clipboard->hwnd) + PostMessage(clipboard->hwnd, WM_QUIT, 0, 0); + + if (clipboard->thread) + { + (void)WaitForSingleObject(clipboard->thread, INFINITE); + (void)CloseHandle(clipboard->thread); + } + + if (clipboard->response_data_event) + (void)CloseHandle(clipboard->response_data_event); + + if (clipboard->req_fevent) + (void)CloseHandle(clipboard->req_fevent); + + clear_file_array(clipboard); + clear_format_map(clipboard); + free(clipboard->format_mappings); + free(clipboard); + return TRUE; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.h b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.h new file mode 100644 index 0000000000000000000000000000000000000000..3a6b4a1860764a3ea68c12ed87c004de197cba89 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_cliprdr.h @@ -0,0 +1,27 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Clipboard Redirection + * + * Copyright 2012 Jason Champion + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FREERDP_CLIENT_WIN_CLIPRDR_H +#define FREERDP_CLIENT_WIN_CLIPRDR_H + +#include "wf_client.h" + +BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr); +BOOL wf_cliprdr_uninit(wfContext* wfc, CliprdrClientContext* cliprdr); + +#endif /* FREERDP_CLIENT_WIN_CLIPRDR_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.c b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.c new file mode 100644 index 0000000000000000000000000000000000000000..f91047ce2b25db43272993a970889464ecf4e83d --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.c @@ -0,0 +1,730 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Float Bar + * + * Copyright 2013 Zhang Zhaolong + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "wf_client.h" +#include "wf_floatbar.h" + +#include "resource/resource.h" +#include "wf_gdi.h" +#ifdef _MSC_VER +#pragma comment(lib, "Msimg32.lib") +#endif + +#define TAG CLIENT_TAG("windows.floatbar") + +/* TIMERs */ +#define TIMER_HIDE 1 +#define TIMER_ANIMAT_SHOW 2 +#define TIMER_ANIMAT_HIDE 3 + +/* Button Type */ +#define BUTTON_LOCKPIN 0 +#define BUTTON_MINIMIZE 1 +#define BUTTON_RESTORE 2 +#define BUTTON_CLOSE 3 +#define BTN_MAX 4 + +/* bmp size */ +#define BACKGROUND_W 576 +#define BACKGROUND_H 27 +#define BUTTON_OFFSET 5 +#define BUTTON_Y 2 +#define BUTTON_WIDTH 23 +#define BUTTON_HEIGHT 21 +#define BUTTON_SPACING 1 + +#define LOCK_X (BACKGROUND_H + BUTTON_OFFSET) +#define CLOSE_X ((BACKGROUND_W - (BACKGROUND_H + BUTTON_OFFSET)) - BUTTON_WIDTH) +#define RESTORE_X (CLOSE_X - (BUTTON_WIDTH + BUTTON_SPACING)) +#define MINIMIZE_X (RESTORE_X - (BUTTON_WIDTH + BUTTON_SPACING)) +#define TEXT_X (BACKGROUND_H + ((BUTTON_WIDTH + BUTTON_SPACING) * 3) + 5) + +typedef struct +{ + wfFloatBar* floatbar; + int type; + int x, y, h, w; + int active; + HBITMAP bmp; + HBITMAP bmp_act; + + /* Lock Specified */ + HBITMAP locked_bmp; + HBITMAP locked_bmp_act; + HBITMAP unlocked_bmp; + HBITMAP unlocked_bmp_act; +} Button; + +struct s_FloatBar +{ + HINSTANCE root_window; + DWORD flags; + HWND parent; + HWND hwnd; + RECT rect; + LONG width; + LONG height; + LONG offset; + wfContext* wfc; + Button* buttons[BTN_MAX]; + BOOL shown; + BOOL locked; + HDC hdcmem; + RECT textRect; + UINT_PTR animating; +}; + +static BOOL floatbar_kill_timers(wfFloatBar* floatbar) +{ + UINT_PTR timers[] = { TIMER_HIDE, TIMER_ANIMAT_HIDE, TIMER_ANIMAT_SHOW }; + + if (!floatbar) + return FALSE; + + for (size_t x = 0; x < ARRAYSIZE(timers); x++) + KillTimer(floatbar->hwnd, timers[x]); + + floatbar->animating = 0; + return TRUE; +} + +static BOOL floatbar_animation(wfFloatBar* const floatbar, const BOOL show) +{ + UINT_PTR timer = show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE; + + if (!floatbar) + return FALSE; + + if (floatbar->shown == show) + return TRUE; + + if (floatbar->animating == timer) + return TRUE; + + floatbar->animating = timer; + + if (SetTimer(floatbar->hwnd, timer, USER_TIMER_MINIMUM, NULL) == 0) + { + DWORD err = GetLastError(); + WLog_ERR(TAG, "SetTimer failed with %08" PRIx32, err); + return FALSE; + } + + return TRUE; +} + +static BOOL floatbar_trigger_hide(wfFloatBar* floatbar) +{ + if (!floatbar_kill_timers(floatbar)) + return FALSE; + + if (!floatbar->locked && floatbar->shown) + { + if (SetTimer(floatbar->hwnd, TIMER_HIDE, 3000, NULL) == 0) + { + DWORD err = GetLastError(); + WLog_ERR(TAG, "SetTimer failed with %08" PRIx32, err); + return FALSE; + } + } + + return TRUE; +} + +static BOOL floatbar_hide(wfFloatBar* floatbar) +{ + if (!floatbar_kill_timers(floatbar)) + return FALSE; + + floatbar->offset = floatbar->height - 2; + + if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, floatbar->width, + floatbar->height, TRUE)) + { + DWORD err = GetLastError(); + WLog_ERR(TAG, "MoveWindow failed with %08" PRIx32, err); + return FALSE; + } + + floatbar->shown = FALSE; + + if (!floatbar_trigger_hide(floatbar)) + return FALSE; + + return TRUE; +} + +static BOOL floatbar_show(wfFloatBar* floatbar) +{ + if (!floatbar_kill_timers(floatbar)) + return FALSE; + + floatbar->offset = 0; + + if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, floatbar->width, + floatbar->height, TRUE)) + { + DWORD err = GetLastError(); + WLog_ERR(TAG, "MoveWindow failed with %08" PRIx32, err); + return FALSE; + } + + floatbar->shown = TRUE; + + if (!floatbar_trigger_hide(floatbar)) + return FALSE; + + return TRUE; +} + +static BOOL button_set_locked(Button* button, BOOL locked) +{ + if (locked) + { + button->bmp = button->locked_bmp; + button->bmp_act = button->locked_bmp_act; + } + else + { + button->bmp = button->unlocked_bmp; + button->bmp_act = button->unlocked_bmp_act; + } + + InvalidateRect(button->floatbar->hwnd, NULL, FALSE); + UpdateWindow(button->floatbar->hwnd); + return TRUE; +} + +static BOOL update_locked_state(wfFloatBar* floatbar) +{ + Button* button; + + if (!floatbar) + return FALSE; + + button = floatbar->buttons[3]; + + if (!button_set_locked(button, floatbar->locked)) + return FALSE; + + return TRUE; +} + +static int button_hit(Button* const button) +{ + wfFloatBar* const floatbar = button->floatbar; + + switch (button->type) + { + case BUTTON_LOCKPIN: + floatbar->locked = !floatbar->locked; + update_locked_state(floatbar); + break; + + case BUTTON_MINIMIZE: + ShowWindow(floatbar->parent, SW_MINIMIZE); + break; + + case BUTTON_RESTORE: + wf_toggle_fullscreen(floatbar->wfc); + break; + + case BUTTON_CLOSE: + SendMessage(floatbar->parent, WM_DESTROY, 0, 0); + break; + + default: + return 0; + } + + return 0; +} + +static int button_paint(const Button* const button, const HDC hdc) +{ + if (button != NULL) + { + wfFloatBar* floatbar = button->floatbar; + BLENDFUNCTION bf; + SelectObject(floatbar->hdcmem, button->active ? button->bmp_act : button->bmp); + bf.BlendOp = AC_SRC_OVER; + bf.BlendFlags = 0; + bf.SourceConstantAlpha = 255; + bf.AlphaFormat = AC_SRC_ALPHA; + AlphaBlend(hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0, 0, + button->w, button->h, bf); + } + + return 0; +} + +static Button* floatbar_create_button(wfFloatBar* const floatbar, const int type, const int resid, + const int resid_act, const int x, const int y, const int h, + const int w) +{ + Button* button = (Button*)calloc(1, sizeof(Button)); + + if (!button) + return NULL; + + button->floatbar = floatbar; + button->type = type; + button->x = x; + button->y = y; + button->w = w; + button->h = h; + button->active = FALSE; + button->bmp = (HBITMAP)LoadImage(floatbar->root_window, MAKEINTRESOURCE(resid), IMAGE_BITMAP, 0, + 0, LR_DEFAULTCOLOR); + button->bmp_act = (HBITMAP)LoadImage(floatbar->root_window, MAKEINTRESOURCE(resid_act), + IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); + return button; +} + +static Button* floatbar_create_lock_button(wfFloatBar* const floatbar, const int unlock_resid, + const int unlock_resid_act, const int lock_resid, + const int lock_resid_act, const int x, const int y, + const int h, const int w) +{ + Button* button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid, + unlock_resid_act, x, y, h, w); + + if (!button) + return NULL; + + button->unlocked_bmp = button->bmp; + button->unlocked_bmp_act = button->bmp_act; + button->locked_bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid), + IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); + button->locked_bmp_act = + (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP, + 0, 0, LR_DEFAULTCOLOR); + return button; +} + +static Button* floatbar_get_button(const wfFloatBar* const floatbar, const int x, const int y) +{ + if ((y > BUTTON_Y) && (y < BUTTON_Y + BUTTON_HEIGHT)) + { + for (int i = 0; i < BTN_MAX; i++) + { + if ((floatbar->buttons[i] != NULL) && (x > floatbar->buttons[i]->x) && + (x < floatbar->buttons[i]->x + floatbar->buttons[i]->w)) + { + return floatbar->buttons[i]; + } + } + } + + return NULL; +} + +static BOOL floatbar_paint(wfFloatBar* const floatbar, const HDC hdc) +{ + HPEN hpen; + HGDIOBJECT orig; + /* paint background */ + GRADIENT_RECT gradientRect = { 0, 1 }; + COLORREF rgbTop = RGB(117, 154, 198); + COLORREF rgbBottom = RGB(6, 55, 120); + const int top = 0; + int left = 0; + int bottom = BACKGROUND_H - 1; + int right = BACKGROUND_W - 1; + const int angleOffset = BACKGROUND_H - 1; + TRIVERTEX triVertext[2] = { { left, top, GetRValue(rgbTop) << 8, GetGValue(rgbTop) << 8, + GetBValue(rgbTop) << 8, 0x0000 }, + { right, bottom, GetRValue(rgbBottom) << 8, + GetGValue(rgbBottom) << 8, GetBValue(rgbBottom) << 8, 0x0000 } }; + + if (!floatbar) + return FALSE; + + GradientFill(hdc, triVertext, 2, &gradientRect, 1, GRADIENT_FILL_RECT_V); + /* paint shadow */ + hpen = CreatePen(PS_SOLID, 1, RGB(71, 71, 71)); + orig = SelectObject(hdc, hpen); + MoveToEx(hdc, left, top, NULL); + LineTo(hdc, left + angleOffset, bottom); + LineTo(hdc, right - angleOffset, bottom); + LineTo(hdc, right + 1, top - 1); + DeleteObject(hpen); + hpen = CreatePen(PS_SOLID, 1, RGB(107, 141, 184)); + SelectObject(hdc, hpen); + left += 1; + bottom -= 1; + right -= 1; + MoveToEx(hdc, left, top, NULL); + LineTo(hdc, left + (angleOffset - 1), bottom); + LineTo(hdc, right - (angleOffset - 1), bottom); + LineTo(hdc, right + 1, top - 1); + DeleteObject(hpen); + SelectObject(hdc, orig); + DrawText(hdc, floatbar->wfc->window_title, wcslen(floatbar->wfc->window_title), + &floatbar->textRect, + DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE); + + /* paint buttons */ + + for (int i = 0; i < BTN_MAX; i++) + button_paint(floatbar->buttons[i], hdc); + + return TRUE; +} + +static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPARAM wParam, + const LPARAM lParam) +{ + static int dragging = FALSE; + static int lbtn_dwn = FALSE; + static int btn_dwn_x = 0; + static wfFloatBar* floatbar; + static TRACKMOUSEEVENT tme; + PAINTSTRUCT ps; + Button* button; + HDC hdc; + int pos_x; + int pos_y; + NONCLIENTMETRICS ncm; + int xScreen = GetSystemMetrics(SM_CXSCREEN); + + switch (Msg) + { + case WM_CREATE: + floatbar = ((wfFloatBar*)((CREATESTRUCT*)lParam)->lpCreateParams); + floatbar->hwnd = hWnd; + GetWindowRect(floatbar->hwnd, &floatbar->rect); + floatbar->width = floatbar->rect.right - floatbar->rect.left; + floatbar->height = floatbar->rect.bottom - floatbar->rect.top; + hdc = GetDC(hWnd); + floatbar->hdcmem = CreateCompatibleDC(hdc); + ReleaseDC(hWnd, hdc); + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hWnd; + tme.dwHoverTime = HOVER_DEFAULT; + // Use caption font, white, draw transparent + GetClientRect(hWnd, &floatbar->textRect); + InflateRect(&floatbar->textRect, -TEXT_X, 0); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, RGB(255, 255, 255)); + ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); + SelectObject(hdc, CreateFontIndirect(&ncm.lfCaptionFont)); + floatbar_trigger_hide(floatbar); + break; + + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + floatbar_paint(floatbar, hdc); + EndPaint(hWnd, &ps); + break; + + case WM_LBUTTONDOWN: + pos_x = lParam & 0xffff; + pos_y = (lParam >> 16) & 0xffff; + button = floatbar_get_button(floatbar, pos_x, pos_y); + + if (!button) + { + SetCapture(hWnd); + dragging = TRUE; + btn_dwn_x = lParam & 0xffff; + } + else + lbtn_dwn = TRUE; + + break; + + case WM_LBUTTONUP: + pos_x = lParam & 0xffff; + pos_y = (lParam >> 16) & 0xffff; + ReleaseCapture(); + dragging = FALSE; + + if (lbtn_dwn) + { + button = floatbar_get_button(floatbar, pos_x, pos_y); + + if (button) + button_hit(button); + + lbtn_dwn = FALSE; + } + + break; + + case WM_MOUSEMOVE: + pos_x = lParam & 0xffff; + pos_y = (lParam >> 16) & 0xffff; + + if (!floatbar->locked) + floatbar_animation(floatbar, TRUE); + + if (dragging) + { + floatbar->rect.left = floatbar->rect.left + (lParam & 0xffff) - btn_dwn_x; + + if (floatbar->rect.left < 0) + floatbar->rect.left = 0; + else if (floatbar->rect.left > xScreen - floatbar->width) + floatbar->rect.left = xScreen - floatbar->width; + + MoveWindow(hWnd, floatbar->rect.left, 0, floatbar->width, floatbar->height, TRUE); + } + else + { + for (int i = 0; i < BTN_MAX; i++) + { + if (floatbar->buttons[i] != NULL) + { + floatbar->buttons[i]->active = FALSE; + } + } + + button = floatbar_get_button(floatbar, pos_x, pos_y); + + if (button) + button->active = TRUE; + + InvalidateRect(hWnd, NULL, FALSE); + UpdateWindow(hWnd); + } + + TrackMouseEvent(&tme); + break; + + case WM_CAPTURECHANGED: + dragging = FALSE; + break; + + case WM_MOUSELEAVE: + { + for (int i = 0; i < BTN_MAX; i++) + { + if (floatbar->buttons[i] != NULL) + { + floatbar->buttons[i]->active = FALSE; + } + } + + InvalidateRect(hWnd, NULL, FALSE); + UpdateWindow(hWnd); + floatbar_trigger_hide(floatbar); + break; + } + + case WM_TIMER: + switch (wParam) + { + case TIMER_HIDE: + floatbar_animation(floatbar, FALSE); + break; + + case TIMER_ANIMAT_SHOW: + { + floatbar->offset--; + MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, + floatbar->width, floatbar->height, TRUE); + + if (floatbar->offset <= 0) + floatbar_show(floatbar); + + break; + } + + case TIMER_ANIMAT_HIDE: + { + floatbar->offset++; + MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, + floatbar->width, floatbar->height, TRUE); + + if (floatbar->offset >= floatbar->height - 2) + floatbar_hide(floatbar); + + break; + } + + default: + break; + } + + break; + + case WM_DESTROY: + DeleteDC(floatbar->hdcmem); + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, Msg, wParam, lParam); + } + + return 0; +} + +static BOOL floatbar_window_create(wfFloatBar* floatbar) +{ + WNDCLASSEX wnd_cls; + HWND barWnd; + HRGN hRgn; + POINT pt[4]; + RECT rect; + LONG x; + + if (!floatbar) + return FALSE; + + if (!GetWindowRect(floatbar->parent, &rect)) + return FALSE; + + x = (rect.right - rect.left - BACKGROUND_W) / 2; + wnd_cls.cbSize = sizeof(WNDCLASSEX); + wnd_cls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wnd_cls.lpfnWndProc = floatbar_proc; + wnd_cls.cbClsExtra = 0; + wnd_cls.cbWndExtra = 0; + wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wnd_cls.hCursor = LoadCursor(floatbar->root_window, IDC_ARROW); + wnd_cls.hbrBackground = NULL; + wnd_cls.lpszMenuName = NULL; + wnd_cls.lpszClassName = L"floatbar"; + wnd_cls.hInstance = floatbar->root_window; + wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + RegisterClassEx(&wnd_cls); + barWnd = CreateWindowEx(WS_EX_TOPMOST, L"floatbar", L"floatbar", WS_CHILD, x, 0, BACKGROUND_W, + BACKGROUND_H, floatbar->parent, NULL, floatbar->root_window, floatbar); + + if (barWnd == NULL) + return FALSE; + + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = BACKGROUND_W; + pt[1].y = 0; + pt[2].x = BACKGROUND_W - BACKGROUND_H; + pt[2].y = BACKGROUND_H; + pt[3].x = BACKGROUND_H; + pt[3].y = BACKGROUND_H; + hRgn = CreatePolygonRgn(pt, 4, ALTERNATE); + SetWindowRgn(barWnd, hRgn, TRUE); + return TRUE; +} + +void wf_floatbar_free(wfFloatBar* floatbar) +{ + if (!floatbar) + return; + + free(floatbar); +} + +wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags) +{ + wfFloatBar* floatbar; + + /* Floatbar not enabled */ + if ((flags & 0x0001) == 0) + return NULL; + + if (!wfc) + return NULL; + + // TODO: Disable for remote app + floatbar = (wfFloatBar*)calloc(1, sizeof(wfFloatBar)); + + if (!floatbar) + return NULL; + + floatbar->root_window = window; + floatbar->flags = flags; + floatbar->wfc = wfc; + floatbar->locked = (flags & 0x0002) != 0; + floatbar->shown = (flags & 0x0006) != 0; /* If it is loked or shown show it */ + floatbar->hwnd = NULL; + floatbar->parent = wfc->hwnd; + floatbar->hdcmem = NULL; + + if (wfc->fullscreen_toggle) + { + floatbar->buttons[0] = + floatbar_create_button(floatbar, BUTTON_MINIMIZE, IDB_MINIMIZE, IDB_MINIMIZE_ACT, + MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH); + floatbar->buttons[1] = + floatbar_create_button(floatbar, BUTTON_RESTORE, IDB_RESTORE, IDB_RESTORE_ACT, + RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH); + } + else + { + floatbar->buttons[0] = NULL; + floatbar->buttons[1] = NULL; + } + + floatbar->buttons[2] = floatbar_create_button(floatbar, BUTTON_CLOSE, IDB_CLOSE, IDB_CLOSE_ACT, + CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH); + floatbar->buttons[3] = + floatbar_create_lock_button(floatbar, IDB_UNLOCK, IDB_UNLOCK_ACT, IDB_LOCK, IDB_LOCK_ACT, + LOCK_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH); + + if (!floatbar_window_create(floatbar)) + goto fail; + + if (!update_locked_state(floatbar)) + goto fail; + + if (!wf_floatbar_toggle_fullscreen( + floatbar, freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Fullscreen))) + goto fail; + + return floatbar; +fail: + wf_floatbar_free(floatbar); + return NULL; +} + +BOOL wf_floatbar_toggle_fullscreen(wfFloatBar* floatbar, BOOL fullscreen) +{ + BOOL show_fs, show_wn; + + if (!floatbar) + return FALSE; + + show_fs = (floatbar->flags & 0x0010) != 0; + show_wn = (floatbar->flags & 0x0020) != 0; + + if ((show_fs && fullscreen) || (show_wn && !fullscreen)) + { + ShowWindow(floatbar->hwnd, SW_SHOWNORMAL); + Sleep(10); + + if (floatbar->shown) + floatbar_show(floatbar); + else + floatbar_hide(floatbar); + } + else + { + ShowWindow(floatbar->hwnd, SW_HIDE); + } + + return TRUE; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.h b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.h new file mode 100644 index 0000000000000000000000000000000000000000..761eeb2a9e36f552044ddba14d94402abdfca19e --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_floatbar.h @@ -0,0 +1,33 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows Float Bar + * + * Copyright 2013 Zhang Zhaolong + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WIN_FLOATBAR_H +#define FREERDP_CLIENT_WIN_FLOATBAR_H + +#include + +typedef struct s_FloatBar wfFloatBar; +typedef struct wf_context wfContext; + +wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags); +void wf_floatbar_free(wfFloatBar* floatbar); + +BOOL wf_floatbar_toggle_fullscreen(wfFloatBar* floatbar, BOOL fullscreen); + +#endif /* FREERDP_CLIENT_WIN_FLOATBAR_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_gdi.c b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_gdi.c new file mode 100644 index 0000000000000000000000000000000000000000..4dc964709c87341db56fe34717bd08ef96d00681 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_gdi.c @@ -0,0 +1,848 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Windows GDI + * + * Copyright 2009-2011 Jay Sorg + * Copyright 2010-2011 Vic Lee + * Copyright 2010-2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wf_client.h" +#include "wf_graphics.h" +#include "wf_gdi.h" + +#define TAG CLIENT_TAG("windows.gdi") + +static const BYTE wf_rop2_table[] = { + R2_BLACK, /* 0 */ + R2_NOTMERGEPEN, /* DPon */ + R2_MASKNOTPEN, /* DPna */ + R2_NOTCOPYPEN, /* Pn */ + R2_MASKPENNOT, /* PDna */ + R2_NOT, /* Dn */ + R2_XORPEN, /* DPx */ + R2_NOTMASKPEN, /* DPan */ + R2_MASKPEN, /* DPa */ + R2_NOTXORPEN, /* DPxn */ + R2_NOP, /* D */ + R2_MERGENOTPEN, /* DPno */ + R2_COPYPEN, /* P */ + R2_MERGEPENNOT, /* PDno */ + R2_MERGEPEN, /* PDo */ + R2_WHITE, /* 1 */ +}; + +static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, COLORREF* color, UINT32* format) +{ + rdpGdi* gdi; + rdpSettings* settings; + UINT32 SrcFormat, DstFormat; + + if (!wfc) + return FALSE; + + gdi = wfc->common.context.gdi; + settings = wfc->common.context.settings; + + if (!gdi || !settings) + return FALSE; + + SrcFormat = gdi_get_pixel_format(freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)); + + if (format) + *format = SrcFormat; + + switch (FreeRDPGetBitsPerPixel(gdi->dstFormat)) + { + case 32: + DstFormat = PIXEL_FORMAT_ABGR32; + break; + + case 24: + DstFormat = PIXEL_FORMAT_BGR24; + break; + + case 16: + DstFormat = PIXEL_FORMAT_RGB16; + break; + + default: + return FALSE; + } + + *color = FreeRDPConvertColor(srcColor, SrcFormat, DstFormat, &gdi->palette); + return TRUE; +} + +static BOOL wf_set_rop2(HDC hdc, int rop2) +{ + if ((rop2 < 0x01) || (rop2 > 0x10)) + { + WLog_ERR(TAG, "Unsupported ROP2: %d", rop2); + return FALSE; + } + + SetROP2(hdc, wf_rop2_table[rop2 - 1]); + return TRUE; +} + +static wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph) +{ + wfBitmap* glyph_bmp; + glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO, glyph->aj); + return glyph_bmp; +} + +static void wf_glyph_free(wfBitmap* glyph) +{ + wf_image_free(glyph); +} + +static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, const BYTE* data) +{ + const int src_bytes_per_row = (width + 7) / 8; + const int dst_bytes_per_row = src_bytes_per_row + (src_bytes_per_row % 2); + BYTE* cdata = (BYTE*)malloc(dst_bytes_per_row * height); + const BYTE* src = data; + + for (int indexy = 0; indexy < height; indexy++) + { + BYTE* dst = &cdata[1ull * indexy * dst_bytes_per_row]; + + for (int indexx = 0; indexx < dst_bytes_per_row; indexx++) + { + if (indexx < src_bytes_per_row) + *dst++ = *src++; + else + *dst++ = 0; + } + } + + return cdata; +} + +static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UINT32 bpp) +{ + HBRUSH br; + LOGBRUSH lbr; + BYTE* cdata; + BYTE ipattern[8]; + HBITMAP pattern = NULL; + lbr.lbStyle = brush->style; + + if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8 || + lbr.lbStyle == BS_DIBPATTERNPT) + lbr.lbColor = DIB_RGB_COLORS; + else + lbr.lbColor = color; + + if (lbr.lbStyle == BS_PATTERN || lbr.lbStyle == BS_PATTERN8X8) + { + if (brush->bpp > 1) + { + UINT32 format = gdi_get_pixel_format(bpp); + pattern = wf_create_dib(wfc, 8, 8, format, brush->data, NULL); + lbr.lbHatch = (ULONG_PTR)pattern; + } + else + { + for (UINT32 i = 0; i != 8; i++) + ipattern[7 - i] = brush->data[i]; + + cdata = wf_glyph_convert(wfc, 8, 8, ipattern); + pattern = CreateBitmap(8, 8, 1, 1, cdata); + lbr.lbHatch = (ULONG_PTR)pattern; + free(cdata); + } + } + else if (lbr.lbStyle == BS_HATCHED) + { + lbr.lbHatch = brush->hatch; + } + else + { + lbr.lbHatch = 0; + } + + br = CreateBrushIndirect(&lbr); + SetBrushOrgEx(wfc->drawing->hdc, brush->x, brush->y, NULL); + + if (pattern != NULL) + DeleteObject(pattern); + + return br; +} + +BOOL wf_scale_rect(wfContext* wfc, RECT* source) +{ + UINT32 ww, wh, dw, dh; + rdpSettings* settings; + + if (!wfc || !source || !wfc->common.context.settings) + return FALSE; + + settings = wfc->common.context.settings; + + if (!settings) + return FALSE; + + dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + + if (!wfc->client_width) + wfc->client_width = dw; + + if (!wfc->client_height) + wfc->client_height = dh; + + ww = wfc->client_width; + wh = wfc->client_height; + + if (!ww) + ww = dw; + + if (!wh) + wh = dh; + + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) && + (ww != dw || wh != dh)) + { + source->bottom = source->bottom * wh / dh + 20; + source->top = source->top * wh / dh - 20; + source->left = source->left * ww / dw - 20; + source->right = source->right * ww / dw + 20; + } + + source->bottom -= wfc->yCurrentScroll; + source->top -= wfc->yCurrentScroll; + source->left -= wfc->xCurrentScroll; + source->right -= wfc->xCurrentScroll; + return TRUE; +} + +void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height) +{ + RECT rect; + rdpGdi* gdi = wfc->common.context.gdi; + wfc->update_rect.left = x + wfc->offset_x; + wfc->update_rect.top = y + wfc->offset_y; + wfc->update_rect.right = wfc->update_rect.left + width; + wfc->update_rect.bottom = wfc->update_rect.top + height; + wf_scale_rect(wfc, &(wfc->update_rect)); + InvalidateRect(wfc->hwnd, &(wfc->update_rect), FALSE); + rect.left = x; + rect.right = width; + rect.top = y; + rect.bottom = height; + wf_scale_rect(wfc, &rect); + gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right, rect.bottom); +} + +void wf_update_offset(wfContext* wfc) +{ + rdpSettings* settings; + settings = wfc->common.context.settings; + + if (wfc->fullscreen) + { + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon)) + { + int x = GetSystemMetrics(SM_XVIRTUALSCREEN); + int y = GetSystemMetrics(SM_YVIRTUALSCREEN); + int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); + int h = GetSystemMetrics(SM_CYVIRTUALSCREEN); + wfc->offset_x = (w - freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / 2; + + if (wfc->offset_x < x) + wfc->offset_x = x; + + wfc->offset_y = (h - freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / 2; + + if (wfc->offset_y < y) + wfc->offset_y = y; + } + else + { + wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / + 2; + + if (wfc->offset_x < 0) + wfc->offset_x = 0; + + wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / + 2; + + if (wfc->offset_y < 0) + wfc->offset_y = 0; + } + } + else + { + wfc->offset_x = 0; + wfc->offset_y = 0; + } +} + +void wf_resize_window(wfContext* wfc) +{ + rdpSettings* settings; + settings = wfc->common.context.settings; + + if (wfc->fullscreen) + { + if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon)) + { + int x = GetSystemMetrics(SM_XVIRTUALSCREEN); + int y = GetSystemMetrics(SM_YVIRTUALSCREEN); + int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); + int h = GetSystemMetrics(SM_CYVIRTUALSCREEN); + SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP); + SetWindowPos(wfc->hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED); + } + else + { + SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP); + SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), + GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED); + } + } + else if (!freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Decorations)) + { + SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD); + + if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow)) + { + if (!wfc->client_height) + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + + if (!wfc->client_width) + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + + wf_update_canvas_diff(wfc); + /* Now resize to get full canvas size and room for caption and borders */ + SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y, + wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y, + 0 /*SWP_FRAMECHANGED*/); + } + else + { + /* Now resize to get full canvas size and room for caption and borders */ + SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), + SWP_FRAMECHANGED); + wf_update_canvas_diff(wfc); + SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x, + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y, + SWP_NOMOVE | SWP_FRAMECHANGED); + } + } + else + { + SetWindowLongPtr(wfc->hwnd, GWL_STYLE, + WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | + WS_MAXIMIZEBOX); + + if (!wfc->client_height) + wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight); + + if (!wfc->client_width) + wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth); + + if (!wfc->client_x) + wfc->client_x = 10; + + if (!wfc->client_y) + wfc->client_y = 10; + + wf_update_canvas_diff(wfc); + /* Now resize to get full canvas size and room for caption and borders */ + int width, height; + if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) && + freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight)) + { + width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth); + height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight); + } + else + { + width = wfc->client_width + wfc->diff.x; + height = wfc->client_height + wfc->diff.y; + } + + int xpos, ypos; + if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) && + (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX)) + { + xpos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX); + ypos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY); + } + else + { + xpos = wfc->client_x; + ypos = wfc->client_y; + } + SetWindowPos(wfc->hwnd, HWND_TOP, xpos, ypos, width, height, 0 /*SWP_FRAMECHANGED*/); + // wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height); + } + + wf_update_offset(wfc); +} + +void wf_toggle_fullscreen(wfContext* wfc) +{ + ShowWindow(wfc->hwnd, SW_HIDE); + wfc->fullscreen = !wfc->fullscreen; + + if (wfc->fullscreen) + { + wfc->disablewindowtracking = TRUE; + } + + wf_floatbar_toggle_fullscreen(wfc->floatbar, wfc->fullscreen); + SetParent(wfc->hwnd, wfc->fullscreen ? NULL : wfc->hWndParent); + wf_resize_window(wfc); + ShowWindow(wfc->hwnd, SW_SHOW); + SetForegroundWindow(wfc->hwnd); + + if (!wfc->fullscreen) + { + // Re-enable window tracking AFTER resizing it back, otherwise it can lean to repositioning + // errors. + wfc->disablewindowtracking = FALSE; + } +} + +static BOOL wf_gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palette) +{ + return TRUE; +} + +void wf_set_null_clip_rgn(wfContext* wfc) +{ + SelectClipRgn(wfc->drawing->hdc, NULL); +} + +void wf_set_clip_rgn(wfContext* wfc, int x, int y, int width, int height) +{ + HRGN clip; + clip = CreateRectRgn(x, y, x + width, y + height); + SelectClipRgn(wfc->drawing->hdc, clip); + DeleteObject(clip); +} + +static BOOL wf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds) +{ + HRGN hrgn; + wfContext* wfc = (wfContext*)context; + + if (!context || !bounds) + return FALSE; + + if (bounds != NULL) + { + hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1, bounds->bottom + 1); + SelectClipRgn(wfc->drawing->hdc, hrgn); + DeleteObject(hrgn); + } + else + SelectClipRgn(wfc->drawing->hdc, NULL); + + return TRUE; +} + +static BOOL wf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt) +{ + wfContext* wfc = (wfContext*)context; + + if (!context || !dstblt) + return FALSE; + + if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, + dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop))) + return FALSE; + + wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight); + return TRUE; +} + +static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) +{ + HBRUSH brush; + HBRUSH org_brush; + int org_bkmode; + COLORREF fgcolor; + COLORREF bgcolor; + COLORREF org_bkcolor; + COLORREF org_textcolor; + BOOL rc; + wfContext* wfc = (wfContext*)context; + + if (!context || !patblt) + return FALSE; + + if (!wf_decode_color(wfc, patblt->foreColor, &fgcolor, NULL)) + return FALSE; + + if (!wf_decode_color(wfc, patblt->backColor, &bgcolor, NULL)) + return FALSE; + + brush = wf_create_brush(wfc, &patblt->brush, fgcolor, + freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth)); + org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE); + org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor); + org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor); + org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush); + rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, + patblt->nHeight, gdi_rop3_code(patblt->bRop)); + SelectObject(wfc->drawing->hdc, org_brush); + DeleteObject(brush); + SetBkMode(wfc->drawing->hdc, org_bkmode); + SetBkColor(wfc->drawing->hdc, org_bkcolor); + SetTextColor(wfc->drawing->hdc, org_textcolor); + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, + patblt->nHeight); + + return rc; +} + +static BOOL wf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt) +{ + wfContext* wfc = (wfContext*)context; + + if (!context || !scrblt || !wfc->drawing) + return FALSE; + + if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, + scrblt->nHeight, wfc->primary->hdc, scrblt->nXSrc, scrblt->nYSrc, + gdi_rop3_code(scrblt->bRop))) + return FALSE; + + wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight); + return TRUE; +} + +static BOOL wf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect) +{ + RECT rect; + HBRUSH brush; + COLORREF brush_color; + wfContext* wfc = (wfContext*)context; + + if (!context || !opaque_rect) + return FALSE; + + if (!wf_decode_color(wfc, opaque_rect->color, &brush_color, NULL)) + return FALSE; + + rect.left = opaque_rect->nLeftRect; + rect.top = opaque_rect->nTopRect; + rect.right = opaque_rect->nLeftRect + opaque_rect->nWidth; + rect.bottom = opaque_rect->nTopRect + opaque_rect->nHeight; + brush = CreateSolidBrush(brush_color); + FillRect(wfc->drawing->hdc, &rect, brush); + DeleteObject(brush); + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1, + rect.bottom - rect.top + 1); + + return TRUE; +} + +static BOOL wf_gdi_multi_opaque_rect(rdpContext* context, + const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) +{ + RECT rect; + HBRUSH brush; + COLORREF brush_color; + wfContext* wfc = (wfContext*)context; + + if (!context || !multi_opaque_rect) + return FALSE; + + if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color, NULL)) + return FALSE; + + for (UINT32 i = 0; i < multi_opaque_rect->numRectangles; i++) + { + const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i]; + rect.left = rectangle->left; + rect.top = rectangle->top; + rect.right = rectangle->left + rectangle->width; + rect.bottom = rectangle->top + rectangle->height; + brush = CreateSolidBrush(brush_color); + FillRect(wfc->drawing->hdc, &rect, brush); + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1, + rect.bottom - rect.top + 1); + + DeleteObject(brush); + } + + return TRUE; +} + +static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to) +{ + HPEN pen; + HPEN org_pen; + int x, y, w, h; + COLORREF pen_color; + wfContext* wfc = (wfContext*)context; + + if (!context || !line_to) + return FALSE; + + if (!wf_decode_color(wfc, line_to->penColor, &pen_color, NULL)) + return FALSE; + + pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color); + wf_set_rop2(wfc->drawing->hdc, line_to->bRop2); + org_pen = (HPEN)SelectObject(wfc->drawing->hdc, pen); + MoveToEx(wfc->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL); + LineTo(wfc->drawing->hdc, line_to->nXEnd, line_to->nYEnd); + x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd; + y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd; + w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart) + : (line_to->nXStart - line_to->nXEnd); + h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart) + : (line_to->nYStart - line_to->nYEnd); + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, x, y, w, h); + + SelectObject(wfc->drawing->hdc, org_pen); + DeleteObject(pen); + return TRUE; +} + +static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline) +{ + int org_rop2; + HPEN hpen; + HPEN org_hpen; + COLORREF pen_color; + wfContext* wfc = (wfContext*)context; + + if (!context || !polyline) + return FALSE; + + if (!wf_decode_color(wfc, polyline->penColor, &pen_color, NULL)) + return FALSE; + + hpen = CreatePen(0, 1, pen_color); + org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2); + org_hpen = (HPEN)SelectObject(wfc->drawing->hdc, hpen); + + if (polyline->numDeltaEntries > 0) + { + POINT* pts; + POINT temp; + int numPoints; + numPoints = polyline->numDeltaEntries + 1; + pts = (POINT*)malloc(sizeof(POINT) * numPoints); + pts[0].x = temp.x = polyline->xStart; + pts[0].y = temp.y = polyline->yStart; + + for (UINT32 i = 0; i < polyline->numDeltaEntries; i++) + { + temp.x += polyline->points[i].x; + temp.y += polyline->points[i].y; + pts[i + 1].x = temp.x; + pts[i + 1].y = temp.y; + } + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, wfc->client_x, wfc->client_y, wfc->client_width, + wfc->client_height); + + Polyline(wfc->drawing->hdc, pts, numPoints); + free(pts); + } + + SelectObject(wfc->drawing->hdc, org_hpen); + wf_set_rop2(wfc->drawing->hdc, org_rop2); + DeleteObject(hpen); + return TRUE; +} + +static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt) +{ + wfBitmap* bitmap; + wfContext* wfc = (wfContext*)context; + + if (!context || !memblt) + return FALSE; + + bitmap = (wfBitmap*)memblt->bitmap; + + if (!bitmap || !wfc->drawing || !wfc->drawing->hdc) + return FALSE; + + if (!BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, + memblt->nHeight, bitmap->hdc, memblt->nXSrc, memblt->nYSrc, + gdi_rop3_code(memblt->bRop))) + return FALSE; + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth, + memblt->nHeight); + + return TRUE; +} + +static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) +{ + BOOL rc = FALSE; + HDC hdc; + wfBitmap* bitmap; + wfContext* wfc = (wfContext*)context; + COLORREF fgcolor, bgcolor, orgColor; + HBRUSH orgBrush = NULL, brush = NULL; + + if (!context || !mem3blt) + return FALSE; + + bitmap = (wfBitmap*)mem3blt->bitmap; + + if (!bitmap || !wfc->drawing || !wfc->drawing->hdc) + return FALSE; + + hdc = wfc->drawing->hdc; + + if (!wf_decode_color(wfc, mem3blt->foreColor, &fgcolor, NULL)) + return FALSE; + + if (!wf_decode_color(wfc, mem3blt->backColor, &bgcolor, NULL)) + return FALSE; + + orgColor = SetTextColor(hdc, fgcolor); + + switch (mem3blt->brush.style) + { + case GDI_BS_SOLID: + brush = CreateSolidBrush(fgcolor); + break; + + case GDI_BS_HATCHED: + case GDI_BS_PATTERN: + { + HBITMAP bmp = CreateBitmap(8, 8, 1, mem3blt->brush.bpp, mem3blt->brush.data); + brush = CreatePatternBrush(bmp); + } + break; + + default: + goto fail; + } + + orgBrush = SelectObject(hdc, brush); + + if (!BitBlt(hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight, + bitmap->hdc, mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop))) + goto fail; + + if (wfc->drawing == wfc->primary) + wf_invalidate_region(wfc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, + mem3blt->nHeight); + + rc = TRUE; +fail: + + if (brush) + SelectObject(hdc, orgBrush); + + SetTextColor(hdc, orgColor); + return rc; +} + +static BOOL wf_gdi_surface_frame_marker(rdpContext* context, + const SURFACE_FRAME_MARKER* surface_frame_marker) +{ + rdpSettings* settings; + + if (!context || !surface_frame_marker || !context->instance) + return FALSE; + + settings = context->settings; + + if (!settings) + return FALSE; + + if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END && + freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0) + { + IFCALL(context->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId); + } + + return TRUE; +} + +void wf_gdi_register_update_callbacks(rdpUpdate* update) +{ + rdpPrimaryUpdate* primary = update->primary; + update->Palette = wf_gdi_palette_update; + update->SetBounds = wf_gdi_set_bounds; + primary->DstBlt = wf_gdi_dstblt; + primary->PatBlt = wf_gdi_patblt; + primary->ScrBlt = wf_gdi_scrblt; + primary->OpaqueRect = wf_gdi_opaque_rect; + primary->MultiOpaqueRect = wf_gdi_multi_opaque_rect; + primary->LineTo = wf_gdi_line_to; + primary->Polyline = wf_gdi_polyline; + primary->MemBlt = wf_gdi_memblt; + primary->Mem3Blt = wf_gdi_mem3blt; + update->SurfaceFrameMarker = wf_gdi_surface_frame_marker; +} + +void wf_update_canvas_diff(wfContext* wfc) +{ + RECT rc_client, rc_wnd; + int dx, dy; + GetClientRect(wfc->hwnd, &rc_client); + GetWindowRect(wfc->hwnd, &rc_wnd); + dx = (rc_wnd.right - rc_wnd.left) - rc_client.right; + dy = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom; + + if (!wfc->disablewindowtracking) + { + wfc->diff.x = dx; + wfc->diff.y = dy; + } +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.c b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.c new file mode 100644 index 0000000000000000000000000000000000000000..6d185e3fc2143ed547836d15d8bd69a7757973e3 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.c @@ -0,0 +1,994 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2013-2014 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include + +#include "wf_rail.h" + +#define TAG CLIENT_TAG("windows") + +#define GET_X_LPARAM(lParam) ((UINT16)(lParam & 0xFFFF)) +#define GET_Y_LPARAM(lParam) ((UINT16)((lParam >> 16) & 0xFFFF)) + +struct wf_rail_window +{ + wfContext* wfc; + + HWND hWnd; + + DWORD dwStyle; + DWORD dwExStyle; + + int x; + int y; + int width; + int height; + char* title; +}; + +/* RemoteApp Core Protocol Extension */ + +typedef struct +{ + UINT32 style; + const char* name; + BOOL multi; +} WINDOW_STYLE; + +static const WINDOW_STYLE WINDOW_STYLES[] = { { WS_BORDER, "WS_BORDER", FALSE }, + { WS_CAPTION, "WS_CAPTION", FALSE }, + { WS_CHILD, "WS_CHILD", FALSE }, + { WS_CLIPCHILDREN, "WS_CLIPCHILDREN", FALSE }, + { WS_CLIPSIBLINGS, "WS_CLIPSIBLINGS", FALSE }, + { WS_DISABLED, "WS_DISABLED", FALSE }, + { WS_DLGFRAME, "WS_DLGFRAME", FALSE }, + { WS_GROUP, "WS_GROUP", FALSE }, + { WS_HSCROLL, "WS_HSCROLL", FALSE }, + { WS_ICONIC, "WS_ICONIC", FALSE }, + { WS_MAXIMIZE, "WS_MAXIMIZE", FALSE }, + { WS_MAXIMIZEBOX, "WS_MAXIMIZEBOX", FALSE }, + { WS_MINIMIZE, "WS_MINIMIZE", FALSE }, + { WS_MINIMIZEBOX, "WS_MINIMIZEBOX", FALSE }, + { WS_OVERLAPPED, "WS_OVERLAPPED", FALSE }, + { WS_OVERLAPPEDWINDOW, "WS_OVERLAPPEDWINDOW", TRUE }, + { WS_POPUP, "WS_POPUP", FALSE }, + { WS_POPUPWINDOW, "WS_POPUPWINDOW", TRUE }, + { WS_SIZEBOX, "WS_SIZEBOX", FALSE }, + { WS_SYSMENU, "WS_SYSMENU", FALSE }, + { WS_TABSTOP, "WS_TABSTOP", FALSE }, + { WS_THICKFRAME, "WS_THICKFRAME", FALSE }, + { WS_VISIBLE, "WS_VISIBLE", FALSE } }; + +static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] = { + { WS_EX_ACCEPTFILES, "WS_EX_ACCEPTFILES", FALSE }, + { WS_EX_APPWINDOW, "WS_EX_APPWINDOW", FALSE }, + { WS_EX_CLIENTEDGE, "WS_EX_CLIENTEDGE", FALSE }, + { WS_EX_COMPOSITED, "WS_EX_COMPOSITED", FALSE }, + { WS_EX_CONTEXTHELP, "WS_EX_CONTEXTHELP", FALSE }, + { WS_EX_CONTROLPARENT, "WS_EX_CONTROLPARENT", FALSE }, + { WS_EX_DLGMODALFRAME, "WS_EX_DLGMODALFRAME", FALSE }, + { WS_EX_LAYERED, "WS_EX_LAYERED", FALSE }, + { WS_EX_LAYOUTRTL, "WS_EX_LAYOUTRTL", FALSE }, + { WS_EX_LEFT, "WS_EX_LEFT", FALSE }, + { WS_EX_LEFTSCROLLBAR, "WS_EX_LEFTSCROLLBAR", FALSE }, + { WS_EX_LTRREADING, "WS_EX_LTRREADING", FALSE }, + { WS_EX_MDICHILD, "WS_EX_MDICHILD", FALSE }, + { WS_EX_NOACTIVATE, "WS_EX_NOACTIVATE", FALSE }, + { WS_EX_NOINHERITLAYOUT, "WS_EX_NOINHERITLAYOUT", FALSE }, + { WS_EX_NOPARENTNOTIFY, "WS_EX_NOPARENTNOTIFY", FALSE }, + { WS_EX_OVERLAPPEDWINDOW, "WS_EX_OVERLAPPEDWINDOW", TRUE }, + { WS_EX_PALETTEWINDOW, "WS_EX_PALETTEWINDOW", TRUE }, + { WS_EX_RIGHT, "WS_EX_RIGHT", FALSE }, + { WS_EX_RIGHTSCROLLBAR, "WS_EX_RIGHTSCROLLBAR", FALSE }, + { WS_EX_RTLREADING, "WS_EX_RTLREADING", FALSE }, + { WS_EX_STATICEDGE, "WS_EX_STATICEDGE", FALSE }, + { WS_EX_TOOLWINDOW, "WS_EX_TOOLWINDOW", FALSE }, + { WS_EX_TOPMOST, "WS_EX_TOPMOST", FALSE }, + { WS_EX_TRANSPARENT, "WS_EX_TRANSPARENT", FALSE }, + { WS_EX_WINDOWEDGE, "WS_EX_WINDOWEDGE", FALSE } +}; + +static void PrintWindowStyles(UINT32 style) +{ + WLog_INFO(TAG, "\tWindow Styles:\t{"); + + for (size_t i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++) + { + if (style & WINDOW_STYLES[i].style) + { + if (WINDOW_STYLES[i].multi) + { + if ((style & WINDOW_STYLES[i].style) != WINDOW_STYLES[i].style) + continue; + } + + WLog_INFO(TAG, "\t\t%s", WINDOW_STYLES[i].name); + } + } +} + +static void PrintExtendedWindowStyles(UINT32 style) +{ + WLog_INFO(TAG, "\tExtended Window Styles:\t{"); + + for (size_t i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++) + { + if (style & EXTENDED_WINDOW_STYLES[i].style) + { + if (EXTENDED_WINDOW_STYLES[i].multi) + { + if ((style & EXTENDED_WINDOW_STYLES[i].style) != EXTENDED_WINDOW_STYLES[i].style) + continue; + } + + WLog_INFO(TAG, "\t\t%s", EXTENDED_WINDOW_STYLES[i].name); + } + } +} + +static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo, + const WINDOW_STATE_ORDER* windowState) +{ + if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW) + WLog_INFO(TAG, "WindowCreate: WindowId: 0x%08X", orderInfo->windowId); + else + WLog_INFO(TAG, "WindowUpdate: WindowId: 0x%08X", orderInfo->windowId); + + WLog_INFO(TAG, "{"); + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) + { + WLog_INFO(TAG, "\tOwnerWindowId: 0x%08X", windowState->ownerWindowId); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE) + { + WLog_INFO(TAG, "\tStyle: 0x%08X ExtendedStyle: 0x%08X", windowState->style, + windowState->extendedStyle); + PrintWindowStyles(windowState->style); + PrintExtendedWindowStyles(windowState->extendedStyle); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) + { + WLog_INFO(TAG, "\tShowState: %u", windowState->showState); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE) + { + const WCHAR* str = (const WCHAR*)windowState->titleInfo.string; + char* title = + ConvertWCharNToUtf8Alloc(str, windowState->titleInfo.length / sizeof(WCHAR), NULL); + WLog_INFO(TAG, "\tTitleInfo: %s (length = %hu)", title, windowState->titleInfo.length); + free(title); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) + { + WLog_INFO(TAG, "\tClientOffsetX: %d ClientOffsetY: %d", windowState->clientOffsetX, + windowState->clientOffsetY); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) + { + WLog_INFO(TAG, "\tClientAreaWidth: %u ClientAreaHeight: %u", windowState->clientAreaWidth, + windowState->clientAreaHeight); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) + { + WLog_INFO(TAG, "\tRPContent: %u", windowState->RPContent); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) + { + WLog_INFO(TAG, "\tRootParentHandle: 0x%08X", windowState->rootParentHandle); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) + { + WLog_INFO(TAG, "\tWindowOffsetX: %d WindowOffsetY: %d", windowState->windowOffsetX, + windowState->windowOffsetY); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) + { + WLog_INFO(TAG, "\tWindowClientDeltaX: %d WindowClientDeltaY: %d", + windowState->windowClientDeltaX, windowState->windowClientDeltaY); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) + { + WLog_INFO(TAG, "\tWindowWidth: %u WindowHeight: %u", windowState->windowWidth, + windowState->windowHeight); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) + { + RECTANGLE_16* rect; + WLog_INFO(TAG, "\tnumWindowRects: %u", windowState->numWindowRects); + + for (UINT32 index = 0; index < windowState->numWindowRects; index++) + { + rect = &windowState->windowRects[index]; + WLog_INFO(TAG, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index, + rect->left, rect->top, rect->right, rect->bottom); + } + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) + { + WLog_INFO(TAG, "\tvisibileOffsetX: %d visibleOffsetY: %d", windowState->visibleOffsetX, + windowState->visibleOffsetY); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) + { + RECTANGLE_16* rect; + WLog_INFO(TAG, "\tnumVisibilityRects: %u", windowState->numVisibilityRects); + + for (UINT32 index = 0; index < windowState->numVisibilityRects; index++) + { + rect = &windowState->visibilityRects[index]; + WLog_INFO(TAG, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index, + rect->left, rect->top, rect->right, rect->bottom); + } + } + + WLog_INFO(TAG, "}"); +} + +static void PrintRailIconInfo(const WINDOW_ORDER_INFO* orderInfo, const ICON_INFO* iconInfo) +{ + WLog_INFO(TAG, "ICON_INFO"); + WLog_INFO(TAG, "{"); + WLog_INFO(TAG, "\tbigIcon: %s", + (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? "true" : "false"); + WLog_INFO(TAG, "\tcacheEntry; 0x%08X", iconInfo->cacheEntry); + WLog_INFO(TAG, "\tcacheId: 0x%08X", iconInfo->cacheId); + WLog_INFO(TAG, "\tbpp: %u", iconInfo->bpp); + WLog_INFO(TAG, "\twidth: %u", iconInfo->width); + WLog_INFO(TAG, "\theight: %u", iconInfo->height); + WLog_INFO(TAG, "\tcbColorTable: %u", iconInfo->cbColorTable); + WLog_INFO(TAG, "\tcbBitsMask: %u", iconInfo->cbBitsMask); + WLog_INFO(TAG, "\tcbBitsColor: %u", iconInfo->cbBitsColor); + WLog_INFO(TAG, "\tcolorTable: %p", (void*)iconInfo->colorTable); + WLog_INFO(TAG, "\tbitsMask: %p", (void*)iconInfo->bitsMask); + WLog_INFO(TAG, "\tbitsColor: %p", (void*)iconInfo->bitsColor); + WLog_INFO(TAG, "}"); +} + +LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HDC hDC; + int x, y; + int width; + int height; + UINT32 xPos; + UINT32 yPos; + PAINTSTRUCT ps; + UINT32 inputFlags; + wfContext* wfc = NULL; + rdpInput* input = NULL; + rdpContext* context = NULL; + wfRailWindow* railWindow; + railWindow = (wfRailWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + + if (railWindow) + wfc = railWindow->wfc; + + if (wfc) + context = (rdpContext*)wfc; + + if (context) + input = context->input; + + switch (msg) + { + case WM_PAINT: + { + if (!wfc) + return 0; + + hDC = BeginPaint(hWnd, &ps); + x = ps.rcPaint.left; + y = ps.rcPaint.top; + width = ps.rcPaint.right - ps.rcPaint.left + 1; + height = ps.rcPaint.bottom - ps.rcPaint.top + 1; + BitBlt(hDC, x, y, width, height, wfc->primary->hdc, railWindow->x + x, + railWindow->y + y, SRCCOPY); + EndPaint(hWnd, &ps); + } + break; + + case WM_LBUTTONDOWN: + { + if (!railWindow || !input) + return 0; + + xPos = GET_X_LPARAM(lParam) + railWindow->x; + yPos = GET_Y_LPARAM(lParam) + railWindow->y; + inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1; + + if (input) + input->MouseEvent(input, inputFlags, xPos, yPos); + } + break; + + case WM_LBUTTONUP: + { + if (!railWindow || !input) + return 0; + + xPos = GET_X_LPARAM(lParam) + railWindow->x; + yPos = GET_Y_LPARAM(lParam) + railWindow->y; + inputFlags = PTR_FLAGS_BUTTON1; + + if (input) + input->MouseEvent(input, inputFlags, xPos, yPos); + } + break; + + case WM_RBUTTONDOWN: + { + if (!railWindow || !input) + return 0; + + xPos = GET_X_LPARAM(lParam) + railWindow->x; + yPos = GET_Y_LPARAM(lParam) + railWindow->y; + inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2; + + if (input) + input->MouseEvent(input, inputFlags, xPos, yPos); + } + break; + + case WM_RBUTTONUP: + { + if (!railWindow || !input) + return 0; + + xPos = GET_X_LPARAM(lParam) + railWindow->x; + yPos = GET_Y_LPARAM(lParam) + railWindow->y; + inputFlags = PTR_FLAGS_BUTTON2; + + if (input) + input->MouseEvent(input, inputFlags, xPos, yPos); + } + break; + + case WM_MOUSEMOVE: + { + if (!railWindow || !input) + return 0; + + xPos = GET_X_LPARAM(lParam) + railWindow->x; + yPos = GET_Y_LPARAM(lParam) + railWindow->y; + inputFlags = PTR_FLAGS_MOVE; + + if (input) + input->MouseEvent(input, inputFlags, xPos, yPos); + } + break; + + case WM_MOUSEWHEEL: + break; + + case WM_CLOSE: + DestroyWindow(hWnd); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + + return 0; +} + +#define RAIL_DISABLED_WINDOW_STYLES \ + (WS_BORDER | WS_THICKFRAME | WS_DLGFRAME | WS_CAPTION | WS_OVERLAPPED | WS_VSCROLL | \ + WS_HSCROLL | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) +#define RAIL_DISABLED_EXTENDED_WINDOW_STYLES \ + (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE) + +static BOOL wf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const WINDOW_STATE_ORDER* windowState) +{ + wfRailWindow* railWindow = NULL; + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + UINT32 fieldFlags = orderInfo->fieldFlags; + PrintRailWindowState(orderInfo, windowState); + + if (fieldFlags & WINDOW_ORDER_STATE_NEW) + { + BOOL rc; + HANDLE hInstance; + WCHAR* titleW = NULL; + WNDCLASSEX wndClassEx = { 0 }; + railWindow = (wfRailWindow*)calloc(1, sizeof(wfRailWindow)); + + if (!railWindow) + return FALSE; + + railWindow->wfc = wfc; + railWindow->dwStyle = windowState->style; + railWindow->dwStyle &= ~RAIL_DISABLED_WINDOW_STYLES; + railWindow->dwExStyle = windowState->extendedStyle; + railWindow->dwExStyle &= ~RAIL_DISABLED_EXTENDED_WINDOW_STYLES; + railWindow->x = windowState->windowOffsetX; + railWindow->y = windowState->windowOffsetY; + railWindow->width = windowState->windowWidth; + railWindow->height = windowState->windowHeight; + + if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) + { + const WCHAR* str = (const WCHAR*)windowState->titleInfo.string; + char* title = NULL; + + if (windowState->titleInfo.length == 0) + { + if (!(title = _strdup(""))) + { + WLog_ERR(TAG, "failed to duplicate empty window title string"); + /* error handled below */ + } + } + else if (!(title = ConvertWCharNToUtf8Alloc( + str, windowState->titleInfo.length / sizeof(WCHAR), NULL))) + { + WLog_ERR(TAG, "failed to convert window title"); + /* error handled below */ + } + + railWindow->title = title; + } + else + { + if (!(railWindow->title = _strdup("RdpRailWindow"))) + WLog_ERR(TAG, "failed to duplicate default window title string"); + } + + if (!railWindow->title) + { + free(railWindow); + return FALSE; + } + + titleW = ConvertUtf8ToWCharAlloc(railWindow->title, NULL); + hInstance = GetModuleHandle(NULL); + + wndClassEx.cbSize = sizeof(WNDCLASSEX); + wndClassEx.style = 0; + wndClassEx.lpfnWndProc = wf_RailWndProc; + wndClassEx.cbClsExtra = 0; + wndClassEx.cbWndExtra = 0; + wndClassEx.hIcon = NULL; + wndClassEx.hCursor = NULL; + wndClassEx.hbrBackground = NULL; + wndClassEx.lpszMenuName = NULL; + wndClassEx.lpszClassName = _T("RdpRailWindow"); + wndClassEx.hInstance = hInstance; + wndClassEx.hIconSm = NULL; + RegisterClassEx(&wndClassEx); + railWindow->hWnd = CreateWindowExW(railWindow->dwExStyle, /* dwExStyle */ + _T("RdpRailWindow"), /* lpClassName */ + titleW, /* lpWindowName */ + railWindow->dwStyle, /* dwStyle */ + railWindow->x, /* x */ + railWindow->y, /* y */ + railWindow->width, /* nWidth */ + railWindow->height, /* nHeight */ + NULL, /* hWndParent */ + NULL, /* hMenu */ + hInstance, /* hInstance */ + NULL /* lpParam */ + ); + + if (!railWindow->hWnd) + { + free(titleW); + free(railWindow->title); + free(railWindow); + WLog_ERR(TAG, "CreateWindowExW failed with error %" PRIu32 "", GetLastError()); + return FALSE; + } + + SetWindowLongPtr(railWindow->hWnd, GWLP_USERDATA, (LONG_PTR)railWindow); + rc = HashTable_Insert(wfc->railWindows, (void*)(UINT_PTR)orderInfo->windowId, + (void*)railWindow); + free(titleW); + UpdateWindow(railWindow->hWnd); + return rc; + } + else + { + railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, + (void*)(UINT_PTR)orderInfo->windowId); + } + + if (!railWindow) + return TRUE; + + if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)) + { + if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) + { + railWindow->x = windowState->windowOffsetX; + railWindow->y = windowState->windowOffsetY; + } + + if (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) + { + railWindow->width = windowState->windowWidth; + railWindow->height = windowState->windowHeight; + } + + SetWindowPos(railWindow->hWnd, NULL, railWindow->x, railWindow->y, railWindow->width, + railWindow->height, 0); + } + + if (fieldFlags & WINDOW_ORDER_FIELD_OWNER) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) + { + railWindow->dwStyle = windowState->style; + railWindow->dwStyle &= ~RAIL_DISABLED_WINDOW_STYLES; + railWindow->dwExStyle = windowState->extendedStyle; + railWindow->dwExStyle &= ~RAIL_DISABLED_EXTENDED_WINDOW_STYLES; + SetWindowLongPtr(railWindow->hWnd, GWL_STYLE, (LONG)railWindow->dwStyle); + SetWindowLongPtr(railWindow->hWnd, GWL_EXSTYLE, (LONG)railWindow->dwExStyle); + } + + if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) + { + ShowWindow(railWindow->hWnd, windowState->showState); + } + + if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) + { + const WCHAR* str = (const WCHAR*)windowState->titleInfo.string; + char* title = NULL; + + if (windowState->titleInfo.length == 0) + { + if (!(title = _strdup(""))) + { + WLog_ERR(TAG, "failed to duplicate empty window title string"); + return FALSE; + } + } + else if (!(title = ConvertWCharNToUtf8Alloc( + str, windowState->titleInfo.length / sizeof(WCHAR), NULL))) + { + WLog_ERR(TAG, "failed to convert window title"); + return FALSE; + } + + free(railWindow->title); + railWindow->title = title; + SetWindowTextW(railWindow->hWnd, str); + } + + if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) + { + HRGN hWndRect; + HRGN hWndRects; + RECTANGLE_16* rect; + + if (windowState->numWindowRects > 0) + { + rect = &(windowState->windowRects[0]); + hWndRects = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); + + for (UINT32 index = 1; index < windowState->numWindowRects; index++) + { + rect = &(windowState->windowRects[index]); + hWndRect = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); + CombineRgn(hWndRects, hWndRects, hWndRect, RGN_OR); + DeleteObject(hWndRect); + } + + SetWindowRgn(railWindow->hWnd, hWndRects, TRUE); + DeleteObject(hWndRects); + } + } + + if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) + { + } + + if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) + { + } + + UpdateWindow(railWindow->hWnd); + return TRUE; +} + +static BOOL wf_rail_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) +{ + wfRailWindow* railWindow = NULL; + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailWindowDelete"); + railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, + (void*)(UINT_PTR)orderInfo->windowId); + + if (!railWindow) + return TRUE; + + HashTable_Remove(wfc->railWindows, (void*)(UINT_PTR)orderInfo->windowId); + DestroyWindow(railWindow->hWnd); + free(railWindow); + return TRUE; +} + +static BOOL wf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const WINDOW_ICON_ORDER* windowIcon) +{ + HDC hDC; + int bpp; + int width; + int height; + HICON hIcon; + BOOL bigIcon; + ICONINFO iconInfo = { 0 }; + BITMAPINFO bitmapInfo = { 0 }; + wfRailWindow* railWindow; + BITMAPINFOHEADER* bitmapInfoHeader; + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailWindowIcon"); + PrintRailIconInfo(orderInfo, windowIcon->iconInfo); + railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, + (void*)(UINT_PTR)orderInfo->windowId); + + if (!railWindow) + return TRUE; + + bigIcon = (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? TRUE : FALSE; + hDC = GetDC(railWindow->hWnd); + iconInfo.fIcon = TRUE; + iconInfo.xHotspot = 0; + iconInfo.yHotspot = 0; + + bitmapInfoHeader = &(bitmapInfo.bmiHeader); + bpp = windowIcon->iconInfo->bpp; + width = windowIcon->iconInfo->width; + height = windowIcon->iconInfo->height; + bitmapInfoHeader->biSize = sizeof(BITMAPINFOHEADER); + bitmapInfoHeader->biWidth = width; + bitmapInfoHeader->biHeight = height; + bitmapInfoHeader->biPlanes = 1; + bitmapInfoHeader->biBitCount = bpp; + bitmapInfoHeader->biCompression = 0; + bitmapInfoHeader->biSizeImage = height * width * ((bpp + 7) / 8); + bitmapInfoHeader->biXPelsPerMeter = width; + bitmapInfoHeader->biYPelsPerMeter = height; + bitmapInfoHeader->biClrUsed = 0; + bitmapInfoHeader->biClrImportant = 0; + iconInfo.hbmMask = CreateDIBitmap(hDC, bitmapInfoHeader, CBM_INIT, + windowIcon->iconInfo->bitsMask, &bitmapInfo, DIB_RGB_COLORS); + iconInfo.hbmColor = + CreateDIBitmap(hDC, bitmapInfoHeader, CBM_INIT, windowIcon->iconInfo->bitsColor, + &bitmapInfo, DIB_RGB_COLORS); + hIcon = CreateIconIndirect(&iconInfo); + + if (hIcon) + { + WPARAM wParam; + LPARAM lParam; + wParam = (WPARAM)bigIcon ? ICON_BIG : ICON_SMALL; + lParam = (LPARAM)hIcon; + SendMessage(railWindow->hWnd, WM_SETICON, wParam, lParam); + } + + ReleaseDC(NULL, hDC); + + if (windowIcon->iconInfo->cacheEntry != 0xFFFF) + { + /* icon should be cached */ + } + + return TRUE; +} + +static BOOL wf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const WINDOW_CACHED_ICON_ORDER* windowCachedIcon) +{ + WLog_DBG(TAG, "RailWindowCachedIcon"); + return TRUE; +} + +static void wf_rail_notify_icon_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const NOTIFY_ICON_STATE_ORDER* notifyIconState) +{ + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) + { + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP) + { + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP) + { + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) + { + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_ICON) + { + const ICON_INFO* iconInfo = &(notifyIconState->icon); + PrintRailIconInfo(orderInfo, iconInfo); + } + + if (orderInfo->fieldFlags & WINDOW_ORDER_CACHED_ICON) + { + } +} + +static BOOL wf_rail_notify_icon_create(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const NOTIFY_ICON_STATE_ORDER* notifyIconState) +{ + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailNotifyIconCreate"); + wf_rail_notify_icon_common(context, orderInfo, notifyIconState); + return TRUE; +} + +static BOOL wf_rail_notify_icon_update(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const NOTIFY_ICON_STATE_ORDER* notifyIconState) +{ + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailNotifyIconUpdate"); + wf_rail_notify_icon_common(context, orderInfo, notifyIconState); + return TRUE; +} + +static BOOL wf_rail_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) +{ + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailNotifyIconDelete"); + return TRUE; +} + +static BOOL wf_rail_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, + const MONITORED_DESKTOP_ORDER* monitoredDesktop) +{ + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailMonitorDesktop"); + return TRUE; +} + +static BOOL wf_rail_non_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) +{ + wfContext* wfc = (wfContext*)context; + RailClientContext* rail = wfc->rail; + WLog_DBG(TAG, "RailNonMonitorDesktop"); + return TRUE; +} + +void wf_rail_register_update_callbacks(rdpUpdate* update) +{ + rdpWindowUpdate* window = update->window; + window->WindowCreate = wf_rail_window_common; + window->WindowUpdate = wf_rail_window_common; + window->WindowDelete = wf_rail_window_delete; + window->WindowIcon = wf_rail_window_icon; + window->WindowCachedIcon = wf_rail_window_cached_icon; + window->NotifyIconCreate = wf_rail_notify_icon_create; + window->NotifyIconUpdate = wf_rail_notify_icon_update; + window->NotifyIconDelete = wf_rail_notify_icon_delete; + window->MonitoredDesktop = wf_rail_monitored_desktop; + window->NonMonitoredDesktop = wf_rail_non_monitored_desktop; +} + +/* RemoteApp Virtual Channel Extension */ + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_execute_result(RailClientContext* context, + const RAIL_EXEC_RESULT_ORDER* execResult) +{ + WLog_DBG(TAG, "RailServerExecuteResult: 0x%08X", execResult->rawResult); + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_system_param(RailClientContext* context, + const RAIL_SYSPARAM_ORDER* sysparam) +{ + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_handshake(RailClientContext* context, + const RAIL_HANDSHAKE_ORDER* handshake) +{ + return client_rail_server_start_cmd(context); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_handshake_ex(RailClientContext* context, + const RAIL_HANDSHAKE_EX_ORDER* handshakeEx) +{ + return client_rail_server_start_cmd(context); +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_local_move_size(RailClientContext* context, + const RAIL_LOCALMOVESIZE_ORDER* localMoveSize) +{ + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_min_max_info(RailClientContext* context, + const RAIL_MINMAXINFO_ORDER* minMaxInfo) +{ + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_language_bar_info(RailClientContext* context, + const RAIL_LANGBAR_INFO_ORDER* langBarInfo) +{ + return CHANNEL_RC_OK; +} + +/** + * Function description + * + * @return 0 on success, otherwise a Win32 error code + */ +static UINT wf_rail_server_get_appid_response(RailClientContext* context, + const RAIL_GET_APPID_RESP_ORDER* getAppIdResp) +{ + return CHANNEL_RC_OK; +} + +void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion) +{ + RECT updateRect; + RECTANGLE_16 windowRect; + ULONG_PTR* pKeys = NULL; + wfRailWindow* railWindow; + const RECTANGLE_16* extents; + REGION16 windowInvalidRegion; + region16_init(&windowInvalidRegion); + size_t count = HashTable_GetKeys(wfc->railWindows, &pKeys); + + for (size_t index = 0; index < count; index++) + { + railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, (void*)pKeys[index]); + + if (railWindow) + { + windowRect.left = railWindow->x; + windowRect.top = railWindow->y; + windowRect.right = railWindow->x + railWindow->width; + windowRect.bottom = railWindow->y + railWindow->height; + region16_clear(&windowInvalidRegion); + region16_intersect_rect(&windowInvalidRegion, invalidRegion, &windowRect); + + if (!region16_is_empty(&windowInvalidRegion)) + { + extents = region16_extents(&windowInvalidRegion); + updateRect.left = extents->left - railWindow->x; + updateRect.top = extents->top - railWindow->y; + updateRect.right = extents->right - railWindow->x; + updateRect.bottom = extents->bottom - railWindow->y; + InvalidateRect(railWindow->hWnd, &updateRect, FALSE); + } + } + } + + region16_uninit(&windowInvalidRegion); +} + +BOOL wf_rail_init(wfContext* wfc, RailClientContext* rail) +{ + rdpContext* context = (rdpContext*)wfc; + wfc->rail = rail; + rail->custom = (void*)wfc; + rail->ServerExecuteResult = wf_rail_server_execute_result; + rail->ServerSystemParam = wf_rail_server_system_param; + rail->ServerHandshake = wf_rail_server_handshake; + rail->ServerHandshakeEx = wf_rail_server_handshake_ex; + rail->ServerLocalMoveSize = wf_rail_server_local_move_size; + rail->ServerMinMaxInfo = wf_rail_server_min_max_info; + rail->ServerLanguageBarInfo = wf_rail_server_language_bar_info; + rail->ServerGetAppIdResponse = wf_rail_server_get_appid_response; + wf_rail_register_update_callbacks(context->update); + wfc->railWindows = HashTable_New(TRUE); + return (wfc->railWindows != NULL); +} + +void wf_rail_uninit(wfContext* wfc, RailClientContext* rail) +{ + wfc->rail = NULL; + rail->custom = NULL; + HashTable_Free(wfc->railWindows); +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.h b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.h new file mode 100644 index 0000000000000000000000000000000000000000..2b73821e1a7d5a3428f20762b3ee75d734a597c0 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/Windows/wf_rail.h @@ -0,0 +1,33 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2013-2014 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CLIENT_WIN_RAIL_H +#define FREERDP_CLIENT_WIN_RAIL_H + +typedef struct wf_rail_window wfRailWindow; + +#include "wf_client.h" + +#include + +BOOL wf_rail_init(wfContext* wfc, RailClientContext* rail); +void wf_rail_uninit(wfContext* wfc, RailClientContext* rail); + +void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion); + +#endif /* FREERDP_CLIENT_WIN_RAIL_H */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/freerdp-client.pc.in b/local-test-freerdp-delta-01/afc-freerdp/client/freerdp-client.pc.in new file mode 100644 index 0000000000000000000000000000000000000000..e446657cf0748d14b5cbd2830c89000a43cf4031 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/freerdp-client.pc.in @@ -0,0 +1,15 @@ +prefix=@PKG_CONFIG_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@FREERDP_INCLUDE_DIR@ +libs=-lfreerdp-client@FREERDP_API_VERSION@ + +Name: FreeRDP client +Description: FreeRDP: A Remote Desktop Protocol Implementation +URL: http://www.freerdp.com/ +Version: @FREERDP_VERSION@ +Requires: +Requires.private: @WINPR_PKG_CONFIG_FILENAME@ freerdp@FREERDP_VERSION_MAJOR@ +Libs: -L${libdir} ${libs} +Libs.private: -ldl -lpthread @FREERDP_CLIENT_PC_PRIVATE_LIBS@ +Cflags: -I${includedir} diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.h b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..dc13cd8fa416bab1b1257546645c420667ab59c9 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.h @@ -0,0 +1,24 @@ +/* + App delegate + + Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at + http://mozilla.org/MPL/2.0/. + */ + +#import + +@class MainTabBarController; + +@interface AppDelegate : NSObject +{ + + MainTabBarController *_tabBarController; +} + +@property(nonatomic, retain) IBOutlet UIWindow *window; +@property(nonatomic, retain) IBOutlet MainTabBarController *tabBarController; + +@end diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.m b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..b964593fb3a16d523a7b0c437c46ef395f12fe7c --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/AppDelegate.m @@ -0,0 +1,127 @@ +/* + App delegate + + Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at + http://mozilla.org/MPL/2.0/. + */ + +#import "AppDelegate.h" + +#import "AboutController.h" +#import "HelpController.h" +#import "BookmarkListController.h" +#import "AppSettingsController.h" +#import "MainTabBarController.h" +#import "Utils.h" + +@implementation AppDelegate + +@synthesize window = _window, tabBarController = _tabBarController; + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + // Set default values for most NSUserDefaults + [[NSUserDefaults standardUserDefaults] + registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] + pathForResource:@"Defaults" + ofType:@"plist"]]]; + + // init global settings + SetSwapMouseButtonsFlag( + [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]); + SetInvertScrollingFlag( + [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]); + + // create bookmark view and navigation controller + BookmarkListController *bookmarkListController = + [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView" + bundle:nil] autorelease]; + UINavigationController *bookmarkNavigationController = [[[UINavigationController alloc] + initWithRootViewController:bookmarkListController] autorelease]; + + // create app settings view and navigation controller + AppSettingsController *appSettingsController = + [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; + UINavigationController *appSettingsNavigationController = [[[UINavigationController alloc] + initWithRootViewController:appSettingsController] autorelease]; + + // create help view controller + HelpController *helpViewController = [[[HelpController alloc] initWithNibName:nil + bundle:nil] autorelease]; + + // create about view controller + AboutController *aboutViewController = + [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease]; + + // add tab-bar controller to the main window and display everything + NSArray *tabItems = + [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController, + helpViewController, aboutViewController, nil]; + [_tabBarController setViewControllers:tabItems]; + if ([_window respondsToSelector:@selector(setRootViewController:)]) + [_window setRootViewController:_tabBarController]; + else + [_window addSubview:[_tabBarController view]]; + [_window makeKeyAndVisible]; + + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + /* + Sent when the application is about to move from active to inactive state. This can occur for + certain types of temporary interruptions (such as an incoming phone call or SMS message) or + when the user quits the application and it begins the transition to the background state. Use + this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. + Games should use this method to pause the game. + */ +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + /* + Use this method to release shared resources, save user data, invalidate timers, and store + enough application state information to restore your application to its current state in case + it is terminated later. If your application supports background execution, this method is + called instead of applicationWillTerminate: when the user quits. + */ +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + /* + Called as part of the transition from the background to the inactive state; here you can undo + many of the changes made on entering the background. + */ + // cancel disconnect timer +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If + the application was previously in the background, optionally refresh the user interface. + */ +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + /* + Called when the application is about to terminate. + Save data if appropriate. + See also applicationDidEnterBackground:. + */ +} + +- (void)dealloc +{ + [_window release]; + [super dealloc]; +} + +@end diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/CMakeLists.txt b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f69dd692d5fb70e5f78cefadb2a7324a1307f955 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/CMakeLists.txt @@ -0,0 +1,160 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP X11 Client +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.13) + +if(NOT FREERDP_DEFAULT_PROJECT_VERSION) + set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0") +endif() + +project(iFreeRDP VERSION ${FREERDP_DEFAULT_PROJECT_VERSION}) + +message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}") + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_CURRENT_SOURCE_DIR}/../../cmake/) +include(CommonConfigOptions) + +set(MODULE_NAME "iFreeRDP") +set(MODULE_PREFIX "IFREERDP_CLIENT") +set(APP_TYPE MACOSX_BUNDLE) + +set(IOS_CLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(IOS_CLIENT_ADDITIONS_DIR ${IOS_CLIENT_DIR}/Additions) +set(IOS_CLIENT_CONTROLLERS_DIR ${IOS_CLIENT_DIR}/Controllers) +set(IOS_CLIENT_FREERDP_DIR ${IOS_CLIENT_DIR}/FreeRDP) +set(IOS_CLIENT_MISC_DIR ${IOS_CLIENT_DIR}/Misc) +set(IOS_CLIENT_MODELS_DIR ${IOS_CLIENT_DIR}/Models) +set(IOS_CLIENT_VIEWS_DIR ${IOS_CLIENT_DIR}/Views) +set(IOS_CLIENT_RESOURCES_DIR ${IOS_CLIENT_DIR}/Resources) + +include_directories(SYSTEM ${IOS_CLIENT_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_ADDITIONS_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_CONTROLLERS_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_FREERDP_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_MISC_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_MODELS_DIR}) +include_directories(SYSTEM ${IOS_CLIENT_VIEWS_DIR}) +include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) + +# Add sources +set(${MODULE_PREFIX}_SRCS AppDelegate.m AppDelegate.h main.m) + +file(GLOB IOS_CLIENT_ADDITIONS_SRCS ${IOS_CLIENT_ADDITIONS_DIR}/*.m) +file(GLOB IOS_CLIENT_ADDITIONS_HDRS ${IOS_CLIENT_ADDITIONS_DIR}/*.h) + +file(GLOB IOS_CLIENT_CONTROLLERS_SRCS ${IOS_CLIENT_CONTROLLERS_DIR}/*.m) +file(GLOB IOS_CLIENT_CONTROLLERS_HDRS ${IOS_CLIENT_CONTROLLERS_DIR}/*.h) + +file(GLOB IOS_CLIENT_FREERDP_SRCS ${IOS_CLIENT_FREERDP_DIR}/*.m) +file(GLOB IOS_CLIENT_FREERDP_HDRS ${IOS_CLIENT_FREERDP_DIR}/*.h) + +file(GLOB IOS_CLIENT_MISC_SRCS ${IOS_CLIENT_MISC_DIR}/*.m) +file(GLOB IOS_CLIENT_MISC_HDRS ${IOS_CLIENT_MISC_DIR}/*.h) + +file(GLOB IOS_CLIENT_MODELS_SRCS ${IOS_CLIENT_MODELS_DIR}/*.m) +file(GLOB IOS_CLIENT_MODELS_HDRS ${IOS_CLIENT_MODELS_DIR}/*.h) + +file(GLOB IOS_CLIENT_VIEWS_SRCS ${IOS_CLIENT_VIEWS_DIR}/*.m) +file(GLOB IOS_CLIENT_VIEWS_HDRS ${IOS_CLIENT_VIEWS_DIR}/*.h) + +# add resources +file(GLOB IOS_CLIENT_RESOURCES_XIBS ${IOS_CLIENT_RESOURCES_DIR}/*.xib) +file(GLOB IOS_CLIENT_RESOURCES_PNGS ${IOS_CLIENT_RESOURCES_DIR}/*.png) + +# Specify source grouping +source_group(Additions FILES ${IOS_CLIENT_ADDITIONS_SRCS} ${IOS_CLIENT_ADDITIONS_HDRS}) +source_group(Controllers FILES ${IOS_CLIENT_CONTROLLERS_SRCS} ${IOS_CLIENT_CONTROLLERS_HDRS}) +source_group(FreeRDP FILES ${IOS_CLIENT_FREERDP_SRCS} ${IOS_CLIENT_FREERDP_HDRS}) +source_group(Misc FILES ${IOS_CLIENT_MISC_SRCS} ${IOS_CLIENT_MISC_HDRS}) +source_group(Models FILES ${IOS_CLIENT_MODELS_SRCS} ${IOS_CLIENT_MODELS_HDRS}) +source_group(Views FILES ${IOS_CLIENT_RESOURCES_XIBS} ${IOS_CLIENT_VIEWS_SRCS} ${IOS_CLIENT_VIEWS_HDRS}) +source_group( + Resources FILES ${IOS_CLIENT_RESOURCES_PNGS} ${IOS_CLIENT_RESOURCES_DIR}/about_page + ${IOS_CLIENT_RESOURCES_DIR}/help_page ${IOS_CLIENT_RESOURCES_DIR}/en.lproj +) + +# import libraries +find_library(FOUNDATION_FRAMEWORK Foundation) +find_library(COREGRAPHICS_FRAMEWORK CoreGraphics) +find_library(SECURITY_FRAMEWORK Security) +find_library(UIKIT_FRAMEWORK UIKit) +find_library(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) + +mark_as_advanced( + FOUNDATION_FRAMEWORK COREGRAPHICS_FRAMEWORK SECURITY_FRAMEWORK UIKIT_FRAMEWORK SYSTEMCONFIGURATION_FRAMEWORK +) +set(EXTRA_LIBS ${FOUNDATION_FRAMEWORK} ${COREGRAPHICS_FRAMEWORK} ${SECURITY_FRAMEWORK} ${UIKIT_FRAMEWORK} + ${SYSTEMCONFIGURATION_FRAMEWORK} +) + +set(${MODULE_NAME}_RESOURCES ${IOS_CLIENT_RESOURCES_XIBS}) +set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${IOS_CLIENT_RESOURCES_PNGS}) +set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${IOS_CLIENT_RESOURCES_DIR}/about_page + ${IOS_CLIENT_RESOURCES_DIR}/help_page ${IOS_CLIENT_RESOURCES_DIR}/en.lproj +) +set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${IOS_CLIENT_DIR}/Defaults.plist) + +add_executable( + ${MODULE_NAME} + ${APP_TYPE} + ${${MODULE_PREFIX}_SRCS} + ${IOS_CLIENT_ADDITIONS_SRCS} + ${IOS_CLIENT_ADDITIONS_HDRS} + ${IOS_CLIENT_CONTROLLERS_SRCS} + ${IOS_CLIENT_CONTROLLERS_HDRS} + ${IOS_CLIENT_FREERDP_SRCS} + ${IOS_CLIENT_FREERDP_HDRS} + ${IOS_CLIENT_MISC_SRCS} + ${IOS_CLIENT_MISC_HDRS} + ${IOS_CLIENT_MODELS_SRCS} + ${IOS_CLIENT_MODELS_HDRS} + ${IOS_CLIENT_VIEWS_SRCS} + ${IOS_CLIENT_VIEWS_HDRS} + ${${MODULE_NAME}_RESOURCES} +) + +if(WITH_BINARY_VERSIONING) + set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${PROJECT_VERSION_MAJOR}") +endif() +set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOURCES}") + +set(EXECUTABLE_NAME "\${EXECUTABLE_NAME}") + +set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${IOS_CLIENT_DIR}/iFreeRDP.plist) +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_TARGET_SDK}") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++0x") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO) +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "gnu99") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES "NO") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_SKIP_INSTALL NO) +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH "/Applications") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS YES) +if(CODE_SIGN_IDENTITY) + set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODE_SIGN_IDENTITY}") +endif() + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS}) + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/iOS") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/Defaults.plist b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/Defaults.plist new file mode 100644 index 0000000000000000000000000000000000000000..d0313e133883909a007fb4347447dea52ac2da19 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/Defaults.plist @@ -0,0 +1,92 @@ + + + + + TSXDefaultComputerBookmarkSettings + + hostname + + port + 3389 + screen_resolution_type + 1 + width + 0 + height + 0 + colors + 16 + perf_font_smoothing + + perf_menu_animation + + perf_show_desktop + + perf_window_dragging + + perf_windows_themes + + perf_remotefx + + perf_gfx + + perf_h264 + + perf_desktop_composition + + enable_3g_settings + + settings_3g + + screen_resolution_type + 0 + width + 800 + height + 600 + colors + 16 + perf_remotefx + + perf_gfx + + perf_h264 + + perf_desktop_composition + + perf_windows_themes + + perf_window_dragging + + perf_show_desktop + + perf_menu_animation + + perf_font_smoothing + + + security + 0 + remote_program + + working_dir + + console + + enable_tsg_settings + + tsg_hostname + + tsg_port + 443 + tsg_username + + tsg_password + + tsg_domain + + + ui.auto_scroll_touchpointer + + + diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/ModuleOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/ModuleOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ced71677cad9ec2be8630b33559d2297b16069b4 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/ModuleOptions.cmake @@ -0,0 +1,3 @@ +set(FREERDP_CLIENT_NAME "ifreerdp") +set(FREERDP_CLIENT_PLATFORM "iOS") +set(FREERDP_CLIENT_VENDOR "FreeRDP") diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP-Prefix.pch b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP-Prefix.pch new file mode 100644 index 0000000000000000000000000000000000000000..171160a36540852e31ec7fb7b50ca8415f2675e4 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP-Prefix.pch @@ -0,0 +1,23 @@ +/* + PCH + + Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// +// Prefix header for all source files of the 'iFreeRDP' target in the 'iFreeRDP' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iPhone SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP.plist b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP.plist new file mode 100644 index 0000000000000000000000000000000000000000..2cf9069878a164fa28f8cdc4003ae44ea62d3b02 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/iFreeRDP.plist @@ -0,0 +1,53 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + iFreeRDP + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + Icon.png + Icon-72.png + Icon@2x.png + Icon-72@2x.png + + CFBundleIdentifier + com.freerdp.ifreerdp + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0.1 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UIPrerenderedIcon + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/local-test-freerdp-delta-01/afc-freerdp/client/iOS/main.m b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/main.m new file mode 100644 index 0000000000000000000000000000000000000000..bf0b614024f09c1234cda81684c788628731b69a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/client/iOS/main.m @@ -0,0 +1,21 @@ +/* + Main App Entry + + Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at + http://mozilla.org/MPL/2.0/. + */ + +#import +#include + +int main(int argc, char *argv[]) +{ + freerdp_client_warn_deprecated(argc, argv); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/AddFuzzerTest.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/AddFuzzerTest.cmake new file mode 100644 index 0000000000000000000000000000000000000000..382d04dea444636d4cbc079e0d2cb57d85018552 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/AddFuzzerTest.cmake @@ -0,0 +1,15 @@ +macro(add_fuzzer_test FILES LINK_LIBS) + if(BUILD_FUZZERS) + string(REPLACE " " ";" LOCAL_LINK_LIBS ${LINK_LIBS}) + list(APPEND LOCAL_LINK_LIBS fuzzer_config) + foreach(test ${FILES}) + get_filename_component(TestName ${test} NAME_WE) + add_executable(${TestName} ${test}) + # Use PUBLIC to force 'fuzzer_config' for all dependent targets. + target_link_libraries(${TestName} PUBLIC ${LOCAL_LINK_LIBS}) + add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName}) + set_target_properties(${TestName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") + add_dependencies(fuzzers ${TestName}) + endforeach() + endif(BUILD_FUZZERS) +endmacro() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/AddTargetWithResourceFile.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/AddTargetWithResourceFile.cmake new file mode 100644 index 0000000000000000000000000000000000000000..91cdd0e616edc7c98e96a050c0ed4849f061bf71 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/AddTargetWithResourceFile.cmake @@ -0,0 +1,94 @@ +set(add_resource_macro_internal_dir ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") + +include(CleaningConfigureFile) + +macro(AddTargetWithResourceFile nameAndTarget is_exe version sources) + list(LENGTH ${nameAndTarget} target_length) + if(target_length GREATER 1) + list(GET ${nameAndTarget} 1 name) + list(GET ${nameAndTarget} 0 target) + else() + set(name ${nameAndTarget}) + set(target ${nameAndTarget}) + endif() + + set(VERSIONING OFF) + set(IS_EXE OFF) + if("${is_exe}" MATCHES "TRUE") + set(IS_EXE ON) + elseif("${is_exe}" MATCHES "WIN32") + set(IS_EXE ON) + set(exe_options "WIN32") + elseif("${is_exe}" MATCHES "SHARED") + set(lib_options "SHARED") + elseif("${is_exe}" MATCHES "STATIC") + set(lib_options "STATIC") + endif() + + if(IS_EXE AND WITH_BINARY_VERSIONING) + set(VERSIONING ON) + elseif(NOT IS_EXE AND WITH_LIBRARY_VERSIONING) + set(VERSIONING ON) + endif() + if(${ARGC} GREATER 4) + set(VERSIONING ${ARGV5}) + endif() + + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" RC_PROGRAM_VERSION_MATCH ${version}) + set(RC_VERSION_MAJOR ${CMAKE_MATCH_1}) + set(RC_VERSION_MINOR ${CMAKE_MATCH_2}) + set(RC_VERSION_BUILD ${CMAKE_MATCH_3}) + + if(WIN32) + if(IS_EXE) + if(VERSIONING) + set(RC_VERSION_FILE "${name}${RC_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}") + else() + set(RC_VERSION_FILE "${name}${CMAKE_EXECUTABLE_SUFFIX}") + endif() + else() + if(VERSIONING) + set(RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${name}${RC_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") + else() + set(RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + endif() + + cleaning_configure_file( + ${add_resource_macro_internal_dir}/WindowsDLLVersion.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY + ) + + list(APPEND ${sources} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) + endif() + + set(OUTPUT_FILENAME "${name}") + if(VERSIONING) + string(APPEND OUTPUT_FILENAME "${RC_VERSION_MAJOR}") + endif() + + if(IS_EXE) + message("add_executable(${target}) [${exe_options}]") + add_executable(${target} ${exe_options} ${${sources}}) + + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${OUTPUT_FILENAME}) + string(APPEND OUTPUT_FILENAME "${CMAKE_EXECUTABLE_SUFFIX}") + else() + message("add_library(${target}) [${lib_options}]") + add_library(${target} ${lib_options} ${${sources}}) + + if(VERSIONING) + set_target_properties(${target} PROPERTIES VERSION ${version} SOVERSION ${RC_VERSION_MAJOR}) + else() + set_target_properties(${target} PROPERTIES PREFIX "") + endif() + + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${OUTPUT_FILENAME}) + set(OUTPUT_FILENAME "${CMAKE_SHARED_LIBRARY_PREFIX}${OUTPUT_FILENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + + if(WITH_DEBUG_SYMBOLS AND MSVC AND (is_exe OR BUILD_SHARED_LIBS)) + message("add PDB for ${OUTPUT_FILENAME}") + set_target_properties(${target} PROPERTIES PDB_NAME ${OUTPUT_FILENAME}) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) + endif() +endmacro() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CFlagsToVar.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CFlagsToVar.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c6e9999e6776a7729afe075dd18bb081659a3893 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CFlagsToVar.cmake @@ -0,0 +1,12 @@ +function(CFlagsToVar NAME CFG) + string(TOUPPER "${CFG}" UCFG) + set(C_FLAGS ${CMAKE_C_FLAGS}) + string(REPLACE "${CMAKE_SOURCE_DIR}" "" C_FLAGS "${C_FLAGS}") + string(REPLACE "${CMAKE_BINARY_DIR}" "" C_FLAGS "${C_FLAGS}") + + string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${UCFG}}") + + string(REPLACE "\$" "\\\$" C_FLAGS "${C_FLAGS}") + string(REPLACE "\"" "\\\"" C_FLAGS "${C_FLAGS}") + set(${NAME} ${C_FLAGS} PARENT_SCOPE) +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CXXCompilerFlags.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CXXCompilerFlags.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cc71f1861c65f7c7736ff0e92799740e6adbb363 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CXXCompilerFlags.cmake @@ -0,0 +1,58 @@ +include(CheckCXXCompilerFlag) +include(CommonCompilerFlags) + +macro(checkCXXFlag FLAG) + check_cxx_compiler_flag("${FLAG}" CXXFLAG${FLAG}) + if(CXXFLAG${FLAG}) + string(APPEND CMAKE_CXX_FLAGS " ${FLAG}") + else() + message(WARNING "compiler does not support ${FLAG}") + endif() +endmacro() + +if(ENABLE_WARNING_VERBOSE) + if(MSVC) + # Remove previous warning definitions, + # NMake is otherwise complaining. + foreach(flags_var_to_scrub CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL + ) + string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") + endforeach() + else() + list( + APPEND + COMMON_COMPILER_FLAGS + -Wno-declaration-after-statement + -Wno-ctad-maybe-unsupported + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-pre-c++17-compat + -Wno-exit-time-destructors + -Wno-gnu-zero-variadic-macro-arguments + ) + endif() +endif() + +foreach(FLAG ${COMMON_COMPILER_FLAGS}) + checkcxxflag(${FLAG}) +endforeach() + +# https://stackoverflow.com/questions/4913922/possible-problems-with-nominmax-on-visual-c +if(WIN32) + add_compile_definitions($<$:NOMINMAX>) +endif() + +if(MSVC) + add_compile_options(/Gd) + + add_compile_options("$<$:/Zi>") + add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) +endif() + +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "default CXXFLAGS") +message("Using CXXFLAGS ${CMAKE_CXX_FLAGS}") +message("Using CXXFLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") +message("Using CXXFLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}") +message("Using CXXFLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}") +message("Using CXXFLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckAndSetFlag.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckAndSetFlag.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5cf000a02737cf803d4dac77584c7d53f26be3dc --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckAndSetFlag.cmake @@ -0,0 +1,28 @@ +include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) + +macro(CheckAndSetFlag FLAG) + if(FLAG) + get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + + unset(C_FLAG) + unset(CXX_FLAG) + if("C" IN_LIST languages) + check_c_compiler_flag("${FLAG}" C_FLAG) + if(C_FLAG) + string(APPEND CMAKE_C_FLAGS " ${FLAG}") + endif() + endif() + + if("CXX" IN_LIST languages) + check_cxx_compiler_flag("${FLAG}" CXX_FLAG) + if(CXX_FLAG) + string(APPEND CMAKE_CXX_FLAGS " ${FLAG}") + endif() + endif() + + if(NOT C_FLAG AND NOT CXX_FLAG) + message(WARNING "compiler does not support ${FLAG}") + endif() + endif() +endmacro() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckCmakeCompat.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckCmakeCompat.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1f5e69348b133cace28967e431181823229c0841 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CheckCmakeCompat.cmake @@ -0,0 +1,26 @@ +# Central location to check for cmake (version) requirements +# +#============================================================================= +# Copyright 2012 Bernhard Miklautz +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +macro(enable_cmake_compat CMVERSION) + if(${CMAKE_VERSION} VERSION_LESS ${CMVERSION}) + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/compat_${CMVERSION}/") + endif() +endmacro() + +# Compatibility includes - order does matter! +enable_cmake_compat(3.7.0) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangDetectTool.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangDetectTool.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3be4736989c51d2da16b73fd8a72f02a5a179976 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangDetectTool.cmake @@ -0,0 +1,42 @@ +function(clang_detect_tool VAR NAME OPTS) + set(NAMES "") + foreach(CNT RANGE 12 22) + list(APPEND NAMES "${NAME}-${CNT}") + endforeach() + list(REVERSE NAMES) + list(APPEND NAMES ${NAME}) + + find_program(${VAR} NAMES ${NAMES} ${OPTS}) + if(NOT ${VAR}) + message(WARNING "clang tool ${NAME} (${VAR}) not detected, skipping") + unset(${VAR}) + return() + endif() + + execute_process( + COMMAND ${${VAR}} "--version" OUTPUT_VARIABLE _CLANG_TOOL_VERSION RESULT_VARIABLE _CLANG_TOOL_VERSION_FAILED + ) + + if(_CLANG_TOOL_VERSION_FAILED) + message(WARNING "A problem was encountered with ${${VAR}}") + message(WARNING "${_CLANG_TOOL_VERSION_FAILED}") + unset(${VAR}) + return() + endif() + + string(REGEX MATCH "([7-9]|[1-9][0-9])\\.[0-9]\\.[0-9]" CLANG_TOOL_VERSION "${_CLANG_TOOL_VERSION}") + + if(NOT CLANG_TOOL_VERSION) + message(WARNING "problem parsing ${NAME} version for ${${VAR}}") + unset(${VAR}) + return() + endif() + + set(_CLANG_TOOL_MINIMUM_VERSION "12.0.0") + if(${CLANG_TOOL_VERSION} VERSION_LESS ${_CLANG_TOOL_MINIMUM_VERSION}) + message(WARNING "clang-format version ${CLANG_TOOL_VERSION} not supported") + message(WARNING "Minimum version required: ${_CLANG_TOOL_MINIMUM_VERSION}") + unset(${VAR}) + return() + endif() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangFormat.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangFormat.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0f56dafa7cf89763d87e97d86cecced6b336dd49 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangFormat.cmake @@ -0,0 +1,19 @@ +# get all project files +file( + GLOB_RECURSE + ALL_SOURCE_FILES + *.cpp + *.c + *.h + *.m + *.java +) + +include(ClangDetectTool) +clang_detect_tool(CLANG_FORMAT clang-format "") + +if(NOT CLANG_FORMAT) + message(WARNING "clang-format not found in path! code format target not available.") +else() + add_custom_target(clangformat COMMAND ${CLANG_FORMAT} -style=file -i ${ALL_SOURCE_FILES}) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangTidy.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangTidy.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d6b504d459f5278a88428605626771cf6a0cba67 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangTidy.cmake @@ -0,0 +1,16 @@ +option(BUILD_WITH_CLANG_TIDY "Build with clang-tidy for extra warnings" OFF) + +if(BUILD_WITH_CLANG_TIDY) + include(ClangDetectTool) + clang_detect_tool(CLANG_TIDY_EXE clang-tidy REQUIRED) + + set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}") + + set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_COMMAND}" --extra-arg=-std=gnu11) + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}" --extra-arg=-std=gnu++17) + set(CMAKE_OBJC_CLANG_TIDY "${CLANG_TIDY_COMMAND}") +else() + unset(CMAKE_C_CLANG_TIDY) + unset(CMAKE_CXX_CLANG_TIDY) + unset(CMAKE_OBJC_CLANG_TIDY) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangToolchain.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangToolchain.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1450e1973a98c032a538bfe27cad26a93468e648 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ClangToolchain.cmake @@ -0,0 +1,19 @@ +if($ENV{CLANG_VERSION}) + set(CLANG_VERSION "-$ENV{CLANG_VERSION}") +endif() + +set(CLANG_WARNINGS + "-pedantic -Weverything -Wno-padded -Wno-covered-switch-default -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-cast-align" +) + +set(CMAKE_C_COMPILER "/usr/bin/clang${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_C_FLAGS ${CLANG_WARNINGS} CACHE STRING "") + +set(CMAKE_CXX_COMPILER "/usr/bin/clang++${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_CXX_FLAGS ${CLANG_WARNINGS} CACHE STRING "") + +set(CMAKE_AR "/usr/bin/llvm-ar${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_LINKER "/usr/bin/llvm-link${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_NM "/usr/bin/llvm-nm${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump${CLANG_VERSION}" CACHE PATH "") +set(CMAKE_RANLIB "/usr/bin/llvm-ranlib${CLANG_VERSION}" CACHE PATH "") diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CleaningConfigureFile.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CleaningConfigureFile.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cf168c3d26b62394d17ab59e75d109a6d503bb33 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CleaningConfigureFile.cmake @@ -0,0 +1,70 @@ +# Little helper that adds the generated file to the +# files to be cleaned in the current directory. +# +# Handy if the generated files might have changed +# + +include(CFlagsToVar) + +function(cleaning_configure_file RSRC RDST) + get_filename_component(SRC "${RSRC}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + get_filename_component(DST "${RDST}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + get_filename_component(DST_DIR "${DST}" DIRECTORY) + get_filename_component(DST_NAME ${DST} NAME) + + # ensure the temporary configuration files are in a different directory + set(CFG_DIR "${CMAKE_CURRENT_BINARY_DIR}/cfg") + file(MAKE_DIRECTORY "${CFG_DIR}") + + # Generate the temporary configuration files + if(CMAKE_CONFIGURATION_TYPES) + foreach(CFG ${CMAKE_CONFIGURATION_TYPES}) + set(CURRENT_BUILD_CONFIG ${CFG}) + if(NOT SOURCE_CFG_INIT) + set(SOURCE_CFG_INIT "${CFG_DIR}/${DST_NAME}_${CFG}") + endif() + cflagstovar(CURRENT_C_FLAGS ${CURRENT_BUILD_CONFIG}) + configure_file(${SRC} "${CFG_DIR}/${DST_NAME}_${CFG}" ${ARGN}) + unset(CURRENT_BUILD_CONFIG) + unset(CURRENT_C_FLAGS) + endforeach() + set(SOURCE_CFG "${CFG_DIR}/${DST_NAME}_$") + else() + # We call this also from CMake scripts without a CMAKE_BUILD_TYPE + # Fall back to an explicitly unsupported build type to point out something is wrong + # if this variable is used during such a call + if(CMAKE_BUILD_TYPE) + set(CURRENT_BUILD_CONFIG ${CMAKE_BUILD_TYPE}) + else() + set(CURRENT_BUILD_CONFIG "InvalidBuildType") + endif() + cflagstovar(CURRENT_C_FLAGS ${CURRENT_BUILD_CONFIG}) + set(SOURCE_CFG "${CFG_DIR}/${DST_NAME}_${CMAKE_BUILD_TYPE}") + set(SOURCE_CFG_INIT "${SOURCE_CFG}") + configure_file(${SRC} "${SOURCE_CFG}" ${ARGN}) + unset(CURRENT_BUILD_CONFIG) + unset(CURRENT_C_FLAGS) + endif() + + # Fallback for older CMake: we want to copy only if the destination is different. + # First do an initial copy during configuration + file(MAKE_DIRECTORY "${DST_DIR}") + if(CMAKE_VERSION VERSION_LESS "3.21.0") + get_filename_component(CFG_VAR ${SOURCE_CFG_INIT} NAME) + file(COPY ${SOURCE_CFG_INIT} DESTINATION ${DST_DIR}) + set(CFG_VAR_ABS "${DST_DIR}/${CFG_VAR}") + file(RENAME ${CFG_VAR_ABS} ${DST}) + else() + file(COPY_FILE ${SOURCE_CFG_INIT} ${DST} ONLY_IF_DIFFERENT) + endif() + + # Create a target to recreate the configuration file if something changes. + string(SHA256 DST_HASH "${DST}") + string(SUBSTRING "${DST_HASH}" 0 8 DST_HASH) + if(NOT TARGET ct-${DST_HASH}) + add_custom_target( + ct-${DST_HASH} COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${DST_DIR}" + COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${SOURCE_CFG}" "${DST}" DEPENDS ${SOURCE_CFG} ${DST} + ) + endif() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonCompilerFlags.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonCompilerFlags.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d755cf37b52c71eb049041f732f6325bfc41df0a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonCompilerFlags.cmake @@ -0,0 +1,46 @@ +include(CheckAndSetFlag) + +option(ENABLE_WARNING_VERBOSE "enable -Weveryting (and some exceptions) for compile" OFF) +option(ENABLE_WARNING_ERROR "enable -Werror for compile" OFF) + +set(COMMON_COMPILER_FLAGS "") +if(ENABLE_WARNING_VERBOSE) + if(MSVC) + list(APPEND COMMON_COMPILER_FLAGS /W4 /wo4324) + else() + list( + APPEND + COMMON_COMPILER_FLAGS + -Weverything + -Wall + -Wpedantic + -Wno-padded + -Wno-switch-enum + -Wno-cast-align + -Wno-unsafe-buffer-usage + -Wno-reserved-identifier + -Wno-covered-switch-default + -Wno-disabled-macro-expansion + ) + endif() +endif() + +if(ENABLE_WARNING_ERROR) + list(APPEND COMMON_COMPILER_FLAGS -Werror) +endif() + +list(APPEND COMMON_COMPILER_FLAGS -fno-omit-frame-pointer -Wredundant-decls) + +include(ExportAllSymbols) +include(CompilerSanitizerOptions) + +if(CMAKE_C_COMPILER_ID MATCHES ".*Clang.*" OR (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION + VERSION_GREATER_EQUAL 10) +) + add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>) + add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>) + add_compile_options($<$>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>) + add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>) + add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>) + add_compile_options($<$>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonConfigOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonConfigOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..31a2ef3a6ec34902089870e8abf6d5109b06ee98 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CommonConfigOptions.cmake @@ -0,0 +1,64 @@ +option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON) +option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON) +option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON) +option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON) +option(WITH_BINARY_VERSIONING "Use binary versioning" OFF) +option(WITH_RESOURCE_VERSIONING "Use resource versioning" OFF) +option(BUILD_SHARED_LIBS "Build shared libraries" ON) + +# We want to control the winpr assert for the whole project +option(WITH_VERBOSE_WINPR_ASSERT "Compile with verbose WINPR_ASSERT." ON) +if(WITH_VERBOSE_WINPR_ASSERT) + add_compile_definitions(WITH_VERBOSE_WINPR_ASSERT) +endif() + +# known issue on android, thus disabled until we support newer CMake +# https://github.com/android/ndk/issues/1444 +if(NOT ANDROID) + if(POLICY CMP0069) + cmake_policy(SET CMP0069 NEW) + endif() + if(POLICY CMP0138) + cmake_policy(SET CMP0138 NEW) + endif() + include(CheckIPOSupported) + check_ipo_supported(RESULT supported OUTPUT error) + if(NOT supported) + message(WARNING "LTO not supported, got ${error}") + endif() + + option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "build with link time optimization" ${supported}) +endif() + +set(SUPPORTED_BUILD_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + +# Default to release build type +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + # Set a default build type if none was specified + set(default_build_type "Release") + + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${SUPPORTED_BUILD_TYPES}) +endif() + +if(CMAKE_BUILD_TYPE) + if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST SUPPORTED_BUILD_TYPES) + message(FATAL_ERROR "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not supported. Set to any of ${SUPPORTED_BUILD_TYPES}") + endif() +endif() + +if(CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo" CACHE INTERNAL "freerdp default") +endif() + +include(PlatformDefaults) +include(PreventInSourceBuilds) +include(GNUInstallDirsWrapper) +include(MSVCRuntime) +include(ConfigureRPATH) +include(ClangTidy) +include(AddTargetWithResourceFile) +include(DisableCompilerWarnings) +include(CleaningConfigureFile) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerDetect.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerDetect.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2f86539a45db3d58e7eabf743d3a54c1b2c26b61 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerDetect.cmake @@ -0,0 +1,3 @@ +if(CMAKE_C_COMPILER_ID MATCHES ".*Clang.*" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*") + set(CMAKE_COMPILER_IS_CLANG 1) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerFlags.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerFlags.cmake new file mode 100644 index 0000000000000000000000000000000000000000..af814c2fd9843aa4d92c5627ca8e3c2ffa6681c1 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerFlags.cmake @@ -0,0 +1,49 @@ +include(CheckCCompilerFlag) +include(CommonCompilerFlags) + +macro(checkCFlag FLAG) + check_c_compiler_flag("${FLAG}" CFLAG${FLAG}) + if(CFLAG${FLAG}) + string(APPEND CMAKE_C_FLAGS " ${FLAG}") + else() + message(WARNING "compiler does not support ${FLAG}") + endif() +endmacro() + +if(ENABLE_WARNING_VERBOSE) + if(MSVC) + # Remove previous warning definitions, + # NMake is otherwise complaining. + foreach(flags_var_to_scrub CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_MINSIZEREL + ) + string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") + endforeach() + else() + list(APPEND COMMON_COMPILER_FLAGS -Wno-declaration-after-statement -Wno-pre-c11-compat + -Wno-gnu-zero-variadic-macro-arguments + ) + endif() +endif() + +list(APPEND COMMON_COMPILER_FLAGS -Wimplicit-function-declaration) + +foreach(FLAG ${COMMON_COMPILER_FLAGS}) + checkcflag(${FLAG}) +endforeach() + +# Android profiling +if(ANDROID) + if(WITH_GPROF) + checkandsetflag(-pg) + set(PROFILER_LIBRARIES "${FREERDP_EXTERNAL_PROFILER_PATH}/obj/local/${ANDROID_ABI}/libandroid-ndk-profiler.a") + include_directories(SYSTEM "${FREERDP_EXTERNAL_PROFILER_PATH}") + endif() +endif() + +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "default CFLAGS") +message("Using CFLAGS ${CMAKE_C_FLAGS}") +message("Using CFLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}") +message("Using CFLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}") +message("Using CFLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}") +message("Using CFLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}") diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerSanitizerOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerSanitizerOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b128cd8b7ff69b67010e6102aae93f58623849a8 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/CompilerSanitizerOptions.cmake @@ -0,0 +1,48 @@ +include(CMakeDependentOption) + +cmake_dependent_option( + WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF + "NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF +) +cmake_dependent_option( + WITH_SANITIZE_ADDRESS "Compile with gcc/clang address sanitizer." OFF + "NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF +) +cmake_dependent_option( + WITH_SANITIZE_MEMORY "Compile with gcc/clang memory sanitizer." OFF + "NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_THREAD" OFF +) +cmake_dependent_option( + WITH_SANITIZE_THREAD "Compile with gcc/clang thread sanitizer." OFF + "NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY" OFF +) + +if(WITH_VALGRIND_MEMCHECK) + check_include_files(valgrind/memcheck.h FREERDP_HAVE_VALGRIND_MEMCHECK_H) +else() + unset(FREERDP_HAVE_VALGRIND_MEMCHECK_H CACHE) +endif() + +# Enable address sanitizer, where supported and when required +if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_REQUIRED_LINK_OPTIONS_SAVED ${CMAKE_REQUIRED_LINK_OPTIONS}) + file(WRITE ${PROJECT_BINARY_DIR}/foo.txt "") + if(WITH_SANITIZE_ADDRESS) + add_compile_options(-fsanitize=address) + add_compile_options(-fsanitize-address-use-after-scope) + add_link_options(-fsanitize=address) + elseif(WITH_SANITIZE_MEMORY) + add_compile_options(-fsanitize=memory) + add_compile_options(-fsanitize-memory-use-after-dtor) + add_compile_options(-fsanitize-memory-track-origins) + add_link_options(-fsanitize=memory) + elseif(WITH_SANITIZE_THREAD) + add_compile_options(-fsanitize=thread) + add_link_options(-fsanitize=thread) + endif() + + option(WITH_NO_UNDEFINED "Add -Wl,--no-undefined" OFF) + if(WITH_NO_UNDEFINED) + add_link_options(-Wl,--no-undefined) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptions.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1feb6c81151c5bfe5e978e9ca97448691a278fdd --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptions.cmake @@ -0,0 +1,244 @@ +include(CMakeDependentOption) + +if((CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|x86|AMD64") AND (CMAKE_SIZEOF_VOID_P EQUAL 4)) + set(TARGET_ARCH "x86") +elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") AND (CMAKE_SIZEOF_VOID_P EQUAL 8)) + set(TARGET_ARCH "x64") +elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (CMAKE_SIZEOF_VOID_P EQUAL 8) AND (APPLE)) + # Mac is weird like that. + set(TARGET_ARCH "x64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm*") + set(TARGET_ARCH "ARM") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") + set(TARGET_ARCH "sparc") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "e2k") + set(TARGET_ARCH "e2k") +endif() + +if(NOT OPENBSD AND NOT WIN32) + set(MANPAGE_DEF ON) +endif() +option(WITH_MANPAGES "Generate manpages." ${MANPAGE_DEF}) +option(WITH_PROFILER "Compile profiler." OFF) +option(WITH_GPROF "Compile with GProf profiler." OFF) + +option(WITH_JPEG "Use JPEG decoding." OFF) + +include(CompilerDetect) + +if(WIN32) + if(NOT UWP) + option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." OFF) + endif() +endif() + +if(WIN32 AND NOT UWP) + option(WITH_WINMM "Use Windows Multimedia" ON) + option(WITH_WIN8 "Use Windows 8 libraries" OFF) +endif() + +option(BUILD_BENCHMARK "Build benchmark tools (for debugging and development only)" OFF) +option(BUILD_TESTING "Build unit tests (compatible with packaging)" OFF) +cmake_dependent_option( + BUILD_TESTING_INTERNAL "Build unit tests (CI only, not for packaging!)" OFF "NOT BUILD_TESTING" OFF +) +cmake_dependent_option( + BUILD_TESTING_NO_H264 "Skip building h264 unit tests (no implementation during packaging)" OFF + "BUILD_TESTING OR BUILD_TESTING_INTERNAL" OFF +) +cmake_dependent_option(TESTS_WTSAPI_EXTRA "Build extra WTSAPI tests (interactive)" OFF "BUILD_TESTING_INTERNAL" OFF) +cmake_dependent_option(BUILD_COMM_TESTS "Build comm related tests (require comm port)" OFF "BUILD_TESTING_INTERNAL" OFF) + +option(WITH_SAMPLE "Build sample code" ON) + +option(WITH_CLIENT_COMMON "Build client common library" ON) +cmake_dependent_option(WITH_CLIENT "Build client binaries" ON "WITH_CLIENT_COMMON" OFF) +cmake_dependent_option(WITH_CLIENT_SDL "[experimental] Build SDL client " ON "WITH_CLIENT" OFF) + +option(WITH_SERVER "Build server binaries" ON) + +option(WITH_CHANNELS "Build virtual channel plugins" ON) + +option(FREERDP_UNIFIED_BUILD "Build WinPR, uwac, RdTk and FreeRDP in one go" ON) + +cmake_dependent_option(WITH_CLIENT_CHANNELS "Build virtual channel plugins" ON "WITH_CLIENT_COMMON;WITH_CHANNELS" OFF) + +cmake_dependent_option(WITH_MACAUDIO "Enable OSX sound backend" ON "APPLE;NOT IOS" OFF) + +if(WITH_SERVER AND WITH_CHANNELS) + option(WITH_SERVER_CHANNELS "Build virtual channel plugins" ON) +endif() + +option(WITH_THIRD_PARTY "Build third-party components" OFF) + +option(WITH_CLIENT_INTERFACE "Build clients as a library with an interface" OFF) +cmake_dependent_option( + CLIENT_INTERFACE_SHARED "Build clients as a shared library with an interface" OFF "WITH_CLIENT_INTERFACE" OFF +) +option(WITH_SERVER_INTERFACE "Build servers as a library with an interface" ON) + +option(WITH_DEBUG_ALL "Print all debug messages." OFF) + +if(WITH_DEBUG_ALL) + message( + WARNING + "WITH_DEBUG_ALL=ON, the build will be slow and might leak sensitive information, do not use with release builds!" + ) + set(DEFAULT_DEBUG_OPTION ON CACHE INTERNAL "debug default") +else() + set(DEFAULT_DEBUG_OPTION OFF CACHE INTERNAL "debug default") +endif() + +option(WITH_DEBUG_CERTIFICATE "Print certificate related debug messages." ${DEFAULT_DEBUG_OPTION}) +if(WITH_DEBUG_CERTIFICATE) + message( + WARNING "WITH_DEBUG_CERTIFICATE=ON, the build might leak sensitive information, do not use with release builds!" + ) +endif() +option(WITH_DEBUG_CAPABILITIES "Print capability negotiation debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_CHANNELS "Print channel manager debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_CLIPRDR "Print clipboard redirection debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_CODECS "Print codec debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RDPGFX "Print RDPGFX debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_DVC "Print dynamic virtual channel debug messages." ${DEFAULT_DEBUG_OPTION}) +cmake_dependent_option( + WITH_DEBUG_TSMF "Print TSMF virtual channel debug messages." ${DEFAULT_DEBUG_OPTION} "CHANNEL_TSMF" OFF +) +option(WITH_DEBUG_KBD "Print keyboard related debug messages." ${DEFAULT_DEBUG_OPTION}) +if(WITH_DEBUG_KBD) + message(WARNING "WITH_DEBUG_KBD=ON, the build might leak sensitive information, do not use with release builds!") +endif() +option(WITH_DEBUG_LICENSE "Print license debug messages." ${DEFAULT_DEBUG_OPTION}) +if(WITH_DEBUG_LICENSE) + message(WARNING "WITH_DEBUG_LICENSE=ON, the build might leak sensitive information, do not use with release builds!") +endif() +option(WITH_DEBUG_NEGO "Print negotiation related debug messages." ${DEFAULT_DEBUG_OPTION}) +if(WITH_DEBUG_NEGO) + message(WARNING "WITH_DEBUG_NEGO=ON, the build might leak sensitive information, do not use with release builds!") +endif() +option(WITH_DEBUG_NLA "Print authentication related debug messages." ${DEFAULT_DEBUG_OPTION}) +if(WITH_DEBUG_NLA) + message(WARNING "WITH_DEBUG_NLA=ON, the build might leak sensitive information, do not use with release builds!") +endif() +option(WITH_DEBUG_TSG "Print Terminal Server Gateway debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RDP "Print RDP debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RDPEI "Print input virtual channel debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_REDIR "Redirection debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RDPDR "Rdpdr debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RFX "Print RemoteFX debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_SCARD "Print smartcard debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_SND "Print rdpsnd debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_SVC "Print static virtual channel debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_TRANSPORT "Print transport debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_TIMEZONE "Print timezone debug messages." ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_WND "Print window order debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_X11_LOCAL_MOVESIZE "Print X11 Client local movesize debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_X11 "Print X11 Client debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_XV "Print XVideo debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RINGBUFFER "Enable Ringbuffer debug messages" ${DEFAULT_DEBUG_OPTION}) + +option(WITH_DEBUG_SYMBOLS "Pack debug symbols to installer" OFF) +option(WITH_CCACHE "Use ccache support if available" ON) +option(WITH_CLANG_FORMAT "Detect clang-format. run 'cmake --build . --target clangformat' to format." ON) + +option(WITH_DSP_EXPERIMENTAL "Enable experimental sound encoder/decoder formats" OFF) + +option(WITH_FFMPEG "Enable FFMPEG for audio/video encoding/decoding" ON) +cmake_dependent_option(WITH_DSP_FFMPEG "Use FFMPEG for audio encoding/decoding" ON "WITH_FFMPEG" OFF) +cmake_dependent_option(WITH_VIDEO_FFMPEG "Use FFMPEG for video encoding/decoding" ON "WITH_FFMPEG" OFF) +cmake_dependent_option(WITH_VAAPI "Use FFMPEG VAAPI" OFF "WITH_VIDEO_FFMPEG" OFF) +cmake_dependent_option(WITH_VAAPI_H264_ENCODING "Use FFMPEG VAAPI hardware H264 encoding" ON "WITH_VIDEO_FFMPEG" OFF) +if(WITH_VAAPI_H264_ENCODING) + add_definitions("-DWITH_VAAPI_H264_ENCODING") +endif() + +option(USE_VERSION_FROM_GIT_TAG "Extract FreeRDP version from git tag." ON) + +option(WITH_CAIRO "Use CAIRO image library for screen resizing" OFF) +option(WITH_SWSCALE "Use SWScale image library for screen resizing" ON) + +if(ANDROID) + include(ConfigOptionsAndroid) +endif(ANDROID) + +if(IOS) + include(ConfigOptionsiOS) +endif(IOS) + +if(UNIX AND NOT APPLE) + find_package(ALSA) + find_package(PulseAudio) + find_package(OSS) + option(WITH_ALSA "use alsa for sound" ${ALSA_FOUND}) + option(WITH_PULSE "use alsa for sound" ${PULSE_FOUND}) + option(WITH_OSS "use alsa for sound" ${OSS_FOUND}) +endif() + +if(OPENBSD) + find_package(SNDIO) + option(WITH_SNDIO "use SNDIO for sound" ${SNDIO_FOUND # OpenBSD + endif () } + ) +endif() + +option(BUILD_FUZZERS "Use BUILD_FUZZERS to build fuzzing tests" OFF) + +if(BUILD_FUZZERS) + if(NOT OSS_FUZZ) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer-no-link") + endif() + + if(OSS_FUZZ AND NOT DEFINED ENV{LIB_FUZZING_ENGINE}) + message(SEND_ERROR "OSS-Fuzz builds require the environment variable " + "LIB_FUZZING_ENGINE to be set. If you are seeing this " + "warning, it points to a deeper problem in the ossfuzz " "build setup." + ) + endif() + + if(CMAKE_COMPILER_IS_GNUCC) + message(FATAL_ERROR "\n" "Fuzzing is unsupported with GCC compiler. Use Clang:\n" + " $ CC=clang CXX=clang++ cmake . <...> -DBUILD_FUZZERS=ON && make -j\n" "\n" + ) + endif() + + set(BUILD_TESTING_INTERNAL ON CACHE BOOL "fuzzer default" FORCE) + + if(BUILD_SHARED_LIBS STREQUAL "OFF") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}") + endif() + + # A special target with fuzzer and sanitizer flags. + add_library(fuzzer_config INTERFACE) + + target_compile_options( + fuzzer_config + INTERFACE $<$>: + -fsanitize=fuzzer + > + $<$: + ${CXX} + ${CXXFLAGS} + > + ) + target_link_libraries( + fuzzer_config INTERFACE $<$>: -fsanitize=fuzzer > $<$: + $ENV{LIB_FUZZING_ENGINE} > + ) +endif() + +option( + WITH_FULL_CONFIG_PATH + "Use /Vendor/Product instead of /product (lowercase, only if vendor equals product) as config directory" + OFF +) + +# Configuration settings for manpages +if(NOT WITH_FULL_CONFIG_PATH AND "${VENDOR}" STREQUAL "${PRODUCT}") + string(TOLOWER "${VENDOR}" VENDOR_PRODUCT) +else() + set(VENDOR_PRODUCT "${VENDOR}/${PRODUCT}") +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsAndroid.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsAndroid.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ea0a3ddea526e7f4456f22681174865ab1ceaa7d --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsAndroid.cmake @@ -0,0 +1,22 @@ +# FreeRDP cmake android options +# +# Copyright 2013 Thincast Technologies GmbH +# Copyright 2013 Bernhard Miklautz +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +option(WITH_OPENSLES "Enable sound and microphone redirection using OpenSLES" ON) + +set(ANDROID_APP_TARGET_SDK 21 CACHE STRING "Application target android SDK") +set(ANDROID_APP_MIN_SDK 14 CACHE STRING "Application minimum android SDK requirement") +option(WITH_MEDIACODEC "[experimental] Use MediaCodec API (currently no fallback if no device support)" OFF) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsiOS.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsiOS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a167a10bc6df97dca0c706f95180aa0d3211c188 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigOptionsiOS.cmake @@ -0,0 +1,25 @@ +# FreeRDP cmake ios options +# +# Copyright 2013 Thincast Technologies GmbH +# Copyright 2013 Martin Fleisz +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if(NOT FREERDP_IOS_EXTERNAL_SSL_PATH) + set(FREERDP_IOS_EXTERNAL_SSL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/openssl") +endif() +mark_as_advanced(FREERDP_IOS_EXTERNAL_SSL_PATH) + +if(NOT DEFINED IOS_TARGET_SDK) + set(IOS_TARGET_SDK 12.0 CACHE STRING "Application target iOS SDK") +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureFreeRDP.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureFreeRDP.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7b8ef8285dfe018dc81c277954e080d6dff3ed84 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureFreeRDP.cmake @@ -0,0 +1,10 @@ +if(NOT FREERDP_UNIFIED_BUILD) + find_package(WinPR 3 REQUIRED) + include_directories(SYSTEM ${WinPR_INCLUDE_DIR}) + + find_package(FreeRDP 3 REQUIRED) + include_directories(SYSTEM ${FreeRDP_INCLUDE_DIR}) + + find_package(FreeRDP-Client 3 REQUIRED) + include_directories(SYSTEM ${FreeRDP-Client_INCLUDE_DIR}) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureRPATH.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureRPATH.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0082d13deb3318adcc4e1b65db70353b2f309b8a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConfigureRPATH.cmake @@ -0,0 +1,27 @@ +# RPATH configuration +option(CMAKE_SKIP_BUILD_RPATH "skip build RPATH" OFF) +option(CMAKE_BUILD_WITH_INSTALL_RPATH "build with install RPATH" OFF) +option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "build with link RPATH" OFF) + +if(APPLE) + if(BUILD_SHARED_LIBS) + option(CMAKE_MACOSX_RPATH "MacOSX RPATH" ON) + endif() + + file(RELATIVE_PATH FRAMEWORK_PATH ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_LIBDIR}) + set(CFG_INSTALL_RPATH "@loader_path/${FRAMEWORK_PATH}") +elseif(NOT WIN32) + if(NOT FREEBSD) + option(WITH_ADD_PLUGIN_TO_RPATH "Add extension and plugin path to RPATH" OFF) + if(WITH_ADD_PLUGIN_TO_RPATH) + set(CFG_INSTALL_RPATH + "\$ORIGIN/../${FREERDP_EXTENSION_REL_PATH}:\$ORIGIN/../${FREERDP_PLUGIN_PATH}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/.." + ) + else() + set(CFG_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..") + endif() + endif() +endif(APPLE) + +set(CMAKE_INSTALL_RPATH ${CFG_INSTALL_RPATH} CACHE INTERNAL "ConfigureRPATH") +message("Configured RPATH=${CMAKE_INSTALL_RPATH}") diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ConvertFileToHexArray.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConvertFileToHexArray.cmake new file mode 100644 index 0000000000000000000000000000000000000000..48c47f11317a2927ee966dfc6b2da8c0b1d83076 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ConvertFileToHexArray.cmake @@ -0,0 +1,16 @@ +function(file_to_hex_array FILE DATA) + # Read the ASCII file as hex. + file(READ "${FILE}" HEX_CONTENTS HEX) + + # Separate into individual bytes. + string(REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" SEPARATED_HEX "${HEX_CONTENTS}") + + # Append the "0x" to each byte. + list(JOIN SEPARATED_HEX ", 0x" FORMATTED_HEX) + + # JOIN misses the first byte's "0x", so add it here. + string(PREPEND FORMATTED_HEX "0x") + + # Set the variable named by DATA argument to the formatted hex string. + set(${DATA} ${FORMATTED_HEX} PARENT_SCOPE) +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/DetectIntrinsicSupport.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/DetectIntrinsicSupport.cmake new file mode 100644 index 0000000000000000000000000000000000000000..80d8c9f51e4e83c817b84fdd5b3f96f6d1c57604 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/DetectIntrinsicSupport.cmake @@ -0,0 +1,106 @@ +option(WITH_SIMD "Enable best platform specific vector instruction support" ON) +cmake_dependent_option(WITH_AVX2 "Compile AVX2 optimizations." ON "WITH_SIMD" OFF) + +if(WITH_SSE2) + message(WARNING "WITH_SSE2 is deprecated, use WITH_SIMD instead") + set(WITH_SIMD ON CACHE BOOL "WITH_SSE2") +endif() +if(WITH_NEON) + message(WARNING "WITH_NEON is deprecated, use WITH_SIMD instead") + set(WITH_SIMD ON CACHE BOOL "WITH_NEON") +endif() + +macro(set_simd_source_file_properties INTRINSIC_TYPE) + if(ARGC LESS_EQUAL 1) + message(FATAL_ERROR "set_simd_source_file_properties called with invalid arguments: [${ARGC}] {${ARGN}") + endif() + + # see https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html + set(GCC_CLANG_NAMES "AppleClang;Clang;CrayClang;FujitsuClang;GNU;IntelLLVM;TIClang;XLClang;IBMClang") + + set(SSE_X86_LIST "i686;x86") + set(SSE_LIST "x86_64;ia64;x64;amd64;ia64;em64t;${SSE_X86_LIST}") + set(NEON_LIST "arm;armv7;armv8b;armv8l") + set(SUPPORTED_INTRINSICS_LIST "neon;sse2;sse3;ssse3;sse4.1;sse4.2;avx2") + + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR) + + if(NOT "${INTRINSIC_TYPE}" IN_LIST SUPPORTED_INTRINSICS_LIST) + message(WARNING "Intrinsic type ${INTRINSIC_TYPE} not supported, only ${SUPPORTED_INTRINSICS_LIST} are available") + else() + set(SIMD_LINK_ARG "") + if(MSVC) + # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-140 + if("${SYSTEM_PROCESSOR}" IN_LIST SSE_LIST) + if("${SYSTEM_PROCESSOR}" IN_LIST SSE_X86_LIST) + # /arch:SSE2 is the default, so do nothing + set(SIMD_LINK_ARG "ignore") + if("${INTRINSIC_TYPE}" STREQUAL "avx2") + set(SIMD_LINK_ARG "/arch:AVX2") + endif() + else() + # /arch:SSE2 is the default, so do nothing + set(SIMD_LINK_ARG "ignore") + if("${INTRINSIC_TYPE}" STREQUAL "sse4.2") + set(SIMD_LINK_ARG "/arch:SSE4.2") + elseif("${INTRINSIC_TYPE}" STREQUAL "avx2") + set(SIMD_LINK_ARG "/arch:AVX2") + endif() + endif() + endif() + elseif("${CMAKE_C_COMPILER_ID}" IN_LIST GCC_CLANG_NAMES) + set(HAVE_SSE_AVX OFF) + foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) + if("${ARCH}" IN_LIST SSE_LIST) + set(HAVE_SSE_AVX ON) + endif() + endforeach() + if("${SYSTEM_PROCESSOR}" IN_LIST SSE_LIST OR HAVE_SSE_AVX) + if("${INTRINSIC_TYPE}" STREQUAL "sse2") + set(SIMD_LINK_ARG "-msse2") + elseif("${INTRINSIC_TYPE}" STREQUAL "sse3") + set(SIMD_LINK_ARG "-msse3") + elseif("${INTRINSIC_TYPE}" STREQUAL "ssse3") + set(SIMD_LINK_ARG "-mssse3") + elseif("${INTRINSIC_TYPE}" STREQUAL "sse4.1") + set(SIMD_LINK_ARG "-msse4.1") + elseif("${INTRINSIC_TYPE}" STREQUAL "sse4.2") + set(SIMD_LINK_ARG "-msse4.2") + elseif("${INTRINSIC_TYPE}" STREQUAL "avx2") + set(SIMD_LINK_ARG "-mavx2") + endif() + endif() + else() + message(WARNING "[SIMD] Unsupported compiler ${CMAKE_C_COMPILER_ID}, ignoring") + endif() + + if("${INTRINSIC_TYPE}" STREQUAL "neon") + set(HAVE_NEON OFF) + foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) + if("${ARCH}" IN_LIST NEON_LIST) + set(HAVE_NEON ON) + endif() + endforeach() + if("${SYSTEM_PROCESSOR}" IN_LIST NEON_LIST OR HAVE_NEON) + if(MSVC) + set(SIMD_LINK_ARG "/arch:VFPv4") + elseif("${CMAKE_C_COMPILER_ID}" IN_LIST GCC_CLANG_NAMES) + set(SIMD_LINK_ARG "-mfpu=neon") + else() + message(WARNING "[SIMD] Unsupported compiler ${CMAKE_C_COMPILER_ID}, ignoring") + endif() + endif() + endif() + + if(SIMD_LINK_ARG STREQUAL "") + message(NOTICE "INTRINSIC_TYPE=${INTRINSIC_TYPE}: not supported on target platform, ignoring") + elseif(SIMD_LINK_ARG STREQUAL "ignore") + message(NOTICE "INTRINSIC_TYPE=${INTRINSIC_TYPE}: does not require linker flags, enabled by default") + else() + message("[SIMD] linking ${INTRINSIC_TYPE} [${SIMD_LINK_ARG}]: ${ARGN}") + foreach(src ${ARGN}) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS "${SIMD_LINK_ARG}") + endforeach() + endif() + endif() +endmacro() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/DisableCompilerWarnings.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/DisableCompilerWarnings.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d08b721f861b774be21540b619646a39aced6ede --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/DisableCompilerWarnings.cmake @@ -0,0 +1,18 @@ +if(MSVC) + set(COMPILE_WARN_OPTS "/W0") +else() + set(COMPILE_WARN_OPTS "-w") +endif() +set(COMPILE_WARN_OPTS "${COMPILE_WARN_OPTS}" CACHE STRING "cached value") + +function(disable_warnings_for_directory dir) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0") + set_property(DIRECTORY "${dir}" PROPERTY COMPILE_OPTIONS ${COMPILE_WARN_OPTS}) + endif() + + file(MAKE_DIRECTORY "${dir}") + set(ctidy "${dir}/.clang-tidy") + file(WRITE ${ctidy} "Checks: '-*,misc-definitions-in-headers'\n") + file(APPEND ${ctidy} "CheckOptions:\n") + file(APPEND ${ctidy} "\t- { key: HeaderFileExtensions, value: \"x\" }\n") +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/Doxygen.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/Doxygen.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0e1888ef32af0ea3f30e5100238ffb0770a9e54b --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/Doxygen.cmake @@ -0,0 +1,21 @@ +option(WITH_DOCUMENTATION "Add target to build doxygen documentation" OFF) + +if(WITH_DOCUMENTATION) + if(CMAKE_VERSION VERSION_LESS "3.27") + message(WARNING "Building with CMake ${CMAKE_VERSION} but >= 3.27 required for doxygen target") + else() + include(FindDoxygen) + find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS mscgen dia) + + set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) + set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION}) + set(DOXYGEN_EXCLUDE_PATTERNS "*/uwac/protocols/*") + set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/docs") + + doxygen_add_docs( + docs "${CMAKE_SOURCE_DIR}" ALL COMMENT "Generate doxygen docs" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/docs" CONFIG_FILE "${CMAKE_SOURCE_DIR}/docs/Doxyfile" + ) + install(DIRECTORY "${CMAKE_SOURCE_DIR}/docs/api" DESTINATION ${CMAKE_INSTALL_DOCDIR}) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/DumpVariables.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/DumpVariables.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6d5e121209f34add6c7c4d669cc510edda2cb308 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/DumpVariables.cmake @@ -0,0 +1,9 @@ +function(dump_cmake_variables) + get_cmake_property(_variableNames VARIABLES) + list(SORT _variableNames) + foreach(_variableName ${_variableNames}) + if((NOT DEFINED ARGV0) OR _variableName MATCHES ${ARGV0}) + message(STATUS "${_variableName}=${${_variableName}}") + endif() + endforeach() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/EchoTarget.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/EchoTarget.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1daa877f2921b7df889ee7fc596a8e26ed0c0e97 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/EchoTarget.cmake @@ -0,0 +1,177 @@ +function(echo_target_property tgt prop) + # v for value, d for defined, s for set + get_property(v TARGET ${tgt} PROPERTY ${prop}) + get_property(d TARGET ${tgt} PROPERTY ${prop} DEFINED) + get_property(s TARGET ${tgt} PROPERTY ${prop} SET) + + # only produce output for values that are set + if(s) + message("tgt='${tgt}' prop='${prop}'") + message(" value='${v}'") + message(" defined='${d}'") + message(" set='${s}'") + message("") + endif() +endfunction() + +function(echo_target tgt) + if(NOT TARGET ${tgt}) + message("There is no target named '${tgt}'") + return() + endif() + + set(props + DEBUG_OUTPUT_NAME + RELEASE_OUTPUT_NAME + DEBUG_POSTFIX + RELEASE_POSTFIX + ARCHIVE_OUTPUT_DIRECTORY + ARCHIVE_OUTPUT_DIRECTORY_DEBUG + ARCHIVE_OUTPUT_DIRECTORY_RELEASE + ARCHIVE_OUTPUT_NAME + ARCHIVE_OUTPUT_NAME_DEBUG + ARCHIVE_OUTPUT_NAME_RELEASE + AUTOMOC + AUTOMOC_MOC_OPTIONS + BUILD_WITH_INSTALL_RPATH + BUNDLE + BUNDLE_EXTENSION + COMPILE_DEFINITIONS + COMPILE_DEFINITIONS_DEBUG + COMPILE_DEFINITIONS_RELEASE + COMPILE_FLAGS + DEBUG_POSTFIX + DEFINE_SYMBOL + ENABLE_EXPORTS + EXCLUDE_FROM_ALL + EchoString + FOLDER + FRAMEWORK + Fortran_FORMAT + Fortran_MODULE_DIRECTORY + GENERATOR_FILE_NAME + GNUtoMS + HAS_CXX + IMPLICIT_DEPENDS_INCLUDE_TRANSFORM + IMPORTED + IMPORTED_CONFIGURATIONS + IMPORTED_IMPLIB + IMPORTED_IMPLIB_RELEASE + IMPORTED_IMPLIB_RELEASE + IMPORTED_LINK_DEPENDENT_LIBRARIES + IMPORTED_LINK_DEPENDENT_LIBRARIES_DEBUG + IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE + IMPORTED_LINK_INTERFACE_LANGUAGES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE + IMPORTED_LINK_INTERFACE_LIBRARIES + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE + IMPORTED_LINK_INTERFACE_MULTIPLICITY + IMPORTED_LINK_INTERFACE_MULTIPLICITY_DEBUG + IMPORTED_LINK_INTERFACE_MULTIPLICITY_RELEASE + IMPORTED_LOCATION + IMPORTED_LOCATION_DEBUG + IMPORTED_LOCATION_RELEASE + IMPORTED_NO_SONAME + IMPORTED_NO_SONAME_DEBUG + IMPORTED_NO_SONAME_RELEASE + IMPORTED_SONAME + IMPORTED_SONAME_DEBUG + IMPORTED_SONAME_RELEASE + IMPORT_PREFIX + IMPORT_SUFFIX + INCLUDE_DIRECTORIES + INSTALL_NAME_DIR + INSTALL_RPATH + INSTALL_RPATH_USE_LINK_PATH + INTERPROCEDURAL_OPTIMIZATION + INTERPROCEDURAL_OPTIMIZATION_DEBUG + INTERPROCEDURAL_OPTIMIZATION_RELEASE + LABELS + LIBRARY_OUTPUT_DIRECTORY + LIBRARY_OUTPUT_DIRECTORY_DEBUG + LIBRARY_OUTPUT_DIRECTORY_RELEASE + LIBRARY_OUTPUT_NAME + LIBRARY_OUTPUT_NAME_DEBUG + LIBRARY_OUTPUT_NAME_RELEASE + LINKER_LANGUAGE + LINK_DEPENDS + LINK_LIBRARIES + LINK_FLAGS + LINK_FLAGS_DEBUG + LINK_FLAGS_RELEASE + LINK_INTERFACE_LIBRARIES + LINK_INTERFACE_LIBRARIES_DEBUG + LINK_INTERFACE_LIBRARIES_RELEASE + LINK_INTERFACE_MULTIPLICITY + LINK_INTERFACE_MULTIPLICITY_DEBUG + LINK_INTERFACE_MULTIPLICITY_RELEASE + LINK_SEARCH_END_STATIC + LINK_SEARCH_START_STATIC + LOCATION + LOCATION_DEBUG + LOCATION_RELEASE + MACOSX_BUNDLE + MACOSX_BUNDLE_INFO_PLIST + MACOSX_FRAMEWORK_INFO_PLIST + MAP_IMPORTED_CONFIG_DEBUG + MAP_IMPORTED_CONFIG_RELEASE + OSX_ARCHITECTURES + OSX_ARCHITECTURES_DEBUG + OSX_ARCHITECTURES_RELEASE + OUTPUT_NAME + OUTPUT_NAME_DEBUG + OUTPUT_NAME_RELEASE + POST_INSTALL_SCRIPT + PREFIX + PRE_INSTALL_SCRIPT + PRIVATE_HEADER + PROJECT_LABEL + PUBLIC_HEADER + RESOURCE + RULE_LAUNCH_COMPILE + RULE_LAUNCH_CUSTOM + RULE_LAUNCH_LINK + RUNTIME_OUTPUT_DIRECTORY + RUNTIME_OUTPUT_DIRECTORY_DEBUG + RUNTIME_OUTPUT_DIRECTORY_RELEASE + RUNTIME_OUTPUT_NAME + RUNTIME_OUTPUT_NAME_DEBUG + RUNTIME_OUTPUT_NAME_RELEASE + SKIP_BUILD_RPATH + SOURCES + SOVERSION + STATIC_LIBRARY_FLAGS + STATIC_LIBRARY_FLAGS_DEBUG + STATIC_LIBRARY_FLAGS_RELEASE + SUFFIX + TYPE + VERSION + VS_DOTNET_REFERENCES + VS_GLOBAL_KEYWORD + VS_GLOBAL_PROJECT_TYPES + VS_KEYWORD + VS_SCC_AUXPATH + VS_SCC_LOCALPATH + VS_SCC_PROJECTNAME + VS_SCC_PROVIDER + VS_WINRT_EXTENSIONS + VS_WINRT_REFERENCES + WIN32_EXECUTABLE + ) + + message("======================== ${tgt} ========================") + foreach(p ${props}) + echo_target_property("${tgt}" "${p}") + endforeach() + message("") + +endfunction() + +function(echo_targets) + set(tgts ${ARGV}) + foreach(t ${tgts}) + echo_target("${t}") + endforeach() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ExportAllSymbols.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ExportAllSymbols.cmake new file mode 100644 index 0000000000000000000000000000000000000000..76a543daf256388d88f74529cd700d6fc50bfeaf --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ExportAllSymbols.cmake @@ -0,0 +1,11 @@ +include(CheckAndSetFlag) + +option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF) + +if(EXPORT_ALL_SYMBOLS) + add_compile_definitions(EXPORT_ALL_SYMBOLS) +else() + message(STATUS "${} default symbol visibility: hidden") + + checkandsetflag(-fvisibility=hidden) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindCairo.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindCairo.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c9ec7f0727e6fb42b93669d1754d059a60d9862c --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindCairo.cmake @@ -0,0 +1,107 @@ +# - Try to find the CAIRO library +# Once done this will define +# +# CAIRO_ROOT_DIR - Set this variable to the root installation of CAIRO +# +# Read-Only variables: +# CAIRO_FOUND - system has the CAIRO library +# CAIRO_INCLUDE_DIR - the CAIRO include directory +# CAIRO_LIBRARIES - The libraries needed to use CAIRO +# CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) + +#============================================================================= +# Copyright 2012 Dmitry Baryshnikov +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(_CAIRO cairo) +endif(PKG_CONFIG_FOUND) + +set(_CAIRO_ROOT_HINTS $ENV{CAIRO} ${CAIRO_ROOT_DIR}) +set(_CAIRO_ROOT_PATHS $ENV{CAIRO}/src /usr /usr/local) +set(_CAIRO_ROOT_HINTS_AND_PATHS HINTS ${_CAIRO_ROOT_HINTS} PATHS ${_CAIRO_ROOT_PATHS}) + +find_path(CAIRO_INCLUDE_DIR NAMES cairo.h HINTS ${_CAIRO_INCLUDEDIR} ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES include "include/cairo" +) + +if(NOT PKGCONFIG_FOUND AND WIN32 AND NOT CYGWIN) + # MINGW should go here too + if(MSVC) + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory even though : + find_library(CAIRO_DEBUG NAMES cairod ${_CAIRO_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC") + + find_library(CAIRO_RELEASE NAMES cairo ${_CAIRO_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC") + + if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + if(NOT CAIRO_DEBUG) + set(CAIRO_DEBUG ${CAIRO_RELEASE}) + endif(NOT CAIRO_DEBUG) + set(CAIRO_LIBRARIES optimized ${CAIRO_RELEASE} debug ${CAIRO_DEBUG}) + else() + set(CAIRO_LIBRARIES ${CAIRO_RELEASE}) + endif() + mark_as_advanced(CAIRO_DEBUG CAIRO_RELEASE) + elseif(MINGW) + # same player, for MingW + find_library(CAIRO NAMES cairo ${_CAIRO_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "lib/MinGW") + + mark_as_advanced(CAIRO) + set(CAIRO_LIBRARIES ${CAIRO}) + else(MSVC) + # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: + find_library(CAIRO NAMES cairo HINTS ${_CAIRO_LIBDIR} ${_CAIRO_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES lib) + + mark_as_advanced(CAIRO) + set(CAIRO_LIBRARIES ${CAIRO}) + endif(MSVC) +else() + + find_library( + CAIRO_LIBRARY NAMES cairo HINTS ${_CAIRO_LIBDIR} ${_CAIRO_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "local/lib" + ) + + mark_as_advanced(CAIRO_LIBRARY) + + # compat defines + set(CAIRO_LIBRARIES ${CAIRO_LIBRARY}) + +endif() + +#message( STATUS "Cairo_FIND_VERSION=${Cairo_FIND_VERSION}.") +#message( STATUS "CAIRO_INCLUDE_DIR=${CAIRO_INCLUDE_DIR}.") + +# Fetch version from cairo-version.h if a version was requested by find_package() +if(CAIRO_INCLUDE_DIR AND Cairo_FIND_VERSION) + file(READ "${CAIRO_INCLUDE_DIR}/cairo-version.h" _CAIRO_VERSION_H_CONTENTS) + string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MAJOR[ \t]+([0-9]+).*" "\\2" CAIRO_VERSION_MAJOR + ${_CAIRO_VERSION_H_CONTENTS} + ) + string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MINOR[ \t]+([0-9]+).*" "\\2" CAIRO_VERSION_MINOR + ${_CAIRO_VERSION_H_CONTENTS} + ) + string(REGEX REPLACE "^(.*\n)?#define[ \t]+CAIRO_VERSION_MICRO[ \t]+([0-9]+).*" "\\2" CAIRO_VERSION_MICRO + ${_CAIRO_VERSION_H_CONTENTS} + ) + set(CAIRO_VERSION ${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO} + CACHE INTERNAL "The version number for Cairo libraries" + ) +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Cairo REQUIRED_VARS CAIRO_LIBRARIES CAIRO_INCLUDE_DIR VERSION_VAR CAIRO_VERSION) + +mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAC.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAC.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0f2d262d7313c72c1ff0515b4539611857f30f4b --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAC.cmake @@ -0,0 +1,12 @@ +find_path(FAAC_INCLUDE_DIR faac.h) + +find_library(FAAC_LIBRARY faac) + +find_package_handle_standard_args(FAAC DEFAULT_MSG FAAC_INCLUDE_DIR FAAC_LIBRARY) + +if(FAAC_FOUND) + set(FAAC_LIBRARIES ${FAAC_LIBRARY}) + set(FAAC_INCLUDE_DIRS ${FAAC_INCLUDE_DIR}) +endif() + +mark_as_advanced(FAAC_INCLUDE_DIR FAAC_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAD2.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAD2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..125d328e5fbe650629425d0b8629af224b33c67f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFAAD2.cmake @@ -0,0 +1,12 @@ +find_path(FAAD2_INCLUDE_DIR faad.h) + +find_library(FAAD2_LIBRARY faad) + +find_package_handle_standard_args(FAAD2 DEFAULT_MSG FAAD2_INCLUDE_DIR FAAD2_LIBRARY) + +if(FAAD2_FOUND) + set(FAAD2_LIBRARIES ${FAAD2_LIBRARY}) + set(FAAD2_INCLUDE_DIRS ${FAAD2_INCLUDE_DIR}) +endif() + +mark_as_advanced(FAAD2_INCLUDE_DIR FAAD2_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFFmpeg.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFFmpeg.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0e5f7bec7c7a39c5c1b2bd38407c100d74243843 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFFmpeg.cmake @@ -0,0 +1,208 @@ +# vim: ts=2 sw=2 +# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) +# +# Once done this will define +# FFMPEG_FOUND - System has the all required components. +# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers. +# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. +# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components. +# +# For each of the components +# - AVCODEC +# - AVDEVICE +# - AVFORMAT +# - AVFILTER +# - AVUTIL +# - POSTPROCESS +# - SWSCALE +# - SWRESAMPLE +# the following variables will be defined: +# _FOUND - System has +# _INCLUDE_DIRS - Include directory necessary for using the headers +# _LIBRARIES - Link these to use +# _DEFINITIONS - Compiler switches required for using +# _VERSION - The components version +# +# As the versions of the various FFmpeg components differ for a given release, +# and CMake supports only one common version for all components, use the +# following to specify required versions for multiple components: +# +# find_package(FFmpeg 57.48 COMPONENTS AVCODEC) +# find_package(FFmpeg 57.40 COMPONENTS AVFORMAT) +# find_package(FFmpeg 55.27 COMPONENTS AVUTIL) +# +# SPDX-FileCopyrightText: 2006 Matthias Kretz +# SPDX-FileCopyrightText: 2008 Alexander Neundorf +# SPDX-FileCopyrightText: 2011 Michael Jansen +# SPDX-FileCopyrightText: 2021 Stefan Brüns +# SPDX-FileCopyrightText: 2024 Armin Novak +# SPDX-License-Identifier: BSD-3-Clause + +include(FindPackageHandleStandardArgs) + +if(NOT FFmpeg_FIND_COMPONENTS) + # The default components were taken from a survey over other FindFFMPEG.cmake files + set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) +endif() + +list(LENGTH FFmpeg_FIND_COMPONENTS _numComponents) + +if((${_numComponents} GREATER 1) AND DEFINED ${FFmpeg_FIND_VERSION}) + message(WARNING "Using a required version in combination with multiple COMPONENTS is not supported") + set(_FFmpeg_REQUIRED_VERSION 0) +elseif(DEFINED FFmpeg_FIND_VERSION) + set(_FFmpeg_REQUIRED_VERSION ${FFmpeg_FIND_VERSION}) +else() + set(_FFmpeg_REQUIRED_VERSION 0) +endif() + +set(_FFmpeg_ALL_COMPONENTS + AVCODEC + AVDEVICE + AVFORMAT + AVFILTER + AVUTIL + POSTPROCESS + SWSCALE + SWRESAMPLE +) + +# +# ## Macro: set_component_found +# +# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. +# +macro(set_component_found _component) + if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) + set(${_component}_FOUND TRUE) + set(FFmpeg_${_component}_FOUND TRUE) + endif() +endmacro() + +# +# ## Macro: find_component +# +# Checks for the given component by invoking pkgconfig and then looking up the libraries and +# include directories. +# +macro(find_component _component _pkgconfig _library _header) + if(NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_${_component} QUIET ${_pkgconfig}) + endif() + endif(NOT WIN32) + + find_path(${_component}_INCLUDE_DIRS ${_header} HINTS ${PC_LIB${_component}_INCLUDEDIR} + ${PC_LIB${_component}_INCLUDE_DIRS} PATH_SUFFIXES ffmpeg + ) + + find_library( + ${_component}_LIBRARIES NAMES ${_library} HINTS ${PC_LIB${_component}_LIBDIR} ${PC_LIB${_component}_LIBRARY_DIRS} + ) + + set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.") + + # Fallback version detection: + # Read version.h (and version_major.h if it exists) and try to extract the version + if("${PC_${_component}_VERSION}_" STREQUAL "_") + get_filename_component(${_component}_suffix "${_header}" DIRECTORY) + find_file(${_component}_hdr_version_major NAMES version_major.h PATH_SUFFIXES ${${_component}_suffix} + HINTS ${${_component}_INCLUDE_DIRS} + ) + find_file(${_component}_hdr_version NAMES version.h PATH_SUFFIXES ${${_component}_suffix} + HINTS ${${_component}_INCLUDE_DIRS} + ) + if(NOT ${${_component}_hdr_version} MATCHES ".*-NOTFOUND") + file(READ "${${_component}_hdr_version}" ${_component}_version_text) + endif() + if(NOT ${${_component}_hdr_version_major} MATCHES ".*-NOTFOUND") + file(READ "${${_component}_hdr_version_major}" ${_component}_version_major_text) + else() + set(${_component}_version_major_text "${${_component}_version_text}") + endif() + + string(REGEX MATCH "#define[ \t]+.*_VERSION_MAJOR[ \t]+([0-9]+)" _ "${${_component}_version_major_text}") + set(${_component}_version_major ${CMAKE_MATCH_1}) + string(REGEX MATCH "#define[ \t]+.*_VERSION_MINOR[ \t]+([0-9]+)" _ "${${_component}_version_text}") + set(${_component}_version_minor ${CMAKE_MATCH_1}) + string(REGEX MATCH "#define[ \t]+.*_VERSION_MICRO[ \t]+([0-9]+)" _ "${${_component}_version_text}") + set(${_component}_version_micro ${CMAKE_MATCH_1}) + + set(${_component}_VERSION + "${${_component}_version_major}.${${_component}_version_minor}.${${_component}_version_micro}" + CACHE STRING "The ${_component} version number." + ) + else() + set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.") + endif() + + set_component_found(${_component}) + + mark_as_advanced(${_component}_INCLUDE_DIRS ${_component}_LIBRARIES ${_component}_DEFINITIONS ${_component}_VERSION) +endmacro() + +# Check for cached results. If there are skip the costly part. +if(NOT FFMPEG_LIBRARIES) + # Check for all possible component. + find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) + find_component(AVFORMAT libavformat avformat libavformat/avformat.h) + find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) + find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) + find_component(AVUTIL libavutil avutil libavutil/avutil.h) + find_component(SWSCALE libswscale swscale libswscale/swscale.h) + find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) + find_component(POSTPROCESS libpostproc postproc libpostproc/postprocess.h) + + # Check if the required components were found and add their stuff to the FFMPEG_* vars. + foreach(_component ${_FFmpeg_ALL_COMPONENTS}) + if(${_component}_FOUND) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) + list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) + endif() + endforeach() + + # Build the include path with duplicates removed. + if(FFMPEG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) + endif() + + # cache the vars. + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) + + mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES FFMPEG_DEFINITIONS) + +else() + # Set the noncached _FOUND vars for the components. + foreach(_component ${_FFmpeg_ALL_COMPONENTS}) + set_component_found(${_component}) + endforeach() +endif() + +# Compile the list of required vars +unset(_FFmpeg_REQUIRED_VARS) +set(_FFmpeg_FOUND_LIBRARIES "") + +foreach(_component ${FFmpeg_FIND_COMPONENTS}) + if(${_component}_FOUND) + if(${_component}_VERSION VERSION_LESS _FFmpeg_REQUIRED_VERSION) + message(STATUS "${_component}: ${${_component}_VERSION} < ${_FFmpeg_REQUIRED_VERSION}") + unset(${_component}_FOUND) + endif() + + list(APPEND _FFmpeg_FOUND_LIBRARIES ${${_component}_LIBRARIES}) + endif() + + list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS ${_component}_FOUND) +endforeach() + +list(INSERT _FFmpeg_REQUIRED_VARS 0 _FFmpeg_FOUND_LIBRARIES) + +# Give a nice error message if some of the required vars are missing. +find_package_handle_standard_args(FFmpeg REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS} HANDLE_COMPONENTS) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFeature.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFeature.cmake new file mode 100644 index 0000000000000000000000000000000000000000..11bd9f1b1f4210670902d46c2dc772b45fba8d39 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindFeature.cmake @@ -0,0 +1,64 @@ +include(FeatureSummary) + +# types: DISABLED < RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED + +macro(find_feature _feature _type _purpose _description) + + string(TOUPPER ${_feature} _feature_upper) + string(TOLOWER ${_type} _type_lower) + + if(${_type} STREQUAL "DISABLED") + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + else() + if(${_type} STREQUAL "REQUIRED") + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature} REQUIRED) + elseif(${_type} STREQUAL "RECOMMENDED") + if(NOT ${WITH_${_feature_upper}}) + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + else() + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + message(STATUS " Disable feature ${_feature} using \"-DWITH_${_feature_upper}=OFF\"") + find_package(${_feature}) + if(NOT ${_feature}_FOUND) + set(_feature_default "OFF") + message( + STATUS "Not detected ${_type_lower} feature ${_feature} for ${_purpose} (${_description}), feature disabled" + ) + endif() + endif() + elseif(${_type} STREQUAL "OPTIONAL") + if(${WITH_${_feature_upper}}) + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature} REQUIRED) + else() + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + message(STATUS " Enable feature ${_feature} using \"-DWITH_${_feature_upper}=ON\"") + endif() + else() + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature}) + endif() + + if(NOT ${${_feature}_FOUND}) + if(${_feature_default}) + message( + WARNING + " feature ${_feature} was requested but could not be found! ${_feature_default} / ${${_feature}_FOUND}" + ) + endif() + set(_feature_default "OFF") + endif() + + option(WITH_${_feature_upper} "Enable feature ${_feature} for ${_purpose}" ${_feature_default}) + + set_package_properties(${_feature} PROPERTIES TYPE ${_type} PURPOSE "${_purpose}" DESCRIPTION "${_description}") + endif() +endmacro(find_feature) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindGSM.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindGSM.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c2078fd44e066c8c9d07bd0f1fb29aa871cf2c1f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindGSM.cmake @@ -0,0 +1,12 @@ +find_path(GSM_INCLUDE_DIR gsm/gsm.h) + +find_library(GSM_LIBRARY gsm) + +find_package_handle_standard_args(GSM DEFAULT_MSG GSM_INCLUDE_DIR GSM_LIBRARY) + +if(GSM_FOUND) + set(GSM_LIBRARIES ${GSM_LIBRARY}) + set(GSM_INCLUDE_DIRS ${GSM_INCLUDE_DIR}) +endif() + +mark_as_advanced(GSM_INCLUDE_DIR GSM_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindJSONC.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindJSONC.cmake new file mode 100644 index 0000000000000000000000000000000000000000..68ccc7359dfbab682e8cb00ad9799a6298bf125a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindJSONC.cmake @@ -0,0 +1,24 @@ +# - Try to find JSON-C +# Once done this will define +# +# JSONC_FOUND - JSON-C was found +# JSONC_INCLUDE_DIRS - JSON-C include directories +# JSONC_LIBRARIES - libraries needed for linking + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_JSONC json-c) +endif() + +find_path(JSONC_INCLUDE_DIR NAMES json.h HINTS ${PC_JSONC_INCLUDE_DIRS} PATH_SUFFIXES json-c) +find_library(JSONC_LIBRARY NAMES json-c HINTS ${PC_JSONC_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(JSONC DEFAULT_MSG JSONC_LIBRARY JSONC_INCLUDE_DIR) + +if(JSONC_FOUND) + set(JSONC_LIBRARIES ${JSONC_LIBRARY}) + set(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR}) +endif() + +mark_as_advanced(JSONC_LIBRARY JSONC_INCLUDE_DIR) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindKRB5.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindKRB5.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ee627089b59168bb64cb1ba4e9a3c51ffca4d96b --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindKRB5.cmake @@ -0,0 +1,198 @@ +# - Try to find the Kerberos libraries +# Once done this will define +# +# KRB5_ROOT_CONFIG - Set this variable to the full path of krb5-config of Kerberos +# KRB5_ROOT_FLAVOUR - Set this variable to the flavour of Kerberos installation (MIT or Heimdal) +# +# Read-Only variables: +# KRB5_FOUND - system has the Heimdal library +# KRB5_FLAVOUR - "MIT" or "Heimdal" if anything found. +# KRB5_INCLUDE_DIRS - the Heimdal include directory +# KRB5_LIBRARIES - The libraries needed to use Kerberos +# KRB5_LIBRARY_DIRS - Directories to add to linker search path +# KRB5_LDFLAGS - Additional linker flags +# KRB5_CFLAGS - Additional compiler flags +# KRB5_VERSION - This is set to version advertised by pkg-config or read from manifest. +# In case the library is found but no version info available it'll be set to "unknown" + +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckTypeSize) + +set(_KRB5_REQUIRED_VARS KRB5_FOUND KRB5_VERSION KRB5_FLAVOUR KRB5_INCLUDE_DIRS KRB5_LIBRARIES) + +macro(PROVIDES_KRB5) + set(PREFIX "MACRO_KRB5") + + cmake_parse_arguments("${PREFIX}" "" "NAME" "" ${ARGN}) + + set(KRB5_FLAVOUR ${MACRO_KRB5_NAME}) + string(TOUPPER "${MACRO_KRB5_NAME}" MACRO_KRB5_NAME) + + # This is a list of all variables that pkg_check_modules exports. + set(VARIABLES + "CFLAGS;CFLAGS_I;CFLAGS_OTHER;FOUND;INCLUDEDIR;INCLUDE_DIRS;LDFLAGS;LDFLAGS_OTHER;LIBDIR;LIBRARIES;LIBRARY_DIRS;LIBS;LIBS_L;LIBS_OTHER;LIBS_PATHS;LINK_LIBRARIS;MODULE_NAME;PREFIX;VERSION;STATIC_CFLAGS;STATIC_CFLAGS_I;STATIC_CFLAGS_OTHER;STATIC_INCLUDE_DIRS;STATIC_LDFLAGS;STATIC_LDFLAGS_OTHER;STATIC_LIBDIR;STATIC_LIBRARIES;STATIC_LIBRARY_DIRS;STATIC_LIBS;STATIC_LIBS_L;STATIC_LIBS_OTHER;STATIC_LIBS_PATHS" + ) + foreach(VAR ${VARIABLES}) + set(KRB5_${VAR} ${KRB5_${MACRO_KRB5_NAME}_${VAR}}) + endforeach() + + # Bugfix for older installations: + # KRB5_INCLUDE_DIRS might not be set, fall back to KRB5_INCLUDEDIR + if(NOT KRB5_INCLUDE_DIRS) + set(KRB5_INCLUDE_DIRS ${KRB5_INCLUDEDIR}) + endif() +endmacro() + +function(GET_KRB5_CONFIG KRB5_CONFIG COMMAND RESULT) + execute_process(COMMAND ${KRB5_CONFIG} ${COMMAND} OUTPUT_VARIABLE _KRB5_RESULT RESULT_VARIABLE _KRB5_CONFIGURE_FAILED) + if(_KRB5_CONFIGURE_FAILED) + message(FATAL_ERROR "Failed to detect krb5-config [${COMMAND}]") + endif() + + string(REGEX REPLACE "[\r\n]" "" _KRB5_RESULT ${_KRB5_RESULT}) + set(${RESULT} "${_KRB5_RESULT}" PARENT_SCOPE) +endfunction() + +function(string_starts_with str search RES) + string(FIND "${str}" "${search}" out) + if("${out}" EQUAL 0) + set(${RES} ON PARENT_SCOPE) + else() + set(${RES} OFF PARENT_SCOPE) + endif() +endfunction() + +function(GET_KRB5_BY_CONFIG KRB5_CONFIG) + if(NOT KRB5_CONFIG) + find_program( + KRB5_CONFIG NAMES "krb5-config" "krb5-config.mit" "krb5-config.heimdal" PATH_SUFFIXES bin + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH REQUIRED + ) + message("autodetected krb5-config at ${KRB5_CONFIG}") + if(NOT KRB5_CONFIG) + return() + endif() + else() + message("using krb5-config ${KRB5_CONFIG} provided by KRB5_ROOT_CONFIG") + endif() + + get_krb5_config("${KRB5_CONFIG}" "--vendor" _KRB5_VENDOR) + + if("${_KRB5_VENDOR}" STREQUAL "Apple MITKerberosShim") + message(FATAL_ERROR "Apple MITKerberosShim is deprecated and not supported") + elseif("${_KRB5_VENDOR}" STREQUAL "Massachusetts Institute of Technology") + set(KRB5_FLAVOUR "MIT") + else() + set(KRB5_FLAVOUR "${_KRB5_VENDOR}") + endif() + + get_krb5_config("${KRB5_CONFIG}" "--cflags" KRB5_CFLAGS) + get_krb5_config("${KRB5_CONFIG}" "--version" KRB5_VERSION_RAW) + + string(REGEX REPLACE "[ ]" ";" KRB5_VERSION_LIST "${KRB5_VERSION_RAW}") + list(LENGTH KRB5_VERSION_LIST KRB5_VERSION_LIST_LEN) + math(EXPR KRB5_VERSION_LIST_LAST "${KRB5_VERSION_LIST_LEN} - 1") + list(GET KRB5_VERSION_LIST ${KRB5_VERSION_LIST_LAST} KRB5_VERSION) + + if(KRB5_FLAVOUR STREQUAL "MIT") + if(KRB5_VERSION VERSION_LESS "1.14") + message(FATAL_ERROR "MIT kerberos ${KRB5_VERSION} < 1.14 is not supported, upgrade the library!") + endif() + endif() + + get_krb5_config("${KRB5_CONFIG}" "--libs" KRB5_LDFLAGS) + + string(REGEX REPLACE "[ ]" ";" KRB5_CFLAG_LIST "${KRB5_CFLAGS}") + foreach(FLAG ${KRB5_CFLAG_LIST}) + string_starts_with("${FLAG}" "-I" RES) + if(RES) + string(SUBSTRING "${FLAG}" 2 -1 FLAG) + endif() + + if(IS_DIRECTORY "${FLAG}") + list(APPEND KRB5_INCLUDEDIR ${FLAG}) + endif() + endforeach() + if(NOT KRB5_INCLUDEDIR) + find_file(KRB5_INCLUDEDIR_HEADER NAMES krb5.h REQUIRED) + get_filename_component(KRB5_INCLUDEDIR "${KRB5_INCLUDEDIR_HEADER}" DIRECTORY) + endif() + + string(REGEX REPLACE "[ ]" ";" KRB5_LDFLAG_LIST "${KRB5_LDFLAGS}") + foreach(FLAG ${KRB5_LDFLAG_LIST}) + string_starts_with("${FLAG}" "-L" RES) + if(RES) + string(SUBSTRING "${FLAG}" 2 -1 SUBFLAG) + list(APPEND KRB5_LIBRARY_DIRS ${SUBFLAG}) + endif() + string_starts_with("${FLAG}" "-l" RES) + if(RES) + string(SUBSTRING "${FLAG}" 2 -1 SUBFLAG) + list(APPEND KRB5_LIBRARIES ${SUBFLAG}) + endif() + endforeach() + + set(KRB5_FOUND ON PARENT_SCOPE) + set(KRB5_VERSION ${KRB5_VERSION} PARENT_SCOPE) + set(KRB5_FLAVOUR ${KRB5_FLAVOUR} PARENT_SCOPE) + set(KRB5_CFLAGS ${KRB5_CFLAGS} PARENT_SCOPE) + set(KRB5_LDFLAGS ${KRB5_LDFLAGS} PARENT_SCOPE) + set(KRB5_INCLUDEDIR ${KRB5_INCLUDEDIR} PARENT_SCOPE) + set(KRB5_INCLUDE_DIRS ${KRB5_INCLUDEDIR} PARENT_SCOPE) + set(KRB5_LIBRARIES ${KRB5_LIBRARIES} PARENT_SCOPE) + set(KRB5_LIBRARY_DIRS ${KRB5_LIBRARY_DIRS} PARENT_SCOPE) +endfunction() + +# try to find kerberos to compile against. +# +# * First search with pkg-config (prefer MIT over Heimdal) +# * Then try to find krb5-config (generic, krb5-config.mit and last krb5-config.heimdal) +find_package(PkgConfig REQUIRED) + +if(KRB5_ROOT_CONFIG) + +elseif(KRB5_ROOT_FLAVOUR) + if(KRB5_ROOT_FLAVOUR STREQUAL "Heimdal") + pkg_check_modules(KRB5_HEIMDAL heimdal-krb5) + elseif(KRB5_ROOT_FLAVOUR STREQUAL "MIT") + pkg_check_modules(KRB5_HEIMDAL mit-krb5) + else() + message(FATAL_ERROR "Invalid KRB5_ROOT_FLAVOUR=${KRB5_ROOT_FLAVOUR}, only 'MIT' or 'Heimdal' are supported") + endif() +else() + pkg_check_modules(KRB5_MIT mit-krb5) + pkg_check_modules(KRB5_HEIMDAL heimdal-krb5) +endif() + +if(KRB5_MIT_FOUND) + provides_krb5(NAME "MIT") + if(KRB5_VERSION VERSION_LESS "1.14") + message(FATAL_ERROR "MIT kerberos < 1.14 is not supported, upgrade the library!") + endif() +elseif(KRB5_HEIMDAL_FOUND) + provides_krb5(NAME "Heimdal") +elseif(KRB5_ANY_FOUND) + get_krb5_vendor(ANY_VENDOR) + provides_krb5(NAME "${ANY_VENDOR}") +else() + get_krb5_by_config("${KRB5_ROOT_CONFIG}") +endif() + +message("using KRB5_FOUND ${KRB5_FOUND} ") +message("using KRB5_VERSION ${KRB5_VERSION} ") +message("using KRB5_FLAVOUR ${KRB5_FLAVOUR} ") +message("using KRB5_CFLAGS ${KRB5_CFLAGS} ") +message("using KRB5_LDFLAGS ${KRB5_LDFLAGS} ") +message("using KRB5_INCLUDEDIR ${KRB5_INCLUDEDIR} ") +message("using KRB5_INCLUDE_DIRS ${KRB5_INCLUDE_DIRS} ") +message("using KRB5_LIBRARIES ${KRB5_LIBRARIES} ") + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( + KRB5 REQUIRED_VARS ${_KRB5_REQUIRED_VARS} VERSION_VAR KRB5_VERSION + FAIL_MESSAGE "Could NOT find Kerberos, try to set the CMake variable KRB5_ROOT_CONFIG to the full path of krb5-config" +) + +mark_as_advanced(${_KRB5_REQUIRED_VARS}) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindLAME.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindLAME.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9ba4225a006b8af9ed28a4300550c9b98816231a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindLAME.cmake @@ -0,0 +1,12 @@ +find_path(LAME_INCLUDE_DIR lame/lame.h) + +find_library(LAME_LIBRARY NAMES lame mp3lame) + +find_package_handle_standard_args(LAME DEFAULT_MSG LAME_INCLUDE_DIR LAME_LIBRARY) + +if(LAME_FOUND) + set(LAME_LIBRARIES ${LAME_LIBRARY}) + set(LAME_INCLUDE_DIRS ${LAME_INCLUDE_DIR}) +endif() + +mark_as_advanced(LAME_INCLUDE_DIR LAME_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindMbedTLS.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindMbedTLS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8d57768de5e65f2db0015fb136c4bbe39371b461 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindMbedTLS.cmake @@ -0,0 +1,24 @@ +find_path(MBEDTLS_INCLUDE_DIR NAMES mbedtls/ssl.h PATH_SUFFIXES include HINTS ${MBEDTLS_ROOT}) + +find_library(MBEDTLS_LIBRARY NAMES mbedtls PATH_SUFFIXES lib HINTS ${MBEDTLS_ROOT}) + +find_library(MBEDCRYPTO_LIBRARY NAMES mbedcrypto PATH_SUFFIXES lib HINTS ${MBEDTLS_ROOT}) + +find_library(MBEDX509_LIBRARY NAMES mbedx509 PATH_SUFFIXES lib HINTS ${MBEDTLS_ROOT}) + +if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY) + set(MBEDTLS_FOUND TRUE) + set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDCRYPTO_LIBRARY} ${MBEDX509_LIBRARY}) +endif() + +if(MBEDTLS_FOUND) + if(NOT MBEDTLS_FIND_QUIETLY) + message(STATUS "Found mbed TLS: ${MBEDTLS_LIBRARIES}") + endif() +else() + if(MBEDTLS_FIND_REQUIRED) + message(FATAL_ERROR "mbed TLS was not found") + endif() +endif() + +mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOSS.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOSS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e582540488a6e461ace23688fe120ea2cd5e88b9 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOSS.cmake @@ -0,0 +1,34 @@ +# +# Find OSS include header for Unix platforms. +# used by FQTerm to detect the availability of OSS. + +if(UNIX) + if(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(PLATFORM_PREFIX "linux/") + elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + set(PLATFORM_PREFIX "sys/") + elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") + set(PLATFORM_PREFIX "machine/") + endif() +endif(UNIX) + +set(OSS_HDR_NAME "${PLATFORM_PREFIX}soundcard.h" CACHE STRING "oss header include file name") +find_path(OSS_INCLUDE_DIRS ${OSS_HDR_NAME} PATHS "/usr/local/include" PATH_SUFFIXES ${PLATFORM_SUFFIX}) + +if(OSS_INCLUDE_DIRS) + set(OSS_FOUND ON CACHE BOOL "oss detection status") +else(OSS_INCLUDE_DIRS) + set(OSS_FOUND OFF CACHE BOOL "oss detection status") +endif(OSS_INCLUDE_DIRS) + +if(OSS_FOUND) + message(STATUS "Found OSS Audio") +else(OSS_FOUND) + if(OSS_FIND_REQUIRED) + message(FATAL_ERROR "FAILED to found Audio - REQUIRED") + else(OSS_FIND_REQUIRED) + message(STATUS "Audio Disabled") + endif(OSS_FIND_REQUIRED) +endif(OSS_FOUND) + +mark_as_advanced(OSS_FOUND OSS_HDR_NAME OSS_INCLUDE_DIRS) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenH264.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenH264.cmake new file mode 100644 index 0000000000000000000000000000000000000000..51b5a63329b2029ab878a55f66ba87cc991574c7 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenH264.cmake @@ -0,0 +1,45 @@ +# - Try to find the OpenH264 library +# Once done this will define +# +# OPENH264_ROOT - A list of search hints +# +# OPENH264_FOUND - system has OpenH264 +# OPENH264_INCLUDE_DIR - the OpenH264 include directory +# OPENH264_LIBRARIES - libopenh264 library + +if(UNIX AND NOT ANDROID) + find_package(PkgConfig QUIET) + pkg_check_modules(PC_OPENH264 QUIET openh264) +endif(UNIX AND NOT ANDROID) + +if(OPENH264_INCLUDE_DIR AND OPENH264_LIBRARY) + set(OPENH264_FIND_QUIETLY TRUE) +endif(OPENH264_INCLUDE_DIR AND OPENH264_LIBRARY) + +find_path(OPENH264_INCLUDE_DIR NAMES wels/codec_api.h wels/codec_app_def.h wels/codec_def.h PATH_SUFFIXES include + HINTS ${OPENH264_ROOT} ${PC_OPENH264_INCLUDE_DIRS} +) +find_library( + OPENH264_LIBRARY NAMES openh264_dll openh264 welsdec PATH_SUFFIXES lib HINTS ${OPENH264_ROOT} + ${PC_OPENH264_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenH264 DEFAULT_MSG OPENH264_LIBRARY OPENH264_INCLUDE_DIR) + +if(OPENH264_INCLUDE_DIR AND OPENH264_LIBRARY) + set(OPENH264_FOUND TRUE) + set(OPENH264_LIBRARIES ${OPENH264_LIBRARY}) +endif(OPENH264_INCLUDE_DIR AND OPENH264_LIBRARY) + +if(OPENH264_FOUND) + if(NOT OPENH264_FIND_QUIETLY) + message(STATUS "Found OpenH264: ${OPENH264_LIBRARIES}") + endif(NOT OPENH264_FIND_QUIETLY) +else(OPENH264_FOUND) + if(OPENH264_FIND_REQUIRED) + message(FATAL_ERROR "OpenH264 was not found") + endif(OPENH264_FIND_REQUIRED) +endif(OPENH264_FOUND) + +mark_as_advanced(OPENH264_INCLUDE_DIR OPENH264_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenSLES.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenSLES.cmake new file mode 100644 index 0000000000000000000000000000000000000000..466dcbbe9e92a0b0b1e0961061597080e8724369 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindOpenSLES.cmake @@ -0,0 +1,29 @@ +# - Find OpenSLES +# Find the OpenSLES includes and libraries +# +# OpenSLES_INCLUDE_DIR - where to find dsound.h +# OpenSLES_LIBRARIES - List of libraries when using dsound. +# OpenSLES_FOUND - True if dsound found. + +get_property(_FIND_LIBRARY_USE_LIB64_PATHS GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS 1) + +find_path(OpenSLES_INCLUDE_DIR SLES/OpenSLES.h) + +find_library(OpenSLES_LIBRARY NAMES OpenSLES) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenSLES DEFAULT_MSG OpenSLES_INCLUDE_DIR OpenSLES_LIBRARY) + +if(OpenSLES_FOUND) + set(OpenSLES_INCLUDE_DIRS ${OpenSLES_INCLUDE_DIR}) + set(OpenSLES_LIBRARIES ${OpenSLES_LIBRARY}) +else(OpenSLES_FOUND) + if(OpenSLES_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find OpenSLES") + endif() +endif(OpenSLES_FOUND) + +mark_as_advanced(OpenSLES_INCLUDE_DIR OpenSLES_LIBRARY) + +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${_FIND_LIBRARY_USE_LIB64_PATHS}) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPAM.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPAM.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5ce7b23b1d90b9e80b59fe2e02d0ba2eb44d906d --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPAM.cmake @@ -0,0 +1,39 @@ +# - Try to find the PAM libraries +# Once done this will define +# +# PAM_FOUND - system has pam +# PAM_INCLUDE_DIR - the pam include directory +# PAM_LIBRARIES - libpam library + +if(PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FIND_QUIETLY TRUE) +endif(PAM_INCLUDE_DIR AND PAM_LIBRARY) + +find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) +find_library(PAM_LIBRARY pam) +find_library(DL_LIBRARY dl) + +if(PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FOUND TRUE) + if(DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) + else(DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY}) + endif(DL_LIBRARY) + + if(EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + set(HAVE_PAM_PAM_APPL_H 1) + endif(EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) +endif(PAM_INCLUDE_DIR AND PAM_LIBRARY) + +if(PAM_FOUND) + if(NOT PAM_FIND_QUIETLY) + message(STATUS "Found PAM: ${PAM_LIBRARIES}") + endif(NOT PAM_FIND_QUIETLY) +else(PAM_FOUND) + if(PAM_FIND_REQUIRED) + message(FATAL_ERROR "PAM was not found") + endif(PAM_FIND_REQUIRED) +endif(PAM_FOUND) + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSC.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSC.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5309581f29e4a07b02e43b516815c00ae3287b52 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSC.cmake @@ -0,0 +1,23 @@ +# - Try to find PCSC +# Once done this will define +# PCSC_FOUND - pcsc was found +# PCSC_INCLUDE_DIRS - pcsc include directories +# PCSC_LIBRARIES - libraries needed for linking + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_PCSC QUIET libpcsclite) +endif() + +find_path(PCSC_INCLUDE_DIR pcsclite.h WinSCard.h HINTS ${PC_PCSC_INCLUDEDIR} ${PC_PCSC_INCLUDE_DIRS} PATH_SUFFIXES PCSC) + +find_library(PCSC_LIBRARY NAMES PCSC WinSCard pcsclite HINTS ${PC_PCSC_LIBDIR} ${PC_PCSC_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCSC DEFAULT_MSG PCSC_LIBRARY PCSC_INCLUDE_DIR) + +set(PCSC_LIBRARIES ${PCSC_LIBRARY}) +set(PCSC_INCLUDE_DIRS ${PCSC_INCLUDE_DIR}) + +mark_as_advanced(PCSC_INCLUDE_DIR PCSC_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSCWinPR.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSCWinPR.cmake new file mode 100644 index 0000000000000000000000000000000000000000..acc6e60092e308d9ade543acd3627852dc48b902 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPCSCWinPR.cmake @@ -0,0 +1,8 @@ +find_library(PCSC_WINPR_LIBRARY NAMES libpcsc-winpr.a PATHS /opt/lib /usr/lib /usr/local/lib) + +if(NOT ${PCSC_WINPR_LIBRARY} MATCHES ".*-NOTFOUND") + set(PCSC_WINPR_FOUND 1) + message(STATUS "Found PCSC-WinPR: ${PCSC_WINPR_LIBRARY}") +endif() + +mark_as_advanced(PCSC_WINPR_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPixman.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPixman.cmake new file mode 100644 index 0000000000000000000000000000000000000000..372c5018dfa013358c0d420707af91e93593777e --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindPixman.cmake @@ -0,0 +1,41 @@ +# - Find Pixman +# Find the Pixman libraries +# +# This module defines the following variables: +# PIXMAN_FOUND - true if PIXMAN_INCLUDE_DIR & PIXMAN_LIBRARY are found +# PIXMAN_LIBRARIES - Set when PIXMAN_LIBRARY is found +# PIXMAN_INCLUDE_DIRS - Set when PIXMAN_INCLUDE_DIR is found +# +# PIXMAN_INCLUDE_DIR - where to find pixman.h, etc. +# PIXMAN_LIBRARY - the Pixman library +# + +#============================================================================= +# Copyright 2013 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +find_path(PIXMAN_INCLUDE_DIR NAMES pixman.h PATH_SUFFIXES pixman-1) + +find_library(PIXMAN_LIBRARY NAMES pixman-1) + +find_package_handle_standard_args(Pixman DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INCLUDE_DIR) + +if(Pixman_FOUND) + set(PIXMAN_FOUND ON) + set(PIXMAN_LIBRARIES ${PIXMAN_LIBRARY}) + set(PIXMAN_INCLUDE_DIRS ${PIXMAN_INCLUDE_DIR}) +endif() + +mark_as_advanced(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindV4L.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindV4L.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0003fe84fdaad3d68fe51c51ca8e6e764eafd2e2 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindV4L.cmake @@ -0,0 +1,99 @@ +############################################################################ +# FindV4L.cmake +# Copyright (C) 2014-2023 Belledonne Communications, Grenoble France +# +############################################################################ +# +# 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 General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ +# +# Find the v4l library. +# +# Targets +# ^^^^^^^ +# +# The following targets may be defined: +# +# v4l1 - If the v4l1 library has been found +# v4l2 - If the v4l2 library has been found +# v4lconvert - If the v4lconvert library has been found +# +# +# Result variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project: +# +# V4L_FOUND - The v4l library has been found +# V4L_TARGETS - The list of the names of the CMake targets for the v4l libraries +# V4L_TARGET - The name of the CMake target for the v4l library +# V4L_convert_TARGET - The name of the CMake target for the v4lconvert library +# HAVE_LINUX_VIDEODEV_H - If the v4l library provides the linux/videodev.h header file +# HAVE_LINUX_VIDEODEV2_H - If the v4l library provides the linux/videodev2.h header file + +set(_V4L_REQUIRED_VARS V4L_TARGETS V4L_TARGET V4L_convert_TARGET) +set(_V4L_CACHE_VARS ${_V4L_REQUIRED_VARS} HAVE_LINUX_VIDEODEV_H HAVE_LINUX_VIDEODEV2_H) + +set(_V4L_ROOT_PATHS ${CMAKE_INSTALL_PREFIX}) + +find_path(_V4L1_INCLUDE_DIRS NAMES linux/videodev.h HINTS _V4L_ROOT_PATHS PATH_SUFFIXES include) +if(_V4L1_INCLUDE_DIRS) + set(HAVE_LINUX_VIDEODEV_H 1) +endif() +find_path(_V4L2_INCLUDE_DIRS NAMES linux/videodev2.h HINTS _V4L_ROOT_PATHS PATH_SUFFIXES include) +if(_V4L2_INCLUDE_DIRS) + set(HAVE_LINUX_VIDEODEV2_H 1) +endif() + +if(_V4L1_INCLUDE_DIRS OR _V4L2_INCLUDE_DIRS) + find_library(_V4L1_LIBRARY NAMES v4l1 HINTS _V4L_ROOT_PATHS PATH_SUFFIXES bin lib) + find_library(_V4L2_LIBRARY NAMES v4l2 HINTS _V4L_ROOT_PATHS PATH_SUFFIXES bin lib) + find_library(_V4LCONVERT_LIBRARY NAMES v4lconvert HINTS _V4L_ROOT_PATHS PATH_SUFFIXES bin lib) +endif() + +if(_V4L1_LIBRARY OR _V4L2_LIBRARY OR _V4LCONVERT_LIBRARY) + set(V4L_TARGETS) + if(_V4L2_LIBRARY) + add_library(v4l2 UNKNOWN IMPORTED) + set_target_properties( + v4l2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_V4L2_INCLUDE_DIRS}" IMPORTED_LOCATION "${_V4L2_LIBRARY}" + ) + set(V4L_TARGET v4l2) + list(APPEND V4L_TARGETS v4l2) + set(_V4L_INCLUDE_DIRS "${_V4L2_INCLUDE_DIRS}") + elseif(_V4L1_LIBRARY) + add_library(v4l1 UNKNOWN IMPORTED) + set_target_properties( + v4l1 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_V4L1_INCLUDE_DIRS}" IMPORTED_LOCATION "${_V4L1_LIBRARY}" + ) + set(V4L_TARGET v4l1) + list(APPEND V4L_TARGETS v4l1) + set(_V4L_INCLUDE_DIRS "${_V4L1_INCLUDE_DIRS}") + endif() + if(_V4LCONVERT_LIBRARY) + add_library(v4lconvert UNKNOWN IMPORTED) + set_target_properties( + v4lconvert PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_V4L_INCLUDE_DIRS}" IMPORTED_LOCATION + "${_V4LCONVERT_LIBRARY}" + ) + set(V4L_convert_TARGET v4lconvert) + list(APPEND V4L_TARGETS v4lconvert) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(V4L REQUIRED_VARS ${_V4L_REQUIRED_VARS}) +mark_as_advanced(${_V4L_CACHE_VARS}) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/FindWayland.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindWayland.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a9eca7480640e584a65a2ac81da128a333cfef57 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/FindWayland.cmake @@ -0,0 +1,68 @@ +# - Finds Wayland +# Find the Wayland libraries that are needed for UWAC +# +# This module defines the following variables: +# WAYLAND_FOUND - true if UWAC has been found +# WAYLAND_LIBS - Set to the full path to wayland client libraries +# WAYLAND_INCLUDE_DIR - Set to the include directories for wayland +# XKBCOMMON_LIBS - Set to the full path to xkbcommon libraries +# XKBCOMMON_INCLUDE_DIR - Set to the include directories for xkbcommon +# + +#============================================================================= +# Copyright 2015 David Fort +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(WAYLAND_SCANNER_PC wayland-scanner) + pkg_check_modules(WAYLAND_CLIENT_PC wayland-client) + pkg_check_modules(WAYLAND_CURSOR_PC wayland-cursor) + pkg_check_modules(XKBCOMMON_PC xkbcommon) +endif() + +find_program(WAYLAND_SCANNER wayland-scanner HINTS "${WAYLAND_SCANNER_PC_PREFIX}/bin") + +find_path(WAYLAND_INCLUDE_DIR wayland-client.h HINTS ${WAYLAND_CLIENT_PC_INCLUDE_DIRS}) + +find_library(WAYLAND_CLIENT_LIB NAMES "wayland-client" HINTS "${WAYLAND_CLIENT_PC_LIBRARY_DIRS}") + +find_library(WAYLAND_CURSOR_LIB NAMES "wayland-cursor" HINTS "${WAYLAND_CURSOR_PC_LIBRARY_DIRS}") + +if(WAYLAND_CLIENT_LIB AND WAYLAND_CURSOR_LIB) + list(APPEND WAYLAND_LIBS ${WAYLAND_CLIENT_LIB} ${WAYLAND_CURSOR_LIB}) +endif(WAYLAND_CLIENT_LIB AND WAYLAND_CURSOR_LIB) + +find_path(XKBCOMMON_INCLUDE_DIR xkbcommon/xkbcommon.h HINTS ${XKBCOMMON_PC_INCLUDE_DIRS}) + +find_library(XKBCOMMON_LIBS NAMES xkbcommon HINTS "${XKBCOMMON_PC_LIBRARY_DIRS}") + +set(Wayland_SCANNER ${WAYLAND_SCANNER}) +set(Wayland_INCLUDE_DIR ${WAYLAND_INCLUDE_DIR}) +set(Wayland_LIBS ${WAYLAND_LIBS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Wayland + DEFAULT_MSG + Wayland_SCANNER + Wayland_INCLUDE_DIR + Wayland_LIBS + XKBCOMMON_INCLUDE_DIR + XKBCOMMON_LIBS +) + +set(WAYLAND_FOUND ${Wayland_FOUND}) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibsystemd.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibsystemd.cmake new file mode 100644 index 0000000000000000000000000000000000000000..dde8f48f59e6695581ac7442e6930877c3cdd766 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibsystemd.cmake @@ -0,0 +1,37 @@ +# Module defines +# LIBSYSTEMD_FOUND - libsystemd libraries and includes found +# LIBSYSTEMD_INCLUDE_DIRS - the libsystemd include directories +# LIBSYSTEMD_LIBRARIES - the libsystemd libraries +# +# Cache entries: +# LIBSYSTEMD_LIBRARY - detected libsystemd library +# LIBSYSTEMD_INCLUDE_DIR - detected libsystemd include dir(s) +# + +if(LIBSYSTEMD_INCLUDE_DIR AND LIBSYSTEMD_LIBRARY) + # in cache already + set(LIBSYSTEMD_FOUND TRUE) + set(LIBSYSTEMD_LIBRARIES ${LIBSYSTEMD_LIBRARY}) + set(LIBSYSTEMD_INCLUDE_DIRS ${LIBSYSTEMD_INCLUDE_DIR}) +else() + + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(_LIBSYSTEMD_PC QUIET "libsystemd") + endif(PKG_CONFIG_FOUND) + + find_path(LIBSYSTEMD_INCLUDE_DIR systemd/sd-journal.h ${_LIBSYSTEMD_PC_INCLUDE_DIRS} /usr/include /usr/local/include) + mark_as_advanced(LIBSYSTEMD_INCLUDE_DIR) + + find_library(LIBSYSTEMD_LIBRARY NAMES systemd PATHS ${_LIBSYSTEMD_PC_LIBDIR}) + mark_as_advanced(LIBSYSTEMD_LIBRARY) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(libsystemd DEFAULT_MSG LIBSYSTEMD_LIBRARY LIBSYSTEMD_INCLUDE_DIR) + + if(libsystemd_FOUND) + set(LIBSYSTEMD_LIBRARIES ${LIBSYSTEMD_LIBRARY}) + set(LIBSYSTEMD_INCLUDE_DIRS ${LIBSYSTEMD_INCLUDE_DIR}) + endif() + +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibusb-1.0.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibusb-1.0.cmake new file mode 100644 index 0000000000000000000000000000000000000000..35b135168a6126c0efd118386adde5f0e36b9ff6 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlibusb-1.0.cmake @@ -0,0 +1,77 @@ +# - Try to find libusb-1.0 +# Once done this will define +# +# LIBUSB_1_FOUND - system has libusb +# LIBUSB_1_INCLUDE_DIRS - the libusb include directory +# LIBUSB_1_LIBRARIES - Link these to use libusb +# LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb +# +# Adapted from cmake-modules Google Code project +# +# Copyright (c) 2006 Andreas Schneider +# +# (Changes for libusb) Copyright (c) 2008 Kyle Machulis +# +# Redistribution and use is allowed according to the terms of the New BSD license. +# +# CMake-Modules Project New BSD License +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the CMake-Modules Project nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +if(LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) + # in cache already + set(LIBUSB_FOUND TRUE) +else(LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) + find_path(LIBUSB_1_INCLUDE_DIR NAMES libusb.h PATHS /usr/include /usr/local/include /sw/include + PATH_SUFFIXES libusb-1.0 + ) + + find_library(LIBUSB_1_LIBRARY NAMES libusb-1.0 usb-1.0 usb PATHS /usr/lib /usr/local/lib /sw/lib) + + set(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR}) + set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY}) + + if(LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES) + set(LIBUSB_1_FOUND TRUE) + endif(LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES) + + if(LIBUSB_1_FOUND) + if(NOT libusb_1_FIND_QUIETLY) + message(STATUS "Found libusb-1.0:") + message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}") + message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}") + endif(NOT libusb_1_FIND_QUIETLY) + else(LIBUSB_1_FOUND) + if(libusb_1_FIND_REQUIRED) + message(FATAL_ERROR "Could not find libusb") + endif(libusb_1_FIND_REQUIRED) + endif(LIBUSB_1_FOUND) + + # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view + mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES) + +endif(LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlodepng.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlodepng.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2c3e147910285727c1e0fabe5ae9b9ef20c1d8a3 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findlodepng.cmake @@ -0,0 +1,17 @@ +# - Try to find lodepng +# Once done this will define +# lodepng_FOUND - lodepng was found +# lodepng_INCLUDE_DIRS - lodepng include directories +# lodepng_LIBRARIES - lodepng libraries for linking + +find_path(lodepng_INCLUDE_DIR NAMES lodepng.h) + +find_library(lodepng_LIBRARY NAMES lodepng) + +if(lodepng_INCLUDE_DIR AND lodepng_LIBRARY) + set(lodepng_FOUND ON) + set(lodepng_INCLUDE_DIRS ${lodepng_INCLUDE_DIR}) + set(lodepng_LIBRARIES ${lodepng_LIBRARY}) +endif() + +mark_as_advanced(lodepng_INCLUDE_DIRS lodepng_LIBRARIES) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/Findsoxr.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findsoxr.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f8953057e523b8e5f952268268f2072cdc0a943f --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/Findsoxr.cmake @@ -0,0 +1,56 @@ +# Try to find the soxr library +# +# Copyright 2018 Thincast Technologies GmbH +# Copyright 2018 Armin Novak +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# +# Once done this will define +# +# SOXR_ROOT - A list of search hints +# +# SOXR_FOUND - system has soxr +# SOXR_INCLUDE_DIR - the soxr include directory +# SOXR_LIBRARIES - libsoxr library + +if(UNIX AND NOT ANDROID) + find_package(PkgConfig QUIET) + pkg_check_modules(PC_SOXR QUIET soxr) +endif(UNIX AND NOT ANDROID) + +if(SOXR_INCLUDE_DIR AND SOXR_LIBRARY) + set(SOXR_FIND_QUIETLY TRUE) +endif(SOXR_INCLUDE_DIR AND SOXR_LIBRARY) + +find_path(SOXR_INCLUDE_DIR NAMES soxr.h PATH_SUFFIXES include HINTS ${SOXR_ROOT} ${PC_SOXR_INCLUDE_DIRS}) +find_library(SOXR_LIBRARY NAMES soxr PATH_SUFFIXES lib HINTS ${SOXR_ROOT} ${PC_SOXR_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(soxr DEFAULT_MSG SOXR_LIBRARY SOXR_INCLUDE_DIR) + +if(SOXR_INCLUDE_DIR AND SOXR_LIBRARY) + set(SOXR_FOUND TRUE) + set(SOXR_INCLUDE_DIRS ${SOXR_INCLUDE_DIR}) + set(SOXR_LIBRARIES ${SOXR_LIBRARY}) +endif(SOXR_INCLUDE_DIR AND SOXR_LIBRARY) + +if(SOXR_FOUND) + if(NOT SOXR_FIND_QUIETLY) + message(STATUS "Found soxr: ${SOXR_LIBRARIES}") + endif(NOT SOXR_FIND_QUIETLY) +else(SOXR_FOUND) + if(SOXR_FIND_REQUIRED) + message(FATAL_ERROR "soxr was not found") + endif(SOXR_FIND_REQUIRED) +endif(SOXR_FOUND) + +mark_as_advanced(SOXR_INCLUDE_DIR SOXR_LIBRARY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/GNUInstallDirsWrapper.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/GNUInstallDirsWrapper.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a79484b6a853db51b2388b7c77a4988ae78288ca --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/GNUInstallDirsWrapper.cmake @@ -0,0 +1,21 @@ +# GNUInstallDirs is a relatively new cmake module, so wrap it to avoid errors +include(GNUInstallDirs OPTIONAL RESULT_VARIABLE GID_PATH) +if(GID_PATH STREQUAL "NOTFOUND") + if(NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") + endif() + + if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}" CACHE PATH "object code libraries (lib)") + endif() + + foreach(dir BINDIR LIBDIR) + if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + else() + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") + endif() + endforeach() + + mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/GenerateManpages.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/GenerateManpages.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c41634a2c18b58ea1aecf8bd48a003f51cd8cef8 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/GenerateManpages.cmake @@ -0,0 +1,46 @@ +get_filename_component(GENERATE_MANPAGES_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) +list(APPEND CMAKE_MODULE_PATH ${GENERATE_MANPAGES_SCRIPT_DIR}) + +set(SRC "${CURRENT_SOURCE_DIR}/${target}.${section}.in") +configure_file(${SRC} ${manpage}.tmp @ONLY IMMEDIATE) + +# write header (aka name of the manpage), truncate existing +file(READ ${CURRENT_BINARY_DIR}/${manpage}.tmp CONTENTS) +file(WRITE ${CURRENT_BINARY_DIR}/${manpage} "${CONTENTS}") + +string(REPLACE " " ";" DEPS ${dependencies}) +foreach(DEP IN LISTS DEPS) + get_filename_component(DNAME "${DEP}" NAME) + set(SRC_IN ${CURRENT_SOURCE_DIR}/${DEP}.in) + set(DST_IN ${CURRENT_BINARY_DIR}/${DEP}.in) + set(SRC ${CURRENT_SOURCE_DIR}/${DEP}) + set(BIN ${CURRENT_BINARY_DIR}/${DEP}) + set(DST ${CURRENT_BINARY_DIR}/${DNAME}) + + if(EXISTS ${SRC_IN}) + message("using generated ${DST} from ${SRC_IN}") + configure_file(${SRC_IN} ${DST} @ONLY IMMEDIATE) + elseif(EXISTS ${DST_IN}) + message("using generated ${DST} from ${DST_IN}") + configure_file(${DST_IN} ${DST} @ONLY IMMEDIATE) + elseif(EXISTS ${SRC}) + set(DST ${SRC}) + message("using ${DST}") + elseif(EXISTS ${BIN}) + set(DST ${BIN}) + message("using ${DST}") + elseif(EXISTS ${DST}) + message("using ${DST}") + else() + message(WARNING "Missing manpage section, considered:") + message(WARNING " ${SRC_IN}") + message(WARNING " ${DST_IN}") + message(WARNING " ${SRC}") + message(WARNING " ${BIN}") + message(WARNING " ${DST}") + message(FATAL_ERROR "Can not continue, terminating") + endif() + + file(READ ${DST} CONTENTS) + file(APPEND ${CURRENT_BINARY_DIR}/${manpage} "${CONTENTS}") +endforeach() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9d0a052f9c9f173c16db305978715c0512b5e289 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,128 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + + set(GIT_PARENT_DIR "${PROJECT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_rev_parse _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + get_git_head_revision(refspec hash) + if(NOT hash) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse ${ARGN} ${hash} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" RESULT_VARIABLE res + OUTPUT_VARIABLE out ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT res EQUAL 0) + set(out "n/a") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + get_git_head_revision(refspec hash) + if(NOT hash) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN} WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" RESULT_VARIABLE res + OUTPUT_VARIABLE out ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT res EQUAL 0) + set(out "n/a") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake.in b/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..888ce13aaba354f5d7d7946dd661963278dc8fc2 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPDesktop.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPDesktop.cmake new file mode 100644 index 0000000000000000000000000000000000000000..015a6b5ce273da5b1cba420239c9b36e45424942 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPDesktop.cmake @@ -0,0 +1,22 @@ +include(GNUInstallDirs) + +option(WITH_INSTALL_CLIENT_DESKTOP_FILES "Install .desktop files for clients" OFF) + +set(DESKTOP_RESOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../resources" CACHE INTERNAL "") + +function(install_freerdp_desktop name) + if(WITH_INSTALL_CLIENT_DESKTOP_FILES) + get_target_property(FREERDP_APP_NAME ${name} OUTPUT_NAME) + set(FREERDP_BIN_NAME "${CMAKE_INSTALL_FULL_BINDIR}/${FREERDP_APP_NAME}") + set(FREERDP_DESKTOP_NAME "${CMAKE_CURRENT_BINARY_DIR}/${FREERDP_BIN_NAME}.desktop") + set(FREERDP_DESKTOP_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${FREERDP_BIN_NAME}-file.desktop") + configure_file(${DESKTOP_RESOURCE_DIR}/freerdp.desktop.template ${FREERDP_DESKTOP_NAME} @ONLY) + configure_file(${DESKTOP_RESOURCE_DIR}/freerdp-file.desktop.template ${FREERDP_DESKTOP_FILE_NAME} @ONLY) + install(FILES ${FREERDP_DESKTOP_NAME} ${FREERDP_DESKTOP_FILE_NAME} + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications + ) + install(FILES ${DESKTOP_RESOURCE_DIR}/FreeRDP_Icon.svg + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps RENAME FreeRDP.svg + ) + endif() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPMan.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPMan.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6dba37e8e69c424e21a775ff3e847cbe2612995a --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/InstallFreeRDPMan.cmake @@ -0,0 +1,71 @@ +include(today) +include(GNUInstallDirs) +include(CleaningConfigureFile) + +get_filename_component(INSTALL_FREERDP_MAN_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) + +function(install_freerdp_man manpage section) + if(WITH_MANPAGES) + install(FILES ${manpage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}) + endif() +endfunction() + +function(generate_and_install_freerdp_man_from_template name_base section api) + if(WITH_MANPAGES) + if(WITH_BINARY_VERSIONING) + set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}${api}.${section}") + else() + set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}.${section}") + endif() + cleaning_configure_file(${name_base}.${section}.in ${manpage}) + install_freerdp_man(${manpage} ${section}) + endif() +endfunction() + +# Generate an install target for a manpage. +# +# This is not as simple as it looks like: +# +# 1. extract the raw file names (files that require configure_file end with .in, ready to use files +# with .1 or some other manpage related number) +# 2. do the same for every dependency +# 3. create a command to run during build. Add a few defined symbols by default +# 4. add variable names passed to the function to the command +# 5. run CMake -P as custom_target during build. +# * run configure_file for all .in files +# * concatenate all manpage sections to the target manpage +# 6. create the actual install target +function(generate_and_install_freerdp_man_from_xml target section dependencies variable_names) + if(WITH_MANPAGES) + get_target_property(name_base "${target}" OUTPUT_NAME) + set(template "${target}.${section}") + set(MANPAGE_NAME "${name_base}") + set(manpage "${name_base}.${section}") + + # We need the variable ${MAN_TODAY} to contain the current date in ISO + # format to replace it in the cleaning_configure_file step. + include(today) + + today(MAN_TODAY) + + set(GENERATE_COMMAND + -Dtemplate=\"${template}\" -DMANPAGE_NAME=\"${MANPAGE_NAME}\" -Dmanpage=\"${manpage}\" + -DMAN_TODAY=\"${MAN_TODAY}\" -DCURRENT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\" + -DCURRENT_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" -Dtarget="${target}" -Dsection="${section}" + -Ddependencies="${dependencies}" + ) + + foreach(var IN ITEMS ${variable_names}) + list(APPEND GENERATE_COMMAND -D${var}=${${var}}) + endforeach() + + list(APPEND GENERATE_COMMAND -P \"${INSTALL_FREERDP_MAN_SCRIPT_DIR}/GenerateManpages.cmake\") + + add_custom_target( + ${manpage}.target ALL COMMAND ${CMAKE_COMMAND} ${GENERATE_COMMAND} DEPENDS generate_argument_manpage.target + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + + install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${manpage} ${section}) + endif() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/JsonDetect.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/JsonDetect.cmake new file mode 100644 index 0000000000000000000000000000000000000000..af7628d039bf5d360a8bf7b1fcaf7d219af923a2 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/JsonDetect.cmake @@ -0,0 +1,49 @@ +include(CMakeDependentOption) + +option(WITH_JSON_DISABLED "Build without any JSON support" OFF) +cmake_dependent_option(WITH_CJSON_REQUIRED "Build with cJSON (fail if not found)" OFF "NOT WITH_JSON_DISABLED" OFF) +cmake_dependent_option(WITH_JSONC_REQUIRED "Build with JSON-C (fail if not found)" OFF "NOT WITH_JSON_DISABLED" OFF) +if(NOT WITH_JSON_DISABLED) + find_package(cJSON) + + # Fallback detection: + # older ubuntu releases did not ship CMake or pkg-config files + # for cJSON. Be optimistic and try pkg-config and as last resort + # try manual detection + if(NOT CJSON_FOUND) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(CJSON libcjson) + endif() + + if(NOT CJSON_FOUND) + find_path(CJSON_INCLUDE_DIRS NAMES cjson/cJSON.h) + find_library(CJSON_LIBRARIES NAMES cjson) + if(NOT "${CJSON_LIBRARIES}" STREQUAL "CJSON_LIBRARIES-NOTFOUND" AND NOT "${CJSON_INCLUDE_DIRS}" STREQUAL + "CJSON_INCLUDE_DIRS-NOTFOUND" + ) + set(CJSON_FOUND ON) + endif() + endif() + endif() + + if(WITH_CJSON_REQUIRED) + if(NOT CJSON_FOUND) + message(FATAL_ERROR "cJSON was requested but not found") + endif() + endif() + + if(WITH_JSONC_REQUIRED) + find_package(JSONC REQUIRED) + else() + find_package(JSONC) + endif() + + if(NOT JSONC_FOUND AND NOT CJSON_FOUND) + set(WITH_WINPR_JSON OFF CACHE INTERNAL "internal") + message("compiling without JSON support. Install cJSON or json-c to enable") + endif() +else() + set(WITH_WINPR_JSON OFF CACHE INTERNAL "internal") + message("forced compile without JSON support. Set -DWITH_JSON_DISABLED=OFF to enable compile time detection") +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/LibFindMacros.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/LibFindMacros.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3350435ffb57f39668c351fdafd3fe56c6017f18 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/LibFindMacros.cmake @@ -0,0 +1,115 @@ +# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments +# used for the current package. For this to work, the first parameter must be the +# prefix of the current package, then the prefix of the new package etc, which are +# passed to find_package. +macro(libfind_package PREFIX) + set(LIBFIND_PACKAGE_ARGS $ {ARGN}) + if($ {PREFIX} _FIND_QUIETLY) + set(LIBFIND_PACKAGE_ARGS $ {LIBFIND_PACKAGE_ARGS} QUIET) + endif($ {PREFIX} _FIND_QUIETLY) + if($ {PREFIX} _FIND_REQUIRED) + set(LIBFIND_PACKAGE_ARGS $ {LIBFIND_PACKAGE_ARGS} REQUIRED) + endif($ {PREFIX} _FIND_REQUIRED) + find_package($ {LIBFIND_PACKAGE_ARGS}) +endmacro(libfind_package) + +# CMake developers made the UsePkgConfig system deprecated in the same release (2.6) +# where they added pkg_check_modules. Consequently I need to support both in my scripts +# to avoid those deprecated warnings. Here's a helper that does just that. +# Works identically to pkg_check_modules, except that no checks are needed prior to use. +macro(libfind_pkg_check_modules PREFIX PKGNAME) + if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) + else(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(${PREFIX} ${PKGNAME}) + endif(PKG_CONFIG_FOUND) + endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) +endmacro(libfind_pkg_check_modules) + +# Do the final processing once the paths have been detected. +# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain +# all the variables, each of which contain one include directory. +# Ditto for ${PREFIX}_PROCESS_LIBS and library files. +# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. +# Also handles errors in case library detection was required, etc. +macro(libfind_process PREFIX) + # Skip processing if already processed during this run + if(NOT ${PREFIX}_FOUND) + # Start with the assumption that the library was found + set(${PREFIX}_FOUND TRUE) + + # Process all includes and set _FOUND to false if any are missing + foreach(i ${${PREFIX}_PROCESS_INCLUDES}) + if(${i}) + set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) + mark_as_advanced(${i}) + else(${i}) + set(${PREFIX}_FOUND FALSE) + endif(${i}) + endforeach(i) + + # Process all libraries and set _FOUND to false if any are missing + foreach(i ${${PREFIX}_PROCESS_LIBS}) + if(${i}) + set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) + mark_as_advanced(${i}) + else(${i}) + set(${PREFIX}_FOUND FALSE) + endif(${i}) + endforeach(i) + + # Print message and/or exit on fatal error + if(${PREFIX}_FOUND) + if(NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") + endif(NOT ${PREFIX}_FIND_QUIETLY) + else(${PREFIX}_FOUND) + if(${PREFIX}_FIND_REQUIRED) + foreach(i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) + message("${i}=${${i}}") + endforeach(i) + message( + FATAL_ERROR + "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually." + ) + endif(${PREFIX}_FIND_REQUIRED) + endif(${PREFIX}_FOUND) + endif(NOT ${PREFIX}_FOUND) +endmacro(libfind_process) + +macro(libfind_library PREFIX basename) + set(TMP "") + if(MSVC80) + set(TMP -vc80) + endif(MSVC80) + if(MSVC90) + set(TMP -vc90) + endif(MSVC90) + set(${PREFIX}_LIBNAMES ${basename}${TMP}) + if(${ARGC} GREATER 2) + set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) + string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) + set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) + endif(${ARGC} GREATER 2) + find_library(${PREFIX}_LIBRARY NAMES ${${PREFIX}_LIBNAMES} PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) +endmacro(libfind_library) + +set(THREE_PART_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+") +# Breaks up a string in the form n1.n2.n3 into three parts and stores +# them in major, minor, and patch. version should be a value, not a +# variable, while major, minor and patch should be variables. +macro(THREE_PART_VERSION_TO_VARS version major minor patch) + if(${version} MATCHES ${THREE_PART_VERSION_REGEX}) + string(REPLACE "." " " version_list ${version}) + separate_arguments(version_list) + list(GET version_list 0 ${major}) + list(GET version_list 1 ${minor}) + list(GET version_list 2 ${patch}) + else(${version} MATCHES ${THREE_PART_VERSION_REGEX}) + message("MACRO(THREE_PART_VERSION_TO_VARS ${version} ${major} ${minor} ${patch}") + message(FATAL_ERROR "Problem parsing version string, I can't parse it properly.") + endif(${version} MATCHES ${THREE_PART_VERSION_REGEX}) +endmacro(THREE_PART_VERSION_TO_VARS) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ListTargetProperties.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ListTargetProperties.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e38bd3d32205776496fdcabaf72bcc7409b1cbfe --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ListTargetProperties.cmake @@ -0,0 +1,35 @@ +# Get all properties that cmake supports +if(NOT CMAKE_PROPERTY_LIST) + execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST) + + # Convert command output into a CMake list + string(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") + string(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") + list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST) +endif() + +function(print_properties) + message("CMAKE_PROPERTY_LIST = ${CMAKE_PROPERTY_LIST}") +endfunction() + +function(list_target_properties target) + if(NOT TARGET ${target}) + message(STATUS "There is no target named '${target}'") + return() + endif() + + foreach(property ${CMAKE_PROPERTY_LIST}) + string(REPLACE "" "${CMAKE_BUILD_TYPE}" property ${property}) + + # Fix https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i + if(property STREQUAL "LOCATION" OR property MATCHES "^LOCATION_" OR property MATCHES "_LOCATION$") + continue() + endif() + + get_property(was_set TARGET ${target} PROPERTY ${property} SET) + if(was_set) + get_target_property(value ${target} ${property}) + message("${target} ${property} = ${value}") + endif() + endforeach() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/MSVCRuntime.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/MSVCRuntime.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2aafd7255f7eee820b63df961f8b91f5939c9ee7 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/MSVCRuntime.cmake @@ -0,0 +1,47 @@ +if(MSVC) + if(CMAKE_VERSION VERSION_LESS 3.15.0) + message(FATAL_ERROR "windows builds require CMake >= 3.15") + endif() + if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + if(MSVC_RUNTIME STREQUAL "dynamic") + set(MSVC_DEFAULT_RUNTIME "MultiThreadedDLL") + elseif(MSVC_RUNTIME STREQUAL "static") + set(MSVC_DEFAULT_RUNTIME "MultiThreaded") + else() + message(WARNING "invalid MSVC_RUNTIME (deprecated) value '${MSVC_RUNTIME}', ignoring") + endif() + + if(MSVC_DEFAULT_RUNTIME) + message( + "Using CMAKE_MSVC_RUNTIME_LIBRARY=${MSVC_DEFAULT_RUNTIME} (derived from MSVC_RUNTIME (deprecated) value '${MSVC_RUNTIME}')" + ) + else() + set(MSVC_DEFAULT_RUNTIME "MultiThreaded") + + string(APPEND MSVC_DEFAULT_RUNTIME "$<$:Debug>") + + if(BUILD_SHARED_LIBS) + string(APPEND MSVC_DEFAULT_RUNTIME "DLL") + endif() + message("Using CMAKE_MSVC_RUNTIME_LIBRARY=${MSVC_DEFAULT_RUNTIME}") + endif() + + set(CMAKE_MSVC_RUNTIME_LIBRARY ${MSVC_DEFAULT_RUNTIME} CACHE STRING "MSVC runtime") + endif() + + message("build is using MSVC runtime ${CMAKE_MSVC_RUNTIME_LIBRARY}") + + string(FIND ${CMAKE_MSVC_RUNTIME_LIBRARY} "DLL" IS_SHARED) + if(IS_SHARED STREQUAL "-1") + if(BUILD_SHARED_LIBS) + message(FATAL_ERROR "Static CRT is only supported in a fully static build") + endif() + message(STATUS "Use the MSVC static runtime option carefully!") + message(STATUS "OpenSSL uses /MD by default, and is very picky") + message(STATUS "Random freeing errors are a common sign of runtime issues") + endif() + + if(NOT DEFINED CMAKE_SUPPRESS_REGENERATION) + set(CMAKE_SUPPRESS_REGENERATION ON) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/MergeStaticLibs.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/MergeStaticLibs.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b803ba37610bbdf1b17d723eaf27c86701658b57 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/MergeStaticLibs.cmake @@ -0,0 +1,151 @@ +# Copyright (C) 2012 Modelon AB + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the BSD style license. + +# 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 +# FMILIB_License.txt file for more details. + +# You should have received a copy of the FMILIB_License.txt file +# along with this program. If not, contact Modelon AB . + +# Merge_static_libs(output_library lib1 lib2 ... libn) merges a number of static +# libs into a single static library +function(merge_static_libs output_library) + set(output_target "${output_library}") + string(REGEX REPLACE "-" "_" output_library ${output_library}) + set(libs ${ARGV}) + list(REMOVE_AT libs 0) + + # Create a dummy file that the target will depend on + set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${output_library}_dummy.c) + file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") + + add_library(${output_target} STATIC ${dummyfile}) + + if("${CMAKE_CFG_INTDIR}" STREQUAL ".") + set(multiconfig FALSE) + else() + set(multiconfig TRUE) + endif() + + # First get the file names of the libraries to be merged + foreach(lib ${libs}) + get_target_property(libtype ${lib} TYPE) + if(NOT libtype STREQUAL "STATIC_LIBRARY") + message(FATAL_ERROR "Merge_static_libs can only process static libraries") + endif() + if(multiconfig) + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}") + list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}}) + endforeach() + else() + get_target_property(libfile ${lib} LOCATION) + list(APPEND libfiles "${libfile}") + endif(multiconfig) + endforeach() + + # Just to be sure: cleanup from duplicates + if(multiconfig) + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE}) + set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}}) + endforeach() + endif() + list(REMOVE_DUPLICATES libfiles) + + # Now the easy part for MSVC and for MAC + if(MSVC) + # lib.exe does the merging of libraries just need to convert the list into string + foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + set(flags "") + foreach(lib ${libfiles_${CONFIG_TYPE}}) + set(flags "${flags} ${lib}") + endforeach() + string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) + set_target_properties(${output_target} PROPERTIES ${PROPNAME} "${flags}") + endforeach() + + elseif(APPLE) + # Use OSX's libtool to merge archives + if(multiconfig) + message(FATAL_ERROR "Multiple configurations are not supported") + endif() + get_target_property(outfile ${output_target} LOCATION) + add_custom_command( + TARGET ${output_target} POST_BUILD COMMAND rm ${outfile} COMMAND /usr/bin/libtool -static -o ${outfile} + ${libfiles} + ) + else() + # general UNIX - need to "ar -x" and then "ar -ru" + if(multiconfig) + message(FATAL_ERROR "Multiple configurations are not supported") + endif() + get_target_property(outfile ${output_target} LOCATION) + message(STATUS "output file location is ${outfile}") + foreach(lib ${libfiles}) + # objlistfile will contain the list of object files for the library + set(objlistfile ${lib}.objlist) + set(objdir ${lib}.objdir) + set(objlistcmake ${objlistfile}.cmake) + get_filename_component(libname ${lib} NAME_WE) + + if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake}) + + file( + WRITE ${objlistcmake} + " + # delete previous object files + message(STATUS \"Removing previous object files from ${lib}\") + EXECUTE_PROCESS(COMMAND ls . + WORKING_DIRECTORY ${objdir} + COMMAND xargs -I {} rm {} + WORKING_DIRECTORY ${objdir}) + # Extract object files from the library + message(STATUS \"Extracting object files from ${lib}\") + EXECUTE_PROCESS(COMMAND ${CMAKE_AR} -x ${lib} + WORKING_DIRECTORY ${objdir}) + # Prefixing object files to avoid conflicts + message(STATUS \"Prefixing object files to avoid conflicts\") + EXECUTE_PROCESS(COMMAND ls . + WORKING_DIRECTORY ${objdir} + COMMAND xargs -I {} mv {} ${libname}_{} + WORKING_DIRECTORY ${objdir}) + # save the list of object files + EXECUTE_PROCESS(COMMAND ls . + OUTPUT_FILE ${objlistfile} + WORKING_DIRECTORY ${objdir}) + " + ) + + file(MAKE_DIRECTORY ${objdir}) + + add_custom_command(OUTPUT ${objlistfile} COMMAND ${CMAKE_COMMAND} -P ${objlistcmake} DEPENDS ${lib}) + + endif() + + list(APPEND extrafiles "${objlistfile}") + # relative path is needed by ar under MSYS + file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile}) + add_custom_command( + TARGET ${output_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo + "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}" + COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}" + #COMMAND ld -r -static -o "${outfile}" --whole-archive @"${objlistfilerpath}" + WORKING_DIRECTORY ${objdir} + ) + endforeach() + add_custom_command( + TARGET ${output_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}" + COMMAND ${CMAKE_RANLIB} ${outfile} + ) + endif() + file(WRITE ${dummyfile}.base "const char* ${output_library}_sublibs=\"${libs}\";") + add_custom_command( + OUTPUT ${dummyfile} COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile} DEPENDS ${libs} ${extrafiles} + ) + +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/PlatformDefaults.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/PlatformDefaults.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b3d4356db303bfe8217d94dfa02374ae6ea0ccda --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/PlatformDefaults.cmake @@ -0,0 +1,110 @@ +# This option allows deactivating FreeRDP supplied platform defaults to replace these with +# user supplied values. +# +# Compilation will fail without a replacement defining the symbols, but that can be +# done by supplying a TOOLCHAIN_FILE defining these. +option(USE_PLATFORM_DEFAULT + "Use this configuration file for platform defaults. Supply -DCMAKE_TOOLCHAIN_FILE=." ON +) +if(USE_PLATFORM_DEFAULT) + # default defines or other required preferences per platform + if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0")) + set(UWP 1 CACHE BOOL "platform default") + add_compile_definitions("_UWP") + set(CMAKE_WINDOWS_VERSION "WIN10" CACHE STRING "platform default") + endif() + + if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + # Linux already does define _POSIX_C_SOURCE by default, nothing to do + add_compile_definitions("_FILE_OFFSET_BITS=64") + set(WINPR_TIMEZONE_FILE "/etc/timezone") + endif() + + if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") + set(BSD TRUE CACHE INTERNAL "platform default") + set(FREEBSD TRUE CACHE INTERNAL "platform default") + # we want POSIX 2008. FreeBSD 14 does only support 2001 fully, but the subset we require from 2008 + # is implemented, so ignore _POSIX_VERSION from unistd.h + add_compile_definitions("_POSIX_C_SOURCE=200809L") + # TODO: FreeBSD allows mixing POSIX and BSD API calls if we do not set + # _POSIX_C_SOURCE but lack a macro to re-enable the BSD calls... + add_compile_definitions("__BSD_VISIBLE") + + # There are some symbols only visible for XOpen standard + add_compile_definitions("_XOPEN_SOURCE=700") + add_compile_definitions("_FILE_OFFSET_BITS=64") + set(WINPR_TIMEZONE_FILE "/var/db/zoneinfo") + endif() + + if("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS") + # TODO: Does somebody still use this? please show yourself and + # tell us if this still works. + add_compile_definitions("_POSIX_PTHREAD_SEMANTICS") + list(APPEND CMAKE_STANDARD_LIBRARIES rt) + set(CMAKE_STANDARD_LIBRARIES ${CMAKE_STANDARD_LIBRARIES} CACHE STRING "platform default") + set(WITH_SUN true CACHE BOOL "platform default") + endif() + + if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + # we want POSIX 2008. MacOS does only support 2001 fully, but the subset we require from 2008 + # is implemented, so ignore _POSIX_VERSION from unistd.h + add_compile_definitions("_POSIX_C_SOURCE=200809L") + + # as _POSIX_C_SOURCE sets a fully POSIX confirmant environment re-enable + # MacOS API visibility by defining the following feature test macro + add_compile_definitions("_DARWIN_C_SOURCE") + endif() + + if(${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD") + set(BSD TRUE CACHE INTERNAL "platform default") + set(KFREEBSD TRUE CACHE INTERNAL "platform default") + add_compile_definitions(KFREEBSD) + add_compile_definitions("_GNU_SOURCE") + endif() + + if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") + set(BSD TRUE CACHE INTERNAL "platform default") + set(OPENBSD TRUE CACHE INTERNAL "platform default") + endif() + + if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly") + set(BSD TRUE CACHE INTERNAL "platform default") + set(FREEBSD TRUE CACHE INTERNAL "platform default") + + # we want POSIX 2008. FreeBSD 14 does only support 2001 fully, but the subset we require from 2008 + # is implemented, so ignore _POSIX_VERSION from unistd.h + add_compile_definitions("_POSIX_C_SOURCE=200809L") + # TODO: FreeBSD allows mixing POSIX and BSD API calls if we do not set + # _POSIX_C_SOURCE but lack a macro to re-enable the BSD calls... + add_compile_definitions("__BSD_VISIBLE") + + # There are some symbols only visible for XOpen standard + add_compile_definitions("_XOPEN_SOURCE=700") + add_compile_definitions("_FILE_OFFSET_BITS=64") + set(WINPR_TIMEZONE_FILE "/var/db/zoneinfo") + endif() + + if(BSD) + if(IS_DIRECTORY /usr/local/include) + include_directories(SYSTEM /usr/local/include) + link_directories(/usr/local/lib) + endif() + if(OPENBSD) + if(IS_DIRECTORY /usr/X11R6/include) + include_directories(SYSTEM /usr/X11R6/include) + endif() + endif() + endif() + + # define a fallback for systems that do not support a timezone file or we did not yet test. + # since most of these are BSD try a sensible default + if(NOT WINPR_TIMEZONE_FILE) + set(WINPR_TIMEZONE_FILE "/var/db/zoneinfo") + endif() + add_compile_definitions("WINPR_TIMEZONE_FILE=\"${WINPR_TIMEZONE_FILE}\"") + + if(FREEBSD) + find_path(EPOLLSHIM_INCLUDE_DIR NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim) + find_library(EPOLLSHIM_LIBS NAMES epoll-shim libepoll-shim HINTS /usr/local/lib) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/PreventInSourceBuilds.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/PreventInSourceBuilds.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5fe93d86597c3d66a58b3c1b5ab7349dd756d61e --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/PreventInSourceBuilds.cmake @@ -0,0 +1,61 @@ +# PreventInSourceBuilds +# --------------------- +# +# Prevent in-source builds +# +# It is generally acknowledged that it is preferable to run CMake out of source, +# in a dedicated build directory. To prevent users from accidentally running +# CMake in the source directory, just include this module. + +option(ALLOW_IN_SOURCE_BUILD "[deprecated] Allow building in source tree" OFF) + +if(ALLOW_IN_SOURCE_BUILD) + set(CMAKE_DISABLE_SOURCE_CHANGES OFF CACHE INTERNAL "policy") + set(CMAKE_DISABLE_IN_SOURCE_BUILD OFF CACHE INTERNAL "policy") + if("${srcdir}" STREQUAL "${bindir}") + message(WARNING "Running in-source-tree build [ALLOW_IN_SOURCE_BUILD=ON]") + endif() +else() + set(CMAKE_DISABLE_SOURCE_CHANGES ON CACHE INTERNAL "policy") + set(CMAKE_DISABLE_IN_SOURCE_BUILD ON CACHE INTERNAL "policy") + + # make sure the user doesn't play dirty with symlinks + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) + get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + + # disallow in-source builds + if("${srcdir}" STREQUAL "${bindir}") + message( + FATAL_ERROR + "\ + +CMake must not to be run in the source directory. \ +Rather create a dedicated build directory and run CMake there. \ +CMake now already created some files, to clean up after this aborted in-source compilation: + rm -r CMakeCache.txt CMakeFiles +or + git clean -xdf + +If you happen to require in-source-tree builds for some reason rerun with -DALLOW_IN_SOURCE_BUILD=ON +" + ) + endif() + + # Check for remnants of in source builds + if(EXISTS "${CMAKE_SOURCE_DIR}/CMakeCache.txt" OR EXISTS "${CMAKE_SOURCE_DIR}/CMakeFiles") + message( + FATAL_ERROR + " \ + +Remnants of in source CMake run detected, aborting! + +To clean up after this aborted in-source compilation: + rm -r CMakeCache.txt CMakeFiles +or + git clean -xdf + +If you happen to require in-source-tree builds for some reason rerun with -DALLOW_IN_SOURCE_BUILD=ON +" + ) + endif() +endif() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/SetFreeRDPCMakeInstallDir.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/SetFreeRDPCMakeInstallDir.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7c4ac2cb30f4c5d72d194e3a8565c31afd4098b1 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/SetFreeRDPCMakeInstallDir.cmake @@ -0,0 +1,3 @@ +function(SetFreeRDPCMakeInstallDir SETVAR subdir) + set(${SETVAR} "${CMAKE_INSTALL_LIBDIR}/cmake/${subdir}" PARENT_SCOPE) +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ShowCMakeVars.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ShowCMakeVars.cmake new file mode 100644 index 0000000000000000000000000000000000000000..045a0b5da4ff55b5e0c25a21871da820168af306 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ShowCMakeVars.cmake @@ -0,0 +1,14 @@ +function(ShowCMakeVars) + get_cmake_property(_variableNames VARIABLES) + list(SORT _variableNames) + foreach(_variableName ${_variableNames}) + if(ARGV0) + unset(MATCHED) + string(REGEX MATCH ${ARGV0} MATCHED ${_variableName}) + if(NOT MATCHED) + continue() + endif() + endif() + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/WarnUnmaintained.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/WarnUnmaintained.cmake new file mode 100644 index 0000000000000000000000000000000000000000..62ff5eae4b00aaed00768c24ef756e2e047e91ff --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/WarnUnmaintained.cmake @@ -0,0 +1,14 @@ +macro(warn_unmaintained name) + message(WARNING "[unmaintained] ${name} is unmaintained!") + message(WARNING "[unmaintained] use at your own risk!") + message( + WARNING + "[unmaintained] If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for known issues, but be prepared to fix them on your own!" + ) + message(WARNING "[unmaintained] Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org") + message( + WARNING + "[unmaintained] - dont hesitate to ask some questions. (replies might take some time depending on your timezone)" + ) + message(WARNING "[unmaintained] - if you intend using this component write us a message") +endmacro() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/WebView2.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/WebView2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..52f012b62e3e6febba0e642798c8c32f922d3830 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/WebView2.cmake @@ -0,0 +1,41 @@ +if(WIN32) + # WebView2 SDK + set(WEBVIEW2_VERSION "1.0.2535.41") + set(WEBVIEW2_URL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}") + set(WEBVIEW2_SHA256 "c9c5518e4d7efa9079ad87bafb64f3c8e8edca0e95d34df878034b880a7af56b") + set(WEBVIEW2_DEFAULT_PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}") + + if(NOT EXISTS ${WEBVIEW2_PACKAGE_DIR}) + unset(WEBVIEW2_PACKAGE_DIR CACHE) + endif() + find_path(WEBVIEW2_PACKAGE_DIR NAMES "build/native/include/WebView2.h" + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH # dont prepend CMAKE_PREFIX + ) + if(NOT WEBVIEW2_PACKAGE_DIR) + message(WARNING "WebView2 SDK not found locally, downloading ${WEBVIEW2_VERSION} ...") + set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_DEFAULT_PACKAGE_DIR} CACHE PATH "WebView2 SDK PATH" FORCE) + file(DOWNLOAD ${WEBVIEW2_URL} ${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget EXPECTED_HASH SHA256=${WEBVIEW2_SHA256}) + file(MAKE_DIRECTORY ${WEBVIEW2_PACKAGE_DIR}) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E tar x "${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget" + WORKING_DIRECTORY "${WEBVIEW2_PACKAGE_DIR}" + ) + endif() + set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_PACKAGE_DIR} CACHE INTERNAL "" FORCE) +endif() + +function(target_link_webview2 target) + if(WIN32) + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID) + set(ARCH ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID) + set(ARCH ${CMAKE_C_COMPILER_ARCHITECTURE_ID}) + else() + message(FATAL_ERROR "Unknown CMAKE__COMPILER_ARCHITECTURE_ID") + endif() + target_include_directories(${target} PRIVATE "${WEBVIEW2_PACKAGE_DIR}/build/native/include") + target_link_libraries( + ${target} PRIVATE shlwapi version "${WEBVIEW2_PACKAGE_DIR}/build/native/${ARCH}/WebView2LoaderStatic.lib" + ) + endif() +endfunction() diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/WindowsDLLVersion.rc.in b/local-test-freerdp-delta-01/afc-freerdp/cmake/WindowsDLLVersion.rc.in new file mode 100644 index 0000000000000000000000000000000000000000..5a0da5eae4799179f705ab39fc39593361401531 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/WindowsDLLVersion.rc.in @@ -0,0 +1,35 @@ +#include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @RC_VERSION_MAJOR@,@RC_VERSION_MINOR@,@RC_VERSION_BUILD@,@RC_VERSION_PATCH@ + PRODUCTVERSION @RC_VERSION_MAJOR@,@RC_VERSION_MINOR@,@RC_VERSION_BUILD@,@RC_VERSION_PATCH@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "@RC_VERSION_VENDOR@" + VALUE "FileDescription", "@RC_VERSION_DESCRIPTION@" + VALUE "FileVersion", "@RC_VERSION_MAJOR@,@RC_VERSION_MINOR@,@RC_VERSION_PATCH@,@RC_VERSION_BUILD@" + VALUE "InternalName", "@RC_VERSION_FILE@" + VALUE "LegalCopyright", "Copyright (C) 2011-@RC_VERSION_YEAR@" + VALUE "OriginalFilename", "@RC_VERSION_FILE@" + VALUE "ProductName", "@RC_VERSION_PRODUCT@" + VALUE "ProductVersion", "@RC_VERSION_MAJOR@,@RC_VERSION_MINOR@,@RC_VERSION_BUILD@,@RC_VERSION_PATCH@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/ios.toolchain.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/ios.toolchain.cmake new file mode 100644 index 0000000000000000000000000000000000000000..36ace3783558ed3b57ceacfdc069c599525302de --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/ios.toolchain.cmake @@ -0,0 +1,977 @@ +# This file is part of the ios-cmake project. It was retrieved from +# https://github.com/leetal/ios-cmake.git, which is a fork of +# https://github.com/gerstrong/ios-cmake.git, which is a fork of +# https://github.com/cristeab/ios-cmake.git, which is a fork of +# https://code.google.com/p/ios-cmake/. Which in turn is based off of +# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which +# are included with CMake 2.8.4 +# +# The ios-cmake project is licensed under the new BSD license. +# +# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, +# Kitware, Inc., Insight Software Consortium. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file is based off of the Platform/Darwin.cmake and +# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 +# It has been altered for iOS development. +# +# Updated by Alex Stewart (alexs.mac@gmail.com) +# +# ***************************************************************************** +# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com) +# under the BSD-3-Clause license +# https://github.com/leetal/ios-cmake +# ***************************************************************************** +# +# INFORMATION / HELP +# +# The following options control the behaviour of this toolchain: +# +# PLATFORM: (default "OS64") +# OS = Build for iPhoneOS. +# OS64 = Build for arm64 iphoneOS. +# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY) +# SIMULATOR = Build for x86 i386 iphoneOS Simulator. +# SIMULATOR64 = Build for x86_64 iphoneOS Simulator. +# SIMULATORARM64 = Build for arm64 iphoneOS Simulator. +# TVOS = Build for arm64 tvOS. +# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) +# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator. +# WATCHOS = Build for armv7k arm64_32 for watchOS. +# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) +# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. +# MAC = Build for x86_64 macOS. +# MAC_ARM64 = Build for Apple Silicon macOS. +# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS). +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS +# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS). +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS +# +# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is +# automatically determined from PLATFORM and xcodebuild, but +# can also be manually specified (although this should not be required). +# +# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform +# being compiled for. By default this is automatically determined from +# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should +# not be required). +# +# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS +# +# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true) +# +# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default) +# +# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default) +# +# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker +# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY) +# +# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM +# OS = armv7 armv7s arm64 (if applicable) +# OS64 = arm64 (if applicable) +# SIMULATOR = i386 +# SIMULATOR64 = x86_64 +# SIMULATORARM64 = arm64 +# TVOS = arm64 +# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated) +# WATCHOS = armv7k arm64_32 (if applicable) +# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) +# MAC = x86_64 +# MAC_ARM64 = arm64 +# MAC_CATALYST = x86_64 +# MAC_CATALYST_ARM64 = arm64 +# +# This toolchain defines the following properties (available via get_property()) for use externally: +# +# PLATFORM: The currently targeted platform. +# XCODE_VERSION: Version number (not including Build version) of Xcode detected. +# SDK_VERSION: Version of SDK being used. +# OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM). +# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set! +# +# This toolchain defines the following macros for use externally: +# +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) +# A convenience macro for setting xcode specific properties on targets. +# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). +# +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the +# environment. Thanks to the android-cmake project for providing the +# command. +# + +cmake_minimum_required(VERSION 3.13) + +# CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. +if(DEFINED ENV{_IOS_TOOLCHAIN_HAS_RUN}) + return() +endif() +set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true) + +############################################################################### +# OPTIONS # +############################################################################### + +option(DROP_32_BIT "Drops the 32-bit targets universally." YES) + +############################################################################### +# END OPTIONS # +############################################################################### + +# List of supported platform values +list( + APPEND + _supported_platforms + "OS" + "OS64" + "OS64COMBINED" + "SIMULATOR" + "SIMULATOR64" + "SIMULATORARM64" + "TVOS" + "TVOSCOMBINED" + "SIMULATOR_TVOS" + "WATCHOS" + "WATCHOSCOMBINED" + "SIMULATOR_WATCHOS" + "MAC" + "MAC_ARM64" + "MAC_CATALYST" + "MAC_CATALYST_ARM64" +) + +# Cache what generator is used +set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}") + +# Check if using a CMake version capable of building combined FAT builds (simulator and target slices combined in one static lib) +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14") + set(MODERN_CMAKE YES) +endif() + +# Get the Xcode version being used. +# Problem: CMake runs toolchain files multiple times, but can't read cache variables on some runs. +# Workaround: On first run (in which cache variables are always accessible), set an intermediary environment variable. +# +# NOTE: This pattern is used i many places in this toolchain to speed up checks of all sorts +if(DEFINED XCODE_VERSION_INT) + # Environment variables are always preserved. + set(ENV{_XCODE_VERSION_INT} "${XCODE_VERSION_INT}") +elseif(DEFINED ENV{_XCODE_VERSION_INT}) + set(XCODE_VERSION_INT "$ENV{_XCODE_VERSION_INT}") +elseif(NOT DEFINED XCODE_VERSION_INT) + find_program(XCODEBUILD_EXECUTABLE xcodebuild) + if(NOT XCODEBUILD_EXECUTABLE) + message(FATAL_ERROR "xcodebuild not found. Please install either the standalone commandline tools or Xcode.") + endif() + execute_process( + COMMAND ${XCODEBUILD_EXECUTABLE} -version OUTPUT_VARIABLE XCODE_VERSION_INT ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION_INT "${XCODE_VERSION_INT}") + string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION_INT "${XCODE_VERSION_INT}") + set(XCODE_VERSION_INT "${XCODE_VERSION_INT}" CACHE INTERNAL "") +endif() + +# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur) +# if you don't set a deployment target it will be set the way you only get 64-bit builds +if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0) + # Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...) + set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64") +endif() + +# Check if the platform variable is set +if(DEFINED PLATFORM) + # Environment variables are always preserved. + set(ENV{_PLATFORM} "${PLATFORM}") +elseif(DEFINED ENV{_PLATFORM}) + set(PLATFORM "$ENV{_PLATFORM}") +elseif(NOT DEFINED PLATFORM) + message( + FATAL_ERROR "PLATFORM argument not set. Bailing configure since I don't know what target you want to build for!" + ) +endif() + +if(PLATFORM MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") + message( + FATAL_ERROR + "The combined builds support requires Xcode to be used as generator via '-G Xcode' command-line argument in CMake" + ) +endif() + +# Safeguard that the platform value is set and is one of the supported values +list(FIND _supported_platforms ${PLATFORM} contains_PLATFORM) +if("${contains_PLATFORM}" EQUAL "-1") + string(REPLACE ";" "\n * " _supported_platforms_formatted "${_supported_platforms}") + message(FATAL_ERROR " Invalid PLATFORM specified! Current value: ${PLATFORM}.\n" + " Supported PLATFORM values: \n * ${_supported_platforms_formatted}" + ) +endif() + +# Check if Apple Silicon is supported +if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") + message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5") +endif() + +# Touch toolchain variable to suppress "unused variable" warning. +# This happens if CMake is invoked with the same command line the second time. +if(CMAKE_TOOLCHAIN_FILE) + +endif() + +# Fix for PThread library not in path +set(CMAKE_THREAD_LIBS_INIT "-lpthread") +set(CMAKE_HAVE_THREADS_LIBRARY 1) +set(CMAKE_USE_WIN32_THREADS_INIT 0) +set(CMAKE_USE_PTHREADS_INIT 1) + +# Specify minimum version of deployment target. +if(NOT DEFINED DEPLOYMENT_TARGET) + if(PLATFORM MATCHES "WATCHOS") + # Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS). + set(DEPLOYMENT_TARGET "4.0") + elseif(PLATFORM STREQUAL "MAC") + # Unless specified, SDK version 10.13 (High sierra) is used by default as minimum target version (macos). + set(DEPLOYMENT_TARGET "10.13") + elseif(PLATFORM STREQUAL "MAC_ARM64") + # Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version (macos on arm). + set(DEPLOYMENT_TARGET "11.0") + elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") + # Unless specified, SDK version 13.0 is used by default as minimum target version (mac catalyst minimum requirement). + set(DEPLOYMENT_TARGET "13.0") + else() + # Unless specified, SDK version 11.0 is used by default as minimum target version (iOS, tvOS). + set(DEPLOYMENT_TARGET "11.0") + endif() + message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!") +elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM MATCHES "^MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.0") + message(FATAL_ERROR "Mac Catalyst builds requires a minimum deployment target of 13.0!") +endif() + +# Store the DEPLOYMENT_TARGET in the cache +set(DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}" CACHE INTERNAL "") + +# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially) +if(PLATFORM STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM "OS64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +elseif(PLATFORM STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM "SIMULATOR64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +endif() + +set(PLATFORM_INT "${PLATFORM}") + +if(DEFINED ARCHS) + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") +endif() + +# Determine the platform name and architectures for use in xcodebuild commands +# from the specified PLATFORM_INT name. +if(PLATFORM_INT STREQUAL "OS") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + set(ARCHS armv7 armv7s arm64) + set(APPLE_TARGET_TRIPLE_INT arm-apple-ios$${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "OS64") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + if(XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS arm64) + + # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example + else() + set(ARCHS arm64) + endif() + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "OS64COMBINED") + set(SDK_NAME iphoneos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if(XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS arm64 x86_64) + + # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") + else() + set(ARCHS arm64 x86_64) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") + endif() + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() + message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.") +elseif(PLATFORM_INT STREQUAL "SIMULATOR64") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME appletvos) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "TVOSCOMBINED") + set(SDK_NAME appletvos) + if(MODERN_CMAKE) + if(NOT ARCHS) + set(ARCHS arm64 x86_64) + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvsimulator*] "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvsimulator*] "x86_64") + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME appletvsimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME watchos) + if(NOT ARCHS) + if(XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32) + set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos${DEPLOYMENT_TARGET}) + else() + set(ARCHS armv7k) + set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos${DEPLOYMENT_TARGET}) + endif() + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED") + set(SDK_NAME watchos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if(XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32 i386) + set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") + else() + set(ARCHS armv7k i386) + set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") + endif() + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME watchsimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "MAC" OR PLATFORM_INT STREQUAL "MAC_CATALYST") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS x86_64) + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + if(PLATFORM_INT STREQUAL "MAC") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) + endif() +elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS arm64) + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + if(PLATFORM_INT STREQUAL "MAC_ARM64") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) + endif() +else() + message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") +endif() + +if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") + message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode") +endif() + +if(CMAKE_GENERATOR MATCHES "Xcode" AND PLATFORM_INT MATCHES "^MAC_CATALYST") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx") + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-maccatalyst") + if(NOT DEFINED MACOSX_DEPLOYMENT_TARGET) + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.15") + else() + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") + endif() +elseif(CMAKE_GENERATOR MATCHES "Xcode") + set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}") + if(NOT PLATFORM_INT MATCHES ".*COMBINED") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}") + endif() +endif() + +# If user did not specify the SDK root to use, then query xcodebuild for it. +if(DEFINED CMAKE_OSX_SYSROOT_INT) + # Environment variables are always preserved. + set(ENV{_CMAKE_OSX_SYSROOT_INT} "${CMAKE_OSX_SYSROOT_INT}") +elseif(DEFINED ENV{_CMAKE_OSX_SYSROOT_INT}) + set(CMAKE_OSX_SYSROOT_INT "$ENV{_CMAKE_OSX_SYSROOT_INT}") +elseif(NOT DEFINED CMAKE_OSX_SYSROOT_INT) + execute_process( + COMMAND ${XCODEBUILD_EXECUTABLE} -version -sdk ${SDK_NAME} Path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +if(NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT) + message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain" + "is pointing to the correct path. Please run:" + "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" + "and see if that fixes the problem for you." + ) + message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " "does not exist.") +elseif(DEFINED CMAKE_OSX_SYSROOT_INT) + set(CMAKE_OSX_SYSROOT_INT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") + # Specify the location or name of the platform SDK to be used in CMAKE_OSX_SYSROOT. + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") +endif() + +# Use bitcode or not +if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+") + # Unless specified, enable bitcode support by default + message(STATUS "[DEFAULTS] Enabling bitcode support by default. ENABLE_BITCODE not provided!") + set(ENABLE_BITCODE TRUE) +elseif(NOT DEFINED ENABLE_BITCODE) + message( + STATUS "[DEFAULTS] Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!" + ) + set(ENABLE_BITCODE FALSE) +endif() +set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable bitcode" FORCE) +# Use ARC or not +if(NOT DEFINED ENABLE_ARC) + # Unless specified, enable ARC support by default + set(ENABLE_ARC TRUE) + message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!") +endif() +set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE) +# Use hidden visibility or not +if(NOT DEFINED ENABLE_VISIBILITY) + # Unless specified, disable symbols visibility by default + set(ENABLE_VISIBILITY FALSE) + message(STATUS "[DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!") +endif() +set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} + CACHE BOOL "Whether or not to hide symbols from the dynamic linker (-fvisibility=hidden)" FORCE +) +# Set strict compiler checks or not +if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE) + # Unless specified, disable strict try_compile() + set(ENABLE_STRICT_TRY_COMPILE FALSE) + message(STATUS "[DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!") +endif() +set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} + CACHE BOOL "Whether or not to use strict compiler checks" FORCE +) + +# Get the SDK version information. +if(DEFINED SDK_VERSION) + # Environment variables are always preserved. + set(ENV{_SDK_VERSION} "${SDK_VERSION}") +elseif(DEFINED ENV{_SDK_VERSION}) + set(SDK_VERSION "$ENV{_SDK_VERSION}") +elseif(NOT DEFINED SDK_VERSION) + execute_process( + COMMAND ${XCODEBUILD_EXECUTABLE} -sdk ${CMAKE_OSX_SYSROOT_INT} -version SDKVersion OUTPUT_VARIABLE SDK_VERSION + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +# Find the Developer root for the specific iOS platform being compiled for +# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in +# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain +# this information from xcrun or xcodebuild. +if(NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT CMAKE_GENERATOR MATCHES "Xcode") + get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT_INT} PATH) + get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH) + if(NOT EXISTS "${CMAKE_DEVELOPER_ROOT}") + message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: ${CMAKE_DEVELOPER_ROOT} does not exist.") + endif() +endif() + +# Find the C & C++ compilers for the specified SDK. +if(DEFINED CMAKE_C_COMPILER) + # Environment variables are always preserved. + set(ENV{_CMAKE_C_COMPILER} "${CMAKE_C_COMPILER}") +elseif(DEFINED ENV{_CMAKE_C_COMPILER}) + set(CMAKE_C_COMPILER "$ENV{_CMAKE_C_COMPILER}") + set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +elseif(NOT DEFINED CMAKE_C_COMPILER) + execute_process( + COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang OUTPUT_VARIABLE CMAKE_C_COMPILER + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +endif() +if(DEFINED CMAKE_CXX_COMPILER) + # Environment variables are always preserved. + set(ENV{_CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER}") +elseif(DEFINED ENV{_CMAKE_CXX_COMPILER}) + set(CMAKE_CXX_COMPILER "$ENV{_CMAKE_CXX_COMPILER}") +elseif(NOT DEFINED CMAKE_CXX_COMPILER) + execute_process( + COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang++ OUTPUT_VARIABLE CMAKE_CXX_COMPILER + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() +# Find (Apple's) libtool. +if(DEFINED BUILD_LIBTOOL) + # Environment variables are always preserved. + set(ENV{_BUILD_LIBTOOL} "${BUILD_LIBTOOL}") +elseif(DEFINED ENV{_BUILD_LIBTOOL}) + set(BUILD_LIBTOOL "$ENV{_BUILD_LIBTOOL}") +elseif(NOT DEFINED BUILD_LIBTOOL) + execute_process( + COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find libtool OUTPUT_VARIABLE BUILD_LIBTOOL + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() +# Find the toolchain's provided install_name_tool if none is found on the host +if(DEFINED CMAKE_INSTALL_NAME_TOOL) + # Environment variables are always preserved. + set(ENV{_CMAKE_INSTALL_NAME_TOOL} "${CMAKE_INSTALL_NAME_TOOL}") +elseif(DEFINED ENV{_CMAKE_INSTALL_NAME_TOOL}) + set(CMAKE_INSTALL_NAME_TOOL "$ENV{_CMAKE_INSTALL_NAME_TOOL}") +elseif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + execute_process( + COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find install_name_tool OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE INTERNAL "") +endif() + +# Configure libtool to be used instead of ar + ranlib to build static libraries. +# This is required on Xcode 7+, but should also work on previous versions of +# Xcode. +get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach(lang ${languages}) + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "${BUILD_LIBTOOL} -static -o " CACHE INTERNAL + "" + ) +endforeach() + +# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box. +if(MODERN_CMAKE) + if(SDK_NAME MATCHES "iphone") + set(CMAKE_SYSTEM_NAME iOS) + elseif(SDK_NAME MATCHES "macosx") + set(CMAKE_SYSTEM_NAME Darwin) + elseif(SDK_NAME MATCHES "appletv") + set(CMAKE_SYSTEM_NAME tvOS) + elseif(SDK_NAME MATCHES "watch") + set(CMAKE_SYSTEM_NAME watchOS) + endif() + # Provide flags for a combined FAT library build on newer CMake versions + if(PLATFORM_INT MATCHES ".*COMBINED") + set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO") + set(CMAKE_IOS_INSTALL_COMBINED YES) + message(STATUS "Will combine built (static) artifacts into FAT lib...") + endif() +elseif(NOT DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") + # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified + set(CMAKE_SYSTEM_NAME iOS) +elseif(NOT DEFINED CMAKE_SYSTEM_NAME) + # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified + set(CMAKE_SYSTEM_NAME Darwin) +endif() +# Standard settings. +set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") +set(UNIX TRUE CACHE BOOL "") +set(APPLE TRUE CACHE BOOL "") +if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64") + set(IOS FALSE CACHE BOOL "") + set(MACOS TRUE CACHE BOOL "") +elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") + set(IOS TRUE CACHE BOOL "") + set(MACOS TRUE CACHE BOOL "") +else() + set(IOS TRUE CACHE BOOL "") +endif() +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) +set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) +set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE) +# Set the architectures for which to build. +set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE INTERNAL "") +# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks +if(NOT ENABLE_STRICT_TRY_COMPILE_INT) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +endif() +# All iOS/Darwin specific settings - some may be redundant. +set(CMAKE_MACOSX_BUNDLE YES) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set(CMAKE_SHARED_MODULE_PREFIX "lib") +set(CMAKE_SHARED_MODULE_SUFFIX ".so") +set(CMAKE_C_COMPILER_ABI ELF) +set(CMAKE_CXX_COMPILER_ABI ELF) +set(CMAKE_C_HAS_ISYSROOT 1) +set(CMAKE_CXX_HAS_ISYSROOT 1) +set(CMAKE_MODULE_EXISTS 1) +set(CMAKE_DL_LIBS "") +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + +if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+") + set(CMAKE_C_SIZEOF_DATA_PTR 8) + set(CMAKE_CXX_SIZEOF_DATA_PTR 8) + if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+") + set(CMAKE_SYSTEM_PROCESSOR "aarch64") + else() + set(CMAKE_SYSTEM_PROCESSOR "x86_64") + endif() +else() + set(CMAKE_C_SIZEOF_DATA_PTR 4) + set(CMAKE_CXX_SIZEOF_DATA_PTR 4) + set(CMAKE_SYSTEM_PROCESSOR "arm") +endif() + +# Note that only Xcode 7+ supports the newer more specific: +# -m${SDK_NAME}-version-min flags, older versions of Xcode use: +# -m(ios/ios-simulator)-version-min instead. +if(${CMAKE_VERSION} VERSION_LESS "3.11") + if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64") + if(XCODE_VERSION_INT VERSION_LESS 7.0) + set(SDK_NAME_VERSION_FLAGS "-mios-version-min=${DEPLOYMENT_TARGET}") + else() + # Xcode 7.0+ uses flags we can build directly from SDK_NAME. + set(SDK_NAME_VERSION_FLAGS "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}") + endif() + elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME_VERSION_FLAGS "-mtvos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME_VERSION_FLAGS "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME_VERSION_FLAGS "-mwatchos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME_VERSION_FLAGS "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "MAC") + set(SDK_NAME_VERSION_FLAGS "-mmacosx-version-min=${DEPLOYMENT_TARGET}") + else() + # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. + set(SDK_NAME_VERSION_FLAGS "-mios-simulator-version-min=${DEPLOYMENT_TARGET}") + endif() +elseif(NOT PLATFORM_INT MATCHES "^MAC_CATALYST") + # Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets + set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}) +endif() + +if(DEFINED APPLE_TARGET_TRIPLE_INT) + set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE INTERNAL "") + set(CMAKE_C_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) + set(CMAKE_CXX_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) + set(CMAKE_ASM_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) +endif() + +if(PLATFORM_INT MATCHES "^MAC_CATALYST") + set(C_TARGET_FLAGS + "-isystem ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/usr/include -iframework ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks" + ) +endif() + +if(ENABLE_BITCODE_INT) + set(BITCODE "-fembed-bitcode") + set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +else() + set(BITCODE "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(ENABLE_ARC_INT) + set(FOBJC_ARC "-fobjc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") +else() + set(FOBJC_ARC "-fno-objc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO") +endif() + +if(NOT ENABLE_VISIBILITY_INT) + foreach(lang ${languages}) + set(CMAKE_${lang}_VISIBILITY_PRESET "hidden" CACHE INTERNAL "") + endforeach() + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES") + set(VISIBILITY "-fvisibility=hidden -fvisibility-inlines-hidden") +else() + foreach(lang ${languages}) + set(CMAKE_${lang}_VISIBILITY_PRESET "default" CACHE INTERNAL "") + endforeach() + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO") + set(VISIBILITY "-fvisibility=default") +endif() + +if(DEFINED APPLE_TARGET_TRIPLE) + set(APPLE_TARGET_TRIPLE_FLAG "-target ${APPLE_TARGET_TRIPLE}") +endif() + +#Check if Xcode generator is used, since that will handle these flags automagically +if(CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.") +else() + # Hidden visibility is required for C++ on iOS. + set(CMAKE_C_FLAGS + "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}" + ) + set(CMAKE_CXX_FLAGS + "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}" + ) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") + set(CMAKE_CXX_LINK_FLAGS + "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}" + ) + set(CMAKE_ASM_FLAGS + "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES} ${APPLE_TARGET_TRIPLE_FLAG}" + ) +endif() + +## Print status messages to inform of the current state +message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}") +message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}") +message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") +message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") +message(STATUS "Using libtool: ${BUILD_LIBTOOL}") +message(STATUS "Using install name tool: ${CMAKE_INSTALL_NAME_TOOL}") +if(DEFINED APPLE_TARGET_TRIPLE) + message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}") +endif() +message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}" " (SDK version: ${SDK_VERSION})") +if(MODERN_CMAKE) + message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!") +endif() +if(CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Using Xcode version: ${XCODE_VERSION_INT}") +endif() +message(STATUS "CMake version: ${CMAKE_VERSION}") +if(DEFINED SDK_NAME_VERSION_FLAGS) + message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}") +endif() +message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}") +if(ENABLE_BITCODE_INT) + message(STATUS "Bitcode: Enabled") +else() + message(STATUS "Bitcode: Disabled") +endif() + +if(ENABLE_ARC_INT) + message(STATUS "ARC: Enabled") +else() + message(STATUS "ARC: Disabled") +endif() + +if(ENABLE_VISIBILITY_INT) + message(STATUS "Hiding symbols: Disabled") +else() + message(STATUS "Hiding symbols: Enabled") +endif() + +# Set global properties +set_property(GLOBAL PROPERTY PLATFORM "${PLATFORM}") +set_property(GLOBAL PROPERTY APPLE_TARGET_TRIPLE "${APPLE_TARGET_TRIPLE_INT}") +set_property(GLOBAL PROPERTY SDK_VERSION "${SDK_VERSION}") +set_property(GLOBAL PROPERTY XCODE_VERSION "${XCODE_VERSION_INT}") +set_property(GLOBAL PROPERTY OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + +# Export configurable variables for the try_compile() command. +set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + PLATFORM + XCODE_VERSION_INT + SDK_VERSION + DEPLOYMENT_TARGET + CMAKE_DEVELOPER_ROOT + CMAKE_OSX_SYSROOT_INT + ENABLE_BITCODE + ENABLE_ARC + CMAKE_ASM_COMPILER + CMAKE_C_COMPILER + CMAKE_C_COMPILER_TARGET + CMAKE_CXX_COMPILER + CMAKE_CXX_COMPILER_TARGET + BUILD_LIBTOOL + CMAKE_INSTALL_NAME_TOOL + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_LINK_FLAGS + CMAKE_CXX_LINK_FLAGS + CMAKE_ASM_FLAGS +) + +set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") + +# Set the find root to the SDK developer roots. +# Note: CMAKE_FIND_ROOT_PATH is only useful when cross-compiling. Thus, do not set on macOS builds. +if(NOT PLATFORM_INT STREQUAL "MAC" AND NOT PLATFORM_INT STREQUAL "MAC_ARM64") + list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") + set(CMAKE_IGNORE_PATH "/System/Library/Frameworks;/usr/local/lib" CACHE INTERNAL "") +endif() + +# Default to searching for frameworks first. +set(CMAKE_FIND_FRAMEWORK FIRST) + +# Set up the default search directories for frameworks. +if(PLATFORM_INT MATCHES "^MAC_CATALYST") + set(CMAKE_FRAMEWORK_PATH + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks + ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "" + ) +else() + set(CMAKE_FRAMEWORK_PATH ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "" + ) +endif() + +# By default, search both the specified iOS SDK and the remainder of the host filesystem. +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE INTERNAL "") +endif() + +# +# Some helper-macros below to simplify and beautify the CMakeFile +# + +# This little macro lets you set any Xcode specific property. +macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) + set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") + if(XCODE_RELVERSION_I STREQUAL "All") + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") + else() + set_property( + TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}" + ) + endif() +endmacro(set_xcode_property) + +# This macro lets you find executable programs on the host system. +macro(find_host_package) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) + set(_TOOLCHAIN_IOS ${IOS}) + set(IOS FALSE) + find_package(${ARGN}) + set(IOS ${_TOOLCHAIN_IOS}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) +endmacro(find_host_package) diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/oss-includes.h.in b/local-test-freerdp-delta-01/afc-freerdp/cmake/oss-includes.h.in new file mode 100644 index 0000000000000000000000000000000000000000..f3fb673515f784e939e5d623210289ddeacf4302 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/oss-includes.h.in @@ -0,0 +1,6 @@ +#ifndef OSS_INCLUDES_H_ +#define OSS_INCLUDES_H_ + +#include <@OSS_HDR_NAME@> + +#endif /* OSS_INCLUDES_H_ */ diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/pkg-config-install-prefix.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/pkg-config-install-prefix.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cac331c1dbb6582fba1dfb8a8b501babfaa3f4f2 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/pkg-config-install-prefix.cmake @@ -0,0 +1,13 @@ +option(PKG_CONFIG_RELOCATABLE "Generate relocatable pkg-config files" ON) +if(PKG_CONFIG_RELOCATABLE) + file(RELATIVE_PATH PKG_CONFIG_INSTALL_REL ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig ${CMAKE_INSTALL_PREFIX}) + if(PKG_CONFIG_INSTALL_REL MATCHES "/$") + string(LENGTH ${PKG_CONFIG_INSTALL_REL} PKG_CONFIG_INSTALL_REL_LEN) + math(EXPR PKG_CONFIG_INSTALL_REL_LEN "${PKG_CONFIG_INSTALL_REL_LEN} - 1") + string(SUBSTRING ${PKG_CONFIG_INSTALL_REL} 0 ${PKG_CONFIG_INSTALL_REL_LEN} PKG_CONFIG_INSTALL_REL) + endif() + set(PKG_CONFIG_INSTALL_PREFIX "\${pcfiledir}/${PKG_CONFIG_INSTALL_REL}") +else() + set(PKG_CONFIG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +endif() +set(PKG_CONFIG_PC_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") diff --git a/local-test-freerdp-delta-01/afc-freerdp/cmake/today.cmake b/local-test-freerdp-delta-01/afc-freerdp/cmake/today.cmake new file mode 100644 index 0000000000000000000000000000000000000000..09049773089c6055f3b8fd27c1caebad27cd3079 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/cmake/today.cmake @@ -0,0 +1,14 @@ +# This script returns the current date in ISO format +# +# YYYY-MM-DD +# +macro(TODAY RESULT) + if(DEFINED ENV{SOURCE_DATE_EPOCH} AND NOT WIN32) + execute_process( + COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT} + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + else() + string(TIMESTAMP ${RESULT} "%Y-%m-%d" UTC) + endif() +endmacro(TODAY) diff --git a/local-test-freerdp-delta-01/afc-freerdp/docs/Doxyfile b/local-test-freerdp-delta-01/afc-freerdp/docs/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..9ba204e11f50ba652ede060d4917a1b909e02a63 --- /dev/null +++ b/local-test-freerdp-delta-01/afc-freerdp/docs/Doxyfile @@ -0,0 +1,2685 @@ +# Doxyfile 1.9.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables: +# doxygen -x_noenv [configFile] + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = FreeRDP + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = ../resources/FreeRDP_Logo.svg + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +# OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = NO + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 2 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = msdn{1}=http://msdn.microsoft.com/en-us/library/\1/ + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = YES + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = YES + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# The default value is: system dependent. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = YES + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = YES + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = .. + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = ../build \ + ../cmake \ + ../CMakeFiles \ + ../cunit \ + ../docs \ + ../uwac/protocols \ + ../keymaps \ + ../resources + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# ANamespace::AClass, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = api + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.freerdp + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /