Kitxuuu commited on
Commit
e66a594
·
verified ·
1 Parent(s): 904b4b5

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. local-test-freerdp-full-01/afc-freerdp/CMakeCPack.cmake +98 -0
  2. local-test-freerdp-full-01/afc-freerdp/CMakeCPackOptions.cmake.in +10 -0
  3. local-test-freerdp-full-01/afc-freerdp/CMakeLists.txt +600 -0
  4. local-test-freerdp-full-01/afc-freerdp/ChangeLog +622 -0
  5. local-test-freerdp-full-01/afc-freerdp/LICENSE +202 -0
  6. local-test-freerdp-full-01/afc-freerdp/README.md +44 -0
  7. local-test-freerdp-full-01/afc-freerdp/SECURITY.md +114 -0
  8. local-test-freerdp-full-01/afc-freerdp/client/Android/BuildFlags.java.in +6 -0
  9. local-test-freerdp-full-01/afc-freerdp/client/CMakeLists.txt +126 -0
  10. local-test-freerdp-full-01/afc-freerdp/client/FreeRDP-ClientConfig.cmake.in +16 -0
  11. local-test-freerdp-full-01/afc-freerdp/client/Mac/CMakeLists.txt +92 -0
  12. local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.h +60 -0
  13. local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.m +135 -0
  14. local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.xib +169 -0
  15. local-test-freerdp-full-01/afc-freerdp/client/Mac/Clipboard.h +31 -0
  16. local-test-freerdp-full-01/afc-freerdp/client/Mac/Clipboard.m +432 -0
  17. local-test-freerdp-full-01/afc-freerdp/client/Mac/Credits.rtf +21 -0
  18. local-test-freerdp-full-01/afc-freerdp/client/Mac/Info.plist +30 -0
  19. local-test-freerdp-full-01/afc-freerdp/client/Mac/Keyboard.h +27 -0
  20. local-test-freerdp-full-01/afc-freerdp/client/Mac/Keyboard.m +240 -0
  21. local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPCursor.h +34 -0
  22. local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPCursor.m +24 -0
  23. local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPView.h +91 -0
  24. local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPView.m +1534 -0
  25. local-test-freerdp-full-01/afc-freerdp/client/Mac/ModuleOptions.cmake +3 -0
  26. local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.h +49 -0
  27. local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.m +140 -0
  28. local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.xib +132 -0
  29. local-test-freerdp-full-01/afc-freerdp/client/Mac/main.m +25 -0
  30. local-test-freerdp-full-01/afc-freerdp/client/Mac/mf_client.h +46 -0
  31. local-test-freerdp-full-01/afc-freerdp/client/Mac/mf_client.m +220 -0
  32. local-test-freerdp-full-01/afc-freerdp/client/Mac/mfreerdp.h +86 -0
  33. local-test-freerdp-full-01/afc-freerdp/client/SDL/CMakeLists.txt +104 -0
  34. local-test-freerdp-full-01/afc-freerdp/client/Sample/CMakeLists.txt +48 -0
  35. local-test-freerdp-full-01/afc-freerdp/client/Sample/ModuleOptions.cmake +3 -0
  36. local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_channels.c +73 -0
  37. local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_channels.h +33 -0
  38. local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_freerdp.c +417 -0
  39. local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_freerdp.h +37 -0
  40. local-test-freerdp-full-01/afc-freerdp/client/Wayland/CMakeLists.txt +56 -0
  41. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_channels.c +79 -0
  42. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_channels.h +37 -0
  43. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_cliprdr.c +1018 -0
  44. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_cliprdr.h +36 -0
  45. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_disp.c +458 -0
  46. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_disp.h +38 -0
  47. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_input.c +455 -0
  48. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_input.h +45 -0
  49. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_pointer.c +167 -0
  50. local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_pointer.h +28 -0
local-test-freerdp-full-01/afc-freerdp/CMakeCPack.cmake ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generate .txt license file for CPack (PackageMaker requires a file extension)
2
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt @ONLY)
3
+
4
+ # Workaround to remove c++ compiler macros and defines for Eclipse.
5
+ # If c++ macros/defines are set __cplusplus is also set which causes
6
+ # problems when compiling freerdp/jni. To prevent this problem we set the macros to "".
7
+
8
+ if(ANDROID AND CMAKE_EXTRA_GENERATOR STREQUAL "Eclipse CDT4")
9
+ set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "")
10
+ message(STATUS "Disabled CXX system defines for eclipse (workaround).")
11
+ endif()
12
+
13
+ set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;/\\\\.gitignore;/CMakeCache.txt")
14
+
15
+ if(NOT WIN32)
16
+ if(APPLE AND (NOT IOS))
17
+
18
+ if(WITH_SERVER)
19
+ set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "mfreerdp-server")
20
+ endif()
21
+ endif()
22
+
23
+ if(WITH_X11)
24
+ set(CPACK_PACKAGE_EXECUTABLES "xfreerdp")
25
+
26
+ if(WITH_SERVER)
27
+ set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "xfreerdp-server")
28
+ endif()
29
+ endif()
30
+ endif()
31
+
32
+ set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
33
+ set(CPACK_TOPLEVEL_TAG "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
34
+
35
+ string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_lower)
36
+ set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}-${CPACK_SYSTEM_NAME}")
37
+ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}-${CPACK_SYSTEM_NAME}")
38
+
39
+ set(CPACK_PACKAGE_NAME "FreeRDP")
40
+ set(CPACK_PACKAGE_VENDOR "FreeRDP")
41
+ set(CPACK_PACKAGE_VERSION ${FREERDP_VERSION_FULL})
42
+ set(CPACK_PACKAGE_VERSION_MAJOR ${FREERDP_VERSION_MAJOR})
43
+ set(CPACK_PACKAGE_VERSION_MINOR ${FREERDP_VERSION_MINOR})
44
+ set(CPACK_PACKAGE_VERSION_PATCH ${FREERDP_VERSION_REVISION})
45
+ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FreeRDP: A Remote Desktop Protocol Implementation")
46
+
47
+ set(CPACK_PACKAGE_CONTACT "Marc-Andre Moreau")
48
+ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "marcandre.moreau@gmail.com")
49
+ set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
50
+
51
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY "FreeRDP")
52
+ set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
53
+ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
54
+
55
+ set(CPACK_NSIS_MODIFY_PATH ON)
56
+ set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/resources\\\\FreeRDP_Install.bmp")
57
+ set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/resources\\\\FreeRDP_Icon_96px.ico")
58
+ set(CPACK_NSIS_MUI_UNICON "${PROJECT_SOURCE_DIR}/resource\\\\FreeRDP_Icon_96px.ico")
59
+
60
+ set(CPACK_COMPONENTS_ALL client server libraries headers symbols tools)
61
+
62
+ if(MSVC)
63
+ string(FIND ${CMAKE_MSVC_RUNTIME_LIBRARY} "DLL" IS_SHARED)
64
+
65
+ if(NOT IS_SHARED STREQUAL "-1")
66
+ set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
67
+ include(InstallRequiredSystemLibraries)
68
+
69
+ install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries)
70
+ endif()
71
+ endif()
72
+
73
+ set(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client")
74
+ set(CPACK_COMPONENT_CLIENT_GROUP "Applications")
75
+
76
+ set(CPACK_COMPONENT_SERVER_DISPLAY_NAME "Server")
77
+ set(CPACK_COMPONENT_SERVER_GROUP "Applications")
78
+
79
+ set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
80
+ set(CPACK_COMPONENT_LIBRARIES_GROUP "Runtime")
81
+
82
+ set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Headers")
83
+ set(CPACK_COMPONENT_HEADERS_GROUP "Development")
84
+
85
+ set(CPACK_COMPONENT_SYMBOLS_DISPLAY_NAME "Symbols")
86
+ set(CPACK_COMPONENT_SYMBOLS_GROUP "Development")
87
+
88
+ set(CPACK_COMPONENT_TOOLS_DISPLAY_NAME "Tools")
89
+ set(CPACK_COMPONENT_TOOLS_GROUP "Applications")
90
+
91
+ set(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Runtime")
92
+ set(CPACK_COMPONENT_GROUP_APPLICATIONS_DESCRIPTION "Applications")
93
+ set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Development")
94
+
95
+ configure_file("${PROJECT_SOURCE_DIR}/CMakeCPackOptions.cmake.in" "${PROJECT_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY)
96
+ set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CMakeCPackOptions.cmake")
97
+
98
+ include(CPack)
local-test-freerdp-full-01/afc-freerdp/CMakeCPackOptions.cmake.in ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is configured at cmake time, and loaded at cpack time.
2
+ # To pass variables to cpack from cmake, they must be configured in this file.
3
+
4
+ if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
5
+ if(CMAKE_PACKAGE_QTGUI)
6
+ set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
7
+ else()
8
+ set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr")
9
+ endif()
10
+ endif()
local-test-freerdp-full-01/afc-freerdp/CMakeLists.txt ADDED
@@ -0,0 +1,600 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP cmake build script
3
+ #
4
+ # Copyright 2011 O.S. Systems Software Ltda.
5
+ # Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
6
+ # Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7
+ # Copyright 2012 HP Development Company, LLC
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+
21
+ cmake_minimum_required(VERSION 3.13)
22
+
23
+ if(POLICY CMP0091)
24
+ cmake_policy(SET CMP0091 NEW)
25
+ endif()
26
+ project(FreeRDP LANGUAGES C)
27
+
28
+ set(CMAKE_C_STANDARD 11)
29
+ set(CMAKE_C_STANDARD_REQUIRED ON)
30
+ set(CMAKE_C_EXTENSIONS ON)
31
+
32
+ add_custom_target(fuzzers COMMENT "Build fuzzers")
33
+
34
+ if(NOT DEFINED VENDOR)
35
+ set(VENDOR "FreeRDP" CACHE STRING "FreeRDP package vendor")
36
+ endif()
37
+
38
+ if(NOT DEFINED PRODUCT)
39
+ set(PRODUCT "FreeRDP" CACHE STRING "FreeRDP package name")
40
+ endif()
41
+
42
+ if(NOT DEFINED FREERDP_VENDOR)
43
+ set(FREERDP_VENDOR 1)
44
+ endif()
45
+
46
+ if(NOT WIN32 AND NOT ANDROID)
47
+ if(APPLE)
48
+ set(OPT_DEFAULT_VAL OFF)
49
+ else()
50
+ set(OPT_DEFAULT_VAL ON)
51
+ endif()
52
+ option(WITH_X11 "build X11 client/server" ${OPT_DEFAULT_VAL})
53
+ endif()
54
+
55
+ # Enable coverity related pragma definitions
56
+ if(COVERITY_BUILD)
57
+ add_compile_definitions(COVERITY_BUILD)
58
+ endif()
59
+
60
+ # Include our extra modules
61
+ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
62
+
63
+ # Check for cmake compatibility (enable/disable features)
64
+ include(CheckCmakeCompat)
65
+
66
+ # Include cmake modules
67
+ if(WITH_CLANG_FORMAT)
68
+ include(ClangFormat)
69
+ endif()
70
+
71
+ include(CompilerFlags)
72
+ include(CheckIncludeFiles)
73
+ include(CheckLibraryExists)
74
+ include(CheckSymbolExists)
75
+ include(CheckStructHasMember)
76
+ include(TestBigEndian)
77
+ include(CompilerDetect)
78
+
79
+ include(FindFeature)
80
+ include(ShowCMakeVars)
81
+ include(ConfigOptions)
82
+ include(FeatureSummary)
83
+ include(CheckCCompilerFlag)
84
+ include(CMakePackageConfigHelpers)
85
+ include(InstallFreeRDPMan)
86
+ include(GetGitRevisionDescription)
87
+ include(SetFreeRDPCMakeInstallDir)
88
+ include(Doxygen)
89
+
90
+ # Soname versioning
91
+ set(BUILD_NUMBER 0)
92
+ if($ENV{BUILD_NUMBER})
93
+ set(BUILD_NUMBER $ENV{BUILD_NUMBER})
94
+ endif()
95
+
96
+ set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
97
+ set(RAW_VERSION_STRING "3.11.2-dev0")
98
+ if(EXISTS "${PROJECT_SOURCE_DIR}/.source_tag")
99
+ file(READ ${PROJECT_SOURCE_DIR}/.source_tag RAW_VERSION_STRING)
100
+ elseif(USE_VERSION_FROM_GIT_TAG)
101
+ git_get_exact_tag(_GIT_TAG --tags --always)
102
+ if(NOT ${_GIT_TAG} STREQUAL "n/a")
103
+ string(REGEX MATCH ${VERSION_REGEX} FOUND_TAG "${_GIT_TAG}")
104
+ if(FOUND_TAG)
105
+ set(RAW_VERSION_STRING ${_GIT_TAG})
106
+ endif()
107
+ endif()
108
+ endif()
109
+ string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
110
+
111
+ string(REGEX REPLACE "${VERSION_REGEX}" "\\2" FREERDP_VERSION_MAJOR "${RAW_VERSION_STRING}")
112
+ string(REGEX REPLACE "${VERSION_REGEX}" "\\3" FREERDP_VERSION_MINOR "${RAW_VERSION_STRING}")
113
+ string(REGEX REPLACE "${VERSION_REGEX}" "\\4" FREERDP_VERSION_REVISION "${RAW_VERSION_STRING}")
114
+ string(REGEX REPLACE "${VERSION_REGEX}" "\\5" FREERDP_VERSION_SUFFIX "${RAW_VERSION_STRING}")
115
+
116
+ set(FREERDP_API_VERSION "${FREERDP_VERSION_MAJOR}")
117
+ set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}.${FREERDP_VERSION_REVISION}")
118
+ if(FREERDP_VERSION_SUFFIX)
119
+ set(FREERDP_VERSION_FULL "${FREERDP_VERSION}-${FREERDP_VERSION_SUFFIX}")
120
+ else()
121
+ set(FREERDP_VERSION_FULL "${FREERDP_VERSION}")
122
+ endif()
123
+ message("FREERDP_VERSION=${FREERDP_VERSION_FULL}")
124
+
125
+ if(EXISTS "${PROJECT_SOURCE_DIR}/.source_version")
126
+ file(READ ${PROJECT_SOURCE_DIR}/.source_version GIT_REVISION)
127
+
128
+ string(STRIP ${GIT_REVISION} GIT_REVISION)
129
+ elseif(USE_VERSION_FROM_GIT_TAG)
130
+ git_get_exact_tag(GIT_REVISION --tags --always)
131
+
132
+ if(${GIT_REVISION} STREQUAL "n/a")
133
+ git_rev_parse(GIT_REVISION --short)
134
+ endif()
135
+ endif()
136
+
137
+ if(NOT GIT_REVISION)
138
+ set(GIT_REVISION ${FREERDP_VERSION})
139
+ endif()
140
+
141
+ message(STATUS "Git Revision ${GIT_REVISION}")
142
+
143
+ # MSVC compatibility with system headers
144
+ add_compile_definitions(NONAMELESSUNION)
145
+
146
+ # Make the detected version available as default version for all subprojects
147
+ set(FREERDP_DEFAULT_PROJECT_VERSION ${FREERDP_VERSION} CACHE STRING INTERNAL)
148
+
149
+ set(FREERDP_MAJOR_DIR "freerdp${FREERDP_VERSION_MAJOR}")
150
+ set(FREERDP_INCLUDE_DIR "include/${FREERDP_MAJOR_DIR}/")
151
+
152
+ option(WITH_SMARTCARD_EMULATE "Emulate smartcards instead of redirecting readers" ON)
153
+ if(WITH_SMARTCARD_EMULATE)
154
+ add_compile_definitions(WITH_SMARTCARD_EMULATE)
155
+ find_package(ZLIB REQUIRED)
156
+ endif()
157
+
158
+ option(WITH_FREERDP_DEPRECATED "Build FreeRDP deprecated symbols" OFF)
159
+ if(WITH_FREERDP_DEPRECATED)
160
+ add_compile_definitions(WITH_FREERDP_DEPRECATED)
161
+ endif()
162
+
163
+ option(WITH_FREERDP_DEPRECATED_COMMANDLINE "Build FreeRDP deprecated command line options" OFF)
164
+ if(WITH_FREERDP_DEPRECATED_COMMANDLINE)
165
+ add_compile_definitions(WITH_FREERDP_DEPRECATED_COMMANDLINE)
166
+ endif()
167
+
168
+ # Make paths absolute
169
+ if(CMAKE_INSTALL_PREFIX)
170
+ get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
171
+ endif()
172
+ if(FREERDP_EXTERNAL_PATH)
173
+ get_filename_component(FREERDP_EXTERNAL_PATH "${FREERDP_EXTERNAL_PATH}" ABSOLUTE)
174
+ endif()
175
+
176
+ # Allow to search the host machine for git/ccache
177
+ if(CMAKE_CROSSCOMPILING)
178
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
179
+ endif(CMAKE_CROSSCOMPILING)
180
+
181
+ find_program(CCACHE ccache)
182
+ if(CCACHE AND WITH_CCACHE)
183
+ if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER)
184
+ set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
185
+ endif(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER)
186
+ endif(CCACHE AND WITH_CCACHE)
187
+
188
+ if(CMAKE_CROSSCOMPILING)
189
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
190
+ endif(CMAKE_CROSSCOMPILING)
191
+ # /Allow to search the host machine for git/ccache
192
+
193
+ # Turn on solution folders (2.8.4+)
194
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
195
+
196
+ option(CTEST_OUTPUT_ON_FAILURE ON "show verbose output on CTest failures")
197
+ if(BUILD_TESTING_INTERNAL)
198
+ set(EXPORT_ALL_SYMBOLS ON CACHE BOOL "testing default" FORCE)
199
+ add_compile_definitions(BUILD_TESTING_INTERNAL)
200
+ elseif(BUILD_TESTING)
201
+ set(EXPORT_ALL_SYMBOLS OFF CACHE BOOL "testing default" FORCE)
202
+ endif()
203
+
204
+ include(ExportAllSymbols)
205
+
206
+ set(THREAD_PREFER_PTHREAD_FLAG TRUE)
207
+
208
+ if(NOT IOS)
209
+ find_package(Threads REQUIRED)
210
+ endif()
211
+
212
+ if(WIN32)
213
+ add_compile_definitions(UNICODE _UNICODE)
214
+ add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
215
+ add_compile_definitions(WIN32_LEAN_AND_MEAN)
216
+ add_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS)
217
+
218
+ set(CMAKE_DL_LIBS "")
219
+ set(CMAKE_USE_RELATIVE_PATH ON)
220
+ string(TIMESTAMP RC_VERSION_YEAR "%Y")
221
+
222
+ if(NOT DEFINED CMAKE_WINDOWS_VERSION)
223
+ set(CMAKE_WINDOWS_VERSION "WIN7")
224
+ endif()
225
+
226
+ if(CMAKE_WINDOWS_VERSION STREQUAL "WINXP")
227
+ add_compile_definitions(WINVER=0x0501 _WIN32_WINNT=0x0501)
228
+ elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN7")
229
+ add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601)
230
+ elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN8")
231
+ add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602)
232
+ elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN10")
233
+ add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00)
234
+ endif()
235
+
236
+ # Set product and vendor for dll and exe version information.
237
+ set(RC_VERSION_VENDOR ${VENDOR})
238
+ set(RC_VERSION_PRODUCT ${PRODUCT})
239
+ set(RC_VERSION_PATCH ${BUILD_NUMBER})
240
+ set(RC_VERSION_DESCRIPTION
241
+ "${FREERDP_VERSION_FULL} ${GIT_REVISION} ${CMAKE_WINDOWS_VERSION} ${CMAKE_SYSTEM_PROCESSOR}"
242
+ )
243
+
244
+ if(FREERDP_EXTERNAL_SSL_PATH)
245
+ set(OPENSSL_ROOT_DIR ${FREERDP_EXTERNAL_SSL_PATH})
246
+ endif()
247
+ endif()
248
+
249
+ add_compile_definitions(FREERDP_EXPORTS)
250
+
251
+ # Mac OS X
252
+ if(APPLE)
253
+ if(IOS)
254
+ if(NOT FREERDP_IOS_EXTERNAL_SSL_PATH)
255
+ message(
256
+ STATUS
257
+ "FREERDP_IOS_EXTERNAL_SSL_PATH not set! Required if openssl is not found in the iOS SDK (which usually isn't"
258
+ )
259
+ endif()
260
+ set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${FREERDP_IOS_EXTERNAL_SSL_PATH})
261
+ set_property(GLOBAL PROPERTY XCODE_ATTRIBUTE_SKIP_INSTALL YES)
262
+ endif(IOS)
263
+
264
+ # Temporarily disabled, causes the cmake script to be reexecuted, causing the compilation to fail.
265
+ # Workaround: specify the parameter in the command-line
266
+ # if(WITH_CLANG)
267
+ # set(CMAKE_C_COMPILER "clang")
268
+ # endif()
269
+
270
+ if(WITH_VERBOSE)
271
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -v")
272
+ endif()
273
+ endif(APPLE)
274
+
275
+ # Android
276
+ if(ANDROID)
277
+ set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ANDROID_LIBRARY_USE_LIB64_PATHS})
278
+
279
+ if(ANDROID_ABI STREQUAL arm64-v8a)
280
+ include(CheckCCompilerFlag)
281
+ check_c_compiler_flag("-mfloat-abi=softfp" ABI_SOFTFP_SUPPORTED)
282
+
283
+ if(ABI_SOFTFP_SUPPORTED)
284
+ # https://github.com/android/ndk/issues/910
285
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp")
286
+ endif()
287
+ endif()
288
+
289
+ add_compile_definitions("$<$<CONFIG:Debug>:NDK_DEBUG=1>")
290
+
291
+ # NOTE: Manually add -gdwarf-3, as newer toolchains default to -gdwarf-4,
292
+ # which is not supported by the gdbserver binary shipped with
293
+ # the android NDK (tested with r9b)
294
+ add_compile_options("$<$<CONFIG:Debug>:-gdwarf-3>")
295
+ add_link_options(-llog)
296
+
297
+ # CMAKE_PREFIX_PATH detection is broken in most Android toolchain files
298
+ # Append it to CMAKE_FIND_ROOT_PATH and avoid potential duplicates
299
+ list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
300
+ list(REMOVE_DUPLICATES CMAKE_FIND_ROOT_PATH)
301
+
302
+ if(NOT FREERDP_EXTERNAL_PATH)
303
+ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external/")
304
+ set(FREERDP_EXTERNAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/")
305
+ else()
306
+ message(STATUS "FREERDP_EXTERNAL_PATH not set!")
307
+ endif()
308
+ endif()
309
+
310
+ list(APPEND CMAKE_INCLUDE_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/include)
311
+ list(APPEND CMAKE_LIBRARY_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/)
312
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
313
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
314
+
315
+ if(WITH_GPROF)
316
+ configure_file(
317
+ ${PROJECT_SOURCE_DIR}/scripts/gprof_generate.sh.in ${PROJECT_BINARY_DIR}/scripts/gprof_generate.sh @ONLY
318
+ )
319
+ endif(WITH_GPROF)
320
+ endif()
321
+
322
+ if(UNIX OR CYGWIN)
323
+ set(WAYLAND_FEATURE_TYPE "RECOMMENDED")
324
+ else()
325
+ set(WAYLAND_FEATURE_TYPE "DISABLED")
326
+ endif()
327
+
328
+ if(WITH_PCSC_WINPR)
329
+ find_package(PCSCWinPR)
330
+ endif()
331
+
332
+ set(WAYLAND_FEATURE_PURPOSE "Wayland")
333
+ set(WAYLAND_FEATURE_DESCRIPTION "Wayland client")
334
+
335
+ set(OPENSSL_FEATURE_TYPE "REQUIRED")
336
+ set(OPENSSL_FEATURE_PURPOSE "cryptography")
337
+ set(OPENSSL_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
338
+
339
+ set(MBEDTLS_FEATURE_TYPE "OPTIONAL")
340
+ set(MBEDTLS_FEATURE_PURPOSE "cryptography")
341
+ set(MBEDTLS_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
342
+
343
+ set(PCSC_FEATURE_TYPE "RECOMMENDED")
344
+ set(PCSC_FEATURE_PURPOSE "smart card")
345
+ set(PCSC_FEATURE_DESCRIPTION "smart card device redirection")
346
+
347
+ set(OPENH264_FEATURE_TYPE "OPTIONAL")
348
+ set(OPENH264_FEATURE_PURPOSE "codec")
349
+ set(OPENH264_FEATURE_DESCRIPTION "use OpenH264 library")
350
+
351
+ set(OPENCL_FEATURE_TYPE "OPTIONAL")
352
+ set(OPENCL_FEATURE_PURPOSE "codec")
353
+ set(OPENCL_FEATURE_DESCRIPTION "use OpenCL library")
354
+
355
+ set(GSM_FEATURE_TYPE "OPTIONAL")
356
+ set(GSM_FEATURE_PURPOSE "codec")
357
+ set(GSM_FEATURE_DESCRIPTION "GSM audio codec library")
358
+
359
+ set(LAME_FEATURE_TYPE "OPTIONAL")
360
+ set(LAME_FEATURE_PURPOSE "codec")
361
+ set(LAME_FEATURE_DESCRIPTION "lame MP3 audio codec library")
362
+
363
+ set(FAAD2_FEATURE_TYPE "OPTIONAL")
364
+ set(FAAD2_FEATURE_PURPOSE "codec")
365
+ set(FAAD2_FEATURE_DESCRIPTION "FAAD2 AAC audio codec library")
366
+
367
+ set(FAAC_FEATURE_TYPE "OPTIONAL")
368
+ set(FAAC_FEATURE_PURPOSE "codec")
369
+ set(FAAC_FEATURE_DESCRIPTION "FAAC AAC audio codec library")
370
+
371
+ set(SOXR_FEATURE_TYPE "OPTIONAL")
372
+ set(SOXR_FEATURE_PURPOSE "codec")
373
+ set(SOXR_FEATURE_DESCRIPTION "SOX audio resample library")
374
+
375
+ if(WIN32)
376
+ set(WAYLAND_FEATURE_TYPE "DISABLED")
377
+ set(PCSC_FEATURE_TYPE "DISABLED")
378
+ endif()
379
+
380
+ if(APPLE)
381
+ set(WAYLAND_FEATURE_TYPE "DISABLED")
382
+ if(IOS)
383
+ set(PCSC_FEATURE_TYPE "DISABLED")
384
+ endif()
385
+ endif()
386
+
387
+ if(ANDROID)
388
+ set(WAYLAND_FEATURE_TYPE "DISABLED")
389
+ set(PCSC_FEATURE_TYPE "DISABLED")
390
+ endif()
391
+
392
+ find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION})
393
+
394
+ option(WITH_LIBRESSL "build with LibreSSL" OFF)
395
+ if(WITH_LIBRESSL)
396
+ find_package(LibreSSL REQUIRED)
397
+ include_directories(SYSTEM ${LibreSSL_INCLUDE_DIRS})
398
+ set(OPENSSL_INCLUDE_DIR ${LIBRESSL_INCLUDE_DIR})
399
+ set(OPENSSL_LIBRARIES ${LIBRESSL_LIBRARIES})
400
+ set(OPENSSL_CRYPTO_LIBRARIES ${LIBRESSL_LIBRARIES})
401
+ set(WITH_OPENSSL ON)
402
+ set(OPENSSL_FOUND ON)
403
+ add_compile_definitions("WITH_LIBRESSL")
404
+ add_compile_definitions("WITH_OPENSSL")
405
+ else()
406
+ find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
407
+ find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
408
+ endif()
409
+
410
+ find_feature(PCSC ${PCSC_FEATURE_TYPE} ${PCSC_FEATURE_PURPOSE} ${PCSC_FEATURE_DESCRIPTION})
411
+
412
+ if(WITH_DSP_FFMPEG OR WITH_VIDEO_FFMPEG OR WITH_FFMPEG)
413
+ find_package(FFmpeg REQUIRED COMPONENTS AVUTIL AVCODEC)
414
+ endif()
415
+
416
+ find_feature(OpenH264 ${OPENH264_FEATURE_TYPE} ${OPENH264_FEATURE_PURPOSE} ${OPENH264_FEATURE_DESCRIPTION})
417
+ find_feature(OpenCL ${OPENCL_FEATURE_TYPE} ${OPENCL_FEATURE_PURPOSE} ${OPENCL_FEATURE_DESCRIPTION})
418
+ find_feature(GSM ${GSM_FEATURE_TYPE} ${GSM_FEATURE_PURPOSE} ${GSM_FEATURE_DESCRIPTION})
419
+ find_feature(LAME ${LAME_FEATURE_TYPE} ${LAME_FEATURE_PURPOSE} ${LAME_FEATURE_DESCRIPTION})
420
+ find_feature(FAAD2 ${FAAD2_FEATURE_TYPE} ${FAAD2_FEATURE_PURPOSE} ${FAAD2_FEATURE_DESCRIPTION})
421
+ find_feature(FAAC ${FAAC_FEATURE_TYPE} ${FAAC_FEATURE_PURPOSE} ${FAAC_FEATURE_DESCRIPTION})
422
+ find_feature(soxr ${SOXR_FEATURE_TYPE} ${SOXR_FEATURE_PURPOSE} ${SOXR_FEATURE_DESCRIPTION})
423
+
424
+ if(WITH_OPENH264 AND NOT WITH_OPENH264_LOADING)
425
+ option(WITH_OPENH264_LOADING "Use LoadLibrary to load openh264 at runtime" OFF)
426
+ endif(WITH_OPENH264 AND NOT WITH_OPENH264_LOADING)
427
+
428
+ # Version check, if we have detected FFMPEG but the version is too old
429
+ # deactivate it as sound backend.
430
+ if(WITH_DSP_FFMPEG)
431
+ if(AVCODEC_VERSION VERSION_LESS "57.48.101")
432
+ message(
433
+ WARNING
434
+ "FFmpeg version detected (${AVCODEC_VERSION}) is too old. (Require at least 57.48.101 for sound). Deactivating"
435
+ )
436
+ set(WITH_DSP_FFMPEG OFF)
437
+ endif()
438
+ endif(WITH_DSP_FFMPEG)
439
+
440
+ if(WITH_OPENH264 AND NOT OPENH264_FOUND)
441
+ message(FATAL_ERROR "OpenH264 support requested but not detected")
442
+ endif()
443
+ set(WITH_OPENH264 ${OPENH264_FOUND})
444
+
445
+ if(OPENSSL_FOUND)
446
+ add_compile_definitions("WITH_OPENSSL")
447
+ message(STATUS "Using OpenSSL Version: ${OPENSSL_VERSION}")
448
+ include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
449
+ endif()
450
+
451
+ if(MBEDTLS_FOUND)
452
+ add_compile_definitions("WITH_MBEDTLS")
453
+ endif()
454
+
455
+ if(WITH_OPENH264 OR WITH_MEDIA_FOUNDATION OR WITH_VIDEO_FFMPEG OR WITH_MEDIACODEC)
456
+ set(WITH_GFX_H264 ON)
457
+ else()
458
+ set(WITH_GFX_H264 OFF)
459
+ endif()
460
+
461
+ # Android expects all libraries to be loadable
462
+ # without paths.
463
+ if(ANDROID OR WIN32 OR MAC_BUNDLE)
464
+ set(PLUGIN_ABS_PATHS_DEFAULT OFF)
465
+ else()
466
+ set(PLUGIN_ABS_PATHS_DEFAULT ON)
467
+ endif()
468
+ option(WITH_ABSOLUTE_PLUGIN_LOAD_PATHS "Load plugins with absolute paths" ${PLUGIN_ABS_PATHS_DEFAULT})
469
+
470
+ if(NOT WITH_ABSOLUTE_PLUGIN_LOAD_PATHS)
471
+ set(FREERDP_DATA_PATH "share")
472
+ if(NOT FREERDP_INSTALL_PREFIX)
473
+ set(FREERDP_INSTALL_PREFIX ".")
474
+ endif()
475
+ set(FREERDP_LIBRARY_PATH ".")
476
+ set(FREERDP_PLUGIN_PATH ".")
477
+ else()
478
+ set(FREERDP_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/${FREERDP_MAJOR_DIR}")
479
+ if(NOT FREERDP_INSTALL_PREFIX)
480
+ set(FREERDP_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
481
+ endif()
482
+ set(FREERDP_LIBRARY_PATH "${CMAKE_INSTALL_LIBDIR}")
483
+ if(WIN32)
484
+ set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_BINDIR}/${FREERDP_MAJOR_DIR}")
485
+ else()
486
+ set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/${FREERDP_MAJOR_DIR}")
487
+ endif()
488
+ endif()
489
+ set(FREERDP_ADDIN_PATH "${FREERDP_PLUGIN_PATH}")
490
+
491
+ # Path to put extensions
492
+ set(FREERDP_EXTENSION_POSTFIX "${FREERDP_MAJOR_DIR}/extensions")
493
+ set(FREERDP_EXTENSION_REL_PATH "${CMAKE_INSTALL_LIBDIR}/${FREERDP_EXTENSION_POSTFIX}")
494
+ set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${FREERDP_EXTENSION_POSTFIX}")
495
+
496
+ # Proxy plugins path
497
+ if(NOT DEFINED PROXY_PLUGINDIR)
498
+ message("using default plugins location")
499
+ set(FREERDP_PROXY_PLUGINDIR "${FREERDP_PLUGIN_PATH}/proxy/")
500
+ else()
501
+ set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}")
502
+ endif()
503
+
504
+ # Unit Tests
505
+
506
+ include(CTest)
507
+
508
+ if(BUILD_TESTING_INTERNAL OR BUILD_TESTING)
509
+ enable_testing()
510
+
511
+ if(MSVC)
512
+ set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
513
+ else()
514
+ set(TESTING_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing")
515
+ endif()
516
+ endif()
517
+
518
+ include(CommonConfigOptions)
519
+
520
+ if(FREERDP_UNIFIED_BUILD)
521
+ add_subdirectory(winpr)
522
+ if(WITH_WAYLAND)
523
+ add_subdirectory(uwac)
524
+ endif()
525
+ if(WITH_SERVER)
526
+ option(WITH_RDTK "build rdtk toolkit" ON)
527
+ if(WITH_RDTK)
528
+ add_subdirectory(rdtk)
529
+ endif()
530
+ endif()
531
+
532
+ include_directories(${PROJECT_SOURCE_DIR}/winpr/include)
533
+ include_directories(${PROJECT_BINARY_DIR}/winpr/include)
534
+ else()
535
+ find_package(WinPR 3 REQUIRED)
536
+ include_directories(SYSTEM ${WinPR_INCLUDE_DIR})
537
+ endif()
538
+
539
+ option(WITH_AAD "Compile with support for Azure AD authentication" ${WITH_WINPR_JSON})
540
+
541
+ # Include directories
542
+ include_directories(${CMAKE_CURRENT_BINARY_DIR})
543
+ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
544
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
545
+
546
+ # Sub-directories
547
+
548
+ if(WITH_THIRD_PARTY)
549
+ add_subdirectory(third-party)
550
+ if(NOT "${THIRD_PARTY_INCLUDES}" STREQUAL "")
551
+ include_directories(SYSTEM ${THIRD_PARTY_INCLUDES})
552
+ endif()
553
+ endif()
554
+
555
+ add_subdirectory(libfreerdp)
556
+
557
+ if(WITH_CHANNELS)
558
+ add_subdirectory(channels)
559
+ endif()
560
+
561
+ if(WITH_CLIENT_COMMON OR WITH_CLIENT)
562
+ add_subdirectory(client)
563
+ endif()
564
+
565
+ if(WITH_SERVER)
566
+ add_subdirectory(server)
567
+ endif()
568
+
569
+ # Packaging
570
+
571
+ set(CMAKE_CPACK_INCLUDE_FILE "CMakeCPack.cmake")
572
+
573
+ if(NOT (VENDOR MATCHES "FreeRDP"))
574
+ if(DEFINED CLIENT_VENDOR_PATH)
575
+ if(EXISTS "${PROJECT_SOURCE_DIR}/${CLIENT_VENDOR_PATH}/CMakeCPack.cmake")
576
+ set(CMAKE_CPACK_INCLUDE_FILE "${CLIENT_VENDOR_PATH}/CMakeCPack.cmake")
577
+ endif()
578
+ endif()
579
+ endif()
580
+
581
+ #message("VENDOR: ${VENDOR} CLIENT_VENDOR_PATH: ${CLIENT_VENDOR_PATH} CMAKE_CPACK_INCLUDE_FILE: ${CMAKE_CPACK_INCLUDE_FILE}")
582
+
583
+ set(FREERDP_BUILD_CONFIG_LIST "")
584
+ get_cmake_property(res VARIABLES)
585
+ foreach(var ${res})
586
+ if(var MATCHES "^WITH_*|^BUILD_TESTING*|^WINPR_HAVE_*")
587
+ list(APPEND FREERDP_BUILD_CONFIG_LIST "${var}=${${var}}")
588
+ endif()
589
+ endforeach()
590
+ string(REPLACE ";" " " FREERDP_BUILD_CONFIG "${FREERDP_BUILD_CONFIG_LIST}")
591
+
592
+ add_subdirectory(include)
593
+
594
+ include(${CMAKE_CPACK_INCLUDE_FILE})
595
+
596
+ message(STATUS "Intrinsic path configuration:")
597
+ #ShowCMakeVars("^CMAKE_INSTALL_PREFIX")
598
+ #ShowCMakeVars("^CMAKE_INSTALL_LIBDIR")
599
+ showcmakevars("^FREERDP_INSTALL_PREFIX|^FREERDP_LIBRARY_PATH|^FREERDP_PLUGIN_PATH")
600
+ showcmakevars("^FREERDP_ADDIN_PATH|^FREERDP_EXTENSION_PATH|^FREERDP_PROXY_PLUGINDIR")
local-test-freerdp-full-01/afc-freerdp/ChangeLog ADDED
@@ -0,0 +1,622 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 2025-02-07 Version 3.11.1
2
+
3
+ A bugfix release addressing two regressions reported against 3.11.0
4
+
5
+ Noteworthy changes:
6
+ * Fix a segfault when passing /pth (#11138)
7
+ * Fix a regression in planar codec (#11136)
8
+
9
+ For a complete and detailed change log since the last release run:
10
+ git log 3.11.1...3.11.0
11
+
12
+ # 2025-02-06 Version 3.11.0
13
+
14
+ A new release with bugfixes and code cleanups as well as a few nifty little
15
+ features that will improve your meetings.
16
+
17
+ Noteworthy changes:
18
+ * Updated android client to more recent gradle (#11105, #11110)
19
+ * Fix cmake clean target (#109
20
+ * SDL3 bugfixes and API updates (#11092, #11093, #11128)
21
+ * Fix keyboard mapping, add working japanese and korean types, deprecate
22
+ obsolete functions (#10989, #11035, #11011, #11074, #11037)
23
+ * Fix timezone mapping and iteration (#11077, #11079, #11080, #11083)
24
+ * Fix YUV reverse filter for AVC444 modes (#11045, #11063, #11066, #11081, #11086,
25
+ #11087)
26
+ * Fix H.264 encoder wrapper issues (#11117, #11121, #11078)
27
+ * MS-RDPECAM: Support for H.264 encoding with VA-API (#10887)
28
+ * Fix various CMake, build script and github workflow issues (#10992, #10996,
29
+ #11020, #11031, #11030, #11062, #11064, #11069, #11073, #11123, #11109,
30
+ #11120, #11053, #11089)
31
+ * [codec,planar] fix decoder regression (#11033)
32
+ * [client,cmdline] fix vmconnect checks (#11051)
33
+ * Fix multi-monitor related checks (#11095)
34
+ * Fix various compiler and clang-tidy warnings (#10953, #11003, #11004,
35
+ #11007, #11016, #11018, #11019, #11021, #11017, #11000, #11023, #11024,
36
+ #11026, #11002, #11028, #11001, #11029, #10999, #11006, #11034, #10998,
37
+ #11044, #11050, #11052, #11057, #11059, #11065, #11067, #11068, #11060,
38
+ #11071, #11085, #11088, #11099, #11102, #11108, #11124, #11126, #11129,
39
+ #11130)
40
+
41
+ New Contributors
42
+ * @chewi made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11004
43
+ * @gpotter2 made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11016
44
+ * @vmpn made their first contribution in https://github.com/FreeRDP/FreeRDP/pull/11092
45
+
46
+ For a complete and detailed change log since the last release run:
47
+ git log 3.11.0...3.10.3
48
+
49
+
50
+ # 2024-12-17 Version 3.10.3
51
+
52
+ Follow up release to 3.10.2, as we've discovered a few bugs after release.
53
+
54
+ Noteworthy changes:
55
+ * Fix usage of GetComputerNameExA (#10988)
56
+ * Fix cmake clean target (#10990)
57
+
58
+ For a complete and detailed change log since the last release run:
59
+ git log 3.10.3...3.10.2
60
+
61
+ # 2024-12-16 Version 3.10.2
62
+
63
+ Follow up release to 3.10.1, as we've discovered a few bugs during release
64
+ tests.
65
+
66
+ Noteworthy changes:
67
+ * Fix initializing ComputerName setting (#10985)
68
+ * Fix some warnings and possible leaks (#10985)
69
+
70
+ For a complete and detailed change log since the last release run:
71
+ git log 3.10.2...3.10.1
72
+
73
+ # 2024-12-16 Version 3.10.1
74
+
75
+ We're happy to present a new release of FreeRDP.
76
+ This release contains a few fixes for bugs revealed by checks introduced
77
+ with 3.10.0
78
+
79
+ Noteworthy Changes:
80
+ * Add FreeBSD as architecture build to our ci (#10980 and others)
81
+ * Fix empty include directory creation (#10981)
82
+ * fix SIMD detection (#10968)
83
+ * improve settings unit test coverage (#10966)
84
+ * fix sending server redirection PDU (#10963)
85
+ * fix return and use of GetComputerNameA (#10962)
86
+
87
+ For a complete and detailed change log since the last release run:
88
+ git log 3.10.1...3.10.0
89
+
90
+ # 2024-12-12 Version 3.10.0
91
+
92
+ We're happy to present a new release of FreeRDP.
93
+ This one contains some more code cleanups (we've addressed lots of clang-tidy
94
+ warnings) as well as some highly anticipated new features and bugfixes.
95
+
96
+ So, what is new:
97
+ * Enforce use of a supported build type (#10777)
98
+ * Enable FDK-AAC support for nightly packages (#10875, #10781)
99
+ * Better AAD/AVD support (#10796)
100
+ * Build system updates (#10844)
101
+ * Enforce spell checking (#10881)
102
+ * Split unit tests so a subset can be run during package build (#10776)
103
+ * We're shipping a .desktop file now (#10465)
104
+ * Build scripts for nightly packages (#10835, #10783)
105
+
106
+ Noteworthy changes:
107
+ * Fix wStream API bugs (#10885)
108
+ * Autoreconnect fixes (#10915)
109
+ * Fix monitor layout checks (#10905)
110
+ * Enforce code formatting for CMake files (#10895)
111
+ * Enable SIMD optimizations by default (#10894)
112
+ * WinPR types not based on stdint.h et al (#10754)
113
+ * Improve code assertions (#10768)
114
+ * Code cleanups (#10763, #10914)
115
+
116
+ For a complete and detailed change log since the last release run:
117
+ git log 3.10.0...3.9.0
118
+
119
+
120
+ # 2024-10-21 Version 3.9.0
121
+
122
+ We're proud to present the newest release of FreeRDP.
123
+ This one brings some major code cleanup (we've addressed lots of clang-tidy
124
+ warnings) as well as some highly anticipated new features.
125
+ We also did update the API documentation quite a bit (still incomplete though,
126
+ help always welcome ;))
127
+
128
+ So, what is new:
129
+ * Support for RDPEAR (remote credential guard) /remoteGuard option for non windows clients
130
+ * Global configuration file support, allowing to configure certificate
131
+ accept/ignore/... default settings for all users
132
+ * Simplified manpage generation, eliminates docbook and xmlto dependencies
133
+ speeding up builds
134
+ * New API for client channels to run tasks on RDP thread
135
+ * New extended transport layer API
136
+ * RDPECAM MJPEG support
137
+ * the first updates of timezone definitions from our automated ci
138
+
139
+ Noteworthy changes:
140
+ * Fix bugs in SSE4.1/AVX2 image copy (#10720)
141
+ * Add warnings for invalid monitor settings during connect (#10672)
142
+ * Fix ALSA microphone support (#10664)
143
+ * Fix modal windows in RAILS mode (#10629)
144
+ * Update experimental SDL3 client (SDL3 API should now have been stabilized,
145
+ various pull requests)
146
+ * Fix keyboard layouts, the external JSON did miss a few (#10639)
147
+
148
+ For a complete and detailed change log since the last release run:
149
+ git log 3.9.0...3.8.0
150
+
151
+ # 2024-08-30 Version 3.8.0
152
+
153
+ This is a bugfix release. Due to additional exports required by a bugfix the minor version was incremented
154
+
155
+ Noteworthy changes:
156
+ * Reduce number of warnings on CI build (make dependency includes SYSTEM) (#10509)
157
+ * Fix possible crashes with P11 certificate parsing (#10462, #10463)
158
+ * Various clipboard related fixes (#10472, #10476, #10477, #10480, #10484)
159
+ * Fix a race condition on DesktopResize (xfreerdp) (#10488)
160
+ * Improve certificate warnings (#10489)
161
+ * Try all possible resolved IP addresses for a DNS name on connect (#10491)
162
+ * Fix an issue with GFX SolidFill alpha data (#10498)
163
+ * Various fixes for SDL clients (#10504, #10492, #10471)
164
+ * Fix serial and parallel redirection crashes (#10510)
165
+ * Fix android build issues with NDK 27 (#10529)
166
+ * Improve performance of some WinPR primitives (#10528)
167
+ * Fix an issue with autoreconnect (#10523)
168
+ * Support ssh-askpass like password reading (#10516)
169
+ * Lots of code cleanups to reduce clang-tidy warnings (#10531, #10525, #10521, #10520, #10519, #10518)
170
+
171
+ For a complete and detailed change log since the last release run:
172
+ git log 3.8.0...3.7.0
173
+
174
+ # 2024-08-08 Version 3.7.0
175
+
176
+ This release has accumulated quite a number of changes. Along bugfixes for 3.6.3 it also
177
+ contains a number of improvements for distributors:
178
+
179
+ * Support for FDK-AAC for sound and microphone redirection (activate with -DWITH_FDK_AAC=ON build option)
180
+ This allows enabling the AAC compression that do not ship faad2 and/or faac
181
+ * Support keyboard layouts as JSON resources (activate with -DWITH_KEYBOARD_LAYOUT_FROM_FILE=ON build option,
182
+ also requires JSON support)
183
+ This allows editing keyboard layouts for existing releases should the need arise
184
+ * Support timezones as JSON resources (activate with -DWITH_TIMEZONE_FROM_FILE=ON -DWITH_TIMEZONE_COMPILED=OFF build options,
185
+ also requires JSON support)
186
+ Allows reading the mapping between IANA and windows timezones from a JSON file, allowing easier updates without recompile
187
+ * Improve shadow server compatibility with windows 11 24H2 RDP client
188
+ Windows 7 RFX and bitmap updates with multiple rectangles have been deactivated, so adjust shadow to not send such.
189
+
190
+ Noteworthy changes:
191
+ * Fix ActionScript parameter (#10423)
192
+ * Support keyboard layouts as JSON resource (#10394)
193
+ * Support timezones as JSON resource and command line argument (#10428 #10393 #10391)
194
+ * Deactivate AsyncUpdate (#10402)
195
+ * Compatibility fixes for shadow with windows 11 24H2 (#10455 #10422 #10420 #10416)
196
+ * Fix SDL client autoreconnect (#10390)
197
+ * Fix xfreerdp clipboard locking (#10385)
198
+ * Improve logging (#10426 #10441)
199
+ * Improve warnings and code checks (#10381 #10401 #10403 #10405 #10406 #10410 #10421 #10454)
200
+ * Support FDK-AAC (#10372)
201
+ * Fix drive redirection state transitions (#10367 #10374)
202
+ * Support mth:// routing token (#10366)
203
+ * Ignore unsupported SetThreadPriority (#10363)
204
+ * Fix reported documentation and code typos (#10365 #10368 #10370 #10369 #10431 #10446)
205
+
206
+ For a complete and detailed change log since the last release run:
207
+ git log 3.7.0...3.6.3
208
+
209
+ # 2024-07-08 Version 3.6.3
210
+
211
+ Bugfix release for 3.6.2 issues reported
212
+
213
+ Noteworthy changes:
214
+ * fix a graphics regression (#10352)
215
+ * workaround for a protocol bug of older FreeRDP based servers (#10358)
216
+ * fix possible NULL dereference in command line parser (#10348)
217
+ * fix intrinsics detection (#10346, #10350)
218
+
219
+ For a complete and detailed change log since the last release run:
220
+ git log 3.6.3...3.6.2
221
+
222
+
223
+ # 2024-07-04 Version 3.6.2
224
+
225
+ Bugfix release for 3.6.1 issues detected during release tests
226
+
227
+ Noteworthy changes:
228
+ * Fix xfreerdp and sdl-freerdp manpage names (accidentally changed name)
229
+ * Fix crash of wfreerdp
230
+
231
+ For a complete and detailed change log since the last release run:
232
+ git log 3.6.2...3.6.1
233
+
234
+
235
+ # 2024-07-04 Version 3.6.1
236
+
237
+ Bugfix release for 3.6.0
238
+
239
+ Noteworthy changes:
240
+ * Fix missing dependency for ci abi-checker
241
+ * Fix build WITH_SSE2/WITH_NEON: only enable support if the compiler
242
+ also defines symbols that suggest support.
243
+ * Fix incomplete changelog for 3.6.0:
244
+ * Improved image copy (#10208)
245
+ * Experimental [MS-RDPECAM] support by @oleg0421 (#10258)
246
+ * Improved primitives (#10304)
247
+ * Connection timeout for HTTP gateway transport (#10288)
248
+
249
+ For a complete and detailed change log since the last release run:
250
+ git log 3.6.1...3.6.0
251
+
252
+
253
+ # 2024-07-03 Version 3.6.0
254
+
255
+ With this release we did improve decoder speed so you should notice a significant
256
+ speed improvement with progressive and other gfx codecs.
257
+ We've also eliminated a couple of issues along the way, so an update
258
+ is highly recommended.
259
+
260
+ Noteworthy changes:
261
+ * Improved command line failure logging (#10333)
262
+ * p11-kit support (#10081)
263
+ * json-c support (#10183)
264
+ * (experimental) SDL3 port SDL client (#10195)
265
+ * New option '/gfx:frame-ack:off' for connection delay testing (#10214)
266
+ * improved decoder speed (#10222, #10235)
267
+ * xfreerdp floatbar hide bug (#10237)
268
+ * winpr-makecert month bug (#10236)
269
+ * kerberos kdcUrl check fixes (#10238)
270
+ * timezone updates (#10120, #10144, #10170)
271
+ * fixed a capability protocol violation bug (#10132)
272
+ * fix SDL client dialog bug terminating on credential dialog (#10134)
273
+ * some more oss-fuzz issues (#10126, #10141, #10148, #10161, #10239)
274
+ * rails popup window fixes (#10160)
275
+
276
+
277
+ For a complete and detailed change log since the last release run:
278
+ git log 3.6.0...3.5.1
279
+
280
+
281
+ # 2024-04-22 Version 3.5.1
282
+
283
+ This release eliminates a bunch of issues detected during oss-fuzz runs.
284
+ The test coverage was increased and detected issues eliminates, so an update
285
+ is highly recommended.
286
+
287
+ Noteworthy changes:
288
+ * Lots of fixes for oss-fuzz reports
289
+ * Timezone detection fixes (#10106)
290
+ * SDL key remapping support (#10103)
291
+ * Improved help (#10099)
292
+ * FreeBSD epoll detection fix (#10097)
293
+
294
+ For a complete and detailed change log since the last release run:
295
+ git log 3.5.1...3.5.0
296
+
297
+ # 2024-04-16 Version 3.5.0
298
+
299
+ This release focus is on squashing bugs.
300
+ The improved test coverage and ci builds revealed a number of previously
301
+ unnoticed issues we have addressed and we also got a report from
302
+ Evgeny Legerov of Kaspersky Lab identifying a number of out of bound reads
303
+ in decoder components and one very nasty out of bound write.
304
+
305
+ CVE:
306
+ CVE-2024-32041 [Low[ OutOfBound Read in zgfx_decompress_segment
307
+ CVE-2024-32039 [Moderate] Integer overflow & OutOfBound Write in clear_decompress_residual_data
308
+ CVE-2024-32040 [Low] integer underflow in nsc_rle_decode
309
+ CVE-2024-32458 [Low] OutOfBound Read in planar_skip_plane_rle
310
+ CVE-2024-32459 [Low] OutOfBound Read in ncrush_decompress
311
+ CVE-2024-32460 [Low] OutOfBound Read in interleaved_decompress
312
+
313
+ Noteworthy changes:
314
+ * location channel support #9981, #9984, #10065
315
+ * bugfixes for report from Evgeny Legerov of Kaspersky Lab #10077
316
+ * fuzzer tests from Evgeny Legerov of Kaspersky Lab #10078
317
+ * bugfixes for coverty scanner #10066, #10068, #10069, #10070, #10075
318
+ * clipboard and generic locking fixes #10076
319
+ * split autoreconnect support from enabling it #10063
320
+ * various nightly and workflow fixes #10064, #10058, #10062
321
+ * always set wm-class to app_id #10051
322
+ * refactored and simplified CMake #10046, #10047
323
+ * fix relative mouse event sending #10010
324
+ * improve and unify check for APIs used (POSIX, win32, mac, ...) #9995
325
+ * fix termination for gateway connections #9985
326
+ * fix drivestoredirect RDP file setting, ignore invalid #9989
327
+ * drop IPP support #10038
328
+
329
+ For a complete and detailed change log since the last release run:
330
+ git log 3.5.0...3.4.0
331
+
332
+ # 2024-03-14 Version 3.4.0
333
+
334
+ This release concentrates on improving test coverage and ci builds.
335
+ Some usability issues and inconvenient API functions were fixed on the way.
336
+
337
+ New features have been introduced (stub for location channel)
338
+
339
+ Noteworthy changes:
340
+ * fix a bug in RAIL mode not activating window focus (#9973)
341
+ * improve logging (#9969, #9943)
342
+ * OpenSSL <= 1.1.1 build fixes (#9897)
343
+ * improved help (#9899, #9905)
344
+ * improved MINGW support (#9914, #9915, #9919, #9964, #9965, #9920)
345
+ * fix right control ungrab for xfreerdp (#9960)
346
+ * fix RPATH option settings (#9963)
347
+ * fix SDL client screen updates (#9962, #9954)
348
+ * fix issues with childSession under windows (#9961, #9956, #9922)
349
+ * fix xfreerdp crash with +auth-only (#9947)
350
+ * fix windows printer channel (#9934)
351
+ * add support to enforce gateway policy (#9942)
352
+ * improve big endian support (#9927)
353
+ * ignore empty proxy environment variables (#9929)
354
+ * improve quoting support for command line (#9912)
355
+
356
+ For a complete and detailed change log since the last release run:
357
+ git log 3.4.0...3.3.0
358
+
359
+
360
+ # 2024-02-22 Version 3.3.0
361
+
362
+ This release concentrates on code cleanup and overall quality improvements.
363
+ Some usability issues and inconvenient API functions were fixed on the way.
364
+
365
+ New features have been introduced (better image clipboard) but that stays
366
+ deactivated by default as we´re in a stable series.
367
+
368
+ Check the new CMake options:
369
+ * PLUGIN_ABS_PATHS_DEFAULT disables loading of external channels from all
370
+ but a specified absolute plugin directory defined by FREERDP_PLUGIN_PATH
371
+ * WINPR_UTILS_IMAGE_PNG enables PNG support with libpng in winpr image/clipboard
372
+ * WITH_LODEPNG enables PNG support with lodepng library in winpr image/clipboard
373
+ * WINPR_UTILS_IMAGE_WEBP enables WEBP support in winpr image/clipboard
374
+ * WINPR_UTILS_IMAGE_JPEG enables JPEG support in winpr image/clipboard
375
+ * USE_EXECINFO enables or disables backtrace support with execinfo
376
+ * WITH_WEBVIEW now defaults to OFF on windows, apple and android (not implemented)
377
+
378
+ Noteworthy changes:
379
+ * Improved image clipboard (xfreerdp, wlfreerdp) (#9873, #9826)
380
+ * Improved SDL client (#9875, #9887, #9883, #9878, #9792)
381
+ * Allow plugin loader to only use absolute paths (#9809)
382
+ * Improved TLS channel binding (#9838)
383
+ * Add GCC/clang attribute malloc wrapper WINPR_ATTR_MALLOC (#9863)
384
+ * Major clang-tidy code cleanups and bugfixes (#9799, #9834)
385
+ * Provide some defaults for wObject functions (#9799)
386
+ * Fix a bug in shadow with GFX breaking mstsc (#9818)
387
+ * Improved manpages and help (#9813, #9804)
388
+ * Blocking mode via transport IO interface (#9793)
389
+
390
+ For a complete and detailed change log since the last release run:
391
+ git log 3.3.0...3.2.0
392
+
393
+ # 2024-01-19 Version 3.2.0
394
+
395
+ This release mostly addresses issues reported since the last release.
396
+ Fixing some usablity and build issues as well as adding API functions
397
+ that are needed from external projects
398
+
399
+ Noteworthy changes:
400
+ * Fix proxy module load check (#9777)
401
+ * Improve kerberos error logging (#9771)
402
+ * Improve mac client keyboard handling (#9767)
403
+ * Add option to run client dynamic channel synchronous (#9764)
404
+ * Move huge struct to heap (#9763)
405
+ * Improved failure logging of license module (#9759)
406
+ * Improve server side gfx logging (#9757)
407
+ * Print shadow server help with printf instead of WLog (#9756)
408
+ * Fix SDL client timer initialization (#9754)
409
+ * Fix server peer message parsing (#9751)
410
+ * Enable NEON instructions if __ARM_NEON is defined (#9748)
411
+ * Add new proxy config file option TlsSecLevel (#9741)
412
+ * Improve android and mac os build scripts (#9735)
413
+ * Do not disable wayland support on BSD (#9730)
414
+ * Fix issues with assistance file parsing (#9727, #9728)
415
+ * Keyboard handling fixes for wayland client (#9725)
416
+ * Fix relative pkg-config file paths (#9720)
417
+ * Add new transport IO callback GetPublicKey (#9719)
418
+ * Fix wayland client scaling (#9715)
419
+
420
+ For a complete and detailed change log since the last release run:
421
+ git log 3.2.0...3.1.0
422
+
423
+ # 2023-12-22 Version 3.1.0
424
+
425
+ A new 3.1.0 minor release for the new 3.0.0 series.
426
+ This contains bugfixes, adds (better) support for libressl and mbedtls and
427
+ brings a bunch of improvements for the SDL client.
428
+
429
+ This comes with a price though, we now (optionally) require SDL_image if you
430
+ want to build the sdl-client
431
+
432
+ Since there are multiple new features, some new files (man pages) and new
433
+ optional dependencies we´ve directly incremented the minor version.
434
+
435
+ New CMake options:
436
+ * SDL_USE_COMPILED_RESOURCES (default ON) builds fonts and images into SDL
437
+ client. Set to OFF to install these resources as files. (was already part of
438
+ 3.0.0, but worth mentioning here)
439
+ * WITH_SDL_IMAGE_DIALOGS (default OFF) Show some nice icons for SDL client
440
+ connection dialogs. Requires SDL_image for build.
441
+ * WITH_BINARY_VERSIONING (default OFF) Similar as for libraries the binaries,
442
+ manpages and resource locations created by FreeRDP project are postfixed
443
+ with the API version. Recommended if packagers want to install the package
444
+ alongside FreeRDP 2 without conflicts.
445
+ * RDTK_FORCE_STATIC_BUILD (default OFF) Build and link RDTK statically into
446
+ shadow server. Recommended for packagers as this library is not really used
447
+ outside of FreeRDP-shadow.
448
+ * UWAC_FORCE_STATIC_BUILD (default OFF) Build and link UWAC statically into
449
+ wlfreerdp. Recommended for packagers as this library is not really used
450
+ outside of wlfreerdp.
451
+
452
+ Noteworthy changes:
453
+ * Fix a nasty bug with relative mouse movement (#9677)
454
+ * LibreSSL support enhancements (#9691, #9670)
455
+ * mbedTLS support enhancements (#9662)
456
+ * Improve building on mac OS (#9641)
457
+ * New and improved manpages (#9690, #9650)
458
+ * Unify CMake common options, add (optional) binary versioning and allow
459
+ building rdtk and uwac as static dependencies (#9695)
460
+ * SDL client improvements (#9693, #9657, #9659, #9683, #9680, #9657, #9664,
461
+ #9656)
462
+
463
+ For a complete and detailed change log since the last release run:
464
+ git log 3.1.0...3.0.0
465
+
466
+ # 2023-12-12 Version 3.0.0
467
+
468
+ Final 3.0.0 release just a little over two weeks after the last 3.0.0-rc0.
469
+ This contains bugfixes, drops some legacy code, implements a small feature
470
+ request and adds some improvements to the build system.
471
+
472
+ Most notably is the new PreventInSourceBuilds.cmake which does exactly what
473
+ the name implies, it aborts builds where source equals build directory.
474
+ If you can not use out of source tree builds for some reason, you can
475
+ circumvent this measure with the CMake setting -DALLOW_IN_SOURCE_BUILD=ON
476
+
477
+ Noteworthy changes:
478
+ * add support for AF_VSOCK #9561
479
+ * xfreerdp drop X11 GDI implementation #9492
480
+ * fixed connection freeze with childSession #9594
481
+ * fixed relative mouse input issues #9608
482
+ * fixed issues with drive redirection #9610
483
+ * simplified mac build #9601
484
+ * fixed TSMF to build again #9603
485
+ * fixed command line /gfx parsing bug #9598
486
+ * prevent in source tree build #9550
487
+ * fixed various issues with settings #9595, #9596
488
+ * add E2K cpu support in WinPR #9599
489
+ * fixed wfreerdp DPI settings when used as embedded window #9593
490
+ * android add mouse hover support #9495
491
+
492
+ For a complete and detailed change log since the last release run:
493
+ git log 3.0.0..3.0.0-rc0
494
+
495
+ # 2023-11-27 Version 3.0.0-rc0
496
+
497
+ Nearly 2 months of testing, bugfixing and API refinements later we´re
498
+ happy to announce the first release candidate for FreeRDP 3.0
499
+ The API should now be considered stable and only minor changes (if at all)
500
+ will happen from this point on, so every project using FreeRDP can check
501
+ compatibility with upcoming 3.0
502
+
503
+ Noteworthy changes:
504
+ * Updated rdpSettings API #9465:
505
+ * getter/setter now use enum types for keys (generates compiler warnings for mismatch)
506
+ * Refined functions (added missing, dropped problematic ones)
507
+ * prepared opaque settings (direct struct access now deprecated)
508
+ * Server side [MS-RDPEL] channel #9471
509
+ * Relative mouse movement support #9459
510
+ * relocatable pkg-config files (enable with -DPKG_CONFIG_RELOCATABLE=ON, #9453)
511
+ * cliprdr dropped support for fuse2 (#9453)
512
+ * added support for uriparser for clipboard file:// parsing (#9455)
513
+ * aFreeRDP translation for traditional chinese (zh-rTW) added (#9450)
514
+ * fixed sdl-freerdp crash on credential dialog (#9455)
515
+ * fixed sdl-freerdp alt+tab in fullscreen (#9442)
516
+ * added /connect-child-session option (WIN32 only, #9427)
517
+ * fix rfx-image codec setup (#9425)
518
+ * added missing cmake configuration for winpr-tools (#9453)
519
+ * cleaned up cmake configuration files, dropped no longer required ones (#9455)
520
+ * fixed x11 keyboard layout detection (#9433)
521
+ * add missing API calls for server implementation (tested against ogon, #9453)
522
+ * keep dynamic channels in a hash table instead of a list (#9448)
523
+ * keep TSCredentials in server peer instance (#9430)
524
+ * fix FFMPEG/AAC encoding (#9576)
525
+ * support remote credential guard (#9574)
526
+ * fix printing on mac os 14 (#9569)
527
+ * improve RPC gateway support (#9508)
528
+ * add opus audio support for gnome-remote-desktop (#9575)
529
+ * server side handling of mouse cursor channel [MS-RDPEMSC] (#9513)
530
+
531
+ For a complete and detailed change log since the last release run:
532
+ git log 3.0.0-rc0..3.0.0-beta4
533
+
534
+ # 2023-09-31 Version 3.0.0-beta4
535
+
536
+ Noteworthy changes:
537
+ * Improved and fixed AVD authentication, now allows retries for
538
+ machines just starting up
539
+ * Improve RDP file parser, prepare new fields used by AVD
540
+ * Fixed and improved pen support in multitouch implementation (xfreerdp)
541
+ * Lots of smaller code and leak cleanups
542
+
543
+ For a complete and detailed change log since the last release run:
544
+ git log 3.0.0-beta4..3.0.0-beta3
545
+
546
+ # 2023-08-31 Version 3.0.0-beta3
547
+
548
+ Noteworthy changes:
549
+ * fix xfreerdp keyboard on mac os
550
+ * Various crashes and input check fixes
551
+ * Improved logging of autodetect, redirection and fastpath failures
552
+ * Smartcard emulation now selectable at runtime
553
+ * Allow certificates without a subject to pass client checks
554
+ * Fix FindFirstFile issues on android
555
+ * Add FREERDP_ENTRY_POINT to silence -Wmissing-prototypes warnings for
556
+ library entry points
557
+ * Add WINPR_RESTRICT to enable restrict (C99) or __restring (MSVC)
558
+ keywords for compiler
559
+ * Fix support for older OpenSSL versions
560
+
561
+ For a complete and detailed change log since the last release run:
562
+ git log 3.0.0-beta3..3.0.0-beta2
563
+
564
+ # 2023-08-03 Version 3.0.0-beta2
565
+
566
+ Noteworthy changes:
567
+ * Update CMake defaults, now all features are enabled by default with a platform
568
+ independent option if multiple are available.
569
+ * SDL client: (basic) multimonitor support
570
+ * SDL client: fix dialog cleanup order (crash fix)
571
+ * clipboard: fix FUSE shutdown crash
572
+ * fixed drive redirection: FindNextFile did miss some files/directories
573
+ * improved AAD support: honor rdp file options
574
+ * improved (gateway) http failure logging
575
+ * improved shadow server error handling
576
+ * improved CMake configuration (using find_dependency)
577
+ * updated timezone definitions
578
+ * mbedTLS build fixed
579
+ * improved MINGW build support
580
+
581
+ For a complete and detailed change log since the last release run:
582
+ git log 3.0.0-beta2..3.0.0-beta1
583
+
584
+ # 2023-07-21 Version 3.0.0-beta1
585
+
586
+ We are pleased to announce the first beta release for the next stable 3.0
587
+ series of FreeRDP. It has been a huge endeavour to implement all the new
588
+ shiny bells and whistles as well as clean up the code base and we´re still
589
+ ironing out some smaller glitches.
590
+ This is the first API breaking change since the 2.0 series and there are
591
+ some adjustments to be made for existing applications.
592
+ See https://github.com/FreeRDP/FreeRDP/wiki/FreeRDP3-migration-notes for
593
+ help (still incomplete)
594
+
595
+ Noteworthy changes:
596
+ * Support for AAD/AVD authentication
597
+ * Support for websocket transport
598
+ * Support smartcard authentication (TLS and NLA)
599
+ * Full smartcard emulation support (login with certificate + key)
600
+ * Rewritten proxy, new module API
601
+ * New reference client based on SDL2 (work in progress)
602
+ * Rewritten logging, now parsing issues are all writing to the log so
603
+ that issues with protocol incompatibilities can be easier analyzed
604
+ by just turning on logging
605
+ * Full OpenSSL 3 support
606
+ * Internal implementations for RC4, MD4 and MD5 (required for non critical
607
+ parts in RDP but not part of more recent SSL libraries)
608
+ * Updated RDP protocol support
609
+ * Improved xfreerdp remote app support
610
+ * Reworked internal state machine for both client and server implementations
611
+ * Server implementations can now make use of connect-time network autodetection
612
+ * Improved clipboard handling, now also support server-to-client file transfer
613
+ (currently xfreerdp only)
614
+ * EnhancedRemoteApp support: Utilizing the more modern standard allows remote
615
+ apps with less glitches and window shadows
616
+ * Added client- and server-side handling for RDSTLS
617
+ * Support for the graphics redirection channel
618
+
619
+ For a complete and detailed change log since the last release run:
620
+ git log 3.0.0-beta1..2.10.0
621
+
622
+
local-test-freerdp-full-01/afc-freerdp/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
local-test-freerdp-full-01/afc-freerdp/README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+
3
+ FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released under the Apache license.
4
+ Enjoy the freedom of using your software wherever you want, the way you want it, in a world where
5
+ interoperability can finally liberate your computing experience.
6
+
7
+ ## Code Quality Status
8
+
9
+ [![abi-checker](https://github.com/FreeRDP/FreeRDP/actions/workflows/abi-checker.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/abi-checker.yml)
10
+ [![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)
11
+ [![CodeQL](https://github.com/FreeRDP/FreeRDP/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/codeql-analysis.yml)
12
+ [![mingw-builder](https://github.com/FreeRDP/FreeRDP/actions/workflows/mingw.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/mingw.yml)
13
+ [![[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)
14
+ [![[freebsd] architecture builds](https://github.com/FreeRDP/FreeRDP/actions/workflows/freebsd.yml/badge.svg)](https://github.com/FreeRDP/FreeRDP/actions/workflows/freebsd.yml)
15
+ [![coverity](https://scan.coverity.com/projects/616/badge.svg)](https://scan.coverity.com/projects/freerdp)
16
+
17
+ ## Resources
18
+
19
+ Project website: https://www.freerdp.com/
20
+ Issue tracker: https://github.com/FreeRDP/FreeRDP/issues
21
+ Sources: https://github.com/FreeRDP/FreeRDP/
22
+ Downloads: https://pub.freerdp.com/releases/
23
+ Wiki: https://github.com/FreeRDP/FreeRDP/wiki
24
+ API documentation: https://pub.freerdp.com/api/
25
+
26
+ Security policy: https://github.com/FreeRDP/FreeRDP/security/policy
27
+
28
+ Matrix room : #FreeRDP:matrix.org (main)
29
+ XMPP channel: #FreeRDP#matrix.org@matrix.org (bridged)
30
+ IRC channel : #freerdp @ irc.oftc.net (bridged)
31
+ Mailing list: https://lists.sourceforge.net/lists/listinfo/freerdp-devel
32
+
33
+ ## Microsoft Open Specifications
34
+
35
+ Information regarding the Microsoft Open Specifications can be found at:
36
+ https://www.microsoft.com/openspecifications/
37
+
38
+ A list of reference documentation is maintained here:
39
+ https://github.com/FreeRDP/FreeRDP/wiki/Reference-Documentation
40
+
41
+ ## Compilation
42
+
43
+ Instructions on how to get started compiling FreeRDP can be found on the wiki:
44
+ https://github.com/FreeRDP/FreeRDP/wiki/Compilation
local-test-freerdp-full-01/afc-freerdp/SECURITY.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP Security Policies and Procedures
2
+
3
+ This document describes the security policy and procedures for the [FreeRDP Project](https://github.com/FreeRDP/FreeRDP).
4
+ The following topics are covered:
5
+
6
+ * [Supported Versions](#supported-versions)
7
+ * [Reporting a Vulnerability](#reporting-a-vulnerability)
8
+ * [Disclosure Procedure](#disclosure-procedure)
9
+
10
+
11
+ ## Supported versions
12
+
13
+ Security is very important for us therefore we try to provide security updates and support for
14
+ the latest stable version as well as for the development branch.
15
+ 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.
16
+
17
+ The following table shows the currently supported versions:
18
+
19
+ | Version | Branch | Supported |
20
+ | ------- |--------------| ------------------ |
21
+ | < 2.0.0 | stable-1.x | :x: |
22
+ | 2.x.x | stable-2.0 | :heavy_check_mark: |
23
+ | 3.x.x | stable-3.0 | :white_check_mark: |
24
+ | - | master | :white_check_mark: |
25
+
26
+
27
+ ## Reporting a vulnerability
28
+
29
+ **IMPORTANT**: Please, do not file security vulnerabilities as public issues on GitHub
30
+
31
+ In advance: **Thank you** for reporting a security vulnerability and making FreeRDP more stable! We really appreciate your effort.
32
+ Please let us know who we should give the credit or attributions to.
33
+
34
+
35
+ 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
36
+
37
+ In case of an email you can use the [FreeRDP security team GPG key](#reporting-gpg-key) for encrypted communication.
38
+
39
+ Once we receive a report we will review it and respond as soon as possible.
40
+
41
+ ###
42
+
43
+
44
+ ## Disclosure procedure
45
+
46
+ When the FreeRDP team receives a report one of the team members will be assigned as primary contact.
47
+ The primary contact will do all further communications and coordinate the fix and release process.
48
+
49
+ How your report will be handled:
50
+
51
+ * When a report is received we will acknowledge the reception and review the reported issue(s) as soon as possible.
52
+ * 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.
53
+ * On a private branch we will fix the issue and check the code for any potential similar problem.
54
+ * After the fix is validated we will create and publish a new release for all supported versions and publish the advisories.
55
+
56
+ ## Reporting GPG key
57
+
58
+ FreeRDP's security reporting public gpg key https://pub.freerdp.com/FreeRDP-security-team.pub.asc
59
+
60
+ ```
61
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
62
+
63
+ mQINBGBz+jsBEADaIM94hYfn/xDzncQwXl7/q6+06+ssqO3iUGqFr+0EPS+HxRjD
64
+ BeKjVRSkuo0+QLQoZgCwkoltEj1xRWNqCTDMA+oZkZH8L82eqCnUQqgCOyNWAVMH
65
+ 6u6ValiZH3ruYxergBBHhyR4Ot2ia0xWN8MKTp+emLpzQ7goimGMo0mxR5FiDAdb
66
+ QKz1q5bgs3bb2pLpERNF+z13OS10Mzk1zdr++1pov5PWOTBRKmvBtPJKswmDpb0y
67
+ jQGeeqBFZwKzx0n6BTzDZtkqzTwvGhbm9Sb+qO0IO66IV8zQhPG/JUfDkByd6mX9
68
+ Ykke0gxoRx54XqoRwZGNydOxMN6g3Oj1+ioWisltYLs/SzW20f3AMCoTeYyfjKtf
69
+ 01refrA3aRfhDctvW5/s2LP0OEG2P/yQYXiGhK6uVxShz3Oa5dhFwiS8G63omZRH
70
+ AEqSk46EhAbbT4xfZ/Np209rhis4KW40cMMpI0F+XpyfT05ZQD6ytHTPgWTxv/OF
71
+ G9zy2ysT0kq+t+Hb+1RWQUq/2Dz9Lf6xLZPgqtyzg8xiFxZ4i1kf/VDWa3M76zn3
72
+ qMcj3SPOxKY//wW70jCxf44yD38NvSa1M2Sz/K/RJKWkRWP/jhV1UHYusbzCmsvm
73
+ M9JkknNMJvGIjBDjHEVy6dlTaHQoHDY+Me9gsrEX0ZS9xXgAiB2IupabEwARAQAB
74
+ tEJGcmVlUkRQIFNlY3VyaXR5IFRlYW0gKGh0dHBzOi8vZnJlZXJkcC5jb20pIDxz
75
+ ZWN1cml0eUBmcmVlcmRwLmNvbT6JAk4EEwEKADgWIQRvuAE0sDt7JnxXu0o3Ibww
76
+ YbfjNAUCYHP6OwIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRA3IbwwYbfj
77
+ NPviD/43NLg7YfjAlvj5GipSmgelLwlIA+L/qbrf4NAB+NZ9oqp3bBdj4e5gZmiI
78
+ zd6bkANCqk21YiOE31medUfy+nfBQFVvj0oUg1X16C6RaIX5qA3Dwt5qBwKmDkT5
79
+ j7JlxUS6Eluiau67ePiDYu2Wbp0qYuAmNUNL+Y2NCO9UJiy0Oq6YVXS971D5lC+a
80
+ SX0x9pizmFV3zro+l6/3kHTVbPednfX99yz9SZge64aWXo3MXVN8JD0lR3+92l99
81
+ XsFDc+lGeR4azLFIqXC4Cr5Lbk34Hw/VwUC32xxFUaJ2ZmV3pA8bhCtBSxSmxnHS
82
+ H3hoBaD1WpuApbW8Psx6qsgoaSUdWsjluA4eQ5afJBf9O2NlT1mim5MAINY4PbWP
83
+ o4zq3p1ABVTzuB8tsGA9o6DeYVUUrj7lCv9STdGRhm0472BDkp/gvKMBoPgg3Qez
84
+ kvGKK7iVy8R/BOPjh9wP1art5JLVsralXGHA/5Ceid4ojKFzGIC9g3lnAPh+T/eM
85
+ duyY9XH4un1r73r6DRqUoczSfHYbxhKxWt0cRNdIadcXXusMPV/w4J4j55WcLrBE
86
+ 5nopp/prJ5bYegUvRRrwVSFwLDxkE2dh68Zvlh5VWXIPFge0RPEAijYWR5qR2z+/
87
+ VHgPYmliOnWFJN1rzekmWjKFtg5A57FkZyk3cp5x0/2xAX+TIbkCDQRgc/o7ARAA
88
+ vw53CoVkMzBlisSEETNdEKQMaiQ8BtbC438v/b1mOOeoE0YCfSW7RyflA/TXHOah
89
+ db0s3v/Kk2xmbjeMS9IJXlWviKKnOVMrMZvtJdQ4EKfqc5EpxNx7OiEofA/7n7Xs
90
+ 1YEt6KjYaM/vgANl9HA2UXzqSFiRhkWjj1WA7vhqCWUArpAMGeCDYab2BBfp6Z4f
91
+ W9178N2vHH+Hh/uBwGUDnShU38GH8Nstkdcyw5puiJqNQBfZ1Fz9luzutp6zAgHz
92
+ WzobeRPZCCXs7CfxcvpkFS0ctOteQtIRIfP+jbDnldMmClQ87UVcKv0pCCJkMLNk
93
+ YUCMAb2UC2boCIf0omeeque4+FOphcO4+R/8jc6cYlQpgwUg2/IwBEEnCqtvo3qu
94
+ k6uzONhfWZPtUdJd158MGKGTogXVXGzoGzxIrKkZ4W1VuuMiEmhIQZO8e7/4Iz4a
95
+ Zp4qQXI8rsmNJN3lB5a7MWgrZ8mjllYRdfiTEvfQ+PiQqnG6PEHZ82om9kp555gs
96
+ 15UqhjHAqRRtfXzQvZko0ngAxxZNVFPwK8LnxkyEPClRBC5eV3ljI8cvCfnWD01q
97
+ rCzSlSafFHCEUEQOhOrf/bBbXPkYTJw2KlumH5w9R6xQWgqneiD/+Qmqdclzdn36
98
+ Pgbhyu6uSNZehbx5ptt/EM66JSAW7Q7W6Qnz5PNnHgEAEQEAAYkCNgQYAQoAIBYh
99
+ BG+4ATSwO3smfFe7SjchvDBht+M0BQJgc/o7AhsMAAoJEDchvDBht+M0JYUQALlV
100
+ dwmk6ZFq5dq0utWgutysL47b30BhYwNMVe0/6UW4h4TYaW6B3f58X7ik7EdYciyR
101
+ 68eYfwKGhuv/y90QaGXJMU13XHpoInSaHQRhn5M/GkN16DBXdBok70Fh9Gx89Zhs
102
+ VKF3qwIVx5AO5CwrVA6F/iOiUEW31xiT7VFkbW1Cfl5H+M6nVXSR1bOdmxTObTz7
103
+ CEeJMOVrZs36hVLMWLqZF0igVebO2AsDOY63fy/9MLn8ynCHhnAMvsm9ULWuFzGj
104
+ OsJezChduaHqPkopgwihe7jthUn4qWjABbbzKkS6HLBpGAfCzUun+lMpvIEUf+EJ
105
+ bpk7gj9xDEP6y96tV/dCeWb4p8N8webR8nVgsRxoEnfIdCkoB80iZGOzKfYYnvdz
106
+ ngs8MIL6dC4Nc1/t9ECV4O/w4uwIH65nC1ay0YOK/O/j2SEfnVHQmAuOsgTz+pBn
107
+ u6DIA2HsBzFdOCljtf3m4AeAaTbL7MBSDceApqg0lcrhjclqHJo1aJh3M6aVm3gq
108
+ yUt7y26Hkh/vYEJwW4gqRho4gb7BvjTZh5LUbrjmRtexFQ1eWM82u23yYS2L+y2Y
109
+ ejSKIKmJhXHqsgCVGYw5woZEEMzgpkoIWYG/Eoy+oVuU02QITh/Uc5VRsA9DuwSV
110
+ Vw2F8gu/fHiadawxWIhUH+plFVQZc1KwgPcIMW3S
111
+ =O0kP
112
+ -----END PGP PUBLIC KEY BLOCK-----
113
+ ```
114
+ [^1]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability
local-test-freerdp-full-01/afc-freerdp/client/Android/BuildFlags.java.in ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ package com.freerdp.freerdpcore.utils;
2
+
3
+ public class BuildFlags
4
+ {
5
+ private final static boolean USE_OPENSSL_DEFAULT_NAMES = @USE_OPENSSL_DEFAULT_NAMES@;
6
+ }
local-test-freerdp-full-01/afc-freerdp/client/CMakeLists.txt ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP Clients
3
+ #
4
+ # Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ # Clients
19
+
20
+ include(CMakeDependentOption)
21
+ include(InstallFreeRDPDesktop)
22
+
23
+ if(WITH_CLIENT_COMMON)
24
+ add_subdirectory(common)
25
+ endif()
26
+
27
+ if(FREERDP_VENDOR AND WITH_CLIENT)
28
+ if(WIN32 AND NOT UWP)
29
+ add_subdirectory(Windows)
30
+ else()
31
+ if(WITH_SAMPLE)
32
+ add_subdirectory(Sample)
33
+ endif()
34
+ endif()
35
+
36
+ if(WITH_CLIENT_SDL)
37
+ add_subdirectory(SDL)
38
+ endif()
39
+
40
+ if(WITH_X11)
41
+ add_subdirectory(X11)
42
+ endif()
43
+
44
+ if(WITH_WAYLAND AND WAYLAND_FOUND)
45
+ add_subdirectory(Wayland)
46
+ endif()
47
+
48
+ if(APPLE)
49
+ if(IOS)
50
+ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS")
51
+ message(STATUS "Adding iOS client")
52
+ add_subdirectory(iOS)
53
+ endif()
54
+ else()
55
+ option(WITH_CLIENT_MAC "Build native mac client" ON)
56
+ if(WITH_CLIENT_MAC)
57
+ add_subdirectory(Mac)
58
+ endif()
59
+ endif()
60
+ endif()
61
+
62
+ if(ANDROID)
63
+ message(STATUS "Android client module is built with Android Studio project")
64
+ endif()
65
+ endif()
66
+
67
+ # Pick up other clients
68
+ if(WITH_CLIENT)
69
+ set(FILENAME "ModuleOptions.cmake")
70
+ file(GLOB FILEPATHS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${FILENAME}")
71
+
72
+ foreach(FILEPATH ${FILEPATHS})
73
+ if(${FILEPATH} MATCHES "^([^/]*)/+${FILENAME}")
74
+ string(REGEX REPLACE "^([^/]*)/+${FILENAME}" "\\1" FREERDP_CLIENT ${FILEPATH})
75
+ set(FREERDP_CLIENT_ENABLED 0)
76
+ include(${FILEPATH})
77
+ if(FREERDP_CLIENT_ENABLED)
78
+ if(NOT (${FREERDP_CLIENT_VENDOR} MATCHES "FreeRDP"))
79
+ list(APPEND FREERDP_EXTRA_CLIENTS ${FREERDP_CLIENT})
80
+ if(${FREERDP_CLIENT_VENDOR} MATCHES "${VENDOR}")
81
+ set(CLIENT_VENDOR_PATH "client/${FREERDP_CLIENT}" PARENT_SCOPE)
82
+ endif()
83
+ endif()
84
+ endif()
85
+ endif()
86
+ endforeach()
87
+
88
+ foreach(FREERDP_CLIENT ${FREERDP_EXTRA_CLIENTS})
89
+ add_subdirectory(${FREERDP_CLIENT})
90
+ endforeach()
91
+ endif()
92
+
93
+ if(WITH_FUSE)
94
+ list(APPEND FREERDP_CLIENT_PC_PRIVATE_LIBS "-lfuse3")
95
+ endif()
96
+
97
+ list(JOIN FREERDP_CLIENT_PC_PRIVATE_LIBS " " FREERDP_CLIENT_PC_PRIVATE_LIBS)
98
+ include(pkg-config-install-prefix)
99
+ cleaning_configure_file(
100
+ ${CMAKE_CURRENT_SOURCE_DIR}/freerdp-client.pc.in
101
+ ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc @ONLY
102
+ )
103
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc
104
+ DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}
105
+ )
106
+
107
+ export(PACKAGE freerdp-client)
108
+
109
+ setfreerdpcmakeinstalldir(FREERDP_CLIENT_CMAKE_INSTALL_DIR "FreeRDP-Client${FREERDP_VERSION_MAJOR}")
110
+
111
+ configure_package_config_file(
112
+ FreeRDP-ClientConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfig.cmake
113
+ INSTALL_DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR} PATH_VARS FREERDP_INCLUDE_DIR
114
+ )
115
+
116
+ write_basic_package_version_file(
117
+ ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfigVersion.cmake VERSION ${FREERDP_VERSION}
118
+ COMPATIBILITY SameMajorVersion
119
+ )
120
+
121
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfig.cmake
122
+ ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfigVersion.cmake
123
+ DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR}
124
+ )
125
+
126
+ install(EXPORT FreeRDP-ClientTargets DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR})
local-test-freerdp-full-01/afc-freerdp/client/FreeRDP-ClientConfig.cmake.in ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include(CMakeFindDependencyMacro)
2
+ find_dependency(WinPR @FREERDP_VERSION@)
3
+ find_dependency(FreeRDP @FREERDP_VERSION@)
4
+ if("@WITH_SMARTCARD_EMULATE@")
5
+ find_dependency(ZLIB)
6
+ endif()
7
+
8
+ @PACKAGE_INIT@
9
+
10
+ set(FreeRDP-Client_VERSION_MAJOR "@FREERDP_VERSION_MAJOR@")
11
+ set(FreeRDP-Client_VERSION_MINOR "@FREERDP_VERSION_MINOR@")
12
+ set(FreeRDP-Client_VERSION_REVISION "@FREERDP_VERSION_REVISION@")
13
+
14
+ set_and_check(FreeRDP-Client_INCLUDE_DIR "@PACKAGE_FREERDP_INCLUDE_DIR@")
15
+
16
+ include("${CMAKE_CURRENT_LIST_DIR}/FreeRDP-ClientTargets.cmake")
local-test-freerdp-full-01/afc-freerdp/client/Mac/CMakeLists.txt ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cmake_minimum_required(VERSION 3.13)
2
+
3
+ if(NOT FREERDP_DEFAULT_PROJECT_VERSION)
4
+ set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0")
5
+ endif()
6
+
7
+ project(MacFreeRDP-library VERSION ${FREERDP_DEFAULT_PROJECT_VERSION})
8
+
9
+ message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
10
+
11
+ cmake_policy(SET CMP0026 OLD)
12
+ cmake_policy(SET CMP0045 OLD)
13
+
14
+ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
15
+ include(CommonConfigOptions)
16
+
17
+ find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
18
+ find_library(COCOA_LIBRARY Cocoa REQUIRED)
19
+ find_library(APPKIT_LIBRARY AppKit REQUIRED)
20
+ find_library(IOKIT_LIBRARY IOKit REQUIRED)
21
+ find_library(COREGRAPHICS_LIBRARY CoreGraphics REQUIRED)
22
+
23
+ set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY} ${IOKIT_LIBRARY})
24
+
25
+ set(XIBS CertificateDialog.xib PasswordDialog.xib)
26
+
27
+ set(SOURCES "")
28
+
29
+ set(OBJECTIVE_SOURCES
30
+ main.m
31
+ mf_client.m
32
+ MRDPCursor.m
33
+ MRDPView.m
34
+ Keyboard.m
35
+ Clipboard.m
36
+ CertificateDialog.m
37
+ PasswordDialog.m
38
+ )
39
+
40
+ list(APPEND SOURCES ${OBJECTIVE_SOURCES})
41
+
42
+ set(HEADERS
43
+ mfreerdp.h
44
+ mf_client.h
45
+ MRDPCursor.h
46
+ MRDPView.h
47
+ Keyboard.h
48
+ Clipboard.h
49
+ CertificateDialog.h
50
+ PasswordDialog.h
51
+ )
52
+
53
+ set(RESOURCES "en.lproj/InfoPlist.strings")
54
+
55
+ # Include XIB file in Xcode resources.
56
+ if("${CMAKE_GENERATOR}" MATCHES "Xcode")
57
+ message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}")
58
+ list(APPEND RESOURCES ${XIBS})
59
+ set(IS_XCODE ON)
60
+ endif()
61
+
62
+ add_library(${PROJECT_NAME} ../common/client.c ${SOURCES} ${HEADERS} ${RESOURCES})
63
+
64
+ set(LIBS ${EXTRA_LIBS} freerdp-client)
65
+
66
+ target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBS})
67
+
68
+ set_target_properties(${PROJECT_NAME} PROPERTIES RESOURCE "${RESOURCES}")
69
+
70
+ if(NOT IS_XCODE)
71
+ find_program(IBTOOL ibtool REQUIRED HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
72
+
73
+ # Compile the .xib files using the 'ibtool' program with the destination being the app package
74
+ foreach(xib ${XIBS})
75
+ get_filename_component(XIB_WE ${xib} NAME_WE)
76
+ set(NIB ${CMAKE_CURRENT_BINARY_DIR}/${XIB_WE}.nib)
77
+ list(APPEND NIBS ${NIB})
78
+
79
+ add_custom_command(
80
+ TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${IBTOOL} --errors --warnings --notices --output-format
81
+ human-readable-text --compile ${NIB} ${CMAKE_CURRENT_SOURCE_DIR}/${xib}
82
+ COMMENT "Compiling ${xib}"
83
+ )
84
+ endforeach()
85
+
86
+ install(FILES ${NIBS} DESTINATION ${CMAKE_INSTALL_DATADIR})
87
+ endif()
88
+
89
+ install(TARGETS ${PROJECT_NAME} COMPONENT client RESOURCE DESTINATION ${CMAKE_INSTALL_DATADIR})
90
+
91
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
92
+ add_subdirectory(cli)
local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.h ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thicast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #import <Cocoa/Cocoa.h>
22
+
23
+ @interface CertificateDialog : NSWindowController
24
+ {
25
+ @public
26
+ NSTextField *textCommonName;
27
+ NSTextField *textSubject;
28
+ NSTextField *textIssuer;
29
+ NSTextField *textFingerprint;
30
+ NSTextField *textMismatch;
31
+ NSTextField *messageLabel;
32
+ NSString *serverHostname;
33
+
34
+ BOOL hostMismatch;
35
+ BOOL changed;
36
+ int result;
37
+ }
38
+ @property(retain) IBOutlet NSTextField *textCommonName;
39
+ @property(retain) IBOutlet NSTextField *textSubject;
40
+ @property(retain) IBOutlet NSTextField *textIssuer;
41
+ @property(retain) IBOutlet NSTextField *textFingerprint;
42
+ @property(retain) IBOutlet NSTextField *textMismatch;
43
+ @property(retain) IBOutlet NSTextField *messageLabel;
44
+
45
+ - (IBAction)onAccept:(NSObject *)sender;
46
+ - (IBAction)onTemporary:(NSObject *)sender;
47
+ - (IBAction)onCancel:(NSObject *)sender;
48
+
49
+ @property(retain) NSString *serverHostname;
50
+ @property(retain) NSString *commonName;
51
+ @property(retain) NSString *subject;
52
+ @property(retain) NSString *issuer;
53
+ @property(retain) NSString *fingerprint;
54
+ @property BOOL hostMismatch;
55
+ @property BOOL changed;
56
+ @property(readonly) int result;
57
+
58
+ - (int)runModal:(NSWindow *)mainWindow;
59
+
60
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.m ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thicast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #import "CertificateDialog.h"
22
+ #import <freerdp/client/cmdline.h>
23
+
24
+ #import <CoreGraphics/CoreGraphics.h>
25
+
26
+ @interface CertificateDialog ()
27
+
28
+ @property int result;
29
+
30
+ @end
31
+
32
+ @implementation CertificateDialog
33
+
34
+ @synthesize textCommonName;
35
+ @synthesize textFingerprint;
36
+ @synthesize textIssuer;
37
+ @synthesize textSubject;
38
+ @synthesize textMismatch;
39
+ @synthesize messageLabel;
40
+ @synthesize serverHostname;
41
+ @synthesize commonName;
42
+ @synthesize fingerprint;
43
+ @synthesize issuer;
44
+ @synthesize subject;
45
+ @synthesize hostMismatch;
46
+ @synthesize changed;
47
+ @synthesize result;
48
+
49
+ - (id)init
50
+ {
51
+ return [self initWithWindowNibName:@"CertificateDialog"];
52
+ }
53
+
54
+ - (void)windowDidLoad
55
+ {
56
+ [super windowDidLoad];
57
+ // Implement this method to handle any initialization after your window controller's window has
58
+ // been loaded from its nib file.
59
+ [self.window setTitle:self.serverHostname];
60
+ if (self.changed)
61
+ [self.messageLabel setStringValue:[NSString stringWithFormat:@"Changed certificate for %@",
62
+ self.serverHostname]];
63
+ else
64
+ [self.messageLabel setStringValue:[NSString stringWithFormat:@"New Certificate for %@",
65
+ self.serverHostname]];
66
+
67
+ if (!self.hostMismatch)
68
+ [self.textMismatch
69
+ setStringValue:[NSString stringWithFormat:
70
+ @"NOTE: The server name matches the certificate, good."]];
71
+ else
72
+ [self.textMismatch
73
+ setStringValue:[NSString
74
+ stringWithFormat:
75
+ @"ATTENTION: The common name does not match the server name!"]];
76
+ [self.textCommonName setStringValue:self.commonName];
77
+ [self.textFingerprint setStringValue:self.fingerprint];
78
+ [self.textIssuer setStringValue:self.issuer];
79
+ [self.textSubject setStringValue:self.subject];
80
+ }
81
+
82
+ - (IBAction)onAccept:(NSObject *)sender
83
+ {
84
+ [NSApp stopModalWithCode:1];
85
+ }
86
+
87
+ - (IBAction)onTemporary:(NSObject *)sender
88
+ {
89
+ [NSApp stopModalWithCode:2];
90
+ }
91
+
92
+ - (IBAction)onCancel:(NSObject *)sender
93
+ {
94
+ [NSApp stopModalWithCode:0];
95
+ }
96
+
97
+ - (int)runModal:(NSWindow *)mainWindow
98
+ {
99
+ if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
100
+ {
101
+ [mainWindow beginSheet:self.window completionHandler:nil];
102
+ self.result = [NSApp runModalForWindow:self.window];
103
+ [mainWindow endSheet:self.window];
104
+ }
105
+ else
106
+ {
107
+ [NSApp beginSheet:self.window
108
+ modalForWindow:mainWindow
109
+ modalDelegate:nil
110
+ didEndSelector:nil
111
+ contextInfo:nil];
112
+ self.result = [NSApp runModalForWindow:self.window];
113
+ [NSApp endSheet:self.window];
114
+ }
115
+
116
+ [self.window orderOut:nil];
117
+ return self.result;
118
+ }
119
+
120
+ - (void)dealloc
121
+ {
122
+ [textCommonName release];
123
+ [textFingerprint release];
124
+ [textIssuer release];
125
+ [textSubject release];
126
+ [messageLabel release];
127
+ [serverHostname release];
128
+ [commonName release];
129
+ [fingerprint release];
130
+ [issuer release];
131
+ [subject release];
132
+ [super dealloc];
133
+ }
134
+
135
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/CertificateDialog.xib ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
5
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6
+ </dependencies>
7
+ <objects>
8
+ <customObject id="-2" userLabel="File's Owner" customClass="CertificateDialog">
9
+ <connections>
10
+ <outlet property="messageLabel" destination="7" id="50"/>
11
+ <outlet property="textCommonName" destination="2HW-of-a4n" id="4442"/>
12
+ <outlet property="textFingerprint" destination="cLB-ZO-jvx" id="4445"/>
13
+ <outlet property="textIssuer" destination="kHA-F4-dxw" id="4444"/>
14
+ <outlet property="textMismatch" destination="LgQ-ni-jXv" id="5550"/>
15
+ <outlet property="textSubject" destination="R9r-82-XAH" id="4443"/>
16
+ <outlet property="window" destination="1" id="3"/>
17
+ </connections>
18
+ </customObject>
19
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
20
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
21
+ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
22
+ <windowStyleMask key="styleMask" titled="YES" texturedBackground="YES"/>
23
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
24
+ <rect key="contentRect" x="196" y="240" width="641" height="338"/>
25
+ <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
26
+ <view key="contentView" id="2">
27
+ <rect key="frame" x="0.0" y="0.0" width="641" height="338"/>
28
+ <autoresizingMask key="autoresizingMask"/>
29
+ <subviews>
30
+ <textField verticalHuggingPriority="750" id="7">
31
+ <rect key="frame" x="47" y="274" width="344" height="17"/>
32
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
33
+ <textFieldCell key="cell" scrollable="YES" sendsActionOnEndEditing="YES" title="Certificate for SERVER_NAME" placeholderString="" id="20">
34
+ <font key="font" metaFont="system"/>
35
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
36
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
37
+ </textFieldCell>
38
+ </textField>
39
+ <button verticalHuggingPriority="750" id="8">
40
+ <rect key="frame" x="545" y="13" width="82" height="32"/>
41
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
42
+ <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="18">
43
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
44
+ <font key="font" metaFont="system"/>
45
+ <string key="keyEquivalent" base64-UTF8="YES">
46
+ Gw
47
+ </string>
48
+ </buttonCell>
49
+ <connections>
50
+ <action selector="onCancel:" target="-2" id="52"/>
51
+ </connections>
52
+ </button>
53
+ <button verticalHuggingPriority="750" id="9">
54
+ <rect key="frame" x="463" y="13" width="82" height="32"/>
55
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
56
+ <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="17">
57
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
58
+ <font key="font" metaFont="system"/>
59
+ <string key="keyEquivalent" base64-UTF8="YES">
60
+ DQ
61
+ </string>
62
+ </buttonCell>
63
+ <connections>
64
+ <accessibilityConnection property="link" destination="8" id="cks-Lf-tCO"/>
65
+ <action selector="onAccept:" target="-2" id="522"/>
66
+ </connections>
67
+ </button>
68
+ <button verticalHuggingPriority="750" id="7I5-a2-h65">
69
+ <rect key="frame" x="358" y="13" width="105" height="32"/>
70
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
71
+ <buttonCell key="cell" type="push" title="Temporary" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="i6y-0u-COa">
72
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
73
+ <font key="font" metaFont="system"/>
74
+ </buttonCell>
75
+ <connections>
76
+ <accessibilityConnection property="link" destination="9" id="5nn-SX-Rqq"/>
77
+ <action selector="onTemporary:" target="-2" id="BWk-o1-tug"/>
78
+ </connections>
79
+ </button>
80
+ <textField verticalHuggingPriority="750" id="LgQ-ni-jXv">
81
+ <rect key="frame" x="47" y="236" width="582" height="36"/>
82
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
83
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="ATTENTION: The common name does not match the server name!" id="94f-Om-tJh">
84
+ <font key="font" metaFont="system"/>
85
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
86
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
87
+ </textFieldCell>
88
+ </textField>
89
+ <textField verticalHuggingPriority="750" id="5">
90
+ <rect key="frame" x="47" y="186" width="89" height="17"/>
91
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
92
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Subject" id="22">
93
+ <font key="font" metaFont="system"/>
94
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
95
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
96
+ </textFieldCell>
97
+ </textField>
98
+ <textField verticalHuggingPriority="750" id="vA4-qf-QuW">
99
+ <rect key="frame" x="47" y="161" width="89" height="17"/>
100
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
101
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Issuer" id="tAl-Qh-OR9">
102
+ <font key="font" metaFont="system"/>
103
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
104
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
105
+ </textFieldCell>
106
+ </textField>
107
+ <textField verticalHuggingPriority="750" id="10">
108
+ <rect key="frame" x="47" y="211" width="89" height="17"/>
109
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
110
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Common" id="15">
111
+ <font key="font" metaFont="system"/>
112
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
113
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
114
+ </textFieldCell>
115
+ </textField>
116
+ <textField verticalHuggingPriority="750" id="2HW-of-a4n">
117
+ <rect key="frame" x="140" y="211" width="305" height="17"/>
118
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
119
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="COMMON NAME" id="N48-2i-W6H">
120
+ <font key="font" metaFont="system"/>
121
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
122
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
123
+ </textFieldCell>
124
+ </textField>
125
+ <textField verticalHuggingPriority="750" id="R9r-82-XAH">
126
+ <rect key="frame" x="140" y="186" width="305" height="17"/>
127
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
128
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="SUBJECT" id="iGw-oh-i3p">
129
+ <font key="font" metaFont="system"/>
130
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
131
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
132
+ </textFieldCell>
133
+ </textField>
134
+ <textField verticalHuggingPriority="750" id="kHA-F4-dxw">
135
+ <rect key="frame" x="140" y="161" width="305" height="17"/>
136
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
137
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="ISSUER" id="daP-a0-hI1">
138
+ <font key="font" metaFont="system"/>
139
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
140
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
141
+ </textFieldCell>
142
+ </textField>
143
+ <textField verticalHuggingPriority="750" id="cLB-ZO-jvx">
144
+ <rect key="frame" x="140" y="117" width="483" height="36"/>
145
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
146
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="FINGERPRINT" id="VqU-vO-noG">
147
+ <font key="font" metaFont="system"/>
148
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
149
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
150
+ </textFieldCell>
151
+ </textField>
152
+ <textField verticalHuggingPriority="750" id="VLG-f9-Gcl">
153
+ <rect key="frame" x="47" y="136" width="89" height="17"/>
154
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
155
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Fingerprint" id="49l-Xk-MUH">
156
+ <font key="font" metaFont="system"/>
157
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
158
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
159
+ </textFieldCell>
160
+ </textField>
161
+ </subviews>
162
+ </view>
163
+ <connections>
164
+ <outlet property="delegate" destination="-2" id="4"/>
165
+ </connections>
166
+ <point key="canvasLocation" x="228.5" y="102"/>
167
+ </window>
168
+ </objects>
169
+ </document>
local-test-freerdp-full-01/afc-freerdp/client/Mac/Clipboard.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ *
4
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
5
+ * Copyright 2015 Thincast Technologies GmbH
6
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #import "mfreerdp.h"
22
+ #import "mf_client.h"
23
+
24
+ #import "freerdp/freerdp.h"
25
+ #import "freerdp/channels/channels.h"
26
+ #import "freerdp/client/cliprdr.h"
27
+
28
+ int mac_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr);
29
+
30
+ void mac_cliprdr_init(mfContext* mfc, CliprdrClientContext* cliprdr);
31
+ void mac_cliprdr_uninit(mfContext* mfc, CliprdrClientContext* cliprdr);
local-test-freerdp-full-01/afc-freerdp/client/Mac/Clipboard.m ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ *
4
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
5
+ * Copyright 2015 Thincast Technologies GmbH
6
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #import "Clipboard.h"
22
+ #import "MRDPView.h"
23
+
24
+ int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr)
25
+ {
26
+ UINT32 formatId;
27
+ UINT32 numFormats;
28
+ UINT32 *pFormatIds;
29
+ const char *formatName;
30
+ CLIPRDR_FORMAT *formats;
31
+ CLIPRDR_FORMAT_LIST formatList = { 0 };
32
+
33
+ WINPR_ASSERT(cliprdr);
34
+ mfContext *mfc = (mfContext *)cliprdr->custom;
35
+ WINPR_ASSERT(mfc);
36
+
37
+ pFormatIds = NULL;
38
+ numFormats = ClipboardGetFormatIds(mfc->clipboard, &pFormatIds);
39
+
40
+ formats = (CLIPRDR_FORMAT *)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
41
+
42
+ if (!formats)
43
+ return -1;
44
+
45
+ for (UINT32 index = 0; index < numFormats; index++)
46
+ {
47
+ formatId = pFormatIds[index];
48
+ formatName = ClipboardGetFormatName(mfc->clipboard, formatId);
49
+
50
+ formats[index].formatId = formatId;
51
+ formats[index].formatName = NULL;
52
+
53
+ if ((formatId > CF_MAX) && formatName)
54
+ formats[index].formatName = _strdup(formatName);
55
+ }
56
+
57
+ formatList.common.msgFlags = 0;
58
+ formatList.numFormats = numFormats;
59
+ formatList.formats = formats;
60
+ formatList.common.msgType = CB_FORMAT_LIST;
61
+
62
+ mfc->cliprdr->ClientFormatList(mfc->cliprdr, &formatList);
63
+
64
+ for (UINT32 index = 0; index < numFormats; index++)
65
+ {
66
+ free(formats[index].formatName);
67
+ }
68
+
69
+ free(pFormatIds);
70
+ free(formats);
71
+
72
+ return 1;
73
+ }
74
+
75
+ static int mac_cliprdr_send_client_format_list_response(CliprdrClientContext *cliprdr, BOOL status)
76
+ {
77
+ CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
78
+
79
+ formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
80
+ formatListResponse.common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
81
+ formatListResponse.common.dataLen = 0;
82
+
83
+ cliprdr->ClientFormatListResponse(cliprdr, &formatListResponse);
84
+
85
+ return 1;
86
+ }
87
+
88
+ static int mac_cliprdr_send_client_format_data_request(CliprdrClientContext *cliprdr,
89
+ UINT32 formatId)
90
+ {
91
+ CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest = { 0 };
92
+ WINPR_ASSERT(cliprdr);
93
+
94
+ mfContext *mfc = (mfContext *)cliprdr->custom;
95
+ WINPR_ASSERT(mfc);
96
+
97
+ formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
98
+ formatDataRequest.common.msgFlags = 0;
99
+
100
+ formatDataRequest.requestedFormatId = formatId;
101
+ mfc->requestedFormatId = formatId;
102
+ (void)ResetEvent(mfc->clipboardRequestEvent);
103
+
104
+ cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest);
105
+
106
+ return 1;
107
+ }
108
+
109
+ static int mac_cliprdr_send_client_capabilities(CliprdrClientContext *cliprdr)
110
+ {
111
+ CLIPRDR_CAPABILITIES capabilities;
112
+ CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
113
+
114
+ capabilities.cCapabilitiesSets = 1;
115
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
116
+
117
+ generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
118
+ generalCapabilitySet.capabilitySetLength = 12;
119
+
120
+ generalCapabilitySet.version = CB_CAPS_VERSION_2;
121
+ generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
122
+
123
+ cliprdr->ClientCapabilities(cliprdr, &capabilities);
124
+
125
+ return 1;
126
+ }
127
+
128
+ /**
129
+ * Function description
130
+ *
131
+ * @return 0 on success, otherwise a Win32 error code
132
+ */
133
+ static UINT mac_cliprdr_monitor_ready(CliprdrClientContext *cliprdr,
134
+ const CLIPRDR_MONITOR_READY *monitorReady)
135
+ {
136
+ mfContext *mfc = (mfContext *)cliprdr->custom;
137
+
138
+ mfc->clipboardSync = TRUE;
139
+ mac_cliprdr_send_client_capabilities(cliprdr);
140
+ mac_cliprdr_send_client_format_list(cliprdr);
141
+
142
+ return CHANNEL_RC_OK;
143
+ }
144
+
145
+ /**
146
+ * Function description
147
+ *
148
+ * @return 0 on success, otherwise a Win32 error code
149
+ */
150
+ static UINT mac_cliprdr_server_capabilities(CliprdrClientContext *cliprdr,
151
+ const CLIPRDR_CAPABILITIES *capabilities)
152
+ {
153
+ CLIPRDR_CAPABILITY_SET *capabilitySet;
154
+ mfContext *mfc = (mfContext *)cliprdr->custom;
155
+
156
+ for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++)
157
+ {
158
+ capabilitySet = &(capabilities->capabilitySets[index]);
159
+
160
+ if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) &&
161
+ (capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN))
162
+ {
163
+ CLIPRDR_GENERAL_CAPABILITY_SET *generalCapabilitySet =
164
+ (CLIPRDR_GENERAL_CAPABILITY_SET *)capabilitySet;
165
+
166
+ mfc->clipboardCapabilities = generalCapabilitySet->generalFlags;
167
+ break;
168
+ }
169
+ }
170
+
171
+ return CHANNEL_RC_OK;
172
+ }
173
+
174
+ /**
175
+ * Function description
176
+ *
177
+ * @return 0 on success, otherwise a Win32 error code
178
+ */
179
+ static UINT mac_cliprdr_server_format_list(CliprdrClientContext *cliprdr,
180
+ const CLIPRDR_FORMAT_LIST *formatList)
181
+ {
182
+ CLIPRDR_FORMAT *format;
183
+ mfContext *mfc = (mfContext *)cliprdr->custom;
184
+
185
+ if (mfc->serverFormats)
186
+ {
187
+ for (UINT32 index = 0; index < mfc->numServerFormats; index++)
188
+ {
189
+ free(mfc->serverFormats[index].formatName);
190
+ }
191
+
192
+ free(mfc->serverFormats);
193
+ mfc->serverFormats = NULL;
194
+ mfc->numServerFormats = 0;
195
+ }
196
+
197
+ if (formatList->numFormats < 1)
198
+ return CHANNEL_RC_OK;
199
+
200
+ mfc->numServerFormats = formatList->numFormats;
201
+ mfc->serverFormats = (CLIPRDR_FORMAT *)calloc(mfc->numServerFormats, sizeof(CLIPRDR_FORMAT));
202
+
203
+ if (!mfc->serverFormats)
204
+ return CHANNEL_RC_NO_MEMORY;
205
+
206
+ for (UINT32 index = 0; index < mfc->numServerFormats; index++)
207
+ {
208
+ mfc->serverFormats[index].formatId = formatList->formats[index].formatId;
209
+ mfc->serverFormats[index].formatName = NULL;
210
+
211
+ if (formatList->formats[index].formatName)
212
+ mfc->serverFormats[index].formatName = _strdup(formatList->formats[index].formatName);
213
+ }
214
+
215
+ mac_cliprdr_send_client_format_list_response(cliprdr, TRUE);
216
+
217
+ for (UINT32 index = 0; index < mfc->numServerFormats; index++)
218
+ {
219
+ format = &(mfc->serverFormats[index]);
220
+
221
+ if (format->formatId == CF_UNICODETEXT)
222
+ {
223
+ mac_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT);
224
+ break;
225
+ }
226
+ else if (format->formatId == CF_OEMTEXT)
227
+ {
228
+ mac_cliprdr_send_client_format_data_request(cliprdr, CF_OEMTEXT);
229
+ break;
230
+ }
231
+ else if (format->formatId == CF_TEXT)
232
+ {
233
+ mac_cliprdr_send_client_format_data_request(cliprdr, CF_TEXT);
234
+ break;
235
+ }
236
+ }
237
+
238
+ return CHANNEL_RC_OK;
239
+ }
240
+
241
+ /**
242
+ * Function description
243
+ *
244
+ * @return 0 on success, otherwise a Win32 error code
245
+ */
246
+ static UINT
247
+ mac_cliprdr_server_format_list_response(CliprdrClientContext *cliprdr,
248
+ const CLIPRDR_FORMAT_LIST_RESPONSE *formatListResponse)
249
+ {
250
+ return CHANNEL_RC_OK;
251
+ }
252
+
253
+ /**
254
+ * Function description
255
+ *
256
+ * @return 0 on success, otherwise a Win32 error code
257
+ */
258
+ static UINT
259
+ mac_cliprdr_server_lock_clipboard_data(CliprdrClientContext *cliprdr,
260
+ const CLIPRDR_LOCK_CLIPBOARD_DATA *lockClipboardData)
261
+ {
262
+ return CHANNEL_RC_OK;
263
+ }
264
+
265
+ /**
266
+ * Function description
267
+ *
268
+ * @return 0 on success, otherwise a Win32 error code
269
+ */
270
+ static UINT
271
+ mac_cliprdr_server_unlock_clipboard_data(CliprdrClientContext *cliprdr,
272
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA *unlockClipboardData)
273
+ {
274
+ return CHANNEL_RC_OK;
275
+ }
276
+
277
+ /**
278
+ * Function description
279
+ *
280
+ * @return 0 on success, otherwise a Win32 error code
281
+ */
282
+ static UINT
283
+ mac_cliprdr_server_format_data_request(CliprdrClientContext *cliprdr,
284
+ const CLIPRDR_FORMAT_DATA_REQUEST *formatDataRequest)
285
+ {
286
+ BYTE *data;
287
+ UINT32 size;
288
+ UINT32 formatId;
289
+ CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
290
+
291
+ WINPR_ASSERT(cliprdr);
292
+
293
+ mfContext *mfc = (mfContext *)cliprdr->custom;
294
+ WINPR_ASSERT(mfc);
295
+
296
+ formatId = formatDataRequest->requestedFormatId;
297
+ data = (BYTE *)ClipboardGetData(mfc->clipboard, formatId, &size);
298
+
299
+ response.common.msgFlags = CB_RESPONSE_OK;
300
+ response.common.dataLen = size;
301
+ response.requestedFormatData = data;
302
+
303
+ if (!data)
304
+ {
305
+ response.common.msgFlags = CB_RESPONSE_FAIL;
306
+ response.common.dataLen = 0;
307
+ response.requestedFormatData = NULL;
308
+ }
309
+
310
+ cliprdr->ClientFormatDataResponse(cliprdr, &response);
311
+
312
+ free(data);
313
+
314
+ return CHANNEL_RC_OK;
315
+ }
316
+
317
+ /**
318
+ * Function description
319
+ *
320
+ * @return 0 on success, otherwise a Win32 error code
321
+ */
322
+ static UINT
323
+ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr,
324
+ const CLIPRDR_FORMAT_DATA_RESPONSE *formatDataResponse)
325
+ {
326
+ UINT32 formatId;
327
+ CLIPRDR_FORMAT *format = NULL;
328
+ mfContext *mfc = (mfContext *)cliprdr->custom;
329
+ MRDPView *view = (MRDPView *)mfc->view;
330
+
331
+ if (formatDataResponse->common.msgFlags & CB_RESPONSE_FAIL)
332
+ {
333
+ (void)SetEvent(mfc->clipboardRequestEvent);
334
+ return ERROR_INTERNAL_ERROR;
335
+ }
336
+
337
+ for (UINT32 index = 0; index < mfc->numServerFormats; index++)
338
+ {
339
+ if (mfc->requestedFormatId == mfc->serverFormats[index].formatId)
340
+ format = &(mfc->serverFormats[index]);
341
+ }
342
+
343
+ if (!format)
344
+ {
345
+ (void)SetEvent(mfc->clipboardRequestEvent);
346
+ return ERROR_INTERNAL_ERROR;
347
+ }
348
+
349
+ if (format->formatName)
350
+ formatId = ClipboardRegisterFormat(mfc->clipboard, format->formatName);
351
+ else
352
+ formatId = format->formatId;
353
+
354
+ const size_t size = formatDataResponse->common.dataLen;
355
+
356
+ ClipboardSetData(mfc->clipboard, formatId, formatDataResponse->requestedFormatData, size);
357
+
358
+ (void)SetEvent(mfc->clipboardRequestEvent);
359
+
360
+ if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) || (formatId == CF_UNICODETEXT))
361
+ {
362
+ formatId = ClipboardRegisterFormat(mfc->clipboard, "text/plain");
363
+
364
+ UINT32 dstSize = 0;
365
+ char *data = ClipboardGetData(mfc->clipboard, formatId, &dstSize);
366
+
367
+ dstSize = strnlen(data, dstSize); /* we need the size without the null terminator */
368
+
369
+ NSString *str = [[NSString alloc] initWithBytes:(void *)data
370
+ length:dstSize
371
+ encoding:NSUTF8StringEncoding];
372
+ free(data);
373
+
374
+ NSArray *types = [[NSArray alloc] initWithObjects:NSPasteboardTypeString, nil];
375
+ [view->pasteboard_wr declareTypes:types owner:view];
376
+ [view->pasteboard_wr setString:str forType:NSPasteboardTypeString];
377
+ }
378
+
379
+ return CHANNEL_RC_OK;
380
+ }
381
+
382
+ /**
383
+ * Function description
384
+ *
385
+ * @return 0 on success, otherwise a Win32 error code
386
+ */
387
+ static UINT
388
+ mac_cliprdr_server_file_contents_request(CliprdrClientContext *cliprdr,
389
+ const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
390
+ {
391
+ return CHANNEL_RC_OK;
392
+ }
393
+
394
+ /**
395
+ * Function description
396
+ *
397
+ * @return 0 on success, otherwise a Win32 error code
398
+ */
399
+ static UINT mac_cliprdr_server_file_contents_response(
400
+ CliprdrClientContext *cliprdr, const CLIPRDR_FILE_CONTENTS_RESPONSE *fileContentsResponse)
401
+ {
402
+ return CHANNEL_RC_OK;
403
+ }
404
+
405
+ void mac_cliprdr_init(mfContext *mfc, CliprdrClientContext *cliprdr)
406
+ {
407
+ cliprdr->custom = (void *)mfc;
408
+ mfc->cliprdr = cliprdr;
409
+
410
+ mfc->clipboard = ClipboardCreate();
411
+ mfc->clipboardRequestEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
412
+
413
+ cliprdr->MonitorReady = mac_cliprdr_monitor_ready;
414
+ cliprdr->ServerCapabilities = mac_cliprdr_server_capabilities;
415
+ cliprdr->ServerFormatList = mac_cliprdr_server_format_list;
416
+ cliprdr->ServerFormatListResponse = mac_cliprdr_server_format_list_response;
417
+ cliprdr->ServerLockClipboardData = mac_cliprdr_server_lock_clipboard_data;
418
+ cliprdr->ServerUnlockClipboardData = mac_cliprdr_server_unlock_clipboard_data;
419
+ cliprdr->ServerFormatDataRequest = mac_cliprdr_server_format_data_request;
420
+ cliprdr->ServerFormatDataResponse = mac_cliprdr_server_format_data_response;
421
+ cliprdr->ServerFileContentsRequest = mac_cliprdr_server_file_contents_request;
422
+ cliprdr->ServerFileContentsResponse = mac_cliprdr_server_file_contents_response;
423
+ }
424
+
425
+ void mac_cliprdr_uninit(mfContext *mfc, CliprdrClientContext *cliprdr)
426
+ {
427
+ cliprdr->custom = NULL;
428
+ mfc->cliprdr = NULL;
429
+
430
+ ClipboardDestroy(mfc->clipboard);
431
+ (void)CloseHandle(mfc->clipboardRequestEvent);
432
+ }
local-test-freerdp-full-01/afc-freerdp/client/Mac/Credits.rtf ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf320
2
+ {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3
+ {\colortbl;\red255\green255\blue255;}
4
+ \vieww9600\viewh8400\viewkind0
5
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
6
+
7
+ \f0\b\fs24 \cf0 Engineering:
8
+ \b0 \
9
+ Jay sorg\
10
+ Marc-Andre Moreau\
11
+ Vic Lee\
12
+ Otvaio Salvador \
13
+ Laxmikant Rashinkar\
14
+ and others\
15
+ \
16
+
17
+ \b Human Interface Design:
18
+ \b0 \
19
+ Laxmikant Rashinkar\
20
+ Jay Sorg\
21
+ }
local-test-freerdp-full-01/afc-freerdp/client/Mac/Info.plist ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSCameraUsageDescription</key>
6
+ <string>This application requires camera access to redirect it to the remote host</string>
7
+ <key>NSMicrophoneUsageDescription</key>
8
+ <string>This application requires microphone access to redirect it to the remote host</string>
9
+ <key>CFBundleDevelopmentRegion</key>
10
+ <string>English</string>
11
+ <key>CFBundleIconFile</key>
12
+ <string></string>
13
+ <key>CFBundleIdentifier</key>
14
+ <string>FreeRDP.Mac</string>
15
+ <key>CFBundleInfoDictionaryVersion</key>
16
+ <string>6.0</string>
17
+ <key>CFBundleName</key>
18
+ <string></string>
19
+ <key>CFBundlePackageType</key>
20
+ <string>FMWK</string>
21
+ <key>CFBundleShortVersionString</key>
22
+ <string>1.0</string>
23
+ <key>CFBundleSignature</key>
24
+ <string>????</string>
25
+ <key>CFBundleVersion</key>
26
+ <string>1</string>
27
+ <key>NSPrincipalClass</key>
28
+ <string></string>
29
+ </dict>
30
+ </plist>
local-test-freerdp-full-01/afc-freerdp/client/Mac/Keyboard.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ enum APPLE_KEYBOARD_TYPE
21
+ {
22
+ APPLE_KEYBOARD_TYPE_ANSI,
23
+ APPLE_KEYBOARD_TYPE_ISO,
24
+ APPLE_KEYBOARD_TYPE_JIS
25
+ };
26
+
27
+ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type(void);
local-test-freerdp-full-01/afc-freerdp/client/Mac/Keyboard.m ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import "Keyboard.h"
21
+
22
+ #include <CoreFoundation/CoreFoundation.h>
23
+
24
+ #include <IOKit/IOKitLib.h>
25
+ #include <IOKit/hid/IOHIDManager.h>
26
+
27
+ typedef struct
28
+ {
29
+ uint32_t ProductId;
30
+ enum APPLE_KEYBOARD_TYPE Type;
31
+ } APPLE_KEYBOARD_DESC;
32
+
33
+ /* VendorID: 0x05AC (Apple, Inc.) */
34
+
35
+ static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] = {
36
+ { 0x200, APPLE_KEYBOARD_TYPE_ANSI },
37
+ { 0x201, APPLE_KEYBOARD_TYPE_ANSI }, /* USB Keyboard [Alps or Logitech, M2452] */
38
+ { 0x202, APPLE_KEYBOARD_TYPE_ANSI }, /* Keyboard [ALPS] */
39
+ { 0x203, APPLE_KEYBOARD_TYPE_ANSI },
40
+ { 0x204, APPLE_KEYBOARD_TYPE_ANSI },
41
+ { 0x205, APPLE_KEYBOARD_TYPE_ANSI }, /* Extended Keyboard [Mitsumi] */
42
+ { 0x206, APPLE_KEYBOARD_TYPE_ANSI }, /* Extended Keyboard [Mitsumi] */
43
+ { 0x207, APPLE_KEYBOARD_TYPE_ANSI },
44
+ { 0x208, APPLE_KEYBOARD_TYPE_ANSI },
45
+ { 0x209, APPLE_KEYBOARD_TYPE_ANSI },
46
+ { 0x20A, APPLE_KEYBOARD_TYPE_ANSI },
47
+ { 0x20B, APPLE_KEYBOARD_TYPE_ANSI }, /* Pro Keyboard [Mitsumi, A1048/US layout] */
48
+ { 0x20C, APPLE_KEYBOARD_TYPE_ANSI }, /* Extended Keyboard [Mitsumi] */
49
+ { 0x20D, APPLE_KEYBOARD_TYPE_ANSI }, /* Pro Keyboard [Mitsumi, A1048/JIS layout] */
50
+ { 0x20E, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
51
+ { 0x20F, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
52
+ { 0x210, APPLE_KEYBOARD_TYPE_ANSI },
53
+ { 0x211, APPLE_KEYBOARD_TYPE_ANSI },
54
+ { 0x212, APPLE_KEYBOARD_TYPE_ANSI },
55
+ { 0x213, APPLE_KEYBOARD_TYPE_ANSI },
56
+ { 0x214, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
57
+ { 0x215, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
58
+ { 0x216, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
59
+ { 0x217, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
60
+ { 0x218, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
61
+ { 0x219, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
62
+ { 0x21A, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
63
+ { 0x21B, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
64
+ { 0x21C, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
65
+ { 0x21D, APPLE_KEYBOARD_TYPE_ANSI }, /* Aluminum Mini Keyboard (ANSI) */
66
+ { 0x21E, APPLE_KEYBOARD_TYPE_ISO }, /* Aluminum Mini Keyboard (ISO) */
67
+ { 0x21F, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Mini Keyboard (JIS) */
68
+ { 0x220, APPLE_KEYBOARD_TYPE_ANSI }, /* Aluminum Keyboard (ANSI) */
69
+ { 0x221, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
70
+ { 0x222, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
71
+ { 0x223, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
72
+ { 0x224, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
73
+ { 0x225, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
74
+ { 0x226, APPLE_KEYBOARD_TYPE_ANSI },
75
+ { 0x227, APPLE_KEYBOARD_TYPE_ANSI },
76
+ { 0x228, APPLE_KEYBOARD_TYPE_ANSI },
77
+ { 0x229, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (MacBook Pro) (ANSI) */
78
+ { 0x22A, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro) (ISO) */
79
+ { 0x22B, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro) (JIS) */
80
+ { 0x22C, APPLE_KEYBOARD_TYPE_ANSI },
81
+ { 0x22D, APPLE_KEYBOARD_TYPE_ANSI },
82
+ { 0x22E, APPLE_KEYBOARD_TYPE_ANSI },
83
+ { 0x22F, APPLE_KEYBOARD_TYPE_ANSI },
84
+ { 0x230, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (ANSI) */
85
+ { 0x231, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (ISO) */
86
+ { 0x232, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (JIS) */
87
+ { 0x233, APPLE_KEYBOARD_TYPE_ANSI },
88
+ { 0x234, APPLE_KEYBOARD_TYPE_ANSI },
89
+ { 0x235, APPLE_KEYBOARD_TYPE_ANSI },
90
+ { 0x236, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
91
+ { 0x237, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
92
+ { 0x238, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
93
+ { 0x239, APPLE_KEYBOARD_TYPE_ANSI },
94
+ { 0x23A, APPLE_KEYBOARD_TYPE_ANSI },
95
+ { 0x23B, APPLE_KEYBOARD_TYPE_ANSI },
96
+ { 0x23C, APPLE_KEYBOARD_TYPE_ANSI },
97
+ { 0x23D, APPLE_KEYBOARD_TYPE_ANSI },
98
+ { 0x23E, APPLE_KEYBOARD_TYPE_ANSI },
99
+ { 0x23F, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
100
+ { 0x240, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
101
+ { 0x241, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
102
+ { 0x242, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
103
+ { 0x243, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
104
+ { 0x244, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
105
+ { 0x245, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
106
+ { 0x246, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
107
+ { 0x247, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
108
+ { 0x248, APPLE_KEYBOARD_TYPE_ANSI },
109
+ { 0x249, APPLE_KEYBOARD_TYPE_ANSI },
110
+ { 0x24A, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Air) (ISO) */
111
+ { 0x24B, APPLE_KEYBOARD_TYPE_ANSI },
112
+ { 0x24C, APPLE_KEYBOARD_TYPE_ANSI },
113
+ { 0x24D, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Air) (ISO) */
114
+ { 0x24E, APPLE_KEYBOARD_TYPE_ANSI },
115
+ { 0x24F, APPLE_KEYBOARD_TYPE_ANSI },
116
+ { 0x250, APPLE_KEYBOARD_TYPE_ISO }, /* Aluminium Keyboard (ISO) */
117
+ { 0x251, APPLE_KEYBOARD_TYPE_ANSI },
118
+ { 0x252, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
119
+ { 0x253, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
120
+ { 0x254, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
121
+ { 0x255, APPLE_KEYBOARD_TYPE_ANSI },
122
+ { 0x256, APPLE_KEYBOARD_TYPE_ANSI },
123
+ { 0x257, APPLE_KEYBOARD_TYPE_ANSI },
124
+ { 0x258, APPLE_KEYBOARD_TYPE_ANSI },
125
+ { 0x259, APPLE_KEYBOARD_TYPE_ANSI },
126
+ { 0x25A, APPLE_KEYBOARD_TYPE_ANSI },
127
+ { 0x25B, APPLE_KEYBOARD_TYPE_ANSI },
128
+ { 0x25C, APPLE_KEYBOARD_TYPE_ANSI },
129
+ { 0x25D, APPLE_KEYBOARD_TYPE_ANSI },
130
+ { 0x25E, APPLE_KEYBOARD_TYPE_ANSI },
131
+ { 0x25F, APPLE_KEYBOARD_TYPE_ANSI },
132
+ { 0x260, APPLE_KEYBOARD_TYPE_ANSI },
133
+ { 0x261, APPLE_KEYBOARD_TYPE_ANSI },
134
+ { 0x262, APPLE_KEYBOARD_TYPE_ANSI },
135
+ { 0x263, APPLE_KEYBOARD_TYPE_ANSI }, /* Apple Internal Keyboard / Trackpad (MacBook Retina) */
136
+ { 0x264, APPLE_KEYBOARD_TYPE_ANSI },
137
+ { 0x265, APPLE_KEYBOARD_TYPE_ANSI },
138
+ { 0x266, APPLE_KEYBOARD_TYPE_ANSI },
139
+ { 0x267, APPLE_KEYBOARD_TYPE_ANSI },
140
+ { 0x268, APPLE_KEYBOARD_TYPE_ANSI },
141
+ { 0x269, APPLE_KEYBOARD_TYPE_ANSI },
142
+ { 0x26A, APPLE_KEYBOARD_TYPE_ANSI }
143
+ };
144
+
145
+ static enum APPLE_KEYBOARD_TYPE mac_identify_keyboard_type(uint32_t vendorID, uint32_t productID)
146
+ {
147
+ enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
148
+
149
+ if (vendorID != 0x05AC) /* Apple, Inc. */
150
+ return type;
151
+
152
+ if ((productID < 0x200) || (productID > 0x26A))
153
+ return type;
154
+
155
+ type = APPLE_KEYBOARDS[productID - 0x200].Type;
156
+ return type;
157
+ }
158
+
159
+ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type(void)
160
+ {
161
+ CFSetRef deviceCFSetRef = NULL;
162
+ IOHIDDeviceRef inIOHIDDeviceRef = NULL;
163
+ IOHIDManagerRef tIOHIDManagerRef = NULL;
164
+ IOHIDDeviceRef *tIOHIDDeviceRefs = nil;
165
+ enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
166
+ tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
167
+
168
+ if (!tIOHIDManagerRef)
169
+ return type;
170
+
171
+ IOHIDManagerSetDeviceMatching(tIOHIDManagerRef, NULL);
172
+ IOReturn tIOReturn = IOHIDManagerOpen(tIOHIDManagerRef, kIOHIDOptionsTypeNone);
173
+
174
+ if (noErr != tIOReturn)
175
+ return type;
176
+
177
+ deviceCFSetRef = IOHIDManagerCopyDevices(tIOHIDManagerRef);
178
+
179
+ if (!deviceCFSetRef)
180
+ return type;
181
+
182
+ CFIndex deviceIndex, deviceCount = CFSetGetCount(deviceCFSetRef);
183
+ tIOHIDDeviceRefs = malloc(sizeof(IOHIDDeviceRef) * deviceCount);
184
+
185
+ if (!tIOHIDDeviceRefs)
186
+ return type;
187
+
188
+ CFSetGetValues(deviceCFSetRef, (const void **)tIOHIDDeviceRefs);
189
+ CFRelease(deviceCFSetRef);
190
+ deviceCFSetRef = NULL;
191
+
192
+ for (deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
193
+ {
194
+ CFTypeRef tCFTypeRef;
195
+ uint32_t vendorID = 0;
196
+ uint32_t productID = 0;
197
+ uint32_t countryCode = 0;
198
+ enum APPLE_KEYBOARD_TYPE ltype;
199
+
200
+ if (!tIOHIDDeviceRefs[deviceIndex])
201
+ continue;
202
+
203
+ inIOHIDDeviceRef = tIOHIDDeviceRefs[deviceIndex];
204
+ tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDVendorIDKey));
205
+
206
+ if (tCFTypeRef)
207
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &vendorID);
208
+
209
+ tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductIDKey));
210
+
211
+ if (tCFTypeRef)
212
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &productID);
213
+
214
+ tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDCountryCodeKey));
215
+
216
+ if (tCFTypeRef)
217
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &countryCode);
218
+
219
+ ltype = mac_identify_keyboard_type(vendorID, productID);
220
+
221
+ if (ltype != APPLE_KEYBOARD_TYPE_ANSI)
222
+ {
223
+ type = ltype;
224
+ break;
225
+ }
226
+ }
227
+
228
+ free(tIOHIDDeviceRefs);
229
+
230
+ if (deviceCFSetRef)
231
+ {
232
+ CFRelease(deviceCFSetRef);
233
+ deviceCFSetRef = NULL;
234
+ }
235
+
236
+ if (tIOHIDManagerRef)
237
+ CFRelease(tIOHIDManagerRef);
238
+
239
+ return type;
240
+ }
local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPCursor.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2012 Thomas Goddard
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import <Cocoa/Cocoa.h>
21
+
22
+ #include "freerdp/graphics.h"
23
+
24
+ @interface MRDPCursor : NSObject
25
+ {
26
+ @public
27
+ rdpPointer *pointer;
28
+ BYTE *cursor_data;
29
+ NSBitmapImageRep *bmiRep;
30
+ NSCursor *nsCursor;
31
+ NSImage *nsImage;
32
+ }
33
+
34
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPCursor.m ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2012 Thomas Goddard
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import "MRDPCursor.h"
21
+
22
+ @implementation MRDPCursor
23
+
24
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPView.h ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREERDP_CLIENT_MAC_MRDPVIEW_H
2
+ #define FREERDP_CLIENT_MAC_MRDPVIEW_H
3
+
4
+ /**
5
+ * FreeRDP: A Remote Desktop Protocol Implementation
6
+ * MacFreeRDP
7
+ *
8
+ * Copyright 2012 Thomas Goddard
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+
23
+ #import <Cocoa/Cocoa.h>
24
+
25
+ #import "mfreerdp.h"
26
+ #import "mf_client.h"
27
+ #import "Keyboard.h"
28
+
29
+ #import <CoreGraphics/CoreGraphics.h>
30
+
31
+ @interface MRDPView : NSView
32
+ {
33
+ mfContext *mfc;
34
+ NSBitmapImageRep *bmiRep;
35
+ NSMutableArray *cursors;
36
+ NSMutableArray *windows;
37
+ NSTimer *pasteboard_timer;
38
+ NSCursor *currentCursor;
39
+ NSRect prevWinPosition;
40
+ freerdp *instance;
41
+ rdpContext *context;
42
+ CGContextRef bitmap_context;
43
+ char *pixel_data;
44
+ int argc;
45
+ char **argv;
46
+ DWORD kbdModFlags;
47
+ BOOL initialized;
48
+ NSPoint savedDragLocation;
49
+ BOOL firstCreateWindow;
50
+ BOOL isMoveSizeInProgress;
51
+ BOOL skipResizeOnce;
52
+ BOOL saveInitialDragLoc;
53
+ BOOL skipMoveWindowOnce;
54
+ @public
55
+ NSPasteboard *pasteboard_rd;
56
+ NSPasteboard *pasteboard_wr;
57
+ int pasteboard_changecount;
58
+ int pasteboard_format;
59
+ int is_connected;
60
+ }
61
+
62
+ - (int)rdpStart:(rdpContext *)rdp_context;
63
+ - (void)setCursor:(NSCursor *)cursor;
64
+ - (void)setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height;
65
+
66
+ - (void)onPasteboardTimerFired:(NSTimer *)timer;
67
+ - (void)pause;
68
+ - (void)resume;
69
+ - (void)releaseResources;
70
+
71
+ @property(assign) int is_connected;
72
+
73
+ @end
74
+
75
+ BOOL mac_pre_connect(freerdp *instance);
76
+ BOOL mac_post_connect(freerdp *instance);
77
+ void mac_post_disconnect(freerdp *instance);
78
+ BOOL mac_authenticate_ex(freerdp *instance, char **username, char **password, char **domain,
79
+ rdp_auth_reason reason);
80
+
81
+ DWORD mac_verify_certificate_ex(freerdp *instance, const char *host, UINT16 port,
82
+ const char *common_name, const char *subject, const char *issuer,
83
+ const char *fingerprint, DWORD flags);
84
+ DWORD mac_verify_changed_certificate_ex(freerdp *instance, const char *host, UINT16 port,
85
+ const char *common_name, const char *subject,
86
+ const char *issuer, const char *fingerprint,
87
+ const char *old_subject, const char *old_issuer,
88
+ const char *old_fingerprint, DWORD flags);
89
+
90
+ int mac_logon_error_info(freerdp *instance, UINT32 data, UINT32 type);
91
+ #endif /* FREERDP_CLIENT_MAC_MRDPVIEW_H */
local-test-freerdp-full-01/afc-freerdp/client/Mac/MRDPView.m ADDED
@@ -0,0 +1,1534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2012 Thomas Goddard
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #include <winpr/windows.h>
21
+
22
+ #include "mf_client.h"
23
+ #import "mfreerdp.h"
24
+ #import "MRDPView.h"
25
+ #import "MRDPCursor.h"
26
+ #import "Clipboard.h"
27
+ #import "PasswordDialog.h"
28
+ #import "CertificateDialog.h"
29
+
30
+ #include <winpr/crt.h>
31
+ #include <winpr/assert.h>
32
+ #include <winpr/input.h>
33
+ #include <winpr/synch.h>
34
+ #include <winpr/sysinfo.h>
35
+
36
+ #include <freerdp/constants.h>
37
+
38
+ #import "freerdp/freerdp.h"
39
+ #import "freerdp/types.h"
40
+ #import "freerdp/config.h"
41
+ #import "freerdp/channels/channels.h"
42
+ #import "freerdp/gdi/gdi.h"
43
+ #import "freerdp/gdi/dc.h"
44
+ #import "freerdp/gdi/region.h"
45
+ #import "freerdp/graphics.h"
46
+ #import "freerdp/client/file.h"
47
+ #import "freerdp/client/cmdline.h"
48
+ #import "freerdp/log.h"
49
+
50
+ #import <CoreGraphics/CoreGraphics.h>
51
+
52
+ #define TAG CLIENT_TAG("mac")
53
+
54
+ static BOOL mf_Pointer_New(rdpContext *context, rdpPointer *pointer);
55
+ static void mf_Pointer_Free(rdpContext *context, rdpPointer *pointer);
56
+ static BOOL mf_Pointer_Set(rdpContext *context, rdpPointer *pointer);
57
+ static BOOL mf_Pointer_SetNull(rdpContext *context);
58
+ static BOOL mf_Pointer_SetDefault(rdpContext *context);
59
+ static BOOL mf_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y);
60
+
61
+ static BOOL mac_begin_paint(rdpContext *context);
62
+ static BOOL mac_end_paint(rdpContext *context);
63
+ static BOOL mac_desktop_resize(rdpContext *context);
64
+
65
+ static void input_activity_cb(freerdp *instance);
66
+
67
+ static DWORD WINAPI mac_client_thread(void *param);
68
+ static void windows_to_apple_cords(MRDPView *view, NSRect *r);
69
+ static CGContextRef mac_create_bitmap_context(rdpContext *context);
70
+
71
+ @implementation MRDPView
72
+
73
+ @synthesize is_connected;
74
+
75
+ - (int)rdpStart:(rdpContext *)rdp_context
76
+ {
77
+ rdpSettings *settings;
78
+ EmbedWindowEventArgs e;
79
+ [self initializeView];
80
+
81
+ WINPR_ASSERT(rdp_context);
82
+ context = rdp_context;
83
+ mfc = (mfContext *)rdp_context;
84
+
85
+ instance = context->instance;
86
+ WINPR_ASSERT(instance);
87
+
88
+ settings = context->settings;
89
+ WINPR_ASSERT(settings);
90
+
91
+ EventArgsInit(&e, "mfreerdp");
92
+ e.embed = TRUE;
93
+ e.handle = (void *)self;
94
+ PubSub_OnEmbedWindow(context->pubSub, context, &e);
95
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
96
+ NSRect screenFrame = [screen frame];
97
+
98
+ if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
99
+ {
100
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, screenFrame.size.width))
101
+ return -1;
102
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, screenFrame.size.height))
103
+ return -1;
104
+ [self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
105
+ }
106
+ else
107
+ {
108
+ [self exitFullScreenModeWithOptions:nil];
109
+ }
110
+
111
+ mfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
112
+ mfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
113
+
114
+ if (!(mfc->common.thread =
115
+ CreateThread(NULL, 0, mac_client_thread, (void *)context, 0, &mfc->mainThreadId)))
116
+ {
117
+ WLog_ERR(TAG, "failed to create client thread");
118
+ return -1;
119
+ }
120
+
121
+ return 0;
122
+ }
123
+
124
+ DWORD WINAPI mac_client_thread(void *param)
125
+ {
126
+ @autoreleasepool
127
+ {
128
+ int status;
129
+ DWORD rc;
130
+ HANDLE events[16] = { 0 };
131
+ HANDLE inputEvent;
132
+ DWORD nCount;
133
+ DWORD nCountTmp;
134
+ DWORD nCountBase;
135
+ rdpContext *context = (rdpContext *)param;
136
+ mfContext *mfc = (mfContext *)context;
137
+ freerdp *instance = context->instance;
138
+ MRDPView *view = mfc->view;
139
+ rdpSettings *settings = context->settings;
140
+ status = freerdp_connect(context->instance);
141
+
142
+ if (!status)
143
+ {
144
+ [view setIs_connected:0];
145
+ return 0;
146
+ }
147
+
148
+ [view setIs_connected:1];
149
+ nCount = 0;
150
+ events[nCount++] = mfc->stopEvent;
151
+
152
+ if (!(inputEvent =
153
+ freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE)))
154
+ {
155
+ WLog_ERR(TAG, "failed to get input event handle");
156
+ goto disconnect;
157
+ }
158
+
159
+ events[nCount++] = inputEvent;
160
+
161
+ nCountBase = nCount;
162
+
163
+ while (!freerdp_shall_disconnect_context(instance->context))
164
+ {
165
+ nCount = nCountBase;
166
+ {
167
+ if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount], 16 - nCount)))
168
+ {
169
+ WLog_ERR(TAG, "freerdp_get_event_handles failed");
170
+ break;
171
+ }
172
+
173
+ nCount += nCountTmp;
174
+ }
175
+ rc = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
176
+
177
+ if (rc >= (WAIT_OBJECT_0 + nCount))
178
+ {
179
+ WLog_ERR(TAG, "WaitForMultipleObjects failed (0x%08X)", rc);
180
+ break;
181
+ }
182
+
183
+ if (rc == WAIT_OBJECT_0)
184
+ {
185
+ /* stop event triggered */
186
+ break;
187
+ }
188
+
189
+ if (WaitForSingleObject(inputEvent, 0) == WAIT_OBJECT_0)
190
+ {
191
+ input_activity_cb(instance);
192
+ }
193
+
194
+ {
195
+ if (!freerdp_check_event_handles(context))
196
+ {
197
+ WLog_ERR(TAG, "freerdp_check_event_handles failed");
198
+ break;
199
+ }
200
+ }
201
+ }
202
+
203
+ disconnect:
204
+ [view setIs_connected:0];
205
+ freerdp_disconnect(instance);
206
+
207
+ ExitThread(0);
208
+ return 0;
209
+ }
210
+ }
211
+
212
+ - (id)initWithFrame:(NSRect)frame
213
+ {
214
+ self = [super initWithFrame:frame];
215
+
216
+ if (self)
217
+ {
218
+ // Initialization code here.
219
+ }
220
+
221
+ return self;
222
+ }
223
+
224
+ - (void)viewDidLoad
225
+ {
226
+ [self initializeView];
227
+ }
228
+
229
+ - (void)initializeView
230
+ {
231
+ if (!initialized)
232
+ {
233
+ cursors = [[NSMutableArray alloc] initWithCapacity:10];
234
+ // setup a mouse tracking area
235
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
236
+ initWithRect:[self visibleRect]
237
+ options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
238
+ NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
239
+ NSTrackingActiveWhenFirstResponder
240
+ owner:self
241
+ userInfo:nil];
242
+ [self addTrackingArea:trackingArea];
243
+ // Set the default cursor
244
+ currentCursor = [NSCursor arrowCursor];
245
+ initialized = YES;
246
+ }
247
+ }
248
+
249
+ - (void)setCursor:(NSCursor *)cursor
250
+ {
251
+ self->currentCursor = cursor;
252
+ dispatch_async(dispatch_get_main_queue(), ^{
253
+ [[self window] invalidateCursorRectsForView:self];
254
+ });
255
+ }
256
+
257
+ - (void)resetCursorRects
258
+ {
259
+ [self addCursorRect:[self visibleRect] cursor:currentCursor];
260
+ }
261
+
262
+ - (BOOL)acceptsFirstResponder
263
+ {
264
+ return YES;
265
+ }
266
+
267
+ - (void)mouseMoved:(NSEvent *)event
268
+ {
269
+ [super mouseMoved:event];
270
+
271
+ if (!self.is_connected)
272
+ return;
273
+
274
+ NSPoint loc = [event locationInWindow];
275
+ int x = (int)loc.x;
276
+ int y = (int)loc.y;
277
+ mf_scale_mouse_event(context, PTR_FLAGS_MOVE, x, y);
278
+ }
279
+
280
+ - (void)mouseDown:(NSEvent *)event
281
+ {
282
+ [super mouseDown:event];
283
+
284
+ if (!self.is_connected)
285
+ return;
286
+
287
+ NSPoint loc = [event locationInWindow];
288
+ int x = (int)loc.x;
289
+ int y = (int)loc.y;
290
+ mf_press_mouse_button(context, 0, x, y, TRUE);
291
+ }
292
+
293
+ - (void)mouseUp:(NSEvent *)event
294
+ {
295
+ [super mouseUp:event];
296
+
297
+ if (!self.is_connected)
298
+ return;
299
+
300
+ NSPoint loc = [event locationInWindow];
301
+ int x = (int)loc.x;
302
+ int y = (int)loc.y;
303
+ mf_press_mouse_button(context, 0, x, y, FALSE);
304
+ }
305
+
306
+ - (void)rightMouseDown:(NSEvent *)event
307
+ {
308
+ [super rightMouseDown:event];
309
+
310
+ if (!self.is_connected)
311
+ return;
312
+
313
+ NSPoint loc = [event locationInWindow];
314
+ int x = (int)loc.x;
315
+ int y = (int)loc.y;
316
+ mf_press_mouse_button(context, 1, x, y, TRUE);
317
+ }
318
+
319
+ - (void)rightMouseUp:(NSEvent *)event
320
+ {
321
+ [super rightMouseUp:event];
322
+
323
+ if (!self.is_connected)
324
+ return;
325
+
326
+ NSPoint loc = [event locationInWindow];
327
+ int x = (int)loc.x;
328
+ int y = (int)loc.y;
329
+ mf_press_mouse_button(context, 1, x, y, FALSE);
330
+ }
331
+
332
+ - (void)otherMouseDown:(NSEvent *)event
333
+ {
334
+ [super otherMouseDown:event];
335
+
336
+ if (!self.is_connected)
337
+ return;
338
+
339
+ NSPoint loc = [event locationInWindow];
340
+ int x = (int)loc.x;
341
+ int y = (int)loc.y;
342
+ int pressed = [event buttonNumber];
343
+ mf_press_mouse_button(context, pressed, x, y, TRUE);
344
+ }
345
+
346
+ - (void)otherMouseUp:(NSEvent *)event
347
+ {
348
+ [super otherMouseUp:event];
349
+
350
+ if (!self.is_connected)
351
+ return;
352
+
353
+ NSPoint loc = [event locationInWindow];
354
+ int x = (int)loc.x;
355
+ int y = (int)loc.y;
356
+ int pressed = [event buttonNumber];
357
+ mf_press_mouse_button(context, pressed, x, y, FALSE);
358
+ }
359
+
360
+ - (void)scrollWheel:(NSEvent *)event
361
+ {
362
+ UINT16 flags;
363
+ [super scrollWheel:event];
364
+
365
+ if (!self.is_connected)
366
+ return;
367
+
368
+ float dx = [event deltaX];
369
+ float dy = [event deltaY];
370
+ /* 1 event = 120 units */
371
+ UINT16 units = 0;
372
+
373
+ if (fabsf(dy) > FLT_EPSILON)
374
+ {
375
+ flags = PTR_FLAGS_WHEEL;
376
+ units = fabsf(dy) * 120;
377
+
378
+ if (dy < 0)
379
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE;
380
+ }
381
+ else if (fabsf(dx) > FLT_EPSILON)
382
+ {
383
+ flags = PTR_FLAGS_HWHEEL;
384
+ units = fabsf(dx) * 120;
385
+
386
+ if (dx > 0)
387
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE;
388
+ }
389
+ else
390
+ return;
391
+
392
+ /* Wheel rotation steps:
393
+ *
394
+ * positive: 0 ... 0xFF -> slow ... fast
395
+ * negative: 0 ... 0xFF -> fast ... slow
396
+ */
397
+ UINT16 step = units;
398
+ if (step > 0xFF)
399
+ step = 0xFF;
400
+
401
+ /* Negative rotation, so count down steps from top
402
+ * 9bit twos complement */
403
+ if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
404
+ step = 0x100 - step;
405
+
406
+ mf_scale_mouse_event(context, flags | step, 0, 0);
407
+ }
408
+
409
+ - (void)mouseDragged:(NSEvent *)event
410
+ {
411
+ [super mouseDragged:event];
412
+
413
+ if (!self.is_connected)
414
+ return;
415
+
416
+ NSPoint loc = [event locationInWindow];
417
+ int x = (int)loc.x;
418
+ int y = (int)loc.y;
419
+ // send mouse motion event to RDP server
420
+ mf_scale_mouse_event(context, PTR_FLAGS_MOVE, x, y);
421
+ }
422
+
423
+ static DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
424
+ {
425
+ /**
426
+ * In 99% of cases, the given key code is truly keyboard independent.
427
+ * This function handles the remaining 1% of edge cases.
428
+ *
429
+ * Hungarian Keyboard: This is 'QWERTZ' and not 'QWERTY'.
430
+ * The '0' key is on the left of the '1' key, where '~' is on a US keyboard.
431
+ * A special 'i' letter key with acute is found on the right of the left shift key.
432
+ * On the hungarian keyboard, the 'i' key is at the left of the 'Y' key
433
+ * Some international keyboards have a corresponding key which would be at
434
+ * the left of the 'Z' key when using a QWERTY layout.
435
+ *
436
+ * The Apple Hungarian keyboard sends inverted key codes for the '0' and 'i' keys.
437
+ * When using the US keyboard layout, key codes are left as-is (inverted).
438
+ * When using the Hungarian keyboard layout, key codes are swapped (non-inverted).
439
+ * This means that when using the Hungarian keyboard layout with a US keyboard,
440
+ * the keys corresponding to '0' and 'i' will effectively be inverted.
441
+ *
442
+ * To fix the '0' and 'i' key inversion, we use the corresponding output character
443
+ * provided by OS X and check for a character to key code mismatch: for instance,
444
+ * when the output character is '0' for the key code corresponding to the 'i' key.
445
+ */
446
+ #if 0
447
+ switch (keyChar)
448
+ {
449
+ case '0':
450
+ case 0x00A7: /* section sign */
451
+ if (keyCode == APPLE_VK_ISO_Section)
452
+ keyCode = APPLE_VK_ANSI_Grave;
453
+
454
+ break;
455
+
456
+ case 0x00ED: /* latin small letter i with acute */
457
+ case 0x00CD: /* latin capital letter i with acute */
458
+ if (keyCode == APPLE_VK_ANSI_Grave)
459
+ keyCode = APPLE_VK_ISO_Section;
460
+
461
+ break;
462
+ }
463
+
464
+ #endif
465
+
466
+ /* Perform keycode correction for all ISO keyboards */
467
+
468
+ if (type == APPLE_KEYBOARD_TYPE_ISO)
469
+ {
470
+ if (keyCode == APPLE_VK_ANSI_Grave)
471
+ keyCode = APPLE_VK_ISO_Section;
472
+ else if (keyCode == APPLE_VK_ISO_Section)
473
+ keyCode = APPLE_VK_ANSI_Grave;
474
+ }
475
+
476
+ return keyCode;
477
+ }
478
+
479
+ - (void)flagsChanged:(NSEvent *)event
480
+ {
481
+ if (!is_connected)
482
+ return;
483
+
484
+ DWORD modFlags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
485
+
486
+ WINPR_ASSERT(instance);
487
+ WINPR_ASSERT(instance->context);
488
+
489
+ rdpInput *input = instance->context->input;
490
+
491
+ #if defined(WITH_DEBUG_KBD)
492
+ WLog_DBG(TAG, "flagsChanged: modFlags: 0x%04X kbdModFlags: 0x%04X", modFlags, kbdModFlags);
493
+ #endif
494
+
495
+ updateFlagStates(input, modFlags, kbdModFlags);
496
+ kbdModFlags = modFlags;
497
+ }
498
+
499
+ - (void)keyDown:(NSEvent *)event
500
+ {
501
+ DWORD keyCode;
502
+ DWORD keyFlags;
503
+ DWORD vkcode;
504
+ DWORD scancode;
505
+ unichar keyChar;
506
+ NSString *characters;
507
+
508
+ if (!is_connected)
509
+ return;
510
+
511
+ [self flagsChanged:event];
512
+
513
+ keyFlags = KBD_FLAGS_DOWN;
514
+ keyCode = [event keyCode];
515
+ characters = [event charactersIgnoringModifiers];
516
+
517
+ if ([characters length] > 0)
518
+ {
519
+ keyChar = [characters characterAtIndex:0];
520
+ keyCode = fixKeyCode(keyCode, keyChar, mfc->appleKeyboardType);
521
+ }
522
+
523
+ vkcode = GetVirtualKeyCodeFromKeycode(keyCode, WINPR_KEYCODE_TYPE_APPLE);
524
+ scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
525
+ keyFlags |= (scancode & KBDEXT) ? KBDEXT : 0;
526
+ scancode &= 0xFF;
527
+ vkcode &= 0xFF;
528
+
529
+ #if defined(WITH_DEBUG_KBD)
530
+ WLog_DBG(TAG, "keyDown: keyCode: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s",
531
+ keyCode, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode));
532
+ #endif
533
+
534
+ WINPR_ASSERT(instance->context);
535
+ freerdp_input_send_keyboard_event(instance->context->input, keyFlags, scancode);
536
+ }
537
+
538
+ - (void)keyUp:(NSEvent *)event
539
+ {
540
+ DWORD keyCode;
541
+ DWORD keyFlags;
542
+ DWORD vkcode;
543
+ DWORD scancode;
544
+ unichar keyChar;
545
+ NSString *characters;
546
+
547
+ if (!is_connected)
548
+ return;
549
+
550
+ [self flagsChanged:event];
551
+
552
+ keyFlags = KBD_FLAGS_RELEASE;
553
+ keyCode = [event keyCode];
554
+ characters = [event charactersIgnoringModifiers];
555
+
556
+ if ([characters length] > 0)
557
+ {
558
+ keyChar = [characters characterAtIndex:0];
559
+ keyCode = fixKeyCode(keyCode, keyChar, mfc->appleKeyboardType);
560
+ }
561
+
562
+ vkcode = GetVirtualKeyCodeFromKeycode(keyCode, WINPR_KEYCODE_TYPE_APPLE);
563
+ scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
564
+ keyFlags |= (scancode & KBDEXT) ? KBDEXT : 0;
565
+ scancode &= 0xFF;
566
+ vkcode &= 0xFF;
567
+ #if defined(WITH_DEBUG_KBD)
568
+ WLog_DBG(TAG, "keyUp: key: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s",
569
+ keyCode, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode));
570
+ #endif
571
+ WINPR_ASSERT(instance->context);
572
+ freerdp_input_send_keyboard_event(instance->context->input, keyFlags, scancode);
573
+ }
574
+
575
+ static BOOL updateFlagState(rdpInput *input, DWORD modFlags, DWORD aKbdModFlags, DWORD flag)
576
+ {
577
+ BOOL press = ((modFlags & flag) != 0) && ((aKbdModFlags & flag) == 0);
578
+ BOOL release = ((modFlags & flag) == 0) && ((aKbdModFlags & flag) != 0);
579
+ DWORD keyFlags = 0;
580
+ const char *name = NULL;
581
+ DWORD scancode = 0;
582
+
583
+ if ((modFlags & flag) == (aKbdModFlags & flag))
584
+ return TRUE;
585
+
586
+ switch (flag)
587
+ {
588
+ case NSEventModifierFlagCapsLock:
589
+ name = "NSEventModifierFlagCapsLock";
590
+ scancode = RDP_SCANCODE_CAPSLOCK;
591
+ release = press = TRUE;
592
+ break;
593
+ case NSEventModifierFlagShift:
594
+ name = "NSEventModifierFlagShift";
595
+ scancode = RDP_SCANCODE_LSHIFT;
596
+ break;
597
+
598
+ case NSEventModifierFlagControl:
599
+ name = "NSEventModifierFlagControl";
600
+ scancode = RDP_SCANCODE_LCONTROL;
601
+ break;
602
+
603
+ case NSEventModifierFlagOption:
604
+ name = "NSEventModifierFlagOption";
605
+ scancode = RDP_SCANCODE_LMENU;
606
+ break;
607
+
608
+ case NSEventModifierFlagCommand:
609
+ name = "NSEventModifierFlagCommand";
610
+ scancode = RDP_SCANCODE_LWIN;
611
+ break;
612
+
613
+ case NSEventModifierFlagNumericPad:
614
+ name = "NSEventModifierFlagNumericPad";
615
+ scancode = RDP_SCANCODE_NUMLOCK;
616
+ release = press = TRUE;
617
+ break;
618
+
619
+ case NSEventModifierFlagHelp:
620
+ name = "NSEventModifierFlagHelp";
621
+ scancode = RDP_SCANCODE_HELP;
622
+ break;
623
+
624
+ case NSEventModifierFlagFunction:
625
+ name = "NSEventModifierFlagFunction";
626
+ scancode = RDP_SCANCODE_HELP;
627
+ break;
628
+
629
+ default:
630
+ WLog_ERR(TAG, "Invalid flag: 0x%08" PRIx32 ", not supported", flag);
631
+ return FALSE;
632
+ }
633
+
634
+ keyFlags = (scancode & KBDEXT);
635
+ scancode &= 0xFF;
636
+
637
+ #if defined(WITH_DEBUG_KBD)
638
+ if (press || release)
639
+ WLog_DBG(TAG, "changing flag %s[0x%08" PRIx32 "] to %s", name, flag,
640
+ press ? "DOWN" : "RELEASE");
641
+ #endif
642
+
643
+ if (press)
644
+ {
645
+ if (!freerdp_input_send_keyboard_event(input, keyFlags | KBD_FLAGS_DOWN, scancode))
646
+ return FALSE;
647
+ }
648
+
649
+ if (release)
650
+ {
651
+ if (!freerdp_input_send_keyboard_event(input, keyFlags | KBD_FLAGS_RELEASE, scancode))
652
+ return FALSE;
653
+ }
654
+
655
+ return TRUE;
656
+ }
657
+
658
+ static BOOL updateFlagStates(rdpInput *input, UINT32 modFlags, UINT32 aKbdModFlags)
659
+ {
660
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagCapsLock);
661
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagShift);
662
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagControl);
663
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagOption);
664
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagCommand);
665
+ updateFlagState(input, modFlags, aKbdModFlags, NSEventModifierFlagNumericPad);
666
+ return TRUE;
667
+ }
668
+
669
+ static BOOL releaseFlagStates(rdpInput *input, UINT32 aKbdModFlags)
670
+ {
671
+ return updateFlagStates(input, 0, aKbdModFlags);
672
+ }
673
+
674
+ - (void)releaseResources
675
+ {
676
+ for (int i = 0; i < argc; i++)
677
+ free(argv[i]);
678
+
679
+ if (!is_connected)
680
+ return;
681
+
682
+ free(pixel_data);
683
+ }
684
+
685
+ - (void)drawRect:(NSRect)rect
686
+ {
687
+ if (!context)
688
+ return;
689
+
690
+ if (self->bitmap_context)
691
+ {
692
+ CGContextRef cgContext = [[NSGraphicsContext currentContext] CGContext];
693
+ CGImageRef cgImage = CGBitmapContextCreateImage(self->bitmap_context);
694
+ CGContextSaveGState(cgContext);
695
+ CGContextClipToRect(
696
+ cgContext, CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
697
+ CGContextDrawImage(cgContext,
698
+ CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height),
699
+ cgImage);
700
+ CGContextRestoreGState(cgContext);
701
+ CGImageRelease(cgImage);
702
+ }
703
+ else
704
+ {
705
+ /* Fill the screen with black */
706
+ [[NSColor blackColor] set];
707
+ NSRectFill([self bounds]);
708
+ }
709
+ }
710
+
711
+ - (void)onPasteboardTimerFired:(NSTimer *)timer
712
+ {
713
+ UINT32 formatId;
714
+ BOOL formatMatch;
715
+ int changeCount;
716
+ NSData *formatData;
717
+ NSString *formatString;
718
+ const char *formatType;
719
+ NSPasteboardItem *item;
720
+ changeCount = (int)[pasteboard_rd changeCount];
721
+
722
+ if (changeCount == pasteboard_changecount)
723
+ return;
724
+
725
+ pasteboard_changecount = changeCount;
726
+ NSArray *items = [pasteboard_rd pasteboardItems];
727
+
728
+ if ([items count] < 1)
729
+ return;
730
+
731
+ item = [items objectAtIndex:0];
732
+ /**
733
+ * System-Declared Uniform Type Identifiers:
734
+ * https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
735
+ */
736
+ formatMatch = FALSE;
737
+
738
+ for (NSString *type in [item types])
739
+ {
740
+ formatType = [type UTF8String];
741
+
742
+ if (strcmp(formatType, "public.utf8-plain-text") == 0)
743
+ {
744
+ formatData = [item dataForType:type];
745
+
746
+ if (formatData == nil)
747
+ {
748
+ break;
749
+ }
750
+
751
+ formatString = [[NSString alloc] initWithData:formatData encoding:NSUTF8StringEncoding];
752
+
753
+ const char *data = [formatString cStringUsingEncoding:NSUTF8StringEncoding];
754
+ const size_t dataLen = [formatString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
755
+ formatId = ClipboardRegisterFormat(mfc->clipboard, "text/plain");
756
+ ClipboardSetData(mfc->clipboard, formatId, data, dataLen + 1);
757
+ [formatString release];
758
+
759
+ formatMatch = TRUE;
760
+
761
+ break;
762
+ }
763
+ }
764
+
765
+ if (!formatMatch)
766
+ ClipboardEmpty(mfc->clipboard);
767
+
768
+ if (mfc->clipboardSync)
769
+ mac_cliprdr_send_client_format_list(mfc->cliprdr);
770
+ }
771
+
772
+ - (void)pause
773
+ {
774
+ dispatch_async(dispatch_get_main_queue(), ^{
775
+ [self->pasteboard_timer invalidate];
776
+ });
777
+ NSArray *trackingAreas = self.trackingAreas;
778
+
779
+ for (NSTrackingArea *ta in trackingAreas)
780
+ {
781
+ [self removeTrackingArea:ta];
782
+ }
783
+ releaseFlagStates(instance->context->input, kbdModFlags);
784
+ kbdModFlags = 0;
785
+ }
786
+
787
+ - (void)resume
788
+ {
789
+ if (!self.is_connected)
790
+ return;
791
+
792
+ releaseFlagStates(instance->context->input, kbdModFlags);
793
+ kbdModFlags = 0;
794
+ freerdp_input_send_focus_in_event(instance->context->input, 0);
795
+
796
+ dispatch_async(dispatch_get_main_queue(), ^{
797
+ self->pasteboard_timer =
798
+ [NSTimer scheduledTimerWithTimeInterval:0.5
799
+ target:self
800
+ selector:@selector(onPasteboardTimerFired:)
801
+ userInfo:nil
802
+ repeats:YES];
803
+
804
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
805
+ initWithRect:[self visibleRect]
806
+ options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
807
+ NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
808
+ NSTrackingActiveWhenFirstResponder
809
+ owner:self
810
+ userInfo:nil];
811
+ [self addTrackingArea:trackingArea];
812
+ [trackingArea release];
813
+ });
814
+ }
815
+
816
+ - (void)setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height
817
+ {
818
+ WINPR_ASSERT(mfc);
819
+
820
+ mfc->yCurrentScroll = yOffset;
821
+ mfc->xCurrentScroll = xOffset;
822
+ mfc->client_height = height;
823
+ mfc->client_width = width;
824
+ }
825
+
826
+ static void mac_OnChannelConnectedEventHandler(void *context, const ChannelConnectedEventArgs *e)
827
+ {
828
+ rdpSettings *settings;
829
+ mfContext *mfc = (mfContext *)context;
830
+
831
+ WINPR_ASSERT(mfc);
832
+ WINPR_ASSERT(e);
833
+
834
+ settings = mfc->common.context.settings;
835
+ WINPR_ASSERT(settings);
836
+
837
+ if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
838
+ {
839
+ mac_cliprdr_init(mfc, (CliprdrClientContext *)e->pInterface);
840
+ }
841
+ else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
842
+ {
843
+ }
844
+ else
845
+ freerdp_client_OnChannelConnectedEventHandler(context, e);
846
+ }
847
+
848
+ static void mac_OnChannelDisconnectedEventHandler(void *context,
849
+ const ChannelDisconnectedEventArgs *e)
850
+ {
851
+ rdpSettings *settings;
852
+ mfContext *mfc = (mfContext *)context;
853
+
854
+ WINPR_ASSERT(mfc);
855
+ WINPR_ASSERT(e);
856
+
857
+ settings = mfc->common.context.settings;
858
+ WINPR_ASSERT(settings);
859
+
860
+ if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
861
+ {
862
+ mac_cliprdr_uninit(mfc, (CliprdrClientContext *)e->pInterface);
863
+ }
864
+ else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
865
+ {
866
+ }
867
+ else
868
+ freerdp_client_OnChannelDisconnectedEventHandler(context, e);
869
+ }
870
+
871
+ BOOL mac_pre_connect(freerdp *instance)
872
+ {
873
+ rdpSettings *settings;
874
+ rdpUpdate *update;
875
+
876
+ WINPR_ASSERT(instance);
877
+ WINPR_ASSERT(instance->context);
878
+
879
+ update = instance->context->update;
880
+ WINPR_ASSERT(update);
881
+
882
+ update->BeginPaint = mac_begin_paint;
883
+ update->EndPaint = mac_end_paint;
884
+ update->DesktopResize = mac_desktop_resize;
885
+
886
+ settings = instance->context->settings;
887
+ WINPR_ASSERT(settings);
888
+
889
+ if (!freerdp_settings_get_string(settings, FreeRDP_ServerHostname))
890
+ {
891
+ WLog_ERR(TAG, "error: server hostname was not specified with /v:<server>[:port]");
892
+ return FALSE;
893
+ }
894
+
895
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_MACINTOSH))
896
+ return FALSE;
897
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_MACINTOSH))
898
+ return FALSE;
899
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler);
900
+ PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
901
+ mac_OnChannelDisconnectedEventHandler);
902
+
903
+ return TRUE;
904
+ }
905
+
906
+ BOOL mac_post_connect(freerdp *instance)
907
+ {
908
+ rdpGdi *gdi;
909
+ rdpPointer rdp_pointer = { 0 };
910
+ mfContext *mfc;
911
+ MRDPView *view;
912
+
913
+ WINPR_ASSERT(instance);
914
+
915
+ mfc = (mfContext *)instance->context;
916
+ WINPR_ASSERT(mfc);
917
+
918
+ view = (MRDPView *)mfc->view;
919
+ WINPR_ASSERT(view);
920
+
921
+ rdp_pointer.size = sizeof(rdpPointer);
922
+ rdp_pointer.New = mf_Pointer_New;
923
+ rdp_pointer.Free = mf_Pointer_Free;
924
+ rdp_pointer.Set = mf_Pointer_Set;
925
+ rdp_pointer.SetNull = mf_Pointer_SetNull;
926
+ rdp_pointer.SetDefault = mf_Pointer_SetDefault;
927
+ rdp_pointer.SetPosition = mf_Pointer_SetPosition;
928
+
929
+ if (!gdi_init(instance, PIXEL_FORMAT_BGRX32))
930
+ return FALSE;
931
+
932
+ gdi = instance->context->gdi;
933
+ view->bitmap_context = mac_create_bitmap_context(instance->context);
934
+ graphics_register_pointer(instance->context->graphics, &rdp_pointer);
935
+ /* setup pasteboard (aka clipboard) for copy operations (write only) */
936
+ view->pasteboard_wr = [NSPasteboard generalPasteboard];
937
+ /* setup pasteboard for read operations */
938
+ dispatch_async(dispatch_get_main_queue(), ^{
939
+ view->pasteboard_rd = [NSPasteboard generalPasteboard];
940
+ view->pasteboard_changecount = -1;
941
+ });
942
+ [view resume];
943
+ mfc->appleKeyboardType = mac_detect_keyboard_type();
944
+ return TRUE;
945
+ }
946
+
947
+ void mac_post_disconnect(freerdp *instance)
948
+ {
949
+ mfContext *mfc;
950
+ MRDPView *view;
951
+ if (!instance || !instance->context)
952
+ return;
953
+
954
+ mfc = (mfContext *)instance->context;
955
+ view = (MRDPView *)mfc->view;
956
+
957
+ [view pause];
958
+
959
+ PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
960
+ mac_OnChannelConnectedEventHandler);
961
+ PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
962
+ mac_OnChannelDisconnectedEventHandler);
963
+ gdi_free(instance);
964
+ }
965
+
966
+ static BOOL mac_show_auth_dialog(MRDPView *view, NSString *title, char **username, char **password,
967
+ char **domain)
968
+ {
969
+ WINPR_ASSERT(view);
970
+ WINPR_ASSERT(title);
971
+ WINPR_ASSERT(username);
972
+ WINPR_ASSERT(password);
973
+ WINPR_ASSERT(domain);
974
+
975
+ PasswordDialog *dialog = [PasswordDialog new];
976
+
977
+ dialog.serverHostname = title;
978
+
979
+ if (*username)
980
+ dialog.username = [NSString stringWithCString:*username encoding:NSUTF8StringEncoding];
981
+
982
+ if (*password)
983
+ dialog.password = [NSString stringWithCString:*password encoding:NSUTF8StringEncoding];
984
+
985
+ if (*domain)
986
+ dialog.domain = [NSString stringWithCString:*domain encoding:NSUTF8StringEncoding];
987
+
988
+ free(*username);
989
+ free(*password);
990
+ free(*domain);
991
+ *username = NULL;
992
+ *password = NULL;
993
+ *domain = NULL;
994
+
995
+ dispatch_sync(dispatch_get_main_queue(), ^{
996
+ [dialog performSelectorOnMainThread:@selector(runModal:)
997
+ withObject:[view window]
998
+ waitUntilDone:TRUE];
999
+ });
1000
+ BOOL ok = dialog.modalCode;
1001
+
1002
+ if (ok)
1003
+ {
1004
+ const char *submittedUsername = [dialog.username cStringUsingEncoding:NSUTF8StringEncoding];
1005
+ const size_t submittedUsernameLen =
1006
+ [dialog.username lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1007
+ if (submittedUsername && (submittedUsernameLen > 0))
1008
+ *username = strndup(submittedUsername, submittedUsernameLen);
1009
+
1010
+ if (!(*username))
1011
+ return FALSE;
1012
+
1013
+ const char *submittedPassword = [dialog.password cStringUsingEncoding:NSUTF8StringEncoding];
1014
+ const size_t submittedPasswordLen =
1015
+ [dialog.password lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1016
+ if (submittedPassword && (submittedPasswordLen > 0))
1017
+ *password = strndup(submittedPassword, submittedPasswordLen);
1018
+
1019
+ if (!(*password))
1020
+ return FALSE;
1021
+
1022
+ const char *submittedDomain = [dialog.domain cStringUsingEncoding:NSUTF8StringEncoding];
1023
+ const size_t submittedDomainLen =
1024
+ [dialog.domain lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1025
+ if (submittedDomain && (submittedDomainLen > 0))
1026
+ {
1027
+ *domain = strndup(submittedDomain, submittedDomainLen);
1028
+ if (!(*domain))
1029
+ return FALSE;
1030
+ }
1031
+ }
1032
+
1033
+ return ok;
1034
+ }
1035
+
1036
+ static BOOL mac_authenticate_raw(freerdp *instance, char **username, char **password, char **domain,
1037
+ rdp_auth_reason reason)
1038
+ {
1039
+ BOOL pinOnly = FALSE;
1040
+
1041
+ WINPR_ASSERT(instance);
1042
+ WINPR_ASSERT(instance->context);
1043
+ WINPR_ASSERT(instance->context->settings);
1044
+
1045
+ const rdpSettings *settings = instance->context->settings;
1046
+ mfContext *mfc = (mfContext *)instance->context;
1047
+ MRDPView *view = (MRDPView *)mfc->view;
1048
+ NSString *title = NULL;
1049
+
1050
+ switch (reason)
1051
+ {
1052
+ case AUTH_SMARTCARD_PIN:
1053
+ pinOnly = TRUE;
1054
+ title = [NSString
1055
+ stringWithFormat:@"%@:%u",
1056
+ [NSString stringWithCString:freerdp_settings_get_string(
1057
+ settings, FreeRDP_ServerHostname)
1058
+ encoding:NSUTF8StringEncoding],
1059
+ freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)];
1060
+ break;
1061
+ case AUTH_TLS:
1062
+ case AUTH_RDP:
1063
+ case AUTH_NLA:
1064
+ title = [NSString
1065
+ stringWithFormat:@"%@:%u",
1066
+ [NSString stringWithCString:freerdp_settings_get_string(
1067
+ settings, FreeRDP_ServerHostname)
1068
+ encoding:NSUTF8StringEncoding],
1069
+ freerdp_settings_get_uint32(settings, FreeRDP_ServerPort)];
1070
+ break;
1071
+ case GW_AUTH_HTTP:
1072
+ case GW_AUTH_RDG:
1073
+ case GW_AUTH_RPC:
1074
+ title = [NSString
1075
+ stringWithFormat:@"%@:%u",
1076
+ [NSString stringWithCString:freerdp_settings_get_string(
1077
+ settings, FreeRDP_GatewayHostname)
1078
+ encoding:NSUTF8StringEncoding],
1079
+ freerdp_settings_get_uint32(settings, FreeRDP_GatewayPort)];
1080
+ break;
1081
+ default:
1082
+ return FALSE;
1083
+ }
1084
+
1085
+ if (!username || !password || !domain)
1086
+ return FALSE;
1087
+
1088
+ if (!*username && !pinOnly)
1089
+ {
1090
+ if (!mac_show_auth_dialog(view, title, username, password, domain))
1091
+ goto fail;
1092
+ }
1093
+ else if (!*domain && !pinOnly)
1094
+ {
1095
+ if (!mac_show_auth_dialog(view, title, username, password, domain))
1096
+ goto fail;
1097
+ }
1098
+ else if (!*password)
1099
+ {
1100
+ if (!mac_show_auth_dialog(view, title, username, password, domain))
1101
+ goto fail;
1102
+ }
1103
+
1104
+ return TRUE;
1105
+ fail:
1106
+ free(*username);
1107
+ free(*domain);
1108
+ free(*password);
1109
+ *username = NULL;
1110
+ *domain = NULL;
1111
+ *password = NULL;
1112
+ return FALSE;
1113
+ }
1114
+
1115
+ BOOL mac_authenticate_ex(freerdp *instance, char **username, char **password, char **domain,
1116
+ rdp_auth_reason reason)
1117
+ {
1118
+ WINPR_ASSERT(instance);
1119
+ WINPR_ASSERT(username);
1120
+ WINPR_ASSERT(password);
1121
+ WINPR_ASSERT(domain);
1122
+
1123
+ NSString *title;
1124
+ switch (reason)
1125
+ {
1126
+ case AUTH_NLA:
1127
+ break;
1128
+
1129
+ case AUTH_TLS:
1130
+ case AUTH_RDP:
1131
+ case AUTH_SMARTCARD_PIN: /* in this case password is pin code */
1132
+ if ((*username) && (*password))
1133
+ return TRUE;
1134
+ break;
1135
+ case GW_AUTH_HTTP:
1136
+ case GW_AUTH_RDG:
1137
+ case GW_AUTH_RPC:
1138
+ break;
1139
+ default:
1140
+ return FALSE;
1141
+ }
1142
+
1143
+ return mac_authenticate_raw(instance, username, password, domain, reason);
1144
+ }
1145
+
1146
+ DWORD mac_verify_certificate_ex(freerdp *instance, const char *host, UINT16 port,
1147
+ const char *common_name, const char *subject, const char *issuer,
1148
+ const char *fingerprint, DWORD flags)
1149
+ {
1150
+ mfContext *mfc = (mfContext *)instance->context;
1151
+ MRDPView *view = (MRDPView *)mfc->view;
1152
+ CertificateDialog *dialog = [CertificateDialog new];
1153
+ const char *type = "RDP-Server";
1154
+ char hostname[8192] = { 0 };
1155
+
1156
+ if (flags & VERIFY_CERT_FLAG_GATEWAY)
1157
+ type = "RDP-Gateway";
1158
+
1159
+ if (flags & VERIFY_CERT_FLAG_REDIRECT)
1160
+ type = "RDP-Redirect";
1161
+
1162
+ sprintf_s(hostname, sizeof(hostname), "%s %s:%" PRIu16, type, host, port);
1163
+ dialog.serverHostname = [NSString stringWithCString:hostname encoding:NSUTF8StringEncoding];
1164
+ dialog.commonName = [NSString stringWithCString:common_name encoding:NSUTF8StringEncoding];
1165
+ dialog.subject = [NSString stringWithCString:subject encoding:NSUTF8StringEncoding];
1166
+ dialog.issuer = [NSString stringWithCString:issuer encoding:NSUTF8StringEncoding];
1167
+ dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:NSUTF8StringEncoding];
1168
+
1169
+ if (flags & VERIFY_CERT_FLAG_MISMATCH)
1170
+ dialog.hostMismatch = TRUE;
1171
+
1172
+ if (flags & VERIFY_CERT_FLAG_CHANGED)
1173
+ dialog.changed = TRUE;
1174
+
1175
+ [dialog performSelectorOnMainThread:@selector(runModal:)
1176
+ withObject:[view window]
1177
+ waitUntilDone:TRUE];
1178
+ return dialog.result;
1179
+ }
1180
+
1181
+ DWORD mac_verify_changed_certificate_ex(freerdp *instance, const char *host, UINT16 port,
1182
+ const char *common_name, const char *subject,
1183
+ const char *issuer, const char *fingerprint,
1184
+ const char *old_subject, const char *old_issuer,
1185
+ const char *old_fingerprint, DWORD flags)
1186
+ {
1187
+ mfContext *mfc = (mfContext *)instance->context;
1188
+ MRDPView *view = (MRDPView *)mfc->view;
1189
+ CertificateDialog *dialog = [CertificateDialog new];
1190
+ const char *type = "RDP-Server";
1191
+ char hostname[8192];
1192
+
1193
+ if (flags & VERIFY_CERT_FLAG_GATEWAY)
1194
+ type = "RDP-Gateway";
1195
+
1196
+ if (flags & VERIFY_CERT_FLAG_REDIRECT)
1197
+ type = "RDP-Redirect";
1198
+
1199
+ sprintf_s(hostname, sizeof(hostname), "%s %s:%" PRIu16, type, host, port);
1200
+ dialog.serverHostname = [NSString stringWithCString:hostname encoding:NSUTF8StringEncoding];
1201
+ dialog.commonName = [NSString stringWithCString:common_name encoding:NSUTF8StringEncoding];
1202
+ dialog.subject = [NSString stringWithCString:subject encoding:NSUTF8StringEncoding];
1203
+ dialog.issuer = [NSString stringWithCString:issuer encoding:NSUTF8StringEncoding];
1204
+ dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:NSUTF8StringEncoding];
1205
+
1206
+ if (flags & VERIFY_CERT_FLAG_MISMATCH)
1207
+ dialog.hostMismatch = TRUE;
1208
+
1209
+ if (flags & VERIFY_CERT_FLAG_CHANGED)
1210
+ dialog.changed = TRUE;
1211
+
1212
+ [dialog performSelectorOnMainThread:@selector(runModal:)
1213
+ withObject:[view window]
1214
+ waitUntilDone:TRUE];
1215
+ return dialog.result;
1216
+ }
1217
+
1218
+ int mac_logon_error_info(freerdp *instance, UINT32 data, UINT32 type)
1219
+ {
1220
+ const char *str_data = freerdp_get_logon_error_info_data(data);
1221
+ const char *str_type = freerdp_get_logon_error_info_type(type);
1222
+ // TODO: Error message dialog
1223
+ WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
1224
+ return 1;
1225
+ }
1226
+
1227
+ BOOL mf_Pointer_New(rdpContext *context, rdpPointer *pointer)
1228
+ {
1229
+ rdpGdi *gdi;
1230
+ NSRect rect;
1231
+ NSImage *image;
1232
+ NSPoint hotSpot;
1233
+ NSCursor *cursor;
1234
+ BYTE *cursor_data;
1235
+ NSMutableArray *ma;
1236
+ NSBitmapImageRep *bmiRep;
1237
+ MRDPCursor *mrdpCursor = [[MRDPCursor alloc] init];
1238
+ mfContext *mfc = (mfContext *)context;
1239
+ MRDPView *view;
1240
+ UINT32 format;
1241
+
1242
+ if (!mfc || !context || !pointer)
1243
+ return FALSE;
1244
+
1245
+ view = (MRDPView *)mfc->view;
1246
+ gdi = context->gdi;
1247
+
1248
+ if (!gdi || !view)
1249
+ return FALSE;
1250
+
1251
+ rect.size.width = pointer->width;
1252
+ rect.size.height = pointer->height;
1253
+ rect.origin.x = pointer->xPos;
1254
+ rect.origin.y = pointer->yPos;
1255
+ cursor_data = (BYTE *)malloc(rect.size.width * rect.size.height * 4);
1256
+
1257
+ if (!cursor_data)
1258
+ return FALSE;
1259
+
1260
+ mrdpCursor->cursor_data = cursor_data;
1261
+ format = PIXEL_FORMAT_RGBA32;
1262
+
1263
+ if (!freerdp_image_copy_from_pointer_data(cursor_data, format, 0, 0, 0, pointer->width,
1264
+ pointer->height, pointer->xorMaskData,
1265
+ pointer->lengthXorMask, pointer->andMaskData,
1266
+ pointer->lengthAndMask, pointer->xorBpp, NULL))
1267
+ {
1268
+ free(cursor_data);
1269
+ mrdpCursor->cursor_data = NULL;
1270
+ return FALSE;
1271
+ }
1272
+
1273
+ /* store cursor bitmap image in representation - required by NSImage */
1274
+ bmiRep = [[NSBitmapImageRep alloc]
1275
+ initWithBitmapDataPlanes:(unsigned char **)&cursor_data
1276
+ pixelsWide:rect.size.width
1277
+ pixelsHigh:rect.size.height
1278
+ bitsPerSample:8
1279
+ samplesPerPixel:4
1280
+ hasAlpha:YES
1281
+ isPlanar:NO
1282
+ colorSpaceName:NSDeviceRGBColorSpace
1283
+ bitmapFormat:0
1284
+ bytesPerRow:rect.size.width * FreeRDPGetBytesPerPixel(format)
1285
+ bitsPerPixel:0];
1286
+ mrdpCursor->bmiRep = bmiRep;
1287
+ /* create an image using above representation */
1288
+ image = [[NSImage alloc] initWithSize:[bmiRep size]];
1289
+ [image addRepresentation:bmiRep];
1290
+ mrdpCursor->nsImage = image;
1291
+ /* need hotspot to create cursor */
1292
+ hotSpot.x = pointer->xPos;
1293
+ hotSpot.y = pointer->yPos;
1294
+ cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
1295
+ mrdpCursor->nsCursor = cursor;
1296
+ mrdpCursor->pointer = pointer;
1297
+ /* save cursor for later use in mf_Pointer_Set() */
1298
+ ma = view->cursors;
1299
+ [ma addObject:mrdpCursor];
1300
+ return TRUE;
1301
+ }
1302
+
1303
+ void mf_Pointer_Free(rdpContext *context, rdpPointer *pointer)
1304
+ {
1305
+ mfContext *mfc = (mfContext *)context;
1306
+ MRDPView *view = (MRDPView *)mfc->view;
1307
+ NSMutableArray *ma = view->cursors;
1308
+
1309
+ for (MRDPCursor *cursor in ma)
1310
+ {
1311
+ if (cursor->pointer == pointer)
1312
+ {
1313
+ cursor->nsImage = nil;
1314
+ cursor->nsCursor = nil;
1315
+ cursor->bmiRep = nil;
1316
+ free(cursor->cursor_data);
1317
+ [ma removeObject:cursor];
1318
+ return;
1319
+ }
1320
+ }
1321
+ }
1322
+
1323
+ BOOL mf_Pointer_Set(rdpContext *context, rdpPointer *pointer)
1324
+ {
1325
+ mfContext *mfc = (mfContext *)context;
1326
+ MRDPView *view = (MRDPView *)mfc->view;
1327
+ NSMutableArray *ma = view->cursors;
1328
+
1329
+ for (MRDPCursor *cursor in ma)
1330
+ {
1331
+ if (cursor->pointer == pointer)
1332
+ {
1333
+ [view setCursor:cursor->nsCursor];
1334
+ return TRUE;
1335
+ }
1336
+ }
1337
+
1338
+ NSLog(@"Cursor not found");
1339
+ return TRUE;
1340
+ }
1341
+
1342
+ BOOL mf_Pointer_SetNull(rdpContext *context)
1343
+ {
1344
+ return TRUE;
1345
+ }
1346
+
1347
+ BOOL mf_Pointer_SetDefault(rdpContext *context)
1348
+ {
1349
+ mfContext *mfc = (mfContext *)context;
1350
+ MRDPView *view = (MRDPView *)mfc->view;
1351
+ [view setCursor:[NSCursor arrowCursor]];
1352
+ return TRUE;
1353
+ }
1354
+
1355
+ static BOOL mf_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y)
1356
+ {
1357
+ mfContext *mfc = (mfContext *)context;
1358
+
1359
+ if (!mfc)
1360
+ return FALSE;
1361
+
1362
+ /* TODO: Set pointer position */
1363
+ return TRUE;
1364
+ }
1365
+
1366
+ CGContextRef mac_create_bitmap_context(rdpContext *context)
1367
+ {
1368
+ CGContextRef bitmap_context;
1369
+ rdpGdi *gdi = context->gdi;
1370
+ UINT32 bpp = FreeRDPGetBytesPerPixel(gdi->dstFormat);
1371
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
1372
+
1373
+ if (bpp == 2)
1374
+ {
1375
+ bitmap_context = CGBitmapContextCreate(
1376
+ gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace,
1377
+ kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
1378
+ }
1379
+ else
1380
+ {
1381
+ bitmap_context = CGBitmapContextCreate(
1382
+ gdi->primary_buffer, gdi->width, gdi->height, 8, gdi->stride, colorSpace,
1383
+ kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
1384
+ }
1385
+
1386
+ CGColorSpaceRelease(colorSpace);
1387
+ return bitmap_context;
1388
+ }
1389
+
1390
+ BOOL mac_begin_paint(rdpContext *context)
1391
+ {
1392
+ rdpGdi *gdi = context->gdi;
1393
+
1394
+ if (!gdi)
1395
+ return FALSE;
1396
+
1397
+ gdi->primary->hdc->hwnd->invalid->null = TRUE;
1398
+ return TRUE;
1399
+ }
1400
+
1401
+ BOOL mac_end_paint(rdpContext *context)
1402
+ {
1403
+ rdpGdi *gdi;
1404
+ HGDI_RGN invalid;
1405
+ NSRect newDrawRect;
1406
+ int ww, wh, dw, dh;
1407
+ mfContext *mfc = (mfContext *)context;
1408
+ MRDPView *view = (MRDPView *)mfc->view;
1409
+ gdi = context->gdi;
1410
+
1411
+ if (!gdi)
1412
+ return FALSE;
1413
+
1414
+ ww = mfc->client_width;
1415
+ wh = mfc->client_height;
1416
+ dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth);
1417
+ dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight);
1418
+
1419
+ if ((!context) || (!context->gdi))
1420
+ return FALSE;
1421
+
1422
+ if (context->gdi->primary->hdc->hwnd->invalid->null)
1423
+ return TRUE;
1424
+
1425
+ invalid = gdi->primary->hdc->hwnd->invalid;
1426
+ newDrawRect.origin.x = invalid->x;
1427
+ newDrawRect.origin.y = invalid->y;
1428
+ newDrawRect.size.width = invalid->w;
1429
+ newDrawRect.size.height = invalid->h;
1430
+
1431
+ if (freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) &&
1432
+ (ww != dw || wh != dh))
1433
+ {
1434
+ newDrawRect.origin.y = newDrawRect.origin.y * wh / dh - 1;
1435
+ newDrawRect.size.height = newDrawRect.size.height * wh / dh + 1;
1436
+ newDrawRect.origin.x = newDrawRect.origin.x * ww / dw - 1;
1437
+ newDrawRect.size.width = newDrawRect.size.width * ww / dw + 1;
1438
+ }
1439
+ else
1440
+ {
1441
+ newDrawRect.origin.y = newDrawRect.origin.y - 1;
1442
+ newDrawRect.size.height = newDrawRect.size.height + 1;
1443
+ newDrawRect.origin.x = newDrawRect.origin.x - 1;
1444
+ newDrawRect.size.width = newDrawRect.size.width + 1;
1445
+ }
1446
+
1447
+ windows_to_apple_cords(mfc->view, &newDrawRect);
1448
+ dispatch_sync(dispatch_get_main_queue(), ^{
1449
+ [view setNeedsDisplayInRect:newDrawRect];
1450
+ });
1451
+ gdi->primary->hdc->hwnd->ninvalid = 0;
1452
+ return TRUE;
1453
+ }
1454
+
1455
+ BOOL mac_desktop_resize(rdpContext *context)
1456
+ {
1457
+ ResizeWindowEventArgs e;
1458
+ mfContext *mfc = (mfContext *)context;
1459
+ MRDPView *view = (MRDPView *)mfc->view;
1460
+ rdpSettings *settings = context->settings;
1461
+
1462
+ if (!context->gdi)
1463
+ return TRUE;
1464
+
1465
+ /**
1466
+ * TODO: Fix resizing race condition. We should probably implement a message to be
1467
+ * put on the update message queue to be able to properly flush pending updates,
1468
+ * resize, and then continue with post-resizing graphical updates.
1469
+ */
1470
+ CGContextRef old_context = view->bitmap_context;
1471
+ view->bitmap_context = NULL;
1472
+ CGContextRelease(old_context);
1473
+ mfc->width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
1474
+ mfc->height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
1475
+
1476
+ if (!gdi_resize(context->gdi, mfc->width, mfc->height))
1477
+ return FALSE;
1478
+
1479
+ view->bitmap_context = mac_create_bitmap_context(context);
1480
+
1481
+ if (!view->bitmap_context)
1482
+ return FALSE;
1483
+
1484
+ mfc->client_width = mfc->width;
1485
+ mfc->client_height = mfc->height;
1486
+ [view setFrameSize:NSMakeSize(mfc->width, mfc->height)];
1487
+ EventArgsInit(&e, "mfreerdp");
1488
+ e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
1489
+ e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
1490
+ PubSub_OnResizeWindow(context->pubSub, context, &e);
1491
+ return TRUE;
1492
+ }
1493
+
1494
+ void input_activity_cb(freerdp *instance)
1495
+ {
1496
+ int status;
1497
+ wMessage message;
1498
+ wMessageQueue *queue;
1499
+ status = 1;
1500
+ queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
1501
+
1502
+ if (queue)
1503
+ {
1504
+ while (MessageQueue_Peek(queue, &message, TRUE))
1505
+ {
1506
+ status = freerdp_message_queue_process_message(instance, FREERDP_INPUT_MESSAGE_QUEUE,
1507
+ &message);
1508
+
1509
+ if (!status)
1510
+ break;
1511
+ }
1512
+ }
1513
+ else
1514
+ {
1515
+ WLog_ERR(TAG, "input_activity_cb: No queue!");
1516
+ }
1517
+ }
1518
+
1519
+ /**
1520
+ * given a rect with 0,0 at the top left (windows cords)
1521
+ * convert it to a rect with 0,0 at the bottom left (apple cords)
1522
+ *
1523
+ * Note: the formula works for conversions in both directions.
1524
+ *
1525
+ */
1526
+
1527
+ void windows_to_apple_cords(MRDPView *view, NSRect *r)
1528
+ {
1529
+ dispatch_sync(dispatch_get_main_queue(), ^{
1530
+ r->origin.y = [view frame].size.height - (r->origin.y + r->size.height);
1531
+ });
1532
+ }
1533
+
1534
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/ModuleOptions.cmake ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ set(FREERDP_CLIENT_NAME "mfreerdp")
2
+ set(FREERDP_CLIENT_PLATFORM "MacOSX")
3
+ set(FREERDP_CLIENT_VENDOR "FreeRDP")
local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2013 Christian Hofstaedtler
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import <Cocoa/Cocoa.h>
21
+
22
+ @interface PasswordDialog : NSWindowController
23
+ {
24
+ @public
25
+ NSTextField *usernameText;
26
+ NSTextField *passwordText;
27
+ NSTextField *messageLabel;
28
+ NSString *serverHostname;
29
+ NSString *username;
30
+ NSString *password;
31
+ NSString *domain;
32
+ BOOL modalCode;
33
+ }
34
+ @property(retain) IBOutlet NSTextField *usernameText;
35
+ @property(retain) IBOutlet NSTextField *passwordText;
36
+ @property(retain) IBOutlet NSTextField *messageLabel;
37
+
38
+ - (IBAction)onOK:(NSObject *)sender;
39
+ - (IBAction)onCancel:(NSObject *)sender;
40
+
41
+ @property(retain) NSString *serverHostname;
42
+ @property(retain) NSString *username;
43
+ @property(retain) NSString *password;
44
+ @property(retain) NSString *domain;
45
+ @property(readonly) BOOL modalCode;
46
+
47
+ - (BOOL)runModal:(NSWindow *)mainWindow;
48
+
49
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.m ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2013 Christian Hofstaedtler
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import "PasswordDialog.h"
21
+ #import <freerdp/client/cmdline.h>
22
+
23
+ #import <CoreGraphics/CoreGraphics.h>
24
+
25
+ @interface PasswordDialog ()
26
+
27
+ @property BOOL modalCode;
28
+
29
+ @end
30
+
31
+ @implementation PasswordDialog
32
+
33
+ @synthesize usernameText;
34
+ @synthesize passwordText;
35
+ @synthesize messageLabel;
36
+ @synthesize serverHostname;
37
+ @synthesize username;
38
+ @synthesize password;
39
+ @synthesize domain;
40
+ @synthesize modalCode;
41
+
42
+ - (id)init
43
+ {
44
+ return [self initWithWindowNibName:@"PasswordDialog"];
45
+ }
46
+
47
+ - (void)windowDidLoad
48
+ {
49
+ [super windowDidLoad];
50
+ // Implement this method to handle any initialization after your window controller's window has
51
+ // been loaded from its nib file.
52
+ [self.window setTitle:self.serverHostname];
53
+ [self.messageLabel
54
+ setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverHostname]];
55
+ NSMutableString *domainUser = [[NSMutableString alloc] initWithString:@""];
56
+
57
+ if (self.domain != nil &&
58
+ [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
59
+ length] > 0)
60
+ {
61
+ [domainUser appendFormat:@"%@\\", self.domain];
62
+ }
63
+
64
+ if (self.username != nil)
65
+ {
66
+ [domainUser appendString:self.username];
67
+ [self.window makeFirstResponder:self.passwordText];
68
+ }
69
+
70
+ [self.usernameText setStringValue:domainUser];
71
+ }
72
+
73
+ - (IBAction)onOK:(NSObject *)sender
74
+ {
75
+ char *submittedUser = NULL;
76
+ char *submittedDomain = NULL;
77
+
78
+ if (freerdp_parse_username(
79
+ [self.usernameText.stringValue cStringUsingEncoding:NSUTF8StringEncoding],
80
+ &submittedUser, &submittedDomain))
81
+ {
82
+ if (submittedUser)
83
+ self.username = [NSString stringWithCString:submittedUser
84
+ encoding:NSUTF8StringEncoding];
85
+ if (submittedDomain)
86
+ self.domain = [NSString stringWithCString:submittedDomain
87
+ encoding:NSUTF8StringEncoding];
88
+ }
89
+ else
90
+ {
91
+ self.username = self.usernameText.stringValue;
92
+ }
93
+
94
+ self.password = self.passwordText.stringValue;
95
+ free(submittedUser);
96
+ free(submittedDomain);
97
+ [NSApp stopModalWithCode:TRUE];
98
+ }
99
+
100
+ - (IBAction)onCancel:(NSObject *)sender
101
+ {
102
+ [NSApp stopModalWithCode:FALSE];
103
+ }
104
+
105
+ - (BOOL)runModal:(NSWindow *)mainWindow
106
+ {
107
+ if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
108
+ {
109
+ [mainWindow beginSheet:self.window completionHandler:nil];
110
+ self.modalCode = [NSApp runModalForWindow:self.window];
111
+ [mainWindow endSheet:self.window];
112
+ }
113
+ else
114
+ {
115
+ [NSApp beginSheet:self.window
116
+ modalForWindow:mainWindow
117
+ modalDelegate:nil
118
+ didEndSelector:nil
119
+ contextInfo:nil];
120
+ self.modalCode = [NSApp runModalForWindow:self.window];
121
+ [NSApp endSheet:self.window];
122
+ }
123
+
124
+ [self.window orderOut:nil];
125
+ return self.modalCode;
126
+ }
127
+
128
+ - (void)dealloc
129
+ {
130
+ [usernameText release];
131
+ [passwordText release];
132
+ [messageLabel release];
133
+ [serverHostname release];
134
+ [username release];
135
+ [password release];
136
+ [domain release];
137
+ [super dealloc];
138
+ }
139
+
140
+ @end
local-test-freerdp-full-01/afc-freerdp/client/Mac/PasswordDialog.xib ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
5
+ </dependencies>
6
+ <objects>
7
+ <customObject id="-2" userLabel="File's Owner" customClass="PasswordDialog">
8
+ <connections>
9
+ <outlet property="messageLabel" destination="7" id="50"/>
10
+ <outlet property="passwordText" destination="6" id="48"/>
11
+ <outlet property="usernameText" destination="11" id="49"/>
12
+ <outlet property="window" destination="1" id="3"/>
13
+ </connections>
14
+ </customObject>
15
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
16
+ <customObject id="-3" userLabel="Application"/>
17
+ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
18
+ <windowStyleMask key="styleMask" titled="YES" texturedBackground="YES"/>
19
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
20
+ <rect key="contentRect" x="196" y="240" width="480" height="270"/>
21
+ <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
22
+ <view key="contentView" id="2">
23
+ <rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
24
+ <autoresizingMask key="autoresizingMask"/>
25
+ <subviews>
26
+ <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5">
27
+ <rect key="frame" x="47" y="127" width="106" height="17"/>
28
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Password:" id="22">
29
+ <font key="font" metaFont="system"/>
30
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
31
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
32
+ </textFieldCell>
33
+ </textField>
34
+ <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6">
35
+ <rect key="frame" x="159" y="124" width="233" height="22"/>
36
+ <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="Password" drawsBackground="YES" usesSingleLineMode="YES" id="21">
37
+ <font key="font" metaFont="system"/>
38
+ <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
39
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
40
+ <allowedInputSourceLocales>
41
+ <string>NSAllRomanInputSourcesLocaleIdentifier</string>
42
+ </allowedInputSourceLocales>
43
+ </secureTextFieldCell>
44
+ </secureTextField>
45
+ <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7">
46
+ <rect key="frame" x="47" y="206" width="344" height="17"/>
47
+ <constraints>
48
+ <constraint firstAttribute="width" constant="340" id="19"/>
49
+ </constraints>
50
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Connect to SERVER_NAME" placeholderString="" id="20">
51
+ <font key="font" metaFont="system"/>
52
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
53
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
54
+ </textFieldCell>
55
+ </textField>
56
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8">
57
+ <rect key="frame" x="384" y="13" width="82" height="32"/>
58
+ <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="18">
59
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
60
+ <font key="font" metaFont="system"/>
61
+ <string key="keyEquivalent" base64-UTF8="YES">
62
+ Gw
63
+ </string>
64
+ </buttonCell>
65
+ <connections>
66
+ <action selector="onCancel:" target="-2" id="52"/>
67
+ </connections>
68
+ </button>
69
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9">
70
+ <rect key="frame" x="302" y="13" width="82" height="32"/>
71
+ <constraints>
72
+ <constraint firstAttribute="width" constant="70" id="16"/>
73
+ </constraints>
74
+ <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="17">
75
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
76
+ <font key="font" metaFont="system"/>
77
+ <string key="keyEquivalent" base64-UTF8="YES">
78
+ DQ
79
+ </string>
80
+ </buttonCell>
81
+ <connections>
82
+ <action selector="onOK:" target="-2" id="51"/>
83
+ </connections>
84
+ </button>
85
+ <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="10">
86
+ <rect key="frame" x="47" y="159" width="106" height="17"/>
87
+ <constraints>
88
+ <constraint firstAttribute="width" constant="102" id="14"/>
89
+ </constraints>
90
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Username:" id="15">
91
+ <font key="font" metaFont="system"/>
92
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
93
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
94
+ </textFieldCell>
95
+ </textField>
96
+ <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="11">
97
+ <rect key="frame" x="159" y="156" width="233" height="22"/>
98
+ <constraints>
99
+ <constraint firstAttribute="width" constant="233" id="12"/>
100
+ </constraints>
101
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="username@domain" drawsBackground="YES" id="13">
102
+ <font key="font" metaFont="system"/>
103
+ <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
104
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
105
+ </textFieldCell>
106
+ </textField>
107
+ </subviews>
108
+ <constraints>
109
+ <constraint firstItem="6" firstAttribute="leading" secondItem="11" secondAttribute="leading" id="25"/>
110
+ <constraint firstItem="5" firstAttribute="centerY" secondItem="6" secondAttribute="centerY" id="27"/>
111
+ <constraint firstItem="6" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="8" symbolic="YES" id="28"/>
112
+ <constraint firstItem="6" firstAttribute="trailing" secondItem="11" secondAttribute="trailing" id="30"/>
113
+ <constraint firstItem="11" firstAttribute="leading" secondItem="10" secondAttribute="trailing" constant="8" symbolic="YES" id="31"/>
114
+ <constraint firstItem="8" firstAttribute="leading" secondItem="9" secondAttribute="trailing" constant="12" symbolic="YES" id="32"/>
115
+ <constraint firstItem="10" firstAttribute="leading" secondItem="5" secondAttribute="leading" id="34"/>
116
+ <constraint firstItem="10" firstAttribute="leading" secondItem="7" secondAttribute="leading" id="37"/>
117
+ <constraint firstAttribute="bottom" secondItem="9" secondAttribute="bottom" constant="20" symbolic="YES" id="39"/>
118
+ <constraint firstItem="5" firstAttribute="centerY" secondItem="2" secondAttribute="centerY" id="41"/>
119
+ <constraint firstAttribute="bottom" secondItem="8" secondAttribute="bottom" constant="20" symbolic="YES" id="42"/>
120
+ <constraint firstAttribute="trailing" secondItem="8" secondAttribute="trailing" constant="20" symbolic="YES" id="43"/>
121
+ <constraint firstItem="7" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="49" id="44"/>
122
+ <constraint firstItem="7" firstAttribute="top" secondItem="2" secondAttribute="top" constant="47" id="45"/>
123
+ <constraint firstItem="6" firstAttribute="top" secondItem="11" secondAttribute="bottom" constant="10" symbolic="YES" id="46"/>
124
+ <constraint firstItem="10" firstAttribute="baseline" secondItem="11" secondAttribute="baseline" id="47"/>
125
+ </constraints>
126
+ </view>
127
+ <connections>
128
+ <outlet property="delegate" destination="-2" id="4"/>
129
+ </connections>
130
+ </window>
131
+ </objects>
132
+ </document>
local-test-freerdp-full-01/afc-freerdp/client/Mac/main.m ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * MacFreeRDP
4
+ *
5
+ * Copyright 2012 Thomas Goddard
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #import <Cocoa/Cocoa.h>
21
+
22
+ int main(int argc, char *argv[])
23
+ {
24
+ return NSApplicationMain(argc, argv);
25
+ }
local-test-freerdp-full-01/afc-freerdp/client/Mac/mf_client.h ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Windows Client
4
+ *
5
+ * Copyright 2009-2011 Jay Sorg
6
+ * Copyright 2010-2011 Vic Lee
7
+ * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+
22
+ #ifndef FREERDP_CLIENT_MAC_CLIENT_H
23
+ #define FREERDP_CLIENT_MAC_CLIENT_H
24
+
25
+ #include <freerdp/client.h>
26
+
27
+ #ifdef __cplusplus
28
+ extern "C"
29
+ {
30
+ #endif
31
+
32
+ FREERDP_API void mf_press_mouse_button(void* context, int button, int x, int y, BOOL down);
33
+ FREERDP_API void mf_scale_mouse_event(void* context, UINT16 flags, UINT16 x, UINT16 y);
34
+ FREERDP_API void mf_scale_mouse_event_ex(void* context, UINT16 flags, UINT16 x, UINT16 y);
35
+
36
+ /**
37
+ * Client Interface
38
+ */
39
+
40
+ FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
41
+
42
+ #ifdef __cplusplus
43
+ }
44
+ #endif
45
+
46
+ #endif /* FREERDP_CLIENT_MAC_CLIENT_H */
local-test-freerdp-full-01/afc-freerdp/client/Mac/mf_client.m ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * X11 Client Interface
4
+ *
5
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #include <freerdp/config.h>
21
+
22
+ #include "mfreerdp.h"
23
+
24
+ #include <winpr/assert.h>
25
+
26
+ #include <freerdp/constants.h>
27
+ #include <freerdp/utils/signal.h>
28
+ #include <freerdp/client/cmdline.h>
29
+
30
+ #include "MRDPView.h"
31
+
32
+ /**
33
+ * Client Interface
34
+ */
35
+
36
+ static BOOL mfreerdp_client_global_init(void)
37
+ {
38
+ freerdp_handle_signals();
39
+ return TRUE;
40
+ }
41
+
42
+ static void mfreerdp_client_global_uninit(void)
43
+ {
44
+ }
45
+
46
+ static int mfreerdp_client_start(rdpContext *context)
47
+ {
48
+ MRDPView *view;
49
+ mfContext *mfc = (mfContext *)context;
50
+
51
+ if (mfc->view == NULL)
52
+ {
53
+ // view not specified beforehand. Create view dynamically
54
+ mfc->view = [[MRDPView alloc]
55
+ initWithFrame:NSMakeRect(
56
+ 0, 0,
57
+ freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth),
58
+ freerdp_settings_get_uint32(context->settings,
59
+ FreeRDP_DesktopHeight))];
60
+ mfc->view_ownership = TRUE;
61
+ }
62
+
63
+ view = (MRDPView *)mfc->view;
64
+ return [view rdpStart:context];
65
+ }
66
+
67
+ static int mfreerdp_client_stop(rdpContext *context)
68
+ {
69
+ mfContext *mfc = (mfContext *)context;
70
+
71
+ freerdp_client_common_stop(context);
72
+
73
+ if (mfc->view_ownership)
74
+ {
75
+ MRDPView *view = (MRDPView *)mfc->view;
76
+ [view releaseResources];
77
+ [view release];
78
+ mfc->view = nil;
79
+ }
80
+
81
+ return 0;
82
+ }
83
+
84
+ static BOOL mfreerdp_client_new(freerdp *instance, rdpContext *context)
85
+ {
86
+ mfContext *mfc;
87
+
88
+ WINPR_ASSERT(instance);
89
+
90
+ mfc = (mfContext *)instance->context;
91
+ WINPR_ASSERT(mfc);
92
+
93
+ mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
94
+ if (!mfc->stopEvent)
95
+ return FALSE;
96
+ context->instance->PreConnect = mac_pre_connect;
97
+ context->instance->PostConnect = mac_post_connect;
98
+ context->instance->PostDisconnect = mac_post_disconnect;
99
+ context->instance->AuthenticateEx = mac_authenticate_ex;
100
+ context->instance->VerifyCertificateEx = mac_verify_certificate_ex;
101
+ context->instance->VerifyChangedCertificateEx = mac_verify_changed_certificate_ex;
102
+ context->instance->LogonErrorInfo = mac_logon_error_info;
103
+ return TRUE;
104
+ }
105
+
106
+ static void mfreerdp_client_free(freerdp *instance, rdpContext *context)
107
+ {
108
+ mfContext *mfc;
109
+
110
+ if (!instance || !context)
111
+ return;
112
+
113
+ mfc = (mfContext *)instance->context;
114
+ (void)CloseHandle(mfc->stopEvent);
115
+ }
116
+
117
+ static void mf_scale_mouse_coordinates(mfContext *mfc, UINT16 *px, UINT16 *py)
118
+ {
119
+ UINT16 x = *px;
120
+ UINT16 y = *py;
121
+ UINT32 ww = mfc->client_width;
122
+ UINT32 wh = mfc->client_height;
123
+ UINT32 dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth);
124
+ UINT32 dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight);
125
+
126
+ if (!freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) ||
127
+ ((ww == dw) && (wh == dh)))
128
+ {
129
+ y = y + mfc->yCurrentScroll;
130
+ x = x + mfc->xCurrentScroll;
131
+
132
+ y -= (dh - wh);
133
+ x -= (dw - ww);
134
+ }
135
+ else
136
+ {
137
+ y = y * dh / wh + mfc->yCurrentScroll;
138
+ x = x * dw / ww + mfc->xCurrentScroll;
139
+ }
140
+
141
+ *px = x;
142
+ *py = y;
143
+ }
144
+
145
+ void mf_scale_mouse_event(void *context, UINT16 flags, UINT16 x, UINT16 y)
146
+ {
147
+ mfContext *mfc = (mfContext *)context;
148
+ MRDPView *view = (MRDPView *)mfc->view;
149
+ // Convert to windows coordinates
150
+ y = [view frame].size.height - y;
151
+
152
+ if ((flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL)) == 0)
153
+ mf_scale_mouse_coordinates(mfc, &x, &y);
154
+ freerdp_client_send_button_event(&mfc->common, FALSE, flags, x, y);
155
+ }
156
+
157
+ void mf_scale_mouse_event_ex(void *context, UINT16 flags, UINT16 x, UINT16 y)
158
+ {
159
+ mfContext *mfc = (mfContext *)context;
160
+ MRDPView *view = (MRDPView *)mfc->view;
161
+ // Convert to windows coordinates
162
+ y = [view frame].size.height - y;
163
+
164
+ mf_scale_mouse_coordinates(mfc, &x, &y);
165
+ freerdp_client_send_extended_button_event(&mfc->common, FALSE, flags, x, y);
166
+ }
167
+
168
+ void mf_press_mouse_button(void *context, int button, int x, int y, BOOL down)
169
+ {
170
+ UINT16 flags = 0;
171
+ UINT16 xflags = 0;
172
+
173
+ if (down)
174
+ {
175
+ flags |= PTR_FLAGS_DOWN;
176
+ xflags |= PTR_XFLAGS_DOWN;
177
+ }
178
+
179
+ switch (button)
180
+ {
181
+ case 0:
182
+ mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON1, x, y);
183
+ break;
184
+
185
+ case 1:
186
+ mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON2, x, y);
187
+ break;
188
+
189
+ case 2:
190
+ mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON3, x, y);
191
+ break;
192
+
193
+ case 3:
194
+ mf_scale_mouse_event_ex(context, xflags | PTR_XFLAGS_BUTTON1, x, y);
195
+ break;
196
+
197
+ case 4:
198
+ mf_scale_mouse_event_ex(context, xflags | PTR_XFLAGS_BUTTON2, x, y);
199
+ break;
200
+
201
+ default:
202
+ break;
203
+ }
204
+ }
205
+
206
+ int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
207
+ {
208
+ WINPR_ASSERT(pEntryPoints);
209
+
210
+ pEntryPoints->Version = 1;
211
+ pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
212
+ pEntryPoints->GlobalInit = mfreerdp_client_global_init;
213
+ pEntryPoints->GlobalUninit = mfreerdp_client_global_uninit;
214
+ pEntryPoints->ContextSize = sizeof(mfContext);
215
+ pEntryPoints->ClientNew = mfreerdp_client_new;
216
+ pEntryPoints->ClientFree = mfreerdp_client_free;
217
+ pEntryPoints->ClientStart = mfreerdp_client_start;
218
+ pEntryPoints->ClientStop = mfreerdp_client_stop;
219
+ return 0;
220
+ }
local-test-freerdp-full-01/afc-freerdp/client/Mac/mfreerdp.h ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREERDP_CLIENT_MAC_FREERDP_H
2
+ #define FREERDP_CLIENT_MAC_FREERDP_H
3
+
4
+ #include <freerdp/freerdp.h>
5
+ #include <freerdp/client/file.h>
6
+ #include <freerdp/api.h>
7
+ #include <freerdp/freerdp.h>
8
+
9
+ #include <freerdp/gdi/gdi.h>
10
+ #include <freerdp/gdi/dc.h>
11
+ #include <freerdp/gdi/gfx.h>
12
+ #include <freerdp/gdi/region.h>
13
+ #include <freerdp/channels/channels.h>
14
+
15
+ #include <freerdp/client/channels.h>
16
+ #include <freerdp/client/rdpei.h>
17
+ #include <freerdp/client/rdpgfx.h>
18
+ #include <freerdp/client/cliprdr.h>
19
+ #include <freerdp/client/encomsp.h>
20
+
21
+ #include <winpr/crt.h>
22
+ #include <winpr/synch.h>
23
+ #include <winpr/thread.h>
24
+ #include <winpr/clipboard.h>
25
+
26
+ #include "Keyboard.h"
27
+ #include <CoreGraphics/CoreGraphics.h>
28
+
29
+ typedef struct
30
+ {
31
+ rdpClientContext common;
32
+
33
+ void* view;
34
+ BOOL view_ownership;
35
+
36
+ int width;
37
+ int height;
38
+ int offset_x;
39
+ int offset_y;
40
+ int fs_toggle;
41
+ int fullscreen;
42
+ int percentscreen;
43
+ char window_title[64];
44
+ int client_x;
45
+ int client_y;
46
+ int client_width;
47
+ int client_height;
48
+
49
+ HANDLE stopEvent;
50
+ HANDLE keyboardThread;
51
+ enum APPLE_KEYBOARD_TYPE appleKeyboardType;
52
+
53
+ DWORD mainThreadId;
54
+ DWORD keyboardThreadId;
55
+
56
+ BOOL clipboardSync;
57
+ wClipboard* clipboard;
58
+ UINT32 numServerFormats;
59
+ UINT32 requestedFormatId;
60
+ HANDLE clipboardRequestEvent;
61
+ CLIPRDR_FORMAT* serverFormats;
62
+ CliprdrClientContext* cliprdr;
63
+ UINT32 clipboardCapabilities;
64
+
65
+ rdpFile* connectionRdpFile;
66
+
67
+ // Keep track of window size and position, disable when in fullscreen mode.
68
+ BOOL disablewindowtracking;
69
+
70
+ // These variables are required for horizontal scrolling.
71
+ BOOL updating_scrollbars;
72
+ BOOL xScrollVisible;
73
+ int xMinScroll; // minimum horizontal scroll value
74
+ int xCurrentScroll; // current horizontal scroll value
75
+ int xMaxScroll; // maximum horizontal scroll value
76
+
77
+ // These variables are required for vertical scrolling.
78
+ BOOL yScrollVisible;
79
+ int yMinScroll; // minimum vertical scroll value
80
+ int yCurrentScroll; // current vertical scroll value
81
+ int yMaxScroll; // maximum vertical scroll value
82
+
83
+ CGEventFlags kbdFlags;
84
+ } mfContext;
85
+
86
+ #endif /* FREERDP_CLIENT_MAC_FREERDP_H */
local-test-freerdp-full-01/afc-freerdp/client/SDL/CMakeLists.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP SDL Client
3
+ #
4
+ # Copyright 2024 Armin Novak <anovak@thincast.com>
5
+ # Copyright 2024 Thincast Technologies GmbH
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ cmake_minimum_required(VERSION 3.13)
19
+
20
+ if(POLICY CMP0091)
21
+ cmake_policy(SET CMP0091 NEW)
22
+ endif()
23
+ if(NOT FREERDP_DEFAULT_PROJECT_VERSION)
24
+ set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0")
25
+ endif()
26
+
27
+ project(sdl-freerdp LANGUAGES CXX VERSION ${FREERDP_DEFAULT_PROJECT_VERSION})
28
+
29
+ message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
30
+
31
+ set(CMAKE_CXX_STANDARD 17)
32
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
33
+ set(CMAKE_CXX_EXTENSIONS ON)
34
+
35
+ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
36
+ include(CommonConfigOptions)
37
+
38
+ include(ConfigureFreeRDP)
39
+ include(CXXCompilerFlags)
40
+
41
+ option(WITH_DEBUG_SDL_EVENTS "[dangerous, not for release builds!] Debug SDL events" ${DEFAULT_DEBUG_OPTION})
42
+ option(WITH_DEBUG_SDL_KBD_EVENTS "[dangerous, not for release builds!] Debug SDL keyboard events"
43
+ ${DEFAULT_DEBUG_OPTION}
44
+ )
45
+ option(WITH_WIN_CONSOLE "Build ${PROJECT_NAME} with console support" ON)
46
+ option(WITH_SDL_LINK_SHARED "link SDL dynamic or static" ON)
47
+
48
+ if(WITH_WIN_CONSOLE)
49
+ set(WIN32_GUI_FLAG "TRUE")
50
+ else()
51
+ set(WIN32_GUI_FLAG "WIN32")
52
+ endif()
53
+
54
+ if(WITH_DEBUG_SDL_EVENTS)
55
+ add_compile_definitions(WITH_DEBUG_SDL_EVENTS)
56
+ endif()
57
+ if(WITH_DEBUG_SDL_KBD_EVENTS)
58
+ add_compile_definitions(WITH_DEBUG_SDL_KBD_EVENTS)
59
+ endif()
60
+
61
+ include(CMakeDependentOption)
62
+
63
+ # Require 2.0.20 for ubuntu 22.04.
64
+ # older versions do not have the SDL2::SDL2 et al targets
65
+ find_package(SDL2 2.0.20)
66
+ find_package(SDL3)
67
+
68
+ cmake_dependent_option(WITH_CLIENT_SDL_VERSIONED "append sdl version to client binaries" OFF WITH_CLIENT_SDL OFF)
69
+ cmake_dependent_option(
70
+ WITH_CLIENT_SDL2 "[experimental] build experimental SDL2 client" ${SDL2_FOUND} WITH_CLIENT_SDL OFF
71
+ )
72
+ cmake_dependent_option(
73
+ WITH_CLIENT_SDL3 "[experimental] build experimental SDL3 client" ${SDL3_FOUND} WITH_CLIENT_SDL OFF
74
+ )
75
+
76
+ if(WITH_CLIENT_SDL2 AND WITH_CLIENT_SDL3)
77
+ message("Building both, SDL2 and SDL3 clients, forcing WITH_CLIENT_SDL_VERSIONED=ON")
78
+ set(WITH_CLIENT_SDL_VERSIONED ON)
79
+ endif()
80
+
81
+ if(NOT SDL2_FOUND AND NOT SDL3_FOUND)
82
+ message(WARNING "No SDL library detected, giving up. Install SDL2 or SDL3 development package to fix")
83
+ endif()
84
+
85
+ if((WITH_CLIENT_SDL2 AND SDL2_FOUND) OR (WITH_CLIENT_SDL3 AND SDL3_FOUND))
86
+ add_subdirectory(common)
87
+ include_directories(common)
88
+ endif()
89
+
90
+ if(WITH_CLIENT_SDL2)
91
+ if(SDL2_FOUND)
92
+ add_subdirectory(SDL2)
93
+ else()
94
+ message(WARNING "SDL2 requested but not found, continuing build without SDL2 client")
95
+ endif()
96
+ endif()
97
+
98
+ if(WITH_CLIENT_SDL3)
99
+ if(SDL3_FOUND)
100
+ add_subdirectory(SDL3)
101
+ else()
102
+ message(WARNING "SDL3 requested but not found, continuing build without SDL3 client")
103
+ endif()
104
+ endif()
local-test-freerdp-full-01/afc-freerdp/client/Sample/CMakeLists.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP Sample UI cmake build script
3
+ #
4
+ # Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ cmake_minimum_required(VERSION 3.13)
18
+
19
+ if(POLICY CMP0091)
20
+ cmake_policy(SET CMP0091 NEW)
21
+ endif()
22
+ if(NOT FREERDP_DEFAULT_PROJECT_VERSION)
23
+ set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0")
24
+ endif()
25
+
26
+ project(sfreerdp LANGUAGES C VERSION ${FREERDP_DEFAULT_PROJECT_VERSION})
27
+
28
+ message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
29
+
30
+ set(CMAKE_C_STANDARD 11)
31
+ set(CMAKE_C_STANDARD_REQUIRED ON)
32
+ set(CMAKE_C_EXTENSIONS ON)
33
+
34
+ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
35
+ include(CommonConfigOptions)
36
+
37
+ include(ConfigureFreeRDP)
38
+
39
+ set(SRCS tf_channels.c tf_channels.h tf_freerdp.h tf_freerdp.c)
40
+
41
+ addtargetwithresourcefile(${PROJECT_NAME} TRUE "${PROJECT_VERSION}" SRCS)
42
+
43
+ set(LIBS freerdp-client freerdp winpr)
44
+ target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS})
45
+
46
+ set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/Sample")
47
+ install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
48
+ install_freerdp_desktop("${PROJECT_NAME}")
local-test-freerdp-full-01/afc-freerdp/client/Sample/ModuleOptions.cmake ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ set(FREERDP_CLIENT_NAME "sfreerdp")
2
+ set(FREERDP_CLIENT_PLATFORM "Sample")
3
+ set(FREERDP_CLIENT_VENDOR "FreeRDP")
local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_channels.c ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Sample Client Channels
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #include <freerdp/config.h>
22
+
23
+ #include <winpr/assert.h>
24
+ #include <freerdp/gdi/gfx.h>
25
+
26
+ #include <freerdp/client/rdpei.h>
27
+ #include <freerdp/client/rail.h>
28
+ #include <freerdp/client/cliprdr.h>
29
+ #include <freerdp/client/rdpgfx.h>
30
+ #include <freerdp/client/encomsp.h>
31
+
32
+ #include "tf_channels.h"
33
+ #include "tf_freerdp.h"
34
+
35
+ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e)
36
+ {
37
+ tfContext* tf = (tfContext*)context;
38
+
39
+ WINPR_ASSERT(tf);
40
+ WINPR_ASSERT(e);
41
+
42
+ if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
43
+ {
44
+ }
45
+ else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
46
+ {
47
+ CliprdrClientContext* clip = (CliprdrClientContext*)e->pInterface;
48
+ WINPR_ASSERT(clip);
49
+ clip->custom = context;
50
+ }
51
+ else
52
+ freerdp_client_OnChannelConnectedEventHandler(&tf->common, e);
53
+ }
54
+
55
+ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e)
56
+ {
57
+ tfContext* tf = (tfContext*)context;
58
+
59
+ WINPR_ASSERT(tf);
60
+ WINPR_ASSERT(e);
61
+
62
+ if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
63
+ {
64
+ }
65
+ else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
66
+ {
67
+ CliprdrClientContext* clip = (CliprdrClientContext*)e->pInterface;
68
+ WINPR_ASSERT(clip);
69
+ clip->custom = NULL;
70
+ }
71
+ else
72
+ freerdp_client_OnChannelDisconnectedEventHandler(&tf->common, e);
73
+ }
local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_channels.h ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Sample Client Channels
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #ifndef FREERDP_CLIENT_SAMPLE_CHANNELS_H
22
+ #define FREERDP_CLIENT_SAMPLE_CHANNELS_H
23
+
24
+ #include <freerdp/freerdp.h>
25
+ #include <freerdp/client/channels.h>
26
+
27
+ int tf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
28
+ int tf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
29
+
30
+ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e);
31
+ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e);
32
+
33
+ #endif /* FREERDP_CLIENT_SAMPLE_CHANNELS_H */
local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_freerdp.c ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * FreeRDP Test UI
4
+ *
5
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ * Copyright 2016,2018 Armin Novak <armin.novak@thincast.com>
7
+ * Copyright 2016,2018 Thincast Technologies GmbH
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+
22
+ #include <freerdp/config.h>
23
+
24
+ #include <errno.h>
25
+ #include <stdio.h>
26
+ #include <string.h>
27
+
28
+ #include <freerdp/freerdp.h>
29
+ #include <freerdp/constants.h>
30
+ #include <freerdp/gdi/gdi.h>
31
+ #include <freerdp/streamdump.h>
32
+ #include <freerdp/utils/signal.h>
33
+
34
+ #include <freerdp/client/file.h>
35
+ #include <freerdp/client/cmdline.h>
36
+ #include <freerdp/client/cliprdr.h>
37
+ #include <freerdp/client/channels.h>
38
+ #include <freerdp/channels/channels.h>
39
+
40
+ #include <winpr/crt.h>
41
+ #include <winpr/assert.h>
42
+ #include <winpr/synch.h>
43
+ #include <freerdp/log.h>
44
+
45
+ #include "tf_channels.h"
46
+ #include "tf_freerdp.h"
47
+
48
+ #define TAG CLIENT_TAG("sample")
49
+
50
+ /* This function is called whenever a new frame starts.
51
+ * It can be used to reset invalidated areas. */
52
+ static BOOL tf_begin_paint(rdpContext* context)
53
+ {
54
+ rdpGdi* gdi = NULL;
55
+
56
+ WINPR_ASSERT(context);
57
+
58
+ gdi = context->gdi;
59
+ WINPR_ASSERT(gdi);
60
+ WINPR_ASSERT(gdi->primary);
61
+ WINPR_ASSERT(gdi->primary->hdc);
62
+ WINPR_ASSERT(gdi->primary->hdc->hwnd);
63
+ WINPR_ASSERT(gdi->primary->hdc->hwnd->invalid);
64
+ gdi->primary->hdc->hwnd->invalid->null = TRUE;
65
+ return TRUE;
66
+ }
67
+
68
+ /* This function is called when the library completed composing a new
69
+ * frame. Read out the changed areas and blit them to your output device.
70
+ * The image buffer will have the format specified by gdi_init
71
+ */
72
+ static BOOL tf_end_paint(rdpContext* context)
73
+ {
74
+ rdpGdi* gdi = NULL;
75
+
76
+ WINPR_ASSERT(context);
77
+
78
+ gdi = context->gdi;
79
+ WINPR_ASSERT(gdi);
80
+ WINPR_ASSERT(gdi->primary);
81
+ WINPR_ASSERT(gdi->primary->hdc);
82
+ WINPR_ASSERT(gdi->primary->hdc->hwnd);
83
+ WINPR_ASSERT(gdi->primary->hdc->hwnd->invalid);
84
+
85
+ if (gdi->primary->hdc->hwnd->invalid->null)
86
+ return TRUE;
87
+
88
+ return TRUE;
89
+ }
90
+
91
+ static BOOL tf_desktop_resize(rdpContext* context)
92
+ {
93
+ rdpGdi* gdi = NULL;
94
+ rdpSettings* settings = NULL;
95
+
96
+ WINPR_ASSERT(context);
97
+
98
+ settings = context->settings;
99
+ WINPR_ASSERT(settings);
100
+
101
+ gdi = context->gdi;
102
+ return gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
103
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
104
+ }
105
+
106
+ /* This function is called to output a System BEEP */
107
+ static BOOL tf_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound)
108
+ {
109
+ /* TODO: Implement */
110
+ WINPR_UNUSED(context);
111
+ WINPR_UNUSED(play_sound);
112
+ return TRUE;
113
+ }
114
+
115
+ /* This function is called to update the keyboard indocator LED */
116
+ static BOOL tf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
117
+ {
118
+ /* TODO: Set local keyboard indicator LED status */
119
+ WINPR_UNUSED(context);
120
+ WINPR_UNUSED(led_flags);
121
+ return TRUE;
122
+ }
123
+
124
+ /* This function is called to set the IME state */
125
+ static BOOL tf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
126
+ UINT32 imeConvMode)
127
+ {
128
+ if (!context)
129
+ return FALSE;
130
+
131
+ WLog_WARN(TAG,
132
+ "KeyboardSetImeStatus(unitId=%04" PRIx16 ", imeState=%08" PRIx32
133
+ ", imeConvMode=%08" PRIx32 ") ignored",
134
+ imeId, imeState, imeConvMode);
135
+ return TRUE;
136
+ }
137
+
138
+ /* Called before a connection is established.
139
+ * Set all configuration options to support and load channels here. */
140
+ static BOOL tf_pre_connect(freerdp* instance)
141
+ {
142
+ rdpSettings* settings = NULL;
143
+
144
+ WINPR_ASSERT(instance);
145
+ WINPR_ASSERT(instance->context);
146
+
147
+ settings = instance->context->settings;
148
+ WINPR_ASSERT(settings);
149
+
150
+ /* If the callbacks provide the PEM all certificate options can be extracted, otherwise
151
+ * only the certificate fingerprint is available. */
152
+ if (!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, TRUE))
153
+ return FALSE;
154
+
155
+ /* Optional OS identifier sent to server */
156
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
157
+ return FALSE;
158
+ if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER))
159
+ return FALSE;
160
+ /* OrderSupport is initialized at this point.
161
+ * Only override it if you plan to implement custom order
162
+ * callbacks or deactivate certain features. */
163
+ /* Register the channel listeners.
164
+ * They are required to set up / tear down channels if they are loaded. */
165
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, tf_OnChannelConnectedEventHandler);
166
+ PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
167
+ tf_OnChannelDisconnectedEventHandler);
168
+
169
+ /* TODO: Any code your client requires */
170
+ return TRUE;
171
+ }
172
+
173
+ /* Called after a RDP connection was successfully established.
174
+ * Settings might have changed during negotiation of client / server feature
175
+ * support.
176
+ *
177
+ * Set up local framebuffers and paing callbacks.
178
+ * If required, register pointer callbacks to change the local mouse cursor
179
+ * when hovering over the RDP window
180
+ */
181
+ static BOOL tf_post_connect(freerdp* instance)
182
+ {
183
+ rdpContext* context = NULL;
184
+
185
+ if (!gdi_init(instance, PIXEL_FORMAT_XRGB32))
186
+ return FALSE;
187
+
188
+ context = instance->context;
189
+ WINPR_ASSERT(context);
190
+ WINPR_ASSERT(context->update);
191
+
192
+ /* With this setting we disable all graphics processing in the library.
193
+ *
194
+ * This allows low resource (client) protocol parsing.
195
+ */
196
+ if (!freerdp_settings_set_bool(context->settings, FreeRDP_DeactivateClientDecoding, TRUE))
197
+ return FALSE;
198
+
199
+ context->update->BeginPaint = tf_begin_paint;
200
+ context->update->EndPaint = tf_end_paint;
201
+ context->update->PlaySound = tf_play_sound;
202
+ context->update->DesktopResize = tf_desktop_resize;
203
+ context->update->SetKeyboardIndicators = tf_keyboard_set_indicators;
204
+ context->update->SetKeyboardImeStatus = tf_keyboard_set_ime_status;
205
+ return TRUE;
206
+ }
207
+
208
+ /* This function is called whether a session ends by failure or success.
209
+ * Clean up everything allocated by pre_connect and post_connect.
210
+ */
211
+ static void tf_post_disconnect(freerdp* instance)
212
+ {
213
+ tfContext* context = NULL;
214
+
215
+ if (!instance)
216
+ return;
217
+
218
+ if (!instance->context)
219
+ return;
220
+
221
+ context = (tfContext*)instance->context;
222
+ PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
223
+ tf_OnChannelConnectedEventHandler);
224
+ PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
225
+ tf_OnChannelDisconnectedEventHandler);
226
+ gdi_free(instance);
227
+ /* TODO : Clean up custom stuff */
228
+ WINPR_UNUSED(context);
229
+ }
230
+
231
+ /* RDP main loop.
232
+ * Connects RDP, loops while running and handles event and dispatch, cleans up
233
+ * after the connection ends. */
234
+ static DWORD WINAPI tf_client_thread_proc(LPVOID arg)
235
+ {
236
+ freerdp* instance = (freerdp*)arg;
237
+ DWORD nCount = 0;
238
+ DWORD status = 0;
239
+ DWORD result = 0;
240
+ HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 };
241
+ BOOL rc = freerdp_connect(instance);
242
+
243
+ WINPR_ASSERT(instance->context);
244
+ WINPR_ASSERT(instance->context->settings);
245
+ if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_AuthenticationOnly))
246
+ {
247
+ result = freerdp_get_last_error(instance->context);
248
+ freerdp_abort_connect_context(instance->context);
249
+ WLog_ERR(TAG, "Authentication only, exit status 0x%08" PRIx32 "", result);
250
+ goto disconnect;
251
+ }
252
+
253
+ if (!rc)
254
+ {
255
+ result = freerdp_get_last_error(instance->context);
256
+ WLog_ERR(TAG, "connection failure 0x%08" PRIx32, result);
257
+ return result;
258
+ }
259
+
260
+ while (!freerdp_shall_disconnect_context(instance->context))
261
+ {
262
+ nCount = freerdp_get_event_handles(instance->context, handles, ARRAYSIZE(handles));
263
+
264
+ if (nCount == 0)
265
+ {
266
+ WLog_ERR(TAG, "freerdp_get_event_handles failed");
267
+ break;
268
+ }
269
+
270
+ status = WaitForMultipleObjects(nCount, handles, FALSE, 100);
271
+
272
+ if (status == WAIT_FAILED)
273
+ {
274
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with %" PRIu32 "", status);
275
+ break;
276
+ }
277
+
278
+ if (!freerdp_check_event_handles(instance->context))
279
+ {
280
+ if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SUCCESS)
281
+ WLog_ERR(TAG, "Failed to check FreeRDP event handles");
282
+
283
+ break;
284
+ }
285
+ }
286
+
287
+ disconnect:
288
+ freerdp_disconnect(instance);
289
+ return result;
290
+ }
291
+
292
+ /* Optional global initializer.
293
+ * Here we just register a signal handler to print out stack traces
294
+ * if available. */
295
+ static BOOL tf_client_global_init(void)
296
+ {
297
+ if (freerdp_handle_signals() != 0)
298
+ return FALSE;
299
+
300
+ return TRUE;
301
+ }
302
+
303
+ /* Optional global tear down */
304
+ static void tf_client_global_uninit(void)
305
+ {
306
+ }
307
+
308
+ static int tf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
309
+ {
310
+ tfContext* tf = NULL;
311
+ const char* str_data = freerdp_get_logon_error_info_data(data);
312
+ const char* str_type = freerdp_get_logon_error_info_type(type);
313
+
314
+ if (!instance || !instance->context)
315
+ return -1;
316
+
317
+ tf = (tfContext*)instance->context;
318
+ WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
319
+ WINPR_UNUSED(tf);
320
+
321
+ return 1;
322
+ }
323
+
324
+ static BOOL tf_client_new(freerdp* instance, rdpContext* context)
325
+ {
326
+ tfContext* tf = (tfContext*)context;
327
+
328
+ if (!instance || !context)
329
+ return FALSE;
330
+
331
+ instance->PreConnect = tf_pre_connect;
332
+ instance->PostConnect = tf_post_connect;
333
+ instance->PostDisconnect = tf_post_disconnect;
334
+ instance->LogonErrorInfo = tf_logon_error_info;
335
+ /* TODO: Client display set up */
336
+ WINPR_UNUSED(tf);
337
+ return TRUE;
338
+ }
339
+
340
+ static void tf_client_free(freerdp* instance, rdpContext* context)
341
+ {
342
+ tfContext* tf = (tfContext*)instance->context;
343
+
344
+ if (!context)
345
+ return;
346
+
347
+ /* TODO: Client display tear down */
348
+ WINPR_UNUSED(tf);
349
+ }
350
+
351
+ static int tf_client_start(rdpContext* context)
352
+ {
353
+ /* TODO: Start client related stuff */
354
+ WINPR_UNUSED(context);
355
+ return 0;
356
+ }
357
+
358
+ static int tf_client_stop(rdpContext* context)
359
+ {
360
+ /* TODO: Stop client related stuff */
361
+ WINPR_UNUSED(context);
362
+ return 0;
363
+ }
364
+
365
+ static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
366
+ {
367
+ WINPR_ASSERT(pEntryPoints);
368
+
369
+ ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
370
+ pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION;
371
+ pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
372
+ pEntryPoints->GlobalInit = tf_client_global_init;
373
+ pEntryPoints->GlobalUninit = tf_client_global_uninit;
374
+ pEntryPoints->ContextSize = sizeof(tfContext);
375
+ pEntryPoints->ClientNew = tf_client_new;
376
+ pEntryPoints->ClientFree = tf_client_free;
377
+ pEntryPoints->ClientStart = tf_client_start;
378
+ pEntryPoints->ClientStop = tf_client_stop;
379
+ return 0;
380
+ }
381
+
382
+ int main(int argc, char* argv[])
383
+ {
384
+ int rc = -1;
385
+ RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 };
386
+
387
+ RdpClientEntry(&clientEntryPoints);
388
+ rdpContext* context = freerdp_client_context_new(&clientEntryPoints);
389
+
390
+ if (!context)
391
+ goto fail;
392
+
393
+ const int status =
394
+ freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
395
+ if (status)
396
+ {
397
+ rc = freerdp_client_settings_command_line_status_print(context->settings, status, argc,
398
+ argv);
399
+ goto fail;
400
+ }
401
+
402
+ if (!stream_dump_register_handlers(context, CONNECTION_STATE_MCS_CREATE_REQUEST, FALSE))
403
+ goto fail;
404
+
405
+ if (freerdp_client_start(context) != 0)
406
+ goto fail;
407
+
408
+ const DWORD res = tf_client_thread_proc(context->instance);
409
+ rc = (int)res;
410
+
411
+ if (freerdp_client_stop(context) != 0)
412
+ rc = -1;
413
+
414
+ fail:
415
+ freerdp_client_context_free(context);
416
+ return rc;
417
+ }
local-test-freerdp-full-01/afc-freerdp/client/Sample/tf_freerdp.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Sample Client
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #ifndef FREERDP_CLIENT_SAMPLE_H
22
+ #define FREERDP_CLIENT_SAMPLE_H
23
+
24
+ #include <freerdp/freerdp.h>
25
+ #include <freerdp/client/rdpei.h>
26
+ #include <freerdp/client/rail.h>
27
+ #include <freerdp/client/cliprdr.h>
28
+ #include <freerdp/client/rdpgfx.h>
29
+
30
+ typedef struct
31
+ {
32
+ rdpClientContext common;
33
+
34
+ /* Channels */
35
+ } tfContext;
36
+
37
+ #endif /* FREERDP_CLIENT_SAMPLE_H */
local-test-freerdp-full-01/afc-freerdp/client/Wayland/CMakeLists.txt ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP Wayland Client cmake build script
3
+ #
4
+ # Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
5
+ # Copyright 2015 David Fort <contact@hardening-consulting.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ set(MODULE_NAME "wlfreerdp")
20
+ set(MODULE_PREFIX "FREERDP_CLIENT_WAYLAND")
21
+
22
+ include_directories(SYSTEM ${WAYLAND_INCLUDE_DIR})
23
+
24
+ set(${MODULE_PREFIX}_SRCS
25
+ wlfreerdp.c
26
+ wlfreerdp.h
27
+ wlf_disp.c
28
+ wlf_disp.h
29
+ wlf_pointer.c
30
+ wlf_pointer.h
31
+ wlf_input.c
32
+ wlf_input.h
33
+ wlf_cliprdr.c
34
+ wlf_cliprdr.h
35
+ wlf_channels.c
36
+ wlf_channels.h
37
+ )
38
+
39
+ if(FREERDP_UNIFIED_BUILD)
40
+ include_directories(${PROJECT_SOURCE_DIR}/uwac/include)
41
+ include_directories(${PROJECT_BINARY_DIR}/uwac/include)
42
+ else()
43
+ find_package(uwac 0 REQUIRED)
44
+ include_directories(SYSTEM ${UWAC_INCLUDE_DIR})
45
+ endif()
46
+
47
+ list(APPEND ${MODULE_PREFIX}_LIBS freerdp-client freerdp uwac)
48
+
49
+ addtargetwithresourcefile(${MODULE_NAME} TRUE ${FREERDP_VERSION} ${MODULE_PREFIX}_SRCS)
50
+
51
+ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
52
+
53
+ install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
54
+
55
+ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Wayland")
56
+ generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}")
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_channels.c ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * X11 Client Channels
4
+ *
5
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #include <freerdp/config.h>
21
+
22
+ #include <freerdp/gdi/gfx.h>
23
+
24
+ #include <freerdp/gdi/video.h>
25
+
26
+ #include "wlf_channels.h"
27
+ #include "wlf_cliprdr.h"
28
+ #include "wlf_disp.h"
29
+ #include "wlfreerdp.h"
30
+
31
+ void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e)
32
+ {
33
+ wlfContext* wlf = (wlfContext*)context;
34
+
35
+ WINPR_ASSERT(wlf);
36
+ WINPR_ASSERT(e);
37
+
38
+ if (FALSE)
39
+ {
40
+ }
41
+ else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
42
+ {
43
+ }
44
+ else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
45
+ {
46
+ wlf_cliprdr_init(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
47
+ }
48
+ else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
49
+ {
50
+ wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface);
51
+ }
52
+ else
53
+ freerdp_client_OnChannelConnectedEventHandler(context, e);
54
+ }
55
+
56
+ void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e)
57
+ {
58
+ wlfContext* wlf = (wlfContext*)context;
59
+
60
+ WINPR_ASSERT(wlf);
61
+ WINPR_ASSERT(e);
62
+
63
+ if (FALSE)
64
+ {
65
+ }
66
+ else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
67
+ {
68
+ }
69
+ else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
70
+ {
71
+ wlf_cliprdr_uninit(wlf->clipboard, (CliprdrClientContext*)e->pInterface);
72
+ }
73
+ else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
74
+ {
75
+ wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface);
76
+ }
77
+ else
78
+ freerdp_client_OnChannelDisconnectedEventHandler(context, e);
79
+ }
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_channels.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * X11 Client Channels
4
+ *
5
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #ifndef FREERDP_CLIENT_WAYLAND_CHANNELS_H
21
+ #define FREERDP_CLIENT_WAYLAND_CHANNELS_H
22
+
23
+ #include <freerdp/freerdp.h>
24
+ #include <freerdp/client/channels.h>
25
+ #include <freerdp/client/rdpei.h>
26
+ #include <freerdp/client/rail.h>
27
+ #include <freerdp/client/cliprdr.h>
28
+ #include <freerdp/client/rdpgfx.h>
29
+ #include <freerdp/client/encomsp.h>
30
+
31
+ int wlf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
32
+ int wlf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
33
+
34
+ void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e);
35
+ void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e);
36
+
37
+ #endif /* FREERDP_CLIENT_WAYLAND_CHANNELS_H */
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_cliprdr.c ADDED
@@ -0,0 +1,1018 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Clipboard Redirection
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #include <freerdp/config.h>
22
+
23
+ #include <stdlib.h>
24
+
25
+ #include <winpr/crt.h>
26
+ #include <winpr/image.h>
27
+ #include <winpr/stream.h>
28
+ #include <winpr/clipboard.h>
29
+
30
+ #include <freerdp/log.h>
31
+ #include <freerdp/client/cliprdr.h>
32
+ #include <freerdp/channels/channels.h>
33
+ #include <freerdp/channels/cliprdr.h>
34
+
35
+ #include <freerdp/client/client_cliprdr_file.h>
36
+
37
+ #include "wlf_cliprdr.h"
38
+
39
+ #define TAG CLIENT_TAG("wayland.cliprdr")
40
+
41
+ #define mime_text_plain "text/plain"
42
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
43
+ static const char mime_text_utf8[] = mime_text_plain ";charset=utf-8";
44
+
45
+ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
46
+ static const char* mime_text[] = { mime_text_plain, mime_text_utf8, "UTF8_STRING",
47
+ "COMPOUND_TEXT", "TEXT", "STRING" };
48
+
49
+ static const char mime_png[] = "image/png";
50
+ static const char mime_webp[] = "image/webp";
51
+ static const char mime_jpg[] = "image/jpeg";
52
+ static const char mime_tiff[] = "image/tiff";
53
+ static const char mime_uri_list[] = "text/uri-list";
54
+ static const char mime_html[] = "text/html";
55
+
56
+ #define BMP_MIME_LIST "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-win-bitmap"
57
+ static const char* mime_bitmap[] = { BMP_MIME_LIST };
58
+ static const char* mime_image[] = { mime_png, mime_webp, mime_jpg, mime_tiff, BMP_MIME_LIST };
59
+
60
+ static const char mime_gnome_copied_files[] = "x-special/gnome-copied-files";
61
+ static const char mime_mate_copied_files[] = "x-special/mate-copied-files";
62
+
63
+ static const char type_FileGroupDescriptorW[] = "FileGroupDescriptorW";
64
+ static const char type_HtmlFormat[] = "HTML Format";
65
+
66
+ typedef struct
67
+ {
68
+ FILE* responseFile;
69
+ UINT32 responseFormat;
70
+ char* responseMime;
71
+ } wlf_request;
72
+
73
+ typedef struct
74
+ {
75
+ const FILE* responseFile;
76
+ UINT32 responseFormat;
77
+ const char* responseMime;
78
+ } wlf_const_request;
79
+
80
+ struct wlf_clipboard
81
+ {
82
+ wlfContext* wfc;
83
+ rdpChannels* channels;
84
+ CliprdrClientContext* context;
85
+ wLog* log;
86
+
87
+ UwacSeat* seat;
88
+ wClipboard* system;
89
+
90
+ size_t numClientFormats;
91
+ CLIPRDR_FORMAT* clientFormats;
92
+
93
+ size_t numServerFormats;
94
+ CLIPRDR_FORMAT* serverFormats;
95
+
96
+ BOOL sync;
97
+
98
+ CRITICAL_SECTION lock;
99
+ CliprdrFileContext* file;
100
+
101
+ wQueue* request_queue;
102
+ };
103
+
104
+ static void wlf_request_free(void* rq)
105
+ {
106
+ wlf_request* request = rq;
107
+ if (request)
108
+ {
109
+ free(request->responseMime);
110
+ if (request->responseFile)
111
+ (void)fclose(request->responseFile);
112
+ }
113
+ free(request);
114
+ }
115
+
116
+ static wlf_request* wlf_request_new(void)
117
+ {
118
+ return calloc(1, sizeof(wlf_request));
119
+ }
120
+
121
+ static void* wlf_request_clone(const void* oth)
122
+ {
123
+ const wlf_request* other = (const wlf_request*)oth;
124
+ wlf_request* copy = wlf_request_new();
125
+ if (!copy)
126
+ return NULL;
127
+ *copy = *other;
128
+ if (other->responseMime)
129
+ {
130
+ copy->responseMime = _strdup(other->responseMime);
131
+ if (!copy->responseMime)
132
+ goto fail;
133
+ }
134
+ return copy;
135
+ fail:
136
+ wlf_request_free(copy);
137
+ return NULL;
138
+ }
139
+
140
+ static BOOL wlf_mime_is_file(const char* mime)
141
+ {
142
+ if (strncmp(mime_uri_list, mime, sizeof(mime_uri_list)) == 0)
143
+ return TRUE;
144
+ if (strncmp(mime_gnome_copied_files, mime, sizeof(mime_gnome_copied_files)) == 0)
145
+ return TRUE;
146
+ if (strncmp(mime_mate_copied_files, mime, sizeof(mime_mate_copied_files)) == 0)
147
+ return TRUE;
148
+ return FALSE;
149
+ }
150
+
151
+ static BOOL wlf_mime_is_text(const char* mime)
152
+ {
153
+ for (size_t x = 0; x < ARRAYSIZE(mime_text); x++)
154
+ {
155
+ if (strcmp(mime, mime_text[x]) == 0)
156
+ return TRUE;
157
+ }
158
+
159
+ return FALSE;
160
+ }
161
+
162
+ static BOOL wlf_mime_is_image(const char* mime)
163
+ {
164
+ for (size_t x = 0; x < ARRAYSIZE(mime_image); x++)
165
+ {
166
+ if (strcmp(mime, mime_image[x]) == 0)
167
+ return TRUE;
168
+ }
169
+
170
+ return FALSE;
171
+ }
172
+
173
+ static BOOL wlf_mime_is_html(const char* mime)
174
+ {
175
+ if (strcmp(mime, mime_html) == 0)
176
+ return TRUE;
177
+
178
+ return FALSE;
179
+ }
180
+
181
+ static void wlf_cliprdr_free_server_formats(wfClipboard* clipboard)
182
+ {
183
+ if (clipboard && clipboard->serverFormats)
184
+ {
185
+ for (size_t j = 0; j < clipboard->numServerFormats; j++)
186
+ {
187
+ CLIPRDR_FORMAT* format = &clipboard->serverFormats[j];
188
+ free(format->formatName);
189
+ }
190
+
191
+ free(clipboard->serverFormats);
192
+ clipboard->serverFormats = NULL;
193
+ clipboard->numServerFormats = 0;
194
+ }
195
+
196
+ if (clipboard)
197
+ UwacClipboardOfferDestroy(clipboard->seat);
198
+ }
199
+
200
+ static void wlf_cliprdr_free_client_formats(wfClipboard* clipboard)
201
+ {
202
+ if (clipboard && clipboard->numClientFormats)
203
+ {
204
+ for (size_t j = 0; j < clipboard->numClientFormats; j++)
205
+ {
206
+ CLIPRDR_FORMAT* format = &clipboard->clientFormats[j];
207
+ free(format->formatName);
208
+ }
209
+
210
+ free(clipboard->clientFormats);
211
+ clipboard->clientFormats = NULL;
212
+ clipboard->numClientFormats = 0;
213
+ }
214
+
215
+ if (clipboard)
216
+ UwacClipboardOfferDestroy(clipboard->seat);
217
+ }
218
+
219
+ /**
220
+ * Function description
221
+ *
222
+ * @return 0 on success, otherwise a Win32 error code
223
+ */
224
+ static UINT wlf_cliprdr_send_client_format_list(wfClipboard* clipboard)
225
+ {
226
+ WINPR_ASSERT(clipboard);
227
+
228
+ const CLIPRDR_FORMAT_LIST formatList = { .common.msgFlags = 0,
229
+ .numFormats = (UINT32)clipboard->numClientFormats,
230
+ .formats = clipboard->clientFormats,
231
+ .common.msgType = CB_FORMAT_LIST };
232
+
233
+ cliprdr_file_context_clear(clipboard->file);
234
+
235
+ WLog_VRB(TAG, "-------------- client format list [%" PRIu32 "] ------------------",
236
+ formatList.numFormats);
237
+ for (UINT32 x = 0; x < formatList.numFormats; x++)
238
+ {
239
+ const CLIPRDR_FORMAT* format = &formatList.formats[x];
240
+ WLog_VRB(TAG, "client announces %" PRIu32 " [%s][%s]", format->formatId,
241
+ ClipboardGetFormatIdString(format->formatId), format->formatName);
242
+ }
243
+ WINPR_ASSERT(clipboard->context);
244
+ WINPR_ASSERT(clipboard->context->ClientFormatList);
245
+ return clipboard->context->ClientFormatList(clipboard->context, &formatList);
246
+ }
247
+
248
+ static void wfl_cliprdr_add_client_format_id(wfClipboard* clipboard, UINT32 formatId)
249
+ {
250
+ CLIPRDR_FORMAT* format = NULL;
251
+ const char* name = ClipboardGetFormatName(clipboard->system, formatId);
252
+
253
+ for (size_t x = 0; x < clipboard->numClientFormats; x++)
254
+ {
255
+ format = &clipboard->clientFormats[x];
256
+
257
+ if (format->formatId == formatId)
258
+ return;
259
+ }
260
+
261
+ format = realloc(clipboard->clientFormats,
262
+ (clipboard->numClientFormats + 1) * sizeof(CLIPRDR_FORMAT));
263
+
264
+ if (!format)
265
+ return;
266
+
267
+ clipboard->clientFormats = format;
268
+ format = &clipboard->clientFormats[clipboard->numClientFormats++];
269
+ format->formatId = formatId;
270
+ format->formatName = NULL;
271
+
272
+ if (name && (formatId >= CF_MAX))
273
+ format->formatName = _strdup(name);
274
+ }
275
+
276
+ static BOOL wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mime)
277
+ {
278
+ WINPR_ASSERT(mime);
279
+ ClipboardLock(clipboard->system);
280
+ if (wlf_mime_is_html(mime))
281
+ {
282
+ UINT32 formatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat);
283
+ wfl_cliprdr_add_client_format_id(clipboard, formatId);
284
+ }
285
+ else if (wlf_mime_is_text(mime))
286
+ {
287
+ wfl_cliprdr_add_client_format_id(clipboard, CF_TEXT);
288
+ wfl_cliprdr_add_client_format_id(clipboard, CF_OEMTEXT);
289
+ wfl_cliprdr_add_client_format_id(clipboard, CF_UNICODETEXT);
290
+ }
291
+ else if (wlf_mime_is_image(mime))
292
+ {
293
+ for (size_t x = 0; x < ARRAYSIZE(mime_image); x++)
294
+ {
295
+ const char* mime_bmp = mime_image[x];
296
+ UINT32 formatId = ClipboardGetFormatId(clipboard->system, mime_bmp);
297
+ if (formatId != 0)
298
+ wfl_cliprdr_add_client_format_id(clipboard, formatId);
299
+ }
300
+ wfl_cliprdr_add_client_format_id(clipboard, CF_DIB);
301
+ wfl_cliprdr_add_client_format_id(clipboard, CF_TIFF);
302
+ }
303
+ else if (wlf_mime_is_file(mime))
304
+ {
305
+ const UINT32 fileFormatId =
306
+ ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW);
307
+ wfl_cliprdr_add_client_format_id(clipboard, fileFormatId);
308
+ }
309
+
310
+ ClipboardUnlock(clipboard->system);
311
+ if (wlf_cliprdr_send_client_format_list(clipboard) != CHANNEL_RC_OK)
312
+ return FALSE;
313
+ return TRUE;
314
+ }
315
+
316
+ /**
317
+ * Function description
318
+ *
319
+ * @return 0 on success, otherwise a Win32 error code
320
+ */
321
+ static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_const_request* rq)
322
+ {
323
+ WINPR_ASSERT(rq);
324
+
325
+ CLIPRDR_FORMAT_DATA_REQUEST request = { .requestedFormatId = rq->responseFormat };
326
+
327
+ if (!Queue_Enqueue(clipboard->request_queue, rq))
328
+ return ERROR_INTERNAL_ERROR;
329
+
330
+ WINPR_ASSERT(clipboard);
331
+ WINPR_ASSERT(clipboard->context);
332
+ WINPR_ASSERT(clipboard->context->ClientFormatDataRequest);
333
+ return clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
334
+ }
335
+
336
+ /**
337
+ * Function description
338
+ *
339
+ * @return 0 on success, otherwise a Win32 error code
340
+ */
341
+ static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* data, size_t size)
342
+ {
343
+ CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
344
+
345
+ if (size > UINT32_MAX)
346
+ return ERROR_INVALID_PARAMETER;
347
+
348
+ response.common.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
349
+ response.common.dataLen = (UINT32)size;
350
+ response.requestedFormatData = data;
351
+
352
+ WINPR_ASSERT(clipboard);
353
+ WINPR_ASSERT(clipboard->context);
354
+ WINPR_ASSERT(clipboard->context->ClientFormatDataResponse);
355
+ return clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
356
+ }
357
+
358
+ BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event)
359
+ {
360
+ if (!clipboard || !event)
361
+ return FALSE;
362
+
363
+ if (!clipboard->context)
364
+ return TRUE;
365
+
366
+ switch (event->type)
367
+ {
368
+ case UWAC_EVENT_CLIPBOARD_AVAILABLE:
369
+ clipboard->seat = event->seat;
370
+ return TRUE;
371
+
372
+ case UWAC_EVENT_CLIPBOARD_OFFER:
373
+ WLog_Print(clipboard->log, WLOG_DEBUG, "client announces mime %s", event->mime);
374
+ return wlf_cliprdr_add_client_format(clipboard, event->mime);
375
+
376
+ case UWAC_EVENT_CLIPBOARD_SELECT:
377
+ WLog_Print(clipboard->log, WLOG_DEBUG, "client announces new data");
378
+ wlf_cliprdr_free_client_formats(clipboard);
379
+ return TRUE;
380
+
381
+ default:
382
+ return FALSE;
383
+ }
384
+ }
385
+
386
+ /**
387
+ * Function description
388
+ *
389
+ * @return 0 on success, otherwise a Win32 error code
390
+ */
391
+ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
392
+ {
393
+ WINPR_ASSERT(clipboard);
394
+
395
+ CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = {
396
+ .capabilitySetType = CB_CAPSTYPE_GENERAL,
397
+ .capabilitySetLength = 12,
398
+ .version = CB_CAPS_VERSION_2,
399
+ .generalFlags =
400
+ CB_USE_LONG_FORMAT_NAMES | cliprdr_file_context_current_flags(clipboard->file)
401
+ };
402
+ CLIPRDR_CAPABILITIES capabilities = { .cCapabilitiesSets = 1,
403
+ .capabilitySets =
404
+ (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet) };
405
+
406
+ WINPR_ASSERT(clipboard);
407
+ WINPR_ASSERT(clipboard->context);
408
+ WINPR_ASSERT(clipboard->context->ClientCapabilities);
409
+ return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
410
+ }
411
+
412
+ /**
413
+ * Function description
414
+ *
415
+ * @return 0 on success, otherwise a Win32 error code
416
+ */
417
+ static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard, BOOL status)
418
+ {
419
+ const CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse = {
420
+ .common.msgType = CB_FORMAT_LIST_RESPONSE,
421
+ .common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL,
422
+ .common.dataLen = 0
423
+ };
424
+ WINPR_ASSERT(clipboard);
425
+ WINPR_ASSERT(clipboard->context);
426
+ WINPR_ASSERT(clipboard->context->ClientFormatListResponse);
427
+ return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse);
428
+ }
429
+
430
+ /**
431
+ * Function description
432
+ *
433
+ * @return 0 on success, otherwise a Win32 error code
434
+ */
435
+ static UINT wlf_cliprdr_monitor_ready(CliprdrClientContext* context,
436
+ const CLIPRDR_MONITOR_READY* monitorReady)
437
+ {
438
+ UINT ret = 0;
439
+
440
+ WINPR_UNUSED(monitorReady);
441
+ WINPR_ASSERT(context);
442
+ WINPR_ASSERT(monitorReady);
443
+
444
+ wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom);
445
+ WINPR_ASSERT(clipboard);
446
+
447
+ if ((ret = wlf_cliprdr_send_client_capabilities(clipboard)) != CHANNEL_RC_OK)
448
+ return ret;
449
+
450
+ if ((ret = wlf_cliprdr_send_client_format_list(clipboard)) != CHANNEL_RC_OK)
451
+ return ret;
452
+
453
+ clipboard->sync = TRUE;
454
+ return CHANNEL_RC_OK;
455
+ }
456
+
457
+ /**
458
+ * Function description
459
+ *
460
+ * @return 0 on success, otherwise a Win32 error code
461
+ */
462
+ static UINT wlf_cliprdr_server_capabilities(CliprdrClientContext* context,
463
+ const CLIPRDR_CAPABILITIES* capabilities)
464
+ {
465
+ WINPR_ASSERT(context);
466
+ WINPR_ASSERT(capabilities);
467
+
468
+ const BYTE* capsPtr = (const BYTE*)capabilities->capabilitySets;
469
+ WINPR_ASSERT(capsPtr);
470
+
471
+ wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom);
472
+ WINPR_ASSERT(clipboard);
473
+
474
+ if (!cliprdr_file_context_remote_set_flags(clipboard->file, 0))
475
+ return ERROR_INTERNAL_ERROR;
476
+
477
+ for (UINT32 i = 0; i < capabilities->cCapabilitiesSets; i++)
478
+ {
479
+ const CLIPRDR_CAPABILITY_SET* caps = (const CLIPRDR_CAPABILITY_SET*)capsPtr;
480
+
481
+ if (caps->capabilitySetType == CB_CAPSTYPE_GENERAL)
482
+ {
483
+ const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps =
484
+ (const CLIPRDR_GENERAL_CAPABILITY_SET*)caps;
485
+
486
+ if (!cliprdr_file_context_remote_set_flags(clipboard->file, generalCaps->generalFlags))
487
+ return ERROR_INTERNAL_ERROR;
488
+ }
489
+
490
+ capsPtr += caps->capabilitySetLength;
491
+ }
492
+
493
+ return CHANNEL_RC_OK;
494
+ }
495
+
496
+ static UINT32 wlf_get_server_format_id(const wfClipboard* clipboard, const char* name)
497
+ {
498
+ WINPR_ASSERT(clipboard);
499
+ WINPR_ASSERT(name);
500
+
501
+ for (UINT32 x = 0; x < clipboard->numServerFormats; x++)
502
+ {
503
+ const CLIPRDR_FORMAT* format = &clipboard->serverFormats[x];
504
+ if (!format->formatName)
505
+ continue;
506
+ if (strcmp(name, format->formatName) == 0)
507
+ return format->formatId;
508
+ }
509
+ return 0;
510
+ }
511
+
512
+ static const char* wlf_get_server_format_name(const wfClipboard* clipboard, UINT32 formatId)
513
+ {
514
+ WINPR_ASSERT(clipboard);
515
+
516
+ for (UINT32 x = 0; x < clipboard->numServerFormats; x++)
517
+ {
518
+ const CLIPRDR_FORMAT* format = &clipboard->serverFormats[x];
519
+ if (format->formatId == formatId)
520
+ return format->formatName;
521
+ }
522
+ return NULL;
523
+ }
524
+
525
+ static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char* mime, int fd)
526
+ {
527
+ wfClipboard* clipboard = (wfClipboard*)context;
528
+ WINPR_UNUSED(seat);
529
+
530
+ EnterCriticalSection(&clipboard->lock);
531
+
532
+ wlf_const_request request = { 0 };
533
+ if (wlf_mime_is_html(mime))
534
+ {
535
+ request.responseMime = mime_html;
536
+ request.responseFormat = wlf_get_server_format_id(clipboard, type_HtmlFormat);
537
+ }
538
+ else if (wlf_mime_is_file(mime))
539
+ {
540
+ request.responseMime = mime;
541
+ request.responseFormat = wlf_get_server_format_id(clipboard, type_FileGroupDescriptorW);
542
+ }
543
+ else if (wlf_mime_is_text(mime))
544
+ {
545
+ request.responseMime = mime_text_plain;
546
+ request.responseFormat = CF_UNICODETEXT;
547
+ }
548
+ else if (wlf_mime_is_image(mime))
549
+ {
550
+ request.responseMime = mime;
551
+ if (strcmp(mime, mime_tiff) == 0)
552
+ request.responseFormat = CF_TIFF;
553
+ else
554
+ request.responseFormat = CF_DIB;
555
+ }
556
+
557
+ if (request.responseMime != NULL)
558
+ {
559
+ request.responseFile = fdopen(fd, "w");
560
+
561
+ if (request.responseFile)
562
+ wlf_cliprdr_send_data_request(clipboard, &request);
563
+ else
564
+ WLog_Print(clipboard->log, WLOG_ERROR,
565
+ "failed to open clipboard file descriptor for MIME %s",
566
+ request.responseMime);
567
+ }
568
+
569
+ LeaveCriticalSection(&clipboard->lock);
570
+ }
571
+
572
+ static void wlf_cliprdr_cancel_data(UwacSeat* seat, void* context)
573
+ {
574
+ wfClipboard* clipboard = (wfClipboard*)context;
575
+
576
+ WINPR_UNUSED(seat);
577
+ WINPR_ASSERT(clipboard);
578
+ cliprdr_file_context_clear(clipboard->file);
579
+ }
580
+
581
+ /**
582
+ * Called when the clipboard changes server side.
583
+ *
584
+ * Clear the local clipboard offer and replace it with a new one
585
+ * that announces the formats we get listed here.
586
+ *
587
+ * @return 0 on success, otherwise a Win32 error code
588
+ */
589
+ static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context,
590
+ const CLIPRDR_FORMAT_LIST* formatList)
591
+ {
592
+ BOOL html = FALSE;
593
+ BOOL text = FALSE;
594
+ BOOL image = FALSE;
595
+ BOOL file = FALSE;
596
+
597
+ if (!context || !context->custom)
598
+ return ERROR_INVALID_PARAMETER;
599
+
600
+ wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom);
601
+ WINPR_ASSERT(clipboard);
602
+
603
+ wlf_cliprdr_free_server_formats(clipboard);
604
+ cliprdr_file_context_clear(clipboard->file);
605
+
606
+ if (!(clipboard->serverFormats =
607
+ (CLIPRDR_FORMAT*)calloc(formatList->numFormats, sizeof(CLIPRDR_FORMAT))))
608
+ {
609
+ WLog_Print(clipboard->log, WLOG_ERROR,
610
+ "failed to allocate %" PRIuz " CLIPRDR_FORMAT structs",
611
+ clipboard->numServerFormats);
612
+ return CHANNEL_RC_NO_MEMORY;
613
+ }
614
+
615
+ clipboard->numServerFormats = formatList->numFormats;
616
+
617
+ if (!clipboard->seat)
618
+ {
619
+ WLog_Print(clipboard->log, WLOG_ERROR,
620
+ "clipboard->seat=NULL, check your client implementation");
621
+ return ERROR_INTERNAL_ERROR;
622
+ }
623
+
624
+ for (UINT32 i = 0; i < formatList->numFormats; i++)
625
+ {
626
+ const CLIPRDR_FORMAT* format = &formatList->formats[i];
627
+ CLIPRDR_FORMAT* srvFormat = &clipboard->serverFormats[i];
628
+ srvFormat->formatId = format->formatId;
629
+
630
+ if (format->formatName)
631
+ {
632
+ srvFormat->formatName = _strdup(format->formatName);
633
+
634
+ if (!srvFormat->formatName)
635
+ {
636
+ wlf_cliprdr_free_server_formats(clipboard);
637
+ return CHANNEL_RC_NO_MEMORY;
638
+ }
639
+ }
640
+
641
+ if (format->formatName)
642
+ {
643
+ if (strcmp(format->formatName, type_HtmlFormat) == 0)
644
+ {
645
+ text = TRUE;
646
+ html = TRUE;
647
+ }
648
+ else if (strcmp(format->formatName, type_FileGroupDescriptorW) == 0)
649
+ {
650
+ file = TRUE;
651
+ text = TRUE;
652
+ }
653
+ }
654
+ else
655
+ {
656
+ switch (format->formatId)
657
+ {
658
+ case CF_TEXT:
659
+ case CF_OEMTEXT:
660
+ case CF_UNICODETEXT:
661
+ text = TRUE;
662
+ break;
663
+
664
+ case CF_DIB:
665
+ image = TRUE;
666
+ break;
667
+
668
+ default:
669
+ break;
670
+ }
671
+ }
672
+ }
673
+
674
+ if (html)
675
+ {
676
+ UwacClipboardOfferCreate(clipboard->seat, mime_html);
677
+ }
678
+
679
+ if (file && cliprdr_file_context_has_local_support(clipboard->file))
680
+ {
681
+ UwacClipboardOfferCreate(clipboard->seat, mime_uri_list);
682
+ UwacClipboardOfferCreate(clipboard->seat, mime_gnome_copied_files);
683
+ UwacClipboardOfferCreate(clipboard->seat, mime_mate_copied_files);
684
+ }
685
+
686
+ if (text)
687
+ {
688
+ for (size_t x = 0; x < ARRAYSIZE(mime_text); x++)
689
+ UwacClipboardOfferCreate(clipboard->seat, mime_text[x]);
690
+ }
691
+
692
+ if (image)
693
+ {
694
+ for (size_t x = 0; x < ARRAYSIZE(mime_image); x++)
695
+ UwacClipboardOfferCreate(clipboard->seat, mime_image[x]);
696
+ }
697
+
698
+ UwacClipboardOfferAnnounce(clipboard->seat, clipboard, wlf_cliprdr_transfer_data,
699
+ wlf_cliprdr_cancel_data);
700
+ return wlf_cliprdr_send_client_format_list_response(clipboard, TRUE);
701
+ }
702
+
703
+ /**
704
+ * Function description
705
+ *
706
+ * @return 0 on success, otherwise a Win32 error code
707
+ */
708
+ static UINT
709
+ wlf_cliprdr_server_format_list_response(CliprdrClientContext* context,
710
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
711
+ {
712
+ WINPR_ASSERT(context);
713
+ WINPR_ASSERT(formatListResponse);
714
+
715
+ if (formatListResponse->common.msgFlags & CB_RESPONSE_FAIL)
716
+ WLog_WARN(TAG, "format list update failed");
717
+ return CHANNEL_RC_OK;
718
+ }
719
+
720
+ /**
721
+ * Function description
722
+ *
723
+ * @return 0 on success, otherwise a Win32 error code
724
+ */
725
+ static UINT
726
+ wlf_cliprdr_server_format_data_request(CliprdrClientContext* context,
727
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
728
+ {
729
+ UINT rc = CHANNEL_RC_OK;
730
+ char* data = NULL;
731
+ size_t size = 0;
732
+ const char* mime = NULL;
733
+ UINT32 formatId = 0;
734
+ UINT32 localFormatId = 0;
735
+ wfClipboard* clipboard = 0;
736
+
737
+ UINT32 dsize = 0;
738
+ BYTE* ddata = NULL;
739
+
740
+ WINPR_ASSERT(context);
741
+ WINPR_ASSERT(formatDataRequest);
742
+
743
+ localFormatId = formatId = formatDataRequest->requestedFormatId;
744
+ clipboard = cliprdr_file_context_get_context(context->custom);
745
+ WINPR_ASSERT(clipboard);
746
+
747
+ ClipboardLock(clipboard->system);
748
+ const UINT32 fileFormatId = ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW);
749
+ const UINT32 htmlFormatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat);
750
+
751
+ switch (formatId)
752
+ {
753
+ case CF_TEXT:
754
+ case CF_OEMTEXT:
755
+ case CF_UNICODETEXT:
756
+ localFormatId = ClipboardGetFormatId(clipboard->system, mime_text_plain);
757
+ mime = mime_text_utf8;
758
+ break;
759
+
760
+ case CF_DIB:
761
+ case CF_DIBV5:
762
+ mime = mime_bitmap[0];
763
+ break;
764
+
765
+ case CF_TIFF:
766
+ mime = mime_tiff;
767
+ break;
768
+
769
+ default:
770
+ if (formatId == fileFormatId)
771
+ {
772
+ localFormatId = ClipboardGetFormatId(clipboard->system, mime_uri_list);
773
+ mime = mime_uri_list;
774
+ }
775
+ else if (formatId == htmlFormatId)
776
+ {
777
+ localFormatId = ClipboardGetFormatId(clipboard->system, mime_html);
778
+ mime = mime_html;
779
+ }
780
+ else
781
+ goto fail;
782
+ break;
783
+ }
784
+
785
+ data = UwacClipboardDataGet(clipboard->seat, mime, &size);
786
+
787
+ if (!data || (size > UINT32_MAX))
788
+ goto fail;
789
+
790
+ if (fileFormatId == formatId)
791
+ {
792
+ if (!cliprdr_file_context_update_client_data(clipboard->file, data, size))
793
+ goto fail;
794
+ }
795
+
796
+ const BOOL res = ClipboardSetData(clipboard->system, localFormatId, data, (UINT32)size);
797
+ free(data);
798
+
799
+ UINT32 len = 0;
800
+ data = NULL;
801
+ if (res)
802
+ data = ClipboardGetData(clipboard->system, formatId, &len);
803
+
804
+ if (!res || !data)
805
+ goto fail;
806
+
807
+ if (fileFormatId == formatId)
808
+ {
809
+ const UINT32 flags = cliprdr_file_context_remote_get_flags(clipboard->file);
810
+ const UINT32 error = cliprdr_serialize_file_list_ex(
811
+ flags, (const FILEDESCRIPTORW*)data, len / sizeof(FILEDESCRIPTORW), &ddata, &dsize);
812
+ if (error)
813
+ goto fail;
814
+ }
815
+ fail:
816
+ ClipboardUnlock(clipboard->system);
817
+ rc = wlf_cliprdr_send_data_response(clipboard, ddata, dsize);
818
+ free(data);
819
+ return rc;
820
+ }
821
+
822
+ /**
823
+ * Function description
824
+ *
825
+ * @return 0 on success, otherwise a Win32 error code
826
+ */
827
+ static UINT
828
+ wlf_cliprdr_server_format_data_response(CliprdrClientContext* context,
829
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
830
+ {
831
+ UINT rc = ERROR_INTERNAL_ERROR;
832
+
833
+ WINPR_ASSERT(context);
834
+ WINPR_ASSERT(formatDataResponse);
835
+
836
+ const UINT32 size = formatDataResponse->common.dataLen;
837
+ const BYTE* data = formatDataResponse->requestedFormatData;
838
+
839
+ wfClipboard* clipboard = cliprdr_file_context_get_context(context->custom);
840
+ WINPR_ASSERT(clipboard);
841
+
842
+ wlf_request* request = Queue_Dequeue(clipboard->request_queue);
843
+ if (!request)
844
+ goto fail;
845
+
846
+ rc = CHANNEL_RC_OK;
847
+ if (formatDataResponse->common.msgFlags & CB_RESPONSE_FAIL)
848
+ {
849
+ WLog_WARN(TAG, "clipboard data request for format %" PRIu32 " [%s], mime %s failed",
850
+ request->responseFormat, ClipboardGetFormatIdString(request->responseFormat),
851
+ request->responseMime);
852
+ goto fail;
853
+ }
854
+ rc = ERROR_INTERNAL_ERROR;
855
+
856
+ ClipboardLock(clipboard->system);
857
+ EnterCriticalSection(&clipboard->lock);
858
+
859
+ BYTE* cdata = NULL;
860
+ UINT32 srcFormatId = 0;
861
+ UINT32 dstFormatId = 0;
862
+ switch (request->responseFormat)
863
+ {
864
+ case CF_TEXT:
865
+ case CF_OEMTEXT:
866
+ case CF_UNICODETEXT:
867
+ srcFormatId = request->responseFormat;
868
+ dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime);
869
+ break;
870
+
871
+ case CF_DIB:
872
+ case CF_DIBV5:
873
+ srcFormatId = request->responseFormat;
874
+ dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime);
875
+ break;
876
+
877
+ default:
878
+ {
879
+ const char* name = wlf_get_server_format_name(clipboard, request->responseFormat);
880
+ if (name)
881
+ {
882
+ if (strcmp(type_FileGroupDescriptorW, name) == 0)
883
+ {
884
+ srcFormatId =
885
+ ClipboardGetFormatId(clipboard->system, type_FileGroupDescriptorW);
886
+ dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime);
887
+
888
+ if (!cliprdr_file_context_update_server_data(clipboard->file, clipboard->system,
889
+ data, size))
890
+ goto unlock;
891
+ }
892
+ else if (strcmp(type_HtmlFormat, name) == 0)
893
+ {
894
+ srcFormatId = ClipboardGetFormatId(clipboard->system, type_HtmlFormat);
895
+ dstFormatId = ClipboardGetFormatId(clipboard->system, request->responseMime);
896
+ }
897
+ }
898
+ }
899
+ break;
900
+ }
901
+
902
+ UINT32 len = 0;
903
+
904
+ const BOOL sres = ClipboardSetData(clipboard->system, srcFormatId, data, size);
905
+ if (sres)
906
+ cdata = ClipboardGetData(clipboard->system, dstFormatId, &len);
907
+
908
+ if (!sres || !cdata)
909
+ goto unlock;
910
+
911
+ if (request->responseFile)
912
+ {
913
+ const size_t res = fwrite(cdata, 1, len, request->responseFile);
914
+ if (res == len)
915
+ rc = CHANNEL_RC_OK;
916
+ }
917
+ else
918
+ rc = CHANNEL_RC_OK;
919
+
920
+ unlock:
921
+ free(cdata);
922
+ ClipboardUnlock(clipboard->system);
923
+ LeaveCriticalSection(&clipboard->lock);
924
+ fail:
925
+ wlf_request_free(request);
926
+ return rc;
927
+ }
928
+
929
+ wfClipboard* wlf_clipboard_new(wlfContext* wfc)
930
+ {
931
+ rdpChannels* channels = NULL;
932
+ wfClipboard* clipboard = NULL;
933
+
934
+ WINPR_ASSERT(wfc);
935
+
936
+ clipboard = (wfClipboard*)calloc(1, sizeof(wfClipboard));
937
+
938
+ if (!clipboard)
939
+ goto fail;
940
+
941
+ InitializeCriticalSection(&clipboard->lock);
942
+ clipboard->wfc = wfc;
943
+ channels = wfc->common.context.channels;
944
+ clipboard->log = WLog_Get(TAG);
945
+ clipboard->channels = channels;
946
+ clipboard->system = ClipboardCreate();
947
+ if (!clipboard->system)
948
+ goto fail;
949
+
950
+ clipboard->file = cliprdr_file_context_new(clipboard);
951
+ if (!clipboard->file)
952
+ goto fail;
953
+
954
+ if (!cliprdr_file_context_set_locally_available(clipboard->file, TRUE))
955
+ goto fail;
956
+
957
+ clipboard->request_queue = Queue_New(TRUE, -1, -1);
958
+ if (!clipboard->request_queue)
959
+ goto fail;
960
+
961
+ wObject* obj = Queue_Object(clipboard->request_queue);
962
+ WINPR_ASSERT(obj);
963
+ obj->fnObjectFree = wlf_request_free;
964
+ obj->fnObjectNew = wlf_request_clone;
965
+
966
+ return clipboard;
967
+
968
+ fail:
969
+ wlf_clipboard_free(clipboard);
970
+ return NULL;
971
+ }
972
+
973
+ void wlf_clipboard_free(wfClipboard* clipboard)
974
+ {
975
+ if (!clipboard)
976
+ return;
977
+
978
+ cliprdr_file_context_free(clipboard->file);
979
+
980
+ wlf_cliprdr_free_server_formats(clipboard);
981
+ wlf_cliprdr_free_client_formats(clipboard);
982
+ ClipboardDestroy(clipboard->system);
983
+
984
+ EnterCriticalSection(&clipboard->lock);
985
+
986
+ Queue_Free(clipboard->request_queue);
987
+ LeaveCriticalSection(&clipboard->lock);
988
+ DeleteCriticalSection(&clipboard->lock);
989
+ free(clipboard);
990
+ }
991
+
992
+ BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr)
993
+ {
994
+ WINPR_ASSERT(clipboard);
995
+ WINPR_ASSERT(cliprdr);
996
+
997
+ clipboard->context = cliprdr;
998
+ cliprdr->MonitorReady = wlf_cliprdr_monitor_ready;
999
+ cliprdr->ServerCapabilities = wlf_cliprdr_server_capabilities;
1000
+ cliprdr->ServerFormatList = wlf_cliprdr_server_format_list;
1001
+ cliprdr->ServerFormatListResponse = wlf_cliprdr_server_format_list_response;
1002
+ cliprdr->ServerFormatDataRequest = wlf_cliprdr_server_format_data_request;
1003
+ cliprdr->ServerFormatDataResponse = wlf_cliprdr_server_format_data_response;
1004
+
1005
+ return cliprdr_file_context_init(clipboard->file, cliprdr);
1006
+ }
1007
+
1008
+ BOOL wlf_cliprdr_uninit(wfClipboard* clipboard, CliprdrClientContext* cliprdr)
1009
+ {
1010
+ WINPR_ASSERT(clipboard);
1011
+ if (!cliprdr_file_context_uninit(clipboard->file, cliprdr))
1012
+ return FALSE;
1013
+
1014
+ if (cliprdr)
1015
+ cliprdr->custom = NULL;
1016
+
1017
+ return TRUE;
1018
+ }
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_cliprdr.h ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Clipboard Redirection
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #ifndef FREERDP_CLIENT_WAYLAND_CLIPRDR_H
22
+ #define FREERDP_CLIENT_WAYLAND_CLIPRDR_H
23
+
24
+ #include "wlfreerdp.h"
25
+
26
+ #include <freerdp/client/cliprdr.h>
27
+
28
+ wfClipboard* wlf_clipboard_new(wlfContext* wfc);
29
+ void wlf_clipboard_free(wfClipboard* clipboard);
30
+
31
+ BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr);
32
+ BOOL wlf_cliprdr_uninit(wfClipboard* clipboard, CliprdrClientContext* cliprdr);
33
+
34
+ BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event);
35
+
36
+ #endif /* FREERDP_CLIENT_WAYLAND_CLIPRDR_H */
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_disp.c ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Display Control Channel
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #include <winpr/sysinfo.h>
22
+ #include <winpr/cast.h>
23
+
24
+ #include "wlf_disp.h"
25
+
26
+ #define TAG CLIENT_TAG("wayland.disp")
27
+
28
+ #define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */
29
+
30
+ struct s_wlfDispContext
31
+ {
32
+ wlfContext* wlc;
33
+ DispClientContext* disp;
34
+ BOOL haveXRandr;
35
+ int eventBase, errorBase;
36
+ int lastSentWidth, lastSentHeight;
37
+ UINT64 lastSentDate;
38
+ int targetWidth, targetHeight;
39
+ BOOL activated;
40
+ BOOL waitingResize;
41
+ BOOL fullscreen;
42
+ UINT16 lastSentDesktopOrientation;
43
+ UINT32 lastSentDesktopScaleFactor;
44
+ UINT32 lastSentDeviceScaleFactor;
45
+ };
46
+
47
+ static UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors,
48
+ size_t nmonitors);
49
+
50
+ static BOOL wlf_disp_settings_changed(wlfDispContext* wlfDisp)
51
+ {
52
+ rdpSettings* settings = NULL;
53
+
54
+ WINPR_ASSERT(wlfDisp);
55
+ WINPR_ASSERT(wlfDisp->wlc);
56
+
57
+ settings = wlfDisp->wlc->common.context.settings;
58
+ WINPR_ASSERT(settings);
59
+
60
+ if (wlfDisp->lastSentWidth != wlfDisp->targetWidth)
61
+ return TRUE;
62
+
63
+ if (wlfDisp->lastSentHeight != wlfDisp->targetHeight)
64
+ return TRUE;
65
+
66
+ if (wlfDisp->lastSentDesktopOrientation !=
67
+ freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation))
68
+ return TRUE;
69
+
70
+ if (wlfDisp->lastSentDesktopScaleFactor !=
71
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor))
72
+ return TRUE;
73
+
74
+ if (wlfDisp->lastSentDeviceScaleFactor !=
75
+ freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor))
76
+ return TRUE;
77
+
78
+ if (wlfDisp->fullscreen != wlfDisp->wlc->fullscreen)
79
+ return TRUE;
80
+
81
+ return FALSE;
82
+ }
83
+
84
+ static BOOL wlf_update_last_sent(wlfDispContext* wlfDisp)
85
+ {
86
+ rdpSettings* settings = NULL;
87
+
88
+ WINPR_ASSERT(wlfDisp);
89
+ WINPR_ASSERT(wlfDisp->wlc);
90
+
91
+ settings = wlfDisp->wlc->common.context.settings;
92
+ WINPR_ASSERT(settings);
93
+
94
+ wlfDisp->lastSentWidth = wlfDisp->targetWidth;
95
+ wlfDisp->lastSentHeight = wlfDisp->targetHeight;
96
+ wlfDisp->lastSentDesktopOrientation =
97
+ freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
98
+ wlfDisp->lastSentDesktopScaleFactor =
99
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
100
+ wlfDisp->lastSentDeviceScaleFactor =
101
+ freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
102
+ wlfDisp->fullscreen = wlfDisp->wlc->fullscreen;
103
+ return TRUE;
104
+ }
105
+
106
+ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp)
107
+ {
108
+ DISPLAY_CONTROL_MONITOR_LAYOUT layout;
109
+ wlfContext* wlc = NULL;
110
+ rdpSettings* settings = NULL;
111
+
112
+ if (!wlfDisp || !wlfDisp->wlc)
113
+ return FALSE;
114
+
115
+ wlc = wlfDisp->wlc;
116
+ settings = wlc->common.context.settings;
117
+
118
+ if (!settings)
119
+ return FALSE;
120
+
121
+ if (!wlfDisp->activated || !wlfDisp->disp)
122
+ return TRUE;
123
+
124
+ if (GetTickCount64() - wlfDisp->lastSentDate < RESIZE_MIN_DELAY)
125
+ return TRUE;
126
+
127
+ wlfDisp->lastSentDate = GetTickCount64();
128
+
129
+ if (!wlf_disp_settings_changed(wlfDisp))
130
+ return TRUE;
131
+
132
+ /* TODO: Multimonitor support for wayland
133
+ if (wlc->fullscreen && (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount > 0))
134
+ {
135
+ if (wlf_disp_sendLayout(wlfDisp->disp, setings->MonitorDefArray,
136
+ freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) !=
137
+ CHANNEL_RC_OK) return FALSE;
138
+ }
139
+ else
140
+ */
141
+ {
142
+ wlfDisp->waitingResize = TRUE;
143
+ layout.Flags = DISPLAY_CONTROL_MONITOR_PRIMARY;
144
+ layout.Top = layout.Left = 0;
145
+ layout.Width = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth);
146
+ layout.Height = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight);
147
+ layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
148
+ layout.DesktopScaleFactor =
149
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
150
+ layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
151
+ layout.PhysicalWidth = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetWidth);
152
+ layout.PhysicalHeight = WINPR_ASSERTING_INT_CAST(uint32_t, wlfDisp->targetHeight);
153
+
154
+ if (IFCALLRESULT(CHANNEL_RC_OK, wlfDisp->disp->SendMonitorLayout, wlfDisp->disp, 1,
155
+ &layout) != CHANNEL_RC_OK)
156
+ return FALSE;
157
+ }
158
+ return wlf_update_last_sent(wlfDisp);
159
+ }
160
+
161
+ static BOOL wlf_disp_set_window_resizable(wlfDispContext* wlfDisp)
162
+ {
163
+ #if 0 // TODO
164
+ #endif
165
+ return TRUE;
166
+ }
167
+
168
+ static BOOL wlf_disp_check_context(void* context, wlfContext** ppwlc, wlfDispContext** ppwlfDisp,
169
+ rdpSettings** ppSettings)
170
+ {
171
+ wlfContext* wlc = NULL;
172
+
173
+ if (!context)
174
+ return FALSE;
175
+
176
+ wlc = (wlfContext*)context;
177
+
178
+ if (!(wlc->disp))
179
+ return FALSE;
180
+
181
+ if (!wlc->common.context.settings)
182
+ return FALSE;
183
+
184
+ *ppwlc = wlc;
185
+ *ppwlfDisp = wlc->disp;
186
+ *ppSettings = wlc->common.context.settings;
187
+ return TRUE;
188
+ }
189
+
190
+ static void wlf_disp_OnActivated(void* context, const ActivatedEventArgs* e)
191
+ {
192
+ wlfContext* wlc = NULL;
193
+ wlfDispContext* wlfDisp = NULL;
194
+ rdpSettings* settings = NULL;
195
+
196
+ if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
197
+ return;
198
+
199
+ wlfDisp->waitingResize = FALSE;
200
+
201
+ if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
202
+ {
203
+ wlf_disp_set_window_resizable(wlfDisp);
204
+
205
+ if (e->firstActivation)
206
+ return;
207
+
208
+ wlf_disp_sendResize(wlfDisp);
209
+ }
210
+ }
211
+
212
+ static void wlf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs* e)
213
+ {
214
+ wlfContext* wlc = NULL;
215
+ wlfDispContext* wlfDisp = NULL;
216
+ rdpSettings* settings = NULL;
217
+
218
+ WINPR_UNUSED(e);
219
+ if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
220
+ return;
221
+
222
+ wlfDisp->waitingResize = FALSE;
223
+
224
+ if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
225
+ {
226
+ wlf_disp_set_window_resizable(wlfDisp);
227
+ wlf_disp_sendResize(wlfDisp);
228
+ }
229
+ }
230
+
231
+ static void wlf_disp_OnTimer(void* context, const TimerEventArgs* e)
232
+ {
233
+ wlfContext* wlc = NULL;
234
+ wlfDispContext* wlfDisp = NULL;
235
+ rdpSettings* settings = NULL;
236
+
237
+ WINPR_UNUSED(e);
238
+ if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
239
+ return;
240
+
241
+ if (!wlfDisp->activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
242
+ return;
243
+
244
+ wlf_disp_sendResize(wlfDisp);
245
+ }
246
+
247
+ wlfDispContext* wlf_disp_new(wlfContext* wlc)
248
+ {
249
+ wlfDispContext* ret = NULL;
250
+ wPubSub* pubSub = NULL;
251
+ rdpSettings* settings = NULL;
252
+
253
+ if (!wlc || !wlc->common.context.settings || !wlc->common.context.pubSub)
254
+ return NULL;
255
+
256
+ settings = wlc->common.context.settings;
257
+ pubSub = wlc->common.context.pubSub;
258
+ ret = calloc(1, sizeof(wlfDispContext));
259
+
260
+ if (!ret)
261
+ return NULL;
262
+
263
+ ret->wlc = wlc;
264
+ ret->lastSentWidth = ret->targetWidth =
265
+ WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
266
+ ret->lastSentHeight = ret->targetHeight =
267
+ WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
268
+ PubSub_SubscribeActivated(pubSub, wlf_disp_OnActivated);
269
+ PubSub_SubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset);
270
+ PubSub_SubscribeTimer(pubSub, wlf_disp_OnTimer);
271
+ return ret;
272
+ }
273
+
274
+ void wlf_disp_free(wlfDispContext* disp)
275
+ {
276
+ if (!disp)
277
+ return;
278
+
279
+ if (disp->wlc)
280
+ {
281
+ wPubSub* pubSub = disp->wlc->common.context.pubSub;
282
+ PubSub_UnsubscribeActivated(pubSub, wlf_disp_OnActivated);
283
+ PubSub_UnsubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset);
284
+ PubSub_UnsubscribeTimer(pubSub, wlf_disp_OnTimer);
285
+ }
286
+
287
+ free(disp);
288
+ }
289
+
290
+ UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, size_t nmonitors)
291
+ {
292
+ UINT ret = CHANNEL_RC_OK;
293
+ DISPLAY_CONTROL_MONITOR_LAYOUT* layouts = NULL;
294
+ wlfDispContext* wlfDisp = NULL;
295
+ rdpSettings* settings = NULL;
296
+
297
+ WINPR_ASSERT(disp);
298
+ WINPR_ASSERT(monitors);
299
+ WINPR_ASSERT(nmonitors > 0);
300
+ WINPR_ASSERT(nmonitors <= UINT32_MAX);
301
+
302
+ wlfDisp = (wlfDispContext*)disp->custom;
303
+ WINPR_ASSERT(wlfDisp);
304
+ WINPR_ASSERT(wlfDisp->wlc);
305
+
306
+ settings = wlfDisp->wlc->common.context.settings;
307
+ WINPR_ASSERT(settings);
308
+
309
+ layouts = calloc(nmonitors, sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
310
+
311
+ if (!layouts)
312
+ return CHANNEL_RC_NO_MEMORY;
313
+
314
+ for (size_t i = 0; i < nmonitors; i++)
315
+ {
316
+ const rdpMonitor* monitor = &monitors[i];
317
+ DISPLAY_CONTROL_MONITOR_LAYOUT* layout = &layouts[i];
318
+
319
+ layout->Flags = (monitor->is_primary ? DISPLAY_CONTROL_MONITOR_PRIMARY : 0);
320
+ layout->Left = monitor->x;
321
+ layout->Top = monitor->y;
322
+ layout->Width = WINPR_ASSERTING_INT_CAST(UINT32, monitor->width);
323
+ layout->Height = WINPR_ASSERTING_INT_CAST(UINT32, monitor->height);
324
+ layout->Orientation = ORIENTATION_LANDSCAPE;
325
+ layout->PhysicalWidth = monitor->attributes.physicalWidth;
326
+ layout->PhysicalHeight = monitor->attributes.physicalHeight;
327
+
328
+ switch (monitor->attributes.orientation)
329
+ {
330
+ case 90:
331
+ layout->Orientation = ORIENTATION_PORTRAIT;
332
+ break;
333
+
334
+ case 180:
335
+ layout->Orientation = ORIENTATION_LANDSCAPE_FLIPPED;
336
+ break;
337
+
338
+ case 270:
339
+ layout->Orientation = ORIENTATION_PORTRAIT_FLIPPED;
340
+ break;
341
+
342
+ case 0:
343
+ default:
344
+ /* MS-RDPEDISP - 2.2.2.2.1:
345
+ * Orientation (4 bytes): A 32-bit unsigned integer that specifies the
346
+ * orientation of the monitor in degrees. Valid values are 0, 90, 180
347
+ * or 270
348
+ *
349
+ * So we default to ORIENTATION_LANDSCAPE
350
+ */
351
+ layout->Orientation = ORIENTATION_LANDSCAPE;
352
+ break;
353
+ }
354
+
355
+ layout->DesktopScaleFactor =
356
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
357
+ layout->DeviceScaleFactor =
358
+ freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
359
+ }
360
+
361
+ ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, (UINT32)nmonitors, layouts);
362
+ free(layouts);
363
+ return ret;
364
+ }
365
+
366
+ BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height)
367
+ {
368
+ if (!disp)
369
+ return FALSE;
370
+
371
+ disp->targetWidth = width;
372
+ disp->targetHeight = height;
373
+ return wlf_disp_sendResize(disp);
374
+ }
375
+
376
+ static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors,
377
+ UINT32 maxMonitorAreaFactorA, UINT32 maxMonitorAreaFactorB)
378
+ {
379
+ /* we're called only if dynamic resolution update is activated */
380
+ wlfDispContext* wlfDisp = NULL;
381
+ rdpSettings* settings = NULL;
382
+
383
+ WINPR_ASSERT(disp);
384
+
385
+ wlfDisp = (wlfDispContext*)disp->custom;
386
+ WINPR_ASSERT(wlfDisp);
387
+ WINPR_ASSERT(wlfDisp->wlc);
388
+
389
+ settings = wlfDisp->wlc->common.context.settings;
390
+ WINPR_ASSERT(settings);
391
+
392
+ WLog_DBG(TAG,
393
+ "DisplayControlCapsPdu: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32
394
+ " MaxMonitorAreaFactorB: %" PRIu32 "",
395
+ maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
396
+ wlfDisp->activated = TRUE;
397
+
398
+ if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
399
+ return CHANNEL_RC_OK;
400
+
401
+ WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable");
402
+ return wlf_disp_set_window_resizable(wlfDisp) ? CHANNEL_RC_OK : CHANNEL_RC_NO_MEMORY;
403
+ }
404
+
405
+ BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp)
406
+ {
407
+ rdpSettings* settings = NULL;
408
+
409
+ if (!wlfDisp || !wlfDisp->wlc || !disp)
410
+ return FALSE;
411
+
412
+ settings = wlfDisp->wlc->common.context.settings;
413
+
414
+ if (!settings)
415
+ return FALSE;
416
+
417
+ wlfDisp->disp = disp;
418
+ disp->custom = (void*)wlfDisp;
419
+
420
+ if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
421
+ {
422
+ disp->DisplayControlCaps = wlf_DisplayControlCaps;
423
+ }
424
+
425
+ return TRUE;
426
+ }
427
+
428
+ BOOL wlf_disp_uninit(wlfDispContext* wlfDisp, DispClientContext* disp)
429
+ {
430
+ if (!wlfDisp || !disp)
431
+ return FALSE;
432
+
433
+ wlfDisp->disp = NULL;
434
+ return TRUE;
435
+ }
436
+
437
+ int wlf_list_monitors(wlfContext* wlc)
438
+ {
439
+ uint32_t nmonitors = UwacDisplayGetNbOutputs(wlc->display);
440
+
441
+ for (uint32_t i = 0; i < nmonitors; i++)
442
+ {
443
+ const UwacOutput* monitor =
444
+ UwacDisplayGetOutput(wlc->display, WINPR_ASSERTING_INT_CAST(int, i));
445
+ UwacSize resolution;
446
+ UwacPosition pos;
447
+
448
+ if (!monitor)
449
+ continue;
450
+ UwacOutputGetPosition(monitor, &pos);
451
+ UwacOutputGetResolution(monitor, &resolution);
452
+
453
+ printf(" %s [%u] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, resolution.width,
454
+ resolution.height, pos.x, pos.y);
455
+ }
456
+
457
+ return 0;
458
+ }
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_disp.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Display Control Channel
4
+ *
5
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2018 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+ #ifndef FREERDP_CLIENT_WAYLAND_DISP_H
21
+ #define FREERDP_CLIENT_WAYLAND_DISP_H
22
+
23
+ #include <freerdp/types.h>
24
+ #include <freerdp/client/disp.h>
25
+
26
+ #include "wlfreerdp.h"
27
+
28
+ FREERDP_API BOOL wlf_disp_init(wlfDispContext* xfDisp, DispClientContext* disp);
29
+ FREERDP_API BOOL wlf_disp_uninit(wlfDispContext* xfDisp, DispClientContext* disp);
30
+
31
+ wlfDispContext* wlf_disp_new(wlfContext* wlc);
32
+ void wlf_disp_free(wlfDispContext* disp);
33
+ BOOL wlf_disp_handle_configure(wlfDispContext* disp, int32_t width, int32_t height);
34
+ void wlf_disp_resized(wlfDispContext* disp);
35
+
36
+ int wlf_list_monitors(wlfContext* wlc);
37
+
38
+ #endif /* FREERDP_CLIENT_WAYLAND_DISP_H */
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_input.c ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Input
4
+ *
5
+ * Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
6
+ * Copyright 2015 David Fort <contact@hardening-consulting.com>
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #include <stdlib.h>
22
+ #include <float.h>
23
+
24
+ #include <linux/input.h>
25
+
26
+ #include <winpr/assert.h>
27
+ #include <winpr/cast.h>
28
+
29
+ #include <freerdp/config.h>
30
+ #include <freerdp/locale/keyboard.h>
31
+ #if defined(CHANNEL_RDPEI_CLIENT)
32
+ #include <freerdp/client/rdpei.h>
33
+ #endif
34
+ #include <uwac/uwac.h>
35
+
36
+ #include "wlfreerdp.h"
37
+ #include "wlf_input.h"
38
+
39
+ static BOOL scale_signed_coordinates(rdpContext* context, int32_t* x, int32_t* y,
40
+ BOOL fromLocalToRDP)
41
+ {
42
+ BOOL rc = 0;
43
+ UINT32 ux = 0;
44
+ UINT32 uy = 0;
45
+ WINPR_ASSERT(context);
46
+ WINPR_ASSERT(x);
47
+ WINPR_ASSERT(y);
48
+ WINPR_ASSERT(*x >= 0);
49
+ WINPR_ASSERT(*y >= 0);
50
+
51
+ ux = (UINT32)*x;
52
+ uy = (UINT32)*y;
53
+ rc = wlf_scale_coordinates(context, &ux, &uy, fromLocalToRDP);
54
+ WINPR_ASSERT(ux < INT32_MAX);
55
+ WINPR_ASSERT(uy < INT32_MAX);
56
+ *x = (int32_t)ux;
57
+ *y = (int32_t)uy;
58
+ return rc;
59
+ }
60
+
61
+ BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev)
62
+ {
63
+ uint32_t x = 0;
64
+ uint32_t y = 0;
65
+ rdpClientContext* cctx = NULL;
66
+
67
+ if (!instance || !ev)
68
+ return FALSE;
69
+
70
+ x = ev->x;
71
+ y = ev->y;
72
+
73
+ if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
74
+ return FALSE;
75
+
76
+ cctx = (rdpClientContext*)instance->context;
77
+ return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE,
78
+ WINPR_ASSERTING_INT_CAST(int, x),
79
+ WINPR_ASSERTING_INT_CAST(int, y));
80
+ }
81
+
82
+ BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev)
83
+ {
84
+ rdpClientContext* cctx = NULL;
85
+
86
+ if (!instance || !ev)
87
+ return FALSE;
88
+
89
+ cctx = (rdpClientContext*)instance->context;
90
+ WINPR_ASSERT(cctx);
91
+
92
+ uint32_t x = ev->x;
93
+ uint32_t y = ev->y;
94
+
95
+ if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
96
+ return FALSE;
97
+
98
+ return freerdp_client_send_button_event(cctx, FALSE, PTR_FLAGS_MOVE,
99
+ WINPR_ASSERTING_INT_CAST(int32_t, x),
100
+ WINPR_ASSERTING_INT_CAST(int32_t, y));
101
+ }
102
+
103
+ BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev)
104
+ {
105
+ rdpClientContext* cctx = NULL;
106
+ UINT16 flags = 0;
107
+ UINT16 xflags = 0;
108
+
109
+ if (!instance || !ev)
110
+ return FALSE;
111
+
112
+ cctx = (rdpClientContext*)instance->context;
113
+ WINPR_ASSERT(cctx);
114
+
115
+ uint32_t x = ev->x;
116
+ uint32_t y = ev->y;
117
+
118
+ if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
119
+ return FALSE;
120
+
121
+ if (ev->state == WL_POINTER_BUTTON_STATE_PRESSED)
122
+ {
123
+ flags |= PTR_FLAGS_DOWN;
124
+ xflags |= PTR_XFLAGS_DOWN;
125
+ }
126
+
127
+ switch (ev->button)
128
+ {
129
+ case BTN_LEFT:
130
+ flags |= PTR_FLAGS_BUTTON1;
131
+ break;
132
+
133
+ case BTN_RIGHT:
134
+ flags |= PTR_FLAGS_BUTTON2;
135
+ break;
136
+
137
+ case BTN_MIDDLE:
138
+ flags |= PTR_FLAGS_BUTTON3;
139
+ break;
140
+
141
+ case BTN_SIDE:
142
+ xflags |= PTR_XFLAGS_BUTTON1;
143
+ break;
144
+
145
+ case BTN_EXTRA:
146
+ xflags |= PTR_XFLAGS_BUTTON2;
147
+ break;
148
+
149
+ default:
150
+ return TRUE;
151
+ }
152
+
153
+ const INT32 cx = WINPR_ASSERTING_INT_CAST(int32_t, x);
154
+ const INT32 cy = WINPR_ASSERTING_INT_CAST(int32_t, y);
155
+
156
+ if ((flags & ~PTR_FLAGS_DOWN) != 0)
157
+ return freerdp_client_send_button_event(cctx, FALSE, flags, cx, cy);
158
+
159
+ if ((xflags & ~PTR_XFLAGS_DOWN) != 0)
160
+ return freerdp_client_send_extended_button_event(cctx, FALSE, xflags, cx, cy);
161
+
162
+ return FALSE;
163
+ }
164
+
165
+ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
166
+ {
167
+ wlfContext* context = NULL;
168
+ if (!instance || !instance->context || !ev)
169
+ return FALSE;
170
+
171
+ context = (wlfContext*)instance->context;
172
+ return ArrayList_Append(context->events, ev);
173
+ }
174
+
175
+ BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev)
176
+ {
177
+ wlfContext* context = NULL;
178
+ if (!instance || !instance->context || !ev)
179
+ return FALSE;
180
+
181
+ context = (wlfContext*)instance->context;
182
+ return ArrayList_Append(context->events, ev);
183
+ }
184
+
185
+ static BOOL wlf_handle_wheel(freerdp* instance, uint32_t x, uint32_t y, uint32_t axis,
186
+ int32_t value)
187
+ {
188
+ rdpClientContext* cctx = NULL;
189
+ UINT16 flags = 0;
190
+ int32_t direction = 0;
191
+ uint32_t avalue = (uint32_t)abs(value);
192
+
193
+ WINPR_ASSERT(instance);
194
+
195
+ cctx = (rdpClientContext*)instance->context;
196
+ WINPR_ASSERT(cctx);
197
+
198
+ if (!wlf_scale_coordinates(instance->context, &x, &y, TRUE))
199
+ return FALSE;
200
+
201
+ direction = value;
202
+ switch (axis)
203
+ {
204
+ case WL_POINTER_AXIS_VERTICAL_SCROLL:
205
+ flags |= PTR_FLAGS_WHEEL;
206
+ if (direction > 0)
207
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE;
208
+ break;
209
+
210
+ case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
211
+ flags |= PTR_FLAGS_HWHEEL;
212
+ if (direction < 0)
213
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE;
214
+ break;
215
+
216
+ default:
217
+ return FALSE;
218
+ }
219
+
220
+ /* Wheel rotation steps:
221
+ *
222
+ * positive: 0 ... 0xFF -> slow ... fast
223
+ * negative: 0 ... 0xFF -> fast ... slow
224
+ */
225
+
226
+ while (avalue > 0)
227
+ {
228
+ const UINT16 cval = (avalue > 0xFF) ? 0xFF : (UINT16)avalue;
229
+ UINT16 cflags = flags | cval;
230
+ /* Convert negative values to 9bit twos complement */
231
+ if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
232
+ cflags = (flags & 0xFF00) | (0x100 - cval);
233
+ if (!freerdp_client_send_wheel_event(cctx, cflags))
234
+ return FALSE;
235
+
236
+ avalue -= cval;
237
+ }
238
+ return TRUE;
239
+ }
240
+
241
+ BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev)
242
+ {
243
+ BOOL success = TRUE;
244
+ BOOL handle = FALSE;
245
+ wlfContext* context = NULL;
246
+ enum wl_pointer_axis_source source = WL_POINTER_AXIS_SOURCE_CONTINUOUS;
247
+
248
+ if (!instance || !ev || !instance->context)
249
+ return FALSE;
250
+
251
+ context = (wlfContext*)instance->context;
252
+
253
+ for (size_t x = 0; x < ArrayList_Count(context->events); x++)
254
+ {
255
+ UwacEvent* cev = ArrayList_GetItem(context->events, x);
256
+ if (!cev)
257
+ continue;
258
+ if (cev->type == UWAC_EVENT_POINTER_SOURCE)
259
+ {
260
+ handle = TRUE;
261
+ source = cev->mouse_source.axis_source;
262
+ }
263
+ }
264
+
265
+ /* We need source events to determine how to interpret the data */
266
+ if (handle)
267
+ {
268
+ for (size_t x = 0; x < ArrayList_Count(context->events); x++)
269
+ {
270
+ UwacEvent* cev = ArrayList_GetItem(context->events, x);
271
+ if (!cev)
272
+ continue;
273
+
274
+ switch (source)
275
+ {
276
+ /* If we have a mouse wheel, just use discrete data */
277
+ case WL_POINTER_AXIS_SOURCE_WHEEL:
278
+ #if defined(WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION)
279
+ case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
280
+ #endif
281
+ if (cev->type == UWAC_EVENT_POINTER_AXIS_DISCRETE)
282
+ {
283
+ /* Get the number of steps, multiply by default step width of 120 */
284
+ int32_t val = cev->mouse_axis.value * 0x78;
285
+ /* No wheel event received, success! */
286
+ if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y,
287
+ cev->mouse_axis.axis, val))
288
+ success = FALSE;
289
+ }
290
+ break;
291
+ /* If we have a touch pad we get actual data, scale */
292
+ case WL_POINTER_AXIS_SOURCE_FINGER:
293
+ case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
294
+ if (cev->type == UWAC_EVENT_POINTER_AXIS)
295
+ {
296
+ double dval = wl_fixed_to_double(cev->mouse_axis.value);
297
+ int32_t val = (int32_t)(dval * 0x78 / 10.0);
298
+ if (!wlf_handle_wheel(instance, cev->mouse_axis.x, cev->mouse_axis.y,
299
+ cev->mouse_axis.axis, val))
300
+ success = FALSE;
301
+ }
302
+ break;
303
+ default:
304
+ break;
305
+ }
306
+ }
307
+ }
308
+ ArrayList_Clear(context->events);
309
+ return success;
310
+ }
311
+
312
+ BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev)
313
+ {
314
+ wlfContext* context = NULL;
315
+ if (!instance || !instance->context || !ev)
316
+ return FALSE;
317
+
318
+ context = (wlfContext*)instance->context;
319
+ return ArrayList_Append(context->events, ev);
320
+ }
321
+
322
+ BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev)
323
+ {
324
+ if (!instance || !ev)
325
+ return FALSE;
326
+
327
+ WINPR_ASSERT(instance->context);
328
+ wlfContext* ctx = (wlfContext*)instance->context;
329
+ if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard) &&
330
+ ev->raw_key == KEY_RIGHTCTRL)
331
+ wlf_handle_ungrab_key(instance, ev);
332
+
333
+ rdpInput* input = instance->context->input;
334
+
335
+ const DWORD vc = GetVirtualKeyCodeFromKeycode(ev->raw_key, WINPR_KEYCODE_TYPE_EVDEV);
336
+ const DWORD sc = GetVirtualScanCodeFromVirtualKeyCode(vc, WINPR_KBD_TYPE_IBM_ENHANCED);
337
+ const DWORD rdp_scancode = freerdp_keyboard_remap_key(ctx->remap_table, sc);
338
+
339
+ if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
340
+ return TRUE;
341
+
342
+ return freerdp_input_send_keyboard_event_ex(input, ev->pressed, ev->repeated, rdp_scancode);
343
+ }
344
+
345
+ BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev)
346
+ {
347
+ wlfContext* context = NULL;
348
+ if (!instance || !instance->context || !ev)
349
+ return FALSE;
350
+
351
+ context = (wlfContext*)instance->context;
352
+
353
+ return UwacSeatInhibitShortcuts(context->seat, false) == UWAC_SUCCESS;
354
+ }
355
+
356
+ BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev)
357
+ {
358
+ if (!instance || !ev)
359
+ return FALSE;
360
+
361
+ ((wlfContext*)instance->context)->focusing = TRUE;
362
+ return TRUE;
363
+ }
364
+
365
+ BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev)
366
+ {
367
+ rdpInput* input = NULL;
368
+ UINT16 syncFlags = 0;
369
+ wlfContext* wlf = NULL;
370
+
371
+ if (!instance || !ev)
372
+ return FALSE;
373
+
374
+ wlf = (wlfContext*)instance->context;
375
+ WINPR_ASSERT(wlf);
376
+
377
+ input = instance->context->input;
378
+ WINPR_ASSERT(input);
379
+
380
+ syncFlags = 0;
381
+
382
+ if (ev->modifiers & UWAC_MOD_CAPS_MASK)
383
+ syncFlags |= KBD_SYNC_CAPS_LOCK;
384
+ if (ev->modifiers & UWAC_MOD_NUM_MASK)
385
+ syncFlags |= KBD_SYNC_NUM_LOCK;
386
+
387
+ if (!wlf->focusing)
388
+ return TRUE;
389
+
390
+ ((wlfContext*)instance->context)->focusing = FALSE;
391
+
392
+ return freerdp_input_send_focus_in_event(input, syncFlags) &&
393
+ freerdp_client_send_button_event(&wlf->common, FALSE, PTR_FLAGS_MOVE, 0, 0);
394
+ }
395
+
396
+ BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev)
397
+ {
398
+ int32_t x = 0;
399
+ int32_t y = 0;
400
+
401
+ WINPR_ASSERT(instance);
402
+ WINPR_ASSERT(ev);
403
+
404
+ wlfContext* wlf = (wlfContext*)instance->context;
405
+ WINPR_ASSERT(wlf);
406
+
407
+ x = ev->x;
408
+ y = ev->y;
409
+
410
+ if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
411
+ return FALSE;
412
+
413
+ return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_UP, ev->id, 0, x, y);
414
+ }
415
+
416
+ BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev)
417
+ {
418
+ int32_t x = 0;
419
+ int32_t y = 0;
420
+
421
+ WINPR_ASSERT(instance);
422
+ WINPR_ASSERT(ev);
423
+
424
+ wlfContext* wlf = (wlfContext*)instance->context;
425
+ WINPR_ASSERT(wlf);
426
+
427
+ x = ev->x;
428
+ y = ev->y;
429
+
430
+ if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
431
+ return FALSE;
432
+
433
+ return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_DOWN, ev->id, 0, x, y);
434
+ }
435
+
436
+ BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev)
437
+ {
438
+ int32_t x = 0;
439
+ int32_t y = 0;
440
+
441
+ WINPR_ASSERT(instance);
442
+ WINPR_ASSERT(ev);
443
+
444
+ wlfContext* wlf = (wlfContext*)instance->context;
445
+ WINPR_ASSERT(wlf);
446
+
447
+ x = ev->x;
448
+ y = ev->y;
449
+
450
+ if (!scale_signed_coordinates(instance->context, &x, &y, TRUE))
451
+ return FALSE;
452
+
453
+ return freerdp_client_handle_touch(&wlf->common, FREERDP_TOUCH_MOTION, 0,
454
+ WINPR_ASSERTING_INT_CAST(uint32_t, ev->id), x, y);
455
+ }
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_input.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Input
4
+ *
5
+ * Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
6
+ * Copyright 2015 David Fort <contact@hardening-consulting.com>
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #ifndef FREERDP_CLIENT_WAYLAND_INPUT_H
22
+ #define FREERDP_CLIENT_WAYLAND_INPUT_H
23
+
24
+ #include <freerdp/freerdp.h>
25
+ #include <freerdp/gdi/gdi.h>
26
+ #include <freerdp/gdi/gfx.h>
27
+ #include <uwac/uwac.h>
28
+
29
+ BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev);
30
+ BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev);
31
+ BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev);
32
+ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev);
33
+ BOOL wlf_handle_pointer_axis_discrete(freerdp* instance, const UwacPointerAxisEvent* ev);
34
+ BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev);
35
+ BOOL wlf_handle_pointer_source(freerdp* instance, const UwacPointerSourceEvent* ev);
36
+ BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev);
37
+ BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev);
38
+ BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev);
39
+
40
+ BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev);
41
+ BOOL wlf_handle_ungrab_key(freerdp* instance, const UwacKeyEvent* ev);
42
+ BOOL wlf_keyboard_enter(freerdp* instance, const UwacKeyboardEnterLeaveEvent* ev);
43
+ BOOL wlf_keyboard_modifiers(freerdp* instance, const UwacKeyboardModifiersEvent* ev);
44
+
45
+ #endif /* FREERDP_CLIENT_WAYLAND_INPUT_H */
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_pointer.c ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Mouse Pointer
4
+ *
5
+ * Copyright 2019 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2019 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #include <freerdp/config.h>
22
+
23
+ #include "wlf_pointer.h"
24
+ #include "wlfreerdp.h"
25
+
26
+ #define TAG CLIENT_TAG("wayland.pointer")
27
+
28
+ typedef struct
29
+ {
30
+ rdpPointer pointer;
31
+ size_t size;
32
+ void* data;
33
+ } wlfPointer;
34
+
35
+ static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer)
36
+ {
37
+ wlfPointer* ptr = (wlfPointer*)pointer;
38
+
39
+ if (!ptr)
40
+ return FALSE;
41
+
42
+ ptr->size = 4ULL * pointer->width * pointer->height;
43
+ ptr->data = winpr_aligned_malloc(ptr->size, 16);
44
+
45
+ if (!ptr->data)
46
+ return FALSE;
47
+
48
+ if (!freerdp_image_copy_from_pointer_data(
49
+ ptr->data, PIXEL_FORMAT_BGRA32, 0, 0, 0, pointer->width, pointer->height,
50
+ pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
51
+ pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
52
+ {
53
+ winpr_aligned_free(ptr->data);
54
+ return FALSE;
55
+ }
56
+
57
+ return TRUE;
58
+ }
59
+
60
+ static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
61
+ {
62
+ wlfPointer* ptr = (wlfPointer*)pointer;
63
+ WINPR_UNUSED(context);
64
+
65
+ if (ptr)
66
+ winpr_aligned_free(ptr->data);
67
+ }
68
+
69
+ static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
70
+ {
71
+ wlfContext* wlf = (wlfContext*)context;
72
+ wlfPointer* ptr = (wlfPointer*)pointer;
73
+ void* data = NULL;
74
+ UINT32 w = 0;
75
+ UINT32 h = 0;
76
+ UINT32 x = 0;
77
+ UINT32 y = 0;
78
+ size_t size = 0;
79
+ UwacReturnCode rc = UWAC_ERROR_INTERNAL;
80
+ BOOL res = FALSE;
81
+ RECTANGLE_16 area;
82
+
83
+ if (!wlf || !wlf->seat)
84
+ return FALSE;
85
+
86
+ x = pointer->xPos;
87
+ y = pointer->yPos;
88
+ w = pointer->width;
89
+ h = pointer->height;
90
+
91
+ if (!wlf_scale_coordinates(context, &x, &y, FALSE) ||
92
+ !wlf_scale_coordinates(context, &w, &h, FALSE))
93
+ return FALSE;
94
+
95
+ size = 4ULL * w * h;
96
+ data = malloc(size);
97
+
98
+ if (!data)
99
+ return FALSE;
100
+
101
+ area.top = 0;
102
+ area.left = 0;
103
+ area.right = (UINT16)pointer->width;
104
+ area.bottom = (UINT16)pointer->height;
105
+
106
+ if (!wlf_copy_image(ptr->data, 4ULL * pointer->width, pointer->width, pointer->height, data,
107
+ 4ULL * w, w, h, &area,
108
+ freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)))
109
+ goto fail;
110
+
111
+ rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y);
112
+
113
+ if (rc == UWAC_SUCCESS)
114
+ res = TRUE;
115
+
116
+ fail:
117
+ free(data);
118
+ return res;
119
+ }
120
+
121
+ static BOOL wlf_Pointer_SetNull(rdpContext* context)
122
+ {
123
+ wlfContext* wlf = (wlfContext*)context;
124
+
125
+ if (!wlf || !wlf->seat)
126
+ return FALSE;
127
+
128
+ if (UwacSeatSetMouseCursor(wlf->seat, NULL, 0, 0, 0, 0, 0) != UWAC_SUCCESS)
129
+ return FALSE;
130
+
131
+ return TRUE;
132
+ }
133
+
134
+ static BOOL wlf_Pointer_SetDefault(rdpContext* context)
135
+ {
136
+ wlfContext* wlf = (wlfContext*)context;
137
+
138
+ if (!wlf || !wlf->seat)
139
+ return FALSE;
140
+
141
+ if (UwacSeatSetMouseCursor(wlf->seat, NULL, 1, 0, 0, 0, 0) != UWAC_SUCCESS)
142
+ return FALSE;
143
+
144
+ return TRUE;
145
+ }
146
+
147
+ static BOOL wlf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
148
+ {
149
+ // TODO
150
+ WLog_WARN(TAG, "not implemented");
151
+ return TRUE;
152
+ }
153
+
154
+ BOOL wlf_register_pointer(rdpGraphics* graphics)
155
+ {
156
+ rdpPointer pointer = { 0 };
157
+
158
+ pointer.size = sizeof(wlfPointer);
159
+ pointer.New = wlf_Pointer_New;
160
+ pointer.Free = wlf_Pointer_Free;
161
+ pointer.Set = wlf_Pointer_Set;
162
+ pointer.SetNull = wlf_Pointer_SetNull;
163
+ pointer.SetDefault = wlf_Pointer_SetDefault;
164
+ pointer.SetPosition = wlf_Pointer_SetPosition;
165
+ graphics_register_pointer(graphics, &pointer);
166
+ return TRUE;
167
+ }
local-test-freerdp-full-01/afc-freerdp/client/Wayland/wlf_pointer.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Wayland Mouse Pointer
4
+ *
5
+ * Copyright 2019 Armin Novak <armin.novak@thincast.com>
6
+ * Copyright 2019 Thincast Technologies GmbH
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ #ifndef FREERDP_CLIENT_WAYLAND_POINTER_H
22
+ #define FREERDP_CLIENT_WAYLAND_POINTER_H
23
+
24
+ #include <freerdp/graphics.h>
25
+
26
+ BOOL wlf_register_pointer(rdpGraphics* graphics);
27
+
28
+ #endif /* FREERDP_CLIENT_WAYLAND_POINTER_H */