Kitxuuu commited on
Commit
6ca7e7f
·
verified ·
1 Parent(s): 8d39233

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. .gitattributes +11 -0
  2. local-test-freerdp-full-01/afc-freerdp/channels/CMakeLists.txt +285 -0
  3. local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/OrderedDictionary.m +167 -0
  4. local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/TSXAdditions.m +239 -0
  5. local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/Toast+UIView.m +367 -0
  6. local-test-freerdp-full-01/afc-freerdp/client/iOS/AppDelegate.m +127 -0
  7. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AboutController.h +19 -0
  8. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AboutController.m +120 -0
  9. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AdvancedBookmarkEditorController.h +26 -0
  10. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AdvancedBookmarkEditorController.m +407 -0
  11. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AppSettingsController.h +15 -0
  12. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AppSettingsController.m +360 -0
  13. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkEditorController.h +38 -0
  14. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkEditorController.m +427 -0
  15. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkGatewaySettingsController.h +26 -0
  16. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkGatewaySettingsController.m +242 -0
  17. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkListController.h +56 -0
  18. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkListController.m +957 -0
  19. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsEditorController.h +26 -0
  20. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsEditorController.m +215 -0
  21. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsInputController.h +35 -0
  22. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsInputController.m +160 -0
  23. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorBaseController.h +44 -0
  24. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorBaseController.m +110 -0
  25. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorSelectionController.m +143 -0
  26. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EncryptionController.h +25 -0
  27. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EncryptionController.m +155 -0
  28. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/HelpController.h +17 -0
  29. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/HelpController.m +76 -0
  30. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/MainTabBarController.h +18 -0
  31. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/MainTabBarController.m +20 -0
  32. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/PerformanceEditorController.h +25 -0
  33. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/PerformanceEditorController.m +244 -0
  34. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/RDPSessionViewController.h +75 -0
  35. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/RDPSessionViewController.m +1113 -0
  36. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/ScreenSelectionController.h +34 -0
  37. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/ScreenSelectionController.m +253 -0
  38. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/VerifyCertificateController.h +33 -0
  39. local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/VerifyCertificateController.m +86 -0
  40. local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_cliprdr.m +499 -0
  41. local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp.h +87 -0
  42. local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp_ui.h +29 -0
  43. local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp_ui.m +211 -0
  44. local-test-freerdp-full-01/afc-freerdp/client/iOS/Misc/Reachability.m +277 -0
  45. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Encryptor.h +43 -0
  46. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPKeyboard.h +76 -0
  47. local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPKeyboard.m +310 -0
  48. local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/AdvancedKeyboardView.h +48 -0
  49. local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/BlockAlertView.h +42 -0
  50. local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/BlockAlertView.m +475 -0
.gitattributes CHANGED
@@ -104,3 +104,14 @@ local-test-sqlite3-delta-01/afc-sqlite3/test/fuzzdata5.db filter=lfs diff=lfs me
104
  local-test-sqlite3-delta-03/afc-sqlite3/contacts.lsm filter=lfs diff=lfs merge=lfs -text
105
  local-test-sqlite3-delta-03/fuzz-tooling/infra/cifuzz/test_data/timeout_fuzzer filter=lfs diff=lfs merge=lfs -text
106
  local-test-freerdp-full-01/afc-freerdp/client/Windows/resource/FreeRDP.ico filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
104
  local-test-sqlite3-delta-03/afc-sqlite3/contacts.lsm filter=lfs diff=lfs merge=lfs -text
105
  local-test-sqlite3-delta-03/fuzz-tooling/infra/cifuzz/test_data/timeout_fuzzer filter=lfs diff=lfs merge=lfs -text
106
  local-test-freerdp-full-01/afc-freerdp/client/Windows/resource/FreeRDP.ico filter=lfs diff=lfs merge=lfs -text
107
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata4.db filter=lfs diff=lfs merge=lfs -text
108
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata6.db filter=lfs diff=lfs merge=lfs -text
109
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata1.db filter=lfs diff=lfs merge=lfs -text
110
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata3.db filter=lfs diff=lfs merge=lfs -text
111
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata2.db filter=lfs diff=lfs merge=lfs -text
112
+ local-test-sqlite3-delta-03/afc-sqlite3/test/sessionfuzz-data1.db filter=lfs diff=lfs merge=lfs -text
113
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata7.db filter=lfs diff=lfs merge=lfs -text
114
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata8.db filter=lfs diff=lfs merge=lfs -text
115
+ local-test-sqlite3-delta-03/afc-sqlite3/test/fuzzdata5.db filter=lfs diff=lfs merge=lfs -text
116
+ local-test-libexif-delta-01-exif-003/fuzz-tooling/infra/cifuzz/test_data/timeout_fuzzer filter=lfs diff=lfs merge=lfs -text
117
+ local-test-libpostal-full-01/afc-libpostal/src/transliteration_data.c filter=lfs diff=lfs merge=lfs -text
local-test-freerdp-full-01/afc-freerdp/channels/CMakeLists.txt ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FreeRDP: A Remote Desktop Protocol Implementation
2
+ # FreeRDP cmake build script
3
+ #
4
+ # Copyright 2012 Marc-Andre Moreau <[email protected]>
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
+ include(CMakeParseArguments)
19
+ include(CMakeDependentOption)
20
+
21
+ macro(define_channel_options)
22
+ set(PREFIX "CHANNEL")
23
+
24
+ cmake_parse_arguments(
25
+ ${PREFIX} "" "NAME;TYPE;DESCRIPTION;SPECIFICATIONS;DEFAULT;CLIENT_DEFAULT;SERVER_DEFAULT" "" ${ARGN}
26
+ )
27
+
28
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}" CHANNEL_OPTION)
29
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" CHANNEL_CLIENT_OPTION)
30
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" CHANNEL_SERVER_OPTION)
31
+ string(TOUPPER "${CHANNEL_TYPE}" CHANNEL_TYPE)
32
+
33
+ if(CHANNEL_DEFAULT)
34
+ set(OPTION_DEFAULT ${CHANNEL_DEFAULT})
35
+ elseif(CHANNEL_CLIENT_OPTION OR CHANNEL_SERVER_OPTION)
36
+ set(OPTION_DEFAULT "ON")
37
+ endif()
38
+
39
+ set(CHANNEL_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel")
40
+ set(CHANNEL_CLIENT_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel client")
41
+ set(CHANNEL_SERVER_OPTION_DOC "Build ${CHANNEL_NAME} ${CHANNEL_TYPE} channel server")
42
+
43
+ if("${CHANNEL_TYPE}" STREQUAL "DYNAMIC")
44
+ cmake_dependent_option(${CHANNEL_OPTION} "${CHANNEL_OPTION_DOC}" ${CHANNEL_DEFAULT} "CHANNEL_DRDYNVC" OFF)
45
+ else()
46
+ option(${CHANNEL_OPTION} "${CHANNEL_OPTION_DOC}" ${CHANNEL_DEFAULT})
47
+ endif()
48
+
49
+ cmake_dependent_option(
50
+ ${CHANNEL_CLIENT_OPTION} "${CHANNEL_CLIENT_OPTION_DOC}" ${CHANNEL_CLIENT_DEFAULT} "${CHANNEL_OPTION}" OFF
51
+ )
52
+
53
+ cmake_dependent_option(
54
+ ${CHANNEL_SERVER_OPTION} "${CHANNEL_SERVER_OPTION_DOC}" ${CHANNEL_SERVER_DEFAULT} "${CHANNEL_OPTION}" OFF
55
+ )
56
+ endmacro(define_channel_options)
57
+
58
+ macro(define_channel _channel_name)
59
+ set(CHANNEL_NAME ${_channel_name})
60
+ set(MODULE_NAME ${CHANNEL_NAME})
61
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}" MODULE_PREFIX)
62
+ endmacro(define_channel)
63
+
64
+ macro(define_channel_client _channel_name)
65
+ set(CHANNEL_NAME ${_channel_name})
66
+ set(MODULE_NAME "${CHANNEL_NAME}-client")
67
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
68
+ endmacro(define_channel_client)
69
+
70
+ macro(define_channel_server _channel_name)
71
+ set(CHANNEL_NAME ${_channel_name})
72
+ set(MODULE_NAME "${CHANNEL_NAME}-server")
73
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" MODULE_PREFIX)
74
+ endmacro(define_channel_server)
75
+
76
+ macro(define_channel_client_subsystem _channel_name _subsystem _type)
77
+ set(CHANNEL_NAME ${_channel_name})
78
+ set(CHANNEL_SUBSYSTEM ${_subsystem})
79
+ string(LENGTH "${_type}" _type_length)
80
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" CHANNEL_PREFIX)
81
+ if(_type_length GREATER 0)
82
+ set(SUBSYSTEM_TYPE ${_type})
83
+ set(MODULE_NAME "${CHANNEL_NAME}-client-${CHANNEL_SUBSYSTEM}-${SUBSYSTEM_TYPE}")
84
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT_${CHANNEL_SUBSYSTEM}_${SUBSYSTEM_TYPE}" MODULE_PREFIX)
85
+ else()
86
+ set(MODULE_NAME "${CHANNEL_NAME}-client-${CHANNEL_SUBSYSTEM}")
87
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT_${CHANNEL_SUBSYSTEM}" MODULE_PREFIX)
88
+ endif()
89
+ endmacro(define_channel_client_subsystem)
90
+
91
+ macro(define_channel_server_subsystem _channel_name _subsystem _type)
92
+ set(CHANNEL_NAME ${_channel_name})
93
+ set(CHANNEL_SUBSYSTEM ${_subsystem})
94
+ set(MODULE_NAME "${CHANNEL_NAME}-server-${CHANNEL_SUBSYSTEM}")
95
+ string(TOUPPER "CHANNEL_${CHANNEL_NAME}_server_${CHANNEL_SUBSYSTEM}" MODULE_PREFIX)
96
+ endmacro(define_channel_server_subsystem)
97
+
98
+ macro(add_channel_client _channel_prefix _channel_name)
99
+ if(${_channel_prefix}_CLIENT)
100
+ add_subdirectory(client)
101
+ if(${${_channel_prefix}_CLIENT_STATIC})
102
+ set(CHANNEL_STATIC_CLIENT_MODULES ${CHANNEL_STATIC_CLIENT_MODULES} ${_channel_prefix} PARENT_SCOPE)
103
+ set(${_channel_prefix}_CLIENT_NAME ${${_channel_prefix}_CLIENT_NAME} PARENT_SCOPE)
104
+ set(${_channel_prefix}_CLIENT_CHANNEL ${${_channel_prefix}_CLIENT_CHANNEL} PARENT_SCOPE)
105
+ set(${_channel_prefix}_CLIENT_ENTRY ${${_channel_prefix}_CLIENT_ENTRY} PARENT_SCOPE)
106
+ set(CHANNEL_STATIC_CLIENT_ENTRIES ${CHANNEL_STATIC_CLIENT_ENTRIES} ${${_channel_prefix}_CLIENT_ENTRY}
107
+ PARENT_SCOPE
108
+ )
109
+ endif()
110
+ endif()
111
+ endmacro(add_channel_client)
112
+
113
+ macro(add_channel_server _channel_prefix _channel_name)
114
+ if(${_channel_prefix}_SERVER)
115
+ add_subdirectory(server)
116
+ if(${${_channel_prefix}_SERVER_STATIC})
117
+ set(CHANNEL_STATIC_SERVER_MODULES ${CHANNEL_STATIC_SERVER_MODULES} ${_channel_prefix} PARENT_SCOPE)
118
+ set(${_channel_prefix}_SERVER_NAME ${${_channel_prefix}_SERVER_NAME} PARENT_SCOPE)
119
+ set(${_channel_prefix}_SERVER_CHANNEL ${${_channel_prefix}_SERVER_CHANNEL} PARENT_SCOPE)
120
+ set(${_channel_prefix}_SERVER_ENTRY ${${_channel_prefix}_SERVER_ENTRY} PARENT_SCOPE)
121
+ set(CHANNEL_STATIC_SERVER_ENTRIES ${CHANNEL_STATIC_SERVER_ENTRIES} ${${_channel_prefix}_SERVER_ENTRY}
122
+ PARENT_SCOPE
123
+ )
124
+ endif()
125
+ endif()
126
+ endmacro(add_channel_server)
127
+
128
+ macro(add_channel_client_subsystem _channel_prefix _channel_name _subsystem _type)
129
+ add_subdirectory(${_subsystem})
130
+ set(_channel_module_name "${_channel_name}-client")
131
+ string(LENGTH "${_type}" _type_length)
132
+ if(_type_length GREATER 0)
133
+ string(TOUPPER "CHANNEL_${_channel_name}_CLIENT_${_subsystem}_${_type}" _subsystem_prefix)
134
+ else()
135
+ string(TOUPPER "CHANNEL_${_channel_name}_CLIENT_${_subsystem}" _subsystem_prefix)
136
+ endif()
137
+ if(${${_subsystem_prefix}_STATIC})
138
+ get_target_property(CHANNEL_SUBSYSTEMS ${_channel_module_name} SUBSYSTEMS)
139
+ if(_type_length GREATER 0)
140
+ set(SUBSYSTEMS ${SUBSYSTEMS} "${_subsystem}-${_type}")
141
+ else()
142
+ set(SUBSYSTEMS ${SUBSYSTEMS} ${_subsystem})
143
+ endif()
144
+ set_target_properties(${_channel_module_name} PROPERTIES SUBSYSTEMS "${SUBSYSTEMS}")
145
+ endif()
146
+ endmacro(add_channel_client_subsystem)
147
+
148
+ macro(channel_install _targets _destination _export_target)
149
+ if(NOT BUILD_SHARED_LIBS)
150
+ foreach(_target_name IN ITEMS ${_targets})
151
+ target_include_directories(${_target_name} INTERFACE $<INSTALL_INTERFACE:include>)
152
+ endforeach()
153
+ install(TARGETS ${_targets} DESTINATION ${_destination} EXPORT ${_export_target})
154
+ endif()
155
+ endmacro(channel_install)
156
+
157
+ macro(server_channel_install _targets _destination)
158
+ channel_install(${_targets} ${_destination} "FreeRDP-ServerTargets")
159
+ endmacro(server_channel_install)
160
+
161
+ macro(client_channel_install _targets _destination)
162
+ channel_install(${_targets} ${_destination} "FreeRDP-ClientTargets")
163
+ endmacro(client_channel_install)
164
+
165
+ macro(add_channel_client_library _module_prefix _module_name _channel_name _dynamic _entry)
166
+ set(_lnk_dir ${${_module_prefix}_LINK_DIRS})
167
+ if(NOT "${_lnk_dir}" STREQUAL "")
168
+ link_directories(${_lnk_dir})
169
+ endif()
170
+
171
+ set(${_module_prefix}_STATIC ON PARENT_SCOPE)
172
+ set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE)
173
+ set(${_module_prefix}_CHANNEL ${_channel_name} PARENT_SCOPE)
174
+ set(${_module_prefix}_ENTRY ${_entry} PARENT_SCOPE)
175
+
176
+ add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS})
177
+ set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")
178
+
179
+ if(${_module_prefix}_LIBS)
180
+ target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS})
181
+ endif()
182
+ client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH})
183
+ endmacro(add_channel_client_library)
184
+
185
+ macro(
186
+ add_channel_client_subsystem_library
187
+ _module_prefix
188
+ _module_name
189
+ _channel_name
190
+ _type
191
+ _dynamic
192
+ _entry
193
+ )
194
+ set(_lnk_dir ${${_module_prefix}_LINK_DIRS})
195
+ if(NOT "${_lnk_dir}" STREQUAL "")
196
+ link_directories(${_lnk_dir})
197
+ endif()
198
+
199
+ set(${_module_prefix}_STATIC ON PARENT_SCOPE)
200
+ set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE)
201
+ set(${_module_prefix}_TYPE ${_type} PARENT_SCOPE)
202
+
203
+ add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS})
204
+ set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${_channel_name}/Client/Subsystem/${CHANNEL_SUBSYSTEM}")
205
+
206
+ if(${_module_prefix}_LIBS)
207
+ target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS})
208
+ endif()
209
+ client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH})
210
+ endmacro(add_channel_client_subsystem_library)
211
+
212
+ macro(add_channel_server_library _module_prefix _module_name _channel_name _dynamic _entry)
213
+ set(_lnk_dir ${${_module_prefix}_LINK_DIRS})
214
+ if(NOT "${_lnk_dir}" STREQUAL "")
215
+ link_directories(${_lnk_dir})
216
+ endif()
217
+
218
+ set(${_module_prefix}_STATIC ON PARENT_SCOPE)
219
+ set(${_module_prefix}_NAME ${_module_name} PARENT_SCOPE)
220
+ set(${_module_prefix}_CHANNEL ${_channel_name} PARENT_SCOPE)
221
+ set(${_module_prefix}_ENTRY ${_entry} PARENT_SCOPE)
222
+
223
+ add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS})
224
+ set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")
225
+
226
+ if(${_module_prefix}_LIBS)
227
+ target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS})
228
+ endif()
229
+ server_channel_install(${_module_name} ${FREERDP_ADDIN_PATH})
230
+ endmacro(add_channel_server_library)
231
+
232
+ set(FILENAME "ChannelOptions.cmake")
233
+ file(GLOB FILEPATHS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${FILENAME}")
234
+
235
+ # We need special treatment for drdynvc:
236
+ # It needs to be the first entry so that every
237
+ # dynamic channel has the dependent options available.
238
+ set(DRDYNVC_MATCH "")
239
+
240
+ foreach(FILEPATH ${FILEPATHS})
241
+ if(${FILEPATH} MATCHES "^([^/]*)drdynvc/+${FILENAME}")
242
+ set(DRDYNVC_MATCH ${FILEPATH})
243
+ endif()
244
+ endforeach()
245
+
246
+ if(NOT "${DRDYNVC_MATCH}" STREQUAL "")
247
+ list(REMOVE_ITEM FILEPATHS ${DRDYNVC_MATCH})
248
+ list(APPEND FILEPATHS ${DRDYNVC_MATCH})
249
+ list(REVERSE FILEPATHS) # list PREPEND is not available on old CMake3
250
+ endif()
251
+
252
+ foreach(FILEPATH ${FILEPATHS})
253
+ if(${FILEPATH} MATCHES "^([^/]*)/+${FILENAME}")
254
+ string(REGEX REPLACE "^([^/]*)/+${FILENAME}" "\\1" DIR ${FILEPATH})
255
+ set(CHANNEL_OPTION)
256
+ include(${FILEPATH})
257
+ if(${CHANNEL_OPTION})
258
+ set(CHANNEL_MESSAGE "Adding ${CHANNEL_TYPE} channel")
259
+ if(${CHANNEL_CLIENT_OPTION})
260
+ set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} client")
261
+ endif()
262
+ if(${CHANNEL_SERVER_OPTION})
263
+ set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} server")
264
+ endif()
265
+ set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE} \"${CHANNEL_NAME}\"")
266
+ set(CHANNEL_MESSAGE "${CHANNEL_MESSAGE}: ${CHANNEL_DESCRIPTION}")
267
+ message(STATUS "${CHANNEL_MESSAGE}")
268
+ add_subdirectory(${DIR})
269
+ endif()
270
+ endif()
271
+ endforeach(FILEPATH)
272
+
273
+ if(WITH_CHANNELS)
274
+ if(WITH_CLIENT_CHANNELS)
275
+ add_subdirectory(client)
276
+ set(FREERDP_CHANNELS_CLIENT_SRCS ${FREERDP_CHANNELS_CLIENT_SRCS} PARENT_SCOPE)
277
+ set(FREERDP_CHANNELS_CLIENT_LIBS ${FREERDP_CHANNELS_CLIENT_LIBS} PARENT_SCOPE)
278
+ endif()
279
+
280
+ if(WITH_SERVER_CHANNELS)
281
+ add_subdirectory(server)
282
+ set(FREERDP_CHANNELS_SERVER_SRCS ${FREERDP_CHANNELS_SERVER_SRCS} PARENT_SCOPE)
283
+ set(FREERDP_CHANNELS_SERVER_LIBS ${FREERDP_CHANNELS_SERVER_LIBS} PARENT_SCOPE)
284
+ endif()
285
+ endif()
local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/OrderedDictionary.m ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // OrderedDictionary.m
3
+ // OrderedDictionary
4
+ //
5
+ // Modified version (Added indexForKey/Value functions)
6
+ //
7
+ // Created by Matt Gallagher on 19/12/08.
8
+ // Copyright 2008 Matt Gallagher. All rights reserved.
9
+ //
10
+ // This software is provided 'as-is', without any express or implied
11
+ // warranty. In no event will the authors be held liable for any damages
12
+ // arising from the use of this software. Permission is granted to anyone to
13
+ // use this software for any purpose, including commercial applications, and to
14
+ // alter it and redistribute it freely, subject to the following restrictions:
15
+ //
16
+ // 1. The origin of this software must not be misrepresented; you must not
17
+ // claim that you wrote the original software. If you use this software
18
+ // in a product, an acknowledgment in the product documentation would be
19
+ // appreciated but is not required.
20
+ // 2. Altered source versions must be plainly marked as such, and must not be
21
+ // misrepresented as being the original software.
22
+ // 3. This notice may not be removed or altered from any source
23
+ // distribution.
24
+ //
25
+
26
+ #import "OrderedDictionary.h"
27
+
28
+ NSString *DescriptionForObject(NSObject *object, id locale, NSUInteger indent)
29
+ {
30
+ NSString *objectString;
31
+ if ([object isKindOfClass:[NSString class]])
32
+ {
33
+ objectString = (NSString *)[[object retain] autorelease];
34
+ }
35
+ else if ([object respondsToSelector:@selector(descriptionWithLocale:indent:)])
36
+ {
37
+ objectString = [(NSDictionary *)object descriptionWithLocale:locale indent:indent];
38
+ }
39
+ else if ([object respondsToSelector:@selector(descriptionWithLocale:)])
40
+ {
41
+ objectString = [(NSSet *)object descriptionWithLocale:locale];
42
+ }
43
+ else
44
+ {
45
+ objectString = [object description];
46
+ }
47
+ return objectString;
48
+ }
49
+
50
+ @implementation OrderedDictionary
51
+
52
+ - (id)init
53
+ {
54
+ return [self initWithCapacity:0];
55
+ }
56
+
57
+ - (id)initWithCapacity:(NSUInteger)capacity
58
+ {
59
+ self = [super init];
60
+ if (self != nil)
61
+ {
62
+ dictionary = [[NSMutableDictionary alloc] initWithCapacity:capacity];
63
+ array = [[NSMutableArray alloc] initWithCapacity:capacity];
64
+ }
65
+ return self;
66
+ }
67
+
68
+ - (void)dealloc
69
+ {
70
+ [dictionary release];
71
+ [array release];
72
+ [super dealloc];
73
+ }
74
+
75
+ - (id)copy
76
+ {
77
+ return [self mutableCopy];
78
+ }
79
+
80
+ - (void)setObject:(id)anObject forKey:(id)aKey
81
+ {
82
+ if (![dictionary objectForKey:aKey])
83
+ {
84
+ [array addObject:aKey];
85
+ }
86
+ [dictionary setObject:anObject forKey:aKey];
87
+ }
88
+
89
+ - (void)removeObjectForKey:(id)aKey
90
+ {
91
+ [dictionary removeObjectForKey:aKey];
92
+ [array removeObject:aKey];
93
+ }
94
+
95
+ - (NSUInteger)count
96
+ {
97
+ return [dictionary count];
98
+ }
99
+
100
+ - (id)objectForKey:(id)aKey
101
+ {
102
+ return [dictionary objectForKey:aKey];
103
+ }
104
+
105
+ - (NSEnumerator *)keyEnumerator
106
+ {
107
+ return [array objectEnumerator];
108
+ }
109
+
110
+ - (NSEnumerator *)reverseKeyEnumerator
111
+ {
112
+ return [array reverseObjectEnumerator];
113
+ }
114
+
115
+ - (void)insertObject:(id)anObject forKey:(id)aKey atIndex:(NSUInteger)anIndex
116
+ {
117
+ if ([dictionary objectForKey:aKey])
118
+ {
119
+ [self removeObjectForKey:aKey];
120
+ }
121
+ [array insertObject:aKey atIndex:anIndex];
122
+ [dictionary setObject:anObject forKey:aKey];
123
+ }
124
+
125
+ - (id)keyAtIndex:(NSUInteger)anIndex
126
+ {
127
+ return [array objectAtIndex:anIndex];
128
+ }
129
+
130
+ - (NSUInteger)indexForKey:(id)key
131
+ {
132
+ return [array indexOfObject:key];
133
+ }
134
+
135
+ - (NSUInteger)indexForValue:(id)value
136
+ {
137
+ NSArray *keys = [self allKeysForObject:value];
138
+ if ([keys count] > 0)
139
+ {
140
+ return [self indexForKey:[keys objectAtIndex:0]];
141
+ }
142
+
143
+ return NSNotFound;
144
+ }
145
+
146
+ - (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level
147
+ {
148
+ NSMutableString *indentString = [NSMutableString string];
149
+ NSUInteger count = level;
150
+ for (NSUInteger i = 0; i < count; i++)
151
+ {
152
+ [indentString appendFormat:@" "];
153
+ }
154
+
155
+ NSMutableString *description = [NSMutableString string];
156
+ [description appendFormat:@"%@{\n", indentString];
157
+ for (NSObject *key in self)
158
+ {
159
+ [description appendFormat:@"%@ %@ = %@;\n", indentString,
160
+ DescriptionForObject(key, locale, level),
161
+ DescriptionForObject([self objectForKey:key], locale, level)];
162
+ }
163
+ [description appendFormat:@"%@}\n", indentString];
164
+ return description;
165
+ }
166
+
167
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/TSXAdditions.m ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Additions to Cocoa touch classes
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson, Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "TSXAdditions.h"
12
+ #include <openssl/bio.h>
13
+ #include <openssl/evp.h>
14
+ #include <openssl/err.h>
15
+
16
+ @implementation NSObject (TSXAdditions)
17
+
18
+ - (void)setValuesForKeyPathsWithDictionary:(NSDictionary *)keyedValues
19
+ {
20
+ for (id keyPath in keyedValues)
21
+ [self setValue:[keyedValues objectForKey:keyPath] forKeyPath:keyPath];
22
+ }
23
+
24
+ - mutableDeepCopy
25
+ {
26
+ if ([self respondsToSelector:@selector(mutableCopyWithZone:)])
27
+ return [self mutableCopy];
28
+ else if ([self respondsToSelector:@selector(copyWithZone:)])
29
+ return [self copy];
30
+ else
31
+ return [self retain];
32
+ }
33
+
34
+ @end
35
+
36
+ #pragma mark -
37
+
38
+ @implementation NSString (TSXAdditions)
39
+
40
+ #pragma mark Creation routines
41
+ + (NSString *)stringWithUUID
42
+ {
43
+ CFUUIDRef uuidObj = CFUUIDCreate(nil);
44
+ NSString *uuidString = (NSString *)CFUUIDCreateString(nil, uuidObj);
45
+ CFRelease(uuidObj);
46
+ return [uuidString autorelease];
47
+ }
48
+
49
+ /* Code from
50
+ * http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSData%2BHex.m?r=344
51
+ */
52
+ - (NSData *)dataFromHexString
53
+ {
54
+ NSData *hexData = [self dataUsingEncoding:NSASCIIStringEncoding];
55
+ const char *hexBuf = [hexData bytes];
56
+ NSUInteger hexLen = [hexData length];
57
+
58
+ // This indicates an error converting to ASCII.
59
+ if (!hexData)
60
+ return nil;
61
+
62
+ if ((hexLen % 2) != 0)
63
+ {
64
+ return nil;
65
+ }
66
+
67
+ NSMutableData *binaryData = [NSMutableData dataWithLength:(hexLen / 2)];
68
+ unsigned char *binaryPtr = [binaryData mutableBytes];
69
+ unsigned char value = 0;
70
+ for (NSUInteger i = 0; i < hexLen; i++)
71
+ {
72
+ char c = hexBuf[i];
73
+
74
+ if (!isxdigit(c))
75
+ {
76
+ return nil;
77
+ }
78
+
79
+ if (isdigit(c))
80
+ {
81
+ value += c - '0';
82
+ }
83
+ else if (islower(c))
84
+ {
85
+ value += 10 + c - 'a';
86
+ }
87
+ else
88
+ {
89
+ value += 10 + c - 'A';
90
+ }
91
+
92
+ if (i & 1)
93
+ {
94
+ *binaryPtr++ = value;
95
+ value = 0;
96
+ }
97
+ else
98
+ {
99
+ value <<= 4;
100
+ }
101
+ }
102
+
103
+ return [NSData dataWithData:binaryData];
104
+ }
105
+
106
+ + (NSString *)hexStringFromData:(const unsigned char *)data
107
+ ofSize:(unsigned int)size
108
+ withSeparator:(NSString *)sep
109
+ afterNthChar:(int)sepnth
110
+ {
111
+ NSMutableString *result;
112
+ NSString *immutableResult;
113
+
114
+ result = [[NSMutableString alloc] init];
115
+ for (int i = 0; i < size; i++)
116
+ {
117
+ if (i && sep && sepnth && i % sepnth == 0)
118
+ [result appendString:sep];
119
+ [result appendFormat:@"%02X", data[i]];
120
+ }
121
+
122
+ immutableResult = [NSString stringWithString:result];
123
+ [result release];
124
+ return immutableResult;
125
+ }
126
+
127
+ @end
128
+
129
+ #pragma mark Mutable deep copy for dictionary, array and set
130
+
131
+ @implementation NSDictionary (TSXAdditions)
132
+
133
+ - mutableDeepCopy
134
+ {
135
+ NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] init];
136
+ NSEnumerator *enumerator = [self keyEnumerator];
137
+ id key;
138
+ while ((key = [enumerator nextObject]))
139
+ {
140
+ id obj = [[self objectForKey:key] mutableDeepCopy];
141
+ [newDictionary setObject:obj forKey:key];
142
+ [obj release];
143
+ }
144
+ return newDictionary;
145
+ }
146
+
147
+ @end
148
+
149
+ @implementation NSArray (TSXAdditions)
150
+
151
+ - mutableDeepCopy
152
+ {
153
+ NSMutableArray *newArray = [[NSMutableArray alloc] init];
154
+ NSEnumerator *enumerator = [self objectEnumerator];
155
+ id obj;
156
+ while ((obj = [enumerator nextObject]))
157
+ {
158
+ obj = [obj mutableDeepCopy];
159
+ [newArray addObject:obj];
160
+ [obj release];
161
+ }
162
+ return newArray;
163
+ }
164
+
165
+ @end
166
+
167
+ @implementation NSSet (TSXAdditions)
168
+
169
+ - mutableDeepCopy
170
+ {
171
+ NSMutableSet *newSet = [[NSMutableSet alloc] init];
172
+ NSEnumerator *enumerator = [self objectEnumerator];
173
+ id obj;
174
+ while ((obj = [enumerator nextObject]))
175
+ {
176
+ obj = [obj mutableDeepCopy];
177
+ [newSet addObject:obj];
178
+ [obj release];
179
+ }
180
+ return newSet;
181
+ }
182
+
183
+ @end
184
+
185
+ #pragma mark -
186
+
187
+ /* Code from
188
+ * http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string
189
+ */
190
+ @implementation NSData (TSXAdditions)
191
+
192
+ #pragma mark - String Conversion
193
+ - (NSString *)hexadecimalString
194
+ {
195
+ /* Returns hexadecimal string of NSData. Empty string if data is empty. */
196
+
197
+ const unsigned char *dataBuffer = (const unsigned char *)[self bytes];
198
+
199
+ if (!dataBuffer)
200
+ return [NSString string];
201
+
202
+ NSUInteger dataLength = [self length];
203
+ NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
204
+
205
+ for (int i = 0; i < dataLength; ++i)
206
+ [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
207
+
208
+ return [NSString stringWithString:hexString];
209
+ }
210
+
211
+ /* Code from http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html */
212
+ - (NSString *)base64EncodedString
213
+ {
214
+ // Construct an OpenSSL context
215
+ BIO *context = BIO_new(BIO_s_mem());
216
+
217
+ // Tell the context to encode base64
218
+ BIO *command = BIO_new(BIO_f_base64());
219
+ context = BIO_push(command, context);
220
+ BIO_set_flags(context, BIO_FLAGS_BASE64_NO_NL);
221
+
222
+ // Encode all the data
223
+ ERR_clear_error();
224
+ BIO_write(context, [self bytes], [self length]);
225
+ (void)BIO_flush(context);
226
+
227
+ // Get the data out of the context
228
+ char *outputBuffer;
229
+ long outputLength = BIO_get_mem_data(context, &outputBuffer);
230
+ NSString *encodedString = [[NSString alloc] initWithBytes:outputBuffer
231
+ length:outputLength
232
+ encoding:NSASCIIStringEncoding];
233
+
234
+ BIO_free_all(context);
235
+
236
+ return encodedString;
237
+ }
238
+
239
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Additions/Toast+UIView.m ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /***************************************************************************
2
+
3
+ Toast+UIView.h
4
+ Toast
5
+ Version 0.1
6
+
7
+ Copyright (c) 2011 Charles Scalesse.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a
10
+ copy of this software and associated documentation files (the
11
+ "Software"), to deal in the Software without restriction, including
12
+ without limitation the rights to use, copy, modify, merge, publish,
13
+ distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to
15
+ the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included
18
+ in all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+ ***************************************************************************/
29
+
30
+ #import "Toast+UIView.h"
31
+ #import <QuartzCore/QuartzCore.h>
32
+ #import <objc/runtime.h>
33
+
34
+ #define kMaxWidth 0.8
35
+ #define kMaxHeight 0.8
36
+
37
+ #define kHorizontalPadding 10.0
38
+ #define kVerticalPadding 10.0
39
+ #define kCornerRadius 10.0
40
+ #define kOpacity 0.8
41
+ #define kFontSize 16.0
42
+ #define kMaxTitleLines 999
43
+ #define kMaxMessageLines 999
44
+
45
+ #define kFadeDuration 0.2
46
+
47
+ #define kDefaultLength 3
48
+ #define kDefaultPosition @"bottom"
49
+
50
+ #define kImageWidth 80.0
51
+ #define kImageHeight 80.0
52
+
53
+ static NSString *kDurationKey = @"duration";
54
+
55
+ @interface UIView (ToastPrivate)
56
+
57
+ - (CGPoint)getPositionFor:(id)position toast:(UIView *)toast;
58
+ - (UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image;
59
+
60
+ @end
61
+
62
+ @implementation UIView (Toast)
63
+
64
+ #pragma mark -
65
+ #pragma mark Toast Methods
66
+
67
+ - (void)makeToast:(NSString *)message
68
+ {
69
+ [self makeToast:message duration:kDefaultLength position:kDefaultPosition];
70
+ }
71
+
72
+ - (void)makeToast:(NSString *)message duration:(float)interval position:(id)point
73
+ {
74
+ UIView *toast = [self makeViewForMessage:message title:nil image:nil];
75
+ [self showToast:toast duration:interval position:point];
76
+ }
77
+
78
+ - (void)makeToast:(NSString *)message
79
+ duration:(float)interval
80
+ position:(id)point
81
+ title:(NSString *)title
82
+ {
83
+ UIView *toast = [self makeViewForMessage:message title:title image:nil];
84
+ [self showToast:toast duration:interval position:point];
85
+ }
86
+
87
+ - (void)makeToast:(NSString *)message
88
+ duration:(float)interval
89
+ position:(id)point
90
+ image:(UIImage *)image
91
+ {
92
+ UIView *toast = [self makeViewForMessage:message title:nil image:image];
93
+ [self showToast:toast duration:interval position:point];
94
+ }
95
+
96
+ - (void)makeToast:(NSString *)message
97
+ duration:(float)interval
98
+ position:(id)point
99
+ title:(NSString *)title
100
+ image:(UIImage *)image
101
+ {
102
+ UIView *toast = [self makeViewForMessage:message title:title image:image];
103
+ [self showToast:toast duration:interval position:point];
104
+ }
105
+
106
+ - (void)showToast:(UIView *)toast
107
+ {
108
+ [self showToast:toast duration:kDefaultLength position:kDefaultPosition];
109
+ }
110
+
111
+ - (void)showToast:(UIView *)toast duration:(float)interval position:(id)point
112
+ {
113
+
114
+ /****************************************************
115
+ * *
116
+ * Displays a view for a given duration & position. *
117
+ * *
118
+ ****************************************************/
119
+
120
+ CGPoint toastPoint = [self getPositionFor:point toast:toast];
121
+
122
+ // use an associative reference to associate the toast view with the display interval
123
+ objc_setAssociatedObject(toast, &kDurationKey, [NSNumber numberWithFloat:interval],
124
+ OBJC_ASSOCIATION_RETAIN);
125
+
126
+ [toast setCenter:toastPoint];
127
+ [toast setAlpha:0.0];
128
+ [self addSubview:toast];
129
+
130
+ [UIView beginAnimations:@"fade_in" context:toast];
131
+ [UIView setAnimationDuration:kFadeDuration];
132
+ [UIView setAnimationDelegate:self];
133
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
134
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
135
+ [toast setAlpha:1.0];
136
+ [UIView commitAnimations];
137
+ }
138
+
139
+ #pragma mark -
140
+ #pragma mark Animation Delegate Method
141
+
142
+ - (void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context
143
+ {
144
+
145
+ UIView *toast = (UIView *)context;
146
+
147
+ // retrieve the display interval associated with the view
148
+ float interval = [(NSNumber *)objc_getAssociatedObject(toast, &kDurationKey) floatValue];
149
+
150
+ if ([animationID isEqualToString:@"fade_in"])
151
+ {
152
+
153
+ [UIView beginAnimations:@"fade_out" context:toast];
154
+ [UIView setAnimationDelay:interval];
155
+ [UIView setAnimationDuration:kFadeDuration];
156
+ [UIView setAnimationDelegate:self];
157
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
158
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
159
+ [toast setAlpha:0.0];
160
+ [UIView commitAnimations];
161
+ }
162
+ else if ([animationID isEqualToString:@"fade_out"])
163
+ {
164
+
165
+ [toast removeFromSuperview];
166
+ }
167
+ }
168
+
169
+ #pragma mark -
170
+ #pragma mark Private Methods
171
+
172
+ - (CGPoint)getPositionFor:(id)point toast:(UIView *)toast
173
+ {
174
+
175
+ /*************************************************************************************
176
+ * *
177
+ * Converts string literals @"top", @"bottom", @"center", or any point wrapped in an *
178
+ * NSValue object into a CGPoint *
179
+ * *
180
+ *************************************************************************************/
181
+
182
+ if ([point isKindOfClass:[NSString class]])
183
+ {
184
+
185
+ if ([point caseInsensitiveCompare:@"top"] == NSOrderedSame)
186
+ {
187
+ return CGPointMake(self.bounds.size.width / 2,
188
+ (toast.frame.size.height / 2) + kVerticalPadding);
189
+ }
190
+ else if ([point caseInsensitiveCompare:@"bottom"] == NSOrderedSame)
191
+ {
192
+ return CGPointMake(self.bounds.size.width / 2,
193
+ (self.bounds.size.height - (toast.frame.size.height / 2)) -
194
+ kVerticalPadding);
195
+ }
196
+ else if ([point caseInsensitiveCompare:@"center"] == NSOrderedSame)
197
+ {
198
+ return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
199
+ }
200
+ }
201
+ else if ([point isKindOfClass:[NSValue class]])
202
+ {
203
+ return [point CGPointValue];
204
+ }
205
+
206
+ NSLog(@"Error: Invalid position for toast.");
207
+ return [self getPositionFor:kDefaultPosition toast:toast];
208
+ }
209
+
210
+ - (UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image
211
+ {
212
+
213
+ /***********************************************************************************
214
+ * *
215
+ * Dynamically build a toast view with any combination of message, title, & image. *
216
+ * *
217
+ ***********************************************************************************/
218
+
219
+ if ((message == nil) && (title == nil) && (image == nil))
220
+ return nil;
221
+
222
+ UILabel *messageLabel = nil;
223
+ UILabel *titleLabel = nil;
224
+ UIImageView *imageView = nil;
225
+
226
+ // create the parent view
227
+ UIView *wrapperView = [[[UIView alloc] init] autorelease];
228
+ [wrapperView.layer setCornerRadius:kCornerRadius];
229
+ [wrapperView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:kOpacity]];
230
+ wrapperView.autoresizingMask =
231
+ UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin |
232
+ UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
233
+
234
+ if (image != nil)
235
+ {
236
+ imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
237
+ [imageView setContentMode:UIViewContentModeScaleAspectFit];
238
+ [imageView
239
+ setFrame:CGRectMake(kHorizontalPadding, kVerticalPadding, kImageWidth, kImageHeight)];
240
+ }
241
+
242
+ float imageWidth, imageHeight, imageLeft;
243
+
244
+ // the imageView frame values will be used to size & position the other views
245
+ if (imageView != nil)
246
+ {
247
+ imageWidth = imageView.bounds.size.width;
248
+ imageHeight = imageView.bounds.size.height;
249
+ imageLeft = kHorizontalPadding;
250
+ }
251
+ else
252
+ {
253
+ imageWidth = imageHeight = imageLeft = 0;
254
+ }
255
+
256
+ if (title != nil)
257
+ {
258
+ titleLabel = [[[UILabel alloc] init] autorelease];
259
+ [titleLabel setNumberOfLines:kMaxTitleLines];
260
+ [titleLabel setFont:[UIFont boldSystemFontOfSize:kFontSize]];
261
+ [titleLabel setTextAlignment:UITextAlignmentLeft];
262
+ [titleLabel setLineBreakMode:UILineBreakModeWordWrap];
263
+ [titleLabel setTextColor:[UIColor whiteColor]];
264
+ [titleLabel setBackgroundColor:[UIColor clearColor]];
265
+ [titleLabel setAlpha:1.0];
266
+ [titleLabel setText:title];
267
+
268
+ // size the title label according to the length of the text
269
+ CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth,
270
+ self.bounds.size.height * kMaxHeight);
271
+ CGSize expectedSizeTitle = [title sizeWithFont:titleLabel.font
272
+ constrainedToSize:maxSizeTitle
273
+ lineBreakMode:titleLabel.lineBreakMode];
274
+ [titleLabel setFrame:CGRectMake(0, 0, expectedSizeTitle.width, expectedSizeTitle.height)];
275
+ }
276
+
277
+ if (message != nil)
278
+ {
279
+ messageLabel = [[[UILabel alloc] init] autorelease];
280
+ [messageLabel setNumberOfLines:kMaxMessageLines];
281
+ [messageLabel setFont:[UIFont systemFontOfSize:kFontSize]];
282
+ [messageLabel setLineBreakMode:UILineBreakModeWordWrap];
283
+ [messageLabel setTextColor:[UIColor whiteColor]];
284
+ [messageLabel setTextAlignment:UITextAlignmentCenter];
285
+ [messageLabel setBackgroundColor:[UIColor clearColor]];
286
+ [messageLabel setAlpha:1.0];
287
+ [messageLabel setText:message];
288
+
289
+ // size the message label according to the length of the text
290
+ CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth,
291
+ self.bounds.size.height * kMaxHeight);
292
+ CGSize expectedSizeMessage = [message sizeWithFont:messageLabel.font
293
+ constrainedToSize:maxSizeMessage
294
+ lineBreakMode:messageLabel.lineBreakMode];
295
+ [messageLabel
296
+ setFrame:CGRectMake(0, 0, expectedSizeMessage.width, expectedSizeMessage.height)];
297
+ }
298
+
299
+ // titleLabel frame values
300
+ float titleWidth, titleHeight, titleTop, titleLeft;
301
+
302
+ if (titleLabel != nil)
303
+ {
304
+ titleWidth = titleLabel.bounds.size.width;
305
+ titleHeight = titleLabel.bounds.size.height;
306
+ titleTop = kVerticalPadding;
307
+ titleLeft = imageLeft + imageWidth + kHorizontalPadding;
308
+ }
309
+ else
310
+ {
311
+ titleWidth = titleHeight = titleTop = titleLeft = 0;
312
+ }
313
+
314
+ // messageLabel frame values
315
+ float messageWidth, messageHeight, messageLeft, messageTop;
316
+
317
+ if (messageLabel != nil)
318
+ {
319
+ messageWidth = messageLabel.bounds.size.width;
320
+ messageHeight = messageLabel.bounds.size.height;
321
+ messageLeft = imageLeft + imageWidth + kHorizontalPadding;
322
+ messageTop = titleTop + titleHeight + kVerticalPadding;
323
+ }
324
+ else
325
+ {
326
+ messageWidth = messageHeight = messageLeft = messageTop = 0;
327
+ }
328
+
329
+ // compare the title & message widths and use the longer value to calculate the size of the
330
+ // wrapper width the same logic applies to the x value (left)
331
+ float longerWidth = (messageWidth < titleWidth) ? titleWidth : messageWidth;
332
+ float longerLeft = (messageLeft < titleLeft) ? titleLeft : messageLeft;
333
+
334
+ // if the image width is larger than longerWidth, use the image width to calculate the wrapper
335
+ // width. the same logic applies to the wrapper height
336
+ float wrapperWidth =
337
+ ((longerLeft + longerWidth + kHorizontalPadding) < imageWidth + (kHorizontalPadding * 2))
338
+ ? imageWidth + (kHorizontalPadding * 2)
339
+ : (longerLeft + longerWidth + kHorizontalPadding);
340
+ float wrapperHeight =
341
+ ((messageTop + messageHeight + kVerticalPadding) < imageHeight + (kVerticalPadding * 2))
342
+ ? imageHeight + (kVerticalPadding * 2)
343
+ : (messageTop + messageHeight + kVerticalPadding);
344
+
345
+ [wrapperView setFrame:CGRectMake(0, 0, wrapperWidth, wrapperHeight)];
346
+
347
+ if (titleLabel != nil)
348
+ {
349
+ [titleLabel setFrame:CGRectMake(titleLeft, titleTop, titleWidth, titleHeight)];
350
+ [wrapperView addSubview:titleLabel];
351
+ }
352
+
353
+ if (messageLabel != nil)
354
+ {
355
+ [messageLabel setFrame:CGRectMake(messageLeft, messageTop, messageWidth, messageHeight)];
356
+ [wrapperView addSubview:messageLabel];
357
+ }
358
+
359
+ if (imageView != nil)
360
+ {
361
+ [wrapperView addSubview:imageView];
362
+ }
363
+
364
+ return wrapperView;
365
+ }
366
+
367
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/AppDelegate.m ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ App delegate
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "AppDelegate.h"
12
+
13
+ #import "AboutController.h"
14
+ #import "HelpController.h"
15
+ #import "BookmarkListController.h"
16
+ #import "AppSettingsController.h"
17
+ #import "MainTabBarController.h"
18
+ #import "Utils.h"
19
+
20
+ @implementation AppDelegate
21
+
22
+ @synthesize window = _window, tabBarController = _tabBarController;
23
+
24
+ - (BOOL)application:(UIApplication *)application
25
+ didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
26
+ {
27
+ // Set default values for most NSUserDefaults
28
+ [[NSUserDefaults standardUserDefaults]
29
+ registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]
30
+ pathForResource:@"Defaults"
31
+ ofType:@"plist"]]];
32
+
33
+ // init global settings
34
+ SetSwapMouseButtonsFlag(
35
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]);
36
+ SetInvertScrollingFlag(
37
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]);
38
+
39
+ // create bookmark view and navigation controller
40
+ BookmarkListController *bookmarkListController =
41
+ [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView"
42
+ bundle:nil] autorelease];
43
+ UINavigationController *bookmarkNavigationController = [[[UINavigationController alloc]
44
+ initWithRootViewController:bookmarkListController] autorelease];
45
+
46
+ // create app settings view and navigation controller
47
+ AppSettingsController *appSettingsController =
48
+ [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
49
+ UINavigationController *appSettingsNavigationController = [[[UINavigationController alloc]
50
+ initWithRootViewController:appSettingsController] autorelease];
51
+
52
+ // create help view controller
53
+ HelpController *helpViewController = [[[HelpController alloc] initWithNibName:nil
54
+ bundle:nil] autorelease];
55
+
56
+ // create about view controller
57
+ AboutController *aboutViewController =
58
+ [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease];
59
+
60
+ // add tab-bar controller to the main window and display everything
61
+ NSArray *tabItems =
62
+ [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController,
63
+ helpViewController, aboutViewController, nil];
64
+ [_tabBarController setViewControllers:tabItems];
65
+ if ([_window respondsToSelector:@selector(setRootViewController:)])
66
+ [_window setRootViewController:_tabBarController];
67
+ else
68
+ [_window addSubview:[_tabBarController view]];
69
+ [_window makeKeyAndVisible];
70
+
71
+ return YES;
72
+ }
73
+
74
+ - (void)applicationWillResignActive:(UIApplication *)application
75
+ {
76
+ /*
77
+ Sent when the application is about to move from active to inactive state. This can occur for
78
+ certain types of temporary interruptions (such as an incoming phone call or SMS message) or
79
+ when the user quits the application and it begins the transition to the background state. Use
80
+ this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
81
+ Games should use this method to pause the game.
82
+ */
83
+ }
84
+
85
+ - (void)applicationDidEnterBackground:(UIApplication *)application
86
+ {
87
+ /*
88
+ Use this method to release shared resources, save user data, invalidate timers, and store
89
+ enough application state information to restore your application to its current state in case
90
+ it is terminated later. If your application supports background execution, this method is
91
+ called instead of applicationWillTerminate: when the user quits.
92
+ */
93
+ }
94
+
95
+ - (void)applicationWillEnterForeground:(UIApplication *)application
96
+ {
97
+ /*
98
+ Called as part of the transition from the background to the inactive state; here you can undo
99
+ many of the changes made on entering the background.
100
+ */
101
+ // cancel disconnect timer
102
+ }
103
+
104
+ - (void)applicationDidBecomeActive:(UIApplication *)application
105
+ {
106
+ /*
107
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If
108
+ the application was previously in the background, optionally refresh the user interface.
109
+ */
110
+ }
111
+
112
+ - (void)applicationWillTerminate:(UIApplication *)application
113
+ {
114
+ /*
115
+ Called when the application is about to terminate.
116
+ Save data if appropriate.
117
+ See also applicationDidEnterBackground:.
118
+ */
119
+ }
120
+
121
+ - (void)dealloc
122
+ {
123
+ [_window release];
124
+ [super dealloc];
125
+ }
126
+
127
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AboutController.h ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Application info controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+
13
+ @interface AboutController : UIViewController <UIWebViewDelegate>
14
+ {
15
+ NSString *last_link_clicked;
16
+ UIWebView *webView;
17
+ }
18
+
19
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AboutController.m ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Application info controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "AboutController.h"
12
+ #import "Utils.h"
13
+ #import "BlockAlertView.h"
14
+
15
+ @implementation AboutController
16
+
17
+ // The designated initializer. Override if you create the controller programmatically and want to
18
+ // perform customization that is not appropriate for viewDidLoad.
19
+ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
20
+ {
21
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
22
+ {
23
+
24
+ // set title and tab-bar image
25
+ [self setTitle:NSLocalizedString(@"About", @"About Controller title")];
26
+ UIImage *tabBarIcon = [UIImage
27
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about"
28
+ ofType:@"png"]];
29
+ [self setTabBarItem:[[[UITabBarItem alloc]
30
+ initWithTitle:NSLocalizedString(@"About", @"Tabbar item about")
31
+ image:tabBarIcon
32
+ tag:0] autorelease]];
33
+
34
+ last_link_clicked = nil;
35
+ }
36
+ return self;
37
+ }
38
+
39
+ - (void)dealloc
40
+ {
41
+ [super dealloc];
42
+ [last_link_clicked release];
43
+ }
44
+
45
+ // Implement loadView to create a view hierarchy programmatically, without using a nib.
46
+ - (void)loadView
47
+ {
48
+ webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
49
+ [webView
50
+ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
51
+ [webView setAutoresizesSubviews:YES];
52
+ [webView setDelegate:self];
53
+ [webView setDataDetectorTypes:UIDataDetectorTypeNone];
54
+ [self setView:webView];
55
+ }
56
+
57
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
58
+ - (void)viewDidLoad
59
+ {
60
+ [super viewDidLoad];
61
+
62
+ NSString *filename = (IsPhone() ? @"about_phone" : @"about");
63
+ NSString *htmlString = [[[NSString alloc]
64
+ initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
65
+ ofType:@"html"
66
+ inDirectory:@"about_page"]
67
+ encoding:NSUTF8StringEncoding
68
+ error:nil] autorelease];
69
+
70
+ [webView
71
+ loadHTMLString:[NSString stringWithFormat:htmlString, TSXAppFullVersion(),
72
+ [[UIDevice currentDevice] systemName],
73
+ [[UIDevice currentDevice] systemVersion],
74
+ [[UIDevice currentDevice] model]]
75
+ baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
76
+ stringByAppendingPathComponent:@"about_page"]]];
77
+ }
78
+
79
+ // Override to allow orientations other than the default portrait orientation.
80
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
81
+ {
82
+ return YES;
83
+ }
84
+
85
+ #pragma mark -
86
+ #pragma mark UIWebView callbacks
87
+ - (BOOL)webView:(UIWebView *)webView
88
+ shouldStartLoadWithRequest:(NSURLRequest *)request
89
+ navigationType:(UIWebViewNavigationType)navigationType
90
+ {
91
+ if ([[request URL] isFileURL])
92
+ return YES;
93
+
94
+ if (navigationType == UIWebViewNavigationTypeLinkClicked)
95
+ {
96
+ [last_link_clicked release];
97
+ last_link_clicked = [[[request URL] absoluteString] retain];
98
+ BlockAlertView *alert = [BlockAlertView
99
+ alertWithTitle:NSLocalizedString(@"External Link", @"External Link Alert Title")
100
+ message:[NSString stringWithFormat:
101
+ NSLocalizedString(
102
+ @"Open [%@] in Browser?",
103
+ @"Open link in browser (with link as parameter)"),
104
+ last_link_clicked]];
105
+
106
+ [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
107
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK Button")
108
+ block:^{
109
+ [[UIApplication sharedApplication]
110
+ openURL:[NSURL URLWithString:last_link_clicked]];
111
+ }];
112
+
113
+ [alert show];
114
+
115
+ return NO;
116
+ }
117
+ return YES;
118
+ }
119
+
120
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AdvancedBookmarkEditorController.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to edit advanced bookmark settings
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @class ComputerBookmark;
14
+ @class ConnectionParams;
15
+
16
+ @interface AdvancedBookmarkEditorController : EditorBaseController
17
+ {
18
+ @private
19
+ ComputerBookmark *_bookmark;
20
+ ConnectionParams *_params;
21
+ }
22
+
23
+ // init for the given bookmark
24
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark;
25
+
26
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AdvancedBookmarkEditorController.m ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to edit advanced bookmark settings
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "AdvancedBookmarkEditorController.h"
12
+ #import "Bookmark.h"
13
+ #import "Utils.h"
14
+ #import "EditorSelectionController.h"
15
+ #import "ScreenSelectionController.h"
16
+ #import "PerformanceEditorController.h"
17
+ #import "BookmarkGatewaySettingsController.h"
18
+
19
+ @interface AdvancedBookmarkEditorController ()
20
+
21
+ @end
22
+
23
+ #define SECTION_ADVANCED_SETTINGS 0
24
+ #define SECTION_COUNT 1
25
+
26
+ @implementation AdvancedBookmarkEditorController
27
+
28
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark
29
+ {
30
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
31
+ {
32
+ // set additional settings state according to bookmark data
33
+ _bookmark = [bookmark retain];
34
+ _params = [bookmark params];
35
+ }
36
+ return self;
37
+ }
38
+
39
+ - (void)viewDidLoad
40
+ {
41
+ [super viewDidLoad];
42
+ [self setTitle:NSLocalizedString(@"Advanced Settings", @"Advanced Settings title")];
43
+ }
44
+
45
+ - (void)viewWillAppear:(BOOL)animated
46
+ {
47
+ [super viewWillAppear:animated];
48
+
49
+ // we need to reload the table view data here to have up-to-date data for the
50
+ // advanced settings accessory items (like for resolution/color mode settings)
51
+ [[self tableView] reloadData];
52
+ }
53
+
54
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
55
+ {
56
+ return YES;
57
+ }
58
+
59
+ #pragma mark -
60
+ #pragma mark Table view data source
61
+
62
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
63
+ {
64
+ // Return the number of sections.
65
+ return SECTION_COUNT;
66
+ }
67
+
68
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
69
+ {
70
+ // Return the number of rows in the section.
71
+ switch (section)
72
+ {
73
+ case SECTION_ADVANCED_SETTINGS: // advanced settings
74
+ return 9;
75
+ default:
76
+ break;
77
+ }
78
+
79
+ return 0;
80
+ }
81
+
82
+ // set section headers
83
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
84
+ {
85
+ switch (section)
86
+ {
87
+ case SECTION_ADVANCED_SETTINGS:
88
+ return NSLocalizedString(@"Advanced", @"'Advanced': advanced settings header");
89
+ }
90
+ return @"unknown";
91
+ }
92
+
93
+ // Customize the appearance of table view cells.
94
+ - (UITableViewCell *)tableView:(UITableView *)tableView
95
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
96
+ {
97
+
98
+ // determine the required cell type
99
+ NSString *cellType = nil;
100
+ switch ([indexPath section])
101
+ {
102
+ case SECTION_ADVANCED_SETTINGS: // advanced settings
103
+ {
104
+ switch ([indexPath row])
105
+ {
106
+ case 0: // Enable/Disable TSG Settings
107
+ cellType = TableCellIdentifierYesNo;
108
+ break;
109
+ case 1: // TS Gateway Settings
110
+ cellType = TableCellIdentifierSubEditor;
111
+ break;
112
+ case 2: // 3G Settings
113
+ cellType = TableCellIdentifierYesNo;
114
+ break;
115
+ case 3: // 3G screen/color depth
116
+ cellType = TableCellIdentifierSelection;
117
+ break;
118
+ case 4: // 3G performance settings
119
+ cellType = TableCellIdentifierSubEditor;
120
+ break;
121
+ case 5: // security mode
122
+ cellType = TableCellIdentifierSelection;
123
+ break;
124
+ case 6: // remote program
125
+ case 7: // work dir
126
+ cellType = TableCellIdentifierText;
127
+ break;
128
+ case 8: // console mode
129
+ cellType = TableCellIdentifierYesNo;
130
+ break;
131
+ default:
132
+ break;
133
+ }
134
+ break;
135
+ }
136
+ }
137
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
138
+
139
+ // get the table view cell
140
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
141
+ NSAssert(cell, @"Invalid cell");
142
+
143
+ // set cell values
144
+ switch ([indexPath section])
145
+ {
146
+ // advanced settings
147
+ case SECTION_ADVANCED_SETTINGS:
148
+ [self initAdvancedSettings:indexPath cell:cell];
149
+ break;
150
+
151
+ default:
152
+ break;
153
+ }
154
+
155
+ return cell;
156
+ }
157
+
158
+ // updates advanced settings in the UI
159
+ - (void)initAdvancedSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
160
+ {
161
+ BOOL enable_3G_settings = [_params boolForKey:@"enable_3g_settings"];
162
+ switch (indexPath.row)
163
+ {
164
+ case 0:
165
+ {
166
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
167
+ [[flagCell label]
168
+ setText:NSLocalizedString(@"Enable TS Gateway",
169
+ @"'Enable TS Gateway': Bookmark enable TSG settings")];
170
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
171
+ [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]];
172
+ [[flagCell toggle] addTarget:self
173
+ action:@selector(toggleSettingValue:)
174
+ forControlEvents:UIControlEventValueChanged];
175
+ break;
176
+ }
177
+ case 1:
178
+ {
179
+ BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"];
180
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
181
+ [[editCell label]
182
+ setText:NSLocalizedString(@"TS Gateway Settings",
183
+ @"'TS Gateway Settings': Bookmark TS Gateway Settings")];
184
+ [[editCell label] setEnabled:enable_tsg_settings];
185
+ [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue
186
+ : UITableViewCellSelectionStyleNone];
187
+ break;
188
+ }
189
+ case 2:
190
+ {
191
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
192
+ [[flagCell label]
193
+ setText:NSLocalizedString(@"3G Settings",
194
+ @"'3G Settings': Bookmark enable 3G settings")];
195
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
196
+ [[flagCell toggle] setOn:[_params boolForKey:@"enable_3g_settings"]];
197
+ [[flagCell toggle] addTarget:self
198
+ action:@selector(toggleSettingValue:)
199
+ forControlEvents:UIControlEventValueChanged];
200
+ break;
201
+ }
202
+ case 3:
203
+ {
204
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
205
+ [[selCell label]
206
+ setText:NSLocalizedString(@"3G Screen",
207
+ @"'3G Screen': Bookmark 3G Screen settings")];
208
+ NSString *resolution = ScreenResolutionDescription(
209
+ [_params intForKeyPath:@"settings_3g.screen_resolution_type"],
210
+ [_params intForKeyPath:@"settings_3g.width"],
211
+ [_params intForKeyPath:@"settings_3g.height"]);
212
+ int colorBits = [_params intForKeyPath:@"settings_3g.colors"];
213
+ [[selCell selection]
214
+ setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
215
+ [[selCell label] setEnabled:enable_3G_settings];
216
+ [[selCell selection] setEnabled:enable_3G_settings];
217
+ [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue
218
+ : UITableViewCellSelectionStyleNone];
219
+ break;
220
+ }
221
+ case 4:
222
+ {
223
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
224
+ [[editCell label]
225
+ setText:NSLocalizedString(@"3G Performance",
226
+ @"'3G Performance': Bookmark 3G Performance Settings")];
227
+ [[editCell label] setEnabled:enable_3G_settings];
228
+ [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue
229
+ : UITableViewCellSelectionStyleNone];
230
+ break;
231
+ }
232
+ case 5:
233
+ {
234
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
235
+ [[selCell label]
236
+ setText:NSLocalizedString(@"Security",
237
+ @"'Security': Bookmark protocol security settings")];
238
+ [[selCell selection]
239
+ setText:ProtocolSecurityDescription([_params intForKey:@"security"])];
240
+ break;
241
+ }
242
+ case 6:
243
+ {
244
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
245
+ [[textCell label]
246
+ setText:NSLocalizedString(@"Remote Program",
247
+ @"'Remote Program': Bookmark remote program settings")];
248
+ [[textCell textfield] setText:[_params StringForKey:@"remote_program"]];
249
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
250
+ [[textCell textfield]
251
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
252
+ [self adjustEditTextTableViewCell:textCell];
253
+ break;
254
+ }
255
+ case 7:
256
+ {
257
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
258
+ [[textCell label]
259
+ setText:NSLocalizedString(
260
+ @"Working Directory",
261
+ @"'Working Directory': Bookmark working directory settings")];
262
+ [[textCell textfield] setText:[_params StringForKey:@"working_dir"]];
263
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
264
+ [[textCell textfield]
265
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
266
+ [self adjustEditTextTableViewCell:textCell];
267
+ break;
268
+ }
269
+ case 8:
270
+ {
271
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
272
+ [[flagCell label]
273
+ setText:NSLocalizedString(@"Console Mode",
274
+ @"'Console Mode': Bookmark console mode settings")];
275
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
276
+ [[flagCell toggle] setOn:[_params boolForKey:@"console"]];
277
+ [[flagCell toggle] addTarget:self
278
+ action:@selector(toggleSettingValue:)
279
+ forControlEvents:UIControlEventValueChanged];
280
+ break;
281
+ }
282
+ default:
283
+ NSLog(@"Invalid row index in settings table!");
284
+ break;
285
+ }
286
+ }
287
+
288
+ #pragma mark -
289
+ #pragma mark Table view delegate
290
+
291
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
292
+ {
293
+ UIViewController *viewCtrl = nil;
294
+
295
+ // determine view
296
+ switch ([indexPath row])
297
+ {
298
+ case 1:
299
+ if ([_params boolForKey:@"enable_tsg_settings"])
300
+ viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark]
301
+ autorelease];
302
+ break;
303
+ case 3:
304
+ if ([_params boolForKey:@"enable_3g_settings"])
305
+ viewCtrl = [[[ScreenSelectionController alloc]
306
+ initWithConnectionParams:_params
307
+ keyPath:@"settings_3g"] autorelease];
308
+ break;
309
+ case 4:
310
+ if ([_params boolForKey:@"enable_3g_settings"])
311
+ viewCtrl = [[[PerformanceEditorController alloc]
312
+ initWithConnectionParams:_params
313
+ keyPath:@"settings_3g"] autorelease];
314
+ break;
315
+ case 5:
316
+ viewCtrl = [[[EditorSelectionController alloc]
317
+ initWithConnectionParams:_params
318
+ entries:[NSArray arrayWithObject:@"security"]
319
+ selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]]
320
+ autorelease];
321
+ break;
322
+ default:
323
+ break;
324
+ }
325
+
326
+ // display view
327
+ if (viewCtrl)
328
+ [[self navigationController] pushViewController:viewCtrl animated:YES];
329
+ }
330
+
331
+ #pragma mark -
332
+ #pragma mark Text Field delegate
333
+
334
+ - (BOOL)textFieldShouldReturn:(UITextField *)textField
335
+ {
336
+ [textField resignFirstResponder];
337
+ return NO;
338
+ }
339
+
340
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
341
+ {
342
+ switch (textField.tag)
343
+ {
344
+ // update remote program/work dir settings
345
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 6):
346
+ {
347
+ [_params setValue:[textField text] forKey:@"remote_program"];
348
+ break;
349
+ }
350
+
351
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 7):
352
+ {
353
+ [_params setValue:[textField text] forKey:@"working_dir"];
354
+ break;
355
+ }
356
+
357
+ default:
358
+ break;
359
+ }
360
+ return YES;
361
+ }
362
+
363
+ #pragma mark - Action handlers
364
+
365
+ - (void)toggleSettingValue:(id)sender
366
+ {
367
+ UISwitch *valueSwitch = (UISwitch *)sender;
368
+ switch (valueSwitch.tag)
369
+ {
370
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 0):
371
+ {
372
+ [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"];
373
+ NSArray *indexPaths =
374
+ [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1
375
+ inSection:SECTION_ADVANCED_SETTINGS],
376
+ [NSIndexPath indexPathForRow:2
377
+ inSection:SECTION_ADVANCED_SETTINGS],
378
+ nil];
379
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
380
+ withRowAnimation:UITableViewRowAnimationNone];
381
+ break;
382
+ }
383
+
384
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 2):
385
+ {
386
+ [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"];
387
+ NSArray *indexPaths =
388
+ [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3
389
+ inSection:SECTION_ADVANCED_SETTINGS],
390
+ [NSIndexPath indexPathForRow:2
391
+ inSection:SECTION_ADVANCED_SETTINGS],
392
+ nil];
393
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
394
+ withRowAnimation:UITableViewRowAnimationNone];
395
+ break;
396
+ }
397
+
398
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 8):
399
+ [_params setBool:[valueSwitch isOn] forKey:@"console"];
400
+ break;
401
+
402
+ default:
403
+ break;
404
+ }
405
+ }
406
+
407
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AppSettingsController.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to specify application wide settings
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @interface AppSettingsController : EditorBaseController
14
+
15
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/AppSettingsController.m ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to specify application wide settings
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "AppSettingsController.h"
12
+ #import "Utils.h"
13
+ #import "Toast+UIView.h"
14
+
15
+ @implementation AppSettingsController
16
+
17
+ // keep this up-to-date for correct section display/hiding
18
+ #define SECTION_UI_SETTINGS 0
19
+ #define SECTION_CERTIFICATE_HANDLING_SETTINGS 1
20
+ #define SECTION_NUM_SECTIONS 2
21
+
22
+ #pragma mark -
23
+ #pragma mark Initialization
24
+
25
+ - (id)initWithStyle:(UITableViewStyle)style
26
+ {
27
+ if ((self = [super initWithStyle:style]))
28
+ {
29
+ UIImage *tabBarIcon = [UIImage
30
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_settings"
31
+ ofType:@"png"]];
32
+ [self
33
+ setTabBarItem:[[[UITabBarItem alloc]
34
+ initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings")
35
+ image:tabBarIcon
36
+ tag:0] autorelease]];
37
+ }
38
+ return self;
39
+ }
40
+
41
+ #pragma mark -
42
+ #pragma mark View lifecycle
43
+
44
+ - (void)viewDidLoad
45
+ {
46
+ [super viewDidLoad];
47
+
48
+ // set title
49
+ [self setTitle:NSLocalizedString(@"Settings", @"App Settings title")];
50
+ }
51
+
52
+ - (void)viewWillDisappear:(BOOL)animated
53
+ {
54
+ [super viewWillDisappear:animated];
55
+ }
56
+
57
+ // Override to allow orientations other than the default portrait orientation.
58
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
59
+ {
60
+ return YES;
61
+ }
62
+
63
+ - (void)dealloc
64
+ {
65
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
66
+ [super dealloc];
67
+ }
68
+
69
+ #pragma mark -
70
+ #pragma mark Table view data source
71
+
72
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
73
+ {
74
+ // Return the number of sections.
75
+ return SECTION_NUM_SECTIONS;
76
+ }
77
+
78
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
79
+ {
80
+ // Return the number of rows in the section.
81
+ switch (section)
82
+ {
83
+ case SECTION_UI_SETTINGS: // UI settings
84
+ return 5;
85
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS: // certificate handling settings
86
+ return 2;
87
+ default:
88
+ break;
89
+ }
90
+
91
+ return 0;
92
+ }
93
+
94
+ // set section headers
95
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
96
+ {
97
+ switch (section)
98
+ {
99
+ case SECTION_UI_SETTINGS:
100
+ return NSLocalizedString(@"User Interface", @"UI settings section title");
101
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
102
+ return NSLocalizedString(@"Server Certificate Handling",
103
+ @"Server Certificate Handling section title");
104
+ default:
105
+ return nil;
106
+ }
107
+ return @"unknown";
108
+ }
109
+
110
+ // Customize the appearance of table view cells.
111
+ - (UITableViewCell *)tableView:(UITableView *)tableView
112
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
113
+ {
114
+
115
+ // determine the required cell type
116
+ NSString *cellIdentifier = nil;
117
+ switch ([indexPath section])
118
+ {
119
+ case SECTION_UI_SETTINGS:
120
+ {
121
+ switch ([indexPath row])
122
+ {
123
+ case 0:
124
+ case 1:
125
+ case 2:
126
+ case 3:
127
+ case 4:
128
+ cellIdentifier = TableCellIdentifierYesNo;
129
+ break;
130
+ }
131
+ break;
132
+ }
133
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
134
+ {
135
+ switch ([indexPath row])
136
+ {
137
+ case 0:
138
+ cellIdentifier = TableCellIdentifierYesNo;
139
+ break;
140
+ case 1:
141
+ cellIdentifier = TableCellIdentifierSubEditor;
142
+ break;
143
+ }
144
+ break;
145
+ }
146
+ }
147
+ NSAssert(cellIdentifier != nil, @"Couldn't determine cell type");
148
+
149
+ // get the table view cell
150
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellIdentifier];
151
+ NSAssert(cell, @"Invalid cell");
152
+
153
+ // set cell values
154
+ switch ([indexPath section])
155
+ {
156
+ case SECTION_UI_SETTINGS:
157
+ [self initUISettings:indexPath cell:cell];
158
+ break;
159
+
160
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
161
+ [self initCertificateHandlingSettings:indexPath cell:cell];
162
+ break;
163
+
164
+ default:
165
+ break;
166
+ }
167
+
168
+ return cell;
169
+ }
170
+
171
+ #pragma mark - Initialization helpers
172
+
173
+ // updates UI settings in the UI
174
+ - (void)initUISettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
175
+ {
176
+ switch ([indexPath row])
177
+ {
178
+ case 0:
179
+ {
180
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
181
+ [[flagCell label] setText:NSLocalizedString(@"Hide Status Bar",
182
+ "Show/Hide Phone Status Bar setting")];
183
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
184
+ [[flagCell toggle]
185
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"]];
186
+ [[flagCell toggle] addTarget:self
187
+ action:@selector(toggleSettingValue:)
188
+ forControlEvents:UIControlEventValueChanged];
189
+ break;
190
+ }
191
+ case 1:
192
+ {
193
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
194
+ [[flagCell label]
195
+ setText:NSLocalizedString(@"Hide Tool Bar", "Show/Hide Tool Bar setting")];
196
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
197
+ [[flagCell toggle]
198
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
199
+ [[flagCell toggle] addTarget:self
200
+ action:@selector(toggleSettingValue:)
201
+ forControlEvents:UIControlEventValueChanged];
202
+ break;
203
+ }
204
+ case 2:
205
+ {
206
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
207
+ [[flagCell label]
208
+ setText:NSLocalizedString(@"Swap Mouse Buttons", "Swap Mouse Button UI setting")];
209
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
210
+ [[flagCell toggle]
211
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]];
212
+ [[flagCell toggle] addTarget:self
213
+ action:@selector(toggleSettingValue:)
214
+ forControlEvents:UIControlEventValueChanged];
215
+ break;
216
+ }
217
+ case 3:
218
+ {
219
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
220
+ [[flagCell label]
221
+ setText:NSLocalizedString(@"Invert Scrolling", "Invert Scrolling UI setting")];
222
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
223
+ [[flagCell toggle]
224
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]];
225
+ [[flagCell toggle] addTarget:self
226
+ action:@selector(toggleSettingValue:)
227
+ forControlEvents:UIControlEventValueChanged];
228
+ break;
229
+ }
230
+ case 4:
231
+ {
232
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
233
+ [[flagCell label] setText:NSLocalizedString(@"Touch Pointer Auto Scroll",
234
+ "Touch Pointer Auto Scroll UI setting")];
235
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
236
+ [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults]
237
+ boolForKey:@"ui.auto_scroll_touchpointer"]];
238
+ [[flagCell toggle] addTarget:self
239
+ action:@selector(toggleSettingValue:)
240
+ forControlEvents:UIControlEventValueChanged];
241
+ break;
242
+ }
243
+ default:
244
+ NSLog(@"Invalid row index in settings table!");
245
+ break;
246
+ }
247
+ }
248
+
249
+ // updates certificate handling settings in the UI
250
+ - (void)initCertificateHandlingSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
251
+ {
252
+ switch ([indexPath row])
253
+ {
254
+ case 0:
255
+ {
256
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
257
+ [[flagCell label] setText:NSLocalizedString(@"Accept all Certificates",
258
+ "Accept All Certificates setting")];
259
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
260
+ [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults]
261
+ boolForKey:@"security.accept_certificates"]];
262
+ [[flagCell toggle] addTarget:self
263
+ action:@selector(toggleSettingValue:)
264
+ forControlEvents:UIControlEventValueChanged];
265
+ break;
266
+ }
267
+ case 1:
268
+ {
269
+ EditSubEditTableViewCell *subCell = (EditSubEditTableViewCell *)cell;
270
+ [[subCell label] setText:NSLocalizedString(@"Erase Certificate Cache",
271
+ @"Erase certificate cache button")];
272
+ break;
273
+ }
274
+ default:
275
+ NSLog(@"Invalid row index in settings table!");
276
+ break;
277
+ }
278
+ }
279
+
280
+ #pragma mark -
281
+ #pragma mark Table view delegate
282
+
283
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
284
+ {
285
+
286
+ // deselect any row to fake a button-pressed like effect
287
+ [tableView deselectRowAtIndexPath:indexPath animated:YES];
288
+
289
+ // ensure everything is stored in our settings before we proceed
290
+ [[self view] endEditing:NO];
291
+
292
+ // clear certificate cache
293
+ if ([indexPath section] == SECTION_CERTIFICATE_HANDLING_SETTINGS && [indexPath row] == 1)
294
+ {
295
+ // delete certificates cache
296
+ NSError *err;
297
+ if ([[NSFileManager defaultManager]
298
+ removeItemAtPath:[[NSSearchPathForDirectoriesInDomains(
299
+ NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
300
+ stringByAppendingPathComponent:@"/.freerdp"]
301
+ error:&err])
302
+ [[self view] makeToast:NSLocalizedString(@"Certificate Cache cleared!",
303
+ @"Clear Certificate cache success message")
304
+ duration:ToastDurationNormal
305
+ position:@"center"];
306
+ else
307
+ [[self view] makeToast:NSLocalizedString(@"Error clearing the Certificate Cache!",
308
+ @"Clear Certificate cache failed message")
309
+ duration:ToastDurationNormal
310
+ position:@"center"];
311
+ }
312
+ }
313
+
314
+ #pragma mark -
315
+ #pragma mark Action Handlers
316
+
317
+ - (void)toggleSettingValue:(id)sender
318
+ {
319
+ UISwitch *valueSwitch = (UISwitch *)sender;
320
+ switch ([valueSwitch tag])
321
+ {
322
+ case GET_TAG(SECTION_UI_SETTINGS, 0):
323
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
324
+ forKey:@"ui.hide_status_bar"];
325
+ break;
326
+
327
+ case GET_TAG(SECTION_UI_SETTINGS, 1):
328
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
329
+ forKey:@"ui.hide_tool_bar"];
330
+ break;
331
+
332
+ case GET_TAG(SECTION_UI_SETTINGS, 2):
333
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
334
+ forKey:@"ui.swap_mouse_buttons"];
335
+ SetSwapMouseButtonsFlag([valueSwitch isOn]);
336
+ break;
337
+
338
+ case GET_TAG(SECTION_UI_SETTINGS, 3):
339
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
340
+ forKey:@"ui.invert_scrolling"];
341
+ SetInvertScrollingFlag([valueSwitch isOn]);
342
+ break;
343
+
344
+ case GET_TAG(SECTION_UI_SETTINGS, 4):
345
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
346
+ forKey:@"ui.auto_scroll_touchpointer"];
347
+ SetInvertScrollingFlag([valueSwitch isOn]);
348
+ break;
349
+
350
+ case GET_TAG(SECTION_CERTIFICATE_HANDLING_SETTINGS, 0):
351
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
352
+ forKey:@"security.accept_certificates"];
353
+ break;
354
+
355
+ default:
356
+ break;
357
+ }
358
+ }
359
+
360
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkEditorController.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Bookmark editor controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+ #import "EditorBaseController.h"
13
+
14
+ @class ComputerBookmark;
15
+ @class ConnectionParams;
16
+
17
+ @protocol BookmarkEditorDelegate <NSObject>
18
+ // bookmark editing finished
19
+ - (void)commitBookmark:(ComputerBookmark *)bookmark;
20
+ @end
21
+
22
+ @interface BookmarkEditorController : EditorBaseController
23
+ {
24
+ @private
25
+ ComputerBookmark *_bookmark;
26
+ ConnectionParams *_params;
27
+
28
+ BOOL _display_server_settings;
29
+
30
+ id<BookmarkEditorDelegate> delegate;
31
+ }
32
+
33
+ @property(nonatomic, assign) id<BookmarkEditorDelegate> delegate;
34
+
35
+ // init for the given bookmark
36
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark;
37
+
38
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkEditorController.m ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Bookmark editor controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "BookmarkEditorController.h"
12
+ #import "Bookmark.h"
13
+ #import "Utils.h"
14
+ #import "ScreenSelectionController.h"
15
+ #import "PerformanceEditorController.h"
16
+ #import "CredentialsEditorController.h"
17
+ #import "AdvancedBookmarkEditorController.h"
18
+ #import "BlockAlertView.h"
19
+
20
+ @implementation BookmarkEditorController
21
+
22
+ @synthesize delegate;
23
+
24
+ #define SECTION_SERVER 0
25
+ #define SECTION_CREDENTIALS 1
26
+ #define SECTION_SETTINGS 2
27
+ #define SECTION_COUNT 3
28
+
29
+ #pragma mark -
30
+ #pragma mark Initialization
31
+
32
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark
33
+ {
34
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
35
+ {
36
+ // set additional settings state according to bookmark data
37
+ if ([[bookmark uuid] length] == 0)
38
+ _bookmark = [bookmark copy];
39
+ else
40
+ _bookmark = [bookmark copyWithUUID];
41
+ _params = [_bookmark params];
42
+
43
+ _display_server_settings = YES;
44
+ }
45
+ return self;
46
+ }
47
+
48
+ #pragma mark -
49
+ #pragma mark View lifecycle
50
+
51
+ - (void)viewDidLoad
52
+ {
53
+ [super viewDidLoad];
54
+
55
+ // replace back button with a custom handler that checks if the required bookmark settings were
56
+ // specified
57
+ UIBarButtonItem *saveButton =
58
+ [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", @"Save Button title")
59
+ style:UIBarButtonItemStyleDone
60
+ target:self
61
+ action:@selector(handleSave:)] autorelease];
62
+ UIBarButtonItem *cancelButton =
63
+ [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button title")
64
+ style:UIBarButtonItemStyleBordered
65
+ target:self
66
+ action:@selector(handleCancel:)] autorelease];
67
+ [[self navigationItem] setLeftBarButtonItem:cancelButton];
68
+ [[self navigationItem] setRightBarButtonItem:saveButton];
69
+ }
70
+
71
+ - (void)viewWillAppear:(BOOL)animated
72
+ {
73
+ [super viewWillAppear:animated];
74
+
75
+ // we need to reload the table view data here to have up-to-date data for the
76
+ // advanced settings accessory items (like for resolution/color mode settings)
77
+ [[self tableView] reloadData];
78
+ }
79
+
80
+ // Override to allow orientations other than the default portrait orientation.
81
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
82
+ {
83
+ return YES;
84
+ }
85
+
86
+ #pragma mark -
87
+ #pragma mark Table view data source
88
+
89
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
90
+ {
91
+ // Return the number of sections.
92
+ return SECTION_COUNT;
93
+ }
94
+
95
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
96
+ {
97
+ // Return the number of rows in the section.
98
+ switch (section)
99
+ {
100
+ case SECTION_SERVER: // server settings
101
+ return (_display_server_settings ? 3 : 0);
102
+ case SECTION_CREDENTIALS: // credentials
103
+ return 1;
104
+ case SECTION_SETTINGS: // session settings
105
+ return 3;
106
+ default:
107
+ break;
108
+ }
109
+
110
+ return 0;
111
+ }
112
+
113
+ // set section headers
114
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
115
+ {
116
+ switch (section)
117
+ {
118
+ case SECTION_SERVER:
119
+ return (_display_server_settings
120
+ ? NSLocalizedString(@"Host", @"'Host': host settings header")
121
+ : nil);
122
+ case SECTION_CREDENTIALS:
123
+ return NSLocalizedString(@"Credentials", @"'Credentials': credentials settings header");
124
+ case SECTION_SETTINGS:
125
+ return NSLocalizedString(@"Settings", @"'Session Settings': session settings header");
126
+ }
127
+ return @"unknown";
128
+ }
129
+
130
+ // Customize the appearance of table view cells.
131
+ - (UITableViewCell *)tableView:(UITableView *)tableView
132
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
133
+ {
134
+
135
+ // determine the required cell type
136
+ NSString *cellType = nil;
137
+ switch ([indexPath section])
138
+ {
139
+ case SECTION_SERVER:
140
+ cellType = TableCellIdentifierText;
141
+ break;
142
+
143
+ case SECTION_CREDENTIALS:
144
+ cellType = TableCellIdentifierSelection;
145
+ break;
146
+
147
+ case SECTION_SETTINGS: // settings
148
+ {
149
+ switch ([indexPath row])
150
+ {
151
+ case 0: // screen/color depth
152
+ cellType = TableCellIdentifierSelection;
153
+ break;
154
+ case 1: // performance settings
155
+ case 2: // advanced settings
156
+ cellType = TableCellIdentifierSubEditor;
157
+ break;
158
+ default:
159
+ break;
160
+ }
161
+ }
162
+ break;
163
+
164
+ default:
165
+ break;
166
+ }
167
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
168
+
169
+ // get the table view cell
170
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
171
+ NSAssert(cell, @"Invalid cell");
172
+
173
+ // set cell values
174
+ switch ([indexPath section])
175
+ {
176
+ // server settings
177
+ case SECTION_SERVER:
178
+ [self initServerSettings:indexPath cell:cell];
179
+ break;
180
+
181
+ // credentials
182
+ case SECTION_CREDENTIALS:
183
+ [self initCredentialSettings:indexPath cell:cell];
184
+ break;
185
+
186
+ // session settings
187
+ case SECTION_SETTINGS:
188
+ [self initSettings:indexPath cell:cell];
189
+ break;
190
+
191
+ default:
192
+ break;
193
+ }
194
+
195
+ return cell;
196
+ }
197
+
198
+ // updates server settings in the UI
199
+ - (void)initServerSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
200
+ {
201
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
202
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
203
+ switch ([indexPath row])
204
+ {
205
+ case 0:
206
+ [[textCell label] setText:NSLocalizedString(@"Label", @"'Label': Bookmark label")];
207
+ [[textCell textfield] setText:[_bookmark label]];
208
+ [[textCell textfield]
209
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
210
+ break;
211
+ case 1:
212
+ [[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")];
213
+ [[textCell textfield] setText:[_params StringForKey:@"hostname"]];
214
+ [[textCell textfield]
215
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
216
+ break;
217
+ case 2:
218
+ [[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")];
219
+ [[textCell textfield]
220
+ setText:[NSString stringWithFormat:@"%d", [_params intForKey:@"port"]]];
221
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
222
+ break;
223
+ default:
224
+ NSLog(@"Invalid row index in settings table!");
225
+ break;
226
+ }
227
+
228
+ [self adjustEditTextTableViewCell:textCell];
229
+ }
230
+
231
+ // updates credentials in the UI
232
+ - (void)initCredentialSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
233
+ {
234
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
235
+ switch (indexPath.row)
236
+ {
237
+ case 0:
238
+ [[selCell label]
239
+ setText:NSLocalizedString(@"Credentials", @"'Credentials': Bookmark credentials")];
240
+ [[selCell selection] setText:[_params StringForKey:@"username"]];
241
+ break;
242
+ default:
243
+ NSLog(@"Invalid row index in settings table!");
244
+ break;
245
+ }
246
+ }
247
+
248
+ // updates session settings in the UI
249
+ - (void)initSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
250
+ {
251
+ switch (indexPath.row)
252
+ {
253
+ case 0:
254
+ {
255
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
256
+ [[selCell label]
257
+ setText:NSLocalizedString(@"Screen", @"'Screen': Bookmark Screen settings")];
258
+ NSString *resolution = ScreenResolutionDescription(
259
+ [_params intForKey:@"screen_resolution_type"], [_params intForKey:@"width"],
260
+ [_params intForKey:@"height"]);
261
+ int colorBits = [_params intForKey:@"colors"];
262
+ [[selCell selection]
263
+ setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
264
+ break;
265
+ }
266
+ case 1:
267
+ {
268
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
269
+ [[editCell label]
270
+ setText:NSLocalizedString(@"Performance",
271
+ @"'Performance': Bookmark Performance Settings")];
272
+ break;
273
+ }
274
+ case 2:
275
+ {
276
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
277
+ [[editCell label]
278
+ setText:NSLocalizedString(@"Advanced", @"'Advanced': Bookmark Advanced Settings")];
279
+ break;
280
+ }
281
+ default:
282
+ NSLog(@"Invalid row index in settings table!");
283
+ break;
284
+ }
285
+ }
286
+
287
+ #pragma mark -
288
+ #pragma mark Table view delegate
289
+
290
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
291
+ {
292
+ UIViewController *viewCtrl = nil;
293
+
294
+ // determine view
295
+ switch ([indexPath section])
296
+ {
297
+ case SECTION_CREDENTIALS:
298
+ {
299
+ if ([indexPath row] == 0)
300
+ viewCtrl =
301
+ [[[CredentialsEditorController alloc] initWithBookmark:_bookmark] autorelease];
302
+ break;
303
+ }
304
+
305
+ case SECTION_SETTINGS:
306
+ {
307
+ switch ([indexPath row])
308
+ {
309
+ case 0:
310
+ viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params]
311
+ autorelease];
312
+ break;
313
+ case 1:
314
+ viewCtrl = [[[PerformanceEditorController alloc]
315
+ initWithConnectionParams:_params] autorelease];
316
+ break;
317
+ case 2:
318
+ viewCtrl = [[[AdvancedBookmarkEditorController alloc]
319
+ initWithBookmark:_bookmark] autorelease];
320
+ break;
321
+ default:
322
+ break;
323
+ }
324
+
325
+ break;
326
+ }
327
+ }
328
+
329
+ // display view
330
+ if (viewCtrl)
331
+ [[self navigationController] pushViewController:viewCtrl animated:YES];
332
+ }
333
+
334
+ #pragma mark -
335
+ #pragma mark Text Field delegate
336
+
337
+ - (BOOL)textFieldShouldReturn:(UITextField *)textField
338
+ {
339
+ [textField resignFirstResponder];
340
+ return NO;
341
+ }
342
+
343
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
344
+ {
345
+ switch (textField.tag)
346
+ {
347
+ // update server settings
348
+ case GET_TAG(SECTION_SERVER, 0):
349
+ [_bookmark setLabel:[textField text]];
350
+ break;
351
+
352
+ case GET_TAG(SECTION_SERVER, 1):
353
+ [_params setValue:[textField text] forKey:@"hostname"];
354
+ break;
355
+
356
+ case GET_TAG(SECTION_SERVER, 2):
357
+ [_params setInt:[[textField text] intValue] forKey:@"port"];
358
+ break;
359
+
360
+ default:
361
+ break;
362
+ }
363
+ return YES;
364
+ }
365
+
366
+ #pragma mark -
367
+ #pragma mark Action Handlers
368
+
369
+ - (void)handleSave:(id)sender
370
+ {
371
+ // resign any first responder (so that we finish editing any bookmark parameter that might be
372
+ // currently edited)
373
+ [[self view] endEditing:NO];
374
+
375
+ // verify that bookmark is complete (only for manual bookmarks)
376
+ if ([[_bookmark label] length] == 0 || [[_params StringForKey:@"hostname"] length] == 0 ||
377
+ [_params intForKey:@"port"] == 0)
378
+ {
379
+ BlockAlertView *alertView = [BlockAlertView
380
+ alertWithTitle:NSLocalizedString(@"Cancel without saving?",
381
+ @"Incomplete bookmark error title")
382
+ message:NSLocalizedString(@"Press 'Cancel' to abort!\nPress 'Continue' to "
383
+ @"specify the required fields!",
384
+ @"Incomplete bookmark error message")];
385
+ [alertView
386
+ setCancelButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
387
+ block:^{
388
+ // cancel bookmark editing and return to previous view controller
389
+ [[self navigationController] popViewControllerAnimated:YES];
390
+ }];
391
+ [alertView addButtonWithTitle:NSLocalizedString(@"Continue", @"Continue Button") block:nil];
392
+ [alertView show];
393
+ return;
394
+ }
395
+
396
+ // commit bookmark
397
+ if ([[self delegate] respondsToSelector:@selector(commitBookmark:)])
398
+ [[self delegate] commitBookmark:_bookmark];
399
+
400
+ // return to previous view controller
401
+ [[self navigationController] popViewControllerAnimated:YES];
402
+ }
403
+
404
+ - (void)handleCancel:(id)sender
405
+ {
406
+ // return to previous view controller
407
+ [[self navigationController] popViewControllerAnimated:YES];
408
+ }
409
+
410
+ #pragma mark -
411
+ #pragma mark Memory management
412
+
413
+ - (void)didReceiveMemoryWarning
414
+ {
415
+ // Releases the view if it doesn't have a superview.
416
+ [super didReceiveMemoryWarning];
417
+
418
+ // Relinquish ownership any cached data, images, etc that aren't in use.
419
+ }
420
+
421
+ - (void)dealloc
422
+ {
423
+ [super dealloc];
424
+ [_bookmark autorelease];
425
+ }
426
+
427
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkGatewaySettingsController.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to edit ts gateway bookmark settings
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @class ComputerBookmark;
14
+ @class ConnectionParams;
15
+
16
+ @interface BookmarkGatewaySettingsController : EditorBaseController
17
+ {
18
+ @private
19
+ ComputerBookmark *_bookmark;
20
+ ConnectionParams *_params;
21
+ }
22
+
23
+ // init for the given bookmark
24
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark;
25
+
26
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkGatewaySettingsController.m ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // BookmarkGatewaySettingsController.m
3
+ // FreeRDP
4
+ //
5
+ // Created by a Thincast Developer on 4/30/13.
6
+ //
7
+ //
8
+
9
+ #import "BookmarkGatewaySettingsController.h"
10
+ #import "Bookmark.h"
11
+ #import "Utils.h"
12
+ #import "EditorSelectionController.h"
13
+
14
+ #define SECTION_TSGATEWAY_SETTINGS 0
15
+ #define SECTION_COUNT 1
16
+
17
+ @interface BookmarkGatewaySettingsController ()
18
+
19
+ @end
20
+
21
+ @implementation BookmarkGatewaySettingsController
22
+
23
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark
24
+ {
25
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
26
+ {
27
+ // set additional settings state according to bookmark data
28
+ _bookmark = [bookmark retain];
29
+ _params = [bookmark params];
30
+ }
31
+ return self;
32
+ }
33
+
34
+ - (void)viewDidLoad
35
+ {
36
+ [super viewDidLoad];
37
+ [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")];
38
+ }
39
+
40
+ - (void)viewWillAppear:(BOOL)animated
41
+ {
42
+ [super viewWillAppear:animated];
43
+
44
+ // we need to reload the table view data here to have up-to-date data for the
45
+ // advanced settings accessory items (like for resolution/color mode settings)
46
+ [[self tableView] reloadData];
47
+ }
48
+
49
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
50
+ {
51
+ return YES;
52
+ }
53
+
54
+ - (void)dealloc
55
+ {
56
+ [super dealloc];
57
+ [_bookmark release];
58
+ }
59
+
60
+ #pragma mark - Table view data source
61
+
62
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
63
+ {
64
+ // Return the number of sections.
65
+ return SECTION_COUNT;
66
+ }
67
+
68
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
69
+ {
70
+ // Return the number of rows in the section.
71
+ switch (section)
72
+ {
73
+ case SECTION_TSGATEWAY_SETTINGS: // ts gateway settings
74
+ return 5;
75
+ default:
76
+ break;
77
+ }
78
+
79
+ return 0;
80
+ }
81
+
82
+ // set section headers
83
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
84
+ {
85
+ switch (section)
86
+ {
87
+ case SECTION_TSGATEWAY_SETTINGS:
88
+ return NSLocalizedString(@"TS Gateway", @"'TS Gateway': ts gateway settings header");
89
+ }
90
+ return @"unknown";
91
+ }
92
+
93
+ - (UITableViewCell *)tableView:(UITableView *)tableView
94
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
95
+ {
96
+ // determine the required cell type
97
+ NSString *cellType = nil;
98
+ switch ([indexPath section])
99
+ {
100
+ case SECTION_TSGATEWAY_SETTINGS: // advanced settings
101
+ {
102
+ switch ([indexPath row])
103
+ {
104
+ case 0: // hostname
105
+ case 1: // port
106
+ case 2: // username
107
+ case 4: // domain
108
+ cellType = TableCellIdentifierText;
109
+ break;
110
+ case 3: // password
111
+ cellType = TableCellIdentifierSecretText;
112
+ break;
113
+ default:
114
+ break;
115
+ }
116
+ break;
117
+ }
118
+ }
119
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
120
+
121
+ // get the table view cell
122
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
123
+ NSAssert(cell, @"Invalid cell");
124
+
125
+ // set cell values
126
+ switch ([indexPath section])
127
+ {
128
+ // advanced settings
129
+ case SECTION_TSGATEWAY_SETTINGS:
130
+ [self initGatewaySettings:indexPath cell:cell];
131
+ break;
132
+
133
+ default:
134
+ break;
135
+ }
136
+
137
+ return cell;
138
+ }
139
+
140
+ // updates server settings in the UI
141
+ - (void)initGatewaySettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
142
+ {
143
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
144
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
145
+ switch ([indexPath row])
146
+ {
147
+ case 0:
148
+ {
149
+ [[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")];
150
+ [[textCell textfield] setText:[_params StringForKey:@"tsg_hostname"]];
151
+ [[textCell textfield]
152
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
153
+ break;
154
+ }
155
+ case 1:
156
+ {
157
+ int port = [_params intForKey:@"tsg_port"];
158
+ if (port == 0)
159
+ port = 443;
160
+ [[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")];
161
+ [[textCell textfield] setText:[NSString stringWithFormat:@"%d", port]];
162
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
163
+ break;
164
+ }
165
+ case 2:
166
+ {
167
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
168
+ [[textCell label]
169
+ setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
170
+ [[textCell textfield] setText:[_params StringForKey:@"tsg_username"]];
171
+ [[textCell textfield]
172
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
173
+ break;
174
+ }
175
+ case 3:
176
+ {
177
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
178
+ [[textCell label]
179
+ setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
180
+ [[textCell textfield] setText:[_params StringForKey:@"tsg_password"]];
181
+ [[textCell textfield]
182
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
183
+ break;
184
+ }
185
+ case 4:
186
+ {
187
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
188
+ [[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")];
189
+ [[textCell textfield] setText:[_params StringForKey:@"tsg_domain"]];
190
+ [[textCell textfield]
191
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
192
+ break;
193
+ }
194
+ default:
195
+ NSLog(@"Invalid row index in settings table!");
196
+ break;
197
+ }
198
+
199
+ [self adjustEditTextTableViewCell:textCell];
200
+ }
201
+
202
+ #pragma mark -
203
+ #pragma mark Text Field delegate
204
+
205
+ - (BOOL)textFieldShouldReturn:(UITextField *)textField
206
+ {
207
+ [textField resignFirstResponder];
208
+ return NO;
209
+ }
210
+
211
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
212
+ {
213
+ switch (textField.tag)
214
+ {
215
+ // update server settings
216
+ case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 0):
217
+ [_params setValue:[textField text] forKey:@"tsg_hostname"];
218
+ break;
219
+
220
+ case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 1):
221
+ [_params setInt:[[textField text] intValue] forKey:@"tsg_port"];
222
+ break;
223
+
224
+ case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 2):
225
+ [_params setValue:[textField text] forKey:@"tsg_username"];
226
+ break;
227
+
228
+ case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 3):
229
+ [_params setValue:[textField text] forKey:@"tsg_password"];
230
+ break;
231
+
232
+ case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 4):
233
+ [_params setValue:[textField text] forKey:@"tsg_domain"];
234
+ break;
235
+
236
+ default:
237
+ break;
238
+ }
239
+ return YES;
240
+ }
241
+
242
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkListController.h ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ bookmarks and active session view controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+ #import "Bookmark.h"
13
+ #import "BookmarkTableCell.h"
14
+ #import "SessionTableCell.h"
15
+ #import "BookmarkEditorController.h"
16
+ #import "Reachability.h"
17
+
18
+ @interface BookmarkListController : UIViewController <UISearchBarDelegate, UITableViewDelegate,
19
+ UITableViewDataSource, BookmarkEditorDelegate>
20
+ {
21
+ // custom bookmark and session table cells
22
+ BookmarkTableCell *_bmTableCell;
23
+ SessionTableCell *_sessTableCell;
24
+
25
+ // child views
26
+ UISearchBar *_searchBar;
27
+ UITableView *_tableView;
28
+
29
+ // array with search results (or nil if no search active)
30
+ NSMutableArray *_manual_search_result;
31
+ NSMutableArray *_history_search_result;
32
+
33
+ // bookmark arrays
34
+ NSMutableArray *_manual_bookmarks;
35
+
36
+ // bookmark star images
37
+ UIImage *_star_on_img;
38
+ UIImage *_star_off_img;
39
+
40
+ // array with active sessions
41
+ NSMutableArray *_active_sessions;
42
+
43
+ // array with connection history entries
44
+ NSMutableArray *_connection_history;
45
+
46
+ // temporary bookmark when asking if the user wants to store a bookmark for a session initiated
47
+ // by a quick connect
48
+ ComputerBookmark *_temporary_bookmark;
49
+ }
50
+
51
+ @property(nonatomic, retain) IBOutlet UISearchBar *searchBar;
52
+ @property(nonatomic, retain) IBOutlet UITableView *tableView;
53
+ @property(nonatomic, retain) IBOutlet BookmarkTableCell *bmTableCell;
54
+ @property(nonatomic, retain) IBOutlet SessionTableCell *sessTableCell;
55
+
56
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/BookmarkListController.m ADDED
@@ -0,0 +1,957 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ bookmarks and active session view controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "BookmarkListController.h"
12
+ #import "Utils.h"
13
+ #import "BookmarkEditorController.h"
14
+ #import "RDPSessionViewController.h"
15
+ #import "Toast+UIView.h"
16
+ #import "Reachability.h"
17
+ #import "GlobalDefaults.h"
18
+ #import "BlockAlertView.h"
19
+
20
+ #define SECTION_SESSIONS 0
21
+ #define SECTION_BOOKMARKS 1
22
+ #define NUM_SECTIONS 2
23
+
24
+ @interface BookmarkListController (Private)
25
+ #pragma mark misc functions
26
+ - (UIButton *)disclosureButtonWithImage:(UIImage *)image;
27
+ - (void)performSearch:(NSString *)searchText;
28
+ #pragma mark Persisting bookmarks
29
+ - (void)scheduleWriteBookmarksToDataStore;
30
+ - (void)writeBookmarksToDataStore;
31
+ - (void)scheduleWriteManualBookmarksToDataStore;
32
+ - (void)writeManualBookmarksToDataStore;
33
+ - (void)readManualBookmarksFromDataStore;
34
+ - (void)writeArray:(NSArray *)bookmarks toDataStoreURL:(NSURL *)url;
35
+ - (NSMutableArray *)arrayFromDataStoreURL:(NSURL *)url;
36
+ - (NSURL *)manualBookmarksDataStoreURL;
37
+ - (NSURL *)connectionHistoryDataStoreURL;
38
+ @end
39
+
40
+ @implementation BookmarkListController
41
+
42
+ @synthesize searchBar = _searchBar, tableView = _tableView, bmTableCell = _bmTableCell,
43
+ sessTableCell = _sessTableCell;
44
+
45
+ // The designated initializer. Override if you create the controller programmatically and want to
46
+ // perform customization that is not appropriate for viewDidLoad.
47
+ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
48
+ {
49
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
50
+ {
51
+ // load bookmarks
52
+ [self readManualBookmarksFromDataStore];
53
+
54
+ // load connection history
55
+ [self readConnectionHistoryFromDataStore];
56
+
57
+ // init search result array
58
+ _manual_search_result = nil;
59
+
60
+ // register for session notifications
61
+ [[NSNotificationCenter defaultCenter] addObserver:self
62
+ selector:@selector(sessionDisconnected:)
63
+ name:TSXSessionDidDisconnectNotification
64
+ object:nil];
65
+ [[NSNotificationCenter defaultCenter] addObserver:self
66
+ selector:@selector(sessionFailedToConnect:)
67
+ name:TSXSessionDidFailToConnectNotification
68
+ object:nil];
69
+
70
+ // set title and tabbar controller image
71
+ [self setTitle:NSLocalizedString(@"Connections",
72
+ @"'Connections': bookmark controller title")];
73
+ [self setTabBarItem:[[[UITabBarItem alloc]
74
+ initWithTabBarSystemItem:UITabBarSystemItemBookmarks
75
+ tag:0] autorelease]];
76
+
77
+ // load images
78
+ _star_on_img = [[UIImage
79
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_on"
80
+ ofType:@"png"]] retain];
81
+ _star_off_img =
82
+ [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]
83
+ pathForResource:@"icon_accessory_star_off"
84
+ ofType:@"png"]] retain];
85
+
86
+ // init reachability detection
87
+ [[NSNotificationCenter defaultCenter] addObserver:self
88
+ selector:@selector(reachabilityChanged:)
89
+ name:kReachabilityChangedNotification
90
+ object:nil];
91
+
92
+ // init other properties
93
+ _active_sessions = [[NSMutableArray alloc] init];
94
+ _temporary_bookmark = nil;
95
+ }
96
+ return self;
97
+ }
98
+
99
+ - (void)loadView
100
+ {
101
+ [super loadView];
102
+ }
103
+
104
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
105
+ - (void)viewDidLoad
106
+ {
107
+ [super viewDidLoad];
108
+
109
+ // set edit button to allow bookmark list editing
110
+ [[self navigationItem] setRightBarButtonItem:[self editButtonItem]];
111
+ }
112
+
113
+ - (void)viewWillAppear:(BOOL)animated
114
+ {
115
+ [super viewWillAppear:animated];
116
+
117
+ // in case we had a search - search again cause the bookmark searchable items could have changed
118
+ if ([[_searchBar text] length] > 0)
119
+ [self performSearch:[_searchBar text]];
120
+
121
+ // to reflect any bookmark changes - reload table
122
+ [_tableView reloadData];
123
+ }
124
+
125
+ - (void)viewWillDisappear:(BOOL)animated
126
+ {
127
+ [super viewWillDisappear:animated];
128
+
129
+ // clear any search
130
+ [_searchBar setText:@""];
131
+ [_searchBar resignFirstResponder];
132
+ [self performSearch:@""];
133
+ }
134
+
135
+ // Override to allow orientations other than the default portrait orientation.
136
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
137
+ {
138
+ // Return YES for supported orientations
139
+ return YES;
140
+ }
141
+
142
+ - (void)didReceiveMemoryWarning
143
+ {
144
+ // Releases the view if it doesn't have a superview.
145
+ [super didReceiveMemoryWarning];
146
+
147
+ // Release any cached data, images, etc that aren't in use.
148
+ }
149
+
150
+ - (void)viewDidUnload
151
+ {
152
+ [super viewDidUnload];
153
+ // Release any retained subviews of the main view.
154
+ // e.g. self.myOutlet = nil;
155
+ }
156
+
157
+ - (void)dealloc
158
+ {
159
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
160
+
161
+ [_temporary_bookmark release];
162
+ [_connection_history release];
163
+ [_active_sessions release];
164
+ [_manual_search_result release];
165
+ [_manual_bookmarks release];
166
+
167
+ [_star_on_img release];
168
+ [_star_off_img release];
169
+
170
+ [super dealloc];
171
+ }
172
+
173
+ #pragma mark -
174
+ #pragma mark Table view data source
175
+
176
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
177
+ {
178
+ // Return the number of sections.
179
+ return NUM_SECTIONS;
180
+ }
181
+
182
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
183
+ {
184
+
185
+ switch (section)
186
+ {
187
+ case SECTION_SESSIONS:
188
+ return 0;
189
+ break;
190
+
191
+ case SECTION_BOOKMARKS:
192
+ {
193
+ // (+1 for Add Bookmark entry)
194
+ if (_manual_search_result != nil)
195
+ return ([_manual_search_result count] + [_history_search_result count] + 1);
196
+ return ([_manual_bookmarks count] + 1);
197
+ }
198
+ break;
199
+
200
+ default:
201
+ break;
202
+ }
203
+ return 0;
204
+ }
205
+
206
+ - (UITableViewCell *)cellForGenericListEntry
207
+ {
208
+ static NSString *CellIdentifier = @"BookmarkListCell";
209
+ UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:CellIdentifier];
210
+ if (cell == nil)
211
+ {
212
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
213
+ reuseIdentifier:CellIdentifier];
214
+ [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
215
+ [cell setAccessoryView:[self disclosureButtonWithImage:_star_off_img]];
216
+ }
217
+
218
+ return cell;
219
+ }
220
+
221
+ - (BookmarkTableCell *)cellForBookmark
222
+ {
223
+ static NSString *BookmarkCellIdentifier = @"BookmarkCell";
224
+ BookmarkTableCell *cell = (BookmarkTableCell *)[[self tableView]
225
+ dequeueReusableCellWithIdentifier:BookmarkCellIdentifier];
226
+ if (cell == nil)
227
+ {
228
+ [[NSBundle mainBundle] loadNibNamed:@"BookmarkTableViewCell" owner:self options:nil];
229
+ [_bmTableCell setAccessoryView:[self disclosureButtonWithImage:_star_on_img]];
230
+ cell = _bmTableCell;
231
+ _bmTableCell = nil;
232
+ }
233
+
234
+ return cell;
235
+ }
236
+
237
+ // Customize the appearance of table view cells.
238
+ - (UITableViewCell *)tableView:(UITableView *)tableView
239
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
240
+ {
241
+
242
+ switch ([indexPath section])
243
+ {
244
+ case SECTION_SESSIONS:
245
+ {
246
+ // get custom session cell
247
+ static NSString *SessionCellIdentifier = @"SessionCell";
248
+ SessionTableCell *cell = (SessionTableCell *)[tableView
249
+ dequeueReusableCellWithIdentifier:SessionCellIdentifier];
250
+ if (cell == nil)
251
+ {
252
+ [[NSBundle mainBundle] loadNibNamed:@"SessionTableViewCell" owner:self options:nil];
253
+ cell = _sessTableCell;
254
+ _sessTableCell = nil;
255
+ }
256
+
257
+ // set cell data
258
+ RDPSession *session = [_active_sessions objectAtIndex:[indexPath row]];
259
+ [[cell title] setText:[session sessionName]];
260
+ [[cell server] setText:[[session params] StringForKey:@"hostname"]];
261
+ [[cell username] setText:[[session params] StringForKey:@"username"]];
262
+ [[cell screenshot]
263
+ setImage:[session getScreenshotWithSize:[[cell screenshot] bounds].size]];
264
+ [[cell disconnectButton] setTag:[indexPath row]];
265
+ return cell;
266
+ }
267
+
268
+ case SECTION_BOOKMARKS:
269
+ {
270
+ // special handling for first cell - quick connect/quick create Bookmark cell
271
+ if ([indexPath row] == 0)
272
+ {
273
+ // if a search text is entered the cell becomes a quick connect/quick create
274
+ // bookmark cell - otherwise it's just an add bookmark cell
275
+ UITableViewCell *cell = [self cellForGenericListEntry];
276
+ if ([[_searchBar text] length] == 0)
277
+ {
278
+ [[cell textLabel]
279
+ setText:[@" " stringByAppendingString:
280
+ NSLocalizedString(@"Add Connection",
281
+ @"'Add Connection': button label")]];
282
+ [((UIButton *)[cell accessoryView]) setHidden:YES];
283
+ }
284
+ else
285
+ {
286
+ [[cell textLabel] setText:[@" " stringByAppendingString:[_searchBar text]]];
287
+ [((UIButton *)[cell accessoryView]) setHidden:NO];
288
+ }
289
+
290
+ return cell;
291
+ }
292
+ else
293
+ {
294
+ // do we have a history cell or bookmark cell?
295
+ if ([self isIndexPathToHistoryItem:indexPath])
296
+ {
297
+ UITableViewCell *cell = [self cellForGenericListEntry];
298
+ [[cell textLabel]
299
+ setText:[@" " stringByAppendingString:
300
+ [_history_search_result
301
+ objectAtIndex:
302
+ [self historyIndexFromIndexPath:indexPath]]]];
303
+ [((UIButton *)[cell accessoryView]) setHidden:NO];
304
+ return cell;
305
+ }
306
+ else
307
+ {
308
+ // set cell properties
309
+ ComputerBookmark *entry;
310
+ BookmarkTableCell *cell = [self cellForBookmark];
311
+ if (_manual_search_result == nil)
312
+ entry = [_manual_bookmarks
313
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
314
+ else
315
+ entry = [[_manual_search_result
316
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
317
+ valueForKey:@"bookmark"];
318
+
319
+ [[cell title] setText:[entry label]];
320
+ [[cell subTitle] setText:[[entry params] StringForKey:@"hostname"]];
321
+ return cell;
322
+ }
323
+ }
324
+ }
325
+
326
+ default:
327
+ break;
328
+ }
329
+
330
+ NSAssert(0, @"Failed to create cell");
331
+ return nil;
332
+ }
333
+
334
+ // Override to support conditional editing of the table view.
335
+ - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
336
+ {
337
+ // dont allow to edit Add Bookmark item
338
+ if ([indexPath section] == SECTION_SESSIONS)
339
+ return NO;
340
+ if ([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
341
+ return NO;
342
+ return YES;
343
+ }
344
+
345
+ // Override to support editing the table view.
346
+ - (void)tableView:(UITableView *)tableView
347
+ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
348
+ forRowAtIndexPath:(NSIndexPath *)indexPath
349
+ {
350
+ if (editingStyle == UITableViewCellEditingStyleDelete)
351
+ {
352
+ // Delete the row from the data source
353
+ switch ([indexPath section])
354
+ {
355
+ case SECTION_BOOKMARKS:
356
+ {
357
+ if (_manual_search_result == nil)
358
+ [_manual_bookmarks
359
+ removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
360
+ else
361
+ {
362
+ // history item or bookmark?
363
+ if ([self isIndexPathToHistoryItem:indexPath])
364
+ {
365
+ [_connection_history
366
+ removeObject:
367
+ [_history_search_result
368
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]]];
369
+ [_history_search_result
370
+ removeObjectAtIndex:[self historyIndexFromIndexPath:indexPath]];
371
+ }
372
+ else
373
+ {
374
+ [_manual_bookmarks
375
+ removeObject:
376
+ [[_manual_search_result
377
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
378
+ valueForKey:@"bookmark"]];
379
+ [_manual_search_result
380
+ removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
381
+ }
382
+ }
383
+ [self scheduleWriteManualBookmarksToDataStore];
384
+ break;
385
+ }
386
+ }
387
+
388
+ [tableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]]
389
+ withRowAnimation:UITableViewRowAnimationNone];
390
+ }
391
+ }
392
+
393
+ // Override to support rearranging the table view.
394
+ - (void)tableView:(UITableView *)tableView
395
+ moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
396
+ toIndexPath:(NSIndexPath *)toIndexPath
397
+ {
398
+ if ([fromIndexPath compare:toIndexPath] != NSOrderedSame)
399
+ {
400
+ switch ([fromIndexPath section])
401
+ {
402
+ case SECTION_BOOKMARKS:
403
+ {
404
+ int fromIdx = [self bookmarkIndexFromIndexPath:fromIndexPath];
405
+ int toIdx = [self bookmarkIndexFromIndexPath:toIndexPath];
406
+ ComputerBookmark *temp_bookmark =
407
+ [[_manual_bookmarks objectAtIndex:fromIdx] retain];
408
+ [_manual_bookmarks removeObjectAtIndex:fromIdx];
409
+ if (toIdx >= [_manual_bookmarks count])
410
+ [_manual_bookmarks addObject:temp_bookmark];
411
+ else
412
+ [_manual_bookmarks insertObject:temp_bookmark atIndex:toIdx];
413
+ [temp_bookmark release];
414
+
415
+ [self scheduleWriteManualBookmarksToDataStore];
416
+ break;
417
+ }
418
+ }
419
+ }
420
+ }
421
+
422
+ // prevent that an item is moved before the Add Bookmark item
423
+ - (NSIndexPath *)tableView:(UITableView *)tableView
424
+ targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath
425
+ toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
426
+ {
427
+ // don't allow to move:
428
+ // - items between sections
429
+ // - the quick connect/quick create bookmark cell
430
+ // - any item while a search is applied
431
+ if ([proposedDestinationIndexPath row] == 0 ||
432
+ ([sourceIndexPath section] != [proposedDestinationIndexPath section]) ||
433
+ _manual_search_result != nil)
434
+ {
435
+ return sourceIndexPath;
436
+ }
437
+ else
438
+ {
439
+ return proposedDestinationIndexPath;
440
+ }
441
+ }
442
+
443
+ // Override to support conditional rearranging of the table view.
444
+ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
445
+ {
446
+ // dont allow to reorder Add Bookmark item
447
+ if ([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
448
+ return NO;
449
+ return YES;
450
+ }
451
+
452
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
453
+ {
454
+ if (section == SECTION_SESSIONS && [_active_sessions count] > 0)
455
+ return NSLocalizedString(@"My Sessions", @"'My Session': section sessions header");
456
+ if (section == SECTION_BOOKMARKS)
457
+ return NSLocalizedString(@"Manual Connections",
458
+ @"'Manual Connections': section manual bookmarks header");
459
+ return nil;
460
+ }
461
+
462
+ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
463
+ {
464
+ return nil;
465
+ }
466
+
467
+ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
468
+ {
469
+ if ([indexPath section] == SECTION_SESSIONS)
470
+ return 72;
471
+ return [tableView rowHeight];
472
+ }
473
+
474
+ #pragma mark -
475
+ #pragma mark Table view delegate
476
+
477
+ - (void)setEditing:(BOOL)editing animated:(BOOL)animated
478
+ {
479
+ [super setEditing:editing animated:animated];
480
+ [[self tableView] setEditing:editing animated:animated];
481
+ }
482
+
483
+ - (void)accessoryButtonTapped:(UIControl *)button withEvent:(UIEvent *)event
484
+ {
485
+ // forward a tap on our custom accessory button to the real accessory button handler
486
+ NSIndexPath *indexPath =
487
+ [[self tableView] indexPathForRowAtPoint:[[[event touchesForView:button] anyObject]
488
+ locationInView:[self tableView]]];
489
+ if (indexPath == nil)
490
+ return;
491
+
492
+ [[[self tableView] delegate] tableView:[self tableView]
493
+ accessoryButtonTappedForRowWithIndexPath:indexPath];
494
+ }
495
+
496
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
497
+ {
498
+ if ([indexPath section] == SECTION_SESSIONS)
499
+ {
500
+ // resume session
501
+ RDPSession *session = [_active_sessions objectAtIndex:[indexPath row]];
502
+ UIViewController *ctrl =
503
+ [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView"
504
+ bundle:nil
505
+ session:session] autorelease];
506
+ [ctrl setHidesBottomBarWhenPushed:YES];
507
+ [[self navigationController] pushViewController:ctrl animated:YES];
508
+ }
509
+ else
510
+ {
511
+ ComputerBookmark *bookmark = nil;
512
+ if ([indexPath section] == SECTION_BOOKMARKS)
513
+ {
514
+ // first row has either quick connect or add bookmark item
515
+ if ([indexPath row] == 0)
516
+ {
517
+ if ([[_searchBar text] length] == 0)
518
+ {
519
+ // show add bookmark controller
520
+ ComputerBookmark *bookmark =
521
+ [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
522
+ BookmarkEditorController *bookmarkEditorController =
523
+ [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
524
+ [bookmarkEditorController
525
+ setTitle:NSLocalizedString(@"Add Connection", @"Add Connection title")];
526
+ [bookmarkEditorController setDelegate:self];
527
+ [bookmarkEditorController setHidesBottomBarWhenPushed:YES];
528
+ [[self navigationController] pushViewController:bookmarkEditorController
529
+ animated:YES];
530
+ }
531
+ else
532
+ {
533
+ // create a quick connect bookmark and add an entry to the quick connect history
534
+ // (if not already in the history)
535
+ bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
536
+ if (![_connection_history containsObject:[_searchBar text]])
537
+ {
538
+ [_connection_history addObject:[_searchBar text]];
539
+ [self scheduleWriteConnectionHistoryToDataStore];
540
+ }
541
+ }
542
+ }
543
+ else
544
+ {
545
+ if (_manual_search_result != nil)
546
+ {
547
+ if ([self isIndexPathToHistoryItem:indexPath])
548
+ {
549
+ // create a quick connect bookmark for a history item
550
+ NSString *item = [_history_search_result
551
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
552
+ bookmark = [self bookmarkForQuickConnectTo:item];
553
+ }
554
+ else
555
+ bookmark = [[_manual_search_result
556
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
557
+ valueForKey:@"bookmark"];
558
+ }
559
+ else
560
+ bookmark = [_manual_bookmarks
561
+ objectAtIndex:[self bookmarkIndexFromIndexPath:
562
+ indexPath]]; // -1 because of ADD BOOKMARK entry
563
+ }
564
+
565
+ // set reachability status
566
+ WakeUpWWAN();
567
+ [bookmark
568
+ setConntectedViaWLAN:[[Reachability
569
+ reachabilityWithHostName:[[bookmark params]
570
+ StringForKey:@"hostname"]]
571
+ currentReachabilityStatus] == ReachableViaWiFi];
572
+ }
573
+
574
+ if (bookmark != nil)
575
+ {
576
+ // create rdp session
577
+ RDPSession *session = [[[RDPSession alloc] initWithBookmark:bookmark] autorelease];
578
+ UIViewController *ctrl =
579
+ [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView"
580
+ bundle:nil
581
+ session:session] autorelease];
582
+ [ctrl setHidesBottomBarWhenPushed:YES];
583
+ [[self navigationController] pushViewController:ctrl animated:YES];
584
+ [_active_sessions addObject:session];
585
+ }
586
+ }
587
+ }
588
+
589
+ - (void)tableView:(UITableView *)tableView
590
+ accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
591
+ {
592
+ // get the bookmark
593
+ NSString *bookmark_editor_title =
594
+ NSLocalizedString(@"Edit Connection", @"Edit Connection title");
595
+ ComputerBookmark *bookmark = nil;
596
+ if ([indexPath section] == SECTION_BOOKMARKS)
597
+ {
598
+ if ([indexPath row] == 0)
599
+ {
600
+ // create a new bookmark and init hostname and label
601
+ bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
602
+ bookmark_editor_title = NSLocalizedString(@"Add Connection", @"Add Connection title");
603
+ }
604
+ else
605
+ {
606
+ if (_manual_search_result != nil)
607
+ {
608
+ if ([self isIndexPathToHistoryItem:indexPath])
609
+ {
610
+ // create a new bookmark and init hostname and label
611
+ NSString *item = [_history_search_result
612
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
613
+ bookmark = [self bookmarkForQuickConnectTo:item];
614
+ bookmark_editor_title =
615
+ NSLocalizedString(@"Add Connection", @"Add Connection title");
616
+ }
617
+ else
618
+ bookmark = [[_manual_search_result
619
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
620
+ valueForKey:@"bookmark"];
621
+ }
622
+ else
623
+ bookmark = [_manual_bookmarks
624
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]; // -1 because of ADD
625
+ // BOOKMARK entry
626
+ }
627
+ }
628
+
629
+ // bookmark found? - start the editor
630
+ if (bookmark != nil)
631
+ {
632
+ BookmarkEditorController *editBookmarkController =
633
+ [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
634
+ [editBookmarkController setHidesBottomBarWhenPushed:YES];
635
+ [editBookmarkController setTitle:bookmark_editor_title];
636
+ [editBookmarkController setDelegate:self];
637
+ [[self navigationController] pushViewController:editBookmarkController animated:YES];
638
+ }
639
+ }
640
+
641
+ #pragma mark -
642
+ #pragma mark Search Bar Delegates
643
+
644
+ - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
645
+ {
646
+ // show cancel button
647
+ [searchBar setShowsCancelButton:YES animated:YES];
648
+ return YES;
649
+ }
650
+
651
+ - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
652
+ {
653
+ // clear search result
654
+ [_manual_search_result release];
655
+ _manual_search_result = nil;
656
+
657
+ // clear text and remove cancel button
658
+ [searchBar setText:@""];
659
+ [searchBar resignFirstResponder];
660
+ }
661
+
662
+ - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
663
+ {
664
+ [searchBar setShowsCancelButton:NO animated:YES];
665
+
666
+ // re-enable table selection
667
+ [_tableView setAllowsSelection:YES];
668
+
669
+ return YES;
670
+ }
671
+
672
+ - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
673
+ {
674
+ [_searchBar resignFirstResponder];
675
+ }
676
+
677
+ - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
678
+ {
679
+ [self performSearch:searchText];
680
+ [_tableView reloadData];
681
+ }
682
+
683
+ #pragma mark - Session handling
684
+
685
+ // session was added
686
+ - (void)sessionDisconnected:(NSNotification *)notification
687
+ {
688
+ // remove session from active sessions
689
+ RDPSession *session = (RDPSession *)[notification object];
690
+ [_active_sessions removeObject:session];
691
+
692
+ // if this view is currently active refresh entries
693
+ if ([[self navigationController] visibleViewController] == self)
694
+ [_tableView reloadSections:[NSIndexSet indexSetWithIndex:SECTION_SESSIONS]
695
+ withRowAnimation:UITableViewRowAnimationNone];
696
+
697
+ // if session's bookmark is not in the bookmark list ask the user if he wants to add it
698
+ // (this happens if the session is created using the quick connect feature)
699
+ if (![_manual_bookmarks containsObject:[session bookmark]])
700
+ {
701
+ // retain the bookmark in case we want to save it later
702
+ _temporary_bookmark = [[session bookmark] retain];
703
+
704
+ // ask the user if he wants to save the bookmark
705
+ NSString *title =
706
+ NSLocalizedString(@"Save Connection Settings?", @"Save connection settings title");
707
+ NSString *message = NSLocalizedString(
708
+ @"Your Connection Settings have not been saved. Do you want to save them?",
709
+ @"Save connection settings message");
710
+ BlockAlertView *alert = [BlockAlertView alertWithTitle:title message:message];
711
+ [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
712
+ [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Yes Button")
713
+ block:^{
714
+ if (_temporary_bookmark)
715
+ {
716
+ [_manual_bookmarks addObject:_temporary_bookmark];
717
+ [_tableView
718
+ reloadSections:[NSIndexSet
719
+ indexSetWithIndex:SECTION_BOOKMARKS]
720
+ withRowAnimation:UITableViewRowAnimationNone];
721
+ [_temporary_bookmark autorelease];
722
+ _temporary_bookmark = nil;
723
+ }
724
+ }];
725
+ [alert show];
726
+ }
727
+ }
728
+
729
+ - (void)sessionFailedToConnect:(NSNotification *)notification
730
+ {
731
+ // remove session from active sessions
732
+ RDPSession *session = (RDPSession *)[notification object];
733
+ [_active_sessions removeObject:session];
734
+
735
+ // display error toast
736
+ [[self view] makeToast:NSLocalizedString(@"Failed to connect to session!",
737
+ @"Failed to connect error message")
738
+ duration:ToastDurationNormal
739
+ position:@"center"];
740
+ }
741
+
742
+ #pragma mark - Reachability notification
743
+ - (void)reachabilityChanged:(NSNotification *)notification
744
+ {
745
+ // no matter how the network changed - we will disconnect
746
+ // disconnect session (if there is any)
747
+ if ([_active_sessions count] > 0)
748
+ {
749
+ RDPSession *session = [_active_sessions objectAtIndex:0];
750
+ [session disconnect];
751
+ }
752
+ }
753
+
754
+ #pragma mark - BookmarkEditorController delegate
755
+
756
+ - (void)commitBookmark:(ComputerBookmark *)bookmark
757
+ {
758
+ // if we got a manual bookmark that is not in the list yet - add it otherwise replace it
759
+ BOOL found = NO;
760
+ for (int idx = 0; idx < [_manual_bookmarks count]; ++idx)
761
+ {
762
+ if ([[bookmark uuid] isEqualToString:[[_manual_bookmarks objectAtIndex:idx] uuid]])
763
+ {
764
+ [_manual_bookmarks replaceObjectAtIndex:idx withObject:bookmark];
765
+ found = YES;
766
+ break;
767
+ }
768
+ }
769
+ if (!found)
770
+ [_manual_bookmarks addObject:bookmark];
771
+
772
+ // remove any quick connect history entry with the same hostname
773
+ NSString *hostname = [[bookmark params] StringForKey:@"hostname"];
774
+ if ([_connection_history containsObject:hostname])
775
+ {
776
+ [_connection_history removeObject:hostname];
777
+ [self scheduleWriteConnectionHistoryToDataStore];
778
+ }
779
+
780
+ [self scheduleWriteManualBookmarksToDataStore];
781
+ }
782
+
783
+ - (IBAction)disconnectButtonPressed:(id)sender
784
+ {
785
+ // disconnect session and refresh table view
786
+ RDPSession *session = [_active_sessions objectAtIndex:[sender tag]];
787
+ [session disconnect];
788
+ }
789
+
790
+ #pragma mark - Misc functions
791
+
792
+ - (BOOL)hasNoBookmarks
793
+ {
794
+ return ([_manual_bookmarks count] == 0);
795
+ }
796
+
797
+ - (UIButton *)disclosureButtonWithImage:(UIImage *)image
798
+ {
799
+ // we make the button a little bit bigger (image width * 2, height + 10) so that the user
800
+ // doesn't accidentally connect to the bookmark ...
801
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
802
+ [button setFrame:CGRectMake(0, 0, [image size].width * 2, [image size].height + 10)];
803
+ [button setImage:image forState:UIControlStateNormal];
804
+ [button addTarget:self
805
+ action:@selector(accessoryButtonTapped:withEvent:)
806
+ forControlEvents:UIControlEventTouchUpInside];
807
+ [button setUserInteractionEnabled:YES];
808
+ return button;
809
+ }
810
+
811
+ - (void)performSearch:(NSString *)searchText
812
+ {
813
+ [_manual_search_result autorelease];
814
+
815
+ if ([searchText length] > 0)
816
+ {
817
+ _manual_search_result = [FilterBookmarks(
818
+ _manual_bookmarks,
819
+ [searchText componentsSeparatedByCharactersInSet:[NSCharacterSet
820
+ whitespaceAndNewlineCharacterSet]])
821
+ retain];
822
+ _history_search_result = [FilterHistory(_connection_history, searchText) retain];
823
+ }
824
+ else
825
+ {
826
+ _history_search_result = nil;
827
+ _manual_search_result = nil;
828
+ }
829
+ }
830
+
831
+ - (int)bookmarkIndexFromIndexPath:(NSIndexPath *)indexPath
832
+ {
833
+ return [indexPath row] -
834
+ ((_history_search_result != nil) ? [_history_search_result count] : 0) - 1;
835
+ }
836
+
837
+ - (int)historyIndexFromIndexPath:(NSIndexPath *)indexPath
838
+ {
839
+ return [indexPath row] - 1;
840
+ }
841
+
842
+ - (BOOL)isIndexPathToHistoryItem:(NSIndexPath *)indexPath
843
+ {
844
+ return (([indexPath row] - 1) < [_history_search_result count]);
845
+ }
846
+
847
+ - (ComputerBookmark *)bookmarkForQuickConnectTo:(NSString *)host
848
+ {
849
+ ComputerBookmark *bookmark =
850
+ [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
851
+ [bookmark setLabel:host];
852
+ [[bookmark params] setValue:host forKey:@"hostname"];
853
+ return bookmark;
854
+ }
855
+
856
+ #pragma mark - Persisting bookmarks
857
+
858
+ - (void)scheduleWriteBookmarksToDataStore
859
+ {
860
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
861
+ [self writeBookmarksToDataStore];
862
+ }];
863
+ }
864
+
865
+ - (void)writeBookmarksToDataStore
866
+ {
867
+ [self writeManualBookmarksToDataStore];
868
+ }
869
+
870
+ - (void)scheduleWriteManualBookmarksToDataStore
871
+ {
872
+ [[NSOperationQueue mainQueue]
873
+ addOperation:[[[NSInvocationOperation alloc]
874
+ initWithTarget:self
875
+ selector:@selector(writeManualBookmarksToDataStore)
876
+ object:nil] autorelease]];
877
+ }
878
+
879
+ - (void)writeManualBookmarksToDataStore
880
+ {
881
+ [self writeArray:_manual_bookmarks toDataStoreURL:[self manualBookmarksDataStoreURL]];
882
+ }
883
+
884
+ - (void)scheduleWriteConnectionHistoryToDataStore
885
+ {
886
+ [[NSOperationQueue mainQueue]
887
+ addOperation:[[[NSInvocationOperation alloc]
888
+ initWithTarget:self
889
+ selector:@selector(writeConnectionHistoryToDataStore)
890
+ object:nil] autorelease]];
891
+ }
892
+
893
+ - (void)writeConnectionHistoryToDataStore
894
+ {
895
+ [self writeArray:_connection_history toDataStoreURL:[self connectionHistoryDataStoreURL]];
896
+ }
897
+
898
+ - (void)writeArray:(NSArray *)bookmarks toDataStoreURL:(NSURL *)url
899
+ {
900
+ NSData *archived_data = [NSKeyedArchiver archivedDataWithRootObject:bookmarks];
901
+ [archived_data writeToURL:url atomically:YES];
902
+ }
903
+
904
+ - (void)readManualBookmarksFromDataStore
905
+ {
906
+ [_manual_bookmarks autorelease];
907
+ _manual_bookmarks = [self arrayFromDataStoreURL:[self manualBookmarksDataStoreURL]];
908
+
909
+ if (_manual_bookmarks == nil)
910
+ {
911
+ _manual_bookmarks = [[NSMutableArray alloc] init];
912
+ [_manual_bookmarks
913
+ addObject:[[[GlobalDefaults sharedGlobalDefaults] newTestServerBookmark] autorelease]];
914
+ }
915
+ }
916
+
917
+ - (void)readConnectionHistoryFromDataStore
918
+ {
919
+ [_connection_history autorelease];
920
+ _connection_history = [self arrayFromDataStoreURL:[self connectionHistoryDataStoreURL]];
921
+
922
+ if (_connection_history == nil)
923
+ _connection_history = [[NSMutableArray alloc] init];
924
+ }
925
+
926
+ - (NSMutableArray *)arrayFromDataStoreURL:(NSURL *)url
927
+ {
928
+ NSData *archived_data = [NSData dataWithContentsOfURL:url];
929
+
930
+ if (!archived_data)
931
+ return nil;
932
+
933
+ return [[NSKeyedUnarchiver unarchiveObjectWithData:archived_data] retain];
934
+ }
935
+
936
+ - (NSURL *)manualBookmarksDataStoreURL
937
+ {
938
+ return [NSURL
939
+ fileURLWithPath:[NSString stringWithFormat:@"%@/%@",
940
+ [NSSearchPathForDirectoriesInDomains(
941
+ NSDocumentDirectory, NSUserDomainMask, YES)
942
+ lastObject],
943
+ @"com.freerdp.ifreerdp.bookmarks.plist"]];
944
+ }
945
+
946
+ - (NSURL *)connectionHistoryDataStoreURL
947
+ {
948
+ return [NSURL
949
+ fileURLWithPath:[NSString
950
+ stringWithFormat:@"%@/%@",
951
+ [NSSearchPathForDirectoriesInDomains(
952
+ NSDocumentDirectory, NSUserDomainMask, YES)
953
+ lastObject],
954
+ @"com.freerdp.ifreerdp.connection_history.plist"]];
955
+ }
956
+
957
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsEditorController.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to edit bookmark credentials
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @class ComputerBookmark;
14
+ @class ConnectionParams;
15
+
16
+ @interface CredentialsEditorController : EditorBaseController
17
+ {
18
+ @private
19
+ ComputerBookmark *_bookmark;
20
+ ConnectionParams *_params;
21
+ }
22
+
23
+ // init for the given bookmark
24
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark;
25
+
26
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsEditorController.m ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Controller to edit bookmark credentials
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "CredentialsEditorController.h"
12
+ #import "Bookmark.h"
13
+ #import "Utils.h"
14
+
15
+ @interface CredentialsEditorController ()
16
+
17
+ @end
18
+
19
+ #define SECTION_CREDENTIALS 0
20
+ #define SECTION_COUNT 1
21
+
22
+ @implementation CredentialsEditorController
23
+
24
+ - (id)initWithBookmark:(ComputerBookmark *)bookmark
25
+ {
26
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
27
+ {
28
+ // set additional settings state according to bookmark data
29
+ _bookmark = [bookmark retain];
30
+ _params = [bookmark params];
31
+ }
32
+ return self;
33
+ }
34
+
35
+ - (void)viewDidLoad
36
+ {
37
+ [super viewDidLoad];
38
+ [self setTitle:NSLocalizedString(@"Credentials", @"Credentials title")];
39
+ }
40
+
41
+ - (void)viewDidUnload
42
+ {
43
+ [super viewDidUnload];
44
+ // Release any retained subviews of the main view.
45
+ }
46
+
47
+ - (void)viewWillDisappear:(BOOL)animated
48
+ {
49
+ [super viewWillDisappear:animated];
50
+
51
+ // foce any active editing to stop
52
+ [[self view] endEditing:NO];
53
+ }
54
+
55
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
56
+ {
57
+ return YES;
58
+ }
59
+
60
+ - (void)dealloc
61
+ {
62
+ [super dealloc];
63
+ [_bookmark release];
64
+ }
65
+
66
+ #pragma mark -
67
+ #pragma mark Table view data source
68
+
69
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
70
+ {
71
+ // Return the number of sections.
72
+ return SECTION_COUNT;
73
+ }
74
+
75
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
76
+ {
77
+ // Return the number of rows in the section.
78
+ switch (section)
79
+ {
80
+ case SECTION_CREDENTIALS: // credentials
81
+ return 3;
82
+ default:
83
+ break;
84
+ }
85
+
86
+ return 0;
87
+ }
88
+
89
+ // set section headers
90
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
91
+ {
92
+ switch (section)
93
+ {
94
+ case SECTION_CREDENTIALS:
95
+ return NSLocalizedString(@"Credentials", @"'Credentials': credentials settings header");
96
+ }
97
+ return @"unknown";
98
+ }
99
+
100
+ // Customize the appearance of table view cells.
101
+ - (UITableViewCell *)tableView:(UITableView *)tableView
102
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
103
+ {
104
+
105
+ // determine the required cell type
106
+ NSString *cellType = nil;
107
+ switch ([indexPath section])
108
+ {
109
+ case SECTION_CREDENTIALS: // credentials
110
+ if ([indexPath row] == 1)
111
+ cellType = TableCellIdentifierSecretText; // password field
112
+ else
113
+ cellType = TableCellIdentifierText;
114
+ break;
115
+
116
+ default:
117
+ break;
118
+ }
119
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
120
+
121
+ // get the table view cell
122
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
123
+ NSAssert(cell, @"Invalid cell");
124
+
125
+ // set cell values
126
+ switch ([indexPath section])
127
+ {
128
+ // credentials
129
+ case SECTION_CREDENTIALS:
130
+ [self initCredentialSettings:indexPath cell:cell];
131
+ break;
132
+
133
+ default:
134
+ break;
135
+ }
136
+
137
+ return cell;
138
+ }
139
+
140
+ // updates credentials in the UI
141
+ - (void)initCredentialSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
142
+ {
143
+ switch (indexPath.row)
144
+ {
145
+ case 0:
146
+ {
147
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
148
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
149
+ [[textCell label]
150
+ setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
151
+ [[textCell textfield] setText:[_params StringForKey:@"username"]];
152
+ [[textCell textfield]
153
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
154
+ break;
155
+ }
156
+ case 1:
157
+ {
158
+ EditSecretTextTableViewCell *textCell = (EditSecretTextTableViewCell *)cell;
159
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
160
+ [[textCell label]
161
+ setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
162
+ [[textCell textfield] setText:[_params StringForKey:@"password"]];
163
+ [[textCell textfield]
164
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
165
+ break;
166
+ }
167
+ case 2:
168
+ {
169
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
170
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
171
+ [[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")];
172
+ [[textCell textfield] setText:[_params StringForKey:@"domain"]];
173
+ [[textCell textfield]
174
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
175
+ break;
176
+ }
177
+ default:
178
+ NSLog(@"Invalid row index in settings table!");
179
+ break;
180
+ }
181
+ }
182
+
183
+ #pragma mark -
184
+ #pragma mark Text Field delegate
185
+
186
+ - (BOOL)textFieldShouldReturn:(UITextField *)textField
187
+ {
188
+ [textField resignFirstResponder];
189
+ return NO;
190
+ }
191
+
192
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
193
+ {
194
+ switch (textField.tag)
195
+ {
196
+ // update credentials settings
197
+ case GET_TAG(SECTION_CREDENTIALS, 0):
198
+ [_params setValue:[textField text] forKey:@"username"];
199
+ break;
200
+
201
+ case GET_TAG(SECTION_CREDENTIALS, 1):
202
+ [_params setValue:[textField text] forKey:@"password"];
203
+ break;
204
+
205
+ case GET_TAG(SECTION_CREDENTIALS, 2):
206
+ [_params setValue:[textField text] forKey:@"domain"];
207
+ break;
208
+
209
+ default:
210
+ break;
211
+ }
212
+ return YES;
213
+ }
214
+
215
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsInputController.h ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Credentials input controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+
13
+ @class RDPSession;
14
+
15
+ @interface CredentialsInputController : UIViewController
16
+ {
17
+ @private
18
+ IBOutlet UITextField *_textfield_username;
19
+ IBOutlet UITextField *_textfield_password;
20
+ IBOutlet UITextField *_textfield_domain;
21
+ IBOutlet UIButton *_btn_login;
22
+ IBOutlet UIButton *_btn_cancel;
23
+ IBOutlet UIScrollView *_scroll_view;
24
+ IBOutlet UILabel *_lbl_message;
25
+
26
+ RDPSession *_session;
27
+ NSMutableDictionary *_params;
28
+ }
29
+
30
+ - (id)initWithNibName:(NSString *)nibNameOrNil
31
+ bundle:(NSBundle *)nibBundleOrNil
32
+ session:(RDPSession *)session
33
+ params:(NSMutableDictionary *)params;
34
+
35
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/CredentialsInputController.m ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Credentials input controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "CredentialsInputController.h"
12
+ #import "RDPSession.h"
13
+ #import "Utils.h"
14
+
15
+ @implementation CredentialsInputController
16
+
17
+ - (id)initWithNibName:(NSString *)nibNameOrNil
18
+ bundle:(NSBundle *)nibBundleOrNil
19
+ session:(RDPSession *)session
20
+ params:(NSMutableDictionary *)params
21
+ {
22
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
23
+ if (self)
24
+ {
25
+ _session = session;
26
+ _params = params;
27
+ [self setModalPresentationStyle:UIModalPresentationFormSheet];
28
+
29
+ // on iphone we have the problem that the buttons are hidden by the keyboard
30
+ // we solve this issue by registering keyboard notification handlers and adjusting the
31
+ // scrollview accordingly
32
+ if (IsPhone())
33
+ {
34
+ [[NSNotificationCenter defaultCenter] addObserver:self
35
+ selector:@selector(keyboardWillShow:)
36
+ name:UIKeyboardWillShowNotification
37
+ object:nil];
38
+ [[NSNotificationCenter defaultCenter] addObserver:self
39
+ selector:@selector(keyboardWillHide:)
40
+ name:UIKeyboardWillHideNotification
41
+ object:nil];
42
+ }
43
+ }
44
+ return self;
45
+ }
46
+
47
+ - (void)viewDidLoad
48
+ {
49
+ [super viewDidLoad];
50
+
51
+ // set localized strings
52
+ [_lbl_message
53
+ setText:NSLocalizedString(
54
+ @"Please provide the missing user information in order to proceed and login.",
55
+ @"Credentials input view message")];
56
+ [_textfield_username
57
+ setPlaceholder:NSLocalizedString(@"Username", @"Credentials Input Username hint")];
58
+ [_textfield_password
59
+ setPlaceholder:NSLocalizedString(@"Password", @"Credentials Input Password hint")];
60
+ [_textfield_domain
61
+ setPlaceholder:NSLocalizedString(@"Domain", @"Credentials Input Domain hint")];
62
+ [_btn_login setTitle:NSLocalizedString(@"Login", @"Login Button")
63
+ forState:UIControlStateNormal];
64
+ [_btn_cancel setTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
65
+ forState:UIControlStateNormal];
66
+
67
+ // init scrollview content size
68
+ [_scroll_view setContentSize:[_scroll_view frame].size];
69
+
70
+ // set params in the view
71
+ [_textfield_username setText:[_params valueForKey:@"username"]];
72
+ [_textfield_password setText:[_params valueForKey:@"password"]];
73
+ [_textfield_domain setText:[_params valueForKey:@"domain"]];
74
+ }
75
+
76
+ - (void)viewDidUnload
77
+ {
78
+ [super viewDidUnload];
79
+ }
80
+
81
+ - (void)viewDidDisappear:(BOOL)animated
82
+ {
83
+ [super viewDidDisappear:animated];
84
+ // set signal
85
+ [[_session uiRequestCompleted] signal];
86
+ }
87
+
88
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
89
+ {
90
+ return YES;
91
+ }
92
+
93
+ - (void)dealloc
94
+ {
95
+ [super dealloc];
96
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
97
+ }
98
+
99
+ #pragma mark -
100
+ #pragma mark iOS Keyboard Notification Handlers
101
+
102
+ - (void)keyboardWillShow:(NSNotification *)notification
103
+ {
104
+ CGRect keyboardEndFrame =
105
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
106
+ CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
107
+
108
+ [UIView beginAnimations:nil context:NULL];
109
+ [UIView setAnimationCurve:[[[notification userInfo]
110
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
111
+ [UIView
112
+ setAnimationDuration:[[[notification userInfo]
113
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
114
+ CGRect frame = [_scroll_view frame];
115
+ frame.size.height -= keyboardFrame.size.height;
116
+ [_scroll_view setFrame:frame];
117
+ [UIView commitAnimations];
118
+ }
119
+
120
+ - (void)keyboardWillHide:(NSNotification *)notification
121
+ {
122
+ CGRect keyboardEndFrame =
123
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
124
+ CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
125
+
126
+ [UIView beginAnimations:nil context:NULL];
127
+ [UIView setAnimationCurve:[[[notification userInfo]
128
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
129
+ [UIView
130
+ setAnimationDuration:[[[notification userInfo]
131
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
132
+ CGRect frame = [_scroll_view frame];
133
+ frame.size.height += keyboardFrame.size.height;
134
+ [_scroll_view setFrame:frame];
135
+ [UIView commitAnimations];
136
+ }
137
+
138
+ #pragma mark - Action handlers
139
+
140
+ - (IBAction)loginPressed:(id)sender
141
+ {
142
+ // read input back in
143
+ [_params setValue:[_textfield_username text] forKey:@"username"];
144
+ [_params setValue:[_textfield_password text] forKey:@"password"];
145
+ [_params setValue:[_textfield_domain text] forKey:@"domain"];
146
+ [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
147
+
148
+ // dismiss controller
149
+ [self dismissModalViewControllerAnimated:YES];
150
+ }
151
+
152
+ - (IBAction)cancelPressed:(id)sender
153
+ {
154
+ [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
155
+
156
+ // dismiss controller
157
+ [self dismissModalViewControllerAnimated:YES];
158
+ }
159
+
160
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorBaseController.h ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic interface for settings editors
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+ #import "EditTextTableViewCell.h"
13
+ #import "EditFlagTableViewCell.h"
14
+ #import "EditSelectionTableViewCell.h"
15
+ #import "EditSubEditTableViewCell.h"
16
+ #import "EditSecretTextTableViewCell.h"
17
+ #import "EditButtonTableViewCell.h"
18
+
19
+ extern NSString *TableCellIdentifierText;
20
+ extern NSString *TableCellIdentifierSecretText;
21
+ extern NSString *TableCellIdentifierYesNo;
22
+ extern NSString *TableCellIdentifierSelection;
23
+ extern NSString *TableCellIdentifierSubEditor;
24
+ extern NSString *TableCellIdentifierMultiChoice;
25
+ extern NSString *TableCellIdentifierButton;
26
+
27
+ @interface EditorBaseController : UITableViewController <UITextFieldDelegate>
28
+ {
29
+ @private
30
+ IBOutlet EditTextTableViewCell *_textTableViewCell;
31
+ IBOutlet EditSecretTextTableViewCell *_secretTextTableViewCell;
32
+ IBOutlet EditFlagTableViewCell *_flagTableViewCell;
33
+ IBOutlet EditSelectionTableViewCell *_selectionTableViewCell;
34
+ IBOutlet EditSubEditTableViewCell *_subEditTableViewCell;
35
+ IBOutlet EditButtonTableViewCell *_buttonTableViewCell;
36
+ }
37
+
38
+ // returns one of the requested table view cells
39
+ - (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier;
40
+
41
+ // Adjust text input cells label/textfield width according to the label's text size
42
+ - (void)adjustEditTextTableViewCell:(EditTextTableViewCell *)cell;
43
+
44
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorBaseController.m ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Basic interface for settings editors
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @interface EditorBaseController ()
14
+
15
+ @end
16
+
17
+ NSString *TableCellIdentifierText = @"cellIdText";
18
+ NSString *TableCellIdentifierSecretText = @"cellIdSecretText";
19
+ NSString *TableCellIdentifierYesNo = @"cellIdYesNo";
20
+ NSString *TableCellIdentifierSelection = @"cellIdSelection";
21
+ NSString *TableCellIdentifierSubEditor = @"cellIdSubEditor";
22
+ NSString *TableCellIdentifierMultiChoice = @"cellIdMultiChoice";
23
+ NSString *TableCellIdentifierButton = @"cellIdButton";
24
+
25
+ @implementation EditorBaseController
26
+
27
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
28
+ {
29
+ return YES;
30
+ }
31
+
32
+ #pragma mark - Create table view cells
33
+ - (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier
34
+ {
35
+ // try to reuse a cell
36
+ UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:identifier];
37
+ if (cell != nil)
38
+ return cell;
39
+
40
+ // we have to create a new cell
41
+ if ([identifier isEqualToString:TableCellIdentifierText])
42
+ {
43
+ [[NSBundle mainBundle] loadNibNamed:@"EditTextTableViewCell" owner:self options:nil];
44
+ cell = _textTableViewCell;
45
+ _textTableViewCell = nil;
46
+ }
47
+ else if ([identifier isEqualToString:TableCellIdentifierSecretText])
48
+ {
49
+ [[NSBundle mainBundle] loadNibNamed:@"EditSecretTextTableViewCell" owner:self options:nil];
50
+ cell = _secretTextTableViewCell;
51
+ _secretTextTableViewCell = nil;
52
+ }
53
+ else if ([identifier isEqualToString:TableCellIdentifierYesNo])
54
+ {
55
+ [[NSBundle mainBundle] loadNibNamed:@"EditFlagTableViewCell" owner:self options:nil];
56
+ cell = _flagTableViewCell;
57
+ _flagTableViewCell = nil;
58
+ }
59
+ else if ([identifier isEqualToString:TableCellIdentifierSelection])
60
+ {
61
+ [[NSBundle mainBundle] loadNibNamed:@"EditSelectionTableViewCell" owner:self options:nil];
62
+ cell = _selectionTableViewCell;
63
+ _selectionTableViewCell = nil;
64
+ }
65
+ else if ([identifier isEqualToString:TableCellIdentifierSubEditor])
66
+ {
67
+ [[NSBundle mainBundle] loadNibNamed:@"EditSubEditTableViewCell" owner:self options:nil];
68
+ cell = _subEditTableViewCell;
69
+ _subEditTableViewCell = nil;
70
+ }
71
+ else if ([identifier isEqualToString:TableCellIdentifierButton])
72
+ {
73
+ [[NSBundle mainBundle] loadNibNamed:@"EditButtonTableViewCell" owner:self options:nil];
74
+ cell = _buttonTableViewCell;
75
+ _buttonTableViewCell = nil;
76
+ }
77
+ else if ([identifier isEqualToString:TableCellIdentifierMultiChoice])
78
+ {
79
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
80
+ reuseIdentifier:identifier] autorelease];
81
+ }
82
+ else
83
+ {
84
+ NSAssert(false, @"Unknown table cell identifier");
85
+ }
86
+
87
+ return cell;
88
+ }
89
+
90
+ #pragma mark - Utility functions
91
+ - (void)adjustEditTextTableViewCell:(EditTextTableViewCell *)cell
92
+ {
93
+ UILabel *label = [cell label];
94
+ UITextField *textField = [cell textfield];
95
+
96
+ // adjust label
97
+ CGFloat width = [[label text] sizeWithFont:[label font]].width;
98
+ CGRect frame = [label frame];
99
+ CGFloat delta = width - frame.size.width;
100
+ frame.size.width = width;
101
+ [label setFrame:frame];
102
+
103
+ // adjust text field
104
+ frame = [textField frame];
105
+ frame.origin.x += delta;
106
+ frame.size.width -= delta;
107
+ [textField setFrame:frame];
108
+ }
109
+
110
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EditorSelectionController.m ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Generic controller to select a single item from a list of options
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorSelectionController.h"
12
+ #import "ConnectionParams.h"
13
+ #import "OrderedDictionary.h"
14
+
15
+ @interface EditorSelectionController (Private)
16
+ - (OrderedDictionary *)selectionForIndex:(int)index;
17
+ @end
18
+
19
+ @implementation EditorSelectionController
20
+
21
+ - (id)initWithConnectionParams:(ConnectionParams *)params
22
+ entries:(NSArray *)entries
23
+ selections:(NSArray *)selections
24
+ {
25
+ self = [super initWithStyle:UITableViewStyleGrouped];
26
+ if (self)
27
+ {
28
+ _params = [params retain];
29
+ _entries = [entries retain];
30
+ _selections = [selections retain];
31
+
32
+ // allocate and init current selections array
33
+ _cur_selections = [[NSMutableArray alloc] initWithCapacity:[_entries count]];
34
+ for (int i = 0; i < [entries count]; ++i)
35
+ {
36
+ NSString *entry = [entries objectAtIndex:i];
37
+ if ([_params hasValueForKeyPath:entry])
38
+ {
39
+ NSUInteger idx = [(OrderedDictionary *)[selections objectAtIndex:i]
40
+ indexForValue:[NSNumber numberWithInt:[_params intForKeyPath:entry]]];
41
+ [_cur_selections addObject:[NSNumber numberWithInt:(idx != NSNotFound ? idx : 0)]];
42
+ }
43
+ else
44
+ [_cur_selections addObject:[NSNumber numberWithInt:0]];
45
+ }
46
+ }
47
+ return self;
48
+ }
49
+
50
+ - (void)didReceiveMemoryWarning
51
+ {
52
+ // Releases the view if it doesn't have a superview.
53
+ [super didReceiveMemoryWarning];
54
+
55
+ // Release any cached data, images, etc that aren't in use.
56
+ [_params autorelease];
57
+ [_entries autorelease];
58
+ [_selections autorelease];
59
+ [_cur_selections autorelease];
60
+ }
61
+
62
+ #pragma mark - View lifecycle
63
+
64
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
65
+ {
66
+ // Return YES for supported orientations
67
+ return YES;
68
+ }
69
+
70
+ #pragma mark - Table view data source
71
+
72
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
73
+ {
74
+ // Return the number of sections.
75
+ return [_entries count];
76
+ }
77
+
78
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
79
+ {
80
+ // Return the number of rows in the section.
81
+ return [[self selectionForIndex:section] count];
82
+ }
83
+
84
+ - (UITableViewCell *)tableView:(UITableView *)tableView
85
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
86
+ {
87
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
88
+
89
+ // get selection
90
+ OrderedDictionary *selection = [self selectionForIndex:[indexPath section]];
91
+
92
+ // set cell properties
93
+ [[cell textLabel] setText:[selection keyAtIndex:[indexPath row]]];
94
+
95
+ // set default checkmark
96
+ if ([indexPath row] == [[_cur_selections objectAtIndex:[indexPath section]] intValue])
97
+ [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
98
+ else
99
+ [cell setAccessoryType:UITableViewCellAccessoryNone];
100
+
101
+ return cell;
102
+ }
103
+
104
+ #pragma mark - Table view delegate
105
+
106
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
107
+ {
108
+ // has selection change?
109
+ int cur_selection = [[_cur_selections objectAtIndex:[indexPath section]] intValue];
110
+ if ([indexPath row] != cur_selection)
111
+ {
112
+ [tableView deselectRowAtIndexPath:indexPath animated:NO];
113
+
114
+ NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:cur_selection
115
+ inSection:[indexPath section]];
116
+
117
+ // clear old checkmark
118
+ UITableViewCell *old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
119
+ old_sel_cell.accessoryType = UITableViewCellAccessoryNone;
120
+
121
+ // set new checkmark
122
+ UITableViewCell *new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
123
+ new_sel_cell.accessoryType = UITableViewCellAccessoryCheckmark;
124
+
125
+ // get value from selection dictionary
126
+ OrderedDictionary *dict = [self selectionForIndex:[indexPath section]];
127
+ int sel_value = [[dict valueForKey:[dict keyAtIndex:[indexPath row]]] intValue];
128
+
129
+ // update selection index and params value
130
+ [_cur_selections replaceObjectAtIndex:[indexPath section]
131
+ withObject:[NSNumber numberWithInt:[indexPath row]]];
132
+ [_params setInt:sel_value forKeyPath:[_entries objectAtIndex:[indexPath section]]];
133
+ }
134
+ }
135
+
136
+ #pragma mark - Convenience functions
137
+
138
+ - (OrderedDictionary *)selectionForIndex:(int)index
139
+ {
140
+ return (OrderedDictionary *)[_selections objectAtIndex:index];
141
+ }
142
+
143
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EncryptionController.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Password Encryption Controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import "Encryptor.h"
13
+
14
+ @interface EncryptionController : NSObject
15
+ {
16
+ Encryptor *_shared_encryptor;
17
+ }
18
+
19
+ + (EncryptionController *)sharedEncryptionController;
20
+
21
+ // Return a Encryptor suitable for encrypting or decrypting with the master password
22
+ - (Encryptor *)decryptor;
23
+ - (Encryptor *)encryptor;
24
+
25
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/EncryptionController.m ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Password Encryption Controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EncryptionController.h"
12
+ #import "SFHFKeychainUtils.h"
13
+ #import "TSXAdditions.h"
14
+
15
+ @interface EncryptionController (Private)
16
+
17
+ - (BOOL)verifyPassword:(Encryptor *)decryptor;
18
+ - (NSData *)encryptedVerificationData;
19
+ - (void)setEncryptedVerificationData:(Encryptor *)encryptor;
20
+
21
+ - (NSString *)keychainServerName;
22
+ - (NSString *)keychainUsername;
23
+ - (void)setKeychainPassword:(NSString *)password;
24
+ - (NSString *)keychainPassword;
25
+ - (NSString *)keychainDefaultPassword;
26
+
27
+ @end
28
+
29
+ static EncryptionController *_shared_encryption_controller = nil;
30
+
31
+ #pragma mark -
32
+
33
+ @implementation EncryptionController
34
+
35
+ + (EncryptionController *)sharedEncryptionController
36
+ {
37
+ @synchronized(self)
38
+ {
39
+ if (_shared_encryption_controller == nil)
40
+ _shared_encryption_controller = [[EncryptionController alloc] init];
41
+ }
42
+
43
+ return _shared_encryption_controller;
44
+ }
45
+
46
+ #pragma mark Getting an encryptor or decryptor
47
+
48
+ - (Encryptor *)encryptor
49
+ {
50
+ if (_shared_encryptor)
51
+ return _shared_encryptor;
52
+
53
+ NSString *saved_password = [self keychainPassword];
54
+ if (saved_password == nil)
55
+ {
56
+ saved_password = [self keychainDefaultPassword];
57
+ Encryptor *encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
58
+ [self setEncryptedVerificationData:encryptor];
59
+ _shared_encryptor = [encryptor retain];
60
+ }
61
+ else
62
+ {
63
+ Encryptor *encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
64
+ if ([self verifyPassword:encryptor])
65
+ _shared_encryptor = [encryptor retain];
66
+ }
67
+
68
+ return _shared_encryptor;
69
+ }
70
+
71
+ // For the current implementation, decryptors and encryptors are equivalent.
72
+ - (Encryptor *)decryptor
73
+ {
74
+ return [self encryptor];
75
+ }
76
+
77
+ @end
78
+
79
+ #pragma mark -
80
+
81
+ @implementation EncryptionController (Private)
82
+
83
+ #pragma mark -
84
+ #pragma mark Keychain password storage
85
+
86
+ - (NSString *)keychainServerName
87
+ {
88
+ return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
89
+ }
90
+
91
+ - (NSString *)keychainUsername
92
+ {
93
+ return @"master.password";
94
+ }
95
+
96
+ - (void)setKeychainPassword:(NSString *)password
97
+ {
98
+ NSError *error;
99
+ if (password == nil)
100
+ {
101
+ [SFHFKeychainUtils deleteItemForUsername:[self keychainUsername]
102
+ andServerName:[self keychainServerName]
103
+ error:&error];
104
+ return;
105
+ }
106
+
107
+ [SFHFKeychainUtils storeUsername:[self keychainUsername]
108
+ andPassword:password
109
+ forServerName:[self keychainServerName]
110
+ updateExisting:YES
111
+ error:&error];
112
+ }
113
+
114
+ - (NSString *)keychainPassword
115
+ {
116
+ NSError *error;
117
+ return [SFHFKeychainUtils getPasswordForUsername:[self keychainUsername]
118
+ andServerName:[self keychainServerName]
119
+ error:&error];
120
+ }
121
+
122
+ - (NSString *)keychainDefaultPassword
123
+ {
124
+ NSString *password = [[NSUserDefaults standardUserDefaults] stringForKey:@"UUID"];
125
+ if ([password length] == 0)
126
+ {
127
+ password = [NSString stringWithUUID];
128
+ [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"];
129
+ [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TSXMasterPasswordVerification"];
130
+ }
131
+ return password;
132
+ }
133
+
134
+ #pragma mark -
135
+ #pragma mark Verification of encryption key against verification data
136
+
137
+ - (BOOL)verifyPassword:(Encryptor *)decryptor
138
+ {
139
+ return [[decryptor plaintextPassword]
140
+ isEqualToString:[decryptor decryptString:[self encryptedVerificationData]]];
141
+ }
142
+
143
+ - (NSData *)encryptedVerificationData
144
+ {
145
+ return [[NSUserDefaults standardUserDefaults] dataForKey:@"TSXMasterPasswordVerification"];
146
+ }
147
+
148
+ - (void)setEncryptedVerificationData:(Encryptor *)encryptor
149
+ {
150
+ [[NSUserDefaults standardUserDefaults]
151
+ setObject:[encryptor encryptString:[encryptor plaintextPassword]]
152
+ forKey:@"TSXMasterPasswordVerification"];
153
+ }
154
+
155
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/HelpController.h ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Application help controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+
13
+ @interface HelpController : UIViewController <UIWebViewDelegate>
14
+ {
15
+ UIWebView *webView;
16
+ }
17
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/HelpController.m ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Application help controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "HelpController.h"
12
+ #import "Utils.h"
13
+
14
+ @implementation HelpController
15
+
16
+ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
17
+ {
18
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
19
+ if (self)
20
+ {
21
+ // set title and tab-bar image
22
+ [self setTitle:NSLocalizedString(@"Help", @"Help Controller title")];
23
+ UIImage *tabBarIcon = [UIImage
24
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_help"
25
+ ofType:@"png"]];
26
+ [self setTabBarItem:[[[UITabBarItem alloc]
27
+ initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help")
28
+ image:tabBarIcon
29
+ tag:0] autorelease]];
30
+ }
31
+ return self;
32
+ }
33
+
34
+ // Implement loadView to create a view hierarchy programmatically, without using a nib.
35
+ - (void)loadView
36
+ {
37
+ webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
38
+ [webView
39
+ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
40
+ [webView setAutoresizesSubviews:YES];
41
+ [webView setDelegate:self];
42
+ [webView setDataDetectorTypes:UIDataDetectorTypeNone];
43
+ [self setView:webView];
44
+ }
45
+
46
+ - (void)dealloc
47
+ {
48
+ [super dealloc];
49
+ }
50
+
51
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
52
+ - (void)viewDidLoad
53
+ {
54
+ [super viewDidLoad];
55
+
56
+ NSString *filename = (IsPhone() ? @"gestures_phone" : @"gestures");
57
+ NSString *htmlString = [[[NSString alloc]
58
+ initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
59
+ ofType:@"html"
60
+ inDirectory:@"help_page"]
61
+ encoding:NSUTF8StringEncoding
62
+ error:nil] autorelease];
63
+
64
+ [webView
65
+ loadHTMLString:htmlString
66
+ baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
67
+ stringByAppendingPathComponent:@"help_page"]]];
68
+ }
69
+
70
+ // Override to allow orientations other than the default portrait orientation.
71
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
72
+ {
73
+ return YES;
74
+ }
75
+
76
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/MainTabBarController.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ main tabbar controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import <UIKit/UIKit.h>
13
+
14
+ @interface MainTabBarController : UITabBarController
15
+ {
16
+ }
17
+
18
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/MainTabBarController.m ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ main tabbar controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "MainTabBarController.h"
12
+
13
+ @implementation MainTabBarController
14
+
15
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
16
+ {
17
+ return YES;
18
+ }
19
+
20
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/PerformanceEditorController.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ controller for performance settings selection
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @class ConnectionParams;
14
+
15
+ @interface PerformanceEditorController : EditorBaseController
16
+ {
17
+ @private
18
+ ConnectionParams *_params;
19
+ NSString *_keyPath;
20
+ }
21
+
22
+ - (id)initWithConnectionParams:(ConnectionParams *)params;
23
+ - (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
24
+
25
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/PerformanceEditorController.m ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ controller for performance settings selection
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "PerformanceEditorController.h"
12
+ #import "ConnectionParams.h"
13
+ #import "Utils.h"
14
+
15
+ @interface PerformanceEditorController (Private)
16
+ - (NSString *)keyPathForKey:(NSString *)key;
17
+ @end
18
+
19
+ @implementation PerformanceEditorController
20
+
21
+ - (id)initWithConnectionParams:(ConnectionParams *)params
22
+ {
23
+ return [self initWithConnectionParams:params keyPath:nil];
24
+ }
25
+
26
+ - (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
27
+ {
28
+ self = [super initWithStyle:UITableViewStyleGrouped];
29
+
30
+ if (self)
31
+ {
32
+ _params = [params retain];
33
+ _keyPath = (keyPath != nil ? [keyPath retain] : nil);
34
+ }
35
+
36
+ return self;
37
+ }
38
+
39
+ - (void)viewDidLoad
40
+ {
41
+ [super viewDidLoad];
42
+ // Do any additional setup after loading the view.
43
+ }
44
+
45
+ - (void)viewDidUnload
46
+ {
47
+ [super viewDidUnload];
48
+ // Release any retained subviews of the main view.
49
+ }
50
+
51
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
52
+ {
53
+ return YES;
54
+ }
55
+
56
+ - (NSString *)keyPathForKey:(NSString *)key
57
+ {
58
+ if (_keyPath)
59
+ return [_keyPath stringByAppendingFormat:@".%@", key];
60
+
61
+ return key;
62
+ }
63
+
64
+ - (void)dealloc
65
+ {
66
+ [super dealloc];
67
+ [_params release];
68
+ }
69
+
70
+ #pragma mark -
71
+ #pragma mark Table view data source
72
+
73
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
74
+ {
75
+ // Return the number of sections.
76
+ return 1;
77
+ }
78
+
79
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
80
+ {
81
+ return 7;
82
+ }
83
+
84
+ // set section headers
85
+ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
86
+ {
87
+ return NSLocalizedString(@"Performance Settings",
88
+ @"'Performance Settings': performance settings header");
89
+ }
90
+
91
+ // Customize the appearance of table view cells.
92
+ - (UITableViewCell *)tableView:(UITableView *)tableView
93
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
94
+ {
95
+ // get the table view cell
96
+ EditFlagTableViewCell *cell =
97
+ (EditFlagTableViewCell *)[self tableViewCellFromIdentifier:TableCellIdentifierYesNo];
98
+ NSAssert(cell, @"Invalid cell");
99
+
100
+ switch ([indexPath row])
101
+ {
102
+ case 0:
103
+ {
104
+ [[cell label] setText:NSLocalizedString(@"RemoteFX", @"RemoteFX performance setting")];
105
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_remotefx"]]];
106
+ break;
107
+ }
108
+
109
+ case 1:
110
+ {
111
+ [[cell label] setText:NSLocalizedString(@"GFX", @"GFX performance setting")];
112
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_gfx"]]];
113
+ break;
114
+ }
115
+
116
+ case 2:
117
+ {
118
+ [[cell label] setText:NSLocalizedString(@"H264", @"H264 performance setting")];
119
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_h264"]]];
120
+ break;
121
+ }
122
+
123
+ case 3:
124
+ {
125
+ [[cell label] setText:NSLocalizedString(@"Desktop Background",
126
+ @"Desktop background performance setting")];
127
+ [[cell toggle]
128
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_show_desktop"]]];
129
+ break;
130
+ }
131
+
132
+ case 4:
133
+ {
134
+ [[cell label] setText:NSLocalizedString(@"Font Smoothing",
135
+ @"Font smoothing performance setting")];
136
+ [[cell toggle]
137
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_font_smoothing"]]];
138
+ break;
139
+ }
140
+
141
+ case 5:
142
+ {
143
+ [[cell label] setText:NSLocalizedString(@"Desktop Composition",
144
+ @"Desktop composition performance setting")];
145
+ [[cell toggle]
146
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_desktop_composition"]]];
147
+ break;
148
+ }
149
+
150
+ case 6:
151
+ {
152
+ [[cell label] setText:NSLocalizedString(@"Window contents while dragging",
153
+ @"Window Dragging performance setting")];
154
+ [[cell toggle]
155
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_window_dragging"]]];
156
+ break;
157
+ }
158
+
159
+ case 7:
160
+ {
161
+ [[cell label] setText:NSLocalizedString(@"Menu Animation",
162
+ @"Menu Animations performance setting")];
163
+ [[cell toggle]
164
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_menu_animation"]]];
165
+ break;
166
+ }
167
+
168
+ case 8:
169
+ {
170
+ [[cell label]
171
+ setText:NSLocalizedString(@"Visual Styles", @"Use Themes performance setting")];
172
+ [[cell toggle]
173
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_windows_themes"]]];
174
+ break;
175
+ }
176
+
177
+ default:
178
+ break;
179
+ }
180
+
181
+ [[cell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
182
+ [[cell toggle] addTarget:self
183
+ action:@selector(togglePerformanceSetting:)
184
+ forControlEvents:UIControlEventValueChanged];
185
+ return cell;
186
+ }
187
+
188
+ #pragma mark -
189
+ #pragma mark Action Handlers
190
+
191
+ - (void)togglePerformanceSetting:(id)sender
192
+ {
193
+ UISwitch *valueSwitch = (UISwitch *)sender;
194
+
195
+ switch (valueSwitch.tag)
196
+ {
197
+ case GET_TAG(0, 0):
198
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_remotefx"]];
199
+ break;
200
+
201
+ case GET_TAG(0, 1):
202
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_gfx"]];
203
+ break;
204
+
205
+ case GET_TAG(0, 2):
206
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_h264"]];
207
+ break;
208
+
209
+ case GET_TAG(0, 3):
210
+ [_params setBool:[valueSwitch isOn]
211
+ forKeyPath:[self keyPathForKey:@"perf_show_desktop"]];
212
+ break;
213
+
214
+ case GET_TAG(0, 4):
215
+ [_params setBool:[valueSwitch isOn]
216
+ forKeyPath:[self keyPathForKey:@"perf_font_smoothing"]];
217
+ break;
218
+
219
+ case GET_TAG(0, 5):
220
+ [_params setBool:[valueSwitch isOn]
221
+ forKeyPath:[self keyPathForKey:@"perf_desktop_composition"]];
222
+ break;
223
+
224
+ case GET_TAG(0, 6):
225
+ [_params setBool:[valueSwitch isOn]
226
+ forKeyPath:[self keyPathForKey:@"perf_window_dragging"]];
227
+ break;
228
+
229
+ case GET_TAG(0, 7):
230
+ [_params setBool:[valueSwitch isOn]
231
+ forKeyPath:[self keyPathForKey:@"perf_menu_animation"]];
232
+ break;
233
+
234
+ case GET_TAG(0, 8):
235
+ [_params setBool:[valueSwitch isOn]
236
+ forKeyPath:[self keyPathForKey:@"perf_windows_themes"]];
237
+ break;
238
+
239
+ default:
240
+ break;
241
+ }
242
+ }
243
+
244
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/RDPSessionViewController.h ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Session View Controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+ #import "RDPSession.h"
13
+ #import "RDPKeyboard.h"
14
+ #import "RDPSessionView.h"
15
+ #import "TouchPointerView.h"
16
+ #import "AdvancedKeyboardView.h"
17
+
18
+ @interface RDPSessionViewController
19
+ : UIViewController <RDPSessionDelegate, TouchPointerDelegate, AdvancedKeyboardDelegate,
20
+ RDPKeyboardDelegate, UIScrollViewDelegate, UITextFieldDelegate>
21
+ {
22
+ // scrollview that hosts the rdp session view
23
+ IBOutlet UIScrollView *_session_scrollview;
24
+
25
+ // rdp session view
26
+ IBOutlet RDPSessionView *_session_view;
27
+
28
+ // touch pointer view
29
+ IBOutlet TouchPointerView *_touchpointer_view;
30
+ BOOL _autoscroll_with_touchpointer;
31
+ BOOL _is_autoscrolling;
32
+
33
+ // rdp session toolbar
34
+ IBOutlet UIToolbar *_session_toolbar;
35
+ BOOL _session_toolbar_visible;
36
+
37
+ // dummy text field used to display the keyboard
38
+ IBOutlet UITextField *_dummy_textfield;
39
+
40
+ // connecting view and the controls within that view
41
+ IBOutlet UIView *_connecting_view;
42
+ IBOutlet UILabel *_lbl_connecting;
43
+ IBOutlet UIActivityIndicatorView *_connecting_indicator_view;
44
+ IBOutlet UIButton *_cancel_connect_button;
45
+
46
+ // extended keyboard toolbar
47
+ UIToolbar *_keyboard_toolbar;
48
+
49
+ // rdp session
50
+ RDPSession *_session;
51
+ BOOL _session_initilized;
52
+
53
+ // flag that indicates whether the keyboard is visible or not
54
+ BOOL _keyboard_visible;
55
+
56
+ // flag to switch between left/right mouse button mode
57
+ BOOL _toggle_mouse_button;
58
+
59
+ // keyboard extension view
60
+ AdvancedKeyboardView *_advanced_keyboard_view;
61
+ BOOL _advanced_keyboard_visible;
62
+ BOOL _requesting_advanced_keyboard;
63
+ CGFloat _keyboard_last_height;
64
+
65
+ // delayed mouse move event sending
66
+ NSTimer *_mouse_move_event_timer;
67
+ int _mouse_move_events_skipped;
68
+ CGPoint _prev_long_press_position;
69
+ }
70
+
71
+ - (id)initWithNibName:(NSString *)nibNameOrNil
72
+ bundle:(NSBundle *)nibBundleOrNil
73
+ session:(RDPSession *)session;
74
+
75
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/RDPSessionViewController.m ADDED
@@ -0,0 +1,1113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Session View Controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <QuartzCore/QuartzCore.h>
12
+ #import "RDPSessionViewController.h"
13
+ #import "RDPKeyboard.h"
14
+ #import "Utils.h"
15
+ #import "Toast+UIView.h"
16
+ #import "ConnectionParams.h"
17
+ #import "CredentialsInputController.h"
18
+ #import "VerifyCertificateController.h"
19
+ #import "BlockAlertView.h"
20
+
21
+ #define TOOLBAR_HEIGHT 30
22
+
23
+ #define AUTOSCROLLDISTANCE 20
24
+ #define AUTOSCROLLTIMEOUT 0.05
25
+
26
+ @interface RDPSessionViewController (Private)
27
+ - (void)showSessionToolbar:(BOOL)show;
28
+ - (UIToolbar *)keyboardToolbar;
29
+ - (void)initGestureRecognizers;
30
+ - (void)suspendSession;
31
+ - (NSDictionary *)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position;
32
+ - (void)handleMouseMoveForPosition:(CGPoint)position;
33
+ @end
34
+
35
+ @implementation RDPSessionViewController
36
+
37
+ #pragma mark class methods
38
+
39
+ - (id)initWithNibName:(NSString *)nibNameOrNil
40
+ bundle:(NSBundle *)nibBundleOrNil
41
+ session:(RDPSession *)session
42
+ {
43
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
44
+ if (self)
45
+ {
46
+ _session = [session retain];
47
+ [_session setDelegate:self];
48
+ _session_initilized = NO;
49
+
50
+ _mouse_move_events_skipped = 0;
51
+ _mouse_move_event_timer = nil;
52
+
53
+ _advanced_keyboard_view = nil;
54
+ _advanced_keyboard_visible = NO;
55
+ _requesting_advanced_keyboard = NO;
56
+ _keyboard_last_height = 0;
57
+
58
+ _session_toolbar_visible = NO;
59
+
60
+ _toggle_mouse_button = NO;
61
+
62
+ _autoscroll_with_touchpointer =
63
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.auto_scroll_touchpointer"];
64
+ _is_autoscrolling = NO;
65
+
66
+ [UIView setAnimationDelegate:self];
67
+ [UIView setAnimationDidStopSelector:@selector(animationStopped:finished:context:)];
68
+ }
69
+
70
+ return self;
71
+ }
72
+
73
+ // Implement loadView to create a view hierarchy programmatically, without using a nib.
74
+ - (void)loadView
75
+ {
76
+ // load default view and set background color and resizing mask
77
+ [super loadView];
78
+
79
+ // init keyboard handling vars
80
+ _keyboard_visible = NO;
81
+
82
+ // init keyboard toolbar
83
+ _keyboard_toolbar = [[self keyboardToolbar] retain];
84
+ [_dummy_textfield setInputAccessoryView:_keyboard_toolbar];
85
+
86
+ // init gesture recognizers
87
+ [self initGestureRecognizers];
88
+
89
+ // hide session toolbar
90
+ [_session_toolbar
91
+ setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
92
+ }
93
+
94
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
95
+ - (void)viewDidLoad
96
+ {
97
+ [super viewDidLoad];
98
+ }
99
+
100
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
101
+ {
102
+ return YES;
103
+ }
104
+
105
+ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
106
+ {
107
+ if (![_touchpointer_view isHidden])
108
+ [_touchpointer_view ensurePointerIsVisible];
109
+ }
110
+
111
+ - (void)didReceiveMemoryWarning
112
+ {
113
+ // Releases the view if it doesn't have a superview.
114
+ [super didReceiveMemoryWarning];
115
+
116
+ // Release any cached data, images, etc. that aren't in use.
117
+ }
118
+
119
+ - (void)viewDidUnload
120
+ {
121
+ [super viewDidUnload];
122
+ // Release any retained subviews of the main view.
123
+ // e.g. self.myOutlet = nil;
124
+ }
125
+
126
+ - (void)viewWillAppear:(BOOL)animated
127
+ {
128
+ [super viewWillAppear:animated];
129
+
130
+ // hide navigation bar and (if enabled) the status bar
131
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"])
132
+ {
133
+ if (animated == YES)
134
+ [[UIApplication sharedApplication] setStatusBarHidden:YES
135
+ withAnimation:UIStatusBarAnimationSlide];
136
+ else
137
+ [[UIApplication sharedApplication] setStatusBarHidden:YES
138
+ withAnimation:UIStatusBarAnimationNone];
139
+ }
140
+ [[self navigationController] setNavigationBarHidden:YES animated:animated];
141
+
142
+ // if session is suspended - notify that we got a new bitmap context
143
+ if ([_session isSuspended])
144
+ [self sessionBitmapContextWillChange:_session];
145
+
146
+ // init keyboard
147
+ [[RDPKeyboard getSharedRDPKeyboard] initWithSession:_session delegate:self];
148
+ }
149
+
150
+ - (void)viewDidAppear:(BOOL)animated
151
+ {
152
+ [super viewDidAppear:animated];
153
+
154
+ if (!_session_initilized)
155
+ {
156
+ if ([_session isSuspended])
157
+ {
158
+ [_session resume];
159
+ [self sessionBitmapContextDidChange:_session];
160
+ [_session_view setNeedsDisplay];
161
+ }
162
+ else
163
+ [_session connect];
164
+
165
+ _session_initilized = YES;
166
+ }
167
+ }
168
+
169
+ - (void)viewWillDisappear:(BOOL)animated
170
+ {
171
+ [super viewWillDisappear:animated];
172
+
173
+ // show navigation and status bar again
174
+ if (animated == YES)
175
+ [[UIApplication sharedApplication] setStatusBarHidden:NO
176
+ withAnimation:UIStatusBarAnimationSlide];
177
+ else
178
+ [[UIApplication sharedApplication] setStatusBarHidden:NO
179
+ withAnimation:UIStatusBarAnimationNone];
180
+ [[self navigationController] setNavigationBarHidden:NO animated:animated];
181
+
182
+ // reset all modifier keys on rdp keyboard
183
+ [[RDPKeyboard getSharedRDPKeyboard] reset];
184
+
185
+ // hide toolbar and keyboard
186
+ [self showSessionToolbar:NO];
187
+ [_dummy_textfield resignFirstResponder];
188
+ }
189
+
190
+ - (void)dealloc
191
+ {
192
+ // remove any observers
193
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
194
+
195
+ // the session lives on longer so set the delegate to nil
196
+ [_session setDelegate:nil];
197
+
198
+ [_advanced_keyboard_view release];
199
+ [_keyboard_toolbar release];
200
+ [_session release];
201
+ [super dealloc];
202
+ }
203
+
204
+ #pragma mark -
205
+ #pragma mark ScrollView delegate methods
206
+
207
+ - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
208
+ {
209
+ return _session_view;
210
+ }
211
+
212
+ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView
213
+ withView:(UIView *)view
214
+ atScale:(float)scale
215
+ {
216
+ NSLog(@"New zoom scale: %f", scale);
217
+ [_session_view setNeedsDisplay];
218
+ }
219
+
220
+ #pragma mark -
221
+ #pragma mark TextField delegate methods
222
+ - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
223
+ {
224
+ _keyboard_visible = YES;
225
+ _advanced_keyboard_visible = NO;
226
+ return YES;
227
+ }
228
+
229
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
230
+ {
231
+ _keyboard_visible = NO;
232
+ _advanced_keyboard_visible = NO;
233
+ return YES;
234
+ }
235
+
236
+ - (BOOL)textField:(UITextField *)textField
237
+ shouldChangeCharactersInRange:(NSRange)range
238
+ replacementString:(NSString *)string
239
+ {
240
+ if ([string length] > 0)
241
+ {
242
+ for (int i = 0; i < [string length]; i++)
243
+ {
244
+ unichar curChar = [string characterAtIndex:i];
245
+
246
+ // special handling for return/enter key
247
+ if (curChar == '\n')
248
+ [[RDPKeyboard getSharedRDPKeyboard] sendEnterKeyStroke];
249
+ else
250
+ [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:curChar];
251
+ }
252
+ }
253
+ else
254
+ {
255
+ [[RDPKeyboard getSharedRDPKeyboard] sendBackspaceKeyStroke];
256
+ }
257
+
258
+ return NO;
259
+ }
260
+
261
+ #pragma mark -
262
+ #pragma mark AdvancedKeyboardDelegate functions
263
+ - (void)advancedKeyPressedVKey:(int)key
264
+ {
265
+ [[RDPKeyboard getSharedRDPKeyboard] sendVirtualKeyCode:key];
266
+ }
267
+
268
+ - (void)advancedKeyPressedUnicode:(int)key
269
+ {
270
+ [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:key];
271
+ }
272
+
273
+ #pragma mark - RDP keyboard handler
274
+
275
+ - (void)modifiersChangedForKeyboard:(RDPKeyboard *)keyboard
276
+ {
277
+ UIBarButtonItem *curItem;
278
+
279
+ // shift button (only on iPad)
280
+ int objectIdx = 0;
281
+ if (IsPad())
282
+ {
283
+ objectIdx = 2;
284
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
285
+ [curItem setStyle:[keyboard shiftPressed] ? UIBarButtonItemStyleDone
286
+ : UIBarButtonItemStyleBordered];
287
+ }
288
+
289
+ // ctrl button
290
+ objectIdx += 2;
291
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
292
+ [curItem
293
+ setStyle:[keyboard ctrlPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
294
+
295
+ // win button
296
+ objectIdx += 2;
297
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
298
+ [curItem
299
+ setStyle:[keyboard winPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
300
+
301
+ // alt button
302
+ objectIdx += 2;
303
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
304
+ [curItem
305
+ setStyle:[keyboard altPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
306
+ }
307
+
308
+ #pragma mark -
309
+ #pragma mark RDPSessionDelegate functions
310
+
311
+ - (void)session:(RDPSession *)session didFailToConnect:(int)reason
312
+ {
313
+ // remove and release connecting view
314
+ [_connecting_indicator_view stopAnimating];
315
+ [_connecting_view removeFromSuperview];
316
+ [_connecting_view autorelease];
317
+
318
+ // return to bookmark list
319
+ [[self navigationController] popViewControllerAnimated:YES];
320
+ }
321
+
322
+ - (void)sessionWillConnect:(RDPSession *)session
323
+ {
324
+ // load connecting view
325
+ [[NSBundle mainBundle] loadNibNamed:@"RDPConnectingView" owner:self options:nil];
326
+
327
+ // set strings
328
+ [_lbl_connecting setText:NSLocalizedString(@"Connecting", @"Connecting progress view - label")];
329
+ [_cancel_connect_button setTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
330
+ forState:UIControlStateNormal];
331
+
332
+ // center view and give it round corners
333
+ [_connecting_view setCenter:[[self view] center]];
334
+ [[_connecting_view layer] setCornerRadius:10];
335
+
336
+ // display connecting view and start indicator
337
+ [[self view] addSubview:_connecting_view];
338
+ [_connecting_indicator_view startAnimating];
339
+ }
340
+
341
+ - (void)sessionDidConnect:(RDPSession *)session
342
+ {
343
+ // register keyboard notification handlers
344
+ [[NSNotificationCenter defaultCenter] addObserver:self
345
+ selector:@selector(keyboardWillShow:)
346
+ name:UIKeyboardWillShowNotification
347
+ object:nil];
348
+ [[NSNotificationCenter defaultCenter] addObserver:self
349
+ selector:@selector(keyboardDidShow:)
350
+ name:UIKeyboardDidShowNotification
351
+ object:nil];
352
+ [[NSNotificationCenter defaultCenter] addObserver:self
353
+ selector:@selector(keyboardWillHide:)
354
+ name:UIKeyboardWillHideNotification
355
+ object:nil];
356
+ [[NSNotificationCenter defaultCenter] addObserver:self
357
+ selector:@selector(keyboardDidHide:)
358
+ name:UIKeyboardDidHideNotification
359
+ object:nil];
360
+
361
+ // remove and release connecting view
362
+ [_connecting_indicator_view stopAnimating];
363
+ [_connecting_view removeFromSuperview];
364
+ [_connecting_view autorelease];
365
+
366
+ // check if session settings changed ...
367
+ // The 2nd width check is to ignore changes in resolution settings due to the RDVH display bug
368
+ // (refer to RDPSEssion.m for more details)
369
+ ConnectionParams *orig_params = [session params];
370
+ rdpSettings *sess_params = [session getSessionParams];
371
+ if (([orig_params intForKey:@"width"] != sess_params->DesktopWidth &&
372
+ [orig_params intForKey:@"width"] != (sess_params->DesktopWidth + 1)) ||
373
+ [orig_params intForKey:@"height"] != sess_params->DesktopHeight ||
374
+ [orig_params intForKey:@"colors"] != sess_params->ColorDepth)
375
+ {
376
+ // display notification that the session params have been changed by the server
377
+ NSString *message =
378
+ [NSString stringWithFormat:NSLocalizedString(
379
+ @"The server changed the screen settings to %dx%dx%d",
380
+ @"Screen settings not supported message with width, "
381
+ @"height and colors parameter"),
382
+ sess_params->DesktopWidth, sess_params->DesktopHeight,
383
+ sess_params->ColorDepth];
384
+ [[self view] makeToast:message duration:ToastDurationNormal position:@"bottom"];
385
+ }
386
+ }
387
+
388
+ - (void)sessionWillDisconnect:(RDPSession *)session
389
+ {
390
+ }
391
+
392
+ - (void)sessionDidDisconnect:(RDPSession *)session
393
+ {
394
+ // return to bookmark list
395
+ [[self navigationController] popViewControllerAnimated:YES];
396
+ }
397
+
398
+ - (void)sessionBitmapContextWillChange:(RDPSession *)session
399
+ {
400
+ // calc new view frame
401
+ rdpSettings *sess_params = [session getSessionParams];
402
+ CGRect view_rect = CGRectMake(0, 0, sess_params->DesktopWidth, sess_params->DesktopHeight);
403
+
404
+ // reset zoom level and update content size
405
+ [_session_scrollview setZoomScale:1.0];
406
+ [_session_scrollview setContentSize:view_rect.size];
407
+
408
+ // set session view size
409
+ [_session_view setFrame:view_rect];
410
+
411
+ // show/hide toolbar
412
+ [_session
413
+ setToolbarVisible:![[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
414
+ [self showSessionToolbar:[_session toolbarVisible]];
415
+ }
416
+
417
+ - (void)sessionBitmapContextDidChange:(RDPSession *)session
418
+ {
419
+ // associate view with session
420
+ [_session_view setSession:session];
421
+
422
+ // issue an update (this might be needed in case we had a resize for instance)
423
+ [_session_view setNeedsDisplay];
424
+ }
425
+
426
+ - (void)session:(RDPSession *)session needsRedrawInRect:(CGRect)rect
427
+ {
428
+ [_session_view setNeedsDisplayInRect:rect];
429
+ }
430
+
431
+ - (void)session:(RDPSession *)session requestsAuthenticationWithParams:(NSMutableDictionary *)params
432
+ {
433
+ CredentialsInputController *view_controller =
434
+ [[[CredentialsInputController alloc] initWithNibName:@"CredentialsInputView"
435
+ bundle:nil
436
+ session:_session
437
+ params:params] autorelease];
438
+ [self presentModalViewController:view_controller animated:YES];
439
+ }
440
+
441
+ - (void)session:(RDPSession *)session verifyCertificateWithParams:(NSMutableDictionary *)params
442
+ {
443
+ VerifyCertificateController *view_controller =
444
+ [[[VerifyCertificateController alloc] initWithNibName:@"VerifyCertificateView"
445
+ bundle:nil
446
+ session:_session
447
+ params:params] autorelease];
448
+ [self presentModalViewController:view_controller animated:YES];
449
+ }
450
+
451
+ - (CGSize)sizeForFitScreenForSession:(RDPSession *)session
452
+ {
453
+ if (IsPad())
454
+ return [self view].bounds.size;
455
+ else
456
+ {
457
+ // on phones make a resolution that has a 16:10 ratio with the phone's height
458
+ CGSize size = [self view].bounds.size;
459
+ CGFloat maxSize = (size.width > size.height) ? size.width : size.height;
460
+ return CGSizeMake(maxSize * 1.6f, maxSize);
461
+ }
462
+ }
463
+
464
+ #pragma mark - Keyboard Toolbar Handlers
465
+
466
+ - (void)showAdvancedKeyboardAnimated
467
+ {
468
+ // calc initial and final rect of the advanced keyboard view
469
+ CGRect rect = [[_keyboard_toolbar superview] bounds];
470
+ rect.origin.y = [_keyboard_toolbar bounds].size.height;
471
+ rect.size.height -= rect.origin.y;
472
+
473
+ // create new view (hidden) and add to host-view of keyboard toolbar
474
+ _advanced_keyboard_view = [[AdvancedKeyboardView alloc]
475
+ initWithFrame:CGRectMake(rect.origin.x, [[_keyboard_toolbar superview] bounds].size.height,
476
+ rect.size.width, rect.size.height)
477
+ delegate:self];
478
+ [[_keyboard_toolbar superview] addSubview:_advanced_keyboard_view];
479
+ // we set autoresize to YES for the keyboard toolbar's superview so that our adv. keyboard view
480
+ // gets properly resized
481
+ [[_keyboard_toolbar superview] setAutoresizesSubviews:YES];
482
+
483
+ // show view with animation
484
+ [UIView beginAnimations:nil context:NULL];
485
+ [_advanced_keyboard_view setFrame:rect];
486
+ [UIView commitAnimations];
487
+ }
488
+
489
+ - (IBAction)toggleKeyboardWhenOtherVisible:(id)sender
490
+ {
491
+ if (_advanced_keyboard_visible == NO)
492
+ {
493
+ [self showAdvancedKeyboardAnimated];
494
+ }
495
+ else
496
+ {
497
+ // hide existing view
498
+ [UIView beginAnimations:@"hide_advanced_keyboard_view" context:NULL];
499
+ CGRect rect = [_advanced_keyboard_view frame];
500
+ rect.origin.y = [[_keyboard_toolbar superview] bounds].size.height;
501
+ [_advanced_keyboard_view setFrame:rect];
502
+ [UIView commitAnimations];
503
+
504
+ // the view is released in the animationDidStop selector registered in init
505
+ }
506
+
507
+ // toggle flag
508
+ _advanced_keyboard_visible = !_advanced_keyboard_visible;
509
+ }
510
+
511
+ - (IBAction)toggleWinKey:(id)sender
512
+ {
513
+ [[RDPKeyboard getSharedRDPKeyboard] toggleWinKey];
514
+ }
515
+
516
+ - (IBAction)toggleShiftKey:(id)sender
517
+ {
518
+ [[RDPKeyboard getSharedRDPKeyboard] toggleShiftKey];
519
+ }
520
+
521
+ - (IBAction)toggleCtrlKey:(id)sender
522
+ {
523
+ [[RDPKeyboard getSharedRDPKeyboard] toggleCtrlKey];
524
+ }
525
+
526
+ - (IBAction)toggleAltKey:(id)sender
527
+ {
528
+ [[RDPKeyboard getSharedRDPKeyboard] toggleAltKey];
529
+ }
530
+
531
+ - (IBAction)pressEscKey:(id)sender
532
+ {
533
+ [[RDPKeyboard getSharedRDPKeyboard] sendEscapeKeyStroke];
534
+ }
535
+
536
+ #pragma mark -
537
+ #pragma mark event handlers
538
+
539
+ - (void)animationStopped:(NSString *)animationID
540
+ finished:(NSNumber *)finished
541
+ context:(void *)context
542
+ {
543
+ if ([animationID isEqualToString:@"hide_advanced_keyboard_view"])
544
+ {
545
+ // cleanup advanced keyboard view
546
+ [_advanced_keyboard_view removeFromSuperview];
547
+ [_advanced_keyboard_view autorelease];
548
+ _advanced_keyboard_view = nil;
549
+ }
550
+ }
551
+
552
+ - (IBAction)switchSession:(id)sender
553
+ {
554
+ [self suspendSession];
555
+ }
556
+
557
+ - (IBAction)toggleKeyboard:(id)sender
558
+ {
559
+ if (!_keyboard_visible)
560
+ [_dummy_textfield becomeFirstResponder];
561
+ else
562
+ [_dummy_textfield resignFirstResponder];
563
+ }
564
+
565
+ - (IBAction)toggleExtKeyboard:(id)sender
566
+ {
567
+ // if the sys kb is shown but not the advanced kb then toggle the advanced kb
568
+ if (_keyboard_visible && !_advanced_keyboard_visible)
569
+ [self toggleKeyboardWhenOtherVisible:nil];
570
+ else
571
+ {
572
+ // if not visible request the advanced keyboard view
573
+ if (_advanced_keyboard_visible == NO)
574
+ _requesting_advanced_keyboard = YES;
575
+ [self toggleKeyboard:nil];
576
+ }
577
+ }
578
+
579
+ - (IBAction)toggleTouchPointer:(id)sender
580
+ {
581
+ BOOL toggle_visibilty = ![_touchpointer_view isHidden];
582
+ [_touchpointer_view setHidden:toggle_visibilty];
583
+ if (toggle_visibilty)
584
+ [_session_scrollview setContentInset:UIEdgeInsetsZero];
585
+ else
586
+ [_session_scrollview setContentInset:[_touchpointer_view getEdgeInsets]];
587
+ }
588
+
589
+ - (IBAction)disconnectSession:(id)sender
590
+ {
591
+ [_session disconnect];
592
+ }
593
+
594
+ - (IBAction)cancelButtonPressed:(id)sender
595
+ {
596
+ [_session disconnect];
597
+ }
598
+
599
+ #pragma mark -
600
+ #pragma mark iOS Keyboard Notification Handlers
601
+
602
+ // the keyboard is given in a portrait frame of reference
603
+ - (BOOL)isLandscape
604
+ {
605
+
606
+ UIInterfaceOrientation ori = [[UIApplication sharedApplication] statusBarOrientation];
607
+ return (ori == UIInterfaceOrientationLandscapeLeft ||
608
+ ori == UIInterfaceOrientationLandscapeRight);
609
+ }
610
+
611
+ - (void)shiftKeyboard:(NSNotification *)notification
612
+ {
613
+
614
+ CGRect keyboardEndFrame =
615
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
616
+
617
+ CGFloat previousHeight = _keyboard_last_height;
618
+
619
+ if ([self isLandscape])
620
+ {
621
+ // landscape has the keyboard based on x, so x can go negative
622
+ _keyboard_last_height = keyboardEndFrame.size.width + keyboardEndFrame.origin.x;
623
+ }
624
+ else
625
+ {
626
+ // portrait has the keyboard based on the difference of the height and the frames y.
627
+ CGFloat height = [[UIScreen mainScreen] bounds].size.height;
628
+ _keyboard_last_height = height - keyboardEndFrame.origin.y;
629
+ }
630
+
631
+ CGFloat shiftHeight = _keyboard_last_height - previousHeight;
632
+
633
+ [UIView beginAnimations:nil context:NULL];
634
+ [UIView setAnimationCurve:[[[notification userInfo]
635
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
636
+ [UIView
637
+ setAnimationDuration:[[[notification userInfo]
638
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
639
+ CGRect frame = [_session_scrollview frame];
640
+ frame.size.height -= shiftHeight;
641
+ [_session_scrollview setFrame:frame];
642
+ [_touchpointer_view setFrame:frame];
643
+ [UIView commitAnimations];
644
+ }
645
+
646
+ - (void)keyboardWillShow:(NSNotification *)notification
647
+ {
648
+ [self shiftKeyboard:notification];
649
+
650
+ [_touchpointer_view ensurePointerIsVisible];
651
+ }
652
+
653
+ - (void)keyboardDidShow:(NSNotification *)notification
654
+ {
655
+ if (_requesting_advanced_keyboard)
656
+ {
657
+ [self showAdvancedKeyboardAnimated];
658
+ _advanced_keyboard_visible = YES;
659
+ _requesting_advanced_keyboard = NO;
660
+ }
661
+ }
662
+
663
+ - (void)keyboardWillHide:(NSNotification *)notification
664
+ {
665
+
666
+ [self shiftKeyboard:notification];
667
+ }
668
+
669
+ - (void)keyboardDidHide:(NSNotification *)notification
670
+ {
671
+ // release adanced keyboard view
672
+ if (_advanced_keyboard_visible == YES)
673
+ {
674
+ _advanced_keyboard_visible = NO;
675
+ [_advanced_keyboard_view removeFromSuperview];
676
+ [_advanced_keyboard_view autorelease];
677
+ _advanced_keyboard_view = nil;
678
+ }
679
+ }
680
+
681
+ #pragma mark -
682
+ #pragma mark Gesture handlers
683
+
684
+ - (void)handleSingleTap:(UITapGestureRecognizer *)gesture
685
+ {
686
+ CGPoint pos = [gesture locationInView:_session_view];
687
+ if (_toggle_mouse_button)
688
+ {
689
+ [_session
690
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(YES)
691
+ position:pos]];
692
+ [_session
693
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(NO)
694
+ position:pos]];
695
+ }
696
+ else
697
+ {
698
+ [_session
699
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
700
+ position:pos]];
701
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
702
+ position:pos]];
703
+ }
704
+
705
+ _toggle_mouse_button = NO;
706
+ }
707
+
708
+ - (void)handleDoubleTap:(UITapGestureRecognizer *)gesture
709
+ {
710
+ CGPoint pos = [gesture locationInView:_session_view];
711
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
712
+ position:pos]];
713
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
714
+ position:pos]];
715
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
716
+ position:pos]];
717
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
718
+ position:pos]];
719
+ _toggle_mouse_button = NO;
720
+ }
721
+
722
+ - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
723
+ {
724
+ CGPoint pos = [gesture locationInView:_session_view];
725
+
726
+ if ([gesture state] == UIGestureRecognizerStateBegan)
727
+ [_session
728
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
729
+ position:pos]];
730
+ else if ([gesture state] == UIGestureRecognizerStateChanged)
731
+ [self handleMouseMoveForPosition:pos];
732
+ else if ([gesture state] == UIGestureRecognizerStateEnded)
733
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
734
+ position:pos]];
735
+ }
736
+
737
+ - (void)handleDoubleLongPress:(UILongPressGestureRecognizer *)gesture
738
+ {
739
+ // this point is mapped against the scroll view because we want to have relative movement to the
740
+ // screen/scrollview
741
+ CGPoint pos = [gesture locationInView:_session_scrollview];
742
+
743
+ if ([gesture state] == UIGestureRecognizerStateBegan)
744
+ _prev_long_press_position = pos;
745
+ else if ([gesture state] == UIGestureRecognizerStateChanged)
746
+ {
747
+ int delta = _prev_long_press_position.y - pos.y;
748
+
749
+ if (delta > GetScrollGestureDelta())
750
+ {
751
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(YES)
752
+ position:pos]];
753
+ _prev_long_press_position = pos;
754
+ }
755
+ else if (delta < -GetScrollGestureDelta())
756
+ {
757
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(NO)
758
+ position:pos]];
759
+ _prev_long_press_position = pos;
760
+ }
761
+ }
762
+ }
763
+
764
+ - (void)handleSingle2FingersTap:(UITapGestureRecognizer *)gesture
765
+ {
766
+ _toggle_mouse_button = !_toggle_mouse_button;
767
+ }
768
+
769
+ - (void)handleSingle3FingersTap:(UITapGestureRecognizer *)gesture
770
+ {
771
+ [_session setToolbarVisible:![_session toolbarVisible]];
772
+ [self showSessionToolbar:[_session toolbarVisible]];
773
+ }
774
+
775
+ #pragma mark -
776
+ #pragma mark Touch Pointer delegates
777
+ // callback if touch pointer should be closed
778
+ - (void)touchPointerClose
779
+ {
780
+ [self toggleTouchPointer:nil];
781
+ }
782
+
783
+ // callback for a left click action
784
+ - (void)touchPointerLeftClick:(CGPoint)pos down:(BOOL)down
785
+ {
786
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
787
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(down)
788
+ position:session_view_pos]];
789
+ }
790
+
791
+ // callback for a right click action
792
+ - (void)touchPointerRightClick:(CGPoint)pos down:(BOOL)down
793
+ {
794
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
795
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(down)
796
+ position:session_view_pos]];
797
+ }
798
+
799
+ - (void)doAutoScrolling
800
+ {
801
+ int scrollX = 0;
802
+ int scrollY = 0;
803
+ CGPoint curPointerPos = [_touchpointer_view getPointerPosition];
804
+ CGRect viewBounds = [_touchpointer_view bounds];
805
+ CGRect scrollBounds = [_session_view bounds];
806
+
807
+ // add content insets to scroll bounds
808
+ scrollBounds.size.width += [_session_scrollview contentInset].right;
809
+ scrollBounds.size.height += [_session_scrollview contentInset].bottom;
810
+
811
+ // add zoom factor
812
+ scrollBounds.size.width *= [_session_scrollview zoomScale];
813
+ scrollBounds.size.height *= [_session_scrollview zoomScale];
814
+
815
+ if (curPointerPos.x > (viewBounds.size.width - [_touchpointer_view getPointerWidth]))
816
+ scrollX = AUTOSCROLLDISTANCE;
817
+ else if (curPointerPos.x < 0)
818
+ scrollX = -AUTOSCROLLDISTANCE;
819
+
820
+ if (curPointerPos.y > (viewBounds.size.height - [_touchpointer_view getPointerHeight]))
821
+ scrollY = AUTOSCROLLDISTANCE;
822
+ else if (curPointerPos.y < (_session_toolbar_visible ? TOOLBAR_HEIGHT : 0))
823
+ scrollY = -AUTOSCROLLDISTANCE;
824
+
825
+ CGPoint newOffset = [_session_scrollview contentOffset];
826
+ newOffset.x += scrollX;
827
+ newOffset.y += scrollY;
828
+
829
+ // if offset is going off screen - stop scrolling in that direction
830
+ if (newOffset.x < 0)
831
+ {
832
+ scrollX = 0;
833
+ newOffset.x = 0;
834
+ }
835
+ else if (newOffset.x > (scrollBounds.size.width - viewBounds.size.width))
836
+ {
837
+ scrollX = 0;
838
+ newOffset.x = MAX(scrollBounds.size.width - viewBounds.size.width, 0);
839
+ }
840
+ if (newOffset.y < 0)
841
+ {
842
+ scrollY = 0;
843
+ newOffset.y = 0;
844
+ }
845
+ else if (newOffset.y > (scrollBounds.size.height - viewBounds.size.height))
846
+ {
847
+ scrollY = 0;
848
+ newOffset.y = MAX(scrollBounds.size.height - viewBounds.size.height, 0);
849
+ }
850
+
851
+ // perform scrolling
852
+ [_session_scrollview setContentOffset:newOffset];
853
+
854
+ // continue scrolling?
855
+ if (scrollX != 0 || scrollY != 0)
856
+ [self performSelector:@selector(doAutoScrolling)
857
+ withObject:nil
858
+ afterDelay:AUTOSCROLLTIMEOUT];
859
+ else
860
+ _is_autoscrolling = NO;
861
+ }
862
+
863
+ // callback for a right click action
864
+ - (void)touchPointerMove:(CGPoint)pos
865
+ {
866
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
867
+ [self handleMouseMoveForPosition:session_view_pos];
868
+
869
+ if (_autoscroll_with_touchpointer && !_is_autoscrolling)
870
+ {
871
+ _is_autoscrolling = YES;
872
+ [self performSelector:@selector(doAutoScrolling)
873
+ withObject:nil
874
+ afterDelay:AUTOSCROLLTIMEOUT];
875
+ }
876
+ }
877
+
878
+ // callback if scrolling is performed
879
+ - (void)touchPointerScrollDown:(BOOL)down
880
+ {
881
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(down)
882
+ position:CGPointZero]];
883
+ }
884
+
885
+ // callback for toggling the standard keyboard
886
+ - (void)touchPointerToggleKeyboard
887
+ {
888
+ if (_advanced_keyboard_visible)
889
+ [self toggleKeyboardWhenOtherVisible:nil];
890
+ else
891
+ [self toggleKeyboard:nil];
892
+ }
893
+
894
+ // callback for toggling the extended keyboard
895
+ - (void)touchPointerToggleExtendedKeyboard
896
+ {
897
+ [self toggleExtKeyboard:nil];
898
+ }
899
+
900
+ // callback for reset view
901
+ - (void)touchPointerResetSessionView
902
+ {
903
+ [_session_scrollview setZoomScale:1.0 animated:YES];
904
+ }
905
+
906
+ @end
907
+
908
+ @implementation RDPSessionViewController (Private)
909
+
910
+ #pragma mark -
911
+ #pragma mark Helper functions
912
+
913
+ - (void)showSessionToolbar:(BOOL)show
914
+ {
915
+ // already shown or hidden?
916
+ if (_session_toolbar_visible == show)
917
+ return;
918
+
919
+ if (show)
920
+ {
921
+ [UIView beginAnimations:@"showToolbar" context:nil];
922
+ [UIView setAnimationDuration:.4];
923
+ [UIView setAnimationCurve:UIViewAnimationCurveLinear];
924
+ [_session_toolbar
925
+ setFrame:CGRectMake(0.0, 0.0, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
926
+ [UIView commitAnimations];
927
+ _session_toolbar_visible = YES;
928
+ }
929
+ else
930
+ {
931
+ [UIView beginAnimations:@"hideToolbar" context:nil];
932
+ [UIView setAnimationDuration:.4];
933
+ [UIView setAnimationCurve:UIViewAnimationCurveLinear];
934
+ [_session_toolbar setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width,
935
+ TOOLBAR_HEIGHT)];
936
+ [UIView commitAnimations];
937
+ _session_toolbar_visible = NO;
938
+ }
939
+ }
940
+
941
+ - (UIToolbar *)keyboardToolbar
942
+ {
943
+ UIToolbar *keyboard_toolbar = [[[UIToolbar alloc] initWithFrame:CGRectNull] autorelease];
944
+ [keyboard_toolbar setBarStyle:UIBarStyleBlackOpaque];
945
+
946
+ UIBarButtonItem *esc_btn =
947
+ [[[UIBarButtonItem alloc] initWithTitle:@"Esc"
948
+ style:UIBarButtonItemStyleBordered
949
+ target:self
950
+ action:@selector(pressEscKey:)] autorelease];
951
+ UIImage *win_icon =
952
+ [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"toolbar_icon_win"
953
+ ofType:@"png"]];
954
+ UIBarButtonItem *win_btn =
955
+ [[[UIBarButtonItem alloc] initWithImage:win_icon
956
+ style:UIBarButtonItemStyleBordered
957
+ target:self
958
+ action:@selector(toggleWinKey:)] autorelease];
959
+ UIBarButtonItem *ctrl_btn =
960
+ [[[UIBarButtonItem alloc] initWithTitle:@"Ctrl"
961
+ style:UIBarButtonItemStyleBordered
962
+ target:self
963
+ action:@selector(toggleCtrlKey:)] autorelease];
964
+ UIBarButtonItem *alt_btn =
965
+ [[[UIBarButtonItem alloc] initWithTitle:@"Alt"
966
+ style:UIBarButtonItemStyleBordered
967
+ target:self
968
+ action:@selector(toggleAltKey:)] autorelease];
969
+ UIBarButtonItem *ext_btn = [[[UIBarButtonItem alloc]
970
+ initWithTitle:@"Ext"
971
+ style:UIBarButtonItemStyleBordered
972
+ target:self
973
+ action:@selector(toggleKeyboardWhenOtherVisible:)] autorelease];
974
+ UIBarButtonItem *done_btn = [[[UIBarButtonItem alloc]
975
+ initWithBarButtonSystemItem:UIBarButtonSystemItemDone
976
+ target:self
977
+ action:@selector(toggleKeyboard:)] autorelease];
978
+ UIBarButtonItem *flex_spacer =
979
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
980
+ target:nil
981
+ action:nil] autorelease];
982
+
983
+ // iPad gets a shift button, iphone doesn't (there's just not enough space ...)
984
+ NSArray *items;
985
+ if (IsPad())
986
+ {
987
+ UIBarButtonItem *shift_btn =
988
+ [[[UIBarButtonItem alloc] initWithTitle:@"Shift"
989
+ style:UIBarButtonItemStyleBordered
990
+ target:self
991
+ action:@selector(toggleShiftKey:)] autorelease];
992
+ items = [NSArray arrayWithObjects:esc_btn, flex_spacer, shift_btn, flex_spacer, ctrl_btn,
993
+ flex_spacer, win_btn, flex_spacer, alt_btn, flex_spacer,
994
+ ext_btn, flex_spacer, done_btn, nil];
995
+ }
996
+ else
997
+ {
998
+ items = [NSArray arrayWithObjects:esc_btn, flex_spacer, ctrl_btn, flex_spacer, win_btn,
999
+ flex_spacer, alt_btn, flex_spacer, ext_btn, flex_spacer,
1000
+ done_btn, nil];
1001
+ }
1002
+
1003
+ [keyboard_toolbar setItems:items];
1004
+ [keyboard_toolbar sizeToFit];
1005
+ return keyboard_toolbar;
1006
+ }
1007
+
1008
+ - (void)initGestureRecognizers
1009
+ {
1010
+ // single and double tap recognizer
1011
+ UITapGestureRecognizer *doubleTapRecognizer =
1012
+ [[[UITapGestureRecognizer alloc] initWithTarget:self
1013
+ action:@selector(handleDoubleTap:)] autorelease];
1014
+ [doubleTapRecognizer setNumberOfTouchesRequired:1];
1015
+ [doubleTapRecognizer setNumberOfTapsRequired:2];
1016
+
1017
+ UITapGestureRecognizer *singleTapRecognizer =
1018
+ [[[UITapGestureRecognizer alloc] initWithTarget:self
1019
+ action:@selector(handleSingleTap:)] autorelease];
1020
+ [singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
1021
+ [singleTapRecognizer setNumberOfTouchesRequired:1];
1022
+ [singleTapRecognizer setNumberOfTapsRequired:1];
1023
+
1024
+ // 2 fingers - tap recognizer
1025
+ UITapGestureRecognizer *single2FingersTapRecognizer = [[[UITapGestureRecognizer alloc]
1026
+ initWithTarget:self
1027
+ action:@selector(handleSingle2FingersTap:)] autorelease];
1028
+ [single2FingersTapRecognizer setNumberOfTouchesRequired:2];
1029
+ [single2FingersTapRecognizer setNumberOfTapsRequired:1];
1030
+
1031
+ // long press gesture recognizer
1032
+ UILongPressGestureRecognizer *longPressRecognizer = [[[UILongPressGestureRecognizer alloc]
1033
+ initWithTarget:self
1034
+ action:@selector(handleLongPress:)] autorelease];
1035
+ [longPressRecognizer setMinimumPressDuration:0.5];
1036
+
1037
+ // double long press gesture recognizer
1038
+ UILongPressGestureRecognizer *doubleLongPressRecognizer = [[[UILongPressGestureRecognizer alloc]
1039
+ initWithTarget:self
1040
+ action:@selector(handleDoubleLongPress:)] autorelease];
1041
+ [doubleLongPressRecognizer setNumberOfTouchesRequired:2];
1042
+ [doubleLongPressRecognizer setMinimumPressDuration:0.5];
1043
+
1044
+ // 3 finger, single tap gesture for showing/hiding the toolbar
1045
+ UITapGestureRecognizer *single3FingersTapRecognizer = [[[UITapGestureRecognizer alloc]
1046
+ initWithTarget:self
1047
+ action:@selector(handleSingle3FingersTap:)] autorelease];
1048
+ [single3FingersTapRecognizer setNumberOfTapsRequired:1];
1049
+ [single3FingersTapRecognizer setNumberOfTouchesRequired:3];
1050
+
1051
+ // add gestures to scroll view
1052
+ [_session_scrollview addGestureRecognizer:singleTapRecognizer];
1053
+ [_session_scrollview addGestureRecognizer:doubleTapRecognizer];
1054
+ [_session_scrollview addGestureRecognizer:single2FingersTapRecognizer];
1055
+ [_session_scrollview addGestureRecognizer:longPressRecognizer];
1056
+ [_session_scrollview addGestureRecognizer:doubleLongPressRecognizer];
1057
+ [_session_scrollview addGestureRecognizer:single3FingersTapRecognizer];
1058
+ }
1059
+
1060
+ - (void)suspendSession
1061
+ {
1062
+ // suspend session and pop navigation controller
1063
+ [_session suspend];
1064
+
1065
+ // pop current view controller
1066
+ [[self navigationController] popViewControllerAnimated:YES];
1067
+ }
1068
+
1069
+ - (NSDictionary *)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position
1070
+ {
1071
+ return [NSDictionary
1072
+ dictionaryWithObjectsAndKeys:@"mouse", @"type", [NSNumber numberWithUnsignedShort:event],
1073
+ @"flags",
1074
+ [NSNumber numberWithUnsignedShort:lrintf(position.x)],
1075
+ @"coord_x",
1076
+ [NSNumber numberWithUnsignedShort:lrintf(position.y)],
1077
+ @"coord_y", nil];
1078
+ }
1079
+
1080
+ - (void)sendDelayedMouseEventWithTimer:(NSTimer *)timer
1081
+ {
1082
+ _mouse_move_event_timer = nil;
1083
+ NSDictionary *event = [timer userInfo];
1084
+ [_session sendInputEvent:event];
1085
+ [timer autorelease];
1086
+ }
1087
+
1088
+ - (void)handleMouseMoveForPosition:(CGPoint)position
1089
+ {
1090
+ NSDictionary *event = [self eventDescriptorForMouseEvent:PTR_FLAGS_MOVE position:position];
1091
+
1092
+ // cancel pending mouse move events
1093
+ [_mouse_move_event_timer invalidate];
1094
+ _mouse_move_events_skipped++;
1095
+
1096
+ if (_mouse_move_events_skipped >= 5)
1097
+ {
1098
+ [_session sendInputEvent:event];
1099
+ _mouse_move_events_skipped = 0;
1100
+ }
1101
+ else
1102
+ {
1103
+ [_mouse_move_event_timer autorelease];
1104
+ _mouse_move_event_timer =
1105
+ [[NSTimer scheduledTimerWithTimeInterval:0.05
1106
+ target:self
1107
+ selector:@selector(sendDelayedMouseEventWithTimer:)
1108
+ userInfo:event
1109
+ repeats:NO] retain];
1110
+ }
1111
+ }
1112
+
1113
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/ScreenSelectionController.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ controller for screen settings selection
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "EditorBaseController.h"
12
+
13
+ @class ConnectionParams;
14
+ @class OrderedDictionary;
15
+
16
+ @interface ScreenSelectionController : EditorBaseController
17
+ {
18
+ @private
19
+ NSString *_keyPath;
20
+ ConnectionParams *_params;
21
+
22
+ // available options
23
+ OrderedDictionary *_color_options;
24
+ NSArray *_resolution_modes;
25
+
26
+ // current selections
27
+ int _selection_color;
28
+ int _selection_resolution;
29
+ }
30
+
31
+ - (id)initWithConnectionParams:(ConnectionParams *)params;
32
+ - (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
33
+
34
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/ScreenSelectionController.m ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ controller for screen settings selection
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "ScreenSelectionController.h"
12
+ #import "Utils.h"
13
+ #import "OrderedDictionary.h"
14
+ #import "ConnectionParams.h"
15
+
16
+ @interface ScreenSelectionController (Private)
17
+ - (NSString *)keyPathForKey:(NSString *)key;
18
+ @end
19
+
20
+ @implementation ScreenSelectionController
21
+
22
+ - (id)initWithConnectionParams:(ConnectionParams *)params
23
+ {
24
+ return [self initWithConnectionParams:params keyPath:nil];
25
+ }
26
+
27
+ - (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath
28
+ {
29
+ self = [super initWithStyle:UITableViewStyleGrouped];
30
+ if (self)
31
+ {
32
+ _params = [params retain];
33
+ _keyPath = (keyPath != nil ? [keyPath retain] : nil);
34
+
35
+ _color_options = (OrderedDictionary *)[SelectionForColorSetting() retain];
36
+ _resolution_modes = [ResolutionModes() retain];
37
+
38
+ // init current selections
39
+ NSUInteger idx = [_color_options
40
+ indexForValue:[NSNumber
41
+ numberWithInt:[_params
42
+ intForKeyPath:[self keyPathForKey:@"colors"]]]];
43
+ _selection_color = (idx != NSNotFound) ? idx : 0;
44
+
45
+ idx = [_resolution_modes
46
+ indexOfObject:ScreenResolutionDescription(
47
+ [_params
48
+ intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]],
49
+ [_params intForKeyPath:[self keyPathForKey:@"width"]],
50
+ [_params intForKeyPath:[self keyPathForKey:@"height"]])];
51
+ _selection_resolution = (idx != NSNotFound) ? idx : 0;
52
+ }
53
+ return self;
54
+ }
55
+
56
+ - (void)dealloc
57
+ {
58
+ [super dealloc];
59
+ [_params autorelease];
60
+ [_keyPath autorelease];
61
+ [_color_options autorelease];
62
+ [_resolution_modes autorelease];
63
+ }
64
+
65
+ - (NSString *)keyPathForKey:(NSString *)key
66
+ {
67
+ if (_keyPath)
68
+ return [_keyPath stringByAppendingFormat:@".%@", key];
69
+ return key;
70
+ }
71
+
72
+ #pragma mark - View lifecycle
73
+
74
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
75
+ {
76
+ // Return YES for supported orientations
77
+ return YES;
78
+ }
79
+
80
+ #pragma mark - Table view data source
81
+
82
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
83
+ {
84
+ return 2;
85
+ }
86
+
87
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
88
+ {
89
+ // Return the number of rows in the section.
90
+ if (section == 0)
91
+ return [_color_options count];
92
+ return [_resolution_modes count] + 2; // +2 for custom width/height input fields
93
+ }
94
+
95
+ - (UITableViewCell *)tableView:(UITableView *)tableView
96
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
97
+ {
98
+ UITableViewCell *cell = nil;
99
+ switch ([indexPath section])
100
+ {
101
+ case 0:
102
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
103
+ [[cell textLabel] setText:[_color_options keyAtIndex:[indexPath row]]];
104
+ break;
105
+
106
+ case 1:
107
+ if ([indexPath row] < [_resolution_modes count])
108
+ {
109
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
110
+ [[cell textLabel] setText:[_resolution_modes objectAtIndex:[indexPath row]]];
111
+ }
112
+ else
113
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierText];
114
+ break;
115
+
116
+ default:
117
+ break;
118
+ }
119
+
120
+ if ([indexPath section] == 1)
121
+ {
122
+ BOOL enabled = ([_params intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]] ==
123
+ TSXScreenOptionCustom);
124
+ if ([indexPath row] == [_resolution_modes count])
125
+ {
126
+ int value = [_params intForKeyPath:[self keyPathForKey:@"width"]];
127
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
128
+ [[textCell label] setText:NSLocalizedString(@"Width", @"Custom Screen Width")];
129
+ [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 800]];
130
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
131
+ [[textCell label] setEnabled:enabled];
132
+ [[textCell textfield] setEnabled:enabled];
133
+ [[textCell textfield] setTag:1];
134
+ }
135
+ else if ([indexPath row] == ([_resolution_modes count] + 1))
136
+ {
137
+ int value = [_params intForKeyPath:[self keyPathForKey:@"height"]];
138
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
139
+ [[textCell label] setText:NSLocalizedString(@"Height", @"Custom Screen Height")];
140
+ [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 600]];
141
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
142
+ [[textCell label] setEnabled:enabled];
143
+ [[textCell textfield] setEnabled:enabled];
144
+ [[textCell textfield] setTag:2];
145
+ }
146
+ }
147
+
148
+ // set default checkmark
149
+ if ([indexPath row] == ([indexPath section] == 0 ? _selection_color : _selection_resolution))
150
+ [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
151
+ else
152
+ [cell setAccessoryType:UITableViewCellAccessoryNone];
153
+
154
+ return cell;
155
+ }
156
+
157
+ #pragma mark - Table view delegate
158
+
159
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
160
+ {
161
+ // custom width/height cells are not selectable
162
+ if ([indexPath section] == 1 && [indexPath row] >= [_resolution_modes count])
163
+ return;
164
+
165
+ // has selection change?
166
+ int cur_selection = ([indexPath section] == 0 ? _selection_color : _selection_resolution);
167
+ if ([indexPath row] != cur_selection)
168
+ {
169
+ [tableView deselectRowAtIndexPath:indexPath animated:NO];
170
+
171
+ NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:cur_selection
172
+ inSection:[indexPath section]];
173
+
174
+ // clear old checkmark
175
+ UITableViewCell *old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
176
+ old_sel_cell.accessoryType = UITableViewCellAccessoryNone;
177
+
178
+ // set new checkmark
179
+ UITableViewCell *new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
180
+ new_sel_cell.accessoryType = UITableViewCellAccessoryCheckmark;
181
+
182
+ if ([indexPath section] == 0)
183
+ {
184
+ // get value from color dictionary
185
+ int sel_value =
186
+ [[_color_options valueForKey:[_color_options keyAtIndex:[indexPath row]]] intValue];
187
+
188
+ // update selection index and params value
189
+ [_params setInt:sel_value forKeyPath:[self keyPathForKey:@"colors"]];
190
+ _selection_color = [indexPath row];
191
+ }
192
+ else
193
+ {
194
+ // update selection index and params value
195
+ int width, height;
196
+ TSXScreenOptions mode;
197
+ ScanScreenResolution([_resolution_modes objectAtIndex:[indexPath row]], &width, &height,
198
+ &mode);
199
+ [_params setInt:mode forKeyPath:[self keyPathForKey:@"screen_resolution_type"]];
200
+ if (mode != TSXScreenOptionCustom)
201
+ {
202
+ [_params setInt:width forKeyPath:[self keyPathForKey:@"width"]];
203
+ [_params setInt:height forKeyPath:[self keyPathForKey:@"height"]];
204
+ }
205
+ _selection_resolution = [indexPath row];
206
+
207
+ // refresh width/height edit fields if custom selection changed
208
+ NSArray *indexPaths = [NSArray
209
+ arrayWithObjects:[NSIndexPath indexPathForRow:[_resolution_modes count]
210
+ inSection:1],
211
+ [NSIndexPath indexPathForRow:([_resolution_modes count] + 1)
212
+ inSection:1],
213
+ nil];
214
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
215
+ withRowAnimation:UITableViewRowAnimationNone];
216
+ }
217
+ }
218
+ }
219
+
220
+ #pragma mark -
221
+ #pragma mark Text Field delegate
222
+
223
+ - (BOOL)textFieldShouldReturn:(UITextField *)textField
224
+ {
225
+ [textField resignFirstResponder];
226
+ return NO;
227
+ }
228
+
229
+ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
230
+ {
231
+
232
+ switch ([textField tag])
233
+ {
234
+ // update resolution settings (and check for invalid input)
235
+ case 1:
236
+ if ([[textField text] intValue] < 640)
237
+ [textField setText:@"640"];
238
+ [_params setInt:[[textField text] intValue] forKeyPath:[self keyPathForKey:@"width"]];
239
+ break;
240
+
241
+ case 2:
242
+ if ([[textField text] intValue] < 480)
243
+ [textField setText:@"480"];
244
+ [_params setInt:[[textField text] intValue] forKeyPath:[self keyPathForKey:@"height"]];
245
+ break;
246
+
247
+ default:
248
+ break;
249
+ }
250
+ return YES;
251
+ }
252
+
253
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/VerifyCertificateController.h ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Certificate verification controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+
13
+ @class RDPSession;
14
+
15
+ @interface VerifyCertificateController : UIViewController
16
+ {
17
+ @private
18
+ IBOutlet UILabel *_label_issuer;
19
+ IBOutlet UIButton *_btn_accept;
20
+ IBOutlet UIButton *_btn_decline;
21
+ IBOutlet UILabel *_label_message;
22
+ IBOutlet UILabel *_label_for_issuer;
23
+
24
+ RDPSession *_session;
25
+ NSMutableDictionary *_params;
26
+ }
27
+
28
+ - (id)initWithNibName:(NSString *)nibNameOrNil
29
+ bundle:(NSBundle *)nibBundleOrNil
30
+ session:(RDPSession *)session
31
+ params:(NSMutableDictionary *)params;
32
+
33
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Controllers/VerifyCertificateController.m ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Certificate verification controller
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "VerifyCertificateController.h"
12
+ #import "RDPSession.h"
13
+
14
+ @implementation VerifyCertificateController
15
+
16
+ - (id)initWithNibName:(NSString *)nibNameOrNil
17
+ bundle:(NSBundle *)nibBundleOrNil
18
+ session:(RDPSession *)session
19
+ params:(NSMutableDictionary *)params
20
+ {
21
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
22
+ if (self)
23
+ {
24
+ _session = session;
25
+ _params = params;
26
+ [self setModalPresentationStyle:UIModalPresentationFormSheet];
27
+ }
28
+ return self;
29
+ }
30
+
31
+ - (void)viewDidLoad
32
+ {
33
+ [super viewDidLoad];
34
+
35
+ NSString *message = NSLocalizedString(
36
+ @"The identity of the remote computer cannot be verified. Do you want to connect anyway?",
37
+ @"Verify certificate view message");
38
+
39
+ // init strings
40
+ [_label_message setText:message];
41
+ [_label_for_issuer
42
+ setText:NSLocalizedString(@"Issuer:", @"Verify certificate view issuer label")];
43
+ [_btn_accept setTitle:NSLocalizedString(@"Yes", @"Yes Button") forState:UIControlStateNormal];
44
+ [_btn_decline setTitle:NSLocalizedString(@"No", @"No Button") forState:UIControlStateNormal];
45
+
46
+ [_label_issuer setText:[_params valueForKey:@"issuer"]];
47
+ }
48
+
49
+ - (void)viewDidUnload
50
+ {
51
+ [super viewDidUnload];
52
+ // Release any retained subviews of the main view.
53
+ }
54
+
55
+ - (void)viewDidDisappear:(BOOL)animated
56
+ {
57
+ [super viewDidDisappear:animated];
58
+
59
+ // set signal
60
+ [[_session uiRequestCompleted] signal];
61
+ }
62
+
63
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
64
+ {
65
+ return YES;
66
+ }
67
+
68
+ #pragma mark - Action handlers
69
+
70
+ - (IBAction)acceptPressed:(id)sender
71
+ {
72
+ [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
73
+
74
+ // dismiss controller
75
+ [self dismissModalViewControllerAnimated:YES];
76
+ }
77
+
78
+ - (IBAction)declinePressed:(id)sender
79
+ {
80
+ [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
81
+
82
+ // dismiss controller
83
+ [self dismissModalViewControllerAnimated:YES];
84
+ }
85
+
86
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_cliprdr.m ADDED
@@ -0,0 +1,499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FreeRDP: A Remote Desktop Protocol Implementation
3
+ * Android Clipboard Redirection
4
+ *
5
+ * Copyright 2013 Felix Long
6
+ * Copyright 2015 Thincast Technologies GmbH
7
+ * Copyright 2015 DI (FH) Martin Haimberger <[email protected]>
8
+ * Copyright 2023 Iordan Iordanov
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
+ #include <freerdp/config.h>
24
+
25
+ #include <winpr/crt.h>
26
+ #include <winpr/stream.h>
27
+ #include <winpr/clipboard.h>
28
+
29
+ #include <freerdp/client/channels.h>
30
+ #include <freerdp/client/cliprdr.h>
31
+
32
+ #include "ios_cliprdr.h"
33
+
34
+ UINT ios_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr)
35
+ {
36
+ UINT rc = ERROR_INTERNAL_ERROR;
37
+ UINT32 formatId;
38
+ UINT32 numFormats;
39
+ UINT32 *pFormatIds;
40
+ const char *formatName;
41
+ CLIPRDR_FORMAT *formats;
42
+ CLIPRDR_FORMAT_LIST formatList = { 0 };
43
+
44
+ if (!cliprdr)
45
+ return ERROR_INVALID_PARAMETER;
46
+
47
+ mfContext *afc = (mfContext *)cliprdr->custom;
48
+
49
+ if (!afc || !afc->cliprdr)
50
+ return ERROR_INVALID_PARAMETER;
51
+
52
+ pFormatIds = NULL;
53
+ numFormats = ClipboardGetFormatIds(afc->clipboard, &pFormatIds);
54
+ formats = (CLIPRDR_FORMAT *)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
55
+
56
+ if (!formats)
57
+ goto fail;
58
+
59
+ for (UINT32 index = 0; index < numFormats; index++)
60
+ {
61
+ formatId = pFormatIds[index];
62
+ formatName = ClipboardGetFormatName(afc->clipboard, formatId);
63
+ formats[index].formatId = formatId;
64
+ formats[index].formatName = NULL;
65
+
66
+ if ((formatId > CF_MAX) && formatName)
67
+ {
68
+ formats[index].formatName = _strdup(formatName);
69
+
70
+ if (!formats[index].formatName)
71
+ goto fail;
72
+ }
73
+ }
74
+
75
+ formatList.common.msgFlags = 0;
76
+ formatList.numFormats = numFormats;
77
+ formatList.formats = formats;
78
+ formatList.common.msgType = CB_FORMAT_LIST;
79
+
80
+ if (!afc->cliprdr->ClientFormatList)
81
+ goto fail;
82
+
83
+ rc = afc->cliprdr->ClientFormatList(afc->cliprdr, &formatList);
84
+ fail:
85
+ free(pFormatIds);
86
+ free(formats);
87
+ return rc;
88
+ }
89
+
90
+ static UINT ios_cliprdr_send_client_format_data_request(CliprdrClientContext *cliprdr,
91
+ UINT32 formatId)
92
+ {
93
+ UINT rc = ERROR_INVALID_PARAMETER;
94
+ CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest = { 0 };
95
+ mfContext *afc;
96
+
97
+ if (!cliprdr)
98
+ goto fail;
99
+
100
+ afc = (mfContext *)cliprdr->custom;
101
+
102
+ if (!afc || !afc->clipboardRequestEvent || !cliprdr->ClientFormatDataRequest)
103
+ goto fail;
104
+
105
+ formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
106
+ formatDataRequest.common.msgFlags = 0;
107
+ formatDataRequest.requestedFormatId = formatId;
108
+ afc->requestedFormatId = formatId;
109
+ (void)ResetEvent(afc->clipboardRequestEvent);
110
+ rc = cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest);
111
+ fail:
112
+ return rc;
113
+ }
114
+
115
+ static UINT ios_cliprdr_send_client_capabilities(CliprdrClientContext *cliprdr)
116
+ {
117
+ CLIPRDR_CAPABILITIES capabilities;
118
+ CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
119
+
120
+ if (!cliprdr || !cliprdr->ClientCapabilities)
121
+ return ERROR_INVALID_PARAMETER;
122
+
123
+ capabilities.cCapabilitiesSets = 1;
124
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
125
+ generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
126
+ generalCapabilitySet.capabilitySetLength = 12;
127
+ generalCapabilitySet.version = CB_CAPS_VERSION_2;
128
+ generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
129
+ return cliprdr->ClientCapabilities(cliprdr, &capabilities);
130
+ }
131
+
132
+ /**
133
+ * Function description
134
+ *
135
+ * @return 0 on success, otherwise a Win32 error code
136
+ */
137
+ static UINT ios_cliprdr_monitor_ready(CliprdrClientContext *cliprdr,
138
+ const CLIPRDR_MONITOR_READY *monitorReady)
139
+ {
140
+ UINT rc;
141
+ mfContext *afc;
142
+
143
+ if (!cliprdr || !monitorReady)
144
+ return ERROR_INVALID_PARAMETER;
145
+
146
+ afc = (mfContext *)cliprdr->custom;
147
+
148
+ if (!afc)
149
+ return ERROR_INVALID_PARAMETER;
150
+
151
+ if ((rc = ios_cliprdr_send_client_capabilities(cliprdr)) != CHANNEL_RC_OK)
152
+ return rc;
153
+
154
+ if ((rc = ios_cliprdr_send_client_format_list(cliprdr)) != CHANNEL_RC_OK)
155
+ return rc;
156
+
157
+ afc->clipboardSync = TRUE;
158
+ return CHANNEL_RC_OK;
159
+ }
160
+
161
+ /**
162
+ * Function description
163
+ *
164
+ * @return 0 on success, otherwise a Win32 error code
165
+ */
166
+ static UINT ios_cliprdr_server_capabilities(CliprdrClientContext *cliprdr,
167
+ const CLIPRDR_CAPABILITIES *capabilities)
168
+ {
169
+ CLIPRDR_CAPABILITY_SET *capabilitySet;
170
+ mfContext *afc;
171
+
172
+ if (!cliprdr || !capabilities)
173
+ return ERROR_INVALID_PARAMETER;
174
+
175
+ afc = (mfContext *)cliprdr->custom;
176
+
177
+ if (!afc)
178
+ return ERROR_INVALID_PARAMETER;
179
+
180
+ for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++)
181
+ {
182
+ capabilitySet = &(capabilities->capabilitySets[index]);
183
+
184
+ if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) &&
185
+ (capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN))
186
+ {
187
+ CLIPRDR_GENERAL_CAPABILITY_SET *generalCapabilitySet =
188
+ (CLIPRDR_GENERAL_CAPABILITY_SET *)capabilitySet;
189
+ afc->clipboardCapabilities = generalCapabilitySet->generalFlags;
190
+ break;
191
+ }
192
+ }
193
+
194
+ return CHANNEL_RC_OK;
195
+ }
196
+
197
+ /**
198
+ * Function description
199
+ *
200
+ * @return 0 on success, otherwise a Win32 error code
201
+ */
202
+ static UINT ios_cliprdr_server_format_list(CliprdrClientContext *cliprdr,
203
+ const CLIPRDR_FORMAT_LIST *formatList)
204
+ {
205
+ UINT rc;
206
+ CLIPRDR_FORMAT *format;
207
+ mfContext *afc;
208
+
209
+ if (!cliprdr || !formatList)
210
+ return ERROR_INVALID_PARAMETER;
211
+
212
+ afc = (mfContext *)cliprdr->custom;
213
+
214
+ if (!afc)
215
+ return ERROR_INVALID_PARAMETER;
216
+
217
+ if (afc->serverFormats)
218
+ {
219
+ for (UINT32 index = 0; index < afc->numServerFormats; index++)
220
+ free(afc->serverFormats[index].formatName);
221
+
222
+ free(afc->serverFormats);
223
+ afc->serverFormats = NULL;
224
+ afc->numServerFormats = 0;
225
+ }
226
+
227
+ if (formatList->numFormats < 1)
228
+ return CHANNEL_RC_OK;
229
+
230
+ afc->numServerFormats = formatList->numFormats;
231
+ afc->serverFormats = (CLIPRDR_FORMAT *)calloc(afc->numServerFormats, sizeof(CLIPRDR_FORMAT));
232
+
233
+ if (!afc->serverFormats)
234
+ return CHANNEL_RC_NO_MEMORY;
235
+
236
+ for (UINT32 index = 0; index < afc->numServerFormats; index++)
237
+ {
238
+ afc->serverFormats[index].formatId = formatList->formats[index].formatId;
239
+ afc->serverFormats[index].formatName = NULL;
240
+
241
+ if (formatList->formats[index].formatName)
242
+ {
243
+ afc->serverFormats[index].formatName = _strdup(formatList->formats[index].formatName);
244
+
245
+ if (!afc->serverFormats[index].formatName)
246
+ return CHANNEL_RC_NO_MEMORY;
247
+ }
248
+ }
249
+
250
+ BOOL unicode = FALSE;
251
+ BOOL text = FALSE;
252
+ for (UINT32 index = 0; index < afc->numServerFormats; index++)
253
+ {
254
+ format = &(afc->serverFormats[index]);
255
+
256
+ if (format->formatId == CF_UNICODETEXT)
257
+ unicode = TRUE;
258
+
259
+ else if (format->formatId == CF_TEXT)
260
+ text = TRUE;
261
+ }
262
+
263
+ if (unicode)
264
+ return ios_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT);
265
+ if (text)
266
+ return ios_cliprdr_send_client_format_data_request(cliprdr, CF_TEXT);
267
+ return CHANNEL_RC_OK;
268
+ }
269
+
270
+ /**
271
+ * Function description
272
+ *
273
+ * @return 0 on success, otherwise a Win32 error code
274
+ */
275
+ static UINT
276
+ ios_cliprdr_server_format_list_response(CliprdrClientContext *cliprdr,
277
+ const CLIPRDR_FORMAT_LIST_RESPONSE *formatListResponse)
278
+ {
279
+ if (!cliprdr || !formatListResponse)
280
+ return ERROR_INVALID_PARAMETER;
281
+
282
+ return CHANNEL_RC_OK;
283
+ }
284
+
285
+ /**
286
+ * Function description
287
+ *
288
+ * @return 0 on success, otherwise a Win32 error code
289
+ */
290
+ static UINT
291
+ ios_cliprdr_server_lock_clipboard_data(CliprdrClientContext *cliprdr,
292
+ const CLIPRDR_LOCK_CLIPBOARD_DATA *lockClipboardData)
293
+ {
294
+ if (!cliprdr || !lockClipboardData)
295
+ return ERROR_INVALID_PARAMETER;
296
+
297
+ return CHANNEL_RC_OK;
298
+ }
299
+
300
+ /**
301
+ * Function description
302
+ *
303
+ * @return 0 on success, otherwise a Win32 error code
304
+ */
305
+ static UINT
306
+ ios_cliprdr_server_unlock_clipboard_data(CliprdrClientContext *cliprdr,
307
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA *unlockClipboardData)
308
+ {
309
+ if (!cliprdr || !unlockClipboardData)
310
+ return ERROR_INVALID_PARAMETER;
311
+
312
+ return CHANNEL_RC_OK;
313
+ }
314
+
315
+ /**
316
+ * Function description
317
+ *
318
+ * @return 0 on success, otherwise a Win32 error code
319
+ */
320
+ static UINT
321
+ ios_cliprdr_server_format_data_request(CliprdrClientContext *cliprdr,
322
+ const CLIPRDR_FORMAT_DATA_REQUEST *formatDataRequest)
323
+ {
324
+ UINT rc;
325
+ BYTE *data;
326
+ UINT32 size;
327
+ UINT32 formatId;
328
+ CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
329
+ mfContext *afc;
330
+
331
+ if (!cliprdr || !formatDataRequest || !cliprdr->ClientFormatDataResponse)
332
+ return ERROR_INVALID_PARAMETER;
333
+
334
+ afc = (mfContext *)cliprdr->custom;
335
+
336
+ if (!afc)
337
+ return ERROR_INVALID_PARAMETER;
338
+
339
+ formatId = formatDataRequest->requestedFormatId;
340
+ data = (BYTE *)ClipboardGetData(afc->clipboard, formatId, &size);
341
+ response.common.msgFlags = CB_RESPONSE_OK;
342
+ response.common.dataLen = size;
343
+ response.requestedFormatData = data;
344
+
345
+ if (!data)
346
+ {
347
+ response.common.msgFlags = CB_RESPONSE_FAIL;
348
+ response.common.dataLen = 0;
349
+ response.requestedFormatData = NULL;
350
+ }
351
+
352
+ rc = cliprdr->ClientFormatDataResponse(cliprdr, &response);
353
+ free(data);
354
+ return rc;
355
+ }
356
+
357
+ /**
358
+ * Function description
359
+ *
360
+ * @return 0 on success, otherwise a Win32 error code
361
+ */
362
+ static UINT
363
+ ios_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr,
364
+ const CLIPRDR_FORMAT_DATA_RESPONSE *formatDataResponse)
365
+ {
366
+ BYTE *data;
367
+ UINT32 size;
368
+ UINT32 formatId;
369
+ CLIPRDR_FORMAT *format = NULL;
370
+ mfContext *afc;
371
+ freerdp *instance;
372
+
373
+ if (!cliprdr || !formatDataResponse)
374
+ return ERROR_INVALID_PARAMETER;
375
+
376
+ afc = (mfContext *)cliprdr->custom;
377
+
378
+ if (!afc)
379
+ return ERROR_INVALID_PARAMETER;
380
+
381
+ instance = ((rdpContext *)afc)->instance;
382
+
383
+ if (!instance)
384
+ return ERROR_INVALID_PARAMETER;
385
+
386
+ for (UINT32 index = 0; index < afc->numServerFormats; index++)
387
+ {
388
+ if (afc->requestedFormatId == afc->serverFormats[index].formatId)
389
+ format = &(afc->serverFormats[index]);
390
+ }
391
+
392
+ if (!format)
393
+ {
394
+ (void)SetEvent(afc->clipboardRequestEvent);
395
+ return ERROR_INTERNAL_ERROR;
396
+ }
397
+
398
+ if (format->formatName)
399
+ formatId = ClipboardRegisterFormat(afc->clipboard, format->formatName);
400
+ else
401
+ formatId = format->formatId;
402
+
403
+ size = formatDataResponse->common.dataLen;
404
+
405
+ ClipboardLock(afc->clipboard);
406
+ if (!ClipboardSetData(afc->clipboard, formatId, formatDataResponse->requestedFormatData, size))
407
+ return ERROR_INTERNAL_ERROR;
408
+
409
+ (void)SetEvent(afc->clipboardRequestEvent);
410
+
411
+ if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT))
412
+ {
413
+ formatId = ClipboardRegisterFormat(afc->clipboard, "UTF8_STRING");
414
+ data = (BYTE *)ClipboardGetData(afc->clipboard, formatId, &size);
415
+ size = (UINT32)strnlen(data, size);
416
+ if (afc->ServerCutText != NULL)
417
+ {
418
+ afc->ServerCutText((rdpContext *)afc, (uint8_t *)data, size);
419
+ }
420
+ }
421
+ ClipboardUnlock(afc->clipboard);
422
+
423
+ return CHANNEL_RC_OK;
424
+ }
425
+
426
+ /**
427
+ * Function description
428
+ *
429
+ * @return 0 on success, otherwise a Win32 error code
430
+ */
431
+ static UINT
432
+ ios_cliprdr_server_file_contents_request(CliprdrClientContext *cliprdr,
433
+ const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
434
+ {
435
+ if (!cliprdr || !fileContentsRequest)
436
+ return ERROR_INVALID_PARAMETER;
437
+
438
+ return CHANNEL_RC_OK;
439
+ }
440
+
441
+ /**
442
+ * Function description
443
+ *
444
+ * @return 0 on success, otherwise a Win32 error code
445
+ */
446
+ static UINT ios_cliprdr_server_file_contents_response(
447
+ CliprdrClientContext *cliprdr, const CLIPRDR_FILE_CONTENTS_RESPONSE *fileContentsResponse)
448
+ {
449
+ if (!cliprdr || !fileContentsResponse)
450
+ return ERROR_INVALID_PARAMETER;
451
+
452
+ return CHANNEL_RC_OK;
453
+ }
454
+
455
+ BOOL ios_cliprdr_init(mfContext *afc, CliprdrClientContext *cliprdr)
456
+ {
457
+ wClipboard *clipboard;
458
+ HANDLE hevent;
459
+
460
+ if (!afc || !cliprdr)
461
+ return FALSE;
462
+
463
+ if (!(hevent = CreateEvent(NULL, TRUE, FALSE, NULL)))
464
+ return FALSE;
465
+
466
+ if (!(clipboard = ClipboardCreate()))
467
+ {
468
+ (void)CloseHandle(hevent);
469
+ return FALSE;
470
+ }
471
+
472
+ afc->cliprdr = cliprdr;
473
+ afc->clipboard = clipboard;
474
+ afc->clipboardRequestEvent = hevent;
475
+ cliprdr->custom = (void *)afc;
476
+ cliprdr->MonitorReady = ios_cliprdr_monitor_ready;
477
+ cliprdr->ServerCapabilities = ios_cliprdr_server_capabilities;
478
+ cliprdr->ServerFormatList = ios_cliprdr_server_format_list;
479
+ cliprdr->ServerFormatListResponse = ios_cliprdr_server_format_list_response;
480
+ cliprdr->ServerLockClipboardData = ios_cliprdr_server_lock_clipboard_data;
481
+ cliprdr->ServerUnlockClipboardData = ios_cliprdr_server_unlock_clipboard_data;
482
+ cliprdr->ServerFormatDataRequest = ios_cliprdr_server_format_data_request;
483
+ cliprdr->ServerFormatDataResponse = ios_cliprdr_server_format_data_response;
484
+ cliprdr->ServerFileContentsRequest = ios_cliprdr_server_file_contents_request;
485
+ cliprdr->ServerFileContentsResponse = ios_cliprdr_server_file_contents_response;
486
+ return TRUE;
487
+ }
488
+
489
+ BOOL ios_cliprdr_uninit(mfContext *afc, CliprdrClientContext *cliprdr)
490
+ {
491
+ if (!afc || !cliprdr)
492
+ return FALSE;
493
+
494
+ cliprdr->custom = NULL;
495
+ afc->cliprdr = NULL;
496
+ ClipboardDestroy(afc->clipboard);
497
+ (void)CloseHandle(afc->clipboardRequestEvent);
498
+ return TRUE;
499
+ }
local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp.h ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP run-loop
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
5
+ Copyright 2023 Iordan Iordanov
6
+
7
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
8
+ If a copy of the MPL was not distributed with this file, You can obtain one at
9
+ http://mozilla.org/MPL/2.0/.
10
+ */
11
+
12
+ #import <CoreGraphics/CoreGraphics.h>
13
+
14
+ #import <freerdp/freerdp.h>
15
+ #import <freerdp/channels/channels.h>
16
+ #import "TSXTypes.h"
17
+ #import <winpr/clipboard.h>
18
+ #import <freerdp/client/cliprdr.h>
19
+
20
+ @class RDPSession, RDPSessionView;
21
+
22
+ typedef BOOL (*pServerCutText)(rdpContext *context, UINT8 *data, UINT32 size);
23
+
24
+ // FreeRDP extended structs
25
+ typedef struct mf_info mfInfo;
26
+
27
+ typedef struct mf_context
28
+ {
29
+ rdpContext _p;
30
+
31
+ mfInfo *mfi;
32
+ rdpSettings *settings;
33
+
34
+ BOOL clipboardSync;
35
+ wClipboard *clipboard;
36
+ UINT32 numServerFormats;
37
+ UINT32 requestedFormatId;
38
+ HANDLE clipboardRequestEvent;
39
+ CLIPRDR_FORMAT *serverFormats;
40
+ CliprdrClientContext *cliprdr;
41
+ UINT32 clipboardCapabilities;
42
+ pServerCutText ServerCutText;
43
+ } mfContext;
44
+
45
+ struct mf_info
46
+ {
47
+ // RDP
48
+ freerdp *instance;
49
+ mfContext *context;
50
+ rdpContext *_context;
51
+
52
+ // UI
53
+ RDPSession *session;
54
+
55
+ // Graphics
56
+ CGContextRef bitmap_context;
57
+
58
+ // Events
59
+ int event_pipe_producer;
60
+ int event_pipe_consumer;
61
+ HANDLE handle;
62
+
63
+ // Tracking connection state
64
+ volatile TSXConnectionState connection_state;
65
+ volatile BOOL
66
+ unwanted; // set when controlling Session no longer wants the connection to continue
67
+ };
68
+
69
+ #define MFI_FROM_INSTANCE(inst) (((mfContext *)((inst)->context))->mfi)
70
+
71
+ enum MF_EXIT_CODE
72
+ {
73
+ MF_EXIT_SUCCESS = 0,
74
+
75
+ MF_EXIT_CONN_FAILED = 128,
76
+ MF_EXIT_CONN_CANCELED = 129,
77
+ MF_EXIT_LOGON_TIMEOUT = 130,
78
+
79
+ MF_EXIT_UNKNOWN = 255
80
+ };
81
+
82
+ void ios_init_freerdp(void);
83
+ void ios_uninit_freerdp(void);
84
+ freerdp *ios_freerdp_new(void);
85
+ int ios_run_freerdp(freerdp *instance);
86
+ void ios_freerdp_free(freerdp *instance);
87
+ void ios_send_clipboard_data(void *context, const void *data, UINT32 size);
local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp_ui.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP ui callbacks
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "ios_freerdp.h"
12
+
13
+ BOOL ios_ui_begin_paint(rdpContext* context);
14
+ BOOL ios_ui_end_paint(rdpContext* context);
15
+ BOOL ios_ui_resize_window(rdpContext* context);
16
+
17
+ BOOL ios_ui_authenticate(freerdp* instance, char** username, char** password, char** domain);
18
+ BOOL ios_ui_gw_authenticate(freerdp* instance, char** username, char** password, char** domain);
19
+ DWORD ios_ui_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
20
+ const char* common_name, const char* subject, const char* issuer,
21
+ const char* fingerprint, DWORD flags);
22
+
23
+ DWORD ios_ui_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port,
24
+ const char* common_name, const char* subject,
25
+ const char* issuer, const char* fingerprint,
26
+ const char* old_subject, const char* old_issuer,
27
+ const char* old_fingerprint, DWORD flags);
28
+
29
+ void ios_allocate_display_buffer(mfInfo* mfi);
local-test-freerdp-full-01/afc-freerdp/client/iOS/FreeRDP/ios_freerdp_ui.m ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP ui callbacks
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+
13
+ #import <freerdp/gdi/gdi.h>
14
+ #import "ios_freerdp_ui.h"
15
+
16
+ #import "RDPSession.h"
17
+
18
+ #pragma mark -
19
+ #pragma mark Certificate authentication
20
+
21
+ static void ios_resize_display_buffer(mfInfo *mfi);
22
+ static BOOL ios_ui_authenticate_raw(freerdp *instance, char **username, char **password,
23
+ char **domain, const char *title)
24
+ {
25
+ mfInfo *mfi = MFI_FROM_INSTANCE(instance);
26
+ NSMutableDictionary *params = [NSMutableDictionary
27
+ dictionaryWithObjectsAndKeys:(*username) ? [NSString stringWithUTF8String:*username] : @"",
28
+ @"username",
29
+ (*password) ? [NSString stringWithUTF8String:*password] : @"",
30
+ @"password",
31
+ (*domain) ? [NSString stringWithUTF8String:*domain] : @"",
32
+ @"domain",
33
+ [NSString stringWithUTF8String:freerdp_settings_get_string(
34
+ instance->context->settings,
35
+ FreeRDP_ServerHostname)],
36
+ @"hostname", // used for the auth prompt message; not changed
37
+ nil];
38
+ // request auth UI
39
+ [mfi->session performSelectorOnMainThread:@selector(sessionRequestsAuthenticationWithParams:)
40
+ withObject:params
41
+ waitUntilDone:YES];
42
+ // wait for UI request to be completed
43
+ [[mfi->session uiRequestCompleted] lock];
44
+ [[mfi->session uiRequestCompleted] wait];
45
+ [[mfi->session uiRequestCompleted] unlock];
46
+
47
+ if (![[params valueForKey:@"result"] boolValue])
48
+ {
49
+ mfi->unwanted = YES;
50
+ return FALSE;
51
+ }
52
+
53
+ // Free old values
54
+ free(*username);
55
+ free(*password);
56
+ free(*domain);
57
+ // set values back
58
+ *username = _strdup([[params objectForKey:@"username"] UTF8String]);
59
+ *password = _strdup([[params objectForKey:@"password"] UTF8String]);
60
+ *domain = _strdup([[params objectForKey:@"domain"] UTF8String]);
61
+
62
+ if (!(*username) || !(*password) || !(*domain))
63
+ {
64
+ free(*username);
65
+ free(*password);
66
+ free(*domain);
67
+ return FALSE;
68
+ }
69
+
70
+ return TRUE;
71
+ }
72
+
73
+ BOOL ios_ui_authenticate(freerdp *instance, char **username, char **password, char **domain)
74
+ {
75
+ return ios_ui_authenticate_raw(instance, username, password, domain, "");
76
+ }
77
+
78
+ BOOL ios_ui_gw_authenticate(freerdp *instance, char **username, char **password, char **domain)
79
+ {
80
+ return ios_ui_authenticate_raw(instance, username, password, domain, "gateway");
81
+ }
82
+
83
+ DWORD ios_ui_verify_certificate_ex(freerdp *instance, const char *host, UINT16 port,
84
+ const char *common_name, const char *subject, const char *issuer,
85
+ const char *fingerprint, DWORD flags)
86
+ {
87
+ // check whether we accept all certificates
88
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"security.accept_certificates"] == YES)
89
+ return 2;
90
+
91
+ mfInfo *mfi = MFI_FROM_INSTANCE(instance);
92
+ NSMutableDictionary *params = [NSMutableDictionary
93
+ dictionaryWithObjectsAndKeys:(subject) ? [NSString stringWithUTF8String:subject] : @"",
94
+ @"subject",
95
+ (issuer) ? [NSString stringWithUTF8String:issuer] : @"",
96
+ @"issuer",
97
+ (fingerprint) ? [NSString stringWithUTF8String:subject] : @"",
98
+ @"fingerprint", nil];
99
+ // request certificate verification UI
100
+ [mfi->session performSelectorOnMainThread:@selector(sessionVerifyCertificateWithParams:)
101
+ withObject:params
102
+ waitUntilDone:YES];
103
+ // wait for UI request to be completed
104
+ [[mfi->session uiRequestCompleted] lock];
105
+ [[mfi->session uiRequestCompleted] wait];
106
+ [[mfi->session uiRequestCompleted] unlock];
107
+
108
+ if (![[params valueForKey:@"result"] boolValue])
109
+ {
110
+ mfi->unwanted = YES;
111
+ return 0;
112
+ }
113
+
114
+ return 1;
115
+ }
116
+
117
+ DWORD ios_ui_verify_changed_certificate_ex(freerdp *instance, const char *host, UINT16 port,
118
+ const char *common_name, const char *subject,
119
+ const char *issuer, const char *fingerprint,
120
+ const char *old_subject, const char *old_issuer,
121
+ const char *old_fingerprint, DWORD flags)
122
+ {
123
+ return ios_ui_verify_certificate_ex(instance, host, port, common_name, subject, issuer,
124
+ fingerprint, flags);
125
+ }
126
+
127
+ #pragma mark -
128
+ #pragma mark Graphics updates
129
+
130
+ BOOL ios_ui_begin_paint(rdpContext *context)
131
+ {
132
+ rdpGdi *gdi = context->gdi;
133
+ gdi->primary->hdc->hwnd->invalid->null = TRUE;
134
+ return TRUE;
135
+ }
136
+
137
+ BOOL ios_ui_end_paint(rdpContext *context)
138
+ {
139
+ mfInfo *mfi = MFI_FROM_INSTANCE(context->instance);
140
+ rdpGdi *gdi = context->gdi;
141
+ CGRect dirty_rect =
142
+ CGRectMake(gdi->primary->hdc->hwnd->invalid->x, gdi->primary->hdc->hwnd->invalid->y,
143
+ gdi->primary->hdc->hwnd->invalid->w, gdi->primary->hdc->hwnd->invalid->h);
144
+
145
+ if (!gdi->primary->hdc->hwnd->invalid->null)
146
+ [mfi->session performSelectorOnMainThread:@selector(setNeedsDisplayInRectAsValue:)
147
+ withObject:[NSValue valueWithCGRect:dirty_rect]
148
+ waitUntilDone:NO];
149
+
150
+ return TRUE;
151
+ }
152
+
153
+ BOOL ios_ui_resize_window(rdpContext *context)
154
+ {
155
+ rdpSettings *settings;
156
+ rdpGdi *gdi;
157
+
158
+ if (!context || !context->settings)
159
+ return FALSE;
160
+
161
+ settings = context->settings;
162
+ gdi = context->gdi;
163
+
164
+ if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
165
+ freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
166
+ return FALSE;
167
+
168
+ ios_resize_display_buffer(MFI_FROM_INSTANCE(context->instance));
169
+ return TRUE;
170
+ }
171
+
172
+ #pragma mark -
173
+ #pragma mark Exported
174
+
175
+ static void ios_create_bitmap_context(mfInfo *mfi)
176
+ {
177
+ [mfi->session performSelectorOnMainThread:@selector(sessionBitmapContextWillChange)
178
+ withObject:nil
179
+ waitUntilDone:YES];
180
+ rdpGdi *gdi = mfi->instance->context->gdi;
181
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
182
+
183
+ if (FreeRDPGetBytesPerPixel(gdi->dstFormat) == 2)
184
+ mfi->bitmap_context = CGBitmapContextCreate(
185
+ gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace,
186
+ kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
187
+ else
188
+ mfi->bitmap_context = CGBitmapContextCreate(
189
+ gdi->primary_buffer, gdi->width, gdi->height, 8, gdi->stride, colorSpace,
190
+ kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
191
+
192
+ CGColorSpaceRelease(colorSpace);
193
+ [mfi->session performSelectorOnMainThread:@selector(sessionBitmapContextDidChange)
194
+ withObject:nil
195
+ waitUntilDone:YES];
196
+ }
197
+
198
+ void ios_allocate_display_buffer(mfInfo *mfi)
199
+ {
200
+ ios_create_bitmap_context(mfi);
201
+ }
202
+
203
+ void ios_resize_display_buffer(mfInfo *mfi)
204
+ {
205
+ // Release the old context in a thread-safe manner
206
+ CGContextRef old_context = mfi->bitmap_context;
207
+ mfi->bitmap_context = NULL;
208
+ CGContextRelease(old_context);
209
+ // Create the new context
210
+ ios_create_bitmap_context(mfi);
211
+ }
local-test-freerdp-full-01/afc-freerdp/client/iOS/Misc/Reachability.m ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ File: Reachability.m
4
+ Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
5
+
6
+ Version: 2.2
7
+
8
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
9
+ ("Apple") in consideration of your agreement to the following terms, and your
10
+ use, installation, modification or redistribution of this Apple software
11
+ constitutes acceptance of these terms. If you do not agree with these terms,
12
+ please do not use, install, modify or redistribute this Apple software.
13
+
14
+ In consideration of your agreement to abide by the following terms, and subject
15
+ to these terms, Apple grants you a personal, non-exclusive license, under
16
+ Apple's copyrights in this original Apple software (the "Apple Software"), to
17
+ use, reproduce, modify and redistribute the Apple Software, with or without
18
+ modifications, in source and/or binary forms; provided that if you redistribute
19
+ the Apple Software in its entirety and without modifications, you must retain
20
+ this notice and the following text and disclaimers in all such redistributions
21
+ of the Apple Software.
22
+ Neither the name, trademarks, service marks or logos of Apple Inc. may be used
23
+ to endorse or promote products derived from the Apple Software without specific
24
+ prior written permission from Apple. Except as expressly stated in this notice,
25
+ no other rights or licenses, express or implied, are granted by Apple herein,
26
+ including but not limited to any patent rights that may be infringed by your
27
+ derivative works or by other works in which the Apple Software may be
28
+ incorporated.
29
+
30
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
31
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
32
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
34
+ COMBINATION WITH YOUR PRODUCTS.
35
+
36
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
37
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
40
+ DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
41
+ CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
42
+ APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ Copyright (C) 2010 Apple Inc. All Rights Reserved.
45
+
46
+ */
47
+
48
+ #import <sys/socket.h>
49
+ #import <netinet/in.h>
50
+ #import <netinet6/in6.h>
51
+ #import <arpa/inet.h>
52
+ #import <ifaddrs.h>
53
+ #import <netdb.h>
54
+
55
+ #import <CoreFoundation/CoreFoundation.h>
56
+
57
+ #import "Reachability.h"
58
+
59
+ #define kShouldPrintReachabilityFlags 1
60
+
61
+ static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char *comment)
62
+ {
63
+ #if kShouldPrintReachabilityFlags
64
+
65
+ NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
66
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
67
+ (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
68
+
69
+ (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
70
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
71
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
72
+ (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
73
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
74
+ (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
75
+ (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', comment);
76
+ #endif
77
+ }
78
+
79
+ @implementation Reachability
80
+ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags,
81
+ void *info)
82
+ {
83
+ #pragma unused(target, flags)
84
+ NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
85
+ NSCAssert([(NSObject *)info isKindOfClass:[Reachability class]],
86
+ @"info was wrong class in ReachabilityCallback");
87
+
88
+ // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
89
+ // in case someone uses the Reachablity object in a different thread.
90
+ NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
91
+
92
+ Reachability *noteObject = (Reachability *)info;
93
+ // Post a notification to notify the client that the network reachability changed.
94
+ [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
95
+ object:noteObject];
96
+
97
+ [myPool release];
98
+ }
99
+
100
+ - (BOOL)startNotifier
101
+ {
102
+ BOOL retVal = NO;
103
+ SCNetworkReachabilityContext context = { 0, self, NULL, NULL, NULL };
104
+ if (SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
105
+ {
106
+ if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(),
107
+ kCFRunLoopDefaultMode))
108
+ {
109
+ retVal = YES;
110
+ }
111
+ }
112
+ return retVal;
113
+ }
114
+
115
+ - (void)stopNotifier
116
+ {
117
+ if (reachabilityRef != NULL)
118
+ {
119
+ SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(),
120
+ kCFRunLoopDefaultMode);
121
+ }
122
+ }
123
+
124
+ - (void)dealloc
125
+ {
126
+ [self stopNotifier];
127
+ if (reachabilityRef != NULL)
128
+ {
129
+ CFRelease(reachabilityRef);
130
+ }
131
+ [super dealloc];
132
+ }
133
+
134
+ + (Reachability *)reachabilityWithHostName:(NSString *)hostName;
135
+ {
136
+ Reachability *retVal = NULL;
137
+ SCNetworkReachabilityRef reachability =
138
+ SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
139
+ if (reachability != NULL)
140
+ {
141
+ retVal = [[[self alloc] init] autorelease];
142
+ if (retVal != NULL)
143
+ {
144
+ retVal->reachabilityRef = reachability;
145
+ retVal->localWiFiRef = NO;
146
+ }
147
+ }
148
+ return retVal;
149
+ }
150
+
151
+ + (Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
152
+ {
153
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(
154
+ kCFAllocatorDefault, (const struct sockaddr *)hostAddress);
155
+ Reachability *retVal = NULL;
156
+ if (reachability != NULL)
157
+ {
158
+ retVal = [[[self alloc] init] autorelease];
159
+ if (retVal != NULL)
160
+ {
161
+ retVal->reachabilityRef = reachability;
162
+ retVal->localWiFiRef = NO;
163
+ }
164
+ }
165
+ return retVal;
166
+ }
167
+
168
+ + (Reachability *)reachabilityForInternetConnection;
169
+ {
170
+ struct sockaddr_in zeroAddress;
171
+ bzero(&zeroAddress, sizeof(zeroAddress));
172
+ zeroAddress.sin_len = sizeof(zeroAddress);
173
+ zeroAddress.sin_family = AF_INET;
174
+ return [self reachabilityWithAddress:&zeroAddress];
175
+ }
176
+
177
+ + (Reachability *)reachabilityForLocalWiFi;
178
+ {
179
+ struct sockaddr_in localWifiAddress;
180
+ bzero(&localWifiAddress, sizeof(localWifiAddress));
181
+ localWifiAddress.sin_len = sizeof(localWifiAddress);
182
+ localWifiAddress.sin_family = AF_INET;
183
+ // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
184
+ localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
185
+ Reachability *retVal = [self reachabilityWithAddress:&localWifiAddress];
186
+ if (retVal != NULL)
187
+ {
188
+ retVal->localWiFiRef = YES;
189
+ }
190
+ return retVal;
191
+ }
192
+
193
+ #pragma mark Network Flag Handling
194
+
195
+ - (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
196
+ {
197
+ PrintReachabilityFlags(flags, "localWiFiStatusForFlags");
198
+
199
+ BOOL retVal = NotReachable;
200
+ if ((flags & kSCNetworkReachabilityFlagsReachable) &&
201
+ (flags & kSCNetworkReachabilityFlagsIsDirect))
202
+ {
203
+ retVal = ReachableViaWiFi;
204
+ }
205
+ return retVal;
206
+ }
207
+
208
+ - (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
209
+ {
210
+ PrintReachabilityFlags(flags, "networkStatusForFlags");
211
+ if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
212
+ {
213
+ // if target host is not reachable
214
+ return NotReachable;
215
+ }
216
+
217
+ BOOL retVal = NotReachable;
218
+
219
+ if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
220
+ {
221
+ // if target host is reachable and no connection is required
222
+ // then we'll assume (for now) that your on Wi-Fi
223
+ retVal = ReachableViaWiFi;
224
+ }
225
+
226
+ if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
227
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
228
+ {
229
+ // ... and the connection is on-demand (or on-traffic) if the
230
+ // calling application is using the CFSocketStream or higher APIs
231
+
232
+ if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
233
+ {
234
+ // ... and no [user] intervention is needed
235
+ retVal = ReachableViaWiFi;
236
+ }
237
+ }
238
+
239
+ if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
240
+ {
241
+ // ... but WWAN connections are OK if the calling application
242
+ // is using the CFNetwork (CFSocketStream?) APIs.
243
+ retVal = ReachableViaWWAN;
244
+ }
245
+ return retVal;
246
+ }
247
+
248
+ - (BOOL)connectionRequired;
249
+ {
250
+ NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
251
+ SCNetworkReachabilityFlags flags;
252
+ if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
253
+ {
254
+ return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
255
+ }
256
+ return NO;
257
+ }
258
+
259
+ - (NetworkStatus)currentReachabilityStatus
260
+ {
261
+ NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
262
+ NetworkStatus retVal = NotReachable;
263
+ SCNetworkReachabilityFlags flags;
264
+ if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
265
+ {
266
+ if (localWiFiRef)
267
+ {
268
+ retVal = [self localWiFiStatusForFlags:flags];
269
+ }
270
+ else
271
+ {
272
+ retVal = [self networkStatusForFlags:flags];
273
+ }
274
+ }
275
+ return retVal;
276
+ }
277
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/Encryptor.h ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Password Encryptor
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ /* Encrypts data using AES 128 with a 256 bit key derived using PBKDF2-HMAC-SHA1 */
12
+
13
+ #import <Foundation/Foundation.h>
14
+
15
+ // Encryption block cipher config
16
+ #define TSXEncryptorBlockCipherAlgo kCCAlgorithmAES128
17
+ #define TSXEncryptorBlockCipherKeySize kCCKeySizeAES256
18
+ #define TSXEncryptorBlockCipherOptions kCCOptionPKCS7Padding
19
+ #define TSXEncryptorBlockCipherBlockSize 16
20
+
21
+ // Key generation: If any of these are changed, existing password stores will no longer work
22
+ #define TSXEncryptorPBKDF2Rounds 100
23
+ #define TSXEncryptorPBKDF2Salt "9D¶3L}S¿lA[e€3C«"
24
+ #define TSXEncryptorPBKDF2SaltLen TSXEncryptorBlockCipherOptions
25
+ #define TSXEncryptorPBKDF2KeySize TSXEncryptorBlockCipherKeySize
26
+
27
+ @interface Encryptor : NSObject
28
+ {
29
+ @private
30
+ NSData *_encryption_key;
31
+ NSString *_plaintext_password;
32
+ }
33
+
34
+ @property(readonly) NSString *plaintextPassword;
35
+
36
+ - (id)initWithPassword:(NSString *)plaintext_password;
37
+
38
+ - (NSData *)encryptData:(NSData *)plaintext_data;
39
+ - (NSData *)decryptData:(NSData *)encrypted_data;
40
+ - (NSData *)encryptString:(NSString *)plaintext_string;
41
+ - (NSString *)decryptString:(NSData *)encrypted_string;
42
+
43
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPKeyboard.h ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Keyboard helper
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import "RDPSession.h"
13
+
14
+ @class RDPKeyboard;
15
+
16
+ @protocol RDPKeyboardDelegate <NSObject>
17
+ @optional
18
+ - (void)modifiersChangedForKeyboard:(RDPKeyboard *)keyboard;
19
+ @end
20
+
21
+ @interface RDPKeyboard : NSObject
22
+ {
23
+
24
+ RDPSession *_session;
25
+
26
+ int _virtual_key_map[256];
27
+ int _unicode_map[256];
28
+ NSDictionary *_special_keys;
29
+
30
+ NSObject<RDPKeyboardDelegate> *_delegate;
31
+
32
+ BOOL _ctrl_pressed;
33
+ BOOL _alt_pressed;
34
+ BOOL _shift_pressed;
35
+ BOOL _win_pressed;
36
+ }
37
+
38
+ @property(assign) id<RDPKeyboardDelegate> delegate;
39
+ @property(readonly) BOOL ctrlPressed;
40
+ @property(readonly) BOOL altPressed;
41
+ @property(readonly) BOOL shiftPressed;
42
+ @property(readonly) BOOL winPressed;
43
+
44
+ // returns a keyboard instance
45
+ + (RDPKeyboard *)getSharedRDPKeyboard;
46
+
47
+ // init the keyboard and assign the given rdp session and delegate
48
+ - (void)initWithSession:(RDPSession *)session delegate:(NSObject<RDPKeyboardDelegate> *)delegate;
49
+
50
+ // called to reset any pending key states (i.e. pressed modifier keys)
51
+ - (void)reset;
52
+
53
+ // sends the given unicode character to the server
54
+ - (void)sendUnicode:(int)character;
55
+
56
+ // send a key stroke event using the given virtual key code
57
+ - (void)sendVirtualKeyCode:(int)keyCode;
58
+
59
+ // toggle ctrl key, returns true if pressed, otherwise false
60
+ - (void)toggleCtrlKey;
61
+
62
+ // toggle alt key, returns true if pressed, otherwise false
63
+ - (void)toggleAltKey;
64
+
65
+ // toggle shift key, returns true if pressed, otherwise false
66
+ - (void)toggleShiftKey;
67
+
68
+ // toggle windows key, returns true if pressed, otherwise false
69
+ - (void)toggleWinKey;
70
+
71
+ // send key strokes
72
+ - (void)sendEnterKeyStroke;
73
+ - (void)sendEscapeKeyStroke;
74
+ - (void)sendBackspaceKeyStroke;
75
+
76
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Models/RDPKeyboard.m ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ RDP Keyboard helper
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import "RDPKeyboard.h"
12
+ #include <freerdp/locale/keyboard.h>
13
+
14
+ @interface RDPKeyboard (Private)
15
+ - (void)sendVirtualKey:(int)vKey up:(BOOL)up;
16
+ - (void)handleSpecialKey:(int)character;
17
+ - (void)handleAlphaNumChar:(int)character;
18
+ - (void)notifyDelegateModifiersChanged;
19
+ @end
20
+
21
+ @implementation RDPKeyboard
22
+
23
+ @synthesize delegate = _delegate, ctrlPressed = _ctrl_pressed, altPressed = _alt_pressed,
24
+ shiftPressed = _shift_pressed, winPressed = _win_pressed;
25
+
26
+ - (id)init
27
+ {
28
+ if ((self = [super init]) != nil)
29
+ {
30
+ [self initWithSession:nil delegate:nil];
31
+
32
+ memset(_virtual_key_map, 0, sizeof(_virtual_key_map));
33
+ memset(_unicode_map, 0, sizeof(_unicode_map));
34
+
35
+ // init vkey map - used for alpha-num characters
36
+ _virtual_key_map['0'] = VK_KEY_0;
37
+ _virtual_key_map['1'] = VK_KEY_1;
38
+ _virtual_key_map['2'] = VK_KEY_2;
39
+ _virtual_key_map['3'] = VK_KEY_3;
40
+ _virtual_key_map['4'] = VK_KEY_4;
41
+ _virtual_key_map['5'] = VK_KEY_5;
42
+ _virtual_key_map['6'] = VK_KEY_6;
43
+ _virtual_key_map['7'] = VK_KEY_7;
44
+ _virtual_key_map['8'] = VK_KEY_8;
45
+ _virtual_key_map['9'] = VK_KEY_9;
46
+
47
+ _virtual_key_map['a'] = VK_KEY_A;
48
+ _virtual_key_map['b'] = VK_KEY_B;
49
+ _virtual_key_map['c'] = VK_KEY_C;
50
+ _virtual_key_map['d'] = VK_KEY_D;
51
+ _virtual_key_map['e'] = VK_KEY_E;
52
+ _virtual_key_map['f'] = VK_KEY_F;
53
+ _virtual_key_map['g'] = VK_KEY_G;
54
+ _virtual_key_map['h'] = VK_KEY_H;
55
+ _virtual_key_map['i'] = VK_KEY_I;
56
+ _virtual_key_map['j'] = VK_KEY_J;
57
+ _virtual_key_map['k'] = VK_KEY_K;
58
+ _virtual_key_map['l'] = VK_KEY_L;
59
+ _virtual_key_map['m'] = VK_KEY_M;
60
+ _virtual_key_map['n'] = VK_KEY_N;
61
+ _virtual_key_map['o'] = VK_KEY_O;
62
+ _virtual_key_map['p'] = VK_KEY_P;
63
+ _virtual_key_map['q'] = VK_KEY_Q;
64
+ _virtual_key_map['r'] = VK_KEY_R;
65
+ _virtual_key_map['s'] = VK_KEY_S;
66
+ _virtual_key_map['t'] = VK_KEY_T;
67
+ _virtual_key_map['u'] = VK_KEY_U;
68
+ _virtual_key_map['v'] = VK_KEY_V;
69
+ _virtual_key_map['w'] = VK_KEY_W;
70
+ _virtual_key_map['x'] = VK_KEY_X;
71
+ _virtual_key_map['y'] = VK_KEY_Y;
72
+ _virtual_key_map['z'] = VK_KEY_Z;
73
+
74
+ // init scancode map - used for special characters
75
+ _unicode_map['-'] = 45;
76
+ _unicode_map['/'] = 47;
77
+ _unicode_map[':'] = 58;
78
+ _unicode_map[';'] = 59;
79
+ _unicode_map['('] = 40;
80
+ _unicode_map[')'] = 41;
81
+ _unicode_map['&'] = 38;
82
+ _unicode_map['@'] = 64;
83
+ _unicode_map['.'] = 46;
84
+ _unicode_map[','] = 44;
85
+ _unicode_map['?'] = 63;
86
+ _unicode_map['!'] = 33;
87
+ _unicode_map['\''] = 39;
88
+ _unicode_map['\"'] = 34;
89
+
90
+ _unicode_map['['] = 91;
91
+ _unicode_map[']'] = 93;
92
+ _unicode_map['{'] = 123;
93
+ _unicode_map['}'] = 125;
94
+ _unicode_map['#'] = 35;
95
+ _unicode_map['%'] = 37;
96
+ _unicode_map['^'] = 94;
97
+ _unicode_map['*'] = 42;
98
+ _unicode_map['+'] = 43;
99
+ _unicode_map['='] = 61;
100
+
101
+ _unicode_map['_'] = 95;
102
+ _unicode_map['\\'] = 92;
103
+ _unicode_map['|'] = 124;
104
+ _unicode_map['~'] = 126;
105
+ _unicode_map['<'] = 60;
106
+ _unicode_map['>'] = 62;
107
+ _unicode_map['$'] = 36;
108
+ }
109
+ return self;
110
+ }
111
+
112
+ - (void)dealloc
113
+ {
114
+ [super dealloc];
115
+ }
116
+
117
+ #pragma mark -
118
+ #pragma mark class methods
119
+
120
+ // return a keyboard instance
121
+ + (RDPKeyboard *)getSharedRDPKeyboard
122
+ {
123
+ static RDPKeyboard *_shared_keyboard = nil;
124
+
125
+ if (_shared_keyboard == nil)
126
+ {
127
+ @synchronized(self)
128
+ {
129
+ if (_shared_keyboard == nil)
130
+ _shared_keyboard = [[RDPKeyboard alloc] init];
131
+ }
132
+ }
133
+
134
+ return _shared_keyboard;
135
+ }
136
+
137
+ // reset the keyboard instance and assign the given rdp instance
138
+ - (void)initWithSession:(RDPSession *)session delegate:(NSObject<RDPKeyboardDelegate> *)delegate
139
+ {
140
+ _alt_pressed = NO;
141
+ _ctrl_pressed = NO;
142
+ _shift_pressed = NO;
143
+ _win_pressed = NO;
144
+
145
+ _session = session;
146
+ _delegate = delegate;
147
+ }
148
+
149
+ - (void)reset
150
+ {
151
+ // reset pressed ctrl, alt, shift or win key
152
+ if (_shift_pressed)
153
+ [self toggleShiftKey];
154
+ if (_alt_pressed)
155
+ [self toggleAltKey];
156
+ if (_ctrl_pressed)
157
+ [self toggleCtrlKey];
158
+ if (_win_pressed)
159
+ [self toggleWinKey];
160
+ }
161
+
162
+ // handles button pressed input event from the iOS keyboard
163
+ // performs all conversions etc.
164
+ - (void)sendUnicode:(int)character
165
+ {
166
+ if (isalnum(character))
167
+ [self handleAlphaNumChar:character];
168
+ else
169
+ [self handleSpecialKey:character];
170
+
171
+ [self reset];
172
+ }
173
+
174
+ // send a backspace key press
175
+ - (void)sendVirtualKeyCode:(int)keyCode
176
+ {
177
+ [self sendVirtualKey:keyCode up:NO];
178
+ [self sendVirtualKey:keyCode up:YES];
179
+ }
180
+
181
+ #pragma mark modifier key handling
182
+ // toggle ctrl key, returns true if pressed, otherwise false
183
+ - (void)toggleCtrlKey
184
+ {
185
+ [self sendVirtualKey:VK_LCONTROL up:_ctrl_pressed];
186
+ _ctrl_pressed = !_ctrl_pressed;
187
+ [self notifyDelegateModifiersChanged];
188
+ }
189
+
190
+ // toggle alt key, returns true if pressed, otherwise false
191
+ - (void)toggleAltKey
192
+ {
193
+ [self sendVirtualKey:VK_LMENU up:_alt_pressed];
194
+ _alt_pressed = !_alt_pressed;
195
+ [self notifyDelegateModifiersChanged];
196
+ }
197
+
198
+ // toggle shift key, returns true if pressed, otherwise false
199
+ - (void)toggleShiftKey
200
+ {
201
+ [self sendVirtualKey:VK_LSHIFT up:_shift_pressed];
202
+ _shift_pressed = !_shift_pressed;
203
+ [self notifyDelegateModifiersChanged];
204
+ }
205
+
206
+ // toggle windows key, returns true if pressed, otherwise false
207
+ - (void)toggleWinKey
208
+ {
209
+ [self sendVirtualKey:(VK_LWIN | KBDEXT) up:_win_pressed];
210
+ _win_pressed = !_win_pressed;
211
+ [self notifyDelegateModifiersChanged];
212
+ }
213
+
214
+ #pragma mark Sending special key strokes
215
+
216
+ - (void)sendEnterKeyStroke
217
+ {
218
+ [self sendVirtualKeyCode:(VK_RETURN | KBDEXT)];
219
+ }
220
+
221
+ - (void)sendEscapeKeyStroke
222
+ {
223
+ [self sendVirtualKeyCode:VK_ESCAPE];
224
+ }
225
+
226
+ - (void)sendBackspaceKeyStroke
227
+ {
228
+ [self sendVirtualKeyCode:VK_BACK];
229
+ }
230
+
231
+ @end
232
+
233
+ #pragma mark -
234
+ @implementation RDPKeyboard (Private)
235
+
236
+ - (void)handleAlphaNumChar:(int)character
237
+ {
238
+ // if we receive an uppercase letter - make it lower and send an shift down event to server
239
+ BOOL shift_was_sent = NO;
240
+ if (isupper(character) && _shift_pressed == NO)
241
+ {
242
+ character = tolower(character);
243
+ [self sendVirtualKey:VK_LSHIFT up:NO];
244
+ shift_was_sent = YES;
245
+ }
246
+
247
+ // convert the character to a VK
248
+ int vk = _virtual_key_map[character];
249
+ if (vk != 0)
250
+ {
251
+ // send key pressed
252
+ [self sendVirtualKey:vk up:NO];
253
+ [self sendVirtualKey:vk up:YES];
254
+ }
255
+
256
+ // send the missing shift up if we had a shift down
257
+ if (shift_was_sent)
258
+ [self sendVirtualKey:VK_LSHIFT up:YES];
259
+ }
260
+
261
+ - (void)handleSpecialKey:(int)character
262
+ {
263
+ NSDictionary *eventDescriptor = nil;
264
+ if (character < 256)
265
+ {
266
+ // convert the character to a unicode character
267
+ int code = _unicode_map[character];
268
+ if (code != 0)
269
+ eventDescriptor = [NSDictionary
270
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"unicode", @"subtype",
271
+ [NSNumber numberWithUnsignedShort:0], @"flags",
272
+ [NSNumber numberWithUnsignedShort:code],
273
+ @"unicode_char", nil];
274
+ }
275
+
276
+ if (eventDescriptor == nil)
277
+ eventDescriptor = [NSDictionary
278
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"unicode", @"subtype",
279
+ [NSNumber numberWithUnsignedShort:0], @"flags",
280
+ [NSNumber numberWithUnsignedShort:character],
281
+ @"unicode_char", nil];
282
+
283
+ [_session sendInputEvent:eventDescriptor];
284
+ }
285
+
286
+ // sends the vk code to the session
287
+ - (void)sendVirtualKey:(int)vKey up:(BOOL)up
288
+ {
289
+ DWORD scancode = GetVirtualScanCodeFromVirtualKeyCode(vKey, 4);
290
+ int flags = (up ? KBD_FLAGS_RELEASE : KBD_FLAGS_DOWN);
291
+ flags |= ((scancode & KBDEXT) ? KBD_FLAGS_EXTENDED : 0);
292
+ [_session
293
+ sendInputEvent:[NSDictionary
294
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"scancode",
295
+ @"subtype",
296
+ [NSNumber numberWithUnsignedShort:flags],
297
+ @"flags",
298
+ [NSNumber
299
+ numberWithUnsignedShort:(scancode &
300
+ 0xFF)],
301
+ @"scancode", nil]];
302
+ }
303
+
304
+ - (void)notifyDelegateModifiersChanged
305
+ {
306
+ if ([[self delegate] respondsToSelector:@selector(modifiersChangedForKeyboard:)])
307
+ [[self delegate] modifiersChangedForKeyboard:self];
308
+ }
309
+
310
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/AdvancedKeyboardView.h ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Advanced keyboard view interface
3
+
4
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7
+ If a copy of the MPL was not distributed with this file, You can obtain one at
8
+ http://mozilla.org/MPL/2.0/.
9
+ */
10
+
11
+ #import <UIKit/UIKit.h>
12
+
13
+ // forward declaration
14
+ @protocol AdvancedKeyboardDelegate <NSObject>
15
+ @optional
16
+ // called when a function key was pressed and a virtual keycode is provided
17
+ // @key: virtual key code
18
+ - (void)advancedKeyPressedVKey:(int)key;
19
+ // called when a function key was pressed and the keys unicode is provided
20
+ // @key: unicode character
21
+ - (void)advancedKeyPressedUnicode:(int)key;
22
+ @end
23
+
24
+ @interface AdvancedKeyboardView : UIView
25
+ {
26
+ @private
27
+ // view containing function keys (F-keys) and function block (ins, del, home, end, ...)
28
+ UIView *_function_keys_view;
29
+
30
+ // view containing numpad keys (0-9, +-/*)
31
+ UIView *_numpad_keys_view;
32
+
33
+ // view containing cursor keys (up, down, left, right)
34
+ UIView *_cursor_keys_view;
35
+
36
+ // currently visible view
37
+ UIView *_cur_view;
38
+
39
+ // delegate
40
+ NSObject<AdvancedKeyboardDelegate> *_delegate;
41
+ }
42
+
43
+ @property(assign) NSObject<AdvancedKeyboardDelegate> *delegate;
44
+
45
+ // init keyboard view with frame and delegate
46
+ - (id)initWithFrame:(CGRect)frame delegate:(NSObject<AdvancedKeyboardDelegate> *)delegate;
47
+
48
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/BlockAlertView.h ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // BlockAlertView.h
3
+ //
4
+ //
5
+
6
+ #import <UIKit/UIKit.h>
7
+
8
+ @interface BlockAlertView : NSObject
9
+ {
10
+ @protected
11
+ UIView *_view;
12
+ NSMutableArray *_blocks;
13
+ CGFloat _height;
14
+ NSString *_title;
15
+ NSString *_message;
16
+ BOOL _shown;
17
+ BOOL _cancelBounce;
18
+ }
19
+
20
+ + (BlockAlertView *)alertWithTitle:(NSString *)title message:(NSString *)message;
21
+
22
+ + (void)showInfoAlertWithTitle:(NSString *)title message:(NSString *)message;
23
+ + (void)showErrorAlert:(NSError *)error;
24
+
25
+ - (id)initWithTitle:(NSString *)title message:(NSString *)message;
26
+
27
+ - (void)setDestructiveButtonWithTitle:(NSString *)title block:(void (^)())block;
28
+ - (void)setCancelButtonWithTitle:(NSString *)title block:(void (^)())block;
29
+ - (void)addButtonWithTitle:(NSString *)title block:(void (^)())block;
30
+
31
+ - (void)addComponents:(CGRect)frame;
32
+
33
+ - (void)show;
34
+ - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
35
+
36
+ - (void)setupDisplay;
37
+
38
+ @property(nonatomic, retain) UIImage *backgroundImage;
39
+ @property(nonatomic, readonly) UIView *view;
40
+ @property(nonatomic, readwrite) BOOL vignetteBackground;
41
+
42
+ @end
local-test-freerdp-full-01/afc-freerdp/client/iOS/Views/BlockAlertView.m ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // BlockAlertView.m
3
+ //
4
+ //
5
+
6
+ #import "BlockAlertView.h"
7
+ #import "BlockBackground.h"
8
+ #import "BlockUI.h"
9
+
10
+ @implementation BlockAlertView
11
+
12
+ @synthesize view = _view;
13
+ @synthesize backgroundImage = _backgroundImage;
14
+ @synthesize vignetteBackground = _vignetteBackground;
15
+
16
+ static UIImage *background = nil;
17
+ static UIImage *backgroundlandscape = nil;
18
+ static UIFont *titleFont = nil;
19
+ static UIFont *messageFont = nil;
20
+ static UIFont *buttonFont = nil;
21
+
22
+ #pragma mark - init
23
+
24
+ + (void)initialize
25
+ {
26
+ if (self == [BlockAlertView class])
27
+ {
28
+ background = [UIImage imageNamed:kAlertViewBackground];
29
+ background =
30
+ [[background stretchableImageWithLeftCapWidth:0
31
+ topCapHeight:kAlertViewBackgroundCapHeight] retain];
32
+
33
+ backgroundlandscape = [UIImage imageNamed:kAlertViewBackgroundLandscape];
34
+ backgroundlandscape = [[backgroundlandscape
35
+ stretchableImageWithLeftCapWidth:0
36
+ topCapHeight:kAlertViewBackgroundCapHeight] retain];
37
+
38
+ titleFont = [kAlertViewTitleFont retain];
39
+ messageFont = [kAlertViewMessageFont retain];
40
+ buttonFont = [kAlertViewButtonFont retain];
41
+ }
42
+ }
43
+
44
+ + (BlockAlertView *)alertWithTitle:(NSString *)title message:(NSString *)message
45
+ {
46
+ return [[[BlockAlertView alloc] initWithTitle:title message:message] autorelease];
47
+ }
48
+
49
+ + (void)showInfoAlertWithTitle:(NSString *)title message:(NSString *)message
50
+ {
51
+ BlockAlertView *alert = [[BlockAlertView alloc] initWithTitle:title message:message];
52
+ [alert setCancelButtonWithTitle:NSLocalizedString(@"Dismiss", nil) block:nil];
53
+ [alert show];
54
+ [alert release];
55
+ }
56
+
57
+ + (void)showErrorAlert:(NSError *)error
58
+ {
59
+ BlockAlertView *alert = [[BlockAlertView alloc]
60
+ initWithTitle:NSLocalizedString(@"Operation Failed", nil)
61
+ message:[NSString
62
+ stringWithFormat:NSLocalizedString(
63
+ @"The operation did not complete successfully: %@",
64
+ nil),
65
+ error]];
66
+ [alert setCancelButtonWithTitle:@"Dismiss" block:nil];
67
+ [alert show];
68
+ [alert release];
69
+ }
70
+
71
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
72
+ #pragma mark - NSObject
73
+
74
+ - (void)addComponents:(CGRect)frame
75
+ {
76
+ if (_title)
77
+ {
78
+ CGSize size = [_title sizeWithFont:titleFont
79
+ constrainedToSize:CGSizeMake(frame.size.width - kAlertViewBorder * 2, 1000)
80
+ lineBreakMode:NSLineBreakByWordWrapping];
81
+
82
+ UILabel *labelView = [[UILabel alloc]
83
+ initWithFrame:CGRectMake(kAlertViewBorder, _height,
84
+ frame.size.width - kAlertViewBorder * 2, size.height)];
85
+ labelView.font = titleFont;
86
+ labelView.numberOfLines = 0;
87
+ labelView.lineBreakMode = NSLineBreakByWordWrapping;
88
+ labelView.textColor = kAlertViewTitleTextColor;
89
+ labelView.backgroundColor = [UIColor clearColor];
90
+ labelView.textAlignment = NSTextAlignmentCenter;
91
+ labelView.shadowColor = kAlertViewTitleShadowColor;
92
+ labelView.shadowOffset = kAlertViewTitleShadowOffset;
93
+ labelView.text = _title;
94
+ [_view addSubview:labelView];
95
+ [labelView release];
96
+
97
+ _height += size.height + kAlertViewBorder;
98
+ }
99
+
100
+ if (_message)
101
+ {
102
+ CGSize size =
103
+ [_message sizeWithFont:messageFont
104
+ constrainedToSize:CGSizeMake(frame.size.width - kAlertViewBorder * 2, 1000)
105
+ lineBreakMode:NSLineBreakByWordWrapping];
106
+
107
+ UILabel *labelView = [[UILabel alloc]
108
+ initWithFrame:CGRectMake(kAlertViewBorder, _height,
109
+ frame.size.width - kAlertViewBorder * 2, size.height)];
110
+ labelView.font = messageFont;
111
+ labelView.numberOfLines = 0;
112
+ labelView.lineBreakMode = NSLineBreakByWordWrapping;
113
+ labelView.textColor = kAlertViewMessageTextColor;
114
+ labelView.backgroundColor = [UIColor clearColor];
115
+ labelView.textAlignment = NSTextAlignmentCenter;
116
+ labelView.shadowColor = kAlertViewMessageShadowColor;
117
+ labelView.shadowOffset = kAlertViewMessageShadowOffset;
118
+ labelView.text = _message;
119
+ [_view addSubview:labelView];
120
+ [labelView release];
121
+
122
+ _height += size.height + kAlertViewBorder;
123
+ }
124
+ }
125
+
126
+ - (void)setupDisplay
127
+ {
128
+ [[_view subviews] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
129
+ [obj removeFromSuperview];
130
+ }];
131
+
132
+ UIWindow *parentView = [BlockBackground sharedInstance];
133
+ CGRect frame = parentView.bounds;
134
+ frame.origin.x = floorf((frame.size.width - background.size.width) * 0.5);
135
+ frame.size.width = background.size.width;
136
+
137
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
138
+ if (UIInterfaceOrientationIsLandscape(orientation))
139
+ {
140
+ frame.size.width += 150;
141
+ frame.origin.x -= 75;
142
+ }
143
+
144
+ _view.frame = frame;
145
+
146
+ _height = kAlertViewBorder + 15;
147
+
148
+ if (NeedsLandscapePhoneTweaks)
149
+ {
150
+ _height -= 15; // landscape phones need to trimmed a bit
151
+ }
152
+
153
+ [self addComponents:frame];
154
+
155
+ if (_shown)
156
+ [self show];
157
+ }
158
+
159
+ - (id)initWithTitle:(NSString *)title message:(NSString *)message
160
+ {
161
+ self = [super init];
162
+
163
+ if (self)
164
+ {
165
+ _title = [title copy];
166
+ _message = [message copy];
167
+
168
+ _view = [[UIView alloc] init];
169
+
170
+ _view.autoresizingMask =
171
+ UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin |
172
+ UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
173
+
174
+ _blocks = [[NSMutableArray alloc] init];
175
+
176
+ [[NSNotificationCenter defaultCenter]
177
+ addObserver:self
178
+ selector:@selector(setupDisplay)
179
+ name:UIApplicationDidChangeStatusBarOrientationNotification
180
+ object:nil];
181
+
182
+ if ([self class] == [BlockAlertView class])
183
+ [self setupDisplay];
184
+
185
+ _vignetteBackground = NO;
186
+ }
187
+
188
+ return self;
189
+ }
190
+
191
+ - (void)dealloc
192
+ {
193
+ [_title release];
194
+ [_message release];
195
+ [_backgroundImage release];
196
+ [_view release];
197
+ [_blocks release];
198
+ [super dealloc];
199
+ }
200
+
201
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
202
+ #pragma mark - Public
203
+
204
+ - (void)addButtonWithTitle:(NSString *)title color:(NSString *)color block:(void (^)())block
205
+ {
206
+ [_blocks addObject:[NSArray arrayWithObjects:block ? [[block copy] autorelease] : [NSNull null],
207
+ title, color, nil]];
208
+ }
209
+
210
+ - (void)addButtonWithTitle:(NSString *)title block:(void (^)())block
211
+ {
212
+ [self addButtonWithTitle:title color:@"gray" block:block];
213
+ }
214
+
215
+ - (void)setCancelButtonWithTitle:(NSString *)title block:(void (^)())block
216
+ {
217
+ [self addButtonWithTitle:title color:@"black" block:block];
218
+ }
219
+
220
+ - (void)setDestructiveButtonWithTitle:(NSString *)title block:(void (^)())block
221
+ {
222
+ [self addButtonWithTitle:title color:@"red" block:block];
223
+ }
224
+
225
+ - (void)show
226
+ {
227
+ _shown = YES;
228
+
229
+ BOOL isSecondButton = NO;
230
+ NSUInteger index = 0;
231
+ for (NSUInteger i = 0; i < _blocks.count; i++)
232
+ {
233
+ NSArray *block = [_blocks objectAtIndex:i];
234
+ NSString *title = [block objectAtIndex:1];
235
+ NSString *color = [block objectAtIndex:2];
236
+
237
+ UIImage *image =
238
+ [UIImage imageNamed:[NSString stringWithFormat:@"alert-%@-button.png", color]];
239
+ image = [image stretchableImageWithLeftCapWidth:(int)(image.size.width + 1) >> 1
240
+ topCapHeight:0];
241
+
242
+ CGFloat maxHalfWidth = floorf((_view.bounds.size.width - kAlertViewBorder * 3) * 0.5);
243
+ CGFloat width = _view.bounds.size.width - kAlertViewBorder * 2;
244
+ CGFloat xOffset = kAlertViewBorder;
245
+ if (isSecondButton)
246
+ {
247
+ width = maxHalfWidth;
248
+ xOffset = width + kAlertViewBorder * 2;
249
+ isSecondButton = NO;
250
+ }
251
+ else if (i + 1 < _blocks.count)
252
+ {
253
+ // In this case there's another button.
254
+ // Let's check if they fit on the same line.
255
+ CGSize size = [title sizeWithFont:buttonFont
256
+ minFontSize:10
257
+ actualFontSize:nil
258
+ forWidth:_view.bounds.size.width - kAlertViewBorder * 2
259
+ lineBreakMode:NSLineBreakByClipping];
260
+
261
+ if (size.width < maxHalfWidth - kAlertViewBorder)
262
+ {
263
+ // It might fit. Check the next Button
264
+ NSArray *block2 = [_blocks objectAtIndex:i + 1];
265
+ NSString *title2 = [block2 objectAtIndex:1];
266
+ size = [title2 sizeWithFont:buttonFont
267
+ minFontSize:10
268
+ actualFontSize:nil
269
+ forWidth:_view.bounds.size.width - kAlertViewBorder * 2
270
+ lineBreakMode:NSLineBreakByClipping];
271
+
272
+ if (size.width < maxHalfWidth - kAlertViewBorder)
273
+ {
274
+ // They'll fit!
275
+ isSecondButton = YES; // For the next iteration
276
+ width = maxHalfWidth;
277
+ }
278
+ }
279
+ }
280
+ else if (_blocks.count == 1)
281
+ {
282
+ // In this case this is the only button. We'll size according to the text
283
+ CGSize size = [title sizeWithFont:buttonFont
284
+ minFontSize:10
285
+ actualFontSize:nil
286
+ forWidth:_view.bounds.size.width - kAlertViewBorder * 2
287
+ lineBreakMode:UILineBreakModeClip];
288
+
289
+ size.width = MAX(size.width, 80);
290
+ if (size.width + 2 * kAlertViewBorder < width)
291
+ {
292
+ width = size.width + 2 * kAlertViewBorder;
293
+ xOffset = floorf((_view.bounds.size.width - width) * 0.5);
294
+ }
295
+ }
296
+
297
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
298
+ button.frame = CGRectMake(xOffset, _height, width, kAlertButtonHeight);
299
+ button.titleLabel.font = buttonFont;
300
+ if (IOS_LESS_THAN_6)
301
+ {
302
+ #pragma clang diagnostic push
303
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
304
+ button.titleLabel.minimumFontSize = 10;
305
+ #pragma clang diagnostic pop
306
+ }
307
+ else
308
+ {
309
+ button.titleLabel.adjustsFontSizeToFitWidth = YES;
310
+ button.titleLabel.adjustsLetterSpacingToFitWidth = YES;
311
+ button.titleLabel.minimumScaleFactor = 0.1;
312
+ }
313
+ button.titleLabel.textAlignment = NSTextAlignmentCenter;
314
+ button.titleLabel.shadowOffset = kAlertViewButtonShadowOffset;
315
+ button.backgroundColor = [UIColor clearColor];
316
+ button.tag = i + 1;
317
+
318
+ [button setBackgroundImage:image forState:UIControlStateNormal];
319
+ [button setTitleColor:kAlertViewButtonTextColor forState:UIControlStateNormal];
320
+ [button setTitleShadowColor:kAlertViewButtonShadowColor forState:UIControlStateNormal];
321
+ [button setTitle:title forState:UIControlStateNormal];
322
+ button.accessibilityLabel = title;
323
+
324
+ [button addTarget:self
325
+ action:@selector(buttonClicked:)
326
+ forControlEvents:UIControlEventTouchUpInside];
327
+
328
+ [_view addSubview:button];
329
+
330
+ if (!isSecondButton)
331
+ _height += kAlertButtonHeight + kAlertViewBorder;
332
+
333
+ index++;
334
+ }
335
+
336
+ _height += 10; // Margin for the shadow
337
+
338
+ if (_height < background.size.height)
339
+ {
340
+ CGFloat offset = background.size.height - _height;
341
+ _height = background.size.height;
342
+ CGRect frame;
343
+ for (NSUInteger i = 0; i < _blocks.count; i++)
344
+ {
345
+ UIButton *btn = (UIButton *)[_view viewWithTag:i + 1];
346
+ frame = btn.frame;
347
+ frame.origin.y += offset;
348
+ btn.frame = frame;
349
+ }
350
+ }
351
+
352
+ CGRect frame = _view.frame;
353
+ frame.origin.y = -_height;
354
+ frame.size.height = _height;
355
+ _view.frame = frame;
356
+
357
+ UIImageView *modalBackground = [[UIImageView alloc] initWithFrame:_view.bounds];
358
+
359
+ if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
360
+ modalBackground.image = backgroundlandscape;
361
+ else
362
+ modalBackground.image = background;
363
+
364
+ modalBackground.contentMode = UIViewContentModeScaleToFill;
365
+ modalBackground.autoresizingMask =
366
+ UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
367
+ [_view insertSubview:modalBackground atIndex:0];
368
+ [modalBackground release];
369
+
370
+ if (_backgroundImage)
371
+ {
372
+ [BlockBackground sharedInstance].backgroundImage = _backgroundImage;
373
+ [_backgroundImage release];
374
+ _backgroundImage = nil;
375
+ }
376
+
377
+ [BlockBackground sharedInstance].vignetteBackground = _vignetteBackground;
378
+ [[BlockBackground sharedInstance] addToMainWindow:_view];
379
+
380
+ __block CGPoint center = _view.center;
381
+ center.y = floorf([BlockBackground sharedInstance].bounds.size.height * 0.5) + kAlertViewBounce;
382
+
383
+ _cancelBounce = NO;
384
+
385
+ [UIView animateWithDuration:0.4
386
+ delay:0.0
387
+ options:UIViewAnimationCurveEaseOut
388
+ animations:^{
389
+ [BlockBackground sharedInstance].alpha = 1.0f;
390
+ _view.center = center;
391
+ }
392
+ completion:^(BOOL finished) {
393
+ if (_cancelBounce)
394
+ return;
395
+
396
+ [UIView animateWithDuration:0.1
397
+ delay:0.0
398
+ options:0
399
+ animations:^{
400
+ center.y -= kAlertViewBounce;
401
+ _view.center = center;
402
+ }
403
+ completion:^(BOOL finished) {
404
+ [[NSNotificationCenter defaultCenter]
405
+ postNotificationName:@"AlertViewFinishedAnimations"
406
+ object:nil];
407
+ }];
408
+ }];
409
+
410
+ [self retain];
411
+ }
412
+
413
+ - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
414
+ {
415
+ _shown = NO;
416
+
417
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
418
+
419
+ if (buttonIndex >= 0 && buttonIndex < [_blocks count])
420
+ {
421
+ id obj = [[_blocks objectAtIndex:buttonIndex] objectAtIndex:0];
422
+ if (![obj isEqual:[NSNull null]])
423
+ {
424
+ ((void (^)())obj)();
425
+ }
426
+ }
427
+
428
+ if (animated)
429
+ {
430
+ [UIView animateWithDuration:0.1
431
+ delay:0.0
432
+ options:0
433
+ animations:^{
434
+ CGPoint center = _view.center;
435
+ center.y += 20;
436
+ _view.center = center;
437
+ }
438
+ completion:^(BOOL finished) {
439
+ [UIView animateWithDuration:0.4
440
+ delay:0.0
441
+ options:UIViewAnimationCurveEaseIn
442
+ animations:^{
443
+ CGRect frame = _view.frame;
444
+ frame.origin.y = -frame.size.height;
445
+ _view.frame = frame;
446
+ [[BlockBackground sharedInstance] reduceAlphaIfEmpty];
447
+ }
448
+ completion:^(BOOL finished) {
449
+ [[BlockBackground sharedInstance] removeView:_view];
450
+ [_view release];
451
+ _view = nil;
452
+ [self autorelease];
453
+ }];
454
+ }];
455
+ }
456
+ else
457
+ {
458
+ [[BlockBackground sharedInstance] removeView:_view];
459
+ [_view release];
460
+ _view = nil;
461
+ [self autorelease];
462
+ }
463
+ }
464
+
465
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
466
+ #pragma mark - Action
467
+
468
+ - (void)buttonClicked:(id)sender
469
+ {
470
+ /* Run the button's block */
471
+ int buttonIndex = [sender tag] - 1;
472
+ [self dismissWithClickedButtonIndex:buttonIndex animated:YES];
473
+ }
474
+
475
+ @end