From 72ca88f49c1b7f6678a66c09fa5fe5506623ed35 Mon Sep 17 00:00:00 2001
From: Armin Novak
Date: Wed, 6 Nov 2019 15:24:51 +0100
Subject: [PATCH] Reformatted to new style
---
channels/audin/client/alsa/audin_alsa.c | 105 +-
channels/audin/client/audin_main.c | 207 +-
channels/audin/client/audin_main.h | 1 -
channels/audin/client/mac/audin_mac.c | 77 +-
.../audin/client/opensles/audin_opensl_es.c | 105 +-
channels/audin/client/opensles/opensl_io.c | 108 +-
channels/audin/client/opensles/opensl_io.h | 46 +-
channels/audin/client/oss/audin_oss.c | 63 +-
channels/audin/client/pulse/audin_pulse.c | 99 +-
channels/audin/client/winmm/audin_winmm.c | 95 +-
channels/audin/server/audin.c | 161 +-
channels/client/addin.c | 69 +-
channels/client/addin.h | 2 -
channels/client/tables.h | 4 +-
channels/cliprdr/client/cliprdr_format.c | 72 +-
channels/cliprdr/client/cliprdr_format.h | 12 +-
channels/cliprdr/client/cliprdr_main.c | 327 +-
channels/cliprdr/client/cliprdr_main.h | 5 +-
channels/cliprdr/cliprdr_common.c | 48 +-
channels/cliprdr/cliprdr_common.h | 36 +-
channels/cliprdr/server/cliprdr_main.c | 398 +-
channels/cliprdr/server/cliprdr_main.h | 2 +-
channels/disp/client/disp_main.c | 98 +-
channels/disp/client/disp_main.h | 2 -
channels/disp/server/disp_main.c | 144 +-
channels/drdynvc/client/drdynvc_main.c | 411 +-
channels/drdynvc/client/drdynvc_main.h | 10 +-
channels/drdynvc/server/drdynvc_main.c | 14 +-
channels/drive/client/drive_file.c | 257 +-
channels/drive/client/drive_file.h | 4 +-
channels/drive/client/drive_main.c | 107 +-
channels/echo/client/echo_main.c | 34 +-
channels/echo/client/echo_main.h | 6 +-
channels/echo/server/echo_main.c | 64 +-
channels/encomsp/client/encomsp_main.c | 319 +-
channels/encomsp/server/encomsp_main.c | 69 +-
channels/geometry/client/geometry_main.c | 96 +-
channels/geometry/client/geometry_main.h | 2 -
channels/parallel/client/parallel_main.c | 59 +-
channels/printer/client/cups/printer_cups.c | 85 +-
channels/printer/client/printer_main.c | 341 +-
channels/printer/client/win/printer_win.c | 102 +-
channels/printer/printer.h | 19 +-
channels/rail/client/rail_main.c | 189 +-
channels/rail/client/rail_orders.c | 243 +-
channels/rail/client/rail_orders.h | 11 +-
channels/rail/rail_common.c | 61 +-
channels/rail/rail_common.h | 28 +-
channels/rdp2tcp/client/rdp2tcp_main.c | 45 +-
channels/rdpdr/client/devman.c | 34 +-
channels/rdpdr/client/irp.c | 17 +-
channels/rdpdr/client/rdpdr_capabilities.c | 10 +-
channels/rdpdr/client/rdpdr_main.c | 351 +-
channels/rdpdr/server/rdpdr_main.c | 893 +-
channels/rdpdr/server/rdpdr_main.h | 20 +-
channels/rdpei/client/rdpei_main.c | 235 +-
channels/rdpei/client/rdpei_main.h | 14 +-
channels/rdpei/rdpei_common.c | 25 +-
channels/rdpei/rdpei_common.h | 8 +-
channels/rdpei/server/rdpei_main.c | 227 +-
channels/rdpei/server/rdpei_main.h | 3 -
channels/rdpgfx/client/rdpgfx_codec.c | 52 +-
channels/rdpgfx/client/rdpgfx_main.c | 702 +-
channels/rdpgfx/client/rdpgfx_main.h | 1 -
channels/rdpgfx/rdpgfx_common.c | 85 +-
channels/rdpgfx/rdpgfx_common.h | 8 +-
channels/rdpgfx/server/rdpgfx_main.c | 431 +-
channels/rdpsnd/client/alsa/rdpsnd_alsa.c | 100 +-
channels/rdpsnd/client/fake/rdpsnd_fake.c | 26 +-
channels/rdpsnd/client/ios/TPCircularBuffer.c | 197 +-
channels/rdpsnd/client/ios/TPCircularBuffer.h | 284 +-
channels/rdpsnd/client/ios/rdpsnd_ios.c | 59 +-
channels/rdpsnd/client/mac/rdpsnd_mac.m | 100 +-
channels/rdpsnd/client/opensles/opensl_io.c | 165 +-
channels/rdpsnd/client/opensles/opensl_io.h | 131 +-
.../rdpsnd/client/opensles/rdpsnd_opensles.c | 135 +-
channels/rdpsnd/client/oss/rdpsnd_oss.c | 39 +-
channels/rdpsnd/client/proxy/rdpsnd_proxy.c | 14 +-
channels/rdpsnd/client/pulse/rdpsnd_pulse.c | 89 +-
channels/rdpsnd/client/rdpsnd_main.c | 275 +-
channels/rdpsnd/client/rdpsnd_main.h | 5 +-
channels/rdpsnd/client/winmm/rdpsnd_winmm.c | 82 +-
channels/rdpsnd/server/rdpsnd_main.c | 196 +-
channels/remdesk/client/remdesk_main.c | 234 +-
channels/remdesk/server/remdesk_main.c | 165 +-
channels/remdesk/server/remdesk_main.h | 1 -
channels/serial/client/serial_main.c | 207 +-
channels/server/channels.h | 2 -
channels/smartcard/client/smartcard_main.c | 122 +-
channels/smartcard/client/smartcard_main.h | 105 +-
.../smartcard/client/smartcard_operations.c | 332 +-
channels/smartcard/client/smartcard_pack.c | 1032 +-
channels/smartcard/client/smartcard_pack.h | 76 +-
channels/sshagent/client/sshagent_main.c | 86 +-
channels/sshagent/client/sshagent_main.h | 6 +-
channels/tsmf/client/alsa/tsmf_alsa.c | 58 +-
channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 105 +-
channels/tsmf/client/gstreamer/tsmf_X11.c | 99 +-
.../tsmf/client/gstreamer/tsmf_gstreamer.c | 560 +-
.../tsmf/client/gstreamer/tsmf_platform.h | 28 +-
channels/tsmf/client/oss/tsmf_oss.c | 20 +-
channels/tsmf/client/pulse/tsmf_pulse.c | 89 +-
channels/tsmf/client/tsmf_audio.c | 6 +-
channels/tsmf/client/tsmf_audio.h | 6 +-
channels/tsmf/client/tsmf_codec.c | 353 +-
channels/tsmf/client/tsmf_codec.h | 1 -
channels/tsmf/client/tsmf_constants.h | 172 +-
channels/tsmf/client/tsmf_decoder.c | 11 +-
channels/tsmf/client/tsmf_decoder.h | 37 +-
channels/tsmf/client/tsmf_ifman.c | 83 +-
channels/tsmf/client/tsmf_ifman.h | 1 -
channels/tsmf/client/tsmf_main.c | 136 +-
channels/tsmf/client/tsmf_main.h | 4 +-
channels/tsmf/client/tsmf_media.c | 272 +-
channels/tsmf/client/tsmf_media.h | 17 +-
channels/tsmf/client/tsmf_types.h | 6 +-
channels/urbdrc/client/data_transfer.c | 1590 +-
channels/urbdrc/client/data_transfer.h | 6 +-
channels/urbdrc/client/isoch_queue.c | 25 +-
channels/urbdrc/client/isoch_queue.h | 41 +-
.../urbdrc/client/libusb/libusb_udevice.c | 540 +-
.../urbdrc/client/libusb/libusb_udevice.h | 62 +-
.../urbdrc/client/libusb/libusb_udevman.c | 131 +-
channels/urbdrc/client/libusb/request_queue.c | 45 +-
channels/urbdrc/client/libusb/request_queue.h | 31 +-
channels/urbdrc/client/searchman.c | 30 +-
channels/urbdrc/client/searchman.h | 25 +-
channels/urbdrc/client/urbdrc_main.c | 314 +-
channels/urbdrc/client/urbdrc_main.h | 140 +-
channels/urbdrc/client/urbdrc_types.h | 415 +-
channels/video/client/video_main.c | 341 +-
channels/video/client/video_main.h | 2 -
.../afreerdp/application/GlobalApp.java | 5 +-
.../freerdpcore/application/GlobalApp.java | 277 +-
.../application/NetworkStateReceiver.java | 59 +-
.../application/ScreenReceiver.java | 27 +-
.../freerdpcore/application/SessionState.java | 170 +-
.../freerdpcore/domain/BookmarkBase.java | 1996 +-
.../domain/ConnectionReference.java | 110 +-
.../freerdpcore/domain/ManualBookmark.java | 379 +-
.../domain/PlaceholderBookmark.java | 110 +-
.../domain/QuickConnectBookmark.java | 88 +-
.../presentation/AboutActivity.java | 155 +-
.../ApplicationSettingsActivity.java | 427 +-
.../presentation/BookmarkActivity.java | 1363 +-
.../presentation/HelpActivity.java | 86 +-
.../presentation/HomeActivity.java | 562 +-
.../presentation/ScrollView2D.java | 2385 ++-
.../presentation/SessionActivity.java | 2652 +--
.../freerdpcore/presentation/SessionView.java | 594 +-
.../presentation/ShortcutsActivity.java | 219 +-
.../presentation/TouchPointerView.java | 581 +-
.../services/BookmarkBaseGateway.java | 1047 +-
.../freerdpcore/services/BookmarkDB.java | 675 +-
.../services/FreeRDPSuggestionProvider.java | 174 +-
.../freerdpcore/services/HistoryDB.java | 52 +-
.../freerdpcore/services/LibFreeRDP.java | 1094 +-
.../services/ManualBookmarkGateway.java | 176 +-
.../services/QuickConnectHistoryGateway.java | 155 +-
.../SessionRequestHandlerActivity.java | 91 +-
.../utils/AppCompatPreferenceActivity.java | 153 +-
.../utils/BookmarkArrayAdapter.java | 168 +-
.../freerdpcore/utils/ButtonPreference.java | 118 +-
.../utils/ClipboardManagerProxy.java | 139 +-
.../utils/DoubleGestureDetector.java | 560 +-
.../freerdpcore/utils/GestureDetector.java | 1011 +-
.../utils/IntEditTextPreference.java | 132 +-
.../freerdpcore/utils/IntListPreference.java | 38 +-
.../freerdpcore/utils/KeyboardMapper.java | 1232 +-
.../com/freerdp/freerdpcore/utils/Mouse.java | 77 +-
.../freerdpcore/utils/RDPFileParser.java | 142 +-
.../utils/SeparatedListAdapter.java | 286 +-
client/Android/android_cliprdr.c | 103 +-
client/Android/android_cliprdr.h | 9 +-
client/Android/android_event.c | 33 +-
client/Android/android_event.h | 19 +-
client/Android/android_freerdp.c | 363 +-
client/Android/android_freerdp.h | 7 +-
client/Android/android_freerdp_jni.h | 1 -
client/Android/android_jni_callback.c | 29 +-
client/Android/android_jni_callback.h | 11 +-
client/Android/android_jni_utils.c | 46 +-
client/Android/android_jni_utils.h | 13 +-
client/Mac/CertificateDialog.h | 46 +-
client/Mac/CertificateDialog.m | 46 +-
client/Mac/Clipboard.m | 233 +-
client/Mac/Keyboard.m | 79 +-
client/Mac/MRDPCursor.h | 12 +-
client/Mac/MRDPView.h | 90 +-
client/Mac/MRDPView.m | 617 +-
client/Mac/PasswordDialog.h | 36 +-
client/Mac/PasswordDialog.m | 58 +-
client/Mac/cli/AppDelegate.h | 14 +-
client/Mac/cli/AppDelegate.m | 153 +-
client/Mac/mf_client.h | 23 +-
client/Mac/mf_client.m | 69 +-
client/Mac/mfreerdp.h | 12 +-
client/Sample/tf_channels.c | 26 +-
client/Sample/tf_channels.h | 12 +-
client/Sample/tf_freerdp.c | 30 +-
client/Wayland/wlf_channels.c | 26 +-
client/Wayland/wlf_channels.h | 12 +-
client/Wayland/wlf_cliprdr.c | 165 +-
client/Wayland/wlf_disp.c | 11 +-
client/Wayland/wlf_input.c | 3 +-
client/Wayland/wlf_input.h | 3 +-
client/Wayland/wlf_pointer.c | 17 +-
client/Wayland/wlfreerdp.c | 55 +-
client/Wayland/wlfreerdp.h | 7 +-
client/Windows/cli/wfreerdp.c | 11 +-
client/Windows/resource.h | 22 +-
client/Windows/wf_channels.c | 27 +-
client/Windows/wf_channels.h | 6 +-
client/Windows/wf_client.c | 307 +-
client/Windows/wf_client.h | 147 +-
client/Windows/wf_cliprdr.c | 580 +-
client/Windows/wf_event.c | 421 +-
client/Windows/wf_event.h | 8 +-
client/Windows/wf_floatbar.c | 225 +-
client/Windows/wf_gdi.c | 135 +-
client/Windows/wf_gdi.h | 6 +-
client/Windows/wf_graphics.c | 79 +-
client/Windows/wf_graphics.h | 8 +-
client/Windows/wf_rail.c | 402 +-
client/X11/cli/xfreerdp.c | 2 +-
client/X11/generate_argument_docbook.c | 28 +-
client/X11/xf_channels.c | 26 +-
client/X11/xf_client.c | 314 +-
client/X11/xf_client.h | 12 +-
client/X11/xf_cliprdr.c | 337 +-
client/X11/xf_disp.c | 16 +-
client/X11/xf_event.c | 143 +-
client/X11/xf_floatbar.c | 85 +-
client/X11/xf_gdi.c | 234 +-
client/X11/xf_gfx.c | 87 +-
client/X11/xf_gfx.h | 3 +-
client/X11/xf_graphics.c | 114 +-
client/X11/xf_input.c | 39 +-
client/X11/xf_keyboard.c | 52 +-
client/X11/xf_keyboard.h | 3 +-
client/X11/xf_monitor.c | 154 +-
client/X11/xf_rail.c | 229 +-
client/X11/xf_rail.h | 10 +-
client/X11/xf_tsmf.c | 76 +-
client/X11/xf_video.c | 21 +-
client/X11/xf_video.h | 1 -
client/X11/xf_window.c | 342 +-
client/X11/xf_window.h | 34 +-
client/X11/xfreerdp.h | 1 -
client/common/client.c | 122 +-
client/common/cmdline.c | 354 +-
client/common/cmdline.h | 12 +-
client/common/compatibility.c | 232 +-
client/common/compatibility.h | 4 +-
client/common/file.c | 258 +-
client/common/test/TestClientChannels.c | 20 +-
client/common/test/TestClientCmdLine.c | 254 +-
client/common/test/TestClientRdpFile.c | 487 +-
client/iOS/Additions/OrderedDictionary.m | 25 +-
client/iOS/Additions/TSXAdditions.h | 18 +-
client/iOS/Additions/TSXAdditions.m | 271 +-
client/iOS/Additions/Toast+UIView.h | 35 +-
client/iOS/Additions/Toast+UIView.m | 526 +-
client/iOS/AppDelegate.h | 18 +-
client/iOS/AppDelegate.m | 133 +-
client/iOS/Controllers/AboutController.h | 14 +-
client/iOS/Controllers/AboutController.m | 129 +-
.../AdvancedBookmarkEditorController.h | 17 +-
.../AdvancedBookmarkEditorController.m | 506 +-
.../iOS/Controllers/AppSettingsController.h | 9 +-
.../iOS/Controllers/AppSettingsController.m | 441 +-
.../Controllers/BookmarkEditorController.h | 34 +-
.../Controllers/BookmarkEditorController.m | 415 +-
.../BookmarkGatewaySettingsController.h | 15 +-
.../BookmarkGatewaySettingsController.m | 180 +-
.../iOS/Controllers/BookmarkListController.h | 70 +-
.../iOS/Controllers/BookmarkListController.m | 1231 +-
.../Controllers/CredentialsEditorController.h | 17 +-
.../Controllers/CredentialsEditorController.m | 188 +-
.../Controllers/CredentialsInputController.h | 36 +-
.../Controllers/CredentialsInputController.m | 165 +-
client/iOS/Controllers/EditorBaseController.h | 46 +-
client/iOS/Controllers/EditorBaseController.m | 162 +-
.../Controllers/EditorSelectionController.h | 30 +-
.../Controllers/EditorSelectionController.m | 145 +-
client/iOS/Controllers/EncryptionController.h | 17 +-
client/iOS/Controllers/EncryptionController.m | 134 +-
client/iOS/Controllers/HelpController.h | 11 +-
client/iOS/Controllers/HelpController.m | 68 +-
client/iOS/Controllers/MainTabBarController.h | 13 +-
client/iOS/Controllers/MainTabBarController.m | 14 +-
.../Controllers/PerformanceEditorController.h | 19 +-
.../Controllers/PerformanceEditorController.m | 192 +-
.../Controllers/RDPSessionViewController.h | 97 +-
.../Controllers/RDPSessionViewController.m | 1354 +-
.../Controllers/ScreenSelectionController.h | 33 +-
.../Controllers/ScreenSelectionController.m | 317 +-
.../Controllers/VerifyCertificateController.h | 30 +-
.../Controllers/VerifyCertificateController.m | 79 +-
client/iOS/FreeRDP/ios_freerdp.h | 50 +-
client/iOS/FreeRDP/ios_freerdp.m | 132 +-
client/iOS/FreeRDP/ios_freerdp_events.h | 22 +-
client/iOS/FreeRDP/ios_freerdp_events.m | 128 +-
client/iOS/FreeRDP/ios_freerdp_ui.h | 29 +-
client/iOS/FreeRDP/ios_freerdp_ui.m | 150 +-
client/iOS/Misc/Reachability.h | 56 +-
client/iOS/Misc/Reachability.m | 168 +-
client/iOS/Misc/SFHFKeychainUtils.h | 19 +-
client/iOS/Misc/SFHFKeychainUtils.m | 593 +-
client/iOS/Misc/TSXTypes.h | 38 +-
client/iOS/Misc/Utils.h | 44 +-
client/iOS/Misc/Utils.m | 196 +-
client/iOS/Models/Bookmark.h | 44 +-
client/iOS/Models/Bookmark.m | 229 +-
client/iOS/Models/ConnectionParams.h | 55 +-
client/iOS/Models/ConnectionParams.m | 152 +-
client/iOS/Models/Encryptor.h | 31 +-
client/iOS/Models/Encryptor.m | 178 +-
client/iOS/Models/GlobalDefaults.h | 29 +-
client/iOS/Models/GlobalDefaults.m | 29 +-
client/iOS/Models/RDPKeyboard.h | 48 +-
client/iOS/Models/RDPKeyboard.m | 296 +-
client/iOS/Models/RDPSession.h | 107 +-
client/iOS/Models/RDPSession.m | 173 +-
client/iOS/Views/AdvancedKeyboardView.h | 50 +-
client/iOS/Views/AdvancedKeyboardView.m | 535 +-
client/iOS/Views/BlockAlertView.h | 25 +-
client/iOS/Views/BlockAlertView.m | 736 +-
client/iOS/Views/BlockBackground.h | 13 +-
client/iOS/Views/BlockBackground.m | 319 +-
client/iOS/Views/BlockUI.h | 82 +-
client/iOS/Views/BookmarkTableCell.h | 25 +-
client/iOS/Views/BookmarkTableCell.m | 37 +-
client/iOS/Views/EditButtonTableViewCell.h | 17 +-
client/iOS/Views/EditButtonTableViewCell.m | 24 +-
client/iOS/Views/EditFlagTableViewCell.h | 17 +-
client/iOS/Views/EditFlagTableViewCell.m | 24 +-
.../iOS/Views/EditSecretTextTableViewCell.h | 19 +-
.../iOS/Views/EditSecretTextTableViewCell.m | 63 +-
client/iOS/Views/EditSelectionTableViewCell.h | 17 +-
client/iOS/Views/EditSelectionTableViewCell.m | 24 +-
client/iOS/Views/EditSubEditTableViewCell.h | 13 +-
client/iOS/Views/EditSubEditTableViewCell.m | 24 +-
client/iOS/Views/EditTextTableViewCell.h | 17 +-
client/iOS/Views/EditTextTableViewCell.m | 24 +-
client/iOS/Views/RDPSessionView.h | 13 +-
client/iOS/Views/RDPSessionView.m | 55 +-
client/iOS/Views/SessionTableCell.h | 32 +-
client/iOS/Views/SessionTableCell.m | 46 +-
client/iOS/Views/TouchPointerView.h | 82 +-
client/iOS/Views/TouchPointerView.m | 473 +-
client/iOS/main.m | 19 +-
include/freerdp/addin.h | 55 +-
include/freerdp/altsec.h | 60 +-
include/freerdp/api.h | 31 +-
include/freerdp/assistance.h | 45 +-
include/freerdp/autodetect.h | 21 +-
include/freerdp/cache/bitmap.h | 23 +-
include/freerdp/cache/brush.h | 29 +-
include/freerdp/cache/cache.h | 19 +-
include/freerdp/cache/glyph.h | 9 +-
include/freerdp/cache/nine_grid.h | 17 +-
include/freerdp/cache/offscreen.h | 18 +-
include/freerdp/cache/palette.h | 11 +-
include/freerdp/cache/pointer.h | 11 +-
include/freerdp/channels/audin.h | 3 -
include/freerdp/channels/channels.h | 39 +-
include/freerdp/channels/cliprdr.h | 78 +-
include/freerdp/channels/disp.h | 32 +-
include/freerdp/channels/encomsp.h | 54 +-
include/freerdp/channels/geometry.h | 7 +-
include/freerdp/channels/rail.h | 3 -
include/freerdp/channels/rdpdr.h | 148 +-
include/freerdp/channels/rdpei.h | 33 +-
include/freerdp/channels/rdpgfx.h | 141 +-
include/freerdp/channels/rdpsnd.h | 1 -
include/freerdp/channels/remdesk.h | 127 +-
include/freerdp/channels/tsmf.h | 2 +-
include/freerdp/channels/video.h | 24 +-
include/freerdp/channels/wtsvc.h | 56 +-
include/freerdp/client.h | 153 +-
include/freerdp/client/audin.h | 5 +-
include/freerdp/client/channels.h | 17 +-
include/freerdp/client/cliprdr.h | 65 +-
include/freerdp/client/cmdline.h | 46 +-
include/freerdp/client/disp.h | 9 +-
include/freerdp/client/drdynvc.h | 16 +-
include/freerdp/client/encomsp.h | 34 +-
include/freerdp/client/file.h | 50 +-
include/freerdp/client/geometry.h | 20 +-
include/freerdp/client/rail.h | 105 +-
include/freerdp/client/rdpei.h | 9 +-
include/freerdp/client/rdpgfx.h | 123 +-
include/freerdp/client/rdpsnd.h | 2 +-
include/freerdp/client/remdesk.h | 1 -
include/freerdp/client/sshagent.h | 11 +-
include/freerdp/client/tsmf.h | 4 +-
include/freerdp/client/video.h | 19 +-
include/freerdp/codec/audio.h | 281 +-
include/freerdp/codec/bitmap.h | 8 +-
include/freerdp/codec/bulk.h | 15 +-
include/freerdp/codec/clear.h | 24 +-
include/freerdp/codec/color.h | 1682 +-
include/freerdp/codec/dsp.h | 26 +-
include/freerdp/codec/h264.h | 55 +-
include/freerdp/codec/interleaved.h | 38 +-
include/freerdp/codec/jpeg.h | 8 +-
include/freerdp/codec/mppc.h | 17 +-
include/freerdp/codec/ncrush.h | 16 +-
include/freerdp/codec/nsc.h | 18 +-
include/freerdp/codec/planar.h | 47 +-
include/freerdp/codec/progressive.h | 32 +-
include/freerdp/codec/region.h | 199 +-
include/freerdp/codec/rfx.h | 275 +-
include/freerdp/codec/xcrush.h | 16 +-
include/freerdp/codec/yuv.h | 16 +-
include/freerdp/codec/zgfx.h | 31 +-
include/freerdp/codecs.h | 38 +-
include/freerdp/constants.h | 32 +-
include/freerdp/crypto/ber.h | 93 +-
include/freerdp/crypto/certificate.h | 41 +-
include/freerdp/crypto/crypto.h | 95 +-
include/freerdp/crypto/der.h | 23 +-
include/freerdp/crypto/er.h | 102 +-
include/freerdp/crypto/per.h | 49 +-
include/freerdp/crypto/tls.h | 71 +-
include/freerdp/display.h | 7 +-
include/freerdp/dvc.h | 57 +-
include/freerdp/error.h | 447 +-
include/freerdp/event.h | 155 +-
include/freerdp/extension.h | 18 +-
include/freerdp/freerdp.h | 739 +-
include/freerdp/gdi/bitmap.h | 34 +-
include/freerdp/gdi/dc.h | 17 +-
include/freerdp/gdi/gdi.h | 640 +-
include/freerdp/gdi/gfx.h | 16 +-
include/freerdp/gdi/pen.h | 11 +-
include/freerdp/gdi/region.h | 60 +-
include/freerdp/gdi/shape.h | 20 +-
include/freerdp/gdi/video.h | 1 -
include/freerdp/graphics.h | 234 +-
include/freerdp/input.h | 84 +-
include/freerdp/license.h | 135 +-
include/freerdp/listener.h | 60 +-
include/freerdp/locale/keyboard.h | 330 +-
include/freerdp/locale/locale.h | 409 +-
include/freerdp/message.h | 516 +-
include/freerdp/metrics.h | 13 +-
include/freerdp/peer.h | 33 +-
include/freerdp/pointer.h | 38 +-
include/freerdp/primary.h | 86 +-
include/freerdp/primitives.h | 277 +-
include/freerdp/rail.h | 425 +-
include/freerdp/scancode.h | 345 +-
include/freerdp/secondary.h | 95 +-
include/freerdp/server/audin.h | 20 +-
include/freerdp/server/channels.h | 1 -
include/freerdp/server/cliprdr.h | 72 +-
include/freerdp/server/disp.h | 17 +-
include/freerdp/server/drdynvc.h | 9 +-
include/freerdp/server/echo.h | 16 +-
include/freerdp/server/encomsp.h | 43 +-
include/freerdp/server/rdpdr.h | 75 +-
include/freerdp/server/rdpei.h | 32 +-
include/freerdp/server/rdpgfx.h | 105 +-
include/freerdp/server/rdpsnd.h | 36 +-
include/freerdp/server/remdesk.h | 10 +-
include/freerdp/server/shadow.h | 121 +-
include/freerdp/session.h | 18 +-
include/freerdp/settings.h | 1998 +-
include/freerdp/svc.h | 28 +-
include/freerdp/types.h | 4 +-
include/freerdp/update.h | 60 +-
include/freerdp/utils/msusb.h | 165 +-
include/freerdp/utils/passphrase.h | 6 +-
include/freerdp/utils/pcap.h | 39 +-
include/freerdp/utils/profiler.h | 80 +-
include/freerdp/utils/ringbuffer.h | 142 +-
include/freerdp/utils/signal.h | 5 +-
include/freerdp/utils/stopwatch.h | 18 +-
include/freerdp/window.h | 216 +-
libfreerdp/cache/bitmap.c | 116 +-
libfreerdp/cache/bitmap.h | 6 +-
libfreerdp/cache/brush.c | 30 +-
libfreerdp/cache/brush.h | 2 +-
libfreerdp/cache/cache.c | 12 +-
libfreerdp/cache/cache.h | 8 +-
libfreerdp/cache/glyph.c | 184 +-
libfreerdp/cache/glyph.h | 4 +-
libfreerdp/cache/nine_grid.c | 18 +-
libfreerdp/cache/offscreen.c | 32 +-
libfreerdp/cache/palette.c | 18 +-
libfreerdp/cache/palette.h | 2 +-
libfreerdp/cache/pointer.c | 71 +-
libfreerdp/cache/pointer.h | 21 +-
libfreerdp/codec/audio.c | 32 +-
libfreerdp/codec/bitmap.c | 272 +-
libfreerdp/codec/clear.c | 416 +-
libfreerdp/codec/color.c | 349 +-
libfreerdp/codec/dsp.c | 188 +-
libfreerdp/codec/dsp_ffmpeg.c | 61 +-
libfreerdp/codec/dsp_ffmpeg.h | 15 +-
libfreerdp/codec/h264.c | 144 +-
libfreerdp/codec/h264.h | 5 +-
libfreerdp/codec/h264_ffmpeg.c | 93 +-
libfreerdp/codec/h264_mf.c | 281 +-
libfreerdp/codec/h264_openh264.c | 177 +-
libfreerdp/codec/h264_x264.c | 54 +-
libfreerdp/codec/include/bitmap.c | 54 +-
libfreerdp/codec/interleaved.c | 167 +-
libfreerdp/codec/jpeg.c | 18 +-
libfreerdp/codec/mppc.c | 38 +-
libfreerdp/codec/ncrush.c | 1688 +-
libfreerdp/codec/nsc.c | 103 +-
libfreerdp/codec/nsc_encode.c | 120 +-
libfreerdp/codec/nsc_encode.h | 3 +-
libfreerdp/codec/nsc_sse2.c | 253 +-
libfreerdp/codec/nsc_types.h | 44 +-
libfreerdp/codec/progressive.c | 663 +-
libfreerdp/codec/progressive.h | 23 +-
libfreerdp/codec/region.c | 88 +-
libfreerdp/codec/rfx.c | 464 +-
libfreerdp/codec/rfx_bitstream.h | 122 +-
libfreerdp/codec/rfx_constants.h | 41 +-
libfreerdp/codec/rfx_decode.c | 21 +-
libfreerdp/codec/rfx_decode.h | 5 +-
libfreerdp/codec/rfx_dwt.c | 27 +-
libfreerdp/codec/rfx_encode.c | 55 +-
libfreerdp/codec/rfx_encode.h | 1 -
libfreerdp/codec/rfx_neon.c | 32 +-
libfreerdp/codec/rfx_neon.h | 1 -
libfreerdp/codec/rfx_quantization.c | 35 +-
libfreerdp/codec/rfx_quantization.h | 10 +-
libfreerdp/codec/rfx_rlgr.c | 161 +-
libfreerdp/codec/rfx_rlgr.h | 4 +-
libfreerdp/codec/rfx_sse2.c | 129 +-
libfreerdp/codec/rfx_types.h | 5 +-
libfreerdp/codec/test/TestFreeRDPCodecClear.c | 29 +-
.../codec/test/TestFreeRDPCodecInterleaved.c | 32 +-
libfreerdp/codec/test/TestFreeRDPCodecMppc.c | 77 +-
.../codec/test/TestFreeRDPCodecNCrush.c | 14 +-
.../codec/test/TestFreeRDPCodecPlanar.c | 7941 ++++---
.../codec/test/TestFreeRDPCodecProgressive.c | 511 +-
.../codec/test/TestFreeRDPCodecRemoteFX.c | 1126 +-
.../codec/test/TestFreeRDPCodecXCrush.c | 36 +-
libfreerdp/codec/test/TestFreeRDPCodecZGfx.c | 38 +-
libfreerdp/codec/test/TestFreeRDPRegion.c | 240 +-
libfreerdp/codec/xcrush.c | 93 +-
libfreerdp/codec/yuv.c | 31 +-
libfreerdp/codec/zgfx.c | 111 +-
libfreerdp/common/addin.c | 53 +-
libfreerdp/common/assistance.c | 200 +-
libfreerdp/common/settings.c | 97 +-
libfreerdp/common/settings_getters.c | 36 +-
libfreerdp/common/test/TestCommonAssistance.c | 33 +-
libfreerdp/core/activation.c | 80 +-
libfreerdp/core/activation.h | 24 +-
libfreerdp/core/autodetect.c | 195 +-
libfreerdp/core/autodetect.h | 25 +-
libfreerdp/core/bulk.c | 45 +-
libfreerdp/core/bulk.h | 12 +-
libfreerdp/core/capabilities.c | 1408 +-
libfreerdp/core/capabilities.h | 185 +-
libfreerdp/core/certificate.c | 146 +-
libfreerdp/core/certificate.h | 30 +-
libfreerdp/core/channels.c | 144 +-
libfreerdp/core/channels.h | 9 +-
libfreerdp/core/client.c | 221 +-
libfreerdp/core/client.h | 12 +-
libfreerdp/core/codecs.c | 9 +-
libfreerdp/core/connection.c | 224 +-
libfreerdp/core/connection.h | 15 +-
libfreerdp/core/display.c | 21 +-
libfreerdp/core/display.h | 3 +-
libfreerdp/core/errbase.c | 13 +-
libfreerdp/core/errconnect.c | 75 +-
libfreerdp/core/errinfo.c | 459 +-
libfreerdp/core/fastpath.c | 211 +-
libfreerdp/core/fastpath.h | 21 +-
libfreerdp/core/freerdp.c | 135 +-
libfreerdp/core/gateway/http.c | 38 +-
libfreerdp/core/gateway/http.h | 39 +-
libfreerdp/core/gateway/ncacn_http.c | 22 +-
libfreerdp/core/gateway/ncacn_http.h | 6 +-
libfreerdp/core/gateway/ntlm.c | 80 +-
libfreerdp/core/gateway/ntlm.h | 11 +-
libfreerdp/core/gateway/rdg.c | 283 +-
libfreerdp/core/gateway/rdg.h | 5 +-
libfreerdp/core/gateway/rpc.c | 121 +-
libfreerdp/core/gateway/rpc.h | 268 +-
libfreerdp/core/gateway/rpc_bind.c | 105 +-
libfreerdp/core/gateway/rpc_bind.h | 9 +-
libfreerdp/core/gateway/rpc_client.c | 125 +-
libfreerdp/core/gateway/rpc_client.h | 9 +-
libfreerdp/core/gateway/rpc_fault.c | 387 +-
libfreerdp/core/gateway/rts.c | 210 +-
libfreerdp/core/gateway/rts.h | 95 +-
libfreerdp/core/gateway/rts_signature.c | 335 +-
libfreerdp/core/gateway/rts_signature.h | 131 +-
libfreerdp/core/gateway/tsg.c | 765 +-
libfreerdp/core/gateway/tsg.h | 114 +-
libfreerdp/core/gcc.c | 453 +-
libfreerdp/core/gcc.h | 64 +-
libfreerdp/core/graphics.c | 26 +-
libfreerdp/core/heartbeat.c | 15 +-
libfreerdp/core/info.c | 274 +-
libfreerdp/core/info.h | 46 +-
libfreerdp/core/input.c | 97 +-
libfreerdp/core/license.c | 411 +-
libfreerdp/core/license.h | 9 +-
libfreerdp/core/listener.c | 62 +-
libfreerdp/core/listener.h | 7 +-
libfreerdp/core/mcs.c | 113 +-
libfreerdp/core/message.c | 1216 +-
libfreerdp/core/message.h | 9 +-
libfreerdp/core/metrics.c | 7 +-
libfreerdp/core/multitransport.c | 6 +-
libfreerdp/core/nego.c | 107 +-
libfreerdp/core/nego.h | 66 +-
libfreerdp/core/nla.c | 448 +-
libfreerdp/core/nla.h | 6 +-
libfreerdp/core/orders.c | 1462 +-
libfreerdp/core/orders.h | 399 +-
libfreerdp/core/peer.c | 168 +-
libfreerdp/core/peer.h | 1 -
libfreerdp/core/proxy.c | 59 +-
libfreerdp/core/proxy.h | 6 +-
libfreerdp/core/rdp.c | 269 +-
libfreerdp/core/rdp.h | 177 +-
libfreerdp/core/redirection.c | 59 +-
libfreerdp/core/redirection.h | 8 +-
libfreerdp/core/security.c | 255 +-
libfreerdp/core/security.h | 41 +-
libfreerdp/core/server.c | 410 +-
libfreerdp/core/server.h | 304 +-
libfreerdp/core/settings.c | 379 +-
libfreerdp/core/surface.c | 14 +-
libfreerdp/core/surface.h | 8 +-
libfreerdp/core/tcp.c | 145 +-
libfreerdp/core/tcp.h | 43 +-
libfreerdp/core/test/TestConnect.c | 32 +-
libfreerdp/core/test/TestSettings.c | 1 -
libfreerdp/core/test/TestVersion.c | 1 -
.../core/test/settings_property_lists.h | 22 +-
libfreerdp/core/timezone.c | 48 +-
libfreerdp/core/timezone.h | 8 +-
libfreerdp/core/tpdu.c | 15 +-
libfreerdp/core/tpdu.h | 16 +-
libfreerdp/core/tpkt.c | 4 +-
libfreerdp/core/tpkt.h | 2 +-
libfreerdp/core/transport.c | 162 +-
libfreerdp/core/transport.h | 30 +-
libfreerdp/core/update.c | 511 +-
libfreerdp/core/update.h | 14 +-
libfreerdp/core/window.c | 239 +-
libfreerdp/core/window.h | 8 +-
libfreerdp/crypto/base64.c | 38 +-
libfreerdp/crypto/ber.c | 32 +-
libfreerdp/crypto/certificate.c | 159 +-
libfreerdp/crypto/crypto.c | 117 +-
libfreerdp/crypto/der.c | 1 -
libfreerdp/crypto/er.c | 6 +-
libfreerdp/crypto/opensslcompat.h | 36 +-
libfreerdp/crypto/per.c | 15 +-
libfreerdp/crypto/test/TestBase64.c | 25 +-
libfreerdp/crypto/test/TestKnownHosts.c | 37 +-
libfreerdp/crypto/test/Test_x509_cert_info.c | 92 +-
libfreerdp/crypto/tls.c | 244 +-
libfreerdp/gdi/bitmap.c | 134 +-
libfreerdp/gdi/brush.c | 27 +-
libfreerdp/gdi/brush.h | 23 +-
libfreerdp/gdi/clipping.c | 12 +-
libfreerdp/gdi/clipping.h | 15 +-
libfreerdp/gdi/dc.c | 30 +-
libfreerdp/gdi/drawing.c | 1 -
libfreerdp/gdi/drawing.h | 17 +-
libfreerdp/gdi/gdi.c | 904 +-
libfreerdp/gdi/gdi.h | 44 +-
libfreerdp/gdi/gfx.c | 332 +-
libfreerdp/gdi/graphics.c | 110 +-
libfreerdp/gdi/graphics.h | 5 +-
libfreerdp/gdi/line.c | 5 +-
libfreerdp/gdi/line.h | 16 +-
libfreerdp/gdi/pen.c | 6 +-
libfreerdp/gdi/region.c | 66 +-
libfreerdp/gdi/shape.c | 38 +-
libfreerdp/gdi/test/TestGdiBitBlt.c | 199 +-
libfreerdp/gdi/test/TestGdiClip.c | 21 +-
libfreerdp/gdi/test/TestGdiCreate.c | 67 +-
libfreerdp/gdi/test/TestGdiEllipse.c | 61 +-
libfreerdp/gdi/test/TestGdiLine.c | 192 +-
libfreerdp/gdi/test/TestGdiRect.c | 10 +-
libfreerdp/gdi/test/TestGdiRop3.c | 48 +-
libfreerdp/gdi/test/helpers.c | 25 +-
libfreerdp/gdi/test/helpers.h | 10 +-
libfreerdp/gdi/video.c | 29 +-
libfreerdp/locale/keyboard.c | 19 +-
libfreerdp/locale/keyboard_layout.c | 321 +-
libfreerdp/locale/keyboard_sun.c | 295 +-
libfreerdp/locale/keyboard_x11.c | 7 +-
libfreerdp/locale/keyboard_x11.h | 3 +-
libfreerdp/locale/keyboard_xkbfile.c | 327 +-
libfreerdp/locale/keyboard_xkbfile.h | 7 +-
libfreerdp/locale/liblocale.h | 10 +-
libfreerdp/locale/locale.c | 749 +-
libfreerdp/locale/xkb_layout_ids.c | 1223 +-
libfreerdp/locale/xkb_layout_ids.h | 3 +-
libfreerdp/primitives/prim_YCoCg.c | 24 +-
libfreerdp/primitives/prim_YCoCg_opt.c | 212 +-
libfreerdp/primitives/prim_YUV.c | 298 +-
libfreerdp/primitives/prim_YUV_neon.c | 112 +-
libfreerdp/primitives/prim_YUV_ssse3.c | 491 +-
libfreerdp/primitives/prim_add.c | 18 +-
libfreerdp/primitives/prim_add_opt.c | 17 +-
libfreerdp/primitives/prim_alphaComp.c | 27 +-
libfreerdp/primitives/prim_alphaComp_opt.c | 63 +-
libfreerdp/primitives/prim_andor.c | 17 +-
libfreerdp/primitives/prim_andor_opt.c | 23 +-
libfreerdp/primitives/prim_colors.c | 158 +-
libfreerdp/primitives/prim_colors_opt.c | 600 +-
libfreerdp/primitives/prim_copy.c | 93 +-
libfreerdp/primitives/prim_internal.h | 40 +-
libfreerdp/primitives/prim_set.c | 47 +-
libfreerdp/primitives/prim_set_opt.c | 149 +-
libfreerdp/primitives/prim_shift.c | 87 +-
libfreerdp/primitives/prim_shift_opt.c | 34 +-
libfreerdp/primitives/prim_sign.c | 8 +-
libfreerdp/primitives/prim_sign_opt.c | 63 +-
libfreerdp/primitives/prim_templates.h | 749 +-
libfreerdp/primitives/primitives.c | 2 -
.../primitives/test/TestPrimitivesAdd.c | 12 +-
.../primitives/test/TestPrimitivesAlphaComp.c | 75 +-
.../primitives/test/TestPrimitivesAndOr.c | 49 +-
.../primitives/test/TestPrimitivesColors.c | 57 +-
.../primitives/test/TestPrimitivesCopy.c | 21 +-
.../primitives/test/TestPrimitivesSet.c | 27 +-
.../primitives/test/TestPrimitivesShift.c | 48 +-
.../primitives/test/TestPrimitivesSign.c | 12 +-
.../primitives/test/TestPrimitivesYCbCr.c | 2578 +--
.../primitives/test/TestPrimitivesYCoCg.c | 33 +-
.../primitives/test/TestPrimitivesYUV.c | 112 +-
libfreerdp/primitives/test/measure.h | 121 +-
libfreerdp/primitives/test/prim_test.c | 45 +-
libfreerdp/primitives/test/prim_test.h | 5 +-
libfreerdp/utils/msusb.c | 130 +-
libfreerdp/utils/passphrase.c | 36 +-
libfreerdp/utils/pcap.c | 23 +-
libfreerdp/utils/profiler.c | 18 +-
libfreerdp/utils/ringbuffer.c | 30 +-
libfreerdp/utils/signal.c | 38 +-
libfreerdp/utils/stopwatch.c | 12 +-
libfreerdp/utils/test/TestRingBuffer.c | 35 +-
rdtk/include/rdtk/api.h | 36 +-
rdtk/include/rdtk/rdtk.h | 44 +-
rdtk/librdtk/rdtk_button.c | 5 +-
rdtk/librdtk/rdtk_button.h | 12 +-
rdtk/librdtk/rdtk_engine.c | 2 +-
rdtk/librdtk/rdtk_engine.h | 6 +-
rdtk/librdtk/rdtk_font.c | 33 +-
rdtk/librdtk/rdtk_font.h | 14 +-
rdtk/librdtk/rdtk_label.c | 4 +-
rdtk/librdtk/rdtk_label.h | 12 +-
rdtk/librdtk/rdtk_nine_patch.c | 54 +-
rdtk/librdtk/rdtk_nine_patch.h | 17 +-
rdtk/librdtk/rdtk_resources.c | 2220 +-
rdtk/librdtk/rdtk_resources.h | 6 +-
rdtk/librdtk/rdtk_surface.c | 9 +-
rdtk/librdtk/rdtk_surface.h | 1 -
rdtk/librdtk/rdtk_text_field.c | 4 +-
rdtk/librdtk/rdtk_text_field.h | 12 +-
rdtk/librdtk/test/TestRdTkNinePatch.c | 11 +-
rdtk/sample/rdtk_x11.c | 13 +-
resources/FreeRDP_Icon_256px.h | 17558 ++++++++--------
scripts/LECHash.c | 61 +-
scripts/LOMHash.c | 22 +-
server/Mac/mf_audin.c | 2 +-
server/Mac/mf_audin.h | 2 -
server/Mac/mf_event.c | 81 +-
server/Mac/mf_event.h | 2 +-
server/Mac/mf_info.c | 76 +-
server/Mac/mf_info.h | 5 +-
server/Mac/mf_input.c | 544 +-
server/Mac/mf_input.h | 2 +-
server/Mac/mf_interface.h | 19 +-
server/Mac/mf_mountain_lion.c | 267 +-
server/Mac/mf_mountain_lion.h | 3 +-
server/Mac/mf_peer.c | 79 +-
server/Mac/mf_rdpsnd.c | 84 +-
server/Mac/mf_rdpsnd.h | 38 +-
server/Mac/mfreerdp.c | 8 +-
server/Sample/sf_audin.c | 11 +-
server/Sample/sf_audin.h | 1 -
server/Sample/sf_rdpsnd.c | 4 +-
server/Sample/sf_rdpsnd.h | 1 -
server/Sample/sfreerdp.c | 156 +-
server/Sample/sfreerdp.h | 1 -
server/Windows/cli/wfreerdp.c | 11 +-
server/Windows/wf_directsound.c | 43 +-
server/Windows/wf_dxgi.c | 91 +-
server/Windows/wf_dxgi.h | 1 -
server/Windows/wf_info.c | 82 +-
server/Windows/wf_info.h | 3 +-
server/Windows/wf_input.c | 20 +-
server/Windows/wf_input.h | 2 +-
server/Windows/wf_interface.c | 24 +-
server/Windows/wf_interface.h | 44 +-
server/Windows/wf_mirage.c | 44 +-
server/Windows/wf_mirage.h | 52 +-
server/Windows/wf_peer.c | 83 +-
server/Windows/wf_rdpsnd.c | 11 +-
server/Windows/wf_rdpsnd.h | 2 -
server/Windows/wf_settings.c | 10 +-
server/Windows/wf_update.c | 80 +-
server/Windows/wf_wasapi.c | 94 +-
server/Windows/wf_wasapi.h | 2 +-
server/common/server.c | 90 +-
server/proxy/freerdp_proxy.c | 1 -
server/proxy/modules/demo/demo.c | 6 +-
server/proxy/pf_capture.c | 30 +-
server/proxy/pf_channels.c | 27 +-
server/proxy/pf_channels.h | 6 +-
server/proxy/pf_client.c | 54 +-
server/proxy/pf_cliprdr.c | 135 +-
server/proxy/pf_cliprdr.h | 3 +-
server/proxy/pf_config.c | 19 +-
server/proxy/pf_config.h | 6 +-
server/proxy/pf_context.c | 54 +-
server/proxy/pf_context.h | 7 +-
server/proxy/pf_disp.c | 17 +-
server/proxy/pf_disp.h | 2 +-
server/proxy/pf_gdi.c | 20 +-
server/proxy/pf_graphics.c | 21 +-
server/proxy/pf_input.c | 3 +-
server/proxy/pf_modules.c | 32 +-
server/proxy/pf_rdpgfx.c | 130 +-
server/proxy/pf_server.c | 63 +-
server/proxy/pf_update.c | 43 +-
server/shadow/Mac/mac_shadow.c | 293 +-
server/shadow/Mac/mac_shadow.h | 5 +-
server/shadow/Win/win_dxgi.c | 348 +-
server/shadow/Win/win_dxgi.h | 15 +-
server/shadow/Win/win_rdp.c | 71 +-
server/shadow/Win/win_rdp.h | 11 +-
server/shadow/Win/win_shadow.c | 60 +-
server/shadow/Win/win_shadow.h | 5 +-
server/shadow/Win/win_wds.c | 331 +-
server/shadow/Win/win_wds.h | 11 +-
server/shadow/X11/x11_shadow.c | 177 +-
server/shadow/X11/x11_shadow.h | 5 +-
server/shadow/shadow.c | 3 +-
server/shadow/shadow.h | 6 +-
server/shadow/shadow_audin.c | 2 +-
server/shadow/shadow_audin.h | 7 +-
server/shadow/shadow_capture.c | 13 +-
server/shadow/shadow_capture.h | 7 +-
server/shadow/shadow_channels.h | 7 +-
server/shadow/shadow_client.c | 470 +-
server/shadow/shadow_client.h | 7 +-
server/shadow/shadow_encoder.c | 61 +-
server/shadow/shadow_encoder.h | 13 +-
server/shadow/shadow_encomsp.c | 17 +-
server/shadow/shadow_encomsp.h | 7 +-
server/shadow/shadow_input.c | 13 +-
server/shadow/shadow_input.h | 5 +-
server/shadow/shadow_lobby.c | 10 +-
server/shadow/shadow_lobby.h | 5 +-
server/shadow/shadow_mcevent.c | 37 +-
server/shadow/shadow_mcevent.h | 27 +-
server/shadow/shadow_rdpgfx.h | 7 +-
server/shadow/shadow_rdpsnd.h | 7 +-
server/shadow/shadow_remdesk.c | 5 +-
server/shadow/shadow_remdesk.h | 7 +-
server/shadow/shadow_screen.c | 8 +-
server/shadow/shadow_screen.h | 7 +-
server/shadow/shadow_server.c | 145 +-
server/shadow/shadow_subsystem.c | 28 +-
server/shadow/shadow_subsystem.h | 16 +-
server/shadow/shadow_subsystem_builtin.c | 3 +-
server/shadow/shadow_surface.c | 16 +-
server/shadow/shadow_surface.h | 10 +-
uwac/include/uwac/uwac-tools.h | 10 +-
uwac/include/uwac/uwac.h | 580 +-
uwac/libuwac/uwac-clipboard.c | 36 +-
uwac/libuwac/uwac-display.c | 115 +-
uwac/libuwac/uwac-input.c | 473 +-
uwac/libuwac/uwac-os.c | 3 +-
uwac/libuwac/uwac-os.h | 2 +-
uwac/libuwac/uwac-output.c | 76 +-
uwac/libuwac/uwac-priv.h | 153 +-
uwac/libuwac/uwac-tools.c | 101 +-
uwac/libuwac/uwac-utils.c | 20 +-
uwac/libuwac/uwac-utils.h | 33 +-
uwac/libuwac/uwac-window.c | 128 +-
winpr/include/winpr/asn1.h | 953 +-
winpr/include/winpr/bcrypt.h | 161 +-
winpr/include/winpr/bitstream.h | 217 +-
winpr/include/winpr/clipboard.h | 67 +-
winpr/include/winpr/cmdline.h | 132 +-
winpr/include/winpr/collections.h | 968 +-
winpr/include/winpr/comm.h | 725 +-
winpr/include/winpr/credentials.h | 245 +-
winpr/include/winpr/credui.h | 150 +-
winpr/include/winpr/crt.h | 72 +-
winpr/include/winpr/crypto.h | 992 +-
winpr/include/winpr/debug.h | 18 +-
winpr/include/winpr/dsparse.h | 37 +-
winpr/include/winpr/endian.h | 221 +-
winpr/include/winpr/environment.h | 117 +-
winpr/include/winpr/error.h | 5812 ++---
winpr/include/winpr/file.h | 589 +-
winpr/include/winpr/handle.h | 35 +-
winpr/include/winpr/heap.h | 20 +-
winpr/include/winpr/image.h | 20 +-
winpr/include/winpr/ini.h | 31 +-
winpr/include/winpr/input.h | 1420 +-
winpr/include/winpr/interlocked.h | 202 +-
winpr/include/winpr/intrin.h | 46 +-
winpr/include/winpr/io.h | 244 +-
winpr/include/winpr/library.h | 79 +-
winpr/include/winpr/locale.h | 855 +-
winpr/include/winpr/memory.h | 40 +-
winpr/include/winpr/midl.h | 7 +-
winpr/include/winpr/ndr.h | 337 +-
winpr/include/winpr/nt.h | 2510 +--
winpr/include/winpr/ntlm.h | 45 +-
winpr/include/winpr/pack.h | 73 +-
winpr/include/winpr/path.h | 395 +-
winpr/include/winpr/pipe.h | 112 +-
winpr/include/winpr/platform.h | 88 +-
winpr/include/winpr/pool.h | 183 +-
winpr/include/winpr/print.h | 21 +-
winpr/include/winpr/registry.h | 385 +-
winpr/include/winpr/rpc.h | 841 +-
winpr/include/winpr/sam.h | 18 +-
winpr/include/winpr/schannel.h | 248 +-
winpr/include/winpr/security.h | 220 +-
winpr/include/winpr/shell.h | 46 +-
winpr/include/winpr/smartcard.h | 1207 +-
winpr/include/winpr/spec.h | 211 +-
winpr/include/winpr/ssl.h | 16 +-
winpr/include/winpr/sspi.h | 970 +-
winpr/include/winpr/sspicli.h | 83 +-
winpr/include/winpr/stream.h | 566 +-
winpr/include/winpr/string.h | 189 +-
winpr/include/winpr/strlst.h | 12 +-
winpr/include/winpr/synch.h | 477 +-
winpr/include/winpr/sysinfo.h | 484 +-
winpr/include/winpr/tchar.h | 48 +-
winpr/include/winpr/thread.h | 297 +-
winpr/include/winpr/timezone.h | 98 +-
winpr/include/winpr/tools/makecert.h | 17 +-
winpr/include/winpr/user.h | 142 +-
winpr/include/winpr/windows.h | 98 +-
winpr/include/winpr/winhttp.h | 907 +-
winpr/include/winpr/winpr.h | 11 +-
winpr/include/winpr/winsock.h | 310 +-
winpr/include/winpr/wlog.h | 255 +-
winpr/include/winpr/wnd.h | 780 +-
winpr/include/winpr/wtsapi.h | 1149 +-
winpr/libwinpr/asn1/asn1.c | 51 +-
winpr/libwinpr/asn1/test/TestAsn1BerDec.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1BerEnc.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Compare.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Decode.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Decoder.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1DerDec.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1DerEnc.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Encode.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Encoder.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Integer.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1Module.c | 1 -
winpr/libwinpr/asn1/test/TestAsn1String.c | 1 -
winpr/libwinpr/bcrypt/bcrypt.c | 35 +-
winpr/libwinpr/clipboard/clipboard.c | 88 +-
winpr/libwinpr/clipboard/posix.c | 47 +-
winpr/libwinpr/clipboard/synthetic.c | 141 +-
.../clipboard/test/TestClipboardFormats.c | 14 +-
winpr/libwinpr/com/com.c | 1 -
winpr/libwinpr/com/test/TestComReference.c | 1 -
winpr/libwinpr/comm/comm.c | 218 +-
winpr/libwinpr/comm/comm.h | 35 +-
winpr/libwinpr/comm/comm_io.c | 124 +-
winpr/libwinpr/comm/comm_ioctl.c | 115 +-
winpr/libwinpr/comm/comm_ioctl.h | 332 +-
winpr/libwinpr/comm/comm_sercx2_sys.c | 120 +-
winpr/libwinpr/comm/comm_sercx2_sys.h | 5 +-
winpr/libwinpr/comm/comm_sercx_sys.c | 152 +-
winpr/libwinpr/comm/comm_sercx_sys.h | 7 +-
winpr/libwinpr/comm/comm_serial_sys.c | 511 +-
winpr/libwinpr/comm/comm_serial_sys.h | 6 +-
winpr/libwinpr/comm/test/TestCommConfig.c | 47 +-
winpr/libwinpr/comm/test/TestCommDevice.c | 28 +-
winpr/libwinpr/comm/test/TestCommMonitor.c | 12 +-
.../libwinpr/comm/test/TestControlSettings.c | 8 +-
winpr/libwinpr/comm/test/TestGetCommState.c | 11 +-
winpr/libwinpr/comm/test/TestHandflow.c | 6 +-
winpr/libwinpr/comm/test/TestSerialChars.c | 24 +-
winpr/libwinpr/comm/test/TestSetCommState.c | 38 +-
winpr/libwinpr/comm/test/TestTimeouts.c | 27 +-
winpr/libwinpr/credentials/credentials.c | 42 +-
winpr/libwinpr/credui/credui.c | 30 +-
.../TestCredUICmdLinePromptForCredentials.c | 11 +-
.../test/TestCredUIConfirmCredentials.c | 1 -
.../credui/test/TestCredUIParseUserName.c | 13 +-
.../test/TestCredUIPromptForCredentials.c | 21 +-
winpr/libwinpr/crt/alignment.c | 10 +-
winpr/libwinpr/crt/casing.c | 1729 +-
winpr/libwinpr/crt/conversion.c | 1 -
winpr/libwinpr/crt/string.c | 30 +-
winpr/libwinpr/crt/test/TestAlignment.c | 30 +-
.../libwinpr/crt/test/TestFormatSpecifiers.c | 99 +-
winpr/libwinpr/crt/test/TestString.c | 44 +-
winpr/libwinpr/crt/test/TestTypes.c | 92 +-
.../libwinpr/crt/test/TestUnicodeConversion.c | 210 +-
winpr/libwinpr/crt/unicode.c | 96 +-
winpr/libwinpr/crt/utf.c | 112 +-
winpr/libwinpr/crt/utf.h | 66 +-
winpr/libwinpr/crypto/cert.c | 24 +-
winpr/libwinpr/crypto/cipher.c | 55 +-
winpr/libwinpr/crypto/crypto.c | 41 +-
winpr/libwinpr/crypto/hash.c | 56 +-
.../TestCryptoCertEnumCertificatesInStore.c | 18 +-
winpr/libwinpr/crypto/test/TestCryptoCipher.c | 58 +-
winpr/libwinpr/crypto/test/TestCryptoHash.c | 37 +-
.../crypto/test/TestCryptoProtectData.c | 1 -
.../crypto/test/TestCryptoProtectMemory.c | 8 +-
winpr/libwinpr/crypto/test/TestCryptoRand.c | 2 +-
winpr/libwinpr/dsparse/dsparse.c | 16 +-
.../libwinpr/dsparse/test/TestDsCrackNames.c | 3 +-
winpr/libwinpr/dsparse/test/TestDsMakeSpn.c | 6 +-
winpr/libwinpr/environment/environment.c | 79 +-
.../TestEnvironmentGetEnvironmentStrings.c | 3 +-
.../test/TestEnvironmentGetSetEB.c | 5 +-
.../TestEnvironmentMergeEnvironmentStrings.c | 3 +-
.../TestEnvironmentSetEnvironmentVariable.c | 3 +-
winpr/libwinpr/error/error.c | 8 +-
.../error/test/TestErrorSetLastError.c | 25 +-
winpr/libwinpr/file/file.c | 475 +-
winpr/libwinpr/file/file.h | 3 +-
winpr/libwinpr/file/generic.c | 92 +-
winpr/libwinpr/file/namedPipeClient.c | 37 +-
winpr/libwinpr/file/pattern.c | 37 +-
winpr/libwinpr/file/test/TestFileCreateFile.c | 11 +-
.../file/test/TestFileFindFirstFile.c | 8 +-
.../file/test/TestFileFindFirstFileEx.c | 1 -
.../libwinpr/file/test/TestFileFindNextFile.c | 18 +-
.../libwinpr/file/test/TestFileGetStdHandle.c | 2 +-
.../libwinpr/file/test/TestFilePatternMatch.c | 11 +-
winpr/libwinpr/handle/handle.c | 7 +-
winpr/libwinpr/handle/handle.h | 83 +-
winpr/libwinpr/handle/nonehandle.c | 49 +-
winpr/libwinpr/input/keycode.c | 1038 +-
winpr/libwinpr/input/scancode.c | 584 +-
winpr/libwinpr/input/virtualkey.c | 234 +-
winpr/libwinpr/interlocked/interlocked.c | 117 +-
.../interlocked/test/TestInterlockedAccess.c | 51 +-
.../interlocked/test/TestInterlockedDList.c | 12 +-
.../interlocked/test/TestInterlockedSList.c | 12 +-
winpr/libwinpr/io/device.c | 21 +-
winpr/libwinpr/io/io.c | 51 +-
winpr/libwinpr/io/io.h | 1 -
winpr/libwinpr/io/test/TestIoDevice.c | 5 +-
winpr/libwinpr/library/library.c | 7 +-
.../test/TestLibraryGetModuleFileName.c | 20 +-
.../library/test/TestLibraryGetProcAddress.c | 10 +-
.../library/test/TestLibraryLoadLibrary.c | 6 +-
winpr/libwinpr/locale/locale.c | 5 +-
.../locale/test/TestLocaleFormatMessage.c | 1 -
winpr/libwinpr/memory/memory.c | 9 +-
winpr/libwinpr/memory/memory.h | 4 -
.../memory/test/TestMemoryCreateFileMapping.c | 1 -
winpr/libwinpr/nt/nt.c | 206 +-
winpr/libwinpr/nt/test/TestNtCreateFile.c | 13 +-
winpr/libwinpr/nt/test/TestNtCurrentTeb.c | 1 -
.../libwinpr/path/include/PathAllocCombine.c | 16 +-
.../path/include/PathCchAddExtension.c | 1 -
.../path/include/PathCchAddSeparator.c | 1 -
.../path/include/PathCchAddSeparatorEx.c | 7 +-
winpr/libwinpr/path/include/PathCchAppend.c | 15 +-
winpr/libwinpr/path/path.c | 290 +-
winpr/libwinpr/path/shell.c | 97 +-
winpr/libwinpr/path/shell_ios.h | 1 -
winpr/libwinpr/path/shell_ios.m | 21 +-
.../path/test/TestPathAllocCanonicalize.c | 1 -
.../libwinpr/path/test/TestPathAllocCombine.c | 15 +-
.../path/test/TestPathCchAddBackslash.c | 15 +-
.../path/test/TestPathCchAddBackslashEx.c | 17 +-
.../path/test/TestPathCchAddExtension.c | 34 +-
winpr/libwinpr/path/test/TestPathCchAppend.c | 28 +-
.../libwinpr/path/test/TestPathCchAppendEx.c | 1 -
.../path/test/TestPathCchCanonicalize.c | 1 -
.../path/test/TestPathCchCanonicalizeEx.c | 1 -
winpr/libwinpr/path/test/TestPathCchCombine.c | 1 -
.../libwinpr/path/test/TestPathCchCombineEx.c | 1 -
.../path/test/TestPathCchFindExtension.c | 32 +-
winpr/libwinpr/path/test/TestPathCchIsRoot.c | 1 -
.../path/test/TestPathCchRemoveBackslash.c | 1 -
.../path/test/TestPathCchRemoveBackslashEx.c | 1 -
.../path/test/TestPathCchRemoveExtension.c | 1 -
.../path/test/TestPathCchRemoveFileSpec.c | 1 -
.../path/test/TestPathCchRenameExtension.c | 1 -
.../libwinpr/path/test/TestPathCchSkipRoot.c | 1 -
.../path/test/TestPathCchStripPrefix.c | 31 +-
.../path/test/TestPathCchStripToRoot.c | 1 -
winpr/libwinpr/path/test/TestPathIsUNCEx.c | 9 +-
winpr/libwinpr/path/test/TestPathMakePath.c | 1 -
winpr/libwinpr/path/test/TestPathShell.c | 29 +-
winpr/libwinpr/pipe/pipe.c | 176 +-
winpr/libwinpr/pipe/pipe.h | 9 +-
.../pipe/test/TestPipeCreateNamedPipe.c | 130 +-
.../test/TestPipeCreateNamedPipeOverlapped.c | 98 +-
winpr/libwinpr/pipe/test/TestPipeCreatePipe.c | 12 +-
winpr/libwinpr/pool/callback.c | 4 +-
winpr/libwinpr/pool/callback_cleanup.c | 35 +-
winpr/libwinpr/pool/cleanup_group.c | 24 +-
winpr/libwinpr/pool/io.c | 7 +-
winpr/libwinpr/pool/pool.c | 29 +-
winpr/libwinpr/pool/pool.h | 1 -
winpr/libwinpr/pool/synch.c | 3 -
winpr/libwinpr/pool/test/TestPoolIO.c | 1 -
winpr/libwinpr/pool/test/TestPoolSynch.c | 1 -
winpr/libwinpr/pool/test/TestPoolTimer.c | 1 -
winpr/libwinpr/pool/test/TestPoolWork.c | 17 +-
winpr/libwinpr/pool/timer.c | 6 +-
winpr/libwinpr/pool/work.c | 27 +-
winpr/libwinpr/registry/registry.c | 94 +-
winpr/libwinpr/registry/registry_reg.c | 70 +-
winpr/libwinpr/registry/registry_reg.h | 5 +-
winpr/libwinpr/rpc/midl.c | 2 +-
winpr/libwinpr/rpc/ndr.c | 64 +-
winpr/libwinpr/rpc/ndr_array.c | 17 +-
winpr/libwinpr/rpc/ndr_array.h | 15 +-
winpr/libwinpr/rpc/ndr_context.c | 3 +-
winpr/libwinpr/rpc/ndr_context.h | 3 +-
winpr/libwinpr/rpc/ndr_correlation.c | 47 +-
winpr/libwinpr/rpc/ndr_correlation.h | 9 +-
winpr/libwinpr/rpc/ndr_pointer.c | 42 +-
winpr/libwinpr/rpc/ndr_pointer.h | 15 +-
winpr/libwinpr/rpc/ndr_private.c | 755 +-
winpr/libwinpr/rpc/ndr_simple.c | 23 +-
winpr/libwinpr/rpc/ndr_simple.h | 11 +-
winpr/libwinpr/rpc/ndr_string.c | 7 +-
winpr/libwinpr/rpc/ndr_string.h | 6 +-
winpr/libwinpr/rpc/ndr_structure.c | 34 +-
winpr/libwinpr/rpc/ndr_structure.h | 12 +-
winpr/libwinpr/rpc/ndr_union.c | 6 +-
winpr/libwinpr/rpc/ndr_union.h | 6 +-
winpr/libwinpr/rpc/rpc.c | 425 +-
winpr/libwinpr/security/security.c | 30 +-
.../security/test/TestSecurityToken.c | 1 -
winpr/libwinpr/shell/shell.c | 7 +-
winpr/libwinpr/smartcard/smartcard.c | 318 +-
winpr/libwinpr/smartcard/smartcard_inspect.c | 930 +-
winpr/libwinpr/smartcard/smartcard_pcsc.c | 779 +-
winpr/libwinpr/smartcard/smartcard_pcsc.h | 113 +-
winpr/libwinpr/smartcard/smartcard_winscard.c | 5 +-
winpr/libwinpr/smartcard/smartcard_winscard.h | 2 +-
.../smartcard/test/TestSmartCardListReaders.c | 9 +-
.../smartcard/test/TestSmartCardStatus.c | 16 +-
winpr/libwinpr/sspi/CredSSP/credssp.c | 225 +-
winpr/libwinpr/sspi/CredSSP/credssp.h | 1 -
winpr/libwinpr/sspi/Kerberos/kerberos.c | 304 +-
winpr/libwinpr/sspi/NTLM/ntlm.c | 404 +-
winpr/libwinpr/sspi/NTLM/ntlm.h | 88 +-
winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c | 115 +-
winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.h | 4 +-
winpr/libwinpr/sspi/NTLM/ntlm_compute.c | 151 +-
winpr/libwinpr/sspi/NTLM/ntlm_message.c | 269 +-
winpr/libwinpr/sspi/Negotiate/negotiate.c | 350 +-
winpr/libwinpr/sspi/Negotiate/negotiate.h | 3 +-
winpr/libwinpr/sspi/Schannel/schannel.c | 281 +-
winpr/libwinpr/sspi/Schannel/schannel.h | 1 -
.../libwinpr/sspi/Schannel/schannel_openssl.c | 37 +-
.../libwinpr/sspi/Schannel/schannel_openssl.h | 16 +-
winpr/libwinpr/sspi/sspi.c | 297 +-
winpr/libwinpr/sspi/sspi.h | 62 +-
winpr/libwinpr/sspi/sspi_export.c | 130 +-
winpr/libwinpr/sspi/sspi_gss.c | 751 +-
winpr/libwinpr/sspi/sspi_gss.h | 1232 +-
winpr/libwinpr/sspi/sspi_winpr.c | 451 +-
.../sspi/test/TestAcquireCredentialsHandle.c | 14 +-
.../sspi/test/TestEnumerateSecurityPackages.c | 7 +-
.../sspi/test/TestInitializeSecurityContext.c | 26 +-
winpr/libwinpr/sspi/test/TestNTLM.c | 121 +-
.../sspi/test/TestQuerySecurityPackageInfo.c | 1 -
winpr/libwinpr/sspi/test/TestSchannel.c | 598 +-
winpr/libwinpr/sspicli/sspicli.c | 76 +-
winpr/libwinpr/synch/address.c | 5 +-
winpr/libwinpr/synch/barrier.c | 32 +-
winpr/libwinpr/synch/condition.c | 9 +-
winpr/libwinpr/synch/critical.c | 26 +-
winpr/libwinpr/synch/event.c | 90 +-
winpr/libwinpr/synch/init.c | 9 +-
winpr/libwinpr/synch/mutex.c | 53 +-
winpr/libwinpr/synch/semaphore.c | 69 +-
winpr/libwinpr/synch/sleep.c | 19 +-
winpr/libwinpr/synch/srw.c | 5 -
winpr/libwinpr/synch/synch.h | 2 +-
winpr/libwinpr/synch/test/TestSynchBarrier.c | 78 +-
winpr/libwinpr/synch/test/TestSynchCritical.c | 93 +-
winpr/libwinpr/synch/test/TestSynchInit.c | 43 +-
.../synch/test/TestSynchMultipleThreads.c | 14 +-
winpr/libwinpr/synch/test/TestSynchMutex.c | 18 +-
.../libwinpr/synch/test/TestSynchSemaphore.c | 1 -
winpr/libwinpr/synch/test/TestSynchThread.c | 15 +-
.../libwinpr/synch/test/TestSynchTimerQueue.c | 30 +-
.../synch/test/TestSynchWaitableTimer.c | 4 +-
.../synch/test/TestSynchWaitableTimerAPC.c | 20 +-
winpr/libwinpr/synch/timer.c | 105 +-
winpr/libwinpr/synch/wait.c | 49 +-
.../sysinfo/cpufeatures/cpu-features.c | 321 +-
.../sysinfo/cpufeatures/cpu-features.h | 62 +-
winpr/libwinpr/sysinfo/sysinfo.c | 441 +-
winpr/libwinpr/sysinfo/test/TestCPUFeatures.c | 6 +-
.../sysinfo/test/TestGetComputerName.c | 141 +-
.../sysinfo/test/TestGetNativeSystemInfo.c | 18 +-
winpr/libwinpr/sysinfo/test/TestLocalTime.c | 7 +-
winpr/libwinpr/sysinfo/test/TestSystemTime.c | 8 +-
winpr/libwinpr/thread/argv.c | 35 +-
winpr/libwinpr/thread/process.c | 165 +-
winpr/libwinpr/thread/processor.c | 1 -
.../thread/test/TestThreadCommandLineToArgv.c | 66 +-
.../thread/test/TestThreadCreateProcess.c | 51 +-
.../thread/test/TestThreadExitThread.c | 16 +-
winpr/libwinpr/thread/thread.c | 128 +-
winpr/libwinpr/thread/thread.h | 7 +-
winpr/libwinpr/thread/tls.c | 9 +-
winpr/libwinpr/timezone/TimeZones.c | 5359 +++--
winpr/libwinpr/timezone/WindowsZones.c | 41 +-
winpr/libwinpr/timezone/timezone.c | 54 +-
winpr/libwinpr/utils/cmdline.c | 19 +-
winpr/libwinpr/utils/collections/ArrayList.c | 31 +-
winpr/libwinpr/utils/collections/BipBuffer.c | 13 +-
winpr/libwinpr/utils/collections/BitStream.c | 205 +-
winpr/libwinpr/utils/collections/BufferPool.c | 38 +-
.../utils/collections/CountdownEvent.c | 5 +-
winpr/libwinpr/utils/collections/Dictionary.c | 6 +-
winpr/libwinpr/utils/collections/HashTable.c | 31 +-
.../libwinpr/utils/collections/KeyValuePair.c | 2 +-
winpr/libwinpr/utils/collections/LinkedList.c | 4 +-
.../utils/collections/ListDictionary.c | 9 +-
.../libwinpr/utils/collections/MessagePipe.c | 4 +-
.../libwinpr/utils/collections/MessageQueue.c | 17 +-
winpr/libwinpr/utils/collections/ObjectPool.c | 9 +-
winpr/libwinpr/utils/collections/PubSub.c | 10 +-
winpr/libwinpr/utils/collections/Reference.c | 11 +-
winpr/libwinpr/utils/collections/Stack.c | 5 +-
winpr/libwinpr/utils/collections/StreamPool.c | 36 +-
winpr/libwinpr/utils/corkscrew/backtrace.h | 48 +-
winpr/libwinpr/utils/corkscrew/demangle.h | 19 +-
winpr/libwinpr/utils/corkscrew/map_info.h | 68 +-
winpr/libwinpr/utils/corkscrew/ptrace.h | 171 +-
winpr/libwinpr/utils/corkscrew/symbol_table.h | 51 +-
winpr/libwinpr/utils/debug.c | 98 +-
winpr/libwinpr/utils/image.c | 20 +-
winpr/libwinpr/utils/ini.c | 31 +-
winpr/libwinpr/utils/lodepng/lodepng.c | 9075 ++++----
winpr/libwinpr/utils/lodepng/lodepng.h | 582 +-
winpr/libwinpr/utils/ntlm.c | 36 +-
winpr/libwinpr/utils/print.c | 20 +-
winpr/libwinpr/utils/sam.c | 32 +-
winpr/libwinpr/utils/ssl.c | 19 +-
winpr/libwinpr/utils/stream.c | 12 +-
winpr/libwinpr/utils/strlst.c | 15 +-
winpr/libwinpr/utils/test/TestArrayList.c | 25 +-
winpr/libwinpr/utils/test/TestBacktrace.c | 2 +-
winpr/libwinpr/utils/test/TestBipBuffer.c | 2 +-
winpr/libwinpr/utils/test/TestBitStream.c | 13 +-
winpr/libwinpr/utils/test/TestBufferPool.c | 9 +-
winpr/libwinpr/utils/test/TestCmdLine.c | 122 +-
winpr/libwinpr/utils/test/TestHashTable.c | 16 +-
winpr/libwinpr/utils/test/TestImage.c | 12 +-
winpr/libwinpr/utils/test/TestIni.c | 66 +-
winpr/libwinpr/utils/test/TestLinkedList.c | 49 +-
.../libwinpr/utils/test/TestListDictionary.c | 39 +-
winpr/libwinpr/utils/test/TestMessagePipe.c | 14 +-
winpr/libwinpr/utils/test/TestMessageQueue.c | 13 +-
winpr/libwinpr/utils/test/TestPrint.c | 11 +-
winpr/libwinpr/utils/test/TestPubSub.c | 20 +-
winpr/libwinpr/utils/test/TestQueue.c | 16 +-
winpr/libwinpr/utils/test/TestStream.c | 117 +-
winpr/libwinpr/utils/test/TestStreamPool.c | 1 -
winpr/libwinpr/utils/test/TestVersion.c | 1 -
winpr/libwinpr/utils/test/TestWLog.c | 12 +-
winpr/libwinpr/utils/test/TestWLogCallback.c | 47 +-
winpr/libwinpr/utils/trio/strio.h | 61 +-
winpr/libwinpr/utils/trio/trio.c | 10268 +++++----
winpr/libwinpr/utils/trio/trio.h | 271 +-
winpr/libwinpr/utils/trio/triodef.h | 320 +-
winpr/libwinpr/utils/trio/trionan.c | 1494 +-
winpr/libwinpr/utils/trio/trionan.h | 145 +-
winpr/libwinpr/utils/trio/triop.h | 268 +-
winpr/libwinpr/utils/trio/triostr.c | 2039 +-
winpr/libwinpr/utils/trio/triostr.h | 671 +-
winpr/libwinpr/utils/winpr.c | 11 +-
winpr/libwinpr/utils/wlog/Appender.c | 56 +-
winpr/libwinpr/utils/wlog/Appender.h | 1 -
winpr/libwinpr/utils/wlog/BinaryAppender.c | 48 +-
winpr/libwinpr/utils/wlog/CallbackAppender.c | 41 +-
winpr/libwinpr/utils/wlog/ConsoleAppender.c | 62 +-
winpr/libwinpr/utils/wlog/DataMessage.c | 2 +-
winpr/libwinpr/utils/wlog/FileAppender.c | 24 +-
winpr/libwinpr/utils/wlog/JournaldAppender.c | 81 +-
winpr/libwinpr/utils/wlog/Layout.c | 43 +-
winpr/libwinpr/utils/wlog/Layout.h | 1 -
winpr/libwinpr/utils/wlog/Message.c | 7 +-
winpr/libwinpr/utils/wlog/PacketMessage.c | 33 +-
winpr/libwinpr/utils/wlog/PacketMessage.h | 17 +-
winpr/libwinpr/utils/wlog/SyslogAppender.c | 46 +-
winpr/libwinpr/utils/wlog/UdpAppender.c | 18 +-
winpr/libwinpr/utils/wlog/wlog.c | 82 +-
winpr/libwinpr/utils/wlog/wlog.h | 54 +-
winpr/libwinpr/winhttp/winhttp.c | 53 +-
winpr/libwinpr/winsock/winsock.c | 171 +-
.../libwinpr/wnd/test/TestWndCreateWindowEx.c | 44 +-
winpr/libwinpr/wnd/test/TestWndWmCopyData.c | 23 +-
winpr/libwinpr/wnd/wnd.c | 52 +-
.../test/TestWtsApiEnumerateProcesses.c | 2 +-
.../wtsapi/test/TestWtsApiEnumerateSessions.c | 12 +-
.../test/TestWtsApiExtraDisconnectSession.c | 2 +-
.../TestWtsApiExtraDynamicVirtualChannel.c | 15 +-
.../test/TestWtsApiExtraLogoffSession.c | 2 +-
.../wtsapi/test/TestWtsApiExtraSendMessage.c | 7 +-
.../TestWtsApiExtraStartRemoteSessionEx.c | 8 +-
.../test/TestWtsApiExtraVirtualChannel.c | 14 +-
.../test/TestWtsApiQuerySessionInformation.c | 114 +-
.../test/TestWtsApiSessionNotification.c | 12 +-
.../wtsapi/test/TestWtsApiShutdownSystem.c | 2 +-
.../wtsapi/test/TestWtsApiWaitSystemEvent.c | 2 +-
winpr/libwinpr/wtsapi/wtsapi.c | 353 +-
winpr/libwinpr/wtsapi/wtsapi_win32.c | 162 +-
winpr/test/TestIntrinsics.c | 64 +-
winpr/test/TestTypes.c | 5 +-
winpr/tools/hash-cli/hash.c | 9 +-
winpr/tools/makecert/makecert.c | 390 +-
1335 files changed, 118253 insertions(+), 113607 deletions(-)
mode change 100755 => 100644 channels/video/client/video_main.c
mode change 100755 => 100644 libfreerdp/core/gateway/rdg.h
diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c
index 2b2571056..60e9fd8d4 100644
--- a/channels/audin/client/alsa/audin_alsa.c
+++ b/channels/audin/client/alsa/audin_alsa.c
@@ -87,30 +87,26 @@ static snd_pcm_format_t audin_alsa_format(UINT32 wFormatTag, UINT32 bitPerChanne
}
}
-static BOOL audin_alsa_set_params(AudinALSADevice* alsa,
- snd_pcm_t* capture_handle)
+static BOOL audin_alsa_set_params(AudinALSADevice* alsa, snd_pcm_t* capture_handle)
{
int error;
SSIZE_T s;
UINT32 channels = alsa->aformat.nChannels;
snd_pcm_hw_params_t* hw_params;
- snd_pcm_format_t format = audin_alsa_format(alsa->aformat.wFormatTag, alsa->aformat.wBitsPerSample);
+ snd_pcm_format_t format =
+ audin_alsa_format(alsa->aformat.wFormatTag, alsa->aformat.wBitsPerSample);
if ((error = snd_pcm_hw_params_malloc(&hw_params)) < 0)
{
- WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_hw_params_malloc (%s)",
- snd_strerror(error));
+ WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_hw_params_malloc (%s)", snd_strerror(error));
return FALSE;
}
snd_pcm_hw_params_any(capture_handle, hw_params);
- snd_pcm_hw_params_set_access(capture_handle, hw_params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
+ snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(capture_handle, hw_params, format);
- snd_pcm_hw_params_set_rate_near(capture_handle, hw_params,
- &alsa->aformat.nSamplesPerSec, NULL);
- snd_pcm_hw_params_set_channels_near(capture_handle, hw_params,
- &channels);
+ snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &alsa->aformat.nSamplesPerSec, NULL);
+ snd_pcm_hw_params_set_channels_near(capture_handle, hw_params, &channels);
snd_pcm_hw_params(capture_handle, hw_params);
snd_pcm_hw_params_free(hw_params);
snd_pcm_prepare(capture_handle);
@@ -129,12 +125,11 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
long error;
BYTE* buffer;
snd_pcm_t* capture_handle = NULL;
- AudinALSADevice* alsa = (AudinALSADevice*) arg;
+ AudinALSADevice* alsa = (AudinALSADevice*)arg;
DWORD status;
WLog_Print(alsa->log, WLOG_DEBUG, "in");
- if ((error = snd_pcm_open(&capture_handle, alsa->device_name,
- SND_PCM_STREAM_CAPTURE, 0)) < 0)
+ if ((error = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0)
{
WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_open (%s)", snd_strerror(error));
error = CHANNEL_RC_INITIALIZATION_ERROR;
@@ -147,7 +142,8 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
goto out;
}
- buffer = (BYTE*) calloc(alsa->frames_per_packet + alsa->aformat.nBlockAlign, alsa->bytes_per_frame);
+ buffer =
+ (BYTE*)calloc(alsa->frames_per_packet + alsa->aformat.nBlockAlign, alsa->bytes_per_frame);
if (!buffer)
{
@@ -187,12 +183,13 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg)
break;
}
- error = alsa->receive(&alsa->aformat,
- buffer, error * alsa->bytes_per_frame, alsa->user_data);
+ error =
+ alsa->receive(&alsa->aformat, buffer, error * alsa->bytes_per_frame, alsa->user_data);
if (error)
{
- WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_thread_receive failed with error %ld", error);
+ WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_thread_receive failed with error %ld",
+ error);
break;
}
}
@@ -206,8 +203,7 @@ out:
WLog_Print(alsa->log, WLOG_DEBUG, "out");
if (error && alsa->rdpcontext)
- setChannelError(alsa->rdpcontext, error,
- "audin_alsa_thread_func reported an error");
+ setChannelError(alsa->rdpcontext, error, "audin_alsa_thread_func reported an error");
ExitThread(error);
return error;
@@ -220,7 +216,7 @@ out:
*/
static UINT audin_alsa_free(IAudinDevice* device)
{
- AudinALSADevice* alsa = (AudinALSADevice*) device;
+ AudinALSADevice* alsa = (AudinALSADevice*)device;
if (alsa)
free(alsa->device_name);
@@ -229,8 +225,7 @@ static UINT audin_alsa_free(IAudinDevice* device)
return CHANNEL_RC_OK;
}
-static BOOL audin_alsa_format_supported(IAudinDevice* device,
- const AUDIO_FORMAT* format)
+static BOOL audin_alsa_format_supported(IAudinDevice* device, const AUDIO_FORMAT* format)
{
if (!device || !format)
return FALSE;
@@ -238,8 +233,7 @@ static BOOL audin_alsa_format_supported(IAudinDevice* device,
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= 48000) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= 48000) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels == 1 || format->nChannels == 2))
{
@@ -267,7 +261,7 @@ static BOOL audin_alsa_format_supported(IAudinDevice* device,
static UINT audin_alsa_set_format(IAudinDevice* device, const AUDIO_FORMAT* format,
UINT32 FramesPerPacket)
{
- AudinALSADevice* alsa = (AudinALSADevice*) device;
+ AudinALSADevice* alsa = (AudinALSADevice*)device;
if (!alsa || !format)
return ERROR_INVALID_PARAMETER;
@@ -286,10 +280,9 @@ static UINT audin_alsa_set_format(IAudinDevice* device, const AUDIO_FORMAT* form
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive,
- void* user_data)
+static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
- AudinALSADevice* alsa = (AudinALSADevice*) device;
+ AudinALSADevice* alsa = (AudinALSADevice*)device;
if (!device || !receive || !user_data)
return ERROR_INVALID_PARAMETER;
@@ -303,8 +296,7 @@ static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive,
goto error_out;
}
- if (!(alsa->thread = CreateThread(NULL, 0,
- audin_alsa_thread_func, alsa, 0, NULL)))
+ if (!(alsa->thread = CreateThread(NULL, 0, audin_alsa_thread_func, alsa, 0, NULL)))
{
WLog_Print(alsa->log, WLOG_ERROR, "CreateThread failed!");
goto error_out;
@@ -325,7 +317,7 @@ error_out:
static UINT audin_alsa_close(IAudinDevice* device)
{
UINT error = CHANNEL_RC_OK;
- AudinALSADevice* alsa = (AudinALSADevice*) device;
+ AudinALSADevice* alsa = (AudinALSADevice*)device;
if (!alsa)
return ERROR_INVALID_PARAMETER;
@@ -337,7 +329,8 @@ static UINT audin_alsa_close(IAudinDevice* device)
if (WaitForSingleObject(alsa->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_Print(alsa->log, WLOG_ERROR, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_Print(alsa->log, WLOG_ERROR, "WaitForSingleObject failed with error %" PRIu32 "",
+ error);
return error;
}
@@ -357,22 +350,19 @@ static UINT audin_alsa_close(IAudinDevice* device)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_alsa_parse_addin_args(AudinALSADevice* device,
- ADDIN_ARGV* args)
+static UINT audin_alsa_parse_addin_args(AudinALSADevice* device, ADDIN_ARGV* args)
{
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- AudinALSADevice* alsa = (AudinALSADevice*) device;
- COMMAND_LINE_ARGUMENT_A audin_alsa_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON |
- COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- audin_alsa_args, flags, alsa, NULL, NULL);
+ AudinALSADevice* alsa = (AudinALSADevice*)device;
+ COMMAND_LINE_ARGUMENT_A audin_alsa_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio device name" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, audin_alsa_args, flags, alsa, NULL,
+ NULL);
if (status < 0)
return ERROR_INVALID_PARAMETER;
@@ -384,8 +374,7 @@ static UINT audin_alsa_parse_addin_args(AudinALSADevice* device,
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
alsa->device_name = _strdup(arg->Value);
@@ -396,16 +385,15 @@ static UINT audin_alsa_parse_addin_args(AudinALSADevice* device,
}
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry alsa_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry alsa_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
/**
@@ -413,13 +401,12 @@ static UINT audin_alsa_parse_addin_args(AudinALSADevice* device,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS
- pEntryPoints)
+UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
{
ADDIN_ARGV* args;
AudinALSADevice* alsa;
UINT error;
- alsa = (AudinALSADevice*) calloc(1, sizeof(AudinALSADevice));
+ alsa = (AudinALSADevice*)calloc(1, sizeof(AudinALSADevice));
if (!alsa)
{
@@ -438,8 +425,8 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS
if ((error = audin_alsa_parse_addin_args(alsa, args)))
{
- WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_parse_addin_args failed with errorcode %"PRIu32"!",
- error);
+ WLog_Print(alsa->log, WLOG_ERROR,
+ "audin_alsa_parse_addin_args failed with errorcode %" PRIu32 "!", error);
goto error_out;
}
@@ -461,10 +448,10 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS
alsa->aformat.wFormatTag = WAVE_FORMAT_PCM;
alsa->aformat.nSamplesPerSec = 44100;
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin,
- (IAudinDevice*) alsa)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)alsa)))
{
- WLog_Print(alsa->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_Print(alsa->log, WLOG_ERROR, "RegisterAudinDevice failed with error %" PRIu32 "!",
+ error);
goto error_out;
}
diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c
index 0aa34957c..f9a67c17f 100644
--- a/channels/audin/client/audin_main.c
+++ b/channels/audin/client/audin_main.c
@@ -42,13 +42,13 @@
#include "audin_main.h"
-#define MSG_SNDIN_VERSION 0x01
-#define MSG_SNDIN_FORMATS 0x02
-#define MSG_SNDIN_OPEN 0x03
-#define MSG_SNDIN_OPEN_REPLY 0x04
+#define MSG_SNDIN_VERSION 0x01
+#define MSG_SNDIN_FORMATS 0x02
+#define MSG_SNDIN_OPEN 0x03
+#define MSG_SNDIN_OPEN_REPLY 0x04
#define MSG_SNDIN_DATA_INCOMING 0x05
-#define MSG_SNDIN_DATA 0x06
-#define MSG_SNDIN_FORMATCHANGE 0x07
+#define MSG_SNDIN_DATA 0x06
+#define MSG_SNDIN_FORMATCHANGE 0x07
typedef struct _AUDIN_LISTENER_CALLBACK AUDIN_LISTENER_CALLBACK;
struct _AUDIN_LISTENER_CALLBACK
@@ -105,7 +105,7 @@ struct _AUDIN_PLUGIN
static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args);
static UINT audin_channel_write_and_free(AUDIN_CHANNEL_CALLBACK* callback, wStream* out,
- BOOL freeStream)
+ BOOL freeStream)
{
UINT error;
@@ -116,9 +116,8 @@ static UINT audin_channel_write_and_free(AUDIN_CHANNEL_CALLBACK* callback, wStre
return ERROR_INTERNAL_ERROR;
Stream_SealLength(out);
- error = callback->channel->Write(callback->channel,
- Stream_Length(out),
- Stream_Buffer(out), NULL);
+ error =
+ callback->channel->Write(callback->channel, Stream_Length(out), Stream_Buffer(out), NULL);
if (freeStream)
Stream_Free(out, TRUE);
@@ -126,7 +125,6 @@ static UINT audin_channel_write_and_free(AUDIN_CHANNEL_CALLBACK* callback, wStre
return error;
}
-
/**
* Function description
*
@@ -142,15 +140,16 @@ static UINT audin_process_version(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* c
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, ServerVersion);
- WLog_Print(audin->log, WLOG_DEBUG, "ServerVersion=%"PRIu32", ClientVersion=%"PRIu32, ServerVersion,
- ClientVersion);
+ WLog_Print(audin->log, WLOG_DEBUG, "ServerVersion=%" PRIu32 ", ClientVersion=%" PRIu32,
+ ServerVersion, ClientVersion);
/* Do not answer server packet, we do not support the channel version. */
if (ServerVersion != ClientVersion)
{
WLog_Print(audin->log, WLOG_WARN,
- "Incompatible channel version server=%"PRIu32", client supports version=%"PRIu32, ServerVersion,
- ClientVersion);
+ "Incompatible channel version server=%" PRIu32
+ ", client supports version=%" PRIu32,
+ ServerVersion, ClientVersion);
return CHANNEL_RC_OK;
}
@@ -199,11 +198,11 @@ static UINT audin_process_formats(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* c
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, NumFormats);
- WLog_Print(audin->log, WLOG_DEBUG, "NumFormats %"PRIu32"", NumFormats);
+ WLog_Print(audin->log, WLOG_DEBUG, "NumFormats %" PRIu32 "", NumFormats);
if ((NumFormats < 1) || (NumFormats > 1000))
{
- WLog_Print(audin->log, WLOG_ERROR, "bad NumFormats %"PRIu32"", NumFormats);
+ WLog_Print(audin->log, WLOG_ERROR, "bad NumFormats %" PRIu32 "", NumFormats);
return ERROR_INVALID_DATA;
}
@@ -271,11 +270,11 @@ static UINT audin_process_formats(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* c
goto out;
}
- cbSizeFormatsPacket = (UINT32) Stream_GetPosition(out);
+ cbSizeFormatsPacket = (UINT32)Stream_GetPosition(out);
Stream_SetPosition(out, 0);
- Stream_Write_UINT8(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */
+ Stream_Write_UINT8(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */
Stream_Write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */
- Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */
+ Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */
Stream_SetPosition(out, cbSizeFormatsPacket);
error = audin_channel_write_and_free(callback, out, FALSE);
out:
@@ -296,7 +295,7 @@ out:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT audin_send_format_change_pdu(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback,
- UINT32 NewFormat)
+ UINT32 NewFormat)
{
wStream* out = Stream_New(NULL, 5);
@@ -337,13 +336,13 @@ static UINT audin_send_open_reply_pdu(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBAC
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_receive_wave_data(const AUDIO_FORMAT* format,
- const BYTE* data, size_t size, void* user_data)
+static UINT audin_receive_wave_data(const AUDIO_FORMAT* format, const BYTE* data, size_t size,
+ void* user_data)
{
UINT error;
BOOL compatible;
AUDIN_PLUGIN* audin;
- AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) user_data;
+ AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*)user_data;
if (!callback)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@@ -382,7 +381,7 @@ static UINT audin_receive_wave_data(const AUDIO_FORMAT* format,
return CHANNEL_RC_OK;
audio_format_print(audin->log, WLOG_TRACE, audin->format);
- WLog_Print(audin->log, WLOG_TRACE, "[%"PRIdz"/%"PRIdz"]", size,
+ WLog_Print(audin->log, WLOG_TRACE, "[%" PRIdz "/%" PRIdz "]", size,
Stream_GetPosition(audin->data) - 1);
if ((error = audin_send_incoming_data_pdu(callback)))
@@ -411,12 +410,7 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb
if (!supported)
{
/* Default sample rates supported by most backends. */
- const UINT32 samplerates[] = {
- 96000,
- 48000,
- 44100,
- 22050
- };
+ const UINT32 samplerates[] = { 96000, 48000, 44100, 22050 };
BOOL test = FALSE;
format.wFormatTag = WAVE_FORMAT_PCM;
@@ -425,7 +419,7 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb
if (!test)
{
size_t x;
- for (x=0; xdevice->FormatSupported, audin->device, &format);
@@ -437,13 +431,11 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb
return FALSE;
}
- IFCALLRET(audin->device->SetFormat, error,
- audin->device, &format,
- audin->FramesPerPacket);
+ IFCALLRET(audin->device->SetFormat, error, audin->device, &format, audin->FramesPerPacket);
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "SetFormat failed with errorcode %"PRIu32"", error);
+ WLog_ERR(TAG, "SetFormat failed with errorcode %" PRIu32 "", error);
return FALSE;
}
@@ -453,12 +445,11 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb
return FALSE;
}
- IFCALLRET(audin->device->Open, error, audin->device,
- audin_receive_wave_data, callback);
+ IFCALLRET(audin->device->Open, error, audin->device, audin_receive_wave_data, callback);
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Open failed with errorcode %"PRIu32"", error);
+ WLog_ERR(TAG, "Open failed with errorcode %" PRIu32 "", error);
return FALSE;
}
@@ -480,13 +471,13 @@ static UINT audin_process_open(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* call
Stream_Read_UINT32(s, FramesPerPacket);
Stream_Read_UINT32(s, initialFormat);
- WLog_Print(audin->log, WLOG_DEBUG, "FramesPerPacket=%"PRIu32" initialFormat=%"PRIu32"",
+ WLog_Print(audin->log, WLOG_DEBUG, "FramesPerPacket=%" PRIu32 " initialFormat=%" PRIu32 "",
FramesPerPacket, initialFormat);
audin->FramesPerPacket = FramesPerPacket;
if (initialFormat >= callback->formats_count)
{
- WLog_Print(audin->log, WLOG_ERROR, "invalid format index %"PRIu32" (total %d)",
+ WLog_Print(audin->log, WLOG_ERROR, "invalid format index %" PRIu32 " (total %d)",
initialFormat, callback->formats_count);
return ERROR_INVALID_DATA;
}
@@ -523,12 +514,12 @@ static UINT audin_process_format_change(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLB
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, NewFormat);
- WLog_Print(audin->log, WLOG_DEBUG, "NewFormat=%"PRIu32"", NewFormat);
+ WLog_Print(audin->log, WLOG_DEBUG, "NewFormat=%" PRIu32 "", NewFormat);
if (NewFormat >= callback->formats_count)
{
- WLog_Print(audin->log, WLOG_ERROR, "invalid format index %"PRIu32" (total %d)",
- NewFormat, callback->formats_count);
+ WLog_Print(audin->log, WLOG_ERROR, "invalid format index %" PRIu32 " (total %d)", NewFormat,
+ callback->formats_count);
return ERROR_INVALID_DATA;
}
@@ -540,7 +531,7 @@ static UINT audin_process_format_change(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLB
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Close failed with errorcode %"PRIu32"", error);
+ WLog_ERR(TAG, "Close failed with errorcode %" PRIu32 "", error);
return error;
}
}
@@ -564,12 +555,12 @@ static UINT audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
UINT error;
BYTE MessageId;
AUDIN_PLUGIN* audin;
- AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback;
+ AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*)pChannelCallback;
if (!callback || !data)
return ERROR_INVALID_PARAMETER;
- audin = (AUDIN_PLUGIN*) callback->plugin;
+ audin = (AUDIN_PLUGIN*)callback->plugin;
if (!audin)
return ERROR_INTERNAL_ERROR;
@@ -578,7 +569,7 @@ static UINT audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
return ERROR_NO_DATA;
Stream_Read_UINT8(data, MessageId);
- WLog_Print(audin->log, WLOG_DEBUG, "MessageId=0x%02"PRIx8"", MessageId);
+ WLog_Print(audin->log, WLOG_DEBUG, "MessageId=0x%02" PRIx8 "", MessageId);
switch (MessageId)
{
@@ -599,7 +590,7 @@ static UINT audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
break;
default:
- WLog_Print(audin->log, WLOG_ERROR, "unknown MessageId=0x%02"PRIx8"", MessageId);
+ WLog_Print(audin->log, WLOG_ERROR, "unknown MessageId=0x%02" PRIx8 "", MessageId);
error = ERROR_INVALID_DATA;
break;
}
@@ -614,8 +605,8 @@ static UINT audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
*/
static UINT audin_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
- AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback;
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) callback->plugin;
+ AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*)pChannelCallback;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)callback->plugin;
UINT error = CHANNEL_RC_OK;
WLog_Print(audin->log, WLOG_TRACE, "...");
@@ -624,7 +615,7 @@ static UINT audin_on_close(IWTSVirtualChannelCallback* pChannelCallback)
IFCALLRET(audin->device->Close, error, audin->device);
if (error != CHANNEL_RC_OK)
- WLog_Print(audin->log, WLOG_ERROR, "Close failed with errorcode %"PRIu32"", error);
+ WLog_Print(audin->log, WLOG_ERROR, "Close failed with errorcode %" PRIu32 "", error);
}
audin->format = NULL;
@@ -639,19 +630,19 @@ static UINT audin_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback)
{
AUDIN_CHANNEL_CALLBACK* callback;
AUDIN_PLUGIN* audin;
- AUDIN_LISTENER_CALLBACK* listener_callback = (AUDIN_LISTENER_CALLBACK*) pListenerCallback;
+ AUDIN_LISTENER_CALLBACK* listener_callback = (AUDIN_LISTENER_CALLBACK*)pListenerCallback;
if (!listener_callback || !listener_callback->plugin)
return ERROR_INTERNAL_ERROR;
- audin = (AUDIN_PLUGIN*) listener_callback->plugin;
+ audin = (AUDIN_PLUGIN*)listener_callback->plugin;
WLog_Print(audin->log, WLOG_TRACE, "...");
- callback = (AUDIN_CHANNEL_CALLBACK*) calloc(1, sizeof(AUDIN_CHANNEL_CALLBACK));
+ callback = (AUDIN_CHANNEL_CALLBACK*)calloc(1, sizeof(AUDIN_CHANNEL_CALLBACK));
if (!callback)
{
@@ -664,7 +655,7 @@ static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallb
callback->plugin = listener_callback->plugin;
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -675,7 +666,7 @@ static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallb
*/
static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin;
if (!audin)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@@ -684,7 +675,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
return ERROR_INVALID_PARAMETER;
WLog_Print(audin->log, WLOG_TRACE, "...");
- audin->listener_callback = (AUDIN_LISTENER_CALLBACK*) calloc(1, sizeof(AUDIN_LISTENER_CALLBACK));
+ audin->listener_callback = (AUDIN_LISTENER_CALLBACK*)calloc(1, sizeof(AUDIN_LISTENER_CALLBACK));
if (!audin->listener_callback)
{
@@ -696,7 +687,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
audin->listener_callback->plugin = pPlugin;
audin->listener_callback->channel_mgr = pChannelMgr;
return pChannelMgr->CreateListener(pChannelMgr, "AUDIO_INPUT", 0,
- (IWTSListenerCallback*) audin->listener_callback, NULL);
+ (IWTSListenerCallback*)audin->listener_callback, NULL);
}
/**
@@ -706,7 +697,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
*/
static UINT audin_plugin_terminated(IWTSPlugin* pPlugin)
{
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin;
UINT error = CHANNEL_RC_OK;
if (!audin)
@@ -721,7 +712,7 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin)
if (error != CHANNEL_RC_OK)
{
- WLog_Print(audin->log, WLOG_ERROR, "Free failed with errorcode %"PRIu32"", error);
+ WLog_Print(audin->log, WLOG_ERROR, "Free failed with errorcode %" PRIu32 "", error);
// dont stop on error
}
@@ -739,7 +730,7 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin)
static UINT audin_plugin_attached(IWTSPlugin* pPlugin)
{
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin;
UINT error = CHANNEL_RC_OK;
if (!audin)
@@ -751,7 +742,7 @@ static UINT audin_plugin_attached(IWTSPlugin* pPlugin)
static UINT audin_plugin_detached(IWTSPlugin* pPlugin)
{
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin;
UINT error = CHANNEL_RC_OK;
if (!audin)
@@ -768,7 +759,7 @@ static UINT audin_plugin_detached(IWTSPlugin* pPlugin)
*/
static UINT audin_register_device_plugin(IWTSPlugin* pPlugin, IAudinDevice* device)
{
- AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
+ AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin;
if (audin->device)
{
@@ -791,8 +782,8 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, char* name, ADDIN_ARGV
PFREERDP_AUDIN_DEVICE_ENTRY entry;
FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints;
UINT error;
- entry = (PFREERDP_AUDIN_DEVICE_ENTRY) freerdp_load_channel_addin_entry("audin", (LPSTR) name, NULL,
- 0);
+ entry = (PFREERDP_AUDIN_DEVICE_ENTRY)freerdp_load_channel_addin_entry("audin", (LPSTR)name,
+ NULL, 0);
if (entry == NULL)
{
@@ -802,14 +793,14 @@ static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, char* name, ADDIN_ARGV
return ERROR_INVALID_FUNCTION;
}
- entryPoints.plugin = (IWTSPlugin*) audin;
+ entryPoints.plugin = (IWTSPlugin*)audin;
entryPoints.pRegisterAudinDevice = audin_register_device_plugin;
entryPoints.args = args;
entryPoints.rdpcontext = audin->rdpcontext;
if ((error = entry(&entryPoints)))
{
- WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %"PRIu32".", name, error);
+ WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %" PRIu32 ".", name, error);
return error;
}
@@ -861,22 +852,22 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args)
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
UINT error;
- COMMAND_LINE_ARGUMENT_A audin_args[] =
- {
- { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
- { "format", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "format" },
- { "rate", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "rate" },
- { "channel", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "channel" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A audin_args[] = {
+ { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
+ { "format", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "format" },
+ { "rate", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "rate" },
+ { "channel", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "channel" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ };
if (!args || args->argc == 1)
return TRUE;
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- audin_args, flags, audin, NULL, NULL);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status =
+ CommandLineParseArgumentsA(args->argc, args->argv, audin_args, flags, audin, NULL, NULL);
if (status != 0)
return FALSE;
@@ -889,12 +880,12 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "sys")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "sys")
{
if ((error = audin_set_subsystem(audin, arg->Value)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_set_subsystem failed with error %"PRIu32"!", error);
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_set_subsystem failed with error %" PRIu32 "!", error);
return FALSE;
}
}
@@ -902,7 +893,8 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args)
{
if ((error = audin_set_device_name(audin, arg->Value)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_set_device_name failed with error %"PRIu32"!", error);
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_set_device_name failed with error %" PRIu32 "!", error);
return FALSE;
}
}
@@ -935,16 +927,15 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args)
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return TRUE;
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry audin_DVCPluginEntry
+#define DVCPluginEntry audin_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -965,34 +956,34 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
struct SubsystemEntry entries[] =
{
#if defined(WITH_PULSE)
- {"pulse", ""},
+ { "pulse", "" },
#endif
#if defined(WITH_OSS)
- {"oss", "default"},
+ { "oss", "default" },
#endif
#if defined(WITH_ALSA)
- {"alsa", "default"},
+ { "alsa", "default" },
#endif
#if defined(WITH_OPENSLES)
- {"opensles", "default"},
+ { "opensles", "default" },
#endif
#if defined(WITH_WINMM)
- {"winmm", "default"},
+ { "winmm", "default" },
#endif
#if defined(WITH_MACAUDIO)
- {"mac", "default"},
+ { "mac", "default" },
#endif
- {NULL, NULL}
+ { NULL, NULL }
};
struct SubsystemEntry* entry = &entries[0];
assert(pEntryPoints);
assert(pEntryPoints->GetPlugin);
- audin = (AUDIN_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "audin");
+ audin = (AUDIN_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "audin");
if (audin != NULL)
return CHANNEL_RC_ALREADY_INITIALIZED;
- audin = (AUDIN_PLUGIN*) calloc(1, sizeof(AUDIN_PLUGIN));
+ audin = (AUDIN_PLUGIN*)calloc(1, sizeof(AUDIN_PLUGIN));
if (!audin)
{
@@ -1023,8 +1014,8 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
audin->iface.Attached = audin_plugin_attached;
audin->iface.Detached = audin_plugin_detached;
args = pEntryPoints->GetPluginData(pEntryPoints);
- audin->rdpcontext = ((freerdp*)((rdpSettings*) pEntryPoints->GetRdpSettings(
- pEntryPoints))->instance)->context;
+ audin->rdpcontext =
+ ((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)->context;
if (args)
{
@@ -1036,7 +1027,8 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
if ((error = audin_load_device_plugin(audin, audin->subsystem, args)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_load_device_plugin %s failed with error %"PRIu32"!",
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_load_device_plugin %s failed with error %" PRIu32 "!",
audin->subsystem, error);
goto out;
}
@@ -1047,17 +1039,20 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
if ((error = audin_set_subsystem(audin, entry->subsystem)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_set_subsystem for %s failed with error %"PRIu32"!",
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_set_subsystem for %s failed with error %" PRIu32 "!",
entry->subsystem, error);
}
else if ((error = audin_set_device_name(audin, entry->device)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_set_device_name for %s failed with error %"PRIu32"!",
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_set_device_name for %s failed with error %" PRIu32 "!",
entry->subsystem, error);
}
else if ((error = audin_load_device_plugin(audin, audin->subsystem, args)))
{
- WLog_Print(audin->log, WLOG_ERROR, "audin_load_device_plugin %s failed with error %"PRIu32"!",
+ WLog_Print(audin->log, WLOG_ERROR,
+ "audin_load_device_plugin %s failed with error %" PRIu32 "!",
entry->subsystem, error);
}
@@ -1068,7 +1063,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
if (audin->device == NULL)
WLog_Print(audin->log, WLOG_ERROR, "no sound device.");
- error = pEntryPoints->RegisterPlugin(pEntryPoints, "audin", (IWTSPlugin*) audin);
+ error = pEntryPoints->RegisterPlugin(pEntryPoints, "audin", (IWTSPlugin*)audin);
out:
if (error != CHANNEL_RC_OK)
diff --git a/channels/audin/client/audin_main.h b/channels/audin/client/audin_main.h
index 83a75a456..760d3c8e8 100644
--- a/channels/audin/client/audin_main.h
+++ b/channels/audin/client/audin_main.h
@@ -33,4 +33,3 @@
#define TAG CHANNELS_TAG("audin.client")
#endif /* FREERDP_CHANNEL_AUDIN_CLIENT_MAIN_H */
-
diff --git a/channels/audin/client/mac/audin_mac.c b/channels/audin/client/mac/audin_mac.c
index 1d7c56239..e34b83528 100644
--- a/channels/audin/client/mac/audin_mac.c
+++ b/channels/audin/client/mac/audin_mac.c
@@ -34,7 +34,11 @@
#include
#define __COREFOUNDATION_CFPLUGINCOM__ 1
-#define IUNKNOWN_C_GUTS void *_reserved; void* QueryInterface; void* AddRef; void* Release
+#define IUNKNOWN_C_GUTS \
+ void* _reserved; \
+ void* QueryInterface; \
+ void* AddRef; \
+ void* Release
#include
#include
@@ -46,7 +50,7 @@
#include "audin_main.h"
-#define MAC_AUDIO_QUEUE_NUM_BUFFERS 100
+#define MAC_AUDIO_QUEUE_NUM_BUFFERS 100
/* Fix for #4462: Provide type alias if not declared (Mac OS < 10.10)
* https://developer.apple.com/documentation/coreaudio/audioformatid
@@ -133,8 +137,8 @@ static UINT audin_mac_set_format(IAudinDevice* device, const AUDIO_FORMAT* forma
mac->FramesPerPacket = FramesPerPacket;
mac->format = *format;
WLog_INFO(TAG, "Audio Format %s [channels=%d, samples=%d, bits=%d]",
- audio_format_get_tag_string(format->wFormatTag),
- format->nChannels, format->nSamplesPerSec, format->wBitsPerSample);
+ audio_format_get_tag_string(format->wFormatTag), format->nChannels,
+ format->nSamplesPerSec, format->wBitsPerSample);
mac->audioFormat.mBitsPerChannel = format->wBitsPerSample;
if (format->wBitsPerSample == 0)
@@ -151,11 +155,8 @@ static UINT audin_mac_set_format(IAudinDevice* device, const AUDIO_FORMAT* forma
return CHANNEL_RC_OK;
}
-static void mac_audio_queue_input_cb(void* aqData,
- AudioQueueRef inAQ,
- AudioQueueBufferRef inBuffer,
- const AudioTimeStamp* inStartTime,
- UInt32 inNumPackets,
+static void mac_audio_queue_input_cb(void* aqData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
+ const AudioTimeStamp* inStartTime, UInt32 inNumPackets,
const AudioStreamPacketDescription* inPacketDesc)
{
AudinMacDevice* mac = (AudinMacDevice*)aqData;
@@ -174,7 +175,7 @@ static void mac_audio_queue_input_cb(void* aqData,
if (error)
{
- WLog_ERR(TAG, "mac->receive failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "mac->receive failed with error %" PRIu32 "", error);
SetLastError(ERROR_INTERNAL_ERROR);
}
}
@@ -196,7 +197,7 @@ static UINT audin_mac_close(IAudinDevice* device)
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueStop failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueStop failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
}
@@ -210,7 +211,7 @@ static UINT audin_mac_close(IAudinDevice* device)
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueDispose failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueDispose failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
}
@@ -231,13 +232,13 @@ static UINT audin_mac_open(IAudinDevice* device, AudinReceive receive, void* use
size_t index;
mac->receive = receive;
mac->user_data = user_data;
- devStat = AudioQueueNewInput(&(mac->audioFormat), mac_audio_queue_input_cb,
- mac, NULL, kCFRunLoopCommonModes, 0, &(mac->audioQueue));
+ devStat = AudioQueueNewInput(&(mac->audioFormat), mac_audio_queue_input_cb, mac, NULL,
+ kCFRunLoopCommonModes, 0, &(mac->audioQueue));
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueNewInput failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueNewInput failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
goto err_out;
}
@@ -251,20 +252,17 @@ static UINT audin_mac_open(IAudinDevice* device, AudinReceive receive, void* use
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueAllocateBuffer failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueAllocateBuffer failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
goto err_out;
}
- devStat = AudioQueueEnqueueBuffer(mac->audioQueue,
- mac->audioBuffers[index],
- 0,
- NULL);
+ devStat = AudioQueueEnqueueBuffer(mac->audioQueue, mac->audioBuffers[index], 0, NULL);
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueEnqueueBuffer failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueEnqueueBuffer failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
goto err_out;
}
@@ -275,7 +273,7 @@ static UINT audin_mac_open(IAudinDevice* device, AudinReceive receive, void* use
if (devStat != 0)
{
errCode = GetLastError();
- WLog_ERR(TAG, "AudioQueueStart failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "AudioQueueStart failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
goto err_out;
}
@@ -309,23 +307,22 @@ static UINT audin_mac_parse_addin_args(AudinMacDevice* device, ADDIN_ARGV* args)
DWORD errCode;
char errString[1024];
int status;
- char* str_num, *eptr;
+ char *str_num, *eptr;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- COMMAND_LINE_ARGUMENT_A audin_mac_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A audin_mac_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio device name" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
AudinMacDevice* mac = (AudinMacDevice*)device;
if (args->argc == 1)
return CHANNEL_RC_OK;
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv, audin_mac_args, flags,
- mac, NULL, NULL);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status =
+ CommandLineParseArgumentsA(args->argc, args->argv, audin_mac_args, flags, mac, NULL, NULL);
if (status < 0)
return ERROR_INVALID_PARAMETER;
@@ -337,8 +334,7 @@ static UINT audin_mac_parse_addin_args(AudinMacDevice* device, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
str_num = _strdup(arg->Value);
@@ -358,16 +354,15 @@ static UINT audin_mac_parse_addin_args(AudinMacDevice* device, ADDIN_ARGV* args)
free(str_num);
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry mac_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry mac_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
@@ -382,7 +377,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
if (!mac)
{
errCode = GetLastError();
- WLog_ERR(TAG, "calloc failed with %s [%"PRIu32"]",
+ WLog_ERR(TAG, "calloc failed with %s [%" PRIu32 "]",
winpr_strerror(errCode, errString, sizeof(errString)), errCode);
return CHANNEL_RC_NO_MEMORY;
}
@@ -398,13 +393,13 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
if ((error = audin_mac_parse_addin_args(mac, args)))
{
- WLog_ERR(TAG, "audin_mac_parse_addin_args failed with %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_mac_parse_addin_args failed with %" PRIu32 "!", error);
goto error_out;
}
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) mac)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)mac)))
{
- WLog_ERR(TAG, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "RegisterAudinDevice failed with error %" PRIu32 "!", error);
goto error_out;
}
diff --git a/channels/audin/client/opensles/audin_opensl_es.c b/channels/audin/client/opensles/audin_opensl_es.c
index 1021843f1..4e3efdeb2 100644
--- a/channels/audin/client/opensles/audin_opensl_es.c
+++ b/channels/audin/client/opensles/audin_opensl_es.c
@@ -65,7 +65,7 @@ static UINT audin_opensles_close(IAudinDevice* device);
static void audin_receive(void* context, const void* data, size_t size)
{
UINT error;
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) context;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)context;
if (!opensles || !data)
{
@@ -86,34 +86,32 @@ static void audin_receive(void* context, const void* data, size_t size)
*/
static UINT audin_opensles_free(IAudinDevice* device)
{
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
if (!opensles)
return ERROR_INVALID_PARAMETER;
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p", (void*) device);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p", (void*)device);
free(opensles->device_name);
free(opensles);
return CHANNEL_RC_OK;
}
-static BOOL audin_opensles_format_supported(IAudinDevice* device,
- const AUDIO_FORMAT* format)
+static BOOL audin_opensles_format_supported(IAudinDevice* device, const AUDIO_FORMAT* format)
{
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
if (!opensles || !format)
return FALSE;
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, format=%p", (void*) opensles, (void*) format);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, format=%p", (void*)opensles, (void*)format);
assert(format);
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM: /* PCM */
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= 48000) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= 48000) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels >= 1 && format->nChannels <= 2))
{
@@ -123,9 +121,8 @@ static BOOL audin_opensles_format_supported(IAudinDevice* device,
break;
default:
- WLog_Print(opensles->log, WLOG_DEBUG, "Encoding '%s' [0x%04X"PRIX16"] not supported",
- audio_format_get_tag_string(format->wFormatTag),
- format->wFormatTag);
+ WLog_Print(opensles->log, WLOG_DEBUG, "Encoding '%s' [0x%04X" PRIX16 "] not supported",
+ audio_format_get_tag_string(format->wFormatTag), format->wFormatTag);
break;
}
@@ -137,16 +134,16 @@ static BOOL audin_opensles_format_supported(IAudinDevice* device,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_opensles_set_format(IAudinDevice* device,
- const AUDIO_FORMAT* format, UINT32 FramesPerPacket)
+static UINT audin_opensles_set_format(IAudinDevice* device, const AUDIO_FORMAT* format,
+ UINT32 FramesPerPacket)
{
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
if (!opensles || !format)
return ERROR_INVALID_PARAMETER;
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, format=%p, FramesPerPacket=%"PRIu32"",
- (void*) device, (void*) format, FramesPerPacket);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, format=%p, FramesPerPacket=%" PRIu32 "",
+ (void*)device, (void*)format, FramesPerPacket);
assert(format);
opensles->format = *format;
@@ -177,13 +174,13 @@ static UINT audin_opensles_set_format(IAudinDevice* device,
break;
default:
- WLog_Print(opensles->log, WLOG_ERROR, "Encoding '%"PRIu16"' [%04"PRIX16"] not supported",
- format->wFormatTag,
+ WLog_Print(opensles->log, WLOG_ERROR,
+ "Encoding '%" PRIu16 "' [%04" PRIX16 "] not supported", format->wFormatTag,
format->wFormatTag);
return ERROR_UNSUPPORTED_TYPE;
}
- WLog_Print(opensles->log, WLOG_DEBUG, "frames_per_packet=%"PRIu32,
+ WLog_Print(opensles->log, WLOG_DEBUG, "frames_per_packet=%" PRIu32,
opensles->frames_per_packet);
return CHANNEL_RC_OK;
}
@@ -193,27 +190,22 @@ static UINT audin_opensles_set_format(IAudinDevice* device,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_opensles_open(IAudinDevice* device, AudinReceive receive,
- void* user_data)
+static UINT audin_opensles_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
if (!opensles || !receive || !user_data)
return ERROR_INVALID_PARAMETER;
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, receive=%p, user_data=%p", (void*) device,
- (void*) receive,
- (void*) user_data);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, receive=%p, user_data=%p", (void*)device,
+ (void*)receive, (void*)user_data);
if (opensles->stream)
goto error_out;
if (!(opensles->stream = android_OpenRecDevice(
- opensles, audin_receive,
- opensles->format.nSamplesPerSec,
- opensles->format.nChannels,
- opensles->frames_per_packet,
- opensles->format.wBitsPerSample)))
+ opensles, audin_receive, opensles->format.nSamplesPerSec, opensles->format.nChannels,
+ opensles->frames_per_packet, opensles->format.wBitsPerSample)))
{
WLog_Print(opensles->log, WLOG_ERROR, "android_OpenRecDevice failed!");
goto error_out;
@@ -234,12 +226,12 @@ error_out:
*/
UINT audin_opensles_close(IAudinDevice* device)
{
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
if (!opensles)
return ERROR_INVALID_PARAMETER;
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p", (void*) device);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p", (void*)device);
android_CloseRecDevice(opensles->stream);
opensles->receive = NULL;
opensles->user_data = NULL;
@@ -252,26 +244,23 @@ UINT audin_opensles_close(IAudinDevice* device)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device,
- ADDIN_ARGV* args)
+static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device, ADDIN_ARGV* args)
{
UINT status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*) device;
- COMMAND_LINE_ARGUMENT_A audin_opensles_args[] =
- {
- {
- "dev", COMMAND_LINE_VALUE_REQUIRED, "",
- NULL, NULL, -1, NULL, "audio device name"
- },
+ AudinOpenSLESDevice* opensles = (AudinOpenSLESDevice*)device;
+ COMMAND_LINE_ARGUMENT_A audin_opensles_args[] = {
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ "audio device name" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
};
- WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, args=%p", (void*) device, (void*) args);
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- audin_opensles_args, flags, opensles, NULL, NULL);
+ WLog_Print(opensles->log, WLOG_DEBUG, "device=%p, args=%p", (void*)device, (void*)args);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, audin_opensles_args, flags,
+ opensles, NULL, NULL);
if (status < 0)
return status;
@@ -283,8 +272,7 @@ static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device,
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
opensles->device_name = _strdup(arg->Value);
@@ -295,18 +283,15 @@ static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device,
}
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry \
- opensles_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry opensles_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry \
- FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
/**
@@ -314,13 +299,12 @@ static UINT audin_opensles_parse_addin_args(AudinOpenSLESDevice* device,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT freerdp_audin_client_subsystem_entry(
- PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
+UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
{
ADDIN_ARGV* args;
AudinOpenSLESDevice* opensles;
UINT error;
- opensles = (AudinOpenSLESDevice*) calloc(1, sizeof(AudinOpenSLESDevice));
+ opensles = (AudinOpenSLESDevice*)calloc(1, sizeof(AudinOpenSLESDevice));
if (!opensles)
{
@@ -340,13 +324,14 @@ UINT freerdp_audin_client_subsystem_entry(
if ((error = audin_opensles_parse_addin_args(opensles, args)))
{
WLog_Print(opensles->log, WLOG_ERROR,
- "audin_opensles_parse_addin_args failed with errorcode %"PRIu32"!", error);
+ "audin_opensles_parse_addin_args failed with errorcode %" PRIu32 "!", error);
goto error_out;
}
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) opensles)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)opensles)))
{
- WLog_Print(opensles->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_Print(opensles->log, WLOG_ERROR, "RegisterAudinDevice failed with error %" PRIu32 "!",
+ error);
goto error_out;
}
diff --git a/channels/audin/client/opensles/opensl_io.c b/channels/audin/client/opensles/opensl_io.c
index 5e7fba603..be3e0b4f1 100644
--- a/channels/audin/client/opensles/opensl_io.c
+++ b/channels/audin/client/opensles/opensl_io.c
@@ -6,14 +6,14 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "audin_main.h"
#include "opensl_io.h"
#define CONV16BIT 32768
-#define CONVMYFLT (1./32768.)
+#define CONVMYFLT (1. / 32768.)
typedef struct
{
@@ -66,7 +66,6 @@ struct opensl_stream
opensl_receive_t receive;
};
-
static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void* context);
// creates the OpenSL ES audio engine
@@ -76,22 +75,24 @@ static SLresult openSLCreateEngine(OPENSL_STREAM* p)
// create engine
result = slCreateEngine(&(p->engineObject), 0, NULL, 0, NULL, NULL);
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
// realize the engine
result = (*p->engineObject)->Realize(p->engineObject, SL_BOOLEAN_FALSE);
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
// get the engine interface, which is needed in order to create other objects
- result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE,
- &(p->engineEngine));
+ result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE, &(p->engineEngine));
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
// get the volume interface - important, this is optional!
- result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_DEVICEVOLUME,
- &(p->deviceVolume));
+ result =
+ (*p->engineObject)->GetInterface(p->engineObject, SL_IID_DEVICEVOLUME, &(p->deviceVolume));
if (result != SL_RESULT_SUCCESS)
{
@@ -169,10 +170,9 @@ static SLresult openSLRecOpen(OPENSL_STREAM* p)
}
// configure audio source
- SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
- SL_DEFAULTDEVICEID_AUDIOINPUT, NULL
- };
- SLDataSource audioSrc = {&loc_dev, NULL};
+ SLDataLocator_IODevice loc_dev = { SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,
+ SL_DEFAULTDEVICEID_AUDIOINPUT, NULL };
+ SLDataSource audioSrc = { &loc_dev, NULL };
// configure audio sink
int speakers;
@@ -181,7 +181,8 @@ static SLresult openSLRecOpen(OPENSL_STREAM* p)
else
speakers = SL_SPEAKER_FRONT_CENTER;
- SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
+ SLDataLocator_AndroidSimpleBufferQueue loc_bq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
+ 2 };
SLDataFormat_PCM format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM;
format_pcm.numChannels = channels;
@@ -202,41 +203,46 @@ static SLresult openSLRecOpen(OPENSL_STREAM* p)
else
assert(0);
- SLDataSink audioSnk = {&loc_bq, &format_pcm};
+ SLDataSink audioSnk = { &loc_bq, &format_pcm };
// create audio recorder
// (requires the RECORD_AUDIO permission)
- const SLInterfaceID id[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
- const SLboolean req[] = {SL_BOOLEAN_TRUE};
- result = (*p->engineEngine)->CreateAudioRecorder(p->engineEngine,
- &(p->recorderObject), &audioSrc, &audioSnk, 1, id, req);
+ const SLInterfaceID id[] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
+ const SLboolean req[] = { SL_BOOLEAN_TRUE };
+ result = (*p->engineEngine)
+ ->CreateAudioRecorder(p->engineEngine, &(p->recorderObject), &audioSrc,
+ &audioSnk, 1, id, req);
assert(!result);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
+ if (SL_RESULT_SUCCESS != result)
+ goto end_recopen;
// realize the audio recorder
result = (*p->recorderObject)->Realize(p->recorderObject, SL_BOOLEAN_FALSE);
assert(!result);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
+ if (SL_RESULT_SUCCESS != result)
+ goto end_recopen;
// get the record interface
- result = (*p->recorderObject)->GetInterface(p->recorderObject,
- SL_IID_RECORD, &(p->recorderRecord));
+ result = (*p->recorderObject)
+ ->GetInterface(p->recorderObject, SL_IID_RECORD, &(p->recorderRecord));
assert(!result);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
+ if (SL_RESULT_SUCCESS != result)
+ goto end_recopen;
// get the buffer queue interface
- result = (*p->recorderObject)->GetInterface(p->recorderObject,
- SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &(p->recorderBufferQueue));
+ result = (*p->recorderObject)
+ ->GetInterface(p->recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
+ &(p->recorderBufferQueue));
assert(!result);
- if (SL_RESULT_SUCCESS != result) goto end_recopen;
+ if (SL_RESULT_SUCCESS != result)
+ goto end_recopen;
// register callback on the buffer queue
- result = (*p->recorderBufferQueue)->RegisterCallback(p->recorderBufferQueue,
- bqRecorderCallback, p);
+ result = (*p->recorderBufferQueue)
+ ->RegisterCallback(p->recorderBufferQueue, bqRecorderCallback, p);
assert(!result);
if (SL_RESULT_SUCCESS != result)
@@ -245,7 +251,8 @@ static SLresult openSLRecOpen(OPENSL_STREAM* p)
end_recopen:
return result;
}
- else return SL_RESULT_SUCCESS;
+ else
+ return SL_RESULT_SUCCESS;
}
// close the OpenSL IO and destroy the audio engine
@@ -299,17 +306,15 @@ static void opensles_queue_element_free(void* obj)
}
// open the android audio device for input
-OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive,
- int sr,
- int inchannels,
- int bufferframes, int bits_per_sample)
+OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive, int sr,
+ int inchannels, int bufferframes, int bits_per_sample)
{
OPENSL_STREAM* p;
if (!context || !receive)
return NULL;
- p = (OPENSL_STREAM*) calloc(1, sizeof(OPENSL_STREAM));
+ p = (OPENSL_STREAM*)calloc(1, sizeof(OPENSL_STREAM));
if (!p)
return NULL;
@@ -337,12 +342,9 @@ OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive,
if (!p->prep || !p->next)
goto fail;
- (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,
- p->next->data, p->next->size);
- (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,
- p->prep->data, p->prep->size);
- (*p->recorderRecord)->SetRecordState(p->recorderRecord,
- SL_RECORDSTATE_RECORDING);
+ (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue, p->next->data, p->next->size);
+ (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue, p->prep->data, p->prep->size);
+ (*p->recorderRecord)->SetRecordState(p->recorderRecord, SL_RECORDSTATE_RECORDING);
return p;
fail:
android_CloseRecDevice(p);
@@ -364,7 +366,7 @@ void android_CloseRecDevice(OPENSL_STREAM* p)
// this callback handler is called every time a buffer finishes recording
static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void* context)
{
- OPENSL_STREAM* p = (OPENSL_STREAM*) context;
+ OPENSL_STREAM* p = (OPENSL_STREAM*)context;
queue_element* e;
if (!p)
@@ -382,7 +384,5 @@ static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void* context)
p->next = p->prep;
p->prep = e;
- (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,
- e->data, e->size);
+ (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue, e->data, e->size);
}
-
diff --git a/channels/audin/client/opensles/opensl_io.h b/channels/audin/client/opensles/opensl_io.h
index 6a54b7cce..e99522cfe 100644
--- a/channels/audin/client/opensles/opensl_io.h
+++ b/channels/audin/client/opensles/opensl_io.h
@@ -6,14 +6,14 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -38,25 +38,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-typedef struct opensl_stream OPENSL_STREAM;
+ typedef struct opensl_stream OPENSL_STREAM;
-typedef void (*opensl_receive_t)(void* context, const void* data, size_t size);
+ typedef void (*opensl_receive_t)(void* context, const void* data, size_t size);
-/*
-Open the audio device with a given sampling rate (sr), input and output channels and IO buffer size
-in frames. Returns a handle to the OpenSL stream
-*/
-FREERDP_LOCAL OPENSL_STREAM* android_OpenRecDevice(void* context,
- opensl_receive_t receive, int sr,
- int inchannels,
- int bufferframes, int bits_per_sample);
-/*
-Close the audio device
-*/
-FREERDP_LOCAL void android_CloseRecDevice(OPENSL_STREAM* p);
+ /*
+ Open the audio device with a given sampling rate (sr), input and output channels and IO buffer
+ size in frames. Returns a handle to the OpenSL stream
+ */
+ FREERDP_LOCAL OPENSL_STREAM* android_OpenRecDevice(void* context, opensl_receive_t receive,
+ int sr, int inchannels, int bufferframes,
+ int bits_per_sample);
+ /*
+ Close the audio device
+ */
+ FREERDP_LOCAL void android_CloseRecDevice(OPENSL_STREAM* p);
#ifdef __cplusplus
};
diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c
index c39e25d00..97eb3496e 100644
--- a/channels/audin/client/oss/audin_oss.c
+++ b/channels/audin/client/oss/audin_oss.c
@@ -69,10 +69,9 @@ typedef struct _AudinOSSDevice
} AudinOSSDevice;
#define OSS_LOG_ERR(_text, _error) \
- if (_error != 0) \
+ if (_error != 0) \
WLog_ERR(TAG, "%s: %i - %s\n", _text, _error, strerror(_error));
-
static UINT32 audin_oss_get_format(const AUDIO_FORMAT* format)
{
switch (format->wFormatTag)
@@ -99,8 +98,7 @@ static UINT32 audin_oss_get_format(const AUDIO_FORMAT* format)
return 0;
}
-static BOOL audin_oss_format_supported(IAudinDevice* device,
- const AUDIO_FORMAT* format)
+static BOOL audin_oss_format_supported(IAudinDevice* device, const AUDIO_FORMAT* format)
{
if (device == NULL || format == NULL)
return FALSE;
@@ -108,8 +106,7 @@ static BOOL audin_oss_format_supported(IAudinDevice* device,
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize != 0 ||
- format->nSamplesPerSec > 48000 ||
+ if (format->cbSize != 0 || format->nSamplesPerSec > 48000 ||
(format->wBitsPerSample != 8 && format->wBitsPerSample != 16) ||
(format->nChannels != 1 && format->nChannels != 2))
return FALSE;
@@ -233,8 +230,7 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg)
if (ioctl(pcm_handle, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1)
OSS_LOG_ERR("SNDCTL_DSP_SETFRAGMENT failed", errno);
- buffer_size = (oss->FramesPerPacket * oss->format.nChannels *
- (oss->format.wBitsPerSample / 8));
+ buffer_size = (oss->FramesPerPacket * oss->format.nChannels * (oss->format.wBitsPerSample / 8));
buffer = (BYTE*)calloc((buffer_size + sizeof(void*)), sizeof(BYTE));
if (NULL == buffer)
@@ -252,7 +248,7 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
goto err_out;
}
@@ -273,7 +269,7 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg)
if ((error = oss->receive(&oss->format, buffer, buffer_size, oss->user_data)))
{
- WLog_ERR(TAG, "oss->receive failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "oss->receive failed with error %" PRIu32 "", error);
break;
}
}
@@ -281,8 +277,7 @@ static DWORD WINAPI audin_oss_thread_func(LPVOID arg)
err_out:
if (error && oss && oss->rdpcontext)
- setChannelError(oss->rdpcontext, error,
- "audin_oss_thread_func reported an error");
+ setChannelError(oss->rdpcontext, error, "audin_oss_thread_func reported an error");
if (pcm_handle != -1)
{
@@ -300,8 +295,7 @@ err_out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_oss_open(IAudinDevice* device, AudinReceive receive,
- void* user_data)
+static UINT audin_oss_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
AudinOSSDevice* oss = (AudinOSSDevice*)device;
oss->receive = receive;
@@ -344,7 +338,7 @@ static UINT audin_oss_close(IAudinDevice* device)
if (WaitForSingleObject(oss->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -389,21 +383,18 @@ static UINT audin_oss_free(IAudinDevice* device)
static UINT audin_oss_parse_addin_args(AudinOSSDevice* device, ADDIN_ARGV* args)
{
int status;
- char* str_num, *eptr;
+ char *str_num, *eptr;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
AudinOSSDevice* oss = (AudinOSSDevice*)device;
- COMMAND_LINE_ARGUMENT_A audin_oss_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A audin_oss_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio device name" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
-
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON |
- COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- audin_oss_args, flags, oss, NULL, NULL);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status =
+ CommandLineParseArgumentsA(args->argc, args->argv, audin_oss_args, flags, oss, NULL, NULL);
if (status < 0)
return ERROR_INVALID_PARAMETER;
@@ -416,8 +407,7 @@ static UINT audin_oss_parse_addin_args(AudinOSSDevice* device, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
str_num = _strdup(arg->Value);
@@ -445,16 +435,15 @@ static UINT audin_oss_parse_addin_args(AudinOSSDevice* device, ADDIN_ARGV* args)
free(str_num);
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry oss_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry oss_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
/**
@@ -462,8 +451,7 @@ static UINT audin_oss_parse_addin_args(AudinOSSDevice* device, ADDIN_ARGV* args)
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS
- pEntryPoints)
+UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEntryPoints)
{
ADDIN_ARGV* args;
AudinOSSDevice* oss;
@@ -487,14 +475,13 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS
if ((error = audin_oss_parse_addin_args(oss, args)))
{
- WLog_ERR(TAG, "audin_oss_parse_addin_args failed with errorcode %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_oss_parse_addin_args failed with errorcode %" PRIu32 "!", error);
goto error_out;
}
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin,
- (IAudinDevice*) oss)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)oss)))
{
- WLog_ERR(TAG, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "RegisterAudinDevice failed with error %" PRIu32 "!", error);
goto error_out;
}
diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c
index af2ef5d4e..4b3b4dc71 100644
--- a/channels/audin/client/pulse/audin_pulse.c
+++ b/channels/audin/client/pulse/audin_pulse.c
@@ -65,7 +65,7 @@ typedef struct _AudinPulseDevice
static void audin_pulse_context_state_callback(pa_context* context, void* userdata)
{
pa_context_state_t state;
- AudinPulseDevice* pulse = (AudinPulseDevice*) userdata;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)userdata;
state = pa_context_get_state(context);
switch (state)
@@ -95,7 +95,7 @@ static void audin_pulse_context_state_callback(pa_context* context, void* userda
static UINT audin_pulse_connect(IAudinDevice* device)
{
pa_context_state_t state;
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse->context)
return ERROR_INVALID_PARAMETER;
@@ -136,7 +136,7 @@ static UINT audin_pulse_connect(IAudinDevice* device)
}
pa_threaded_mainloop_unlock(pulse->mainloop);
- WLog_Print(pulse->log, WLOG_DEBUG, "connected");
+ WLog_Print(pulse->log, WLOG_DEBUG, "connected");
return CHANNEL_RC_OK;
}
@@ -147,7 +147,7 @@ static UINT audin_pulse_connect(IAudinDevice* device)
*/
static UINT audin_pulse_free(IAudinDevice* device)
{
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse)
return ERROR_INVALID_PARAMETER;
@@ -176,7 +176,7 @@ static UINT audin_pulse_free(IAudinDevice* device)
static BOOL audin_pulse_format_supported(IAudinDevice* device, const AUDIO_FORMAT* format)
{
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse || !format)
return FALSE;
@@ -187,8 +187,7 @@ static BOOL audin_pulse_format_supported(IAudinDevice* device, const AUDIO_FORMA
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= PA_RATE_MAX) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels >= 1 && format->nChannels <= PA_CHANNELS_MAX))
{
@@ -197,10 +196,9 @@ static BOOL audin_pulse_format_supported(IAudinDevice* device, const AUDIO_FORMA
break;
- case WAVE_FORMAT_ALAW: /* A-LAW */
+ case WAVE_FORMAT_ALAW: /* A-LAW */
case WAVE_FORMAT_MULAW: /* U-LAW */
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= PA_RATE_MAX) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8) &&
(format->nChannels >= 1 && format->nChannels <= PA_CHANNELS_MAX))
{
@@ -225,7 +223,7 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
UINT32 FramesPerPacket)
{
pa_sample_spec sample_spec = { 0 };
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse || !format)
return ERROR_INVALID_PARAMETER;
@@ -278,7 +276,7 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
static void audin_pulse_stream_state_callback(pa_stream* stream, void* userdata)
{
pa_stream_state_t state;
- AudinPulseDevice* pulse = (AudinPulseDevice*) userdata;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)userdata;
state = pa_stream_get_state(stream);
switch (state)
@@ -303,17 +301,17 @@ static void audin_pulse_stream_state_callback(pa_stream* stream, void* userdata)
static void audin_pulse_stream_request_callback(pa_stream* stream, size_t length, void* userdata)
{
const void* data;
- AudinPulseDevice* pulse = (AudinPulseDevice*) userdata;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)userdata;
UINT error = CHANNEL_RC_OK;
pa_stream_peek(stream, &data, &length);
- error = IFCALLRESULT(CHANNEL_RC_OK, pulse->receive, &pulse->format, data, length, pulse->user_data);
+ error =
+ IFCALLRESULT(CHANNEL_RC_OK, pulse->receive, &pulse->format, data, length, pulse->user_data);
pa_stream_drop(stream);
if (error && pulse->rdpcontext)
setChannelError(pulse->rdpcontext, error, "audin_pulse_thread_func reported an error");
}
-
/**
* Function description
*
@@ -321,7 +319,7 @@ static void audin_pulse_stream_request_callback(pa_stream* stream, size_t length
*/
static UINT audin_pulse_close(IAudinDevice* device)
{
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse)
return ERROR_INVALID_PARAMETER;
@@ -349,7 +347,7 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
{
pa_stream_state_t state;
pa_buffer_attr buffer_attr = { 0 };
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
if (!pulse || !receive || !user_data)
return ERROR_INVALID_PARAMETER;
@@ -363,8 +361,7 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
pulse->receive = receive;
pulse->user_data = user_data;
pa_threaded_mainloop_lock(pulse->mainloop);
- pulse->stream = pa_stream_new(pulse->context, "freerdp_audin",
- &pulse->sample_spec, NULL);
+ pulse->stream = pa_stream_new(pulse->context, "freerdp_audin", &pulse->sample_spec, NULL);
if (!pulse->stream)
{
@@ -375,24 +372,21 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
}
pulse->bytes_per_frame = pa_frame_size(&pulse->sample_spec);
- pa_stream_set_state_callback(pulse->stream,
- audin_pulse_stream_state_callback, pulse);
- pa_stream_set_read_callback(pulse->stream,
- audin_pulse_stream_request_callback, pulse);
- buffer_attr.maxlength = (UINT32) - 1;
- buffer_attr.tlength = (UINT32) - 1;
- buffer_attr.prebuf = (UINT32) - 1;
- buffer_attr.minreq = (UINT32) - 1;
+ pa_stream_set_state_callback(pulse->stream, audin_pulse_stream_state_callback, pulse);
+ pa_stream_set_read_callback(pulse->stream, audin_pulse_stream_request_callback, pulse);
+ buffer_attr.maxlength = (UINT32)-1;
+ buffer_attr.tlength = (UINT32)-1;
+ buffer_attr.prebuf = (UINT32)-1;
+ buffer_attr.minreq = (UINT32)-1;
/* 500ms latency */
buffer_attr.fragsize = pulse->bytes_per_frame * pulse->frames_per_packet;
if (buffer_attr.fragsize % pulse->format.nBlockAlign)
- buffer_attr.fragsize += pulse->format.nBlockAlign - buffer_attr.fragsize %
- pulse->format.nBlockAlign;
+ buffer_attr.fragsize +=
+ pulse->format.nBlockAlign - buffer_attr.fragsize % pulse->format.nBlockAlign;
- if (pa_stream_connect_record(pulse->stream,
- pulse->device_name,
- &buffer_attr, PA_STREAM_ADJUST_LATENCY) < 0)
+ if (pa_stream_connect_record(pulse->stream, pulse->device_name, &buffer_attr,
+ PA_STREAM_ADJUST_LATENCY) < 0)
{
pa_threaded_mainloop_unlock(pulse->mainloop);
WLog_Print(pulse->log, WLOG_ERROR, "pa_stream_connect_playback failed (%d)",
@@ -435,16 +429,15 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* device, ADDIN_ARGV* a
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- AudinPulseDevice* pulse = (AudinPulseDevice*) device;
- COMMAND_LINE_ARGUMENT_A audin_pulse_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ AudinPulseDevice* pulse = (AudinPulseDevice*)device;
+ COMMAND_LINE_ARGUMENT_A audin_pulse_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio device name" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv, audin_pulse_args, flags,
- pulse, NULL, NULL);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, audin_pulse_args, flags, pulse,
+ NULL, NULL);
if (status < 0)
return ERROR_INVALID_PARAMETER;
@@ -456,8 +449,7 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* device, ADDIN_ARGV* a
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
pulse->device_name = _strdup(arg->Value);
@@ -468,16 +460,15 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* device, ADDIN_ARGV* a
}
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry pulse_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry pulse_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
/**
@@ -490,7 +481,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
ADDIN_ARGV* args;
AudinPulseDevice* pulse;
UINT error;
- pulse = (AudinPulseDevice*) calloc(1, sizeof(AudinPulseDevice));
+ pulse = (AudinPulseDevice*)calloc(1, sizeof(AudinPulseDevice));
if (!pulse)
{
@@ -509,8 +500,8 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
if ((error = audin_pulse_parse_addin_args(pulse, args)))
{
- WLog_Print(pulse->log, WLOG_ERROR, "audin_pulse_parse_addin_args failed with error %"PRIu32"!",
- error);
+ WLog_Print(pulse->log, WLOG_ERROR,
+ "audin_pulse_parse_addin_args failed with error %" PRIu32 "!", error);
goto error_out;
}
@@ -534,15 +525,16 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
pa_context_set_state_callback(pulse->context, audin_pulse_context_state_callback, pulse);
- if ((error = audin_pulse_connect((IAudinDevice*) pulse)))
+ if ((error = audin_pulse_connect((IAudinDevice*)pulse)))
{
WLog_Print(pulse->log, WLOG_ERROR, "audin_pulse_connect failed");
goto error_out;
}
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) pulse)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)pulse)))
{
- WLog_Print(pulse->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_Print(pulse->log, WLOG_ERROR, "RegisterAudinDevice failed with error %" PRIu32 "!",
+ error);
goto error_out;
}
@@ -551,4 +543,3 @@ error_out:
audin_pulse_free((IAudinDevice*)pulse);
return error;
}
-
diff --git a/channels/audin/client/winmm/audin_winmm.c b/channels/audin/client/winmm/audin_winmm.c
index 495c9e18c..68e355fd5 100644
--- a/channels/audin/client/winmm/audin_winmm.c
+++ b/channels/audin/client/winmm/audin_winmm.c
@@ -59,7 +59,7 @@ typedef struct _AudinWinmmDevice
static void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance,
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) dwInstance;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)dwInstance;
PWAVEHDR pWaveHdr;
UINT error = CHANNEL_RC_OK;
MMRESULT mmResult;
@@ -74,8 +74,8 @@ static void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance
if (WHDR_DONE == (WHDR_DONE & pWaveHdr->dwFlags))
{
- if (pWaveHdr->dwBytesRecorded
- && !(WaitForSingleObject(winmm->stopEvent, 0) == WAIT_OBJECT_0))
+ if (pWaveHdr->dwBytesRecorded &&
+ !(WaitForSingleObject(winmm->stopEvent, 0) == WAIT_OBJECT_0))
{
AUDIO_FORMAT format;
format.cbSize = winmm->pwfx_cur->cbSize;
@@ -86,8 +86,8 @@ static void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance
format.wBitsPerSample = winmm->pwfx_cur->wBitsPerSample;
format.wFormatTag = winmm->pwfx_cur->wFormatTag;
- if ((error = winmm->receive(&format, pWaveHdr->lpData, pWaveHdr->dwBytesRecorded,
- winmm->user_data)))
+ if ((error = winmm->receive(&format, pWaveHdr->lpData,
+ pWaveHdr->dwBytesRecorded, winmm->user_data)))
break;
mmResult = waveInAddBuffer(hWaveIn, pWaveHdr, sizeof(WAVEHDR));
@@ -112,7 +112,7 @@ static void CALLBACK waveInProc(HWAVEIN hWaveIn, UINT uMsg, DWORD_PTR dwInstance
static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
{
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) arg;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)arg;
char* buffer;
int size, i;
WAVEHDR waveHdr[4];
@@ -122,7 +122,8 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (!winmm->hWaveIn)
{
if (MMSYSERR_NOERROR != waveInOpen(&winmm->hWaveIn, WAVE_MAPPER, winmm->pwfx_cur,
- (DWORD_PTR)waveInProc, (DWORD_PTR)winmm, CALLBACK_FUNCTION))
+ (DWORD_PTR)waveInProc, (DWORD_PTR)winmm,
+ CALLBACK_FUNCTION))
{
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -132,12 +133,14 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
}
}
- size = (winmm->pwfx_cur->wBitsPerSample * winmm->pwfx_cur->nChannels * winmm->frames_per_packet +
- 7) / 8;
+ size =
+ (winmm->pwfx_cur->wBitsPerSample * winmm->pwfx_cur->nChannels * winmm->frames_per_packet +
+ 7) /
+ 8;
for (i = 0; i < 4; i++)
{
- buffer = (char*) malloc(size);
+ buffer = (char*)malloc(size);
if (!buffer)
return CHANNEL_RC_NO_MEMORY;
@@ -149,7 +152,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInPrepareHeader failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInPrepareHeader failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -160,7 +163,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInAddBuffer failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInAddBuffer failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -172,7 +175,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInStart failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInStart failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -194,7 +197,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInReset failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInReset failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -207,7 +210,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInUnprepareHeader failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInUnprepareHeader failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -221,7 +224,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
if (MMSYSERR_NOERROR != rc)
{
- WLog_Print(winmm->log, WLOG_DEBUG, "waveInClose failed. %"PRIu32"", rc);
+ WLog_Print(winmm->log, WLOG_DEBUG, "waveInClose failed. %" PRIu32 "", rc);
if (winmm->rdpcontext)
setChannelError(winmm->rdpcontext, ERROR_INTERNAL_ERROR,
@@ -240,7 +243,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
static UINT audin_winmm_free(IAudinDevice* device)
{
UINT32 i;
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
if (!winmm)
return ERROR_INVALID_PARAMETER;
@@ -265,7 +268,7 @@ static UINT audin_winmm_close(IAudinDevice* device)
{
DWORD status;
UINT error = CHANNEL_RC_OK;
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
if (!winmm)
return ERROR_INVALID_PARAMETER;
@@ -276,7 +279,8 @@ static UINT audin_winmm_close(IAudinDevice* device)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_Print(winmm->log, WLOG_ERROR, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_Print(winmm->log, WLOG_ERROR, "WaitForSingleObject failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -298,7 +302,7 @@ static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
UINT32 FramesPerPacket)
{
UINT32 i;
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
if (!winmm || !format)
return ERROR_INVALID_PARAMETER;
@@ -307,9 +311,9 @@ static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
for (i = 0; i < winmm->cFormats; i++)
{
- if (winmm->ppwfx[i]->wFormatTag == format->wFormatTag
- && winmm->ppwfx[i]->nChannels == format->nChannels
- && winmm->ppwfx[i]->wBitsPerSample == format->wBitsPerSample)
+ if (winmm->ppwfx[i]->wFormatTag == format->wFormatTag &&
+ winmm->ppwfx[i]->nChannels == format->nChannels &&
+ winmm->ppwfx[i]->wBitsPerSample == format->wBitsPerSample)
{
winmm->pwfx_cur = winmm->ppwfx[i];
break;
@@ -321,7 +325,7 @@ static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* for
static BOOL audin_winmm_format_supported(IAudinDevice* device, const AUDIO_FORMAT* format)
{
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
PWAVEFORMATEX pwfx;
BYTE* data;
@@ -376,7 +380,7 @@ static BOOL audin_winmm_format_supported(IAudinDevice* device, const AUDIO_FORMA
*/
static UINT audin_winmm_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
if (!winmm || !receive || !user_data)
return ERROR_INVALID_PARAMETER;
@@ -390,8 +394,7 @@ static UINT audin_winmm_open(IAudinDevice* device, AudinReceive receive, void* u
return ERROR_INTERNAL_ERROR;
}
- if (!(winmm->thread = CreateThread(NULL, 0,
- audin_winmm_thread_func, winmm, 0, NULL)))
+ if (!(winmm->thread = CreateThread(NULL, 0, audin_winmm_thread_func, winmm, 0, NULL)))
{
WLog_Print(winmm->log, WLOG_ERROR, "CreateThread failed!");
CloseHandle(winmm->stopEvent);
@@ -412,16 +415,15 @@ static UINT audin_winmm_parse_addin_args(AudinWinmmDevice* device, ADDIN_ARGV* a
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- AudinWinmmDevice* winmm = (AudinWinmmDevice*) device;
- COMMAND_LINE_ARGUMENT_A audin_winmm_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
+ COMMAND_LINE_ARGUMENT_A audin_winmm_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio device name" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv, audin_winmm_args, flags,
- winmm, NULL, NULL);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, audin_winmm_args, flags, winmm,
+ NULL, NULL);
arg = audin_winmm_args;
do
@@ -429,8 +431,7 @@ static UINT audin_winmm_parse_addin_args(AudinWinmmDevice* device, ADDIN_ARGV* a
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
winmm->device_name = _strdup(arg->Value);
@@ -441,16 +442,15 @@ static UINT audin_winmm_parse_addin_args(AudinWinmmDevice* device, ADDIN_ARGV* a
}
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_audin_client_subsystem_entry winmm_freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry winmm_freerdp_audin_client_subsystem_entry
#else
-#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
+#define freerdp_audin_client_subsystem_entry FREERDP_API freerdp_audin_client_subsystem_entry
#endif
/**
@@ -463,7 +463,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
ADDIN_ARGV* args;
AudinWinmmDevice* winmm;
UINT error;
- winmm = (AudinWinmmDevice*) calloc(1, sizeof(AudinWinmmDevice));
+ winmm = (AudinWinmmDevice*)calloc(1, sizeof(AudinWinmmDevice));
if (!winmm)
{
@@ -482,8 +482,8 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
if ((error = audin_winmm_parse_addin_args(winmm, args)))
{
- WLog_Print(winmm->log, WLOG_ERROR, "audin_winmm_parse_addin_args failed with error %"PRIu32"!",
- error);
+ WLog_Print(winmm->log, WLOG_ERROR,
+ "audin_winmm_parse_addin_args failed with error %" PRIu32 "!", error);
goto error_out;
}
@@ -509,9 +509,10 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn
goto error_out;
}
- if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) winmm)))
+ if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*)winmm)))
{
- WLog_Print(winmm->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error);
+ WLog_Print(winmm->log, WLOG_ERROR, "RegisterAudinDevice failed with error %" PRIu32 "!",
+ error);
goto error_out;
}
diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c
index f5216676d..aa1979ce5 100644
--- a/channels/audin/server/audin.c
+++ b/channels/audin/server/audin.c
@@ -39,13 +39,13 @@
#include
#define TAG CHANNELS_TAG("audin.server")
-#define MSG_SNDIN_VERSION 0x01
-#define MSG_SNDIN_FORMATS 0x02
-#define MSG_SNDIN_OPEN 0x03
-#define MSG_SNDIN_OPEN_REPLY 0x04
-#define MSG_SNDIN_DATA_INCOMING 0x05
-#define MSG_SNDIN_DATA 0x06
-#define MSG_SNDIN_FORMATCHANGE 0x07
+#define MSG_SNDIN_VERSION 0x01
+#define MSG_SNDIN_FORMATS 0x02
+#define MSG_SNDIN_OPEN 0x03
+#define MSG_SNDIN_OPEN_REPLY 0x04
+#define MSG_SNDIN_DATA_INCOMING 0x05
+#define MSG_SNDIN_DATA 0x06
+#define MSG_SNDIN_FORMATCHANGE 0x07
typedef struct _audin_server
{
@@ -69,15 +69,13 @@ typedef struct _audin_server
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_server_select_format(audin_server_context* context,
- size_t client_format_index)
+static UINT audin_server_select_format(audin_server_context* context, size_t client_format_index)
{
- audin_server* audin = (audin_server*) context;
+ audin_server* audin = (audin_server*)context;
if (client_format_index >= context->num_client_formats)
{
- WLog_ERR(TAG,
- "error in protocol: client_format_index >= context->num_client_formats!");
+ WLog_ERR(TAG, "error in protocol: client_format_index >= context->num_client_formats!");
return ERROR_INVALID_DATA;
}
@@ -109,7 +107,7 @@ static UINT audin_server_send_version(audin_server* audin, wStream* s)
Stream_Write_UINT8(s, MSG_SNDIN_VERSION);
Stream_Write_UINT32(s, 1); /* Version (4 bytes) */
- if (!WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s),
+ if (!WTSVirtualChannelWrite(audin->audin_channel, (PCHAR)Stream_Buffer(s),
Stream_GetPosition(s), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
@@ -124,14 +122,13 @@ static UINT audin_server_send_version(audin_server* audin, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_server_recv_version(audin_server* audin, wStream* s,
- UINT32 length)
+static UINT audin_server_recv_version(audin_server* audin, wStream* s, UINT32 length)
{
UINT32 Version;
if (length < 4)
{
- WLog_ERR(TAG, "error parsing version info: expected at least 4 bytes, got %"PRIu32"",
+ WLog_ERR(TAG, "error parsing version info: expected at least 4 bytes, got %" PRIu32 "",
length);
return ERROR_INVALID_DATA;
}
@@ -140,7 +137,7 @@ static UINT audin_server_recv_version(audin_server* audin, wStream* s,
if (Version < 1)
{
- WLog_ERR(TAG, "expected Version > 0 but got %"PRIu32"", Version);
+ WLog_ERR(TAG, "expected Version > 0 but got %" PRIu32 "", Version);
return ERROR_INVALID_DATA;
}
@@ -158,16 +155,15 @@ static UINT audin_server_send_formats(audin_server* audin, wStream* s)
ULONG written;
Stream_SetPosition(s, 0);
Stream_Write_UINT8(s, MSG_SNDIN_FORMATS);
- Stream_Write_UINT32(s,
- audin->context.num_server_formats); /* NumFormats (4 bytes) */
- Stream_Write_UINT32(s,
- 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */
+ Stream_Write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */
+ Stream_Write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */
for (i = 0; i < audin->context.num_server_formats; i++)
{
AUDIO_FORMAT format = audin->context.server_formats[i];
// TODO: Eliminate this
- format.nAvgBytesPerSec = format.nSamplesPerSec * format.nChannels * format.wBitsPerSample / 8;
+ format.nAvgBytesPerSec =
+ format.nSamplesPerSec * format.nChannels * format.wBitsPerSample / 8;
if (!audio_format_write(s, &format))
{
@@ -176,8 +172,10 @@ static UINT audin_server_send_formats(audin_server* audin, wStream* s)
}
}
- return WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s),
- Stream_GetPosition(s), &written) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
+ return WTSVirtualChannelWrite(audin->audin_channel, (PCHAR)Stream_Buffer(s),
+ Stream_GetPosition(s), &written)
+ ? CHANNEL_RC_OK
+ : ERROR_INTERNAL_ERROR;
}
/**
@@ -185,22 +183,20 @@ static UINT audin_server_send_formats(audin_server* audin, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_server_recv_formats(audin_server* audin, wStream* s,
- UINT32 length)
+static UINT audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 length)
{
size_t i;
UINT success = CHANNEL_RC_OK;
if (length < 8)
{
- WLog_ERR(TAG, "error parsing rec formats: expected at least 8 bytes, got %"PRIu32"",
+ WLog_ERR(TAG, "error parsing rec formats: expected at least 8 bytes, got %" PRIu32 "",
length);
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s,
- audin->context.num_client_formats); /* NumFormats (4 bytes) */
- Stream_Seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */
+ Stream_Read_UINT32(s, audin->context.num_client_formats); /* NumFormats (4 bytes) */
+ Stream_Seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */
length -= 8;
if (audin->context.num_client_formats <= 0)
@@ -223,7 +219,7 @@ static UINT audin_server_recv_formats(audin_server* audin, wStream* s,
{
audio_formats_free(audin->context.client_formats, i);
audin->context.client_formats = NULL;
- WLog_ERR(TAG, "expected length at least 18, but got %"PRIu32"", length);
+ WLog_ERR(TAG, "expected length at least 18, but got %" PRIu32 "", length);
return ERROR_INVALID_DATA;
}
@@ -233,7 +229,7 @@ static UINT audin_server_recv_formats(audin_server* audin, wStream* s,
IFCALLRET(audin->context.Opening, success, &audin->context);
if (success)
- WLog_ERR(TAG, "context.Opening failed with error %"PRIu32"", success);
+ WLog_ERR(TAG, "context.Opening failed with error %" PRIu32 "", success);
return success;
}
@@ -257,24 +253,24 @@ static UINT audin_server_send_open(audin_server* audin, wStream* s)
audin->opened = TRUE;
Stream_SetPosition(s, 0);
Stream_Write_UINT8(s, MSG_SNDIN_OPEN);
- Stream_Write_UINT32(s,
- audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */
- Stream_Write_UINT32(s,
- audin->context.selected_client_format); /* initialFormat (4 bytes) */
+ Stream_Write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */
+ Stream_Write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */
/*
* [MS-RDPEAI] 3.2.5.1.6
* The second format specify the format that SHOULD be used to capture data from
* the actual audio input device.
*/
- Stream_Write_UINT16(s, 1); /* wFormatTag = PCM */
- Stream_Write_UINT16(s, 2); /* nChannels */
- Stream_Write_UINT32(s, 44100); /* nSamplesPerSec */
+ Stream_Write_UINT16(s, 1); /* wFormatTag = PCM */
+ Stream_Write_UINT16(s, 2); /* nChannels */
+ Stream_Write_UINT32(s, 44100); /* nSamplesPerSec */
Stream_Write_UINT32(s, 44100 * 2 * 2); /* nAvgBytesPerSec */
- Stream_Write_UINT16(s, 4); /* nBlockAlign */
- Stream_Write_UINT16(s, 16); /* wBitsPerSample */
- Stream_Write_UINT16(s, 0); /* cbSize */
- return WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s),
- Stream_GetPosition(s), &written) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
+ Stream_Write_UINT16(s, 4); /* nBlockAlign */
+ Stream_Write_UINT16(s, 16); /* wBitsPerSample */
+ Stream_Write_UINT16(s, 0); /* cbSize */
+ return WTSVirtualChannelWrite(audin->audin_channel, (PCHAR)Stream_Buffer(s),
+ Stream_GetPosition(s), &written)
+ ? CHANNEL_RC_OK
+ : ERROR_INTERNAL_ERROR;
}
/**
@@ -282,15 +278,14 @@ static UINT audin_server_send_open(audin_server* audin, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_server_recv_open_reply(audin_server* audin, wStream* s,
- UINT32 length)
+static UINT audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 length)
{
UINT32 Result;
UINT success = CHANNEL_RC_OK;
if (length < 4)
{
- WLog_ERR(TAG, "error parsing version info: expected at least 4 bytes, got %"PRIu32"",
+ WLog_ERR(TAG, "error parsing version info: expected at least 4 bytes, got %" PRIu32 "",
length);
return ERROR_INVALID_DATA;
}
@@ -299,7 +294,7 @@ static UINT audin_server_recv_open_reply(audin_server* audin, wStream* s,
IFCALLRET(audin->context.OpenResult, success, &audin->context, Result);
if (success)
- WLog_ERR(TAG, "context.OpenResult failed with error %"PRIu32"", success);
+ WLog_ERR(TAG, "context.OpenResult failed with error %" PRIu32 "", success);
return success;
}
@@ -309,8 +304,7 @@ static UINT audin_server_recv_open_reply(audin_server* audin, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT audin_server_recv_data(audin_server* audin, wStream* s,
- UINT32 length)
+static UINT audin_server_recv_data(audin_server* audin, wStream* s, UINT32 length)
{
AUDIO_FORMAT* format;
int sbytes_per_sample;
@@ -346,7 +340,7 @@ static UINT audin_server_recv_data(audin_server* audin, wStream* s,
IFCALLRET(audin->context.ReceiveSamples, success, &audin->context, &dformat, out, frames);
if (success)
- WLog_ERR(TAG, "context.ReceiveSamples failed with error %"PRIu32"", success);
+ WLog_ERR(TAG, "context.ReceiveSamples failed with error %" PRIu32 "", success);
}
else
WLog_ERR(TAG, "freerdp_dsp_decode failed!");
@@ -365,7 +359,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
BOOL ready = FALSE;
HANDLE ChannelEvent;
DWORD BytesReturned = 0;
- audin_server* audin = (audin_server*) arg;
+ audin_server* audin = (audin_server*)arg;
UINT error = CHANNEL_RC_OK;
DWORD status;
buffer = NULL;
@@ -395,26 +389,25 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
while (1)
{
- if ((status = WaitForMultipleObjects(nCount, events, FALSE,
- 100)) == WAIT_OBJECT_0)
+ if ((status = WaitForMultipleObjects(nCount, events, FALSE, 100)) == WAIT_OBJECT_0)
goto out;
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
goto out;
}
- if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualChannelReady,
- &buffer, &BytesReturned) == FALSE)
+ if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualChannelReady, &buffer,
+ &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSVirtualChannelQuery failed");
error = ERROR_INTERNAL_ERROR;
goto out;
}
- ready = *((BOOL*) buffer);
+ ready = *((BOOL*)buffer);
WTSFreeMemory(buffer);
if (ready)
@@ -434,21 +427,20 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
{
if ((error = audin_server_send_version(audin, s)))
{
- WLog_ERR(TAG, "audin_server_send_version failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_send_version failed with error %" PRIu32 "!", error);
goto out_capacity;
}
}
while (ready)
{
- if ((status = WaitForMultipleObjects(nCount, events, FALSE,
- INFINITE)) == WAIT_OBJECT_0)
+ if ((status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE)) == WAIT_OBJECT_0)
break;
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
goto out;
}
@@ -467,7 +459,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
if (!Stream_EnsureRemainingCapacity(s, BytesReturned))
break;
- if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR) Stream_Buffer(s),
+ if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
@@ -483,13 +475,15 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
case MSG_SNDIN_VERSION:
if ((error = audin_server_recv_version(audin, s, BytesReturned)))
{
- WLog_ERR(TAG, "audin_server_recv_version failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_recv_version failed with error %" PRIu32 "!",
+ error);
goto out_capacity;
}
if ((error = audin_server_send_formats(audin, s)))
{
- WLog_ERR(TAG, "audin_server_send_formats failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_send_formats failed with error %" PRIu32 "!",
+ error);
goto out_capacity;
}
@@ -498,13 +492,14 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
case MSG_SNDIN_FORMATS:
if ((error = audin_server_recv_formats(audin, s, BytesReturned)))
{
- WLog_ERR(TAG, "audin_server_recv_formats failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_recv_formats failed with error %" PRIu32 "!",
+ error);
goto out_capacity;
}
if ((error = audin_server_send_open(audin, s)))
{
- WLog_ERR(TAG, "audin_server_send_open failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_send_open failed with error %" PRIu32 "!", error);
goto out_capacity;
}
@@ -513,7 +508,8 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
case MSG_SNDIN_OPEN_REPLY:
if ((error = audin_server_recv_open_reply(audin, s, BytesReturned)))
{
- WLog_ERR(TAG, "audin_server_recv_open_reply failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_recv_open_reply failed with error %" PRIu32 "!",
+ error);
goto out_capacity;
}
@@ -525,7 +521,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
case MSG_SNDIN_DATA:
if ((error = audin_server_recv_data(audin, s, BytesReturned)))
{
- WLog_ERR(TAG, "audin_server_recv_data failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "audin_server_recv_data failed with error %" PRIu32 "!", error);
goto out_capacity;
};
@@ -535,7 +531,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
break;
default:
- WLog_ERR(TAG, "audin_server_thread_func: unknown MessageId %"PRIu8"", MessageId);
+ WLog_ERR(TAG, "audin_server_thread_func: unknown MessageId %" PRIu8 "", MessageId);
break;
}
}
@@ -556,7 +552,7 @@ out:
static BOOL audin_server_open(audin_server_context* context)
{
- audin_server* audin = (audin_server*) context;
+ audin_server* audin = (audin_server*)context;
if (!audin->thread)
{
@@ -564,15 +560,15 @@ static BOOL audin_server_open(audin_server_context* context)
DWORD BytesReturned = 0;
audin->SessionId = WTS_CURRENT_SESSION;
- if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION,
- WTSSessionId, (LPSTR*) &pSessionId, &BytesReturned))
+ if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION, WTSSessionId,
+ (LPSTR*)&pSessionId, &BytesReturned))
{
- audin->SessionId = (DWORD) * pSessionId;
+ audin->SessionId = (DWORD)*pSessionId;
WTSFreeMemory(pSessionId);
}
- audin->audin_channel = WTSVirtualChannelOpenEx(audin->SessionId,
- "AUDIO_INPUT", WTS_CHANNEL_OPTION_DYNAMIC);
+ audin->audin_channel =
+ WTSVirtualChannelOpenEx(audin->SessionId, "AUDIO_INPUT", WTS_CHANNEL_OPTION_DYNAMIC);
if (!audin->audin_channel)
{
@@ -586,7 +582,8 @@ static BOOL audin_server_open(audin_server_context* context)
return FALSE;
}
- if (!(audin->thread = CreateThread(NULL, 0, audin_server_thread_func, (void*) audin, 0, NULL)))
+ if (!(audin->thread =
+ CreateThread(NULL, 0, audin_server_thread_func, (void*)audin, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(audin->stopEvent);
@@ -603,7 +600,7 @@ static BOOL audin_server_open(audin_server_context* context)
static BOOL audin_server_is_open(audin_server_context* context)
{
- audin_server* audin = (audin_server*) context;
+ audin_server* audin = (audin_server*)context;
if (!audin)
return FALSE;
@@ -613,7 +610,7 @@ static BOOL audin_server_is_open(audin_server_context* context)
static BOOL audin_server_close(audin_server_context* context)
{
- audin_server* audin = (audin_server*) context;
+ audin_server* audin = (audin_server*)context;
if (audin->thread)
{
@@ -621,7 +618,7 @@ static BOOL audin_server_close(audin_server_context* context)
if (WaitForSingleObject(audin->thread, INFINITE) == WAIT_FAILED)
{
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", GetLastError());
return FALSE;
}
@@ -668,12 +665,12 @@ audin_server_context* audin_server_context_new(HANDLE vcm)
return NULL;
}
- return (audin_server_context*) audin;
+ return (audin_server_context*)audin;
}
void audin_server_context_free(audin_server_context* context)
{
- audin_server* audin = (audin_server*) context;
+ audin_server* audin = (audin_server*)context;
if (!audin)
return;
diff --git a/channels/client/addin.c b/channels/client/addin.c
index d3b81b16e..d7c4d9dce 100644
--- a/channels/client/addin.c
+++ b/channels/client/addin.c
@@ -44,20 +44,20 @@
extern const STATIC_ENTRY_TABLE CLIENT_STATIC_ENTRY_TABLES[];
void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* table,
- const char* identifier)
+ const char* identifier)
{
int index = 0;
STATIC_ENTRY* pEntry;
- pEntry = (STATIC_ENTRY*) &table->table[index++];
+ pEntry = (STATIC_ENTRY*)&table->table[index++];
while (pEntry->entry != NULL)
{
if (strcmp(pEntry->name, identifier) == 0)
{
- return (void*) pEntry->entry;
+ return (void*)pEntry->entry;
}
- pEntry = (STATIC_ENTRY*) &table->table[index++];
+ pEntry = (STATIC_ENTRY*)&table->table[index++];
}
return NULL;
@@ -67,7 +67,7 @@ void* freerdp_channels_client_find_static_entry(const char* name, const char* id
{
int index = 0;
STATIC_ENTRY_TABLE* pEntry;
- pEntry = (STATIC_ENTRY_TABLE*) &CLIENT_STATIC_ENTRY_TABLES[index++];
+ pEntry = (STATIC_ENTRY_TABLE*)&CLIENT_STATIC_ENTRY_TABLES[index++];
while (pEntry->table != NULL)
{
@@ -76,7 +76,7 @@ void* freerdp_channels_client_find_static_entry(const char* name, const char* id
return freerdp_channels_find_static_entry_in_table(pEntry, identifier);
}
- pEntry = (STATIC_ENTRY_TABLE*) &CLIENT_STATIC_ENTRY_TABLES[index++];
+ pEntry = (STATIC_ENTRY_TABLE*)&CLIENT_STATIC_ENTRY_TABLES[index++];
}
return NULL;
@@ -84,15 +84,16 @@ void* freerdp_channels_client_find_static_entry(const char* name, const char* id
extern const STATIC_ADDIN_TABLE CLIENT_STATIC_ADDIN_TABLE[];
-static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName, LPCSTR pszSubsystem,
- LPCSTR pszType, DWORD dwFlags)
+static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName,
+ LPCSTR pszSubsystem,
+ LPCSTR pszType, DWORD dwFlags)
{
size_t i, j;
DWORD nAddins;
FREERDP_ADDIN** ppAddins = NULL;
STATIC_SUBSYSTEM_ENTRY* subsystems;
nAddins = 0;
- ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));
+ ppAddins = (FREERDP_ADDIN**)calloc(128, sizeof(FREERDP_ADDIN*));
if (!ppAddins)
{
@@ -104,7 +105,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
for (i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++)
{
- FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*) calloc(1, sizeof(FREERDP_ADDIN));
+ FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
if (!pAddin)
{
@@ -117,11 +118,11 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;
pAddin->dwFlags |= FREERDP_ADDIN_NAME;
ppAddins[nAddins++] = pAddin;
- subsystems = (STATIC_SUBSYSTEM_ENTRY*) CLIENT_STATIC_ADDIN_TABLE[i].table;
+ subsystems = (STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table;
for (j = 0; subsystems[j].name != NULL; j++)
{
- pAddin = (FREERDP_ADDIN*) calloc(1, sizeof(FREERDP_ADDIN));
+ pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
if (!pAddin)
{
@@ -129,7 +130,8 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
goto error_out;
}
- sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", CLIENT_STATIC_ADDIN_TABLE[i].name);
+ sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s",
+ CLIENT_STATIC_ADDIN_TABLE[i].name);
sprintf_s(pAddin->cSubsystem, ARRAYSIZE(pAddin->cSubsystem), "%s", subsystems[j].name);
pAddin->dwFlags = FREERDP_ADDIN_CLIENT;
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;
@@ -146,7 +148,7 @@ error_out:
}
static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCSTR pszSubsystem,
- LPCSTR pszType, DWORD dwFlags)
+ LPCSTR pszType, DWORD dwFlags)
{
int index;
int nDashes;
@@ -167,7 +169,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
cchInstallPrefix = strnlen(pszInstallPrefix, sizeof(FREERDP_INSTALL_PREFIX));
pszExtension = PathGetSharedLibraryExtensionA(0);
cchPattern = 128 + strnlen(pszExtension, MAX_PATH) + 2;
- pszPattern = (LPSTR) malloc(cchPattern + 1);
+ pszPattern = (LPSTR)malloc(cchPattern + 1);
if (!pszPattern)
{
@@ -177,28 +179,28 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
if (pszName && pszSubsystem && pszType)
{
- sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX"%s-client-%s-%s.%s",
+ sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX "%s-client-%s-%s.%s",
pszName, pszSubsystem, pszType, pszExtension);
}
else if (pszName && pszType)
{
- sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX"%s-client-?-%s.%s",
+ sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX "%s-client-?-%s.%s",
pszName, pszType, pszExtension);
}
else if (pszName)
{
- sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX"%s-client*.%s",
- pszName, pszExtension);
+ sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX "%s-client*.%s", pszName,
+ pszExtension);
}
else
{
- sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX"?-client*.%s",
+ sprintf_s(pszPattern, cchPattern, FREERDP_SHARED_LIBRARY_PREFIX "?-client*.%s",
pszExtension);
}
cchPattern = strnlen(pszPattern, cchPattern);
cchSearchPath = cchInstallPrefix + cchAddinPath + cchPattern + 3;
- pszSearchPath = (LPSTR) malloc(cchSearchPath + 1);
+ pszSearchPath = (LPSTR)malloc(cchSearchPath + 1);
if (!pszSearchPath)
{
@@ -215,7 +217,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
hFind = FindFirstFileA(pszSearchPath, &FindData);
free(pszSearchPath);
nAddins = 0;
- ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));
+ ppAddins = (FREERDP_ADDIN**)calloc(128, sizeof(FREERDP_ADDIN*));
if (!ppAddins)
{
@@ -232,7 +234,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
char* p[5];
FREERDP_ADDIN* pAddin;
nDashes = 0;
- pAddin = (FREERDP_ADDIN*) calloc(1, sizeof(FREERDP_ADDIN));
+ pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
if (!pAddin)
{
@@ -291,8 +293,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
{
free(pAddin);
}
- }
- while (FindNextFileA(hFind, &FindData));
+ } while (FindNextFileA(hFind, &FindData));
FindClose(hFind);
ppAddins[nAddins] = NULL;
@@ -304,7 +305,7 @@ error_out:
}
FREERDP_ADDIN** freerdp_channels_list_addins(LPCSTR pszName, LPCSTR pszSubsystem, LPCSTR pszType,
- DWORD dwFlags)
+ DWORD dwFlags)
{
if (dwFlags & FREERDP_ADDIN_STATIC)
return freerdp_channels_list_client_static_addins(pszName, pszSubsystem, pszType, dwFlags);
@@ -336,7 +337,7 @@ BOOL freerdp_channels_is_virtual_channel_entry_ex(LPCSTR pszName)
for (i = 0; CLIENT_VirtualChannelEntryEx_TABLE[i].name != NULL; i++)
{
- entry = (STATIC_ENTRY*) &CLIENT_VirtualChannelEntryEx_TABLE[i];
+ entry = (STATIC_ENTRY*)&CLIENT_VirtualChannelEntryEx_TABLE[i];
if (!strcmp(entry->name, pszName))
return TRUE;
@@ -346,7 +347,7 @@ BOOL freerdp_channels_is_virtual_channel_entry_ex(LPCSTR pszName)
}
PVIRTUALCHANNELENTRY freerdp_channels_load_static_addin_entry(LPCSTR pszName, LPCSTR pszSubsystem,
- LPCSTR pszType, DWORD dwFlags)
+ LPCSTR pszType, DWORD dwFlags)
{
const STATIC_ADDIN_TABLE* table = CLIENT_STATIC_ADDIN_TABLE;
for (; table->name != NULL; table++)
@@ -355,21 +356,23 @@ PVIRTUALCHANNELENTRY freerdp_channels_load_static_addin_entry(LPCSTR pszName, LP
{
if (pszSubsystem != NULL)
{
- const STATIC_SUBSYSTEM_ENTRY* subsystems = (const STATIC_SUBSYSTEM_ENTRY*) table->table;
+ const STATIC_SUBSYSTEM_ENTRY* subsystems =
+ (const STATIC_SUBSYSTEM_ENTRY*)table->table;
for (; subsystems->name != NULL; subsystems++)
{
/* If the pszSubsystem is an empty string use the default backend. */
- if ((strlen(pszSubsystem) == 0) || (strcmp(subsystems->name, pszSubsystem) == 0))
+ if ((strlen(pszSubsystem) == 0) ||
+ (strcmp(subsystems->name, pszSubsystem) == 0))
{
if (pszType)
{
if (strcmp(subsystems->type, pszType) == 0)
- return (PVIRTUALCHANNELENTRY) subsystems->entry;
+ return (PVIRTUALCHANNELENTRY)subsystems->entry;
}
else
{
- return (PVIRTUALCHANNELENTRY) subsystems->entry;
+ return (PVIRTUALCHANNELENTRY)subsystems->entry;
}
}
}
@@ -382,7 +385,7 @@ PVIRTUALCHANNELENTRY freerdp_channels_load_static_addin_entry(LPCSTR pszName, LP
return NULL;
}
- return (PVIRTUALCHANNELENTRY) table->entry;
+ return (PVIRTUALCHANNELENTRY)table->entry;
}
}
}
diff --git a/channels/client/addin.h b/channels/client/addin.h
index f3ad9702a..849b11f29 100644
--- a/channels/client/addin.h
+++ b/channels/client/addin.h
@@ -16,5 +16,3 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
diff --git a/channels/client/tables.h b/channels/client/tables.h
index c84298a7f..378021073 100644
--- a/channels/client/tables.h
+++ b/channels/client/tables.h
@@ -22,7 +22,7 @@
struct _STATIC_ENTRY
{
const char* name;
- UINT(*entry)();
+ UINT (*entry)();
};
typedef struct _STATIC_ENTRY STATIC_ENTRY;
@@ -44,7 +44,7 @@ typedef struct _STATIC_SUBSYSTEM_ENTRY STATIC_SUBSYSTEM_ENTRY;
struct _STATIC_ADDIN_TABLE
{
const char* name;
- UINT(*entry)();
+ UINT (*entry)();
const STATIC_SUBSYSTEM_ENTRY* table;
};
typedef struct _STATIC_ADDIN_TABLE STATIC_ADDIN_TABLE;
diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c
index 151aef188..e2ab39ad8 100644
--- a/channels/cliprdr/client/cliprdr_format.c
+++ b/channels/cliprdr/client/cliprdr_format.c
@@ -40,7 +40,8 @@
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
+UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags)
{
CLIPRDR_FORMAT_LIST formatList;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -59,13 +60,13 @@ UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
if ((error = cliprdr_read_format_list(s, &formatList, cliprdr->useLongFormatNames)))
goto error_out;
- WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatList: numFormats: %"PRIu32"",
- formatList.numFormats);
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatList: numFormats: %" PRIu32 "",
+ formatList.numFormats);
if (context->ServerFormatList)
{
if ((error = context->ServerFormatList(context, &formatList)))
- WLog_ERR(TAG, "ServerFormatList failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "ServerFormatList failed with error %" PRIu32 "", error);
}
error_out:
@@ -78,7 +79,8 @@ error_out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
+UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags)
{
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -98,7 +100,7 @@ UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UI
IFCALLRET(context->ServerFormatListResponse, error, context, &formatListResponse);
if (error)
- WLog_ERR(TAG, "ServerFormatListResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerFormatListResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -108,7 +110,8 @@ UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UI
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
+UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags)
{
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -132,7 +135,7 @@ UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UIN
context->lastRequestedFormatId = formatDataRequest.requestedFormatId;
IFCALLRET(context->ServerFormatDataRequest, error, context, &formatDataRequest);
if (error)
- WLog_ERR(TAG, "ServerFormatDataRequest failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerFormatDataRequest failed with error %" PRIu32 "!", error);
return error;
}
@@ -142,7 +145,8 @@ UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UIN
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
+UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags)
{
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -165,7 +169,7 @@ UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UI
IFCALLRET(context->ServerFormatDataResponse, error, context, &formatDataResponse);
if (error)
- WLog_ERR(TAG, "ServerFormatDataResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerFormatDataResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -173,17 +177,17 @@ UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UI
static UINT64 filetime_to_uint64(FILETIME value)
{
UINT64 converted = 0;
- converted |= (UINT32) value.dwHighDateTime;
+ converted |= (UINT32)value.dwHighDateTime;
converted <<= 32;
- converted |= (UINT32) value.dwLowDateTime;
+ converted |= (UINT32)value.dwLowDateTime;
return converted;
}
static FILETIME uint64_to_filetime(UINT64 value)
{
FILETIME converted;
- converted.dwLowDateTime = (UINT32) (value >> 0);
- converted.dwHighDateTime = (UINT32) (value >> 32);
+ converted.dwLowDateTime = (UINT32)(value >> 0);
+ converted.dwHighDateTime = (UINT32)(value >> 32);
return converted;
}
@@ -202,7 +206,7 @@ static FILETIME uint64_to_filetime(UINT64 value)
* @returns 0 on success, otherwise a Win32 error code.
*/
UINT cliprdr_parse_file_list(const BYTE* format_data, UINT32 format_data_length,
- FILEDESCRIPTOR** file_descriptor_array, UINT32* file_descriptor_count)
+ FILEDESCRIPTOR** file_descriptor_array, UINT32* file_descriptor_count)
{
UINT result = NO_ERROR;
UINT32 i;
@@ -212,7 +216,7 @@ UINT cliprdr_parse_file_list(const BYTE* format_data, UINT32 format_data_length,
if (!format_data || !file_descriptor_array || !file_descriptor_count)
return ERROR_BAD_ARGUMENTS;
- s = Stream_New((BYTE*) format_data, format_data_length);
+ s = Stream_New((BYTE*)format_data, format_data_length);
if (!s)
return ERROR_NOT_ENOUGH_MEMORY;
@@ -228,9 +232,8 @@ UINT cliprdr_parse_file_list(const BYTE* format_data, UINT32 format_data_length,
if (Stream_GetRemainingLength(s) / CLIPRDR_FILEDESCRIPTOR_SIZE < count)
{
- WLog_ERR(TAG, "packed file list is too short: expected %"PRIuz", have %"PRIuz,
- ((size_t) count) * CLIPRDR_FILEDESCRIPTOR_SIZE,
- Stream_GetRemainingLength(s));
+ WLog_ERR(TAG, "packed file list is too short: expected %" PRIuz ", have %" PRIuz,
+ ((size_t)count) * CLIPRDR_FILEDESCRIPTOR_SIZE, Stream_GetRemainingLength(s));
result = ERROR_INCORRECT_SIZE;
goto out;
@@ -250,21 +253,21 @@ UINT cliprdr_parse_file_list(const BYTE* format_data, UINT32 format_data_length,
UINT64 lastWriteTime;
FILEDESCRIPTOR* file = &((*file_descriptor_array)[i]);
- Stream_Read_UINT32(s, file->dwFlags); /* flags (4 bytes) */
- Stream_Seek(s, 32); /* reserved1 (32 bytes) */
+ Stream_Read_UINT32(s, file->dwFlags); /* flags (4 bytes) */
+ Stream_Seek(s, 32); /* reserved1 (32 bytes) */
Stream_Read_UINT32(s, file->dwFileAttributes); /* fileAttributes (4 bytes) */
- Stream_Seek(s, 16); /* reserved2 (16 bytes) */
- Stream_Read_UINT64(s, lastWriteTime); /* lastWriteTime (8 bytes) */
+ Stream_Seek(s, 16); /* reserved2 (16 bytes) */
+ Stream_Read_UINT64(s, lastWriteTime); /* lastWriteTime (8 bytes) */
file->ftLastWriteTime = uint64_to_filetime(lastWriteTime);
Stream_Read_UINT32(s, file->nFileSizeHigh); /* fileSizeHigh (4 bytes) */
- Stream_Read_UINT32(s, file->nFileSizeLow); /* fileSizeLow (4 bytes) */
- for (c = 0; c < 260; c++) /* cFileName (520 bytes) */
+ Stream_Read_UINT32(s, file->nFileSizeLow); /* fileSizeLow (4 bytes) */
+ for (c = 0; c < 260; c++) /* cFileName (520 bytes) */
Stream_Read_UINT16(s, file->cFileName[c]);
}
if (Stream_GetRemainingLength(s) > 0)
- WLog_WARN(TAG, "packed file list has %"PRIuz" excess bytes",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "packed file list has %" PRIuz " excess bytes",
+ Stream_GetRemainingLength(s));
out:
Stream_Free(s, FALSE);
@@ -286,7 +289,8 @@ out:
* @returns 0 on success, otherwise a Win32 error code.
*/
UINT cliprdr_serialize_file_list(const FILEDESCRIPTOR* file_descriptor_array,
- UINT32 file_descriptor_count, BYTE** format_data, UINT32* format_data_length)
+ UINT32 file_descriptor_count, BYTE** format_data,
+ UINT32* format_data_length)
{
UINT result = NO_ERROR;
UINT32 i;
@@ -321,15 +325,15 @@ UINT cliprdr_serialize_file_list(const FILEDESCRIPTOR* file_descriptor_array,
goto error;
}
- Stream_Write_UINT32(s, file->dwFlags); /* flags (4 bytes) */
- Stream_Zero(s, 32); /* reserved1 (32 bytes) */
+ Stream_Write_UINT32(s, file->dwFlags); /* flags (4 bytes) */
+ Stream_Zero(s, 32); /* reserved1 (32 bytes) */
Stream_Write_UINT32(s, file->dwFileAttributes); /* fileAttributes (4 bytes) */
- Stream_Zero(s, 16); /* reserved2 (16 bytes) */
+ Stream_Zero(s, 16); /* reserved2 (16 bytes) */
lastWriteTime = filetime_to_uint64(file->ftLastWriteTime);
- Stream_Write_UINT64(s, lastWriteTime); /* lastWriteTime (8 bytes) */
+ Stream_Write_UINT64(s, lastWriteTime); /* lastWriteTime (8 bytes) */
Stream_Write_UINT32(s, file->nFileSizeHigh); /* fileSizeHigh (4 bytes) */
- Stream_Write_UINT32(s, file->nFileSizeLow); /* fileSizeLow (4 bytes) */
- for (c = 0; c < 260; c++) /* cFileName (520 bytes) */
+ Stream_Write_UINT32(s, file->nFileSizeLow); /* fileSizeLow (4 bytes) */
+ for (c = 0; c < 260; c++) /* cFileName (520 bytes) */
Stream_Write_UINT16(s, file->cFileName[c]);
}
diff --git a/channels/cliprdr/client/cliprdr_format.h b/channels/cliprdr/client/cliprdr_format.h
index dfe6965bb..a068d6ff4 100644
--- a/channels/cliprdr/client/cliprdr_format.h
+++ b/channels/cliprdr/client/cliprdr_format.h
@@ -23,9 +23,13 @@
#ifndef FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H
#define FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H
-UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
-UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
-UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
-UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
+UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags);
+UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags);
+UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags);
+UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
+ UINT16 msgFlags);
#endif /* FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H */
diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c
index e93f95628..9118b9c64 100644
--- a/channels/cliprdr/client/cliprdr_main.c
+++ b/channels/cliprdr/client/cliprdr_main.c
@@ -36,21 +36,18 @@
#include "../cliprdr_common.h"
#ifdef WITH_DEBUG_CLIPRDR
-static const char* const CB_MSG_TYPE_STRINGS[] =
-{
- "",
- "CB_MONITOR_READY",
- "CB_FORMAT_LIST",
- "CB_FORMAT_LIST_RESPONSE",
- "CB_FORMAT_DATA_REQUEST",
- "CB_FORMAT_DATA_RESPONSE",
- "CB_TEMP_DIRECTORY",
- "CB_CLIP_CAPS",
- "CB_FILECONTENTS_REQUEST",
- "CB_FILECONTENTS_RESPONSE",
- "CB_LOCK_CLIPDATA",
- "CB_UNLOCK_CLIPDATA"
-};
+static const char* const CB_MSG_TYPE_STRINGS[] = { "",
+ "CB_MONITOR_READY",
+ "CB_FORMAT_LIST",
+ "CB_FORMAT_LIST_RESPONSE",
+ "CB_FORMAT_DATA_REQUEST",
+ "CB_FORMAT_DATA_RESPONSE",
+ "CB_TEMP_DIRECTORY",
+ "CB_CLIP_CAPS",
+ "CB_FILECONTENTS_REQUEST",
+ "CB_FILECONTENTS_RESPONSE",
+ "CB_LOCK_CLIPDATA",
+ "CB_UNLOCK_CLIPDATA" };
#endif
CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr)
@@ -60,7 +57,7 @@ CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr)
if (!cliprdr)
return NULL;
- pInterface = (CliprdrClientContext*) cliprdr->channelEntryPoints.pInterface;
+ pInterface = (CliprdrClientContext*)cliprdr->channelEntryPoints.pInterface;
return pInterface;
}
@@ -80,7 +77,7 @@ static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
Stream_Write_UINT32(s, dataLen);
Stream_SetPosition(s, pos);
#ifdef WITH_DEBUG_CLIPRDR
- WLog_DBG(TAG, "Cliprdr Sending (%"PRIu32" bytes)", dataLen + 8);
+ WLog_DBG(TAG, "Cliprdr Sending (%" PRIu32 " bytes)", dataLen + 8);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
#endif
@@ -90,15 +87,15 @@ static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
}
else
{
- status = cliprdr->channelEntryPoints.pVirtualChannelWriteEx(cliprdr->InitHandle,
- cliprdr->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
+ status = cliprdr->channelEntryPoints.pVirtualChannelWriteEx(
+ cliprdr->InitHandle, cliprdr->OpenHandle, Stream_Buffer(s),
+ (UINT32)Stream_GetPosition(s), s);
}
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -108,21 +105,21 @@ static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
#ifdef WITH_DEBUG_CLIPRDR
static void cliprdr_print_general_capability_flags(UINT32 flags)
{
- WLog_INFO(TAG, "generalFlags (0x%08"PRIX32") {", flags);
+ WLog_INFO(TAG, "generalFlags (0x%08" PRIX32 ") {", flags);
if (flags & CB_USE_LONG_FORMAT_NAMES)
- WLog_INFO(TAG, "\tCB_USE_LONG_FORMAT_NAMES");
+ WLog_INFO(TAG, "\tCB_USE_LONG_FORMAT_NAMES");
if (flags & CB_STREAM_FILECLIP_ENABLED)
- WLog_INFO(TAG, "\tCB_STREAM_FILECLIP_ENABLED");
+ WLog_INFO(TAG, "\tCB_STREAM_FILECLIP_ENABLED");
if (flags & CB_FILECLIP_NO_FILE_PATHS)
- WLog_INFO(TAG, "\tCB_FILECLIP_NO_FILE_PATHS");
+ WLog_INFO(TAG, "\tCB_FILECLIP_NO_FILE_PATHS");
if (flags & CB_CAN_LOCK_CLIPDATA)
- WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA");
+ WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA");
- WLog_INFO(TAG, "}");
+ WLog_INFO(TAG, "}");
}
#endif
@@ -131,8 +128,7 @@ static void cliprdr_print_general_capability_flags(UINT32 flags)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
- wStream* s)
+static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* s)
{
UINT32 version;
UINT32 generalFlags;
@@ -150,9 +146,9 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
if (Stream_GetRemainingLength(s) < 8)
return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, version); /* version (4 bytes) */
+ Stream_Read_UINT32(s, version); /* version (4 bytes) */
Stream_Read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */
- DEBUG_CLIPRDR("Version: %"PRIu32"", version);
+ DEBUG_CLIPRDR("Version: %" PRIu32 "", version);
#ifdef WITH_DEBUG_CLIPRDR
cliprdr_print_general_capability_flags(generalFlags);
#endif
@@ -171,8 +167,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
capabilities.msgType = CB_CLIP_CAPS;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
- (generalCapabilitySet);
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = version;
@@ -180,7 +175,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
IFCALLRET(context->ServerCapabilities, error, context, &capabilities);
if (error)
- WLog_ERR(TAG, "ServerCapabilities failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerCapabilities failed with error %" PRIu32 "!", error);
return error;
}
@@ -190,8 +185,8 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
- UINT32 length, UINT16 flags)
+static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
UINT16 index;
UINT16 lengthCapability;
@@ -203,7 +198,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
return ERROR_INVALID_DATA;
Stream_Read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
- Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
+ Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerCapabilities");
for (index = 0; index < cCapabilitiesSets; index++)
@@ -212,7 +207,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
return ERROR_INVALID_DATA;
Stream_Read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */
- Stream_Read_UINT16(s, lengthCapability); /* lengthCapability (2 bytes) */
+ Stream_Read_UINT16(s, lengthCapability); /* lengthCapability (2 bytes) */
if ((lengthCapability < 4) || (Stream_GetRemainingLength(s) < (lengthCapability - 4U)))
return ERROR_INVALID_DATA;
@@ -222,7 +217,8 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
case CB_CAPSTYPE_GENERAL:
if ((error = cliprdr_process_general_capability(cliprdr, s)))
{
- WLog_ERR(TAG, "cliprdr_process_general_capability failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "cliprdr_process_general_capability failed with error %" PRIu32 "!",
error);
return error;
}
@@ -230,7 +226,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
break;
default:
- WLog_ERR(TAG, "unknown cliprdr capability set: %"PRIu16"", capabilitySetType);
+ WLog_ERR(TAG, "unknown cliprdr capability set: %" PRIu16 "", capabilitySetType);
return CHANNEL_RC_BAD_PROC;
}
}
@@ -243,8 +239,8 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
- UINT32 length, UINT16 flags)
+static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
CLIPRDR_MONITOR_READY monitorReady;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -260,11 +256,11 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
if (!cliprdr->capabilitiesReceived)
{
/**
- * The clipboard capabilities pdu from server to client is optional,
- * but a server using it must send it before sending the monitor ready pdu.
- * When the server capabilities pdu is not used, default capabilities
- * corresponding to a generalFlags field set to zero are assumed.
- */
+ * The clipboard capabilities pdu from server to client is optional,
+ * but a server using it must send it before sending the monitor ready pdu.
+ * When the server capabilities pdu is not used, default capabilities
+ * corresponding to a generalFlags field set to zero are assumed.
+ */
cliprdr->useLongFormatNames = FALSE;
cliprdr->streamFileClipEnabled = FALSE;
cliprdr->fileClipNoFilePaths = TRUE;
@@ -277,7 +273,7 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
IFCALLRET(context->MonitorReady, error, context, &monitorReady);
if (error)
- WLog_ERR(TAG, "MonitorReady failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "MonitorReady failed with error %" PRIu32 "!", error);
return error;
}
@@ -287,8 +283,8 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
- wStream* s, UINT32 length, UINT16 flags)
+static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
CLIPRDR_FILE_CONTENTS_REQUEST request;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -311,7 +307,7 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
IFCALLRET(context->ServerFileContentsRequest, error, context, &request);
if (error)
- WLog_ERR(TAG, "ServerFileContentsRequest failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerFileContentsRequest failed with error %" PRIu32 "!", error);
return error;
}
@@ -321,8 +317,8 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr,
- wStream* s, UINT32 length, UINT16 flags)
+static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -345,7 +341,7 @@ static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr,
IFCALLRET(context->ServerFileContentsResponse, error, context, &response);
if (error)
- WLog_ERR(TAG, "ServerFileContentsResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerFileContentsResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -355,8 +351,8 @@ static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
- UINT32 length, UINT16 flags)
+static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -382,7 +378,7 @@ static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
IFCALLRET(context->ServerLockClipboardData, error, context, &lockClipboardData);
if (error)
- WLog_ERR(TAG, "ServerLockClipboardData failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerLockClipboardData failed with error %" PRIu32 "!", error);
return error;
}
@@ -392,8 +388,8 @@ static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
- UINT32 length, UINT16 flags)
+static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
+ UINT16 flags)
{
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
@@ -413,11 +409,10 @@ static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
unlockClipboardData.msgFlags = flags;
unlockClipboardData.dataLen = length;
- IFCALLRET(context->ServerUnlockClipboardData, error, context,
- &unlockClipboardData);
+ IFCALLRET(context->ServerUnlockClipboardData, error, context, &unlockClipboardData);
if (error)
- WLog_ERR(TAG, "ServerUnlockClipboardData failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerUnlockClipboardData failed with error %" PRIu32 "!", error);
return error;
}
@@ -437,15 +432,15 @@ static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
if (Stream_GetRemainingLength(s) < 8)
return ERROR_INVALID_DATA;
- Stream_Read_UINT16(s, msgType); /* msgType (2 bytes) */
+ Stream_Read_UINT16(s, msgType); /* msgType (2 bytes) */
Stream_Read_UINT16(s, msgFlags); /* msgFlags (2 bytes) */
- Stream_Read_UINT32(s, dataLen); /* dataLen (4 bytes) */
+ Stream_Read_UINT32(s, dataLen); /* dataLen (4 bytes) */
if (Stream_GetRemainingLength(s) < dataLen)
return ERROR_INVALID_DATA;
#ifdef WITH_DEBUG_CLIPRDR
- WLog_DBG(TAG, "msgType: %s (%"PRIu16"), msgFlags: %"PRIu16" dataLen: %"PRIu32"",
+ WLog_DBG(TAG, "msgType: %s (%" PRIu16 "), msgFlags: %" PRIu16 " dataLen: %" PRIu32 "",
CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
#endif
@@ -454,72 +449,76 @@ static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
{
case CB_CLIP_CAPS:
if ((error = cliprdr_process_clip_caps(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_clip_caps failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_process_clip_caps failed with error %" PRIu32 "!", error);
break;
case CB_MONITOR_READY:
if ((error = cliprdr_process_monitor_ready(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_monitor_ready failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_process_monitor_ready failed with error %" PRIu32 "!",
+ error);
break;
case CB_FORMAT_LIST:
if ((error = cliprdr_process_format_list(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_format_list failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_process_format_list failed with error %" PRIu32 "!", error);
break;
case CB_FORMAT_LIST_RESPONSE:
if ((error = cliprdr_process_format_list_response(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_format_list_response failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_process_format_list_response failed with error %" PRIu32 "!",
error);
break;
case CB_FORMAT_DATA_REQUEST:
if ((error = cliprdr_process_format_data_request(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_format_data_request failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_process_format_data_request failed with error %" PRIu32 "!",
error);
break;
case CB_FORMAT_DATA_RESPONSE:
if ((error = cliprdr_process_format_data_response(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_format_data_response failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_process_format_data_response failed with error %" PRIu32 "!",
error);
break;
case CB_FILECONTENTS_REQUEST:
if ((error = cliprdr_process_filecontents_request(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_filecontents_request failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_process_filecontents_request failed with error %" PRIu32 "!",
error);
break;
case CB_FILECONTENTS_RESPONSE:
if ((error = cliprdr_process_filecontents_response(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_filecontents_response failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "cliprdr_process_filecontents_response failed with error %" PRIu32 "!",
error);
break;
case CB_LOCK_CLIPDATA:
if ((error = cliprdr_process_lock_clipdata(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %" PRIu32 "!",
+ error);
break;
case CB_UNLOCK_CLIPDATA:
if ((error = cliprdr_process_unlock_clipdata(cliprdr, s, dataLen, msgFlags)))
- WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_process_lock_clipdata failed with error %" PRIu32 "!",
+ error);
break;
default:
error = CHANNEL_RC_BAD_PROC;
- WLog_ERR(TAG, "unknown msgType %"PRIu16"", msgType);
+ WLog_ERR(TAG, "unknown msgType %" PRIu16 "", msgType);
break;
}
@@ -541,7 +540,7 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
{
wStream* s;
const CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_new(CB_CLIP_CAPS, 0, 4 + CB_CAPSTYPE_GENERAL_LEN);
if (!s)
@@ -553,10 +552,10 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */
Stream_Write_UINT16(s, 0); /* pad1 */
generalCapabilitySet = (const CLIPRDR_GENERAL_CAPABILITY_SET*)capabilities->capabilitySets;
- Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType); /* capabilitySetType */
+ Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType); /* capabilitySetType */
Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetLength); /* lengthCapability */
- Stream_Write_UINT32(s, generalCapabilitySet->version); /* version */
- Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags */
+ Stream_Write_UINT32(s, generalCapabilitySet->version); /* version */
+ Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags */
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities");
return cliprdr_packet_send(cliprdr, s);
}
@@ -572,7 +571,7 @@ static UINT cliprdr_temp_directory(CliprdrClientContext* context,
int length;
wStream* s;
WCHAR* wszTempDir = NULL;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_new(CB_TEMP_DIRECTORY, 0, 520 * 2);
if (!s)
@@ -592,8 +591,7 @@ static UINT cliprdr_temp_directory(CliprdrClientContext* context,
Stream_Write(s, wszTempDir, (size_t)length * 2);
Stream_Zero(s, (520 - (size_t)length) * 2);
free(wszTempDir);
- WLog_Print(cliprdr->log, WLOG_DEBUG, "TempDirectory: %s",
- tempDirectory->szTempDir);
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "TempDirectory: %s", tempDirectory->szTempDir);
return cliprdr_packet_send(cliprdr, s);
}
@@ -606,7 +604,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
const CLIPRDR_FORMAT_LIST* formatList)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_format_list_new(formatList, cliprdr->useLongFormatNames);
if (!s)
@@ -615,7 +613,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatList: numFormats: %"PRIu32"",
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatList: numFormats: %" PRIu32 "",
formatList->numFormats);
return cliprdr_packet_send(cliprdr, s);
}
@@ -625,13 +623,13 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_client_format_list_response(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+cliprdr_client_format_list_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
- s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE,
- formatListResponse->msgFlags, 0);
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
+ s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->msgFlags, 0);
if (!s)
{
@@ -649,10 +647,10 @@ static UINT cliprdr_client_format_list_response(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
- const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+ const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_lock_clipdata_new(lockClipboardData);
if (!s)
@@ -661,8 +659,7 @@ static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_Print(cliprdr->log, WLOG_DEBUG,
- "ClientLockClipboardData: clipDataId: 0x%08"PRIX32"",
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientLockClipboardData: clipDataId: 0x%08" PRIX32 "",
lockClipboardData->clipDataId);
return cliprdr_packet_send(cliprdr, s);
}
@@ -672,11 +669,12 @@ static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
- const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+static UINT
+cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_unlock_clipdata_new(unlockClipboardData);
if (!s)
@@ -685,8 +683,7 @@ static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_Print(cliprdr->log, WLOG_DEBUG,
- "ClientUnlockClipboardData: clipDataId: 0x%08"PRIX32"",
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientUnlockClipboardData: clipDataId: 0x%08" PRIX32 "",
unlockClipboardData->clipDataId);
return cliprdr_packet_send(cliprdr, s);
}
@@ -697,10 +694,10 @@ static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, 0, 4);
@@ -720,14 +717,15 @@ static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+cliprdr_client_format_data_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
- s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE,
- formatDataResponse->msgFlags, formatDataResponse->dataLen);
+ s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->msgFlags,
+ formatDataResponse->dataLen);
if (!s)
{
@@ -735,8 +733,7 @@ static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- Stream_Write(s, formatDataResponse->requestedFormatData,
- formatDataResponse->dataLen);
+ Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataResponse");
return cliprdr_packet_send(cliprdr, s);
}
@@ -746,11 +743,12 @@ static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+cliprdr_client_file_contents_request(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_file_contents_request_new(fileContentsRequest);
@@ -760,8 +758,7 @@ static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_Print(cliprdr->log, WLOG_DEBUG,
- "ClientFileContentsRequest: streamId: 0x%08"PRIX32"",
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFileContentsRequest: streamId: 0x%08" PRIX32 "",
fileContentsRequest->streamId);
return cliprdr_packet_send(cliprdr, s);
}
@@ -771,11 +768,12 @@ static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
+static UINT
+cliprdr_client_file_contents_response(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
{
wStream* s;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
s = cliprdr_packet_file_contents_response_new(fileContentsResponse);
if (!s)
@@ -784,8 +782,7 @@ static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_Print(cliprdr->log, WLOG_DEBUG,
- "ClientFileContentsResponse: streamId: 0x%08"PRIX32"",
+ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFileContentsResponse: streamId: 0x%08" PRIX32 "",
fileContentsResponse->streamId);
return cliprdr_packet_send(cliprdr, s);
}
@@ -795,8 +792,9 @@ static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -840,7 +838,7 @@ static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(cliprdr->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(cliprdr->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -851,11 +849,12 @@ static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
}
static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) lpUserParam;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam;
if (!cliprdr || (cliprdr->OpenHandle != openHandle))
{
@@ -867,7 +866,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength,
- totalLength, dataFlags)))
+ totalLength, dataFlags)))
WLog_ERR(TAG, "failed with error %" PRIu32 "", error);
break;
@@ -878,7 +877,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
@@ -893,7 +892,7 @@ static DWORD WINAPI cliprdr_virtual_channel_client_thread(LPVOID arg)
{
wStream* data;
wMessage message;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) arg;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)arg;
UINT error = CHANNEL_RC_OK;
while (1)
@@ -917,11 +916,11 @@ static DWORD WINAPI cliprdr_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
if ((error = cliprdr_order_recv(cliprdr, data)))
{
- WLog_ERR(TAG, "cliprdr_order_recv failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_order_recv failed with error %" PRIu32 "!", error);
break;
}
}
@@ -951,18 +950,18 @@ static void cliprdr_free_msg(void* obj)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr,
- LPVOID pData, UINT32 dataLength)
+static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr, LPVOID pData,
+ UINT32 dataLength)
{
UINT32 status;
wObject obj = { 0 };
- status = cliprdr->channelEntryPoints.pVirtualChannelOpenEx(cliprdr->InitHandle,
- &cliprdr->OpenHandle, cliprdr->channelDef.name,
- cliprdr_virtual_channel_open_event_ex);
+ status = cliprdr->channelEntryPoints.pVirtualChannelOpenEx(
+ cliprdr->InitHandle, &cliprdr->OpenHandle, cliprdr->channelDef.name,
+ cliprdr_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -977,8 +976,7 @@ static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr,
}
if (!(cliprdr->thread = CreateThread(NULL, 0, cliprdr_virtual_channel_client_thread,
- (void*) cliprdr,
- 0, NULL)))
+ (void*)cliprdr, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
MessageQueue_Free(cliprdr->queue);
@@ -1001,22 +999,23 @@ static UINT cliprdr_virtual_channel_event_disconnected(cliprdrPlugin* cliprdr)
if (cliprdr->OpenHandle == 0)
return CHANNEL_RC_OK;
- if (MessageQueue_PostQuit(cliprdr->queue, 0)
- && (WaitForSingleObject(cliprdr->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(cliprdr->queue, 0) &&
+ (WaitForSingleObject(cliprdr->thread, INFINITE) == WAIT_FAILED))
{
rc = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", rc);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
}
MessageQueue_Free(cliprdr->queue);
CloseHandle(cliprdr->thread);
- rc = cliprdr->channelEntryPoints.pVirtualChannelCloseEx(cliprdr->InitHandle, cliprdr->OpenHandle);
+ rc = cliprdr->channelEntryPoints.pVirtualChannelCloseEx(cliprdr->InitHandle,
+ cliprdr->OpenHandle);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
return rc;
}
@@ -1045,10 +1044,11 @@ static UINT cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
}
static VOID VCAPITYPE cliprdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData,
+ UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- cliprdrPlugin* cliprdr = (cliprdrPlugin*) lpUserParam;
+ cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam;
if (!cliprdr || (cliprdr->InitHandle != pInitHandle))
{
@@ -1060,7 +1060,8 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event_ex(LPVOID lpUserParam,
{
case CHANNEL_EVENT_CONNECTED:
if ((error = cliprdr_virtual_channel_event_connected(cliprdr, pData, dataLength)))
- WLog_ERR(TAG, "cliprdr_virtual_channel_event_connected failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "cliprdr_virtual_channel_event_connected failed with error %" PRIu32 "!",
error);
break;
@@ -1068,13 +1069,16 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event_ex(LPVOID lpUserParam,
case CHANNEL_EVENT_DISCONNECTED:
if ((error = cliprdr_virtual_channel_event_disconnected(cliprdr)))
WLog_ERR(TAG,
- "cliprdr_virtual_channel_event_disconnected failed with error %"PRIu32"!", error);
+ "cliprdr_virtual_channel_event_disconnected failed with error %" PRIu32
+ "!",
+ error);
break;
case CHANNEL_EVENT_TERMINATED:
if ((error = cliprdr_virtual_channel_event_terminated(cliprdr)))
- WLog_ERR(TAG, "cliprdr_virtual_channel_event_terminated failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "cliprdr_virtual_channel_event_terminated failed with error %" PRIu32 "!",
error);
break;
@@ -1086,7 +1090,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event_ex(LPVOID lpUserParam,
}
/* cliprdr is always built-in */
-#define VirtualChannelEntryEx cliprdr_VirtualChannelEntryEx
+#define VirtualChannelEntryEx cliprdr_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
@@ -1094,7 +1098,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
cliprdrPlugin* cliprdr;
CliprdrClientContext* context = NULL;
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
- cliprdr = (cliprdrPlugin*) calloc(1, sizeof(cliprdrPlugin));
+ cliprdr = (cliprdrPlugin*)calloc(1, sizeof(cliprdrPlugin));
if (!cliprdr)
{
@@ -1102,18 +1106,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- cliprdr->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP |
- CHANNEL_OPTION_SHOW_PROTOCOL;
+ cliprdr->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
+ CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
sprintf_s(cliprdr->channelDef.name, ARRAYSIZE(cliprdr->channelDef.name), "cliprdr");
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
- context = (CliprdrClientContext*) calloc(1, sizeof(CliprdrClientContext));
+ context = (CliprdrClientContext*)calloc(1, sizeof(CliprdrClientContext));
if (!context)
{
@@ -1122,7 +1123,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- context->handle = (void*) cliprdr;
+ context->handle = (void*)cliprdr;
context->custom = NULL;
context->ClientCapabilities = cliprdr_client_capabilities;
context->TempDirectory = cliprdr_temp_directory;
@@ -1147,14 +1148,14 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
cliprdr->InitHandle = pInitHandle;
- rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx(cliprdr, context, pInitHandle,
- &cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- cliprdr_virtual_channel_init_event_ex);
+ rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx(
+ cliprdr, context, pInitHandle, &cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ cliprdr_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
free(cliprdr->context);
free(cliprdr);
return FALSE;
diff --git a/channels/cliprdr/client/cliprdr_main.h b/channels/cliprdr/client/cliprdr_main.h
index 25bad1828..a23340786 100644
--- a/channels/cliprdr/client/cliprdr_main.h
+++ b/channels/cliprdr/client/cliprdr_main.h
@@ -57,7 +57,10 @@ CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr);
#ifdef WITH_DEBUG_CLIPRDR
#define DEBUG_CLIPRDR(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_CLIPRDR(...) do { } while (0)
+#define DEBUG_CLIPRDR(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CHANNEL_CLIPRDR_CLIENT_MAIN_H */
diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c
index 31180b7d4..9a099423f 100644
--- a/channels/cliprdr/cliprdr_common.c
+++ b/channels/cliprdr/cliprdr_common.c
@@ -43,7 +43,7 @@ static BOOL cliprdr_validate_file_contents_request(const CLIPRDR_FILE_CONTENTS_R
{
if (request->cbRequested != sizeof(UINT64))
{
- WLog_ERR(TAG, "[%s]: cbRequested must be %"PRIu32", got %"PRIu32"", __FUNCTION__,
+ WLog_ERR(TAG, "[%s]: cbRequested must be %" PRIu32 ", got %" PRIu32 "", __FUNCTION__,
sizeof(UINT64), request->cbRequested);
return FALSE;
}
@@ -58,8 +58,7 @@ static BOOL cliprdr_validate_file_contents_request(const CLIPRDR_FILE_CONTENTS_R
return TRUE;
}
-wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags,
- UINT32 dataLen)
+wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen)
{
wStream* s;
s = Stream_New(NULL, dataLen + 8);
@@ -77,7 +76,8 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags,
return s;
}
-static void cliprdr_write_file_contents_request(wStream* s, const CLIPRDR_FILE_CONTENTS_REQUEST* request)
+static void cliprdr_write_file_contents_request(wStream* s,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* request)
{
Stream_Write_UINT32(s, request->streamId); /* streamId (4 bytes) */
Stream_Write_UINT32(s, request->listIndex); /* listIndex (4 bytes) */
@@ -95,19 +95,20 @@ static INLINE void cliprdr_write_lock_unlock_clipdata(wStream* s, UINT32 clipDat
Stream_Write_UINT32(s, clipDataId);
}
-static void cliprdr_write_lock_clipdata(wStream* s, const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+static void cliprdr_write_lock_clipdata(wStream* s,
+ const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
{
cliprdr_write_lock_unlock_clipdata(s, lockClipboardData->clipDataId);
}
static void cliprdr_write_unlock_clipdata(wStream* s,
- const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
cliprdr_write_lock_unlock_clipdata(s, unlockClipboardData->clipDataId);
}
static void cliprdr_write_file_contents_response(wStream* s,
- const CLIPRDR_FILE_CONTENTS_RESPONSE* response)
+ const CLIPRDR_FILE_CONTENTS_RESPONSE* response)
{
Stream_Write_UINT32(s, response->streamId); /* streamId (4 bytes) */
Stream_Write(s, response->requestedData, response->cbRequested);
@@ -129,7 +130,8 @@ wStream* cliprdr_packet_lock_clipdata_new(const CLIPRDR_LOCK_CLIPBOARD_DATA* loc
return s;
}
-wStream* cliprdr_packet_unlock_clipdata_new(const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+wStream*
+cliprdr_packet_unlock_clipdata_new(const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
wStream* s;
@@ -168,8 +170,7 @@ wStream* cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_R
if (!response)
return NULL;
- s = cliprdr_packet_new(CB_FILECONTENTS_RESPONSE, response->msgFlags,
- 4 + response->cbRequested);
+ s = cliprdr_packet_new(CB_FILECONTENTS_RESPONSE, response->msgFlags, 4 + response->cbRequested);
if (!s)
return NULL;
@@ -178,7 +179,8 @@ wStream* cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_R
return s;
}
-wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames)
+wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
+ BOOL useLongFormatNames)
{
wStream* s;
UINT32 index;
@@ -191,7 +193,8 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
CLIPRDR_FORMAT* format;
if (formatList->msgType != CB_FORMAT_LIST)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, formatList->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ formatList->msgType);
if (!useLongFormatNames)
{
@@ -207,7 +210,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
for (index = 0; index < formatList->numFormats; index++)
{
size_t formatNameLength = 0;
- format = (CLIPRDR_FORMAT*) & (formatList->formats[index]);
+ format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */
formatNameSize = 0;
@@ -229,8 +232,8 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
wszFormatName = NULL;
if (szFormatName)
- formatNameSize = ConvertToUnicode(CP_UTF8, 0, szFormatName, -1, &wszFormatName,
- 0);
+ formatNameSize =
+ ConvertToUnicode(CP_UTF8, 0, szFormatName, -1, &wszFormatName, 0);
if (formatNameSize < 0)
return NULL;
@@ -254,13 +257,13 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
UINT32 length = 0;
for (index = 0; index < formatList->numFormats; index++)
{
- format = (CLIPRDR_FORMAT*) & (formatList->formats[index]);
+ format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
length += 4;
formatNameSize = 2;
if (format->formatName)
- formatNameSize = MultiByteToWideChar(CP_UTF8, 0, format->formatName, -1, NULL,
- 0) * 2;
+ formatNameSize =
+ MultiByteToWideChar(CP_UTF8, 0, format->formatName, -1, NULL, 0) * 2;
if (formatNameSize < 0)
return NULL;
@@ -278,7 +281,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
for (index = 0; index < formatList->numFormats; index++)
{
- format = (CLIPRDR_FORMAT*) & (formatList->formats[index]);
+ format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */
if (format->formatName)
@@ -289,10 +292,11 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, B
if ((cap < pos) || ((rem / 2) > INT_MAX))
return NULL;
- lpWideCharStr = (LPWSTR) Stream_Pointer(s);
+ lpWideCharStr = (LPWSTR)Stream_Pointer(s);
cchWideChar = (int)(rem / 2);
- formatNameSize = MultiByteToWideChar(CP_UTF8, 0,
- format->formatName, -1, lpWideCharStr, cchWideChar) * 2;
+ formatNameSize = MultiByteToWideChar(CP_UTF8, 0, format->formatName, -1,
+ lpWideCharStr, cchWideChar) *
+ 2;
if (formatNameSize < 0)
return NULL;
Stream_Seek(s, (size_t)formatNameSize);
diff --git a/channels/cliprdr/cliprdr_common.h b/channels/cliprdr/cliprdr_common.h
index d2c236967..b5d36b9b4 100644
--- a/channels/cliprdr/cliprdr_common.h
+++ b/channels/cliprdr/cliprdr_common.h
@@ -30,19 +30,31 @@
#include
FREERDP_LOCAL wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen);
-FREERDP_LOCAL wStream* cliprdr_packet_lock_clipdata_new(const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
-FREERDP_LOCAL wStream* cliprdr_packet_unlock_clipdata_new(const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
-FREERDP_LOCAL wStream* cliprdr_packet_file_contents_request_new(const CLIPRDR_FILE_CONTENTS_REQUEST* request);
-FREERDP_LOCAL wStream* cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_RESPONSE* response);
-FREERDP_LOCAL wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames);
+FREERDP_LOCAL wStream*
+cliprdr_packet_lock_clipdata_new(const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
+FREERDP_LOCAL wStream*
+cliprdr_packet_unlock_clipdata_new(const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
+FREERDP_LOCAL wStream*
+cliprdr_packet_file_contents_request_new(const CLIPRDR_FILE_CONTENTS_REQUEST* request);
+FREERDP_LOCAL wStream*
+cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_RESPONSE* response);
+FREERDP_LOCAL wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
+ BOOL useLongFormatNames);
-FREERDP_LOCAL UINT cliprdr_read_lock_clipdata(wStream* s, CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
-FREERDP_LOCAL UINT cliprdr_read_unlock_clipdata(wStream* s, CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
-FREERDP_LOCAL UINT cliprdr_read_format_data_request(wStream* s, CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest);
-FREERDP_LOCAL UINT cliprdr_read_format_data_response(wStream* s, CLIPRDR_FORMAT_DATA_RESPONSE* response);
-FREERDP_LOCAL UINT cliprdr_read_file_contents_request(wStream* s, CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest);
-FREERDP_LOCAL UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPONSE* response);
-FREERDP_LOCAL UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames);
+FREERDP_LOCAL UINT cliprdr_read_lock_clipdata(wStream* s,
+ CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
+FREERDP_LOCAL UINT cliprdr_read_unlock_clipdata(wStream* s,
+ CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
+FREERDP_LOCAL UINT cliprdr_read_format_data_request(wStream* s,
+ CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest);
+FREERDP_LOCAL UINT cliprdr_read_format_data_response(wStream* s,
+ CLIPRDR_FORMAT_DATA_RESPONSE* response);
+FREERDP_LOCAL UINT
+cliprdr_read_file_contents_request(wStream* s, CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest);
+FREERDP_LOCAL UINT cliprdr_read_file_contents_response(wStream* s,
+ CLIPRDR_FILE_CONTENTS_RESPONSE* response);
+FREERDP_LOCAL UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList,
+ BOOL useLongFormatNames);
FREERDP_LOCAL void cliprdr_free_format_list(CLIPRDR_FORMAT_LIST* formatList);
diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c
index 95b8cb675..d8a733bc5 100644
--- a/channels/cliprdr/server/cliprdr_main.c
+++ b/channels/cliprdr/server/cliprdr_main.c
@@ -51,16 +51,21 @@
* | |\n
* |-------------------------------------------------------------------------|\n _
* |-------------------------------Format List PDU-------------------------->|\n |
- * |<--------------------------Format List Response PDU----------------------|\n _| Copy Sequence
+ * |<--------------------------Format List Response PDU----------------------|\n _| Copy
+ * Sequence
* |<---------------------Lock Clipboard Data PDU (Optional)-----------------|\n
* |-------------------------------------------------------------------------|\n
* |-------------------------------------------------------------------------|\n _
- * |<--------------------------Format Data Request PDU-----------------------|\n | Paste Sequence Palette,
- * |---------------------------Format Data Response PDU--------------------->|\n _| Metafile, File List Data
+ * |<--------------------------Format Data Request PDU-----------------------|\n | Paste
+ * Sequence Palette,
+ * |---------------------------Format Data Response PDU--------------------->|\n _| Metafile,
+ * File List Data
* |-------------------------------------------------------------------------|\n
* |-------------------------------------------------------------------------|\n _
- * |<------------------------Format Contents Request PDU---------------------|\n | Paste Sequence
- * |-------------------------Format Contents Response PDU------------------->|\n _| File Stream Data
+ * |<------------------------Format Contents Request PDU---------------------|\n | Paste
+ * Sequence
+ * |-------------------------Format Contents Response PDU------------------->|\n _| File
+ * Stream Data
* |<---------------------Lock Clipboard Data PDU (Optional)-----------------|\n
* |-------------------------------------------------------------------------|\n
*
@@ -96,10 +101,10 @@ UINT cliprdr_server_packet_send(CliprdrServerPrivate* cliprdr, wStream* s)
goto fail;
}
- status = WTSVirtualChannelWrite(cliprdr->ChannelHandle,
- (PCHAR) Stream_Buffer(s), (UINT32)size, &written);
+ status = WTSVirtualChannelWrite(cliprdr->ChannelHandle, (PCHAR)Stream_Buffer(s), (UINT32)size,
+ &written);
rc = status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
- fail:
+fail:
Stream_Free(s, TRUE);
return rc;
}
@@ -115,10 +120,11 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
size_t offset = 0;
UINT32 x;
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (capabilities->msgType != CB_CLIP_CAPS)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, capabilities->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ capabilities->msgType);
if (capabilities->cCapabilitiesSets > UINT16_MAX)
{
@@ -134,27 +140,33 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- Stream_Write_UINT16(s, (UINT16)capabilities->cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
- Stream_Write_UINT16(s, 0); /* pad1 (2 bytes) */
+ Stream_Write_UINT16(s,
+ (UINT16)capabilities->cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
+ Stream_Write_UINT16(s, 0); /* pad1 (2 bytes) */
for (x = 0; x < capabilities->cCapabilitiesSets; x++)
{
- const CLIPRDR_CAPABILITY_SET* cap = (const CLIPRDR_CAPABILITY_SET*) (((const BYTE*)capabilities->capabilitySets) + offset);
+ const CLIPRDR_CAPABILITY_SET* cap =
+ (const CLIPRDR_CAPABILITY_SET*)(((const BYTE*)capabilities->capabilitySets) + offset);
offset += cap->capabilitySetLength;
switch (cap->capabilitySetType)
{
case CB_CAPSTYPE_GENERAL:
{
- const CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet = (const CLIPRDR_GENERAL_CAPABILITY_SET*)cap;
- Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType); /* capabilitySetType (2 bytes) */
- Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetLength); /* lengthCapability (2 bytes) */
+ const CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet =
+ (const CLIPRDR_GENERAL_CAPABILITY_SET*)cap;
+ Stream_Write_UINT16(
+ s, generalCapabilitySet->capabilitySetType); /* capabilitySetType (2 bytes) */
+ Stream_Write_UINT16(
+ s, generalCapabilitySet->capabilitySetLength); /* lengthCapability (2 bytes) */
Stream_Write_UINT32(s, generalCapabilitySet->version); /* version (4 bytes) */
- Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags (4 bytes) */
+ Stream_Write_UINT32(
+ s, generalCapabilitySet->generalFlags); /* generalFlags (4 bytes) */
}
break;
default:
- WLog_WARN(TAG, "Unknown capability set type %08"PRIx16, cap->capabilitySetType);
+ WLog_WARN(TAG, "Unknown capability set type %08" PRIx16, cap->capabilitySetType);
if (!Stream_SafeSeek(s, cap->capabilitySetLength))
{
WLog_ERR(TAG, "%s: short stream", __FUNCTION__);
@@ -162,7 +174,6 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
}
break;
}
-
}
WLog_DBG(TAG, "ServerCapabilities");
return cliprdr_server_packet_send(cliprdr, s);
@@ -173,16 +184,17 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_monitor_ready(CliprdrServerContext* context, const CLIPRDR_MONITOR_READY* monitorReady)
+static UINT cliprdr_server_monitor_ready(CliprdrServerContext* context,
+ const CLIPRDR_MONITOR_READY* monitorReady)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (monitorReady->msgType != CB_MONITOR_READY)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, monitorReady->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ monitorReady->msgType);
- s = cliprdr_packet_new(CB_MONITOR_READY,
- monitorReady->msgFlags, monitorReady->dataLen);
+ s = cliprdr_packet_new(CB_MONITOR_READY, monitorReady->msgFlags, monitorReady->dataLen);
if (!s)
{
@@ -203,7 +215,7 @@ static UINT cliprdr_server_format_list(CliprdrServerContext* context,
const CLIPRDR_FORMAT_LIST* formatList)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
s = cliprdr_packet_format_list_new(formatList, context->useLongFormatNames);
if (!s)
@@ -212,8 +224,7 @@ static UINT cliprdr_server_format_list(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "ServerFormatList: numFormats: %"PRIu32"",
- formatList->numFormats);
+ WLog_DBG(TAG, "ServerFormatList: numFormats: %" PRIu32 "", formatList->numFormats);
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -222,16 +233,18 @@ static UINT cliprdr_server_format_list(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_format_list_response(CliprdrServerContext* context,
- const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+cliprdr_server_format_list_response(CliprdrServerContext* context,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (formatListResponse->msgType != CB_FORMAT_LIST_RESPONSE)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, formatListResponse->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ formatListResponse->msgType);
- s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE,
- formatListResponse->msgFlags, formatListResponse->dataLen);
+ s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->msgFlags,
+ formatListResponse->dataLen);
if (!s)
{
@@ -249,12 +262,13 @@ static UINT cliprdr_server_format_list_response(CliprdrServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT cliprdr_server_lock_clipboard_data(CliprdrServerContext* context,
- const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+ const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (lockClipboardData->msgType != CB_LOCK_CLIPDATA)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, lockClipboardData->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ lockClipboardData->msgType);
s = cliprdr_packet_lock_clipdata_new(lockClipboardData);
if (!s)
@@ -263,7 +277,7 @@ static UINT cliprdr_server_lock_clipboard_data(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "ServerLockClipboardData: clipDataId: 0x%08"PRIX32"",
+ WLog_DBG(TAG, "ServerLockClipboardData: clipDataId: 0x%08" PRIX32 "",
lockClipboardData->clipDataId);
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -273,13 +287,15 @@ static UINT cliprdr_server_lock_clipboard_data(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_unlock_clipboard_data(CliprdrServerContext* context,
- const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+static UINT
+cliprdr_server_unlock_clipboard_data(CliprdrServerContext* context,
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (unlockClipboardData->msgType != CB_UNLOCK_CLIPDATA)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, unlockClipboardData->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ unlockClipboardData->msgType);
s = cliprdr_packet_unlock_clipdata_new(unlockClipboardData);
@@ -289,7 +305,7 @@ static UINT cliprdr_server_unlock_clipboard_data(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "ServerUnlockClipboardData: clipDataId: 0x%08"PRIX32"",
+ WLog_DBG(TAG, "ServerUnlockClipboardData: clipDataId: 0x%08" PRIX32 "",
unlockClipboardData->clipDataId);
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -300,15 +316,16 @@ static UINT cliprdr_server_unlock_clipboard_data(CliprdrServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT cliprdr_server_format_data_request(CliprdrServerContext* context,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (formatDataRequest->msgType != CB_FORMAT_DATA_REQUEST)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, formatDataRequest->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ formatDataRequest->msgType);
- s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST,
- formatDataRequest->msgFlags, formatDataRequest->dataLen);
+ s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, formatDataRequest->msgFlags,
+ formatDataRequest->dataLen);
if (!s)
{
@@ -316,8 +333,7 @@ static UINT cliprdr_server_format_data_request(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- Stream_Write_UINT32(s,
- formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
+ Stream_Write_UINT32(s, formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
WLog_DBG(TAG, "ClientFormatDataRequest");
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -327,17 +343,19 @@ static UINT cliprdr_server_format_data_request(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_format_data_response(CliprdrServerContext* context,
- const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+cliprdr_server_format_data_response(CliprdrServerContext* context,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (formatDataResponse->msgType != CB_FORMAT_DATA_RESPONSE)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, formatDataResponse->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ formatDataResponse->msgType);
- s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE,
- formatDataResponse->msgFlags, formatDataResponse->dataLen);
+ s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->msgFlags,
+ formatDataResponse->dataLen);
if (!s)
{
@@ -345,8 +363,7 @@ static UINT cliprdr_server_format_data_response(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- Stream_Write(s, formatDataResponse->requestedFormatData,
- formatDataResponse->dataLen);
+ Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
WLog_DBG(TAG, "ServerFormatDataResponse");
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -356,14 +373,16 @@ static UINT cliprdr_server_format_data_response(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_file_contents_request(CliprdrServerContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+cliprdr_server_file_contents_request(CliprdrServerContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (fileContentsRequest->msgType != CB_FILECONTENTS_REQUEST)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, fileContentsRequest->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ fileContentsRequest->msgType);
s = cliprdr_packet_file_contents_request_new(fileContentsRequest);
if (!s)
@@ -372,7 +391,7 @@ static UINT cliprdr_server_file_contents_request(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "ServerFileContentsRequest: streamId: 0x%08"PRIX32"",
+ WLog_DBG(TAG, "ServerFileContentsRequest: streamId: 0x%08" PRIX32 "",
fileContentsRequest->streamId);
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -382,14 +401,16 @@ static UINT cliprdr_server_file_contents_request(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_file_contents_response(CliprdrServerContext* context,
- const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
+static UINT
+cliprdr_server_file_contents_response(CliprdrServerContext* context,
+ const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
{
wStream* s;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (fileContentsResponse->msgType != CB_FILECONTENTS_RESPONSE)
- WLog_WARN(TAG, "[%s] called with invalid type %08"PRIx32, __FUNCTION__, fileContentsResponse->msgType);
+ WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
+ fileContentsResponse->msgType);
s = cliprdr_packet_file_contents_response_new(fileContentsResponse);
if (!s)
@@ -398,7 +419,7 @@ static UINT cliprdr_server_file_contents_response(CliprdrServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "ServerFileContentsResponse: streamId: 0x%08"PRIX32"",
+ WLog_DBG(TAG, "ServerFileContentsResponse: streamId: 0x%08" PRIX32 "",
fileContentsResponse->streamId);
return cliprdr_server_packet_send(cliprdr, s);
}
@@ -408,23 +429,23 @@ static UINT cliprdr_server_file_contents_response(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_general_capability(CliprdrServerContext*
- context, wStream* s, CLIPRDR_GENERAL_CAPABILITY_SET* cap_set)
+static UINT cliprdr_server_receive_general_capability(CliprdrServerContext* context, wStream* s,
+ CLIPRDR_GENERAL_CAPABILITY_SET* cap_set)
{
- Stream_Read_UINT32(s, cap_set->version); /* version (4 bytes) */
+ Stream_Read_UINT32(s, cap_set->version); /* version (4 bytes) */
Stream_Read_UINT32(s, cap_set->generalFlags); /* generalFlags (4 bytes) */
if (context->useLongFormatNames)
- context->useLongFormatNames = (cap_set->generalFlags & CB_USE_LONG_FORMAT_NAMES) ? TRUE :
- FALSE;
+ context->useLongFormatNames =
+ (cap_set->generalFlags & CB_USE_LONG_FORMAT_NAMES) ? TRUE : FALSE;
if (context->streamFileClipEnabled)
- context->streamFileClipEnabled = (cap_set->generalFlags & CB_STREAM_FILECLIP_ENABLED) ?
- TRUE : FALSE;
+ context->streamFileClipEnabled =
+ (cap_set->generalFlags & CB_STREAM_FILECLIP_ENABLED) ? TRUE : FALSE;
if (context->fileClipNoFilePaths)
- context->fileClipNoFilePaths = (cap_set->generalFlags & CB_FILECLIP_NO_FILE_PATHS) ?
- TRUE : FALSE;
+ context->fileClipNoFilePaths =
+ (cap_set->generalFlags & CB_FILECLIP_NO_FILE_PATHS) ? TRUE : FALSE;
if (context->canLockClipData)
context->canLockClipData = (cap_set->generalFlags & CB_CAN_LOCK_CLIPDATA) ? TRUE : FALSE;
@@ -437,8 +458,8 @@ static UINT cliprdr_server_receive_general_capability(CliprdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context,
- wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
UINT16 index;
UINT16 capabilitySetType;
@@ -456,11 +477,11 @@ static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context,
WLog_DBG(TAG, "CliprdrClientCapabilities");
Stream_Read_UINT16(s, capabilities.cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
- Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
+ Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
for (index = 0; index < capabilities.cCapabilitiesSets; index++)
{
- Stream_Read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */
+ Stream_Read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */
Stream_Read_UINT16(s, capabilitySetLength); /* capabilitySetLength (2 bytes) */
cap_sets_size += capabilitySetLength;
@@ -473,26 +494,30 @@ static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) tmp;
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)tmp;
capSet = &(capabilities.capabilitySets[index]);
capSet->capabilitySetType = capabilitySetType;
- capSet->capabilitySetLength= capabilitySetLength;
+ capSet->capabilitySetLength = capabilitySetLength;
switch (capSet->capabilitySetType)
{
case CB_CAPSTYPE_GENERAL:
- if ((error = cliprdr_server_receive_general_capability(context, s, (CLIPRDR_GENERAL_CAPABILITY_SET*) capSet)))
+ if ((error = cliprdr_server_receive_general_capability(
+ context, s, (CLIPRDR_GENERAL_CAPABILITY_SET*)capSet)))
{
- WLog_ERR(TAG, "cliprdr_server_receive_general_capability failed with error %"PRIu32"",
+ WLog_ERR(TAG,
+ "cliprdr_server_receive_general_capability failed with error %" PRIu32
+ "",
error);
goto out;
}
break;
default:
- WLog_ERR(TAG, "unknown cliprdr capability set: %"PRIu16"", capSet->capabilitySetType);
+ WLog_ERR(TAG, "unknown cliprdr capability set: %" PRIu16 "",
+ capSet->capabilitySetType);
error = ERROR_INVALID_DATA;
goto out;
}
@@ -509,25 +534,25 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext*
- context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
size_t length;
WCHAR* wszTempDir;
CLIPRDR_TEMP_DIRECTORY tempDirectory;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
size_t slength;
UINT error = CHANNEL_RC_OK;
WINPR_UNUSED(header);
if ((slength = Stream_GetRemainingLength(s)) < 520)
{
- WLog_ERR(TAG,
- "Stream_GetRemainingLength returned %"PRIuz" but should at least be 520", slength);
+ WLog_ERR(TAG, "Stream_GetRemainingLength returned %" PRIuz " but should at least be 520",
+ slength);
return CHANNEL_RC_NO_MEMORY;
}
- wszTempDir = (WCHAR*) Stream_Pointer(s);
+ wszTempDir = (WCHAR*)Stream_Pointer(s);
if (wszTempDir[260] != 0)
{
@@ -538,8 +563,8 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext*
free(cliprdr->temporaryDirectory);
cliprdr->temporaryDirectory = NULL;
- if (ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1,
- &(cliprdr->temporaryDirectory), 0, NULL, NULL) < 1)
+ if (ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1, &(cliprdr->temporaryDirectory), 0, NULL,
+ NULL) < 1)
{
WLog_ERR(TAG, "failed to convert temporary directory name");
return ERROR_INVALID_DATA;
@@ -556,7 +581,7 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext*
IFCALLRET(context->TempDirectory, error, context, &tempDirectory);
if (error)
- WLog_ERR(TAG, "TempDirectory failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "TempDirectory failed with error %" PRIu32 "!", error);
return error;
}
@@ -566,8 +591,8 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_format_list(CliprdrServerContext* context,
- wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_format_list(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FORMAT_LIST formatList;
UINT error = CHANNEL_RC_OK;
@@ -579,12 +604,11 @@ static UINT cliprdr_server_receive_format_list(CliprdrServerContext* context,
if ((error = cliprdr_read_format_list(s, &formatList, context->useLongFormatNames)))
goto out;
- WLog_DBG(TAG, "ClientFormatList: numFormats: %"PRIu32"",
- formatList.numFormats);
+ WLog_DBG(TAG, "ClientFormatList: numFormats: %" PRIu32 "", formatList.numFormats);
IFCALLRET(context->ClientFormatList, error, context, &formatList);
if (error)
- WLog_ERR(TAG, "ClientFormatList failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFormatList failed with error %" PRIu32 "!", error);
out:
cliprdr_free_format_list(&formatList);
@@ -596,8 +620,8 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_format_list_response(
- CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_format_list_response(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
UINT error = CHANNEL_RC_OK;
@@ -607,11 +631,10 @@ static UINT cliprdr_server_receive_format_list_response(
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
formatListResponse.msgFlags = header->msgFlags;
formatListResponse.dataLen = header->dataLen;
- IFCALLRET(context->ClientFormatListResponse, error, context,
- &formatListResponse);
+ IFCALLRET(context->ClientFormatListResponse, error, context, &formatListResponse);
if (error)
- WLog_ERR(TAG, "ClientFormatListResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFormatListResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -621,8 +644,8 @@ static UINT cliprdr_server_receive_format_list_response(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context,
- wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
UINT error = CHANNEL_RC_OK;
@@ -641,7 +664,7 @@ static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context,
IFCALLRET(context->ClientLockClipboardData, error, context, &lockClipboardData);
if (error)
- WLog_ERR(TAG, "ClientLockClipboardData failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientLockClipboardData failed with error %" PRIu32 "!", error);
return error;
}
@@ -651,8 +674,8 @@ static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext*
- context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
UINT error = CHANNEL_RC_OK;
@@ -665,11 +688,10 @@ static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext*
if ((error = cliprdr_read_unlock_clipdata(s, &unlockClipboardData)))
return error;
- IFCALLRET(context->ClientUnlockClipboardData, error, context,
- &unlockClipboardData);
+ IFCALLRET(context->ClientUnlockClipboardData, error, context, &unlockClipboardData);
if (error)
- WLog_ERR(TAG, "ClientUnlockClipboardData failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientUnlockClipboardData failed with error %" PRIu32 "!", error);
return error;
}
@@ -679,8 +701,8 @@ static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext*
- context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
UINT error = CHANNEL_RC_OK;
@@ -696,7 +718,7 @@ static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext*
IFCALLRET(context->ClientFormatDataRequest, error, context, &formatDataRequest);
if (error)
- WLog_ERR(TAG, "ClientFormatDataRequest failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFormatDataRequest failed with error %" PRIu32 "!", error);
return error;
}
@@ -706,8 +728,8 @@ static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_format_data_response(
- CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_format_data_response(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse;
UINT error = CHANNEL_RC_OK;
@@ -720,11 +742,10 @@ static UINT cliprdr_server_receive_format_data_response(
if ((error = cliprdr_read_format_data_response(s, &formatDataResponse)))
return error;
- IFCALLRET(context->ClientFormatDataResponse, error, context,
- &formatDataResponse);
+ IFCALLRET(context->ClientFormatDataResponse, error, context, &formatDataResponse);
if (error)
- WLog_ERR(TAG, "ClientFormatDataResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFormatDataResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -734,8 +755,8 @@ static UINT cliprdr_server_receive_format_data_response(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_filecontents_request(
- CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_filecontents_request(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FILE_CONTENTS_REQUEST request;
UINT error = CHANNEL_RC_OK;
@@ -750,7 +771,7 @@ static UINT cliprdr_server_receive_filecontents_request(
IFCALLRET(context->ClientFileContentsRequest, error, context, &request);
if (error)
- WLog_ERR(TAG, "ClientFileContentsRequest failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFileContentsRequest failed with error %" PRIu32 "!", error);
return error;
}
@@ -760,8 +781,8 @@ static UINT cliprdr_server_receive_filecontents_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_filecontents_response(
- CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_filecontents_response(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response;
UINT error = CHANNEL_RC_OK;
@@ -777,7 +798,7 @@ static UINT cliprdr_server_receive_filecontents_response(
IFCALLRET(context->ClientFileContentsResponse, error, context, &response);
if (error)
- WLog_ERR(TAG, "ClientFileContentsResponse failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ClientFileContentsResponse failed with error %" PRIu32 "!", error);
return error;
}
@@ -787,19 +808,20 @@ static UINT cliprdr_server_receive_filecontents_response(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context,
- wStream* s, const CLIPRDR_HEADER* header)
+static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context, wStream* s,
+ const CLIPRDR_HEADER* header)
{
UINT error;
WLog_DBG(TAG,
- "CliprdrServerReceivePdu: msgType: %"PRIu16" msgFlags: 0x%04"PRIX16" dataLen: %"PRIu32"",
+ "CliprdrServerReceivePdu: msgType: %" PRIu16 " msgFlags: 0x%04" PRIX16
+ " dataLen: %" PRIu32 "",
header->msgType, header->msgFlags, header->dataLen);
switch (header->msgType)
{
case CB_CLIP_CAPS:
if ((error = cliprdr_server_receive_capabilities(context, s, header)))
- WLog_ERR(TAG, "cliprdr_server_receive_capabilities failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_server_receive_capabilities failed with error %" PRIu32 "!",
error);
break;
@@ -807,13 +829,15 @@ static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context,
case CB_TEMP_DIRECTORY:
if ((error = cliprdr_server_receive_temporary_directory(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_temporary_directory failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_temporary_directory failed with error %" PRIu32
+ "!",
+ error);
break;
case CB_FORMAT_LIST:
if ((error = cliprdr_server_receive_format_list(context, s, header)))
- WLog_ERR(TAG, "cliprdr_server_receive_format_list failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_server_receive_format_list failed with error %" PRIu32 "!",
error);
break;
@@ -821,20 +845,23 @@ static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context,
case CB_FORMAT_LIST_RESPONSE:
if ((error = cliprdr_server_receive_format_list_response(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_format_list_response failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_format_list_response failed with error %" PRIu32
+ "!",
+ error);
break;
case CB_LOCK_CLIPDATA:
if ((error = cliprdr_server_receive_lock_clipdata(context, s, header)))
- WLog_ERR(TAG, "cliprdr_server_receive_lock_clipdata failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "cliprdr_server_receive_lock_clipdata failed with error %" PRIu32 "!",
error);
break;
case CB_UNLOCK_CLIPDATA:
if ((error = cliprdr_server_receive_unlock_clipdata(context, s, header)))
- WLog_ERR(TAG, "cliprdr_server_receive_unlock_clipdata failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "cliprdr_server_receive_unlock_clipdata failed with error %" PRIu32 "!",
error);
break;
@@ -842,34 +869,42 @@ static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context,
case CB_FORMAT_DATA_REQUEST:
if ((error = cliprdr_server_receive_format_data_request(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_format_data_request failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_format_data_request failed with error %" PRIu32
+ "!",
+ error);
break;
case CB_FORMAT_DATA_RESPONSE:
if ((error = cliprdr_server_receive_format_data_response(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_format_data_response failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_format_data_response failed with error %" PRIu32
+ "!",
+ error);
break;
case CB_FILECONTENTS_REQUEST:
if ((error = cliprdr_server_receive_filecontents_request(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_filecontents_request failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_filecontents_request failed with error %" PRIu32
+ "!",
+ error);
break;
case CB_FILECONTENTS_RESPONSE:
if ((error = cliprdr_server_receive_filecontents_response(context, s, header)))
WLog_ERR(TAG,
- "cliprdr_server_receive_filecontents_response failed with error %"PRIu32"!", error);
+ "cliprdr_server_receive_filecontents_response failed with error %" PRIu32
+ "!",
+ error);
break;
default:
error = ERROR_INVALID_DATA;
- WLog_ERR(TAG, "Unexpected clipboard PDU type: %"PRIu16"", header->msgType);
+ WLog_ERR(TAG, "Unexpected clipboard PDU type: %" PRIu16 "", header->msgType);
break;
}
@@ -909,7 +944,7 @@ static UINT cliprdr_server_init(CliprdrServerContext* context)
capabilities.msgFlags = 0;
capabilities.dataLen = 4 + CB_CAPSTYPE_GENERAL_LEN;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &generalCapabilitySet;
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&generalCapabilitySet;
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = CB_CAPSTYPE_GENERAL_LEN;
generalCapabilitySet.version = CB_CAPS_VERSION_2;
@@ -917,13 +952,13 @@ static UINT cliprdr_server_init(CliprdrServerContext* context)
if ((error = context->ServerCapabilities(context, &capabilities)))
{
- WLog_ERR(TAG, "ServerCapabilities failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ServerCapabilities failed with error %" PRIu32 "!", error);
return error;
}
if ((error = context->MonitorReady(context, &monitorReady)))
{
- WLog_ERR(TAG, "MonitorReady failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "MonitorReady failed with error %" PRIu32 "!", error);
return error;
}
@@ -942,7 +977,7 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
DWORD BytesToRead;
DWORD BytesReturned;
CLIPRDR_HEADER header;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
UINT error;
DWORD status;
s = cliprdr->s;
@@ -956,15 +991,15 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
if (status == WAIT_TIMEOUT)
return CHANNEL_RC_OK;
- if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0,
- (PCHAR) Stream_Pointer(s), BytesToRead, &BytesReturned))
+ if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s), BytesToRead,
+ &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
return ERROR_INTERNAL_ERROR;
@@ -977,9 +1012,9 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
{
position = Stream_GetPosition(s);
Stream_SetPosition(s, 0);
- Stream_Read_UINT16(s, header.msgType); /* msgType (2 bytes) */
+ Stream_Read_UINT16(s, header.msgType); /* msgType (2 bytes) */
Stream_Read_UINT16(s, header.msgFlags); /* msgFlags (2 bytes) */
- Stream_Read_UINT32(s, header.dataLen); /* dataLen (4 bytes) */
+ Stream_Read_UINT32(s, header.dataLen); /* dataLen (4 bytes) */
if (!Stream_EnsureCapacity(s, (header.dataLen + CLIPRDR_HEADER_LENGTH)))
{
@@ -992,21 +1027,22 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
if (Stream_GetPosition(s) < (header.dataLen + CLIPRDR_HEADER_LENGTH))
{
BytesReturned = 0;
- BytesToRead = (UINT32)((header.dataLen + CLIPRDR_HEADER_LENGTH) - Stream_GetPosition(s));
+ BytesToRead =
+ (UINT32)((header.dataLen + CLIPRDR_HEADER_LENGTH) - Stream_GetPosition(s));
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
if (status == WAIT_TIMEOUT)
return CHANNEL_RC_OK;
- if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0,
- (PCHAR) Stream_Pointer(s), BytesToRead, &BytesReturned))
+ if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s),
+ BytesToRead, &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
return ERROR_INTERNAL_ERROR;
@@ -1023,7 +1059,8 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
if ((error = cliprdr_server_receive_pdu(context, s, &header)))
{
- WLog_ERR(TAG, "cliprdr_server_receive_pdu failed with error code %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_server_receive_pdu failed with error code %" PRIu32 "!",
+ error);
return error;
}
@@ -1034,7 +1071,7 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -1044,8 +1081,8 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
BytesReturned = 0;
BytesToRead = 4;
- if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0,
- (PCHAR) Stream_Pointer(s), BytesToRead, &BytesReturned))
+ if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s),
+ BytesToRead, &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
return ERROR_INTERNAL_ERROR;
@@ -1053,7 +1090,7 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
if (BytesReturned == 4)
{
- Stream_Read_UINT16(s, header.msgType); /* msgType (2 bytes) */
+ Stream_Read_UINT16(s, header.msgType); /* msgType (2 bytes) */
Stream_Read_UINT16(s, header.msgFlags); /* msgFlags (2 bytes) */
if (!header.msgType)
@@ -1078,8 +1115,8 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
DWORD nCount;
HANDLE events[8];
HANDLE ChannelEvent;
- CliprdrServerContext* context = (CliprdrServerContext*) arg;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerContext* context = (CliprdrServerContext*)arg;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
UINT error = CHANNEL_RC_OK;
ChannelEvent = context->GetEventHandle(context);
@@ -1091,7 +1128,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
{
if ((error = cliprdr_server_init(context)))
{
- WLog_ERR(TAG, "cliprdr_server_init failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "cliprdr_server_init failed with error %" PRIu32 "!", error);
goto out;
}
}
@@ -1103,7 +1140,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
goto out;
}
@@ -1112,7 +1149,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
goto out;
}
@@ -1124,7 +1161,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
goto out;
}
@@ -1132,7 +1169,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
{
if ((error = context->CheckEventHandle(context)))
{
- WLog_ERR(TAG, "CheckEventHandle failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "CheckEventHandle failed with error %" PRIu32 "!", error);
break;
}
}
@@ -1141,8 +1178,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
out:
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "cliprdr_server_thread reported an error");
+ setChannelError(context->rdpcontext, error, "cliprdr_server_thread reported an error");
ExitThread(error);
return error;
@@ -1157,9 +1193,8 @@ static UINT cliprdr_server_open(CliprdrServerContext* context)
{
void* buffer = NULL;
DWORD BytesReturned = 0;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
- cliprdr->ChannelHandle = WTSVirtualChannelOpen(cliprdr->vcm,
- WTS_CURRENT_SESSION, "cliprdr");
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
+ cliprdr->ChannelHandle = WTSVirtualChannelOpen(cliprdr->vcm, WTS_CURRENT_SESSION, "cliprdr");
if (!cliprdr->ChannelHandle)
{
@@ -1169,8 +1204,8 @@ static UINT cliprdr_server_open(CliprdrServerContext* context)
cliprdr->ChannelEvent = NULL;
- if (WTSVirtualChannelQuery(cliprdr->ChannelHandle, WTSVirtualEventHandle,
- &buffer, &BytesReturned))
+ if (WTSVirtualChannelQuery(cliprdr->ChannelHandle, WTSVirtualEventHandle, &buffer,
+ &BytesReturned))
{
if (BytesReturned != sizeof(HANDLE))
{
@@ -1198,7 +1233,7 @@ static UINT cliprdr_server_open(CliprdrServerContext* context)
*/
static UINT cliprdr_server_close(CliprdrServerContext* context)
{
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (cliprdr->ChannelHandle)
{
@@ -1216,7 +1251,7 @@ static UINT cliprdr_server_close(CliprdrServerContext* context)
*/
static UINT cliprdr_server_start(CliprdrServerContext* context)
{
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
UINT error;
if (!cliprdr->ChannelHandle)
@@ -1234,7 +1269,7 @@ static UINT cliprdr_server_start(CliprdrServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(cliprdr->Thread = CreateThread(NULL, 0, cliprdr_server_thread, (void*) context, 0, NULL)))
+ if (!(cliprdr->Thread = CreateThread(NULL, 0, cliprdr_server_thread, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(cliprdr->StopEvent);
@@ -1253,7 +1288,7 @@ static UINT cliprdr_server_start(CliprdrServerContext* context)
static UINT cliprdr_server_stop(CliprdrServerContext* context)
{
UINT error = CHANNEL_RC_OK;
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
if (cliprdr->StopEvent)
{
@@ -1262,7 +1297,7 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context)
if (WaitForSingleObject(cliprdr->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -1278,7 +1313,7 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context)
static HANDLE cliprdr_server_get_event_handle(CliprdrServerContext* context)
{
- CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
+ CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
return cliprdr->ChannelEvent;
}
@@ -1296,7 +1331,7 @@ CliprdrServerContext* cliprdr_server_context_new(HANDLE vcm)
{
CliprdrServerContext* context;
CliprdrServerPrivate* cliprdr;
- context = (CliprdrServerContext*) calloc(1, sizeof(CliprdrServerContext));
+ context = (CliprdrServerContext*)calloc(1, sizeof(CliprdrServerContext));
if (context)
{
@@ -1317,8 +1352,7 @@ CliprdrServerContext* cliprdr_server_context_new(HANDLE vcm)
context->ServerFormatDataResponse = cliprdr_server_format_data_response;
context->ServerFileContentsRequest = cliprdr_server_file_contents_request;
context->ServerFileContentsResponse = cliprdr_server_file_contents_response;
- cliprdr = context->handle = (CliprdrServerPrivate*) calloc(1,
- sizeof(CliprdrServerPrivate));
+ cliprdr = context->handle = (CliprdrServerPrivate*)calloc(1, sizeof(CliprdrServerPrivate));
if (cliprdr)
{
@@ -1351,7 +1385,7 @@ void cliprdr_server_context_free(CliprdrServerContext* context)
if (!context)
return;
- cliprdr = (CliprdrServerPrivate*) context->handle;
+ cliprdr = (CliprdrServerPrivate*)context->handle;
if (cliprdr)
{
diff --git a/channels/cliprdr/server/cliprdr_main.h b/channels/cliprdr/server/cliprdr_main.h
index 248f34109..fce0ddba5 100644
--- a/channels/cliprdr/server/cliprdr_main.h
+++ b/channels/cliprdr/server/cliprdr_main.h
@@ -30,7 +30,7 @@
#define TAG CHANNELS_TAG("cliprdr.server")
-#define CLIPRDR_HEADER_LENGTH 8
+#define CLIPRDR_HEADER_LENGTH 8
struct _cliprdr_server_private
{
diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c
index 294d20de1..d3e9a22cf 100644
--- a/channels/disp/client/disp_main.c
+++ b/channels/disp/client/disp_main.c
@@ -81,7 +81,8 @@ typedef struct _DISP_PLUGIN DISP_PLUGIN;
* @return 0 on success, otherwise a Win32 error code
*/
static UINT disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback,
- UINT32 NumMonitors, DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors)
+ UINT32 NumMonitors,
+ DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors)
{
UINT status;
wStream* s;
@@ -89,7 +90,7 @@ static UINT disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK*
DISP_PLUGIN* disp;
UINT32 MonitorLayoutSize;
DISPLAY_CONTROL_HEADER header;
- disp = (DISP_PLUGIN*) callback->plugin;
+ disp = (DISP_PLUGIN*)callback->plugin;
MonitorLayoutSize = DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE;
header.length = 8 + 8 + (NumMonitors * MonitorLayoutSize);
header.type = DISPLAY_CONTROL_PDU_TYPE_MONITOR_LAYOUT;
@@ -104,7 +105,7 @@ static UINT disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK*
if ((status = disp_write_header(s, &header)))
{
- WLog_ERR(TAG, "Failed to write header with error %"PRIu32"!", status);
+ WLog_ERR(TAG, "Failed to write header with error %" PRIu32 "!", status);
goto out;
}
@@ -112,8 +113,9 @@ static UINT disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK*
NumMonitors = disp->MaxNumMonitors;
Stream_Write_UINT32(s, MonitorLayoutSize); /* MonitorLayoutSize (4 bytes) */
- Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */
- WLog_DBG(TAG, "disp_send_display_control_monitor_layout_pdu: NumMonitors=%"PRIu32"", NumMonitors);
+ Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */
+ WLog_DBG(TAG, "disp_send_display_control_monitor_layout_pdu: NumMonitors=%" PRIu32 "",
+ NumMonitors);
for (index = 0; index < NumMonitors; index++)
{
@@ -134,27 +136,32 @@ static UINT disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK*
if (Monitors[index].Height > 8192)
Monitors[index].Height = 8192;
- Stream_Write_UINT32(s, Monitors[index].Flags); /* Flags (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].Left); /* Left (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].Top); /* Top (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].Width); /* Width (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].Height); /* Height (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].PhysicalWidth); /* PhysicalWidth (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Flags); /* Flags (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Left); /* Left (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Top); /* Top (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Width); /* Width (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Height); /* Height (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].PhysicalWidth); /* PhysicalWidth (4 bytes) */
Stream_Write_UINT32(s, Monitors[index].PhysicalHeight); /* PhysicalHeight (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].Orientation); /* Orientation (4 bytes) */
- Stream_Write_UINT32(s, Monitors[index].DesktopScaleFactor); /* DesktopScaleFactor (4 bytes) */
+ Stream_Write_UINT32(s, Monitors[index].Orientation); /* Orientation (4 bytes) */
+ Stream_Write_UINT32(s,
+ Monitors[index].DesktopScaleFactor); /* DesktopScaleFactor (4 bytes) */
Stream_Write_UINT32(s, Monitors[index].DeviceScaleFactor); /* DeviceScaleFactor (4 bytes) */
WLog_DBG(TAG,
- "\t%d : Flags: 0x%08"PRIX32" Left/Top: (%"PRId32",%"PRId32") W/H=%"PRIu32"x%"PRIu32")", index,
- Monitors[index].Flags, Monitors[index].Left, Monitors[index].Top, Monitors[index].Width,
- Monitors[index].Height);
- WLog_DBG(TAG, "\t PhysicalWidth: %"PRIu32" PhysicalHeight: %"PRIu32" Orientation: %"PRIu32"",
- Monitors[index].PhysicalWidth, Monitors[index].PhysicalHeight, Monitors[index].Orientation);
+ "\t%d : Flags: 0x%08" PRIX32 " Left/Top: (%" PRId32 ",%" PRId32 ") W/H=%" PRIu32
+ "x%" PRIu32 ")",
+ index, Monitors[index].Flags, Monitors[index].Left, Monitors[index].Top,
+ Monitors[index].Width, Monitors[index].Height);
+ WLog_DBG(TAG,
+ "\t PhysicalWidth: %" PRIu32 " PhysicalHeight: %" PRIu32 " Orientation: %" PRIu32
+ "",
+ Monitors[index].PhysicalWidth, Monitors[index].PhysicalHeight,
+ Monitors[index].Orientation);
}
out:
Stream_SealLength(s);
- status = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s), Stream_Buffer(s),
+ status = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
NULL);
Stream_Free(s, TRUE);
return status;
@@ -170,7 +177,7 @@ static UINT disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback,
DISP_PLUGIN* disp;
DispClientContext* context;
UINT ret = CHANNEL_RC_OK;
- disp = (DISP_PLUGIN*) callback->plugin;
+ disp = (DISP_PLUGIN*)callback->plugin;
context = (DispClientContext*)disp->iface.pInterface;
if (Stream_GetRemainingLength(s) < 12)
@@ -179,13 +186,13 @@ static UINT disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, disp->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
+ Stream_Read_UINT32(s, disp->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorA); /* MaxMonitorAreaFactorA (4 bytes) */
Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorB); /* MaxMonitorAreaFactorB (4 bytes) */
if (context->DisplayControlCaps)
- ret = context->DisplayControlCaps(context, disp->MaxNumMonitors, disp->MaxMonitorAreaFactorA,
- disp->MaxMonitorAreaFactorB);
+ ret = context->DisplayControlCaps(context, disp->MaxNumMonitors,
+ disp->MaxMonitorAreaFactorA, disp->MaxMonitorAreaFactorB);
return ret;
}
@@ -208,7 +215,7 @@ static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
if ((error = disp_read_header(s, &header)))
{
- WLog_ERR(TAG, "disp_read_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "disp_read_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -224,7 +231,7 @@ static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
return disp_recv_display_control_caps_pdu(callback, s);
default:
- WLog_ERR(TAG, "Type %"PRIu32" not recognized!", header.type);
+ WLog_ERR(TAG, "Type %" PRIu32 " not recognized!", header.type);
return ERROR_INTERNAL_ERROR;
}
}
@@ -236,7 +243,7 @@ static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
*/
static UINT disp_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*) pChannelCallback;
+ DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*)pChannelCallback;
return disp_recv_pdu(callback, data);
}
@@ -257,12 +264,12 @@ static UINT disp_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT disp_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
DISP_CHANNEL_CALLBACK* callback;
- DISP_LISTENER_CALLBACK* listener_callback = (DISP_LISTENER_CALLBACK*) pListenerCallback;
- callback = (DISP_CHANNEL_CALLBACK*) calloc(1, sizeof(DISP_CHANNEL_CALLBACK));
+ DISP_LISTENER_CALLBACK* listener_callback = (DISP_LISTENER_CALLBACK*)pListenerCallback;
+ callback = (DISP_CHANNEL_CALLBACK*)calloc(1, sizeof(DISP_CHANNEL_CALLBACK));
if (!callback)
{
@@ -276,7 +283,7 @@ static UINT disp_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -288,8 +295,8 @@ static UINT disp_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
UINT status;
- DISP_PLUGIN* disp = (DISP_PLUGIN*) pPlugin;
- disp->listener_callback = (DISP_LISTENER_CALLBACK*) calloc(1, sizeof(DISP_LISTENER_CALLBACK));
+ DISP_PLUGIN* disp = (DISP_PLUGIN*)pPlugin;
+ disp->listener_callback = (DISP_LISTENER_CALLBACK*)calloc(1, sizeof(DISP_LISTENER_CALLBACK));
if (!disp->listener_callback)
{
@@ -301,7 +308,8 @@ static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
disp->listener_callback->plugin = pPlugin;
disp->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, DISP_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*) disp->listener_callback, &(disp->listener));
+ (IWTSListenerCallback*)disp->listener_callback,
+ &(disp->listener));
disp->listener->pInterface = disp->iface.pInterface;
return status;
}
@@ -313,7 +321,7 @@ static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
*/
static UINT disp_plugin_terminated(IWTSPlugin* pPlugin)
{
- DISP_PLUGIN* disp = (DISP_PLUGIN*) pPlugin;
+ DISP_PLUGIN* disp = (DISP_PLUGIN*)pPlugin;
free(disp->listener_callback);
free(disp->iface.pInterface);
free(pPlugin);
@@ -330,17 +338,17 @@ static UINT disp_plugin_terminated(IWTSPlugin* pPlugin)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT disp_send_monitor_layout(DispClientContext* context, UINT32 NumMonitors,
- DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors)
+ DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors)
{
- DISP_PLUGIN* disp = (DISP_PLUGIN*) context->handle;
+ DISP_PLUGIN* disp = (DISP_PLUGIN*)context->handle;
DISP_CHANNEL_CALLBACK* callback = disp->listener_callback->channel_callback;
return disp_send_display_control_monitor_layout_pdu(callback, NumMonitors, Monitors);
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry disp_DVCPluginEntry
+#define DVCPluginEntry disp_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -353,11 +361,11 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error = CHANNEL_RC_OK;
DISP_PLUGIN* disp;
DispClientContext* context;
- disp = (DISP_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "disp");
+ disp = (DISP_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "disp");
if (!disp)
{
- disp = (DISP_PLUGIN*) calloc(1, sizeof(DISP_PLUGIN));
+ disp = (DISP_PLUGIN*)calloc(1, sizeof(DISP_PLUGIN));
if (!disp)
{
@@ -372,7 +380,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
disp->MaxNumMonitors = 16;
disp->MaxMonitorAreaFactorA = 8192;
disp->MaxMonitorAreaFactorB = 8192;
- context = (DispClientContext*) calloc(1, sizeof(DispClientContext));
+ context = (DispClientContext*)calloc(1, sizeof(DispClientContext));
if (!context)
{
@@ -381,10 +389,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
return CHANNEL_RC_NO_MEMORY;
}
- context->handle = (void*) disp;
+ context->handle = (void*)disp;
context->SendMonitorLayout = disp_send_monitor_layout;
- disp->iface.pInterface = (void*) context;
- error = pEntryPoints->RegisterPlugin(pEntryPoints, "disp", (IWTSPlugin*) disp);
+ disp->iface.pInterface = (void*)context;
+ error = pEntryPoints->RegisterPlugin(pEntryPoints, "disp", (IWTSPlugin*)disp);
}
else
{
diff --git a/channels/disp/client/disp_main.h b/channels/disp/client/disp_main.h
index 9d4f70251..45a483042 100644
--- a/channels/disp/client/disp_main.h
+++ b/channels/disp/client/disp_main.h
@@ -33,8 +33,6 @@
#include
-
#define TAG CHANNELS_TAG("disp.client")
#endif /* FREERDP_CHANNEL_DISP_CLIENT_MAIN_H */
-
diff --git a/channels/disp/server/disp_main.c b/channels/disp/server/disp_main.c
index 8a632d015..06b263aa5 100644
--- a/channels/disp/server/disp_main.c
+++ b/channels/disp/server/disp_main.c
@@ -34,7 +34,6 @@
#include
#include
-
#include
#include "../disp_common.h"
@@ -63,7 +62,7 @@ static wStream* disp_server_single_packet_new(UINT32 type, UINT32 length)
if ((error = disp_write_header(s, &header)))
{
- WLog_ERR(TAG, "Failed to write header with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Failed to write header with error %" PRIu32 "!", error);
goto error;
}
@@ -78,21 +77,21 @@ static BOOL disp_server_is_monitor_layout_valid(DISPLAY_CONTROL_MONITOR_LAYOUT*
if (monitor->Width < DISPLAY_CONTROL_MIN_MONITOR_WIDTH ||
monitor->Width > DISPLAY_CONTROL_MAX_MONITOR_WIDTH)
{
- WLog_WARN(TAG, "Received invalid value for monitor->Width: %"PRIu32"", monitor->Width);
+ WLog_WARN(TAG, "Received invalid value for monitor->Width: %" PRIu32 "", monitor->Width);
return FALSE;
}
if (monitor->Height < DISPLAY_CONTROL_MIN_MONITOR_HEIGHT ||
monitor->Height > DISPLAY_CONTROL_MAX_MONITOR_HEIGHT)
{
- WLog_WARN(TAG, "Received invalid value for monitor->Height: %"PRIu32"", monitor->Width);
+ WLog_WARN(TAG, "Received invalid value for monitor->Height: %" PRIu32 "", monitor->Width);
return FALSE;
}
if (monitor->PhysicalWidth < DISPLAY_CONTROL_MIN_PHYSICAL_MONITOR_WIDTH ||
monitor->PhysicalWidth > DISPLAY_CONTROL_MAX_PHYSICAL_MONITOR_WIDTH)
{
- WLog_WARN(TAG, "Received invalid value for monitor->PhysicalWidth: %"PRIu32"",
+ WLog_WARN(TAG, "Received invalid value for monitor->PhysicalWidth: %" PRIu32 "",
monitor->PhysicalWidth);
return FALSE;
}
@@ -100,7 +99,8 @@ static BOOL disp_server_is_monitor_layout_valid(DISPLAY_CONTROL_MONITOR_LAYOUT*
if (monitor->PhysicalHeight < DISPLAY_CONTROL_MIN_PHYSICAL_MONITOR_HEIGHT ||
monitor->PhysicalHeight > DISPLAY_CONTROL_MAX_PHYSICAL_MONITOR_HEIGHT)
{
- WLog_WARN(TAG, "Received invalid value for monitor->Height: %"PRIu32"", monitor->PhysicalHeight);
+ WLog_WARN(TAG, "Received invalid value for monitor->Height: %" PRIu32 "",
+ monitor->PhysicalHeight);
return FALSE;
}
@@ -113,7 +113,7 @@ static BOOL disp_server_is_monitor_layout_valid(DISPLAY_CONTROL_MONITOR_LAYOUT*
break;
default:
- WLog_WARN(TAG, "Received incorrect value for monitor->Orientation: %"PRIu32"",
+ WLog_WARN(TAG, "Received incorrect value for monitor->Orientation: %" PRIu32 "",
monitor->Orientation);
return FALSE;
}
@@ -138,8 +138,8 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
if (pdu.MonitorLayoutSize != DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE)
{
- WLog_ERR(TAG, "MonitorLayoutSize is set to %"PRIu32". expected %"PRIu32"", pdu.MonitorLayoutSize,
- DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE);
+ WLog_ERR(TAG, "MonitorLayoutSize is set to %" PRIu32 ". expected %" PRIu32 "",
+ pdu.MonitorLayoutSize, DISPLAY_CONTROL_MONITOR_LAYOUT_SIZE);
return ERROR_INVALID_DATA;
}
@@ -147,8 +147,8 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
if (pdu.NumMonitors > context->MaxNumMonitors)
{
- WLog_ERR(TAG, "NumMonitors (%"PRIu32")> server MaxNumMonitors (%"PRIu32")", pdu.NumMonitors,
- context->MaxNumMonitors);
+ WLog_ERR(TAG, "NumMonitors (%" PRIu32 ")> server MaxNumMonitors (%" PRIu32 ")",
+ pdu.NumMonitors, context->MaxNumMonitors);
return ERROR_INVALID_DATA;
}
@@ -158,8 +158,8 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
return ERROR_INVALID_DATA;
}
- pdu.Monitors = (DISPLAY_CONTROL_MONITOR_LAYOUT*) calloc(pdu.NumMonitors,
- sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
+ pdu.Monitors = (DISPLAY_CONTROL_MONITOR_LAYOUT*)calloc(pdu.NumMonitors,
+ sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
if (!pdu.Monitors)
{
@@ -167,30 +167,31 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
return CHANNEL_RC_NO_MEMORY;
}
- WLog_DBG(TAG, "disp_recv_display_control_monitor_layout_pdu: NumMonitors=%"PRIu32"",
+ WLog_DBG(TAG, "disp_recv_display_control_monitor_layout_pdu: NumMonitors=%" PRIu32 "",
pdu.NumMonitors);
for (index = 0; index < pdu.NumMonitors; index++)
{
monitor = &(pdu.Monitors[index]);
- Stream_Read_UINT32(s, monitor->Flags); /* Flags (4 bytes) */
- Stream_Read_UINT32(s, monitor->Left); /* Left (4 bytes) */
- Stream_Read_UINT32(s, monitor->Top); /* Top (4 bytes) */
- Stream_Read_UINT32(s, monitor->Width); /* Width (4 bytes) */
- Stream_Read_UINT32(s, monitor->Height); /* Height (4 bytes) */
- Stream_Read_UINT32(s, monitor->PhysicalWidth); /* PhysicalWidth (4 bytes) */
- Stream_Read_UINT32(s, monitor->PhysicalHeight); /* PhysicalHeight (4 bytes) */
- Stream_Read_UINT32(s, monitor->Orientation); /* Orientation (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Flags); /* Flags (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Left); /* Left (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Top); /* Top (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Width); /* Width (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Height); /* Height (4 bytes) */
+ Stream_Read_UINT32(s, monitor->PhysicalWidth); /* PhysicalWidth (4 bytes) */
+ Stream_Read_UINT32(s, monitor->PhysicalHeight); /* PhysicalHeight (4 bytes) */
+ Stream_Read_UINT32(s, monitor->Orientation); /* Orientation (4 bytes) */
Stream_Read_UINT32(s, monitor->DesktopScaleFactor); /* DesktopScaleFactor (4 bytes) */
- Stream_Read_UINT32(s, monitor->DeviceScaleFactor); /* DeviceScaleFactor (4 bytes) */
+ Stream_Read_UINT32(s, monitor->DeviceScaleFactor); /* DeviceScaleFactor (4 bytes) */
WLog_DBG(TAG,
- "\t%d : Flags: 0x%08"PRIX32" Left/Top: (%"PRId32",%"PRId32") W/H=%"PRIu32"x%"PRIu32")", index,
- monitor->Flags, monitor->Left, monitor->Top,
- monitor->Width,
+ "\t%d : Flags: 0x%08" PRIX32 " Left/Top: (%" PRId32 ",%" PRId32 ") W/H=%" PRIu32
+ "x%" PRIu32 ")",
+ index, monitor->Flags, monitor->Left, monitor->Top, monitor->Width,
monitor->Height);
- WLog_DBG(TAG, "\t PhysicalWidth: %"PRIu32" PhysicalHeight: %"PRIu32" Orientation: %"PRIu32"",
- monitor->PhysicalWidth, monitor->PhysicalHeight,
- monitor->Orientation);
+ WLog_DBG(TAG,
+ "\t PhysicalWidth: %" PRIu32 " PhysicalHeight: %" PRIu32 " Orientation: %" PRIu32
+ "",
+ monitor->PhysicalWidth, monitor->PhysicalHeight, monitor->Orientation);
if (!disp_server_is_monitor_layout_valid(monitor))
{
@@ -207,7 +208,6 @@ out:
return error;
}
-
static UINT disp_server_receive_pdu(DispServerContext* context, wStream* s)
{
UINT error = CHANNEL_RC_OK;
@@ -217,7 +217,7 @@ static UINT disp_server_receive_pdu(DispServerContext* context, wStream* s)
if ((error = disp_read_header(s, &header)))
{
- WLog_ERR(TAG, "disp_read_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "disp_read_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -225,14 +225,16 @@ static UINT disp_server_receive_pdu(DispServerContext* context, wStream* s)
{
case DISPLAY_CONTROL_PDU_TYPE_MONITOR_LAYOUT:
if ((error = disp_recv_display_control_monitor_layout_pdu(s, context)))
- WLog_ERR(TAG, "disp_recv_display_control_monitor_layout_pdu "
- "failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "disp_recv_display_control_monitor_layout_pdu "
+ "failed with error %" PRIu32 "!",
+ error);
break;
default:
error = CHANNEL_RC_BAD_PROC;
- WLog_WARN(TAG, "Received unknown PDU type: %"PRIu32"", header.type);
+ WLog_WARN(TAG, "Received unknown PDU type: %" PRIu32 "", header.type);
break;
}
@@ -240,8 +242,8 @@ static UINT disp_server_receive_pdu(DispServerContext* context, wStream* s)
if (end != (beg + header.length))
{
- WLog_ERR(TAG, "Unexpected DISP pdu end: Actual: %d, Expected: %"PRIu32"",
- end, (beg + header.length));
+ WLog_ERR(TAG, "Unexpected DISP pdu end: Actual: %d, Expected: %" PRIu32 "", end,
+ (beg + header.length));
Stream_SetPosition(s, (beg + header.length));
}
@@ -259,9 +261,8 @@ static UINT disp_server_handle_messages(DispServerContext* context)
/* Check whether the dynamic channel is ready */
if (!priv->isReady)
{
- if (WTSVirtualChannelQuery(priv->disp_channel,
- WTSVirtualChannelReady,
- &buffer, &BytesReturned) == FALSE)
+ if (WTSVirtualChannelQuery(priv->disp_channel, WTSVirtualChannelReady, &buffer,
+ &BytesReturned) == FALSE)
{
if (GetLastError() == ERROR_NO_DATA)
return ERROR_NO_DATA;
@@ -270,15 +271,14 @@ static UINT disp_server_handle_messages(DispServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- priv->isReady = *((BOOL*) buffer);
+ priv->isReady = *((BOOL*)buffer);
WTSFreeMemory(buffer);
}
/* Consume channel event only after the gfx dynamic channel is ready */
Stream_SetPosition(s, 0);
- if (!WTSVirtualChannelRead(priv->disp_channel,
- 0, NULL, 0, &BytesReturned))
+ if (!WTSVirtualChannelRead(priv->disp_channel, 0, NULL, 0, &BytesReturned))
{
if (GetLastError() == ERROR_NO_DATA)
return ERROR_NO_DATA;
@@ -296,9 +296,8 @@ static UINT disp_server_handle_messages(DispServerContext* context)
return CHANNEL_RC_NO_MEMORY;
}
- if (WTSVirtualChannelRead(priv->disp_channel, 0,
- (PCHAR) Stream_Buffer(s),
- Stream_Capacity(s), &BytesReturned) == FALSE)
+ if (WTSVirtualChannelRead(priv->disp_channel, 0, (PCHAR)Stream_Buffer(s), Stream_Capacity(s),
+ &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
return ERROR_INTERNAL_ERROR;
@@ -311,8 +310,10 @@ static UINT disp_server_handle_messages(DispServerContext* context)
{
if ((ret = disp_server_receive_pdu(context, s)))
{
- WLog_ERR(TAG, "disp_server_receive_pdu "
- "failed with error %"PRIu32"!", ret);
+ WLog_ERR(TAG,
+ "disp_server_receive_pdu "
+ "failed with error %" PRIu32 "!",
+ ret);
return ret;
}
}
@@ -322,7 +323,7 @@ static UINT disp_server_handle_messages(DispServerContext* context)
static DWORD WINAPI disp_server_thread_func(LPVOID arg)
{
- DispServerContext* context = (DispServerContext*) arg;
+ DispServerContext* context = (DispServerContext*)arg;
DispServerPrivate* priv = context->priv;
DWORD status;
DWORD nCount;
@@ -340,7 +341,7 @@ static DWORD WINAPI disp_server_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -350,8 +351,7 @@ static DWORD WINAPI disp_server_thread_func(LPVOID arg)
if ((error = disp_server_handle_messages(context)))
{
- WLog_ERR(TAG, "disp_server_handle_messages failed with error %"PRIu32"",
- error);
+ WLog_ERR(TAG, "disp_server_handle_messages failed with error %" PRIu32 "", error);
break;
}
}
@@ -360,7 +360,6 @@ static DWORD WINAPI disp_server_thread_func(LPVOID arg)
return error;
}
-
/**
* Function description
*
@@ -376,19 +375,17 @@ static UINT disp_server_open(DispServerContext* context)
buffer = NULL;
priv->SessionId = WTS_CURRENT_SESSION;
- if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION,
- WTSSessionId, (LPSTR*) &pSessionId,
- &BytesReturned) == FALSE)
+ if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION, WTSSessionId,
+ (LPSTR*)&pSessionId, &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSQuerySessionInformationA failed!");
rc = ERROR_INTERNAL_ERROR;
goto out_close;
}
- priv->SessionId = (DWORD) * pSessionId;
- priv->disp_channel = (HANDLE) WTSVirtualChannelOpenEx(priv->SessionId,
- DISP_DVC_CHANNEL_NAME,
- WTS_CHANNEL_OPTION_DYNAMIC);
+ priv->SessionId = (DWORD)*pSessionId;
+ priv->disp_channel = (HANDLE)WTSVirtualChannelOpenEx(priv->SessionId, DISP_DVC_CHANNEL_NAME,
+ WTS_CHANNEL_OPTION_DYNAMIC);
if (!priv->disp_channel)
{
@@ -398,12 +395,13 @@ static UINT disp_server_open(DispServerContext* context)
}
/* Query for channel event handle */
- if (!WTSVirtualChannelQuery(priv->disp_channel, WTSVirtualEventHandle,
- &buffer, &BytesReturned)
- || (BytesReturned != sizeof(HANDLE)))
+ if (!WTSVirtualChannelQuery(priv->disp_channel, WTSVirtualEventHandle, &buffer,
+ &BytesReturned) ||
+ (BytesReturned != sizeof(HANDLE)))
{
- WLog_ERR(TAG, "WTSVirtualChannelQuery failed "
- "or invalid returned size(%"PRIu32")",
+ WLog_ERR(TAG,
+ "WTSVirtualChannelQuery failed "
+ "or invalid returned size(%" PRIu32 ")",
BytesReturned);
if (buffer)
@@ -424,7 +422,8 @@ static UINT disp_server_open(DispServerContext* context)
rc = ERROR_INTERNAL_ERROR;
}
- if (!(priv->thread = CreateThread(NULL, 0, disp_server_thread_func, (void*) context, 0, NULL)))
+ if (!(priv->thread =
+ CreateThread(NULL, 0, disp_server_thread_func, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateEvent failed!");
CloseHandle(priv->stopEvent);
@@ -446,8 +445,7 @@ static UINT disp_server_packet_send(DispServerContext* context, wStream* s)
UINT ret;
ULONG written;
- if (!WTSVirtualChannelWrite(context->priv->disp_channel,
- (PCHAR) Stream_Buffer(s),
+ if (!WTSVirtualChannelWrite(context->priv->disp_channel, (PCHAR)Stream_Buffer(s),
Stream_GetPosition(s), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
@@ -457,8 +455,8 @@ static UINT disp_server_packet_send(DispServerContext* context, wStream* s)
if (written < Stream_GetPosition(s))
{
- WLog_WARN(TAG, "Unexpected bytes written: %"PRIu32"/%"PRIuz"",
- written, Stream_GetPosition(s));
+ WLog_WARN(TAG, "Unexpected bytes written: %" PRIu32 "/%" PRIuz "", written,
+ Stream_GetPosition(s));
}
ret = CHANNEL_RC_OK;
@@ -482,7 +480,7 @@ static UINT disp_server_send_caps_pdu(DispServerContext* context)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT32(s, context->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
+ Stream_Write_UINT32(s, context->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
Stream_Write_UINT32(s, context->MaxMonitorAreaFactorA); /* MaxMonitorAreaFactorA (4 bytes) */
Stream_Write_UINT32(s, context->MaxMonitorAreaFactorB); /* MaxMonitorAreaFactorB (4 bytes) */
return disp_server_packet_send(context, s);
@@ -505,7 +503,7 @@ static UINT disp_server_close(DispServerContext* context)
if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -522,7 +520,7 @@ DispServerContext* disp_server_context_new(HANDLE vcm)
{
DispServerContext* context;
DispServerPrivate* priv;
- context = (DispServerContext*) calloc(1, sizeof(DispServerContext));
+ context = (DispServerContext*)calloc(1, sizeof(DispServerContext));
if (!context)
{
@@ -530,7 +528,7 @@ DispServerContext* disp_server_context_new(HANDLE vcm)
goto out_free;
}
- priv = context->priv = (DispServerPrivate*) calloc(1, sizeof(DispServerPrivate));
+ priv = context->priv = (DispServerPrivate*)calloc(1, sizeof(DispServerPrivate));
if (!context->priv)
{
diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c
index dd08c9877..0d2a227b6 100644
--- a/channels/drdynvc/client/drdynvc_main.c
+++ b/channels/drdynvc/client/drdynvc_main.c
@@ -31,16 +31,15 @@
#define TAG CHANNELS_TAG("drdynvc.client")
static void dvcman_channel_free(void* channel);
-static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
- const BYTE* data, UINT32 dataSize);
+static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, const BYTE* data,
+ UINT32 dataSize);
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_get_configuration(IWTSListener* pListener,
- void** ppPropertyBag)
+static UINT dvcman_get_configuration(IWTSListener* pListener, void** ppPropertyBag)
{
WINPR_UNUSED(pListener);
*ppPropertyBag = NULL;
@@ -54,15 +53,16 @@ static UINT dvcman_get_configuration(IWTSListener* pListener,
*/
static UINT dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr,
const char* pszChannelName, ULONG ulFlags,
- IWTSListenerCallback* pListenerCallback, IWTSListener** ppListener)
+ IWTSListenerCallback* pListenerCallback,
+ IWTSListener** ppListener)
{
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
DVCMAN_LISTENER* listener;
if (dvcman->num_listeners < MAX_PLUGINS)
{
WLog_DBG(TAG, "create_listener: %d.%s.", dvcman->num_listeners, pszChannelName);
- listener = (DVCMAN_LISTENER*) calloc(1, sizeof(DVCMAN_LISTENER));
+ listener = (DVCMAN_LISTENER*)calloc(1, sizeof(DVCMAN_LISTENER));
if (!listener)
{
@@ -86,9 +86,9 @@ static UINT dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr,
listener->listener_callback = pListenerCallback;
if (ppListener)
- *ppListener = (IWTSListener*) listener;
+ *ppListener = (IWTSListener*)listener;
- dvcman->listeners[dvcman->num_listeners++] = (IWTSListener*) listener;
+ dvcman->listeners[dvcman->num_listeners++] = (IWTSListener*)listener;
return CHANNEL_RC_OK;
}
else
@@ -103,10 +103,10 @@ static UINT dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints,
- const char* name, IWTSPlugin* pPlugin)
+static UINT dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name,
+ IWTSPlugin* pPlugin)
{
- DVCMAN* dvcman = ((DVCMAN_ENTRY_POINTS*) pEntryPoints)->dvcman;
+ DVCMAN* dvcman = ((DVCMAN_ENTRY_POINTS*)pEntryPoints)->dvcman;
if (dvcman->num_plugins < MAX_PLUGINS)
{
@@ -117,22 +117,19 @@ static UINT dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints,
}
else
{
- WLog_ERR(TAG, "register_plugin: Maximum DVC plugin number %u reached.",
- MAX_PLUGINS);
+ WLog_ERR(TAG, "register_plugin: Maximum DVC plugin number %u reached.", MAX_PLUGINS);
return ERROR_INTERNAL_ERROR;
}
}
-static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints,
- const char* name)
+static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name)
{
int i;
- DVCMAN* dvcman = ((DVCMAN_ENTRY_POINTS*) pEntryPoints)->dvcman;
+ DVCMAN* dvcman = ((DVCMAN_ENTRY_POINTS*)pEntryPoints)->dvcman;
for (i = 0; i < dvcman->num_plugins; i++)
{
- if (dvcman->plugin_names[i] == name ||
- strcmp(dvcman->plugin_names[i], name) == 0)
+ if (dvcman->plugin_names[i] == name || strcmp(dvcman->plugin_names[i], name) == 0)
{
return dvcman->plugins[i];
}
@@ -143,30 +140,29 @@ static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints,
static ADDIN_ARGV* dvcman_get_plugin_data(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
- return ((DVCMAN_ENTRY_POINTS*) pEntryPoints)->args;
+ return ((DVCMAN_ENTRY_POINTS*)pEntryPoints)->args;
}
static void* dvcman_get_rdp_settings(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
- return (void*)((DVCMAN_ENTRY_POINTS*) pEntryPoints)->settings;
+ return (void*)((DVCMAN_ENTRY_POINTS*)pEntryPoints)->settings;
}
static UINT32 dvcman_get_channel_id(IWTSVirtualChannel* channel)
{
- return ((DVCMAN_CHANNEL*) channel)->channel_id;
+ return ((DVCMAN_CHANNEL*)channel)->channel_id;
}
-static IWTSVirtualChannel* dvcman_find_channel_by_id(IWTSVirtualChannelManager*
- pChannelMgr,
- UINT32 ChannelId)
+static IWTSVirtualChannel* dvcman_find_channel_by_id(IWTSVirtualChannelManager* pChannelMgr,
+ UINT32 ChannelId)
{
int index;
BOOL found = FALSE;
DVCMAN_CHANNEL* channel;
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
ArrayList_Lock(dvcman->channels);
index = 0;
- channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, index++);
+ channel = (DVCMAN_CHANNEL*)ArrayList_GetItem(dvcman->channels, index++);
while (channel)
{
@@ -176,17 +172,17 @@ static IWTSVirtualChannel* dvcman_find_channel_by_id(IWTSVirtualChannelManager*
break;
}
- channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, index++);
+ channel = (DVCMAN_CHANNEL*)ArrayList_GetItem(dvcman->channels, index++);
}
ArrayList_Unlock(dvcman->channels);
- return (found) ? ((IWTSVirtualChannel*) channel) : NULL;
+ return (found) ? ((IWTSVirtualChannel*)channel) : NULL;
}
static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
{
DVCMAN* dvcman;
- dvcman = (DVCMAN*) calloc(1, sizeof(DVCMAN));
+ dvcman = (DVCMAN*)calloc(1, sizeof(DVCMAN));
if (!dvcman)
{
@@ -218,7 +214,7 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
return NULL;
}
- return (IWTSVirtualChannelManager*) dvcman;
+ return (IWTSVirtualChannelManager*)dvcman;
}
/**
@@ -226,17 +222,14 @@ static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_load_addin(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
- ADDIN_ARGV* args,
- rdpSettings* settings)
+static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr,
+ ADDIN_ARGV* args, rdpSettings* settings)
{
DVCMAN_ENTRY_POINTS entryPoints;
PDVC_PLUGIN_ENTRY pDVCPluginEntry = NULL;
WLog_Print(drdynvc->log, WLOG_INFO, "Loading Dynamic Virtual Channel %s", args->argv[0]);
- pDVCPluginEntry = (PDVC_PLUGIN_ENTRY) freerdp_load_channel_addin_entry(
- args->argv[0],
- NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC);
+ pDVCPluginEntry = (PDVC_PLUGIN_ENTRY)freerdp_load_channel_addin_entry(
+ args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC);
if (pDVCPluginEntry)
{
@@ -244,30 +237,30 @@ static UINT dvcman_load_addin(drdynvcPlugin* drdynvc,
entryPoints.iface.GetPlugin = dvcman_get_plugin;
entryPoints.iface.GetPluginData = dvcman_get_plugin_data;
entryPoints.iface.GetRdpSettings = dvcman_get_rdp_settings;
- entryPoints.dvcman = (DVCMAN*) pChannelMgr;
+ entryPoints.dvcman = (DVCMAN*)pChannelMgr;
entryPoints.args = args;
entryPoints.settings = settings;
- return pDVCPluginEntry((IDRDYNVC_ENTRY_POINTS*) &entryPoints);
+ return pDVCPluginEntry((IDRDYNVC_ENTRY_POINTS*)&entryPoints);
}
return ERROR_INVALID_FUNCTION;
}
static DVCMAN_CHANNEL* dvcman_channel_new(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
- UINT32 ChannelId, const char* ChannelName)
+ IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId,
+ const char* ChannelName)
{
DVCMAN_CHANNEL* channel;
if (dvcman_find_channel_by_id(pChannelMgr, ChannelId))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "Protocol error: Duplicated ChannelId %"PRIu32" (%s)!",
- ChannelId,
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "Protocol error: Duplicated ChannelId %" PRIu32 " (%s)!", ChannelId,
ChannelName);
return NULL;
}
- channel = (DVCMAN_CHANNEL*) calloc(1, sizeof(DVCMAN_CHANNEL));
+ channel = (DVCMAN_CHANNEL*)calloc(1, sizeof(DVCMAN_CHANNEL));
if (!channel)
{
@@ -275,7 +268,7 @@ static DVCMAN_CHANNEL* dvcman_channel_new(drdynvcPlugin* drdynvc,
return NULL;
}
- channel->dvcman = (DVCMAN*) pChannelMgr;
+ channel->dvcman = (DVCMAN*)pChannelMgr;
channel->channel_id = ChannelId;
channel->channel_name = _strdup(ChannelName);
@@ -299,20 +292,19 @@ static DVCMAN_CHANNEL* dvcman_channel_new(drdynvcPlugin* drdynvc,
static void dvcman_channel_free(void* arg)
{
- DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*) arg;
+ DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*)arg;
UINT error = CHANNEL_RC_OK;
if (channel)
{
if (channel->channel_callback)
{
- IFCALL(channel->channel_callback->OnClose,
- channel->channel_callback);
+ IFCALL(channel->channel_callback->OnClose, channel->channel_callback);
}
if (channel->status == CHANNEL_RC_OK)
{
- IWTSVirtualChannel* ichannel = (IWTSVirtualChannel*) channel;
+ IWTSVirtualChannel* ichannel = (IWTSVirtualChannel*)channel;
if (channel->dvcman && channel->dvcman->drdynvc)
{
@@ -320,8 +312,7 @@ static void dvcman_channel_free(void* arg)
if (context)
{
- IFCALLRET(context->OnChannelDisconnected, error,
- context, channel->channel_name,
+ IFCALLRET(context->OnChannelDisconnected, error, context, channel->channel_name,
channel->pInterface);
}
}
@@ -329,7 +320,7 @@ static void dvcman_channel_free(void* arg)
error = IFCALLRESULT(CHANNEL_RC_OK, ichannel->Close, ichannel);
if (error != CHANNEL_RC_OK)
- WLog_ERR(TAG, "Close failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Close failed with error %" PRIu32 "!", error);
}
if (channel->dvc_data)
@@ -347,13 +338,13 @@ static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
int i;
IWTSPlugin* pPlugin;
DVCMAN_LISTENER* listener;
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
UINT error;
ArrayList_Free(dvcman->channels);
for (i = 0; i < dvcman->num_listeners; i++)
{
- listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
+ listener = (DVCMAN_LISTENER*)dvcman->listeners[i];
free(listener->channel_name);
free(listener);
}
@@ -366,7 +357,8 @@ static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
if (pPlugin->Terminated)
if ((error = pPlugin->Terminated(pPlugin)))
- WLog_Print(drdynvc->log, WLOG_ERROR, "Terminated failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "Terminated failed with error %" PRIu32 "!",
+ error);
}
dvcman->num_plugins = 0;
@@ -383,7 +375,7 @@ static UINT dvcman_init(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
{
int i;
IWTSPlugin* pPlugin;
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
UINT error;
for (i = 0; i < dvcman->num_plugins; i++)
@@ -393,7 +385,8 @@ static UINT dvcman_init(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
if (pPlugin->Initialize)
if ((error = pPlugin->Initialize(pPlugin, pChannelMgr)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "Initialize failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "Initialize failed with error %" PRIu32 "!",
+ error);
return error;
}
}
@@ -406,19 +399,18 @@ static UINT dvcman_init(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_write_channel(IWTSVirtualChannel* pChannel, ULONG cbSize,
- const BYTE* pBuffer, void* pReserved)
+static UINT dvcman_write_channel(IWTSVirtualChannel* pChannel, ULONG cbSize, const BYTE* pBuffer,
+ void* pReserved)
{
UINT status;
- DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*) pChannel;
+ DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*)pChannel;
WINPR_UNUSED(pReserved);
if (!channel || !channel->dvcman)
return CHANNEL_RC_BAD_CHANNEL;
EnterCriticalSection(&(channel->lock));
- status = drdynvc_write_data(channel->dvcman->drdynvc,
- channel->channel_id, pBuffer, cbSize);
+ status = drdynvc_write_data(channel->dvcman->drdynvc, channel->channel_id, pBuffer, cbSize);
LeaveCriticalSection(&(channel->lock));
return status;
}
@@ -430,12 +422,12 @@ static UINT dvcman_write_channel(IWTSVirtualChannel* pChannel, ULONG cbSize,
*/
static UINT dvcman_close_channel_iface(IWTSVirtualChannel* pChannel)
{
- DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*) pChannel;
+ DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*)pChannel;
if (!channel)
return CHANNEL_RC_BAD_CHANNEL;
- WLog_DBG(TAG, "close_channel_iface: id=%"PRIu32"", channel->channel_id);
+ WLog_DBG(TAG, "close_channel_iface: id=%" PRIu32 "", channel->channel_id);
return CHANNEL_RC_OK;
}
@@ -444,8 +436,7 @@ static UINT dvcman_close_channel_iface(IWTSVirtualChannel* pChannel)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
+static UINT dvcman_create_channel(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr,
UINT32 ChannelId, const char* ChannelName)
{
int i;
@@ -454,7 +445,7 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
DVCMAN_CHANNEL* channel;
DrdynvcClientContext* context;
IWTSVirtualChannelCallback* pCallback;
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
UINT error;
if (!(channel = dvcman_channel_new(drdynvc, pChannelMgr, ChannelId, ChannelName)))
@@ -468,7 +459,7 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
for (i = 0; i < dvcman->num_listeners; i++)
{
- listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
+ listener = (DVCMAN_LISTENER*)dvcman->listeners[i];
if (strcmp(listener->channel_name, ChannelName) == 0)
{
@@ -478,11 +469,11 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
pCallback = NULL;
if ((error = listener->listener_callback->OnNewChannelConnection(
- listener->listener_callback,
- (IWTSVirtualChannel*) channel, NULL, &bAccept, &pCallback)) == CHANNEL_RC_OK
- && bAccept)
+ listener->listener_callback, (IWTSVirtualChannel*)channel, NULL, &bAccept,
+ &pCallback)) == CHANNEL_RC_OK &&
+ bAccept)
{
- WLog_Print(drdynvc->log, WLOG_DEBUG, "listener %s created new channel %"PRIu32"",
+ WLog_Print(drdynvc->log, WLOG_DEBUG, "listener %s created new channel %" PRIu32 "",
listener->channel_name, channel->channel_id);
channel->status = CHANNEL_RC_OK;
channel->channel_callback = pCallback;
@@ -492,8 +483,8 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
listener->iface.pInterface);
if (error)
- WLog_Print(drdynvc->log, WLOG_ERROR, "context.OnChannelConnected failed with error %"PRIu32"",
- error);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "context.OnChannelConnected failed with error %" PRIu32 "", error);
return error;
}
@@ -501,12 +492,14 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
{
if (error)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "OnNewChannelConnection failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "OnNewChannelConnection failed with error %" PRIu32 "!", error);
return error;
}
else
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "OnNewChannelConnection returned with bAccept FALSE!");
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "OnNewChannelConnection returned with bAccept FALSE!");
return ERROR_INTERNAL_ERROR;
}
}
@@ -521,18 +514,17 @@ static UINT dvcman_create_channel(drdynvcPlugin* drdynvc,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_open_channel(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
+static UINT dvcman_open_channel(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr,
UINT32 ChannelId)
{
DVCMAN_CHANNEL* channel;
IWTSVirtualChannelCallback* pCallback;
UINT error;
- channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
+ channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %"PRIu32" not found!", ChannelId);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %" PRIu32 " not found!", ChannelId);
return ERROR_INTERNAL_ERROR;
}
@@ -542,11 +534,11 @@ static UINT dvcman_open_channel(drdynvcPlugin* drdynvc,
if ((pCallback->OnOpen) && (error = pCallback->OnOpen(pCallback)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "OnOpen failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "OnOpen failed with error %" PRIu32 "!", error);
return error;
}
- WLog_Print(drdynvc->log, WLOG_DEBUG, "open_channel: ChannelId %"PRIu32"", ChannelId);
+ WLog_Print(drdynvc->log, WLOG_DEBUG, "open_channel: ChannelId %" PRIu32 "", ChannelId);
}
return CHANNEL_RC_OK;
@@ -557,20 +549,19 @@ static UINT dvcman_open_channel(drdynvcPlugin* drdynvc,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr,
- UINT32 ChannelId)
+static UINT dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId)
{
DVCMAN_CHANNEL* channel;
UINT error = CHANNEL_RC_OK;
- DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
- channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
+ DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
+ channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
- //WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %"PRIu32" not found!", ChannelId);
+ // WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %"PRIu32" not found!", ChannelId);
/**
- * Windows 8 / Windows Server 2012 send close requests for channels that failed to be created.
- * Do not warn, simply return success here.
+ * Windows 8 / Windows Server 2012 send close requests for channels that failed to be
+ * created. Do not warn, simply return success here.
*/
return CHANNEL_RC_OK;
}
@@ -585,19 +576,20 @@ static UINT dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT dvcman_receive_channel_data_first(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
- UINT32 ChannelId, UINT32 length)
+ IWTSVirtualChannelManager* pChannelMgr,
+ UINT32 ChannelId, UINT32 length)
{
DVCMAN_CHANNEL* channel;
- channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
+ channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
/**
- * Windows Server 2012 R2 can send some messages over Microsoft::Windows::RDS::Geometry::v08.01
- * even if the dynamic virtual channel wasn't registered on our side. Ignoring it works.
+ * Windows Server 2012 R2 can send some messages over
+ * Microsoft::Windows::RDS::Geometry::v08.01 even if the dynamic virtual channel wasn't
+ * registered on our side. Ignoring it works.
*/
- WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %"PRIu32" not found!", ChannelId);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %" PRIu32 " not found!", ChannelId);
return CHANNEL_RC_OK;
}
@@ -622,19 +614,19 @@ static UINT dvcman_receive_channel_data_first(drdynvcPlugin* drdynvc,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT dvcman_receive_channel_data(drdynvcPlugin* drdynvc,
- IWTSVirtualChannelManager* pChannelMgr,
- UINT32 ChannelId, wStream* data)
+ IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId,
+ wStream* data)
{
UINT status = CHANNEL_RC_OK;
DVCMAN_CHANNEL* channel;
size_t dataSize = Stream_GetRemainingLength(data);
- channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
+ channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
/* Windows 8.1 tries to open channels not created.
- * Ignore cases like this. */
- WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %"PRIu32" not found!", ChannelId);
+ * Ignore cases like this. */
+ WLog_Print(drdynvc->log, WLOG_ERROR, "ChannelId %" PRIu32 " not found!", ChannelId);
return CHANNEL_RC_OK;
}
@@ -656,15 +648,14 @@ static UINT dvcman_receive_channel_data(drdynvcPlugin* drdynvc,
Stream_SealLength(channel->dvc_data);
Stream_SetPosition(channel->dvc_data, 0);
status = channel->channel_callback->OnDataReceived(channel->channel_callback,
- channel->dvc_data);
+ channel->dvc_data);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
}
}
else
{
- status = channel->channel_callback->OnDataReceived(channel->channel_callback,
- data);
+ status = channel->channel_callback->OnDataReceived(channel->channel_callback, data);
}
return status;
@@ -706,8 +697,9 @@ static UINT drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
status = CHANNEL_RC_BAD_CHANNEL_HANDLE;
else
{
- status = drdynvc->channelEntryPoints.pVirtualChannelWriteEx(drdynvc->InitHandle,
- drdynvc->OpenHandle, Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
+ status = drdynvc->channelEntryPoints.pVirtualChannelWriteEx(
+ drdynvc->InitHandle, drdynvc->OpenHandle, Stream_Buffer(s),
+ (UINT32)Stream_GetPosition(s), s);
}
switch (status)
@@ -726,9 +718,9 @@ static UINT drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
default:
Stream_Free(s, TRUE);
- WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(status),
- status);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
+ WTSErrorToString(status), status);
return status;
}
}
@@ -738,8 +730,8 @@ static UINT drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
- const BYTE* data, UINT32 dataSize)
+static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, const BYTE* data,
+ UINT32 dataSize)
{
wStream* data_out;
size_t pos;
@@ -751,8 +743,8 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
if (!drdynvc)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
- WLog_Print(drdynvc->log, WLOG_DEBUG, "write_data: ChannelId=%"PRIu32" size=%"PRIu32"", ChannelId,
- dataSize);
+ WLog_Print(drdynvc->log, WLOG_DEBUG, "write_data: ChannelId=%" PRIu32 " size=%" PRIu32 "",
+ ChannelId, dataSize);
data_out = Stream_New(NULL, CHANNEL_CHUNK_LENGTH);
if (!data_out)
@@ -827,7 +819,7 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
if (status != CHANNEL_RC_OK)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -857,14 +849,13 @@ static UINT drdynvc_send_capability_response(drdynvcPlugin* drdynvc)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s,
- 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */
+ Stream_Write_UINT16(s, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */
Stream_Write_UINT16(s, drdynvc->version);
status = drdynvc_send(drdynvc, s);
if (status != CHANNEL_RC_OK)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -876,8 +867,8 @@ static UINT drdynvc_send_capability_response(drdynvcPlugin* drdynvc)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp,
- int cbChId, wStream* s)
+static UINT drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, int cbChId,
+ wStream* s)
{
UINT status;
@@ -952,8 +943,7 @@ static UINT32 drdynvc_read_variable_uint(wStream* s, int cbLen)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
- int cbChId, wStream* s)
+static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
{
size_t pos;
UINT status;
@@ -996,8 +986,8 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
if (strnlen(name, length) >= length)
return ERROR_INVALID_DATA;
- WLog_Print(drdynvc->log, WLOG_DEBUG, "process_create_request: ChannelId=%"PRIu32" ChannelName=%s",
- ChannelId, name);
+ WLog_Print(drdynvc->log, WLOG_DEBUG,
+ "process_create_request: ChannelId=%" PRIu32 " ChannelName=%s", ChannelId, name);
channel_status = dvcman_create_channel(drdynvc, drdynvc->channel_mgr, ChannelId, name);
data_out = Stream_New(NULL, pos + 4);
@@ -1026,7 +1016,7 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
if (status != CHANNEL_RC_OK)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -1035,14 +1025,16 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
{
if ((status = dvcman_open_channel(drdynvc, drdynvc->channel_mgr, ChannelId)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_open_channel failed with error %"PRIu32"!", status);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "dvcman_open_channel failed with error %" PRIu32 "!", status);
return status;
}
}
else
{
if ((status = dvcman_close_channel(drdynvc->channel_mgr, ChannelId)))
- WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_close_channel failed with error %"PRIu32"!", status);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "dvcman_close_channel failed with error %" PRIu32 "!", status);
}
return status;
@@ -1053,8 +1045,7 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp,
- int cbChId, wStream* s)
+static UINT drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
{
UINT status;
UINT32 Length;
@@ -1066,10 +1057,9 @@ static UINT drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp,
ChannelId = drdynvc_read_variable_uint(s, cbChId);
Length = drdynvc_read_variable_uint(s, Sp);
WLog_Print(drdynvc->log, WLOG_DEBUG,
- "process_data_first: Sp=%d cbChId=%d, ChannelId=%"PRIu32" Length=%"PRIu32"", Sp,
+ "process_data_first: Sp=%d cbChId=%d, ChannelId=%" PRIu32 " Length=%" PRIu32 "", Sp,
cbChId, ChannelId, Length);
- status = dvcman_receive_channel_data_first(drdynvc, drdynvc->channel_mgr, ChannelId,
- Length);
+ status = dvcman_receive_channel_data_first(drdynvc, drdynvc->channel_mgr, ChannelId, Length);
if (status)
return status;
@@ -1082,8 +1072,7 @@ static UINT drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId,
- wStream* s)
+static UINT drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
{
UINT32 ChannelId;
@@ -1091,9 +1080,8 @@ static UINT drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId,
return ERROR_INVALID_DATA;
ChannelId = drdynvc_read_variable_uint(s, cbChId);
- WLog_Print(drdynvc->log, WLOG_TRACE, "process_data: Sp=%d cbChId=%d, ChannelId=%"PRIu32"", Sp,
- cbChId,
- ChannelId);
+ WLog_Print(drdynvc->log, WLOG_TRACE, "process_data: Sp=%d cbChId=%d, ChannelId=%" PRIu32 "", Sp,
+ cbChId, ChannelId);
return dvcman_receive_channel_data(drdynvc, drdynvc->channel_mgr, ChannelId, s);
}
@@ -1102,8 +1090,7 @@ static UINT drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp,
- int cbChId, wStream* s)
+static UINT drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
{
UINT8 value;
UINT error;
@@ -1114,13 +1101,14 @@ static UINT drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp,
return ERROR_INVALID_DATA;
ChannelId = drdynvc_read_variable_uint(s, cbChId);
- WLog_Print(drdynvc->log, WLOG_DEBUG, "process_close_request: Sp=%d cbChId=%d, ChannelId=%"PRIu32"",
- Sp,
- cbChId, ChannelId);
+ WLog_Print(drdynvc->log, WLOG_DEBUG,
+ "process_close_request: Sp=%d cbChId=%d, ChannelId=%" PRIu32 "", Sp, cbChId,
+ ChannelId);
if ((error = dvcman_close_channel(drdynvc->channel_mgr, ChannelId)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_close_channel failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_close_channel failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -1138,7 +1126,7 @@ static UINT drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp,
error = drdynvc_send(drdynvc, data_out);
if (error)
- WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(error), error);
return error;
@@ -1193,8 +1181,9 @@ static UINT drdynvc_order_recv(drdynvcPlugin* drdynvc, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drdynvc_virtual_channel_event_data_received(drdynvcPlugin* drdynvc,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT drdynvc_virtual_channel_event_data_received(drdynvcPlugin* drdynvc, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -1239,7 +1228,7 @@ static UINT drdynvc_virtual_channel_event_data_received(drdynvcPlugin* drdynvc,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(drdynvc->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(drdynvc->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_Print(drdynvc->log, WLOG_ERROR, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -1250,10 +1239,12 @@ static UINT drdynvc_virtual_channel_event_data_received(drdynvcPlugin* drdynvc,
}
static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event, LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- drdynvcPlugin* drdynvc = (drdynvcPlugin*) lpUserParam;
+ drdynvcPlugin* drdynvc = (drdynvcPlugin*)lpUserParam;
if (!drdynvc || (drdynvc->OpenHandle != openHandle))
{
@@ -1264,10 +1255,12 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength, totalLength,
- dataFlags)))
+ if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength,
+ totalLength, dataFlags)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_data_received failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_data_received failed with error %" PRIu32
+ "",
+ error);
break;
@@ -1277,14 +1270,15 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
}
if (error && drdynvc->rdpcontext)
- setChannelError(drdynvc->rdpcontext, error, "drdynvc_virtual_channel_open_event reported an error");
+ setChannelError(drdynvc->rdpcontext, error,
+ "drdynvc_virtual_channel_open_event reported an error");
}
static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
@@ -1292,11 +1286,11 @@ static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
wStream* data;
wMessage message;
UINT error = CHANNEL_RC_OK;
- drdynvcPlugin* drdynvc = (drdynvcPlugin*) arg;
+ drdynvcPlugin* drdynvc = (drdynvcPlugin*)arg;
if (!drdynvc)
{
- ExitThread((DWORD) CHANNEL_RC_BAD_CHANNEL_HANDLE);
+ ExitThread((DWORD)CHANNEL_RC_BAD_CHANNEL_HANDLE);
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
}
@@ -1321,12 +1315,13 @@ static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
if ((error = drdynvc_order_recv(drdynvc, data)))
{
Stream_Free(data, TRUE);
- WLog_Print(drdynvc->log, WLOG_ERROR, "drdynvc_order_recv failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR,
+ "drdynvc_order_recv failed with error %" PRIu32 "!", error);
break;
}
@@ -1336,14 +1331,14 @@ static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
{
/* Disconnect remaining dynamic channels that the server did not.
- * This is required to properly shut down channels by calling the appropriate
- * event handlers. */
+ * This is required to properly shut down channels by calling the appropriate
+ * event handlers. */
DVCMAN* drdynvcMgr = (DVCMAN*)drdynvc->channel_mgr;
while (ArrayList_Count(drdynvcMgr->channels) > 0)
{
- IWTSVirtualChannel* channel = (IWTSVirtualChannel*)
- ArrayList_GetItem(drdynvcMgr->channels, 0);
+ IWTSVirtualChannel* channel =
+ (IWTSVirtualChannel*)ArrayList_GetItem(drdynvcMgr->channels, 0);
const UINT32 ChannelId = drdynvc->channel_mgr->GetChannelId(channel);
dvcman_close_channel(drdynvc->channel_mgr, ChannelId);
}
@@ -1353,7 +1348,7 @@ static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
setChannelError(drdynvc->rdpcontext, error,
"drdynvc_virtual_channel_client_thread reported an error");
- ExitThread((DWORD) error);
+ ExitThread((DWORD)error);
return error;
}
@@ -1377,7 +1372,7 @@ static void drdynvc_queue_object_free(void* obj)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVOID pData,
- UINT32 dataLength)
+ UINT32 dataLength)
{
UINT error;
UINT32 status;
@@ -1391,12 +1386,13 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
if (!drdynvc)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
- status = drdynvc->channelEntryPoints.pVirtualChannelOpenEx(drdynvc->InitHandle,
- &drdynvc->OpenHandle, drdynvc->channelDef.name, drdynvc_virtual_channel_open_event_ex);
+ status = drdynvc->channelEntryPoints.pVirtualChannelOpenEx(
+ drdynvc->InitHandle, &drdynvc->OpenHandle, drdynvc->channelDef.name,
+ drdynvc_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelOpen failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -1420,7 +1416,7 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
goto error;
}
- settings = (rdpSettings*) drdynvc->channelEntryPoints.pExtendedData;
+ settings = (rdpSettings*)drdynvc->channelEntryPoints.pExtendedData;
for (index = 0; index < settings->DynamicChannelCount; index++)
{
@@ -1433,15 +1429,14 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
if ((error = dvcman_init(drdynvc, drdynvc->channel_mgr)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_init failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "dvcman_init failed with error %" PRIu32 "!", error);
goto error;
}
drdynvc->state = DRDYNVC_STATE_CAPABILITIES;
if (!(drdynvc->thread = CreateThread(NULL, 0, drdynvc_virtual_channel_client_thread,
- (void*) drdynvc,
- 0, NULL)))
+ (void*)drdynvc, 0, NULL)))
{
error = ERROR_INTERNAL_ERROR;
WLog_Print(drdynvc->log, WLOG_ERROR, "CreateThread failed!");
@@ -1470,14 +1465,16 @@ static UINT drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
if (!MessageQueue_PostQuit(drdynvc->queue, 0))
{
status = GetLastError();
- WLog_Print(drdynvc->log, WLOG_ERROR, "MessageQueue_PostQuit failed with error %"PRIu32"", status);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "MessageQueue_PostQuit failed with error %" PRIu32 "",
+ status);
return status;
}
if (WaitForSingleObject(drdynvc->thread, INFINITE) != WAIT_OBJECT_0)
{
status = GetLastError();
- WLog_Print(drdynvc->log, WLOG_ERROR, "WaitForSingleObject failed with error %"PRIu32"", status);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "WaitForSingleObject failed with error %" PRIu32 "",
+ status);
return status;
}
@@ -1486,11 +1483,11 @@ static UINT drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
drdynvc->queue = NULL;
drdynvc->thread = NULL;
status = drdynvc->channelEntryPoints.pVirtualChannelCloseEx(drdynvc->InitHandle,
- drdynvc->OpenHandle);
+ drdynvc->OpenHandle);
if (status != CHANNEL_RC_OK)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelClose failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelClose failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -1535,7 +1532,7 @@ static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc)
if (!drdynvc)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
- dvcman = (DVCMAN*) drdynvc->channel_mgr;
+ dvcman = (DVCMAN*)drdynvc->channel_mgr;
if (!dvcman)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@@ -1548,7 +1545,8 @@ static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc)
if (pPlugin->Attached)
if ((error = pPlugin->Attached(pPlugin)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "Attach failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "Attach failed with error %" PRIu32 "!",
+ error);
return error;
}
}
@@ -1564,7 +1562,7 @@ static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc)
if (!drdynvc)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
- dvcman = (DVCMAN*) drdynvc->channel_mgr;
+ dvcman = (DVCMAN*)drdynvc->channel_mgr;
if (!dvcman)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@@ -1577,7 +1575,8 @@ static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc)
if (pPlugin->Detached)
if ((error = pPlugin->Detached(pPlugin)))
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "Detach failed with error %"PRIu32"!", error);
+ WLog_Print(drdynvc->log, WLOG_ERROR, "Detach failed with error %" PRIu32 "!",
+ error);
return error;
}
}
@@ -1586,10 +1585,11 @@ static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc)
}
static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData,
+ UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- drdynvcPlugin* drdynvc = (drdynvcPlugin*) lpUserParam;
+ drdynvcPlugin* drdynvc = (drdynvcPlugin*)lpUserParam;
if (!drdynvc || (drdynvc->InitHandle != pInitHandle))
{
@@ -1602,35 +1602,41 @@ static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam,
case CHANNEL_EVENT_CONNECTED:
if ((error = drdynvc_virtual_channel_event_connected(drdynvc, pData, dataLength)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_connected failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_connected failed with error %" PRIu32 "",
+ error);
break;
case CHANNEL_EVENT_DISCONNECTED:
- if ((error = drdynvc_virtual_channel_event_disconnected(drdynvc)))
+ if ((error = drdynvc_virtual_channel_event_disconnected(drdynvc)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_disconnected failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_disconnected failed with error %" PRIu32
+ "",
+ error);
break;
case CHANNEL_EVENT_TERMINATED:
- if ((error = drdynvc_virtual_channel_event_terminated(drdynvc)))
+ if ((error = drdynvc_virtual_channel_event_terminated(drdynvc)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_terminated failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_terminated failed with error %" PRIu32 "",
+ error);
break;
case CHANNEL_EVENT_ATTACHED:
- if ((error = drdynvc_virtual_channel_event_attached(drdynvc)))
+ if ((error = drdynvc_virtual_channel_event_attached(drdynvc)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_attached failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_attached failed with error %" PRIu32 "",
+ error);
break;
case CHANNEL_EVENT_DETACHED:
- if ((error = drdynvc_virtual_channel_event_detached(drdynvc)))
+ if ((error = drdynvc_virtual_channel_event_detached(drdynvc)))
WLog_Print(drdynvc->log, WLOG_ERROR,
- "drdynvc_virtual_channel_event_detached failed with error %"PRIu32"", error);
+ "drdynvc_virtual_channel_event_detached failed with error %" PRIu32 "",
+ error);
break;
@@ -1649,12 +1655,12 @@ static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam,
static int drdynvc_get_version(DrdynvcClientContext* context)
{
- drdynvcPlugin* drdynvc = (drdynvcPlugin*) context->handle;
+ drdynvcPlugin* drdynvc = (drdynvcPlugin*)context->handle;
return drdynvc->version;
}
/* drdynvc is always built-in */
-#define VirtualChannelEntryEx drdynvc_VirtualChannelEntryEx
+#define VirtualChannelEntryEx drdynvc_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOID pInitHandle)
{
@@ -1662,7 +1668,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
drdynvcPlugin* drdynvc;
DrdynvcClientContext* context = NULL;
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
- drdynvc = (drdynvcPlugin*) calloc(1, sizeof(drdynvcPlugin));
+ drdynvc = (drdynvcPlugin*)calloc(1, sizeof(drdynvcPlugin));
if (!drdynvc)
{
@@ -1671,17 +1677,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
}
drdynvc->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP;
+ CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP;
sprintf_s(drdynvc->channelDef.name, ARRAYSIZE(drdynvc->channelDef.name), "drdynvc");
drdynvc->state = DRDYNVC_STATE_INITIAL;
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
- context = (DrdynvcClientContext*) calloc(1, sizeof(DrdynvcClientContext));
+ context = (DrdynvcClientContext*)calloc(1, sizeof(DrdynvcClientContext));
if (!context)
{
@@ -1690,7 +1694,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
return FALSE;
}
- context->handle = (void*) drdynvc;
+ context->handle = (void*)drdynvc;
context->custom = NULL;
drdynvc->context = context;
context->GetVersion = drdynvc_get_version;
@@ -1699,14 +1703,16 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
drdynvc->log = WLog_Get(TAG);
WLog_Print(drdynvc->log, WLOG_DEBUG, "VirtualChannelEntryEx");
- CopyMemory(&(drdynvc->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
+ CopyMemory(&(drdynvc->channelEntryPoints), pEntryPoints,
+ sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
drdynvc->InitHandle = pInitHandle;
- rc = drdynvc->channelEntryPoints.pVirtualChannelInitEx(drdynvc, context, pInitHandle,
- &drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, drdynvc_virtual_channel_init_event_ex);
+ rc = drdynvc->channelEntryPoints.pVirtualChannelInitEx(
+ drdynvc, context, pInitHandle, &drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ drdynvc_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelInit failed with %s [%08"PRIX32"]",
+ WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelInit failed with %s [%08" PRIX32 "]",
WTSErrorToString(rc), rc);
free(drdynvc->context);
free(drdynvc);
@@ -1716,4 +1722,3 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
drdynvc->channelEntryPoints.pInterface = context;
return TRUE;
}
-
diff --git a/channels/drdynvc/client/drdynvc_main.h b/channels/drdynvc/client/drdynvc_main.h
index 7492465c0..4b69f9d51 100644
--- a/channels/drdynvc/client/drdynvc_main.h
+++ b/channels/drdynvc/client/drdynvc_main.h
@@ -106,11 +106,11 @@ enum _DRDYNVC_STATE
};
typedef enum _DRDYNVC_STATE DRDYNVC_STATE;
-#define CREATE_REQUEST_PDU 0x01
-#define DATA_FIRST_PDU 0x02
-#define DATA_PDU 0x03
-#define CLOSE_REQUEST_PDU 0x04
-#define CAPABILITY_REQUEST_PDU 0x05
+#define CREATE_REQUEST_PDU 0x01
+#define DATA_FIRST_PDU 0x02
+#define DATA_PDU 0x03
+#define CLOSE_REQUEST_PDU 0x04
+#define CAPABILITY_REQUEST_PDU 0x05
struct drdynvc_plugin
{
diff --git a/channels/drdynvc/server/drdynvc_main.c b/channels/drdynvc/server/drdynvc_main.c
index b9639704b..66440b27b 100644
--- a/channels/drdynvc/server/drdynvc_main.c
+++ b/channels/drdynvc/server/drdynvc_main.c
@@ -32,7 +32,6 @@
#define TAG CHANNELS_TAG("drdynvc.server")
-
static DWORD WINAPI drdynvc_server_thread(LPVOID arg)
{
#if 0
@@ -121,8 +120,8 @@ static DWORD WINAPI drdynvc_server_thread(LPVOID arg)
*/
static UINT drdynvc_server_start(DrdynvcServerContext* context)
{
- context->priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm,
- WTS_CURRENT_SESSION, "drdynvc");
+ context->priv->ChannelHandle =
+ WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "drdynvc");
if (!context->priv->ChannelHandle)
{
@@ -136,7 +135,8 @@ static UINT drdynvc_server_start(DrdynvcServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(context->priv->Thread = CreateThread(NULL, 0, drdynvc_server_thread, (void*) context, 0, NULL)))
+ if (!(context->priv->Thread =
+ CreateThread(NULL, 0, drdynvc_server_thread, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(context->priv->StopEvent);
@@ -160,7 +160,7 @@ static UINT drdynvc_server_stop(DrdynvcServerContext* context)
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -171,14 +171,14 @@ static UINT drdynvc_server_stop(DrdynvcServerContext* context)
DrdynvcServerContext* drdynvc_server_context_new(HANDLE vcm)
{
DrdynvcServerContext* context;
- context = (DrdynvcServerContext*) calloc(1, sizeof(DrdynvcServerContext));
+ context = (DrdynvcServerContext*)calloc(1, sizeof(DrdynvcServerContext));
if (context)
{
context->vcm = vcm;
context->Start = drdynvc_server_start;
context->Stop = drdynvc_server_stop;
- context->priv = (DrdynvcServerPrivate*) calloc(1, sizeof(DrdynvcServerPrivate));
+ context->priv = (DrdynvcServerPrivate*)calloc(1, sizeof(DrdynvcServerPrivate));
if (!context->priv)
{
diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c
index c0e36f503..8f03fd858 100644
--- a/channels/drive/client/drive_file.c
+++ b/channels/drive/client/drive_file.c
@@ -46,9 +46,19 @@
#include "drive_file.h"
#ifdef WITH_DEBUG_RDPDR
-#define DEBUG_WSTR(msg, wstr) do { LPSTR lpstr; ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &lpstr, 0, NULL, NULL); WLog_DBG(TAG, msg, lpstr); free(lpstr); } while (0)
+#define DEBUG_WSTR(msg, wstr) \
+ do \
+ { \
+ LPSTR lpstr; \
+ ConvertFromUnicode(CP_UTF8, 0, wstr, -1, &lpstr, 0, NULL, NULL); \
+ WLog_DBG(TAG, msg, lpstr); \
+ free(lpstr); \
+ } while (0)
#else
-#define DEBUG_WSTR(msg, wstr) do { } while (0)
+#define DEBUG_WSTR(msg, wstr) \
+ do \
+ { \
+ } while (0)
#endif
static void drive_file_fix_path(WCHAR* path)
@@ -79,7 +89,7 @@ static void drive_file_fix_path(WCHAR* path)
}
static WCHAR* drive_file_combine_fullpath(const WCHAR* base_path, const WCHAR* path,
- size_t PathLength)
+ size_t PathLength)
{
WCHAR* fullpath;
size_t base_path_length;
@@ -140,8 +150,8 @@ static BOOL drive_file_remove_dir(const WCHAR* path)
{
size_t len = _wcslen(findFileData.cFileName);
- if ((len == 1 && findFileData.cFileName[0] == L'.') || (len == 2 &&
- findFileData.cFileName[0] == L'.' && findFileData.cFileName[1] == L'.'))
+ if ((len == 1 && findFileData.cFileName[0] == L'.') ||
+ (len == 2 && findFileData.cFileName[0] == L'.' && findFileData.cFileName[1] == L'.'))
{
continue;
}
@@ -162,8 +172,7 @@ static BOOL drive_file_remove_dir(const WCHAR* path)
if (!ret)
break;
- }
- while (ret && FindNextFileW(dir, &findFileData) != 0);
+ } while (ret && FindNextFileW(dir, &findFileData) != 0);
FindClose(dir);
@@ -238,7 +247,8 @@ static BOOL drive_file_init(DRIVE_FILE* file)
if (file->is_dir)
{
/* Should only create the directory if the disposition allows for it */
- if ((file->CreateDisposition == FILE_OPEN_IF) || (file->CreateDisposition == FILE_CREATE))
+ if ((file->CreateDisposition == FILE_OPEN_IF) ||
+ (file->CreateDisposition == FILE_CREATE))
{
if (CreateDirectoryW(file->fullpath, NULL) != 0)
{
@@ -255,27 +265,33 @@ static BOOL drive_file_init(DRIVE_FILE* file)
{
switch (file->CreateDisposition)
{
- case FILE_SUPERSEDE: /* If the file already exists, replace it with the given file. If it does not, create the given file. */
+ case FILE_SUPERSEDE: /* If the file already exists, replace it with the given file. If
+ it does not, create the given file. */
CreateDisposition = CREATE_ALWAYS;
break;
- case FILE_OPEN: /* If the file already exists, open it instead of creating a new file. If it does not, fail the request and do not create a new file. */
+ case FILE_OPEN: /* If the file already exists, open it instead of creating a new file.
+ If it does not, fail the request and do not create a new file. */
CreateDisposition = OPEN_EXISTING;
break;
- case FILE_CREATE: /* If the file already exists, fail the request and do not create or open the given file. If it does not, create the given file. */
+ case FILE_CREATE: /* If the file already exists, fail the request and do not create or
+ open the given file. If it does not, create the given file. */
CreateDisposition = CREATE_NEW;
break;
- case FILE_OPEN_IF: /* If the file already exists, open it. If it does not, create the given file. */
+ case FILE_OPEN_IF: /* If the file already exists, open it. If it does not, create the
+ given file. */
CreateDisposition = OPEN_ALWAYS;
break;
- case FILE_OVERWRITE: /* If the file already exists, open it and overwrite it. If it does not, fail the request. */
+ case FILE_OVERWRITE: /* If the file already exists, open it and overwrite it. If it does
+ not, fail the request. */
CreateDisposition = TRUNCATE_EXISTING;
break;
- case FILE_OVERWRITE_IF: /* If the file already exists, open it and overwrite it. If it does not, create the given file. */
+ case FILE_OVERWRITE_IF: /* If the file already exists, open it and overwrite it. If it
+ does not, create the given file. */
CreateDisposition = CREATE_ALWAYS;
break;
@@ -286,9 +302,8 @@ static BOOL drive_file_init(DRIVE_FILE* file)
#ifndef WIN32
file->SharedAccess = 0;
#endif
- file->file_handle = CreateFileW(file->fullpath, file->DesiredAccess,
- file->SharedAccess, NULL, CreateDisposition,
- file->FileAttributes, NULL);
+ file->file_handle = CreateFileW(file->fullpath, file->DesiredAccess, file->SharedAccess,
+ NULL, CreateDisposition, file->FileAttributes, NULL);
}
#ifdef WIN32
@@ -300,9 +315,11 @@ static BOOL drive_file_init(DRIVE_FILE* file)
if (errorMessageID != 0)
{
LPSTR messageBuffer = NULL;
- size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
+ size_t size =
+ FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&messageBuffer, 0, NULL);
WLog_ERR(TAG, "Error in drive_file_init: %s %s", messageBuffer, file->fullpath);
/* Free the buffer. */
LocalFree(messageBuffer);
@@ -316,15 +333,15 @@ static BOOL drive_file_init(DRIVE_FILE* file)
}
DRIVE_FILE* drive_file_new(const WCHAR* base_path, const WCHAR* path, UINT32 PathLength, UINT32 id,
- UINT32 DesiredAccess, UINT32 CreateDisposition,
- UINT32 CreateOptions, UINT32 FileAttributes, UINT32 SharedAccess)
+ UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions,
+ UINT32 FileAttributes, UINT32 SharedAccess)
{
DRIVE_FILE* file;
if (!base_path || !path)
return NULL;
- file = (DRIVE_FILE*) calloc(1, sizeof(DRIVE_FILE));
+ file = (DRIVE_FILE*)calloc(1, sizeof(DRIVE_FILE));
if (!file)
{
@@ -465,15 +482,23 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w
goto out_fail;
Stream_Write_UINT32(output, 36); /* Length */
- Stream_Write_UINT32(output, fileAttributes.ftCreationTime.dwLowDateTime); /* CreationTime */
- Stream_Write_UINT32(output, fileAttributes.ftCreationTime.dwHighDateTime); /* CreationTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, fileAttributes.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, fileAttributes.dwFileAttributes); /* FileAttributes */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftCreationTime.dwLowDateTime); /* CreationTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftCreationTime.dwHighDateTime); /* CreationTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(
+ output, fileAttributes.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output,
+ fileAttributes.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output, fileAttributes.dwFileAttributes); /* FileAttributes */
/* Reserved(4), MUST NOT be added! */
break;
@@ -483,15 +508,16 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w
if (!Stream_EnsureRemainingCapacity(output, 4 + 22))
goto out_fail;
- Stream_Write_UINT32(output, 22); /* Length */
- Stream_Write_UINT32(output, fileAttributes.nFileSizeLow); /* AllocationSize */
+ Stream_Write_UINT32(output, 22); /* Length */
+ Stream_Write_UINT32(output, fileAttributes.nFileSizeLow); /* AllocationSize */
Stream_Write_UINT32(output, fileAttributes.nFileSizeHigh); /* AllocationSize */
- Stream_Write_UINT32(output, fileAttributes.nFileSizeLow); /* EndOfFile */
+ Stream_Write_UINT32(output, fileAttributes.nFileSizeLow); /* EndOfFile */
Stream_Write_UINT32(output, fileAttributes.nFileSizeHigh); /* EndOfFile */
- Stream_Write_UINT32(output, 0); /* NumberOfLinks */
- Stream_Write_UINT8(output, file->delete_pending ? 1 : 0); /* DeletePending */
- Stream_Write_UINT8(output, fileAttributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? TRUE :
- FALSE); /* Directory */
+ Stream_Write_UINT32(output, 0); /* NumberOfLinks */
+ Stream_Write_UINT8(output, file->delete_pending ? 1 : 0); /* DeletePending */
+ Stream_Write_UINT8(output, fileAttributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
+ ? TRUE
+ : FALSE); /* Directory */
/* Reserved(2), MUST NOT be added! */
break;
@@ -501,9 +527,9 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w
if (!Stream_EnsureRemainingCapacity(output, 4 + 8))
goto out_fail;
- Stream_Write_UINT32(output, 8); /* Length */
+ Stream_Write_UINT32(output, 8); /* Length */
Stream_Write_UINT32(output, fileAttributes.dwFileAttributes); /* FileAttributes */
- Stream_Write_UINT32(output, 0); /* ReparseTag */
+ Stream_Write_UINT32(output, 0); /* ReparseTag */
break;
default:
@@ -560,7 +586,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (file->file_handle == INVALID_HANDLE_VALUE)
{
- WLog_ERR(TAG, "Unable to set file time %s (%"PRId32")", file->fullpath, GetLastError());
+ WLog_ERR(TAG, "Unable to set file time %s (%" PRId32 ")", file->fullpath,
+ GetLastError());
return FALSE;
}
@@ -595,7 +622,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
DEBUG_WSTR("SetFileTime %s", file->fullpath);
SetFileAttributesW(file->fullpath, FileAttributes);
- if (!SetFileTime(file->file_handle, pftCreationTime, pftLastAccessTime, pftLastWriteTime))
+ if (!SetFileTime(file->file_handle, pftCreationTime, pftLastAccessTime,
+ pftLastWriteTime))
{
WLog_ERR(TAG, "Unable to set file time to %s", file->fullpath);
return FALSE;
@@ -615,8 +643,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (file->file_handle == INVALID_HANDLE_VALUE)
{
- WLog_ERR(TAG, "Unable to truncate %s to %"PRId64" (%"PRId32")", file->fullpath, size,
- GetLastError());
+ WLog_ERR(TAG, "Unable to truncate %s to %" PRId64 " (%" PRId32 ")", file->fullpath,
+ size, GetLastError());
return FALSE;
}
@@ -624,7 +652,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (!SetFilePointerEx(file->file_handle, liSize, NULL, FILE_BEGIN))
{
- WLog_ERR(TAG, "Unable to truncate %s to %d (%"PRId32")", file->fullpath, size, GetLastError());
+ WLog_ERR(TAG, "Unable to truncate %s to %d (%" PRId32 ")", file->fullpath, size,
+ GetLastError());
return FALSE;
}
@@ -632,7 +661,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (SetEndOfFile(file->file_handle) == 0)
{
- WLog_ERR(TAG, "Unable to truncate %s to %d (%"PRId32")", file->fullpath, size, GetLastError());
+ WLog_ERR(TAG, "Unable to truncate %s to %d (%" PRId32 ")", file->fullpath, size,
+ GetLastError());
return FALSE;
}
@@ -703,7 +733,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
DEBUG_WSTR("MoveFileExW %s", file->fullpath);
if (MoveFileExW(file->fullpath, fullpath,
- MOVEFILE_COPY_ALLOWED | (ReplaceIfExists ? MOVEFILE_REPLACE_EXISTING : 0)))
+ MOVEFILE_COPY_ALLOWED |
+ (ReplaceIfExists ? MOVEFILE_REPLACE_EXISTING : 0)))
{
if (!drive_file_set_fullpath(file, fullpath))
return FALSE;
@@ -766,22 +797,30 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT
goto out_fail;
Stream_Write_UINT32(output, (UINT32)(64 + length)); /* Length */
- Stream_Write_UINT32(output, 0); /* NextEntryOffset */
- Stream_Write_UINT32(output, 0); /* FileIndex */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
+ Stream_Write_UINT32(output, 0); /* NextEntryOffset */
+ Stream_Write_UINT32(output, 0); /* FileIndex */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
Stream_Write_UINT32(output, file->find_data.dwFileAttributes); /* FileAttributes */
- Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
+ Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
Stream_Write(output, file->find_data.cFileName, length);
break;
@@ -795,23 +834,31 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT
goto out_fail;
Stream_Write_UINT32(output, (UINT32)(68 + length)); /* Length */
- Stream_Write_UINT32(output, 0); /* NextEntryOffset */
- Stream_Write_UINT32(output, 0); /* FileIndex */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
+ Stream_Write_UINT32(output, 0); /* NextEntryOffset */
+ Stream_Write_UINT32(output, 0); /* FileIndex */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
Stream_Write_UINT32(output, file->find_data.dwFileAttributes); /* FileAttributes */
- Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
- Stream_Write_UINT32(output, 0); /* EaSize */
+ Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
+ Stream_Write_UINT32(output, 0); /* EaSize */
Stream_Write(output, file->find_data.cFileName, length);
break;
@@ -825,24 +872,32 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT
goto out_fail;
Stream_Write_UINT32(output, (UINT32)(93 + length)); /* Length */
- Stream_Write_UINT32(output, 0); /* NextEntryOffset */
- Stream_Write_UINT32(output, 0); /* FileIndex */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
- Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
- Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
+ Stream_Write_UINT32(output, 0); /* NextEntryOffset */
+ Stream_Write_UINT32(output, 0); /* FileIndex */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwLowDateTime); /* CreationTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftCreationTime.dwHighDateTime); /* CreationTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwLowDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(
+ output, file->find_data.ftLastAccessTime.dwHighDateTime); /* LastAccessTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* LastWriteTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwLowDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output,
+ file->find_data.ftLastWriteTime.dwHighDateTime); /* ChangeTime */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* EndOfFile */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeLow); /* AllocationSize */
+ Stream_Write_UINT32(output, file->find_data.nFileSizeHigh); /* AllocationSize */
Stream_Write_UINT32(output, file->find_data.dwFileAttributes); /* FileAttributes */
- Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
- Stream_Write_UINT32(output, 0); /* EaSize */
- Stream_Write_UINT8(output, 0); /* ShortNameLength */
+ Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
+ Stream_Write_UINT32(output, 0); /* EaSize */
+ Stream_Write_UINT8(output, 0); /* ShortNameLength */
/* Reserved(1), MUST NOT be added! */
Stream_Zero(output, 24); /* ShortName */
Stream_Write(output, file->find_data.cFileName, length);
@@ -858,14 +913,14 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT
goto out_fail;
Stream_Write_UINT32(output, (UINT32)(12 + length)); /* Length */
- Stream_Write_UINT32(output, 0); /* NextEntryOffset */
- Stream_Write_UINT32(output, 0); /* FileIndex */
- Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
+ Stream_Write_UINT32(output, 0); /* NextEntryOffset */
+ Stream_Write_UINT32(output, 0); /* FileIndex */
+ Stream_Write_UINT32(output, (UINT32)length); /* FileNameLength */
Stream_Write(output, file->find_data.cFileName, length);
break;
default:
- WLog_ERR(TAG, "unhandled FsInformationClass %"PRIu32, FsInformationClass);
+ WLog_ERR(TAG, "unhandled FsInformationClass %" PRIu32, FsInformationClass);
/* Unhandled FsInformationClass */
goto out_fail;
}
@@ -873,6 +928,6 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT
return TRUE;
out_fail:
Stream_Write_UINT32(output, 0); /* Length */
- Stream_Write_UINT8(output, 0); /* Padding */
+ Stream_Write_UINT8(output, 0); /* Padding */
return FALSE;
}
diff --git a/channels/drive/client/drive_file.h b/channels/drive/client/drive_file.h
index 45e76128a..ed789d6f0 100644
--- a/channels/drive/client/drive_file.h
+++ b/channels/drive/client/drive_file.h
@@ -52,8 +52,8 @@ struct _DRIVE_FILE
};
DRIVE_FILE* drive_file_new(const WCHAR* base_path, const WCHAR* path, UINT32 PathLength, UINT32 id,
- UINT32 DesiredAccess, UINT32 CreateDisposition,
- UINT32 CreateOptions, UINT32 FileAttributes, UINT32 SharedAccess);
+ UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions,
+ UINT32 FileAttributes, UINT32 SharedAccess);
BOOL drive_file_free(DRIVE_FILE* file);
BOOL drive_file_open(DRIVE_FILE* file);
diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c
index 2b7c3dd03..8340d3071 100644
--- a/channels/drive/client/drive_main.c
+++ b/channels/drive/client/drive_main.c
@@ -102,7 +102,7 @@ static DWORD drive_map_windows_err(DWORD fs_errno)
case ERROR_FILE_EXISTS:
case ERROR_ALREADY_EXISTS:
- rc = STATUS_OBJECT_NAME_COLLISION;
+ rc = STATUS_OBJECT_NAME_COLLISION;
break;
case ERROR_INVALID_NAME:
@@ -127,7 +127,7 @@ static DWORD drive_map_windows_err(DWORD fs_errno)
default:
rc = STATUS_UNSUCCESSFUL;
- WLog_ERR(TAG, "Error code not found: %"PRIu32"", fs_errno);
+ WLog_ERR(TAG, "Error code not found: %" PRIu32 "", fs_errno);
break;
}
@@ -137,12 +137,12 @@ static DWORD drive_map_windows_err(DWORD fs_errno)
static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* drive, UINT32 id)
{
DRIVE_FILE* file = NULL;
- void* key = (void*)(size_t) id;
+ void* key = (void*)(size_t)id;
if (!drive)
return NULL;
- file = (DRIVE_FILE*) ListDictionary_GetItemValue(drive->files, key);
+ file = (DRIVE_FILE*)ListDictionary_GetItemValue(drive->files, key);
return file;
}
@@ -182,7 +182,7 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
if (Stream_GetRemainingLength(irp->input) < PathLength)
return ERROR_INVALID_DATA;
- path = (WCHAR*) Stream_Pointer(irp->input);
+ path = (WCHAR*)Stream_Pointer(irp->input);
FileId = irp->devman->id_sequence++;
file = drive_file_new(drive->path, path, PathLength, FileId, DesiredAccess, CreateDisposition,
CreateOptions, FileAttributes, SharedAccess);
@@ -195,7 +195,7 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
}
else
{
- void* key = (void*)(size_t) file->id;
+ void* key = (void*)(size_t)file->id;
if (!ListDictionary_Add(drive->files, key, file))
{
@@ -245,7 +245,7 @@ static UINT drive_process_irp_close(DRIVE_DEVICE* drive, IRP* irp)
return ERROR_INVALID_PARAMETER;
file = drive_get_file_by_id(drive, irp->FileId);
- key = (void*)(size_t) irp->FileId;
+ key = (void*)(size_t)irp->FileId;
if (!file)
irp->IoStatus = STATUS_UNSUCCESSFUL;
@@ -421,8 +421,7 @@ static UINT drive_process_irp_set_information(DRIVE_DEVICE* drive, IRP* irp)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
}
- else if (!drive_file_set_information(file, FsInformationClass, Length,
- irp->input))
+ else if (!drive_file_set_information(file, FsInformationClass, Length, irp->input))
{
irp->IoStatus = drive_map_windows_err(GetLastError());
}
@@ -434,19 +433,17 @@ static UINT drive_process_irp_set_information(DRIVE_DEVICE* drive, IRP* irp)
return irp->Complete(irp);
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
- IRP* irp)
+static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* irp)
{
UINT32 FsInformationClass;
wStream* output = NULL;
- char* volumeLabel = {"FREERDP"};
- char* diskType = {"FAT32"};
+ char* volumeLabel = { "FREERDP" };
+ char* diskType = { "FAT32" };
WCHAR* outStr = NULL;
int length;
DWORD lpSectorsPerCluster;
@@ -489,10 +486,11 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
GetFileAttributesExW(drive->path, GetFileExInfoStandard, &wfad);
Stream_Write_UINT32(output, wfad.ftCreationTime.dwLowDateTime); /* VolumeCreationTime */
- Stream_Write_UINT32(output, wfad.ftCreationTime.dwHighDateTime); /* VolumeCreationTime */
+ Stream_Write_UINT32(output,
+ wfad.ftCreationTime.dwHighDateTime); /* VolumeCreationTime */
Stream_Write_UINT32(output, lpNumberOfFreeClusters & 0xffff); /* VolumeSerialNumber */
- Stream_Write_UINT32(output, length); /* VolumeLabelLength */
- Stream_Write_UINT8(output, 0); /* SupportsObjects */
+ Stream_Write_UINT32(output, length); /* VolumeLabelLength */
+ Stream_Write_UINT8(output, 0); /* SupportsObjects */
/* Reserved(1), MUST NOT be added! */
Stream_Write(output, outStr, length); /* VolumeLabel (Unicode) */
free(outStr);
@@ -509,9 +507,9 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
}
Stream_Write_UINT64(output, lpTotalNumberOfClusters); /* TotalAllocationUnits */
- Stream_Write_UINT64(output, lpNumberOfFreeClusters); /* AvailableAllocationUnits */
- Stream_Write_UINT32(output, lpSectorsPerCluster); /* SectorsPerAllocationUnit */
- Stream_Write_UINT32(output, lpBytesPerSector); /* BytesPerSector */
+ Stream_Write_UINT64(output, lpNumberOfFreeClusters); /* AvailableAllocationUnits */
+ Stream_Write_UINT32(output, lpSectorsPerCluster); /* SectorsPerAllocationUnit */
+ Stream_Write_UINT32(output, lpBytesPerSector); /* BytesPerSector */
break;
case FileFsAttributeInformation:
@@ -532,13 +530,11 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT32(output,
- FILE_CASE_SENSITIVE_SEARCH |
- FILE_CASE_PRESERVED_NAMES |
- FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
- Stream_Write_UINT32(output, MAX_PATH); /* MaximumComponentNameLength */
- Stream_Write_UINT32(output, length); /* FileSystemNameLength */
- Stream_Write(output, outStr, length); /* FileSystemName (Unicode) */
+ Stream_Write_UINT32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES |
+ FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
+ Stream_Write_UINT32(output, MAX_PATH); /* MaximumComponentNameLength */
+ Stream_Write_UINT32(output, length); /* FileSystemNameLength */
+ Stream_Write(output, outStr, length); /* FileSystemName (Unicode) */
free(outStr);
break;
@@ -553,10 +549,11 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
}
Stream_Write_UINT64(output, lpTotalNumberOfClusters); /* TotalAllocationUnits */
- Stream_Write_UINT64(output, lpNumberOfFreeClusters); /* CallerAvailableAllocationUnits */
+ Stream_Write_UINT64(output,
+ lpNumberOfFreeClusters); /* CallerAvailableAllocationUnits */
Stream_Write_UINT64(output, lpNumberOfFreeClusters); /* AvailableAllocationUnits */
- Stream_Write_UINT32(output, lpSectorsPerCluster); /* SectorsPerAllocationUnit */
- Stream_Write_UINT32(output, lpBytesPerSector); /* BytesPerSector */
+ Stream_Write_UINT32(output, lpSectorsPerCluster); /* SectorsPerAllocationUnit */
+ Stream_Write_UINT32(output, lpBytesPerSector); /* BytesPerSector */
break;
case FileFsDeviceInformation:
@@ -570,7 +567,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive,
}
Stream_Write_UINT32(output, FILE_DEVICE_DISK); /* DeviceType */
- Stream_Write_UINT32(output, 0); /* Characteristics */
+ Stream_Write_UINT32(output, 0); /* Characteristics */
break;
default:
@@ -627,7 +624,7 @@ static UINT drive_process_irp_query_directory(DRIVE_DEVICE* drive, IRP* irp)
Stream_Read_UINT8(irp->input, InitialQuery);
Stream_Read_UINT32(irp->input, PathLength);
Stream_Seek(irp->input, 23); /* Padding */
- path = (WCHAR*) Stream_Pointer(irp->input);
+ path = (WCHAR*)Stream_Pointer(irp->input);
file = drive_get_file_by_id(drive, irp->FileId);
if (file == NULL)
@@ -754,7 +751,7 @@ static DWORD WINAPI drive_thread_func(LPVOID arg)
{
IRP* irp;
wMessage message;
- DRIVE_DEVICE* drive = (DRIVE_DEVICE*) arg;
+ DRIVE_DEVICE* drive = (DRIVE_DEVICE*)arg;
UINT error = CHANNEL_RC_OK;
if (!drive)
@@ -782,13 +779,13 @@ static DWORD WINAPI drive_thread_func(LPVOID arg)
if (message.id == WMQ_QUIT)
break;
- irp = (IRP*) message.wParam;
+ irp = (IRP*)message.wParam;
if (irp)
{
if ((error = drive_process_irp(drive, irp)))
{
- WLog_ERR(TAG, "drive_process_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "drive_process_irp failed with error %" PRIu32 "!", error);
break;
}
}
@@ -810,12 +807,12 @@ fail:
*/
static UINT drive_irp_request(DEVICE* device, IRP* irp)
{
- DRIVE_DEVICE* drive = (DRIVE_DEVICE*) device;
+ DRIVE_DEVICE* drive = (DRIVE_DEVICE*)device;
if (!drive)
return ERROR_INVALID_PARAMETER;
- if (!MessageQueue_Post(drive->IrpQueue, NULL, 0, (void*) irp, NULL))
+ if (!MessageQueue_Post(drive->IrpQueue, NULL, 0, (void*)irp, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -848,17 +845,17 @@ static UINT drive_free_int(DRIVE_DEVICE* drive)
*/
static UINT drive_free(DEVICE* device)
{
- DRIVE_DEVICE* drive = (DRIVE_DEVICE*) device;
+ DRIVE_DEVICE* drive = (DRIVE_DEVICE*)device;
UINT error = CHANNEL_RC_OK;
if (!drive)
return ERROR_INVALID_PARAMETER;
- if (MessageQueue_PostQuit(drive->IrpQueue, 0)
- && (WaitForSingleObject(drive->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(drive->IrpQueue, 0) &&
+ (WaitForSingleObject(drive->thread, INFINITE) == WAIT_FAILED))
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -870,7 +867,7 @@ static UINT drive_free(DEVICE* device)
*/
static void drive_file_objfree(void* obj)
{
- drive_file_free((DRIVE_FILE*) obj);
+ drive_file_free((DRIVE_FILE*)obj);
}
/**
@@ -878,8 +875,8 @@ static void drive_file_objfree(void* obj)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
- const char* name, const char* path, BOOL automount)
+static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, const char* name,
+ const char* path, BOOL automount)
{
size_t i, length;
DRIVE_DEVICE* drive;
@@ -887,14 +884,15 @@ static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
if (!pEntryPoints || !name || !path)
{
- WLog_ERR(TAG, "[%s] Invalid parameters: pEntryPoints=%p, name=%p, path=%p", pEntryPoints, name, path);
+ WLog_ERR(TAG, "[%s] Invalid parameters: pEntryPoints=%p, name=%p, path=%p", pEntryPoints,
+ name, path);
return ERROR_INVALID_PARAMETER;
}
if (name[0] && path[0])
{
size_t pathLength = strnlen(path, MAX_PATH);
- drive = (DRIVE_DEVICE*) calloc(1, sizeof(DRIVE_DEVICE));
+ drive = (DRIVE_DEVICE*)calloc(1, sizeof(DRIVE_DEVICE));
if (!drive)
{
@@ -922,7 +920,7 @@ static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
Stream_Write_UINT8(drive->device.data, name[i] < 0 ? '_' : name[i]);
if ((pathLength > 1) && (path[pathLength - 1] == '/'))
- pathLength --;
+ pathLength--;
if (ConvertToUnicode(sys_code_page, 0, path, pathLength, &drive->path, 0) <= 0)
{
@@ -950,15 +948,14 @@ static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
goto out_error;
}
- if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman,
- (DEVICE*) drive)))
+ if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)drive)))
{
- WLog_ERR(TAG, "RegisterDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "RegisterDevice failed with error %" PRIu32 "!", error);
goto out_error;
}
- if (!(drive->thread = CreateThread(NULL, 0, drive_thread_func, drive,
- CREATE_SUSPENDED, NULL)))
+ if (!(drive->thread =
+ CreateThread(NULL, 0, drive_thread_func, drive, CREATE_SUSPENDED, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
goto out_error;
@@ -974,9 +971,9 @@ out_error:
}
#ifdef BUILTIN_CHANNELS
-#define DeviceServiceEntry drive_DeviceServiceEntry
+#define DeviceServiceEntry drive_DeviceServiceEntry
#else
-#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
+#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
#endif
/**
@@ -995,7 +992,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
char* bufdup;
char* devdup;
#endif
- drive = (RDPDR_DRIVE*) pEntryPoints->device;
+ drive = (RDPDR_DRIVE*)pEntryPoints->device;
#ifndef WIN32
sys_code_page = CP_UTF8;
diff --git a/channels/echo/client/echo_main.c b/channels/echo/client/echo_main.c
index a16089fd9..e830122a7 100644
--- a/channels/echo/client/echo_main.c
+++ b/channels/echo/client/echo_main.c
@@ -66,9 +66,9 @@ struct _ECHO_PLUGIN
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
+static UINT echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*) pChannelCallback;
+ ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*)pChannelCallback;
BYTE* pBuffer = Stream_Pointer(data);
UINT32 cbSize = Stream_GetRemainingLength(data);
@@ -83,7 +83,7 @@ static UINT echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
*/
static UINT echo_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
- ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*) pChannelCallback;
+ ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*)pChannelCallback;
free(callback);
@@ -96,13 +96,13 @@ static UINT echo_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT echo_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
ECHO_CHANNEL_CALLBACK* callback;
- ECHO_LISTENER_CALLBACK* listener_callback = (ECHO_LISTENER_CALLBACK*) pListenerCallback;
+ ECHO_LISTENER_CALLBACK* listener_callback = (ECHO_LISTENER_CALLBACK*)pListenerCallback;
- callback = (ECHO_CHANNEL_CALLBACK*) calloc(1, sizeof(ECHO_CHANNEL_CALLBACK));
+ callback = (ECHO_CHANNEL_CALLBACK*)calloc(1, sizeof(ECHO_CHANNEL_CALLBACK));
if (!callback)
{
@@ -116,7 +116,7 @@ static UINT echo_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -128,9 +128,9 @@ static UINT echo_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
*/
static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
- ECHO_PLUGIN* echo = (ECHO_PLUGIN*) pPlugin;
+ ECHO_PLUGIN* echo = (ECHO_PLUGIN*)pPlugin;
- echo->listener_callback = (ECHO_LISTENER_CALLBACK*) calloc(1, sizeof(ECHO_LISTENER_CALLBACK));
+ echo->listener_callback = (ECHO_LISTENER_CALLBACK*)calloc(1, sizeof(ECHO_LISTENER_CALLBACK));
if (!echo->listener_callback)
{
@@ -143,7 +143,7 @@ static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
echo->listener_callback->channel_mgr = pChannelMgr;
return pChannelMgr->CreateListener(pChannelMgr, "ECHO", 0,
- (IWTSListenerCallback*) echo->listener_callback, NULL);
+ (IWTSListenerCallback*)echo->listener_callback, NULL);
}
/**
@@ -153,7 +153,7 @@ static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
*/
static UINT echo_plugin_terminated(IWTSPlugin* pPlugin)
{
- ECHO_PLUGIN* echo = (ECHO_PLUGIN*) pPlugin;
+ ECHO_PLUGIN* echo = (ECHO_PLUGIN*)pPlugin;
free(echo);
@@ -161,9 +161,9 @@ static UINT echo_plugin_terminated(IWTSPlugin* pPlugin)
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry echo_DVCPluginEntry
+#define DVCPluginEntry echo_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -176,11 +176,11 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT status = CHANNEL_RC_OK;
ECHO_PLUGIN* echo;
- echo = (ECHO_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "echo");
+ echo = (ECHO_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "echo");
if (!echo)
{
- echo = (ECHO_PLUGIN*) calloc(1, sizeof(ECHO_PLUGIN));
+ echo = (ECHO_PLUGIN*)calloc(1, sizeof(ECHO_PLUGIN));
if (!echo)
{
@@ -193,7 +193,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
echo->iface.Disconnected = NULL;
echo->iface.Terminated = echo_plugin_terminated;
- status = pEntryPoints->RegisterPlugin(pEntryPoints, "echo", (IWTSPlugin*) echo);
+ status = pEntryPoints->RegisterPlugin(pEntryPoints, "echo", (IWTSPlugin*)echo);
}
return status;
diff --git a/channels/echo/client/echo_main.h b/channels/echo/client/echo_main.h
index 04cda415a..06262b12b 100644
--- a/channels/echo/client/echo_main.h
+++ b/channels/echo/client/echo_main.h
@@ -33,8 +33,10 @@
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(...) WLog_DBG(DVC_TAG, __VA_ARGS__)
#else
-#define DEBUG_DVC(...) do { } while (0)
+#define DEBUG_DVC(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CHANNEL_ECHO_CLIENT_MAIN_H */
-
diff --git a/channels/echo/server/echo_main.c b/channels/echo/server/echo_main.c
index b3f8eb0f7..55e2fa237 100644
--- a/channels/echo/server/echo_main.c
+++ b/channels/echo/server/echo_main.c
@@ -66,14 +66,14 @@ static UINT echo_server_open_channel(echo_server* echo)
DWORD BytesReturned = 0;
PULONG pSessionId = NULL;
- if (WTSQuerySessionInformationA(echo->context.vcm, WTS_CURRENT_SESSION,
- WTSSessionId, (LPSTR*) &pSessionId, &BytesReturned) == FALSE)
+ if (WTSQuerySessionInformationA(echo->context.vcm, WTS_CURRENT_SESSION, WTSSessionId,
+ (LPSTR*)&pSessionId, &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSQuerySessionInformationA failed!");
return ERROR_INTERNAL_ERROR;
}
- echo->SessionId = (DWORD) * pSessionId;
+ echo->SessionId = (DWORD)*pSessionId;
WTSFreeMemory(pSessionId);
hEvent = WTSVirtualChannelManagerGetEventHandle(echo->context.vcm);
StartTick = GetTickCount();
@@ -83,12 +83,12 @@ static UINT echo_server_open_channel(echo_server* echo)
if (WaitForSingleObject(hEvent, 1000) == WAIT_FAILED)
{
Error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", Error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", Error);
return Error;
}
- echo->echo_channel = WTSVirtualChannelOpenEx(echo->SessionId,
- "ECHO", WTS_CHANNEL_OPTION_DYNAMIC);
+ echo->echo_channel =
+ WTSVirtualChannelOpenEx(echo->SessionId, "ECHO", WTS_CHANNEL_OPTION_DYNAMIC);
if (echo->echo_channel)
break;
@@ -114,19 +114,19 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
BOOL ready = FALSE;
HANDLE ChannelEvent;
DWORD BytesReturned = 0;
- echo_server* echo = (echo_server*) arg;
+ echo_server* echo = (echo_server*)arg;
UINT error;
DWORD status;
if ((error = echo_server_open_channel(echo)))
{
UINT error2 = 0;
- WLog_ERR(TAG, "echo_server_open_channel failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "echo_server_open_channel failed with error %" PRIu32 "!", error);
IFCALLRET(echo->context.OpenResult, error2, &echo->context,
ECHO_SERVER_OPEN_RESULT_NOTSUPPORTED);
if (error2)
- WLog_ERR(TAG, "echo server's OpenResult callback failed with error %"PRIu32"",
+ WLog_ERR(TAG, "echo server's OpenResult callback failed with error %" PRIu32 "",
error2);
goto out;
@@ -158,7 +158,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -168,7 +168,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
ECHO_SERVER_OPEN_RESULT_CLOSED);
if (error)
- WLog_ERR(TAG, "OpenResult failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "OpenResult failed with error %" PRIu32 "!", error);
break;
}
@@ -180,21 +180,20 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
ECHO_SERVER_OPEN_RESULT_ERROR);
if (error)
- WLog_ERR(TAG, "OpenResult failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "OpenResult failed with error %" PRIu32 "!", error);
break;
}
- ready = *((BOOL*) buffer);
+ ready = *((BOOL*)buffer);
WTSFreeMemory(buffer);
if (ready)
{
- IFCALLRET(echo->context.OpenResult, error, &echo->context,
- ECHO_SERVER_OPEN_RESULT_OK);
+ IFCALLRET(echo->context.OpenResult, error, &echo->context, ECHO_SERVER_OPEN_RESULT_OK);
if (error)
- WLog_ERR(TAG, "OpenResult failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "OpenResult failed with error %" PRIu32 "!", error);
break;
}
@@ -217,7 +216,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -237,20 +236,20 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
break;
}
- if (WTSVirtualChannelRead(echo->echo_channel, 0, (PCHAR) Stream_Buffer(s),
- (ULONG) Stream_Capacity(s), &BytesReturned) == FALSE)
+ if (WTSVirtualChannelRead(echo->echo_channel, 0, (PCHAR)Stream_Buffer(s),
+ (ULONG)Stream_Capacity(s), &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
error = ERROR_INTERNAL_ERROR;
break;
}
- IFCALLRET(echo->context.Response, error, &echo->context,
- (BYTE*) Stream_Buffer(s), BytesReturned);
+ IFCALLRET(echo->context.Response, error, &echo->context, (BYTE*)Stream_Buffer(s),
+ BytesReturned);
if (error)
{
- WLog_ERR(TAG, "Response failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Response failed with error %" PRIu32 "!", error);
break;
}
}
@@ -275,7 +274,7 @@ out:
*/
static UINT echo_server_open(echo_server_context* context)
{
- echo_server* echo = (echo_server*) context;
+ echo_server* echo = (echo_server*)context;
if (echo->thread == NULL)
{
@@ -285,7 +284,7 @@ static UINT echo_server_open(echo_server_context* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(echo->thread = CreateThread(NULL, 0, echo_server_thread_func, (void*) echo, 0, NULL)))
+ if (!(echo->thread = CreateThread(NULL, 0, echo_server_thread_func, (void*)echo, 0, NULL)))
{
WLog_ERR(TAG, "CreateEvent failed!");
CloseHandle(echo->stopEvent);
@@ -305,7 +304,7 @@ static UINT echo_server_open(echo_server_context* context)
static UINT echo_server_close(echo_server_context* context)
{
UINT error = CHANNEL_RC_OK;
- echo_server* echo = (echo_server*) context;
+ echo_server* echo = (echo_server*)context;
if (echo->thread)
{
@@ -314,7 +313,7 @@ static UINT echo_server_close(echo_server_context* context)
if (WaitForSingleObject(echo->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -327,17 +326,16 @@ static UINT echo_server_close(echo_server_context* context)
return error;
}
-static BOOL echo_server_request(echo_server_context* context,
- const BYTE* buffer, UINT32 length)
+static BOOL echo_server_request(echo_server_context* context, const BYTE* buffer, UINT32 length)
{
- echo_server* echo = (echo_server*) context;
- return WTSVirtualChannelWrite(echo->echo_channel, (PCHAR) buffer, length, NULL);
+ echo_server* echo = (echo_server*)context;
+ return WTSVirtualChannelWrite(echo->echo_channel, (PCHAR)buffer, length, NULL);
}
echo_server_context* echo_server_context_new(HANDLE vcm)
{
echo_server* echo;
- echo = (echo_server*) calloc(1, sizeof(echo_server));
+ echo = (echo_server*)calloc(1, sizeof(echo_server));
if (echo)
{
@@ -349,12 +347,12 @@ echo_server_context* echo_server_context_new(HANDLE vcm)
else
WLog_ERR(TAG, "calloc failed!");
- return (echo_server_context*) echo;
+ return (echo_server_context*)echo;
}
void echo_server_context_free(echo_server_context* context)
{
- echo_server* echo = (echo_server*) context;
+ echo_server* echo = (echo_server*)context;
echo_server_close(context);
free(echo);
}
diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c
index a2482fe74..2d22eeb59 100644
--- a/channels/encomsp/client/encomsp_main.c
+++ b/channels/encomsp/client/encomsp_main.c
@@ -44,7 +44,7 @@ static UINT encomsp_read_header(wStream* s, ENCOMSP_ORDER_HEADER* header)
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, header->Type); /* Type (2 bytes) */
+ Stream_Read_UINT16(s, header->Type); /* Type (2 bytes) */
Stream_Read_UINT16(s, header->Length); /* Length (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -56,7 +56,7 @@ static UINT encomsp_read_header(wStream* s, ENCOMSP_ORDER_HEADER* header)
*/
static UINT encomsp_write_header(wStream* s, ENCOMSP_ORDER_HEADER* header)
{
- Stream_Write_UINT16(s, header->Type); /* Type (2 bytes) */
+ Stream_Write_UINT16(s, header->Type); /* Type (2 bytes) */
Stream_Write_UINT16(s, header->Length); /* Length (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -80,7 +80,7 @@ static UINT encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str)
if (str->cchString > 1024)
{
- WLog_ERR(TAG, "cchString was %"PRIu16" but has to be < 1025!", str->cchString);
+ WLog_ERR(TAG, "cchString was %" PRIu16 " but has to be < 1025!", str->cchString);
return ERROR_INVALID_DATA;
}
@@ -94,11 +94,10 @@ static UINT encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str)
return CHANNEL_RC_OK;
}
-static EncomspClientContext* encomsp_get_client_interface(
- encomspPlugin* encomsp)
+static EncomspClientContext* encomsp_get_client_interface(encomspPlugin* encomsp)
{
EncomspClientContext* pInterface;
- pInterface = (EncomspClientContext*) encomsp->channelEntryPoints.pInterface;
+ pInterface = (EncomspClientContext*)encomsp->channelEntryPoints.pInterface;
return pInterface;
}
@@ -121,15 +120,14 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
WLog_INFO(TAG, "EncomspWrite (%"PRIuz")", Stream_Length(s));
winpr_HexDump(Stream_Buffer(s), Stream_Length(s));
#endif
- status = encomsp->channelEntryPoints.pVirtualChannelWriteEx(encomsp->InitHandle,
- encomsp->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_Length(s), s);
+ status = encomsp->channelEntryPoints.pVirtualChannelWriteEx(
+ encomsp->InitHandle, encomsp->OpenHandle, Stream_Buffer(s), (UINT32)Stream_Length(s), s);
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(status), status);
+ WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
+ WTSErrorToString(status), status);
}
return status;
}
@@ -140,7 +138,7 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
- ENCOMSP_ORDER_HEADER* header)
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -151,7 +149,7 @@ static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 1)
@@ -161,7 +159,7 @@ static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
}
Stream_Read_UINT8(s, pdu.Flags); /* Flags (1 byte) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -183,7 +181,7 @@ static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
IFCALLRET(context->FilterUpdated, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->FilterUpdated failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->FilterUpdated failed with error %" PRIu32 "", error);
return error;
}
@@ -193,8 +191,8 @@ static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -205,7 +203,7 @@ static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 6)
@@ -219,11 +217,11 @@ static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
if ((error = encomsp_read_unicode_string(s, &(pdu.Name))))
{
- WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %" PRIu32 "", error);
return error;
}
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -245,7 +243,7 @@ static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
IFCALLRET(context->ApplicationCreated, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ApplicationCreated failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ApplicationCreated failed with error %" PRIu32 "", error);
return error;
}
@@ -255,8 +253,8 @@ static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -267,7 +265,7 @@ static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 4)
@@ -277,7 +275,7 @@ static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
}
Stream_Read_UINT32(s, pdu.AppId); /* AppId (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -299,7 +297,7 @@ static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
IFCALLRET(context->ApplicationRemoved, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ApplicationRemoved failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ApplicationRemoved failed with error %" PRIu32 "", error);
return error;
}
@@ -310,7 +308,7 @@ static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
- ENCOMSP_ORDER_HEADER* header)
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -321,7 +319,7 @@ static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 10)
@@ -336,11 +334,11 @@ static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
if ((error = encomsp_read_unicode_string(s, &(pdu.Name))))
{
- WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %" PRIu32 "", error);
return error;
}
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -362,7 +360,7 @@ static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
IFCALLRET(context->WindowCreated, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->WindowCreated failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->WindowCreated failed with error %" PRIu32 "", error);
return error;
}
@@ -373,7 +371,7 @@ static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
- ENCOMSP_ORDER_HEADER* header)
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -384,7 +382,7 @@ static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 4)
@@ -394,7 +392,7 @@ static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
}
Stream_Read_UINT32(s, pdu.WndId); /* WndId (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -416,7 +414,7 @@ static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
IFCALLRET(context->WindowRemoved, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->WindowRemoved failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->WindowRemoved failed with error %" PRIu32 "", error);
return error;
}
@@ -427,7 +425,7 @@ static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
- ENCOMSP_ORDER_HEADER* header)
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -438,7 +436,7 @@ static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 4)
@@ -448,7 +446,7 @@ static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
}
Stream_Read_UINT32(s, pdu.WndId); /* WndId (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -470,7 +468,7 @@ static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
IFCALLRET(context->ShowWindow, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ShowWindow failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ShowWindow failed with error %" PRIu32 "", error);
return error;
}
@@ -480,8 +478,8 @@ static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -492,7 +490,7 @@ static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 10)
@@ -502,16 +500,16 @@ static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
}
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
- Stream_Read_UINT32(s, pdu.GroupId); /* GroupId (4 bytes) */
- Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
+ Stream_Read_UINT32(s, pdu.GroupId); /* GroupId (4 bytes) */
+ Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
if ((error = encomsp_read_unicode_string(s, &(pdu.FriendlyName))))
{
- WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "encomsp_read_unicode_string failed with error %" PRIu32 "", error);
return error;
}
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -533,7 +531,7 @@ static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
IFCALLRET(context->ParticipantCreated, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ParticipantCreated failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ParticipantCreated failed with error %" PRIu32 "", error);
return error;
}
@@ -543,8 +541,8 @@ static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -555,7 +553,7 @@ static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 12)
@@ -565,9 +563,9 @@ static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
}
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
- Stream_Read_UINT32(s, pdu.DiscType); /* DiscType (4 bytes) */
- Stream_Read_UINT32(s, pdu.DiscCode); /* DiscCode (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ Stream_Read_UINT32(s, pdu.DiscType); /* DiscType (4 bytes) */
+ Stream_Read_UINT32(s, pdu.DiscCode); /* DiscCode (4 bytes) */
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -589,7 +587,7 @@ static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
IFCALLRET(context->ParticipantRemoved, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ParticipantRemoved failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ParticipantRemoved failed with error %" PRIu32 "", error);
return error;
}
@@ -599,8 +597,8 @@ static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_change_participant_control_level_pdu(
- encomspPlugin* encomsp, wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_change_participant_control_level_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -611,7 +609,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 6)
@@ -620,9 +618,9 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
+ Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -644,7 +642,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
IFCALLRET(context->ChangeParticipantControlLevel, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %"PRIu32"",
+ WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %" PRIu32 "",
error);
return error;
@@ -655,14 +653,14 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_send_change_participant_control_level_pdu(
- EncomspClientContext* context,
- ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU* pdu)
+static UINT
+encomsp_send_change_participant_control_level_pdu(EncomspClientContext* context,
+ ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU* pdu)
{
wStream* s;
encomspPlugin* encomsp;
UINT error;
- encomsp = (encomspPlugin*) context->handle;
+ encomsp = (encomspPlugin*)context->handle;
pdu->Type = ODTYPE_PARTICIPANT_CTRL_CHANGED;
pdu->Length = ENCOMSP_ORDER_HEADER_SIZE + 6;
s = Stream_New(NULL, pdu->Length);
@@ -673,13 +671,13 @@ static UINT encomsp_send_change_participant_control_level_pdu(
return CHANNEL_RC_NO_MEMORY;
}
- if ((error = encomsp_write_header(s, (ENCOMSP_ORDER_HEADER*) pdu)))
+ if ((error = encomsp_write_header(s, (ENCOMSP_ORDER_HEADER*)pdu)))
{
- WLog_ERR(TAG, "encomsp_write_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_write_header failed with error %" PRIu32 "!", error);
return error;
}
- Stream_Write_UINT16(s, pdu->Flags); /* Flags (2 bytes) */
+ Stream_Write_UINT16(s, pdu->Flags); /* Flags (2 bytes) */
Stream_Write_UINT32(s, pdu->ParticipantId); /* ParticipantId (4 bytes) */
Stream_SealLength(s);
return encomsp_virtual_channel_write(encomsp, s);
@@ -690,8 +688,8 @@ static UINT encomsp_send_change_participant_control_level_pdu(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -702,9 +700,9 @@ static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -726,7 +724,7 @@ static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
IFCALLRET(context->GraphicsStreamPaused, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->GraphicsStreamPaused failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->GraphicsStreamPaused failed with error %" PRIu32 "", error);
return error;
}
@@ -736,8 +734,8 @@ static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp,
- wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp, wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
@@ -748,9 +746,9 @@ static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp,
if (!context)
return ERROR_INVALID_HANDLE;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -772,7 +770,7 @@ static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp,
IFCALLRET(context->GraphicsStreamResumed, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->GraphicsStreamResumed failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->GraphicsStreamResumed failed with error %" PRIu32 "", error);
return error;
}
@@ -791,18 +789,20 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
{
if ((error = encomsp_read_header(s, &header)))
{
- WLog_ERR(TAG, "encomsp_read_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_read_header failed with error %" PRIu32 "!", error);
return error;
}
- //WLog_DBG(TAG, "EncomspReceive: Type: %"PRIu16" Length: %"PRIu16"", header.Type, header.Length);
+ // WLog_DBG(TAG, "EncomspReceive: Type: %"PRIu16" Length: %"PRIu16"", header.Type,
+ // header.Length);
switch (header.Type)
{
case ODTYPE_FILTER_STATE_UPDATED:
if ((error = encomsp_recv_filter_updated_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_filter_updated_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_recv_filter_updated_pdu failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -811,7 +811,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_APP_REMOVED:
if ((error = encomsp_recv_application_removed_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_application_removed_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_application_removed_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -821,7 +822,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_APP_CREATED:
if ((error = encomsp_recv_application_created_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_application_removed_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_application_removed_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -831,7 +833,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_WND_REMOVED:
if ((error = encomsp_recv_window_removed_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_window_removed_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_recv_window_removed_pdu failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -840,7 +843,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_WND_CREATED:
if ((error = encomsp_recv_window_created_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_window_created_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_recv_window_created_pdu failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -849,7 +853,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_WND_SHOW:
if ((error = encomsp_recv_show_window_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_show_window_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_recv_show_window_pdu failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -858,7 +863,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_PARTICIPANT_REMOVED:
if ((error = encomsp_recv_participant_removed_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_participant_removed_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_participant_removed_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -868,7 +874,8 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_PARTICIPANT_CREATED:
if ((error = encomsp_recv_participant_created_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_participant_created_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_participant_created_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -876,11 +883,12 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
break;
case ODTYPE_PARTICIPANT_CTRL_CHANGED:
- if ((error = encomsp_recv_change_participant_control_level_pdu(encomsp, s,
- &header)))
+ if ((error =
+ encomsp_recv_change_participant_control_level_pdu(encomsp, s, &header)))
{
WLog_ERR(TAG,
- "encomsp_recv_change_participant_control_level_pdu failed with error %"PRIu32"!",
+ "encomsp_recv_change_participant_control_level_pdu failed with error "
+ "%" PRIu32 "!",
error);
return error;
}
@@ -890,7 +898,9 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_GRAPHICS_STREAM_PAUSED:
if ((error = encomsp_recv_graphics_stream_paused_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_graphics_stream_paused_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_graphics_stream_paused_pdu failed with error %" PRIu32
+ "!",
error);
return error;
}
@@ -900,7 +910,9 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
case ODTYPE_GRAPHICS_STREAM_RESUMED:
if ((error = encomsp_recv_graphics_stream_resumed_pdu(encomsp, s, &header)))
{
- WLog_ERR(TAG, "encomsp_recv_graphics_stream_resumed_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "encomsp_recv_graphics_stream_resumed_pdu failed with error %" PRIu32
+ "!",
error);
return error;
}
@@ -908,7 +920,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
break;
default:
- WLog_ERR(TAG, "header.Type %"PRIu16" not found", header.Type);
+ WLog_ERR(TAG, "header.Type %" PRIu16 " not found", header.Type);
return ERROR_INVALID_DATA;
break;
}
@@ -926,8 +938,9 @@ static void encomsp_process_connect(encomspPlugin* encomsp)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -950,7 +963,7 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
data_in = encomsp->data_in;
- if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
+ if (!Stream_EnsureRemainingCapacity(data_in, (int)dataLength))
{
WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
return ERROR_INTERNAL_ERROR;
@@ -962,7 +975,7 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
{
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
{
- WLog_ERR(TAG, "encomsp_plugin_process_received: read error");
+ WLog_ERR(TAG, "encomsp_plugin_process_received: read error");
return ERROR_INVALID_DATA;
}
@@ -970,7 +983,7 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(encomsp->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(encomsp->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -981,24 +994,28 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
}
static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- encomspPlugin* encomsp = (encomspPlugin*) lpUserParam;
+ encomspPlugin* encomsp = (encomspPlugin*)lpUserParam;
if (!encomsp || (encomsp->OpenHandle != openHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- if ((error = encomsp_virtual_channel_event_data_received(encomsp, pData,
- dataLength, totalLength, dataFlags)))
- WLog_ERR(TAG, "encomsp_virtual_channel_event_data_received failed with error %"PRIu32"", error);
+ if ((error = encomsp_virtual_channel_event_data_received(encomsp, pData, dataLength,
+ totalLength, dataFlags)))
+ WLog_ERR(TAG,
+ "encomsp_virtual_channel_event_data_received failed with error %" PRIu32
+ "",
+ error);
break;
@@ -1008,14 +1025,15 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam,
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
}
if (error && encomsp->rdpcontext)
- setChannelError(encomsp->rdpcontext, error, "encomsp_virtual_channel_open_event reported an error");
+ setChannelError(encomsp->rdpcontext, error,
+ "encomsp_virtual_channel_open_event reported an error");
return;
}
@@ -1024,7 +1042,7 @@ static DWORD WINAPI encomsp_virtual_channel_client_thread(LPVOID arg)
{
wStream* data;
wMessage message;
- encomspPlugin* encomsp = (encomspPlugin*) arg;
+ encomspPlugin* encomsp = (encomspPlugin*)arg;
UINT error = CHANNEL_RC_OK;
encomsp_process_connect(encomsp);
@@ -1049,11 +1067,11 @@ static DWORD WINAPI encomsp_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
if ((error = encomsp_process_receive(encomsp, data)))
{
- WLog_ERR(TAG, "encomsp_process_receive failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_process_receive failed with error %" PRIu32 "!", error);
break;
}
}
@@ -1072,17 +1090,17 @@ static DWORD WINAPI encomsp_virtual_channel_client_thread(LPVOID arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp,
- LPVOID pData, UINT32 dataLength)
+static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVOID pData,
+ UINT32 dataLength)
{
UINT32 status;
- status = encomsp->channelEntryPoints.pVirtualChannelOpenEx(encomsp->InitHandle,
- &encomsp->OpenHandle, encomsp->channelDef.name,
- encomsp_virtual_channel_open_event_ex);
+ status = encomsp->channelEntryPoints.pVirtualChannelOpenEx(
+ encomsp->InitHandle, &encomsp->OpenHandle, encomsp->channelDef.name,
+ encomsp_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -1095,9 +1113,8 @@ static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp,
return CHANNEL_RC_NO_MEMORY;
}
- if (!(encomsp->thread = CreateThread(NULL, 0,
- encomsp_virtual_channel_client_thread, (void*) encomsp,
- 0, NULL)))
+ if (!(encomsp->thread = CreateThread(NULL, 0, encomsp_virtual_channel_client_thread,
+ (void*)encomsp, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
MessageQueue_Free(encomsp->queue);
@@ -1119,11 +1136,11 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
if (encomsp->OpenHandle == 0)
return CHANNEL_RC_OK;
- if (MessageQueue_PostQuit(encomsp->queue, 0)
- && (WaitForSingleObject(encomsp->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(encomsp->queue, 0) &&
+ (WaitForSingleObject(encomsp->thread, INFINITE) == WAIT_FAILED))
{
rc = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", rc);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
}
@@ -1131,12 +1148,13 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
CloseHandle(encomsp->thread);
encomsp->queue = NULL;
encomsp->thread = NULL;
- rc = encomsp->channelEntryPoints.pVirtualChannelCloseEx(encomsp->InitHandle, encomsp->OpenHandle);
+ rc = encomsp->channelEntryPoints.pVirtualChannelCloseEx(encomsp->InitHandle,
+ encomsp->OpenHandle);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
return rc;
}
@@ -1151,7 +1169,6 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
return CHANNEL_RC_OK;
}
-
/**
* Function description
*
@@ -1166,23 +1183,24 @@ static UINT encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
}
static VOID VCAPITYPE encomsp_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData,
+ UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- encomspPlugin* encomsp = (encomspPlugin*) lpUserParam;
+ encomspPlugin* encomsp = (encomspPlugin*)lpUserParam;
if (!encomsp || (encomsp->InitHandle != pInitHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_CONNECTED:
- if ((error = encomsp_virtual_channel_event_connected(encomsp, pData,
- dataLength)))
- WLog_ERR(TAG, "encomsp_virtual_channel_event_connected failed with error %"PRIu32"",
+ if ((error = encomsp_virtual_channel_event_connected(encomsp, pData, dataLength)))
+ WLog_ERR(TAG,
+ "encomsp_virtual_channel_event_connected failed with error %" PRIu32 "",
error);
break;
@@ -1190,7 +1208,8 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event_ex(LPVOID lpUserParam,
case CHANNEL_EVENT_DISCONNECTED:
if ((error = encomsp_virtual_channel_event_disconnected(encomsp)))
WLog_ERR(TAG,
- "encomsp_virtual_channel_event_disconnected failed with error %"PRIu32"", error);
+ "encomsp_virtual_channel_event_disconnected failed with error %" PRIu32 "",
+ error);
break;
@@ -1199,15 +1218,16 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event_ex(LPVOID lpUserParam,
break;
default:
- WLog_ERR(TAG, "Unhandled event type %"PRIu32"", event);
+ WLog_ERR(TAG, "Unhandled event type %" PRIu32 "", event);
}
if (error && encomsp->rdpcontext)
- setChannelError(encomsp->rdpcontext, error, "encomsp_virtual_channel_init_event reported an error");
+ setChannelError(encomsp->rdpcontext, error,
+ "encomsp_virtual_channel_init_event reported an error");
}
/* encomsp is always built-in */
-#define VirtualChannelEntryEx encomsp_VirtualChannelEntryEx
+#define VirtualChannelEntryEx encomsp_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOID pInitHandle)
{
@@ -1216,7 +1236,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
EncomspClientContext* context = NULL;
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
BOOL isFreerdp = FALSE;
- encomsp = (encomspPlugin*) calloc(1, sizeof(encomspPlugin));
+ encomsp = (encomspPlugin*)calloc(1, sizeof(encomspPlugin));
if (!encomsp)
{
@@ -1224,18 +1244,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
return FALSE;
}
- encomsp->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP |
- CHANNEL_OPTION_SHOW_PROTOCOL;
+ encomsp->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
+ CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
sprintf_s(encomsp->channelDef.name, ARRAYSIZE(encomsp->channelDef.name), "encomsp");
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
- context = (EncomspClientContext*) calloc(1, sizeof(EncomspClientContext));
+ context = (EncomspClientContext*)calloc(1, sizeof(EncomspClientContext));
if (!context)
{
@@ -1243,7 +1260,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
goto error_out;
}
- context->handle = (void*) encomsp;
+ context->handle = (void*)encomsp;
context->FilterUpdated = NULL;
context->ApplicationCreated = NULL;
context->ApplicationRemoved = NULL;
@@ -1252,8 +1269,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
context->ShowWindow = NULL;
context->ParticipantCreated = NULL;
context->ParticipantRemoved = NULL;
- context->ChangeParticipantControlLevel =
- encomsp_send_change_participant_control_level_pdu;
+ context->ChangeParticipantControlLevel = encomsp_send_change_participant_control_level_pdu;
context->GraphicsStreamPaused = NULL;
context->GraphicsStreamResumed = NULL;
encomsp->context = context;
@@ -1264,14 +1280,13 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
CopyMemory(&(encomsp->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
encomsp->InitHandle = pInitHandle;
- rc = encomsp->channelEntryPoints.pVirtualChannelInitEx(encomsp, context, pInitHandle,
- &encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- encomsp_virtual_channel_init_event_ex);
+ rc = encomsp->channelEntryPoints.pVirtualChannelInitEx(
+ encomsp, context, pInitHandle, &encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ encomsp_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "failed with %s [%08" PRIX32 "]", WTSErrorToString(rc), rc);
goto error_out;
}
diff --git a/channels/encomsp/server/encomsp_main.c b/channels/encomsp/server/encomsp_main.c
index 0d3e3e7cd..9b1693bbb 100644
--- a/channels/encomsp/server/encomsp_main.c
+++ b/channels/encomsp/server/encomsp_main.c
@@ -43,7 +43,7 @@ static UINT encomsp_read_header(wStream* s, ENCOMSP_ORDER_HEADER* header)
if (Stream_GetRemainingLength(s) < ENCOMSP_ORDER_HEADER_SIZE)
return ERROR_INVALID_DATA;
- Stream_Read_UINT16(s, header->Type); /* Type (2 bytes) */
+ Stream_Read_UINT16(s, header->Type); /* Type (2 bytes) */
Stream_Read_UINT16(s, header->Length); /* Length (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -83,13 +83,14 @@ static int encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_recv_change_participant_control_level_pdu(
- EncomspServerContext* context, wStream* s, ENCOMSP_ORDER_HEADER* header)
+static UINT encomsp_recv_change_participant_control_level_pdu(EncomspServerContext* context,
+ wStream* s,
+ ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu;
UINT error = CHANNEL_RC_OK;
- beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
+ beg = ((int)Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 6)
@@ -98,9 +99,9 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
+ Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
- end = (int) Stream_GetPosition(s);
+ end = (int)Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
@@ -122,7 +123,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
IFCALLRET(context->ChangeParticipantControlLevel, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %"PRIu32"",
+ WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %" PRIu32 "",
error);
return error;
@@ -133,8 +134,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT encomsp_server_receive_pdu(EncomspServerContext* context,
- wStream* s)
+static UINT encomsp_server_receive_pdu(EncomspServerContext* context, wStream* s)
{
UINT error = CHANNEL_RC_OK;
ENCOMSP_ORDER_HEADER header;
@@ -143,21 +143,22 @@ static UINT encomsp_server_receive_pdu(EncomspServerContext* context,
{
if ((error = encomsp_read_header(s, &header)))
{
- WLog_ERR(TAG, "encomsp_read_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_read_header failed with error %" PRIu32 "!", error);
return error;
}
- WLog_INFO(TAG, "EncomspReceive: Type: %"PRIu16" Length: %"PRIu16"", header.Type,
+ WLog_INFO(TAG, "EncomspReceive: Type: %" PRIu16 " Length: %" PRIu16 "", header.Type,
header.Length);
switch (header.Type)
{
case ODTYPE_PARTICIPANT_CTRL_CHANGED:
- if ((error = encomsp_recv_change_participant_control_level_pdu(context, s,
- &header)))
+ if ((error =
+ encomsp_recv_change_participant_control_level_pdu(context, s, &header)))
{
WLog_ERR(TAG,
- "encomsp_recv_change_participant_control_level_pdu failed with error %"PRIu32"!",
+ "encomsp_recv_change_participant_control_level_pdu failed with error "
+ "%" PRIu32 "!",
error);
return error;
}
@@ -165,7 +166,7 @@ static UINT encomsp_server_receive_pdu(EncomspServerContext* context,
break;
default:
- WLog_ERR(TAG, "header.Type unknown %"PRIu16"!", header.Type);
+ WLog_ERR(TAG, "header.Type unknown %" PRIu16 "!", header.Type);
return ERROR_INVALID_DATA;
break;
}
@@ -186,7 +187,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
EncomspServerContext* context;
UINT error = CHANNEL_RC_OK;
DWORD status;
- context = (EncomspServerContext*) arg;
+ context = (EncomspServerContext*)arg;
buffer = NULL;
BytesReturned = 0;
@@ -200,8 +201,8 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
goto out;
}
- if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle,
- &buffer, &BytesReturned) == TRUE)
+ if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer,
+ &BytesReturned) == TRUE)
{
if (BytesReturned == sizeof(HANDLE))
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
@@ -220,7 +221,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -229,7 +230,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
break;
}
@@ -250,8 +251,8 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
break;
}
- if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
- (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned))
+ if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
+ Stream_Capacity(s), &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
error = ERROR_INTERNAL_ERROR;
@@ -260,7 +261,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
if (Stream_GetPosition(s) >= ENCOMSP_ORDER_HEADER_SIZE)
{
- header = (ENCOMSP_ORDER_HEADER*) Stream_Buffer(s);
+ header = (ENCOMSP_ORDER_HEADER*)Stream_Buffer(s);
if (header->Length >= Stream_GetPosition(s))
{
@@ -269,7 +270,8 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
if ((error = encomsp_server_receive_pdu(context, s)))
{
- WLog_ERR(TAG, "encomsp_server_receive_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "encomsp_server_receive_pdu failed with error %" PRIu32 "!",
+ error);
break;
}
@@ -282,8 +284,7 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
out:
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "encomsp_server_thread reported an error");
+ setChannelError(context->rdpcontext, error, "encomsp_server_thread reported an error");
ExitThread(error);
return error;
@@ -296,8 +297,8 @@ out:
*/
static UINT encomsp_server_start(EncomspServerContext* context)
{
- context->priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm,
- WTS_CURRENT_SESSION, "encomsp");
+ context->priv->ChannelHandle =
+ WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "encomsp");
if (!context->priv->ChannelHandle)
return CHANNEL_RC_BAD_CHANNEL;
@@ -308,8 +309,8 @@ static UINT encomsp_server_start(EncomspServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(context->priv->Thread = CreateThread(NULL, 0,
- encomsp_server_thread, (void*) context, 0, NULL)))
+ if (!(context->priv->Thread =
+ CreateThread(NULL, 0, encomsp_server_thread, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(context->priv->StopEvent);
@@ -333,7 +334,7 @@ static UINT encomsp_server_stop(EncomspServerContext* context)
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
return error;
}
@@ -345,14 +346,14 @@ static UINT encomsp_server_stop(EncomspServerContext* context)
EncomspServerContext* encomsp_server_context_new(HANDLE vcm)
{
EncomspServerContext* context;
- context = (EncomspServerContext*) calloc(1, sizeof(EncomspServerContext));
+ context = (EncomspServerContext*)calloc(1, sizeof(EncomspServerContext));
if (context)
{
context->vcm = vcm;
context->Start = encomsp_server_start;
context->Stop = encomsp_server_stop;
- context->priv = (EncomspServerPrivate*) calloc(1, sizeof(EncomspServerPrivate));
+ context->priv = (EncomspServerPrivate*)calloc(1, sizeof(EncomspServerPrivate));
if (!context->priv)
{
@@ -371,7 +372,7 @@ void encomsp_server_context_free(EncomspServerContext* context)
{
if (context->priv->ChannelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(context->priv->ChannelHandle);
-
+
free(context->priv);
free(context);
}
diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c
index 94671bb19..eb7b33864 100644
--- a/channels/geometry/client/geometry_main.c
+++ b/channels/geometry/client/geometry_main.c
@@ -72,23 +72,22 @@ struct _GEOMETRY_PLUGIN
};
typedef struct _GEOMETRY_PLUGIN GEOMETRY_PLUGIN;
-
-static UINT32 mappedGeometryHash(UINT64 *g)
+static UINT32 mappedGeometryHash(UINT64* g)
{
return (UINT32)((*g >> 32) + (*g & 0xffffffff));
}
-static BOOL mappedGeometryKeyCompare(UINT64 *g1, UINT64 *g2)
+static BOOL mappedGeometryKeyCompare(UINT64* g1, UINT64* g2)
{
return *g1 == *g2;
}
-void mappedGeometryRef(MAPPED_GEOMETRY *g)
+void mappedGeometryRef(MAPPED_GEOMETRY* g)
{
InterlockedIncrement(&g->refCounter);
}
-void mappedGeometryUnref(MAPPED_GEOMETRY *g)
+void mappedGeometryUnref(MAPPED_GEOMETRY* g)
{
if (InterlockedDecrement(&g->refCounter))
return;
@@ -100,13 +99,12 @@ void mappedGeometryUnref(MAPPED_GEOMETRY *g)
free(g);
}
-
-void freerdp_rgndata_reset(FREERDP_RGNDATA *data)
+void freerdp_rgndata_reset(FREERDP_RGNDATA* data)
{
data->nRectCount = 0;
}
-static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgndata)
+static UINT32 geometry_read_RGNDATA(wStream* s, UINT32 len, FREERDP_RGNDATA* rgndata)
{
UINT32 dwSize, iType;
INT32 right, bottom;
@@ -130,7 +128,7 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
if (iType != RDH_RECTANGLE)
{
- WLog_ERR(TAG, "iType %"PRIu32" for RGNDATA is not supported", iType);
+ WLog_ERR(TAG, "iType %" PRIu32 " for RGNDATA is not supported", iType);
return ERROR_UNSUPPORTED_TYPE;
}
@@ -160,11 +158,11 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
if (rgndata->nRectCount)
{
UINT32 i;
- RDP_RECT *tmp = realloc(rgndata->rects, rgndata->nRectCount * sizeof(RDP_RECT));
+ RDP_RECT* tmp = realloc(rgndata->rects, rgndata->nRectCount * sizeof(RDP_RECT));
if (!tmp)
{
- WLog_ERR(TAG, "unable to allocate memory for %"PRIu32" RECTs", rgndata->nRectCount);
+ WLog_ERR(TAG, "unable to allocate memory for %" PRIu32 " RECTs", rgndata->nRectCount);
return CHANNEL_RC_NO_MEMORY;
}
rgndata->rects = tmp;
@@ -199,14 +197,14 @@ static UINT32 geometry_read_RGNDATA(wStream *s, UINT32 len, FREERDP_RGNDATA *rgn
static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
{
UINT32 length, cbGeometryBuffer;
- MAPPED_GEOMETRY *mappedGeometry;
+ MAPPED_GEOMETRY* mappedGeometry;
GEOMETRY_PLUGIN* geometry;
- GeometryClientContext *context;
+ GeometryClientContext* context;
UINT ret = CHANNEL_RC_OK;
UINT32 version, updateType, geometryType;
UINT64 id;
- geometry = (GEOMETRY_PLUGIN*) callback->plugin;
+ geometry = (GEOMETRY_PLUGIN*)callback->plugin;
context = (GeometryClientContext*)geometry->iface.pInterface;
if (Stream_GetRemainingLength(s) < 4)
@@ -230,17 +228,18 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
mappedGeometry = HashTable_GetItemValue(context->geometries, &id);
- if (updateType == GEOMETRY_CLEAR )
+ if (updateType == GEOMETRY_CLEAR)
{
if (!mappedGeometry)
{
- WLog_ERR(TAG, "geometry 0x%"PRIx64" not found here, ignoring clear command", id);
+ WLog_ERR(TAG, "geometry 0x%" PRIx64 " not found here, ignoring clear command", id);
return CHANNEL_RC_OK;
}
- WLog_DBG(TAG, "clearing geometry 0x%"PRIx64"", id);
+ WLog_DBG(TAG, "clearing geometry 0x%" PRIx64 "", id);
- if (mappedGeometry->MappedGeometryClear && !mappedGeometry->MappedGeometryClear(mappedGeometry))
+ if (mappedGeometry->MappedGeometryClear &&
+ !mappedGeometry->MappedGeometryClear(mappedGeometry))
return ERROR_INTERNAL_ERROR;
if (!HashTable_Remove(context->geometries, &id))
@@ -253,7 +252,7 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
if (!mappedGeometry)
{
newOne = TRUE;
- WLog_DBG(TAG, "creating geometry 0x%"PRIx64"", id);
+ WLog_DBG(TAG, "creating geometry 0x%" PRIx64 "", id);
mappedGeometry = calloc(1, sizeof(MAPPED_GEOMETRY));
if (!mappedGeometry)
return CHANNEL_RC_NO_MEMORY;
@@ -261,16 +260,17 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
mappedGeometry->refCounter = 1;
mappedGeometry->mappingId = id;
- if (HashTable_Add(context->geometries, &(mappedGeometry->mappingId), mappedGeometry) < 0)
+ if (HashTable_Add(context->geometries, &(mappedGeometry->mappingId), mappedGeometry) <
+ 0)
{
- WLog_ERR(TAG, "unable to register geometry 0x%"PRIx64" in the table", id);
+ WLog_ERR(TAG, "unable to register geometry 0x%" PRIx64 " in the table", id);
free(mappedGeometry);
return CHANNEL_RC_NO_MEMORY;
}
}
else
{
- WLog_DBG(TAG, "updating geometry 0x%"PRIx64"", id);
+ WLog_DBG(TAG, "updating geometry 0x%" PRIx64 "", id);
}
Stream_Read_UINT64(s, mappedGeometry->topLevelId);
@@ -307,7 +307,8 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
if (newOne)
{
- if (context->MappedGeometryAdded && !context->MappedGeometryAdded(context, mappedGeometry))
+ if (context->MappedGeometryAdded &&
+ !context->MappedGeometryAdded(context, mappedGeometry))
{
WLog_ERR(TAG, "geometry added callback failed");
ret = ERROR_INTERNAL_ERROR;
@@ -315,7 +316,8 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
}
else
{
- if (mappedGeometry->MappedGeometryUpdate && !mappedGeometry->MappedGeometryUpdate(mappedGeometry))
+ if (mappedGeometry->MappedGeometryUpdate &&
+ !mappedGeometry->MappedGeometryUpdate(mappedGeometry))
{
WLog_ERR(TAG, "geometry update callback failed");
ret = ERROR_INTERNAL_ERROR;
@@ -324,11 +326,10 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
}
else
{
- WLog_ERR(TAG, "unknown updateType=%"PRIu32"", updateType);
+ WLog_ERR(TAG, "unknown updateType=%" PRIu32 "", updateType);
ret = CHANNEL_RC_OK;
}
-
return ret;
}
@@ -339,7 +340,7 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s)
*/
static UINT geometry_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- GEOMETRY_CHANNEL_CALLBACK* callback = (GEOMETRY_CHANNEL_CALLBACK*) pChannelCallback;
+ GEOMETRY_CHANNEL_CALLBACK* callback = (GEOMETRY_CHANNEL_CALLBACK*)pChannelCallback;
return geometry_recv_pdu(callback, data);
}
@@ -360,16 +361,17 @@ static UINT geometry_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
GEOMETRY_CHANNEL_CALLBACK* callback;
- GEOMETRY_LISTENER_CALLBACK* listener_callback = (GEOMETRY_LISTENER_CALLBACK*) pListenerCallback;
+ GEOMETRY_LISTENER_CALLBACK* listener_callback = (GEOMETRY_LISTENER_CALLBACK*)pListenerCallback;
WINPR_UNUSED(Data);
WINPR_UNUSED(pbAccept);
- callback = (GEOMETRY_CHANNEL_CALLBACK*) calloc(1, sizeof(GEOMETRY_CHANNEL_CALLBACK));
+ callback = (GEOMETRY_CHANNEL_CALLBACK*)calloc(1, sizeof(GEOMETRY_CHANNEL_CALLBACK));
if (!callback)
{
@@ -383,7 +385,7 @@ static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCa
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -395,9 +397,9 @@ static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCa
static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
UINT status;
- GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*) pPlugin;
- geometry->listener_callback = (GEOMETRY_LISTENER_CALLBACK*) calloc(1,
- sizeof(GEOMETRY_LISTENER_CALLBACK));
+ GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)pPlugin;
+ geometry->listener_callback =
+ (GEOMETRY_LISTENER_CALLBACK*)calloc(1, sizeof(GEOMETRY_LISTENER_CALLBACK));
if (!geometry->listener_callback)
{
@@ -409,7 +411,8 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
geometry->listener_callback->plugin = pPlugin;
geometry->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, GEOMETRY_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*) geometry->listener_callback, &(geometry->listener));
+ (IWTSListenerCallback*)geometry->listener_callback,
+ &(geometry->listener));
geometry->listener->pInterface = geometry->iface.pInterface;
return status;
}
@@ -421,8 +424,8 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
*/
static UINT geometry_plugin_terminated(IWTSPlugin* pPlugin)
{
- GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*) pPlugin;
- GeometryClientContext* context = (GeometryClientContext *)geometry->iface.pInterface;
+ GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)pPlugin;
+ GeometryClientContext* context = (GeometryClientContext*)geometry->iface.pInterface;
if (context)
HashTable_Free(context->geometries);
@@ -438,9 +441,9 @@ static UINT geometry_plugin_terminated(IWTSPlugin* pPlugin)
*/
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry geometry_DVCPluginEntry
+#define DVCPluginEntry geometry_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -453,11 +456,11 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error = CHANNEL_RC_OK;
GEOMETRY_PLUGIN* geometry;
GeometryClientContext* context;
- geometry = (GEOMETRY_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "geometry");
+ geometry = (GEOMETRY_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "geometry");
if (!geometry)
{
- geometry = (GEOMETRY_PLUGIN*) calloc(1, sizeof(GEOMETRY_PLUGIN));
+ geometry = (GEOMETRY_PLUGIN*)calloc(1, sizeof(GEOMETRY_PLUGIN));
if (!geometry)
{
@@ -469,7 +472,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
geometry->iface.Connected = NULL;
geometry->iface.Disconnected = NULL;
geometry->iface.Terminated = geometry_plugin_terminated;
- context = (GeometryClientContext*) calloc(1, sizeof(GeometryClientContext));
+ context = (GeometryClientContext*)calloc(1, sizeof(GeometryClientContext));
if (!context)
{
@@ -482,10 +485,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
context->geometries->keyCompare = (HASH_TABLE_KEY_COMPARE_FN)mappedGeometryKeyCompare;
context->geometries->valueFree = (HASH_TABLE_VALUE_FREE_FN)mappedGeometryUnref;
- context->handle = (void*) geometry;
- geometry->iface.pInterface = (void*) context;
+ context->handle = (void*)geometry;
+ geometry->iface.pInterface = (void*)context;
geometry->context = context;
- error = pEntryPoints->RegisterPlugin(pEntryPoints, "geometry", (IWTSPlugin*) geometry);
+ error = pEntryPoints->RegisterPlugin(pEntryPoints, "geometry", (IWTSPlugin*)geometry);
}
else
{
@@ -498,5 +501,4 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
error_context:
free(geometry);
return CHANNEL_RC_NO_MEMORY;
-
}
diff --git a/channels/geometry/client/geometry_main.h b/channels/geometry/client/geometry_main.h
index 1fb5321a2..ff6add28d 100644
--- a/channels/geometry/client/geometry_main.h
+++ b/channels/geometry/client/geometry_main.h
@@ -29,6 +29,4 @@
#include
#include
-
#endif /* FREERDP_CHANNEL_GEOMETRY_CLIENT_MAIN_H */
-
diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c
index 19ebce326..3fc6c4158 100644
--- a/channels/parallel/client/parallel_main.c
+++ b/channels/parallel/client/parallel_main.c
@@ -88,11 +88,11 @@ static UINT parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
Stream_Read_UINT32(irp->input, PathLength);
- status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input),
- PathLength / 2, &path, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)Stream_Pointer(irp->input), PathLength / 2,
+ &path, 0, NULL, NULL);
if (status < 1)
- if (!(path = (char*) calloc(1, 1)))
+ if (!(path = (char*)calloc(1, 1)))
{
WLog_ERR(TAG, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
@@ -151,7 +151,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
BYTE* buffer = NULL;
Stream_Read_UINT32(irp->input, Length);
Stream_Read_UINT64(irp->input, Offset);
- buffer = (BYTE*) malloc(Length);
+ buffer = (BYTE*)malloc(Length);
if (!buffer)
{
@@ -231,8 +231,7 @@ static UINT parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT parallel_process_irp_device_control(PARALLEL_DEVICE* parallel,
- IRP* irp)
+static UINT parallel_process_irp_device_control(PARALLEL_DEVICE* parallel, IRP* irp)
{
Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */
return irp->Complete(irp);
@@ -252,7 +251,7 @@ static UINT parallel_process_irp(PARALLEL_DEVICE* parallel, IRP* irp)
case IRP_MJ_CREATE:
if ((error = parallel_process_irp_create(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp_create failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "parallel_process_irp_create failed with error %" PRIu32 "!", error);
return error;
}
@@ -261,7 +260,7 @@ static UINT parallel_process_irp(PARALLEL_DEVICE* parallel, IRP* irp)
case IRP_MJ_CLOSE:
if ((error = parallel_process_irp_close(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp_close failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "parallel_process_irp_close failed with error %" PRIu32 "!", error);
return error;
}
@@ -270,7 +269,7 @@ static UINT parallel_process_irp(PARALLEL_DEVICE* parallel, IRP* irp)
case IRP_MJ_READ:
if ((error = parallel_process_irp_read(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp_read failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "parallel_process_irp_read failed with error %" PRIu32 "!", error);
return error;
}
@@ -279,7 +278,7 @@ static UINT parallel_process_irp(PARALLEL_DEVICE* parallel, IRP* irp)
case IRP_MJ_WRITE:
if ((error = parallel_process_irp_write(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "parallel_process_irp_write failed with error %" PRIu32 "!", error);
return error;
}
@@ -288,7 +287,7 @@ static UINT parallel_process_irp(PARALLEL_DEVICE* parallel, IRP* irp)
case IRP_MJ_DEVICE_CONTROL:
if ((error = parallel_process_irp_device_control(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp_device_control failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "parallel_process_irp_device_control failed with error %" PRIu32 "!",
error);
return error;
}
@@ -308,7 +307,7 @@ static DWORD WINAPI parallel_thread_func(LPVOID arg)
{
IRP* irp;
wMessage message;
- PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) arg;
+ PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*)arg;
UINT error = CHANNEL_RC_OK;
while (1)
@@ -330,18 +329,17 @@ static DWORD WINAPI parallel_thread_func(LPVOID arg)
if (message.id == WMQ_QUIT)
break;
- irp = (IRP*) message.wParam;
+ irp = (IRP*)message.wParam;
if ((error = parallel_process_irp(parallel, irp)))
{
- WLog_ERR(TAG, "parallel_process_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "parallel_process_irp failed with error %" PRIu32 "!", error);
break;
}
}
if (error && parallel->rdpcontext)
- setChannelError(parallel->rdpcontext, error,
- "parallel_thread_func reported an error");
+ setChannelError(parallel->rdpcontext, error, "parallel_thread_func reported an error");
ExitThread(error);
return error;
@@ -354,9 +352,9 @@ static DWORD WINAPI parallel_thread_func(LPVOID arg)
*/
static UINT parallel_irp_request(DEVICE* device, IRP* irp)
{
- PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) device;
+ PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*)device;
- if (!MessageQueue_Post(parallel->queue, NULL, 0, (void*) irp, NULL))
+ if (!MessageQueue_Post(parallel->queue, NULL, 0, (void*)irp, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -373,13 +371,13 @@ static UINT parallel_irp_request(DEVICE* device, IRP* irp)
static UINT parallel_free(DEVICE* device)
{
UINT error;
- PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) device;
+ PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*)device;
- if (!MessageQueue_PostQuit(parallel->queue, 0)
- || (WaitForSingleObject(parallel->thread, INFINITE) == WAIT_FAILED))
+ if (!MessageQueue_PostQuit(parallel->queue, 0) ||
+ (WaitForSingleObject(parallel->thread, INFINITE) == WAIT_FAILED))
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -391,9 +389,9 @@ static UINT parallel_free(DEVICE* device)
}
#ifdef BUILTIN_CHANNELS
-#define DeviceServiceEntry parallel_DeviceServiceEntry
+#define DeviceServiceEntry parallel_DeviceServiceEntry
#else
-#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
+#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
#endif
/**
@@ -410,7 +408,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
RDPDR_PARALLEL* device;
PARALLEL_DEVICE* parallel;
UINT error;
- device = (RDPDR_PARALLEL*) pEntryPoints->device;
+ device = (RDPDR_PARALLEL*)pEntryPoints->device;
name = device->Name;
path = device->Path;
@@ -422,7 +420,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
if (name[0] && path[0])
{
- parallel = (PARALLEL_DEVICE*) calloc(1, sizeof(PARALLEL_DEVICE));
+ parallel = (PARALLEL_DEVICE*)calloc(1, sizeof(PARALLEL_DEVICE));
if (!parallel)
{
@@ -458,15 +456,14 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
goto error_out;
}
- if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman,
- (DEVICE*) parallel)))
+ if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)parallel)))
{
- WLog_ERR(TAG, "RegisterDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "RegisterDevice failed with error %" PRIu32 "!", error);
goto error_out;
}
- if (!(parallel->thread = CreateThread(NULL, 0,
- parallel_thread_func, (void*) parallel, 0, NULL)))
+ if (!(parallel->thread =
+ CreateThread(NULL, 0, parallel_thread_func, (void*)parallel, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
error = ERROR_INTERNAL_ERROR;
diff --git a/channels/printer/client/cups/printer_cups.c b/channels/printer/client/cups/printer_cups.c
index 6683de5c2..b78632e9c 100644
--- a/channels/printer/client/cups/printer_cups.c
+++ b/channels/printer/client/cups/printer_cups.c
@@ -73,9 +73,8 @@ static void printer_cups_get_printjob_name(char* buf, size_t size, size_t id)
tt = time(NULL);
t = localtime(&tt);
- sprintf_s(buf, size - 1, "FreeRDP Print %04d-%02d-%02d %02d-%02d-%02d - Job %"PRIdz,
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec, id);
+ sprintf_s(buf, size - 1, "FreeRDP Print %04d-%02d-%02d %02d-%02d-%02d - Job %" PRIdz,
+ t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, id);
}
/**
@@ -85,14 +84,14 @@ static void printer_cups_get_printjob_name(char* buf, size_t size, size_t id)
*/
static UINT printer_cups_write_printjob(rdpPrintJob* printjob, const BYTE* data, size_t size)
{
- rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob;
+ rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
#ifndef _CUPS_API_1_4
{
FILE* fp;
- fp = fopen((const char*) cups_printjob->printjob_object, "a+b");
+ fp = fopen((const char*)cups_printjob->printjob_object, "a+b");
if (!fp)
return ERROR_INTERNAL_ERROR;
@@ -109,7 +108,7 @@ static UINT printer_cups_write_printjob(rdpPrintJob* printjob, const BYTE* data,
#else
- cupsWriteRequestData((http_t*) cups_printjob->printjob_object, (const char*) data, size);
+ cupsWriteRequestData((http_t*)cups_printjob->printjob_object, (const char*)data, size);
#endif
@@ -118,7 +117,7 @@ static UINT printer_cups_write_printjob(rdpPrintJob* printjob, const BYTE* data,
static void printer_cups_close_printjob(rdpPrintJob* printjob)
{
- rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob;
+ rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
#ifndef _CUPS_API_1_4
@@ -127,9 +126,9 @@ static void printer_cups_close_printjob(rdpPrintJob* printjob)
printer_cups_get_printjob_name(buf, sizeof(buf), printjob->id);
- if (cupsPrintFile(printjob->printer->name, (const char*) cups_printjob->printjob_object, buf, 0, NULL) == 0)
+ if (cupsPrintFile(printjob->printer->name, (const char*)cups_printjob->printjob_object, buf,
+ 0, NULL) == 0)
{
-
}
unlink(cups_printjob->printjob_object);
@@ -138,25 +137,25 @@ static void printer_cups_close_printjob(rdpPrintJob* printjob)
#else
- cupsFinishDocument((http_t*) cups_printjob->printjob_object, printjob->printer->name);
+ cupsFinishDocument((http_t*)cups_printjob->printjob_object, printjob->printer->name);
cups_printjob->printjob_id = 0;
- httpClose((http_t*) cups_printjob->printjob_object);
+ httpClose((http_t*)cups_printjob->printjob_object);
#endif
- ((rdpCupsPrinter*) printjob->printer)->printjob = NULL;
- free(cups_printjob) ;
+ ((rdpCupsPrinter*)printjob->printer)->printjob = NULL;
+ free(cups_printjob);
}
static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
{
- rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer;
+ rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer;
rdpCupsPrintJob* cups_printjob;
if (cups_printer->printjob != NULL)
return NULL;
- cups_printjob = (rdpCupsPrintJob*) calloc(1, sizeof(rdpCupsPrintJob));
+ cups_printjob = (rdpCupsPrintJob*)calloc(1, sizeof(rdpCupsPrintJob));
if (!cups_printjob)
return NULL;
@@ -179,7 +178,8 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
{
char buf[100];
- cups_printjob->printjob_object = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED);
+ cups_printjob->printjob_object =
+ httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED);
if (!cups_printjob->printjob_object)
{
@@ -189,24 +189,24 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
printer_cups_get_printjob_name(buf, sizeof(buf), cups_printjob->printjob.id);
- cups_printjob->printjob_id = cupsCreateJob((http_t*) cups_printjob->printjob_object,
- printer->name, buf, 0, NULL);
+ cups_printjob->printjob_id =
+ cupsCreateJob((http_t*)cups_printjob->printjob_object, printer->name, buf, 0, NULL);
if (!cups_printjob->printjob_id)
{
- httpClose((http_t*) cups_printjob->printjob_object);
+ httpClose((http_t*)cups_printjob->printjob_object);
free(cups_printjob);
return NULL;
}
- cupsStartDocument((http_t*) cups_printjob->printjob_object,
- printer->name, cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1);
+ cupsStartDocument((http_t*)cups_printjob->printjob_object, printer->name,
+ cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1);
}
#endif
cups_printer->printjob = cups_printjob;
-
+
return (rdpPrintJob*)cups_printjob;
}
@@ -224,10 +224,10 @@ static rdpPrintJob* printer_cups_find_printjob(rdpPrinter* printer, UINT32 id)
static void printer_cups_free_printer(rdpPrinter* printer)
{
- rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer;
+ rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer;
if (cups_printer->printjob)
- cups_printer->printjob->printjob.Close((rdpPrintJob*) cups_printer->printjob);
+ cups_printer->printjob->printjob.Close((rdpPrintJob*)cups_printer->printjob);
if (printer->backend)
printer->backend->ReleaseRef(printer->backend);
@@ -252,12 +252,12 @@ static void printer_cups_release_ref_printer(rdpPrinter* printer)
printer->references--;
}
-static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver,
- const char* name, const char* driverName, BOOL is_default)
+static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, const char* name,
+ const char* driverName, BOOL is_default)
{
rdpCupsPrinter* cups_printer;
- cups_printer = (rdpCupsPrinter*) calloc(1, sizeof(rdpCupsPrinter));
+ cups_printer = (rdpCupsPrinter*)calloc(1, sizeof(rdpCupsPrinter));
if (!cups_printer)
return NULL;
@@ -288,7 +288,6 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver,
cups_printer->printer.AddRef = printer_cups_add_ref_printer;
cups_printer->printer.ReleaseRef = printer_cups_release_ref_printer;
-
cups_printer->printer.AddRef(&cups_printer->printer);
cups_printer->printer.backend->AddRef(cups_printer->printer.backend);
return &cups_printer->printer;
@@ -298,7 +297,7 @@ static void printer_cups_release_enum_printers(rdpPrinter** printers)
{
rdpPrinter** cur = printers;
- while((cur != NULL) && ((*cur) != NULL))
+ while ((cur != NULL) && ((*cur) != NULL))
{
if ((*cur)->ReleaseRef)
(*cur)->ReleaseRef(*cur);
@@ -311,13 +310,13 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
{
rdpPrinter** printers;
int num_printers;
- cups_dest_t *dests;
- cups_dest_t *dest;
+ cups_dest_t* dests;
+ cups_dest_t* dest;
int num_dests;
int i;
num_dests = cupsGetDests(&dests);
- printers = (rdpPrinter**) calloc(num_dests + 1, sizeof(rdpPrinter*));
+ printers = (rdpPrinter**)calloc(num_dests + 1, sizeof(rdpPrinter*));
if (!printers)
return NULL;
@@ -328,8 +327,8 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
if (dest->instance == NULL)
{
rdpPrinter* current = printers[num_printers];
- current = printer_cups_new_printer((rdpCupsPrinterDriver*) driver,
- dest->name, NULL, dest->is_default);
+ current = printer_cups_new_printer((rdpCupsPrinterDriver*)driver, dest->name, NULL,
+ dest->is_default);
if (!current)
{
printer_cups_release_enum_printers(printers);
@@ -345,18 +344,18 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
return printers;
}
-static rdpPrinter* printer_cups_get_printer(rdpPrinterDriver* driver,
- const char* name, const char* driverName)
+static rdpPrinter* printer_cups_get_printer(rdpPrinterDriver* driver, const char* name,
+ const char* driverName)
{
- rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*) driver;
+ rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*)driver;
return printer_cups_new_printer(cups_driver, name, driverName,
- cups_driver->id_sequence == 1 ? TRUE : FALSE);
+ cups_driver->id_sequence == 1 ? TRUE : FALSE);
}
static void printer_cups_add_ref_driver(rdpPrinterDriver* driver)
{
- rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*) driver;
+ rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*)driver;
if (cups_driver)
cups_driver->references++;
}
@@ -366,7 +365,7 @@ static rdpCupsPrinterDriver* cups_driver = NULL;
static void printer_cups_release_ref_driver(rdpPrinterDriver* driver)
{
- rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*) driver;
+ rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*)driver;
if (cups_driver->references <= 1)
{
free(cups_driver);
@@ -377,14 +376,14 @@ static void printer_cups_release_ref_driver(rdpPrinterDriver* driver)
}
#ifdef BUILTIN_CHANNELS
-rdpPrinterDriver *cups_freerdp_printer_client_subsystem_entry(void)
+rdpPrinterDriver* cups_freerdp_printer_client_subsystem_entry(void)
#else
-FREERDP_API rdpPrinterDriver *freerdp_printer_client_subsystem_entry(void)
+FREERDP_API rdpPrinterDriver* freerdp_printer_client_subsystem_entry(void)
#endif
{
if (!cups_driver)
{
- cups_driver = (rdpCupsPrinterDriver*) calloc(1, sizeof(rdpCupsPrinterDriver));
+ cups_driver = (rdpCupsPrinterDriver*)calloc(1, sizeof(rdpCupsPrinterDriver));
if (!cups_driver)
return NULL;
diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c
index 4c1f35984..e83ef5a07 100644
--- a/channels/printer/client/printer_main.c
+++ b/channels/printer/client/printer_main.c
@@ -71,21 +71,15 @@ typedef enum
PRN_CONF_PNP = 1,
PRN_CONF_DRIVER = 2,
PRN_CONF_DATA = 3
-}
-prn_conf_t;
+} prn_conf_t;
-static const char* filemap[] =
-{
- "PortDosName",
- "PnPName",
- "DriverName",
- "CachedPrinterConfigData"
-};
+static const char* filemap[] = { "PortDosName", "PnPName", "DriverName",
+ "CachedPrinterConfigData" };
static char* get_printer_config_path(const rdpSettings* settings, const WCHAR* name, size_t length)
{
char* dir = GetCombinedPath(settings->ConfigPath, "printers");
- char* bname = crypto_base64_encode((const BYTE*) name, (int)length);
+ char* bname = crypto_base64_encode((const BYTE*)name, (int)length);
char* config = GetCombinedPath(dir, bname);
if (config && !PathFileExistsA(config))
@@ -116,8 +110,7 @@ static BOOL printer_write_setting(const char* path, prn_conf_t type, const void*
if (!abs)
return FALSE;
- file = CreateFileA(abs, GENERIC_WRITE, 0,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ file = CreateFileA(abs, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
free(abs);
if (file == INVALID_HANDLE_VALUE)
@@ -171,8 +164,7 @@ static BOOL printer_read_setting(const char* path, prn_conf_t type, void** data,
if (!abs)
return FALSE;
- file = CreateFileA(abs, GENERIC_READ, 0,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ file = CreateFileA(abs, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
free(abs);
if (file == INVALID_HANDLE_VALUE)
@@ -222,9 +214,8 @@ fail:
return rc;
}
-static BOOL printer_save_to_config(const rdpSettings* settings,
- const char* PortDosName, size_t PortDosNameLen,
- const WCHAR* PnPName, size_t PnPNameLen,
+static BOOL printer_save_to_config(const rdpSettings* settings, const char* PortDosName,
+ size_t PortDosNameLen, const WCHAR* PnPName, size_t PnPNameLen,
const WCHAR* DriverName, size_t DriverNameLen,
const WCHAR* PrinterName, size_t PrintNameLen,
const BYTE* CachedPrinterConfigData, size_t CacheFieldsLen)
@@ -332,8 +323,8 @@ static BOOL printer_load_from_config(const rdpSettings* settings, rdpPrinter* pr
if (!printer_read_setting(path, PRN_CONF_DRIVER, &DriverName, &DriverNameLen))
{
- DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, (LPWSTR*)&DriverName,
- 0) * 2 + 1;
+ DriverNameLen =
+ ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, (LPWSTR*)&DriverName, 0) * 2 + 1;
}
if (!printer_read_setting(path, PRN_CONF_DATA, &CachedPrinterConfigData, &CachedFieldsLen))
@@ -346,7 +337,7 @@ static BOOL printer_load_from_config(const rdpSettings* settings, rdpPrinter* pr
goto fail;
Stream_Write_UINT32(printer_dev->device.data, flags);
- Stream_Write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */
+ Stream_Write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */
Stream_Write_UINT32(printer_dev->device.data, PnPNameLen); /* PnPNameLen */
Stream_Write_UINT32(printer_dev->device.data, DriverNameLen);
Stream_Write_UINT32(printer_dev->device.data, PrinterNameLen);
@@ -435,8 +426,8 @@ static UINT printer_process_irp_create(PRINTER_DEVICE* printer_dev, IRP* irp)
rdpPrintJob* printjob = NULL;
if (printer_dev->printer)
- printjob = printer_dev->printer->CreatePrintJob(printer_dev->printer,
- irp->devman->id_sequence++);
+ printjob =
+ printer_dev->printer->CreatePrintJob(printer_dev->printer, irp->devman->id_sequence++);
if (printjob)
{
@@ -461,8 +452,7 @@ static UINT printer_process_irp_close(PRINTER_DEVICE* printer_dev, IRP* irp)
rdpPrintJob* printjob = NULL;
if (printer_dev->printer)
- printjob = printer_dev->printer->FindPrintJob(printer_dev->printer,
- irp->FileId);
+ printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId);
if (!printjob)
{
@@ -493,8 +483,7 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
Stream_Seek(irp->input, 20); /* Padding */
if (printer_dev->printer)
- printjob = printer_dev->printer->FindPrintJob(printer_dev->printer,
- irp->FileId);
+ printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId);
if (!printjob)
{
@@ -508,7 +497,7 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
if (error)
{
- WLog_ERR(TAG, "printjob->Write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printjob->Write failed with error %" PRIu32 "!", error);
return error;
}
@@ -522,8 +511,7 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT printer_process_irp_device_control(PRINTER_DEVICE* printer_dev,
- IRP* irp)
+static UINT printer_process_irp_device_control(PRINTER_DEVICE* printer_dev, IRP* irp)
{
Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */
return irp->Complete(irp);
@@ -543,7 +531,7 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
case IRP_MJ_CREATE:
if ((error = printer_process_irp_create(printer_dev, irp)))
{
- WLog_ERR(TAG, "printer_process_irp_create failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_process_irp_create failed with error %" PRIu32 "!", error);
return error;
}
@@ -552,7 +540,7 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
case IRP_MJ_CLOSE:
if ((error = printer_process_irp_close(printer_dev, irp)))
{
- WLog_ERR(TAG, "printer_process_irp_close failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_process_irp_close failed with error %" PRIu32 "!", error);
return error;
}
@@ -561,7 +549,7 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
case IRP_MJ_WRITE:
if ((error = printer_process_irp_write(printer_dev, irp)))
{
- WLog_ERR(TAG, "printer_process_irp_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_process_irp_write failed with error %" PRIu32 "!", error);
return error;
}
@@ -570,7 +558,7 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
case IRP_MJ_DEVICE_CONTROL:
if ((error = printer_process_irp_device_control(printer_dev, irp)))
{
- WLog_ERR(TAG, "printer_process_irp_device_control failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "printer_process_irp_device_control failed with error %" PRIu32 "!",
error);
return error;
}
@@ -589,8 +577,8 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
static DWORD WINAPI printer_thread_func(LPVOID arg)
{
IRP* irp;
- PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) arg;
- HANDLE obj[] = {printer_dev->event, printer_dev->stopEvent};
+ PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)arg;
+ HANDLE obj[] = { printer_dev->event, printer_dev->stopEvent };
UINT error = CHANNEL_RC_OK;
while (1)
@@ -600,7 +588,7 @@ static DWORD WINAPI printer_thread_func(LPVOID arg)
if (rc == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -610,7 +598,7 @@ static DWORD WINAPI printer_thread_func(LPVOID arg)
continue;
ResetEvent(printer_dev->event);
- irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList);
+ irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList);
if (irp == NULL)
{
@@ -621,14 +609,13 @@ static DWORD WINAPI printer_thread_func(LPVOID arg)
if ((error = printer_process_irp(printer_dev, irp)))
{
- WLog_ERR(TAG, "printer_process_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_process_irp failed with error %" PRIu32 "!", error);
break;
}
}
if (error && printer_dev->rdpcontext)
- setChannelError(printer_dev->rdpcontext, error,
- "printer_thread_func reported an error");
+ setChannelError(printer_dev->rdpcontext, error, "printer_thread_func reported an error");
ExitThread(error);
return error;
@@ -641,7 +628,7 @@ static DWORD WINAPI printer_thread_func(LPVOID arg)
*/
static UINT printer_irp_request(DEVICE* device, IRP* irp)
{
- PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device;
+ PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)device;
InterlockedPushEntrySList(printer_dev->pIrpList, &(irp->ItemEntry));
SetEvent(printer_dev->event);
return CHANNEL_RC_OK;
@@ -650,7 +637,7 @@ static UINT printer_irp_request(DEVICE* device, IRP* irp)
static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 packetId, wStream* s)
{
UINT32 eventID;
- PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device;
+ PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)device;
const rdpSettings* settings = printer_dev->rdpcontext->settings;
if (component != RDPDR_CTYP_PRN)
@@ -667,156 +654,156 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
switch (eventID)
{
case RDPDR_ADD_PRINTER_EVENT:
- {
- char PortDosName[8];
- UINT32 PnPNameLen, DriverNameLen, PrintNameLen, CacheFieldsLen;
- const WCHAR* PnPName, *DriverName, *PrinterName;
- const BYTE* CachedPrinterConfigData;
+ {
+ char PortDosName[8];
+ UINT32 PnPNameLen, DriverNameLen, PrintNameLen, CacheFieldsLen;
+ const WCHAR *PnPName, *DriverName, *PrinterName;
+ const BYTE* CachedPrinterConfigData;
- if (Stream_GetRemainingLength(s) < 24)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < 24)
+ return ERROR_INVALID_DATA;
- Stream_Read(s, PortDosName, sizeof(PortDosName));
- Stream_Read_UINT32(s, PnPNameLen);
- Stream_Read_UINT32(s, DriverNameLen);
- Stream_Read_UINT32(s, PrintNameLen);
- Stream_Read_UINT32(s, CacheFieldsLen);
+ Stream_Read(s, PortDosName, sizeof(PortDosName));
+ Stream_Read_UINT32(s, PnPNameLen);
+ Stream_Read_UINT32(s, DriverNameLen);
+ Stream_Read_UINT32(s, PrintNameLen);
+ Stream_Read_UINT32(s, CacheFieldsLen);
- if (Stream_GetRemainingLength(s) < PnPNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < PnPNameLen)
+ return ERROR_INVALID_DATA;
- PnPName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, PnPNameLen);
+ PnPName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, PnPNameLen);
- if (Stream_GetRemainingLength(s) < DriverNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < DriverNameLen)
+ return ERROR_INVALID_DATA;
- DriverName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, DriverNameLen);
+ DriverName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, DriverNameLen);
- if (Stream_GetRemainingLength(s) < PrintNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < PrintNameLen)
+ return ERROR_INVALID_DATA;
- PrinterName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, PrintNameLen);
+ PrinterName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, PrintNameLen);
- if (Stream_GetRemainingLength(s) < CacheFieldsLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < CacheFieldsLen)
+ return ERROR_INVALID_DATA;
- CachedPrinterConfigData = Stream_Pointer(s);
- Stream_Seek(s, CacheFieldsLen);
+ CachedPrinterConfigData = Stream_Pointer(s);
+ Stream_Seek(s, CacheFieldsLen);
- if (!printer_save_to_config(settings,
- PortDosName, sizeof(PortDosName),
- PnPName, PnPNameLen,
- DriverName, DriverNameLen,
- PrinterName, PrintNameLen,
- CachedPrinterConfigData, CacheFieldsLen))
- return ERROR_INTERNAL_ERROR;
- }
- break;
+ if (!printer_save_to_config(settings, PortDosName, sizeof(PortDosName), PnPName,
+ PnPNameLen, DriverName, DriverNameLen, PrinterName,
+ PrintNameLen, CachedPrinterConfigData,
+ CacheFieldsLen))
+ return ERROR_INTERNAL_ERROR;
+ }
+ break;
case RDPDR_UPDATE_PRINTER_EVENT:
- {
- UINT32 PrinterNameLen, ConfigDataLen;
- const WCHAR* PrinterName;
- const BYTE* ConfigData;
+ {
+ UINT32 PrinterNameLen, ConfigDataLen;
+ const WCHAR* PrinterName;
+ const BYTE* ConfigData;
- if (Stream_GetRemainingLength(s) < 8)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < 8)
+ return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, PrinterNameLen);
- Stream_Read_UINT32(s, ConfigDataLen);
+ Stream_Read_UINT32(s, PrinterNameLen);
+ Stream_Read_UINT32(s, ConfigDataLen);
- if (Stream_GetRemainingLength(s) < PrinterNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < PrinterNameLen)
+ return ERROR_INVALID_DATA;
- PrinterName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, PrinterNameLen);
+ PrinterName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, PrinterNameLen);
- if (Stream_GetRemainingLength(s) < ConfigDataLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < ConfigDataLen)
+ return ERROR_INVALID_DATA;
- ConfigData = Stream_Pointer(s);
- Stream_Seek(s, ConfigDataLen);
+ ConfigData = Stream_Pointer(s);
+ Stream_Seek(s, ConfigDataLen);
- if (!printer_update_to_config(settings, PrinterName, PrinterNameLen, ConfigData, ConfigDataLen))
- return ERROR_INTERNAL_ERROR;
- }
- break;
+ if (!printer_update_to_config(settings, PrinterName, PrinterNameLen, ConfigData,
+ ConfigDataLen))
+ return ERROR_INTERNAL_ERROR;
+ }
+ break;
case RDPDR_DELETE_PRINTER_EVENT:
- {
- UINT32 PrinterNameLen;
- const WCHAR* PrinterName;
+ {
+ UINT32 PrinterNameLen;
+ const WCHAR* PrinterName;
- if (Stream_GetRemainingLength(s) < 4)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < 4)
+ return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, PrinterNameLen);
+ Stream_Read_UINT32(s, PrinterNameLen);
- if (Stream_GetRemainingLength(s) < PrinterNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < PrinterNameLen)
+ return ERROR_INVALID_DATA;
- PrinterName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, PrinterNameLen);
- printer_remove_config(settings, PrinterName, PrinterNameLen);
- }
- break;
+ PrinterName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, PrinterNameLen);
+ printer_remove_config(settings, PrinterName, PrinterNameLen);
+ }
+ break;
case RDPDR_RENAME_PRINTER_EVENT:
- {
- UINT32 OldPrinterNameLen, NewPrinterNameLen;
- const WCHAR* OldPrinterName;
- const WCHAR* NewPrinterName;
+ {
+ UINT32 OldPrinterNameLen, NewPrinterNameLen;
+ const WCHAR* OldPrinterName;
+ const WCHAR* NewPrinterName;
- if (Stream_GetRemainingLength(s) < 8)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < 8)
+ return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, OldPrinterNameLen);
- Stream_Read_UINT32(s, NewPrinterNameLen);
+ Stream_Read_UINT32(s, OldPrinterNameLen);
+ Stream_Read_UINT32(s, NewPrinterNameLen);
- if (Stream_GetRemainingLength(s) < OldPrinterNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < OldPrinterNameLen)
+ return ERROR_INVALID_DATA;
- OldPrinterName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, OldPrinterNameLen);
+ OldPrinterName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, OldPrinterNameLen);
- if (Stream_GetRemainingLength(s) < NewPrinterNameLen)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < NewPrinterNameLen)
+ return ERROR_INVALID_DATA;
- NewPrinterName = (const WCHAR*)Stream_Pointer(s);
- Stream_Seek(s, NewPrinterNameLen);
+ NewPrinterName = (const WCHAR*)Stream_Pointer(s);
+ Stream_Seek(s, NewPrinterNameLen);
- if (!printer_move_config(settings, OldPrinterName, OldPrinterNameLen, NewPrinterName,
- NewPrinterNameLen))
- return ERROR_INTERNAL_ERROR;
- }
- break;
+ if (!printer_move_config(settings, OldPrinterName, OldPrinterNameLen,
+ NewPrinterName, NewPrinterNameLen))
+ return ERROR_INTERNAL_ERROR;
+ }
+ break;
default:
- WLog_ERR(TAG, "Unknown cache data eventID: 0x%08"PRIX32"", eventID);
+ WLog_ERR(TAG, "Unknown cache data eventID: 0x%08" PRIX32 "", eventID);
return ERROR_INVALID_DATA;
}
break;
case PAKID_PRN_USING_XPS:
- {
- UINT32 flags;
+ {
+ UINT32 flags;
- if (Stream_GetRemainingLength(s) < 4)
- return ERROR_INVALID_DATA;
+ if (Stream_GetRemainingLength(s) < 4)
+ return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, flags);
- WLog_ERR(TAG,
- "Ignoring unhandled message PAKID_PRN_USING_XPS [printerID=%08"PRIx32", flags=%08"PRIx32"]",
- eventID, flags);
- }
- break;
+ Stream_Read_UINT32(s, flags);
+ WLog_ERR(TAG,
+ "Ignoring unhandled message PAKID_PRN_USING_XPS [printerID=%08" PRIx32
+ ", flags=%08" PRIx32 "]",
+ eventID, flags);
+ }
+ break;
default:
- WLog_ERR(TAG, "Unknown printing component packetID: 0x%04"PRIX16"", packetId);
+ WLog_ERR(TAG, "Unknown printing component packetID: 0x%04" PRIX16 "", packetId);
return ERROR_INVALID_DATA;
}
@@ -831,14 +818,14 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
static UINT printer_free(DEVICE* device)
{
IRP* irp;
- PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) device;
+ PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)device;
UINT error;
SetEvent(printer_dev->stopEvent);
if (WaitForSingleObject(printer_dev->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
/* The analyzer is confused by this premature return value.
* Since this case can not be handled gracefully silence the
@@ -848,7 +835,7 @@ static UINT printer_free(DEVICE* device)
#endif
}
- while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
+ while ((irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
irp->Discard(irp);
CloseHandle(printer_dev->thread);
@@ -869,12 +856,11 @@ static UINT printer_free(DEVICE* device)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
- rdpPrinter* printer)
+static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
{
PRINTER_DEVICE* printer_dev;
UINT error = ERROR_INTERNAL_ERROR;
- printer_dev = (PRINTER_DEVICE*) calloc(1, sizeof(PRINTER_DEVICE));
+ printer_dev = (PRINTER_DEVICE*)calloc(1, sizeof(PRINTER_DEVICE));
if (!printer_dev)
{
@@ -887,7 +873,7 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
if (!printer_dev->device.data)
goto error_out;
- sprintf_s(printer_dev->port, sizeof(printer_dev->port), "PRN%"PRIdz, printer->id);
+ sprintf_s(printer_dev->port, sizeof(printer_dev->port), "PRN%" PRIdz, printer->id);
printer_dev->device.type = RDPDR_DTYP_PRINT;
printer_dev->device.name = printer_dev->port;
printer_dev->device.IRPRequest = printer_irp_request;
@@ -895,8 +881,8 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
printer_dev->device.Free = printer_free;
printer_dev->rdpcontext = pEntryPoints->rdpcontext;
printer_dev->printer = printer;
- printer_dev->pIrpList = (WINPR_PSLIST_HEADER) _aligned_malloc(sizeof(
- WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
+ printer_dev->pIrpList = (WINPR_PSLIST_HEADER)_aligned_malloc(sizeof(WINPR_SLIST_HEADER),
+ MEMORY_ALLOCATION_ALIGNMENT);
if (!printer_dev->pIrpList)
{
@@ -924,15 +910,14 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
goto error_out;
}
- if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman,
- (DEVICE*) printer_dev)))
+ if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)printer_dev)))
{
- WLog_ERR(TAG, "RegisterDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "RegisterDevice failed with error %" PRIu32 "!", error);
goto error_out;
}
- if (!(printer_dev->thread = CreateThread(NULL, 0, printer_thread_func, (void*) printer_dev, 0,
- NULL)))
+ if (!(printer_dev->thread =
+ CreateThread(NULL, 0, printer_thread_func, (void*)printer_dev, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
error = ERROR_INTERNAL_ERROR;
@@ -950,7 +935,8 @@ static rdpPrinterDriver* printer_load_backend(const char* backend)
{
typedef rdpPrinterDriver* (*backend_load_t)(void);
- backend_load_t entry = (backend_load_t)freerdp_load_channel_addin_entry("printer", backend, NULL, 0);
+ backend_load_t entry =
+ (backend_load_t)freerdp_load_channel_addin_entry("printer", backend, NULL, 0);
if (!entry)
return NULL;
@@ -966,22 +952,23 @@ UINT
#ifdef BUILTIN_CHANNELS
printer_DeviceServiceEntry
#else
-FREERDP_API DeviceServiceEntry
+ FREERDP_API
+ DeviceServiceEntry
#endif
(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
int i;
char* name;
char* driver_name;
- BOOL default_backend = TRUE;
+ BOOL default_backend = TRUE;
RDPDR_PRINTER* device = NULL;
rdpPrinterDriver* driver = NULL;
- UINT error = CHANNEL_RC_OK;
+ UINT error = CHANNEL_RC_OK;
if (!pEntryPoints || !pEntryPoints->device)
return ERROR_INVALID_PARAMETER;
- device = (RDPDR_PRINTER*) pEntryPoints->device;
+ device = (RDPDR_PRINTER*)pEntryPoints->device;
name = device->Name;
driver_name = device->DriverName;
@@ -998,24 +985,24 @@ FREERDP_API DeviceServiceEntry
const char* backend = sep + 1;
*sep = '\0';
driver = printer_load_backend(backend);
- default_backend = FALSE;
+ default_backend = FALSE;
}
}
- if (!driver && default_backend)
- {
- const char* backend =
+ if (!driver && default_backend)
+ {
+ const char* backend =
#if defined(WITH_CUPS)
- "cups"
+ "cups"
#elif defined(_WIN32)
- "win"
+ "win"
#else
- ""
+ ""
#endif
- ;
+ ;
- driver = printer_load_backend(backend);
- }
+ driver = printer_load_backend(backend);
+ }
if (!driver)
{
@@ -1043,7 +1030,7 @@ FREERDP_API DeviceServiceEntry
if ((error = printer_register(pEntryPoints, printer)))
{
- WLog_ERR(TAG, "printer_register failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_register failed with error %" PRIu32 "!", error);
printer->ReleaseRef(printer);
goto fail;
}
@@ -1059,7 +1046,7 @@ FREERDP_API DeviceServiceEntry
if ((error = printer_register(pEntryPoints, printer)))
{
- WLog_ERR(TAG, "printer_register failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "printer_register failed with error %" PRIu32 "!", error);
break;
}
}
@@ -1067,7 +1054,7 @@ FREERDP_API DeviceServiceEntry
driver->ReleaseEnumPrinters(printers);
}
- fail:
+fail:
driver->ReleaseRef(driver);
return error;
diff --git a/channels/printer/client/win/printer_win.c b/channels/printer/client/win/printer_win.c
index 1be9365ed..5306f59fb 100644
--- a/channels/printer/client/win/printer_win.c
+++ b/channels/printer/client/win/printer_win.c
@@ -40,7 +40,10 @@
#ifdef WITH_DEBUG_WINPR
#define DEBUG_WINPR(...) WLog_DBG(PRINTER_TAG, __VA_ARGS__)
#else
-#define DEBUG_WINPR(...) do { } while (0)
+#define DEBUG_WINPR(...) \
+ do \
+ { \
+ } while (0)
#endif
typedef struct rdp_win_printer_driver rdpWinPrinterDriver;
@@ -88,8 +91,8 @@ static WCHAR* printer_win_get_printjob_name(size_t id)
return NULL;
rc = swprintf_s(str, len, L"FreeRDP Print %04d-%02d-%02d% 02d-%02d-%02d - Job %lu\0",
- t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
- t->tm_hour, t->tm_min, t->tm_sec, id);
+ t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
+ id);
return str;
}
@@ -113,14 +116,14 @@ static UINT printer_win_write_printjob(rdpPrintJob* printjob, const BYTE* data,
if (!printer)
return ERROR_BAD_ARGUMENTS;
- if(!WritePrinter(printer->hPrinter, pBuf, cbBuf, &pcWritten))
+ if (!WritePrinter(printer->hPrinter, pBuf, cbBuf, &pcWritten))
return ERROR_INTERNAL_ERROR;
return CHANNEL_RC_OK;
}
static void printer_win_close_printjob(rdpPrintJob* printjob)
{
- rdpWinPrintJob* win_printjob = (rdpWinPrintJob*) printjob;
+ rdpWinPrintJob* win_printjob = (rdpWinPrintJob*)printjob;
rdpWinPrinter* win_printer;
if (!printjob)
@@ -132,12 +135,10 @@ static void printer_win_close_printjob(rdpPrintJob* printjob)
if (!EndPagePrinter(win_printer->hPrinter))
{
-
}
if (!ClosePrinter(win_printer->hPrinter))
{
-
}
win_printer->printjob = NULL;
@@ -154,17 +155,17 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id)
if (win_printer->printjob != NULL)
return NULL;
- win_printjob = (rdpWinPrintJob*) calloc(1, sizeof(rdpWinPrintJob));
+ win_printjob = (rdpWinPrintJob*)calloc(1, sizeof(rdpWinPrintJob));
if (!win_printjob)
return NULL;
win_printjob->printjob.id = id;
win_printjob->printjob.printer = printer;
win_printjob->di.pDocName = printer_win_get_printjob_name(id);
- win_printjob->di.pDatatype= NULL;
+ win_printjob->di.pDatatype = NULL;
win_printjob->di.pOutputFile = NULL;
- win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE) &(win_printjob->di));
+ win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE) & (win_printjob->di));
if (!win_printjob->handle)
{
@@ -184,13 +185,13 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id)
win_printjob->printjob.Close = printer_win_close_printjob;
win_printer->printjob = win_printjob;
-
+
return &win_printjob->printjob;
}
static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id)
{
- rdpWinPrinter* win_printer = (rdpWinPrinter*) printer;
+ rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
if (!win_printer->printjob)
return NULL;
@@ -198,18 +199,18 @@ static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id)
if (win_printer->printjob->printjob.id != id)
return NULL;
- return (rdpPrintJob*) win_printer->printjob;
+ return (rdpPrintJob*)win_printer->printjob;
}
static void printer_win_free_printer(rdpPrinter* printer)
{
- rdpWinPrinter* win_printer = (rdpWinPrinter*) printer;
+ rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
if (win_printer->printjob)
- win_printer->printjob->printjob.Close((rdpPrintJob*) win_printer->printjob);
+ win_printer->printjob->printjob.Close((rdpPrintJob*)win_printer->printjob);
if (printer->backend)
- printer->backend->ReleaseRef(printer->backend);
+ printer->backend->ReleaseRef(printer->backend);
free(printer->name);
free(printer->driver);
@@ -232,15 +233,15 @@ static void printer_win_release_ref_printer(rdpPrinter* printer)
printer->references--;
}
-static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
- const WCHAR* name, const WCHAR* drivername, BOOL is_default)
+static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, const WCHAR* name,
+ const WCHAR* drivername, BOOL is_default)
{
rdpWinPrinter* win_printer;
DWORD needed = 0;
int status;
- PRINTER_INFO_2 *prninfo=NULL;
+ PRINTER_INFO_2* prninfo = NULL;
- win_printer = (rdpWinPrinter*) calloc(1, sizeof(rdpWinPrinter));
+ win_printer = (rdpWinPrinter*)calloc(1, sizeof(rdpWinPrinter));
if (!win_printer)
return NULL;
@@ -272,7 +273,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
}
/* How many memory should be allocated for printer data */
- GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, 0, &needed);
+ GetPrinter(win_printer->hPrinter, 2, (LPBYTE)prninfo, 0, &needed);
if (needed == 0)
{
free(win_printer->printer.name);
@@ -280,7 +281,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
return NULL;
}
- prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed);
+ prninfo = (PRINTER_INFO_2*)GlobalAlloc(GPTR, needed);
if (!prninfo)
{
free(win_printer->printer.name);
@@ -288,7 +289,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
return NULL;
}
- if (!GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, needed, &needed))
+ if (!GetPrinter(win_printer->hPrinter, 2, (LPBYTE)prninfo, needed, &needed))
{
GlobalFree(prninfo);
free(win_printer->printer.name);
@@ -297,9 +298,11 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
}
if (drivername)
- status = ConvertFromUnicode(CP_UTF8, 0, drivername, -1, &win_printer->printer.driver, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, drivername, -1, &win_printer->printer.driver, 0,
+ NULL, NULL);
else
- status = ConvertFromUnicode(CP_UTF8, 0, prninfo->pDriverName, -1, &win_printer->printer.driver, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, prninfo->pDriverName, -1,
+ &win_printer->printer.driver, 0, NULL, NULL);
if (!win_printer->printer.driver || (status <= 0))
{
GlobalFree(prninfo);
@@ -317,7 +320,7 @@ static void printer_win_release_enum_printers(rdpPrinter** printers)
{
rdpPrinter** cur = printers;
- while((cur != NULL) && ((*cur) != NULL))
+ while ((cur != NULL) && ((*cur) != NULL))
{
if ((*cur)->ReleaseRef)
(*cur)->ReleaseRef(*cur);
@@ -335,21 +338,21 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
DWORD needed, returned;
/* find required size for the buffer */
- EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &returned);
-
+ EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed,
+ &returned);
/* allocate array of PRINTER_INFO structures */
- prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed);
+ prninfo = (PRINTER_INFO_2*)GlobalAlloc(GPTR, needed);
if (!prninfo)
return NULL;
-
- /* call again */
- if (!EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE) prninfo, needed, &needed, &returned))
- {
+ /* call again */
+ if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE)prninfo,
+ needed, &needed, &returned))
+ {
}
- printers = (rdpPrinter**) calloc((returned + 1), sizeof(rdpPrinter*));
+ printers = (rdpPrinter**)calloc((returned + 1), sizeof(rdpPrinter*));
if (!printers)
{
GlobalFree(prninfo);
@@ -358,11 +361,11 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
num_printers = 0;
- for (i = 0; i < (int) returned; i++)
+ for (i = 0; i < (int)returned; i++)
{
rdpPrinter* current = printers[num_printers];
- current = printer_win_new_printer((rdpWinPrinterDriver*)driver,
- prninfo[i].pPrinterName, prninfo[i].pDriverName, 0);
+ current = printer_win_new_printer((rdpWinPrinterDriver*)driver, prninfo[i].pPrinterName,
+ prninfo[i].pDriverName, 0);
if (!current)
{
printer_win_release_enum_printers(printers);
@@ -376,14 +379,14 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
return printers;
}
-static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver,
- const char* name, const char* driverName)
+static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver, const char* name,
+ const char* driverName)
{
WCHAR* driverNameW = NULL;
WCHAR* nameW = NULL;
rdpWinPrinterDriver* win_driver = (rdpWinPrinterDriver*)driver;
- rdpPrinter *myPrinter = NULL;
-
+ rdpPrinter* myPrinter = NULL;
+
if (name)
{
ConvertToUnicode(CP_UTF8, 0, name, -1, &nameW, 0);
@@ -398,17 +401,16 @@ static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver,
}
myPrinter = printer_win_new_printer(win_driver, nameW, driverNameW,
- win_driver->id_sequence == 1 ? TRUE : FALSE);
+ win_driver->id_sequence == 1 ? TRUE : FALSE);
free(driverNameW);
free(nameW);
return myPrinter;
}
-
static void printer_win_add_ref_driver(rdpPrinterDriver* driver)
{
- rdpWinPrinterDriver* win = (rdpWinPrinterDriver*) driver;
+ rdpWinPrinterDriver* win = (rdpWinPrinterDriver*)driver;
if (win)
win->references++;
}
@@ -418,7 +420,7 @@ static rdpWinPrinterDriver* win_driver = NULL;
static void printer_win_release_ref_driver(rdpPrinterDriver* driver)
{
- rdpWinPrinterDriver* win = (rdpWinPrinterDriver*) driver;
+ rdpWinPrinterDriver* win = (rdpWinPrinterDriver*)driver;
if (win->references <= 1)
{
free(win);
@@ -429,14 +431,14 @@ static void printer_win_release_ref_driver(rdpPrinterDriver* driver)
}
#ifdef BUILTIN_CHANNELS
-rdpPrinterDriver *win_freerdp_printer_client_subsystem_entry(void)
+rdpPrinterDriver* win_freerdp_printer_client_subsystem_entry(void)
#else
-FREERDP_API rdpPrinterDriver *freerdp_printer_client_subsystem_entry(void)
+FREERDP_API rdpPrinterDriver* freerdp_printer_client_subsystem_entry(void)
#endif
{
if (!win_driver)
{
- win_driver = (rdpWinPrinterDriver*) calloc(1, sizeof(rdpWinPrinterDriver));
+ win_driver = (rdpWinPrinterDriver*)calloc(1, sizeof(rdpWinPrinterDriver));
if (!win_driver)
return NULL;
@@ -454,7 +456,3 @@ FREERDP_API rdpPrinterDriver *freerdp_printer_client_subsystem_entry(void)
return &win_driver->driver;
}
-
-
-
-
diff --git a/channels/printer/printer.h b/channels/printer/printer.h
index 5ce8f5e45..ae0902dff 100644
--- a/channels/printer/printer.h
+++ b/channels/printer/printer.h
@@ -21,17 +21,16 @@
#define FREERDP_CHANNEL_PRINTER_PRINTER_H
/* SERVER_PRINTER_CACHE_EVENT.cachedata */
-#define RDPDR_ADD_PRINTER_EVENT 0x00000001
-#define RDPDR_UPDATE_PRINTER_EVENT 0x00000002
-#define RDPDR_DELETE_PRINTER_EVENT 0x00000003
-#define RDPDR_RENAME_PRINTER_EVENT 0x00000004
+#define RDPDR_ADD_PRINTER_EVENT 0x00000001
+#define RDPDR_UPDATE_PRINTER_EVENT 0x00000002
+#define RDPDR_DELETE_PRINTER_EVENT 0x00000003
+#define RDPDR_RENAME_PRINTER_EVENT 0x00000004
/* DR_PRN_DEVICE_ANNOUNCE.Flags */
-#define RDPDR_PRINTER_ANNOUNCE_FLAG_ASCII 0x00000001
-#define RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER 0x00000002
-#define RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER 0x00000004
-#define RDPDR_PRINTER_ANNOUNCE_FLAG_TSPRINTER 0x00000008
-#define RDPDR_PRINTER_ANNOUNCE_FLAG_XPSFORMAT 0x00000010
-
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_ASCII 0x00000001
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER 0x00000002
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER 0x00000004
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_TSPRINTER 0x00000008
+#define RDPDR_PRINTER_ANNOUNCE_FLAG_XPSFORMAT 0x00000010
#endif /* FREERDP_CHANNEL_PRINTER_PRINTER_H */
diff --git a/channels/rail/client/rail_main.c b/channels/rail/client/rail_main.c
index fb9add9d9..ce58070f0 100644
--- a/channels/rail/client/rail_main.c
+++ b/channels/rail/client/rail_main.c
@@ -42,7 +42,7 @@ RailClientContext* rail_get_client_interface(railPlugin* rail)
if (!rail)
return NULL;
- pInterface = (RailClientContext*) rail->channelEntryPoints.pInterface;
+ pInterface = (RailClientContext*)rail->channelEntryPoints.pInterface;
return pInterface;
}
@@ -61,13 +61,13 @@ static UINT rail_send(railPlugin* rail, wStream* s)
return CHANNEL_RC_BAD_INIT_HANDLE;
}
- status = rail->channelEntryPoints.pVirtualChannelWriteEx(rail->InitHandle, rail->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
+ status = rail->channelEntryPoints.pVirtualChannelWriteEx(
+ rail->InitHandle, rail->OpenHandle, Stream_Buffer(s), (UINT32)Stream_GetPosition(s), s);
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -109,8 +109,7 @@ UINT rail_send_channel_data(railPlugin* rail, wStream* src)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_client_execute(RailClientContext* context,
- const RAIL_EXEC_ORDER* exec)
+static UINT rail_client_execute(RailClientContext* context, const RAIL_EXEC_ORDER* exec)
{
char* exeOrFile;
UINT error;
@@ -123,7 +122,7 @@ static UINT rail_client_execute(RailClientContext* context,
if (!context || !exec)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
exeOrFile = exec->RemoteApplicationProgram;
flags = exec->flags;
@@ -151,15 +150,14 @@ static UINT rail_client_execute(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_client_activate(RailClientContext* context,
- const RAIL_ACTIVATE_ORDER* activate)
+static UINT rail_client_activate(RailClientContext* context, const RAIL_ACTIVATE_ORDER* activate)
{
railPlugin* rail;
if (!context || !activate)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_activate_order(rail, activate);
}
@@ -168,8 +166,7 @@ static UINT rail_client_activate(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_send_client_sysparam(RailClientContext* context,
- RAIL_SYSPARAM_ORDER* sysparam)
+static UINT rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
{
wStream* s;
size_t length = RAIL_SYSPARAM_ORDER_LENGTH;
@@ -179,7 +176,7 @@ static UINT rail_send_client_sysparam(RailClientContext* context,
if (!context || !sysparam)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
switch (sysparam->param)
{
@@ -224,14 +221,14 @@ static UINT rail_send_client_sysparam(RailClientContext* context,
if ((error = rail_write_client_sysparam_order(rail, s, sysparam)))
{
- WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %" PRIu32 "!", error);
Stream_Free(s, TRUE);
return error;
}
if ((error = rail_send_pdu(rail, s, TS_RAIL_ORDER_SYSPARAM)))
{
- WLog_ERR(TAG, "rail_send_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_pdu failed with error %" PRIu32 "!", error);
}
Stream_Free(s, TRUE);
@@ -260,7 +257,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -271,7 +268,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -282,7 +279,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -293,7 +290,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -304,7 +301,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -315,7 +312,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -326,7 +323,7 @@ static UINT rail_client_system_param(RailClientContext* context,
if ((error = rail_send_client_sysparam(context, &sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -361,7 +358,7 @@ static UINT rail_client_system_command(RailClientContext* context,
if (!context || !syscommand)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_syscommand_order(rail, syscommand);
}
@@ -370,15 +367,14 @@ static UINT rail_client_system_command(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_client_handshake(RailClientContext* context,
- const RAIL_HANDSHAKE_ORDER* handshake)
+static UINT rail_client_handshake(RailClientContext* context, const RAIL_HANDSHAKE_ORDER* handshake)
{
railPlugin* rail;
if (!context || !handshake)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_handshake_order(rail, handshake);
}
@@ -387,8 +383,7 @@ static UINT rail_client_handshake(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_server_handshake(RailClientContext* context,
- const RAIL_HANDSHAKE_ORDER* handshake)
+static UINT rail_server_handshake(RailClientContext* context, const RAIL_HANDSHAKE_ORDER* handshake)
{
if (!context || !handshake)
return ERROR_INVALID_PARAMETER;
@@ -409,7 +404,7 @@ static UINT rail_server_handshake_ex(RailClientContext* context,
if (!context || !handshakeEx)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return CHANNEL_RC_OK;
}
@@ -426,7 +421,7 @@ static UINT rail_client_notify_event(RailClientContext* context,
if (!context || !notifyEvent)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_notify_event_order(rail, notifyEvent);
}
@@ -443,7 +438,7 @@ static UINT rail_client_window_move(RailClientContext* context,
if (!context || !windowMove)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_window_move_order(rail, windowMove);
}
@@ -488,7 +483,7 @@ static UINT rail_client_information(RailClientContext* context,
if (!context || !clientStatus)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_status_order(rail, clientStatus);
}
@@ -497,15 +492,14 @@ static UINT rail_client_information(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_client_system_menu(RailClientContext* context,
- const RAIL_SYSMENU_ORDER* sysmenu)
+static UINT rail_client_system_menu(RailClientContext* context, const RAIL_SYSMENU_ORDER* sysmenu)
{
railPlugin* rail;
if (!context || !sysmenu)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_sysmenu_order(rail, sysmenu);
}
@@ -515,14 +509,14 @@ static UINT rail_client_system_menu(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_client_language_bar_info(RailClientContext* context,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
railPlugin* rail;
if (!context || !langBarInfo)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_langbar_info_order(rail, langBarInfo);
}
@@ -532,7 +526,7 @@ static UINT rail_client_language_bar_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_server_language_bar_info(RailClientContext* context,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
if (!context || !langBarInfo)
return ERROR_INVALID_PARAMETER;
@@ -541,14 +535,14 @@ static UINT rail_server_language_bar_info(RailClientContext* context,
}
static UINT rail_client_language_ime_info(RailClientContext* context,
- const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
+ const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
{
railPlugin* rail;
if (!context || !langImeInfo)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_languageime_info_order(rail, langImeInfo);
}
@@ -572,38 +566,36 @@ static UINT rail_server_execute_result(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_client_get_appid_request(RailClientContext* context,
- const RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
+ const RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
{
railPlugin* rail;
if (!context || !getAppIdReq || !context->handle)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_get_appid_req_order(rail, getAppIdReq);
}
-static UINT rail_client_cloak(RailClientContext* context,
- const RAIL_CLOAK* cloak)
+static UINT rail_client_cloak(RailClientContext* context, const RAIL_CLOAK* cloak)
{
railPlugin* rail;
if (!context || !cloak || !context->handle)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_order_cloak_order(rail, cloak);
}
-static UINT rail_client_snap_arrange(RailClientContext* context,
- const RAIL_SNAP_ARRANGE* snap)
+static UINT rail_client_snap_arrange(RailClientContext* context, const RAIL_SNAP_ARRANGE* snap)
{
railPlugin* rail;
if (!context || !snap || !context->handle)
return ERROR_INVALID_PARAMETER;
- rail = (railPlugin*) context->handle;
+ rail = (railPlugin*)context->handle;
return rail_send_client_order_snap_arrange_order(rail, snap);
}
@@ -613,7 +605,7 @@ static UINT rail_client_snap_arrange(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_server_get_appid_response(RailClientContext* context,
- const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+ const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
if (!context || !getAppIdResp)
return ERROR_INVALID_PARAMETER;
@@ -626,8 +618,9 @@ static UINT rail_server_get_appid_response(RailClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT rail_virtual_channel_event_data_received(railPlugin* rail, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -652,7 +645,7 @@ static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
data_in = rail->data_in;
- if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
+ if (!Stream_EnsureRemainingCapacity(data_in, (int)dataLength))
{
WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
return CHANNEL_RC_NO_MEMORY;
@@ -664,7 +657,7 @@ static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
{
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
{
- WLog_ERR(TAG, "rail_plugin_process_received: read error");
+ WLog_ERR(TAG, "rail_plugin_process_received: read error");
return ERROR_INTERNAL_ERROR;
}
@@ -672,7 +665,7 @@ static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(rail->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(rail->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -683,11 +676,12 @@ static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
}
static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- railPlugin* rail = (railPlugin*) lpUserParam;
+ railPlugin* rail = (railPlugin*)lpUserParam;
if (!rail || (rail->OpenHandle != openHandle))
{
@@ -699,8 +693,9 @@ static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWO
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = rail_virtual_channel_event_data_received(rail, pData, dataLength,
- totalLength, dataFlags)))
- WLog_ERR(TAG, "rail_virtual_channel_event_data_received failed with error %"PRIu32"!",
+ totalLength, dataFlags)))
+ WLog_ERR(TAG,
+ "rail_virtual_channel_event_data_received failed with error %" PRIu32 "!",
error);
break;
@@ -711,7 +706,7 @@ static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWO
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
@@ -728,7 +723,7 @@ static DWORD WINAPI rail_virtual_channel_client_thread(LPVOID arg)
{
wStream* data;
wMessage message;
- railPlugin* rail = (railPlugin*) arg;
+ railPlugin* rail = (railPlugin*)arg;
UINT error = CHANNEL_RC_OK;
while (1)
@@ -752,13 +747,13 @@ static DWORD WINAPI rail_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
error = rail_order_recv(rail, data);
Stream_Free(data, TRUE);
if (error)
{
- WLog_ERR(TAG, "rail_order_recv failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_order_recv failed with error %" PRIu32 "!", error);
break;
}
}
@@ -777,16 +772,16 @@ static DWORD WINAPI rail_virtual_channel_client_thread(LPVOID arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
- UINT32 dataLength)
+static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, UINT32 dataLength)
{
UINT status;
- status = rail->channelEntryPoints.pVirtualChannelOpenEx(rail->InitHandle,
- &rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event_ex);
+ status = rail->channelEntryPoints.pVirtualChannelOpenEx(rail->InitHandle, &rail->OpenHandle,
+ rail->channelDef.name,
+ rail_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -799,9 +794,8 @@ static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
return CHANNEL_RC_NO_MEMORY;
}
- if (!(rail->thread = CreateThread(NULL, 0,
- rail_virtual_channel_client_thread, (void*) rail, 0,
- NULL)))
+ if (!(rail->thread =
+ CreateThread(NULL, 0, rail_virtual_channel_client_thread, (void*)rail, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
MessageQueue_Free(rail->queue);
@@ -824,11 +818,11 @@ static UINT rail_virtual_channel_event_disconnected(railPlugin* rail)
if (rail->OpenHandle == 0)
return CHANNEL_RC_OK;
- if (MessageQueue_PostQuit(rail->queue, 0)
- && (WaitForSingleObject(rail->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(rail->queue, 0) &&
+ (WaitForSingleObject(rail->thread, INFINITE) == WAIT_FAILED))
{
rc = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", rc);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
}
@@ -840,8 +834,8 @@ static UINT rail_virtual_channel_event_disconnected(railPlugin* rail)
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
return rc;
}
@@ -864,14 +858,14 @@ static void rail_virtual_channel_event_terminated(railPlugin* rail)
}
static VOID VCAPITYPE rail_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData, UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- railPlugin* rail = (railPlugin*) lpUserParam;
+ railPlugin* rail = (railPlugin*)lpUserParam;
if (!rail || (rail->InitHandle != pInitHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
@@ -879,14 +873,15 @@ static VOID VCAPITYPE rail_virtual_channel_init_event_ex(LPVOID lpUserParam, LPV
{
case CHANNEL_EVENT_CONNECTED:
if ((error = rail_virtual_channel_event_connected(rail, pData, dataLength)))
- WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %" PRIu32 "!",
error);
break;
case CHANNEL_EVENT_DISCONNECTED:
if ((error = rail_virtual_channel_event_disconnected(rail)))
- WLog_ERR(TAG, "rail_virtual_channel_event_disconnected failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rail_virtual_channel_event_disconnected failed with error %" PRIu32 "!",
error);
break;
@@ -902,11 +897,12 @@ static VOID VCAPITYPE rail_virtual_channel_init_event_ex(LPVOID lpUserParam, LPV
}
if (error && rail->rdpcontext)
- setChannelError(rail->rdpcontext, error, "rail_virtual_channel_init_event_ex reported an error");
+ setChannelError(rail->rdpcontext, error,
+ "rail_virtual_channel_init_event_ex reported an error");
}
/* rail is always built-in */
-#define VirtualChannelEntryEx rail_VirtualChannelEntryEx
+#define VirtualChannelEntryEx rail_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
@@ -915,7 +911,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
RailClientContext* context = NULL;
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
BOOL isFreerdp = FALSE;
- rail = (railPlugin*) calloc(1, sizeof(railPlugin));
+ rail = (railPlugin*)calloc(1, sizeof(railPlugin));
if (!rail)
{
@@ -923,18 +919,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- rail->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP |
- CHANNEL_OPTION_SHOW_PROTOCOL;
+ rail->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
+ CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
sprintf_s(rail->channelDef.name, ARRAYSIZE(rail->channelDef.name), "rail");
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
- context = (RailClientContext*) calloc(1, sizeof(RailClientContext));
+ context = (RailClientContext*)calloc(1, sizeof(RailClientContext));
if (!context)
{
@@ -943,7 +936,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- context->handle = (void*) rail;
+ context->handle = (void*)rail;
context->custom = NULL;
context->ClientExecute = rail_client_execute;
context->ClientActivate = rail_client_activate;
@@ -974,17 +967,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
rail->log = WLog_Get("com.freerdp.channels.rail.client");
WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntryEx");
- CopyMemory(&(rail->channelEntryPoints), pEntryPoints,
- sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
+ CopyMemory(&(rail->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
rail->InitHandle = pInitHandle;
- rc = rail->channelEntryPoints.pVirtualChannelInitEx(rail, context, pInitHandle,
- &rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- rail_virtual_channel_init_event_ex);
+ rc = rail->channelEntryPoints.pVirtualChannelInitEx(
+ rail, context, pInitHandle, &rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ rail_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "failed with %s [%08" PRIX32 "]", WTSErrorToString(rc), rc);
goto error_out;
}
diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c
index 72fd99e87..309654287 100644
--- a/channels/rail/client/rail_orders.c
+++ b/channels/rail/client/rail_orders.c
@@ -48,7 +48,7 @@ static UINT rail_write_unicode_string(wStream* s, const RAIL_UNICODE_STRING* uni
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
+ Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
return CHANNEL_RC_OK;
}
@@ -65,7 +65,7 @@ static UINT rail_write_unicode_string_value(wStream* s, const RAIL_UNICODE_STRIN
if (!s || !unicode_string)
return ERROR_INVALID_PARAMETER;
- length = unicode_string->length;
+ length = unicode_string->length;
if (length > 0)
{
@@ -93,12 +93,13 @@ UINT rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
if (!rail || !s)
return ERROR_INVALID_PARAMETER;
- orderLength = (UINT16) Stream_GetPosition(s);
+ orderLength = (UINT16)Stream_GetPosition(s);
Stream_SetPosition(s, 0);
rail_write_pdu_header(s, orderType, orderLength);
Stream_SetPosition(s, orderLength);
- WLog_Print(rail->log, WLOG_DEBUG, "Sending %s PDU, length: %"PRIu16"",
- RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
+ WLog_Print(rail->log, WLOG_DEBUG, "Sending %s PDU, length: %" PRIu16 "",
+ RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)],
+ orderLength);
return rail_send_channel_data(rail, s);
}
@@ -116,7 +117,7 @@ static UINT rail_write_high_contrast(wStream* s, const RAIL_HIGH_CONTRAST* highC
colorSchemeLength = highContrast->colorScheme.length + 2;
Stream_Write_UINT32(s, highContrast->flags); /* flags (4 bytes) */
- Stream_Write_UINT32(s, colorSchemeLength); /* colorSchemeLength (4 bytes) */
+ Stream_Write_UINT32(s, colorSchemeLength); /* colorSchemeLength (4 bytes) */
return rail_write_unicode_string(s, &highContrast->colorScheme); /* colorScheme */
}
@@ -149,11 +150,13 @@ static UINT rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDE
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, execResult->flags); /* flags (2 bytes) */
+ Stream_Read_UINT16(s, execResult->flags); /* flags (2 bytes) */
Stream_Read_UINT16(s, execResult->execResult); /* execResult (2 bytes) */
- Stream_Read_UINT32(s, execResult->rawResult); /* rawResult (4 bytes) */
- Stream_Seek_UINT16(s); /* padding (2 bytes) */
- return rail_read_unicode_string(s, &execResult->exeOrFile) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR; /* exeOrFile */
+ Stream_Read_UINT32(s, execResult->rawResult); /* rawResult (4 bytes) */
+ Stream_Seek_UINT16(s); /* padding (2 bytes) */
+ return rail_read_unicode_string(s, &execResult->exeOrFile)
+ ? CHANNEL_RC_OK
+ : ERROR_INTERNAL_ERROR; /* exeOrFile */
}
/**
@@ -175,7 +178,7 @@ static UINT rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sys
}
Stream_Read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */
- Stream_Read_UINT8(s, body); /* body (1 byte) */
+ Stream_Read_UINT8(s, body); /* body (1 byte) */
switch (sysparam->param)
{
@@ -210,14 +213,14 @@ static UINT rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */
- Stream_Read_INT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */
- Stream_Read_INT16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */
- Stream_Read_INT16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */
- Stream_Read_INT16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */
- Stream_Read_INT16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */
+ Stream_Read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */
Stream_Read_INT16(s, minmaxinfo->minTrackHeight); /* minTrackHeight (2 bytes) */
- Stream_Read_INT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */
+ Stream_Read_INT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */
Stream_Read_INT16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -228,7 +231,7 @@ static UINT rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_read_server_localmovesize_order(wStream* s,
- RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+ RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
UINT16 isMoveSizeStart;
@@ -242,11 +245,11 @@ static UINT rail_read_server_localmovesize_order(wStream* s,
}
Stream_Read_UINT32(s, localMoveSize->windowId); /* windowId (4 bytes) */
- Stream_Read_UINT16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */
+ Stream_Read_UINT16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */
localMoveSize->isMoveSizeStart = (isMoveSizeStart != 0) ? TRUE : FALSE;
Stream_Read_UINT16(s, localMoveSize->moveSizeType); /* moveSizeType (2 bytes) */
- Stream_Read_INT16(s, localMoveSize->posX); /* posX (2 bytes) */
- Stream_Read_INT16(s, localMoveSize->posY); /* posY (2 bytes) */
+ Stream_Read_INT16(s, localMoveSize->posX); /* posX (2 bytes) */
+ Stream_Read_INT16(s, localMoveSize->posY); /* posY (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -256,7 +259,7 @@ static UINT rail_read_server_localmovesize_order(wStream* s,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_read_server_get_appid_resp_order(wStream* s,
- RAIL_GET_APPID_RESP_ORDER* getAppidResp)
+ RAIL_GET_APPID_RESP_ORDER* getAppidResp)
{
if (!s || !getAppidResp)
return ERROR_INVALID_PARAMETER;
@@ -268,7 +271,8 @@ static UINT rail_read_server_get_appid_resp_order(wStream* s,
}
Stream_Read_UINT32(s, getAppidResp->windowId); /* windowId (4 bytes) */
- Stream_Read(s, (BYTE*) & (getAppidResp->applicationId), 520); /* applicationId (260 UNICODE chars) */
+ Stream_Read(s, (BYTE*)&(getAppidResp->applicationId),
+ 520); /* applicationId (260 UNICODE chars) */
return CHANNEL_RC_OK;
}
@@ -307,8 +311,9 @@ static UINT rail_write_client_status_order(wStream* s, const RAIL_CLIENT_STATUS_
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rail_write_client_exec_order(wStream* s, UINT16 flags,
- const RAIL_UNICODE_STRING* exeOrFile, const RAIL_UNICODE_STRING* workingDir,
- const RAIL_UNICODE_STRING* arguments)
+ const RAIL_UNICODE_STRING* exeOrFile,
+ const RAIL_UNICODE_STRING* workingDir,
+ const RAIL_UNICODE_STRING* arguments)
{
UINT error;
@@ -317,35 +322,35 @@ static UINT rail_write_client_exec_order(wStream* s, UINT16 flags,
/* [MS-RDPERP] 2.2.2.3.1 Client Execute PDU (TS_RAIL_ORDER_EXEC)
* Check argument limits */
- if ((exeOrFile->length > 520) || (workingDir->length > 520) ||
- (arguments->length > 16000))
+ if ((exeOrFile->length > 520) || (workingDir->length > 520) || (arguments->length > 16000))
{
WLog_ERR(TAG,
- "TS_RAIL_ORDER_EXEC argument limits exceeded: ExeOrFile=%"PRIu16" [max=520], WorkingDir=%"PRIu16" [max=520], Arguments=%"PRIu16" [max=16000]",
+ "TS_RAIL_ORDER_EXEC argument limits exceeded: ExeOrFile=%" PRIu16
+ " [max=520], WorkingDir=%" PRIu16 " [max=520], Arguments=%" PRIu16 " [max=16000]",
exeOrFile->length, workingDir->length, arguments->length);
return ERROR_BAD_ARGUMENTS;
}
- Stream_Write_UINT16(s, flags); /* flags (2 bytes) */
- Stream_Write_UINT16(s, exeOrFile->length); /* exeOrFileLength (2 bytes) */
+ Stream_Write_UINT16(s, flags); /* flags (2 bytes) */
+ Stream_Write_UINT16(s, exeOrFile->length); /* exeOrFileLength (2 bytes) */
Stream_Write_UINT16(s, workingDir->length); /* workingDirLength (2 bytes) */
- Stream_Write_UINT16(s, arguments->length); /* argumentsLength (2 bytes) */
+ Stream_Write_UINT16(s, arguments->length); /* argumentsLength (2 bytes) */
if ((error = rail_write_unicode_string_value(s, exeOrFile)))
{
- WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error);
return error;
}
if ((error = rail_write_unicode_string_value(s, workingDir)))
{
- WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error);
return error;
}
if ((error = rail_write_unicode_string_value(s, arguments)))
{
- WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rail_write_unicode_string_value failed with error %" PRIu32 "", error);
return error;
}
@@ -391,23 +396,23 @@ UINT rail_write_client_sysparam_order(railPlugin* rail, wStream* s,
break;
case SPI_SET_WORK_AREA:
- Stream_Write_UINT16(s, sysparam->workArea.left); /* left (2 bytes) */
- Stream_Write_UINT16(s, sysparam->workArea.top); /* top (2 bytes) */
- Stream_Write_UINT16(s, sysparam->workArea.right); /* right (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->workArea.left); /* left (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->workArea.top); /* top (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->workArea.right); /* right (2 bytes) */
Stream_Write_UINT16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */
break;
case SPI_DISPLAY_CHANGE:
- Stream_Write_UINT16(s, sysparam->displayChange.left); /* left (2 bytes) */
- Stream_Write_UINT16(s, sysparam->displayChange.top); /* top (2 bytes) */
- Stream_Write_UINT16(s, sysparam->displayChange.right); /* right (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->displayChange.left); /* left (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->displayChange.top); /* top (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->displayChange.right); /* right (2 bytes) */
Stream_Write_UINT16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */
break;
case SPI_TASKBAR_POS:
- Stream_Write_UINT16(s, sysparam->taskbarPos.left); /* left (2 bytes) */
- Stream_Write_UINT16(s, sysparam->taskbarPos.top); /* top (2 bytes) */
- Stream_Write_UINT16(s, sysparam->taskbarPos.right); /* right (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->taskbarPos.left); /* left (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->taskbarPos.top); /* top (2 bytes) */
+ Stream_Write_UINT16(s, sysparam->taskbarPos.right); /* right (2 bytes) */
Stream_Write_UINT16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */
break;
@@ -472,8 +477,8 @@ static UINT rail_write_client_sysmenu_order(wStream* s, const RAIL_SYSMENU_ORDER
return ERROR_INVALID_PARAMETER;
Stream_Write_UINT32(s, sysmenu->windowId); /* windowId (4 bytes) */
- Stream_Write_INT16(s, sysmenu->left); /* left (2 bytes) */
- Stream_Write_INT16(s, sysmenu->top); /* top (2 bytes) */
+ Stream_Write_INT16(s, sysmenu->left); /* left (2 bytes) */
+ Stream_Write_INT16(s, sysmenu->top); /* top (2 bytes) */
return ERROR_SUCCESS;
}
@@ -483,38 +488,38 @@ static UINT rail_write_client_syscommand_order(wStream* s, const RAIL_SYSCOMMAND
return ERROR_INVALID_PARAMETER;
Stream_Write_UINT32(s, syscommand->windowId); /* windowId (4 bytes) */
- Stream_Write_UINT16(s, syscommand->command); /* command (2 bytes) */
+ Stream_Write_UINT16(s, syscommand->command); /* command (2 bytes) */
return ERROR_SUCCESS;
}
static UINT rail_write_client_notify_event_order(wStream* s,
- const RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
+ const RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
{
if (!s || !notifyEvent)
return ERROR_INVALID_PARAMETER;
- Stream_Write_UINT32(s, notifyEvent->windowId); /* windowId (4 bytes) */
+ Stream_Write_UINT32(s, notifyEvent->windowId); /* windowId (4 bytes) */
Stream_Write_UINT32(s, notifyEvent->notifyIconId); /* notifyIconId (4 bytes) */
- Stream_Write_UINT32(s, notifyEvent->message); /* notifyIconId (4 bytes) */
+ Stream_Write_UINT32(s, notifyEvent->message); /* notifyIconId (4 bytes) */
return ERROR_SUCCESS;
}
static UINT rail_write_client_window_move_order(wStream* s,
- const RAIL_WINDOW_MOVE_ORDER* windowMove)
+ const RAIL_WINDOW_MOVE_ORDER* windowMove)
{
if (!s || !windowMove)
return ERROR_INVALID_PARAMETER;
Stream_Write_UINT32(s, windowMove->windowId); /* windowId (4 bytes) */
- Stream_Write_INT16(s, windowMove->left); /* left (2 bytes) */
- Stream_Write_INT16(s, windowMove->top); /* top (2 bytes) */
- Stream_Write_INT16(s, windowMove->right); /* right (2 bytes) */
- Stream_Write_INT16(s, windowMove->bottom); /* bottom (2 bytes) */
+ Stream_Write_INT16(s, windowMove->left); /* left (2 bytes) */
+ Stream_Write_INT16(s, windowMove->top); /* top (2 bytes) */
+ Stream_Write_INT16(s, windowMove->right); /* right (2 bytes) */
+ Stream_Write_INT16(s, windowMove->bottom); /* bottom (2 bytes) */
return ERROR_SUCCESS;
}
static UINT rail_write_client_get_appid_req_order(wStream* s,
- const RAIL_GET_APPID_REQ_ORDER* getAppidReq)
+ const RAIL_GET_APPID_REQ_ORDER* getAppidReq)
{
if (!s || !getAppidReq)
return ERROR_INVALID_PARAMETER;
@@ -533,7 +538,7 @@ static UINT rail_write_langbar_info_order(wStream* s, const RAIL_LANGBAR_INFO_OR
}
static UINT rail_write_languageime_info_order(wStream* s,
- const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
+ const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
{
if (!s || !langImeInfo)
return ERROR_INVALID_PARAMETER;
@@ -563,7 +568,7 @@ static UINT rail_recv_handshake_order(railPlugin* rail, wStream* s)
if ((error = rail_read_handshake_order(s, &serverHandshake)))
{
- WLog_ERR(TAG, "rail_read_handshake_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_handshake_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -581,7 +586,7 @@ static UINT rail_recv_handshake_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerHandshake, error, context, &serverHandshake);
if (error)
- WLog_ERR(TAG, "context.ServerHandshake failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerHandshake failed with error %" PRIu32 "", error);
}
return error;
@@ -624,7 +629,7 @@ static UINT rail_recv_handshake_ex_order(railPlugin* rail, wStream* s)
if ((error = rail_read_handshake_ex_order(s, &serverHandshake)))
{
- WLog_ERR(TAG, "rail_read_handshake_ex_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_handshake_ex_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -643,7 +648,7 @@ static UINT rail_recv_handshake_ex_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerHandshakeEx, error, context, &serverHandshake);
if (error)
- WLog_ERR(TAG, "context.ServerHandshakeEx failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerHandshakeEx failed with error %" PRIu32 "", error);
}
return error;
@@ -665,7 +670,7 @@ static UINT rail_recv_exec_result_order(railPlugin* rail, wStream* s)
if ((error = rail_read_server_exec_result_order(s, &execResult)))
{
- WLog_ERR(TAG, "rail_read_server_exec_result_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_server_exec_result_order failed with error %" PRIu32 "!", error);
goto fail;
}
@@ -674,7 +679,7 @@ static UINT rail_recv_exec_result_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerExecuteResult, error, context, &execResult);
if (error)
- WLog_ERR(TAG, "context.ServerExecuteResult failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerExecuteResult failed with error %" PRIu32 "", error);
}
fail:
@@ -698,7 +703,7 @@ static UINT rail_recv_server_sysparam_order(railPlugin* rail, wStream* s)
if ((error = rail_read_server_sysparam_order(s, &sysparam)))
{
- WLog_ERR(TAG, "rail_read_server_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_server_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -707,7 +712,7 @@ static UINT rail_recv_server_sysparam_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerSystemParam, error, context, &sysparam);
if (error)
- WLog_ERR(TAG, "context.ServerSystemParam failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerSystemParam failed with error %" PRIu32 "", error);
}
return error;
@@ -729,7 +734,7 @@ static UINT rail_recv_server_minmaxinfo_order(railPlugin* rail, wStream* s)
if ((error = rail_read_server_minmaxinfo_order(s, &minMaxInfo)))
{
- WLog_ERR(TAG, "rail_read_server_minmaxinfo_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_server_minmaxinfo_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -738,7 +743,7 @@ static UINT rail_recv_server_minmaxinfo_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerMinMaxInfo, error, context, &minMaxInfo);
if (error)
- WLog_ERR(TAG, "context.ServerMinMaxInfo failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerMinMaxInfo failed with error %" PRIu32 "", error);
}
return error;
@@ -760,7 +765,7 @@ static UINT rail_recv_server_localmovesize_order(railPlugin* rail, wStream* s)
if ((error = rail_read_server_localmovesize_order(s, &localMoveSize)))
{
- WLog_ERR(TAG, "rail_read_server_localmovesize_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_server_localmovesize_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -769,7 +774,7 @@ static UINT rail_recv_server_localmovesize_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerLocalMoveSize, error, context, &localMoveSize);
if (error)
- WLog_ERR(TAG, "context.ServerLocalMoveSize failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerLocalMoveSize failed with error %" PRIu32 "", error);
}
return error;
@@ -791,7 +796,8 @@ static UINT rail_recv_server_get_appid_resp_order(railPlugin* rail, wStream* s)
if ((error = rail_read_server_get_appid_resp_order(s, &getAppIdResp)))
{
- WLog_ERR(TAG, "rail_read_server_get_appid_resp_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_server_get_appid_resp_order failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -800,7 +806,7 @@ static UINT rail_recv_server_get_appid_resp_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerGetAppIdResponse, error, context, &getAppIdResp);
if (error)
- WLog_ERR(TAG, "context.ServerGetAppIdResponse failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerGetAppIdResponse failed with error %" PRIu32 "", error);
}
return error;
@@ -825,7 +831,7 @@ static UINT rail_recv_langbar_info_order(railPlugin* rail, wStream* s)
if ((error = rail_read_langbar_info_order(s, &langBarInfo)))
{
- WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -834,13 +840,12 @@ static UINT rail_recv_langbar_info_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerLanguageBarInfo, error, context, &langBarInfo);
if (error)
- WLog_ERR(TAG, "context.ServerLanguageBarInfo failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerLanguageBarInfo failed with error %" PRIu32 "", error);
}
return error;
}
-
static UINT rail_read_taskbar_info_order(wStream* s, RAIL_TASKBAR_INFO_ORDER* taskbarInfo)
{
if (!s || !taskbarInfo)
@@ -858,7 +863,6 @@ static UINT rail_read_taskbar_info_order(wStream* s, RAIL_TASKBAR_INFO_ORDER* ta
return CHANNEL_RC_OK;
}
-
static UINT rail_recv_taskbar_info_order(railPlugin* rail, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
@@ -875,7 +879,7 @@ static UINT rail_recv_taskbar_info_order(railPlugin* rail, wStream* s)
if ((error = rail_read_taskbar_info_order(s, &taskBarInfo)))
{
- WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_langbar_info_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -884,7 +888,7 @@ static UINT rail_recv_taskbar_info_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerTaskBarInfo, error, context, &taskBarInfo);
if (error)
- WLog_ERR(TAG, "context.ServerLanguageBarInfo failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerLanguageBarInfo failed with error %" PRIu32 "", error);
}
return error;
@@ -919,7 +923,7 @@ static UINT rail_recv_zorder_sync_order(railPlugin* rail, wStream* s)
if ((error = rail_read_zorder_sync_order(s, &zorder)))
{
- WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -928,7 +932,7 @@ static UINT rail_recv_zorder_sync_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerZOrderSync, error, context, &zorder);
if (error)
- WLog_ERR(TAG, "context.ServerZOrderSync failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerZOrderSync failed with error %" PRIu32 "", error);
}
return error;
@@ -966,7 +970,7 @@ static UINT rail_recv_order_cloak(railPlugin* rail, wStream* s)
if ((error = rail_read_order_cloak(s, &cloak)))
{
- WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -975,7 +979,7 @@ static UINT rail_recv_order_cloak(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerCloak, error, context, &cloak);
if (error)
- WLog_ERR(TAG, "context.ServerZOrderSync failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerZOrderSync failed with error %" PRIu32 "", error);
}
return error;
@@ -1012,7 +1016,7 @@ static UINT rail_recv_power_display_request_order(railPlugin* rail, wStream* s)
if ((error = rail_read_power_display_request_order(s, &power)))
{
- WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_zorder_sync_order failed with error %" PRIu32 "!", error);
return error;
}
@@ -1021,15 +1025,14 @@ static UINT rail_recv_power_display_request_order(railPlugin* rail, wStream* s)
IFCALLRET(context->ServerPowerDisplayRequest, error, context, &power);
if (error)
- WLog_ERR(TAG, "context.ServerPowerDisplayRequest failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerPowerDisplayRequest failed with error %" PRIu32 "", error);
}
return error;
}
-
static UINT rail_read_get_application_id_extended_response_order(wStream* s,
- RAIL_GET_APPID_RESP_EX* id)
+ RAIL_GET_APPID_RESP_EX* id)
{
if (!s || !id)
return ERROR_INVALID_PARAMETER;
@@ -1059,14 +1062,14 @@ static UINT rail_read_get_application_id_extended_response_order(wStream* s,
if (!Stream_Read_UTF16_String(s, id->processImageName, ARRAYSIZE(id->processImageName)))
return ERROR_INVALID_DATA;
- if (_wcsnlen(id->applicationID, ARRAYSIZE(id->processImageName)) >= ARRAYSIZE(id->processImageName))
+ if (_wcsnlen(id->applicationID, ARRAYSIZE(id->processImageName)) >=
+ ARRAYSIZE(id->processImageName))
return ERROR_INVALID_DATA;
return CHANNEL_RC_OK;
}
-static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rail,
- wStream* s)
+static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rail, wStream* s)
{
RailClientContext* context = rail_get_client_interface(rail);
RAIL_GET_APPID_RESP_EX id = { 0 };
@@ -1077,7 +1080,9 @@ static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rai
if ((error = rail_read_get_application_id_extended_response_order(s, &id)))
{
- WLog_ERR(TAG, "rail_read_get_application_id_extended_response_order failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rail_read_get_application_id_extended_response_order failed with error %" PRIu32
+ "!",
error);
return error;
}
@@ -1087,7 +1092,8 @@ static UINT rail_recv_get_application_id_extended_response_order(railPlugin* rai
IFCALLRET(context->ServerGetAppidResponseExtended, error, context, &id);
if (error)
- WLog_ERR(TAG, "context.ServerGetAppidResponseExtended failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context.ServerGetAppidResponseExtended failed with error %" PRIu32 "",
+ error);
}
return error;
@@ -1109,12 +1115,13 @@ UINT rail_order_recv(railPlugin* rail, wStream* s)
if ((error = rail_read_pdu_header(s, &orderType, &orderLength)))
{
- WLog_ERR(TAG, "rail_read_pdu_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_read_pdu_header failed with error %" PRIu32 "!", error);
return error;
}
- WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length:%"PRIu16"",
- RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
+ WLog_Print(rail->log, WLOG_DEBUG, "Received %s PDU, length:%" PRIu16 "",
+ RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)],
+ orderLength);
switch (orderType)
{
@@ -1158,7 +1165,7 @@ UINT rail_order_recv(railPlugin* rail, wStream* s)
return rail_recv_get_application_id_extended_response_order(rail, s);
default:
- WLog_ERR(TAG, "Unknown RAIL PDU order reveived.");
+ WLog_ERR(TAG, "Unknown RAIL PDU order reveived.");
return ERROR_INVALID_DATA;
}
@@ -1256,7 +1263,8 @@ UINT rail_send_client_status_order(railPlugin* rail, const RAIL_CLIENT_STATUS_OR
* @return 0 on success, otherwise a Win32 error code
*/
UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags,
- const RAIL_UNICODE_STRING* exeOrFile, const RAIL_UNICODE_STRING* workingDir,
+ const RAIL_UNICODE_STRING* exeOrFile,
+ const RAIL_UNICODE_STRING* workingDir,
const RAIL_UNICODE_STRING* arguments)
{
wStream* s;
@@ -1266,10 +1274,7 @@ UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags,
if (!rail || !exeOrFile || !workingDir || !arguments)
return ERROR_INVALID_PARAMETER;
- length = RAIL_EXEC_ORDER_LENGTH +
- exeOrFile->length +
- workingDir->length +
- arguments->length;
+ length = RAIL_EXEC_ORDER_LENGTH + exeOrFile->length + workingDir->length + arguments->length;
s = rail_pdu_init(length);
if (!s)
@@ -1280,13 +1285,13 @@ UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags,
if ((error = rail_write_client_exec_order(s, flags, exeOrFile, workingDir, arguments)))
{
- WLog_ERR(TAG, "rail_write_client_exec_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_write_client_exec_order failed with error %" PRIu32 "!", error);
goto out;
}
if ((error = rail_send_pdu(rail, s, TS_RAIL_ORDER_EXEC)))
{
- WLog_ERR(TAG, "rail_send_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_pdu failed with error %" PRIu32 "!", error);
goto out;
}
@@ -1353,13 +1358,13 @@ static UINT rail_send_client_sysparam_order(railPlugin* rail, const RAIL_SYSPARA
if ((error = rail_write_client_sysparam_order(rail, s, sysparam)))
{
- WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_write_client_sysparam_order failed with error %" PRIu32 "!", error);
goto out;
}
if ((error = rail_send_pdu(rail, s, TS_RAIL_ORDER_SYSPARAM)))
{
- WLog_ERR(TAG, "rail_send_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_pdu failed with error %" PRIu32 "!", error);
goto out;
}
@@ -1386,7 +1391,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1397,7 +1402,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1406,9 +1411,9 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
{
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
- if ((error = rail_send_client_sysparam_order(rail, sysparam)))
+ if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1419,7 +1424,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1430,7 +1435,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1441,7 +1446,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1452,7 +1457,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1463,7 +1468,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1474,7 +1479,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1485,7 +1490,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1496,7 +1501,7 @@ static UINT rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORD
if ((error = rail_send_client_sysparam_order(rail, sysparam)))
{
- WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rail_send_client_sysparam_order failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1600,7 +1605,7 @@ UINT rail_send_client_syscommand_order(railPlugin* rail, const RAIL_SYSCOMMAND_O
* @return 0 on success, otherwise a Win32 error code
*/
UINT rail_send_client_notify_event_order(railPlugin* rail,
- const RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
+ const RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
{
wStream* s;
UINT error;
@@ -1661,7 +1666,7 @@ UINT rail_send_client_window_move_order(railPlugin* rail, const RAIL_WINDOW_MOVE
* @return 0 on success, otherwise a Win32 error code
*/
UINT rail_send_client_get_appid_req_order(railPlugin* rail,
- const RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
+ const RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
{
wStream* s;
UINT error;
@@ -1692,7 +1697,7 @@ UINT rail_send_client_get_appid_req_order(railPlugin* rail,
* @return 0 on success, otherwise a Win32 error code
*/
UINT rail_send_client_langbar_info_order(railPlugin* rail,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
wStream* s;
UINT error;
@@ -1721,7 +1726,7 @@ UINT rail_send_client_langbar_info_order(railPlugin* rail,
}
UINT rail_send_client_languageime_info_order(railPlugin* rail,
- const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
+ const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo)
{
wStream* s;
UINT error;
diff --git a/channels/rail/client/rail_orders.h b/channels/rail/client/rail_orders.h
index 41ef3ebb9..f1dfd1cc8 100644
--- a/channels/rail/client/rail_orders.h
+++ b/channels/rail/client/rail_orders.h
@@ -39,21 +39,22 @@ UINT rail_send_handshake_order(railPlugin* rail, const RAIL_HANDSHAKE_ORDER* han
UINT rail_send_handshake_ex_order(railPlugin* rail, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
UINT rail_send_client_status_order(railPlugin* rail, const RAIL_CLIENT_STATUS_ORDER* clientStatus);
UINT rail_send_client_exec_order(railPlugin* rail, UINT16 flags,
- const RAIL_UNICODE_STRING* exeOrFile, const RAIL_UNICODE_STRING* workingDir,
+ const RAIL_UNICODE_STRING* exeOrFile,
+ const RAIL_UNICODE_STRING* workingDir,
const RAIL_UNICODE_STRING* arguments);
UINT rail_send_client_activate_order(railPlugin* rail, const RAIL_ACTIVATE_ORDER* activate);
UINT rail_send_client_sysmenu_order(railPlugin* rail, const RAIL_SYSMENU_ORDER* sysmenu);
UINT rail_send_client_syscommand_order(railPlugin* rail, const RAIL_SYSCOMMAND_ORDER* syscommand);
UINT rail_send_client_notify_event_order(railPlugin* rail,
- const RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
+ const RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
UINT rail_send_client_window_move_order(railPlugin* rail, const RAIL_WINDOW_MOVE_ORDER* windowMove);
UINT rail_send_client_get_appid_req_order(railPlugin* rail,
- const RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
+ const RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
UINT rail_send_client_langbar_info_order(railPlugin* rail,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo);
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo);
UINT rail_send_client_languageime_info_order(railPlugin* rail,
- const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo);
+ const RAIL_LANGUAGEIME_INFO_ORDER* langImeInfo);
UINT rail_send_client_order_cloak_order(railPlugin* rail, const RAIL_CLOAK* cloak);
UINT rail_send_client_order_snap_arrange_order(railPlugin* rail, const RAIL_SNAP_ARRANGE* snap);
diff --git a/channels/rail/rail_common.c b/channels/rail/rail_common.c
index ac0103ffc..a9149248b 100644
--- a/channels/rail/rail_common.c
+++ b/channels/rail/rail_common.c
@@ -24,32 +24,29 @@
#include
-const char* const RAIL_ORDER_TYPE_STRINGS[] =
-{
- "",
- "Execute",
- "Activate",
- "System Parameters Update",
- "System Command",
- "Handshake",
- "Notify Event",
- "",
- "Window Move",
- "Local Move/Size",
- "Min Max Info",
- "Client Status",
- "System Menu",
- "Language Bar Info",
- "Get Application ID Request",
- "Get Application ID Response",
- "Execute Result",
- "",
- "",
- "",
- "",
- "",
- ""
-};
+const char* const RAIL_ORDER_TYPE_STRINGS[] = { "",
+ "Execute",
+ "Activate",
+ "System Parameters Update",
+ "System Command",
+ "Handshake",
+ "Notify Event",
+ "",
+ "Window Move",
+ "Local Move/Size",
+ "Min Max Info",
+ "Client Status",
+ "System Menu",
+ "Language Bar Info",
+ "Get Application ID Request",
+ "Get Application ID Response",
+ "Execute Result",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "" };
BOOL rail_string_to_unicode_string(const char* string, RAIL_UNICODE_STRING* unicode_string)
{
@@ -70,8 +67,8 @@ BOOL rail_string_to_unicode_string(const char* string, RAIL_UNICODE_STRING* unic
return FALSE;
}
- unicode_string->string = (BYTE*) buffer;
- unicode_string->length = (UINT16) length * sizeof(WCHAR);
+ unicode_string->string = (BYTE*)buffer;
+ unicode_string->length = (UINT16)length * sizeof(WCHAR);
return TRUE;
}
@@ -88,14 +85,14 @@ UINT rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength)
if (Stream_GetRemainingLength(s) < 4)
return ERROR_INVALID_DATA;
- Stream_Read_UINT16(s, *orderType); /* orderType (2 bytes) */
+ Stream_Read_UINT16(s, *orderType); /* orderType (2 bytes) */
Stream_Read_UINT16(s, *orderLength); /* orderLength (2 bytes) */
return CHANNEL_RC_OK;
}
void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength)
{
- Stream_Write_UINT16(s, orderType); /* orderType (2 bytes) */
+ Stream_Write_UINT16(s, orderType); /* orderType (2 bytes) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
}
@@ -140,13 +137,13 @@ UINT rail_read_handshake_ex_order(wStream* s, RAIL_HANDSHAKE_EX_ORDER* handshake
if (Stream_GetRemainingLength(s) < 8)
return ERROR_INVALID_DATA;
- Stream_Read_UINT32(s, handshakeEx->buildNumber); /* buildNumber (4 bytes) */
+ Stream_Read_UINT32(s, handshakeEx->buildNumber); /* buildNumber (4 bytes) */
Stream_Read_UINT32(s, handshakeEx->railHandshakeFlags); /* railHandshakeFlags (4 bytes) */
return CHANNEL_RC_OK;
}
void rail_write_handshake_ex_order(wStream* s, const RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
- Stream_Write_UINT32(s, handshakeEx->buildNumber); /* buildNumber (4 bytes) */
+ Stream_Write_UINT32(s, handshakeEx->buildNumber); /* buildNumber (4 bytes) */
Stream_Write_UINT32(s, handshakeEx->railHandshakeFlags); /* railHandshakeFlags (4 bytes) */
}
diff --git a/channels/rail/rail_common.h b/channels/rail/rail_common.h
index c481cc4ce..cbce3a2ee 100644
--- a/channels/rail/rail_common.h
+++ b/channels/rail/rail_common.h
@@ -28,22 +28,22 @@
extern const char* const RAIL_ORDER_TYPE_STRINGS[];
-#define RAIL_PDU_HEADER_LENGTH 4
+#define RAIL_PDU_HEADER_LENGTH 4
/* Fixed length of PDUs, excluding variable lengths */
-#define RAIL_HANDSHAKE_ORDER_LENGTH 4 /* fixed */
-#define RAIL_HANDSHAKE_EX_ORDER_LENGTH 8 /* fixed */
-#define RAIL_CLIENT_STATUS_ORDER_LENGTH 4 /* fixed */
-#define RAIL_EXEC_ORDER_LENGTH 8 /* variable */
-#define RAIL_SYSPARAM_ORDER_LENGTH 4 /* variable */
-#define RAIL_ACTIVATE_ORDER_LENGTH 5 /* fixed */
-#define RAIL_SYSMENU_ORDER_LENGTH 8 /* fixed */
-#define RAIL_SYSCOMMAND_ORDER_LENGTH 6 /* fixed */
-#define RAIL_NOTIFY_EVENT_ORDER_LENGTH 12 /* fixed */
-#define RAIL_WINDOW_MOVE_ORDER_LENGTH 12 /* fixed */
-#define RAIL_GET_APPID_REQ_ORDER_LENGTH 4 /* fixed */
-#define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */
-#define RAIL_LANGUAGEIME_INFO_ORDER_LENGTH 44 /* fixed */
+#define RAIL_HANDSHAKE_ORDER_LENGTH 4 /* fixed */
+#define RAIL_HANDSHAKE_EX_ORDER_LENGTH 8 /* fixed */
+#define RAIL_CLIENT_STATUS_ORDER_LENGTH 4 /* fixed */
+#define RAIL_EXEC_ORDER_LENGTH 8 /* variable */
+#define RAIL_SYSPARAM_ORDER_LENGTH 4 /* variable */
+#define RAIL_ACTIVATE_ORDER_LENGTH 5 /* fixed */
+#define RAIL_SYSMENU_ORDER_LENGTH 8 /* fixed */
+#define RAIL_SYSCOMMAND_ORDER_LENGTH 6 /* fixed */
+#define RAIL_NOTIFY_EVENT_ORDER_LENGTH 12 /* fixed */
+#define RAIL_WINDOW_MOVE_ORDER_LENGTH 12 /* fixed */
+#define RAIL_GET_APPID_REQ_ORDER_LENGTH 4 /* fixed */
+#define RAIL_LANGBAR_INFO_ORDER_LENGTH 4 /* fixed */
+#define RAIL_LANGUAGEIME_INFO_ORDER_LENGTH 44 /* fixed */
BOOL rail_string_to_unicode_string(const char* string, RAIL_UNICODE_STRING* unicode_string);
UINT rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake);
diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c
index bc0ad2f59..58a2ef55c 100644
--- a/channels/rdp2tcp/client/rdp2tcp_main.c
+++ b/channels/rdp2tcp/client/rdp2tcp_main.c
@@ -46,7 +46,6 @@ typedef struct
char buffer[16 * 1024];
} Plugin;
-
static int init_external_addin(Plugin* plugin)
{
SECURITY_ATTRIBUTES saAttr;
@@ -86,16 +85,16 @@ static int init_external_addin(Plugin* plugin)
// Execute plugin
if (!CreateProcess(NULL,
- plugin->channelEntryPoints.pExtendedData, // command line
- NULL, // process security attributes
- NULL, // primary thread security attributes
- TRUE, // handles are inherited
- 0, // creation flags
- NULL, // use parent's environment
- NULL, // use parent's current directory
- &siStartInfo, // STARTUPINFO pointer
- &procInfo // receives PROCESS_INFORMATION
- ))
+ plugin->channelEntryPoints.pExtendedData, // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ NULL, // use parent's current directory
+ &siStartInfo, // STARTUPINFO pointer
+ &procInfo // receives PROCESS_INFORMATION
+ ))
{
WLog_ERR(TAG, "fork for addin");
return -1;
@@ -146,7 +145,8 @@ static DWORD WINAPI copyThread(void* data)
goto fail;
}
- //if (!ReadFile(plugin->hStdOutputRead, plugin->buffer, sizeof plugin->buffer, &dwRead, NULL))
+ // if (!ReadFile(plugin->hStdOutputRead, plugin->buffer, sizeof plugin->buffer, &dwRead,
+ // NULL))
if (!ReadFile(plugin->hStdOutputRead, buffer, bufsize, &dwRead, NULL))
{
free(buffer);
@@ -159,8 +159,8 @@ static DWORD WINAPI copyThread(void* data)
dumpData(buffer, dwRead);
}
- if (plugin->channelEntryPoints.pVirtualChannelWriteEx(plugin->initHandle, plugin->openHandle,
- buffer, dwRead, buffer) != CHANNEL_RC_OK)
+ if (plugin->channelEntryPoints.pVirtualChannelWriteEx(
+ plugin->initHandle, plugin->openHandle, buffer, dwRead, buffer) != CHANNEL_RC_OK)
{
free(buffer);
fprintf(stderr, "rdp2tcp copyThread failed %i\n", (int)dwRead);
@@ -222,7 +222,8 @@ static void dataReceived(Plugin* plugin, void* pData, UINT32 dataLength, UINT32
}
static void VCAPITYPE VirtualChannelOpenEventEx(LPVOID lpUserParam, DWORD openHandle, UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ LPVOID pData, UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
Plugin* plugin = (Plugin*)lpUserParam;
@@ -243,7 +244,7 @@ static void VCAPITYPE VirtualChannelOpenEventEx(LPVOID lpUserParam, DWORD openHa
}
static VOID VCAPITYPE VirtualChannelInitEventEx(LPVOID lpUserParam, LPVOID pInitHandle, UINT event,
- LPVOID pData, UINT dataLength)
+ LPVOID pData, UINT dataLength)
{
Plugin* plugin = (Plugin*)lpUserParam;
@@ -256,8 +257,9 @@ static VOID VCAPITYPE VirtualChannelInitEventEx(LPVOID lpUserParam, LPVOID pInit
plugin->writeComplete = CreateEvent(NULL, TRUE, FALSE, NULL);
plugin->copyThread = CreateThread(NULL, 0, copyThread, plugin, 0, NULL);
- if (plugin->channelEntryPoints.pVirtualChannelOpenEx(pInitHandle, &plugin->openHandle,
- RDP2TCP_CHAN_NAME, VirtualChannelOpenEventEx) != CHANNEL_RC_OK)
+ if (plugin->channelEntryPoints.pVirtualChannelOpenEx(
+ pInitHandle, &plugin->openHandle, RDP2TCP_CHAN_NAME,
+ VirtualChannelOpenEventEx) != CHANNEL_RC_OK)
return;
break;
@@ -312,12 +314,11 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
strncpy(channelDef.name, RDP2TCP_CHAN_NAME, sizeof(channelDef.name));
channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP;
+ CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP;
if (pEntryPointsEx->pVirtualChannelInitEx(plugin, NULL, pInitHandle, &channelDef, 1,
- VIRTUAL_CHANNEL_VERSION_WIN2000, VirtualChannelInitEventEx) != CHANNEL_RC_OK)
+ VIRTUAL_CHANNEL_VERSION_WIN2000,
+ VirtualChannelInitEventEx) != CHANNEL_RC_OK)
return FALSE;
return TRUE;
diff --git a/channels/rdpdr/client/devman.c b/channels/rdpdr/client/devman.c
index acb9c44e8..5ade857a5 100644
--- a/channels/rdpdr/client/devman.c
+++ b/channels/rdpdr/client/devman.c
@@ -43,7 +43,7 @@
static void devman_device_free(void* obj)
{
- DEVICE* device = (DEVICE*) obj;
+ DEVICE* device = (DEVICE*)obj;
if (!device)
return;
@@ -58,21 +58,21 @@ DEVMAN* devman_new(rdpdrPlugin* rdpdr)
if (!rdpdr)
return NULL;
- devman = (DEVMAN*) calloc(1, sizeof(DEVMAN));
+ devman = (DEVMAN*)calloc(1, sizeof(DEVMAN));
if (!devman)
{
- WLog_INFO(TAG, "calloc failed!");
+ WLog_INFO(TAG, "calloc failed!");
return NULL;
}
- devman->plugin = (void*) rdpdr;
+ devman->plugin = (void*)rdpdr;
devman->id_sequence = 1;
devman->devices = ListDictionary_New(TRUE);
if (!devman->devices)
{
- WLog_INFO(TAG, "ListDictionary_New failed!");
+ WLog_INFO(TAG, "ListDictionary_New failed!");
free(devman);
return NULL;
}
@@ -94,7 +94,7 @@ void devman_unregister_device(DEVMAN* devman, void* key)
if (!devman || !key)
return;
- device = (DEVICE*) ListDictionary_Remove(devman->devices, key);
+ device = (DEVICE*)ListDictionary_Remove(devman->devices, key);
if (device)
devman_device_free(device);
@@ -113,11 +113,11 @@ static UINT devman_register_device(DEVMAN* devman, DEVICE* device)
return ERROR_INVALID_PARAMETER;
device->id = devman->id_sequence++;
- key = (void*)(size_t) device->id;
+ key = (void*)(size_t)device->id;
if (!ListDictionary_Add(devman->devices, key, device))
{
- WLog_INFO(TAG, "ListDictionary_Add failed!");
+ WLog_INFO(TAG, "ListDictionary_Add failed!");
return ERROR_INTERNAL_ERROR;
}
@@ -127,12 +127,12 @@ static UINT devman_register_device(DEVMAN* devman, DEVICE* device)
DEVICE* devman_get_device_by_id(DEVMAN* devman, UINT32 id)
{
DEVICE* device = NULL;
- void* key = (void*)(size_t) id;
+ void* key = (void*)(size_t)id;
if (!devman)
return NULL;
- device = (DEVICE*) ListDictionary_GetItemValue(devman->devices, key);
+ device = (DEVICE*)ListDictionary_GetItemValue(devman->devices, key);
return device;
}
@@ -150,7 +150,7 @@ DEVICE* devman_get_device_by_type(DEVMAN* devman, UINT32 type)
for (x = 0; x < count; x++)
{
- DEVICE* cur = (DEVICE*) ListDictionary_GetItemValue(devman->devices, (void*)keys[x]);
+ DEVICE* cur = (DEVICE*)ListDictionary_GetItemValue(devman->devices, (void*)keys[x]);
if (!cur)
continue;
@@ -200,21 +200,21 @@ UINT devman_load_device_service(DEVMAN* devman, const RDPDR_DEVICE* device, rdpC
if (!ServiceName)
{
- WLog_INFO(TAG, "ServiceName %s did not match!", ServiceName);
+ WLog_INFO(TAG, "ServiceName %s did not match!", ServiceName);
return ERROR_INVALID_NAME;
}
if (device->Name)
- WLog_INFO(TAG, "Loading device service %s [%s] (static)", ServiceName, device->Name);
+ WLog_INFO(TAG, "Loading device service %s [%s] (static)", ServiceName, device->Name);
else
- WLog_INFO(TAG, "Loading device service %s (static)", ServiceName);
+ WLog_INFO(TAG, "Loading device service %s (static)", ServiceName);
- entry = (PDEVICE_SERVICE_ENTRY) freerdp_load_channel_addin_entry(ServiceName, NULL,
- "DeviceServiceEntry", 0);
+ entry = (PDEVICE_SERVICE_ENTRY)freerdp_load_channel_addin_entry(ServiceName, NULL,
+ "DeviceServiceEntry", 0);
if (!entry)
{
- WLog_INFO(TAG, "freerdp_load_channel_addin_entry failed!");
+ WLog_INFO(TAG, "freerdp_load_channel_addin_entry failed!");
return ERROR_INTERNAL_ERROR;
}
diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c
index 21d4a466f..f5ad4861a 100644
--- a/channels/rdpdr/client/irp.c
+++ b/channels/rdpdr/client/irp.c
@@ -63,7 +63,7 @@ static UINT irp_complete(IRP* irp)
rdpdrPlugin* rdpdr;
UINT error;
- rdpdr = (rdpdrPlugin*) irp->devman->plugin;
+ rdpdr = (rdpdrPlugin*)irp->devman->plugin;
pos = Stream_GetPosition(irp->output);
Stream_SetPosition(irp->output, RDPDR_DEVICE_IO_RESPONSE_LENGTH - 4);
@@ -102,7 +102,7 @@ IRP* irp_new(DEVMAN* devman, wStream* s, UINT* error)
return NULL;
};
- irp = (IRP*) _aligned_malloc(sizeof(IRP), MEMORY_ALLOCATION_ALIGNMENT);
+ irp = (IRP*)_aligned_malloc(sizeof(IRP), MEMORY_ALLOCATION_ALIGNMENT);
if (!irp)
{
@@ -112,15 +112,14 @@ IRP* irp_new(DEVMAN* devman, wStream* s, UINT* error)
return NULL;
}
-
ZeroMemory(irp, sizeof(IRP));
irp->input = s;
irp->device = device;
irp->devman = devman;
- Stream_Read_UINT32(s, irp->FileId); /* FileId (4 bytes) */
- Stream_Read_UINT32(s, irp->CompletionId); /* CompletionId (4 bytes) */
+ Stream_Read_UINT32(s, irp->FileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, irp->CompletionId); /* CompletionId (4 bytes) */
Stream_Read_UINT32(s, irp->MajorFunction); /* MajorFunction (4 bytes) */
Stream_Read_UINT32(s, irp->MinorFunction); /* MinorFunction (4 bytes) */
@@ -133,11 +132,11 @@ IRP* irp_new(DEVMAN* devman, wStream* s, UINT* error)
*error = CHANNEL_RC_NO_MEMORY;
return NULL;
}
- Stream_Write_UINT16(irp->output, RDPDR_CTYP_CORE); /* Component (2 bytes) */
+ Stream_Write_UINT16(irp->output, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION); /* PacketId (2 bytes) */
- Stream_Write_UINT32(irp->output, DeviceId); /* DeviceId (4 bytes) */
- Stream_Write_UINT32(irp->output, irp->CompletionId); /* CompletionId (4 bytes) */
- Stream_Write_UINT32(irp->output, 0); /* IoStatus (4 bytes) */
+ Stream_Write_UINT32(irp->output, DeviceId); /* DeviceId (4 bytes) */
+ Stream_Write_UINT32(irp->output, irp->CompletionId); /* CompletionId (4 bytes) */
+ Stream_Write_UINT32(irp->output, 0); /* IoStatus (4 bytes) */
irp->Complete = irp_complete;
irp->Discard = irp_free;
diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c
index b5de7ad7c..97c876b0e 100644
--- a/channels/rdpdr/client/rdpdr_capabilities.c
+++ b/channels/rdpdr/client/rdpdr_capabilities.c
@@ -53,14 +53,14 @@ static void rdpdr_write_general_capset(rdpdrPlugin* rdpdr, wStream* s)
Stream_Write_UINT32(s, 0); /* osVersion, unused and must be set to zero */
Stream_Write_UINT16(s, 1); /* protocolMajorVersion, must be set to 1 */
Stream_Write_UINT16(s, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */
- Stream_Write_UINT32(s, 0x0000FFFF); /* ioCode1 */
+ Stream_Write_UINT32(s, 0x0000FFFF); /* ioCode1 */
Stream_Write_UINT32(s, 0); /* ioCode2, must be set to zero, reserved for future use */
Stream_Write_UINT32(s, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU |
- RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */
- Stream_Write_UINT32(s, ENABLE_ASYNCIO); /* extraFlags1 */
+ RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */
+ Stream_Write_UINT32(s, ENABLE_ASYNCIO); /* extraFlags1 */
Stream_Write_UINT32(s, 0); /* extraFlags2, must be set to zero, reserved for future use */
- Stream_Write_UINT32(s,
- 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */
+ Stream_Write_UINT32(
+ s, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */
}
/* Process device direction general capability set */
diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c
index a809a1965..d37c1a276 100644
--- a/channels/rdpdr/client/rdpdr_main.c
+++ b/channels/rdpdr/client/rdpdr_main.c
@@ -81,16 +81,14 @@ struct _DEVICE_DRIVE_EXT
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
- BOOL userLoggedOn);
+static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL userLoggedOn);
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr,
- UINT32 count, UINT32 ids[])
+static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr, UINT32 count, UINT32 ids[])
{
UINT32 i;
wStream* s;
@@ -185,17 +183,17 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
switch (wParam)
{
case DBT_DEVICEARRIVAL:
- if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)
+ if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
DWORD unitmask = lpdbv->dbcv_unitmask;
int i;
- char drive_path[4] = { 'c', ':', '/', '\0'};
+ char drive_path[4] = { 'c', ':', '/', '\0' };
for (i = 0; i < 26; i++)
{
if (unitmask & 0x01)
- {
+ {
drive_path[0] = 'A' + i;
drive_path[1] = ':';
@@ -208,7 +206,8 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
drive_path[1] = '\0';
drive.automount = TRUE;
drive.Name = drive_path;
- devman_load_device_service(rdpdr->devman, (const RDPDR_DEVICE*)&drive,
+ devman_load_device_service(rdpdr->devman,
+ (const RDPDR_DEVICE*)&drive,
rdpdr->rdpcontext);
rdpdr_send_device_list_announce_request(rdpdr, TRUE);
}
@@ -221,7 +220,7 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
break;
case DBT_DEVICEREMOVECOMPLETE:
- if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)
+ if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
DWORD unitmask = lpdbv->dbcv_unitmask;
@@ -242,21 +241,25 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
for (j = 0; j < count; j++)
{
device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
- rdpdr->devman->devices, (void*)keys[j]);
+ rdpdr->devman->devices, (void*)keys[j]);
- if (device_ext->path[0] == drive_name_upper
- || device_ext->path[0] == drive_name_lower)
+ if (device_ext->path[0] == drive_name_upper ||
+ device_ext->path[0] == drive_name_lower)
{
if (device_ext->automount)
{
devman_unregister_device(rdpdr->devman, (void*)keys[j]);
ids[0] = keys[j];
- if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
+ if ((error = rdpdr_send_device_list_remove_request(
+ rdpdr, 1, ids)))
{
// dont end on error, just report ?
- WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %"PRIu32"!",
- error);
+ WLog_ERR(
+ TAG,
+ "rdpdr_send_device_list_remove_request failed "
+ "with error %" PRIu32 "!",
+ error);
}
break;
@@ -297,30 +300,27 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
HDEVNOTIFY hDevNotify;
rdpdr = (rdpdrPlugin*)arg;
/* init windows class */
- wnd_cls.cbSize = sizeof(WNDCLASSEX);
- wnd_cls.style = CS_HREDRAW | CS_VREDRAW;
- wnd_cls.lpfnWndProc = hotplug_proc;
- wnd_cls.cbClsExtra = 0;
- wnd_cls.cbWndExtra = 0;
- wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wnd_cls.hCursor = NULL;
+ wnd_cls.cbSize = sizeof(WNDCLASSEX);
+ wnd_cls.style = CS_HREDRAW | CS_VREDRAW;
+ wnd_cls.lpfnWndProc = hotplug_proc;
+ wnd_cls.cbClsExtra = 0;
+ wnd_cls.cbWndExtra = 0;
+ wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wnd_cls.hCursor = NULL;
wnd_cls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- wnd_cls.lpszMenuName = NULL;
+ wnd_cls.lpszMenuName = NULL;
wnd_cls.lpszClassName = L"DRIVE_HOTPLUG";
- wnd_cls.hInstance = NULL;
- wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+ wnd_cls.hInstance = NULL;
+ wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wnd_cls);
/* create window */
- hwnd = CreateWindowEx(0, L"DRIVE_HOTPLUG", NULL,
- 0, 0, 0, 0, 0,
- NULL, NULL, NULL, NULL);
+ hwnd = CreateWindowEx(0, L"DRIVE_HOTPLUG", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)rdpdr);
rdpdr->hotplug_wnd = hwnd;
/* register device interface to hwnd */
NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HANDLE);
NotificationFilter.dbch_devicetype = DBT_DEVTYP_HANDLE;
- hDevNotify = RegisterDeviceNotification(hwnd, &NotificationFilter,
- DEVICE_NOTIFY_WINDOW_HANDLE);
+ hDevNotify = RegisterDeviceNotification(hwnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
/* message loop */
while ((bRet = GetMessage(&msg, 0, 0, 0)) != 0)
@@ -352,7 +352,7 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr)
if (rdpdr->hotplug_wnd && !PostMessage(rdpdr->hotplug_wnd, WM_QUIT, 0, 0))
{
error = GetLastError();
- WLog_ERR(TAG, "PostMessage failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "PostMessage failed with error %" PRIu32 "", error);
}
return error;
@@ -365,10 +365,9 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr)
typedef struct _hotplug_dev
{
char* path;
- BOOL to_add;
+ BOOL to_add;
} hotplug_dev;
-
/**
* Function description
*
@@ -429,8 +428,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
{
char* path = NULL;
BOOL dev_found = FALSE;
- device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
- rdpdr->devman->devices, (void*)keys[j]);
+ device_ext =
+ (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(rdpdr->devman->devices, (void*)keys[j]);
if (!device_ext || !device_ext->automount)
continue;
@@ -470,7 +469,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
{
- WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_send_device_list_remove_request failed with error %" PRIu32 "!",
error);
goto cleanup;
}
@@ -516,17 +516,17 @@ cleanup:
return error;
}
-
static void drive_hotplug_fsevent_callback(ConstFSEventStreamRef streamRef,
- void* clientCallBackInfo,
- size_t numEvents, void* eventPaths, const FSEventStreamEventFlags eventFlags[],
- const FSEventStreamEventId eventIds[])
+ void* clientCallBackInfo, size_t numEvents,
+ void* eventPaths,
+ const FSEventStreamEventFlags eventFlags[],
+ const FSEventStreamEventId eventIds[])
{
rdpdrPlugin* rdpdr;
size_t i;
UINT error;
char** paths = (char**)eventPaths;
- rdpdr = (rdpdrPlugin*) clientCallBackInfo;
+ rdpdr = (rdpdrPlugin*)clientCallBackInfo;
for (i = 0; i < numEvents; i++)
{
@@ -534,7 +534,7 @@ static void drive_hotplug_fsevent_callback(ConstFSEventStreamRef streamRef,
{
if ((error = handle_hotplug(rdpdr)))
{
- WLog_ERR(TAG, "handle_hotplug failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "handle_hotplug failed with error %" PRIu32 "!", error);
}
else
rdpdr_send_device_list_announce_request(rdpdr, TRUE);
@@ -550,7 +550,7 @@ void first_hotplug(rdpdrPlugin* rdpdr)
if ((error = handle_hotplug(rdpdr)))
{
- WLog_ERR(TAG, "handle_hotplug failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "handle_hotplug failed with error %" PRIu32 "!", error);
}
}
@@ -558,16 +558,15 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
{
rdpdrPlugin* rdpdr;
FSEventStreamRef fsev;
- rdpdr = (rdpdrPlugin*) arg;
+ rdpdr = (rdpdrPlugin*)arg;
CFStringRef path = CFSTR("/Volumes/");
- CFArrayRef pathsToWatch = CFArrayCreate(kCFAllocatorMalloc, (const void**)&path,
- 1, NULL);
+ CFArrayRef pathsToWatch = CFArrayCreate(kCFAllocatorMalloc, (const void**)&path, 1, NULL);
FSEventStreamContext ctx;
ZeroMemory(&ctx, sizeof(ctx));
ctx.info = arg;
- fsev = FSEventStreamCreate(kCFAllocatorMalloc, drive_hotplug_fsevent_callback,
- &ctx, pathsToWatch, kFSEventStreamEventIdSinceNow, 1,
- kFSEventStreamCreateFlagNone);
+ fsev =
+ FSEventStreamCreate(kCFAllocatorMalloc, drive_hotplug_fsevent_callback, &ctx, pathsToWatch,
+ kFSEventStreamEventIdSinceNow, 1, kFSEventStreamCreateFlagNone);
rdpdr->runLoop = CFRunLoopGetCurrent();
FSEventStreamScheduleWithRunLoop(fsev, rdpdr->runLoop, kCFRunLoopDefaultMode);
FSEventStreamStart(fsev);
@@ -585,18 +584,11 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
typedef struct _hotplug_dev
{
char* path;
- BOOL to_add;
+ BOOL to_add;
} hotplug_dev;
-
-static const char* automountLocations[] =
-{
- "/run/user/%lu/gvfs",
- "/run/media/%s",
- "/media/%s",
- "/media",
- "/mnt"
-};
+static const char* automountLocations[] = { "/run/user/%lu/gvfs", "/run/media/%s", "/media/%s",
+ "/media", "/mnt" };
static BOOL isAutomountLocation(const char* path)
{
@@ -716,7 +708,7 @@ static char* get_word(char* str, size_t* offset)
p = str + *offset;
tmp = p;
- while (*tmp != ' ' && *tmp != '\0')
+ while (*tmp != ' ' && *tmp != '\0')
tmp++;
wlen = tmp - p;
@@ -791,10 +783,11 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
{
char* path = NULL;
BOOL dev_found = FALSE;
- DEVICE_DRIVE_EXT* device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
- rdpdr->devman->devices, (void*)keys[j]);
+ DEVICE_DRIVE_EXT* device_ext =
+ (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(rdpdr->devman->devices, (void*)keys[j]);
- if (!device_ext || (device_ext->device.type != RDPDR_DTYP_FILESYSTEM) || !device_ext->path || !device_ext->automount)
+ if (!device_ext || (device_ext->device.type != RDPDR_DTYP_FILESYSTEM) ||
+ !device_ext->path || !device_ext->automount)
continue;
ConvertFromUnicode(CP_UTF8, 0, device_ext->path, -1, &path, 0, NULL, NULL);
@@ -825,7 +818,8 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
{
- WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_send_device_list_remove_request failed with error %" PRIu32 "!",
error);
goto cleanup;
}
@@ -877,7 +871,7 @@ static void first_hotplug(rdpdrPlugin* rdpdr)
if ((error = handle_hotplug(rdpdr)))
{
- WLog_ERR(TAG, "handle_hotplug failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "handle_hotplug failed with error %" PRIu32 "!", error);
}
}
@@ -890,7 +884,7 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
int rv;
UINT error = 0;
DWORD status;
- rdpdr = (rdpdrPlugin*) arg;
+ rdpdr = (rdpdrPlugin*)arg;
mfd = open("/proc/mounts", O_RDONLY, 0);
if (mfd < 0)
@@ -912,7 +906,7 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
goto out;
}
@@ -924,7 +918,7 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
/* file /proc/mounts changed, handle this */
if ((error = handle_hotplug(rdpdr)))
{
- WLog_ERR(TAG, "handle_hotplug failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "handle_hotplug failed with error %" PRIu32 "!", error);
goto out;
}
else
@@ -940,8 +934,7 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg)
out:
if (error && rdpdr->rdpcontext)
- setChannelError(rdpdr->rdpcontext, error,
- "drive_hotplug_thread_func reported an error");
+ setChannelError(rdpdr->rdpcontext, error, "drive_hotplug_thread_func reported an error");
ExitThread(error);
return error;
@@ -969,7 +962,7 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr)
if (WaitForSingleObject(rdpdr->hotplugThread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -984,7 +977,6 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr)
#endif
-
/**
* Function description
*
@@ -1003,14 +995,12 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
return CHANNEL_RC_NO_MEMORY;
}
- settings = (rdpSettings*) rdpdr->channelEntryPoints.pExtendedData;
+ settings = (rdpSettings*)rdpdr->channelEntryPoints.pExtendedData;
if (settings->ClientHostname)
- strncpy(rdpdr->computerName, settings->ClientHostname,
- sizeof(rdpdr->computerName) - 1);
+ strncpy(rdpdr->computerName, settings->ClientHostname, sizeof(rdpdr->computerName) - 1);
else
- strncpy(rdpdr->computerName, settings->ComputerName,
- sizeof(rdpdr->computerName) - 1);
+ strncpy(rdpdr->computerName, settings->ComputerName, sizeof(rdpdr->computerName) - 1);
for (index = 0; index < settings->DeviceCount; index++)
{
@@ -1036,8 +1026,8 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
#endif
- if (!(rdpdr->hotplugThread = CreateThread(NULL, 0,
- drive_hotplug_thread_func, rdpdr, 0, NULL)))
+ if (!(rdpdr->hotplugThread =
+ CreateThread(NULL, 0, drive_hotplug_thread_func, rdpdr, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
#ifndef _WIN32
@@ -1051,10 +1041,9 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
}
}
- if ((error = devman_load_device_service(rdpdr->devman, device,
- rdpdr->rdpcontext)))
+ if ((error = devman_load_device_service(rdpdr->devman, device, rdpdr->rdpcontext)))
{
- WLog_ERR(TAG, "devman_load_device_service failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "devman_load_device_service failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1062,8 +1051,7 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
return error;
}
-static UINT rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr,
- wStream* s)
+static UINT rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr, wStream* s)
{
if (Stream_GetRemainingLength(s) < 8)
return ERROR_INVALID_DATA;
@@ -1091,11 +1079,11 @@ static UINT rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(s, PAKID_CORE_CLIENTID_CONFIRM); /* PacketId (2 bytes) */
Stream_Write_UINT16(s, rdpdr->versionMajor);
Stream_Write_UINT16(s, rdpdr->versionMinor);
- Stream_Write_UINT32(s, (UINT32) rdpdr->clientID);
+ Stream_Write_UINT32(s, (UINT32)rdpdr->clientID);
return rdpdr_send(rdpdr, s);
}
@@ -1113,8 +1101,7 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
if (!rdpdr->computerName[0])
gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
- computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1,
- &computerNameW, 0) * 2;
+ computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2;
s = Stream_New(NULL, 16 + computerNameLenW + 2);
if (!s)
@@ -1124,20 +1111,18 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(s, PAKID_CORE_CLIENT_NAME); /* PacketId (2 bytes) */
- Stream_Write_UINT32(s, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
- Stream_Write_UINT32(s, 0); /* codePage, must be set to zero */
- Stream_Write_UINT32(s, computerNameLenW +
- 2); /* computerNameLen, including null terminator */
+ Stream_Write_UINT32(s, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
+ Stream_Write_UINT32(s, 0); /* codePage, must be set to zero */
+ Stream_Write_UINT32(s, computerNameLenW + 2); /* computerNameLen, including null terminator */
Stream_Write(s, computerNameW, computerNameLenW);
Stream_Write_UINT16(s, 0); /* null terminator */
free(computerNameW);
return rdpdr_send(rdpdr, s);
}
-static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr,
- wStream* s)
+static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr, wStream* s)
{
UINT16 versionMajor;
UINT16 versionMinor;
@@ -1167,8 +1152,7 @@ static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
- BOOL userLoggedOn)
+static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL userLoggedOn)
{
int i;
BYTE c;
@@ -1189,7 +1173,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(s, PAKID_CORE_DEVICELIST_ANNOUNCE); /* PacketId (2 bytes) */
count_pos = Stream_GetPosition(s);
count = 0;
@@ -1199,8 +1183,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
for (index = 0; index < keyCount; index++)
{
- device = (DEVICE*) ListDictionary_GetItemValue(rdpdr->devman->devices,
- (void*) pKeys[index]);
+ device = (DEVICE*)ListDictionary_GetItemValue(rdpdr->devman->devices, (void*)pKeys[index]);
/**
* 1. versionMinor 0x0005 doesn't send PAKID_CORE_USER_LOGGEDON
@@ -1209,8 +1192,8 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
* 3. other devices are sent only after user_loggedon
*/
- if ((rdpdr->versionMinor == 0x0005) ||
- (device->type == RDPDR_DTYP_SMARTCARD) || userLoggedOn)
+ if ((rdpdr->versionMinor == 0x0005) || (device->type == RDPDR_DTYP_SMARTCARD) ||
+ userLoggedOn)
{
data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data));
@@ -1223,8 +1206,8 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
}
Stream_Write_UINT32(s, device->type); /* deviceType */
- Stream_Write_UINT32(s, device->id); /* deviceID */
- strncpy((char*) Stream_Pointer(s), device->name, 8);
+ Stream_Write_UINT32(s, device->id); /* deviceID */
+ strncpy((char*)Stream_Pointer(s), device->name, 8);
for (i = 0; i < 8; i++)
{
@@ -1242,7 +1225,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
Stream_Write(s, Stream_Buffer(device->data), data_len);
count++;
- WLog_INFO(TAG, "registered device #%"PRIu32": %s (type=%"PRIu32" id=%"PRIu32")",
+ WLog_INFO(TAG, "registered device #%" PRIu32 ": %s (type=%" PRIu32 " id=%" PRIu32 ")",
count, device->name, device->type, device->id);
}
}
@@ -1269,14 +1252,14 @@ static UINT rdpdr_process_irp(rdpdrPlugin* rdpdr, wStream* s)
if (!irp)
{
- WLog_ERR(TAG, "irp_new failed with %"PRIu32"!", error);
+ WLog_ERR(TAG, "irp_new failed with %" PRIu32 "!", error);
return error;
}
IFCALLRET(irp->device->IRPRequest, error, irp->device, irp);
if (error)
- WLog_ERR(TAG, "device->IRPRequest failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "device->IRPRequest failed with error %" PRIu32 "", error);
return error;
}
@@ -1323,8 +1306,7 @@ static UINT rdpdr_process_init(rdpdrPlugin* rdpdr)
for (index = 0; index < keyCount; index++)
{
- device = (DEVICE*) ListDictionary_GetItemValue(rdpdr->devman->devices,
- (void*) pKeys[index]);
+ device = (DEVICE*)ListDictionary_GetItemValue(rdpdr->devman->devices, (void*)pKeys[index]);
IFCALLRET(device->Init, error, device);
if (error != CHANNEL_RC_OK)
@@ -1358,7 +1340,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
if (Stream_GetRemainingLength(s) >= 4)
{
Stream_Read_UINT16(s, component); /* Component (2 bytes) */
- Stream_Read_UINT16(s, packetId); /* PacketId (2 bytes) */
+ Stream_Read_UINT16(s, packetId); /* PacketId (2 bytes) */
if (component == RDPDR_CTYP_CORE)
{
@@ -1370,15 +1352,19 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
}
else if ((error = rdpdr_send_client_announce_reply(rdpdr)))
{
- WLog_ERR(TAG, "rdpdr_send_client_announce_reply failed with error %"PRIu32"", error);
+ WLog_ERR(TAG,
+ "rdpdr_send_client_announce_reply failed with error %" PRIu32 "",
+ error);
}
else if ((error = rdpdr_send_client_name_request(rdpdr)))
{
- WLog_ERR(TAG, "rdpdr_send_client_name_request failed with error %"PRIu32"", error);
+ WLog_ERR(TAG,
+ "rdpdr_send_client_name_request failed with error %" PRIu32 "",
+ error);
}
else if ((error = rdpdr_process_init(rdpdr)))
{
- WLog_ERR(TAG, "rdpdr_process_init failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpdr_process_init failed with error %" PRIu32 "", error);
}
break;
@@ -1389,7 +1375,9 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
}
else if ((error = rdpdr_send_capability_response(rdpdr)))
{
- WLog_ERR(TAG, "rdpdr_send_capability_response failed with error %"PRIu32"", error);
+ WLog_ERR(TAG,
+ "rdpdr_send_capability_response failed with error %" PRIu32 "",
+ error);
}
break;
@@ -1400,8 +1388,10 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
}
else if ((error = rdpdr_send_device_list_announce_request(rdpdr, FALSE)))
{
- WLog_ERR(TAG, "rdpdr_send_device_list_announce_request failed with error %"PRIu32"",
- error);
+ WLog_ERR(
+ TAG,
+ "rdpdr_send_device_list_announce_request failed with error %" PRIu32 "",
+ error);
}
break;
@@ -1409,8 +1399,10 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
case PAKID_CORE_USER_LOGGEDON:
if ((error = rdpdr_send_device_list_announce_request(rdpdr, TRUE)))
{
- WLog_ERR(TAG, "rdpdr_send_device_list_announce_request failed with error %"PRIu32"",
- error);
+ WLog_ERR(
+ TAG,
+ "rdpdr_send_device_list_announce_request failed with error %" PRIu32 "",
+ error);
}
break;
@@ -1430,7 +1422,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
case PAKID_CORE_DEVICE_IOREQUEST:
if ((error = rdpdr_process_irp(rdpdr, s)))
{
- WLog_ERR(TAG, "rdpdr_process_irp failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpdr_process_irp failed with error %" PRIu32 "", error);
return error;
}
else
@@ -1439,7 +1431,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
break;
default:
- WLog_ERR(TAG, "RDPDR_CTYP_CORE unknown PacketId: 0x%04"PRIX16"", packetId);
+ WLog_ERR(TAG, "RDPDR_CTYP_CORE unknown PacketId: 0x%04" PRIX16 "", packetId);
error = ERROR_INVALID_DATA;
break;
}
@@ -1450,8 +1442,9 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Unknown message: Component: 0x%04"PRIX16" PacketId: 0x%04"PRIX16"", component,
- packetId);
+ WLog_ERR(TAG,
+ "Unknown message: Component: 0x%04" PRIX16 " PacketId: 0x%04" PRIX16 "",
+ component, packetId);
}
}
}
@@ -1468,7 +1461,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
{
UINT status;
- rdpdrPlugin* plugin = (rdpdrPlugin*) rdpdr;
+ rdpdrPlugin* plugin = (rdpdrPlugin*)rdpdr;
if (!rdpdr || !s)
{
@@ -1483,14 +1476,15 @@ UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
}
else
{
- status = plugin->channelEntryPoints.pVirtualChannelWriteEx(plugin->InitHandle, plugin->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
+ status = plugin->channelEntryPoints.pVirtualChannelWriteEx(
+ plugin->InitHandle, plugin->OpenHandle, Stream_Buffer(s), (UINT32)Stream_GetPosition(s),
+ s);
}
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -1502,8 +1496,9 @@ UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -1527,16 +1522,16 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
if (!rdpdr->data_in)
{
- WLog_ERR(TAG, "Stream_New failed!");
+ WLog_ERR(TAG, "Stream_New failed!");
return CHANNEL_RC_NO_MEMORY;
}
}
data_in = rdpdr->data_in;
- if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
+ if (!Stream_EnsureRemainingCapacity(data_in, (int)dataLength))
{
- WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
+ WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
return ERROR_INVALID_DATA;
}
@@ -1554,7 +1549,7 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(rdpdr->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(rdpdr->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -1565,25 +1560,27 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
}
static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- rdpdrPlugin* rdpdr = (rdpdrPlugin*) lpUserParam;
+ rdpdrPlugin* rdpdr = (rdpdrPlugin*)lpUserParam;
if (!rdpdr || !pData || (rdpdr->OpenHandle != openHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- if ((error = rdpdr_virtual_channel_event_data_received(rdpdr, pData,
- dataLength, totalLength, dataFlags)))
+ if ((error = rdpdr_virtual_channel_event_data_received(rdpdr, pData, dataLength,
+ totalLength, dataFlags)))
WLog_ERR(TAG,
- "rdpdr_virtual_channel_event_data_received failed with error %"PRIu32"!", error);
+ "rdpdr_virtual_channel_event_data_received failed with error %" PRIu32 "!",
+ error);
break;
@@ -1593,7 +1590,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DW
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
@@ -1610,18 +1607,18 @@ static DWORD WINAPI rdpdr_virtual_channel_client_thread(LPVOID arg)
{
wStream* data;
wMessage message;
- rdpdrPlugin* rdpdr = (rdpdrPlugin*) arg;
+ rdpdrPlugin* rdpdr = (rdpdrPlugin*)arg;
UINT error;
if (!rdpdr)
{
- ExitThread((DWORD) CHANNEL_RC_NULL_DATA);
+ ExitThread((DWORD)CHANNEL_RC_NULL_DATA);
return CHANNEL_RC_NULL_DATA;
}
if ((error = rdpdr_process_connect(rdpdr)))
{
- WLog_ERR(TAG, "rdpdr_process_connect failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpdr_process_connect failed with error %" PRIu32 "!", error);
if (rdpdr->rdpcontext)
setChannelError(rdpdr->rdpcontext, error,
@@ -1643,17 +1640,17 @@ static DWORD WINAPI rdpdr_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
if ((error = rdpdr_process_receive(rdpdr, data)))
{
- WLog_ERR(TAG, "rdpdr_process_receive failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpdr_process_receive failed with error %" PRIu32 "!", error);
if (rdpdr->rdpcontext)
setChannelError(rdpdr->rdpcontext, error,
"rdpdr_virtual_channel_client_thread reported an error");
- ExitThread((DWORD) error);
+ ExitThread((DWORD)error);
return error;
}
}
@@ -1669,16 +1666,17 @@ static DWORD WINAPI rdpdr_virtual_channel_client_thread(LPVOID arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr,
- LPVOID pData, UINT32 dataLength)
+static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pData,
+ UINT32 dataLength)
{
UINT32 status;
- status = rdpdr->channelEntryPoints.pVirtualChannelOpenEx(rdpdr->InitHandle,
- &rdpdr->OpenHandle, rdpdr->channelDef.name, rdpdr_virtual_channel_open_event_ex);
+ status = rdpdr->channelEntryPoints.pVirtualChannelOpenEx(rdpdr->InitHandle, &rdpdr->OpenHandle,
+ rdpdr->channelDef.name,
+ rdpdr_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -1691,9 +1689,8 @@ static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr,
return CHANNEL_RC_NO_MEMORY;
}
- if (!(rdpdr->thread = CreateThread(NULL, 0,
- rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0,
- NULL)))
+ if (!(rdpdr->thread =
+ CreateThread(NULL, 0, rdpdr_virtual_channel_client_thread, (void*)rdpdr, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
return ERROR_INTERNAL_ERROR;
@@ -1714,11 +1711,11 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
if (rdpdr->OpenHandle == 0)
return CHANNEL_RC_OK;
- if (MessageQueue_PostQuit(rdpdr->queue, 0)
- && (WaitForSingleObject(rdpdr->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(rdpdr->queue, 0) &&
+ (WaitForSingleObject(rdpdr->thread, INFINITE) == WAIT_FAILED))
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -1729,7 +1726,7 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
if ((error = drive_hotplug_thread_terminate(rdpdr)))
{
- WLog_ERR(TAG, "drive_hotplug_thread_terminate failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "drive_hotplug_thread_terminate failed with error %" PRIu32 "!", error);
return error;
}
@@ -1737,7 +1734,7 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
if (CHANNEL_RC_OK != error)
{
- WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(error), error);
}
@@ -1765,11 +1762,10 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
}
static VOID VCAPITYPE rdpdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event,
- LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData, UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- rdpdrPlugin* rdpdr = (rdpdrPlugin*) lpUserParam;
+ rdpdrPlugin* rdpdr = (rdpdrPlugin*)lpUserParam;
if (!rdpdr || (rdpdr->InitHandle != pInitHandle))
{
@@ -1784,14 +1780,16 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LP
case CHANNEL_EVENT_CONNECTED:
if ((error = rdpdr_virtual_channel_event_connected(rdpdr, pData, dataLength)))
- WLog_ERR(TAG, "rdpdr_virtual_channel_event_connected failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_virtual_channel_event_connected failed with error %" PRIu32 "!",
error);
break;
case CHANNEL_EVENT_DISCONNECTED:
if ((error = rdpdr_virtual_channel_event_disconnected(rdpdr)))
- WLog_ERR(TAG, "rdpdr_virtual_channel_event_disconnected failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_virtual_channel_event_disconnected failed with error %" PRIu32 "!",
error);
break;
@@ -1803,7 +1801,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LP
case CHANNEL_EVENT_ATTACHED:
case CHANNEL_EVENT_DETACHED:
default:
- WLog_ERR(TAG, "unknown event %"PRIu32"!", event);
+ WLog_ERR(TAG, "unknown event %" PRIu32 "!", event);
break;
}
@@ -1813,14 +1811,14 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LP
}
/* rdpdr is always built-in */
-#define VirtualChannelEntryEx rdpdr_VirtualChannelEntryEx
+#define VirtualChannelEntryEx rdpdr_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
UINT rc;
rdpdrPlugin* rdpdr;
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
- rdpdr = (rdpdrPlugin*) calloc(1, sizeof(rdpdrPlugin));
+ rdpdr = (rdpdrPlugin*)calloc(1, sizeof(rdpdrPlugin));
if (!rdpdr)
{
@@ -1829,12 +1827,10 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
}
rdpdr->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP;
+ CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP;
sprintf_s(rdpdr->channelDef.name, ARRAYSIZE(rdpdr->channelDef.name), "rdpdr");
rdpdr->sequenceId = 0;
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
@@ -1842,17 +1838,16 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
rdpdr->rdpcontext = pEntryPointsEx->context;
}
- CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints,
- sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
+ CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
rdpdr->InitHandle = pInitHandle;
- rc = rdpdr->channelEntryPoints.pVirtualChannelInitEx(rdpdr, NULL, pInitHandle,
- &rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- rdpdr_virtual_channel_init_event_ex);
+ rc = rdpdr->channelEntryPoints.pVirtualChannelInitEx(
+ rdpdr, NULL, pInitHandle, &rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ rdpdr_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
free(rdpdr);
return FALSE;
}
diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c
index e8711196c..3e005da0f 100644
--- a/channels/rdpdr/server/rdpdr_main.c
+++ b/channels/rdpdr/server/rdpdr_main.c
@@ -39,7 +39,7 @@ static UINT32 g_ClientId = 0;
static RDPDR_IRP* rdpdr_server_irp_new()
{
RDPDR_IRP* irp;
- irp = (RDPDR_IRP*) calloc(1, sizeof(RDPDR_IRP));
+ irp = (RDPDR_IRP*)calloc(1, sizeof(RDPDR_IRP));
return irp;
}
@@ -48,19 +48,15 @@ static void rdpdr_server_irp_free(RDPDR_IRP* irp)
free(irp);
}
-static BOOL rdpdr_server_enqueue_irp(RdpdrServerContext* context,
- RDPDR_IRP* irp)
+static BOOL rdpdr_server_enqueue_irp(RdpdrServerContext* context, RDPDR_IRP* irp)
{
- return ListDictionary_Add(context->priv->IrpList,
- (void*)(size_t) irp->CompletionId, irp);
+ return ListDictionary_Add(context->priv->IrpList, (void*)(size_t)irp->CompletionId, irp);
}
-static RDPDR_IRP* rdpdr_server_dequeue_irp(RdpdrServerContext* context,
- UINT32 completionId)
+static RDPDR_IRP* rdpdr_server_dequeue_irp(RdpdrServerContext* context, UINT32 completionId)
{
RDPDR_IRP* irp;
- irp = (RDPDR_IRP*) ListDictionary_Remove(context->priv->IrpList,
- (void*)(size_t) completionId);
+ irp = (RDPDR_IRP*)ListDictionary_Remove(context->priv->IrpList, (void*)(size_t)completionId);
return irp;
}
@@ -86,17 +82,15 @@ static UINT rdpdr_server_send_announce_request(RdpdrServerContext* context)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
- Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
- Stream_Write_UINT16(s,
- context->priv->VersionMajor); /* VersionMajor (2 bytes) */
- Stream_Write_UINT16(s,
- context->priv->VersionMinor); /* VersionMinor (2 bytes) */
- Stream_Write_UINT32(s, context->priv->ClientId); /* ClientId (4 bytes) */
+ Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
+ Stream_Write_UINT16(s, context->priv->VersionMajor); /* VersionMajor (2 bytes) */
+ Stream_Write_UINT16(s, context->priv->VersionMinor); /* VersionMinor (2 bytes) */
+ Stream_Write_UINT32(s, context->priv->ClientId); /* ClientId (4 bytes) */
Stream_SealLength(s);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -106,8 +100,8 @@ static UINT rdpdr_server_send_announce_request(RdpdrServerContext* context)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_announce_response(RdpdrServerContext* context,
- wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_announce_response(RdpdrServerContext* context, wStream* s,
+ RDPDR_HEADER* header)
{
UINT32 ClientId;
UINT16 VersionMajor;
@@ -121,9 +115,10 @@ static UINT rdpdr_server_receive_announce_response(RdpdrServerContext* context,
Stream_Read_UINT16(s, VersionMajor); /* VersionMajor (2 bytes) */
Stream_Read_UINT16(s, VersionMinor); /* VersionMinor (2 bytes) */
- Stream_Read_UINT32(s, ClientId); /* ClientId (4 bytes) */
+ Stream_Read_UINT32(s, ClientId); /* ClientId (4 bytes) */
WLog_DBG(TAG,
- "Client Announce Response: VersionMajor: 0x%08"PRIX16" VersionMinor: 0x%04"PRIX16" ClientId: 0x%08"PRIX32"",
+ "Client Announce Response: VersionMajor: 0x%08" PRIX16 " VersionMinor: 0x%04" PRIX16
+ " ClientId: 0x%08" PRIX32 "",
VersionMajor, VersionMinor, ClientId);
context->priv->ClientId = ClientId;
return CHANNEL_RC_OK;
@@ -134,8 +129,8 @@ static UINT rdpdr_server_receive_announce_response(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
- context, wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext* context, wStream* s,
+ RDPDR_HEADER* header)
{
UINT32 UnicodeFlag;
UINT32 ComputerNameLen;
@@ -146,8 +141,8 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, UnicodeFlag); /* UnicodeFlag (4 bytes) */
- Stream_Seek_UINT32(s); /* CodePage (4 bytes), MUST be set to zero */
+ Stream_Read_UINT32(s, UnicodeFlag); /* UnicodeFlag (4 bytes) */
+ Stream_Seek_UINT32(s); /* CodePage (4 bytes), MUST be set to zero */
Stream_Read_UINT32(s, ComputerNameLen); /* ComputerNameLen (4 bytes) */
/* UnicodeFlag is either 0 or 1, the other 31 bits must be ignored.
*/
@@ -162,7 +157,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
{
if ((ComputerNameLen % 2) || ComputerNameLen > 512 || ComputerNameLen < 2)
{
- WLog_ERR(TAG, "invalid unicode computer name length: %"PRIu32"", ComputerNameLen);
+ WLog_ERR(TAG, "invalid unicode computer name length: %" PRIu32 "", ComputerNameLen);
return ERROR_INVALID_DATA;
}
}
@@ -170,7 +165,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
{
if (ComputerNameLen > 256 || ComputerNameLen < 1)
{
- WLog_ERR(TAG, "invalid ascii computer name length: %"PRIu32"", ComputerNameLen);
+ WLog_ERR(TAG, "invalid ascii computer name length: %" PRIu32 "", ComputerNameLen);
return ERROR_INVALID_DATA;
}
}
@@ -198,7 +193,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
if (UnicodeFlag)
{
- if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), -1,
+ if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)Stream_Pointer(s), -1,
&(context->priv->ClientComputerName), 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "failed to convert client computer name");
@@ -207,7 +202,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
}
else
{
- context->priv->ClientComputerName = _strdup((char*) Stream_Pointer(s));
+ context->priv->ClientComputerName = _strdup((char*)Stream_Pointer(s));
if (!context->priv->ClientComputerName)
{
@@ -226,8 +221,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_capability_set_header(wStream* s,
- RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_capability_set_header(wStream* s, RDPDR_CAPABILITY_HEADER* header)
{
if (Stream_GetRemainingLength(s) < 8)
{
@@ -235,10 +229,9 @@ static UINT rdpdr_server_read_capability_set_header(wStream* s,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
- Stream_Read_UINT16(s,
- header->CapabilityLength); /* CapabilityLength (2 bytes) */
- Stream_Read_UINT32(s, header->Version); /* Version (4 bytes) */
+ Stream_Read_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
+ Stream_Read_UINT16(s, header->CapabilityLength); /* CapabilityLength (2 bytes) */
+ Stream_Read_UINT32(s, header->Version); /* Version (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -247,8 +240,7 @@ static UINT rdpdr_server_read_capability_set_header(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_capability_set_header(wStream* s,
- RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_write_capability_set_header(wStream* s, RDPDR_CAPABILITY_HEADER* header)
{
if (!Stream_EnsureRemainingCapacity(s, 8))
{
@@ -256,10 +248,9 @@ static UINT rdpdr_server_write_capability_set_header(wStream* s,
return ERROR_INVALID_DATA;
}
- Stream_Write_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
- Stream_Write_UINT16(s,
- header->CapabilityLength); /* CapabilityLength (2 bytes) */
- Stream_Write_UINT32(s, header->Version); /* Version (4 bytes) */
+ Stream_Write_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
+ Stream_Write_UINT16(s, header->CapabilityLength); /* CapabilityLength (2 bytes) */
+ Stream_Write_UINT32(s, header->Version); /* Version (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -268,8 +259,8 @@ static UINT rdpdr_server_write_capability_set_header(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_general_capability_set(RdpdrServerContext*
- context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_general_capability_set(RdpdrServerContext* context, wStream* s,
+ RDPDR_CAPABILITY_HEADER* header)
{
UINT32 ioCode1;
UINT32 extraFlags1;
@@ -284,17 +275,15 @@ static UINT rdpdr_server_read_general_capability_set(RdpdrServerContext*
return ERROR_INVALID_DATA;
}
- Stream_Seek_UINT32(s); /* osType (4 bytes), ignored on receipt */
- Stream_Seek_UINT32(s); /* osVersion (4 bytes), unused and must be set to zero */
+ Stream_Seek_UINT32(s); /* osType (4 bytes), ignored on receipt */
+ Stream_Seek_UINT32(s); /* osVersion (4 bytes), unused and must be set to zero */
Stream_Read_UINT16(s, VersionMajor); /* protocolMajorVersion (2 bytes) */
Stream_Read_UINT16(s, VersionMinor); /* protocolMinorVersion (2 bytes) */
- Stream_Read_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
- Stream_Seek_UINT32(
- s); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
+ Stream_Read_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
+ Stream_Seek_UINT32(s); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
Stream_Read_UINT32(s, extendedPdu); /* extendedPdu (4 bytes) */
Stream_Read_UINT32(s, extraFlags1); /* extraFlags1 (4 bytes) */
- Stream_Seek_UINT32(
- s); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
+ Stream_Seek_UINT32(s); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
if (header->Version == GENERAL_CAPABILITY_VERSION_02)
{
@@ -304,12 +293,10 @@ static UINT rdpdr_server_read_general_capability_set(RdpdrServerContext*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s,
- SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
+ Stream_Read_UINT32(s, SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
}
- context->priv->UserLoggedOnPdu = (extendedPdu & RDPDR_USER_LOGGEDON_PDU) ?
- TRUE : FALSE;
+ context->priv->UserLoggedOnPdu = (extendedPdu & RDPDR_USER_LOGGEDON_PDU) ? TRUE : FALSE;
return CHANNEL_RC_OK;
}
@@ -318,8 +305,7 @@ static UINT rdpdr_server_read_general_capability_set(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext*
- context, wStream* s)
+static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext* context, wStream* s)
{
UINT32 ioCode1;
UINT32 extendedPdu;
@@ -330,25 +316,25 @@ static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext*
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH + 36;
header.Version = GENERAL_CAPABILITY_VERSION_02;
ioCode1 = 0;
- ioCode1 |= RDPDR_IRP_MJ_CREATE; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_CLEANUP; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_CLOSE; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_READ; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_WRITE; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_FLUSH_BUFFERS; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_SHUTDOWN; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_DEVICE_CONTROL; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_CREATE; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_CLEANUP; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_CLOSE; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_READ; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_WRITE; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_FLUSH_BUFFERS; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_SHUTDOWN; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_DEVICE_CONTROL; /* always set */
ioCode1 |= RDPDR_IRP_MJ_QUERY_VOLUME_INFORMATION; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_SET_VOLUME_INFORMATION; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_QUERY_INFORMATION; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_SET_INFORMATION; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_DIRECTORY_CONTROL; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_LOCK_CONTROL; /* always set */
- ioCode1 |= RDPDR_IRP_MJ_QUERY_SECURITY; /* optional */
- ioCode1 |= RDPDR_IRP_MJ_SET_SECURITY; /* optional */
+ ioCode1 |= RDPDR_IRP_MJ_SET_VOLUME_INFORMATION; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_QUERY_INFORMATION; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_SET_INFORMATION; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_DIRECTORY_CONTROL; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_LOCK_CONTROL; /* always set */
+ ioCode1 |= RDPDR_IRP_MJ_QUERY_SECURITY; /* optional */
+ ioCode1 |= RDPDR_IRP_MJ_SET_SECURITY; /* optional */
extendedPdu = 0;
extendedPdu |= RDPDR_CLIENT_DISPLAY_NAME_PDU; /* always set */
- extendedPdu |= RDPDR_DEVICE_REMOVE_PDUS; /* optional */
+ extendedPdu |= RDPDR_DEVICE_REMOVE_PDUS; /* optional */
if (context->priv->UserLoggedOnPdu)
extendedPdu |= RDPDR_USER_LOGGEDON_PDU; /* optional */
@@ -365,21 +351,16 @@ static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext*
rdpdr_server_write_capability_set_header(s, &header);
Stream_Write_UINT32(s, 0); /* osType (4 bytes), ignored on receipt */
- Stream_Write_UINT32(s,
- 0); /* osVersion (4 bytes), unused and must be set to zero */
- Stream_Write_UINT16(s,
- context->priv->VersionMajor); /* protocolMajorVersion (2 bytes) */
- Stream_Write_UINT16(s,
- context->priv->VersionMinor); /* protocolMinorVersion (2 bytes) */
- Stream_Write_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
- Stream_Write_UINT32(s,
- 0); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
+ Stream_Write_UINT32(s, 0); /* osVersion (4 bytes), unused and must be set to zero */
+ Stream_Write_UINT16(s, context->priv->VersionMajor); /* protocolMajorVersion (2 bytes) */
+ Stream_Write_UINT16(s, context->priv->VersionMinor); /* protocolMinorVersion (2 bytes) */
+ Stream_Write_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
+ Stream_Write_UINT32(s, 0); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
Stream_Write_UINT32(s, extendedPdu); /* extendedPdu (4 bytes) */
Stream_Write_UINT32(s, extraFlags1); /* extraFlags1 (4 bytes) */
- Stream_Write_UINT32(s,
- 0); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
- Stream_Write_UINT32(s,
- SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
+ Stream_Write_UINT32(
+ s, 0); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
+ Stream_Write_UINT32(s, SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -388,8 +369,8 @@ static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_printer_capability_set(RdpdrServerContext*
- context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_printer_capability_set(RdpdrServerContext* context, wStream* s,
+ RDPDR_CAPABILITY_HEADER* header)
{
return CHANNEL_RC_OK;
}
@@ -399,8 +380,7 @@ static UINT rdpdr_server_read_printer_capability_set(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_printer_capability_set(RdpdrServerContext*
- context, wStream* s)
+static UINT rdpdr_server_write_printer_capability_set(RdpdrServerContext* context, wStream* s)
{
RDPDR_CAPABILITY_HEADER header;
header.CapabilityType = CAP_PRINTER_TYPE;
@@ -421,8 +401,8 @@ static UINT rdpdr_server_write_printer_capability_set(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_port_capability_set(RdpdrServerContext* context,
- wStream* s, RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_port_capability_set(RdpdrServerContext* context, wStream* s,
+ RDPDR_CAPABILITY_HEADER* header)
{
return CHANNEL_RC_OK;
}
@@ -432,8 +412,7 @@ static UINT rdpdr_server_read_port_capability_set(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_port_capability_set(RdpdrServerContext* context,
- wStream* s)
+static UINT rdpdr_server_write_port_capability_set(RdpdrServerContext* context, wStream* s)
{
RDPDR_CAPABILITY_HEADER header;
header.CapabilityType = CAP_PORT_TYPE;
@@ -454,8 +433,8 @@ static UINT rdpdr_server_write_port_capability_set(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_drive_capability_set(RdpdrServerContext* context,
- wStream* s, RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_drive_capability_set(RdpdrServerContext* context, wStream* s,
+ RDPDR_CAPABILITY_HEADER* header)
{
return CHANNEL_RC_OK;
}
@@ -465,8 +444,7 @@ static UINT rdpdr_server_read_drive_capability_set(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_drive_capability_set(RdpdrServerContext* context,
- wStream* s)
+static UINT rdpdr_server_write_drive_capability_set(RdpdrServerContext* context, wStream* s)
{
RDPDR_CAPABILITY_HEADER header;
header.CapabilityType = CAP_DRIVE_TYPE;
@@ -487,8 +465,8 @@ static UINT rdpdr_server_write_drive_capability_set(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_read_smartcard_capability_set(RdpdrServerContext*
- context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
+static UINT rdpdr_server_read_smartcard_capability_set(RdpdrServerContext* context, wStream* s,
+ RDPDR_CAPABILITY_HEADER* header)
{
return CHANNEL_RC_OK;
}
@@ -498,8 +476,7 @@ static UINT rdpdr_server_read_smartcard_capability_set(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_write_smartcard_capability_set(
- RdpdrServerContext* context, wStream* s)
+static UINT rdpdr_server_write_smartcard_capability_set(RdpdrServerContext* context, wStream* s)
{
RDPDR_CAPABILITY_HEADER header;
header.CapabilityType = CAP_SMARTCARD_TYPE;
@@ -520,8 +497,7 @@ static UINT rdpdr_server_write_smartcard_capability_set(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
- context)
+static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext* context)
{
wStream* s;
BOOL status;
@@ -555,14 +531,14 @@ static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
}
Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
- Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
- Stream_Write_UINT16(s, numCapabilities); /* numCapabilities (2 bytes) */
- Stream_Write_UINT16(s, 0); /* Padding (2 bytes) */
+ Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
+ Stream_Write_UINT16(s, numCapabilities); /* numCapabilities (2 bytes) */
+ Stream_Write_UINT16(s, 0); /* Padding (2 bytes) */
if ((error = rdpdr_server_write_general_capability_set(context, s)))
{
- WLog_ERR(TAG,
- "rdpdr_server_write_general_capability_set failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpdr_server_write_general_capability_set failed with error %" PRIu32 "!",
+ error);
goto out;
}
@@ -570,7 +546,7 @@ static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
{
if ((error = rdpdr_server_write_drive_capability_set(context, s)))
{
- WLog_ERR(TAG, "rdpdr_server_write_drive_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "rdpdr_server_write_drive_capability_set failed with error %" PRIu32 "!",
error);
goto out;
}
@@ -580,7 +556,7 @@ static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
{
if ((error = rdpdr_server_write_port_capability_set(context, s)))
{
- WLog_ERR(TAG, "rdpdr_server_write_port_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "rdpdr_server_write_port_capability_set failed with error %" PRIu32 "!",
error);
goto out;
}
@@ -591,7 +567,8 @@ static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
if ((error = rdpdr_server_write_printer_capability_set(context, s)))
{
WLog_ERR(TAG,
- "rdpdr_server_write_printer_capability_set failed with error %"PRIu32"!", error);
+ "rdpdr_server_write_printer_capability_set failed with error %" PRIu32 "!",
+ error);
goto out;
}
}
@@ -601,15 +578,16 @@ static UINT rdpdr_server_send_core_capability_request(RdpdrServerContext*
if ((error = rdpdr_server_write_smartcard_capability_set(context, s)))
{
WLog_ERR(TAG,
- "rdpdr_server_write_printer_capability_set failed with error %"PRIu32"!", error);
+ "rdpdr_server_write_printer_capability_set failed with error %" PRIu32 "!",
+ error);
goto out;
}
}
Stream_SealLength(s);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
out:
@@ -622,8 +600,8 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_core_capability_response(
- RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_core_capability_response(RdpdrServerContext* context, wStream* s,
+ RDPDR_HEADER* header)
{
int i;
UINT status;
@@ -637,13 +615,13 @@ static UINT rdpdr_server_receive_core_capability_response(
}
Stream_Read_UINT16(s, numCapabilities); /* numCapabilities (2 bytes) */
- Stream_Seek_UINT16(s); /* Padding (2 bytes) */
+ Stream_Seek_UINT16(s); /* Padding (2 bytes) */
for (i = 0; i < numCapabilities; i++)
{
if ((status = rdpdr_server_read_capability_set_header(s, &capabilityHeader)))
{
- WLog_ERR(TAG, "rdpdr_server_read_capability_set_header failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "rdpdr_server_read_capability_set_header failed with error %" PRIu32 "!",
status);
return status;
}
@@ -651,10 +629,12 @@ static UINT rdpdr_server_receive_core_capability_response(
switch (capabilityHeader.CapabilityType)
{
case CAP_GENERAL_TYPE:
- if ((status = rdpdr_server_read_general_capability_set(context, s,
- &capabilityHeader)))
+ if ((status =
+ rdpdr_server_read_general_capability_set(context, s, &capabilityHeader)))
{
- WLog_ERR(TAG, "rdpdr_server_read_general_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_read_general_capability_set failed with error %" PRIu32
+ "!",
status);
return status;
}
@@ -662,10 +642,12 @@ static UINT rdpdr_server_receive_core_capability_response(
break;
case CAP_PRINTER_TYPE:
- if ((status = rdpdr_server_read_printer_capability_set(context, s,
- &capabilityHeader)))
+ if ((status =
+ rdpdr_server_read_printer_capability_set(context, s, &capabilityHeader)))
{
- WLog_ERR(TAG, "rdpdr_server_read_printer_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_read_printer_capability_set failed with error %" PRIu32
+ "!",
status);
return status;
}
@@ -673,10 +655,10 @@ static UINT rdpdr_server_receive_core_capability_response(
break;
case CAP_PORT_TYPE:
- if ((status = rdpdr_server_read_port_capability_set(context, s,
- &capabilityHeader)))
+ if ((status = rdpdr_server_read_port_capability_set(context, s, &capabilityHeader)))
{
- WLog_ERR(TAG, "rdpdr_server_read_port_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_read_port_capability_set failed with error %" PRIu32 "!",
status);
return status;
}
@@ -684,10 +666,12 @@ static UINT rdpdr_server_receive_core_capability_response(
break;
case CAP_DRIVE_TYPE:
- if ((status = rdpdr_server_read_drive_capability_set(context, s,
- &capabilityHeader)))
+ if ((status =
+ rdpdr_server_read_drive_capability_set(context, s, &capabilityHeader)))
{
- WLog_ERR(TAG, "rdpdr_server_read_drive_capability_set failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_read_drive_capability_set failed with error %" PRIu32
+ "!",
status);
return status;
}
@@ -695,20 +679,22 @@ static UINT rdpdr_server_receive_core_capability_response(
break;
case CAP_SMARTCARD_TYPE:
- if ((status = rdpdr_server_read_smartcard_capability_set(context, s,
- &capabilityHeader)))
+ if ((status =
+ rdpdr_server_read_smartcard_capability_set(context, s, &capabilityHeader)))
{
WLog_ERR(TAG,
- "rdpdr_server_read_smartcard_capability_set failed with error %"PRIu32"!", status);
+ "rdpdr_server_read_smartcard_capability_set failed with error %" PRIu32
+ "!",
+ status);
return status;
}
break;
default:
- WLog_DBG(TAG, "Unknown capabilityType %"PRIu16"", capabilityHeader.CapabilityType);
- Stream_Seek(s, capabilityHeader.CapabilityLength -
- RDPDR_CAPABILITY_HEADER_LENGTH);
+ WLog_DBG(TAG, "Unknown capabilityType %" PRIu16 "",
+ capabilityHeader.CapabilityType);
+ Stream_Seek(s, capabilityHeader.CapabilityLength - RDPDR_CAPABILITY_HEADER_LENGTH);
return ERROR_INVALID_DATA;
break;
}
@@ -739,17 +725,15 @@ static UINT rdpdr_server_send_client_id_confirm(RdpdrServerContext* context)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
- Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
- Stream_Write_UINT16(s,
- context->priv->VersionMajor); /* VersionMajor (2 bytes) */
- Stream_Write_UINT16(s,
- context->priv->VersionMinor); /* VersionMinor (2 bytes) */
- Stream_Write_UINT32(s, context->priv->ClientId); /* ClientId (4 bytes) */
+ Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
+ Stream_Write_UINT16(s, context->priv->VersionMajor); /* VersionMajor (2 bytes) */
+ Stream_Write_UINT16(s, context->priv->VersionMinor); /* VersionMinor (2 bytes) */
+ Stream_Write_UINT32(s, context->priv->ClientId); /* ClientId (4 bytes) */
Stream_SealLength(s);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -759,8 +743,8 @@ static UINT rdpdr_server_send_client_id_confirm(RdpdrServerContext* context)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_device_list_announce_request(
- RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_device_list_announce_request(RdpdrServerContext* context,
+ wStream* s, RDPDR_HEADER* header)
{
UINT32 i;
UINT32 DeviceCount;
@@ -776,7 +760,7 @@ static UINT rdpdr_server_receive_device_list_announce_request(
}
Stream_Read_UINT32(s, DeviceCount); /* DeviceCount (4 bytes) */
- WLog_DBG(TAG, "DeviceCount: %"PRIu32"", DeviceCount);
+ WLog_DBG(TAG, "DeviceCount: %" PRIu32 "", DeviceCount);
for (i = 0; i < DeviceCount; i++)
{
@@ -788,9 +772,9 @@ static UINT rdpdr_server_receive_device_list_announce_request(
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, DeviceType); /* DeviceType (4 bytes) */
- Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */
- Stream_Read(s, PreferredDosName, 8); /* PreferredDosName (8 bytes) */
+ Stream_Read_UINT32(s, DeviceType); /* DeviceType (4 bytes) */
+ Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */
+ Stream_Read(s, PreferredDosName, 8); /* PreferredDosName (8 bytes) */
Stream_Read_UINT32(s, DeviceDataLength); /* DeviceDataLength (4 bytes) */
if (Stream_GetRemainingLength(s) < DeviceDataLength)
@@ -799,8 +783,8 @@ static UINT rdpdr_server_receive_device_list_announce_request(
return ERROR_INVALID_DATA;
}
- WLog_DBG(TAG, "Device %d Name: %s Id: 0x%08"PRIX32" DataLength: %"PRIu32"",
- i, PreferredDosName, DeviceId, DeviceDataLength);
+ WLog_DBG(TAG, "Device %d Name: %s Id: 0x%08" PRIX32 " DataLength: %" PRIu32 "", i,
+ PreferredDosName, DeviceId, DeviceDataLength);
switch (DeviceType)
{
@@ -852,8 +836,8 @@ static UINT rdpdr_server_receive_device_list_announce_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_device_list_remove_request(
- RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_device_list_remove_request(RdpdrServerContext* context, wStream* s,
+ RDPDR_HEADER* header)
{
UINT32 i;
UINT32 DeviceCount;
@@ -867,7 +851,7 @@ static UINT rdpdr_server_receive_device_list_remove_request(
}
Stream_Read_UINT32(s, DeviceCount); /* DeviceCount (4 bytes) */
- WLog_DBG(TAG, "DeviceCount: %"PRIu32"", DeviceCount);
+ WLog_DBG(TAG, "DeviceCount: %" PRIu32 "", DeviceCount);
for (i = 0; i < DeviceCount; i++)
{
@@ -878,7 +862,7 @@ static UINT rdpdr_server_receive_device_list_remove_request(
}
Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */
- WLog_DBG(TAG, "Device %d Id: 0x%08"PRIX32"", i, DeviceId);
+ WLog_DBG(TAG, "Device %d Id: 0x%08" PRIX32 "", i, DeviceId);
DeviceType = 0; /* TODO: Save the device type on the announce request. */
switch (DeviceType)
@@ -929,8 +913,8 @@ static UINT rdpdr_server_receive_device_list_remove_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_device_io_completion(RdpdrServerContext*
- context, wStream* s, RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_device_io_completion(RdpdrServerContext* context, wStream* s,
+ RDPDR_HEADER* header)
{
UINT32 deviceId;
UINT32 completionId;
@@ -947,13 +931,13 @@ static UINT rdpdr_server_receive_device_io_completion(RdpdrServerContext*
Stream_Read_UINT32(s, deviceId);
Stream_Read_UINT32(s, completionId);
Stream_Read_UINT32(s, ioStatus);
- WLog_DBG(TAG, "deviceId=%"PRIu32", completionId=0x%"PRIx32", ioStatus=0x%"PRIx32"", deviceId,
- completionId, ioStatus);
+ WLog_DBG(TAG, "deviceId=%" PRIu32 ", completionId=0x%" PRIx32 ", ioStatus=0x%" PRIx32 "",
+ deviceId, completionId, ioStatus);
irp = rdpdr_server_dequeue_irp(context, completionId);
if (!irp)
{
- WLog_ERR(TAG, "IRP not found for completionId=0x%"PRIx32"", completionId);
+ WLog_ERR(TAG, "IRP not found for completionId=0x%" PRIx32 "", completionId);
return ERROR_INTERNAL_ERROR;
}
@@ -989,11 +973,11 @@ static UINT rdpdr_server_send_user_logged_on(RdpdrServerContext* context)
}
Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
- Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
+ Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
Stream_SealLength(s);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1003,11 +987,10 @@ static UINT rdpdr_server_send_user_logged_on(RdpdrServerContext* context)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
- RDPDR_HEADER* header)
+static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
{
UINT error = CHANNEL_RC_OK;
- WLog_DBG(TAG, "RdpdrServerReceivePdu: Component: 0x%04"PRIX16" PacketId: 0x%04"PRIX16"",
+ WLog_DBG(TAG, "RdpdrServerReceivePdu: Component: 0x%04" PRIX16 " PacketId: 0x%04" PRIX16 "",
header->Component, header->PacketId);
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), Stream_Length(s));
@@ -1018,7 +1001,9 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
case PAKID_CORE_CLIENTID_CONFIRM:
if ((error = rdpdr_server_receive_announce_response(context, s, header)))
{
- WLog_ERR(TAG, "rdpdr_server_receive_announce_response failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_receive_announce_response failed with error %" PRIu32
+ "!",
error);
return error;
}
@@ -1028,7 +1013,9 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
case PAKID_CORE_CLIENT_NAME:
if ((error = rdpdr_server_receive_client_name_request(context, s, header)))
{
- WLog_ERR(TAG, "rdpdr_server_receive_client_name_request failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_receive_client_name_request failed with error %" PRIu32
+ "!",
error);
return error;
}
@@ -1036,13 +1023,16 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
if ((error = rdpdr_server_send_core_capability_request(context)))
{
WLog_ERR(TAG,
- "rdpdr_server_send_core_capability_request failed with error %"PRIu32"!", error);
+ "rdpdr_server_send_core_capability_request failed with error %" PRIu32
+ "!",
+ error);
return error;
}
if ((error = rdpdr_server_send_client_id_confirm(context)))
{
- WLog_ERR(TAG, "rdpdr_server_send_client_id_confirm failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpdr_server_send_client_id_confirm failed with error %" PRIu32 "!",
error);
return error;
}
@@ -1052,26 +1042,31 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
case PAKID_CORE_CLIENT_CAPABILITY:
if ((error = rdpdr_server_receive_core_capability_response(context, s, header)))
{
- WLog_ERR(TAG,
- "rdpdr_server_receive_core_capability_response failed with error %"PRIu32"!", error);
+ WLog_ERR(
+ TAG,
+ "rdpdr_server_receive_core_capability_response failed with error %" PRIu32
+ "!",
+ error);
return error;
}
if (context->priv->UserLoggedOnPdu)
if ((error = rdpdr_server_send_user_logged_on(context)))
{
- WLog_ERR(TAG, "rdpdr_server_send_user_logged_on failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "rdpdr_server_send_user_logged_on failed with error %" PRIu32 "!",
+ error);
return error;
}
break;
case PAKID_CORE_DEVICELIST_ANNOUNCE:
- if ((error = rdpdr_server_receive_device_list_announce_request(context, s,
- header)))
+ if ((error = rdpdr_server_receive_device_list_announce_request(context, s, header)))
{
WLog_ERR(TAG,
- "rdpdr_server_receive_device_list_announce_request failed with error %"PRIu32"!",
+ "rdpdr_server_receive_device_list_announce_request failed with error "
+ "%" PRIu32 "!",
error);
return error;
}
@@ -1088,18 +1083,21 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
if ((error = rdpdr_server_receive_device_io_completion(context, s, header)))
{
WLog_ERR(TAG,
- "rdpdr_server_receive_device_io_completion failed with error %"PRIu32"!", error);
+ "rdpdr_server_receive_device_io_completion failed with error %" PRIu32
+ "!",
+ error);
return error;
}
break;
case PAKID_CORE_DEVICELIST_REMOVE:
- if ((error = rdpdr_server_receive_device_list_remove_request(context, s,
- header)))
+ if ((error = rdpdr_server_receive_device_list_remove_request(context, s, header)))
{
WLog_ERR(TAG,
- "rdpdr_server_receive_device_io_completion failed with error %"PRIu32"!", error);
+ "rdpdr_server_receive_device_io_completion failed with error %" PRIu32
+ "!",
+ error);
return error;
}
@@ -1125,7 +1123,7 @@ static UINT rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s,
}
else
{
- WLog_WARN(TAG, "Unknown RDPDR_HEADER.Component: 0x%04"PRIX16"", header->Component);
+ WLog_WARN(TAG, "Unknown RDPDR_HEADER.Component: 0x%04" PRIX16 "", header->Component);
return ERROR_INVALID_DATA;
}
@@ -1144,7 +1142,7 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
DWORD BytesReturned;
RdpdrServerContext* context;
UINT error;
- context = (RdpdrServerContext*) arg;
+ context = (RdpdrServerContext*)arg;
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
@@ -1157,8 +1155,8 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
goto out;
}
- if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle,
- &buffer, &BytesReturned) == TRUE)
+ if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer,
+ &BytesReturned) == TRUE)
{
if (BytesReturned == sizeof(HANDLE))
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
@@ -1172,8 +1170,7 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
if ((error = rdpdr_server_send_announce_request(context)))
{
- WLog_ERR(TAG, "rdpdr_server_send_announce_request failed with error %"PRIu32"!",
- error);
+ WLog_ERR(TAG, "rdpdr_server_send_announce_request failed with error %" PRIu32 "!", error);
goto out_stream;
}
@@ -1185,7 +1182,7 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
goto out_stream;
}
@@ -1194,15 +1191,15 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
goto out_stream;
}
if (status == WAIT_OBJECT_0)
break;
- if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
- (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned))
+ if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
+ Stream_Capacity(s), &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
error = ERROR_INTERNAL_ERROR;
@@ -1217,11 +1214,11 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg)
while (Stream_GetRemainingLength(s) >= RDPDR_HEADER_LENGTH)
{
Stream_Read_UINT16(s, header.Component); /* Component (2 bytes) */
- Stream_Read_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
+ Stream_Read_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
if ((error = rdpdr_server_receive_pdu(context, s, &header)))
{
- WLog_ERR(TAG, "rdpdr_server_receive_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpdr_server_receive_pdu failed with error %" PRIu32 "!", error);
goto out_stream;
}
}
@@ -1233,8 +1230,7 @@ out_stream:
out:
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "rdpdr_server_thread reported an error");
+ setChannelError(context->rdpcontext, error, "rdpdr_server_thread reported an error");
ExitThread(error);
return error;
@@ -1247,8 +1243,8 @@ out:
*/
static UINT rdpdr_server_start(RdpdrServerContext* context)
{
- context->priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm,
- WTS_CURRENT_SESSION, "rdpdr");
+ context->priv->ChannelHandle =
+ WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "rdpdr");
if (!context->priv->ChannelHandle)
{
@@ -1262,8 +1258,8 @@ static UINT rdpdr_server_start(RdpdrServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(context->priv->Thread = CreateThread(NULL, 0,
- rdpdr_server_thread, (void*) context, 0, NULL)))
+ if (!(context->priv->Thread =
+ CreateThread(NULL, 0, rdpdr_server_thread, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(context->priv->StopEvent);
@@ -1290,7 +1286,7 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context)
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -1303,21 +1299,17 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context)
return CHANNEL_RC_OK;
}
-static void rdpdr_server_write_device_iorequest(
- wStream* s,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId,
- UINT32 majorFunction,
- UINT32 minorFunction)
+static void rdpdr_server_write_device_iorequest(wStream* s, UINT32 deviceId, UINT32 fileId,
+ UINT32 completionId, UINT32 majorFunction,
+ UINT32 minorFunction)
{
- Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
+ Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(s, PAKID_CORE_DEVICE_IOREQUEST); /* PacketId (2 bytes) */
- Stream_Write_UINT32(s, deviceId); /* DeviceId (4 bytes) */
- Stream_Write_UINT32(s, fileId); /* FileId (4 bytes) */
- Stream_Write_UINT32(s, completionId); /* CompletionId (4 bytes) */
- Stream_Write_UINT32(s, majorFunction); /* MajorFunction (4 bytes) */
- Stream_Write_UINT32(s, minorFunction); /* MinorFunction (4 bytes) */
+ Stream_Write_UINT32(s, deviceId); /* DeviceId (4 bytes) */
+ Stream_Write_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Write_UINT32(s, completionId); /* CompletionId (4 bytes) */
+ Stream_Write_UINT32(s, majorFunction); /* MajorFunction (4 bytes) */
+ Stream_Write_UINT32(s, minorFunction); /* MinorFunction (4 bytes) */
}
/**
@@ -1326,7 +1318,7 @@ static void rdpdr_server_write_device_iorequest(
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpdr_server_read_file_directory_information(wStream* s,
- FILE_DIRECTORY_INFORMATION* fdi)
+ FILE_DIRECTORY_INFORMATION* fdi)
{
UINT32 fileNameLength;
ZeroMemory(fdi, sizeof(FILE_DIRECTORY_INFORMATION));
@@ -1338,15 +1330,15 @@ static UINT rdpdr_server_read_file_directory_information(wStream* s,
}
Stream_Read_UINT32(s, fdi->NextEntryOffset); /* NextEntryOffset (4 bytes) */
- Stream_Read_UINT32(s, fdi->FileIndex); /* FileIndex (4 bytes) */
- Stream_Read_UINT64(s, fdi->CreationTime); /* CreationTime (8 bytes) */
- Stream_Read_UINT64(s, fdi->LastAccessTime); /* LastAccessTime (8 bytes) */
- Stream_Read_UINT64(s, fdi->LastWriteTime); /* LastWriteTime (8 bytes) */
- Stream_Read_UINT64(s, fdi->ChangeTime); /* ChangeTime (8 bytes) */
- Stream_Read_UINT64(s, fdi->EndOfFile); /* EndOfFile (8 bytes) */
- Stream_Read_UINT64(s, fdi->AllocationSize); /* AllocationSize (8 bytes) */
- Stream_Read_UINT32(s, fdi->FileAttributes); /* FileAttributes (4 bytes) */
- Stream_Read_UINT32(s, fileNameLength); /* FileNameLength (4 bytes) */
+ Stream_Read_UINT32(s, fdi->FileIndex); /* FileIndex (4 bytes) */
+ Stream_Read_UINT64(s, fdi->CreationTime); /* CreationTime (8 bytes) */
+ Stream_Read_UINT64(s, fdi->LastAccessTime); /* LastAccessTime (8 bytes) */
+ Stream_Read_UINT64(s, fdi->LastWriteTime); /* LastWriteTime (8 bytes) */
+ Stream_Read_UINT64(s, fdi->ChangeTime); /* ChangeTime (8 bytes) */
+ Stream_Read_UINT64(s, fdi->EndOfFile); /* EndOfFile (8 bytes) */
+ Stream_Read_UINT64(s, fdi->AllocationSize); /* AllocationSize (8 bytes) */
+ Stream_Read_UINT32(s, fdi->FileAttributes); /* FileAttributes (4 bytes) */
+ Stream_Read_UINT32(s, fileNameLength); /* FileNameLength (4 bytes) */
if (Stream_GetRemainingLength(s) < fileNameLength)
{
@@ -1354,8 +1346,8 @@ static UINT rdpdr_server_read_file_directory_information(wStream* s,
return ERROR_INVALID_DATA;
}
- WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) Stream_Pointer(s), fileNameLength / 2,
- fdi->FileName, sizeof(fdi->FileName), NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)Stream_Pointer(s), fileNameLength / 2, fdi->FileName,
+ sizeof(fdi->FileName), NULL, NULL);
Stream_Seek(s, fileNameLength);
return CHANNEL_RC_OK;
}
@@ -1365,21 +1357,19 @@ static UINT rdpdr_server_read_file_directory_information(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_create_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 completionId,
- const char* path,
- UINT32 desiredAccess,
- UINT32 createOptions,
- UINT32 createDisposition)
+static UINT rdpdr_server_send_device_create_request(RdpdrServerContext* context, UINT32 deviceId,
+ UINT32 completionId, const char* path,
+ UINT32 desiredAccess, UINT32 createOptions,
+ UINT32 createDisposition)
{
UINT32 pathLength;
ULONG written;
BOOL status;
wStream* s;
WLog_DBG(TAG,
- "RdpdrServerSendDeviceCreateRequest: deviceId=%"PRIu32", path=%s, desiredAccess=0x%"PRIx32" createOptions=0x%"PRIx32" createDisposition=0x%"PRIx32"",
+ "RdpdrServerSendDeviceCreateRequest: deviceId=%" PRIu32
+ ", path=%s, desiredAccess=0x%" PRIx32 " createOptions=0x%" PRIx32
+ " createDisposition=0x%" PRIx32 "",
deviceId, path, desiredAccess, createOptions, createDisposition);
/* Compute the required Unicode size. */
pathLength = (strlen(path) + 1) * sizeof(WCHAR);
@@ -1391,23 +1381,21 @@ static UINT rdpdr_server_send_device_create_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, 0, completionId, IRP_MJ_CREATE,
- 0);
+ rdpdr_server_write_device_iorequest(s, deviceId, 0, completionId, IRP_MJ_CREATE, 0);
Stream_Write_UINT32(s, desiredAccess); /* DesiredAccess (4 bytes) */
- Stream_Write_UINT32(s, 0); /* AllocationSize (8 bytes) */
+ Stream_Write_UINT32(s, 0); /* AllocationSize (8 bytes) */
Stream_Write_UINT32(s, 0);
- Stream_Write_UINT32(s, 0); /* FileAttributes (4 bytes) */
- Stream_Write_UINT32(s, 3); /* SharedAccess (4 bytes) */
+ Stream_Write_UINT32(s, 0); /* FileAttributes (4 bytes) */
+ Stream_Write_UINT32(s, 3); /* SharedAccess (4 bytes) */
Stream_Write_UINT32(s, createDisposition); /* CreateDisposition (4 bytes) */
- Stream_Write_UINT32(s, createOptions); /* CreateOptions (4 bytes) */
- Stream_Write_UINT32(s, pathLength); /* PathLength (4 bytes) */
+ Stream_Write_UINT32(s, createOptions); /* CreateOptions (4 bytes) */
+ Stream_Write_UINT32(s, pathLength); /* PathLength (4 bytes) */
/* Convert the path to Unicode. */
- MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR) Stream_Pointer(s),
- pathLength);
+ MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR)Stream_Pointer(s), pathLength);
Stream_Seek(s, pathLength);
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1417,16 +1405,13 @@ static UINT rdpdr_server_send_device_create_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_close_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId)
+static UINT rdpdr_server_send_device_close_request(RdpdrServerContext* context, UINT32 deviceId,
+ UINT32 fileId, UINT32 completionId)
{
ULONG written;
BOOL status;
wStream* s;
- WLog_DBG(TAG, "RdpdrServerSendDeviceCloseRequest: deviceId=%"PRIu32", fileId=%"PRIu32"",
+ WLog_DBG(TAG, "RdpdrServerSendDeviceCloseRequest: deviceId=%" PRIu32 ", fileId=%" PRIu32 "",
deviceId, fileId);
s = Stream_New(NULL, 128);
@@ -1436,12 +1421,11 @@ static UINT rdpdr_server_send_device_close_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId,
- IRP_MJ_CLOSE, 0);
+ rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId, IRP_MJ_CLOSE, 0);
Stream_Zero(s, 32); /* Padding (32 bytes) */
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1451,19 +1435,16 @@ static UINT rdpdr_server_send_device_close_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_read_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId,
- UINT32 length,
- UINT32 offset)
+static UINT rdpdr_server_send_device_read_request(RdpdrServerContext* context, UINT32 deviceId,
+ UINT32 fileId, UINT32 completionId, UINT32 length,
+ UINT32 offset)
{
ULONG written;
BOOL status;
wStream* s;
WLog_DBG(TAG,
- "RdpdrServerSendDeviceReadRequest: deviceId=%"PRIu32", fileId=%"PRIu32", length=%"PRIu32", offset=%"PRIu32"",
+ "RdpdrServerSendDeviceReadRequest: deviceId=%" PRIu32 ", fileId=%" PRIu32
+ ", length=%" PRIu32 ", offset=%" PRIu32 "",
deviceId, fileId, length, offset);
s = Stream_New(NULL, 128);
@@ -1473,15 +1454,14 @@ static UINT rdpdr_server_send_device_read_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId,
- IRP_MJ_READ, 0);
+ rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId, IRP_MJ_READ, 0);
Stream_Write_UINT32(s, length); /* Length (4 bytes) */
Stream_Write_UINT32(s, offset); /* Offset (8 bytes) */
Stream_Write_UINT32(s, 0);
Stream_Zero(s, 20); /* Padding (20 bytes) */
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1491,20 +1471,16 @@ static UINT rdpdr_server_send_device_read_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_write_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId,
- const char* data,
- UINT32 length,
- UINT32 offset)
+static UINT rdpdr_server_send_device_write_request(RdpdrServerContext* context, UINT32 deviceId,
+ UINT32 fileId, UINT32 completionId,
+ const char* data, UINT32 length, UINT32 offset)
{
ULONG written;
BOOL status;
wStream* s;
WLog_DBG(TAG,
- "RdpdrServerSendDeviceWriteRequest: deviceId=%"PRIu32", fileId=%"PRIu32", length=%"PRIu32", offset=%"PRIu32"",
+ "RdpdrServerSendDeviceWriteRequest: deviceId=%" PRIu32 ", fileId=%" PRIu32
+ ", length=%" PRIu32 ", offset=%" PRIu32 "",
deviceId, fileId, length, offset);
s = Stream_New(NULL, 64 + length);
@@ -1514,16 +1490,15 @@ static UINT rdpdr_server_send_device_write_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId,
- IRP_MJ_WRITE, 0);
+ rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId, IRP_MJ_WRITE, 0);
Stream_Write_UINT32(s, length); /* Length (4 bytes) */
Stream_Write_UINT32(s, offset); /* Offset (8 bytes) */
Stream_Write_UINT32(s, 0);
- Stream_Zero(s, 20); /* Padding (20 bytes) */
+ Stream_Zero(s, 20); /* Padding (20 bytes) */
Stream_Write(s, data, length); /* WriteData (variable) */
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1533,19 +1508,17 @@ static UINT rdpdr_server_send_device_write_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_query_directory_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId,
- const char* path)
+static UINT rdpdr_server_send_device_query_directory_request(RdpdrServerContext* context,
+ UINT32 deviceId, UINT32 fileId,
+ UINT32 completionId, const char* path)
{
UINT32 pathLength;
ULONG written;
BOOL status;
wStream* s;
WLog_DBG(TAG,
- "RdpdrServerSendDeviceQueryDirectoryRequest: deviceId=%"PRIu32", fileId=%"PRIu32", path=%s",
+ "RdpdrServerSendDeviceQueryDirectoryRequest: deviceId=%" PRIu32 ", fileId=%" PRIu32
+ ", path=%s",
deviceId, fileId, path);
/* Compute the required Unicode size. */
pathLength = path ? (strlen(path) + 1) * sizeof(WCHAR) : 0;
@@ -1557,25 +1530,23 @@ static UINT rdpdr_server_send_device_query_directory_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId,
- IRP_MJ_DIRECTORY_CONTROL, IRP_MN_QUERY_DIRECTORY);
- Stream_Write_UINT32(s,
- FileDirectoryInformation); /* FsInformationClass (4 bytes) */
- Stream_Write_UINT8(s, path ? 1 : 0); /* InitialQuery (1 byte) */
- Stream_Write_UINT32(s, pathLength); /* PathLength (4 bytes) */
- Stream_Zero(s, 23); /* Padding (23 bytes) */
+ rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId, IRP_MJ_DIRECTORY_CONTROL,
+ IRP_MN_QUERY_DIRECTORY);
+ Stream_Write_UINT32(s, FileDirectoryInformation); /* FsInformationClass (4 bytes) */
+ Stream_Write_UINT8(s, path ? 1 : 0); /* InitialQuery (1 byte) */
+ Stream_Write_UINT32(s, pathLength); /* PathLength (4 bytes) */
+ Stream_Zero(s, 23); /* Padding (23 bytes) */
/* Convert the path to Unicode. */
if (pathLength > 0)
{
- MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR) Stream_Pointer(s),
- pathLength);
+ MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR)Stream_Pointer(s), pathLength);
Stream_Seek(s, pathLength);
}
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1585,19 +1556,17 @@ static UINT rdpdr_server_send_device_query_directory_request(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_send_device_file_rename_request(
- RdpdrServerContext* context,
- UINT32 deviceId,
- UINT32 fileId,
- UINT32 completionId,
- const char* path)
+static UINT rdpdr_server_send_device_file_rename_request(RdpdrServerContext* context,
+ UINT32 deviceId, UINT32 fileId,
+ UINT32 completionId, const char* path)
{
UINT32 pathLength;
ULONG written;
BOOL status;
wStream* s;
WLog_DBG(TAG,
- "RdpdrServerSendDeviceFileNameRequest: deviceId=%"PRIu32", fileId=%"PRIu32", path=%s",
+ "RdpdrServerSendDeviceFileNameRequest: deviceId=%" PRIu32 ", fileId=%" PRIu32
+ ", path=%s",
deviceId, fileId, path);
/* Compute the required Unicode size. */
pathLength = path ? (strlen(path) + 1) * sizeof(WCHAR) : 0;
@@ -1609,28 +1578,26 @@ static UINT rdpdr_server_send_device_file_rename_request(
return CHANNEL_RC_NO_MEMORY;
}
- rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId,
- IRP_MJ_SET_INFORMATION, 0);
- Stream_Write_UINT32(s,
- FileRenameInformation); /* FsInformationClass (4 bytes) */
- Stream_Write_UINT32(s, pathLength + 6); /* Length (4 bytes) */
- Stream_Zero(s, 24); /* Padding (24 bytes) */
+ rdpdr_server_write_device_iorequest(s, deviceId, fileId, completionId, IRP_MJ_SET_INFORMATION,
+ 0);
+ Stream_Write_UINT32(s, FileRenameInformation); /* FsInformationClass (4 bytes) */
+ Stream_Write_UINT32(s, pathLength + 6); /* Length (4 bytes) */
+ Stream_Zero(s, 24); /* Padding (24 bytes) */
/* RDP_FILE_RENAME_INFORMATION */
- Stream_Write_UINT8(s, 0); /* ReplaceIfExists (1 byte) */
- Stream_Write_UINT8(s, 0); /* RootDirectory (1 byte) */
+ Stream_Write_UINT8(s, 0); /* ReplaceIfExists (1 byte) */
+ Stream_Write_UINT8(s, 0); /* RootDirectory (1 byte) */
Stream_Write_UINT32(s, pathLength); /* FileNameLength (4 bytes) */
/* Convert the path to Unicode. */
if (pathLength > 0)
{
- MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR) Stream_Pointer(s),
- pathLength);
+ MultiByteToWideChar(CP_ACP, 0, path, -1, (LPWSTR)Stream_Pointer(s), pathLength);
Stream_Seek(s, pathLength);
}
Stream_SealLength(s);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &written);
Stream_Free(s, TRUE);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -1655,12 +1622,13 @@ static void rdpdr_server_convert_slashes(char* path, int size)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_create_directory_callback2(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_create_directory_callback2(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
WLog_DBG(TAG,
- "RdpdrServerDriveCreateDirectoryCallback2: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveCreateDirectoryCallback2: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
/* Invoke the create directory completion routine. */
context->OnDriveCreateDirectoryComplete(context, irp->CallbackData, ioStatus);
@@ -1674,14 +1642,15 @@ static UINT rdpdr_server_drive_create_directory_callback2(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_create_directory_callback1(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_create_directory_callback1(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
UINT8 information;
WLog_DBG(TAG,
- "RdpdrServerDriveCreateDirectoryCallback1: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveCreateDirectoryCallback1: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (ioStatus != STATUS_SUCCESS)
@@ -1699,7 +1668,7 @@ static UINT rdpdr_server_drive_create_directory_callback1(
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
Stream_Read_UINT8(s, information); /* Information (1 byte) */
/* Setup the IRP. */
irp->CompletionId = context->priv->NextCompletionId++;
@@ -1715,8 +1684,7 @@ static UINT rdpdr_server_drive_create_directory_callback1(
}
/* Send a request to close the file */
- return rdpdr_server_send_device_close_request(context, deviceId, fileId,
- irp->CompletionId);
+ return rdpdr_server_send_device_close_request(context, deviceId, fileId, irp->CompletionId);
}
/**
@@ -1724,8 +1692,8 @@ static UINT rdpdr_server_drive_create_directory_callback1(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_create_directory(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* path)
+static UINT rdpdr_server_drive_create_directory(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -1751,10 +1719,9 @@ static UINT rdpdr_server_drive_create_directory(RdpdrServerContext* context,
}
/* Send a request to open the file. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- FILE_READ_DATA | SYNCHRONIZE,
- FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_CREATE);
+ return rdpdr_server_send_device_create_request(
+ context, deviceId, irp->CompletionId, irp->PathName, FILE_READ_DATA | SYNCHRONIZE,
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_CREATE);
}
/*************************************************
@@ -1766,12 +1733,13 @@ static UINT rdpdr_server_drive_create_directory(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_directory_callback2(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_delete_directory_callback2(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
WLog_DBG(TAG,
- "RdpdrServerDriveDeleteDirectoryCallback2: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveDeleteDirectoryCallback2: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
/* Invoke the delete directory completion routine. */
context->OnDriveDeleteDirectoryComplete(context, irp->CallbackData, ioStatus);
@@ -1785,14 +1753,15 @@ static UINT rdpdr_server_drive_delete_directory_callback2(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_directory_callback1(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_delete_directory_callback1(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
UINT8 information;
WLog_DBG(TAG,
- "RdpdrServerDriveDeleteDirectoryCallback1: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveDeleteDirectoryCallback1: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (ioStatus != STATUS_SUCCESS)
@@ -1810,7 +1779,7 @@ static UINT rdpdr_server_drive_delete_directory_callback1(
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
Stream_Read_UINT8(s, information); /* Information (1 byte) */
/* Setup the IRP. */
irp->CompletionId = context->priv->NextCompletionId++;
@@ -1826,8 +1795,7 @@ static UINT rdpdr_server_drive_delete_directory_callback1(
}
/* Send a request to close the file */
- return rdpdr_server_send_device_close_request(context, deviceId, fileId,
- irp->CompletionId);
+ return rdpdr_server_send_device_close_request(context, deviceId, fileId, irp->CompletionId);
}
/**
@@ -1835,8 +1803,8 @@ static UINT rdpdr_server_drive_delete_directory_callback1(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_directory(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* path)
+static UINT rdpdr_server_drive_delete_directory(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -1862,10 +1830,9 @@ static UINT rdpdr_server_drive_delete_directory(RdpdrServerContext* context,
}
/* Send a request to open the file. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- DELETE | SYNCHRONIZE, FILE_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE |
- FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
+ return rdpdr_server_send_device_create_request(
+ context, deviceId, irp->CompletionId, irp->PathName, DELETE | SYNCHRONIZE,
+ FILE_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
}
/*************************************************
@@ -1877,15 +1844,16 @@ static UINT rdpdr_server_drive_delete_directory(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_query_directory_callback2(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_query_directory_callback2(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT error;
UINT32 length;
FILE_DIRECTORY_INFORMATION fdi;
WLog_DBG(TAG,
- "RdpdrServerDriveQueryDirectoryCallback2: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveQueryDirectoryCallback2: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (Stream_GetRemainingLength(s) < 4)
@@ -1901,7 +1869,8 @@ static UINT rdpdr_server_drive_query_directory_callback2(
if ((error = rdpdr_server_read_file_directory_information(s, &fdi)))
{
WLog_ERR(TAG,
- "rdpdr_server_read_file_directory_information failed with error %"PRIu32"!", error);
+ "rdpdr_server_read_file_directory_information failed with error %" PRIu32 "!",
+ error);
return error;
}
}
@@ -1933,14 +1902,13 @@ static UINT rdpdr_server_drive_query_directory_callback2(
}
/* Send a request to query the directory. */
- return rdpdr_server_send_device_query_directory_request(context, irp->DeviceId,
- irp->FileId, irp->CompletionId, NULL);
+ return rdpdr_server_send_device_query_directory_request(context, irp->DeviceId, irp->FileId,
+ irp->CompletionId, NULL);
}
else
{
/* Invoke the query directory completion routine. */
- context->OnDriveQueryDirectoryComplete(context, irp->CallbackData, ioStatus,
- NULL);
+ context->OnDriveQueryDirectoryComplete(context, irp->CallbackData, ioStatus, NULL);
/* Destroy the IRP. */
rdpdr_server_irp_free(irp);
}
@@ -1953,20 +1921,20 @@ static UINT rdpdr_server_drive_query_directory_callback2(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_query_directory_callback1(
- RdpdrServerContext* context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId,
- UINT32 completionId, UINT32 ioStatus)
+static UINT rdpdr_server_drive_query_directory_callback1(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
WLog_DBG(TAG,
- "RdpdrServerDriveQueryDirectoryCallback1: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveQueryDirectoryCallback1: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (ioStatus != STATUS_SUCCESS)
{
/* Invoke the query directory completion routine. */
- context->OnDriveQueryDirectoryComplete(context, irp->CallbackData, ioStatus,
- NULL);
+ context->OnDriveQueryDirectoryComplete(context, irp->CallbackData, ioStatus, NULL);
/* Destroy the IRP. */
rdpdr_server_irp_free(irp);
return CHANNEL_RC_OK;
@@ -1994,8 +1962,8 @@ static UINT rdpdr_server_drive_query_directory_callback1(
}
/* Send a request to query the directory. */
- return rdpdr_server_send_device_query_directory_request(context, deviceId,
- fileId, irp->CompletionId, irp->PathName);
+ return rdpdr_server_send_device_query_directory_request(context, deviceId, fileId,
+ irp->CompletionId, irp->PathName);
}
/**
@@ -2003,8 +1971,8 @@ static UINT rdpdr_server_drive_query_directory_callback1(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_query_directory(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* path)
+static UINT rdpdr_server_drive_query_directory(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2030,10 +1998,9 @@ static UINT rdpdr_server_drive_query_directory(RdpdrServerContext* context,
}
/* Send a request to open the directory. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- FILE_READ_DATA | SYNCHRONIZE,
- FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
+ return rdpdr_server_send_device_create_request(
+ context, deviceId, irp->CompletionId, irp->PathName, FILE_READ_DATA | SYNCHRONIZE,
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
}
/*************************************************
@@ -2045,14 +2012,15 @@ static UINT rdpdr_server_drive_query_directory(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context,
- wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
UINT8 information;
WLog_DBG(TAG,
- "RdpdrServerDriveOpenFileCallback: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveOpenFileCallback: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (Stream_GetRemainingLength(s) < 5)
@@ -2061,11 +2029,10 @@ static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
Stream_Read_UINT8(s, information); /* Information (1 byte) */
/* Invoke the open file completion routine. */
- context->OnDriveOpenFileComplete(context, irp->CallbackData, ioStatus, deviceId,
- fileId);
+ context->OnDriveOpenFileComplete(context, irp->CallbackData, ioStatus, deviceId, fileId);
/* Destroy the IRP. */
rdpdr_server_irp_free(irp);
return CHANNEL_RC_OK;
@@ -2076,9 +2043,9 @@ static UINT rdpdr_server_drive_open_file_callback(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_open_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* path, UINT32 desiredAccess,
- UINT32 createDisposition)
+static UINT rdpdr_server_drive_open_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path, UINT32 desiredAccess,
+ UINT32 createDisposition)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2104,9 +2071,9 @@ static UINT rdpdr_server_drive_open_file(RdpdrServerContext* context,
}
/* Send a request to open the file. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- desiredAccess | SYNCHRONIZE, FILE_SYNCHRONOUS_IO_NONALERT, createDisposition);
+ return rdpdr_server_send_device_create_request(context, deviceId, irp->CompletionId,
+ irp->PathName, desiredAccess | SYNCHRONIZE,
+ FILE_SYNCHRONOUS_IO_NONALERT, createDisposition);
}
/*************************************************
@@ -2118,14 +2085,15 @@ static UINT rdpdr_server_drive_open_file(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_read_file_callback(RdpdrServerContext* context,
- wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_read_file_callback(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 length;
char* buffer = NULL;
WLog_DBG(TAG,
- "RdpdrServerDriveReadFileCallback: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveReadFileCallback: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (Stream_GetRemainingLength(s) < 4)
@@ -2144,13 +2112,12 @@ static UINT rdpdr_server_drive_read_file_callback(RdpdrServerContext* context,
if (length > 0)
{
- buffer = (char*) Stream_Pointer(s);
+ buffer = (char*)Stream_Pointer(s);
Stream_Seek(s, length);
}
/* Invoke the read file completion routine. */
- context->OnDriveReadFileComplete(context, irp->CallbackData, ioStatus, buffer,
- length);
+ context->OnDriveReadFileComplete(context, irp->CallbackData, ioStatus, buffer, length);
/* Destroy the IRP. */
rdpdr_server_irp_free(irp);
return CHANNEL_RC_OK;
@@ -2161,9 +2128,9 @@ static UINT rdpdr_server_drive_read_file_callback(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_read_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, UINT32 fileId, UINT32 length,
- UINT32 offset)
+static UINT rdpdr_server_drive_read_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId, UINT32 length,
+ UINT32 offset)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2188,8 +2155,8 @@ static UINT rdpdr_server_drive_read_file(RdpdrServerContext* context,
}
/* Send a request to open the directory. */
- return rdpdr_server_send_device_read_request(context, deviceId, fileId,
- irp->CompletionId, length, offset);
+ return rdpdr_server_send_device_read_request(context, deviceId, fileId, irp->CompletionId,
+ length, offset);
}
/*************************************************
@@ -2201,13 +2168,14 @@ static UINT rdpdr_server_drive_read_file(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_write_file_callback(RdpdrServerContext* context,
- wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_write_file_callback(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 length;
WLog_DBG(TAG,
- "RdpdrServerDriveWriteFileCallback: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveWriteFileCallback: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (Stream_GetRemainingLength(s) < 5)
@@ -2217,7 +2185,7 @@ static UINT rdpdr_server_drive_write_file_callback(RdpdrServerContext* context,
}
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
- Stream_Seek(s, 1); /* Padding (1 byte) */
+ Stream_Seek(s, 1); /* Padding (1 byte) */
if (Stream_GetRemainingLength(s) < length)
{
@@ -2237,9 +2205,9 @@ static UINT rdpdr_server_drive_write_file_callback(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_write_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, UINT32 fileId, const char* buffer,
- UINT32 length, UINT32 offset)
+static UINT rdpdr_server_drive_write_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId, const char* buffer,
+ UINT32 length, UINT32 offset)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2264,8 +2232,8 @@ static UINT rdpdr_server_drive_write_file(RdpdrServerContext* context,
}
/* Send a request to open the directory. */
- return rdpdr_server_send_device_write_request(context, deviceId, fileId,
- irp->CompletionId, buffer, length, offset);
+ return rdpdr_server_send_device_write_request(context, deviceId, fileId, irp->CompletionId,
+ buffer, length, offset);
}
/*************************************************
@@ -2277,12 +2245,13 @@ static UINT rdpdr_server_drive_write_file(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_close_file_callback(RdpdrServerContext* context,
- wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_close_file_callback(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
WLog_DBG(TAG,
- "RdpdrServerDriveCloseFileCallback: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveCloseFileCallback: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
/* Invoke the close file completion routine. */
context->OnDriveCloseFileComplete(context, irp->CallbackData, ioStatus);
@@ -2296,8 +2265,8 @@ static UINT rdpdr_server_drive_close_file_callback(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_close_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, UINT32 fileId)
+static UINT rdpdr_server_drive_close_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2322,8 +2291,7 @@ static UINT rdpdr_server_drive_close_file(RdpdrServerContext* context,
}
/* Send a request to open the directory. */
- return rdpdr_server_send_device_close_request(context, deviceId, fileId,
- irp->CompletionId);
+ return rdpdr_server_send_device_close_request(context, deviceId, fileId, irp->CompletionId);
}
/*************************************************
@@ -2335,12 +2303,13 @@ static UINT rdpdr_server_drive_close_file(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_file_callback2(RdpdrServerContext*
- context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_delete_file_callback2(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
WLog_DBG(TAG,
- "RdpdrServerDriveDeleteFileCallback2: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveDeleteFileCallback2: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
/* Invoke the delete file completion routine. */
context->OnDriveDeleteFileComplete(context, irp->CallbackData, ioStatus);
@@ -2354,14 +2323,15 @@ static UINT rdpdr_server_drive_delete_file_callback2(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext*
- context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
UINT8 information;
WLog_DBG(TAG,
- "RdpdrServerDriveDeleteFileCallback1: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveDeleteFileCallback1: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (ioStatus != STATUS_SUCCESS)
@@ -2379,7 +2349,7 @@ static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
Stream_Read_UINT8(s, information); /* Information (1 byte) */
/* Setup the IRP. */
irp->CompletionId = context->priv->NextCompletionId++;
@@ -2395,8 +2365,7 @@ static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext*
}
/* Send a request to close the file */
- return rdpdr_server_send_device_close_request(context, deviceId, fileId,
- irp->CompletionId);
+ return rdpdr_server_send_device_close_request(context, deviceId, fileId, irp->CompletionId);
}
/**
@@ -2404,8 +2373,8 @@ static UINT rdpdr_server_drive_delete_file_callback1(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_delete_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* path)
+static UINT rdpdr_server_drive_delete_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2431,10 +2400,9 @@ static UINT rdpdr_server_drive_delete_file(RdpdrServerContext* context,
}
/* Send a request to open the file. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- FILE_READ_DATA | SYNCHRONIZE,
- FILE_DELETE_ON_CLOSE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
+ return rdpdr_server_send_device_create_request(
+ context, deviceId, irp->CompletionId, irp->PathName, FILE_READ_DATA | SYNCHRONIZE,
+ FILE_DELETE_ON_CLOSE | FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
}
/*************************************************
@@ -2446,12 +2414,13 @@ static UINT rdpdr_server_drive_delete_file(RdpdrServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_rename_file_callback3(RdpdrServerContext*
- context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_rename_file_callback3(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
WLog_DBG(TAG,
- "RdpdrServerDriveRenameFileCallback3: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveRenameFileCallback3: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
/* Destroy the IRP. */
rdpdr_server_irp_free(irp);
@@ -2463,13 +2432,14 @@ static UINT rdpdr_server_drive_rename_file_callback3(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_rename_file_callback2(RdpdrServerContext*
- context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_rename_file_callback2(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 length;
WLog_DBG(TAG,
- "RdpdrServerDriveRenameFileCallback2: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveRenameFileCallback2: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (Stream_GetRemainingLength(s) < 5)
@@ -2479,7 +2449,7 @@ static UINT rdpdr_server_drive_rename_file_callback2(RdpdrServerContext*
}
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
- Stream_Seek(s, 1); /* Padding (1 byte) */
+ Stream_Seek(s, 1); /* Padding (1 byte) */
/* Invoke the rename file completion routine. */
context->OnDriveRenameFileComplete(context, irp->CallbackData, ioStatus);
/* Setup the IRP. */
@@ -2496,7 +2466,7 @@ static UINT rdpdr_server_drive_rename_file_callback2(RdpdrServerContext*
/* Send a request to close the file */
return rdpdr_server_send_device_close_request(context, deviceId, irp->FileId,
- irp->CompletionId);
+ irp->CompletionId);
}
/**
@@ -2504,14 +2474,15 @@ static UINT rdpdr_server_drive_rename_file_callback2(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext*
- context, wStream* s, RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId,
- UINT32 ioStatus)
+static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext* context, wStream* s,
+ RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus)
{
UINT32 fileId;
UINT8 information;
WLog_DBG(TAG,
- "RdpdrServerDriveRenameFileCallback1: deviceId=%"PRIu32", completionId=%"PRIu32", ioStatus=0x%"PRIx32"",
+ "RdpdrServerDriveRenameFileCallback1: deviceId=%" PRIu32 ", completionId=%" PRIu32
+ ", ioStatus=0x%" PRIx32 "",
deviceId, completionId, ioStatus);
if (ioStatus != STATUS_SUCCESS)
@@ -2529,7 +2500,7 @@ static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
+ Stream_Read_UINT32(s, fileId); /* FileId (4 bytes) */
Stream_Read_UINT8(s, information); /* Information (1 byte) */
/* Setup the IRP. */
irp->CompletionId = context->priv->NextCompletionId++;
@@ -2546,7 +2517,7 @@ static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext*
/* Send a request to rename the file */
return rdpdr_server_send_device_file_rename_request(context, deviceId, fileId,
- irp->CompletionId, irp->ExtraBuffer);
+ irp->CompletionId, irp->ExtraBuffer);
}
/**
@@ -2554,8 +2525,9 @@ static UINT rdpdr_server_drive_rename_file_callback1(RdpdrServerContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpdr_server_drive_rename_file(RdpdrServerContext* context,
- void* callbackData, UINT32 deviceId, const char* oldPath, const char* newPath)
+static UINT rdpdr_server_drive_rename_file(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* oldPath,
+ const char* newPath)
{
RDPDR_IRP* irp;
irp = rdpdr_server_irp_new();
@@ -2583,15 +2555,15 @@ static UINT rdpdr_server_drive_rename_file(RdpdrServerContext* context,
}
/* Send a request to open the file. */
- return rdpdr_server_send_device_create_request(context, deviceId,
- irp->CompletionId, irp->PathName,
- FILE_READ_DATA | SYNCHRONIZE, FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
+ return rdpdr_server_send_device_create_request(context, deviceId, irp->CompletionId,
+ irp->PathName, FILE_READ_DATA | SYNCHRONIZE,
+ FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN);
}
RdpdrServerContext* rdpdr_server_context_new(HANDLE vcm)
{
RdpdrServerContext* context;
- context = (RdpdrServerContext*) calloc(1, sizeof(RdpdrServerContext));
+ context = (RdpdrServerContext*)calloc(1, sizeof(RdpdrServerContext));
if (context)
{
@@ -2607,7 +2579,7 @@ RdpdrServerContext* rdpdr_server_context_new(HANDLE vcm)
context->DriveCloseFile = rdpdr_server_drive_close_file;
context->DriveDeleteFile = rdpdr_server_drive_delete_file;
context->DriveRenameFile = rdpdr_server_drive_rename_file;
- context->priv = (RdpdrServerPrivate*) calloc(1, sizeof(RdpdrServerPrivate));
+ context->priv = (RdpdrServerPrivate*)calloc(1, sizeof(RdpdrServerPrivate));
if (!context->priv)
{
@@ -2652,4 +2624,3 @@ void rdpdr_server_context_free(RdpdrServerContext* context)
free(context);
}
}
-
diff --git a/channels/rdpdr/server/rdpdr_main.h b/channels/rdpdr/server/rdpdr_main.h
index 035ff7d70..f3f54cc07 100644
--- a/channels/rdpdr/server/rdpdr_main.h
+++ b/channels/rdpdr/server/rdpdr_main.h
@@ -48,7 +48,7 @@ struct _rdpdr_server_private
UINT32 NextCompletionId;
};
-#define RDPDR_HEADER_LENGTH 4
+#define RDPDR_HEADER_LENGTH 4
struct _RDPDR_HEADER
{
@@ -57,14 +57,14 @@ struct _RDPDR_HEADER
};
typedef struct _RDPDR_HEADER RDPDR_HEADER;
-#define RDPDR_VERSION_MAJOR 0x0001
+#define RDPDR_VERSION_MAJOR 0x0001
-#define RDPDR_VERSION_MINOR_RDP50 0x0002
-#define RDPDR_VERSION_MINOR_RDP51 0x0005
-#define RDPDR_VERSION_MINOR_RDP52 0x000A
-#define RDPDR_VERSION_MINOR_RDP6X 0x000C
+#define RDPDR_VERSION_MINOR_RDP50 0x0002
+#define RDPDR_VERSION_MINOR_RDP51 0x0005
+#define RDPDR_VERSION_MINOR_RDP52 0x000A
+#define RDPDR_VERSION_MINOR_RDP6X 0x000C
-#define RDPDR_CAPABILITY_HEADER_LENGTH 8
+#define RDPDR_CAPABILITY_HEADER_LENGTH 8
struct _RDPDR_CAPABILITY_HEADER
{
@@ -81,8 +81,10 @@ struct _RDPDR_IRP
UINT32 FileId;
char PathName[256];
char ExtraBuffer[256];
- void *CallbackData;
- UINT (*Callback)(RdpdrServerContext* context, wStream* s, struct _RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus);
+ void* CallbackData;
+ UINT(*Callback)
+ (RdpdrServerContext* context, wStream* s, struct _RDPDR_IRP* irp, UINT32 deviceId,
+ UINT32 completionId, UINT32 ioStatus);
};
typedef struct _RDPDR_IRP RDPDR_IRP;
diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c
index 9aca25861..27e09ea4a 100644
--- a/channels/rdpei/client/rdpei_main.c
+++ b/channels/rdpei/client/rdpei_main.c
@@ -62,7 +62,7 @@
* http://msdn.microsoft.com/en-us/library/hh454910/
*/
-#define MAX_CONTACTS 512
+#define MAX_CONTACTS 512
struct _RDPEI_CHANNEL_CALLBACK
{
@@ -117,16 +117,13 @@ typedef struct _RDPEI_PLUGIN RDPEI_PLUGIN;
*/
UINT rdpei_send_frame(RdpeiClientContext* context);
-const char* RDPEI_EVENTID_STRINGS[] =
-{
- "",
- "EVENTID_SC_READY",
- "EVENTID_CS_READY",
- "EVENTID_TOUCH",
- "EVENTID_SUSPEND_TOUCH",
- "EVENTID_RESUME_TOUCH",
- "EVENTID_DISMISS_HOVERING_CONTACT"
-};
+const char* RDPEI_EVENTID_STRINGS[] = { "",
+ "EVENTID_SC_READY",
+ "EVENTID_CS_READY",
+ "EVENTID_TOUCH",
+ "EVENTID_SUSPEND_TOUCH",
+ "EVENTID_RESUME_TOUCH",
+ "EVENTID_DISMISS_HOVERING_CONTACT" };
/**
* Function description
@@ -137,12 +134,12 @@ UINT rdpei_add_frame(RdpeiClientContext* context)
{
int i;
RDPINPUT_CONTACT_DATA* contact;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
rdpei->frame.contactCount = 0;
for (i = 0; i < rdpei->maxTouchContacts; i++)
{
- contact = (RDPINPUT_CONTACT_DATA*) & (rdpei->contactPoints[i].data);
+ contact = (RDPINPUT_CONTACT_DATA*)&(rdpei->contactPoints[i].data);
if (rdpei->contactPoints[i].dirty)
{
@@ -172,7 +169,7 @@ UINT rdpei_add_frame(RdpeiClientContext* context)
static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
{
DWORD status;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) arg;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)arg;
UINT error = CHANNEL_RC_OK;
RdpeiClientContext* context;
HANDLE hdl[2];
@@ -183,7 +180,7 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
goto out;
}
- context = (RdpeiClientContext*) rdpei->iface.pInterface;
+ context = (RdpeiClientContext*)rdpei->iface.pInterface;
hdl[0] = rdpei->event;
hdl[1] = rdpei->stopEvent;
@@ -200,7 +197,7 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -211,7 +208,7 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
if ((error = rdpei_add_frame(context)))
{
- WLog_ERR(TAG, "rdpei_add_frame failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_add_frame failed with error %" PRIu32 "!", error);
break;
}
@@ -219,7 +216,7 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
{
if ((error = rdpei_send_frame(context)))
{
- WLog_ERR(TAG, "rdpei_send_frame failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_send_frame failed with error %" PRIu32 "!", error);
break;
}
}
@@ -233,8 +230,7 @@ static DWORD WINAPI rdpei_schedule_thread(LPVOID arg)
out:
if (error && rdpei && rdpei->rdpcontext)
- setChannelError(rdpei->rdpcontext, error,
- "rdpei_schedule_thread reported an error");
+ setChannelError(rdpei->rdpcontext, error, "rdpei_schedule_thread reported an error");
ExitThread(error);
return error;
@@ -245,18 +241,18 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s,
- UINT16 eventId, UINT32 pduLength)
+UINT rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, UINT32 pduLength)
{
UINT status;
Stream_SetPosition(s, 0);
- Stream_Write_UINT16(s, eventId); /* eventId (2 bytes) */
+ Stream_Write_UINT16(s, eventId); /* eventId (2 bytes) */
Stream_Write_UINT32(s, pduLength); /* pduLength (4 bytes) */
Stream_SetPosition(s, Stream_Length(s));
- status = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s),
- Stream_Buffer(s), NULL);
+ status = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
+ NULL);
#ifdef WITH_DEBUG_RDPEI
- WLog_DBG(TAG, "rdpei_send_pdu: eventId: %"PRIu16" (%s) length: %"PRIu32" status: %"PRIu32"",
+ WLog_DBG(TAG,
+ "rdpei_send_pdu: eventId: %" PRIu16 " (%s) length: %" PRIu32 " status: %" PRIu32 "",
eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status);
#endif
return status;
@@ -273,10 +269,10 @@ UINT rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback)
wStream* s;
UINT32 flags;
UINT32 pduLength;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) callback->plugin;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)callback->plugin;
flags = 0;
flags |= READY_FLAGS_SHOW_TOUCH_VISUALS;
- //flags |= READY_FLAGS_DISABLE_TIMESTAMP_INJECTION;
+ // flags |= READY_FLAGS_DISABLE_TIMESTAMP_INJECTION;
pduLength = RDPINPUT_HEADER_LENGTH + 10;
s = Stream_New(NULL, pduLength);
@@ -287,10 +283,9 @@ UINT rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback)
}
Stream_Seek(s, RDPINPUT_HEADER_LENGTH);
- Stream_Write_UINT32(s, flags); /* flags (4 bytes) */
- Stream_Write_UINT32(s, RDPINPUT_PROTOCOL_V10); /* protocolVersion (4 bytes) */
- Stream_Write_UINT16(s,
- rdpei->maxTouchContacts); /* maxTouchContacts (2 bytes) */
+ Stream_Write_UINT32(s, flags); /* flags (4 bytes) */
+ Stream_Write_UINT32(s, RDPINPUT_PROTOCOL_V10); /* protocolVersion (4 bytes) */
+ Stream_Write_UINT16(s, rdpei->maxTouchContacts); /* maxTouchContacts (2 bytes) */
Stream_SealLength(s);
status = rdpei_send_pdu(callback, s, EVENTID_CS_READY, pduLength);
Stream_Free(s, TRUE);
@@ -329,8 +324,8 @@ UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
int rectSize = 2;
RDPINPUT_CONTACT_DATA* contact;
#ifdef WITH_DEBUG_RDPEI
- WLog_DBG(TAG, "contactCount: %"PRIu32"", frame->contactCount);
- WLog_DBG(TAG, "frameOffset: 0x%016"PRIX64"", frame->frameOffset);
+ WLog_DBG(TAG, "contactCount: %" PRIu32 "", frame->contactCount);
+ WLog_DBG(TAG, "frameOffset: 0x%016" PRIX64 "", frame->frameOffset);
#endif
rdpei_write_2byte_unsigned(s,
frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */
@@ -338,10 +333,10 @@ UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
* the time offset from the previous frame (in microseconds).
* If this is the first frame being transmitted then this field MUST be set to zero.
*/
- rdpei_write_8byte_unsigned(s,
- frame->frameOffset * 1000); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */
+ rdpei_write_8byte_unsigned(s, frame->frameOffset *
+ 1000); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */
- if (!Stream_EnsureRemainingCapacity(s, (size_t) frame->contactCount * 64))
+ if (!Stream_EnsureRemainingCapacity(s, (size_t)frame->contactCount * 64))
{
WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
return CHANNEL_RC_NO_MEMORY;
@@ -356,11 +351,13 @@ UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
contact->contactRectRight = contact->x + rectSize;
contact->contactRectBottom = contact->y + rectSize;
#ifdef WITH_DEBUG_RDPEI
- WLog_DBG(TAG, "contact[%"PRIu32"].contactId: %"PRIu32"", index, contact->contactId);
- WLog_DBG(TAG, "contact[%"PRIu32"].fieldsPresent: %"PRIu32"", index, contact->fieldsPresent);
- WLog_DBG(TAG, "contact[%"PRIu32"].x: %"PRId32"", index, contact->x);
- WLog_DBG(TAG, "contact[%"PRIu32"].y: %"PRId32"", index, contact->y);
- WLog_DBG(TAG, "contact[%"PRIu32"].contactFlags: 0x%08"PRIX32"", index, contact->contactFlags);
+ WLog_DBG(TAG, "contact[%" PRIu32 "].contactId: %" PRIu32 "", index, contact->contactId);
+ WLog_DBG(TAG, "contact[%" PRIu32 "].fieldsPresent: %" PRIu32 "", index,
+ contact->fieldsPresent);
+ WLog_DBG(TAG, "contact[%" PRIu32 "].x: %" PRId32 "", index, contact->x);
+ WLog_DBG(TAG, "contact[%" PRIu32 "].y: %" PRId32 "", index, contact->y);
+ WLog_DBG(TAG, "contact[%" PRIu32 "].contactFlags: 0x%08" PRIX32 "", index,
+ contact->contactFlags);
rdpei_print_contact_flags(contact->contactFlags);
#endif
Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */
@@ -404,8 +401,7 @@ UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback,
- RDPINPUT_TOUCH_FRAME* frame)
+UINT rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_FRAME* frame)
{
UINT status;
wStream* s;
@@ -424,13 +420,13 @@ UINT rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback,
* the time that has elapsed (in milliseconds) from when the oldest touch frame
* was generated to when it was encoded for transmission by the client.
*/
- rdpei_write_4byte_unsigned(s,
- (UINT32) frame->frameOffset); /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */
- rdpei_write_2byte_unsigned(s, 1); /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */
+ rdpei_write_4byte_unsigned(
+ s, (UINT32)frame->frameOffset); /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */
+ rdpei_write_2byte_unsigned(s, 1); /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */
if ((status = rdpei_write_touch_frame(s, frame)))
{
- WLog_ERR(TAG, "rdpei_write_touch_frame failed with error %"PRIu32"!", status);
+ WLog_ERR(TAG, "rdpei_write_touch_frame failed with error %" PRIu32 "!", status);
Stream_Free(s, TRUE);
return status;
}
@@ -470,12 +466,12 @@ UINT rdpei_recv_sc_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
*/
UINT rdpei_recv_suspend_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
{
- RdpeiClientContext* rdpei = (RdpeiClientContext*) callback->plugin->pInterface;
+ RdpeiClientContext* rdpei = (RdpeiClientContext*)callback->plugin->pInterface;
UINT error = CHANNEL_RC_OK;
IFCALLRET(rdpei->SuspendTouch, error, rdpei);
if (error)
- WLog_ERR(TAG, "rdpei->SuspendTouch failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei->SuspendTouch failed with error %" PRIu32 "!", error);
return error;
}
@@ -487,12 +483,12 @@ UINT rdpei_recv_suspend_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
*/
UINT rdpei_recv_resume_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
{
- RdpeiClientContext* rdpei = (RdpeiClientContext*) callback->plugin->pInterface;
+ RdpeiClientContext* rdpei = (RdpeiClientContext*)callback->plugin->pInterface;
UINT error = CHANNEL_RC_OK;
IFCALLRET(rdpei->ResumeTouch, error, rdpei);
if (error)
- WLog_ERR(TAG, "rdpei->ResumeTouch failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei->ResumeTouch failed with error %" PRIu32 "!", error);
return error;
}
@@ -507,11 +503,11 @@ UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
UINT16 eventId;
UINT32 pduLength;
UINT error;
- Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */
+ Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */
Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */
#ifdef WITH_DEBUG_RDPEI
- WLog_DBG(TAG, "rdpei_recv_pdu: eventId: %"PRIu16" (%s) length: %"PRIu32"",
- eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength);
+ WLog_DBG(TAG, "rdpei_recv_pdu: eventId: %" PRIu16 " (%s) length: %" PRIu32 "", eventId,
+ RDPEI_EVENTID_STRINGS[eventId], pduLength);
#endif
switch (eventId)
@@ -519,13 +515,13 @@ UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
case EVENTID_SC_READY:
if ((error = rdpei_recv_sc_ready_pdu(callback, s)))
{
- WLog_ERR(TAG, "rdpei_recv_sc_ready_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_recv_sc_ready_pdu failed with error %" PRIu32 "!", error);
return error;
}
if ((error = rdpei_send_cs_ready_pdu(callback)))
{
- WLog_ERR(TAG, "rdpei_send_cs_ready_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_send_cs_ready_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -534,7 +530,7 @@ UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
case EVENTID_SUSPEND_TOUCH:
if ((error = rdpei_recv_suspend_touch_pdu(callback, s)))
{
- WLog_ERR(TAG, "rdpei_recv_suspend_touch_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_recv_suspend_touch_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -543,7 +539,7 @@ UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
case EVENTID_RESUME_TOUCH:
if ((error = rdpei_recv_resume_touch_pdu(callback, s)))
{
- WLog_ERR(TAG, "rdpei_recv_resume_touch_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_recv_resume_touch_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -561,11 +557,10 @@ UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
- wStream* data)
+static UINT rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback;
- return rdpei_recv_pdu(callback, data);
+ RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*)pChannelCallback;
+ return rdpei_recv_pdu(callback, data);
}
/**
@@ -575,7 +570,7 @@ static UINT rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
*/
static UINT rdpei_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
- RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback;
+ RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*)pChannelCallback;
free(callback);
return CHANNEL_RC_OK;
}
@@ -585,15 +580,13 @@ static UINT rdpei_on_close(IWTSVirtualChannelCallback* pChannelCallback)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpei_on_new_channel_connection(IWTSListenerCallback*
- pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+static UINT rdpei_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback)
{
RDPEI_CHANNEL_CALLBACK* callback;
- RDPEI_LISTENER_CALLBACK* listener_callback = (RDPEI_LISTENER_CALLBACK*)
- pListenerCallback;
- callback = (RDPEI_CHANNEL_CALLBACK*) calloc(1, sizeof(RDPEI_CHANNEL_CALLBACK));
+ RDPEI_LISTENER_CALLBACK* listener_callback = (RDPEI_LISTENER_CALLBACK*)pListenerCallback;
+ callback = (RDPEI_CHANNEL_CALLBACK*)calloc(1, sizeof(RDPEI_CHANNEL_CALLBACK));
if (!callback)
{
@@ -607,7 +600,7 @@ static UINT rdpei_on_new_channel_connection(IWTSListenerCallback*
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -616,13 +609,11 @@ static UINT rdpei_on_new_channel_connection(IWTSListenerCallback*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin,
- IWTSVirtualChannelManager* pChannelMgr)
+static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
UINT error;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) pPlugin;
- rdpei->listener_callback = (RDPEI_LISTENER_CALLBACK*) calloc(1 ,
- sizeof(RDPEI_LISTENER_CALLBACK));
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)pPlugin;
+ rdpei->listener_callback = (RDPEI_LISTENER_CALLBACK*)calloc(1, sizeof(RDPEI_LISTENER_CALLBACK));
if (!rdpei->listener_callback)
{
@@ -630,15 +621,15 @@ static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin,
return CHANNEL_RC_NO_MEMORY;
}
- rdpei->listener_callback->iface.OnNewChannelConnection =
- rdpei_on_new_channel_connection;
+ rdpei->listener_callback->iface.OnNewChannelConnection = rdpei_on_new_channel_connection;
rdpei->listener_callback->plugin = pPlugin;
rdpei->listener_callback->channel_mgr = pChannelMgr;
if ((error = pChannelMgr->CreateListener(pChannelMgr, RDPEI_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*) rdpei->listener_callback, &(rdpei->listener))))
+ (IWTSListenerCallback*)rdpei->listener_callback,
+ &(rdpei->listener))))
{
- WLog_ERR(TAG, "ChannelMgr->CreateListener failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "ChannelMgr->CreateListener failed with error %" PRIu32 "!", error);
goto error_out;
}
@@ -657,8 +648,7 @@ static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin,
goto error_out;
}
- if (!(rdpei->thread = CreateThread(NULL, 0,
- rdpei_schedule_thread, (void*) rdpei, 0, NULL)))
+ if (!(rdpei->thread = CreateThread(NULL, 0, rdpei_schedule_thread, (void*)rdpei, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
goto error_out;
@@ -679,7 +669,7 @@ error_out:
*/
static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin)
{
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) pPlugin;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)pPlugin;
UINT error;
if (!pPlugin)
@@ -691,7 +681,7 @@ static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin)
if (WaitForSingleObject(rdpei->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -711,7 +701,7 @@ static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin)
int rdpei_get_version(RdpeiClientContext* context)
{
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
return rdpei->version;
}
@@ -723,7 +713,7 @@ int rdpei_get_version(RdpeiClientContext* context)
UINT rdpei_send_frame(RdpeiClientContext* context)
{
UINT64 currentTime;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback;
UINT error;
currentTime = GetTickCount64();
@@ -741,7 +731,7 @@ UINT rdpei_send_frame(RdpeiClientContext* context)
if ((error = rdpei_send_touch_event_pdu(callback, &rdpei->frame)))
{
- WLog_ERR(TAG, "rdpei_send_touch_event_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpei_send_touch_event_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -755,14 +745,12 @@ UINT rdpei_send_frame(RdpeiClientContext* context)
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_add_contact(RdpeiClientContext* context,
- RDPINPUT_CONTACT_DATA* contact)
+UINT rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact)
{
RDPINPUT_CONTACT_POINT* contactPoint;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
EnterCriticalSection(&rdpei->lock);
- contactPoint = (RDPINPUT_CONTACT_POINT*)
- &rdpei->contactPoints[contact->contactId];
+ contactPoint = (RDPINPUT_CONTACT_POINT*)&rdpei->contactPoints[contact->contactId];
CopyMemory(&(contactPoint->data), contact, sizeof(RDPINPUT_CONTACT_DATA));
contactPoint->dirty = TRUE;
SetEvent(rdpei->event);
@@ -775,21 +763,20 @@ UINT rdpei_add_contact(RdpeiClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_touch_begin(RdpeiClientContext* context, int externalId, int x,
- int y, int* contactId)
+UINT rdpei_touch_begin(RdpeiClientContext* context, int externalId, int x, int y, int* contactId)
{
unsigned int i;
int contactIdlocal = -1;
RDPINPUT_CONTACT_DATA contact;
RDPINPUT_CONTACT_POINT* contactPoint = NULL;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
- UINT error = CHANNEL_RC_OK;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
+ UINT error = CHANNEL_RC_OK;
/* Create a new contact point in an empty slot */
for (i = 0; i < rdpei->maxTouchContacts; i++)
{
- contactPoint = (RDPINPUT_CONTACT_POINT*) &rdpei->contactPoints[i];
+ contactPoint = (RDPINPUT_CONTACT_POINT*)&rdpei->contactPoints[i];
if (!contactPoint->active)
{
@@ -809,7 +796,7 @@ UINT rdpei_touch_begin(RdpeiClientContext* context, int externalId, int x,
contactPoint->lastY = y;
contact.x = x;
contact.y = y;
- contact.contactId = (UINT32) contactIdlocal;
+ contact.contactId = (UINT32)contactIdlocal;
contact.contactFlags |= CONTACT_FLAG_DOWN;
contact.contactFlags |= CONTACT_FLAG_INRANGE;
contact.contactFlags |= CONTACT_FLAG_INCONTACT;
@@ -825,19 +812,18 @@ UINT rdpei_touch_begin(RdpeiClientContext* context, int externalId, int x,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_touch_update(RdpeiClientContext* context, int externalId, int x,
- int y, int* contactId)
+UINT rdpei_touch_update(RdpeiClientContext* context, int externalId, int x, int y, int* contactId)
{
unsigned int i;
int contactIdlocal = -1;
RDPINPUT_CONTACT_DATA contact;
RDPINPUT_CONTACT_POINT* contactPoint = NULL;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
UINT error = CHANNEL_RC_OK;
for (i = 0; i < rdpei->maxTouchContacts; i++)
{
- contactPoint = (RDPINPUT_CONTACT_POINT*) &rdpei->contactPoints[i];
+ contactPoint = (RDPINPUT_CONTACT_POINT*)&rdpei->contactPoints[i];
if (!contactPoint->active)
continue;
@@ -856,7 +842,7 @@ UINT rdpei_touch_update(RdpeiClientContext* context, int externalId, int x,
contactPoint->lastY = y;
contact.x = x;
contact.y = y;
- contact.contactId = (UINT32) contactIdlocal;
+ contact.contactId = (UINT32)contactIdlocal;
contact.contactFlags |= CONTACT_FLAG_UPDATE;
contact.contactFlags |= CONTACT_FLAG_INRANGE;
contact.contactFlags |= CONTACT_FLAG_INCONTACT;
@@ -872,20 +858,19 @@ UINT rdpei_touch_update(RdpeiClientContext* context, int externalId, int x,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_touch_end(RdpeiClientContext* context, int externalId, int x, int y,
- int* contactId)
+UINT rdpei_touch_end(RdpeiClientContext* context, int externalId, int x, int y, int* contactId)
{
unsigned int i;
int contactIdlocal = -1;
int tempvalue;
RDPINPUT_CONTACT_DATA contact;
RDPINPUT_CONTACT_POINT* contactPoint = NULL;
- RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
+ RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle;
UINT error;
for (i = 0; i < rdpei->maxTouchContacts; i++)
{
- contactPoint = (RDPINPUT_CONTACT_POINT*) &rdpei->contactPoints[i];
+ contactPoint = (RDPINPUT_CONTACT_POINT*)&rdpei->contactPoints[i];
if (!contactPoint->active)
continue;
@@ -905,19 +890,19 @@ UINT rdpei_touch_end(RdpeiClientContext* context, int externalId, int x, int y,
{
if ((error = context->TouchUpdate(context, externalId, x, y, &tempvalue)))
{
- WLog_ERR(TAG, "context->TouchUpdate failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "context->TouchUpdate failed with error %" PRIu32 "!", error);
return error;
}
}
contact.x = x;
contact.y = y;
- contact.contactId = (UINT32) contactIdlocal;
+ contact.contactId = (UINT32)contactIdlocal;
contact.contactFlags |= CONTACT_FLAG_UP;
if ((error = context->AddContact(context, &contact)))
{
- WLog_ERR(TAG, "context->AddContact failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "context->AddContact failed with error %" PRIu32 "!", error);
return error;
}
@@ -933,9 +918,9 @@ UINT rdpei_touch_end(RdpeiClientContext* context, int externalId, int x, int y,
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry rdpei_DVCPluginEntry
+#define DVCPluginEntry rdpei_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -948,12 +933,12 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error;
RDPEI_PLUGIN* rdpei = NULL;
RdpeiClientContext* context = NULL;
- rdpei = (RDPEI_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpei");
+ rdpei = (RDPEI_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "rdpei");
if (!rdpei)
{
size_t size;
- rdpei = (RDPEI_PLUGIN*) calloc(1, sizeof(RDPEI_PLUGIN));
+ rdpei = (RDPEI_PLUGIN*)calloc(1, sizeof(RDPEI_PLUGIN));
if (!rdpei)
{
@@ -968,12 +953,13 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
rdpei->version = 1;
rdpei->currentFrameTime = 0;
rdpei->previousFrameTime = 0;
- rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts;
+ rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*)rdpei->contacts;
rdpei->maxTouchContacts = 10;
size = rdpei->maxTouchContacts * sizeof(RDPINPUT_CONTACT_POINT);
- rdpei->contactPoints = (RDPINPUT_CONTACT_POINT*) calloc(1, size);
- rdpei->rdpcontext = ((freerdp*)((rdpSettings*) pEntryPoints->GetRdpSettings(
- pEntryPoints))->instance)->context;
+ rdpei->contactPoints = (RDPINPUT_CONTACT_POINT*)calloc(1, size);
+ rdpei->rdpcontext =
+ ((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
+ ->context;
if (!rdpei->contactPoints)
{
@@ -982,7 +968,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
goto error_out;
}
- context = (RdpeiClientContext*) calloc(1, sizeof(RdpeiClientContext));
+ context = (RdpeiClientContext*)calloc(1, sizeof(RdpeiClientContext));
if (!context)
{
@@ -991,18 +977,17 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
goto error_out;
}
- context->handle = (void*) rdpei;
+ context->handle = (void*)rdpei;
context->GetVersion = rdpei_get_version;
context->AddContact = rdpei_add_contact;
context->TouchBegin = rdpei_touch_begin;
context->TouchUpdate = rdpei_touch_update;
context->TouchEnd = rdpei_touch_end;
- rdpei->iface.pInterface = (void*) context;
+ rdpei->iface.pInterface = (void*)context;
- if ((error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpei",
- (IWTSPlugin*) rdpei)))
+ if ((error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpei", (IWTSPlugin*)rdpei)))
{
- WLog_ERR(TAG, "EntryPoints->RegisterPlugin failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "EntryPoints->RegisterPlugin failed with error %" PRIu32 "!", error);
error = CHANNEL_RC_NO_MEMORY;
goto error_out;
}
diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h
index 4dc499831..ed557b29d 100644
--- a/channels/rdpei/client/rdpei_main.h
+++ b/channels/rdpei/client/rdpei_main.h
@@ -34,10 +34,10 @@
#define TAG CHANNELS_TAG("rdpei.client")
-#define RDPINPUT_CONTACT_STATE_INITIAL 0x0000
-#define RDPINPUT_CONTACT_STATE_ENGAGED 0x0001
-#define RDPINPUT_CONTACT_STATE_HOVERING 0x0002
-#define RDPINPUT_CONTACT_STATE_OUT_OF_RANGE 0x0003
+#define RDPINPUT_CONTACT_STATE_INITIAL 0x0000
+#define RDPINPUT_CONTACT_STATE_ENGAGED 0x0001
+#define RDPINPUT_CONTACT_STATE_HOVERING 0x0002
+#define RDPINPUT_CONTACT_STATE_OUT_OF_RANGE 0x0003
/**
* Touch Contact State Transitions
@@ -84,8 +84,10 @@ typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT;
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_DVC(...) do { } while (0)
+#define DEBUG_DVC(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CHANNEL_RDPEI_CLIENT_MAIN_H */
-
diff --git a/channels/rdpei/rdpei_common.c b/channels/rdpei/rdpei_common.c
index 41a2ec3c3..adf9710d1 100644
--- a/channels/rdpei/rdpei_common.c
+++ b/channels/rdpei/rdpei_common.c
@@ -408,7 +408,7 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value)
break;
case 4:
- *value = ((UINT64) (byte & 0x1F)) << 32;
+ *value = ((UINT64)(byte & 0x1F)) << 32;
Stream_Read_UINT8(s, byte);
*value |= (byte << 24);
Stream_Read_UINT8(s, byte);
@@ -420,9 +420,9 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value)
break;
case 5:
- *value = ((UINT64) (byte & 0x1F)) << 40;
+ *value = ((UINT64)(byte & 0x1F)) << 40;
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 32);
+ *value |= (((UINT64)byte) << 32);
Stream_Read_UINT8(s, byte);
*value |= (byte << 24);
Stream_Read_UINT8(s, byte);
@@ -434,11 +434,11 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value)
break;
case 6:
- *value = ((UINT64) (byte & 0x1F)) << 48;
+ *value = ((UINT64)(byte & 0x1F)) << 48;
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 40);
+ *value |= (((UINT64)byte) << 40);
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 32);
+ *value |= (((UINT64)byte) << 32);
Stream_Read_UINT8(s, byte);
*value |= (byte << 24);
Stream_Read_UINT8(s, byte);
@@ -450,13 +450,13 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value)
break;
case 7:
- *value = ((UINT64) (byte & 0x1F)) << 56;
+ *value = ((UINT64)(byte & 0x1F)) << 56;
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 48);
+ *value |= (((UINT64)byte) << 48);
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 40);
+ *value |= (((UINT64)byte) << 40);
Stream_Read_UINT8(s, byte);
- *value |= (((UINT64) byte) << 32);
+ *value |= (((UINT64)byte) << 32);
Stream_Read_UINT8(s, byte);
*value |= (byte << 24);
Stream_Read_UINT8(s, byte);
@@ -589,7 +589,7 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
return TRUE;
}
-void touch_event_reset(RDPINPUT_TOUCH_EVENT *event)
+void touch_event_reset(RDPINPUT_TOUCH_EVENT* event)
{
int i;
@@ -601,8 +601,7 @@ void touch_event_reset(RDPINPUT_TOUCH_EVENT *event)
event->frameCount = 0;
}
-
-void touch_frame_reset(RDPINPUT_TOUCH_FRAME *frame)
+void touch_frame_reset(RDPINPUT_TOUCH_FRAME* frame)
{
free(frame->contacts);
frame->contacts = NULL;
diff --git a/channels/rdpei/rdpei_common.h b/channels/rdpei/rdpei_common.h
index 34d1edd64..610767a95 100644
--- a/channels/rdpei/rdpei_common.h
+++ b/channels/rdpei/rdpei_common.h
@@ -26,7 +26,8 @@
#include
/** @brief input event ids */
-enum {
+enum
+{
EVENTID_SC_READY = 0x0001,
EVENTID_CS_READY = 0x0002,
EVENTID_TOUCH = 0x0003,
@@ -46,8 +47,7 @@ BOOL rdpei_write_4byte_signed(wStream* s, INT32 value);
BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value);
BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value);
-void touch_event_reset(RDPINPUT_TOUCH_EVENT *event);
-void touch_frame_reset(RDPINPUT_TOUCH_FRAME *frame);
+void touch_event_reset(RDPINPUT_TOUCH_EVENT* event);
+void touch_frame_reset(RDPINPUT_TOUCH_FRAME* frame);
#endif /* FREERDP_CHANNEL_RDPEI_COMMON_H */
-
diff --git a/channels/rdpei/server/rdpei_main.c b/channels/rdpei/server/rdpei_main.c
index 7f5a20d63..81b93ce6f 100644
--- a/channels/rdpei/server/rdpei_main.c
+++ b/channels/rdpei/server/rdpei_main.c
@@ -34,7 +34,8 @@
#include
/** @brief */
-enum RdpEiState {
+enum RdpEiState
+{
STATE_INITIAL,
STATE_WAITING_CLIENT_READY,
STATE_WAITING_FRAME,
@@ -48,8 +49,8 @@ struct _rdpei_server_private
UINT32 expectedBytes;
BOOL waitingHeaders;
- wStream *inputStream;
- wStream *outputStream;
+ wStream* inputStream;
+ wStream* outputStream;
UINT16 currentMsgType;
@@ -58,11 +59,10 @@ struct _rdpei_server_private
enum RdpEiState automataState;
};
-
RdpeiServerContext* rdpei_server_context_new(HANDLE vcm)
{
- RdpeiServerContext *ret = calloc(1, sizeof(*ret));
- RdpeiServerPrivate *priv;
+ RdpeiServerContext* ret = calloc(1, sizeof(*ret));
+ RdpeiServerPrivate* priv;
if (!ret)
return NULL;
@@ -97,22 +97,27 @@ out_free:
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_server_init(RdpeiServerContext *context)
+UINT rdpei_server_init(RdpeiServerContext* context)
{
- void *buffer = NULL;
+ void* buffer = NULL;
DWORD bytesReturned;
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
- priv->channelHandle = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, RDPEI_DVC_CHANNEL_NAME, WTS_CHANNEL_OPTION_DYNAMIC);
+ priv->channelHandle = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, RDPEI_DVC_CHANNEL_NAME,
+ WTS_CHANNEL_OPTION_DYNAMIC);
if (!priv->channelHandle)
{
WLog_ERR(TAG, "WTSVirtualChannelOpenEx failed!");
return CHANNEL_RC_INITIALIZATION_ERROR;
}
- if (!WTSVirtualChannelQuery(priv->channelHandle, WTSVirtualEventHandle, &buffer, &bytesReturned) || (bytesReturned != sizeof(HANDLE)))
+ if (!WTSVirtualChannelQuery(priv->channelHandle, WTSVirtualEventHandle, &buffer,
+ &bytesReturned) ||
+ (bytesReturned != sizeof(HANDLE)))
{
- WLog_ERR(TAG, "WTSVirtualChannelQuery failed or invalid invalid returned size(%"PRIu32")!", bytesReturned);
+ WLog_ERR(TAG,
+ "WTSVirtualChannelQuery failed or invalid invalid returned size(%" PRIu32 ")!",
+ bytesReturned);
if (buffer)
WTSFreeMemory(buffer);
goto out_close;
@@ -127,10 +132,9 @@ out_close:
return CHANNEL_RC_INITIALIZATION_ERROR;
}
-
-void rdpei_server_context_reset(RdpeiServerContext *context)
+void rdpei_server_context_reset(RdpeiServerContext* context)
{
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
priv->channelHandle = INVALID_HANDLE_VALUE;
priv->expectedBytes = RDPINPUT_HEADER_LENGTH;
@@ -141,7 +145,7 @@ void rdpei_server_context_reset(RdpeiServerContext *context)
void rdpei_server_context_free(RdpeiServerContext* context)
{
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
if (priv->channelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(priv->channelHandle);
Stream_Free(priv->inputStream, TRUE);
@@ -149,18 +153,17 @@ void rdpei_server_context_free(RdpeiServerContext* context)
free(context);
}
-HANDLE rdpei_server_get_event_handle(RdpeiServerContext *context)
+HANDLE rdpei_server_get_event_handle(RdpeiServerContext* context)
{
return context->priv->eventHandle;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT read_cs_ready_message(RdpeiServerContext *context, wStream *s)
+static UINT read_cs_ready_message(RdpeiServerContext* context, wStream* s)
{
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 10)
@@ -175,17 +178,17 @@ static UINT read_cs_ready_message(RdpeiServerContext *context, wStream *s)
switch (context->clientVersion)
{
- case RDPINPUT_PROTOCOL_V10:
- case RDPINPUT_PROTOCOL_V101:
- break;
- default:
- WLog_ERR(TAG, "unhandled RPDEI protocol version 0x%"PRIx32"", context->clientVersion);
- break;
+ case RDPINPUT_PROTOCOL_V10:
+ case RDPINPUT_PROTOCOL_V101:
+ break;
+ default:
+ WLog_ERR(TAG, "unhandled RPDEI protocol version 0x%" PRIx32 "", context->clientVersion);
+ break;
}
IFCALLRET(context->onClientReady, error, context);
if (error)
- WLog_ERR(TAG, "context->onClientReady failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->onClientReady failed with error %" PRIu32 "", error);
return error;
}
@@ -195,7 +198,8 @@ static UINT read_cs_ready_message(RdpeiServerContext *context, wStream *s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT read_touch_contact_data(RdpeiServerContext *context, wStream *s, RDPINPUT_CONTACT_DATA *contactData)
+static UINT read_touch_contact_data(RdpeiServerContext* context, wStream* s,
+ RDPINPUT_CONTACT_DATA* contactData)
{
if (Stream_GetRemainingLength(s) < 1)
{
@@ -205,9 +209,9 @@ static UINT read_touch_contact_data(RdpeiServerContext *context, wStream *s, RDP
Stream_Read_UINT8(s, contactData->contactId);
if (!rdpei_read_2byte_unsigned(s, &contactData->fieldsPresent) ||
- !rdpei_read_4byte_signed(s, &contactData->x) ||
- !rdpei_read_4byte_signed(s, &contactData->y) ||
- !rdpei_read_4byte_unsigned(s, &contactData->contactFlags))
+ !rdpei_read_4byte_signed(s, &contactData->x) ||
+ !rdpei_read_4byte_signed(s, &contactData->y) ||
+ !rdpei_read_4byte_unsigned(s, &contactData->contactFlags))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
@@ -216,9 +220,9 @@ static UINT read_touch_contact_data(RdpeiServerContext *context, wStream *s, RDP
if (contactData->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT)
{
if (!rdpei_read_2byte_signed(s, &contactData->contactRectLeft) ||
- !rdpei_read_2byte_signed(s, &contactData->contactRectTop) ||
- !rdpei_read_2byte_signed(s, &contactData->contactRectRight) ||
- !rdpei_read_2byte_signed(s, &contactData->contactRectBottom))
+ !rdpei_read_2byte_signed(s, &contactData->contactRectTop) ||
+ !rdpei_read_2byte_signed(s, &contactData->contactRectRight) ||
+ !rdpei_read_2byte_signed(s, &contactData->contactRectBottom))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
@@ -226,15 +230,14 @@ static UINT read_touch_contact_data(RdpeiServerContext *context, wStream *s, RDP
}
if ((contactData->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT) &&
- !rdpei_read_4byte_unsigned(s, &contactData->orientation))
+ !rdpei_read_4byte_unsigned(s, &contactData->orientation))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
}
-
if ((contactData->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT) &&
- !rdpei_read_4byte_unsigned(s, &contactData->pressure))
+ !rdpei_read_4byte_unsigned(s, &contactData->pressure))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
@@ -248,13 +251,14 @@ static UINT read_touch_contact_data(RdpeiServerContext *context, wStream *s, RDP
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT read_touch_frame(RdpeiServerContext *context, wStream *s, RDPINPUT_TOUCH_FRAME *frame)
+static UINT read_touch_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_TOUCH_FRAME* frame)
{
UINT32 i;
- RDPINPUT_CONTACT_DATA *contact;
+ RDPINPUT_CONTACT_DATA* contact;
UINT error;
- if (!rdpei_read_2byte_unsigned(s, &frame->contactCount) || !rdpei_read_8byte_unsigned(s, &frame->frameOffset))
+ if (!rdpei_read_2byte_unsigned(s, &frame->contactCount) ||
+ !rdpei_read_8byte_unsigned(s, &frame->frameOffset))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
@@ -271,7 +275,7 @@ static UINT read_touch_frame(RdpeiServerContext *context, wStream *s, RDPINPUT_T
{
if ((error = read_touch_contact_data(context, s, contact)))
{
- WLog_ERR(TAG, "read_touch_contact_data failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "read_touch_contact_data failed with error %" PRIu32 "!", error);
frame->contactCount = i;
touch_frame_reset(frame);
return error;
@@ -285,15 +289,16 @@ static UINT read_touch_frame(RdpeiServerContext *context, wStream *s, RDPINPUT_T
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT read_touch_event(RdpeiServerContext *context, wStream *s)
+static UINT read_touch_event(RdpeiServerContext* context, wStream* s)
{
UINT32 frameCount;
UINT32 i;
- RDPINPUT_TOUCH_EVENT *event = &context->priv->touchEvent;
- RDPINPUT_TOUCH_FRAME *frame;
+ RDPINPUT_TOUCH_EVENT* event = &context->priv->touchEvent;
+ RDPINPUT_TOUCH_FRAME* frame;
UINT error = CHANNEL_RC_OK;
- if (!rdpei_read_4byte_unsigned(s, &event->encodeTime) || !rdpei_read_2byte_unsigned(s, &frameCount))
+ if (!rdpei_read_4byte_unsigned(s, &event->encodeTime) ||
+ !rdpei_read_2byte_unsigned(s, &frameCount))
{
WLog_ERR(TAG, "rdpei_read_ failed!");
return ERROR_INTERNAL_ERROR;
@@ -311,29 +316,28 @@ static UINT read_touch_event(RdpeiServerContext *context, wStream *s)
{
if ((error = read_touch_frame(context, s, frame)))
{
- WLog_ERR(TAG, "read_touch_contact_data failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "read_touch_contact_data failed with error %" PRIu32 "!", error);
event->frameCount = i;
goto out_cleanup;
}
}
-
IFCALLRET(context->onTouchEvent, error, context, event);
if (error)
- WLog_ERR(TAG, "context->onTouchEvent failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->onTouchEvent failed with error %" PRIu32 "", error);
out_cleanup:
touch_event_reset(event);
return error;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT read_dismiss_hovering_contact(RdpeiServerContext *context, wStream *s) {
+static UINT read_dismiss_hovering_contact(RdpeiServerContext* context, wStream* s)
+{
BYTE contactId;
UINT error = CHANNEL_RC_OK;
@@ -347,24 +351,25 @@ static UINT read_dismiss_hovering_contact(RdpeiServerContext *context, wStream *
IFCALLRET(context->onTouchReleased, error, context, contactId);
if (error)
- WLog_ERR(TAG, "context->onTouchReleased failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->onTouchReleased failed with error %" PRIu32 "", error);
return error;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_server_handle_messages(RdpeiServerContext *context) {
+UINT rdpei_server_handle_messages(RdpeiServerContext* context)
+{
DWORD bytesReturned;
- RdpeiServerPrivate *priv = context->priv;
- wStream *s = priv->inputStream;
+ RdpeiServerPrivate* priv = context->priv;
+ wStream* s = priv->inputStream;
UINT error = CHANNEL_RC_OK;
- if (!WTSVirtualChannelRead(priv->channelHandle, 0, (PCHAR)Stream_Pointer(s), priv->expectedBytes, &bytesReturned))
+ if (!WTSVirtualChannelRead(priv->channelHandle, 0, (PCHAR)Stream_Pointer(s),
+ priv->expectedBytes, &bytesReturned))
{
if (GetLastError() == ERROR_NO_DATA)
return ERROR_READ_FAULT;
@@ -391,7 +396,7 @@ UINT rdpei_server_handle_messages(RdpeiServerContext *context) {
if (pduLen < RDPINPUT_HEADER_LENGTH)
{
- WLog_ERR(TAG, "invalid pduLength %"PRIu32"", pduLen);
+ WLog_ERR(TAG, "invalid pduLength %" PRIu32 "", pduLen);
return ERROR_INVALID_DATA;
}
priv->expectedBytes = pduLen - RDPINPUT_HEADER_LENGTH;
@@ -411,36 +416,37 @@ UINT rdpei_server_handle_messages(RdpeiServerContext *context) {
/* when here we have the header + the body */
switch (priv->currentMsgType)
{
- case EVENTID_CS_READY:
- if (priv->automataState != STATE_WAITING_CLIENT_READY)
- {
- WLog_ERR(TAG, "not expecting a CS_READY packet in this state(%d)", priv->automataState);
- return ERROR_INVALID_STATE;
- }
+ case EVENTID_CS_READY:
+ if (priv->automataState != STATE_WAITING_CLIENT_READY)
+ {
+ WLog_ERR(TAG, "not expecting a CS_READY packet in this state(%d)",
+ priv->automataState);
+ return ERROR_INVALID_STATE;
+ }
- if ((error = read_cs_ready_message(context, s)))
- {
- WLog_ERR(TAG, "read_cs_ready_message failed with error %"PRIu32"", error);
- return error;
- }
- break;
+ if ((error = read_cs_ready_message(context, s)))
+ {
+ WLog_ERR(TAG, "read_cs_ready_message failed with error %" PRIu32 "", error);
+ return error;
+ }
+ break;
- case EVENTID_TOUCH:
- if ((error = read_touch_event(context, s)))
- {
- WLog_ERR(TAG, "read_touch_event failed with error %"PRIu32"", error);
- return error;
- }
- break;
- case EVENTID_DISMISS_HOVERING_CONTACT:
- if ((error = read_dismiss_hovering_contact(context, s)))
- {
- WLog_ERR(TAG, "read_dismiss_hovering_contact failed with error %"PRIu32"", error);
- return error;
- }
- break;
- default:
- WLog_ERR(TAG, "unexpected message type 0x%"PRIx16"", priv->currentMsgType);
+ case EVENTID_TOUCH:
+ if ((error = read_touch_event(context, s)))
+ {
+ WLog_ERR(TAG, "read_touch_event failed with error %" PRIu32 "", error);
+ return error;
+ }
+ break;
+ case EVENTID_DISMISS_HOVERING_CONTACT:
+ if ((error = read_dismiss_hovering_contact(context, s)))
+ {
+ WLog_ERR(TAG, "read_dismiss_hovering_contact failed with error %" PRIu32 "", error);
+ return error;
+ }
+ break;
+ default:
+ WLog_ERR(TAG, "unexpected message type 0x%" PRIx16 "", priv->currentMsgType);
}
Stream_SetPosition(s, 0);
@@ -449,16 +455,15 @@ UINT rdpei_server_handle_messages(RdpeiServerContext *context) {
return error;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_server_send_sc_ready(RdpeiServerContext *context, UINT32 version)
+UINT rdpei_server_send_sc_ready(RdpeiServerContext* context, UINT32 version)
{
ULONG written;
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
if (priv->automataState != STATE_INITIAL)
{
@@ -479,7 +484,7 @@ UINT rdpei_server_send_sc_ready(RdpeiServerContext *context, UINT32 version)
Stream_Write_UINT32(priv->outputStream, version);
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
- Stream_GetPosition(priv->outputStream), &written))
+ Stream_GetPosition(priv->outputStream), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
return ERROR_INTERNAL_ERROR;
@@ -494,21 +499,21 @@ UINT rdpei_server_send_sc_ready(RdpeiServerContext *context, UINT32 version)
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_server_suspend(RdpeiServerContext *context)
+UINT rdpei_server_suspend(RdpeiServerContext* context)
{
ULONG written;
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
switch (priv->automataState)
{
- case STATE_SUSPENDED:
- WLog_ERR(TAG, "already suspended");
- return CHANNEL_RC_OK;
- case STATE_WAITING_FRAME:
- break;
- default:
- WLog_ERR(TAG, "called from unexpected state %d", priv->automataState);
- return ERROR_INVALID_STATE;
+ case STATE_SUSPENDED:
+ WLog_ERR(TAG, "already suspended");
+ return CHANNEL_RC_OK;
+ case STATE_WAITING_FRAME:
+ break;
+ default:
+ WLog_ERR(TAG, "called from unexpected state %d", priv->automataState);
+ return ERROR_INVALID_STATE;
}
Stream_SetPosition(priv->outputStream, 0);
@@ -522,7 +527,7 @@ UINT rdpei_server_suspend(RdpeiServerContext *context)
Stream_Write_UINT32(priv->outputStream, RDPINPUT_HEADER_LENGTH);
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
- Stream_GetPosition(priv->outputStream), &written))
+ Stream_GetPosition(priv->outputStream), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
return ERROR_INTERNAL_ERROR;
@@ -532,27 +537,26 @@ UINT rdpei_server_suspend(RdpeiServerContext *context)
return CHANNEL_RC_OK;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT rdpei_server_resume(RdpeiServerContext *context)
+UINT rdpei_server_resume(RdpeiServerContext* context)
{
ULONG written;
- RdpeiServerPrivate *priv = context->priv;
+ RdpeiServerPrivate* priv = context->priv;
switch (priv->automataState)
{
- case STATE_WAITING_FRAME:
- WLog_ERR(TAG, "not suspended");
- return CHANNEL_RC_OK;
- case STATE_SUSPENDED:
- break;
- default:
- WLog_ERR(TAG, "called from unexpected state %d", priv->automataState);
- return ERROR_INVALID_STATE;
+ case STATE_WAITING_FRAME:
+ WLog_ERR(TAG, "not suspended");
+ return CHANNEL_RC_OK;
+ case STATE_SUSPENDED:
+ break;
+ default:
+ WLog_ERR(TAG, "called from unexpected state %d", priv->automataState);
+ return ERROR_INVALID_STATE;
}
Stream_SetPosition(priv->outputStream, 0);
@@ -566,7 +570,7 @@ UINT rdpei_server_resume(RdpeiServerContext *context)
Stream_Write_UINT32(priv->outputStream, RDPINPUT_HEADER_LENGTH);
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
- Stream_GetPosition(priv->outputStream), &written))
+ Stream_GetPosition(priv->outputStream), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
return ERROR_INTERNAL_ERROR;
@@ -575,4 +579,3 @@ UINT rdpei_server_resume(RdpeiServerContext *context)
priv->automataState = STATE_WAITING_FRAME;
return CHANNEL_RC_OK;
}
-
diff --git a/channels/rdpei/server/rdpei_main.h b/channels/rdpei/server/rdpei_main.h
index f6505f54d..cf3e3cbb4 100644
--- a/channels/rdpei/server/rdpei_main.h
+++ b/channels/rdpei/server/rdpei_main.h
@@ -29,7 +29,4 @@
#define TAG CHANNELS_TAG("rdpei.server")
-
-
#endif /* FREERDP_CHANNEL_RDPEI_SERVER_MAIN_H */
-
diff --git a/channels/rdpgfx/client/rdpgfx_codec.c b/channels/rdpgfx/client/rdpgfx_codec.c
index cf96f44c9..d89278c75 100644
--- a/channels/rdpgfx/client/rdpgfx_codec.c
+++ b/channels/rdpgfx/client/rdpgfx_codec.c
@@ -39,8 +39,7 @@
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
- RDPGFX_H264_METABLOCK* meta)
+static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H264_METABLOCK* meta)
{
UINT32 index;
RECTANGLE_16* regionRect;
@@ -63,7 +62,7 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
goto error_out;
}
- meta->regionRects = (RECTANGLE_16*) calloc(meta->numRegionRects, sizeof(RECTANGLE_16));
+ meta->regionRects = (RECTANGLE_16*)calloc(meta->numRegionRects, sizeof(RECTANGLE_16));
if (!meta->regionRects)
{
@@ -72,8 +71,8 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
goto error_out;
}
- meta->quantQualityVals = (RDPGFX_H264_QUANT_QUALITY*) calloc(meta->numRegionRects, sizeof(
- RDPGFX_H264_QUANT_QUALITY));
+ meta->quantQualityVals =
+ (RDPGFX_H264_QUANT_QUALITY*)calloc(meta->numRegionRects, sizeof(RDPGFX_H264_QUANT_QUALITY));
if (!meta->quantQualityVals)
{
@@ -82,7 +81,7 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
goto error_out;
}
- WLog_DBG(TAG, "H264_METABLOCK: numRegionRects: %"PRIu32"", meta->numRegionRects);
+ WLog_DBG(TAG, "H264_METABLOCK: numRegionRects: %" PRIu32 "", meta->numRegionRects);
for (index = 0; index < meta->numRegionRects; index++)
{
@@ -90,12 +89,13 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
if ((error = rdpgfx_read_rect16(s, regionRect)))
{
- WLog_ERR(TAG, "rdpgfx_read_rect16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_read_rect16 failed with error %" PRIu32 "!", error);
goto error_out;
}
WLog_DBG(TAG,
- "regionRects[%"PRIu32"]: left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16"",
+ "regionRects[%" PRIu32 "]: left: %" PRIu16 " top: %" PRIu16 " right: %" PRIu16
+ " bottom: %" PRIu16 "",
index, regionRect->left, regionRect->top, regionRect->right, regionRect->bottom);
}
@@ -109,14 +109,16 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s,
for (index = 0; index < meta->numRegionRects; index++)
{
quantQualityVal = &(meta->quantQualityVals[index]);
- Stream_Read_UINT8(s, quantQualityVal->qpVal); /* qpVal (1 byte) */
+ Stream_Read_UINT8(s, quantQualityVal->qpVal); /* qpVal (1 byte) */
Stream_Read_UINT8(s, quantQualityVal->qualityVal); /* qualityVal (1 byte) */
quantQualityVal->qp = quantQualityVal->qpVal & 0x3F;
quantQualityVal->r = (quantQualityVal->qpVal >> 6) & 1;
quantQualityVal->p = (quantQualityVal->qpVal >> 7) & 1;
WLog_DBG(TAG,
- "quantQualityVals[%"PRIu32"]: qp: %"PRIu8" r: %"PRIu8" p: %"PRIu8" qualityVal: %"PRIu8"",
- index, quantQualityVal->qp, quantQualityVal->r, quantQualityVal->p, quantQualityVal->qualityVal);
+ "quantQualityVals[%" PRIu32 "]: qp: %" PRIu8 " r: %" PRIu8 " p: %" PRIu8
+ " qualityVal: %" PRIu8 "",
+ index, quantQualityVal->qp, quantQualityVal->r, quantQualityVal->p,
+ quantQualityVal->qualityVal);
}
return CHANNEL_RC_OK;
@@ -138,7 +140,7 @@ static UINT rdpgfx_decode_AVC420(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
UINT error;
wStream* s;
RDPGFX_AVC420_BITMAP_STREAM h264;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
s = Stream_New(cmd->data, cmd->length);
if (!s)
@@ -150,21 +152,21 @@ static UINT rdpgfx_decode_AVC420(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.meta))))
{
Stream_Free(s, FALSE);
- WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %" PRIu32 "!", error);
return error;
}
h264.data = Stream_Pointer(s);
- h264.length = (UINT32) Stream_GetRemainingLength(s);
+ h264.length = (UINT32)Stream_GetRemainingLength(s);
Stream_Free(s, FALSE);
- cmd->extra = (void*) &h264;
+ cmd->extra = (void*)&h264;
if (context)
{
IFCALLRET(context->SurfaceCommand, error, context, cmd);
if (error)
- WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->SurfaceCommand failed with error %" PRIu32 "", error);
}
free(h264.meta.regionRects);
@@ -184,7 +186,7 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
size_t pos1, pos2;
wStream* s;
RDPGFX_AVC444_BITMAP_STREAM h264 = { 0 };
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
s = Stream_New(cmd->data, cmd->length);
if (!s)
@@ -213,7 +215,7 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[0].meta))))
{
- WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %" PRIu32 "!", error);
goto fail;
}
@@ -235,7 +237,7 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[1].meta))))
{
- WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %" PRIu32 "!", error);
goto fail;
}
@@ -245,14 +247,14 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
else
h264.bitstream[0].length = Stream_GetRemainingLength(s);
- cmd->extra = (void*) &h264;
+ cmd->extra = (void*)&h264;
if (context)
{
IFCALLRET(context->SurfaceCommand, error, context, cmd);
if (error)
- WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->SurfaceCommand failed with error %" PRIu32 "", error);
}
fail:
@@ -272,21 +274,21 @@ fail:
UINT rdpgfx_decode(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
{
UINT error = CHANNEL_RC_OK;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
PROFILER_ENTER(context->SurfaceProfiler)
switch (cmd->codecId)
{
case RDPGFX_CODECID_AVC420:
if ((error = rdpgfx_decode_AVC420(gfx, cmd)))
- WLog_ERR(TAG, "rdpgfx_decode_AVC420 failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpgfx_decode_AVC420 failed with error %" PRIu32 "", error);
break;
case RDPGFX_CODECID_AVC444:
case RDPGFX_CODECID_AVC444v2:
if ((error = rdpgfx_decode_AVC444(gfx, cmd)))
- WLog_ERR(TAG, "rdpgfx_decode_AVC444 failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpgfx_decode_AVC444 failed with error %" PRIu32 "", error);
break;
@@ -296,7 +298,7 @@ UINT rdpgfx_decode(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
IFCALLRET(context->SurfaceCommand, error, context, cmd);
if (error)
- WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->SurfaceCommand failed with error %" PRIu32 "", error);
}
break;
diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c
index 00a450ed0..1063c67a5 100644
--- a/channels/rdpgfx/client/rdpgfx_main.c
+++ b/channels/rdpgfx/client/rdpgfx_main.c
@@ -53,7 +53,7 @@
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context,
- const RDPGFX_CAPS_ADVERTISE_PDU* pdu)
+ const RDPGFX_CAPS_ADVERTISE_PDU* pdu)
{
UINT error = CHANNEL_RC_OK;
UINT16 index;
@@ -62,7 +62,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context,
RDPGFX_PLUGIN* gfx;
RDPGFX_CHANNEL_CALLBACK* callback;
wStream* s;
- gfx = (RDPGFX_PLUGIN*) context->handle;
+ gfx = (RDPGFX_PLUGIN*)context->handle;
callback = gfx->listener_callback->channel_callback;
header.flags = 0;
header.cmdId = RDPGFX_CMDID_CAPSADVERTISE;
@@ -74,7 +74,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context,
header.pduLength += RDPGFX_CAPSET_BASE_SIZE + capsSet->length;
}
- DEBUG_RDPGFX(gfx->log, "SendCapsAdvertisePdu %"PRIu16"", pdu->capsSetCount);
+ DEBUG_RDPGFX(gfx->log, "SendCapsAdvertisePdu %" PRIu16 "", pdu->capsSetCount);
s = Stream_New(NULL, header.pduLength);
if (!s)
@@ -93,14 +93,14 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context,
{
capsSet = &(pdu->capsSets[index]);
Stream_Write_UINT32(s, capsSet->version); /* version (4 bytes) */
- Stream_Write_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
- Stream_Write_UINT32(s, capsSet->flags); /* capsData (4 bytes) */
+ Stream_Write_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
+ Stream_Write_UINT32(s, capsSet->flags); /* capsData (4 bytes) */
Stream_Zero(s, capsSet->length - 4);
}
Stream_SealLength(s);
- error = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s),
- Stream_Buffer(s), NULL);
+ error = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
+ NULL);
fail:
Stream_Free(s, TRUE);
return error;
@@ -109,17 +109,10 @@ fail:
static BOOL rdpgfx_is_capability_filtered(RDPGFX_PLUGIN* gfx, UINT32 caps)
{
const UINT32 filter = gfx->capsFilter;
- const UINT32 capList[] =
- {
- RDPGFX_CAPVERSION_8,
- RDPGFX_CAPVERSION_81,
- RDPGFX_CAPVERSION_10,
- RDPGFX_CAPVERSION_101,
- RDPGFX_CAPVERSION_102,
- RDPGFX_CAPVERSION_103,
- RDPGFX_CAPVERSION_104,
- RDPGFX_CAPVERSION_105,
- RDPGFX_CAPVERSION_106
+ const UINT32 capList[] = {
+ RDPGFX_CAPVERSION_8, RDPGFX_CAPVERSION_81, RDPGFX_CAPVERSION_10,
+ RDPGFX_CAPVERSION_101, RDPGFX_CAPVERSION_102, RDPGFX_CAPVERSION_103,
+ RDPGFX_CAPVERSION_104, RDPGFX_CAPVERSION_105, RDPGFX_CAPVERSION_106
};
UINT32 x;
@@ -148,18 +141,18 @@ static UINT rdpgfx_send_supported_caps(RDPGFX_CHANNEL_CALLBACK* callback)
if (!callback)
return ERROR_BAD_ARGUMENTS;
- gfx = (RDPGFX_PLUGIN*) callback->plugin;
+ gfx = (RDPGFX_PLUGIN*)callback->plugin;
if (!gfx)
return ERROR_BAD_CONFIGURATION;
- context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ context = (RdpgfxClientContext*)gfx->iface.pInterface;
if (!context)
return ERROR_BAD_CONFIGURATION;
pdu.capsSetCount = 0;
- pdu.capsSets = (RDPGFX_CAPSET*) capsSets;
+ pdu.capsSets = (RDPGFX_CAPSET*)capsSets;
if (!rdpgfx_is_capability_filtered(gfx, RDPGFX_CAPVERSION_8))
{
@@ -286,13 +279,12 @@ static UINT rdpgfx_send_supported_caps(RDPGFX_CHANNEL_CALLBACK* callback)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_CAPSET capsSet;
RDPGFX_CAPS_CONFIRM_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
pdu.capsSet = &capsSet;
if (Stream_GetRemainingLength(s) < 12)
@@ -302,11 +294,11 @@ static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT32(s, capsSet.version); /* version (4 bytes) */
- Stream_Read_UINT32(s, capsSet.length); /* capsDataLength (4 bytes) */
- Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */
+ Stream_Read_UINT32(s, capsSet.length); /* capsDataLength (4 bytes) */
+ Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */
gfx->ConnectionCaps = capsSet;
- DEBUG_RDPGFX(gfx->log, "RecvCapsConfirmPdu: version: 0x%08"PRIX32" flags: 0x%08"PRIX32"",
- capsSet.version, capsSet.flags);
+ DEBUG_RDPGFX(gfx->log, "RecvCapsConfirmPdu: version: 0x%08" PRIX32 " flags: 0x%08" PRIX32 "",
+ capsSet.version, capsSet.flags);
if (!context)
return ERROR_BAD_CONFIGURATION;
@@ -320,7 +312,7 @@ static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context,
- const RDPGFX_FRAME_ACKNOWLEDGE_PDU* pdu)
+ const RDPGFX_FRAME_ACKNOWLEDGE_PDU* pdu)
{
UINT error;
wStream* s;
@@ -331,7 +323,7 @@ static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context,
if (!context || !pdu)
return ERROR_BAD_ARGUMENTS;
- gfx = (RDPGFX_PLUGIN*) context->handle;
+ gfx = (RDPGFX_PLUGIN*)context->handle;
if (!gfx)
return ERROR_BAD_CONFIGURATION;
@@ -344,7 +336,7 @@ static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context,
header.flags = 0;
header.cmdId = RDPGFX_CMDID_FRAMEACKNOWLEDGE;
header.pduLength = RDPGFX_HEADER_SIZE + 12;
- DEBUG_RDPGFX(gfx->log, "SendFrameAcknowledgePdu: %"PRIu32"", pdu->frameId);
+ DEBUG_RDPGFX(gfx->log, "SendFrameAcknowledgePdu: %" PRIu32 "", pdu->frameId);
s = Stream_New(NULL, header.pduLength);
if (!s)
@@ -357,12 +349,11 @@ static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context,
goto fail;
/* RDPGFX_FRAME_ACKNOWLEDGE_PDU */
- Stream_Write_UINT32(s, pdu->queueDepth); /* queueDepth (4 bytes) */
- Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */
- Stream_Write_UINT32(s,
- pdu->totalFramesDecoded); /* totalFramesDecoded (4 bytes) */
- error = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s),
- Stream_Buffer(s), NULL);
+ Stream_Write_UINT32(s, pdu->queueDepth); /* queueDepth (4 bytes) */
+ Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */
+ Stream_Write_UINT32(s, pdu->totalFramesDecoded); /* totalFramesDecoded (4 bytes) */
+ error = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
+ NULL);
if (error == CHANNEL_RC_OK) /* frame successfully acked */
gfx->UnacknowledgedFrames--;
@@ -373,7 +364,7 @@ fail:
}
static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context,
- const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* pdu)
+ const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* pdu)
{
UINT error;
wStream* s;
@@ -387,7 +378,7 @@ static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context,
if (!context || !pdu)
return ERROR_BAD_ARGUMENTS;
- gfx = (RDPGFX_PLUGIN*) context->handle;
+ gfx = (RDPGFX_PLUGIN*)context->handle;
if (!gfx)
return ERROR_BAD_CONFIGURATION;
@@ -397,7 +388,7 @@ static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context,
if (!callback)
return ERROR_BAD_CONFIGURATION;
- DEBUG_RDPGFX(gfx->log, "SendQoeFrameAcknowledgePdu: %"PRIu32"", pdu->frameId);
+ DEBUG_RDPGFX(gfx->log, "SendQoeFrameAcknowledgePdu: %" PRIu32 "", pdu->frameId);
s = Stream_New(NULL, header.pduLength);
if (!s)
@@ -414,8 +405,8 @@ static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context,
Stream_Write_UINT32(s, pdu->timestamp);
Stream_Write_UINT16(s, pdu->timeDiffSE);
Stream_Write_UINT16(s, pdu->timeDiffEDR);
- error = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s),
- Stream_Buffer(s), NULL);
+ error = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
+ NULL);
fail:
Stream_Free(s, TRUE);
return error;
@@ -427,7 +418,7 @@ fail:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
- const RDPGFX_CACHE_IMPORT_OFFER_PDU* pdu)
+ const RDPGFX_CACHE_IMPORT_OFFER_PDU* pdu)
{
UINT16 index;
UINT error = CHANNEL_RC_OK;
@@ -440,7 +431,7 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
if (!context || !pdu)
return ERROR_BAD_ARGUMENTS;
- gfx = (RDPGFX_PLUGIN*) context->handle;
+ gfx = (RDPGFX_PLUGIN*)context->handle;
if (!gfx)
return ERROR_BAD_CONFIGURATION;
@@ -453,9 +444,10 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
header.flags = 0;
header.cmdId = RDPGFX_CMDID_CACHEIMPORTOFFER;
header.pduLength = RDPGFX_HEADER_SIZE + 2 + pdu->cacheEntriesCount * 12;
- DEBUG_RDPGFX(gfx->log, "SendCacheImportOfferPdu: cacheEntriesCount: %"PRIu16"", pdu->cacheEntriesCount);
+ DEBUG_RDPGFX(gfx->log, "SendCacheImportOfferPdu: cacheEntriesCount: %" PRIu16 "",
+ pdu->cacheEntriesCount);
s = Stream_New(NULL, header.pduLength);
-
+
if (!s)
{
WLog_ERR(TAG, "Stream_New failed!");
@@ -467,7 +459,7 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
if (pdu->cacheEntriesCount <= 0)
{
- WLog_ERR(TAG, "Invalid cacheEntriesCount: %"PRIu16"", pdu->cacheEntriesCount);
+ WLog_ERR(TAG, "Invalid cacheEntriesCount: %" PRIu16 "", pdu->cacheEntriesCount);
error = ERROR_INVALID_DATA;
goto fail;
}
@@ -478,12 +470,12 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context,
for (index = 0; index < pdu->cacheEntriesCount; index++)
{
cacheEntries = &(pdu->cacheEntries[index]);
- Stream_Write_UINT64(s, cacheEntries->cacheKey); /* cacheKey (8 bytes) */
+ Stream_Write_UINT64(s, cacheEntries->cacheKey); /* cacheKey (8 bytes) */
Stream_Write_UINT32(s, cacheEntries->bitmapLength); /* bitmapLength (4 bytes) */
}
- error = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s),
- Stream_Buffer(s), NULL);
+ error = callback->channel->Write(callback->channel, (UINT32)Stream_Length(s), Stream_Buffer(s),
+ NULL);
fail:
Stream_Free(s, TRUE);
@@ -495,15 +487,14 @@ fail:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
int pad;
UINT32 index;
MONITOR_DEF* monitor;
RDPGFX_RESET_GRAPHICS_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
GraphicsResetEventArgs graphicsReset;
@@ -513,8 +504,8 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, pdu.width); /* width (4 bytes) */
- Stream_Read_UINT32(s, pdu.height); /* height (4 bytes) */
+ Stream_Read_UINT32(s, pdu.width); /* width (4 bytes) */
+ Stream_Read_UINT32(s, pdu.height); /* height (4 bytes) */
Stream_Read_UINT32(s, pdu.monitorCount); /* monitorCount (4 bytes) */
if (Stream_GetRemainingLength(s) < (pdu.monitorCount * 20))
@@ -523,7 +514,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- pdu.monitorDefArray = (MONITOR_DEF*) calloc(pdu.monitorCount, sizeof(MONITOR_DEF));
+ pdu.monitorDefArray = (MONITOR_DEF*)calloc(pdu.monitorCount, sizeof(MONITOR_DEF));
if (!pdu.monitorDefArray)
{
@@ -534,16 +525,16 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
for (index = 0; index < pdu.monitorCount; index++)
{
monitor = &(pdu.monitorDefArray[index]);
- Stream_Read_UINT32(s, monitor->left); /* left (4 bytes) */
- Stream_Read_UINT32(s, monitor->top); /* top (4 bytes) */
- Stream_Read_UINT32(s, monitor->right); /* right (4 bytes) */
+ Stream_Read_UINT32(s, monitor->left); /* left (4 bytes) */
+ Stream_Read_UINT32(s, monitor->top); /* top (4 bytes) */
+ Stream_Read_UINT32(s, monitor->right); /* right (4 bytes) */
Stream_Read_UINT32(s, monitor->bottom); /* bottom (4 bytes) */
- Stream_Read_UINT32(s, monitor->flags); /* flags (4 bytes) */
+ Stream_Read_UINT32(s, monitor->flags); /* flags (4 bytes) */
}
pad = 340 - (RDPGFX_HEADER_SIZE + 12 + (pdu.monitorCount * 20));
- if (Stream_GetRemainingLength(s) < (size_t) pad)
+ if (Stream_GetRemainingLength(s) < (size_t)pad)
{
WLog_Print(gfx->log, WLOG_ERROR, "Stream_GetRemainingLength failed!");
free(pdu.monitorDefArray);
@@ -551,14 +542,17 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Seek(s, pad); /* pad (total size is 340 bytes) */
- DEBUG_RDPGFX(gfx->log, "RecvResetGraphicsPdu: width: %"PRIu32" height: %"PRIu32" count: %"PRIu32"",
- pdu.width, pdu.height, pdu.monitorCount);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvResetGraphicsPdu: width: %" PRIu32 " height: %" PRIu32 " count: %" PRIu32 "",
+ pdu.width, pdu.height, pdu.monitorCount);
for (index = 0; index < pdu.monitorCount; index++)
{
monitor = &(pdu.monitorDefArray[index]);
- DEBUG_RDPGFX(gfx->log, "RecvResetGraphicsPdu: monitor left:%"PRIi32" top:%"PRIi32" right:%"PRIi32" left:%"PRIi32" flags:0x%"PRIx32"",
- monitor->left, monitor->top, monitor->right, monitor->bottom, monitor->flags);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvResetGraphicsPdu: monitor left:%" PRIi32 " top:%" PRIi32 " right:%" PRIi32
+ " left:%" PRIi32 " flags:0x%" PRIx32 "",
+ monitor->left, monitor->top, monitor->right, monitor->bottom, monitor->flags);
}
if (context)
@@ -566,7 +560,8 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
IFCALLRET(context->ResetGraphics, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->ResetGraphics failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->ResetGraphics failed with error %" PRIu32 "",
+ error);
}
/* some listeners may be interested (namely the display channel) */
@@ -583,12 +578,11 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 2)
@@ -598,14 +592,16 @@ static UINT rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
- WLog_Print(gfx->log, WLOG_DEBUG, "RecvEvictCacheEntryPdu: cacheSlot: %"PRIu16"", pdu.cacheSlot);
+ WLog_Print(gfx->log, WLOG_DEBUG, "RecvEvictCacheEntryPdu: cacheSlot: %" PRIu16 "",
+ pdu.cacheSlot);
if (context)
{
IFCALLRET(context->EvictCacheEntry, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->EvictCacheEntry failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->EvictCacheEntry failed with error %" PRIu32 "", error);
}
return error;
@@ -616,13 +612,12 @@ static UINT rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
UINT16 index;
RDPGFX_CACHE_IMPORT_REPLY_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 2)
@@ -639,7 +634,7 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback
return ERROR_INVALID_DATA;
}
- pdu.cacheSlots = (UINT16*) calloc(pdu.importedEntriesCount, sizeof(UINT16));
+ pdu.cacheSlots = (UINT16*)calloc(pdu.importedEntriesCount, sizeof(UINT16));
if (!pdu.cacheSlots)
{
@@ -652,15 +647,16 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback
Stream_Read_UINT16(s, pdu.cacheSlots[index]); /* cacheSlot (2 bytes) */
}
- DEBUG_RDPGFX(gfx->log, "RecvCacheImportReplyPdu: importedEntriesCount: %"PRIu16"",
- pdu.importedEntriesCount);
+ DEBUG_RDPGFX(gfx->log, "RecvCacheImportReplyPdu: importedEntriesCount: %" PRIu16 "",
+ pdu.importedEntriesCount);
if (context)
{
IFCALLRET(context->CacheImportReply, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->CacheImportReply failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->CacheImportReply failed with error %" PRIu32 "", error);
}
free(pdu.cacheSlots);
@@ -672,12 +668,11 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_CREATE_SURFACE_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 7)
@@ -686,19 +681,22 @@ static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT16(s, pdu.width); /* width (2 bytes) */
- Stream_Read_UINT16(s, pdu.height); /* height (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.width); /* width (2 bytes) */
+ Stream_Read_UINT16(s, pdu.height); /* height (2 bytes) */
Stream_Read_UINT8(s, pdu.pixelFormat); /* RDPGFX_PIXELFORMAT (1 byte) */
- DEBUG_RDPGFX(gfx->log, "RecvCreateSurfacePdu: surfaceId: %"PRIu16" width: %"PRIu16" height: %"PRIu16" pixelFormat: 0x%02"PRIX8"",
- pdu.surfaceId, pdu.width, pdu.height, pdu.pixelFormat);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvCreateSurfacePdu: surfaceId: %" PRIu16 " width: %" PRIu16 " height: %" PRIu16
+ " pixelFormat: 0x%02" PRIX8 "",
+ pdu.surfaceId, pdu.width, pdu.height, pdu.pixelFormat);
if (context)
{
IFCALLRET(context->CreateSurface, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->CreateSurface failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->CreateSurface failed with error %" PRIu32 "",
+ error);
}
return error;
@@ -709,12 +707,11 @@ static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_DELETE_SURFACE_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 2)
@@ -724,14 +721,15 @@ static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- DEBUG_RDPGFX(gfx->log, "RecvDeleteSurfacePdu: surfaceId: %"PRIu16"", pdu.surfaceId);
+ DEBUG_RDPGFX(gfx->log, "RecvDeleteSurfacePdu: surfaceId: %" PRIu16 "", pdu.surfaceId);
if (context)
{
IFCALLRET(context->DeleteSurface, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->DeleteSurface failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->DeleteSurface failed with error %" PRIu32 "",
+ error);
}
return error;
@@ -742,12 +740,11 @@ static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_START_FRAME_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < RDPGFX_START_FRAME_PDU_SIZE)
@@ -757,9 +754,9 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
- Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
- DEBUG_RDPGFX(gfx->log, "RecvStartFramePdu: frameId: %"PRIu32" timestamp: 0x%08"PRIX32"",
- pdu.frameId, pdu.timestamp);
+ Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
+ DEBUG_RDPGFX(gfx->log, "RecvStartFramePdu: frameId: %" PRIu32 " timestamp: 0x%08" PRIX32 "",
+ pdu.frameId, pdu.timestamp);
gfx->StartDecodingTime = GetTickCount64();
if (context)
@@ -767,7 +764,8 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
IFCALLRET(context->StartFrame, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->StartFrame failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->StartFrame failed with error %" PRIu32 "",
+ error);
}
gfx->UnacknowledgedFrames++;
@@ -779,13 +777,12 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_END_FRAME_PDU pdu;
RDPGFX_FRAME_ACKNOWLEDGE_PDU ack;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < RDPGFX_END_FRAME_PDU_SIZE)
@@ -795,7 +792,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
- DEBUG_RDPGFX(gfx->log, "RecvEndFramePdu: frameId: %"PRIu32"", pdu.frameId);
+ DEBUG_RDPGFX(gfx->log, "RecvEndFramePdu: frameId: %" PRIu32 "", pdu.frameId);
if (context)
{
@@ -803,7 +800,8 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
if (error)
{
- WLog_Print(gfx->log, WLOG_ERROR, "context->EndFrame failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->EndFrame failed with error %" PRIu32 "",
+ error);
return error;
}
}
@@ -822,16 +820,17 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
if (gfx->TotalDecodedFrames == 1)
if ((error = rdpgfx_send_frame_acknowledge_pdu(context, &ack)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_send_frame_acknowledge_pdu failed with error %" PRIu32 "",
+ error);
}
else
{
ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
if ((error = rdpgfx_send_frame_acknowledge_pdu(context, &ack)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_send_frame_acknowledge_pdu failed with error %" PRIu32 "", error);
}
switch (gfx->ConnectionCaps.version)
@@ -857,7 +856,8 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
if ((error = rdpgfx_send_qoe_frame_acknowledge_pdu(context, &qoe)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_send_qoe_frame_acknowledge_pdu failed with error %"PRIu32"",
+ "rdpgfx_send_qoe_frame_acknowledge_pdu failed with error %" PRIu32
+ "",
error);
}
@@ -875,12 +875,11 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_SURFACE_COMMAND cmd;
RDPGFX_WIRE_TO_SURFACE_PDU_1 pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
UINT error;
if (Stream_GetRemainingLength(s) < RDPGFX_WIRE_TO_SURFACE_PDU_1_SIZE)
@@ -889,13 +888,13 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */
Stream_Read_UINT8(s, pdu.pixelFormat); /* pixelFormat (1 byte) */
if ((error = rdpgfx_read_rect16(s, &(pdu.destRect)))) /* destRect (8 bytes) */
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %" PRIu32 "", error);
return error;
}
@@ -910,13 +909,14 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
pdu.bitmapData = Stream_Pointer(s);
Stream_Seek(s, pdu.bitmapDataLength);
- DEBUG_RDPGFX(gfx->log, "RecvWireToSurface1Pdu: surfaceId: %"PRIu16" codecId: %s (0x%04"PRIX16") pixelFormat: 0x%02"PRIX8" "
- "destRect: left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16" bitmapDataLength: %"PRIu32"",
- pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId),
- pdu.codecId, pdu.pixelFormat,
- pdu.destRect.left, pdu.destRect.top,
- pdu.destRect.right, pdu.destRect.bottom,
- pdu.bitmapDataLength);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvWireToSurface1Pdu: surfaceId: %" PRIu16 " codecId: %s (0x%04" PRIX16
+ ") pixelFormat: 0x%02" PRIX8 " "
+ "destRect: left: %" PRIu16 " top: %" PRIu16 " right: %" PRIu16 " bottom: %" PRIu16
+ " bitmapDataLength: %" PRIu32 "",
+ pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId,
+ pdu.pixelFormat, pdu.destRect.left, pdu.destRect.top, pdu.destRect.right,
+ pdu.destRect.bottom, pdu.bitmapDataLength);
cmd.surfaceId = pdu.surfaceId;
cmd.codecId = pdu.codecId;
cmd.contextId = 0;
@@ -946,7 +946,7 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
cmd.extra = NULL;
if ((error = rdpgfx_decode(gfx, &cmd)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_decode failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_decode failed with error %" PRIu32 "!", error);
return error;
}
@@ -956,13 +956,12 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_SURFACE_COMMAND cmd;
RDPGFX_WIRE_TO_SURFACE_PDU_2 pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < RDPGFX_WIRE_TO_SURFACE_PDU_2_SIZE)
@@ -971,18 +970,19 @@ static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */
- Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */
- Stream_Read_UINT8(s, pdu.pixelFormat); /* pixelFormat (1 byte) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */
+ Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */
+ Stream_Read_UINT8(s, pdu.pixelFormat); /* pixelFormat (1 byte) */
Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */
pdu.bitmapData = Stream_Pointer(s);
Stream_Seek(s, pdu.bitmapDataLength);
- DEBUG_RDPGFX(gfx->log,
- "RecvWireToSurface2Pdu: surfaceId: %"PRIu16" codecId: %s (0x%04"PRIX16") "
- "codecContextId: %"PRIu32" pixelFormat: 0x%02"PRIX8" bitmapDataLength: %"PRIu32"",
- pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId,
- pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvWireToSurface2Pdu: surfaceId: %" PRIu16 " codecId: %s (0x%04" PRIX16 ") "
+ "codecContextId: %" PRIu32 " pixelFormat: 0x%02" PRIX8
+ " bitmapDataLength: %" PRIu32 "",
+ pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId,
+ pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength);
cmd.surfaceId = pdu.surfaceId;
cmd.codecId = pdu.codecId;
@@ -1017,7 +1017,8 @@ static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
IFCALLRET(context->SurfaceCommand, error, context, &cmd);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->SurfaceCommand failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->SurfaceCommand failed with error %" PRIu32 "", error);
}
return error;
@@ -1028,12 +1029,11 @@ static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK*
- callback, wStream* s)
+static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_DELETE_ENCODING_CONTEXT_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 6)
@@ -1042,19 +1042,20 @@ static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */
- DEBUG_RDPGFX(gfx->log, "RecvDeleteEncodingContextPdu: surfaceId: %"PRIu16" codecContextId: %"PRIu32"",
- pdu.surfaceId, pdu.codecContextId);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvDeleteEncodingContextPdu: surfaceId: %" PRIu16 " codecContextId: %" PRIu32 "",
+ pdu.surfaceId, pdu.codecContextId);
if (context)
{
IFCALLRET(context->DeleteEncodingContext, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->DeleteEncodingContext failed with error %"PRIu32"",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->DeleteEncodingContext failed with error %" PRIu32 "", error);
}
return error;
@@ -1070,8 +1071,8 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
UINT16 index;
RECTANGLE_16* fillRect;
RDPGFX_SOLID_FILL_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error;
if (Stream_GetRemainingLength(s) < 8)
@@ -1084,7 +1085,8 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
if ((error = rdpgfx_read_color32(s, &(pdu.fillPixel)))) /* fillPixel (4 bytes) */
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_color32 failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_color32 failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -1096,7 +1098,7 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
return ERROR_INVALID_DATA;
}
- pdu.fillRects = (RECTANGLE_16*) calloc(pdu.fillRectCount, sizeof(RECTANGLE_16));
+ pdu.fillRects = (RECTANGLE_16*)calloc(pdu.fillRectCount, sizeof(RECTANGLE_16));
if (!pdu.fillRects)
{
@@ -1110,20 +1112,22 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
if ((error = rdpgfx_read_rect16(s, fillRect)))
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %" PRIu32 "!",
+ error);
free(pdu.fillRects);
return error;
}
}
- DEBUG_RDPGFX(gfx->log, "RecvSolidFillPdu: surfaceId: %"PRIu16" fillRectCount: %"PRIu16"",
- pdu.surfaceId, pdu.fillRectCount);
+ DEBUG_RDPGFX(gfx->log, "RecvSolidFillPdu: surfaceId: %" PRIu16 " fillRectCount: %" PRIu16 "",
+ pdu.surfaceId, pdu.fillRectCount);
if (context)
{
IFCALLRET(context->SolidFill, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->SolidFill failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->SolidFill failed with error %" PRIu32 "",
+ error);
}
free(pdu.fillRects);
@@ -1135,14 +1139,13 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK*
- callback, wStream* s)
+static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
UINT16 index;
RDPGFX_POINT16* destPt;
RDPGFX_SURFACE_TO_SURFACE_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error;
if (Stream_GetRemainingLength(s) < 14)
@@ -1151,12 +1154,13 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceIdSrc); /* surfaceIdSrc (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceIdSrc); /* surfaceIdSrc (2 bytes) */
Stream_Read_UINT16(s, pdu.surfaceIdDest); /* surfaceIdDest (2 bytes) */
if ((error = rdpgfx_read_rect16(s, &(pdu.rectSrc)))) /* rectSrc (8 bytes ) */
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %" PRIu32 "!",
+ error);
return error;
}
@@ -1168,7 +1172,7 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK*
return ERROR_INVALID_DATA;
}
- pdu.destPts = (RDPGFX_POINT16*) calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16));
+ pdu.destPts = (RDPGFX_POINT16*)calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16));
if (!pdu.destPts)
{
@@ -1182,24 +1186,27 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK*
if ((error = rdpgfx_read_point16(s, destPt)))
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_point16 failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_point16 failed with error %" PRIu32 "!",
+ error);
free(pdu.destPts);
return error;
}
}
- DEBUG_RDPGFX(gfx->log, "RecvSurfaceToSurfacePdu: surfaceIdSrc: %"PRIu16" surfaceIdDest: %"PRIu16" "
- "left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16" destPtsCount: %"PRIu16"",
- pdu.surfaceIdSrc, pdu.surfaceIdDest,
- pdu.rectSrc.left, pdu.rectSrc.top, pdu.rectSrc.right, pdu.rectSrc.bottom,
- pdu.destPtsCount);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvSurfaceToSurfacePdu: surfaceIdSrc: %" PRIu16 " surfaceIdDest: %" PRIu16 " "
+ "left: %" PRIu16 " top: %" PRIu16 " right: %" PRIu16 " bottom: %" PRIu16
+ " destPtsCount: %" PRIu16 "",
+ pdu.surfaceIdSrc, pdu.surfaceIdDest, pdu.rectSrc.left, pdu.rectSrc.top,
+ pdu.rectSrc.right, pdu.rectSrc.bottom, pdu.destPtsCount);
if (context)
{
IFCALLRET(context->SurfaceToSurface, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->SurfaceToSurface failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->SurfaceToSurface failed with error %" PRIu32 "", error);
}
free(pdu.destPts);
@@ -1211,12 +1218,11 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_SURFACE_TO_CACHE_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error;
if (Stream_GetRemainingLength(s) < 20)
@@ -1226,28 +1232,30 @@ static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
}
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT64(s, pdu.cacheKey); /* cacheKey (8 bytes) */
+ Stream_Read_UINT64(s, pdu.cacheKey); /* cacheKey (8 bytes) */
Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
if ((error = rdpgfx_read_rect16(s, &(pdu.rectSrc)))) /* rectSrc (8 bytes ) */
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %" PRIu32 "!",
+ error);
return error;
}
- DEBUG_RDPGFX(gfx->log,
- "RecvSurfaceToCachePdu: surfaceId: %"PRIu16" cacheKey: 0x%016"PRIX64" cacheSlot: %"PRIu16" "
- "left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16"",
- pdu.surfaceId, pdu.cacheKey, pdu.cacheSlot,
- pdu.rectSrc.left, pdu.rectSrc.top,
- pdu.rectSrc.right, pdu.rectSrc.bottom);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvSurfaceToCachePdu: surfaceId: %" PRIu16 " cacheKey: 0x%016" PRIX64
+ " cacheSlot: %" PRIu16 " "
+ "left: %" PRIu16 " top: %" PRIu16 " right: %" PRIu16 " bottom: %" PRIu16 "",
+ pdu.surfaceId, pdu.cacheKey, pdu.cacheSlot, pdu.rectSrc.left, pdu.rectSrc.top,
+ pdu.rectSrc.right, pdu.rectSrc.bottom);
if (context)
{
IFCALLRET(context->SurfaceToCache, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->SurfaceToCache failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->SurfaceToCache failed with error %" PRIu32 "", error);
}
return error;
@@ -1258,14 +1266,13 @@ static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
UINT16 index;
RDPGFX_POINT16* destPt;
RDPGFX_CACHE_TO_SURFACE_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 6)
@@ -1274,8 +1281,8 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
Stream_Read_UINT16(s, pdu.destPtsCount); /* destPtsCount (2 bytes) */
if (Stream_GetRemainingLength(s) < (size_t)(pdu.destPtsCount * 4))
@@ -1284,7 +1291,7 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
return ERROR_INVALID_DATA;
}
- pdu.destPts = (RDPGFX_POINT16*) calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16));
+ pdu.destPts = (RDPGFX_POINT16*)calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16));
if (!pdu.destPts)
{
@@ -1298,22 +1305,25 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
if ((error = rdpgfx_read_point16(s, destPt)))
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_point16 failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_point16 failed with error %" PRIu32 "",
+ error);
free(pdu.destPts);
return error;
}
}
- DEBUG_RDPGFX(gfx->log,
- "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %"PRIu16" surfaceId: %"PRIu16" destPtsCount: %"PRIu16"",
- pdu.cacheSlot, pdu.surfaceId, pdu.destPtsCount);
+ DEBUG_RDPGFX(gfx->log,
+ "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %" PRIu16 " surfaceId: %" PRIu16
+ " destPtsCount: %" PRIu16 "",
+ pdu.cacheSlot, pdu.surfaceId, pdu.destPtsCount);
if (context)
{
IFCALLRET(context->CacheToSurface, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->CacheToSurface failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->CacheToSurface failed with error %" PRIu32 "", error);
}
free(pdu.destPts);
@@ -1325,12 +1335,11 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK*
- callback, wStream* s)
+static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 12)
@@ -1339,31 +1348,33 @@ static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK*
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */
Stream_Read_UINT32(s, pdu.outputOriginX); /* outputOriginX (4 bytes) */
Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */
- DEBUG_RDPGFX(gfx->log,
- "RecvMapSurfaceToOutputPdu: surfaceId: %"PRIu16" outputOriginX: %"PRIu32" outputOriginY: %"PRIu32"",
- pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvMapSurfaceToOutputPdu: surfaceId: %" PRIu16 " outputOriginX: %" PRIu32
+ " outputOriginY: %" PRIu32 "",
+ pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY);
if (context)
{
IFCALLRET(context->MapSurfaceToOutput, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->MapSurfaceToOutput failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->MapSurfaceToOutput failed with error %" PRIu32 "", error);
}
return error;
}
-static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK*
- callback, wStream* s)
+static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
+ wStream* s)
{
RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 20)
@@ -1372,23 +1383,25 @@ static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */
Stream_Read_UINT32(s, pdu.outputOriginX); /* outputOriginX (4 bytes) */
Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */
- Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */
- Stream_Read_UINT32(s, pdu.targetHeight); /* targetHeight (4 bytes) */
- DEBUG_RDPGFX(gfx->log,
- "RecvMapSurfaceToScaledOutputPdu: surfaceId: %"PRIu16" outputOriginX: %"PRIu32" outputOriginY: %"PRIu32" targetWidth: %"PRIu32" targetHeight: %"PRIu32,
- pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY, pdu.targetWidth, pdu.targetHeight);
+ Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */
+ Stream_Read_UINT32(s, pdu.targetHeight); /* targetHeight (4 bytes) */
+ DEBUG_RDPGFX(gfx->log,
+ "RecvMapSurfaceToScaledOutputPdu: surfaceId: %" PRIu16 " outputOriginX: %" PRIu32
+ " outputOriginY: %" PRIu32 " targetWidth: %" PRIu32 " targetHeight: %" PRIu32,
+ pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY, pdu.targetWidth,
+ pdu.targetHeight);
if (context)
{
IFCALLRET(context->MapSurfaceToScaledOutput, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->MapSurfaceToScaledOutput failed with error %"PRIu32"",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->MapSurfaceToScaledOutput failed with error %" PRIu32 "", error);
}
return error;
@@ -1399,12 +1412,11 @@ static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
RDPGFX_MAP_SURFACE_TO_WINDOW_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 18)
@@ -1413,31 +1425,33 @@ static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callb
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */
- Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */
+ Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */
Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */
- DEBUG_RDPGFX(gfx->log,
- "RecvMapSurfaceToWindowPdu: surfaceId: %"PRIu16" windowId: 0x%016"PRIX64" mappedWidth: %"PRIu32" mappedHeight: %"PRIu32"",
- pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvMapSurfaceToWindowPdu: surfaceId: %" PRIu16 " windowId: 0x%016" PRIX64
+ " mappedWidth: %" PRIu32 " mappedHeight: %" PRIu32 "",
+ pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight);
if (context && context->MapSurfaceToWindow)
{
IFCALLRET(context->MapSurfaceToWindow, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->MapSurfaceToWindow failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->MapSurfaceToWindow failed with error %" PRIu32 "", error);
}
return error;
}
static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
- wStream* s)
+ wStream* s)
{
RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU pdu;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
if (Stream_GetRemainingLength(s) < 26)
@@ -1446,23 +1460,26 @@ static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(RDPGFX_CHANNEL_CALLBACK
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
- Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */
- Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */
+ Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
+ Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */
+ Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */
Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */
- Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */
+ Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */
Stream_Read_UINT32(s, pdu.targetHeight); /* targetHeight (4 bytes) */
- DEBUG_RDPGFX(gfx->log,
- "RecvMapSurfaceToScaledWindowPdu: surfaceId: %"PRIu16" windowId: 0x%016"PRIX64" mappedWidth: %"PRIu32" mappedHeight: %"PRIu32" targetWidth: %"PRIu32" targetHeight: %"PRIu32"",
- pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight, pdu.targetWidth, pdu.targetHeight);
+ DEBUG_RDPGFX(gfx->log,
+ "RecvMapSurfaceToScaledWindowPdu: surfaceId: %" PRIu16 " windowId: 0x%016" PRIX64
+ " mappedWidth: %" PRIu32 " mappedHeight: %" PRIu32 " targetWidth: %" PRIu32
+ " targetHeight: %" PRIu32 "",
+ pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight, pdu.targetWidth,
+ pdu.targetHeight);
if (context && context->MapSurfaceToScaledWindow)
{
IFCALLRET(context->MapSurfaceToScaledWindow, error, context, &pdu);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->MapSurfaceToScaledWindow failed with error %"PRIu32"",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "context->MapSurfaceToScaledWindow failed with error %" PRIu32 "", error);
}
return error;
@@ -1478,32 +1495,34 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
size_t beg, end;
RDPGFX_HEADER header;
UINT error;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
beg = Stream_GetPosition(s);
if ((error = rdpgfx_read_header(s, &header)))
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_header failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_header failed with error %" PRIu32 "!",
+ error);
return error;
}
- DEBUG_RDPGFX(gfx->log,
- "cmdId: %s (0x%04"PRIX16") flags: 0x%04"PRIX16" pduLength: %"PRIu32"",
- rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags,
- header.pduLength);
+ DEBUG_RDPGFX(
+ gfx->log, "cmdId: %s (0x%04" PRIX16 ") flags: 0x%04" PRIX16 " pduLength: %" PRIu32 "",
+ rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength);
switch (header.cmdId)
{
case RDPGFX_CMDID_WIRETOSURFACE_1:
if ((error = rdpgfx_recv_wire_to_surface_1_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_wire_to_surface_1_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_wire_to_surface_1_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_WIRETOSURFACE_2:
if ((error = rdpgfx_recv_wire_to_surface_2_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_wire_to_surface_2_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_wire_to_surface_2_pdu failed with error %" PRIu32 "!",
error);
break;
@@ -1511,104 +1530,112 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
case RDPGFX_CMDID_DELETEENCODINGCONTEXT:
if ((error = rdpgfx_recv_delete_encoding_context_pdu(callback, s)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_recv_delete_encoding_context_pdu failed with error %"PRIu32"!",
+ "rdpgfx_recv_delete_encoding_context_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_SOLIDFILL:
if ((error = rdpgfx_recv_solid_fill_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_solid_fill_pdu failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_solid_fill_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_SURFACETOSURFACE:
if ((error = rdpgfx_recv_surface_to_surface_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_surface_to_surface_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_surface_to_surface_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_SURFACETOCACHE:
if ((error = rdpgfx_recv_surface_to_cache_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_surface_to_cache_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_surface_to_cache_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_CACHETOSURFACE:
if ((error = rdpgfx_recv_cache_to_surface_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_cache_to_surface_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_cache_to_surface_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_EVICTCACHEENTRY:
if ((error = rdpgfx_recv_evict_cache_entry_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_evict_cache_entry_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_evict_cache_entry_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_CREATESURFACE:
if ((error = rdpgfx_recv_create_surface_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_create_surface_pdu failed with error %"PRIu32"!",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_create_surface_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_DELETESURFACE:
if ((error = rdpgfx_recv_delete_surface_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_delete_surface_pdu failed with error %"PRIu32"!",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_delete_surface_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_STARTFRAME:
if ((error = rdpgfx_recv_start_frame_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_start_frame_pdu failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_start_frame_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_ENDFRAME:
if ((error = rdpgfx_recv_end_frame_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_end_frame_pdu failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_end_frame_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_RESETGRAPHICS:
if ((error = rdpgfx_recv_reset_graphics_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_reset_graphics_pdu failed with error %"PRIu32"!",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_reset_graphics_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_MAPSURFACETOOUTPUT:
if ((error = rdpgfx_recv_map_surface_to_output_pdu(callback, s)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_recv_map_surface_to_output_pdu failed with error %"PRIu32"!",
+ "rdpgfx_recv_map_surface_to_output_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_CACHEIMPORTREPLY:
if ((error = rdpgfx_recv_cache_import_reply_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_cache_import_reply_pdu failed with error %"PRIu32"!",
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_cache_import_reply_pdu failed with error %" PRIu32 "!",
error);
break;
case RDPGFX_CMDID_CAPSCONFIRM:
if ((error = rdpgfx_recv_caps_confirm_pdu(callback, s)))
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_caps_confirm_pdu failed with error %"PRIu32"!",
- error);
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "rdpgfx_recv_caps_confirm_pdu failed with error %" PRIu32 "!", error);
break;
case RDPGFX_CMDID_MAPSURFACETOWINDOW:
if ((error = rdpgfx_recv_map_surface_to_window_pdu(callback, s)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_recv_map_surface_to_window_pdu failed with error %"PRIu32"!",
+ "rdpgfx_recv_map_surface_to_window_pdu failed with error %" PRIu32 "!",
error);
break;
@@ -1616,7 +1643,8 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
case RDPGFX_CMDID_MAPSURFACETOSCALEDWINDOW:
if ((error = rdpgfx_recv_map_surface_to_scaled_window_pdu(callback, s)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_recv_map_surface_to_scaled_window_pdu failed with error %"PRIu32"!",
+ "rdpgfx_recv_map_surface_to_scaled_window_pdu failed with error %" PRIu32
+ "!",
error);
break;
@@ -1624,7 +1652,8 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
case RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT:
if ((error = rdpgfx_recv_map_surface_to_scaled_output_pdu(callback, s)))
WLog_Print(gfx->log, WLOG_ERROR,
- "rdpgfx_recv_map_surface_to_scaled_output_pdu failed with error %"PRIu32"!",
+ "rdpgfx_recv_map_surface_to_scaled_output_pdu failed with error %" PRIu32
+ "!",
error);
break;
@@ -1636,7 +1665,7 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
if (error)
{
- WLog_Print(gfx->log, WLOG_ERROR, "Error while parsing GFX cmdId: %s (0x%04"PRIX16")",
+ WLog_Print(gfx->log, WLOG_ERROR, "Error while parsing GFX cmdId: %s (0x%04" PRIX16 ")",
rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId);
return error;
}
@@ -1645,8 +1674,9 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
if (end != (beg + header.pduLength))
{
- WLog_Print(gfx->log, WLOG_ERROR, "Unexpected gfx pdu end: Actual: %d, Expected: %"PRIu32"",
- end, (beg + header.pduLength));
+ WLog_Print(gfx->log, WLOG_ERROR,
+ "Unexpected gfx pdu end: Actual: %d, Expected: %" PRIu32 "", end,
+ (beg + header.pduLength));
Stream_SetPosition(s, (beg + header.pduLength));
}
@@ -1658,15 +1688,14 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback*
- pChannelCallback, wStream* data)
+static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
wStream* s;
int status = 0;
UINT32 DstSize = 0;
BYTE* pDstData = NULL;
- RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
+ RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
UINT error = CHANNEL_RC_OK;
status = zgfx_decompress(gfx->zgfx, Stream_Pointer(data), Stream_GetRemainingLength(data),
&pDstData, &DstSize, 0);
@@ -1689,7 +1718,8 @@ static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback*
{
if ((error = rdpgfx_recv_pdu(callback, s)))
{
- WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_pdu failed with error %"PRIu32"!", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_recv_pdu failed with error %" PRIu32 "!",
+ error);
break;
}
}
@@ -1705,9 +1735,9 @@ static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback*
*/
static UINT rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback)
{
- RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
BOOL do_caps_advertise = TRUE;
gfx->sendFrameAcks = TRUE;
@@ -1717,7 +1747,8 @@ static UINT rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback)
IFCALLRET(context->OnOpen, error, context, &do_caps_advertise, &gfx->sendFrameAcks);
if (error)
- WLog_Print(gfx->log, WLOG_ERROR, "context->OnOpen failed with error %"PRIu32"", error);
+ WLog_Print(gfx->log, WLOG_ERROR, "context->OnOpen failed with error %" PRIu32 "",
+ error);
}
if (do_caps_advertise)
@@ -1736,10 +1767,10 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
int count;
int index;
ULONG_PTR* pKeys = NULL;
- RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
- DEBUG_RDPGFX(gfx->log, "OnClose");
+ RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
+ DEBUG_RDPGFX(gfx->log, "OnClose");
free(callback);
gfx->UnacknowledgedFrames = 0;
gfx->TotalDecodedFrames = 0;
@@ -1758,7 +1789,7 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
for (index = 0; index < count; index++)
{
RDPGFX_DELETE_SURFACE_PDU pdu;
- pdu.surfaceId = ((UINT16) pKeys[index]) - 1;
+ pdu.surfaceId = ((UINT16)pKeys[index]) - 1;
if (context && context->DeleteSurface)
{
@@ -1773,7 +1804,7 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
if (gfx->CacheSlots[index])
{
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
- pdu.cacheSlot = (UINT16) index;
+ pdu.cacheSlot = (UINT16)index;
if (context && context->EvictCacheEntry)
{
@@ -1797,14 +1828,14 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_on_new_channel_connection(IWTSListenerCallback*
- pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+static UINT rdpgfx_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
RDPGFX_CHANNEL_CALLBACK* callback;
RDPGFX_LISTENER_CALLBACK* listener_callback = (RDPGFX_LISTENER_CALLBACK*)pListenerCallback;
- callback = (RDPGFX_CHANNEL_CALLBACK*) calloc(1, sizeof(RDPGFX_CHANNEL_CALLBACK));
+ callback = (RDPGFX_CHANNEL_CALLBACK*)calloc(1, sizeof(RDPGFX_CHANNEL_CALLBACK));
if (!callback)
{
@@ -1819,7 +1850,7 @@ static UINT rdpgfx_on_new_channel_connection(IWTSListenerCallback*
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -1828,12 +1859,11 @@ static UINT rdpgfx_on_new_channel_connection(IWTSListenerCallback*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin,
- IWTSVirtualChannelManager* pChannelMgr)
+static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
UINT error;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin;
- gfx->listener_callback = (RDPGFX_LISTENER_CALLBACK*) calloc(1, sizeof(RDPGFX_LISTENER_CALLBACK));
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)pPlugin;
+ gfx->listener_callback = (RDPGFX_LISTENER_CALLBACK*)calloc(1, sizeof(RDPGFX_LISTENER_CALLBACK));
if (!gfx->listener_callback)
{
@@ -1845,7 +1875,8 @@ static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin,
gfx->listener_callback->plugin = pPlugin;
gfx->listener_callback->channel_mgr = pChannelMgr;
error = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*) gfx->listener_callback, &(gfx->listener));
+ (IWTSListenerCallback*)gfx->listener_callback,
+ &(gfx->listener));
gfx->listener->pInterface = gfx->iface.pInterface;
DEBUG_RDPGFX(gfx->log, "Initialize");
return error;
@@ -1861,8 +1892,8 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
int count;
int index;
ULONG_PTR* pKeys = NULL;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin;
- RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)pPlugin;
+ RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
UINT error = CHANNEL_RC_OK;
DEBUG_RDPGFX(gfx->log, "Terminated");
@@ -1871,7 +1902,7 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
for (index = 0; index < count; index++)
{
RDPGFX_DELETE_SURFACE_PDU pdu;
- pdu.surfaceId = ((UINT16) pKeys[index]) - 1;
+ pdu.surfaceId = ((UINT16)pKeys[index]) - 1;
if (context)
{
@@ -1886,13 +1917,12 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
}
}
-
for (index = 0; index < gfx->MaxCacheSlot; index++)
{
if (gfx->CacheSlots[index])
{
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
- pdu.cacheSlot = (UINT16) index;
+ pdu.cacheSlot = (UINT16)index;
if (context)
{
@@ -1919,17 +1949,16 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_set_surface_data(RdpgfxClientContext* context,
- UINT16 surfaceId, void* pData)
+static UINT rdpgfx_set_surface_data(RdpgfxClientContext* context, UINT16 surfaceId, void* pData)
{
ULONG_PTR key;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
- key = ((ULONG_PTR) surfaceId) + 1;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
+ key = ((ULONG_PTR)surfaceId) + 1;
if (pData)
- HashTable_Add(gfx->SurfaceTable, (void*) key, pData);
+ HashTable_Add(gfx->SurfaceTable, (void*)key, pData);
else
- HashTable_Remove(gfx->SurfaceTable, (void*) key);
+ HashTable_Remove(gfx->SurfaceTable, (void*)key);
return CHANNEL_RC_OK;
}
@@ -1939,14 +1968,14 @@ static UINT rdpgfx_set_surface_data(RdpgfxClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context,
- UINT16** ppSurfaceIds, UINT16* count_out)
+static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context, UINT16** ppSurfaceIds,
+ UINT16* count_out)
{
int count;
int index;
UINT16* pSurfaceIds;
ULONG_PTR* pKeys = NULL;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys);
if (count < 1)
@@ -1955,7 +1984,7 @@ static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context,
return CHANNEL_RC_OK;
}
- pSurfaceIds = (UINT16*) calloc(count, sizeof(UINT16));
+ pSurfaceIds = (UINT16*)calloc(count, sizeof(UINT16));
if (!pSurfaceIds)
{
@@ -1975,14 +2004,13 @@ static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context,
return CHANNEL_RC_OK;
}
-static void* rdpgfx_get_surface_data(RdpgfxClientContext* context,
- UINT16 surfaceId)
+static void* rdpgfx_get_surface_data(RdpgfxClientContext* context, UINT16 surfaceId)
{
ULONG_PTR key;
void* pData = NULL;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
- key = ((ULONG_PTR) surfaceId) + 1;
- pData = HashTable_GetItemValue(gfx->SurfaceTable, (void*) key);
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
+ key = ((ULONG_PTR)surfaceId) + 1;
+ pData = HashTable_GetItemValue(gfx->SurfaceTable, (void*)key);
return pData;
}
@@ -1991,14 +2019,13 @@ static void* rdpgfx_get_surface_data(RdpgfxClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_set_cache_slot_data(RdpgfxClientContext* context,
- UINT16 cacheSlot, void* pData)
+static UINT rdpgfx_set_cache_slot_data(RdpgfxClientContext* context, UINT16 cacheSlot, void* pData)
{
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (cacheSlot >= gfx->MaxCacheSlot)
{
- WLog_ERR(TAG, "%s: invalid cache slot %"PRIu16" maxAllowed=%"PRIu16"", __FUNCTION__,
+ WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 " maxAllowed=%" PRIu16 "", __FUNCTION__,
cacheSlot, gfx->MaxCacheSlot);
return ERROR_INVALID_INDEX;
}
@@ -2010,11 +2037,11 @@ static UINT rdpgfx_set_cache_slot_data(RdpgfxClientContext* context,
static void* rdpgfx_get_cache_slot_data(RdpgfxClientContext* context, UINT16 cacheSlot)
{
void* pData = NULL;
- RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
+ RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (cacheSlot >= gfx->MaxCacheSlot)
{
- WLog_ERR(TAG, "%s: invalid cache slot %"PRIu16" maxAllowed=%"PRIu16"", __FUNCTION__,
+ WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 " maxAllowed=%" PRIu16 "", __FUNCTION__,
cacheSlot, gfx->MaxCacheSlot);
return NULL;
}
@@ -2024,9 +2051,9 @@ static void* rdpgfx_get_cache_slot_data(RdpgfxClientContext* context, UINT16 cac
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry rdpgfx_DVCPluginEntry
+#define DVCPluginEntry rdpgfx_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
RdpgfxClientContext* rdpgfx_client_context_new(rdpSettings* settings)
@@ -2145,11 +2172,12 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error = CHANNEL_RC_OK;
RDPGFX_PLUGIN* gfx;
RdpgfxClientContext* context;
- gfx = (RDPGFX_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx");
+ gfx = (RDPGFX_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx");
if (!gfx)
{
- context = rdpgfx_client_context_new((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints));
+ context =
+ rdpgfx_client_context_new((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints));
if (!context)
{
@@ -2157,14 +2185,14 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
return CHANNEL_RC_NO_MEMORY;
}
- gfx = (RDPGFX_PLUGIN*) context->handle;
+ gfx = (RDPGFX_PLUGIN*)context->handle;
gfx->iface.Initialize = rdpgfx_plugin_initialize;
gfx->iface.Connected = NULL;
gfx->iface.Disconnected = NULL;
gfx->iface.Terminated = rdpgfx_plugin_terminated;
- error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*) gfx);
+ error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*)gfx);
}
return error;
diff --git a/channels/rdpgfx/client/rdpgfx_main.h b/channels/rdpgfx/client/rdpgfx_main.h
index f7dfdf254..3f58f2d14 100644
--- a/channels/rdpgfx/client/rdpgfx_main.h
+++ b/channels/rdpgfx/client/rdpgfx_main.h
@@ -89,4 +89,3 @@ struct _RDPGFX_PLUGIN
typedef struct _RDPGFX_PLUGIN RDPGFX_PLUGIN;
#endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_MAIN_H */
-
diff --git a/channels/rdpgfx/rdpgfx_common.c b/channels/rdpgfx/rdpgfx_common.c
index 1a01db323..090aa50ab 100644
--- a/channels/rdpgfx/rdpgfx_common.c
+++ b/channels/rdpgfx/rdpgfx_common.c
@@ -31,34 +31,31 @@
#include "rdpgfx_common.h"
-static const char* RDPGFX_CMDID_STRINGS[] =
-{
- "RDPGFX_CMDID_UNUSED_0000",
- "RDPGFX_CMDID_WIRETOSURFACE_1",
- "RDPGFX_CMDID_WIRETOSURFACE_2",
- "RDPGFX_CMDID_DELETEENCODINGCONTEXT",
- "RDPGFX_CMDID_SOLIDFILL",
- "RDPGFX_CMDID_SURFACETOSURFACE",
- "RDPGFX_CMDID_SURFACETOCACHE",
- "RDPGFX_CMDID_CACHETOSURFACE",
- "RDPGFX_CMDID_EVICTCACHEENTRY",
- "RDPGFX_CMDID_CREATESURFACE",
- "RDPGFX_CMDID_DELETESURFACE",
- "RDPGFX_CMDID_STARTFRAME",
- "RDPGFX_CMDID_ENDFRAME",
- "RDPGFX_CMDID_FRAMEACKNOWLEDGE",
- "RDPGFX_CMDID_RESETGRAPHICS",
- "RDPGFX_CMDID_MAPSURFACETOOUTPUT",
- "RDPGFX_CMDID_CACHEIMPORTOFFER",
- "RDPGFX_CMDID_CACHEIMPORTREPLY",
- "RDPGFX_CMDID_CAPSADVERTISE",
- "RDPGFX_CMDID_CAPSCONFIRM",
- "RDPGFX_CMDID_UNUSED_0014",
- "RDPGFX_CMDID_MAPSURFACETOWINDOW",
- "RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE",
- "RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT",
- "RDPGFX_CMDID_MAPSURFACETOSCALEDWINDOW"
-};
+static const char* RDPGFX_CMDID_STRINGS[] = { "RDPGFX_CMDID_UNUSED_0000",
+ "RDPGFX_CMDID_WIRETOSURFACE_1",
+ "RDPGFX_CMDID_WIRETOSURFACE_2",
+ "RDPGFX_CMDID_DELETEENCODINGCONTEXT",
+ "RDPGFX_CMDID_SOLIDFILL",
+ "RDPGFX_CMDID_SURFACETOSURFACE",
+ "RDPGFX_CMDID_SURFACETOCACHE",
+ "RDPGFX_CMDID_CACHETOSURFACE",
+ "RDPGFX_CMDID_EVICTCACHEENTRY",
+ "RDPGFX_CMDID_CREATESURFACE",
+ "RDPGFX_CMDID_DELETESURFACE",
+ "RDPGFX_CMDID_STARTFRAME",
+ "RDPGFX_CMDID_ENDFRAME",
+ "RDPGFX_CMDID_FRAMEACKNOWLEDGE",
+ "RDPGFX_CMDID_RESETGRAPHICS",
+ "RDPGFX_CMDID_MAPSURFACETOOUTPUT",
+ "RDPGFX_CMDID_CACHEIMPORTOFFER",
+ "RDPGFX_CMDID_CACHEIMPORTREPLY",
+ "RDPGFX_CMDID_CAPSADVERTISE",
+ "RDPGFX_CMDID_CAPSCONFIRM",
+ "RDPGFX_CMDID_UNUSED_0014",
+ "RDPGFX_CMDID_MAPSURFACETOWINDOW",
+ "RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE",
+ "RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT",
+ "RDPGFX_CMDID_MAPSURFACETOSCALEDWINDOW" };
const char* rdpgfx_get_cmd_id_string(UINT16 cmdId)
{
@@ -119,8 +116,8 @@ UINT rdpgfx_read_header(wStream* s, RDPGFX_HEADER* header)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Read_UINT16(s, header->cmdId); /* cmdId (2 bytes) */
- Stream_Read_UINT16(s, header->flags); /* flags (2 bytes) */
+ Stream_Read_UINT16(s, header->cmdId); /* cmdId (2 bytes) */
+ Stream_Read_UINT16(s, header->flags); /* flags (2 bytes) */
Stream_Read_UINT32(s, header->pduLength); /* pduLength (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -132,8 +129,8 @@ UINT rdpgfx_read_header(wStream* s, RDPGFX_HEADER* header)
*/
UINT rdpgfx_write_header(wStream* s, const RDPGFX_HEADER* header)
{
- Stream_Write_UINT16(s, header->cmdId); /* cmdId (2 bytes) */
- Stream_Write_UINT16(s, header->flags); /* flags (2 bytes) */
+ Stream_Write_UINT16(s, header->cmdId); /* cmdId (2 bytes) */
+ Stream_Write_UINT16(s, header->flags); /* flags (2 bytes) */
Stream_Write_UINT32(s, header->pduLength); /* pduLength (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -181,9 +178,9 @@ UINT rdpgfx_read_rect16(wStream* s, RECTANGLE_16* rect16)
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT16(s, rect16->left); /* left (2 bytes) */
- Stream_Read_UINT16(s, rect16->top); /* top (2 bytes) */
- Stream_Read_UINT16(s, rect16->right); /* right (2 bytes) */
+ Stream_Read_UINT16(s, rect16->left); /* left (2 bytes) */
+ Stream_Read_UINT16(s, rect16->top); /* top (2 bytes) */
+ Stream_Read_UINT16(s, rect16->right); /* right (2 bytes) */
Stream_Read_UINT16(s, rect16->bottom); /* bottom (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -195,9 +192,9 @@ UINT rdpgfx_read_rect16(wStream* s, RECTANGLE_16* rect16)
*/
UINT rdpgfx_write_rect16(wStream* s, const RECTANGLE_16* rect16)
{
- Stream_Write_UINT16(s, rect16->left); /* left (2 bytes) */
- Stream_Write_UINT16(s, rect16->top); /* top (2 bytes) */
- Stream_Write_UINT16(s, rect16->right); /* right (2 bytes) */
+ Stream_Write_UINT16(s, rect16->left); /* left (2 bytes) */
+ Stream_Write_UINT16(s, rect16->top); /* top (2 bytes) */
+ Stream_Write_UINT16(s, rect16->right); /* right (2 bytes) */
Stream_Write_UINT16(s, rect16->bottom); /* bottom (2 bytes) */
return CHANNEL_RC_OK;
}
@@ -215,9 +212,9 @@ UINT rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32)
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT8(s, color32->B); /* B (1 byte) */
- Stream_Read_UINT8(s, color32->G); /* G (1 byte) */
- Stream_Read_UINT8(s, color32->R); /* R (1 byte) */
+ Stream_Read_UINT8(s, color32->B); /* B (1 byte) */
+ Stream_Read_UINT8(s, color32->G); /* G (1 byte) */
+ Stream_Read_UINT8(s, color32->R); /* R (1 byte) */
Stream_Read_UINT8(s, color32->XA); /* XA (1 byte) */
return CHANNEL_RC_OK;
}
@@ -229,9 +226,9 @@ UINT rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32)
*/
UINT rdpgfx_write_color32(wStream* s, const RDPGFX_COLOR32* color32)
{
- Stream_Write_UINT8(s, color32->B); /* B (1 byte) */
- Stream_Write_UINT8(s, color32->G); /* G (1 byte) */
- Stream_Write_UINT8(s, color32->R); /* R (1 byte) */
+ Stream_Write_UINT8(s, color32->B); /* B (1 byte) */
+ Stream_Write_UINT8(s, color32->G); /* G (1 byte) */
+ Stream_Write_UINT8(s, color32->R); /* R (1 byte) */
Stream_Write_UINT8(s, color32->XA); /* XA (1 byte) */
return CHANNEL_RC_OK;
}
diff --git a/channels/rdpgfx/rdpgfx_common.h b/channels/rdpgfx/rdpgfx_common.h
index 4a7d6eca4..664c9cc08 100644
--- a/channels/rdpgfx/rdpgfx_common.h
+++ b/channels/rdpgfx/rdpgfx_common.h
@@ -44,10 +44,12 @@ FREERDP_LOCAL UINT rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32);
FREERDP_LOCAL UINT rdpgfx_write_color32(wStream* s, const RDPGFX_COLOR32* color32);
#ifdef WITH_DEBUG_RDPGFX
-#define DEBUG_RDPGFX(_LOGGER,...) WLog_Print(_LOGGER, WLOG_DEBUG, __VA_ARGS__)
+#define DEBUG_RDPGFX(_LOGGER, ...) WLog_Print(_LOGGER, WLOG_DEBUG, __VA_ARGS__)
#else
-#define DEBUG_RDPGFX(_LOGGER,...) do { } while (0)
+#define DEBUG_RDPGFX(_LOGGER, ...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CHANNEL_RDPGFX_COMMON_H */
-
diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c
index 793dcd1c3..34a77e06e 100644
--- a/channels/rdpgfx/server/rdpgfx_main.c
+++ b/channels/rdpgfx/server/rdpgfx_main.c
@@ -54,9 +54,7 @@ static INLINE UINT32 rdpgfx_pdu_length(UINT32 dataLen)
return RDPGFX_HEADER_SIZE + dataLen;
}
-
-static INLINE UINT rdpgfx_server_packet_init_header(wStream* s,
- UINT16 cmdId, UINT32 pduLength)
+static INLINE UINT rdpgfx_server_packet_init_header(wStream* s, UINT16 cmdId, UINT32 pduLength)
{
RDPGFX_HEADER header;
header.flags = 0;
@@ -74,8 +72,7 @@ static INLINE UINT rdpgfx_server_packet_init_header(wStream* s,
* @param s stream
* @param start saved start pos of the packet in the stream
*/
-static INLINE void rdpgfx_server_packet_complete_header(wStream* s,
- size_t start)
+static INLINE void rdpgfx_server_packet_complete_header(wStream* s, size_t start)
{
size_t current = Stream_GetPosition(s);
/* Fill actual length */
@@ -102,8 +99,7 @@ static UINT rdpgfx_server_packet_send(RdpgfxServerContext* context, wStream* s)
/* Allocate new stream with enough capacity. Additional overhead is
* descriptor (1 bytes) + segmentCount (2 bytes) + uncompressedSize (4 bytes)
* + segmentCount * size (4 bytes) */
- fs = Stream_New(NULL, SrcSize + 7
- + (SrcSize / ZGFX_SEGMENTED_MAXSIZE + 1) * 4);
+ fs = Stream_New(NULL, SrcSize + 7 + (SrcSize / ZGFX_SEGMENTED_MAXSIZE + 1) * 4);
if (!fs)
{
@@ -112,16 +108,14 @@ static UINT rdpgfx_server_packet_send(RdpgfxServerContext* context, wStream* s)
goto out;
}
- if (zgfx_compress_to_stream(context->priv->zgfx, fs, pSrcData,
- SrcSize, &flags) < 0)
+ if (zgfx_compress_to_stream(context->priv->zgfx, fs, pSrcData, SrcSize, &flags) < 0)
{
WLog_ERR(TAG, "zgfx_compress_to_stream failed!");
error = ERROR_INTERNAL_ERROR;
goto out;
}
- if (!WTSVirtualChannelWrite(context->priv->rdpgfx_channel,
- (PCHAR) Stream_Buffer(fs),
+ if (!WTSVirtualChannelWrite(context->priv->rdpgfx_channel, (PCHAR)Stream_Buffer(fs),
Stream_GetPosition(fs), &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
@@ -131,8 +125,8 @@ static UINT rdpgfx_server_packet_send(RdpgfxServerContext* context, wStream* s)
if (written < Stream_GetPosition(fs))
{
- WLog_WARN(TAG, "Unexpected bytes written: %"PRIu32"/%"PRIuz"",
- written, Stream_GetPosition(fs));
+ WLog_WARN(TAG, "Unexpected bytes written: %" PRIu32 "/%" PRIuz "", written,
+ Stream_GetPosition(fs));
}
error = CHANNEL_RC_OK;
@@ -169,7 +163,7 @@ static wStream* rdpgfx_server_single_packet_new(UINT16 cmdId, UINT32 dataLen)
if ((error = rdpgfx_server_packet_init_header(s, cmdId, pduLength)))
{
- WLog_ERR(TAG, "Failed to init header with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Failed to init header with error %" PRIu32 "!", error);
goto error;
}
@@ -187,8 +181,7 @@ error:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static INLINE UINT rdpgfx_server_single_packet_send(
- RdpgfxServerContext* context, wStream* s)
+static INLINE UINT rdpgfx_server_single_packet_send(RdpgfxServerContext* context, wStream* s)
{
/* Fill actual length */
rdpgfx_server_packet_complete_header(s, 0);
@@ -201,11 +194,11 @@ static INLINE UINT rdpgfx_server_single_packet_send(
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_caps_confirm_pdu(RdpgfxServerContext* context,
- const RDPGFX_CAPS_CONFIRM_PDU* capsConfirm)
+ const RDPGFX_CAPS_CONFIRM_PDU* capsConfirm)
{
RDPGFX_CAPSET* capsSet = capsConfirm->capsSet;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_CAPSCONFIRM, RDPGFX_CAPSET_BASE_SIZE + capsSet->length);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_CAPSCONFIRM,
+ RDPGFX_CAPSET_BASE_SIZE + capsSet->length);
if (!s)
{
@@ -214,7 +207,7 @@ static UINT rdpgfx_send_caps_confirm_pdu(RdpgfxServerContext* context,
}
Stream_Write_UINT32(s, capsSet->version); /* version (4 bytes) */
- Stream_Write_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
+ Stream_Write_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
if (capsSet->length >= 4)
{
@@ -233,7 +226,7 @@ static UINT rdpgfx_send_caps_confirm_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
- const RDPGFX_RESET_GRAPHICS_PDU* pdu)
+ const RDPGFX_RESET_GRAPHICS_PDU* pdu)
{
UINT32 index;
MONITOR_DEF* monitor;
@@ -242,14 +235,13 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
/* Check monitorCount. This ensures total size within 340 bytes) */
if (pdu->monitorCount >= 16)
{
- WLog_ERR(TAG, "Monitor count MUST be less than or equal to 16: %"PRIu32"",
+ WLog_ERR(TAG, "Monitor count MUST be less than or equal to 16: %" PRIu32 "",
pdu->monitorCount);
return ERROR_INVALID_DATA;
}
- s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_RESETGRAPHICS,
- RDPGFX_RESET_GRAPHICS_PDU_SIZE - RDPGFX_HEADER_SIZE);
+ s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_RESETGRAPHICS,
+ RDPGFX_RESET_GRAPHICS_PDU_SIZE - RDPGFX_HEADER_SIZE);
if (!s)
{
@@ -257,18 +249,18 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT32(s, pdu->width); /* width (4 bytes) */
- Stream_Write_UINT32(s, pdu->height); /* height (4 bytes) */
+ Stream_Write_UINT32(s, pdu->width); /* width (4 bytes) */
+ Stream_Write_UINT32(s, pdu->height); /* height (4 bytes) */
Stream_Write_UINT32(s, pdu->monitorCount); /* monitorCount (4 bytes) */
for (index = 0; index < pdu->monitorCount; index++)
{
monitor = &(pdu->monitorDefArray[index]);
- Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */
- Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */
- Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */
+ Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */
+ Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */
+ Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */
Stream_Write_UINT32(s, monitor->bottom); /* bottom (4 bytes) */
- Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
+ Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
}
/* pad (total size must be 340 bytes) */
@@ -282,7 +274,7 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_evict_cache_entry_pdu(RdpgfxServerContext* context,
- const RDPGFX_EVICT_CACHE_ENTRY_PDU* pdu)
+ const RDPGFX_EVICT_CACHE_ENTRY_PDU* pdu)
{
wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_EVICTCACHEENTRY, 2);
@@ -302,12 +294,11 @@ static UINT rdpgfx_send_evict_cache_entry_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_cache_import_reply_pdu(RdpgfxServerContext* context,
- const RDPGFX_CACHE_IMPORT_REPLY_PDU* pdu)
+ const RDPGFX_CACHE_IMPORT_REPLY_PDU* pdu)
{
UINT16 index;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_CACHEIMPORTREPLY,
- 2 + 2 * pdu->importedEntriesCount);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_CACHEIMPORTREPLY,
+ 2 + 2 * pdu->importedEntriesCount);
if (!s)
{
@@ -332,7 +323,7 @@ static UINT rdpgfx_send_cache_import_reply_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_create_surface_pdu(RdpgfxServerContext* context,
- const RDPGFX_CREATE_SURFACE_PDU* pdu)
+ const RDPGFX_CREATE_SURFACE_PDU* pdu)
{
wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_CREATESURFACE, 7);
@@ -342,9 +333,9 @@ static UINT rdpgfx_send_create_surface_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT16(s, pdu->width); /* width (2 bytes) */
- Stream_Write_UINT16(s, pdu->height); /* height (2 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT16(s, pdu->width); /* width (2 bytes) */
+ Stream_Write_UINT16(s, pdu->height); /* height (2 bytes) */
Stream_Write_UINT8(s, pdu->pixelFormat); /* RDPGFX_PIXELFORMAT (1 byte) */
return rdpgfx_server_single_packet_send(context, s);
}
@@ -355,7 +346,7 @@ static UINT rdpgfx_send_create_surface_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_delete_surface_pdu(RdpgfxServerContext* context,
- const RDPGFX_DELETE_SURFACE_PDU* pdu)
+ const RDPGFX_DELETE_SURFACE_PDU* pdu)
{
wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_DELETESURFACE, 2);
@@ -369,15 +360,13 @@ static UINT rdpgfx_send_delete_surface_pdu(RdpgfxServerContext* context,
return rdpgfx_server_single_packet_send(context, s);
}
-static INLINE void rdpgfx_write_start_frame_pdu(wStream* s,
- const RDPGFX_START_FRAME_PDU* pdu)
+static INLINE void rdpgfx_write_start_frame_pdu(wStream* s, const RDPGFX_START_FRAME_PDU* pdu)
{
Stream_Write_UINT32(s, pdu->timestamp); /* timestamp (4 bytes) */
- Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */
+ Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */
}
-static INLINE void rdpgfx_write_end_frame_pdu(wStream* s,
- const RDPGFX_END_FRAME_PDU* pdu)
+static INLINE void rdpgfx_write_end_frame_pdu(wStream* s, const RDPGFX_END_FRAME_PDU* pdu)
{
Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */
}
@@ -390,9 +379,8 @@ static INLINE void rdpgfx_write_end_frame_pdu(wStream* s,
static UINT rdpgfx_send_start_frame_pdu(RdpgfxServerContext* context,
const RDPGFX_START_FRAME_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_STARTFRAME,
- RDPGFX_START_FRAME_PDU_SIZE);
+ wStream* s =
+ rdpgfx_server_single_packet_new(RDPGFX_CMDID_STARTFRAME, RDPGFX_START_FRAME_PDU_SIZE);
if (!s)
{
@@ -409,12 +397,9 @@ static UINT rdpgfx_send_start_frame_pdu(RdpgfxServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_send_end_frame_pdu(RdpgfxServerContext* context,
- const RDPGFX_END_FRAME_PDU* pdu)
+static UINT rdpgfx_send_end_frame_pdu(RdpgfxServerContext* context, const RDPGFX_END_FRAME_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_ENDFRAME,
- RDPGFX_END_FRAME_PDU_SIZE);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_ENDFRAME, RDPGFX_END_FRAME_PDU_SIZE);
if (!s)
{
@@ -432,14 +417,13 @@ static UINT rdpgfx_send_end_frame_pdu(RdpgfxServerContext* context,
*
* @return estimated size
*/
-static INLINE UINT32 rdpgfx_estimate_h264_avc420(
- const RDPGFX_AVC420_BITMAP_STREAM* havc420)
+static INLINE UINT32 rdpgfx_estimate_h264_avc420(const RDPGFX_AVC420_BITMAP_STREAM* havc420)
{
/* H264 metadata + H264 stream. See rdpgfx_write_h264_avc420 */
return sizeof(UINT32) /* numRegionRects */
- + 10 /* regionRects + quantQualityVals */
- * havc420->meta.numRegionRects
- + havc420->length;
+ + 10 /* regionRects + quantQualityVals */
+ * havc420->meta.numRegionRects +
+ havc420->length;
}
/**
@@ -448,8 +432,7 @@ static INLINE UINT32 rdpgfx_estimate_h264_avc420(
*
* @return estimated size
*/
-static INLINE UINT32 rdpgfx_estimate_surface_command(const RDPGFX_SURFACE_COMMAND*
- cmd)
+static INLINE UINT32 rdpgfx_estimate_surface_command(const RDPGFX_SURFACE_COMMAND* cmd)
{
RDPGFX_AVC420_BITMAP_STREAM* havc420 = NULL;
RDPGFX_AVC444_BITMAP_STREAM* havc444 = NULL;
@@ -529,7 +512,7 @@ static UINT rdpgfx_write_h264_metablock(wStream* s, const RDPGFX_H264_METABLOCK*
if ((error = rdpgfx_write_rect16(s, regionRect)))
{
- WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -537,9 +520,8 @@ static UINT rdpgfx_write_h264_metablock(wStream* s, const RDPGFX_H264_METABLOCK*
for (index = 0; index < meta->numRegionRects; index++)
{
quantQualityVal = &(meta->quantQualityVals[index]);
- Stream_Write_UINT8(s, quantQualityVal->qp
- | (quantQualityVal->r << 6)
- | (quantQualityVal->p << 7)); /* qpVal (1 byte) */
+ Stream_Write_UINT8(s, quantQualityVal->qp | (quantQualityVal->r << 6) |
+ (quantQualityVal->p << 7)); /* qpVal (1 byte) */
/* qualityVal (1 byte) */
Stream_Write_UINT8(s, quantQualityVal->qualityVal);
}
@@ -553,15 +535,13 @@ static UINT rdpgfx_write_h264_metablock(wStream* s, const RDPGFX_H264_METABLOCK*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static INLINE UINT rdpgfx_write_h264_avc420(wStream* s,
- RDPGFX_AVC420_BITMAP_STREAM* havc420)
+static INLINE UINT rdpgfx_write_h264_avc420(wStream* s, RDPGFX_AVC420_BITMAP_STREAM* havc420)
{
UINT error = CHANNEL_RC_OK;
if ((error = rdpgfx_write_h264_metablock(s, &(havc420->meta))))
{
- WLog_ERR(TAG, "rdpgfx_write_h264_metablock failed with error %"PRIu32"!",
- error);
+ WLog_ERR(TAG, "rdpgfx_write_h264_metablock failed with error %" PRIu32 "!", error);
return error;
}
@@ -579,8 +559,7 @@ static INLINE UINT rdpgfx_write_h264_avc420(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_write_surface_command(wStream* s,
- const RDPGFX_SURFACE_COMMAND* cmd)
+static UINT rdpgfx_write_surface_command(wStream* s, const RDPGFX_SURFACE_COMMAND* cmd)
{
UINT error = CHANNEL_RC_OK;
RDPGFX_AVC420_BITMAP_STREAM* havc420 = NULL;
@@ -609,23 +588,23 @@ static UINT rdpgfx_write_surface_command(wStream* s,
{
/* Write RDPGFX_CMDID_WIRETOSURFACE_2 format for CAPROGRESSIVE */
Stream_Write_UINT16(s, cmd->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
+ Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
Stream_Write_UINT32(s, cmd->contextId); /* codecContextId (4 bytes) */
- Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
- Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
+ Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
+ Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
Stream_Write(s, cmd->data, cmd->length);
}
else
{
/* Write RDPGFX_CMDID_WIRETOSURFACE_1 format for others */
Stream_Write_UINT16(s, cmd->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
- Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
- Stream_Write_UINT16(s, cmd->left); /* left (2 bytes) */
- Stream_Write_UINT16(s, cmd->top); /* top (2 bytes) */
- Stream_Write_UINT16(s, cmd->right); /* right (2 bytes) */
- Stream_Write_UINT16(s, cmd->bottom); /* bottom (2 bytes) */
- Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
+ Stream_Write_UINT16(s, cmd->codecId); /* codecId (2 bytes) */
+ Stream_Write_UINT8(s, pixelFormat); /* pixelFormat (1 byte) */
+ Stream_Write_UINT16(s, cmd->left); /* left (2 bytes) */
+ Stream_Write_UINT16(s, cmd->top); /* top (2 bytes) */
+ Stream_Write_UINT16(s, cmd->right); /* right (2 bytes) */
+ Stream_Write_UINT16(s, cmd->bottom); /* bottom (2 bytes) */
+ Stream_Write_UINT32(s, cmd->length); /* bitmapDataLength (4 bytes) */
bitmapDataStart = Stream_GetPosition(s);
if (cmd->codecId == RDPGFX_CODECID_AVC420)
@@ -639,10 +618,11 @@ static UINT rdpgfx_write_surface_command(wStream* s,
return error;
}
}
- else if ((cmd->codecId == RDPGFX_CODECID_AVC444) || (cmd->codecId == RDPGFX_CODECID_AVC444v2))
+ else if ((cmd->codecId == RDPGFX_CODECID_AVC444) ||
+ (cmd->codecId == RDPGFX_CODECID_AVC444v2))
{
havc444 = (RDPGFX_AVC444_BITMAP_STREAM*)cmd->extra;
- havc420 = &(havc444->bitstream[0]); /* avc420EncodedBitstreamInfo (4 bytes) */
+ havc420 = &(havc444->bitstream[0]); /* avc420EncodedBitstreamInfo (4 bytes) */
Stream_Write_UINT32(s, havc444->cbAvc420EncodedBitstream1 | (havc444->LC << 30UL));
/* avc420EncodedBitstream1 */
error = rdpgfx_write_h264_avc420(s, havc420);
@@ -693,9 +673,8 @@ static UINT rdpgfx_send_surface_command(RdpgfxServerContext* context,
{
UINT error = CHANNEL_RC_OK;
wStream* s;
- s = rdpgfx_server_single_packet_new(
- rdpgfx_surface_command_cmdid(cmd),
- rdpgfx_estimate_surface_command(cmd));
+ s = rdpgfx_server_single_packet_new(rdpgfx_surface_command_cmdid(cmd),
+ rdpgfx_estimate_surface_command(cmd));
if (!s)
{
@@ -726,8 +705,9 @@ error:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_surface_frame_command(RdpgfxServerContext* context,
- const RDPGFX_SURFACE_COMMAND* cmd, const RDPGFX_START_FRAME_PDU* startFrame,
- const RDPGFX_END_FRAME_PDU* endFrame)
+ const RDPGFX_SURFACE_COMMAND* cmd,
+ const RDPGFX_START_FRAME_PDU* startFrame,
+ const RDPGFX_END_FRAME_PDU* endFrame)
{
UINT error = CHANNEL_RC_OK;
@@ -757,12 +737,11 @@ static UINT rdpgfx_send_surface_frame_command(RdpgfxServerContext* context,
if (startFrame)
{
position = Stream_GetPosition(s);
- error = rdpgfx_server_packet_init_header(s,
- RDPGFX_CMDID_STARTFRAME, 0);
+ error = rdpgfx_server_packet_init_header(s, RDPGFX_CMDID_STARTFRAME, 0);
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Failed to init header with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Failed to init header with error %" PRIu32 "!", error);
goto error;
}
@@ -772,13 +751,12 @@ static UINT rdpgfx_send_surface_frame_command(RdpgfxServerContext* context,
/* Write RDPGFX_CMDID_WIRETOSURFACE_1 or RDPGFX_CMDID_WIRETOSURFACE_2 */
position = Stream_GetPosition(s);
- error = rdpgfx_server_packet_init_header(s,
- rdpgfx_surface_command_cmdid(cmd),
- 0); // Actual length will be filled later
+ error = rdpgfx_server_packet_init_header(s, rdpgfx_surface_command_cmdid(cmd),
+ 0); // Actual length will be filled later
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Failed to init header with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Failed to init header with error %" PRIu32 "!", error);
goto error;
}
@@ -796,12 +774,11 @@ static UINT rdpgfx_send_surface_frame_command(RdpgfxServerContext* context,
if (endFrame)
{
position = Stream_GetPosition(s);
- error = rdpgfx_server_packet_init_header(s,
- RDPGFX_CMDID_ENDFRAME, 0);
+ error = rdpgfx_server_packet_init_header(s, RDPGFX_CMDID_ENDFRAME, 0);
if (error != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "Failed to init header with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "Failed to init header with error %" PRIu32 "!", error);
goto error;
}
@@ -820,12 +797,10 @@ error:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_send_delete_encoding_context_pdu(RdpgfxServerContext*
- context,
- const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* pdu)
+static UINT rdpgfx_send_delete_encoding_context_pdu(RdpgfxServerContext* context,
+ const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_DELETEENCODINGCONTEXT, 6);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_DELETEENCODINGCONTEXT, 6);
if (!s)
{
@@ -833,7 +808,7 @@ static UINT rdpgfx_send_delete_encoding_context_pdu(RdpgfxServerContext*
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
Stream_Write_UINT32(s, pdu->codecContextId); /* codecContextId (4 bytes) */
return rdpgfx_server_single_packet_send(context, s);
}
@@ -849,9 +824,8 @@ static UINT rdpgfx_send_solid_fill_pdu(RdpgfxServerContext* context,
UINT error = CHANNEL_RC_OK;
UINT16 index;
RECTANGLE_16* fillRect;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_SOLIDFILL,
- 8 + 8 * pdu->fillRectCount);
+ wStream* s =
+ rdpgfx_server_single_packet_new(RDPGFX_CMDID_SOLIDFILL, 8 + 8 * pdu->fillRectCount);
if (!s)
{
@@ -864,7 +838,7 @@ static UINT rdpgfx_send_solid_fill_pdu(RdpgfxServerContext* context,
/* fillPixel (4 bytes) */
if ((error = rdpgfx_write_color32(s, &(pdu->fillPixel))))
{
- WLog_ERR(TAG, "rdpgfx_write_color32 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_color32 failed with error %" PRIu32 "!", error);
goto error;
}
@@ -876,7 +850,7 @@ static UINT rdpgfx_send_solid_fill_pdu(RdpgfxServerContext* context,
if ((error = rdpgfx_write_rect16(s, fillRect)))
{
- WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %" PRIu32 "!", error);
goto error;
}
}
@@ -893,14 +867,13 @@ error:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_surface_to_surface_pdu(RdpgfxServerContext* context,
- const RDPGFX_SURFACE_TO_SURFACE_PDU* pdu)
+ const RDPGFX_SURFACE_TO_SURFACE_PDU* pdu)
{
UINT error = CHANNEL_RC_OK;
UINT16 index;
RDPGFX_POINT16* destPt;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_SURFACETOSURFACE,
- 14 + 4 * pdu->destPtsCount);
+ wStream* s =
+ rdpgfx_server_single_packet_new(RDPGFX_CMDID_SURFACETOSURFACE, 14 + 4 * pdu->destPtsCount);
if (!s)
{
@@ -908,13 +881,13 @@ static UINT rdpgfx_send_surface_to_surface_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceIdSrc); /* surfaceIdSrc (2 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceIdSrc); /* surfaceIdSrc (2 bytes) */
Stream_Write_UINT16(s, pdu->surfaceIdDest); /* surfaceIdDest (2 bytes) */
/* rectSrc (8 bytes ) */
if ((error = rdpgfx_write_rect16(s, &(pdu->rectSrc))))
{
- WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %" PRIu32 "!", error);
goto error;
}
@@ -926,7 +899,7 @@ static UINT rdpgfx_send_surface_to_surface_pdu(RdpgfxServerContext* context,
if ((error = rdpgfx_write_point16(s, destPt)))
{
- WLog_ERR(TAG, "rdpgfx_write_point16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_point16 failed with error %" PRIu32 "!", error);
goto error;
}
}
@@ -943,11 +916,10 @@ error:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_surface_to_cache_pdu(RdpgfxServerContext* context,
- const RDPGFX_SURFACE_TO_CACHE_PDU* pdu)
+ const RDPGFX_SURFACE_TO_CACHE_PDU* pdu)
{
UINT error = CHANNEL_RC_OK;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_SURFACETOCACHE, 20);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_SURFACETOCACHE, 20);
if (!s)
{
@@ -956,13 +928,13 @@ static UINT rdpgfx_send_surface_to_cache_pdu(RdpgfxServerContext* context,
}
Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT64(s, pdu->cacheKey); /* cacheKey (8 bytes) */
+ Stream_Write_UINT64(s, pdu->cacheKey); /* cacheKey (8 bytes) */
Stream_Write_UINT16(s, pdu->cacheSlot); /* cacheSlot (2 bytes) */
/* rectSrc (8 bytes ) */
if ((error = rdpgfx_write_rect16(s, &(pdu->rectSrc))))
{
- WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_write_rect16 failed with error %" PRIu32 "!", error);
goto error;
}
@@ -978,14 +950,13 @@ error:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_cache_to_surface_pdu(RdpgfxServerContext* context,
- const RDPGFX_CACHE_TO_SURFACE_PDU* pdu)
+ const RDPGFX_CACHE_TO_SURFACE_PDU* pdu)
{
UINT error = CHANNEL_RC_OK;
UINT16 index;
RDPGFX_POINT16* destPt;
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_CACHETOSURFACE,
- 6 + 4 * pdu->destPtsCount);
+ wStream* s =
+ rdpgfx_server_single_packet_new(RDPGFX_CMDID_CACHETOSURFACE, 6 + 4 * pdu->destPtsCount);
if (!s)
{
@@ -993,8 +964,8 @@ static UINT rdpgfx_send_cache_to_surface_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->cacheSlot); /* cacheSlot (2 bytes) */
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT16(s, pdu->cacheSlot); /* cacheSlot (2 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
Stream_Write_UINT16(s, pdu->destPtsCount); /* destPtsCount (2 bytes) */
for (index = 0; index < pdu->destPtsCount; index++)
@@ -1003,7 +974,7 @@ static UINT rdpgfx_send_cache_to_surface_pdu(RdpgfxServerContext* context,
if ((error = rdpgfx_write_point16(s, destPt)))
{
- WLog_ERR(TAG, "rdpgfx_write_point16 failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpgfx_write_point16 failed with error %" PRIu32 "", error);
goto error;
}
}
@@ -1020,10 +991,9 @@ error:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_map_surface_to_output_pdu(RdpgfxServerContext* context,
- const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* pdu)
+ const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_MAPSURFACETOOUTPUT, 12);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_MAPSURFACETOOUTPUT, 12);
if (!s)
{
@@ -1031,8 +1001,8 @@ static UINT rdpgfx_send_map_surface_to_output_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT16(s, 0); /* reserved (2 bytes). Must be 0 */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT16(s, 0); /* reserved (2 bytes). Must be 0 */
Stream_Write_UINT32(s, pdu->outputOriginX); /* outputOriginX (4 bytes) */
Stream_Write_UINT32(s, pdu->outputOriginY); /* outputOriginY (4 bytes) */
return rdpgfx_server_single_packet_send(context, s);
@@ -1044,10 +1014,9 @@ static UINT rdpgfx_send_map_surface_to_output_pdu(RdpgfxServerContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_map_surface_to_window_pdu(RdpgfxServerContext* context,
- const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* pdu)
+ const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_MAPSURFACETOWINDOW, 18);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_MAPSURFACETOWINDOW, 18);
if (!s)
{
@@ -1055,18 +1024,18 @@ static UINT rdpgfx_send_map_surface_to_window_pdu(RdpgfxServerContext* context,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT64(s, pdu->windowId); /* windowId (8 bytes) */
- Stream_Write_UINT32(s, pdu->mappedWidth); /* mappedWidth (4 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT64(s, pdu->windowId); /* windowId (8 bytes) */
+ Stream_Write_UINT32(s, pdu->mappedWidth); /* mappedWidth (4 bytes) */
Stream_Write_UINT32(s, pdu->mappedHeight); /* mappedHeight (4 bytes) */
return rdpgfx_server_single_packet_send(context, s);
}
-static UINT rdpgfx_send_map_surface_to_scaled_window_pdu(RdpgfxServerContext* context,
- const RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU* pdu)
+static UINT
+rdpgfx_send_map_surface_to_scaled_window_pdu(RdpgfxServerContext* context,
+ const RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_MAPSURFACETOWINDOW, 26);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_MAPSURFACETOWINDOW, 26);
if (!s)
{
@@ -1074,11 +1043,11 @@ static UINT rdpgfx_send_map_surface_to_scaled_window_pdu(RdpgfxServerContext* co
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT64(s, pdu->windowId); /* windowId (8 bytes) */
- Stream_Write_UINT32(s, pdu->mappedWidth); /* mappedWidth (4 bytes) */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT64(s, pdu->windowId); /* windowId (8 bytes) */
+ Stream_Write_UINT32(s, pdu->mappedWidth); /* mappedWidth (4 bytes) */
Stream_Write_UINT32(s, pdu->mappedHeight); /* mappedHeight (4 bytes) */
- Stream_Write_UINT32(s, pdu->targetWidth); /* targetWidth (4 bytes) */
+ Stream_Write_UINT32(s, pdu->targetWidth); /* targetWidth (4 bytes) */
Stream_Write_UINT32(s, pdu->targetHeight); /* targetHeight (4 bytes) */
return rdpgfx_server_single_packet_send(context, s);
}
@@ -1088,8 +1057,7 @@ static UINT rdpgfx_send_map_surface_to_scaled_window_pdu(RdpgfxServerContext* co
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_frame_acknowledge_pdu(RdpgfxServerContext* context,
- wStream* s)
+static UINT rdpgfx_recv_frame_acknowledge_pdu(RdpgfxServerContext* context, wStream* s)
{
RDPGFX_FRAME_ACKNOWLEDGE_PDU pdu;
UINT error = CHANNEL_RC_OK;
@@ -1100,8 +1068,8 @@ static UINT rdpgfx_recv_frame_acknowledge_pdu(RdpgfxServerContext* context,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, pdu.queueDepth); /* queueDepth (4 bytes) */
- Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
+ Stream_Read_UINT32(s, pdu.queueDepth); /* queueDepth (4 bytes) */
+ Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
Stream_Read_UINT32(s, pdu.totalFramesDecoded); /* totalFramesDecoded (4 bytes) */
if (context)
@@ -1109,8 +1077,7 @@ static UINT rdpgfx_recv_frame_acknowledge_pdu(RdpgfxServerContext* context,
IFCALLRET(context->FrameAcknowledge, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->FrameAcknowledge failed with error %"PRIu32"",
- error);
+ WLog_ERR(TAG, "context->FrameAcknowledge failed with error %" PRIu32 "", error);
}
return error;
@@ -1121,8 +1088,7 @@ static UINT rdpgfx_recv_frame_acknowledge_pdu(RdpgfxServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
- wStream* s)
+static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context, wStream* s)
{
UINT16 index;
RDPGFX_CACHE_IMPORT_OFFER_PDU pdu;
@@ -1141,7 +1107,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
if (pdu.cacheEntriesCount <= 0)
{
/* According to the latest spec, capsSetCount <= 3 */
- WLog_ERR(TAG, "Invalid cacheEntriesCount: %"PRIu16"", pdu.cacheEntriesCount);
+ WLog_ERR(TAG, "Invalid cacheEntriesCount: %" PRIu16 "", pdu.cacheEntriesCount);
return ERROR_INVALID_DATA;
}
@@ -1151,9 +1117,8 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
return ERROR_INVALID_DATA;
}
- pdu.cacheEntries = (RDPGFX_CACHE_ENTRY_METADATA*)
- calloc(pdu.cacheEntriesCount,
- sizeof(RDPGFX_CACHE_ENTRY_METADATA));
+ pdu.cacheEntries = (RDPGFX_CACHE_ENTRY_METADATA*)calloc(pdu.cacheEntriesCount,
+ sizeof(RDPGFX_CACHE_ENTRY_METADATA));
if (!pdu.cacheEntries)
{
@@ -1164,7 +1129,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
for (index = 0; index < pdu.cacheEntriesCount; index++)
{
cacheEntries = &(pdu.cacheEntries[index]);
- Stream_Read_UINT64(s, cacheEntries->cacheKey); /* cacheKey (8 bytes) */
+ Stream_Read_UINT64(s, cacheEntries->cacheKey); /* cacheKey (8 bytes) */
Stream_Read_UINT32(s, cacheEntries->bitmapLength); /* bitmapLength (4 bytes) */
}
@@ -1173,8 +1138,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
IFCALLRET(context->CacheImportOffer, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->CacheImportOffer failed with error %"PRIu32"",
- error);
+ WLog_ERR(TAG, "context->CacheImportOffer failed with error %" PRIu32 "", error);
}
free(pdu.cacheEntries);
@@ -1186,8 +1150,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context,
- wStream* s)
+static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context, wStream* s)
{
UINT16 index;
RDPGFX_CAPSET* capsSets;
@@ -1209,7 +1172,7 @@ static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context,
if (!capsSets)
return ERROR_OUTOFMEMORY;
- pdu.capsSets = (RDPGFX_CAPSET*) capsSets;
+ pdu.capsSets = (RDPGFX_CAPSET*)capsSets;
for (index = 0; index < pdu.capsSetCount; index++)
{
@@ -1219,7 +1182,7 @@ static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context,
goto fail;
Stream_Read_UINT32(s, capsSet->version); /* version (4 bytes) */
- Stream_Read_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
+ Stream_Read_UINT32(s, capsSet->length); /* capsDataLength (4 bytes) */
if (capsSet->length >= 4)
{
@@ -1237,7 +1200,7 @@ static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context,
IFCALLRET(context->CapsAdvertise, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->CapsAdvertise failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->CapsAdvertise failed with error %" PRIu32 "", error);
fail:
free(capsSets);
@@ -1249,8 +1212,7 @@ fail:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu(RdpgfxServerContext* context,
- wStream* s)
+static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu(RdpgfxServerContext* context, wStream* s)
{
RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU pdu;
UINT error = CHANNEL_RC_OK;
@@ -1261,9 +1223,9 @@ static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu(RdpgfxServerContext* context,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
- Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
- Stream_Read_UINT16(s, pdu.timeDiffSE); /* timeDiffSE (2 bytes) */
+ Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
+ Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
+ Stream_Read_UINT16(s, pdu.timeDiffSE); /* timeDiffSE (2 bytes) */
Stream_Read_UINT16(s, pdu.timeDiffEDR); /* timeDiffEDR (2 bytes) */
if (context)
@@ -1271,18 +1233,17 @@ static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu(RdpgfxServerContext* context,
IFCALLRET(context->QoeFrameAcknowledge, error, context, &pdu);
if (error)
- WLog_ERR(TAG, "context->QoeFrameAcknowledge failed with error %"PRIu32"",
- error);
+ WLog_ERR(TAG, "context->QoeFrameAcknowledge failed with error %" PRIu32 "", error);
}
return error;
}
-static UINT rdpgfx_send_map_surface_to_scaled_output_pdu(RdpgfxServerContext* context,
- const RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU* pdu)
+static UINT
+rdpgfx_send_map_surface_to_scaled_output_pdu(RdpgfxServerContext* context,
+ const RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU* pdu)
{
- wStream* s = rdpgfx_server_single_packet_new(
- RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT, 20);
+ wStream* s = rdpgfx_server_single_packet_new(RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT, 20);
if (!s)
{
@@ -1290,12 +1251,12 @@ static UINT rdpgfx_send_map_surface_to_scaled_output_pdu(RdpgfxServerContext* co
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
- Stream_Write_UINT16(s, 0); /* reserved (2 bytes). Must be 0 */
+ Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */
+ Stream_Write_UINT16(s, 0); /* reserved (2 bytes). Must be 0 */
Stream_Write_UINT32(s, pdu->outputOriginX); /* outputOriginX (4 bytes) */
Stream_Write_UINT32(s, pdu->outputOriginY); /* outputOriginY (4 bytes) */
- Stream_Write_UINT32(s, pdu->targetWidth); /* targetWidth (4 bytes) */
- Stream_Write_UINT32(s, pdu->targetHeight); /* targetHeight (4 bytes) */
+ Stream_Write_UINT32(s, pdu->targetWidth); /* targetWidth (4 bytes) */
+ Stream_Write_UINT32(s, pdu->targetHeight); /* targetHeight (4 bytes) */
return rdpgfx_server_single_packet_send(context, s);
}
@@ -1313,43 +1274,50 @@ static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s)
if ((error = rdpgfx_read_header(s, &header)))
{
- WLog_ERR(TAG, "rdpgfx_read_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "rdpgfx_read_header failed with error %" PRIu32 "!", error);
return error;
}
#ifdef WITH_DEBUG_RDPGFX
- WLog_DBG(TAG, "cmdId: %s (0x%04"PRIX16") flags: 0x%04"PRIX16" pduLength: %"PRIu32"",
- rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId,
- header.flags, header.pduLength);
+ WLog_DBG(TAG, "cmdId: %s (0x%04" PRIX16 ") flags: 0x%04" PRIX16 " pduLength: %" PRIu32 "",
+ rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength);
#endif
switch (header.cmdId)
{
case RDPGFX_CMDID_FRAMEACKNOWLEDGE:
if ((error = rdpgfx_recv_frame_acknowledge_pdu(context, s)))
- WLog_ERR(TAG, "rdpgfx_recv_frame_acknowledge_pdu "
- "failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "rdpgfx_recv_frame_acknowledge_pdu "
+ "failed with error %" PRIu32 "!",
+ error);
break;
case RDPGFX_CMDID_CACHEIMPORTOFFER:
if ((error = rdpgfx_recv_cache_import_offer_pdu(context, s)))
- WLog_ERR(TAG, "rdpgfx_recv_cache_import_offer_pdu "
- "failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "rdpgfx_recv_cache_import_offer_pdu "
+ "failed with error %" PRIu32 "!",
+ error);
break;
case RDPGFX_CMDID_CAPSADVERTISE:
if ((error = rdpgfx_recv_caps_advertise_pdu(context, s)))
- WLog_ERR(TAG, "rdpgfx_recv_caps_advertise_pdu "
- "failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "rdpgfx_recv_caps_advertise_pdu "
+ "failed with error %" PRIu32 "!",
+ error);
break;
case RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE:
if ((error = rdpgfx_recv_qoe_frame_acknowledge_pdu(context, s)))
- WLog_ERR(TAG, "rdpgfx_recv_qoe_frame_acknowledge_pdu "
- "failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG,
+ "rdpgfx_recv_qoe_frame_acknowledge_pdu "
+ "failed with error %" PRIu32 "!",
+ error);
break;
@@ -1360,7 +1328,7 @@ static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s)
if (error)
{
- WLog_ERR(TAG, "Error while parsing GFX cmdId: %s (0x%04"PRIX16")",
+ WLog_ERR(TAG, "Error while parsing GFX cmdId: %s (0x%04" PRIX16 ")",
rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId);
return error;
}
@@ -1369,8 +1337,8 @@ static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s)
if (end != (beg + header.pduLength))
{
- WLog_ERR(TAG, "Unexpected gfx pdu end: Actual: %d, Expected: %"PRIu32"",
- end, (beg + header.pduLength));
+ WLog_ERR(TAG, "Unexpected gfx pdu end: Actual: %d, Expected: %" PRIu32 "", end,
+ (beg + header.pduLength));
Stream_SetPosition(s, (beg + header.pduLength));
}
@@ -1379,7 +1347,7 @@ static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s)
static DWORD WINAPI rdpgfx_server_thread_func(LPVOID arg)
{
- RdpgfxServerContext* context = (RdpgfxServerContext*) arg;
+ RdpgfxServerContext* context = (RdpgfxServerContext*)arg;
RdpgfxServerPrivate* priv = context->priv;
DWORD status;
DWORD nCount;
@@ -1399,7 +1367,7 @@ static DWORD WINAPI rdpgfx_server_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -1409,15 +1377,13 @@ static DWORD WINAPI rdpgfx_server_thread_func(LPVOID arg)
if ((error = rdpgfx_server_handle_messages(context)))
{
- WLog_ERR(TAG, "rdpgfx_server_handle_messages failed with error %"PRIu32"",
- error);
+ WLog_ERR(TAG, "rdpgfx_server_handle_messages failed with error %" PRIu32 "", error);
break;
}
}
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "rdpgfx_server_thread_func reported an error");
+ setChannelError(context->rdpcontext, error, "rdpgfx_server_thread_func reported an error");
ExitThread(error);
return error;
@@ -1425,7 +1391,7 @@ static DWORD WINAPI rdpgfx_server_thread_func(LPVOID arg)
static BOOL rdpgfx_server_open(RdpgfxServerContext* context)
{
- RdpgfxServerPrivate* priv = (RdpgfxServerPrivate*) context->priv;
+ RdpgfxServerPrivate* priv = (RdpgfxServerPrivate*)context->priv;
void* buffer = NULL;
if (!priv->isOpened)
@@ -1434,19 +1400,17 @@ static BOOL rdpgfx_server_open(RdpgfxServerContext* context)
DWORD BytesReturned = 0;
priv->SessionId = WTS_CURRENT_SESSION;
- if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION,
- WTSSessionId, (LPSTR*) &pSessionId,
- &BytesReturned) == FALSE)
+ if (WTSQuerySessionInformationA(context->vcm, WTS_CURRENT_SESSION, WTSSessionId,
+ (LPSTR*)&pSessionId, &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSQuerySessionInformationA failed!");
return FALSE;
}
- priv->SessionId = (DWORD) * pSessionId;
+ priv->SessionId = (DWORD)*pSessionId;
WTSFreeMemory(pSessionId);
- priv->rdpgfx_channel = WTSVirtualChannelOpenEx(priv->SessionId,
- RDPGFX_DVC_CHANNEL_NAME,
- WTS_CHANNEL_OPTION_DYNAMIC);
+ priv->rdpgfx_channel = WTSVirtualChannelOpenEx(priv->SessionId, RDPGFX_DVC_CHANNEL_NAME,
+ WTS_CHANNEL_OPTION_DYNAMIC);
if (!priv->rdpgfx_channel)
{
@@ -1455,12 +1419,13 @@ static BOOL rdpgfx_server_open(RdpgfxServerContext* context)
}
/* Query for channel event handle */
- if (!WTSVirtualChannelQuery(priv->rdpgfx_channel, WTSVirtualEventHandle,
- &buffer, &BytesReturned)
- || (BytesReturned != sizeof(HANDLE)))
+ if (!WTSVirtualChannelQuery(priv->rdpgfx_channel, WTSVirtualEventHandle, &buffer,
+ &BytesReturned) ||
+ (BytesReturned != sizeof(HANDLE)))
{
- WLog_ERR(TAG, "WTSVirtualChannelQuery failed "
- "or invalid returned size(%"PRIu32")",
+ WLog_ERR(TAG,
+ "WTSVirtualChannelQuery failed "
+ "or invalid returned size(%" PRIu32 ")",
BytesReturned);
if (buffer)
@@ -1486,9 +1451,8 @@ static BOOL rdpgfx_server_open(RdpgfxServerContext* context)
goto out_zgfx;
}
- if (!(priv->thread = CreateThread(NULL, 0,
- rdpgfx_server_thread_func,
- (void*) context, 0, NULL)))
+ if (!(priv->thread =
+ CreateThread(NULL, 0, rdpgfx_server_thread_func, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
goto out_stopEvent;
@@ -1517,7 +1481,7 @@ out_close:
static BOOL rdpgfx_server_close(RdpgfxServerContext* context)
{
- RdpgfxServerPrivate* priv = (RdpgfxServerPrivate*) context->priv;
+ RdpgfxServerPrivate* priv = (RdpgfxServerPrivate*)context->priv;
if (priv->ownThread && priv->thread)
{
@@ -1525,8 +1489,7 @@ static BOOL rdpgfx_server_close(RdpgfxServerContext* context)
if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED)
{
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"",
- GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", GetLastError());
return FALSE;
}
@@ -1589,8 +1552,7 @@ RdpgfxServerContext* rdpgfx_server_context_new(HANDLE vcm)
context->CapsConfirm = rdpgfx_send_caps_confirm_pdu;
context->FrameAcknowledge = NULL;
context->QoeFrameAcknowledge = NULL;
- context->priv = priv = (RdpgfxServerPrivate*)
- calloc(1, sizeof(RdpgfxServerPrivate));
+ context->priv = priv = (RdpgfxServerPrivate*)calloc(1, sizeof(RdpgfxServerPrivate));
if (!priv)
{
@@ -1610,7 +1572,7 @@ RdpgfxServerContext* rdpgfx_server_context_new(HANDLE vcm)
priv->isOpened = FALSE;
priv->isReady = FALSE;
priv->ownThread = TRUE;
- return (RdpgfxServerContext*) context;
+ return (RdpgfxServerContext*)context;
out_free_priv:
free(context->priv);
out_free:
@@ -1654,9 +1616,8 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
/* Check whether the dynamic channel is ready */
if (!priv->isReady)
{
- if (WTSVirtualChannelQuery(priv->rdpgfx_channel,
- WTSVirtualChannelReady,
- &buffer, &BytesReturned) == FALSE)
+ if (WTSVirtualChannelQuery(priv->rdpgfx_channel, WTSVirtualChannelReady, &buffer,
+ &BytesReturned) == FALSE)
{
if (GetLastError() == ERROR_NO_DATA)
return ERROR_NO_DATA;
@@ -1665,7 +1626,7 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- priv->isReady = *((BOOL*) buffer);
+ priv->isReady = *((BOOL*)buffer);
WTSFreeMemory(buffer);
}
@@ -1674,8 +1635,7 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
{
Stream_SetPosition(s, 0);
- if (!WTSVirtualChannelRead(priv->rdpgfx_channel,
- 0, NULL, 0, &BytesReturned))
+ if (!WTSVirtualChannelRead(priv->rdpgfx_channel, 0, NULL, 0, &BytesReturned))
{
if (GetLastError() == ERROR_NO_DATA)
return ERROR_NO_DATA;
@@ -1693,8 +1653,7 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
return CHANNEL_RC_NO_MEMORY;
}
- if (WTSVirtualChannelRead(priv->rdpgfx_channel, 0,
- (PCHAR) Stream_Buffer(s),
+ if (WTSVirtualChannelRead(priv->rdpgfx_channel, 0, (PCHAR)Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE)
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
@@ -1708,8 +1667,10 @@ UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context)
{
if ((ret = rdpgfx_server_receive_pdu(context, s)))
{
- WLog_ERR(TAG, "rdpgfx_server_receive_pdu "
- "failed with error %"PRIu32"!", ret);
+ WLog_ERR(TAG,
+ "rdpgfx_server_receive_pdu "
+ "failed with error %" PRIu32 "!",
+ ret);
return ret;
}
}
diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c
index c085abf49..95e7a7976 100644
--- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c
+++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c
@@ -61,11 +61,11 @@ struct rdpsnd_alsa_plugin
snd_pcm_uframes_t period_size;
};
-#define SND_PCM_CHECK(_func, _status) \
- if (_status < 0) \
- { \
- WLog_ERR(TAG, "%s: %d\n", _func, _status); \
- return -1; \
+#define SND_PCM_CHECK(_func, _status) \
+ if (_status < 0) \
+ { \
+ WLog_ERR(TAG, "%s: %d\n", _func, _status); \
+ return -1; \
}
static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
@@ -78,7 +78,8 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
status = snd_pcm_hw_params_any(alsa->pcm_handle, hw_params);
SND_PCM_CHECK("snd_pcm_hw_params_any", status);
/* Set interleaved read/write access */
- status = snd_pcm_hw_params_set_access(alsa->pcm_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ status =
+ snd_pcm_hw_params_set_access(alsa->pcm_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
SND_PCM_CHECK("snd_pcm_hw_params_set_access", status);
/* Set sample format */
status = snd_pcm_hw_params_set_format(alsa->pcm_handle, hw_params, alsa->format);
@@ -111,7 +112,8 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
* It is also possible for the buffer size to not be an integer multiple of the period size.
*/
int interrupts_per_sec_near = 50;
- int bytes_per_sec = (alsa->actual_rate * alsa->aformat.wBitsPerSample / 8 * alsa->actual_channels);
+ int bytes_per_sec =
+ (alsa->actual_rate * alsa->aformat.wBitsPerSample / 8 * alsa->actual_channels);
alsa->buffer_size = buffer_size_max;
alsa->period_size = (bytes_per_sec / interrupts_per_sec_near);
@@ -123,11 +125,12 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa)
}
/* Set buffer size */
- status = snd_pcm_hw_params_set_buffer_size_near(alsa->pcm_handle, hw_params, &alsa->buffer_size);
+ status =
+ snd_pcm_hw_params_set_buffer_size_near(alsa->pcm_handle, hw_params, &alsa->buffer_size);
SND_PCM_CHECK("snd_pcm_hw_params_set_buffer_size_near", status);
/* Set period size */
status = snd_pcm_hw_params_set_period_size_near(alsa->pcm_handle, hw_params, &alsa->period_size,
- NULL);
+ NULL);
SND_PCM_CHECK("snd_pcm_hw_params_set_period_size_near", status);
status = snd_pcm_hw_params(alsa->pcm_handle, hw_params);
SND_PCM_CHECK("snd_pcm_hw_params", status);
@@ -144,10 +147,10 @@ static int rdpsnd_alsa_set_sw_params(rdpsndAlsaPlugin* alsa)
status = snd_pcm_sw_params_current(alsa->pcm_handle, sw_params);
SND_PCM_CHECK("snd_pcm_sw_params_current", status);
status = snd_pcm_sw_params_set_avail_min(alsa->pcm_handle, sw_params,
- (alsa->aformat.nChannels * alsa->actual_channels));
+ (alsa->aformat.nChannels * alsa->actual_channels));
SND_PCM_CHECK("snd_pcm_sw_params_set_avail_min", status);
status = snd_pcm_sw_params_set_start_threshold(alsa->pcm_handle, sw_params,
- alsa->aformat.nBlockAlign);
+ alsa->aformat.nBlockAlign);
SND_PCM_CHECK("snd_pcm_sw_params_set_start_threshold", status);
status = snd_pcm_sw_params(alsa->pcm_handle, sw_params);
SND_PCM_CHECK("snd_pcm_sw_params", status);
@@ -183,7 +186,7 @@ static int rdpsnd_alsa_set_params(rdpsndAlsaPlugin* alsa)
static BOOL rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
UINT32 latency)
{
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
if (format)
{
@@ -291,7 +294,7 @@ static BOOL rdpsnd_alsa_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* for
{
int mode;
int status;
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
if (alsa->pcm_handle)
return TRUE;
@@ -306,13 +309,12 @@ static BOOL rdpsnd_alsa_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* for
return FALSE;
}
- return rdpsnd_alsa_set_format(device, format, latency) &&
- rdpsnd_alsa_open_mixer(alsa);
+ return rdpsnd_alsa_set_format(device, format, latency) && rdpsnd_alsa_open_mixer(alsa);
}
static void rdpsnd_alsa_close(rdpsndDevicePlugin* device)
{
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
if (!alsa)
return;
@@ -322,7 +324,7 @@ static void rdpsnd_alsa_close(rdpsndDevicePlugin* device)
static void rdpsnd_alsa_free(rdpsndDevicePlugin* device)
{
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
rdpsnd_alsa_pcm_close(alsa);
rdpsnd_alsa_close_mixer(alsa);
free(alsa->device_name);
@@ -334,8 +336,7 @@ static BOOL rdpsnd_alsa_format_supported(rdpsndDevicePlugin* device, const AUDIO
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize == 0 &&
- format->nSamplesPerSec <= 48000 &&
+ if (format->cbSize == 0 && format->nSamplesPerSec <= 48000 &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels == 1 || format->nChannels == 2))
{
@@ -358,8 +359,8 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device)
UINT16 dwVolumeLeft;
UINT16 dwVolumeRight;
snd_mixer_elem_t* elem;
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
- dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
+ dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
if (!rdpsnd_alsa_open_mixer(alsa))
@@ -372,8 +373,10 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device)
snd_mixer_selem_get_playback_volume_range(elem, &volume_min, &volume_max);
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &volume_left);
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &volume_right);
- dwVolumeLeft = (UINT16)(((volume_left * 0xFFFF) - volume_min) / (volume_max - volume_min));
- dwVolumeRight = (UINT16)(((volume_right * 0xFFFF) - volume_min) / (volume_max - volume_min));
+ dwVolumeLeft =
+ (UINT16)(((volume_left * 0xFFFF) - volume_min) / (volume_max - volume_min));
+ dwVolumeRight =
+ (UINT16)(((volume_right * 0xFFFF) - volume_min) / (volume_max - volume_min));
break;
}
}
@@ -391,7 +394,7 @@ static BOOL rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
long volume_left;
long volume_right;
snd_mixer_elem_t* elem;
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
if (!rdpsnd_alsa_open_mixer(alsa))
return FALSE;
@@ -407,8 +410,10 @@ static BOOL rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value)
volume_left = volume_min + (left * (volume_max - volume_min)) / 0xFFFF;
volume_right = volume_min + (right * (volume_max - volume_min)) / 0xFFFF;
- if ((snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, volume_left) < 0) ||
- (snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, volume_right) < 0))
+ if ((snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, volume_left) <
+ 0) ||
+ (snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT,
+ volume_right) < 0))
{
WLog_ERR(TAG, "error setting the volume\n");
return FALSE;
@@ -424,21 +429,21 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
UINT latency;
size_t offset;
int frame_size;
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
offset = 0;
frame_size = alsa->actual_channels * alsa->aformat.wBitsPerSample / 8;
while (offset < size)
{
- snd_pcm_sframes_t status = snd_pcm_writei(alsa->pcm_handle, &data[offset],
- (size - offset) / frame_size);
+ snd_pcm_sframes_t status =
+ snd_pcm_writei(alsa->pcm_handle, &data[offset], (size - offset) / frame_size);
if (status < 0)
status = snd_pcm_recover(alsa->pcm_handle, status, 0);
if (status < 0)
{
- WLog_ERR(TAG, "status: %d\n", status);
+ WLog_ERR(TAG, "status: %d\n", status);
rdpsnd_alsa_close(device);
rdpsnd_alsa_open(device, NULL, alsa->latency);
break;
@@ -472,15 +477,14 @@ static UINT rdpsnd_alsa_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV*
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*) device;
- COMMAND_LINE_ARGUMENT_A rdpsnd_alsa_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_alsa_args, flags,
- alsa, NULL, NULL);
+ rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device;
+ COMMAND_LINE_ARGUMENT_A rdpsnd_alsa_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "device" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_alsa_args, flags, alsa, NULL,
+ NULL);
if (status < 0)
{
@@ -495,8 +499,7 @@ static UINT rdpsnd_alsa_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV*
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
alsa->device_name = _strdup(arg->Value);
@@ -504,16 +507,15 @@ static UINT rdpsnd_alsa_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV*
return CHANNEL_RC_NO_MEMORY;
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry alsa_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry alsa_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -526,7 +528,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
ADDIN_ARGV* args;
rdpsndAlsaPlugin* alsa;
UINT error;
- alsa = (rdpsndAlsaPlugin*) calloc(1, sizeof(rdpsndAlsaPlugin));
+ alsa = (rdpsndAlsaPlugin*)calloc(1, sizeof(rdpsndAlsaPlugin));
if (!alsa)
{
@@ -545,9 +547,9 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
if (args->argc > 1)
{
- if ((error = rdpsnd_alsa_parse_addin_args((rdpsndDevicePlugin*) alsa, args)))
+ if ((error = rdpsnd_alsa_parse_addin_args((rdpsndDevicePlugin*)alsa, args)))
{
- WLog_ERR(TAG, "rdpsnd_alsa_parse_addin_args failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpsnd_alsa_parse_addin_args failed with error %" PRIu32 "", error);
goto error_parse_args;
}
}
@@ -568,7 +570,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
alsa->actual_rate = 22050;
alsa->format = SND_PCM_FORMAT_S16_LE;
alsa->actual_channels = 2;
- pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*) alsa);
+ pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)alsa);
return CHANNEL_RC_OK;
error_strdup:
free(alsa->device_name);
diff --git a/channels/rdpsnd/client/fake/rdpsnd_fake.c b/channels/rdpsnd/client/fake/rdpsnd_fake.c
index 9c23baec2..6ae792659 100644
--- a/channels/rdpsnd/client/fake/rdpsnd_fake.c
+++ b/channels/rdpsnd/client/fake/rdpsnd_fake.c
@@ -57,7 +57,7 @@ static BOOL rdpsnd_fake_set_volume(rdpsndDevicePlugin* device, UINT32 value)
static void rdpsnd_fake_free(rdpsndDevicePlugin* device)
{
- rdpsndFakePlugin* fake = (rdpsndFakePlugin*) device;
+ rdpsndFakePlugin* fake = (rdpsndFakePlugin*)device;
if (!fake)
return;
@@ -95,13 +95,11 @@ static UINT rdpsnd_fake_parse_addin_args(rdpsndFakePlugin* fake, ADDIN_ARGV* arg
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- COMMAND_LINE_ARGUMENT_A rdpsnd_fake_args[] =
- {
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- rdpsnd_fake_args, flags, fake, NULL, NULL);
+ COMMAND_LINE_ARGUMENT_A rdpsnd_fake_args[] = { { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_fake_args, flags, fake, NULL,
+ NULL);
if (status < 0)
return ERROR_INVALID_DATA;
@@ -113,18 +111,16 @@ static UINT rdpsnd_fake_parse_addin_args(rdpsndFakePlugin* fake, ADDIN_ARGV* arg
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ CommandLineSwitchStart(arg) CommandLineSwitchEnd(arg)
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry fake_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry fake_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -137,7 +133,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
ADDIN_ARGV* args;
rdpsndFakePlugin* fake;
UINT ret = CHANNEL_RC_OK;
- fake = (rdpsndFakePlugin*) calloc(1, sizeof(rdpsndFakePlugin));
+ fake = (rdpsndFakePlugin*)calloc(1, sizeof(rdpsndFakePlugin));
if (!fake)
return CHANNEL_RC_NO_MEMORY;
diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.c b/channels/rdpsnd/client/ios/TPCircularBuffer.c
index 1c9402799..b29f61184 100644
--- a/channels/rdpsnd/client/ios/TPCircularBuffer.c
+++ b/channels/rdpsnd/client/ios/TPCircularBuffer.c
@@ -35,106 +35,119 @@
#include
#include
-#define reportResult(result,operation) (_reportResult((result),(operation),__FILE__,__LINE__))
-static inline bool _reportResult(kern_return_t result, const char *operation, const char* file, int line) {
- if ( result != ERR_SUCCESS ) {
- WLog_DBG(TAG, "%s:%d: %s: %s\n", file, line, operation, mach_error_string(result));
- return false;
- }
- return true;
+#define reportResult(result, operation) (_reportResult((result), (operation), __FILE__, __LINE__))
+static inline bool _reportResult(kern_return_t result, const char* operation, const char* file,
+ int line)
+{
+ if (result != ERR_SUCCESS)
+ {
+ WLog_DBG(TAG, "%s:%d: %s: %s\n", file, line, operation, mach_error_string(result));
+ return false;
+ }
+ return true;
}
-bool TPCircularBufferInit(TPCircularBuffer *buffer, int length) {
+bool TPCircularBufferInit(TPCircularBuffer* buffer, int length)
+{
- // Keep trying until we get our buffer, needed to handle race conditions
- int retries = 3;
- while ( true ) {
+ // Keep trying until we get our buffer, needed to handle race conditions
+ int retries = 3;
+ while (true)
+ {
- buffer->length = round_page(length); // We need whole page sizes
+ buffer->length = round_page(length); // We need whole page sizes
- // Temporarily allocate twice the length, so we have the contiguous address space to
- // support a second instance of the buffer directly after
- vm_address_t bufferAddress;
- kern_return_t result = vm_allocate(mach_task_self(),
- &bufferAddress,
- buffer->length * 2,
- VM_FLAGS_ANYWHERE); // allocate anywhere it'll fit
- if ( result != ERR_SUCCESS ) {
- if ( retries-- == 0 ) {
- reportResult(result, "Buffer allocation");
- return false;
- }
- // Try again if we fail
- continue;
- }
-
- // Now replace the second half of the allocation with a virtual copy of the first half. Deallocate the second half...
- result = vm_deallocate(mach_task_self(),
- bufferAddress + buffer->length,
- buffer->length);
- if ( result != ERR_SUCCESS ) {
- if ( retries-- == 0 ) {
- reportResult(result, "Buffer deallocation");
- return false;
- }
- // If this fails somehow, deallocate the whole region and try again
- vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
- continue;
- }
-
- // Re-map the buffer to the address space immediately after the buffer
- vm_address_t virtualAddress = bufferAddress + buffer->length;
- vm_prot_t cur_prot, max_prot;
- result = vm_remap(mach_task_self(),
- &virtualAddress, // mirror target
- buffer->length, // size of mirror
- 0, // auto alignment
- 0, // force remapping to virtualAddress
- mach_task_self(), // same task
- bufferAddress, // mirror source
- 0, // MAP READ-WRITE, NOT COPY
- &cur_prot, // unused protection struct
- &max_prot, // unused protection struct
- VM_INHERIT_DEFAULT);
- if ( result != ERR_SUCCESS ) {
- if ( retries-- == 0 ) {
- reportResult(result, "Remap buffer memory");
- return false;
- }
- // If this remap failed, we hit a race condition, so deallocate and try again
- vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
- continue;
- }
-
- if ( virtualAddress != bufferAddress+buffer->length ) {
- // If the memory is not contiguous, clean up both allocated buffers and try again
- if ( retries-- == 0 ) {
- WLog_DBG(TAG, "Couldn't map buffer memory to end of buffer");
- return false;
- }
+ // Temporarily allocate twice the length, so we have the contiguous address space to
+ // support a second instance of the buffer directly after
+ vm_address_t bufferAddress;
+ kern_return_t result = vm_allocate(mach_task_self(), &bufferAddress, buffer->length * 2,
+ VM_FLAGS_ANYWHERE); // allocate anywhere it'll fit
+ if (result != ERR_SUCCESS)
+ {
+ if (retries-- == 0)
+ {
+ reportResult(result, "Buffer allocation");
+ return false;
+ }
+ // Try again if we fail
+ continue;
+ }
- vm_deallocate(mach_task_self(), virtualAddress, buffer->length);
- vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
- continue;
- }
-
- buffer->buffer = (void*)bufferAddress;
- buffer->fillCount = 0;
- buffer->head = buffer->tail = 0;
-
- return true;
- }
- return false;
+ // Now replace the second half of the allocation with a virtual copy of the first half.
+ // Deallocate the second half...
+ result = vm_deallocate(mach_task_self(), bufferAddress + buffer->length, buffer->length);
+ if (result != ERR_SUCCESS)
+ {
+ if (retries-- == 0)
+ {
+ reportResult(result, "Buffer deallocation");
+ return false;
+ }
+ // If this fails somehow, deallocate the whole region and try again
+ vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
+ continue;
+ }
+
+ // Re-map the buffer to the address space immediately after the buffer
+ vm_address_t virtualAddress = bufferAddress + buffer->length;
+ vm_prot_t cur_prot, max_prot;
+ result = vm_remap(mach_task_self(),
+ &virtualAddress, // mirror target
+ buffer->length, // size of mirror
+ 0, // auto alignment
+ 0, // force remapping to virtualAddress
+ mach_task_self(), // same task
+ bufferAddress, // mirror source
+ 0, // MAP READ-WRITE, NOT COPY
+ &cur_prot, // unused protection struct
+ &max_prot, // unused protection struct
+ VM_INHERIT_DEFAULT);
+ if (result != ERR_SUCCESS)
+ {
+ if (retries-- == 0)
+ {
+ reportResult(result, "Remap buffer memory");
+ return false;
+ }
+ // If this remap failed, we hit a race condition, so deallocate and try again
+ vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
+ continue;
+ }
+
+ if (virtualAddress != bufferAddress + buffer->length)
+ {
+ // If the memory is not contiguous, clean up both allocated buffers and try again
+ if (retries-- == 0)
+ {
+ WLog_DBG(TAG, "Couldn't map buffer memory to end of buffer");
+ return false;
+ }
+
+ vm_deallocate(mach_task_self(), virtualAddress, buffer->length);
+ vm_deallocate(mach_task_self(), bufferAddress, buffer->length);
+ continue;
+ }
+
+ buffer->buffer = (void*)bufferAddress;
+ buffer->fillCount = 0;
+ buffer->head = buffer->tail = 0;
+
+ return true;
+ }
+ return false;
}
-void TPCircularBufferCleanup(TPCircularBuffer *buffer) {
- vm_deallocate(mach_task_self(), (vm_address_t)buffer->buffer, buffer->length * 2);
- memset(buffer, 0, sizeof(TPCircularBuffer));
+void TPCircularBufferCleanup(TPCircularBuffer* buffer)
+{
+ vm_deallocate(mach_task_self(), (vm_address_t)buffer->buffer, buffer->length * 2);
+ memset(buffer, 0, sizeof(TPCircularBuffer));
}
-void TPCircularBufferClear(TPCircularBuffer *buffer) {
- int32_t fillCount;
- if ( TPCircularBufferTail(buffer, &fillCount) ) {
- TPCircularBufferConsume(buffer, fillCount);
- }
+void TPCircularBufferClear(TPCircularBuffer* buffer)
+{
+ int32_t fillCount;
+ if (TPCircularBufferTail(buffer, &fillCount))
+ {
+ TPCircularBufferConsume(buffer, fillCount);
+ }
}
diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.h b/channels/rdpsnd/client/ios/TPCircularBuffer.h
index cd2a4d837..d246efae2 100644
--- a/channels/rdpsnd/client/ios/TPCircularBuffer.h
+++ b/channels/rdpsnd/client/ios/TPCircularBuffer.h
@@ -8,9 +8,10 @@
//
//
// This implementation makes use of a virtual memory mapping technique that inserts a virtual copy
-// of the buffer memory directly after the buffer's end, negating the need for any buffer wrap-around
-// logic. Clients can simply use the returned memory address as if it were contiguous space.
-//
+// of the buffer memory directly after the buffer's end, negating the need for any buffer
+// wrap-around logic. Clients can simply use the returned memory address as if it were contiguous
+// space.
+//
// The implementation is thread-safe in the case of a single producer and single consumer.
//
// Virtual memory technique originally proposed by Philip Howard (http://vrb.slashusr.org/), and
@@ -47,146 +48,167 @@
#include
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-
-typedef struct {
- void *buffer;
- int32_t length;
- int32_t tail;
- int32_t head;
- volatile int32_t fillCount;
-} TPCircularBuffer;
-/*!
- * Initialise buffer
- *
- * Note that the length is advisory only: Because of the way the
- * memory mirroring technique works, the true buffer length will
- * be multiples of the device page size (e.g. 4096 bytes)
- *
- * @param buffer Circular buffer
- * @param length Length of buffer
- */
-bool TPCircularBufferInit(TPCircularBuffer *buffer, int32_t length);
+ typedef struct
+ {
+ void* buffer;
+ int32_t length;
+ int32_t tail;
+ int32_t head;
+ volatile int32_t fillCount;
+ } TPCircularBuffer;
-/*!
- * Cleanup buffer
- *
- * Releases buffer resources.
- */
-void TPCircularBufferCleanup(TPCircularBuffer *buffer);
+ /*!
+ * Initialise buffer
+ *
+ * Note that the length is advisory only: Because of the way the
+ * memory mirroring technique works, the true buffer length will
+ * be multiples of the device page size (e.g. 4096 bytes)
+ *
+ * @param buffer Circular buffer
+ * @param length Length of buffer
+ */
+ bool TPCircularBufferInit(TPCircularBuffer* buffer, int32_t length);
-/*!
- * Clear buffer
- *
- * Resets buffer to original, empty state.
- *
- * This is safe for use by consumer while producer is accessing
- * buffer.
- */
-void TPCircularBufferClear(TPCircularBuffer *buffer);
+ /*!
+ * Cleanup buffer
+ *
+ * Releases buffer resources.
+ */
+ void TPCircularBufferCleanup(TPCircularBuffer* buffer);
-// Reading (consuming)
+ /*!
+ * Clear buffer
+ *
+ * Resets buffer to original, empty state.
+ *
+ * This is safe for use by consumer while producer is accessing
+ * buffer.
+ */
+ void TPCircularBufferClear(TPCircularBuffer* buffer);
-/*!
- * Access end of buffer
- *
- * This gives you a pointer to the end of the buffer, ready
- * for reading, and the number of available bytes to read.
- *
- * @param buffer Circular buffer
- * @param availableBytes On output, the number of bytes ready for reading
- * @return Pointer to the first bytes ready for reading, or NULL if buffer is empty
- */
-static __inline__ __attribute__((always_inline)) void* TPCircularBufferTail(TPCircularBuffer *buffer, int32_t* availableBytes) {
- *availableBytes = buffer->fillCount;
- if ( *availableBytes == 0 ) return NULL;
- return (void*)((char*)buffer->buffer + buffer->tail);
-}
+ // Reading (consuming)
-/*!
- * Consume bytes in buffer
- *
- * This frees up the just-read bytes, ready for writing again.
- *
- * @param buffer Circular buffer
- * @param amount Number of bytes to consume
- */
-static __inline__ __attribute__((always_inline)) void TPCircularBufferConsume(TPCircularBuffer *buffer, int32_t amount) {
- buffer->tail = (buffer->tail + amount) % buffer->length;
- OSAtomicAdd32Barrier(-amount, &buffer->fillCount);
- assert(buffer->fillCount >= 0);
-}
+ /*!
+ * Access end of buffer
+ *
+ * This gives you a pointer to the end of the buffer, ready
+ * for reading, and the number of available bytes to read.
+ *
+ * @param buffer Circular buffer
+ * @param availableBytes On output, the number of bytes ready for reading
+ * @return Pointer to the first bytes ready for reading, or NULL if buffer is empty
+ */
+ static __inline__ __attribute__((always_inline)) void*
+ TPCircularBufferTail(TPCircularBuffer* buffer, int32_t* availableBytes)
+ {
+ *availableBytes = buffer->fillCount;
+ if (*availableBytes == 0)
+ return NULL;
+ return (void*)((char*)buffer->buffer + buffer->tail);
+ }
-/*!
- * Version of TPCircularBufferConsume without the memory barrier, for more optimal use in single-threaded contexts
- */
-static __inline__ __attribute__((always_inline)) void TPCircularBufferConsumeNoBarrier(TPCircularBuffer *buffer, int32_t amount) {
- buffer->tail = (buffer->tail + amount) % buffer->length;
- buffer->fillCount -= amount;
- assert(buffer->fillCount >= 0);
-}
+ /*!
+ * Consume bytes in buffer
+ *
+ * This frees up the just-read bytes, ready for writing again.
+ *
+ * @param buffer Circular buffer
+ * @param amount Number of bytes to consume
+ */
+ static __inline__ __attribute__((always_inline)) void
+ TPCircularBufferConsume(TPCircularBuffer* buffer, int32_t amount)
+ {
+ buffer->tail = (buffer->tail + amount) % buffer->length;
+ OSAtomicAdd32Barrier(-amount, &buffer->fillCount);
+ assert(buffer->fillCount >= 0);
+ }
-/*!
- * Access front of buffer
- *
- * This gives you a pointer to the front of the buffer, ready
- * for writing, and the number of available bytes to write.
- *
- * @param buffer Circular buffer
- * @param availableBytes On output, the number of bytes ready for writing
- * @return Pointer to the first bytes ready for writing, or NULL if buffer is full
- */
-static __inline__ __attribute__((always_inline)) void* TPCircularBufferHead(TPCircularBuffer *buffer, int32_t* availableBytes) {
- *availableBytes = (buffer->length - buffer->fillCount);
- if ( *availableBytes == 0 ) return NULL;
- return (void*)((char*)buffer->buffer + buffer->head);
-}
-
-// Writing (producing)
+ /*!
+ * Version of TPCircularBufferConsume without the memory barrier, for more optimal use in
+ * single-threaded contexts
+ */
+ static __inline__ __attribute__((always_inline)) void
+ TPCircularBufferConsumeNoBarrier(TPCircularBuffer* buffer, int32_t amount)
+ {
+ buffer->tail = (buffer->tail + amount) % buffer->length;
+ buffer->fillCount -= amount;
+ assert(buffer->fillCount >= 0);
+ }
-/*!
- * Produce bytes in buffer
- *
- * This marks the given section of the buffer ready for reading.
- *
- * @param buffer Circular buffer
- * @param amount Number of bytes to produce
- */
-static __inline__ __attribute__((always_inline)) void TPCircularBufferProduce(TPCircularBuffer *buffer, int amount) {
- buffer->head = (buffer->head + amount) % buffer->length;
- OSAtomicAdd32Barrier(amount, &buffer->fillCount);
- assert(buffer->fillCount <= buffer->length);
-}
+ /*!
+ * Access front of buffer
+ *
+ * This gives you a pointer to the front of the buffer, ready
+ * for writing, and the number of available bytes to write.
+ *
+ * @param buffer Circular buffer
+ * @param availableBytes On output, the number of bytes ready for writing
+ * @return Pointer to the first bytes ready for writing, or NULL if buffer is full
+ */
+ static __inline__ __attribute__((always_inline)) void*
+ TPCircularBufferHead(TPCircularBuffer* buffer, int32_t* availableBytes)
+ {
+ *availableBytes = (buffer->length - buffer->fillCount);
+ if (*availableBytes == 0)
+ return NULL;
+ return (void*)((char*)buffer->buffer + buffer->head);
+ }
-/*!
- * Version of TPCircularBufferProduce without the memory barrier, for more optimal use in single-threaded contexts
- */
-static __inline__ __attribute__((always_inline)) void TPCircularBufferProduceNoBarrier(TPCircularBuffer *buffer, int amount) {
- buffer->head = (buffer->head + amount) % buffer->length;
- buffer->fillCount += amount;
- assert(buffer->fillCount <= buffer->length);
-}
+ // Writing (producing)
-/*!
- * Helper routine to copy bytes to buffer
- *
- * This copies the given bytes to the buffer, and marks them ready for writing.
- *
- * @param buffer Circular buffer
- * @param src Source buffer
- * @param len Number of bytes in source buffer
- * @return true if bytes copied, false if there was insufficient space
- */
-static __inline__ __attribute__((always_inline)) bool TPCircularBufferProduceBytes(TPCircularBuffer *buffer, const void* src, int32_t len) {
- int32_t space;
- void *ptr = TPCircularBufferHead(buffer, &space);
- if ( space < len ) return false;
- memcpy(ptr, src, len);
- TPCircularBufferProduce(buffer, len);
- return true;
-}
+ /*!
+ * Produce bytes in buffer
+ *
+ * This marks the given section of the buffer ready for reading.
+ *
+ * @param buffer Circular buffer
+ * @param amount Number of bytes to produce
+ */
+ static __inline__ __attribute__((always_inline)) void
+ TPCircularBufferProduce(TPCircularBuffer* buffer, int amount)
+ {
+ buffer->head = (buffer->head + amount) % buffer->length;
+ OSAtomicAdd32Barrier(amount, &buffer->fillCount);
+ assert(buffer->fillCount <= buffer->length);
+ }
+
+ /*!
+ * Version of TPCircularBufferProduce without the memory barrier, for more optimal use in
+ * single-threaded contexts
+ */
+ static __inline__ __attribute__((always_inline)) void
+ TPCircularBufferProduceNoBarrier(TPCircularBuffer* buffer, int amount)
+ {
+ buffer->head = (buffer->head + amount) % buffer->length;
+ buffer->fillCount += amount;
+ assert(buffer->fillCount <= buffer->length);
+ }
+
+ /*!
+ * Helper routine to copy bytes to buffer
+ *
+ * This copies the given bytes to the buffer, and marks them ready for writing.
+ *
+ * @param buffer Circular buffer
+ * @param src Source buffer
+ * @param len Number of bytes in source buffer
+ * @return true if bytes copied, false if there was insufficient space
+ */
+ static __inline__ __attribute__((always_inline)) bool
+ TPCircularBufferProduceBytes(TPCircularBuffer* buffer, const void* src, int32_t len)
+ {
+ int32_t space;
+ void* ptr = TPCircularBufferHead(buffer, &space);
+ if (space < len)
+ return false;
+ memcpy(ptr, src, len);
+ TPCircularBufferProduce(buffer, len);
+ return true;
+ }
#ifdef __cplusplus
}
diff --git a/channels/rdpsnd/client/ios/rdpsnd_ios.c b/channels/rdpsnd/client/ios/rdpsnd_ios.c
index 643164441..29feb97cc 100644
--- a/channels/rdpsnd/client/ios/rdpsnd_ios.c
+++ b/channels/rdpsnd/client/ios/rdpsnd_ios.c
@@ -33,8 +33,8 @@
#include "rdpsnd_main.h"
#include "TPCircularBuffer.h"
-#define INPUT_BUFFER_SIZE 32768
-#define CIRCULAR_BUFFER_SIZE (INPUT_BUFFER_SIZE * 4)
+#define INPUT_BUFFER_SIZE 32768
+#define CIRCULAR_BUFFER_SIZE (INPUT_BUFFER_SIZE * 4)
typedef struct rdpsnd_ios_plugin
{
@@ -47,14 +47,10 @@ typedef struct rdpsnd_ios_plugin
#define THIS(__ptr) ((rdpsndIOSPlugin*)__ptr)
-static OSStatus rdpsnd_ios_render_cb(
- void* inRefCon,
- AudioUnitRenderActionFlags __unused* ioActionFlags,
- const AudioTimeStamp __unused* inTimeStamp,
- UInt32 inBusNumber,
- UInt32 __unused inNumberFrames,
- AudioBufferList* ioData
-)
+static OSStatus rdpsnd_ios_render_cb(void* inRefCon,
+ AudioUnitRenderActionFlags __unused* ioActionFlags,
+ const AudioTimeStamp __unused* inTimeStamp, UInt32 inBusNumber,
+ UInt32 __unused inNumberFrames, AudioBufferList* ioData)
{
unsigned int i;
@@ -182,22 +178,17 @@ static BOOL rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in
return FALSE;
/* Set the format for the AudioUnit. */
- AudioStreamBasicDescription audioFormat = {0};
- audioFormat.mSampleRate = format->nSamplesPerSec;
- audioFormat.mFormatID = kAudioFormatLinearPCM;
- audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
- audioFormat.mFramesPerPacket = 1; /* imminent property of the Linear PCM */
+ AudioStreamBasicDescription audioFormat = { 0 };
+ audioFormat.mSampleRate = format->nSamplesPerSec;
+ audioFormat.mFormatID = kAudioFormatLinearPCM;
+ audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
+ audioFormat.mFramesPerPacket = 1; /* imminent property of the Linear PCM */
audioFormat.mChannelsPerFrame = format->nChannels;
- audioFormat.mBitsPerChannel = format->wBitsPerSample;
- audioFormat.mBytesPerFrame = (format->wBitsPerSample * format->nChannels) / 8;
- audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame * audioFormat.mFramesPerPacket;
- status = AudioUnitSetProperty(
- p->audio_unit,
- kAudioUnitProperty_StreamFormat,
- kAudioUnitScope_Input,
- 0,
- &audioFormat,
- sizeof(audioFormat));
+ audioFormat.mBitsPerChannel = format->wBitsPerSample;
+ audioFormat.mBytesPerFrame = (format->wBitsPerSample * format->nChannels) / 8;
+ audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame * audioFormat.mFramesPerPacket;
+ status = AudioUnitSetProperty(p->audio_unit, kAudioUnitProperty_StreamFormat,
+ kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat));
if (status != 0)
{
@@ -207,16 +198,12 @@ static BOOL rdpsnd_ios_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in
}
/* Set up the AudioUnit callback. */
- AURenderCallbackStruct callbackStruct = {0};
+ AURenderCallbackStruct callbackStruct = { 0 };
callbackStruct.inputProc = rdpsnd_ios_render_cb;
callbackStruct.inputProcRefCon = p;
- status = AudioUnitSetProperty(
- p->audio_unit,
- kAudioUnitProperty_SetRenderCallback,
- kAudioUnitScope_Input,
- 0,
- &callbackStruct,
- sizeof(callbackStruct));
+ status =
+ AudioUnitSetProperty(p->audio_unit, kAudioUnitProperty_SetRenderCallback,
+ kAudioUnitScope_Input, 0, &callbackStruct, sizeof(callbackStruct));
if (status != 0)
{
@@ -279,9 +266,9 @@ static void rdpsnd_ios_free(rdpsndDevicePlugin* device)
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry ios_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry ios_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -291,7 +278,7 @@ static void rdpsnd_ios_free(rdpsndDevicePlugin* device)
*/
UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
{
- rdpsndIOSPlugin* p = (rdpsndIOSPlugin*) calloc(1, sizeof(rdpsndIOSPlugin));
+ rdpsndIOSPlugin* p = (rdpsndIOSPlugin*)calloc(1, sizeof(rdpsndIOSPlugin));
if (!p)
return CHANNEL_RC_NO_MEMORY;
diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.m b/channels/rdpsnd/client/mac/rdpsnd_mac.m
index d31466427..78ac8003c 100644
--- a/channels/rdpsnd/client/mac/rdpsnd_mac.m
+++ b/channels/rdpsnd/client/mac/rdpsnd_mac.m
@@ -49,16 +49,16 @@ struct rdpsnd_mac_plugin
UINT32 latency;
AUDIO_FORMAT format;
- AVAudioEngine* engine;
- AVAudioPlayerNode* player;
+ AVAudioEngine *engine;
+ AVAudioPlayerNode *player;
UINT64 diff;
};
typedef struct rdpsnd_mac_plugin rdpsndMacPlugin;
-static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
+static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin *device, const AUDIO_FORMAT *format,
UINT32 latency)
{
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (!mac || !format)
return FALSE;
@@ -69,7 +69,7 @@ static BOOL rdpsnd_mac_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT
return TRUE;
}
-static char* FormatError(OSStatus st)
+static char *FormatError(OSStatus st)
{
switch (st)
{
@@ -126,7 +126,7 @@ static char* FormatError(OSStatus st)
}
}
-static void rdpsnd_mac_release(rdpsndMacPlugin* mac)
+static void rdpsnd_mac_release(rdpsndMacPlugin *mac)
{
if (mac->player)
[mac->player release];
@@ -137,10 +137,10 @@ static void rdpsnd_mac_release(rdpsndMacPlugin* mac)
mac->engine = NULL;
}
-static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format, UINT32 latency)
+static BOOL rdpsnd_mac_open(rdpsndDevicePlugin *device, const AUDIO_FORMAT *format, UINT32 latency)
{
- NSError* error;
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ NSError *error;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (mac->isOpen)
return TRUE;
@@ -160,11 +160,11 @@ static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* form
return FALSE;
}
- [mac->engine attachNode: mac->player];
+ [mac->engine attachNode:mac->player];
- [mac->engine connect: mac->player to: mac->engine.mainMixerNode format: nil];
+ [mac->engine connect:mac->player to:mac->engine.mainMixerNode format:nil];
- if (![mac->engine startAndReturnError: &error])
+ if (![mac->engine startAndReturnError:&error])
{
device->Close(device);
WLog_ERR(TAG, "Failed to start audio player %s", [error.localizedDescription UTF8String]);
@@ -175,14 +175,14 @@ static BOOL rdpsnd_mac_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* form
return TRUE;
}
-static void rdpsnd_mac_close(rdpsndDevicePlugin* device)
+static void rdpsnd_mac_close(rdpsndDevicePlugin *device)
{
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (mac->isPlaying)
{
- [mac->player stop];
- mac->isPlaying = FALSE;
+ [mac->player stop];
+ mac->isPlaying = FALSE;
}
if (mac->isOpen)
@@ -194,22 +194,22 @@ static void rdpsnd_mac_close(rdpsndDevicePlugin* device)
rdpsnd_mac_release(mac);
}
-static void rdpsnd_mac_free(rdpsndDevicePlugin* device)
+static void rdpsnd_mac_free(rdpsndDevicePlugin *device)
{
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
device->Close(device);
free(mac);
}
-static BOOL rdpsnd_mac_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format)
+static BOOL rdpsnd_mac_format_supported(rdpsndDevicePlugin *device, const AUDIO_FORMAT *format)
{
WINPR_UNUSED(device);
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->wBitsPerSample != 16)
- return FALSE;
+ if (format->wBitsPerSample != 16)
+ return FALSE;
return TRUE;
default:
@@ -217,28 +217,28 @@ static BOOL rdpsnd_mac_format_supported(rdpsndDevicePlugin* device, const AUDIO_
}
}
-static BOOL rdpsnd_mac_set_volume(rdpsndDevicePlugin* device, UINT32 value)
+static BOOL rdpsnd_mac_set_volume(rdpsndDevicePlugin *device, UINT32 value)
{
Float32 fVolume;
UINT16 volumeLeft;
UINT16 volumeRight;
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (!mac->player)
return FALSE;
volumeLeft = (value & 0xFFFF);
volumeRight = ((value >> 16) & 0xFFFF);
- fVolume = ((float) volumeLeft) / 65535.0f;
+ fVolume = ((float)volumeLeft) / 65535.0f;
mac->player.volume = fVolume;
return TRUE;
}
-static void rdpsnd_mac_start(rdpsndDevicePlugin* device)
+static void rdpsnd_mac_start(rdpsndDevicePlugin *device)
{
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (!mac->isPlaying)
{
@@ -249,12 +249,12 @@ static void rdpsnd_mac_start(rdpsndDevicePlugin* device)
}
}
-static UINT rdpsnd_mac_play(rdpsndDevicePlugin* device, const BYTE* data, size_t size)
+static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t size)
{
- rdpsndMacPlugin* mac = (rdpsndMacPlugin*) device;
- AVAudioPCMBuffer* buffer;
- AVAudioFormat* format;
- float * const * db;
+ rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
+ AVAudioPCMBuffer *buffer;
+ AVAudioFormat *format;
+ float *const *db;
size_t pos, step, x;
AVAudioFrameCount count;
UINT64 start = GetTickCount64();
@@ -265,13 +265,16 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin* device, const BYTE* data, size_t
step = 2 * mac->format.nChannels;
count = size / step;
- format = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:mac->format.nSamplesPerSec channels:mac->format.nChannels interleaved:NO];
+ format = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32
+ sampleRate:mac->format.nSamplesPerSec
+ channels:mac->format.nChannels
+ interleaved:NO];
if (!format)
{
WLog_WARN(TAG, "AVAudioFormat::init() failed");
return 0;
}
- buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity: count];
+ buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:count];
if (!buffer)
{
[format release];
@@ -282,10 +285,10 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin* device, const BYTE* data, size_t
buffer.frameLength = buffer.frameCapacity;
db = buffer.floatChannelData;
- for (pos=0; posformat.nChannels; x++)
+ const BYTE *d = &data[pos * step];
+ for (x = 0; x < mac->format.nChannels; x++)
{
const float val = (int16_t)((uint16_t)d[0] | ((uint16_t)d[1] << 8)) / 32768.0f;
db[x][pos] = val;
@@ -295,21 +298,22 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin* device, const BYTE* data, size_t
rdpsnd_mac_start(device);
- [mac->player scheduleBuffer: buffer completionHandler:^{
- UINT64 stop = GetTickCount64();
- if (start > stop)
- mac->diff = 0;
- else
- mac->diff = stop - start;
- }];
+ [mac->player scheduleBuffer:buffer
+ completionHandler:^{
+ UINT64 stop = GetTickCount64();
+ if (start > stop)
+ mac->diff = 0;
+ else
+ mac->diff = stop - start;
+ }];
return mac->diff > UINT_MAX ? UINT_MAX : mac->diff;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry mac_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry mac_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -319,8 +323,8 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin* device, const BYTE* data, size_t
*/
UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
{
- rdpsndMacPlugin* mac;
- mac = (rdpsndMacPlugin*) calloc(1, sizeof(rdpsndMacPlugin));
+ rdpsndMacPlugin *mac;
+ mac = (rdpsndMacPlugin *)calloc(1, sizeof(rdpsndMacPlugin));
if (!mac)
return CHANNEL_RC_NO_MEMORY;
@@ -331,6 +335,6 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
mac->device.Play = rdpsnd_mac_play;
mac->device.Close = rdpsnd_mac_close;
mac->device.Free = rdpsnd_mac_free;
- pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*) mac);
+ pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin *)mac);
return CHANNEL_RC_OK;
}
diff --git a/channels/rdpsnd/client/opensles/opensl_io.c b/channels/rdpsnd/client/opensles/opensl_io.c
index ffc24e12c..61afc108f 100644
--- a/channels/rdpsnd/client/opensles/opensl_io.c
+++ b/channels/rdpsnd/client/opensles/opensl_io.c
@@ -6,14 +6,14 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rdpsnd_main.h"
#include "opensl_io.h"
#define CONV16BIT 32768
-#define CONVMYFLT (1./32768.)
+#define CONVMYFLT (1. / 32768.)
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void* context);
@@ -42,22 +42,24 @@ static SLresult openSLCreateEngine(OPENSL_STREAM* p)
SLresult result;
// create engine
result = slCreateEngine(&(p->engineObject), 0, NULL, 0, NULL, NULL);
- DEBUG_SND("engineObject=%p", (void*) p->engineObject);
+ DEBUG_SND("engineObject=%p", (void*)p->engineObject);
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
// realize the engine
result = (*p->engineObject)->Realize(p->engineObject, SL_BOOLEAN_FALSE);
- DEBUG_SND("Realize=%"PRIu32"", result);
+ DEBUG_SND("Realize=%" PRIu32 "", result);
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
// get the engine interface, which is needed in order to create other objects
- result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE,
- &(p->engineEngine));
- DEBUG_SND("engineEngine=%p", (void*) p->engineEngine);
+ result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE, &(p->engineEngine));
+ DEBUG_SND("engineEngine=%p", (void*)p->engineEngine);
- if (result != SL_RESULT_SUCCESS) goto engine_end;
+ if (result != SL_RESULT_SUCCESS)
+ goto engine_end;
engine_end:
return result;
@@ -68,18 +70,15 @@ static SLresult openSLPlayOpen(OPENSL_STREAM* p)
{
SLresult result;
SLuint32 sr = p->sr;
- SLuint32 channels = p->outchannels;
+ SLuint32 channels = p->outchannels;
assert(p->engineObject);
assert(p->engineEngine);
if (channels)
{
// configure audio source
- SLDataLocator_AndroidSimpleBufferQueue loc_bufq =
- {
- SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
- p->queuesize
- };
+ SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
+ p->queuesize };
switch (sr)
{
@@ -135,90 +134,102 @@ static SLresult openSLPlayOpen(OPENSL_STREAM* p)
return -1;
}
- const SLInterfaceID ids[] = {SL_IID_VOLUME};
- const SLboolean req[] = {SL_BOOLEAN_FALSE};
- result = (*p->engineEngine)->CreateOutputMix(p->engineEngine,
- &(p->outputMixObject), 1, ids, req);
- DEBUG_SND("engineEngine=%p", (void*) p->engineEngine);
+ const SLInterfaceID ids[] = { SL_IID_VOLUME };
+ const SLboolean req[] = { SL_BOOLEAN_FALSE };
+ result = (*p->engineEngine)
+ ->CreateOutputMix(p->engineEngine, &(p->outputMixObject), 1, ids, req);
+ DEBUG_SND("engineEngine=%p", (void*)p->engineEngine);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// realize the output mix
result = (*p->outputMixObject)->Realize(p->outputMixObject, SL_BOOLEAN_FALSE);
- DEBUG_SND("Realize=%"PRIu32"", result);
+ DEBUG_SND("Realize=%" PRIu32 "", result);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
int speakers;
if (channels > 1)
speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- else speakers = SL_SPEAKER_FRONT_CENTER;
+ else
+ speakers = SL_SPEAKER_FRONT_CENTER;
- SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, channels, sr,
- SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
- speakers, SL_BYTEORDER_LITTLEENDIAN
- };
- SLDataSource audioSrc = {&loc_bufq, &format_pcm};
+ SLDataFormat_PCM format_pcm = { SL_DATAFORMAT_PCM,
+ channels,
+ sr,
+ SL_PCMSAMPLEFORMAT_FIXED_16,
+ SL_PCMSAMPLEFORMAT_FIXED_16,
+ speakers,
+ SL_BYTEORDER_LITTLEENDIAN };
+ SLDataSource audioSrc = { &loc_bufq, &format_pcm };
// configure audio sink
- SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, p->outputMixObject};
- SLDataSink audioSnk = {&loc_outmix, NULL};
+ SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX, p->outputMixObject };
+ SLDataSink audioSnk = { &loc_outmix, NULL };
// create audio player
- const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_VOLUME};
- const SLboolean req1[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
- result = (*p->engineEngine)->CreateAudioPlayer(p->engineEngine,
- &(p->bqPlayerObject), &audioSrc, &audioSnk, 2, ids1, req1);
- DEBUG_SND("bqPlayerObject=%p", (void*) p->bqPlayerObject);
+ const SLInterfaceID ids1[] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_VOLUME };
+ const SLboolean req1[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
+ result = (*p->engineEngine)
+ ->CreateAudioPlayer(p->engineEngine, &(p->bqPlayerObject), &audioSrc,
+ &audioSnk, 2, ids1, req1);
+ DEBUG_SND("bqPlayerObject=%p", (void*)p->bqPlayerObject);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// realize the player
result = (*p->bqPlayerObject)->Realize(p->bqPlayerObject, SL_BOOLEAN_FALSE);
- DEBUG_SND("Realize=%"PRIu32"", result);
+ DEBUG_SND("Realize=%" PRIu32 "", result);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// get the play interface
- result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_PLAY,
- &(p->bqPlayerPlay));
- DEBUG_SND("bqPlayerPlay=%p", (void*) p->bqPlayerPlay);
+ result =
+ (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_PLAY, &(p->bqPlayerPlay));
+ DEBUG_SND("bqPlayerPlay=%p", (void*)p->bqPlayerPlay);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// get the volume interface
- result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_VOLUME,
- &(p->bqPlayerVolume));
- DEBUG_SND("bqPlayerVolume=%p", (void*) p->bqPlayerVolume);
+ result = (*p->bqPlayerObject)
+ ->GetInterface(p->bqPlayerObject, SL_IID_VOLUME, &(p->bqPlayerVolume));
+ DEBUG_SND("bqPlayerVolume=%p", (void*)p->bqPlayerVolume);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// get the buffer queue interface
- result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject,
- SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &(p->bqPlayerBufferQueue));
- DEBUG_SND("bqPlayerBufferQueue=%p", (void*) p->bqPlayerBufferQueue);
+ result = (*p->bqPlayerObject)
+ ->GetInterface(p->bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
+ &(p->bqPlayerBufferQueue));
+ DEBUG_SND("bqPlayerBufferQueue=%p", (void*)p->bqPlayerBufferQueue);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// register callback on the buffer queue
- result = (*p->bqPlayerBufferQueue)->RegisterCallback(p->bqPlayerBufferQueue,
- bqPlayerCallback, p);
- DEBUG_SND("bqPlayerCallback=%p", (void*) p->bqPlayerCallback);
+ result = (*p->bqPlayerBufferQueue)
+ ->RegisterCallback(p->bqPlayerBufferQueue, bqPlayerCallback, p);
+ DEBUG_SND("bqPlayerCallback=%p", (void*)p->bqPlayerCallback);
assert(!result);
- if (result != SL_RESULT_SUCCESS) goto end_openaudio;
+ if (result != SL_RESULT_SUCCESS)
+ goto end_openaudio;
// set the player's state to playing
- result = (*p->bqPlayerPlay)->SetPlayState(p->bqPlayerPlay,
- SL_PLAYSTATE_PLAYING);
- DEBUG_SND("SetPlayState=%"PRIu32"", result);
+ result = (*p->bqPlayerPlay)->SetPlayState(p->bqPlayerPlay, SL_PLAYSTATE_PLAYING);
+ DEBUG_SND("SetPlayState=%" PRIu32 "", result);
assert(!result);
end_openaudio:
assert(!result);
@@ -258,13 +269,11 @@ static void openSLDestroyEngine(OPENSL_STREAM* p)
}
}
-
// open the android audio device for and/or output
-OPENSL_STREAM* android_OpenAudioDevice(int sr, int outchannels,
- int bufferframes)
+OPENSL_STREAM* android_OpenAudioDevice(int sr, int outchannels, int bufferframes)
{
OPENSL_STREAM* p;
- p = (OPENSL_STREAM*) calloc(1, sizeof(OPENSL_STREAM));
+ p = (OPENSL_STREAM*)calloc(1, sizeof(OPENSL_STREAM));
if (!p)
return NULL;
@@ -313,7 +322,7 @@ void android_CloseAudioDevice(OPENSL_STREAM* p)
// this callback handler is called every time a buffer finishes playing
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void* context)
{
- OPENSL_STREAM* p = (OPENSL_STREAM*) context;
+ OPENSL_STREAM* p = (OPENSL_STREAM*)context;
assert(p);
assert(p->queue);
void* data = Queue_Dequeue(p->queue);
@@ -328,8 +337,8 @@ int android_AudioOut(OPENSL_STREAM* p, const short* buffer, int size)
assert(size > 0);
/* Assure, that the queue is not full. */
- if (p->queuesize <= Queue_Count(p->queue)
- && WaitForSingleObject(p->queue->event, INFINITE) == WAIT_FAILED)
+ if (p->queuesize <= Queue_Count(p->queue) &&
+ WaitForSingleObject(p->queue->event, INFINITE) == WAIT_FAILED)
{
DEBUG_SND("WaitForSingleObject failed!");
return -1;
@@ -345,8 +354,7 @@ int android_AudioOut(OPENSL_STREAM* p, const short* buffer, int size)
memcpy(data, buffer, size * sizeof(short));
Queue_Enqueue(p->queue, data);
- (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue,
- data, sizeof(short) * size);
+ (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue, data, sizeof(short) * size);
return size;
}
@@ -394,8 +402,7 @@ int android_GetOutputVolumeMax(OPENSL_STREAM* p)
SLmillibel level;
assert(p);
assert(p->bqPlayerVolume);
- SLresult rc = (*p->bqPlayerVolume)->GetMaxVolumeLevel(p->bqPlayerVolume,
- &level);
+ SLresult rc = (*p->bqPlayerVolume)->GetMaxVolumeLevel(p->bqPlayerVolume, &level);
if (SL_RESULT_SUCCESS != rc)
return 0;
@@ -403,7 +410,6 @@ int android_GetOutputVolumeMax(OPENSL_STREAM* p)
return level;
}
-
BOOL android_SetOutputVolume(OPENSL_STREAM* p, int level)
{
SLresult rc = (*p->bqPlayerVolume)->SetVolumeLevel(p->bqPlayerVolume, level);
@@ -413,4 +419,3 @@ BOOL android_SetOutputVolume(OPENSL_STREAM* p, int level)
return TRUE;
}
-
diff --git a/channels/rdpsnd/client/opensles/opensl_io.h b/channels/rdpsnd/client/opensles/opensl_io.h
index 0bb121a53..57dc04841 100644
--- a/channels/rdpsnd/client/opensles/opensl_io.h
+++ b/channels/rdpsnd/client/opensles/opensl_io.h
@@ -6,14 +6,14 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -38,72 +38,71 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-typedef struct opensl_stream
-{
- // engine interfaces
- SLObjectItf engineObject;
- SLEngineItf engineEngine;
+ typedef struct opensl_stream
+ {
+ // engine interfaces
+ SLObjectItf engineObject;
+ SLEngineItf engineEngine;
- // output mix interfaces
- SLObjectItf outputMixObject;
+ // output mix interfaces
+ SLObjectItf outputMixObject;
- // buffer queue player interfaces
- SLObjectItf bqPlayerObject;
- SLPlayItf bqPlayerPlay;
- SLVolumeItf bqPlayerVolume;
- SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
- SLEffectSendItf bqPlayerEffectSend;
+ // buffer queue player interfaces
+ SLObjectItf bqPlayerObject;
+ SLPlayItf bqPlayerPlay;
+ SLVolumeItf bqPlayerVolume;
+ SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
+ SLEffectSendItf bqPlayerEffectSend;
- unsigned int outchannels;
- unsigned int sr;
+ unsigned int outchannels;
+ unsigned int sr;
- unsigned int queuesize;
- wQueue* queue;
-} OPENSL_STREAM;
+ unsigned int queuesize;
+ wQueue* queue;
+ } OPENSL_STREAM;
-/*
-Open the audio device with a given sampling rate (sr), output channels and IO buffer size
-in frames. Returns a handle to the OpenSL stream
-*/
-FREERDP_LOCAL OPENSL_STREAM* android_OpenAudioDevice(int sr, int outchannels,
- int bufferframes);
-/*
-Close the audio device
-*/
-FREERDP_LOCAL void android_CloseAudioDevice(OPENSL_STREAM* p);
-/*
-Write a buffer to the OpenSL stream *p, of size samples. Returns the number of samples written.
-*/
-FREERDP_LOCAL int android_AudioOut(OPENSL_STREAM* p, const short* buffer,
- int size);
-/*
- * Set the volume input level.
- */
-FREERDP_LOCAL void android_SetInputVolume(OPENSL_STREAM* p, int level);
-/*
- * Get the current output mute setting.
- */
-FREERDP_LOCAL int android_GetOutputMute(OPENSL_STREAM* p);
-/*
- * Change the current output mute setting.
- */
-FREERDP_LOCAL BOOL android_SetOutputMute(OPENSL_STREAM* p, BOOL mute);
-/*
- * Get the current output volume level.
- */
-FREERDP_LOCAL int android_GetOutputVolume(OPENSL_STREAM* p);
-/*
- * Get the maximum output volume level.
- */
-FREERDP_LOCAL int android_GetOutputVolumeMax(OPENSL_STREAM* p);
+ /*
+ Open the audio device with a given sampling rate (sr), output channels and IO buffer size
+ in frames. Returns a handle to the OpenSL stream
+ */
+ FREERDP_LOCAL OPENSL_STREAM* android_OpenAudioDevice(int sr, int outchannels, int bufferframes);
+ /*
+ Close the audio device
+ */
+ FREERDP_LOCAL void android_CloseAudioDevice(OPENSL_STREAM* p);
+ /*
+ Write a buffer to the OpenSL stream *p, of size samples. Returns the number of samples written.
+ */
+ FREERDP_LOCAL int android_AudioOut(OPENSL_STREAM* p, const short* buffer, int size);
+ /*
+ * Set the volume input level.
+ */
+ FREERDP_LOCAL void android_SetInputVolume(OPENSL_STREAM* p, int level);
+ /*
+ * Get the current output mute setting.
+ */
+ FREERDP_LOCAL int android_GetOutputMute(OPENSL_STREAM* p);
+ /*
+ * Change the current output mute setting.
+ */
+ FREERDP_LOCAL BOOL android_SetOutputMute(OPENSL_STREAM* p, BOOL mute);
+ /*
+ * Get the current output volume level.
+ */
+ FREERDP_LOCAL int android_GetOutputVolume(OPENSL_STREAM* p);
+ /*
+ * Get the maximum output volume level.
+ */
+ FREERDP_LOCAL int android_GetOutputVolumeMax(OPENSL_STREAM* p);
-/*
- * Set the volume output level.
- */
-FREERDP_LOCAL BOOL android_SetOutputVolume(OPENSL_STREAM* p, int level);
+ /*
+ * Set the volume output level.
+ */
+ FREERDP_LOCAL BOOL android_SetOutputVolume(OPENSL_STREAM* p, int level);
#ifdef __cplusplus
};
#endif
diff --git a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c
index e00c0e76a..3481d9130 100644
--- a/channels/rdpsnd/client/opensles/rdpsnd_opensles.c
+++ b/channels/rdpsnd/client/opensles/rdpsnd_opensles.c
@@ -66,8 +66,7 @@ static int rdpsnd_opensles_volume_to_millibel(unsigned short level, int max)
const int min = SL_MILLIBEL_MIN;
const int step = max - min;
const int rc = (level * step / 0xFFFF) + min;
- DEBUG_SND("level=%hu, min=%d, max=%d, step=%d, result=%d",
- level, min, max, step, rc);
+ DEBUG_SND("level=%hu, min=%d, max=%d, step=%d, result=%d", level, min, max, step, rc);
return rc;
}
@@ -76,8 +75,7 @@ static unsigned short rdpsnd_opensles_millibel_to_volume(int millibel, int max)
const int min = SL_MILLIBEL_MIN;
const int range = max - min;
const int rc = ((millibel - min) * 0xFFFF + range / 2 + 1) / range;
- DEBUG_SND("millibel=%d, min=%d, max=%d, range=%d, result=%d",
- millibel, min, max, range, rc);
+ DEBUG_SND("millibel=%d, min=%d, max=%d, range=%d, result=%d", millibel, min, max, range, rc);
return rc;
}
@@ -96,12 +94,11 @@ static bool rdpsnd_opensles_check_handle(const rdpsndopenslesPlugin* hdl)
return rc;
}
-static BOOL rdpsnd_opensles_set_volume(rdpsndDevicePlugin* device,
- UINT32 volume);
+static BOOL rdpsnd_opensles_set_volume(rdpsndDevicePlugin* device, UINT32 volume);
static int rdpsnd_opensles_set_params(rdpsndopenslesPlugin* opensles)
{
- DEBUG_SND("opensles=%p", (void*) opensles);
+ DEBUG_SND("opensles=%p", (void*)opensles);
if (!rdpsnd_opensles_check_handle(opensles))
return 0;
@@ -109,23 +106,23 @@ static int rdpsnd_opensles_set_params(rdpsndopenslesPlugin* opensles)
if (opensles->stream)
android_CloseAudioDevice(opensles->stream);
- opensles->stream = android_OpenAudioDevice(
- opensles->rate, opensles->channels, 20);
+ opensles->stream = android_OpenAudioDevice(opensles->rate, opensles->channels, 20);
return 0;
}
-static BOOL rdpsnd_opensles_set_format(rdpsndDevicePlugin* device,
- const AUDIO_FORMAT* format, UINT32 latency)
+static BOOL rdpsnd_opensles_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
+ UINT32 latency)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
rdpsnd_opensles_check_handle(opensles);
- DEBUG_SND("opensles=%p format=%p, latency=%"PRIu32, (void*) opensles, (void*) format, latency);
+ DEBUG_SND("opensles=%p format=%p, latency=%" PRIu32, (void*)opensles, (void*)format, latency);
if (format)
{
- DEBUG_SND("format=%"PRIu16", cbsize=%"PRIu16", samples=%"PRIu32", bits=%"PRIu16", channels=%"PRIu16", align=%"PRIu16"",
+ DEBUG_SND("format=%" PRIu16 ", cbsize=%" PRIu16 ", samples=%" PRIu32 ", bits=%" PRIu16
+ ", channels=%" PRIu16 ", align=%" PRIu16 "",
format->wFormatTag, format->cbSize, format->nSamplesPerSec,
- format->wBitsPerSample, format->nChannels, format->nBlockAlign);
+ format->wBitsPerSample, format->nChannels, format->nBlockAlign);
opensles->rate = format->nSamplesPerSec;
opensles->channels = format->nChannels;
opensles->format = format->wFormatTag;
@@ -137,18 +134,17 @@ static BOOL rdpsnd_opensles_set_format(rdpsndDevicePlugin* device,
return (rdpsnd_opensles_set_params(opensles) == 0);
}
-static BOOL rdpsnd_opensles_open(rdpsndDevicePlugin* device,
- const AUDIO_FORMAT* format, UINT32 latency)
+static BOOL rdpsnd_opensles_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
+ UINT32 latency)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p format=%p, latency=%"PRIu32", rate=%"PRIu32"",
- (void*) opensles, (void*) format, latency, opensles->rate);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p format=%p, latency=%" PRIu32 ", rate=%" PRIu32 "", (void*)opensles,
+ (void*)format, latency, opensles->rate);
if (rdpsnd_opensles_check_handle(opensles))
return TRUE;
- opensles->stream = android_OpenAudioDevice(opensles->rate, opensles->channels,
- 20);
+ opensles->stream = android_OpenAudioDevice(opensles->rate, opensles->channels, 20);
assert(opensles->stream);
if (!opensles->stream)
@@ -161,8 +157,8 @@ static BOOL rdpsnd_opensles_open(rdpsndDevicePlugin* device,
static void rdpsnd_opensles_close(rdpsndDevicePlugin* device)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p", (void*) opensles);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p", (void*)opensles);
if (!rdpsnd_opensles_check_handle(opensles))
return;
@@ -173,28 +169,27 @@ static void rdpsnd_opensles_close(rdpsndDevicePlugin* device)
static void rdpsnd_opensles_free(rdpsndDevicePlugin* device)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p", (void*) opensles);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p", (void*)opensles);
assert(opensles);
assert(opensles->device_name);
free(opensles->device_name);
free(opensles);
}
-static BOOL rdpsnd_opensles_format_supported(rdpsndDevicePlugin* device,
- const AUDIO_FORMAT* format)
+static BOOL rdpsnd_opensles_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format)
{
- DEBUG_SND("format=%"PRIu16", cbsize=%"PRIu16", samples=%"PRIu32", bits=%"PRIu16", channels=%"PRIu16", align=%"PRIu16"",
- format->wFormatTag, format->cbSize, format->nSamplesPerSec,
- format->wBitsPerSample, format->nChannels, format->nBlockAlign);
+ DEBUG_SND("format=%" PRIu16 ", cbsize=%" PRIu16 ", samples=%" PRIu32 ", bits=%" PRIu16
+ ", channels=%" PRIu16 ", align=%" PRIu16 "",
+ format->wFormatTag, format->cbSize, format->nSamplesPerSec, format->wBitsPerSample,
+ format->nChannels, format->nBlockAlign);
assert(device);
assert(format);
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize == 0 &&
- format->nSamplesPerSec <= 48000 &&
+ if (format->cbSize == 0 && format->nSamplesPerSec <= 48000 &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels == 1 || format->nChannels == 2))
{
@@ -212,8 +207,8 @@ static BOOL rdpsnd_opensles_format_supported(rdpsndDevicePlugin* device,
static UINT32 rdpsnd_opensles_get_volume(rdpsndDevicePlugin* device)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p", (void*) opensles);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p", (void*)opensles);
assert(opensles);
if (opensles->stream)
@@ -233,11 +228,10 @@ static UINT32 rdpsnd_opensles_get_volume(rdpsndDevicePlugin* device)
return opensles->volume;
}
-static BOOL rdpsnd_opensles_set_volume(rdpsndDevicePlugin* device,
- UINT32 value)
+static BOOL rdpsnd_opensles_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p, value=%"PRIu32"", (void*) opensles, value);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p, value=%" PRIu32 "", (void*)opensles, value);
assert(opensles);
opensles->volume = value;
@@ -261,23 +255,21 @@ static BOOL rdpsnd_opensles_set_volume(rdpsndDevicePlugin* device,
return TRUE;
}
-static UINT rdpsnd_opensles_play(rdpsndDevicePlugin* device,
- const BYTE* data, size_t size)
+static UINT rdpsnd_opensles_play(rdpsndDevicePlugin* device, const BYTE* data, size_t size)
{
- union
- {
+ union {
const BYTE* b;
const short* s;
} src;
int ret;
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- DEBUG_SND("opensles=%p, data=%p, size=%d", (void*) opensles, (void*) data, size);
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ DEBUG_SND("opensles=%p, data=%p, size=%d", (void*)opensles, (void*)data, size);
if (!rdpsnd_opensles_check_handle(opensles))
return 0;
src.b = data;
- DEBUG_SND("size=%d, src=%p", size, (void*) src.b);
+ DEBUG_SND("size=%d, src=%p", size, (void*)src.b);
assert(0 == size % 2);
assert(size > 0);
assert(src.b);
@@ -291,34 +283,29 @@ static UINT rdpsnd_opensles_play(rdpsndDevicePlugin* device,
static void rdpsnd_opensles_start(rdpsndDevicePlugin* device)
{
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
rdpsnd_opensles_check_handle(opensles);
- DEBUG_SND("opensles=%p", (void*) opensles);
+ DEBUG_SND("opensles=%p", (void*)opensles);
}
-static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device,
- ADDIN_ARGV* args)
+static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV* args)
{
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*) device;
- COMMAND_LINE_ARGUMENT_A rdpsnd_opensles_args[] =
- {
- {
- "dev", COMMAND_LINE_VALUE_REQUIRED, "",
- NULL, NULL, -1, NULL, "device"
- },
+ rdpsndopenslesPlugin* opensles = (rdpsndopenslesPlugin*)device;
+ COMMAND_LINE_ARGUMENT_A rdpsnd_opensles_args[] = {
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
};
assert(opensles);
assert(args);
- DEBUG_SND("opensles=%p, args=%p", (void*) opensles, (void*) args);
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON |
- COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- rdpsnd_opensles_args, flags, opensles, NULL, NULL);
+ DEBUG_SND("opensles=%p, args=%p", (void*)opensles, (void*)args);
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_opensles_args, flags,
+ opensles, NULL, NULL);
if (status < 0)
return status;
@@ -330,8 +317,7 @@ static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device,
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
opensles->device_name = _strdup(arg->Value);
@@ -339,18 +325,15 @@ static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device,
return ERROR_OUTOFMEMORY;
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return status;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry \
- opensles_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry opensles_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry \
- FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -358,14 +341,13 @@ static int rdpsnd_opensles_parse_addin_args(rdpsndDevicePlugin* device,
*
* @return 0 on success, otherwise a Win32 error code
*/
-UINT freerdp_rdpsnd_client_subsystem_entry(
- PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
+UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
{
ADDIN_ARGV* args;
rdpsndopenslesPlugin* opensles;
UINT error;
- DEBUG_SND("pEntryPoints=%p", (void*) pEntryPoints);
- opensles = (rdpsndopenslesPlugin*) calloc(1, sizeof(rdpsndopenslesPlugin));
+ DEBUG_SND("pEntryPoints=%p", (void*)pEntryPoints);
+ opensles = (rdpsndopenslesPlugin*)calloc(1, sizeof(rdpsndopenslesPlugin));
if (!opensles)
return CHANNEL_RC_NO_MEMORY;
@@ -379,7 +361,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(
opensles->device.Close = rdpsnd_opensles_close;
opensles->device.Free = rdpsnd_opensles_free;
args = pEntryPoints->args;
- rdpsnd_opensles_parse_addin_args((rdpsndDevicePlugin*) opensles, args);
+ rdpsnd_opensles_parse_addin_args((rdpsndDevicePlugin*)opensles, args);
if (!opensles->device_name)
{
@@ -395,8 +377,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(
opensles->rate = 44100;
opensles->channels = 2;
opensles->format = WAVE_FORMAT_ADPCM;
- pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd,
- (rdpsndDevicePlugin*) opensles);
+ pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)opensles);
DEBUG_SND("success");
return CHANNEL_RC_OK;
outstrdup:
diff --git a/channels/rdpsnd/client/oss/rdpsnd_oss.c b/channels/rdpsnd/client/oss/rdpsnd_oss.c
index 19b0a07c5..7a7937dad 100644
--- a/channels/rdpsnd/client/oss/rdpsnd_oss.c
+++ b/channels/rdpsnd/client/oss/rdpsnd_oss.c
@@ -67,13 +67,12 @@ struct rdpsnd_oss_plugin
AUDIO_FORMAT format;
};
-#define OSS_LOG_ERR(_text, _error) \
- { \
- if (_error != 0) \
+#define OSS_LOG_ERR(_text, _error) \
+ { \
+ if (_error != 0) \
WLog_ERR(TAG, "%s: %i - %s", _text, _error, strerror(_error)); \
}
-
static int rdpsnd_oss_get_format(const AUDIO_FORMAT* format)
{
switch (format->wFormatTag)
@@ -111,8 +110,7 @@ static BOOL rdpsnd_oss_format_supported(rdpsndDevicePlugin* device, const AUDIO_
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize != 0 ||
- format->nSamplesPerSec > 48000 ||
+ if (format->cbSize != 0 || format->nSamplesPerSec > 48000 ||
(format->wBitsPerSample != 8 && format->wBitsPerSample != 16) ||
(format->nChannels != 1 && format->nChannels != 2))
return FALSE;
@@ -307,7 +305,7 @@ static UINT32 rdpsnd_oss_get_volume(rdpsndDevicePlugin* device)
UINT16 dwVolumeLeft, dwVolumeRight;
rdpsndOssPlugin* oss = (rdpsndOssPlugin*)device;
/* On error return 50% volume. */
- dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
+ dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
dwVolume = ((dwVolumeLeft << 16) | dwVolumeRight);
@@ -391,18 +389,17 @@ static UINT rdpsnd_oss_play(rdpsndDevicePlugin* device, const BYTE* data, size_t
static int rdpsnd_oss_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV* args)
{
int status;
- char* str_num, *eptr;
+ char *str_num, *eptr;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
rdpsndOssPlugin* oss = (rdpsndOssPlugin*)device;
- COMMAND_LINE_ARGUMENT_A rdpsnd_oss_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_oss_args, flags,
- oss, NULL, NULL);
+ COMMAND_LINE_ARGUMENT_A rdpsnd_oss_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "device" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status =
+ CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_oss_args, flags, oss, NULL, NULL);
if (status < 0)
return status;
@@ -415,8 +412,7 @@ static int rdpsnd_oss_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV* a
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
str_num = _strdup(arg->Value);
@@ -441,16 +437,15 @@ static int rdpsnd_oss_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV* a
free(str_num);
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return status;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry oss_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry oss_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
diff --git a/channels/rdpsnd/client/proxy/rdpsnd_proxy.c b/channels/rdpsnd/client/proxy/rdpsnd_proxy.c
index 16c4edffd..9de71c96e 100644
--- a/channels/rdpsnd/client/proxy/rdpsnd_proxy.c
+++ b/channels/rdpsnd/client/proxy/rdpsnd_proxy.c
@@ -44,7 +44,8 @@ struct rdpsnd_proxy_plugin
RdpsndServerContext* rdpsnd_server;
};
-static BOOL rdpsnd_proxy_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format, UINT32 latency)
+static BOOL rdpsnd_proxy_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
+ UINT32 latency)
{
rdpsndProxyPlugin* proxy = (rdpsndProxyPlugin*)device;
@@ -67,7 +68,7 @@ static BOOL rdpsnd_proxy_set_volume(rdpsndDevicePlugin* device, UINT32 value)
static void rdpsnd_proxy_free(rdpsndDevicePlugin* device)
{
- rdpsndProxyPlugin* proxy = (rdpsndProxyPlugin*) device;
+ rdpsndProxyPlugin* proxy = (rdpsndProxyPlugin*)device;
if (!proxy)
return;
@@ -105,11 +106,10 @@ static void rdpsnd_proxy_start(rdpsndDevicePlugin* device)
* @return 0 on success, otherwise a Win32 error code
*/
-
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry proxy_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry proxy_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -122,7 +122,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
ADDIN_ARGV* args;
rdpsndProxyPlugin* proxy;
pClientContext* pc;
- proxy = (rdpsndProxyPlugin*) calloc(1, sizeof(rdpsndProxyPlugin));
+ proxy = (rdpsndProxyPlugin*)calloc(1, sizeof(rdpsndProxyPlugin));
if (!proxy)
return CHANNEL_RC_NO_MEMORY;
@@ -137,7 +137,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
args = pEntryPoints->args;
pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, &proxy->device);
- pc = (pClientContext*) freerdp_rdpsnd_get_context(pEntryPoints->rdpsnd);
+ pc = (pClientContext*)freerdp_rdpsnd_get_context(pEntryPoints->rdpsnd);
if (pc == NULL)
{
free(proxy);
diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c
index b3e88c037..0ea359fdf 100644
--- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c
+++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c
@@ -59,9 +59,11 @@ static void rdpsnd_pulse_get_sink_info(pa_context* c, const pa_sink_info* i, int
void* userdata)
{
uint8_t x;
- UINT16 dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */;
- UINT16 dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) userdata;
+ UINT16 dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */
+ ;
+ UINT16 dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */
+ ;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata;
if (!pulse || !c || !i)
return;
@@ -94,7 +96,7 @@ static void rdpsnd_pulse_get_sink_info(pa_context* c, const pa_sink_info* i, int
static void rdpsnd_pulse_context_state_callback(pa_context* context, void* userdata)
{
pa_context_state_t state;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) userdata;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata;
state = pa_context_get_state(context);
switch (state)
@@ -117,7 +119,7 @@ static BOOL rdpsnd_pulse_connect(rdpsndDevicePlugin* device)
{
pa_operation* o;
pa_context_state_t state;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->context)
return FALSE;
@@ -170,7 +172,7 @@ static BOOL rdpsnd_pulse_connect(rdpsndDevicePlugin* device)
static void rdpsnd_pulse_stream_success_callback(pa_stream* stream, int success, void* userdata)
{
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) userdata;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata;
pa_threaded_mainloop_signal(pulse->mainloop, 0);
}
@@ -190,7 +192,7 @@ static void rdpsnd_pulse_wait_for_operation(rdpsndPulsePlugin* pulse, pa_operati
static void rdpsnd_pulse_stream_state_callback(pa_stream* stream, void* userdata)
{
pa_stream_state_t state;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) userdata;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata;
state = pa_stream_get_state(stream);
switch (state)
@@ -211,20 +213,20 @@ static void rdpsnd_pulse_stream_state_callback(pa_stream* stream, void* userdata
static void rdpsnd_pulse_stream_request_callback(pa_stream* stream, size_t length, void* userdata)
{
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) userdata;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata;
pa_threaded_mainloop_signal(pulse->mainloop, 0);
}
static void rdpsnd_pulse_close(rdpsndDevicePlugin* device)
{
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->context || !pulse->stream)
return;
pa_threaded_mainloop_lock(pulse->mainloop);
- rdpsnd_pulse_wait_for_operation(pulse, pa_stream_drain(pulse->stream,
- rdpsnd_pulse_stream_success_callback, pulse));
+ rdpsnd_pulse_wait_for_operation(
+ pulse, pa_stream_drain(pulse->stream, rdpsnd_pulse_stream_success_callback, pulse));
pa_stream_disconnect(pulse->stream);
pa_stream_unref(pulse->stream);
pulse->stream = NULL;
@@ -286,7 +288,7 @@ static BOOL rdpsnd_pulse_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
pa_stream_flags_t flags;
pa_buffer_attr buffer_attr = { 0 };
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->context || pulse->stream)
return TRUE;
@@ -320,14 +322,14 @@ static BOOL rdpsnd_pulse_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
{
buffer_attr.maxlength = pa_usec_to_bytes(pulse->latency * 2 * 1000, &pulse->sample_spec);
buffer_attr.tlength = pa_usec_to_bytes(pulse->latency * 1000, &pulse->sample_spec);
- buffer_attr.prebuf = (UINT32) - 1;
- buffer_attr.minreq = (UINT32) - 1;
- buffer_attr.fragsize = (UINT32) - 1;
+ buffer_attr.prebuf = (UINT32)-1;
+ buffer_attr.minreq = (UINT32)-1;
+ buffer_attr.fragsize = (UINT32)-1;
flags |= PA_STREAM_ADJUST_LATENCY;
}
- if (pa_stream_connect_playback(pulse->stream,
- pulse->device_name, pulse->latency > 0 ? &buffer_attr : NULL, flags, NULL, NULL) < 0)
+ if (pa_stream_connect_playback(pulse->stream, pulse->device_name,
+ pulse->latency > 0 ? &buffer_attr : NULL, flags, NULL, NULL) < 0)
{
pa_threaded_mainloop_unlock(pulse->mainloop);
return TRUE;
@@ -359,7 +361,7 @@ static BOOL rdpsnd_pulse_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
static void rdpsnd_pulse_free(rdpsndDevicePlugin* device)
{
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse)
return;
@@ -393,8 +395,7 @@ BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMA
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= PA_RATE_MAX) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8 || format->wBitsPerSample == 16) &&
(format->nChannels >= 1 && format->nChannels <= PA_CHANNELS_MAX))
{
@@ -405,8 +406,7 @@ BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMA
case WAVE_FORMAT_ALAW:
case WAVE_FORMAT_MULAW:
- if (format->cbSize == 0 &&
- (format->nSamplesPerSec <= PA_RATE_MAX) &&
+ if (format->cbSize == 0 && (format->nSamplesPerSec <= PA_RATE_MAX) &&
(format->wBitsPerSample == 8) &&
(format->nChannels >= 1 && format->nChannels <= PA_CHANNELS_MAX))
{
@@ -422,7 +422,7 @@ BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, const AUDIO_FORMA
static UINT32 rdpsnd_pulse_get_volume(rdpsndDevicePlugin* device)
{
pa_operation* o;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse)
return 0;
@@ -443,7 +443,7 @@ static BOOL rdpsnd_pulse_set_volume(rdpsndDevicePlugin* device, UINT32 value)
pa_volume_t left;
pa_volume_t right;
pa_operation* operation;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->context || !pulse->stream)
return FALSE;
@@ -456,7 +456,7 @@ static BOOL rdpsnd_pulse_set_volume(rdpsndDevicePlugin* device, UINT32 value)
cv.values[1] = PA_VOLUME_MUTED + (right * (PA_VOLUME_NORM - PA_VOLUME_MUTED)) / 0xFFFF;
pa_threaded_mainloop_lock(pulse->mainloop);
operation = pa_context_set_sink_input_volume(pulse->context, pa_stream_get_index(pulse->stream),
- &cv, NULL, NULL);
+ &cv, NULL, NULL);
if (operation)
pa_operation_unref(operation);
@@ -471,7 +471,7 @@ static UINT rdpsnd_pulse_play(rdpsndDevicePlugin* device, const BYTE* data, size
int status;
pa_usec_t latency;
int negative;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->stream || !data)
return 0;
@@ -483,7 +483,7 @@ static UINT rdpsnd_pulse_play(rdpsndDevicePlugin* device, const BYTE* data, size
while ((length = pa_stream_writable_size(pulse->stream)) == 0)
pa_threaded_mainloop_wait(pulse->mainloop);
- if (length == (size_t) -1)
+ if (length == (size_t)-1)
break;
if (length > size)
@@ -509,7 +509,7 @@ static UINT rdpsnd_pulse_play(rdpsndDevicePlugin* device, const BYTE* data, size
static void rdpsnd_pulse_start(rdpsndDevicePlugin* device)
{
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
if (!pulse->stream)
return;
@@ -529,15 +529,14 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*) device;
- COMMAND_LINE_ARGUMENT_A rdpsnd_pulse_args[] =
- {
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
- flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- rdpsnd_pulse_args, flags, pulse, NULL, NULL);
+ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
+ COMMAND_LINE_ARGUMENT_A rdpsnd_pulse_args[] = { { "dev", COMMAND_LINE_VALUE_REQUIRED,
+ "", NULL, NULL, -1, NULL, "device" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
+ flags =
+ COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
+ status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_pulse_args, flags, pulse,
+ NULL, NULL);
if (status < 0)
return ERROR_INVALID_DATA;
@@ -549,8 +548,7 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dev")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dev")
{
pulse->device_name = _strdup(arg->Value);
@@ -558,16 +556,15 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV
return ERROR_OUTOFMEMORY;
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry pulse_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry pulse_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -580,7 +577,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
ADDIN_ARGV* args;
rdpsndPulsePlugin* pulse;
UINT ret;
- pulse = (rdpsndPulsePlugin*) calloc(1, sizeof(rdpsndPulsePlugin));
+ pulse = (rdpsndPulsePlugin*)calloc(1, sizeof(rdpsndPulsePlugin));
if (!pulse)
return CHANNEL_RC_NO_MEMORY;
@@ -597,7 +594,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
if (args->argc > 1)
{
- ret = rdpsnd_pulse_parse_addin_args((rdpsndDevicePlugin*) pulse, args);
+ ret = rdpsnd_pulse_parse_addin_args((rdpsndDevicePlugin*)pulse, args);
if (ret != CHANNEL_RC_OK)
{
@@ -623,7 +620,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
if (!rdpsnd_pulse_connect((rdpsndDevicePlugin*)pulse))
goto error;
- pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*) pulse);
+ pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)pulse);
return CHANNEL_RC_OK;
error:
rdpsnd_pulse_free((rdpsndDevicePlugin*)pulse);
diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c
index 5be8263ce..68ff694f5 100644
--- a/channels/rdpsnd/client/rdpsnd_main.c
+++ b/channels/rdpsnd/client/rdpsnd_main.c
@@ -124,12 +124,12 @@ static UINT rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */
- Stream_Write_UINT8(pdu, 0); /* bPad */
- Stream_Write_UINT16(pdu, 4); /* BodySize */
+ Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */
+ Stream_Write_UINT8(pdu, 0); /* bPad */
+ Stream_Write_UINT16(pdu, 4); /* BodySize */
Stream_Write_UINT16(pdu, rdpsnd->wQualityMode); /* wQualityMode */
- Stream_Write_UINT16(pdu, 0); /* Reserved */
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "QualityMode: %"PRIu16"", rdpsnd->wQualityMode);
+ Stream_Write_UINT16(pdu, 0); /* Reserved */
+ WLog_Print(rdpsnd->log, WLOG_DEBUG, "QualityMode: %" PRIu16 "", rdpsnd->wQualityMode);
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
}
@@ -191,17 +191,17 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */
- Stream_Write_UINT8(pdu, 0); /* bPad */
- Stream_Write_UINT16(pdu, length - 4); /* BodySize */
+ Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */
+ Stream_Write_UINT8(pdu, 0); /* bPad */
+ Stream_Write_UINT16(pdu, length - 4); /* BodySize */
Stream_Write_UINT32(pdu, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */
- Stream_Write_UINT32(pdu, dwVolume); /* dwVolume */
- Stream_Write_UINT32(pdu, 0); /* dwPitch */
- Stream_Write_UINT16(pdu, 0); /* wDGramPort */
- Stream_Write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */
- Stream_Write_UINT8(pdu, 0); /* cLastBlockConfirmed */
- Stream_Write_UINT16(pdu, CHANNEL_VERSION_WIN_MAX); /* wVersion */
- Stream_Write_UINT8(pdu, 0); /* bPad */
+ Stream_Write_UINT32(pdu, dwVolume); /* dwVolume */
+ Stream_Write_UINT32(pdu, 0); /* dwPitch */
+ Stream_Write_UINT16(pdu, 0); /* wDGramPort */
+ Stream_Write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */
+ Stream_Write_UINT8(pdu, 0); /* cLastBlockConfirmed */
+ Stream_Write_UINT16(pdu, CHANNEL_VERSION_WIN_MAX); /* wVersion */
+ Stream_Write_UINT8(pdu, 0); /* bPad */
for (index = 0; index < wNumberOfFormats; index++)
{
@@ -223,8 +223,7 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd,
- wStream* s)
+static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s)
{
UINT16 index;
UINT16 wVersion;
@@ -244,8 +243,8 @@ static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd,
Stream_Seek_UINT16(s); /* wDGramPort */
Stream_Read_UINT16(s, wNumberOfFormats);
Stream_Read_UINT8(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
- Stream_Read_UINT16(s, wVersion); /* wVersion */
- Stream_Seek_UINT8(s); /* bPad */
+ Stream_Read_UINT16(s, wVersion); /* wVersion */
+ Stream_Seek_UINT8(s); /* bPad */
rdpsnd->NumberOfServerFormats = wNumberOfFormats;
if (Stream_GetRemainingLength(s) / 14 < wNumberOfFormats)
@@ -287,8 +286,8 @@ out_fail:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd,
- UINT16 wTimeStamp, UINT16 wPackSize)
+static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp,
+ UINT16 wPackSize)
{
wStream* pdu;
pdu = Stream_New(NULL, 8);
@@ -300,13 +299,13 @@ static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd,
}
Stream_Write_UINT8(pdu, SNDC_TRAINING); /* msgType */
- Stream_Write_UINT8(pdu, 0); /* bPad */
- Stream_Write_UINT16(pdu, 4); /* BodySize */
+ Stream_Write_UINT8(pdu, 0); /* bPad */
+ Stream_Write_UINT16(pdu, 4); /* BodySize */
Stream_Write_UINT16(pdu, wTimeStamp);
Stream_Write_UINT16(pdu, wPackSize);
WLog_Print(rdpsnd->log, WLOG_DEBUG,
- "Training Response: wTimeStamp: %"PRIu16" wPackSize: %"PRIu16"",
- wTimeStamp, wPackSize);
+ "Training Response: wTimeStamp: %" PRIu16 " wPackSize: %" PRIu16 "", wTimeStamp,
+ wPackSize);
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
}
@@ -326,13 +325,13 @@ static UINT rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, wStream* s)
Stream_Read_UINT16(s, wTimeStamp);
Stream_Read_UINT16(s, wPackSize);
WLog_Print(rdpsnd->log, WLOG_DEBUG,
- "Training Request: wTimeStamp: %"PRIu16" wPackSize: %"PRIu16"",
- wTimeStamp, wPackSize);
+ "Training Request: wTimeStamp: %" PRIu16 " wPackSize: %" PRIu16 "", wTimeStamp,
+ wPackSize);
return rdpsnd_send_training_confirm_pdu(rdpsnd, wTimeStamp, wPackSize);
}
static BOOL rdpsnd_ensure_device_is_open(rdpsndPlugin* rdpsnd, UINT32 wFormatNo,
- const AUDIO_FORMAT* format)
+ const AUDIO_FORMAT* format)
{
if (!rdpsnd)
return FALSE;
@@ -356,7 +355,8 @@ static BOOL rdpsnd_ensure_device_is_open(rdpsndPlugin* rdpsnd, UINT32 wFormatNo,
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Opening device with format %s [backend %s]",
audio_format_get_tag_string(format->wFormatTag),
audio_format_get_tag_string(deviceFormat.wFormatTag));
- rc = IFCALLRESULT(FALSE, rdpsnd->device->Open, rdpsnd->device, &deviceFormat, rdpsnd->latency);
+ rc = IFCALLRESULT(FALSE, rdpsnd->device->Open, rdpsnd->device, &deviceFormat,
+ rdpsnd->latency);
if (!rc)
return FALSE;
@@ -379,8 +379,7 @@ static BOOL rdpsnd_ensure_device_is_open(rdpsndPlugin* rdpsnd, UINT32 wFormatNo,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
- UINT16 BodySize)
+static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 BodySize)
{
UINT16 wFormatNo;
const AUDIO_FORMAT* format;
@@ -400,8 +399,9 @@ static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
Stream_Read(s, rdpsnd->waveData, 4);
rdpsnd->waveDataSize = BodySize - 8;
format = &rdpsnd->ClientFormats[wFormatNo];
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "WaveInfo: cBlockNo: %"PRIu8" wFormatNo: %"PRIu16" [%s]",
- rdpsnd->cBlockNo, wFormatNo, audio_format_get_tag_string(format->wFormatTag));
+ WLog_Print(rdpsnd->log, WLOG_DEBUG,
+ "WaveInfo: cBlockNo: %" PRIu8 " wFormatNo: %" PRIu16 " [%s]", rdpsnd->cBlockNo,
+ wFormatNo, audio_format_get_tag_string(format->wFormatTag));
if (!rdpsnd_ensure_device_is_open(rdpsnd, wFormatNo, format))
return ERROR_INTERNAL_ERROR;
@@ -415,8 +415,8 @@ static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd,
- UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
+static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp,
+ BYTE cConfirmedBlockNo)
{
wStream* pdu;
pdu = Stream_New(NULL, 8);
@@ -432,7 +432,7 @@ static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd,
Stream_Write_UINT16(pdu, 4);
Stream_Write_UINT16(pdu, wTimeStamp);
Stream_Write_UINT8(pdu, cConfirmedBlockNo); /* cConfirmedBlockNo */
- Stream_Write_UINT8(pdu, 0); /* bPad */
+ Stream_Write_UINT8(pdu, 0); /* bPad */
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
}
@@ -444,13 +444,13 @@ static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
UINT64 diffMS, ts;
UINT latency = 0;
-
if (Stream_GetRemainingLength(s) < size)
return ERROR_BAD_LENGTH;
data = Stream_Pointer(s);
format = &rdpsnd->ClientFormats[rdpsnd->wCurrentFormatNo];
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "Wave: cBlockNo: %"PRIu8" wTimeStamp: %"PRIu16", size: %"PRIdz,
+ WLog_Print(rdpsnd->log, WLOG_DEBUG,
+ "Wave: cBlockNo: %" PRIu8 " wTimeStamp: %" PRIu16 ", size: %" PRIdz,
rdpsnd->cBlockNo, rdpsnd->wTimeStamp, size);
if (rdpsnd->device && rdpsnd->attached)
@@ -483,7 +483,6 @@ static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
return rdpsnd_send_wave_confirm_pdu(rdpsnd, (UINT16)ts, rdpsnd->cBlockNo);
}
-
/**
* Function description
*
@@ -523,8 +522,9 @@ static UINT rdpsnd_recv_wave2_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 BodyS
rdpsnd->waveDataSize = BodySize - 12;
format = &rdpsnd->ClientFormats[wFormatNo];
rdpsnd->wArrivalTime = GetTickCount64();
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "Wave2PDU: cBlockNo: %"PRIu8" wFormatNo: %"PRIu16", align=%hu",
- rdpsnd->cBlockNo, wFormatNo, format->nBlockAlign);
+ WLog_Print(rdpsnd->log, WLOG_DEBUG,
+ "Wave2PDU: cBlockNo: %" PRIu8 " wFormatNo: %" PRIu16 ", align=%hu", rdpsnd->cBlockNo,
+ wFormatNo, format->nBlockAlign);
if (!rdpsnd_ensure_device_is_open(rdpsnd, wFormatNo, format))
return ERROR_INTERNAL_ERROR;
@@ -536,7 +536,7 @@ static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd)
{
if (rdpsnd->isOpen)
{
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "Closing device");
+ WLog_Print(rdpsnd->log, WLOG_DEBUG, "Closing device");
}
else
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Device already closed");
@@ -556,7 +556,7 @@ static UINT rdpsnd_recv_volume_pdu(rdpsndPlugin* rdpsnd, wStream* s)
return ERROR_BAD_LENGTH;
Stream_Read_UINT32(s, dwVolume);
- WLog_Print(rdpsnd->log, WLOG_DEBUG, "Volume: 0x%08"PRIX32"", dwVolume);
+ WLog_Print(rdpsnd->log, WLOG_DEBUG, "Volume: 0x%08" PRIX32 "", dwVolume);
rc = IFCALLRESULT(FALSE, rdpsnd->device->SetVolume, rdpsnd->device, dwVolume);
if (!rc)
@@ -592,7 +592,7 @@ static UINT rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s)
}
Stream_Read_UINT8(s, msgType); /* msgType */
- Stream_Seek_UINT8(s); /* bPad */
+ Stream_Seek_UINT8(s); /* bPad */
Stream_Read_UINT16(s, BodySize);
switch (msgType)
@@ -622,7 +622,7 @@ static UINT rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s)
break;
default:
- WLog_ERR(TAG, "unknown msgType %"PRIu8"", msgType);
+ WLog_ERR(TAG, "unknown msgType %" PRIu8 "", msgType);
break;
}
@@ -631,8 +631,7 @@ out:
return status;
}
-static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd,
- rdpsndDevicePlugin* device)
+static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlugin* device)
{
if (rdpsnd->device)
{
@@ -649,14 +648,13 @@ static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
- ADDIN_ARGV* args)
+static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, ADDIN_ARGV* args)
{
PFREERDP_RDPSND_DEVICE_ENTRY entry;
FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints;
UINT error;
- entry = (PFREERDP_RDPSND_DEVICE_ENTRY)
- freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);
+ entry = (PFREERDP_RDPSND_DEVICE_ENTRY)freerdp_load_channel_addin_entry("rdpsnd", (LPSTR)name,
+ NULL, 0);
if (!entry)
return ERROR_INTERNAL_ERROR;
@@ -666,7 +664,7 @@ static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
entryPoints.args = args;
if ((error = entry(&entryPoints)))
- WLog_ERR(TAG, "%s entry returns error %"PRIu32"", name, error);
+ WLog_ERR(TAG, "%s entry returns error %" PRIu32 "", name, error);
WLog_INFO(TAG, "Loaded %s backend for rdpsnd", name);
return error;
@@ -696,24 +694,24 @@ static UINT rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- COMMAND_LINE_ARGUMENT_A rdpsnd_args[] =
- {
- { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
- { "format", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "format" },
- { "rate", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "rate" },
- { "channel", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "channel" },
- { "latency", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "latency" },
- { "quality", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "quality mode" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A rdpsnd_args[] = {
+ { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device" },
+ { "format", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "format" },
+ { "rate", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "rate" },
+ { "channel", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "channel" },
+ { "latency", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "latency" },
+ { "quality", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ "quality mode" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ };
rdpsnd->wQualityMode = HIGH_QUALITY; /* default quality mode */
if (args->argc > 1)
{
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- rdpsnd_args, flags, rdpsnd, NULL, NULL);
+ status = CommandLineParseArgumentsA(args->argc, args->argv, rdpsnd_args, flags, rdpsnd,
+ NULL, NULL);
if (status < 0)
return CHANNEL_RC_INITIALIZATION_ERROR;
@@ -726,8 +724,7 @@ static UINT rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "sys")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "sys")
{
if (!rdpsnd_set_subsystem(rdpsnd, arg->Value))
return CHANNEL_RC_NO_MEMORY;
@@ -794,14 +791,13 @@ static UINT rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
if ((wQualityMode < 0) || (wQualityMode > 2))
wQualityMode = DYNAMIC_QUALITY;
- rdpsnd->wQualityMode = (UINT16) wQualityMode;
+ rdpsnd->wQualityMode = (UINT16)wQualityMode;
}
CommandLineSwitchDefault(arg)
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
}
return CHANNEL_RC_OK;
@@ -818,36 +814,34 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
{
const char* subsystem;
const char* device;
- }
- backends[] =
- {
+ } backends[] = {
#if defined(WITH_IOSAUDIO)
- {"ios", ""},
+ { "ios", "" },
#endif
#if defined(WITH_OPENSLES)
- {"opensles", ""},
+ { "opensles", "" },
#endif
#if defined(WITH_PULSE)
- {"pulse", ""},
+ { "pulse", "" },
#endif
#if defined(WITH_ALSA)
- {"alsa", "default"},
+ { "alsa", "default" },
#endif
#if defined(WITH_OSS)
- {"oss", ""},
+ { "oss", "" },
#endif
#if defined(WITH_MACAUDIO)
- {"mac", "default"},
+ { "mac", "default" },
#endif
#if defined(WITH_WINMM)
- { "winmm", ""},
+ { "winmm", "" },
#endif
{ "fake", "" }
};
ADDIN_ARGV* args;
UINT status = ERROR_INTERNAL_ERROR;
rdpsnd->latency = 0;
- args = (ADDIN_ARGV*) rdpsnd->channelEntryPoints.pExtendedData;
+ args = (ADDIN_ARGV*)rdpsnd->channelEntryPoints.pExtendedData;
if (args)
{
@@ -861,7 +855,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
{
if ((status = rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args)))
{
- WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %"PRIu32"",
+ WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %" PRIu32 "",
rdpsnd->subsystem, status);
return status;
}
@@ -876,7 +870,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
const char* device_name = backends[x].device;
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
- WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %"PRIu32"",
+ WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %" PRIu32 "",
subsystem_name, status);
if (!rdpsnd->device)
@@ -898,7 +892,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
static void rdpsnd_process_disconnect(rdpsndPlugin* rdpsnd)
{
- IFCALL(rdpsnd->device->Close, rdpsnd->device);
+ IFCALL(rdpsnd->device->Close, rdpsnd->device);
}
/**
@@ -912,14 +906,15 @@ UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
if (rdpsnd)
{
- status = rdpsnd->channelEntryPoints.pVirtualChannelWriteEx(rdpsnd->InitHandle, rdpsnd->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
+ status = rdpsnd->channelEntryPoints.pVirtualChannelWriteEx(
+ rdpsnd->InitHandle, rdpsnd->OpenHandle, Stream_Buffer(s), (UINT32)Stream_GetPosition(s),
+ s);
}
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
@@ -931,8 +926,9 @@ UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
return CHANNEL_RC_OK;
@@ -957,7 +953,7 @@ static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
if (!Queue_Enqueue(plugin->queue, plugin->data_in))
{
- WLog_ERR(TAG, "Queue_Enqueue failed!");
+ WLog_ERR(TAG, "Queue_Enqueue failed!");
return ERROR_INTERNAL_ERROR;
}
@@ -968,25 +964,27 @@ static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
}
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- rdpsndPlugin* rdpsnd = (rdpsndPlugin*) lpUserParam;
+ rdpsndPlugin* rdpsnd = (rdpsndPlugin*)lpUserParam;
if (!rdpsnd || (rdpsnd->OpenHandle != openHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData,
- dataLength, totalLength, dataFlags)))
+ if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData, dataLength,
+ totalLength, dataFlags)))
WLog_ERR(TAG,
- "rdpsnd_virtual_channel_event_data_received failed with error %"PRIu32"", error);
+ "rdpsnd_virtual_channel_event_data_received failed with error %" PRIu32 "",
+ error);
break;
@@ -996,7 +994,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, D
wStream* s = (wStream*)pData;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
@@ -1010,7 +1008,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, D
static DWORD WINAPI rdpsnd_virtual_channel_client_thread(LPVOID arg)
{
BOOL running = TRUE;
- rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
+ rdpsndPlugin* rdpsnd = (rdpsndPlugin*)arg;
DWORD error = CHANNEL_RC_OK;
HANDLE events[2];
@@ -1030,11 +1028,11 @@ static DWORD WINAPI rdpsnd_virtual_channel_client_thread(LPVOID arg)
switch (status)
{
case WAIT_OBJECT_0:
- {
- wStream* s = Queue_Dequeue(rdpsnd->queue);
- error = rdpsnd_recv_pdu(rdpsnd, s);
- }
- break;
+ {
+ wStream* s = Queue_Dequeue(rdpsnd->queue);
+ error = rdpsnd_recv_pdu(rdpsnd, s);
+ }
+ break;
case WAIT_OBJECT_0 + 1:
running = FALSE;
@@ -1044,8 +1042,7 @@ static DWORD WINAPI rdpsnd_virtual_channel_client_thread(LPVOID arg)
error = status;
break;
}
- }
- while ((error == CHANNEL_RC_OK) && running);
+ } while ((error == CHANNEL_RC_OK) && running);
out:
@@ -1067,10 +1064,10 @@ static void rdpsnd_queue_free(void* data)
Stream_Free(s, TRUE);
}
-static UINT rdpsnd_virtual_channel_event_initialized(rdpsndPlugin* rdpsnd,
- LPVOID pData, UINT32 dataLength)
+static UINT rdpsnd_virtual_channel_event_initialized(rdpsndPlugin* rdpsnd, LPVOID pData,
+ UINT32 dataLength)
{
- rdpsnd->stopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
+ rdpsnd->stopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
if (!rdpsnd->stopEvent)
goto fail;
@@ -1085,17 +1082,17 @@ fail:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd,
- LPVOID pData, UINT32 dataLength)
+static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd, LPVOID pData,
+ UINT32 dataLength)
{
UINT32 status;
- status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx(rdpsnd->InitHandle,
- &rdpsnd->OpenHandle, rdpsnd->channelDef.name,
- rdpsnd_virtual_channel_open_event_ex);
+ status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx(
+ rdpsnd->InitHandle, &rdpsnd->OpenHandle, rdpsnd->channelDef.name,
+ rdpsnd_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -1117,9 +1114,8 @@ static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd,
goto fail;
ResetEvent(rdpsnd->stopEvent);
- rdpsnd->thread = CreateThread(NULL, 0,
- rdpsnd_virtual_channel_client_thread, (void*) rdpsnd,
- 0, NULL);
+ rdpsnd->thread =
+ CreateThread(NULL, 0, rdpsnd_virtual_channel_client_thread, (void*)rdpsnd, 0, NULL);
if (!rdpsnd->thread)
goto fail;
@@ -1156,16 +1152,17 @@ static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
if (WaitForSingleObject(rdpsnd->thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
CloseHandle(rdpsnd->thread);
- error = rdpsnd->channelEntryPoints.pVirtualChannelCloseEx(rdpsnd->InitHandle, rdpsnd->OpenHandle);
+ error =
+ rdpsnd->channelEntryPoints.pVirtualChannelCloseEx(rdpsnd->InitHandle, rdpsnd->OpenHandle);
if (CHANNEL_RC_OK != error)
{
- WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(error), error);
return error;
}
@@ -1206,14 +1203,15 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
}
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData, UINT dataLength)
+ UINT event, LPVOID pData,
+ UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- rdpsndPlugin* plugin = (rdpsndPlugin*) lpUserParam;
+ rdpsndPlugin* plugin = (rdpsndPlugin*)lpUserParam;
if (!plugin || (plugin->InitHandle != pInitHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
@@ -1221,14 +1219,16 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, L
{
case CHANNEL_EVENT_INITIALIZED:
if ((error = rdpsnd_virtual_channel_event_initialized(plugin, pData, dataLength)))
- WLog_ERR(TAG, "rdpsnd_virtual_channel_event_initialized failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpsnd_virtual_channel_event_initialized failed with error %" PRIu32 "!",
error);
break;
case CHANNEL_EVENT_CONNECTED:
if ((error = rdpsnd_virtual_channel_event_connected(plugin, pData, dataLength)))
- WLog_ERR(TAG, "rdpsnd_virtual_channel_event_connected failed with error %"PRIu32"!",
+ WLog_ERR(TAG,
+ "rdpsnd_virtual_channel_event_connected failed with error %" PRIu32 "!",
error);
break;
@@ -1236,7 +1236,8 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, L
case CHANNEL_EVENT_DISCONNECTED:
if ((error = rdpsnd_virtual_channel_event_disconnected(plugin)))
WLog_ERR(TAG,
- "rdpsnd_virtual_channel_event_disconnected failed with error %"PRIu32"!", error);
+ "rdpsnd_virtual_channel_event_disconnected failed with error %" PRIu32 "!",
+ error);
break;
@@ -1270,7 +1271,7 @@ rdpContext* freerdp_rdpsnd_get_context(rdpsndPlugin* plugin)
}
/* rdpsnd is always built-in */
-#define VirtualChannelEntryEx rdpsnd_VirtualChannelEntryEx
+#define VirtualChannelEntryEx rdpsnd_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
@@ -1281,17 +1282,15 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
if (!pEntryPoints)
return FALSE;
- rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
+ rdpsnd = (rdpsndPlugin*)calloc(1, sizeof(rdpsndPlugin));
if (!rdpsnd)
return FALSE;
rdpsnd->attached = TRUE;
- rdpsnd->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP;
+ rdpsnd->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP;
sprintf_s(rdpsnd->channelDef.name, ARRAYSIZE(rdpsnd->channelDef.name), "rdpsnd");
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
@@ -1311,14 +1310,14 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
rdpsnd->InitHandle = pInitHandle;
- rc = rdpsnd->channelEntryPoints.pVirtualChannelInitEx(rdpsnd, NULL, pInitHandle,
- &rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- rdpsnd_virtual_channel_init_event_ex);
+ rc = rdpsnd->channelEntryPoints.pVirtualChannelInitEx(
+ rdpsnd, NULL, pInitHandle, &rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ rdpsnd_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
free(rdpsnd);
return FALSE;
}
diff --git a/channels/rdpsnd/client/rdpsnd_main.h b/channels/rdpsnd/client/rdpsnd_main.h
index 3202f26e4..b3b478ff7 100644
--- a/channels/rdpsnd/client/rdpsnd_main.h
+++ b/channels/rdpsnd/client/rdpsnd_main.h
@@ -34,7 +34,10 @@ FREERDP_API rdpContext* freerdp_rdpsnd_get_context(rdpsndPlugin* rdpsnd);
#if defined(WITH_DEBUG_SND)
#define DEBUG_SND(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_SND(...) do { } while (0)
+#define DEBUG_SND(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CHANNEL_RDPSND_CLIENT_MAIN_H */
diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c
index 5d96970b2..386a7f3a6 100644
--- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c
+++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c
@@ -85,7 +85,7 @@ static BOOL rdpsnd_winmm_convert_format(const AUDIO_FORMAT* in, WAVEFORMATEX* ou
static BOOL rdpsnd_winmm_set_format(rdpsndDevicePlugin* device, const AUDIO_FORMAT* format,
UINT32 latency)
{
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
winmm->latency = latency;
if (!rdpsnd_winmm_convert_format(format, &winmm->format))
@@ -94,29 +94,24 @@ static BOOL rdpsnd_winmm_set_format(rdpsndDevicePlugin* device, const AUDIO_FORM
return TRUE;
}
-static void CALLBACK waveOutProc(
- HWAVEOUT hwo,
- UINT uMsg,
- DWORD_PTR dwInstance,
- DWORD_PTR dwParam1,
- DWORD_PTR dwParam2
- )
+static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1,
+ DWORD_PTR dwParam2)
{
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) dwInstance;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)dwInstance;
LPWAVEHDR lpWaveHdr = (LPWAVEHDR)dwParam1;
- switch(uMsg)
+ switch (uMsg)
{
- case WOM_OPEN:
- case WOM_CLOSE:
- break;
- case WOM_DONE:
- waveOutUnprepareHeader(hwo, lpWaveHdr, sizeof(WAVEHDR));
- free(lpWaveHdr);
- ReleaseSemaphore(winmm->semaphore, 1, NULL);
- break;
- default:
- break;
+ case WOM_OPEN:
+ case WOM_CLOSE:
+ break;
+ case WOM_DONE:
+ waveOutUnprepareHeader(hwo, lpWaveHdr, sizeof(WAVEHDR));
+ free(lpWaveHdr);
+ ReleaseSemaphore(winmm->semaphore, 1, NULL);
+ break;
+ default:
+ break;
}
}
@@ -124,7 +119,7 @@ static BOOL rdpsnd_winmm_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
UINT32 latency)
{
MMRESULT mmResult;
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (winmm->hWaveOut)
return TRUE;
@@ -132,13 +127,12 @@ static BOOL rdpsnd_winmm_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
if (!rdpsnd_winmm_set_format(device, format, latency))
return FALSE;
- mmResult = waveOutOpen(&winmm->hWaveOut, WAVE_MAPPER, &winmm->format,
- (DWORD_PTR) waveOutProc, (DWORD_PTR)winmm,
- CALLBACK_FUNCTION);
+ mmResult = waveOutOpen(&winmm->hWaveOut, WAVE_MAPPER, &winmm->format, (DWORD_PTR)waveOutProc,
+ (DWORD_PTR)winmm, CALLBACK_FUNCTION);
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutOpen failed: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutOpen failed: %" PRIu32 "", mmResult);
return FALSE;
}
@@ -148,7 +142,7 @@ static BOOL rdpsnd_winmm_open(rdpsndDevicePlugin* device, const AUDIO_FORMAT* fo
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutSetVolume failed: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutSetVolume failed: %" PRIu32 "", mmResult);
return FALSE;
}
@@ -159,15 +153,15 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device)
{
size_t x;
MMRESULT mmResult;
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (winmm->hWaveOut)
{
- for (x=0; xsemaphore, INFINITE);
mmResult = waveOutClose(winmm->hWaveOut);
if (mmResult != MMSYSERR_NOERROR)
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutClose failure: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutClose failure: %" PRIu32 "", mmResult);
winmm->hWaveOut = NULL;
}
@@ -175,7 +169,7 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device)
static void rdpsnd_winmm_free(rdpsndDevicePlugin* device)
{
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (winmm)
{
@@ -206,7 +200,7 @@ static UINT32 rdpsnd_winmm_get_volume(rdpsndDevicePlugin* device)
{
MMRESULT mmResult;
DWORD dwVolume = UINT32_MAX;
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (!winmm->hWaveOut)
return dwVolume;
@@ -214,7 +208,7 @@ static UINT32 rdpsnd_winmm_get_volume(rdpsndDevicePlugin* device)
mmResult = waveOutGetVolume(winmm->hWaveOut, &dwVolume);
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutGetVolume failure: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutGetVolume failure: %" PRIu32 "", mmResult);
dwVolume = UINT32_MAX;
}
return dwVolume;
@@ -223,7 +217,7 @@ static UINT32 rdpsnd_winmm_get_volume(rdpsndDevicePlugin* device)
static BOOL rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
MMRESULT mmResult;
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
winmm->volume = value;
if (!winmm->hWaveOut)
@@ -232,7 +226,7 @@ static BOOL rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
mmResult = waveOutSetVolume(winmm->hWaveOut, value);
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutGetVolume failure: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutGetVolume failure: %" PRIu32 "", mmResult);
return FALSE;
}
return TRUE;
@@ -240,7 +234,7 @@ static BOOL rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
static void rdpsnd_winmm_start(rdpsndDevicePlugin* device)
{
- //rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ // rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
WINPR_UNUSED(device);
}
@@ -248,7 +242,7 @@ static UINT rdpsnd_winmm_play(rdpsndDevicePlugin* device, const BYTE* data, size
{
MMRESULT mmResult;
LPWAVEHDR lpWaveHdr;
- rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;
+ rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*)device;
if (!winmm->hWaveOut)
return 0;
@@ -262,14 +256,14 @@ static UINT rdpsnd_winmm_play(rdpsndDevicePlugin* device, const BYTE* data, size
lpWaveHdr->dwFlags = 0;
lpWaveHdr->dwLoops = 0;
- lpWaveHdr->lpData = (LPSTR) data;
+ lpWaveHdr->lpData = (LPSTR)data;
lpWaveHdr->dwBufferLength = (DWORD)size;
mmResult = waveOutPrepareHeader(winmm->hWaveOut, lpWaveHdr, sizeof(WAVEHDR));
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutPrepareHeader failure: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutPrepareHeader failure: %" PRIu32 "", mmResult);
free(lpWaveHdr);
return 0;
}
@@ -279,7 +273,7 @@ static UINT rdpsnd_winmm_play(rdpsndDevicePlugin* device, const BYTE* data, size
if (mmResult != MMSYSERR_NOERROR)
{
- WLog_Print(winmm->log, WLOG_ERROR, "waveOutWrite failure: %"PRIu32"", mmResult);
+ WLog_Print(winmm->log, WLOG_ERROR, "waveOutWrite failure: %" PRIu32 "", mmResult);
waveOutUnprepareHeader(winmm->hWaveOut, lpWaveHdr, sizeof(WAVEHDR));
free(lpWaveHdr);
return 0;
@@ -295,9 +289,9 @@ static void rdpsnd_winmm_parse_addin_args(rdpsndDevicePlugin* device, ADDIN_ARGV
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_rdpsnd_client_subsystem_entry winmm_freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry winmm_freerdp_rdpsnd_client_subsystem_entry
#else
-#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
+#define freerdp_rdpsnd_client_subsystem_entry FREERDP_API freerdp_rdpsnd_client_subsystem_entry
#endif
/**
@@ -309,7 +303,7 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
{
ADDIN_ARGV* args;
rdpsndWinmmPlugin* winmm;
- winmm = (rdpsndWinmmPlugin*) calloc(1, sizeof(rdpsndWinmmPlugin));
+ winmm = (rdpsndWinmmPlugin*)calloc(1, sizeof(rdpsndWinmmPlugin));
if (!winmm)
return CHANNEL_RC_NO_MEMORY;
@@ -327,9 +321,9 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p
if (!winmm->semaphore)
goto fail;
args = pEntryPoints->args;
- rdpsnd_winmm_parse_addin_args((rdpsndDevicePlugin*) winmm, args);
+ rdpsnd_winmm_parse_addin_args((rdpsndDevicePlugin*)winmm, args);
winmm->volume = 0xFFFFFFFF;
- pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*) winmm);
+ pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)winmm);
return CHANNEL_RC_OK;
fail:
diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c
index 53d4d5c32..0c51c7641 100644
--- a/channels/rdpsnd/server/rdpsnd_main.c
+++ b/channels/rdpsnd/server/rdpsnd_main.c
@@ -50,20 +50,21 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s)
Stream_Write_UINT8(s, SNDC_FORMATS);
Stream_Write_UINT8(s, 0);
Stream_Seek_UINT16(s);
- Stream_Write_UINT32(s, 0); /* dwFlags */
- Stream_Write_UINT32(s, 0); /* dwVolume */
- Stream_Write_UINT32(s, 0); /* dwPitch */
- Stream_Write_UINT16(s, 0); /* wDGramPort */
+ Stream_Write_UINT32(s, 0); /* dwFlags */
+ Stream_Write_UINT32(s, 0); /* dwVolume */
+ Stream_Write_UINT32(s, 0); /* dwPitch */
+ Stream_Write_UINT16(s, 0); /* wDGramPort */
Stream_Write_UINT16(s, context->num_server_formats); /* wNumberOfFormats */
- Stream_Write_UINT8(s, context->block_no); /* cLastBlockConfirmed */
- Stream_Write_UINT16(s, CHANNEL_VERSION_WIN_MAX); /* wVersion */
- Stream_Write_UINT8(s, 0); /* bPad */
+ Stream_Write_UINT8(s, context->block_no); /* cLastBlockConfirmed */
+ Stream_Write_UINT16(s, CHANNEL_VERSION_WIN_MAX); /* wVersion */
+ Stream_Write_UINT8(s, 0); /* bPad */
for (i = 0; i < context->num_server_formats; i++)
{
AUDIO_FORMAT format = context->server_formats[i];
// TODO: Eliminate this!!!
- format.nAvgBytesPerSec = format.nSamplesPerSec * format.nChannels * format.wBitsPerSample / 8;
+ format.nAvgBytesPerSec =
+ format.nSamplesPerSec * format.nChannels * format.wBitsPerSample / 8;
if (!audio_format_write(s, &format))
goto fail;
@@ -73,8 +74,8 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s)
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_GetPosition(s), &written);
Stream_SetPosition(s, 0);
fail:
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
@@ -85,8 +86,7 @@ fail:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context,
- wStream* s)
+static UINT rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context, wStream* s)
{
UINT16 timestamp;
BYTE confirmBlockNum;
@@ -101,10 +101,10 @@ static UINT rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context,
Stream_Read_UINT16(s, timestamp);
Stream_Read_UINT8(s, confirmBlockNum);
Stream_Seek_UINT8(s);
- IFCALLRET(context->ConfirmBlock, error, context, confirmBlockNum, timestamp);
+ IFCALLRET(context->ConfirmBlock, error, context, confirmBlockNum, timestamp);
if (error)
- WLog_ERR(TAG, "context->ConfirmBlock failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "context->ConfirmBlock failed with error %" PRIu32 "", error);
return error;
}
@@ -114,8 +114,7 @@ static UINT rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context,
- wStream* s)
+static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStream* s)
{
UINT16 quality;
@@ -127,7 +126,7 @@ static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context,
Stream_Read_UINT16(s, quality);
Stream_Seek_UINT16(s); // reserved
- WLog_DBG(TAG, "Client requested sound quality: 0x%04"PRIX16"", quality);
+ WLog_DBG(TAG, "Client requested sound quality: 0x%04" PRIX16 "", quality);
return CHANNEL_RC_OK;
}
@@ -150,14 +149,14 @@ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, flags); /* dwFlags */
- Stream_Read_UINT32(s, vol); /* dwVolume */
- Stream_Read_UINT32(s, pitch); /* dwPitch */
- Stream_Read_UINT16(s, udpPort); /* wDGramPort */
+ Stream_Read_UINT32(s, flags); /* dwFlags */
+ Stream_Read_UINT32(s, vol); /* dwVolume */
+ Stream_Read_UINT32(s, pitch); /* dwPitch */
+ Stream_Read_UINT16(s, udpPort); /* wDGramPort */
Stream_Read_UINT16(s, context->num_client_formats); /* wNumberOfFormats */
- Stream_Read_UINT8(s, lastblock); /* cLastBlockConfirmed */
- Stream_Read_UINT16(s, context->clientVersion); /* wVersion */
- Stream_Seek_UINT8(s); /* bPad */
+ Stream_Read_UINT8(s, lastblock); /* cLastBlockConfirmed */
+ Stream_Read_UINT16(s, context->clientVersion); /* wVersion */
+ Stream_Seek_UINT8(s); /* bPad */
/* this check is only a guess as cbSize can influence the size of a format record */
if (Stream_GetRemainingLength(s) < context->num_client_formats * 18)
@@ -168,7 +167,7 @@ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
if (!context->num_client_formats)
{
- WLog_ERR(TAG, "client doesn't support any format!");
+ WLog_ERR(TAG, "client doesn't support any format!");
return ERROR_INTERNAL_ERROR;
}
@@ -176,7 +175,7 @@ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
if (!context->client_formats)
{
- WLog_ERR(TAG, "calloc failed!");
+ WLog_ERR(TAG, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
}
@@ -209,15 +208,15 @@ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
if (context->client_formats[i].wFormatTag != 0)
{
- //lets call this a known format
- //TODO: actually look through our own list of known formats
+ // lets call this a known format
+ // TODO: actually look through our own list of known formats
num_known_format++;
}
}
if (!context->num_client_formats)
{
- WLog_ERR(TAG, "client doesn't support any known format!");
+ WLog_ERR(TAG, "client doesn't support any known format!");
goto out_free;
}
@@ -245,7 +244,7 @@ static DWORD WINAPI rdpsnd_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -254,7 +253,7 @@ static DWORD WINAPI rdpsnd_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
@@ -263,14 +262,13 @@ static DWORD WINAPI rdpsnd_server_thread(LPVOID arg)
if ((error = rdpsnd_server_handle_messages(context)))
{
- WLog_ERR(TAG, "rdpsnd_server_handle_messages failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpsnd_server_handle_messages failed with error %" PRIu32 "", error);
break;
}
}
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "rdpsnd_server_thread reported an error");
+ setChannelError(context->rdpcontext, error, "rdpsnd_server_thread reported an error");
ExitThread(error);
return error;
@@ -281,8 +279,7 @@ static DWORD WINAPI rdpsnd_server_thread(LPVOID arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_initialize(RdpsndServerContext* context,
- BOOL ownThread)
+static UINT rdpsnd_server_initialize(RdpsndServerContext* context, BOOL ownThread)
{
context->priv->ownThread = ownThread;
return context->Start(context);
@@ -293,31 +290,29 @@ static UINT rdpsnd_server_initialize(RdpsndServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_select_format(RdpsndServerContext* context,
- UINT16 client_format_index)
+static UINT rdpsnd_server_select_format(RdpsndServerContext* context, UINT16 client_format_index)
{
int bs;
int out_buffer_size;
AUDIO_FORMAT* format;
UINT error = CHANNEL_RC_OK;
- if ((client_format_index >= context->num_client_formats)
- || (!context->src_format))
+ if ((client_format_index >= context->num_client_formats) || (!context->src_format))
{
- WLog_ERR(TAG, "index %d is not correct.", client_format_index);
+ WLog_ERR(TAG, "index %d is not correct.", client_format_index);
return ERROR_INVALID_DATA;
}
EnterCriticalSection(&context->priv->lock);
context->priv->src_bytes_per_sample = context->src_format->wBitsPerSample / 8;
- context->priv->src_bytes_per_frame = context->priv->src_bytes_per_sample *
- context->src_format->nChannels;
+ context->priv->src_bytes_per_frame =
+ context->priv->src_bytes_per_sample * context->src_format->nChannels;
context->selected_client_format = client_format_index;
format = &context->client_formats[client_format_index];
if (format->nSamplesPerSec == 0)
{
- WLog_ERR(TAG, "invalid Client Sound Format!!");
+ WLog_ERR(TAG, "invalid Client Sound Format!!");
error = ERROR_INVALID_DATA;
goto out;
}
@@ -325,8 +320,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context,
if (context->latency <= 0)
context->latency = 50;
- context->priv->out_frames = context->src_format->nSamplesPerSec *
- context->latency / 1000;
+ context->priv->out_frames = context->src_format->nSamplesPerSec * context->latency / 1000;
if (context->priv->out_frames < 1)
context->priv->out_frames = 1;
@@ -353,8 +347,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context,
}
context->priv->out_pending_frames = 0;
- out_buffer_size = context->priv->out_frames *
- context->priv->src_bytes_per_frame;
+ out_buffer_size = context->priv->out_frames * context->priv->src_bytes_per_frame;
if (context->priv->out_buffer_size < out_buffer_size)
{
@@ -404,8 +397,7 @@ static BOOL rdpsnd_server_align_wave_pdu(wStream* s, UINT32 alignment)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context,
- UINT16 wTimestamp)
+static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context, UINT16 wTimestamp)
{
size_t length;
size_t start, end = 0;
@@ -421,13 +413,13 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context,
format = &context->client_formats[context->selected_client_format];
/* WaveInfo PDU */
Stream_SetPosition(s, 0);
- Stream_Write_UINT8(s, SNDC_WAVE); /* msgType */
- Stream_Write_UINT8(s, 0); /* bPad */
- Stream_Write_UINT16(s, 0); /* BodySize */
- Stream_Write_UINT16(s, wTimestamp); /* wTimeStamp */
+ Stream_Write_UINT8(s, SNDC_WAVE); /* msgType */
+ Stream_Write_UINT8(s, 0); /* bPad */
+ Stream_Write_UINT16(s, 0); /* BodySize */
+ Stream_Write_UINT16(s, wTimestamp); /* wTimeStamp */
Stream_Write_UINT16(s, context->selected_client_format); /* wFormatNo */
- Stream_Write_UINT8(s, context->block_no); /* cBlockNo */
- Stream_Seek(s, 3); /* bPad */
+ Stream_Write_UINT8(s, context->block_no); /* cBlockNo */
+ Stream_Seek(s, 3); /* bPad */
start = Stream_GetPosition(s);
src = context->priv->out_buffer;
length = context->priv->out_pending_frames * context->priv->src_bytes_per_frame;
@@ -446,8 +438,8 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context,
Stream_SetPosition(s, end);
context->block_no = (context->block_no + 1) % 256;
- if (!WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), start + 4, &written))
+ if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ start + 4, &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
error = ERROR_INTERNAL_ERROR;
@@ -465,8 +457,8 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context,
Stream_Write_UINT32(s, 0); /* bPad */
Stream_SetPosition(s, start);
- if (!WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Pointer(s), end - start, &written))
+ if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Pointer(s), end - start,
+ &written))
{
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
error = ERROR_INTERNAL_ERROR;
@@ -484,8 +476,7 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context,
- UINT16 wTimestamp)
+static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context, UINT16 wTimestamp)
{
size_t length;
size_t end = 0;
@@ -501,14 +492,14 @@ static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context,
format = &context->client_formats[context->selected_client_format];
/* WaveInfo PDU */
Stream_SetPosition(s, 0);
- Stream_Write_UINT8(s, SNDC_WAVE2); /* msgType */
- Stream_Write_UINT8(s, 0); /* bPad */
- Stream_Write_UINT16(s, 0); /* BodySize */
- Stream_Write_UINT16(s, wTimestamp); /* wTimeStamp */
+ Stream_Write_UINT8(s, SNDC_WAVE2); /* msgType */
+ Stream_Write_UINT8(s, 0); /* bPad */
+ Stream_Write_UINT16(s, 0); /* BodySize */
+ Stream_Write_UINT16(s, wTimestamp); /* wTimeStamp */
Stream_Write_UINT16(s, context->selected_client_format); /* wFormatNo */
- Stream_Write_UINT8(s, context->block_no); /* cBlockNo */
- Stream_Seek(s, 3); /* bPad */
- Stream_Write_UINT32(s, wTimestamp); /* dwAudioTimeStamp */
+ Stream_Write_UINT8(s, context->block_no); /* cBlockNo */
+ Stream_Seek(s, 3); /* bPad */
+ Stream_Write_UINT32(s, wTimestamp); /* dwAudioTimeStamp */
src = context->priv->out_buffer;
length = context->priv->out_pending_frames * context->priv->src_bytes_per_frame;
@@ -526,13 +517,14 @@ static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context,
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, end - 4);
context->block_no = (context->block_no + 1) % 256;
- rc = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), end, &written);
+ rc = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s), end,
+ &written);
if (!rc || (end != written))
{
- WLog_ERR(TAG, "WTSVirtualChannelWrite failed! [stream length=%"PRIdz" - written=%"PRIu32, end,
- written);
+ WLog_ERR(TAG,
+ "WTSVirtualChannelWrite failed! [stream length=%" PRIdz " - written=%" PRIu32,
+ end, written);
error = ERROR_INTERNAL_ERROR;
}
}
@@ -543,8 +535,7 @@ static UINT rdpsnd_server_send_wave2_pdu(RdpsndServerContext* context,
}
/* Wrapper function to send WAVE or WAVE2 PDU depending on client connected */
-static UINT rdpsnd_server_send_audio_pdu(RdpsndServerContext* context,
- UINT16 wTimestamp)
+static UINT rdpsnd_server_send_audio_pdu(RdpsndServerContext* context, UINT16 wTimestamp)
{
if (context->clientVersion >= CHANNEL_VERSION_WIN_8)
return rdpsnd_server_send_wave2_pdu(context, wTimestamp);
@@ -557,8 +548,8 @@ static UINT rdpsnd_server_send_audio_pdu(RdpsndServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_send_samples(RdpsndServerContext* context,
- const void* buf, int nframes, UINT16 wTimestamp)
+static UINT rdpsnd_server_send_samples(RdpsndServerContext* context, const void* buf, int nframes,
+ UINT16 wTimestamp)
{
int cframes;
int cframesize;
@@ -575,13 +566,12 @@ static UINT rdpsnd_server_send_samples(RdpsndServerContext* context,
while (nframes > 0)
{
- cframes = MIN(nframes, context->priv->out_frames -
- context->priv->out_pending_frames);
+ cframes = MIN(nframes, context->priv->out_frames - context->priv->out_pending_frames);
cframesize = cframes * context->priv->src_bytes_per_frame;
CopyMemory(context->priv->out_buffer +
- (context->priv->out_pending_frames * context->priv->src_bytes_per_frame), buf,
- cframesize);
- buf = (BYTE*) buf + cframesize;
+ (context->priv->out_pending_frames * context->priv->src_bytes_per_frame),
+ buf, cframesize);
+ buf = (BYTE*)buf + cframesize;
nframes -= cframes;
context->priv->out_pending_frames += cframes;
@@ -589,7 +579,7 @@ static UINT rdpsnd_server_send_samples(RdpsndServerContext* context,
{
if ((error = rdpsnd_server_send_audio_pdu(context, wTimestamp)))
{
- WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %" PRIu32 "", error);
break;
}
}
@@ -605,8 +595,7 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, int left,
- int right)
+static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, int left, int right)
{
size_t pos;
BOOL status;
@@ -621,8 +610,8 @@ static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, int left,
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_GetPosition(s), &written);
Stream_SetPosition(s, 0);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -650,7 +639,7 @@ static UINT rdpsnd_server_close(RdpsndServerContext* context)
}
else if ((error = rdpsnd_server_send_audio_pdu(context, 0)))
{
- WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %" PRIu32 "", error);
}
}
@@ -667,8 +656,8 @@ static UINT rdpsnd_server_close(RdpsndServerContext* context)
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), &written);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_GetPosition(s), &written);
Stream_SetPosition(s, 0);
return status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -684,8 +673,7 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context)
DWORD bytesReturned;
RdpsndServerPrivate* priv = context->priv;
UINT error = ERROR_INTERNAL_ERROR;
- priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION,
- "rdpsnd");
+ priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "rdpsnd");
if (!priv->ChannelHandle)
{
@@ -694,10 +682,12 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context)
}
if (!WTSVirtualChannelQuery(priv->ChannelHandle, WTSVirtualEventHandle, &buffer,
- &bytesReturned) || (bytesReturned != sizeof(HANDLE)))
+ &bytesReturned) ||
+ (bytesReturned != sizeof(HANDLE)))
{
WLog_ERR(TAG,
- "error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%"PRIu32")",
+ "error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned "
+ "size(%" PRIu32 ")",
bytesReturned);
if (buffer)
@@ -725,7 +715,7 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context)
if ((error = rdpsnd_server_send_formats(context, context->priv->rdpsnd_pdu)))
{
- WLog_ERR(TAG, "rdpsnd_server_send_formats failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "rdpsnd_server_send_formats failed with error %" PRIu32 "", error);
goto out_lock;
}
@@ -739,8 +729,8 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context)
goto out_lock;
}
- context->priv->Thread = CreateThread(NULL, 0,
- rdpsnd_server_thread, (void*) context, 0, NULL);
+ context->priv->Thread =
+ CreateThread(NULL, 0, rdpsnd_server_thread, (void*)context, 0, NULL);
if (!context->priv->Thread)
{
@@ -782,7 +772,7 @@ static UINT rdpsnd_server_stop(RdpsndServerContext* context)
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -820,8 +810,7 @@ RdpsndServerContext* rdpsnd_server_context_new(HANDLE vcm)
context->SendSamples = rdpsnd_server_send_samples;
context->SetVolume = rdpsnd_server_set_volume;
context->Close = rdpsnd_server_close;
- context->priv = priv = (RdpsndServerPrivate*)calloc(1,
- sizeof(RdpsndServerPrivate));
+ context->priv = priv = (RdpsndServerPrivate*)calloc(1, sizeof(RdpsndServerPrivate));
if (!priv)
{
@@ -858,7 +847,6 @@ out_free:
return NULL;
}
-
void rdpsnd_server_context_reset(RdpsndServerContext* context)
{
context->priv->expectedBytes = 4;
@@ -916,7 +904,7 @@ UINT rdpsnd_server_handle_messages(RdpsndServerContext* context)
if (GetLastError() == ERROR_NO_DATA)
return ERROR_NO_DATA;
- WLog_ERR(TAG, "channel connection closed");
+ WLog_ERR(TAG, "channel connection closed");
return ERROR_INTERNAL_ERROR;
}
@@ -952,7 +940,7 @@ UINT rdpsnd_server_handle_messages(RdpsndServerContext* context)
/* when here we have the header + the body */
#ifdef WITH_DEBUG_SND
- WLog_DBG(TAG, "message type %"PRIu8"", priv->msgType);
+ WLog_DBG(TAG, "message type %" PRIu8 "", priv->msgType);
#endif
priv->expectedBytes = 4;
priv->waitingHeader = TRUE;
@@ -982,7 +970,7 @@ UINT rdpsnd_server_handle_messages(RdpsndServerContext* context)
break;
default:
- WLog_ERR(TAG, "UNKNOWN MESSAGE TYPE!! (0x%02"PRIX8")", priv->msgType);
+ WLog_ERR(TAG, "UNKNOWN MESSAGE TYPE!! (0x%02" PRIX8 ")", priv->msgType);
ret = ERROR_INVALID_DATA;
break;
}
diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c
index dc2a6f839..c950d458f 100644
--- a/channels/remdesk/client/remdesk_main.c
+++ b/channels/remdesk/client/remdesk_main.c
@@ -49,14 +49,13 @@ static UINT remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s)
return CHANNEL_RC_INVALID_INSTANCE;
}
- status = remdesk->channelEntryPoints.pVirtualChannelWriteEx(remdesk->InitHandle,
- remdesk->OpenHandle,
- Stream_Buffer(s), (UINT32) Stream_Length(s), s);
+ status = remdesk->channelEntryPoints.pVirtualChannelWriteEx(
+ remdesk->InitHandle, remdesk->OpenHandle, Stream_Buffer(s), (UINT32)Stream_Length(s), s);
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
- WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
}
return status;
@@ -93,8 +92,8 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
if (!name)
name = "Expert";
- remdesk->EncryptedPassStub = freerdp_assistance_encrypt_pass_stub(password,
- settings->RemoteAssistancePassStub, &(remdesk->EncryptedPassStubSize));
+ remdesk->EncryptedPassStub = freerdp_assistance_encrypt_pass_stub(
+ password, settings->RemoteAssistancePassStub, &(remdesk->EncryptedPassStubSize));
if (!remdesk->EncryptedPassStub)
{
@@ -103,7 +102,7 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
}
pass = freerdp_assistance_bin_to_hex_string(remdesk->EncryptedPassStub,
- remdesk->EncryptedPassStubSize);
+ remdesk->EncryptedPassStubSize);
if (!pass)
{
@@ -128,8 +127,7 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_read_channel_header(wStream* s,
- REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_read_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header)
{
int status;
UINT32 ChannelNameLen;
@@ -141,7 +139,7 @@ static UINT remdesk_read_channel_header(wStream* s,
return ERROR_INVALID_DATA;
}
- Stream_Read_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
+ Stream_Read_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
Stream_Read_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
if (ChannelNameLen > 64)
@@ -163,9 +161,9 @@ static UINT remdesk_read_channel_header(wStream* s,
}
ZeroMemory(header->ChannelName, sizeof(header->ChannelName));
- pChannelName = (char*) header->ChannelName;
- status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
- ChannelNameLen / 2, &pChannelName, 32, NULL, NULL);
+ pChannelName = (char*)header->ChannelName;
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)Stream_Pointer(s), ChannelNameLen / 2,
+ &pChannelName, 32, NULL, NULL);
Stream_Seek(s, ChannelNameLen);
if (status <= 0)
@@ -182,8 +180,7 @@ static UINT remdesk_read_channel_header(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_write_channel_header(wStream* s,
- REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_write_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header)
{
int index;
UINT32 ChannelNameLen;
@@ -192,12 +189,12 @@ static UINT remdesk_write_channel_header(wStream* s,
for (index = 0; index < 32; index++)
{
- ChannelNameW[index] = (WCHAR) header->ChannelName[index];
+ ChannelNameW[index] = (WCHAR)header->ChannelName[index];
}
ChannelNameLen = (strnlen(header->ChannelName, sizeof(header->ChannelName)) + 1) * 2;
- Stream_Write_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
- Stream_Write_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
+ Stream_Write_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
+ Stream_Write_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
Stream_Write(s, ChannelNameW, ChannelNameLen); /* ChannelName (variable) */
return CHANNEL_RC_OK;
}
@@ -209,7 +206,7 @@ static UINT remdesk_write_channel_header(wStream* s,
*/
static UINT remdesk_write_ctl_header(wStream* s, REMDESK_CTL_HEADER* ctlHeader)
{
- remdesk_write_channel_header(s, (REMDESK_CHANNEL_HEADER*) ctlHeader);
+ remdesk_write_channel_header(s, (REMDESK_CHANNEL_HEADER*)ctlHeader);
Stream_Write_UINT32(s, ctlHeader->msgType); /* msgType (4 bytes) */
return CHANNEL_RC_OK;
}
@@ -219,8 +216,8 @@ static UINT remdesk_write_ctl_header(wStream* s, REMDESK_CTL_HEADER* ctlHeader)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
- UINT32 msgType, UINT32 msgSize)
+static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader, UINT32 msgType,
+ UINT32 msgSize)
{
ctlHeader->msgType = msgType;
sprintf_s(ctlHeader->ChannelName, ARRAYSIZE(ctlHeader->ChannelName), REMDESK_CHANNEL_CTL_NAME);
@@ -233,8 +230,8 @@ static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_server_announce_pdu(remdeskPlugin* remdesk,
- wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_server_announce_pdu(remdeskPlugin* remdesk, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
return CHANNEL_RC_OK;
}
@@ -244,8 +241,8 @@ static UINT remdesk_recv_ctl_server_announce_pdu(remdeskPlugin* remdesk,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_version_info_pdu(remdeskPlugin* remdesk,
- wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_version_info_pdu(remdeskPlugin* remdesk, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
UINT32 versionMajor;
UINT32 versionMinor;
@@ -261,7 +258,8 @@ static UINT remdesk_recv_ctl_version_info_pdu(remdeskPlugin* remdesk,
if ((versionMajor != 1) || (versionMinor > 2) || (versionMinor == 0))
{
- WLog_ERR(TAG, "Unsupported protocol version %"PRId32".%"PRId32, versionMajor, versionMinor);
+ WLog_ERR(TAG, "Unsupported protocol version %" PRId32 ".%" PRId32, versionMajor,
+ versionMinor);
}
remdesk->Version = versionMinor;
@@ -277,7 +275,7 @@ static UINT remdesk_send_ctl_version_info_pdu(remdeskPlugin* remdesk)
{
wStream* s;
REMDESK_CTL_VERSION_INFO_PDU pdu;
- UINT error;
+ UINT error;
remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_VERSIONINFO, 8);
pdu.versionMajor = 1;
pdu.versionMinor = 2;
@@ -295,7 +293,7 @@ static UINT remdesk_send_ctl_version_info_pdu(remdeskPlugin* remdesk)
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(remdesk, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
return error;
}
@@ -318,7 +316,7 @@ static UINT remdesk_recv_ctl_result_pdu(remdeskPlugin* remdesk, wStream* s,
Stream_Read_UINT32(s, result); /* result (4 bytes) */
*pResult = result;
- //WLog_DBG(TAG, "RemdeskRecvResult: 0x%08"PRIX32"", result);
+ // WLog_DBG(TAG, "RemdeskRecvResult: 0x%08"PRIX32"", result);
return CHANNEL_RC_OK;
}
@@ -340,14 +338,13 @@ static UINT remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk)
if ((error = remdesk_generate_expert_blob(remdesk)))
{
- WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %" PRIu32 "", error);
return error;
}
pdu.expertBlob = remdesk->ExpertBlob;
pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;
- status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1,
- &raConnectionStringW, 0);
+ status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1, &raConnectionStringW, 0);
if (status <= 0)
{
@@ -378,12 +375,12 @@ static UINT remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk)
}
remdesk_write_ctl_header(s, &(pdu.ctlHeader));
- Stream_Write(s, (BYTE*) raConnectionStringW, cbRaConnectionStringW);
- Stream_Write(s, (BYTE*) expertBlobW, cbExpertBlobW);
+ Stream_Write(s, (BYTE*)raConnectionStringW, cbRaConnectionStringW);
+ Stream_Write(s, (BYTE*)expertBlobW, cbExpertBlobW);
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(remdesk, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
out:
free(raConnectionStringW);
@@ -406,8 +403,7 @@ static UINT remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk)
WCHAR* raConnectionStringW = NULL;
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;
pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;
- status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1,
- &raConnectionStringW, 0);
+ status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1, &raConnectionStringW, 0);
if (status <= 0)
{
@@ -428,11 +424,11 @@ static UINT remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk)
}
remdesk_write_ctl_header(s, &(pdu.ctlHeader));
- Stream_Write(s, (BYTE*) raConnectionStringW, cbRaConnectionStringW);
+ Stream_Write(s, (BYTE*)raConnectionStringW, cbRaConnectionStringW);
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(remdesk, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
out:
free(raConnectionStringW);
@@ -456,7 +452,7 @@ static UINT remdesk_send_ctl_verify_password_pdu(remdeskPlugin* remdesk)
if ((error = remdesk_generate_expert_blob(remdesk)))
{
- WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %" PRIu32 "!", error);
return error;
}
@@ -470,8 +466,7 @@ static UINT remdesk_send_ctl_verify_password_pdu(remdeskPlugin* remdesk)
}
cbExpertBlobW = status * 2;
- remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_VERIFY_PASSWORD,
- cbExpertBlobW);
+ remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_VERIFY_PASSWORD, cbExpertBlobW);
s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);
if (!s)
@@ -482,11 +477,11 @@ static UINT remdesk_send_ctl_verify_password_pdu(remdeskPlugin* remdesk)
}
remdesk_write_ctl_header(s, &(pdu.ctlHeader));
- Stream_Write(s, (BYTE*) expertBlobW, cbExpertBlobW);
+ Stream_Write(s, (BYTE*)expertBlobW, cbExpertBlobW);
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(remdesk, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
out:
free(expertBlobW);
@@ -507,7 +502,7 @@ static UINT remdesk_send_ctl_expert_on_vista_pdu(remdeskPlugin* remdesk)
if ((error = remdesk_generate_expert_blob(remdesk)))
{
- WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_generate_expert_blob failed with error %" PRIu32 "!", error);
return error;
}
@@ -534,8 +529,7 @@ static UINT remdesk_send_ctl_expert_on_vista_pdu(remdeskPlugin* remdesk)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
- REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s, REMDESK_CHANNEL_HEADER* header)
{
UINT error = CHANNEL_RC_OK;
UINT32 msgType = 0;
@@ -549,7 +543,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
Stream_Read_UINT32(s, msgType); /* msgType (4 bytes) */
- //WLog_DBG(TAG, "msgType: %"PRIu32"", msgType);
+ // WLog_DBG(TAG, "msgType: %"PRIu32"", msgType);
switch (msgType)
{
@@ -558,7 +552,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
case REMDESK_CTL_RESULT:
if ((error = remdesk_recv_ctl_result_pdu(remdesk, s, header, &result)))
- WLog_ERR(TAG, "remdesk_recv_ctl_result_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "remdesk_recv_ctl_result_pdu failed with error %" PRIu32 "", error);
break;
@@ -567,7 +561,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
case REMDESK_CTL_SERVER_ANNOUNCE:
if ((error = remdesk_recv_ctl_server_announce_pdu(remdesk, s, header)))
- WLog_ERR(TAG, "remdesk_recv_ctl_server_announce_pdu failed with error %"PRIu32"",
+ WLog_ERR(TAG, "remdesk_recv_ctl_server_announce_pdu failed with error %" PRIu32 "",
error);
break;
@@ -578,7 +572,8 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
case REMDESK_CTL_VERSIONINFO:
if ((error = remdesk_recv_ctl_version_info_pdu(remdesk, s, header)))
{
- WLog_ERR(TAG, "remdesk_recv_ctl_version_info_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "remdesk_recv_ctl_version_info_pdu failed with error %" PRIu32 "",
+ error);
break;
}
@@ -586,20 +581,24 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
{
if ((error = remdesk_send_ctl_version_info_pdu(remdesk)))
{
- WLog_ERR(TAG, "remdesk_send_ctl_version_info_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "remdesk_send_ctl_version_info_pdu failed with error %" PRIu32 "",
+ error);
break;
}
if ((error = remdesk_send_ctl_authenticate_pdu(remdesk)))
{
- WLog_ERR(TAG, "remdesk_send_ctl_authenticate_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "remdesk_send_ctl_authenticate_pdu failed with error %" PRIu32 "",
+ error);
break;
}
if ((error = remdesk_send_ctl_remote_control_desktop_pdu(remdesk)))
{
- WLog_ERR(TAG,
- "remdesk_send_ctl_remote_control_desktop_pdu failed with error %"PRIu32"", error);
+ WLog_ERR(
+ TAG,
+ "remdesk_send_ctl_remote_control_desktop_pdu failed with error %" PRIu32 "",
+ error);
break;
}
}
@@ -607,14 +606,16 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
{
if ((error = remdesk_send_ctl_expert_on_vista_pdu(remdesk)))
{
- WLog_ERR(TAG, "remdesk_send_ctl_expert_on_vista_pdu failed with error %"PRIu32"",
+ WLog_ERR(TAG,
+ "remdesk_send_ctl_expert_on_vista_pdu failed with error %" PRIu32 "",
error);
break;
}
if ((error = remdesk_send_ctl_verify_password_pdu(remdesk)))
{
- WLog_ERR(TAG, "remdesk_send_ctl_verify_password_pdu failed with error %"PRIu32"",
+ WLog_ERR(TAG,
+ "remdesk_send_ctl_verify_password_pdu failed with error %" PRIu32 "",
error);
break;
}
@@ -641,7 +642,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
break;
default:
- WLog_ERR(TAG, "unknown msgType: %"PRIu32"", msgType);
+ WLog_ERR(TAG, "unknown msgType: %" PRIu32 "", msgType);
error = ERROR_INVALID_DATA;
break;
}
@@ -665,7 +666,7 @@ static UINT remdesk_process_receive(remdeskPlugin* remdesk, wStream* s)
if ((status = remdesk_read_channel_header(s, &header)))
{
- WLog_ERR(TAG, "remdesk_read_channel_header failed with error %"PRIu32"", status);
+ WLog_ERR(TAG, "remdesk_read_channel_header failed with error %" PRIu32 "", status);
return status;
}
@@ -697,17 +698,17 @@ static UINT remdesk_process_receive(remdeskPlugin* remdesk, wStream* s)
static void remdesk_process_connect(remdeskPlugin* remdesk)
{
- remdesk->settings = (rdpSettings*) remdesk->channelEntryPoints.pExtendedData;
+ remdesk->settings = (rdpSettings*)remdesk->channelEntryPoints.pExtendedData;
}
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
- void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk, void* pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
wStream* data_in;
@@ -732,7 +733,7 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
data_in = remdesk->data_in;
- if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
+ if (!Stream_EnsureRemainingCapacity(data_in, (int)dataLength))
{
WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!");
return CHANNEL_RC_NO_MEMORY;
@@ -744,7 +745,7 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
{
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
{
- WLog_ERR(TAG, "read error");
+ WLog_ERR(TAG, "read error");
return ERROR_INTERNAL_ERROR;
}
@@ -752,7 +753,7 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
- if (!MessageQueue_Post(remdesk->queue, NULL, 0, (void*) data_in, NULL))
+ if (!MessageQueue_Post(remdesk->queue, NULL, 0, (void*)data_in, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -763,25 +764,28 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
}
static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
- UINT event,
- LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
+ UINT event, LPVOID pData,
+ UINT32 dataLength, UINT32 totalLength,
+ UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
- remdeskPlugin* remdesk = (remdeskPlugin*) lpUserParam;
+ remdeskPlugin* remdesk = (remdeskPlugin*)lpUserParam;
if (!remdesk || (remdesk->OpenHandle != openHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
- if ((error = remdesk_virtual_channel_event_data_received(remdesk, pData,
- dataLength, totalLength, dataFlags)))
+ if ((error = remdesk_virtual_channel_event_data_received(remdesk, pData, dataLength,
+ totalLength, dataFlags)))
WLog_ERR(TAG,
- "remdesk_virtual_channel_event_data_received failed with error %"PRIu32"!", error);
+ "remdesk_virtual_channel_event_data_received failed with error %" PRIu32
+ "!",
+ error);
break;
@@ -791,13 +795,13 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam,
wStream* s = (wStream*)lpUserParam;
Stream_Free(s, TRUE);
}
- break;
+ break;
case CHANNEL_EVENT_USER:
break;
default:
- WLog_ERR(TAG, "unhandled event %"PRIu32"!", event);
+ WLog_ERR(TAG, "unhandled event %" PRIu32 "!", event);
error = ERROR_INTERNAL_ERROR;
}
@@ -810,7 +814,7 @@ static DWORD WINAPI remdesk_virtual_channel_client_thread(LPVOID arg)
{
wStream* data;
wMessage message;
- remdeskPlugin* remdesk = (remdeskPlugin*) arg;
+ remdeskPlugin* remdesk = (remdeskPlugin*)arg;
UINT error = CHANNEL_RC_OK;
remdesk_process_connect(remdesk);
@@ -835,11 +839,11 @@ static DWORD WINAPI remdesk_virtual_channel_client_thread(LPVOID arg)
if (message.id == 0)
{
- data = (wStream*) message.wParam;
+ data = (wStream*)message.wParam;
if ((error = remdesk_process_receive(remdesk, data)))
{
- WLog_ERR(TAG, "remdesk_process_receive failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_process_receive failed with error %" PRIu32 "!", error);
break;
}
}
@@ -858,18 +862,18 @@ static DWORD WINAPI remdesk_virtual_channel_client_thread(LPVOID arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk,
- LPVOID pData, UINT32 dataLength)
+static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVOID pData,
+ UINT32 dataLength)
{
UINT32 status;
UINT error;
- status = remdesk->channelEntryPoints.pVirtualChannelOpenEx(remdesk->InitHandle,
- &remdesk->OpenHandle, remdesk->channelDef.name,
- remdesk_virtual_channel_open_event_ex);
+ status = remdesk->channelEntryPoints.pVirtualChannelOpenEx(
+ remdesk->InitHandle, &remdesk->OpenHandle, remdesk->channelDef.name,
+ remdesk_virtual_channel_open_event_ex);
if (status != CHANNEL_RC_OK)
{
- WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08"PRIX32"]",
+ WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]",
WTSErrorToString(status), status);
return status;
}
@@ -883,9 +887,8 @@ static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk,
goto error_out;
}
- remdesk->thread = CreateThread(NULL, 0,
- remdesk_virtual_channel_client_thread, (void*) remdesk,
- 0, NULL);
+ remdesk->thread =
+ CreateThread(NULL, 0, remdesk_virtual_channel_client_thread, (void*)remdesk, 0, NULL);
if (!remdesk->thread)
{
@@ -913,11 +916,11 @@ static UINT remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk)
if (remdesk->OpenHandle == 0)
return CHANNEL_RC_OK;
- if (MessageQueue_PostQuit(remdesk->queue, 0)
- && (WaitForSingleObject(remdesk->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(remdesk->queue, 0) &&
+ (WaitForSingleObject(remdesk->thread, INFINITE) == WAIT_FAILED))
{
rc = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", rc);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", rc);
return rc;
}
@@ -925,12 +928,13 @@ static UINT remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk)
CloseHandle(remdesk->thread);
remdesk->queue = NULL;
remdesk->thread = NULL;
- rc = remdesk->channelEntryPoints.pVirtualChannelCloseEx(remdesk->InitHandle, remdesk->OpenHandle);
+ rc = remdesk->channelEntryPoints.pVirtualChannelCloseEx(remdesk->InitHandle,
+ remdesk->OpenHandle);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
}
remdesk->OpenHandle = 0;
@@ -952,24 +956,24 @@ static void remdesk_virtual_channel_event_terminated(remdeskPlugin* remdesk)
}
static VOID VCAPITYPE remdesk_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
- UINT event, LPVOID pData,
- UINT dataLength)
+ UINT event, LPVOID pData,
+ UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
- remdeskPlugin* remdesk = (remdeskPlugin*) lpUserParam;
+ remdeskPlugin* remdesk = (remdeskPlugin*)lpUserParam;
if (!remdesk || (remdesk->InitHandle != pInitHandle))
{
- WLog_ERR(TAG, "error no match");
+ WLog_ERR(TAG, "error no match");
return;
}
switch (event)
{
case CHANNEL_EVENT_CONNECTED:
- if ((error = remdesk_virtual_channel_event_connected(remdesk, pData,
- dataLength)))
- WLog_ERR(TAG, "remdesk_virtual_channel_event_connected failed with error %"PRIu32"",
+ if ((error = remdesk_virtual_channel_event_connected(remdesk, pData, dataLength)))
+ WLog_ERR(TAG,
+ "remdesk_virtual_channel_event_connected failed with error %" PRIu32 "",
error);
break;
@@ -977,7 +981,8 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event_ex(LPVOID lpUserParam,
case CHANNEL_EVENT_DISCONNECTED:
if ((error = remdesk_virtual_channel_event_disconnected(remdesk)))
WLog_ERR(TAG,
- "remdesk_virtual_channel_event_disconnected failed with error %"PRIu32"", error);
+ "remdesk_virtual_channel_event_disconnected failed with error %" PRIu32 "",
+ error);
break;
@@ -997,7 +1002,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event_ex(LPVOID lpUserParam,
}
/* remdesk is always built-in */
-#define VirtualChannelEntryEx remdesk_VirtualChannelEntryEx
+#define VirtualChannelEntryEx remdesk_VirtualChannelEntryEx
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
@@ -1011,7 +1016,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- remdesk = (remdeskPlugin*) calloc(1, sizeof(remdeskPlugin));
+ remdesk = (remdeskPlugin*)calloc(1, sizeof(remdeskPlugin));
if (!remdesk)
{
@@ -1019,19 +1024,16 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
return FALSE;
}
- remdesk->channelDef.options =
- CHANNEL_OPTION_INITIALIZED |
- CHANNEL_OPTION_ENCRYPT_RDP |
- CHANNEL_OPTION_COMPRESS_RDP |
- CHANNEL_OPTION_SHOW_PROTOCOL;
+ remdesk->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
+ CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL;
sprintf_s(remdesk->channelDef.name, ARRAYSIZE(remdesk->channelDef.name), "remdesk");
remdesk->Version = 2;
- pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
+ pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*)pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{
- context = (RemdeskClientContext*) calloc(1, sizeof(RemdeskClientContext));
+ context = (RemdeskClientContext*)calloc(1, sizeof(RemdeskClientContext));
if (!context)
{
@@ -1039,7 +1041,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
goto error_out;
}
- context->handle = (void*) remdesk;
+ context->handle = (void*)remdesk;
remdesk->context = context;
remdesk->rdpcontext = pEntryPointsEx->context;
}
@@ -1047,14 +1049,14 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CopyMemory(&(remdesk->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
remdesk->InitHandle = pInitHandle;
- rc = remdesk->channelEntryPoints.pVirtualChannelInitEx(remdesk, context, pInitHandle,
- &remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
- remdesk_virtual_channel_init_event_ex);
+ rc = remdesk->channelEntryPoints.pVirtualChannelInitEx(
+ remdesk, context, pInitHandle, &remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
+ remdesk_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
- WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08"PRIX32"]",
- WTSErrorToString(rc), rc);
+ WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08" PRIX32 "]", WTSErrorToString(rc),
+ rc);
goto error_out;
}
diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c
index 04781773e..aeaa332e5 100644
--- a/channels/remdesk/server/remdesk_main.c
+++ b/channels/remdesk/server/remdesk_main.c
@@ -34,13 +34,12 @@
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_virtual_channel_write(RemdeskServerContext* context,
- wStream* s)
+static UINT remdesk_virtual_channel_write(RemdeskServerContext* context, wStream* s)
{
BOOL status;
ULONG BytesWritten = 0;
- status = WTSVirtualChannelWrite(context->priv->ChannelHandle,
- (PCHAR) Stream_Buffer(s), Stream_Length(s), &BytesWritten);
+ status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Buffer(s),
+ Stream_Length(s), &BytesWritten);
return (status) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
}
@@ -49,8 +48,7 @@ static UINT remdesk_virtual_channel_write(RemdeskServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_read_channel_header(wStream* s,
- REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_read_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header)
{
int status;
UINT32 ChannelNameLen;
@@ -62,7 +60,7 @@ static UINT remdesk_read_channel_header(wStream* s,
return CHANNEL_RC_NO_MEMORY;
}
- Stream_Read_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
+ Stream_Read_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
Stream_Read_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
if (ChannelNameLen > 64)
@@ -84,9 +82,9 @@ static UINT remdesk_read_channel_header(wStream* s,
}
ZeroMemory(header->ChannelName, sizeof(header->ChannelName));
- pChannelName = (char*) header->ChannelName;
- status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
- ChannelNameLen / 2, &pChannelName, 32, NULL, NULL);
+ pChannelName = (char*)header->ChannelName;
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)Stream_Pointer(s), ChannelNameLen / 2,
+ &pChannelName, 32, NULL, NULL);
Stream_Seek(s, ChannelNameLen);
if (status <= 0)
@@ -103,8 +101,7 @@ static UINT remdesk_read_channel_header(wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_write_channel_header(wStream* s,
- REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_write_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header)
{
int index;
UINT32 ChannelNameLen;
@@ -113,12 +110,12 @@ static UINT remdesk_write_channel_header(wStream* s,
for (index = 0; index < 32; index++)
{
- ChannelNameW[index] = (WCHAR) header->ChannelName[index];
+ ChannelNameW[index] = (WCHAR)header->ChannelName[index];
}
ChannelNameLen = (strnlen(header->ChannelName, sizeof(header->ChannelName)) + 1) * 2;
- Stream_Write_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
- Stream_Write_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
+ Stream_Write_UINT32(s, ChannelNameLen); /* ChannelNameLen (4 bytes) */
+ Stream_Write_UINT32(s, header->DataLength); /* DataLen (4 bytes) */
Stream_Write(s, ChannelNameW, ChannelNameLen); /* ChannelName (variable) */
return CHANNEL_RC_OK;
}
@@ -132,10 +129,9 @@ static UINT remdesk_write_ctl_header(wStream* s, REMDESK_CTL_HEADER* ctlHeader)
{
UINT error;
- if ((error = remdesk_write_channel_header(s,
- (REMDESK_CHANNEL_HEADER*) ctlHeader)))
+ if ((error = remdesk_write_channel_header(s, (REMDESK_CHANNEL_HEADER*)ctlHeader)))
{
- WLog_ERR(TAG, "remdesk_write_channel_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_write_channel_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -148,8 +144,8 @@ static UINT remdesk_write_ctl_header(wStream* s, REMDESK_CTL_HEADER* ctlHeader)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
- UINT32 msgType, UINT32 msgSize)
+static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader, UINT32 msgType,
+ UINT32 msgSize)
{
ctlHeader->msgType = msgType;
sprintf_s(ctlHeader->ChannelName, ARRAYSIZE(ctlHeader->ChannelName), REMDESK_CHANNEL_CTL_NAME);
@@ -162,18 +158,16 @@ static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_send_ctl_result_pdu(RemdeskServerContext* context,
- UINT32 result)
+static UINT remdesk_send_ctl_result_pdu(RemdeskServerContext* context, UINT32 result)
{
wStream* s;
REMDESK_CTL_RESULT_PDU pdu;
UINT error;
pdu.result = result;
- if ((error = remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_RESULT,
- 4)))
+ if ((error = remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_RESULT, 4)))
{
- WLog_ERR(TAG, "remdesk_prepare_ctl_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_prepare_ctl_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -187,7 +181,7 @@ static UINT remdesk_send_ctl_result_pdu(RemdeskServerContext* context,
if ((error = remdesk_write_ctl_header(s, &(pdu.ctlHeader))))
{
- WLog_ERR(TAG, "remdesk_write_ctl_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_write_ctl_header failed with error %" PRIu32 "!", error);
goto out;
}
@@ -195,7 +189,7 @@ static UINT remdesk_send_ctl_result_pdu(RemdeskServerContext* context,
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(context, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
out:
Stream_Free(s, TRUE);
@@ -213,10 +207,9 @@ static UINT remdesk_send_ctl_version_info_pdu(RemdeskServerContext* context)
REMDESK_CTL_VERSION_INFO_PDU pdu;
UINT error;
- if ((error = remdesk_prepare_ctl_header(&(pdu.ctlHeader),
- REMDESK_CTL_VERSIONINFO, 8)))
+ if ((error = remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_VERSIONINFO, 8)))
{
- WLog_ERR(TAG, "remdesk_prepare_ctl_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_prepare_ctl_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -232,7 +225,7 @@ static UINT remdesk_send_ctl_version_info_pdu(RemdeskServerContext* context)
if ((error = remdesk_write_ctl_header(s, &(pdu.ctlHeader))))
{
- WLog_ERR(TAG, "remdesk_write_ctl_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_write_ctl_header failed with error %" PRIu32 "!", error);
goto out;
}
@@ -241,7 +234,7 @@ static UINT remdesk_send_ctl_version_info_pdu(RemdeskServerContext* context)
Stream_SealLength(s);
if ((error = remdesk_virtual_channel_write(context, s)))
- WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_virtual_channel_write failed with error %" PRIu32 "!", error);
out:
Stream_Free(s, TRUE);
@@ -253,8 +246,8 @@ out:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_version_info_pdu(RemdeskServerContext* context,
- wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_version_info_pdu(RemdeskServerContext* context, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
UINT32 versionMajor;
UINT32 versionMinor;
@@ -275,8 +268,8 @@ static UINT remdesk_recv_ctl_version_info_pdu(RemdeskServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_remote_control_desktop_pdu(
- RemdeskServerContext* context, wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* context, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
int status;
int cchStringW;
@@ -287,7 +280,7 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;
UINT error;
msgLength = header->DataLength - 4;
- pStringW = (WCHAR*) Stream_Pointer(s);
+ pStringW = (WCHAR*)Stream_Pointer(s);
raConnectionStringW = pStringW;
cchStringW = 0;
@@ -303,8 +296,8 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(
cchStringW++;
cbRaConnectionStringW = cchStringW * 2;
pdu.raConnectionString = NULL;
- status = ConvertFromUnicode(CP_UTF8, 0, raConnectionStringW,
- cbRaConnectionStringW / 2, &pdu.raConnectionString, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, raConnectionStringW, cbRaConnectionStringW / 2,
+ &pdu.raConnectionString, 0, NULL, NULL);
if (status <= 0)
{
@@ -312,12 +305,11 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(
return ERROR_INTERNAL_ERROR;
}
- WLog_INFO(TAG, "RaConnectionString: %s",
- pdu.raConnectionString);
+ WLog_INFO(TAG, "RaConnectionString: %s", pdu.raConnectionString);
free(pdu.raConnectionString);
if ((error = remdesk_send_ctl_result_pdu(context, 0)))
- WLog_ERR(TAG, "remdesk_send_ctl_result_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_send_ctl_result_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -327,8 +319,8 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
- wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
int status;
int cchStringW;
@@ -340,7 +332,7 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
WCHAR* raConnectionStringW = NULL;
REMDESK_CTL_AUTHENTICATE_PDU pdu;
msgLength = header->DataLength - 4;
- pStringW = (WCHAR*) Stream_Pointer(s);
+ pStringW = (WCHAR*)Stream_Pointer(s);
raConnectionStringW = pStringW;
cchStringW = 0;
@@ -371,8 +363,8 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
cchStringW++;
cbExpertBlobW = cchStringW * 2;
pdu.raConnectionString = NULL;
- status = ConvertFromUnicode(CP_UTF8, 0, raConnectionStringW,
- cbRaConnectionStringW / 2, &pdu.raConnectionString, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, raConnectionStringW, cbRaConnectionStringW / 2,
+ &pdu.raConnectionString, 0, NULL, NULL);
if (status <= 0)
{
@@ -381,8 +373,8 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
}
pdu.expertBlob = NULL;
- status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW,
- cbExpertBlobW / 2, &pdu.expertBlob, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW, cbExpertBlobW / 2, &pdu.expertBlob, 0,
+ NULL, NULL);
if (status <= 0)
{
@@ -391,8 +383,7 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
return ERROR_INTERNAL_ERROR;
}
- WLog_INFO(TAG, "RaConnectionString: %s ExpertBlob: %s",
- pdu.raConnectionString, pdu.expertBlob);
+ WLog_INFO(TAG, "RaConnectionString: %s ExpertBlob: %s", pdu.raConnectionString, pdu.expertBlob);
free(pdu.raConnectionString);
free(pdu.expertBlob);
return CHANNEL_RC_OK;
@@ -403,8 +394,8 @@ static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context,
- wStream* s, REMDESK_CHANNEL_HEADER* header)
+static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context, wStream* s,
+ REMDESK_CHANNEL_HEADER* header)
{
int status;
int cbExpertBlobW = 0;
@@ -419,10 +410,10 @@ static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context,
}
pdu.expertBlob = NULL;
- expertBlobW = (WCHAR*) Stream_Pointer(s);
+ expertBlobW = (WCHAR*)Stream_Pointer(s);
cbExpertBlobW = header->DataLength - 4;
- status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW, cbExpertBlobW / 2,
- &pdu.expertBlob, 0, NULL, NULL);
+ status = ConvertFromUnicode(CP_UTF8, 0, expertBlobW, cbExpertBlobW / 2, &pdu.expertBlob, 0,
+ NULL, NULL);
if (status <= 0)
{
@@ -433,7 +424,7 @@ static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context,
WLog_INFO(TAG, "ExpertBlob: %s", pdu.expertBlob);
if ((error = remdesk_send_ctl_result_pdu(context, 0)))
- WLog_ERR(TAG, "remdesk_send_ctl_result_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_send_ctl_result_pdu failed with error %" PRIu32 "!", error);
return error;
}
@@ -456,7 +447,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
}
Stream_Read_UINT32(s, msgType); /* msgType (4 bytes) */
- WLog_INFO(TAG, "msgType: %"PRIu32"", msgType);
+ WLog_INFO(TAG, "msgType: %" PRIu32 "", msgType);
switch (msgType)
{
@@ -464,7 +455,9 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
if ((error = remdesk_recv_ctl_remote_control_desktop_pdu(context, s, header)))
{
WLog_ERR(TAG,
- "remdesk_recv_ctl_remote_control_desktop_pdu failed with error %"PRIu32"!", error);
+ "remdesk_recv_ctl_remote_control_desktop_pdu failed with error %" PRIu32
+ "!",
+ error);
return error;
}
@@ -473,7 +466,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
case REMDESK_CTL_AUTHENTICATE:
if ((error = remdesk_recv_ctl_authenticate_pdu(context, s, header)))
{
- WLog_ERR(TAG, "remdesk_recv_ctl_authenticate_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "remdesk_recv_ctl_authenticate_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -486,7 +479,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
case REMDESK_CTL_VERSIONINFO:
if ((error = remdesk_recv_ctl_version_info_pdu(context, s, header)))
{
- WLog_ERR(TAG, "remdesk_recv_ctl_version_info_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "remdesk_recv_ctl_version_info_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -499,7 +492,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
case REMDESK_CTL_VERIFY_PASSWORD:
if ((error = remdesk_recv_ctl_verify_password_pdu(context, s, header)))
{
- WLog_ERR(TAG, "remdesk_recv_ctl_verify_password_pdu failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "remdesk_recv_ctl_verify_password_pdu failed with error %" PRIu32 "!",
error);
return error;
}
@@ -519,7 +512,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
break;
default:
- WLog_ERR(TAG, "remdesk_recv_control_pdu: unknown msgType: %"PRIu32"", msgType);
+ WLog_ERR(TAG, "remdesk_recv_control_pdu: unknown msgType: %" PRIu32 "", msgType);
error = ERROR_INVALID_DATA;
break;
}
@@ -532,8 +525,7 @@ static UINT remdesk_recv_ctl_pdu(RemdeskServerContext* context, wStream* s,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT remdesk_server_receive_pdu(RemdeskServerContext* context,
- wStream* s)
+static UINT remdesk_server_receive_pdu(RemdeskServerContext* context, wStream* s)
{
UINT error = CHANNEL_RC_OK;
REMDESK_CHANNEL_HEADER header;
@@ -544,7 +536,7 @@ static UINT remdesk_server_receive_pdu(RemdeskServerContext* context,
if ((error = remdesk_read_channel_header(s, &header)))
{
- WLog_ERR(TAG, "remdesk_read_channel_header failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_read_channel_header failed with error %" PRIu32 "!", error);
return error;
}
@@ -552,7 +544,7 @@ static UINT remdesk_server_receive_pdu(RemdeskServerContext* context,
{
if ((error = remdesk_recv_ctl_pdu(context, s, &header)))
{
- WLog_ERR(TAG, "remdesk_recv_ctl_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_recv_ctl_pdu failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -591,7 +583,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
DWORD BytesReturned;
RemdeskServerContext* context;
UINT error;
- context = (RemdeskServerContext*) arg;
+ context = (RemdeskServerContext*)arg;
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
@@ -604,8 +596,8 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
goto out;
}
- if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle,
- &buffer, &BytesReturned) == TRUE)
+ if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer,
+ &BytesReturned) == TRUE)
{
if (BytesReturned == sizeof(HANDLE))
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
@@ -625,8 +617,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
if ((error = remdesk_send_ctl_version_info_pdu(context)))
{
- WLog_ERR(TAG, "remdesk_send_ctl_version_info_pdu failed with error %"PRIu32"!",
- error);
+ WLog_ERR(TAG, "remdesk_send_ctl_version_info_pdu failed with error %" PRIu32 "!", error);
goto out;
}
@@ -637,7 +628,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "", error);
break;
}
@@ -646,7 +637,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "", error);
break;
}
@@ -655,8 +646,8 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
break;
}
- if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
- (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned))
+ if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
+ Stream_Capacity(s), &BytesReturned))
{
if (BytesReturned)
Stream_Seek(s, BytesReturned);
@@ -673,7 +664,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
if (Stream_GetPosition(s) >= 8)
{
- pHeader = (UINT32*) Stream_Buffer(s);
+ pHeader = (UINT32*)Stream_Buffer(s);
PduLength = pHeader[0] + pHeader[1] + 8;
if (PduLength >= Stream_GetPosition(s))
@@ -683,7 +674,8 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
if ((error = remdesk_server_receive_pdu(context, s)))
{
- WLog_ERR(TAG, "remdesk_server_receive_pdu failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "remdesk_server_receive_pdu failed with error %" PRIu32 "!",
+ error);
break;
}
@@ -696,8 +688,7 @@ static DWORD WINAPI remdesk_server_thread(LPVOID arg)
out:
if (error && context->rdpcontext)
- setChannelError(context->rdpcontext, error,
- "remdesk_server_thread reported an error");
+ setChannelError(context->rdpcontext, error, "remdesk_server_thread reported an error");
ExitThread(error);
return error;
@@ -710,8 +701,8 @@ out:
*/
static UINT remdesk_server_start(RemdeskServerContext* context)
{
- context->priv->ChannelHandle = WTSVirtualChannelOpen(context->vcm,
- WTS_CURRENT_SESSION, "remdesk");
+ context->priv->ChannelHandle =
+ WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "remdesk");
if (!context->priv->ChannelHandle)
{
@@ -725,8 +716,8 @@ static UINT remdesk_server_start(RemdeskServerContext* context)
return ERROR_INTERNAL_ERROR;
}
- if (!(context->priv->Thread = CreateThread(NULL, 0,
- remdesk_server_thread, (void*) context, 0, NULL)))
+ if (!(context->priv->Thread =
+ CreateThread(NULL, 0, remdesk_server_thread, (void*)context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(context->priv->StopEvent);
@@ -750,7 +741,7 @@ static UINT remdesk_server_stop(RemdeskServerContext* context)
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -762,14 +753,14 @@ static UINT remdesk_server_stop(RemdeskServerContext* context)
RemdeskServerContext* remdesk_server_context_new(HANDLE vcm)
{
RemdeskServerContext* context;
- context = (RemdeskServerContext*) calloc(1, sizeof(RemdeskServerContext));
+ context = (RemdeskServerContext*)calloc(1, sizeof(RemdeskServerContext));
if (context)
{
context->vcm = vcm;
context->Start = remdesk_server_start;
context->Stop = remdesk_server_stop;
- context->priv = (RemdeskServerPrivate*) calloc(1, sizeof(RemdeskServerPrivate));
+ context->priv = (RemdeskServerPrivate*)calloc(1, sizeof(RemdeskServerPrivate));
if (!context->priv)
{
diff --git a/channels/remdesk/server/remdesk_main.h b/channels/remdesk/server/remdesk_main.h
index 857376ae5..f47d037ab 100644
--- a/channels/remdesk/server/remdesk_main.h
+++ b/channels/remdesk/server/remdesk_main.h
@@ -39,4 +39,3 @@ struct _remdesk_server_private
};
#endif /* FREERDP_CHANNEL_REMDESK_SERVER_MAIN_H */
-
diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c
index b0a83eccc..cac534c8d 100644
--- a/channels/serial/client/serial_main.c
+++ b/channels/serial/client/serial_main.c
@@ -49,7 +49,7 @@
* CommWriteFile by WriteFile etc.. */
#if defined __linux__ && !defined ANDROID
-#define MAX_IRP_THREADS 5
+#define MAX_IRP_THREADS 5
typedef struct _SERIAL_DEVICE SERIAL_DEVICE;
@@ -81,7 +81,8 @@ struct _IRP_THREAD_DATA
static UINT32 _GetLastErrorToIoStatus(SERIAL_DEVICE* serial)
{
- /* http://msdn.microsoft.com/en-us/library/ff547466%28v=vs.85%29.aspx#generic_status_values_for_serial_device_control_requests */
+ /* http://msdn.microsoft.com/en-us/library/ff547466%28v=vs.85%29.aspx#generic_status_values_for_serial_device_control_requests
+ */
switch (GetLastError())
{
case ERROR_BAD_DEVICE:
@@ -119,8 +120,7 @@ static UINT32 _GetLastErrorToIoStatus(SERIAL_DEVICE* serial)
/* no default */
}
- WLog_Print(serial->log, WLOG_DEBUG, "unexpected last-error: 0x%08"PRIX32"",
- GetLastError());
+ WLog_Print(serial->log, WLOG_DEBUG, "unexpected last-error: 0x%08" PRIX32 "", GetLastError());
return STATUS_UNSUCCESSFUL;
}
@@ -134,19 +134,19 @@ static UINT serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
if (Stream_GetRemainingLength(irp->input) < 32)
return ERROR_INVALID_DATA;
- Stream_Read_UINT32(irp->input, DesiredAccess); /* DesiredAccess (4 bytes) */
- Stream_Seek_UINT64(irp->input); /* AllocationSize (8 bytes) */
- Stream_Seek_UINT32(irp->input); /* FileAttributes (4 bytes) */
- Stream_Read_UINT32(irp->input, SharedAccess); /* SharedAccess (4 bytes) */
- Stream_Read_UINT32(irp->input, CreateDisposition); /* CreateDisposition (4 bytes) */
- Stream_Seek_UINT32(irp->input); /* CreateOptions (4 bytes) */
- Stream_Read_UINT32(irp->input, PathLength); /* PathLength (4 bytes) */
+ Stream_Read_UINT32(irp->input, DesiredAccess); /* DesiredAccess (4 bytes) */
+ Stream_Seek_UINT64(irp->input); /* AllocationSize (8 bytes) */
+ Stream_Seek_UINT32(irp->input); /* FileAttributes (4 bytes) */
+ Stream_Read_UINT32(irp->input, SharedAccess); /* SharedAccess (4 bytes) */
+ Stream_Read_UINT32(irp->input, CreateDisposition); /* CreateDisposition (4 bytes) */
+ Stream_Seek_UINT32(irp->input); /* CreateOptions (4 bytes) */
+ Stream_Read_UINT32(irp->input, PathLength); /* PathLength (4 bytes) */
if (Stream_GetRemainingLength(irp->input) < PathLength)
return ERROR_INVALID_DATA;
- Stream_Seek(irp->input, PathLength); /* Path (variable) */
- assert(PathLength == 0); /* MS-RDPESP 2.2.2.2 */
+ Stream_Seek(irp->input, PathLength); /* Path (variable) */
+ assert(PathLength == 0); /* MS-RDPESP 2.2.2.2 */
#ifndef _WIN32
/* Windows 2012 server sends on a first call :
* DesiredAccess = 0x00100080: SYNCHRONIZE | FILE_READ_ATTRIBUTES
@@ -154,9 +154,9 @@ static UINT serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
* CreateDisposition = 0x00000001: CREATE_NEW
*
* then Windows 2012 sends :
- * DesiredAccess = 0x00120089: SYNCHRONIZE | READ_CONTROL | FILE_READ_ATTRIBUTES | FILE_READ_EA | FILE_READ_DATA
- * SharedAccess = 0x00000007: FILE_SHARE_DELETE | FILE_SHARE_WRITE | FILE_SHARE_READ
- * CreateDisposition = 0x00000001: CREATE_NEW
+ * DesiredAccess = 0x00120089: SYNCHRONIZE | READ_CONTROL | FILE_READ_ATTRIBUTES |
+ * FILE_READ_EA | FILE_READ_DATA SharedAccess = 0x00000007: FILE_SHARE_DELETE |
+ * FILE_SHARE_WRITE | FILE_SHARE_READ CreateDisposition = 0x00000001: CREATE_NEW
*
* assert(DesiredAccess == (GENERIC_READ | GENERIC_WRITE));
* assert(SharedAccess == 0);
@@ -164,24 +164,22 @@ static UINT serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
*
*/
WLog_Print(serial->log, WLOG_DEBUG,
- "DesiredAccess: 0x%"PRIX32", SharedAccess: 0x%"PRIX32", CreateDisposition: 0x%"PRIX32"",
+ "DesiredAccess: 0x%" PRIX32 ", SharedAccess: 0x%" PRIX32
+ ", CreateDisposition: 0x%" PRIX32 "",
DesiredAccess, SharedAccess, CreateDisposition);
/* FIXME: As of today only the flags below are supported by CommCreateFileA: */
- DesiredAccess = GENERIC_READ | GENERIC_WRITE;
- SharedAccess = 0;
+ DesiredAccess = GENERIC_READ | GENERIC_WRITE;
+ SharedAccess = 0;
CreateDisposition = OPEN_EXISTING;
#endif
- serial->hComm = CreateFile(serial->device.name,
- DesiredAccess,
- SharedAccess,
- NULL, /* SecurityAttributes */
- CreateDisposition,
- 0, /* FlagsAndAttributes */
- NULL); /* TemplateFile */
+ serial->hComm =
+ CreateFile(serial->device.name, DesiredAccess, SharedAccess, NULL, /* SecurityAttributes */
+ CreateDisposition, 0, /* FlagsAndAttributes */
+ NULL); /* TemplateFile */
if (!serial->hComm || (serial->hComm == INVALID_HANDLE_VALUE))
{
- WLog_Print(serial->log, WLOG_WARN, "CreateFile failure: %s last-error: 0x%08"PRIX32"",
+ WLog_Print(serial->log, WLOG_WARN, "CreateFile failure: %s last-error: 0x%08" PRIX32 "",
serial->device.name, GetLastError());
irp->IoStatus = STATUS_UNSUCCESSFUL;
goto error_handle;
@@ -200,11 +198,11 @@ static UINT serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
assert(irp->FileId == 0);
irp->FileId = irp->devman->id_sequence++; /* FIXME: why not ((WINPR_COMM*)hComm)->fd? */
irp->IoStatus = STATUS_SUCCESS;
- WLog_Print(serial->log, WLOG_DEBUG, "%s (DeviceId: %"PRIu32", FileId: %"PRIu32") created.",
+ WLog_Print(serial->log, WLOG_DEBUG, "%s (DeviceId: %" PRIu32 ", FileId: %" PRIu32 ") created.",
serial->device.name, irp->device->id, irp->FileId);
error_handle:
- Stream_Write_UINT32(irp->output, irp->FileId); /* FileId (4 bytes) */
- Stream_Write_UINT8(irp->output, 0); /* Information (1 byte) */
+ Stream_Write_UINT32(irp->output, irp->FileId); /* FileId (4 bytes) */
+ Stream_Write_UINT8(irp->output, 0); /* Information (1 byte) */
return CHANNEL_RC_OK;
}
@@ -217,13 +215,13 @@ static UINT serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp)
if (!CloseHandle(serial->hComm))
{
- WLog_Print(serial->log, WLOG_WARN, "CloseHandle failure: %s (%"PRIu32") closed.",
+ WLog_Print(serial->log, WLOG_WARN, "CloseHandle failure: %s (%" PRIu32 ") closed.",
serial->device.name, irp->device->id);
irp->IoStatus = STATUS_UNSUCCESSFUL;
goto error_handle;
}
- WLog_Print(serial->log, WLOG_DEBUG, "%s (DeviceId: %"PRIu32", FileId: %"PRIu32") closed.",
+ WLog_Print(serial->log, WLOG_DEBUG, "%s (DeviceId: %" PRIu32 ", FileId: %" PRIu32 ") closed.",
serial->device.name, irp->device->id, irp->FileId);
serial->hComm = NULL;
irp->IoStatus = STATUS_SUCCESS;
@@ -249,7 +247,7 @@ static UINT serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
Stream_Read_UINT32(irp->input, Length); /* Length (4 bytes) */
Stream_Read_UINT64(irp->input, Offset); /* Offset (8 bytes) */
- Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
+ Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
buffer = (BYTE*)calloc(Length, sizeof(BYTE));
if (buffer == NULL)
@@ -261,7 +259,7 @@ static UINT serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
/* MS-RDPESP 3.2.5.1.4: If the Offset field is not set to 0, the value MUST be ignored
* assert(Offset == 0);
*/
- WLog_Print(serial->log, WLOG_DEBUG, "reading %"PRIu32" bytes from %s", Length,
+ WLog_Print(serial->log, WLOG_DEBUG, "reading %" PRIu32 " bytes from %s", Length,
serial->device.name);
/* FIXME: CommReadFile to be replaced by ReadFile */
@@ -272,12 +270,12 @@ static UINT serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
else
{
WLog_Print(serial->log, WLOG_DEBUG,
- "read failure to %s, nbRead=%"PRIu32", last-error: 0x%08"PRIX32"", serial->device.name,
- nbRead, GetLastError());
+ "read failure to %s, nbRead=%" PRIu32 ", last-error: 0x%08" PRIX32 "",
+ serial->device.name, nbRead, GetLastError());
irp->IoStatus = _GetLastErrorToIoStatus(serial);
}
- WLog_Print(serial->log, WLOG_DEBUG, "%"PRIu32" bytes read from %s", nbRead,
+ WLog_Print(serial->log, WLOG_DEBUG, "%" PRIu32 " bytes read from %s", nbRead,
serial->device.name);
error_handle:
Stream_Write_UINT32(irp->output, nbRead); /* Length (4 bytes) */
@@ -309,38 +307,36 @@ static UINT serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
Stream_Read_UINT32(irp->input, Length); /* Length (4 bytes) */
Stream_Read_UINT64(irp->input, Offset); /* Offset (8 bytes) */
- Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
+ Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
/* MS-RDPESP 3.2.5.1.5: The Offset field is ignored
* assert(Offset == 0);
*
* Using a serial printer, noticed though this field could be
* set.
*/
- WLog_Print(serial->log, WLOG_DEBUG, "writing %"PRIu32" bytes to %s", Length,
+ WLog_Print(serial->log, WLOG_DEBUG, "writing %" PRIu32 " bytes to %s", Length,
serial->device.name);
/* FIXME: CommWriteFile to be replaced by WriteFile */
- if (CommWriteFile(serial->hComm, Stream_Pointer(irp->input), Length, &nbWritten,
- NULL))
+ if (CommWriteFile(serial->hComm, Stream_Pointer(irp->input), Length, &nbWritten, NULL))
{
irp->IoStatus = STATUS_SUCCESS;
}
else
{
WLog_Print(serial->log, WLOG_DEBUG,
- "write failure to %s, nbWritten=%"PRIu32", last-error: 0x%08"PRIX32"", serial->device.name,
- nbWritten, GetLastError());
+ "write failure to %s, nbWritten=%" PRIu32 ", last-error: 0x%08" PRIX32 "",
+ serial->device.name, nbWritten, GetLastError());
irp->IoStatus = _GetLastErrorToIoStatus(serial);
}
- WLog_Print(serial->log, WLOG_DEBUG, "%"PRIu32" bytes written to %s", nbWritten,
+ WLog_Print(serial->log, WLOG_DEBUG, "%" PRIu32 " bytes written to %s", nbWritten,
serial->device.name);
Stream_Write_UINT32(irp->output, nbWritten); /* Length (4 bytes) */
- Stream_Write_UINT8(irp->output, 0); /* Padding (1 byte) */
+ Stream_Write_UINT8(irp->output, 0); /* Padding (1 byte) */
return CHANNEL_RC_OK;
}
-
/**
* Function description
*
@@ -350,18 +346,18 @@ static UINT serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
{
UINT32 IoControlCode;
UINT32 InputBufferLength;
- BYTE* InputBuffer = NULL;
+ BYTE* InputBuffer = NULL;
UINT32 OutputBufferLength;
- BYTE* OutputBuffer = NULL;
- DWORD BytesReturned = 0;
+ BYTE* OutputBuffer = NULL;
+ DWORD BytesReturned = 0;
if (Stream_GetRemainingLength(irp->input) < 32)
return ERROR_INVALID_DATA;
Stream_Read_UINT32(irp->input, OutputBufferLength); /* OutputBufferLength (4 bytes) */
- Stream_Read_UINT32(irp->input, InputBufferLength); /* InputBufferLength (4 bytes) */
- Stream_Read_UINT32(irp->input, IoControlCode); /* IoControlCode (4 bytes) */
- Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
+ Stream_Read_UINT32(irp->input, InputBufferLength); /* InputBufferLength (4 bytes) */
+ Stream_Read_UINT32(irp->input, IoControlCode); /* IoControlCode (4 bytes) */
+ Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
if (Stream_GetRemainingLength(irp->input) < InputBufferLength)
return ERROR_INVALID_DATA;
@@ -384,20 +380,23 @@ static UINT serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
Stream_Read(irp->input, InputBuffer, InputBufferLength);
WLog_Print(serial->log, WLOG_DEBUG,
- "CommDeviceIoControl: CompletionId=%"PRIu32", IoControlCode=[0x%"PRIX32"] %s",
+ "CommDeviceIoControl: CompletionId=%" PRIu32 ", IoControlCode=[0x%" PRIX32 "] %s",
irp->CompletionId, IoControlCode, _comm_serial_ioctl_name(IoControlCode));
/* FIXME: CommDeviceIoControl to be replaced by DeviceIoControl() */
- if (CommDeviceIoControl(serial->hComm, IoControlCode, InputBuffer,
- InputBufferLength, OutputBuffer, OutputBufferLength, &BytesReturned, NULL))
+ if (CommDeviceIoControl(serial->hComm, IoControlCode, InputBuffer, InputBufferLength,
+ OutputBuffer, OutputBufferLength, &BytesReturned, NULL))
{
- /* WLog_Print(serial->log, WLOG_DEBUG, "CommDeviceIoControl: CompletionId=%"PRIu32", IoControlCode=[0x%"PRIX32"] %s done", irp->CompletionId, IoControlCode, _comm_serial_ioctl_name(IoControlCode)); */
+ /* WLog_Print(serial->log, WLOG_DEBUG, "CommDeviceIoControl: CompletionId=%"PRIu32",
+ * IoControlCode=[0x%"PRIX32"] %s done", irp->CompletionId, IoControlCode,
+ * _comm_serial_ioctl_name(IoControlCode)); */
irp->IoStatus = STATUS_SUCCESS;
}
else
{
WLog_Print(serial->log, WLOG_DEBUG,
- "CommDeviceIoControl failure: IoControlCode=[0x%"PRIX32"] %s, last-error: 0x%08"PRIX32"",
+ "CommDeviceIoControl failure: IoControlCode=[0x%" PRIX32
+ "] %s, last-error: 0x%08" PRIX32 "",
IoControlCode, _comm_serial_ioctl_name(IoControlCode), GetLastError());
irp->IoStatus = _GetLastErrorToIoStatus(serial);
}
@@ -444,7 +443,7 @@ static UINT serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
{
UINT error = CHANNEL_RC_OK;
WLog_Print(serial->log, WLOG_DEBUG,
- "IRP MajorFunction: 0x%08"PRIX32" MinorFunction: 0x%08"PRIX32"\n",
+ "IRP MajorFunction: 0x%08" PRIX32 " MinorFunction: 0x%08" PRIX32 "\n",
irp->MajorFunction, irp->MinorFunction);
switch (irp->MajorFunction)
@@ -459,7 +458,7 @@ static UINT serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
case IRP_MJ_READ:
if ((error = serial_process_irp_read(serial, irp)))
- WLog_ERR(TAG, "serial_process_irp_read failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "serial_process_irp_read failed with error %" PRIu32 "!", error);
break;
@@ -469,7 +468,7 @@ static UINT serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
case IRP_MJ_DEVICE_CONTROL:
if ((error = serial_process_irp_device_control(serial, irp)))
- WLog_ERR(TAG, "serial_process_irp_device_control failed with error %"PRIu32"!",
+ WLog_ERR(TAG, "serial_process_irp_device_control failed with error %" PRIu32 "!",
error);
break;
@@ -482,7 +481,6 @@ static UINT serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
return error;
}
-
static DWORD WINAPI irp_thread_func(LPVOID arg)
{
IRP_THREAD_DATA* data = (IRP_THREAD_DATA*)arg;
@@ -491,7 +489,7 @@ static DWORD WINAPI irp_thread_func(LPVOID arg)
/* blocks until the end of the request */
if ((error = serial_process_irp(data->serial, data->irp)))
{
- WLog_ERR(TAG, "serial_process_irp failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "serial_process_irp failed with error %" PRIu32 "", error);
goto error_out;
}
@@ -502,8 +500,7 @@ static DWORD WINAPI irp_thread_func(LPVOID arg)
error_out:
if (error && data->serial->rdpcontext)
- setChannelError(data->serial->rdpcontext, error,
- "irp_thread_func reported an error");
+ setChannelError(data->serial->rdpcontext, error, "irp_thread_func reported an error");
/* NB: At this point, the server might already being reusing
* the CompletionId whereas the thread is not yet
@@ -513,7 +510,6 @@ error_out:
return error;
}
-
static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
{
IRP_THREAD_DATA* data = NULL;
@@ -547,13 +543,15 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
DWORD waitResult;
ULONG_PTR id = ids[i];
irpThread = ListDictionary_GetItemValue(serial->IrpThreads, (void*)id);
- /* FIXME: not quite sure a zero timeout is a good thing to check whether a thread is stil alived or not */
+ /* FIXME: not quite sure a zero timeout is a good thing to check whether a thread is
+ * stil alived or not */
waitResult = WaitForSingleObject(irpThread, 0);
if (waitResult == WAIT_OBJECT_0)
{
/* terminating thread */
- /* WLog_Print(serial->log, WLOG_DEBUG, "IRP thread with CompletionId=%"PRIuz" naturally died", id); */
+ /* WLog_Print(serial->log, WLOG_DEBUG, "IRP thread with CompletionId=%"PRIuz"
+ * naturally died", id); */
CloseHandle(irpThread);
ListDictionary_Remove(serial->IrpThreads, (void*)id);
serial->IrpThreadToBeTerminatedCount--;
@@ -562,7 +560,8 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
{
/* unexpected thread state */
WLog_Print(serial->log, WLOG_WARN,
- "WaitForSingleObject, got an unexpected result=0x%"PRIX32"\n", waitResult);
+ "WaitForSingleObject, got an unexpected result=0x%" PRIX32 "\n",
+ waitResult);
assert(FALSE);
}
@@ -571,7 +570,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
if (serial->IrpThreadToBeTerminatedCount > 0)
{
- WLog_Print(serial->log, WLOG_DEBUG, "%"PRIu32" IRP thread(s) not yet terminated",
+ WLog_Print(serial->log, WLOG_DEBUG, "%" PRIu32 " IRP thread(s) not yet terminated",
serial->IrpThreadToBeTerminatedCount);
Sleep(1); /* 1 ms */
}
@@ -597,7 +596,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
{
/* Thread still alived <=> Request still pending */
WLog_Print(serial->log, WLOG_DEBUG,
- "IRP recall: IRP with the CompletionId=%"PRIu32" not yet completed!",
+ "IRP recall: IRP with the CompletionId=%" PRIu32 " not yet completed!",
irp->CompletionId);
assert(FALSE); /* unimplemented */
/* TODO: asserts that previousIrpThread handles well
@@ -623,11 +622,11 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
"Number of IRP threads threshold reached: %d, keep on anyway",
ListDictionary_Count(serial->IrpThreads));
assert(FALSE); /* unimplemented */
- /* TODO: MAX_IRP_THREADS has been thought to avoid a
- * flooding of pending requests. Use
- * WaitForMultipleObjects() when available in winpr
- * for threads.
- */
+ /* TODO: MAX_IRP_THREADS has been thought to avoid a
+ * flooding of pending requests. Use
+ * WaitForMultipleObjects() when available in winpr
+ * for threads.
+ */
}
/* error_handle to be used ... */
@@ -642,12 +641,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
data->serial = serial;
data->irp = irp;
/* data freed by irp_thread_func */
- irpThread = CreateThread(NULL,
- 0,
- irp_thread_func,
- (void*)data,
- 0,
- NULL);
+ irpThread = CreateThread(NULL, 0, irp_thread_func, (void*)data, 0, NULL);
if (irpThread == INVALID_HANDLE_VALUE)
{
@@ -670,7 +664,6 @@ error_handle:
free(data);
}
-
static void terminate_pending_irp_threads(SERIAL_DEVICE* serial)
{
ULONG_PTR* ids;
@@ -692,19 +685,18 @@ static void terminate_pending_irp_threads(SERIAL_DEVICE* serial)
}
CloseHandle(irpThread);
- WLog_Print(serial->log, WLOG_DEBUG, "IRP thread terminated, CompletionId %p", (void*) id);
+ WLog_Print(serial->log, WLOG_DEBUG, "IRP thread terminated, CompletionId %p", (void*)id);
}
ListDictionary_Clear(serial->IrpThreads);
free(ids);
}
-
static DWORD WINAPI serial_thread_func(LPVOID arg)
{
IRP* irp;
wMessage message;
- SERIAL_DEVICE* serial = (SERIAL_DEVICE*) arg;
+ SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg;
UINT error = CHANNEL_RC_OK;
while (1)
@@ -729,21 +721,19 @@ static DWORD WINAPI serial_thread_func(LPVOID arg)
break;
}
- irp = (IRP*) message.wParam;
+ irp = (IRP*)message.wParam;
if (irp)
create_irp_thread(serial, irp);
}
if (error && serial->rdpcontext)
- setChannelError(serial->rdpcontext, error,
- "serial_thread_func reported an error");
+ setChannelError(serial->rdpcontext, error, "serial_thread_func reported an error");
ExitThread(error);
return error;
}
-
/**
* Function description
*
@@ -751,7 +741,7 @@ static DWORD WINAPI serial_thread_func(LPVOID arg)
*/
static UINT serial_irp_request(DEVICE* device, IRP* irp)
{
- SERIAL_DEVICE* serial = (SERIAL_DEVICE*) device;
+ SERIAL_DEVICE* serial = (SERIAL_DEVICE*)device;
assert(irp != NULL);
if (irp == NULL)
@@ -762,7 +752,7 @@ static UINT serial_irp_request(DEVICE* device, IRP* irp)
* write requests.
*/
- if (!MessageQueue_Post(serial->MainIrpQueue, NULL, 0, (void*) irp, NULL))
+ if (!MessageQueue_Post(serial->MainIrpQueue, NULL, 0, (void*)irp, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -771,7 +761,6 @@ static UINT serial_irp_request(DEVICE* device, IRP* irp)
return CHANNEL_RC_OK;
}
-
/**
* Function description
*
@@ -780,14 +769,14 @@ static UINT serial_irp_request(DEVICE* device, IRP* irp)
static UINT serial_free(DEVICE* device)
{
UINT error;
- SERIAL_DEVICE* serial = (SERIAL_DEVICE*) device;
+ SERIAL_DEVICE* serial = (SERIAL_DEVICE*)device;
WLog_Print(serial->log, WLOG_DEBUG, "freeing");
MessageQueue_PostQuit(serial->MainIrpQueue, 0);
if (WaitForSingleObject(serial->MainThread, INFINITE) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -808,9 +797,9 @@ static UINT serial_free(DEVICE* device)
#endif /* __linux__ */
#ifdef BUILTIN_CHANNELS
-#define DeviceServiceEntry serial_DeviceServiceEntry
+#define DeviceServiceEntry serial_DeviceServiceEntry
#else
-#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
+#define DeviceServiceEntry FREERDP_API DeviceServiceEntry
#endif
/**
@@ -829,7 +818,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
SERIAL_DEVICE* serial;
#endif /* __linux__ */
UINT error = CHANNEL_RC_OK;
- device = (RDPDR_SERIAL*) pEntryPoints->device;
+ device = (RDPDR_SERIAL*)pEntryPoints->device;
name = device->Name;
path = device->Path;
driver = device->Driver;
@@ -846,8 +835,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
log = WLog_Get("com.freerdp.channel.serial.client");
WLog_Print(log, WLOG_DEBUG, "initializing");
#ifndef __linux__ /* to be removed */
- WLog_Print(log, WLOG_WARN,
- "Serial ports redirection not supported on this platform.");
+ WLog_Print(log, WLOG_WARN, "Serial ports redirection not supported on this platform.");
return CHANNEL_RC_INITIALIZATION_ERROR;
#else /* __linux __ */
WLog_Print(log, WLOG_DEBUG, "Defining %s as %s", name, path);
@@ -855,11 +843,11 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
if (!DefineCommDevice(name /* eg: COM1 */, path /* eg: /dev/ttyS0 */))
{
DWORD status = GetLastError();
- WLog_ERR(TAG, "DefineCommDevice failed with %08"PRIx32, status);
+ WLog_ERR(TAG, "DefineCommDevice failed with %08" PRIx32, status);
return ERROR_INTERNAL_ERROR;
}
- serial = (SERIAL_DEVICE*) calloc(1, sizeof(SERIAL_DEVICE));
+ serial = (SERIAL_DEVICE*)calloc(1, sizeof(SERIAL_DEVICE));
if (!serial)
{
@@ -921,8 +909,8 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
}
}
- WLog_Print(serial->log, WLOG_DEBUG, "Server's serial driver: %s (id: %d)",
- driver, serial->ServerSerialDriverId);
+ WLog_Print(serial->log, WLOG_DEBUG, "Server's serial driver: %s (id: %d)", driver,
+ serial->ServerSerialDriverId);
/* TODO: implement auto detection of the server's serial driver */
serial->MainIrpQueue = MessageQueue_New(NULL);
@@ -946,19 +934,14 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
serial->IrpThreadToBeTerminatedCount = 0;
InitializeCriticalSection(&serial->TerminatingIrpThreadsLock);
- if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman,
- (DEVICE*) serial)))
+ if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)serial)))
{
- WLog_ERR(TAG, "EntryPoints->RegisterDevice failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "EntryPoints->RegisterDevice failed with error %" PRIu32 "!", error);
goto error_out;
}
- if (!(serial->MainThread = CreateThread(NULL,
- 0,
- serial_thread_func,
- (void*) serial,
- 0,
- NULL)))
+ if (!(serial->MainThread =
+ CreateThread(NULL, 0, serial_thread_func, (void*)serial, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
error = ERROR_INTERNAL_ERROR;
diff --git a/channels/server/channels.h b/channels/server/channels.h
index f054c919f..a6c4791ca 100644
--- a/channels/server/channels.h
+++ b/channels/server/channels.h
@@ -21,6 +21,4 @@
#ifndef FREERDP_CHANNEL_SERVER_CHANNELS_H
#define FREERDP_CHANNEL_SERVER_CHANNELS_H
-
-
#endif /* FREERDP_CHANNEL_SERVER_CHANNELS_H */
diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c
index 134c021f8..fb79fb151 100644
--- a/channels/smartcard/client/smartcard_main.c
+++ b/channels/smartcard/client/smartcard_main.c
@@ -39,7 +39,7 @@
static SMARTCARD_DEVICE* sSmartcard = NULL;
static SMARTCARD_DEVICE* cast_device_from(DEVICE* device, const char* fkt, const char* file,
- int line)
+ int line)
{
if (!device)
{
@@ -49,7 +49,7 @@ static SMARTCARD_DEVICE* cast_device_from(DEVICE* device, const char* fkt, const
if (device->type != RDPDR_DTYP_SMARTCARD)
{
- WLog_ERR(TAG, "%s [%s:%d] Called smartcard channel with invalid device of type %"PRIx32,
+ WLog_ERR(TAG, "%s [%s:%d] Called smartcard channel with invalid device of type %" PRIx32,
fkt, file, line, device->type);
return NULL;
}
@@ -79,7 +79,7 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
if (waitStatus == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -88,7 +88,7 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
if (waitStatus == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
@@ -104,18 +104,18 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
if (message.id == WMQ_QUIT)
break;
- operation = (SMARTCARD_OPERATION*) message.wParam;
+ operation = (SMARTCARD_OPERATION*)message.wParam;
if (operation)
{
if ((status = smartcard_irp_device_control_call(smartcard, operation)))
{
- WLog_ERR(TAG, "smartcard_irp_device_control_call failed with error %"PRIu32"",
+ WLog_ERR(TAG, "smartcard_irp_device_control_call failed with error %" PRIu32 "",
status);
break;
}
- if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) operation->irp))
+ if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*)operation->irp))
{
WLog_ERR(TAG, "Queue_Enqueue failed!");
status = ERROR_INTERNAL_ERROR;
@@ -128,18 +128,16 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
}
if (status && smartcard->rdpcontext)
- setChannelError(smartcard->rdpcontext, error,
- "smartcard_context_thread reported an error");
+ setChannelError(smartcard->rdpcontext, error, "smartcard_context_thread reported an error");
ExitThread(status);
return error;
}
-SMARTCARD_CONTEXT* smartcard_context_new(SMARTCARD_DEVICE* smartcard,
- SCARDCONTEXT hContext)
+SMARTCARD_CONTEXT* smartcard_context_new(SMARTCARD_DEVICE* smartcard, SCARDCONTEXT hContext)
{
SMARTCARD_CONTEXT* pContext;
- pContext = (SMARTCARD_CONTEXT*) calloc(1, sizeof(SMARTCARD_CONTEXT));
+ pContext = (SMARTCARD_CONTEXT*)calloc(1, sizeof(SMARTCARD_CONTEXT));
if (!pContext)
{
@@ -157,9 +155,7 @@ SMARTCARD_CONTEXT* smartcard_context_new(SMARTCARD_DEVICE* smartcard,
goto error_irpqueue;
}
- pContext->thread = CreateThread(NULL, 0,
- smartcard_context_thread,
- pContext, 0, NULL);
+ pContext->thread = CreateThread(NULL, 0, smartcard_context_thread, pContext, 0, NULL);
if (!pContext->thread)
{
@@ -185,9 +181,9 @@ void smartcard_context_free(void* pCtx)
/* cancel blocking calls like SCardGetStatusChange */
SCardCancel(pContext->hContext);
- if (MessageQueue_PostQuit(pContext->IrpQueue, 0)
- && (WaitForSingleObject(pContext->thread, INFINITE) == WAIT_FAILED))
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ if (MessageQueue_PostQuit(pContext->IrpQueue, 0) &&
+ (WaitForSingleObject(pContext->thread, INFINITE) == WAIT_FAILED))
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError());
CloseHandle(pContext->thread);
MessageQueue_Free(pContext->IrpQueue);
@@ -204,8 +200,9 @@ static void smartcard_release_all_contexts(SMARTCARD_DEVICE* smartcard)
/**
* On protocol termination, the following actions are performed:
- * For each context in rgSCardContextList, SCardCancel is called causing all SCardGetStatusChange calls to be processed.
- * After that, SCardReleaseContext is called on each context and the context MUST be removed from rgSCardContextList.
+ * For each context in rgSCardContextList, SCardCancel is called causing all
+ * SCardGetStatusChange calls to be processed. After that, SCardReleaseContext is called on each
+ * context and the context MUST be removed from rgSCardContextList.
*/
/**
@@ -219,8 +216,8 @@ static void smartcard_release_all_contexts(SMARTCARD_DEVICE* smartcard)
for (index = 0; index < keyCount; index++)
{
- pContext = (SMARTCARD_CONTEXT*) ListDictionary_GetItemValue(
- smartcard->rgSCardContextList, (void*) pKeys[index]);
+ pContext = (SMARTCARD_CONTEXT*)ListDictionary_GetItemValue(
+ smartcard->rgSCardContextList, (void*)pKeys[index]);
if (!pContext)
continue;
@@ -247,8 +244,8 @@ static void smartcard_release_all_contexts(SMARTCARD_DEVICE* smartcard)
for (index = 0; index < keyCount; index++)
{
- pContext = (SMARTCARD_CONTEXT*) ListDictionary_Remove(
- smartcard->rgSCardContextList, (void*) pKeys[index]);
+ pContext = (SMARTCARD_CONTEXT*)ListDictionary_Remove(smartcard->rgSCardContextList,
+ (void*)pKeys[index]);
if (!pContext)
continue;
@@ -259,9 +256,10 @@ static void smartcard_release_all_contexts(SMARTCARD_DEVICE* smartcard)
{
SCardReleaseContext(hContext);
- if (MessageQueue_PostQuit(pContext->IrpQueue, 0)
- && (WaitForSingleObject(pContext->thread, INFINITE) == WAIT_FAILED))
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ if (MessageQueue_PostQuit(pContext->IrpQueue, 0) &&
+ (WaitForSingleObject(pContext->thread, INFINITE) == WAIT_FAILED))
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!",
+ GetLastError());
CloseHandle(pContext->thread);
MessageQueue_Free(pContext->IrpQueue);
@@ -319,11 +317,11 @@ static UINT smartcard_free(DEVICE* device)
if (smartcard->IrpQueue)
{
- if (MessageQueue_PostQuit(smartcard->IrpQueue, 0)
- && (WaitForSingleObject(smartcard->thread, INFINITE) == WAIT_FAILED))
+ if (MessageQueue_PostQuit(smartcard->IrpQueue, 0) &&
+ (WaitForSingleObject(smartcard->thread, INFINITE) == WAIT_FAILED))
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -363,7 +361,7 @@ static UINT smartcard_init(DEVICE* device)
static UINT smartcard_complete_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
{
void* key;
- key = (void*)(size_t) irp->CompletionId;
+ key = (void*)(size_t)irp->CompletionId;
ListDictionary_Remove(smartcard->rgOutstandingMessages, key);
return irp->Complete(irp);
}
@@ -385,7 +383,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
BOOL asyncIrp = FALSE;
SMARTCARD_CONTEXT* pContext = NULL;
SMARTCARD_OPERATION* operation = NULL;
- key = (void*)(size_t) irp->CompletionId;
+ key = (void*)(size_t)irp->CompletionId;
if (!ListDictionary_Add(smartcard->rgOutstandingMessages, key, irp))
{
@@ -395,7 +393,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
if (irp->MajorFunction == IRP_MJ_DEVICE_CONTROL)
{
- operation = (SMARTCARD_OPERATION*) calloc(1, sizeof(SMARTCARD_OPERATION));
+ operation = (SMARTCARD_OPERATION*)calloc(1, sizeof(SMARTCARD_OPERATION));
if (!operation)
{
@@ -410,7 +408,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
{
irp->IoStatus = (UINT32)STATUS_UNSUCCESSFUL;
- if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp))
+ if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*)irp))
{
free(operation);
WLog_ERR(TAG, "Queue_Enqueue failed!");
@@ -480,8 +478,8 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
break;
}
- pContext = ListDictionary_GetItemValue(smartcard->rgSCardContextList,
- (void*) operation->hContext);
+ pContext =
+ ListDictionary_GetItemValue(smartcard->rgSCardContextList, (void*)operation->hContext);
if (!pContext)
asyncIrp = FALSE;
@@ -490,12 +488,12 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
{
if ((status = smartcard_irp_device_control_call(smartcard, operation)))
{
- WLog_ERR(TAG, "smartcard_irp_device_control_call failed with error %"PRId32"!",
+ WLog_ERR(TAG, "smartcard_irp_device_control_call failed with error %" PRId32 "!",
status);
return (UINT32)status;
}
- if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp))
+ if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*)irp))
{
free(operation);
WLog_ERR(TAG, "Queue_Enqueue failed!");
@@ -508,7 +506,7 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
{
if (pContext)
{
- if (!MessageQueue_Post(pContext->IrpQueue, NULL, 0, (void*) operation, NULL))
+ if (!MessageQueue_Post(pContext->IrpQueue, NULL, 0, (void*)operation, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -519,11 +517,12 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
else
{
WLog_ERR(TAG,
- "Unexpected SmartCard IRP: MajorFunction 0x%08"PRIX32" MinorFunction: 0x%08"PRIX32"",
+ "Unexpected SmartCard IRP: MajorFunction 0x%08" PRIX32
+ " MinorFunction: 0x%08" PRIX32 "",
irp->MajorFunction, irp->MinorFunction);
irp->IoStatus = (UINT32)STATUS_NOT_SUPPORTED;
- if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) irp))
+ if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*)irp))
{
WLog_ERR(TAG, "Queue_Enqueue failed!");
return ERROR_INTERNAL_ERROR;
@@ -557,7 +556,7 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -566,7 +565,7 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
@@ -588,14 +587,14 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
goto out;
}
if (status == WAIT_TIMEOUT)
break;
- irp = (IRP*) Queue_Dequeue(smartcard->CompletedIrpQueue);
+ irp = (IRP*)Queue_Dequeue(smartcard->CompletedIrpQueue);
if (irp)
{
@@ -606,7 +605,8 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!",
+ error);
goto out;
}
@@ -616,7 +616,8 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if ((error = smartcard_complete_irp(smartcard, irp)))
{
- WLog_ERR(TAG, "smartcard_complete_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "smartcard_complete_irp failed with error %" PRIu32 "!",
+ error);
goto out;
}
}
@@ -625,13 +626,13 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
break;
}
- irp = (IRP*) message.wParam;
+ irp = (IRP*)message.wParam;
if (irp)
{
if ((error = smartcard_process_irp(smartcard, irp)))
{
- WLog_ERR(TAG, "smartcard_process_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "smartcard_process_irp failed with error %" PRIu32 "!", error);
goto out;
}
}
@@ -642,13 +643,13 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
if (status == WAIT_OBJECT_0)
{
- irp = (IRP*) Queue_Dequeue(smartcard->CompletedIrpQueue);
+ irp = (IRP*)Queue_Dequeue(smartcard->CompletedIrpQueue);
if (irp)
{
@@ -659,7 +660,7 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
@@ -675,7 +676,7 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
goto out;
}
- WLog_ERR(TAG, "smartcard_complete_irp failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "smartcard_complete_irp failed with error %" PRIu32 "!", error);
goto out;
}
}
@@ -685,8 +686,7 @@ static DWORD WINAPI smartcard_thread_func(LPVOID arg)
out:
if (error && smartcard->rdpcontext)
- setChannelError(smartcard->rdpcontext, error,
- "smartcard_thread_func reported an error");
+ setChannelError(smartcard->rdpcontext, error, "smartcard_thread_func reported an error");
ExitThread(error);
return error;
@@ -704,7 +704,7 @@ static UINT smartcard_irp_request(DEVICE* device, IRP* irp)
if (!smartcard)
return ERROR_INVALID_PARAMETER;
- if (!MessageQueue_Post(smartcard->IrpQueue, NULL, 0, (void*) irp, NULL))
+ if (!MessageQueue_Post(smartcard->IrpQueue, NULL, 0, (void*)irp, NULL))
{
WLog_ERR(TAG, "MessageQueue_Post failed!");
return ERROR_INTERNAL_ERROR;
@@ -714,7 +714,7 @@ static UINT smartcard_irp_request(DEVICE* device, IRP* irp)
}
/* smartcard is always built-in */
-#define DeviceServiceEntry smartcard_DeviceServiceEntry
+#define DeviceServiceEntry smartcard_DeviceServiceEntry
/**
* Function description
@@ -730,7 +730,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
if (!sSmartcard)
{
wObject* obj;
- smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
+ smartcard = (SMARTCARD_DEVICE*)calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
{
@@ -795,9 +795,8 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
goto fail;
}
- smartcard->thread = CreateThread(NULL, 0,
- smartcard_thread_func,
- smartcard, CREATE_SUSPENDED, NULL);
+ smartcard->thread =
+ CreateThread(NULL, 0, smartcard_thread_func, smartcard, CREATE_SUSPENDED, NULL);
if (!smartcard->thread)
{
@@ -820,4 +819,3 @@ fail:
smartcard_free_(smartcard);
return error;
}
-
diff --git a/channels/smartcard/client/smartcard_main.h b/channels/smartcard/client/smartcard_main.h
index a867e69b2..e14423359 100644
--- a/channels/smartcard/client/smartcard_main.h
+++ b/channels/smartcard/client/smartcard_main.h
@@ -34,56 +34,61 @@
#define TAG CHANNELS_TAG("smartcard.client")
-#define RDP_SCARD_CTL_CODE(code) CTL_CODE(FILE_DEVICE_FILE_SYSTEM, (code), METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define RDP_SCARD_CTL_CODE(code) \
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, (code), METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define SCARD_IOCTL_ESTABLISHCONTEXT RDP_SCARD_CTL_CODE(5) /* SCardEstablishContext */
-#define SCARD_IOCTL_RELEASECONTEXT RDP_SCARD_CTL_CODE(6) /* SCardReleaseContext */
-#define SCARD_IOCTL_ISVALIDCONTEXT RDP_SCARD_CTL_CODE(7) /* SCardIsValidContext */
-#define SCARD_IOCTL_LISTREADERGROUPSA RDP_SCARD_CTL_CODE(8) /* SCardListReaderGroupsA */
-#define SCARD_IOCTL_LISTREADERGROUPSW RDP_SCARD_CTL_CODE(9) /* SCardListReaderGroupsW */
-#define SCARD_IOCTL_LISTREADERSA RDP_SCARD_CTL_CODE(10) /* SCardListReadersA */
-#define SCARD_IOCTL_LISTREADERSW RDP_SCARD_CTL_CODE(11) /* SCardListReadersW */
-#define SCARD_IOCTL_INTRODUCEREADERGROUPA RDP_SCARD_CTL_CODE(20) /* SCardIntroduceReaderGroupA */
-#define SCARD_IOCTL_INTRODUCEREADERGROUPW RDP_SCARD_CTL_CODE(21) /* SCardIntroduceReaderGroupW */
-#define SCARD_IOCTL_FORGETREADERGROUPA RDP_SCARD_CTL_CODE(22) /* SCardForgetReaderGroupA */
-#define SCARD_IOCTL_FORGETREADERGROUPW RDP_SCARD_CTL_CODE(23) /* SCardForgetReaderGroupW */
-#define SCARD_IOCTL_INTRODUCEREADERA RDP_SCARD_CTL_CODE(24) /* SCardIntroduceReaderA */
-#define SCARD_IOCTL_INTRODUCEREADERW RDP_SCARD_CTL_CODE(25) /* SCardIntroduceReaderW */
-#define SCARD_IOCTL_FORGETREADERA RDP_SCARD_CTL_CODE(26) /* SCardForgetReaderA */
-#define SCARD_IOCTL_FORGETREADERW RDP_SCARD_CTL_CODE(27) /* SCardForgetReaderW */
-#define SCARD_IOCTL_ADDREADERTOGROUPA RDP_SCARD_CTL_CODE(28) /* SCardAddReaderToGroupA */
-#define SCARD_IOCTL_ADDREADERTOGROUPW RDP_SCARD_CTL_CODE(29) /* SCardAddReaderToGroupW */
-#define SCARD_IOCTL_REMOVEREADERFROMGROUPA RDP_SCARD_CTL_CODE(30) /* SCardRemoveReaderFromGroupA */
-#define SCARD_IOCTL_REMOVEREADERFROMGROUPW RDP_SCARD_CTL_CODE(31) /* SCardRemoveReaderFromGroupW */
-#define SCARD_IOCTL_LOCATECARDSA RDP_SCARD_CTL_CODE(38) /* SCardLocateCardsA */
-#define SCARD_IOCTL_LOCATECARDSW RDP_SCARD_CTL_CODE(39) /* SCardLocateCardsW */
-#define SCARD_IOCTL_GETSTATUSCHANGEA RDP_SCARD_CTL_CODE(40) /* SCardGetStatusChangeA */
-#define SCARD_IOCTL_GETSTATUSCHANGEW RDP_SCARD_CTL_CODE(41) /* SCardGetStatusChangeW */
-#define SCARD_IOCTL_CANCEL RDP_SCARD_CTL_CODE(42) /* SCardCancel */
-#define SCARD_IOCTL_CONNECTA RDP_SCARD_CTL_CODE(43) /* SCardConnectA */
-#define SCARD_IOCTL_CONNECTW RDP_SCARD_CTL_CODE(44) /* SCardConnectW */
-#define SCARD_IOCTL_RECONNECT RDP_SCARD_CTL_CODE(45) /* SCardReconnect */
-#define SCARD_IOCTL_DISCONNECT RDP_SCARD_CTL_CODE(46) /* SCardDisconnect */
-#define SCARD_IOCTL_BEGINTRANSACTION RDP_SCARD_CTL_CODE(47) /* SCardBeginTransaction */
-#define SCARD_IOCTL_ENDTRANSACTION RDP_SCARD_CTL_CODE(48) /* SCardEndTransaction */
-#define SCARD_IOCTL_STATE RDP_SCARD_CTL_CODE(49) /* SCardState */
-#define SCARD_IOCTL_STATUSA RDP_SCARD_CTL_CODE(50) /* SCardStatusA */
-#define SCARD_IOCTL_STATUSW RDP_SCARD_CTL_CODE(51) /* SCardStatusW */
-#define SCARD_IOCTL_TRANSMIT RDP_SCARD_CTL_CODE(52) /* SCardTransmit */
-#define SCARD_IOCTL_CONTROL RDP_SCARD_CTL_CODE(53) /* SCardControl */
-#define SCARD_IOCTL_GETATTRIB RDP_SCARD_CTL_CODE(54) /* SCardGetAttrib */
-#define SCARD_IOCTL_SETATTRIB RDP_SCARD_CTL_CODE(55) /* SCardSetAttrib */
-#define SCARD_IOCTL_ACCESSSTARTEDEVENT RDP_SCARD_CTL_CODE(56) /* SCardAccessStartedEvent */
-#define SCARD_IOCTL_LOCATECARDSBYATRA RDP_SCARD_CTL_CODE(58) /* SCardLocateCardsByATRA */
-#define SCARD_IOCTL_LOCATECARDSBYATRW RDP_SCARD_CTL_CODE(59) /* SCardLocateCardsByATRW */
-#define SCARD_IOCTL_READCACHEA RDP_SCARD_CTL_CODE(60) /* SCardReadCacheA */
-#define SCARD_IOCTL_READCACHEW RDP_SCARD_CTL_CODE(61) /* SCardReadCacheW */
-#define SCARD_IOCTL_WRITECACHEA RDP_SCARD_CTL_CODE(62) /* SCardWriteCacheA */
-#define SCARD_IOCTL_WRITECACHEW RDP_SCARD_CTL_CODE(63) /* SCardWriteCacheW */
-#define SCARD_IOCTL_GETTRANSMITCOUNT RDP_SCARD_CTL_CODE(64) /* SCardGetTransmitCount */
-#define SCARD_IOCTL_RELEASESTARTEDEVENT RDP_SCARD_CTL_CODE(66) /* SCardReleaseStartedEvent */
-#define SCARD_IOCTL_GETREADERICON RDP_SCARD_CTL_CODE(67) /* SCardGetReaderIconA */
-#define SCARD_IOCTL_GETDEVICETYPEID RDP_SCARD_CTL_CODE(68) /* SCardGetDeviceTypeIdA */
+#define SCARD_IOCTL_ESTABLISHCONTEXT RDP_SCARD_CTL_CODE(5) /* SCardEstablishContext */
+#define SCARD_IOCTL_RELEASECONTEXT RDP_SCARD_CTL_CODE(6) /* SCardReleaseContext */
+#define SCARD_IOCTL_ISVALIDCONTEXT RDP_SCARD_CTL_CODE(7) /* SCardIsValidContext */
+#define SCARD_IOCTL_LISTREADERGROUPSA RDP_SCARD_CTL_CODE(8) /* SCardListReaderGroupsA */
+#define SCARD_IOCTL_LISTREADERGROUPSW RDP_SCARD_CTL_CODE(9) /* SCardListReaderGroupsW */
+#define SCARD_IOCTL_LISTREADERSA RDP_SCARD_CTL_CODE(10) /* SCardListReadersA */
+#define SCARD_IOCTL_LISTREADERSW RDP_SCARD_CTL_CODE(11) /* SCardListReadersW */
+#define SCARD_IOCTL_INTRODUCEREADERGROUPA RDP_SCARD_CTL_CODE(20) /* SCardIntroduceReaderGroupA */
+#define SCARD_IOCTL_INTRODUCEREADERGROUPW RDP_SCARD_CTL_CODE(21) /* SCardIntroduceReaderGroupW */
+#define SCARD_IOCTL_FORGETREADERGROUPA RDP_SCARD_CTL_CODE(22) /* SCardForgetReaderGroupA */
+#define SCARD_IOCTL_FORGETREADERGROUPW RDP_SCARD_CTL_CODE(23) /* SCardForgetReaderGroupW */
+#define SCARD_IOCTL_INTRODUCEREADERA RDP_SCARD_CTL_CODE(24) /* SCardIntroduceReaderA */
+#define SCARD_IOCTL_INTRODUCEREADERW RDP_SCARD_CTL_CODE(25) /* SCardIntroduceReaderW */
+#define SCARD_IOCTL_FORGETREADERA RDP_SCARD_CTL_CODE(26) /* SCardForgetReaderA */
+#define SCARD_IOCTL_FORGETREADERW RDP_SCARD_CTL_CODE(27) /* SCardForgetReaderW */
+#define SCARD_IOCTL_ADDREADERTOGROUPA RDP_SCARD_CTL_CODE(28) /* SCardAddReaderToGroupA */
+#define SCARD_IOCTL_ADDREADERTOGROUPW RDP_SCARD_CTL_CODE(29) /* SCardAddReaderToGroupW */
+#define SCARD_IOCTL_REMOVEREADERFROMGROUPA \
+ RDP_SCARD_CTL_CODE(30) /* SCardRemoveReaderFromGroupA \
+ */
+#define SCARD_IOCTL_REMOVEREADERFROMGROUPW \
+ RDP_SCARD_CTL_CODE(31) /* SCardRemoveReaderFromGroupW \
+ */
+#define SCARD_IOCTL_LOCATECARDSA RDP_SCARD_CTL_CODE(38) /* SCardLocateCardsA */
+#define SCARD_IOCTL_LOCATECARDSW RDP_SCARD_CTL_CODE(39) /* SCardLocateCardsW */
+#define SCARD_IOCTL_GETSTATUSCHANGEA RDP_SCARD_CTL_CODE(40) /* SCardGetStatusChangeA */
+#define SCARD_IOCTL_GETSTATUSCHANGEW RDP_SCARD_CTL_CODE(41) /* SCardGetStatusChangeW */
+#define SCARD_IOCTL_CANCEL RDP_SCARD_CTL_CODE(42) /* SCardCancel */
+#define SCARD_IOCTL_CONNECTA RDP_SCARD_CTL_CODE(43) /* SCardConnectA */
+#define SCARD_IOCTL_CONNECTW RDP_SCARD_CTL_CODE(44) /* SCardConnectW */
+#define SCARD_IOCTL_RECONNECT RDP_SCARD_CTL_CODE(45) /* SCardReconnect */
+#define SCARD_IOCTL_DISCONNECT RDP_SCARD_CTL_CODE(46) /* SCardDisconnect */
+#define SCARD_IOCTL_BEGINTRANSACTION RDP_SCARD_CTL_CODE(47) /* SCardBeginTransaction */
+#define SCARD_IOCTL_ENDTRANSACTION RDP_SCARD_CTL_CODE(48) /* SCardEndTransaction */
+#define SCARD_IOCTL_STATE RDP_SCARD_CTL_CODE(49) /* SCardState */
+#define SCARD_IOCTL_STATUSA RDP_SCARD_CTL_CODE(50) /* SCardStatusA */
+#define SCARD_IOCTL_STATUSW RDP_SCARD_CTL_CODE(51) /* SCardStatusW */
+#define SCARD_IOCTL_TRANSMIT RDP_SCARD_CTL_CODE(52) /* SCardTransmit */
+#define SCARD_IOCTL_CONTROL RDP_SCARD_CTL_CODE(53) /* SCardControl */
+#define SCARD_IOCTL_GETATTRIB RDP_SCARD_CTL_CODE(54) /* SCardGetAttrib */
+#define SCARD_IOCTL_SETATTRIB RDP_SCARD_CTL_CODE(55) /* SCardSetAttrib */
+#define SCARD_IOCTL_ACCESSSTARTEDEVENT RDP_SCARD_CTL_CODE(56) /* SCardAccessStartedEvent */
+#define SCARD_IOCTL_LOCATECARDSBYATRA RDP_SCARD_CTL_CODE(58) /* SCardLocateCardsByATRA */
+#define SCARD_IOCTL_LOCATECARDSBYATRW RDP_SCARD_CTL_CODE(59) /* SCardLocateCardsByATRW */
+#define SCARD_IOCTL_READCACHEA RDP_SCARD_CTL_CODE(60) /* SCardReadCacheA */
+#define SCARD_IOCTL_READCACHEW RDP_SCARD_CTL_CODE(61) /* SCardReadCacheW */
+#define SCARD_IOCTL_WRITECACHEA RDP_SCARD_CTL_CODE(62) /* SCardWriteCacheA */
+#define SCARD_IOCTL_WRITECACHEW RDP_SCARD_CTL_CODE(63) /* SCardWriteCacheW */
+#define SCARD_IOCTL_GETTRANSMITCOUNT RDP_SCARD_CTL_CODE(64) /* SCardGetTransmitCount */
+#define SCARD_IOCTL_RELEASESTARTEDEVENT RDP_SCARD_CTL_CODE(66) /* SCardReleaseStartedEvent */
+#define SCARD_IOCTL_GETREADERICON RDP_SCARD_CTL_CODE(67) /* SCardGetReaderIconA */
+#define SCARD_IOCTL_GETDEVICETYPEID RDP_SCARD_CTL_CODE(68) /* SCardGetDeviceTypeIdA */
typedef struct _SMARTCARD_DEVICE SMARTCARD_DEVICE;
@@ -124,7 +129,7 @@ SMARTCARD_CONTEXT* smartcard_context_new(SMARTCARD_DEVICE* smartcard, SCARDCONTE
void smartcard_context_free(void* pContext);
LONG smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation);
+ SMARTCARD_OPERATION* operation);
LONG smartcard_irp_device_control_call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation);
#include "smartcard_pack.h"
diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c
index 336a05ae1..fc1e8a2f2 100644
--- a/channels/smartcard/client/smartcard_operations.c
+++ b/channels/smartcard/client/smartcard_operations.c
@@ -195,7 +195,7 @@ const char* smartcard_get_ioctl_string(UINT32 ioControlCode, BOOL funcName)
}
static LONG smartcard_EstablishContext_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
EstablishContext_Call* call;
@@ -207,7 +207,8 @@ static LONG smartcard_EstablishContext_Decode(SMARTCARD_DEVICE* smartcard,
if ((status = smartcard_unpack_establish_context_call(smartcard, irp->input, call)))
{
- WLog_ERR(TAG, "smartcard_unpack_establish_context_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_establish_context_call failed with error %" PRId32 "",
+ status);
return status;
}
@@ -216,7 +217,7 @@ static LONG smartcard_EstablishContext_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
SCARDCONTEXT hContext = -1;
@@ -228,7 +229,7 @@ static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
if (ret.ReturnCode == SCARD_S_SUCCESS)
{
SMARTCARD_CONTEXT* pContext;
- void* key = (void*)(size_t) hContext;
+ void* key = (void*)(size_t)hContext;
// TODO: handle return values
pContext = smartcard_context_new(smartcard, hContext);
@@ -238,7 +239,7 @@ static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
}
- if (!ListDictionary_Add(smartcard->rgSCardContextList, key, (void*) pContext))
+ if (!ListDictionary_Add(smartcard->rgSCardContextList, key, (void*)pContext))
{
WLog_ERR(TAG, "ListDictionary_Add failed!");
return STATUS_INTERNAL_ERROR;
@@ -246,7 +247,7 @@ static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
}
else
{
- WLog_ERR(TAG, "SCardEstablishContext failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardEstablishContext failed with error %" PRId32 "", status);
return status;
}
@@ -255,7 +256,8 @@ static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
if ((status = smartcard_pack_establish_context_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_establish_context_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_establish_context_return failed with error %" PRId32 "",
+ status);
return status;
}
@@ -263,7 +265,7 @@ static LONG smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ReleaseContext_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
Context_Call* call;
@@ -274,7 +276,7 @@ static LONG smartcard_ReleaseContext_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_context_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %" PRId32 "", status);
smartcard_trace_context_call(smartcard, call, "ReleaseContext");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -282,7 +284,7 @@ static LONG smartcard_ReleaseContext_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ReleaseContext_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
Long_Return ret;
@@ -291,13 +293,13 @@ static LONG smartcard_ReleaseContext_Call(SMARTCARD_DEVICE* smartcard,
if (ret.ReturnCode == SCARD_S_SUCCESS)
{
SMARTCARD_CONTEXT* pContext;
- void* key = (void*)(size_t) operation->hContext;
- pContext = (SMARTCARD_CONTEXT*) ListDictionary_Remove(smartcard->rgSCardContextList, key);
+ void* key = (void*)(size_t)operation->hContext;
+ pContext = (SMARTCARD_CONTEXT*)ListDictionary_Remove(smartcard->rgSCardContextList, key);
smartcard_context_free(pContext);
}
else
{
- WLog_ERR(TAG, "SCardReleaseContext failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardReleaseContext failed with error %" PRId32 "", status);
return status;
}
@@ -306,7 +308,7 @@ static LONG smartcard_ReleaseContext_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_IsValidContext_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
Context_Call* call;
@@ -317,7 +319,7 @@ static LONG smartcard_IsValidContext_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_context_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %" PRId32 "", status);
smartcard_trace_context_call(smartcard, call, "IsValidContext");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -325,14 +327,14 @@ static LONG smartcard_IsValidContext_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_IsValidContext_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
Long_Return ret;
if ((status = ret.ReturnCode = SCardIsValidContext(operation->hContext)))
{
- WLog_ERR(TAG, "SCardIsValidContext failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardIsValidContext failed with error %" PRId32 "", status);
return status;
}
@@ -341,7 +343,7 @@ static LONG smartcard_IsValidContext_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ListReaderGroupsA_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaderGroups_Call* call;
@@ -358,7 +360,7 @@ static LONG smartcard_ListReaderGroupsA_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ListReaderGroupsA_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaderGroups_Return ret;
@@ -366,9 +368,9 @@ static LONG smartcard_ListReaderGroupsA_Call(SMARTCARD_DEVICE* smartcard,
DWORD cchGroups = 0;
IRP* irp = operation->irp;
cchGroups = SCARD_AUTOALLOCATE;
- status = ret.ReturnCode = SCardListReaderGroupsA(operation->hContext, (LPSTR) &mszGroups,
- &cchGroups);
- ret.msz = (BYTE*) mszGroups;
+ status = ret.ReturnCode =
+ SCardListReaderGroupsA(operation->hContext, (LPSTR)&mszGroups, &cchGroups);
+ ret.msz = (BYTE*)mszGroups;
ret.cBytes = cchGroups;
if (status != SCARD_S_SUCCESS)
@@ -387,7 +389,7 @@ static LONG smartcard_ListReaderGroupsA_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ListReaderGroupsW_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaderGroups_Call* call;
@@ -404,7 +406,7 @@ static LONG smartcard_ListReaderGroupsW_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_ListReaderGroupsW_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaderGroups_Return ret;
@@ -412,9 +414,9 @@ static LONG smartcard_ListReaderGroupsW_Call(SMARTCARD_DEVICE* smartcard,
DWORD cchGroups = 0;
IRP* irp = operation->irp;
cchGroups = SCARD_AUTOALLOCATE;
- status = ret.ReturnCode = SCardListReaderGroupsW(operation->hContext, (LPWSTR) &mszGroups,
- &cchGroups);
- ret.msz = (BYTE*) mszGroups;
+ status = ret.ReturnCode =
+ SCardListReaderGroupsW(operation->hContext, (LPWSTR)&mszGroups, &cchGroups);
+ ret.msz = (BYTE*)mszGroups;
ret.cBytes = cchGroups;
if (status != SCARD_S_SUCCESS)
@@ -474,8 +476,7 @@ static DWORD filter_device_by_name_a(wLinkedList* list, LPSTR* mszReaders, DWORD
wpos += readerLen + 1;
}
- }
- while (rpos < cchReaders);
+ } while (rpos < cchReaders);
/* this string must be double 0 terminated */
if (rpos != wpos)
@@ -498,8 +499,7 @@ static DWORD filter_device_by_name_w(wLinkedList* list, LPWSTR* mszReaders, DWOR
if (LinkedList_Count(list) < 1)
return cchReaders;
- res = ConvertFromUnicode(CP_UTF8, 0, *mszReaders, (int)cchReaders, &readers, 0, NULL,
- NULL);
+ res = ConvertFromUnicode(CP_UTF8, 0, *mszReaders, (int)cchReaders, &readers, 0, NULL, NULL);
/* When res==0, readers may have been set to NULL by ConvertFromUnicode */
if ((res < 0) || ((DWORD)res != cchReaders) || (readers == 0))
@@ -518,7 +518,7 @@ static DWORD filter_device_by_name_w(wLinkedList* list, LPWSTR* mszReaders, DWOR
}
static LONG smartcard_ListReadersA_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaders_Call* call;
@@ -529,7 +529,7 @@ static LONG smartcard_ListReadersA_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_list_readers_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_list_readers_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_list_readers_call failed with error %" PRId32 "", status);
smartcard_trace_list_readers_call(smartcard, call, FALSE);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -545,8 +545,8 @@ static LONG smartcard_ListReadersA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
IRP* irp = operation->irp;
ListReaders_Call* call = operation->call;
cchReaders = SCARD_AUTOALLOCATE;
- status = ret.ReturnCode = SCardListReadersA(operation->hContext, (LPCSTR) call->mszGroups,
- (LPSTR) &mszReaders, &cchReaders);
+ status = ret.ReturnCode = SCardListReadersA(operation->hContext, (LPCSTR)call->mszGroups,
+ (LPSTR)&mszReaders, &cchReaders);
if (call->mszGroups)
{
@@ -556,18 +556,18 @@ static LONG smartcard_ListReadersA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
if (status)
{
- WLog_ERR(TAG, "SCardListReadersA failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardListReadersA failed with error %" PRId32 "", status);
return status;
}
cchReaders = filter_device_by_name_a(smartcard->names, &mszReaders, cchReaders);
- ret.msz = (BYTE*) mszReaders;
+ ret.msz = (BYTE*)mszReaders;
ret.cBytes = cchReaders;
smartcard_trace_list_readers_return(smartcard, &ret, FALSE);
if ((status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_list_readers_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_list_readers_return failed with error %" PRId32 "", status);
return status;
}
@@ -581,7 +581,7 @@ static LONG smartcard_ListReadersA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
}
static LONG smartcard_ListReadersW_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
ListReaders_Call* call;
@@ -592,7 +592,7 @@ static LONG smartcard_ListReadersW_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_list_readers_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_list_readers_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_list_readers_call failed with error %" PRId32 "", status);
smartcard_trace_list_readers_call(smartcard, call, TRUE);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -608,8 +608,8 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
IRP* irp = operation->irp;
ListReaders_Call* call = operation->call;
cchReaders = SCARD_AUTOALLOCATE;
- status = ret.ReturnCode = SCardListReadersW(operation->hContext,
- (LPCWSTR) call->mszGroups, (LPWSTR) &mszReaders, &cchReaders);
+ status = ret.ReturnCode = SCardListReadersW(operation->hContext, (LPCWSTR)call->mszGroups,
+ (LPWSTR)&mszReaders, &cchReaders);
if (call->mszGroups)
{
@@ -619,18 +619,18 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
if (status != SCARD_S_SUCCESS)
{
- WLog_ERR(TAG, "SCardListReadersW failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardListReadersW failed with error %" PRId32 "", status);
return status;
}
cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders, cchReaders);
- ret.msz = (BYTE*) mszReaders;
+ ret.msz = (BYTE*)mszReaders;
ret.cBytes = cchReaders * 2;
smartcard_trace_list_readers_return(smartcard, &ret, TRUE);
if ((status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_list_readers_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_list_readers_return failed with error %" PRId32 "", status);
return status;
}
@@ -644,7 +644,7 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
}
static LONG smartcard_GetStatusChangeA_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
GetStatusChangeA_Call* call;
@@ -656,7 +656,8 @@ static LONG smartcard_GetStatusChangeA_Decode(SMARTCARD_DEVICE* smartcard,
if ((status = smartcard_unpack_get_status_change_a_call(smartcard, irp->input, call)))
{
- WLog_ERR(TAG, "smartcard_unpack_get_status_change_a_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_get_status_change_a_call failed with error %" PRId32 "",
+ status);
return status;
}
@@ -666,21 +667,21 @@ static LONG smartcard_GetStatusChangeA_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_GetStatusChangeA_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
UINT32 index;
GetStatusChange_Return ret;
LPSCARD_READERSTATEA rgReaderState = NULL;
IRP* irp = operation->irp;
GetStatusChangeA_Call* call = operation->call;
- ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, call->dwTimeOut, call->rgReaderStates,
- call->cReaders);
+ ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, call->dwTimeOut,
+ call->rgReaderStates, call->cReaders);
ret.cReaders = call->cReaders;
ret.rgReaderStates = NULL;
if (ret.cReaders > 0)
{
- ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return));
+ ret.rgReaderStates = (ReaderState_Return*)calloc(ret.cReaders, sizeof(ReaderState_Return));
if (!ret.rgReaderStates)
return STATUS_NO_MEMORY;
@@ -713,7 +714,7 @@ static LONG smartcard_GetStatusChangeA_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_GetStatusChangeW_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
GetStatusChangeW_Call* call;
@@ -724,7 +725,8 @@ static LONG smartcard_GetStatusChangeW_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_get_status_change_w_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_get_status_change_w_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_get_status_change_w_call failed with error %" PRId32 "",
+ status);
smartcard_trace_get_status_change_w_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -732,7 +734,7 @@ static LONG smartcard_GetStatusChangeW_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
UINT32 index;
GetStatusChange_Return ret;
@@ -746,7 +748,7 @@ static LONG smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard,
if (ret.cReaders > 0)
{
- ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return));
+ ret.rgReaderStates = (ReaderState_Return*)calloc(ret.cReaders, sizeof(ReaderState_Return));
if (!ret.rgReaderStates)
return STATUS_NO_MEMORY;
@@ -789,7 +791,7 @@ static LONG smartcard_Cancel_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_context_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_context_call failed with error %" PRId32 "", status);
smartcard_trace_context_call(smartcard, call, "Cancel");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -803,7 +805,7 @@ static LONG smartcard_Cancel_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATI
if ((status = ret.ReturnCode = SCardCancel(operation->hContext)))
{
- WLog_ERR(TAG, "SCardCancel failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardCancel failed with error %" PRId32 "", status);
return status;
}
@@ -822,11 +824,11 @@ static LONG smartcard_ConnectA_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_connect_a_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_connect_a_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_connect_a_call failed with error %" PRId32 "", status);
smartcard_trace_connect_a_call(smartcard, call);
- operation->hContext = smartcard_scard_context_native_from_redir(smartcard,
- &(call->Common.hContext));
+ operation->hContext =
+ smartcard_scard_context_native_from_redir(smartcard, &(call->Common.hContext));
return status;
}
@@ -844,22 +846,22 @@ static LONG smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
call->Common.dwPreferredProtocols = SCARD_PROTOCOL_Tx;
}
- status = ret.ReturnCode = SCardConnectA(operation->hContext, (char*) call->szReader,
- call->Common.dwShareMode,
- call->Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
+ status = ret.ReturnCode =
+ SCardConnectA(operation->hContext, (char*)call->szReader, call->Common.dwShareMode,
+ call->Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
smartcard_scard_context_native_to_redir(smartcard, &(ret.hContext), operation->hContext);
smartcard_scard_handle_native_to_redir(smartcard, &(ret.hCard), hCard);
smartcard_trace_connect_return(smartcard, &ret);
if (status)
{
- WLog_ERR(TAG, "SCardConnectA failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardConnectA failed with error %" PRId32 "", status);
goto out_fail;
}
if ((status = smartcard_pack_connect_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %" PRId32 "", status);
goto out_fail;
}
@@ -880,11 +882,11 @@ static LONG smartcard_ConnectW_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_connect_w_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_connect_w_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_connect_w_call failed with error %" PRId32 "", status);
smartcard_trace_connect_w_call(smartcard, call);
- operation->hContext = smartcard_scard_context_native_from_redir(smartcard,
- &(call->Common.hContext));
+ operation->hContext =
+ smartcard_scard_context_native_from_redir(smartcard, &(call->Common.hContext));
return status;
}
@@ -902,22 +904,22 @@ static LONG smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
call->Common.dwPreferredProtocols = SCARD_PROTOCOL_Tx;
}
- status = ret.ReturnCode = SCardConnectW(operation->hContext, (WCHAR*) call->szReader,
- call->Common.dwShareMode,
- call->Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
+ status = ret.ReturnCode =
+ SCardConnectW(operation->hContext, (WCHAR*)call->szReader, call->Common.dwShareMode,
+ call->Common.dwPreferredProtocols, &hCard, &ret.dwActiveProtocol);
smartcard_scard_context_native_to_redir(smartcard, &(ret.hContext), operation->hContext);
smartcard_scard_handle_native_to_redir(smartcard, &(ret.hCard), hCard);
smartcard_trace_connect_return(smartcard, &ret);
if (status)
{
- WLog_ERR(TAG, "SCardConnectW failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardConnectW failed with error %" PRId32 "", status);
goto out_fail;
}
if ((status = smartcard_pack_connect_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %" PRId32 "", status);
goto out_fail;
}
@@ -938,7 +940,7 @@ static LONG smartcard_Reconnect_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_reconnect_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_reconnect_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_reconnect_call failed with error %" PRId32 "", status);
smartcard_trace_reconnect_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -952,13 +954,13 @@ static LONG smartcard_Reconnect_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
Reconnect_Return ret;
IRP* irp = operation->irp;
Reconnect_Call* call = operation->call;
- ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode,
- call->dwPreferredProtocols, call->dwInitialization, &ret.dwActiveProtocol);
+ ret.ReturnCode = SCardReconnect(operation->hCard, call->dwShareMode, call->dwPreferredProtocols,
+ call->dwInitialization, &ret.dwActiveProtocol);
smartcard_trace_reconnect_return(smartcard, &ret);
if ((status = smartcard_pack_reconnect_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_reconnect_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_reconnect_return failed with error %" PRId32 "", status);
return status;
}
@@ -976,7 +978,8 @@ static LONG smartcard_Disconnect_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_hcard_and_disposition_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %" PRId32 "",
+ status);
smartcard_trace_hcard_and_disposition_call(smartcard, call, "Disconnect");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -992,7 +995,7 @@ static LONG smartcard_Disconnect_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if ((status = ret.ReturnCode = SCardDisconnect(operation->hCard, call->dwDisposition)))
{
- WLog_ERR(TAG, "SCardDisconnect failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "SCardDisconnect failed with error %" PRId32 "", status);
return status;
}
@@ -1005,7 +1008,7 @@ static LONG smartcard_Disconnect_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
}
static LONG smartcard_BeginTransaction_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
HCardAndDisposition_Call* call;
@@ -1016,7 +1019,8 @@ static LONG smartcard_BeginTransaction_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_hcard_and_disposition_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %" PRId32 "",
+ status);
smartcard_trace_hcard_and_disposition_call(smartcard, call, "BeginTransaction");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1025,13 +1029,13 @@ static LONG smartcard_BeginTransaction_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_BeginTransaction_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
Long_Return ret;
if ((ret.ReturnCode = SCardBeginTransaction(operation->hCard)))
{
- WLog_ERR(TAG, "SCardBeginTransaction failed with error %"PRId32"", ret.ReturnCode);
+ WLog_ERR(TAG, "SCardBeginTransaction failed with error %" PRId32 "", ret.ReturnCode);
return ret.ReturnCode;
}
@@ -1040,7 +1044,7 @@ static LONG smartcard_BeginTransaction_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_EndTransaction_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
HCardAndDisposition_Call* call;
@@ -1051,7 +1055,8 @@ static LONG smartcard_EndTransaction_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_hcard_and_disposition_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_hcard_and_disposition_call failed with error %" PRId32 "",
+ status);
smartcard_trace_hcard_and_disposition_call(smartcard, call, "EndTransaction");
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1060,14 +1065,14 @@ static LONG smartcard_EndTransaction_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_EndTransaction_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
Long_Return ret;
HCardAndDisposition_Call* call = operation->call;
if ((ret.ReturnCode = SCardEndTransaction(operation->hCard, call->dwDisposition)))
{
- WLog_ERR(TAG, "SCardEndTransaction failed with error %"PRId32"", ret.ReturnCode);
+ WLog_ERR(TAG, "SCardEndTransaction failed with error %" PRId32 "", ret.ReturnCode);
return ret.ReturnCode;
}
@@ -1086,7 +1091,7 @@ static LONG smartcard_State_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_state_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_state_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_state_call failed with error %" PRId32 "", status);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
operation->hCard = smartcard_scard_handle_native_from_redir(smartcard, &(call->hCard));
@@ -1099,12 +1104,12 @@ static LONG smartcard_State_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATIO
State_Return ret;
IRP* irp = operation->irp;
ret.cbAtrLen = SCARD_ATR_LENGTH;
- ret.ReturnCode = SCardState(operation->hCard, &ret.dwState, &ret.dwProtocol, (BYTE*) &ret.rgAtr,
+ ret.ReturnCode = SCardState(operation->hCard, &ret.dwState, &ret.dwProtocol, (BYTE*)&ret.rgAtr,
&ret.cbAtrLen);
if ((status = smartcard_pack_state_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_state_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_state_return failed with error %" PRId32 "", status);
return status;
}
@@ -1122,7 +1127,7 @@ static LONG smartcard_StatusA_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_status_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_status_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_status_call failed with error %" PRId32 "", status);
smartcard_trace_status_call(smartcard, call, FALSE);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1148,15 +1153,15 @@ static LONG smartcard_StatusA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
else
cchReaderLen = SCARD_AUTOALLOCATE;
- status = ret.ReturnCode = SCardStatusA(operation->hCard,
- call->fmszReaderNamesIsNULL ? NULL : (LPSTR) &mszReaderNames,
- &cchReaderLen, &ret.dwState, &ret.dwProtocol,
- cbAtrLen ? (BYTE*) &ret.pbAtr : NULL, &cbAtrLen);
+ status = ret.ReturnCode =
+ SCardStatusA(operation->hCard, call->fmszReaderNamesIsNULL ? NULL : (LPSTR)&mszReaderNames,
+ &cchReaderLen, &ret.dwState, &ret.dwProtocol,
+ cbAtrLen ? (BYTE*)&ret.pbAtr : NULL, &cbAtrLen);
if (status == SCARD_S_SUCCESS)
{
if (!call->fmszReaderNamesIsNULL)
- ret.mszReaderNames = (BYTE*) mszReaderNames;
+ ret.mszReaderNames = (BYTE*)mszReaderNames;
ret.cBytes = cchReaderLen;
@@ -1168,7 +1173,7 @@ static LONG smartcard_StatusA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if ((status = smartcard_pack_status_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_status_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_status_return failed with error %" PRId32 "", status);
return status;
}
@@ -1191,7 +1196,7 @@ static LONG smartcard_StatusW_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_status_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_status_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_status_call failed with error %" PRId32 "", status);
smartcard_trace_status_call(smartcard, call, TRUE);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1221,17 +1226,17 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
cchReaderLen = SCARD_AUTOALLOCATE;
ZeroMemory(ret.pbAtr, 32);
- status = ret.ReturnCode = SCardStatusW(operation->hCard,
- call->fmszReaderNamesIsNULL ? NULL : (LPWSTR) &mszReaderNames,
- &cchReaderLen, &ret.dwState, &ret.dwProtocol, (BYTE*) &ret.pbAtr, &cbAtrLen);
+ status = ret.ReturnCode =
+ SCardStatusW(operation->hCard, call->fmszReaderNamesIsNULL ? NULL : (LPWSTR)&mszReaderNames,
+ &cchReaderLen, &ret.dwState, &ret.dwProtocol, (BYTE*)&ret.pbAtr, &cbAtrLen);
if (status == SCARD_S_SUCCESS)
{
if (!call->fmszReaderNamesIsNULL)
- ret.mszReaderNames = (BYTE*) mszReaderNames;
+ ret.mszReaderNames = (BYTE*)mszReaderNames;
- // WinScard returns the number of CHARACTERS whereas pcsc-lite returns the
- // number of BYTES.
+ // WinScard returns the number of CHARACTERS whereas pcsc-lite returns the
+ // number of BYTES.
#ifdef _WIN32
ret.cBytes = cchReaderLen * 2;
#else
@@ -1245,7 +1250,7 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
if ((status = smartcard_pack_status_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_status_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_status_return failed with error %" PRId32 "", status);
return status;
}
@@ -1266,7 +1271,7 @@ static LONG smartcard_Transmit_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_transmit_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_transmit_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_transmit_call failed with error %" PRId32 "", status);
smartcard_trace_transmit_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1289,15 +1294,16 @@ static LONG smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
call->cbRecvLength = 66560;
ret.cbRecvLength = call->cbRecvLength;
- ret.pbRecvBuffer = (BYTE*) malloc(ret.cbRecvLength);
+ ret.pbRecvBuffer = (BYTE*)malloc(ret.cbRecvLength);
if (!ret.pbRecvBuffer)
return STATUS_NO_MEMORY;
}
ret.pioRecvPci = call->pioRecvPci;
- ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
- call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
+ ret.ReturnCode =
+ SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer, call->cbSendLength,
+ ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
smartcard_trace_transmit_return(smartcard, &ret);
status = smartcard_pack_transmit_return(smartcard, irp->output, &ret);
@@ -1308,7 +1314,7 @@ static LONG smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA
if (status)
{
- WLog_ERR(TAG, "smartcard_pack_transmit_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_transmit_return failed with error %" PRId32 "", status);
return status;
}
return ret.ReturnCode;
@@ -1325,7 +1331,7 @@ static LONG smartcard_Control_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_control_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_control_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_control_call failed with error %" PRId32 "", status);
smartcard_trace_control_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1340,19 +1346,19 @@ static LONG smartcard_Control_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
IRP* irp = operation->irp;
Control_Call* call = operation->call;
ret.cbOutBufferSize = call->cbOutBufferSize;
- ret.pvOutBuffer = (BYTE*) malloc(call->cbOutBufferSize);
+ ret.pvOutBuffer = (BYTE*)malloc(call->cbOutBufferSize);
if (!ret.pvOutBuffer)
return SCARD_E_NO_MEMORY;
- ret.ReturnCode = SCardControl(operation->hCard,
- call->dwControlCode, call->pvInBuffer, call->cbInBufferSize,
- ret.pvOutBuffer, call->cbOutBufferSize, &ret.cbOutBufferSize);
+ ret.ReturnCode =
+ SCardControl(operation->hCard, call->dwControlCode, call->pvInBuffer, call->cbInBufferSize,
+ ret.pvOutBuffer, call->cbOutBufferSize, &ret.cbOutBufferSize);
smartcard_trace_control_return(smartcard, &ret);
if ((status = smartcard_pack_control_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_control_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_control_return failed with error %" PRId32 "", status);
return status;
}
@@ -1372,7 +1378,7 @@ static LONG smartcard_GetAttrib_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_get_attrib_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_get_attrib_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_get_attrib_call failed with error %" PRId32 "", status);
smartcard_trace_get_attrib_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1397,21 +1403,22 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
if (call->cbAttrLen && !autoAllocate)
{
- ret.pbAttr = (BYTE*) malloc(call->cbAttrLen);
+ ret.pbAttr = (BYTE*)malloc(call->cbAttrLen);
if (!ret.pbAttr)
return SCARD_E_NO_MEMORY;
}
cbAttrLen = call->cbAttrLen;
- ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId,
- autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr, &cbAttrLen);
+ ret.ReturnCode =
+ SCardGetAttrib(operation->hCard, call->dwAttrId,
+ autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr, &cbAttrLen);
ret.cbAttrLen = cbAttrLen;
smartcard_trace_get_attrib_return(smartcard, &ret, call->dwAttrId);
if (ret.ReturnCode)
{
- WLog_WARN(TAG, "SCardGetAttrib: %s (0x%08"PRIX32") cbAttrLen: %"PRIu32"",
+ WLog_WARN(TAG, "SCardGetAttrib: %s (0x%08" PRIX32 ") cbAttrLen: %" PRIu32 "",
SCardGetAttributeString(call->dwAttrId), call->dwAttrId, call->cbAttrLen);
Stream_Zero(irp->output, 256);
free(ret.pbAttr);
@@ -1420,7 +1427,7 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
if ((status = smartcard_pack_get_attrib_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_get_attrib_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_get_attrib_return failed with error %" PRId32 "", status);
return status;
}
@@ -1429,7 +1436,7 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
}
static LONG smartcard_AccessStartedEvent_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
Long_Call* call;
IRP* irp;
@@ -1442,7 +1449,7 @@ static LONG smartcard_AccessStartedEvent_Decode(SMARTCARD_DEVICE* smartcard,
if (Stream_GetRemainingLength(irp->input) < 4)
{
- WLog_WARN(TAG, "AccessStartedEvent is too short: %"PRIuz"",
+ WLog_WARN(TAG, "AccessStartedEvent is too short: %" PRIuz "",
Stream_GetRemainingLength(irp->input));
return SCARD_F_INTERNAL_ERROR;
}
@@ -1452,7 +1459,7 @@ static LONG smartcard_AccessStartedEvent_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_AccessStartedEvent_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status = SCARD_S_SUCCESS;
WINPR_UNUSED(operation);
@@ -1467,7 +1474,7 @@ static LONG smartcard_AccessStartedEvent_Call(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_LocateCardsByATRA_Decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
LocateCardsByATRA_Call* call;
@@ -1478,7 +1485,8 @@ static LONG smartcard_LocateCardsByATRA_Decode(SMARTCARD_DEVICE* smartcard,
return STATUS_NO_MEMORY;
if ((status = smartcard_unpack_locate_cards_by_atr_a_call(smartcard, irp->input, call)))
- WLog_ERR(TAG, "smartcard_unpack_locate_cards_by_atr_a_call failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_locate_cards_by_atr_a_call failed with error %" PRId32 "",
+ status);
smartcard_trace_locate_cards_by_atr_a_call(smartcard, call);
operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext));
@@ -1486,7 +1494,7 @@ static LONG smartcard_LocateCardsByATRA_Decode(SMARTCARD_DEVICE* smartcard,
}
static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
DWORD i, j, k;
@@ -1495,22 +1503,22 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
LPSCARD_READERSTATEA states = NULL;
IRP* irp = operation->irp;
LocateCardsByATRA_Call* call = operation->call;
- states = (LPSCARD_READERSTATEA) calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
+ states = (LPSCARD_READERSTATEA)calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
if (!states)
return STATUS_NO_MEMORY;
for (i = 0; i < call->cReaders; i++)
{
- states[i].szReader = (LPCSTR) call->rgReaderStates[i].szReader;
+ states[i].szReader = (LPCSTR)call->rgReaderStates[i].szReader;
states[i].dwCurrentState = call->rgReaderStates[i].Common.dwCurrentState;
states[i].dwEventState = call->rgReaderStates[i].Common.dwEventState;
states[i].cbAtr = call->rgReaderStates[i].Common.cbAtr;
CopyMemory(&(states[i].rgbAtr), &(call->rgReaderStates[i].Common.rgbAtr), 36);
}
- status = ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, 0x000001F4, states,
- call->cReaders);
+ status = ret.ReturnCode =
+ SCardGetStatusChangeA(operation->hContext, 0x000001F4, states, call->cReaders);
if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED))
{
@@ -1538,7 +1546,7 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
ret.rgReaderStates = NULL;
if (ret.cReaders > 0)
- ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return));
+ ret.rgReaderStates = (ReaderState_Return*)calloc(ret.cReaders, sizeof(ReaderState_Return));
if (!ret.rgReaderStates)
{
@@ -1560,7 +1568,8 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
if ((status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret)))
{
- WLog_ERR(TAG, "smartcard_pack_get_status_change_return failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_get_status_change_return failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1568,11 +1577,11 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
{
for (i = 0; i < call->cReaders; i++)
{
- state = (LPSCARD_READERSTATEA) &call->rgReaderStates[i];
+ state = (LPSCARD_READERSTATEA)&call->rgReaderStates[i];
if (state->szReader)
{
- free((void*) state->szReader);
+ free((void*)state->szReader);
state->szReader = NULL;
}
}
@@ -1586,7 +1595,7 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard,
}
LONG smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard,
- SMARTCARD_OPERATION* operation)
+ SMARTCARD_OPERATION* operation)
{
LONG status;
UINT32 offset;
@@ -1599,41 +1608,42 @@ LONG smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard,
if (Stream_GetRemainingLength(irp->input) < 32)
{
- WLog_WARN(TAG, "Device Control Request is too short: %"PRIuz"",
+ WLog_WARN(TAG, "Device Control Request is too short: %" PRIuz "",
Stream_GetRemainingLength(irp->input));
return SCARD_F_INTERNAL_ERROR;
}
Stream_Read_UINT32(irp->input, outputBufferLength); /* OutputBufferLength (4 bytes) */
- Stream_Read_UINT32(irp->input, inputBufferLength); /* InputBufferLength (4 bytes) */
- Stream_Read_UINT32(irp->input, ioControlCode); /* IoControlCode (4 bytes) */
- Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
+ Stream_Read_UINT32(irp->input, inputBufferLength); /* InputBufferLength (4 bytes) */
+ Stream_Read_UINT32(irp->input, ioControlCode); /* IoControlCode (4 bytes) */
+ Stream_Seek(irp->input, 20); /* Padding (20 bytes) */
operation->ioControlCode = ioControlCode;
if (Stream_Length(irp->input) != (Stream_GetPosition(irp->input) + inputBufferLength))
{
- WLog_WARN(TAG, "InputBufferLength mismatch: Actual: %"PRIuz" Expected: %"PRIuz"",
- Stream_Length(irp->input),
- Stream_GetPosition(irp->input) + inputBufferLength);
+ WLog_WARN(TAG, "InputBufferLength mismatch: Actual: %" PRIuz " Expected: %" PRIuz "",
+ Stream_Length(irp->input), Stream_GetPosition(irp->input) + inputBufferLength);
return SCARD_F_INTERNAL_ERROR;
}
- WLog_DBG(TAG, "%s (0x%08"PRIX32") FileId: %"PRIu32" CompletionId: %"PRIu32"",
- smartcard_get_ioctl_string(ioControlCode, TRUE),
- ioControlCode, irp->FileId, irp->CompletionId);
+ WLog_DBG(TAG, "%s (0x%08" PRIX32 ") FileId: %" PRIu32 " CompletionId: %" PRIu32 "",
+ smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, irp->FileId,
+ irp->CompletionId);
if ((ioControlCode != SCARD_IOCTL_ACCESSSTARTEDEVENT) &&
(ioControlCode != SCARD_IOCTL_RELEASESTARTEDEVENT))
{
if ((status = smartcard_unpack_common_type_header(smartcard, irp->input)))
{
- WLog_ERR(TAG, "smartcard_unpack_common_type_header failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_common_type_header failed with error %" PRId32 "",
+ status);
return SCARD_F_INTERNAL_ERROR;
}
if ((status = smartcard_unpack_private_type_header(smartcard, irp->input)))
{
- WLog_ERR(TAG, "smartcard_unpack_common_type_header failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_common_type_header failed with error %" PRId32 "",
+ status);
return SCARD_F_INTERNAL_ERROR;
}
}
@@ -1853,7 +1863,8 @@ LONG smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard,
SIZE_T difference;
difference = Stream_Length(irp->input) - Stream_GetPosition(irp->input);
WLog_WARN(TAG,
- "IRP was not fully parsed %s (0x%08"PRIX32"): Actual: %"PRIuz", Expected: %"PRIuz", Difference: %"PRIuz"",
+ "IRP was not fully parsed %s (0x%08" PRIX32 "): Actual: %" PRIuz
+ ", Expected: %" PRIuz ", Difference: %" PRIuz "",
smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode,
Stream_GetPosition(irp->input), Stream_Length(irp->input), difference);
winpr_HexDump(TAG, WLOG_WARN, Stream_Pointer(irp->input), difference);
@@ -1864,7 +1875,8 @@ LONG smartcard_irp_device_control_decode(SMARTCARD_DEVICE* smartcard,
SIZE_T difference;
difference = Stream_GetPosition(irp->input) - Stream_Length(irp->input);
WLog_WARN(TAG,
- "IRP was parsed beyond its end %s (0x%08"PRIX32"): Actual: %"PRIuz", Expected: %"PRIuz", Difference: %"PRIuz"",
+ "IRP was parsed beyond its end %s (0x%08" PRIX32 "): Actual: %" PRIuz
+ ", Expected: %" PRIuz ", Difference: %" PRIuz "",
smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode,
Stream_GetPosition(irp->input), Stream_Length(irp->input), difference);
}
@@ -1899,8 +1911,9 @@ LONG smartcard_irp_device_control_call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
/* Device Control Response */
Stream_Seek_UINT32(irp->output); /* OutputBufferLength (4 bytes) */
Stream_Seek(irp->output, SMARTCARD_COMMON_TYPE_HEADER_LENGTH); /* CommonTypeHeader (8 bytes) */
- Stream_Seek(irp->output, SMARTCARD_PRIVATE_TYPE_HEADER_LENGTH); /* PrivateTypeHeader (8 bytes) */
- Stream_Seek_UINT32(irp->output); /* Result (4 bytes) */
+ Stream_Seek(irp->output,
+ SMARTCARD_PRIVATE_TYPE_HEADER_LENGTH); /* PrivateTypeHeader (8 bytes) */
+ Stream_Seek_UINT32(irp->output); /* Result (4 bytes) */
/* Call */
@@ -2116,14 +2129,14 @@ LONG smartcard_irp_device_control_call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
(ioControlCode != SCARD_IOCTL_RELEASESTARTEDEVENT))
{
offset = (RDPDR_DEVICE_IO_RESPONSE_LENGTH + RDPDR_DEVICE_IO_CONTROL_RSP_HDR_LENGTH);
- smartcard_pack_write_size_align(smartcard, irp->output, Stream_GetPosition(irp->output) - offset,
- 8);
+ smartcard_pack_write_size_align(smartcard, irp->output,
+ Stream_GetPosition(irp->output) - offset, 8);
}
if ((result != SCARD_S_SUCCESS) && (result != SCARD_E_TIMEOUT) &&
(result != SCARD_E_NO_READERS_AVAILABLE) && (result != SCARD_E_NO_SERVICE))
{
- WLog_WARN(TAG, "IRP failure: %s (0x%08"PRIX32"), status: %s (0x%08"PRIX32")",
+ WLog_WARN(TAG, "IRP failure: %s (0x%08" PRIX32 "), status: %s (0x%08" PRIX32 ")",
smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode,
SCardGetErrorString(result), result);
}
@@ -2134,7 +2147,7 @@ LONG smartcard_irp_device_control_call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
{
/* NTSTATUS error */
irp->IoStatus = (UINT32)result;
- WLog_WARN(TAG, "IRP failure: %s (0x%08"PRIX32"), ntstatus: 0x%08"PRIX32"",
+ WLog_WARN(TAG, "IRP failure: %s (0x%08" PRIX32 "), ntstatus: 0x%08" PRIX32 "",
smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, result);
}
@@ -2143,12 +2156,11 @@ LONG smartcard_irp_device_control_call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OP
objectBufferLength = outputBufferLength - RDPDR_DEVICE_IO_RESPONSE_LENGTH;
Stream_SetPosition(irp->output, RDPDR_DEVICE_IO_RESPONSE_LENGTH);
/* Device Control Response */
- Stream_Write_UINT32(irp->output, outputBufferLength); /* OutputBufferLength (4 bytes) */
+ Stream_Write_UINT32(irp->output, outputBufferLength); /* OutputBufferLength (4 bytes) */
smartcard_pack_common_type_header(smartcard, irp->output); /* CommonTypeHeader (8 bytes) */
smartcard_pack_private_type_header(smartcard, irp->output,
objectBufferLength); /* PrivateTypeHeader (8 bytes) */
- Stream_Write_UINT32(irp->output, result); /* Result (4 bytes) */
+ Stream_Write_UINT32(irp->output, result); /* Result (4 bytes) */
Stream_SetPosition(irp->output, Stream_Length(irp->output));
return SCARD_S_SUCCESS;
}
-
diff --git a/channels/smartcard/client/smartcard_pack.c b/channels/smartcard/client/smartcard_pack.c
index 6ab809c4d..b2ce09a0f 100644
--- a/channels/smartcard/client/smartcard_pack.c
+++ b/channels/smartcard/client/smartcard_pack.c
@@ -38,38 +38,38 @@ LONG smartcard_unpack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream* s
if (Stream_GetRemainingLength(s) < 8)
{
- WLog_WARN(TAG, "CommonTypeHeader is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "CommonTypeHeader is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
/* Process CommonTypeHeader */
- Stream_Read_UINT8(s, version); /* Version (1 byte) */
- Stream_Read_UINT8(s, endianness); /* Endianness (1 byte) */
+ Stream_Read_UINT8(s, version); /* Version (1 byte) */
+ Stream_Read_UINT8(s, endianness); /* Endianness (1 byte) */
Stream_Read_UINT16(s, commonHeaderLength); /* CommonHeaderLength (2 bytes) */
- Stream_Read_UINT32(s, filler); /* Filler (4 bytes), should be 0xCCCCCCCC */
+ Stream_Read_UINT32(s, filler); /* Filler (4 bytes), should be 0xCCCCCCCC */
if (version != 1)
{
- WLog_WARN(TAG, "Unsupported CommonTypeHeader Version %"PRIu8"", version);
+ WLog_WARN(TAG, "Unsupported CommonTypeHeader Version %" PRIu8 "", version);
return STATUS_INVALID_PARAMETER;
}
if (endianness != 0x10)
{
- WLog_WARN(TAG, "Unsupported CommonTypeHeader Endianness %"PRIu8"", endianness);
+ WLog_WARN(TAG, "Unsupported CommonTypeHeader Endianness %" PRIu8 "", endianness);
return STATUS_INVALID_PARAMETER;
}
if (commonHeaderLength != 8)
{
- WLog_WARN(TAG, "Unsupported CommonTypeHeader CommonHeaderLength %"PRIu16"", commonHeaderLength);
+ WLog_WARN(TAG, "Unsupported CommonTypeHeader CommonHeaderLength %" PRIu16 "",
+ commonHeaderLength);
return STATUS_INVALID_PARAMETER;
}
if (filler != 0xCCCCCCCC)
{
- WLog_WARN(TAG, "Unexpected CommonTypeHeader Filler 0x%08"PRIX32"", filler);
+ WLog_WARN(TAG, "Unexpected CommonTypeHeader Filler 0x%08" PRIX32 "", filler);
return STATUS_INVALID_PARAMETER;
}
@@ -79,9 +79,9 @@ LONG smartcard_unpack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream* s
void smartcard_pack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream* s)
{
WINPR_UNUSED(smartcard);
- Stream_Write_UINT8(s, 1); /* Version (1 byte) */
- Stream_Write_UINT8(s, 0x10); /* Endianness (1 byte) */
- Stream_Write_UINT16(s, 8); /* CommonHeaderLength (2 bytes) */
+ Stream_Write_UINT8(s, 1); /* Version (1 byte) */
+ Stream_Write_UINT8(s, 0x10); /* Endianness (1 byte) */
+ Stream_Write_UINT16(s, 8); /* CommonHeaderLength (2 bytes) */
Stream_Write_UINT32(s, 0xCCCCCCCC); /* Filler (4 bytes), should be 0xCCCCCCCC */
}
@@ -93,24 +93,24 @@ LONG smartcard_unpack_private_type_header(SMARTCARD_DEVICE* smartcard, wStream*
if (Stream_GetRemainingLength(s) < 8)
{
- WLog_WARN(TAG, "PrivateTypeHeader is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "PrivateTypeHeader is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, objectBufferLength); /* ObjectBufferLength (4 bytes) */
- Stream_Read_UINT32(s, filler); /* Filler (4 bytes), should be 0x00000000 */
+ Stream_Read_UINT32(s, filler); /* Filler (4 bytes), should be 0x00000000 */
if (filler != 0x00000000)
{
- WLog_WARN(TAG, "Unexpected PrivateTypeHeader Filler 0x%08"PRIX32"", filler);
+ WLog_WARN(TAG, "Unexpected PrivateTypeHeader Filler 0x%08" PRIX32 "", filler);
return STATUS_INVALID_PARAMETER;
}
if (objectBufferLength != Stream_GetRemainingLength(s))
{
WLog_WARN(TAG,
- "PrivateTypeHeader ObjectBufferLength mismatch: Actual: %"PRIu32", Expected: %"PRIuz"",
+ "PrivateTypeHeader ObjectBufferLength mismatch: Actual: %" PRIu32
+ ", Expected: %" PRIuz "",
objectBufferLength, Stream_GetRemainingLength(s));
return STATUS_INVALID_PARAMETER;
}
@@ -123,7 +123,7 @@ void smartcard_pack_private_type_header(SMARTCARD_DEVICE* smartcard, wStream* s,
{
WINPR_UNUSED(smartcard);
Stream_Write_UINT32(s, objectBufferLength); /* ObjectBufferLength (4 bytes) */
- Stream_Write_UINT32(s, 0x00000000); /* Filler (4 bytes), should be 0x00000000 */
+ Stream_Write_UINT32(s, 0x00000000); /* Filler (4 bytes), should be 0x00000000 */
}
LONG smartcard_unpack_read_size_align(SMARTCARD_DEVICE* smartcard, wStream* s, UINT32 size,
@@ -165,7 +165,7 @@ LONG smartcard_pack_write_size_align(SMARTCARD_DEVICE* smartcard, wStream* s, UI
}
SCARDCONTEXT smartcard_scard_context_native_from_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDCONTEXT* context)
+ REDIR_SCARDCONTEXT* context)
{
SCARDCONTEXT hContext = { 0 };
WINPR_UNUSED(smartcard);
@@ -173,7 +173,8 @@ SCARDCONTEXT smartcard_scard_context_native_from_redir(SMARTCARD_DEVICE* smartca
if ((context->cbContext != sizeof(ULONG_PTR)) && (context->cbContext != 0))
{
WLog_WARN(TAG,
- "REDIR_SCARDCONTEXT does not match native size: Actual: %"PRIu32", Expected: %"PRIuz"",
+ "REDIR_SCARDCONTEXT does not match native size: Actual: %" PRIu32
+ ", Expected: %" PRIuz "",
context->cbContext, sizeof(ULONG_PTR));
return 0;
}
@@ -185,7 +186,7 @@ SCARDCONTEXT smartcard_scard_context_native_from_redir(SMARTCARD_DEVICE* smartca
}
void smartcard_scard_context_native_to_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDCONTEXT* context, SCARDCONTEXT hContext)
+ REDIR_SCARDCONTEXT* context, SCARDCONTEXT hContext)
{
WINPR_UNUSED(smartcard);
ZeroMemory(context, sizeof(REDIR_SCARDCONTEXT));
@@ -194,7 +195,7 @@ void smartcard_scard_context_native_to_redir(SMARTCARD_DEVICE* smartcard,
}
SCARDHANDLE smartcard_scard_handle_native_from_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDHANDLE* handle)
+ REDIR_SCARDHANDLE* handle)
{
SCARDHANDLE hCard = 0;
WINPR_UNUSED(smartcard);
@@ -202,7 +203,8 @@ SCARDHANDLE smartcard_scard_handle_native_from_redir(SMARTCARD_DEVICE* smartcard
if (handle->cbHandle != sizeof(ULONG_PTR))
{
WLog_WARN(TAG,
- "REDIR_SCARDHANDLE does not match native size: Actual: %"PRIu32", Expected: %"PRIuz"",
+ "REDIR_SCARDHANDLE does not match native size: Actual: %" PRIu32
+ ", Expected: %" PRIuz "",
handle->cbHandle, sizeof(ULONG_PTR));
return 0;
}
@@ -214,7 +216,7 @@ SCARDHANDLE smartcard_scard_handle_native_from_redir(SMARTCARD_DEVICE* smartcard
}
void smartcard_scard_handle_native_to_redir(SMARTCARD_DEVICE* smartcard, REDIR_SCARDHANDLE* handle,
- SCARDHANDLE hCard)
+ SCARDHANDLE hCard)
{
WINPR_UNUSED(smartcard);
ZeroMemory(handle, sizeof(REDIR_SCARDHANDLE));
@@ -223,7 +225,7 @@ void smartcard_scard_handle_native_to_redir(SMARTCARD_DEVICE* smartcard, REDIR_S
}
LONG smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context)
+ REDIR_SCARDCONTEXT* context)
{
UINT32 pbContextNdrPtr;
WINPR_UNUSED(smartcard);
@@ -231,8 +233,7 @@ LONG smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream*
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -240,30 +241,33 @@ LONG smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream*
if (Stream_GetRemainingLength(s) < context->cbContext)
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), context->cbContext);
return STATUS_BUFFER_TOO_SMALL;
}
if ((context->cbContext != 0) && (context->cbContext != 4) && (context->cbContext != 8))
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT length is not 0, 4 or 8: %"PRIu32"", context->cbContext);
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT length is not 0, 4 or 8: %" PRIu32 "",
+ context->cbContext);
return STATUS_INVALID_PARAMETER;
}
Stream_Read_UINT32(s, pbContextNdrPtr); /* pbContextNdrPtr (4 bytes) */
- if (((context->cbContext == 0) && pbContextNdrPtr) || ((context->cbContext != 0) &&
- !pbContextNdrPtr))
+ if (((context->cbContext == 0) && pbContextNdrPtr) ||
+ ((context->cbContext != 0) && !pbContextNdrPtr))
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT cbContext (%"PRIu32") pbContextNdrPtr (%"PRIu32") inconsistency",
+ WLog_WARN(TAG,
+ "REDIR_SCARDCONTEXT cbContext (%" PRIu32 ") pbContextNdrPtr (%" PRIu32
+ ") inconsistency",
context->cbContext, pbContextNdrPtr);
return STATUS_INVALID_PARAMETER;
}
if (context->cbContext > Stream_GetRemainingLength(s))
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too long: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too long: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), context->cbContext);
return STATUS_INVALID_PARAMETER;
}
@@ -278,12 +282,12 @@ LONG smartcard_pack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream* s,
WINPR_UNUSED(smartcard);
pbContextNdrPtr = (context->cbContext) ? 0x00020001 : 0;
Stream_Write_UINT32(s, context->cbContext); /* cbContext (4 bytes) */
- Stream_Write_UINT32(s, pbContextNdrPtr); /* pbContextNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, pbContextNdrPtr); /* pbContextNdrPtr (4 bytes) */
return SCARD_S_SUCCESS;
}
LONG smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context)
+ REDIR_SCARDCONTEXT* context)
{
UINT32 length;
WINPR_UNUSED(smartcard);
@@ -293,7 +297,7 @@ LONG smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStre
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %"PRIuz", Expected: 4",
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %" PRIuz ", Expected: 4",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -302,20 +306,20 @@ LONG smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStre
if (length != context->cbContext)
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT length (%"PRIu32") cbContext (%"PRIu32") mismatch",
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT length (%" PRIu32 ") cbContext (%" PRIu32 ") mismatch",
length, context->cbContext);
return STATUS_INVALID_PARAMETER;
}
if ((context->cbContext != 0) && (context->cbContext != 4) && (context->cbContext != 8))
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT length is not 4 or 8: %"PRIu32"", context->cbContext);
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT length is not 4 or 8: %" PRIu32 "", context->cbContext);
return STATUS_INVALID_PARAMETER;
}
if (Stream_GetRemainingLength(s) < context->cbContext)
{
- WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG, "REDIR_SCARDCONTEXT is too short: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), context->cbContext);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -329,7 +333,7 @@ LONG smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStre
}
LONG smartcard_pack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context)
+ REDIR_SCARDCONTEXT* context)
{
WINPR_UNUSED(smartcard);
Stream_Write_UINT32(s, context->cbContext); /* Length (4 bytes) */
@@ -343,7 +347,7 @@ LONG smartcard_pack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStream
}
LONG smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle)
+ REDIR_SCARDHANDLE* handle)
{
UINT32 pbHandleNdrPtr;
WINPR_UNUSED(smartcard);
@@ -351,8 +355,7 @@ LONG smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "SCARDHANDLE is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "SCARDHANDLE is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -360,7 +363,7 @@ LONG smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s
if ((Stream_GetRemainingLength(s) < handle->cbHandle) || (!handle->cbHandle))
{
- WLog_WARN(TAG, "SCARDHANDLE is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG, "SCARDHANDLE is too short: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), handle->cbHandle);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -376,19 +379,19 @@ LONG smartcard_pack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s,
WINPR_UNUSED(smartcard);
pbHandleNdrPtr = (handle->cbHandle) ? 0x00020002 : 0;
Stream_Write_UINT32(s, handle->cbHandle); /* cbHandle (4 bytes) */
- Stream_Write_UINT32(s, pbHandleNdrPtr); /* pbHandleNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, pbHandleNdrPtr); /* pbHandleNdrPtr (4 bytes) */
return SCARD_S_SUCCESS;
}
LONG smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle)
+ REDIR_SCARDHANDLE* handle)
{
UINT32 length;
WINPR_UNUSED(smartcard);
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "REDIR_SCARDHANDLE is too short: Actual: %"PRIuz", Expected: 4",
+ WLog_WARN(TAG, "REDIR_SCARDHANDLE is too short: Actual: %" PRIuz ", Expected: 4",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -397,20 +400,20 @@ LONG smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStrea
if (length != handle->cbHandle)
{
- WLog_WARN(TAG, "REDIR_SCARDHANDLE length (%"PRIu32") cbHandle (%"PRIu32") mismatch",
+ WLog_WARN(TAG, "REDIR_SCARDHANDLE length (%" PRIu32 ") cbHandle (%" PRIu32 ") mismatch",
length, handle->cbHandle);
return STATUS_INVALID_PARAMETER;
}
if ((handle->cbHandle != 4) && (handle->cbHandle != 8))
{
- WLog_WARN(TAG, "REDIR_SCARDHANDLE length is not 4 or 8: %"PRIu32"", handle->cbHandle);
+ WLog_WARN(TAG, "REDIR_SCARDHANDLE length is not 4 or 8: %" PRIu32 "", handle->cbHandle);
return STATUS_INVALID_PARAMETER;
}
if ((Stream_GetRemainingLength(s) < handle->cbHandle) || (!handle->cbHandle))
{
- WLog_WARN(TAG, "REDIR_SCARDHANDLE is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG, "REDIR_SCARDHANDLE is too short: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), handle->cbHandle);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -422,7 +425,7 @@ LONG smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStrea
}
LONG smartcard_pack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle)
+ REDIR_SCARDHANDLE* handle)
{
WINPR_UNUSED(smartcard);
Stream_Write_UINT32(s, handle->cbHandle); /* Length (4 bytes) */
@@ -434,13 +437,13 @@ LONG smartcard_pack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStream*
}
LONG smartcard_unpack_establish_context_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- EstablishContext_Call* call)
+ EstablishContext_Call* call)
{
WINPR_UNUSED(smartcard);
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "EstablishContext_Call is too short: Actual: %"PRIuz", Expected: 4",
+ WLog_WARN(TAG, "EstablishContext_Call is too short: Actual: %" PRIuz ", Expected: 4",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -450,7 +453,7 @@ LONG smartcard_unpack_establish_context_call(SMARTCARD_DEVICE* smartcard, wStrea
}
void smartcard_trace_establish_context_call(SMARTCARD_DEVICE* smartcard,
- const EstablishContext_Call* call)
+ const EstablishContext_Call* call)
{
WINPR_UNUSED(smartcard);
@@ -458,30 +461,31 @@ void smartcard_trace_establish_context_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "EstablishContext_Call {");
- WLog_DBG(TAG, "dwScope: %s (0x%08"PRIX32")",
- SCardGetScopeString(call->dwScope), call->dwScope);
+ WLog_DBG(TAG, "dwScope: %s (0x%08" PRIX32 ")", SCardGetScopeString(call->dwScope),
+ call->dwScope);
WLog_DBG(TAG, "}");
}
LONG smartcard_pack_establish_context_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- EstablishContext_Return* ret)
+ EstablishContext_Return* ret)
{
LONG status;
if ((status = smartcard_pack_redir_scard_context(smartcard, s, &(ret->hContext))))
{
- WLog_ERR(TAG, "smartcard_pack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_pack_redir_scard_context_ref(smartcard, s, &(ret->hContext))))
- WLog_ERR(TAG, "smartcard_pack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
void smartcard_trace_establish_context_return(SMARTCARD_DEVICE* smartcard,
- const EstablishContext_Return* ret)
+ const EstablishContext_Return* ret)
{
BYTE* pb;
WINPR_UNUSED(smartcard);
@@ -490,19 +494,20 @@ void smartcard_trace_establish_context_return(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "EstablishContext_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- pb = (BYTE*) & (ret->hContext.pbContext);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ pb = (BYTE*)&(ret->hContext.pbContext);
if (ret->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], ret->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], ret->hContext.cbContext);
}
@@ -515,17 +520,19 @@ LONG smartcard_unpack_context_call(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
-void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, const Context_Call* call, const char* name)
+void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, const Context_Call* call,
+ const char* name)
{
BYTE* pb;
WINPR_UNUSED(smartcard);
@@ -534,24 +541,26 @@ void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, const Context_Cal
return;
WLog_DBG(TAG, "%s_Call {", name);
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
WLog_DBG(TAG, "}");
}
-void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, const Long_Return* ret, const char* name)
+void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, const Long_Return* ret,
+ const char* name)
{
WINPR_UNUSED(smartcard);
@@ -559,13 +568,13 @@ void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, const Long_Return*
return;
WLog_DBG(TAG, "%s_Return {", name);
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
WLog_DBG(TAG, "}");
}
LONG smartcard_unpack_list_reader_groups_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- ListReaderGroups_Call* call)
+ ListReaderGroups_Call* call)
{
LONG status;
status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext));
@@ -575,13 +584,12 @@ LONG smartcard_unpack_list_reader_groups_call(SMARTCARD_DEVICE* smartcard, wStre
if (Stream_GetRemainingLength(s) < 8)
{
- WLog_WARN(TAG, "ListReaderGroups_Call is too short: %d",
- (int) Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "ListReaderGroups_Call is too short: %d", (int)Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, call->fmszGroupsIsNULL); /* fmszGroupsIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cchGroups); /* cchGroups (4 bytes) */
+ Stream_Read_UINT32(s, call->cchGroups); /* cchGroups (4 bytes) */
status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext));
if (status)
@@ -591,7 +599,7 @@ LONG smartcard_unpack_list_reader_groups_call(SMARTCARD_DEVICE* smartcard, wStre
}
void smartcard_trace_list_reader_groups_call(SMARTCARD_DEVICE* smartcard,
- const ListReaderGroups_Call* call, BOOL unicode)
+ const ListReaderGroups_Call* call, BOOL unicode)
{
BYTE* pb;
WINPR_UNUSED(smartcard);
@@ -600,33 +608,34 @@ void smartcard_trace_list_reader_groups_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "ListReaderGroups%S_Call {", unicode ? "W" : "A");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8" (%"PRIu32")",
+ "hContext: 0x%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8
+ "%02" PRIx8 "%02" PRIx8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- WLog_DBG(TAG, "fmszGroupsIsNULL: %"PRId32" cchGroups: 0x%08"PRIx32,
- call->fmszGroupsIsNULL, call->cchGroups);
+ WLog_DBG(TAG, "fmszGroupsIsNULL: %" PRId32 " cchGroups: 0x%08" PRIx32, call->fmszGroupsIsNULL,
+ call->cchGroups);
WLog_DBG(TAG, "}");
}
LONG smartcard_pack_list_reader_groups_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- ListReaderGroups_Return* ret)
+ ListReaderGroups_Return* ret)
{
UINT32 mszNdrPtr;
mszNdrPtr = (ret->cBytes) ? 0x00020008 : 0;
Stream_EnsureRemainingCapacity(s, ret->cBytes + 32);
Stream_Write_UINT32(s, ret->cBytes); /* cBytes (4 bytes) */
- Stream_Write_UINT32(s, mszNdrPtr); /* mszNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, mszNdrPtr); /* mszNdrPtr (4 bytes) */
if (mszNdrPtr)
{
@@ -644,7 +653,7 @@ LONG smartcard_pack_list_reader_groups_return(SMARTCARD_DEVICE* smartcard, wStre
}
void smartcard_trace_list_reader_groups_return(SMARTCARD_DEVICE* smartcard,
- const ListReaderGroups_Return* ret, BOOL unicode)
+ const ListReaderGroups_Return* ret, BOOL unicode)
{
int index;
int length;
@@ -657,12 +666,12 @@ void smartcard_trace_list_reader_groups_return(SMARTCARD_DEVICE* smartcard,
if (unicode)
{
length = ret->cBytes / 2;
- ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) ret->msz, length, &mszA, 0, NULL, NULL);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)ret->msz, length, &mszA, 0, NULL, NULL);
}
else
{
length = ret->cBytes;
- mszA = (char*) malloc(length);
+ mszA = (char*)malloc(length);
CopyMemory(mszA, ret->msz, ret->cBytes);
}
@@ -673,9 +682,9 @@ void smartcard_trace_list_reader_groups_return(SMARTCARD_DEVICE* smartcard,
}
WLog_DBG(TAG, "ListReaderGroups%s_Return {", unicode ? "W" : "A");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIx32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "cBytes: %"PRIu32" msz: %s", ret->cBytes, mszA);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIx32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "cBytes: %" PRIu32 " msz: %s", ret->cBytes, mszA);
WLog_DBG(TAG, "}");
free(mszA);
}
@@ -690,32 +699,33 @@ LONG smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream* s,
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 16)
{
- WLog_WARN(TAG, "ListReaders_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "ListReaders_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->cBytes); /* cBytes (4 bytes) */
- Stream_Read_UINT32(s, mszGroupsNdrPtr); /* mszGroupsNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, call->cBytes); /* cBytes (4 bytes) */
+ Stream_Read_UINT32(s, mszGroupsNdrPtr); /* mszGroupsNdrPtr (4 bytes) */
Stream_Read_UINT32(s, call->fmszReadersIsNULL); /* fmszReadersIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cchReaders); /* cchReaders (4 bytes) */
+ Stream_Read_UINT32(s, call->cchReaders); /* cchReaders (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((mszGroupsNdrPtr && !call->cBytes) || (!mszGroupsNdrPtr && call->cBytes))
{
WLog_WARN(TAG,
- "ListReaders_Call mszGroupsNdrPtr (0x%08"PRIX32") and cBytes (0x%08"PRIX32") inconsistency",
+ "ListReaders_Call mszGroupsNdrPtr (0x%08" PRIX32 ") and cBytes (0x%08" PRIX32
+ ") inconsistency",
mszGroupsNdrPtr, call->cBytes);
return STATUS_INVALID_PARAMETER;
}
@@ -726,19 +736,22 @@ LONG smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream* s,
if (count != call->cBytes)
{
- WLog_WARN(TAG, "ListReaders_Call NdrCount (0x%08"PRIX32") and cBytes (0x%08"PRIX32") inconsistency",
+ WLog_WARN(TAG,
+ "ListReaders_Call NdrCount (0x%08" PRIX32 ") and cBytes (0x%08" PRIX32
+ ") inconsistency",
count, call->cBytes);
return STATUS_INVALID_PARAMETER;
}
if (Stream_GetRemainingLength(s) < call->cBytes)
{
- WLog_WARN(TAG, "ListReaders_Call is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG,
+ "ListReaders_Call is too short: Actual: %" PRIuz ", Expected: %" PRIu32 "",
Stream_GetRemainingLength(s), call->cBytes);
return STATUS_BUFFER_TOO_SMALL;
}
- call->mszGroups = (BYTE*) calloc(1, call->cBytes + 4);
+ call->mszGroups = (BYTE*)calloc(1, call->cBytes + 4);
if (!call->mszGroups)
{
@@ -764,26 +777,28 @@ void smartcard_trace_list_readers_call(SMARTCARD_DEVICE* smartcard, const ListRe
return;
if (unicode)
- ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) call->mszGroups, call->cBytes / 2, &mszGroupsA, 0, NULL,
- NULL);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)call->mszGroups, call->cBytes / 2, &mszGroupsA, 0,
+ NULL, NULL);
WLog_DBG(TAG, "ListReaders%s_Call {", unicode ? "W" : "A");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
WLog_DBG(TAG,
- "cBytes: %"PRIu32" mszGroups: %s fmszReadersIsNULL: %"PRId32" cchReaders: 0x%08"PRIX32"",
+ "cBytes: %" PRIu32 " mszGroups: %s fmszReadersIsNULL: %" PRId32
+ " cchReaders: 0x%08" PRIX32 "",
call->cBytes, mszGroupsA, call->fmszReadersIsNULL, call->cchReaders);
WLog_DBG(TAG, "}");
@@ -809,7 +824,7 @@ LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
}
Stream_Write_UINT32(s, ret->cBytes); /* cBytes (4 bytes) */
- Stream_Write_UINT32(s, mszNdrPtr); /* mszNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, mszNdrPtr); /* mszNdrPtr (4 bytes) */
if (mszNdrPtr)
{
@@ -822,7 +837,7 @@ LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
if ((error = smartcard_pack_write_size_align(smartcard, s, ret->cBytes, 4)))
{
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"", error);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "", error);
return error;
}
}
@@ -831,7 +846,7 @@ LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
}
void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const ListReaders_Return* ret,
- BOOL unicode)
+ BOOL unicode)
{
size_t index;
size_t length;
@@ -842,8 +857,8 @@ void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const List
return;
WLog_DBG(TAG, "ListReaders%s_Return {", unicode ? "W" : "A");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
if (ret->ReturnCode != SCARD_S_SUCCESS)
{
@@ -855,8 +870,7 @@ void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const List
{
length = ret->cBytes / 2;
- if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) ret->msz, (int)length,
- &mszA, 0, NULL, NULL) < 1)
+ if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)ret->msz, (int)length, &mszA, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "ConvertFromUnicode failed");
return;
@@ -865,7 +879,7 @@ void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const List
else
{
length = ret->cBytes;
- mszA = (char*) malloc(length);
+ mszA = (char*)malloc(length);
if (!mszA)
{
@@ -882,7 +896,7 @@ void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const List
mszA[index] = ',';
}
- WLog_DBG(TAG, "cBytes: %"PRIu32" msz: %s", ret->cBytes, mszA);
+ WLog_DBG(TAG, "cBytes: %" PRIu32 " msz: %s", ret->cBytes, mszA);
WLog_DBG(TAG, "}");
free(mszA);
}
@@ -894,18 +908,17 @@ LONG smartcard_unpack_connect_common(SMARTCARD_DEVICE* smartcard, wStream* s,
if (Stream_GetRemainingLength(s) < 8)
{
- WLog_WARN(TAG, "Connect_Common is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Connect_Common is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(common->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
- Stream_Read_UINT32(s, common->dwShareMode); /* dwShareMode (4 bytes) */
+ Stream_Read_UINT32(s, common->dwShareMode); /* dwShareMode (4 bytes) */
Stream_Read_UINT32(s, common->dwPreferredProtocols); /* dwPreferredProtocols (4 bytes) */
return SCARD_S_SUCCESS;
}
@@ -918,8 +931,7 @@ LONG smartcard_unpack_connect_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "ConnectA_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "ConnectA_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -927,15 +939,15 @@ LONG smartcard_unpack_connect_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
if ((status = smartcard_unpack_connect_common(smartcard, s, &(call->Common))))
{
- WLog_ERR(TAG, "smartcard_unpack_connect_common failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_connect_common failed with error %" PRId32 "", status);
return status;
}
/* szReader */
- Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
- Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
+ Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
+ Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
- call->szReader = (unsigned char*) malloc(count + 1);
+ call->szReader = (unsigned char*)malloc(count + 1);
if (!call->szReader)
{
@@ -948,7 +960,8 @@ LONG smartcard_unpack_connect_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
call->szReader[count] = '\0';
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->Common.hContext))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -962,24 +975,28 @@ void smartcard_trace_connect_a_call(SMARTCARD_DEVICE* smartcard, const ConnectA_
return;
WLog_DBG(TAG, "ConnectA_Call {");
- pb = (BYTE*) & (call->Common.hContext.pbContext);
+ pb = (BYTE*)&(call->Common.hContext.pbContext);
if (call->Common.hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
- pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->Common.hContext.cbContext);
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
+ pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7],
+ call->Common.hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->Common.hContext.cbContext);
}
WLog_DBG(TAG,
- "szReader: %s dwShareMode: %s (0x%08"PRIX32") dwPreferredProtocols: %s (0x%08"PRIX32")",
- call->szReader, SCardGetShareModeString(call->Common.dwShareMode), call->Common.dwShareMode,
- SCardGetProtocolString(call->Common.dwPreferredProtocols), call->Common.dwPreferredProtocols);
+ "szReader: %s dwShareMode: %s (0x%08" PRIX32 ") dwPreferredProtocols: %s (0x%08" PRIX32
+ ")",
+ call->szReader, SCardGetShareModeString(call->Common.dwShareMode),
+ call->Common.dwShareMode, SCardGetProtocolString(call->Common.dwPreferredProtocols),
+ call->Common.dwPreferredProtocols);
WLog_DBG(TAG, "}");
}
@@ -991,8 +1008,7 @@ LONG smartcard_unpack_connect_w_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "ConnectW_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "ConnectW_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1000,15 +1016,15 @@ LONG smartcard_unpack_connect_w_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
if ((status = smartcard_unpack_connect_common(smartcard, s, &(call->Common))))
{
- WLog_ERR(TAG, "smartcard_unpack_connect_common failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_connect_common failed with error %" PRId32 "", status);
return status;
}
/* szReader */
- Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
- Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
+ Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
+ Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
- call->szReader = (WCHAR*) calloc((count + 1), 2);
+ call->szReader = (WCHAR*)calloc((count + 1), 2);
if (!call->szReader)
{
@@ -1021,7 +1037,8 @@ LONG smartcard_unpack_connect_w_call(SMARTCARD_DEVICE* smartcard, wStream* s, Co
call->szReader[count] = '\0';
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->Common.hContext))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1037,24 +1054,28 @@ void smartcard_trace_connect_w_call(SMARTCARD_DEVICE* smartcard, const ConnectW_
ConvertFromUnicode(CP_UTF8, 0, call->szReader, -1, &szReaderA, 0, NULL, NULL);
WLog_DBG(TAG, "ConnectW_Call {");
- pb = (BYTE*) & (call->Common.hContext.pbContext);
+ pb = (BYTE*)&(call->Common.hContext.pbContext);
if (call->Common.hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
- pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->Common.hContext.cbContext);
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
+ pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7],
+ call->Common.hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->Common.hContext.cbContext);
}
WLog_DBG(TAG,
- "szReader: %s dwShareMode: %s (0x%08"PRIX32") dwPreferredProtocols: %s (0x%08"PRIX32")",
+ "szReader: %s dwShareMode: %s (0x%08" PRIX32 ") dwPreferredProtocols: %s (0x%08" PRIX32
+ ")",
szReaderA, SCardGetShareModeString(call->Common.dwShareMode), call->Common.dwShareMode,
- SCardGetProtocolString(call->Common.dwPreferredProtocols), call->Common.dwPreferredProtocols);
+ SCardGetProtocolString(call->Common.dwPreferredProtocols),
+ call->Common.dwPreferredProtocols);
WLog_DBG(TAG, "}");
free(szReaderA);
}
@@ -1065,13 +1086,13 @@ LONG smartcard_pack_connect_return(SMARTCARD_DEVICE* smartcard, wStream* s, Conn
if ((status = smartcard_pack_redir_scard_context(smartcard, s, &(ret->hContext))))
{
- WLog_ERR(TAG, "smartcard_pack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_pack_redir_scard_handle(smartcard, s, &(ret->hCard))))
{
- WLog_ERR(TAG, "smartcard_pack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
@@ -1079,12 +1100,14 @@ LONG smartcard_pack_connect_return(SMARTCARD_DEVICE* smartcard, wStream* s, Conn
if ((status = smartcard_pack_redir_scard_context_ref(smartcard, s, &(ret->hContext))))
{
- WLog_ERR(TAG, "smartcard_pack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_pack_redir_scard_handle_ref(smartcard, s, &(ret->hCard))))
- WLog_ERR(TAG, "smartcard_pack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1098,37 +1121,39 @@ void smartcard_trace_connect_return(SMARTCARD_DEVICE* smartcard, const Connect_R
return;
WLog_DBG(TAG, "Connect_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- pb = (BYTE*) & (ret->hContext.pbContext);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ pb = (BYTE*)&(ret->hContext.pbContext);
if (ret->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], ret->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], ret->hContext.cbContext);
}
- pb = (BYTE*) & (ret->hCard.pbHandle);
+ pb = (BYTE*)&(ret->hCard.pbHandle);
if (ret->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], ret->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], ret->hCard.cbHandle);
}
- WLog_DBG(TAG, "dwActiveProtocol: %s (0x%08"PRIX32")",
+ WLog_DBG(TAG, "dwActiveProtocol: %s (0x%08" PRIX32 ")",
SCardGetProtocolString(ret->dwActiveProtocol), ret->dwActiveProtocol);
WLog_DBG(TAG, "}");
}
@@ -1139,35 +1164,36 @@ LONG smartcard_unpack_reconnect_call(SMARTCARD_DEVICE* smartcard, wStream* s, Re
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "Reconnect_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Reconnect_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->dwShareMode); /* dwShareMode (4 bytes) */
+ Stream_Read_UINT32(s, call->dwShareMode); /* dwShareMode (4 bytes) */
Stream_Read_UINT32(s, call->dwPreferredProtocols); /* dwPreferredProtocols (4 bytes) */
- Stream_Read_UINT32(s, call->dwInitialization); /* dwInitialization (4 bytes) */
+ Stream_Read_UINT32(s, call->dwInitialization); /* dwInitialization (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1181,36 +1207,39 @@ void smartcard_trace_reconnect_call(SMARTCARD_DEVICE* smartcard, const Reconnect
return;
WLog_DBG(TAG, "Reconnect_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
WLog_DBG(TAG,
- "dwShareMode: %s (0x%08"PRIX32") dwPreferredProtocols: %s (0x%08"PRIX32") dwInitialization: %s (0x%08"PRIX32")",
+ "dwShareMode: %s (0x%08" PRIX32 ") dwPreferredProtocols: %s (0x%08" PRIX32
+ ") dwInitialization: %s (0x%08" PRIX32 ")",
SCardGetShareModeString(call->dwShareMode), call->dwShareMode,
SCardGetProtocolString(call->dwPreferredProtocols), call->dwPreferredProtocols,
SCardGetDispositionString(call->dwInitialization), call->dwInitialization);
@@ -1232,33 +1261,33 @@ void smartcard_trace_reconnect_return(SMARTCARD_DEVICE* smartcard, const Reconne
return;
WLog_DBG(TAG, "Reconnect_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "dwActiveProtocol: %s (0x%08"PRIX32")",
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "dwActiveProtocol: %s (0x%08" PRIX32 ")",
SCardGetProtocolString(ret->dwActiveProtocol), ret->dwActiveProtocol);
WLog_DBG(TAG, "}");
}
LONG smartcard_unpack_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- HCardAndDisposition_Call* call)
+ HCardAndDisposition_Call* call)
{
LONG status;
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "HCardAndDisposition_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "HCardAndDisposition_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1267,18 +1296,20 @@ LONG smartcard_unpack_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard, wS
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
void smartcard_trace_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard,
- HCardAndDisposition_Call* call, const char* name)
+ HCardAndDisposition_Call* call, const char* name)
{
BYTE* pb;
WINPR_UNUSED(smartcard);
@@ -1287,41 +1318,43 @@ void smartcard_trace_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "%s_Call {", name);
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
- WLog_DBG(TAG, "dwDisposition: %s (0x%08"PRIX32")",
+ WLog_DBG(TAG, "dwDisposition: %s (0x%08" PRIX32 ")",
SCardGetDispositionString(call->dwDisposition), call->dwDisposition);
WLog_DBG(TAG, "}");
}
LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChangeA_Call* call)
+ GetStatusChangeA_Call* call)
{
UINT32 index;
UINT32 count;
@@ -1335,30 +1368,31 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
- Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
+ Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
+ Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
Stream_Read_UINT32(s, rgReaderStatesNdrPtr); /* rgReaderStatesNdrPtr (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1368,14 +1402,16 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
if (count != call->cReaders)
{
WLog_WARN(TAG,
- "GetStatusChangeA_Call unexpected reader count: Actual: %"PRIu32", Expected: %"PRIu32"",
+ "GetStatusChangeA_Call unexpected reader count: Actual: %" PRIu32
+ ", Expected: %" PRIu32 "",
count, call->cReaders);
return STATUS_INVALID_PARAMETER;
}
if (call->cReaders > 0)
{
- call->rgReaderStates = (LPSCARD_READERSTATEA) calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
+ call->rgReaderStates =
+ (LPSCARD_READERSTATEA)calloc(call->cReaders, sizeof(SCARD_READERSTATEA));
if (!call->rgReaderStates)
{
@@ -1389,17 +1425,17 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
if (Stream_GetRemainingLength(s) < 52)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
- Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
- Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
- Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
- Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
+ Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
+ Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
+ Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
+ Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
}
for (index = 0; index < call->cReaders; index++)
@@ -1408,23 +1444,23 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, maxCount); /* NdrMaxCount (4 bytes) */
- Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
- Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
+ Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
+ Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
if (Stream_GetRemainingLength(s) < count)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- readerState->szReader = (LPCSTR) malloc(count + 1);
+ readerState->szReader = (LPCSTR)malloc(count + 1);
if (!readerState->szReader)
{
@@ -1432,9 +1468,9 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
return STATUS_NO_MEMORY;
}
- Stream_Read(s, (void*) readerState->szReader, count);
+ Stream_Read(s, (void*)readerState->szReader, count);
smartcard_unpack_read_size_align(smartcard, s, count, 4);
- ((char*) readerState->szReader)[count] = '\0';
+ ((char*)readerState->szReader)[count] = '\0';
if (!readerState->szReader)
{
@@ -1448,7 +1484,7 @@ LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStr
}
void smartcard_trace_get_status_change_a_call(SMARTCARD_DEVICE* smartcard,
- const GetStatusChangeA_Call* call)
+ const GetStatusChangeA_Call* call)
{
BYTE* pb;
UINT32 index;
@@ -1461,34 +1497,35 @@ void smartcard_trace_get_status_change_a_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "GetStatusChangeA_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- WLog_DBG(TAG, "dwTimeOut: 0x%08"PRIX32" cReaders: %"PRIu32"",
- call->dwTimeOut, call->cReaders);
+ WLog_DBG(TAG, "dwTimeOut: 0x%08" PRIX32 " cReaders: %" PRIu32 "", call->dwTimeOut,
+ call->cReaders);
for (index = 0; index < call->cReaders; index++)
{
readerState = &call->rgReaderStates[index];
- WLog_DBG(TAG, "\t[%"PRIu32"]: szReader: %s cbAtr: %"PRIu32"",
- index, readerState->szReader, readerState->cbAtr);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index,
+ readerState->szReader, readerState->cbAtr);
szCurrentState = SCardGetReaderStateString(readerState->dwCurrentState);
szEventState = SCardGetReaderStateString(readerState->dwEventState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwCurrentState: %s (0x%08"PRIX32")",
- index, szCurrentState, readerState->dwCurrentState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwEventState: %s (0x%08"PRIX32")",
- index, szEventState, readerState->dwEventState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwCurrentState: %s (0x%08" PRIX32 ")", index,
+ szCurrentState, readerState->dwCurrentState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwEventState: %s (0x%08" PRIX32 ")", index, szEventState,
+ readerState->dwEventState);
free(szCurrentState);
free(szEventState);
}
@@ -1497,7 +1534,7 @@ void smartcard_trace_get_status_change_a_call(SMARTCARD_DEVICE* smartcard,
}
LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChangeW_Call* call)
+ GetStatusChangeW_Call* call)
{
UINT32 index;
UINT32 count;
@@ -1511,30 +1548,31 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
- Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
+ Stream_Read_UINT32(s, call->dwTimeOut); /* dwTimeOut (4 bytes) */
+ Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
Stream_Read_UINT32(s, rgReaderStatesNdrPtr); /* rgReaderStatesNdrPtr (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1543,7 +1581,8 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
if (call->cReaders > 0)
{
- call->rgReaderStates = (LPSCARD_READERSTATEW) calloc(call->cReaders, sizeof(SCARD_READERSTATEW));
+ call->rgReaderStates =
+ (LPSCARD_READERSTATEW)calloc(call->cReaders, sizeof(SCARD_READERSTATEW));
if (!call->rgReaderStates)
{
@@ -1557,17 +1596,17 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
if (Stream_GetRemainingLength(s) < 52)
{
- WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, szReaderNdrPtr); /* (4 bytes) */
+ Stream_Read_UINT32(s, szReaderNdrPtr); /* (4 bytes) */
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
- Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
- Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
- Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
- Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
+ Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
+ Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
+ Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
+ Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
}
for (index = 0; index < call->cReaders; index++)
@@ -1576,23 +1615,23 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, maxCount); /* NdrMaxCount (4 bytes) */
- Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
- Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
+ Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
+ Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
if (Stream_GetRemainingLength(s) < (count * 2))
{
- WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeW_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- readerState->szReader = (WCHAR*) calloc((count + 1), 2);
+ readerState->szReader = (WCHAR*)calloc((count + 1), 2);
if (!readerState->szReader)
{
@@ -1600,9 +1639,9 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
return STATUS_NO_MEMORY;
}
- Stream_Read(s, (void*) readerState->szReader, (count * 2));
+ Stream_Read(s, (void*)readerState->szReader, (count * 2));
smartcard_unpack_read_size_align(smartcard, s, (count * 2), 4);
- ((WCHAR*) readerState->szReader)[count] = '\0';
+ ((WCHAR*)readerState->szReader)[count] = '\0';
if (!readerState->szReader)
{
@@ -1616,7 +1655,7 @@ LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStr
}
void smartcard_trace_get_status_change_w_call(SMARTCARD_DEVICE* smartcard,
- GetStatusChangeW_Call* call)
+ GetStatusChangeW_Call* call)
{
BYTE* pb;
UINT32 index;
@@ -1629,36 +1668,37 @@ void smartcard_trace_get_status_change_w_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "GetStatusChangeW_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- WLog_DBG(TAG, "dwTimeOut: 0x%08"PRIX32" cReaders: %"PRIu32"",
- call->dwTimeOut, call->cReaders);
+ WLog_DBG(TAG, "dwTimeOut: 0x%08" PRIX32 " cReaders: %" PRIu32 "", call->dwTimeOut,
+ call->cReaders);
for (index = 0; index < call->cReaders; index++)
{
char* szReaderA = NULL;
readerState = &call->rgReaderStates[index];
ConvertFromUnicode(CP_UTF8, 0, readerState->szReader, -1, &szReaderA, 0, NULL, NULL);
- WLog_DBG(TAG, "\t[%"PRIu32"]: szReader: %s cbAtr: %"PRIu32"",
- index, szReaderA, readerState->cbAtr);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index, szReaderA,
+ readerState->cbAtr);
szCurrentState = SCardGetReaderStateString(readerState->dwCurrentState);
szEventState = SCardGetReaderStateString(readerState->dwEventState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwCurrentState: %s (0x%08"PRIX32")",
- index, szCurrentState, readerState->dwCurrentState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwEventState: %s (0x%08"PRIX32")",
- index, szEventState, readerState->dwEventState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwCurrentState: %s (0x%08" PRIX32 ")", index,
+ szCurrentState, readerState->dwCurrentState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwEventState: %s (0x%08" PRIX32 ")", index, szEventState,
+ readerState->dwEventState);
free(szCurrentState);
free(szEventState);
free(szReaderA);
@@ -1668,30 +1708,30 @@ void smartcard_trace_get_status_change_w_call(SMARTCARD_DEVICE* smartcard,
}
LONG smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChange_Return* ret)
+ GetStatusChange_Return* ret)
{
UINT32 index;
ReaderState_Return* rgReaderState;
WINPR_UNUSED(smartcard);
Stream_Write_UINT32(s, ret->cReaders); /* cReaders (4 bytes) */
- Stream_Write_UINT32(s, 0x00020100); /* rgReaderStatesNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, 0x00020100); /* rgReaderStatesNdrPtr (4 bytes) */
Stream_Write_UINT32(s, ret->cReaders); /* rgReaderStatesNdrCount (4 bytes) */
for (index = 0; index < ret->cReaders; index++)
{
rgReaderState = &(ret->rgReaderStates[index]);
Stream_Write_UINT32(s, rgReaderState->dwCurrentState); /* dwCurrentState (4 bytes) */
- Stream_Write_UINT32(s, rgReaderState->dwEventState); /* dwEventState (4 bytes) */
- Stream_Write_UINT32(s, rgReaderState->cbAtr); /* cbAtr (4 bytes) */
- Stream_Write(s, rgReaderState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
- Stream_Zero(s, 4); /* rgbAtr [32..36] (32 bytes) */
+ Stream_Write_UINT32(s, rgReaderState->dwEventState); /* dwEventState (4 bytes) */
+ Stream_Write_UINT32(s, rgReaderState->cbAtr); /* cbAtr (4 bytes) */
+ Stream_Write(s, rgReaderState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
+ Stream_Zero(s, 4); /* rgbAtr [32..36] (32 bytes) */
}
return SCARD_S_SUCCESS;
}
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard,
- const GetStatusChange_Return* ret, BOOL unicode)
+ const GetStatusChange_Return* ret, BOOL unicode)
{
UINT32 index;
char* rgbAtr;
@@ -1704,22 +1744,22 @@ void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "GetStatusChange%s_Return {", unicode ? "W" : "A");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "cReaders: %"PRIu32"", ret->cReaders);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "cReaders: %" PRIu32 "", ret->cReaders);
for (index = 0; index < ret->cReaders; index++)
{
rgReaderState = &(ret->rgReaderStates[index]);
szCurrentState = SCardGetReaderStateString(rgReaderState->dwCurrentState);
szEventState = SCardGetReaderStateString(rgReaderState->dwEventState);
- rgbAtr = winpr_BinToHexString((BYTE*) & (rgReaderState->rgbAtr), rgReaderState->cbAtr, FALSE);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwCurrentState: %s (0x%08"PRIX32")",
- index, szCurrentState, rgReaderState->dwCurrentState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwEventState: %s (0x%08"PRIX32")",
- index, szEventState, rgReaderState->dwEventState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: cbAtr: %"PRIu32" rgbAtr: %s",
- index, rgReaderState->cbAtr, rgbAtr);
+ rgbAtr = winpr_BinToHexString((BYTE*)&(rgReaderState->rgbAtr), rgReaderState->cbAtr, FALSE);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwCurrentState: %s (0x%08" PRIX32 ")", index,
+ szCurrentState, rgReaderState->dwCurrentState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwEventState: %s (0x%08" PRIX32 ")", index, szEventState,
+ rgReaderState->dwEventState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: cbAtr: %" PRIu32 " rgbAtr: %s", index, rgReaderState->cbAtr,
+ rgbAtr);
free(szCurrentState);
free(szEventState);
free(rgbAtr);
@@ -1734,34 +1774,35 @@ LONG smartcard_unpack_state_call(SMARTCARD_DEVICE* smartcard, wStream* s, State_
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 8)
{
- WLog_WARN(TAG, "State_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "State_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, call->fpbAtrIsNULL); /* fpbAtrIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cbAtrLen); /* cbAtrLen (4 bytes) */
+ Stream_Read_UINT32(s, call->cbAtrLen); /* cbAtrLen (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1769,15 +1810,15 @@ LONG smartcard_unpack_state_call(SMARTCARD_DEVICE* smartcard, wStream* s, State_
LONG smartcard_pack_state_return(SMARTCARD_DEVICE* smartcard, wStream* s, State_Return* ret)
{
LONG status;
- Stream_Write_UINT32(s, ret->dwState); /* dwState (4 bytes) */
- Stream_Write_UINT32(s, ret->dwProtocol); /* dwProtocol (4 bytes) */
- Stream_Write_UINT32(s, ret->cbAtrLen); /* cbAtrLen (4 bytes) */
- Stream_Write_UINT32(s, 0x00020020); /* rgAtrNdrPtr (4 bytes) */
- Stream_Write_UINT32(s, ret->cbAtrLen); /* rgAtrLength (4 bytes) */
+ Stream_Write_UINT32(s, ret->dwState); /* dwState (4 bytes) */
+ Stream_Write_UINT32(s, ret->dwProtocol); /* dwProtocol (4 bytes) */
+ Stream_Write_UINT32(s, ret->cbAtrLen); /* cbAtrLen (4 bytes) */
+ Stream_Write_UINT32(s, 0x00020020); /* rgAtrNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, ret->cbAtrLen); /* rgAtrLength (4 bytes) */
Stream_Write(s, ret->rgAtr, ret->cbAtrLen); /* rgAtr */
if ((status = smartcard_pack_write_size_align(smartcard, s, ret->cbAtrLen, 4)))
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "", status);
return status;
}
@@ -1788,35 +1829,36 @@ LONG smartcard_unpack_status_call(SMARTCARD_DEVICE* smartcard, wStream* s, Statu
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "Status_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Status_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, call->fmszReaderNamesIsNULL); /* fmszReaderNamesIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cchReaderLen); /* cchReaderLen (4 bytes) */
- Stream_Read_UINT32(s, call->cbAtrLen); /* cbAtrLen (4 bytes) */
+ Stream_Read_UINT32(s, call->cchReaderLen); /* cchReaderLen (4 bytes) */
+ Stream_Read_UINT32(s, call->cbAtrLen); /* cbAtrLen (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -1830,35 +1872,38 @@ void smartcard_trace_status_call(SMARTCARD_DEVICE* smartcard, const Status_Call*
return;
WLog_DBG(TAG, "Status%s_Call {", unicode ? "W" : "A");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
- WLog_DBG(TAG, "fmszReaderNamesIsNULL: %"PRId32" cchReaderLen: %"PRIu32" cbAtrLen: %"PRIu32"",
+ WLog_DBG(TAG,
+ "fmszReaderNamesIsNULL: %" PRId32 " cchReaderLen: %" PRIu32 " cbAtrLen: %" PRIu32 "",
call->fmszReaderNamesIsNULL, call->cchReaderLen, call->cbAtrLen);
WLog_DBG(TAG, "}");
}
@@ -1873,13 +1918,13 @@ LONG smartcard_pack_status_return(SMARTCARD_DEVICE* smartcard, wStream* s, Statu
return SCARD_F_INTERNAL_ERROR;
}
- Stream_Write_UINT32(s, ret->cBytes); /* cBytes (4 bytes) */
- Stream_Write_UINT32(s, 0x00020010); /* mszReaderNamesNdrPtr (4 bytes) */
- Stream_Write_UINT32(s, ret->dwState); /* dwState (4 bytes) */
+ Stream_Write_UINT32(s, ret->cBytes); /* cBytes (4 bytes) */
+ Stream_Write_UINT32(s, 0x00020010); /* mszReaderNamesNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, ret->dwState); /* dwState (4 bytes) */
Stream_Write_UINT32(s, ret->dwProtocol); /* dwProtocol (4 bytes) */
- Stream_Write(s, ret->pbAtr, 32); /* pbAtr (32 bytes) */
- Stream_Write_UINT32(s, ret->cbAtrLen); /* cbAtrLen (4 bytes) */
- Stream_Write_UINT32(s, ret->cBytes); /* mszReaderNamesNdrLen (4 bytes) */
+ Stream_Write(s, ret->pbAtr, 32); /* pbAtr (32 bytes) */
+ Stream_Write_UINT32(s, ret->cbAtrLen); /* cbAtrLen (4 bytes) */
+ Stream_Write_UINT32(s, ret->cBytes); /* mszReaderNamesNdrLen (4 bytes) */
if (ret->mszReaderNames)
Stream_Write(s, ret->mszReaderNames, ret->cBytes);
@@ -1887,12 +1932,13 @@ LONG smartcard_pack_status_return(SMARTCARD_DEVICE* smartcard, wStream* s, Statu
Stream_Zero(s, ret->cBytes);
if ((status = smartcard_pack_write_size_align(smartcard, s, ret->cBytes, 4)))
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "", status);
return status;
}
-void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Return* ret, BOOL unicode)
+void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Return* ret,
+ BOOL unicode)
{
size_t index;
size_t length;
@@ -1909,7 +1955,7 @@ void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Ret
{
length = ret->cBytes / 2;
- if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) ret->mszReaderNames, (int) length,
+ if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)ret->mszReaderNames, (int)length,
&mszReaderNamesA, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "ConvertFromUnicode failed");
@@ -1918,8 +1964,8 @@ void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Ret
}
else
{
- length = (int) ret->cBytes;
- mszReaderNamesA = (char*) malloc(length);
+ length = (int)ret->cBytes;
+ mszReaderNamesA = (char*)malloc(length);
if (!mszReaderNamesA)
{
@@ -1944,19 +1990,18 @@ void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Ret
pbAtr = winpr_BinToHexString(ret->pbAtr, ret->cbAtrLen, FALSE);
WLog_DBG(TAG, "Status%s_Return {", unicode ? "W" : "A");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "dwState: %s (0x%08"PRIX32") dwProtocol: %s (0x%08"PRIX32")",
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "dwState: %s (0x%08" PRIX32 ") dwProtocol: %s (0x%08" PRIX32 ")",
SCardGetCardStateString(ret->dwState), ret->dwState,
SCardGetProtocolString(ret->dwProtocol), ret->dwProtocol);
if (mszReaderNamesA)
{
- WLog_DBG(TAG, "cBytes: %"PRIu32" mszReaderNames: %s",
- ret->cBytes, mszReaderNamesA);
+ WLog_DBG(TAG, "cBytes: %" PRIu32 " mszReaderNames: %s", ret->cBytes, mszReaderNamesA);
}
- WLog_DBG(TAG, "cbAtrLen: %"PRIu32" pbAtr: %s", ret->cbAtrLen, pbAtr);
+ WLog_DBG(TAG, "cbAtrLen: %" PRIu32 " pbAtr: %s", ret->cbAtrLen, pbAtr);
WLog_DBG(TAG, "}");
free(mszReaderNamesA);
free(pbAtr);
@@ -1968,35 +2013,36 @@ LONG smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s, G
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetAttrib_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "GetAttrib_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->dwAttrId); /* dwAttrId (4 bytes) */
+ Stream_Read_UINT32(s, call->dwAttrId); /* dwAttrId (4 bytes) */
Stream_Read_UINT32(s, call->fpbAttrIsNULL); /* fpbAttrIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cbAttrLen); /* cbAttrLen (4 bytes) */
+ Stream_Read_UINT32(s, call->cbAttrLen); /* cbAttrLen (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -2010,36 +2056,40 @@ void smartcard_trace_get_attrib_call(SMARTCARD_DEVICE* smartcard, GetAttrib_Call
return;
WLog_DBG(TAG, "GetAttrib_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
- WLog_DBG(TAG, "dwAttrId: %s (0x%08"PRIX32") fpbAttrIsNULL: %"PRId32" cbAttrLen: 0x%08"PRIX32"",
- SCardGetAttributeString(call->dwAttrId), call->dwAttrId, call->fpbAttrIsNULL, call->cbAttrLen);
+ WLog_DBG(TAG,
+ "dwAttrId: %s (0x%08" PRIX32 ") fpbAttrIsNULL: %" PRId32 " cbAttrLen: 0x%08" PRIX32 "",
+ SCardGetAttributeString(call->dwAttrId), call->dwAttrId, call->fpbAttrIsNULL,
+ call->cbAttrLen);
WLog_DBG(TAG, "}");
}
@@ -2055,7 +2105,7 @@ LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s,
}
Stream_Write_UINT32(s, ret->cbAttrLen); /* cbAttrLen (4 bytes) */
- Stream_Write_UINT32(s, 0x00020080); /* pbAttrNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, 0x00020080); /* pbAttrNdrPtr (4 bytes) */
Stream_Write_UINT32(s, ret->cbAttrLen); /* pbAttrNdrCount (4 bytes) */
if (!ret->pbAttr)
@@ -2064,7 +2114,7 @@ LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s,
Stream_Write(s, ret->pbAttr, ret->cbAttrLen); /* pbAttr */
if ((status = smartcard_pack_write_size_align(smartcard, s, ret->cbAttrLen, 4)))
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "", status);
return status;
}
@@ -2078,19 +2128,19 @@ void smartcard_trace_get_attrib_return(SMARTCARD_DEVICE* smartcard, const GetAtt
return;
WLog_DBG(TAG, "GetAttrib_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "dwAttrId: %s (0x%08"PRIX32") cbAttrLen: 0x%08"PRIX32"",
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "dwAttrId: %s (0x%08" PRIX32 ") cbAttrLen: 0x%08" PRIX32 "",
SCardGetAttributeString(dwAttrId), dwAttrId, ret->cbAttrLen);
if (dwAttrId == SCARD_ATTR_VENDOR_NAME)
{
- WLog_DBG(TAG, "pbAttr: %.*s", ret->cbAttrLen, (char*) ret->pbAttr);
+ WLog_DBG(TAG, "pbAttr: %.*s", ret->cbAttrLen, (char*)ret->pbAttr);
}
else if (dwAttrId == SCARD_ATTR_CURRENT_PROTOCOL_TYPE)
{
- UINT32 dwProtocolType = *((UINT32*) ret->pbAttr);
- WLog_DBG(TAG, "dwProtocolType: %s (0x%08"PRIX32")",
+ UINT32 dwProtocolType = *((UINT32*)ret->pbAttr);
+ WLog_DBG(TAG, "dwProtocolType: %s (0x%08" PRIX32 ")",
SCardGetProtocolString(dwProtocolType), dwProtocolType);
}
@@ -2105,38 +2155,39 @@ LONG smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 20)
{
- WLog_WARN(TAG, "Control_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Control_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, call->dwControlCode); /* dwControlCode (4 bytes) */
- Stream_Read_UINT32(s, call->cbInBufferSize); /* cbInBufferSize (4 bytes) */
- Stream_Seek_UINT32(s); /* pvInBufferNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, call->dwControlCode); /* dwControlCode (4 bytes) */
+ Stream_Read_UINT32(s, call->cbInBufferSize); /* cbInBufferSize (4 bytes) */
+ Stream_Seek_UINT32(s); /* pvInBufferNdrPtr (4 bytes) */
Stream_Read_UINT32(s, call->fpvOutBufferIsNULL); /* fpvOutBufferIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cbOutBufferSize); /* cbOutBufferSize (4 bytes) */
+ Stream_Read_UINT32(s, call->cbOutBufferSize); /* cbOutBufferSize (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
@@ -2144,8 +2195,7 @@ LONG smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
{
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "Control_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Control_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2153,12 +2203,11 @@ LONG smartcard_unpack_control_call(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
if (Stream_GetRemainingLength(s) < length)
{
- WLog_WARN(TAG, "Control_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Control_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- call->pvInBuffer = (BYTE*) malloc(length);
+ call->pvInBuffer = (BYTE*)malloc(length);
if (!call->pvInBuffer)
{
@@ -2182,37 +2231,41 @@ void smartcard_trace_control_call(SMARTCARD_DEVICE* smartcard, const Control_Cal
return;
WLog_DBG(TAG, "Control_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
WLog_DBG(TAG,
- "dwControlCode: 0x%08"PRIX32" cbInBufferSize: %"PRIu32" fpvOutBufferIsNULL: %"PRId32" cbOutBufferSize: %"PRIu32"",
- call->dwControlCode, call->cbInBufferSize, call->fpvOutBufferIsNULL, call->cbOutBufferSize);
+ "dwControlCode: 0x%08" PRIX32 " cbInBufferSize: %" PRIu32
+ " fpvOutBufferIsNULL: %" PRId32 " cbOutBufferSize: %" PRIu32 "",
+ call->dwControlCode, call->cbInBufferSize, call->fpvOutBufferIsNULL,
+ call->cbOutBufferSize);
if (call->pvInBuffer)
{
@@ -2239,7 +2292,7 @@ LONG smartcard_pack_control_return(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
}
Stream_Write_UINT32(s, ret->cbOutBufferSize); /* cbOutBufferSize (4 bytes) */
- Stream_Write_UINT32(s, 0x00020040); /* pvOutBufferPointer (4 bytes) */
+ Stream_Write_UINT32(s, 0x00020040); /* pvOutBufferPointer (4 bytes) */
Stream_Write_UINT32(s, ret->cbOutBufferSize); /* pvOutBufferLength (4 bytes) */
if (ret->cbOutBufferSize > 0)
@@ -2248,7 +2301,7 @@ LONG smartcard_pack_control_return(SMARTCARD_DEVICE* smartcard, wStream* s, Cont
if ((error = smartcard_pack_write_size_align(smartcard, s, ret->cbOutBufferSize, 4)))
{
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"", error);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "", error);
return error;
}
}
@@ -2264,9 +2317,9 @@ void smartcard_trace_control_return(SMARTCARD_DEVICE* smartcard, const Control_R
return;
WLog_DBG(TAG, "Control_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
- WLog_DBG(TAG, "cbOutBufferSize: %"PRIu32"", ret->cbOutBufferSize);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
+ WLog_DBG(TAG, "cbOutBufferSize: %" PRIu32 "", ret->cbOutBufferSize);
if (ret->pvOutBuffer)
{
@@ -2298,61 +2351,65 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 32)
{
- WLog_WARN(TAG, "Transmit_Call is too short: Actual: %"PRIuz", Expected: 32",
+ WLog_WARN(TAG, "Transmit_Call is too short: Actual: %" PRIuz ", Expected: 32",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, ioSendPci.dwProtocol); /* dwProtocol (4 bytes) */
- Stream_Read_UINT32(s, ioSendPci.cbExtraBytes); /* cbExtraBytes (4 bytes) */
- Stream_Read_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
- Stream_Read_UINT32(s, call->cbSendLength); /* cbSendLength (4 bytes) */
- Stream_Read_UINT32(s, pbSendBufferNdrPtr); /* pbSendBufferNdrPtr (4 bytes) */
- Stream_Read_UINT32(s, pioRecvPciNdrPtr); /* pioRecvPciNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, ioSendPci.dwProtocol); /* dwProtocol (4 bytes) */
+ Stream_Read_UINT32(s, ioSendPci.cbExtraBytes); /* cbExtraBytes (4 bytes) */
+ Stream_Read_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, call->cbSendLength); /* cbSendLength (4 bytes) */
+ Stream_Read_UINT32(s, pbSendBufferNdrPtr); /* pbSendBufferNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, pioRecvPciNdrPtr); /* pioRecvPciNdrPtr (4 bytes) */
Stream_Read_UINT32(s, call->fpbRecvBufferIsNULL); /* fpbRecvBufferIsNULL (4 bytes) */
- Stream_Read_UINT32(s, call->cbRecvLength); /* cbRecvLength (4 bytes) */
+ Stream_Read_UINT32(s, call->cbRecvLength); /* cbRecvLength (4 bytes) */
if (ioSendPci.cbExtraBytes > 1024)
{
- WLog_WARN(TAG, "Transmit_Call ioSendPci.cbExtraBytes is out of bounds: %"PRIu32" (max: 1024)",
+ WLog_WARN(TAG,
+ "Transmit_Call ioSendPci.cbExtraBytes is out of bounds: %" PRIu32 " (max: 1024)",
ioSendPci.cbExtraBytes);
return STATUS_INVALID_PARAMETER;
}
if (call->cbSendLength > 66560)
{
- WLog_WARN(TAG, "Transmit_Call cbSendLength is out of bounds: %"PRIu32" (max: 66560)",
+ WLog_WARN(TAG, "Transmit_Call cbSendLength is out of bounds: %" PRIu32 " (max: 66560)",
ioSendPci.cbExtraBytes);
return STATUS_INVALID_PARAMETER;
}
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if ((status = smartcard_unpack_redir_scard_handle_ref(smartcard, s, &(call->hCard))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_handle_ref failed with error %" PRId32 "",
+ status);
return status;
}
if (ioSendPci.cbExtraBytes && !pbExtraBytesNdrPtr)
{
- WLog_WARN(TAG, "Transmit_Call ioSendPci.cbExtraBytes is non-zero but pbExtraBytesNdrPtr is null");
+ WLog_WARN(
+ TAG, "Transmit_Call ioSendPci.cbExtraBytes is non-zero but pbExtraBytesNdrPtr is null");
return STATUS_INVALID_PARAMETER;
}
@@ -2360,7 +2417,7 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
{
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "Transmit_Call is too short: %"PRIuz" (ioSendPci.pbExtraBytes)",
+ WLog_WARN(TAG, "Transmit_Call is too short: %" PRIuz " (ioSendPci.pbExtraBytes)",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2370,13 +2427,15 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if (Stream_GetRemainingLength(s) < ioSendPci.cbExtraBytes)
{
WLog_WARN(TAG,
- "Transmit_Call is too short: Actual: %"PRIuz", Expected: %"PRIu32" (ioSendPci.cbExtraBytes)",
+ "Transmit_Call is too short: Actual: %" PRIuz ", Expected: %" PRIu32
+ " (ioSendPci.cbExtraBytes)",
Stream_GetRemainingLength(s), ioSendPci.cbExtraBytes);
return STATUS_BUFFER_TOO_SMALL;
}
ioSendPci.pbExtraBytes = Stream_Pointer(s);
- call->pioSendPci = (LPSCARD_IO_REQUEST) malloc(sizeof(SCARD_IO_REQUEST) + ioSendPci.cbExtraBytes);
+ call->pioSendPci =
+ (LPSCARD_IO_REQUEST)malloc(sizeof(SCARD_IO_REQUEST) + ioSendPci.cbExtraBytes);
if (!call->pioSendPci)
{
@@ -2386,13 +2445,13 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
call->pioSendPci->dwProtocol = ioSendPci.dwProtocol;
call->pioSendPci->cbPciLength = (DWORD)(ioSendPci.cbExtraBytes + sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) call->pioSendPci)[sizeof(SCARD_IO_REQUEST)];
+ pbExtraBytes = &((BYTE*)call->pioSendPci)[sizeof(SCARD_IO_REQUEST)];
Stream_Read(s, pbExtraBytes, ioSendPci.cbExtraBytes);
smartcard_unpack_read_size_align(smartcard, s, ioSendPci.cbExtraBytes, 4);
}
else
{
- call->pioSendPci = (LPSCARD_IO_REQUEST) calloc(1, sizeof(SCARD_IO_REQUEST));
+ call->pioSendPci = (LPSCARD_IO_REQUEST)calloc(1, sizeof(SCARD_IO_REQUEST));
if (!call->pioSendPci)
{
@@ -2408,8 +2467,7 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
{
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "Transmit_Call is too short: %"PRIuz"",
- Stream_GetRemainingLength(s));
+ WLog_WARN(TAG, "Transmit_Call is too short: %" PRIuz "", Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2418,19 +2476,22 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if (length != call->cbSendLength)
{
WLog_WARN(TAG,
- "Transmit_Call unexpected length: Actual: %"PRIu32", Expected: %"PRIu32" (cbSendLength)",
+ "Transmit_Call unexpected length: Actual: %" PRIu32 ", Expected: %" PRIu32
+ " (cbSendLength)",
length, call->cbSendLength);
return STATUS_INVALID_PARAMETER;
}
if (Stream_GetRemainingLength(s) < call->cbSendLength)
{
- WLog_WARN(TAG, "Transmit_Call is too short: Actual: %"PRIuz", Expected: %"PRIu32" (cbSendLength)",
+ WLog_WARN(TAG,
+ "Transmit_Call is too short: Actual: %" PRIuz ", Expected: %" PRIu32
+ " (cbSendLength)",
Stream_GetRemainingLength(s), call->cbSendLength);
return STATUS_BUFFER_TOO_SMALL;
}
- call->pbSendBuffer = (BYTE*) malloc(call->cbSendLength);
+ call->pbSendBuffer = (BYTE*)malloc(call->cbSendLength);
if (!call->pbSendBuffer)
{
@@ -2446,18 +2507,20 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
{
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "Transmit_Call is too short: Actual: %"PRIuz", Expected: 12",
+ WLog_WARN(TAG, "Transmit_Call is too short: Actual: %" PRIuz ", Expected: 12",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, ioRecvPci.dwProtocol); /* dwProtocol (4 bytes) */
+ Stream_Read_UINT32(s, ioRecvPci.dwProtocol); /* dwProtocol (4 bytes) */
Stream_Read_UINT32(s, ioRecvPci.cbExtraBytes); /* cbExtraBytes (4 bytes) */
- Stream_Read_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
if (ioRecvPci.cbExtraBytes && !pbExtraBytesNdrPtr)
{
- WLog_WARN(TAG, "Transmit_Call ioRecvPci.cbExtraBytes is non-zero but pbExtraBytesNdrPtr is null");
+ WLog_WARN(
+ TAG,
+ "Transmit_Call ioRecvPci.cbExtraBytes is non-zero but pbExtraBytesNdrPtr is null");
return STATUS_INVALID_PARAMETER;
}
@@ -2465,7 +2528,7 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
{
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "Transmit_Call is too short: %"PRIuz" (ioRecvPci.pbExtraBytes)",
+ WLog_WARN(TAG, "Transmit_Call is too short: %" PRIuz " (ioRecvPci.pbExtraBytes)",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2474,7 +2537,9 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if (ioRecvPci.cbExtraBytes > 1024)
{
- WLog_WARN(TAG, "Transmit_Call ioRecvPci.cbExtraBytes is out of bounds: %"PRIu32" (max: 1024)",
+ WLog_WARN(TAG,
+ "Transmit_Call ioRecvPci.cbExtraBytes is out of bounds: %" PRIu32
+ " (max: 1024)",
ioRecvPci.cbExtraBytes);
return STATUS_INVALID_PARAMETER;
}
@@ -2482,7 +2547,8 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if (length != ioRecvPci.cbExtraBytes)
{
WLog_WARN(TAG,
- "Transmit_Call unexpected length: Actual: %"PRIu32", Expected: %"PRIu32" (ioRecvPci.cbExtraBytes)",
+ "Transmit_Call unexpected length: Actual: %" PRIu32 ", Expected: %" PRIu32
+ " (ioRecvPci.cbExtraBytes)",
length, ioRecvPci.cbExtraBytes);
return STATUS_INVALID_PARAMETER;
}
@@ -2490,13 +2556,15 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if (Stream_GetRemainingLength(s) < ioRecvPci.cbExtraBytes)
{
WLog_WARN(TAG,
- "Transmit_Call is too short: Actual: %"PRIuz", Expected: %"PRIu32" (ioRecvPci.cbExtraBytes)",
+ "Transmit_Call is too short: Actual: %" PRIuz ", Expected: %" PRIu32
+ " (ioRecvPci.cbExtraBytes)",
Stream_GetRemainingLength(s), ioRecvPci.cbExtraBytes);
return STATUS_BUFFER_TOO_SMALL;
}
ioRecvPci.pbExtraBytes = Stream_Pointer(s);
- call->pioRecvPci = (LPSCARD_IO_REQUEST) malloc(sizeof(SCARD_IO_REQUEST) + ioRecvPci.cbExtraBytes);
+ call->pioRecvPci =
+ (LPSCARD_IO_REQUEST)malloc(sizeof(SCARD_IO_REQUEST) + ioRecvPci.cbExtraBytes);
if (!call->pioRecvPci)
{
@@ -2505,14 +2573,15 @@ LONG smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
}
call->pioRecvPci->dwProtocol = ioRecvPci.dwProtocol;
- call->pioRecvPci->cbPciLength = (DWORD)(ioRecvPci.cbExtraBytes + sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) call->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
+ call->pioRecvPci->cbPciLength =
+ (DWORD)(ioRecvPci.cbExtraBytes + sizeof(SCARD_IO_REQUEST));
+ pbExtraBytes = &((BYTE*)call->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
Stream_Read(s, pbExtraBytes, ioRecvPci.cbExtraBytes);
smartcard_unpack_read_size_align(smartcard, s, ioRecvPci.cbExtraBytes, 4);
}
else
{
- call->pioRecvPci = (LPSCARD_IO_REQUEST) calloc(1, sizeof(SCARD_IO_REQUEST));
+ call->pioRecvPci = (LPSCARD_IO_REQUEST)calloc(1, sizeof(SCARD_IO_REQUEST));
if (!call->pioRecvPci)
{
@@ -2539,39 +2608,41 @@ void smartcard_trace_transmit_call(SMARTCARD_DEVICE* smartcard, const Transmit_C
return;
WLog_DBG(TAG, "Transmit_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
- pb = (BYTE*) & (call->hCard.pbHandle);
+ pb = (BYTE*)&(call->hCard.pbHandle);
if (call->hCard.cbHandle > 4)
{
WLog_DBG(TAG,
- "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hCard.cbHandle);
}
else
{
- WLog_DBG(TAG, "hCard: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hCard: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hCard.cbHandle);
}
if (call->pioSendPci)
{
cbExtraBytes = (UINT32)(call->pioSendPci->cbPciLength - sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) call->pioSendPci)[sizeof(SCARD_IO_REQUEST)];
- WLog_DBG(TAG, "pioSendPci: dwProtocol: %"PRIu32" cbExtraBytes: %"PRIu32"",
+ pbExtraBytes = &((BYTE*)call->pioSendPci)[sizeof(SCARD_IO_REQUEST)];
+ WLog_DBG(TAG, "pioSendPci: dwProtocol: %" PRIu32 " cbExtraBytes: %" PRIu32 "",
call->pioSendPci->dwProtocol, cbExtraBytes);
if (cbExtraBytes)
@@ -2586,7 +2657,7 @@ void smartcard_trace_transmit_call(SMARTCARD_DEVICE* smartcard, const Transmit_C
WLog_DBG(TAG, "pioSendPci: null");
}
- WLog_DBG(TAG, "cbSendLength: %"PRIu32"", call->cbSendLength);
+ WLog_DBG(TAG, "cbSendLength: %" PRIu32 "", call->cbSendLength);
if (call->pbSendBuffer)
{
@@ -2602,8 +2673,8 @@ void smartcard_trace_transmit_call(SMARTCARD_DEVICE* smartcard, const Transmit_C
if (call->pioRecvPci)
{
cbExtraBytes = (UINT32)(call->pioRecvPci->cbPciLength - sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) call->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
- WLog_DBG(TAG, "pioRecvPci: dwProtocol: %"PRIu32" cbExtraBytes: %"PRIu32"",
+ pbExtraBytes = &((BYTE*)call->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
+ WLog_DBG(TAG, "pioRecvPci: dwProtocol: %" PRIu32 " cbExtraBytes: %" PRIu32 "",
call->pioRecvPci->dwProtocol, cbExtraBytes);
if (cbExtraBytes)
@@ -2618,7 +2689,7 @@ void smartcard_trace_transmit_call(SMARTCARD_DEVICE* smartcard, const Transmit_C
WLog_DBG(TAG, "pioRecvPci: null");
}
- WLog_DBG(TAG, "fpbRecvBufferIsNULL: %"PRId32" cbRecvLength: %"PRIu32"",
+ WLog_DBG(TAG, "fpbRecvBufferIsNULL: %" PRId32 " cbRecvLength: %" PRIu32 "",
call->fpbRecvBufferIsNULL, call->cbRecvLength);
WLog_DBG(TAG, "}");
}
@@ -2637,14 +2708,14 @@ LONG smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
pioRecvPciNdrPtr = (ret->pioRecvPci) ? 0x00020000 : 0;
pbRecvBufferNdrPtr = (ret->pbRecvBuffer) ? 0x00020004 : 0;
- Stream_Write_UINT32(s, pioRecvPciNdrPtr); /* pioRecvPciNdrPtr (4 bytes) */
- Stream_Write_UINT32(s, ret->cbRecvLength); /* cbRecvLength (4 bytes) */
+ Stream_Write_UINT32(s, pioRecvPciNdrPtr); /* pioRecvPciNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, ret->cbRecvLength); /* cbRecvLength (4 bytes) */
Stream_Write_UINT32(s, pbRecvBufferNdrPtr); /* pbRecvBufferNdrPtr (4 bytes) */
if (pioRecvPciNdrPtr)
{
cbExtraBytes = (UINT32)(ret->pioRecvPci->cbPciLength - sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) ret->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
+ pbExtraBytes = &((BYTE*)ret->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
pbExtraBytesNdrPtr = cbExtraBytes ? 0x00020008 : 0;
if (!Stream_EnsureRemainingCapacity(s, cbExtraBytes + 16))
@@ -2654,8 +2725,8 @@ LONG smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
}
Stream_Write_UINT32(s, ret->pioRecvPci->dwProtocol); /* dwProtocol (4 bytes) */
- Stream_Write_UINT32(s, cbExtraBytes); /* cbExtraBytes (4 bytes) */
- Stream_Write_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
+ Stream_Write_UINT32(s, cbExtraBytes); /* cbExtraBytes (4 bytes) */
+ Stream_Write_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
if (pbExtraBytesNdrPtr)
{
@@ -2664,7 +2735,8 @@ LONG smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if ((error = smartcard_pack_write_size_align(smartcard, s, cbExtraBytes, 4)))
{
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"!", error);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "!",
+ error);
return error;
}
}
@@ -2683,7 +2755,7 @@ LONG smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
if ((error = smartcard_pack_write_size_align(smartcard, s, ret->cbRecvLength, 4)))
{
- WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %"PRId32"!", error);
+ WLog_ERR(TAG, "smartcard_pack_write_size_align failed with error %" PRId32 "!", error);
return error;
}
}
@@ -2701,14 +2773,14 @@ void smartcard_trace_transmit_return(SMARTCARD_DEVICE* smartcard, const Transmit
return;
WLog_DBG(TAG, "Transmit_Return {");
- WLog_DBG(TAG, "ReturnCode: %s (0x%08"PRIX32")",
- SCardGetErrorString(ret->ReturnCode), ret->ReturnCode);
+ WLog_DBG(TAG, "ReturnCode: %s (0x%08" PRIX32 ")", SCardGetErrorString(ret->ReturnCode),
+ ret->ReturnCode);
if (ret->pioRecvPci)
{
cbExtraBytes = (UINT32)(ret->pioRecvPci->cbPciLength - sizeof(SCARD_IO_REQUEST));
- pbExtraBytes = &((BYTE*) ret->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
- WLog_DBG(TAG, "pioRecvPci: dwProtocol: %"PRIu32" cbExtraBytes: %"PRIu32"",
+ pbExtraBytes = &((BYTE*)ret->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
+ WLog_DBG(TAG, "pioRecvPci: dwProtocol: %" PRIu32 " cbExtraBytes: %" PRIu32 "",
ret->pioRecvPci->dwProtocol, cbExtraBytes);
if (cbExtraBytes)
@@ -2723,7 +2795,7 @@ void smartcard_trace_transmit_return(SMARTCARD_DEVICE* smartcard, const Transmit
WLog_DBG(TAG, "pioRecvPci: null");
}
- WLog_DBG(TAG, "cbRecvLength: %"PRIu32"", ret->cbRecvLength);
+ WLog_DBG(TAG, "cbRecvLength: %" PRIu32 "", ret->cbRecvLength);
if (ret->pbRecvBuffer)
{
@@ -2740,7 +2812,7 @@ void smartcard_trace_transmit_return(SMARTCARD_DEVICE* smartcard, const Transmit
}
LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- LocateCardsByATRA_Call* call)
+ LocateCardsByATRA_Call* call)
{
UINT32 index;
UINT32 count;
@@ -2755,31 +2827,32 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
if ((status = smartcard_unpack_redir_scard_context(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context failed with error %" PRId32 "", status);
return status;
}
if (Stream_GetRemainingLength(s) < 16)
{
- WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, call->cAtrs);
Stream_Read_UINT32(s, rgAtrMasksNdrPtr);
- Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
+ Stream_Read_UINT32(s, call->cReaders); /* cReaders (4 bytes) */
Stream_Read_UINT32(s, rgReaderStatesNdrPtr); /* rgReaderStatesNdrPtr (4 bytes) */
if ((status = smartcard_unpack_redir_scard_context_ref(smartcard, s, &(call->hContext))))
{
- WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %"PRId32"", status);
+ WLog_ERR(TAG, "smartcard_unpack_redir_scard_context_ref failed with error %" PRId32 "",
+ status);
return status;
}
if (Stream_GetRemainingLength(s) < 4)
{
- WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2787,7 +2860,8 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
if ((rgAtrMasksNdrPtr && !call->cAtrs) || (!rgAtrMasksNdrPtr && call->cAtrs))
{
WLog_WARN(TAG,
- "LocateCardsByATRA_Call rgAtrMasksNdrPtr (0x%08"PRIX32") and cAtrs (0x%08"PRIX32") inconsistency",
+ "LocateCardsByATRA_Call rgAtrMasksNdrPtr (0x%08" PRIX32
+ ") and cAtrs (0x%08" PRIX32 ") inconsistency",
rgAtrMasksNdrPtr, call->cAtrs);
return STATUS_INVALID_PARAMETER;
}
@@ -2799,14 +2873,17 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
if (count != call->cAtrs)
{
WLog_WARN(TAG,
- "LocateCardsByATRA_Call NdrCount (0x%08"PRIX32") and cAtrs (0x%08"PRIX32") inconsistency",
+ "LocateCardsByATRA_Call NdrCount (0x%08" PRIX32 ") and cAtrs (0x%08" PRIX32
+ ") inconsistency",
count, call->cAtrs);
return STATUS_INVALID_PARAMETER;
}
if (Stream_GetRemainingLength(s) < call->cAtrs)
{
- WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: Actual: %"PRIuz", Expected: %"PRIu32"",
+ WLog_WARN(TAG,
+ "LocateCardsByATRA_Call is too short: Actual: %" PRIuz ", Expected: %" PRIu32
+ "",
Stream_GetRemainingLength(s), call->cAtrs);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -2832,7 +2909,8 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
if (count != call->cReaders)
{
WLog_WARN(TAG,
- "GetStatusChangeA_Call unexpected reader count: Actual: %"PRIu32", Expected: %"PRIu32"",
+ "GetStatusChangeA_Call unexpected reader count: Actual: %" PRIu32
+ ", Expected: %" PRIu32 "",
count, call->cReaders);
return STATUS_INVALID_PARAMETER;
}
@@ -2849,46 +2927,46 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
for (index = 0; index < call->cReaders; index++)
{
- readerState = (LPSCARD_READERSTATEA) &call->rgReaderStates[index];
+ readerState = (LPSCARD_READERSTATEA)&call->rgReaderStates[index];
if (Stream_GetRemainingLength(s) < 52)
{
- WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "LocateCardsByATRA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
+ Stream_Read_UINT32(s, szReaderNdrPtr); /* szReaderNdrPtr (4 bytes) */
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
- Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
- Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
- Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
- Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
+ Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
+ Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
+ Stream_Read(s, readerState->rgbAtr, 32); /* rgbAtr [0..32] (32 bytes) */
+ Stream_Seek(s, 4); /* rgbAtr [32..36] (4 bytes) */
}
for (index = 0; index < call->cReaders; index++)
{
- readerState = (LPSCARD_READERSTATEA) &call->rgReaderStates[index];
+ readerState = (LPSCARD_READERSTATEA)&call->rgReaderStates[index];
if (Stream_GetRemainingLength(s) < 12)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
Stream_Read_UINT32(s, maxCount); /* NdrMaxCount (4 bytes) */
- Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
- Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
+ Stream_Read_UINT32(s, offset); /* NdrOffset (4 bytes) */
+ Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
if (Stream_GetRemainingLength(s) < count)
{
- WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %"PRIuz"",
+ WLog_WARN(TAG, "GetStatusChangeA_Call is too short: %" PRIuz "",
Stream_GetRemainingLength(s));
return STATUS_BUFFER_TOO_SMALL;
}
- readerState->szReader = (LPCSTR) malloc(count + 1);
+ readerState->szReader = (LPCSTR)malloc(count + 1);
if (!readerState->szReader)
{
@@ -2896,9 +2974,9 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
return STATUS_NO_MEMORY;
}
- Stream_Read(s, (void*) readerState->szReader, count);
+ Stream_Read(s, (void*)readerState->szReader, count);
smartcard_unpack_read_size_align(smartcard, s, count, 4);
- ((char*) readerState->szReader)[count] = '\0';
+ ((char*)readerState->szReader)[count] = '\0';
if (!readerState->szReader)
{
@@ -2912,7 +2990,7 @@ LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wS
}
void smartcard_trace_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard,
- const LocateCardsByATRA_Call* call)
+ const LocateCardsByATRA_Call* call)
{
BYTE* pb;
UINT32 index;
@@ -2926,42 +3004,42 @@ void smartcard_trace_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard,
return;
WLog_DBG(TAG, "LocateCardsByATRA_Call {");
- pb = (BYTE*) & (call->hContext.pbContext);
+ pb = (BYTE*)&(call->hContext.pbContext);
if (call->hContext.cbContext > 4)
{
WLog_DBG(TAG,
- "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], pb[4], pb[5], pb[6], pb[7], call->hContext.cbContext);
}
else
{
- WLog_DBG(TAG, "hContext: 0x%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8" (%"PRIu32")",
+ WLog_DBG(TAG, "hContext: 0x%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 " (%" PRIu32 ")",
pb[0], pb[1], pb[2], pb[3], call->hContext.cbContext);
}
for (index = 0; index < call->cReaders; index++)
{
- readerState = (LPSCARD_READERSTATEA) &call->rgReaderStates[index];
- WLog_DBG(TAG, "\t[%"PRIu32"]: szReader: %s cbAtr: %"PRIu32"",
- index, readerState->szReader, readerState->cbAtr);
+ readerState = (LPSCARD_READERSTATEA)&call->rgReaderStates[index];
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index,
+ readerState->szReader, readerState->cbAtr);
szCurrentState = SCardGetReaderStateString(readerState->dwCurrentState);
szEventState = SCardGetReaderStateString(readerState->dwEventState);
- rgbAtr = winpr_BinToHexString((BYTE*) & (readerState->rgbAtr), readerState->cbAtr, FALSE);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwCurrentState: %s (0x%08"PRIX32")",
- index, szCurrentState, readerState->dwCurrentState);
- WLog_DBG(TAG, "\t[%"PRIu32"]: dwEventState: %s (0x%08"PRIX32")",
- index, szEventState, readerState->dwEventState);
+ rgbAtr = winpr_BinToHexString((BYTE*)&(readerState->rgbAtr), readerState->cbAtr, FALSE);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwCurrentState: %s (0x%08" PRIX32 ")", index,
+ szCurrentState, readerState->dwCurrentState);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: dwEventState: %s (0x%08" PRIX32 ")", index, szEventState,
+ readerState->dwEventState);
if (rgbAtr)
{
- WLog_DBG(TAG, "\t[%"PRIu32"]: cbAtr: %"PRIu32" rgbAtr: %s",
- index, readerState->cbAtr, rgbAtr);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: cbAtr: %" PRIu32 " rgbAtr: %s", index,
+ readerState->cbAtr, rgbAtr);
}
else
{
- WLog_DBG(TAG, "\t[%"PRIu32"]: cbAtr: 0 rgbAtr: n/a",
- index);
+ WLog_DBG(TAG, "\t[%" PRIu32 "]: cbAtr: 0 rgbAtr: n/a", index);
}
free(szCurrentState);
diff --git a/channels/smartcard/client/smartcard_pack.h b/channels/smartcard/client/smartcard_pack.h
index 92bb9b505..87709649b 100644
--- a/channels/smartcard/client/smartcard_pack.h
+++ b/channels/smartcard/client/smartcard_pack.h
@@ -175,8 +175,8 @@ typedef struct _LocateCardsW_Call
typedef struct _LocateCards_ATRMask
{
/* [range] */ DWORD cbAtr;
- BYTE rgbAtr[ 36 ];
- BYTE rgbMask[ 36 ];
+ BYTE rgbAtr[36];
+ BYTE rgbMask[36];
} LocateCards_ATRMask;
typedef struct _LocateCardsByATRA_Call
@@ -431,8 +431,8 @@ typedef struct _WriteCacheW_Call
WriteCache_Common Common;
} WriteCacheW_Call;
-#define SMARTCARD_COMMON_TYPE_HEADER_LENGTH 8
-#define SMARTCARD_PRIVATE_TYPE_HEADER_LENGTH 8
+#define SMARTCARD_COMMON_TYPE_HEADER_LENGTH 8
+#define SMARTCARD_PRIVATE_TYPE_HEADER_LENGTH 8
#include "smartcard_main.h"
@@ -442,14 +442,14 @@ LONG smartcard_unpack_read_size_align(SMARTCARD_DEVICE* smartcard, wStream* s, U
UINT32 alignment);
SCARDCONTEXT smartcard_scard_context_native_from_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDCONTEXT* context);
+ REDIR_SCARDCONTEXT* context);
void smartcard_scard_context_native_to_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDCONTEXT* context, SCARDCONTEXT hContext);
+ REDIR_SCARDCONTEXT* context, SCARDCONTEXT hContext);
SCARDHANDLE smartcard_scard_handle_native_from_redir(SMARTCARD_DEVICE* smartcard,
- REDIR_SCARDHANDLE* handle);
+ REDIR_SCARDHANDLE* handle);
void smartcard_scard_handle_native_to_redir(SMARTCARD_DEVICE* smartcard, REDIR_SCARDHANDLE* handle,
- SCARDHANDLE hCard);
+ SCARDHANDLE hCard);
LONG smartcard_unpack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream* s);
void smartcard_pack_common_type_header(SMARTCARD_DEVICE* smartcard, wStream* s);
@@ -459,50 +459,51 @@ void smartcard_pack_private_type_header(SMARTCARD_DEVICE* smartcard, wStream* s,
UINT32 objectBufferLength);
LONG smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context);
+ REDIR_SCARDCONTEXT* context);
LONG smartcard_pack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream* s,
REDIR_SCARDCONTEXT* context);
LONG smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context);
+ REDIR_SCARDCONTEXT* context);
LONG smartcard_pack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDCONTEXT* context);
+ REDIR_SCARDCONTEXT* context);
LONG smartcard_unpack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle);
+ REDIR_SCARDHANDLE* handle);
LONG smartcard_pack_redir_scard_handle(SMARTCARD_DEVICE* smartcard, wStream* s,
REDIR_SCARDHANDLE* handle);
LONG smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle);
+ REDIR_SCARDHANDLE* handle);
LONG smartcard_pack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStream* s,
- REDIR_SCARDHANDLE* handle);
+ REDIR_SCARDHANDLE* handle);
LONG smartcard_unpack_establish_context_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- EstablishContext_Call* call);
+ EstablishContext_Call* call);
void smartcard_trace_establish_context_call(SMARTCARD_DEVICE* smartcard,
- const EstablishContext_Call* call);
+ const EstablishContext_Call* call);
LONG smartcard_pack_establish_context_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- EstablishContext_Return* ret);
+ EstablishContext_Return* ret);
void smartcard_trace_establish_context_return(SMARTCARD_DEVICE* smartcard,
- const EstablishContext_Return* ret);
+ const EstablishContext_Return* ret);
LONG smartcard_unpack_context_call(SMARTCARD_DEVICE* smartcard, wStream* s, Context_Call* call);
void smartcard_trace_context_call(SMARTCARD_DEVICE* smartcard, const Context_Call* call,
const char* name);
-void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, const Long_Return* ret, const char* name);
+void smartcard_trace_long_return(SMARTCARD_DEVICE* smartcard, const Long_Return* ret,
+ const char* name);
LONG smartcard_unpack_list_reader_groups_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- ListReaderGroups_Call* call);
+ ListReaderGroups_Call* call);
void smartcard_trace_list_reader_groups_call(SMARTCARD_DEVICE* smartcard,
- const ListReaderGroups_Call* call, BOOL unicode);
+ const ListReaderGroups_Call* call, BOOL unicode);
LONG smartcard_pack_list_reader_groups_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- ListReaderGroups_Return* ret);
+ ListReaderGroups_Return* ret);
void smartcard_trace_list_reader_groups_return(SMARTCARD_DEVICE* smartcard,
- const ListReaderGroups_Return* ret, BOOL unicode);
+ const ListReaderGroups_Return* ret, BOOL unicode);
LONG smartcard_unpack_list_readers_call(SMARTCARD_DEVICE* smartcard, wStream* s,
ListReaders_Call* call);
@@ -512,7 +513,7 @@ void smartcard_trace_list_readers_call(SMARTCARD_DEVICE* smartcard, const ListRe
LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
ListReaders_Return* ret);
void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, const ListReaders_Return* ret,
- BOOL unicode);
+ BOOL unicode);
LONG smartcard_unpack_connect_a_call(SMARTCARD_DEVICE* smartcard, wStream* s, ConnectA_Call* call);
void smartcard_trace_connect_a_call(SMARTCARD_DEVICE* smartcard, const ConnectA_Call* call);
@@ -531,33 +532,35 @@ LONG smartcard_pack_reconnect_return(SMARTCARD_DEVICE* smartcard, wStream* s,
void smartcard_trace_reconnect_return(SMARTCARD_DEVICE* smartcard, const Reconnect_Return* ret);
LONG smartcard_unpack_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- HCardAndDisposition_Call* call);
+ HCardAndDisposition_Call* call);
void smartcard_trace_hcard_and_disposition_call(SMARTCARD_DEVICE* smartcard,
- HCardAndDisposition_Call* call, const char* name);
+ HCardAndDisposition_Call* call, const char* name);
LONG smartcard_unpack_get_status_change_a_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChangeA_Call* call);
+ GetStatusChangeA_Call* call);
void smartcard_trace_get_status_change_a_call(SMARTCARD_DEVICE* smartcard,
- const GetStatusChangeA_Call* call);
+ const GetStatusChangeA_Call* call);
LONG smartcard_unpack_get_status_change_w_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChangeW_Call* call);
+ GetStatusChangeW_Call* call);
void smartcard_trace_get_status_change_w_call(SMARTCARD_DEVICE* smartcard,
- GetStatusChangeW_Call* call);
+ GetStatusChangeW_Call* call);
LONG smartcard_pack_get_status_change_return(SMARTCARD_DEVICE* smartcard, wStream* s,
- GetStatusChange_Return* ret);
+ GetStatusChange_Return* ret);
void smartcard_trace_get_status_change_return(SMARTCARD_DEVICE* smartcard,
- const GetStatusChange_Return* ret, BOOL unicode);
+ const GetStatusChange_Return* ret, BOOL unicode);
LONG smartcard_unpack_state_call(SMARTCARD_DEVICE* smartcard, wStream* s, State_Call* call);
LONG smartcard_pack_state_return(SMARTCARD_DEVICE* smartcard, wStream* s, State_Return* ret);
LONG smartcard_unpack_status_call(SMARTCARD_DEVICE* smartcard, wStream* s, Status_Call* call);
-void smartcard_trace_status_call(SMARTCARD_DEVICE* smartcard, const Status_Call* call, BOOL unicode);
+void smartcard_trace_status_call(SMARTCARD_DEVICE* smartcard, const Status_Call* call,
+ BOOL unicode);
LONG smartcard_pack_status_return(SMARTCARD_DEVICE* smartcard, wStream* s, Status_Return* ret);
-void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Return* ret, BOOL unicode);
+void smartcard_trace_status_return(SMARTCARD_DEVICE* smartcard, const Status_Return* ret,
+ BOOL unicode);
LONG smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s,
GetAttrib_Call* call);
@@ -581,9 +584,8 @@ LONG smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, Tra
void smartcard_trace_transmit_return(SMARTCARD_DEVICE* smartcard, const Transmit_Return* ret);
LONG smartcard_unpack_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard, wStream* s,
- LocateCardsByATRA_Call* call);
+ LocateCardsByATRA_Call* call);
void smartcard_trace_locate_cards_by_atr_a_call(SMARTCARD_DEVICE* smartcard,
- const LocateCardsByATRA_Call* call);
-
+ const LocateCardsByATRA_Call* call);
#endif /* FREERDP_CHANNEL_SMARTCARD_CLIENT_PACK_H */
diff --git a/channels/sshagent/client/sshagent_main.c b/channels/sshagent/client/sshagent_main.c
index 39d81aaf5..aa7e632e7 100644
--- a/channels/sshagent/client/sshagent_main.c
+++ b/channels/sshagent/client/sshagent_main.c
@@ -95,7 +95,6 @@ struct _SSHAGENT_PLUGIN
rdpContext* rdpcontext;
};
-
/**
* Function to open the connection to the sshagent
*
@@ -123,8 +122,7 @@ static int connect_to_sshagent(const char* udspath)
if (rc != 0)
{
- WLog_ERR(TAG, "Can't connect to Unix domain socket \"%s\"!",
- udspath);
+ WLog_ERR(TAG, "Can't connect to Unix domain socket \"%s\"!", udspath);
close(agent_fd);
return -1;
}
@@ -132,7 +130,6 @@ static int connect_to_sshagent(const char* udspath)
return agent_fd;
}
-
/**
* Entry point for thread to read from the ssh-agent socket and forward
* the data to RDP
@@ -148,9 +145,7 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
while (going)
{
- int bytes_read = read(callback->agent_fd,
- buffer,
- sizeof(buffer));
+ int bytes_read = read(callback->agent_fd, buffer, sizeof(buffer));
if (bytes_read == 0)
{
@@ -161,9 +156,7 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
{
if (errno != EINTR)
{
- WLog_ERR(TAG,
- "Error reading from sshagent, errno=%d",
- errno);
+ WLog_ERR(TAG, "Error reading from sshagent, errno=%d", errno);
status = ERROR_READ_FAULT;
going = 0;
}
@@ -171,10 +164,7 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
else
{
/* Something read: forward to virtual channel */
- status = callback->channel->Write(callback->channel,
- bytes_read,
- buffer,
- NULL);
+ status = callback->channel->Write(callback->channel, bytes_read, buffer, NULL);
if (status != CHANNEL_RC_OK)
{
@@ -186,11 +176,10 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
close(callback->agent_fd);
if (status != CHANNEL_RC_OK)
- setChannelError(callback->rdpcontext, status,
- "sshagent_read_thread reported an error");
+ setChannelError(callback->rdpcontext, status, "sshagent_read_thread reported an error");
- ExitThread(status);
- return status;
+ ExitThread(status);
+ return status;
}
/**
@@ -200,7 +189,7 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data)
*/
static UINT sshagent_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*) pChannelCallback;
+ SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*)pChannelCallback;
BYTE* pBuffer = Stream_Pointer(data);
UINT32 cbSize = Stream_GetRemainingLength(data);
BYTE* pos = pBuffer;
@@ -210,16 +199,13 @@ static UINT sshagent_on_data_received(IWTSVirtualChannelCallback* pChannelCallba
while (bytes_to_write > 0)
{
- int bytes_written = write(callback->agent_fd, pos,
- bytes_to_write);
+ int bytes_written = write(callback->agent_fd, pos, bytes_to_write);
if (bytes_written < 0)
{
if (errno != EINTR)
{
- WLog_ERR(TAG,
- "Error writing to sshagent, errno=%d",
- errno);
+ WLog_ERR(TAG, "Error writing to sshagent, errno=%d", errno);
return ERROR_WRITE_FAULT;
}
}
@@ -242,7 +228,7 @@ static UINT sshagent_on_data_received(IWTSVirtualChannelCallback* pChannelCallba
*/
static UINT sshagent_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
- SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*) pChannelCallback;
+ SSHAGENT_CHANNEL_CALLBACK* callback = (SSHAGENT_CHANNEL_CALLBACK*)pChannelCallback;
/* Call shutdown() to wake up the read() in sshagent_read_thread(). */
shutdown(callback->agent_fd, SHUT_RDWR);
EnterCriticalSection(&callback->lock);
@@ -250,7 +236,7 @@ static UINT sshagent_on_close(IWTSVirtualChannelCallback* pChannelCallback)
if (WaitForSingleObject(callback->thread, INFINITE) == WAIT_FAILED)
{
UINT error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
@@ -261,19 +247,19 @@ static UINT sshagent_on_close(IWTSVirtualChannelCallback* pChannelCallback)
return CHANNEL_RC_OK;
}
-
/**
* Callback for when a new virtual channel is opened
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
SSHAGENT_CHANNEL_CALLBACK* callback;
- SSHAGENT_LISTENER_CALLBACK* listener_callback = (SSHAGENT_LISTENER_CALLBACK*) pListenerCallback;
- callback = (SSHAGENT_CHANNEL_CALLBACK*) calloc(1, sizeof(SSHAGENT_CHANNEL_CALLBACK));
+ SSHAGENT_LISTENER_CALLBACK* listener_callback = (SSHAGENT_LISTENER_CALLBACK*)pListenerCallback;
+ callback = (SSHAGENT_CHANNEL_CALLBACK*)calloc(1, sizeof(SSHAGENT_CHANNEL_CALLBACK));
if (!callback)
{
@@ -283,8 +269,7 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa
/* Now open a connection to the local ssh-agent. Do this for each
* connection to the plugin in case we mess up the agent session. */
- callback->agent_fd
- = connect_to_sshagent(listener_callback->agent_uds_path);
+ callback->agent_fd = connect_to_sshagent(listener_callback->agent_uds_path);
if (callback->agent_fd == -1)
{
@@ -299,13 +284,7 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
callback->rdpcontext = listener_callback->rdpcontext;
- callback->thread
- = CreateThread(NULL,
- 0,
- sshagent_read_thread,
- (void*) callback,
- 0,
- NULL);
+ callback->thread = CreateThread(NULL, 0, sshagent_read_thread, (void*)callback, 0, NULL);
if (!callback->thread)
{
@@ -315,7 +294,7 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa
return CHANNEL_RC_INITIALIZATION_ERROR;
}
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -326,9 +305,9 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa
*/
static UINT sshagent_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
- SSHAGENT_PLUGIN* sshagent = (SSHAGENT_PLUGIN*) pPlugin;
- sshagent->listener_callback = (SSHAGENT_LISTENER_CALLBACK*) calloc(1,
- sizeof(SSHAGENT_LISTENER_CALLBACK));
+ SSHAGENT_PLUGIN* sshagent = (SSHAGENT_PLUGIN*)pPlugin;
+ sshagent->listener_callback =
+ (SSHAGENT_LISTENER_CALLBACK*)calloc(1, sizeof(SSHAGENT_LISTENER_CALLBACK));
if (!sshagent->listener_callback)
{
@@ -351,7 +330,7 @@ static UINT sshagent_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
}
return pChannelMgr->CreateListener(pChannelMgr, "SSHAGENT", 0,
- (IWTSListenerCallback*) sshagent->listener_callback, NULL);
+ (IWTSListenerCallback*)sshagent->listener_callback, NULL);
}
/**
@@ -361,15 +340,15 @@ static UINT sshagent_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
*/
static UINT sshagent_plugin_terminated(IWTSPlugin* pPlugin)
{
- SSHAGENT_PLUGIN* sshagent = (SSHAGENT_PLUGIN*) pPlugin;
+ SSHAGENT_PLUGIN* sshagent = (SSHAGENT_PLUGIN*)pPlugin;
free(sshagent);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry sshagent_DVCPluginEntry
+#define DVCPluginEntry sshagent_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -381,11 +360,11 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
UINT status = CHANNEL_RC_OK;
SSHAGENT_PLUGIN* sshagent;
- sshagent = (SSHAGENT_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "sshagent");
+ sshagent = (SSHAGENT_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "sshagent");
if (!sshagent)
{
- sshagent = (SSHAGENT_PLUGIN*) calloc(1, sizeof(SSHAGENT_PLUGIN));
+ sshagent = (SSHAGENT_PLUGIN*)calloc(1, sizeof(SSHAGENT_PLUGIN));
if (!sshagent)
{
@@ -397,9 +376,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
sshagent->iface.Connected = NULL;
sshagent->iface.Disconnected = NULL;
sshagent->iface.Terminated = sshagent_plugin_terminated;
- sshagent->rdpcontext = ((freerdp*)((rdpSettings*) pEntryPoints->GetRdpSettings(
- pEntryPoints))->instance)->context;
- status = pEntryPoints->RegisterPlugin(pEntryPoints, "sshagent", (IWTSPlugin*) sshagent);
+ sshagent->rdpcontext =
+ ((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
+ ->context;
+ status = pEntryPoints->RegisterPlugin(pEntryPoints, "sshagent", (IWTSPlugin*)sshagent);
}
return status;
diff --git a/channels/sshagent/client/sshagent_main.h b/channels/sshagent/client/sshagent_main.h
index fc1ac150d..550b2b74d 100644
--- a/channels/sshagent/client/sshagent_main.h
+++ b/channels/sshagent/client/sshagent_main.h
@@ -35,8 +35,10 @@
#ifdef WITH_DEBUG_SSHAGENT
#define DEBUG_SSHAGENT(...) WLog_DBG(DVC_TAG, __VA_ARGS__)
#else
-#define DEBUG_SSHAGENT(...) do { } while (0)
+#define DEBUG_SSHAGENT(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* SSHAGENT_MAIN_H */
-
diff --git a/channels/tsmf/client/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c
index 3cf821b60..6e1f00357 100644
--- a/channels/tsmf/client/alsa/tsmf_alsa.c
+++ b/channels/tsmf/client/alsa/tsmf_alsa.c
@@ -65,7 +65,7 @@ static BOOL tsmf_alsa_open_device(TSMFAlsaAudioDevice* alsa)
static BOOL tsmf_alsa_open(ITSMFAudioDevice* audio, const char* device)
{
- TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
+ TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
if (!device)
{
@@ -79,14 +79,14 @@ static BOOL tsmf_alsa_open(ITSMFAudioDevice* audio, const char* device)
return tsmf_alsa_open_device(alsa);
}
-static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
- UINT32 sample_rate, UINT32 channels, UINT32 bits_per_sample)
+static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UINT32 channels,
+ UINT32 bits_per_sample)
{
int error;
snd_pcm_uframes_t frames;
snd_pcm_hw_params_t* hw_params;
snd_pcm_sw_params_t* sw_params;
- TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
+ TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
if (!alsa->out_handle)
return FALSE;
@@ -104,17 +104,12 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
}
snd_pcm_hw_params_any(alsa->out_handle, hw_params);
- snd_pcm_hw_params_set_access(alsa->out_handle, hw_params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
- snd_pcm_hw_params_set_format(alsa->out_handle, hw_params,
- SND_PCM_FORMAT_S16_LE);
- snd_pcm_hw_params_set_rate_near(alsa->out_handle, hw_params,
- &alsa->actual_rate, NULL);
- snd_pcm_hw_params_set_channels_near(alsa->out_handle, hw_params,
- &alsa->actual_channels);
+ snd_pcm_hw_params_set_access(alsa->out_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ snd_pcm_hw_params_set_format(alsa->out_handle, hw_params, SND_PCM_FORMAT_S16_LE);
+ snd_pcm_hw_params_set_rate_near(alsa->out_handle, hw_params, &alsa->actual_rate, NULL);
+ snd_pcm_hw_params_set_channels_near(alsa->out_handle, hw_params, &alsa->actual_channels);
frames = sample_rate;
- snd_pcm_hw_params_set_buffer_size_near(alsa->out_handle, hw_params,
- &frames);
+ snd_pcm_hw_params_set_buffer_size_near(alsa->out_handle, hw_params, &frames);
snd_pcm_hw_params(alsa->out_handle, hw_params);
snd_pcm_hw_params_free(hw_params);
error = snd_pcm_sw_params_malloc(&sw_params);
@@ -126,22 +121,21 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
}
snd_pcm_sw_params_current(alsa->out_handle, sw_params);
- snd_pcm_sw_params_set_start_threshold(alsa->out_handle, sw_params,
- frames / 2);
+ snd_pcm_sw_params_set_start_threshold(alsa->out_handle, sw_params, frames / 2);
snd_pcm_sw_params(alsa->out_handle, sw_params);
snd_pcm_sw_params_free(sw_params);
snd_pcm_prepare(alsa->out_handle);
- DEBUG_TSMF("sample_rate %"PRIu32" channels %"PRIu32" bits_per_sample %"PRIu32"",
+ DEBUG_TSMF("sample_rate %" PRIu32 " channels %" PRIu32 " bits_per_sample %" PRIu32 "",
sample_rate, channels, bits_per_sample);
DEBUG_TSMF("hardware buffer %lu frames", frames);
if ((alsa->actual_rate != alsa->source_rate) ||
(alsa->actual_channels != alsa->source_channels))
{
- DEBUG_TSMF("actual rate %"PRIu32" / channel %"PRIu32" is different "
- "from source rate %"PRIu32" / channel %"PRIu32", resampling required.",
- alsa->actual_rate, alsa->actual_channels,
- alsa->source_rate, alsa->source_channels);
+ DEBUG_TSMF("actual rate %" PRIu32 " / channel %" PRIu32 " is different "
+ "from source rate %" PRIu32 " / channel %" PRIu32 ", resampling required.",
+ alsa->actual_rate, alsa->actual_channels, alsa->source_rate,
+ alsa->source_channels);
}
return TRUE;
@@ -156,8 +150,8 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data
const BYTE* pindex;
int rbytes_per_frame;
int sbytes_per_frame;
- TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
- DEBUG_TSMF("data_size %"PRIu32"", data_size);
+ TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
+ DEBUG_TSMF("data_size %" PRIu32 "", data_size);
if (alsa->out_handle)
{
@@ -202,13 +196,12 @@ static UINT64 tsmf_alsa_get_latency(ITSMFAudioDevice* audio)
{
UINT64 latency = 0;
snd_pcm_sframes_t frames = 0;
- TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
+ TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
if (alsa->out_handle && alsa->actual_rate > 0 &&
- snd_pcm_delay(alsa->out_handle, &frames) == 0 &&
- frames > 0)
+ snd_pcm_delay(alsa->out_handle, &frames) == 0 && frames > 0)
{
- latency = ((UINT64)frames) * 10000000LL / (UINT64) alsa->actual_rate;
+ latency = ((UINT64)frames) * 10000000LL / (UINT64)alsa->actual_rate;
}
return latency;
@@ -221,7 +214,7 @@ static BOOL tsmf_alsa_flush(ITSMFAudioDevice* audio)
static void tsmf_alsa_free(ITSMFAudioDevice* audio)
{
- TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
+ TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
DEBUG_TSMF("");
if (alsa->out_handle)
@@ -234,15 +227,16 @@ static void tsmf_alsa_free(ITSMFAudioDevice* audio)
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_tsmf_client_audio_subsystem_entry alsa_freerdp_tsmf_client_audio_subsystem_entry
+#define freerdp_tsmf_client_audio_subsystem_entry alsa_freerdp_tsmf_client_audio_subsystem_entry
#else
-#define freerdp_tsmf_client_audio_subsystem_entry FREERDP_API freerdp_tsmf_client_audio_subsystem_entry
+#define freerdp_tsmf_client_audio_subsystem_entry \
+ FREERDP_API freerdp_tsmf_client_audio_subsystem_entry
#endif
ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
{
TSMFAlsaAudioDevice* alsa;
- alsa = (TSMFAlsaAudioDevice*) malloc(sizeof(TSMFAlsaAudioDevice));
+ alsa = (TSMFAlsaAudioDevice*)malloc(sizeof(TSMFAlsaAudioDevice));
ZeroMemory(alsa, sizeof(TSMFAlsaAudioDevice));
alsa->iface.Open = tsmf_alsa_open;
alsa->iface.SetFormat = tsmf_alsa_set_format;
@@ -250,5 +244,5 @@ ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
alsa->iface.GetLatency = tsmf_alsa_get_latency;
alsa->iface.Flush = tsmf_alsa_flush;
alsa->iface.Free = tsmf_alsa_free;
- return (ITSMFAudioDevice*) alsa;
+ return (ITSMFAudioDevice*)alsa;
}
diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
index 5522eb724..0444ad07b 100644
--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
@@ -92,7 +92,7 @@ typedef struct _TSMFFFmpegDecoder
static BOOL tsmf_ffmpeg_init_context(ITSMFDecoder* decoder)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
mdecoder->codec_context = avcodec_alloc_context3(NULL);
if (!mdecoder->codec_context)
@@ -106,7 +106,7 @@ static BOOL tsmf_ffmpeg_init_context(ITSMFDecoder* decoder)
static BOOL tsmf_ffmpeg_init_video_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYPE* media_type)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
mdecoder->codec_context->width = media_type->Width;
mdecoder->codec_context->height = media_type->Height;
mdecoder->codec_context->bit_rate = media_type->BitRate;
@@ -122,7 +122,7 @@ static BOOL tsmf_ffmpeg_init_video_stream(ITSMFDecoder* decoder, const TS_AM_MED
static BOOL tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYPE* media_type)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
mdecoder->codec_context->sample_rate = media_type->SamplesPerSecond.Numerator;
mdecoder->codec_context->bit_rate = media_type->BitRate;
mdecoder->codec_context->channels = media_type->Channels;
@@ -137,7 +137,7 @@ static BOOL tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_MED
mdecoder->codec_context->dsp_mask = FF_MM_SSE2 | FF_MM_MMX2;
#endif
#endif
-#else /* LIBAVCODEC_VERSION_MAJOR < 55 */
+#else /* LIBAVCODEC_VERSION_MAJOR < 55 */
#ifdef AV_CPU_FLAG_SSE2
av_set_cpu_flags_mask(AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMXEXT);
#else
@@ -152,7 +152,7 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
BYTE* p;
UINT32 size;
const BYTE* s;
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
mdecoder->codec = avcodec_find_decoder(mdecoder->codec_id);
if (!mdecoder->codec)
@@ -198,12 +198,12 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
/* The extradata format that FFmpeg uses is following CodecPrivate in Matroska.
See http://haali.su/mkv/codecs.pdf */
p = mdecoder->codec_context->extradata;
- *p++ = 1; /* Reserved? */
- *p++ = media_type->ExtraData[8]; /* Profile */
- *p++ = 0; /* Profile */
+ *p++ = 1; /* Reserved? */
+ *p++ = media_type->ExtraData[8]; /* Profile */
+ *p++ = 0; /* Profile */
*p++ = media_type->ExtraData[12]; /* Level */
- *p++ = 0xff; /* Flag? */
- *p++ = 0xe0 | 0x01; /* Reserved | #sps */
+ *p++ = 0xff; /* Flag? */
+ *p++ = 0xe0 | 0x01; /* Reserved | #sps */
s = media_type->ExtraData + 20;
size = ((UINT32)(*s)) * 256 + ((UINT32)(*(s + 1)));
memcpy(p, s, size + 2);
@@ -215,7 +215,8 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
}
else
{
- memcpy(mdecoder->codec_context->extradata, media_type->ExtraData, media_type->ExtraDataSize);
+ memcpy(mdecoder->codec_context->extradata, media_type->ExtraData,
+ media_type->ExtraDataSize);
memset(mdecoder->codec_context->extradata + media_type->ExtraDataSize, 0, 8);
}
}
@@ -228,7 +229,7 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
static BOOL tsmf_ffmpeg_prepare(ITSMFDecoder* decoder)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
if (avcodec_open2(mdecoder->codec_context, mdecoder->codec, NULL) < 0)
{
@@ -242,7 +243,7 @@ static BOOL tsmf_ffmpeg_prepare(ITSMFDecoder* decoder)
static BOOL tsmf_ffmpeg_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
switch (media_type->MajorType)
{
@@ -330,18 +331,19 @@ static BOOL tsmf_ffmpeg_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* medi
static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size,
UINT32 extensions)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
int decoded;
int len;
AVFrame* frame;
BOOL ret = TRUE;
-#if LIBAVCODEC_VERSION_MAJOR < 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20)
+#if LIBAVCODEC_VERSION_MAJOR < 52 || \
+ (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20)
len = avcodec_decode_video(mdecoder->codec_context, mdecoder->frame, &decoded, data, data_size);
#else
{
AVPacket pkt;
av_init_packet(&pkt);
- pkt.data = (BYTE*) data;
+ pkt.data = (BYTE*)data;
pkt.size = data_size;
if (extensions & TSMM_SAMPLE_EXT_CLEANPOINT)
@@ -353,12 +355,12 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
if (len < 0)
{
- WLog_ERR(TAG, "data_size %"PRIu32", avcodec_decode_video failed (%d)", data_size, len);
+ WLog_ERR(TAG, "data_size %" PRIu32 ", avcodec_decode_video failed (%d)", data_size, len);
ret = FALSE;
}
else if (!decoded)
{
- WLog_ERR(TAG, "data_size %"PRIu32", no frame is decoded.", data_size);
+ WLog_ERR(TAG, "data_size %" PRIu32 ", no frame is decoded.", data_size);
ret = FALSE;
}
else
@@ -367,10 +369,11 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
"pix_fmt %d width %d height %d",
mdecoder->frame->linesize[0], mdecoder->frame->linesize[1],
mdecoder->frame->linesize[2], mdecoder->frame->linesize[3],
- mdecoder->codec_context->pix_fmt,
- mdecoder->codec_context->width, mdecoder->codec_context->height);
- mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt,
- mdecoder->codec_context->width, mdecoder->codec_context->height);
+ mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
+ mdecoder->codec_context->height);
+ mdecoder->decoded_size =
+ avpicture_get_size(mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
+ mdecoder->codec_context->height);
mdecoder->decoded_data = calloc(1, mdecoder->decoded_size);
if (!mdecoder->decoded_data)
@@ -381,12 +384,11 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
#else
frame = av_frame_alloc();
#endif
- avpicture_fill((AVPicture*) frame, mdecoder->decoded_data,
- mdecoder->codec_context->pix_fmt,
+ avpicture_fill((AVPicture*)frame, mdecoder->decoded_data, mdecoder->codec_context->pix_fmt,
mdecoder->codec_context->width, mdecoder->codec_context->height);
- av_picture_copy((AVPicture*) frame, (AVPicture*) mdecoder->frame,
- mdecoder->codec_context->pix_fmt,
- mdecoder->codec_context->width, mdecoder->codec_context->height);
+ av_picture_copy((AVPicture*)frame, (AVPicture*)mdecoder->frame,
+ mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
+ mdecoder->codec_context->height);
av_free(frame);
}
@@ -396,7 +398,7 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size,
UINT32 extensions)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
int len;
int frame_size;
UINT32 src_size;
@@ -426,7 +428,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
return FALSE;
/* align the memory for SSE2 needs */
- dst = (BYTE*)(((uintptr_t) mdecoder->decoded_data + 15) & ~ 0x0F);
+ dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
dst_offset = dst - mdecoder->decoded_data;
src = data;
src_size = data_size;
@@ -444,7 +446,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16;
mdecoder->decoded_data = tmp_data;
- dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F);
+ dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
if (dst - mdecoder->decoded_data != dst_offset)
{
@@ -457,9 +459,10 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
}
frame_size = mdecoder->decoded_size_max - mdecoder->decoded_size;
-#if LIBAVCODEC_VERSION_MAJOR < 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20)
- len = avcodec_decode_audio2(mdecoder->codec_context,
- (int16_t*) dst, &frame_size, src, src_size);
+#if LIBAVCODEC_VERSION_MAJOR < 52 || \
+ (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR <= 20)
+ len = avcodec_decode_audio2(mdecoder->codec_context, (int16_t*)dst, &frame_size, src,
+ src_size);
#else
{
#if LIBAVCODEC_VERSION_MAJOR < 55
@@ -470,14 +473,15 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
int got_frame = 0;
AVPacket pkt;
av_init_packet(&pkt);
- pkt.data = (BYTE*) src;
+ pkt.data = (BYTE*)src;
pkt.size = src_size;
len = avcodec_decode_audio4(mdecoder->codec_context, decoded_frame, &got_frame, &pkt);
if (len >= 0 && got_frame)
{
frame_size = av_samples_get_buffer_size(NULL, mdecoder->codec_context->channels,
- decoded_frame->nb_samples, mdecoder->codec_context->sample_fmt, 1);
+ decoded_frame->nb_samples,
+ mdecoder->codec_context->sample_fmt, 1);
memcpy(dst, decoded_frame->data[0], frame_size);
}
else
@@ -510,18 +514,18 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
else if (dst_offset)
{
/* move the aligned decoded data to original place */
- memmove(mdecoder->decoded_data, mdecoder->decoded_data + dst_offset, mdecoder->decoded_size);
+ memmove(mdecoder->decoded_data, mdecoder->decoded_data + dst_offset,
+ mdecoder->decoded_size);
}
- DEBUG_TSMF("data_size %"PRIu32" decoded_size %"PRIu32"",
- data_size, mdecoder->decoded_size);
+ DEBUG_TSMF("data_size %" PRIu32 " decoded_size %" PRIu32 "", data_size, mdecoder->decoded_size);
return TRUE;
}
static BOOL tsmf_ffmpeg_decode(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size,
UINT32 extensions)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
if (mdecoder->decoded_data)
{
@@ -548,7 +552,7 @@ static BOOL tsmf_ffmpeg_decode(ITSMFDecoder* decoder, const BYTE* data, UINT32 d
static BYTE* tsmf_ffmpeg_get_decoded_data(ITSMFDecoder* decoder, UINT32* size)
{
BYTE* buf;
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
*size = mdecoder->decoded_size;
buf = mdecoder->decoded_data;
mdecoder->decoded_data = NULL;
@@ -558,7 +562,7 @@ static BYTE* tsmf_ffmpeg_get_decoded_data(ITSMFDecoder* decoder, UINT32* size)
static UINT32 tsmf_ffmpeg_get_decoded_format(ITSMFDecoder* decoder)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
switch (mdecoder->codec_context->pix_fmt)
{
@@ -566,15 +570,14 @@ static UINT32 tsmf_ffmpeg_get_decoded_format(ITSMFDecoder* decoder)
return RDP_PIXFMT_I420;
default:
- WLog_ERR(TAG, "unsupported pixel format %u",
- mdecoder->codec_context->pix_fmt);
- return (UINT32) - 1;
+ WLog_ERR(TAG, "unsupported pixel format %u", mdecoder->codec_context->pix_fmt);
+ return (UINT32)-1;
}
}
static BOOL tsmf_ffmpeg_get_decoded_dimension(ITSMFDecoder* decoder, UINT32* width, UINT32* height)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
if (mdecoder->codec_context->width > 0 && mdecoder->codec_context->height > 0)
{
@@ -590,7 +593,7 @@ static BOOL tsmf_ffmpeg_get_decoded_dimension(ITSMFDecoder* decoder, UINT32* wid
static void tsmf_ffmpeg_free(ITSMFDecoder* decoder)
{
- TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
+ TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
if (mdecoder->frame)
av_free(mdecoder->frame);
@@ -617,17 +620,17 @@ static BOOL CALLBACK InitializeAvCodecs(PINIT_ONCE once, PVOID param, PVOID* con
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_tsmf_client_subsystem_entry ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry
+#define freerdp_tsmf_client_subsystem_entry ffmpeg_freerdp_tsmf_client_decoder_subsystem_entry
#else
-#define freerdp_tsmf_client_subsystem_entry FREERDP_API freerdp_tsmf_client_decoder_subsystem_entry
+#define freerdp_tsmf_client_subsystem_entry FREERDP_API freerdp_tsmf_client_decoder_subsystem_entry
#endif
ITSMFDecoder* freerdp_tsmf_client_subsystem_entry(void)
{
TSMFFFmpegDecoder* decoder;
InitOnceExecuteOnce(&g_Initialized, InitializeAvCodecs, NULL, NULL);
- WLog_DBG(TAG, "TSMFDecoderEntry FFMPEG");
- decoder = (TSMFFFmpegDecoder*) calloc(1, sizeof(TSMFFFmpegDecoder));
+ WLog_DBG(TAG, "TSMFDecoderEntry FFMPEG");
+ decoder = (TSMFFFmpegDecoder*)calloc(1, sizeof(TSMFFFmpegDecoder));
if (!decoder)
return NULL;
@@ -638,5 +641,5 @@ ITSMFDecoder* freerdp_tsmf_client_subsystem_entry(void)
decoder->iface.GetDecodedFormat = tsmf_ffmpeg_get_decoded_format;
decoder->iface.GetDecodedDimension = tsmf_ffmpeg_get_decoded_dimension;
decoder->iface.Free = tsmf_ffmpeg_free;
- return (ITSMFDecoder*) decoder;
+ return (ITSMFDecoder*)decoder;
}
diff --git a/channels/tsmf/client/gstreamer/tsmf_X11.c b/channels/tsmf/client/gstreamer/tsmf_X11.c
index 7035d0db3..f7b339c95 100644
--- a/channels/tsmf/client/gstreamer/tsmf_X11.c
+++ b/channels/tsmf/client/gstreamer/tsmf_X11.c
@@ -16,7 +16,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
+ */
#include
#include
@@ -65,17 +65,17 @@
struct X11Handle
{
int shmid;
- int *xfwin;
+ int* xfwin;
#if defined(WITH_XEXT)
BOOL has_shape;
#endif
- Display *disp;
+ Display* disp;
Window subwin;
BOOL subwinMapped;
#if GST_VERSION_MAJOR > 0
- GstVideoOverlay *overlay;
+ GstVideoOverlay* overlay;
#else
- GstXOverlay *overlay;
+ GstXOverlay* overlay;
#endif
int subwinWidth;
int subwinHeight;
@@ -90,34 +90,35 @@ static const char* get_shm_id()
return shm_id;
}
-static GstBusSyncReply tsmf_platform_bus_sync_handler(GstBus *bus, GstMessage *message, gpointer user_data)
+static GstBusSyncReply tsmf_platform_bus_sync_handler(GstBus* bus, GstMessage* message,
+ gpointer user_data)
{
struct X11Handle* hdl;
TSMFGstreamerDecoder* decoder = user_data;
- if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
+ if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
#if GST_VERSION_MAJOR > 0
- if (!gst_is_video_overlay_prepare_window_handle_message (message))
+ if (!gst_is_video_overlay_prepare_window_handle_message(message))
return GST_BUS_PASS;
#else
- if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
+ if (!gst_structure_has_name(message->structure, "prepare-xwindow-id"))
return GST_BUS_PASS;
#endif
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
if (hdl->subwin)
{
#if GST_VERSION_MAJOR > 0
- hdl->overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
+ hdl->overlay = GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(message));
gst_video_overlay_set_window_handle(hdl->overlay, hdl->subwin);
gst_video_overlay_handle_events(hdl->overlay, FALSE);
#else
- hdl->overlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message));
-#if GST_CHECK_VERSION(0,10,31)
+ hdl->overlay = GST_X_OVERLAY(GST_MESSAGE_SRC(message));
+#if GST_CHECK_VERSION(0, 10, 31)
gst_x_overlay_set_window_handle(hdl->overlay, hdl->subwin);
#else
gst_x_overlay_set_xwindow_id(hdl->overlay, hdl->subwin);
@@ -125,17 +126,20 @@ static GstBusSyncReply tsmf_platform_bus_sync_handler(GstBus *bus, GstMessage *m
gst_x_overlay_handle_events(hdl->overlay, TRUE);
#endif
- if (hdl->subwinWidth != -1 && hdl->subwinHeight != -1 && hdl->subwinX != -1 && hdl->subwinY != -1)
+ if (hdl->subwinWidth != -1 && hdl->subwinHeight != -1 && hdl->subwinX != -1 &&
+ hdl->subwinY != -1)
{
#if GST_VERSION_MAJOR > 0
- if (!gst_video_overlay_set_render_rectangle(hdl->overlay, 0, 0, hdl->subwinWidth, hdl->subwinHeight))
+ if (!gst_video_overlay_set_render_rectangle(hdl->overlay, 0, 0, hdl->subwinWidth,
+ hdl->subwinHeight))
{
WLog_ERR(TAG, "Could not resize overlay!");
}
gst_video_overlay_expose(hdl->overlay);
#else
- if (!gst_x_overlay_set_render_rectangle(hdl->overlay, 0, 0, hdl->subwinWidth, hdl->subwinHeight))
+ if (!gst_x_overlay_set_render_rectangle(hdl->overlay, 0, 0, hdl->subwinWidth,
+ hdl->subwinHeight))
{
WLog_ERR(TAG, "Could not resize overlay!");
}
@@ -143,15 +147,18 @@ static GstBusSyncReply tsmf_platform_bus_sync_handler(GstBus *bus, GstMessage *m
gst_x_overlay_expose(hdl->overlay);
#endif
XLockDisplay(hdl->disp);
- XMoveResizeWindow(hdl->disp, hdl->subwin, hdl->subwinX, hdl->subwinY, hdl->subwinWidth, hdl->subwinHeight);
+ XMoveResizeWindow(hdl->disp, hdl->subwin, hdl->subwinX, hdl->subwinY, hdl->subwinWidth,
+ hdl->subwinHeight);
XSync(hdl->disp, FALSE);
XUnlockDisplay(hdl->disp);
}
- } else {
- g_warning ("Window was not available before retrieving the overlay!");
+ }
+ else
+ {
+ g_warning("Window was not available before retrieving the overlay!");
}
- gst_message_unref (message);
+ gst_message_unref(message);
return GST_BUS_DROP;
}
@@ -187,11 +194,12 @@ int tsmf_platform_create(TSMFGstreamerDecoder* decoder)
hdl->shmid = shm_open(get_shm_id(), (O_RDWR | O_CREAT), (PROT_READ | PROT_WRITE));
if (hdl->shmid == -1)
{
- WLog_ERR(TAG, "failed to get access to shared memory - shmget(%s): %i - %s", get_shm_id(), errno, strerror(errno));
+ WLog_ERR(TAG, "failed to get access to shared memory - shmget(%s): %i - %s", get_shm_id(),
+ errno, strerror(errno));
return -2;
}
- hdl->xfwin = mmap(0, sizeof(void *), PROT_READ | PROT_WRITE, MAP_SHARED, hdl->shmid, 0);
+ hdl->xfwin = mmap(0, sizeof(void*), PROT_READ | PROT_WRITE, MAP_SHARED, hdl->shmid, 0);
if (hdl->xfwin == MAP_FAILED)
{
WLog_ERR(TAG, "shmat failed!");
@@ -221,7 +229,6 @@ int tsmf_platform_set_format(TSMFGstreamerDecoder* decoder)
if (decoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
{
-
}
return 0;
@@ -240,9 +247,9 @@ int tsmf_platform_register_handler(TSMFGstreamerDecoder* decoder)
bus = gst_pipeline_get_bus(GST_PIPELINE(decoder->pipe));
#if GST_VERSION_MAJOR > 0
- gst_bus_set_sync_handler (bus, (GstBusSyncHandler) tsmf_platform_bus_sync_handler, decoder, NULL);
+ gst_bus_set_sync_handler(bus, (GstBusSyncHandler)tsmf_platform_bus_sync_handler, decoder, NULL);
#else
- gst_bus_set_sync_handler (bus, (GstBusSyncHandler) tsmf_platform_bus_sync_handler, decoder);
+ gst_bus_set_sync_handler(bus, (GstBusSyncHandler)tsmf_platform_bus_sync_handler, decoder);
#endif
if (!bus)
@@ -251,7 +258,7 @@ int tsmf_platform_register_handler(TSMFGstreamerDecoder* decoder)
return 1;
}
- gst_object_unref (bus);
+ gst_object_unref(bus);
return 0;
}
@@ -295,12 +302,12 @@ int tsmf_window_create(TSMFGstreamerDecoder* decoder)
if (!decoder->platform)
return -1;
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
if (!hdl->subwin)
{
XLockDisplay(hdl->disp);
- hdl->subwin = XCreateSimpleWindow(hdl->disp, *(int *)hdl->xfwin, 0, 0, 1, 1, 0, 0, 0);
+ hdl->subwin = XCreateSimpleWindow(hdl->disp, *(int*)hdl->xfwin, 0, 0, 1, 1, 0, 0, 0);
XUnlockDisplay(hdl->disp);
if (!hdl->subwin)
@@ -313,18 +320,18 @@ int tsmf_window_create(TSMFGstreamerDecoder* decoder)
decoder->ready = TRUE;
#if defined(WITH_XEXT)
- int event, error;
- XLockDisplay(hdl->disp);
- hdl->has_shape = XShapeQueryExtension(hdl->disp, &event, &error);
- XUnlockDisplay(hdl->disp);
+ int event, error;
+ XLockDisplay(hdl->disp);
+ hdl->has_shape = XShapeQueryExtension(hdl->disp, &event, &error);
+ XUnlockDisplay(hdl->disp);
#endif
}
return 0;
}
-int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
- int height, int nr_rects, RDP_RECT *rects)
+int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, int height,
+ int nr_rects, RDP_RECT* rects)
{
struct X11Handle* hdl;
@@ -339,7 +346,7 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
if (!decoder->platform)
return -1;
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
DEBUG_TSMF("resize: x=%d, y=%d, w=%d, h=%d", x, y, width, height);
if (hdl->overlay)
@@ -370,7 +377,8 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
hdl->subwinHeight = height;
XLockDisplay(hdl->disp);
- XMoveResizeWindow(hdl->disp, hdl->subwin, hdl->subwinX, hdl->subwinY, hdl->subwinWidth, hdl->subwinHeight);
+ XMoveResizeWindow(hdl->disp, hdl->subwin, hdl->subwinX, hdl->subwinY, hdl->subwinWidth,
+ hdl->subwinHeight);
/* Unmap the window if there are no visibility rects */
if (nr_rects == 0)
@@ -382,7 +390,7 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
if (hdl->has_shape)
{
int i;
- XRectangle *xrects = NULL;
+ XRectangle* xrects = NULL;
if (nr_rects == 0)
{
@@ -396,7 +404,7 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
{
xrects = calloc(nr_rects, sizeof(XRectangle));
}
-
+
if (xrects)
{
for (i = 0; i < nr_rects; i++)
@@ -407,7 +415,8 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width,
xrects[i].height = rects[i].height;
}
- XShapeCombineRectangles(hdl->disp, hdl->subwin, ShapeBounding, x, y, xrects, nr_rects, ShapeSet, 0);
+ XShapeCombineRectangles(hdl->disp, hdl->subwin, ShapeBounding, x, y, xrects,
+ nr_rects, ShapeSet, 0);
free(xrects);
}
}
@@ -441,7 +450,7 @@ int tsmf_window_map(TSMFGstreamerDecoder* decoder)
if (!decoder)
return -1;
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
/* Only need to map the window if it is not currently mapped */
if ((hdl->subwin) && (!hdl->subwinMapped))
@@ -462,22 +471,21 @@ int tsmf_window_unmap(TSMFGstreamerDecoder* decoder)
if (!decoder)
return -1;
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
/* only need to unmap window if it is currently mapped */
if ((hdl->subwin) && (hdl->subwinMapped))
{
XLockDisplay(hdl->disp);
XUnmapWindow(hdl->disp, hdl->subwin);
- hdl->subwinMapped = FALSE;
- XSync(hdl->disp, FALSE);
+ hdl->subwinMapped = FALSE;
+ XSync(hdl->disp, FALSE);
XUnlockDisplay(hdl->disp);
}
return 0;
}
-
int tsmf_window_destroy(TSMFGstreamerDecoder* decoder)
{
struct X11Handle* hdl;
@@ -493,7 +501,7 @@ int tsmf_window_destroy(TSMFGstreamerDecoder* decoder)
if (!decoder->platform)
return -1;
- hdl = (struct X11Handle*) decoder->platform;
+ hdl = (struct X11Handle*)decoder->platform;
if (hdl->subwin)
{
@@ -512,4 +520,3 @@ int tsmf_window_destroy(TSMFGstreamerDecoder* decoder)
hdl->subwinHeight = -1;
return 0;
}
-
diff --git a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c
index 22f6698fb..64a7b6824 100644
--- a/channels/tsmf/client/gstreamer/tsmf_gstreamer.c
+++ b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c
@@ -17,7 +17,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -54,12 +54,12 @@
#endif
/* 1 second = 10,000,000 100ns units*/
-#define SEEK_TOLERANCE 10*1000*1000
+#define SEEK_TOLERANCE 10 * 1000 * 1000
static BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder);
static void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder* mdecoder);
static int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder* mdecoder,
- GstState desired_state);
+ GstState desired_state);
static BOOL tsmf_gstreamer_buffer_level(ITSMFDecoder* decoder);
const char* get_type(TSMFGstreamerDecoder* mdecoder)
@@ -78,55 +78,59 @@ const char* get_type(TSMFGstreamerDecoder* mdecoder)
}
}
-static void cb_child_added(GstChildProxy *child_proxy, GObject *object, TSMFGstreamerDecoder* mdecoder)
+static void cb_child_added(GstChildProxy* child_proxy, GObject* object,
+ TSMFGstreamerDecoder* mdecoder)
{
DEBUG_TSMF("NAME: %s", G_OBJECT_TYPE_NAME(object));
- if (!g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstXvImageSink") || !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstXImageSink") || !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstFluVAAutoSink"))
+ if (!g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstXvImageSink") ||
+ !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstXImageSink") ||
+ !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstFluVAAutoSink"))
{
- gst_base_sink_set_max_lateness((GstBaseSink *) object, 10000000); /* nanoseconds */
- g_object_set(G_OBJECT(object), "sync", TRUE, NULL); /* synchronize on the clock */
+ gst_base_sink_set_max_lateness((GstBaseSink*)object, 10000000); /* nanoseconds */
+ g_object_set(G_OBJECT(object), "sync", TRUE, NULL); /* synchronize on the clock */
g_object_set(G_OBJECT(object), "async", TRUE, NULL); /* no async state changes */
}
- else if (!g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstAlsaSink") || !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstPulseSink"))
+ else if (!g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstAlsaSink") ||
+ !g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstPulseSink"))
{
- gst_base_sink_set_max_lateness((GstBaseSink *) object, 10000000); /* nanoseconds */
+ gst_base_sink_set_max_lateness((GstBaseSink*)object, 10000000); /* nanoseconds */
g_object_set(G_OBJECT(object), "slave-method", 1, NULL);
- g_object_set(G_OBJECT(object), "buffer-time", (gint64) 20000, NULL); /* microseconds */
- g_object_set(G_OBJECT(object), "drift-tolerance", (gint64) 20000, NULL); /* microseconds */
- g_object_set(G_OBJECT(object), "latency-time", (gint64) 10000, NULL); /* microseconds */
- g_object_set(G_OBJECT(object), "sync", TRUE, NULL); /* synchronize on the clock */
+ g_object_set(G_OBJECT(object), "buffer-time", (gint64)20000, NULL); /* microseconds */
+ g_object_set(G_OBJECT(object), "drift-tolerance", (gint64)20000, NULL); /* microseconds */
+ g_object_set(G_OBJECT(object), "latency-time", (gint64)10000, NULL); /* microseconds */
+ g_object_set(G_OBJECT(object), "sync", TRUE, NULL); /* synchronize on the clock */
g_object_set(G_OBJECT(object), "async", TRUE, NULL); /* no async state changes */
}
}
-static void tsmf_gstreamer_enough_data(GstAppSrc *src, gpointer user_data)
+static void tsmf_gstreamer_enough_data(GstAppSrc* src, gpointer user_data)
{
TSMFGstreamerDecoder* mdecoder = user_data;
- (void) mdecoder;
+ (void)mdecoder;
DEBUG_TSMF("%s", get_type(mdecoder));
}
-static void tsmf_gstreamer_need_data(GstAppSrc *src, guint length, gpointer user_data)
+static void tsmf_gstreamer_need_data(GstAppSrc* src, guint length, gpointer user_data)
{
TSMFGstreamerDecoder* mdecoder = user_data;
- (void) mdecoder;
+ (void)mdecoder;
DEBUG_TSMF("%s length=%u", get_type(mdecoder), length);
}
-static gboolean tsmf_gstreamer_seek_data(GstAppSrc *src, guint64 offset, gpointer user_data)
+static gboolean tsmf_gstreamer_seek_data(GstAppSrc* src, guint64 offset, gpointer user_data)
{
TSMFGstreamerDecoder* mdecoder = user_data;
- (void) mdecoder;
- DEBUG_TSMF("%s offset=%"PRIu64"", get_type(mdecoder), offset);
+ (void)mdecoder;
+ DEBUG_TSMF("%s offset=%" PRIu64 "", get_type(mdecoder), offset);
return TRUE;
}
static BOOL tsmf_gstreamer_change_volume(ITSMFDecoder* decoder, UINT32 newVolume, UINT32 muted)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
if (!mdecoder || !mdecoder->pipe)
return TRUE;
@@ -134,9 +138,9 @@ static BOOL tsmf_gstreamer_change_volume(ITSMFDecoder* decoder, UINT32 newVolume
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
return TRUE;
- mdecoder->gstMuted = (BOOL) muted;
- DEBUG_TSMF("mute=[%"PRId32"]", mdecoder->gstMuted);
- mdecoder->gstVolume = (double) newVolume / (double) 10000;
+ mdecoder->gstMuted = (BOOL)muted;
+ DEBUG_TSMF("mute=[%" PRId32 "]", mdecoder->gstMuted);
+ mdecoder->gstVolume = (double)newVolume / (double)10000;
DEBUG_TSMF("gst_new_vol=[%f]", mdecoder->gstVolume);
if (!mdecoder->volume)
@@ -169,10 +173,11 @@ int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder* mdecoder, GstState d
return 0;
if (!mdecoder->pipe)
- return 0; /* Just in case this is called during startup or shutdown when we don't expect it */
+ return 0; /* Just in case this is called during startup or shutdown when we don't expect it
+ */
if (desired_state == mdecoder->state)
- return 0; /* Redundant request - Nothing to do */
+ return 0; /* Redundant request - Nothing to do */
name = gst_element_state_get_name(desired_state); /* For debug */
DEBUG_TSMF("%s to %s", sname, name);
@@ -210,7 +215,7 @@ static GstBuffer* tsmf_get_buffer_from_data(const void* raw_data, gsize size)
if (!data)
{
- WLog_ERR(TAG, "Could not allocate %"G_GSIZE_FORMAT" bytes of data.", size);
+ WLog_ERR(TAG, "Could not allocate %" G_GSIZE_FORMAT " bytes of data.", size);
return NULL;
}
@@ -238,7 +243,7 @@ static GstBuffer* tsmf_get_buffer_from_data(const void* raw_data, gsize size)
static BOOL tsmf_gstreamer_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
if (!mdecoder)
return FALSE;
@@ -260,175 +265,153 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* m
switch (media_type->SubType)
{
case TSMF_SUB_TYPE_WVC1:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "wmvversion", G_TYPE_INT, 3,
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-wmv", "bitrate", G_TYPE_UINT, media_type->BitRate, "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height, "wmvversion",
+ G_TYPE_INT, 3,
#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "WVC1",
+ "format", G_TYPE_STRING, "WVC1",
#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'V', 'C', '1'),
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('W', 'V', 'C', '1'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1 , 1,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, "pixel-aspect-ratio", GST_TYPE_FRACTION,
+ 1, 1, NULL);
break;
case TSMF_SUB_TYPE_MP4S:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-divx",
- "divxversion", G_TYPE_INT, 5,
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-divx", "divxversion", G_TYPE_INT, 5, "bitrate", G_TYPE_UINT,
+ media_type->BitRate, "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT,
+ media_type->Height,
#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "MP42",
-#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('M', 'P', '4', '2'),
+ "format", G_TYPE_STRING, "MP42",
+#else
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('M', 'P', '4', '2'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
break;
case TSMF_SUB_TYPE_MP42:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
- "msmpegversion", G_TYPE_INT, 42,
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "MP42",
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-msmpeg", "msmpegversion", G_TYPE_INT, 42, "bitrate", G_TYPE_UINT,
+ media_type->BitRate, "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT,
+ media_type->Height,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "MP42",
#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('M', 'P', '4', '2'),
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('M', 'P', '4', '2'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
break;
case TSMF_SUB_TYPE_MP43:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
- "msmpegversion", G_TYPE_INT, 43,
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "MP43",
-#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('M', 'P', '4', '3'),
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-msmpeg", "msmpegversion", G_TYPE_INT, 43, "bitrate", G_TYPE_UINT,
+ media_type->BitRate, "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT,
+ media_type->Height,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "MP43",
+#else
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('M', 'P', '4', '3'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
break;
case TSMF_SUB_TYPE_M4S2:
- mdecoder->gst_caps = gst_caps_new_simple ("video/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "M4S2",
-#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('M', '4', 'S', '2'),
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/mpeg", "mpegversion", G_TYPE_INT, 4, "width", G_TYPE_INT, media_type->Width,
+ "height", G_TYPE_INT, media_type->Height,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "M4S2",
+#else
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('M', '4', 'S', '2'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
break;
case TSMF_SUB_TYPE_WMA9:
- mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
- "wmaversion", G_TYPE_INT, 3,
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- "bitrate", G_TYPE_INT, media_type->BitRate,
- "depth", G_TYPE_INT, media_type->BitsPerSample,
- "width", G_TYPE_INT, media_type->BitsPerSample,
- "block_align", G_TYPE_INT, media_type->BlockAlign,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "audio/x-wma", "wmaversion", G_TYPE_INT, 3, "rate", G_TYPE_INT,
+ media_type->SamplesPerSecond.Numerator, "channels", G_TYPE_INT,
+ media_type->Channels, "bitrate", G_TYPE_INT, media_type->BitRate, "depth",
+ G_TYPE_INT, media_type->BitsPerSample, "width", G_TYPE_INT,
+ media_type->BitsPerSample, "block_align", G_TYPE_INT, media_type->BlockAlign, NULL);
break;
case TSMF_SUB_TYPE_WMA1:
- mdecoder->gst_caps = gst_caps_new_simple ("audio/x-wma",
- "wmaversion", G_TYPE_INT, 1,
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- "bitrate", G_TYPE_INT, media_type->BitRate,
- "depth", G_TYPE_INT, media_type->BitsPerSample,
- "width", G_TYPE_INT, media_type->BitsPerSample,
- "block_align", G_TYPE_INT, media_type->BlockAlign,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "audio/x-wma", "wmaversion", G_TYPE_INT, 1, "rate", G_TYPE_INT,
+ media_type->SamplesPerSecond.Numerator, "channels", G_TYPE_INT,
+ media_type->Channels, "bitrate", G_TYPE_INT, media_type->BitRate, "depth",
+ G_TYPE_INT, media_type->BitsPerSample, "width", G_TYPE_INT,
+ media_type->BitsPerSample, "block_align", G_TYPE_INT, media_type->BlockAlign, NULL);
break;
case TSMF_SUB_TYPE_WMA2:
- mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
- "wmaversion", G_TYPE_INT, 2,
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- "bitrate", G_TYPE_INT, media_type->BitRate,
- "depth", G_TYPE_INT, media_type->BitsPerSample,
- "width", G_TYPE_INT, media_type->BitsPerSample,
- "block_align", G_TYPE_INT, media_type->BlockAlign,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "audio/x-wma", "wmaversion", G_TYPE_INT, 2, "rate", G_TYPE_INT,
+ media_type->SamplesPerSecond.Numerator, "channels", G_TYPE_INT,
+ media_type->Channels, "bitrate", G_TYPE_INT, media_type->BitRate, "depth",
+ G_TYPE_INT, media_type->BitsPerSample, "width", G_TYPE_INT,
+ media_type->BitsPerSample, "block_align", G_TYPE_INT, media_type->BlockAlign, NULL);
break;
case TSMF_SUB_TYPE_MP3:
- mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, 3,
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- NULL);
+ mdecoder->gst_caps =
+ gst_caps_new_simple("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT,
+ 3, "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
+ "channels", G_TYPE_INT, media_type->Channels, NULL);
break;
case TSMF_SUB_TYPE_WMV1:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "wmvversion", G_TYPE_INT, 1,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "WMV1",
-#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'M', 'V', '1'),
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-wmv", "bitrate", G_TYPE_UINT, media_type->BitRate, "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height, "wmvversion",
+ G_TYPE_INT, 1,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "WMV1",
+#else
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('W', 'M', 'V', '1'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
break;
case TSMF_SUB_TYPE_WMV2:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "wmvversion", G_TYPE_INT, 2,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "WMV2",
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-wmv", "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT,
+ media_type->Height, "wmvversion", G_TYPE_INT, 2,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "WMV2",
#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'M', 'V', '2'),
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('W', 'M', 'V', '2'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1 , 1,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, "pixel-aspect-ratio", GST_TYPE_FRACTION,
+ 1, 1, NULL);
break;
case TSMF_SUB_TYPE_WMV3:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
- "bitrate", G_TYPE_UINT, media_type->BitRate,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "wmvversion", G_TYPE_INT, 3,
-#if GST_VERSION_MAJOR > 0
- "format", G_TYPE_STRING, "WMV3",
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-wmv", "bitrate", G_TYPE_UINT, media_type->BitRate, "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height, "wmvversion",
+ G_TYPE_INT, 3,
+#if GST_VERSION_MAJOR > 0
+ "format", G_TYPE_STRING, "WMV3",
#else
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'M', 'V', '3'),
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('W', 'M', 'V', '3'),
#endif
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1 , 1,
- NULL);
+ "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, "pixel-aspect-ratio", GST_TYPE_FRACTION,
+ 1, 1, NULL);
break;
case TSMF_SUB_TYPE_AVC1:
case TSMF_SUB_TYPE_H264:
- mdecoder->gst_caps = gst_caps_new_simple("video/x-h264",
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1 , 1,
- "stream-format", G_TYPE_STRING, "byte-stream",
- "alignment", G_TYPE_STRING, "nal",
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-h264", "width", G_TYPE_INT, media_type->Width, "height", G_TYPE_INT,
+ media_type->Height, "framerate", GST_TYPE_FRACTION,
+ media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
+ "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, "stream-format", G_TYPE_STRING,
+ "byte-stream", "alignment", G_TYPE_STRING, "nal", NULL);
break;
case TSMF_SUB_TYPE_AC3:
- mdecoder->gst_caps = gst_caps_new_simple("audio/x-ac3",
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "audio/x-ac3", "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
+ "channels", G_TYPE_INT, media_type->Channels, NULL);
break;
case TSMF_SUB_TYPE_AAC:
@@ -441,59 +424,47 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* m
media_type->ExtraDataSize -= 12;
}
- mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- "mpegversion", G_TYPE_INT, 4,
- "framed", G_TYPE_BOOLEAN, TRUE,
- "stream-format", G_TYPE_STRING, "raw",
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "audio/mpeg", "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
+ "channels", G_TYPE_INT, media_type->Channels, "mpegversion", G_TYPE_INT, 4,
+ "framed", G_TYPE_BOOLEAN, TRUE, "stream-format", G_TYPE_STRING, "raw", NULL);
break;
case TSMF_SUB_TYPE_MP1A:
- mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "channels", G_TYPE_INT, media_type->Channels,
- NULL);
+ mdecoder->gst_caps =
+ gst_caps_new_simple("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "channels",
+ G_TYPE_INT, media_type->Channels, NULL);
break;
case TSMF_SUB_TYPE_MP1V:
- mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- NULL);
+ mdecoder->gst_caps =
+ gst_caps_new_simple("video/mpeg", "mpegversion", G_TYPE_INT, 1, "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height,
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
break;
case TSMF_SUB_TYPE_YUY2:
#if GST_VERSION_MAJOR > 0
- mdecoder->gst_caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, "YUY2",
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-raw", "format", G_TYPE_STRING, "YUY2", "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height, NULL);
#else
- mdecoder->gst_caps = gst_caps_new_simple("video/x-raw-yuv",
- "format", G_TYPE_STRING, "YUY2",
- "width", G_TYPE_INT, media_type->Width,
- "height", G_TYPE_INT, media_type->Height,
- "framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple(
+ "video/x-raw-yuv", "format", G_TYPE_STRING, "YUY2", "width", G_TYPE_INT,
+ media_type->Width, "height", G_TYPE_INT, media_type->Height, "framerate",
+ GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator,
+ media_type->SamplesPerSecond.Denominator, NULL);
#endif
break;
case TSMF_SUB_TYPE_MP2V:
- mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
- "mpegversion", G_TYPE_INT, 2,
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- NULL);
+ mdecoder->gst_caps = gst_caps_new_simple("video/mpeg", "mpegversion", G_TYPE_INT, 2,
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
break;
case TSMF_SUB_TYPE_MP2A:
- mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
- "channels", G_TYPE_INT, media_type->Channels,
- NULL);
+ mdecoder->gst_caps =
+ gst_caps_new_simple("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "rate", G_TYPE_INT,
+ media_type->SamplesPerSecond.Numerator, "channels", G_TYPE_INT,
+ media_type->Channels, NULL);
break;
case TSMF_SUB_TYPE_FLAC:
- mdecoder->gst_caps = gst_caps_new_simple("audio/x-flac", "", NULL);
+ mdecoder->gst_caps = gst_caps_new_simple("audio/x-flac", "", NULL);
break;
default:
WLog_ERR(TAG, "unknown format:(%d).", media_type->SubType);
@@ -502,8 +473,8 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* m
if (media_type->ExtraDataSize > 0)
{
- GstBuffer *buffer;
- DEBUG_TSMF("Extra data available (%"PRIu32")", media_type->ExtraDataSize);
+ GstBuffer* buffer;
+ DEBUG_TSMF("Extra data available (%" PRIu32 ")", media_type->ExtraDataSize);
buffer = tsmf_get_buffer_from_data(media_type->ExtraData, media_type->ExtraDataSize);
if (!buffer)
@@ -515,7 +486,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* m
gst_caps_set_simple(mdecoder->gst_caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
}
- DEBUG_TSMF("%p format '%s'", (void*) mdecoder, gst_caps_to_string(mdecoder->gst_caps));
+ DEBUG_TSMF("%p format '%s'", (void*)mdecoder, gst_caps_to_string(mdecoder->gst_caps));
tsmf_platform_set_format(mdecoder);
/* Create the pipeline... */
@@ -547,11 +518,17 @@ void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder* mdecoder)
BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder)
{
#if GST_VERSION_MAJOR > 0
- const char* video = "appsrc name=videosource ! queue2 name=videoqueue ! decodebin name=videodecoder !";
- const char* audio = "appsrc name=audiosource ! queue2 name=audioqueue ! decodebin name=audiodecoder ! audioconvert ! audiorate ! audioresample ! volume name=audiovolume !";
+ const char* video =
+ "appsrc name=videosource ! queue2 name=videoqueue ! decodebin name=videodecoder !";
+ const char* audio =
+ "appsrc name=audiosource ! queue2 name=audioqueue ! decodebin name=audiodecoder ! "
+ "audioconvert ! audiorate ! audioresample ! volume name=audiovolume !";
#else
- const char* video = "appsrc name=videosource ! queue2 name=videoqueue ! decodebin2 name=videodecoder !";
- const char* audio = "appsrc name=audiosource ! queue2 name=audioqueue ! decodebin2 name=audiodecoder ! audioconvert ! audiorate ! audioresample ! volume name=audiovolume !";
+ const char* video =
+ "appsrc name=videosource ! queue2 name=videoqueue ! decodebin2 name=videodecoder !";
+ const char* audio =
+ "appsrc name=audiosource ! queue2 name=audioqueue ! decodebin2 name=audiodecoder ! "
+ "audioconvert ! audiorate ! audioresample ! volume name=audiovolume !";
#endif
char pipeline[1024];
@@ -562,9 +539,11 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder)
* The only fixed elements necessary are appsrc and the volume element for audio streams.
* The rest could easily be provided in gstreamer pipeline notation from command line. */
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
- sprintf_s(pipeline, sizeof(pipeline), "%s %s name=videosink", video, tsmf_platform_get_video_sink());
+ sprintf_s(pipeline, sizeof(pipeline), "%s %s name=videosink", video,
+ tsmf_platform_get_video_sink());
else
- sprintf_s(pipeline, sizeof(pipeline), "%s %s name=audiosink", audio, tsmf_platform_get_audio_sink());
+ sprintf_s(pipeline, sizeof(pipeline), "%s %s name=audiosink", audio,
+ tsmf_platform_get_audio_sink());
DEBUG_TSMF("pipeline=%s", pipeline);
mdecoder->pipe = gst_parse_launch(pipeline, NULL);
@@ -620,49 +599,54 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder)
return FALSE;
}
- tsmf_gstreamer_change_volume((ITSMFDecoder*)mdecoder, mdecoder->gstVolume*((double) 10000), mdecoder->gstMuted);
+ tsmf_gstreamer_change_volume((ITSMFDecoder*)mdecoder, mdecoder->gstVolume * ((double)10000),
+ mdecoder->gstMuted);
}
tsmf_platform_register_handler(mdecoder);
/* AppSrc settings */
- GstAppSrcCallbacks callbacks =
- {
- tsmf_gstreamer_need_data,
- tsmf_gstreamer_enough_data,
- tsmf_gstreamer_seek_data,
- { NULL }
+ GstAppSrcCallbacks callbacks = {
+ tsmf_gstreamer_need_data, tsmf_gstreamer_enough_data, tsmf_gstreamer_seek_data, { NULL }
};
g_object_set(mdecoder->src, "format", GST_FORMAT_TIME, NULL);
g_object_set(mdecoder->src, "is-live", FALSE, NULL);
g_object_set(mdecoder->src, "block", FALSE, NULL);
g_object_set(mdecoder->src, "blocksize", 1024, NULL);
- gst_app_src_set_caps((GstAppSrc *) mdecoder->src, mdecoder->gst_caps);
- gst_app_src_set_callbacks((GstAppSrc *)mdecoder->src, &callbacks, mdecoder, NULL);
- gst_app_src_set_stream_type((GstAppSrc *) mdecoder->src, GST_APP_STREAM_TYPE_SEEKABLE);
- gst_app_src_set_latency((GstAppSrc *) mdecoder->src, 0, -1);
- gst_app_src_set_max_bytes((GstAppSrc *) mdecoder->src, (guint64) 0);//unlimited
+ gst_app_src_set_caps((GstAppSrc*)mdecoder->src, mdecoder->gst_caps);
+ gst_app_src_set_callbacks((GstAppSrc*)mdecoder->src, &callbacks, mdecoder, NULL);
+ gst_app_src_set_stream_type((GstAppSrc*)mdecoder->src, GST_APP_STREAM_TYPE_SEEKABLE);
+ gst_app_src_set_latency((GstAppSrc*)mdecoder->src, 0, -1);
+ gst_app_src_set_max_bytes((GstAppSrc*)mdecoder->src, (guint64)0); // unlimited
g_object_set(G_OBJECT(mdecoder->queue), "use-buffering", FALSE, NULL);
g_object_set(G_OBJECT(mdecoder->queue), "use-rate-estimate", FALSE, NULL);
g_object_set(G_OBJECT(mdecoder->queue), "max-size-buffers", 0, NULL);
g_object_set(G_OBJECT(mdecoder->queue), "max-size-bytes", 0, NULL);
- g_object_set(G_OBJECT(mdecoder->queue), "max-size-time", (guint64) 0, NULL);
+ g_object_set(G_OBJECT(mdecoder->queue), "max-size-time", (guint64)0, NULL);
- /* Only set these properties if not an autosink, otherwise we will set properties when real sinks are added */
- if (!g_strcmp0(G_OBJECT_TYPE_NAME(mdecoder->outsink), "GstAutoVideoSink") && !g_strcmp0(G_OBJECT_TYPE_NAME(mdecoder->outsink), "GstAutoAudioSink"))
+ /* Only set these properties if not an autosink, otherwise we will set properties when real
+ * sinks are added */
+ if (!g_strcmp0(G_OBJECT_TYPE_NAME(mdecoder->outsink), "GstAutoVideoSink") &&
+ !g_strcmp0(G_OBJECT_TYPE_NAME(mdecoder->outsink), "GstAutoAudioSink"))
{
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
{
- gst_base_sink_set_max_lateness((GstBaseSink *) mdecoder->outsink, 10000000); /* nanoseconds */
+ gst_base_sink_set_max_lateness((GstBaseSink*)mdecoder->outsink,
+ 10000000); /* nanoseconds */
}
else
{
- gst_base_sink_set_max_lateness((GstBaseSink *) mdecoder->outsink, 10000000); /* nanoseconds */
- g_object_set(G_OBJECT(mdecoder->outsink), "buffer-time", (gint64) 20000, NULL); /* microseconds */
- g_object_set(G_OBJECT(mdecoder->outsink), "drift-tolerance", (gint64) 20000, NULL); /* microseconds */
- g_object_set(G_OBJECT(mdecoder->outsink), "latency-time", (gint64) 10000, NULL); /* microseconds */
+ gst_base_sink_set_max_lateness((GstBaseSink*)mdecoder->outsink,
+ 10000000); /* nanoseconds */
+ g_object_set(G_OBJECT(mdecoder->outsink), "buffer-time", (gint64)20000,
+ NULL); /* microseconds */
+ g_object_set(G_OBJECT(mdecoder->outsink), "drift-tolerance", (gint64)20000,
+ NULL); /* microseconds */
+ g_object_set(G_OBJECT(mdecoder->outsink), "latency-time", (gint64)10000,
+ NULL); /* microseconds */
g_object_set(G_OBJECT(mdecoder->outsink), "slave-method", 1, NULL);
}
- g_object_set(G_OBJECT(mdecoder->outsink), "sync", TRUE, NULL); /* synchronize on the clock */
+ g_object_set(G_OBJECT(mdecoder->outsink), "sync", TRUE,
+ NULL); /* synchronize on the clock */
g_object_set(G_OBJECT(mdecoder->outsink), "async", TRUE, NULL); /* no async state changes */
}
@@ -673,16 +657,18 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder)
mdecoder->shutdown = 0;
mdecoder->paused = FALSE;
- GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(mdecoder->pipe), GST_DEBUG_GRAPH_SHOW_ALL, get_type(mdecoder));
+ GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(mdecoder->pipe), GST_DEBUG_GRAPH_SHOW_ALL,
+ get_type(mdecoder));
return TRUE;
}
-static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UINT32 data_size, UINT32 extensions,
- UINT64 start_time, UINT64 end_time, UINT64 duration)
+static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size,
+ UINT32 extensions, UINT64 start_time, UINT64 end_time,
+ UINT64 duration)
{
- GstBuffer *gst_buf;
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ GstBuffer* gst_buf;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
UINT64 sample_time = tsmf_gstreamer_timestamp_ms_to_gst(start_time);
BOOL useTimestamps = TRUE;
@@ -698,9 +684,9 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
* We don't expect to block here often, since the pipeline should
* have more than enough buffering.
*/
- DEBUG_TSMF("%s. Start:(%"PRIu64") End:(%"PRIu64") Duration:(%"PRIu64") Last Start:(%"PRIu64")",
- get_type(mdecoder), start_time, end_time, duration,
- mdecoder->last_sample_start_time);
+ DEBUG_TSMF(
+ "%s. Start:(%" PRIu64 ") End:(%" PRIu64 ") Duration:(%" PRIu64 ") Last Start:(%" PRIu64 ")",
+ get_type(mdecoder), start_time, end_time, duration, mdecoder->last_sample_start_time);
if (mdecoder->shutdown)
{
@@ -719,7 +705,9 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
if (!mdecoder->src)
{
- WLog_ERR(TAG, "failed to construct pipeline correctly. Unable to push buffer to source element.");
+ WLog_ERR(
+ TAG,
+ "failed to construct pipeline correctly. Unable to push buffer to source element.");
return FALSE;
}
@@ -727,7 +715,7 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
if (gst_buf == NULL)
{
- WLog_ERR(TAG, "tsmf_get_buffer_from_data(%p, %"PRIu32") failed.", (void*) data, data_size);
+ WLog_ERR(TAG, "tsmf_get_buffer_from_data(%p, %" PRIu32 ") failed.", (void*)data, data_size);
return FALSE;
}
@@ -752,46 +740,54 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
{
mdecoder->seeking = FALSE;
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
- mdecoder->pipeline_start_time_valid = 0;
+ mdecoder->pipeline_start_time_valid = 0;
}
if (mdecoder->pipeline_start_time_valid)
{
- DEBUG_TSMF("%s start time %"PRIu64"", get_type(mdecoder), start_time);
+ DEBUG_TSMF("%s start time %" PRIu64 "", get_type(mdecoder), start_time);
/* Adjusted the condition for a seek to be based on start time only
* WMV1 and WMV2 files in particular have bad end time and duration values
* there seems to be no real side effects of just using the start time instead
*/
- UINT64 minTime = mdecoder->last_sample_start_time - (UINT64) SEEK_TOLERANCE;
- UINT64 maxTime = mdecoder->last_sample_start_time + (UINT64) SEEK_TOLERANCE;
+ UINT64 minTime = mdecoder->last_sample_start_time - (UINT64)SEEK_TOLERANCE;
+ UINT64 maxTime = mdecoder->last_sample_start_time + (UINT64)SEEK_TOLERANCE;
- /* Make sure the minTime stops at 0 , should we be at the beginning of the stream */
- if (mdecoder->last_sample_start_time < (UINT64) SEEK_TOLERANCE)
- minTime = 0;
+ /* Make sure the minTime stops at 0 , should we be at the beginning of the stream */
+ if (mdecoder->last_sample_start_time < (UINT64)SEEK_TOLERANCE)
+ minTime = 0;
- /* If the start_time is valid and different from the previous start time by more than the seek tolerance, then we have a seek condition */
+ /* If the start_time is valid and different from the previous start time by more than the
+ * seek tolerance, then we have a seek condition */
if (((start_time > maxTime) || (start_time < minTime)) && useTimestamps)
{
- DEBUG_TSMF("tsmf_gstreamer_decodeEx: start_time=[%"PRIu64"] > last_sample_start_time=[%"PRIu64"] OR ", start_time, mdecoder->last_sample_start_time);
- DEBUG_TSMF("tsmf_gstreamer_decodeEx: start_time=[%"PRIu64"] < last_sample_start_time=[%"PRIu64"] with", start_time, mdecoder->last_sample_start_time);
- DEBUG_TSMF("tsmf_gstreamer_decodeEX: a tolerance of more than [%lu] from the last sample", SEEK_TOLERANCE);
- DEBUG_TSMF("tsmf_gstreamer_decodeEX: minTime=[%"PRIu64"] maxTime=[%"PRIu64"]", minTime, maxTime);
+ DEBUG_TSMF("tsmf_gstreamer_decodeEx: start_time=[%" PRIu64
+ "] > last_sample_start_time=[%" PRIu64 "] OR ",
+ start_time, mdecoder->last_sample_start_time);
+ DEBUG_TSMF("tsmf_gstreamer_decodeEx: start_time=[%" PRIu64
+ "] < last_sample_start_time=[%" PRIu64 "] with",
+ start_time, mdecoder->last_sample_start_time);
+ DEBUG_TSMF(
+ "tsmf_gstreamer_decodeEX: a tolerance of more than [%lu] from the last sample",
+ SEEK_TOLERANCE);
+ DEBUG_TSMF("tsmf_gstreamer_decodeEX: minTime=[%" PRIu64 "] maxTime=[%" PRIu64 "]",
+ minTime, maxTime);
mdecoder->seeking = TRUE;
- /* since we cant make the gstreamer pipeline jump to the new start time after a seek - we just maintain
- * a offset between realtime and gstreamer time
+ /* since we cant make the gstreamer pipeline jump to the new start time after a seek -
+ * we just maintain a offset between realtime and gstreamer time
*/
mdecoder->seek_offset = start_time;
}
}
else
{
- DEBUG_TSMF("%s start time %"PRIu64"", get_type(mdecoder), start_time);
+ DEBUG_TSMF("%s start time %" PRIu64 "", get_type(mdecoder), start_time);
/* Always set base/start time to 0. Will use seek offset to translate real buffer times
- * back to 0. This allows the video to be started from anywhere and the ability to handle seeks
- * without rebuilding the pipeline, etc. since that is costly
+ * back to 0. This allows the video to be started from anywhere and the ability to handle
+ * seeks without rebuilding the pipeline, etc. since that is costly
*/
gst_element_set_base_time(mdecoder->pipe, tsmf_gstreamer_timestamp_ms_to_gst(0));
gst_element_set_start_time(mdecoder->pipe, tsmf_gstreamer_timestamp_ms_to_gst(0));
@@ -802,8 +798,7 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
mdecoder->seek_offset = start_time;
if (!gst_element_seek(mdecoder->pipe, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
- GST_SEEK_TYPE_SET, 0,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+ GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
{
WLog_ERR(TAG, "seek failed");
}
@@ -811,12 +806,14 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
#if GST_VERSION_MAJOR > 0
if (useTimestamps)
- GST_BUFFER_PTS(gst_buf) = sample_time - tsmf_gstreamer_timestamp_ms_to_gst(mdecoder->seek_offset);
+ GST_BUFFER_PTS(gst_buf) =
+ sample_time - tsmf_gstreamer_timestamp_ms_to_gst(mdecoder->seek_offset);
else
GST_BUFFER_PTS(gst_buf) = GST_CLOCK_TIME_NONE;
#else
if (useTimestamps)
- GST_BUFFER_TIMESTAMP(gst_buf) = sample_time - tsmf_gstreamer_timestamp_ms_to_gst(mdecoder->seek_offset);
+ GST_BUFFER_TIMESTAMP(gst_buf) =
+ sample_time - tsmf_gstreamer_timestamp_ms_to_gst(mdecoder->seek_offset);
else
GST_BUFFER_TIMESTAMP(gst_buf) = GST_CLOCK_TIME_NONE;
#endif
@@ -837,9 +834,11 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
if (mdecoder->pipe && (GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING))
{
- DEBUG_TSMF("%s: state=%s", get_type(mdecoder), gst_element_state_get_name(GST_STATE(mdecoder->pipe)));
+ DEBUG_TSMF("%s: state=%s", get_type(mdecoder),
+ gst_element_state_get_name(GST_STATE(mdecoder->pipe)));
- DEBUG_TSMF("%s Paused: %"PRIi32" Shutdown: %i Ready: %"PRIi32"", get_type(mdecoder), mdecoder->paused, mdecoder->shutdown, mdecoder->ready);
+ DEBUG_TSMF("%s Paused: %" PRIi32 " Shutdown: %i Ready: %" PRIi32 "", get_type(mdecoder),
+ mdecoder->paused, mdecoder->shutdown, mdecoder->ready);
if (!mdecoder->paused && !mdecoder->shutdown && mdecoder->ready)
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
}
@@ -847,9 +846,9 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder* decoder, const BYTE *data, UIN
return TRUE;
}
-static BOOL tsmf_gstreamer_control(ITSMFDecoder* decoder, ITSMFControlMsg control_msg, UINT32 *arg)
+static BOOL tsmf_gstreamer_control(ITSMFDecoder* decoder, ITSMFControlMsg control_msg, UINT32* arg)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
if (!mdecoder)
{
@@ -922,7 +921,7 @@ static BOOL tsmf_gstreamer_control(ITSMFDecoder* decoder, ITSMFControlMsg contro
static BOOL tsmf_gstreamer_buffer_level(ITSMFDecoder* decoder)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
DEBUG_TSMF("");
if (!mdecoder)
@@ -939,7 +938,7 @@ static BOOL tsmf_gstreamer_buffer_level(ITSMFDecoder* decoder)
static void tsmf_gstreamer_free(ITSMFDecoder* decoder)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
DEBUG_TSMF("%s", get_type(mdecoder));
if (mdecoder)
@@ -959,7 +958,7 @@ static void tsmf_gstreamer_free(ITSMFDecoder* decoder)
static UINT64 tsmf_gstreamer_get_running_time(ITSMFDecoder* decoder)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
if (!mdecoder)
return 0;
@@ -977,38 +976,37 @@ static UINT64 tsmf_gstreamer_get_running_time(ITSMFDecoder* decoder)
#else
gst_element_query_position(mdecoder->pipe, &fmt, &pos);
#endif
- return (UINT64) (pos/100 + mdecoder->seek_offset);
+ return (UINT64)(pos / 100 + mdecoder->seek_offset);
}
-static BOOL tsmf_gstreamer_update_rendering_area(ITSMFDecoder* decoder,
- int newX, int newY, int newWidth, int newHeight, int numRectangles,
- RDP_RECT *rectangles)
+static BOOL tsmf_gstreamer_update_rendering_area(ITSMFDecoder* decoder, int newX, int newY,
+ int newWidth, int newHeight, int numRectangles,
+ RDP_RECT* rectangles)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
- DEBUG_TSMF("x=%d, y=%d, w=%d, h=%d, rect=%d", newX, newY, newWidth,
- newHeight, numRectangles);
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
+ DEBUG_TSMF("x=%d, y=%d, w=%d, h=%d, rect=%d", newX, newY, newWidth, newHeight, numRectangles);
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
{
- return tsmf_window_resize(mdecoder, newX, newY, newWidth, newHeight,
- numRectangles, rectangles) == 0;
+ return tsmf_window_resize(mdecoder, newX, newY, newWidth, newHeight, numRectangles,
+ rectangles) == 0;
}
return TRUE;
}
-BOOL tsmf_gstreamer_ack(ITSMFDecoder* decoder, BOOL (*cb)(void *, BOOL), void *stream)
+BOOL tsmf_gstreamer_ack(ITSMFDecoder* decoder, BOOL (*cb)(void*, BOOL), void* stream)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
DEBUG_TSMF("");
mdecoder->ack_cb = NULL;
mdecoder->stream = stream;
return TRUE;
}
-BOOL tsmf_gstreamer_sync(ITSMFDecoder* decoder, void (*cb)(void *), void *stream)
+BOOL tsmf_gstreamer_sync(ITSMFDecoder* decoder, void (*cb)(void*), void* stream)
{
- TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder *) decoder;
+ TSMFGstreamerDecoder* mdecoder = (TSMFGstreamerDecoder*)decoder;
DEBUG_TSMF("");
mdecoder->sync_cb = NULL;
mdecoder->stream = stream;
@@ -1016,16 +1014,16 @@ BOOL tsmf_gstreamer_sync(ITSMFDecoder* decoder, void (*cb)(void *), void *stream
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_tsmf_client_subsystem_entry gstreamer_freerdp_tsmf_client_decoder_subsystem_entry
+#define freerdp_tsmf_client_subsystem_entry gstreamer_freerdp_tsmf_client_decoder_subsystem_entry
#else
-#define freerdp_tsmf_client_subsystem_entry FREERDP_API freerdp_tsmf_client_decoder_subsystem_entry
+#define freerdp_tsmf_client_subsystem_entry FREERDP_API freerdp_tsmf_client_decoder_subsystem_entry
#endif
ITSMFDecoder* freerdp_tsmf_client_subsystem_entry(void)
{
- TSMFGstreamerDecoder *decoder;
+ TSMFGstreamerDecoder* decoder;
-#if GST_CHECK_VERSION(0,10,31)
+#if GST_CHECK_VERSION(0, 10, 31)
if (!gst_is_initialized())
{
gst_init(NULL, NULL);
@@ -1056,7 +1054,7 @@ ITSMFDecoder* freerdp_tsmf_client_subsystem_entry(void)
decoder->paused = FALSE;
decoder->gstVolume = 0.5;
decoder->gstMuted = FALSE;
- decoder->state = GST_STATE_VOID_PENDING; /* No real state yet */
+ decoder->state = GST_STATE_VOID_PENDING; /* No real state yet */
decoder->last_sample_start_time = 0;
decoder->last_sample_end_time = 0;
decoder->seek_offset = 0;
@@ -1068,5 +1066,5 @@ ITSMFDecoder* freerdp_tsmf_client_subsystem_entry(void)
return NULL;
}
- return (ITSMFDecoder*) decoder;
+ return (ITSMFDecoder*)decoder;
}
diff --git a/channels/tsmf/client/gstreamer/tsmf_platform.h b/channels/tsmf/client/gstreamer/tsmf_platform.h
index 7fb6be1f7..970a59984 100644
--- a/channels/tsmf/client/gstreamer/tsmf_platform.h
+++ b/channels/tsmf/client/gstreamer/tsmf_platform.h
@@ -17,7 +17,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
+ */
#ifndef FREERDP_CHANNEL_TSMF_CLIENT_GST_PLATFORM_H
#define FREERDP_CHANNEL_TSMF_CLIENT_GST_PLATFORM_H
@@ -34,13 +34,13 @@ typedef struct _TSMFGstreamerDecoder
gint64 duration;
GstState state;
- GstCaps *gst_caps;
+ GstCaps* gst_caps;
- GstElement *pipe;
- GstElement *src;
- GstElement *queue;
- GstElement *outsink;
- GstElement *volume;
+ GstElement* pipe;
+ GstElement* src;
+ GstElement* queue;
+ GstElement* outsink;
+ GstElement* volume;
BOOL ready;
BOOL paused;
@@ -53,13 +53,13 @@ typedef struct _TSMFGstreamerDecoder
BOOL gstMuted;
int pipeline_start_time_valid; /* We've set the start time and have not reset the pipeline */
- int shutdown; /* The decoder stream is shutting down */
+ int shutdown; /* The decoder stream is shutting down */
- void *platform;
+ void* platform;
- BOOL (*ack_cb)(void *,BOOL);
- void (*sync_cb)(void *);
- void *stream;
+ BOOL (*ack_cb)(void*, BOOL);
+ void (*sync_cb)(void*);
+ void* stream;
} TSMFGstreamerDecoder;
@@ -74,8 +74,8 @@ int tsmf_platform_register_handler(TSMFGstreamerDecoder* decoder);
int tsmf_platform_free(TSMFGstreamerDecoder* decoder);
int tsmf_window_create(TSMFGstreamerDecoder* decoder);
-int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y,
- int width, int height, int nr_rect, RDP_RECT *visible);
+int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, int height,
+ int nr_rect, RDP_RECT* visible);
int tsmf_window_destroy(TSMFGstreamerDecoder* decoder);
int tsmf_window_map(TSMFGstreamerDecoder* decoder);
diff --git a/channels/tsmf/client/oss/tsmf_oss.c b/channels/tsmf/client/oss/tsmf_oss.c
index 67a792728..774affbd1 100644
--- a/channels/tsmf/client/oss/tsmf_oss.c
+++ b/channels/tsmf/client/oss/tsmf_oss.c
@@ -46,7 +46,6 @@
#include "tsmf_audio.h"
-
typedef struct _TSMFOSSAudioDevice
{
ITSMFAudioDevice iface;
@@ -61,12 +60,10 @@ typedef struct _TSMFOSSAudioDevice
UINT32 data_size_last;
} TSMFOssAudioDevice;
-
#define OSS_LOG_ERR(_text, _error) \
- if (_error != 0) \
+ if (_error != 0) \
WLog_ERR(TAG, "%s: %i - %s", _text, _error, strerror(_error));
-
static BOOL tsmf_oss_open(ITSMFAudioDevice* audio, const char* device)
{
int tmp;
@@ -75,7 +72,7 @@ static BOOL tsmf_oss_open(ITSMFAudioDevice* audio, const char* device)
if (oss == NULL || oss->pcm_handle != -1)
return FALSE;
- if (device == NULL) /* Default device. */
+ if (device == NULL) /* Default device. */
{
strncpy(oss->dev_name, "/dev/dsp", sizeof(oss->dev_name));
}
@@ -161,7 +158,7 @@ static BOOL tsmf_oss_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UIN
if (ioctl(oss->pcm_handle, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1)
OSS_LOG_ERR("SNDCTL_DSP_SETFRAGMENT failed", errno);
- DEBUG_TSMF("sample_rate %"PRIu32" channels %"PRIu32" bits_per_sample %"PRIu32"",
+ DEBUG_TSMF("sample_rate %" PRIu32 " channels %" PRIu32 " bits_per_sample %" PRIu32 "",
sample_rate, channels, bits_per_sample);
return TRUE;
}
@@ -171,7 +168,7 @@ static BOOL tsmf_oss_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data
int status;
UINT32 offset;
TSMFOssAudioDevice* oss = (TSMFOssAudioDevice*)audio;
- DEBUG_TSMF("tsmf_oss_play: data_size %"PRIu32"", data_size);
+ DEBUG_TSMF("tsmf_oss_play: data_size %" PRIu32 "", data_size);
if (oss == NULL || oss->pcm_handle == -1)
return FALSE;
@@ -206,8 +203,8 @@ static UINT64 tsmf_oss_get_latency(ITSMFAudioDevice* audio)
if (oss == NULL)
return 0;
- //latency = ((oss->data_size_last / (oss->bits_per_sample / 8)) * oss->sample_rate);
- //WLog_INFO(TAG, "latency: %zu", latency);
+ // latency = ((oss->data_size_last / (oss->bits_per_sample / 8)) * oss->sample_rate);
+ // WLog_INFO(TAG, "latency: %zu", latency);
return latency;
}
@@ -233,9 +230,10 @@ static void tsmf_oss_free(ITSMFAudioDevice* audio)
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_tsmf_client_audio_subsystem_entry oss_freerdp_tsmf_client_audio_subsystem_entry
+#define freerdp_tsmf_client_audio_subsystem_entry oss_freerdp_tsmf_client_audio_subsystem_entry
#else
-#define freerdp_tsmf_client_audio_subsystem_entry FREERDP_API freerdp_tsmf_client_audio_subsystem_entry
+#define freerdp_tsmf_client_audio_subsystem_entry \
+ FREERDP_API freerdp_tsmf_client_audio_subsystem_entry
#endif
ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
diff --git a/channels/tsmf/client/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c
index e63477c57..b2f567e05 100644
--- a/channels/tsmf/client/pulse/tsmf_pulse.c
+++ b/channels/tsmf/client/pulse/tsmf_pulse.c
@@ -45,7 +45,7 @@ typedef struct _TSMFPulseAudioDevice
static void tsmf_pulse_context_state_callback(pa_context* context, void* userdata)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) userdata;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata;
pa_context_state_t state;
state = pa_context_get_state(context);
@@ -77,8 +77,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice* pulse)
if (pa_context_connect(pulse->context, NULL, 0, NULL))
{
- WLog_ERR(TAG, "pa_context_connect failed (%d)",
- pa_context_errno(pulse->context));
+ WLog_ERR(TAG, "pa_context_connect failed (%d)", pa_context_errno(pulse->context));
return FALSE;
}
@@ -87,8 +86,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice* pulse)
if (pa_threaded_mainloop_start(pulse->mainloop) < 0)
{
pa_threaded_mainloop_unlock(pulse->mainloop);
- WLog_ERR(TAG, "pa_threaded_mainloop_start failed (%d)",
- pa_context_errno(pulse->context));
+ WLog_ERR(TAG, "pa_threaded_mainloop_start failed (%d)", pa_context_errno(pulse->context));
return FALSE;
}
@@ -101,8 +99,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice* pulse)
if (!PA_CONTEXT_IS_GOOD(state))
{
- DEBUG_TSMF("bad context state (%d)",
- pa_context_errno(pulse->context));
+ DEBUG_TSMF("bad context state (%d)", pa_context_errno(pulse->context));
break;
}
@@ -125,7 +122,7 @@ static BOOL tsmf_pulse_connect(TSMFPulseAudioDevice* pulse)
static BOOL tsmf_pulse_open(ITSMFAudioDevice* audio, const char* device)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
if (device)
{
@@ -162,7 +159,7 @@ static BOOL tsmf_pulse_open(ITSMFAudioDevice* audio, const char* device)
static void tsmf_pulse_stream_success_callback(pa_stream* stream, int success, void* userdata)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) userdata;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata;
pa_threaded_mainloop_signal(pulse->mainloop, 0);
}
@@ -181,7 +178,7 @@ static void tsmf_pulse_wait_for_operation(TSMFPulseAudioDevice* pulse, pa_operat
static void tsmf_pulse_stream_state_callback(pa_stream* stream, void* userdata)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) userdata;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata;
pa_stream_state_t state;
state = pa_stream_get_state(stream);
@@ -206,8 +203,8 @@ static void tsmf_pulse_stream_state_callback(pa_stream* stream, void* userdata)
static void tsmf_pulse_stream_request_callback(pa_stream* stream, size_t length, void* userdata)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) userdata;
- DEBUG_TSMF("%"PRIdz"", length);
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata;
+ DEBUG_TSMF("%" PRIdz "", length);
pa_threaded_mainloop_signal(pulse->mainloop, 0);
}
@@ -219,8 +216,8 @@ static BOOL tsmf_pulse_close_stream(TSMFPulseAudioDevice* pulse)
DEBUG_TSMF("");
pa_threaded_mainloop_lock(pulse->mainloop);
pa_stream_set_write_callback(pulse->stream, NULL, NULL);
- tsmf_pulse_wait_for_operation(pulse,
- pa_stream_drain(pulse->stream, tsmf_pulse_stream_success_callback, pulse));
+ tsmf_pulse_wait_for_operation(
+ pulse, pa_stream_drain(pulse->stream, tsmf_pulse_stream_success_callback, pulse));
pa_stream_disconnect(pulse->stream);
pa_stream_unref(pulse->stream);
pulse->stream = NULL;
@@ -238,35 +235,30 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice* pulse)
DEBUG_TSMF("");
pa_threaded_mainloop_lock(pulse->mainloop);
- pulse->stream = pa_stream_new(pulse->context, "freerdp",
- &pulse->sample_spec, NULL);
+ pulse->stream = pa_stream_new(pulse->context, "freerdp", &pulse->sample_spec, NULL);
if (!pulse->stream)
{
pa_threaded_mainloop_unlock(pulse->mainloop);
- WLog_ERR(TAG, "pa_stream_new failed (%d)",
- pa_context_errno(pulse->context));
+ WLog_ERR(TAG, "pa_stream_new failed (%d)", pa_context_errno(pulse->context));
return FALSE;
}
- pa_stream_set_state_callback(pulse->stream,
- tsmf_pulse_stream_state_callback, pulse);
- pa_stream_set_write_callback(pulse->stream,
- tsmf_pulse_stream_request_callback, pulse);
+ pa_stream_set_state_callback(pulse->stream, tsmf_pulse_stream_state_callback, pulse);
+ pa_stream_set_write_callback(pulse->stream, tsmf_pulse_stream_request_callback, pulse);
buffer_attr.maxlength = pa_usec_to_bytes(500000, &pulse->sample_spec);
buffer_attr.tlength = pa_usec_to_bytes(250000, &pulse->sample_spec);
- buffer_attr.prebuf = (UINT32) - 1;
- buffer_attr.minreq = (UINT32) - 1;
- buffer_attr.fragsize = (UINT32) - 1;
+ buffer_attr.prebuf = (UINT32)-1;
+ buffer_attr.minreq = (UINT32)-1;
+ buffer_attr.fragsize = (UINT32)-1;
- if (pa_stream_connect_playback(pulse->stream,
- pulse->device[0] ? pulse->device : NULL, &buffer_attr,
- PA_STREAM_ADJUST_LATENCY | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE,
- NULL, NULL) < 0)
+ if (pa_stream_connect_playback(
+ pulse->stream, pulse->device[0] ? pulse->device : NULL, &buffer_attr,
+ PA_STREAM_ADJUST_LATENCY | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE,
+ NULL, NULL) < 0)
{
pa_threaded_mainloop_unlock(pulse->mainloop);
- WLog_ERR(TAG, "pa_stream_connect_playback failed (%d)",
- pa_context_errno(pulse->context));
+ WLog_ERR(TAG, "pa_stream_connect_playback failed (%d)", pa_context_errno(pulse->context));
return FALSE;
}
@@ -279,8 +271,7 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice* pulse)
if (!PA_STREAM_IS_GOOD(state))
{
- WLog_ERR(TAG, "bad stream state (%d)",
- pa_context_errno(pulse->context));
+ WLog_ERR(TAG, "bad stream state (%d)", pa_context_errno(pulse->context));
break;
}
@@ -301,11 +292,11 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice* pulse)
}
}
-static BOOL tsmf_pulse_set_format(ITSMFAudioDevice* audio,
- UINT32 sample_rate, UINT32 channels, UINT32 bits_per_sample)
+static BOOL tsmf_pulse_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UINT32 channels,
+ UINT32 bits_per_sample)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
- DEBUG_TSMF("sample_rate %"PRIu32" channels %"PRIu32" bits_per_sample %"PRIu32"",
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
+ DEBUG_TSMF("sample_rate %" PRIu32 " channels %" PRIu32 " bits_per_sample %" PRIu32 "",
sample_rate, channels, bits_per_sample);
pulse->sample_spec.rate = sample_rate;
pulse->sample_spec.channels = channels;
@@ -315,11 +306,11 @@ static BOOL tsmf_pulse_set_format(ITSMFAudioDevice* audio,
static BOOL tsmf_pulse_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data_size)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
const BYTE* src;
size_t len;
int ret;
- DEBUG_TSMF("data_size %"PRIu32"", data_size);
+ DEBUG_TSMF("data_size %" PRIu32 "", data_size);
if (pulse->stream)
{
@@ -334,7 +325,7 @@ static BOOL tsmf_pulse_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 da
pa_threaded_mainloop_wait(pulse->mainloop);
}
- if (len == (size_t) -1)
+ if (len == (size_t)-1)
break;
if (len > data_size)
@@ -344,8 +335,7 @@ static BOOL tsmf_pulse_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 da
if (ret < 0)
{
- DEBUG_TSMF("pa_stream_write failed (%d)",
- pa_context_errno(pulse->context));
+ DEBUG_TSMF("pa_stream_write failed (%d)", pa_context_errno(pulse->context));
break;
}
@@ -363,7 +353,7 @@ static UINT64 tsmf_pulse_get_latency(ITSMFAudioDevice* audio)
{
pa_usec_t usec;
UINT64 latency = 0;
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
if (pulse->stream && pa_stream_get_latency(pulse->stream, &usec, NULL) == 0)
{
@@ -375,17 +365,17 @@ static UINT64 tsmf_pulse_get_latency(ITSMFAudioDevice* audio)
static BOOL tsmf_pulse_flush(ITSMFAudioDevice* audio)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
pa_threaded_mainloop_lock(pulse->mainloop);
- tsmf_pulse_wait_for_operation(pulse,
- pa_stream_flush(pulse->stream, tsmf_pulse_stream_success_callback, pulse));
+ tsmf_pulse_wait_for_operation(
+ pulse, pa_stream_flush(pulse->stream, tsmf_pulse_stream_success_callback, pulse));
pa_threaded_mainloop_unlock(pulse->mainloop);
return TRUE;
}
static void tsmf_pulse_free(ITSMFAudioDevice* audio)
{
- TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio;
+ TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio;
DEBUG_TSMF("");
tsmf_pulse_close_stream(pulse);
@@ -417,7 +407,7 @@ FREERDP_API ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
#endif
{
TSMFPulseAudioDevice* pulse;
- pulse = (TSMFPulseAudioDevice*) calloc(1, sizeof(TSMFPulseAudioDevice));
+ pulse = (TSMFPulseAudioDevice*)calloc(1, sizeof(TSMFPulseAudioDevice));
if (!pulse)
return NULL;
@@ -428,6 +418,5 @@ FREERDP_API ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
pulse->iface.GetLatency = tsmf_pulse_get_latency;
pulse->iface.Flush = tsmf_pulse_flush;
pulse->iface.Free = tsmf_pulse_free;
- return (ITSMFAudioDevice*) pulse;
+ return (ITSMFAudioDevice*)pulse;
}
-
diff --git a/channels/tsmf/client/tsmf_audio.c b/channels/tsmf/client/tsmf_audio.c
index 18d844c41..9f0bb3230 100644
--- a/channels/tsmf/client/tsmf_audio.c
+++ b/channels/tsmf/client/tsmf_audio.c
@@ -32,7 +32,8 @@ static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const
ITSMFAudioDevice* audio;
TSMF_AUDIO_DEVICE_ENTRY entry;
- entry = (TSMF_AUDIO_DEVICE_ENTRY) (void*)freerdp_load_channel_addin_entry("tsmf", name, "audio", 0);
+ entry =
+ (TSMF_AUDIO_DEVICE_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "audio", 0);
if (!entry)
return NULL;
@@ -84,7 +85,7 @@ ITSMFAudioDevice* tsmf_load_audio_device(const char* name, const char* device)
audio = tsmf_load_audio_device_by_name("alsa", device);
#endif
}
-
+
if (audio == NULL)
{
WLog_ERR(TAG, "no sound device.");
@@ -96,4 +97,3 @@ ITSMFAudioDevice* tsmf_load_audio_device(const char* name, const char* device)
return audio;
}
-
diff --git a/channels/tsmf/client/tsmf_audio.h b/channels/tsmf/client/tsmf_audio.h
index d589d5489..e7ae68cb1 100644
--- a/channels/tsmf/client/tsmf_audio.h
+++ b/channels/tsmf/client/tsmf_audio.h
@@ -29,12 +29,12 @@ struct _ITSMFAudioDevice
/* Open the audio device. */
BOOL (*Open)(ITSMFAudioDevice* audio, const char* device);
/* Set the audio data format. */
- BOOL (*SetFormat)(ITSMFAudioDevice* audio, UINT32 sample_rate, UINT32 channels,
- UINT32 bits_per_sample);
+ BOOL(*SetFormat)
+ (ITSMFAudioDevice* audio, UINT32 sample_rate, UINT32 channels, UINT32 bits_per_sample);
/* Play audio data. */
BOOL (*Play)(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data_size);
/* Get the latency of the last written sample, in 100ns */
- UINT64(*GetLatency)(ITSMFAudioDevice* audio);
+ UINT64 (*GetLatency)(ITSMFAudioDevice* audio);
/* Change the playback volume level */
BOOL (*ChangeVolume)(ITSMFAudioDevice* audio, UINT32 newVolume, UINT32 muted);
/* Flush queued audio data */
diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c
index 0918c456d..66723962d 100644
--- a/channels/tsmf/client/tsmf_codec.c
+++ b/channels/tsmf/client/tsmf_codec.c
@@ -43,260 +43,212 @@ typedef struct _TSMFMediaTypeMap
int type;
} TSMFMediaTypeMap;
-static const TSMFMediaTypeMap tsmf_major_type_map[] =
-{
+static const TSMFMediaTypeMap tsmf_major_type_map[] = {
/* 73646976-0000-0010-8000-00AA00389B71 */
- {
- { 0x76, 0x69, 0x64, 0x73, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIATYPE_Video",
- TSMF_MAJOR_TYPE_VIDEO
- },
+ { { 0x76, 0x69, 0x64, 0x73, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIATYPE_Video",
+ TSMF_MAJOR_TYPE_VIDEO },
/* 73647561-0000-0010-8000-00AA00389B71 */
- {
- { 0x61, 0x75, 0x64, 0x73, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIATYPE_Audio",
- TSMF_MAJOR_TYPE_AUDIO
- },
+ { { 0x61, 0x75, 0x64, 0x73, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIATYPE_Audio",
+ TSMF_MAJOR_TYPE_AUDIO },
- {
- { 0 },
- "Unknown",
- TSMF_MAJOR_TYPE_UNKNOWN
- }
+ { { 0 }, "Unknown", TSMF_MAJOR_TYPE_UNKNOWN }
};
-static const TSMFMediaTypeMap tsmf_sub_type_map[] =
-{
+static const TSMFMediaTypeMap tsmf_sub_type_map[] = {
/* 31435657-0000-0010-8000-00AA00389B71 */
- {
- { 0x57, 0x56, 0x43, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WVC1",
- TSMF_SUB_TYPE_WVC1
- },
+ { { 0x57, 0x56, 0x43, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WVC1",
+ TSMF_SUB_TYPE_WVC1 },
- /* 00000160-0000-0010-8000-00AA00389B71 */
- {
- { 0x60, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMAudioV1", /* V7, V8 has the same GUID */
- TSMF_SUB_TYPE_WMA1
- },
+ /* 00000160-0000-0010-8000-00AA00389B71 */
+ { { 0x60, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMAudioV1", /* V7, V8 has the same GUID */
+ TSMF_SUB_TYPE_WMA1 },
/* 00000161-0000-0010-8000-00AA00389B71 */
- {
- { 0x61, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMAudioV2", /* V7, V8 has the same GUID */
- TSMF_SUB_TYPE_WMA2
- },
+ { { 0x61, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMAudioV2", /* V7, V8 has the same GUID */
+ TSMF_SUB_TYPE_WMA2 },
/* 00000162-0000-0010-8000-00AA00389B71 */
- {
- { 0x62, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMAudioV9",
- TSMF_SUB_TYPE_WMA9
- },
+ { { 0x62, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMAudioV9",
+ TSMF_SUB_TYPE_WMA9 },
/* 00000055-0000-0010-8000-00AA00389B71 */
- {
- { 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP3",
- TSMF_SUB_TYPE_MP3
- },
+ { { 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP3",
+ TSMF_SUB_TYPE_MP3 },
/* E06D802B-DB46-11CF-B4D1-00805F6CBBEA */
- {
- { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA },
- "MEDIASUBTYPE_MPEG2_AUDIO",
- TSMF_SUB_TYPE_MP2A
- },
+ { { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB,
+ 0xEA },
+ "MEDIASUBTYPE_MPEG2_AUDIO",
+ TSMF_SUB_TYPE_MP2A },
/* E06D8026-DB46-11CF-B4D1-00805F6CBBEA */
- {
- { 0x26, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA },
- "MEDIASUBTYPE_MPEG2_VIDEO",
- TSMF_SUB_TYPE_MP2V
- },
+ { { 0x26, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB,
+ 0xEA },
+ "MEDIASUBTYPE_MPEG2_VIDEO",
+ TSMF_SUB_TYPE_MP2V },
/* 31564D57-0000-0010-8000-00AA00389B71 */
- {
- { 0x57, 0x4D, 0x56, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMV1",
- TSMF_SUB_TYPE_WMV1
- },
+ { { 0x57, 0x4D, 0x56, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMV1",
+ TSMF_SUB_TYPE_WMV1 },
/* 32564D57-0000-0010-8000-00AA00389B71 */
- {
- { 0x57, 0x4D, 0x56, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMV2",
- TSMF_SUB_TYPE_WMV2
- },
+ { { 0x57, 0x4D, 0x56, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMV2",
+ TSMF_SUB_TYPE_WMV2 },
/* 33564D57-0000-0010-8000-00AA00389B71 */
- {
- { 0x57, 0x4D, 0x56, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_WMV3",
- TSMF_SUB_TYPE_WMV3
- },
+ { { 0x57, 0x4D, 0x56, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_WMV3",
+ TSMF_SUB_TYPE_WMV3 },
/* 00001610-0000-0010-8000-00AA00389B71 */
- {
- { 0x10, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MPEG_HEAAC",
- TSMF_SUB_TYPE_AAC
- },
+ { { 0x10, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MPEG_HEAAC",
+ TSMF_SUB_TYPE_AAC },
/* 34363248-0000-0010-8000-00AA00389B71 */
- {
- { 0x48, 0x32, 0x36, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_H264",
- TSMF_SUB_TYPE_H264
- },
+ { { 0x48, 0x32, 0x36, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_H264",
+ TSMF_SUB_TYPE_H264 },
/* 31435641-0000-0010-8000-00AA00389B71 */
- {
- { 0x41, 0x56, 0x43, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_AVC1",
- TSMF_SUB_TYPE_AVC1
- },
+ { { 0x41, 0x56, 0x43, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_AVC1",
+ TSMF_SUB_TYPE_AVC1 },
/* 3334504D-0000-0010-8000-00AA00389B71 */
- {
- { 0x4D, 0x50, 0x34, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP43",
- TSMF_SUB_TYPE_MP43
- },
+ { { 0x4D, 0x50, 0x34, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP43",
+ TSMF_SUB_TYPE_MP43 },
/* 5634504D-0000-0010-8000-00AA00389B71 */
- {
- { 0x4D, 0x50, 0x34, 0x56, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP4S",
- TSMF_SUB_TYPE_MP4S
- },
+ { { 0x4D, 0x50, 0x34, 0x56, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP4S",
+ TSMF_SUB_TYPE_MP4S },
/* 3234504D-0000-0010-8000-00AA00389B71 */
- {
- { 0x4D, 0x50, 0x34, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP42",
- TSMF_SUB_TYPE_MP42
- },
+ { { 0x4D, 0x50, 0x34, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP42",
+ TSMF_SUB_TYPE_MP42 },
/* 3253344D-0000-0010-8000-00AA00389B71 */
- {
- { 0x4D, 0x34, 0x53, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP42",
- TSMF_SUB_TYPE_M4S2
- },
+ { { 0x4D, 0x34, 0x53, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP42",
+ TSMF_SUB_TYPE_M4S2 },
/* E436EB81-524F-11CE-9F53-0020AF0BA770 */
- {
- { 0x81, 0xEB, 0x36, 0xE4, 0x4F, 0x52, 0xCE, 0x11, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 },
- "MEDIASUBTYPE_MP1V",
- TSMF_SUB_TYPE_MP1V
- },
+ { { 0x81, 0xEB, 0x36, 0xE4, 0x4F, 0x52, 0xCE, 0x11, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7,
+ 0x70 },
+ "MEDIASUBTYPE_MP1V",
+ TSMF_SUB_TYPE_MP1V },
/* 00000050-0000-0010-8000-00AA00389B71 */
- {
- { 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_MP1A",
- TSMF_SUB_TYPE_MP1A
- },
+ { { 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_MP1A",
+ TSMF_SUB_TYPE_MP1A },
/* E06D802C-DB46-11CF-B4D1-00805F6CBBEA */
- {
- { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA },
- "MEDIASUBTYPE_DOLBY_AC3",
- TSMF_SUB_TYPE_AC3
- },
+ { { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB,
+ 0xEA },
+ "MEDIASUBTYPE_DOLBY_AC3",
+ TSMF_SUB_TYPE_AC3 },
/* 32595559-0000-0010-8000-00AA00389B71 */
- {
- { 0x59, 0x55, 0x59, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 },
- "MEDIASUBTYPE_YUY2",
- TSMF_SUB_TYPE_YUY2
- },
+ { { 0x59, 0x55, 0x59, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_YUY2",
+ TSMF_SUB_TYPE_YUY2 },
/* Opencodec IDS */
- {
- {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71},
- "MEDIASUBTYPE_FLAC",
- TSMF_SUB_TYPE_FLAC
- },
+ { { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_FLAC",
+ TSMF_SUB_TYPE_FLAC },
- {
- {0x61, 0x34, 0x70, 0x6D, 0x7A, 0x76, 0x4D, 0x49, 0xB4, 0x78, 0xF2, 0x9D, 0x25, 0xDC, 0x90, 0x37},
- "MEDIASUBTYPE_OGG",
- TSMF_SUB_TYPE_OGG
- },
+ { { 0x61, 0x34, 0x70, 0x6D, 0x7A, 0x76, 0x4D, 0x49, 0xB4, 0x78, 0xF2, 0x9D, 0x25, 0xDC, 0x90,
+ 0x37 },
+ "MEDIASUBTYPE_OGG",
+ TSMF_SUB_TYPE_OGG },
- {
- {0x4D, 0x34, 0x53, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71},
- "MEDIASUBTYPE_H263",
- TSMF_SUB_TYPE_H263
- },
+ { { 0x4D, 0x34, 0x53, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_H263",
+ TSMF_SUB_TYPE_H263 },
/* WebMMF codec IDS */
- {
- {0x56, 0x50, 0x38, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71},
- "MEDIASUBTYPE_VP8",
- TSMF_SUB_TYPE_VP8
- },
+ { { 0x56, 0x50, 0x38, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,
+ 0x71 },
+ "MEDIASUBTYPE_VP8",
+ TSMF_SUB_TYPE_VP8 },
- {
- {0x0B, 0xD1, 0x2F, 0x8D, 0x41, 0x58, 0x6B, 0x4A, 0x89, 0x05, 0x58, 0x8F, 0xEC, 0x1A, 0xDE, 0xD9},
- "MEDIASUBTYPE_OGG",
- TSMF_SUB_TYPE_OGG
- },
+ { { 0x0B, 0xD1, 0x2F, 0x8D, 0x41, 0x58, 0x6B, 0x4A, 0x89, 0x05, 0x58, 0x8F, 0xEC, 0x1A, 0xDE,
+ 0xD9 },
+ "MEDIASUBTYPE_OGG",
+ TSMF_SUB_TYPE_OGG },
- {
- { 0 },
- "Unknown",
- TSMF_SUB_TYPE_UNKNOWN
- }
+ { { 0 }, "Unknown", TSMF_SUB_TYPE_UNKNOWN }
};
-static const TSMFMediaTypeMap tsmf_format_type_map[] =
-{
+static const TSMFMediaTypeMap tsmf_format_type_map[] = {
/* AED4AB2D-7326-43CB-9464-C879CAB9C43D */
- {
- { 0x2D, 0xAB, 0xD4, 0xAE, 0x26, 0x73, 0xCB, 0x43, 0x94, 0x64, 0xC8, 0x79, 0xCA, 0xB9, 0xC4, 0x3D },
- "FORMAT_MFVideoFormat",
- TSMF_FORMAT_TYPE_MFVIDEOFORMAT
- },
+ { { 0x2D, 0xAB, 0xD4, 0xAE, 0x26, 0x73, 0xCB, 0x43, 0x94, 0x64, 0xC8, 0x79, 0xCA, 0xB9, 0xC4,
+ 0x3D },
+ "FORMAT_MFVideoFormat",
+ TSMF_FORMAT_TYPE_MFVIDEOFORMAT },
/* 05589F81-C356-11CE-BF01-00AA0055595A */
- {
- { 0x81, 0x9F, 0x58, 0x05, 0x56, 0xC3, 0xCE, 0x11, 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A },
- "FORMAT_WaveFormatEx",
- TSMF_FORMAT_TYPE_WAVEFORMATEX
- },
+ { { 0x81, 0x9F, 0x58, 0x05, 0x56, 0xC3, 0xCE, 0x11, 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59,
+ 0x5A },
+ "FORMAT_WaveFormatEx",
+ TSMF_FORMAT_TYPE_WAVEFORMATEX },
/* E06D80E3-DB46-11CF-B4D1-00805F6CBBEA */
- {
- { 0xE3, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA },
- "FORMAT_MPEG2_VIDEO",
- TSMF_FORMAT_TYPE_MPEG2VIDEOINFO
- },
+ { { 0xE3, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB,
+ 0xEA },
+ "FORMAT_MPEG2_VIDEO",
+ TSMF_FORMAT_TYPE_MPEG2VIDEOINFO },
/* F72A76A0-EB0A-11D0-ACE4-0000C0CC16BA */
- {
- { 0xA0, 0x76, 0x2A, 0xF7, 0x0A, 0xEB, 0xD0, 0x11, 0xAC, 0xE4, 0x00, 0x00, 0xC0, 0xCC, 0x16, 0xBA },
- "FORMAT_VideoInfo2",
- TSMF_FORMAT_TYPE_VIDEOINFO2
- },
+ { { 0xA0, 0x76, 0x2A, 0xF7, 0x0A, 0xEB, 0xD0, 0x11, 0xAC, 0xE4, 0x00, 0x00, 0xC0, 0xCC, 0x16,
+ 0xBA },
+ "FORMAT_VideoInfo2",
+ TSMF_FORMAT_TYPE_VIDEOINFO2 },
/* 05589F82-C356-11CE-BF01-00AA0055595A */
- {
- { 0x82, 0x9F, 0x58, 0x05, 0x56, 0xC3, 0xCE, 0x11, 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A },
- "FORMAT_MPEG1_VIDEO",
- TSMF_FORMAT_TYPE_MPEG1VIDEOINFO
- },
+ { { 0x82, 0x9F, 0x58, 0x05, 0x56, 0xC3, 0xCE, 0x11, 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59,
+ 0x5A },
+ "FORMAT_MPEG1_VIDEO",
+ TSMF_FORMAT_TYPE_MPEG1VIDEOINFO },
- {
- { 0 },
- "Unknown",
- TSMF_FORMAT_TYPE_UNKNOWN
- }
+ { { 0 }, "Unknown", TSMF_FORMAT_TYPE_UNKNOWN }
};
static void tsmf_print_guid(const BYTE* guid)
@@ -304,21 +256,20 @@ static void tsmf_print_guid(const BYTE* guid)
#ifdef WITH_DEBUG_TSMF
char guidString[37];
- snprintf(guidString, sizeof(guidString), "%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"-%02"PRIX8"%02"PRIX8"-%02"PRIX8"%02"PRIX8"-%02"PRIX8"%02"PRIX8"-%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"%02"PRIX8"",
- guid[3], guid[2], guid[1], guid[0],
- guid[5], guid[4],
- guid[7], guid[6],
- guid[8], guid[9],
- guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]
- );
-
+ snprintf(guidString, sizeof(guidString),
+ "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "-%02" PRIX8 "%02" PRIX8 "-%02" PRIX8
+ "%02" PRIX8 "-%02" PRIX8 "%02" PRIX8 "-%02" PRIX8 "%02" PRIX8 "%02" PRIX8 "%02" PRIX8
+ "%02" PRIX8 "%02" PRIX8 "",
+ guid[3], guid[2], guid[1], guid[0], guid[5], guid[4], guid[7], guid[6], guid[8],
+ guid[9], guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
WLog_INFO(TAG, "%s", guidString);
#endif
}
/* http://msdn.microsoft.com/en-us/library/dd318229.aspx */
-static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStream* s, BOOL bypass)
+static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStream* s,
+ BOOL bypass)
{
UINT32 biSize;
UINT32 biWidth;
@@ -338,7 +289,7 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt
mediatype->Height = biHeight;
/* Assume there will be no color table for video? */
- if ((biSize < 40) || (Stream_GetRemainingLength(s) < (biSize-40)))
+ if ((biSize < 40) || (Stream_GetRemainingLength(s) < (biSize - 40)))
return 0;
if (bypass && biSize > 40)
@@ -422,8 +373,8 @@ static BOOL tsmf_read_format_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s, UINT3
if (Stream_GetRemainingLength(s) < 176)
return FALSE;
- Stream_Seek(s, 8); /* dwSize and ? */
- Stream_Read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */
+ Stream_Seek(s, 8); /* dwSize and ? */
+ Stream_Read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */
Stream_Read_UINT32(s, mediatype->Height); /* videoInfo.dwHeight */
Stream_Seek(s, 32);
/* videoInfo.FramesPerSecond */
@@ -600,7 +551,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s)
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
Stream_Read_UINT32(s, cbFormat);
- DEBUG_TSMF("cbFormat %"PRIu32"", cbFormat);
+ DEBUG_TSMF("cbFormat %" PRIu32 "", cbFormat);
#ifdef WITH_DEBUG_TSMF
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Pointer(s), cbFormat);
#endif
@@ -627,7 +578,7 @@ BOOL tsmf_codec_check_media_type(const char* decoder_name, wStream* s)
if (firstRun)
{
- firstRun =FALSE;
+ firstRun = FALSE;
if (tsmf_check_decoder_available(decoder_name))
decoderAvailable = TRUE;
}
diff --git a/channels/tsmf/client/tsmf_codec.h b/channels/tsmf/client/tsmf_codec.h
index a678ea41c..ab988991d 100644
--- a/channels/tsmf/client/tsmf_codec.h
+++ b/channels/tsmf/client/tsmf_codec.h
@@ -26,4 +26,3 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s);
BOOL tsmf_codec_check_media_type(const char* decoder_name, wStream* s);
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_CODEC_H */
-
diff --git a/channels/tsmf/client/tsmf_constants.h b/channels/tsmf/client/tsmf_constants.h
index d84370a2a..43d37f27d 100644
--- a/channels/tsmf/client/tsmf_constants.h
+++ b/channels/tsmf/client/tsmf_constants.h
@@ -26,114 +26,114 @@
/* Interface IDs defined in [MS-RDPEV]. There's no constant names in the MS
documentation, so we create them on our own. */
-#define TSMF_INTERFACE_DEFAULT 0x00000000
-#define TSMF_INTERFACE_CLIENT_NOTIFICATIONS 0x00000001
-#define TSMF_INTERFACE_CAPABILITIES 0x00000002
+#define TSMF_INTERFACE_DEFAULT 0x00000000
+#define TSMF_INTERFACE_CLIENT_NOTIFICATIONS 0x00000001
+#define TSMF_INTERFACE_CAPABILITIES 0x00000002
/* Interface ID Mask */
-#define STREAM_ID_STUB 0x80000000
-#define STREAM_ID_PROXY 0x40000000
-#define STREAM_ID_NONE 0x00000000
+#define STREAM_ID_STUB 0x80000000
+#define STREAM_ID_PROXY 0x40000000
+#define STREAM_ID_NONE 0x00000000
/* Functon ID */
/* Common IDs for all interfaces are as follows. */
-#define RIMCALL_RELEASE 0x00000001
-#define RIMCALL_QUERYINTERFACE 0x00000002
+#define RIMCALL_RELEASE 0x00000001
+#define RIMCALL_QUERYINTERFACE 0x00000002
/* Capabilities Negotiator Interface IDs are as follows. */
-#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100
+#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100
/* The Client Notifications Interface ID is as follows. */
-#define PLAYBACK_ACK 0x00000100
-#define CLIENT_EVENT_NOTIFICATION 0x00000101
+#define PLAYBACK_ACK 0x00000100
+#define CLIENT_EVENT_NOTIFICATION 0x00000101
/* Server Data Interface IDs are as follows. */
-#define EXCHANGE_CAPABILITIES_REQ 0x00000100
-#define SET_CHANNEL_PARAMS 0x00000101
-#define ADD_STREAM 0x00000102
-#define ON_SAMPLE 0x00000103
-#define SET_VIDEO_WINDOW 0x00000104
-#define ON_NEW_PRESENTATION 0x00000105
-#define SHUTDOWN_PRESENTATION_REQ 0x00000106
-#define SET_TOPOLOGY_REQ 0x00000107
-#define CHECK_FORMAT_SUPPORT_REQ 0x00000108
-#define ON_PLAYBACK_STARTED 0x00000109
-#define ON_PLAYBACK_PAUSED 0x0000010a
-#define ON_PLAYBACK_STOPPED 0x0000010b
-#define ON_PLAYBACK_RESTARTED 0x0000010c
-#define ON_PLAYBACK_RATE_CHANGED 0x0000010d
-#define ON_FLUSH 0x0000010e
-#define ON_STREAM_VOLUME 0x0000010f
-#define ON_CHANNEL_VOLUME 0x00000110
-#define ON_END_OF_STREAM 0x00000111
-#define SET_ALLOCATOR 0x00000112
-#define NOTIFY_PREROLL 0x00000113
-#define UPDATE_GEOMETRY_INFO 0x00000114
-#define REMOVE_STREAM 0x00000115
-#define SET_SOURCE_VIDEO_RECT 0x00000116
+#define EXCHANGE_CAPABILITIES_REQ 0x00000100
+#define SET_CHANNEL_PARAMS 0x00000101
+#define ADD_STREAM 0x00000102
+#define ON_SAMPLE 0x00000103
+#define SET_VIDEO_WINDOW 0x00000104
+#define ON_NEW_PRESENTATION 0x00000105
+#define SHUTDOWN_PRESENTATION_REQ 0x00000106
+#define SET_TOPOLOGY_REQ 0x00000107
+#define CHECK_FORMAT_SUPPORT_REQ 0x00000108
+#define ON_PLAYBACK_STARTED 0x00000109
+#define ON_PLAYBACK_PAUSED 0x0000010a
+#define ON_PLAYBACK_STOPPED 0x0000010b
+#define ON_PLAYBACK_RESTARTED 0x0000010c
+#define ON_PLAYBACK_RATE_CHANGED 0x0000010d
+#define ON_FLUSH 0x0000010e
+#define ON_STREAM_VOLUME 0x0000010f
+#define ON_CHANNEL_VOLUME 0x00000110
+#define ON_END_OF_STREAM 0x00000111
+#define SET_ALLOCATOR 0x00000112
+#define NOTIFY_PREROLL 0x00000113
+#define UPDATE_GEOMETRY_INFO 0x00000114
+#define REMOVE_STREAM 0x00000115
+#define SET_SOURCE_VIDEO_RECT 0x00000116
/* Supported platform */
-#define MMREDIR_CAPABILITY_PLATFORM_MF 0x00000001
-#define MMREDIR_CAPABILITY_PLATFORM_DSHOW 0x00000002
-#define MMREDIR_CAPABILITY_PLATFORM_OTHER 0x00000004
+#define MMREDIR_CAPABILITY_PLATFORM_MF 0x00000001
+#define MMREDIR_CAPABILITY_PLATFORM_DSHOW 0x00000002
+#define MMREDIR_CAPABILITY_PLATFORM_OTHER 0x00000004
/* TSMM_CLIENT_EVENT Constants */
-#define TSMM_CLIENT_EVENT_ENDOFSTREAM 0x0064
-#define TSMM_CLIENT_EVENT_STOP_COMPLETED 0x00C8
-#define TSMM_CLIENT_EVENT_START_COMPLETED 0x00C9
-#define TSMM_CLIENT_EVENT_MONITORCHANGED 0x012C
+#define TSMM_CLIENT_EVENT_ENDOFSTREAM 0x0064
+#define TSMM_CLIENT_EVENT_STOP_COMPLETED 0x00C8
+#define TSMM_CLIENT_EVENT_START_COMPLETED 0x00C9
+#define TSMM_CLIENT_EVENT_MONITORCHANGED 0x012C
/* TS_MM_DATA_SAMPLE.SampleExtensions */
-#define TSMM_SAMPLE_EXT_CLEANPOINT 0x00000001
-#define TSMM_SAMPLE_EXT_DISCONTINUITY 0x00000002
-#define TSMM_SAMPLE_EXT_INTERLACED 0x00000004
-#define TSMM_SAMPLE_EXT_BOTTOMFIELDFIRST 0x00000008
-#define TSMM_SAMPLE_EXT_REPEATFIELDFIRST 0x00000010
-#define TSMM_SAMPLE_EXT_SINGLEFIELD 0x00000020
+#define TSMM_SAMPLE_EXT_CLEANPOINT 0x00000001
+#define TSMM_SAMPLE_EXT_DISCONTINUITY 0x00000002
+#define TSMM_SAMPLE_EXT_INTERLACED 0x00000004
+#define TSMM_SAMPLE_EXT_BOTTOMFIELDFIRST 0x00000008
+#define TSMM_SAMPLE_EXT_REPEATFIELDFIRST 0x00000010
+#define TSMM_SAMPLE_EXT_SINGLEFIELD 0x00000020
#define TSMM_SAMPLE_EXT_DERIVEDFROMTOPFIELD 0x00000040
-#define TSMM_SAMPLE_EXT_HAS_NO_TIMESTAMPS 0x00000080
+#define TSMM_SAMPLE_EXT_HAS_NO_TIMESTAMPS 0x00000080
#define TSMM_SAMPLE_EXT_RELATIVE_TIMESTAMPS 0x00000100
#define TSMM_SAMPLE_EXT_ABSOLUTE_TIMESTAMPS 0x00000200
/* MajorType */
-#define TSMF_MAJOR_TYPE_UNKNOWN 0
-#define TSMF_MAJOR_TYPE_VIDEO 1
-#define TSMF_MAJOR_TYPE_AUDIO 2
+#define TSMF_MAJOR_TYPE_UNKNOWN 0
+#define TSMF_MAJOR_TYPE_VIDEO 1
+#define TSMF_MAJOR_TYPE_AUDIO 2
/* SubType */
-#define TSMF_SUB_TYPE_UNKNOWN 0
-#define TSMF_SUB_TYPE_WVC1 1
-#define TSMF_SUB_TYPE_WMA2 2
-#define TSMF_SUB_TYPE_WMA9 3
-#define TSMF_SUB_TYPE_MP3 4
-#define TSMF_SUB_TYPE_MP2A 5
-#define TSMF_SUB_TYPE_MP2V 6
-#define TSMF_SUB_TYPE_WMV3 7
-#define TSMF_SUB_TYPE_AAC 8
-#define TSMF_SUB_TYPE_H264 9
-#define TSMF_SUB_TYPE_AVC1 10
-#define TSMF_SUB_TYPE_AC3 11
-#define TSMF_SUB_TYPE_WMV2 12
-#define TSMF_SUB_TYPE_WMV1 13
-#define TSMF_SUB_TYPE_MP1V 14
-#define TSMF_SUB_TYPE_MP1A 15
-#define TSMF_SUB_TYPE_YUY2 16
-#define TSMF_SUB_TYPE_MP43 17
-#define TSMF_SUB_TYPE_MP4S 18
-#define TSMF_SUB_TYPE_MP42 19
-#define TSMF_SUB_TYPE_OGG 20
-#define TSMF_SUB_TYPE_SPEEX 21
-#define TSMF_SUB_TYPE_THEORA 22
-#define TSMF_SUB_TYPE_FLAC 23
-#define TSMF_SUB_TYPE_VP8 24
-#define TSMF_SUB_TYPE_VP9 25
-#define TSMF_SUB_TYPE_H263 26
-#define TSMF_SUB_TYPE_M4S2 27
-#define TSMF_SUB_TYPE_WMA1 28
+#define TSMF_SUB_TYPE_UNKNOWN 0
+#define TSMF_SUB_TYPE_WVC1 1
+#define TSMF_SUB_TYPE_WMA2 2
+#define TSMF_SUB_TYPE_WMA9 3
+#define TSMF_SUB_TYPE_MP3 4
+#define TSMF_SUB_TYPE_MP2A 5
+#define TSMF_SUB_TYPE_MP2V 6
+#define TSMF_SUB_TYPE_WMV3 7
+#define TSMF_SUB_TYPE_AAC 8
+#define TSMF_SUB_TYPE_H264 9
+#define TSMF_SUB_TYPE_AVC1 10
+#define TSMF_SUB_TYPE_AC3 11
+#define TSMF_SUB_TYPE_WMV2 12
+#define TSMF_SUB_TYPE_WMV1 13
+#define TSMF_SUB_TYPE_MP1V 14
+#define TSMF_SUB_TYPE_MP1A 15
+#define TSMF_SUB_TYPE_YUY2 16
+#define TSMF_SUB_TYPE_MP43 17
+#define TSMF_SUB_TYPE_MP4S 18
+#define TSMF_SUB_TYPE_MP42 19
+#define TSMF_SUB_TYPE_OGG 20
+#define TSMF_SUB_TYPE_SPEEX 21
+#define TSMF_SUB_TYPE_THEORA 22
+#define TSMF_SUB_TYPE_FLAC 23
+#define TSMF_SUB_TYPE_VP8 24
+#define TSMF_SUB_TYPE_VP9 25
+#define TSMF_SUB_TYPE_H263 26
+#define TSMF_SUB_TYPE_M4S2 27
+#define TSMF_SUB_TYPE_WMA1 28
/* FormatType */
-#define TSMF_FORMAT_TYPE_UNKNOWN 0
-#define TSMF_FORMAT_TYPE_MFVIDEOFORMAT 1
-#define TSMF_FORMAT_TYPE_WAVEFORMATEX 2
-#define TSMF_FORMAT_TYPE_MPEG2VIDEOINFO 3
-#define TSMF_FORMAT_TYPE_VIDEOINFO2 4
-#define TSMF_FORMAT_TYPE_MPEG1VIDEOINFO 5
+#define TSMF_FORMAT_TYPE_UNKNOWN 0
+#define TSMF_FORMAT_TYPE_MFVIDEOFORMAT 1
+#define TSMF_FORMAT_TYPE_WAVEFORMATEX 2
+#define TSMF_FORMAT_TYPE_MPEG2VIDEOINFO 3
+#define TSMF_FORMAT_TYPE_VIDEOINFO2 4
+#define TSMF_FORMAT_TYPE_MPEG1VIDEOINFO 5
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_CONSTANTS_H */
diff --git a/channels/tsmf/client/tsmf_decoder.c b/channels/tsmf/client/tsmf_decoder.c
index 5e8411462..c59b0f61d 100644
--- a/channels/tsmf/client/tsmf_decoder.c
+++ b/channels/tsmf/client/tsmf_decoder.c
@@ -32,12 +32,12 @@
#include "tsmf_constants.h"
#include "tsmf_decoder.h"
-static ITSMFDecoder* tsmf_load_decoder_by_name(const char *name)
+static ITSMFDecoder* tsmf_load_decoder_by_name(const char* name)
{
ITSMFDecoder* decoder;
TSMF_DECODER_ENTRY entry;
- entry = (TSMF_DECODER_ENTRY) (void*)freerdp_load_channel_addin_entry("tsmf", name, "decoder", 0);
+ entry = (TSMF_DECODER_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "decoder", 0);
if (!entry)
return NULL;
@@ -53,7 +53,7 @@ static ITSMFDecoder* tsmf_load_decoder_by_name(const char *name)
return decoder;
}
-static BOOL tsmf_decoder_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE* media_type)
+static BOOL tsmf_decoder_set_format(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type)
{
if (decoder->SetFormat(decoder, media_type))
return TRUE;
@@ -102,8 +102,8 @@ BOOL tsmf_check_decoder_available(const char* name)
decoder = tsmf_load_decoder_by_name(name);
}
#if defined(WITH_GSTREAMER_1_0) || defined(WITH_GSTREAMER_0_10)
- if (!decoder)
- decoder = tsmf_load_decoder_by_name("gstreamer");
+ if (!decoder)
+ decoder = tsmf_load_decoder_by_name("gstreamer");
#endif
#if defined(WITH_FFMPEG)
@@ -120,4 +120,3 @@ BOOL tsmf_check_decoder_available(const char* name)
return retValue;
}
-
diff --git a/channels/tsmf/client/tsmf_decoder.h b/channels/tsmf/client/tsmf_decoder.h
index a12e8ceeb..9a16faffe 100644
--- a/channels/tsmf/client/tsmf_decoder.h
+++ b/channels/tsmf/client/tsmf_decoder.h
@@ -36,40 +36,43 @@ typedef struct _ITSMFDecoder ITSMFDecoder;
struct _ITSMFDecoder
{
/* Set the decoder format. Return true if supported. */
- BOOL (*SetFormat)(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *media_type);
+ BOOL (*SetFormat)(ITSMFDecoder* decoder, TS_AM_MEDIA_TYPE* media_type);
/* Decode a sample. */
- BOOL (*Decode)(ITSMFDecoder *decoder, const BYTE *data, UINT32 data_size, UINT32 extensions);
+ BOOL (*Decode)(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, UINT32 extensions);
/* Get the decoded data */
- BYTE *(*GetDecodedData)(ITSMFDecoder *decoder, UINT32 *size);
+ BYTE* (*GetDecodedData)(ITSMFDecoder* decoder, UINT32* size);
/* Get the pixel format of decoded video frame */
- UINT32(*GetDecodedFormat)(ITSMFDecoder *decoder);
+ UINT32 (*GetDecodedFormat)(ITSMFDecoder* decoder);
/* Get the width and height of decoded video frame */
- BOOL (*GetDecodedDimension)(ITSMFDecoder *decoder, UINT32 *width, UINT32 *height);
+ BOOL (*GetDecodedDimension)(ITSMFDecoder* decoder, UINT32* width, UINT32* height);
/* Free the decoder */
- void (*Free)(ITSMFDecoder *decoder);
+ void (*Free)(ITSMFDecoder* decoder);
/* Optional Contol function */
- BOOL (*Control)(ITSMFDecoder *decoder, ITSMFControlMsg control_msg, UINT32 *arg);
+ BOOL (*Control)(ITSMFDecoder* decoder, ITSMFControlMsg control_msg, UINT32* arg);
/* Decode a sample with extended interface. */
- BOOL (*DecodeEx)(ITSMFDecoder *decoder, const BYTE *data, UINT32 data_size, UINT32 extensions,
- UINT64 start_time, UINT64 end_time, UINT64 duration);
+ BOOL(*DecodeEx)
+ (ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, UINT32 extensions,
+ UINT64 start_time, UINT64 end_time, UINT64 duration);
/* Get current play time */
- UINT64(*GetRunningTime)(ITSMFDecoder *decoder);
+ UINT64 (*GetRunningTime)(ITSMFDecoder* decoder);
/* Update Gstreamer Rendering Area */
- BOOL (*UpdateRenderingArea)(ITSMFDecoder *decoder, int newX, int newY, int newWidth, int newHeight, int numRectangles, RDP_RECT *rectangles);
+ BOOL(*UpdateRenderingArea)
+ (ITSMFDecoder* decoder, int newX, int newY, int newWidth, int newHeight, int numRectangles,
+ RDP_RECT* rectangles);
/* Change Gstreamer Audio Volume */
- BOOL (*ChangeVolume)(ITSMFDecoder *decoder, UINT32 newVolume, UINT32 muted);
+ BOOL (*ChangeVolume)(ITSMFDecoder* decoder, UINT32 newVolume, UINT32 muted);
/* Check buffer level */
- BOOL (*BufferLevel)(ITSMFDecoder *decoder);
+ BOOL (*BufferLevel)(ITSMFDecoder* decoder);
/* Register a callback for frame ack. */
- BOOL (*SetAckFunc)(ITSMFDecoder *decoder, BOOL (*cb)(void *,BOOL), void *stream);
+ BOOL (*SetAckFunc)(ITSMFDecoder* decoder, BOOL (*cb)(void*, BOOL), void* stream);
/* Register a callback for stream seek detection. */
- BOOL (*SetSyncFunc)(ITSMFDecoder *decoder, void (*cb)(void *), void *stream);
+ BOOL (*SetSyncFunc)(ITSMFDecoder* decoder, void (*cb)(void*), void* stream);
};
#define TSMF_DECODER_EXPORT_FUNC_NAME "TSMFDecoderEntry"
-typedef ITSMFDecoder *(*TSMF_DECODER_ENTRY)(void);
+typedef ITSMFDecoder* (*TSMF_DECODER_ENTRY)(void);
-ITSMFDecoder *tsmf_load_decoder(const char *name, TS_AM_MEDIA_TYPE *media_type);
+ITSMFDecoder* tsmf_load_decoder(const char* name, TS_AM_MEDIA_TYPE* media_type);
BOOL tsmf_check_decoder_available(const char* name);
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_DECODER_H */
diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c
index 9fcc620c1..752666d33 100644
--- a/channels/tsmf/client/tsmf_ifman.c
+++ b/channels/tsmf/client/tsmf_ifman.c
@@ -52,7 +52,7 @@ UINT tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman)
return ERROR_INVALID_DATA;
Stream_Read_UINT32(ifman->input, CapabilityValue);
- DEBUG_TSMF("server CapabilityValue %"PRIu32"", CapabilityValue);
+ DEBUG_TSMF("server CapabilityValue %" PRIu32 "", CapabilityValue);
if (!Stream_EnsureRemainingCapacity(ifman->output, 8))
return ERROR_INVALID_DATA;
@@ -108,7 +108,7 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
return ERROR_INVALID_DATA;
Stream_Read_UINT32(ifman->output, v);
- DEBUG_TSMF("server protocol version %"PRIu32"", v);
+ DEBUG_TSMF("server protocol version %" PRIu32 "", v);
break;
case 2: /* Supported platform */
@@ -116,14 +116,14 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
return ERROR_INVALID_DATA;
Stream_Peek_UINT32(ifman->output, v);
- DEBUG_TSMF("server supported platform %"PRIu32"", v);
+ DEBUG_TSMF("server supported platform %" PRIu32 "", v);
/* Claim that we support both MF and DShow platforms. */
- Stream_Write_UINT32(ifman->output,
- MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW);
+ Stream_Write_UINT32(ifman->output, MMREDIR_CAPABILITY_PLATFORM_MF |
+ MMREDIR_CAPABILITY_PLATFORM_DSHOW);
break;
default:
- WLog_ERR(TAG, "skipping unknown capability type %"PRIu32"", CapabilityType);
+ WLog_ERR(TAG, "skipping unknown capability type %" PRIu32 "", CapabilityType);
break;
}
@@ -152,7 +152,7 @@ UINT tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman)
Stream_Read_UINT32(ifman->input, PlatformCookie);
Stream_Seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */
Stream_Read_UINT32(ifman->input, numMediaType);
- DEBUG_TSMF("PlatformCookie %"PRIu32" numMediaType %"PRIu32"", PlatformCookie, numMediaType);
+ DEBUG_TSMF("PlatformCookie %" PRIu32 " numMediaType %" PRIu32 "", PlatformCookie, numMediaType);
if (!tsmf_codec_check_media_type(ifman->decoder_name, ifman->input))
FormatSupported = 0;
@@ -343,12 +343,12 @@ UINT tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman)
}
else
{
- Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */
- Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */
- Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */
+ Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */
+ Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */
+ Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */
Bottom = tsmf_stream_read_float(ifman->input); /* Bottom (4 bytes) */
- DEBUG_TSMF("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f",
- Left, Top, Right, Bottom);
+ DEBUG_TSMF("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f", Left, Top, Right,
+ Bottom);
}
ifman->output_pending = TRUE;
@@ -411,9 +411,9 @@ UINT tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman)
Stream_Seek(ifman->input, 16);
Stream_Read_UINT32(ifman->input, newVolume);
- DEBUG_TSMF("on stream volume: new volume=[%"PRIu32"]", newVolume);
+ DEBUG_TSMF("on stream volume: new volume=[%" PRIu32 "]", newVolume);
Stream_Read_UINT32(ifman->input, muted);
- DEBUG_TSMF("on stream volume: muted=[%"PRIu32"]", muted);
+ DEBUG_TSMF("on stream volume: muted=[%" PRIu32 "]", muted);
if (!tsmf_presentation_volume_changed(presentation, newVolume, muted))
return ERROR_INVALID_OPERATION;
@@ -443,9 +443,9 @@ UINT tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman)
UINT32 changedChannel;
Stream_Seek(ifman->input, 16);
Stream_Read_UINT32(ifman->input, channelVolume);
- DEBUG_TSMF("on channel volume: channel volume=[%"PRIu32"]", channelVolume);
+ DEBUG_TSMF("on channel volume: channel volume=[%" PRIu32 "]", channelVolume);
Stream_Read_UINT32(ifman->input, changedChannel);
- DEBUG_TSMF("on stream volume: changed channel=[%"PRIu32"]", changedChannel);
+ DEBUG_TSMF("on stream volume: changed channel=[%" PRIu32 "]", changedChannel);
}
ifman->output_pending = TRUE;
@@ -503,12 +503,13 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
Stream_SetPosition(ifman->input, pos + numGeometryInfo);
Stream_Read_UINT32(ifman->input, cbVisibleRect);
num_rects = cbVisibleRect / 16;
- DEBUG_TSMF("numGeometryInfo %"PRIu32" Width %"PRIu32" Height %"PRIu32" Left %"PRIu32" Top %"PRIu32" cbVisibleRect %"PRIu32" num_rects %d",
+ DEBUG_TSMF("numGeometryInfo %" PRIu32 " Width %" PRIu32 " Height %" PRIu32 " Left %" PRIu32
+ " Top %" PRIu32 " cbVisibleRect %" PRIu32 " num_rects %d",
numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects);
if (num_rects > 0)
{
- rects = (RDP_RECT*) calloc(num_rects, sizeof(RDP_RECT));
+ rects = (RDP_RECT*)calloc(num_rects, sizeof(RDP_RECT));
for (i = 0; i < num_rects; i++)
{
@@ -522,12 +523,13 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
Stream_Seek_UINT16(ifman->input);
rects[i].width -= rects[i].x;
rects[i].height -= rects[i].y;
- DEBUG_TSMF("rect %d: %"PRId16" %"PRId16" %"PRId16" %"PRId16"", i,
- rects[i].x, rects[i].y, rects[i].width, rects[i].height);
+ DEBUG_TSMF("rect %d: %" PRId16 " %" PRId16 " %" PRId16 " %" PRId16 "", i, rects[i].x,
+ rects[i].y, rects[i].width, rects[i].height);
}
}
- if (!tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects, rects))
+ if (!tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects,
+ rects))
return ERROR_INVALID_OPERATION;
ifman->output_pending = TRUE;
@@ -592,10 +594,11 @@ UINT tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
if (Stream_GetRemainingLength(ifman->input) < cbData)
return ERROR_INVALID_DATA;
- DEBUG_TSMF("MessageId %"PRIu32" StreamId %"PRIu32" SampleStartTime %"PRIu64" SampleEndTime %"PRIu64" "
- "ThrottleDuration %"PRIu64" SampleExtensions %"PRIu32" cbData %"PRIu32"",
- ifman->message_id, StreamId, SampleStartTime, SampleEndTime,
- ThrottleDuration, SampleExtensions, cbData);
+ DEBUG_TSMF("MessageId %" PRIu32 " StreamId %" PRIu32 " SampleStartTime %" PRIu64
+ " SampleEndTime %" PRIu64 " "
+ "ThrottleDuration %" PRIu64 " SampleExtensions %" PRIu32 " cbData %" PRIu32 "",
+ ifman->message_id, StreamId, SampleStartTime, SampleEndTime, ThrottleDuration,
+ SampleExtensions, cbData);
presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
if (!presentation)
@@ -612,9 +615,9 @@ UINT tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
return ERROR_NOT_FOUND;
}
- if (!tsmf_stream_push_sample(stream, ifman->channel_callback,
- ifman->message_id, SampleStartTime, SampleEndTime,
- ThrottleDuration, SampleExtensions, cbData, Stream_Pointer(ifman->input)))
+ if (!tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id,
+ SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions,
+ cbData, Stream_Pointer(ifman->input)))
{
WLog_ERR(TAG, "unable to push sample");
return ERROR_OUTOFMEMORY;
@@ -622,7 +625,7 @@ UINT tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
if ((error = tsmf_presentation_sync(presentation)))
{
- WLog_ERR(TAG, "tsmf_presentation_sync failed with error %"PRIu32"", error);
+ WLog_ERR(TAG, "tsmf_presentation_sync failed with error %" PRIu32 "", error);
return error;
}
@@ -646,7 +649,7 @@ UINT tsmf_ifman_on_flush(TSMF_IFMAN* ifman)
Stream_Seek(ifman->input, 16);
Stream_Read_UINT32(ifman->input, StreamId);
- DEBUG_TSMF("StreamId %"PRIu32"", StreamId);
+ DEBUG_TSMF("StreamId %" PRIu32 "", StreamId);
presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
if (!presentation)
@@ -698,7 +701,7 @@ UINT tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman)
tsmf_stream_end(stream, ifman->message_id, ifman->channel_callback);
}
- DEBUG_TSMF("StreamId %"PRIu32"", StreamId);
+ DEBUG_TSMF("StreamId %" PRIu32 "", StreamId);
ifman->output_pending = TRUE;
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
return CHANNEL_RC_OK;
@@ -727,10 +730,10 @@ UINT tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman)
if (!Stream_EnsureRemainingCapacity(ifman->output, 16))
return ERROR_OUTOFMEMORY;
- Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
- Stream_Write_UINT32(ifman->output, 0); /* StreamId */
+ Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
+ Stream_Write_UINT32(ifman->output, 0); /* StreamId */
Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */
- Stream_Write_UINT32(ifman->output, 0); /* cbData */
+ Stream_Write_UINT32(ifman->output, 0); /* cbData */
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
return CHANNEL_RC_OK;
}
@@ -805,10 +808,10 @@ UINT tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman)
if (!Stream_EnsureRemainingCapacity(ifman->output, 16))
return ERROR_OUTOFMEMORY;
- Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
- Stream_Write_UINT32(ifman->output, 0); /* StreamId */
+ Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
+ Stream_Write_UINT32(ifman->output, 0); /* StreamId */
Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */
- Stream_Write_UINT32(ifman->output, 0); /* cbData */
+ Stream_Write_UINT32(ifman->output, 0); /* cbData */
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
return CHANNEL_RC_OK;
}
@@ -825,10 +828,10 @@ UINT tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN* ifman)
if (!Stream_EnsureRemainingCapacity(ifman->output, 16))
return ERROR_OUTOFMEMORY;
- Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
- Stream_Write_UINT32(ifman->output, 0); /* StreamId */
+ Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
+ Stream_Write_UINT32(ifman->output, 0); /* StreamId */
Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */
- Stream_Write_UINT32(ifman->output, 0); /* cbData */
+ Stream_Write_UINT32(ifman->output, 0); /* cbData */
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
return CHANNEL_RC_OK;
}
diff --git a/channels/tsmf/client/tsmf_ifman.h b/channels/tsmf/client/tsmf_ifman.h
index b6986205a..3830f5b49 100644
--- a/channels/tsmf/client/tsmf_ifman.h
+++ b/channels/tsmf/client/tsmf_ifman.h
@@ -67,4 +67,3 @@ UINT tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman);
UINT tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN* ifman);
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_IFMAN_H */
-
diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c
index 8f7902da1..ec281ea11 100644
--- a/channels/tsmf/client/tsmf_main.c
+++ b/channels/tsmf/client/tsmf_main.c
@@ -40,7 +40,7 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
{
wStream* s = NULL;
int status = -1;
- TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
+ TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
if (!callback)
{
@@ -57,12 +57,13 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
Stream_Write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY);
Stream_Write_UINT32(s, message_id);
- Stream_Write_UINT32(s, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
- Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
+ Stream_Write_UINT32(s, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
+ Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
Stream_Write_UINT32(s, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */
- Stream_Write_UINT32(s, 0); /* cbData */
- DEBUG_TSMF("EOS response size %"PRIuz"", Stream_GetPosition(s));
- status = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL);
+ Stream_Write_UINT32(s, 0); /* cbData */
+ DEBUG_TSMF("EOS response size %" PRIuz "", Stream_GetPosition(s));
+ status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
+ Stream_Buffer(s), NULL);
if (status)
{
@@ -75,12 +76,12 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
return (status == 0);
}
-BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
- UINT32 message_id, UINT64 duration, UINT32 data_size)
+BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id,
+ UINT64 duration, UINT32 data_size)
{
wStream* s = NULL;
int status = -1;
- TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
+ TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
if (!callback)
return FALSE;
@@ -92,11 +93,11 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
Stream_Write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY);
Stream_Write_UINT32(s, message_id);
- Stream_Write_UINT32(s, PLAYBACK_ACK); /* FunctionId */
+ Stream_Write_UINT32(s, PLAYBACK_ACK); /* FunctionId */
Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
- Stream_Write_UINT64(s, duration); /* DataDuration */
- Stream_Write_UINT64(s, data_size); /* cbData */
- DEBUG_TSMF("ACK response size %"PRIuz"", Stream_GetPosition(s));
+ Stream_Write_UINT64(s, duration); /* DataDuration */
+ Stream_Write_UINT64(s, data_size); /* cbData */
+ DEBUG_TSMF("ACK response size %" PRIuz "", Stream_GetPosition(s));
if (!callback->channel || !callback->channel->Write)
{
@@ -106,8 +107,8 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
}
else
{
- status = callback->channel->Write(callback->channel,
- Stream_GetPosition(s), Stream_Buffer(s), NULL);
+ status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
+ Stream_Buffer(s), NULL);
}
if (status)
@@ -135,13 +136,13 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
UINT32 MessageId;
UINT32 FunctionId;
UINT32 InterfaceId;
- TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
+ TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
UINT32 cbSize = Stream_GetRemainingLength(data);
/* 2.2.1 Shared Message Header (SHARED_MSG_HEADER) */
if (cbSize < 12)
{
- WLog_ERR(TAG, "invalid size. cbSize=%"PRIu32"", cbSize);
+ WLog_ERR(TAG, "invalid size. cbSize=%" PRIu32 "", cbSize);
return ERROR_INVALID_DATA;
}
@@ -153,15 +154,16 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
Stream_Seek(output, 8);
Stream_Read_UINT32(input, InterfaceId); /* InterfaceId (4 bytes) */
- Stream_Read_UINT32(input, MessageId); /* MessageId (4 bytes) */
- Stream_Read_UINT32(input, FunctionId); /* FunctionId (4 bytes) */
- DEBUG_TSMF("cbSize=%"PRIu32" InterfaceId=0x%"PRIX32" MessageId=0x%"PRIX32" FunctionId=0x%"PRIX32"",
+ Stream_Read_UINT32(input, MessageId); /* MessageId (4 bytes) */
+ Stream_Read_UINT32(input, FunctionId); /* FunctionId (4 bytes) */
+ DEBUG_TSMF("cbSize=%" PRIu32 " InterfaceId=0x%" PRIX32 " MessageId=0x%" PRIX32
+ " FunctionId=0x%" PRIX32 "",
cbSize, InterfaceId, MessageId, FunctionId);
ZeroMemory(&ifman, sizeof(TSMF_IFMAN));
ifman.channel_callback = pChannelCallback;
- ifman.decoder_name = ((TSMF_PLUGIN*) callback->plugin)->decoder_name;
- ifman.audio_name = ((TSMF_PLUGIN*) callback->plugin)->audio_name;
- ifman.audio_device = ((TSMF_PLUGIN*) callback->plugin)->audio_device;
+ ifman.decoder_name = ((TSMF_PLUGIN*)callback->plugin)->decoder_name;
+ ifman.audio_name = ((TSMF_PLUGIN*)callback->plugin)->audio_name;
+ ifman.audio_device = ((TSMF_PLUGIN*)callback->plugin)->audio_device;
CopyMemory(ifman.presentation_id, callback->presentation_id, GUID_SIZE);
ifman.stream_id = callback->stream_id;
ifman.message_id = MessageId;
@@ -171,7 +173,8 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
ifman.output_pending = FALSE;
ifman.output_interface_id = InterfaceId;
- //fprintf(stderr, "InterfaceId: 0x%08"PRIX32" MessageId: 0x%08"PRIX32" FunctionId: 0x%08"PRIX32"\n", InterfaceId, MessageId, FunctionId);
+ // fprintf(stderr, "InterfaceId: 0x%08"PRIX32" MessageId: 0x%08"PRIX32" FunctionId:
+ // 0x%08"PRIX32"\n", InterfaceId, MessageId, FunctionId);
switch (InterfaceId)
{
@@ -206,7 +209,7 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
CopyMemory(callback->presentation_id, Stream_Pointer(input), GUID_SIZE);
Stream_Seek(input, GUID_SIZE);
Stream_Read_UINT32(input, callback->stream_id);
- DEBUG_TSMF("SET_CHANNEL_PARAMS StreamId=%"PRIu32"", callback->stream_id);
+ DEBUG_TSMF("SET_CHANNEL_PARAMS StreamId=%" PRIu32 "", callback->stream_id);
ifman.output_pending = TRUE;
processed = TRUE;
break;
@@ -227,7 +230,8 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
break;
case ADD_STREAM:
- error = tsmf_ifman_add_stream(&ifman, ((TSMF_PLUGIN*) callback->plugin)->rdpcontext);
+ error =
+ tsmf_ifman_add_stream(&ifman, ((TSMF_PLUGIN*)callback->plugin)->rdpcontext);
processed = TRUE;
break;
@@ -340,7 +344,7 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
if (error)
{
- WLog_ERR(TAG, "ifman data received processing error %"PRIu32"", error);
+ WLog_ERR(TAG, "ifman data received processing error %" PRIu32 "", error);
}
if (!processed)
@@ -364,7 +368,8 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
if (!processed)
{
WLog_ERR(TAG,
- "Unknown InterfaceId: 0x%08"PRIX32" MessageId: 0x%08"PRIX32" FunctionId: 0x%08"PRIX32"\n",
+ "Unknown InterfaceId: 0x%08" PRIX32 " MessageId: 0x%08" PRIX32
+ " FunctionId: 0x%08" PRIX32 "\n",
InterfaceId, MessageId, FunctionId);
/* When a request is not implemented we return empty response indicating error */
}
@@ -384,7 +389,7 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
if (error)
{
- WLog_ERR(TAG, "response error %"PRIu32"", error);
+ WLog_ERR(TAG, "response error %" PRIu32 "", error);
}
}
@@ -402,7 +407,7 @@ static UINT tsmf_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
TSMF_STREAM* stream;
TSMF_PRESENTATION* presentation;
- TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
+ TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
DEBUG_TSMF("");
if (callback->stream_id)
@@ -428,15 +433,13 @@ static UINT tsmf_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT tsmf_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel,
- BYTE* Data,
- BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
TSMF_CHANNEL_CALLBACK* callback;
- TSMF_LISTENER_CALLBACK* listener_callback = (TSMF_LISTENER_CALLBACK*) pListenerCallback;
+ TSMF_LISTENER_CALLBACK* listener_callback = (TSMF_LISTENER_CALLBACK*)pListenerCallback;
DEBUG_TSMF("");
- callback = (TSMF_CHANNEL_CALLBACK*) calloc(1, sizeof(TSMF_CHANNEL_CALLBACK));
+ callback = (TSMF_CHANNEL_CALLBACK*)calloc(1, sizeof(TSMF_CHANNEL_CALLBACK));
if (!callback)
return CHANNEL_RC_NO_MEMORY;
@@ -447,7 +450,7 @@ static UINT tsmf_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
callback->plugin = listener_callback->plugin;
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -459,9 +462,9 @@ static UINT tsmf_on_new_channel_connection(IWTSListenerCallback* pListenerCallba
static UINT tsmf_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
UINT status;
- TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*) pPlugin;
+ TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*)pPlugin;
DEBUG_TSMF("");
- tsmf->listener_callback = (TSMF_LISTENER_CALLBACK*) calloc(1, sizeof(TSMF_LISTENER_CALLBACK));
+ tsmf->listener_callback = (TSMF_LISTENER_CALLBACK*)calloc(1, sizeof(TSMF_LISTENER_CALLBACK));
if (!tsmf->listener_callback)
return CHANNEL_RC_NO_MEMORY;
@@ -469,8 +472,8 @@ static UINT tsmf_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
tsmf->listener_callback->iface.OnNewChannelConnection = tsmf_on_new_channel_connection;
tsmf->listener_callback->plugin = pPlugin;
tsmf->listener_callback->channel_mgr = pChannelMgr;
- status = pChannelMgr->CreateListener(pChannelMgr, "TSMF", 0,
- (IWTSListenerCallback*) tsmf->listener_callback, &(tsmf->listener));
+ status = pChannelMgr->CreateListener(
+ pChannelMgr, "TSMF", 0, (IWTSListenerCallback*)tsmf->listener_callback, &(tsmf->listener));
tsmf->listener->pInterface = tsmf->iface.pInterface;
return status;
}
@@ -482,7 +485,7 @@ static UINT tsmf_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
*/
static UINT tsmf_plugin_terminated(IWTSPlugin* pPlugin)
{
- TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*) pPlugin;
+ TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*)pPlugin;
DEBUG_TSMF("");
free(tsmf->listener_callback);
free(tsmf);
@@ -499,17 +502,16 @@ static UINT tsmf_process_addin_args(IWTSPlugin* pPlugin, ADDIN_ARGV* args)
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*) pPlugin;
- COMMAND_LINE_ARGUMENT_A tsmf_args[] =
- {
- { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio subsystem" },
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "audio device name" },
- { "decoder", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "decoder subsystem" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*)pPlugin;
+ COMMAND_LINE_ARGUMENT_A tsmf_args[] = { { "sys", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "audio subsystem" },
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL,
+ NULL, -1, NULL, "audio device name" },
+ { "decoder", COMMAND_LINE_VALUE_REQUIRED, "",
+ NULL, NULL, -1, NULL, "decoder subsystem" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } };
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- tsmf_args, flags, tsmf, NULL, NULL);
+ status = CommandLineParseArgumentsA(args->argc, args->argv, tsmf_args, flags, tsmf, NULL, NULL);
if (status != 0)
return ERROR_INVALID_DATA;
@@ -521,8 +523,7 @@ static UINT tsmf_process_addin_args(IWTSPlugin* pPlugin, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "sys")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "sys")
{
tsmf->audio_name = _strdup(arg->Value);
@@ -547,16 +548,15 @@ static UINT tsmf_process_addin_args(IWTSPlugin* pPlugin, ADDIN_ARGV* args)
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry tsmf_DVCPluginEntry
+#define DVCPluginEntry tsmf_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -570,11 +570,11 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
TSMF_PLUGIN* tsmf;
TsmfClientContext* context;
UINT error = CHANNEL_RC_NO_MEMORY;
- tsmf = (TSMF_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "tsmf");
+ tsmf = (TSMF_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "tsmf");
if (!tsmf)
{
- tsmf = (TSMF_PLUGIN*) calloc(1, sizeof(TSMF_PLUGIN));
+ tsmf = (TSMF_PLUGIN*)calloc(1, sizeof(TSMF_PLUGIN));
if (!tsmf)
{
@@ -586,9 +586,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
tsmf->iface.Connected = NULL;
tsmf->iface.Disconnected = NULL;
tsmf->iface.Terminated = tsmf_plugin_terminated;
- tsmf->rdpcontext = ((freerdp*)((rdpSettings*) pEntryPoints->GetRdpSettings(
- pEntryPoints))->instance)->context;
- context = (TsmfClientContext*) calloc(1, sizeof(TsmfClientContext));
+ tsmf->rdpcontext =
+ ((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
+ ->context;
+ context = (TsmfClientContext*)calloc(1, sizeof(TsmfClientContext));
if (!context)
{
@@ -596,8 +597,8 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
goto error_context;
}
- context->handle = (void*) tsmf;
- tsmf->iface.pInterface = (void*) context;
+ context->handle = (void*)tsmf;
+ tsmf->iface.pInterface = (void*)context;
if (!tsmf_media_init())
{
@@ -605,12 +606,13 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
goto error_init;
}
- status = pEntryPoints->RegisterPlugin(pEntryPoints, "tsmf", (IWTSPlugin*) tsmf);
+ status = pEntryPoints->RegisterPlugin(pEntryPoints, "tsmf", (IWTSPlugin*)tsmf);
}
if (status == CHANNEL_RC_OK)
{
- status = tsmf_process_addin_args((IWTSPlugin*) tsmf, pEntryPoints->GetPluginData(pEntryPoints));
+ status =
+ tsmf_process_addin_args((IWTSPlugin*)tsmf, pEntryPoints->GetPluginData(pEntryPoints));
}
return status;
diff --git a/channels/tsmf/client/tsmf_main.h b/channels/tsmf/client/tsmf_main.h
index 0143d29f3..366215cdb 100644
--- a/channels/tsmf/client/tsmf_main.h
+++ b/channels/tsmf/client/tsmf_main.h
@@ -65,7 +65,7 @@ struct _TSMF_PLUGIN
};
BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id);
-BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
- UINT32 message_id, UINT64 duration, UINT32 data_size);
+BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id,
+ UINT64 duration, UINT32 data_size);
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_MAIN_H */
diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c
index 0e2072510..b77a3c642 100644
--- a/channels/tsmf/client/tsmf_media.c
+++ b/channels/tsmf/client/tsmf_media.c
@@ -57,7 +57,7 @@
#define AUDIO_TOLERANCE 10000000LL
/* 1 second = 10,000,000 100ns units*/
-#define VIDEO_ADJUST_MAX 10*1000*1000
+#define VIDEO_ADJUST_MAX 10 * 1000 * 1000
#define MAX_ACK_TIME 666667
@@ -194,9 +194,10 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
{
if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO)
{
- /* Check if some other stream has earlier sample that needs to be played first */
- /* Start time is more reliable than end time as some stream types seem to have incorrect
- * end times from the server
+ /* Check if some other stream has earlier sample that needs to be played first
+ */
+ /* Start time is more reliable than end time as some stream types seem to have
+ * incorrect end times from the server
*/
if (stream->last_start_time > AUDIO_TOLERANCE)
{
@@ -205,10 +206,10 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
for (index = 0; index < count; index++)
{
- s = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ s = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
- /* Start time is more reliable than end time as some stream types seem to have incorrect
- * end times from the server
+ /* Start time is more reliable than end time as some stream types seem
+ * to have incorrect end times from the server
*/
if (s != stream && !s->eos && s->last_start_time &&
s->last_start_time < stream->last_start_time - AUDIO_TOLERANCE)
@@ -224,8 +225,8 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
}
else
{
- /* Start time is more reliable than end time as some stream types seem to have incorrect
- * end times from the server
+ /* Start time is more reliable than end time as some stream types seem to have
+ * incorrect end times from the server
*/
if (stream->last_start_time > presentation->audio_start_time)
{
@@ -240,16 +241,16 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
if (pending)
return NULL;
- sample = (TSMF_SAMPLE*) Queue_Dequeue(stream->sample_list);
+ sample = (TSMF_SAMPLE*)Queue_Dequeue(stream->sample_list);
- /* Only update stream last end time if the sample end time is valid and greater than the current stream end time */
- if (sample && (sample->end_time > stream->last_end_time)
- && (!sample->invalidTimestamps))
+ /* Only update stream last end time if the sample end time is valid and greater than the current
+ * stream end time */
+ if (sample && (sample->end_time > stream->last_end_time) && (!sample->invalidTimestamps))
stream->last_end_time = sample->end_time;
- /* Only update stream last start time if the sample start time is valid and greater than the current stream start time */
- if (sample && (sample->start_time > stream->last_start_time)
- && (!sample->invalidTimestamps))
+ /* Only update stream last start time if the sample start time is valid and greater than the
+ * current stream start time */
+ if (sample && (sample->start_time > stream->last_start_time) && (!sample->invalidTimestamps))
stream->last_start_time = sample->start_time;
return sample;
@@ -271,8 +272,8 @@ static BOOL tsmf_sample_ack(TSMF_SAMPLE* sample)
if (!sample)
return FALSE;
- return tsmf_playback_ack(sample->channel_callback, sample->sample_id,
- sample->duration, sample->data_size);
+ return tsmf_playback_ack(sample->channel_callback, sample->sample_id, sample->duration,
+ sample->data_size);
}
static BOOL tsmf_sample_queue_ack(TSMF_SAMPLE* sample)
@@ -300,7 +301,7 @@ static BOOL tsmf_stream_process_ack(void* arg, BOOL force)
return TRUE;
Queue_Lock(stream->sample_ack_list);
- sample = (TSMF_SAMPLE*) Queue_Peek(stream->sample_ack_list);
+ sample = (TSMF_SAMPLE*)Queue_Peek(stream->sample_ack_list);
if (!sample)
{
@@ -343,14 +344,14 @@ finally:
}
TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid,
- IWTSVirtualChannelCallback* pChannelCallback)
+ IWTSVirtualChannelCallback* pChannelCallback)
{
TSMF_PRESENTATION* presentation;
if (!guid || !pChannelCallback)
return NULL;
- presentation = (TSMF_PRESENTATION*) calloc(1, sizeof(TSMF_PRESENTATION));
+ presentation = (TSMF_PRESENTATION*)calloc(1, sizeof(TSMF_PRESENTATION));
if (!presentation)
{
@@ -366,8 +367,7 @@ TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid,
if (!(presentation->stream_list = ArrayList_New(TRUE)))
goto error_stream_list;
- ArrayList_Object(presentation->stream_list)->fnObjectFree =
- _tsmf_stream_free;
+ ArrayList_Object(presentation->stream_list)->fnObjectFree = _tsmf_stream_free;
if (ArrayList_Add(presentation_list, presentation) < 0)
goto error_add;
@@ -388,7 +388,7 @@ static char* guid_to_string(const BYTE* guid, char* str, size_t len)
return NULL;
for (i = 0; i < GUID_SIZE && (len > 2 * i); i++)
- sprintf_s(str + (2 * i), len - 2 * i, "%02"PRIX8"", guid[i]);
+ sprintf_s(str + (2 * i), len - 2 * i, "%02" PRIX8 "", guid[i]);
return str;
}
@@ -405,7 +405,7 @@ TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
for (index = 0; index < count; index++)
{
- presentation = (TSMF_PRESENTATION*) ArrayList_GetItem(presentation_list, index);
+ presentation = (TSMF_PRESENTATION*)ArrayList_GetItem(presentation_list, index);
if (memcmp(presentation->presentation_id, guid, GUID_SIZE) == 0)
{
@@ -417,8 +417,8 @@ TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
ArrayList_Unlock(presentation_list);
if (!found)
- WLog_WARN(TAG, "presentation id %s not found", guid_to_string(guid, guid_str,
- sizeof(guid_str)));
+ WLog_WARN(TAG, "presentation id %s not found",
+ guid_to_string(guid, guid_str, sizeof(guid_str)));
return (found) ? presentation : NULL;
}
@@ -429,10 +429,9 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
TSMF_VIDEO_FRAME_EVENT event;
TSMF_STREAM* stream = sample->stream;
TSMF_PRESENTATION* presentation = stream->presentation;
- TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)
- sample->channel_callback;
- TsmfClientContext* tsmf = (TsmfClientContext*) callback->plugin->pInterface;
- DEBUG_TSMF("MessageId %"PRIu32" EndTime %"PRIu64" data_size %"PRIu32" consumed.",
+ TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)sample->channel_callback;
+ TsmfClientContext* tsmf = (TsmfClientContext*)callback->plugin->pInterface;
+ DEBUG_TSMF("MessageId %" PRIu32 " EndTime %" PRIu64 " data_size %" PRIu32 " consumed.",
sample->sample_id, sample->end_time, sample->data_size);
if (sample->data)
@@ -444,8 +443,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
*/
if (stream->next_start_time > t &&
((sample->start_time >= presentation->audio_start_time) ||
- ((sample->start_time < stream->last_start_time)
- && (!sample->invalidTimestamps))))
+ ((sample->start_time < stream->last_start_time) && (!sample->invalidTimestamps))))
{
USleep((stream->next_start_time - t) / 10);
}
@@ -465,7 +463,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
if (presentation->nr_rects > 0)
{
event.numVisibleRects = presentation->nr_rects;
- event.visibleRects = (RECTANGLE_16*) calloc(event.numVisibleRects, sizeof(RECTANGLE_16));
+ event.visibleRects = (RECTANGLE_16*)calloc(event.numVisibleRects, sizeof(RECTANGLE_16));
if (!event.visibleRects)
{
@@ -473,7 +471,8 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
return FALSE;
}
- memcpy(event.visibleRects, presentation->rects, presentation->nr_rects * sizeof(RDP_RECT));
+ memcpy(event.visibleRects, presentation->rects,
+ presentation->nr_rects * sizeof(RDP_RECT));
presentation->nr_rects = 0;
}
@@ -500,7 +499,8 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
frame_id++;
#endif
- /* The frame data ownership is passed to the event object, and is freed after the event is processed. */
+ /* The frame data ownership is passed to the event object, and is freed after the event is
+ * processed. */
sample->data = NULL;
sample->decoded_size = 0;
@@ -521,13 +521,13 @@ static BOOL tsmf_sample_playback_audio(TSMF_SAMPLE* sample)
UINT64 latency = 0;
TSMF_STREAM* stream = sample->stream;
BOOL ret;
- DEBUG_TSMF("MessageId %"PRIu32" EndTime %"PRIu64" consumed.",
- sample->sample_id, sample->end_time);
+ DEBUG_TSMF("MessageId %" PRIu32 " EndTime %" PRIu64 " consumed.", sample->sample_id,
+ sample->end_time);
if (stream->audio && sample->data)
{
- ret = sample->stream->audio->Play(sample->stream->audio, sample->data,
- sample->decoded_size);
+ ret =
+ sample->stream->audio->Play(sample->stream->audio, sample->data, sample->decoded_size);
free(sample->data);
sample->data = NULL;
sample->decoded_size = 0;
@@ -567,9 +567,10 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
{
if (stream->decoder->DecodeEx)
{
- /* Try to "sync" video buffers to audio buffers by looking at the running time for each stream
- * The difference between the two running times causes an offset between audio and video actual
- * render times. So, we try to adjust timestamps on the video buffer to match those on the audio buffer.
+ /* Try to "sync" video buffers to audio buffers by looking at the running time for each
+ * stream The difference between the two running times causes an offset between audio
+ * and video actual render times. So, we try to adjust timestamps on the video buffer to
+ * match those on the audio buffer.
*/
if (stream->major_type == TSMF_MAJOR_TYPE_VIDEO)
{
@@ -582,14 +583,14 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
for (index = 0; index < count; index++)
{
UINT64 time_diff;
- temp_stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list,
- index);
+ temp_stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
if (temp_stream->major_type == TSMF_MAJOR_TYPE_AUDIO)
{
- UINT64 video_time = (UINT64) stream->decoder->GetRunningTime(stream->decoder);
- UINT64 audio_time = (UINT64) temp_stream->decoder->GetRunningTime(
- temp_stream->decoder);
+ UINT64 video_time =
+ (UINT64)stream->decoder->GetRunningTime(stream->decoder);
+ UINT64 audio_time =
+ (UINT64)temp_stream->decoder->GetRunningTime(temp_stream->decoder);
UINT64 max_adjust = VIDEO_ADJUST_MAX;
if (video_time < audio_time)
@@ -610,9 +611,9 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
ArrayList_Unlock(presentation->stream_list);
}
- ret = stream->decoder->DecodeEx(stream->decoder, sample->data,
- sample->data_size, sample->extensions,
- sample->start_time, sample->end_time, sample->duration);
+ ret = stream->decoder->DecodeEx(stream->decoder, sample->data, sample->data_size,
+ sample->extensions, sample->start_time,
+ sample->end_time, sample->duration);
}
else
{
@@ -643,7 +644,7 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
{
pixfmt = stream->decoder->GetDecodedFormat(stream->decoder);
- if (pixfmt == ((UINT32) - 1))
+ if (pixfmt == ((UINT32)-1))
{
WLog_ERR(TAG, "unable to decode video format");
@@ -664,7 +665,7 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
if (ret && (width != stream->width || height != stream->height))
{
- DEBUG_TSMF("video dimension changed to %"PRIu32" x %"PRIu32"", width, height);
+ DEBUG_TSMF("video dimension changed to %" PRIu32 " x %" PRIu32 "", width, height);
stream->width = width;
stream->height = height;
}
@@ -673,19 +674,16 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
if (stream->decoder->GetDecodedData)
{
- sample->data = stream->decoder->GetDecodedData(stream->decoder,
- &sample->decoded_size);
+ sample->data = stream->decoder->GetDecodedData(stream->decoder, &sample->decoded_size);
switch (sample->stream->major_type)
{
case TSMF_MAJOR_TYPE_VIDEO:
- ret = tsmf_sample_playback_video(sample) &&
- tsmf_sample_queue_ack(sample);
+ ret = tsmf_sample_playback_video(sample) && tsmf_sample_queue_ack(sample);
break;
case TSMF_MAJOR_TYPE_AUDIO:
- ret = tsmf_sample_playback_audio(sample) &&
- tsmf_sample_queue_ack(sample);
+ ret = tsmf_sample_playback_audio(sample) && tsmf_sample_queue_ack(sample);
break;
}
}
@@ -702,20 +700,20 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
buffer_filled = FALSE;
}
- ack_anticipation_time += (sample->duration / 2 < MAX_ACK_TIME) ?
- sample->duration / 2 : MAX_ACK_TIME;
+ ack_anticipation_time +=
+ (sample->duration / 2 < MAX_ACK_TIME) ? sample->duration / 2 : MAX_ACK_TIME;
switch (sample->stream->major_type)
{
case TSMF_MAJOR_TYPE_VIDEO:
- {
- break;
- }
+ {
+ break;
+ }
case TSMF_MAJOR_TYPE_AUDIO:
- {
- break;
- }
+ {
+ break;
+ }
}
sample->ack_time = ack_anticipation_time;
@@ -733,9 +731,9 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
static DWORD WINAPI tsmf_stream_ack_func(LPVOID arg)
{
HANDLE hdl[2];
- TSMF_STREAM* stream = (TSMF_STREAM*) arg;
+ TSMF_STREAM* stream = (TSMF_STREAM*)arg;
UINT error = CHANNEL_RC_OK;
- DEBUG_TSMF("in %"PRIu32"", stream->stream_id);
+ DEBUG_TSMF("in %" PRIu32 "", stream->stream_id);
hdl[0] = stream->stopEvent;
hdl[1] = Queue_Event(stream->sample_ack_list);
@@ -746,7 +744,7 @@ static DWORD WINAPI tsmf_stream_ack_func(LPVOID arg)
if (ev == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -756,8 +754,7 @@ static DWORD WINAPI tsmf_stream_ack_func(LPVOID arg)
if (stream->eos)
{
- while ((stream->currentBufferLevel > 0)
- && !(tsmf_stream_process_ack(stream, TRUE)))
+ while ((stream->currentBufferLevel > 0) && !(tsmf_stream_process_ack(stream, TRUE)))
{
DEBUG_TSMF("END OF STREAM PROCESSING!");
@@ -806,10 +803,9 @@ static DWORD WINAPI tsmf_stream_ack_func(LPVOID arg)
}
if (error && stream->rdpcontext)
- setChannelError(stream->rdpcontext, error,
- "tsmf_stream_ack_func reported an error");
+ setChannelError(stream->rdpcontext, error, "tsmf_stream_ack_func reported an error");
- DEBUG_TSMF("out %"PRIu32"", stream->stream_id);
+ DEBUG_TSMF("out %" PRIu32 "", stream->stream_id);
ExitThread(error);
return error;
}
@@ -818,24 +814,26 @@ static DWORD WINAPI tsmf_stream_playback_func(LPVOID arg)
{
HANDLE hdl[2];
TSMF_SAMPLE* sample = NULL;
- TSMF_STREAM* stream = (TSMF_STREAM*) arg;
+ TSMF_STREAM* stream = (TSMF_STREAM*)arg;
TSMF_PRESENTATION* presentation = stream->presentation;
UINT error = CHANNEL_RC_OK;
DWORD status;
- DEBUG_TSMF("in %"PRIu32"", stream->stream_id);
+ DEBUG_TSMF("in %" PRIu32 "", stream->stream_id);
- if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO &&
- stream->sample_rate && stream->channels && stream->bits_per_sample)
+ if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO && stream->sample_rate && stream->channels &&
+ stream->bits_per_sample)
{
if (stream->decoder)
{
if (stream->decoder->GetDecodedData)
{
stream->audio = tsmf_load_audio_device(
- presentation->audio_name
- && presentation->audio_name[0] ? presentation->audio_name : NULL,
- presentation->audio_device
- && presentation->audio_device[0] ? presentation->audio_device : NULL);
+ presentation->audio_name && presentation->audio_name[0]
+ ? presentation->audio_name
+ : NULL,
+ presentation->audio_device && presentation->audio_device[0]
+ ? presentation->audio_device
+ : NULL);
if (stream->audio)
{
@@ -856,7 +854,7 @@ static DWORD WINAPI tsmf_stream_playback_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", error);
break;
}
@@ -865,7 +863,7 @@ static DWORD WINAPI tsmf_stream_playback_func(LPVOID arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
break;
}
@@ -896,18 +894,16 @@ static DWORD WINAPI tsmf_stream_playback_func(LPVOID arg)
}
if (error && stream->rdpcontext)
- setChannelError(stream->rdpcontext, error,
- "tsmf_stream_playback_func reported an error");
+ setChannelError(stream->rdpcontext, error, "tsmf_stream_playback_func reported an error");
- DEBUG_TSMF("out %"PRIu32"", stream->stream_id);
+ DEBUG_TSMF("out %" PRIu32 "", stream->stream_id);
ExitThread(error);
return error;
}
static BOOL tsmf_stream_start(TSMF_STREAM* stream)
{
- if (!stream || !stream->presentation || !stream->decoder
- || !stream->decoder->Control)
+ if (!stream || !stream->presentation || !stream->decoder || !stream->decoder->Control)
return TRUE;
stream->eos = 0;
@@ -955,8 +951,7 @@ static BOOL tsmf_stream_restart(TSMF_STREAM* stream)
return stream->decoder->Control(stream->decoder, Control_Restart, NULL);
}
-static BOOL tsmf_stream_change_volume(TSMF_STREAM* stream, UINT32 newVolume,
- UINT32 muted)
+static BOOL tsmf_stream_change_volume(TSMF_STREAM* stream, UINT32 newVolume, UINT32 muted)
{
if (!stream || !stream->decoder)
return TRUE;
@@ -973,8 +968,8 @@ static BOOL tsmf_stream_change_volume(TSMF_STREAM* stream, UINT32 newVolume,
return TRUE;
}
-BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation,
- UINT32 newVolume, UINT32 muted)
+BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume,
+ UINT32 muted)
{
UINT32 index;
UINT32 count;
@@ -987,7 +982,7 @@ BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation,
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
ret &= tsmf_stream_change_volume(stream, newVolume, muted);
}
@@ -1006,7 +1001,7 @@ BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation)
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
ret &= tsmf_stream_pause(stream);
}
@@ -1025,7 +1020,7 @@ BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation)
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
ret &= tsmf_stream_restart(stream);
}
@@ -1044,7 +1039,7 @@ BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation)
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
ret &= tsmf_stream_start(stream);
}
@@ -1067,13 +1062,12 @@ UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation)
for (index = 0; index < count; index++)
{
- TSMF_STREAM* stream = (TSMF_STREAM*) ArrayList_GetItem(
- presentation->stream_list, index);
+ TSMF_STREAM* stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
if (WaitForSingleObject(stream->ready, 500) == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return error;
}
}
@@ -1093,7 +1087,7 @@ BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation)
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
ret &= tsmf_stream_stop(stream);
}
@@ -1103,8 +1097,9 @@ BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation)
return ret;
}
-BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
- UINT32 x, UINT32 y, UINT32 width, UINT32 height, int num_rects, RDP_RECT* rects)
+BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
+ UINT32 width, UINT32 height, int num_rects,
+ RDP_RECT* rects)
{
UINT32 index;
UINT32 count;
@@ -1117,9 +1112,10 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
if (!width || !height)
return TRUE;
- /* Streams can be added/removed from the presentation and the server will resend geometry info when a new stream is
- * added to the presentation. Also, num_rects is used to indicate whether or not the window is visible.
- * So, always process a valid message with unchanged position/size and/or no visibility rects.
+ /* Streams can be added/removed from the presentation and the server will resend geometry info
+ * when a new stream is added to the presentation. Also, num_rects is used to indicate whether
+ * or not the window is visible. So, always process a valid message with unchanged position/size
+ * and/or no visibility rects.
*/
presentation->x = x;
presentation->y = y;
@@ -1139,7 +1135,7 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
if (!stream->decoder)
continue;
@@ -1147,7 +1143,7 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
if (stream->decoder->UpdateRenderingArea)
{
ret = stream->decoder->UpdateRenderingArea(stream->decoder, x, y, width, height,
- num_rects, rects);
+ num_rects, rects);
}
}
@@ -1155,8 +1151,8 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
return ret;
}
-void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation,
- const char* name, const char* device)
+void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation, const char* name,
+ const char* device)
{
presentation->audio_name = name;
presentation->audio_device = device;
@@ -1166,7 +1162,7 @@ BOOL tsmf_stream_flush(TSMF_STREAM* stream)
{
BOOL ret = TRUE;
- //TSMF_SAMPLE* sample;
+ // TSMF_SAMPLE* sample;
/* TODO: free lists */
if (stream->audio)
ret = stream->audio->Flush(stream->audio);
@@ -1215,11 +1211,11 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id,
if (stream)
{
- WLog_ERR(TAG, "duplicated stream id %"PRIu32"!", stream_id);
+ WLog_ERR(TAG, "duplicated stream id %" PRIu32 "!", stream_id);
return NULL;
}
- stream = (TSMF_STREAM*) calloc(1, sizeof(TSMF_STREAM));
+ stream = (TSMF_STREAM*)calloc(1, sizeof(TSMF_STREAM));
if (!stream)
{
@@ -1258,14 +1254,14 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id,
goto error_sample_ack_list;
stream->sample_ack_list->object.fnObjectFree = tsmf_sample_free;
- stream->play_thread = CreateThread(NULL, 0, tsmf_stream_playback_func,
- stream, CREATE_SUSPENDED, NULL);
+ stream->play_thread =
+ CreateThread(NULL, 0, tsmf_stream_playback_func, stream, CREATE_SUSPENDED, NULL);
if (!stream->play_thread)
goto error_play_thread;
- stream->ack_thread = CreateThread(NULL, 0, tsmf_stream_ack_func, stream,
- CREATE_SUSPENDED, NULL);
+ stream->ack_thread =
+ CreateThread(NULL, 0, tsmf_stream_ack_func, stream, CREATE_SUSPENDED, NULL);
if (!stream->ack_thread)
goto error_ack_thread;
@@ -1279,13 +1275,13 @@ error_add:
SetEvent(stream->stopEvent);
if (WaitForSingleObject(stream->ack_thread, INFINITE) == WAIT_FAILED)
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError());
error_ack_thread:
SetEvent(stream->stopEvent);
if (WaitForSingleObject(stream->play_thread, INFINITE) == WAIT_FAILED)
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError());
error_play_thread:
Queue_Free(stream->sample_ack_list);
@@ -1306,8 +1302,7 @@ void tsmf_stream_start_threads(TSMF_STREAM* stream)
ResumeThread(stream->ack_thread);
}
-TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation,
- UINT32 stream_id)
+TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stream_id)
{
UINT32 index;
UINT32 count;
@@ -1318,7 +1313,7 @@ TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation,
for (index = 0; index < count; index++)
{
- stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index);
+ stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
if (stream->stream_id == stream_id)
{
@@ -1356,20 +1351,21 @@ BOOL tsmf_stream_set_format(TSMF_STREAM* stream, const char* name, wStream* s)
if (mediatype.MajorType == TSMF_MAJOR_TYPE_VIDEO)
{
- DEBUG_TSMF("video width %"PRIu32" height %"PRIu32" bit_rate %"PRIu32" frame_rate %f codec_data %"PRIu32"",
+ DEBUG_TSMF("video width %" PRIu32 " height %" PRIu32 " bit_rate %" PRIu32
+ " frame_rate %f codec_data %" PRIu32 "",
mediatype.Width, mediatype.Height, mediatype.BitRate,
- (double) mediatype.SamplesPerSecond.Numerator / (double)
- mediatype.SamplesPerSecond.Denominator,
+ (double)mediatype.SamplesPerSecond.Numerator /
+ (double)mediatype.SamplesPerSecond.Denominator,
mediatype.ExtraDataSize);
stream->minBufferLevel = VIDEO_MIN_BUFFER_LEVEL;
stream->maxBufferLevel = VIDEO_MAX_BUFFER_LEVEL;
}
else if (mediatype.MajorType == TSMF_MAJOR_TYPE_AUDIO)
{
- DEBUG_TSMF("audio channel %"PRIu32" sample_rate %"PRIu32" bits_per_sample %"PRIu32" codec_data %"PRIu32"",
+ DEBUG_TSMF("audio channel %" PRIu32 " sample_rate %" PRIu32 " bits_per_sample %" PRIu32
+ " codec_data %" PRIu32 "",
mediatype.Channels, mediatype.SamplesPerSecond.Numerator,
- mediatype.BitsPerSample,
- mediatype.ExtraDataSize);
+ mediatype.BitsPerSample, mediatype.ExtraDataSize);
stream->sample_rate = mediatype.SamplesPerSecond.Numerator;
stream->channels = mediatype.Channels;
stream->bits_per_sample = mediatype.BitsPerSample;
@@ -1392,12 +1388,10 @@ BOOL tsmf_stream_set_format(TSMF_STREAM* stream, const char* name, wStream* s)
return FALSE;
if (stream->decoder->SetAckFunc)
- ret &= stream->decoder->SetAckFunc(stream->decoder, tsmf_stream_process_ack,
- stream);
+ ret &= stream->decoder->SetAckFunc(stream->decoder, tsmf_stream_process_ack, stream);
if (stream->decoder->SetSyncFunc)
- ret &= stream->decoder->SetSyncFunc(stream->decoder, tsmf_stream_resync,
- stream);
+ ret &= stream->decoder->SetSyncFunc(stream->decoder, tsmf_stream_resync, stream);
return ret;
}
@@ -1427,7 +1421,7 @@ void _tsmf_stream_free(void* obj)
{
if (WaitForSingleObject(stream->play_thread, INFINITE) == WAIT_FAILED)
{
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError());
return;
}
@@ -1439,7 +1433,7 @@ void _tsmf_stream_free(void* obj)
{
if (WaitForSingleObject(stream->ack_thread, INFINITE) == WAIT_FAILED)
{
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", GetLastError());
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError());
return;
}
@@ -1468,11 +1462,9 @@ void tsmf_stream_free(TSMF_STREAM* stream)
ArrayList_Remove(presentation->stream_list, stream);
}
-BOOL tsmf_stream_push_sample(TSMF_STREAM* stream,
- IWTSVirtualChannelCallback* pChannelCallback,
+BOOL tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pChannelCallback,
UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration,
- UINT32 extensions,
- UINT32 data_size, BYTE* data)
+ UINT32 extensions, UINT32 data_size, BYTE* data)
{
TSMF_SAMPLE* sample;
SetEvent(stream->ready);
@@ -1480,7 +1472,7 @@ BOOL tsmf_stream_push_sample(TSMF_STREAM* stream,
if (TERMINATING)
return TRUE;
- sample = (TSMF_SAMPLE*) calloc(1, sizeof(TSMF_SAMPLE));
+ sample = (TSMF_SAMPLE*)calloc(1, sizeof(TSMF_SAMPLE));
if (!sample)
{
diff --git a/channels/tsmf/client/tsmf_media.h b/channels/tsmf/client/tsmf_media.h
index 3ab21ddc5..ade06da8f 100644
--- a/channels/tsmf/client/tsmf_media.h
+++ b/channels/tsmf/client/tsmf_media.h
@@ -37,7 +37,7 @@ typedef struct _TSMF_STREAM TSMF_STREAM;
typedef struct _TSMF_SAMPLE TSMF_SAMPLE;
TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid,
- IWTSVirtualChannelCallback* pChannelCallback);
+ IWTSVirtualChannelCallback* pChannelCallback);
TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid);
BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation);
BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation);
@@ -46,11 +46,11 @@ BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation);
BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation);
BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume,
UINT32 muted);
-BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
- UINT32 x, UINT32 y, UINT32 width, UINT32 height,
- int num_rects, RDP_RECT* rects);
-void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation,
- const char* name, const char* device);
+BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
+ UINT32 width, UINT32 height, int num_rects,
+ RDP_RECT* rects);
+void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation, const char* name,
+ const char* device);
void tsmf_presentation_free(TSMF_PRESENTATION* presentation);
TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id,
@@ -63,11 +63,10 @@ void tsmf_stream_free(TSMF_STREAM* stream);
BOOL tsmf_stream_flush(TSMF_STREAM* stream);
BOOL tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pChannelCallback,
- UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration, UINT32 extensions,
- UINT32 data_size, BYTE* data);
+ UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration,
+ UINT32 extensions, UINT32 data_size, BYTE* data);
BOOL tsmf_media_init(void);
void tsmf_stream_start_threads(TSMF_STREAM* stream);
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_MEDIA_H */
-
diff --git a/channels/tsmf/client/tsmf_types.h b/channels/tsmf/client/tsmf_types.h
index a6833f03f..7e3823dd2 100644
--- a/channels/tsmf/client/tsmf_types.h
+++ b/channels/tsmf/client/tsmf_types.h
@@ -33,7 +33,10 @@
#ifdef WITH_DEBUG_TSMF
#define DEBUG_TSMF(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_TSMF(...) do { } while (0)
+#define DEBUG_TSMF(...) \
+ do \
+ { \
+ } while (0)
#endif
typedef struct _TS_AM_MEDIA_TYPE
@@ -58,4 +61,3 @@ typedef struct _TS_AM_MEDIA_TYPE
} TS_AM_MEDIA_TYPE;
#endif /* FREERDP_CHANNEL_TSMF_CLIENT_TYPES_H */
-
diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c
index 336b7c081..5b4b00e6a 100644
--- a/channels/urbdrc/client/data_transfer.c
+++ b/channels/urbdrc/client/data_transfer.c
@@ -65,7 +65,7 @@ static int func_check_isochronous_fds(IUDEVICE* pdev)
ISOCH_CALLBACK_DATA* isoch = NULL;
URBDRC_CHANNEL_CALLBACK* callback;
- isoch_queue = (ISOCH_CALLBACK_QUEUE*) pdev->get_isoch_queue(pdev);
+ isoch_queue = (ISOCH_CALLBACK_QUEUE*)pdev->get_isoch_queue(pdev);
while (process_times)
{
@@ -93,7 +93,7 @@ static int func_check_isochronous_fds(IUDEVICE* pdev)
}
else
{
- callback = (URBDRC_CHANNEL_CALLBACK*) isoch->callback;
+ callback = (URBDRC_CHANNEL_CALLBACK*)isoch->callback;
size_temp = isoch->out_size;
data_temp = isoch->out_data;
@@ -117,8 +117,9 @@ static int func_check_isochronous_fds(IUDEVICE* pdev)
#endif
-static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* callback,
- BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman, UINT32 UsbDevice)
+static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, IUDEVMAN* udevman,
+ UINT32 UsbDevice)
{
IUDEVICE* pdev;
UINT32 NumRequestCompletion = 0;
@@ -135,7 +136,7 @@ static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* cal
{
data_read_UINT32(data + 0, NumRequestCompletion); /** must be 1 */
/** RequestCompletion:
- * unique Request Completion interface for the client to use */
+ * unique Request Completion interface for the client to use */
data_read_UINT32(data + 4, RequestCompletion);
pdev->set_ReqCompletion(pdev, RequestCompletion);
}
@@ -143,7 +144,7 @@ static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* cal
{
data_read_UINT32(data + 0, RequestCompletion);
- if (1)//(pdev->get_ReqCompletion(pdev) == RequestCompletion)
+ if (1) //(pdev->get_ReqCompletion(pdev) == RequestCompletion)
{
/** The wrong driver may also receive this message, So we
* need some time(default 3s) to check the driver or delete
@@ -157,7 +158,8 @@ static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* cal
return 0;
}
-static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman, UINT32 UsbDevice)
+static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman,
+ UINT32 UsbDevice)
{
IUDEVICE* pdev;
UINT32 CancelId;
@@ -165,7 +167,7 @@ static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN
data_read_UINT32(data + 0, CancelId); /** RequestId */
- WLog_DBG(TAG, "urbdrc_process_cancel_request: id 0x%"PRIx32"", CancelId);
+ WLog_DBG(TAG, "urbdrc_process_cancel_request: id 0x%" PRIx32 "", CancelId);
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
@@ -177,7 +179,8 @@ static int urbdrc_process_cancel_request(BYTE* data, UINT32 data_sizem, IUDEVMAN
return error;
}
-static int urbdrc_process_retract_device_request(BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman, UINT32 UsbDevice)
+static int urbdrc_process_retract_device_request(BYTE* data, UINT32 data_sizem, IUDEVMAN* udevman,
+ UINT32 UsbDevice)
{
UINT32 Reason;
WLog_DBG(TAG, "urbdrc_process_retract_device_request");
@@ -192,7 +195,8 @@ static int urbdrc_process_retract_device_request(BYTE* data, UINT32 data_sizem,
break;
default:
- WLog_DBG(TAG, "urbdrc_process_retract_device_request: Unknown Reason %"PRIu32"", Reason);
+ WLog_DBG(TAG, "urbdrc_process_retract_device_request: Unknown Reason %" PRIu32 "",
+ Reason);
return -1;
break;
}
@@ -201,7 +205,8 @@ static int urbdrc_process_retract_device_request(BYTE* data, UINT32 data_sizem,
}
static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN * udevman, UINT32 UsbDevice)
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice)
{
IUDEVICE* pdev;
UINT32 out_size;
@@ -227,28 +232,29 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
/** process */
- OutputBuffer = (BYTE *)calloc(1, OutputBufferSize);
+ OutputBuffer = (BYTE*)calloc(1, OutputBufferSize);
if (!OutputBuffer)
return ERROR_OUTOFMEMORY;
switch (IoControlCode)
{
- case IOCTL_INTERNAL_USB_SUBMIT_URB: /** 0x00220003 */
+ case IOCTL_INTERNAL_USB_SUBMIT_URB: /** 0x00220003 */
WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_SUBMIT_URB");
- WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked");
+ WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked");
break;
- case IOCTL_INTERNAL_USB_RESET_PORT: /** 0x00220007 */
+ case IOCTL_INTERNAL_USB_RESET_PORT: /** 0x00220007 */
WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_RESET_PORT");
break;
case IOCTL_INTERNAL_USB_GET_PORT_STATUS: /** 0x00220013 */
WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_GET_PORT_STATUS");
- success = pdev->query_device_port_status(pdev, &usbd_status, &OutputBufferSize, OutputBuffer);
+ success =
+ pdev->query_device_port_status(pdev, &usbd_status, &OutputBufferSize, OutputBuffer);
if (success)
{
@@ -262,24 +268,26 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
OutputBufferSize = 4;
}
- WLog_DBG(TAG, "PORT STATUS(fake!):0x%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"",
- OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0]);
+ WLog_DBG(TAG,
+ "PORT STATUS(fake!):0x%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "",
+ OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0]);
}
break;
- case IOCTL_INTERNAL_USB_CYCLE_PORT: /** 0x0022001F */
+ case IOCTL_INTERNAL_USB_CYCLE_PORT: /** 0x0022001F */
WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_CYCLE_PORT");
- WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked");
+ WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked");
break;
case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: /** 0x00220027 */
WLog_DBG(TAG, "ioctl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION");
- WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked");
+ WLog_ERR(TAG, " Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked");
break;
default:
- WLog_DBG(TAG, "urbdrc_process_io_control: unknown IoControlCode 0x%"PRIX32"", IoControlCode);
+ WLog_DBG(TAG, "urbdrc_process_io_control: unknown IoControlCode 0x%" PRIX32 "",
+ IoControlCode);
zfree(OutputBuffer);
return ERROR_INVALID_OPERATION;
break;
@@ -287,19 +295,19 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
offset = 28;
out_size = offset + OutputBufferSize;
- out_data = (BYTE *) calloc(1, out_size);
+ out_data = (BYTE*)calloc(1, out_size);
if (!out_data)
{
zfree(OutputBuffer);
return ERROR_OUTOFMEMORY;
}
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
data_write_UINT32(out_data + 8, IOCONTROL_COMPLETION); /** function id */
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
data_write_UINT32(out_data + 16, USBD_STATUS_SUCCESS); /** HResult */
- data_write_UINT32(out_data + 20, OutputBufferSize); /** Information */
- data_write_UINT32(out_data + 24, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 20, OutputBufferSize); /** Information */
+ data_write_UINT32(out_data + 24, OutputBufferSize); /** OutputBufferSize */
for (i = 0; i < OutputBufferSize; i++)
{
@@ -317,7 +325,8 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
}
static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice)
+ UINT32 data_sizem, UINT32 MessageId,
+ IUDEVMAN* udevman, UINT32 UsbDevice)
{
IUDEVICE* pdev;
BYTE* out_data;
@@ -326,7 +335,7 @@ static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback,
data_read_UINT32(data + 0, IoControlCode);
- WLog_DBG(TAG, "urbdrc_process_internal_io_control:0x%"PRIx32"", IoControlCode);
+ WLog_DBG(TAG, "urbdrc_process_internal_io_control:0x%" PRIx32 "", IoControlCode);
data_read_UINT32(data + 4, InputBufferSize);
data_read_UINT32(data + 8, OutputBufferSize);
@@ -337,22 +346,22 @@ static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback,
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
/** Fixme: Currently this is a FALSE bustime... */
urbdrc_get_mstime(frames);
out_size = 32;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
data_write_UINT32(out_data + 8, IOCONTROL_COMPLETION); /** function id */
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0); /** HResult */
- data_write_UINT32(out_data + 20, 4); /** Information */
- data_write_UINT32(out_data + 24, 4); /** OutputBufferSize */
- data_write_UINT32(out_data + 28, frames); /** OutputBuffer */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0); /** HResult */
+ data_write_UINT32(out_data + 20, 4); /** Information */
+ data_write_UINT32(out_data + 24, 4); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, frames); /** OutputBuffer */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -363,7 +372,8 @@ static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback,
}
static int urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice)
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice)
{
IUDEVICE* pdev;
UINT32 out_size;
@@ -395,15 +405,15 @@ static int urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK* callback, B
if (bufferSize != 0)
out_size += 2;
- out_data = (BYTE*) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
if (bufferSize != 0)
{
- data_write_UINT32(out_data + 8, (bufferSize/2)+1); /** cchDeviceDescription */
+ data_write_UINT32(out_data + 8, (bufferSize / 2) + 1); /** cchDeviceDescription */
out_offset = 12;
memcpy(out_data + out_offset, DeviceDescription, bufferSize);
out_offset += bufferSize;
@@ -426,11 +436,12 @@ static int urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK* callback, B
return 0;
}
-static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, MSUSB_CONFIG_DESCRIPTOR* MsConfig)
+static void func_select_all_interface_for_msconfig(IUDEVICE* pdev,
+ MSUSB_CONFIG_DESCRIPTOR* MsConfig)
{
UINT32 inum;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces;
- BYTE InterfaceNumber, AlternateSetting;
+ BYTE InterfaceNumber, AlternateSetting;
UINT32 NumInterfaces = MsConfig->NumInterfaces;
for (inum = 0; inum < NumInterfaces; inum++)
@@ -442,9 +453,10 @@ static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, MSUSB_CONFIG_
}
static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice, int transferDir)
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
- MSUSB_CONFIG_DESCRIPTOR * MsConfig = NULL;
+ MSUSB_CONFIG_DESCRIPTOR* MsConfig = NULL;
IUDEVICE* pdev = NULL;
UINT32 out_size, InterfaceId, RequestId, NumInterfaces, usbd_status = 0;
BYTE ConfigurationDescriptorIsValid;
@@ -453,7 +465,7 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
if (transferDir == 0)
{
- WLog_ERR(TAG, "urb_select_configuration: not support transfer out");
+ WLog_ERR(TAG, "urb_select_configuration: not support transfer out");
return -1;
}
@@ -462,7 +474,7 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_BYTE(data + 4, ConfigurationDescriptorIsValid);
data_read_UINT32(data + 8, NumInterfaces);
@@ -488,12 +500,12 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
out_size = 36 + MsOutSize;
else
out_size = 44;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
if (MsOutSize > 0)
{
/** CbTsUrbResult */
@@ -509,7 +521,7 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_SELECT_CONFIGURATION);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
offset = 28;
/** TS_URB_SELECT_CONFIGURATION_RESULT */
if (MsOutSize > 0)
@@ -518,12 +530,12 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
}
else
{
- data_write_UINT32(out_data + offset, 0); /** ConfigurationHandle */
- data_write_UINT32(out_data + offset + 4, NumInterfaces); /** NumInterfaces */
+ data_write_UINT32(out_data + offset, 0); /** ConfigurationHandle */
+ data_write_UINT32(out_data + offset + 4, NumInterfaces); /** NumInterfaces */
offset += 8;
}
- data_write_UINT32(out_data + offset, 0); /** HResult */
- data_write_UINT32(out_data + offset + 4, 0); /** OutputBufferSize */
+ data_write_UINT32(out_data + offset, 0); /** HResult */
+ data_write_UINT32(out_data + offset + 4, 0); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -532,7 +544,8 @@ static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, BYTE* dat
}
static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, UINT32 data_sizem,
- UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice, int transferDir)
+ UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice,
+ int transferDir)
{
MSUSB_CONFIG_DESCRIPTOR* MsConfig;
MSUSB_INTERFACE_DESCRIPTOR* MsInterface;
@@ -545,7 +558,7 @@ static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, U
if (transferDir == 0)
{
- WLog_ERR(TAG, "urb_select_interface: not support transfer out");
+ WLog_ERR(TAG, "urb_select_interface: not support transfer out");
return -1;
}
@@ -576,27 +589,27 @@ static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, U
MsInterface = MsConfig->MsInterfaces[InterfaceNumber];
interface_size = 16 + (MsInterface->NumberOfPipes * 20);
- out_size = 36 + interface_size ;
- out_data = (BYTE*) malloc(out_size);
+ out_size = 36 + interface_size;
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 8 + interface_size); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 8 + interface_size); /** CbTsUrbResult */
/** TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 8 + interface_size); /** Size */
+ data_write_UINT16(out_data + 20, 8 + interface_size); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_SELECT_INTERFACE);
- data_write_UINT32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */
out_offset = 28;
/** TS_URB_SELECT_INTERFACE_RESULT */
msusb_msinterface_write(MsInterface, out_data + out_offset, &out_offset);
- data_write_UINT32(out_data + out_offset, 0); /** HResult */
- data_write_UINT32(out_data + out_offset + 4, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + out_offset, 0); /** HResult */
+ data_write_UINT32(out_data + out_offset + 4, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -606,8 +619,9 @@ static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, U
return 0;
}
-static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice, int transferDir, int External)
+static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, UINT32 data_sizem,
+ UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice,
+ int transferDir, int External)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle;
@@ -629,7 +643,7 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
data_read_UINT32(data + 8, TransferFlags); /** TransferFlags */
EndpointAddress = (PipeHandle & 0x000000ff);
- offset = 12;
+ offset = 12;
Timeout = 2000;
switch (External)
@@ -649,7 +663,7 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
data_read_UINT16(data + offset + 4, Index);
data_read_UINT16(data + offset + 6, length);
data_read_UINT32(data + offset + 8, OutputBufferSize);
- offset += 12;
+ offset += 12;
if (length != OutputBufferSize)
{
@@ -658,7 +672,7 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
}
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
@@ -668,18 +682,12 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
memcpy(buffer, data + offset, OutputBufferSize);
/** process URB_FUNCTION_CONTROL_TRANSFER */
- ret = pdev->control_transfer(
- pdev, RequestId, EndpointAddress, TransferFlags,
- bmRequestType,
- Request,
- Value,
- Index,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- Timeout);
+ ret = pdev->control_transfer(pdev, RequestId, EndpointAddress, TransferFlags, bmRequestType,
+ Request, Value, Index, &usbd_status, &OutputBufferSize, buffer,
+ Timeout);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "control_transfer: error num %d!!", ret);
OutputBufferSize = 0;
}
@@ -691,24 +699,24 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
else
out_size = offset;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ if (transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_CONTROL_TRANSFER);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -719,7 +727,8 @@ static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
}
static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
- UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice, int transferDir)
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
int offset;
BYTE* Buffer;
@@ -737,7 +746,7 @@ static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYT
data_read_UINT32(data + 0, RequestId);
data_read_UINT32(data + 4, PipeHandle);
- data_read_UINT32(data + 8, TransferFlags); /** TransferFlags */
+ data_read_UINT32(data + 8, TransferFlags); /** TransferFlags */
data_read_UINT32(data + 12, OutputBufferSize);
offset = 16;
EndpointAddress = (PipeHandle & 0x000000ff);
@@ -748,7 +757,7 @@ static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYT
out_size = 36 + OutputBufferSize;
Buffer = NULL;
- out_data = (BYTE*) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
switch (transferDir)
@@ -763,13 +772,8 @@ static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYT
}
/** process URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER */
- pdev->bulk_or_interrupt_transfer(
- pdev, RequestId, EndpointAddress,
- TransferFlags,
- &usbd_status,
- &OutputBufferSize,
- Buffer,
- 10000);
+ pdev->bulk_or_interrupt_transfer(pdev, RequestId, EndpointAddress, TransferFlags, &usbd_status,
+ &OutputBufferSize, Buffer, 10000);
offset = 36;
if (transferDir == USBD_TRANSFER_DIRECTION_IN)
@@ -777,23 +781,23 @@ static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYT
else
out_size = offset;
/** send data */
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ if (transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (pdev && !pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -803,24 +807,20 @@ static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYT
return 0;
}
-
-static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, UINT32 data_sizem,
+ UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice,
+ int transferDir)
{
- IUDEVICE * pdev;
- UINT32 RequestId, InterfaceId, EndpointAddress;
- UINT32 PipeHandle, TransferFlags, StartFrame, NumberOfPackets;
- UINT32 ErrorCount, OutputBufferSize, usbd_status = 0;
- UINT32 RequestField, noAck = 0;
- UINT32 out_size = 0;
- BYTE * iso_buffer = NULL;
- BYTE * iso_packets = NULL;
- BYTE * out_data = NULL;
- int offset, nullBuffer = 0, iso_status;
+ IUDEVICE* pdev;
+ UINT32 RequestId, InterfaceId, EndpointAddress;
+ UINT32 PipeHandle, TransferFlags, StartFrame, NumberOfPackets;
+ UINT32 ErrorCount, OutputBufferSize, usbd_status = 0;
+ UINT32 RequestField, noAck = 0;
+ UINT32 out_size = 0;
+ BYTE* iso_buffer = NULL;
+ BYTE* iso_packets = NULL;
+ BYTE* out_data = NULL;
+ int offset, nullBuffer = 0, iso_status;
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
@@ -828,31 +828,34 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
if (pdev->isSigToEnd(pdev))
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestField);
- RequestId = RequestField & 0x7fffffff;
- noAck = (RequestField & 0x80000000)>>31;
+ RequestId = RequestField & 0x7fffffff;
+ noAck = (RequestField & 0x80000000) >> 31;
data_read_UINT32(data + 4, PipeHandle);
- EndpointAddress = (PipeHandle & 0x000000ff);
- data_read_UINT32(data + 8, TransferFlags); /** TransferFlags */
- data_read_UINT32(data + 12, StartFrame); /** StartFrame */
+ EndpointAddress = (PipeHandle & 0x000000ff);
+ data_read_UINT32(data + 8, TransferFlags); /** TransferFlags */
+ data_read_UINT32(data + 12, StartFrame); /** StartFrame */
data_read_UINT32(data + 16, NumberOfPackets); /** NumberOfPackets */
- data_read_UINT32(data + 20, ErrorCount); /** ErrorCount */
+ data_read_UINT32(data + 20, ErrorCount); /** ErrorCount */
offset = 24 + (NumberOfPackets * 12);
data_read_UINT32(data + offset, OutputBufferSize);
offset += 4;
/** send data memory alloc */
- if (transferDir == USBD_TRANSFER_DIRECTION_OUT) {
- if (!noAck) {
+ if (transferDir == USBD_TRANSFER_DIRECTION_OUT)
+ {
+ if (!noAck)
+ {
out_size = 48 + (NumberOfPackets * 12);
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
iso_packets = out_data + 40;
}
}
- else {
+ else
+ {
out_size = 48 + OutputBufferSize + (NumberOfPackets * 12);
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
iso_packets = out_data + 40;
}
@@ -863,7 +866,7 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
{
case USBD_TRANSFER_DIRECTION_OUT:
/** Get Buffer Data */
- //memcpy(iso_buffer, data + offset, OutputBufferSize);
+ // memcpy(iso_buffer, data + offset, OutputBufferSize);
iso_buffer = data + offset;
break;
case USBD_TRANSFER_DIRECTION_IN:
@@ -871,39 +874,31 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
break;
}
- WLog_DBG(TAG, "urb_isoch_transfer: EndpointAddress: 0x%"PRIx32", "
- "TransferFlags: 0x%"PRIx32", "
- "StartFrame: 0x%"PRIx32", "
- "NumberOfPackets: 0x%"PRIx32", "
- "OutputBufferSize: 0x%"PRIx32" "
- "RequestId: 0x%"PRIx32"",
- EndpointAddress, TransferFlags, StartFrame,
- NumberOfPackets, OutputBufferSize, RequestId);
+ WLog_DBG(TAG,
+ "urb_isoch_transfer: EndpointAddress: 0x%" PRIx32 ", "
+ "TransferFlags: 0x%" PRIx32 ", "
+ "StartFrame: 0x%" PRIx32 ", "
+ "NumberOfPackets: 0x%" PRIx32 ", "
+ "OutputBufferSize: 0x%" PRIx32 " "
+ "RequestId: 0x%" PRIx32 "",
+ EndpointAddress, TransferFlags, StartFrame, NumberOfPackets, OutputBufferSize,
+ RequestId);
#if ISOCH_FIFO
- ISOCH_CALLBACK_QUEUE * isoch_queue = NULL;
- ISOCH_CALLBACK_DATA * isoch = NULL;
- if(!noAck)
+ ISOCH_CALLBACK_QUEUE* isoch_queue = NULL;
+ ISOCH_CALLBACK_DATA* isoch = NULL;
+ if (!noAck)
{
- isoch_queue = (ISOCH_CALLBACK_QUEUE *)pdev->get_isoch_queue(pdev);
+ isoch_queue = (ISOCH_CALLBACK_QUEUE*)pdev->get_isoch_queue(pdev);
isoch = isoch_queue->register_data(isoch_queue, callback, pdev);
}
#endif
- iso_status = pdev->isoch_transfer(
- pdev, RequestId, EndpointAddress,
- TransferFlags,
- noAck,
- &ErrorCount,
- &usbd_status,
- &StartFrame,
- NumberOfPackets,
- iso_packets,
- &OutputBufferSize,
- iso_buffer,
- 2000);
+ iso_status = pdev->isoch_transfer(pdev, RequestId, EndpointAddress, TransferFlags, noAck,
+ &ErrorCount, &usbd_status, &StartFrame, NumberOfPackets,
+ iso_packets, &OutputBufferSize, iso_buffer, 2000);
- if(noAck)
+ if (noAck)
{
zfree(out_data);
return 0;
@@ -912,47 +907,47 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
if (iso_status < 0)
nullBuffer = 1;
-
out_size = 48;
if (nullBuffer)
OutputBufferSize = 0;
else
out_size += OutputBufferSize + (NumberOfPackets * 12);
/* fill the send data */
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(OutputBufferSize != 0 && !nullBuffer)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ if (OutputBufferSize != 0 && !nullBuffer)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 20 + (NumberOfPackets * 12)); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 20 + (NumberOfPackets * 12)); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 20 + (NumberOfPackets * 12)); /** Size */
+ data_write_UINT16(out_data + 20, 20 + (NumberOfPackets * 12)); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_ISOCH_TRANSFER);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, StartFrame); /** StartFrame */
+ data_write_UINT32(out_data + 28, StartFrame); /** StartFrame */
if (!nullBuffer)
{
/** NumberOfPackets */
data_write_UINT32(out_data + 32, NumberOfPackets);
- data_write_UINT32(out_data + 36, ErrorCount); /** ErrorCount */
+ data_write_UINT32(out_data + 36, ErrorCount); /** ErrorCount */
offset = 40 + (NumberOfPackets * 12);
}
else
{
- data_write_UINT32(out_data + 32, 0); /** NumberOfPackets */
- data_write_UINT32(out_data + 36, NumberOfPackets); /** ErrorCount */
+ data_write_UINT32(out_data + 32, 0); /** NumberOfPackets */
+ data_write_UINT32(out_data + 36, NumberOfPackets); /** ErrorCount */
offset = 40;
}
- data_write_UINT32(out_data + offset, 0); /** HResult */
- data_write_UINT32(out_data + offset + 4, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + offset, 0); /** HResult */
+ data_write_UINT32(out_data + offset + 4, OutputBufferSize); /** OutputBufferSize */
#if ISOCH_FIFO
- if(!noAck){
+ if (!noAck)
+ {
pthread_mutex_lock(&isoch_queue->isoch_loading);
isoch->out_data = out_data;
isoch->out_size = out_size;
@@ -970,14 +965,9 @@ static int urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
return 0;
}
-static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- BYTE func_recipient,
- int transferDir)
+static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, BYTE func_recipient, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, InterfaceId, RequestId, OutputBufferSize, usbd_status;
@@ -992,7 +982,7 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback,
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_BYTE(data + 4, desc_index);
data_read_BYTE(data + 5, desc_type);
@@ -1000,7 +990,7 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback,
data_read_UINT32(data + 8, OutputBufferSize);
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
@@ -1026,35 +1016,29 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback,
/** process get usb device descriptor */
ret = pdev->control_transfer(
- pdev, RequestId, 0, 0, bmRequestType,
- 0x06, /* REQUEST_GET_DESCRIPTOR */
- (desc_type << 8) | desc_index,
- langId,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ pdev, RequestId, 0, 0, bmRequestType, 0x06, /* REQUEST_GET_DESCRIPTOR */
+ (desc_type << 8) | desc_index, langId, &usbd_status, &OutputBufferSize, buffer, 1000);
-
- if (ret < 0) {
+ if (ret < 0)
+ {
WLog_DBG(TAG, "get_descriptor: error num %d", ret);
OutputBufferSize = 0;
}
offset = 36;
out_size = offset + OutputBufferSize;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1063,13 +1047,9 @@ static int urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback,
return 0;
}
-static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- BYTE func_recipient,
- int transferDir)
+static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, BYTE func_recipient, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status;
@@ -1079,7 +1059,8 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY
BYTE* out_data;
int offset, ret;
- if (transferDir == 0){
+ if (transferDir == 0)
+ {
WLog_DBG(TAG, "urb_control_get_status_request: not support transfer out");
return -1;
}
@@ -1087,36 +1068,32 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT16(data + 4, Index); /** Index */
data_read_UINT32(data + 8, OutputBufferSize);
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
bmRequestType = func_recipient | 0x80;
- ret = pdev->control_transfer(
- pdev, RequestId, 0, 0, bmRequestType,
- 0x00, /* REQUEST_GET_STATUS */
- 0,
- Index,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ ret =
+ pdev->control_transfer(pdev, RequestId, 0, 0, bmRequestType, 0x00, /* REQUEST_GET_STATUS */
+ 0, Index, &usbd_status, &OutputBufferSize, buffer, 1000);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "control_transfer: error num %d!!", ret);
OutputBufferSize = 0;
usbd_status = USBD_STATUS_STALL_PID;
}
- else{
+ else
+ {
usbd_status = USBD_STATUS_SUCCESS;
}
@@ -1127,24 +1104,24 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY
else
out_size = offset;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ if (transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId, include NoAck*/
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId, include NoAck*/
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_VENDOR_DEVICE);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1154,15 +1131,10 @@ static int urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, BY
return 0;
}
-static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- BYTE func_type,
- BYTE func_recipient,
- int transferDir)
+static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId,
+ IUDEVMAN* udevman, UINT32 UsbDevice, BYTE func_type,
+ BYTE func_recipient, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, TransferFlags, usbd_status;
@@ -1177,20 +1149,20 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
- data_read_UINT32(data + 4, TransferFlags); /** TransferFlags */
+ data_read_UINT32(data + 4, TransferFlags); /** TransferFlags */
data_read_BYTE(data + 8, ReqTypeReservedBits); /** ReqTypeReservedBids */
- data_read_BYTE(data + 9, Request); /** Request */
- data_read_UINT16(data + 10, Value); /** value */
- data_read_UINT16(data + 12, Index); /** index */
- data_read_UINT16(data + 14, Padding); /** Padding */
+ data_read_BYTE(data + 9, Request); /** Request */
+ data_read_UINT16(data + 10, Value); /** value */
+ data_read_UINT16(data + 12, Index); /** index */
+ data_read_UINT16(data + 14, Padding); /** Padding */
data_read_UINT32(data + 16, OutputBufferSize);
offset = 20;
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
@@ -1205,28 +1177,26 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac
if (TransferFlags & USBD_TRANSFER_DIRECTION)
bmRequestType |= 0x80;
- WLog_DBG(TAG, "urb_control_vendor_or_class_request: "
- "RequestId 0x%"PRIx32" TransferFlags: 0x%"PRIx32" ReqTypeReservedBits: 0x%"PRIx8" "
- "Request:0x%"PRIx8" Value: 0x%"PRIx16" Index: 0x%"PRIx16" OutputBufferSize: 0x%"PRIx32" bmRequestType: 0x%"PRIx8"!!",
- RequestId, TransferFlags, ReqTypeReservedBits, Request, Value,
- Index, OutputBufferSize, bmRequestType);
+ WLog_DBG(TAG,
+ "urb_control_vendor_or_class_request: "
+ "RequestId 0x%" PRIx32 " TransferFlags: 0x%" PRIx32 " ReqTypeReservedBits: 0x%" PRIx8
+ " "
+ "Request:0x%" PRIx8 " Value: 0x%" PRIx16 " Index: 0x%" PRIx16
+ " OutputBufferSize: 0x%" PRIx32 " bmRequestType: 0x%" PRIx8 "!!",
+ RequestId, TransferFlags, ReqTypeReservedBits, Request, Value, Index, OutputBufferSize,
+ bmRequestType);
- ret = pdev->control_transfer(
- pdev, RequestId, 0, 0, bmRequestType,
- Request,
- Value,
- Index,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 2000);
+ ret = pdev->control_transfer(pdev, RequestId, 0, 0, bmRequestType, Request, Value, Index,
+ &usbd_status, &OutputBufferSize, buffer, 2000);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "control_transfer: error num %d!!", ret);
OutputBufferSize = 0;
usbd_status = USBD_STATUS_STALL_PID;
}
- else{
+ else
+ {
usbd_status = USBD_STATUS_SUCCESS;
}
@@ -1236,23 +1206,24 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac
else
out_size = offset;
/** send data */
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ if (transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId, include NoAck*/
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId, include NoAck*/
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
- data_write_UINT16(out_data + 22, URB_FUNCTION_VENDOR_DEVICE); /** Padding, MUST be ignored upon receipt */
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 22,
+ URB_FUNCTION_VENDOR_DEVICE); /** Padding, MUST be ignored upon receipt */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1261,15 +1232,9 @@ static int urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callbac
return 0;
}
-
-
-static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status;
@@ -1284,19 +1249,19 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
- data_read_BYTE(data + 4, Recipient); /** Recipient */
- Recipient = (Recipient & 0x1f); /* XXX: origin: Recipient && 0x1f !? */
- data_read_BYTE(data + 5, InterfaceNumber); /** InterfaceNumber */
- data_read_BYTE(data + 6, Ms_PageIndex); /** Ms_PageIndex */
+ data_read_BYTE(data + 4, Recipient); /** Recipient */
+ Recipient = (Recipient & 0x1f); /* XXX: origin: Recipient && 0x1f !? */
+ data_read_BYTE(data + 5, InterfaceNumber); /** InterfaceNumber */
+ data_read_BYTE(data + 6, Ms_PageIndex); /** Ms_PageIndex */
data_read_UINT16(data + 7, Ms_featureDescIndex); /** Ms_featureDescIndex */
data_read_UINT32(data + 12, OutputBufferSize);
offset = 16;
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
@@ -1304,29 +1269,23 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
switch (transferDir)
{
case USBD_TRANSFER_DIRECTION_OUT:
- WLog_ERR(TAG, "Function urb_os_feature_descriptor_request: OUT Unchecked");
+ WLog_ERR(TAG, "Function urb_os_feature_descriptor_request: OUT Unchecked");
memcpy(buffer, data + offset, OutputBufferSize);
break;
case USBD_TRANSFER_DIRECTION_IN:
break;
}
- WLog_DBG(TAG, "Ms descriptor arg: Recipient:0x%"PRIx8", "
- "InterfaceNumber:0x%"PRIx8", Ms_PageIndex:0x%"PRIx8", "
- "Ms_featureDescIndex:0x%"PRIx16", OutputBufferSize:0x%"PRIx32"",
- Recipient, InterfaceNumber, Ms_PageIndex,
- Ms_featureDescIndex, OutputBufferSize);
+ WLog_DBG(TAG,
+ "Ms descriptor arg: Recipient:0x%" PRIx8 ", "
+ "InterfaceNumber:0x%" PRIx8 ", Ms_PageIndex:0x%" PRIx8 ", "
+ "Ms_featureDescIndex:0x%" PRIx16 ", OutputBufferSize:0x%" PRIx32 "",
+ Recipient, InterfaceNumber, Ms_PageIndex, Ms_featureDescIndex, OutputBufferSize);
/** get ms string */
- ret = pdev->os_feature_descriptor_request(
- pdev, RequestId, Recipient,
- InterfaceNumber,
- Ms_PageIndex,
- Ms_featureDescIndex,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ ret = pdev->os_feature_descriptor_request(pdev, RequestId, Recipient, InterfaceNumber,
+ Ms_PageIndex, Ms_featureDescIndex, &usbd_status,
+ &OutputBufferSize, buffer, 1000);
if (ret < 0)
WLog_DBG(TAG, "os_feature_descriptor_request: error num %d", ret);
@@ -1334,23 +1293,23 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
offset = 36;
out_size = offset + OutputBufferSize;
/** send data */
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
- if(OutputBufferSize!=0)
- data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
+ if (OutputBufferSize != 0)
+ data_write_UINT32(out_data + 8, URB_COMPLETION); /** function id */
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1360,13 +1319,9 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
return 0;
}
-static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir,
- int action)
+static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data, UINT32 data_sizem,
+ UINT32 MessageId, IUDEVMAN* udevman, UINT32 UsbDevice, int transferDir,
+ int action)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, PipeHandle, EndpointAddress;
@@ -1374,7 +1329,8 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
BYTE* out_data;
int out_offset, ret;
- if (transferDir == 0){
+ if (transferDir == 0)
+ {
WLog_DBG(TAG, "urb_pipe_request: not support transfer out");
return -1;
}
@@ -1384,36 +1340,32 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT32(data + 4, PipeHandle); /** PipeHandle */
data_read_UINT32(data + 8, OutputBufferSize);
EndpointAddress = (PipeHandle & 0x000000ff);
-
- switch (action){
+ switch (action)
+ {
case PIPE_CANCEL:
- WLog_DBG(TAG, "urb_pipe_request: PIPE_CANCEL 0x%"PRIx32"", EndpointAddress);
+ WLog_DBG(TAG, "urb_pipe_request: PIPE_CANCEL 0x%" PRIx32 "", EndpointAddress);
- ret = pdev->control_pipe_request(
- pdev, RequestId, EndpointAddress,
- &usbd_status,
- PIPE_CANCEL);
+ ret = pdev->control_pipe_request(pdev, RequestId, EndpointAddress, &usbd_status,
+ PIPE_CANCEL);
- if (ret < 0) {
+ if (ret < 0)
+ {
WLog_DBG(TAG, "PIPE SET HALT: error num %d", ret);
}
-
break;
case PIPE_RESET:
- WLog_DBG(TAG, "urb_pipe_request: PIPE_RESET ep 0x%"PRIx32"", EndpointAddress);
+ WLog_DBG(TAG, "urb_pipe_request: PIPE_RESET ep 0x%" PRIx32 "", EndpointAddress);
- ret = pdev->control_pipe_request(
- pdev, RequestId, EndpointAddress,
- &usbd_status,
- PIPE_RESET);
+ ret = pdev->control_pipe_request(pdev, RequestId, EndpointAddress, &usbd_status,
+ PIPE_RESET);
if (ret < 0)
WLog_DBG(TAG, "PIPE RESET: error num %d!!", ret);
@@ -1424,27 +1376,26 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
break;
}
-
/** send data */
out_offset = 36;
out_size = out_offset + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 0x00000008); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 0x0008); /** Size */
+ data_write_UINT16(out_data + 20, 0x0008); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, 0); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, 0); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1453,55 +1404,52 @@ static int urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
return 0;
}
-static int urb_get_current_frame_number(URBDRC_CHANNEL_CALLBACK* callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urb_get_current_frame_number(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize;
UINT32 dummy_frames;
BYTE* out_data;
- if (transferDir == 0){
+ if (transferDir == 0)
+ {
WLog_DBG(TAG, "urb_get_current_frame_number: not support transfer out");
- //exit(1);
+ // exit(1);
return -1;
}
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT32(data + 4, OutputBufferSize);
- /** Fixme: Need to fill actual frame number!!*/
+ /** Fixme: Need to fill actual frame number!!*/
urbdrc_get_mstime(dummy_frames);
out_size = 40;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 12); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 12); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 12); /** Size */
+ data_write_UINT16(out_data + 20, 12); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_CURRENT_FRAME_NUMBER);
- data_write_UINT32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */
- data_write_UINT32(out_data + 28, dummy_frames); /** FrameNumber */
+ data_write_UINT32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */
+ data_write_UINT32(out_data + 28, dummy_frames); /** FrameNumber */
- data_write_UINT32(out_data + 32, 0); /** HResult */
- data_write_UINT32(out_data + 36, 0); /** OutputBufferSize */
+ data_write_UINT32(out_data + 32, 0); /** HResult */
+ data_write_UINT32(out_data + 36, 0); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1509,15 +1457,11 @@ static int urb_get_current_frame_number(URBDRC_CHANNEL_CALLBACK* callback,
return 0;
}
-
/* Unused function for current server */
-static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId,
+ IUDEVMAN* udevman, UINT32 UsbDevice,
+ int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status;
@@ -1528,7 +1472,7 @@ static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callba
if (transferDir == 0)
{
WLog_DBG(TAG, "urb_control_get_configuration_request:"
- " not support transfer out");
+ " not support transfer out");
return -1;
}
@@ -1537,53 +1481,47 @@ static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callba
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT32(data + 4, OutputBufferSize);
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
- ret = pdev->control_transfer(
- pdev, RequestId, 0, 0, 0x80 | 0x00,
- 0x08, /* REQUEST_GET_CONFIGURATION */
- 0,
- 0,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ ret = pdev->control_transfer(pdev, RequestId, 0, 0, 0x80 | 0x00,
+ 0x08, /* REQUEST_GET_CONFIGURATION */
+ 0, 0, &usbd_status, &OutputBufferSize, buffer, 1000);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "control_transfer: error num %d", ret);
OutputBufferSize = 0;
}
-
offset = 36;
out_size = offset + OutputBufferSize;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
if (OutputBufferSize != 0)
data_write_UINT32(out_data + 8, URB_COMPLETION);
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 8); /** Size */
+ data_write_UINT16(out_data + 20, 8); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_CONFIGURATION);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1592,13 +1530,9 @@ static int urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK* callba
}
/* Unused function for current server */
-static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback,
- BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status;
@@ -1607,7 +1541,8 @@ static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback,
BYTE* out_data;
int ret, offset;
- if (transferDir == 0){
+ if (transferDir == 0)
+ {
WLog_DBG(TAG, "urb_control_get_interface_request: not support transfer out");
return -1;
}
@@ -1615,52 +1550,48 @@ static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback,
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT16(data + 4, interface);
data_read_UINT32(data + 8, OutputBufferSize);
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
- ret = pdev->control_transfer(pdev, RequestId, 0, 0, 0x80 | 0x01,
- 0x0A, /* REQUEST_GET_INTERFACE */
- 0,
- interface,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ ret =
+ pdev->control_transfer(pdev, RequestId, 0, 0, 0x80 | 0x01, 0x0A, /* REQUEST_GET_INTERFACE */
+ 0, interface, &usbd_status, &OutputBufferSize, buffer, 1000);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "control_transfer: error num %d", ret);
OutputBufferSize = 0;
}
offset = 36;
out_size = offset + OutputBufferSize;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
if (OutputBufferSize != 0)
data_write_UINT32(out_data + 8, URB_COMPLETION);
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 8); /** Size */
+ data_write_UINT16(out_data + 20, 8); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_INTERFACE);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1668,14 +1599,10 @@ static int urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK* callback,
return 0;
}
-static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- BYTE func_recipient,
- BYTE command,
- int transferDir)
+static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, BYTE func_recipient, BYTE command,
+ int transferDir)
{
IUDEVICE* pdev;
UINT32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status;
@@ -1690,7 +1617,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
if (pdev == NULL)
return 0;
- InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev));
+ InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev));
data_read_UINT32(data + 0, RequestId);
data_read_UINT16(data + 4, FeatureSelector);
@@ -1699,7 +1626,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
offset = 12;
out_size = 36 + OutputBufferSize;
- out_data = (BYTE *) malloc(out_size);
+ out_data = (BYTE*)malloc(out_size);
memset(out_data, 0, out_size);
buffer = out_data + 36;
@@ -1708,7 +1635,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
switch (transferDir)
{
case USBD_TRANSFER_DIRECTION_OUT:
- WLog_ERR(TAG, "Function urb_control_feature_request: OUT Unchecked");
+ WLog_ERR(TAG, "Function urb_control_feature_request: OUT Unchecked");
memcpy(buffer, data + offset, OutputBufferSize);
bmRequestType |= 0x00;
break;
@@ -1726,46 +1653,40 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
bmRequest = 0x01; /* REQUEST_CLEAR_FEATURE */
break;
default:
- WLog_ERR(TAG, "urb_control_feature_request: Error Command 0x%02"PRIx8"", command);
+ WLog_ERR(TAG, "urb_control_feature_request: Error Command 0x%02" PRIx8 "", command);
zfree(out_data);
return -1;
}
- ret = pdev->control_transfer(
- pdev, RequestId, 0, 0, bmRequestType, bmRequest,
- FeatureSelector,
- Index,
- &usbd_status,
- &OutputBufferSize,
- buffer,
- 1000);
+ ret = pdev->control_transfer(pdev, RequestId, 0, 0, bmRequestType, bmRequest, FeatureSelector,
+ Index, &usbd_status, &OutputBufferSize, buffer, 1000);
- if (ret < 0){
+ if (ret < 0)
+ {
WLog_DBG(TAG, "feature control transfer: error num %d", ret);
OutputBufferSize = 0;
}
offset = 36;
out_size = offset + OutputBufferSize;
- data_write_UINT32(out_data + 0, InterfaceId); /** interface */
- data_write_UINT32(out_data + 4, MessageId); /** message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /** interface */
+ data_write_UINT32(out_data + 4, MessageId); /** message id */
if (OutputBufferSize != 0)
data_write_UINT32(out_data + 8, URB_COMPLETION);
else
data_write_UINT32(out_data + 8, URB_COMPLETION_NO_DATA);
- data_write_UINT32(out_data + 12, RequestId); /** RequestId */
- data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
+ data_write_UINT32(out_data + 12, RequestId); /** RequestId */
+ data_write_UINT32(out_data + 16, 8); /** CbTsUrbResult */
/** TsUrbResult TS_URB_RESULT_HEADER */
- data_write_UINT16(out_data + 20, 8); /** Size */
+ data_write_UINT16(out_data + 20, 8); /** Size */
/** Padding, MUST be ignored upon receipt */
data_write_UINT16(out_data + 22, URB_FUNCTION_GET_INTERFACE);
- data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
-
- data_write_UINT32(out_data + 28, 0); /** HResult */
- data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
+ data_write_UINT32(out_data + 24, usbd_status); /** UsbdStatus */
+ data_write_UINT32(out_data + 28, 0); /** HResult */
+ data_write_UINT32(out_data + 32, OutputBufferSize); /** OutputBufferSize */
if (!pdev->isSigToEnd(pdev))
callback->channel->Write(callback->channel, out_size, out_data, NULL);
@@ -1773,532 +1694,308 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
return 0;
}
-static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE * data,
- UINT32 data_sizem,
- UINT32 MessageId,
- IUDEVMAN * udevman,
- UINT32 UsbDevice,
- int transferDir)
+static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK* callback, BYTE* data,
+ UINT32 data_sizem, UINT32 MessageId, IUDEVMAN* udevman,
+ UINT32 UsbDevice, int transferDir)
{
- IUDEVICE * pdev;
- UINT32 CbTsUrb;
- UINT16 Size;
- UINT16 URB_Function;
- UINT32 OutputBufferSize;
- int error = 0;
+ IUDEVICE* pdev;
+ UINT32 CbTsUrb;
+ UINT16 Size;
+ UINT16 URB_Function;
+ UINT32 OutputBufferSize;
+ int error = 0;
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL)
return 0;
- data_read_UINT32(data + 0, CbTsUrb); /** CbTsUrb */
- data_read_UINT16(data + 4, Size); /** size */
+ data_read_UINT32(data + 0, CbTsUrb); /** CbTsUrb */
+ data_read_UINT16(data + 4, Size); /** size */
data_read_UINT16(data + 6, URB_Function);
data_read_UINT32(data + 4 + CbTsUrb, OutputBufferSize);
switch (URB_Function)
{
- case URB_FUNCTION_SELECT_CONFIGURATION: /** 0x0000 */
+ case URB_FUNCTION_SELECT_CONFIGURATION: /** 0x0000 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SELECT_CONFIGURATION");
- error = urb_select_configuration(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_select_configuration(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir);
break;
- case URB_FUNCTION_SELECT_INTERFACE: /** 0x0001 */
+ case URB_FUNCTION_SELECT_INTERFACE: /** 0x0001 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SELECT_INTERFACE");
- error = urb_select_interface(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_select_interface(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir);
break;
- case URB_FUNCTION_ABORT_PIPE: /** 0x0002 */
+ case URB_FUNCTION_ABORT_PIPE: /** 0x0002 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_ABORT_PIPE");
- error = urb_pipe_request(
- callback, data + 8, data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- PIPE_CANCEL);
+ error = urb_pipe_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, PIPE_CANCEL);
break;
- case URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: /** 0x0003 */
+ case URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: /** 0x0003 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL");
- error = -1; /** This URB function is obsolete in Windows 2000
- * and later operating systems
- * and is not supported by Microsoft. */
+ error = -1; /** This URB function is obsolete in Windows 2000
+ * and later operating systems
+ * and is not supported by Microsoft. */
break;
- case URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: /** 0x0004 */
+ case URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: /** 0x0004 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL");
- error = -1; /** This URB function is obsolete in Windows 2000
- * and later operating systems
- * and is not supported by Microsoft. */
+ error = -1; /** This URB function is obsolete in Windows 2000
+ * and later operating systems
+ * and is not supported by Microsoft. */
break;
- case URB_FUNCTION_GET_FRAME_LENGTH: /** 0x0005 */
+ case URB_FUNCTION_GET_FRAME_LENGTH: /** 0x0005 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_FRAME_LENGTH");
- error = -1; /** This URB function is obsolete in Windows 2000
- * and later operating systems
- * and is not supported by Microsoft. */
+ error = -1; /** This URB function is obsolete in Windows 2000
+ * and later operating systems
+ * and is not supported by Microsoft. */
break;
- case URB_FUNCTION_SET_FRAME_LENGTH: /** 0x0006 */
+ case URB_FUNCTION_SET_FRAME_LENGTH: /** 0x0006 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FRAME_LENGTH");
- error = -1; /** This URB function is obsolete in Windows 2000
- * and later operating systems
- * and is not supported by Microsoft. */
+ error = -1; /** This URB function is obsolete in Windows 2000
+ * and later operating systems
+ * and is not supported by Microsoft. */
break;
- case URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: /** 0x0007 */
+ case URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: /** 0x0007 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_CURRENT_FRAME_NUMBER");
- error = urb_get_current_frame_number(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_get_current_frame_number(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, transferDir);
break;
- case URB_FUNCTION_CONTROL_TRANSFER: /** 0x0008 */
+ case URB_FUNCTION_CONTROL_TRANSFER: /** 0x0008 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CONTROL_TRANSFER");
- error = urb_control_transfer(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- URB_CONTROL_TRANSFER_NONEXTERNAL);
+ error = urb_control_transfer(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, URB_CONTROL_TRANSFER_NONEXTERNAL);
break;
- case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /** 0x0009 */
+ case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /** 0x0009 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER");
- error = urb_bulk_or_interrupt_transfer(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_bulk_or_interrupt_transfer(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, transferDir);
break;
- case URB_FUNCTION_ISOCH_TRANSFER: /** 0x000A */
+ case URB_FUNCTION_ISOCH_TRANSFER: /** 0x000A */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_ISOCH_TRANSFER");
- error = urb_isoch_transfer(
- callback, data + 8, data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_isoch_transfer(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir);
break;
- case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: /** 0x000B */
+ case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: /** 0x000B */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x00,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x00, transferDir);
break;
- case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: /** 0x000C */
+ case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: /** 0x000C */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x00,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x00, transferDir);
break;
- case URB_FUNCTION_SET_FEATURE_TO_DEVICE: /** 0x000D */
+ case URB_FUNCTION_SET_FEATURE_TO_DEVICE: /** 0x000D */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_DEVICE");
- error = urb_control_feature_request(callback,
- data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x00,
- URB_SET_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x00, URB_SET_FEATURE, transferDir);
break;
- case URB_FUNCTION_SET_FEATURE_TO_INTERFACE: /** 0x000E */
+ case URB_FUNCTION_SET_FEATURE_TO_INTERFACE: /** 0x000E */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_INTERFACE");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x01,
- URB_SET_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x01, URB_SET_FEATURE, transferDir);
break;
- case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: /** 0x000F */
+ case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: /** 0x000F */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_ENDPOINT");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x02,
- URB_SET_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x02, URB_SET_FEATURE, transferDir);
break;
- case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: /** 0x0010 */
+ case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: /** 0x0010 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x00,
- URB_CLEAR_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x00, URB_CLEAR_FEATURE, transferDir);
break;
- case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: /** 0x0011 */
+ case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: /** 0x0011 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x01,
- URB_CLEAR_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x01, URB_CLEAR_FEATURE, transferDir);
break;
- case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: /** 0x0012 */
+ case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: /** 0x0012 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x02,
- URB_CLEAR_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x02, URB_CLEAR_FEATURE, transferDir);
break;
- case URB_FUNCTION_GET_STATUS_FROM_DEVICE: /** 0x0013 */
+ case URB_FUNCTION_GET_STATUS_FROM_DEVICE: /** 0x0013 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_DEVICE");
- error = urb_control_get_status_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x00,
- transferDir);
+ error = urb_control_get_status_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x00, transferDir);
break;
- case URB_FUNCTION_GET_STATUS_FROM_INTERFACE: /** 0x0014 */
+ case URB_FUNCTION_GET_STATUS_FROM_INTERFACE: /** 0x0014 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_INTERFACE");
- error = urb_control_get_status_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x01,
- transferDir);
+ error = urb_control_get_status_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x01, transferDir);
break;
- case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: /** 0x0015 */
+ case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: /** 0x0015 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_ENDPOINT");
- error = urb_control_get_status_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x02,
- transferDir);
+ error = urb_control_get_status_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x02, transferDir);
break;
- case URB_FUNCTION_RESERVED_0X0016: /** 0x0016 */
+ case URB_FUNCTION_RESERVED_0X0016: /** 0x0016 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVED_0X0016");
error = -1;
break;
- case URB_FUNCTION_VENDOR_DEVICE: /** 0x0017 */
+ case URB_FUNCTION_VENDOR_DEVICE: /** 0x0017 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_DEVICE");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x02 << 5), /* vendor type */
- 0x00,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x02 << 5), /* vendor type */
+ 0x00, transferDir);
break;
- case URB_FUNCTION_VENDOR_INTERFACE: /** 0x0018 */
+ case URB_FUNCTION_VENDOR_INTERFACE: /** 0x0018 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_INTERFACE");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x02 << 5), /* vendor type */
- 0x01,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x02 << 5), /* vendor type */
+ 0x01, transferDir);
break;
- case URB_FUNCTION_VENDOR_ENDPOINT: /** 0x0019 */
+ case URB_FUNCTION_VENDOR_ENDPOINT: /** 0x0019 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_ENDPOINT");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x02 << 5), /* vendor type */
- 0x02,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x02 << 5), /* vendor type */
+ 0x02, transferDir);
break;
- case URB_FUNCTION_CLASS_DEVICE: /** 0x001A */
+ case URB_FUNCTION_CLASS_DEVICE: /** 0x001A */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_DEVICE");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x01 << 5), /* class type */
- 0x00,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x01 << 5), /* class type */
+ 0x00, transferDir);
break;
- case URB_FUNCTION_CLASS_INTERFACE: /** 0x001B */
+ case URB_FUNCTION_CLASS_INTERFACE: /** 0x001B */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_INTERFACE");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x01 << 5), /* class type */
- 0x01,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x01 << 5), /* class type */
+ 0x01, transferDir);
break;
- case URB_FUNCTION_CLASS_ENDPOINT: /** 0x001C */
+ case URB_FUNCTION_CLASS_ENDPOINT: /** 0x001C */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_ENDPOINT");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x01 << 5), /* class type */
- 0x02,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x01 << 5), /* class type */
+ 0x02, transferDir);
break;
- case URB_FUNCTION_RESERVE_0X001D: /** 0x001D */
+ case URB_FUNCTION_RESERVE_0X001D: /** 0x001D */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X001D");
error = -1;
break;
case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: /** 0x001E */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL");
- error = urb_pipe_request(
- callback, data + 8, data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- PIPE_RESET);
+ error = urb_pipe_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, PIPE_RESET);
break;
- case URB_FUNCTION_CLASS_OTHER: /** 0x001F */
+ case URB_FUNCTION_CLASS_OTHER: /** 0x001F */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLASS_OTHER");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x01 << 5), /* class type */
- 0x03,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x01 << 5), /* class type */
+ 0x03, transferDir);
break;
- case URB_FUNCTION_VENDOR_OTHER: /** 0x0020 */
+ case URB_FUNCTION_VENDOR_OTHER: /** 0x0020 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_VENDOR_OTHER");
- error = urb_control_vendor_or_class_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- (0x02 << 5), /* vendor type */
- 0x03,
- transferDir);
+ error = urb_control_vendor_or_class_request(callback, data + 8, data_sizem - 8,
+ MessageId, udevman, UsbDevice,
+ (0x02 << 5), /* vendor type */
+ 0x03, transferDir);
break;
- case URB_FUNCTION_GET_STATUS_FROM_OTHER: /** 0x0021 */
+ case URB_FUNCTION_GET_STATUS_FROM_OTHER: /** 0x0021 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_STATUS_FROM_OTHER");
- error = urb_control_get_status_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x03,
- transferDir);
+ error = urb_control_get_status_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x03, transferDir);
break;
- case URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: /** 0x0022 */
+ case URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: /** 0x0022 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_OTHER");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x03,
- URB_CLEAR_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x03, URB_CLEAR_FEATURE, transferDir);
break;
- case URB_FUNCTION_SET_FEATURE_TO_OTHER: /** 0x0023 */
+ case URB_FUNCTION_SET_FEATURE_TO_OTHER: /** 0x0023 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_FEATURE_TO_OTHER");
- error = urb_control_feature_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x03,
- URB_SET_FEATURE,
- transferDir);
+ error =
+ urb_control_feature_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, 0x03, URB_SET_FEATURE, transferDir);
break;
- case URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: /** 0x0024 */
+ case URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: /** 0x0024 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x02,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x02, transferDir);
break;
- case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: /** 0x0025 */
+ case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: /** 0x0025 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x02,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x02, transferDir);
break;
- case URB_FUNCTION_GET_CONFIGURATION: /** 0x0026 */
+ case URB_FUNCTION_GET_CONFIGURATION: /** 0x0026 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_CONFIGURATION");
- error = urb_control_get_configuration_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_control_get_configuration_request(
+ callback, data + 8, data_sizem - 8, MessageId, udevman, UsbDevice, transferDir);
break;
- case URB_FUNCTION_GET_INTERFACE: /** 0x0027 */
+ case URB_FUNCTION_GET_INTERFACE: /** 0x0027 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_INTERFACE");
- error = urb_control_get_interface_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_control_get_interface_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, transferDir);
break;
- case URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: /** 0x0028 */
+ case URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: /** 0x0028 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x01,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x01, transferDir);
break;
- case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: /** 0x0029 */
+ case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: /** 0x0029 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE");
- error = urb_control_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- 0x01,
- transferDir);
+ error = urb_control_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, 0x01, transferDir);
break;
- case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: /** 0x002A */
+ case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: /** 0x002A */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR");
- error = urb_os_feature_descriptor_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir);
+ error = urb_os_feature_descriptor_request(callback, data + 8, data_sizem - 8, MessageId,
+ udevman, UsbDevice, transferDir);
break;
- case URB_FUNCTION_RESERVE_0X002B: /** 0x002B */
+ case URB_FUNCTION_RESERVE_0X002B: /** 0x002B */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002B");
error = -1;
break;
- case URB_FUNCTION_RESERVE_0X002C: /** 0x002C */
+ case URB_FUNCTION_RESERVE_0X002C: /** 0x002C */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002C");
error = -1;
break;
- case URB_FUNCTION_RESERVE_0X002D: /** 0x002D */
+ case URB_FUNCTION_RESERVE_0X002D: /** 0x002D */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002D");
error = -1;
break;
- case URB_FUNCTION_RESERVE_0X002E: /** 0x002E */
+ case URB_FUNCTION_RESERVE_0X002E: /** 0x002E */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002E");
error = -1;
break;
- case URB_FUNCTION_RESERVE_0X002F: /** 0x002F */
+ case URB_FUNCTION_RESERVE_0X002F: /** 0x002F */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_RESERVE_0X002F");
error = -1;
break;
/** USB 2.0 calls start at 0x0030 */
- case URB_FUNCTION_SYNC_RESET_PIPE: /** 0x0030 */
+ case URB_FUNCTION_SYNC_RESET_PIPE: /** 0x0030 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_RESET_PIPE");
- error = urb_pipe_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- PIPE_RESET);
- error = -9; /** function not support */
+ error = urb_pipe_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, PIPE_RESET);
+ error = -9; /** function not support */
break;
- case URB_FUNCTION_SYNC_CLEAR_STALL: /** 0x0031 */
+ case URB_FUNCTION_SYNC_CLEAR_STALL: /** 0x0031 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_SYNC_CLEAR_STALL");
- error = urb_pipe_request(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- PIPE_RESET);
+ error = urb_pipe_request(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, PIPE_RESET);
error = -9;
break;
- case URB_FUNCTION_CONTROL_TRANSFER_EX: /** 0x0032 */
+ case URB_FUNCTION_CONTROL_TRANSFER_EX: /** 0x0032 */
WLog_DBG(TAG, "URB_Func: URB_FUNCTION_CONTROL_TRANSFER_EX");
- error = urb_control_transfer(
- callback, data + 8,
- data_sizem - 8,
- MessageId,
- udevman,
- UsbDevice,
- transferDir,
- URB_CONTROL_TRANSFER_EXTERNAL);
+ error = urb_control_transfer(callback, data + 8, data_sizem - 8, MessageId, udevman,
+ UsbDevice, transferDir, URB_CONTROL_TRANSFER_EXTERNAL);
break;
default:
- WLog_DBG(TAG, "URB_Func: %"PRIx16" is not found!", URB_Function);
+ WLog_DBG(TAG, "URB_Func: %" PRIx16 " is not found!", URB_Function);
break;
}
@@ -2307,15 +2004,15 @@ static int urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, B
void* urbdrc_process_udev_data_transfer(void* arg)
{
- TRANSFER_DATA* transfer_data = (TRANSFER_DATA*) arg;
- URBDRC_CHANNEL_CALLBACK * callback = transfer_data->callback;
- BYTE * pBuffer = transfer_data->pBuffer;
- UINT32 cbSize = transfer_data->cbSize;
- UINT32 UsbDevice = transfer_data->UsbDevice;
- IUDEVMAN * udevman = transfer_data->udevman;
- UINT32 MessageId;
- UINT32 FunctionId;
- IUDEVICE* pdev;
+ TRANSFER_DATA* transfer_data = (TRANSFER_DATA*)arg;
+ URBDRC_CHANNEL_CALLBACK* callback = transfer_data->callback;
+ BYTE* pBuffer = transfer_data->pBuffer;
+ UINT32 cbSize = transfer_data->cbSize;
+ UINT32 UsbDevice = transfer_data->UsbDevice;
+ IUDEVMAN* udevman = transfer_data->udevman;
+ UINT32 MessageId;
+ UINT32 FunctionId;
+ IUDEVICE* pdev;
int error = 0;
pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice);
if (pdev == NULL || pdev->isSigToEnd(pdev))
@@ -2336,91 +2033,74 @@ void* urbdrc_process_udev_data_transfer(void* arg)
switch (FunctionId)
{
case CANCEL_REQUEST:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>CANCEL_REQUEST<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_cancel_request(
- pBuffer + 8,
- cbSize - 8,
- udevman,
- UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>CANCEL_REQUEST<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_cancel_request(pBuffer + 8, cbSize - 8, udevman, UsbDevice);
break;
case REGISTER_REQUEST_CALLBACK:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>REGISTER_REQUEST_CALLBACK<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_register_request_callback(
- callback,
- pBuffer + 8,
- cbSize - 8,
- udevman,
- UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>REGISTER_REQUEST_CALLBACK<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_register_request_callback(callback, pBuffer + 8, cbSize - 8,
+ udevman, UsbDevice);
break;
case IO_CONTROL:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>IO_CONTROL<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_io_control(
- callback,
- pBuffer + 8,
- cbSize - 8,
- MessageId,
- udevman, UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>IO_CONTROL<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_io_control(callback, pBuffer + 8, cbSize - 8, MessageId, udevman,
+ UsbDevice);
break;
case INTERNAL_IO_CONTROL:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>INTERNAL_IO_CONTROL<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_internal_io_control(
- callback,
- pBuffer + 8,
- cbSize - 8,
- MessageId,
- udevman, UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>INTERNAL_IO_CONTROL<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_internal_io_control(callback, pBuffer + 8, cbSize - 8, MessageId,
+ udevman, UsbDevice);
break;
case QUERY_DEVICE_TEXT:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>QUERY_DEVICE_TEXT<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_query_device_text(
- callback,
- pBuffer + 8,
- cbSize - 8,
- MessageId,
- udevman,
- UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>QUERY_DEVICE_TEXT<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_query_device_text(callback, pBuffer + 8, cbSize - 8, MessageId,
+ udevman, UsbDevice);
break;
case TRANSFER_IN_REQUEST:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>TRANSFER_IN_REQUEST<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_transfer_request(
- callback,
- pBuffer + 8,
- cbSize - 8,
- MessageId,
- udevman,
- UsbDevice,
- USBD_TRANSFER_DIRECTION_IN);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>TRANSFER_IN_REQUEST<<0x%" PRIX32 "",
+ FunctionId);
+ error = urbdrc_process_transfer_request(callback, pBuffer + 8, cbSize - 8, MessageId,
+ udevman, UsbDevice, USBD_TRANSFER_DIRECTION_IN);
break;
case TRANSFER_OUT_REQUEST:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>TRANSFER_OUT_REQUEST<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_transfer_request(
- callback,
- pBuffer + 8,
- cbSize - 8,
- MessageId,
- udevman,
- UsbDevice,
- USBD_TRANSFER_DIRECTION_OUT);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>TRANSFER_OUT_REQUEST<<0x%" PRIX32 "",
+ FunctionId);
+ error =
+ urbdrc_process_transfer_request(callback, pBuffer + 8, cbSize - 8, MessageId,
+ udevman, UsbDevice, USBD_TRANSFER_DIRECTION_OUT);
break;
case RETRACT_DEVICE:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " >>RETRACT_DEVICE<<0x%"PRIX32"", FunctionId);
- error = urbdrc_process_retract_device_request(
- pBuffer + 8,
- cbSize - 8,
- udevman,
- UsbDevice);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " >>RETRACT_DEVICE<<0x%" PRIX32 "",
+ FunctionId);
+ error =
+ urbdrc_process_retract_device_request(pBuffer + 8, cbSize - 8, udevman, UsbDevice);
break;
default:
- WLog_DBG(TAG, "urbdrc_process_udev_data_transfer:"
- " unknown FunctionId 0x%"PRIX32"", FunctionId);
+ WLog_DBG(TAG,
+ "urbdrc_process_udev_data_transfer:"
+ " unknown FunctionId 0x%" PRIX32 "",
+ FunctionId);
error = -1;
break;
}
diff --git a/channels/urbdrc/client/data_transfer.h b/channels/urbdrc/client/data_transfer.h
index bc3d70860..5e47e2de5 100644
--- a/channels/urbdrc/client/data_transfer.h
+++ b/channels/urbdrc/client/data_transfer.h
@@ -26,10 +26,8 @@
#define DEVICE_CTX(dev) ((dev)->ctx)
#define HANDLE_CTX(handle) (DEVICE_CTX((handle)->dev))
#define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle))
-#define ITRANSFER_CTX(transfer) \
- (TRANSFER_CTX(__USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)))
+#define ITRANSFER_CTX(transfer) (TRANSFER_CTX(__USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)))
-void *urbdrc_process_udev_data_transfer(void* arg);
+void* urbdrc_process_udev_data_transfer(void* arg);
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_DATA_TRANSFER_H */
-
diff --git a/channels/urbdrc/client/isoch_queue.c b/channels/urbdrc/client/isoch_queue.c
index 4e051f9e0..eff5fbeab 100644
--- a/channels/urbdrc/client/isoch_queue.c
+++ b/channels/urbdrc/client/isoch_queue.c
@@ -44,17 +44,18 @@ static ISOCH_CALLBACK_DATA* isoch_queue_get_next(ISOCH_CALLBACK_QUEUE* queue)
return isoch;
}
-static ISOCH_CALLBACK_DATA* isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void* callback, void* dev)
+static ISOCH_CALLBACK_DATA* isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void* callback,
+ void* dev)
{
ISOCH_CALLBACK_DATA* isoch;
-
- isoch = (ISOCH_CALLBACK_DATA*) calloc(1, sizeof(ISOCH_CALLBACK_DATA));
+
+ isoch = (ISOCH_CALLBACK_DATA*)calloc(1, sizeof(ISOCH_CALLBACK_DATA));
if (!isoch)
return NULL;
-
+
isoch->device = dev;
isoch->callback = callback;
-
+
pthread_mutex_lock(&queue->isoch_loading);
if (queue->head == NULL)
@@ -80,7 +81,7 @@ static ISOCH_CALLBACK_DATA* isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queu
static int isoch_queue_unregister_data(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch)
{
ISOCH_CALLBACK_DATA* p;
-
+
queue->rewind(queue);
while (queue->has_next(queue))
@@ -157,20 +158,20 @@ void isoch_queue_free(ISOCH_CALLBACK_QUEUE* queue)
pthread_mutex_destroy(&queue->isoch_loading);
/* free queue */
- if (queue)
+ if (queue)
zfree(queue);
}
ISOCH_CALLBACK_QUEUE* isoch_queue_new()
{
ISOCH_CALLBACK_QUEUE* queue;
-
- queue = (ISOCH_CALLBACK_QUEUE*) calloc(1, sizeof(ISOCH_CALLBACK_QUEUE));
+
+ queue = (ISOCH_CALLBACK_QUEUE*)calloc(1, sizeof(ISOCH_CALLBACK_QUEUE));
if (!queue)
return NULL;
-
+
pthread_mutex_init(&queue->isoch_loading, NULL);
-
+
/* load service */
queue->get_next = isoch_queue_get_next;
queue->has_next = isoch_queue_has_next;
@@ -178,6 +179,6 @@ ISOCH_CALLBACK_QUEUE* isoch_queue_new()
queue->register_data = isoch_queue_register_data;
queue->unregister_data = isoch_queue_unregister_data;
queue->free = isoch_queue_free;
-
+
return queue;
}
diff --git a/channels/urbdrc/client/isoch_queue.h b/channels/urbdrc/client/isoch_queue.h
index 90ab1a162..a58078816 100644
--- a/channels/urbdrc/client/isoch_queue.h
+++ b/channels/urbdrc/client/isoch_queue.h
@@ -23,47 +23,38 @@
#include "urbdrc_types.h"
-
typedef struct _ISOCH_CALLBACK_DATA ISOCH_CALLBACK_DATA;
typedef struct _ISOCH_CALLBACK_QUEUE ISOCH_CALLBACK_QUEUE;
-
struct _ISOCH_CALLBACK_DATA
{
- void * inode;
- void * prev;
- void * next;
- void * device;
- BYTE * out_data;
+ void* inode;
+ void* prev;
+ void* next;
+ void* device;
+ BYTE* out_data;
UINT32 out_size;
- void * callback;
+ void* callback;
};
-
-
struct _ISOCH_CALLBACK_QUEUE
{
int isoch_num;
ISOCH_CALLBACK_DATA* curr; /* current point */
ISOCH_CALLBACK_DATA* head; /* head point in linked list */
ISOCH_CALLBACK_DATA* tail; /* tail point in linked list */
-
- pthread_mutex_t isoch_loading;
-
- /* Isochronous queue service */
- void (*rewind) (ISOCH_CALLBACK_QUEUE * queue);
- BOOL (*has_next) (ISOCH_CALLBACK_QUEUE * queue);
- int (*unregister_data) (ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch);
- ISOCH_CALLBACK_DATA *(*get_next) (ISOCH_CALLBACK_QUEUE * queue);
- ISOCH_CALLBACK_DATA *(*register_data) (ISOCH_CALLBACK_QUEUE* queue,
- void * callback, void * dev);
- void (*free) (ISOCH_CALLBACK_QUEUE * queue);
-
-};
+ pthread_mutex_t isoch_loading;
+
+ /* Isochronous queue service */
+ void (*rewind)(ISOCH_CALLBACK_QUEUE* queue);
+ BOOL (*has_next)(ISOCH_CALLBACK_QUEUE* queue);
+ int (*unregister_data)(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch);
+ ISOCH_CALLBACK_DATA* (*get_next)(ISOCH_CALLBACK_QUEUE* queue);
+ ISOCH_CALLBACK_DATA* (*register_data)(ISOCH_CALLBACK_QUEUE* queue, void* callback, void* dev);
+ void (*free)(ISOCH_CALLBACK_QUEUE* queue);
+};
ISOCH_CALLBACK_QUEUE* isoch_queue_new(void);
-
-
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_ISOCH_QUEUE_H */
diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c
index 0b1ab0721..084108a92 100644
--- a/channels/urbdrc/client/libusb/libusb_udevice.c
+++ b/channels/urbdrc/client/libusb/libusb_udevice.c
@@ -31,35 +31,34 @@
#include "libusb_udevice.h"
-#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \
- static _type udev_get_##_arg (IUDEVICE* idev) \
- { \
- UDEVICE* pdev = (UDEVICE*) idev; \
- return pdev->_arg; \
- } \
- static void udev_set_##_arg (IUDEVICE* idev, _type _t) \
- { \
- UDEVICE* pdev = (UDEVICE*) idev; \
- pdev->_arg = _t; \
+#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \
+ static _type udev_get_##_arg(IUDEVICE* idev) \
+ { \
+ UDEVICE* pdev = (UDEVICE*)idev; \
+ return pdev->_arg; \
+ } \
+ static void udev_set_##_arg(IUDEVICE* idev, _type _t) \
+ { \
+ UDEVICE* pdev = (UDEVICE*)idev; \
+ pdev->_arg = _t; \
}
-#define BASIC_POINT_FUNC_DEFINED(_arg, _type) \
- static _type udev_get_p_##_arg (IUDEVICE* idev) \
- { \
- UDEVICE* pdev = (UDEVICE*) idev; \
- return pdev->_arg; \
- } \
- static void udev_set_p_##_arg (IUDEVICE* idev, _type _t) \
- { \
- UDEVICE* pdev = (UDEVICE*) idev; \
- pdev->_arg = _t; \
+#define BASIC_POINT_FUNC_DEFINED(_arg, _type) \
+ static _type udev_get_p_##_arg(IUDEVICE* idev) \
+ { \
+ UDEVICE* pdev = (UDEVICE*)idev; \
+ return pdev->_arg; \
+ } \
+ static void udev_set_p_##_arg(IUDEVICE* idev, _type _t) \
+ { \
+ UDEVICE* pdev = (UDEVICE*)idev; \
+ pdev->_arg = _t; \
}
#define BASIC_STATE_FUNC_REGISTER(_arg, _dev) \
_dev->iface.get_##_arg = udev_get_##_arg; \
_dev->iface.set_##_arg = udev_set_##_arg
-
typedef struct _ISO_USER_DATA ISO_USER_DATA;
struct _ISO_USER_DATA
@@ -167,7 +166,7 @@ already_done:
static void func_iso_callback(struct libusb_transfer* transfer)
{
- ISO_USER_DATA* iso_user_data = (ISO_USER_DATA*) transfer->user_data;
+ ISO_USER_DATA* iso_user_data = (ISO_USER_DATA*)transfer->user_data;
BYTE* data = iso_user_data->IsoPacket;
int* completed = &iso_user_data->completed;
UINT32 offset = 0;
@@ -186,8 +185,7 @@ static void func_iso_callback(struct libusb_transfer* transfer)
act_len = transfer->iso_packet_desc[i].actual_length;
data_write_UINT32(data + offset, index);
data_write_UINT32(data + offset + 4, act_len);
- data_write_UINT32(data + offset + 8,
- transfer->iso_packet_desc[i].status);
+ data_write_UINT32(data + offset + 8, transfer->iso_packet_desc[i].status);
offset += 12;
if (transfer->iso_packet_desc[i].status == USBD_STATUS_SUCCESS)
@@ -203,14 +201,14 @@ static void func_iso_callback(struct libusb_transfer* transfer)
}
else
{
- //WLog_ERR(TAG, "actual length %"PRIu32"", act_len);
- //exit(EXIT_FAILURE);
+ // WLog_ERR(TAG, "actual length %"PRIu32"", act_len);
+ // exit(EXIT_FAILURE);
}
}
else
{
iso_user_data->error_count++;
- //print_transfer_status(transfer->iso_packet_desc[i].status);
+ // print_transfer_status(transfer->iso_packet_desc[i].status);
}
}
@@ -225,18 +223,19 @@ static void func_iso_callback(struct libusb_transfer* transfer)
}
else
{
- //print_status(transfer->status);
+ // print_status(transfer->status);
iso_user_data->iso_status = -1;
}
}
static const LIBUSB_ENDPOINT_DESCEIPTOR* func_get_ep_desc(LIBUSB_CONFIG_DESCRIPTOR* LibusbConfig,
- MSUSB_CONFIG_DESCRIPTOR* MsConfig, UINT32 EndpointAddress)
+ MSUSB_CONFIG_DESCRIPTOR* MsConfig,
+ UINT32 EndpointAddress)
{
BYTE alt;
UINT32 inum, pnum;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
- const LIBUSB_INTERFACE* interface;
+ const LIBUSB_INTERFACE* interface;
const LIBUSB_ENDPOINT_DESCEIPTOR* endpoint;
MsInterfaces = MsConfig->MsInterfaces;
interface = LibusbConfig->interface;
@@ -357,7 +356,7 @@ static void func_iso_data_init(ISO_USER_DATA* iso_user_data, UINT32 numPacket, U
}
static int func_config_release_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle,
- UINT32 NumInterfaces)
+ UINT32 NumInterfaces)
{
UINT32 i;
int ret;
@@ -368,7 +367,7 @@ static int func_config_release_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle
if (ret < 0)
{
- WLog_ERR(TAG, "config_release_all_interface: error num %d", ret);
+ WLog_ERR(TAG, "config_release_all_interface: error num %d", ret);
return -1;
}
}
@@ -386,7 +385,7 @@ static int func_claim_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle, int Num
if (ret < 0)
{
- WLog_ERR(TAG, "claim_all_interface: error num %d", ret);
+ WLog_ERR(TAG, "claim_all_interface: error num %d", ret);
return -1;
}
}
@@ -397,65 +396,65 @@ static int func_claim_all_interface(LIBUSB_DEVICE_HANDLE* libusb_handle, int Num
/*
static void* print_transfer_status(enum libusb_transfer_status status)
{
- switch (status)
- {
- case LIBUSB_TRANSFER_COMPLETED:
- //WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_COMPLETED");
- break;
- case LIBUSB_TRANSFER_ERROR:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_ERROR");
- break;
- case LIBUSB_TRANSFER_TIMED_OUT:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_TIMED_OUT");
- break;
- case LIBUSB_TRANSFER_CANCELLED:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_CANCELLED");
- break;
- case LIBUSB_TRANSFER_STALL:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_STALL");
- break;
- case LIBUSB_TRANSFER_NO_DEVICE:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_NO_DEVICE");
- break;
- case LIBUSB_TRANSFER_OVERFLOW:
- WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_OVERFLOW");
- break;
- default:
- WLog_ERR(TAG, "Transfer Status: Get unknow error num %d (0x%x)",
- status, status);
- }
- return 0;
+ switch (status)
+ {
+ case LIBUSB_TRANSFER_COMPLETED:
+ //WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_COMPLETED");
+ break;
+ case LIBUSB_TRANSFER_ERROR:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_ERROR");
+ break;
+ case LIBUSB_TRANSFER_TIMED_OUT:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_TIMED_OUT");
+ break;
+ case LIBUSB_TRANSFER_CANCELLED:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_CANCELLED");
+ break;
+ case LIBUSB_TRANSFER_STALL:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_STALL");
+ break;
+ case LIBUSB_TRANSFER_NO_DEVICE:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_NO_DEVICE");
+ break;
+ case LIBUSB_TRANSFER_OVERFLOW:
+ WLog_ERR(TAG, "Transfer Status: LIBUSB_TRANSFER_OVERFLOW");
+ break;
+ default:
+ WLog_ERR(TAG, "Transfer Status: Get unknow error num %d (0x%x)",
+ status, status);
+ }
+ return 0;
}
static void print_status(enum libusb_transfer_status status)
{
- switch (status)
- {
- case LIBUSB_TRANSFER_COMPLETED:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_COMPLETED");
- break;
- case LIBUSB_TRANSFER_ERROR:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_ERROR");
- break;
- case LIBUSB_TRANSFER_TIMED_OUT:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_TIMED_OUT");
- break;
- case LIBUSB_TRANSFER_CANCELLED:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_CANCELLED");
- break;
- case LIBUSB_TRANSFER_STALL:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_STALL");
- break;
- case LIBUSB_TRANSFER_NO_DEVICE:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_NO_DEVICE");
- break;
- case LIBUSB_TRANSFER_OVERFLOW:
- WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_OVERFLOW");
- break;
- default:
- WLog_ERR(TAG, "Transfer status: unknow status %d(0x%x)", status, status);
- break;
- }
+ switch (status)
+ {
+ case LIBUSB_TRANSFER_COMPLETED:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_COMPLETED");
+ break;
+ case LIBUSB_TRANSFER_ERROR:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_ERROR");
+ break;
+ case LIBUSB_TRANSFER_TIMED_OUT:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_TIMED_OUT");
+ break;
+ case LIBUSB_TRANSFER_CANCELLED:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_CANCELLED");
+ break;
+ case LIBUSB_TRANSFER_STALL:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_STALL");
+ break;
+ case LIBUSB_TRANSFER_NO_DEVICE:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_NO_DEVICE");
+ break;
+ case LIBUSB_TRANSFER_OVERFLOW:
+ WLog_ERR(TAG, "Transfer status: LIBUSB_TRANSFER_OVERFLOW");
+ break;
+ default:
+ WLog_ERR(TAG, "Transfer status: unknow status %d(0x%x)", status, status);
+ break;
+ }
}
*/
@@ -480,12 +479,12 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(LIBUSB_DEVICE* libusb_dev)
{
int ret;
LIBUSB_DEVICE_DESCRIPTOR* descriptor;
- descriptor = (LIBUSB_DEVICE_DESCRIPTOR*) malloc(sizeof(LIBUSB_DEVICE_DESCRIPTOR));
+ descriptor = (LIBUSB_DEVICE_DESCRIPTOR*)malloc(sizeof(LIBUSB_DEVICE_DESCRIPTOR));
ret = libusb_get_device_descriptor(libusb_dev, descriptor);
if (ret < 0)
{
- WLog_ERR(TAG, "libusb_get_device_descriptor: ERROR!!");
+ WLog_ERR(TAG, "libusb_get_device_descriptor: ERROR!!");
free(descriptor);
return NULL;
}
@@ -505,7 +504,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
/* Look for device. */
error = -1;
- for (i = 0; i < total_device; i ++)
+ for (i = 0; i < total_device; i++)
{
if ((bus_number != libusb_get_bus_number(libusb_list[i])) ||
(dev_number != libusb_get_device_address(libusb_list[i])))
@@ -534,7 +533,8 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
error = 0;
WLog_DBG(TAG, " Port: %d", pdev->port_number);
/* gen device path */
- sprintf_s(pdev->path, ARRAYSIZE(pdev->path), "ugen%"PRIu16".%"PRIu16"", bus_number, dev_number);
+ sprintf_s(pdev->path, ARRAYSIZE(pdev->path), "ugen%" PRIu16 ".%" PRIu16 "", bus_number,
+ dev_number);
WLog_DBG(TAG, " DevPath: %s", pdev->path);
break;
}
@@ -544,13 +544,14 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
{
error = -1;
- for (i = 0; i < total_device; i ++)
+ for (i = 0; i < total_device; i++)
{
if ((bus_number != libusb_get_bus_number(libusb_list[i])) ||
- (1 != libusb_get_device_address(libusb_list[i]))) /* Root hub allways first on bus. */
+ (1 !=
+ libusb_get_device_address(libusb_list[i]))) /* Root hub allways first on bus. */
continue;
- WLog_DBG(TAG, " Open hub: %"PRIu16"", bus_number);
+ WLog_DBG(TAG, " Open hub: %" PRIu16 "", bus_number);
error = libusb_open(libusb_list[i], &pdev->hub_handle);
if (error < 0)
@@ -619,28 +620,25 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
if (bus_number == tmp_b && dev_number == tmp_d)
{
/* get port number */
- char* p1, *p2;
- const char* sysfs_path =
- udev_device_get_property_value(dev, "DEVPATH");
- p1 = (char*) sysfs_path;
+ char *p1, *p2;
+ const char* sysfs_path = udev_device_get_property_value(dev, "DEVPATH");
+ p1 = (char*)sysfs_path;
do
{
p2 = p1 + 1;
p1 = strchr(p2, '.');
- }
- while (p1 != NULL);
+ } while (p1 != NULL);
if ((size_t)((p2 - sysfs_path) + 2U) < strlen(sysfs_path))
{
- p1 = (char*) sysfs_path;
+ p1 = (char*)sysfs_path;
do
{
p2 = p1 + 1;
p1 = strchr(p2, '-');
- }
- while (p1 != NULL);
+ } while (p1 != NULL);
}
errno = 0;
@@ -654,14 +652,13 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
}
WLog_DBG(TAG, " Port: %d", pdev->port_number);
/* get device path */
- p1 = (char*) sysfs_path;
+ p1 = (char*)sysfs_path;
do
{
p2 = p1 + 1;
p1 = strchr(p2, '/');
- }
- while (p1 != NULL);
+ } while (p1 != NULL);
sprintf_s(pdev->path, ARRAYSIZE(pdev->path), "%s", p2);
WLog_DBG(TAG, " DevPath: %s", pdev->path);
@@ -717,7 +714,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting)
{
int error = 0, diff = 1;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
MSUSB_CONFIG_DESCRIPTOR* MsConfig;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
MsConfig = pdev->MsConfig;
@@ -734,23 +731,22 @@ static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BY
if (diff)
{
- error = libusb_set_interface_alt_setting(pdev->libusb_handle,
- InterfaceNumber, AlternateSetting);
+ error = libusb_set_interface_alt_setting(pdev->libusb_handle, InterfaceNumber,
+ AlternateSetting);
if (error < 0)
{
- WLog_ERR(TAG, "Set interface altsetting get error num %d",
- error);
+ WLog_ERR(TAG, "Set interface altsetting get error num %d", error);
}
}
return error;
}
-static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* idev,
- MSUSB_CONFIG_DESCRIPTOR* MsConfig)
+static MSUSB_CONFIG_DESCRIPTOR*
+libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsConfig)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces;
MSUSB_INTERFACE_DESCRIPTOR* MsInterface;
MSUSB_PIPE_DESCRIPTOR** MsPipes;
@@ -767,8 +763,9 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
if (LibusbConfig->bNumInterfaces != MsConfig->NumInterfaces)
{
- WLog_ERR(TAG, "Select Configuration: Libusb NumberInterfaces(%"PRIu8") is different "
- "with MsConfig NumberInterfaces(%"PRIu32")",
+ WLog_ERR(TAG,
+ "Select Configuration: Libusb NumberInterfaces(%" PRIu8 ") is different "
+ "with MsConfig NumberInterfaces(%" PRIu32 ")",
LibusbConfig->bNumInterfaces, MsConfig->NumInterfaces);
}
@@ -782,11 +779,12 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber];
LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting];
LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
- t_MsPipes = (MSUSB_PIPE_DESCRIPTOR**) calloc(LibusbNumEndpoint, sizeof(MSUSB_PIPE_DESCRIPTOR*));
+ t_MsPipes =
+ (MSUSB_PIPE_DESCRIPTOR**)calloc(LibusbNumEndpoint, sizeof(MSUSB_PIPE_DESCRIPTOR*));
for (pnum = 0; pnum < LibusbNumEndpoint; pnum++)
{
- t_MsPipe = (MSUSB_PIPE_DESCRIPTOR*) malloc(sizeof(MSUSB_PIPE_DESCRIPTOR));
+ t_MsPipe = (MSUSB_PIPE_DESCRIPTOR*)malloc(sizeof(MSUSB_PIPE_DESCRIPTOR));
memset(t_MsPipe, 0, sizeof(MSUSB_PIPE_DESCRIPTOR));
if (pnum < MsInterface->NumberOfPipes && MsInterface->MsPipes)
@@ -817,14 +815,13 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
/* setup configuration */
MsOutSize = 8;
/* ConfigurationHandle: 4 bytes
- * ---------------------------------------------------------------
- * ||<<< 1 byte >>>|<<< 1 byte >>>|<<<<<<<<<< 2 byte >>>>>>>>>>>||
- * || bus_number | dev_number | bConfigurationValue ||
- * ---------------------------------------------------------------
+ * ---------------------------------------------------------------
+ * ||<<< 1 byte >>>|<<< 1 byte >>>|<<<<<<<<<< 2 byte >>>>>>>>>>>||
+ * || bus_number | dev_number | bConfigurationValue ||
+ * ---------------------------------------------------------------
* ***********************/
- MsConfig->ConfigurationHandle = MsConfig->bConfigurationValue |
- (pdev->bus_number << 24) |
- (pdev->dev_number << 16);
+ MsConfig->ConfigurationHandle =
+ MsConfig->bConfigurationValue | (pdev->bus_number << 24) | (pdev->dev_number << 16);
MsInterfaces = MsConfig->MsInterfaces;
for (inum = 0; inum < MsConfig->NumInterfaces; inum++)
@@ -840,10 +837,9 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
* || bus_number | dev_number | altsetting | interfaceNum ||
* ---------------------------------------------------------------
* ***********************/
- MsInterface->InterfaceHandle = LibusbAltsetting->bInterfaceNumber
- | (LibusbAltsetting->bAlternateSetting << 8)
- | (pdev->dev_number << 16)
- | (pdev->bus_number << 24);
+ MsInterface->InterfaceHandle = LibusbAltsetting->bInterfaceNumber |
+ (LibusbAltsetting->bAlternateSetting << 8) |
+ (pdev->dev_number << 16) | (pdev->bus_number << 24);
MsInterface->Length = 16 + (MsInterface->NumberOfPipes * 20);
MsInterface->bInterfaceClass = LibusbAltsetting->bInterfaceClass;
MsInterface->bInterfaceSubClass = LibusbAltsetting->bInterfaceSubClass;
@@ -864,9 +860,8 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
* || bus_number | dev_number | bEndpointAddress ||
* ---------------------------------------------------------------
* ***********************/
- MsPipe->PipeHandle = LibusbEndpoint->bEndpointAddress
- | (pdev->dev_number << 16)
- | (pdev->bus_number << 24);
+ MsPipe->PipeHandle = LibusbEndpoint->bEndpointAddress | (pdev->dev_number << 16) |
+ (pdev->bus_number << 24);
/* count endpoint max packet size */
int max = LibusbEndpoint->wMaxPacketSize & 0x07ff;
BYTE attr = LibusbEndpoint->bmAttributes;
@@ -899,7 +894,7 @@ static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup(IUDEVICE* id
static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfigurationValue)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
MSUSB_CONFIG_DESCRIPTOR* MsConfig = pdev->MsConfig;
LIBUSB_DEVICE_HANDLE* libusb_handle = pdev->libusb_handle;
LIBUSB_DEVICE* libusb_dev = pdev->libusb_dev;
@@ -919,7 +914,7 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio
if (ret < 0)
{
- WLog_ERR(TAG, "libusb_set_configuration: ERROR number %d!!", ret);
+ WLog_ERR(TAG, "libusb_set_configuration: ERROR number %d!!", ret);
func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces);
return -1;
}
@@ -929,7 +924,7 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio
if (ret < 0)
{
- WLog_ERR(TAG, "libusb_get_config_descriptor_by_value: ERROR number %d!!", ret);
+ WLog_ERR(TAG, "libusb_get_config_descriptor_by_value: ERROR number %d!!", ret);
func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces);
return -1;
}
@@ -940,10 +935,10 @@ static int libusb_udev_select_configuration(IUDEVICE* idev, UINT32 bConfiguratio
}
static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId,
- UINT32 EndpointAddress, UINT32* UsbdStatus, int command)
+ UINT32 EndpointAddress, UINT32* UsbdStatus, int command)
{
int error = 0;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
/*
pdev->request_queue->register_request(pdev->request_queue, RequestId, NULL, 0);
@@ -953,22 +948,17 @@ static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId,
case PIPE_CANCEL:
/** cancel bulk or int transfer */
idev->cancel_all_transfer_request(idev);
- //dummy_wait_s_obj(1);
+ // dummy_wait_s_obj(1);
/** set feature to ep (set halt)*/
- error = libusb_control_transfer(pdev->libusb_handle,
- LIBUSB_ENDPOINT_OUT | LIBUSB_RECIPIENT_ENDPOINT,
- LIBUSB_REQUEST_SET_FEATURE,
- ENDPOINT_HALT,
- EndpointAddress,
- NULL,
- 0,
- 1000);
+ error = libusb_control_transfer(
+ pdev->libusb_handle, LIBUSB_ENDPOINT_OUT | LIBUSB_RECIPIENT_ENDPOINT,
+ LIBUSB_REQUEST_SET_FEATURE, ENDPOINT_HALT, EndpointAddress, NULL, 0, 1000);
break;
case PIPE_RESET:
idev->cancel_all_transfer_request(idev);
error = libusb_clear_halt(pdev->libusb_handle, EndpointAddress);
- //func_set_usbd_status(pdev, UsbdStatus, error);
+ // func_set_usbd_status(pdev, UsbdStatus, error);
break;
default:
@@ -979,17 +969,15 @@ static int libusb_udev_control_pipe_request(IUDEVICE* idev, UINT32 RequestId,
*UsbdStatus = 0;
/*
if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId))
- WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId);
+ WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId);
*/
return error;
}
-static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType,
- UINT32 LocaleId,
- UINT32* BufferSize,
- BYTE* Buffer)
+static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType, UINT32 LocaleId,
+ UINT32* BufferSize, BYTE* Buffer)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
LIBUSB_DEVICE_DESCRIPTOR* devDescriptor = pdev->devDescriptor;
char* strDesc = "Generic Usb String";
char deviceLocation[25];
@@ -1001,11 +989,8 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType
switch (TextType)
{
case DeviceTextDescription:
- ret = libusb_get_string_descriptor(pdev->libusb_handle,
- devDescriptor->iProduct,
- LocaleId,
- Buffer,
- *BufferSize);
+ ret = libusb_get_string_descriptor(pdev->libusb_handle, devDescriptor->iProduct,
+ LocaleId, Buffer, *BufferSize);
for (i = 0; (ret > 0) && (i < (size_t)ret); i++)
{
@@ -1016,8 +1001,10 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType
if (ret <= 0 || ret < 4)
{
- WLog_DBG(TAG, "libusb_get_string_descriptor: "
- "ERROR num %d, iProduct: %"PRIu8"!", ret, devDescriptor->iProduct);
+ WLog_DBG(TAG,
+ "libusb_get_string_descriptor: "
+ "ERROR num %d, iProduct: %" PRIu8 "!",
+ ret, devDescriptor->iProduct);
memcpy(Buffer, strDesc, strlen(strDesc));
Buffer[strlen(strDesc)] = '\0';
*BufferSize = (strlen((char*)Buffer)) * 2;
@@ -1038,8 +1025,8 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType
case DeviceTextLocationInformation:
bus_number = libusb_get_bus_number(pdev->libusb_dev);
device_address = libusb_get_device_address(pdev->libusb_dev);
- sprintf_s(deviceLocation, ARRAYSIZE(deviceLocation), "Port_#%04"PRIu8".Hub_#%04"PRIu8"",
- device_address, bus_number);
+ sprintf_s(deviceLocation, ARRAYSIZE(deviceLocation),
+ "Port_#%04" PRIu8 ".Hub_#%04" PRIu8 "", device_address, bus_number);
for (i = 0; i < strlen(deviceLocation); i++)
{
@@ -1051,55 +1038,41 @@ static int libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextType
break;
default:
- WLog_DBG(TAG, "Query Text: unknown TextType %"PRIu32"", TextType);
+ WLog_DBG(TAG, "Query Text: unknown TextType %" PRIu32 "", TextType);
break;
}
return 0;
}
-
static int libusb_udev_os_feature_descriptor_request(IUDEVICE* idev, UINT32 RequestId,
- BYTE Recipient,
- BYTE InterfaceNumber,
- BYTE Ms_PageIndex,
- UINT16 Ms_featureDescIndex,
- UINT32* UsbdStatus,
- UINT32* BufferSize,
- BYTE* Buffer,
- int Timeout)
+ BYTE Recipient, BYTE InterfaceNumber,
+ BYTE Ms_PageIndex, UINT16 Ms_featureDescIndex,
+ UINT32* UsbdStatus, UINT32* BufferSize,
+ BYTE* Buffer, int Timeout)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
BYTE ms_string_desc[0x13];
int error = 0;
/*
pdev->request_queue->register_request(pdev->request_queue, RequestId, NULL, 0);
*/
memset(ms_string_desc, 0, 0x13);
- error = libusb_control_transfer(pdev->libusb_handle,
- LIBUSB_ENDPOINT_IN | Recipient,
- LIBUSB_REQUEST_GET_DESCRIPTOR,
- 0x03ee,
- 0,
- ms_string_desc,
- 0x12,
+ error = libusb_control_transfer(pdev->libusb_handle, LIBUSB_ENDPOINT_IN | Recipient,
+ LIBUSB_REQUEST_GET_DESCRIPTOR, 0x03ee, 0, ms_string_desc, 0x12,
Timeout);
- //WLog_ERR(TAG, "Get ms string: result number %d", error);
+ // WLog_ERR(TAG, "Get ms string: result number %d", error);
if (error > 0)
{
BYTE bMS_Vendorcode;
data_read_BYTE(ms_string_desc + 16, bMS_Vendorcode);
- //WLog_ERR(TAG, "bMS_Vendorcode:0x%x", bMS_Vendorcode);
+ // WLog_ERR(TAG, "bMS_Vendorcode:0x%x", bMS_Vendorcode);
/** get os descriptor */
error = libusb_control_transfer(pdev->libusb_handle,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | Recipient,
- bMS_Vendorcode,
- (InterfaceNumber << 8) | Ms_PageIndex,
- Ms_featureDescIndex,
- Buffer,
- *BufferSize,
- Timeout);
+ bMS_Vendorcode, (InterfaceNumber << 8) | Ms_PageIndex,
+ Ms_featureDescIndex, Buffer, *BufferSize, Timeout);
*BufferSize = error;
}
@@ -1110,14 +1083,14 @@ static int libusb_udev_os_feature_descriptor_request(IUDEVICE* idev, UINT32 Requ
/*
if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId))
- WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId);
+ WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%x", RequestId);
*/
return error;
}
static int libusb_udev_query_device_descriptor(IUDEVICE* idev, int offset)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
switch (offset)
{
@@ -1173,7 +1146,7 @@ static int libusb_udev_query_device_descriptor(IUDEVICE* idev, int offset)
static void libusb_udev_detach_kernel_driver(IUDEVICE* idev)
{
int i, err = 0;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
if ((pdev->status & URBDRC_DEVICE_DETACH_KERNEL) == 0)
{
@@ -1196,7 +1169,7 @@ static void libusb_udev_detach_kernel_driver(IUDEVICE* idev)
static void libusb_udev_attach_kernel_driver(IUDEVICE* idev)
{
int i, err = 0;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
for (i = 0; i < pdev->LibusbConfig->bNumInterfaces && err != LIBUSB_ERROR_NO_DEVICE; i++)
{
@@ -1217,62 +1190,62 @@ static void libusb_udev_attach_kernel_driver(IUDEVICE* idev)
static int libusb_udev_is_composite_device(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return pdev->isCompositeDevice;
}
static int libusb_udev_is_signal_end(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return (pdev->status & URBDRC_DEVICE_SIGNAL_END) ? 1 : 0;
}
static int libusb_udev_is_exist(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return (pdev->status & URBDRC_DEVICE_NOT_FOUND) ? 0 : 1;
}
static int libusb_udev_is_channel_closed(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return (pdev->status & URBDRC_DEVICE_CHANNEL_CLOSED) ? 1 : 0;
}
static int libusb_udev_is_already_send(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return (pdev->status & URBDRC_DEVICE_ALREADY_SEND) ? 1 : 0;
}
static void libusb_udev_signal_end(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
pdev->status |= URBDRC_DEVICE_SIGNAL_END;
}
static void libusb_udev_channel_closed(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
pdev->status |= URBDRC_DEVICE_CHANNEL_CLOSED;
}
static void libusb_udev_set_already_send(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
pdev->status |= URBDRC_DEVICE_ALREADY_SEND;
}
static char* libusb_udev_get_path(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
return pdev->path;
}
static int libusb_udev_wait_action_completion(IUDEVICE* idev)
{
int error, sval;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
while (1)
{
@@ -1288,13 +1261,13 @@ static int libusb_udev_wait_action_completion(IUDEVICE* idev)
static void libusb_udev_push_action(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
sem_post(&pdev->sem_id);
}
static void libusb_udev_complete_action(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
sem_trywait(&pdev->sem_id);
}
@@ -1302,7 +1275,7 @@ static int libusb_udev_wait_for_detach(IUDEVICE* idev)
{
int error = 0;
int times = 0;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
while (times < 25)
{
@@ -1321,31 +1294,29 @@ static int libusb_udev_wait_for_detach(IUDEVICE* idev)
static void libusb_udev_lock_fifo_isoch(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
pthread_mutex_lock(&pdev->mutex_isoch);
}
-static void libusb_udev_unlock_fifo_isoch(IUDEVICE* idev)
+static void libusb_udev_unlock_fifo_isoch(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
pthread_mutex_unlock(&pdev->mutex_isoch);
}
static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStatus,
- UINT32* BufferSize, BYTE* Buffer)
+ UINT32* BufferSize, BYTE* Buffer)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
int success = 0, ret;
WLog_DBG(TAG, "...");
if (pdev->hub_handle != NULL)
{
- ret = idev->control_transfer(idev, 0xffff, 0, 0,
- LIBUSB_ENDPOINT_IN
- | LIBUSB_REQUEST_TYPE_CLASS
- | LIBUSB_RECIPIENT_OTHER,
- LIBUSB_REQUEST_GET_STATUS,
- 0, pdev->port_number, UsbdStatus, BufferSize, Buffer, 1000);
+ ret = idev->control_transfer(
+ idev, 0xffff, 0, 0,
+ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_OTHER,
+ LIBUSB_REQUEST_GET_STATUS, 0, pdev->port_number, UsbdStatus, BufferSize, Buffer, 1000);
if (ret < 0)
{
@@ -1354,7 +1325,7 @@ static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStat
}
else
{
- WLog_DBG(TAG, "PORT STATUS:0x%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"",
+ WLog_DBG(TAG, "PORT STATUS:0x%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "",
Buffer[3], Buffer[2], Buffer[1], Buffer[0]);
success = 1;
}
@@ -1365,7 +1336,7 @@ static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStat
static int libusb_udev_request_queue_is_none(IUDEVICE* idev)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
if (pdev->request_queue->request_num == 0)
return 1;
@@ -1375,11 +1346,12 @@ static int libusb_udev_request_queue_is_none(IUDEVICE* idev)
static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
UINT32 TransferFlags, int NoAck, UINT32* ErrorCount,
- UINT32* UrbdStatus, UINT32* StartFrame, UINT32 NumberOfPackets,
- BYTE* IsoPacket, UINT32* BufferSize, BYTE* Buffer, int Timeout)
+ UINT32* UrbdStatus, UINT32* StartFrame,
+ UINT32 NumberOfPackets, BYTE* IsoPacket, UINT32* BufferSize,
+ BYTE* Buffer, int Timeout)
{
UINT32 iso_packet_size;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
ISO_USER_DATA iso_user_data;
struct libusb_transfer* iso_transfer = NULL;
int status = 0, ret = 0, submit = 0;
@@ -1388,16 +1360,15 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 E
if (iso_transfer == NULL)
{
- WLog_ERR(TAG, "Error: libusb_alloc_transfer.");
+ WLog_ERR(TAG, "Error: libusb_alloc_transfer.");
return -1;
}
/** process URB_FUNCTION_IOSCH_TRANSFER */
func_iso_data_init(&iso_user_data, NumberOfPackets, *BufferSize, NoAck, IsoPacket, Buffer);
/** fill setting */
- libusb_fill_iso_transfer(iso_transfer,
- pdev->libusb_handle, EndpointAddress, Buffer, *BufferSize,
- NumberOfPackets, func_iso_callback, &iso_user_data, 2000);
+ libusb_fill_iso_transfer(iso_transfer, pdev->libusb_handle, EndpointAddress, Buffer,
+ *BufferSize, NumberOfPackets, func_iso_callback, &iso_user_data, 2000);
libusb_set_iso_packet_lengths(iso_transfer, iso_packet_size);
if (pdev->status & (URBDRC_DEVICE_SIGNAL_END | URBDRC_DEVICE_NOT_FOUND))
@@ -1464,13 +1435,14 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 E
}
static int libusb_udev_control_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
- UINT32 TransferFlags, BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index,
- UINT32* UrbdStatus, UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout)
+ UINT32 TransferFlags, BYTE bmRequestType, BYTE Request,
+ UINT16 Value, UINT16 Index, UINT32* UrbdStatus,
+ UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout)
{
int status = 0;
- UDEVICE* pdev = (UDEVICE*) idev;
- status = libusb_control_transfer(pdev->libusb_handle,
- bmRequestType, Request, Value, Index, Buffer, *BufferSize, Timeout);
+ UDEVICE* pdev = (UDEVICE*)idev;
+ status = libusb_control_transfer(pdev->libusb_handle, bmRequestType, Request, Value, Index,
+ Buffer, *BufferSize, Timeout);
if (!(status < 0))
*BufferSize = status;
@@ -1480,11 +1452,12 @@ static int libusb_udev_control_transfer(IUDEVICE* idev, UINT32 RequestId, UINT32
}
static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 RequestId,
- UINT32 EndpointAddress, UINT32 TransferFlags, UINT32* UsbdStatus, UINT32* BufferSize, BYTE* Buffer,
- UINT32 Timeout)
+ UINT32 EndpointAddress, UINT32 TransferFlags,
+ UINT32* UsbdStatus, UINT32* BufferSize,
+ BYTE* Buffer, UINT32 Timeout)
{
UINT32 transfer_type;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
const LIBUSB_ENDPOINT_DESCEIPTOR* ep_desc;
struct libusb_transfer* transfer = NULL;
TRANSFER_REQUEST* request = NULL;
@@ -1496,20 +1469,21 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
if (!ep_desc)
{
- WLog_ERR(TAG, "func_get_ep_desc: endpoint 0x%"PRIx32" is not found!!", EndpointAddress);
+ WLog_ERR(TAG, "func_get_ep_desc: endpoint 0x%" PRIx32 " is not found!!", EndpointAddress);
return -1;
}
transfer_type = (ep_desc->bmAttributes) & 0x3;
- WLog_DBG(TAG, "urb_bulk_or_interrupt_transfer: ep:0x%"PRIx32" "
- "transfer_type %"PRIu32" flag:%"PRIu32" OutputBufferSize:0x%"PRIx32"",
+ WLog_DBG(TAG,
+ "urb_bulk_or_interrupt_transfer: ep:0x%" PRIx32 " "
+ "transfer_type %" PRIu32 " flag:%" PRIu32 " OutputBufferSize:0x%" PRIx32 "",
EndpointAddress, transfer_type, TransferFlags, *BufferSize);
switch (transfer_type)
{
case BULK_TRANSFER:
/** Bulk Transfer */
- //Timeout = 10000;
+ // Timeout = 10000;
break;
case INTERRUPT_TRANSFER:
@@ -1520,7 +1494,8 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
* request to wMaxPacketSize */
if (*BufferSize != (ep_desc->wMaxPacketSize))
{
- WLog_DBG(TAG, "Interrupt Transfer(%s): "
+ WLog_DBG(TAG,
+ "Interrupt Transfer(%s): "
"BufferSize is different than maxPacketsize(0x%x)",
((transferDir) ? "IN" : "OUT"), ep_desc->wMaxPacketSize);
@@ -1533,15 +1508,17 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
break;
default:
- WLog_DBG(TAG, "urb_bulk_or_interrupt_transfer:"
- " other transfer type 0x%"PRIX32"", transfer_type);
+ WLog_DBG(TAG,
+ "urb_bulk_or_interrupt_transfer:"
+ " other transfer type 0x%" PRIX32 "",
+ transfer_type);
return -1;
break;
}
- libusb_fill_bulk_transfer(transfer, pdev->libusb_handle, EndpointAddress,
- Buffer, *BufferSize, func_bulk_transfer_cb, &completed, Timeout);
- transfer->type = (unsigned char) transfer_type;
+ libusb_fill_bulk_transfer(transfer, pdev->libusb_handle, EndpointAddress, Buffer, *BufferSize,
+ func_bulk_transfer_cb, &completed, Timeout);
+ transfer->type = (unsigned char)transfer_type;
/** Bug fixed in libusb-1.0-8 later: issue of memory crash */
submit = libusb_submit_transfer(transfer);
@@ -1553,13 +1530,13 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
}
else
{
- request = pdev->request_queue->register_request(
- pdev->request_queue, RequestId, transfer, EndpointAddress);
+ request = pdev->request_queue->register_request(pdev->request_queue, RequestId, transfer,
+ EndpointAddress);
request->submit = 1;
}
if ((pdev && *UsbdStatus == 0) && (submit >= 0) &&
- (pdev->iface.isSigToEnd((IUDEVICE*) pdev) == 0))
+ (pdev->iface.isSigToEnd((IUDEVICE*)pdev) == 0))
{
while (!completed)
{
@@ -1626,12 +1603,13 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
*BufferSize = transfer->actual_length;
}
- WLog_DBG(TAG, "bulk or interrupt Transfer data size : 0x%"PRIx32"", *BufferSize);
+ WLog_DBG(TAG, "bulk or interrupt Transfer data size : 0x%" PRIx32 "", *BufferSize);
if (request)
{
if (pdev->request_queue->unregister_request(pdev->request_queue, RequestId))
- WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%"PRIx32"", RequestId);
+ WLog_ERR(TAG, "request_queue_unregister_request: not fount request 0x%" PRIx32 "",
+ RequestId);
}
libusb_free_transfer(transfer);
@@ -1641,7 +1619,7 @@ static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, UINT32 Request
static void libusb_udev_cancel_all_transfer_request(IUDEVICE* idev)
{
int status;
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
REQUEST_QUEUE* request_queue = pdev->request_queue;
TRANSFER_REQUEST* request = NULL;
pthread_mutex_lock(&request_queue->request_loading);
@@ -1707,7 +1685,7 @@ static int func_cancel_xact_request(TRANSFER_REQUEST* request)
static int libusb_udev_cancel_transfer_request(IUDEVICE* idev, UINT32 RequestId)
{
- UDEVICE* pdev = (UDEVICE*) idev;
+ UDEVICE* pdev = (UDEVICE*)idev;
REQUEST_QUEUE* request_queue = pdev->request_queue;
TRANSFER_REQUEST* request = NULL;
int status = 0, retry_times = 0;
@@ -1722,8 +1700,8 @@ cancel_retry:
if (!request)
continue;
- WLog_DBG(TAG, "CancelId:0x%"PRIx32" RequestId:0x%x endpoint 0x%x!!",
- RequestId, request->RequestId, request->endpoint);
+ WLog_DBG(TAG, "CancelId:0x%" PRIx32 " RequestId:0x%x endpoint 0x%x!!", RequestId,
+ request->RequestId, request->endpoint);
if (request->RequestId == (RequestId && retry_times <= 10))
{
@@ -1830,7 +1808,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
if (status < 0)
{
- WLog_ERR(TAG, "USB init: Error to get HUB handle!!");
+ WLog_ERR(TAG, "USB init: Error to get HUB handle!!");
pdev->hub_handle = NULL;
}
@@ -1838,7 +1816,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
if (!pdev->devDescriptor)
{
- WLog_ERR(TAG, "USB init: Error to get device descriptor!!");
+ WLog_ERR(TAG, "USB init: Error to get device descriptor!!");
zfree(pdev);
return NULL;
}
@@ -1848,7 +1826,7 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
if (status < 0)
{
- WLog_ERR(TAG, "libusb_get_descriptor: ERROR!!ret:%d", status);
+ WLog_ERR(TAG, "libusb_get_descriptor: ERROR!!ret:%d", status);
zfree(pdev);
return NULL;
}
@@ -1856,10 +1834,10 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
config_temp = pdev->LibusbConfig;
/* get the first interface and first altsetting */
interface_temp = config_temp->interface[0].altsetting[0];
- WLog_DBG(TAG, "Registered Device: Vid: 0x%04"PRIX16" Pid: 0x%04"PRIX16""
- " InterfaceClass = 0x%02"PRIX8"",
- pdev->devDescriptor->idVendor,
- pdev->devDescriptor->idProduct,
+ WLog_DBG(TAG,
+ "Registered Device: Vid: 0x%04" PRIX16 " Pid: 0x%04" PRIX16 ""
+ " InterfaceClass = 0x%02" PRIX8 "",
+ pdev->devDescriptor->idVendor, pdev->devDescriptor->idProduct,
interface_temp.bInterfaceClass);
/* Denied list */
@@ -1867,18 +1845,18 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
{
case CLASS_RESERVE:
- //case CLASS_COMMUNICATION_IF:
- //case CLASS_HID:
- //case CLASS_PHYSICAL:
+ // case CLASS_COMMUNICATION_IF:
+ // case CLASS_HID:
+ // case CLASS_PHYSICAL:
case CLASS_MASS_STORAGE:
case CLASS_HUB:
- //case CLASS_COMMUNICATION_DATA_IF:
+ // case CLASS_COMMUNICATION_DATA_IF:
case CLASS_SMART_CARD:
case CLASS_CONTENT_SECURITY:
- //case CLASS_WIRELESS_CONTROLLER:
- //case CLASS_ELSE_DEVICE:
- WLog_ERR(TAG, " Device is not supported!!");
+ // case CLASS_WIRELESS_CONTROLLER:
+ // case CLASS_ELSE_DEVICE:
+ WLog_ERR(TAG, " Device is not supported!!");
zfree(pdev);
return NULL;
@@ -1889,14 +1867,12 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
/* Check composite device */
devDescriptor = pdev->devDescriptor;
- if ((devDescriptor->bNumConfigurations == 1) &&
- (config_temp->bNumInterfaces > 1) &&
+ if ((devDescriptor->bNumConfigurations == 1) && (config_temp->bNumInterfaces > 1) &&
(devDescriptor->bDeviceClass == 0x0))
{
pdev->isCompositeDevice = 1;
}
- else if ((devDescriptor->bDeviceClass == 0xef) &&
- (devDescriptor->bDeviceSubClass == 0x02) &&
+ else if ((devDescriptor->bDeviceClass == 0xef) && (devDescriptor->bDeviceSubClass == 0x02) &&
(devDescriptor->bDeviceProtocol == 0x01))
{
pdev->isCompositeDevice = 1;
@@ -1924,12 +1900,12 @@ static IUDEVICE* udev_init(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
/* set config of windows */
pdev->MsConfig = msusb_msconfig_new();
pthread_mutex_init(&pdev->mutex_isoch, NULL);
- //deb_config_msg(pdev->libusb_dev, config_temp, devDescriptor->bNumConfigurations);
+ // deb_config_msg(pdev->libusb_dev, config_temp, devDescriptor->bNumConfigurations);
udev_load_interface(pdev);
- return (IUDEVICE*) pdev;
+ return (IUDEVICE*)pdev;
}
-int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE** * devArray)
+int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray)
{
LIBUSB_DEVICE_DESCRIPTOR* descriptor;
LIBUSB_DEVICE** libusb_list;
@@ -1938,8 +1914,8 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE** * devArray)
UINT16 dev_number;
ssize_t i, total_device;
int status, num = 0;
- WLog_INFO(TAG, "VID: 0x%04"PRIX16", PID: 0x%04"PRIX16"", idVendor, idProduct);
- array = (UDEVICE**) malloc(16 * sizeof(UDEVICE*));
+ WLog_INFO(TAG, "VID: 0x%04" PRIX16 ", PID: 0x%04" PRIX16 "", idVendor, idProduct);
+ array = (UDEVICE**)malloc(16 * sizeof(UDEVICE*));
total_device = libusb_get_device_list(NULL, &libusb_list);
for (i = 0; i < total_device; i++)
@@ -1950,7 +1926,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE** * devArray)
{
bus_number = 0;
dev_number = 0;
- array[num] = (PUDEVICE) malloc(sizeof(UDEVICE));
+ array[num] = (PUDEVICE)malloc(sizeof(UDEVICE));
array[num]->libusb_dev = libusb_list[i];
status = libusb_open(libusb_list[i], &array[num]->libusb_handle);
@@ -1964,7 +1940,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE** * devArray)
bus_number = libusb_get_bus_number(libusb_list[i]);
dev_number = libusb_get_device_address(libusb_list[i]);
- array[num] = (PUDEVICE) udev_init(array[num], bus_number, dev_number);
+ array[num] = (PUDEVICE)udev_init(array[num], bus_number, dev_number);
if (array[num] != NULL)
num++;
@@ -1974,7 +1950,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE** * devArray)
}
libusb_free_device_list(libusb_list, 1);
- *devArray = (IUDEVICE**) array;
+ *devArray = (IUDEVICE**)array;
return num;
}
@@ -1983,12 +1959,12 @@ IUDEVICE* udev_new_by_addr(int bus_number, int dev_number)
int status;
UDEVICE* pDev;
WLog_DBG(TAG, "bus:%d dev:%d", bus_number, dev_number);
- pDev = (PUDEVICE) malloc(sizeof(UDEVICE));
+ pDev = (PUDEVICE)malloc(sizeof(UDEVICE));
pDev->libusb_dev = udev_get_libusb_dev(bus_number, dev_number);
if (pDev->libusb_dev == NULL)
{
- WLog_ERR(TAG, "libusb_device_new: ERROR!!");
+ WLog_ERR(TAG, "libusb_device_new: ERROR!!");
zfree(pDev);
return NULL;
}
@@ -1997,7 +1973,7 @@ IUDEVICE* udev_new_by_addr(int bus_number, int dev_number)
if (status < 0)
{
- WLog_ERR(TAG, "libusb_open: (by addr) ERROR!!");
+ WLog_ERR(TAG, "libusb_open: (by addr) ERROR!!");
zfree(pDev);
return NULL;
}
diff --git a/channels/urbdrc/client/libusb/libusb_udevice.h b/channels/urbdrc/client/libusb/libusb_udevice.h
index c79dfcad5..f08f24b07 100644
--- a/channels/urbdrc/client/libusb/libusb_udevice.h
+++ b/channels/urbdrc/client/libusb/libusb_udevice.h
@@ -18,8 +18,6 @@
* limitations under the License.
*/
-
-
#ifndef FREERDP_CHANNEL_URBDRC_CLIENT_LIBUSB_UDEVICE_H
#define FREERDP_CHANNEL_URBDRC_CLIENT_LIBUSB_UDEVICE_H
@@ -33,13 +31,13 @@
#include "request_queue.h"
#include "urbdrc_main.h"
-typedef struct libusb_device LIBUSB_DEVICE;
-typedef struct libusb_device_handle LIBUSB_DEVICE_HANDLE;
-typedef struct libusb_device_descriptor LIBUSB_DEVICE_DESCRIPTOR;
-typedef struct libusb_config_descriptor LIBUSB_CONFIG_DESCRIPTOR;
-typedef struct libusb_interface LIBUSB_INTERFACE;
-typedef struct libusb_interface_descriptor LIBUSB_INTERFACE_DESCRIPTOR;
-typedef struct libusb_endpoint_descriptor LIBUSB_ENDPOINT_DESCEIPTOR;
+typedef struct libusb_device LIBUSB_DEVICE;
+typedef struct libusb_device_handle LIBUSB_DEVICE_HANDLE;
+typedef struct libusb_device_descriptor LIBUSB_DEVICE_DESCRIPTOR;
+typedef struct libusb_config_descriptor LIBUSB_CONFIG_DESCRIPTOR;
+typedef struct libusb_interface LIBUSB_INTERFACE;
+typedef struct libusb_interface_descriptor LIBUSB_INTERFACE_DESCRIPTOR;
+typedef struct libusb_endpoint_descriptor LIBUSB_ENDPOINT_DESCEIPTOR;
typedef struct _UDEVICE UDEVICE;
@@ -47,37 +45,37 @@ struct _UDEVICE
{
IUDEVICE iface;
- void * udev;
- void * prev;
- void * next;
+ void* udev;
+ void* prev;
+ void* next;
- UINT32 UsbDevice; /* An unique interface ID */
- UINT32 ReqCompletion; /* An unique interface ID */
- UINT32 channel_id;
- UINT16 status;
- UINT16 bus_number;
- UINT16 dev_number;
- char path[17];
- int port_number;
- int isCompositeDevice;
+ UINT32 UsbDevice; /* An unique interface ID */
+ UINT32 ReqCompletion; /* An unique interface ID */
+ UINT32 channel_id;
+ UINT16 status;
+ UINT16 bus_number;
+ UINT16 dev_number;
+ char path[17];
+ int port_number;
+ int isCompositeDevice;
- LIBUSB_DEVICE_HANDLE * libusb_handle;
- LIBUSB_DEVICE_HANDLE * hub_handle;
- LIBUSB_DEVICE * libusb_dev;
- LIBUSB_DEVICE_DESCRIPTOR * devDescriptor;
- MSUSB_CONFIG_DESCRIPTOR * MsConfig;
- LIBUSB_CONFIG_DESCRIPTOR * LibusbConfig;
+ LIBUSB_DEVICE_HANDLE* libusb_handle;
+ LIBUSB_DEVICE_HANDLE* hub_handle;
+ LIBUSB_DEVICE* libusb_dev;
+ LIBUSB_DEVICE_DESCRIPTOR* devDescriptor;
+ MSUSB_CONFIG_DESCRIPTOR* MsConfig;
+ LIBUSB_CONFIG_DESCRIPTOR* LibusbConfig;
- REQUEST_QUEUE * request_queue;
+ REQUEST_QUEUE* request_queue;
/* Used in isochronous transfer */
- void * isoch_queue;
+ void* isoch_queue;
pthread_mutex_t mutex_isoch;
- sem_t sem_id;
+ sem_t sem_id;
};
-typedef UDEVICE * PUDEVICE;
+typedef UDEVICE* PUDEVICE;
-int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE ***devArray);
+int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray);
IUDEVICE* udev_new_by_addr(int bus_number, int dev_number);
extern int libusb_debug;
diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c
index 679318542..035c2d0de 100644
--- a/channels/urbdrc/client/libusb/libusb_udevman.c
+++ b/channels/urbdrc/client/libusb/libusb_udevman.c
@@ -34,19 +34,19 @@
int libusb_debug;
-#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \
- static _type udevman_get_##_arg (IUDEVMAN* idevman) \
- { \
- UDEVMAN * udevman = (UDEVMAN *) idevman; \
- return udevman->_arg; \
- } \
- static void udevman_set_##_arg (IUDEVMAN* idevman, _type _t) \
- { \
- UDEVMAN * udevman = (UDEVMAN *) idevman; \
- udevman->_arg = _t; \
+#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \
+ static _type udevman_get_##_arg(IUDEVMAN* idevman) \
+ { \
+ UDEVMAN* udevman = (UDEVMAN*)idevman; \
+ return udevman->_arg; \
+ } \
+ static void udevman_set_##_arg(IUDEVMAN* idevman, _type _t) \
+ { \
+ UDEVMAN* udevman = (UDEVMAN*)idevman; \
+ udevman->_arg = _t; \
}
-#define BASIC_STATE_FUNC_REGISTER(_arg, _man) \
+#define BASIC_STATE_FUNC_REGISTER(_arg, _man) \
_man->iface.get_##_arg = udevman_get_##_arg; \
_man->iface.set_##_arg = udevman_set_##_arg
@@ -72,13 +72,13 @@ typedef UDEVMAN* PUDEVMAN;
static void udevman_rewind(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
udevman->idev = udevman->head;
}
static int udevman_has_next(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
if (udevman->idev == NULL)
return 0;
@@ -88,10 +88,10 @@ static int udevman_has_next(IUDEVMAN* idevman)
static IUDEVICE* udevman_get_next(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
IUDEVICE* pdev;
pdev = udevman->idev;
- udevman->idev = (IUDEVICE*)((UDEVICE*) udevman->idev)->next;
+ udevman->idev = (IUDEVICE*)((UDEVICE*)udevman->idev)->next;
return pdev;
}
@@ -105,7 +105,8 @@ static IUDEVICE* udevman_get_udevice_by_addr(IUDEVMAN* idevman, int bus_number,
{
pdev = idevman->get_next(idevman);
- if ((pdev->get_bus_number(pdev) == bus_number) && (pdev->get_dev_number(pdev) == dev_number))
+ if ((pdev->get_bus_number(pdev) == bus_number) &&
+ (pdev->get_dev_number(pdev) == dev_number))
{
idevman->loading_unlock(idevman);
return pdev;
@@ -113,19 +114,18 @@ static IUDEVICE* udevman_get_udevice_by_addr(IUDEVMAN* idevman, int bus_number,
}
idevman->loading_unlock(idevman);
- WLog_WARN(TAG, "bus:%d dev:%d not exist in udevman",
- bus_number, dev_number);
+ WLog_WARN(TAG, "bus:%d dev:%d not exist in udevman", bus_number, dev_number);
return NULL;
}
static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_number,
int UsbDevice, UINT16 idVendor, UINT16 idProduct, int flag)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
IUDEVICE* pdev = NULL;
IUDEVICE** devArray;
int i, num, addnum = 0;
- pdev = (IUDEVICE*) udevman_get_udevice_by_addr(idevman, bus_number, dev_number);
+ pdev = (IUDEVICE*)udevman_get_udevice_by_addr(idevman, bus_number, dev_number);
if (pdev != NULL)
return 0;
@@ -167,8 +167,8 @@ static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_n
{
pdev = devArray[i];
- if (udevman_get_udevice_by_addr(idevman,
- pdev->get_bus_number(pdev), pdev->get_dev_number(pdev)) != NULL)
+ if (udevman_get_udevice_by_addr(idevman, pdev->get_bus_number(pdev),
+ pdev->get_dev_number(pdev)) != NULL)
{
zfree(pdev);
continue;
@@ -201,7 +201,7 @@ static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_n
}
else
{
- WLog_ERR(TAG, "udevman_register_udevice: function error!!");
+ WLog_ERR(TAG, "udevman_register_udevice: function error!!");
return 0;
}
@@ -210,16 +210,16 @@ static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_n
static int udevman_unregister_udevice(IUDEVMAN* idevman, int bus_number, int dev_number)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
- UDEVICE* pdev, * dev;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
+ UDEVICE *pdev, *dev;
int ret = 0, err = 0;
- dev = (UDEVICE*) udevman_get_udevice_by_addr(idevman, bus_number, dev_number);
+ dev = (UDEVICE*)udevman_get_udevice_by_addr(idevman, bus_number, dev_number);
idevman->loading_lock(idevman);
idevman->rewind(idevman);
while (idevman->has_next(idevman) != 0)
{
- pdev = (UDEVICE*) idevman->get_next(idevman);
+ pdev = (UDEVICE*)idevman->get_next(idevman);
if (pdev == dev) /* device exists */
{
@@ -273,7 +273,8 @@ static int udevman_unregister_udevice(IUDEVMAN* idevman, int bus_number, int dev
/* release all interface and attach kernel driver */
dev->iface.attach_kernel_driver((IUDEVICE*)dev);
- if (dev->request_queue) zfree(dev->request_queue);
+ if (dev->request_queue)
+ zfree(dev->request_queue);
/* free the config descriptor that send from windows */
msusb_msconfig_free(dev->MsConfig);
@@ -327,7 +328,7 @@ static int udevman_check_device_exist_by_id(IUDEVMAN* idevman, UINT16 idVendor,
static int udevman_is_auto_add(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
return (udevman->flags & UDEVMAN_FLAG_ADD_BY_AUTO) ? 1 : 0;
}
@@ -339,12 +340,12 @@ static IUDEVICE* udevman_get_udevice_by_UsbDevice_try_again(IUDEVMAN* idevman, U
while (idevman->has_next(idevman))
{
- pdev = (UDEVICE*) idevman->get_next(idevman);
+ pdev = (UDEVICE*)idevman->get_next(idevman);
if (pdev->UsbDevice == UsbDevice)
{
idevman->loading_unlock(idevman);
- return (IUDEVICE*) pdev;
+ return (IUDEVICE*)pdev;
}
}
@@ -360,49 +361,49 @@ static IUDEVICE* udevman_get_udevice_by_UsbDevice(IUDEVMAN* idevman, UINT32 UsbD
while (idevman->has_next(idevman))
{
- pdev = (UDEVICE*) idevman->get_next(idevman);
+ pdev = (UDEVICE*)idevman->get_next(idevman);
if (pdev->UsbDevice == UsbDevice)
{
idevman->loading_unlock(idevman);
- return (IUDEVICE*) pdev;
+ return (IUDEVICE*)pdev;
}
}
idevman->loading_unlock(idevman);
/* try again */
- pdev = (UDEVICE*) idevman->get_udevice_by_UsbDevice_try_again(idevman, UsbDevice);
+ pdev = (UDEVICE*)idevman->get_udevice_by_UsbDevice_try_again(idevman, UsbDevice);
if (pdev)
{
- return (IUDEVICE*) pdev;
+ return (IUDEVICE*)pdev;
}
- WLog_ERR(TAG, "0x%"PRIx32" ERROR!!", UsbDevice);
+ WLog_ERR(TAG, "0x%" PRIx32 " ERROR!!", UsbDevice);
return NULL;
}
static void udevman_loading_lock(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
pthread_mutex_lock(&udevman->devman_loading);
}
static void udevman_loading_unlock(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
pthread_mutex_unlock(&udevman->devman_loading);
}
static void udevman_wait_urb(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
sem_wait(&udevman->sem_urb_lock);
}
static void udevman_push_urb(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
sem_post(&udevman->sem_urb_lock);
}
@@ -412,7 +413,7 @@ BASIC_STATE_FUNC_DEFINED(sem_timeout, int)
static void udevman_free(IUDEVMAN* idevman)
{
- UDEVMAN* udevman = (UDEVMAN*) idevman;
+ UDEVMAN* udevman = (UDEVMAN*)idevman;
pthread_mutex_destroy(&udevman->devman_loading);
sem_destroy(&udevman->sem_urb_lock);
libusb_exit(NULL);
@@ -434,8 +435,7 @@ static void udevman_load_interface(UDEVMAN* udevman)
udevman->iface.register_udevice = udevman_register_udevice;
udevman->iface.unregister_udevice = udevman_unregister_udevice;
udevman->iface.get_udevice_by_UsbDevice = udevman_get_udevice_by_UsbDevice;
- udevman->iface.get_udevice_by_UsbDevice_try_again =
- udevman_get_udevice_by_UsbDevice_try_again;
+ udevman->iface.get_udevice_by_UsbDevice_try_again = udevman_get_udevice_by_UsbDevice_try_again;
/* Extension */
udevman->iface.check_device_exist_by_id = udevman_check_device_exist_by_id;
udevman->iface.isAutoAdd = udevman_is_auto_add;
@@ -480,14 +480,15 @@ static void urbdrc_udevman_register_devices(UDEVMAN* udevman, char* devices)
if (udevman->flags & UDEVMAN_FLAG_ADD_BY_VID_PID)
{
udevman_parse_device_pid_vid(hardware_id, &idVendor, &idProduct, ':');
- success = udevman->iface.register_udevice((IUDEVMAN*) udevman,
- 0, 0, UsbDevice, (UINT16) idVendor, (UINT16) idProduct, UDEVMAN_FLAG_ADD_BY_VID_PID);
+ success = udevman->iface.register_udevice((IUDEVMAN*)udevman, 0, 0, UsbDevice,
+ (UINT16)idVendor, (UINT16)idProduct,
+ UDEVMAN_FLAG_ADD_BY_VID_PID);
}
else if (udevman->flags & UDEVMAN_FLAG_ADD_BY_ADDR)
{
udevman_parse_device_addr(hardware_id, &bus_number, &dev_number, ':');
- success = udevman->iface.register_udevice((IUDEVMAN*) udevman,
- bus_number, dev_number, UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
+ success = udevman->iface.register_udevice((IUDEVMAN*)udevman, bus_number, dev_number,
+ UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
}
if (success)
@@ -502,18 +503,18 @@ static void urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, ADDIN_ARGV* args)
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- COMMAND_LINE_ARGUMENT_A urbdrc_udevman_args[] =
- {
- { "dbg", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "debug" },
- { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device list" },
- { "id", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "FLAG_ADD_BY_VID_PID" },
- { "addr", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "FLAG_ADD_BY_ADDR" },
- { "auto", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "FLAG_ADD_BY_AUTO" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A urbdrc_udevman_args[] = {
+ { "dbg", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "debug" },
+ { "dev", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "device list" },
+ { "id", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL,
+ "FLAG_ADD_BY_VID_PID" },
+ { "addr", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "FLAG_ADD_BY_ADDR" },
+ { "auto", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "FLAG_ADD_BY_AUTO" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ };
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- urbdrc_udevman_args, flags, udevman, NULL, NULL);
+ status = CommandLineParseArgumentsA(args->argc, args->argv, urbdrc_udevman_args, flags, udevman,
+ NULL, NULL);
arg = urbdrc_udevman_args;
do
@@ -521,8 +522,7 @@ static void urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dbg")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dbg")
{
WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE);
}
@@ -546,14 +546,13 @@ static void urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, ADDIN_ARGV* args)
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
}
#ifdef BUILTIN_CHANNELS
-#define freerdp_urbdrc_client_subsystem_entry libusb_freerdp_urbdrc_client_subsystem_entry
+#define freerdp_urbdrc_client_subsystem_entry libusb_freerdp_urbdrc_client_subsystem_entry
#else
-#define freerdp_urbdrc_client_subsystem_entry FREERDP_API freerdp_urbdrc_client_subsystem_entry
+#define freerdp_urbdrc_client_subsystem_entry FREERDP_API freerdp_urbdrc_client_subsystem_entry
#endif
int freerdp_urbdrc_client_subsystem_entry(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints)
@@ -561,7 +560,7 @@ int freerdp_urbdrc_client_subsystem_entry(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS p
UDEVMAN* udevman;
ADDIN_ARGV* args = pEntryPoints->args;
libusb_init(NULL);
- udevman = (PUDEVMAN) malloc(sizeof(UDEVMAN));
+ udevman = (PUDEVMAN)malloc(sizeof(UDEVMAN));
if (!udevman)
return -1;
@@ -579,7 +578,7 @@ int freerdp_urbdrc_client_subsystem_entry(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS p
/* set debug flag, to enable Debug message for usb data transfer */
libusb_debug = 10;
urbdrc_udevman_parse_addin_args(udevman, args);
- pEntryPoints->pRegisterUDEVMAN(pEntryPoints->plugin, (IUDEVMAN*) udevman);
+ pEntryPoints->pRegisterUDEVMAN(pEntryPoints->plugin, (IUDEVMAN*)udevman);
WLog_DBG(TAG, "UDEVMAN device registered.");
return 0;
}
diff --git a/channels/urbdrc/client/libusb/request_queue.c b/channels/urbdrc/client/libusb/request_queue.c
index 86035f1e4..9492cddcb 100644
--- a/channels/urbdrc/client/libusb/request_queue.c
+++ b/channels/urbdrc/client/libusb/request_queue.c
@@ -29,7 +29,7 @@ TRANSFER_REQUEST* request_queue_get_next(REQUEST_QUEUE* queue)
TRANSFER_REQUEST* request;
request = queue->ireq;
- queue->ireq = (TRANSFER_REQUEST *)queue->ireq->next;
+ queue->ireq = (TRANSFER_REQUEST*)queue->ireq->next;
return request;
}
@@ -43,11 +43,11 @@ int request_queue_has_next(REQUEST_QUEUE* queue)
}
TRANSFER_REQUEST* request_queue_register_request(REQUEST_QUEUE* queue, UINT32 RequestId,
- struct libusb_transfer* transfer, BYTE endpoint)
+ struct libusb_transfer* transfer, BYTE endpoint)
{
TRANSFER_REQUEST* request;
- request = (TRANSFER_REQUEST*) malloc(sizeof(TRANSFER_REQUEST));
+ request = (TRANSFER_REQUEST*)malloc(sizeof(TRANSFER_REQUEST));
request->prev = NULL;
request->next = NULL;
@@ -68,8 +68,8 @@ TRANSFER_REQUEST* request_queue_register_request(REQUEST_QUEUE* queue, UINT32 Re
else
{
/* append data to the end of the linked queue */
- queue->tail->next = (void*) request;
- request->prev = (void*) queue->tail;
+ queue->tail->next = (void*)request;
+ request->prev = (void*)queue->tail;
queue->tail = request;
}
@@ -87,12 +87,12 @@ void request_queue_rewind(REQUEST_QUEUE* queue)
/* Get first*/
TRANSFER_REQUEST* request_queue_get_request_by_endpoint(REQUEST_QUEUE* queue, BYTE ep)
{
- TRANSFER_REQUEST * request;
+ TRANSFER_REQUEST* request;
pthread_mutex_lock(&queue->request_loading);
- queue->rewind (queue);
- while (queue->has_next (queue))
+ queue->rewind(queue);
+ while (queue->has_next(queue))
{
- request = queue->get_next (queue);
+ request = queue->get_next(queue);
if (request->endpoint == ep)
{
pthread_mutex_unlock(&queue->request_loading);
@@ -100,7 +100,7 @@ TRANSFER_REQUEST* request_queue_get_request_by_endpoint(REQUEST_QUEUE* queue, BY
}
}
pthread_mutex_unlock(&queue->request_loading);
- WLog_ERR(TAG, "request_queue_get_request_by_id: ERROR!!");
+ WLog_ERR(TAG, "request_queue_get_request_by_id: ERROR!!");
return NULL;
}
@@ -114,41 +114,40 @@ int request_queue_unregister_request(REQUEST_QUEUE* queue, UINT32 RequestId)
{
request = queue->get_next(queue);
- if (request->RequestId == RequestId)
+ if (request->RequestId == RequestId)
{
if (request->prev != NULL)
{
- request_temp = (TRANSFER_REQUEST*) request->prev;
- request_temp->next = (TRANSFER_REQUEST*) request->next;
+ request_temp = (TRANSFER_REQUEST*)request->prev;
+ request_temp->next = (TRANSFER_REQUEST*)request->next;
}
else
{
- queue->head = (TRANSFER_REQUEST*) request->next;
+ queue->head = (TRANSFER_REQUEST*)request->next;
}
if (request->next != NULL)
{
- request_temp = (TRANSFER_REQUEST*) request->next;
- request_temp->prev = (TRANSFER_REQUEST*) request->prev;
+ request_temp = (TRANSFER_REQUEST*)request->next;
+ request_temp->prev = (TRANSFER_REQUEST*)request->prev;
}
else
{
- queue->tail = (TRANSFER_REQUEST*) request->prev;
-
+ queue->tail = (TRANSFER_REQUEST*)request->prev;
}
queue->request_num--;
-
+
if (request)
{
request->transfer = NULL;
- zfree(request);
+ zfree(request);
}
pthread_mutex_unlock(&queue->request_loading);
- return 0;
+ return 0;
}
}
pthread_mutex_unlock(&queue->request_loading);
@@ -160,11 +159,11 @@ REQUEST_QUEUE* request_queue_new()
{
REQUEST_QUEUE* queue;
- queue = (REQUEST_QUEUE*) malloc(sizeof(REQUEST_QUEUE));
+ queue = (REQUEST_QUEUE*)malloc(sizeof(REQUEST_QUEUE));
queue->request_num = 0;
queue->ireq = NULL;
queue->head = NULL;
- queue->tail = NULL;
+ queue->tail = NULL;
pthread_mutex_init(&queue->request_loading, NULL);
diff --git a/channels/urbdrc/client/libusb/request_queue.h b/channels/urbdrc/client/libusb/request_queue.h
index 35e80c5d1..bafe6716a 100644
--- a/channels/urbdrc/client/libusb/request_queue.h
+++ b/channels/urbdrc/client/libusb/request_queue.h
@@ -28,17 +28,16 @@ typedef struct _REQUEST_QUEUE REQUEST_QUEUE;
struct _TRANSFER_REQUEST
{
- void* request;
- void* prev;
- void* next;
+ void* request;
+ void* prev;
+ void* next;
- UINT32 RequestId;
- BYTE endpoint;
- struct libusb_transfer *transfer;
- int submit;
+ UINT32 RequestId;
+ BYTE endpoint;
+ struct libusb_transfer* transfer;
+ int submit;
};
-
struct _REQUEST_QUEUE
{
int request_num;
@@ -49,17 +48,15 @@ struct _REQUEST_QUEUE
pthread_mutex_t request_loading;
/* request queue manager service */
- void (*rewind) (REQUEST_QUEUE *queue);
- int (*has_next) (REQUEST_QUEUE* queue);
- int (*unregister_request) (REQUEST_QUEUE *queue, UINT32 RequestId);
- TRANSFER_REQUEST *(*get_next) (REQUEST_QUEUE* queue);
- TRANSFER_REQUEST *(*get_request_by_ep) (REQUEST_QUEUE *queue, BYTE ep);
- TRANSFER_REQUEST *(*register_request) (REQUEST_QUEUE* queue,
- UINT32 RequestId, struct libusb_transfer * transfer, BYTE endpoint);
+ void (*rewind)(REQUEST_QUEUE* queue);
+ int (*has_next)(REQUEST_QUEUE* queue);
+ int (*unregister_request)(REQUEST_QUEUE* queue, UINT32 RequestId);
+ TRANSFER_REQUEST* (*get_next)(REQUEST_QUEUE* queue);
+ TRANSFER_REQUEST* (*get_request_by_ep)(REQUEST_QUEUE* queue, BYTE ep);
+ TRANSFER_REQUEST* (*register_request)(REQUEST_QUEUE* queue, UINT32 RequestId,
+ struct libusb_transfer* transfer, BYTE endpoint);
};
-
REQUEST_QUEUE* request_queue_new(void);
-
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_LIBUSB_REQUEST_QUEUE_H */
diff --git a/channels/urbdrc/client/searchman.c b/channels/urbdrc/client/searchman.c
index e87102ce2..a1a587d5b 100644
--- a/channels/urbdrc/client/searchman.c
+++ b/channels/urbdrc/client/searchman.c
@@ -18,7 +18,6 @@
* limitations under the License.
*/
-
#include
#include
#include
@@ -47,16 +46,16 @@ static USB_SEARCHDEV* searchman_get_next(USB_SEARCHMAN* searchman)
USB_SEARCHDEV* search;
search = searchman->idev;
- searchman->idev = (USB_SEARCHDEV*) searchman->idev->next;
+ searchman->idev = (USB_SEARCHDEV*)searchman->idev->next;
return search;
}
static BOOL searchman_list_add(USB_SEARCHMAN* searchman, UINT16 idVendor, UINT16 idProduct)
{
- USB_SEARCHDEV* search;
+ USB_SEARCHDEV* search;
- search = (USB_SEARCHDEV*) calloc(1, sizeof(USB_SEARCHDEV));
+ search = (USB_SEARCHDEV*)calloc(1, sizeof(USB_SEARCHDEV));
if (!search)
return FALSE;
@@ -92,8 +91,7 @@ static int searchman_list_remove(USB_SEARCHMAN* searchman, UINT16 idVendor, UINT
{
point = searchman_get_next(searchman);
- if (point->idVendor == idVendor &&
- point->idProduct == idProduct)
+ if (point->idVendor == idVendor && point->idProduct == idProduct)
{
/* set previous device to point to next device */
@@ -160,27 +158,27 @@ static void searchman_list_show(USB_SEARCHMAN* self)
{
int num = 0;
USB_SEARCHDEV* usb;
- WLog_DBG(TAG, "=========== Usb Search List =========");
+ WLog_DBG(TAG, "=========== Usb Search List =========");
self->rewind(self);
while (self->has_next(self))
{
usb = self->get_next(self);
- WLog_DBG(TAG, " USB %d: ", num++);
- WLog_DBG(TAG, " idVendor: 0x%04"PRIX16"", usb->idVendor);
- WLog_DBG(TAG, " idProduct: 0x%04"PRIX16"", usb->idProduct);
+ WLog_DBG(TAG, " USB %d: ", num++);
+ WLog_DBG(TAG, " idVendor: 0x%04" PRIX16 "", usb->idVendor);
+ WLog_DBG(TAG, " idProduct: 0x%04" PRIX16 "", usb->idProduct);
}
- WLog_DBG(TAG, "================= END ===============");
+ WLog_DBG(TAG, "================= END ===============");
}
void searchman_free(USB_SEARCHMAN* self)
{
- USB_SEARCHDEV * dev;
+ USB_SEARCHDEV* dev;
while (self->head != NULL)
{
- dev = (USB_SEARCHDEV *)self->head;
- self->remove (self, dev->idVendor, dev->idProduct);
+ dev = (USB_SEARCHDEV*)self->head;
+ self->remove(self, dev->idVendor, dev->idProduct);
}
/* free searchman */
@@ -189,12 +187,12 @@ void searchman_free(USB_SEARCHMAN* self)
free(self);
}
-USB_SEARCHMAN* searchman_new(void * urbdrc, UINT32 UsbDevice)
+USB_SEARCHMAN* searchman_new(void* urbdrc, UINT32 UsbDevice)
{
int ret;
USB_SEARCHMAN* searchman;
- searchman = (USB_SEARCHMAN*) calloc(1, sizeof(USB_SEARCHMAN));
+ searchman = (USB_SEARCHMAN*)calloc(1, sizeof(USB_SEARCHMAN));
if (!searchman)
return NULL;
diff --git a/channels/urbdrc/client/searchman.h b/channels/urbdrc/client/searchman.h
index b449a989f..8e5562819 100644
--- a/channels/urbdrc/client/searchman.h
+++ b/channels/urbdrc/client/searchman.h
@@ -40,9 +40,9 @@ struct _USB_SEARCHMAN
{
int usb_numbers;
UINT32 UsbDevice;
- USB_SEARCHDEV* idev; /* iterator device */
- USB_SEARCHDEV* head; /* head device in linked list */
- USB_SEARCHDEV* tail; /* tail device in linked list */
+ USB_SEARCHDEV* idev; /* iterator device */
+ USB_SEARCHDEV* head; /* head device in linked list */
+ USB_SEARCHDEV* tail; /* tail device in linked list */
pthread_mutex_t mutex;
HANDLE term_event;
@@ -53,26 +53,25 @@ struct _USB_SEARCHMAN
void* urbdrc;
/* load service */
- void (*rewind) (USB_SEARCHMAN* seachman);
+ void (*rewind)(USB_SEARCHMAN* seachman);
/* show all device in the list */
- void (*show) (USB_SEARCHMAN* self);
+ void (*show)(USB_SEARCHMAN* self);
/* start searchman */
- BOOL (*start) (USB_SEARCHMAN* self, void* (*func)(void*));
+ BOOL (*start)(USB_SEARCHMAN* self, void* (*func)(void*));
/* close searchman */
- void (*close) (USB_SEARCHMAN* self);
+ void (*close)(USB_SEARCHMAN* self);
/* add a new usb device for search */
- BOOL (*add) (USB_SEARCHMAN* seachman, UINT16 idVendor, UINT16 idProduct);
+ BOOL (*add)(USB_SEARCHMAN* seachman, UINT16 idVendor, UINT16 idProduct);
/* remove a usb device from list */
- int (*remove) (USB_SEARCHMAN* searchman, UINT16 idVendor, UINT16 idProduct);
+ int (*remove)(USB_SEARCHMAN* searchman, UINT16 idVendor, UINT16 idProduct);
/* check list has next device*/
- int (*has_next) (USB_SEARCHMAN* seachman);
+ int (*has_next)(USB_SEARCHMAN* seachman);
/* get the device from list*/
- USB_SEARCHDEV* (*get_next) (USB_SEARCHMAN* seachman);
+ USB_SEARCHDEV* (*get_next)(USB_SEARCHMAN* seachman);
/* free! */
- void (*free) (USB_SEARCHMAN* searchman);
+ void (*free)(USB_SEARCHMAN* searchman);
};
USB_SEARCHMAN* searchman_new(void* urbdrc, UINT32 UsbDevice);
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_SEARCHMAN_H */
-
diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c
index dcc8cf16f..6694521d2 100644
--- a/channels/urbdrc/client/urbdrc_main.c
+++ b/channels/urbdrc/client/urbdrc_main.c
@@ -51,22 +51,22 @@
#include "data_transfer.h"
#include "searchman.h"
-static int func_hardware_id_format(IUDEVICE* pdev, char(*HardwareIds)[DEVICE_HARDWARE_ID_SIZE])
+static int func_hardware_id_format(IUDEVICE* pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_SIZE])
{
char str[DEVICE_HARDWARE_ID_SIZE];
UINT16 idVendor, idProduct, bcdDevice;
idVendor = (UINT16)pdev->query_device_descriptor(pdev, ID_VENDOR);
idProduct = (UINT16)pdev->query_device_descriptor(pdev, ID_PRODUCT);
bcdDevice = (UINT16)pdev->query_device_descriptor(pdev, BCD_DEVICE);
- sprintf_s(str, sizeof(str), "USB\\VID_%04"PRIX16"&PID_%04"PRIX16"", idVendor, idProduct);
+ sprintf_s(str, sizeof(str), "USB\\VID_%04" PRIX16 "&PID_%04" PRIX16 "", idVendor, idProduct);
strncpy(HardwareIds[1], str, DEVICE_HARDWARE_ID_SIZE);
- sprintf_s(str, sizeof(str), "%s&REV_%04"PRIX16"", HardwareIds[1], bcdDevice);
+ sprintf_s(str, sizeof(str), "%s&REV_%04" PRIX16 "", HardwareIds[1], bcdDevice);
strncpy(HardwareIds[0], str, DEVICE_HARDWARE_ID_SIZE);
return 0;
}
static int func_compat_id_format(IUDEVICE* pdev,
- char(*CompatibilityIds)[DEVICE_COMPATIBILITY_ID_SIZE])
+ char (*CompatibilityIds)[DEVICE_COMPATIBILITY_ID_SIZE])
{
char str[DEVICE_COMPATIBILITY_ID_SIZE];
UINT8 bDeviceClass, bDeviceSubClass, bDeviceProtocol;
@@ -76,11 +76,12 @@ static int func_compat_id_format(IUDEVICE* pdev,
if (!(pdev->isCompositeDevice(pdev)))
{
- sprintf_s(str, sizeof(str), "USB\\Class_%02"PRIX8"", bDeviceClass);
+ sprintf_s(str, sizeof(str), "USB\\Class_%02" PRIX8 "", bDeviceClass);
strncpy(CompatibilityIds[2], str, DEVICE_COMPATIBILITY_ID_SIZE);
- sprintf_s(str, sizeof(str), "%s&SubClass_%02"PRIX8"", CompatibilityIds[2], bDeviceSubClass);
+ sprintf_s(str, sizeof(str), "%s&SubClass_%02" PRIX8 "", CompatibilityIds[2],
+ bDeviceSubClass);
strncpy(CompatibilityIds[1], str, DEVICE_COMPATIBILITY_ID_SIZE);
- sprintf_s(str, sizeof(str), "%s&Prot_%02"PRIX8"", CompatibilityIds[1], bDeviceProtocol);
+ sprintf_s(str, sizeof(str), "%s&Prot_%02" PRIX8 "", CompatibilityIds[1], bDeviceProtocol);
strncpy(CompatibilityIds[0], str, DEVICE_COMPATIBILITY_ID_SIZE);
}
else
@@ -104,7 +105,7 @@ static void func_close_udevice(USB_SEARCHMAN* searchman, IUDEVICE* pdev)
pdev->SigToEnd(pdev);
idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR);
idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT);
- searchman->add(searchman, (UINT16) idVendor, (UINT16) idProduct);
+ searchman->add(searchman, (UINT16)idVendor, (UINT16)idProduct);
pdev->cancel_all_transfer_request(pdev);
pdev->wait_action_completion(pdev);
#if ISOCH_FIFO
@@ -116,8 +117,7 @@ static void func_close_udevice(USB_SEARCHMAN* searchman, IUDEVICE* pdev)
isoch_queue->free(isoch_queue);
}
#endif
- urbdrc->udevman->unregister_udevice(urbdrc->udevman,
- pdev->get_bus_number(pdev),
+ urbdrc->udevman->unregister_udevice(urbdrc->udevman, pdev->get_bus_number(pdev),
pdev->get_dev_number(pdev));
}
@@ -128,19 +128,19 @@ static int fun_device_string_send_set(char* out_data, int out_offset, char* str)
while (str[i])
{
- data_write_UINT16(out_data + out_offset + offset, str[i]); /* str */
+ data_write_UINT16(out_data + out_offset + offset, str[i]); /* str */
i++;
offset += 2;
}
- data_write_UINT16(out_data + out_offset + offset, 0x0000); /* add "\0" */
+ data_write_UINT16(out_data + out_offset + offset, 0x0000); /* add "\0" */
offset += 2;
return offset + out_offset;
}
static int func_container_id_generate(IUDEVICE* pdev, char* strContainerId)
{
- char* p, *path;
+ char *p, *path;
UINT8 containerId[17];
UINT16 idVendor, idProduct;
idVendor = (UINT16)pdev->query_device_descriptor(pdev, ID_VENDOR);
@@ -153,15 +153,17 @@ static int func_container_id_generate(IUDEVICE* pdev, char* strContainerId)
p = path;
ZeroMemory(containerId, sizeof(containerId));
- sprintf_s((char*)containerId, sizeof(containerId), "%04"PRIX16"%04"PRIX16"%s", idVendor, idProduct,
- p);
+ sprintf_s((char*)containerId, sizeof(containerId), "%04" PRIX16 "%04" PRIX16 "%s", idVendor,
+ idProduct, p);
/* format */
sprintf_s(strContainerId, DEVICE_CONTAINER_STR_SIZE,
- "{%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"}",
- containerId[0], containerId[1], containerId[2], containerId[3],
- containerId[4], containerId[5], containerId[6], containerId[7],
- containerId[8], containerId[9], containerId[10], containerId[11],
- containerId[12], containerId[13], containerId[14], containerId[15]);
+ "{%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "-%02" PRIx8
+ "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8
+ "%02" PRIx8 "%02" PRIx8 "}",
+ containerId[0], containerId[1], containerId[2], containerId[3], containerId[4],
+ containerId[5], containerId[6], containerId[7], containerId[8], containerId[9],
+ containerId[10], containerId[11], containerId[12], containerId[13], containerId[14],
+ containerId[15]);
return 0;
}
@@ -172,17 +174,19 @@ static int func_instance_id_generate(IUDEVICE* pdev, char* strInstanceId)
sprintf_s((char*)instanceId, sizeof(instanceId), "\\%s", pdev->getPath(pdev));
/* format */
sprintf_s(strInstanceId, DEVICE_INSTANCE_STR_SIZE,
- "%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"-%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8"",
- instanceId[0], instanceId[1], instanceId[2], instanceId[3],
- instanceId[4], instanceId[5], instanceId[6], instanceId[7],
- instanceId[8], instanceId[9], instanceId[10], instanceId[11],
- instanceId[12], instanceId[13], instanceId[14], instanceId[15]);
+ "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "-%02" PRIx8
+ "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8
+ "%02" PRIx8 "%02" PRIx8 "",
+ instanceId[0], instanceId[1], instanceId[2], instanceId[3], instanceId[4],
+ instanceId[5], instanceId[6], instanceId[7], instanceId[8], instanceId[9],
+ instanceId[10], instanceId[11], instanceId[12], instanceId[13], instanceId[14],
+ instanceId[15]);
return 0;
}
#if ISOCH_FIFO
-static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data)
+static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data)
{
int noAck = 0;
IUDEVICE* pdev;
@@ -195,14 +199,12 @@ static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data)
{
data_read_UINT32(transfer_data->pBuffer + 4, FunctionId);
- if ((FunctionId == TRANSFER_IN_REQUEST ||
- FunctionId == TRANSFER_OUT_REQUEST) &&
+ if ((FunctionId == TRANSFER_IN_REQUEST || FunctionId == TRANSFER_OUT_REQUEST) &&
transfer_data->cbSize >= 16)
{
data_read_UINT16(transfer_data->pBuffer + 14, URB_Function);
- if (URB_Function == URB_FUNCTION_ISOCH_TRANSFER &&
- transfer_data->cbSize >= 20)
+ if (URB_Function == URB_FUNCTION_ISOCH_TRANSFER && transfer_data->cbSize >= 20)
{
data_read_UINT32(transfer_data->pBuffer + 16, RequestField);
noAck = (RequestField & 0x80000000) >> 31;
@@ -225,7 +227,7 @@ static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback, char* data,
- UINT32 data_sizem, UINT32 MessageId)
+ UINT32 data_sizem, UINT32 MessageId)
{
UINT32 InterfaceId;
UINT32 Version;
@@ -236,16 +238,16 @@ static UINT urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback,
data_read_UINT32(data + 0, Version);
InterfaceId = ((STREAM_ID_NONE << 30) | CAPABILITIES_NEGOTIATOR);
out_size = 16;
- out_data = (char*) calloc(1, out_size);
+ out_data = (char*)calloc(1, out_size);
if (!out_data)
return ERROR_OUTOFMEMORY;
data_write_UINT32(out_data + 0, InterfaceId); /* interface id */
- data_write_UINT32(out_data + 4, MessageId); /* message id */
- data_write_UINT32(out_data + 8, Version); /* usb protocol version */
+ data_write_UINT32(out_data + 4, MessageId); /* message id */
+ data_write_UINT32(out_data + 8, Version); /* usb protocol version */
data_write_UINT32(out_data + 12, 0x00000000); /* HRESULT */
- ret = callback->channel->Write(callback->channel, out_size, (BYTE*) out_data, NULL);
+ ret = callback->channel->Write(callback->channel, out_size, (BYTE*)out_data, NULL);
zfree(out_data);
return ret;
}
@@ -256,7 +258,7 @@ static UINT urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK* callback, char* data,
- UINT32 data_sizem, UINT32 MessageId)
+ UINT32 data_sizem, UINT32 MessageId)
{
UINT32 InterfaceId;
UINT32 out_size;
@@ -271,13 +273,13 @@ static UINT urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK* callback, cha
data_read_UINT32(data + 8, Capabilities);
InterfaceId = ((STREAM_ID_PROXY << 30) | CLIENT_CHANNEL_NOTIFICATION);
out_size = 24;
- out_data = (char*) calloc(1, out_size);
+ out_data = (char*)calloc(1, out_size);
if (!out_data)
return ERROR_OUTOFMEMORY;
- data_write_UINT32(out_data + 0, InterfaceId); /* interface id */
- data_write_UINT32(out_data + 4, MessageId); /* message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /* interface id */
+ data_write_UINT32(out_data + 4, MessageId); /* message id */
data_write_UINT32(out_data + 8, CHANNEL_CREATED); /* function id */
data_write_UINT32(out_data + 12, MajorVersion);
data_write_UINT32(out_data + 16, MinorVersion);
@@ -297,12 +299,12 @@ static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, UINT32 M
assert(NULL != channel->Write);
InterfaceId = ((STREAM_ID_PROXY << 30) | CLIENT_DEVICE_SINK);
out_size = 12;
- out_data = (char*) malloc(out_size);
+ out_data = (char*)malloc(out_size);
memset(out_data, 0, out_size);
- data_write_UINT32(out_data + 0, InterfaceId); /* interface */
- data_write_UINT32(out_data + 4, MessageId); /* message id */
+ data_write_UINT32(out_data + 0, InterfaceId); /* interface */
+ data_write_UINT32(out_data + 4, MessageId); /* message id */
data_write_UINT32(out_data + 8, ADD_VIRTUAL_CHANNEL); /* function id */
- channel->Write(channel, out_size, (BYTE*) out_data, NULL);
+ channel->Write(channel, out_size, (BYTE*)out_data, NULL);
zfree(out_data);
return 0;
}
@@ -341,8 +343,7 @@ static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVI
func_compat_id_format(pdev, CompatibilityIds);
func_instance_id_generate(pdev, strInstanceId);
func_container_id_generate(pdev, strContainerId);
- cchCompatIds = strlen(CompatibilityIds[0]) + 1 +
- strlen(CompatibilityIds[1]) + 1 +
+ cchCompatIds = strlen(CompatibilityIds[0]) + 1 + strlen(CompatibilityIds[1]) + 1 +
strlen(CompatibilityIds[2]) + 2;
if (pdev->isCompositeDevice(pdev))
@@ -350,22 +351,20 @@ static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVI
out_offset = 24;
size = 24;
- size += (strlen(strInstanceId) + 1) * 2 +
- (strlen(HardwareIds[0]) + 1) * 2 + 4 +
- (strlen(HardwareIds[1]) + 1) * 2 + 2 +
- 4 + (cchCompatIds) * 2 +
+ size += (strlen(strInstanceId) + 1) * 2 + (strlen(HardwareIds[0]) + 1) * 2 + 4 +
+ (strlen(HardwareIds[1]) + 1) * 2 + 2 + 4 + (cchCompatIds)*2 +
(strlen(strContainerId) + 1) * 2 + 4 + 28;
out_data = (char*)calloc(1, size);
if (!out_data)
return ERROR_OUTOFMEMORY;
- data_write_UINT32(out_data + 0, InterfaceId); /* interface */
- /* data_write_UINT32(out_data + 4, 0);*/ /* message id */
- data_write_UINT32(out_data + 8, ADD_DEVICE); /* function id */
- data_write_UINT32(out_data + 12, 0x00000001); /* NumUsbDevice */
+ data_write_UINT32(out_data + 0, InterfaceId); /* interface */
+ /* data_write_UINT32(out_data + 4, 0);*/ /* message id */
+ data_write_UINT32(out_data + 8, ADD_DEVICE); /* function id */
+ data_write_UINT32(out_data + 12, 0x00000001); /* NumUsbDevice */
data_write_UINT32(out_data + 16, pdev->get_UsbDevice(pdev)); /* UsbDevice */
- data_write_UINT32(out_data + 20, 0x00000025); /* cchDeviceInstanceId */
+ data_write_UINT32(out_data + 20, 0x00000025); /* cchDeviceInstanceId */
out_offset = fun_device_string_send_set(out_data, out_offset, strInstanceId);
data_write_UINT32(out_data + out_offset, 0x00000036); /* cchHwIds */
out_offset += 4;
@@ -395,8 +394,8 @@ static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVI
out_offset = fun_device_string_send_set(out_data, out_offset, strContainerId);
/* USB_DEVICE_CAPABILITIES 28 bytes */
data_write_UINT32(out_data + out_offset, 0x0000001c); /* CbSize */
- data_write_UINT32(out_data + out_offset + 4, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */
- data_write_UINT32(out_data + out_offset + 8, 0x600); /* USBDI_Version, 0x500 or 0x600 */
+ data_write_UINT32(out_data + out_offset + 4, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */
+ data_write_UINT32(out_data + out_offset + 8, 0x600); /* USBDI_Version, 0x500 or 0x600 */
/* Supported_USB_Version, 0x110,0x110 or 0x200(usb2.0) */
bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB);
data_write_UINT32(out_data + out_offset + 12, bcdUSB);
@@ -422,7 +421,7 @@ static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVI
* @return 0 on success, otherwise a Win32 error code
*/
static UINT urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char* pBuffer,
- UINT32 cbSize)
+ UINT32 cbSize)
{
UINT32 MessageId;
UINT32 FunctionId;
@@ -437,7 +436,7 @@ static UINT urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char
break;
default:
- WLog_ERR(TAG, "%s: unknown FunctionId 0x%"PRIX32"", __FUNCTION__, FunctionId);
+ WLog_ERR(TAG, "%s: unknown FunctionId 0x%" PRIX32 "", __FUNCTION__, FunctionId);
error = ERROR_NOT_FOUND;
break;
}
@@ -449,7 +448,7 @@ static UINT urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char
static char* devd_get_val(char* buf, size_t buf_size, const char* val_name, size_t val_name_size,
size_t* val_size)
{
- char* ret, *buf_end, *ptr;
+ char *ret, *buf_end, *ptr;
buf_end = (buf + buf_size);
for (ret = buf; ret != NULL && ret < buf_end;)
@@ -476,7 +475,7 @@ static char* devd_get_val(char* buf, size_t buf_size, const char* val_name, size
if (ret[0] != '=')
continue;
- ret ++;
+ ret++;
break;
}
@@ -547,7 +546,7 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
error = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", error);
return 0;
}
@@ -556,8 +555,12 @@ static void* urbdrc_search_usb_device(void* arg)
errno = 0;
WLog_DBG(TAG, "======= SEARCH ======= ");
- /* !system=USB subsystem=DEVICE type=ATTACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host port=4 parent=ugen3.1 */
- /* !system=USB subsystem=DEVICE type=DETACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host port=4 parent=ugen3.1 */
+ /* !system=USB subsystem=DEVICE type=ATTACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d
+ * product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host
+ * port=4 parent=ugen3.1 */
+ /* !system=USB subsystem=DEVICE type=DETACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d
+ * product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host
+ * port=4 parent=ugen3.1 */
data_size = read(devd_skt, buf, (sizeof(buf) - 1));
if (data_size == -1)
@@ -617,7 +620,7 @@ static void* urbdrc_search_usb_device(void* arg)
/* Prepare strings. */
ptr[0] = 0;
- ptr ++;
+ ptr++;
val[val_size] = 0;
/* Extract numbers. */
busnum = strtol(val, NULL, 0);
@@ -668,7 +671,8 @@ static void* urbdrc_search_usb_device(void* arg)
continue;
val[val_size] = ' ';
- WLog_DBG(TAG, "ATTACH: bus: %i, dev: %i, ven: %i, prod: %i", busnum, devnum, idVendor, idProduct);
+ WLog_DBG(TAG, "ATTACH: bus: %i, dev: %i, ven: %i, prod: %i", busnum, devnum,
+ idVendor, idProduct);
dvc_channel = channel_mgr->FindChannelById(channel_mgr, urbdrc->first_channel_id);
searchman->rewind(searchman);
@@ -676,10 +680,9 @@ static void* urbdrc_search_usb_device(void* arg)
{
sdev = searchman->get_next(searchman);
- if (sdev->idVendor == idVendor &&
- sdev->idProduct == idProduct)
+ if (sdev->idVendor == idVendor && sdev->idProduct == idProduct)
{
- WLog_VRB(TAG, "Searchman Found Device: %04"PRIx16":%04"PRIx16"",
+ WLog_VRB(TAG, "Searchman Found Device: %04" PRIx16 ":%04" PRIx16 "",
sdev->idVendor, sdev->idProduct);
found = 1;
break;
@@ -688,20 +691,20 @@ static void* urbdrc_search_usb_device(void* arg)
if (!found && udevman->isAutoAdd(udevman))
{
- WLog_VRB(TAG, "Auto Find Device: %04x:%04x ",
- idVendor, idProduct);
+ WLog_VRB(TAG, "Auto Find Device: %04x:%04x ", idVendor, idProduct);
found = 2;
}
if (found)
{
- success = udevman->register_udevice(udevman, busnum, devnum,
- searchman->UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
+ success =
+ udevman->register_udevice(udevman, busnum, devnum, searchman->UsbDevice, 0,
+ 0, UDEVMAN_FLAG_ADD_BY_ADDR);
}
if (success)
{
- searchman->UsbDevice ++;
+ searchman->UsbDevice++;
usleep(400000);
error = urdbrc_send_virtual_channel_add(dvc_channel, 0);
@@ -726,11 +729,13 @@ static void* urbdrc_search_usb_device(void* arg)
if (pdev->get_bus_number(pdev) == busnum &&
pdev->get_dev_number(pdev) == devnum)
{
- dvc_channel = channel_mgr->FindChannelById(channel_mgr, pdev->get_channel_id(pdev));
+ dvc_channel =
+ channel_mgr->FindChannelById(channel_mgr, pdev->get_channel_id(pdev));
if (dvc_channel == NULL)
{
- WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev));
+ WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!",
+ pdev->get_channel_id(pdev));
func_close_udevice(searchman, pdev);
break;
}
@@ -749,8 +754,7 @@ static void* urbdrc_search_usb_device(void* arg)
udevman->loading_unlock(udevman);
usleep(300000);
- if (pdev && on_close && dvc_channel &&
- pdev->isSigToEnd(pdev) &&
+ if (pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) &&
!(pdev->isChannelClosed(pdev)))
{
dvc_channel->Close(dvc_channel);
@@ -768,11 +772,11 @@ err_out:
return 0;
}
#endif
-#if defined (__linux__)
+#if defined(__linux__)
static void* urbdrc_search_usb_device(void* arg)
{
- USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) arg;
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) searchman->urbdrc;
+ USB_SEARCHMAN* searchman = (USB_SEARCHMAN*)arg;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)searchman->urbdrc;
IUDEVMAN* udevman = urbdrc->udevman;
IWTSVirtualChannelManager* channel_mgr;
IWTSVirtualChannel* dvc_channel;
@@ -795,7 +799,7 @@ static void* urbdrc_search_usb_device(void* arg)
if (!udev)
{
- WLog_ERR(TAG, "Can't create udev");
+ WLog_ERR(TAG, "Can't create udev");
return 0;
}
@@ -805,8 +809,7 @@ static void* urbdrc_search_usb_device(void* arg)
udev_monitor_enable_receiving(mon);
/* Get the file descriptor (fd) for the monitor.
This fd will get passed to select() */
- mon_fd = CreateFileDescriptorEvent(NULL, TRUE, FALSE,
- udev_monitor_get_fd(mon), WINPR_FD_READ);
+ mon_fd = CreateFileDescriptorEvent(NULL, TRUE, FALSE, udev_monitor_get_fd(mon), WINPR_FD_READ);
if (!mon_fd)
goto fail_create_monfd_event;
@@ -828,7 +831,7 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!", dwError);
goto out;
}
@@ -837,7 +840,7 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", dwError);
goto out;
}
@@ -852,7 +855,7 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", dwError);
goto out;
}
@@ -895,18 +898,17 @@ static void* urbdrc_search_usb_device(void* arg)
if (errno != 0)
continue;
- dvc_channel = channel_mgr->FindChannelById(channel_mgr,
- urbdrc->first_channel_id);
+ dvc_channel =
+ channel_mgr->FindChannelById(channel_mgr, urbdrc->first_channel_id);
searchman->rewind(searchman);
while (dvc_channel && searchman->has_next(searchman))
{
sdev = searchman->get_next(searchman);
- if (sdev->idVendor == idVendor &&
- sdev->idProduct == idProduct)
+ if (sdev->idVendor == idVendor && sdev->idProduct == idProduct)
{
- WLog_VRB(TAG, "Searchman Find Device: %04"PRIx16":%04"PRIx16"",
+ WLog_VRB(TAG, "Searchman Find Device: %04" PRIx16 ":%04" PRIx16 "",
sdev->idVendor, sdev->idProduct);
found = 1;
break;
@@ -915,15 +917,15 @@ static void* urbdrc_search_usb_device(void* arg)
if (!found && udevman->isAutoAdd(udevman))
{
- WLog_VRB(TAG, "Auto Find Device: %04x:%04x ",
- idVendor, idProduct);
+ WLog_VRB(TAG, "Auto Find Device: %04x:%04x ", idVendor, idProduct);
found = 2;
}
if (found)
{
- success = udevman->register_udevice(udevman, busnum, devnum,
- searchman->UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
+ success =
+ udevman->register_udevice(udevman, busnum, devnum, searchman->UsbDevice,
+ 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
}
if (success)
@@ -944,7 +946,8 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!",
+ dwError);
goto out;
}
@@ -953,7 +956,8 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!",
+ dwError);
goto out;
}
@@ -990,13 +994,16 @@ static void* urbdrc_search_usb_device(void* arg)
{
pdev = udevman->get_next(udevman);
- if (pdev->get_bus_number(pdev) == busnum && pdev->get_dev_number(pdev) == devnum)
+ if (pdev->get_bus_number(pdev) == busnum &&
+ pdev->get_dev_number(pdev) == devnum)
{
- dvc_channel = channel_mgr->FindChannelById(channel_mgr, pdev->get_channel_id(pdev));
+ dvc_channel = channel_mgr->FindChannelById(channel_mgr,
+ pdev->get_channel_id(pdev));
if (dvc_channel == NULL)
{
- WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev));
+ WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!",
+ pdev->get_channel_id(pdev));
func_close_udevice(searchman, pdev);
break;
}
@@ -1021,7 +1028,8 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForMultipleObjects failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with error %" PRIu32 "!",
+ dwError);
goto out;
}
@@ -1030,7 +1038,8 @@ static void* urbdrc_search_usb_device(void* arg)
if (status == WAIT_FAILED)
{
dwError = GetLastError();
- WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", dwError);
+ WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!",
+ dwError);
goto out;
}
@@ -1041,7 +1050,8 @@ static void* urbdrc_search_usb_device(void* arg)
return 0;
}
- if (pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) && !(pdev->isChannelClosed(pdev)))
+ if (pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) &&
+ !(pdev->isChannelClosed(pdev)))
{
on_close = 0;
dvc_channel->Close(dvc_channel);
@@ -1052,7 +1062,7 @@ static void* urbdrc_search_usb_device(void* arg)
}
else
{
- WLog_ERR(TAG, "No Device from receive_device(). An error occurred.");
+ WLog_ERR(TAG, "No Device from receive_device(). An error occurred.");
}
}
}
@@ -1067,7 +1077,7 @@ fail_create_monfd_event:
void* urbdrc_new_device_create(void* arg)
{
- TRANSFER_DATA* transfer_data = (TRANSFER_DATA*) arg;
+ TRANSFER_DATA* transfer_data = (TRANSFER_DATA*)arg;
URBDRC_CHANNEL_CALLBACK* callback = transfer_data->callback;
IWTSVirtualChannelManager* channel_mgr;
URBDRC_PLUGIN* urbdrc = transfer_data->urbdrc;
@@ -1137,8 +1147,7 @@ void* urbdrc_new_device_create(void* arg)
break;
default:
- WLog_ERR(TAG, "vchannel_status unknown value %"PRIu32"",
- urbdrc->vchannel_status);
+ WLog_ERR(TAG, "vchannel_status unknown value %" PRIu32 "", urbdrc->vchannel_status);
break;
}
@@ -1151,13 +1160,13 @@ void* urbdrc_new_device_create(void* arg)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback, char* pBuffer,
- UINT32 cbSize)
+ UINT32 cbSize)
{
UINT32 i;
UINT32 MessageId;
UINT32 FunctionId;
UINT error = CHANNEL_RC_OK;
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) callback->plugin;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)callback->plugin;
WLog_DBG(TAG, "...");
data_read_UINT32(pBuffer + 0, MessageId);
data_read_UINT32(pBuffer + 4, FunctionId);
@@ -1171,7 +1180,7 @@ static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callbac
case RIMCALL_RELEASE:
WLog_VRB(TAG, "recv RIMCALL_RELEASE");
pthread_t thread;
- TRANSFER_DATA* transfer_data;
+ TRANSFER_DATA* transfer_data;
transfer_data = (TRANSFER_DATA*)malloc(sizeof(TRANSFER_DATA));
if (!transfer_data)
@@ -1182,7 +1191,7 @@ static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callbac
transfer_data->udevman = urbdrc->udevman;
transfer_data->urbdrc = urbdrc;
transfer_data->cbSize = cbSize;
- transfer_data->pBuffer = (BYTE*) malloc((cbSize));
+ transfer_data->pBuffer = (BYTE*)malloc((cbSize));
if (!transfer_data->pBuffer)
{
@@ -1206,7 +1215,7 @@ static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callbac
break;
default:
- WLog_VRB(TAG, "%s: unknown FunctionId 0x%"PRIX32"", __FUNCTION__, FunctionId);
+ WLog_VRB(TAG, "%s: unknown FunctionId 0x%" PRIX32 "", __FUNCTION__, FunctionId);
error = 1;
break;
}
@@ -1221,7 +1230,7 @@ static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callbac
*/
static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
- URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*) pChannelCallback;
+ URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*)pChannelCallback;
URBDRC_PLUGIN* urbdrc;
IUDEVMAN* udevman;
UINT32 InterfaceTemp;
@@ -1237,16 +1246,17 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback
if (callback->plugin == NULL)
return 0;
- urbdrc = (URBDRC_PLUGIN*) callback->plugin;
+ urbdrc = (URBDRC_PLUGIN*)callback->plugin;
if (urbdrc->udevman == NULL)
return 0;
- udevman = (IUDEVMAN*) urbdrc->udevman;
+ udevman = (IUDEVMAN*)urbdrc->udevman;
data_read_UINT32(pBuffer + 0, InterfaceTemp);
InterfaceId = (InterfaceTemp & 0x0fffffff);
Mask = ((InterfaceTemp & 0xf0000000) >> 30);
- WLog_VRB(TAG, "Size=%"PRIu32" InterfaceId=0x%"PRIX32" Mask=0x%"PRIX32"", cbSize, InterfaceId, Mask);
+ WLog_VRB(TAG, "Size=%" PRIu32 " InterfaceId=0x%" PRIX32 " Mask=0x%" PRIX32 "", cbSize,
+ InterfaceId, Mask);
switch (InterfaceId)
{
@@ -1259,7 +1269,7 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback
break;
default:
- WLog_VRB(TAG, "InterfaceId 0x%"PRIX32" Start matching devices list", InterfaceId);
+ WLog_VRB(TAG, "InterfaceId 0x%" PRIX32 " Start matching devices list", InterfaceId);
pthread_t thread;
TRANSFER_DATA* transfer_data;
transfer_data = (TRANSFER_DATA*)malloc(sizeof(TRANSFER_DATA));
@@ -1294,7 +1304,7 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback
if (error != 0)
{
- WLog_ERR(TAG, "Create Data Transfer Thread got error = %"PRIu32"", error);
+ WLog_ERR(TAG, "Create Data Transfer Thread got error = %" PRIu32 "", error);
free(transfer_data->pBuffer);
free(transfer_data);
return ERROR_INVALID_OPERATION;
@@ -1314,15 +1324,15 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback
*/
static UINT urbdrc_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
- URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*) pChannelCallback;
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) callback->plugin;
- IUDEVMAN* udevman = (IUDEVMAN*) urbdrc->udevman;
- USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) urbdrc->searchman;
+ URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*)pChannelCallback;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)callback->plugin;
+ IUDEVMAN* udevman = (IUDEVMAN*)urbdrc->udevman;
+ USB_SEARCHMAN* searchman = (USB_SEARCHMAN*)urbdrc->searchman;
IUDEVICE* pdev = NULL;
UINT32 ChannelId = 0;
int found = 0;
ChannelId = callback->channel_mgr->GetChannelId(callback->channel);
- WLog_INFO(TAG, "urbdrc_on_close: channel id %"PRIu32"", ChannelId);
+ WLog_INFO(TAG, "urbdrc_on_close: channel id %" PRIu32 "", ChannelId);
udevman->loading_lock(udevman);
udevman->rewind(udevman);
@@ -1356,12 +1366,14 @@ static UINT urbdrc_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* pData, BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* pData,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
- URBDRC_LISTENER_CALLBACK* listener_callback = (URBDRC_LISTENER_CALLBACK*) pListenerCallback;
+ URBDRC_LISTENER_CALLBACK* listener_callback = (URBDRC_LISTENER_CALLBACK*)pListenerCallback;
URBDRC_CHANNEL_CALLBACK* callback;
WLog_VRB(TAG, "");
- callback = (URBDRC_CHANNEL_CALLBACK*) calloc(1, sizeof(URBDRC_CHANNEL_CALLBACK));
+ callback = (URBDRC_CHANNEL_CALLBACK*)calloc(1, sizeof(URBDRC_CHANNEL_CALLBACK));
if (!callback)
return ERROR_OUTOFMEMORY;
@@ -1371,7 +1383,7 @@ static UINT urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCall
callback->plugin = listener_callback->plugin;
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
@@ -1382,11 +1394,12 @@ static UINT urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCall
*/
static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
{
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin;
IUDEVMAN* udevman = NULL;
USB_SEARCHMAN* searchman = NULL;
WLog_VRB(TAG, "");
- urbdrc->listener_callback = (URBDRC_LISTENER_CALLBACK*) calloc(1, sizeof(URBDRC_LISTENER_CALLBACK));
+ urbdrc->listener_callback =
+ (URBDRC_LISTENER_CALLBACK*)calloc(1, sizeof(URBDRC_LISTENER_CALLBACK));
if (!urbdrc->listener_callback)
return CHANNEL_RC_NO_MEMORY;
@@ -1396,7 +1409,7 @@ static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana
urbdrc->listener_callback->channel_mgr = pChannelMgr;
/* Init searchman */
udevman = urbdrc->udevman;
- searchman = searchman_new((void*) urbdrc, udevman->get_defUsbDevice(udevman));
+ searchman = searchman_new((void*)urbdrc, udevman->get_defUsbDevice(udevman));
if (!searchman)
{
@@ -1407,7 +1420,7 @@ static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana
urbdrc->searchman = searchman;
return pChannelMgr->CreateListener(pChannelMgr, "URBDRC", 0,
- (IWTSListenerCallback*) urbdrc->listener_callback, NULL);
+ (IWTSListenerCallback*)urbdrc->listener_callback, NULL);
}
/**
@@ -1417,7 +1430,7 @@ static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana
*/
static UINT urbdrc_plugin_terminated(IWTSPlugin* pPlugin)
{
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin;
IUDEVMAN* udevman = urbdrc->udevman;
USB_SEARCHMAN* searchman = urbdrc->searchman;
WLog_VRB(TAG, "");
@@ -1457,7 +1470,7 @@ static UINT urbdrc_plugin_terminated(IWTSPlugin* pPlugin)
static void urbdrc_register_udevman_addin(IWTSPlugin* pPlugin, IUDEVMAN* udevman)
{
- URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin;
+ URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)pPlugin;
if (urbdrc->udevman)
{
@@ -1478,8 +1491,8 @@ static UINT urbdrc_load_udevman_addin(IWTSPlugin* pPlugin, const char* name, ADD
{
PFREERDP_URBDRC_DEVICE_ENTRY entry;
FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints;
- entry = (PFREERDP_URBDRC_DEVICE_ENTRY) freerdp_load_channel_addin_entry("urbdrc", (LPSTR) name,
- NULL, 0);
+ entry = (PFREERDP_URBDRC_DEVICE_ENTRY)freerdp_load_channel_addin_entry("urbdrc", (LPSTR)name,
+ NULL, 0);
if (!entry)
return ERROR_INVALID_OPERATION;
@@ -1514,15 +1527,14 @@ static UINT urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, ADDIN_ARGV* args)
int status;
DWORD flags;
COMMAND_LINE_ARGUMENT_A* arg;
- COMMAND_LINE_ARGUMENT_A urbdrc_args[] =
- {
- { "dbg", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "debug" },
- { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
- };
+ COMMAND_LINE_ARGUMENT_A urbdrc_args[] = {
+ { "dbg", COMMAND_LINE_VALUE_FLAG, "", NULL, BoolValueFalse, -1, NULL, "debug" },
+ { "sys", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "subsystem" },
+ { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ };
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
- status = CommandLineParseArgumentsA(args->argc, args->argv,
- urbdrc_args, flags, urbdrc, NULL, NULL);
+ status =
+ CommandLineParseArgumentsA(args->argc, args->argv, urbdrc_args, flags, urbdrc, NULL, NULL);
if (status < 0)
return ERROR_INVALID_DATA;
@@ -1534,8 +1546,7 @@ static UINT urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, ADDIN_ARGV* args)
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "dbg")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dbg")
{
WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE);
}
@@ -1548,8 +1559,7 @@ static UINT urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, ADDIN_ARGV* args)
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
return CHANNEL_RC_OK;
}
@@ -1570,12 +1580,12 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT status = 0;
ADDIN_ARGV* args;
URBDRC_PLUGIN* urbdrc;
- urbdrc = (URBDRC_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "urbdrc");
+ urbdrc = (URBDRC_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "urbdrc");
args = pEntryPoints->GetPluginData(pEntryPoints);
if (urbdrc == NULL)
{
- urbdrc = (URBDRC_PLUGIN*) calloc(1, sizeof(URBDRC_PLUGIN));
+ urbdrc = (URBDRC_PLUGIN*)calloc(1, sizeof(URBDRC_PLUGIN));
if (!urbdrc)
return CHANNEL_RC_NO_MEMORY;
@@ -1586,7 +1596,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
urbdrc->iface.Terminated = urbdrc_plugin_terminated;
urbdrc->searchman = NULL;
urbdrc->vchannel_status = INIT_CHANNEL_IN;
- status = pEntryPoints->RegisterPlugin(pEntryPoints, "urbdrc", (IWTSPlugin*) urbdrc);
+ status = pEntryPoints->RegisterPlugin(pEntryPoints, "urbdrc", (IWTSPlugin*)urbdrc);
if (status != CHANNEL_RC_OK)
goto error_register;
@@ -1598,7 +1608,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
/* TODO: we should unregister the plugin ? */
WLog_ERR(TAG, "error processing arguments");
- //return status;
+ // return status;
}
if (!urbdrc->subsystem && !urbdrc_set_subsystem(urbdrc, "libusb"))
@@ -1608,7 +1618,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
return ERROR_OUTOFMEMORY;
}
- return urbdrc_load_udevman_addin((IWTSPlugin*) urbdrc, urbdrc->subsystem, args);
+ return urbdrc_load_udevman_addin((IWTSPlugin*)urbdrc, urbdrc->subsystem, args);
error_register:
free(urbdrc);
return status;
diff --git a/channels/urbdrc/client/urbdrc_main.h b/channels/urbdrc/client/urbdrc_main.h
index 129b84435..e76ef4024 100644
--- a/channels/urbdrc/client/urbdrc_main.h
+++ b/channels/urbdrc/client/urbdrc_main.h
@@ -18,29 +18,27 @@
* limitations under the License.
*/
-
-
#ifndef FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
#define FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H
#include "searchman.h"
#include "isoch_queue.h"
-#define DEVICE_HARDWARE_ID_SIZE 32
-#define DEVICE_COMPATIBILITY_ID_SIZE 36
-#define DEVICE_INSTANCE_STR_SIZE 37
-#define DEVICE_CONTAINER_STR_SIZE 39
+#define DEVICE_HARDWARE_ID_SIZE 32
+#define DEVICE_COMPATIBILITY_ID_SIZE 36
+#define DEVICE_INSTANCE_STR_SIZE 37
+#define DEVICE_CONTAINER_STR_SIZE 39
typedef struct _IUDEVICE IUDEVICE;
typedef struct _IUDEVMAN IUDEVMAN;
#define BASIC_DEV_STATE_DEFINED(_arg, _type) \
- _type (*get_##_arg) (IUDEVICE* pdev); \
- void (*set_##_arg) (IUDEVICE* pdev, _type _arg)
+ _type (*get_##_arg)(IUDEVICE * pdev); \
+ void (*set_##_arg)(IUDEVICE * pdev, _type _arg)
#define BASIC_DEVMAN_STATE_DEFINED(_arg, _type) \
- _type (*get_##_arg) (IUDEVMAN* udevman); \
- void (*set_##_arg) (IUDEVMAN* udevman, _type _arg)
+ _type (*get_##_arg)(IUDEVMAN * udevman); \
+ void (*set_##_arg)(IUDEVMAN * udevman, _type _arg)
typedef struct _URBDRC_LISTENER_CALLBACK URBDRC_LISTENER_CALLBACK;
@@ -106,75 +104,76 @@ struct _TRANSFER_DATA
struct _IUDEVICE
{
/* Transfer */
- int (*isoch_transfer) (IUDEVICE* idev, UINT32 RequestId,
- UINT32 EndpointAddress, UINT32 TransferFlags, int NoAck, UINT32* ErrorCount,
- UINT32* UrbdStatus, UINT32* StartFrame, UINT32 NumberOfPackets,
- BYTE* IsoPacket, UINT32* BufferSize, BYTE* Buffer, int Timeout);
+ int (*isoch_transfer)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
+ UINT32 TransferFlags, int NoAck, UINT32* ErrorCount, UINT32* UrbdStatus,
+ UINT32* StartFrame, UINT32 NumberOfPackets, BYTE* IsoPacket,
+ UINT32* BufferSize, BYTE* Buffer, int Timeout);
- int (*control_transfer) (IUDEVICE* idev, UINT32 RequestId,
- UINT32 EndpointAddress, UINT32 TransferFlags, BYTE bmRequestType, BYTE Request, UINT16 Value,
- UINT16 Index, UINT32* UrbdStatus, UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
+ int (*control_transfer)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
+ UINT32 TransferFlags, BYTE bmRequestType, BYTE Request, UINT16 Value,
+ UINT16 Index, UINT32* UrbdStatus, UINT32* BufferSize, BYTE* Buffer,
+ UINT32 Timeout);
- int (*bulk_or_interrupt_transfer) (IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
- UINT32 TransferFlags, UINT32* UsbdStatus, UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout);
+ int (*bulk_or_interrupt_transfer)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
+ UINT32 TransferFlags, UINT32* UsbdStatus, UINT32* BufferSize,
+ BYTE* Buffer, UINT32 Timeout);
- int (*select_configuration) (IUDEVICE* idev, UINT32 bConfigurationValue);
+ int (*select_configuration)(IUDEVICE* idev, UINT32 bConfigurationValue);
- int (*select_interface) (IUDEVICE* idev, BYTE InterfaceNumber,
- BYTE AlternateSetting);
+ int (*select_interface)(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting);
- int (*control_pipe_request) (IUDEVICE* idev, UINT32 RequestId,
- UINT32 EndpointAddress, UINT32* UsbdStatus, int command);
+ int (*control_pipe_request)(IUDEVICE* idev, UINT32 RequestId, UINT32 EndpointAddress,
+ UINT32* UsbdStatus, int command);
- int (*control_query_device_text) (IUDEVICE* idev, UINT32 TextType,
- UINT32 LocaleId, UINT32*BufferSize, BYTE* Buffer);
+ int (*control_query_device_text)(IUDEVICE* idev, UINT32 TextType, UINT32 LocaleId,
+ UINT32* BufferSize, BYTE* Buffer);
- int (*os_feature_descriptor_request) (IUDEVICE* idev, UINT32 RequestId, BYTE Recipient,
- BYTE InterfaceNumber, BYTE Ms_PageIndex, UINT16 Ms_featureDescIndex, UINT32* UsbdStatus,
- UINT32* BufferSize, BYTE* Buffer, int Timeout);
+ int (*os_feature_descriptor_request)(IUDEVICE* idev, UINT32 RequestId, BYTE Recipient,
+ BYTE InterfaceNumber, BYTE Ms_PageIndex,
+ UINT16 Ms_featureDescIndex, UINT32* UsbdStatus,
+ UINT32* BufferSize, BYTE* Buffer, int Timeout);
- void (*cancel_all_transfer_request) (IUDEVICE* idev);
+ void (*cancel_all_transfer_request)(IUDEVICE* idev);
- int (*cancel_transfer_request) (IUDEVICE* idev, UINT32 RequestId);
+ int (*cancel_transfer_request)(IUDEVICE* idev, UINT32 RequestId);
- int (*query_device_descriptor) (IUDEVICE* idev, int offset);
+ int (*query_device_descriptor)(IUDEVICE* idev, int offset);
- void (*detach_kernel_driver) (IUDEVICE* idev);
+ void (*detach_kernel_driver)(IUDEVICE* idev);
- void (*attach_kernel_driver) (IUDEVICE* idev);
+ void (*attach_kernel_driver)(IUDEVICE* idev);
- int (*wait_action_completion) (IUDEVICE* idev);
+ int (*wait_action_completion)(IUDEVICE* idev);
- void (*push_action) (IUDEVICE* idev);
+ void (*push_action)(IUDEVICE* idev);
- void (*complete_action) (IUDEVICE* idev);
+ void (*complete_action)(IUDEVICE* idev);
/* Wait for 5 sec */
- int (*wait_for_detach) (IUDEVICE* idev);
+ int (*wait_for_detach)(IUDEVICE* idev);
/* FIXME: Currently this is a way of stupid, SHOULD to improve it.
* Isochronous transfer must to FIFO */
- void (*lock_fifo_isoch) (IUDEVICE* idev);
- void (*unlock_fifo_isoch) (IUDEVICE* idev);
+ void (*lock_fifo_isoch)(IUDEVICE* idev);
+ void (*unlock_fifo_isoch)(IUDEVICE* idev);
- int (*query_device_port_status) (IUDEVICE* idev, UINT32 *UsbdStatus,
- UINT32* BufferSize,
- BYTE* Buffer);
+ int (*query_device_port_status)(IUDEVICE* idev, UINT32* UsbdStatus, UINT32* BufferSize,
+ BYTE* Buffer);
- int (*request_queue_is_none) (IUDEVICE* idev);
+ int (*request_queue_is_none)(IUDEVICE* idev);
- MSUSB_CONFIG_DESCRIPTOR* (*complete_msconfig_setup) (IUDEVICE* idev,
- MSUSB_CONFIG_DESCRIPTOR* MsConfig);
+ MSUSB_CONFIG_DESCRIPTOR* (*complete_msconfig_setup)(IUDEVICE* idev,
+ MSUSB_CONFIG_DESCRIPTOR* MsConfig);
/* Basic state */
- int (*isCompositeDevice) (IUDEVICE* idev);
- int (*isSigToEnd) (IUDEVICE* idev);
- int (*isExist) (IUDEVICE* idev);
- int (*isAlreadySend) (IUDEVICE* idev);
- int (*isChannelClosed) (IUDEVICE* idev);
- void (*SigToEnd) (IUDEVICE* idev);
- void (*setAlreadySend) (IUDEVICE* idev);
- void (*setChannelClosed) (IUDEVICE* idev);
- char *(*getPath) (IUDEVICE* idev);
+ int (*isCompositeDevice)(IUDEVICE* idev);
+ int (*isSigToEnd)(IUDEVICE* idev);
+ int (*isExist)(IUDEVICE* idev);
+ int (*isAlreadySend)(IUDEVICE* idev);
+ int (*isChannelClosed)(IUDEVICE* idev);
+ void (*SigToEnd)(IUDEVICE* idev);
+ void (*setAlreadySend)(IUDEVICE* idev);
+ void (*setChannelClosed)(IUDEVICE* idev);
+ char* (*getPath)(IUDEVICE* idev);
BASIC_DEV_STATE_DEFINED(channel_id, UINT32);
BASIC_DEV_STATE_DEFINED(UsbDevice, UINT32);
@@ -190,27 +189,26 @@ struct _IUDEVICE
BASIC_DEV_STATE_DEFINED(p_next, void*);
/* Control semaphore or mutex lock */
-
};
struct _IUDEVMAN
{
/* Standard */
- void (*free) (IUDEVMAN* idevman);
+ void (*free)(IUDEVMAN* idevman);
/* Manage devices */
- void (*rewind) (IUDEVMAN* idevman);
- int (*has_next) (IUDEVMAN* idevman);
- int (*unregister_udevice) (IUDEVMAN* idevman, int bus_number, int dev_number);
- int (*register_udevice) (IUDEVMAN* idevman, int bus_number,
- int dev_number, int UsbDevice, UINT16 idVendor, UINT16 idProduct, int flag);
- IUDEVICE *(*get_next) (IUDEVMAN* idevman);
- IUDEVICE *(*get_udevice_by_UsbDevice) (IUDEVMAN* idevman, UINT32 UsbDevice);
- IUDEVICE *(*get_udevice_by_UsbDevice_try_again) (IUDEVMAN* idevman, UINT32 UsbDevice);
+ void (*rewind)(IUDEVMAN* idevman);
+ int (*has_next)(IUDEVMAN* idevman);
+ int (*unregister_udevice)(IUDEVMAN* idevman, int bus_number, int dev_number);
+ int (*register_udevice)(IUDEVMAN* idevman, int bus_number, int dev_number, int UsbDevice,
+ UINT16 idVendor, UINT16 idProduct, int flag);
+ IUDEVICE* (*get_next)(IUDEVMAN* idevman);
+ IUDEVICE* (*get_udevice_by_UsbDevice)(IUDEVMAN* idevman, UINT32 UsbDevice);
+ IUDEVICE* (*get_udevice_by_UsbDevice_try_again)(IUDEVMAN* idevman, UINT32 UsbDevice);
/* Extension */
- int (*check_device_exist_by_id) (IUDEVMAN* idevman, UINT16 idVendor, UINT16 idProduct);
- int (*isAutoAdd) (IUDEVMAN* idevman);
+ int (*check_device_exist_by_id)(IUDEVMAN* idevman, UINT16 idVendor, UINT16 idProduct);
+ int (*isAutoAdd)(IUDEVMAN* idevman);
/* Basic state */
BASIC_DEVMAN_STATE_DEFINED(defUsbDevice, UINT32);
@@ -218,10 +216,10 @@ struct _IUDEVMAN
BASIC_DEVMAN_STATE_DEFINED(sem_timeout, int);
/* control semaphore or mutex lock */
- void (*loading_lock) (IUDEVMAN* idevman);
- void (*loading_unlock) (IUDEVMAN* idevman);
- void (*push_urb) (IUDEVMAN* idevman);
- void (*wait_urb) (IUDEVMAN* idevman);
+ void (*loading_lock)(IUDEVMAN* idevman);
+ void (*loading_unlock)(IUDEVMAN* idevman);
+ void (*push_urb)(IUDEVMAN* idevman);
+ void (*wait_urb)(IUDEVMAN* idevman);
};
#endif /* FREERDP_CHANNEL_URBDRC_CLIENT_MAIN_H */
diff --git a/channels/urbdrc/client/urbdrc_types.h b/channels/urbdrc/client/urbdrc_types.h
index 204cadec3..57555b47e 100644
--- a/channels/urbdrc/client/urbdrc_types.h
+++ b/channels/urbdrc/client/urbdrc_types.h
@@ -40,72 +40,74 @@
#ifdef WITH_DEBUG_DVC
#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_DVC(...) do { } while (0)
+#define DEBUG_DVC(...) \
+ do \
+ { \
+ } while (0)
#endif
-#define CAPABILITIES_NEGOTIATOR 0x00000000
-#define CLIENT_DEVICE_SINK 0x00000001
-#define SERVER_CHANNEL_NOTIFICATION 0x00000002
-#define CLIENT_CHANNEL_NOTIFICATION 0x00000003
-#define BASE_USBDEVICE_NUM 0x00000005
+#define CAPABILITIES_NEGOTIATOR 0x00000000
+#define CLIENT_DEVICE_SINK 0x00000001
+#define SERVER_CHANNEL_NOTIFICATION 0x00000002
+#define CLIENT_CHANNEL_NOTIFICATION 0x00000003
+#define BASE_USBDEVICE_NUM 0x00000005
-#define RIMCALL_RELEASE 0x00000001
-#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100
-#define CHANNEL_CREATED 0x00000100
-#define ADD_VIRTUAL_CHANNEL 0x00000100
-#define ADD_DEVICE 0x00000101
+#define RIMCALL_RELEASE 0x00000001
+#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100
+#define CHANNEL_CREATED 0x00000100
+#define ADD_VIRTUAL_CHANNEL 0x00000100
+#define ADD_DEVICE 0x00000101
-#define INIT_CHANNEL_IN 1
-#define INIT_CHANNEL_OUT 0
+#define INIT_CHANNEL_IN 1
+#define INIT_CHANNEL_OUT 0
/* InterfaceClass */
-#define CLASS_RESERVE 0x00
-#define CLASS_AUDIO 0x01
-#define CLASS_COMMUNICATION_IF 0x02
-#define CLASS_HID 0x03
-#define CLASS_PHYSICAL 0x05
-#define CLASS_IMAGE 0x06
-#define CLASS_PRINTER 0x07
-#define CLASS_MASS_STORAGE 0x08
-#define CLASS_HUB 0x09
-#define CLASS_COMMUNICATION_DATA_IF 0x0a
-#define CLASS_SMART_CARD 0x0b
-#define CLASS_CONTENT_SECURITY 0x0d
-#define CLASS_VIDEO 0x0e
-#define CLASS_PERSONAL_HEALTHCARE 0x0f
-#define CLASS_DIAGNOSTIC 0xdc
-#define CLASS_WIRELESS_CONTROLLER 0xe0
-#define CLASS_ELSE_DEVICE 0xef
-#define CLASS_DEPENDENCE 0xfe
-#define CLASS_VENDOR_DEPENDENCE 0xff
+#define CLASS_RESERVE 0x00
+#define CLASS_AUDIO 0x01
+#define CLASS_COMMUNICATION_IF 0x02
+#define CLASS_HID 0x03
+#define CLASS_PHYSICAL 0x05
+#define CLASS_IMAGE 0x06
+#define CLASS_PRINTER 0x07
+#define CLASS_MASS_STORAGE 0x08
+#define CLASS_HUB 0x09
+#define CLASS_COMMUNICATION_DATA_IF 0x0a
+#define CLASS_SMART_CARD 0x0b
+#define CLASS_CONTENT_SECURITY 0x0d
+#define CLASS_VIDEO 0x0e
+#define CLASS_PERSONAL_HEALTHCARE 0x0f
+#define CLASS_DIAGNOSTIC 0xdc
+#define CLASS_WIRELESS_CONTROLLER 0xe0
+#define CLASS_ELSE_DEVICE 0xef
+#define CLASS_DEPENDENCE 0xfe
+#define CLASS_VENDOR_DEPENDENCE 0xff
/* usb version */
-#define USB_v1_0 0x100
-#define USB_v1_1 0x110
-#define USB_v2_0 0x200
-#define USB_v3_0 0x300
+#define USB_v1_0 0x100
+#define USB_v1_1 0x110
+#define USB_v2_0 0x200
+#define USB_v3_0 0x300
-#define STREAM_ID_NONE 0x0
-#define STREAM_ID_PROXY 0x1
-#define STREAM_ID_STUB 0x2
+#define STREAM_ID_NONE 0x0
+#define STREAM_ID_PROXY 0x1
+#define STREAM_ID_STUB 0x2
-#define CANCEL_REQUEST 0x00000100
-#define REGISTER_REQUEST_CALLBACK 0x00000101
-#define IO_CONTROL 0x00000102
-#define INTERNAL_IO_CONTROL 0x00000103
-#define QUERY_DEVICE_TEXT 0x00000104
-#define TRANSFER_IN_REQUEST 0x00000105
-#define TRANSFER_OUT_REQUEST 0x00000106
-#define RETRACT_DEVICE 0x00000107
+#define CANCEL_REQUEST 0x00000100
+#define REGISTER_REQUEST_CALLBACK 0x00000101
+#define IO_CONTROL 0x00000102
+#define INTERNAL_IO_CONTROL 0x00000103
+#define QUERY_DEVICE_TEXT 0x00000104
+#define TRANSFER_IN_REQUEST 0x00000105
+#define TRANSFER_OUT_REQUEST 0x00000106
+#define RETRACT_DEVICE 0x00000107
-
-#define IOCONTROL_COMPLETION 0x00000100
-#define URB_COMPLETION 0x00000101
-#define URB_COMPLETION_NO_DATA 0x00000102
+#define IOCONTROL_COMPLETION 0x00000100
+#define URB_COMPLETION 0x00000101
+#define URB_COMPLETION_NO_DATA 0x00000102
/* The USB device is to be stopped from being redirected because the
* device is blocked by the server's policy. */
-#define UsbRetractReason_BlockedByPolicy 0x00000001
+#define UsbRetractReason_BlockedByPolicy 0x00000001
enum device_text_type
{
@@ -131,202 +133,209 @@ enum device_descriptor_table
B_NUM_CONFIGURATIONS = 17
};
-#define PIPE_CANCEL 0
-#define PIPE_RESET 1
+#define PIPE_CANCEL 0
+#define PIPE_RESET 1
-#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003
-#define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007
-#define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013
-#define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F
-#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027
+#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003
+#define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007
+#define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013
+#define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F
+#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027
-
-
-#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000
-#define URB_FUNCTION_SELECT_INTERFACE 0x0001
-#define URB_FUNCTION_ABORT_PIPE 0x0002
-#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003
-#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004
-#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005
-#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006
-#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007
-#define URB_FUNCTION_CONTROL_TRANSFER 0x0008
-#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009
-#define URB_FUNCTION_ISOCH_TRANSFER 0x000A
-#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B
-#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C
-#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D
-#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E
-#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F
-#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010
-#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011
-#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012
-#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013
-#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014
-#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015
-#define URB_FUNCTION_RESERVED_0X0016 0x0016
-#define URB_FUNCTION_VENDOR_DEVICE 0x0017
-#define URB_FUNCTION_VENDOR_INTERFACE 0x0018
-#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019
-#define URB_FUNCTION_CLASS_DEVICE 0x001A
-#define URB_FUNCTION_CLASS_INTERFACE 0x001B
-#define URB_FUNCTION_CLASS_ENDPOINT 0x001C
-#define URB_FUNCTION_RESERVE_0X001D 0x001D
-#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
-#define URB_FUNCTION_CLASS_OTHER 0x001F
-#define URB_FUNCTION_VENDOR_OTHER 0x0020
-#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021
-#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022
-#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023
-#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
-#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
-#define URB_FUNCTION_GET_CONFIGURATION 0x0026
-#define URB_FUNCTION_GET_INTERFACE 0x0027
-#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
-#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029
-#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A
-#define URB_FUNCTION_RESERVE_0X002B 0x002B
-#define URB_FUNCTION_RESERVE_0X002C 0x002C
-#define URB_FUNCTION_RESERVE_0X002D 0x002D
-#define URB_FUNCTION_RESERVE_0X002E 0x002E
-#define URB_FUNCTION_RESERVE_0X002F 0x002F
+#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000
+#define URB_FUNCTION_SELECT_INTERFACE 0x0001
+#define URB_FUNCTION_ABORT_PIPE 0x0002
+#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003
+#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004
+#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005
+#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006
+#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007
+#define URB_FUNCTION_CONTROL_TRANSFER 0x0008
+#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009
+#define URB_FUNCTION_ISOCH_TRANSFER 0x000A
+#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B
+#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C
+#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D
+#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E
+#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F
+#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010
+#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011
+#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012
+#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013
+#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014
+#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015
+#define URB_FUNCTION_RESERVED_0X0016 0x0016
+#define URB_FUNCTION_VENDOR_DEVICE 0x0017
+#define URB_FUNCTION_VENDOR_INTERFACE 0x0018
+#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019
+#define URB_FUNCTION_CLASS_DEVICE 0x001A
+#define URB_FUNCTION_CLASS_INTERFACE 0x001B
+#define URB_FUNCTION_CLASS_ENDPOINT 0x001C
+#define URB_FUNCTION_RESERVE_0X001D 0x001D
+#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
+#define URB_FUNCTION_CLASS_OTHER 0x001F
+#define URB_FUNCTION_VENDOR_OTHER 0x0020
+#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021
+#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022
+#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023
+#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
+#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
+#define URB_FUNCTION_GET_CONFIGURATION 0x0026
+#define URB_FUNCTION_GET_INTERFACE 0x0027
+#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
+#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029
+#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A
+#define URB_FUNCTION_RESERVE_0X002B 0x002B
+#define URB_FUNCTION_RESERVE_0X002C 0x002C
+#define URB_FUNCTION_RESERVE_0X002D 0x002D
+#define URB_FUNCTION_RESERVE_0X002E 0x002E
+#define URB_FUNCTION_RESERVE_0X002F 0x002F
// USB 2.0 calls start at 0x0030
-#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030
-#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031
-#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032
+#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030
+#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031
+#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032
-#define USBD_STATUS_SUCCESS 0x0
-#define USBD_STATUS_PENDING 0x40000000
-#define USBD_STATUS_CANCELED 0xC0010000
+#define USBD_STATUS_SUCCESS 0x0
+#define USBD_STATUS_PENDING 0x40000000
+#define USBD_STATUS_CANCELED 0xC0010000
-#define USBD_STATUS_CRC 0xC0000001
-#define USBD_STATUS_BTSTUFF 0xC0000002
-#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003
-#define USBD_STATUS_STALL_PID 0xC0000004
-#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005
-#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006
-#define USBD_STATUS_UNEXPECTED_PID 0xC0000007
-#define USBD_STATUS_DATA_OVERRUN 0xC0000008
-#define USBD_STATUS_DATA_UNDERRUN 0xC0000009
-#define USBD_STATUS_RESERVED1 0xC000000A
-#define USBD_STATUS_RESERVED2 0xC000000B
-#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C
-#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D
+#define USBD_STATUS_CRC 0xC0000001
+#define USBD_STATUS_BTSTUFF 0xC0000002
+#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003
+#define USBD_STATUS_STALL_PID 0xC0000004
+#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005
+#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006
+#define USBD_STATUS_UNEXPECTED_PID 0xC0000007
+#define USBD_STATUS_DATA_OVERRUN 0xC0000008
+#define USBD_STATUS_DATA_UNDERRUN 0xC0000009
+#define USBD_STATUS_RESERVED1 0xC000000A
+#define USBD_STATUS_RESERVED2 0xC000000B
+#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C
+#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D
/* unknown */
-#define USBD_STATUS_NO_DATA 0xC000000E
+#define USBD_STATUS_NO_DATA 0xC000000E
-#define USBD_STATUS_NOT_ACCESSED 0xC000000F
-#define USBD_STATUS_FIFO 0xC0000010
-#define USBD_STATUS_XACT_ERROR 0xC0000011
-#define USBD_STATUS_BABBLE_DETECTED 0xC0000012
-#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013
+#define USBD_STATUS_NOT_ACCESSED 0xC000000F
+#define USBD_STATUS_FIFO 0xC0000010
+#define USBD_STATUS_XACT_ERROR 0xC0000011
+#define USBD_STATUS_BABBLE_DETECTED 0xC0000012
+#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013
-#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00
-#define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000
-#define USBD_STATUS_TIMEOUT 0xC0006000
-#define USBD_STATUS_DEVICE_GONE 0xC0007000
+#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00
+#define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000
+#define USBD_STATUS_TIMEOUT 0xC0006000
+#define USBD_STATUS_DEVICE_GONE 0xC0007000
-#define USBD_STATUS_NO_MEMORY 0x80000100
-#define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200
-#define USBD_STATUS_INVALID_PARAMETER 0x80000300
-#define USBD_STATUS_REQUEST_FAILED 0x80000500
-#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600
-#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900
+#define USBD_STATUS_NO_MEMORY 0x80000100
+#define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200
+#define USBD_STATUS_INVALID_PARAMETER 0x80000300
+#define USBD_STATUS_REQUEST_FAILED 0x80000500
+#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600
+#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900
// Values for URB TransferFlags Field
//
/*
- Set if data moves device->host
+ Set if data moves device->host
*/
-#define USBD_TRANSFER_DIRECTION 0x00000001
+#define USBD_TRANSFER_DIRECTION 0x00000001
/*
- This bit if not set indicates that a short packet, and hence,
- a short transfer is an error condition
+ This bit if not set indicates that a short packet, and hence,
+ a short transfer is an error condition
*/
-#define USBD_SHORT_TRANSFER_OK 0x00000002
+#define USBD_SHORT_TRANSFER_OK 0x00000002
/*
- Subit the iso transfer on the next frame
+ Subit the iso transfer on the next frame
*/
-#define USBD_START_ISO_TRANSFER_ASAP 0x00000004
-#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008
+#define USBD_START_ISO_TRANSFER_ASAP 0x00000004
+#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008
+#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags)&USBD_TRANSFER_DIRECTION)
-#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) & USBD_TRANSFER_DIRECTION)
-
-#define USBD_TRANSFER_DIRECTION_OUT 0
-#define USBD_TRANSFER_DIRECTION_IN 1
+#define USBD_TRANSFER_DIRECTION_OUT 0
+#define USBD_TRANSFER_DIRECTION_IN 1
#define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \
USBD_TRANSFER_DIRECTION | \
USBD_START_ISO_TRANSFER_ASAP | \
USBD_DEFAULT_PIPE_TRANSFER)
-#define ENDPOINT_HALT 0x00
-#define DEVICE_REMOTE_WAKEUP 0x01
+#define ENDPOINT_HALT 0x00
+#define DEVICE_REMOTE_WAKEUP 0x01
/* transfer type */
-#define CONTROL_TRANSFER 0x00
-#define ISOCHRONOUS_TRANSFER 0x01
-#define BULK_TRANSFER 0x02
-#define INTERRUPT_TRANSFER 0x03
+#define CONTROL_TRANSFER 0x00
+#define ISOCHRONOUS_TRANSFER 0x01
+#define BULK_TRANSFER 0x02
+#define INTERRUPT_TRANSFER 0x03
-#define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE)
-#define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE)
-#define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR)
-#define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS)
-#define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS)
-#define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE)
-#define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE)
+#define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE)
+#define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE)
+#define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR)
+#define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS)
+#define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS)
+#define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE)
+#define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE)
-#define USBD_PF_CHANGE_MAX_PACKET 0x00000001
-#define USBD_PF_SHORT_PACKET_OPT 0x00000002
-#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
-#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
+#define USBD_PF_CHANGE_MAX_PACKET 0x00000001
+#define USBD_PF_SHORT_PACKET_OPT 0x00000002
+#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
+#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
/* feature request */
-#define URB_SET_FEATURE 0x00
-#define URB_CLEAR_FEATURE 0x01
+#define URB_SET_FEATURE 0x00
+#define URB_CLEAR_FEATURE 0x01
-#define USBD_PF_CHANGE_MAX_PACKET 0x00000001
-#define USBD_PF_SHORT_PACKET_OPT 0x00000002
-#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
-#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
+#define USBD_PF_CHANGE_MAX_PACKET 0x00000001
+#define USBD_PF_SHORT_PACKET_OPT 0x00000002
+#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
+#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
-#define URB_CONTROL_TRANSFER_EXTERNAL 0x1
-#define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0
+#define URB_CONTROL_TRANSFER_EXTERNAL 0x1
+#define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0
-#define USBFS_URB_SHORT_NOT_OK 0x01
-#define USBFS_URB_ISO_ASAP 0x02
-#define USBFS_URB_BULK_CONTINUATION 0x04
-#define USBFS_URB_QUEUE_BULK 0x10
+#define USBFS_URB_SHORT_NOT_OK 0x01
+#define USBFS_URB_ISO_ASAP 0x02
+#define USBFS_URB_BULK_CONTINUATION 0x04
+#define USBFS_URB_QUEUE_BULK 0x10
-#define URBDRC_DEVICE_INITIALIZED 0x01
-#define URBDRC_DEVICE_NOT_FOUND 0x02
-#define URBDRC_DEVICE_SIGNAL_END 0x04
-#define URBDRC_DEVICE_CHANNEL_CLOSED 0x08
-#define URBDRC_DEVICE_ALREADY_SEND 0x10
-#define URBDRC_DEVICE_DETACH_KERNEL 0x20
+#define URBDRC_DEVICE_INITIALIZED 0x01
+#define URBDRC_DEVICE_NOT_FOUND 0x02
+#define URBDRC_DEVICE_SIGNAL_END 0x04
+#define URBDRC_DEVICE_CHANNEL_CLOSED 0x08
+#define URBDRC_DEVICE_ALREADY_SEND 0x10
+#define URBDRC_DEVICE_DETACH_KERNEL 0x20
-#define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01
-#define UDEVMAN_FLAG_ADD_BY_ADDR 0x02
-#define UDEVMAN_FLAG_ADD_BY_AUTO 0x04
-#define UDEVMAN_FLAG_DEBUG 0x08
+#define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01
+#define UDEVMAN_FLAG_ADD_BY_ADDR 0x02
+#define UDEVMAN_FLAG_ADD_BY_AUTO 0x04
+#define UDEVMAN_FLAG_DEBUG 0x08
-#define MAX_URB_REQUSET_NUM 0x80
+#define MAX_URB_REQUSET_NUM 0x80
#define LOG_LEVEL 1
-#define dummy_wait_obj(void) do{ sleep(5); } while(0)
-#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0)
+#define dummy_wait_obj(void) \
+ do \
+ { \
+ sleep(5); \
+ } while (0)
+#define dummy_wait_s_obj(_s) \
+ do \
+ { \
+ sleep(_s); \
+ } while (0)
-#define ISOCH_FIFO 1
-#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */
+#define ISOCH_FIFO 1
+#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */
-#define urbdrc_get_mstime(_t) do { \
- struct timeval _tp; \
- gettimeofday(&_tp, 0); \
+#define urbdrc_get_mstime(_t) \
+ do \
+ { \
+ struct timeval _tp; \
+ gettimeofday(&_tp, 0); \
_t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \
} while (0)
diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c
old mode 100755
new mode 100644
index 896ebfb49..3b820b026
--- a/channels/video/client/video_main.c
+++ b/channels/video/client/video_main.c
@@ -42,7 +42,6 @@
#include
#include
-
#define TAG CHANNELS_TAG("video")
#include "video_main.h"
@@ -76,36 +75,31 @@ struct _VIDEO_PLUGIN
VIDEO_LISTENER_CALLBACK* control_callback;
VIDEO_LISTENER_CALLBACK* data_callback;
- VideoClientContext *context;
+ VideoClientContext* context;
};
typedef struct _VIDEO_PLUGIN VIDEO_PLUGIN;
-
#define XF_VIDEO_UNLIMITED_RATE 31
-static const BYTE MFVideoFormat_H264[] = {'H', '2', '6', '4',
- 0x00, 0x00,
- 0x10, 0x00,
- 0x80, 0x00,
- 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71};
+static const BYTE MFVideoFormat_H264[] = { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 };
typedef struct _PresentationContext PresentationContext;
typedef struct _VideoFrame VideoFrame;
-
/** @brief private data for the channel */
struct _VideoClientContextPriv
{
- VideoClientContext *video;
- GeometryClientContext *geometry;
- wQueue *frames;
+ VideoClientContext* video;
+ GeometryClientContext* geometry;
+ wQueue* frames;
CRITICAL_SECTION framesLock;
- wBufferPool *surfacePool;
+ wBufferPool* surfacePool;
UINT32 publishedFrames;
UINT32 droppedFrames;
UINT32 lastSentRate;
UINT64 nextFeedbackTime;
- PresentationContext *currentPresentation;
+ PresentationContext* currentPresentation;
};
/** @brief */
@@ -113,50 +107,49 @@ struct _VideoFrame
{
UINT64 publishTime;
UINT64 hnsDuration;
- MAPPED_GEOMETRY *geometry;
+ MAPPED_GEOMETRY* geometry;
UINT32 w, h;
- BYTE *surfaceData;
- PresentationContext *presentation;
+ BYTE* surfaceData;
+ PresentationContext* presentation;
};
/** @brief */
struct _PresentationContext
{
- VideoClientContext *video;
+ VideoClientContext* video;
BYTE PresentationId;
UINT32 SourceWidth, SourceHeight;
UINT32 ScaledWidth, ScaledHeight;
- MAPPED_GEOMETRY *geometry;
+ MAPPED_GEOMETRY* geometry;
UINT64 startTimeStamp;
UINT64 publishOffset;
- H264_CONTEXT *h264;
- YUV_CONTEXT *yuv;
- wStream *currentSample;
+ H264_CONTEXT* h264;
+ YUV_CONTEXT* yuv;
+ wStream* currentSample;
UINT64 lastPublishTime, nextPublishTime;
volatile LONG refCounter;
- BYTE *surfaceData;
- VideoSurface *surface;
+ BYTE* surfaceData;
+ VideoSurface* surface;
};
-
-static const char *video_command_name(BYTE cmd)
+static const char* video_command_name(BYTE cmd)
{
- switch(cmd)
+ switch (cmd)
{
- case TSMM_START_PRESENTATION:
- return "start";
- case TSMM_STOP_PRESENTATION:
- return "stop";
- default:
- return "";
+ case TSMM_START_PRESENTATION:
+ return "start";
+ case TSMM_STOP_PRESENTATION:
+ return "stop";
+ default:
+ return "";
}
}
-static BOOL yuv_to_rgb(PresentationContext *presentation, BYTE *dest)
+static BOOL yuv_to_rgb(PresentationContext* presentation, BYTE* dest)
{
const BYTE* pYUVPoint[3];
- H264_CONTEXT *h264 = presentation->h264;
+ H264_CONTEXT* h264 = presentation->h264;
BYTE** ppYUVData;
ppYUVData = h264->pYUVData;
@@ -165,7 +158,8 @@ static BOOL yuv_to_rgb(PresentationContext *presentation, BYTE *dest)
pYUVPoint[1] = ppYUVData[1];
pYUVPoint[2] = ppYUVData[2];
- if (!yuv_context_decode(presentation->yuv, pYUVPoint, h264->iStride, PIXEL_FORMAT_BGRX32, dest, h264->width * 4))
+ if (!yuv_context_decode(presentation->yuv, pYUVPoint, h264->iStride, PIXEL_FORMAT_BGRX32, dest,
+ h264->width * 4))
{
WLog_ERR(TAG, "error in yuv_to_rgb conversion");
return FALSE;
@@ -174,15 +168,15 @@ static BOOL yuv_to_rgb(PresentationContext *presentation, BYTE *dest)
return TRUE;
}
-
-static void video_client_context_set_geometry(VideoClientContext *video, GeometryClientContext *geometry)
+static void video_client_context_set_geometry(VideoClientContext* video,
+ GeometryClientContext* geometry)
{
video->priv->geometry = geometry;
}
-VideoClientContextPriv *VideoClientContextPriv_new(VideoClientContext *video)
+VideoClientContextPriv* VideoClientContextPriv_new(VideoClientContext* video)
{
- VideoClientContextPriv *ret = calloc(1, sizeof(*ret));
+ VideoClientContextPriv* ret = calloc(1, sizeof(*ret));
if (!ret)
return NULL;
@@ -208,9 +202,9 @@ VideoClientContextPriv *VideoClientContextPriv_new(VideoClientContext *video)
ret->video = video;
- /* don't set to unlimited so that we have the chance to send a feedback in
- * the first second (for servers that want feedback directly)
- */
+ /* don't set to unlimited so that we have the chance to send a feedback in
+ * the first second (for servers that want feedback directly)
+ */
ret->lastSentRate = 30;
return ret;
@@ -223,12 +217,11 @@ error_frames:
return NULL;
}
-
-static PresentationContext *PresentationContext_new(VideoClientContext *video, BYTE PresentationId,
- UINT32 x, UINT32 y, UINT32 width, UINT32 height)
+static PresentationContext* PresentationContext_new(VideoClientContext* video, BYTE PresentationId,
+ UINT32 x, UINT32 y, UINT32 width, UINT32 height)
{
- VideoClientContextPriv *priv = video->priv;
- PresentationContext *ret = calloc(1, sizeof(*ret));
+ VideoClientContextPriv* priv = video->priv;
+ PresentationContext* ret = calloc(1, sizeof(*ret));
if (!ret)
return NULL;
@@ -288,11 +281,10 @@ error_h264:
return NULL;
}
-
-static void PresentationContext_unref(PresentationContext *presentation)
+static void PresentationContext_unref(PresentationContext* presentation)
{
- VideoClientContextPriv *priv;
- MAPPED_GEOMETRY *geometry;
+ VideoClientContextPriv* priv;
+ MAPPED_GEOMETRY* geometry;
if (!presentation)
return;
@@ -319,10 +311,9 @@ static void PresentationContext_unref(PresentationContext *presentation)
free(presentation);
}
-
-static void VideoFrame_free(VideoFrame **pframe)
+static void VideoFrame_free(VideoFrame** pframe)
{
- VideoFrame *frame = *pframe;
+ VideoFrame* frame = *pframe;
mappedGeometryUnref(frame->geometry);
BufferPool_Return(frame->presentation->video->priv->surfacePool, frame->surfaceData);
@@ -331,13 +322,12 @@ static void VideoFrame_free(VideoFrame **pframe)
*pframe = NULL;
}
-
-static void VideoClientContextPriv_free(VideoClientContextPriv *priv)
+static void VideoClientContextPriv_free(VideoClientContextPriv* priv)
{
EnterCriticalSection(&priv->framesLock);
while (Queue_Count(priv->frames))
{
- VideoFrame *frame = Queue_Dequeue(priv->frames);
+ VideoFrame* frame = Queue_Dequeue(priv->frames);
if (frame)
VideoFrame_free(&frame);
}
@@ -354,12 +344,12 @@ static void VideoClientContextPriv_free(VideoClientContextPriv *priv)
free(priv);
}
-
-static UINT video_control_send_presentation_response(VideoClientContext *context, TSMM_PRESENTATION_RESPONSE *resp)
+static UINT video_control_send_presentation_response(VideoClientContext* context,
+ TSMM_PRESENTATION_RESPONSE* resp)
{
BYTE buf[12];
- wStream *s;
- VIDEO_PLUGIN* video = (VIDEO_PLUGIN *)context->handle;
+ wStream* s;
+ VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)context->handle;
IWTSVirtualChannel* channel;
UINT ret;
@@ -367,7 +357,7 @@ static UINT video_control_send_presentation_response(VideoClientContext *context
if (!s)
return CHANNEL_RC_NO_MEMORY;
- Stream_Write_UINT32(s, 12); /* cbSize */
+ Stream_Write_UINT32(s, 12); /* cbSize */
Stream_Write_UINT32(s, TSMM_PACKET_TYPE_PRESENTATION_RESPONSE); /* PacketType */
Stream_Write_UINT8(s, resp->PresentationId);
Stream_Zero(s, 3);
@@ -380,19 +370,19 @@ static UINT video_control_send_presentation_response(VideoClientContext *context
return ret;
}
-static BOOL video_onMappedGeometryUpdate(MAPPED_GEOMETRY *geometry)
+static BOOL video_onMappedGeometryUpdate(MAPPED_GEOMETRY* geometry)
{
- PresentationContext *presentation = (PresentationContext *)geometry->custom;
- RDP_RECT *r = &geometry->geometry.boundingRect;
+ PresentationContext* presentation = (PresentationContext*)geometry->custom;
+ RDP_RECT* r = &geometry->geometry.boundingRect;
WLog_DBG(TAG, "geometry updated topGeom=(%d,%d-%dx%d) geom=(%d,%d-%dx%d) rects=(%d,%d-%dx%d)",
- geometry->topLevelLeft, geometry->topLevelTop,
- geometry->topLevelRight - geometry->topLevelLeft, geometry->topLevelBottom - geometry->topLevelTop,
+ geometry->topLevelLeft, geometry->topLevelTop,
+ geometry->topLevelRight - geometry->topLevelLeft,
+ geometry->topLevelBottom - geometry->topLevelTop,
- geometry->left, geometry->top,
- geometry->right - geometry->left, geometry->bottom - geometry->top,
+ geometry->left, geometry->top, geometry->right - geometry->left,
+ geometry->bottom - geometry->top,
- r->x, r->y, r->width, r->height
- );
+ r->x, r->y, r->width, r->height);
presentation->surface->x = geometry->topLevelLeft + geometry->left;
presentation->surface->y = geometry->topLevelTop + geometry->top;
@@ -400,26 +390,26 @@ static BOOL video_onMappedGeometryUpdate(MAPPED_GEOMETRY *geometry)
return TRUE;
}
-static BOOL video_onMappedGeometryClear(MAPPED_GEOMETRY *geometry)
+static BOOL video_onMappedGeometryClear(MAPPED_GEOMETRY* geometry)
{
- PresentationContext *presentation = (PresentationContext *)geometry->custom;
+ PresentationContext* presentation = (PresentationContext*)geometry->custom;
mappedGeometryUnref(presentation->geometry);
presentation->geometry = NULL;
return TRUE;
}
-static UINT video_PresentationRequest(VideoClientContext* video, TSMM_PRESENTATION_REQUEST *req)
+static UINT video_PresentationRequest(VideoClientContext* video, TSMM_PRESENTATION_REQUEST* req)
{
- VideoClientContextPriv *priv = video->priv;
- PresentationContext *presentation;
+ VideoClientContextPriv* priv = video->priv;
+ PresentationContext* presentation;
UINT ret = CHANNEL_RC_OK;
presentation = priv->currentPresentation;
if (req->Command == TSMM_START_PRESENTATION)
{
- MAPPED_GEOMETRY *geom;
+ MAPPED_GEOMETRY* geom;
TSMM_PRESENTATION_RESPONSE resp;
if (memcmp(req->VideoSubtypeId, MFVideoFormat_H264, 16) != 0)
@@ -432,7 +422,8 @@ static UINT video_PresentationRequest(VideoClientContext* video, TSMM_PRESENTATI
{
if (presentation->PresentationId == req->PresentationId)
{
- WLog_ERR(TAG, "ignoring start request for existing presentation %d", req->PresentationId);
+ WLog_ERR(TAG, "ignoring start request for existing presentation %d",
+ req->PresentationId);
return CHANNEL_RC_OK;
}
@@ -450,15 +441,14 @@ static UINT video_PresentationRequest(VideoClientContext* video, TSMM_PRESENTATI
geom = HashTable_GetItemValue(priv->geometry->geometries, &(req->GeometryMappingId));
if (!geom)
{
- WLog_ERR(TAG, "geometry mapping 0x%"PRIx64" not registered", req->GeometryMappingId);
+ WLog_ERR(TAG, "geometry mapping 0x%" PRIx64 " not registered", req->GeometryMappingId);
return CHANNEL_RC_OK;
}
WLog_DBG(TAG, "creating presentation 0x%x", req->PresentationId);
- presentation = PresentationContext_new(video, req->PresentationId,
- geom->topLevelLeft + geom->left,
- geom->topLevelTop + geom->top,
- req->SourceWidth, req->SourceHeight);
+ presentation = PresentationContext_new(
+ video, req->PresentationId, geom->topLevelLeft + geom->left,
+ geom->topLevelTop + geom->top, req->SourceWidth, req->SourceHeight);
if (!presentation)
{
WLog_ERR(TAG, "unable to create presentation video");
@@ -501,8 +491,7 @@ static UINT video_PresentationRequest(VideoClientContext* video, TSMM_PRESENTATI
return ret;
}
-
-static UINT video_read_tsmm_presentation_req(VideoClientContext *context, wStream *s)
+static UINT video_read_tsmm_presentation_req(VideoClientContext* context, wStream* s)
{
TSMM_PRESENTATION_REQUEST req;
@@ -538,38 +527,38 @@ static UINT video_read_tsmm_presentation_req(VideoClientContext *context, wStrea
req.pExtraData = Stream_Pointer(s);
- WLog_DBG(TAG, "presentationReq: id:%"PRIu8" version:%"PRIu8" command:%s srcWidth/srcHeight=%"PRIu32"x%"PRIu32
- " scaled Width/Height=%"PRIu32"x%"PRIu32" timestamp=%"PRIu64" mappingId=%"PRIx64"",
- req.PresentationId, req.Version, video_command_name(req.Command),
- req.SourceWidth, req.SourceHeight, req.ScaledWidth, req.ScaledHeight,
- req.hnsTimestampOffset, req.GeometryMappingId);
+ WLog_DBG(TAG,
+ "presentationReq: id:%" PRIu8 " version:%" PRIu8
+ " command:%s srcWidth/srcHeight=%" PRIu32 "x%" PRIu32 " scaled Width/Height=%" PRIu32
+ "x%" PRIu32 " timestamp=%" PRIu64 " mappingId=%" PRIx64 "",
+ req.PresentationId, req.Version, video_command_name(req.Command), req.SourceWidth,
+ req.SourceHeight, req.ScaledWidth, req.ScaledHeight, req.hnsTimestampOffset,
+ req.GeometryMappingId);
return video_PresentationRequest(context, &req);
}
-
-
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *s)
+static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s)
{
- VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*) pChannelCallback;
+ VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*)pChannelCallback;
VIDEO_PLUGIN* video;
- VideoClientContext *context;
+ VideoClientContext* context;
UINT ret = CHANNEL_RC_OK;
UINT32 cbSize, packetType;
- video = (VIDEO_PLUGIN*) callback->plugin;
- context = (VideoClientContext *)video->wtsPlugin.pInterface;
+ video = (VIDEO_PLUGIN*)callback->plugin;
+ context = (VideoClientContext*)video->wtsPlugin.pInterface;
if (Stream_GetRemainingLength(s) < 4)
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, cbSize);
- if (cbSize < 8 || Stream_GetRemainingLength(s) < (cbSize-4))
+ if (cbSize < 8 || Stream_GetRemainingLength(s) < (cbSize - 4))
{
WLog_ERR(TAG, "invalid cbSize");
return ERROR_INVALID_DATA;
@@ -578,23 +567,24 @@ static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelC
Stream_Read_UINT32(s, packetType);
switch (packetType)
{
- case TSMM_PACKET_TYPE_PRESENTATION_REQUEST:
- ret = video_read_tsmm_presentation_req(context, s);
- break;
- default:
- WLog_ERR(TAG, "not expecting packet type %"PRIu32"", packetType);
- ret = ERROR_UNSUPPORTED_TYPE;
- break;
+ case TSMM_PACKET_TYPE_PRESENTATION_REQUEST:
+ ret = video_read_tsmm_presentation_req(context, s);
+ break;
+ default:
+ WLog_ERR(TAG, "not expecting packet type %" PRIu32 "", packetType);
+ ret = ERROR_UNSUPPORTED_TYPE;
+ break;
}
return ret;
}
-static UINT video_control_send_client_notification(VideoClientContext *context, TSMM_CLIENT_NOTIFICATION *notif)
+static UINT video_control_send_client_notification(VideoClientContext* context,
+ TSMM_CLIENT_NOTIFICATION* notif)
{
BYTE buf[100];
- wStream *s;
- VIDEO_PLUGIN* video = (VIDEO_PLUGIN *)context->handle;
+ wStream* s;
+ VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)context->handle;
IWTSVirtualChannel* channel;
UINT ret;
UINT32 cbSize;
@@ -604,7 +594,7 @@ static UINT video_control_send_client_notification(VideoClientContext *context,
return CHANNEL_RC_NO_MEMORY;
cbSize = 16;
- Stream_Seek_UINT32(s); /* cbSize */
+ Stream_Seek_UINT32(s); /* cbSize */
Stream_Write_UINT32(s, TSMM_PACKET_TYPE_CLIENT_NOTIFICATION); /* PacketType */
Stream_Write_UINT8(s, notif->PresentationId);
Stream_Write_UINT8(s, notif->NotificationType);
@@ -636,16 +626,16 @@ static UINT video_control_send_client_notification(VideoClientContext *context,
return ret;
}
-static void video_timer(VideoClientContext *video, UINT64 now)
+static void video_timer(VideoClientContext* video, UINT64 now)
{
- PresentationContext *presentation;
- VideoClientContextPriv *priv = video->priv;
+ PresentationContext* presentation;
+ VideoClientContextPriv* priv = video->priv;
VideoFrame *peekFrame, *frame = NULL;
EnterCriticalSection(&priv->framesLock);
do
{
- peekFrame = (VideoFrame *)Queue_Peek(priv->frames);
+ peekFrame = (VideoFrame*)Queue_Peek(priv->frames);
if (!peekFrame)
break;
@@ -654,14 +644,13 @@ static void video_timer(VideoClientContext *video, UINT64 now)
if (frame)
{
- WLog_DBG(TAG, "dropping frame @%"PRIu64, frame->publishTime);
+ WLog_DBG(TAG, "dropping frame @%" PRIu64, frame->publishTime);
priv->droppedFrames++;
VideoFrame_free(&frame);
}
frame = peekFrame;
Queue_Dequeue(priv->frames);
- }
- while (1);
+ } while (1);
LeaveCriticalSection(&priv->framesLock);
if (!frame)
@@ -709,7 +698,7 @@ treat_feedback:
/**
* we treat all frames ok, so either ask the server to send more,
* or stay unlimited
- */
+ */
if (priv->lastSentRate == XF_VIDEO_UNLIMITED_RATE)
computedRate = XF_VIDEO_UNLIMITED_RATE; /* stay unlimited */
else
@@ -739,15 +728,15 @@ treat_feedback:
video_control_send_client_notification(video, ¬if);
priv->lastSentRate = computedRate;
- WLog_DBG(TAG, "server notified with rate %d published=%d dropped=%d", priv->lastSentRate,
- priv->publishedFrames, priv->droppedFrames);
+ WLog_DBG(TAG, "server notified with rate %d published=%d dropped=%d",
+ priv->lastSentRate, priv->publishedFrames, priv->droppedFrames);
}
PresentationContext_unref(priv->currentPresentation);
}
WLog_DBG(TAG, "currentRate=%d published=%d dropped=%d", priv->lastSentRate,
- priv->publishedFrames, priv->droppedFrames);
+ priv->publishedFrames, priv->droppedFrames);
priv->droppedFrames = 0;
priv->publishedFrames = 0;
@@ -755,11 +744,10 @@ treat_feedback:
}
}
-
-static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
+static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA* data)
{
- VideoClientContextPriv *priv = context->priv;
- PresentationContext *presentation;
+ VideoClientContextPriv* priv = context->priv;
+ PresentationContext* presentation;
int status;
presentation = priv->currentPresentation;
@@ -771,8 +759,8 @@ static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
if (presentation->PresentationId != data->PresentationId)
{
- WLog_ERR(TAG, "current presentation id=%d doesn't match data id=%d", presentation->PresentationId,
- data->PresentationId);
+ WLog_ERR(TAG, "current presentation id=%d doesn't match data id=%d",
+ presentation->PresentationId, data->PresentationId);
return CHANNEL_RC_OK;
}
@@ -786,15 +774,15 @@ static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
if (data->CurrentPacketIndex == data->PacketsInSample)
{
- H264_CONTEXT *h264 = presentation->h264;
+ H264_CONTEXT* h264 = presentation->h264;
UINT64 startTime = GetTickCount64(), timeAfterH264;
- MAPPED_GEOMETRY *geom = presentation->geometry;
+ MAPPED_GEOMETRY* geom = presentation->geometry;
Stream_SealLength(presentation->currentSample);
Stream_SetPosition(presentation->currentSample, 0);
status = h264->subsystem->Decompress(h264, Stream_Pointer(presentation->currentSample),
- Stream_Length(presentation->currentSample));
+ Stream_Length(presentation->currentSample));
if (status == 0)
return CHANNEL_RC_OK;
@@ -823,7 +811,7 @@ static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
EnterCriticalSection(&priv->framesLock);
while (Queue_Count(priv->frames) > 0)
{
- VideoFrame *frame = Queue_Dequeue(priv->frames);
+ VideoFrame* frame = Queue_Dequeue(priv->frames);
if (frame)
{
priv->droppedFrames++;
@@ -839,7 +827,7 @@ static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
else
{
BOOL enqueueResult;
- VideoFrame *frame = calloc(1, sizeof(*frame));
+ VideoFrame* frame = calloc(1, sizeof(*frame));
if (!frame)
{
WLog_ERR(TAG, "unable to create frame");
@@ -884,31 +872,29 @@ static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *data)
return CHANNEL_RC_NO_MEMORY;
}
- WLog_DBG(TAG, "scheduling frame in %"PRIu32" ms", (frame->publishTime-startTime));
+ WLog_DBG(TAG, "scheduling frame in %" PRIu32 " ms", (frame->publishTime - startTime));
}
}
return CHANNEL_RC_OK;
}
-
-
-static UINT video_data_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *s)
+static UINT video_data_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s)
{
- VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*) pChannelCallback;
+ VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*)pChannelCallback;
VIDEO_PLUGIN* video;
- VideoClientContext *context;
+ VideoClientContext* context;
UINT32 cbSize, packetType;
TSMM_VIDEO_DATA data;
- video = (VIDEO_PLUGIN*) callback->plugin;
- context = (VideoClientContext *)video->wtsPlugin.pInterface;
+ video = (VIDEO_PLUGIN*)callback->plugin;
+ context = (VideoClientContext*)video->wtsPlugin.pInterface;
if (Stream_GetRemainingLength(s) < 4)
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, cbSize);
- if (cbSize < 8 || Stream_GetRemainingLength(s) < (cbSize-4))
+ if (cbSize < 8 || Stream_GetRemainingLength(s) < (cbSize - 4))
{
WLog_ERR(TAG, "invalid cbSize");
return ERROR_INVALID_DATA;
@@ -939,17 +925,17 @@ static UINT video_data_on_data_received(IWTSVirtualChannelCallback* pChannelCall
Stream_Read_UINT32(s, data.cbSample);
data.pSample = Stream_Pointer(s);
-/*
- WLog_DBG(TAG, "videoData: id:%"PRIu8" version:%"PRIu8" flags:0x%"PRIx8" timestamp=%"PRIu64" duration=%"PRIu64
- " curPacketIndex:%"PRIu16" packetInSample:%"PRIu16" sampleNumber:%"PRIu32" cbSample:%"PRIu32"",
- data.PresentationId, data.Version, data.Flags, data.hnsTimestamp, data.hnsDuration,
- data.CurrentPacketIndex, data.PacketsInSample, data.SampleNumber, data.cbSample);
-*/
+ /*
+ WLog_DBG(TAG, "videoData: id:%"PRIu8" version:%"PRIu8" flags:0x%"PRIx8" timestamp=%"PRIu64"
+ duration=%"PRIu64 " curPacketIndex:%"PRIu16" packetInSample:%"PRIu16" sampleNumber:%"PRIu32"
+ cbSample:%"PRIu32"", data.PresentationId, data.Version, data.Flags, data.hnsTimestamp,
+ data.hnsDuration, data.CurrentPacketIndex, data.PacketsInSample, data.SampleNumber,
+ data.cbSample);
+ */
return video_VideoData(context, &data);
}
-
/**
* Function description
*
@@ -973,16 +959,17 @@ static UINT video_data_on_close(IWTSVirtualChannelCallback* pChannelCallback)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT video_control_on_new_channel_connection(IWTSListenerCallback* listenerCallback,
- IWTSVirtualChannel* channel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* channel, BYTE* Data,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
VIDEO_CHANNEL_CALLBACK* callback;
- VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*) listenerCallback;
+ VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*)listenerCallback;
WINPR_UNUSED(Data);
WINPR_UNUSED(pbAccept);
- callback = (VIDEO_CHANNEL_CALLBACK*) calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK));
+ callback = (VIDEO_CHANNEL_CALLBACK*)calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK));
if (!callback)
{
WLog_ERR(TAG, "calloc failed!");
@@ -996,22 +983,23 @@ static UINT video_control_on_new_channel_connection(IWTSListenerCallback* listen
callback->channel = channel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
static UINT video_data_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
- IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept,
- IWTSVirtualChannelCallback** ppCallback)
+ IWTSVirtualChannel* pChannel, BYTE* Data,
+ BOOL* pbAccept,
+ IWTSVirtualChannelCallback** ppCallback)
{
VIDEO_CHANNEL_CALLBACK* callback;
- VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*) pListenerCallback;
+ VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*)pListenerCallback;
WINPR_UNUSED(Data);
WINPR_UNUSED(pbAccept);
- callback = (VIDEO_CHANNEL_CALLBACK*) calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK));
+ callback = (VIDEO_CHANNEL_CALLBACK*)calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK));
if (!callback)
{
WLog_ERR(TAG, "calloc failed!");
@@ -1025,12 +1013,11 @@ static UINT video_data_on_new_channel_connection(IWTSListenerCallback* pListener
callback->channel = pChannel;
listener_callback->channel_callback = callback;
- *ppCallback = (IWTSVirtualChannelCallback*) callback;
+ *ppCallback = (IWTSVirtualChannelCallback*)callback;
return CHANNEL_RC_OK;
}
-
/**
* Function description
*
@@ -1039,10 +1026,11 @@ static UINT video_data_on_new_channel_connection(IWTSListenerCallback* pListener
static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManager* channelMgr)
{
UINT status;
- VIDEO_PLUGIN* video = (VIDEO_PLUGIN *)plugin;
- VIDEO_LISTENER_CALLBACK *callback;
+ VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)plugin;
+ VIDEO_LISTENER_CALLBACK* callback;
- video->control_callback = callback = (VIDEO_LISTENER_CALLBACK*) calloc(1, sizeof(VIDEO_LISTENER_CALLBACK));
+ video->control_callback = callback =
+ (VIDEO_LISTENER_CALLBACK*)calloc(1, sizeof(VIDEO_LISTENER_CALLBACK));
if (!callback)
{
WLog_ERR(TAG, "calloc for control callback failed!");
@@ -1054,14 +1042,14 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
callback->channel_mgr = channelMgr;
status = channelMgr->CreateListener(channelMgr, VIDEO_CONTROL_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*)callback, &(video->controlListener));
+ (IWTSListenerCallback*)callback, &(video->controlListener));
if (status != CHANNEL_RC_OK)
return status;
video->controlListener->pInterface = video->wtsPlugin.pInterface;
-
- video->data_callback = callback = (VIDEO_LISTENER_CALLBACK*) calloc(1, sizeof(VIDEO_LISTENER_CALLBACK));
+ video->data_callback = callback =
+ (VIDEO_LISTENER_CALLBACK*)calloc(1, sizeof(VIDEO_LISTENER_CALLBACK));
if (!callback)
{
WLog_ERR(TAG, "calloc for data callback failed!");
@@ -1073,7 +1061,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
callback->channel_mgr = channelMgr;
status = channelMgr->CreateListener(channelMgr, VIDEO_DATA_DVC_CHANNEL_NAME, 0,
- (IWTSListenerCallback*)callback, &(video->dataListener));
+ (IWTSListenerCallback*)callback, &(video->dataListener));
if (status == CHANNEL_RC_OK)
video->dataListener->pInterface = video->wtsPlugin.pInterface;
@@ -1088,7 +1076,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
*/
static UINT video_plugin_terminated(IWTSPlugin* pPlugin)
{
- VIDEO_PLUGIN* video = (VIDEO_PLUGIN*) pPlugin;
+ VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)pPlugin;
if (video->context)
VideoClientContextPriv_free(video->context->priv);
@@ -1104,11 +1092,10 @@ static UINT video_plugin_terminated(IWTSPlugin* pPlugin)
* Channel Client Interface
*/
-
#ifdef BUILTIN_CHANNELS
-#define DVCPluginEntry video_DVCPluginEntry
+#define DVCPluginEntry video_DVCPluginEntry
#else
-#define DVCPluginEntry FREERDP_API DVCPluginEntry
+#define DVCPluginEntry FREERDP_API DVCPluginEntry
#endif
/**
@@ -1121,12 +1108,12 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
UINT error = CHANNEL_RC_OK;
VIDEO_PLUGIN* videoPlugin;
VideoClientContext* videoContext;
- VideoClientContextPriv *priv;
+ VideoClientContextPriv* priv;
- videoPlugin = (VIDEO_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "video");
+ videoPlugin = (VIDEO_PLUGIN*)pEntryPoints->GetPlugin(pEntryPoints, "video");
if (!videoPlugin)
{
- videoPlugin = (VIDEO_PLUGIN*) calloc(1, sizeof(VIDEO_PLUGIN));
+ videoPlugin = (VIDEO_PLUGIN*)calloc(1, sizeof(VIDEO_PLUGIN));
if (!videoPlugin)
{
WLog_ERR(TAG, "calloc failed!");
@@ -1138,7 +1125,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
videoPlugin->wtsPlugin.Disconnected = NULL;
videoPlugin->wtsPlugin.Terminated = video_plugin_terminated;
- videoContext = (VideoClientContext*) calloc(1, sizeof(VideoClientContext));
+ videoContext = (VideoClientContext*)calloc(1, sizeof(VideoClientContext));
if (!videoContext)
{
WLog_ERR(TAG, "calloc failed!");
@@ -1155,15 +1142,15 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
return CHANNEL_RC_NO_MEMORY;
}
- videoContext->handle = (void*) videoPlugin;
+ videoContext->handle = (void*)videoPlugin;
videoContext->priv = priv;
videoContext->timer = video_timer;
videoContext->setGeometry = video_client_context_set_geometry;
- videoPlugin->wtsPlugin.pInterface = (void*) videoContext;
+ videoPlugin->wtsPlugin.pInterface = (void*)videoContext;
videoPlugin->context = videoContext;
- error = pEntryPoints->RegisterPlugin(pEntryPoints, "video", (IWTSPlugin*) videoPlugin);
+ error = pEntryPoints->RegisterPlugin(pEntryPoints, "video", (IWTSPlugin*)videoPlugin);
}
else
{
diff --git a/channels/video/client/video_main.h b/channels/video/client/video_main.h
index f5e5ac910..18145660a 100644
--- a/channels/video/client/video_main.h
+++ b/channels/video/client/video_main.h
@@ -30,6 +30,4 @@
#include
-
#endif /* FREERDP_CHANNEL_GEOMETRY_CLIENT_MAIN_H */
-
diff --git a/client/Android/Studio/aFreeRDP/src/main/java/com/freerdp/afreerdp/application/GlobalApp.java b/client/Android/Studio/aFreeRDP/src/main/java/com/freerdp/afreerdp/application/GlobalApp.java
index c0b36f020..7d4495948 100644
--- a/client/Android/Studio/aFreeRDP/src/main/java/com/freerdp/afreerdp/application/GlobalApp.java
+++ b/client/Android/Studio/aFreeRDP/src/main/java/com/freerdp/afreerdp/application/GlobalApp.java
@@ -1,6 +1,5 @@
package com.freerdp.afreerdp.application;
-
-public class GlobalApp extends com.freerdp.freerdpcore.application.GlobalApp {
-
+public class GlobalApp extends com.freerdp.freerdpcore.application.GlobalApp
+{
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/GlobalApp.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/GlobalApp.java
index ce6c4d871..e71a86e6e 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/GlobalApp.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/GlobalApp.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.application;
@@ -32,159 +33,179 @@ import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-public class GlobalApp extends Application implements LibFreeRDP.EventListener {
- // event notification defines
- public static final String EVENT_TYPE = "EVENT_TYPE";
- public static final String EVENT_PARAM = "EVENT_PARAM";
- public static final String EVENT_STATUS = "EVENT_STATUS";
- public static final String EVENT_ERROR = "EVENT_ERROR";
- public static final String ACTION_EVENT_FREERDP = "com.freerdp.freerdp.event.freerdp";
- public static final int FREERDP_EVENT_CONNECTION_SUCCESS = 1;
- public static final int FREERDP_EVENT_CONNECTION_FAILURE = 2;
- public static final int FREERDP_EVENT_DISCONNECTED = 3;
- private static final String TAG = "GlobalApp";
- public static boolean ConnectedTo3G = false;
- private static Map sessionMap;
- private static BookmarkDB bookmarkDB;
- private static ManualBookmarkGateway manualBookmarkGateway;
+public class GlobalApp extends Application implements LibFreeRDP.EventListener
+{
+ // event notification defines
+ public static final String EVENT_TYPE = "EVENT_TYPE";
+ public static final String EVENT_PARAM = "EVENT_PARAM";
+ public static final String EVENT_STATUS = "EVENT_STATUS";
+ public static final String EVENT_ERROR = "EVENT_ERROR";
+ public static final String ACTION_EVENT_FREERDP = "com.freerdp.freerdp.event.freerdp";
+ public static final int FREERDP_EVENT_CONNECTION_SUCCESS = 1;
+ public static final int FREERDP_EVENT_CONNECTION_FAILURE = 2;
+ public static final int FREERDP_EVENT_DISCONNECTED = 3;
+ private static final String TAG = "GlobalApp";
+ public static boolean ConnectedTo3G = false;
+ private static Map sessionMap;
+ private static BookmarkDB bookmarkDB;
+ private static ManualBookmarkGateway manualBookmarkGateway;
- private static HistoryDB historyDB;
- private static QuickConnectHistoryGateway quickConnectHistoryGateway;
+ private static HistoryDB historyDB;
+ private static QuickConnectHistoryGateway quickConnectHistoryGateway;
- // timer for disconnecting sessions after the screen was turned off
- private static Timer disconnectTimer = null;
+ // timer for disconnecting sessions after the screen was turned off
+ private static Timer disconnectTimer = null;
- public static ManualBookmarkGateway getManualBookmarkGateway() {
- return manualBookmarkGateway;
- }
+ public static ManualBookmarkGateway getManualBookmarkGateway()
+ {
+ return manualBookmarkGateway;
+ }
- public static QuickConnectHistoryGateway getQuickConnectHistoryGateway() {
- return quickConnectHistoryGateway;
- }
+ public static QuickConnectHistoryGateway getQuickConnectHistoryGateway()
+ {
+ return quickConnectHistoryGateway;
+ }
- // Disconnect handling for Screen on/off events
- public void startDisconnectTimer() {
- final int timeoutMinutes = ApplicationSettingsActivity.getDisconnectTimeout(this);
- if (timeoutMinutes > 0) {
- // start disconnect timeout...
- disconnectTimer = new Timer();
- disconnectTimer.schedule(new DisconnectTask(), timeoutMinutes * 60 * 1000);
- }
- }
+ // Disconnect handling for Screen on/off events
+ public void startDisconnectTimer()
+ {
+ final int timeoutMinutes = ApplicationSettingsActivity.getDisconnectTimeout(this);
+ if (timeoutMinutes > 0)
+ {
+ // start disconnect timeout...
+ disconnectTimer = new Timer();
+ disconnectTimer.schedule(new DisconnectTask(), timeoutMinutes * 60 * 1000);
+ }
+ }
- static public void cancelDisconnectTimer() {
- // cancel any pending timer events
- if (disconnectTimer != null) {
- disconnectTimer.cancel();
- disconnectTimer.purge();
- disconnectTimer = null;
- }
- }
+ static public void cancelDisconnectTimer()
+ {
+ // cancel any pending timer events
+ if (disconnectTimer != null)
+ {
+ disconnectTimer.cancel();
+ disconnectTimer.purge();
+ disconnectTimer = null;
+ }
+ }
- // RDP session handling
- static public SessionState createSession(BookmarkBase bookmark, Context context) {
- SessionState session = new SessionState(LibFreeRDP.newInstance(context), bookmark);
- sessionMap.put(Long.valueOf(session.getInstance()), session);
- return session;
- }
+ // RDP session handling
+ static public SessionState createSession(BookmarkBase bookmark, Context context)
+ {
+ SessionState session = new SessionState(LibFreeRDP.newInstance(context), bookmark);
+ sessionMap.put(Long.valueOf(session.getInstance()), session);
+ return session;
+ }
- static public SessionState createSession(Uri openUri, Context context) {
- SessionState session = new SessionState(LibFreeRDP.newInstance(context), openUri);
- sessionMap.put(Long.valueOf(session.getInstance()), session);
- return session;
- }
+ static public SessionState createSession(Uri openUri, Context context)
+ {
+ SessionState session = new SessionState(LibFreeRDP.newInstance(context), openUri);
+ sessionMap.put(Long.valueOf(session.getInstance()), session);
+ return session;
+ }
- static public SessionState getSession(long instance) {
- return sessionMap.get(instance);
- }
+ static public SessionState getSession(long instance)
+ {
+ return sessionMap.get(instance);
+ }
- static public Collection getSessions() {
- // return a copy of the session items
- return new ArrayList(sessionMap.values());
- }
+ static public Collection getSessions()
+ {
+ // return a copy of the session items
+ return new ArrayList(sessionMap.values());
+ }
- static public void freeSession(long instance) {
- if (GlobalApp.sessionMap.containsKey(instance)) {
- GlobalApp.sessionMap.remove(instance);
- LibFreeRDP.freeInstance(instance);
- }
- }
+ static public void freeSession(long instance)
+ {
+ if (GlobalApp.sessionMap.containsKey(instance))
+ {
+ GlobalApp.sessionMap.remove(instance);
+ LibFreeRDP.freeInstance(instance);
+ }
+ }
- @Override
- public void onCreate() {
- super.onCreate();
+ @Override public void onCreate()
+ {
+ super.onCreate();
- /* Initialize preferences. */
- ApplicationSettingsActivity.get(this);
+ /* Initialize preferences. */
+ ApplicationSettingsActivity.get(this);
- sessionMap = Collections.synchronizedMap(new HashMap());
+ sessionMap = Collections.synchronizedMap(new HashMap());
- LibFreeRDP.setEventListener(this);
+ LibFreeRDP.setEventListener(this);
- bookmarkDB = new BookmarkDB(this);
+ bookmarkDB = new BookmarkDB(this);
- manualBookmarkGateway = new ManualBookmarkGateway(bookmarkDB);
+ manualBookmarkGateway = new ManualBookmarkGateway(bookmarkDB);
- historyDB = new HistoryDB(this);
- quickConnectHistoryGateway = new QuickConnectHistoryGateway(historyDB);
+ historyDB = new HistoryDB(this);
+ quickConnectHistoryGateway = new QuickConnectHistoryGateway(historyDB);
- ConnectedTo3G = NetworkStateReceiver.isConnectedTo3G(this);
+ ConnectedTo3G = NetworkStateReceiver.isConnectedTo3G(this);
- // init screen receiver here (this can't be declared in AndroidManifest - refer to:
- // http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
- IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
- filter.addAction(Intent.ACTION_SCREEN_OFF);
- registerReceiver(new ScreenReceiver(), filter);
- }
+ // init screen receiver here (this can't be declared in AndroidManifest - refer to:
+ // http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
+ IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ registerReceiver(new ScreenReceiver(), filter);
+ }
- // helper to send FreeRDP notifications
- private void sendRDPNotification(int type, long param) {
- // send broadcast
- Intent intent = new Intent(ACTION_EVENT_FREERDP);
- intent.putExtra(EVENT_TYPE, type);
- intent.putExtra(EVENT_PARAM, param);
- sendBroadcast(intent);
- }
+ // helper to send FreeRDP notifications
+ private void sendRDPNotification(int type, long param)
+ {
+ // send broadcast
+ Intent intent = new Intent(ACTION_EVENT_FREERDP);
+ intent.putExtra(EVENT_TYPE, type);
+ intent.putExtra(EVENT_PARAM, param);
+ sendBroadcast(intent);
+ }
- @Override
- public void OnPreConnect(long instance) {
- Log.v(TAG, "OnPreConnect");
- }
+ @Override public void OnPreConnect(long instance)
+ {
+ Log.v(TAG, "OnPreConnect");
+ }
- // //////////////////////////////////////////////////////////////////////
- // Implementation of LibFreeRDP.EventListener
- public void OnConnectionSuccess(long instance) {
- Log.v(TAG, "OnConnectionSuccess");
- sendRDPNotification(FREERDP_EVENT_CONNECTION_SUCCESS, instance);
- }
+ // //////////////////////////////////////////////////////////////////////
+ // Implementation of LibFreeRDP.EventListener
+ public void OnConnectionSuccess(long instance)
+ {
+ Log.v(TAG, "OnConnectionSuccess");
+ sendRDPNotification(FREERDP_EVENT_CONNECTION_SUCCESS, instance);
+ }
- public void OnConnectionFailure(long instance) {
- Log.v(TAG, "OnConnectionFailure");
+ public void OnConnectionFailure(long instance)
+ {
+ Log.v(TAG, "OnConnectionFailure");
- // send notification to session activity
- sendRDPNotification(FREERDP_EVENT_CONNECTION_FAILURE, instance);
- }
+ // send notification to session activity
+ sendRDPNotification(FREERDP_EVENT_CONNECTION_FAILURE, instance);
+ }
- public void OnDisconnecting(long instance) {
- Log.v(TAG, "OnDisconnecting");
- }
+ public void OnDisconnecting(long instance)
+ {
+ Log.v(TAG, "OnDisconnecting");
+ }
- public void OnDisconnected(long instance) {
- Log.v(TAG, "OnDisconnected");
- sendRDPNotification(FREERDP_EVENT_DISCONNECTED, instance);
- }
+ public void OnDisconnected(long instance)
+ {
+ Log.v(TAG, "OnDisconnected");
+ sendRDPNotification(FREERDP_EVENT_DISCONNECTED, instance);
+ }
- // TimerTask for disconnecting sessions after screen was turned off
- private static class DisconnectTask extends TimerTask {
- @Override
- public void run() {
- Log.v("DisconnectTask", "Doing action");
+ // TimerTask for disconnecting sessions after screen was turned off
+ private static class DisconnectTask extends TimerTask
+ {
+ @Override public void run()
+ {
+ Log.v("DisconnectTask", "Doing action");
- // disconnect any running rdp session
- Collection sessions = GlobalApp.getSessions();
- for (SessionState session : sessions) {
- LibFreeRDP.disconnect(session.getInstance());
- }
- }
- }
+ // disconnect any running rdp session
+ Collection sessions = GlobalApp.getSessions();
+ for (SessionState session : sessions)
+ {
+ LibFreeRDP.disconnect(session.getInstance());
+ }
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/NetworkStateReceiver.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/NetworkStateReceiver.java
index 38a98a684..ea3d663a7 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/NetworkStateReceiver.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/NetworkStateReceiver.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.application;
@@ -16,34 +17,42 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
-public class NetworkStateReceiver extends BroadcastReceiver {
+public class NetworkStateReceiver extends BroadcastReceiver
+{
- public static boolean isConnectedTo3G(Context context) {
- ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo info = connectivity.getActiveNetworkInfo();
+ public static boolean isConnectedTo3G(Context context)
+ {
+ ConnectivityManager connectivity =
+ (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo info = connectivity.getActiveNetworkInfo();
- // no connection or background data disabled
- if (info == null || !info.isConnected())
- return false;
+ // no connection or background data disabled
+ if (info == null || !info.isConnected())
+ return false;
- return (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
- }
+ return (info.getType() != ConnectivityManager.TYPE_WIFI &&
+ info.getType() != ConnectivityManager.TYPE_WIMAX);
+ }
- @Override
- public void onReceive(Context context, Intent intent) {
+ @Override public void onReceive(Context context, Intent intent)
+ {
- // check if we are connected via 3g or wlan
- if (intent.getExtras() != null) {
- NetworkInfo info = (NetworkInfo) intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
+ // check if we are connected via 3g or wlan
+ if (intent.getExtras() != null)
+ {
+ NetworkInfo info =
+ (NetworkInfo)intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
- // are we connected at all?
- if (info != null && info.isConnected()) {
- // see if we are connected through 3G or WiFi
- Log.d("app", "Connected via type " + info.getTypeName());
- GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
- }
+ // are we connected at all?
+ if (info != null && info.isConnected())
+ {
+ // see if we are connected through 3G or WiFi
+ Log.d("app", "Connected via type " + info.getTypeName());
+ GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI &&
+ info.getType() != ConnectivityManager.TYPE_WIMAX);
+ }
- Log.v("NetworkState", info.toString());
- }
- }
+ Log.v("NetworkState", info.toString());
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/ScreenReceiver.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/ScreenReceiver.java
index f4b36fb07..d1330caf2 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/ScreenReceiver.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/ScreenReceiver.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.application;
@@ -14,16 +15,16 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-public class ScreenReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- GlobalApp app = (GlobalApp) context.getApplicationContext();
- Log.v("ScreenReceiver", "Received action: " + intent.getAction());
- if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
- app.startDisconnectTimer();
- else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
- app.cancelDisconnectTimer();
- }
+public class ScreenReceiver extends BroadcastReceiver
+{
+ @Override public void onReceive(Context context, Intent intent)
+ {
+ GlobalApp app = (GlobalApp)context.getApplicationContext();
+ Log.v("ScreenReceiver", "Received action: " + intent.getAction());
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
+ app.startDisconnectTimer();
+ else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
+ app.cancelDisconnectTimer();
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/SessionState.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/SessionState.java
index 75c901524..1e1431c5a 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/SessionState.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/application/SessionState.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.application;
@@ -19,93 +20,110 @@ import android.os.Parcelable;
import com.freerdp.freerdpcore.domain.BookmarkBase;
import com.freerdp.freerdpcore.services.LibFreeRDP;
-public class SessionState implements Parcelable {
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public SessionState createFromParcel(Parcel in) {
- return new SessionState(in);
- }
+public class SessionState implements Parcelable
+{
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public SessionState createFromParcel(Parcel in)
+ {
+ return new SessionState(in);
+ }
- @Override
- public SessionState[] newArray(int size) {
- return new SessionState[size];
- }
- };
- private long instance;
- private BookmarkBase bookmark;
- private Uri openUri;
- private BitmapDrawable surface;
- private LibFreeRDP.UIEventListener uiEventListener;
+ @Override public SessionState[] newArray(int size)
+ {
+ return new SessionState[size];
+ }
+ };
+ private long instance;
+ private BookmarkBase bookmark;
+ private Uri openUri;
+ private BitmapDrawable surface;
+ private LibFreeRDP.UIEventListener uiEventListener;
- public SessionState(Parcel parcel) {
- instance = parcel.readLong();
- bookmark = parcel.readParcelable(null);
- openUri = parcel.readParcelable(null);
+ public SessionState(Parcel parcel)
+ {
+ instance = parcel.readLong();
+ bookmark = parcel.readParcelable(null);
+ openUri = parcel.readParcelable(null);
- Bitmap bitmap = parcel.readParcelable(null);
- surface = new BitmapDrawable(bitmap);
- }
+ Bitmap bitmap = parcel.readParcelable(null);
+ surface = new BitmapDrawable(bitmap);
+ }
- public SessionState(long instance, BookmarkBase bookmark) {
- this.instance = instance;
- this.bookmark = bookmark;
- this.openUri = null;
- this.uiEventListener = null;
- }
+ public SessionState(long instance, BookmarkBase bookmark)
+ {
+ this.instance = instance;
+ this.bookmark = bookmark;
+ this.openUri = null;
+ this.uiEventListener = null;
+ }
- public SessionState(long instance, Uri openUri) {
- this.instance = instance;
- this.bookmark = null;
- this.openUri = openUri;
- this.uiEventListener = null;
- }
+ public SessionState(long instance, Uri openUri)
+ {
+ this.instance = instance;
+ this.bookmark = null;
+ this.openUri = openUri;
+ this.uiEventListener = null;
+ }
- public void connect(Context context) {
- if (bookmark != null) {
- LibFreeRDP.setConnectionInfo(context, instance, bookmark);
- } else {
- LibFreeRDP.setConnectionInfo(context, instance, openUri);
- }
- LibFreeRDP.connect(instance);
- }
+ public void connect(Context context)
+ {
+ if (bookmark != null)
+ {
+ LibFreeRDP.setConnectionInfo(context, instance, bookmark);
+ }
+ else
+ {
+ LibFreeRDP.setConnectionInfo(context, instance, openUri);
+ }
+ LibFreeRDP.connect(instance);
+ }
- public long getInstance() {
- return instance;
- }
+ public long getInstance()
+ {
+ return instance;
+ }
- public BookmarkBase getBookmark() {
- return bookmark;
- }
+ public BookmarkBase getBookmark()
+ {
+ return bookmark;
+ }
- public Uri getOpenUri() {
- return openUri;
- }
+ public Uri getOpenUri()
+ {
+ return openUri;
+ }
- public LibFreeRDP.UIEventListener getUIEventListener() {
- return uiEventListener;
- }
+ public LibFreeRDP.UIEventListener getUIEventListener()
+ {
+ return uiEventListener;
+ }
- public void setUIEventListener(LibFreeRDP.UIEventListener uiEventListener) {
- this.uiEventListener = uiEventListener;
- }
+ public void setUIEventListener(LibFreeRDP.UIEventListener uiEventListener)
+ {
+ this.uiEventListener = uiEventListener;
+ }
- public BitmapDrawable getSurface() {
- return surface;
- }
+ public BitmapDrawable getSurface()
+ {
+ return surface;
+ }
- public void setSurface(BitmapDrawable surface) {
- this.surface = surface;
- }
+ public void setSurface(BitmapDrawable surface)
+ {
+ this.surface = surface;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override public int describeContents()
+ {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeLong(instance);
- out.writeParcelable(bookmark, flags);
- out.writeParcelable(openUri, flags);
- out.writeParcelable(surface.getBitmap(), flags);
- }
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeLong(instance);
+ out.writeParcelable(bookmark, flags);
+ out.writeParcelable(openUri, flags);
+ out.writeParcelable(surface.getBitmap(), flags);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
index f45cc5035..171f279e8 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/BookmarkBase.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.domain;
@@ -17,953 +18,1046 @@ import com.freerdp.freerdpcore.application.GlobalApp;
import java.util.Locale;
-public class BookmarkBase implements Parcelable, Cloneable {
- public static final int TYPE_INVALID = -1;
- public static final int TYPE_MANUAL = 1;
- public static final int TYPE_QUICKCONNECT = 2;
- public static final int TYPE_PLACEHOLDER = 3;
- public static final int TYPE_CUSTOM_BASE = 1000;
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public BookmarkBase createFromParcel(Parcel in) {
- return new BookmarkBase(in);
- }
-
- @Override
- public BookmarkBase[] newArray(int size) {
- return new BookmarkBase[size];
- }
- };
- protected int type;
- private long id;
- private String label;
- private String username;
- private String password;
- private String domain;
- private ScreenSettings screenSettings;
- private PerformanceFlags performanceFlags;
- private AdvancedSettings advancedSettings;
- private DebugSettings debugSettings;
-
- public BookmarkBase(Parcel parcel) {
- type = parcel.readInt();
- id = parcel.readLong();
- label = parcel.readString();
- username = parcel.readString();
- password = parcel.readString();
- domain = parcel.readString();
-
- screenSettings = parcel.readParcelable(ScreenSettings.class
- .getClassLoader());
- performanceFlags = parcel.readParcelable(PerformanceFlags.class
- .getClassLoader());
- advancedSettings = parcel.readParcelable(AdvancedSettings.class
- .getClassLoader());
- debugSettings = parcel.readParcelable(DebugSettings.class
- .getClassLoader());
- }
-
- public BookmarkBase() {
- init();
- }
-
- private void init() {
- type = TYPE_INVALID;
- id = -1;
- label = "";
- username = "";
- password = "";
- domain = "";
-
- screenSettings = new ScreenSettings();
- performanceFlags = new PerformanceFlags();
- advancedSettings = new AdvancedSettings();
- debugSettings = new DebugSettings();
- }
-
- @SuppressWarnings("unchecked")
- public T get() {
- return (T) this;
- }
-
- public int getType() {
- return type;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public ScreenSettings getScreenSettings() {
- return screenSettings;
- }
-
- public void setScreenSettings(ScreenSettings screenSettings) {
- this.screenSettings = screenSettings;
- }
-
- public PerformanceFlags getPerformanceFlags() {
- return performanceFlags;
- }
-
- public void setPerformanceFlags(PerformanceFlags performanceFlags) {
- this.performanceFlags = performanceFlags;
- }
-
- public AdvancedSettings getAdvancedSettings() {
- return advancedSettings;
- }
-
- public void setAdvancedSettings(AdvancedSettings advancedSettings) {
- this.advancedSettings = advancedSettings;
- }
-
- public DebugSettings getDebugSettings() {
- return debugSettings;
- }
-
- public void setDebugSettings(DebugSettings debugSettings) {
- this.debugSettings = debugSettings;
- }
-
- public ScreenSettings getActiveScreenSettings() {
- return (GlobalApp.ConnectedTo3G && advancedSettings
- .getEnable3GSettings()) ? advancedSettings.getScreen3G()
- : screenSettings;
- }
-
- public PerformanceFlags getActivePerformanceFlags() {
- return (GlobalApp.ConnectedTo3G && advancedSettings
- .getEnable3GSettings()) ? advancedSettings.getPerformance3G()
- : performanceFlags;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(type);
- out.writeLong(id);
- out.writeString(label);
- out.writeString(username);
- out.writeString(password);
- out.writeString(domain);
-
- out.writeParcelable(screenSettings, flags);
- out.writeParcelable(performanceFlags, flags);
- out.writeParcelable(advancedSettings, flags);
- out.writeParcelable(debugSettings, flags);
- }
-
- // write to shared preferences
- public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
-
- Locale locale = Locale.ENGLISH;
-
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.clear();
- editor.putString("bookmark.label", label);
- editor.putString("bookmark.username", username);
- editor.putString("bookmark.password", password);
- editor.putString("bookmark.domain", domain);
-
- editor.putInt("bookmark.colors", screenSettings.getColors());
- editor.putString("bookmark.resolution", screenSettings
- .getResolutionString().toLowerCase(locale));
- editor.putInt("bookmark.width", screenSettings.getWidth());
- editor.putInt("bookmark.height", screenSettings.getHeight());
-
- editor.putBoolean("bookmark.perf_remotefx",
- performanceFlags.getRemoteFX());
- editor.putBoolean("bookmark.perf_gfx",
- performanceFlags.getGfx());
- editor.putBoolean("bookmark.perf_gfx_h264",
- performanceFlags.getH264());
- editor.putBoolean("bookmark.perf_wallpaper",
- performanceFlags.getWallpaper());
- editor.putBoolean("bookmark.perf_font_smoothing",
- performanceFlags.getFontSmoothing());
- editor.putBoolean("bookmark.perf_desktop_composition",
- performanceFlags.getDesktopComposition());
- editor.putBoolean("bookmark.perf_window_dragging",
- performanceFlags.getFullWindowDrag());
- editor.putBoolean("bookmark.perf_menu_animation",
- performanceFlags.getMenuAnimations());
- editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
-
- editor.putBoolean("bookmark.enable_3g_settings",
- advancedSettings.getEnable3GSettings());
-
- editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G()
- .getColors());
- editor.putString("bookmark.resolution_3g", advancedSettings
- .getScreen3G().getResolutionString().toLowerCase(locale));
- editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G()
- .getWidth());
- editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G()
- .getHeight());
-
- editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings
- .getPerformance3G().getRemoteFX());
- editor.putBoolean("bookmark.perf_gfx_3g", advancedSettings
- .getPerformance3G().getGfx());
- editor.putBoolean("bookmark.perf_gfx_h264_3g", advancedSettings
- .getPerformance3G().getH264());
- editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings
- .getPerformance3G().getWallpaper());
- editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings
- .getPerformance3G().getFontSmoothing());
- editor.putBoolean("bookmark.perf_desktop_composition_3g",
- advancedSettings.getPerformance3G().getDesktopComposition());
- editor.putBoolean("bookmark.perf_window_dragging_3g", advancedSettings
- .getPerformance3G().getFullWindowDrag());
- editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings
- .getPerformance3G().getMenuAnimations());
- editor.putBoolean("bookmark.perf_themes_3g", advancedSettings
- .getPerformance3G().getTheming());
-
- editor.putBoolean("bookmark.redirect_sdcard",
- advancedSettings.getRedirectSDCard());
- editor.putInt("bookmark.redirect_sound",
- advancedSettings.getRedirectSound());
- editor.putBoolean("bookmark.redirect_microphone",
- advancedSettings.getRedirectMicrophone());
- editor.putInt("bookmark.security", advancedSettings.getSecurity());
- editor.putString("bookmark.remote_program",
- advancedSettings.getRemoteProgram());
- editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
- editor.putBoolean("bookmark.console_mode",
- advancedSettings.getConsoleMode());
-
- editor.putBoolean("bookmark.async_channel", debugSettings.getAsyncChannel());
- editor.putBoolean("bookmark.async_input", debugSettings.getAsyncInput());
- editor.putBoolean("bookmark.async_update", debugSettings.getAsyncUpdate());
- editor.putString("bookmark.debug_level",
- debugSettings.getDebugLevel());
-
- editor.apply();
- }
-
- // read from shared preferences
- public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
- label = sharedPrefs.getString("bookmark.label", "");
- username = sharedPrefs.getString("bookmark.username", "");
- password = sharedPrefs.getString("bookmark.password", "");
- domain = sharedPrefs.getString("bookmark.domain", "");
-
- screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16));
- screenSettings.setResolution(
- sharedPrefs.getString("bookmark.resolution", "automatic"),
- sharedPrefs.getInt("bookmark.width", 800),
- sharedPrefs.getInt("bookmark.height", 600));
-
- performanceFlags.setRemoteFX(sharedPrefs.getBoolean(
- "bookmark.perf_remotefx", false));
- performanceFlags.setGfx(sharedPrefs.getBoolean(
- "bookmark.perf_gfx", false));
- performanceFlags.setH264(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_h264", false));
- performanceFlags.setWallpaper(sharedPrefs.getBoolean(
- "bookmark.perf_wallpaper", false));
- performanceFlags.setFontSmoothing(sharedPrefs.getBoolean(
- "bookmark.perf_font_smoothing", false));
- performanceFlags.setDesktopComposition(sharedPrefs.getBoolean(
- "bookmark.perf_desktop_composition", false));
- performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean(
- "bookmark.perf_window_dragging", false));
- performanceFlags.setMenuAnimations(sharedPrefs.getBoolean(
- "bookmark.perf_menu_animation", false));
- performanceFlags.setTheming(sharedPrefs.getBoolean(
- "bookmark.perf_themes", false));
-
- advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean(
- "bookmark.enable_3g_settings", false));
-
- advancedSettings.getScreen3G().setColors(
- sharedPrefs.getInt("bookmark.colors_3g", 16));
- advancedSettings.getScreen3G().setResolution(
- sharedPrefs.getString("bookmark.resolution_3g", "automatic"),
- sharedPrefs.getInt("bookmark.width_3g", 800),
- sharedPrefs.getInt("bookmark.height_3g", 600));
-
- advancedSettings.getPerformance3G().setRemoteFX(
- sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false));
- advancedSettings.getPerformance3G().setGfx(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_3g", false));
- advancedSettings.getPerformance3G().setH264(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_h264_3g", false));
- advancedSettings.getPerformance3G().setWallpaper(
- sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false));
- advancedSettings.getPerformance3G().setFontSmoothing(
- sharedPrefs
- .getBoolean("bookmark.perf_font_smoothing_3g", false));
- advancedSettings.getPerformance3G().setDesktopComposition(
- sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g",
- false));
- advancedSettings.getPerformance3G().setFullWindowDrag(
- sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g",
- false));
- advancedSettings.getPerformance3G().setMenuAnimations(
- sharedPrefs
- .getBoolean("bookmark.perf_menu_animation_3g", false));
- advancedSettings.getPerformance3G().setTheming(
- sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
-
- advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
- advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0));
- advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false));
- advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
- advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
- advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
- advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false));
-
- debugSettings.setAsyncChannel(sharedPrefs.getBoolean("bookmark.async_channel", true));
- debugSettings.setAsyncInput(sharedPrefs.getBoolean("bookmark.async_input", true));
- debugSettings.setAsyncUpdate(sharedPrefs.getBoolean("bookmark.async_update", true));
- debugSettings.setDebugLevel(sharedPrefs.getString("bookmark.debug_level", "INFO"));
- }
-
- // Cloneable
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- // performance flags
- public static class PerformanceFlags implements Parcelable {
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public PerformanceFlags createFromParcel(Parcel in) {
- return new PerformanceFlags(in);
- }
-
- @Override
- public PerformanceFlags[] newArray(int size) {
- return new PerformanceFlags[size];
- }
- };
- private boolean remotefx;
- private boolean gfx;
- private boolean h264;
- private boolean wallpaper;
- private boolean theming;
- private boolean fullWindowDrag;
- private boolean menuAnimations;
- private boolean fontSmoothing;
- private boolean desktopComposition;
-
- public PerformanceFlags() {
- remotefx = false;
- gfx = false;
- h264 = false;
- wallpaper = false;
- theming = false;
- fullWindowDrag = false;
- menuAnimations = false;
- fontSmoothing = false;
- desktopComposition = false;
- }
-
- public PerformanceFlags(Parcel parcel) {
- remotefx = parcel.readInt() == 1;
- gfx = parcel.readInt() == 1;
- h264 = parcel.readInt() == 1;
- wallpaper = parcel.readInt() == 1;
- theming = parcel.readInt() == 1;
- fullWindowDrag = (parcel.readInt() == 1);
- menuAnimations = parcel.readInt() == 1;
- fontSmoothing = parcel.readInt() == 1;
- desktopComposition = parcel.readInt() == 1;
- }
-
- public boolean getRemoteFX() {
- return remotefx;
- }
-
- public void setRemoteFX(boolean remotefx) {
- this.remotefx = remotefx;
- }
-
- public boolean getGfx() {
- return gfx;
- }
-
- public void setGfx(boolean gfx) {
- this.gfx = gfx;
- }
-
- public boolean getH264() {
- return h264;
- }
-
- public void setH264(boolean h264) {
- this.h264 = h264;
- }
-
- public boolean getWallpaper() {
- return wallpaper;
- }
-
- public void setWallpaper(boolean wallpaper) {
- this.wallpaper = wallpaper;
- }
-
- public boolean getTheming() {
- return theming;
- }
-
- public void setTheming(boolean theming) {
- this.theming = theming;
- }
-
- public boolean getFullWindowDrag() {
- return fullWindowDrag;
- }
-
- public void setFullWindowDrag(boolean fullWindowDrag) {
- this.fullWindowDrag = fullWindowDrag;
- }
-
- public boolean getMenuAnimations() {
- return menuAnimations;
- }
-
- public void setMenuAnimations(boolean menuAnimations) {
- this.menuAnimations = menuAnimations;
- }
-
- public boolean getFontSmoothing() {
- return fontSmoothing;
- }
-
- public void setFontSmoothing(boolean fontSmoothing) {
- this.fontSmoothing = fontSmoothing;
- }
-
- public boolean getDesktopComposition() {
- return desktopComposition;
- }
-
- public void setDesktopComposition(boolean desktopComposition) {
- this.desktopComposition = desktopComposition;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(remotefx ? 1 : 0);
- out.writeInt(gfx ? 1 : 0);
- out.writeInt(h264 ? 1 : 0);
- out.writeInt(wallpaper ? 1 : 0);
- out.writeInt(theming ? 1 : 0);
- out.writeInt(fullWindowDrag ? 1 : 0);
- out.writeInt(menuAnimations ? 1 : 0);
- out.writeInt(fontSmoothing ? 1 : 0);
- out.writeInt(desktopComposition ? 1 : 0);
- }
- }
-
- // Screen Settings class
- public static class ScreenSettings implements Parcelable {
- public static final int FITSCREEN = -2;
- public static final int AUTOMATIC = -1;
- public static final int CUSTOM = 0;
- public static final int PREDEFINED = 1;
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public ScreenSettings createFromParcel(Parcel in) {
- return new ScreenSettings(in);
- }
-
- @Override
- public ScreenSettings[] newArray(int size) {
- return new ScreenSettings[size];
- }
- };
- private int resolution;
- private int colors;
- private int width;
- private int height;
-
- public ScreenSettings() {
- init();
- }
-
- public ScreenSettings(Parcel parcel) {
- resolution = parcel.readInt();
- colors = parcel.readInt();
- width = parcel.readInt();
- height = parcel.readInt();
- }
-
- private void validate() {
- switch (colors) {
- case 32:
- case 24:
- case 16:
- case 15:
- case 8:
- break;
- default:
- colors = 32;
- break;
- }
-
- if ((width <= 0) || (width > 65536)) {
- width = 1024;
- }
-
- if ((height <= 0) || (height > 65536)) {
- height = 768;
- }
-
- switch(resolution) {
- case FITSCREEN:
- case AUTOMATIC:
- case CUSTOM:
- case PREDEFINED:
- break;
- default:
- resolution = AUTOMATIC;
- break;
- }
- }
-
- private void init() {
- resolution = AUTOMATIC;
- colors = 16;
- width = 0;
- height = 0;
- }
-
- public void setResolution(String resolution, int width, int height) {
- if (resolution.contains("x")) {
- String[] dimensions = resolution.split("x");
- this.width = Integer.valueOf(dimensions[0]);
- this.height = Integer.valueOf(dimensions[1]);
- this.resolution = PREDEFINED;
- } else if (resolution.equalsIgnoreCase("custom")) {
- this.width = width;
- this.height = height;
- this.resolution = CUSTOM;
- } else if (resolution.equalsIgnoreCase("fitscreen")) {
- this.width = this.height = 0;
- this.resolution = FITSCREEN;
- } else {
- this.width = this.height = 0;
- this.resolution = AUTOMATIC;
- }
- }
-
- public int getResolution() {
- return resolution;
- }
-
- public void setResolution(int resolution) {
- this.resolution = resolution;
-
- if (resolution == AUTOMATIC || resolution == FITSCREEN) {
- width = 0;
- height = 0;
- }
- }
-
- public String getResolutionString() {
- if (isPredefined())
- return (width + "x" + height);
-
- return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic"
- : "custom");
- }
-
- public boolean isPredefined() {
- validate();
- return (resolution == PREDEFINED);
- }
-
- public boolean isAutomatic() {
- validate();
- return (resolution == AUTOMATIC);
- }
-
- public boolean isFitScreen() {
- validate();
- return (resolution == FITSCREEN);
- }
-
- public boolean isCustom() {
- validate();
- return (resolution == CUSTOM);
- }
-
- public int getWidth() {
- validate();
- return width;
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public int getHeight() {
- validate();
- return height;
- }
-
- public void setHeight(int height) {
- this.height = height;
- }
-
- public int getColors() {
- validate();
- return colors;
- }
-
- public void setColors(int colors) {
- this.colors = colors;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(resolution);
- out.writeInt(colors);
- out.writeInt(width);
- out.writeInt(height);
- }
- }
-
- public static class DebugSettings implements Parcelable {
-
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public DebugSettings createFromParcel(Parcel in) {
- return new DebugSettings(in);
- }
-
- @Override
- public DebugSettings[] newArray(int size) {
- return new DebugSettings[size];
- }
- };
- private String debug;
- private boolean asyncChannel;
- private boolean asyncTransport;
- private boolean asyncInput;
- private boolean asyncUpdate;
-
- public DebugSettings() {
- init();
- }
-
- // Session Settings
- public DebugSettings(Parcel parcel) {
- asyncChannel = parcel.readInt() == 1;
- asyncTransport = parcel.readInt() == 1;
- asyncInput = parcel.readInt() == 1;
- asyncUpdate = parcel.readInt() == 1;
- debug = parcel.readString();
- }
-
- private void init() {
- debug = "INFO";
- asyncChannel = true;
- asyncTransport = false;
- asyncInput = true;
- asyncUpdate = true;
- }
-
- private void validate() {
- final String[] levels = {
- "OFF",
- "FATAL",
- "ERROR",
- "WARN",
- "INFO",
- "DEBUG",
- "TRACE"
- };
-
- for (String level : levels) {
- if (level.equalsIgnoreCase(this.debug)) {
- return;
- }
- }
-
- this.debug = "INFO";
- }
-
- public String getDebugLevel() {
- validate();
- return debug;
- }
-
- public void setDebugLevel(String debug) {
- this.debug = debug;
- }
-
- public boolean getAsyncUpdate() {
- return asyncUpdate;
- }
-
- public void setAsyncUpdate(boolean enabled) {
- asyncUpdate = enabled;
- }
-
- public boolean getAsyncInput() {
- return asyncInput;
- }
-
- public void setAsyncInput(boolean enabled) {
- asyncInput = enabled;
- }
-
- public boolean getAsyncChannel() {
- return asyncChannel;
- }
-
- public void setAsyncChannel(boolean enabled) {
- asyncChannel = enabled;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(asyncChannel ? 1 : 0);
- out.writeInt(asyncTransport ? 1 : 0);
- out.writeInt(asyncInput ? 1 : 0);
- out.writeInt(asyncUpdate ? 1 : 0);
- out.writeString(debug);
- }
- }
-
- // Session Settings
- public static class AdvancedSettings implements Parcelable {
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public AdvancedSettings createFromParcel(Parcel in) {
- return new AdvancedSettings(in);
- }
-
- @Override
- public AdvancedSettings[] newArray(int size) {
- return new AdvancedSettings[size];
- }
- };
- private boolean enable3GSettings;
- private ScreenSettings screen3G;
- private PerformanceFlags performance3G;
- private boolean redirectSDCard;
- private int redirectSound;
- private boolean redirectMicrophone;
- private int security;
- private boolean consoleMode;
- private String remoteProgram;
- private String workDir;
-
- public AdvancedSettings() {
- init();
- }
-
- public AdvancedSettings(Parcel parcel) {
- enable3GSettings = parcel.readInt() == 1;
- screen3G = parcel.readParcelable(ScreenSettings.class
- .getClassLoader());
- performance3G = parcel.readParcelable(PerformanceFlags.class
- .getClassLoader());
- redirectSDCard = parcel.readInt() == 1;
- redirectSound = parcel.readInt();
- redirectMicrophone = parcel.readInt() == 1;
- security = parcel.readInt();
- consoleMode = parcel.readInt() == 1;
- remoteProgram = parcel.readString();
- workDir = parcel.readString();
- }
-
- private void init() {
- enable3GSettings = false;
- screen3G = new ScreenSettings();
- performance3G = new PerformanceFlags();
- redirectSDCard = false;
- redirectSound = 0;
- redirectMicrophone = false;
- security = 0;
- consoleMode = false;
- remoteProgram = "";
- workDir = "";
- }
-
- private void validate() {
- switch (redirectSound) {
- case 0:
- case 1:
- case 2:
- break;
- default:
- redirectSound = 0;
- break;
- }
-
- switch (security) {
- case 0:
- case 1:
- case 2:
- case 3:
- break;
- default:
- security = 0;
- break;
- }
- }
-
- public boolean getEnable3GSettings() {
- return enable3GSettings;
- }
-
- public void setEnable3GSettings(boolean enable3GSettings) {
- this.enable3GSettings = enable3GSettings;
- }
-
- public ScreenSettings getScreen3G() {
- return screen3G;
- }
-
- public void setScreen3G(ScreenSettings screen3G) {
- this.screen3G = screen3G;
- }
-
- public PerformanceFlags getPerformance3G() {
- return performance3G;
- }
-
- public void setPerformance3G(PerformanceFlags performance3G) {
- this.performance3G = performance3G;
- }
-
- public boolean getRedirectSDCard() {
- return redirectSDCard;
- }
-
- public void setRedirectSDCard(boolean redirectSDCard) {
- this.redirectSDCard = redirectSDCard;
- }
-
- public int getRedirectSound() {
- validate();
- return redirectSound;
- }
-
- public void setRedirectSound(int redirect) {
- this.redirectSound = redirect;
- }
-
- public boolean getRedirectMicrophone() {
- return redirectMicrophone;
- }
-
- public void setRedirectMicrophone(boolean redirect) {
- this.redirectMicrophone = redirect;
- }
-
- public int getSecurity() {
- validate();
- return security;
- }
-
- public void setSecurity(int security) {
- this.security = security;
- }
-
- public boolean getConsoleMode() {
- return consoleMode;
- }
-
- public void setConsoleMode(boolean consoleMode) {
- this.consoleMode = consoleMode;
- }
-
- public String getRemoteProgram() {
- return remoteProgram;
- }
-
- public void setRemoteProgram(String remoteProgram) {
- this.remoteProgram = remoteProgram;
- }
-
- public String getWorkDir() {
- return workDir;
- }
-
- public void setWorkDir(String workDir) {
- this.workDir = workDir;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(enable3GSettings ? 1 : 0);
- out.writeParcelable(screen3G, flags);
- out.writeParcelable(performance3G, flags);
- out.writeInt(redirectSDCard ? 1 : 0);
- out.writeInt(redirectSound);
- out.writeInt(redirectMicrophone ? 1 : 0);
- out.writeInt(security);
- out.writeInt(consoleMode ? 1 : 0);
- out.writeString(remoteProgram);
- out.writeString(workDir);
- }
- }
+public class BookmarkBase implements Parcelable, Cloneable
+{
+ public static final int TYPE_INVALID = -1;
+ public static final int TYPE_MANUAL = 1;
+ public static final int TYPE_QUICKCONNECT = 2;
+ public static final int TYPE_PLACEHOLDER = 3;
+ public static final int TYPE_CUSTOM_BASE = 1000;
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public BookmarkBase createFromParcel(Parcel in)
+ {
+ return new BookmarkBase(in);
+ }
+
+ @Override public BookmarkBase[] newArray(int size)
+ {
+ return new BookmarkBase[size];
+ }
+ };
+ protected int type;
+ private long id;
+ private String label;
+ private String username;
+ private String password;
+ private String domain;
+ private ScreenSettings screenSettings;
+ private PerformanceFlags performanceFlags;
+ private AdvancedSettings advancedSettings;
+ private DebugSettings debugSettings;
+
+ public BookmarkBase(Parcel parcel)
+ {
+ type = parcel.readInt();
+ id = parcel.readLong();
+ label = parcel.readString();
+ username = parcel.readString();
+ password = parcel.readString();
+ domain = parcel.readString();
+
+ screenSettings = parcel.readParcelable(ScreenSettings.class.getClassLoader());
+ performanceFlags = parcel.readParcelable(PerformanceFlags.class.getClassLoader());
+ advancedSettings = parcel.readParcelable(AdvancedSettings.class.getClassLoader());
+ debugSettings = parcel.readParcelable(DebugSettings.class.getClassLoader());
+ }
+
+ public BookmarkBase()
+ {
+ init();
+ }
+
+ private void init()
+ {
+ type = TYPE_INVALID;
+ id = -1;
+ label = "";
+ username = "";
+ password = "";
+ domain = "";
+
+ screenSettings = new ScreenSettings();
+ performanceFlags = new PerformanceFlags();
+ advancedSettings = new AdvancedSettings();
+ debugSettings = new DebugSettings();
+ }
+
+ @SuppressWarnings("unchecked") public T get()
+ {
+ return (T)this;
+ }
+
+ public int getType()
+ {
+ return type;
+ }
+
+ public long getId()
+ {
+ return id;
+ }
+
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
+
+ public ScreenSettings getScreenSettings()
+ {
+ return screenSettings;
+ }
+
+ public void setScreenSettings(ScreenSettings screenSettings)
+ {
+ this.screenSettings = screenSettings;
+ }
+
+ public PerformanceFlags getPerformanceFlags()
+ {
+ return performanceFlags;
+ }
+
+ public void setPerformanceFlags(PerformanceFlags performanceFlags)
+ {
+ this.performanceFlags = performanceFlags;
+ }
+
+ public AdvancedSettings getAdvancedSettings()
+ {
+ return advancedSettings;
+ }
+
+ public void setAdvancedSettings(AdvancedSettings advancedSettings)
+ {
+ this.advancedSettings = advancedSettings;
+ }
+
+ public DebugSettings getDebugSettings()
+ {
+ return debugSettings;
+ }
+
+ public void setDebugSettings(DebugSettings debugSettings)
+ {
+ this.debugSettings = debugSettings;
+ }
+
+ public ScreenSettings getActiveScreenSettings()
+ {
+ return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings())
+ ? advancedSettings.getScreen3G()
+ : screenSettings;
+ }
+
+ public PerformanceFlags getActivePerformanceFlags()
+ {
+ return (GlobalApp.ConnectedTo3G && advancedSettings.getEnable3GSettings())
+ ? advancedSettings.getPerformance3G()
+ : performanceFlags;
+ }
+
+ @Override public int describeContents()
+ {
+ return 0;
+ }
+
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeInt(type);
+ out.writeLong(id);
+ out.writeString(label);
+ out.writeString(username);
+ out.writeString(password);
+ out.writeString(domain);
+
+ out.writeParcelable(screenSettings, flags);
+ out.writeParcelable(performanceFlags, flags);
+ out.writeParcelable(advancedSettings, flags);
+ out.writeParcelable(debugSettings, flags);
+ }
+
+ // write to shared preferences
+ public void writeToSharedPreferences(SharedPreferences sharedPrefs)
+ {
+
+ Locale locale = Locale.ENGLISH;
+
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.clear();
+ editor.putString("bookmark.label", label);
+ editor.putString("bookmark.username", username);
+ editor.putString("bookmark.password", password);
+ editor.putString("bookmark.domain", domain);
+
+ editor.putInt("bookmark.colors", screenSettings.getColors());
+ editor.putString("bookmark.resolution",
+ screenSettings.getResolutionString().toLowerCase(locale));
+ editor.putInt("bookmark.width", screenSettings.getWidth());
+ editor.putInt("bookmark.height", screenSettings.getHeight());
+
+ editor.putBoolean("bookmark.perf_remotefx", performanceFlags.getRemoteFX());
+ editor.putBoolean("bookmark.perf_gfx", performanceFlags.getGfx());
+ editor.putBoolean("bookmark.perf_gfx_h264", performanceFlags.getH264());
+ editor.putBoolean("bookmark.perf_wallpaper", performanceFlags.getWallpaper());
+ editor.putBoolean("bookmark.perf_font_smoothing", performanceFlags.getFontSmoothing());
+ editor.putBoolean("bookmark.perf_desktop_composition",
+ performanceFlags.getDesktopComposition());
+ editor.putBoolean("bookmark.perf_window_dragging", performanceFlags.getFullWindowDrag());
+ editor.putBoolean("bookmark.perf_menu_animation", performanceFlags.getMenuAnimations());
+ editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
+
+ editor.putBoolean("bookmark.enable_3g_settings", advancedSettings.getEnable3GSettings());
+
+ editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G().getColors());
+ editor.putString("bookmark.resolution_3g",
+ advancedSettings.getScreen3G().getResolutionString().toLowerCase(locale));
+ editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G().getWidth());
+ editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G().getHeight());
+
+ editor.putBoolean("bookmark.perf_remotefx_3g",
+ advancedSettings.getPerformance3G().getRemoteFX());
+ editor.putBoolean("bookmark.perf_gfx_3g", advancedSettings.getPerformance3G().getGfx());
+ editor.putBoolean("bookmark.perf_gfx_h264_3g",
+ advancedSettings.getPerformance3G().getH264());
+ editor.putBoolean("bookmark.perf_wallpaper_3g",
+ advancedSettings.getPerformance3G().getWallpaper());
+ editor.putBoolean("bookmark.perf_font_smoothing_3g",
+ advancedSettings.getPerformance3G().getFontSmoothing());
+ editor.putBoolean("bookmark.perf_desktop_composition_3g",
+ advancedSettings.getPerformance3G().getDesktopComposition());
+ editor.putBoolean("bookmark.perf_window_dragging_3g",
+ advancedSettings.getPerformance3G().getFullWindowDrag());
+ editor.putBoolean("bookmark.perf_menu_animation_3g",
+ advancedSettings.getPerformance3G().getMenuAnimations());
+ editor.putBoolean("bookmark.perf_themes_3g",
+ advancedSettings.getPerformance3G().getTheming());
+
+ editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard());
+ editor.putInt("bookmark.redirect_sound", advancedSettings.getRedirectSound());
+ editor.putBoolean("bookmark.redirect_microphone", advancedSettings.getRedirectMicrophone());
+ editor.putInt("bookmark.security", advancedSettings.getSecurity());
+ editor.putString("bookmark.remote_program", advancedSettings.getRemoteProgram());
+ editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
+ editor.putBoolean("bookmark.console_mode", advancedSettings.getConsoleMode());
+
+ editor.putBoolean("bookmark.async_channel", debugSettings.getAsyncChannel());
+ editor.putBoolean("bookmark.async_input", debugSettings.getAsyncInput());
+ editor.putBoolean("bookmark.async_update", debugSettings.getAsyncUpdate());
+ editor.putString("bookmark.debug_level", debugSettings.getDebugLevel());
+
+ editor.apply();
+ }
+
+ // read from shared preferences
+ public void readFromSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ label = sharedPrefs.getString("bookmark.label", "");
+ username = sharedPrefs.getString("bookmark.username", "");
+ password = sharedPrefs.getString("bookmark.password", "");
+ domain = sharedPrefs.getString("bookmark.domain", "");
+
+ screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16));
+ screenSettings.setResolution(sharedPrefs.getString("bookmark.resolution", "automatic"),
+ sharedPrefs.getInt("bookmark.width", 800),
+ sharedPrefs.getInt("bookmark.height", 600));
+
+ performanceFlags.setRemoteFX(sharedPrefs.getBoolean("bookmark.perf_remotefx", false));
+ performanceFlags.setGfx(sharedPrefs.getBoolean("bookmark.perf_gfx", false));
+ performanceFlags.setH264(sharedPrefs.getBoolean("bookmark.perf_gfx_h264", false));
+ performanceFlags.setWallpaper(sharedPrefs.getBoolean("bookmark.perf_wallpaper", false));
+ performanceFlags.setFontSmoothing(
+ sharedPrefs.getBoolean("bookmark.perf_font_smoothing", false));
+ performanceFlags.setDesktopComposition(
+ sharedPrefs.getBoolean("bookmark.perf_desktop_composition", false));
+ performanceFlags.setFullWindowDrag(
+ sharedPrefs.getBoolean("bookmark.perf_window_dragging", false));
+ performanceFlags.setMenuAnimations(
+ sharedPrefs.getBoolean("bookmark.perf_menu_animation", false));
+ performanceFlags.setTheming(sharedPrefs.getBoolean("bookmark.perf_themes", false));
+
+ advancedSettings.setEnable3GSettings(
+ sharedPrefs.getBoolean("bookmark.enable_3g_settings", false));
+
+ advancedSettings.getScreen3G().setColors(sharedPrefs.getInt("bookmark.colors_3g", 16));
+ advancedSettings.getScreen3G().setResolution(
+ sharedPrefs.getString("bookmark.resolution_3g", "automatic"),
+ sharedPrefs.getInt("bookmark.width_3g", 800),
+ sharedPrefs.getInt("bookmark.height_3g", 600));
+
+ advancedSettings.getPerformance3G().setRemoteFX(
+ sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false));
+ advancedSettings.getPerformance3G().setGfx(
+ sharedPrefs.getBoolean("bookmark.perf_gfx_3g", false));
+ advancedSettings.getPerformance3G().setH264(
+ sharedPrefs.getBoolean("bookmark.perf_gfx_h264_3g", false));
+ advancedSettings.getPerformance3G().setWallpaper(
+ sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false));
+ advancedSettings.getPerformance3G().setFontSmoothing(
+ sharedPrefs.getBoolean("bookmark.perf_font_smoothing_3g", false));
+ advancedSettings.getPerformance3G().setDesktopComposition(
+ sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g", false));
+ advancedSettings.getPerformance3G().setFullWindowDrag(
+ sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g", false));
+ advancedSettings.getPerformance3G().setMenuAnimations(
+ sharedPrefs.getBoolean("bookmark.perf_menu_animation_3g", false));
+ advancedSettings.getPerformance3G().setTheming(
+ sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
+
+ advancedSettings.setRedirectSDCard(
+ sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
+ advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0));
+ advancedSettings.setRedirectMicrophone(
+ sharedPrefs.getBoolean("bookmark.redirect_microphone", false));
+ advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
+ advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
+ advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
+ advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false));
+
+ debugSettings.setAsyncChannel(sharedPrefs.getBoolean("bookmark.async_channel", true));
+ debugSettings.setAsyncInput(sharedPrefs.getBoolean("bookmark.async_input", true));
+ debugSettings.setAsyncUpdate(sharedPrefs.getBoolean("bookmark.async_update", true));
+ debugSettings.setDebugLevel(sharedPrefs.getString("bookmark.debug_level", "INFO"));
+ }
+
+ // Cloneable
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ return null;
+ }
+ }
+
+ // performance flags
+ public static class PerformanceFlags implements Parcelable
+ {
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public PerformanceFlags createFromParcel(Parcel in)
+ {
+ return new PerformanceFlags(in);
+ }
+
+ @Override public PerformanceFlags[] newArray(int size)
+ {
+ return new PerformanceFlags[size];
+ }
+ };
+ private boolean remotefx;
+ private boolean gfx;
+ private boolean h264;
+ private boolean wallpaper;
+ private boolean theming;
+ private boolean fullWindowDrag;
+ private boolean menuAnimations;
+ private boolean fontSmoothing;
+ private boolean desktopComposition;
+
+ public PerformanceFlags()
+ {
+ remotefx = false;
+ gfx = false;
+ h264 = false;
+ wallpaper = false;
+ theming = false;
+ fullWindowDrag = false;
+ menuAnimations = false;
+ fontSmoothing = false;
+ desktopComposition = false;
+ }
+
+ public PerformanceFlags(Parcel parcel)
+ {
+ remotefx = parcel.readInt() == 1;
+ gfx = parcel.readInt() == 1;
+ h264 = parcel.readInt() == 1;
+ wallpaper = parcel.readInt() == 1;
+ theming = parcel.readInt() == 1;
+ fullWindowDrag = (parcel.readInt() == 1);
+ menuAnimations = parcel.readInt() == 1;
+ fontSmoothing = parcel.readInt() == 1;
+ desktopComposition = parcel.readInt() == 1;
+ }
+
+ public boolean getRemoteFX()
+ {
+ return remotefx;
+ }
+
+ public void setRemoteFX(boolean remotefx)
+ {
+ this.remotefx = remotefx;
+ }
+
+ public boolean getGfx()
+ {
+ return gfx;
+ }
+
+ public void setGfx(boolean gfx)
+ {
+ this.gfx = gfx;
+ }
+
+ public boolean getH264()
+ {
+ return h264;
+ }
+
+ public void setH264(boolean h264)
+ {
+ this.h264 = h264;
+ }
+
+ public boolean getWallpaper()
+ {
+ return wallpaper;
+ }
+
+ public void setWallpaper(boolean wallpaper)
+ {
+ this.wallpaper = wallpaper;
+ }
+
+ public boolean getTheming()
+ {
+ return theming;
+ }
+
+ public void setTheming(boolean theming)
+ {
+ this.theming = theming;
+ }
+
+ public boolean getFullWindowDrag()
+ {
+ return fullWindowDrag;
+ }
+
+ public void setFullWindowDrag(boolean fullWindowDrag)
+ {
+ this.fullWindowDrag = fullWindowDrag;
+ }
+
+ public boolean getMenuAnimations()
+ {
+ return menuAnimations;
+ }
+
+ public void setMenuAnimations(boolean menuAnimations)
+ {
+ this.menuAnimations = menuAnimations;
+ }
+
+ public boolean getFontSmoothing()
+ {
+ return fontSmoothing;
+ }
+
+ public void setFontSmoothing(boolean fontSmoothing)
+ {
+ this.fontSmoothing = fontSmoothing;
+ }
+
+ public boolean getDesktopComposition()
+ {
+ return desktopComposition;
+ }
+
+ public void setDesktopComposition(boolean desktopComposition)
+ {
+ this.desktopComposition = desktopComposition;
+ }
+
+ @Override public int describeContents()
+ {
+ return 0;
+ }
+
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeInt(remotefx ? 1 : 0);
+ out.writeInt(gfx ? 1 : 0);
+ out.writeInt(h264 ? 1 : 0);
+ out.writeInt(wallpaper ? 1 : 0);
+ out.writeInt(theming ? 1 : 0);
+ out.writeInt(fullWindowDrag ? 1 : 0);
+ out.writeInt(menuAnimations ? 1 : 0);
+ out.writeInt(fontSmoothing ? 1 : 0);
+ out.writeInt(desktopComposition ? 1 : 0);
+ }
+ }
+
+ // Screen Settings class
+ public static class ScreenSettings implements Parcelable
+ {
+ public static final int FITSCREEN = -2;
+ public static final int AUTOMATIC = -1;
+ public static final int CUSTOM = 0;
+ public static final int PREDEFINED = 1;
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public ScreenSettings createFromParcel(Parcel in)
+ {
+ return new ScreenSettings(in);
+ }
+
+ @Override public ScreenSettings[] newArray(int size)
+ {
+ return new ScreenSettings[size];
+ }
+ };
+ private int resolution;
+ private int colors;
+ private int width;
+ private int height;
+
+ public ScreenSettings()
+ {
+ init();
+ }
+
+ public ScreenSettings(Parcel parcel)
+ {
+ resolution = parcel.readInt();
+ colors = parcel.readInt();
+ width = parcel.readInt();
+ height = parcel.readInt();
+ }
+
+ private void validate()
+ {
+ switch (colors)
+ {
+ case 32:
+ case 24:
+ case 16:
+ case 15:
+ case 8:
+ break;
+ default:
+ colors = 32;
+ break;
+ }
+
+ if ((width <= 0) || (width > 65536))
+ {
+ width = 1024;
+ }
+
+ if ((height <= 0) || (height > 65536))
+ {
+ height = 768;
+ }
+
+ switch (resolution)
+ {
+ case FITSCREEN:
+ case AUTOMATIC:
+ case CUSTOM:
+ case PREDEFINED:
+ break;
+ default:
+ resolution = AUTOMATIC;
+ break;
+ }
+ }
+
+ private void init()
+ {
+ resolution = AUTOMATIC;
+ colors = 16;
+ width = 0;
+ height = 0;
+ }
+
+ public void setResolution(String resolution, int width, int height)
+ {
+ if (resolution.contains("x"))
+ {
+ String[] dimensions = resolution.split("x");
+ this.width = Integer.valueOf(dimensions[0]);
+ this.height = Integer.valueOf(dimensions[1]);
+ this.resolution = PREDEFINED;
+ }
+ else if (resolution.equalsIgnoreCase("custom"))
+ {
+ this.width = width;
+ this.height = height;
+ this.resolution = CUSTOM;
+ }
+ else if (resolution.equalsIgnoreCase("fitscreen"))
+ {
+ this.width = this.height = 0;
+ this.resolution = FITSCREEN;
+ }
+ else
+ {
+ this.width = this.height = 0;
+ this.resolution = AUTOMATIC;
+ }
+ }
+
+ public int getResolution()
+ {
+ return resolution;
+ }
+
+ public void setResolution(int resolution)
+ {
+ this.resolution = resolution;
+
+ if (resolution == AUTOMATIC || resolution == FITSCREEN)
+ {
+ width = 0;
+ height = 0;
+ }
+ }
+
+ public String getResolutionString()
+ {
+ if (isPredefined())
+ return (width + "x" + height);
+
+ return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" : "custom");
+ }
+
+ public boolean isPredefined()
+ {
+ validate();
+ return (resolution == PREDEFINED);
+ }
+
+ public boolean isAutomatic()
+ {
+ validate();
+ return (resolution == AUTOMATIC);
+ }
+
+ public boolean isFitScreen()
+ {
+ validate();
+ return (resolution == FITSCREEN);
+ }
+
+ public boolean isCustom()
+ {
+ validate();
+ return (resolution == CUSTOM);
+ }
+
+ public int getWidth()
+ {
+ validate();
+ return width;
+ }
+
+ public void setWidth(int width)
+ {
+ this.width = width;
+ }
+
+ public int getHeight()
+ {
+ validate();
+ return height;
+ }
+
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
+
+ public int getColors()
+ {
+ validate();
+ return colors;
+ }
+
+ public void setColors(int colors)
+ {
+ this.colors = colors;
+ }
+
+ @Override public int describeContents()
+ {
+ return 0;
+ }
+
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeInt(resolution);
+ out.writeInt(colors);
+ out.writeInt(width);
+ out.writeInt(height);
+ }
+ }
+
+ public static class DebugSettings implements Parcelable
+ {
+
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public DebugSettings createFromParcel(Parcel in)
+ {
+ return new DebugSettings(in);
+ }
+
+ @Override public DebugSettings[] newArray(int size)
+ {
+ return new DebugSettings[size];
+ }
+ };
+ private String debug;
+ private boolean asyncChannel;
+ private boolean asyncTransport;
+ private boolean asyncInput;
+ private boolean asyncUpdate;
+
+ public DebugSettings()
+ {
+ init();
+ }
+
+ // Session Settings
+ public DebugSettings(Parcel parcel)
+ {
+ asyncChannel = parcel.readInt() == 1;
+ asyncTransport = parcel.readInt() == 1;
+ asyncInput = parcel.readInt() == 1;
+ asyncUpdate = parcel.readInt() == 1;
+ debug = parcel.readString();
+ }
+
+ private void init()
+ {
+ debug = "INFO";
+ asyncChannel = true;
+ asyncTransport = false;
+ asyncInput = true;
+ asyncUpdate = true;
+ }
+
+ private void validate()
+ {
+ final String[] levels = { "OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
+
+ for (String level : levels)
+ {
+ if (level.equalsIgnoreCase(this.debug))
+ {
+ return;
+ }
+ }
+
+ this.debug = "INFO";
+ }
+
+ public String getDebugLevel()
+ {
+ validate();
+ return debug;
+ }
+
+ public void setDebugLevel(String debug)
+ {
+ this.debug = debug;
+ }
+
+ public boolean getAsyncUpdate()
+ {
+ return asyncUpdate;
+ }
+
+ public void setAsyncUpdate(boolean enabled)
+ {
+ asyncUpdate = enabled;
+ }
+
+ public boolean getAsyncInput()
+ {
+ return asyncInput;
+ }
+
+ public void setAsyncInput(boolean enabled)
+ {
+ asyncInput = enabled;
+ }
+
+ public boolean getAsyncChannel()
+ {
+ return asyncChannel;
+ }
+
+ public void setAsyncChannel(boolean enabled)
+ {
+ asyncChannel = enabled;
+ }
+
+ @Override public int describeContents()
+ {
+ return 0;
+ }
+
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeInt(asyncChannel ? 1 : 0);
+ out.writeInt(asyncTransport ? 1 : 0);
+ out.writeInt(asyncInput ? 1 : 0);
+ out.writeInt(asyncUpdate ? 1 : 0);
+ out.writeString(debug);
+ }
+ }
+
+ // Session Settings
+ public static class AdvancedSettings implements Parcelable
+ {
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public AdvancedSettings createFromParcel(Parcel in)
+ {
+ return new AdvancedSettings(in);
+ }
+
+ @Override public AdvancedSettings[] newArray(int size)
+ {
+ return new AdvancedSettings[size];
+ }
+ };
+ private boolean enable3GSettings;
+ private ScreenSettings screen3G;
+ private PerformanceFlags performance3G;
+ private boolean redirectSDCard;
+ private int redirectSound;
+ private boolean redirectMicrophone;
+ private int security;
+ private boolean consoleMode;
+ private String remoteProgram;
+ private String workDir;
+
+ public AdvancedSettings()
+ {
+ init();
+ }
+
+ public AdvancedSettings(Parcel parcel)
+ {
+ enable3GSettings = parcel.readInt() == 1;
+ screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader());
+ performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader());
+ redirectSDCard = parcel.readInt() == 1;
+ redirectSound = parcel.readInt();
+ redirectMicrophone = parcel.readInt() == 1;
+ security = parcel.readInt();
+ consoleMode = parcel.readInt() == 1;
+ remoteProgram = parcel.readString();
+ workDir = parcel.readString();
+ }
+
+ private void init()
+ {
+ enable3GSettings = false;
+ screen3G = new ScreenSettings();
+ performance3G = new PerformanceFlags();
+ redirectSDCard = false;
+ redirectSound = 0;
+ redirectMicrophone = false;
+ security = 0;
+ consoleMode = false;
+ remoteProgram = "";
+ workDir = "";
+ }
+
+ private void validate()
+ {
+ switch (redirectSound)
+ {
+ case 0:
+ case 1:
+ case 2:
+ break;
+ default:
+ redirectSound = 0;
+ break;
+ }
+
+ switch (security)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ break;
+ default:
+ security = 0;
+ break;
+ }
+ }
+
+ public boolean getEnable3GSettings()
+ {
+ return enable3GSettings;
+ }
+
+ public void setEnable3GSettings(boolean enable3GSettings)
+ {
+ this.enable3GSettings = enable3GSettings;
+ }
+
+ public ScreenSettings getScreen3G()
+ {
+ return screen3G;
+ }
+
+ public void setScreen3G(ScreenSettings screen3G)
+ {
+ this.screen3G = screen3G;
+ }
+
+ public PerformanceFlags getPerformance3G()
+ {
+ return performance3G;
+ }
+
+ public void setPerformance3G(PerformanceFlags performance3G)
+ {
+ this.performance3G = performance3G;
+ }
+
+ public boolean getRedirectSDCard()
+ {
+ return redirectSDCard;
+ }
+
+ public void setRedirectSDCard(boolean redirectSDCard)
+ {
+ this.redirectSDCard = redirectSDCard;
+ }
+
+ public int getRedirectSound()
+ {
+ validate();
+ return redirectSound;
+ }
+
+ public void setRedirectSound(int redirect)
+ {
+ this.redirectSound = redirect;
+ }
+
+ public boolean getRedirectMicrophone()
+ {
+ return redirectMicrophone;
+ }
+
+ public void setRedirectMicrophone(boolean redirect)
+ {
+ this.redirectMicrophone = redirect;
+ }
+
+ public int getSecurity()
+ {
+ validate();
+ return security;
+ }
+
+ public void setSecurity(int security)
+ {
+ this.security = security;
+ }
+
+ public boolean getConsoleMode()
+ {
+ return consoleMode;
+ }
+
+ public void setConsoleMode(boolean consoleMode)
+ {
+ this.consoleMode = consoleMode;
+ }
+
+ public String getRemoteProgram()
+ {
+ return remoteProgram;
+ }
+
+ public void setRemoteProgram(String remoteProgram)
+ {
+ this.remoteProgram = remoteProgram;
+ }
+
+ public String getWorkDir()
+ {
+ return workDir;
+ }
+
+ public void setWorkDir(String workDir)
+ {
+ this.workDir = workDir;
+ }
+
+ @Override public int describeContents()
+ {
+ return 0;
+ }
+
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeInt(enable3GSettings ? 1 : 0);
+ out.writeParcelable(screen3G, flags);
+ out.writeParcelable(performance3G, flags);
+ out.writeInt(redirectSDCard ? 1 : 0);
+ out.writeInt(redirectSound);
+ out.writeInt(redirectMicrophone ? 1 : 0);
+ out.writeInt(security);
+ out.writeInt(consoleMode ? 1 : 0);
+ out.writeString(remoteProgram);
+ out.writeString(workDir);
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ConnectionReference.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ConnectionReference.java
index ac8c2fbc3..3e6877672 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ConnectionReference.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ConnectionReference.java
@@ -1,69 +1,85 @@
/*
- A RDP connection reference. References can use bookmark ids or hostnames to connect to a RDP server.
+ A RDP connection reference. References can use bookmark ids or hostnames to connect to a RDP
+ server.
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.domain;
-public class ConnectionReference {
- public static final String PATH_MANUAL_BOOKMARK_ID = "MBMID/";
- public static final String PATH_HOSTNAME = "HOST/";
- public static final String PATH_PLACEHOLDER = "PLCHLD/";
- public static final String PATH_FILE = "FILE/";
+public class ConnectionReference
+{
+ public static final String PATH_MANUAL_BOOKMARK_ID = "MBMID/";
+ public static final String PATH_HOSTNAME = "HOST/";
+ public static final String PATH_PLACEHOLDER = "PLCHLD/";
+ public static final String PATH_FILE = "FILE/";
- public static String getManualBookmarkReference(long bookmarkId) {
- return (PATH_MANUAL_BOOKMARK_ID + bookmarkId);
- }
+ public static String getManualBookmarkReference(long bookmarkId)
+ {
+ return (PATH_MANUAL_BOOKMARK_ID + bookmarkId);
+ }
- public static String getHostnameReference(String hostname) {
- return (PATH_HOSTNAME + hostname);
- }
+ public static String getHostnameReference(String hostname)
+ {
+ return (PATH_HOSTNAME + hostname);
+ }
- public static String getPlaceholderReference(String name) {
- return (PATH_PLACEHOLDER + name);
- }
+ public static String getPlaceholderReference(String name)
+ {
+ return (PATH_PLACEHOLDER + name);
+ }
- public static String getFileReference(String uri) {
- return (PATH_FILE + uri);
- }
+ public static String getFileReference(String uri)
+ {
+ return (PATH_FILE + uri);
+ }
- public static boolean isBookmarkReference(String refStr) {
- return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
- }
+ public static boolean isBookmarkReference(String refStr)
+ {
+ return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
+ }
- public static boolean isManualBookmarkReference(String refStr) {
- return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
- }
+ public static boolean isManualBookmarkReference(String refStr)
+ {
+ return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
+ }
- public static boolean isHostnameReference(String refStr) {
- return refStr.startsWith(PATH_HOSTNAME);
- }
+ public static boolean isHostnameReference(String refStr)
+ {
+ return refStr.startsWith(PATH_HOSTNAME);
+ }
- public static boolean isPlaceholderReference(String refStr) {
- return refStr.startsWith(PATH_PLACEHOLDER);
- }
+ public static boolean isPlaceholderReference(String refStr)
+ {
+ return refStr.startsWith(PATH_PLACEHOLDER);
+ }
- public static boolean isFileReference(String refStr) {
- return refStr.startsWith(PATH_FILE);
- }
+ public static boolean isFileReference(String refStr)
+ {
+ return refStr.startsWith(PATH_FILE);
+ }
- public static long getManualBookmarkId(String refStr) {
- return Integer.parseInt(refStr.substring(PATH_MANUAL_BOOKMARK_ID.length()));
- }
+ public static long getManualBookmarkId(String refStr)
+ {
+ return Integer.parseInt(refStr.substring(PATH_MANUAL_BOOKMARK_ID.length()));
+ }
- public static String getHostname(String refStr) {
- return refStr.substring(PATH_HOSTNAME.length());
- }
+ public static String getHostname(String refStr)
+ {
+ return refStr.substring(PATH_HOSTNAME.length());
+ }
- public static String getPlaceholder(String refStr) {
- return refStr.substring(PATH_PLACEHOLDER.length());
- }
+ public static String getPlaceholder(String refStr)
+ {
+ return refStr.substring(PATH_PLACEHOLDER.length());
+ }
- public static String getFile(String refStr) {
- return refStr.substring(PATH_FILE.length());
- }
+ public static String getFile(String refStr)
+ {
+ return refStr.substring(PATH_FILE.length());
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ManualBookmark.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ManualBookmark.java
index 0e5b677a3..874d4e934 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ManualBookmark.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/ManualBookmark.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.domain;
@@ -13,212 +14,242 @@ import android.content.SharedPreferences;
import android.os.Parcel;
import android.os.Parcelable;
-public class ManualBookmark extends BookmarkBase {
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public ManualBookmark createFromParcel(Parcel in) {
- return new ManualBookmark(in);
- }
+public class ManualBookmark extends BookmarkBase
+{
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public ManualBookmark createFromParcel(Parcel in)
+ {
+ return new ManualBookmark(in);
+ }
- @Override
- public ManualBookmark[] newArray(int size) {
- return new ManualBookmark[size];
- }
- };
- private String hostname;
- private int port;
- private boolean enableGatewaySettings;
- private GatewaySettings gatewaySettings;
+ @Override public ManualBookmark[] newArray(int size)
+ {
+ return new ManualBookmark[size];
+ }
+ };
+ private String hostname;
+ private int port;
+ private boolean enableGatewaySettings;
+ private GatewaySettings gatewaySettings;
- public ManualBookmark(Parcel parcel) {
- super(parcel);
- type = TYPE_MANUAL;
- hostname = parcel.readString();
- port = parcel.readInt();
+ public ManualBookmark(Parcel parcel)
+ {
+ super(parcel);
+ type = TYPE_MANUAL;
+ hostname = parcel.readString();
+ port = parcel.readInt();
- enableGatewaySettings = (parcel.readInt() == 1 ? true : false);
- gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader());
- }
+ enableGatewaySettings = (parcel.readInt() == 1 ? true : false);
+ gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader());
+ }
- public ManualBookmark() {
- super();
- init();
- }
+ public ManualBookmark()
+ {
+ super();
+ init();
+ }
- private void init() {
- type = TYPE_MANUAL;
- hostname = "";
- port = 3389;
- enableGatewaySettings = false;
- gatewaySettings = new GatewaySettings();
- }
+ private void init()
+ {
+ type = TYPE_MANUAL;
+ hostname = "";
+ port = 3389;
+ enableGatewaySettings = false;
+ gatewaySettings = new GatewaySettings();
+ }
- public String getHostname() {
- return hostname;
- }
+ public String getHostname()
+ {
+ return hostname;
+ }
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
+ public void setHostname(String hostname)
+ {
+ this.hostname = hostname;
+ }
- public int getPort() {
- return port;
- }
+ public int getPort()
+ {
+ return port;
+ }
- public void setPort(int port) {
- this.port = port;
- }
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
- public boolean getEnableGatewaySettings() {
- return enableGatewaySettings;
- }
+ public boolean getEnableGatewaySettings()
+ {
+ return enableGatewaySettings;
+ }
- public void setEnableGatewaySettings(boolean enableGatewaySettings) {
- this.enableGatewaySettings = enableGatewaySettings;
- }
+ public void setEnableGatewaySettings(boolean enableGatewaySettings)
+ {
+ this.enableGatewaySettings = enableGatewaySettings;
+ }
- public GatewaySettings getGatewaySettings() {
- return gatewaySettings;
- }
+ public GatewaySettings getGatewaySettings()
+ {
+ return gatewaySettings;
+ }
- public void setGatewaySettings(GatewaySettings gatewaySettings) {
- this.gatewaySettings = gatewaySettings;
- }
+ public void setGatewaySettings(GatewaySettings gatewaySettings)
+ {
+ this.gatewaySettings = gatewaySettings;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override public int describeContents()
+ {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeString(hostname);
- out.writeInt(port);
- out.writeInt(enableGatewaySettings ? 1 : 0);
- out.writeParcelable(gatewaySettings, flags);
- }
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ super.writeToParcel(out, flags);
+ out.writeString(hostname);
+ out.writeInt(port);
+ out.writeInt(enableGatewaySettings ? 1 : 0);
+ out.writeParcelable(gatewaySettings, flags);
+ }
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
- super.writeToSharedPreferences(sharedPrefs);
+ @Override public void writeToSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.writeToSharedPreferences(sharedPrefs);
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.putString("bookmark.hostname", hostname);
- editor.putInt("bookmark.port", port);
- editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings);
- editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname());
- editor.putInt("bookmark.gateway_port", gatewaySettings.getPort());
- editor.putString("bookmark.gateway_username", gatewaySettings.getUsername());
- editor.putString("bookmark.gateway_password", gatewaySettings.getPassword());
- editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain());
- editor.commit();
- }
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putString("bookmark.hostname", hostname);
+ editor.putInt("bookmark.port", port);
+ editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings);
+ editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname());
+ editor.putInt("bookmark.gateway_port", gatewaySettings.getPort());
+ editor.putString("bookmark.gateway_username", gatewaySettings.getUsername());
+ editor.putString("bookmark.gateway_password", gatewaySettings.getPassword());
+ editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain());
+ editor.commit();
+ }
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
- super.readFromSharedPreferences(sharedPrefs);
+ @Override public void readFromSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.readFromSharedPreferences(sharedPrefs);
- hostname = sharedPrefs.getString("bookmark.hostname", "");
- port = sharedPrefs.getInt("bookmark.port", 3389);
- enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false);
- gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", ""));
- gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443));
- gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", ""));
- gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", ""));
- gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", ""));
- }
+ hostname = sharedPrefs.getString("bookmark.hostname", "");
+ port = sharedPrefs.getInt("bookmark.port", 3389);
+ enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false);
+ gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", ""));
+ gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443));
+ gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", ""));
+ gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", ""));
+ gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", ""));
+ }
- // Cloneable
- public Object clone() {
- return super.clone();
- }
+ // Cloneable
+ public Object clone()
+ {
+ return super.clone();
+ }
- // Gateway Settings class
- public static class GatewaySettings implements Parcelable {
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public GatewaySettings createFromParcel(Parcel in) {
- return new GatewaySettings(in);
- }
+ // Gateway Settings class
+ public static class GatewaySettings implements Parcelable
+ {
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public GatewaySettings createFromParcel(Parcel in)
+ {
+ return new GatewaySettings(in);
+ }
- @Override
- public GatewaySettings[] newArray(int size) {
- return new GatewaySettings[size];
- }
- };
- private String hostname;
- private int port;
- private String username;
- private String password;
- private String domain;
+ @Override public GatewaySettings[] newArray(int size)
+ {
+ return new GatewaySettings[size];
+ }
+ };
+ private String hostname;
+ private int port;
+ private String username;
+ private String password;
+ private String domain;
- public GatewaySettings() {
- hostname = "";
- port = 443;
- username = "";
- password = "";
- domain = "";
- }
+ public GatewaySettings()
+ {
+ hostname = "";
+ port = 443;
+ username = "";
+ password = "";
+ domain = "";
+ }
- public GatewaySettings(Parcel parcel) {
- hostname = parcel.readString();
- port = parcel.readInt();
- username = parcel.readString();
- password = parcel.readString();
- domain = parcel.readString();
- }
+ public GatewaySettings(Parcel parcel)
+ {
+ hostname = parcel.readString();
+ port = parcel.readInt();
+ username = parcel.readString();
+ password = parcel.readString();
+ domain = parcel.readString();
+ }
- public String getHostname() {
- return hostname;
- }
+ public String getHostname()
+ {
+ return hostname;
+ }
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
+ public void setHostname(String hostname)
+ {
+ this.hostname = hostname;
+ }
- public int getPort() {
- return port;
- }
+ public int getPort()
+ {
+ return port;
+ }
- public void setPort(int port) {
- this.port = port;
- }
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
- public String getUsername() {
- return username;
- }
+ public String getUsername()
+ {
+ return username;
+ }
- public void setUsername(String username) {
- this.username = username;
- }
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
- public String getPassword() {
- return password;
- }
+ public String getPassword()
+ {
+ return password;
+ }
- public void setPassword(String password) {
- this.password = password;
- }
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
- public String getDomain() {
- return domain;
- }
+ public String getDomain()
+ {
+ return domain;
+ }
- public void setDomain(String domain) {
- this.domain = domain;
- }
+ public void setDomain(String domain)
+ {
+ this.domain = domain;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override public int describeContents()
+ {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(hostname);
- out.writeInt(port);
- out.writeString(username);
- out.writeString(password);
- out.writeString(domain);
- }
- }
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ out.writeString(hostname);
+ out.writeInt(port);
+ out.writeString(username);
+ out.writeString(password);
+ out.writeString(domain);
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/PlaceholderBookmark.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/PlaceholderBookmark.java
index b181af3b6..d15aaf792 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/PlaceholderBookmark.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/PlaceholderBookmark.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.domain;
@@ -13,64 +14,71 @@ import android.content.SharedPreferences;
import android.os.Parcel;
import android.os.Parcelable;
-public class PlaceholderBookmark extends BookmarkBase {
+public class PlaceholderBookmark extends BookmarkBase
+{
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public PlaceholderBookmark createFromParcel(Parcel in) {
- return new PlaceholderBookmark(in);
- }
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public PlaceholderBookmark createFromParcel(Parcel in)
+ {
+ return new PlaceholderBookmark(in);
+ }
- @Override
- public PlaceholderBookmark[] newArray(int size) {
- return new PlaceholderBookmark[size];
- }
- };
- private String name;
+ @Override public PlaceholderBookmark[] newArray(int size)
+ {
+ return new PlaceholderBookmark[size];
+ }
+ };
+ private String name;
- public PlaceholderBookmark(Parcel parcel) {
- super(parcel);
- type = TYPE_PLACEHOLDER;
- name = parcel.readString();
- }
+ public PlaceholderBookmark(Parcel parcel)
+ {
+ super(parcel);
+ type = TYPE_PLACEHOLDER;
+ name = parcel.readString();
+ }
- public PlaceholderBookmark() {
- super();
- type = TYPE_PLACEHOLDER;
- name = "";
- }
+ public PlaceholderBookmark()
+ {
+ super();
+ type = TYPE_PLACEHOLDER;
+ name = "";
+ }
- public String getName() {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override public int describeContents()
+ {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeString(name);
- }
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ super.writeToParcel(out, flags);
+ out.writeString(name);
+ }
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
- super.writeToSharedPreferences(sharedPrefs);
- }
+ @Override public void writeToSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.writeToSharedPreferences(sharedPrefs);
+ }
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
- super.readFromSharedPreferences(sharedPrefs);
- }
-
- // Cloneable
- public Object clone() {
- return super.clone();
- }
+ @Override public void readFromSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.readFromSharedPreferences(sharedPrefs);
+ }
+ // Cloneable
+ public Object clone()
+ {
+ return super.clone();
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/QuickConnectBookmark.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/QuickConnectBookmark.java
index 7df9db8c9..3367b5479 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/QuickConnectBookmark.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/domain/QuickConnectBookmark.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.domain;
@@ -13,52 +14,57 @@ import android.content.SharedPreferences;
import android.os.Parcel;
import android.os.Parcelable;
-public class QuickConnectBookmark extends ManualBookmark {
+public class QuickConnectBookmark extends ManualBookmark
+{
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public QuickConnectBookmark createFromParcel(Parcel in) {
- return new QuickConnectBookmark(in);
- }
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ public QuickConnectBookmark createFromParcel(Parcel in)
+ {
+ return new QuickConnectBookmark(in);
+ }
- @Override
- public QuickConnectBookmark[] newArray(int size) {
- return new QuickConnectBookmark[size];
- }
- };
+ @Override public QuickConnectBookmark[] newArray(int size)
+ {
+ return new QuickConnectBookmark[size];
+ }
+ };
- public QuickConnectBookmark(Parcel parcel) {
- super(parcel);
- type = TYPE_QUICKCONNECT;
- }
+ public QuickConnectBookmark(Parcel parcel)
+ {
+ super(parcel);
+ type = TYPE_QUICKCONNECT;
+ }
- public QuickConnectBookmark() {
- super();
- type = TYPE_QUICKCONNECT;
- }
+ public QuickConnectBookmark()
+ {
+ super();
+ type = TYPE_QUICKCONNECT;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override public int describeContents()
+ {
+ return 0;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- }
+ @Override public void writeToParcel(Parcel out, int flags)
+ {
+ super.writeToParcel(out, flags);
+ }
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
- super.writeToSharedPreferences(sharedPrefs);
- }
+ @Override public void writeToSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.writeToSharedPreferences(sharedPrefs);
+ }
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
- super.readFromSharedPreferences(sharedPrefs);
- }
-
- // Cloneable
- public Object clone() {
- return super.clone();
- }
+ @Override public void readFromSharedPreferences(SharedPreferences sharedPrefs)
+ {
+ super.readFromSharedPreferences(sharedPrefs);
+ }
+ // Cloneable
+ public Object clone()
+ {
+ return super.clone();
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/AboutActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/AboutActivity.java
index c9320d46e..26a4e455f 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/AboutActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/AboutActivity.java
@@ -22,85 +22,100 @@ import java.util.Formatter;
import java.util.IllegalFormatException;
import java.util.Locale;
-public class AboutActivity extends AppCompatActivity {
- private static final String TAG = AboutActivity.class.toString();
- private WebView mWebView;
+public class AboutActivity extends AppCompatActivity
+{
+ private static final String TAG = AboutActivity.class.toString();
+ private WebView mWebView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_about);
- mWebView = (WebView) findViewById(R.id.activity_about_webview);
- }
+ @Override protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_about);
+ mWebView = (WebView)findViewById(R.id.activity_about_webview);
+ }
- @Override
- protected void onResume() {
- populate();
- super.onResume();
- }
+ @Override protected void onResume()
+ {
+ populate();
+ super.onResume();
+ }
- private void populate() {
- StringBuilder total = new StringBuilder();
+ private void populate()
+ {
+ StringBuilder total = new StringBuilder();
- String filename = "about_phone.html";
- if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
- filename = "about.html";
- }
- Locale def = Locale.getDefault();
- String prefix = def.getLanguage().toLowerCase(def);
+ String filename = "about_phone.html";
+ if ((getResources().getConfiguration().screenLayout &
+ Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
+ {
+ filename = "about.html";
+ }
+ Locale def = Locale.getDefault();
+ String prefix = def.getLanguage().toLowerCase(def);
- String dir = prefix + "_about_page/";
- String file = dir + filename;
- InputStream is;
- try {
- is = getAssets().open(file);
- is.close();
- } catch (IOException e) {
- Log.e(TAG, "Missing localized asset " + file, e);
- dir = "about_page/";
- file = dir + filename;
- }
+ String dir = prefix + "_about_page/";
+ String file = dir + filename;
+ InputStream is;
+ try
+ {
+ is = getAssets().open(file);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ Log.e(TAG, "Missing localized asset " + file, e);
+ dir = "about_page/";
+ file = dir + filename;
+ }
- try {
- BufferedReader r = new BufferedReader(new InputStreamReader(getAssets().open(file)));
- try {
- String line;
- while ((line = r.readLine()) != null) {
- total.append(line);
- total.append("\n");
- }
- } finally {
- r.close();
- }
- } catch (IOException e) {
- Log.e(TAG, "Could not read about page " + file, e);
- }
+ try
+ {
+ BufferedReader r = new BufferedReader(new InputStreamReader(getAssets().open(file)));
+ try
+ {
+ String line;
+ while ((line = r.readLine()) != null)
+ {
+ total.append(line);
+ total.append("\n");
+ }
+ }
+ finally
+ {
+ r.close();
+ }
+ }
+ catch (IOException e)
+ {
+ Log.e(TAG, "Could not read about page " + file, e);
+ }
- // append FreeRDP core version to app version
- // get app version
- String version;
- try {
- version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
- } catch (PackageManager.NameNotFoundException e) {
- version = "unknown";
- }
- version = version + " (" + LibFreeRDP.getVersion() + ")";
+ // append FreeRDP core version to app version
+ // get app version
+ String version;
+ try
+ {
+ version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ }
+ catch (PackageManager.NameNotFoundException e)
+ {
+ version = "unknown";
+ }
+ version = version + " (" + LibFreeRDP.getVersion() + ")";
- WebSettings settings = mWebView.getSettings();
- settings.setDomStorageEnabled(true);
- settings.setUseWideViewPort(true);
- settings.setLoadWithOverviewMode(true);
- settings.setSupportZoom(true);
+ WebSettings settings = mWebView.getSettings();
+ settings.setDomStorageEnabled(true);
+ settings.setUseWideViewPort(true);
+ settings.setLoadWithOverviewMode(true);
+ settings.setSupportZoom(true);
- final String base = "file:///android_asset/" + dir;
+ final String base = "file:///android_asset/" + dir;
- final String rawHtml = total.toString();
- final String html = rawHtml.replaceAll("%AFREERDP_VERSION%", version)
- .replaceAll("%SYSTEM_VERSION%", Build.VERSION.RELEASE)
- .replaceAll("%DEVICE_MODEL%", Build.MODEL);
-
- mWebView.loadDataWithBaseURL(base, html, "text/html", null,
- "about:blank");
- }
+ final String rawHtml = total.toString();
+ final String html = rawHtml.replaceAll("%AFREERDP_VERSION%", version)
+ .replaceAll("%SYSTEM_VERSION%", Build.VERSION.RELEASE)
+ .replaceAll("%DEVICE_MODEL%", Build.MODEL);
+ mWebView.loadDataWithBaseURL(base, html, "text/html", null, "about:blank");
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ApplicationSettingsActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ApplicationSettingsActivity.java
index 05fb79239..2a4fc5e89 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ApplicationSettingsActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ApplicationSettingsActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -31,217 +32,269 @@ import java.io.File;
import java.util.List;
import java.util.UUID;
-public class ApplicationSettingsActivity extends AppCompatPreferenceActivity {
- private static boolean isXLargeTablet(Context context) {
- return (context.getResources().getConfiguration().screenLayout
- & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
- }
+public class ApplicationSettingsActivity extends AppCompatPreferenceActivity
+{
+ private static boolean isXLargeTablet(Context context)
+ {
+ return (context.getResources().getConfiguration().screenLayout &
+ Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setupActionBar();
- }
+ @Override protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setupActionBar();
+ }
- private void setupActionBar() {
- android.app.ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
- }
+ private void setupActionBar()
+ {
+ android.app.ActionBar actionBar = getActionBar();
+ if (actionBar != null)
+ {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+ }
- @Override
- public boolean onIsMultiPane() {
- return isXLargeTablet(this);
- }
+ @Override public boolean onIsMultiPane()
+ {
+ return isXLargeTablet(this);
+ }
- @Override
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public void onBuildHeaders(List target) {
- loadHeadersFromResource(R.xml.settings_app_headers, target);
- }
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public void onBuildHeaders(List target)
+ {
+ loadHeadersFromResource(R.xml.settings_app_headers, target);
+ }
- protected boolean isValidFragment(String fragmentName) {
- return PreferenceFragment.class.getName().equals(fragmentName)
- || ClientPreferenceFragment.class.getName().equals(fragmentName)
- || UiPreferenceFragment.class.getName().equals(fragmentName)
- || PowerPreferenceFragment.class.getName().equals(fragmentName)
- || SecurityPreferenceFragment.class.getName().equals(fragmentName);
- }
+ protected boolean isValidFragment(String fragmentName)
+ {
+ return PreferenceFragment.class.getName().equals(fragmentName) ||
+ ClientPreferenceFragment.class.getName().equals(fragmentName) ||
+ UiPreferenceFragment.class.getName().equals(fragmentName) ||
+ PowerPreferenceFragment.class.getName().equals(fragmentName) ||
+ SecurityPreferenceFragment.class.getName().equals(fragmentName);
+ }
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class ClientPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings_app_client);
- SharedPreferences preferences = get(getActivity());
- preferences.registerOnSharedPreferenceChangeListener(this);
- }
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class ClientPreferenceFragment
+ extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener
+ {
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.settings_app_client);
+ SharedPreferences preferences = get(getActivity());
+ preferences.registerOnSharedPreferenceChangeListener(this);
+ }
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (isAdded()) {
- final String clientNameKey = getString(R.string.preference_key_client_name);
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (isAdded())
+ {
+ final String clientNameKey = getString(R.string.preference_key_client_name);
- get(getActivity());
- if (key.equals(clientNameKey)) {
- final String clientNameValue = sharedPreferences.getString(clientNameKey, "");
- EditTextPreference pref = (EditTextPreference) findPreference(clientNameKey);
- pref.setText(clientNameValue);
- }
- }
- }
- }
+ get(getActivity());
+ if (key.equals(clientNameKey))
+ {
+ final String clientNameValue = sharedPreferences.getString(clientNameKey, "");
+ EditTextPreference pref = (EditTextPreference)findPreference(clientNameKey);
+ pref.setText(clientNameValue);
+ }
+ }
+ }
+ }
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class UiPreferenceFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings_app_ui);
- }
- }
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class UiPreferenceFragment extends PreferenceFragment
+ {
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.settings_app_ui);
+ }
+ }
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class PowerPreferenceFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings_app_power);
- }
- }
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class PowerPreferenceFragment extends PreferenceFragment
+ {
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.settings_app_power);
+ }
+ }
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class SecurityPreferenceFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings_app_security);
- }
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ public static class SecurityPreferenceFragment extends PreferenceFragment
+ {
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.settings_app_security);
+ }
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- final String clear = getString(R.string.preference_key_security_clear_certificate_cache);
- if (preference.getKey().equals(clear)) {
- showDialog();
- return true;
- } else {
- return super.onPreferenceTreeClick(preferenceScreen, preference);
- }
- }
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
+ Preference preference)
+ {
+ final String clear =
+ getString(R.string.preference_key_security_clear_certificate_cache);
+ if (preference.getKey().equals(clear))
+ {
+ showDialog();
+ return true;
+ }
+ else
+ {
+ return super.onPreferenceTreeClick(preferenceScreen, preference);
+ }
+ }
- private void showDialog() {
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.dlg_title_clear_cert_cache)
- .setMessage(R.string.dlg_msg_clear_cert_cache)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- clearCertificateCache();
- dialog.dismiss();
- }
- })
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .setIcon(android.R.drawable.ic_delete)
- .show();
- }
+ private void showDialog()
+ {
+ new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.dlg_title_clear_cert_cache)
+ .setMessage(R.string.dlg_msg_clear_cert_cache)
+ .setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ clearCertificateCache();
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ dialog.dismiss();
+ }
+ })
+ .setIcon(android.R.drawable.ic_delete)
+ .show();
+ }
- private boolean deleteDirectory(File dir) {
- if (dir.isDirectory()) {
- String[] children = dir.list();
- for (String file : children) {
- if (!deleteDirectory(new File(dir, file)))
- return false;
- }
- }
- return dir.delete();
- }
+ private boolean deleteDirectory(File dir)
+ {
+ if (dir.isDirectory())
+ {
+ String[] children = dir.list();
+ for (String file : children)
+ {
+ if (!deleteDirectory(new File(dir, file)))
+ return false;
+ }
+ }
+ return dir.delete();
+ }
- private void clearCertificateCache() {
- Context context = getActivity();
- if ((new File(context.getFilesDir() + "/.freerdp")).exists()) {
- if (deleteDirectory(new File(context.getFilesDir() + "/.freerdp")))
- Toast.makeText(context, R.string.info_reset_success, Toast.LENGTH_LONG).show();
- else
- Toast.makeText(context, R.string.info_reset_failed, Toast.LENGTH_LONG).show();
- } else
- Toast.makeText(context, R.string.info_reset_success, Toast.LENGTH_LONG).show();
- }
- }
+ private void clearCertificateCache()
+ {
+ Context context = getActivity();
+ if ((new File(context.getFilesDir() + "/.freerdp")).exists())
+ {
+ if (deleteDirectory(new File(context.getFilesDir() + "/.freerdp")))
+ Toast.makeText(context, R.string.info_reset_success, Toast.LENGTH_LONG).show();
+ else
+ Toast.makeText(context, R.string.info_reset_failed, Toast.LENGTH_LONG).show();
+ }
+ else
+ Toast.makeText(context, R.string.info_reset_success, Toast.LENGTH_LONG).show();
+ }
+ }
- public static SharedPreferences get(Context context) {
- Context appContext = context.getApplicationContext();
- PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_client, false);
- PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_power, false);
- PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_security, false);
- PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_ui, false);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(appContext);
+ public static SharedPreferences get(Context context)
+ {
+ Context appContext = context.getApplicationContext();
+ PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_client, false);
+ PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_power, false);
+ PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_security, false);
+ PreferenceManager.setDefaultValues(appContext, R.xml.settings_app_ui, false);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(appContext);
- final String key = context.getString(R.string.preference_key_client_name);
- final String value = preferences.getString(key, "");
- if (value.isEmpty()) {
- final String android_id = UUID.randomUUID().toString();
- final String defaultValue = context.getString(R.string.preference_default_client_name);
- final String name = defaultValue + "-" + android_id;
- preferences.edit().putString(key, name.substring(0, 31)).apply();
- }
+ final String key = context.getString(R.string.preference_key_client_name);
+ final String value = preferences.getString(key, "");
+ if (value.isEmpty())
+ {
+ final String android_id = UUID.randomUUID().toString();
+ final String defaultValue = context.getString(R.string.preference_default_client_name);
+ final String name = defaultValue + "-" + android_id;
+ preferences.edit().putString(key, name.substring(0, 31)).apply();
+ }
- return preferences;
- }
+ return preferences;
+ }
- public static int getDisconnectTimeout(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getInt(context.getString(R.string.preference_key_power_disconnect_timeout), 0);
- }
+ public static int getDisconnectTimeout(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getInt(
+ context.getString(R.string.preference_key_power_disconnect_timeout), 0);
+ }
- public static boolean getHideStatusBar(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_status_bar), false);
- }
+ public static boolean getHideStatusBar(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_status_bar),
+ false);
+ }
- public static boolean getHideActionBar(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_action_bar), false);
- }
+ public static boolean getHideActionBar(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_action_bar),
+ false);
+ }
- public static boolean getAcceptAllCertificates(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_accept_certificates), false);
- }
+ public static boolean getAcceptAllCertificates(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(
+ context.getString(R.string.preference_key_accept_certificates), false);
+ }
- public static boolean getHideZoomControls(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_zoom_controls), false);
- }
+ public static boolean getHideZoomControls(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(
+ context.getString(R.string.preference_key_ui_hide_zoom_controls), false);
+ }
- public static boolean getSwapMouseButtons(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_swap_mouse_buttons), false);
- }
+ public static boolean getSwapMouseButtons(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(
+ context.getString(R.string.preference_key_ui_swap_mouse_buttons), false);
+ }
- public static boolean getInvertScrolling(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_invert_scrolling), false);
- }
+ public static boolean getInvertScrolling(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(
+ context.getString(R.string.preference_key_ui_invert_scrolling), false);
+ }
- public static boolean getAskOnExit(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_ask_on_exit), false);
- }
+ public static boolean getAskOnExit(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(context.getString(R.string.preference_key_ui_ask_on_exit),
+ false);
+ }
- public static boolean getAutoScrollTouchPointer(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getBoolean(context.getString(R.string.preference_key_ui_auto_scroll_touchpointer), false);
- }
+ public static boolean getAutoScrollTouchPointer(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getBoolean(
+ context.getString(R.string.preference_key_ui_auto_scroll_touchpointer), false);
+ }
- public static String getClientName(Context context) {
- SharedPreferences preferences = get(context);
- return preferences.getString(context.getString(R.string.preference_key_client_name), "");
- }
+ public static String getClientName(Context context)
+ {
+ SharedPreferences preferences = get(context);
+ return preferences.getString(context.getString(R.string.preference_key_client_name), "");
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/BookmarkActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/BookmarkActivity.java
index 232039d79..89ac4d4c5 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/BookmarkActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/BookmarkActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -36,659 +37,707 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-public class BookmarkActivity extends PreferenceActivity implements
- OnSharedPreferenceChangeListener {
- public static final String PARAM_CONNECTION_REFERENCE = "conRef";
-
- private static final String TAG = "BookmarkActivity";
- private static final int PREFERENCES_BOOKMARK = 1;
- private static final int PREFERENCES_CREDENTIALS = 2;
- private static final int PREFERENCES_SCREEN = 3;
- private static final int PREFERENCES_PERFORMANCE = 4;
- private static final int PREFERENCES_ADVANCED = 5;
- private static final int PREFERENCES_SCREEN3G = 6;
- private static final int PREFERENCES_PERFORMANCE3G = 7;
- private static final int PREFERENCES_GATEWAY = 8;
- private static final int PREFERENCES_DEBUG = 9;
- // bookmark needs to be static because the activity is started for each
- // subview
- // (we have to do this because Android has a bug where the style for
- // Preferences
- // is only applied to the first PreferenceScreen but not to subsequent ones)
- private static BookmarkBase bookmark = null;
- private static boolean settings_changed = false;
- private static boolean new_bookmark = false;
- private int current_preferences;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- PreferenceManager mgr = getPreferenceManager();
- // init shared preferences for activity
- mgr.setSharedPreferencesName("TEMP");
- mgr.setSharedPreferencesMode(MODE_PRIVATE);
-
- if (bookmark == null) {
- // if we have a bookmark id set in the extras we are in edit mode
- Bundle bundle = getIntent().getExtras();
- if (bundle != null) {
- // See if we got a connection reference to a bookmark
- if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- String refStr = bundle
- .getString(PARAM_CONNECTION_REFERENCE);
- if (ConnectionReference.isManualBookmarkReference(refStr)) {
- bookmark = GlobalApp.getManualBookmarkGateway()
- .findById(
- ConnectionReference
- .getManualBookmarkId(refStr));
- new_bookmark = false;
- } else if (ConnectionReference.isHostnameReference(refStr)) {
- bookmark = new ManualBookmark();
- bookmark.get().setLabel(
- ConnectionReference.getHostname(refStr));
- bookmark.get().setHostname(
- ConnectionReference.getHostname(refStr));
- new_bookmark = true;
- } else if (ConnectionReference.isFileReference(refStr)) {
- String file = ConnectionReference.getFile(refStr);
-
- bookmark = new ManualBookmark();
- bookmark.setLabel(file);
-
- try {
- RDPFileParser rdpFile = new RDPFileParser(file);
- updateBookmarkFromFile((ManualBookmark) bookmark,
- rdpFile);
-
- bookmark.setLabel(new File(file).getName());
- new_bookmark = true;
- } catch (IOException e) {
- Log.e(TAG, "Failed reading RDP file", e);
- }
- }
- }
- }
-
- // last chance - ensure we really have a valid bookmark
- if (bookmark == null)
- bookmark = new ManualBookmark();
-
- // hide gateway settings if we edit a non-manual bookmark
- if (current_preferences == PREFERENCES_ADVANCED
- && bookmark.getType() != ManualBookmark.TYPE_MANUAL) {
- PreferenceScreen screen = getPreferenceScreen();
- screen.removePreference(findPreference("bookmark.enable_gateway"));
- screen.removePreference(findPreference("bookmark.gateway"));
- }
-
- updateH264Preferences();
-
- // update preferences from bookmark
- bookmark.writeToSharedPreferences(mgr.getSharedPreferences());
-
- // no settings changed yet
- settings_changed = false;
- }
-
- // load the requested settings resource
- if (getIntent() == null || getIntent().getData() == null) {
- addPreferencesFromResource(R.xml.bookmark_settings);
- current_preferences = PREFERENCES_BOOKMARK;
- } else if (getIntent().getData().toString()
- .equals("preferences://screen_settings")) {
- addPreferencesFromResource(R.xml.screen_settings);
- current_preferences = PREFERENCES_SCREEN;
- } else if (getIntent().getData().toString()
- .equals("preferences://performance_flags")) {
- addPreferencesFromResource(R.xml.performance_flags);
- current_preferences = PREFERENCES_PERFORMANCE;
- } else if (getIntent().getData().toString()
- .equals("preferences://screen_settings_3g")) {
- addPreferencesFromResource(R.xml.screen_settings_3g);
- current_preferences = PREFERENCES_SCREEN3G;
- } else if (getIntent().getData().toString()
- .equals("preferences://performance_flags_3g")) {
- addPreferencesFromResource(R.xml.performance_flags_3g);
- current_preferences = PREFERENCES_PERFORMANCE3G;
- } else if (getIntent().getData().toString()
- .equals("preferences://advanced_settings")) {
- addPreferencesFromResource(R.xml.advanced_settings);
- current_preferences = PREFERENCES_ADVANCED;
- } else if (getIntent().getData().toString()
- .equals("preferences://credentials_settings")) {
- addPreferencesFromResource(R.xml.credentials_settings);
- current_preferences = PREFERENCES_CREDENTIALS;
- } else if (getIntent().getData().toString()
- .equals("preferences://gateway_settings")) {
- addPreferencesFromResource(R.xml.gateway_settings);
- current_preferences = PREFERENCES_GATEWAY;
- } else if (getIntent().getData().toString()
- .equals("preferences://debug_settings")) {
- addPreferencesFromResource(R.xml.debug_settings);
- current_preferences = PREFERENCES_DEBUG;
- } else {
- addPreferencesFromResource(R.xml.bookmark_settings);
- current_preferences = PREFERENCES_BOOKMARK;
- }
-
- // update UI with bookmark data
- SharedPreferences spref = mgr.getSharedPreferences();
- initSettings(spref);
-
- // register for preferences changed notification
- mgr.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
-
- // set the correct component names in our preferencescreen settings
- setIntentComponentNames();
-
- updateH264Preferences();
- }
-
- private void updateH264Preferences() {
- if (!LibFreeRDP.hasH264Support()) {
- final int preferenceIdList[] = {
- R.string.preference_key_h264,
- R.string.preference_key_h264_3g
- };
-
- PreferenceManager mgr = getPreferenceManager();
- for (int id : preferenceIdList) {
- final String key = getString(id);
- Preference preference = mgr.findPreference(key);
- if (preference != null) {
- preference.setEnabled(false);
- }
- }
- }
- }
-
- private void updateBookmarkFromFile(ManualBookmark bookmark,
- RDPFileParser rdpFile) {
- String s;
- Integer i;
-
- s = rdpFile.getString("full address");
- if (s != null) {
- // this gets complicated as it can include port
- if (s.lastIndexOf(":") > s.lastIndexOf("]")) {
- try {
- String port = s.substring(s.lastIndexOf(":") + 1);
- bookmark.setPort(Integer.parseInt(port));
- } catch (NumberFormatException e) {
- Log.e(TAG, "Malformed address");
- }
-
- s = s.substring(0, s.lastIndexOf(":"));
- }
-
- // or even be an ipv6 address
- if (s.startsWith("[") && s.endsWith("]"))
- s = s.substring(1, s.length() - 1);
-
- bookmark.setHostname(s);
- }
-
- i = rdpFile.getInteger("server port");
- if (i != null)
- bookmark.setPort(i);
-
- s = rdpFile.getString("username");
- if (s != null)
- bookmark.setUsername(s);
-
- s = rdpFile.getString("domain");
- if (s != null)
- bookmark.setDomain(s);
-
- i = rdpFile.getInteger("connect to console");
- if (i != null)
- bookmark.getAdvancedSettings().setConsoleMode(i == 1);
- }
-
- private void setIntentComponentNames() {
- // we set the component name for our sub-activity calls here because we
- // don't know the package
- // name of the main app in our library project.
- ComponentName compName = new ComponentName(getPackageName(),
- BookmarkActivity.class.getName());
- ArrayList prefKeys = new ArrayList();
-
- prefKeys.add("bookmark.credentials");
- prefKeys.add("bookmark.screen");
- prefKeys.add("bookmark.performance");
- prefKeys.add("bookmark.advanced");
- prefKeys.add("bookmark.screen_3g");
- prefKeys.add("bookmark.performance_3g");
- prefKeys.add("bookmark.gateway_settings");
- prefKeys.add("bookmark.debug");
-
- for (String p : prefKeys) {
- Preference pref = findPreference(p);
- if (pref != null)
- pref.getIntent().setComponent(compName);
- }
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
- settings_changed = true;
- switch (current_preferences) {
- case PREFERENCES_DEBUG:
- debugSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_BOOKMARK:
- bookmarkSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_ADVANCED:
- advancedSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_CREDENTIALS:
- credentialsSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_SCREEN:
- case PREFERENCES_SCREEN3G:
- screenSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_GATEWAY:
- gatewaySettingsChanged(sharedPreferences, key);
- break;
-
- default:
- break;
- }
-
- }
-
- private void initSettings(SharedPreferences sharedPreferences) {
- switch (current_preferences) {
- case PREFERENCES_BOOKMARK:
- initBookmarkSettings(sharedPreferences);
- break;
-
- case PREFERENCES_ADVANCED:
- initAdvancedSettings(sharedPreferences);
- break;
-
- case PREFERENCES_CREDENTIALS:
- initCredentialsSettings(sharedPreferences);
- break;
-
- case PREFERENCES_SCREEN:
- initScreenSettings(sharedPreferences);
- break;
-
- case PREFERENCES_SCREEN3G:
- initScreenSettings3G(sharedPreferences);
- break;
-
- case PREFERENCES_GATEWAY:
- initGatewaySettings(sharedPreferences);
- break;
-
- case PREFERENCES_DEBUG:
- initDebugSettings(sharedPreferences);
- break;
-
- default:
- break;
- }
- }
-
- private void initBookmarkSettings(SharedPreferences sharedPreferences) {
- bookmarkSettingsChanged(sharedPreferences, "bookmark.label");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.port");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.username");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution");
- }
-
- private void bookmarkSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.label") && findPreference(key) != null)
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.hostname") && findPreference(key) != null)
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.port") && findPreference(key) != null)
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, -1)));
- else if (key.equals("bookmark.username")) {
- String username = sharedPreferences.getString(key, "");
- if (username.length() == 0)
- username = "";
- findPreference("bookmark.credentials").setSummary(username);
- } else if (key.equals("bookmark.resolution")
- || key.equals("bookmark.colors")
- || key.equals("bookmark.width")
- || key.equals("bookmark.height")) {
- String resolution = sharedPreferences.getString(
- "bookmark.resolution", "800x600");
- // compare english string from resolutions_values_array array,
- // decode to localized
- // text for display
- if (resolution.equals("automatic")) {
- resolution = getResources().getString(
- R.string.resolution_automatic);
- }
- if (resolution.equals("custom")) {
- resolution = getResources().getString(
- R.string.resolution_custom);
- }
- if (resolution.equals("fitscreen")) {
- resolution = getResources().getString(R.string.resolution_fit);
- }
- resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16);
- findPreference("bookmark.screen").setSummary(resolution);
- }
- }
-
- private void initAdvancedSettings(SharedPreferences sharedPreferences) {
- advancedSettingsChanged(sharedPreferences,
- "bookmark.enable_gateway_settings");
- advancedSettingsChanged(sharedPreferences,
- "bookmark.enable_3g_settings");
- advancedSettingsChanged(sharedPreferences, "bookmark.security");
- advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
- advancedSettingsChanged(sharedPreferences, "bookmark.remote_program");
- advancedSettingsChanged(sharedPreferences, "bookmark.work_dir");
- }
-
- private void advancedSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.enable_gateway_settings")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- findPreference("bookmark.gateway_settings").setEnabled(enabled);
- } else if (key.equals("bookmark.enable_3g_settings")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- findPreference("bookmark.screen_3g").setEnabled(enabled);
- findPreference("bookmark.performance_3g").setEnabled(enabled);
- } else if (key.equals("bookmark.security")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- CharSequence security = listPreference.getEntries()[sharedPreferences
- .getInt(key, 0)];
- listPreference.setSummary(security);
- } else if (key.equals("bookmark.resolution_3g")
- || key.equals("bookmark.colors_3g")
- || key.equals("bookmark.width_3g")
- || key.equals("bookmark.height_3g")) {
- String resolution = sharedPreferences.getString(
- "bookmark.resolution_3g", "800x600");
- if (resolution.equals("automatic"))
- resolution = getResources().getString(
- R.string.resolution_automatic);
- else if (resolution.equals("custom"))
- resolution = getResources().getString(
- R.string.resolution_custom);
- resolution += "@"
- + sharedPreferences.getInt("bookmark.colors_3g", 16);
- findPreference("bookmark.screen_3g").setSummary(resolution);
- } else if (key.equals("bookmark.remote_program"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.work_dir"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private void initCredentialsSettings(SharedPreferences sharedPreferences) {
- credentialsSettingsChanged(sharedPreferences, "bookmark.username");
- credentialsSettingsChanged(sharedPreferences, "bookmark.password");
- credentialsSettingsChanged(sharedPreferences, "bookmark.domain");
- }
-
- private void credentialsSettingsChanged(
- SharedPreferences sharedPreferences, String key) {
- if (key.equals("bookmark.username"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.password")) {
- if (sharedPreferences.getString(key, "").length() == 0)
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_empty));
- else
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_present));
- } else if (key.equals("bookmark.domain"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private void initScreenSettings(SharedPreferences sharedPreferences) {
- screenSettingsChanged(sharedPreferences, "bookmark.colors");
- screenSettingsChanged(sharedPreferences, "bookmark.resolution");
- screenSettingsChanged(sharedPreferences, "bookmark.width");
- screenSettingsChanged(sharedPreferences, "bookmark.height");
- }
-
- private void initScreenSettings3G(SharedPreferences sharedPreferences) {
- screenSettingsChanged(sharedPreferences, "bookmark.colors_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.width_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.height_3g");
- }
-
- private void screenSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- // could happen during initialization because 3g and non-3g settings
- // share this routine - just skip
- if (findPreference(key) == null)
- return;
-
- if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- listPreference.setSummary(listPreference.getEntry());
- } else if (key.equals("bookmark.resolution")
- || key.equals("bookmark.resolution_3g")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- listPreference.setSummary(listPreference.getEntry());
-
- String value = listPreference.getValue();
- boolean enabled = value.equalsIgnoreCase("custom");
- if (key.equals("bookmark.resolution")) {
- findPreference("bookmark.width").setEnabled(enabled);
- findPreference("bookmark.height").setEnabled(enabled);
- } else {
- findPreference("bookmark.width_3g").setEnabled(enabled);
- findPreference("bookmark.height_3g").setEnabled(enabled);
- }
- } else if (key.equals("bookmark.width")
- || key.equals("bookmark.width_3g"))
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 800)));
- else if (key.equals("bookmark.height")
- || key.equals("bookmark.height_3g"))
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 600)));
- }
-
- private void initDebugSettings(SharedPreferences sharedPreferences) {
- debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
- debugSettingsChanged(sharedPreferences, "bookmark.async_channel");
- debugSettingsChanged(sharedPreferences, "bookmark.async_update");
- debugSettingsChanged(sharedPreferences, "bookmark.async_input");
- }
-
- private void initGatewaySettings(SharedPreferences sharedPreferences) {
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
- }
-
- private void debugSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.debug_level")) {
- String level = sharedPreferences.getString(key, "INFO");
- Preference pref = findPreference("bookmark.debug_level");
- pref.setDefaultValue(level);
- } else if (key.equals("bookmark.async_channel")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_channel");
- pref.setDefaultValue(enabled);
- } else if (key.equals("bookmark.async_update")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_update");
- pref.setDefaultValue(enabled);
- } else if (key.equals("bookmark.async_input")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_input");
- pref.setDefaultValue(enabled);
- }
- }
-
- private void gatewaySettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.gateway_hostname")) {
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- } else if (key.equals("bookmark.gateway_port")) {
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 443)));
- } else if (key.equals("bookmark.gateway_username")) {
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- } else if (key.equals("bookmark.gateway_password")) {
- if (sharedPreferences.getString(key, "").length() == 0)
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_empty));
- else
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_present));
- } else if (key.equals("bookmark.gateway_domain"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private boolean verifySettings(SharedPreferences sharedPreferences) {
-
- boolean verifyFailed = false;
- // perform sanity checks on settings
- // Label set
- if (sharedPreferences.getString("bookmark.label", "").length() == 0)
- verifyFailed = true;
-
- // Server and port specified
- if (!verifyFailed
- && sharedPreferences.getString("bookmark.hostname", "")
- .length() == 0)
- verifyFailed = true;
-
- // Server and port specified
- if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0)
- verifyFailed = true;
-
- // if an error occurred - display toast and return false
- return (!verifyFailed);
- }
-
- private void finishAndResetBookmark() {
- bookmark = null;
- getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- finish();
- }
-
- @Override
- public void onBackPressed() {
- // only proceed if we are in the main preferences screen
- if (current_preferences != PREFERENCES_BOOKMARK) {
- super.onBackPressed();
- getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- return;
- }
-
- SharedPreferences sharedPreferences = getPreferenceManager()
- .getSharedPreferences();
- if (!verifySettings(sharedPreferences)) {
- // ask the user if he wants to cancel or continue editing
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.error_bookmark_incomplete_title)
- .setMessage(R.string.error_bookmark_incomplete)
- .setPositiveButton(R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- finishAndResetBookmark();
- }
- })
- .setNegativeButton(R.string.cont,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- dialog.cancel();
- }
- }).show();
-
- return;
- } else {
- // ask the user if he wants to save or cancel editing if a setting
- // has changed
- if (new_bookmark || settings_changed) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_save_bookmark)
- .setMessage(R.string.dlg_save_bookmark)
- .setPositiveButton(R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- // read shared prefs back to bookmark
- bookmark.readFromSharedPreferences(getPreferenceManager()
- .getSharedPreferences());
-
- BookmarkBaseGateway bookmarkGateway;
- if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
- bookmarkGateway = GlobalApp
- .getManualBookmarkGateway();
- // remove any history entry for this
- // bookmark
- GlobalApp
- .getQuickConnectHistoryGateway()
- .removeHistoryItem(
- bookmark.get()
- .getHostname());
- } else {
- assert false;
- return;
- }
-
- // insert or update bookmark and leave
- // activity
- if (bookmark.getId() > 0)
- bookmarkGateway.update(bookmark);
- else
- bookmarkGateway.insert(bookmark);
-
- finishAndResetBookmark();
- }
- })
- .setNegativeButton(R.string.no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- finishAndResetBookmark();
- }
- }).show();
- } else {
- finishAndResetBookmark();
- }
- }
- }
+public class BookmarkActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener
+{
+ public static final String PARAM_CONNECTION_REFERENCE = "conRef";
+
+ private static final String TAG = "BookmarkActivity";
+ private static final int PREFERENCES_BOOKMARK = 1;
+ private static final int PREFERENCES_CREDENTIALS = 2;
+ private static final int PREFERENCES_SCREEN = 3;
+ private static final int PREFERENCES_PERFORMANCE = 4;
+ private static final int PREFERENCES_ADVANCED = 5;
+ private static final int PREFERENCES_SCREEN3G = 6;
+ private static final int PREFERENCES_PERFORMANCE3G = 7;
+ private static final int PREFERENCES_GATEWAY = 8;
+ private static final int PREFERENCES_DEBUG = 9;
+ // bookmark needs to be static because the activity is started for each
+ // subview
+ // (we have to do this because Android has a bug where the style for
+ // Preferences
+ // is only applied to the first PreferenceScreen but not to subsequent ones)
+ private static BookmarkBase bookmark = null;
+ private static boolean settings_changed = false;
+ private static boolean new_bookmark = false;
+ private int current_preferences;
+
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ PreferenceManager mgr = getPreferenceManager();
+ // init shared preferences for activity
+ mgr.setSharedPreferencesName("TEMP");
+ mgr.setSharedPreferencesMode(MODE_PRIVATE);
+
+ if (bookmark == null)
+ {
+ // if we have a bookmark id set in the extras we are in edit mode
+ Bundle bundle = getIntent().getExtras();
+ if (bundle != null)
+ {
+ // See if we got a connection reference to a bookmark
+ if (bundle.containsKey(PARAM_CONNECTION_REFERENCE))
+ {
+ String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
+ if (ConnectionReference.isManualBookmarkReference(refStr))
+ {
+ bookmark = GlobalApp.getManualBookmarkGateway().findById(
+ ConnectionReference.getManualBookmarkId(refStr));
+ new_bookmark = false;
+ }
+ else if (ConnectionReference.isHostnameReference(refStr))
+ {
+ bookmark = new ManualBookmark();
+ bookmark.get().setLabel(
+ ConnectionReference.getHostname(refStr));
+ bookmark.get().setHostname(
+ ConnectionReference.getHostname(refStr));
+ new_bookmark = true;
+ }
+ else if (ConnectionReference.isFileReference(refStr))
+ {
+ String file = ConnectionReference.getFile(refStr);
+
+ bookmark = new ManualBookmark();
+ bookmark.setLabel(file);
+
+ try
+ {
+ RDPFileParser rdpFile = new RDPFileParser(file);
+ updateBookmarkFromFile((ManualBookmark)bookmark, rdpFile);
+
+ bookmark.setLabel(new File(file).getName());
+ new_bookmark = true;
+ }
+ catch (IOException e)
+ {
+ Log.e(TAG, "Failed reading RDP file", e);
+ }
+ }
+ }
+ }
+
+ // last chance - ensure we really have a valid bookmark
+ if (bookmark == null)
+ bookmark = new ManualBookmark();
+
+ // hide gateway settings if we edit a non-manual bookmark
+ if (current_preferences == PREFERENCES_ADVANCED &&
+ bookmark.getType() != ManualBookmark.TYPE_MANUAL)
+ {
+ PreferenceScreen screen = getPreferenceScreen();
+ screen.removePreference(findPreference("bookmark.enable_gateway"));
+ screen.removePreference(findPreference("bookmark.gateway"));
+ }
+
+ updateH264Preferences();
+
+ // update preferences from bookmark
+ bookmark.writeToSharedPreferences(mgr.getSharedPreferences());
+
+ // no settings changed yet
+ settings_changed = false;
+ }
+
+ // load the requested settings resource
+ if (getIntent() == null || getIntent().getData() == null)
+ {
+ addPreferencesFromResource(R.xml.bookmark_settings);
+ current_preferences = PREFERENCES_BOOKMARK;
+ }
+ else if (getIntent().getData().toString().equals("preferences://screen_settings"))
+ {
+ addPreferencesFromResource(R.xml.screen_settings);
+ current_preferences = PREFERENCES_SCREEN;
+ }
+ else if (getIntent().getData().toString().equals("preferences://performance_flags"))
+ {
+ addPreferencesFromResource(R.xml.performance_flags);
+ current_preferences = PREFERENCES_PERFORMANCE;
+ }
+ else if (getIntent().getData().toString().equals("preferences://screen_settings_3g"))
+ {
+ addPreferencesFromResource(R.xml.screen_settings_3g);
+ current_preferences = PREFERENCES_SCREEN3G;
+ }
+ else if (getIntent().getData().toString().equals("preferences://performance_flags_3g"))
+ {
+ addPreferencesFromResource(R.xml.performance_flags_3g);
+ current_preferences = PREFERENCES_PERFORMANCE3G;
+ }
+ else if (getIntent().getData().toString().equals("preferences://advanced_settings"))
+ {
+ addPreferencesFromResource(R.xml.advanced_settings);
+ current_preferences = PREFERENCES_ADVANCED;
+ }
+ else if (getIntent().getData().toString().equals("preferences://credentials_settings"))
+ {
+ addPreferencesFromResource(R.xml.credentials_settings);
+ current_preferences = PREFERENCES_CREDENTIALS;
+ }
+ else if (getIntent().getData().toString().equals("preferences://gateway_settings"))
+ {
+ addPreferencesFromResource(R.xml.gateway_settings);
+ current_preferences = PREFERENCES_GATEWAY;
+ }
+ else if (getIntent().getData().toString().equals("preferences://debug_settings"))
+ {
+ addPreferencesFromResource(R.xml.debug_settings);
+ current_preferences = PREFERENCES_DEBUG;
+ }
+ else
+ {
+ addPreferencesFromResource(R.xml.bookmark_settings);
+ current_preferences = PREFERENCES_BOOKMARK;
+ }
+
+ // update UI with bookmark data
+ SharedPreferences spref = mgr.getSharedPreferences();
+ initSettings(spref);
+
+ // register for preferences changed notification
+ mgr.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+
+ // set the correct component names in our preferencescreen settings
+ setIntentComponentNames();
+
+ updateH264Preferences();
+ }
+
+ private void updateH264Preferences()
+ {
+ if (!LibFreeRDP.hasH264Support())
+ {
+ final int preferenceIdList[] = { R.string.preference_key_h264,
+ R.string.preference_key_h264_3g };
+
+ PreferenceManager mgr = getPreferenceManager();
+ for (int id : preferenceIdList)
+ {
+ final String key = getString(id);
+ Preference preference = mgr.findPreference(key);
+ if (preference != null)
+ {
+ preference.setEnabled(false);
+ }
+ }
+ }
+ }
+
+ private void updateBookmarkFromFile(ManualBookmark bookmark, RDPFileParser rdpFile)
+ {
+ String s;
+ Integer i;
+
+ s = rdpFile.getString("full address");
+ if (s != null)
+ {
+ // this gets complicated as it can include port
+ if (s.lastIndexOf(":") > s.lastIndexOf("]"))
+ {
+ try
+ {
+ String port = s.substring(s.lastIndexOf(":") + 1);
+ bookmark.setPort(Integer.parseInt(port));
+ }
+ catch (NumberFormatException e)
+ {
+ Log.e(TAG, "Malformed address");
+ }
+
+ s = s.substring(0, s.lastIndexOf(":"));
+ }
+
+ // or even be an ipv6 address
+ if (s.startsWith("[") && s.endsWith("]"))
+ s = s.substring(1, s.length() - 1);
+
+ bookmark.setHostname(s);
+ }
+
+ i = rdpFile.getInteger("server port");
+ if (i != null)
+ bookmark.setPort(i);
+
+ s = rdpFile.getString("username");
+ if (s != null)
+ bookmark.setUsername(s);
+
+ s = rdpFile.getString("domain");
+ if (s != null)
+ bookmark.setDomain(s);
+
+ i = rdpFile.getInteger("connect to console");
+ if (i != null)
+ bookmark.getAdvancedSettings().setConsoleMode(i == 1);
+ }
+
+ private void setIntentComponentNames()
+ {
+ // we set the component name for our sub-activity calls here because we
+ // don't know the package
+ // name of the main app in our library project.
+ ComponentName compName =
+ new ComponentName(getPackageName(), BookmarkActivity.class.getName());
+ ArrayList prefKeys = new ArrayList();
+
+ prefKeys.add("bookmark.credentials");
+ prefKeys.add("bookmark.screen");
+ prefKeys.add("bookmark.performance");
+ prefKeys.add("bookmark.advanced");
+ prefKeys.add("bookmark.screen_3g");
+ prefKeys.add("bookmark.performance_3g");
+ prefKeys.add("bookmark.gateway_settings");
+ prefKeys.add("bookmark.debug");
+
+ for (String p : prefKeys)
+ {
+ Preference pref = findPreference(p);
+ if (pref != null)
+ pref.getIntent().setComponent(compName);
+ }
+ }
+
+ @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+ {
+ settings_changed = true;
+ switch (current_preferences)
+ {
+ case PREFERENCES_DEBUG:
+ debugSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_BOOKMARK:
+ bookmarkSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_ADVANCED:
+ advancedSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_CREDENTIALS:
+ credentialsSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_SCREEN:
+ case PREFERENCES_SCREEN3G:
+ screenSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_GATEWAY:
+ gatewaySettingsChanged(sharedPreferences, key);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void initSettings(SharedPreferences sharedPreferences)
+ {
+ switch (current_preferences)
+ {
+ case PREFERENCES_BOOKMARK:
+ initBookmarkSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_ADVANCED:
+ initAdvancedSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_CREDENTIALS:
+ initCredentialsSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_SCREEN:
+ initScreenSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_SCREEN3G:
+ initScreenSettings3G(sharedPreferences);
+ break;
+
+ case PREFERENCES_GATEWAY:
+ initGatewaySettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_DEBUG:
+ initDebugSettings(sharedPreferences);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void initBookmarkSettings(SharedPreferences sharedPreferences)
+ {
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.label");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.port");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.username");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution");
+ }
+
+ private void bookmarkSettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("bookmark.label") && findPreference(key) != null)
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.hostname") && findPreference(key) != null)
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.port") && findPreference(key) != null)
+ findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, -1)));
+ else if (key.equals("bookmark.username"))
+ {
+ String username = sharedPreferences.getString(key, "");
+ if (username.length() == 0)
+ username = "";
+ findPreference("bookmark.credentials").setSummary(username);
+ }
+ else if (key.equals("bookmark.resolution") || key.equals("bookmark.colors") ||
+ key.equals("bookmark.width") || key.equals("bookmark.height"))
+ {
+ String resolution = sharedPreferences.getString("bookmark.resolution", "800x600");
+ // compare english string from resolutions_values_array array,
+ // decode to localized
+ // text for display
+ if (resolution.equals("automatic"))
+ {
+ resolution = getResources().getString(R.string.resolution_automatic);
+ }
+ if (resolution.equals("custom"))
+ {
+ resolution = getResources().getString(R.string.resolution_custom);
+ }
+ if (resolution.equals("fitscreen"))
+ {
+ resolution = getResources().getString(R.string.resolution_fit);
+ }
+ resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16);
+ findPreference("bookmark.screen").setSummary(resolution);
+ }
+ }
+
+ private void initAdvancedSettings(SharedPreferences sharedPreferences)
+ {
+ advancedSettingsChanged(sharedPreferences, "bookmark.enable_gateway_settings");
+ advancedSettingsChanged(sharedPreferences, "bookmark.enable_3g_settings");
+ advancedSettingsChanged(sharedPreferences, "bookmark.security");
+ advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
+ advancedSettingsChanged(sharedPreferences, "bookmark.remote_program");
+ advancedSettingsChanged(sharedPreferences, "bookmark.work_dir");
+ }
+
+ private void advancedSettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("bookmark.enable_gateway_settings"))
+ {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ findPreference("bookmark.gateway_settings").setEnabled(enabled);
+ }
+ else if (key.equals("bookmark.enable_3g_settings"))
+ {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ findPreference("bookmark.screen_3g").setEnabled(enabled);
+ findPreference("bookmark.performance_3g").setEnabled(enabled);
+ }
+ else if (key.equals("bookmark.security"))
+ {
+ ListPreference listPreference = (ListPreference)findPreference(key);
+ CharSequence security = listPreference.getEntries()[sharedPreferences.getInt(key, 0)];
+ listPreference.setSummary(security);
+ }
+ else if (key.equals("bookmark.resolution_3g") || key.equals("bookmark.colors_3g") ||
+ key.equals("bookmark.width_3g") || key.equals("bookmark.height_3g"))
+ {
+ String resolution = sharedPreferences.getString("bookmark.resolution_3g", "800x600");
+ if (resolution.equals("automatic"))
+ resolution = getResources().getString(R.string.resolution_automatic);
+ else if (resolution.equals("custom"))
+ resolution = getResources().getString(R.string.resolution_custom);
+ resolution += "@" + sharedPreferences.getInt("bookmark.colors_3g", 16);
+ findPreference("bookmark.screen_3g").setSummary(resolution);
+ }
+ else if (key.equals("bookmark.remote_program"))
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.work_dir"))
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private void initCredentialsSettings(SharedPreferences sharedPreferences)
+ {
+ credentialsSettingsChanged(sharedPreferences, "bookmark.username");
+ credentialsSettingsChanged(sharedPreferences, "bookmark.password");
+ credentialsSettingsChanged(sharedPreferences, "bookmark.domain");
+ }
+
+ private void credentialsSettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("bookmark.username"))
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.password"))
+ {
+ if (sharedPreferences.getString(key, "").length() == 0)
+ findPreference(key).setSummary(
+ getResources().getString(R.string.settings_password_empty));
+ else
+ findPreference(key).setSummary(
+ getResources().getString(R.string.settings_password_present));
+ }
+ else if (key.equals("bookmark.domain"))
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private void initScreenSettings(SharedPreferences sharedPreferences)
+ {
+ screenSettingsChanged(sharedPreferences, "bookmark.colors");
+ screenSettingsChanged(sharedPreferences, "bookmark.resolution");
+ screenSettingsChanged(sharedPreferences, "bookmark.width");
+ screenSettingsChanged(sharedPreferences, "bookmark.height");
+ }
+
+ private void initScreenSettings3G(SharedPreferences sharedPreferences)
+ {
+ screenSettingsChanged(sharedPreferences, "bookmark.colors_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.width_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.height_3g");
+ }
+
+ private void screenSettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ // could happen during initialization because 3g and non-3g settings
+ // share this routine - just skip
+ if (findPreference(key) == null)
+ return;
+
+ if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g"))
+ {
+ ListPreference listPreference = (ListPreference)findPreference(key);
+ listPreference.setSummary(listPreference.getEntry());
+ }
+ else if (key.equals("bookmark.resolution") || key.equals("bookmark.resolution_3g"))
+ {
+ ListPreference listPreference = (ListPreference)findPreference(key);
+ listPreference.setSummary(listPreference.getEntry());
+
+ String value = listPreference.getValue();
+ boolean enabled = value.equalsIgnoreCase("custom");
+ if (key.equals("bookmark.resolution"))
+ {
+ findPreference("bookmark.width").setEnabled(enabled);
+ findPreference("bookmark.height").setEnabled(enabled);
+ }
+ else
+ {
+ findPreference("bookmark.width_3g").setEnabled(enabled);
+ findPreference("bookmark.height_3g").setEnabled(enabled);
+ }
+ }
+ else if (key.equals("bookmark.width") || key.equals("bookmark.width_3g"))
+ findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 800)));
+ else if (key.equals("bookmark.height") || key.equals("bookmark.height_3g"))
+ findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 600)));
+ }
+
+ private void initDebugSettings(SharedPreferences sharedPreferences)
+ {
+ debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_channel");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_update");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_input");
+ }
+
+ private void initGatewaySettings(SharedPreferences sharedPreferences)
+ {
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
+ }
+
+ private void debugSettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("bookmark.debug_level"))
+ {
+ String level = sharedPreferences.getString(key, "INFO");
+ Preference pref = findPreference("bookmark.debug_level");
+ pref.setDefaultValue(level);
+ }
+ else if (key.equals("bookmark.async_channel"))
+ {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_channel");
+ pref.setDefaultValue(enabled);
+ }
+ else if (key.equals("bookmark.async_update"))
+ {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_update");
+ pref.setDefaultValue(enabled);
+ }
+ else if (key.equals("bookmark.async_input"))
+ {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_input");
+ pref.setDefaultValue(enabled);
+ }
+ }
+
+ private void gatewaySettingsChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("bookmark.gateway_hostname"))
+ {
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ }
+ else if (key.equals("bookmark.gateway_port"))
+ {
+ findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 443)));
+ }
+ else if (key.equals("bookmark.gateway_username"))
+ {
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ }
+ else if (key.equals("bookmark.gateway_password"))
+ {
+ if (sharedPreferences.getString(key, "").length() == 0)
+ findPreference(key).setSummary(
+ getResources().getString(R.string.settings_password_empty));
+ else
+ findPreference(key).setSummary(
+ getResources().getString(R.string.settings_password_present));
+ }
+ else if (key.equals("bookmark.gateway_domain"))
+ findPreference(key).setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private boolean verifySettings(SharedPreferences sharedPreferences)
+ {
+
+ boolean verifyFailed = false;
+ // perform sanity checks on settings
+ // Label set
+ if (sharedPreferences.getString("bookmark.label", "").length() == 0)
+ verifyFailed = true;
+
+ // Server and port specified
+ if (!verifyFailed && sharedPreferences.getString("bookmark.hostname", "").length() == 0)
+ verifyFailed = true;
+
+ // Server and port specified
+ if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0)
+ verifyFailed = true;
+
+ // if an error occurred - display toast and return false
+ return (!verifyFailed);
+ }
+
+ private void finishAndResetBookmark()
+ {
+ bookmark = null;
+ getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
+ this);
+ finish();
+ }
+
+ @Override public void onBackPressed()
+ {
+ // only proceed if we are in the main preferences screen
+ if (current_preferences != PREFERENCES_BOOKMARK)
+ {
+ super.onBackPressed();
+ getPreferenceManager()
+ .getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(this);
+ return;
+ }
+
+ SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
+ if (!verifySettings(sharedPreferences))
+ {
+ // ask the user if he wants to cancel or continue editing
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.error_bookmark_incomplete_title)
+ .setMessage(R.string.error_bookmark_incomplete)
+ .setPositiveButton(R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ finishAndResetBookmark();
+ }
+ })
+ .setNegativeButton(R.string.cont,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ dialog.cancel();
+ }
+ })
+ .show();
+
+ return;
+ }
+ else
+ {
+ // ask the user if he wants to save or cancel editing if a setting
+ // has changed
+ if (new_bookmark || settings_changed)
+ {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_save_bookmark)
+ .setMessage(R.string.dlg_save_bookmark)
+ .setPositiveButton(
+ R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override public void onClick(DialogInterface dialog, int which)
+ {
+ // read shared prefs back to bookmark
+ bookmark.readFromSharedPreferences(
+ getPreferenceManager().getSharedPreferences());
+
+ BookmarkBaseGateway bookmarkGateway;
+ if (bookmark.getType() == BookmarkBase.TYPE_MANUAL)
+ {
+ bookmarkGateway = GlobalApp.getManualBookmarkGateway();
+ // remove any history entry for this
+ // bookmark
+ GlobalApp.getQuickConnectHistoryGateway().removeHistoryItem(
+ bookmark.get().getHostname());
+ }
+ else
+ {
+ assert false;
+ return;
+ }
+
+ // insert or update bookmark and leave
+ // activity
+ if (bookmark.getId() > 0)
+ bookmarkGateway.update(bookmark);
+ else
+ bookmarkGateway.insert(bookmark);
+
+ finishAndResetBookmark();
+ }
+ })
+ .setNegativeButton(R.string.no,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ finishAndResetBookmark();
+ }
+ })
+ .show();
+ }
+ else
+ {
+ finishAndResetBookmark();
+ }
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HelpActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HelpActivity.java
index 247635e79..8e1e6b2ed 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HelpActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HelpActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -22,50 +23,55 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Locale;
-public class HelpActivity extends AppCompatActivity {
+public class HelpActivity extends AppCompatActivity
+{
- private static final String TAG = HelpActivity.class.toString();
+ private static final String TAG = HelpActivity.class.toString();
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
- WebView webview = new WebView(this);
- setContentView(webview);
+ WebView webview = new WebView(this);
+ setContentView(webview);
- String filename;
- if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
- filename = "gestures.html";
- else
- filename = "gestures_phone.html";
+ String filename;
+ if ((getResources().getConfiguration().screenLayout &
+ Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
+ filename = "gestures.html";
+ else
+ filename = "gestures_phone.html";
- WebSettings settings = webview.getSettings();
- settings.setDomStorageEnabled(true);
- settings.setUseWideViewPort(true);
- settings.setLoadWithOverviewMode(true);
- settings.setSupportZoom(true);
- settings.setJavaScriptEnabled(true);
-
- settings.setAllowContentAccess(true);
- settings.setAllowFileAccess(true);
+ WebSettings settings = webview.getSettings();
+ settings.setDomStorageEnabled(true);
+ settings.setUseWideViewPort(true);
+ settings.setLoadWithOverviewMode(true);
+ settings.setSupportZoom(true);
+ settings.setJavaScriptEnabled(true);
- final Locale def = Locale.getDefault();
- final String prefix = def.getLanguage().toLowerCase(def);
+ settings.setAllowContentAccess(true);
+ settings.setAllowFileAccess(true);
- final String base = "file:///android_asset/";
- final String baseName = "help_page";
- String dir = prefix + "_" + baseName + "/";
- String file = dir + filename;
- InputStream is;
- try {
- is = getAssets().open(file);
- is.close();
- } catch (IOException e) {
- Log.e(TAG, "Missing localized asset " + file, e);
- dir = baseName + "/";
- file = dir + filename;
- }
+ final Locale def = Locale.getDefault();
+ final String prefix = def.getLanguage().toLowerCase(def);
- webview.loadUrl(base + file);
- }
+ final String base = "file:///android_asset/";
+ final String baseName = "help_page";
+ String dir = prefix + "_" + baseName + "/";
+ String file = dir + filename;
+ InputStream is;
+ try
+ {
+ is = getAssets().open(file);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ Log.e(TAG, "Missing localized asset " + file, e);
+ dir = baseName + "/";
+ file = dir + filename;
+ }
+
+ webview.loadUrl(base + file);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HomeActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HomeActivity.java
index 7407373d2..48e197743 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HomeActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/HomeActivity.java
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -45,303 +46,354 @@ import com.freerdp.freerdpcore.utils.SeparatedListAdapter;
import java.util.ArrayList;
-public class HomeActivity extends AppCompatActivity {
- private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
- private static final String TAG = "HomeActivity";
- private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
- private ListView listViewBookmarks;
- private Button clearTextButton;
- private EditText superBarEditText;
- private BookmarkArrayAdapter manualBookmarkAdapter;
- private SeparatedListAdapter separatedListAdapter;
- private PlaceholderBookmark addBookmarkPlaceholder;
- private String sectionLabelBookmarks;
+public class HomeActivity extends AppCompatActivity
+{
+ private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
+ private static final String TAG = "HomeActivity";
+ private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
+ private ListView listViewBookmarks;
+ private Button clearTextButton;
+ private EditText superBarEditText;
+ private BookmarkArrayAdapter manualBookmarkAdapter;
+ private SeparatedListAdapter separatedListAdapter;
+ private PlaceholderBookmark addBookmarkPlaceholder;
+ private String sectionLabelBookmarks;
- View mDecor;
+ View mDecor;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- setTitle(R.string.title_home);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.home);
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ setTitle(R.string.title_home);
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.home);
- mDecor = getWindow().getDecorView();
- mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ mDecor = getWindow().getDecorView();
+ mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
- long heapSize = Runtime.getRuntime().maxMemory();
- Log.i(TAG, "Max HeapSize: " + heapSize);
- Log.i(TAG, "App data folder: " + getFilesDir().toString());
+ long heapSize = Runtime.getRuntime().maxMemory();
+ Log.i(TAG, "Max HeapSize: " + heapSize);
+ Log.i(TAG, "App data folder: " + getFilesDir().toString());
- // load strings
- sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
+ // load strings
+ sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
- // create add bookmark/quick connect bookmark placeholder
- addBookmarkPlaceholder = new PlaceholderBookmark();
- addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
- addBookmarkPlaceholder.setLabel(getResources().getString(R.string.list_placeholder_add_bookmark));
+ // create add bookmark/quick connect bookmark placeholder
+ addBookmarkPlaceholder = new PlaceholderBookmark();
+ addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
+ addBookmarkPlaceholder.setLabel(
+ getResources().getString(R.string.list_placeholder_add_bookmark));
- // check for passed .rdp file and open it in a new bookmark
- Intent caller = getIntent();
- Uri callParameter = caller.getData();
+ // check for passed .rdp file and open it in a new bookmark
+ Intent caller = getIntent();
+ Uri callParameter = caller.getData();
- if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null) {
- String refStr = ConnectionReference.getFileReference(callParameter.getPath());
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null)
+ {
+ String refStr = ConnectionReference.getFileReference(callParameter.getPath());
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivity(bookmarkIntent);
- }
+ Intent bookmarkIntent =
+ new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivity(bookmarkIntent);
+ }
- // load views
- clearTextButton = (Button) findViewById(R.id.clear_search_btn);
- superBarEditText = (EditText) findViewById(R.id.superBarEditText);
+ // load views
+ clearTextButton = (Button)findViewById(R.id.clear_search_btn);
+ superBarEditText = (EditText)findViewById(R.id.superBarEditText);
- listViewBookmarks = (ListView) findViewById(R.id.listViewBookmarks);
+ listViewBookmarks = (ListView)findViewById(R.id.listViewBookmarks);
- // set listeners for the list view
- listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- String curSection = separatedListAdapter.getSectionForPosition(position);
- Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) + " in section " + curSection);
- if (curSection == sectionLabelBookmarks) {
- String refStr = view.getTag().toString();
- if (ConnectionReference.isManualBookmarkReference(refStr) ||
- ConnectionReference.isHostnameReference(refStr)) {
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ // set listeners for the list view
+ listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ String curSection = separatedListAdapter.getSectionForPosition(position);
+ Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) +
+ " in section " + curSection);
+ if (curSection == sectionLabelBookmarks)
+ {
+ String refStr = view.getTag().toString();
+ if (ConnectionReference.isManualBookmarkReference(refStr) ||
+ ConnectionReference.isHostnameReference(refStr))
+ {
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
- sessionIntent.putExtras(bundle);
- startActivity(sessionIntent);
+ Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
+ sessionIntent.putExtras(bundle);
+ startActivity(sessionIntent);
- // clear any search text
- superBarEditText.setText("");
- superBarEditText.clearFocus();
- } else if (ConnectionReference.isPlaceholderReference(refStr)) {
- // is this the add bookmark placeholder?
- if (ConnectionReference.getPlaceholder(refStr).equals(ADD_BOOKMARK_PLACEHOLDER)) {
- Intent bookmarkIntent = new Intent(view.getContext(), BookmarkActivity.class);
- startActivity(bookmarkIntent);
- }
- }
- }
- }
- });
+ // clear any search text
+ superBarEditText.setText("");
+ superBarEditText.clearFocus();
+ }
+ else if (ConnectionReference.isPlaceholderReference(refStr))
+ {
+ // is this the add bookmark placeholder?
+ if (ConnectionReference.getPlaceholder(refStr).equals(
+ ADD_BOOKMARK_PLACEHOLDER))
+ {
+ Intent bookmarkIntent =
+ new Intent(view.getContext(), BookmarkActivity.class);
+ startActivity(bookmarkIntent);
+ }
+ }
+ }
+ }
+ });
- listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- // if the selected item is not a session item (tag == null) and not a quick connect entry
- // (not a hostname connection reference) inflate the context menu
- View itemView = ((AdapterContextMenuInfo) menuInfo).targetView;
- String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
- if (refStr != null && !ConnectionReference.isHostnameReference(refStr) && !ConnectionReference.isPlaceholderReference(refStr)) {
- getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
- menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
- }
- }
- });
+ listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
+ {
+ // if the selected item is not a session item (tag == null) and not a quick connect
+ // entry (not a hostname connection reference) inflate the context menu
+ View itemView = ((AdapterContextMenuInfo)menuInfo).targetView;
+ String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
+ if (refStr != null && !ConnectionReference.isHostnameReference(refStr) &&
+ !ConnectionReference.isPlaceholderReference(refStr))
+ {
+ getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
+ menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
+ }
+ }
+ });
- superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
+ superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
- clearTextButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- superBarEditText.setText("");
- }
- });
- }
+ clearTextButton.setOnClickListener(new OnClickListener() {
+ @Override public void onClick(View v)
+ {
+ superBarEditText.setText("");
+ }
+ });
+ }
+ @Override public void onConfigurationChanged(Configuration newConfig)
+ {
+ // ignore orientation/keyboard change
+ super.onConfigurationChanged(newConfig);
+ mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- // ignore orientation/keyboard change
- super.onConfigurationChanged(newConfig);
- mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
- }
+ @Override public boolean onSearchRequested()
+ {
+ superBarEditText.requestFocus();
+ return true;
+ }
- @Override
- public boolean onSearchRequested() {
- superBarEditText.requestFocus();
- return true;
- }
+ @Override public boolean onContextItemSelected(MenuItem aItem)
+ {
- @Override
- public boolean onContextItemSelected(MenuItem aItem) {
+ // get connection reference
+ AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)aItem.getMenuInfo();
+ String refStr = menuInfo.targetView.getTag().toString();
- // get connection reference
- AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
- String refStr = menuInfo.targetView.getTag().toString();
+ // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case
+ // here ..
+ int itemId = aItem.getItemId();
+ if (itemId == R.id.bookmark_connect)
+ {
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent sessionIntent = new Intent(this, SessionActivity.class);
+ sessionIntent.putExtras(bundle);
- // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
- int itemId = aItem.getItemId();
- if (itemId == R.id.bookmark_connect) {
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent sessionIntent = new Intent(this, SessionActivity.class);
- sessionIntent.putExtras(bundle);
+ startActivity(sessionIntent);
+ return true;
+ }
+ else if (itemId == R.id.bookmark_edit)
+ {
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
- startActivity(sessionIntent);
- return true;
- } else if (itemId == R.id.bookmark_edit) {
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent bookmarkIntent =
+ new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivity(bookmarkIntent);
+ return true;
+ }
+ else if (itemId == R.id.bookmark_delete)
+ {
+ if (ConnectionReference.isManualBookmarkReference(refStr))
+ {
+ long id = ConnectionReference.getManualBookmarkId(refStr);
+ GlobalApp.getManualBookmarkGateway().delete(id);
+ manualBookmarkAdapter.remove(id);
+ separatedListAdapter.notifyDataSetChanged();
+ }
+ else
+ {
+ assert false;
+ }
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivity(bookmarkIntent);
- return true;
- } else if (itemId == R.id.bookmark_delete) {
- if (ConnectionReference.isManualBookmarkReference(refStr)) {
- long id = ConnectionReference.getManualBookmarkId(refStr);
- GlobalApp.getManualBookmarkGateway().delete(id);
- manualBookmarkAdapter.remove(id);
- separatedListAdapter.notifyDataSetChanged();
- } else {
- assert false;
- }
+ // clear super bar text
+ superBarEditText.setText("");
+ return true;
+ }
- // clear super bar text
- superBarEditText.setText("");
- return true;
- }
+ return false;
+ }
- return false;
- }
+ @Override protected void onResume()
+ {
+ super.onResume();
+ Log.v(TAG, "HomeActivity.onResume");
- @Override
- protected void onResume() {
- super.onResume();
- Log.v(TAG, "HomeActivity.onResume");
+ // create bookmark cursor adapter
+ manualBookmarkAdapter = new BookmarkArrayAdapter(
+ this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
- // create bookmark cursor adapter
- manualBookmarkAdapter = new BookmarkArrayAdapter(this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
+ // add add bookmark item to manual adapter
+ manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
- // add add bookmark item to manual adapter
- manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
+ // attach all adapters to the separatedListView adapter and assign it to the list view
+ separatedListAdapter = new SeparatedListAdapter(this);
+ separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
+ listViewBookmarks.setAdapter(separatedListAdapter);
- // attach all adapters to the separatedListView adapter and assign it to the list view
- separatedListAdapter = new SeparatedListAdapter(this);
- separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
- listViewBookmarks.setAdapter(separatedListAdapter);
+ // if we have a filter text entered cause an update to be caused here
+ String filter = superBarEditText.getText().toString();
+ if (filter.length() > 0)
+ superBarEditText.setText(filter);
+ }
- // if we have a filter text entered cause an update to be caused here
- String filter = superBarEditText.getText().toString();
- if (filter.length() > 0)
- superBarEditText.setText(filter);
- }
+ @Override protected void onPause()
+ {
+ super.onPause();
+ Log.v(TAG, "HomeActivity.onPause");
- @Override
- protected void onPause() {
- super.onPause();
- Log.v(TAG, "HomeActivity.onPause");
+ // reset adapters
+ listViewBookmarks.setAdapter(null);
+ separatedListAdapter = null;
+ manualBookmarkAdapter = null;
+ }
- // reset adapters
- listViewBookmarks.setAdapter(null);
- separatedListAdapter = null;
- manualBookmarkAdapter = null;
- }
+ @Override public void onBackPressed()
+ {
+ // if back was pressed - ask the user if he really wants to exit
+ if (ApplicationSettingsActivity.getAskOnExit(this))
+ {
+ final CheckBox cb = new CheckBox(this);
+ cb.setChecked(!ApplicationSettingsActivity.getAskOnExit(this));
+ cb.setText(R.string.dlg_dont_show_again);
- @Override
- public void onBackPressed() {
- // if back was pressed - ask the user if he really wants to exit
- if (ApplicationSettingsActivity.getAskOnExit(this)) {
- final CheckBox cb = new CheckBox(this);
- cb.setChecked(!ApplicationSettingsActivity.getAskOnExit(this));
- cb.setText(R.string.dlg_dont_show_again);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_exit)
+ .setMessage(R.string.dlg_msg_exit)
+ .setView(cb)
+ .setPositiveButton(R.string.yes,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ finish();
+ }
+ })
+ .setNegativeButton(R.string.no,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ dialog.dismiss();
+ }
+ })
+ .create()
+ .show();
+ }
+ else
+ {
+ super.onBackPressed();
+ }
+ }
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_exit)
- .setMessage(R.string.dlg_msg_exit)
- .setView(cb)
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- })
- .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .create()
- .show();
- } else {
- super.onBackPressed();
- }
- }
+ @Override protected void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
+ }
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
- }
+ @Override protected void onRestoreInstanceState(Bundle inState)
+ {
+ super.onRestoreInstanceState(inState);
+ superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
+ }
- @Override
- protected void onRestoreInstanceState(Bundle inState) {
- super.onRestoreInstanceState(inState);
- superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
- }
+ @Override public boolean onCreateOptionsMenu(Menu menu)
+ {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.home_menu, menu);
+ return true;
+ }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.home_menu, menu);
- return true;
- }
+ @Override public boolean onOptionsItemSelected(MenuItem item)
+ {
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case
+ // here ..
+ int itemId = item.getItemId();
+ if (itemId == R.id.newBookmark)
+ {
+ Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
+ startActivity(bookmarkIntent);
+ }
+ else if (itemId == R.id.appSettings)
+ {
+ Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
+ startActivity(settingsIntent);
+ }
+ else if (itemId == R.id.help)
+ {
+ Intent helpIntent = new Intent(this, HelpActivity.class);
+ startActivity(helpIntent);
+ }
+ else if (itemId == R.id.about)
+ {
+ Intent aboutIntent = new Intent(this, AboutActivity.class);
+ startActivity(aboutIntent);
+ }
- // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
- int itemId = item.getItemId();
- if (itemId == R.id.newBookmark) {
- Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
- startActivity(bookmarkIntent);
- } else if (itemId == R.id.appSettings) {
- Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
- startActivity(settingsIntent);
- } else if (itemId == R.id.help) {
- Intent helpIntent = new Intent(this, HelpActivity.class);
- startActivity(helpIntent);
- } else if (itemId == R.id.about) {
- Intent aboutIntent = new Intent(this, AboutActivity.class);
- startActivity(aboutIntent);
- }
+ return true;
+ }
- return true;
- }
+ private class SuperBarTextWatcher implements TextWatcher
+ {
+ @Override public void afterTextChanged(Editable s)
+ {
+ if (separatedListAdapter != null)
+ {
+ String text = s.toString();
+ if (text.length() > 0)
+ {
+ ArrayList computers_list =
+ GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
+ computers_list.addAll(
+ GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
+ manualBookmarkAdapter.replaceItems(computers_list);
+ QuickConnectBookmark qcBm = new QuickConnectBookmark();
+ qcBm.setLabel(text);
+ qcBm.setHostname(text);
+ manualBookmarkAdapter.insert(qcBm, 0);
+ }
+ else
+ {
+ manualBookmarkAdapter.replaceItems(
+ GlobalApp.getManualBookmarkGateway().findAll());
+ manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
+ }
- private class SuperBarTextWatcher implements TextWatcher {
- @Override
- public void afterTextChanged(Editable s) {
- if (separatedListAdapter != null) {
- String text = s.toString();
- if (text.length() > 0) {
- ArrayList computers_list = GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
- computers_list.addAll(GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
- manualBookmarkAdapter.replaceItems(computers_list);
- QuickConnectBookmark qcBm = new QuickConnectBookmark();
- qcBm.setLabel(text);
- qcBm.setHostname(text);
- manualBookmarkAdapter.insert(qcBm, 0);
- } else {
- manualBookmarkAdapter.replaceItems(GlobalApp.getManualBookmarkGateway().findAll());
- manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
- }
+ separatedListAdapter.notifyDataSetChanged();
+ }
+ }
- separatedListAdapter.notifyDataSetChanged();
- }
- }
+ @Override public void beforeTextChanged(CharSequence s, int start, int count, int after)
+ {
+ }
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
- }
+ @Override public void onTextChanged(CharSequence s, int start, int before, int count)
+ {
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ScrollView2D.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ScrollView2D.java
index a2fee7c5c..ad1d572e8 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ScrollView2D.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ScrollView2D.java
@@ -54,1097 +54,1296 @@ import java.util.List;
* using the two together is possible to achieve the effect of a text view
* within a larger container.
*/
-public class ScrollView2D extends FrameLayout {
-
- static final int ANIMATED_SCROLL_GAP = 250;
- static final float MAX_SCROLL_FACTOR = 0.5f;
- private final Rect mTempRect = new Rect();
- private ScrollView2DListener scrollView2DListener = null;
- private long mLastScroll;
- private Scroller mScroller;
- private boolean scrollEnabled = true;
- /**
- * Flag to indicate that we are moving focus ourselves. This is so the
- * code that watches for focus changes initiated outside this TwoDScrollView
- * knows that it does not have to do anything.
- */
- private boolean mTwoDScrollViewMovedFocus;
- /**
- * Position of the last motion event.
- */
- private float mLastMotionY;
- private float mLastMotionX;
- /**
- * True when the layout has changed but the traversal has not come through yet.
- * Ideally the view hierarchy would keep track of this for us.
- */
- private boolean mIsLayoutDirty = true;
- /**
- * The child to give focus to in the event that a child has requested focus while the
- * layout is dirty. This prevents the scroll from being wrong if the child has not been
- * laid out before requesting focus.
- */
- private View mChildToScrollTo = null;
- /**
- * True if the user is currently dragging this TwoDScrollView around. This is
- * not the same as 'is being flinged', which can be checked by
- * mScroller.isFinished() (flinging begins when the user lifts his finger).
- */
- private boolean mIsBeingDragged = false;
- /**
- * Determines speed during touch scrolling
- */
- private VelocityTracker mVelocityTracker;
- /**
- * Whether arrow scrolling is animated.
- */
- private int mTouchSlop;
- private int mMinimumVelocity;
- private int mMaximumVelocity;
- public ScrollView2D(Context context) {
- super(context);
- initTwoDScrollView();
- }
-
- public ScrollView2D(Context context, AttributeSet attrs) {
- super(context, attrs);
- initTwoDScrollView();
- }
-
- public ScrollView2D(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initTwoDScrollView();
- }
-
- @Override
- protected float getTopFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getVerticalFadingEdgeLength();
- if (getScrollY() < length) {
- return getScrollY() / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getBottomFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getVerticalFadingEdgeLength();
- final int bottomEdge = getHeight() - getPaddingBottom();
- final int span = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
- if (span < length) {
- return span / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getLeftFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getHorizontalFadingEdgeLength();
- if (getScrollX() < length) {
- return getScrollX() / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getRightFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getHorizontalFadingEdgeLength();
- final int rightEdge = getWidth() - getPaddingRight();
- final int span = getChildAt(0).getRight() - getScrollX() - rightEdge;
- if (span < length) {
- return span / (float) length;
- }
- return 1.0f;
- }
-
- /**
- * Disable/Enable scrolling
- */
- public void setScrollEnabled(boolean enable) {
- scrollEnabled = enable;
- }
-
- /**
- * @return The maximum amount this scroll view will scroll in response to
- * an arrow event.
- */
- public int getMaxScrollAmountVertical() {
- return (int) (MAX_SCROLL_FACTOR * getHeight());
- }
-
- public int getMaxScrollAmountHorizontal() {
- return (int) (MAX_SCROLL_FACTOR * getWidth());
- }
-
- private void initTwoDScrollView() {
- mScroller = new Scroller(getContext());
- setFocusable(true);
- setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
- setWillNotDraw(false);
- final ViewConfiguration configuration = ViewConfiguration.get(getContext());
- mTouchSlop = configuration.getScaledTouchSlop();
- mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
- mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
- }
-
- @Override
- public void addView(View child) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child);
- }
-
- @Override
- public void addView(View child, int index) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, index);
- }
-
- @Override
- public void addView(View child, ViewGroup.LayoutParams params) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, params);
- }
-
- @Override
- public void addView(View child, int index, ViewGroup.LayoutParams params) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, index, params);
- }
-
- /**
- * @return Returns true this TwoDScrollView can be scrolled
- */
- private boolean canScroll() {
- if (!scrollEnabled)
- return false;
- View child = getChildAt(0);
- if (child != null) {
- int childHeight = child.getHeight();
- int childWidth = child.getWidth();
- return (getHeight() < childHeight + getPaddingTop() + getPaddingBottom()) ||
- (getWidth() < childWidth + getPaddingLeft() + getPaddingRight());
- }
- return false;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- // Let the focused view and/or our descendants get the key first
- boolean handled = super.dispatchKeyEvent(event);
- if (handled) {
- return true;
- }
- return executeKeyEvent(event);
- }
-
- /**
- * You can call this function yourself to have the scroll view perform
- * scrolling from a key event, just as if the event had been dispatched to
- * it by the view hierarchy.
- *
- * @param event The key event to execute.
- * @return Return true if the event was handled, else false.
- */
- public boolean executeKeyEvent(KeyEvent event) {
- mTempRect.setEmpty();
- if (!canScroll()) {
- if (isFocused()) {
- View currentFocused = findFocus();
- if (currentFocused == this) currentFocused = null;
- View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
- return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
- }
- return false;
- }
- boolean handled = false;
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_DPAD_UP:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_UP, false);
- } else {
- handled = fullScroll(View.FOCUS_UP, false);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_DOWN, false);
- } else {
- handled = fullScroll(View.FOCUS_DOWN, false);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_LEFT, true);
- } else {
- handled = fullScroll(View.FOCUS_LEFT, true);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_RIGHT, true);
- } else {
- handled = fullScroll(View.FOCUS_RIGHT, true);
- }
- break;
- }
- }
- return handled;
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- /*
- * This method JUST determines whether we want to intercept the motion.
- * If we return true, onMotionEvent will be called and we do the actual
- * scrolling there.
- *
- * Shortcut the most recurring case: the user is in the dragging
- * state and he is moving his finger. We want to intercept this
- * motion.
- */
- final int action = ev.getAction();
- if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged)) {
- return true;
- }
- if (!canScroll()) {
- mIsBeingDragged = false;
- return false;
- }
- final float y = ev.getY();
- final float x = ev.getX();
- switch (action) {
- case MotionEvent.ACTION_MOVE:
- /*
- * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
- * whether the user has moved far enough from his original down touch.
- */
- /*
- * Locally do absolute value. mLastMotionY is set to the y value
- * of the down event.
- */
- final int yDiff = (int) Math.abs(y - mLastMotionY);
- final int xDiff = (int) Math.abs(x - mLastMotionX);
- if (yDiff > mTouchSlop || xDiff > mTouchSlop) {
- mIsBeingDragged = true;
- }
- break;
-
- case MotionEvent.ACTION_DOWN:
- /* Remember location of down touch */
- mLastMotionY = y;
- mLastMotionX = x;
-
- /*
- * If being flinged and user touches the screen, initiate drag;
- * otherwise don't. mScroller.isFinished should be false when
- * being flinged.
- */
- mIsBeingDragged = !mScroller.isFinished();
- break;
-
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- /* Release the drag */
- mIsBeingDragged = false;
- break;
- }
-
- /*
- * The only time we want to intercept motion events is if we are in the
- * drag mode.
- */
- return mIsBeingDragged;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
-
- if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
- // Don't handle edge touches immediately -- they may actually belong to one of our
- // descendants.
- return false;
- }
-
- if (!canScroll()) {
- return false;
- }
-
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- }
- mVelocityTracker.addMovement(ev);
-
- final int action = ev.getAction();
- final float y = ev.getY();
- final float x = ev.getX();
-
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- /*
- * If being flinged and user touches, stop the fling. isFinished
- * will be false if being flinged.
- */
- if (!mScroller.isFinished()) {
- mScroller.abortAnimation();
- }
-
- // Remember where the motion event started
- mLastMotionY = y;
- mLastMotionX = x;
- break;
- case MotionEvent.ACTION_MOVE:
- // Scroll to follow the motion event
- int deltaX = (int) (mLastMotionX - x);
- int deltaY = (int) (mLastMotionY - y);
- mLastMotionX = x;
- mLastMotionY = y;
-
- if (deltaX < 0) {
- if (getScrollX() < 0) {
- deltaX = 0;
- }
- } else if (deltaX > 0) {
- final int rightEdge = getWidth() - getPaddingRight();
- final int availableToScroll = getChildAt(0).getRight() - getScrollX() - rightEdge;
- if (availableToScroll > 0) {
- deltaX = Math.min(availableToScroll, deltaX);
- } else {
- deltaX = 0;
- }
- }
- if (deltaY < 0) {
- if (getScrollY() < 0) {
- deltaY = 0;
- }
- } else if (deltaY > 0) {
- final int bottomEdge = getHeight() - getPaddingBottom();
- final int availableToScroll = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
- if (availableToScroll > 0) {
- deltaY = Math.min(availableToScroll, deltaY);
- } else {
- deltaY = 0;
- }
- }
- if (deltaY != 0 || deltaX != 0)
- scrollBy(deltaX, deltaY);
- break;
- case MotionEvent.ACTION_UP:
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- int initialXVelocity = (int) velocityTracker.getXVelocity();
- int initialYVelocity = (int) velocityTracker.getYVelocity();
- if ((Math.abs(initialXVelocity) + Math.abs(initialYVelocity) > mMinimumVelocity) && getChildCount() > 0) {
- fling(-initialXVelocity, -initialYVelocity);
- }
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
- }
- return true;
- }
-
- /**
- * Finds the next focusable component that fits in this View's bounds
- * (excluding fading edges) pretending that this View's top is located at
- * the parameter top.
- *
- * @param topFocus look for a candidate is the one at the top of the bounds
- * if topFocus is true, or at the bottom of the bounds if topFocus is
- * false
- * @param top the top offset of the bounds in which a focusable must be
- * found (the fading edge is assumed to start at this position)
- * @param preferredFocusable the View that has highest priority and will be
- * returned if it is within my bounds (null is valid)
- * @return the next focusable component in the bounds or null if none can be
- * found
- */
- private View findFocusableViewInMyBounds(final boolean topFocus, final int top, final boolean leftFocus, final int left, View preferredFocusable) {
- /*
- * The fading edge's transparent side should be considered for focus
- * since it's mostly visible, so we divide the actual fading edge length
- * by 2.
- */
- final int verticalFadingEdgeLength = getVerticalFadingEdgeLength() / 2;
- final int topWithoutFadingEdge = top + verticalFadingEdgeLength;
- final int bottomWithoutFadingEdge = top + getHeight() - verticalFadingEdgeLength;
- final int horizontalFadingEdgeLength = getHorizontalFadingEdgeLength() / 2;
- final int leftWithoutFadingEdge = left + horizontalFadingEdgeLength;
- final int rightWithoutFadingEdge = left + getWidth() - horizontalFadingEdgeLength;
-
- if ((preferredFocusable != null)
- && (preferredFocusable.getTop() < bottomWithoutFadingEdge)
- && (preferredFocusable.getBottom() > topWithoutFadingEdge)
- && (preferredFocusable.getLeft() < rightWithoutFadingEdge)
- && (preferredFocusable.getRight() > leftWithoutFadingEdge)) {
- return preferredFocusable;
- }
- return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, bottomWithoutFadingEdge, leftFocus, leftWithoutFadingEdge, rightWithoutFadingEdge);
- }
-
- /**
- * Finds the next focusable component that fits in the specified bounds.
- *
- *
- * @param topFocus look for a candidate is the one at the top of the bounds
- * if topFocus is true, or at the bottom of the bounds if topFocus is
- * false
- * @param top the top offset of the bounds in which a focusable must be
- * found
- * @param bottom the bottom offset of the bounds in which a focusable must
- * be found
- * @return the next focusable component in the bounds or null if none can
- * be found
- */
- private View findFocusableViewInBounds(boolean topFocus, int top, int bottom, boolean leftFocus, int left, int right) {
- List focusables = getFocusables(View.FOCUS_FORWARD);
- View focusCandidate = null;
-
- /*
- * A fully contained focusable is one where its top is below the bound's
- * top, and its bottom is above the bound's bottom. A partially
- * contained focusable is one where some part of it is within the
- * bounds, but it also has some part that is not within bounds. A fully contained
- * focusable is preferred to a partially contained focusable.
- */
- boolean foundFullyContainedFocusable = false;
-
- int count = focusables.size();
- for (int i = 0; i < count; i++) {
- View view = focusables.get(i);
- int viewTop = view.getTop();
- int viewBottom = view.getBottom();
- int viewLeft = view.getLeft();
- int viewRight = view.getRight();
-
- if (top < viewBottom && viewTop < bottom && left < viewRight && viewLeft < right) {
- /*
- * the focusable is in the target area, it is a candidate for
- * focusing
- */
- final boolean viewIsFullyContained = (top < viewTop) && (viewBottom < bottom) && (left < viewLeft) && (viewRight < right);
- if (focusCandidate == null) {
- /* No candidate, take this one */
- focusCandidate = view;
- foundFullyContainedFocusable = viewIsFullyContained;
- } else {
- final boolean viewIsCloserToVerticalBoundary =
- (topFocus && viewTop < focusCandidate.getTop()) ||
- (!topFocus && viewBottom > focusCandidate.getBottom());
- final boolean viewIsCloserToHorizontalBoundary =
- (leftFocus && viewLeft < focusCandidate.getLeft()) ||
- (!leftFocus && viewRight > focusCandidate.getRight());
- if (foundFullyContainedFocusable) {
- if (viewIsFullyContained && viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
- /*
- * We're dealing with only fully contained views, so
- * it has to be closer to the boundary to beat our
- * candidate
- */
- focusCandidate = view;
- }
- } else {
- if (viewIsFullyContained) {
- /* Any fully contained view beats a partially contained view */
- focusCandidate = view;
- foundFullyContainedFocusable = true;
- } else if (viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
- /*
- * Partially contained view beats another partially
- * contained view if it's closer
- */
- focusCandidate = view;
- }
- }
- }
- }
- }
- return focusCandidate;
- }
-
- /**
- * Handles scrolling in response to a "home/end" shortcut press. This
- * method will scroll the view to the top or bottom and give the focus
- * to the topmost/bottommost component in the new visible area. If no
- * component is a good candidate for focus, this scrollview reclaims the
- * focus.
- *
- * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
- * to go the top of the view or
- * {@link android.view.View#FOCUS_DOWN} to go the bottom
- * @return true if the key event is consumed by this method, false otherwise
- */
- public boolean fullScroll(int direction, boolean horizontal) {
- if (!horizontal) {
- boolean down = direction == View.FOCUS_DOWN;
- int height = getHeight();
- mTempRect.top = 0;
- mTempRect.bottom = height;
- if (down) {
- int count = getChildCount();
- if (count > 0) {
- View view = getChildAt(count - 1);
- mTempRect.bottom = view.getBottom();
- mTempRect.top = mTempRect.bottom - height;
- }
- }
- return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom, 0, 0, 0);
- } else {
- boolean right = direction == View.FOCUS_DOWN;
- int width = getWidth();
- mTempRect.left = 0;
- mTempRect.right = width;
- if (right) {
- int count = getChildCount();
- if (count > 0) {
- View view = getChildAt(count - 1);
- mTempRect.right = view.getBottom();
- mTempRect.left = mTempRect.right - width;
- }
- }
- return scrollAndFocus(0, 0, 0, direction, mTempRect.top, mTempRect.bottom);
- }
- }
-
- /**
- * Scrolls the view to make the area defined by top and
- * bottom visible. This method attempts to give the focus
- * to a component visible in this area. If no component can be focused in
- * the new visible area, the focus is reclaimed by this scrollview.
- *
- * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
- * to go upward
- * {@link android.view.View#FOCUS_DOWN} to downward
- * @param top the top offset of the new area to be made visible
- * @param bottom the bottom offset of the new area to be made visible
- * @return true if the key event is consumed by this method, false otherwise
- */
- private boolean scrollAndFocus(int directionY, int top, int bottom, int directionX, int left, int right) {
- boolean handled = true;
- int height = getHeight();
- int containerTop = getScrollY();
- int containerBottom = containerTop + height;
- boolean up = directionY == View.FOCUS_UP;
- int width = getWidth();
- int containerLeft = getScrollX();
- int containerRight = containerLeft + width;
- boolean leftwards = directionX == View.FOCUS_UP;
- View newFocused = findFocusableViewInBounds(up, top, bottom, leftwards, left, right);
- if (newFocused == null) {
- newFocused = this;
- }
- if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) {
- handled = false;
- } else {
- int deltaY = up ? (top - containerTop) : (bottom - containerBottom);
- int deltaX = leftwards ? (left - containerLeft) : (right - containerRight);
- doScroll(deltaX, deltaY);
- }
- if (newFocused != findFocus() && newFocused.requestFocus(directionY)) {
- mTwoDScrollViewMovedFocus = true;
- mTwoDScrollViewMovedFocus = false;
- }
- return handled;
- }
-
- /**
- * Handle scrolling in response to an up or down arrow click.
- *
- * @param direction The direction corresponding to the arrow key that was
- * pressed
- * @return True if we consumed the event, false otherwise
- */
- public boolean arrowScroll(int direction, boolean horizontal) {
- View currentFocused = findFocus();
- if (currentFocused == this) currentFocused = null;
- View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
- final int maxJump = horizontal ? getMaxScrollAmountHorizontal() : getMaxScrollAmountVertical();
-
- if (!horizontal) {
- if (nextFocused != null) {
- nextFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(nextFocused, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(0, scrollDelta);
- nextFocused.requestFocus(direction);
- } else {
- // no new focus
- int scrollDelta = maxJump;
- if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
- scrollDelta = getScrollY();
- } else if (direction == View.FOCUS_DOWN) {
- if (getChildCount() > 0) {
- int daBottom = getChildAt(0).getBottom();
- int screenBottom = getScrollY() + getHeight();
- if (daBottom - screenBottom < maxJump) {
- scrollDelta = daBottom - screenBottom;
- }
- }
- }
- if (scrollDelta == 0) {
- return false;
- }
- doScroll(0, direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta);
- }
- } else {
- if (nextFocused != null) {
- nextFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(nextFocused, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(scrollDelta, 0);
- nextFocused.requestFocus(direction);
- } else {
- // no new focus
- int scrollDelta = maxJump;
- if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
- scrollDelta = getScrollY();
- } else if (direction == View.FOCUS_DOWN) {
- if (getChildCount() > 0) {
- int daBottom = getChildAt(0).getBottom();
- int screenBottom = getScrollY() + getHeight();
- if (daBottom - screenBottom < maxJump) {
- scrollDelta = daBottom - screenBottom;
- }
- }
- }
- if (scrollDelta == 0) {
- return false;
- }
- doScroll(direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta, 0);
- }
- }
- return true;
- }
-
- /**
- * Smooth scroll by a Y delta
- *
- * @param delta the number of pixels to scroll by on the Y axis
- */
- private void doScroll(int deltaX, int deltaY) {
- if (deltaX != 0 || deltaY != 0) {
- smoothScrollBy(deltaX, deltaY);
- }
- }
-
- /**
- * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
- *
- * @param dx the number of pixels to scroll by on the X axis
- * @param dy the number of pixels to scroll by on the Y axis
- */
- public final void smoothScrollBy(int dx, int dy) {
- long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
- if (duration > ANIMATED_SCROLL_GAP) {
- mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
- awakenScrollBars(mScroller.getDuration());
- invalidate();
- } else {
- if (!mScroller.isFinished()) {
- mScroller.abortAnimation();
- }
- scrollBy(dx, dy);
- }
- mLastScroll = AnimationUtils.currentAnimationTimeMillis();
- }
-
- /**
- * Like {@link #scrollTo}, but scroll smoothly instead of immediately.
- *
- * @param x the position where to scroll on the X axis
- * @param y the position where to scroll on the Y axis
- */
- public final void smoothScrollTo(int x, int y) {
- smoothScrollBy(x - getScrollX(), y - getScrollY());
- }
-
- /**
- * The scroll range of a scroll view is the overall height of all of its
- * children.
- */
- @Override
- protected int computeVerticalScrollRange() {
- int count = getChildCount();
- return count == 0 ? getHeight() : (getChildAt(0)).getBottom();
- }
-
- @Override
- protected int computeHorizontalScrollRange() {
- int count = getChildCount();
- return count == 0 ? getWidth() : (getChildAt(0)).getRight();
- }
-
- @Override
- protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
- ViewGroup.LayoutParams lp = child.getLayoutParams();
- int childWidthMeasureSpec;
- int childHeightMeasureSpec;
-
- childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, getPaddingLeft() + getPaddingRight(), lp.width);
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
-
- @Override
- protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
- final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
- final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
- final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.topMargin + lp.bottomMargin, MeasureSpec.UNSPECIFIED);
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
-
- @Override
- public void computeScroll() {
- if (mScroller.computeScrollOffset()) {
- // This is called at drawing time by ViewGroup. We don't want to
- // re-show the scrollbars at this point, which scrollTo will do,
- // so we replicate most of scrollTo here.
- //
- // It's a little odd to call onScrollChanged from inside the drawing.
- //
- // It is, except when you remember that computeScroll() is used to
- // animate scrolling. So unless we want to defer the onScrollChanged()
- // until the end of the animated scrolling, we don't really have a
- // choice here.
- //
- // I agree. The alternative, which I think would be worse, is to post
- // something and tell the subclasses later. This is bad because there
- // will be a window where mScrollX/Y is different from what the app
- // thinks it is.
- //
- int oldX = getScrollX();
- int oldY = getScrollY();
- int x = mScroller.getCurrX();
- int y = mScroller.getCurrY();
- if (getChildCount() > 0) {
- View child = getChildAt(0);
- scrollTo(clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth()),
- clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight()));
- } else {
- scrollTo(x, y);
- }
- if (oldX != getScrollX() || oldY != getScrollY()) {
- onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
- }
-
- // Keep on drawing until the animation has finished.
- postInvalidate();
- }
- }
-
- /**
- * Scrolls the view to the given child.
- *
- * @param child the View to scroll to
- */
- private void scrollToChild(View child) {
- child.getDrawingRect(mTempRect);
- /* Offset from child's local coordinates to TwoDScrollView coordinates */
- offsetDescendantRectToMyCoords(child, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- if (scrollDelta != 0) {
- scrollBy(0, scrollDelta);
- }
- }
-
- /**
- * If rect is off screen, scroll just enough to get it (or at least the
- * first screen size chunk of it) on screen.
- *
- * @param rect The rectangle.
- * @param immediate True to scroll immediately without animation
- * @return true if scrolling was performed
- */
- private boolean scrollToChildRect(Rect rect, boolean immediate) {
- final int delta = computeScrollDeltaToGetChildRectOnScreen(rect);
- final boolean scroll = delta != 0;
- if (scroll) {
- if (immediate) {
- scrollBy(0, delta);
- } else {
- smoothScrollBy(0, delta);
- }
- }
- return scroll;
- }
-
- /**
- * Compute the amount to scroll in the Y direction in order to get
- * a rectangle completely on the screen (or, if taller than the screen,
- * at least the first screen size chunk of it).
- *
- * @param rect The rect.
- * @return The scroll delta.
- */
- protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
- if (getChildCount() == 0) return 0;
- int height = getHeight();
- int screenTop = getScrollY();
- int screenBottom = screenTop + height;
- int fadingEdge = getVerticalFadingEdgeLength();
- // leave room for top fading edge as long as rect isn't at very top
- if (rect.top > 0) {
- screenTop += fadingEdge;
- }
-
- // leave room for bottom fading edge as long as rect isn't at very bottom
- if (rect.bottom < getChildAt(0).getHeight()) {
- screenBottom -= fadingEdge;
- }
- int scrollYDelta = 0;
- if (rect.bottom > screenBottom && rect.top > screenTop) {
- // need to move down to get it in view: move down just enough so
- // that the entire rectangle is in view (or at least the first
- // screen size chunk).
- if (rect.height() > height) {
- // just enough to get screen size chunk on
- scrollYDelta += (rect.top - screenTop);
- } else {
- // get entire rect at bottom of screen
- scrollYDelta += (rect.bottom - screenBottom);
- }
-
- // make sure we aren't scrolling beyond the end of our content
- int bottom = getChildAt(0).getBottom();
- int distanceToBottom = bottom - screenBottom;
- scrollYDelta = Math.min(scrollYDelta, distanceToBottom);
-
- } else if (rect.top < screenTop && rect.bottom < screenBottom) {
- // need to move up to get it in view: move up just enough so that
- // entire rectangle is in view (or at least the first screen
- // size chunk of it).
-
- if (rect.height() > height) {
- // screen size chunk
- scrollYDelta -= (screenBottom - rect.bottom);
- } else {
- // entire rect at top
- scrollYDelta -= (screenTop - rect.top);
- }
-
- // make sure we aren't scrolling any further than the top our content
- scrollYDelta = Math.max(scrollYDelta, -getScrollY());
- }
- return scrollYDelta;
- }
-
- @Override
- public void requestChildFocus(View child, View focused) {
- if (!mTwoDScrollViewMovedFocus) {
- if (!mIsLayoutDirty) {
- scrollToChild(focused);
- } else {
- // The child may not be laid out yet, we can't compute the scroll yet
- mChildToScrollTo = focused;
- }
- }
- super.requestChildFocus(child, focused);
- }
-
- /**
- * When looking for focus in children of a scroll view, need to be a little
- * more careful not to give focus to something that is scrolled off screen.
- *
- * This is more expensive than the default {@link android.view.ViewGroup}
- * implementation, otherwise this behavior might have been made the default.
- */
- @Override
- protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
- // convert from forward / backward notation to up / down / left / right
- // (ugh).
- if (direction == View.FOCUS_FORWARD) {
- direction = View.FOCUS_DOWN;
- } else if (direction == View.FOCUS_BACKWARD) {
- direction = View.FOCUS_UP;
- }
-
- final View nextFocus = previouslyFocusedRect == null ?
- FocusFinder.getInstance().findNextFocus(this, null, direction) :
- FocusFinder.getInstance().findNextFocusFromRect(this,
- previouslyFocusedRect, direction);
-
- if (nextFocus == null) {
- return false;
- }
-
- return nextFocus.requestFocus(direction, previouslyFocusedRect);
- }
-
- @Override
- public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
- // offset into coordinate space of this scroll view
- rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
- return scrollToChildRect(rectangle, immediate);
- }
-
- @Override
- public void requestLayout() {
- mIsLayoutDirty = true;
- super.requestLayout();
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mIsLayoutDirty = false;
- // Give a child focus if it needs it
- if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
- scrollToChild(mChildToScrollTo);
- }
- mChildToScrollTo = null;
-
- // Calling this with the present values causes it to re-clam them
- scrollTo(getScrollX(), getScrollY());
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
-
- View currentFocused = findFocus();
- if (null == currentFocused || this == currentFocused)
- return;
-
- // If the currently-focused view was visible on the screen when the
- // screen was at the old height, then scroll the screen to make that
- // view visible with the new screen height.
- currentFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(currentFocused, mTempRect);
- int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(scrollDeltaX, scrollDeltaY);
- }
-
- /**
- * Return true if child is an descendant of parent, (or equal to the parent).
- */
- private boolean isViewDescendantOf(View child, View parent) {
- if (child == parent) {
- return true;
- }
-
- final ViewParent theParent = child.getParent();
- return (theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent);
- }
-
- /**
- * Fling the scroll view
- *
- * @param velocityY The initial velocity in the Y direction. Positive
- * numbers mean that the finger/curor is moving down the screen,
- * which means we want to scroll towards the top.
- */
- public void fling(int velocityX, int velocityY) {
- if (getChildCount() > 0) {
- int height = getHeight() - getPaddingBottom() - getPaddingTop();
- int bottom = getChildAt(0).getHeight();
- int width = getWidth() - getPaddingRight() - getPaddingLeft();
- int right = getChildAt(0).getWidth();
-
- mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY, 0, right - width, 0, bottom - height);
-
- final boolean movingDown = velocityY > 0;
- final boolean movingRight = velocityX > 0;
-
- View newFocused = findFocusableViewInMyBounds(movingRight, mScroller.getFinalX(), movingDown, mScroller.getFinalY(), findFocus());
- if (newFocused == null) {
- newFocused = this;
- }
-
- if (newFocused != findFocus() && newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
- mTwoDScrollViewMovedFocus = true;
- mTwoDScrollViewMovedFocus = false;
- }
-
- awakenScrollBars(mScroller.getDuration());
- invalidate();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- *
This version also clamps the scrolling to the bounds of our child.
- */
- public void scrollTo(int x, int y) {
- // we rely on the fact the View.scrollBy calls scrollTo.
- if (getChildCount() > 0) {
- View child = getChildAt(0);
- x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
- y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
- if (x != getScrollX() || y != getScrollY()) {
- super.scrollTo(x, y);
- }
- }
- }
-
- private int clamp(int n, int my, int child) {
- if (my >= child || n < 0) {
- /* my >= child is this case:
- * |--------------- me ---------------|
- * |------ child ------|
- * or
- * |--------------- me ---------------|
- * |------ child ------|
- * or
- * |--------------- me ---------------|
- * |------ child ------|
- *
- * n < 0 is this case:
- * |------ me ------|
- * |-------- child --------|
- * |-- mScrollX --|
- */
- return 0;
- }
- if ((my + n) > child) {
- /* this case:
- * |------ me ------|
- * |------ child ------|
- * |-- mScrollX --|
- */
- return child - my;
- }
- return n;
- }
-
- public void setScrollViewListener(ScrollView2DListener scrollViewListener) {
- this.scrollView2DListener = scrollViewListener;
- }
-
- @Override
- protected void onScrollChanged(int x, int y, int oldx, int oldy) {
- super.onScrollChanged(x, y, oldx, oldy);
- if (scrollView2DListener != null) {
- scrollView2DListener.onScrollChanged(this, x, y, oldx, oldy);
- }
- }
-
- // interface to receive notifications when the view is scrolled
- public interface ScrollView2DListener {
- abstract void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy);
- }
-
+public class ScrollView2D extends FrameLayout
+{
+
+ static final int ANIMATED_SCROLL_GAP = 250;
+ static final float MAX_SCROLL_FACTOR = 0.5f;
+ private final Rect mTempRect = new Rect();
+ private ScrollView2DListener scrollView2DListener = null;
+ private long mLastScroll;
+ private Scroller mScroller;
+ private boolean scrollEnabled = true;
+ /**
+ * Flag to indicate that we are moving focus ourselves. This is so the
+ * code that watches for focus changes initiated outside this TwoDScrollView
+ * knows that it does not have to do anything.
+ */
+ private boolean mTwoDScrollViewMovedFocus;
+ /**
+ * Position of the last motion event.
+ */
+ private float mLastMotionY;
+ private float mLastMotionX;
+ /**
+ * True when the layout has changed but the traversal has not come through yet.
+ * Ideally the view hierarchy would keep track of this for us.
+ */
+ private boolean mIsLayoutDirty = true;
+ /**
+ * The child to give focus to in the event that a child has requested focus while the
+ * layout is dirty. This prevents the scroll from being wrong if the child has not been
+ * laid out before requesting focus.
+ */
+ private View mChildToScrollTo = null;
+ /**
+ * True if the user is currently dragging this TwoDScrollView around. This is
+ * not the same as 'is being flinged', which can be checked by
+ * mScroller.isFinished() (flinging begins when the user lifts his finger).
+ */
+ private boolean mIsBeingDragged = false;
+ /**
+ * Determines speed during touch scrolling
+ */
+ private VelocityTracker mVelocityTracker;
+ /**
+ * Whether arrow scrolling is animated.
+ */
+ private int mTouchSlop;
+ private int mMinimumVelocity;
+ private int mMaximumVelocity;
+ public ScrollView2D(Context context)
+ {
+ super(context);
+ initTwoDScrollView();
+ }
+
+ public ScrollView2D(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ initTwoDScrollView();
+ }
+
+ public ScrollView2D(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ initTwoDScrollView();
+ }
+
+ @Override protected float getTopFadingEdgeStrength()
+ {
+ if (getChildCount() == 0)
+ {
+ return 0.0f;
+ }
+ final int length = getVerticalFadingEdgeLength();
+ if (getScrollY() < length)
+ {
+ return getScrollY() / (float)length;
+ }
+ return 1.0f;
+ }
+
+ @Override protected float getBottomFadingEdgeStrength()
+ {
+ if (getChildCount() == 0)
+ {
+ return 0.0f;
+ }
+ final int length = getVerticalFadingEdgeLength();
+ final int bottomEdge = getHeight() - getPaddingBottom();
+ final int span = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
+ if (span < length)
+ {
+ return span / (float)length;
+ }
+ return 1.0f;
+ }
+
+ @Override protected float getLeftFadingEdgeStrength()
+ {
+ if (getChildCount() == 0)
+ {
+ return 0.0f;
+ }
+ final int length = getHorizontalFadingEdgeLength();
+ if (getScrollX() < length)
+ {
+ return getScrollX() / (float)length;
+ }
+ return 1.0f;
+ }
+
+ @Override protected float getRightFadingEdgeStrength()
+ {
+ if (getChildCount() == 0)
+ {
+ return 0.0f;
+ }
+ final int length = getHorizontalFadingEdgeLength();
+ final int rightEdge = getWidth() - getPaddingRight();
+ final int span = getChildAt(0).getRight() - getScrollX() - rightEdge;
+ if (span < length)
+ {
+ return span / (float)length;
+ }
+ return 1.0f;
+ }
+
+ /**
+ * Disable/Enable scrolling
+ */
+ public void setScrollEnabled(boolean enable)
+ {
+ scrollEnabled = enable;
+ }
+
+ /**
+ * @return The maximum amount this scroll view will scroll in response to
+ * an arrow event.
+ */
+ public int getMaxScrollAmountVertical()
+ {
+ return (int)(MAX_SCROLL_FACTOR * getHeight());
+ }
+
+ public int getMaxScrollAmountHorizontal()
+ {
+ return (int)(MAX_SCROLL_FACTOR * getWidth());
+ }
+
+ private void initTwoDScrollView()
+ {
+ mScroller = new Scroller(getContext());
+ setFocusable(true);
+ setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
+ setWillNotDraw(false);
+ final ViewConfiguration configuration = ViewConfiguration.get(getContext());
+ mTouchSlop = configuration.getScaledTouchSlop();
+ mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
+ mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
+ }
+
+ @Override public void addView(View child)
+ {
+ if (getChildCount() > 0)
+ {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child);
+ }
+
+ @Override public void addView(View child, int index)
+ {
+ if (getChildCount() > 0)
+ {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, index);
+ }
+
+ @Override public void addView(View child, ViewGroup.LayoutParams params)
+ {
+ if (getChildCount() > 0)
+ {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, params);
+ }
+
+ @Override public void addView(View child, int index, ViewGroup.LayoutParams params)
+ {
+ if (getChildCount() > 0)
+ {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, index, params);
+ }
+
+ /**
+ * @return Returns true this TwoDScrollView can be scrolled
+ */
+ private boolean canScroll()
+ {
+ if (!scrollEnabled)
+ return false;
+ View child = getChildAt(0);
+ if (child != null)
+ {
+ int childHeight = child.getHeight();
+ int childWidth = child.getWidth();
+ return (getHeight() < childHeight + getPaddingTop() + getPaddingBottom()) ||
+ (getWidth() < childWidth + getPaddingLeft() + getPaddingRight());
+ }
+ return false;
+ }
+
+ @Override public boolean dispatchKeyEvent(KeyEvent event)
+ {
+ // Let the focused view and/or our descendants get the key first
+ boolean handled = super.dispatchKeyEvent(event);
+ if (handled)
+ {
+ return true;
+ }
+ return executeKeyEvent(event);
+ }
+
+ /**
+ * You can call this function yourself to have the scroll view perform
+ * scrolling from a key event, just as if the event had been dispatched to
+ * it by the view hierarchy.
+ *
+ * @param event The key event to execute.
+ * @return Return true if the event was handled, else false.
+ */
+ public boolean executeKeyEvent(KeyEvent event)
+ {
+ mTempRect.setEmpty();
+ if (!canScroll())
+ {
+ if (isFocused())
+ {
+ View currentFocused = findFocus();
+ if (currentFocused == this)
+ currentFocused = null;
+ View nextFocused =
+ FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
+ return nextFocused != null && nextFocused != this &&
+ nextFocused.requestFocus(View.FOCUS_DOWN);
+ }
+ return false;
+ }
+ boolean handled = false;
+ if (event.getAction() == KeyEvent.ACTION_DOWN)
+ {
+ switch (event.getKeyCode())
+ {
+ case KeyEvent.KEYCODE_DPAD_UP:
+ if (!event.isAltPressed())
+ {
+ handled = arrowScroll(View.FOCUS_UP, false);
+ }
+ else
+ {
+ handled = fullScroll(View.FOCUS_UP, false);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ if (!event.isAltPressed())
+ {
+ handled = arrowScroll(View.FOCUS_DOWN, false);
+ }
+ else
+ {
+ handled = fullScroll(View.FOCUS_DOWN, false);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ if (!event.isAltPressed())
+ {
+ handled = arrowScroll(View.FOCUS_LEFT, true);
+ }
+ else
+ {
+ handled = fullScroll(View.FOCUS_LEFT, true);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ if (!event.isAltPressed())
+ {
+ handled = arrowScroll(View.FOCUS_RIGHT, true);
+ }
+ else
+ {
+ handled = fullScroll(View.FOCUS_RIGHT, true);
+ }
+ break;
+ }
+ }
+ return handled;
+ }
+
+ @Override public boolean onInterceptTouchEvent(MotionEvent ev)
+ {
+ /*
+ * This method JUST determines whether we want to intercept the motion.
+ * If we return true, onMotionEvent will be called and we do the actual
+ * scrolling there.
+ *
+ * Shortcut the most recurring case: the user is in the dragging
+ * state and he is moving his finger. We want to intercept this
+ * motion.
+ */
+ final int action = ev.getAction();
+ if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged))
+ {
+ return true;
+ }
+ if (!canScroll())
+ {
+ mIsBeingDragged = false;
+ return false;
+ }
+ final float y = ev.getY();
+ final float x = ev.getX();
+ switch (action)
+ {
+ case MotionEvent.ACTION_MOVE:
+ /*
+ * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
+ * whether the user has moved far enough from his original down touch.
+ */
+ /*
+ * Locally do absolute value. mLastMotionY is set to the y value
+ * of the down event.
+ */
+ final int yDiff = (int)Math.abs(y - mLastMotionY);
+ final int xDiff = (int)Math.abs(x - mLastMotionX);
+ if (yDiff > mTouchSlop || xDiff > mTouchSlop)
+ {
+ mIsBeingDragged = true;
+ }
+ break;
+
+ case MotionEvent.ACTION_DOWN:
+ /* Remember location of down touch */
+ mLastMotionY = y;
+ mLastMotionX = x;
+
+ /*
+ * If being flinged and user touches the screen, initiate drag;
+ * otherwise don't. mScroller.isFinished should be false when
+ * being flinged.
+ */
+ mIsBeingDragged = !mScroller.isFinished();
+ break;
+
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ /* Release the drag */
+ mIsBeingDragged = false;
+ break;
+ }
+
+ /*
+ * The only time we want to intercept motion events is if we are in the
+ * drag mode.
+ */
+ return mIsBeingDragged;
+ }
+
+ @Override public boolean onTouchEvent(MotionEvent ev)
+ {
+
+ if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0)
+ {
+ // Don't handle edge touches immediately -- they may actually belong to one of our
+ // descendants.
+ return false;
+ }
+
+ if (!canScroll())
+ {
+ return false;
+ }
+
+ if (mVelocityTracker == null)
+ {
+ mVelocityTracker = VelocityTracker.obtain();
+ }
+ mVelocityTracker.addMovement(ev);
+
+ final int action = ev.getAction();
+ final float y = ev.getY();
+ final float x = ev.getX();
+
+ switch (action)
+ {
+ case MotionEvent.ACTION_DOWN:
+ /*
+ * If being flinged and user touches, stop the fling. isFinished
+ * will be false if being flinged.
+ */
+ if (!mScroller.isFinished())
+ {
+ mScroller.abortAnimation();
+ }
+
+ // Remember where the motion event started
+ mLastMotionY = y;
+ mLastMotionX = x;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ // Scroll to follow the motion event
+ int deltaX = (int)(mLastMotionX - x);
+ int deltaY = (int)(mLastMotionY - y);
+ mLastMotionX = x;
+ mLastMotionY = y;
+
+ if (deltaX < 0)
+ {
+ if (getScrollX() < 0)
+ {
+ deltaX = 0;
+ }
+ }
+ else if (deltaX > 0)
+ {
+ final int rightEdge = getWidth() - getPaddingRight();
+ final int availableToScroll =
+ getChildAt(0).getRight() - getScrollX() - rightEdge;
+ if (availableToScroll > 0)
+ {
+ deltaX = Math.min(availableToScroll, deltaX);
+ }
+ else
+ {
+ deltaX = 0;
+ }
+ }
+ if (deltaY < 0)
+ {
+ if (getScrollY() < 0)
+ {
+ deltaY = 0;
+ }
+ }
+ else if (deltaY > 0)
+ {
+ final int bottomEdge = getHeight() - getPaddingBottom();
+ final int availableToScroll =
+ getChildAt(0).getBottom() - getScrollY() - bottomEdge;
+ if (availableToScroll > 0)
+ {
+ deltaY = Math.min(availableToScroll, deltaY);
+ }
+ else
+ {
+ deltaY = 0;
+ }
+ }
+ if (deltaY != 0 || deltaX != 0)
+ scrollBy(deltaX, deltaY);
+ break;
+ case MotionEvent.ACTION_UP:
+ final VelocityTracker velocityTracker = mVelocityTracker;
+ velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
+ int initialXVelocity = (int)velocityTracker.getXVelocity();
+ int initialYVelocity = (int)velocityTracker.getYVelocity();
+ if ((Math.abs(initialXVelocity) + Math.abs(initialYVelocity) > mMinimumVelocity) &&
+ getChildCount() > 0)
+ {
+ fling(-initialXVelocity, -initialYVelocity);
+ }
+ if (mVelocityTracker != null)
+ {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Finds the next focusable component that fits in this View's bounds
+ * (excluding fading edges) pretending that this View's top is located at
+ * the parameter top.
+ *
+ * @param topFocus look for a candidate is the one at the top of the bounds
+ * if topFocus is true, or at the bottom of the bounds if topFocus is
+ * false
+ * @param top the top offset of the bounds in which a focusable must be
+ * found (the fading edge is assumed to start at this position)
+ * @param preferredFocusable the View that has highest priority and will be
+ * returned if it is within my bounds (null is valid)
+ * @return the next focusable component in the bounds or null if none can be
+ * found
+ */
+ private View findFocusableViewInMyBounds(final boolean topFocus, final int top,
+ final boolean leftFocus, final int left,
+ View preferredFocusable)
+ {
+ /*
+ * The fading edge's transparent side should be considered for focus
+ * since it's mostly visible, so we divide the actual fading edge length
+ * by 2.
+ */
+ final int verticalFadingEdgeLength = getVerticalFadingEdgeLength() / 2;
+ final int topWithoutFadingEdge = top + verticalFadingEdgeLength;
+ final int bottomWithoutFadingEdge = top + getHeight() - verticalFadingEdgeLength;
+ final int horizontalFadingEdgeLength = getHorizontalFadingEdgeLength() / 2;
+ final int leftWithoutFadingEdge = left + horizontalFadingEdgeLength;
+ final int rightWithoutFadingEdge = left + getWidth() - horizontalFadingEdgeLength;
+
+ if ((preferredFocusable != null) &&
+ (preferredFocusable.getTop() < bottomWithoutFadingEdge) &&
+ (preferredFocusable.getBottom() > topWithoutFadingEdge) &&
+ (preferredFocusable.getLeft() < rightWithoutFadingEdge) &&
+ (preferredFocusable.getRight() > leftWithoutFadingEdge))
+ {
+ return preferredFocusable;
+ }
+ return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, bottomWithoutFadingEdge,
+ leftFocus, leftWithoutFadingEdge, rightWithoutFadingEdge);
+ }
+
+ /**
+ * Finds the next focusable component that fits in the specified bounds.
+ *
+ *
+ * @param topFocus look for a candidate is the one at the top of the bounds
+ * if topFocus is true, or at the bottom of the bounds if topFocus is
+ * false
+ * @param top the top offset of the bounds in which a focusable must be
+ * found
+ * @param bottom the bottom offset of the bounds in which a focusable must
+ * be found
+ * @return the next focusable component in the bounds or null if none can
+ * be found
+ */
+ private View findFocusableViewInBounds(boolean topFocus, int top, int bottom, boolean leftFocus,
+ int left, int right)
+ {
+ List focusables = getFocusables(View.FOCUS_FORWARD);
+ View focusCandidate = null;
+
+ /*
+ * A fully contained focusable is one where its top is below the bound's
+ * top, and its bottom is above the bound's bottom. A partially
+ * contained focusable is one where some part of it is within the
+ * bounds, but it also has some part that is not within bounds. A fully contained
+ * focusable is preferred to a partially contained focusable.
+ */
+ boolean foundFullyContainedFocusable = false;
+
+ int count = focusables.size();
+ for (int i = 0; i < count; i++)
+ {
+ View view = focusables.get(i);
+ int viewTop = view.getTop();
+ int viewBottom = view.getBottom();
+ int viewLeft = view.getLeft();
+ int viewRight = view.getRight();
+
+ if (top < viewBottom && viewTop < bottom && left < viewRight && viewLeft < right)
+ {
+ /*
+ * the focusable is in the target area, it is a candidate for
+ * focusing
+ */
+ final boolean viewIsFullyContained = (top < viewTop) && (viewBottom < bottom) &&
+ (left < viewLeft) && (viewRight < right);
+ if (focusCandidate == null)
+ {
+ /* No candidate, take this one */
+ focusCandidate = view;
+ foundFullyContainedFocusable = viewIsFullyContained;
+ }
+ else
+ {
+ final boolean viewIsCloserToVerticalBoundary =
+ (topFocus && viewTop < focusCandidate.getTop()) ||
+ (!topFocus && viewBottom > focusCandidate.getBottom());
+ final boolean viewIsCloserToHorizontalBoundary =
+ (leftFocus && viewLeft < focusCandidate.getLeft()) ||
+ (!leftFocus && viewRight > focusCandidate.getRight());
+ if (foundFullyContainedFocusable)
+ {
+ if (viewIsFullyContained && viewIsCloserToVerticalBoundary &&
+ viewIsCloserToHorizontalBoundary)
+ {
+ /*
+ * We're dealing with only fully contained views, so
+ * it has to be closer to the boundary to beat our
+ * candidate
+ */
+ focusCandidate = view;
+ }
+ }
+ else
+ {
+ if (viewIsFullyContained)
+ {
+ /* Any fully contained view beats a partially contained view */
+ focusCandidate = view;
+ foundFullyContainedFocusable = true;
+ }
+ else if (viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary)
+ {
+ /*
+ * Partially contained view beats another partially
+ * contained view if it's closer
+ */
+ focusCandidate = view;
+ }
+ }
+ }
+ }
+ }
+ return focusCandidate;
+ }
+
+ /**
+ * Handles scrolling in response to a "home/end" shortcut press. This
+ * method will scroll the view to the top or bottom and give the focus
+ * to the topmost/bottommost component in the new visible area. If no
+ * component is a good candidate for focus, this scrollview reclaims the
+ * focus.
+ *
+ * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
+ * to go the top of the view or
+ * {@link android.view.View#FOCUS_DOWN} to go the bottom
+ * @return true if the key event is consumed by this method, false otherwise
+ */
+ public boolean fullScroll(int direction, boolean horizontal)
+ {
+ if (!horizontal)
+ {
+ boolean down = direction == View.FOCUS_DOWN;
+ int height = getHeight();
+ mTempRect.top = 0;
+ mTempRect.bottom = height;
+ if (down)
+ {
+ int count = getChildCount();
+ if (count > 0)
+ {
+ View view = getChildAt(count - 1);
+ mTempRect.bottom = view.getBottom();
+ mTempRect.top = mTempRect.bottom - height;
+ }
+ }
+ return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom, 0, 0, 0);
+ }
+ else
+ {
+ boolean right = direction == View.FOCUS_DOWN;
+ int width = getWidth();
+ mTempRect.left = 0;
+ mTempRect.right = width;
+ if (right)
+ {
+ int count = getChildCount();
+ if (count > 0)
+ {
+ View view = getChildAt(count - 1);
+ mTempRect.right = view.getBottom();
+ mTempRect.left = mTempRect.right - width;
+ }
+ }
+ return scrollAndFocus(0, 0, 0, direction, mTempRect.top, mTempRect.bottom);
+ }
+ }
+
+ /**
+ * Scrolls the view to make the area defined by top and
+ * bottom visible. This method attempts to give the focus
+ * to a component visible in this area. If no component can be focused in
+ * the new visible area, the focus is reclaimed by this scrollview.
+ *
+ * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
+ * to go upward
+ * {@link android.view.View#FOCUS_DOWN} to downward
+ * @param top the top offset of the new area to be made visible
+ * @param bottom the bottom offset of the new area to be made visible
+ * @return true if the key event is consumed by this method, false otherwise
+ */
+ private boolean scrollAndFocus(int directionY, int top, int bottom, int directionX, int left,
+ int right)
+ {
+ boolean handled = true;
+ int height = getHeight();
+ int containerTop = getScrollY();
+ int containerBottom = containerTop + height;
+ boolean up = directionY == View.FOCUS_UP;
+ int width = getWidth();
+ int containerLeft = getScrollX();
+ int containerRight = containerLeft + width;
+ boolean leftwards = directionX == View.FOCUS_UP;
+ View newFocused = findFocusableViewInBounds(up, top, bottom, leftwards, left, right);
+ if (newFocused == null)
+ {
+ newFocused = this;
+ }
+ if ((top >= containerTop && bottom <= containerBottom) ||
+ (left >= containerLeft && right <= containerRight))
+ {
+ handled = false;
+ }
+ else
+ {
+ int deltaY = up ? (top - containerTop) : (bottom - containerBottom);
+ int deltaX = leftwards ? (left - containerLeft) : (right - containerRight);
+ doScroll(deltaX, deltaY);
+ }
+ if (newFocused != findFocus() && newFocused.requestFocus(directionY))
+ {
+ mTwoDScrollViewMovedFocus = true;
+ mTwoDScrollViewMovedFocus = false;
+ }
+ return handled;
+ }
+
+ /**
+ * Handle scrolling in response to an up or down arrow click.
+ *
+ * @param direction The direction corresponding to the arrow key that was
+ * pressed
+ * @return True if we consumed the event, false otherwise
+ */
+ public boolean arrowScroll(int direction, boolean horizontal)
+ {
+ View currentFocused = findFocus();
+ if (currentFocused == this)
+ currentFocused = null;
+ View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
+ final int maxJump =
+ horizontal ? getMaxScrollAmountHorizontal() : getMaxScrollAmountVertical();
+
+ if (!horizontal)
+ {
+ if (nextFocused != null)
+ {
+ nextFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(nextFocused, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(0, scrollDelta);
+ nextFocused.requestFocus(direction);
+ }
+ else
+ {
+ // no new focus
+ int scrollDelta = maxJump;
+ if (direction == View.FOCUS_UP && getScrollY() < scrollDelta)
+ {
+ scrollDelta = getScrollY();
+ }
+ else if (direction == View.FOCUS_DOWN)
+ {
+ if (getChildCount() > 0)
+ {
+ int daBottom = getChildAt(0).getBottom();
+ int screenBottom = getScrollY() + getHeight();
+ if (daBottom - screenBottom < maxJump)
+ {
+ scrollDelta = daBottom - screenBottom;
+ }
+ }
+ }
+ if (scrollDelta == 0)
+ {
+ return false;
+ }
+ doScroll(0, direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta);
+ }
+ }
+ else
+ {
+ if (nextFocused != null)
+ {
+ nextFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(nextFocused, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(scrollDelta, 0);
+ nextFocused.requestFocus(direction);
+ }
+ else
+ {
+ // no new focus
+ int scrollDelta = maxJump;
+ if (direction == View.FOCUS_UP && getScrollY() < scrollDelta)
+ {
+ scrollDelta = getScrollY();
+ }
+ else if (direction == View.FOCUS_DOWN)
+ {
+ if (getChildCount() > 0)
+ {
+ int daBottom = getChildAt(0).getBottom();
+ int screenBottom = getScrollY() + getHeight();
+ if (daBottom - screenBottom < maxJump)
+ {
+ scrollDelta = daBottom - screenBottom;
+ }
+ }
+ }
+ if (scrollDelta == 0)
+ {
+ return false;
+ }
+ doScroll(direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta, 0);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Smooth scroll by a Y delta
+ *
+ * @param delta the number of pixels to scroll by on the Y axis
+ */
+ private void doScroll(int deltaX, int deltaY)
+ {
+ if (deltaX != 0 || deltaY != 0)
+ {
+ smoothScrollBy(deltaX, deltaY);
+ }
+ }
+
+ /**
+ * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
+ *
+ * @param dx the number of pixels to scroll by on the X axis
+ * @param dy the number of pixels to scroll by on the Y axis
+ */
+ public final void smoothScrollBy(int dx, int dy)
+ {
+ long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
+ if (duration > ANIMATED_SCROLL_GAP)
+ {
+ mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
+ awakenScrollBars(mScroller.getDuration());
+ invalidate();
+ }
+ else
+ {
+ if (!mScroller.isFinished())
+ {
+ mScroller.abortAnimation();
+ }
+ scrollBy(dx, dy);
+ }
+ mLastScroll = AnimationUtils.currentAnimationTimeMillis();
+ }
+
+ /**
+ * Like {@link #scrollTo}, but scroll smoothly instead of immediately.
+ *
+ * @param x the position where to scroll on the X axis
+ * @param y the position where to scroll on the Y axis
+ */
+ public final void smoothScrollTo(int x, int y)
+ {
+ smoothScrollBy(x - getScrollX(), y - getScrollY());
+ }
+
+ /**
+ * The scroll range of a scroll view is the overall height of all of its
+ * children.
+ */
+ @Override protected int computeVerticalScrollRange()
+ {
+ int count = getChildCount();
+ return count == 0 ? getHeight() : (getChildAt(0)).getBottom();
+ }
+
+ @Override protected int computeHorizontalScrollRange()
+ {
+ int count = getChildCount();
+ return count == 0 ? getWidth() : (getChildAt(0)).getRight();
+ }
+
+ @Override
+ protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec)
+ {
+ ViewGroup.LayoutParams lp = child.getLayoutParams();
+ int childWidthMeasureSpec;
+ int childHeightMeasureSpec;
+
+ childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
+ getPaddingLeft() + getPaddingRight(), lp.width);
+ childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+
+ child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ @Override
+ protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed,
+ int parentHeightMeasureSpec, int heightUsed)
+ {
+ final MarginLayoutParams lp = (MarginLayoutParams)child.getLayoutParams();
+ final int childWidthMeasureSpec =
+ MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
+ final int childHeightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(lp.topMargin + lp.bottomMargin, MeasureSpec.UNSPECIFIED);
+
+ child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ @Override public void computeScroll()
+ {
+ if (mScroller.computeScrollOffset())
+ {
+ // This is called at drawing time by ViewGroup. We don't want to
+ // re-show the scrollbars at this point, which scrollTo will do,
+ // so we replicate most of scrollTo here.
+ //
+ // It's a little odd to call onScrollChanged from inside the drawing.
+ //
+ // It is, except when you remember that computeScroll() is used to
+ // animate scrolling. So unless we want to defer the onScrollChanged()
+ // until the end of the animated scrolling, we don't really have a
+ // choice here.
+ //
+ // I agree. The alternative, which I think would be worse, is to post
+ // something and tell the subclasses later. This is bad because there
+ // will be a window where mScrollX/Y is different from what the app
+ // thinks it is.
+ //
+ int oldX = getScrollX();
+ int oldY = getScrollY();
+ int x = mScroller.getCurrX();
+ int y = mScroller.getCurrY();
+ if (getChildCount() > 0)
+ {
+ View child = getChildAt(0);
+ scrollTo(
+ clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth()),
+ clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(),
+ child.getHeight()));
+ }
+ else
+ {
+ scrollTo(x, y);
+ }
+ if (oldX != getScrollX() || oldY != getScrollY())
+ {
+ onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
+ }
+
+ // Keep on drawing until the animation has finished.
+ postInvalidate();
+ }
+ }
+
+ /**
+ * Scrolls the view to the given child.
+ *
+ * @param child the View to scroll to
+ */
+ private void scrollToChild(View child)
+ {
+ child.getDrawingRect(mTempRect);
+ /* Offset from child's local coordinates to TwoDScrollView coordinates */
+ offsetDescendantRectToMyCoords(child, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ if (scrollDelta != 0)
+ {
+ scrollBy(0, scrollDelta);
+ }
+ }
+
+ /**
+ * If rect is off screen, scroll just enough to get it (or at least the
+ * first screen size chunk of it) on screen.
+ *
+ * @param rect The rectangle.
+ * @param immediate True to scroll immediately without animation
+ * @return true if scrolling was performed
+ */
+ private boolean scrollToChildRect(Rect rect, boolean immediate)
+ {
+ final int delta = computeScrollDeltaToGetChildRectOnScreen(rect);
+ final boolean scroll = delta != 0;
+ if (scroll)
+ {
+ if (immediate)
+ {
+ scrollBy(0, delta);
+ }
+ else
+ {
+ smoothScrollBy(0, delta);
+ }
+ }
+ return scroll;
+ }
+
+ /**
+ * Compute the amount to scroll in the Y direction in order to get
+ * a rectangle completely on the screen (or, if taller than the screen,
+ * at least the first screen size chunk of it).
+ *
+ * @param rect The rect.
+ * @return The scroll delta.
+ */
+ protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect)
+ {
+ if (getChildCount() == 0)
+ return 0;
+ int height = getHeight();
+ int screenTop = getScrollY();
+ int screenBottom = screenTop + height;
+ int fadingEdge = getVerticalFadingEdgeLength();
+ // leave room for top fading edge as long as rect isn't at very top
+ if (rect.top > 0)
+ {
+ screenTop += fadingEdge;
+ }
+
+ // leave room for bottom fading edge as long as rect isn't at very bottom
+ if (rect.bottom < getChildAt(0).getHeight())
+ {
+ screenBottom -= fadingEdge;
+ }
+ int scrollYDelta = 0;
+ if (rect.bottom > screenBottom && rect.top > screenTop)
+ {
+ // need to move down to get it in view: move down just enough so
+ // that the entire rectangle is in view (or at least the first
+ // screen size chunk).
+ if (rect.height() > height)
+ {
+ // just enough to get screen size chunk on
+ scrollYDelta += (rect.top - screenTop);
+ }
+ else
+ {
+ // get entire rect at bottom of screen
+ scrollYDelta += (rect.bottom - screenBottom);
+ }
+
+ // make sure we aren't scrolling beyond the end of our content
+ int bottom = getChildAt(0).getBottom();
+ int distanceToBottom = bottom - screenBottom;
+ scrollYDelta = Math.min(scrollYDelta, distanceToBottom);
+ }
+ else if (rect.top < screenTop && rect.bottom < screenBottom)
+ {
+ // need to move up to get it in view: move up just enough so that
+ // entire rectangle is in view (or at least the first screen
+ // size chunk of it).
+
+ if (rect.height() > height)
+ {
+ // screen size chunk
+ scrollYDelta -= (screenBottom - rect.bottom);
+ }
+ else
+ {
+ // entire rect at top
+ scrollYDelta -= (screenTop - rect.top);
+ }
+
+ // make sure we aren't scrolling any further than the top our content
+ scrollYDelta = Math.max(scrollYDelta, -getScrollY());
+ }
+ return scrollYDelta;
+ }
+
+ @Override public void requestChildFocus(View child, View focused)
+ {
+ if (!mTwoDScrollViewMovedFocus)
+ {
+ if (!mIsLayoutDirty)
+ {
+ scrollToChild(focused);
+ }
+ else
+ {
+ // The child may not be laid out yet, we can't compute the scroll yet
+ mChildToScrollTo = focused;
+ }
+ }
+ super.requestChildFocus(child, focused);
+ }
+
+ /**
+ * When looking for focus in children of a scroll view, need to be a little
+ * more careful not to give focus to something that is scrolled off screen.
+ *
+ * This is more expensive than the default {@link android.view.ViewGroup}
+ * implementation, otherwise this behavior might have been made the default.
+ */
+ @Override
+ protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
+ {
+ // convert from forward / backward notation to up / down / left / right
+ // (ugh).
+ if (direction == View.FOCUS_FORWARD)
+ {
+ direction = View.FOCUS_DOWN;
+ }
+ else if (direction == View.FOCUS_BACKWARD)
+ {
+ direction = View.FOCUS_UP;
+ }
+
+ final View nextFocus = previouslyFocusedRect == null
+ ? FocusFinder.getInstance().findNextFocus(this, null, direction)
+ : FocusFinder.getInstance().findNextFocusFromRect(
+ this, previouslyFocusedRect, direction);
+
+ if (nextFocus == null)
+ {
+ return false;
+ }
+
+ return nextFocus.requestFocus(direction, previouslyFocusedRect);
+ }
+
+ @Override
+ public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
+ {
+ // offset into coordinate space of this scroll view
+ rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
+ return scrollToChildRect(rectangle, immediate);
+ }
+
+ @Override public void requestLayout()
+ {
+ mIsLayoutDirty = true;
+ super.requestLayout();
+ }
+
+ @Override protected void onLayout(boolean changed, int l, int t, int r, int b)
+ {
+ super.onLayout(changed, l, t, r, b);
+ mIsLayoutDirty = false;
+ // Give a child focus if it needs it
+ if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this))
+ {
+ scrollToChild(mChildToScrollTo);
+ }
+ mChildToScrollTo = null;
+
+ // Calling this with the present values causes it to re-clam them
+ scrollTo(getScrollX(), getScrollY());
+ }
+
+ @Override protected void onSizeChanged(int w, int h, int oldw, int oldh)
+ {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ View currentFocused = findFocus();
+ if (null == currentFocused || this == currentFocused)
+ return;
+
+ // If the currently-focused view was visible on the screen when the
+ // screen was at the old height, then scroll the screen to make that
+ // view visible with the new screen height.
+ currentFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(currentFocused, mTempRect);
+ int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(scrollDeltaX, scrollDeltaY);
+ }
+
+ /**
+ * Return true if child is an descendant of parent, (or equal to the parent).
+ */
+ private boolean isViewDescendantOf(View child, View parent)
+ {
+ if (child == parent)
+ {
+ return true;
+ }
+
+ final ViewParent theParent = child.getParent();
+ return (theParent instanceof ViewGroup) && isViewDescendantOf((View)theParent, parent);
+ }
+
+ /**
+ * Fling the scroll view
+ *
+ * @param velocityY The initial velocity in the Y direction. Positive
+ * numbers mean that the finger/curor is moving down the screen,
+ * which means we want to scroll towards the top.
+ */
+ public void fling(int velocityX, int velocityY)
+ {
+ if (getChildCount() > 0)
+ {
+ int height = getHeight() - getPaddingBottom() - getPaddingTop();
+ int bottom = getChildAt(0).getHeight();
+ int width = getWidth() - getPaddingRight() - getPaddingLeft();
+ int right = getChildAt(0).getWidth();
+
+ mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY, 0, right - width, 0,
+ bottom - height);
+
+ final boolean movingDown = velocityY > 0;
+ final boolean movingRight = velocityX > 0;
+
+ View newFocused = findFocusableViewInMyBounds(
+ movingRight, mScroller.getFinalX(), movingDown, mScroller.getFinalY(), findFocus());
+ if (newFocused == null)
+ {
+ newFocused = this;
+ }
+
+ if (newFocused != findFocus() &&
+ newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP))
+ {
+ mTwoDScrollViewMovedFocus = true;
+ mTwoDScrollViewMovedFocus = false;
+ }
+
+ awakenScrollBars(mScroller.getDuration());
+ invalidate();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ *
This version also clamps the scrolling to the bounds of our child.
+ */
+ public void scrollTo(int x, int y)
+ {
+ // we rely on the fact the View.scrollBy calls scrollTo.
+ if (getChildCount() > 0)
+ {
+ View child = getChildAt(0);
+ x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
+ y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
+ if (x != getScrollX() || y != getScrollY())
+ {
+ super.scrollTo(x, y);
+ }
+ }
+ }
+
+ private int clamp(int n, int my, int child)
+ {
+ if (my >= child || n < 0)
+ {
+ /* my >= child is this case:
+ * |--------------- me ---------------|
+ * |------ child ------|
+ * or
+ * |--------------- me ---------------|
+ * |------ child ------|
+ * or
+ * |--------------- me ---------------|
+ * |------ child ------|
+ *
+ * n < 0 is this case:
+ * |------ me ------|
+ * |-------- child --------|
+ * |-- mScrollX --|
+ */
+ return 0;
+ }
+ if ((my + n) > child)
+ {
+ /* this case:
+ * |------ me ------|
+ * |------ child ------|
+ * |-- mScrollX --|
+ */
+ return child - my;
+ }
+ return n;
+ }
+
+ public void setScrollViewListener(ScrollView2DListener scrollViewListener)
+ {
+ this.scrollView2DListener = scrollViewListener;
+ }
+
+ @Override protected void onScrollChanged(int x, int y, int oldx, int oldy)
+ {
+ super.onScrollChanged(x, y, oldx, oldy);
+ if (scrollView2DListener != null)
+ {
+ scrollView2DListener.onScrollChanged(this, x, y, oldx, oldy);
+ }
+ }
+
+ // interface to receive notifications when the view is scrolled
+ public interface ScrollView2DListener {
+ abstract void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionActivity.java
index c148c718d..2e64f856f 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -63,1305 +64,1370 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-public class SessionActivity extends AppCompatActivity implements
- LibFreeRDP.UIEventListener, KeyboardView.OnKeyboardActionListener,
- ScrollView2D.ScrollView2DListener,
- KeyboardMapper.KeyProcessingListener, SessionView.SessionViewListener,
- TouchPointerView.TouchPointerListener,
- ClipboardManagerProxy.OnClipboardChangedListener {
- public static final String PARAM_CONNECTION_REFERENCE = "conRef";
- public static final String PARAM_INSTANCE = "instance";
- private static final float ZOOMING_STEP = 0.5f;
- private static final int ZOOMCONTROLS_AUTOHIDE_TIMEOUT = 4000;
- // timeout between subsequent scrolling requests when the touch-pointer is
- // at the edge of the session view
- private static final int SCROLLING_TIMEOUT = 50;
- private static final int SCROLLING_DISTANCE = 20;
- private static final String TAG = "FreeRDP.SessionActivity";
- // variables for delayed move event sending
- private static final int MAX_DISCARDED_MOVE_EVENTS = 3;
- private static final int SEND_MOVE_EVENT_TIMEOUT = 150;
- private Bitmap bitmap;
- private SessionState session;
- private SessionView sessionView;
- private TouchPointerView touchPointerView;
- private ProgressDialog progressDialog;
- private KeyboardView keyboardView;
- private KeyboardView modifiersKeyboardView;
- private ZoomControls zoomControls;
- private KeyboardMapper keyboardMapper;
-
- private Keyboard specialkeysKeyboard;
- private Keyboard numpadKeyboard;
- private Keyboard cursorKeyboard;
- private Keyboard modifiersKeyboard;
-
- private AlertDialog dlgVerifyCertificate;
- private AlertDialog dlgUserCredentials;
- private View userCredView;
-
- private UIHandler uiHandler;
-
- private int screen_width;
- private int screen_height;
-
- private boolean connectCancelledByUser = false;
- private boolean sessionRunning = false;
- private boolean toggleMouseButtons = false;
-
- private LibFreeRDPBroadcastReceiver libFreeRDPBroadcastReceiver;
- private ScrollView2D scrollView;
- // keyboard visibility flags
- private boolean sysKeyboardVisible = false;
- private boolean extKeyboardVisible = false;
- private int discardedMoveEvents = 0;
- private ClipboardManagerProxy mClipboardManager;
- private boolean callbackDialogResult;
- View mDecor;
-
- private void createDialogs() {
- // build verify certificate dialog
- dlgVerifyCertificate = new AlertDialog.Builder(this)
- .setTitle(R.string.dlg_title_verify_certificate)
- .setPositiveButton(android.R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- })
- .setNegativeButton(android.R.string.no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = false;
- connectCancelledByUser = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- }).setCancelable(false).create();
-
- // build the dialog
- userCredView = getLayoutInflater().inflate(R.layout.credentials, null,
- true);
- dlgUserCredentials = new AlertDialog.Builder(this)
- .setView(userCredView)
- .setTitle(R.string.dlg_title_credentials)
- .setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- })
- .setNegativeButton(android.R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = false;
- connectCancelledByUser = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- }).setCancelable(false).create();
- }
-
- private boolean hasHardwareMenuButton() {
- if (Build.VERSION.SDK_INT <= 10)
- return true;
-
- if (Build.VERSION.SDK_INT >= 14) {
- boolean rc = false;
- final ViewConfiguration cfg = ViewConfiguration.get(this);
-
- return cfg.hasPermanentMenuKey();
- }
-
- return false;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // show status bar or make fullscreen?
- if (ApplicationSettingsActivity.getHideStatusBar(this)) {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
-
- this.setContentView(R.layout.session);
- if (hasHardwareMenuButton() || ApplicationSettingsActivity.getHideActionBar(this)) {
- this.getSupportActionBar().hide();
- } else
- this.getSupportActionBar().show();
-
- Log.v(TAG, "Session.onCreate");
-
- // ATTENTION: We use the onGlobalLayout notification to start our
- // session.
- // This is because only then we can know the exact size of our session
- // when using fit screen
- // accounting for any status bars etc. that Android might throws on us.
- // A bit weird looking
- // but this is the only way ...
- final View activityRootView = findViewById(R.id.session_root_view);
- activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
- new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- screen_width = activityRootView.getWidth();
- screen_height = activityRootView.getHeight();
-
- // start session
- if (!sessionRunning && getIntent() != null) {
- processIntent(getIntent());
- sessionRunning = true;
- }
- }
- });
-
- sessionView = (SessionView) findViewById(R.id.sessionView);
- sessionView.setScaleGestureDetector(new ScaleGestureDetector(this,
- new PinchZoomListener()));
- sessionView.setSessionViewListener(this);
- sessionView.requestFocus();
-
- touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
- touchPointerView.setTouchPointerListener(this);
-
- keyboardMapper = new KeyboardMapper();
- keyboardMapper.init(this);
- keyboardMapper.reset(this);
-
- modifiersKeyboard = new Keyboard(getApplicationContext(),
- R.xml.modifiers_keyboard);
- specialkeysKeyboard = new Keyboard(getApplicationContext(),
- R.xml.specialkeys_keyboard);
- numpadKeyboard = new Keyboard(getApplicationContext(),
- R.xml.numpad_keyboard);
- cursorKeyboard = new Keyboard(getApplicationContext(),
- R.xml.cursor_keyboard);
-
- // hide keyboard below the sessionView
- keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
- keyboardView.setKeyboard(specialkeysKeyboard);
- keyboardView.setOnKeyboardActionListener(this);
-
- modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
- modifiersKeyboardView.setKeyboard(modifiersKeyboard);
- modifiersKeyboardView.setOnKeyboardActionListener(this);
-
- scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
- scrollView.setScrollViewListener(this);
- uiHandler = new UIHandler();
- libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();
-
- zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
- zoomControls.hide();
- zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- resetZoomControlsAutoHideTimeout();
- zoomControls.setIsZoomInEnabled(sessionView
- .zoomIn(ZOOMING_STEP));
- zoomControls.setIsZoomOutEnabled(true);
- }
- });
- zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- resetZoomControlsAutoHideTimeout();
- zoomControls.setIsZoomOutEnabled(sessionView
- .zoomOut(ZOOMING_STEP));
- zoomControls.setIsZoomInEnabled(true);
- }
- });
-
- toggleMouseButtons = false;
-
- createDialogs();
-
- // register freerdp events broadcast receiver
- IntentFilter filter = new IntentFilter();
- filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
- registerReceiver(libFreeRDPBroadcastReceiver, filter);
-
- mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
- mClipboardManager.addClipboardChangedListener(this);
-
- mDecor = getWindow().getDecorView();
- mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- Log.v(TAG, "Session.onStart");
- }
-
- @Override
- protected void onRestart() {
- super.onRestart();
- Log.v(TAG, "Session.onRestart");
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- Log.v(TAG, "Session.onResume");
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- Log.v(TAG, "Session.onPause");
-
- // hide any visible keyboards
- showKeyboard(false, false);
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- Log.v(TAG, "Session.onStop");
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- Log.v(TAG, "Session.onDestroy");
-
- // Cancel running disconnect timers.
- GlobalApp.cancelDisconnectTimer();
-
- // Disconnect all remaining sessions.
- Collection sessions = GlobalApp.getSessions();
- for (SessionState session : sessions)
- LibFreeRDP.disconnect(session.getInstance());
-
- // unregister freerdp events broadcast receiver
- unregisterReceiver(libFreeRDPBroadcastReceiver);
-
- // remove clipboard listener
- mClipboardManager.removeClipboardboardChangedListener(this);
-
- // free session
- GlobalApp.freeSession(session.getInstance());
-
- session = null;
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- // reload keyboard resources (changed from landscape)
- modifiersKeyboard = new Keyboard(getApplicationContext(),
- R.xml.modifiers_keyboard);
- specialkeysKeyboard = new Keyboard(getApplicationContext(),
- R.xml.specialkeys_keyboard);
- numpadKeyboard = new Keyboard(getApplicationContext(),
- R.xml.numpad_keyboard);
- cursorKeyboard = new Keyboard(getApplicationContext(),
- R.xml.cursor_keyboard);
-
- // apply loaded keyboards
- keyboardView.setKeyboard(specialkeysKeyboard);
- modifiersKeyboardView.setKeyboard(modifiersKeyboard);
-
- mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
- }
-
- private void processIntent(Intent intent) {
- // get either session instance or create one from a bookmark/uri
- Bundle bundle = intent.getExtras();
- Uri openUri = intent.getData();
- if (openUri != null) {
- // Launched from URI, e.g:
- // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
- connect(openUri);
- } else if (bundle.containsKey(PARAM_INSTANCE)) {
- int inst = bundle.getInt(PARAM_INSTANCE);
- session = GlobalApp.getSession(inst);
- bitmap = session.getSurface().getBitmap();
- bindSession();
- } else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- BookmarkBase bookmark = null;
- String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
- if (ConnectionReference.isHostnameReference(refStr)) {
- bookmark = new ManualBookmark();
- bookmark.get().setHostname(
- ConnectionReference.getHostname(refStr));
- } else if (ConnectionReference.isBookmarkReference(refStr)) {
- if (ConnectionReference.isManualBookmarkReference(refStr))
- bookmark = GlobalApp.getManualBookmarkGateway().findById(
- ConnectionReference.getManualBookmarkId(refStr));
- else
- assert false;
- }
-
- if (bookmark != null)
- connect(bookmark);
- else
- closeSessionActivity(RESULT_CANCELED);
- } else {
- // no session found - exit
- closeSessionActivity(RESULT_CANCELED);
- }
- }
-
- private void connect(BookmarkBase bookmark) {
- session = GlobalApp.createSession(bookmark, getApplicationContext());
-
- BookmarkBase.ScreenSettings screenSettings = session.getBookmark()
- .getActiveScreenSettings();
- Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString());
- if (screenSettings.isAutomatic()) {
- if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
- // large screen device i.e. tablet: simply use screen info
- screenSettings.setHeight(screen_height);
- screenSettings.setWidth(screen_width);
- } else {
- // small screen device i.e. phone:
- // Automatic uses the largest side length of the screen and
- // makes a 16:10 resolution setting out of it
- int screenMax = (screen_width > screen_height) ? screen_width
- : screen_height;
- screenSettings.setHeight(screenMax);
- screenSettings.setWidth((int) ((float) screenMax * 1.6f));
- }
- }
- if (screenSettings.isFitScreen()) {
- screenSettings.setHeight(screen_height);
- screenSettings.setWidth(screen_width);
- }
-
- connectWithTitle(bookmark.getLabel());
- }
-
- private void connect(Uri openUri) {
- session = GlobalApp.createSession(openUri, getApplicationContext());
-
- connectWithTitle(openUri.getAuthority());
- }
-
- private void connectWithTitle(String title) {
- session.setUIEventListener(this);
-
- progressDialog = new ProgressDialog(this);
- progressDialog.setTitle(title);
- progressDialog.setMessage(getResources().getText(
- R.string.dlg_msg_connecting));
- progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "Cancel",
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- connectCancelledByUser = true;
- LibFreeRDP.cancelConnection(session.getInstance());
- }
- });
- progressDialog.setCancelable(false);
- progressDialog.show();
-
- Thread thread = new Thread(new Runnable() {
- public void run() {
- session.connect(getApplicationContext());
- }
- });
- thread.start();
- }
-
- // binds the current session to the activity by wiring it up with the
- // sessionView and updating all internal objects accordingly
- private void bindSession() {
- Log.v(TAG, "bindSession called");
- session.setUIEventListener(this);
- sessionView.onSurfaceChange(session);
- scrollView.requestLayout();
- keyboardMapper.reset(this);
- mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
-
- }
-
- private void hideSoftInput() {
- InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
-
- if (mgr.isActive()) {
- mgr.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
- } else {
- mgr.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
- }
- }
-
- // displays either the system or the extended keyboard or non of them
- private void showKeyboard(final boolean showSystemKeyboard,
- final boolean showExtendedKeyboard) {
- // no matter what we are doing ... hide the zoom controls
- // TODO: this is not working correctly as hiding the keyboard issues a
- // onScrollChange notification showing the control again ...
- uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
- if (zoomControls.getVisibility() == View.VISIBLE)
- zoomControls.hide();
-
- InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
-
- if (showSystemKeyboard) {
- // hide extended keyboard
- keyboardView.setVisibility(View.GONE);
- // show system keyboard
- mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
-
- // show modifiers keyboard
- modifiersKeyboardView.setVisibility(View.VISIBLE);
- } else if (showExtendedKeyboard) {
- // hide system keyboard
- hideSoftInput();
-
- // show extended keyboard
- keyboardView.setKeyboard(specialkeysKeyboard);
- keyboardView.setVisibility(View.VISIBLE);
- modifiersKeyboardView.setVisibility(View.VISIBLE);
- } else {
- // hide both
- hideSoftInput();
- keyboardView.setVisibility(View.GONE);
- modifiersKeyboardView.setVisibility(View.GONE);
-
- // clear any active key modifiers)
- keyboardMapper.clearlAllModifiers();
- }
-
- sysKeyboardVisible = showSystemKeyboard;
- extKeyboardVisible = showExtendedKeyboard;
- }
-
- private void closeSessionActivity(int resultCode) {
- // Go back to home activity (and send intent data back to home)
- setResult(resultCode, getIntent());
- finish();
- }
-
- // update the state of our modifier keys
- private void updateModifierKeyStates() {
- // check if any key is in the keycodes list
-
- List keys = modifiersKeyboard.getKeys();
- for (Iterator it = keys.iterator(); it.hasNext(); ) {
- // if the key is a sticky key - just set it to off
- Keyboard.Key curKey = it.next();
- if (curKey.sticky) {
- switch (keyboardMapper.getModifierState(curKey.codes[0])) {
- case KeyboardMapper.KEYSTATE_ON:
- curKey.on = true;
- curKey.pressed = false;
- break;
-
- case KeyboardMapper.KEYSTATE_OFF:
- curKey.on = false;
- curKey.pressed = false;
- break;
-
- case KeyboardMapper.KEYSTATE_LOCKED:
- curKey.on = true;
- curKey.pressed = true;
- break;
- }
- }
- }
-
- // refresh image
- modifiersKeyboardView.invalidateAllKeys();
- }
-
- private void sendDelayedMoveEvent(int x, int y) {
- if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT)) {
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
- discardedMoveEvents++;
- } else
- discardedMoveEvents = 0;
-
- if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS)
- LibFreeRDP.sendCursorEvent(session.getInstance(), x, y,
- Mouse.getMoveEvent());
- else
- uiHandler.sendMessageDelayed(
- Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y),
- SEND_MOVE_EVENT_TIMEOUT);
- }
-
- private void cancelDelayedMoveEvent() {
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.session_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // refer to http://tools.android.com/tips/non-constant-fields why we
- // can't use switch/case here ..
- int itemId = item.getItemId();
-
- if (itemId == R.id.session_touch_pointer) {
- // toggle touch pointer
- if (touchPointerView.getVisibility() == View.VISIBLE) {
- touchPointerView.setVisibility(View.INVISIBLE);
- sessionView.setTouchPointerPadding(0, 0);
- } else {
- touchPointerView.setVisibility(View.VISIBLE);
- sessionView.setTouchPointerPadding(
- touchPointerView.getPointerWidth(),
- touchPointerView.getPointerHeight());
- }
- } else if (itemId == R.id.session_sys_keyboard) {
- showKeyboard(!sysKeyboardVisible, false);
- } else if (itemId == R.id.session_ext_keyboard) {
- showKeyboard(false, !extKeyboardVisible);
- } else if (itemId == R.id.session_disconnect) {
- showKeyboard(false, false);
- LibFreeRDP.disconnect(session.getInstance());
- }
-
- return true;
- }
-
- @Override
- public void onBackPressed() {
- // hide keyboards (if any visible) or send alt+f4 to the session
- if (sysKeyboardVisible || extKeyboardVisible)
- showKeyboard(false, false);
- else
- keyboardMapper.sendAltF4();
- }
-
- @Override
- public boolean onKeyLongPress(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- LibFreeRDP.disconnect(session.getInstance());
- return true;
- }
- return super.onKeyLongPress(keyCode, event);
- }
-
- // android keyboard input handling
- // We always use the unicode value to process input from the android
- // keyboard except if key modifiers
- // (like Win, Alt, Ctrl) are activated. In this case we will send the
- // virtual key code to allow key
- // combinations (like Win + E to open the explorer).
- @Override
- public boolean onKeyDown(int keycode, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- @Override
- public boolean onKeyUp(int keycode, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- // onKeyMultiple is called for input of some special characters like umlauts
- // and some symbol characters
- @Override
- public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- // ****************************************************************************
- // KeyboardView.KeyboardActionEventListener
- @Override
- public void onKey(int primaryCode, int[] keyCodes) {
- keyboardMapper.processCustomKeyEvent(primaryCode);
- }
-
- @Override
- public void onText(CharSequence text) {
- }
-
- @Override
- public void swipeRight() {
- }
-
- @Override
- public void swipeLeft() {
- }
-
- @Override
- public void swipeDown() {
- }
-
- @Override
- public void swipeUp() {
- }
-
- @Override
- public void onPress(int primaryCode) {
- }
-
- @Override
- public void onRelease(int primaryCode) {
- }
-
- // ****************************************************************************
- // KeyboardMapper.KeyProcessingListener implementation
- @Override
- public void processVirtualKey(int virtualKeyCode, boolean down) {
- LibFreeRDP.sendKeyEvent(session.getInstance(), virtualKeyCode, down);
- }
-
- @Override
- public void processUnicodeKey(int unicodeKey) {
- LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, true);
- LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, false);
- }
-
- @Override
- public void switchKeyboard(int keyboardType) {
- switch (keyboardType) {
- case KeyboardMapper.KEYBOARD_TYPE_FUNCTIONKEYS:
- keyboardView.setKeyboard(specialkeysKeyboard);
- break;
-
- case KeyboardMapper.KEYBOARD_TYPE_NUMPAD:
- keyboardView.setKeyboard(numpadKeyboard);
- break;
-
- case KeyboardMapper.KEYBOARD_TYPE_CURSOR:
- keyboardView.setKeyboard(cursorKeyboard);
- break;
-
- default:
- break;
- }
- }
-
- @Override
- public void modifiersChanged() {
- updateModifierKeyStates();
- }
-
- // ****************************************************************************
- // LibFreeRDP UI event listener implementation
- @Override
- public void OnSettingsChanged(int width, int height, int bpp) {
-
- if (bpp > 16)
- bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- else
- bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
-
- session.setSurface(new BitmapDrawable(bitmap));
-
- if (session.getBookmark() == null) {
- // Return immediately if we launch from URI
- return;
- }
-
- // check this settings and initial settings - if they are not equal the
- // server doesn't support our settings
- // FIXME: the additional check (settings.getWidth() != width + 1) is for
- // the RDVH bug fix to avoid accidental notifications
- // (refer to android_freerdp.c for more info on this problem)
- BookmarkBase.ScreenSettings settings = session.getBookmark()
- .getActiveScreenSettings();
- if ((settings.getWidth() != width && settings.getWidth() != width + 1)
- || settings.getHeight() != height
- || settings.getColors() != bpp)
- uiHandler
- .sendMessage(Message.obtain(
- null,
- UIHandler.DISPLAY_TOAST,
- getResources().getText(
- R.string.info_capabilities_changed)));
- }
-
- @Override
- public void OnGraphicsUpdate(int x, int y, int width, int height) {
- LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width,
- height);
-
- sessionView.addInvalidRegion(new Rect(x, y, x + width, y + height));
+public class SessionActivity extends AppCompatActivity
+ implements LibFreeRDP.UIEventListener, KeyboardView.OnKeyboardActionListener,
+ ScrollView2D.ScrollView2DListener, KeyboardMapper.KeyProcessingListener,
+ SessionView.SessionViewListener, TouchPointerView.TouchPointerListener,
+ ClipboardManagerProxy.OnClipboardChangedListener
+{
+ public static final String PARAM_CONNECTION_REFERENCE = "conRef";
+ public static final String PARAM_INSTANCE = "instance";
+ private static final float ZOOMING_STEP = 0.5f;
+ private static final int ZOOMCONTROLS_AUTOHIDE_TIMEOUT = 4000;
+ // timeout between subsequent scrolling requests when the touch-pointer is
+ // at the edge of the session view
+ private static final int SCROLLING_TIMEOUT = 50;
+ private static final int SCROLLING_DISTANCE = 20;
+ private static final String TAG = "FreeRDP.SessionActivity";
+ // variables for delayed move event sending
+ private static final int MAX_DISCARDED_MOVE_EVENTS = 3;
+ private static final int SEND_MOVE_EVENT_TIMEOUT = 150;
+ private Bitmap bitmap;
+ private SessionState session;
+ private SessionView sessionView;
+ private TouchPointerView touchPointerView;
+ private ProgressDialog progressDialog;
+ private KeyboardView keyboardView;
+ private KeyboardView modifiersKeyboardView;
+ private ZoomControls zoomControls;
+ private KeyboardMapper keyboardMapper;
+
+ private Keyboard specialkeysKeyboard;
+ private Keyboard numpadKeyboard;
+ private Keyboard cursorKeyboard;
+ private Keyboard modifiersKeyboard;
+
+ private AlertDialog dlgVerifyCertificate;
+ private AlertDialog dlgUserCredentials;
+ private View userCredView;
+
+ private UIHandler uiHandler;
+
+ private int screen_width;
+ private int screen_height;
+
+ private boolean connectCancelledByUser = false;
+ private boolean sessionRunning = false;
+ private boolean toggleMouseButtons = false;
+
+ private LibFreeRDPBroadcastReceiver libFreeRDPBroadcastReceiver;
+ private ScrollView2D scrollView;
+ // keyboard visibility flags
+ private boolean sysKeyboardVisible = false;
+ private boolean extKeyboardVisible = false;
+ private int discardedMoveEvents = 0;
+ private ClipboardManagerProxy mClipboardManager;
+ private boolean callbackDialogResult;
+ View mDecor;
+
+ private void createDialogs()
+ {
+ // build verify certificate dialog
+ dlgVerifyCertificate =
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.dlg_title_verify_certificate)
+ .setPositiveButton(android.R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callbackDialogResult = true;
+ synchronized (dialog)
+ {
+ dialog.notify();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.no,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callbackDialogResult = false;
+ connectCancelledByUser = true;
+ synchronized (dialog)
+ {
+ dialog.notify();
+ }
+ }
+ })
+ .setCancelable(false)
+ .create();
+
+ // build the dialog
+ userCredView = getLayoutInflater().inflate(R.layout.credentials, null, true);
+ dlgUserCredentials =
+ new AlertDialog.Builder(this)
+ .setView(userCredView)
+ .setTitle(R.string.dlg_title_credentials)
+ .setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callbackDialogResult = true;
+ synchronized (dialog)
+ {
+ dialog.notify();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callbackDialogResult = false;
+ connectCancelledByUser = true;
+ synchronized (dialog)
+ {
+ dialog.notify();
+ }
+ }
+ })
+ .setCancelable(false)
+ .create();
+ }
+
+ private boolean hasHardwareMenuButton()
+ {
+ if (Build.VERSION.SDK_INT <= 10)
+ return true;
+
+ if (Build.VERSION.SDK_INT >= 14)
+ {
+ boolean rc = false;
+ final ViewConfiguration cfg = ViewConfiguration.get(this);
+
+ return cfg.hasPermanentMenuKey();
+ }
+
+ return false;
+ }
+
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ // show status bar or make fullscreen?
+ if (ApplicationSettingsActivity.getHideStatusBar(this))
+ {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ this.setContentView(R.layout.session);
+ if (hasHardwareMenuButton() || ApplicationSettingsActivity.getHideActionBar(this))
+ {
+ this.getSupportActionBar().hide();
+ }
+ else
+ this.getSupportActionBar().show();
+
+ Log.v(TAG, "Session.onCreate");
+
+ // ATTENTION: We use the onGlobalLayout notification to start our
+ // session.
+ // This is because only then we can know the exact size of our session
+ // when using fit screen
+ // accounting for any status bars etc. that Android might throws on us.
+ // A bit weird looking
+ // but this is the only way ...
+ final View activityRootView = findViewById(R.id.session_root_view);
+ activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new OnGlobalLayoutListener() {
+ @Override public void onGlobalLayout()
+ {
+ screen_width = activityRootView.getWidth();
+ screen_height = activityRootView.getHeight();
+
+ // start session
+ if (!sessionRunning && getIntent() != null)
+ {
+ processIntent(getIntent());
+ sessionRunning = true;
+ }
+ }
+ });
+
+ sessionView = (SessionView)findViewById(R.id.sessionView);
+ sessionView.setScaleGestureDetector(
+ new ScaleGestureDetector(this, new PinchZoomListener()));
+ sessionView.setSessionViewListener(this);
+ sessionView.requestFocus();
+
+ touchPointerView = (TouchPointerView)findViewById(R.id.touchPointerView);
+ touchPointerView.setTouchPointerListener(this);
+
+ keyboardMapper = new KeyboardMapper();
+ keyboardMapper.init(this);
+ keyboardMapper.reset(this);
+
+ modifiersKeyboard = new Keyboard(getApplicationContext(), R.xml.modifiers_keyboard);
+ specialkeysKeyboard = new Keyboard(getApplicationContext(), R.xml.specialkeys_keyboard);
+ numpadKeyboard = new Keyboard(getApplicationContext(), R.xml.numpad_keyboard);
+ cursorKeyboard = new Keyboard(getApplicationContext(), R.xml.cursor_keyboard);
+
+ // hide keyboard below the sessionView
+ keyboardView = (KeyboardView)findViewById(R.id.extended_keyboard);
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ keyboardView.setOnKeyboardActionListener(this);
+
+ modifiersKeyboardView = (KeyboardView)findViewById(R.id.extended_keyboard_header);
+ modifiersKeyboardView.setKeyboard(modifiersKeyboard);
+ modifiersKeyboardView.setOnKeyboardActionListener(this);
+
+ scrollView = (ScrollView2D)findViewById(R.id.sessionScrollView);
+ scrollView.setScrollViewListener(this);
+ uiHandler = new UIHandler();
+ libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();
+
+ zoomControls = (ZoomControls)findViewById(R.id.zoomControls);
+ zoomControls.hide();
+ zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v)
+ {
+ resetZoomControlsAutoHideTimeout();
+ zoomControls.setIsZoomInEnabled(sessionView.zoomIn(ZOOMING_STEP));
+ zoomControls.setIsZoomOutEnabled(true);
+ }
+ });
+ zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v)
+ {
+ resetZoomControlsAutoHideTimeout();
+ zoomControls.setIsZoomOutEnabled(sessionView.zoomOut(ZOOMING_STEP));
+ zoomControls.setIsZoomInEnabled(true);
+ }
+ });
+
+ toggleMouseButtons = false;
+
+ createDialogs();
+
+ // register freerdp events broadcast receiver
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
+ registerReceiver(libFreeRDPBroadcastReceiver, filter);
+
+ mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
+ mClipboardManager.addClipboardChangedListener(this);
+
+ mDecor = getWindow().getDecorView();
+ mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
+
+ @Override protected void onStart()
+ {
+ super.onStart();
+ Log.v(TAG, "Session.onStart");
+ }
+
+ @Override protected void onRestart()
+ {
+ super.onRestart();
+ Log.v(TAG, "Session.onRestart");
+ }
+
+ @Override protected void onResume()
+ {
+ super.onResume();
+ Log.v(TAG, "Session.onResume");
+ }
+
+ @Override protected void onPause()
+ {
+ super.onPause();
+ Log.v(TAG, "Session.onPause");
+
+ // hide any visible keyboards
+ showKeyboard(false, false);
+ }
+
+ @Override protected void onStop()
+ {
+ super.onStop();
+ Log.v(TAG, "Session.onStop");
+ }
+
+ @Override protected void onDestroy()
+ {
+ super.onDestroy();
+ Log.v(TAG, "Session.onDestroy");
+
+ // Cancel running disconnect timers.
+ GlobalApp.cancelDisconnectTimer();
+
+ // Disconnect all remaining sessions.
+ Collection sessions = GlobalApp.getSessions();
+ for (SessionState session : sessions)
+ LibFreeRDP.disconnect(session.getInstance());
+
+ // unregister freerdp events broadcast receiver
+ unregisterReceiver(libFreeRDPBroadcastReceiver);
+
+ // remove clipboard listener
+ mClipboardManager.removeClipboardboardChangedListener(this);
+
+ // free session
+ GlobalApp.freeSession(session.getInstance());
+
+ session = null;
+ }
+
+ @Override public void onConfigurationChanged(Configuration newConfig)
+ {
+ super.onConfigurationChanged(newConfig);
+
+ // reload keyboard resources (changed from landscape)
+ modifiersKeyboard = new Keyboard(getApplicationContext(), R.xml.modifiers_keyboard);
+ specialkeysKeyboard = new Keyboard(getApplicationContext(), R.xml.specialkeys_keyboard);
+ numpadKeyboard = new Keyboard(getApplicationContext(), R.xml.numpad_keyboard);
+ cursorKeyboard = new Keyboard(getApplicationContext(), R.xml.cursor_keyboard);
+
+ // apply loaded keyboards
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ modifiersKeyboardView.setKeyboard(modifiersKeyboard);
+
+ mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
+
+ private void processIntent(Intent intent)
+ {
+ // get either session instance or create one from a bookmark/uri
+ Bundle bundle = intent.getExtras();
+ Uri openUri = intent.getData();
+ if (openUri != null)
+ {
+ // Launched from URI, e.g:
+ // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
+ connect(openUri);
+ }
+ else if (bundle.containsKey(PARAM_INSTANCE))
+ {
+ int inst = bundle.getInt(PARAM_INSTANCE);
+ session = GlobalApp.getSession(inst);
+ bitmap = session.getSurface().getBitmap();
+ bindSession();
+ }
+ else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE))
+ {
+ BookmarkBase bookmark = null;
+ String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
+ if (ConnectionReference.isHostnameReference(refStr))
+ {
+ bookmark = new ManualBookmark();
+ bookmark.get().setHostname(ConnectionReference.getHostname(refStr));
+ }
+ else if (ConnectionReference.isBookmarkReference(refStr))
+ {
+ if (ConnectionReference.isManualBookmarkReference(refStr))
+ bookmark = GlobalApp.getManualBookmarkGateway().findById(
+ ConnectionReference.getManualBookmarkId(refStr));
+ else
+ assert false;
+ }
+
+ if (bookmark != null)
+ connect(bookmark);
+ else
+ closeSessionActivity(RESULT_CANCELED);
+ }
+ else
+ {
+ // no session found - exit
+ closeSessionActivity(RESULT_CANCELED);
+ }
+ }
+
+ private void connect(BookmarkBase bookmark)
+ {
+ session = GlobalApp.createSession(bookmark, getApplicationContext());
+
+ BookmarkBase.ScreenSettings screenSettings =
+ session.getBookmark().getActiveScreenSettings();
+ Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString());
+ if (screenSettings.isAutomatic())
+ {
+ if ((getResources().getConfiguration().screenLayout &
+ Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
+ {
+ // large screen device i.e. tablet: simply use screen info
+ screenSettings.setHeight(screen_height);
+ screenSettings.setWidth(screen_width);
+ }
+ else
+ {
+ // small screen device i.e. phone:
+ // Automatic uses the largest side length of the screen and
+ // makes a 16:10 resolution setting out of it
+ int screenMax = (screen_width > screen_height) ? screen_width : screen_height;
+ screenSettings.setHeight(screenMax);
+ screenSettings.setWidth((int)((float)screenMax * 1.6f));
+ }
+ }
+ if (screenSettings.isFitScreen())
+ {
+ screenSettings.setHeight(screen_height);
+ screenSettings.setWidth(screen_width);
+ }
+
+ connectWithTitle(bookmark.getLabel());
+ }
+
+ private void connect(Uri openUri)
+ {
+ session = GlobalApp.createSession(openUri, getApplicationContext());
+
+ connectWithTitle(openUri.getAuthority());
+ }
+
+ private void connectWithTitle(String title)
+ {
+ session.setUIEventListener(this);
+
+ progressDialog = new ProgressDialog(this);
+ progressDialog.setTitle(title);
+ progressDialog.setMessage(getResources().getText(R.string.dlg_msg_connecting));
+ progressDialog.setButton(
+ ProgressDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
+ @Override public void onClick(DialogInterface dialog, int which)
+ {
+ connectCancelledByUser = true;
+ LibFreeRDP.cancelConnection(session.getInstance());
+ }
+ });
+ progressDialog.setCancelable(false);
+ progressDialog.show();
+
+ Thread thread = new Thread(new Runnable() {
+ public void run()
+ {
+ session.connect(getApplicationContext());
+ }
+ });
+ thread.start();
+ }
+
+ // binds the current session to the activity by wiring it up with the
+ // sessionView and updating all internal objects accordingly
+ private void bindSession()
+ {
+ Log.v(TAG, "bindSession called");
+ session.setUIEventListener(this);
+ sessionView.onSurfaceChange(session);
+ scrollView.requestLayout();
+ keyboardMapper.reset(this);
+ mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
+
+ private void hideSoftInput()
+ {
+ InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+
+ if (mgr.isActive())
+ {
+ mgr.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
+ }
+ else
+ {
+ mgr.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+ }
+
+ // displays either the system or the extended keyboard or non of them
+ private void showKeyboard(final boolean showSystemKeyboard, final boolean showExtendedKeyboard)
+ {
+ // no matter what we are doing ... hide the zoom controls
+ // TODO: this is not working correctly as hiding the keyboard issues a
+ // onScrollChange notification showing the control again ...
+ uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
+ if (zoomControls.getVisibility() == View.VISIBLE)
+ zoomControls.hide();
+
+ InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+
+ if (showSystemKeyboard)
+ {
+ // hide extended keyboard
+ keyboardView.setVisibility(View.GONE);
+ // show system keyboard
+ mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+
+ // show modifiers keyboard
+ modifiersKeyboardView.setVisibility(View.VISIBLE);
+ }
+ else if (showExtendedKeyboard)
+ {
+ // hide system keyboard
+ hideSoftInput();
+
+ // show extended keyboard
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ keyboardView.setVisibility(View.VISIBLE);
+ modifiersKeyboardView.setVisibility(View.VISIBLE);
+ }
+ else
+ {
+ // hide both
+ hideSoftInput();
+ keyboardView.setVisibility(View.GONE);
+ modifiersKeyboardView.setVisibility(View.GONE);
+
+ // clear any active key modifiers)
+ keyboardMapper.clearlAllModifiers();
+ }
+
+ sysKeyboardVisible = showSystemKeyboard;
+ extKeyboardVisible = showExtendedKeyboard;
+ }
+
+ private void closeSessionActivity(int resultCode)
+ {
+ // Go back to home activity (and send intent data back to home)
+ setResult(resultCode, getIntent());
+ finish();
+ }
+
+ // update the state of our modifier keys
+ private void updateModifierKeyStates()
+ {
+ // check if any key is in the keycodes list
+
+ List keys = modifiersKeyboard.getKeys();
+ for (Iterator it = keys.iterator(); it.hasNext();)
+ {
+ // if the key is a sticky key - just set it to off
+ Keyboard.Key curKey = it.next();
+ if (curKey.sticky)
+ {
+ switch (keyboardMapper.getModifierState(curKey.codes[0]))
+ {
+ case KeyboardMapper.KEYSTATE_ON:
+ curKey.on = true;
+ curKey.pressed = false;
+ break;
+
+ case KeyboardMapper.KEYSTATE_OFF:
+ curKey.on = false;
+ curKey.pressed = false;
+ break;
+
+ case KeyboardMapper.KEYSTATE_LOCKED:
+ curKey.on = true;
+ curKey.pressed = true;
+ break;
+ }
+ }
+ }
+
+ // refresh image
+ modifiersKeyboardView.invalidateAllKeys();
+ }
+
+ private void sendDelayedMoveEvent(int x, int y)
+ {
+ if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT))
+ {
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+ discardedMoveEvents++;
+ }
+ else
+ discardedMoveEvents = 0;
+
+ if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS)
+ LibFreeRDP.sendCursorEvent(session.getInstance(), x, y, Mouse.getMoveEvent());
+ else
+ uiHandler.sendMessageDelayed(Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y),
+ SEND_MOVE_EVENT_TIMEOUT);
+ }
+
+ private void cancelDelayedMoveEvent()
+ {
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+ }
+
+ @Override public boolean onCreateOptionsMenu(Menu menu)
+ {
+ getMenuInflater().inflate(R.menu.session_menu, menu);
+ return true;
+ }
+
+ @Override public boolean onOptionsItemSelected(MenuItem item)
+ {
+ // refer to http://tools.android.com/tips/non-constant-fields why we
+ // can't use switch/case here ..
+ int itemId = item.getItemId();
+
+ if (itemId == R.id.session_touch_pointer)
+ {
+ // toggle touch pointer
+ if (touchPointerView.getVisibility() == View.VISIBLE)
+ {
+ touchPointerView.setVisibility(View.INVISIBLE);
+ sessionView.setTouchPointerPadding(0, 0);
+ }
+ else
+ {
+ touchPointerView.setVisibility(View.VISIBLE);
+ sessionView.setTouchPointerPadding(touchPointerView.getPointerWidth(),
+ touchPointerView.getPointerHeight());
+ }
+ }
+ else if (itemId == R.id.session_sys_keyboard)
+ {
+ showKeyboard(!sysKeyboardVisible, false);
+ }
+ else if (itemId == R.id.session_ext_keyboard)
+ {
+ showKeyboard(false, !extKeyboardVisible);
+ }
+ else if (itemId == R.id.session_disconnect)
+ {
+ showKeyboard(false, false);
+ LibFreeRDP.disconnect(session.getInstance());
+ }
+
+ return true;
+ }
+
+ @Override public void onBackPressed()
+ {
+ // hide keyboards (if any visible) or send alt+f4 to the session
+ if (sysKeyboardVisible || extKeyboardVisible)
+ showKeyboard(false, false);
+ else
+ keyboardMapper.sendAltF4();
+ }
+
+ @Override public boolean onKeyLongPress(int keyCode, KeyEvent event)
+ {
+ if (keyCode == KeyEvent.KEYCODE_BACK)
+ {
+ LibFreeRDP.disconnect(session.getInstance());
+ return true;
+ }
+ return super.onKeyLongPress(keyCode, event);
+ }
+
+ // android keyboard input handling
+ // We always use the unicode value to process input from the android
+ // keyboard except if key modifiers
+ // (like Win, Alt, Ctrl) are activated. In this case we will send the
+ // virtual key code to allow key
+ // combinations (like Win + E to open the explorer).
+ @Override public boolean onKeyDown(int keycode, KeyEvent event)
+ {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ @Override public boolean onKeyUp(int keycode, KeyEvent event)
+ {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ // onKeyMultiple is called for input of some special characters like umlauts
+ // and some symbol characters
+ @Override public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
+ {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ // ****************************************************************************
+ // KeyboardView.KeyboardActionEventListener
+ @Override public void onKey(int primaryCode, int[] keyCodes)
+ {
+ keyboardMapper.processCustomKeyEvent(primaryCode);
+ }
+
+ @Override public void onText(CharSequence text)
+ {
+ }
+
+ @Override public void swipeRight()
+ {
+ }
+
+ @Override public void swipeLeft()
+ {
+ }
+
+ @Override public void swipeDown()
+ {
+ }
+
+ @Override public void swipeUp()
+ {
+ }
+
+ @Override public void onPress(int primaryCode)
+ {
+ }
+
+ @Override public void onRelease(int primaryCode)
+ {
+ }
+
+ // ****************************************************************************
+ // KeyboardMapper.KeyProcessingListener implementation
+ @Override public void processVirtualKey(int virtualKeyCode, boolean down)
+ {
+ LibFreeRDP.sendKeyEvent(session.getInstance(), virtualKeyCode, down);
+ }
+
+ @Override public void processUnicodeKey(int unicodeKey)
+ {
+ LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, true);
+ LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey, false);
+ }
+
+ @Override public void switchKeyboard(int keyboardType)
+ {
+ switch (keyboardType)
+ {
+ case KeyboardMapper.KEYBOARD_TYPE_FUNCTIONKEYS:
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ break;
+
+ case KeyboardMapper.KEYBOARD_TYPE_NUMPAD:
+ keyboardView.setKeyboard(numpadKeyboard);
+ break;
+
+ case KeyboardMapper.KEYBOARD_TYPE_CURSOR:
+ keyboardView.setKeyboard(cursorKeyboard);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ @Override public void modifiersChanged()
+ {
+ updateModifierKeyStates();
+ }
+
+ // ****************************************************************************
+ // LibFreeRDP UI event listener implementation
+ @Override public void OnSettingsChanged(int width, int height, int bpp)
+ {
+
+ if (bpp > 16)
+ bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ else
+ bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
+
+ session.setSurface(new BitmapDrawable(bitmap));
+
+ if (session.getBookmark() == null)
+ {
+ // Return immediately if we launch from URI
+ return;
+ }
+
+ // check this settings and initial settings - if they are not equal the
+ // server doesn't support our settings
+ // FIXME: the additional check (settings.getWidth() != width + 1) is for
+ // the RDVH bug fix to avoid accidental notifications
+ // (refer to android_freerdp.c for more info on this problem)
+ BookmarkBase.ScreenSettings settings = session.getBookmark().getActiveScreenSettings();
+ if ((settings.getWidth() != width && settings.getWidth() != width + 1) ||
+ settings.getHeight() != height || settings.getColors() != bpp)
+ uiHandler.sendMessage(
+ Message.obtain(null, UIHandler.DISPLAY_TOAST,
+ getResources().getText(R.string.info_capabilities_changed)));
+ }
+
+ @Override public void OnGraphicsUpdate(int x, int y, int width, int height)
+ {
+ LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width, height);
+
+ sessionView.addInvalidRegion(new Rect(x, y, x + width, y + height));
/*
- * since sessionView can only be modified from the UI thread any
+ * since sessionView can only be modified from the UI thread any
* modifications to it need to be scheduled
*/
- uiHandler.sendEmptyMessage(UIHandler.REFRESH_SESSIONVIEW);
- }
+ uiHandler.sendEmptyMessage(UIHandler.REFRESH_SESSIONVIEW);
+ }
- @Override
- public void OnGraphicsResize(int width, int height, int bpp) {
- // replace bitmap
- if (bpp > 16)
- bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- else
- bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
- session.setSurface(new BitmapDrawable(bitmap));
+ @Override public void OnGraphicsResize(int width, int height, int bpp)
+ {
+ // replace bitmap
+ if (bpp > 16)
+ bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ else
+ bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
+ session.setSurface(new BitmapDrawable(bitmap));
/*
- * since sessionView can only be modified from the UI thread any
+ * since sessionView can only be modified from the UI thread any
* modifications to it need to be scheduled
*/
- uiHandler.sendEmptyMessage(UIHandler.GRAPHICS_CHANGED);
- }
-
- @Override
- public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
- StringBuilder password) {
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set text fields
- ((EditText) userCredView.findViewById(R.id.editTextUsername))
- .setText(username);
- ((EditText) userCredView.findViewById(R.id.editTextDomain))
- .setText(domain);
- ((EditText) userCredView.findViewById(R.id.editTextPassword))
- .setText(password);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgUserCredentials));
-
- // wait for result
- try {
- synchronized (dlgUserCredentials) {
- dlgUserCredentials.wait();
- }
- } catch (InterruptedException e) {
- }
-
- // clear buffers
- username.setLength(0);
- domain.setLength(0);
- password.setLength(0);
-
- // read back user credentials
- username.append(((EditText) userCredView
- .findViewById(R.id.editTextUsername)).getText().toString());
- domain.append(((EditText) userCredView
- .findViewById(R.id.editTextDomain)).getText().toString());
- password.append(((EditText) userCredView
- .findViewById(R.id.editTextPassword)).getText().toString());
-
- return callbackDialogResult;
- }
-
- @Override
- public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password) {
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set text fields
- ((EditText) userCredView.findViewById(R.id.editTextUsername))
- .setText(username);
- ((EditText) userCredView.findViewById(R.id.editTextDomain))
- .setText(domain);
- ((EditText) userCredView.findViewById(R.id.editTextPassword))
- .setText(password);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgUserCredentials));
-
- // wait for result
- try {
- synchronized (dlgUserCredentials) {
- dlgUserCredentials.wait();
- }
- } catch (InterruptedException e) {
- }
-
- // clear buffers
- username.setLength(0);
- domain.setLength(0);
- password.setLength(0);
-
- // read back user credentials
- username.append(((EditText) userCredView
- .findViewById(R.id.editTextUsername)).getText().toString());
- domain.append(((EditText) userCredView
- .findViewById(R.id.editTextDomain)).getText().toString());
- password.append(((EditText) userCredView
- .findViewById(R.id.editTextPassword)).getText().toString());
-
- return callbackDialogResult;
- }
-
- @Override
- public int OnVerifiyCertificate(String commonName, String subject, String issuer, String fingerprint, boolean mismatch) {
- // see if global settings says accept all
- if (ApplicationSettingsActivity.getAcceptAllCertificates(this))
- return 0;
-
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set message
- String msg = getResources().getString(
- R.string.dlg_msg_verify_certificate);
- msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
- + "\nFingerprint: " + fingerprint;
- dlgVerifyCertificate.setMessage(msg);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgVerifyCertificate));
-
- // wait for result
- try {
- synchronized (dlgVerifyCertificate) {
- dlgVerifyCertificate.wait();
- }
- } catch (InterruptedException e) {
- }
-
- return callbackDialogResult ? 1 : 0;
- }
-
- @Override
- public int OnVerifyChangedCertificate(String commonName, String subject, String issuer, String fingerprint, String oldSubject, String oldIssuer, String oldFingerprint) {
- // see if global settings says accept all
- if (ApplicationSettingsActivity.getAcceptAllCertificates(this))
- return 0;
-
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set message
- String msg = getResources().getString(
- R.string.dlg_msg_verify_certificate);
- msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
- + "\nFingerprint: " + fingerprint;
- dlgVerifyCertificate.setMessage(msg);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgVerifyCertificate));
-
- // wait for result
- try {
- synchronized (dlgVerifyCertificate) {
- dlgVerifyCertificate.wait();
- }
- } catch (InterruptedException e) {
- }
-
- return callbackDialogResult ? 1 : 0;
- }
-
- @Override
- public void OnRemoteClipboardChanged(String data) {
- Log.v(TAG, "OnRemoteClipboardChanged: " + data);
- mClipboardManager.setClipboardData(data);
- }
-
- // ****************************************************************************
- // ScrollView2DListener implementation
- private void resetZoomControlsAutoHideTimeout() {
- uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
- uiHandler.sendEmptyMessageDelayed(UIHandler.HIDE_ZOOMCONTROLS,
- ZOOMCONTROLS_AUTOHIDE_TIMEOUT);
- }
-
- @Override
- public void onScrollChanged(ScrollView2D scrollView, int x, int y,
- int oldx, int oldy) {
- zoomControls.setIsZoomInEnabled(!sessionView.isAtMaxZoom());
- zoomControls.setIsZoomOutEnabled(!sessionView.isAtMinZoom());
- if (!ApplicationSettingsActivity.getHideZoomControls(this)
- && zoomControls.getVisibility() != View.VISIBLE)
- zoomControls.show();
- resetZoomControlsAutoHideTimeout();
- }
-
- // ****************************************************************************
- // SessionView.SessionViewListener
- @Override
- public void onSessionViewBeginTouch() {
- scrollView.setScrollEnabled(false);
- }
-
- @Override
- public void onSessionViewEndTouch() {
- scrollView.setScrollEnabled(true);
- }
-
- @Override
- public void onSessionViewLeftTouch(int x, int y, boolean down) {
- if (!down)
- cancelDelayedMoveEvent();
-
- LibFreeRDP.sendCursorEvent(
- session.getInstance(),
- x,
- y,
- toggleMouseButtons ? Mouse.getRightButtonEvent(this, down) : Mouse
- .getLeftButtonEvent(this, down));
-
- if (!down)
- toggleMouseButtons = false;
- }
-
- public void onSessionViewRightTouch(int x, int y, boolean down) {
- if (!down)
- toggleMouseButtons = !toggleMouseButtons;
- }
-
- @Override
- public void onSessionViewMove(int x, int y) {
- sendDelayedMoveEvent(x, y);
- }
-
- @Override
- public void onSessionViewScroll(boolean down) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
- Mouse.getScrollEvent(this, down));
- }
-
- // ****************************************************************************
- // TouchPointerView.TouchPointerListener
- @Override
- public void onTouchPointerClose() {
- touchPointerView.setVisibility(View.INVISIBLE);
- sessionView.setTouchPointerPadding(0, 0);
- }
-
- private Point mapScreenCoordToSessionCoord(int x, int y) {
- int mappedX = (int) ((float) (x + scrollView.getScrollX()) / sessionView
- .getZoom());
- int mappedY = (int) ((float) (y + scrollView.getScrollY()) / sessionView
- .getZoom());
- if (mappedX > bitmap.getWidth())
- mappedX = bitmap.getWidth();
- if (mappedY > bitmap.getHeight())
- mappedY = bitmap.getHeight();
- return new Point(mappedX, mappedY);
- }
-
- @Override
- public void onTouchPointerLeftClick(int x, int y, boolean down) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getLeftButtonEvent(this, down));
- }
-
- @Override
- public void onTouchPointerRightClick(int x, int y, boolean down) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getRightButtonEvent(this, down));
- }
-
- @Override
- public void onTouchPointerMove(int x, int y) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getMoveEvent());
-
- if (ApplicationSettingsActivity.getAutoScrollTouchPointer(this)
- && !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED)) {
- Log.v(TAG, "Starting auto-scroll");
- uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED,
- SCROLLING_TIMEOUT);
- }
- }
-
- @Override
- public void onTouchPointerScroll(boolean down) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
- Mouse.getScrollEvent(this, down));
- }
-
- @Override
- public void onTouchPointerToggleKeyboard() {
- showKeyboard(!sysKeyboardVisible, false);
- }
-
- @Override
- public void onTouchPointerToggleExtKeyboard() {
- showKeyboard(false, !extKeyboardVisible);
- }
-
- @Override
- public void onTouchPointerResetScrollZoom() {
- sessionView.setZoom(1.0f);
- scrollView.scrollTo(0, 0);
- }
-
- @Override
- public boolean onGenericMotionEvent(MotionEvent e) {
- super.onGenericMotionEvent(e);
- switch (e.getAction()) {
- case MotionEvent.ACTION_SCROLL:
- final float vScroll = e.getAxisValue(MotionEvent.AXIS_VSCROLL);
- if (vScroll < 0) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, false));
- }
- if (vScroll > 0) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, true));
- }
- break;
- }
- return true;
- }
-
- // ****************************************************************************
- // ClipboardManagerProxy.OnClipboardChangedListener
- @Override
- public void onClipboardChanged(String data) {
- Log.v(TAG, "onClipboardChanged: " + data);
- LibFreeRDP.sendClipboardData(session.getInstance(), data);
- }
-
- private class UIHandler extends Handler {
-
- public static final int REFRESH_SESSIONVIEW = 1;
- public static final int DISPLAY_TOAST = 2;
- public static final int HIDE_ZOOMCONTROLS = 3;
- public static final int SEND_MOVE_EVENT = 4;
- public static final int SHOW_DIALOG = 5;
- public static final int GRAPHICS_CHANGED = 6;
- public static final int SCROLLING_REQUESTED = 7;
-
- UIHandler() {
- super();
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case GRAPHICS_CHANGED: {
- sessionView.onSurfaceChange(session);
- scrollView.requestLayout();
- break;
- }
- case REFRESH_SESSIONVIEW: {
- sessionView.invalidateRegion();
- break;
- }
- case DISPLAY_TOAST: {
- Toast errorToast = Toast.makeText(getApplicationContext(),
- msg.obj.toString(), Toast.LENGTH_LONG);
- errorToast.show();
- break;
- }
- case HIDE_ZOOMCONTROLS: {
- zoomControls.hide();
- break;
- }
- case SEND_MOVE_EVENT: {
- LibFreeRDP.sendCursorEvent(session.getInstance(), msg.arg1,
- msg.arg2, Mouse.getMoveEvent());
- break;
- }
- case SHOW_DIALOG: {
- // create and show the dialog
- ((Dialog) msg.obj).show();
- break;
- }
- case SCROLLING_REQUESTED: {
- int scrollX = 0;
- int scrollY = 0;
- float[] pointerPos = touchPointerView.getPointerPosition();
-
- if (pointerPos[0] > (screen_width - touchPointerView
- .getPointerWidth()))
- scrollX = SCROLLING_DISTANCE;
- else if (pointerPos[0] < 0)
- scrollX = -SCROLLING_DISTANCE;
-
- if (pointerPos[1] > (screen_height - touchPointerView
- .getPointerHeight()))
- scrollY = SCROLLING_DISTANCE;
- else if (pointerPos[1] < 0)
- scrollY = -SCROLLING_DISTANCE;
-
- scrollView.scrollBy(scrollX, scrollY);
-
- // see if we reached the min/max scroll positions
- if (scrollView.getScrollX() == 0
- || scrollView.getScrollX() == (sessionView.getWidth() - scrollView
- .getWidth()))
- scrollX = 0;
- if (scrollView.getScrollY() == 0
- || scrollView.getScrollY() == (sessionView.getHeight() - scrollView
- .getHeight()))
- scrollY = 0;
-
- if (scrollX != 0 || scrollY != 0)
- uiHandler.sendEmptyMessageDelayed(SCROLLING_REQUESTED,
- SCROLLING_TIMEOUT);
- else
- Log.v(TAG, "Stopping auto-scroll");
- break;
- }
- }
- }
- }
-
- private class PinchZoomListener extends
- ScaleGestureDetector.SimpleOnScaleGestureListener {
- private float scaleFactor = 1.0f;
-
- @Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- scrollView.setScrollEnabled(false);
- return true;
- }
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
-
- // calc scale factor
- scaleFactor *= detector.getScaleFactor();
- scaleFactor = Math.max(SessionView.MIN_SCALE_FACTOR,
- Math.min(scaleFactor, SessionView.MAX_SCALE_FACTOR));
- sessionView.setZoom(scaleFactor);
-
- if (!sessionView.isAtMinZoom() && !sessionView.isAtMaxZoom()) {
- // transform scroll origin to the new zoom space
- float transOriginX = scrollView.getScrollX()
- * detector.getScaleFactor();
- float transOriginY = scrollView.getScrollY()
- * detector.getScaleFactor();
-
- // transform center point to the zoomed space
- float transCenterX = (scrollView.getScrollX() + detector
- .getFocusX()) * detector.getScaleFactor();
- float transCenterY = (scrollView.getScrollY() + detector
- .getFocusY()) * detector.getScaleFactor();
-
- // scroll by the difference between the distance of the
- // transformed center/origin point and their old distance
- // (focusX/Y)
- scrollView.scrollBy(
- (int) ((transCenterX - transOriginX) - detector
- .getFocusX()),
- (int) ((transCenterY - transOriginY) - detector
- .getFocusY()));
- }
-
- return true;
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector de) {
- scrollView.setScrollEnabled(true);
- }
- }
-
- private class LibFreeRDPBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- // still got a valid session?
- if (session == null)
- return;
-
- // is this event for the current session?
- if (session.getInstance() != intent.getExtras().getLong(
- GlobalApp.EVENT_PARAM, -1))
- return;
-
- switch (intent.getExtras().getInt(GlobalApp.EVENT_TYPE, -1)) {
- case GlobalApp.FREERDP_EVENT_CONNECTION_SUCCESS:
- OnConnectionSuccess(context);
- break;
-
- case GlobalApp.FREERDP_EVENT_CONNECTION_FAILURE:
- OnConnectionFailure(context);
- break;
- case GlobalApp.FREERDP_EVENT_DISCONNECTED:
- OnDisconnected(context);
- break;
- }
- }
-
- private void OnConnectionSuccess(Context context) {
- Log.v(TAG, "OnConnectionSuccess");
-
- // bind session
- bindSession();
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- if (session.getBookmark() == null) {
- // Return immediately if we launch from URI
- return;
- }
-
- // add hostname to history if quick connect was used
- Bundle bundle = getIntent().getExtras();
- if (bundle != null
- && bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- if (ConnectionReference.isHostnameReference(bundle
- .getString(PARAM_CONNECTION_REFERENCE))) {
- assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
- String item = session.getBookmark().get()
- .getHostname();
- if (!GlobalApp.getQuickConnectHistoryGateway()
- .historyItemExists(item))
- GlobalApp.getQuickConnectHistoryGateway()
- .addHistoryItem(item);
- }
- }
- }
-
- private void OnConnectionFailure(Context context) {
- Log.v(TAG, "OnConnectionFailure");
-
- // remove pending move events
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- // post error message on UI thread
- if (!connectCancelledByUser)
- uiHandler.sendMessage(Message.obtain(
- null,
- UIHandler.DISPLAY_TOAST,
- getResources().getText(
- R.string.error_connection_failure)));
-
- closeSessionActivity(RESULT_CANCELED);
- }
-
- private void OnDisconnected(Context context) {
- Log.v(TAG, "OnDisconnected");
-
- // remove pending move events
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- session.setUIEventListener(null);
- closeSessionActivity(RESULT_OK);
- }
- }
-
+ uiHandler.sendEmptyMessage(UIHandler.GRAPHICS_CHANGED);
+ }
+
+ @Override
+ public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
+ StringBuilder password)
+ {
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set text fields
+ ((EditText)userCredView.findViewById(R.id.editTextUsername)).setText(username);
+ ((EditText)userCredView.findViewById(R.id.editTextDomain)).setText(domain);
+ ((EditText)userCredView.findViewById(R.id.editTextPassword)).setText(password);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgUserCredentials));
+
+ // wait for result
+ try
+ {
+ synchronized (dlgUserCredentials)
+ {
+ dlgUserCredentials.wait();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ // clear buffers
+ username.setLength(0);
+ domain.setLength(0);
+ password.setLength(0);
+
+ // read back user credentials
+ username.append(
+ ((EditText)userCredView.findViewById(R.id.editTextUsername)).getText().toString());
+ domain.append(
+ ((EditText)userCredView.findViewById(R.id.editTextDomain)).getText().toString());
+ password.append(
+ ((EditText)userCredView.findViewById(R.id.editTextPassword)).getText().toString());
+
+ return callbackDialogResult;
+ }
+
+ @Override
+ public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain,
+ StringBuilder password)
+ {
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set text fields
+ ((EditText)userCredView.findViewById(R.id.editTextUsername)).setText(username);
+ ((EditText)userCredView.findViewById(R.id.editTextDomain)).setText(domain);
+ ((EditText)userCredView.findViewById(R.id.editTextPassword)).setText(password);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgUserCredentials));
+
+ // wait for result
+ try
+ {
+ synchronized (dlgUserCredentials)
+ {
+ dlgUserCredentials.wait();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ // clear buffers
+ username.setLength(0);
+ domain.setLength(0);
+ password.setLength(0);
+
+ // read back user credentials
+ username.append(
+ ((EditText)userCredView.findViewById(R.id.editTextUsername)).getText().toString());
+ domain.append(
+ ((EditText)userCredView.findViewById(R.id.editTextDomain)).getText().toString());
+ password.append(
+ ((EditText)userCredView.findViewById(R.id.editTextPassword)).getText().toString());
+
+ return callbackDialogResult;
+ }
+
+ @Override
+ public int OnVerifiyCertificate(String commonName, String subject, String issuer,
+ String fingerprint, boolean mismatch)
+ {
+ // see if global settings says accept all
+ if (ApplicationSettingsActivity.getAcceptAllCertificates(this))
+ return 0;
+
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set message
+ String msg = getResources().getString(R.string.dlg_msg_verify_certificate);
+ msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer +
+ "\nFingerprint: " + fingerprint;
+ dlgVerifyCertificate.setMessage(msg);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgVerifyCertificate));
+
+ // wait for result
+ try
+ {
+ synchronized (dlgVerifyCertificate)
+ {
+ dlgVerifyCertificate.wait();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ return callbackDialogResult ? 1 : 0;
+ }
+
+ @Override
+ public int OnVerifyChangedCertificate(String commonName, String subject, String issuer,
+ String fingerprint, String oldSubject, String oldIssuer,
+ String oldFingerprint)
+ {
+ // see if global settings says accept all
+ if (ApplicationSettingsActivity.getAcceptAllCertificates(this))
+ return 0;
+
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set message
+ String msg = getResources().getString(R.string.dlg_msg_verify_certificate);
+ msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer +
+ "\nFingerprint: " + fingerprint;
+ dlgVerifyCertificate.setMessage(msg);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgVerifyCertificate));
+
+ // wait for result
+ try
+ {
+ synchronized (dlgVerifyCertificate)
+ {
+ dlgVerifyCertificate.wait();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ return callbackDialogResult ? 1 : 0;
+ }
+
+ @Override public void OnRemoteClipboardChanged(String data)
+ {
+ Log.v(TAG, "OnRemoteClipboardChanged: " + data);
+ mClipboardManager.setClipboardData(data);
+ }
+
+ // ****************************************************************************
+ // ScrollView2DListener implementation
+ private void resetZoomControlsAutoHideTimeout()
+ {
+ uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
+ uiHandler.sendEmptyMessageDelayed(UIHandler.HIDE_ZOOMCONTROLS,
+ ZOOMCONTROLS_AUTOHIDE_TIMEOUT);
+ }
+
+ @Override public void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy)
+ {
+ zoomControls.setIsZoomInEnabled(!sessionView.isAtMaxZoom());
+ zoomControls.setIsZoomOutEnabled(!sessionView.isAtMinZoom());
+ if (!ApplicationSettingsActivity.getHideZoomControls(this) &&
+ zoomControls.getVisibility() != View.VISIBLE)
+ zoomControls.show();
+ resetZoomControlsAutoHideTimeout();
+ }
+
+ // ****************************************************************************
+ // SessionView.SessionViewListener
+ @Override public void onSessionViewBeginTouch()
+ {
+ scrollView.setScrollEnabled(false);
+ }
+
+ @Override public void onSessionViewEndTouch()
+ {
+ scrollView.setScrollEnabled(true);
+ }
+
+ @Override public void onSessionViewLeftTouch(int x, int y, boolean down)
+ {
+ if (!down)
+ cancelDelayedMoveEvent();
+
+ LibFreeRDP.sendCursorEvent(session.getInstance(), x, y,
+ toggleMouseButtons ? Mouse.getRightButtonEvent(this, down)
+ : Mouse.getLeftButtonEvent(this, down));
+
+ if (!down)
+ toggleMouseButtons = false;
+ }
+
+ public void onSessionViewRightTouch(int x, int y, boolean down)
+ {
+ if (!down)
+ toggleMouseButtons = !toggleMouseButtons;
+ }
+
+ @Override public void onSessionViewMove(int x, int y)
+ {
+ sendDelayedMoveEvent(x, y);
+ }
+
+ @Override public void onSessionViewScroll(boolean down)
+ {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, down));
+ }
+
+ // ****************************************************************************
+ // TouchPointerView.TouchPointerListener
+ @Override public void onTouchPointerClose()
+ {
+ touchPointerView.setVisibility(View.INVISIBLE);
+ sessionView.setTouchPointerPadding(0, 0);
+ }
+
+ private Point mapScreenCoordToSessionCoord(int x, int y)
+ {
+ int mappedX = (int)((float)(x + scrollView.getScrollX()) / sessionView.getZoom());
+ int mappedY = (int)((float)(y + scrollView.getScrollY()) / sessionView.getZoom());
+ if (mappedX > bitmap.getWidth())
+ mappedX = bitmap.getWidth();
+ if (mappedY > bitmap.getHeight())
+ mappedY = bitmap.getHeight();
+ return new Point(mappedX, mappedY);
+ }
+
+ @Override public void onTouchPointerLeftClick(int x, int y, boolean down)
+ {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
+ Mouse.getLeftButtonEvent(this, down));
+ }
+
+ @Override public void onTouchPointerRightClick(int x, int y, boolean down)
+ {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
+ Mouse.getRightButtonEvent(this, down));
+ }
+
+ @Override public void onTouchPointerMove(int x, int y)
+ {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y, Mouse.getMoveEvent());
+
+ if (ApplicationSettingsActivity.getAutoScrollTouchPointer(this) &&
+ !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED))
+ {
+ Log.v(TAG, "Starting auto-scroll");
+ uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED, SCROLLING_TIMEOUT);
+ }
+ }
+
+ @Override public void onTouchPointerScroll(boolean down)
+ {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, down));
+ }
+
+ @Override public void onTouchPointerToggleKeyboard()
+ {
+ showKeyboard(!sysKeyboardVisible, false);
+ }
+
+ @Override public void onTouchPointerToggleExtKeyboard()
+ {
+ showKeyboard(false, !extKeyboardVisible);
+ }
+
+ @Override public void onTouchPointerResetScrollZoom()
+ {
+ sessionView.setZoom(1.0f);
+ scrollView.scrollTo(0, 0);
+ }
+
+ @Override public boolean onGenericMotionEvent(MotionEvent e)
+ {
+ super.onGenericMotionEvent(e);
+ switch (e.getAction())
+ {
+ case MotionEvent.ACTION_SCROLL:
+ final float vScroll = e.getAxisValue(MotionEvent.AXIS_VSCROLL);
+ if (vScroll < 0)
+ {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
+ Mouse.getScrollEvent(this, false));
+ }
+ if (vScroll > 0)
+ {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
+ Mouse.getScrollEvent(this, true));
+ }
+ break;
+ }
+ return true;
+ }
+
+ // ****************************************************************************
+ // ClipboardManagerProxy.OnClipboardChangedListener
+ @Override public void onClipboardChanged(String data)
+ {
+ Log.v(TAG, "onClipboardChanged: " + data);
+ LibFreeRDP.sendClipboardData(session.getInstance(), data);
+ }
+
+ private class UIHandler extends Handler
+ {
+
+ public static final int REFRESH_SESSIONVIEW = 1;
+ public static final int DISPLAY_TOAST = 2;
+ public static final int HIDE_ZOOMCONTROLS = 3;
+ public static final int SEND_MOVE_EVENT = 4;
+ public static final int SHOW_DIALOG = 5;
+ public static final int GRAPHICS_CHANGED = 6;
+ public static final int SCROLLING_REQUESTED = 7;
+
+ UIHandler()
+ {
+ super();
+ }
+
+ @Override public void handleMessage(Message msg)
+ {
+ switch (msg.what)
+ {
+ case GRAPHICS_CHANGED:
+ {
+ sessionView.onSurfaceChange(session);
+ scrollView.requestLayout();
+ break;
+ }
+ case REFRESH_SESSIONVIEW:
+ {
+ sessionView.invalidateRegion();
+ break;
+ }
+ case DISPLAY_TOAST:
+ {
+ Toast errorToast = Toast.makeText(getApplicationContext(), msg.obj.toString(),
+ Toast.LENGTH_LONG);
+ errorToast.show();
+ break;
+ }
+ case HIDE_ZOOMCONTROLS:
+ {
+ zoomControls.hide();
+ break;
+ }
+ case SEND_MOVE_EVENT:
+ {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), msg.arg1, msg.arg2,
+ Mouse.getMoveEvent());
+ break;
+ }
+ case SHOW_DIALOG:
+ {
+ // create and show the dialog
+ ((Dialog)msg.obj).show();
+ break;
+ }
+ case SCROLLING_REQUESTED:
+ {
+ int scrollX = 0;
+ int scrollY = 0;
+ float[] pointerPos = touchPointerView.getPointerPosition();
+
+ if (pointerPos[0] > (screen_width - touchPointerView.getPointerWidth()))
+ scrollX = SCROLLING_DISTANCE;
+ else if (pointerPos[0] < 0)
+ scrollX = -SCROLLING_DISTANCE;
+
+ if (pointerPos[1] > (screen_height - touchPointerView.getPointerHeight()))
+ scrollY = SCROLLING_DISTANCE;
+ else if (pointerPos[1] < 0)
+ scrollY = -SCROLLING_DISTANCE;
+
+ scrollView.scrollBy(scrollX, scrollY);
+
+ // see if we reached the min/max scroll positions
+ if (scrollView.getScrollX() == 0 ||
+ scrollView.getScrollX() == (sessionView.getWidth() - scrollView.getWidth()))
+ scrollX = 0;
+ if (scrollView.getScrollY() == 0 ||
+ scrollView.getScrollY() ==
+ (sessionView.getHeight() - scrollView.getHeight()))
+ scrollY = 0;
+
+ if (scrollX != 0 || scrollY != 0)
+ uiHandler.sendEmptyMessageDelayed(SCROLLING_REQUESTED, SCROLLING_TIMEOUT);
+ else
+ Log.v(TAG, "Stopping auto-scroll");
+ break;
+ }
+ }
+ }
+ }
+
+ private class PinchZoomListener extends ScaleGestureDetector.SimpleOnScaleGestureListener
+ {
+ private float scaleFactor = 1.0f;
+
+ @Override public boolean onScaleBegin(ScaleGestureDetector detector)
+ {
+ scrollView.setScrollEnabled(false);
+ return true;
+ }
+
+ @Override public boolean onScale(ScaleGestureDetector detector)
+ {
+
+ // calc scale factor
+ scaleFactor *= detector.getScaleFactor();
+ scaleFactor = Math.max(SessionView.MIN_SCALE_FACTOR,
+ Math.min(scaleFactor, SessionView.MAX_SCALE_FACTOR));
+ sessionView.setZoom(scaleFactor);
+
+ if (!sessionView.isAtMinZoom() && !sessionView.isAtMaxZoom())
+ {
+ // transform scroll origin to the new zoom space
+ float transOriginX = scrollView.getScrollX() * detector.getScaleFactor();
+ float transOriginY = scrollView.getScrollY() * detector.getScaleFactor();
+
+ // transform center point to the zoomed space
+ float transCenterX =
+ (scrollView.getScrollX() + detector.getFocusX()) * detector.getScaleFactor();
+ float transCenterY =
+ (scrollView.getScrollY() + detector.getFocusY()) * detector.getScaleFactor();
+
+ // scroll by the difference between the distance of the
+ // transformed center/origin point and their old distance
+ // (focusX/Y)
+ scrollView.scrollBy((int)((transCenterX - transOriginX) - detector.getFocusX()),
+ (int)((transCenterY - transOriginY) - detector.getFocusY()));
+ }
+
+ return true;
+ }
+
+ @Override public void onScaleEnd(ScaleGestureDetector de)
+ {
+ scrollView.setScrollEnabled(true);
+ }
+ }
+
+ private class LibFreeRDPBroadcastReceiver extends BroadcastReceiver
+ {
+ @Override public void onReceive(Context context, Intent intent)
+ {
+ // still got a valid session?
+ if (session == null)
+ return;
+
+ // is this event for the current session?
+ if (session.getInstance() != intent.getExtras().getLong(GlobalApp.EVENT_PARAM, -1))
+ return;
+
+ switch (intent.getExtras().getInt(GlobalApp.EVENT_TYPE, -1))
+ {
+ case GlobalApp.FREERDP_EVENT_CONNECTION_SUCCESS:
+ OnConnectionSuccess(context);
+ break;
+
+ case GlobalApp.FREERDP_EVENT_CONNECTION_FAILURE:
+ OnConnectionFailure(context);
+ break;
+ case GlobalApp.FREERDP_EVENT_DISCONNECTED:
+ OnDisconnected(context);
+ break;
+ }
+ }
+
+ private void OnConnectionSuccess(Context context)
+ {
+ Log.v(TAG, "OnConnectionSuccess");
+
+ // bind session
+ bindSession();
+
+ if (progressDialog != null)
+ {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ if (session.getBookmark() == null)
+ {
+ // Return immediately if we launch from URI
+ return;
+ }
+
+ // add hostname to history if quick connect was used
+ Bundle bundle = getIntent().getExtras();
+ if (bundle != null && bundle.containsKey(PARAM_CONNECTION_REFERENCE))
+ {
+ if (ConnectionReference.isHostnameReference(
+ bundle.getString(PARAM_CONNECTION_REFERENCE)))
+ {
+ assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
+ String item = session.getBookmark().get().getHostname();
+ if (!GlobalApp.getQuickConnectHistoryGateway().historyItemExists(item))
+ GlobalApp.getQuickConnectHistoryGateway().addHistoryItem(item);
+ }
+ }
+ }
+
+ private void OnConnectionFailure(Context context)
+ {
+ Log.v(TAG, "OnConnectionFailure");
+
+ // remove pending move events
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+
+ if (progressDialog != null)
+ {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ // post error message on UI thread
+ if (!connectCancelledByUser)
+ uiHandler.sendMessage(
+ Message.obtain(null, UIHandler.DISPLAY_TOAST,
+ getResources().getText(R.string.error_connection_failure)));
+
+ closeSessionActivity(RESULT_CANCELED);
+ }
+
+ private void OnDisconnected(Context context)
+ {
+ Log.v(TAG, "OnDisconnected");
+
+ // remove pending move events
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+
+ if (progressDialog != null)
+ {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ session.setUIEventListener(null);
+ closeSessionActivity(RESULT_OK);
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionView.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionView.java
index 5ecbcb735..008b153b6 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionView.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/SessionView.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -32,319 +33,380 @@ import com.freerdp.freerdpcore.utils.Mouse;
import java.util.Stack;
+public class SessionView extends View
+{
+ public static final float MAX_SCALE_FACTOR = 3.0f;
+ public static final float MIN_SCALE_FACTOR = 1.0f;
+ private static final String TAG = "SessionView";
+ private static final float SCALE_FACTOR_DELTA = 0.0001f;
+ private static final float TOUCH_SCROLL_DELTA = 10.0f;
+ private int width;
+ private int height;
+ private BitmapDrawable surface;
+ private Stack invalidRegions;
+ private int touchPointerPaddingWidth = 0;
+ private int touchPointerPaddingHeight = 0;
+ private SessionViewListener sessionViewListener = null;
+ // helpers for scaling gesture handling
+ private float scaleFactor = 1.0f;
+ private Matrix scaleMatrix;
+ private Matrix invScaleMatrix;
+ private RectF invalidRegionF;
+ private GestureDetector gestureDetector;
+ private SessionState currentSession;
-public class SessionView extends View {
- public static final float MAX_SCALE_FACTOR = 3.0f;
- public static final float MIN_SCALE_FACTOR = 1.0f;
- private static final String TAG = "SessionView";
- private static final float SCALE_FACTOR_DELTA = 0.0001f;
- private static final float TOUCH_SCROLL_DELTA = 10.0f;
- private int width;
- private int height;
- private BitmapDrawable surface;
- private Stack invalidRegions;
- private int touchPointerPaddingWidth = 0;
- private int touchPointerPaddingHeight = 0;
- private SessionViewListener sessionViewListener = null;
- // helpers for scaling gesture handling
- private float scaleFactor = 1.0f;
- private Matrix scaleMatrix;
- private Matrix invScaleMatrix;
- private RectF invalidRegionF;
- private GestureDetector gestureDetector;
- private SessionState currentSession;
+ // private static final String TAG = "FreeRDP.SessionView";
+ private DoubleGestureDetector doubleGestureDetector;
+ public SessionView(Context context)
+ {
+ super(context);
+ initSessionView(context);
+ }
- //private static final String TAG = "FreeRDP.SessionView";
- private DoubleGestureDetector doubleGestureDetector;
- public SessionView(Context context) {
- super(context);
- initSessionView(context);
- }
+ public SessionView(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ initSessionView(context);
+ }
- public SessionView(Context context, AttributeSet attrs) {
- super(context, attrs);
- initSessionView(context);
- }
+ public SessionView(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ initSessionView(context);
+ }
- public SessionView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initSessionView(context);
- }
+ private void initSessionView(Context context)
+ {
+ invalidRegions = new Stack();
+ gestureDetector = new GestureDetector(context, new SessionGestureListener(), null, true);
+ doubleGestureDetector =
+ new DoubleGestureDetector(context, null, new SessionDoubleGestureListener());
- private void initSessionView(Context context) {
- invalidRegions = new Stack();
- gestureDetector = new GestureDetector(context, new SessionGestureListener(), null, true);
- doubleGestureDetector = new DoubleGestureDetector(context, null, new SessionDoubleGestureListener());
+ scaleFactor = 1.0f;
+ scaleMatrix = new Matrix();
+ invScaleMatrix = new Matrix();
+ invalidRegionF = new RectF();
- scaleFactor = 1.0f;
- scaleMatrix = new Matrix();
- invScaleMatrix = new Matrix();
- invalidRegionF = new RectF();
+ setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
- setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
- }
+ public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector)
+ {
+ doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
+ }
- public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
- doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
- }
+ public void setSessionViewListener(SessionViewListener sessionViewListener)
+ {
+ this.sessionViewListener = sessionViewListener;
+ }
- public void setSessionViewListener(SessionViewListener sessionViewListener) {
- this.sessionViewListener = sessionViewListener;
- }
+ public void addInvalidRegion(Rect invalidRegion)
+ {
+ // correctly transform invalid region depending on current scaling
+ invalidRegionF.set(invalidRegion);
+ scaleMatrix.mapRect(invalidRegionF);
+ invalidRegionF.roundOut(invalidRegion);
- public void addInvalidRegion(Rect invalidRegion) {
- // correctly transform invalid region depending on current scaling
- invalidRegionF.set(invalidRegion);
- scaleMatrix.mapRect(invalidRegionF);
- invalidRegionF.roundOut(invalidRegion);
+ invalidRegions.add(invalidRegion);
+ }
- invalidRegions.add(invalidRegion);
- }
+ public void invalidateRegion()
+ {
+ invalidate(invalidRegions.pop());
+ }
- public void invalidateRegion() {
- invalidate(invalidRegions.pop());
- }
+ public void onSurfaceChange(SessionState session)
+ {
+ surface = session.getSurface();
+ Bitmap bitmap = surface.getBitmap();
+ width = bitmap.getWidth();
+ height = bitmap.getHeight();
+ surface.setBounds(0, 0, width, height);
- public void onSurfaceChange(SessionState session) {
- surface = session.getSurface();
- Bitmap bitmap = surface.getBitmap();
- width = bitmap.getWidth();
- height = bitmap.getHeight();
- surface.setBounds(0, 0, width, height);
+ setMinimumWidth(width);
+ setMinimumHeight(height);
- setMinimumWidth(width);
- setMinimumHeight(height);
+ requestLayout();
+ currentSession = session;
+ }
- requestLayout();
- currentSession = session;
- }
+ public float getZoom()
+ {
+ return scaleFactor;
+ }
- public float getZoom() {
- return scaleFactor;
- }
+ public void setZoom(float factor)
+ {
+ // calc scale matrix and inverse scale matrix (to correctly transform the view and moues
+ // coordinates)
+ scaleFactor = factor;
+ scaleMatrix.setScale(scaleFactor, scaleFactor);
+ invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
- public void setZoom(float factor) {
- // calc scale matrix and inverse scale matrix (to correctly transform the view and moues coordinates)
- scaleFactor = factor;
- scaleMatrix.setScale(scaleFactor, scaleFactor);
- invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
+ // update layout
+ requestLayout();
+ }
- // update layout
- requestLayout();
- }
+ public boolean isAtMaxZoom()
+ {
+ return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
+ }
- public boolean isAtMaxZoom() {
- return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
- }
+ public boolean isAtMinZoom()
+ {
+ return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
+ }
- public boolean isAtMinZoom() {
- return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
- }
+ public boolean zoomIn(float factor)
+ {
+ boolean res = true;
+ scaleFactor += factor;
+ if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
+ {
+ scaleFactor = MAX_SCALE_FACTOR;
+ res = false;
+ }
+ setZoom(scaleFactor);
+ return res;
+ }
- public boolean zoomIn(float factor) {
- boolean res = true;
- scaleFactor += factor;
- if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA)) {
- scaleFactor = MAX_SCALE_FACTOR;
- res = false;
- }
- setZoom(scaleFactor);
- return res;
- }
+ public boolean zoomOut(float factor)
+ {
+ boolean res = true;
+ scaleFactor -= factor;
+ if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA))
+ {
+ scaleFactor = MIN_SCALE_FACTOR;
+ res = false;
+ }
+ setZoom(scaleFactor);
+ return res;
+ }
- public boolean zoomOut(float factor) {
- boolean res = true;
- scaleFactor -= factor;
- if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA)) {
- scaleFactor = MIN_SCALE_FACTOR;
- res = false;
- }
- setZoom(scaleFactor);
- return res;
- }
+ public void setTouchPointerPadding(int widht, int height)
+ {
+ touchPointerPaddingWidth = widht;
+ touchPointerPaddingHeight = height;
+ requestLayout();
+ }
- public void setTouchPointerPadding(int widht, int height) {
- touchPointerPaddingWidth = widht;
- touchPointerPaddingHeight = height;
- requestLayout();
- }
+ public int getTouchPointerPaddingWidth()
+ {
+ return touchPointerPaddingWidth;
+ }
- public int getTouchPointerPaddingWidth() {
- return touchPointerPaddingWidth;
- }
+ public int getTouchPointerPaddingHeight()
+ {
+ return touchPointerPaddingHeight;
+ }
- public int getTouchPointerPaddingHeight() {
- return touchPointerPaddingHeight;
- }
+ @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
+ {
+ Log.v(TAG, width + "x" + height);
+ this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth,
+ (int)(height * scaleFactor) + touchPointerPaddingHeight);
+ }
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- Log.v(TAG, width + "x" + height);
- this.setMeasuredDimension((int) (width * scaleFactor) + touchPointerPaddingWidth, (int) (height * scaleFactor) + touchPointerPaddingHeight);
- }
+ @Override public void onDraw(Canvas canvas)
+ {
+ super.onDraw(canvas);
- @Override
- public void onDraw(Canvas canvas) {
- super.onDraw(canvas);
+ canvas.save();
+ canvas.concat(scaleMatrix);
+ surface.draw(canvas);
+ canvas.restore();
+ }
- canvas.save();
- canvas.concat(scaleMatrix);
- surface.draw(canvas);
- canvas.restore();
- }
+ // dirty hack: we call back to our activity and call onBackPressed as this doesn't reach us when
+ // the soft keyboard is shown ...
+ @Override public boolean dispatchKeyEventPreIme(KeyEvent event)
+ {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK &&
+ event.getAction() == KeyEvent.ACTION_DOWN)
+ ((SessionActivity)this.getContext()).onBackPressed();
+ return super.dispatchKeyEventPreIme(event);
+ }
- // dirty hack: we call back to our activity and call onBackPressed as this doesn't reach us when the soft keyboard is shown ...
- @Override
- public boolean dispatchKeyEventPreIme(KeyEvent event) {
- if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)
- ((SessionActivity) this.getContext()).onBackPressed();
- return super.dispatchKeyEventPreIme(event);
- }
+ // perform mapping on the touch event's coordinates according to the current scaling
+ private MotionEvent mapTouchEvent(MotionEvent event)
+ {
+ MotionEvent mappedEvent = MotionEvent.obtain(event);
+ float[] coordinates = { mappedEvent.getX(), mappedEvent.getY() };
+ invScaleMatrix.mapPoints(coordinates);
+ mappedEvent.setLocation(coordinates[0], coordinates[1]);
+ return mappedEvent;
+ }
- // perform mapping on the touch event's coordinates according to the current scaling
- private MotionEvent mapTouchEvent(MotionEvent event) {
- MotionEvent mappedEvent = MotionEvent.obtain(event);
- float[] coordinates = {mappedEvent.getX(), mappedEvent.getY()};
- invScaleMatrix.mapPoints(coordinates);
- mappedEvent.setLocation(coordinates[0], coordinates[1]);
- return mappedEvent;
- }
+ // perform mapping on the double touch event's coordinates according to the current scaling
+ private MotionEvent mapDoubleTouchEvent(MotionEvent event)
+ {
+ MotionEvent mappedEvent = MotionEvent.obtain(event);
+ float[] coordinates = { (mappedEvent.getX(0) + mappedEvent.getX(1)) / 2,
+ (mappedEvent.getY(0) + mappedEvent.getY(1)) / 2 };
+ invScaleMatrix.mapPoints(coordinates);
+ mappedEvent.setLocation(coordinates[0], coordinates[1]);
+ return mappedEvent;
+ }
- // perform mapping on the double touch event's coordinates according to the current scaling
- private MotionEvent mapDoubleTouchEvent(MotionEvent event) {
- MotionEvent mappedEvent = MotionEvent.obtain(event);
- float[] coordinates = {(mappedEvent.getX(0) + mappedEvent.getX(1)) / 2, (mappedEvent.getY(0) + mappedEvent.getY(1)) / 2};
- invScaleMatrix.mapPoints(coordinates);
- mappedEvent.setLocation(coordinates[0], coordinates[1]);
- return mappedEvent;
- }
+ @Override public boolean onTouchEvent(MotionEvent event)
+ {
+ boolean res = gestureDetector.onTouchEvent(event);
+ res |= doubleGestureDetector.onTouchEvent(event);
+ return res;
+ }
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- boolean res = gestureDetector.onTouchEvent(event);
- res |= doubleGestureDetector.onTouchEvent(event);
- return res;
- }
+ public interface SessionViewListener {
+ abstract void onSessionViewBeginTouch();
- public interface SessionViewListener {
- abstract void onSessionViewBeginTouch();
+ abstract void onSessionViewEndTouch();
- abstract void onSessionViewEndTouch();
+ abstract void onSessionViewLeftTouch(int x, int y, boolean down);
- abstract void onSessionViewLeftTouch(int x, int y, boolean down);
+ abstract void onSessionViewRightTouch(int x, int y, boolean down);
- abstract void onSessionViewRightTouch(int x, int y, boolean down);
+ abstract void onSessionViewMove(int x, int y);
- abstract void onSessionViewMove(int x, int y);
+ abstract void onSessionViewScroll(boolean down);
+ }
- abstract void onSessionViewScroll(boolean down);
- }
+ private class SessionGestureListener extends GestureDetector.SimpleOnGestureListener
+ {
+ boolean longPressInProgress = false;
- private class SessionGestureListener extends GestureDetector.SimpleOnGestureListener {
- boolean longPressInProgress = false;
+ public boolean onDown(MotionEvent e)
+ {
+ return true;
+ }
- public boolean onDown(MotionEvent e) {
- return true;
- }
+ public boolean onUp(MotionEvent e)
+ {
+ sessionViewListener.onSessionViewEndTouch();
+ return true;
+ }
- public boolean onUp(MotionEvent e) {
- sessionViewListener.onSessionViewEndTouch();
- return true;
- }
+ public void onLongPress(MotionEvent e)
+ {
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewBeginTouch();
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ longPressInProgress = true;
+ }
- public void onLongPress(MotionEvent e) {
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewBeginTouch();
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- longPressInProgress = true;
- }
+ public void onLongPressUp(MotionEvent e)
+ {
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ longPressInProgress = false;
+ sessionViewListener.onSessionViewEndTouch();
+ }
- public void onLongPressUp(MotionEvent e) {
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- longPressInProgress = false;
- sessionViewListener.onSessionViewEndTouch();
- }
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
+ {
+ if (longPressInProgress)
+ {
+ MotionEvent mappedEvent = mapTouchEvent(e2);
+ sessionViewListener.onSessionViewMove((int)mappedEvent.getX(),
+ (int)mappedEvent.getY());
+ return true;
+ }
- public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
- if (longPressInProgress) {
- MotionEvent mappedEvent = mapTouchEvent(e2);
- sessionViewListener.onSessionViewMove((int) mappedEvent.getX(), (int) mappedEvent.getY());
- return true;
- }
+ return false;
+ }
- return false;
- }
+ public boolean onDoubleTap(MotionEvent e)
+ {
+ // send 2nd click for double click
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ return true;
+ }
- public boolean onDoubleTap(MotionEvent e) {
- // send 2nd click for double click
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- return true;
- }
+ public boolean onSingleTapUp(MotionEvent e)
+ {
+ // send single click
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewBeginTouch();
+ switch (e.getButtonState())
+ {
+ case MotionEvent.BUTTON_PRIMARY:
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ break;
+ case MotionEvent.BUTTON_SECONDARY:
+ sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ break;
+ }
+ sessionViewListener.onSessionViewEndTouch();
+ return true;
+ }
+ }
- public boolean onSingleTapUp(MotionEvent e) {
- // send single click
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewBeginTouch();
- switch (e.getButtonState()) {
- case MotionEvent.BUTTON_PRIMARY:
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- break;
- case MotionEvent.BUTTON_SECONDARY:
- sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- break;
- }
- sessionViewListener.onSessionViewEndTouch();
- return true;
- }
- }
+ private class SessionDoubleGestureListener
+ implements DoubleGestureDetector.OnDoubleGestureListener
+ {
+ private MotionEvent prevEvent = null;
- private class SessionDoubleGestureListener implements DoubleGestureDetector.OnDoubleGestureListener {
- private MotionEvent prevEvent = null;
+ public boolean onDoubleTouchDown(MotionEvent e)
+ {
+ sessionViewListener.onSessionViewBeginTouch();
+ prevEvent = MotionEvent.obtain(e);
+ return true;
+ }
- public boolean onDoubleTouchDown(MotionEvent e) {
- sessionViewListener.onSessionViewBeginTouch();
- prevEvent = MotionEvent.obtain(e);
- return true;
- }
+ public boolean onDoubleTouchUp(MotionEvent e)
+ {
+ if (prevEvent != null)
+ {
+ prevEvent.recycle();
+ prevEvent = null;
+ }
+ sessionViewListener.onSessionViewEndTouch();
+ return true;
+ }
- public boolean onDoubleTouchUp(MotionEvent e) {
- if (prevEvent != null) {
- prevEvent.recycle();
- prevEvent = null;
- }
- sessionViewListener.onSessionViewEndTouch();
- return true;
- }
-
- public boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2) {
- // calc if user scrolled up or down (or if any scrolling happened at all)
- float deltaY = e2.getY() - prevEvent.getY();
- if (deltaY > TOUCH_SCROLL_DELTA) {
- sessionViewListener.onSessionViewScroll(true);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- } else if (deltaY < -TOUCH_SCROLL_DELTA) {
- sessionViewListener.onSessionViewScroll(false);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
- return true;
- }
-
- public boolean onDoubleTouchSingleTap(MotionEvent e) {
- // send single click
- MotionEvent mappedEvent = mapDoubleTouchEvent(e);
- sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
- sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
- return true;
- }
- }
+ public boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2)
+ {
+ // calc if user scrolled up or down (or if any scrolling happened at all)
+ float deltaY = e2.getY() - prevEvent.getY();
+ if (deltaY > TOUCH_SCROLL_DELTA)
+ {
+ sessionViewListener.onSessionViewScroll(true);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
+ else if (deltaY < -TOUCH_SCROLL_DELTA)
+ {
+ sessionViewListener.onSessionViewScroll(false);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
+ return true;
+ }
+ public boolean onDoubleTouchSingleTap(MotionEvent e)
+ {
+ // send single click
+ MotionEvent mappedEvent = mapDoubleTouchEvent(e);
+ sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(),
+ (int)mappedEvent.getY(), false);
+ return true;
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ShortcutsActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ShortcutsActivity.java
index 7101fb451..2121c6e53 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ShortcutsActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/ShortcutsActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -30,118 +31,130 @@ import com.freerdp.freerdpcore.utils.BookmarkArrayAdapter;
import java.util.ArrayList;
-public class ShortcutsActivity extends ListActivity {
+public class ShortcutsActivity extends ListActivity
+{
- public static final String TAG = "ShortcutsActivity";
+ public static final String TAG = "ShortcutsActivity";
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
- @Override
- public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- super.onCreate(savedInstanceState);
+ Intent intent = getIntent();
+ if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction()))
+ {
+ // set listeners for the list view
+ getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View view, int position, long id)
+ {
+ String refStr = view.getTag().toString();
+ String defLabel =
+ ((TextView)(view.findViewById(R.id.bookmark_text1))).getText().toString();
+ setupShortcut(refStr, defLabel);
+ }
+ });
+ }
+ else
+ {
+ // just exit
+ finish();
+ }
+ }
- Intent intent = getIntent();
- if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
- // set listeners for the list view
- getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- String refStr = view.getTag().toString();
- String defLabel = ((TextView) (view.findViewById(R.id.bookmark_text1))).getText().toString();
- setupShortcut(refStr, defLabel);
- }
- });
- } else {
- // just exit
- finish();
- }
- }
+ @Override public void onResume()
+ {
+ super.onResume();
+ // create bookmark cursor adapter
+ ArrayList bookmarks = GlobalApp.getManualBookmarkGateway().findAll();
+ BookmarkArrayAdapter bookmarkAdapter =
+ new BookmarkArrayAdapter(this, android.R.layout.simple_list_item_2, bookmarks);
+ getListView().setAdapter(bookmarkAdapter);
+ }
- @Override
- public void onResume() {
- super.onResume();
- // create bookmark cursor adapter
- ArrayList bookmarks = GlobalApp.getManualBookmarkGateway().findAll();
- BookmarkArrayAdapter bookmarkAdapter = new BookmarkArrayAdapter(this, android.R.layout.simple_list_item_2, bookmarks);
- getListView().setAdapter(bookmarkAdapter);
- }
+ public void onPause()
+ {
+ super.onPause();
+ getListView().setAdapter(null);
+ }
- public void onPause() {
- super.onPause();
- getListView().setAdapter(null);
- }
+ /**
+ * This function creates a shortcut and returns it to the caller. There are actually two
+ * intents that you will send back.
+ *
+ * The first intent serves as a container for the shortcut and is returned to the launcher by
+ * setResult(). This intent must contain three fields:
+ *
+ *
+ * - {@link android.content.Intent#EXTRA_SHORTCUT_INTENT} The shortcut intent.
+ * - {@link android.content.Intent#EXTRA_SHORTCUT_NAME} The text that will be displayed with
+ * the shortcut.
+ * - {@link android.content.Intent#EXTRA_SHORTCUT_ICON} The shortcut's icon, if provided as a
+ * bitmap, or {@link android.content.Intent#EXTRA_SHORTCUT_ICON_RESOURCE} if provided as
+ * a drawable resource.
+ *
+ *
+ * If you use a simple drawable resource, note that you must wrapper it using
+ * {@link android.content.Intent.ShortcutIconResource}, as shown below. This is required so
+ * that the launcher can access resources that are stored in your application's .apk file. If
+ * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras
+ * bundle using {@link android.content.Intent#EXTRA_SHORTCUT_ICON}.
+ *
+ * The shortcut intent can be any intent that you wish the launcher to send, when the user
+ * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW}
+ * with an appropriate Uri for your content, but any Intent will work here as long as it
+ * triggers the desired action within your Activity.
+ */
- /**
- * This function creates a shortcut and returns it to the caller. There are actually two
- * intents that you will send back.
- *
- * The first intent serves as a container for the shortcut and is returned to the launcher by
- * setResult(). This intent must contain three fields:
- *
- *
- * - {@link android.content.Intent#EXTRA_SHORTCUT_INTENT} The shortcut intent.
- * - {@link android.content.Intent#EXTRA_SHORTCUT_NAME} The text that will be displayed with
- * the shortcut.
- * - {@link android.content.Intent#EXTRA_SHORTCUT_ICON} The shortcut's icon, if provided as a
- * bitmap, or {@link android.content.Intent#EXTRA_SHORTCUT_ICON_RESOURCE} if provided as
- * a drawable resource.
- *
- *
- * If you use a simple drawable resource, note that you must wrapper it using
- * {@link android.content.Intent.ShortcutIconResource}, as shown below. This is required so
- * that the launcher can access resources that are stored in your application's .apk file. If
- * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras
- * bundle using {@link android.content.Intent#EXTRA_SHORTCUT_ICON}.
- *
- * The shortcut intent can be any intent that you wish the launcher to send, when the user
- * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW}
- * with an appropriate Uri for your content, but any Intent will work here as long as it
- * triggers the desired action within your Activity.
- */
+ private void setupShortcut(String strRef, String defaultLabel)
+ {
+ final String paramStrRef = strRef;
+ final String paramDefaultLabel = defaultLabel;
+ final Context paramContext = this;
- private void setupShortcut(String strRef, String defaultLabel) {
- final String paramStrRef = strRef;
- final String paramDefaultLabel = defaultLabel;
- final Context paramContext = this;
+ // display edit dialog to the user so he can specify the shortcut name
+ final EditText input = new EditText(this);
+ input.setText(defaultLabel);
- // display edit dialog to the user so he can specify the shortcut name
- final EditText input = new EditText(this);
- input.setText(defaultLabel);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_create_shortcut)
+ .setMessage(R.string.dlg_msg_create_shortcut)
+ .setView(input)
+ .setPositiveButton(
+ android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override public void onClick(DialogInterface dialog, int which)
+ {
+ String label = input.getText().toString();
+ if (label.length() == 0)
+ label = paramDefaultLabel;
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_create_shortcut)
- .setMessage(R.string.dlg_msg_create_shortcut)
- .setView(input)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String label = input.getText().toString();
- if (label.length() == 0)
- label = paramDefaultLabel;
+ Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
+ shortcutIntent.setClassName(paramContext,
+ SessionRequestHandlerActivity.class.getName());
+ shortcutIntent.setData(Uri.parse(paramStrRef));
- Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
- shortcutIntent.setClassName(paramContext, SessionRequestHandlerActivity.class.getName());
- shortcutIntent.setData(Uri.parse(paramStrRef));
-
- // Then, set up the container intent (the response to the caller)
- Intent intent = new Intent();
- intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
- intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
- Parcelable iconResource = Intent.ShortcutIconResource.fromContext(paramContext, R.drawable.icon_launcher_freerdp);
- intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
-
- // Now, return the result to the launcher
- setResult(RESULT_OK, intent);
- finish();
- }
- })
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .create().show();
-
- }
+ // Then, set up the container intent (the response to the caller)
+ Intent intent = new Intent();
+ intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
+ Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
+ paramContext, R.drawable.icon_launcher_freerdp);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
+ // Now, return the result to the launcher
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override public void onClick(DialogInterface dialog, int which)
+ {
+ dialog.dismiss();
+ }
+ })
+ .create()
+ .show();
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/TouchPointerView.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/TouchPointerView.java
index d58159dd0..6b8b96ce6 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/TouchPointerView.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/presentation/TouchPointerView.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.presentation;
@@ -21,312 +22,364 @@ import android.widget.ImageView;
import com.freerdp.freerdpcore.R;
import com.freerdp.freerdpcore.utils.GestureDetector;
-public class TouchPointerView extends ImageView {
+public class TouchPointerView extends ImageView
+{
- private static final int POINTER_ACTION_CURSOR = 0;
- private static final int POINTER_ACTION_CLOSE = 3;
+ private static final int POINTER_ACTION_CURSOR = 0;
+ private static final int POINTER_ACTION_CLOSE = 3;
+ // the touch pointer consists of 9 quadrants with the following functionality:
+ //
+ // -------------
+ // | 0 | 1 | 2 |
+ // -------------
+ // | 3 | 4 | 5 |
+ // -------------
+ // | 6 | 7 | 8 |
+ // -------------
+ //
+ // 0 ... contains the actual pointer (the tip must be centered in the quadrant)
+ // 1 ... is left empty
+ // 2, 3, 5, 6, 7, 8 ... function quadrants that issue a callback
+ // 4 ... pointer center used for left clicks and to drag the pointer
+ private static final int POINTER_ACTION_RCLICK = 2;
+ private static final int POINTER_ACTION_LCLICK = 4;
+ private static final int POINTER_ACTION_MOVE = 4;
+ private static final int POINTER_ACTION_SCROLL = 5;
+ private static final int POINTER_ACTION_RESET = 6;
+ private static final int POINTER_ACTION_KEYBOARD = 7;
+ private static final int POINTER_ACTION_EXTKEYBOARD = 8;
+ private static final float SCROLL_DELTA = 10.0f;
+ private static final int DEFAULT_TOUCH_POINTER_RESTORE_DELAY = 150;
+ private RectF pointerRect;
+ private RectF pointerAreaRects[] = new RectF[9];
+ private Matrix translationMatrix;
+ private boolean pointerMoving = false;
+ private boolean pointerScrolling = false;
+ private TouchPointerListener listener = null;
+ private UIHandler uiHandler = new UIHandler();
+ // gesture detection
+ private GestureDetector gestureDetector;
+ public TouchPointerView(Context context)
+ {
+ super(context);
+ initTouchPointer(context);
+ }
- // the touch pointer consists of 9 quadrants with the following functionality:
- //
- // -------------
- // | 0 | 1 | 2 |
- // -------------
- // | 3 | 4 | 5 |
- // -------------
- // | 6 | 7 | 8 |
- // -------------
- //
- // 0 ... contains the actual pointer (the tip must be centered in the quadrant)
- // 1 ... is left empty
- // 2, 3, 5, 6, 7, 8 ... function quadrants that issue a callback
- // 4 ... pointer center used for left clicks and to drag the pointer
- private static final int POINTER_ACTION_RCLICK = 2;
- private static final int POINTER_ACTION_LCLICK = 4;
- private static final int POINTER_ACTION_MOVE = 4;
- private static final int POINTER_ACTION_SCROLL = 5;
- private static final int POINTER_ACTION_RESET = 6;
- private static final int POINTER_ACTION_KEYBOARD = 7;
- private static final int POINTER_ACTION_EXTKEYBOARD = 8;
- private static final float SCROLL_DELTA = 10.0f;
- private static final int DEFAULT_TOUCH_POINTER_RESTORE_DELAY = 150;
- private RectF pointerRect;
- private RectF pointerAreaRects[] = new RectF[9];
- private Matrix translationMatrix;
- private boolean pointerMoving = false;
- private boolean pointerScrolling = false;
- private TouchPointerListener listener = null;
- private UIHandler uiHandler = new UIHandler();
- // gesture detection
- private GestureDetector gestureDetector;
- public TouchPointerView(Context context) {
- super(context);
- initTouchPointer(context);
- }
+ public TouchPointerView(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ initTouchPointer(context);
+ }
- public TouchPointerView(Context context, AttributeSet attrs) {
- super(context, attrs);
- initTouchPointer(context);
- }
+ public TouchPointerView(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ initTouchPointer(context);
+ }
- public TouchPointerView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initTouchPointer(context);
- }
+ private void initTouchPointer(Context context)
+ {
+ gestureDetector =
+ new GestureDetector(context, new TouchPointerGestureListener(), null, true);
+ gestureDetector.setLongPressTimeout(500);
+ translationMatrix = new Matrix();
+ setScaleType(ScaleType.MATRIX);
+ setImageMatrix(translationMatrix);
- private void initTouchPointer(Context context) {
- gestureDetector = new GestureDetector(context, new TouchPointerGestureListener(), null, true);
- gestureDetector.setLongPressTimeout(500);
- translationMatrix = new Matrix();
- setScaleType(ScaleType.MATRIX);
- setImageMatrix(translationMatrix);
+ // init rects
+ final float rectSizeWidth = (float)getDrawable().getIntrinsicWidth() / 3.0f;
+ final float rectSizeHeight = (float)getDrawable().getIntrinsicWidth() / 3.0f;
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ int left = (int)(j * rectSizeWidth);
+ int top = (int)(i * rectSizeHeight);
+ int right = left + (int)rectSizeWidth;
+ int bottom = top + (int)rectSizeHeight;
+ pointerAreaRects[i * 3 + j] = new RectF(left, top, right, bottom);
+ }
+ }
+ pointerRect =
+ new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
+ }
- // init rects
- final float rectSizeWidth = (float) getDrawable().getIntrinsicWidth() / 3.0f;
- final float rectSizeHeight = (float) getDrawable().getIntrinsicWidth() / 3.0f;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- int left = (int) (j * rectSizeWidth);
- int top = (int) (i * rectSizeHeight);
- int right = left + (int) rectSizeWidth;
- int bottom = top + (int) rectSizeHeight;
- pointerAreaRects[i * 3 + j] = new RectF(left, top, right, bottom);
- }
- }
- pointerRect = new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
- }
+ public void setTouchPointerListener(TouchPointerListener listener)
+ {
+ this.listener = listener;
+ }
- public void setTouchPointerListener(TouchPointerListener listener) {
- this.listener = listener;
- }
+ public int getPointerWidth()
+ {
+ return getDrawable().getIntrinsicWidth();
+ }
- public int getPointerWidth() {
- return getDrawable().getIntrinsicWidth();
- }
+ public int getPointerHeight()
+ {
+ return getDrawable().getIntrinsicHeight();
+ }
- public int getPointerHeight() {
- return getDrawable().getIntrinsicHeight();
- }
+ public float[] getPointerPosition()
+ {
+ float[] curPos = new float[2];
+ translationMatrix.mapPoints(curPos);
+ return curPos;
+ }
- public float[] getPointerPosition() {
- float[] curPos = new float[2];
- translationMatrix.mapPoints(curPos);
- return curPos;
- }
+ private void movePointer(float deltaX, float deltaY)
+ {
+ translationMatrix.postTranslate(deltaX, deltaY);
+ setImageMatrix(translationMatrix);
+ }
- private void movePointer(float deltaX, float deltaY) {
- translationMatrix.postTranslate(deltaX, deltaY);
- setImageMatrix(translationMatrix);
- }
+ private void ensureVisibility(int screen_width, int screen_height)
+ {
+ float[] curPos = new float[2];
+ translationMatrix.mapPoints(curPos);
- private void ensureVisibility(int screen_width, int screen_height) {
- float[] curPos = new float[2];
- translationMatrix.mapPoints(curPos);
+ if (curPos[0] > (screen_width - pointerRect.width()))
+ curPos[0] = screen_width - pointerRect.width();
+ if (curPos[0] < 0)
+ curPos[0] = 0;
+ if (curPos[1] > (screen_height - pointerRect.height()))
+ curPos[1] = screen_height - pointerRect.height();
+ if (curPos[1] < 0)
+ curPos[1] = 0;
- if (curPos[0] > (screen_width - pointerRect.width()))
- curPos[0] = screen_width - pointerRect.width();
- if (curPos[0] < 0)
- curPos[0] = 0;
- if (curPos[1] > (screen_height - pointerRect.height()))
- curPos[1] = screen_height - pointerRect.height();
- if (curPos[1] < 0)
- curPos[1] = 0;
+ translationMatrix.setTranslate(curPos[0], curPos[1]);
+ setImageMatrix(translationMatrix);
+ }
- translationMatrix.setTranslate(curPos[0], curPos[1]);
- setImageMatrix(translationMatrix);
- }
+ private void displayPointerImageAction(int resId)
+ {
+ setPointerImage(resId);
+ uiHandler.sendEmptyMessageDelayed(0, DEFAULT_TOUCH_POINTER_RESTORE_DELAY);
+ }
- private void displayPointerImageAction(int resId) {
- setPointerImage(resId);
- uiHandler.sendEmptyMessageDelayed(0, DEFAULT_TOUCH_POINTER_RESTORE_DELAY);
- }
+ private void setPointerImage(int resId)
+ {
+ setImageResource(resId);
+ }
- private void setPointerImage(int resId) {
- setImageResource(resId);
- }
+ // returns the pointer area with the current translation matrix applied
+ private RectF getCurrentPointerArea(int area)
+ {
+ RectF transRect = new RectF(pointerAreaRects[area]);
+ translationMatrix.mapRect(transRect);
+ return transRect;
+ }
- // returns the pointer area with the current translation matrix applied
- private RectF getCurrentPointerArea(int area) {
- RectF transRect = new RectF(pointerAreaRects[area]);
- translationMatrix.mapRect(transRect);
- return transRect;
- }
+ private boolean pointerAreaTouched(MotionEvent event, int area)
+ {
+ RectF transRect = new RectF(pointerAreaRects[area]);
+ translationMatrix.mapRect(transRect);
+ if (transRect.contains(event.getX(), event.getY()))
+ return true;
+ return false;
+ }
- private boolean pointerAreaTouched(MotionEvent event, int area) {
- RectF transRect = new RectF(pointerAreaRects[area]);
- translationMatrix.mapRect(transRect);
- if (transRect.contains(event.getX(), event.getY()))
- return true;
- return false;
- }
+ private boolean pointerTouched(MotionEvent event)
+ {
+ RectF transRect = new RectF(pointerRect);
+ translationMatrix.mapRect(transRect);
+ if (transRect.contains(event.getX(), event.getY()))
+ return true;
+ return false;
+ }
- private boolean pointerTouched(MotionEvent event) {
- RectF transRect = new RectF(pointerRect);
- translationMatrix.mapRect(transRect);
- if (transRect.contains(event.getX(), event.getY()))
- return true;
- return false;
- }
+ @Override public boolean onTouchEvent(MotionEvent event)
+ {
+ // check if pointer is being moved or if we are in scroll mode or if the pointer is touched
+ if (!pointerMoving && !pointerScrolling && !pointerTouched(event))
+ return false;
+ return gestureDetector.onTouchEvent(event);
+ }
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- // check if pointer is being moved or if we are in scroll mode or if the pointer is touched
- if (!pointerMoving && !pointerScrolling && !pointerTouched(event))
- return false;
- return gestureDetector.onTouchEvent(event);
- }
+ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom)
+ {
+ // ensure touch pointer is visible
+ if (changed)
+ ensureVisibility(right - left, bottom - top);
+ }
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- // ensure touch pointer is visible
- if (changed)
- ensureVisibility(right - left, bottom - top);
- }
+ // touch pointer listener - is triggered if an action field is
+ public interface TouchPointerListener {
+ abstract void onTouchPointerClose();
- // touch pointer listener - is triggered if an action field is
- public interface TouchPointerListener {
- abstract void onTouchPointerClose();
+ abstract void onTouchPointerLeftClick(int x, int y, boolean down);
- abstract void onTouchPointerLeftClick(int x, int y, boolean down);
+ abstract void onTouchPointerRightClick(int x, int y, boolean down);
- abstract void onTouchPointerRightClick(int x, int y, boolean down);
+ abstract void onTouchPointerMove(int x, int y);
- abstract void onTouchPointerMove(int x, int y);
+ abstract void onTouchPointerScroll(boolean down);
- abstract void onTouchPointerScroll(boolean down);
+ abstract void onTouchPointerToggleKeyboard();
- abstract void onTouchPointerToggleKeyboard();
+ abstract void onTouchPointerToggleExtKeyboard();
- abstract void onTouchPointerToggleExtKeyboard();
+ abstract void onTouchPointerResetScrollZoom();
+ }
- abstract void onTouchPointerResetScrollZoom();
- }
+ private class UIHandler extends Handler
+ {
- private class UIHandler extends Handler {
+ UIHandler()
+ {
+ super();
+ }
- UIHandler() {
- super();
- }
+ @Override public void handleMessage(Message msg)
+ {
+ setPointerImage(R.drawable.touch_pointer_default);
+ }
+ }
- @Override
- public void handleMessage(Message msg) {
- setPointerImage(R.drawable.touch_pointer_default);
- }
- }
+ private class TouchPointerGestureListener extends GestureDetector.SimpleOnGestureListener
+ {
- private class TouchPointerGestureListener extends GestureDetector.SimpleOnGestureListener {
+ private MotionEvent prevEvent = null;
- private MotionEvent prevEvent = null;
+ public boolean onDown(MotionEvent e)
+ {
+ if (pointerAreaTouched(e, POINTER_ACTION_MOVE))
+ {
+ prevEvent = MotionEvent.obtain(e);
+ pointerMoving = true;
+ }
+ else if (pointerAreaTouched(e, POINTER_ACTION_SCROLL))
+ {
+ prevEvent = MotionEvent.obtain(e);
+ pointerScrolling = true;
+ setPointerImage(R.drawable.touch_pointer_scroll);
+ }
- public boolean onDown(MotionEvent e) {
- if (pointerAreaTouched(e, POINTER_ACTION_MOVE)) {
- prevEvent = MotionEvent.obtain(e);
- pointerMoving = true;
- } else if (pointerAreaTouched(e, POINTER_ACTION_SCROLL)) {
- prevEvent = MotionEvent.obtain(e);
- pointerScrolling = true;
- setPointerImage(R.drawable.touch_pointer_scroll);
- }
+ return true;
+ }
- return true;
- }
+ public boolean onUp(MotionEvent e)
+ {
+ if (prevEvent != null)
+ {
+ prevEvent.recycle();
+ prevEvent = null;
+ }
- public boolean onUp(MotionEvent e) {
- if (prevEvent != null) {
- prevEvent.recycle();
- prevEvent = null;
- }
+ if (pointerScrolling)
+ setPointerImage(R.drawable.touch_pointer_default);
- if (pointerScrolling)
- setPointerImage(R.drawable.touch_pointer_default);
+ pointerMoving = false;
+ pointerScrolling = false;
+ return true;
+ }
- pointerMoving = false;
- pointerScrolling = false;
- return true;
- }
+ public void onLongPress(MotionEvent e)
+ {
+ if (pointerAreaTouched(e, POINTER_ACTION_LCLICK))
+ {
+ setPointerImage(R.drawable.touch_pointer_active);
+ pointerMoving = true;
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
+ }
+ }
- public void onLongPress(MotionEvent e) {
- if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
- setPointerImage(R.drawable.touch_pointer_active);
- pointerMoving = true;
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
- }
- }
+ public void onLongPressUp(MotionEvent e)
+ {
+ if (pointerMoving)
+ {
+ setPointerImage(R.drawable.touch_pointer_default);
+ pointerMoving = false;
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
+ }
+ }
- public void onLongPressUp(MotionEvent e) {
- if (pointerMoving) {
- setPointerImage(R.drawable.touch_pointer_default);
- pointerMoving = false;
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
- }
- }
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
+ {
+ if (pointerMoving)
+ {
+ // move pointer graphics
+ movePointer((int)(e2.getX() - prevEvent.getX()),
+ (int)(e2.getY() - prevEvent.getY()));
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
- public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
- if (pointerMoving) {
- // move pointer graphics
- movePointer((int) (e2.getX() - prevEvent.getX()), (int) (e2.getY() - prevEvent.getY()));
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
+ // send move notification
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerMove((int)rect.centerX(), (int)rect.centerY());
+ return true;
+ }
+ else if (pointerScrolling)
+ {
+ // calc if user scrolled up or down (or if any scrolling happened at all)
+ float deltaY = e2.getY() - prevEvent.getY();
+ if (deltaY > SCROLL_DELTA)
+ {
+ listener.onTouchPointerScroll(true);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
+ else if (deltaY < -SCROLL_DELTA)
+ {
+ listener.onTouchPointerScroll(false);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
+ return true;
+ }
+ return false;
+ }
- // send move notification
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerMove((int) rect.centerX(), (int) rect.centerY());
- return true;
- } else if (pointerScrolling) {
- // calc if user scrolled up or down (or if any scrolling happened at all)
- float deltaY = e2.getY() - prevEvent.getY();
- if (deltaY > SCROLL_DELTA) {
- listener.onTouchPointerScroll(true);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- } else if (deltaY < -SCROLL_DELTA) {
- listener.onTouchPointerScroll(false);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
- return true;
- }
- return false;
- }
+ public boolean onSingleTapUp(MotionEvent e)
+ {
+ // look what area got touched and fire actions accordingly
+ if (pointerAreaTouched(e, POINTER_ACTION_CLOSE))
+ listener.onTouchPointerClose();
+ else if (pointerAreaTouched(e, POINTER_ACTION_LCLICK))
+ {
+ displayPointerImageAction(R.drawable.touch_pointer_lclick);
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
+ }
+ else if (pointerAreaTouched(e, POINTER_ACTION_RCLICK))
+ {
+ displayPointerImageAction(R.drawable.touch_pointer_rclick);
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerRightClick((int)rect.centerX(), (int)rect.centerY(), true);
+ listener.onTouchPointerRightClick((int)rect.centerX(), (int)rect.centerY(), false);
+ }
+ else if (pointerAreaTouched(e, POINTER_ACTION_KEYBOARD))
+ {
+ displayPointerImageAction(R.drawable.touch_pointer_keyboard);
+ listener.onTouchPointerToggleKeyboard();
+ }
+ else if (pointerAreaTouched(e, POINTER_ACTION_EXTKEYBOARD))
+ {
+ displayPointerImageAction(R.drawable.touch_pointer_extkeyboard);
+ listener.onTouchPointerToggleExtKeyboard();
+ }
+ else if (pointerAreaTouched(e, POINTER_ACTION_RESET))
+ {
+ displayPointerImageAction(R.drawable.touch_pointer_reset);
+ listener.onTouchPointerResetScrollZoom();
+ }
- public boolean onSingleTapUp(MotionEvent e) {
- // look what area got touched and fire actions accordingly
- if (pointerAreaTouched(e, POINTER_ACTION_CLOSE))
- listener.onTouchPointerClose();
- else if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
- displayPointerImageAction(R.drawable.touch_pointer_lclick);
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
- } else if (pointerAreaTouched(e, POINTER_ACTION_RCLICK)) {
- displayPointerImageAction(R.drawable.touch_pointer_rclick);
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerRightClick((int) rect.centerX(), (int) rect.centerY(), true);
- listener.onTouchPointerRightClick((int) rect.centerX(), (int) rect.centerY(), false);
- } else if (pointerAreaTouched(e, POINTER_ACTION_KEYBOARD)) {
- displayPointerImageAction(R.drawable.touch_pointer_keyboard);
- listener.onTouchPointerToggleKeyboard();
- } else if (pointerAreaTouched(e, POINTER_ACTION_EXTKEYBOARD)) {
- displayPointerImageAction(R.drawable.touch_pointer_extkeyboard);
- listener.onTouchPointerToggleExtKeyboard();
- } else if (pointerAreaTouched(e, POINTER_ACTION_RESET)) {
- displayPointerImageAction(R.drawable.touch_pointer_reset);
- listener.onTouchPointerResetScrollZoom();
- }
+ return true;
+ }
- return true;
- }
-
- public boolean onDoubleTap(MotionEvent e) {
- // issue a double click notification if performed in center quadrant
- if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
- listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
- }
- return true;
- }
- }
+ public boolean onDoubleTap(MotionEvent e)
+ {
+ // issue a double click notification if performed in center quadrant
+ if (pointerAreaTouched(e, POINTER_ACTION_LCLICK))
+ {
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
+ listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
+ }
+ return true;
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java
index 5335ff507..d3ed7fe16 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java
@@ -3,13 +3,13 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
-
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
@@ -22,453 +22,596 @@ import com.freerdp.freerdpcore.domain.BookmarkBase;
import java.util.ArrayList;
-public abstract class BookmarkBaseGateway {
- private final static String TAG = "BookmarkBaseGateway";
- private SQLiteOpenHelper bookmarkDB;
-
- private static final String JOIN_PREFIX = "join_";
- private static final String KEY_BOOKMARK_ID = "bookmarkId";
- private static final String KEY_SCREEN_COLORS = "screenColors";
- private static final String KEY_SCREEN_COLORS_3G = "screenColors3G";
- private static final String KEY_SCREEN_RESOLUTION = "screenResolution";
- private static final String KEY_SCREEN_RESOLUTION_3G = "screenResolution3G";
- private static final String KEY_SCREEN_WIDTH = "screenWidth";
- private static final String KEY_SCREEN_WIDTH_3G = "screenWidth3G";
- private static final String KEY_SCREEN_HEIGHT = "screenHeight";
- private static final String KEY_SCREEN_HEIGHT_3G = "screenHeight3G";
-
- private static final String KEY_PERFORMANCE_RFX = "performanceRemoteFX";
- private static final String KEY_PERFORMANCE_RFX_3G = "performanceRemoteFX3G";
- private static final String KEY_PERFORMANCE_GFX = "performanceGfx";
- private static final String KEY_PERFORMANCE_GFX_3G = "performanceGfx3G";
- private static final String KEY_PERFORMANCE_H264 = "performanceGfxH264";
- private static final String KEY_PERFORMANCE_H264_3G = "performanceGfxH2643G";
- private static final String KEY_PERFORMANCE_WALLPAPER = "performanceWallpaper";
- private static final String KEY_PERFORMANCE_WALLPAPER_3G = "performanceWallpaper3G";
- private static final String KEY_PERFORMANCE_THEME = "performanceTheming";
- private static final String KEY_PERFORMANCE_THEME_3G = "performanceTheming3G";
-
- private static final String KEY_PERFORMANCE_DRAG = "performanceFullWindowDrag";
- private static final String KEY_PERFORMANCE_DRAG_3G = "performanceFullWindowDrag3G";
- private static final String KEY_PERFORMANCE_MENU_ANIMATIONS = "performanceMenuAnimations";
- private static final String KEY_PERFORMANCE_MENU_ANIMATIONS_3G = "performanceMenuAnimations3G";
- private static final String KEY_PERFORMANCE_FONTS = "performanceFontSmoothing";
- private static final String KEY_PERFORMANCE_FONTS_3G = "performanceFontSmoothing3G";
- private static final String KEY_PERFORMANCE_COMPOSITION = "performanceDesktopComposition";
- private static final String KEY_PERFORMANCE_COMPOSITION_3G = "performanceDesktopComposition3G";
-
- public BookmarkBaseGateway(SQLiteOpenHelper bookmarkDB) {
- this.bookmarkDB = bookmarkDB;
- }
-
- protected abstract BookmarkBase createBookmark();
-
- protected abstract String getBookmarkTableName();
-
- protected abstract void addBookmarkSpecificColumns(ArrayList columns);
-
- protected abstract void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns);
-
- protected abstract void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor);
-
- public void insert(BookmarkBase bookmark) {
- // begin transaction
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- long rowid;
- ContentValues values = new ContentValues();
- values.put(BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
- // insert screen and performance settings
- rowid = insertScreenSettings(db, bookmark.getScreenSettings());
- values.put(BookmarkDB.DB_KEY_SCREEN_SETTINGS, rowid);
- rowid = insertPerformanceFlags(db, bookmark.getPerformanceFlags());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_FLAGS, rowid);
-
- // advanced settings
- values.put(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE, bookmark.getAdvancedSettings().getEnable3GSettings());
- // insert 3G screen and 3G performance settings
- rowid = insertScreenSettings(db, bookmark.getAdvancedSettings().getScreen3G());
- values.put(BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G, rowid);
- rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G, rowid);
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD, bookmark.getAdvancedSettings().getRedirectSDCard());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND, bookmark.getAdvancedSettings().getRedirectSound());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE, bookmark.getAdvancedSettings().getRedirectMicrophone());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_SECURITY, bookmark.getAdvancedSettings().getSecurity());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE, bookmark.getAdvancedSettings().getConsoleMode());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM, bookmark.getAdvancedSettings().getRemoteProgram());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR, bookmark.getAdvancedSettings().getWorkDir());
-
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL, bookmark.getDebugSettings().getAsyncChannel());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT, bookmark.getDebugSettings().getAsyncInput());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE, bookmark.getDebugSettings().getAsyncUpdate());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL, bookmark.getDebugSettings().getDebugLevel());
-
- // add any special columns
- addBookmarkSpecificColumns(bookmark, values);
-
- // insert bookmark and end transaction
- db.insertOrThrow(getBookmarkTableName(), null, values);
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public boolean update(BookmarkBase bookmark) {
- // start a transaction
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- // bookmark settings
- ContentValues values = new ContentValues();
- values.put(BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
- // update screen and performance settings settings
- updateScreenSettings(db, bookmark);
- updatePerformanceFlags(db, bookmark);
-
- // advanced settings
- values.put(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE, bookmark.getAdvancedSettings().getEnable3GSettings());
- // update 3G screen and 3G performance settings settings
- updateScreenSettings3G(db, bookmark);
- updatePerformanceFlags3G(db, bookmark);
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD, bookmark.getAdvancedSettings().getRedirectSDCard());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND, bookmark.getAdvancedSettings().getRedirectSound());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE, bookmark.getAdvancedSettings().getRedirectMicrophone());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_SECURITY, bookmark.getAdvancedSettings().getSecurity());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE, bookmark.getAdvancedSettings().getConsoleMode());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM, bookmark.getAdvancedSettings().getRemoteProgram());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR, bookmark.getAdvancedSettings().getWorkDir());
-
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL, bookmark.getDebugSettings().getAsyncChannel());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT, bookmark.getDebugSettings().getAsyncInput());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE, bookmark.getDebugSettings().getAsyncUpdate());
- values.put(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL, bookmark.getDebugSettings().getDebugLevel());
-
- addBookmarkSpecificColumns(bookmark, values);
-
- // update bookmark
- boolean res = (db.update(getBookmarkTableName(), values, BookmarkDB.ID + " = " + bookmark.getId(), null) == 1);
-
- // commit
- db.setTransactionSuccessful();
- db.endTransaction();
-
- return res;
- }
-
- public void delete(long id) {
- SQLiteDatabase db = getWritableDatabase();
- db.delete(getBookmarkTableName(), BookmarkDB.ID + " = " + id, null);
- }
-
- public BookmarkBase findById(long id) {
- Cursor cursor = queryBookmarks(getBookmarkTableName() + "." + BookmarkDB.ID + " = " + id, null);
- if (cursor.getCount() == 0) {
- cursor.close();
- return null;
- }
-
- cursor.moveToFirst();
- BookmarkBase bookmark = getBookmarkFromCursor(cursor);
- cursor.close();
- return bookmark;
- }
-
- public BookmarkBase findByLabel(String label) {
- Cursor cursor = queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " = '" + label + "'", BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- if (cursor.getCount() > 1)
- Log.e(TAG, "More than one bookmark with the same label found!");
-
- BookmarkBase bookmark = null;
- if (cursor.moveToFirst() && (cursor.getCount() > 0))
- bookmark = getBookmarkFromCursor(cursor);
-
- cursor.close();
- return bookmark;
- }
-
- public ArrayList findByLabelLike(String pattern) {
- Cursor cursor = queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " LIKE '%" + pattern + "%'", BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- ArrayList bookmarks = new ArrayList(cursor.getCount());
-
- if (cursor.moveToFirst() && (cursor.getCount() > 0)) {
- do {
- bookmarks.add(getBookmarkFromCursor(cursor));
- } while (cursor.moveToNext());
- }
-
- cursor.close();
- return bookmarks;
- }
-
- public ArrayList findAll() {
- Cursor cursor = queryBookmarks(null, BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- final int count = cursor.getCount();
- ArrayList bookmarks = new ArrayList<>(count);
-
- if (cursor.moveToFirst() && (count > 0)) {
- do {
- bookmarks.add(getBookmarkFromCursor(cursor));
- } while (cursor.moveToNext());
- }
-
- cursor.close();
- return bookmarks;
- }
-
- protected Cursor queryBookmarks(String whereClause, String orderBy) {
- // create tables string
- final String ID = BookmarkDB.ID;
- final String tables = BookmarkDB.DB_TABLE_BOOKMARK + " INNER JOIN " +
- BookmarkDB.DB_TABLE_SCREEN + " AS " + JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + " ON " + JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." +
- ID + " = " + BookmarkDB.DB_TABLE_BOOKMARK + "." + BookmarkDB.DB_KEY_SCREEN_SETTINGS +
- " INNER JOIN " + BookmarkDB.DB_TABLE_PERFORMANCE +
- " AS " + JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + " ON " + JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + ID + " = " +
- BookmarkDB.DB_TABLE_BOOKMARK + "." + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
- " INNER JOIN " + BookmarkDB.DB_TABLE_SCREEN +
- " AS " + JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + " ON " + JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + ID + " = " +
- BookmarkDB.DB_TABLE_BOOKMARK + "." + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
- " INNER JOIN " + BookmarkDB.DB_TABLE_PERFORMANCE +
- " AS " + JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + " ON " + JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + ID + " = " +
- BookmarkDB.DB_TABLE_BOOKMARK + "." + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G;
-
- // create columns list
- ArrayList columns = new ArrayList<>();
- addBookmarkColumns(columns);
- addScreenSettingsColumns(columns);
- addPerformanceFlagsColumns(columns);
- addScreenSettings3GColumns(columns);
- addPerformanceFlags3GColumns(columns);
-
- String[] cols = new String[columns.size()];
- columns.toArray(cols);
-
- SQLiteDatabase db = getReadableDatabase();
- final String query = SQLiteQueryBuilder.buildQueryString(false, tables, cols, whereClause, null, null, orderBy, null);
- return db.rawQuery(query, null);
- }
-
- private void addBookmarkColumns(ArrayList columns) {
- columns.add(getBookmarkTableName() + "." + BookmarkDB.ID + " " + KEY_BOOKMARK_ID);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_USERNAME);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN);
-
- // advanced settings
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_SECURITY);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR);
-
- // debug settings
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT);
-
- addBookmarkSpecificColumns(columns);
- }
-
- private void addScreenSettingsColumns(ArrayList columns) {
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." + BookmarkDB.DB_KEY_SCREEN_COLORS + " as " + KEY_SCREEN_COLORS);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." + BookmarkDB.DB_KEY_SCREEN_RESOLUTION + " as " + KEY_SCREEN_RESOLUTION);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." + BookmarkDB.DB_KEY_SCREEN_WIDTH + " as " + KEY_SCREEN_WIDTH);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." + BookmarkDB.DB_KEY_SCREEN_HEIGHT + " as " + KEY_SCREEN_HEIGHT);
- }
-
- private void addPerformanceFlagsColumns(ArrayList columns) {
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_RFX + " as " + KEY_PERFORMANCE_RFX);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_GFX + " as " + KEY_PERFORMANCE_GFX);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_H264 + " as " + KEY_PERFORMANCE_H264);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER + " as " + KEY_PERFORMANCE_WALLPAPER);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_THEME + " as " + KEY_PERFORMANCE_THEME);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_DRAG + " as " + KEY_PERFORMANCE_DRAG);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS + " as " + KEY_PERFORMANCE_MENU_ANIMATIONS);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_FONTS + " as " + KEY_PERFORMANCE_FONTS);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION + " " + KEY_PERFORMANCE_COMPOSITION);
- }
-
- private void addScreenSettings3GColumns(ArrayList columns) {
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + BookmarkDB.DB_KEY_SCREEN_COLORS + " as " + KEY_SCREEN_COLORS_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + BookmarkDB.DB_KEY_SCREEN_RESOLUTION + " as " + KEY_SCREEN_RESOLUTION_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + BookmarkDB.DB_KEY_SCREEN_WIDTH + " as " + KEY_SCREEN_WIDTH_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + BookmarkDB.DB_KEY_SCREEN_HEIGHT + " as " + KEY_SCREEN_HEIGHT_3G);
- }
-
- private void addPerformanceFlags3GColumns(ArrayList columns) {
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_RFX + " as " + KEY_PERFORMANCE_RFX_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_GFX + " as " + KEY_PERFORMANCE_GFX_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_H264 + " as " + KEY_PERFORMANCE_H264_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER + " as " + KEY_PERFORMANCE_WALLPAPER_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_THEME + " as " + KEY_PERFORMANCE_THEME_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_DRAG + " as " + KEY_PERFORMANCE_DRAG_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS + " as " + KEY_PERFORMANCE_MENU_ANIMATIONS_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_FONTS + " as " + KEY_PERFORMANCE_FONTS_3G);
- columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION + " " + KEY_PERFORMANCE_COMPOSITION_3G);
- }
-
- protected BookmarkBase getBookmarkFromCursor(Cursor cursor) {
- BookmarkBase bookmark = createBookmark();
- bookmark.setId(cursor.getLong(cursor.getColumnIndex(KEY_BOOKMARK_ID)));
- bookmark.setLabel(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_LABEL)));
- bookmark.setUsername(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_USERNAME)));
- bookmark.setPassword(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD)));
- bookmark.setDomain(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN)));
- readScreenSettings(bookmark, cursor);
- readPerformanceFlags(bookmark, cursor);
-
- // advanced settings
- bookmark.getAdvancedSettings().setEnable3GSettings(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE)) != 0);
- readScreenSettings3G(bookmark, cursor);
- readPerformanceFlags3G(bookmark, cursor);
- bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD)) != 0);
- bookmark.getAdvancedSettings().setRedirectSound(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND)));
- bookmark.getAdvancedSettings().setRedirectMicrophone(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE)) != 0);
- bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_SECURITY)));
- bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE)) != 0);
- bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM)));
- bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR)));
-
- bookmark.getDebugSettings().setAsyncChannel(
- cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL)) == 1);
- bookmark.getDebugSettings().setAsyncInput(
- cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT)) == 1);
- bookmark.getDebugSettings().setAsyncUpdate(
- cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE)) == 1);
- bookmark.getDebugSettings().setDebugLevel(cursor.getString(cursor.getColumnIndex
- (BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL)));
-
- readBookmarkSpecificColumns(bookmark, cursor);
-
- return bookmark;
- }
-
- private void readScreenSettings(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.ScreenSettings screenSettings = bookmark.getScreenSettings();
- screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS)));
- screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION)));
- screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH)));
- screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT)));
- }
-
- private void readPerformanceFlags(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.PerformanceFlags perfFlags = bookmark.getPerformanceFlags();
- perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX)) != 0);
- perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX)) != 0);
- perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264)) != 0);
- perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER)) != 0);
- perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME)) != 0);
- perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG)) != 0);
- perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS)) != 0);
- perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS)) != 0);
- perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION)) != 0);
- }
-
- private void readScreenSettings3G(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.ScreenSettings screenSettings = bookmark.getAdvancedSettings().getScreen3G();
- screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS_3G)));
- screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION_3G)));
- screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH_3G)));
- screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT_3G)));
- }
-
- private void readPerformanceFlags3G(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.PerformanceFlags perfFlags = bookmark.getAdvancedSettings().getPerformance3G();
- perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX_3G)) != 0);
- perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX_3G)) != 0);
- perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264_3G)) != 0);
- perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER_3G)) != 0);
- perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME_3G)) != 0);
- perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG_3G)) != 0);
- perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS_3G)) != 0);
- perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS_3G)) != 0);
- perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION_3G)) != 0);
- }
-
- private void fillScreenSettingsContentValues(BookmarkBase.ScreenSettings settings, ContentValues values) {
- values.put(BookmarkDB.DB_KEY_SCREEN_COLORS, settings.getColors());
- values.put(BookmarkDB.DB_KEY_SCREEN_RESOLUTION, settings.getResolution());
- values.put(BookmarkDB.DB_KEY_SCREEN_WIDTH, settings.getWidth());
- values.put(BookmarkDB.DB_KEY_SCREEN_HEIGHT, settings.getHeight());
- }
-
- private void fillPerformanceFlagsContentValues(BookmarkBase.PerformanceFlags perfFlags, ContentValues values) {
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_RFX, perfFlags.getRemoteFX());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_GFX, perfFlags.getGfx());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_H264, perfFlags.getH264());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER, perfFlags.getWallpaper());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_THEME, perfFlags.getTheming());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_DRAG, perfFlags.getFullWindowDrag());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS, perfFlags.getMenuAnimations());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_FONTS, perfFlags.getFontSmoothing());
- values.put(BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION, perfFlags.getDesktopComposition());
- }
-
- private long insertScreenSettings(SQLiteDatabase db, BookmarkBase.ScreenSettings settings) {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(settings, values);
- return db.insertOrThrow(BookmarkDB.DB_TABLE_SCREEN, null, values);
- }
-
- private boolean updateScreenSettings(SQLiteDatabase db, BookmarkBase bookmark) {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(bookmark.getScreenSettings(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT " + BookmarkDB.DB_KEY_SCREEN_SETTINGS + " FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update(BookmarkDB.DB_TABLE_SCREEN, values, whereClause, null) == 1);
- }
-
- private boolean updateScreenSettings3G(SQLiteDatabase db, BookmarkBase bookmark) {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(bookmark.getAdvancedSettings().getScreen3G(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT " + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + " FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update(BookmarkDB.DB_TABLE_SCREEN, values, whereClause, null) == 1);
- }
-
- private long insertPerformanceFlags(SQLiteDatabase db, BookmarkBase.PerformanceFlags perfFlags) {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(perfFlags, values);
- return db.insertOrThrow(BookmarkDB.DB_TABLE_PERFORMANCE, null, values);
- }
-
- private boolean updatePerformanceFlags(SQLiteDatabase db, BookmarkBase bookmark) {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(bookmark.getPerformanceFlags(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT " + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + " FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update(BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause, null) == 1);
- }
-
- private boolean updatePerformanceFlags3G(SQLiteDatabase db, BookmarkBase bookmark) {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(bookmark.getAdvancedSettings().getPerformance3G(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT " + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + " FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update(BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause, null) == 1);
- }
-
- // safety wrappers
- // in case of getReadableDatabase it could happen that upgradeDB gets called which is
- // a problem if the DB is only readable
- private SQLiteDatabase getWritableDatabase() {
- return bookmarkDB.getWritableDatabase();
- }
-
- private SQLiteDatabase getReadableDatabase() {
- SQLiteDatabase db;
- try {
- db = bookmarkDB.getReadableDatabase();
- } catch (SQLiteException e) {
- db = bookmarkDB.getWritableDatabase();
- }
- return db;
- }
+public abstract class BookmarkBaseGateway
+{
+ private final static String TAG = "BookmarkBaseGateway";
+ private SQLiteOpenHelper bookmarkDB;
+
+ private static final String JOIN_PREFIX = "join_";
+ private static final String KEY_BOOKMARK_ID = "bookmarkId";
+ private static final String KEY_SCREEN_COLORS = "screenColors";
+ private static final String KEY_SCREEN_COLORS_3G = "screenColors3G";
+ private static final String KEY_SCREEN_RESOLUTION = "screenResolution";
+ private static final String KEY_SCREEN_RESOLUTION_3G = "screenResolution3G";
+ private static final String KEY_SCREEN_WIDTH = "screenWidth";
+ private static final String KEY_SCREEN_WIDTH_3G = "screenWidth3G";
+ private static final String KEY_SCREEN_HEIGHT = "screenHeight";
+ private static final String KEY_SCREEN_HEIGHT_3G = "screenHeight3G";
+
+ private static final String KEY_PERFORMANCE_RFX = "performanceRemoteFX";
+ private static final String KEY_PERFORMANCE_RFX_3G = "performanceRemoteFX3G";
+ private static final String KEY_PERFORMANCE_GFX = "performanceGfx";
+ private static final String KEY_PERFORMANCE_GFX_3G = "performanceGfx3G";
+ private static final String KEY_PERFORMANCE_H264 = "performanceGfxH264";
+ private static final String KEY_PERFORMANCE_H264_3G = "performanceGfxH2643G";
+ private static final String KEY_PERFORMANCE_WALLPAPER = "performanceWallpaper";
+ private static final String KEY_PERFORMANCE_WALLPAPER_3G = "performanceWallpaper3G";
+ private static final String KEY_PERFORMANCE_THEME = "performanceTheming";
+ private static final String KEY_PERFORMANCE_THEME_3G = "performanceTheming3G";
+
+ private static final String KEY_PERFORMANCE_DRAG = "performanceFullWindowDrag";
+ private static final String KEY_PERFORMANCE_DRAG_3G = "performanceFullWindowDrag3G";
+ private static final String KEY_PERFORMANCE_MENU_ANIMATIONS = "performanceMenuAnimations";
+ private static final String KEY_PERFORMANCE_MENU_ANIMATIONS_3G = "performanceMenuAnimations3G";
+ private static final String KEY_PERFORMANCE_FONTS = "performanceFontSmoothing";
+ private static final String KEY_PERFORMANCE_FONTS_3G = "performanceFontSmoothing3G";
+ private static final String KEY_PERFORMANCE_COMPOSITION = "performanceDesktopComposition";
+ private static final String KEY_PERFORMANCE_COMPOSITION_3G = "performanceDesktopComposition3G";
+
+ public BookmarkBaseGateway(SQLiteOpenHelper bookmarkDB)
+ {
+ this.bookmarkDB = bookmarkDB;
+ }
+
+ protected abstract BookmarkBase createBookmark();
+
+ protected abstract String getBookmarkTableName();
+
+ protected abstract void addBookmarkSpecificColumns(ArrayList columns);
+
+ protected abstract void addBookmarkSpecificColumns(BookmarkBase bookmark,
+ ContentValues columns);
+
+ protected abstract void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor);
+
+ public void insert(BookmarkBase bookmark)
+ {
+ // begin transaction
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ long rowid;
+ ContentValues values = new ContentValues();
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
+ // insert screen and performance settings
+ rowid = insertScreenSettings(db, bookmark.getScreenSettings());
+ values.put(BookmarkDB.DB_KEY_SCREEN_SETTINGS, rowid);
+ rowid = insertPerformanceFlags(db, bookmark.getPerformanceFlags());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_FLAGS, rowid);
+
+ // advanced settings
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE,
+ bookmark.getAdvancedSettings().getEnable3GSettings());
+ // insert 3G screen and 3G performance settings
+ rowid = insertScreenSettings(db, bookmark.getAdvancedSettings().getScreen3G());
+ values.put(BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G, rowid);
+ rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G, rowid);
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD,
+ bookmark.getAdvancedSettings().getRedirectSDCard());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND,
+ bookmark.getAdvancedSettings().getRedirectSound());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE,
+ bookmark.getAdvancedSettings().getRedirectMicrophone());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_SECURITY,
+ bookmark.getAdvancedSettings().getSecurity());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE,
+ bookmark.getAdvancedSettings().getConsoleMode());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM,
+ bookmark.getAdvancedSettings().getRemoteProgram());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR,
+ bookmark.getAdvancedSettings().getWorkDir());
+
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL,
+ bookmark.getDebugSettings().getAsyncChannel());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT,
+ bookmark.getDebugSettings().getAsyncInput());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE,
+ bookmark.getDebugSettings().getAsyncUpdate());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL,
+ bookmark.getDebugSettings().getDebugLevel());
+
+ // add any special columns
+ addBookmarkSpecificColumns(bookmark, values);
+
+ // insert bookmark and end transaction
+ db.insertOrThrow(getBookmarkTableName(), null, values);
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public boolean update(BookmarkBase bookmark)
+ {
+ // start a transaction
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ // bookmark settings
+ ContentValues values = new ContentValues();
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
+ // update screen and performance settings settings
+ updateScreenSettings(db, bookmark);
+ updatePerformanceFlags(db, bookmark);
+
+ // advanced settings
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE,
+ bookmark.getAdvancedSettings().getEnable3GSettings());
+ // update 3G screen and 3G performance settings settings
+ updateScreenSettings3G(db, bookmark);
+ updatePerformanceFlags3G(db, bookmark);
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD,
+ bookmark.getAdvancedSettings().getRedirectSDCard());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND,
+ bookmark.getAdvancedSettings().getRedirectSound());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE,
+ bookmark.getAdvancedSettings().getRedirectMicrophone());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_SECURITY,
+ bookmark.getAdvancedSettings().getSecurity());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE,
+ bookmark.getAdvancedSettings().getConsoleMode());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM,
+ bookmark.getAdvancedSettings().getRemoteProgram());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR,
+ bookmark.getAdvancedSettings().getWorkDir());
+
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL,
+ bookmark.getDebugSettings().getAsyncChannel());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT,
+ bookmark.getDebugSettings().getAsyncInput());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE,
+ bookmark.getDebugSettings().getAsyncUpdate());
+ values.put(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL,
+ bookmark.getDebugSettings().getDebugLevel());
+
+ addBookmarkSpecificColumns(bookmark, values);
+
+ // update bookmark
+ boolean res = (db.update(getBookmarkTableName(), values,
+ BookmarkDB.ID + " = " + bookmark.getId(), null) == 1);
+
+ // commit
+ db.setTransactionSuccessful();
+ db.endTransaction();
+
+ return res;
+ }
+
+ public void delete(long id)
+ {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(getBookmarkTableName(), BookmarkDB.ID + " = " + id, null);
+ }
+
+ public BookmarkBase findById(long id)
+ {
+ Cursor cursor =
+ queryBookmarks(getBookmarkTableName() + "." + BookmarkDB.ID + " = " + id, null);
+ if (cursor.getCount() == 0)
+ {
+ cursor.close();
+ return null;
+ }
+
+ cursor.moveToFirst();
+ BookmarkBase bookmark = getBookmarkFromCursor(cursor);
+ cursor.close();
+ return bookmark;
+ }
+
+ public BookmarkBase findByLabel(String label)
+ {
+ Cursor cursor = queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " = '" + label + "'",
+ BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ if (cursor.getCount() > 1)
+ Log.e(TAG, "More than one bookmark with the same label found!");
+
+ BookmarkBase bookmark = null;
+ if (cursor.moveToFirst() && (cursor.getCount() > 0))
+ bookmark = getBookmarkFromCursor(cursor);
+
+ cursor.close();
+ return bookmark;
+ }
+
+ public ArrayList findByLabelLike(String pattern)
+ {
+ Cursor cursor =
+ queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " LIKE '%" + pattern + "%'",
+ BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ ArrayList bookmarks = new ArrayList(cursor.getCount());
+
+ if (cursor.moveToFirst() && (cursor.getCount() > 0))
+ {
+ do
+ {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
+
+ cursor.close();
+ return bookmarks;
+ }
+
+ public ArrayList findAll()
+ {
+ Cursor cursor = queryBookmarks(null, BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ final int count = cursor.getCount();
+ ArrayList bookmarks = new ArrayList<>(count);
+
+ if (cursor.moveToFirst() && (count > 0))
+ {
+ do
+ {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
+
+ cursor.close();
+ return bookmarks;
+ }
+
+ protected Cursor queryBookmarks(String whereClause, String orderBy)
+ {
+ // create tables string
+ final String ID = BookmarkDB.ID;
+ final String tables =
+ BookmarkDB.DB_TABLE_BOOKMARK + " INNER JOIN " + BookmarkDB.DB_TABLE_SCREEN + " AS " +
+ JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + " ON " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." + ID + " = " + BookmarkDB.DB_TABLE_BOOKMARK +
+ "." + BookmarkDB.DB_KEY_SCREEN_SETTINGS + " INNER JOIN " +
+ BookmarkDB.DB_TABLE_PERFORMANCE + " AS " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + " ON " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." + ID + " = " + BookmarkDB.DB_TABLE_BOOKMARK +
+ "." + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + " INNER JOIN " +
+ BookmarkDB.DB_TABLE_SCREEN + " AS " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + " ON " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." + ID + " = " + BookmarkDB.DB_TABLE_BOOKMARK +
+ "." + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + " INNER JOIN " +
+ BookmarkDB.DB_TABLE_PERFORMANCE + " AS " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + " ON " + JOIN_PREFIX +
+ BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." + ID + " = " +
+ BookmarkDB.DB_TABLE_BOOKMARK + "." + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G;
+
+ // create columns list
+ ArrayList columns = new ArrayList<>();
+ addBookmarkColumns(columns);
+ addScreenSettingsColumns(columns);
+ addPerformanceFlagsColumns(columns);
+ addScreenSettings3GColumns(columns);
+ addPerformanceFlags3GColumns(columns);
+
+ String[] cols = new String[columns.size()];
+ columns.toArray(cols);
+
+ SQLiteDatabase db = getReadableDatabase();
+ final String query = SQLiteQueryBuilder.buildQueryString(false, tables, cols, whereClause,
+ null, null, orderBy, null);
+ return db.rawQuery(query, null);
+ }
+
+ private void addBookmarkColumns(ArrayList columns)
+ {
+ columns.add(getBookmarkTableName() + "." + BookmarkDB.ID + " " + KEY_BOOKMARK_ID);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_USERNAME);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN);
+
+ // advanced settings
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_SECURITY);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR);
+
+ // debug settings
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT);
+
+ addBookmarkSpecificColumns(columns);
+ }
+
+ private void addScreenSettingsColumns(ArrayList columns)
+ {
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." +
+ BookmarkDB.DB_KEY_SCREEN_COLORS + " as " + KEY_SCREEN_COLORS);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." +
+ BookmarkDB.DB_KEY_SCREEN_RESOLUTION + " as " + KEY_SCREEN_RESOLUTION);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." +
+ BookmarkDB.DB_KEY_SCREEN_WIDTH + " as " + KEY_SCREEN_WIDTH);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS + "." +
+ BookmarkDB.DB_KEY_SCREEN_HEIGHT + " as " + KEY_SCREEN_HEIGHT);
+ }
+
+ private void addPerformanceFlagsColumns(ArrayList columns)
+ {
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_RFX + " as " + KEY_PERFORMANCE_RFX);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_GFX + " as " + KEY_PERFORMANCE_GFX);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_H264 + " as " + KEY_PERFORMANCE_H264);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER + " as " + KEY_PERFORMANCE_WALLPAPER);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_THEME + " as " + KEY_PERFORMANCE_THEME);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_DRAG + " as " + KEY_PERFORMANCE_DRAG);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS + " as " +
+ KEY_PERFORMANCE_MENU_ANIMATIONS);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_FONTS + " as " + KEY_PERFORMANCE_FONTS);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION + " " + KEY_PERFORMANCE_COMPOSITION);
+ }
+
+ private void addScreenSettings3GColumns(ArrayList columns)
+ {
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." +
+ BookmarkDB.DB_KEY_SCREEN_COLORS + " as " + KEY_SCREEN_COLORS_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." +
+ BookmarkDB.DB_KEY_SCREEN_RESOLUTION + " as " + KEY_SCREEN_RESOLUTION_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." +
+ BookmarkDB.DB_KEY_SCREEN_WIDTH + " as " + KEY_SCREEN_WIDTH_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + "." +
+ BookmarkDB.DB_KEY_SCREEN_HEIGHT + " as " + KEY_SCREEN_HEIGHT_3G);
+ }
+
+ private void addPerformanceFlags3GColumns(ArrayList columns)
+ {
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_RFX + " as " + KEY_PERFORMANCE_RFX_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_GFX + " as " + KEY_PERFORMANCE_GFX_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_H264 + " as " + KEY_PERFORMANCE_H264_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER + " as " +
+ KEY_PERFORMANCE_WALLPAPER_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_THEME + " as " + KEY_PERFORMANCE_THEME_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_DRAG + " as " + KEY_PERFORMANCE_DRAG_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS + " as " +
+ KEY_PERFORMANCE_MENU_ANIMATIONS_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_FONTS + " as " + KEY_PERFORMANCE_FONTS_3G);
+ columns.add(JOIN_PREFIX + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + "." +
+ BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION + " " +
+ KEY_PERFORMANCE_COMPOSITION_3G);
+ }
+
+ protected BookmarkBase getBookmarkFromCursor(Cursor cursor)
+ {
+ BookmarkBase bookmark = createBookmark();
+ bookmark.setId(cursor.getLong(cursor.getColumnIndex(KEY_BOOKMARK_ID)));
+ bookmark.setLabel(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_LABEL)));
+ bookmark.setUsername(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_USERNAME)));
+ bookmark.setPassword(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_PASSWORD)));
+ bookmark.setDomain(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_DOMAIN)));
+ readScreenSettings(bookmark, cursor);
+ readPerformanceFlags(bookmark, cursor);
+
+ // advanced settings
+ bookmark.getAdvancedSettings().setEnable3GSettings(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE)) != 0);
+ readScreenSettings3G(bookmark, cursor);
+ readPerformanceFlags3G(bookmark, cursor);
+ bookmark.getAdvancedSettings().setRedirectSDCard(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD)) != 0);
+ bookmark.getAdvancedSettings().setRedirectSound(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND)));
+ bookmark.getAdvancedSettings().setRedirectMicrophone(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE)) !=
+ 0);
+ bookmark.getAdvancedSettings().setSecurity(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_SECURITY)));
+ bookmark.getAdvancedSettings().setConsoleMode(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE)) != 0);
+ bookmark.getAdvancedSettings().setRemoteProgram(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM)));
+ bookmark.getAdvancedSettings().setWorkDir(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR)));
+
+ bookmark.getDebugSettings().setAsyncChannel(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL)) == 1);
+ bookmark.getDebugSettings().setAsyncInput(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_INPUT)) == 1);
+ bookmark.getDebugSettings().setAsyncUpdate(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE)) == 1);
+ bookmark.getDebugSettings().setDebugLevel(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL)));
+
+ readBookmarkSpecificColumns(bookmark, cursor);
+
+ return bookmark;
+ }
+
+ private void readScreenSettings(BookmarkBase bookmark, Cursor cursor)
+ {
+ BookmarkBase.ScreenSettings screenSettings = bookmark.getScreenSettings();
+ screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS)));
+ screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION)));
+ screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH)));
+ screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT)));
+ }
+
+ private void readPerformanceFlags(BookmarkBase bookmark, Cursor cursor)
+ {
+ BookmarkBase.PerformanceFlags perfFlags = bookmark.getPerformanceFlags();
+ perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX)) != 0);
+ perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX)) != 0);
+ perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264)) != 0);
+ perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER)) !=
+ 0);
+ perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME)) != 0);
+ perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG)) !=
+ 0);
+ perfFlags.setMenuAnimations(
+ cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS)) != 0);
+ perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS)) !=
+ 0);
+ perfFlags.setDesktopComposition(
+ cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION)) != 0);
+ }
+
+ private void readScreenSettings3G(BookmarkBase bookmark, Cursor cursor)
+ {
+ BookmarkBase.ScreenSettings screenSettings = bookmark.getAdvancedSettings().getScreen3G();
+ screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS_3G)));
+ screenSettings.setResolution(
+ cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION_3G)));
+ screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH_3G)));
+ screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT_3G)));
+ }
+
+ private void readPerformanceFlags3G(BookmarkBase bookmark, Cursor cursor)
+ {
+ BookmarkBase.PerformanceFlags perfFlags = bookmark.getAdvancedSettings().getPerformance3G();
+ perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX_3G)) != 0);
+ perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX_3G)) != 0);
+ perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264_3G)) != 0);
+ perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER_3G)) !=
+ 0);
+ perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME_3G)) != 0);
+ perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG_3G)) !=
+ 0);
+ perfFlags.setMenuAnimations(
+ cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS_3G)) != 0);
+ perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS_3G)) !=
+ 0);
+ perfFlags.setDesktopComposition(
+ cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION_3G)) != 0);
+ }
+
+ private void fillScreenSettingsContentValues(BookmarkBase.ScreenSettings settings,
+ ContentValues values)
+ {
+ values.put(BookmarkDB.DB_KEY_SCREEN_COLORS, settings.getColors());
+ values.put(BookmarkDB.DB_KEY_SCREEN_RESOLUTION, settings.getResolution());
+ values.put(BookmarkDB.DB_KEY_SCREEN_WIDTH, settings.getWidth());
+ values.put(BookmarkDB.DB_KEY_SCREEN_HEIGHT, settings.getHeight());
+ }
+
+ private void fillPerformanceFlagsContentValues(BookmarkBase.PerformanceFlags perfFlags,
+ ContentValues values)
+ {
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_RFX, perfFlags.getRemoteFX());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_GFX, perfFlags.getGfx());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_H264, perfFlags.getH264());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER, perfFlags.getWallpaper());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_THEME, perfFlags.getTheming());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_DRAG, perfFlags.getFullWindowDrag());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS, perfFlags.getMenuAnimations());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_FONTS, perfFlags.getFontSmoothing());
+ values.put(BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION, perfFlags.getDesktopComposition());
+ }
+
+ private long insertScreenSettings(SQLiteDatabase db, BookmarkBase.ScreenSettings settings)
+ {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(settings, values);
+ return db.insertOrThrow(BookmarkDB.DB_TABLE_SCREEN, null, values);
+ }
+
+ private boolean updateScreenSettings(SQLiteDatabase db, BookmarkBase bookmark)
+ {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(bookmark.getScreenSettings(), values);
+ String whereClause = BookmarkDB.ID + " IN "
+ + "(SELECT " + BookmarkDB.DB_KEY_SCREEN_SETTINGS + " FROM " +
+ getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " +
+ bookmark.getId() + ");";
+ return (db.update(BookmarkDB.DB_TABLE_SCREEN, values, whereClause, null) == 1);
+ }
+
+ private boolean updateScreenSettings3G(SQLiteDatabase db, BookmarkBase bookmark)
+ {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(bookmark.getAdvancedSettings().getScreen3G(), values);
+ String whereClause = BookmarkDB.ID + " IN "
+ + "(SELECT " + BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G + " FROM " +
+ getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " +
+ bookmark.getId() + ");";
+ return (db.update(BookmarkDB.DB_TABLE_SCREEN, values, whereClause, null) == 1);
+ }
+
+ private long insertPerformanceFlags(SQLiteDatabase db, BookmarkBase.PerformanceFlags perfFlags)
+ {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(perfFlags, values);
+ return db.insertOrThrow(BookmarkDB.DB_TABLE_PERFORMANCE, null, values);
+ }
+
+ private boolean updatePerformanceFlags(SQLiteDatabase db, BookmarkBase bookmark)
+ {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(bookmark.getPerformanceFlags(), values);
+ String whereClause = BookmarkDB.ID + " IN "
+ + "(SELECT " + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS + " FROM " +
+ getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " +
+ bookmark.getId() + ");";
+ return (db.update(BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause, null) == 1);
+ }
+
+ private boolean updatePerformanceFlags3G(SQLiteDatabase db, BookmarkBase bookmark)
+ {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(bookmark.getAdvancedSettings().getPerformance3G(),
+ values);
+ String whereClause = BookmarkDB.ID + " IN "
+ + "(SELECT " + BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G + " FROM " +
+ getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " +
+ bookmark.getId() + ");";
+ return (db.update(BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause, null) == 1);
+ }
+
+ // safety wrappers
+ // in case of getReadableDatabase it could happen that upgradeDB gets called which is
+ // a problem if the DB is only readable
+ private SQLiteDatabase getWritableDatabase()
+ {
+ return bookmarkDB.getWritableDatabase();
+ }
+
+ private SQLiteDatabase getReadableDatabase()
+ {
+ SQLiteDatabase db;
+ try
+ {
+ db = bookmarkDB.getReadableDatabase();
+ }
+ catch (SQLiteException e)
+ {
+ db = bookmarkDB.getWritableDatabase();
+ }
+ return db;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkDB.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkDB.java
index e2537d5a2..420e540ae 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkDB.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/BookmarkDB.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -21,371 +22,401 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class BookmarkDB extends SQLiteOpenHelper {
- public static final String ID = BaseColumns._ID;
- private static final int DB_VERSION = 9;
- private static final String DB_BACKUP_PREFIX = "temp_";
- private static final String DB_NAME = "bookmarks.db";
- static final String DB_TABLE_BOOKMARK = "tbl_manual_bookmarks";
- static final String DB_TABLE_SCREEN = "tbl_screen_settings";
- static final String DB_TABLE_PERFORMANCE = "tbl_performance_flags";
- private static final String[] DB_TABLES = {
- DB_TABLE_BOOKMARK,
- DB_TABLE_SCREEN,
- DB_TABLE_PERFORMANCE
- };
+public class BookmarkDB extends SQLiteOpenHelper
+{
+ public static final String ID = BaseColumns._ID;
+ private static final int DB_VERSION = 9;
+ private static final String DB_BACKUP_PREFIX = "temp_";
+ private static final String DB_NAME = "bookmarks.db";
+ static final String DB_TABLE_BOOKMARK = "tbl_manual_bookmarks";
+ static final String DB_TABLE_SCREEN = "tbl_screen_settings";
+ static final String DB_TABLE_PERFORMANCE = "tbl_performance_flags";
+ private static final String[] DB_TABLES = { DB_TABLE_BOOKMARK, DB_TABLE_SCREEN,
+ DB_TABLE_PERFORMANCE };
- static final String DB_KEY_SCREEN_COLORS = "colors";
- static final String DB_KEY_SCREEN_RESOLUTION = "resolution";
- static final String DB_KEY_SCREEN_WIDTH = "width";
- static final String DB_KEY_SCREEN_HEIGHT = "height";
+ static final String DB_KEY_SCREEN_COLORS = "colors";
+ static final String DB_KEY_SCREEN_RESOLUTION = "resolution";
+ static final String DB_KEY_SCREEN_WIDTH = "width";
+ static final String DB_KEY_SCREEN_HEIGHT = "height";
- static final String DB_KEY_SCREEN_SETTINGS = "screen_settings";
- static final String DB_KEY_SCREEN_SETTINGS_3G = "screen_3g";
- static final String DB_KEY_PERFORMANCE_FLAGS = "performance_flags";
- static final String DB_KEY_PERFORMANCE_FLAGS_3G = "performance_3g";
+ static final String DB_KEY_SCREEN_SETTINGS = "screen_settings";
+ static final String DB_KEY_SCREEN_SETTINGS_3G = "screen_3g";
+ static final String DB_KEY_PERFORMANCE_FLAGS = "performance_flags";
+ static final String DB_KEY_PERFORMANCE_FLAGS_3G = "performance_3g";
- static final String DB_KEY_PERFORMANCE_RFX = "perf_remotefx";
- static final String DB_KEY_PERFORMANCE_GFX = "perf_gfx";
- static final String DB_KEY_PERFORMANCE_H264 = "perf_gfx_h264";
- static final String DB_KEY_PERFORMANCE_WALLPAPER = "perf_wallpaper";
- static final String DB_KEY_PERFORMANCE_THEME = "perf_theming";
- static final String DB_KEY_PERFORMANCE_DRAG = "perf_full_window_drag";
- static final String DB_KEY_PERFORMANCE_MENU_ANIMATIONS = "perf_menu_animations";
- static final String DB_KEY_PERFORMANCE_FONTS = "perf_font_smoothing";
- static final String DB_KEY_PERFORMANCE_COMPOSITION = "perf_desktop_composition";
+ static final String DB_KEY_PERFORMANCE_RFX = "perf_remotefx";
+ static final String DB_KEY_PERFORMANCE_GFX = "perf_gfx";
+ static final String DB_KEY_PERFORMANCE_H264 = "perf_gfx_h264";
+ static final String DB_KEY_PERFORMANCE_WALLPAPER = "perf_wallpaper";
+ static final String DB_KEY_PERFORMANCE_THEME = "perf_theming";
+ static final String DB_KEY_PERFORMANCE_DRAG = "perf_full_window_drag";
+ static final String DB_KEY_PERFORMANCE_MENU_ANIMATIONS = "perf_menu_animations";
+ static final String DB_KEY_PERFORMANCE_FONTS = "perf_font_smoothing";
+ static final String DB_KEY_PERFORMANCE_COMPOSITION = "perf_desktop_composition";
- static final String DB_KEY_BOOKMARK_LABEL = "label";
- static final String DB_KEY_BOOKMARK_HOSTNAME = "hostname";
- static final String DB_KEY_BOOKMARK_USERNAME = "username";
- static final String DB_KEY_BOOKMARK_PASSWORD = "password";
- static final String DB_KEY_BOOKMARK_DOMAIN = "domain";
- static final String DB_KEY_BOOKMARK_PORT = "port";
+ static final String DB_KEY_BOOKMARK_LABEL = "label";
+ static final String DB_KEY_BOOKMARK_HOSTNAME = "hostname";
+ static final String DB_KEY_BOOKMARK_USERNAME = "username";
+ static final String DB_KEY_BOOKMARK_PASSWORD = "password";
+ static final String DB_KEY_BOOKMARK_DOMAIN = "domain";
+ static final String DB_KEY_BOOKMARK_PORT = "port";
- static final String DB_KEY_BOOKMARK_REDIRECT_SDCARD = "redirect_sdcard";
- static final String DB_KEY_BOOKMARK_REDIRECT_SOUND = "redirect_sound";
- static final String DB_KEY_BOOKMARK_REDIRECT_MICROPHONE = "redirect_microphone";
- static final String DB_KEY_BOOKMARK_SECURITY = "security";
- static final String DB_KEY_BOOKMARK_REMOTE_PROGRAM = "remote_program";
- static final String DB_KEY_BOOKMARK_WORK_DIR = "work_dir";
- static final String DB_KEY_BOOKMARK_ASYNC_CHANNEL = "async_channel";
- static final String DB_KEY_BOOKMARK_ASYNC_INPUT = "async_input";
- static final String DB_KEY_BOOKMARK_ASYNC_UPDATE = "async_update";
- static final String DB_KEY_BOOKMARK_CONSOLE_MODE = "console_mode";
- static final String DB_KEY_BOOKMARK_DEBUG_LEVEL = "debug_level";
+ static final String DB_KEY_BOOKMARK_REDIRECT_SDCARD = "redirect_sdcard";
+ static final String DB_KEY_BOOKMARK_REDIRECT_SOUND = "redirect_sound";
+ static final String DB_KEY_BOOKMARK_REDIRECT_MICROPHONE = "redirect_microphone";
+ static final String DB_KEY_BOOKMARK_SECURITY = "security";
+ static final String DB_KEY_BOOKMARK_REMOTE_PROGRAM = "remote_program";
+ static final String DB_KEY_BOOKMARK_WORK_DIR = "work_dir";
+ static final String DB_KEY_BOOKMARK_ASYNC_CHANNEL = "async_channel";
+ static final String DB_KEY_BOOKMARK_ASYNC_INPUT = "async_input";
+ static final String DB_KEY_BOOKMARK_ASYNC_UPDATE = "async_update";
+ static final String DB_KEY_BOOKMARK_CONSOLE_MODE = "console_mode";
+ static final String DB_KEY_BOOKMARK_DEBUG_LEVEL = "debug_level";
- static final String DB_KEY_BOOKMARK_GW_ENABLE = "enable_gateway_settings";
- static final String DB_KEY_BOOKMARK_GW_HOSTNAME = "gateway_hostname";
- static final String DB_KEY_BOOKMARK_GW_PORT = "gateway_port";
- static final String DB_KEY_BOOKMARK_GW_USERNAME = "gateway_username";
- static final String DB_KEY_BOOKMARK_GW_PASSWORD = "gateway_password";
- static final String DB_KEY_BOOKMARK_GW_DOMAIN = "gateway_domain";
- static final String DB_KEY_BOOKMARK_3G_ENABLE = "enable_3g_settings";
+ static final String DB_KEY_BOOKMARK_GW_ENABLE = "enable_gateway_settings";
+ static final String DB_KEY_BOOKMARK_GW_HOSTNAME = "gateway_hostname";
+ static final String DB_KEY_BOOKMARK_GW_PORT = "gateway_port";
+ static final String DB_KEY_BOOKMARK_GW_USERNAME = "gateway_username";
+ static final String DB_KEY_BOOKMARK_GW_PASSWORD = "gateway_password";
+ static final String DB_KEY_BOOKMARK_GW_DOMAIN = "gateway_domain";
+ static final String DB_KEY_BOOKMARK_3G_ENABLE = "enable_3g_settings";
- public BookmarkDB(Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
+ public BookmarkDB(Context context)
+ {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
- private static List GetColumns(SQLiteDatabase db, String tableName) {
- List ar = null;
- Cursor c = null;
- try {
- c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
- if (c != null) {
- ar = new ArrayList<>(Arrays.asList(c.getColumnNames()));
- }
- } catch (Exception e) {
- Log.v(tableName, e.getMessage(), e);
- e.printStackTrace();
- } finally {
- if (c != null)
- c.close();
- }
- return ar;
- }
+ private static List GetColumns(SQLiteDatabase db, String tableName)
+ {
+ List ar = null;
+ Cursor c = null;
+ try
+ {
+ c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
+ if (c != null)
+ {
+ ar = new ArrayList<>(Arrays.asList(c.getColumnNames()));
+ }
+ }
+ catch (Exception e)
+ {
+ Log.v(tableName, e.getMessage(), e);
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (c != null)
+ c.close();
+ }
+ return ar;
+ }
- private static String joinStrings(List list, String delim) {
- StringBuilder buf = new StringBuilder();
- int num = list.size();
- for (int i = 0; i < num; i++) {
- if (i != 0)
- buf.append(delim);
- buf.append((String) list.get(i));
- }
- return buf.toString();
- }
+ private static String joinStrings(List list, String delim)
+ {
+ StringBuilder buf = new StringBuilder();
+ int num = list.size();
+ for (int i = 0; i < num; i++)
+ {
+ if (i != 0)
+ buf.append(delim);
+ buf.append((String)list.get(i));
+ }
+ return buf.toString();
+ }
- private void backupTables(SQLiteDatabase db) {
- for (String table : DB_TABLES) {
- final String tmpTable = DB_BACKUP_PREFIX + table;
- final String query = "ALTER TABLE '" + table + "' RENAME TO '" + tmpTable + "'";
- try {
- db.execSQL(query);
- } catch (Exception e) {
- /* Ignore errors if table does not exist. */
- }
- }
- }
+ private void backupTables(SQLiteDatabase db)
+ {
+ for (String table : DB_TABLES)
+ {
+ final String tmpTable = DB_BACKUP_PREFIX + table;
+ final String query = "ALTER TABLE '" + table + "' RENAME TO '" + tmpTable + "'";
+ try
+ {
+ db.execSQL(query);
+ }
+ catch (Exception e)
+ {
+ /* Ignore errors if table does not exist. */
+ }
+ }
+ }
- private void dropOldTables(SQLiteDatabase db) {
- for (String table : DB_TABLES) {
- final String tmpTable = DB_BACKUP_PREFIX + table;
- final String query = "DROP TABLE IF EXISTS '" + tmpTable + "'";
- db.execSQL(query);
- }
- }
+ private void dropOldTables(SQLiteDatabase db)
+ {
+ for (String table : DB_TABLES)
+ {
+ final String tmpTable = DB_BACKUP_PREFIX + table;
+ final String query = "DROP TABLE IF EXISTS '" + tmpTable + "'";
+ db.execSQL(query);
+ }
+ }
- private void createDB(SQLiteDatabase db) {
- final String sqlScreenSettings =
- "CREATE TABLE IF NOT EXISTS " + DB_TABLE_SCREEN + " ("
- + ID + " INTEGER PRIMARY KEY, "
- + DB_KEY_SCREEN_COLORS + " INTEGER DEFAULT 16, "
- + DB_KEY_SCREEN_RESOLUTION + " INTEGER DEFAULT 0, "
- + DB_KEY_SCREEN_WIDTH + ", "
- + DB_KEY_SCREEN_HEIGHT + ");";
+ private void createDB(SQLiteDatabase db)
+ {
+ final String sqlScreenSettings =
+ "CREATE TABLE IF NOT EXISTS " + DB_TABLE_SCREEN + " (" + ID + " INTEGER PRIMARY KEY, " +
+ DB_KEY_SCREEN_COLORS + " INTEGER DEFAULT 16, " + DB_KEY_SCREEN_RESOLUTION +
+ " INTEGER DEFAULT 0, " + DB_KEY_SCREEN_WIDTH + ", " + DB_KEY_SCREEN_HEIGHT + ");";
- db.execSQL(sqlScreenSettings);
+ db.execSQL(sqlScreenSettings);
- final String sqlPerformanceFlags =
- "CREATE TABLE IF NOT EXISTS " + DB_TABLE_PERFORMANCE + " ("
- + ID + " INTEGER PRIMARY KEY, "
- + DB_KEY_PERFORMANCE_RFX + " INTEGER, "
- + DB_KEY_PERFORMANCE_GFX + " INTEGER, "
- + DB_KEY_PERFORMANCE_H264 + " INTEGER, "
- + DB_KEY_PERFORMANCE_WALLPAPER + " INTEGER, "
- + DB_KEY_PERFORMANCE_THEME + " INTEGER, "
- + DB_KEY_PERFORMANCE_DRAG + " INTEGER, "
- + DB_KEY_PERFORMANCE_MENU_ANIMATIONS + " INTEGER, "
- + DB_KEY_PERFORMANCE_FONTS + " INTEGER, "
- + DB_KEY_PERFORMANCE_COMPOSITION + " INTEGER);";
+ final String sqlPerformanceFlags =
+ "CREATE TABLE IF NOT EXISTS " + DB_TABLE_PERFORMANCE + " (" + ID +
+ " INTEGER PRIMARY KEY, " + DB_KEY_PERFORMANCE_RFX + " INTEGER, " +
+ DB_KEY_PERFORMANCE_GFX + " INTEGER, " + DB_KEY_PERFORMANCE_H264 + " INTEGER, " +
+ DB_KEY_PERFORMANCE_WALLPAPER + " INTEGER, " + DB_KEY_PERFORMANCE_THEME + " INTEGER, " +
+ DB_KEY_PERFORMANCE_DRAG + " INTEGER, " + DB_KEY_PERFORMANCE_MENU_ANIMATIONS +
+ " INTEGER, " + DB_KEY_PERFORMANCE_FONTS + " INTEGER, " +
+ DB_KEY_PERFORMANCE_COMPOSITION + " INTEGER);";
- db.execSQL(sqlPerformanceFlags);
+ db.execSQL(sqlPerformanceFlags);
- final String sqlManualBookmarks = getManualBookmarksCreationString();
- db.execSQL(sqlManualBookmarks);
- }
+ final String sqlManualBookmarks = getManualBookmarksCreationString();
+ db.execSQL(sqlManualBookmarks);
+ }
- private void upgradeTables(SQLiteDatabase db) {
- for (String table : DB_TABLES) {
- final String tmpTable = DB_BACKUP_PREFIX + table;
+ private void upgradeTables(SQLiteDatabase db)
+ {
+ for (String table : DB_TABLES)
+ {
+ final String tmpTable = DB_BACKUP_PREFIX + table;
- final List newColumns = GetColumns(db, table);
- List columns = GetColumns(db, tmpTable);
+ final List newColumns = GetColumns(db, table);
+ List columns = GetColumns(db, tmpTable);
- if (columns != null) {
- columns.retainAll(newColumns);
+ if (columns != null)
+ {
+ columns.retainAll(newColumns);
- // restore data
- final String cols = joinStrings(columns, ",");
- final String query = String.format("INSERT INTO %s (%s) SELECT %s from '%s'", table, cols, cols, tmpTable);
- db.execSQL(query);
- }
- }
- }
+ // restore data
+ final String cols = joinStrings(columns, ",");
+ final String query = String.format("INSERT INTO %s (%s) SELECT %s from '%s'", table,
+ cols, cols, tmpTable);
+ db.execSQL(query);
+ }
+ }
+ }
- private void downgradeTables(SQLiteDatabase db) {
- for (String table : DB_TABLES) {
- final String tmpTable = DB_BACKUP_PREFIX + table;
+ private void downgradeTables(SQLiteDatabase db)
+ {
+ for (String table : DB_TABLES)
+ {
+ final String tmpTable = DB_BACKUP_PREFIX + table;
- List oldColumns = GetColumns(db, table);
- final List columns = GetColumns(db, tmpTable);
+ List oldColumns = GetColumns(db, table);
+ final List columns = GetColumns(db, tmpTable);
- if (oldColumns != null) {
- oldColumns.retainAll(columns);
+ if (oldColumns != null)
+ {
+ oldColumns.retainAll(columns);
- // restore data
- final String cols = joinStrings(oldColumns, ",");
- final String query = String.format("INSERT INTO %s (%s) SELECT %s from '%s'", table, cols, cols, tmpTable);
- db.execSQL(query);
- }
- }
- }
+ // restore data
+ final String cols = joinStrings(oldColumns, ",");
+ final String query = String.format("INSERT INTO %s (%s) SELECT %s from '%s'", table,
+ cols, cols, tmpTable);
+ db.execSQL(query);
+ }
+ }
+ }
- private List getTableNames(SQLiteDatabase db) {
- final String query = "SELECT name FROM sqlite_master WHERE type='table'";
- Cursor cursor = db.rawQuery(query, null);
- List list = new ArrayList<>();
- try {
- if (cursor.moveToFirst() && (cursor.getCount() > 0)) {
- while (!cursor.isAfterLast()) {
- final String name = cursor.getString(cursor.getColumnIndex("name"));
- list.add(name);
- cursor.moveToNext();
- }
- }
- } finally {
- cursor.close();
- }
+ private List getTableNames(SQLiteDatabase db)
+ {
+ final String query = "SELECT name FROM sqlite_master WHERE type='table'";
+ Cursor cursor = db.rawQuery(query, null);
+ List list = new ArrayList<>();
+ try
+ {
+ if (cursor.moveToFirst() && (cursor.getCount() > 0))
+ {
+ while (!cursor.isAfterLast())
+ {
+ final String name = cursor.getString(cursor.getColumnIndex("name"));
+ list.add(name);
+ cursor.moveToNext();
+ }
+ }
+ }
+ finally
+ {
+ cursor.close();
+ }
- return list;
- }
+ return list;
+ }
- private void insertDefault(SQLiteDatabase db) {
- ContentValues screenValues = new ContentValues();
- screenValues.put(DB_KEY_SCREEN_COLORS, 32);
- screenValues.put(DB_KEY_SCREEN_RESOLUTION, 1);
- screenValues.put(DB_KEY_SCREEN_WIDTH, 1024);
- screenValues.put(DB_KEY_SCREEN_HEIGHT, 768);
+ private void insertDefault(SQLiteDatabase db)
+ {
+ ContentValues screenValues = new ContentValues();
+ screenValues.put(DB_KEY_SCREEN_COLORS, 32);
+ screenValues.put(DB_KEY_SCREEN_RESOLUTION, 1);
+ screenValues.put(DB_KEY_SCREEN_WIDTH, 1024);
+ screenValues.put(DB_KEY_SCREEN_HEIGHT, 768);
- final long idScreen = db.insert(DB_TABLE_SCREEN, null, screenValues);
- final long idScreen3g = db.insert(DB_TABLE_SCREEN, null, screenValues);
+ final long idScreen = db.insert(DB_TABLE_SCREEN, null, screenValues);
+ final long idScreen3g = db.insert(DB_TABLE_SCREEN, null, screenValues);
- ContentValues performanceValues = new ContentValues();
- performanceValues.put(DB_KEY_PERFORMANCE_RFX, 1);
- performanceValues.put(DB_KEY_PERFORMANCE_GFX, 1);
- performanceValues.put(DB_KEY_PERFORMANCE_H264, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_WALLPAPER, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_THEME, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_DRAG, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_MENU_ANIMATIONS, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_FONTS, 0);
- performanceValues.put(DB_KEY_PERFORMANCE_COMPOSITION, 0);
+ ContentValues performanceValues = new ContentValues();
+ performanceValues.put(DB_KEY_PERFORMANCE_RFX, 1);
+ performanceValues.put(DB_KEY_PERFORMANCE_GFX, 1);
+ performanceValues.put(DB_KEY_PERFORMANCE_H264, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_WALLPAPER, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_THEME, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_DRAG, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_MENU_ANIMATIONS, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_FONTS, 0);
+ performanceValues.put(DB_KEY_PERFORMANCE_COMPOSITION, 0);
- final long idPerformance = db.insert(DB_TABLE_PERFORMANCE, null, performanceValues);
- final long idPerformance3g = db.insert(DB_TABLE_PERFORMANCE, null, performanceValues);
+ final long idPerformance = db.insert(DB_TABLE_PERFORMANCE, null, performanceValues);
+ final long idPerformance3g = db.insert(DB_TABLE_PERFORMANCE, null, performanceValues);
- ContentValues bookmarkValues = new ContentValues();
- bookmarkValues.put(DB_KEY_BOOKMARK_LABEL, "Test Server");
- bookmarkValues.put(DB_KEY_BOOKMARK_HOSTNAME, "testservice.afreerdp.com");
- bookmarkValues.put(DB_KEY_BOOKMARK_USERNAME, "");
- bookmarkValues.put(DB_KEY_BOOKMARK_PASSWORD, "");
- bookmarkValues.put(DB_KEY_BOOKMARK_DOMAIN, "");
- bookmarkValues.put(DB_KEY_BOOKMARK_PORT, "3389");
+ ContentValues bookmarkValues = new ContentValues();
+ bookmarkValues.put(DB_KEY_BOOKMARK_LABEL, "Test Server");
+ bookmarkValues.put(DB_KEY_BOOKMARK_HOSTNAME, "testservice.afreerdp.com");
+ bookmarkValues.put(DB_KEY_BOOKMARK_USERNAME, "");
+ bookmarkValues.put(DB_KEY_BOOKMARK_PASSWORD, "");
+ bookmarkValues.put(DB_KEY_BOOKMARK_DOMAIN, "");
+ bookmarkValues.put(DB_KEY_BOOKMARK_PORT, "3389");
- bookmarkValues.put(DB_KEY_SCREEN_SETTINGS, idScreen);
- bookmarkValues.put(DB_KEY_SCREEN_SETTINGS_3G, idScreen3g);
- bookmarkValues.put(DB_KEY_PERFORMANCE_FLAGS, idPerformance);
- bookmarkValues.put(DB_KEY_PERFORMANCE_FLAGS_3G, idPerformance3g);
+ bookmarkValues.put(DB_KEY_SCREEN_SETTINGS, idScreen);
+ bookmarkValues.put(DB_KEY_SCREEN_SETTINGS_3G, idScreen3g);
+ bookmarkValues.put(DB_KEY_PERFORMANCE_FLAGS, idPerformance);
+ bookmarkValues.put(DB_KEY_PERFORMANCE_FLAGS_3G, idPerformance3g);
- bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_SDCARD, 0);
- bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_SOUND, 0);
- bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_MICROPHONE, 0);
- bookmarkValues.put(DB_KEY_BOOKMARK_SECURITY, 0);
- bookmarkValues.put(DB_KEY_BOOKMARK_REMOTE_PROGRAM, "");
- bookmarkValues.put(DB_KEY_BOOKMARK_WORK_DIR, "");
- bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_CHANNEL, 1);
- bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_INPUT, 1);
- bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_UPDATE, 1);
- bookmarkValues.put(DB_KEY_BOOKMARK_CONSOLE_MODE, 0);
- bookmarkValues.put(DB_KEY_BOOKMARK_DEBUG_LEVEL, "INFO");
+ bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_SDCARD, 0);
+ bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_SOUND, 0);
+ bookmarkValues.put(DB_KEY_BOOKMARK_REDIRECT_MICROPHONE, 0);
+ bookmarkValues.put(DB_KEY_BOOKMARK_SECURITY, 0);
+ bookmarkValues.put(DB_KEY_BOOKMARK_REMOTE_PROGRAM, "");
+ bookmarkValues.put(DB_KEY_BOOKMARK_WORK_DIR, "");
+ bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_CHANNEL, 1);
+ bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_INPUT, 1);
+ bookmarkValues.put(DB_KEY_BOOKMARK_ASYNC_UPDATE, 1);
+ bookmarkValues.put(DB_KEY_BOOKMARK_CONSOLE_MODE, 0);
+ bookmarkValues.put(DB_KEY_BOOKMARK_DEBUG_LEVEL, "INFO");
- db.insert(DB_TABLE_BOOKMARK, null, bookmarkValues);
- }
+ db.insert(DB_TABLE_BOOKMARK, null, bookmarkValues);
+ }
- @Override
- public void onCreate(SQLiteDatabase db) {
- createDB(db);
- insertDefault(db);
- }
+ @Override public void onCreate(SQLiteDatabase db)
+ {
+ createDB(db);
+ insertDefault(db);
+ }
- private String getManualBookmarksCreationString() {
- return (
- "CREATE TABLE IF NOT EXISTS " + DB_TABLE_BOOKMARK + " ("
- + ID + " INTEGER PRIMARY KEY, "
- + DB_KEY_BOOKMARK_LABEL + " TEXT NOT NULL, "
- + DB_KEY_BOOKMARK_HOSTNAME + " TEXT NOT NULL, "
- + DB_KEY_BOOKMARK_USERNAME + " TEXT NOT NULL, "
- + DB_KEY_BOOKMARK_PASSWORD + " TEXT, "
- + DB_KEY_BOOKMARK_DOMAIN + " TEXT, "
- + DB_KEY_BOOKMARK_PORT + " TEXT, "
- + DB_KEY_SCREEN_SETTINGS + " INTEGER NOT NULL, "
- + DB_KEY_PERFORMANCE_FLAGS + " INTEGER NOT NULL, "
+ private String getManualBookmarksCreationString()
+ {
+ return ("CREATE TABLE IF NOT EXISTS " + DB_TABLE_BOOKMARK + " (" + ID +
+ " INTEGER PRIMARY KEY, " + DB_KEY_BOOKMARK_LABEL + " TEXT NOT NULL, " +
+ DB_KEY_BOOKMARK_HOSTNAME + " TEXT NOT NULL, " + DB_KEY_BOOKMARK_USERNAME +
+ " TEXT NOT NULL, " + DB_KEY_BOOKMARK_PASSWORD + " TEXT, " + DB_KEY_BOOKMARK_DOMAIN +
+ " TEXT, " + DB_KEY_BOOKMARK_PORT + " TEXT, " + DB_KEY_SCREEN_SETTINGS +
+ " INTEGER NOT NULL, " + DB_KEY_PERFORMANCE_FLAGS + " INTEGER NOT NULL, "
- + DB_KEY_BOOKMARK_GW_ENABLE + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_GW_HOSTNAME + " TEXT, "
- + DB_KEY_BOOKMARK_GW_PORT + " INTEGER DEFAULT 443, "
- + DB_KEY_BOOKMARK_GW_USERNAME + " TEXT, "
- + DB_KEY_BOOKMARK_GW_PASSWORD + " TEXT, "
- + DB_KEY_BOOKMARK_GW_DOMAIN + " TEXT, "
+ + DB_KEY_BOOKMARK_GW_ENABLE + " INTEGER DEFAULT 0, " + DB_KEY_BOOKMARK_GW_HOSTNAME +
+ " TEXT, " + DB_KEY_BOOKMARK_GW_PORT + " INTEGER DEFAULT 443, " +
+ DB_KEY_BOOKMARK_GW_USERNAME + " TEXT, " + DB_KEY_BOOKMARK_GW_PASSWORD + " TEXT, " +
+ DB_KEY_BOOKMARK_GW_DOMAIN + " TEXT, "
- + DB_KEY_BOOKMARK_3G_ENABLE + " INTEGER DEFAULT 0, "
- + DB_KEY_SCREEN_SETTINGS_3G + " INTEGER NOT NULL, "
- + DB_KEY_PERFORMANCE_FLAGS_3G + " INTEGER NOT NULL, "
- + DB_KEY_BOOKMARK_REDIRECT_SDCARD + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_REDIRECT_SOUND + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_REDIRECT_MICROPHONE + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_SECURITY + " INTEGER, "
- + DB_KEY_BOOKMARK_REMOTE_PROGRAM + " TEXT, "
- + DB_KEY_BOOKMARK_WORK_DIR + " TEXT, "
- + DB_KEY_BOOKMARK_ASYNC_CHANNEL + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_ASYNC_INPUT + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_ASYNC_UPDATE + " INTEGER DEFAULT 0, "
- + DB_KEY_BOOKMARK_CONSOLE_MODE + " INTEGER, "
- + DB_KEY_BOOKMARK_DEBUG_LEVEL + " TEXT DEFAULT 'INFO', "
+ + DB_KEY_BOOKMARK_3G_ENABLE + " INTEGER DEFAULT 0, " + DB_KEY_SCREEN_SETTINGS_3G +
+ " INTEGER NOT NULL, " + DB_KEY_PERFORMANCE_FLAGS_3G + " INTEGER NOT NULL, " +
+ DB_KEY_BOOKMARK_REDIRECT_SDCARD + " INTEGER DEFAULT 0, " +
+ DB_KEY_BOOKMARK_REDIRECT_SOUND + " INTEGER DEFAULT 0, " +
+ DB_KEY_BOOKMARK_REDIRECT_MICROPHONE + " INTEGER DEFAULT 0, " +
+ DB_KEY_BOOKMARK_SECURITY + " INTEGER, " + DB_KEY_BOOKMARK_REMOTE_PROGRAM +
+ " TEXT, " + DB_KEY_BOOKMARK_WORK_DIR + " TEXT, " + DB_KEY_BOOKMARK_ASYNC_CHANNEL +
+ " INTEGER DEFAULT 0, " + DB_KEY_BOOKMARK_ASYNC_INPUT + " INTEGER DEFAULT 0, " +
+ DB_KEY_BOOKMARK_ASYNC_UPDATE + " INTEGER DEFAULT 0, " +
+ DB_KEY_BOOKMARK_CONSOLE_MODE + " INTEGER, " + DB_KEY_BOOKMARK_DEBUG_LEVEL +
+ " TEXT DEFAULT 'INFO', "
- + "FOREIGN KEY(" + DB_KEY_SCREEN_SETTINGS + ") REFERENCES " + DB_TABLE_SCREEN + "(" + ID + "), "
- + "FOREIGN KEY(" + DB_KEY_PERFORMANCE_FLAGS + ") REFERENCES " + DB_TABLE_PERFORMANCE + "(" + ID + "), "
- + "FOREIGN KEY(" + DB_KEY_SCREEN_SETTINGS_3G + ") REFERENCES " + DB_TABLE_SCREEN + "(" + ID + "), "
- + "FOREIGN KEY(" + DB_KEY_PERFORMANCE_FLAGS_3G + ") REFERENCES " + DB_TABLE_PERFORMANCE + "(" + ID + ") "
+ + "FOREIGN KEY(" + DB_KEY_SCREEN_SETTINGS + ") REFERENCES " + DB_TABLE_SCREEN +
+ "(" + ID + "), "
+ + "FOREIGN KEY(" + DB_KEY_PERFORMANCE_FLAGS + ") REFERENCES " +
+ DB_TABLE_PERFORMANCE + "(" + ID + "), "
+ + "FOREIGN KEY(" + DB_KEY_SCREEN_SETTINGS_3G + ") REFERENCES " + DB_TABLE_SCREEN +
+ "(" + ID + "), "
+ + "FOREIGN KEY(" + DB_KEY_PERFORMANCE_FLAGS_3G + ") REFERENCES " +
+ DB_TABLE_PERFORMANCE + "(" + ID + ") "
- + ");");
- }
+ + ");");
+ }
- private void recreateDB(SQLiteDatabase db) {
- for (String table : DB_TABLES) {
- final String query = "DROP TABLE IF EXISTS '" + table + "'";
- db.execSQL(query);
- }
- onCreate(db);
- }
+ private void recreateDB(SQLiteDatabase db)
+ {
+ for (String table : DB_TABLES)
+ {
+ final String query = "DROP TABLE IF EXISTS '" + table + "'";
+ db.execSQL(query);
+ }
+ onCreate(db);
+ }
- private void upgradeDB(SQLiteDatabase db) {
- db.beginTransaction();
- try {
- /* Back up old tables. */
- dropOldTables(db);
- backupTables(db);
- createDB(db);
- upgradeTables(db);
+ private void upgradeDB(SQLiteDatabase db)
+ {
+ db.beginTransaction();
+ try
+ {
+ /* Back up old tables. */
+ dropOldTables(db);
+ backupTables(db);
+ createDB(db);
+ upgradeTables(db);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- dropOldTables(db);
- }
- }
+ db.setTransactionSuccessful();
+ }
+ finally
+ {
+ db.endTransaction();
+ dropOldTables(db);
+ }
+ }
- private void downgradeDB(SQLiteDatabase db) {
- db.beginTransaction();
- try {
- /* Back up old tables. */
- dropOldTables(db);
- backupTables(db);
- createDB(db);
- downgradeTables(db);
+ private void downgradeDB(SQLiteDatabase db)
+ {
+ db.beginTransaction();
+ try
+ {
+ /* Back up old tables. */
+ dropOldTables(db);
+ backupTables(db);
+ createDB(db);
+ downgradeTables(db);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- dropOldTables(db);
- }
- }
+ db.setTransactionSuccessful();
+ }
+ finally
+ {
+ db.endTransaction();
+ dropOldTables(db);
+ }
+ }
- // from http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- switch (oldVersion) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- upgradeDB(db);
- break;
- default:
- recreateDB(db);
- break;
- }
- }
-
- @Override
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- downgradeDB(db);
- }
+ // from
+ // http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another
+ @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ {
+ switch (oldVersion)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ upgradeDB(db);
+ break;
+ default:
+ recreateDB(db);
+ break;
+ }
+ }
+ @Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ {
+ downgradeDB(db);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/FreeRDPSuggestionProvider.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/FreeRDPSuggestionProvider.java
index 5d0035b41..d5f657c74 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/FreeRDPSuggestionProvider.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/FreeRDPSuggestionProvider.java
@@ -1,10 +1,11 @@
/*
- Suggestion Provider for RDP bookmarks
+ Suggestion Provider for RDP bookmarks
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -24,97 +25,110 @@ import com.freerdp.freerdpcore.domain.ManualBookmark;
import java.util.ArrayList;
-public class FreeRDPSuggestionProvider extends ContentProvider {
+public class FreeRDPSuggestionProvider extends ContentProvider
+{
- public static final Uri CONTENT_URI = Uri.parse("content://com.freerdp.afreerdp.services.freerdpsuggestionprovider");
+ public static final Uri CONTENT_URI =
+ Uri.parse("content://com.freerdp.afreerdp.services.freerdpsuggestionprovider");
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- // TODO Auto-generated method stub
- return 0;
- }
+ @Override public int delete(Uri uri, String selection, String[] selectionArgs)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
- @Override
- public String getType(Uri uri) {
- return "vnd.android.cursor.item/vnd.freerdp.remote";
- }
+ @Override public String getType(Uri uri)
+ {
+ return "vnd.android.cursor.item/vnd.freerdp.remote";
+ }
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override public Uri insert(Uri uri, ContentValues values)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public boolean onCreate() {
- return true;
- }
+ @Override public boolean onCreate()
+ {
+ return true;
+ }
- @Override
- public Cursor query(Uri uri, String[] projection, String selection,
- String[] selectionArgs, String sortOrder) {
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder)
+ {
- String query = (selectionArgs != null && selectionArgs.length > 0) ? selectionArgs[0] : "";
+ String query = (selectionArgs != null && selectionArgs.length > 0) ? selectionArgs[0] : "";
- // search history
- ArrayList history = GlobalApp.getQuickConnectHistoryGateway().findHistory(query);
+ // search history
+ ArrayList history =
+ GlobalApp.getQuickConnectHistoryGateway().findHistory(query);
- // search bookmarks
- ArrayList manualBookmarks;
- if (query.length() > 0)
- manualBookmarks = GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(query);
- else
- manualBookmarks = GlobalApp.getManualBookmarkGateway().findAll();
+ // search bookmarks
+ ArrayList manualBookmarks;
+ if (query.length() > 0)
+ manualBookmarks = GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(query);
+ else
+ manualBookmarks = GlobalApp.getManualBookmarkGateway().findAll();
- return createResultCursor(history, manualBookmarks);
- }
+ return createResultCursor(history, manualBookmarks);
+ }
- @Override
- public int update(Uri uri, ContentValues values, String selection,
- String[] selectionArgs) {
- // TODO Auto-generated method stub
- return 0;
- }
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
- private void addBookmarksToCursor(ArrayList bookmarks, MatrixCursor resultCursor) {
- Object[] row = new Object[5];
- for (BookmarkBase bookmark : bookmarks) {
- row[0] = new Long(bookmark.getId());
- row[1] = bookmark.getLabel();
- row[2] = bookmark.get().getHostname();
- row[3] = ConnectionReference.getManualBookmarkReference(bookmark.getId());
- row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_on;
- resultCursor.addRow(row);
- }
- }
+ private void addBookmarksToCursor(ArrayList bookmarks, MatrixCursor resultCursor)
+ {
+ Object[] row = new Object[5];
+ for (BookmarkBase bookmark : bookmarks)
+ {
+ row[0] = new Long(bookmark.getId());
+ row[1] = bookmark.getLabel();
+ row[2] = bookmark.get().getHostname();
+ row[3] = ConnectionReference.getManualBookmarkReference(bookmark.getId());
+ row[4] = "android.resource://" + getContext().getPackageName() + "/" +
+ R.drawable.icon_star_on;
+ resultCursor.addRow(row);
+ }
+ }
- private void addHistoryToCursor(ArrayList history, MatrixCursor resultCursor) {
- Object[] row = new Object[5];
- for (BookmarkBase bookmark : history) {
- row[0] = new Integer(1);
- row[1] = bookmark.getLabel();
- row[2] = bookmark.getLabel();
- row[3] = ConnectionReference.getHostnameReference(bookmark.getLabel());
- row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_off;
- resultCursor.addRow(row);
- }
- }
+ private void addHistoryToCursor(ArrayList history, MatrixCursor resultCursor)
+ {
+ Object[] row = new Object[5];
+ for (BookmarkBase bookmark : history)
+ {
+ row[0] = new Integer(1);
+ row[1] = bookmark.getLabel();
+ row[2] = bookmark.getLabel();
+ row[3] = ConnectionReference.getHostnameReference(bookmark.getLabel());
+ row[4] = "android.resource://" + getContext().getPackageName() + "/" +
+ R.drawable.icon_star_off;
+ resultCursor.addRow(row);
+ }
+ }
- private Cursor createResultCursor(ArrayList history, ArrayList manualBookmarks) {
+ private Cursor createResultCursor(ArrayList history,
+ ArrayList manualBookmarks)
+ {
- // create result matrix cursor
- int totalCount = history.size() + manualBookmarks.size();
- String[] columns = {android.provider.BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
- SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA,
- SearchManager.SUGGEST_COLUMN_ICON_2};
- MatrixCursor matrixCursor = new MatrixCursor(columns, totalCount);
-
- // populate result matrix
- if (totalCount > 0) {
- addHistoryToCursor(history, matrixCursor);
- addBookmarksToCursor(manualBookmarks, matrixCursor);
- }
- return matrixCursor;
- }
+ // create result matrix cursor
+ int totalCount = history.size() + manualBookmarks.size();
+ String[] columns = { android.provider.BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
+ SearchManager.SUGGEST_COLUMN_TEXT_2,
+ SearchManager.SUGGEST_COLUMN_INTENT_DATA,
+ SearchManager.SUGGEST_COLUMN_ICON_2 };
+ MatrixCursor matrixCursor = new MatrixCursor(columns, totalCount);
+ // populate result matrix
+ if (totalCount > 0)
+ {
+ addHistoryToCursor(history, matrixCursor);
+ addBookmarksToCursor(manualBookmarks, matrixCursor);
+ }
+ return matrixCursor;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/HistoryDB.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/HistoryDB.java
index 91bd8b7b0..b483aac88 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/HistoryDB.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/HistoryDB.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -13,34 +14,33 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
-public class HistoryDB extends SQLiteOpenHelper {
+public class HistoryDB extends SQLiteOpenHelper
+{
- public static final String QUICK_CONNECT_TABLE_NAME = "quick_connect_history";
- public static final String QUICK_CONNECT_TABLE_COL_ITEM = "item";
- public static final String QUICK_CONNECT_TABLE_COL_TIMESTAMP = "timestamp";
- private static final int DB_VERSION = 1;
- private static final String DB_NAME = "history.db";
+ public static final String QUICK_CONNECT_TABLE_NAME = "quick_connect_history";
+ public static final String QUICK_CONNECT_TABLE_COL_ITEM = "item";
+ public static final String QUICK_CONNECT_TABLE_COL_TIMESTAMP = "timestamp";
+ private static final int DB_VERSION = 1;
+ private static final String DB_NAME = "history.db";
- public HistoryDB(Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
+ public HistoryDB(Context context)
+ {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
- @Override
- public void onCreate(SQLiteDatabase db) {
+ @Override public void onCreate(SQLiteDatabase db)
+ {
- String sqlQuickConnectHistory =
- "CREATE TABLE " + QUICK_CONNECT_TABLE_NAME + " ("
- + QUICK_CONNECT_TABLE_COL_ITEM + " TEXT PRIMARY KEY, "
- + QUICK_CONNECT_TABLE_COL_TIMESTAMP + " INTEGER"
- + ");";
+ String sqlQuickConnectHistory = "CREATE TABLE " + QUICK_CONNECT_TABLE_NAME + " (" +
+ QUICK_CONNECT_TABLE_COL_ITEM + " TEXT PRIMARY KEY, " +
+ QUICK_CONNECT_TABLE_COL_TIMESTAMP + " INTEGER"
+ + ");";
- db.execSQL(sqlQuickConnectHistory);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- // TODO Auto-generated method stub
-
- }
+ db.execSQL(sqlQuickConnectHistory);
+ }
+ @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ {
+ // TODO Auto-generated method stub
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
index 686b5c2ed..658b47c73 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java
@@ -3,13 +3,13 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
-
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -24,502 +24,594 @@ import com.freerdp.freerdpcore.presentation.ApplicationSettingsActivity;
import java.util.ArrayList;
-public class LibFreeRDP {
- private static final String TAG = "LibFreeRDP";
- private static EventListener listener;
- private static boolean mHasH264 = true;
-
- private static final LongSparseArray mInstanceState = new LongSparseArray<>();
-
- static {
- final String h264 = "openh264";
- final String[] libraries = {
- h264, "freerdp-openssl", "jpeg", "winpr2",
- "freerdp2", "freerdp-client2", "freerdp-android2"};
- final String LD_PATH = System.getProperty("java.library.path");
-
- for (String lib : libraries) {
- try {
- Log.v(TAG, "Trying to load library " + lib + " from LD_PATH: " + LD_PATH);
- System.loadLibrary(lib);
- } catch (UnsatisfiedLinkError e) {
- Log.e(TAG, "Failed to load library " + lib + ": " + e.toString());
- if (lib.equals(h264)) {
- mHasH264 = false;
- }
- }
- }
- }
-
- public static boolean hasH264Support() {
- return mHasH264;
- }
-
- private static native String freerdp_get_jni_version();
-
- private static native String freerdp_get_version();
-
- private static native String freerdp_get_build_date();
-
- private static native String freerdp_get_build_revision();
-
- private static native String freerdp_get_build_config();
-
- private static native long freerdp_new(Context context);
-
- private static native void freerdp_free(long inst);
-
- private static native boolean freerdp_parse_arguments(long inst, String[] args);
-
- private static native boolean freerdp_connect(long inst);
-
- private static native boolean freerdp_disconnect(long inst);
-
- private static native boolean freerdp_update_graphics(long inst,
- Bitmap bitmap, int x, int y, int width, int height);
-
- private static native boolean freerdp_send_cursor_event(long inst, int x, int y, int flags);
-
- private static native boolean freerdp_send_key_event(long inst, int keycode, boolean down);
-
- private static native boolean freerdp_send_unicodekey_event(long inst, int keycode, boolean down);
-
- private static native boolean freerdp_send_clipboard_data(long inst, String data);
-
- private static native String freerdp_get_last_error_string(long inst);
-
- public static void setEventListener(EventListener l) {
- listener = l;
- }
-
- public static long newInstance(Context context) {
- return freerdp_new(context);
- }
-
- public static void freeInstance(long inst) {
- synchronized (mInstanceState) {
- if (mInstanceState.get(inst, false)) {
- freerdp_disconnect(inst);
- }
- while(mInstanceState.get(inst, false)) {
- try {
- mInstanceState.wait();
- } catch (InterruptedException e) {
- throw new RuntimeException();
- }
- }
- }
- freerdp_free(inst);
- }
-
- public static boolean connect(long inst) {
- synchronized (mInstanceState) {
- if (mInstanceState.get(inst, false)) {
- throw new RuntimeException("instance already connected");
- }
- }
- return freerdp_connect(inst);
- }
-
- public static boolean disconnect(long inst) {
- synchronized (mInstanceState) {
- if (mInstanceState.get(inst, false)) {
- return freerdp_disconnect(inst);
- }
- return true;
- }
- }
-
- public static boolean cancelConnection(long inst) {
- synchronized (mInstanceState) {
- if (mInstanceState.get(inst, false)) {
- return freerdp_disconnect(inst);
- }
- return true;
- }
- }
-
- private static String addFlag(String name, boolean enabled) {
- if (enabled) {
- return "+" + name;
- }
- return "-" + name;
- }
-
- public static boolean setConnectionInfo(Context context, long inst, BookmarkBase bookmark) {
- BookmarkBase.ScreenSettings screenSettings = bookmark.getActiveScreenSettings();
- BookmarkBase.AdvancedSettings advanced = bookmark.getAdvancedSettings();
- BookmarkBase.DebugSettings debug = bookmark.getDebugSettings();
-
- String arg;
- ArrayList args = new ArrayList();
-
- args.add(TAG);
- args.add("/gdi:sw");
-
- final String clientName = ApplicationSettingsActivity.getClientName(context);
- if (!clientName.isEmpty()) {
- args.add("/client-hostname:" + clientName);
- }
- String certName = "";
- if (bookmark.getType() != BookmarkBase.TYPE_MANUAL) {
- return false;
- }
-
- int port = bookmark.get().getPort();
- String hostname = bookmark.get().getHostname();
-
- args.add("/v:" + hostname);
- args.add("/port:" + String.valueOf(port));
-
- arg = bookmark.getUsername();
- if (!arg.isEmpty()) {
- args.add("/u:" + arg);
- }
- arg = bookmark.getDomain();
- if (!arg.isEmpty()) {
- args.add("/d:" + arg);
- }
- arg = bookmark.getPassword();
- if (!arg.isEmpty()) {
- args.add("/p:" + arg);
- }
-
- args.add(String.format("/size:%dx%d", screenSettings.getWidth(),
- screenSettings.getHeight()));
- args.add("/bpp:" + String.valueOf(screenSettings.getColors()));
-
- if (advanced.getConsoleMode()) {
- args.add("/admin");
- }
-
- switch (advanced.getSecurity()) {
- case 3: // NLA
- args.add("/sec-nla");
- break;
- case 2: // TLS
- args.add("/sec-tls");
- break;
- case 1: // RDP
- args.add("/sec-rdp");
- break;
- default:
- break;
- }
-
- if (!certName.isEmpty()) {
- args.add("/cert-name:" + certName);
- }
-
- BookmarkBase.PerformanceFlags flags = bookmark.getActivePerformanceFlags();
- if (flags.getRemoteFX()) {
- args.add("/rfx");
- }
-
- if (flags.getGfx()) {
- args.add("/gfx");
- }
-
- if (flags.getH264() && mHasH264) {
- args.add("/gfx:AVC444");
- }
-
- args.add(addFlag("wallpaper", flags.getWallpaper()));
- args.add(addFlag("window-drag", flags.getFullWindowDrag()));
- args.add(addFlag("menu-anims", flags.getMenuAnimations()));
- args.add(addFlag("themes", flags.getTheming()));
- args.add(addFlag("fonts", flags.getFontSmoothing()));
- args.add(addFlag("aero", flags.getDesktopComposition()));
- args.add(addFlag("glyph-cache", false));
-
- if (!advanced.getRemoteProgram().isEmpty()) {
- args.add("/shell:" + advanced.getRemoteProgram());
- }
-
- if (!advanced.getWorkDir().isEmpty()) {
- args.add("/shell-dir:" + advanced.getWorkDir());
- }
-
- args.add(addFlag("async-channels", debug.getAsyncChannel()));
- args.add(addFlag("async-input", debug.getAsyncInput()));
- args.add(addFlag("async-update", debug.getAsyncUpdate()));
-
- if (advanced.getRedirectSDCard()) {
- String path = android.os.Environment.getExternalStorageDirectory().getPath();
- args.add("/drive:sdcard," + path);
- }
-
- args.add("/clipboard");
-
- // Gateway enabled?
- if (bookmark.getType() == BookmarkBase.TYPE_MANUAL && bookmark.get().getEnableGatewaySettings()) {
- ManualBookmark.GatewaySettings gateway = bookmark.get().getGatewaySettings();
-
- args.add(String.format("/g:%s:%d", gateway.getHostname(), gateway.getPort()));
-
- arg = gateway.getUsername();
- if (!arg.isEmpty()) {
- args.add("/gu:" + arg);
- }
- arg = gateway.getDomain();
- if (!arg.isEmpty()) {
- args.add("/gd:" + arg);
- }
- arg = gateway.getPassword();
- if (!arg.isEmpty()) {
- args.add("/gp:" + arg);
- }
- }
-
- /* 0 ... local
- 1 ... remote
- 2 ... disable */
- args.add("/audio-mode:" + String.valueOf(advanced.getRedirectSound()));
- if (advanced.getRedirectSound() == 0) {
- args.add("/sound");
- }
-
- if (advanced.getRedirectMicrophone()) {
- args.add("/microphone");
- }
-
- args.add("/cert-ignore");
- args.add("/log-level:" + debug.getDebugLevel());
- String[] arrayArgs = args.toArray(new String[args.size()]);
- return freerdp_parse_arguments(inst, arrayArgs);
- }
-
- public static boolean setConnectionInfo(Context context, long inst, Uri openUri) {
- ArrayList args = new ArrayList<>();
-
- // Parse URI from query string. Same key overwrite previous one
- // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
-
- // Now we only support Software GDI
- args.add(TAG);
- args.add("/gdi:sw");
-
- final String clientName = ApplicationSettingsActivity.getClientName(context);
- if (!clientName.isEmpty()) {
- args.add("/client-hostname:" + clientName);
- }
-
- // Parse hostname and port. Set to 'v' argument
- String hostname = openUri.getHost();
- int port = openUri.getPort();
- if (hostname != null) {
- hostname = hostname + ((port == -1) ? "" : (":" + String.valueOf(port)));
- args.add("/v:" + hostname);
- }
-
- String user = openUri.getUserInfo();
- if (user != null) {
- args.add("/u:" + user);
- }
-
- for (String key : openUri.getQueryParameterNames()) {
- String value = openUri.getQueryParameter(key);
-
- if (value.isEmpty()) {
- // Query: key=
- // To freerdp argument: /key
- args.add("/" + key);
- } else if (value.equals("-") || value.equals("+")) {
- // Query: key=- or key=+
- // To freerdp argument: -key or +key
- args.add(value + key);
- } else {
- // Query: key=value
- // To freerdp argument: /key:value
- if (key.equals("drive") && value.equals("sdcard")) {
- // Special for sdcard redirect
- String path = android.os.Environment.getExternalStorageDirectory().getPath();
- value = "sdcard," + path;
- }
-
- args.add("/" + key + ":" + value);
- }
- }
-
- String[] arrayArgs = args.toArray(new String[args.size()]);
- return freerdp_parse_arguments(inst, arrayArgs);
- }
-
- public static boolean updateGraphics(long inst, Bitmap bitmap, int x, int y, int width, int height) {
- return freerdp_update_graphics(inst, bitmap, x, y, width, height);
- }
-
- public static boolean sendCursorEvent(long inst, int x, int y, int flags) {
- return freerdp_send_cursor_event(inst, x, y, flags);
- }
-
- public static boolean sendKeyEvent(long inst, int keycode, boolean down) {
- return freerdp_send_key_event(inst, keycode, down);
- }
-
- public static boolean sendUnicodeKeyEvent(long inst, int keycode, boolean down) {
- return freerdp_send_unicodekey_event(inst, keycode, down);
- }
-
- public static boolean sendClipboardData(long inst, String data) {
- return freerdp_send_clipboard_data(inst, data);
- }
-
- private static void OnConnectionSuccess(long inst) {
- if (listener != null)
- listener.OnConnectionSuccess(inst);
- synchronized (mInstanceState) {
- mInstanceState.append(inst, true);
- mInstanceState.notifyAll();
- }
- }
-
- private static void OnConnectionFailure(long inst) {
- if (listener != null)
- listener.OnConnectionFailure(inst);
- synchronized (mInstanceState) {
- mInstanceState.remove(inst);
- mInstanceState.notifyAll();
- }
- }
-
- private static void OnPreConnect(long inst) {
- if (listener != null)
- listener.OnPreConnect(inst);
- }
-
- private static void OnDisconnecting(long inst) {
- if (listener != null)
- listener.OnDisconnecting(inst);
- }
-
- private static void OnDisconnected(long inst) {
- if (listener != null)
- listener.OnDisconnected(inst);
- synchronized (mInstanceState) {
- mInstanceState.remove(inst);
- mInstanceState.notifyAll();
- }
- }
-
- private static void OnSettingsChanged(long inst, int width, int height, int bpp) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- uiEventListener.OnSettingsChanged(width, height, bpp);
- }
-
- private static boolean OnAuthenticate(long inst, StringBuilder username, StringBuilder domain, StringBuilder password) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return false;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- return uiEventListener.OnAuthenticate(username, domain, password);
- return false;
- }
-
- private static boolean OnGatewayAuthenticate(long inst, StringBuilder username, StringBuilder
- domain, StringBuilder password) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return false;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- return uiEventListener.OnGatewayAuthenticate(username, domain, password);
- return false;
- }
-
- private static int OnVerifyCertificate(long inst, String commonName, String subject,
- String issuer, String fingerprint, boolean
- hostMismatch) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return 0;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- return uiEventListener.OnVerifiyCertificate(commonName, subject, issuer, fingerprint,
- hostMismatch);
- return 0;
- }
-
- private static int OnVerifyChangedCertificate(long inst, String commonName, String subject,
- String issuer, String fingerprint, String oldSubject,
- String oldIssuer, String oldFingerprint) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return 0;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- return uiEventListener.OnVerifyChangedCertificate(commonName, subject, issuer,
- fingerprint, oldSubject, oldIssuer, oldFingerprint);
- return 0;
- }
-
- private static void OnGraphicsUpdate(long inst, int x, int y, int width, int height) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- uiEventListener.OnGraphicsUpdate(x, y, width, height);
- }
-
- private static void OnGraphicsResize(long inst, int width, int height, int bpp) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- uiEventListener.OnGraphicsResize(width, height, bpp);
- }
-
- private static void OnRemoteClipboardChanged(long inst, String data) {
- SessionState s = GlobalApp.getSession(inst);
- if (s == null)
- return;
- UIEventListener uiEventListener = s.getUIEventListener();
- if (uiEventListener != null)
- uiEventListener.OnRemoteClipboardChanged(data);
- }
-
- public static String getVersion() {
- return freerdp_get_version();
- }
-
- public static interface EventListener {
- void OnPreConnect(long instance);
-
- void OnConnectionSuccess(long instance);
-
- void OnConnectionFailure(long instance);
-
- void OnDisconnecting(long instance);
-
- void OnDisconnected(long instance);
- }
-
- public static interface UIEventListener {
- void OnSettingsChanged(int width, int height, int bpp);
-
- boolean OnAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password);
-
- boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder
- password);
-
- int OnVerifiyCertificate(String commonName, String subject,
- String issuer, String fingerprint, boolean mismatch);
-
- int OnVerifyChangedCertificate(String commonName, String subject,
- String issuer, String fingerprint, String oldSubject,
- String oldIssuer, String oldFingerprint);
-
- void OnGraphicsUpdate(int x, int y, int width, int height);
-
- void OnGraphicsResize(int width, int height, int bpp);
-
- void OnRemoteClipboardChanged(String data);
- }
+public class LibFreeRDP
+{
+ private static final String TAG = "LibFreeRDP";
+ private static EventListener listener;
+ private static boolean mHasH264 = true;
+
+ private static final LongSparseArray mInstanceState = new LongSparseArray<>();
+
+ static
+ {
+ final String h264 = "openh264";
+ final String[] libraries = { h264,
+ "freerdp-openssl",
+ "jpeg",
+ "winpr2",
+ "freerdp2",
+ "freerdp-client2",
+ "freerdp-android2" };
+ final String LD_PATH = System.getProperty("java.library.path");
+
+ for (String lib : libraries)
+ {
+ try
+ {
+ Log.v(TAG, "Trying to load library " + lib + " from LD_PATH: " + LD_PATH);
+ System.loadLibrary(lib);
+ }
+ catch (UnsatisfiedLinkError e)
+ {
+ Log.e(TAG, "Failed to load library " + lib + ": " + e.toString());
+ if (lib.equals(h264))
+ {
+ mHasH264 = false;
+ }
+ }
+ }
+ }
+
+ public static boolean hasH264Support()
+ {
+ return mHasH264;
+ }
+
+ private static native String freerdp_get_jni_version();
+
+ private static native String freerdp_get_version();
+
+ private static native String freerdp_get_build_date();
+
+ private static native String freerdp_get_build_revision();
+
+ private static native String freerdp_get_build_config();
+
+ private static native long freerdp_new(Context context);
+
+ private static native void freerdp_free(long inst);
+
+ private static native boolean freerdp_parse_arguments(long inst, String[] args);
+
+ private static native boolean freerdp_connect(long inst);
+
+ private static native boolean freerdp_disconnect(long inst);
+
+ private static native boolean freerdp_update_graphics(long inst, Bitmap bitmap, int x, int y,
+ int width, int height);
+
+ private static native boolean freerdp_send_cursor_event(long inst, int x, int y, int flags);
+
+ private static native boolean freerdp_send_key_event(long inst, int keycode, boolean down);
+
+ private static native boolean freerdp_send_unicodekey_event(long inst, int keycode,
+ boolean down);
+
+ private static native boolean freerdp_send_clipboard_data(long inst, String data);
+
+ private static native String freerdp_get_last_error_string(long inst);
+
+ public static void setEventListener(EventListener l)
+ {
+ listener = l;
+ }
+
+ public static long newInstance(Context context)
+ {
+ return freerdp_new(context);
+ }
+
+ public static void freeInstance(long inst)
+ {
+ synchronized (mInstanceState)
+ {
+ if (mInstanceState.get(inst, false))
+ {
+ freerdp_disconnect(inst);
+ }
+ while (mInstanceState.get(inst, false))
+ {
+ try
+ {
+ mInstanceState.wait();
+ }
+ catch (InterruptedException e)
+ {
+ throw new RuntimeException();
+ }
+ }
+ }
+ freerdp_free(inst);
+ }
+
+ public static boolean connect(long inst)
+ {
+ synchronized (mInstanceState)
+ {
+ if (mInstanceState.get(inst, false))
+ {
+ throw new RuntimeException("instance already connected");
+ }
+ }
+ return freerdp_connect(inst);
+ }
+
+ public static boolean disconnect(long inst)
+ {
+ synchronized (mInstanceState)
+ {
+ if (mInstanceState.get(inst, false))
+ {
+ return freerdp_disconnect(inst);
+ }
+ return true;
+ }
+ }
+
+ public static boolean cancelConnection(long inst)
+ {
+ synchronized (mInstanceState)
+ {
+ if (mInstanceState.get(inst, false))
+ {
+ return freerdp_disconnect(inst);
+ }
+ return true;
+ }
+ }
+
+ private static String addFlag(String name, boolean enabled)
+ {
+ if (enabled)
+ {
+ return "+" + name;
+ }
+ return "-" + name;
+ }
+
+ public static boolean setConnectionInfo(Context context, long inst, BookmarkBase bookmark)
+ {
+ BookmarkBase.ScreenSettings screenSettings = bookmark.getActiveScreenSettings();
+ BookmarkBase.AdvancedSettings advanced = bookmark.getAdvancedSettings();
+ BookmarkBase.DebugSettings debug = bookmark.getDebugSettings();
+
+ String arg;
+ ArrayList args = new ArrayList();
+
+ args.add(TAG);
+ args.add("/gdi:sw");
+
+ final String clientName = ApplicationSettingsActivity.getClientName(context);
+ if (!clientName.isEmpty())
+ {
+ args.add("/client-hostname:" + clientName);
+ }
+ String certName = "";
+ if (bookmark.getType() != BookmarkBase.TYPE_MANUAL)
+ {
+ return false;
+ }
+
+ int port = bookmark.get().getPort();
+ String hostname = bookmark.get().getHostname();
+
+ args.add("/v:" + hostname);
+ args.add("/port:" + String.valueOf(port));
+
+ arg = bookmark.getUsername();
+ if (!arg.isEmpty())
+ {
+ args.add("/u:" + arg);
+ }
+ arg = bookmark.getDomain();
+ if (!arg.isEmpty())
+ {
+ args.add("/d:" + arg);
+ }
+ arg = bookmark.getPassword();
+ if (!arg.isEmpty())
+ {
+ args.add("/p:" + arg);
+ }
+
+ args.add(
+ String.format("/size:%dx%d", screenSettings.getWidth(), screenSettings.getHeight()));
+ args.add("/bpp:" + String.valueOf(screenSettings.getColors()));
+
+ if (advanced.getConsoleMode())
+ {
+ args.add("/admin");
+ }
+
+ switch (advanced.getSecurity())
+ {
+ case 3: // NLA
+ args.add("/sec-nla");
+ break;
+ case 2: // TLS
+ args.add("/sec-tls");
+ break;
+ case 1: // RDP
+ args.add("/sec-rdp");
+ break;
+ default:
+ break;
+ }
+
+ if (!certName.isEmpty())
+ {
+ args.add("/cert-name:" + certName);
+ }
+
+ BookmarkBase.PerformanceFlags flags = bookmark.getActivePerformanceFlags();
+ if (flags.getRemoteFX())
+ {
+ args.add("/rfx");
+ }
+
+ if (flags.getGfx())
+ {
+ args.add("/gfx");
+ }
+
+ if (flags.getH264() && mHasH264)
+ {
+ args.add("/gfx:AVC444");
+ }
+
+ args.add(addFlag("wallpaper", flags.getWallpaper()));
+ args.add(addFlag("window-drag", flags.getFullWindowDrag()));
+ args.add(addFlag("menu-anims", flags.getMenuAnimations()));
+ args.add(addFlag("themes", flags.getTheming()));
+ args.add(addFlag("fonts", flags.getFontSmoothing()));
+ args.add(addFlag("aero", flags.getDesktopComposition()));
+ args.add(addFlag("glyph-cache", false));
+
+ if (!advanced.getRemoteProgram().isEmpty())
+ {
+ args.add("/shell:" + advanced.getRemoteProgram());
+ }
+
+ if (!advanced.getWorkDir().isEmpty())
+ {
+ args.add("/shell-dir:" + advanced.getWorkDir());
+ }
+
+ args.add(addFlag("async-channels", debug.getAsyncChannel()));
+ args.add(addFlag("async-input", debug.getAsyncInput()));
+ args.add(addFlag("async-update", debug.getAsyncUpdate()));
+
+ if (advanced.getRedirectSDCard())
+ {
+ String path = android.os.Environment.getExternalStorageDirectory().getPath();
+ args.add("/drive:sdcard," + path);
+ }
+
+ args.add("/clipboard");
+
+ // Gateway enabled?
+ if (bookmark.getType() == BookmarkBase.TYPE_MANUAL &&
+ bookmark.get().getEnableGatewaySettings())
+ {
+ ManualBookmark.GatewaySettings gateway =
+ bookmark.get().getGatewaySettings();
+
+ args.add(String.format("/g:%s:%d", gateway.getHostname(), gateway.getPort()));
+
+ arg = gateway.getUsername();
+ if (!arg.isEmpty())
+ {
+ args.add("/gu:" + arg);
+ }
+ arg = gateway.getDomain();
+ if (!arg.isEmpty())
+ {
+ args.add("/gd:" + arg);
+ }
+ arg = gateway.getPassword();
+ if (!arg.isEmpty())
+ {
+ args.add("/gp:" + arg);
+ }
+ }
+
+ /* 0 ... local
+ 1 ... remote
+ 2 ... disable */
+ args.add("/audio-mode:" + String.valueOf(advanced.getRedirectSound()));
+ if (advanced.getRedirectSound() == 0)
+ {
+ args.add("/sound");
+ }
+
+ if (advanced.getRedirectMicrophone())
+ {
+ args.add("/microphone");
+ }
+
+ args.add("/cert-ignore");
+ args.add("/log-level:" + debug.getDebugLevel());
+ String[] arrayArgs = args.toArray(new String[args.size()]);
+ return freerdp_parse_arguments(inst, arrayArgs);
+ }
+
+ public static boolean setConnectionInfo(Context context, long inst, Uri openUri)
+ {
+ ArrayList args = new ArrayList<>();
+
+ // Parse URI from query string. Same key overwrite previous one
+ // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
+
+ // Now we only support Software GDI
+ args.add(TAG);
+ args.add("/gdi:sw");
+
+ final String clientName = ApplicationSettingsActivity.getClientName(context);
+ if (!clientName.isEmpty())
+ {
+ args.add("/client-hostname:" + clientName);
+ }
+
+ // Parse hostname and port. Set to 'v' argument
+ String hostname = openUri.getHost();
+ int port = openUri.getPort();
+ if (hostname != null)
+ {
+ hostname = hostname + ((port == -1) ? "" : (":" + String.valueOf(port)));
+ args.add("/v:" + hostname);
+ }
+
+ String user = openUri.getUserInfo();
+ if (user != null)
+ {
+ args.add("/u:" + user);
+ }
+
+ for (String key : openUri.getQueryParameterNames())
+ {
+ String value = openUri.getQueryParameter(key);
+
+ if (value.isEmpty())
+ {
+ // Query: key=
+ // To freerdp argument: /key
+ args.add("/" + key);
+ }
+ else if (value.equals("-") || value.equals("+"))
+ {
+ // Query: key=- or key=+
+ // To freerdp argument: -key or +key
+ args.add(value + key);
+ }
+ else
+ {
+ // Query: key=value
+ // To freerdp argument: /key:value
+ if (key.equals("drive") && value.equals("sdcard"))
+ {
+ // Special for sdcard redirect
+ String path = android.os.Environment.getExternalStorageDirectory().getPath();
+ value = "sdcard," + path;
+ }
+
+ args.add("/" + key + ":" + value);
+ }
+ }
+
+ String[] arrayArgs = args.toArray(new String[args.size()]);
+ return freerdp_parse_arguments(inst, arrayArgs);
+ }
+
+ public static boolean updateGraphics(long inst, Bitmap bitmap, int x, int y, int width,
+ int height)
+ {
+ return freerdp_update_graphics(inst, bitmap, x, y, width, height);
+ }
+
+ public static boolean sendCursorEvent(long inst, int x, int y, int flags)
+ {
+ return freerdp_send_cursor_event(inst, x, y, flags);
+ }
+
+ public static boolean sendKeyEvent(long inst, int keycode, boolean down)
+ {
+ return freerdp_send_key_event(inst, keycode, down);
+ }
+
+ public static boolean sendUnicodeKeyEvent(long inst, int keycode, boolean down)
+ {
+ return freerdp_send_unicodekey_event(inst, keycode, down);
+ }
+
+ public static boolean sendClipboardData(long inst, String data)
+ {
+ return freerdp_send_clipboard_data(inst, data);
+ }
+
+ private static void OnConnectionSuccess(long inst)
+ {
+ if (listener != null)
+ listener.OnConnectionSuccess(inst);
+ synchronized (mInstanceState)
+ {
+ mInstanceState.append(inst, true);
+ mInstanceState.notifyAll();
+ }
+ }
+
+ private static void OnConnectionFailure(long inst)
+ {
+ if (listener != null)
+ listener.OnConnectionFailure(inst);
+ synchronized (mInstanceState)
+ {
+ mInstanceState.remove(inst);
+ mInstanceState.notifyAll();
+ }
+ }
+
+ private static void OnPreConnect(long inst)
+ {
+ if (listener != null)
+ listener.OnPreConnect(inst);
+ }
+
+ private static void OnDisconnecting(long inst)
+ {
+ if (listener != null)
+ listener.OnDisconnecting(inst);
+ }
+
+ private static void OnDisconnected(long inst)
+ {
+ if (listener != null)
+ listener.OnDisconnected(inst);
+ synchronized (mInstanceState)
+ {
+ mInstanceState.remove(inst);
+ mInstanceState.notifyAll();
+ }
+ }
+
+ private static void OnSettingsChanged(long inst, int width, int height, int bpp)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ uiEventListener.OnSettingsChanged(width, height, bpp);
+ }
+
+ private static boolean OnAuthenticate(long inst, StringBuilder username, StringBuilder domain,
+ StringBuilder password)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return false;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ return uiEventListener.OnAuthenticate(username, domain, password);
+ return false;
+ }
+
+ private static boolean OnGatewayAuthenticate(long inst, StringBuilder username,
+ StringBuilder domain, StringBuilder password)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return false;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ return uiEventListener.OnGatewayAuthenticate(username, domain, password);
+ return false;
+ }
+
+ private static int OnVerifyCertificate(long inst, String commonName, String subject,
+ String issuer, String fingerprint, boolean hostMismatch)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return 0;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ return uiEventListener.OnVerifiyCertificate(commonName, subject, issuer, fingerprint,
+ hostMismatch);
+ return 0;
+ }
+
+ private static int OnVerifyChangedCertificate(long inst, String commonName, String subject,
+ String issuer, String fingerprint,
+ String oldSubject, String oldIssuer,
+ String oldFingerprint)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return 0;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ return uiEventListener.OnVerifyChangedCertificate(
+ commonName, subject, issuer, fingerprint, oldSubject, oldIssuer, oldFingerprint);
+ return 0;
+ }
+
+ private static void OnGraphicsUpdate(long inst, int x, int y, int width, int height)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ uiEventListener.OnGraphicsUpdate(x, y, width, height);
+ }
+
+ private static void OnGraphicsResize(long inst, int width, int height, int bpp)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ uiEventListener.OnGraphicsResize(width, height, bpp);
+ }
+
+ private static void OnRemoteClipboardChanged(long inst, String data)
+ {
+ SessionState s = GlobalApp.getSession(inst);
+ if (s == null)
+ return;
+ UIEventListener uiEventListener = s.getUIEventListener();
+ if (uiEventListener != null)
+ uiEventListener.OnRemoteClipboardChanged(data);
+ }
+
+ public static String getVersion()
+ {
+ return freerdp_get_version();
+ }
+
+ public static interface EventListener {
+ void OnPreConnect(long instance);
+
+ void OnConnectionSuccess(long instance);
+
+ void OnConnectionFailure(long instance);
+
+ void OnDisconnecting(long instance);
+
+ void OnDisconnected(long instance);
+ }
+
+ public static interface UIEventListener {
+ void OnSettingsChanged(int width, int height, int bpp);
+
+ boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
+ StringBuilder password);
+
+ boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain,
+ StringBuilder password);
+
+ int OnVerifiyCertificate(String commonName, String subject, String issuer,
+ String fingerprint, boolean mismatch);
+
+ int OnVerifyChangedCertificate(String commonName, String subject, String issuer,
+ String fingerprint, String oldSubject, String oldIssuer,
+ String oldFingerprint);
+
+ void OnGraphicsUpdate(int x, int y, int width, int height);
+
+ void OnGraphicsResize(int width, int height, int bpp);
+
+ void OnRemoteClipboardChanged(String data);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java
index 64df814d7..2cd275163 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -18,96 +19,113 @@ import com.freerdp.freerdpcore.domain.ManualBookmark;
import java.util.ArrayList;
-public class ManualBookmarkGateway extends BookmarkBaseGateway {
+public class ManualBookmarkGateway extends BookmarkBaseGateway
+{
- public ManualBookmarkGateway(SQLiteOpenHelper bookmarkDB) {
- super(bookmarkDB);
- }
+ public ManualBookmarkGateway(SQLiteOpenHelper bookmarkDB)
+ {
+ super(bookmarkDB);
+ }
- @Override
- protected BookmarkBase createBookmark() {
- return new ManualBookmark();
- }
+ @Override protected BookmarkBase createBookmark()
+ {
+ return new ManualBookmark();
+ }
- @Override
- protected String getBookmarkTableName() {
- return BookmarkDB.DB_TABLE_BOOKMARK;
- }
+ @Override protected String getBookmarkTableName()
+ {
+ return BookmarkDB.DB_TABLE_BOOKMARK;
+ }
- @Override
- protected void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns) {
- ManualBookmark bm = (ManualBookmark) bookmark;
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME, bm.getHostname());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_PORT, bm.getPort());
+ @Override
+ protected void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns)
+ {
+ ManualBookmark bm = (ManualBookmark)bookmark;
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME, bm.getHostname());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_PORT, bm.getPort());
- // gateway settings
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE, bm.getEnableGatewaySettings());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME, bm.getGatewaySettings().getHostname());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT, bm.getGatewaySettings().getPort());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME, bm.getGatewaySettings().getUsername());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD, bm.getGatewaySettings().getPassword());
- columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN, bm.getGatewaySettings().getDomain());
- }
+ // gateway settings
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE, bm.getEnableGatewaySettings());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME, bm.getGatewaySettings().getHostname());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT, bm.getGatewaySettings().getPort());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME, bm.getGatewaySettings().getUsername());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD, bm.getGatewaySettings().getPassword());
+ columns.put(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN, bm.getGatewaySettings().getDomain());
+ }
- @Override
- protected void addBookmarkSpecificColumns(ArrayList columns) {
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_PORT);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD);
- columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN);
- }
+ @Override protected void addBookmarkSpecificColumns(ArrayList columns)
+ {
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_PORT);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD);
+ columns.add(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN);
+ }
- @Override
- protected void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor) {
- ManualBookmark bm = (ManualBookmark) bookmark;
- bm.setHostname(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME)));
- bm.setPort(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_PORT)));
+ @Override protected void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor)
+ {
+ ManualBookmark bm = (ManualBookmark)bookmark;
+ bm.setHostname(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME)));
+ bm.setPort(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_PORT)));
- bm.setEnableGatewaySettings(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE)) != 0);
- readGatewaySettings(bm, cursor);
- }
+ bm.setEnableGatewaySettings(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE)) != 0);
+ readGatewaySettings(bm, cursor);
+ }
- public BookmarkBase findByLabelOrHostname(String pattern) {
- if (pattern.length() == 0)
- return null;
+ public BookmarkBase findByLabelOrHostname(String pattern)
+ {
+ if (pattern.length() == 0)
+ return null;
- Cursor cursor = queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " = '" + pattern +
- "' OR " + BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME + " = '" + pattern + "'",
- BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- BookmarkBase bookmark = null;
- if (cursor.moveToFirst() && (cursor.getCount() > 0))
- bookmark = getBookmarkFromCursor(cursor);
+ Cursor cursor =
+ queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " = '" + pattern + "' OR " +
+ BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME + " = '" + pattern + "'",
+ BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ BookmarkBase bookmark = null;
+ if (cursor.moveToFirst() && (cursor.getCount() > 0))
+ bookmark = getBookmarkFromCursor(cursor);
- cursor.close();
- return bookmark;
- }
+ cursor.close();
+ return bookmark;
+ }
- public ArrayList findByLabelOrHostnameLike(String pattern) {
- Cursor cursor = queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " LIKE '%" +
- pattern + "%' OR " + BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME + " LIKE '%" +
- pattern + "%'", BookmarkDB.DB_KEY_BOOKMARK_LABEL);
- ArrayList bookmarks = new ArrayList(cursor.getCount());
+ public ArrayList findByLabelOrHostnameLike(String pattern)
+ {
+ Cursor cursor =
+ queryBookmarks(BookmarkDB.DB_KEY_BOOKMARK_LABEL + " LIKE '%" + pattern + "%' OR " +
+ BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME + " LIKE '%" + pattern + "%'",
+ BookmarkDB.DB_KEY_BOOKMARK_LABEL);
+ ArrayList bookmarks = new ArrayList(cursor.getCount());
- if (cursor.moveToFirst() && (cursor.getCount() > 0)) {
- do {
- bookmarks.add(getBookmarkFromCursor(cursor));
- } while (cursor.moveToNext());
- }
+ if (cursor.moveToFirst() && (cursor.getCount() > 0))
+ {
+ do
+ {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
- cursor.close();
- return bookmarks;
- }
+ cursor.close();
+ return bookmarks;
+ }
- private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor) {
- ManualBookmark.GatewaySettings gatewaySettings = bookmark.getGatewaySettings();
- gatewaySettings.setHostname(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME)));
- gatewaySettings.setPort(cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT)));
- gatewaySettings.setUsername(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME)));
- gatewaySettings.setPassword(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD)));
- gatewaySettings.setDomain(cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN)));
- }
+ private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor)
+ {
+ ManualBookmark.GatewaySettings gatewaySettings = bookmark.getGatewaySettings();
+ gatewaySettings.setHostname(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME)));
+ gatewaySettings.setPort(
+ cursor.getInt(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_PORT)));
+ gatewaySettings.setUsername(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME)));
+ gatewaySettings.setPassword(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD)));
+ gatewaySettings.setDomain(
+ cursor.getString(cursor.getColumnIndex(BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN)));
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/QuickConnectHistoryGateway.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/QuickConnectHistoryGateway.java
index 7d97243f3..4dd51398f 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/QuickConnectHistoryGateway.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/QuickConnectHistoryGateway.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -21,76 +22,100 @@ import com.freerdp.freerdpcore.domain.QuickConnectBookmark;
import java.util.ArrayList;
+public class QuickConnectHistoryGateway
+{
+ private final static String TAG = "QuickConnectHistoryGateway";
+ private SQLiteOpenHelper historyDB;
-public class QuickConnectHistoryGateway {
- private final static String TAG = "QuickConnectHistoryGateway";
- private SQLiteOpenHelper historyDB;
+ public QuickConnectHistoryGateway(SQLiteOpenHelper historyDB)
+ {
+ this.historyDB = historyDB;
+ }
+ public ArrayList findHistory(String filter)
+ {
+ String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
- public QuickConnectHistoryGateway(SQLiteOpenHelper historyDB) {
- this.historyDB = historyDB;
- }
+ SQLiteDatabase db = getReadableDatabase();
+ String selection =
+ (filter.length() > 0)
+ ? (HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " LIKE '%" + filter + "%'")
+ : null;
+ Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, selection, null, null,
+ null, HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP);
- public ArrayList findHistory(String filter) {
- String[] column = {HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM};
+ ArrayList result = new ArrayList(cursor.getCount());
+ if (cursor.moveToFirst())
+ {
+ do
+ {
+ String hostname =
+ cursor.getString(cursor.getColumnIndex(HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM));
+ QuickConnectBookmark bookmark = new QuickConnectBookmark();
+ bookmark.setLabel(hostname);
+ bookmark.setHostname(hostname);
+ result.add(bookmark);
+ } while (cursor.moveToNext());
+ }
+ cursor.close();
+ return result;
+ }
- SQLiteDatabase db = getReadableDatabase();
- String selection = (filter.length() > 0) ? (HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " LIKE '%" + filter + "%'") : null;
- Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, selection, null, null, null, HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP);
+ public void addHistoryItem(String item)
+ {
+ String insertHistoryItem = "INSERT OR REPLACE INTO " + HistoryDB.QUICK_CONNECT_TABLE_NAME +
+ " (" + HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + ", " +
+ HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP + ") VALUES('" +
+ item + "', datetime('now'))";
+ SQLiteDatabase db = getWritableDatabase();
+ try
+ {
+ db.execSQL(insertHistoryItem);
+ }
+ catch (SQLException e)
+ {
+ Log.v(TAG, e.toString());
+ }
+ }
- ArrayList result = new ArrayList(cursor.getCount());
- if (cursor.moveToFirst()) {
- do {
- String hostname = cursor.getString(cursor.getColumnIndex(HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM));
- QuickConnectBookmark bookmark = new QuickConnectBookmark();
- bookmark.setLabel(hostname);
- bookmark.setHostname(hostname);
- result.add(bookmark);
- } while (cursor.moveToNext());
- }
- cursor.close();
- return result;
- }
+ public boolean historyItemExists(String item)
+ {
+ String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column,
+ HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + item + "'", null,
+ null, null, null);
+ boolean exists = (cursor.getCount() == 1);
+ cursor.close();
+ return exists;
+ }
- public void addHistoryItem(String item) {
- String insertHistoryItem = "INSERT OR REPLACE INTO " + HistoryDB.QUICK_CONNECT_TABLE_NAME + " (" +
- HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + ", " + HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP + ") VALUES('" + item + "', datetime('now'))";
- SQLiteDatabase db = getWritableDatabase();
- try {
- db.execSQL(insertHistoryItem);
- } catch (SQLException e) {
- Log.v(TAG, e.toString());
- }
- }
+ public void removeHistoryItem(String hostname)
+ {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(HistoryDB.QUICK_CONNECT_TABLE_NAME,
+ HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + hostname + "'", null);
+ }
- public boolean historyItemExists(String item) {
- String[] column = {HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM};
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + item + "'", null, null, null, null);
- boolean exists = (cursor.getCount() == 1);
- cursor.close();
- return exists;
- }
+ // safety wrappers
+ // in case of getReadableDatabase it could happen that upgradeDB gets called which is
+ // a problem if the DB is only readable
+ private SQLiteDatabase getWritableDatabase()
+ {
+ return historyDB.getWritableDatabase();
+ }
- public void removeHistoryItem(String hostname) {
- SQLiteDatabase db = getWritableDatabase();
- db.delete(HistoryDB.QUICK_CONNECT_TABLE_NAME, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + hostname + "'", null);
- }
-
- // safety wrappers
- // in case of getReadableDatabase it could happen that upgradeDB gets called which is
- // a problem if the DB is only readable
- private SQLiteDatabase getWritableDatabase() {
- return historyDB.getWritableDatabase();
- }
-
- private SQLiteDatabase getReadableDatabase() {
- SQLiteDatabase db;
- try {
- db = historyDB.getReadableDatabase();
- } catch (SQLiteException e) {
- db = historyDB.getWritableDatabase();
- }
- return db;
- }
+ private SQLiteDatabase getReadableDatabase()
+ {
+ SQLiteDatabase db;
+ try
+ {
+ db = historyDB.getReadableDatabase();
+ }
+ catch (SQLiteException e)
+ {
+ db = historyDB.getWritableDatabase();
+ }
+ return db;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/SessionRequestHandlerActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/SessionRequestHandlerActivity.java
index 6239acadd..772b3a3ef 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/SessionRequestHandlerActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/SessionRequestHandlerActivity.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.services;
@@ -19,54 +20,58 @@ import com.freerdp.freerdpcore.domain.ConnectionReference;
import com.freerdp.freerdpcore.presentation.BookmarkActivity;
import com.freerdp.freerdpcore.presentation.SessionActivity;
+public class SessionRequestHandlerActivity extends AppCompatActivity
+{
-public class SessionRequestHandlerActivity extends AppCompatActivity {
+ @Override public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ handleIntent(getIntent());
+ }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- handleIntent(getIntent());
- }
+ @Override protected void onNewIntent(Intent intent)
+ {
+ setIntent(intent);
+ handleIntent(intent);
+ }
- @Override
- protected void onNewIntent(Intent intent) {
- setIntent(intent);
- handleIntent(intent);
- }
+ private void startSessionWithConnectionReference(String refStr)
+ {
- private void startSessionWithConnectionReference(String refStr) {
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent sessionIntent = new Intent(this, SessionActivity.class);
+ sessionIntent.putExtras(bundle);
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent sessionIntent = new Intent(this, SessionActivity.class);
- sessionIntent.putExtras(bundle);
+ startActivityForResult(sessionIntent, 0);
+ }
- startActivityForResult(sessionIntent, 0);
- }
+ private void editBookmarkWithConnectionReference(String refStr)
+ {
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivityForResult(bookmarkIntent, 0);
+ }
- private void editBookmarkWithConnectionReference(String refStr) {
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivityForResult(bookmarkIntent, 0);
- }
+ private void handleIntent(Intent intent)
+ {
- private void handleIntent(Intent intent) {
+ String action = intent.getAction();
+ if (Intent.ACTION_SEARCH.equals(action))
+ startSessionWithConnectionReference(ConnectionReference.getHostnameReference(
+ intent.getStringExtra(SearchManager.QUERY)));
+ else if (Intent.ACTION_VIEW.equals(action))
+ startSessionWithConnectionReference(intent.getDataString());
+ else if (Intent.ACTION_EDIT.equals(action))
+ editBookmarkWithConnectionReference(intent.getDataString());
+ }
- String action = intent.getAction();
- if (Intent.ACTION_SEARCH.equals(action))
- startSessionWithConnectionReference(ConnectionReference.getHostnameReference(intent.getStringExtra(SearchManager.QUERY)));
- else if (Intent.ACTION_VIEW.equals(action))
- startSessionWithConnectionReference(intent.getDataString());
- else if (Intent.ACTION_EDIT.equals(action))
- editBookmarkWithConnectionReference(intent.getDataString());
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- this.setResult(resultCode);
- this.finish();
- }
+ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ super.onActivityResult(requestCode, resultCode, data);
+ this.setResult(resultCode);
+ this.finish();
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/AppCompatPreferenceActivity.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/AppCompatPreferenceActivity.java
index 3e7aaa3cb..73377fa59 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/AppCompatPreferenceActivity.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/AppCompatPreferenceActivity.java
@@ -13,95 +13,100 @@ import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
-public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
+public abstract class AppCompatPreferenceActivity extends PreferenceActivity
+{
- private AppCompatDelegate mDelegate;
+ private AppCompatDelegate mDelegate;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- getDelegate().installViewFactory();
- getDelegate().onCreate(savedInstanceState);
- super.onCreate(savedInstanceState);
- }
+ @Override protected void onCreate(Bundle savedInstanceState)
+ {
+ getDelegate().installViewFactory();
+ getDelegate().onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
+ }
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- getDelegate().onPostCreate(savedInstanceState);
- }
+ @Override protected void onPostCreate(Bundle savedInstanceState)
+ {
+ super.onPostCreate(savedInstanceState);
+ getDelegate().onPostCreate(savedInstanceState);
+ }
- public ActionBar getSupportActionBar() {
- return getDelegate().getSupportActionBar();
- }
+ public ActionBar getSupportActionBar()
+ {
+ return getDelegate().getSupportActionBar();
+ }
- public void setSupportActionBar(@Nullable Toolbar toolbar) {
- getDelegate().setSupportActionBar(toolbar);
- }
+ public void setSupportActionBar(@Nullable Toolbar toolbar)
+ {
+ getDelegate().setSupportActionBar(toolbar);
+ }
- @Override
- @NonNull
- public MenuInflater getMenuInflater() {
- return getDelegate().getMenuInflater();
- }
+ @Override @NonNull public MenuInflater getMenuInflater()
+ {
+ return getDelegate().getMenuInflater();
+ }
- @Override
- public void setContentView(@LayoutRes int layoutResID) {
- getDelegate().setContentView(layoutResID);
- }
+ @Override public void setContentView(@LayoutRes int layoutResID)
+ {
+ getDelegate().setContentView(layoutResID);
+ }
- @Override
- public void setContentView(View view) {
- getDelegate().setContentView(view);
- }
+ @Override public void setContentView(View view)
+ {
+ getDelegate().setContentView(view);
+ }
- @Override
- public void setContentView(View view, ViewGroup.LayoutParams params) {
- getDelegate().setContentView(view, params);
- }
+ @Override public void setContentView(View view, ViewGroup.LayoutParams params)
+ {
+ getDelegate().setContentView(view, params);
+ }
- @Override
- public void addContentView(View view, ViewGroup.LayoutParams params) {
- getDelegate().addContentView(view, params);
- }
+ @Override public void addContentView(View view, ViewGroup.LayoutParams params)
+ {
+ getDelegate().addContentView(view, params);
+ }
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getDelegate().onPostResume();
- }
+ @Override protected void onPostResume()
+ {
+ super.onPostResume();
+ getDelegate().onPostResume();
+ }
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- super.onTitleChanged(title, color);
- getDelegate().setTitle(title);
- }
+ @Override protected void onTitleChanged(CharSequence title, int color)
+ {
+ super.onTitleChanged(title, color);
+ getDelegate().setTitle(title);
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getDelegate().onConfigurationChanged(newConfig);
- }
+ @Override public void onConfigurationChanged(Configuration newConfig)
+ {
+ super.onConfigurationChanged(newConfig);
+ getDelegate().onConfigurationChanged(newConfig);
+ }
- @Override
- protected void onStop() {
- super.onStop();
- getDelegate().onStop();
- }
+ @Override protected void onStop()
+ {
+ super.onStop();
+ getDelegate().onStop();
+ }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- getDelegate().onDestroy();
- }
+ @Override protected void onDestroy()
+ {
+ super.onDestroy();
+ getDelegate().onDestroy();
+ }
- public void invalidateOptionsMenu() {
- getDelegate().invalidateOptionsMenu();
- }
+ public void invalidateOptionsMenu()
+ {
+ getDelegate().invalidateOptionsMenu();
+ }
- private AppCompatDelegate getDelegate() {
- if (mDelegate == null) {
- mDelegate = AppCompatDelegate.create(this, null);
- }
- return mDelegate;
- }
+ private AppCompatDelegate getDelegate()
+ {
+ if (mDelegate == null)
+ {
+ mDelegate = AppCompatDelegate.create(this, null);
+ }
+ return mDelegate;
+ }
}
\ No newline at end of file
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/BookmarkArrayAdapter.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/BookmarkArrayAdapter.java
index 4968c571a..6c6de6acc 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/BookmarkArrayAdapter.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/BookmarkArrayAdapter.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -29,89 +30,106 @@ import com.freerdp.freerdpcore.presentation.BookmarkActivity;
import java.util.List;
-public class BookmarkArrayAdapter extends ArrayAdapter {
+public class BookmarkArrayAdapter extends ArrayAdapter
+{
- public BookmarkArrayAdapter(Context context, int textViewResourceId, List objects) {
- super(context, textViewResourceId, objects);
- }
+ public BookmarkArrayAdapter(Context context, int textViewResourceId, List objects)
+ {
+ super(context, textViewResourceId, objects);
+ }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View curView = convertView;
- if (curView == null) {
- LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- curView = vi.inflate(R.layout.bookmark_list_item, null);
- }
+ @Override public View getView(int position, View convertView, ViewGroup parent)
+ {
+ View curView = convertView;
+ if (curView == null)
+ {
+ LayoutInflater vi =
+ (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ curView = vi.inflate(R.layout.bookmark_list_item, null);
+ }
- BookmarkBase bookmark = getItem(position);
- TextView label = (TextView) curView.findViewById(R.id.bookmark_text1);
- TextView hostname = (TextView) curView.findViewById(R.id.bookmark_text2);
- ImageView star_icon = (ImageView) curView.findViewById(R.id.bookmark_icon2);
- assert label != null;
- assert hostname != null;
+ BookmarkBase bookmark = getItem(position);
+ TextView label = (TextView)curView.findViewById(R.id.bookmark_text1);
+ TextView hostname = (TextView)curView.findViewById(R.id.bookmark_text2);
+ ImageView star_icon = (ImageView)curView.findViewById(R.id.bookmark_icon2);
+ assert label != null;
+ assert hostname != null;
- label.setText(bookmark.getLabel());
- star_icon.setVisibility(View.VISIBLE);
+ label.setText(bookmark.getLabel());
+ star_icon.setVisibility(View.VISIBLE);
- String refStr;
- if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
- hostname.setText(bookmark.get().getHostname());
- refStr = ConnectionReference.getManualBookmarkReference(bookmark.getId());
- star_icon.setImageResource(R.drawable.icon_star_on);
- } else if (bookmark.getType() == BookmarkBase.TYPE_QUICKCONNECT) {
- // just set an empty hostname (with a blank) - the hostname is already displayed in the label
- // and in case we just set it to "" the textview will shrunk
- hostname.setText(" ");
- refStr = ConnectionReference.getHostnameReference(bookmark.getLabel());
- star_icon.setImageResource(R.drawable.icon_star_off);
- } else if (bookmark.getType() == BookmarkBase.TYPE_PLACEHOLDER) {
- hostname.setText(" ");
- refStr = ConnectionReference.getPlaceholderReference(bookmark.get().getName());
- star_icon.setVisibility(View.GONE);
- } else {
- // unknown bookmark type...
- refStr = "";
- assert false;
- }
+ String refStr;
+ if (bookmark.getType() == BookmarkBase.TYPE_MANUAL)
+ {
+ hostname.setText(bookmark.get().getHostname());
+ refStr = ConnectionReference.getManualBookmarkReference(bookmark.getId());
+ star_icon.setImageResource(R.drawable.icon_star_on);
+ }
+ else if (bookmark.getType() == BookmarkBase.TYPE_QUICKCONNECT)
+ {
+ // just set an empty hostname (with a blank) - the hostname is already displayed in the
+ // label and in case we just set it to "" the textview will shrunk
+ hostname.setText(" ");
+ refStr = ConnectionReference.getHostnameReference(bookmark.getLabel());
+ star_icon.setImageResource(R.drawable.icon_star_off);
+ }
+ else if (bookmark.getType() == BookmarkBase.TYPE_PLACEHOLDER)
+ {
+ hostname.setText(" ");
+ refStr = ConnectionReference.getPlaceholderReference(
+ bookmark.get().getName());
+ star_icon.setVisibility(View.GONE);
+ }
+ else
+ {
+ // unknown bookmark type...
+ refStr = "";
+ assert false;
+ }
- star_icon.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- // start bookmark editor
- Bundle bundle = new Bundle();
- String refStr = v.getTag().toString();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ star_icon.setOnClickListener(new OnClickListener() {
+ @Override public void onClick(View v)
+ {
+ // start bookmark editor
+ Bundle bundle = new Bundle();
+ String refStr = v.getTag().toString();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent bookmarkIntent = new Intent(getContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- getContext().startActivity(bookmarkIntent);
- }
- });
+ Intent bookmarkIntent = new Intent(getContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ getContext().startActivity(bookmarkIntent);
+ }
+ });
- curView.setTag(refStr);
- star_icon.setTag(refStr);
+ curView.setTag(refStr);
+ star_icon.setTag(refStr);
- return curView;
- }
+ return curView;
+ }
- public void addItems(List newItems) {
- for (BookmarkBase item : newItems)
- add(item);
- }
+ public void addItems(List newItems)
+ {
+ for (BookmarkBase item : newItems)
+ add(item);
+ }
- public void replaceItems(List newItems) {
- clear();
- for (BookmarkBase item : newItems)
- add(item);
- }
+ public void replaceItems(List newItems)
+ {
+ clear();
+ for (BookmarkBase item : newItems)
+ add(item);
+ }
- public void remove(long bookmarkId) {
- for (int i = 0; i < getCount(); i++) {
- BookmarkBase bm = getItem(i);
- if (bm.getId() == bookmarkId) {
- remove(bm);
- return;
- }
- }
- }
+ public void remove(long bookmarkId)
+ {
+ for (int i = 0; i < getCount(); i++)
+ {
+ BookmarkBase bm = getItem(i);
+ if (bm.getId() == bookmarkId)
+ {
+ remove(bm);
+ return;
+ }
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ButtonPreference.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ButtonPreference.java
index 7248932a4..72c8cf081 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ButtonPreference.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ButtonPreference.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -20,67 +21,76 @@ import android.widget.LinearLayout;
import com.freerdp.freerdpcore.R;
-public class ButtonPreference extends Preference {
+public class ButtonPreference extends Preference
+{
- private OnClickListener buttonOnClickListener;
- private String buttonText;
- private Button button;
+ private OnClickListener buttonOnClickListener;
+ private String buttonText;
+ private Button button;
- public ButtonPreference(Context context) {
- super(context);
- init();
- }
+ public ButtonPreference(Context context)
+ {
+ super(context);
+ init();
+ }
- public ButtonPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- init();
- }
+ public ButtonPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ init();
+ }
- public ButtonPreference(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init();
- }
+ public ButtonPreference(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ init();
+ }
- private void init() {
- setLayoutResource(R.layout.button_preference);
- button = null;
- buttonText = null;
- buttonOnClickListener = null;
- }
+ private void init()
+ {
+ setLayoutResource(R.layout.button_preference);
+ button = null;
+ buttonText = null;
+ buttonOnClickListener = null;
+ }
- @Override
- public View getView(View convertView, ViewGroup parent) {
- View v = super.getView(convertView, parent);
- button = (Button) v.findViewById(R.id.preference_button);
- if (buttonText != null)
- button.setText(buttonText);
- if (buttonOnClickListener != null)
- button.setOnClickListener(buttonOnClickListener);
+ @Override public View getView(View convertView, ViewGroup parent)
+ {
+ View v = super.getView(convertView, parent);
+ button = (Button)v.findViewById(R.id.preference_button);
+ if (buttonText != null)
+ button.setText(buttonText);
+ if (buttonOnClickListener != null)
+ button.setOnClickListener(buttonOnClickListener);
- // additional init for ICS - make widget frame visible
- // refer to http://stackoverflow.com/questions/8762984/custom-preference-broken-in-honeycomb-ics
- LinearLayout widgetFrameView = ((LinearLayout) v.findViewById(android.R.id.widget_frame));
- widgetFrameView.setVisibility(View.VISIBLE);
+ // additional init for ICS - make widget frame visible
+ // refer to
+ // http://stackoverflow.com/questions/8762984/custom-preference-broken-in-honeycomb-ics
+ LinearLayout widgetFrameView = ((LinearLayout)v.findViewById(android.R.id.widget_frame));
+ widgetFrameView.setVisibility(View.VISIBLE);
- return v;
- }
+ return v;
+ }
- public void setButtonText(int resId) {
- buttonText = getContext().getResources().getString(resId);
- if (button != null)
- button.setText(buttonText);
- }
+ public void setButtonText(int resId)
+ {
+ buttonText = getContext().getResources().getString(resId);
+ if (button != null)
+ button.setText(buttonText);
+ }
- public void setButtonText(String text) {
- buttonText = text;
- if (button != null)
- button.setText(text);
- }
+ public void setButtonText(String text)
+ {
+ buttonText = text;
+ if (button != null)
+ button.setText(text);
+ }
- public void setButtonOnClickListener(OnClickListener listener) {
- if (button != null)
- button.setOnClickListener(listener);
- else
- buttonOnClickListener = listener;
- }
+ public void setButtonOnClickListener(OnClickListener listener)
+ {
+ if (button != null)
+ button.setOnClickListener(listener);
+ else
+ buttonOnClickListener = listener;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java
index dce3b1bc9..cb26ddb38 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java
@@ -7,87 +7,94 @@ import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
-public abstract class ClipboardManagerProxy {
+public abstract class ClipboardManagerProxy
+{
- public static ClipboardManagerProxy getClipboardManager(Context ctx) {
- if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB)
- return new PreHCClipboardManager(ctx);
- else
- return new HCClipboardManager(ctx);
- }
+ public static ClipboardManagerProxy getClipboardManager(Context ctx)
+ {
+ if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB)
+ return new PreHCClipboardManager(ctx);
+ else
+ return new HCClipboardManager(ctx);
+ }
- public abstract void setClipboardData(String data);
+ public abstract void setClipboardData(String data);
- public abstract void addClipboardChangedListener(OnClipboardChangedListener listener);
+ public abstract void addClipboardChangedListener(OnClipboardChangedListener listener);
- public abstract void removeClipboardboardChangedListener(OnClipboardChangedListener listener);
+ public abstract void removeClipboardboardChangedListener(OnClipboardChangedListener listener);
- public static interface OnClipboardChangedListener {
- void onClipboardChanged(String data);
- }
+ public static interface OnClipboardChangedListener {
+ void onClipboardChanged(String data);
+ }
- private static class PreHCClipboardManager extends ClipboardManagerProxy {
+ private static class PreHCClipboardManager extends ClipboardManagerProxy
+ {
- public PreHCClipboardManager(Context ctx) {
+ public PreHCClipboardManager(Context ctx)
+ {
+ }
- }
+ @Override public void setClipboardData(String data)
+ {
+ }
- @Override
- public void setClipboardData(String data) {
- }
+ @Override public void addClipboardChangedListener(OnClipboardChangedListener listener)
+ {
+ }
- @Override
- public void addClipboardChangedListener(
- OnClipboardChangedListener listener) {
- }
+ @Override
+ public void removeClipboardboardChangedListener(OnClipboardChangedListener listener)
+ {
+ }
+ }
- @Override
- public void removeClipboardboardChangedListener(
- OnClipboardChangedListener listener) {
- }
- }
+ @TargetApi(11)
+ private static class HCClipboardManager
+ extends ClipboardManagerProxy implements ClipboardManager.OnPrimaryClipChangedListener
+ {
+ private ClipboardManager mClipboardManager;
+ private OnClipboardChangedListener mListener;
- @TargetApi(11)
- private static class HCClipboardManager extends ClipboardManagerProxy implements ClipboardManager.OnPrimaryClipChangedListener {
- private ClipboardManager mClipboardManager;
- private OnClipboardChangedListener mListener;
+ public HCClipboardManager(Context ctx)
+ {
+ mClipboardManager = (ClipboardManager)ctx.getSystemService(Context.CLIPBOARD_SERVICE);
+ }
- public HCClipboardManager(Context ctx) {
- mClipboardManager = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
- }
+ @Override public void setClipboardData(String data)
+ {
+ mClipboardManager.setPrimaryClip(
+ ClipData.newPlainText("rdp-clipboard", data == null ? "" : data));
+ }
- @Override
- public void setClipboardData(String data) {
- mClipboardManager.setPrimaryClip(ClipData.newPlainText("rdp-clipboard", data == null ? "" : data));
- }
+ @Override public void onPrimaryClipChanged()
+ {
+ ClipData clip = mClipboardManager.getPrimaryClip();
+ String data = null;
- @Override
- public void onPrimaryClipChanged() {
- ClipData clip = mClipboardManager.getPrimaryClip();
- String data = null;
+ if (clip != null && clip.getItemCount() > 0)
+ {
+ CharSequence cs = clip.getItemAt(0).getText();
+ if (cs != null)
+ data = cs.toString();
+ }
+ if (mListener != null)
+ {
+ mListener.onClipboardChanged(data);
+ }
+ }
- if (clip != null && clip.getItemCount() > 0) {
- CharSequence cs = clip.getItemAt(0).getText();
- if (cs != null)
- data = cs.toString();
- }
- if (mListener != null) {
- mListener.onClipboardChanged(data);
- }
- }
+ @Override public void addClipboardChangedListener(OnClipboardChangedListener listener)
+ {
+ mListener = listener;
+ mClipboardManager.addPrimaryClipChangedListener(this);
+ }
- @Override
- public void addClipboardChangedListener(
- OnClipboardChangedListener listener) {
- mListener = listener;
- mClipboardManager.addPrimaryClipChangedListener(this);
- }
-
- @Override
- public void removeClipboardboardChangedListener(
- OnClipboardChangedListener listener) {
- mListener = null;
- mClipboardManager.removePrimaryClipChangedListener(this);
- }
- }
+ @Override
+ public void removeClipboardboardChangedListener(OnClipboardChangedListener listener)
+ {
+ mListener = null;
+ mClipboardManager.removePrimaryClipChangedListener(this);
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/DoubleGestureDetector.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/DoubleGestureDetector.java
index 563bc61a9..2e8dfc881 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/DoubleGestureDetector.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/DoubleGestureDetector.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -16,312 +17,333 @@ import android.view.ScaleGestureDetector;
import com.freerdp.freerdpcore.utils.GestureDetector.OnGestureListener;
-public class DoubleGestureDetector {
- // timeout during that the second finger has to touch the screen before the double finger detection is cancelled
- private static final long DOUBLE_TOUCH_TIMEOUT = 100;
- // timeout during that an UP event will trigger a single double touch event
- private static final long SINGLE_DOUBLE_TOUCH_TIMEOUT = 1000;
- // constants for Message.what used by GestureHandler below
- private static final int TAP = 1;
- // different detection modes
- private static final int MODE_UNKNOWN = 0;
- private static final int MODE_PINCH_ZOOM = 1;
- private static final int MODE_SCROLL = 2;
- private static final int SCROLL_SCORE_TO_REACH = 20;
- private final OnDoubleGestureListener mListener;
- private int mPointerDistanceSquare;
- private int mCurrentMode;
- private int mScrollDetectionScore;
- private ScaleGestureDetector scaleGestureDetector;
- private boolean mCancelDetection;
- private boolean mDoubleInProgress;
- private GestureHandler mHandler;
- private MotionEvent mCurrentDownEvent;
- private MotionEvent mCurrentDoubleDownEvent;
- private MotionEvent mPreviousUpEvent;
- private MotionEvent mPreviousPointerUpEvent;
- /**
- * Creates a GestureDetector with the supplied listener.
- * You may only use this constructor from a UI thread (this is the usual situation).
- *
- * @param context the application's context
- * @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @throws NullPointerException if {@code listener} is null.
- * @see android.os.Handler#Handler()
- */
- public DoubleGestureDetector(Context context, Handler handler, OnDoubleGestureListener listener) {
- mListener = listener;
- init(context, handler);
- }
+public class DoubleGestureDetector
+{
+ // timeout during that the second finger has to touch the screen before the double finger
+ // detection is cancelled
+ private static final long DOUBLE_TOUCH_TIMEOUT = 100;
+ // timeout during that an UP event will trigger a single double touch event
+ private static final long SINGLE_DOUBLE_TOUCH_TIMEOUT = 1000;
+ // constants for Message.what used by GestureHandler below
+ private static final int TAP = 1;
+ // different detection modes
+ private static final int MODE_UNKNOWN = 0;
+ private static final int MODE_PINCH_ZOOM = 1;
+ private static final int MODE_SCROLL = 2;
+ private static final int SCROLL_SCORE_TO_REACH = 20;
+ private final OnDoubleGestureListener mListener;
+ private int mPointerDistanceSquare;
+ private int mCurrentMode;
+ private int mScrollDetectionScore;
+ private ScaleGestureDetector scaleGestureDetector;
+ private boolean mCancelDetection;
+ private boolean mDoubleInProgress;
+ private GestureHandler mHandler;
+ private MotionEvent mCurrentDownEvent;
+ private MotionEvent mCurrentDoubleDownEvent;
+ private MotionEvent mPreviousUpEvent;
+ private MotionEvent mPreviousPointerUpEvent;
+ /**
+ * Creates a GestureDetector with the supplied listener.
+ * You may only use this constructor from a UI thread (this is the usual situation).
+ *
+ * @param context the application's context
+ * @param listener the listener invoked for all the callbacks, this must
+ * not be null.
+ * @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
+ */
+ public DoubleGestureDetector(Context context, Handler handler, OnDoubleGestureListener listener)
+ {
+ mListener = listener;
+ init(context, handler);
+ }
- private void init(Context context, Handler handler) {
- if (mListener == null) {
- throw new NullPointerException("OnGestureListener must not be null");
- }
+ private void init(Context context, Handler handler)
+ {
+ if (mListener == null)
+ {
+ throw new NullPointerException("OnGestureListener must not be null");
+ }
- if (handler != null)
- mHandler = new GestureHandler(handler);
- else
- mHandler = new GestureHandler();
+ if (handler != null)
+ mHandler = new GestureHandler(handler);
+ else
+ mHandler = new GestureHandler();
- // we use 1cm distance to decide between scroll and pinch zoom
- // - first convert cm to inches
- // - then multiply inches by dots per inch
- float distInches = 0.5f / 2.54f;
- float distPixelsX = distInches * context.getResources().getDisplayMetrics().xdpi;
- float distPixelsY = distInches * context.getResources().getDisplayMetrics().ydpi;
+ // we use 1cm distance to decide between scroll and pinch zoom
+ // - first convert cm to inches
+ // - then multiply inches by dots per inch
+ float distInches = 0.5f / 2.54f;
+ float distPixelsX = distInches * context.getResources().getDisplayMetrics().xdpi;
+ float distPixelsY = distInches * context.getResources().getDisplayMetrics().ydpi;
- mPointerDistanceSquare = (int) (distPixelsX * distPixelsX + distPixelsY * distPixelsY);
- }
+ mPointerDistanceSquare = (int)(distPixelsX * distPixelsX + distPixelsY * distPixelsY);
+ }
- /**
- * Set scale gesture detector
- *
- * @param scaleGestureDetector
- */
- public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
- this.scaleGestureDetector = scaleGestureDetector;
- }
+ /**
+ * Set scale gesture detector
+ *
+ * @param scaleGestureDetector
+ */
+ public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector)
+ {
+ this.scaleGestureDetector = scaleGestureDetector;
+ }
- /**
- * Analyzes the given motion event and if applicable triggers the
- * appropriate callbacks on the {@link OnGestureListener} supplied.
- *
- * @param ev The current motion event.
- * @return true if the {@link OnGestureListener} consumed the event,
- * else false.
- */
- public boolean onTouchEvent(MotionEvent ev) {
- boolean handled = false;
- final int action = ev.getAction();
- //dumpEvent(ev);
+ /**
+ * Analyzes the given motion event and if applicable triggers the
+ * appropriate callbacks on the {@link OnGestureListener} supplied.
+ *
+ * @param ev The current motion event.
+ * @return true if the {@link OnGestureListener} consumed the event,
+ * else false.
+ */
+ public boolean onTouchEvent(MotionEvent ev)
+ {
+ boolean handled = false;
+ final int action = ev.getAction();
+ // dumpEvent(ev);
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN:
- if (mCurrentDownEvent != null)
- mCurrentDownEvent.recycle();
+ switch (action & MotionEvent.ACTION_MASK)
+ {
+ case MotionEvent.ACTION_DOWN:
+ if (mCurrentDownEvent != null)
+ mCurrentDownEvent.recycle();
- mCurrentMode = MODE_UNKNOWN;
- mCurrentDownEvent = MotionEvent.obtain(ev);
- mCancelDetection = false;
- mDoubleInProgress = false;
- mScrollDetectionScore = 0;
- handled = true;
- break;
+ mCurrentMode = MODE_UNKNOWN;
+ mCurrentDownEvent = MotionEvent.obtain(ev);
+ mCancelDetection = false;
+ mDoubleInProgress = false;
+ mScrollDetectionScore = 0;
+ handled = true;
+ break;
- case MotionEvent.ACTION_POINTER_UP:
- if (mPreviousPointerUpEvent != null)
- mPreviousPointerUpEvent.recycle();
- mPreviousPointerUpEvent = MotionEvent.obtain(ev);
- break;
+ case MotionEvent.ACTION_POINTER_UP:
+ if (mPreviousPointerUpEvent != null)
+ mPreviousPointerUpEvent.recycle();
+ mPreviousPointerUpEvent = MotionEvent.obtain(ev);
+ break;
- case MotionEvent.ACTION_POINTER_DOWN:
- // more than 2 fingers down? cancel
- // 2nd finger touched too late? cancel
- if (ev.getPointerCount() > 2 || (ev.getEventTime() - mCurrentDownEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT) {
- cancel();
- break;
- }
+ case MotionEvent.ACTION_POINTER_DOWN:
+ // more than 2 fingers down? cancel
+ // 2nd finger touched too late? cancel
+ if (ev.getPointerCount() > 2 ||
+ (ev.getEventTime() - mCurrentDownEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT)
+ {
+ cancel();
+ break;
+ }
- // detection cancelled?
- if (mCancelDetection)
- break;
+ // detection cancelled?
+ if (mCancelDetection)
+ break;
- // double touch gesture in progress
- mDoubleInProgress = true;
- if (mCurrentDoubleDownEvent != null)
- mCurrentDoubleDownEvent.recycle();
- mCurrentDoubleDownEvent = MotionEvent.obtain(ev);
+ // double touch gesture in progress
+ mDoubleInProgress = true;
+ if (mCurrentDoubleDownEvent != null)
+ mCurrentDoubleDownEvent.recycle();
+ mCurrentDoubleDownEvent = MotionEvent.obtain(ev);
- // set detection mode to unkown and send a TOUCH timeout event to detect single taps
- mCurrentMode = MODE_UNKNOWN;
- mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
+ // set detection mode to unkown and send a TOUCH timeout event to detect single taps
+ mCurrentMode = MODE_UNKNOWN;
+ mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
- handled |= mListener.onDoubleTouchDown(ev);
- break;
+ handled |= mListener.onDoubleTouchDown(ev);
+ break;
- case MotionEvent.ACTION_MOVE:
+ case MotionEvent.ACTION_MOVE:
- // detection cancelled or not active?
- if (mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
- break;
+ // detection cancelled or not active?
+ if (mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
+ break;
- // determine mode
- if (mCurrentMode == MODE_UNKNOWN) {
- // did the pointer distance change?
- if (pointerDistanceChanged(mCurrentDoubleDownEvent, ev)) {
- handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
- MotionEvent e = MotionEvent.obtain(ev);
- e.setAction(mCurrentDoubleDownEvent.getAction());
- handled |= scaleGestureDetector.onTouchEvent(e);
- mCurrentMode = MODE_PINCH_ZOOM;
- break;
- } else {
- mScrollDetectionScore++;
- if (mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
- mCurrentMode = MODE_SCROLL;
- }
- }
+ // determine mode
+ if (mCurrentMode == MODE_UNKNOWN)
+ {
+ // did the pointer distance change?
+ if (pointerDistanceChanged(mCurrentDoubleDownEvent, ev))
+ {
+ handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
+ MotionEvent e = MotionEvent.obtain(ev);
+ e.setAction(mCurrentDoubleDownEvent.getAction());
+ handled |= scaleGestureDetector.onTouchEvent(e);
+ mCurrentMode = MODE_PINCH_ZOOM;
+ break;
+ }
+ else
+ {
+ mScrollDetectionScore++;
+ if (mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
+ mCurrentMode = MODE_SCROLL;
+ }
+ }
- switch (mCurrentMode) {
- case MODE_PINCH_ZOOM:
- if (scaleGestureDetector != null)
- handled |= scaleGestureDetector.onTouchEvent(ev);
- break;
+ switch (mCurrentMode)
+ {
+ case MODE_PINCH_ZOOM:
+ if (scaleGestureDetector != null)
+ handled |= scaleGestureDetector.onTouchEvent(ev);
+ break;
- case MODE_SCROLL:
- handled = mListener.onDoubleTouchScroll(mCurrentDownEvent, ev);
- break;
+ case MODE_SCROLL:
+ handled = mListener.onDoubleTouchScroll(mCurrentDownEvent, ev);
+ break;
- default:
- handled = true;
- break;
- }
+ default:
+ handled = true;
+ break;
+ }
- break;
+ break;
- case MotionEvent.ACTION_UP:
- // fingers were not removed equally? cancel
- if (mPreviousPointerUpEvent != null && (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT) {
- mPreviousPointerUpEvent.recycle();
- mPreviousPointerUpEvent = null;
- cancel();
- break;
- }
+ case MotionEvent.ACTION_UP:
+ // fingers were not removed equally? cancel
+ if (mPreviousPointerUpEvent != null &&
+ (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) >
+ DOUBLE_TOUCH_TIMEOUT)
+ {
+ mPreviousPointerUpEvent.recycle();
+ mPreviousPointerUpEvent = null;
+ cancel();
+ break;
+ }
- // detection cancelled or not active?
- if (mCancelDetection || !mDoubleInProgress)
- break;
+ // detection cancelled or not active?
+ if (mCancelDetection || !mDoubleInProgress)
+ break;
- boolean hasTapEvent = mHandler.hasMessages(TAP);
- MotionEvent currentUpEvent = MotionEvent.obtain(ev);
- if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
- handled = mListener.onDoubleTouchSingleTap(mCurrentDoubleDownEvent);
- else if (mCurrentMode == MODE_PINCH_ZOOM)
- handled = scaleGestureDetector.onTouchEvent(ev);
+ boolean hasTapEvent = mHandler.hasMessages(TAP);
+ MotionEvent currentUpEvent = MotionEvent.obtain(ev);
+ if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
+ handled = mListener.onDoubleTouchSingleTap(mCurrentDoubleDownEvent);
+ else if (mCurrentMode == MODE_PINCH_ZOOM)
+ handled = scaleGestureDetector.onTouchEvent(ev);
- if (mPreviousUpEvent != null)
- mPreviousUpEvent.recycle();
+ if (mPreviousUpEvent != null)
+ mPreviousUpEvent.recycle();
- // Hold the event we obtained above - listeners may have changed the original.
- mPreviousUpEvent = currentUpEvent;
- handled |= mListener.onDoubleTouchUp(ev);
- break;
+ // Hold the event we obtained above - listeners may have changed the original.
+ mPreviousUpEvent = currentUpEvent;
+ handled |= mListener.onDoubleTouchUp(ev);
+ break;
- case MotionEvent.ACTION_CANCEL:
- cancel();
- break;
- }
+ case MotionEvent.ACTION_CANCEL:
+ cancel();
+ break;
+ }
- if ((action == MotionEvent.ACTION_MOVE) && handled == false)
- handled = true;
+ if ((action == MotionEvent.ACTION_MOVE) && handled == false)
+ handled = true;
- return handled;
- }
+ return handled;
+ }
- private void cancel() {
- mHandler.removeMessages(TAP);
- mCurrentMode = MODE_UNKNOWN;
- mCancelDetection = true;
- mDoubleInProgress = false;
- }
+ private void cancel()
+ {
+ mHandler.removeMessages(TAP);
+ mCurrentMode = MODE_UNKNOWN;
+ mCancelDetection = true;
+ mDoubleInProgress = false;
+ }
- // returns true of the distance between the two pointers changed
- private boolean pointerDistanceChanged(MotionEvent oldEvent, MotionEvent newEvent) {
- int deltaX1 = Math.abs((int) oldEvent.getX(0) - (int) oldEvent.getX(1));
- int deltaX2 = Math.abs((int) newEvent.getX(0) - (int) newEvent.getX(1));
- int distXSquare = (deltaX2 - deltaX1) * (deltaX2 - deltaX1);
+ // returns true of the distance between the two pointers changed
+ private boolean pointerDistanceChanged(MotionEvent oldEvent, MotionEvent newEvent)
+ {
+ int deltaX1 = Math.abs((int)oldEvent.getX(0) - (int)oldEvent.getX(1));
+ int deltaX2 = Math.abs((int)newEvent.getX(0) - (int)newEvent.getX(1));
+ int distXSquare = (deltaX2 - deltaX1) * (deltaX2 - deltaX1);
- int deltaY1 = Math.abs((int) oldEvent.getY(0) - (int) oldEvent.getY(1));
- int deltaY2 = Math.abs((int) newEvent.getY(0) - (int) newEvent.getY(1));
- int distYSquare = (deltaY2 - deltaY1) * (deltaY2 - deltaY1);
+ int deltaY1 = Math.abs((int)oldEvent.getY(0) - (int)oldEvent.getY(1));
+ int deltaY2 = Math.abs((int)newEvent.getY(0) - (int)newEvent.getY(1));
+ int distYSquare = (deltaY2 - deltaY1) * (deltaY2 - deltaY1);
- return (distXSquare + distYSquare) > mPointerDistanceSquare;
- }
+ return (distXSquare + distYSquare) > mPointerDistanceSquare;
+ }
- /**
- * The listener that is used to notify when gestures occur.
- * If you want to listen for all the different gestures then implement
- * this interface. If you only want to listen for a subset it might
- * be easier to extend {@link SimpleOnGestureListener}.
- */
- public interface OnDoubleGestureListener {
+ /**
+ * The listener that is used to notify when gestures occur.
+ * If you want to listen for all the different gestures then implement
+ * this interface. If you only want to listen for a subset it might
+ * be easier to extend {@link SimpleOnGestureListener}.
+ */
+ public interface OnDoubleGestureListener {
- /**
- * Notified when a multi tap event starts
- */
- boolean onDoubleTouchDown(MotionEvent e);
+ /**
+ * Notified when a multi tap event starts
+ */
+ boolean onDoubleTouchDown(MotionEvent e);
- /**
- * Notified when a multi tap event ends
- */
- boolean onDoubleTouchUp(MotionEvent e);
+ /**
+ * Notified when a multi tap event ends
+ */
+ boolean onDoubleTouchUp(MotionEvent e);
- /**
- * Notified when a tap occurs with the up {@link MotionEvent}
- * that triggered it.
- *
- * @param e The up motion event that completed the first tap
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTouchSingleTap(MotionEvent e);
+ /**
+ * Notified when a tap occurs with the up {@link MotionEvent}
+ * that triggered it.
+ *
+ * @param e The up motion event that completed the first tap
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTouchSingleTap(MotionEvent e);
- /**
- * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
- * current move {@link MotionEvent}. The distance in x and y is also supplied for
- * convenience.
- *
- * @param e1 The first down motion event that started the scrolling.
- * @param e2 The move motion event that triggered the current onScroll.
- * @param distanceX The distance along the X axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @param distanceY The distance along the Y axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2);
- }
-
- /*
- private void dumpEvent(MotionEvent event) {
- String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
- "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
- StringBuilder sb = new StringBuilder();
- int action = event.getAction();
- int actionCode = action & MotionEvent.ACTION_MASK;
- sb.append("event ACTION_" ).append(names[actionCode]);
- if (actionCode == MotionEvent.ACTION_POINTER_DOWN
- || actionCode == MotionEvent.ACTION_POINTER_UP) {
- sb.append("(pid " ).append(
- action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
- sb.append(")" );
- }
- sb.append("[" );
- for (int i = 0; i < event.getPointerCount(); i++) {
- sb.append("#" ).append(i);
- sb.append("(pid " ).append(event.getPointerId(i));
- sb.append(")=" ).append((int) event.getX(i));
- sb.append("," ).append((int) event.getY(i));
- if (i + 1 < event.getPointerCount())
- sb.append(";" );
- }
- sb.append("]" );
- Log.d("DoubleDetector", sb.toString());
- }
- */
+ /**
+ * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
+ * current move {@link MotionEvent}. The distance in x and y is also supplied for
+ * convenience.
+ *
+ * @param e1 The first down motion event that started the scrolling.
+ * @param e2 The move motion event that triggered the current onScroll.
+ * @param distanceX The distance along the X axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @param distanceY The distance along the Y axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2);
+ }
- private class GestureHandler extends Handler {
- GestureHandler() {
- super();
- }
+ /*
+ private void dumpEvent(MotionEvent event) {
+ String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
+ "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
+ StringBuilder sb = new StringBuilder();
+ int action = event.getAction();
+ int actionCode = action & MotionEvent.ACTION_MASK;
+ sb.append("event ACTION_" ).append(names[actionCode]);
+ if (actionCode == MotionEvent.ACTION_POINTER_DOWN
+ || actionCode == MotionEvent.ACTION_POINTER_UP) {
+ sb.append("(pid " ).append(
+ action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
+ sb.append(")" );
+ }
+ sb.append("[" );
+ for (int i = 0; i < event.getPointerCount(); i++) {
+ sb.append("#" ).append(i);
+ sb.append("(pid " ).append(event.getPointerId(i));
+ sb.append(")=" ).append((int) event.getX(i));
+ sb.append("," ).append((int) event.getY(i));
+ if (i + 1 < event.getPointerCount())
+ sb.append(";" );
+ }
+ sb.append("]" );
+ Log.d("DoubleDetector", sb.toString());
+ }
+ */
- GestureHandler(Handler handler) {
- super(handler.getLooper());
- }
-
- }
+ private class GestureHandler extends Handler
+ {
+ GestureHandler()
+ {
+ super();
+ }
+ GestureHandler(Handler handler)
+ {
+ super(handler.getLooper());
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/GestureDetector.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/GestureDetector.java
index 71c1e6f1f..2e971b594 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/GestureDetector.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/GestureDetector.java
@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* Modified for aFreeRDP by Martin Fleisz (martin.fleisz@thincast.com)
*/
@@ -26,522 +26,595 @@ import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
-public class GestureDetector {
+public class GestureDetector
+{
- private static final int TAP_TIMEOUT = 100;
- private static final int DOUBLE_TAP_TIMEOUT = 200;
- // Distance a touch can wander before we think the user is the first touch in a sequence of double tap
- private static final int LARGE_TOUCH_SLOP = 18;
- // Distance between the first touch and second touch to still be considered a double tap
- private static final int DOUBLE_TAP_SLOP = 100;
- // constants for Message.what used by GestureHandler below
- private static final int SHOW_PRESS = 1;
- private static final int LONG_PRESS = 2;
- private static final int TAP = 3;
- private final Handler mHandler;
- private final OnGestureListener mListener;
- private int mTouchSlopSquare;
- private int mLargeTouchSlopSquare;
- private int mDoubleTapSlopSquare;
- private int mLongpressTimeout = 100;
- private OnDoubleTapListener mDoubleTapListener;
- private boolean mStillDown;
- private boolean mInLongPress;
- private boolean mAlwaysInTapRegion;
- private boolean mAlwaysInBiggerTapRegion;
- private MotionEvent mCurrentDownEvent;
- private MotionEvent mPreviousUpEvent;
- /**
- * True when the user is still touching for the second tap (down, move, and
- * up events). Can only be true if there is a double tap listener attached.
- */
- private boolean mIsDoubleTapping;
- private float mLastMotionY;
- private float mLastMotionX;
- private boolean mIsLongpressEnabled;
- /**
- * True if we are at a target API level of >= Froyo or the developer can
- * explicitly set it. If true, input events with > 1 pointer will be ignored
- * so we can work side by side with multitouch gesture detectors.
- */
- private boolean mIgnoreMultitouch;
- /**
- * Creates a GestureDetector with the supplied listener.
- * You may only use this constructor from a UI thread (this is the usual situation).
- *
- * @param context the application's context
- * @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @throws NullPointerException if {@code listener} is null.
- * @see android.os.Handler#Handler()
- */
- public GestureDetector(Context context, OnGestureListener listener) {
- this(context, listener, null);
- }
+ private static final int TAP_TIMEOUT = 100;
+ private static final int DOUBLE_TAP_TIMEOUT = 200;
+ // Distance a touch can wander before we think the user is the first touch in a sequence of
+ // double tap
+ private static final int LARGE_TOUCH_SLOP = 18;
+ // Distance between the first touch and second touch to still be considered a double tap
+ private static final int DOUBLE_TAP_SLOP = 100;
+ // constants for Message.what used by GestureHandler below
+ private static final int SHOW_PRESS = 1;
+ private static final int LONG_PRESS = 2;
+ private static final int TAP = 3;
+ private final Handler mHandler;
+ private final OnGestureListener mListener;
+ private int mTouchSlopSquare;
+ private int mLargeTouchSlopSquare;
+ private int mDoubleTapSlopSquare;
+ private int mLongpressTimeout = 100;
+ private OnDoubleTapListener mDoubleTapListener;
+ private boolean mStillDown;
+ private boolean mInLongPress;
+ private boolean mAlwaysInTapRegion;
+ private boolean mAlwaysInBiggerTapRegion;
+ private MotionEvent mCurrentDownEvent;
+ private MotionEvent mPreviousUpEvent;
+ /**
+ * True when the user is still touching for the second tap (down, move, and
+ * up events). Can only be true if there is a double tap listener attached.
+ */
+ private boolean mIsDoubleTapping;
+ private float mLastMotionY;
+ private float mLastMotionX;
+ private boolean mIsLongpressEnabled;
+ /**
+ * True if we are at a target API level of >= Froyo or the developer can
+ * explicitly set it. If true, input events with > 1 pointer will be ignored
+ * so we can work side by side with multitouch gesture detectors.
+ */
+ private boolean mIgnoreMultitouch;
+ /**
+ * Creates a GestureDetector with the supplied listener.
+ * You may only use this constructor from a UI thread (this is the usual situation).
+ *
+ * @param context the application's context
+ * @param listener the listener invoked for all the callbacks, this must
+ * not be null.
+ * @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
+ */
+ public GestureDetector(Context context, OnGestureListener listener)
+ {
+ this(context, listener, null);
+ }
- /**
- * Creates a GestureDetector with the supplied listener.
- * You may only use this constructor from a UI thread (this is the usual situation).
- *
- * @param context the application's context
- * @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @param handler the handler to use
- * @throws NullPointerException if {@code listener} is null.
- * @see android.os.Handler#Handler()
- */
- public GestureDetector(Context context, OnGestureListener listener, Handler handler) {
- this(context, listener, handler, context != null &&
- context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.FROYO);
- }
+ /**
+ * Creates a GestureDetector with the supplied listener.
+ * You may only use this constructor from a UI thread (this is the usual situation).
+ *
+ * @param context the application's context
+ * @param listener the listener invoked for all the callbacks, this must
+ * not be null.
+ * @param handler the handler to use
+ * @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
+ */
+ public GestureDetector(Context context, OnGestureListener listener, Handler handler)
+ {
+ this(context, listener, handler,
+ context != null &&
+ context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.FROYO);
+ }
- /**
- * Creates a GestureDetector with the supplied listener.
- * You may only use this constructor from a UI thread (this is the usual situation).
- *
- * @param context the application's context
- * @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @param handler the handler to use
- * @param ignoreMultitouch whether events involving more than one pointer should
- * be ignored.
- * @throws NullPointerException if {@code listener} is null.
- * @see android.os.Handler#Handler()
- */
- public GestureDetector(Context context, OnGestureListener listener, Handler handler,
- boolean ignoreMultitouch) {
- if (handler != null) {
- mHandler = new GestureHandler(handler);
- } else {
- mHandler = new GestureHandler();
- }
- mListener = listener;
- if (listener instanceof OnDoubleTapListener) {
- setOnDoubleTapListener((OnDoubleTapListener) listener);
- }
- init(context, ignoreMultitouch);
- }
+ /**
+ * Creates a GestureDetector with the supplied listener.
+ * You may only use this constructor from a UI thread (this is the usual situation).
+ *
+ * @param context the application's context
+ * @param listener the listener invoked for all the callbacks, this must
+ * not be null.
+ * @param handler the handler to use
+ * @param ignoreMultitouch whether events involving more than one pointer should
+ * be ignored.
+ * @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
+ */
+ public GestureDetector(Context context, OnGestureListener listener, Handler handler,
+ boolean ignoreMultitouch)
+ {
+ if (handler != null)
+ {
+ mHandler = new GestureHandler(handler);
+ }
+ else
+ {
+ mHandler = new GestureHandler();
+ }
+ mListener = listener;
+ if (listener instanceof OnDoubleTapListener)
+ {
+ setOnDoubleTapListener((OnDoubleTapListener)listener);
+ }
+ init(context, ignoreMultitouch);
+ }
- private void init(Context context, boolean ignoreMultitouch) {
- if (mListener == null) {
- throw new NullPointerException("OnGestureListener must not be null");
- }
- mIsLongpressEnabled = true;
- mIgnoreMultitouch = ignoreMultitouch;
+ private void init(Context context, boolean ignoreMultitouch)
+ {
+ if (mListener == null)
+ {
+ throw new NullPointerException("OnGestureListener must not be null");
+ }
+ mIsLongpressEnabled = true;
+ mIgnoreMultitouch = ignoreMultitouch;
- // Fallback to support pre-donuts releases
- int touchSlop, largeTouchSlop, doubleTapSlop;
- if (context == null) {
- //noinspection deprecation
- touchSlop = ViewConfiguration.getTouchSlop();
- largeTouchSlop = touchSlop + 2;
- doubleTapSlop = DOUBLE_TAP_SLOP;
- } else {
- final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- final float density = metrics.density;
- final ViewConfiguration configuration = ViewConfiguration.get(context);
- touchSlop = configuration.getScaledTouchSlop();
- largeTouchSlop = (int) (density * LARGE_TOUCH_SLOP + 0.5f);
- doubleTapSlop = configuration.getScaledDoubleTapSlop();
- }
- mTouchSlopSquare = touchSlop * touchSlop;
- mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop;
- mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
- }
+ // Fallback to support pre-donuts releases
+ int touchSlop, largeTouchSlop, doubleTapSlop;
+ if (context == null)
+ {
+ // noinspection deprecation
+ touchSlop = ViewConfiguration.getTouchSlop();
+ largeTouchSlop = touchSlop + 2;
+ doubleTapSlop = DOUBLE_TAP_SLOP;
+ }
+ else
+ {
+ final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+ final float density = metrics.density;
+ final ViewConfiguration configuration = ViewConfiguration.get(context);
+ touchSlop = configuration.getScaledTouchSlop();
+ largeTouchSlop = (int)(density * LARGE_TOUCH_SLOP + 0.5f);
+ doubleTapSlop = configuration.getScaledDoubleTapSlop();
+ }
+ mTouchSlopSquare = touchSlop * touchSlop;
+ mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop;
+ mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
+ }
- /**
- * Sets the listener which will be called for double-tap and related
- * gestures.
- *
- * @param onDoubleTapListener the listener invoked for all the callbacks, or
- * null to stop listening for double-tap gestures.
- */
- public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
- mDoubleTapListener = onDoubleTapListener;
- }
+ /**
+ * Sets the listener which will be called for double-tap and related
+ * gestures.
+ *
+ * @param onDoubleTapListener the listener invoked for all the callbacks, or
+ * null to stop listening for double-tap gestures.
+ */
+ public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener)
+ {
+ mDoubleTapListener = onDoubleTapListener;
+ }
- /**
- * Set whether longpress is enabled, if this is enabled when a user
- * presses and holds down you get a longpress event and nothing further.
- * If it's disabled the user can press and hold down and then later
- * moved their finger and you will get scroll events. By default
- * longpress is enabled.
- *
- * @param isLongpressEnabled whether longpress should be enabled.
- */
- public void setIsLongpressEnabled(boolean isLongpressEnabled) {
- mIsLongpressEnabled = isLongpressEnabled;
- }
+ /**
+ * Set whether longpress is enabled, if this is enabled when a user
+ * presses and holds down you get a longpress event and nothing further.
+ * If it's disabled the user can press and hold down and then later
+ * moved their finger and you will get scroll events. By default
+ * longpress is enabled.
+ *
+ * @param isLongpressEnabled whether longpress should be enabled.
+ */
+ public void setIsLongpressEnabled(boolean isLongpressEnabled)
+ {
+ mIsLongpressEnabled = isLongpressEnabled;
+ }
- /**
- * @return true if longpress is enabled, else false.
- */
- public boolean isLongpressEnabled() {
- return mIsLongpressEnabled;
- }
+ /**
+ * @return true if longpress is enabled, else false.
+ */
+ public boolean isLongpressEnabled()
+ {
+ return mIsLongpressEnabled;
+ }
- public void setLongPressTimeout(int timeout) {
- mLongpressTimeout = timeout;
- }
+ public void setLongPressTimeout(int timeout)
+ {
+ mLongpressTimeout = timeout;
+ }
- /**
- * Analyzes the given motion event and if applicable triggers the
- * appropriate callbacks on the {@link OnGestureListener} supplied.
- *
- * @param ev The current motion event.
- * @return true if the {@link OnGestureListener} consumed the event,
- * else false.
- */
- public boolean onTouchEvent(MotionEvent ev) {
- final int action = ev.getAction();
- final float y = ev.getY();
- final float x = ev.getX();
+ /**
+ * Analyzes the given motion event and if applicable triggers the
+ * appropriate callbacks on the {@link OnGestureListener} supplied.
+ *
+ * @param ev The current motion event.
+ * @return true if the {@link OnGestureListener} consumed the event,
+ * else false.
+ */
+ public boolean onTouchEvent(MotionEvent ev)
+ {
+ final int action = ev.getAction();
+ final float y = ev.getY();
+ final float x = ev.getX();
- boolean handled = false;
+ boolean handled = false;
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_POINTER_DOWN:
- if (mIgnoreMultitouch) {
- // Multitouch event - abort.
- cancel();
- }
- break;
+ switch (action & MotionEvent.ACTION_MASK)
+ {
+ case MotionEvent.ACTION_POINTER_DOWN:
+ if (mIgnoreMultitouch)
+ {
+ // Multitouch event - abort.
+ cancel();
+ }
+ break;
- case MotionEvent.ACTION_POINTER_UP:
- // Ending a multitouch gesture and going back to 1 finger
- if (mIgnoreMultitouch && ev.getPointerCount() == 2) {
- int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0;
- mLastMotionX = ev.getX(index);
- mLastMotionY = ev.getY(index);
- }
- break;
+ case MotionEvent.ACTION_POINTER_UP:
+ // Ending a multitouch gesture and going back to 1 finger
+ if (mIgnoreMultitouch && ev.getPointerCount() == 2)
+ {
+ int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
+ MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0)
+ ? 1
+ : 0;
+ mLastMotionX = ev.getX(index);
+ mLastMotionY = ev.getY(index);
+ }
+ break;
- case MotionEvent.ACTION_DOWN:
- if (mDoubleTapListener != null) {
- boolean hadTapMessage = mHandler.hasMessages(TAP);
- if (hadTapMessage) mHandler.removeMessages(TAP);
- if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
- isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) {
- // This is a second tap
- mIsDoubleTapping = true;
- // Give a callback with the first tap of the double-tap
- handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
- // Give a callback with down event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else {
- // This is a first tap
- mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
- }
- }
+ case MotionEvent.ACTION_DOWN:
+ if (mDoubleTapListener != null)
+ {
+ boolean hadTapMessage = mHandler.hasMessages(TAP);
+ if (hadTapMessage)
+ mHandler.removeMessages(TAP);
+ if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) &&
+ hadTapMessage &&
+ isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev))
+ {
+ // This is a second tap
+ mIsDoubleTapping = true;
+ // Give a callback with the first tap of the double-tap
+ handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
+ // Give a callback with down event of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ }
+ else
+ {
+ // This is a first tap
+ mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
+ }
+ }
- mLastMotionX = x;
- mLastMotionY = y;
- if (mCurrentDownEvent != null) {
- mCurrentDownEvent.recycle();
- }
- mCurrentDownEvent = MotionEvent.obtain(ev);
- mAlwaysInTapRegion = true;
- mAlwaysInBiggerTapRegion = true;
- mStillDown = true;
- mInLongPress = false;
+ mLastMotionX = x;
+ mLastMotionY = y;
+ if (mCurrentDownEvent != null)
+ {
+ mCurrentDownEvent.recycle();
+ }
+ mCurrentDownEvent = MotionEvent.obtain(ev);
+ mAlwaysInTapRegion = true;
+ mAlwaysInBiggerTapRegion = true;
+ mStillDown = true;
+ mInLongPress = false;
- if (mIsLongpressEnabled) {
- mHandler.removeMessages(LONG_PRESS);
- mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
- + TAP_TIMEOUT + mLongpressTimeout);
- }
- mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
- handled |= mListener.onDown(ev);
- break;
+ if (mIsLongpressEnabled)
+ {
+ mHandler.removeMessages(LONG_PRESS);
+ mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() +
+ TAP_TIMEOUT +
+ mLongpressTimeout);
+ }
+ mHandler.sendEmptyMessageAtTime(SHOW_PRESS,
+ mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
+ handled |= mListener.onDown(ev);
+ break;
- case MotionEvent.ACTION_MOVE:
- if (mIgnoreMultitouch && ev.getPointerCount() > 1) {
- break;
- }
- final float scrollX = mLastMotionX - x;
- final float scrollY = mLastMotionY - y;
- if (mIsDoubleTapping) {
- // Give the move events of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mAlwaysInTapRegion) {
- final int deltaX = (int) (x - mCurrentDownEvent.getX());
- final int deltaY = (int) (y - mCurrentDownEvent.getY());
- int distance = (deltaX * deltaX) + (deltaY * deltaY);
- if (distance > mTouchSlopSquare) {
- mLastMotionX = x;
- mLastMotionY = y;
- mAlwaysInTapRegion = false;
- mHandler.removeMessages(TAP);
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- }
- if (distance > mLargeTouchSlopSquare) {
- mAlwaysInBiggerTapRegion = false;
- }
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- mLastMotionX = x;
- mLastMotionY = y;
- }
- break;
+ case MotionEvent.ACTION_MOVE:
+ if (mIgnoreMultitouch && ev.getPointerCount() > 1)
+ {
+ break;
+ }
+ final float scrollX = mLastMotionX - x;
+ final float scrollY = mLastMotionY - y;
+ if (mIsDoubleTapping)
+ {
+ // Give the move events of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ }
+ else if (mAlwaysInTapRegion)
+ {
+ final int deltaX = (int)(x - mCurrentDownEvent.getX());
+ final int deltaY = (int)(y - mCurrentDownEvent.getY());
+ int distance = (deltaX * deltaX) + (deltaY * deltaY);
+ if (distance > mTouchSlopSquare)
+ {
+ mLastMotionX = x;
+ mLastMotionY = y;
+ mAlwaysInTapRegion = false;
+ mHandler.removeMessages(TAP);
+ mHandler.removeMessages(SHOW_PRESS);
+ mHandler.removeMessages(LONG_PRESS);
+ }
+ if (distance > mLargeTouchSlopSquare)
+ {
+ mAlwaysInBiggerTapRegion = false;
+ }
+ handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
+ }
+ else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1))
+ {
+ handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
+ mLastMotionX = x;
+ mLastMotionY = y;
+ }
+ break;
- case MotionEvent.ACTION_UP:
- mStillDown = false;
- MotionEvent currentUpEvent = MotionEvent.obtain(ev);
- if (mIsDoubleTapping) {
- // Finally, give the up event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mInLongPress) {
- mHandler.removeMessages(TAP);
- mListener.onLongPressUp(ev);
- mInLongPress = false;
- } else if (mAlwaysInTapRegion) {
- handled = mListener.onSingleTapUp(mCurrentDownEvent);
- } else {
- // A fling must travel the minimum tap distance
- }
- if (mPreviousUpEvent != null) {
- mPreviousUpEvent.recycle();
- }
- // Hold the event we obtained above - listeners may have changed the original.
- mPreviousUpEvent = currentUpEvent;
- mIsDoubleTapping = false;
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- handled |= mListener.onUp(ev);
- break;
- case MotionEvent.ACTION_CANCEL:
- cancel();
- break;
- }
- return handled;
- }
+ case MotionEvent.ACTION_UP:
+ mStillDown = false;
+ MotionEvent currentUpEvent = MotionEvent.obtain(ev);
+ if (mIsDoubleTapping)
+ {
+ // Finally, give the up event of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ }
+ else if (mInLongPress)
+ {
+ mHandler.removeMessages(TAP);
+ mListener.onLongPressUp(ev);
+ mInLongPress = false;
+ }
+ else if (mAlwaysInTapRegion)
+ {
+ handled = mListener.onSingleTapUp(mCurrentDownEvent);
+ }
+ else
+ {
+ // A fling must travel the minimum tap distance
+ }
+ if (mPreviousUpEvent != null)
+ {
+ mPreviousUpEvent.recycle();
+ }
+ // Hold the event we obtained above - listeners may have changed the original.
+ mPreviousUpEvent = currentUpEvent;
+ mIsDoubleTapping = false;
+ mHandler.removeMessages(SHOW_PRESS);
+ mHandler.removeMessages(LONG_PRESS);
+ handled |= mListener.onUp(ev);
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ cancel();
+ break;
+ }
+ return handled;
+ }
- private void cancel() {
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- mHandler.removeMessages(TAP);
- mAlwaysInTapRegion = false; // ensures that we won't receive an OnSingleTap notification when a 2-Finger tap is performed
- mIsDoubleTapping = false;
- mStillDown = false;
- if (mInLongPress) {
- mInLongPress = false;
- }
- }
+ private void cancel()
+ {
+ mHandler.removeMessages(SHOW_PRESS);
+ mHandler.removeMessages(LONG_PRESS);
+ mHandler.removeMessages(TAP);
+ mAlwaysInTapRegion = false; // ensures that we won't receive an OnSingleTap notification
+ // when a 2-Finger tap is performed
+ mIsDoubleTapping = false;
+ mStillDown = false;
+ if (mInLongPress)
+ {
+ mInLongPress = false;
+ }
+ }
- private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp,
- MotionEvent secondDown) {
- if (!mAlwaysInBiggerTapRegion) {
- return false;
- }
+ private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp,
+ MotionEvent secondDown)
+ {
+ if (!mAlwaysInBiggerTapRegion)
+ {
+ return false;
+ }
- if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT) {
- return false;
- }
+ if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT)
+ {
+ return false;
+ }
- int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
- int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
- return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
- }
+ int deltaX = (int)firstDown.getX() - (int)secondDown.getX();
+ int deltaY = (int)firstDown.getY() - (int)secondDown.getY();
+ return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
+ }
- private void dispatchLongPress() {
- mHandler.removeMessages(TAP);
- mInLongPress = true;
- mListener.onLongPress(mCurrentDownEvent);
- }
+ private void dispatchLongPress()
+ {
+ mHandler.removeMessages(TAP);
+ mInLongPress = true;
+ mListener.onLongPress(mCurrentDownEvent);
+ }
- /**
- * The listener that is used to notify when gestures occur.
- * If you want to listen for all the different gestures then implement
- * this interface. If you only want to listen for a subset it might
- * be easier to extend {@link SimpleOnGestureListener}.
- */
- public interface OnGestureListener {
+ /**
+ * The listener that is used to notify when gestures occur.
+ * If you want to listen for all the different gestures then implement
+ * this interface. If you only want to listen for a subset it might
+ * be easier to extend {@link SimpleOnGestureListener}.
+ */
+ public interface OnGestureListener {
- /**
- * Notified when a tap occurs with the down {@link MotionEvent}
- * that triggered it. This will be triggered immediately for
- * every down event. All other events should be preceded by this.
- *
- * @param e The down motion event.
- */
- boolean onDown(MotionEvent e);
+ /**
+ * Notified when a tap occurs with the down {@link MotionEvent}
+ * that triggered it. This will be triggered immediately for
+ * every down event. All other events should be preceded by this.
+ *
+ * @param e The down motion event.
+ */
+ boolean onDown(MotionEvent e);
- /**
- * Notified when a tap finishes with the up {@link MotionEvent}
- * that triggered it. This will be triggered immediately for
- * every up event. All other events should be preceded by this.
- *
- * @param e The up motion event.
- */
- boolean onUp(MotionEvent e);
+ /**
+ * Notified when a tap finishes with the up {@link MotionEvent}
+ * that triggered it. This will be triggered immediately for
+ * every up event. All other events should be preceded by this.
+ *
+ * @param e The up motion event.
+ */
+ boolean onUp(MotionEvent e);
- /**
- * The user has performed a down {@link MotionEvent} and not performed
- * a move or up yet. This event is commonly used to provide visual
- * feedback to the user to let them know that their action has been
- * recognized i.e. highlight an element.
- *
- * @param e The down motion event
- */
- void onShowPress(MotionEvent e);
+ /**
+ * The user has performed a down {@link MotionEvent} and not performed
+ * a move or up yet. This event is commonly used to provide visual
+ * feedback to the user to let them know that their action has been
+ * recognized i.e. highlight an element.
+ *
+ * @param e The down motion event
+ */
+ void onShowPress(MotionEvent e);
- /**
- * Notified when a tap occurs with the up {@link MotionEvent}
- * that triggered it.
- *
- * @param e The up motion event that completed the first tap
- * @return true if the event is consumed, else false
- */
- boolean onSingleTapUp(MotionEvent e);
+ /**
+ * Notified when a tap occurs with the up {@link MotionEvent}
+ * that triggered it.
+ *
+ * @param e The up motion event that completed the first tap
+ * @return true if the event is consumed, else false
+ */
+ boolean onSingleTapUp(MotionEvent e);
- /**
- * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
- * current move {@link MotionEvent}. The distance in x and y is also supplied for
- * convenience.
- *
- * @param e1 The first down motion event that started the scrolling.
- * @param e2 The move motion event that triggered the current onScroll.
- * @param distanceX The distance along the X axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @param distanceY The distance along the Y axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @return true if the event is consumed, else false
- */
- boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
+ /**
+ * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
+ * current move {@link MotionEvent}. The distance in x and y is also supplied for
+ * convenience.
+ *
+ * @param e1 The first down motion event that started the scrolling.
+ * @param e2 The move motion event that triggered the current onScroll.
+ * @param distanceX The distance along the X axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @param distanceY The distance along the Y axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @return true if the event is consumed, else false
+ */
+ boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
- /**
- * Notified when a long press occurs with the initial on down {@link MotionEvent}
- * that trigged it.
- *
- * @param e The initial on down motion event that started the longpress.
- */
- void onLongPress(MotionEvent e);
+ /**
+ * Notified when a long press occurs with the initial on down {@link MotionEvent}
+ * that trigged it.
+ *
+ * @param e The initial on down motion event that started the longpress.
+ */
+ void onLongPress(MotionEvent e);
- /**
- * Notified when a long press ends with the final {@link MotionEvent}.
- *
- * @param e The up motion event that ended the longpress.
- */
- void onLongPressUp(MotionEvent e);
- }
+ /**
+ * Notified when a long press ends with the final {@link MotionEvent}.
+ *
+ * @param e The up motion event that ended the longpress.
+ */
+ void onLongPressUp(MotionEvent e);
+ }
- /**
- * The listener that is used to notify when a double-tap or a confirmed
- * single-tap occur.
- */
- public interface OnDoubleTapListener {
- /**
- * Notified when a single-tap occurs.
- *
- * Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this
- * will only be called after the detector is confident that the user's
- * first tap is not followed by a second tap leading to a double-tap
- * gesture.
- *
- * @param e The down motion event of the single-tap.
- * @return true if the event is consumed, else false
- */
- boolean onSingleTapConfirmed(MotionEvent e);
+ /**
+ * The listener that is used to notify when a double-tap or a confirmed
+ * single-tap occur.
+ */
+ public interface OnDoubleTapListener {
+ /**
+ * Notified when a single-tap occurs.
+ *
+ * Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this
+ * will only be called after the detector is confident that the user's
+ * first tap is not followed by a second tap leading to a double-tap
+ * gesture.
+ *
+ * @param e The down motion event of the single-tap.
+ * @return true if the event is consumed, else false
+ */
+ boolean onSingleTapConfirmed(MotionEvent e);
- /**
- * Notified when a double-tap occurs.
- *
- * @param e The down motion event of the first tap of the double-tap.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTap(MotionEvent e);
+ /**
+ * Notified when a double-tap occurs.
+ *
+ * @param e The down motion event of the first tap of the double-tap.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTap(MotionEvent e);
- /**
- * Notified when an event within a double-tap gesture occurs, including
- * the down, move, and up events.
- *
- * @param e The motion event that occurred during the double-tap gesture.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTapEvent(MotionEvent e);
- }
+ /**
+ * Notified when an event within a double-tap gesture occurs, including
+ * the down, move, and up events.
+ *
+ * @param e The motion event that occurred during the double-tap gesture.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTapEvent(MotionEvent e);
+ }
- /**
- * A convenience class to extend when you only want to listen for a subset
- * of all the gestures. This implements all methods in the
- * {@link OnGestureListener} and {@link OnDoubleTapListener} but does
- * nothing and return {@code false} for all applicable methods.
- */
- public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener {
- public boolean onSingleTapUp(MotionEvent e) {
- return false;
- }
+ /**
+ * A convenience class to extend when you only want to listen for a subset
+ * of all the gestures. This implements all methods in the
+ * {@link OnGestureListener} and {@link OnDoubleTapListener} but does
+ * nothing and return {@code false} for all applicable methods.
+ */
+ public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener
+ {
+ public boolean onSingleTapUp(MotionEvent e)
+ {
+ return false;
+ }
- public void onLongPress(MotionEvent e) {
- }
+ public void onLongPress(MotionEvent e)
+ {
+ }
- public void onLongPressUp(MotionEvent e) {
- }
+ public void onLongPressUp(MotionEvent e)
+ {
+ }
- public boolean onScroll(MotionEvent e1, MotionEvent e2,
- float distanceX, float distanceY) {
- return false;
- }
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
+ {
+ return false;
+ }
- public void onShowPress(MotionEvent e) {
- }
+ public void onShowPress(MotionEvent e)
+ {
+ }
- public boolean onDown(MotionEvent e) {
- return false;
- }
+ public boolean onDown(MotionEvent e)
+ {
+ return false;
+ }
- public boolean onUp(MotionEvent e) {
- return false;
- }
+ public boolean onUp(MotionEvent e)
+ {
+ return false;
+ }
- public boolean onDoubleTap(MotionEvent e) {
- return false;
- }
+ public boolean onDoubleTap(MotionEvent e)
+ {
+ return false;
+ }
- public boolean onDoubleTapEvent(MotionEvent e) {
- return false;
- }
+ public boolean onDoubleTapEvent(MotionEvent e)
+ {
+ return false;
+ }
- public boolean onSingleTapConfirmed(MotionEvent e) {
- return false;
- }
- }
+ public boolean onSingleTapConfirmed(MotionEvent e)
+ {
+ return false;
+ }
+ }
- private class GestureHandler extends Handler {
- GestureHandler() {
- super();
- }
+ private class GestureHandler extends Handler
+ {
+ GestureHandler()
+ {
+ super();
+ }
- GestureHandler(Handler handler) {
- super(handler.getLooper());
- }
+ GestureHandler(Handler handler)
+ {
+ super(handler.getLooper());
+ }
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SHOW_PRESS:
- mListener.onShowPress(mCurrentDownEvent);
- break;
+ @Override public void handleMessage(Message msg)
+ {
+ switch (msg.what)
+ {
+ case SHOW_PRESS:
+ mListener.onShowPress(mCurrentDownEvent);
+ break;
- case LONG_PRESS:
- dispatchLongPress();
- break;
+ case LONG_PRESS:
+ dispatchLongPress();
+ break;
- case TAP:
- // If the user's finger is still down, do not count it as a tap
- if (mDoubleTapListener != null && !mStillDown) {
- mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
- }
- break;
+ case TAP:
+ // If the user's finger is still down, do not count it as a tap
+ if (mDoubleTapListener != null && !mStillDown)
+ {
+ mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
+ }
+ break;
- default:
- throw new RuntimeException("Unknown message " + msg); //never
- }
- }
- }
+ default:
+ throw new RuntimeException("Unknown message " + msg); // never
+ }
+ }
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntEditTextPreference.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntEditTextPreference.java
index a3e951c05..a383d910d 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntEditTextPreference.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntEditTextPreference.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -16,72 +17,85 @@ import android.util.AttributeSet;
import com.freerdp.freerdpcore.R;
-public class IntEditTextPreference extends EditTextPreference {
+public class IntEditTextPreference extends EditTextPreference
+{
- private int bounds_min, bounds_max, bounds_default;
+ private int bounds_min, bounds_max, bounds_default;
- public IntEditTextPreference(Context context) {
- super(context);
- init(context, null);
- }
+ public IntEditTextPreference(Context context)
+ {
+ super(context);
+ init(context, null);
+ }
- public IntEditTextPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
- }
+ public IntEditTextPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ init(context, attrs);
+ }
- public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(context, attrs);
- }
+ public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ init(context, attrs);
+ }
- private void init(Context context, AttributeSet attrs) {
- if (attrs != null) {
- TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.IntEditTextPreference, 0, 0);
- bounds_min = array.getInt(R.styleable.IntEditTextPreference_bounds_min, Integer.MIN_VALUE);
- bounds_max = array.getInt(R.styleable.IntEditTextPreference_bounds_max, Integer.MAX_VALUE);
- bounds_default = array.getInt(R.styleable.IntEditTextPreference_bounds_default, 0);
- array.recycle();
- } else {
- bounds_min = Integer.MIN_VALUE;
- bounds_max = Integer.MAX_VALUE;
- bounds_default = 0;
- }
- }
+ private void init(Context context, AttributeSet attrs)
+ {
+ if (attrs != null)
+ {
+ TypedArray array =
+ context.obtainStyledAttributes(attrs, R.styleable.IntEditTextPreference, 0, 0);
+ bounds_min =
+ array.getInt(R.styleable.IntEditTextPreference_bounds_min, Integer.MIN_VALUE);
+ bounds_max =
+ array.getInt(R.styleable.IntEditTextPreference_bounds_max, Integer.MAX_VALUE);
+ bounds_default = array.getInt(R.styleable.IntEditTextPreference_bounds_default, 0);
+ array.recycle();
+ }
+ else
+ {
+ bounds_min = Integer.MIN_VALUE;
+ bounds_max = Integer.MAX_VALUE;
+ bounds_default = 0;
+ }
+ }
- public void setBounds(int min, int max, int defaultValue) {
- bounds_min = min;
- bounds_max = max;
- bounds_default = defaultValue;
- }
+ public void setBounds(int min, int max, int defaultValue)
+ {
+ bounds_min = min;
+ bounds_max = max;
+ bounds_default = defaultValue;
+ }
- @Override
- protected String getPersistedString(String defaultReturnValue) {
- int value = getPersistedInt(-1);
- if (value > bounds_max || value < bounds_min)
- value = bounds_default;
- return String.valueOf(value);
- }
+ @Override protected String getPersistedString(String defaultReturnValue)
+ {
+ int value = getPersistedInt(-1);
+ if (value > bounds_max || value < bounds_min)
+ value = bounds_default;
+ return String.valueOf(value);
+ }
- @Override
- protected boolean persistString(String value) {
- return persistInt(Integer.valueOf(value));
- }
+ @Override protected boolean persistString(String value)
+ {
+ return persistInt(Integer.valueOf(value));
+ }
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- if (positiveResult) {
- // prevent exception when an empty value is persisted
- if (getEditText().getText().length() == 0)
- getEditText().setText("0");
+ @Override protected void onDialogClosed(boolean positiveResult)
+ {
+ if (positiveResult)
+ {
+ // prevent exception when an empty value is persisted
+ if (getEditText().getText().length() == 0)
+ getEditText().setText("0");
- // check bounds
- int value = Integer.valueOf(getEditText().getText().toString());
- if (value > bounds_max || value < bounds_min)
- value = bounds_default;
- getEditText().setText(String.valueOf(value));
- }
+ // check bounds
+ int value = Integer.valueOf(getEditText().getText().toString());
+ if (value > bounds_max || value < bounds_min)
+ value = bounds_default;
+ getEditText().setText(String.valueOf(value));
+ }
- super.onDialogClosed(positiveResult);
- }
+ super.onDialogClosed(positiveResult);
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntListPreference.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntListPreference.java
index a641061ad..0b4f6433e 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntListPreference.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/IntListPreference.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -13,23 +14,26 @@ import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
-public class IntListPreference extends ListPreference {
+public class IntListPreference extends ListPreference
+{
- public IntListPreference(Context context) {
- super(context);
- }
+ public IntListPreference(Context context)
+ {
+ super(context);
+ }
- public IntListPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
+ public IntListPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ }
- @Override
- protected String getPersistedString(String defaultReturnValue) {
- return String.valueOf(getPersistedInt(-1));
- }
+ @Override protected String getPersistedString(String defaultReturnValue)
+ {
+ return String.valueOf(getPersistedInt(-1));
+ }
- @Override
- protected boolean persistString(String value) {
- return persistInt(Integer.valueOf(value));
- }
+ @Override protected boolean persistString(String value)
+ {
+ return persistInt(Integer.valueOf(value));
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/KeyboardMapper.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/KeyboardMapper.java
index 170f41518..f1456b23d 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/KeyboardMapper.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/KeyboardMapper.java
@@ -3,11 +3,11 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
-
package com.freerdp.freerdpcore.utils;
import android.content.Context;
@@ -15,627 +15,711 @@ import android.view.KeyEvent;
import com.freerdp.freerdpcore.R;
-public class KeyboardMapper {
- public static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1;
- public static final int KEYBOARD_TYPE_NUMPAD = 2;
- public static final int KEYBOARD_TYPE_CURSOR = 3;
+public class KeyboardMapper
+{
+ public static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1;
+ public static final int KEYBOARD_TYPE_NUMPAD = 2;
+ public static final int KEYBOARD_TYPE_CURSOR = 3;
- // defines key states for modifier keys - locked means on and no auto-release if an other key is pressed
- public static final int KEYSTATE_ON = 1;
- public static final int KEYSTATE_LOCKED = 2;
- public static final int KEYSTATE_OFF = 3;
- final static int VK_LBUTTON = 0x01;
- final static int VK_RBUTTON = 0x02;
- final static int VK_CANCEL = 0x03;
- final static int VK_MBUTTON = 0x04;
- final static int VK_XBUTTON1 = 0x05;
- final static int VK_XBUTTON2 = 0x06;
- final static int VK_BACK = 0x08;
- final static int VK_TAB = 0x09;
- final static int VK_CLEAR = 0x0C;
- final static int VK_RETURN = 0x0D;
- final static int VK_SHIFT = 0x10;
- final static int VK_CONTROL = 0x11;
- final static int VK_MENU = 0x12;
- final static int VK_PAUSE = 0x13;
- final static int VK_CAPITAL = 0x14;
- final static int VK_KANA = 0x15;
- final static int VK_HANGUEL = 0x15;
- final static int VK_HANGUL = 0x15;
- final static int VK_JUNJA = 0x17;
- final static int VK_FINAL = 0x18;
- final static int VK_HANJA = 0x19;
- final static int VK_KANJI = 0x19;
- final static int VK_ESCAPE = 0x1B;
- final static int VK_CONVERT = 0x1C;
- final static int VK_NONCONVERT = 0x1D;
- final static int VK_ACCEPT = 0x1E;
- final static int VK_MODECHANGE = 0x1F;
- final static int VK_SPACE = 0x20;
- final static int VK_PRIOR = 0x21;
- final static int VK_NEXT = 0x22;
- final static int VK_END = 0x23;
- final static int VK_HOME = 0x24;
- final static int VK_LEFT = 0x25;
- final static int VK_UP = 0x26;
- final static int VK_RIGHT = 0x27;
- final static int VK_DOWN = 0x28;
- final static int VK_SELECT = 0x29;
- final static int VK_PRINT = 0x2A;
- final static int VK_EXECUTE = 0x2B;
- final static int VK_SNAPSHOT = 0x2C;
- final static int VK_INSERT = 0x2D;
- final static int VK_DELETE = 0x2E;
- final static int VK_HELP = 0x2F;
- final static int VK_KEY_0 = 0x30;
- final static int VK_KEY_1 = 0x31;
- final static int VK_KEY_2 = 0x32;
- final static int VK_KEY_3 = 0x33;
- final static int VK_KEY_4 = 0x34;
- final static int VK_KEY_5 = 0x35;
- final static int VK_KEY_6 = 0x36;
- final static int VK_KEY_7 = 0x37;
- final static int VK_KEY_8 = 0x38;
- final static int VK_KEY_9 = 0x39;
- final static int VK_KEY_A = 0x41;
- final static int VK_KEY_B = 0x42;
- final static int VK_KEY_C = 0x43;
- final static int VK_KEY_D = 0x44;
- final static int VK_KEY_E = 0x45;
- final static int VK_KEY_F = 0x46;
- final static int VK_KEY_G = 0x47;
- final static int VK_KEY_H = 0x48;
- final static int VK_KEY_I = 0x49;
- final static int VK_KEY_J = 0x4A;
- final static int VK_KEY_K = 0x4B;
- final static int VK_KEY_L = 0x4C;
- final static int VK_KEY_M = 0x4D;
- final static int VK_KEY_N = 0x4E;
- final static int VK_KEY_O = 0x4F;
- final static int VK_KEY_P = 0x50;
- final static int VK_KEY_Q = 0x51;
- final static int VK_KEY_R = 0x52;
- final static int VK_KEY_S = 0x53;
- final static int VK_KEY_T = 0x54;
- final static int VK_KEY_U = 0x55;
- final static int VK_KEY_V = 0x56;
- final static int VK_KEY_W = 0x57;
- final static int VK_KEY_X = 0x58;
- final static int VK_KEY_Y = 0x59;
- final static int VK_KEY_Z = 0x5A;
- final static int VK_LWIN = 0x5B;
- final static int VK_RWIN = 0x5C;
- final static int VK_APPS = 0x5D;
- final static int VK_SLEEP = 0x5F;
- final static int VK_NUMPAD0 = 0x60;
- final static int VK_NUMPAD1 = 0x61;
- final static int VK_NUMPAD2 = 0x62;
- final static int VK_NUMPAD3 = 0x63;
- final static int VK_NUMPAD4 = 0x64;
- final static int VK_NUMPAD5 = 0x65;
- final static int VK_NUMPAD6 = 0x66;
- final static int VK_NUMPAD7 = 0x67;
- final static int VK_NUMPAD8 = 0x68;
- final static int VK_NUMPAD9 = 0x69;
- final static int VK_MULTIPLY = 0x6A;
- final static int VK_ADD = 0x6B;
- final static int VK_SEPARATOR = 0x6C;
- final static int VK_SUBTRACT = 0x6D;
- final static int VK_DECIMAL = 0x6E;
- final static int VK_DIVIDE = 0x6F;
- final static int VK_F1 = 0x70;
- final static int VK_F2 = 0x71;
- final static int VK_F3 = 0x72;
- final static int VK_F4 = 0x73;
- final static int VK_F5 = 0x74;
- final static int VK_F6 = 0x75;
- final static int VK_F7 = 0x76;
- final static int VK_F8 = 0x77;
- final static int VK_F9 = 0x78;
- final static int VK_F10 = 0x79;
- final static int VK_F11 = 0x7A;
- final static int VK_F12 = 0x7B;
- final static int VK_F13 = 0x7C;
- final static int VK_F14 = 0x7D;
- final static int VK_F15 = 0x7E;
- final static int VK_F16 = 0x7F;
- final static int VK_F17 = 0x80;
- final static int VK_F18 = 0x81;
- final static int VK_F19 = 0x82;
- final static int VK_F20 = 0x83;
- final static int VK_F21 = 0x84;
- final static int VK_F22 = 0x85;
- final static int VK_F23 = 0x86;
- final static int VK_F24 = 0x87;
- final static int VK_NUMLOCK = 0x90;
- final static int VK_SCROLL = 0x91;
- final static int VK_LSHIFT = 0xA0;
- final static int VK_RSHIFT = 0xA1;
- final static int VK_LCONTROL = 0xA2;
- final static int VK_RCONTROL = 0xA3;
- final static int VK_LMENU = 0xA4;
- final static int VK_RMENU = 0xA5;
- final static int VK_BROWSER_BACK = 0xA6;
- final static int VK_BROWSER_FORWARD = 0xA7;
- final static int VK_BROWSER_REFRESH = 0xA8;
- final static int VK_BROWSER_STOP = 0xA9;
- final static int VK_BROWSER_SEARCH = 0xAA;
- final static int VK_BROWSER_FAVORITES = 0xAB;
- final static int VK_BROWSER_HOME = 0xAC;
- final static int VK_VOLUME_MUTE = 0xAD;
- final static int VK_VOLUME_DOWN = 0xAE;
- final static int VK_VOLUME_UP = 0xAF;
- final static int VK_MEDIA_NEXT_TRACK = 0xB0;
- final static int VK_MEDIA_PREV_TRACK = 0xB1;
- final static int VK_MEDIA_STOP = 0xB2;
- final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
- final static int VK_LAUNCH_MAIL = 0xB4;
- final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
- final static int VK_LAUNCH_APP1 = 0xB6;
- final static int VK_LAUNCH_APP2 = 0xB7;
- final static int VK_OEM_1 = 0xBA;
- final static int VK_OEM_PLUS = 0xBB;
- final static int VK_OEM_COMMA = 0xBC;
- final static int VK_OEM_MINUS = 0xBD;
- final static int VK_OEM_PERIOD = 0xBE;
- final static int VK_OEM_2 = 0xBF;
- final static int VK_OEM_3 = 0xC0;
- final static int VK_ABNT_C1 = 0xC1;
- final static int VK_ABNT_C2 = 0xC2;
- final static int VK_OEM_4 = 0xDB;
- final static int VK_OEM_5 = 0xDC;
- final static int VK_OEM_6 = 0xDD;
- final static int VK_OEM_7 = 0xDE;
- final static int VK_OEM_8 = 0xDF;
- final static int VK_OEM_102 = 0xE2;
- final static int VK_PROCESSKEY = 0xE5;
- final static int VK_PACKET = 0xE7;
- final static int VK_ATTN = 0xF6;
- final static int VK_CRSEL = 0xF7;
- final static int VK_EXSEL = 0xF8;
- final static int VK_EREOF = 0xF9;
- final static int VK_PLAY = 0xFA;
- final static int VK_ZOOM = 0xFB;
- final static int VK_NONAME = 0xFC;
- final static int VK_PA1 = 0xFD;
- final static int VK_OEM_CLEAR = 0xFE;
- final static int VK_UNICODE = 0x80000000;
- final static int VK_EXT_KEY = 0x00000100;
- // key codes to switch between custom keyboard
- private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100;
- private final static int EXTKEY_KBNUMPAD = 0x1101;
- private final static int EXTKEY_KBCURSOR = 0x1102;
- // this flag indicates if we got a VK or a unicode character in our translation map
- private static final int KEY_FLAG_UNICODE = 0x80000000;
- // this flag indicates if the key is a toggle key (remains down when pressed and goes up if pressed again)
- private static final int KEY_FLAG_TOGGLE = 0x40000000;
- private static int[] keymapAndroid;
- private static int[] keymapExt;
- private static boolean initialized = false;
- private KeyProcessingListener listener = null;
- private boolean shiftPressed = false;
- private boolean ctrlPressed = false;
- private boolean altPressed = false;
- private boolean winPressed = false;
- private long lastModifierTime;
- private int lastModifierKeyCode = -1;
- private boolean isShiftLocked = false;
- private boolean isCtrlLocked = false;
- private boolean isAltLocked = false;
- private boolean isWinLocked = false;
+ // defines key states for modifier keys - locked means on and no auto-release if an other key is
+ // pressed
+ public static final int KEYSTATE_ON = 1;
+ public static final int KEYSTATE_LOCKED = 2;
+ public static final int KEYSTATE_OFF = 3;
+ final static int VK_LBUTTON = 0x01;
+ final static int VK_RBUTTON = 0x02;
+ final static int VK_CANCEL = 0x03;
+ final static int VK_MBUTTON = 0x04;
+ final static int VK_XBUTTON1 = 0x05;
+ final static int VK_XBUTTON2 = 0x06;
+ final static int VK_BACK = 0x08;
+ final static int VK_TAB = 0x09;
+ final static int VK_CLEAR = 0x0C;
+ final static int VK_RETURN = 0x0D;
+ final static int VK_SHIFT = 0x10;
+ final static int VK_CONTROL = 0x11;
+ final static int VK_MENU = 0x12;
+ final static int VK_PAUSE = 0x13;
+ final static int VK_CAPITAL = 0x14;
+ final static int VK_KANA = 0x15;
+ final static int VK_HANGUEL = 0x15;
+ final static int VK_HANGUL = 0x15;
+ final static int VK_JUNJA = 0x17;
+ final static int VK_FINAL = 0x18;
+ final static int VK_HANJA = 0x19;
+ final static int VK_KANJI = 0x19;
+ final static int VK_ESCAPE = 0x1B;
+ final static int VK_CONVERT = 0x1C;
+ final static int VK_NONCONVERT = 0x1D;
+ final static int VK_ACCEPT = 0x1E;
+ final static int VK_MODECHANGE = 0x1F;
+ final static int VK_SPACE = 0x20;
+ final static int VK_PRIOR = 0x21;
+ final static int VK_NEXT = 0x22;
+ final static int VK_END = 0x23;
+ final static int VK_HOME = 0x24;
+ final static int VK_LEFT = 0x25;
+ final static int VK_UP = 0x26;
+ final static int VK_RIGHT = 0x27;
+ final static int VK_DOWN = 0x28;
+ final static int VK_SELECT = 0x29;
+ final static int VK_PRINT = 0x2A;
+ final static int VK_EXECUTE = 0x2B;
+ final static int VK_SNAPSHOT = 0x2C;
+ final static int VK_INSERT = 0x2D;
+ final static int VK_DELETE = 0x2E;
+ final static int VK_HELP = 0x2F;
+ final static int VK_KEY_0 = 0x30;
+ final static int VK_KEY_1 = 0x31;
+ final static int VK_KEY_2 = 0x32;
+ final static int VK_KEY_3 = 0x33;
+ final static int VK_KEY_4 = 0x34;
+ final static int VK_KEY_5 = 0x35;
+ final static int VK_KEY_6 = 0x36;
+ final static int VK_KEY_7 = 0x37;
+ final static int VK_KEY_8 = 0x38;
+ final static int VK_KEY_9 = 0x39;
+ final static int VK_KEY_A = 0x41;
+ final static int VK_KEY_B = 0x42;
+ final static int VK_KEY_C = 0x43;
+ final static int VK_KEY_D = 0x44;
+ final static int VK_KEY_E = 0x45;
+ final static int VK_KEY_F = 0x46;
+ final static int VK_KEY_G = 0x47;
+ final static int VK_KEY_H = 0x48;
+ final static int VK_KEY_I = 0x49;
+ final static int VK_KEY_J = 0x4A;
+ final static int VK_KEY_K = 0x4B;
+ final static int VK_KEY_L = 0x4C;
+ final static int VK_KEY_M = 0x4D;
+ final static int VK_KEY_N = 0x4E;
+ final static int VK_KEY_O = 0x4F;
+ final static int VK_KEY_P = 0x50;
+ final static int VK_KEY_Q = 0x51;
+ final static int VK_KEY_R = 0x52;
+ final static int VK_KEY_S = 0x53;
+ final static int VK_KEY_T = 0x54;
+ final static int VK_KEY_U = 0x55;
+ final static int VK_KEY_V = 0x56;
+ final static int VK_KEY_W = 0x57;
+ final static int VK_KEY_X = 0x58;
+ final static int VK_KEY_Y = 0x59;
+ final static int VK_KEY_Z = 0x5A;
+ final static int VK_LWIN = 0x5B;
+ final static int VK_RWIN = 0x5C;
+ final static int VK_APPS = 0x5D;
+ final static int VK_SLEEP = 0x5F;
+ final static int VK_NUMPAD0 = 0x60;
+ final static int VK_NUMPAD1 = 0x61;
+ final static int VK_NUMPAD2 = 0x62;
+ final static int VK_NUMPAD3 = 0x63;
+ final static int VK_NUMPAD4 = 0x64;
+ final static int VK_NUMPAD5 = 0x65;
+ final static int VK_NUMPAD6 = 0x66;
+ final static int VK_NUMPAD7 = 0x67;
+ final static int VK_NUMPAD8 = 0x68;
+ final static int VK_NUMPAD9 = 0x69;
+ final static int VK_MULTIPLY = 0x6A;
+ final static int VK_ADD = 0x6B;
+ final static int VK_SEPARATOR = 0x6C;
+ final static int VK_SUBTRACT = 0x6D;
+ final static int VK_DECIMAL = 0x6E;
+ final static int VK_DIVIDE = 0x6F;
+ final static int VK_F1 = 0x70;
+ final static int VK_F2 = 0x71;
+ final static int VK_F3 = 0x72;
+ final static int VK_F4 = 0x73;
+ final static int VK_F5 = 0x74;
+ final static int VK_F6 = 0x75;
+ final static int VK_F7 = 0x76;
+ final static int VK_F8 = 0x77;
+ final static int VK_F9 = 0x78;
+ final static int VK_F10 = 0x79;
+ final static int VK_F11 = 0x7A;
+ final static int VK_F12 = 0x7B;
+ final static int VK_F13 = 0x7C;
+ final static int VK_F14 = 0x7D;
+ final static int VK_F15 = 0x7E;
+ final static int VK_F16 = 0x7F;
+ final static int VK_F17 = 0x80;
+ final static int VK_F18 = 0x81;
+ final static int VK_F19 = 0x82;
+ final static int VK_F20 = 0x83;
+ final static int VK_F21 = 0x84;
+ final static int VK_F22 = 0x85;
+ final static int VK_F23 = 0x86;
+ final static int VK_F24 = 0x87;
+ final static int VK_NUMLOCK = 0x90;
+ final static int VK_SCROLL = 0x91;
+ final static int VK_LSHIFT = 0xA0;
+ final static int VK_RSHIFT = 0xA1;
+ final static int VK_LCONTROL = 0xA2;
+ final static int VK_RCONTROL = 0xA3;
+ final static int VK_LMENU = 0xA4;
+ final static int VK_RMENU = 0xA5;
+ final static int VK_BROWSER_BACK = 0xA6;
+ final static int VK_BROWSER_FORWARD = 0xA7;
+ final static int VK_BROWSER_REFRESH = 0xA8;
+ final static int VK_BROWSER_STOP = 0xA9;
+ final static int VK_BROWSER_SEARCH = 0xAA;
+ final static int VK_BROWSER_FAVORITES = 0xAB;
+ final static int VK_BROWSER_HOME = 0xAC;
+ final static int VK_VOLUME_MUTE = 0xAD;
+ final static int VK_VOLUME_DOWN = 0xAE;
+ final static int VK_VOLUME_UP = 0xAF;
+ final static int VK_MEDIA_NEXT_TRACK = 0xB0;
+ final static int VK_MEDIA_PREV_TRACK = 0xB1;
+ final static int VK_MEDIA_STOP = 0xB2;
+ final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
+ final static int VK_LAUNCH_MAIL = 0xB4;
+ final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
+ final static int VK_LAUNCH_APP1 = 0xB6;
+ final static int VK_LAUNCH_APP2 = 0xB7;
+ final static int VK_OEM_1 = 0xBA;
+ final static int VK_OEM_PLUS = 0xBB;
+ final static int VK_OEM_COMMA = 0xBC;
+ final static int VK_OEM_MINUS = 0xBD;
+ final static int VK_OEM_PERIOD = 0xBE;
+ final static int VK_OEM_2 = 0xBF;
+ final static int VK_OEM_3 = 0xC0;
+ final static int VK_ABNT_C1 = 0xC1;
+ final static int VK_ABNT_C2 = 0xC2;
+ final static int VK_OEM_4 = 0xDB;
+ final static int VK_OEM_5 = 0xDC;
+ final static int VK_OEM_6 = 0xDD;
+ final static int VK_OEM_7 = 0xDE;
+ final static int VK_OEM_8 = 0xDF;
+ final static int VK_OEM_102 = 0xE2;
+ final static int VK_PROCESSKEY = 0xE5;
+ final static int VK_PACKET = 0xE7;
+ final static int VK_ATTN = 0xF6;
+ final static int VK_CRSEL = 0xF7;
+ final static int VK_EXSEL = 0xF8;
+ final static int VK_EREOF = 0xF9;
+ final static int VK_PLAY = 0xFA;
+ final static int VK_ZOOM = 0xFB;
+ final static int VK_NONAME = 0xFC;
+ final static int VK_PA1 = 0xFD;
+ final static int VK_OEM_CLEAR = 0xFE;
+ final static int VK_UNICODE = 0x80000000;
+ final static int VK_EXT_KEY = 0x00000100;
+ // key codes to switch between custom keyboard
+ private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100;
+ private final static int EXTKEY_KBNUMPAD = 0x1101;
+ private final static int EXTKEY_KBCURSOR = 0x1102;
+ // this flag indicates if we got a VK or a unicode character in our translation map
+ private static final int KEY_FLAG_UNICODE = 0x80000000;
+ // this flag indicates if the key is a toggle key (remains down when pressed and goes up if
+ // pressed again)
+ private static final int KEY_FLAG_TOGGLE = 0x40000000;
+ private static int[] keymapAndroid;
+ private static int[] keymapExt;
+ private static boolean initialized = false;
+ private KeyProcessingListener listener = null;
+ private boolean shiftPressed = false;
+ private boolean ctrlPressed = false;
+ private boolean altPressed = false;
+ private boolean winPressed = false;
+ private long lastModifierTime;
+ private int lastModifierKeyCode = -1;
+ private boolean isShiftLocked = false;
+ private boolean isCtrlLocked = false;
+ private boolean isAltLocked = false;
+ private boolean isWinLocked = false;
- public void init(Context context) {
- if (initialized == true)
- return;
+ public void init(Context context)
+ {
+ if (initialized == true)
+ return;
- keymapAndroid = new int[256];
+ keymapAndroid = new int[256];
- keymapAndroid[KeyEvent.KEYCODE_0] = VK_KEY_0;
- keymapAndroid[KeyEvent.KEYCODE_1] = VK_KEY_1;
- keymapAndroid[KeyEvent.KEYCODE_2] = VK_KEY_2;
- keymapAndroid[KeyEvent.KEYCODE_3] = VK_KEY_3;
- keymapAndroid[KeyEvent.KEYCODE_4] = VK_KEY_4;
- keymapAndroid[KeyEvent.KEYCODE_5] = VK_KEY_5;
- keymapAndroid[KeyEvent.KEYCODE_6] = VK_KEY_6;
- keymapAndroid[KeyEvent.KEYCODE_7] = VK_KEY_7;
- keymapAndroid[KeyEvent.KEYCODE_8] = VK_KEY_8;
- keymapAndroid[KeyEvent.KEYCODE_9] = VK_KEY_9;
+ keymapAndroid[KeyEvent.KEYCODE_0] = VK_KEY_0;
+ keymapAndroid[KeyEvent.KEYCODE_1] = VK_KEY_1;
+ keymapAndroid[KeyEvent.KEYCODE_2] = VK_KEY_2;
+ keymapAndroid[KeyEvent.KEYCODE_3] = VK_KEY_3;
+ keymapAndroid[KeyEvent.KEYCODE_4] = VK_KEY_4;
+ keymapAndroid[KeyEvent.KEYCODE_5] = VK_KEY_5;
+ keymapAndroid[KeyEvent.KEYCODE_6] = VK_KEY_6;
+ keymapAndroid[KeyEvent.KEYCODE_7] = VK_KEY_7;
+ keymapAndroid[KeyEvent.KEYCODE_8] = VK_KEY_8;
+ keymapAndroid[KeyEvent.KEYCODE_9] = VK_KEY_9;
- keymapAndroid[KeyEvent.KEYCODE_A] = VK_KEY_A;
- keymapAndroid[KeyEvent.KEYCODE_B] = VK_KEY_B;
- keymapAndroid[KeyEvent.KEYCODE_C] = VK_KEY_C;
- keymapAndroid[KeyEvent.KEYCODE_D] = VK_KEY_D;
- keymapAndroid[KeyEvent.KEYCODE_E] = VK_KEY_E;
- keymapAndroid[KeyEvent.KEYCODE_F] = VK_KEY_F;
- keymapAndroid[KeyEvent.KEYCODE_G] = VK_KEY_G;
- keymapAndroid[KeyEvent.KEYCODE_H] = VK_KEY_H;
- keymapAndroid[KeyEvent.KEYCODE_I] = VK_KEY_I;
- keymapAndroid[KeyEvent.KEYCODE_J] = VK_KEY_J;
- keymapAndroid[KeyEvent.KEYCODE_K] = VK_KEY_K;
- keymapAndroid[KeyEvent.KEYCODE_L] = VK_KEY_L;
- keymapAndroid[KeyEvent.KEYCODE_M] = VK_KEY_M;
- keymapAndroid[KeyEvent.KEYCODE_N] = VK_KEY_N;
- keymapAndroid[KeyEvent.KEYCODE_O] = VK_KEY_O;
- keymapAndroid[KeyEvent.KEYCODE_P] = VK_KEY_P;
- keymapAndroid[KeyEvent.KEYCODE_Q] = VK_KEY_Q;
- keymapAndroid[KeyEvent.KEYCODE_R] = VK_KEY_R;
- keymapAndroid[KeyEvent.KEYCODE_S] = VK_KEY_S;
- keymapAndroid[KeyEvent.KEYCODE_T] = VK_KEY_T;
- keymapAndroid[KeyEvent.KEYCODE_U] = VK_KEY_U;
- keymapAndroid[KeyEvent.KEYCODE_V] = VK_KEY_V;
- keymapAndroid[KeyEvent.KEYCODE_W] = VK_KEY_W;
- keymapAndroid[KeyEvent.KEYCODE_X] = VK_KEY_X;
- keymapAndroid[KeyEvent.KEYCODE_Y] = VK_KEY_Y;
- keymapAndroid[KeyEvent.KEYCODE_Z] = VK_KEY_Z;
+ keymapAndroid[KeyEvent.KEYCODE_A] = VK_KEY_A;
+ keymapAndroid[KeyEvent.KEYCODE_B] = VK_KEY_B;
+ keymapAndroid[KeyEvent.KEYCODE_C] = VK_KEY_C;
+ keymapAndroid[KeyEvent.KEYCODE_D] = VK_KEY_D;
+ keymapAndroid[KeyEvent.KEYCODE_E] = VK_KEY_E;
+ keymapAndroid[KeyEvent.KEYCODE_F] = VK_KEY_F;
+ keymapAndroid[KeyEvent.KEYCODE_G] = VK_KEY_G;
+ keymapAndroid[KeyEvent.KEYCODE_H] = VK_KEY_H;
+ keymapAndroid[KeyEvent.KEYCODE_I] = VK_KEY_I;
+ keymapAndroid[KeyEvent.KEYCODE_J] = VK_KEY_J;
+ keymapAndroid[KeyEvent.KEYCODE_K] = VK_KEY_K;
+ keymapAndroid[KeyEvent.KEYCODE_L] = VK_KEY_L;
+ keymapAndroid[KeyEvent.KEYCODE_M] = VK_KEY_M;
+ keymapAndroid[KeyEvent.KEYCODE_N] = VK_KEY_N;
+ keymapAndroid[KeyEvent.KEYCODE_O] = VK_KEY_O;
+ keymapAndroid[KeyEvent.KEYCODE_P] = VK_KEY_P;
+ keymapAndroid[KeyEvent.KEYCODE_Q] = VK_KEY_Q;
+ keymapAndroid[KeyEvent.KEYCODE_R] = VK_KEY_R;
+ keymapAndroid[KeyEvent.KEYCODE_S] = VK_KEY_S;
+ keymapAndroid[KeyEvent.KEYCODE_T] = VK_KEY_T;
+ keymapAndroid[KeyEvent.KEYCODE_U] = VK_KEY_U;
+ keymapAndroid[KeyEvent.KEYCODE_V] = VK_KEY_V;
+ keymapAndroid[KeyEvent.KEYCODE_W] = VK_KEY_W;
+ keymapAndroid[KeyEvent.KEYCODE_X] = VK_KEY_X;
+ keymapAndroid[KeyEvent.KEYCODE_Y] = VK_KEY_Y;
+ keymapAndroid[KeyEvent.KEYCODE_Z] = VK_KEY_Z;
- keymapAndroid[KeyEvent.KEYCODE_DEL] = VK_BACK;
- keymapAndroid[KeyEvent.KEYCODE_ENTER] = VK_RETURN;
- keymapAndroid[KeyEvent.KEYCODE_SPACE] = VK_SPACE;
- keymapAndroid[KeyEvent.KEYCODE_TAB] = VK_TAB;
-// keymapAndroid[KeyEvent.KEYCODE_SHIFT_LEFT] = VK_LSHIFT;
-// keymapAndroid[KeyEvent.KEYCODE_SHIFT_RIGHT] = VK_RSHIFT;
+ keymapAndroid[KeyEvent.KEYCODE_DEL] = VK_BACK;
+ keymapAndroid[KeyEvent.KEYCODE_ENTER] = VK_RETURN;
+ keymapAndroid[KeyEvent.KEYCODE_SPACE] = VK_SPACE;
+ keymapAndroid[KeyEvent.KEYCODE_TAB] = VK_TAB;
+ // keymapAndroid[KeyEvent.KEYCODE_SHIFT_LEFT] = VK_LSHIFT;
+ // keymapAndroid[KeyEvent.KEYCODE_SHIFT_RIGHT] = VK_RSHIFT;
-// keymapAndroid[KeyEvent.KEYCODE_DPAD_DOWN] = VK_DOWN;
-// keymapAndroid[KeyEvent.KEYCODE_DPAD_LEFT] = VK_LEFT;
-// keymapAndroid[KeyEvent.KEYCODE_DPAD_RIGHT] = VK_RIGHT;
-// keymapAndroid[KeyEvent.KEYCODE_DPAD_UP] = VK_UP;
+ // keymapAndroid[KeyEvent.KEYCODE_DPAD_DOWN] = VK_DOWN;
+ // keymapAndroid[KeyEvent.KEYCODE_DPAD_LEFT] = VK_LEFT;
+ // keymapAndroid[KeyEvent.KEYCODE_DPAD_RIGHT] = VK_RIGHT;
+ // keymapAndroid[KeyEvent.KEYCODE_DPAD_UP] = VK_UP;
-// keymapAndroid[KeyEvent.KEYCODE_COMMA] = VK_OEM_COMMA;
-// keymapAndroid[KeyEvent.KEYCODE_PERIOD] = VK_OEM_PERIOD;
-// keymapAndroid[KeyEvent.KEYCODE_MINUS] = VK_OEM_MINUS;
-// keymapAndroid[KeyEvent.KEYCODE_PLUS] = VK_OEM_PLUS;
+ // keymapAndroid[KeyEvent.KEYCODE_COMMA] = VK_OEM_COMMA;
+ // keymapAndroid[KeyEvent.KEYCODE_PERIOD] = VK_OEM_PERIOD;
+ // keymapAndroid[KeyEvent.KEYCODE_MINUS] = VK_OEM_MINUS;
+ // keymapAndroid[KeyEvent.KEYCODE_PLUS] = VK_OEM_PLUS;
-// keymapAndroid[KeyEvent.KEYCODE_ALT_LEFT] = VK_LMENU;
-// keymapAndroid[KeyEvent.KEYCODE_ALT_RIGHT] = VK_RMENU;
+ // keymapAndroid[KeyEvent.KEYCODE_ALT_LEFT] = VK_LMENU;
+ // keymapAndroid[KeyEvent.KEYCODE_ALT_RIGHT] = VK_RMENU;
-// keymapAndroid[KeyEvent.KEYCODE_AT] = (KEY_FLAG_UNICODE | 64);
-// keymapAndroid[KeyEvent.KEYCODE_APOSTROPHE] = (KEY_FLAG_UNICODE | 39);
-// keymapAndroid[KeyEvent.KEYCODE_BACKSLASH] = (KEY_FLAG_UNICODE | 92);
-// keymapAndroid[KeyEvent.KEYCODE_COMMA] = (KEY_FLAG_UNICODE | 44);
-// keymapAndroid[KeyEvent.KEYCODE_EQUALS] = (KEY_FLAG_UNICODE | 61);
-// keymapAndroid[KeyEvent.KEYCODE_GRAVE] = (KEY_FLAG_UNICODE | 96);
-// keymapAndroid[KeyEvent.KEYCODE_LEFT_BRACKET] = (KEY_FLAG_UNICODE | 91);
-// keymapAndroid[KeyEvent.KEYCODE_RIGHT_BRACKET] = (KEY_FLAG_UNICODE | 93);
-// keymapAndroid[KeyEvent.KEYCODE_MINUS] = (KEY_FLAG_UNICODE | 45);
-// keymapAndroid[KeyEvent.KEYCODE_PERIOD] = (KEY_FLAG_UNICODE | 46);
-// keymapAndroid[KeyEvent.KEYCODE_PLUS] = (KEY_FLAG_UNICODE | 43);
-// keymapAndroid[KeyEvent.KEYCODE_POUND] = (KEY_FLAG_UNICODE | 35);
-// keymapAndroid[KeyEvent.KEYCODE_SEMICOLON] = (KEY_FLAG_UNICODE | 59);
-// keymapAndroid[KeyEvent.KEYCODE_SLASH] = (KEY_FLAG_UNICODE | 47);
-// keymapAndroid[KeyEvent.KEYCODE_STAR] = (KEY_FLAG_UNICODE | 42);
+ // keymapAndroid[KeyEvent.KEYCODE_AT] = (KEY_FLAG_UNICODE | 64);
+ // keymapAndroid[KeyEvent.KEYCODE_APOSTROPHE] = (KEY_FLAG_UNICODE | 39);
+ // keymapAndroid[KeyEvent.KEYCODE_BACKSLASH] = (KEY_FLAG_UNICODE | 92);
+ // keymapAndroid[KeyEvent.KEYCODE_COMMA] = (KEY_FLAG_UNICODE | 44);
+ // keymapAndroid[KeyEvent.KEYCODE_EQUALS] = (KEY_FLAG_UNICODE | 61);
+ // keymapAndroid[KeyEvent.KEYCODE_GRAVE] = (KEY_FLAG_UNICODE | 96);
+ // keymapAndroid[KeyEvent.KEYCODE_LEFT_BRACKET] = (KEY_FLAG_UNICODE | 91);
+ // keymapAndroid[KeyEvent.KEYCODE_RIGHT_BRACKET] = (KEY_FLAG_UNICODE | 93);
+ // keymapAndroid[KeyEvent.KEYCODE_MINUS] = (KEY_FLAG_UNICODE | 45);
+ // keymapAndroid[KeyEvent.KEYCODE_PERIOD] = (KEY_FLAG_UNICODE | 46);
+ // keymapAndroid[KeyEvent.KEYCODE_PLUS] = (KEY_FLAG_UNICODE | 43);
+ // keymapAndroid[KeyEvent.KEYCODE_POUND] = (KEY_FLAG_UNICODE | 35);
+ // keymapAndroid[KeyEvent.KEYCODE_SEMICOLON] = (KEY_FLAG_UNICODE | 59);
+ // keymapAndroid[KeyEvent.KEYCODE_SLASH] = (KEY_FLAG_UNICODE | 47);
+ // keymapAndroid[KeyEvent.KEYCODE_STAR] = (KEY_FLAG_UNICODE | 42);
- // special keys mapping
- keymapExt = new int[256];
- keymapExt[context.getResources().getInteger(R.integer.keycode_F1)] = VK_F1;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F2)] = VK_F2;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F3)] = VK_F3;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F4)] = VK_F4;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F5)] = VK_F5;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F6)] = VK_F6;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F7)] = VK_F7;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F8)] = VK_F8;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F9)] = VK_F9;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F10)] = VK_F10;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F11)] = VK_F11;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12;
- keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB;
- keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT;
- keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] = VK_INSERT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] = VK_DELETE | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] = VK_PRIOR | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY;
+ // special keys mapping
+ keymapExt = new int[256];
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F1)] = VK_F1;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F2)] = VK_F2;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F3)] = VK_F3;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F4)] = VK_F4;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F5)] = VK_F5;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F6)] = VK_F6;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F7)] = VK_F7;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F8)] = VK_F8;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F9)] = VK_F9;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F10)] = VK_F10;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F11)] = VK_F11;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] =
+ VK_INSERT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] =
+ VK_DELETE | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] =
+ VK_PRIOR | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY;
- // numpad mapping
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_1)] = VK_NUMPAD1;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_2)] = VK_NUMPAD2;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_3)] = VK_NUMPAD3;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_4)] = VK_NUMPAD4;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_5)] = VK_NUMPAD5;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_6)] = VK_NUMPAD6;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_7)] = VK_NUMPAD7;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_8)] = VK_NUMPAD8;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_9)] = VK_NUMPAD9;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] = VK_DIVIDE | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] = VK_RETURN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] = VK_MULTIPLY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] = VK_SUBTRACT;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] = (KEY_FLAG_UNICODE | 61);
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_left_paren)] = (KEY_FLAG_UNICODE | 40);
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] = (KEY_FLAG_UNICODE | 41);
+ // numpad mapping
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_1)] = VK_NUMPAD1;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_2)] = VK_NUMPAD2;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_3)] = VK_NUMPAD3;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_4)] = VK_NUMPAD4;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_5)] = VK_NUMPAD5;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_6)] = VK_NUMPAD6;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_7)] = VK_NUMPAD7;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_8)] = VK_NUMPAD8;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_9)] = VK_NUMPAD9;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] =
+ VK_DIVIDE | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] =
+ VK_RETURN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] =
+ VK_MULTIPLY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] =
+ VK_SUBTRACT;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] =
+ (KEY_FLAG_UNICODE | 61);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_left_paren)] =
+ (KEY_FLAG_UNICODE | 40);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] =
+ (KEY_FLAG_UNICODE | 41);
- // cursor key codes
- keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_right)] = VK_RIGHT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] = VK_RETURN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK;
+ // cursor key codes
+ keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_right)] =
+ VK_RIGHT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] =
+ VK_RETURN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK;
- // shared keys
- keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE;
+ // shared keys
+ keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE;
-/* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] = VK_LCONTROL;
- keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_alt)] = VK_LMENU;
- keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_shift)] = VK_LSHIFT;
-*/
- // get custom keyboard key codes
- keymapExt[context.getResources().getInteger(R.integer.keycode_specialkeys_keyboard)] = EXTKEY_KBFUNCTIONKEYS;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_keyboard)] = EXTKEY_KBNUMPAD;
- keymapExt[context.getResources().getInteger(R.integer.keycode_cursor_keyboard)] = EXTKEY_KBCURSOR;
+ /* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] =
+ VK_LCONTROL; keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_alt)]
+ = VK_LMENU;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_shift)] =
+ VK_LSHIFT;
+ */
+ // get custom keyboard key codes
+ keymapExt[context.getResources().getInteger(R.integer.keycode_specialkeys_keyboard)] =
+ EXTKEY_KBFUNCTIONKEYS;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_keyboard)] =
+ EXTKEY_KBNUMPAD;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_cursor_keyboard)] =
+ EXTKEY_KBCURSOR;
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_shift)] = (KEY_FLAG_TOGGLE | VK_LSHIFT);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_ctrl)] = (KEY_FLAG_TOGGLE | VK_LCONTROL);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_alt)] = (KEY_FLAG_TOGGLE | VK_LMENU);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_win)] = (KEY_FLAG_TOGGLE | VK_LWIN);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_shift)] =
+ (KEY_FLAG_TOGGLE | VK_LSHIFT);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_ctrl)] =
+ (KEY_FLAG_TOGGLE | VK_LCONTROL);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_alt)] =
+ (KEY_FLAG_TOGGLE | VK_LMENU);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_win)] =
+ (KEY_FLAG_TOGGLE | VK_LWIN);
- initialized = true;
- }
+ initialized = true;
+ }
- public void reset(KeyProcessingListener listener) {
- shiftPressed = false;
- ctrlPressed = false;
- altPressed = false;
- winPressed = false;
- setKeyProcessingListener(listener);
- }
+ public void reset(KeyProcessingListener listener)
+ {
+ shiftPressed = false;
+ ctrlPressed = false;
+ altPressed = false;
+ winPressed = false;
+ setKeyProcessingListener(listener);
+ }
- public void setKeyProcessingListener(KeyProcessingListener listener) {
- this.listener = listener;
- }
+ public void setKeyProcessingListener(KeyProcessingListener listener)
+ {
+ this.listener = listener;
+ }
- public boolean processAndroidKeyEvent(KeyEvent event) {
- switch (event.getAction()) {
- // we only process down events
- case KeyEvent.ACTION_UP: {
- return false;
- }
+ public boolean processAndroidKeyEvent(KeyEvent event)
+ {
+ switch (event.getAction())
+ {
+ // we only process down events
+ case KeyEvent.ACTION_UP:
+ {
+ return false;
+ }
- case KeyEvent.ACTION_DOWN: {
- boolean modifierActive = isModifierPressed();
- // if a modifier is pressed we will send a VK event (if possible) so that key combinations will be
- // recognized correctly. Otherwise we will send the unicode key. At the end we will reset all modifiers
- // and notifiy our listener.
- int vkcode = getVirtualKeyCode(event.getKeyCode());
- if ((vkcode & KEY_FLAG_UNICODE) != 0)
- listener.processUnicodeKey(vkcode & (~KEY_FLAG_UNICODE));
- // if we got a valid vkcode send it - except for letters/numbers if a modifier is active
- else if (vkcode > 0 && (event.getMetaState() & (KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) {
- listener.processVirtualKey(vkcode, true);
- listener.processVirtualKey(vkcode, false);
- } else if (event.isShiftPressed() && vkcode != 0) {
- listener.processVirtualKey(VK_LSHIFT, true);
- listener.processVirtualKey(vkcode, true);
- listener.processVirtualKey(vkcode, false);
- listener.processVirtualKey(VK_LSHIFT, false);
- } else if (event.getUnicodeChar() != 0)
- listener.processUnicodeKey(event.getUnicodeChar());
- else
- return false;
+ case KeyEvent.ACTION_DOWN:
+ {
+ boolean modifierActive = isModifierPressed();
+ // if a modifier is pressed we will send a VK event (if possible) so that key
+ // combinations will be recognized correctly. Otherwise we will send the unicode
+ // key. At the end we will reset all modifiers and notifiy our listener.
+ int vkcode = getVirtualKeyCode(event.getKeyCode());
+ if ((vkcode & KEY_FLAG_UNICODE) != 0)
+ listener.processUnicodeKey(vkcode & (~KEY_FLAG_UNICODE));
+ // if we got a valid vkcode send it - except for letters/numbers if a modifier is
+ // active
+ else if (vkcode > 0 &&
+ (event.getMetaState() & (KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON |
+ KeyEvent.META_SYM_ON)) == 0)
+ {
+ listener.processVirtualKey(vkcode, true);
+ listener.processVirtualKey(vkcode, false);
+ }
+ else if (event.isShiftPressed() && vkcode != 0)
+ {
+ listener.processVirtualKey(VK_LSHIFT, true);
+ listener.processVirtualKey(vkcode, true);
+ listener.processVirtualKey(vkcode, false);
+ listener.processVirtualKey(VK_LSHIFT, false);
+ }
+ else if (event.getUnicodeChar() != 0)
+ listener.processUnicodeKey(event.getUnicodeChar());
+ else
+ return false;
- // reset any pending toggle states if a modifier was pressed
- if (modifierActive)
- resetModifierKeysAfterInput(false);
- return true;
- }
+ // reset any pending toggle states if a modifier was pressed
+ if (modifierActive)
+ resetModifierKeysAfterInput(false);
+ return true;
+ }
- case KeyEvent.ACTION_MULTIPLE: {
- String str = event.getCharacters();
- for (int i = 0; i < str.length(); i++)
- listener.processUnicodeKey(str.charAt(i));
- return true;
- }
+ case KeyEvent.ACTION_MULTIPLE:
+ {
+ String str = event.getCharacters();
+ for (int i = 0; i < str.length(); i++)
+ listener.processUnicodeKey(str.charAt(i));
+ return true;
+ }
- default:
- break;
- }
- return false;
- }
+ default:
+ break;
+ }
+ return false;
+ }
- public void processCustomKeyEvent(int keycode) {
- int extCode = getExtendedKeyCode(keycode);
- if (extCode == 0)
- return;
+ public void processCustomKeyEvent(int keycode)
+ {
+ int extCode = getExtendedKeyCode(keycode);
+ if (extCode == 0)
+ return;
- // toggle button pressed?
- if ((extCode & KEY_FLAG_TOGGLE) != 0) {
- processToggleButton(extCode & (~KEY_FLAG_TOGGLE));
- return;
- }
+ // toggle button pressed?
+ if ((extCode & KEY_FLAG_TOGGLE) != 0)
+ {
+ processToggleButton(extCode & (~KEY_FLAG_TOGGLE));
+ return;
+ }
- // keyboard switch button pressed?
- if (extCode == EXTKEY_KBFUNCTIONKEYS || extCode == EXTKEY_KBNUMPAD || extCode == EXTKEY_KBCURSOR) {
- switchKeyboard(extCode);
- return;
- }
+ // keyboard switch button pressed?
+ if (extCode == EXTKEY_KBFUNCTIONKEYS || extCode == EXTKEY_KBNUMPAD ||
+ extCode == EXTKEY_KBCURSOR)
+ {
+ switchKeyboard(extCode);
+ return;
+ }
- // nope - see if we got a unicode or vk
- if ((extCode & KEY_FLAG_UNICODE) != 0)
- listener.processUnicodeKey(extCode & (~KEY_FLAG_UNICODE));
- else {
- listener.processVirtualKey(extCode, true);
- listener.processVirtualKey(extCode, false);
- }
+ // nope - see if we got a unicode or vk
+ if ((extCode & KEY_FLAG_UNICODE) != 0)
+ listener.processUnicodeKey(extCode & (~KEY_FLAG_UNICODE));
+ else
+ {
+ listener.processVirtualKey(extCode, true);
+ listener.processVirtualKey(extCode, false);
+ }
- resetModifierKeysAfterInput(false);
- }
+ resetModifierKeysAfterInput(false);
+ }
- public void sendAltF4() {
- listener.processVirtualKey(VK_LMENU, true);
- listener.processVirtualKey(VK_F4, true);
- listener.processVirtualKey(VK_F4, false);
- listener.processVirtualKey(VK_LMENU, false);
- }
+ public void sendAltF4()
+ {
+ listener.processVirtualKey(VK_LMENU, true);
+ listener.processVirtualKey(VK_F4, true);
+ listener.processVirtualKey(VK_F4, false);
+ listener.processVirtualKey(VK_LMENU, false);
+ }
- private boolean isModifierPressed() {
- return (shiftPressed || ctrlPressed || altPressed || winPressed);
- }
+ private boolean isModifierPressed()
+ {
+ return (shiftPressed || ctrlPressed || altPressed || winPressed);
+ }
- public int getModifierState(int keycode) {
- int modifierCode = getExtendedKeyCode(keycode);
+ public int getModifierState(int keycode)
+ {
+ int modifierCode = getExtendedKeyCode(keycode);
- // check and get real modifier keycode
- if ((modifierCode & KEY_FLAG_TOGGLE) == 0)
- return -1;
- modifierCode = modifierCode & (~KEY_FLAG_TOGGLE);
+ // check and get real modifier keycode
+ if ((modifierCode & KEY_FLAG_TOGGLE) == 0)
+ return -1;
+ modifierCode = modifierCode & (~KEY_FLAG_TOGGLE);
- switch (modifierCode) {
- case VK_LSHIFT: {
- return (shiftPressed ? (isShiftLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LCONTROL: {
- return (ctrlPressed ? (isCtrlLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LMENU: {
- return (altPressed ? (isAltLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LWIN: {
- return (winPressed ? (isWinLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- }
+ switch (modifierCode)
+ {
+ case VK_LSHIFT:
+ {
+ return (shiftPressed ? (isShiftLocked ? KEYSTATE_LOCKED : KEYSTATE_ON)
+ : KEYSTATE_OFF);
+ }
+ case VK_LCONTROL:
+ {
+ return (ctrlPressed ? (isCtrlLocked ? KEYSTATE_LOCKED : KEYSTATE_ON)
+ : KEYSTATE_OFF);
+ }
+ case VK_LMENU:
+ {
+ return (altPressed ? (isAltLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ case VK_LWIN:
+ {
+ return (winPressed ? (isWinLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ }
- return -1;
- }
+ return -1;
+ }
- private int getVirtualKeyCode(int keycode) {
- if (keycode >= 0 && keycode <= 0xFF)
- return keymapAndroid[keycode];
- return 0;
- }
+ private int getVirtualKeyCode(int keycode)
+ {
+ if (keycode >= 0 && keycode <= 0xFF)
+ return keymapAndroid[keycode];
+ return 0;
+ }
- private int getExtendedKeyCode(int keycode) {
- if (keycode >= 0 && keycode <= 0xFF)
- return keymapExt[keycode];
- return 0;
- }
+ private int getExtendedKeyCode(int keycode)
+ {
+ if (keycode >= 0 && keycode <= 0xFF)
+ return keymapExt[keycode];
+ return 0;
+ }
- private void processToggleButton(int keycode) {
- switch (keycode) {
- case VK_LSHIFT: {
- if (!checkToggleModifierLock(VK_LSHIFT)) {
- isShiftLocked = false;
- shiftPressed = !shiftPressed;
- listener.processVirtualKey(VK_LSHIFT, shiftPressed);
- } else
- isShiftLocked = true;
- break;
- }
- case VK_LCONTROL: {
- if (!checkToggleModifierLock(VK_LCONTROL)) {
- isCtrlLocked = false;
- ctrlPressed = !ctrlPressed;
- listener.processVirtualKey(VK_LCONTROL, ctrlPressed);
- } else
- isCtrlLocked = true;
- break;
- }
- case VK_LMENU: {
- if (!checkToggleModifierLock(VK_LMENU)) {
- isAltLocked = false;
- altPressed = !altPressed;
- listener.processVirtualKey(VK_LMENU, altPressed);
- } else
- isAltLocked = true;
- break;
- }
- case VK_LWIN: {
- if (!checkToggleModifierLock(VK_LWIN)) {
- isWinLocked = false;
- winPressed = !winPressed;
- listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, winPressed);
- } else
- isWinLocked = true;
- break;
- }
- }
- listener.modifiersChanged();
- }
+ private void processToggleButton(int keycode)
+ {
+ switch (keycode)
+ {
+ case VK_LSHIFT:
+ {
+ if (!checkToggleModifierLock(VK_LSHIFT))
+ {
+ isShiftLocked = false;
+ shiftPressed = !shiftPressed;
+ listener.processVirtualKey(VK_LSHIFT, shiftPressed);
+ }
+ else
+ isShiftLocked = true;
+ break;
+ }
+ case VK_LCONTROL:
+ {
+ if (!checkToggleModifierLock(VK_LCONTROL))
+ {
+ isCtrlLocked = false;
+ ctrlPressed = !ctrlPressed;
+ listener.processVirtualKey(VK_LCONTROL, ctrlPressed);
+ }
+ else
+ isCtrlLocked = true;
+ break;
+ }
+ case VK_LMENU:
+ {
+ if (!checkToggleModifierLock(VK_LMENU))
+ {
+ isAltLocked = false;
+ altPressed = !altPressed;
+ listener.processVirtualKey(VK_LMENU, altPressed);
+ }
+ else
+ isAltLocked = true;
+ break;
+ }
+ case VK_LWIN:
+ {
+ if (!checkToggleModifierLock(VK_LWIN))
+ {
+ isWinLocked = false;
+ winPressed = !winPressed;
+ listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, winPressed);
+ }
+ else
+ isWinLocked = true;
+ break;
+ }
+ }
+ listener.modifiersChanged();
+ }
- public void clearlAllModifiers() {
- resetModifierKeysAfterInput(true);
- }
+ public void clearlAllModifiers()
+ {
+ resetModifierKeysAfterInput(true);
+ }
- private void resetModifierKeysAfterInput(boolean force) {
- if (shiftPressed && (!isShiftLocked || force)) {
- listener.processVirtualKey(VK_LSHIFT, false);
- shiftPressed = false;
- }
- if (ctrlPressed && (!isCtrlLocked || force)) {
- listener.processVirtualKey(VK_LCONTROL, false);
- ctrlPressed = false;
- }
- if (altPressed && (!isAltLocked || force)) {
- listener.processVirtualKey(VK_LMENU, false);
- altPressed = false;
- }
- if (winPressed && (!isWinLocked || force)) {
- listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
- winPressed = false;
- }
+ private void resetModifierKeysAfterInput(boolean force)
+ {
+ if (shiftPressed && (!isShiftLocked || force))
+ {
+ listener.processVirtualKey(VK_LSHIFT, false);
+ shiftPressed = false;
+ }
+ if (ctrlPressed && (!isCtrlLocked || force))
+ {
+ listener.processVirtualKey(VK_LCONTROL, false);
+ ctrlPressed = false;
+ }
+ if (altPressed && (!isAltLocked || force))
+ {
+ listener.processVirtualKey(VK_LMENU, false);
+ altPressed = false;
+ }
+ if (winPressed && (!isWinLocked || force))
+ {
+ listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
+ winPressed = false;
+ }
- if (listener != null)
- listener.modifiersChanged();
- }
+ if (listener != null)
+ listener.modifiersChanged();
+ }
- private void switchKeyboard(int keycode) {
- switch (keycode) {
- case EXTKEY_KBFUNCTIONKEYS: {
- listener.switchKeyboard(KEYBOARD_TYPE_FUNCTIONKEYS);
- break;
- }
+ private void switchKeyboard(int keycode)
+ {
+ switch (keycode)
+ {
+ case EXTKEY_KBFUNCTIONKEYS:
+ {
+ listener.switchKeyboard(KEYBOARD_TYPE_FUNCTIONKEYS);
+ break;
+ }
- case EXTKEY_KBNUMPAD: {
- listener.switchKeyboard(KEYBOARD_TYPE_NUMPAD);
- break;
- }
+ case EXTKEY_KBNUMPAD:
+ {
+ listener.switchKeyboard(KEYBOARD_TYPE_NUMPAD);
+ break;
+ }
- case EXTKEY_KBCURSOR: {
- listener.switchKeyboard(KEYBOARD_TYPE_CURSOR);
- break;
- }
+ case EXTKEY_KBCURSOR:
+ {
+ listener.switchKeyboard(KEYBOARD_TYPE_CURSOR);
+ break;
+ }
- default:
- break;
- }
- }
+ default:
+ break;
+ }
+ }
- private boolean checkToggleModifierLock(int keycode) {
- long now = System.currentTimeMillis();
+ private boolean checkToggleModifierLock(int keycode)
+ {
+ long now = System.currentTimeMillis();
- // was the same modifier hit?
- if (lastModifierKeyCode != keycode) {
- lastModifierKeyCode = keycode;
- lastModifierTime = now;
- return false;
- }
+ // was the same modifier hit?
+ if (lastModifierKeyCode != keycode)
+ {
+ lastModifierKeyCode = keycode;
+ lastModifierTime = now;
+ return false;
+ }
- // within a certain time interval?
- if (lastModifierTime + 800 > now) {
- lastModifierTime = 0;
- return true;
- } else {
- lastModifierTime = now;
- return false;
- }
- }
+ // within a certain time interval?
+ if (lastModifierTime + 800 > now)
+ {
+ lastModifierTime = 0;
+ return true;
+ }
+ else
+ {
+ lastModifierTime = now;
+ return false;
+ }
+ }
- // interface that gets called for input handling
- public interface KeyProcessingListener {
- abstract void processVirtualKey(int virtualKeyCode, boolean down);
+ // interface that gets called for input handling
+ public interface KeyProcessingListener {
+ abstract void processVirtualKey(int virtualKeyCode, boolean down);
- abstract void processUnicodeKey(int unicodeKey);
+ abstract void processUnicodeKey(int unicodeKey);
- abstract void switchKeyboard(int keyboardType);
-
- abstract void modifiersChanged();
- }
+ abstract void switchKeyboard(int keyboardType);
+ abstract void modifiersChanged();
+ }
}
-
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/Mouse.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/Mouse.java
index 2461486c9..11f1d3e47 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/Mouse.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/Mouse.java
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -13,47 +14,51 @@ import android.content.Context;
import com.freerdp.freerdpcore.presentation.ApplicationSettingsActivity;
-public class Mouse {
+public class Mouse
+{
- private final static int PTRFLAGS_LBUTTON = 0x1000;
- private final static int PTRFLAGS_RBUTTON = 0x2000;
+ private final static int PTRFLAGS_LBUTTON = 0x1000;
+ private final static int PTRFLAGS_RBUTTON = 0x2000;
- private final static int PTRFLAGS_DOWN = 0x8000;
- private final static int PTRFLAGS_MOVE = 0x0800;
+ private final static int PTRFLAGS_DOWN = 0x8000;
+ private final static int PTRFLAGS_MOVE = 0x0800;
- private final static int PTRFLAGS_WHEEL = 0x0200;
- private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
+ private final static int PTRFLAGS_WHEEL = 0x0200;
+ private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
- public static int getLeftButtonEvent(Context context, boolean down) {
- if (ApplicationSettingsActivity.getSwapMouseButtons(context))
- return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
- else
- return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
- }
+ public static int getLeftButtonEvent(Context context, boolean down)
+ {
+ if (ApplicationSettingsActivity.getSwapMouseButtons(context))
+ return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ else
+ return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ }
- public static int getRightButtonEvent(Context context, boolean down) {
- if (ApplicationSettingsActivity.getSwapMouseButtons(context))
- return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
- else
- return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
- }
+ public static int getRightButtonEvent(Context context, boolean down)
+ {
+ if (ApplicationSettingsActivity.getSwapMouseButtons(context))
+ return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ else
+ return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ }
- public static int getMoveEvent() {
- return PTRFLAGS_MOVE;
- }
+ public static int getMoveEvent()
+ {
+ return PTRFLAGS_MOVE;
+ }
- public static int getScrollEvent(Context context, boolean down) {
- int flags = PTRFLAGS_WHEEL;
+ public static int getScrollEvent(Context context, boolean down)
+ {
+ int flags = PTRFLAGS_WHEEL;
- // invert scrolling?
- if (ApplicationSettingsActivity.getInvertScrolling(context))
- down = !down;
-
- if (down)
- flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
- else
- flags |= 0x0078;
- return flags;
- }
+ // invert scrolling?
+ if (ApplicationSettingsActivity.getInvertScrolling(context))
+ down = !down;
+ if (down)
+ flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
+ else
+ flags |= 0x0078;
+ return flags;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/RDPFileParser.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/RDPFileParser.java
index c45d41d07..413050a83 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/RDPFileParser.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/RDPFileParser.java
@@ -3,8 +3,9 @@
Copyright 2013 Blaz Bacnik
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -15,77 +16,96 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
-public class RDPFileParser {
+public class RDPFileParser
+{
- private static final int MAX_ERRORS = 20;
- private static final int MAX_LINES = 500;
+ private static final int MAX_ERRORS = 20;
+ private static final int MAX_LINES = 500;
- private HashMap options;
+ private HashMap options;
- public RDPFileParser() {
- init();
- }
+ public RDPFileParser()
+ {
+ init();
+ }
- public RDPFileParser(String filename) throws IOException {
- init();
- parse(filename);
- }
+ public RDPFileParser(String filename) throws IOException
+ {
+ init();
+ parse(filename);
+ }
- private void init() {
- options = new HashMap();
- }
+ private void init()
+ {
+ options = new HashMap();
+ }
- public void parse(String filename) throws IOException {
- BufferedReader br = new BufferedReader(new FileReader(filename));
- String line = null;
+ public void parse(String filename) throws IOException
+ {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ String line = null;
- int errors = 0;
- int lines = 0;
- boolean ok;
+ int errors = 0;
+ int lines = 0;
+ boolean ok;
- while ((line = br.readLine()) != null) {
- lines++;
- ok = false;
+ while ((line = br.readLine()) != null)
+ {
+ lines++;
+ ok = false;
- if (errors > MAX_ERRORS || lines > MAX_LINES) {
- br.close();
- throw new IOException("Parsing limits exceeded");
- }
+ if (errors > MAX_ERRORS || lines > MAX_LINES)
+ {
+ br.close();
+ throw new IOException("Parsing limits exceeded");
+ }
- String[] fields = line.split(":", 3);
+ String[] fields = line.split(":", 3);
- if (fields.length == 3) {
- if (fields[1].equals("s")) {
- options.put(fields[0].toLowerCase(Locale.ENGLISH), fields[2]);
- ok = true;
- } else if (fields[1].equals("i")) {
- try {
- Integer i = Integer.parseInt(fields[2]);
- options.put(fields[0].toLowerCase(Locale.ENGLISH), i);
- ok = true;
- } catch (NumberFormatException e) {
- }
- } else if (fields[1].equals("b")) {
- ok = true;
- }
- }
+ if (fields.length == 3)
+ {
+ if (fields[1].equals("s"))
+ {
+ options.put(fields[0].toLowerCase(Locale.ENGLISH), fields[2]);
+ ok = true;
+ }
+ else if (fields[1].equals("i"))
+ {
+ try
+ {
+ Integer i = Integer.parseInt(fields[2]);
+ options.put(fields[0].toLowerCase(Locale.ENGLISH), i);
+ ok = true;
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+ else if (fields[1].equals("b"))
+ {
+ ok = true;
+ }
+ }
- if (!ok) errors++;
- }
- br.close();
- }
+ if (!ok)
+ errors++;
+ }
+ br.close();
+ }
- public String getString(String optionName) {
- if (options.get(optionName) instanceof String)
- return (String) options.get(optionName);
- else
- return null;
- }
+ public String getString(String optionName)
+ {
+ if (options.get(optionName) instanceof String)
+ return (String)options.get(optionName);
+ else
+ return null;
+ }
- public Integer getInteger(String optionName) {
- if (options.get(optionName) instanceof Integer)
- return (Integer) options.get(optionName);
- else
- return null;
- }
+ public Integer getInteger(String optionName)
+ {
+ if (options.get(optionName) instanceof Integer)
+ return (Integer)options.get(optionName);
+ else
+ return null;
+ }
}
diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/SeparatedListAdapter.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/SeparatedListAdapter.java
index 7f8d8d2ba..659732da5 100644
--- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/SeparatedListAdapter.java
+++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/utils/SeparatedListAdapter.java
@@ -4,8 +4,9 @@
Copyright Jeff Sharkey
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
package com.freerdp.freerdpcore.utils;
@@ -22,157 +23,186 @@ import com.freerdp.freerdpcore.R;
import java.util.LinkedHashMap;
import java.util.Map;
-public class SeparatedListAdapter extends BaseAdapter {
+public class SeparatedListAdapter extends BaseAdapter
+{
- public final static int TYPE_SECTION_HEADER = 0;
- public final Map sections = new LinkedHashMap();
- public final ArrayAdapter headers;
+ public final static int TYPE_SECTION_HEADER = 0;
+ public final Map sections = new LinkedHashMap();
+ public final ArrayAdapter headers;
- public SeparatedListAdapter(Context context) {
- headers = new ArrayAdapter(context, R.layout.list_header);
- }
+ public SeparatedListAdapter(Context context)
+ {
+ headers = new ArrayAdapter(context, R.layout.list_header);
+ }
- public void addSection(String section, Adapter adapter) {
- this.headers.add(section);
- this.sections.put(section, adapter);
- }
+ public void addSection(String section, Adapter adapter)
+ {
+ this.headers.add(section);
+ this.sections.put(section, adapter);
+ }
- public void setSectionTitle(int section, String title) {
- String oldTitle = this.headers.getItem(section);
+ public void setSectionTitle(int section, String title)
+ {
+ String oldTitle = this.headers.getItem(section);
- // remove/add to headers array
- this.headers.remove(oldTitle);
- this.headers.insert(title, section);
+ // remove/add to headers array
+ this.headers.remove(oldTitle);
+ this.headers.insert(title, section);
- // remove/add to section map
- Adapter adapter = this.sections.get(oldTitle);
- this.sections.remove(oldTitle);
- this.sections.put(title, adapter);
- }
+ // remove/add to section map
+ Adapter adapter = this.sections.get(oldTitle);
+ this.sections.remove(oldTitle);
+ this.sections.put(title, adapter);
+ }
- public Object getItem(int position) {
- for (int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
+ public Object getItem(int position)
+ {
+ for (int i = 0; i < headers.getCount(); i++)
+ {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
- // ignore empty sections
- if (adapter.getCount() > 0) {
- int size = adapter.getCount() + 1;
+ // ignore empty sections
+ if (adapter.getCount() > 0)
+ {
+ int size = adapter.getCount() + 1;
- // check if position inside this section
- if (position == 0) return section;
- if (position < size) return adapter.getItem(position - 1);
+ // check if position inside this section
+ if (position == 0)
+ return section;
+ if (position < size)
+ return adapter.getItem(position - 1);
- // otherwise jump into next section
- position -= size;
- }
- }
- return null;
- }
+ // otherwise jump into next section
+ position -= size;
+ }
+ }
+ return null;
+ }
- public int getCount() {
- // total together all sections, plus one for each section header (except if the section is empty)
- int total = 0;
- for (Adapter adapter : this.sections.values())
- total += ((adapter.getCount() > 0) ? adapter.getCount() + 1 : 0);
- return total;
- }
+ public int getCount()
+ {
+ // total together all sections, plus one for each section header (except if the section is
+ // empty)
+ int total = 0;
+ for (Adapter adapter : this.sections.values())
+ total += ((adapter.getCount() > 0) ? adapter.getCount() + 1 : 0);
+ return total;
+ }
- public int getViewTypeCount() {
- // assume that headers count as one, then total all sections
- int total = 1;
- for (Adapter adapter : this.sections.values())
- total += adapter.getViewTypeCount();
- return total;
- }
+ public int getViewTypeCount()
+ {
+ // assume that headers count as one, then total all sections
+ int total = 1;
+ for (Adapter adapter : this.sections.values())
+ total += adapter.getViewTypeCount();
+ return total;
+ }
- public int getItemViewType(int position) {
- int type = 1;
- for (int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
+ public int getItemViewType(int position)
+ {
+ int type = 1;
+ for (int i = 0; i < headers.getCount(); i++)
+ {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
- // skip empty sections
- if (adapter.getCount() > 0) {
- int size = adapter.getCount() + 1;
+ // skip empty sections
+ if (adapter.getCount() > 0)
+ {
+ int size = adapter.getCount() + 1;
- // check if position inside this section
- if (position == 0) return TYPE_SECTION_HEADER;
- if (position < size) return type + adapter.getItemViewType(position - 1);
+ // check if position inside this section
+ if (position == 0)
+ return TYPE_SECTION_HEADER;
+ if (position < size)
+ return type + adapter.getItemViewType(position - 1);
- // otherwise jump into next section
- position -= size;
- type += adapter.getViewTypeCount();
- }
- }
- return -1;
- }
+ // otherwise jump into next section
+ position -= size;
+ type += adapter.getViewTypeCount();
+ }
+ }
+ return -1;
+ }
- public boolean areAllItemsSelectable() {
- return false;
- }
+ public boolean areAllItemsSelectable()
+ {
+ return false;
+ }
- public boolean isEnabled(int position) {
- return (getItemViewType(position) != TYPE_SECTION_HEADER);
- }
+ public boolean isEnabled(int position)
+ {
+ return (getItemViewType(position) != TYPE_SECTION_HEADER);
+ }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- int sectionnum = 0;
- for (int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
+ @Override public View getView(int position, View convertView, ViewGroup parent)
+ {
+ int sectionnum = 0;
+ for (int i = 0; i < headers.getCount(); i++)
+ {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
- // skip empty sections
- if (adapter.getCount() > 0) {
- int size = adapter.getCount() + 1;
+ // skip empty sections
+ if (adapter.getCount() > 0)
+ {
+ int size = adapter.getCount() + 1;
- // check if position inside this section
- if (position == 0) return headers.getView(sectionnum, convertView, parent);
- if (position < size) return adapter.getView(position - 1, null, parent);
+ // check if position inside this section
+ if (position == 0)
+ return headers.getView(sectionnum, convertView, parent);
+ if (position < size)
+ return adapter.getView(position - 1, null, parent);
- // otherwise jump into next section
- position -= size;
- }
- sectionnum++;
- }
- return null;
- }
+ // otherwise jump into next section
+ position -= size;
+ }
+ sectionnum++;
+ }
+ return null;
+ }
- @Override
- public long getItemId(int position) {
- for (int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
- if (adapter.getCount() > 0) {
- int size = adapter.getCount() + 1;
+ @Override public long getItemId(int position)
+ {
+ for (int i = 0; i < headers.getCount(); i++)
+ {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
+ if (adapter.getCount() > 0)
+ {
+ int size = adapter.getCount() + 1;
- // check if position inside this section
- if (position < size) return adapter.getItemId(position - 1);
+ // check if position inside this section
+ if (position < size)
+ return adapter.getItemId(position - 1);
- // otherwise jump into next section
- position -= size;
- }
- }
- return -1;
- }
+ // otherwise jump into next section
+ position -= size;
+ }
+ }
+ return -1;
+ }
- public String getSectionForPosition(int position) {
- int curPos = 0;
- for (int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
- if (adapter.getCount() > 0) {
- int size = adapter.getCount() + 1;
+ public String getSectionForPosition(int position)
+ {
+ int curPos = 0;
+ for (int i = 0; i < headers.getCount(); i++)
+ {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
+ if (adapter.getCount() > 0)
+ {
+ int size = adapter.getCount() + 1;
- // check if position inside this section
- if (position >= curPos && position < (curPos + size)) return section.toString();
+ // check if position inside this section
+ if (position >= curPos && position < (curPos + size))
+ return section.toString();
- // otherwise jump into next section
- curPos += size;
- }
- }
- return null;
- }
-
-}
\ No newline at end of file
+ // otherwise jump into next section
+ curPos += size;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/client/Android/android_cliprdr.c b/client/Android/android_cliprdr.c
index 998266bc4..5e9f79182 100644
--- a/client/Android/android_cliprdr.c
+++ b/client/Android/android_cliprdr.c
@@ -49,7 +49,7 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
if (!cliprdr)
return ERROR_INVALID_PARAMETER;
- androidContext* afc = (androidContext*) cliprdr->custom;
+ androidContext* afc = (androidContext*)cliprdr->custom;
if (!afc || !afc->cliprdr)
return ERROR_INVALID_PARAMETER;
@@ -57,7 +57,7 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
ZeroMemory(&formatList, sizeof(CLIPRDR_FORMAT_LIST));
pFormatIds = NULL;
numFormats = ClipboardGetFormatIds(afc->clipboard, &pFormatIds);
- formats = (CLIPRDR_FORMAT*) calloc(numFormats, sizeof(CLIPRDR_FORMAT));
+ formats = (CLIPRDR_FORMAT*)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
if (!formats)
goto fail;
@@ -92,8 +92,8 @@ fail:
return rc;
}
-static UINT android_cliprdr_send_client_format_data_request(
- CliprdrClientContext* cliprdr, UINT32 formatId)
+static UINT android_cliprdr_send_client_format_data_request(CliprdrClientContext* cliprdr,
+ UINT32 formatId)
{
UINT rc = ERROR_INVALID_PARAMETER;
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
@@ -102,7 +102,7 @@ static UINT android_cliprdr_send_client_format_data_request(
if (!cliprdr)
goto fail;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc || !afc->clipboardRequestEvent || !cliprdr->ClientFormatDataRequest)
goto fail;
@@ -118,8 +118,7 @@ fail:
return rc;
}
-static UINT android_cliprdr_send_client_capabilities(CliprdrClientContext*
- cliprdr)
+static UINT android_cliprdr_send_client_capabilities(CliprdrClientContext* cliprdr)
{
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
@@ -128,8 +127,7 @@ static UINT android_cliprdr_send_client_capabilities(CliprdrClientContext*
return ERROR_INVALID_PARAMETER;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
- (generalCapabilitySet);
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = CB_CAPS_VERSION_2;
@@ -143,7 +141,7 @@ static UINT android_cliprdr_send_client_capabilities(CliprdrClientContext*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_monitor_ready(CliprdrClientContext* cliprdr,
- const CLIPRDR_MONITOR_READY* monitorReady)
+ const CLIPRDR_MONITOR_READY* monitorReady)
{
UINT rc;
androidContext* afc;
@@ -151,7 +149,7 @@ static UINT android_cliprdr_monitor_ready(CliprdrClientContext* cliprdr,
if (!cliprdr || !monitorReady)
return ERROR_INVALID_PARAMETER;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc)
return ERROR_INVALID_PARAMETER;
@@ -172,7 +170,7 @@ static UINT android_cliprdr_monitor_ready(CliprdrClientContext* cliprdr,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr,
- const CLIPRDR_CAPABILITIES* capabilities)
+ const CLIPRDR_CAPABILITIES* capabilities)
{
UINT32 index;
CLIPRDR_CAPABILITY_SET* capabilitySet;
@@ -181,7 +179,7 @@ static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr,
if (!cliprdr || !capabilities)
return ERROR_INVALID_PARAMETER;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc)
return ERROR_INVALID_PARAMETER;
@@ -193,8 +191,8 @@ static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr,
if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) &&
(capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN))
{
- CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet
- = (CLIPRDR_GENERAL_CAPABILITY_SET*) capabilitySet;
+ CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet =
+ (CLIPRDR_GENERAL_CAPABILITY_SET*)capabilitySet;
afc->clipboardCapabilities = generalCapabilitySet->generalFlags;
break;
}
@@ -209,7 +207,7 @@ static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
- const CLIPRDR_FORMAT_LIST* formatList)
+ const CLIPRDR_FORMAT_LIST* formatList)
{
UINT rc;
UINT32 index;
@@ -219,7 +217,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
if (!cliprdr || !formatList)
return ERROR_INVALID_PARAMETER;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc)
return ERROR_INVALID_PARAMETER;
@@ -238,8 +236,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
return CHANNEL_RC_OK;
afc->numServerFormats = formatList->numFormats;
- afc->serverFormats = (CLIPRDR_FORMAT*) calloc(afc->numServerFormats,
- sizeof(CLIPRDR_FORMAT));
+ afc->serverFormats = (CLIPRDR_FORMAT*)calloc(afc->numServerFormats, sizeof(CLIPRDR_FORMAT));
if (!afc->serverFormats)
return CHANNEL_RC_NO_MEMORY;
@@ -251,8 +248,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
if (formatList->formats[index].formatName)
{
- afc->serverFormats[index].formatName = _strdup(
- formatList->formats[index].formatName);
+ afc->serverFormats[index].formatName = _strdup(formatList->formats[index].formatName);
if (!afc->serverFormats[index].formatName)
return CHANNEL_RC_NO_MEMORY;
@@ -265,16 +261,16 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
if (format->formatId == CF_UNICODETEXT)
{
- if ((rc = android_cliprdr_send_client_format_data_request(cliprdr,
- CF_UNICODETEXT)) != CHANNEL_RC_OK)
+ if ((rc = android_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT)) !=
+ CHANNEL_RC_OK)
return rc;
break;
}
else if (format->formatId == CF_TEXT)
{
- if ((rc = android_cliprdr_send_client_format_data_request(cliprdr,
- CF_TEXT)) != CHANNEL_RC_OK)
+ if ((rc = android_cliprdr_send_client_format_data_request(cliprdr, CF_TEXT)) !=
+ CHANNEL_RC_OK)
return rc;
break;
@@ -289,9 +285,9 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT android_cliprdr_server_format_list_response(
- CliprdrClientContext* cliprdr,
- const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+android_cliprdr_server_format_list_response(CliprdrClientContext* cliprdr,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
if (!cliprdr || !formatListResponse)
return ERROR_INVALID_PARAMETER;
@@ -304,9 +300,9 @@ static UINT android_cliprdr_server_format_list_response(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT android_cliprdr_server_lock_clipboard_data(CliprdrClientContext*
- cliprdr,
- const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+static UINT
+android_cliprdr_server_lock_clipboard_data(CliprdrClientContext* cliprdr,
+ const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
{
if (!cliprdr || !lockClipboardData)
return ERROR_INVALID_PARAMETER;
@@ -320,8 +316,7 @@ static UINT android_cliprdr_server_lock_clipboard_data(CliprdrClientContext*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_server_unlock_clipboard_data(
- CliprdrClientContext* cliprdr,
- const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+ CliprdrClientContext* cliprdr, const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
if (!cliprdr || !unlockClipboardData)
return ERROR_INVALID_PARAMETER;
@@ -334,9 +329,9 @@ static UINT android_cliprdr_server_unlock_clipboard_data(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT android_cliprdr_server_format_data_request(CliprdrClientContext*
- cliprdr,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+static UINT
+android_cliprdr_server_format_data_request(CliprdrClientContext* cliprdr,
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
UINT rc;
BYTE* data;
@@ -348,14 +343,14 @@ static UINT android_cliprdr_server_format_data_request(CliprdrClientContext*
if (!cliprdr || !formatDataRequest || !cliprdr->ClientFormatDataResponse)
return ERROR_INVALID_PARAMETER;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc)
return ERROR_INVALID_PARAMETER;
ZeroMemory(&response, sizeof(CLIPRDR_FORMAT_DATA_RESPONSE));
formatId = formatDataRequest->requestedFormatId;
- data = (BYTE*) ClipboardGetData(afc->clipboard, formatId, &size);
+ data = (BYTE*)ClipboardGetData(afc->clipboard, formatId, &size);
response.msgFlags = CB_RESPONSE_OK;
response.dataLen = size;
response.requestedFormatData = data;
@@ -377,9 +372,9 @@ static UINT android_cliprdr_server_format_data_request(CliprdrClientContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT android_cliprdr_server_format_data_response(
- CliprdrClientContext* cliprdr,
- const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
BYTE* data;
UINT32 size;
@@ -392,12 +387,12 @@ static UINT android_cliprdr_server_format_data_response(
if (!cliprdr || !formatDataResponse)
return ERROR_INVALID_PARAMETER;
- afc = (androidContext*) cliprdr->custom;
+ afc = (androidContext*)cliprdr->custom;
if (!afc)
return ERROR_INVALID_PARAMETER;
- instance = ((rdpContext*) afc)->instance;
+ instance = ((rdpContext*)afc)->instance;
if (!instance)
return ERROR_INVALID_PARAMETER;
@@ -421,8 +416,7 @@ static UINT android_cliprdr_server_format_data_response(
size = formatDataResponse->dataLen;
- if (!ClipboardSetData(afc->clipboard, formatId,
- formatDataResponse->requestedFormatData, size))
+ if (!ClipboardSetData(afc->clipboard, formatId, formatDataResponse->requestedFormatData, size))
return ERROR_INTERNAL_ERROR;
SetEvent(afc->clipboardRequestEvent);
@@ -433,7 +427,7 @@ static UINT android_cliprdr_server_format_data_response(
jstring jdata;
jboolean attached;
formatId = ClipboardRegisterFormat(afc->clipboard, "UTF8_STRING");
- data = (void*) ClipboardGetData(afc->clipboard, formatId, &size);
+ data = (void*)ClipboardGetData(afc->clipboard, formatId, &size);
attached = jni_attach_thread(&env);
size = strnlen(data, size);
jdata = jniNewStringUTF(env, data, size);
@@ -454,8 +448,7 @@ static UINT android_cliprdr_server_format_data_response(
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_server_file_contents_request(
- CliprdrClientContext* cliprdr,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+ CliprdrClientContext* cliprdr, const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
if (!cliprdr || !fileContentsRequest)
return ERROR_INVALID_PARAMETER;
@@ -469,8 +462,7 @@ static UINT android_cliprdr_server_file_contents_request(
* @return 0 on success, otherwise a Win32 error code
*/
static UINT android_cliprdr_server_file_contents_response(
- CliprdrClientContext* cliprdr,
- const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
+ CliprdrClientContext* cliprdr, const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
{
if (!cliprdr || !fileContentsResponse)
return ERROR_INVALID_PARAMETER;
@@ -498,20 +490,17 @@ BOOL android_cliprdr_init(androidContext* afc, CliprdrClientContext* cliprdr)
afc->cliprdr = cliprdr;
afc->clipboard = clipboard;
afc->clipboardRequestEvent = hevent;
- cliprdr->custom = (void*) afc;
+ cliprdr->custom = (void*)afc;
cliprdr->MonitorReady = android_cliprdr_monitor_ready;
cliprdr->ServerCapabilities = android_cliprdr_server_capabilities;
cliprdr->ServerFormatList = android_cliprdr_server_format_list;
cliprdr->ServerFormatListResponse = android_cliprdr_server_format_list_response;
cliprdr->ServerLockClipboardData = android_cliprdr_server_lock_clipboard_data;
- cliprdr->ServerUnlockClipboardData =
- android_cliprdr_server_unlock_clipboard_data;
+ cliprdr->ServerUnlockClipboardData = android_cliprdr_server_unlock_clipboard_data;
cliprdr->ServerFormatDataRequest = android_cliprdr_server_format_data_request;
cliprdr->ServerFormatDataResponse = android_cliprdr_server_format_data_response;
- cliprdr->ServerFileContentsRequest =
- android_cliprdr_server_file_contents_request;
- cliprdr->ServerFileContentsResponse =
- android_cliprdr_server_file_contents_response;
+ cliprdr->ServerFileContentsRequest = android_cliprdr_server_file_contents_request;
+ cliprdr->ServerFileContentsResponse = android_cliprdr_server_file_contents_response;
return TRUE;
}
diff --git a/client/Android/android_cliprdr.h b/client/Android/android_cliprdr.h
index af142c20b..8404d9a74 100644
--- a/client/Android/android_cliprdr.h
+++ b/client/Android/android_cliprdr.h
@@ -25,12 +25,9 @@
#include "android_freerdp.h"
-FREERDP_LOCAL UINT android_cliprdr_send_client_format_list(
- CliprdrClientContext* cliprdr);
+FREERDP_LOCAL UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr);
-FREERDP_LOCAL BOOL android_cliprdr_init(androidContext* afc,
- CliprdrClientContext* cliprdr);
-FREERDP_LOCAL BOOL android_cliprdr_uninit(androidContext* afc,
- CliprdrClientContext* cliprdr);
+FREERDP_LOCAL BOOL android_cliprdr_init(androidContext* afc, CliprdrClientContext* cliprdr);
+FREERDP_LOCAL BOOL android_cliprdr_uninit(androidContext* afc, CliprdrClientContext* cliprdr);
#endif /* FREERDP_CLIENT_ANDROID_CLIPRDR_H */
diff --git a/client/Android/android_event.c b/client/Android/android_event.c
index 7b764aca1..aa6c647a6 100644
--- a/client/Android/android_event.c
+++ b/client/Android/android_event.c
@@ -37,8 +37,7 @@ BOOL android_push_event(freerdp* inst, ANDROID_EVENT* event)
int new_size;
void* new_events;
new_size = aCtx->event_queue->size * 2;
- new_events = realloc((void*) aCtx->event_queue->events,
- sizeof(ANDROID_EVENT*) * new_size);
+ new_events = realloc((void*)aCtx->event_queue->events, sizeof(ANDROID_EVENT*) * new_size);
if (!new_events)
return FALSE;
@@ -85,7 +84,7 @@ static BOOL android_process_event(ANDROID_EVENT_QUEUE* queue, freerdp* inst)
{
ANDROID_EVENT* event;
rdpContext* context = inst->context;
- androidContext* afc = (androidContext*) context;
+ androidContext* afc = (androidContext*)context;
while (android_peek_event(queue))
{
@@ -93,20 +92,19 @@ static BOOL android_process_event(ANDROID_EVENT_QUEUE* queue, freerdp* inst)
if (event->type == EVENT_TYPE_KEY)
{
- ANDROID_EVENT_KEY* key_event = (ANDROID_EVENT_KEY*) event;
+ ANDROID_EVENT_KEY* key_event = (ANDROID_EVENT_KEY*)event;
inst->input->KeyboardEvent(inst->input, key_event->flags, key_event->scancode);
android_event_free((ANDROID_EVENT*)key_event);
}
else if (event->type == EVENT_TYPE_KEY_UNICODE)
{
- ANDROID_EVENT_KEY* key_event = (ANDROID_EVENT_KEY*) event;
- inst->input->UnicodeKeyboardEvent(inst->input, key_event->flags,
- key_event->scancode);
+ ANDROID_EVENT_KEY* key_event = (ANDROID_EVENT_KEY*)event;
+ inst->input->UnicodeKeyboardEvent(inst->input, key_event->flags, key_event->scancode);
android_event_free((ANDROID_EVENT*)key_event);
}
else if (event->type == EVENT_TYPE_CURSOR)
{
- ANDROID_EVENT_CURSOR* cursor_event = (ANDROID_EVENT_CURSOR*) event;
+ ANDROID_EVENT_CURSOR* cursor_event = (ANDROID_EVENT_CURSOR*)event;
inst->input->MouseEvent(inst->input, cursor_event->flags, cursor_event->x,
cursor_event->y);
android_event_free((ANDROID_EVENT*)cursor_event);
@@ -115,7 +113,7 @@ static BOOL android_process_event(ANDROID_EVENT_QUEUE* queue, freerdp* inst)
{
UINT32 size;
UINT32 formatId;
- ANDROID_EVENT_CLIPBOARD* clipboard_event = (ANDROID_EVENT_CLIPBOARD*) event;
+ ANDROID_EVENT_CLIPBOARD* clipboard_event = (ANDROID_EVENT_CLIPBOARD*)event;
formatId = ClipboardRegisterFormat(afc->clipboard, "UTF8_STRING");
size = clipboard_event->data_length;
@@ -179,7 +177,7 @@ BOOL android_check_handle(freerdp* inst)
ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode)
{
ANDROID_EVENT_KEY* event;
- event = (ANDROID_EVENT_KEY*) calloc(1, sizeof(ANDROID_EVENT_KEY));
+ event = (ANDROID_EVENT_KEY*)calloc(1, sizeof(ANDROID_EVENT_KEY));
if (!event)
return NULL;
@@ -198,7 +196,7 @@ static void android_event_key_free(ANDROID_EVENT_KEY* event)
ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 flags, UINT16 key)
{
ANDROID_EVENT_KEY* event;
- event = (ANDROID_EVENT_KEY*) calloc(1, sizeof(ANDROID_EVENT_KEY));
+ event = (ANDROID_EVENT_KEY*)calloc(1, sizeof(ANDROID_EVENT_KEY));
if (!event)
return NULL;
@@ -217,7 +215,7 @@ static void android_event_unicodekey_free(ANDROID_EVENT_KEY* event)
ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y)
{
ANDROID_EVENT_CURSOR* event;
- event = (ANDROID_EVENT_CURSOR*) calloc(1, sizeof(ANDROID_EVENT_CURSOR));
+ event = (ANDROID_EVENT_CURSOR*)calloc(1, sizeof(ANDROID_EVENT_CURSOR));
if (!event)
return NULL;
@@ -237,7 +235,7 @@ static void android_event_cursor_free(ANDROID_EVENT_CURSOR* event)
ANDROID_EVENT* android_event_disconnect_new(void)
{
ANDROID_EVENT* event;
- event = (ANDROID_EVENT*) calloc(1, sizeof(ANDROID_EVENT));
+ event = (ANDROID_EVENT*)calloc(1, sizeof(ANDROID_EVENT));
if (!event)
return NULL;
@@ -251,11 +249,10 @@ static void android_event_disconnect_free(ANDROID_EVENT* event)
free(event);
}
-ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data,
- int data_length)
+ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length)
{
ANDROID_EVENT_CLIPBOARD* event;
- event = (ANDROID_EVENT_CLIPBOARD*) calloc(1, sizeof(ANDROID_EVENT_CLIPBOARD));
+ event = (ANDROID_EVENT_CLIPBOARD*)calloc(1, sizeof(ANDROID_EVENT_CLIPBOARD));
if (!event)
return NULL;
@@ -292,7 +289,7 @@ BOOL android_event_queue_init(freerdp* inst)
{
androidContext* aCtx = (androidContext*)inst->context;
ANDROID_EVENT_QUEUE* queue;
- queue = (ANDROID_EVENT_QUEUE*) calloc(1, sizeof(ANDROID_EVENT_QUEUE));
+ queue = (ANDROID_EVENT_QUEUE*)calloc(1, sizeof(ANDROID_EVENT_QUEUE));
if (!queue)
{
@@ -310,7 +307,7 @@ BOOL android_event_queue_init(freerdp* inst)
return FALSE;
}
- queue->events = (ANDROID_EVENT**) calloc(queue->size, sizeof(ANDROID_EVENT*));
+ queue->events = (ANDROID_EVENT**)calloc(queue->size, sizeof(ANDROID_EVENT*));
if (!queue->events)
{
diff --git a/client/Android/android_event.h b/client/Android/android_event.h
index 1110a8704..b2d7bf2e6 100644
--- a/client/Android/android_event.h
+++ b/client/Android/android_event.h
@@ -14,11 +14,11 @@
#include
#include
-#define EVENT_TYPE_KEY 1
-#define EVENT_TYPE_CURSOR 2
-#define EVENT_TYPE_DISCONNECT 3
-#define EVENT_TYPE_KEY_UNICODE 4
-#define EVENT_TYPE_CLIPBOARD 5
+#define EVENT_TYPE_KEY 1
+#define EVENT_TYPE_CURSOR 2
+#define EVENT_TYPE_DISCONNECT 3
+#define EVENT_TYPE_KEY_UNICODE 4
+#define EVENT_TYPE_CLIPBOARD 5
struct _ANDROID_EVENT
{
@@ -65,14 +65,11 @@ FREERDP_LOCAL BOOL android_push_event(freerdp* inst, ANDROID_EVENT* event);
FREERDP_LOCAL HANDLE android_get_handle(freerdp* inst);
FREERDP_LOCAL BOOL android_check_handle(freerdp* inst);
-FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_key_new(int flags,
- UINT16 scancode);
+FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode);
FREERDP_LOCAL ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 flags, UINT16 key);
-FREERDP_LOCAL ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags,
- UINT16 x, UINT16 y);
+FREERDP_LOCAL ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y);
FREERDP_LOCAL ANDROID_EVENT* android_event_disconnect_new(void);
-FREERDP_LOCAL ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data,
- int data_length);
+FREERDP_LOCAL ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length);
FREERDP_LOCAL void android_event_free(ANDROID_EVENT* event);
diff --git a/client/Android/android_freerdp.c b/client/Android/android_freerdp.c
index fbb966a37..693ddfc6b 100644
--- a/client/Android/android_freerdp.c
+++ b/client/Android/android_freerdp.c
@@ -9,7 +9,8 @@
Copyright 2016 Armin Novak
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#ifdef HAVE_CONFIG_H
@@ -57,74 +58,68 @@
/* Defines the JNI version supported by this library. */
#define FREERDP_JNI_VERSION "2.0.0"
-static void android_OnChannelConnectedEventHandler(
- void* context,
- ChannelConnectedEventArgs* e)
+static void android_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
{
rdpSettings* settings;
androidContext* afc;
if (!context || !e)
{
- WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p",
- __FUNCTION__, context, (void*) e);
+ WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p", __FUNCTION__, context, (void*)e);
return;
}
- afc = (androidContext*) context;
+ afc = (androidContext*)context;
settings = afc->rdpCtx.settings;
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
{
- gdi_graphics_pipeline_init(afc->rdpCtx.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(afc->rdpCtx.gdi, (RdpgfxClientContext*)e->pInterface);
}
else
{
WLog_WARN(TAG, "GFX without software GDI requested. "
- " This is not supported, add /gdi:sw");
+ " This is not supported, add /gdi:sw");
}
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- android_cliprdr_init(afc, (CliprdrClientContext*) e->pInterface);
+ android_cliprdr_init(afc, (CliprdrClientContext*)e->pInterface);
}
}
-static void android_OnChannelDisconnectedEventHandler(
- void* context, ChannelDisconnectedEventArgs* e)
+static void android_OnChannelDisconnectedEventHandler(void* context,
+ ChannelDisconnectedEventArgs* e)
{
rdpSettings* settings;
androidContext* afc;
if (!context || !e)
{
- WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p",
- __FUNCTION__, context, (void*) e);
+ WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p", __FUNCTION__, context, (void*)e);
return;
}
- afc = (androidContext*) context;
+ afc = (androidContext*)context;
settings = afc->rdpCtx.settings;
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
{
- gdi_graphics_pipeline_uninit(afc->rdpCtx.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(afc->rdpCtx.gdi, (RdpgfxClientContext*)e->pInterface);
}
else
{
WLog_WARN(TAG, "GFX without software GDI requested. "
- " This is not supported, add /gdi:sw");
+ " This is not supported, add /gdi:sw");
}
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- android_cliprdr_uninit(afc, (CliprdrClientContext*) e->pInterface);
+ android_cliprdr_uninit(afc, (CliprdrClientContext*)e->pInterface);
}
}
@@ -166,7 +161,7 @@ static BOOL android_end_paint(rdpContext* context)
if (ninvalid < 1)
return TRUE;
-
+
cinvalid = hwnd->cinvalid;
if (!cinvalid)
@@ -185,8 +180,8 @@ static BOOL android_end_paint(rdpContext* context)
y2 = MAX(y2, cinvalid[i].y + cinvalid[i].h);
}
- freerdp_callback("OnGraphicsUpdate", "(JIIII)V", (jlong)context->instance,
- x1, y1, x2 - x1, y2 - y1);
+ freerdp_callback("OnGraphicsUpdate", "(JIIII)V", (jlong)context->instance, x1, y1, x2 - x1,
+ y2 - y1);
hwnd->invalid->null = TRUE;
hwnd->ninvalid = 0;
@@ -198,9 +193,9 @@ static BOOL android_desktop_resize(rdpContext* context)
if (!context || !context->instance || !context->settings)
return FALSE;
- freerdp_callback("OnGraphicsResize", "(JIII)V",
- (jlong)context->instance, context->settings->DesktopWidth,
- context->settings->DesktopHeight, context->settings->ColorDepth);
+ freerdp_callback("OnGraphicsResize", "(JIII)V", (jlong)context->instance,
+ context->settings->DesktopWidth, context->settings->DesktopHeight,
+ context->settings->ColorDepth);
return TRUE;
}
@@ -217,9 +212,8 @@ static BOOL android_pre_connect(freerdp* instance)
if (!settings)
return FALSE;
- rc = PubSub_SubscribeChannelConnected(
- instance->context->pubSub,
- android_OnChannelConnectedEventHandler);
+ rc = PubSub_SubscribeChannelConnected(instance->context->pubSub,
+ android_OnChannelConnectedEventHandler);
if (rc != CHANNEL_RC_OK)
{
@@ -227,9 +221,8 @@ static BOOL android_pre_connect(freerdp* instance)
return FALSE;
}
- rc = PubSub_SubscribeChannelDisconnected(
- instance->context->pubSub,
- android_OnChannelDisconnectedEventHandler);
+ rc = PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
+ android_OnChannelDisconnectedEventHandler);
if (rc != CHANNEL_RC_OK)
{
@@ -237,8 +230,7 @@ static BOOL android_pre_connect(freerdp* instance)
return FALSE;
}
- if (!freerdp_client_load_addins(instance->context->channels,
- instance->settings))
+ if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
{
WLog_ERR(TAG, "Failed to load addins [%l08X]", GetLastError());
return FALSE;
@@ -262,8 +254,7 @@ static void android_Pointer_Free(rdpContext* context, rdpPointer* pointer)
return;
}
-static BOOL android_Pointer_Set(rdpContext* context,
- const rdpPointer* pointer)
+static BOOL android_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
if (!context)
return FALSE;
@@ -271,8 +262,7 @@ static BOOL android_Pointer_Set(rdpContext* context,
return TRUE;
}
-static BOOL android_Pointer_SetPosition(rdpContext* context,
- UINT32 x, UINT32 y)
+static BOOL android_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
{
if (!context)
return FALSE;
@@ -334,9 +324,8 @@ static BOOL android_post_connect(freerdp* instance)
instance->update->BeginPaint = android_begin_paint;
instance->update->EndPaint = android_end_paint;
instance->update->DesktopResize = android_desktop_resize;
- freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance,
- settings->DesktopWidth, settings->DesktopHeight,
- settings->ColorDepth);
+ freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance, settings->DesktopWidth,
+ settings->DesktopHeight, settings->ColorDepth);
freerdp_callback("OnConnectionSuccess", "(J)V", (jlong)instance);
return TRUE;
}
@@ -347,8 +336,8 @@ static void android_post_disconnect(freerdp* instance)
gdi_free(instance);
}
-static BOOL android_authenticate_int(freerdp* instance, char** username,
- char** password, char** domain, const char* cb_name)
+static BOOL android_authenticate_int(freerdp* instance, char** username, char** password,
+ char** domain, const char* cb_name)
{
JNIEnv* env;
jboolean attached = jni_attach_thread(&env);
@@ -356,12 +345,11 @@ static BOOL android_authenticate_int(freerdp* instance, char** username,
jobject jstr2 = create_string_builder(env, *domain);
jobject jstr3 = create_string_builder(env, *password);
jboolean res;
- res = freerdp_callback_bool_result(
- cb_name,
- "(JLjava/lang/StringBuilder;"
- "Ljava/lang/StringBuilder;"
- "Ljava/lang/StringBuilder;)Z",
- (jlong)instance, jstr1, jstr2, jstr3);
+ res = freerdp_callback_bool_result(cb_name,
+ "(JLjava/lang/StringBuilder;"
+ "Ljava/lang/StringBuilder;"
+ "Ljava/lang/StringBuilder;)Z",
+ (jlong)instance, jstr1, jstr2, jstr3);
if (res == JNI_TRUE)
{
@@ -380,24 +368,20 @@ static BOOL android_authenticate_int(freerdp* instance, char** username,
return ((res == JNI_TRUE) ? TRUE : FALSE);
}
-static BOOL android_authenticate(freerdp* instance, char** username,
- char** password, char** domain)
+static BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
- return android_authenticate_int(instance, username, password, domain,
- "OnAuthenticate");
+ return android_authenticate_int(instance, username, password, domain, "OnAuthenticate");
}
-static BOOL android_gw_authenticate(freerdp* instance, char** username,
- char** password, char** domain)
+static BOOL android_gw_authenticate(freerdp* instance, char** username, char** password,
+ char** domain)
{
- return android_authenticate_int(instance, username, password, domain,
- "OnGatewayAuthenticate");
+ return android_authenticate_int(instance, username, password, domain, "OnGatewayAuthenticate");
}
-static DWORD android_verify_certificate(
- freerdp* instance, const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint, BOOL host_mismatch)
+static DWORD android_verify_certificate(freerdp* instance, const char* common_name,
+ const char* subject, const char* issuer,
+ const char* fingerprint, BOOL host_mismatch)
{
WLog_DBG(TAG, "Certificate details:");
WLog_DBG(TAG, "\tSubject: %s", subject);
@@ -413,9 +397,10 @@ static DWORD android_verify_certificate(
jstring jstr1 = (*env)->NewStringUTF(env, subject);
jstring jstr2 = (*env)->NewStringUTF(env, issuer);
jstring jstr3 = (*env)->NewStringUTF(env, fingerprint);
- jint res = freerdp_callback_int_result("OnVerifyCertificate",
- "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I",
- (jlong)instance, jstr0, jstr1, jstr2, jstr3, host_mismatch);
+ jint res = freerdp_callback_int_result(
+ "OnVerifyCertificate",
+ "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I",
+ (jlong)instance, jstr0, jstr1, jstr2, jstr3, host_mismatch);
if (attached == JNI_TRUE)
jni_detach_thread();
@@ -423,14 +408,11 @@ static DWORD android_verify_certificate(
return res;
}
-static DWORD android_verify_changed_certificate(freerdp* instance,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* new_fingerprint,
- const char* old_subject,
- const char* old_issuer,
- const char* old_fingerprint)
+static DWORD android_verify_changed_certificate(freerdp* instance, const char* common_name,
+ const char* subject, const char* issuer,
+ const char* new_fingerprint,
+ const char* old_subject, const char* old_issuer,
+ const char* old_fingerprint)
{
JNIEnv* env;
jboolean attached = jni_attach_thread(&env);
@@ -441,10 +423,11 @@ static DWORD android_verify_changed_certificate(freerdp* instance,
jstring jstr4 = (*env)->NewStringUTF(env, old_subject);
jstring jstr5 = (*env)->NewStringUTF(env, old_issuer);
jstring jstr6 = (*env)->NewStringUTF(env, old_fingerprint);
- jint res = freerdp_callback_int_result("OnVerifyChangedCertificate",
- "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"
- "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
- (jlong)instance, jstr0, jstr1, jstr2, jstr3, jstr4, jstr5, jstr6);
+ jint res = freerdp_callback_int_result(
+ "OnVerifyChangedCertificate",
+ "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"
+ "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
+ (jlong)instance, jstr0, jstr1, jstr2, jstr3, jstr4, jstr5, jstr6);
if (attached == JNI_TRUE)
jni_detach_thread();
@@ -456,7 +439,7 @@ static DWORD WINAPI jni_input_thread(LPVOID arg)
{
HANDLE event[2];
wMessageQueue* queue;
- freerdp* instance = (freerdp*) arg;
+ freerdp* instance = (freerdp*)arg;
WLog_DBG(TAG, "input_thread Start.");
if (!(queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE)))
@@ -465,8 +448,7 @@ static DWORD WINAPI jni_input_thread(LPVOID arg)
if (!(event[0] = android_get_handle(instance)))
goto disconnect;
- if (!(event[1] = freerdp_get_message_queue_event_handle(instance,
- FREERDP_INPUT_MESSAGE_QUEUE)))
+ if (!(event[1] = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE)))
goto disconnect;
do
@@ -487,8 +469,7 @@ static DWORD WINAPI jni_input_thread(LPVOID arg)
if (android_check_handle(instance) != TRUE)
break;
- }
- while (1);
+ } while (1);
WLog_DBG(TAG, "input_thread Quit.");
disconnect:
@@ -507,7 +488,7 @@ static int android_freerdp_run(freerdp* instance)
const rdpSettings* settings = instance->context->settings;
rdpContext* context = instance->context;
BOOL async_input = settings->AsyncInput;
- WLog_DBG(TAG, "AsyncInput=%"PRIu8"", settings->AsyncInput);
+ WLog_DBG(TAG, "AsyncInput=%" PRIu8 "", settings->AsyncInput);
if (async_input)
{
@@ -543,7 +524,8 @@ static int android_freerdp_run(freerdp* instance)
if ((status == WAIT_FAILED))
{
- WLog_ERR(TAG, "WaitForMultipleObjects failed with %"PRIu32" [%08lX]", status, GetLastError());
+ WLog_ERR(TAG, "WaitForMultipleObjects failed with %" PRIu32 " [%08lX]", status,
+ GetLastError());
break;
}
@@ -551,8 +533,8 @@ static int android_freerdp_run(freerdp* instance)
{
/* TODO: Auto reconnect
if (xf_auto_reconnect(instance))
- continue;
- */
+ continue;
+ */
WLog_ERR(TAG, "Failed to check FreeRDP file descriptor");
status = GetLastError();
break;
@@ -577,7 +559,8 @@ disconnect:
if (async_input && inputThread)
{
- wMessageQueue* input_queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
+ wMessageQueue* input_queue =
+ freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
MessageQueue_PostQuit(input_queue, 0);
WaitForSingleObject(inputThread, INFINITE);
CloseHandle(inputThread);
@@ -617,7 +600,7 @@ static DWORD WINAPI android_thread_func(LPVOID param)
goto fail;
fail:
- WLog_DBG(TAG, "Session ended with %08"PRIX32"", status);
+ WLog_DBG(TAG, "Session ended with %08" PRIX32 "", status);
if (status == CHANNEL_RC_OK)
freerdp_callback("OnDisconnected", "(J)V", (jlong)instance);
@@ -648,7 +631,6 @@ static BOOL android_client_new(freerdp* instance, rdpContext* context)
return TRUE;
}
-
static void android_client_free(freerdp* instance, rdpContext* context)
{
if (!context)
@@ -693,27 +675,26 @@ static jlong JNICALL jni_freerdp_new(JNIEnv* env, jclass cls, jobject context)
if (!contextClass || !fileClass)
{
- WLog_FATAL(TAG, "Failed to load class references %s=%p, %s=%p",
- JAVA_CONTEXT_CLASS, (void*) contextClass, JAVA_FILE_CLASS, (void*) fileClass);
+ WLog_FATAL(TAG, "Failed to load class references %s=%p, %s=%p", JAVA_CONTEXT_CLASS,
+ (void*)contextClass, JAVA_FILE_CLASS, (void*)fileClass);
return (jlong)NULL;
}
- getFilesDirID = (*env)->GetMethodID(env, contextClass, "getFilesDir",
- "()L"JAVA_FILE_CLASS";");
+ getFilesDirID =
+ (*env)->GetMethodID(env, contextClass, "getFilesDir", "()L" JAVA_FILE_CLASS ";");
if (!getFilesDirID)
{
- WLog_FATAL(TAG, "Failed to find method ID getFilesDir ()L"JAVA_FILE_CLASS";");
+ WLog_FATAL(TAG, "Failed to find method ID getFilesDir ()L" JAVA_FILE_CLASS ";");
return (jlong)NULL;
}
- getAbsolutePathID = (*env)->GetMethodID(env, fileClass, "getAbsolutePath",
- "()Ljava/lang/String;");
+ getAbsolutePathID =
+ (*env)->GetMethodID(env, fileClass, "getAbsolutePath", "()Ljava/lang/String;");
if (!getAbsolutePathID)
{
- WLog_FATAL(TAG,
- "Failed to find method ID getAbsolutePath ()Ljava/lang/String;");
+ WLog_FATAL(TAG, "Failed to find method ID getAbsolutePath ()Ljava/lang/String;");
return (jlong)NULL;
}
@@ -752,8 +733,7 @@ static jlong JNICALL jni_freerdp_new(JNIEnv* env, jclass cls, jobject context)
if (setenv("HOME", _strdup(envStr), 1) != 0)
{
- WLog_FATAL(TAG, "Failed to set environemnt HOME=%s %s [%d]",
- env, strerror(errno), errno);
+ WLog_FATAL(TAG, "Failed to set environemnt HOME=%s %s [%d]", env, strerror(errno), errno);
return (jlong)NULL;
}
@@ -763,7 +743,7 @@ static jlong JNICALL jni_freerdp_new(JNIEnv* env, jclass cls, jobject context)
if (!ctx)
return (jlong)NULL;
- return (jlong) ctx->instance;
+ return (jlong)ctx->instance;
}
static void JNICALL jni_freerdp_free(JNIEnv* env, jclass cls, jlong instance)
@@ -785,12 +765,12 @@ static jstring JNICALL jni_freerdp_get_last_error_string(JNIEnv* env, jclass cls
if (!inst || !inst->context)
return (*env)->NewStringUTF(env, "");
- return (*env)->NewStringUTF(env,
- freerdp_get_last_error_string(freerdp_get_last_error(inst->context)));
+ return (*env)->NewStringUTF(
+ env, freerdp_get_last_error_string(freerdp_get_last_error(inst->context)));
}
-static jboolean JNICALL jni_freerdp_parse_arguments(
- JNIEnv* env, jclass cls, jlong instance, jobjectArray arguments)
+static jboolean JNICALL jni_freerdp_parse_arguments(JNIEnv* env, jclass cls, jlong instance,
+ jobjectArray arguments)
{
freerdp* inst = (freerdp*)instance;
int i, count;
@@ -814,8 +794,7 @@ static jboolean JNICALL jni_freerdp_parse_arguments(
(*env)->ReleaseStringUTFChars(env, str, raw);
}
- status = freerdp_client_settings_parse_command_line(inst->settings, count, argv,
- FALSE);
+ status = freerdp_client_settings_parse_command_line(inst->settings, count, argv, FALSE);
for (i = 0; i < count; i++)
free(argv[i]);
@@ -824,23 +803,21 @@ static jboolean JNICALL jni_freerdp_parse_arguments(
return (status == 0) ? JNI_TRUE : JNI_FALSE;
}
-static jboolean JNICALL jni_freerdp_connect(JNIEnv* env, jclass cls,
- jlong instance)
+static jboolean JNICALL jni_freerdp_connect(JNIEnv* env, jclass cls, jlong instance)
{
freerdp* inst = (freerdp*)instance;
androidContext* ctx;
if (!inst || !inst->context)
{
- WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__,
- (void*) env, (void*) cls, instance);
+ WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__, (void*)env, (void*)cls,
+ instance);
return JNI_FALSE;
}
ctx = (androidContext*)inst->context;
- if (!(ctx->thread = CreateThread(NULL, 0, android_thread_func,
- inst, 0, NULL)))
+ if (!(ctx->thread = CreateThread(NULL, 0, android_thread_func, inst, 0, NULL)))
{
return JNI_FALSE;
}
@@ -848,8 +825,7 @@ static jboolean JNICALL jni_freerdp_connect(JNIEnv* env, jclass cls,
return JNI_TRUE;
}
-static jboolean JNICALL jni_freerdp_disconnect(JNIEnv* env, jclass cls,
- jlong instance)
+static jboolean JNICALL jni_freerdp_disconnect(JNIEnv* env, jclass cls, jlong instance)
{
freerdp* inst = (freerdp*)instance;
androidContext* ctx;
@@ -857,8 +833,8 @@ static jboolean JNICALL jni_freerdp_disconnect(JNIEnv* env, jclass cls,
if (!inst || !inst->context || !cls || !env)
{
- WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__,
- (void*) env, (void*) cls, instance);
+ WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__, (void*)env, (void*)cls,
+ instance);
return JNI_FALSE;
}
@@ -880,9 +856,9 @@ static jboolean JNICALL jni_freerdp_disconnect(JNIEnv* env, jclass cls,
return JNI_TRUE;
}
-static jboolean JNICALL jni_freerdp_update_graphics(
- JNIEnv* env, jclass cls, jlong instance, jobject bitmap,
- jint x, jint y, jint width, jint height)
+static jboolean JNICALL jni_freerdp_update_graphics(JNIEnv* env, jclass cls, jlong instance,
+ jobject bitmap, jint x, jint y, jint width,
+ jint height)
{
UINT32 DstFormat;
jboolean rc;
@@ -894,8 +870,8 @@ static jboolean JNICALL jni_freerdp_update_graphics(
if (!env || !cls || !inst)
{
- WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__,
- (void*) env, (void*) cls, instance);
+ WLog_FATAL(TAG, "%s(env=%p, cls=%p, instance=%d", __FUNCTION__, (void*)env, (void*)cls,
+ instance);
return JNI_FALSE;
}
@@ -949,9 +925,8 @@ static jboolean JNICALL jni_freerdp_update_graphics(
return rc;
}
-static jboolean JNICALL jni_freerdp_send_key_event(
- JNIEnv* env, jclass cls, jlong instance,
- jint keycode, jboolean down)
+static jboolean JNICALL jni_freerdp_send_key_event(JNIEnv* env, jclass cls, jlong instance,
+ jint keycode, jboolean down)
{
DWORD scancode;
ANDROID_EVENT* event;
@@ -959,7 +934,7 @@ static jboolean JNICALL jni_freerdp_send_key_event(
scancode = GetVirtualScanCodeFromVirtualKeyCode(keycode, 4);
int flags = (down == JNI_TRUE) ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE;
flags |= (scancode & KBDEXT) ? KBD_FLAGS_EXTENDED : 0;
- event = (ANDROID_EVENT*) android_event_key_new(flags, scancode & 0xFF);
+ event = (ANDROID_EVENT*)android_event_key_new(flags, scancode & 0xFF);
if (!event)
return JNI_FALSE;
@@ -970,17 +945,17 @@ static jboolean JNICALL jni_freerdp_send_key_event(
return JNI_FALSE;
}
- WLog_DBG(TAG, "send_key_event: %"PRIu32", %d", scancode, flags);
+ WLog_DBG(TAG, "send_key_event: %" PRIu32 ", %d", scancode, flags);
return JNI_TRUE;
}
-static jboolean JNICALL jni_freerdp_send_unicodekey_event(
- JNIEnv* env, jclass cls, jlong instance, jint keycode, jboolean down)
+static jboolean JNICALL jni_freerdp_send_unicodekey_event(JNIEnv* env, jclass cls, jlong instance,
+ jint keycode, jboolean down)
{
ANDROID_EVENT* event;
freerdp* inst = (freerdp*)instance;
UINT16 flags = (down == JNI_TRUE) ? 0 : KBD_FLAGS_RELEASE;
- event = (ANDROID_EVENT*) android_event_unicodekey_new(flags, keycode);
+ event = (ANDROID_EVENT*)android_event_unicodekey_new(flags, keycode);
if (!event)
return JNI_FALSE;
@@ -995,12 +970,12 @@ static jboolean JNICALL jni_freerdp_send_unicodekey_event(
return JNI_TRUE;
}
-static jboolean JNICALL jni_freerdp_send_cursor_event(
- JNIEnv* env, jclass cls, jlong instance, jint x, jint y, jint flags)
+static jboolean JNICALL jni_freerdp_send_cursor_event(JNIEnv* env, jclass cls, jlong instance,
+ jint x, jint y, jint flags)
{
ANDROID_EVENT* event;
freerdp* inst = (freerdp*)instance;
- event = (ANDROID_EVENT*) android_event_cursor_new(flags, x, y);
+ event = (ANDROID_EVENT*)android_event_cursor_new(flags, x, y);
if (!event)
return JNI_FALSE;
@@ -1015,17 +990,15 @@ static jboolean JNICALL jni_freerdp_send_cursor_event(
return JNI_TRUE;
}
-static jboolean JNICALL jni_freerdp_send_clipboard_data(
- JNIEnv* env, jclass cls,
- jlong instance, jstring jdata)
+static jboolean JNICALL jni_freerdp_send_clipboard_data(JNIEnv* env, jclass cls, jlong instance,
+ jstring jdata)
{
ANDROID_EVENT* event;
freerdp* inst = (freerdp*)instance;
- const jbyte* data = jdata != NULL ? (*env)->GetStringUTFChars(env, jdata,
- NULL) : NULL;
+ const jbyte* data = jdata != NULL ? (*env)->GetStringUTFChars(env, jdata, NULL) : NULL;
int data_length = data ? strlen(data) : 0;
jboolean ret = JNI_FALSE;
- event = (ANDROID_EVENT*) android_event_clipboard_new((void*)data, data_length);
+ event = (ANDROID_EVENT*)android_event_clipboard_new((void*)data, data_length);
if (!event)
goto out_fail;
@@ -1071,88 +1044,25 @@ static jstring JNICALL jni_freerdp_get_build_config(JNIEnv* env, jclass cls)
return (*env)->NewStringUTF(env, freerdp_get_build_config());
}
-static JNINativeMethod methods[] =
-{
- {
- "freerdp_get_jni_version",
- "()Ljava/lang/String;",
- &jni_freerdp_get_jni_version
- },
- {
- "freerdp_get_version",
- "()Ljava/lang/String;",
- &jni_freerdp_get_version
- },
- {
- "freerdp_get_build_date",
- "()Ljava/lang/String;",
- &jni_freerdp_get_build_date
- },
- {
- "freerdp_get_build_revision",
- "()Ljava/lang/String;",
- &jni_freerdp_get_build_revision
- },
- {
- "freerdp_get_build_config",
- "()Ljava/lang/String;",
- &jni_freerdp_get_build_config
- },
- {
- "freerdp_get_last_error_string",
- "(J)Ljava/lang/String;",
- &jni_freerdp_get_last_error_string
- },
- {
- "freerdp_new",
- "(Landroid/content/Context;)J",
- &jni_freerdp_new
- },
- {
- "freerdp_free",
- "(J)V",
- &jni_freerdp_free
- },
- {
- "freerdp_parse_arguments",
- "(J[Ljava/lang/String;)Z",
- &jni_freerdp_parse_arguments
- },
- {
- "freerdp_connect",
- "(J)Z",
- &jni_freerdp_connect
- },
- {
- "freerdp_disconnect",
- "(J)Z",
- &jni_freerdp_disconnect
- },
- {
- "freerdp_update_graphics",
- "(JLandroid/graphics/Bitmap;IIII)Z",
- &jni_freerdp_update_graphics
- },
- {
- "freerdp_send_cursor_event",
- "(JIII)Z",
- &jni_freerdp_send_cursor_event
- },
- {
- "freerdp_send_key_event",
- "(JIZ)Z",
- &jni_freerdp_send_key_event
- },
- {
- "freerdp_send_unicodekey_event",
- "(JIZ)Z",
- &jni_freerdp_send_unicodekey_event
- },
- {
- "freerdp_send_clipboard_data",
- "(JLjava/lang/String;)Z",
- &jni_freerdp_send_clipboard_data
- }
+static JNINativeMethod methods[] = {
+ { "freerdp_get_jni_version", "()Ljava/lang/String;", &jni_freerdp_get_jni_version },
+ { "freerdp_get_version", "()Ljava/lang/String;", &jni_freerdp_get_version },
+ { "freerdp_get_build_date", "()Ljava/lang/String;", &jni_freerdp_get_build_date },
+ { "freerdp_get_build_revision", "()Ljava/lang/String;", &jni_freerdp_get_build_revision },
+ { "freerdp_get_build_config", "()Ljava/lang/String;", &jni_freerdp_get_build_config },
+ { "freerdp_get_last_error_string", "(J)Ljava/lang/String;",
+ &jni_freerdp_get_last_error_string },
+ { "freerdp_new", "(Landroid/content/Context;)J", &jni_freerdp_new },
+ { "freerdp_free", "(J)V", &jni_freerdp_free },
+ { "freerdp_parse_arguments", "(J[Ljava/lang/String;)Z", &jni_freerdp_parse_arguments },
+ { "freerdp_connect", "(J)Z", &jni_freerdp_connect },
+ { "freerdp_disconnect", "(J)Z", &jni_freerdp_disconnect },
+ { "freerdp_update_graphics", "(JLandroid/graphics/Bitmap;IIII)Z",
+ &jni_freerdp_update_graphics },
+ { "freerdp_send_cursor_event", "(JIII)Z", &jni_freerdp_send_cursor_event },
+ { "freerdp_send_key_event", "(JIZ)Z", &jni_freerdp_send_key_event },
+ { "freerdp_send_unicodekey_event", "(JIZ)Z", &jni_freerdp_send_unicodekey_event },
+ { "freerdp_send_clipboard_data", "(JLjava/lang/String;)Z", &jni_freerdp_send_clipboard_data }
};
static jclass gJavaActivityClass = NULL;
@@ -1164,11 +1074,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
WLog_DBG(TAG, "Setting up JNI environement...");
/*
- if (freerdp_handle_signals() != 0)
- {
- WLog_FATAL(TAG, "Failed to register signal handler");
- return -1;
- }
+ if (freerdp_handle_signals() != 0)
+ {
+ WLog_FATAL(TAG, "Failed to register signal handler");
+ return -1;
+ }
*/
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK)
{
@@ -1186,8 +1096,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
}
// Register methods with env->RegisterNatives.
- (*env)->RegisterNatives(env, activityClass, methods,
- sizeof(methods) / sizeof(methods[0]));
+ (*env)->RegisterNatives(env, activityClass, methods, sizeof(methods) / sizeof(methods[0]));
/* create global reference for class */
gJavaActivityClass = (*env)->NewGlobalRef(env, activityClass);
g_JavaVm = vm;
diff --git a/client/Android/android_freerdp.h b/client/Android/android_freerdp.h
index ac8ca897b..58d127cbd 100644
--- a/client/Android/android_freerdp.h
+++ b/client/Android/android_freerdp.h
@@ -3,8 +3,9 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#ifndef FREERDP_CLIENT_ANDROID_FREERDP_H
@@ -41,5 +42,3 @@ struct android_context
typedef struct android_context androidContext;
#endif /* FREERDP_CLIENT_ANDROID_FREERDP_H */
-
-
diff --git a/client/Android/android_freerdp_jni.h b/client/Android/android_freerdp_jni.h
index 5bf48a24f..c0055f574 100644
--- a/client/Android/android_freerdp_jni.h
+++ b/client/Android/android_freerdp_jni.h
@@ -25,4 +25,3 @@
#define JAVA_FILE_CLASS "java/io/File"
#endif /* FREERDP_CLIENT_ANDROID_FREERDP_JNI_H */
-
diff --git a/client/Android/android_jni_callback.c b/client/Android/android_jni_callback.c
index d8a5dcf3e..d57a7caca 100644
--- a/client/Android/android_jni_callback.c
+++ b/client/Android/android_jni_callback.c
@@ -58,7 +58,8 @@ static void jni_load_class(JNIEnv* env, const char* path, jobject* objptr)
(*objptr) = (*env)->NewGlobalRef(env, object);
finish:
- while (0);
+ while (0)
+ ;
}
jint init_callback_environment(JavaVM* vm, JNIEnv* env)
@@ -71,15 +72,14 @@ jint init_callback_environment(JavaVM* vm, JNIEnv* env)
/* attach current thread to jvm */
jboolean jni_attach_thread(JNIEnv** env)
{
- if ((*jVM)->GetEnv(jVM, (void**) env, JNI_VERSION_1_4) != JNI_OK)
+ if ((*jVM)->GetEnv(jVM, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{
WLog_DBG(TAG, "android_java_callback: attaching current thread");
(*jVM)->AttachCurrentThread(jVM, env, NULL);
- if ((*jVM)->GetEnv(jVM, (void**) env, JNI_VERSION_1_4) != JNI_OK)
+ if ((*jVM)->GetEnv(jVM, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{
- WLog_ERR(TAG,
- "android_java_callback: failed to obtain current JNI environment");
+ WLog_ERR(TAG, "android_java_callback: failed to obtain current JNI environment");
}
return JNI_TRUE;
@@ -95,8 +95,8 @@ void jni_detach_thread()
}
/* callback with void result */
-static void java_callback_void(jobject obj, const char* callback,
- const char* signature, va_list args)
+static void java_callback_void(jobject obj, const char* callback, const char* signature,
+ va_list args)
{
jclass jObjClass;
jmethodID jCallback;
@@ -128,8 +128,8 @@ finish:
}
/* callback with bool result */
-static jboolean java_callback_bool(jobject obj, const char* callback,
- const char* signature, va_list args)
+static jboolean java_callback_bool(jobject obj, const char* callback, const char* signature,
+ va_list args)
{
jclass jObjClass;
jmethodID jCallback;
@@ -164,8 +164,8 @@ finish:
}
/* callback with int result */
-static jint java_callback_int(jobject obj, const char* callback,
- const char* signature, va_list args)
+static jint java_callback_int(jobject obj, const char* callback, const char* signature,
+ va_list args)
{
jclass jObjClass;
jmethodID jCallback;
@@ -199,7 +199,6 @@ finish:
return res;
}
-
/* callback to freerdp class */
void freerdp_callback(const char* callback, const char* signature, ...)
{
@@ -209,8 +208,7 @@ void freerdp_callback(const char* callback, const char* signature, ...)
va_end(vl);
}
-jboolean freerdp_callback_bool_result(const char* callback,
- const char* signature, ...)
+jboolean freerdp_callback_bool_result(const char* callback, const char* signature, ...)
{
va_list vl;
va_start(vl, signature);
@@ -219,8 +217,7 @@ jboolean freerdp_callback_bool_result(const char* callback,
return res;
}
-jint freerdp_callback_int_result(const char* callback, const char* signature,
- ...)
+jint freerdp_callback_int_result(const char* callback, const char* signature, ...)
{
va_list vl;
va_start(vl, signature);
diff --git a/client/Android/android_jni_callback.h b/client/Android/android_jni_callback.h
index 7f91306e3..861e40d27 100644
--- a/client/Android/android_jni_callback.h
+++ b/client/Android/android_jni_callback.h
@@ -20,12 +20,9 @@
FREERDP_LOCAL jint init_callback_environment(JavaVM* vm, JNIEnv* env);
FREERDP_LOCAL jboolean jni_attach_thread(JNIEnv** env);
FREERDP_LOCAL void jni_detach_thread(void);
-FREERDP_LOCAL void freerdp_callback(const char* callback, const char* signature,
- ...);
-FREERDP_LOCAL jboolean freerdp_callback_bool_result(const char* callback,
- const char* signature, ...);
-FREERDP_LOCAL jint freerdp_callback_int_result(const char* callback,
- const char* signature, ...);
+FREERDP_LOCAL void freerdp_callback(const char* callback, const char* signature, ...);
+FREERDP_LOCAL jboolean freerdp_callback_bool_result(const char* callback, const char* signature,
+ ...);
+FREERDP_LOCAL jint freerdp_callback_int_result(const char* callback, const char* signature, ...);
#endif /* FREERDP_CLIENT_ANDROID_JNI_CALLBACK_H */
-
diff --git a/client/Android/android_jni_utils.c b/client/Android/android_jni_utils.c
index f79b39c32..9c2ee3840 100644
--- a/client/Android/android_jni_utils.c
+++ b/client/Android/android_jni_utils.c
@@ -20,7 +20,7 @@
#define TAG CLIENT_TAG("android.utils")
-JavaVM *g_JavaVm;
+JavaVM* g_JavaVm;
JavaVM* getJavaVM()
{
@@ -30,7 +30,7 @@ JavaVM* getJavaVM()
JNIEnv* getJNIEnv()
{
JNIEnv* env = NULL;
- if ((*g_JavaVm)->GetEnv(g_JavaVm, (void**) &env, JNI_VERSION_1_4) != JNI_OK)
+ if ((*g_JavaVm)->GetEnv(g_JavaVm, (void**)&env, JNI_VERSION_1_4) != JNI_OK)
{
WLog_FATAL(TAG, "Failed to obtain JNIEnv");
return NULL;
@@ -38,7 +38,7 @@ JNIEnv* getJNIEnv()
return env;
}
-jobject create_string_builder(JNIEnv *env, char* initialStr)
+jobject create_string_builder(JNIEnv* env, char* initialStr)
{
jclass cls;
jmethodID methodId;
@@ -46,14 +46,14 @@ jobject create_string_builder(JNIEnv *env, char* initialStr)
// get class
cls = (*env)->FindClass(env, "java/lang/StringBuilder");
- if(!cls)
+ if (!cls)
return NULL;
- if(initialStr)
+ if (initialStr)
{
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "", "(Ljava/lang/String;)V");
- if(!methodId)
+ if (!methodId)
return NULL;
// create string that holds our initial string
@@ -66,7 +66,7 @@ jobject create_string_builder(JNIEnv *env, char* initialStr)
{
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "", "()V");
- if(!methodId)
+ if (!methodId)
return NULL;
// construct new StringBuilder
@@ -86,12 +86,12 @@ char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder)
// get class
cls = (*env)->FindClass(env, "java/lang/StringBuilder");
- if(!cls)
+ if (!cls)
return NULL;
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;");
- if(!methodId)
+ if (!methodId)
return NULL;
// get jstring representation of our buffer
@@ -128,10 +128,10 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len)
return NULL;
}
- for(i = 0; i < len; i++)
+ for (i = 0; i < len; i++)
{
unsigned char one = utf8[i];
- switch(one >> 4)
+ switch (one >> 4)
{
case 0x00:
case 0x01:
@@ -147,27 +147,25 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len)
case 0x09:
case 0x0a:
case 0x0b:
- //case 0x0f:
+ // case 0x0f:
/*
- * Bit pattern 10xx or 1111, which are illegal start bytes.
- * Note: 1111 is valid for normal UTF-8, but not the
- * modified UTF-8 used here.
- */
+ * Bit pattern 10xx or 1111, which are illegal start bytes.
+ * Note: 1111 is valid for normal UTF-8, but not the
+ * modified UTF-8 used here.
+ */
break;
case 0x0f:
case 0x0e:
// Bit pattern 111x, so there are two additional bytes.
if (i < (len - 2))
{
- unsigned char two = utf8[i+1];
- unsigned char three = utf8[i+2];
+ unsigned char two = utf8[i + 1];
+ unsigned char three = utf8[i + 2];
if ((two & 0xc0) == 0x80 && (three & 0xc0) == 0x80)
{
i += 2;
unicode[result_size++] =
- ((one & 0x0f) << 12)
- | ((two & 0x3f) << 6)
- | (three & 0x3f);
+ ((one & 0x0f) << 12) | ((two & 0x3f) << 6) | (three & 0x3f);
}
}
break;
@@ -176,13 +174,11 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len)
// Bit pattern 110x, so there is one additional byte.
if (i < (len - 1))
{
- unsigned char two = utf8[i+1];
+ unsigned char two = utf8[i + 1];
if ((two & 0xc0) == 0x80)
{
i += 1;
- unicode[result_size++] =
- ((one & 0x1f) << 6)
- | (two & 0x3f);
+ unicode[result_size++] = ((one & 0x1f) << 6) | (two & 0x3f);
}
}
break;
diff --git a/client/Android/android_jni_utils.h b/client/Android/android_jni_utils.h
index 5414e3301..0ac804d3b 100644
--- a/client/Android/android_jni_utils.h
+++ b/client/Android/android_jni_utils.h
@@ -20,15 +20,14 @@ extern "C"
{
#endif
-FREERDP_LOCAL JNIEnv* getJNIEnv();
-FREERDP_LOCAL JavaVM* getJavaVM();
+ FREERDP_LOCAL JNIEnv* getJNIEnv();
+ FREERDP_LOCAL JavaVM* getJavaVM();
-FREERDP_LOCAL char* get_string_from_string_builder(JNIEnv* env,
- jobject strBuilder);
-FREERDP_LOCAL jobject create_string_builder(JNIEnv* env, char* initialStr);
-FREERDP_LOCAL jstring jniNewStringUTF(JNIEnv* env, const char* in, int len);
+ FREERDP_LOCAL char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder);
+ FREERDP_LOCAL jobject create_string_builder(JNIEnv* env, char* initialStr);
+ FREERDP_LOCAL jstring jniNewStringUTF(JNIEnv* env, const char* in, int len);
-FREERDP_LOCAL extern JavaVM* g_JavaVm;
+ FREERDP_LOCAL extern JavaVM* g_JavaVm;
#ifdef __cplusplus
}
diff --git a/client/Mac/CertificateDialog.h b/client/Mac/CertificateDialog.h
index 2fccbcbfd..6c4455f78 100644
--- a/client/Mac/CertificateDialog.h
+++ b/client/Mac/CertificateDialog.h
@@ -22,39 +22,39 @@
@interface CertificateDialog : NSWindowController
{
-@public
- NSTextField* textCommonName;
- NSTextField* textSubject;
- NSTextField* textIssuer;
- NSTextField* textFingerprint;
- NSTextField* textMismatch;
- NSTextField* messageLabel;
- NSString* serverHostname;
+ @public
+ NSTextField *textCommonName;
+ NSTextField *textSubject;
+ NSTextField *textIssuer;
+ NSTextField *textFingerprint;
+ NSTextField *textMismatch;
+ NSTextField *messageLabel;
+ NSString *serverHostname;
BOOL hostMismatch;
BOOL changed;
int result;
}
-@property(retain) IBOutlet NSTextField* textCommonName;
-@property(retain) IBOutlet NSTextField* textSubject;
-@property(retain) IBOutlet NSTextField* textIssuer;
-@property(retain) IBOutlet NSTextField* textFingerprint;
-@property(retain) IBOutlet NSTextField* textMismatch;
-@property(retain) IBOutlet NSTextField* messageLabel;
+@property(retain) IBOutlet NSTextField *textCommonName;
+@property(retain) IBOutlet NSTextField *textSubject;
+@property(retain) IBOutlet NSTextField *textIssuer;
+@property(retain) IBOutlet NSTextField *textFingerprint;
+@property(retain) IBOutlet NSTextField *textMismatch;
+@property(retain) IBOutlet NSTextField *messageLabel;
-- (IBAction)onAccept:(NSObject*)sender;
-- (IBAction)onTemporary:(NSObject*)sender;
-- (IBAction)onCancel:(NSObject*)sender;
+- (IBAction)onAccept:(NSObject *)sender;
+- (IBAction)onTemporary:(NSObject *)sender;
+- (IBAction)onCancel:(NSObject *)sender;
-@property(retain) NSString* serverHostname;
-@property(retain) NSString* commonName;
-@property(retain) NSString* subject;
-@property(retain) NSString* issuer;
-@property(retain) NSString* fingerprint;
+@property(retain) NSString *serverHostname;
+@property(retain) NSString *commonName;
+@property(retain) NSString *subject;
+@property(retain) NSString *issuer;
+@property(retain) NSString *fingerprint;
@property BOOL hostMismatch;
@property BOOL changed;
@property(readonly) int result;
-- (int) runModal:(NSWindow*)mainWindow;
+- (int)runModal:(NSWindow *)mainWindow;
@end
diff --git a/client/Mac/CertificateDialog.m b/client/Mac/CertificateDialog.m
index dc01e10d1..152fbcd43 100644
--- a/client/Mac/CertificateDialog.m
+++ b/client/Mac/CertificateDialog.m
@@ -23,9 +23,9 @@
#import
-@interface CertificateDialog()
+@interface CertificateDialog ()
- @property int result;
+@property int result;
@end
@@ -54,57 +54,63 @@
- (void)windowDidLoad
{
[super windowDidLoad];
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+ // Implement this method to handle any initialization after your window controller's window has
+ // been loaded from its nib file.
[self.window setTitle:self.serverHostname];
if (self.changed)
[self.messageLabel setStringValue:[NSString stringWithFormat:@"Changed certificate for %@",
- self.serverHostname]];
+ self.serverHostname]];
else
[self.messageLabel setStringValue:[NSString stringWithFormat:@"New Certificate for %@",
- self.serverHostname]];
+ self.serverHostname]];
if (!self.hostMismatch)
- [self.textMismatch setStringValue:[NSString stringWithFormat:@"NOTE: The server name matches the certificate, good."]];
+ [self.textMismatch
+ setStringValue:[NSString stringWithFormat:
+ @"NOTE: The server name matches the certificate, good."]];
else
- [self.textMismatch setStringValue:[NSString stringWithFormat:@"ATTENTION: The common name does not match the server name!"]];
+ [self.textMismatch
+ setStringValue:[NSString
+ stringWithFormat:
+ @"ATTENTION: The common name does not match the server name!"]];
[self.textCommonName setStringValue:self.commonName];
[self.textFingerprint setStringValue:self.fingerprint];
[self.textIssuer setStringValue:self.issuer];
[self.textSubject setStringValue:self.subject];
}
-- (IBAction)onAccept:(NSObject*)sender
+- (IBAction)onAccept:(NSObject *)sender
{
[NSApp stopModalWithCode:1];
}
-- (IBAction)onTemporary:(NSObject*)sender
+- (IBAction)onTemporary:(NSObject *)sender
{
[NSApp stopModalWithCode:2];
}
-- (IBAction)onCancel:(NSObject*)sender
+- (IBAction)onCancel:(NSObject *)sender
{
[NSApp stopModalWithCode:0];
}
-- (int)runModal:(NSWindow*)mainWindow
+- (int)runModal:(NSWindow *)mainWindow
{
if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
{
[mainWindow beginSheet:self.window completionHandler:nil];
- self.result = [NSApp runModalForWindow: self.window];
- [mainWindow endSheet: self.window];
+ self.result = [NSApp runModalForWindow:self.window];
+ [mainWindow endSheet:self.window];
}
else
{
- [NSApp beginSheet: self.window
- modalForWindow: mainWindow
- modalDelegate: nil
- didEndSelector: nil
- contextInfo: nil];
- self.result = [NSApp runModalForWindow: self.window];
- [NSApp endSheet: self.window];
+ [NSApp beginSheet:self.window
+ modalForWindow:mainWindow
+ modalDelegate:nil
+ didEndSelector:nil
+ contextInfo:nil];
+ self.result = [NSApp runModalForWindow:self.window];
+ [NSApp endSheet:self.window];
}
[self.window orderOut:nil];
diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m
index 19c2cc5fc..a34e5a85d 100644
--- a/client/Mac/Clipboard.m
+++ b/client/Mac/Clipboard.m
@@ -20,104 +20,105 @@
#import "Clipboard.h"
-int mac_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
+int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr)
{
UINT32 index;
UINT32 formatId;
UINT32 numFormats;
- UINT32* pFormatIds;
- const char* formatName;
- CLIPRDR_FORMAT* formats;
+ UINT32 *pFormatIds;
+ const char *formatName;
+ CLIPRDR_FORMAT *formats;
CLIPRDR_FORMAT_LIST formatList;
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
ZeroMemory(&formatList, sizeof(CLIPRDR_FORMAT_LIST));
-
+
pFormatIds = NULL;
numFormats = ClipboardGetFormatIds(mfc->clipboard, &pFormatIds);
-
- formats = (CLIPRDR_FORMAT*) calloc(numFormats, sizeof(CLIPRDR_FORMAT));
-
+
+ formats = (CLIPRDR_FORMAT *)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
+
if (!formats)
return -1;
-
+
for (index = 0; index < numFormats; index++)
{
formatId = pFormatIds[index];
formatName = ClipboardGetFormatName(mfc->clipboard, formatId);
-
+
formats[index].formatId = formatId;
formats[index].formatName = NULL;
-
+
if ((formatId > CF_MAX) && formatName)
formats[index].formatName = _strdup(formatName);
}
-
+
formatList.msgFlags = CB_RESPONSE_OK;
formatList.numFormats = numFormats;
formatList.formats = formats;
-
+
mfc->cliprdr->ClientFormatList(mfc->cliprdr, &formatList);
-
+
for (index = 0; index < numFormats; index++)
{
free(formats[index].formatName);
}
-
+
free(pFormatIds);
free(formats);
-
+
return 1;
}
-static int mac_cliprdr_send_client_format_list_response(CliprdrClientContext* cliprdr, BOOL status)
+static int mac_cliprdr_send_client_format_list_response(CliprdrClientContext *cliprdr, BOOL status)
{
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
-
+
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
formatListResponse.dataLen = 0;
-
+
cliprdr->ClientFormatListResponse(cliprdr, &formatListResponse);
-
+
return 1;
}
-static int mac_cliprdr_send_client_format_data_request(CliprdrClientContext* cliprdr, UINT32 formatId)
+static int mac_cliprdr_send_client_format_data_request(CliprdrClientContext *cliprdr,
+ UINT32 formatId)
{
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
ZeroMemory(&formatDataRequest, sizeof(CLIPRDR_FORMAT_DATA_REQUEST));
-
+
formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST;
formatDataRequest.msgFlags = 0;
-
+
formatDataRequest.requestedFormatId = formatId;
mfc->requestedFormatId = formatId;
ResetEvent(mfc->clipboardRequestEvent);
-
+
cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest);
-
+
return 1;
}
-static int mac_cliprdr_send_client_capabilities(CliprdrClientContext* cliprdr)
+static int mac_cliprdr_send_client_capabilities(CliprdrClientContext *cliprdr)
{
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
-
+
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &(generalCapabilitySet);
-
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
+
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
-
+
generalCapabilitySet.version = CB_CAPS_VERSION_2;
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
-
+
cliprdr->ClientCapabilities(cliprdr, &capabilities);
-
+
return 1;
}
@@ -126,14 +127,15 @@ static int mac_cliprdr_send_client_capabilities(CliprdrClientContext* cliprdr)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_monitor_ready(CliprdrClientContext* cliprdr, const CLIPRDR_MONITOR_READY* monitorReady)
+static UINT mac_cliprdr_monitor_ready(CliprdrClientContext *cliprdr,
+ const CLIPRDR_MONITOR_READY *monitorReady)
{
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
mfc->clipboardSync = TRUE;
mac_cliprdr_send_client_capabilities(cliprdr);
mac_cliprdr_send_client_format_list(cliprdr);
-
+
return CHANNEL_RC_OK;
}
@@ -142,27 +144,28 @@ static UINT mac_cliprdr_monitor_ready(CliprdrClientContext* cliprdr, const CLIPR
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_capabilities(CliprdrClientContext* cliprdr, const CLIPRDR_CAPABILITIES* capabilities)
+static UINT mac_cliprdr_server_capabilities(CliprdrClientContext *cliprdr,
+ const CLIPRDR_CAPABILITIES *capabilities)
{
UINT32 index;
- CLIPRDR_CAPABILITY_SET* capabilitySet;
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ CLIPRDR_CAPABILITY_SET *capabilitySet;
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
for (index = 0; index < capabilities->cCapabilitiesSets; index++)
{
capabilitySet = &(capabilities->capabilitySets[index]);
-
+
if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) &&
(capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN))
{
- CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet
- = (CLIPRDR_GENERAL_CAPABILITY_SET*) capabilitySet;
-
+ CLIPRDR_GENERAL_CAPABILITY_SET *generalCapabilitySet =
+ (CLIPRDR_GENERAL_CAPABILITY_SET *)capabilitySet;
+
mfc->clipboardCapabilities = generalCapabilitySet->generalFlags;
break;
}
}
-
+
return CHANNEL_RC_OK;
}
@@ -171,48 +174,49 @@ static UINT mac_cliprdr_server_capabilities(CliprdrClientContext* cliprdr, const
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_format_list(CliprdrClientContext* cliprdr, const CLIPRDR_FORMAT_LIST* formatList)
+static UINT mac_cliprdr_server_format_list(CliprdrClientContext *cliprdr,
+ const CLIPRDR_FORMAT_LIST *formatList)
{
UINT32 index;
- CLIPRDR_FORMAT* format;
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ CLIPRDR_FORMAT *format;
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
if (mfc->serverFormats)
{
for (index = 0; index < mfc->numServerFormats; index++)
{
free(mfc->serverFormats[index].formatName);
}
-
+
free(mfc->serverFormats);
mfc->serverFormats = NULL;
mfc->numServerFormats = 0;
}
-
+
if (formatList->numFormats < 1)
return CHANNEL_RC_OK;
-
+
mfc->numServerFormats = formatList->numFormats;
- mfc->serverFormats = (CLIPRDR_FORMAT*) calloc(mfc->numServerFormats, sizeof(CLIPRDR_FORMAT));
-
+ mfc->serverFormats = (CLIPRDR_FORMAT *)calloc(mfc->numServerFormats, sizeof(CLIPRDR_FORMAT));
+
if (!mfc->serverFormats)
return CHANNEL_RC_NO_MEMORY;
-
+
for (index = 0; index < mfc->numServerFormats; index++)
{
mfc->serverFormats[index].formatId = formatList->formats[index].formatId;
mfc->serverFormats[index].formatName = NULL;
-
+
if (formatList->formats[index].formatName)
mfc->serverFormats[index].formatName = _strdup(formatList->formats[index].formatName);
}
-
+
mac_cliprdr_send_client_format_list_response(cliprdr, TRUE);
-
+
for (index = 0; index < mfc->numServerFormats; index++)
{
format = &(mfc->serverFormats[index]);
-
+
if (format->formatId == CF_UNICODETEXT)
{
mac_cliprdr_send_client_format_data_request(cliprdr, CF_UNICODETEXT);
@@ -229,7 +233,7 @@ static UINT mac_cliprdr_server_format_list(CliprdrClientContext* cliprdr, const
break;
}
}
-
+
return CHANNEL_RC_OK;
}
@@ -238,7 +242,9 @@ static UINT mac_cliprdr_server_format_list(CliprdrClientContext* cliprdr, const
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_format_list_response(CliprdrClientContext* cliprdr, const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+mac_cliprdr_server_format_list_response(CliprdrClientContext *cliprdr,
+ const CLIPRDR_FORMAT_LIST_RESPONSE *formatListResponse)
{
return CHANNEL_RC_OK;
}
@@ -248,7 +254,9 @@ static UINT mac_cliprdr_server_format_list_response(CliprdrClientContext* cliprd
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_lock_clipboard_data(CliprdrClientContext* cliprdr, const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+static UINT
+mac_cliprdr_server_lock_clipboard_data(CliprdrClientContext *cliprdr,
+ const CLIPRDR_LOCK_CLIPBOARD_DATA *lockClipboardData)
{
return CHANNEL_RC_OK;
}
@@ -258,7 +266,9 @@ static UINT mac_cliprdr_server_lock_clipboard_data(CliprdrClientContext* cliprdr
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* cliprdr, const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+static UINT
+mac_cliprdr_server_unlock_clipboard_data(CliprdrClientContext *cliprdr,
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA *unlockClipboardData)
{
return CHANNEL_RC_OK;
}
@@ -268,34 +278,36 @@ static UINT mac_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* clipr
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_format_data_request(CliprdrClientContext* cliprdr, const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+static UINT
+mac_cliprdr_server_format_data_request(CliprdrClientContext *cliprdr,
+ const CLIPRDR_FORMAT_DATA_REQUEST *formatDataRequest)
{
- BYTE* data;
+ BYTE *data;
UINT32 size;
UINT32 formatId;
CLIPRDR_FORMAT_DATA_RESPONSE response;
- mfContext* mfc = (mfContext*) cliprdr->custom;
-
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+
ZeroMemory(&response, sizeof(CLIPRDR_FORMAT_DATA_RESPONSE));
-
+
formatId = formatDataRequest->requestedFormatId;
- data = (BYTE*) ClipboardGetData(mfc->clipboard, formatId, &size);
-
+ data = (BYTE *)ClipboardGetData(mfc->clipboard, formatId, &size);
+
response.msgFlags = CB_RESPONSE_OK;
response.dataLen = size;
response.requestedFormatData = data;
-
+
if (!data)
{
response.msgFlags = CB_RESPONSE_FAIL;
response.dataLen = 0;
response.requestedFormatData = NULL;
}
-
+
cliprdr->ClientFormatDataResponse(cliprdr, &response);
-
+
free(data);
-
+
return CHANNEL_RC_OK;
}
@@ -304,62 +316,66 @@ static UINT mac_cliprdr_server_format_data_request(CliprdrClientContext* cliprdr
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr,
+ const CLIPRDR_FORMAT_DATA_RESPONSE *formatDataResponse)
{
- BYTE* data;
+ BYTE *data;
UINT32 size;
UINT32 index;
UINT32 formatId;
- CLIPRDR_FORMAT* format = NULL;
- mfContext* mfc = (mfContext*) cliprdr->custom;
- MRDPView* view = (MRDPView*) mfc->view;
-
+ CLIPRDR_FORMAT *format = NULL;
+ mfContext *mfc = (mfContext *)cliprdr->custom;
+ MRDPView *view = (MRDPView *)mfc->view;
+
if (formatDataResponse->msgFlags & CB_RESPONSE_FAIL)
{
SetEvent(mfc->clipboardRequestEvent);
return ERROR_INTERNAL_ERROR;
}
-
+
for (index = 0; index < mfc->numServerFormats; index++)
{
if (mfc->requestedFormatId == mfc->serverFormats[index].formatId)
format = &(mfc->serverFormats[index]);
}
-
+
if (!format)
{
SetEvent(mfc->clipboardRequestEvent);
return ERROR_INTERNAL_ERROR;
}
-
+
if (format->formatName)
formatId = ClipboardRegisterFormat(mfc->clipboard, format->formatName);
else
formatId = format->formatId;
-
+
size = formatDataResponse->dataLen;
-
+
ClipboardSetData(mfc->clipboard, formatId, formatDataResponse->requestedFormatData, size);
-
+
SetEvent(mfc->clipboardRequestEvent);
-
+
if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) || (formatId == CF_UNICODETEXT))
{
formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING");
-
- data = (void*) ClipboardGetData(mfc->clipboard, formatId, &size);
-
+
+ data = (void *)ClipboardGetData(mfc->clipboard, formatId, &size);
+
if (size > 1)
size--; /* we need the size without the null terminator */
-
- NSString* str = [[NSString alloc] initWithBytes: (void*) data length:size encoding:NSUTF8StringEncoding];
+
+ NSString *str = [[NSString alloc] initWithBytes:(void *)data
+ length:size
+ encoding:NSUTF8StringEncoding];
free(data);
-
- NSArray* types = [[NSArray alloc] initWithObjects:NSStringPboardType, nil];
+
+ NSArray *types = [[NSArray alloc] initWithObjects:NSStringPboardType, nil];
[view->pasteboard_wr declareTypes:types owner:view];
[view->pasteboard_wr setString:str forType:NSStringPboardType];
}
-
+
return CHANNEL_RC_OK;
}
@@ -368,7 +384,9 @@ static UINT mac_cliprdr_server_format_data_response(CliprdrClientContext* cliprd
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_file_contents_request(CliprdrClientContext* cliprdr, const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+mac_cliprdr_server_file_contents_request(CliprdrClientContext *cliprdr,
+ const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
{
return CHANNEL_RC_OK;
}
@@ -378,19 +396,20 @@ static UINT mac_cliprdr_server_file_contents_request(CliprdrClientContext* clipr
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT mac_cliprdr_server_file_contents_response(CliprdrClientContext* cliprdr, const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
+static UINT mac_cliprdr_server_file_contents_response(
+ CliprdrClientContext *cliprdr, const CLIPRDR_FILE_CONTENTS_RESPONSE *fileContentsResponse)
{
return CHANNEL_RC_OK;
}
-void mac_cliprdr_init(mfContext* mfc, CliprdrClientContext* cliprdr)
+void mac_cliprdr_init(mfContext *mfc, CliprdrClientContext *cliprdr)
{
- cliprdr->custom = (void*) mfc;
+ cliprdr->custom = (void *)mfc;
mfc->cliprdr = cliprdr;
-
+
mfc->clipboard = ClipboardCreate();
mfc->clipboardRequestEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
+
cliprdr->MonitorReady = mac_cliprdr_monitor_ready;
cliprdr->ServerCapabilities = mac_cliprdr_server_capabilities;
cliprdr->ServerFormatList = mac_cliprdr_server_format_list;
@@ -403,11 +422,11 @@ void mac_cliprdr_init(mfContext* mfc, CliprdrClientContext* cliprdr)
cliprdr->ServerFileContentsResponse = mac_cliprdr_server_file_contents_response;
}
-void mac_cliprdr_uninit(mfContext* mfc, CliprdrClientContext* cliprdr)
+void mac_cliprdr_uninit(mfContext *mfc, CliprdrClientContext *cliprdr)
{
cliprdr->custom = NULL;
mfc->cliprdr = NULL;
-
+
ClipboardDestroy(mfc->clipboard);
CloseHandle(mfc->clipboardRequestEvent);
}
diff --git a/client/Mac/Keyboard.m b/client/Mac/Keyboard.m
index 90eb5381d..9bb9cd481 100644
--- a/client/Mac/Keyboard.m
+++ b/client/Mac/Keyboard.m
@@ -33,8 +33,7 @@ typedef struct _APPLE_KEYBOARD_DESC APPLE_KEYBOARD_DESC;
/* VendorID: 0x05AC (Apple, Inc.) */
-static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
-{
+static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] = {
{ 0x200, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x201, APPLE_KEYBOARD_TYPE_ANSI }, /* USB Keyboard [Alps or Logitech, M2452] */
{ 0x202, APPLE_KEYBOARD_TYPE_ANSI }, /* Keyboard [ALPS] */
@@ -50,48 +49,48 @@ static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{ 0x20C, APPLE_KEYBOARD_TYPE_ANSI }, /* Extended Keyboard [Mitsumi] */
{ 0x20D, APPLE_KEYBOARD_TYPE_ANSI }, /* Pro Keyboard [Mitsumi, A1048/JIS layout] */
{ 0x20E, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x20F, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x20F, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
{ 0x210, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x211, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x212, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x213, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x214, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x215, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x216, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x215, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x216, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x217, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x218, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x219, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x218, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x219, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x21A, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x21B, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x21C, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x21B, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x21C, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x21D, APPLE_KEYBOARD_TYPE_ANSI }, /* Aluminum Mini Keyboard (ANSI) */
- { 0x21E, APPLE_KEYBOARD_TYPE_ISO }, /* Aluminum Mini Keyboard (ISO) */
- { 0x21F, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Mini Keyboard (JIS) */
+ { 0x21E, APPLE_KEYBOARD_TYPE_ISO }, /* Aluminum Mini Keyboard (ISO) */
+ { 0x21F, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Mini Keyboard (JIS) */
{ 0x220, APPLE_KEYBOARD_TYPE_ANSI }, /* Aluminum Keyboard (ANSI) */
- { 0x221, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
- { 0x222, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
+ { 0x221, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
+ { 0x222, APPLE_KEYBOARD_TYPE_JIS }, /* Aluminum Keyboard (JIS) */
{ 0x223, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x224, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x225, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x224, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x225, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x226, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x227, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x228, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x229, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (MacBook Pro) (ANSI) */
- { 0x22A, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro) (ISO) */
- { 0x22B, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro) (JIS) */
+ { 0x22A, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro) (ISO) */
+ { 0x22B, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro) (JIS) */
{ 0x22C, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x22D, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x22E, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x22F, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x230, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (ANSI) */
- { 0x231, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (ISO) */
- { 0x232, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (JIS) */
+ { 0x231, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (ISO) */
+ { 0x232, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (MacBook Pro 4,1) (JIS) */
{ 0x233, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x234, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x235, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x236, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x237, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x238, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x237, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x238, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x239, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x23A, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x23B, APPLE_KEYBOARD_TYPE_ANSI },
@@ -99,14 +98,14 @@ static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{ 0x23D, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x23E, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x23F, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x240, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x241, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x240, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x241, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x242, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x243, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x244, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x243, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x244, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x245, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x246, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x247, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x246, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x247, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x248, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x249, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x24A, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (MacBook Air) (ISO) */
@@ -118,8 +117,8 @@ static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{ 0x250, APPLE_KEYBOARD_TYPE_ISO }, /* Aluminium Keyboard (ISO) */
{ 0x251, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x252, APPLE_KEYBOARD_TYPE_ANSI }, /* Internal Keyboard/Trackpad (ANSI) */
- { 0x253, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
- { 0x254, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
+ { 0x253, APPLE_KEYBOARD_TYPE_ISO }, /* Internal Keyboard/Trackpad (ISO) */
+ { 0x254, APPLE_KEYBOARD_TYPE_JIS }, /* Internal Keyboard/Trackpad (JIS) */
{ 0x255, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x256, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x257, APPLE_KEYBOARD_TYPE_ANSI },
@@ -144,8 +143,7 @@ static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{ 0x26A, APPLE_KEYBOARD_TYPE_ANSI }
};
-static enum APPLE_KEYBOARD_TYPE mac_identify_keyboard_type(uint32_t vendorID,
- uint32_t productID)
+static enum APPLE_KEYBOARD_TYPE mac_identify_keyboard_type(uint32_t vendorID, uint32_t productID)
{
enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
@@ -164,10 +162,9 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type(void)
CFSetRef deviceCFSetRef = NULL;
IOHIDDeviceRef inIOHIDDeviceRef = NULL;
IOHIDManagerRef tIOHIDManagerRef = NULL;
- IOHIDDeviceRef* tIOHIDDeviceRefs = nil;
+ IOHIDDeviceRef *tIOHIDDeviceRefs = nil;
enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
- tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault,
- kIOHIDOptionsTypeNone);
+ tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
if (!tIOHIDManagerRef)
return type;
@@ -189,7 +186,7 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type(void)
if (!tIOHIDDeviceRefs)
return type;
- CFSetGetValues(deviceCFSetRef, (const void**) tIOHIDDeviceRefs);
+ CFSetGetValues(deviceCFSetRef, (const void **)tIOHIDDeviceRefs);
CFRelease(deviceCFSetRef);
deviceCFSetRef = NULL;
@@ -208,19 +205,17 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type(void)
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDVendorIDKey));
if (tCFTypeRef)
- CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &vendorID);
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &vendorID);
- tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef,
- CFSTR(kIOHIDProductIDKey));
+ tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductIDKey));
if (tCFTypeRef)
- CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &productID);
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &productID);
- tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef,
- CFSTR(kIOHIDCountryCodeKey));
+ tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDCountryCodeKey));
if (tCFTypeRef)
- CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &countryCode);
+ CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, &countryCode);
ltype = mac_identify_keyboard_type(vendorID, productID);
diff --git a/client/Mac/MRDPCursor.h b/client/Mac/MRDPCursor.h
index 767ccbc52..6b16d793f 100644
--- a/client/Mac/MRDPCursor.h
+++ b/client/Mac/MRDPCursor.h
@@ -23,12 +23,12 @@
@interface MRDPCursor : NSObject
{
-@public
- rdpPointer* pointer;
- BYTE* cursor_data;
- NSBitmapImageRep* bmiRep;
- NSCursor* nsCursor;
- NSImage* nsImage;
+ @public
+ rdpPointer *pointer;
+ BYTE *cursor_data;
+ NSBitmapImageRep *bmiRep;
+ NSCursor *nsCursor;
+ NSImage *nsImage;
}
@end
diff --git a/client/Mac/MRDPView.h b/client/Mac/MRDPView.h
index 1c74a1b53..51eb8f549 100644
--- a/client/Mac/MRDPView.h
+++ b/client/Mac/MRDPView.h
@@ -30,19 +30,19 @@
@interface MRDPView : NSView
{
- mfContext* mfc;
- NSBitmapImageRep* bmiRep;
- NSMutableArray* cursors;
- NSMutableArray* windows;
- NSTimer* pasteboard_timer;
- NSCursor* currentCursor;
+ mfContext *mfc;
+ NSBitmapImageRep *bmiRep;
+ NSMutableArray *cursors;
+ NSMutableArray *windows;
+ NSTimer *pasteboard_timer;
+ NSCursor *currentCursor;
NSRect prevWinPosition;
- freerdp* instance;
- rdpContext* context;
+ freerdp *instance;
+ rdpContext *context;
CGContextRef bitmap_context;
- char* pixel_data;
+ char *pixel_data;
int argc;
- char** argv;
+ char **argv;
DWORD kbdModFlags;
BOOL initialized;
NSPoint savedDragLocation;
@@ -51,57 +51,51 @@
BOOL skipResizeOnce;
BOOL saveInitialDragLoc;
BOOL skipMoveWindowOnce;
-@public
- NSPasteboard* pasteboard_rd;
- NSPasteboard* pasteboard_wr;
+ @public
+ NSPasteboard *pasteboard_rd;
+ NSPasteboard *pasteboard_wr;
int pasteboard_changecount;
int pasteboard_format;
int is_connected;
}
-- (int) rdpStart :(rdpContext*) rdp_context;
-- (void) setCursor: (NSCursor*) cursor;
-- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height;
+- (int)rdpStart:(rdpContext *)rdp_context;
+- (void)setCursor:(NSCursor *)cursor;
+- (void)setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height;
-- (void) onPasteboardTimerFired :(NSTimer*) timer;
-- (void) pause;
-- (void) resume;
-- (void) releaseResources;
+- (void)onPasteboardTimerFired:(NSTimer *)timer;
+- (void)pause;
+- (void)resume;
+- (void)releaseResources;
@property(assign) int is_connected;
@end
/* Pointer Flags */
-#define PTR_FLAGS_WHEEL 0x0200
-#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100
-#define PTR_FLAGS_MOVE 0x0800
-#define PTR_FLAGS_DOWN 0x8000
-#define PTR_FLAGS_BUTTON1 0x1000
-#define PTR_FLAGS_BUTTON2 0x2000
-#define PTR_FLAGS_BUTTON3 0x4000
-#define WheelRotationMask 0x01FF
+#define PTR_FLAGS_WHEEL 0x0200
+#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100
+#define PTR_FLAGS_MOVE 0x0800
+#define PTR_FLAGS_DOWN 0x8000
+#define PTR_FLAGS_BUTTON1 0x1000
+#define PTR_FLAGS_BUTTON2 0x2000
+#define PTR_FLAGS_BUTTON3 0x4000
+#define WheelRotationMask 0x01FF
-BOOL mac_pre_connect(freerdp* instance);
-BOOL mac_post_connect(freerdp* instance);
-void mac_post_disconnect(freerdp* instance);
-BOOL mac_authenticate(freerdp* instance, char** username, char** password,
- char** domain);
-BOOL mac_gw_authenticate(freerdp* instance, char** username, char** password,
- char** domain);
+BOOL mac_pre_connect(freerdp *instance);
+BOOL mac_post_connect(freerdp *instance);
+void mac_post_disconnect(freerdp *instance);
+BOOL mac_authenticate(freerdp *instance, char **username, char **password, char **domain);
+BOOL mac_gw_authenticate(freerdp *instance, char **username, char **password, char **domain);
-DWORD mac_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
- const char* common_name, const char* subject,
- const char* issuer, const char* fingerprint,
- DWORD flags);
-DWORD mac_verify_changed_certificate_ex(freerdp* instance, const char* host,
- UINT16 port, const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint,
- const char* old_subject,
- const char* old_issuer,
- const char* old_fingerprint,
- DWORD flags);
+DWORD mac_verify_certificate_ex(freerdp *instance, const char *host, UINT16 port,
+ const char *common_name, const char *subject, const char *issuer,
+ const char *fingerprint, DWORD flags);
+DWORD mac_verify_changed_certificate_ex(freerdp *instance, const char *host, UINT16 port,
+ const char *common_name, const char *subject,
+ const char *issuer, const char *fingerprint,
+ const char *old_subject, const char *old_issuer,
+ const char *old_fingerprint, DWORD flags);
-int mac_logon_error_info(freerdp* instance, UINT32 data, UINT32 type);
+int mac_logon_error_info(freerdp *instance, UINT32 data, UINT32 type);
#endif /* FREERDP_CLIENT_MAC_MRDPVIEW_H */
diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m
index bdc3c32cd..dc07cdc01 100644
--- a/client/Mac/MRDPView.m
+++ b/client/Mac/MRDPView.m
@@ -49,44 +49,44 @@
#define TAG CLIENT_TAG("mac")
-static BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer);
-static void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer);
-static BOOL mf_Pointer_Set(rdpContext* context, const rdpPointer* pointer);
-static BOOL mf_Pointer_SetNull(rdpContext* context);
-static BOOL mf_Pointer_SetDefault(rdpContext* context);
-static BOOL mf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y);
+static BOOL mf_Pointer_New(rdpContext *context, rdpPointer *pointer);
+static void mf_Pointer_Free(rdpContext *context, rdpPointer *pointer);
+static BOOL mf_Pointer_Set(rdpContext *context, const rdpPointer *pointer);
+static BOOL mf_Pointer_SetNull(rdpContext *context);
+static BOOL mf_Pointer_SetDefault(rdpContext *context);
+static BOOL mf_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y);
-static BOOL mac_begin_paint(rdpContext* context);
-static BOOL mac_end_paint(rdpContext* context);
-static BOOL mac_desktop_resize(rdpContext* context);
+static BOOL mac_begin_paint(rdpContext *context);
+static BOOL mac_end_paint(rdpContext *context);
+static BOOL mac_desktop_resize(rdpContext *context);
-static void input_activity_cb(freerdp* instance);
+static void input_activity_cb(freerdp *instance);
-static DWORD WINAPI mac_client_thread(void* param);
+static DWORD WINAPI mac_client_thread(void *param);
@implementation MRDPView
@synthesize is_connected;
-- (int) rdpStart:(rdpContext*) rdp_context
+- (int)rdpStart:(rdpContext *)rdp_context
{
- rdpSettings* settings;
+ rdpSettings *settings;
EmbedWindowEventArgs e;
[self initializeView];
context = rdp_context;
- mfc = (mfContext*) rdp_context;
+ mfc = (mfContext *)rdp_context;
instance = context->instance;
settings = context->settings;
EventArgsInit(&e, "mfreerdp");
e.embed = TRUE;
- e.handle = (void*) self;
+ e.handle = (void *)self;
PubSub_OnEmbedWindow(context->pubSub, context, &e);
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
NSRect screenFrame = [screen frame];
if (instance->settings->Fullscreen)
{
- instance->settings->DesktopWidth = screenFrame.size.width;
+ instance->settings->DesktopWidth = screenFrame.size.width;
instance->settings->DesktopHeight = screenFrame.size.height;
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
}
@@ -98,8 +98,8 @@ static DWORD WINAPI mac_client_thread(void* param);
mfc->client_height = instance->settings->DesktopHeight;
mfc->client_width = instance->settings->DesktopWidth;
- if (!(mfc->thread = CreateThread(NULL, 0, mac_client_thread, (void*) context, 0,
- &mfc->mainThreadId)))
+ if (!(mfc->thread =
+ CreateThread(NULL, 0, mac_client_thread, (void *)context, 0, &mfc->mainThreadId)))
{
WLog_ERR(TAG, "failed to create client thread");
return -1;
@@ -112,18 +112,17 @@ static DWORD WINAPI mac_client_input_thread(LPVOID param)
{
int status;
wMessage message;
- wMessageQueue* queue;
- rdpContext* context = (rdpContext*) param;
+ wMessageQueue *queue;
+ rdpContext *context = (rdpContext *)param;
status = 1;
- queue = freerdp_get_message_queue(context->instance,
- FREERDP_INPUT_MESSAGE_QUEUE);
+ queue = freerdp_get_message_queue(context->instance, FREERDP_INPUT_MESSAGE_QUEUE);
while (MessageQueue_Wait(queue))
{
while (MessageQueue_Peek(queue, &message, TRUE))
{
status = freerdp_message_queue_process_message(context->instance,
- FREERDP_INPUT_MESSAGE_QUEUE, &message);
+ FREERDP_INPUT_MESSAGE_QUEUE, &message);
if (!status)
break;
@@ -137,7 +136,7 @@ static DWORD WINAPI mac_client_input_thread(LPVOID param)
return 0;
}
-DWORD WINAPI mac_client_thread(void* param)
+DWORD WINAPI mac_client_thread(void *param)
{
@autoreleasepool
{
@@ -149,11 +148,11 @@ DWORD WINAPI mac_client_thread(void* param)
DWORD nCount;
DWORD nCountTmp;
DWORD nCountBase;
- rdpContext* context = (rdpContext*) param;
- mfContext* mfc = (mfContext*) context;
- freerdp* instance = context->instance;
- MRDPView* view = mfc->view;
- rdpSettings* settings = context->settings;
+ rdpContext *context = (rdpContext *)param;
+ mfContext *mfc = (mfContext *)context;
+ freerdp *instance = context->instance;
+ MRDPView *view = mfc->view;
+ rdpSettings *settings = context->settings;
status = freerdp_connect(context->instance);
if (!status)
@@ -170,14 +169,14 @@ DWORD WINAPI mac_client_thread(void* param)
{
if (!(inputThread = CreateThread(NULL, 0, mac_client_input_thread, context, 0, NULL)))
{
- WLog_ERR(TAG, "failed to create async input thread");
+ WLog_ERR(TAG, "failed to create async input thread");
goto disconnect;
}
}
else
{
if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
- FREERDP_INPUT_MESSAGE_QUEUE)))
+ FREERDP_INPUT_MESSAGE_QUEUE)))
{
WLog_ERR(TAG, "failed to get input event handle");
goto disconnect;
@@ -192,8 +191,7 @@ DWORD WINAPI mac_client_thread(void* param)
{
nCount = nCountBase;
{
- if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount],
- 16 - nCount)))
+ if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount], 16 - nCount)))
{
WLog_ERR(TAG, "freerdp_get_event_handles failed");
break;
@@ -238,8 +236,8 @@ DWORD WINAPI mac_client_thread(void* param)
if (settings->AsyncInput && inputThread)
{
- wMessageQueue* inputQueue = freerdp_get_message_queue(instance,
- FREERDP_INPUT_MESSAGE_QUEUE);
+ wMessageQueue *inputQueue =
+ freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
if (inputQueue)
{
@@ -267,21 +265,24 @@ DWORD WINAPI mac_client_thread(void* param)
return self;
}
-- (void) viewDidLoad
+- (void)viewDidLoad
{
[self initializeView];
}
-- (void) initializeView
+- (void)initializeView
{
if (!initialized)
{
cursors = [[NSMutableArray alloc] initWithCapacity:10];
// setup a mouse tracking area
- NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:[self
- visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
- NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
- NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
+ initWithRect:[self visibleRect]
+ options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
+ NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
+ NSTrackingActiveWhenFirstResponder
+ owner:self
+ userInfo:nil];
[self addTrackingArea:trackingArea];
// Set the default cursor
currentCursor = [NSCursor arrowCursor];
@@ -289,16 +290,15 @@ DWORD WINAPI mac_client_thread(void* param)
}
}
-- (void) setCursor: (NSCursor*) cursor
+- (void)setCursor:(NSCursor *)cursor
{
self->currentCursor = cursor;
- dispatch_async(dispatch_get_main_queue(), ^
- {
+ dispatch_async(dispatch_get_main_queue(), ^{
[[self window] invalidateCursorRectsForView:self];
});
}
-- (void) resetCursorRects
+- (void)resetCursorRects
{
[self addCursorRect:[self visibleRect] cursor:currentCursor];
}
@@ -308,7 +308,7 @@ DWORD WINAPI mac_client_thread(void* param)
return YES;
}
-- (void) mouseMoved:(NSEvent*)event
+- (void)mouseMoved:(NSEvent *)event
{
[super mouseMoved:event];
@@ -316,12 +316,12 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
mf_scale_mouse_event(context, instance->input, PTR_FLAGS_MOVE, x, y);
}
-- (void)mouseDown:(NSEvent*) event
+- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event];
@@ -329,12 +329,12 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
mf_press_mouse_button(context, instance->input, 0, x, y, TRUE);
}
-- (void) mouseUp:(NSEvent*) event
+- (void)mouseUp:(NSEvent *)event
{
[super mouseUp:event];
@@ -342,12 +342,12 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
mf_press_mouse_button(context, instance->input, 0, x, y, FALSE);
}
-- (void) rightMouseDown:(NSEvent*)event
+- (void)rightMouseDown:(NSEvent *)event
{
[super rightMouseDown:event];
@@ -355,12 +355,12 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
mf_press_mouse_button(context, instance->input, 1, x, y, TRUE);
}
-- (void) rightMouseUp:(NSEvent*)event
+- (void)rightMouseUp:(NSEvent *)event
{
[super rightMouseUp:event];
@@ -368,12 +368,12 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
mf_press_mouse_button(context, instance->input, 1, x, y, FALSE);
}
-- (void) otherMouseDown:(NSEvent*)event
+- (void)otherMouseDown:(NSEvent *)event
{
[super otherMouseDown:event];
@@ -381,13 +381,13 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
int pressed = [event buttonNumber];
mf_press_mouse_button(context, instance->input, pressed, x, y, TRUE);
}
-- (void) otherMouseUp:(NSEvent*)event
+- (void)otherMouseUp:(NSEvent *)event
{
[super otherMouseUp:event];
@@ -395,13 +395,13 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
int pressed = [event buttonNumber];
mf_press_mouse_button(context, instance->input, pressed, x, y, FALSE);
}
-- (void) scrollWheel:(NSEvent*)event
+- (void)scrollWheel:(NSEvent *)event
{
UINT16 flags;
[super scrollWheel:event];
@@ -441,13 +441,12 @@ DWORD WINAPI mac_client_thread(void* param)
{
/* limit to maximum value in WheelRotationMask (9bit signed value) */
const UINT16 step = units & WheelRotationMask;
- mf_scale_mouse_event(context, instance->input,
- flags | step, 0, 0);
+ mf_scale_mouse_event(context, instance->input, flags | step, 0, 0);
units -= step;
}
}
-- (void) mouseDragged:(NSEvent*)event
+- (void)mouseDragged:(NSEvent *)event
{
[super mouseDragged:event];
@@ -455,8 +454,8 @@ DWORD WINAPI mac_client_thread(void* param)
return;
NSPoint loc = [event locationInWindow];
- int x = (int) loc.x;
- int y = (int) loc.y;
+ int x = (int)loc.x;
+ int y = (int)loc.y;
// send mouse motion event to RDP server
mf_scale_mouse_event(context, instance->input, PTR_FLAGS_MOVE, x, y);
}
@@ -517,14 +516,14 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
return keyCode;
}
-- (void) keyDown:(NSEvent*) event
+- (void)keyDown:(NSEvent *)event
{
DWORD keyCode;
DWORD keyFlags;
DWORD vkcode;
DWORD scancode;
unichar keyChar;
- NSString* characters;
+ NSString *characters;
if (!is_connected)
return;
@@ -553,14 +552,14 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
freerdp_input_send_keyboard_event(instance->input, keyFlags, scancode);
}
-- (void) keyUp:(NSEvent*) event
+- (void)keyUp:(NSEvent *)event
{
DWORD keyCode;
DWORD keyFlags;
DWORD vkcode;
DWORD scancode;
unichar keyChar;
- NSString* characters;
+ NSString *characters;
if (!is_connected)
return;
@@ -588,7 +587,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
freerdp_input_send_keyboard_event(instance->input, keyFlags, scancode);
}
-- (void) flagsChanged:(NSEvent*) event
+- (void)flagsChanged:(NSEvent *)event
{
int key;
DWORD keyFlags;
@@ -636,60 +635,44 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
#endif
if ((modFlags & NSAlphaShiftKeyMask) && !(kbdModFlags & NSAlphaShiftKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
- else if (!(modFlags & NSAlphaShiftKeyMask)
- && (kbdModFlags & NSAlphaShiftKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
+ else if (!(modFlags & NSAlphaShiftKeyMask) && (kbdModFlags & NSAlphaShiftKeyMask))
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSShiftKeyMask) && !(kbdModFlags & NSShiftKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
else if (!(modFlags & NSShiftKeyMask) && (kbdModFlags & NSShiftKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSControlKeyMask) && !(kbdModFlags & NSControlKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
else if (!(modFlags & NSControlKeyMask) && (kbdModFlags & NSControlKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSAlternateKeyMask) && !(kbdModFlags & NSAlternateKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
else if (!(modFlags & NSAlternateKeyMask) && (kbdModFlags & NSAlternateKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSCommandKeyMask) && !(kbdModFlags & NSCommandKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
else if (!(modFlags & NSCommandKeyMask) && (kbdModFlags & NSCommandKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSNumericPadKeyMask) && !(kbdModFlags & NSNumericPadKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
- else if (!(modFlags & NSNumericPadKeyMask)
- && (kbdModFlags & NSNumericPadKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
+ else if (!(modFlags & NSNumericPadKeyMask) && (kbdModFlags & NSNumericPadKeyMask))
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
if ((modFlags & NSHelpKeyMask) && !(kbdModFlags & NSHelpKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_DOWN, scancode);
else if (!(modFlags & NSHelpKeyMask) && (kbdModFlags & NSHelpKeyMask))
- freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE,
- scancode);
+ freerdp_input_send_keyboard_event(instance->input, keyFlags | KBD_FLAGS_RELEASE, scancode);
kbdModFlags = modFlags;
}
-- (void) releaseResources
+- (void)releaseResources
{
int i;
@@ -702,7 +685,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
free(pixel_data);
}
-- (void) drawRect:(NSRect)rect
+- (void)drawRect:(NSRect)rect
{
if (!context)
return;
@@ -712,10 +695,11 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
CGImageRef cgImage = CGBitmapContextCreateImage(self->bitmap_context);
CGContextSaveGState(cgContext);
- CGContextClipToRect(cgContext, CGRectMake(rect.origin.x, rect.origin.y,
- rect.size.width, rect.size.height));
- CGContextDrawImage(cgContext, CGRectMake(0,
- 0, [self bounds].size.width, [self bounds].size.height), cgImage);
+ CGContextClipToRect(
+ cgContext, CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
+ CGContextDrawImage(cgContext,
+ CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height),
+ cgImage);
CGContextRestoreGState(cgContext);
CGImageRelease(cgImage);
}
@@ -727,23 +711,23 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
}
}
-- (void) onPasteboardTimerFired :(NSTimer*) timer
+- (void)onPasteboardTimerFired:(NSTimer *)timer
{
- const BYTE* data;
+ const BYTE *data;
UINT32 size;
UINT32 formatId;
BOOL formatMatch;
int changeCount;
- NSData* formatData;
- const char* formatType;
- NSPasteboardItem* item;
- changeCount = (int) [pasteboard_rd changeCount];
+ NSData *formatData;
+ const char *formatType;
+ NSPasteboardItem *item;
+ changeCount = (int)[pasteboard_rd changeCount];
if (changeCount == pasteboard_changecount)
return;
pasteboard_changecount = changeCount;
- NSArray* items = [pasteboard_rd pasteboardItems];
+ NSArray *items = [pasteboard_rd pasteboardItems];
if ([items count] < 1)
return;
@@ -755,7 +739,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
*/
formatMatch = FALSE;
- for (NSString * type in [item types])
+ for (NSString *type in [item types])
{
formatType = [type UTF8String];
@@ -763,7 +747,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
{
formatData = [item dataForType:type];
formatId = ClipboardRegisterFormat(mfc->clipboard, "UTF8_STRING");
- size = (UINT32) [formatData length];
+ size = (UINT32)[formatData length];
data = [formatData bytes];
/* size is the string length without the terminating NULL terminator */
ClipboardSetData(mfc->clipboard, formatId, data, size + 1);
@@ -779,15 +763,14 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
mac_cliprdr_send_client_format_list(mfc->cliprdr);
}
-- (void) pause
+- (void)pause
{
- dispatch_async(dispatch_get_main_queue(), ^
- {
+ dispatch_async(dispatch_get_main_queue(), ^{
[self->pasteboard_timer invalidate];
});
- NSArray* trackingAreas = self.trackingAreas;
+ NSArray *trackingAreas = self.trackingAreas;
- for (NSTrackingArea * ta in trackingAreas)
+ for (NSTrackingArea *ta in trackingAreas)
{
[self removeTrackingArea:ta];
}
@@ -798,20 +781,27 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
if (!self.is_connected)
return;
- dispatch_async(dispatch_get_main_queue(), ^
- {
- self->pasteboard_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onPasteboardTimerFired:) userInfo:nil repeats:YES];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ self->pasteboard_timer =
+ [NSTimer scheduledTimerWithTimeInterval:0.5
+ target:self
+ selector:@selector(onPasteboardTimerFired:)
+ userInfo:nil
+ repeats:YES];
- NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:[self
- visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
- NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
- NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
+ initWithRect:[self visibleRect]
+ options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
+ NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag |
+ NSTrackingActiveWhenFirstResponder
+ owner:self
+ userInfo:nil];
[self addTrackingArea:trackingArea];
[trackingArea release];
});
}
-- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height
+- (void)setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height
{
mfc->yCurrentScroll = yOffset;
mfc->xCurrentScroll = xOffset;
@@ -819,11 +809,10 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
mfc->client_width = width;
}
-void mac_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e)
+void mac_OnChannelConnectedEventHandler(void *context, ChannelConnectedEventArgs *e)
{
- mfContext* mfc = (mfContext*) context;
- rdpSettings* settings = mfc->context.settings;
+ mfContext *mfc = (mfContext *)context;
+ rdpSettings *settings = mfc->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
@@ -831,22 +820,21 @@ void mac_OnChannelConnectedEventHandler(void* context,
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
- gdi_graphics_pipeline_init(mfc->context.gdi, (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(mfc->context.gdi, (RdpgfxClientContext *)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- mac_cliprdr_init(mfc, (CliprdrClientContext*) e->pInterface);
+ mac_cliprdr_init(mfc, (CliprdrClientContext *)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
}
}
-void mac_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e)
+void mac_OnChannelDisconnectedEventHandler(void *context, ChannelDisconnectedEventArgs *e)
{
- mfContext* mfc = (mfContext*) context;
- rdpSettings* settings = mfc->context.settings;
+ mfContext *mfc = (mfContext *)context;
+ rdpSettings *settings = mfc->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
@@ -854,21 +842,20 @@ void mac_OnChannelDisconnectedEventHandler(void* context,
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
- gdi_graphics_pipeline_uninit(mfc->context.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(mfc->context.gdi, (RdpgfxClientContext *)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- mac_cliprdr_uninit(mfc, (CliprdrClientContext*) e->pInterface);
+ mac_cliprdr_uninit(mfc, (CliprdrClientContext *)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
}
}
-BOOL mac_pre_connect(freerdp* instance)
+BOOL mac_pre_connect(freerdp *instance)
{
- rdpSettings* settings;
+ rdpSettings *settings;
instance->update->BeginPaint = mac_begin_paint;
instance->update->EndPaint = mac_end_paint;
instance->update->DesktopResize = mac_desktop_resize;
@@ -876,33 +863,30 @@ BOOL mac_pre_connect(freerdp* instance)
if (!settings->ServerHostname)
{
- WLog_ERR(TAG,
- "error: server hostname was not specified with /v:[:port]");
+ WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]");
[NSApp terminate:nil];
return -1;
}
settings->OsMajorType = OSMAJORTYPE_MACINTOSH;
settings->OsMinorType = OSMINORTYPE_MACINTOSH;
- PubSub_SubscribeChannelConnected(instance->context->pubSub,
- mac_OnChannelConnectedEventHandler);
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
mac_OnChannelDisconnectedEventHandler);
- if (!freerdp_client_load_addins(instance->context->channels,
- instance->settings))
+ if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
return FALSE;
return TRUE;
}
-BOOL mac_post_connect(freerdp* instance)
+BOOL mac_post_connect(freerdp *instance)
{
- rdpGdi* gdi;
- rdpSettings* settings;
+ rdpGdi *gdi;
+ rdpSettings *settings;
rdpPointer rdp_pointer;
- mfContext* mfc = (mfContext*) instance->context;
- MRDPView* view = (MRDPView*) mfc->view;
+ mfContext *mfc = (mfContext *)instance->context;
+ MRDPView *view = (MRDPView *)mfc->view;
ZeroMemory(&rdp_pointer, sizeof(rdpPointer));
rdp_pointer.size = sizeof(rdpPointer);
rdp_pointer.New = mf_Pointer_New;
@@ -922,8 +906,7 @@ BOOL mac_post_connect(freerdp* instance)
/* setup pasteboard (aka clipboard) for copy operations (write only) */
view->pasteboard_wr = [NSPasteboard generalPasteboard];
/* setup pasteboard for read operations */
- dispatch_async(dispatch_get_main_queue(), ^
- {
+ dispatch_async(dispatch_get_main_queue(), ^{
view->pasteboard_rd = [NSPasteboard generalPasteboard];
view->pasteboard_changecount = -1;
});
@@ -932,56 +915,53 @@ BOOL mac_post_connect(freerdp* instance)
return TRUE;
}
-void mac_post_disconnect(freerdp* instance)
+void mac_post_disconnect(freerdp *instance)
{
- mfContext* mfc;
- MRDPView* view;
+ mfContext *mfc;
+ MRDPView *view;
if (!instance || !instance->context)
return;
- mfc = (mfContext*) instance->context;
- view = (MRDPView*) mfc->view;
+ mfc = (mfContext *)instance->context;
+ view = (MRDPView *)mfc->view;
[view pause];
- PubSub_UnsubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler);
+ PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
+ mac_OnChannelConnectedEventHandler);
PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
mac_OnChannelDisconnectedEventHandler);
gdi_free(instance);
}
-static BOOL mac_authenticate_int(NSString* title, freerdp* instance, char** username,
- char** password,
- char** domain)
+static BOOL mac_authenticate_int(NSString *title, freerdp *instance, char **username,
+ char **password, char **domain)
{
- mfContext* mfc = (mfContext*) instance->context;
- MRDPView* view = (MRDPView*) mfc->view;
- PasswordDialog* dialog = [PasswordDialog new];
+ mfContext *mfc = (mfContext *)instance->context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ PasswordDialog *dialog = [PasswordDialog new];
dialog.serverHostname = title;
if (*username)
- dialog.username = [NSString stringWithCString:*username encoding:
- NSUTF8StringEncoding];
+ dialog.username = [NSString stringWithCString:*username encoding:NSUTF8StringEncoding];
if (*password)
- dialog.password = [NSString stringWithCString:*password encoding:
- NSUTF8StringEncoding];
+ dialog.password = [NSString stringWithCString:*password encoding:NSUTF8StringEncoding];
if (*domain)
- dialog.domain = [NSString stringWithCString:*domain encoding:
- NSUTF8StringEncoding];
+ dialog.domain = [NSString stringWithCString:*domain encoding:NSUTF8StringEncoding];
- dispatch_sync(dispatch_get_main_queue(), ^
- {
- [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view window] waitUntilDone:TRUE];
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [dialog performSelectorOnMainThread:@selector(runModal:)
+ withObject:[view window]
+ waitUntilDone:TRUE];
});
BOOL ok = dialog.modalCode;
if (ok)
{
size_t ulen, plen, dlen;
- const char* submittedUsername = [dialog.username cStringUsingEncoding:
- NSUTF8StringEncoding];
+ const char *submittedUsername = [dialog.username cStringUsingEncoding:NSUTF8StringEncoding];
ulen = (strlen(submittedUsername) + 1) * sizeof(char);
*username = malloc(ulen);
@@ -989,8 +969,7 @@ static BOOL mac_authenticate_int(NSString* title, freerdp* instance, char** user
return FALSE;
sprintf_s(*username, ulen, "%s", submittedUsername);
- const char* submittedPassword = [dialog.password cStringUsingEncoding:
- NSUTF8StringEncoding];
+ const char *submittedPassword = [dialog.password cStringUsingEncoding:NSUTF8StringEncoding];
plen = (strlen(submittedPassword) + 1) * sizeof(char);
*password = malloc(plen);
@@ -998,8 +977,7 @@ static BOOL mac_authenticate_int(NSString* title, freerdp* instance, char** user
return FALSE;
sprintf_s(*password, plen, "%s", submittedPassword);
- const char* submittedDomain = [dialog.domain cStringUsingEncoding:
- NSUTF8StringEncoding];
+ const char *submittedDomain = [dialog.domain cStringUsingEncoding:NSUTF8StringEncoding];
dlen = (strlen(submittedDomain) + 1) * sizeof(char);
*domain = malloc(dlen);
@@ -1012,35 +990,34 @@ static BOOL mac_authenticate_int(NSString* title, freerdp* instance, char** user
return ok;
}
-BOOL mac_authenticate(freerdp* instance, char** username, char** password,
- char** domain)
+BOOL mac_authenticate(freerdp *instance, char **username, char **password, char **domain)
{
- NSString* title = [NSString stringWithFormat:@"%@:%u",
- [NSString stringWithCString:instance->settings->ServerHostname encoding:
- NSUTF8StringEncoding],
- instance->settings->ServerPort];
+ NSString *title =
+ [NSString stringWithFormat:@"%@:%u",
+ [NSString stringWithCString:instance->settings->ServerHostname
+ encoding:NSUTF8StringEncoding],
+ instance -> settings -> ServerPort];
return mac_authenticate_int(title, instance, username, password, domain);
}
-BOOL mac_gw_authenticate(freerdp* instance, char** username, char** password,
- char** domain)
+BOOL mac_gw_authenticate(freerdp *instance, char **username, char **password, char **domain)
{
- NSString* title = [NSString stringWithFormat:@"%@:%u",
- [NSString stringWithCString:instance->settings->GatewayHostname encoding:
- NSUTF8StringEncoding],
- instance->settings->GatewayPort];
+ NSString *title =
+ [NSString stringWithFormat:@"%@:%u",
+ [NSString stringWithCString:instance->settings->GatewayHostname
+ encoding:NSUTF8StringEncoding],
+ instance -> settings -> GatewayPort];
return mac_authenticate_int(title, instance, username, password, domain);
}
-DWORD mac_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
- const char* common_name, const char* subject,
- const char* issuer, const char* fingerprint,
- DWORD flags)
+DWORD mac_verify_certificate_ex(freerdp *instance, const char *host, UINT16 port,
+ const char *common_name, const char *subject, const char *issuer,
+ const char *fingerprint, DWORD flags)
{
- mfContext* mfc = (mfContext*) instance->context;
- MRDPView* view = (MRDPView*) mfc->view;
- CertificateDialog* dialog = [CertificateDialog new];
- const char* type = "RDP-Server";
+ mfContext *mfc = (mfContext *)instance->context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ CertificateDialog *dialog = [CertificateDialog new];
+ const char *type = "RDP-Server";
char hostname[8192];
if (flags & VERIFY_CERT_FLAG_GATEWAY)
@@ -1049,16 +1026,12 @@ DWORD mac_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port
if (flags & VERIFY_CERT_FLAG_REDIRECT)
type = "RDP-Redirect";
- sprintf_s(hostname, sizeof(hostname), "%s %s:%"PRIu16, type, host, port);
+ sprintf_s(hostname, sizeof(hostname), "%s %s:%" PRIu16, type, host, port);
dialog.serverHostname = [NSString stringWithCString:hostname];
- dialog.commonName = [NSString stringWithCString:common_name encoding:
- NSUTF8StringEncoding];
- dialog.subject = [NSString stringWithCString:subject encoding:
- NSUTF8StringEncoding];
- dialog.issuer = [NSString stringWithCString:issuer encoding:
- NSUTF8StringEncoding];
- dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:
- NSUTF8StringEncoding];
+ dialog.commonName = [NSString stringWithCString:common_name encoding:NSUTF8StringEncoding];
+ dialog.subject = [NSString stringWithCString:subject encoding:NSUTF8StringEncoding];
+ dialog.issuer = [NSString stringWithCString:issuer encoding:NSUTF8StringEncoding];
+ dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:NSUTF8StringEncoding];
if (flags & VERIFY_CERT_FLAG_MISMATCH)
dialog.hostMismatch = TRUE;
@@ -1066,21 +1039,22 @@ DWORD mac_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port
if (flags & VERIFY_CERT_FLAG_CHANGED)
dialog.changed = TRUE;
- [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view
- window] waitUntilDone:TRUE];
+ [dialog performSelectorOnMainThread:@selector(runModal:)
+ withObject:[view window]
+ waitUntilDone:TRUE];
return dialog.result;
}
-DWORD mac_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port,
- const char* common_name, const char* subject,
- const char* issuer, const char* fingerprint,
- const char* old_subject, const char* old_issuer,
- const char* old_fingerprint, DWORD flags)
+DWORD mac_verify_changed_certificate_ex(freerdp *instance, const char *host, UINT16 port,
+ const char *common_name, const char *subject,
+ const char *issuer, const char *fingerprint,
+ const char *old_subject, const char *old_issuer,
+ const char *old_fingerprint, DWORD flags)
{
- mfContext* mfc = (mfContext*) instance->context;
- MRDPView* view = (MRDPView*) mfc->view;
- CertificateDialog* dialog = [CertificateDialog new];
- const char* type = "RDP-Server";
+ mfContext *mfc = (mfContext *)instance->context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ CertificateDialog *dialog = [CertificateDialog new];
+ const char *type = "RDP-Server";
char hostname[8192];
if (flags & VERIFY_CERT_FLAG_GATEWAY)
@@ -1089,16 +1063,12 @@ DWORD mac_verify_changed_certificate_ex(freerdp* instance, const char* host, UIN
if (flags & VERIFY_CERT_FLAG_REDIRECT)
type = "RDP-Redirect";
- sprintf_s(hostname, sizeof(hostname), "%s %s:%"PRIu16, type, host, port);
+ sprintf_s(hostname, sizeof(hostname), "%s %s:%" PRIu16, type, host, port);
dialog.serverHostname = [NSString stringWithCString:hostname];
- dialog.commonName = [NSString stringWithCString:common_name encoding:
- NSUTF8StringEncoding];
- dialog.subject = [NSString stringWithCString:subject encoding:
- NSUTF8StringEncoding];
- dialog.issuer = [NSString stringWithCString:issuer encoding:
- NSUTF8StringEncoding];
- dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:
- NSUTF8StringEncoding];
+ dialog.commonName = [NSString stringWithCString:common_name encoding:NSUTF8StringEncoding];
+ dialog.subject = [NSString stringWithCString:subject encoding:NSUTF8StringEncoding];
+ dialog.issuer = [NSString stringWithCString:issuer encoding:NSUTF8StringEncoding];
+ dialog.fingerprint = [NSString stringWithCString:fingerprint encoding:NSUTF8StringEncoding];
if (flags & VERIFY_CERT_FLAG_MISMATCH)
dialog.hostMismatch = TRUE;
@@ -1106,39 +1076,40 @@ DWORD mac_verify_changed_certificate_ex(freerdp* instance, const char* host, UIN
if (flags & VERIFY_CERT_FLAG_CHANGED)
dialog.changed = TRUE;
- [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view
- window] waitUntilDone:TRUE];
+ [dialog performSelectorOnMainThread:@selector(runModal:)
+ withObject:[view window]
+ waitUntilDone:TRUE];
return dialog.result;
}
-int mac_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
+int mac_logon_error_info(freerdp *instance, UINT32 data, UINT32 type)
{
- const char* str_data = freerdp_get_logon_error_info_data(data);
- const char* str_type = freerdp_get_logon_error_info_type(type);
+ const char *str_data = freerdp_get_logon_error_info_data(data);
+ const char *str_type = freerdp_get_logon_error_info_type(type);
// TODO: Error message dialog
WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
return 1;
}
-BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer)
+BOOL mf_Pointer_New(rdpContext *context, rdpPointer *pointer)
{
- rdpGdi* gdi;
+ rdpGdi *gdi;
NSRect rect;
- NSImage* image;
+ NSImage *image;
NSPoint hotSpot;
- NSCursor* cursor;
- BYTE* cursor_data;
- NSMutableArray* ma;
- NSBitmapImageRep* bmiRep;
- MRDPCursor* mrdpCursor = [[MRDPCursor alloc] init];
- mfContext* mfc = (mfContext*) context;
- MRDPView* view;
+ NSCursor *cursor;
+ BYTE *cursor_data;
+ NSMutableArray *ma;
+ NSBitmapImageRep *bmiRep;
+ MRDPCursor *mrdpCursor = [[MRDPCursor alloc] init];
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view;
UINT32 format;
if (!mfc || !context || !pointer)
return FALSE;
- view = (MRDPView*) mfc->view;
+ view = (MRDPView *)mfc->view;
gdi = context->gdi;
if (!gdi || !view)
@@ -1148,7 +1119,7 @@ BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer)
rect.size.height = pointer->height;
rect.origin.x = pointer->xPos;
rect.origin.y = pointer->yPos;
- cursor_data = (BYTE*) malloc(rect.size.width * rect.size.height * 4);
+ cursor_data = (BYTE *)malloc(rect.size.width * rect.size.height * 4);
if (!cursor_data)
return FALSE;
@@ -1156,12 +1127,10 @@ BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer)
mrdpCursor->cursor_data = cursor_data;
format = PIXEL_FORMAT_RGBA32;
- if (!freerdp_image_copy_from_pointer_data(
- cursor_data, format,
- 0, 0, 0, pointer->width, pointer->height,
- pointer->xorMaskData, pointer->lengthXorMask,
- pointer->andMaskData, pointer->lengthAndMask,
- pointer->xorBpp, NULL))
+ if (!freerdp_image_copy_from_pointer_data(cursor_data, format, 0, 0, 0, pointer->width,
+ pointer->height, pointer->xorMaskData,
+ pointer->lengthXorMask, pointer->andMaskData,
+ pointer->lengthAndMask, pointer->xorBpp, NULL))
{
free(cursor_data);
mrdpCursor->cursor_data = NULL;
@@ -1169,28 +1138,28 @@ BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer)
}
/* store cursor bitmap image in representation - required by NSImage */
- bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:
- (unsigned char**) &cursor_data
- pixelsWide:rect.size.width
- pixelsHigh:rect.size.height
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bitmapFormat:0
- bytesPerRow:rect.size.width * GetBytesPerPixel(format)
- bitsPerPixel:0];
+ bmiRep = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:(unsigned char **)&cursor_data
+ pixelsWide:rect.size.width
+ pixelsHigh:rect.size.height
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bitmapFormat:0
+ bytesPerRow:rect.size.width * GetBytesPerPixel(format)
+ bitsPerPixel:0];
mrdpCursor->bmiRep = bmiRep;
/* create an image using above representation */
image = [[NSImage alloc] initWithSize:[bmiRep size]];
- [image addRepresentation: bmiRep];
+ [image addRepresentation:bmiRep];
[image setFlipped:NO];
mrdpCursor->nsImage = image;
/* need hotspot to create cursor */
hotSpot.x = pointer->xPos;
hotSpot.y = pointer->yPos;
- cursor = [[NSCursor alloc] initWithImage: image hotSpot:hotSpot];
+ cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
mrdpCursor->nsCursor = cursor;
mrdpCursor->pointer = pointer;
/* save cursor for later use in mf_Pointer_Set() */
@@ -1199,13 +1168,13 @@ BOOL mf_Pointer_New(rdpContext* context, rdpPointer* pointer)
return TRUE;
}
-void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
+void mf_Pointer_Free(rdpContext *context, rdpPointer *pointer)
{
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
- NSMutableArray* ma = view->cursors;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ NSMutableArray *ma = view->cursors;
- for (MRDPCursor * cursor in ma)
+ for (MRDPCursor *cursor in ma)
{
if (cursor->pointer == pointer)
{
@@ -1219,13 +1188,13 @@ void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
}
}
-BOOL mf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
+BOOL mf_Pointer_Set(rdpContext *context, const rdpPointer *pointer)
{
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
- NSMutableArray* ma = view->cursors;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ NSMutableArray *ma = view->cursors;
- for (MRDPCursor * cursor in ma)
+ for (MRDPCursor *cursor in ma)
{
if (cursor->pointer == pointer)
{
@@ -1238,22 +1207,22 @@ BOOL mf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
return TRUE;
}
-BOOL mf_Pointer_SetNull(rdpContext* context)
+BOOL mf_Pointer_SetNull(rdpContext *context)
{
return TRUE;
}
-BOOL mf_Pointer_SetDefault(rdpContext* context)
+BOOL mf_Pointer_SetDefault(rdpContext *context)
{
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
[view setCursor:[NSCursor arrowCursor]];
return TRUE;
}
-static BOOL mf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
+static BOOL mf_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y)
{
- mfContext* mfc = (mfContext*) context;
+ mfContext *mfc = (mfContext *)context;
if (!mfc)
return FALSE;
@@ -1262,33 +1231,33 @@ static BOOL mf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
return TRUE;
}
-CGContextRef mac_create_bitmap_context(rdpContext* context)
+CGContextRef mac_create_bitmap_context(rdpContext *context)
{
CGContextRef bitmap_context;
- rdpGdi* gdi = context->gdi;
+ rdpGdi *gdi = context->gdi;
UINT32 bpp = GetBytesPerPixel(gdi->dstFormat);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (bpp == 2)
{
- bitmap_context = CGBitmapContextCreate(gdi->primary_buffer,
- gdi->width, gdi->height, 5, gdi->stride,
- colorSpace, kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
+ bitmap_context = CGBitmapContextCreate(
+ gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace,
+ kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
}
else
{
- bitmap_context = CGBitmapContextCreate(gdi->primary_buffer,
- gdi->width, gdi->height, 8, gdi->stride,
- colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
+ bitmap_context = CGBitmapContextCreate(
+ gdi->primary_buffer, gdi->width, gdi->height, 8, gdi->stride, colorSpace,
+ kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
}
CGColorSpaceRelease(colorSpace);
return bitmap_context;
}
-BOOL mac_begin_paint(rdpContext* context)
+BOOL mac_begin_paint(rdpContext *context)
{
- rdpGdi* gdi = context->gdi;
+ rdpGdi *gdi = context->gdi;
if (!gdi)
return FALSE;
@@ -1297,14 +1266,14 @@ BOOL mac_begin_paint(rdpContext* context)
return TRUE;
}
-BOOL mac_end_paint(rdpContext* context)
+BOOL mac_end_paint(rdpContext *context)
{
- rdpGdi* gdi;
+ rdpGdi *gdi;
HGDI_RGN invalid;
NSRect newDrawRect;
int ww, wh, dw, dh;
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
gdi = context->gdi;
if (!gdi)
@@ -1343,20 +1312,19 @@ BOOL mac_end_paint(rdpContext* context)
}
windows_to_apple_cords(mfc->view, &newDrawRect);
- dispatch_sync(dispatch_get_main_queue(), ^
- {
+ dispatch_sync(dispatch_get_main_queue(), ^{
[view setNeedsDisplayInRect:newDrawRect];
});
gdi->primary->hdc->hwnd->ninvalid = 0;
return TRUE;
}
-BOOL mac_desktop_resize(rdpContext* context)
+BOOL mac_desktop_resize(rdpContext *context)
{
ResizeWindowEventArgs e;
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
- rdpSettings* settings = context->settings;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
+ rdpSettings *settings = context->settings;
if (!context->gdi)
return TRUE;
@@ -1390,11 +1358,11 @@ BOOL mac_desktop_resize(rdpContext* context)
return TRUE;
}
-void input_activity_cb(freerdp* instance)
+void input_activity_cb(freerdp *instance)
{
int status;
wMessage message;
- wMessageQueue* queue;
+ wMessageQueue *queue;
status = 1;
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
@@ -1402,8 +1370,8 @@ void input_activity_cb(freerdp* instance)
{
while (MessageQueue_Peek(queue, &message, TRUE))
{
- status = freerdp_message_queue_process_message(instance,
- FREERDP_INPUT_MESSAGE_QUEUE, &message);
+ status = freerdp_message_queue_process_message(instance, FREERDP_INPUT_MESSAGE_QUEUE,
+ &message);
if (!status)
break;
@@ -1411,7 +1379,7 @@ void input_activity_cb(freerdp* instance)
}
else
{
- WLog_ERR(TAG, "input_activity_cb: No queue!");
+ WLog_ERR(TAG, "input_activity_cb: No queue!");
}
}
@@ -1423,17 +1391,16 @@ void input_activity_cb(freerdp* instance)
*
*/
-void windows_to_apple_cords(MRDPView* view, NSRect* r)
+void windows_to_apple_cords(MRDPView *view, NSRect *r)
{
- dispatch_sync(dispatch_get_main_queue(), ^
- {
+ dispatch_sync(dispatch_get_main_queue(), ^{
r->origin.y = [view frame].size.height - (r->origin.y + r->size.height);
});
}
-void sync_keyboard_state(freerdp* instance)
+void sync_keyboard_state(freerdp *instance)
{
- mfContext* context = (mfContext*)instance->context;
+ mfContext *context = (mfContext *)instance->context;
UINT32 flags = 0;
CGEventFlags currentFlags = CGEventSourceFlagsState(kCGEventSourceStateHIDSystemState);
diff --git a/client/Mac/PasswordDialog.h b/client/Mac/PasswordDialog.h
index 833336e2f..eb24c5c45 100644
--- a/client/Mac/PasswordDialog.h
+++ b/client/Mac/PasswordDialog.h
@@ -21,29 +21,29 @@
@interface PasswordDialog : NSWindowController
{
-@public
- NSTextField* usernameText;
- NSTextField* passwordText;
- NSTextField* messageLabel;
- NSString* serverHostname;
- NSString* username;
- NSString* password;
- NSString* domain;
+ @public
+ NSTextField *usernameText;
+ NSTextField *passwordText;
+ NSTextField *messageLabel;
+ NSString *serverHostname;
+ NSString *username;
+ NSString *password;
+ NSString *domain;
BOOL modalCode;
}
-@property(retain) IBOutlet NSTextField* usernameText;
-@property(retain) IBOutlet NSTextField* passwordText;
-@property(retain) IBOutlet NSTextField* messageLabel;
+@property(retain) IBOutlet NSTextField *usernameText;
+@property(retain) IBOutlet NSTextField *passwordText;
+@property(retain) IBOutlet NSTextField *messageLabel;
-- (IBAction)onOK:(NSObject*)sender;
-- (IBAction)onCancel:(NSObject*)sender;
+- (IBAction)onOK:(NSObject *)sender;
+- (IBAction)onCancel:(NSObject *)sender;
-@property(retain) NSString* serverHostname;
-@property(retain) NSString* username;
-@property(retain) NSString* password;
-@property(retain) NSString* domain;
+@property(retain) NSString *serverHostname;
+@property(retain) NSString *username;
+@property(retain) NSString *password;
+@property(retain) NSString *domain;
@property(readonly) BOOL modalCode;
-- (BOOL) runModal:(NSWindow*)mainWindow;
+- (BOOL)runModal:(NSWindow *)mainWindow;
@end
diff --git a/client/Mac/PasswordDialog.m b/client/Mac/PasswordDialog.m
index 2eecea4b2..f4c520bec 100644
--- a/client/Mac/PasswordDialog.m
+++ b/client/Mac/PasswordDialog.m
@@ -22,9 +22,9 @@
#import
-@interface PasswordDialog()
+@interface PasswordDialog ()
- @property BOOL modalCode;
+@property BOOL modalCode;
@end
@@ -47,15 +47,16 @@
- (void)windowDidLoad
{
[super windowDidLoad];
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+ // Implement this method to handle any initialization after your window controller's window has
+ // been loaded from its nib file.
[self.window setTitle:self.serverHostname];
- [self.messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@",
- self.serverHostname]];
- NSMutableString* domainUser = [[NSMutableString alloc] initWithString:@""];
+ [self.messageLabel
+ setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverHostname]];
+ NSMutableString *domainUser = [[NSMutableString alloc] initWithString:@""];
- if (self.domain != nil
- && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet
- whitespaceCharacterSet]] length] > 0)
+ if (self.domain != nil &&
+ [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ length] > 0)
{
[domainUser appendFormat:@"%@\\", self.domain];
}
@@ -69,18 +70,17 @@
[self.usernameText setStringValue:domainUser];
}
-- (IBAction)onOK:(NSObject*)sender
+- (IBAction)onOK:(NSObject *)sender
{
- char* submittedUser = NULL;
- char* submittedDomain = NULL;
+ char *submittedUser = NULL;
+ char *submittedDomain = NULL;
- if (freerdp_parse_username([self.usernameText.stringValue cStringUsingEncoding:
- NSUTF8StringEncoding], &submittedUser, &submittedDomain))
+ if (freerdp_parse_username(
+ [self.usernameText.stringValue cStringUsingEncoding:NSUTF8StringEncoding],
+ &submittedUser, &submittedDomain))
{
- self.username = [NSString stringWithCString: submittedUser encoding:
- NSUTF8StringEncoding];
- self.domain = [NSString stringWithCString: submittedDomain encoding:
- NSUTF8StringEncoding];
+ self.username = [NSString stringWithCString:submittedUser encoding:NSUTF8StringEncoding];
+ self.domain = [NSString stringWithCString:submittedDomain encoding:NSUTF8StringEncoding];
}
else
{
@@ -91,28 +91,28 @@
[NSApp stopModalWithCode:TRUE];
}
-- (IBAction)onCancel:(NSObject*)sender
+- (IBAction)onCancel:(NSObject *)sender
{
[NSApp stopModalWithCode:FALSE];
}
-- (BOOL)runModal:(NSWindow*)mainWindow
+- (BOOL)runModal:(NSWindow *)mainWindow
{
if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
{
[mainWindow beginSheet:self.window completionHandler:nil];
- self.modalCode = [NSApp runModalForWindow: self.window];
- [mainWindow endSheet: self.window];
+ self.modalCode = [NSApp runModalForWindow:self.window];
+ [mainWindow endSheet:self.window];
}
else
{
- [NSApp beginSheet: self.window
- modalForWindow: mainWindow
- modalDelegate: nil
- didEndSelector: nil
- contextInfo: nil];
- self.modalCode = [NSApp runModalForWindow: self.window];
- [NSApp endSheet: self.window];
+ [NSApp beginSheet:self.window
+ modalForWindow:mainWindow
+ modalDelegate:nil
+ didEndSelector:nil
+ contextInfo:nil];
+ self.modalCode = [NSApp runModalForWindow:self.window];
+ [NSApp endSheet:self.window];
}
[self.window orderOut:nil];
diff --git a/client/Mac/cli/AppDelegate.h b/client/Mac/cli/AppDelegate.h
index 91439c06f..64b261149 100644
--- a/client/Mac/cli/AppDelegate.h
+++ b/client/Mac/cli/AppDelegate.h
@@ -12,15 +12,15 @@
@interface AppDelegate : NSObject
{
-@public
- NSWindow* window;
- rdpContext* context;
- MRDPView* mrdpView;
+ @public
+ NSWindow *window;
+ rdpContext *context;
+ MRDPView *mrdpView;
}
-- (void) rdpConnectError: (NSString*) customMessage;
+- (void)rdpConnectError:(NSString *)customMessage;
-@property (assign) IBOutlet NSWindow *window;
-@property (assign) rdpContext *context;
+@property(assign) IBOutlet NSWindow *window;
+@property(assign) rdpContext *context;
@end
diff --git a/client/Mac/cli/AppDelegate.m b/client/Mac/cli/AppDelegate.m
index 646f7b56d..d916e710c 100644
--- a/client/Mac/cli/AppDelegate.m
+++ b/client/Mac/cli/AppDelegate.m
@@ -12,15 +12,12 @@
#import "MacFreeRDP/MRDPView.h"
#import
-static AppDelegate* _singleDelegate = nil;
-void AppDelegate_ConnectionResultEventHandler(void* context,
- ConnectionResultEventArgs* e);
-void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e);
-void AppDelegate_EmbedWindowEventHandler(void* context,
- EmbedWindowEventArgs* e);
-void AppDelegate_ResizeWindowEventHandler(void* context,
- ResizeWindowEventArgs* e);
-void mac_set_view_size(rdpContext* context, MRDPView* view);
+static AppDelegate *_singleDelegate = nil;
+void AppDelegate_ConnectionResultEventHandler(void *context, ConnectionResultEventArgs *e);
+void AppDelegate_ErrorInfoEventHandler(void *ctx, ErrorInfoEventArgs *e);
+void AppDelegate_EmbedWindowEventHandler(void *context, EmbedWindowEventArgs *e);
+void AppDelegate_ResizeWindowEventHandler(void *context, ResizeWindowEventArgs *e);
+void mac_set_view_size(rdpContext *context, MRDPView *view);
@implementation AppDelegate
@@ -31,68 +28,64 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
@synthesize window = window;
-
@synthesize context = context;
-- (void) applicationDidFinishLaunching:(NSNotification*)aNotification
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
int status;
- mfContext* mfc;
+ mfContext *mfc;
_singleDelegate = self;
[self CreateContext];
status = [self ParseCommandLineArguments];
- mfc = (mfContext*) context;
- mfc->view = (void*) mrdpView;
+ mfc = (mfContext *)context;
+ mfc->view = (void *)mrdpView;
if (status == 0)
{
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
NSRect screenFrame = [screen frame];
if (context->instance->settings->Fullscreen)
{
- context->instance->settings->DesktopWidth = screenFrame.size.width;
+ context->instance->settings->DesktopWidth = screenFrame.size.width;
context->instance->settings->DesktopHeight = screenFrame.size.height;
}
- PubSub_SubscribeConnectionResult(context->pubSub,
- AppDelegate_ConnectionResultEventHandler);
+ PubSub_SubscribeConnectionResult(context->pubSub, AppDelegate_ConnectionResultEventHandler);
PubSub_SubscribeErrorInfo(context->pubSub, AppDelegate_ErrorInfoEventHandler);
- PubSub_SubscribeEmbedWindow(context->pubSub,
- AppDelegate_EmbedWindowEventHandler);
- PubSub_SubscribeResizeWindow(context->pubSub,
- AppDelegate_ResizeWindowEventHandler);
+ PubSub_SubscribeEmbedWindow(context->pubSub, AppDelegate_EmbedWindowEventHandler);
+ PubSub_SubscribeResizeWindow(context->pubSub, AppDelegate_ResizeWindowEventHandler);
freerdp_client_start(context);
- NSString* winTitle;
+ NSString *winTitle;
if (mfc->context.settings->WindowTitle && mfc->context.settings->WindowTitle[0])
{
- winTitle = [[NSString alloc] initWithCString:
- mfc->context.settings->WindowTitle];
+ winTitle = [[NSString alloc] initWithCString:mfc->context.settings->WindowTitle];
}
else
{
- winTitle = [[NSString alloc] initWithFormat:@"%@:%u",
- [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:
- NSUTF8StringEncoding],
- mfc->context.settings->ServerPort];
+ winTitle = [[NSString alloc]
+ initWithFormat:@"%@:%u",
+ [NSString stringWithCString:mfc->context.settings->ServerHostname
+ encoding:NSUTF8StringEncoding],
+ mfc -> context.settings->ServerPort];
}
[window setTitle:winTitle];
}
}
-- (void) applicationWillBecomeActive:(NSNotification*)notification
+- (void)applicationWillBecomeActive:(NSNotification *)notification
{
[mrdpView resume];
}
-- (void) applicationWillResignActive:(NSNotification*)notification
+- (void)applicationWillResignActive:(NSNotification *)notification
{
[mrdpView pause];
}
-- (void) applicationWillTerminate:(NSNotification*)notification
+- (void)applicationWillTerminate:(NSNotification *)notification
{
NSLog(@"Stopping...\n");
freerdp_client_stop(context);
@@ -101,23 +94,23 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
NSLog(@"Stopped.\n");
}
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}
-- (int) ParseCommandLineArguments
+- (int)ParseCommandLineArguments
{
int i;
int length;
int status;
- char* cptr;
- NSArray* args = [[NSProcessInfo processInfo] arguments];
- context->argc = (int) [args count];
- context->argv = malloc(sizeof(char*) * context->argc);
+ char *cptr;
+ NSArray *args = [[NSProcessInfo processInfo] arguments];
+ context->argc = (int)[args count];
+ context->argv = malloc(sizeof(char *) * context->argc);
i = 0;
- for (NSString * str in args)
+ for (NSString *str in args)
{
/* filter out some arguments added by XCode */
if ([str isEqualToString:@"YES"])
@@ -127,20 +120,20 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
continue;
length = (int)([str length] + 1);
- cptr = (char*) malloc(length);
+ cptr = (char *)malloc(length);
sprintf_s(cptr, length, "%s", [str UTF8String]);
context->argv[i++] = cptr;
}
context->argc = i;
- status = freerdp_client_settings_parse_command_line(context->settings,
- context->argc, context->argv, FALSE);
- status = freerdp_client_settings_command_line_status_print(context->settings,
- status, context->argc, context->argv);
+ status = freerdp_client_settings_parse_command_line(context->settings, context->argc,
+ context->argv, FALSE);
+ status = freerdp_client_settings_command_line_status_print(context->settings, status,
+ context->argc, context->argv);
return status;
}
-- (void) CreateContext
+- (void)CreateContext
{
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
@@ -150,12 +143,12 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
context = freerdp_client_context_new(&clientEntryPoints);
}
-- (void) ReleaseContext
+- (void)ReleaseContext
{
- mfContext* mfc;
- MRDPView* view;
- mfc = (mfContext*) context;
- view = (MRDPView*) mfc->view;
+ mfContext *mfc;
+ MRDPView *view;
+ mfc = (mfContext *)context;
+ view = (MRDPView *)mfc->view;
[view exitFullScreenModeWithOptions:nil];
[view releaseResources];
[view release];
@@ -164,46 +157,42 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
context = nil;
}
-
/** *********************************************************************
* called when we fail to connect to a RDP server - Make sure this is called from the main thread.
***********************************************************************/
-- (void) rdpConnectError : (NSString*) withMessage
+- (void)rdpConnectError:(NSString *)withMessage
{
- mfContext* mfc;
- MRDPView* view;
- mfc = (mfContext*) context;
- view = (MRDPView*) mfc->view;
+ mfContext *mfc;
+ MRDPView *view;
+ mfc = (mfContext *)context;
+ view = (MRDPView *)mfc->view;
[view exitFullScreenModeWithOptions:nil];
- NSString* message = withMessage ? withMessage : @"Error connecting to server";
- NSAlert* alert = [[NSAlert alloc] init];
+ NSString *message = withMessage ? withMessage : @"Error connecting to server";
+ NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:message];
[alert beginSheetModalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
- contextInfo:nil];
+ modalDelegate:self
+ didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
+ contextInfo:nil];
}
-
/** *********************************************************************
* just a terminate selector for above call
***********************************************************************/
-- (void) alertDidEnd:(NSAlert*)a returnCode:(NSInteger)rc contextInfo:(void*)ci
+- (void)alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci
{
[NSApp terminate:nil];
}
-
@end
/** *********************************************************************
* On connection error, display message and quit application
***********************************************************************/
-void AppDelegate_ConnectionResultEventHandler(void* ctx,
- ConnectionResultEventArgs* e)
+void AppDelegate_ConnectionResultEventHandler(void *ctx, ConnectionResultEventArgs *e)
{
NSLog(@"ConnectionResult event result:%d\n", e->result);
@@ -211,50 +200,52 @@ void AppDelegate_ConnectionResultEventHandler(void* ctx,
{
if (e->result != 0)
{
- NSString* message = nil;
+ NSString *message = nil;
if (connectErrorCode == AUTHENTICATIONERROR)
{
- message = [NSString stringWithFormat:@"%@",
- @"Authentication failure, check credentials."];
+ message = [NSString
+ stringWithFormat:@"%@", @"Authentication failure, check credentials."];
}
// Making sure this should be invoked on the main UI thread.
[_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
- withObject:message waitUntilDone:FALSE];
+ withObject:message
+ waitUntilDone:FALSE];
}
}
}
-void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
+void AppDelegate_ErrorInfoEventHandler(void *ctx, ErrorInfoEventArgs *e)
{
NSLog(@"ErrorInfo event code:%d\n", e->code);
if (_singleDelegate)
{
// Retrieve error message associated with error code
- NSString* message = nil;
+ NSString *message = nil;
if (e->code != ERRINFO_NONE)
{
- const char* errorMessage = freerdp_get_error_info_string(e->code);
+ const char *errorMessage = freerdp_get_error_info_string(e->code);
message = [[NSString alloc] initWithUTF8String:errorMessage];
}
// Making sure this should be invoked on the main UI thread.
[_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
- withObject:message waitUntilDone:TRUE];
+ withObject:message
+ waitUntilDone:TRUE];
[message release];
}
}
-void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
+void AppDelegate_EmbedWindowEventHandler(void *ctx, EmbedWindowEventArgs *e)
{
- rdpContext* context = (rdpContext*) ctx;
+ rdpContext *context = (rdpContext *)ctx;
if (_singleDelegate)
{
- mfContext* mfc = (mfContext*) context;
+ mfContext *mfc = (mfContext *)context;
_singleDelegate->mrdpView = mfc->view;
if (_singleDelegate->window)
@@ -268,21 +259,21 @@ void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
}
}
-void AppDelegate_ResizeWindowEventHandler(void* ctx, ResizeWindowEventArgs* e)
+void AppDelegate_ResizeWindowEventHandler(void *ctx, ResizeWindowEventArgs *e)
{
- rdpContext* context = (rdpContext*) ctx;
+ rdpContext *context = (rdpContext *)ctx;
fprintf(stderr, "ResizeWindowEventHandler: %d %d\n", e->width, e->height);
if (_singleDelegate)
{
- mfContext* mfc = (mfContext*) context;
+ mfContext *mfc = (mfContext *)context;
dispatch_async(dispatch_get_main_queue(), ^{
mac_set_view_size(context, mfc->view);
});
}
}
-void mac_set_view_size(rdpContext* context, MRDPView* view)
+void mac_set_view_size(rdpContext *context, MRDPView *view)
{
// set client area to specified dimensions
NSRect innerRect;
diff --git a/client/Mac/mf_client.h b/client/Mac/mf_client.h
index 4d8b2fa53..c3b3c85fc 100644
--- a/client/Mac/mf_client.h
+++ b/client/Mac/mf_client.h
@@ -25,21 +25,22 @@
#include
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-FREERDP_API void mf_press_mouse_button(void* context, rdpInput* intput, int button, int x, int y,
- BOOL down);
-FREERDP_API void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x,
- UINT16 y);
-FREERDP_API void mf_scale_mouse_event_ex(void* context, rdpInput* input, UINT16 flags, UINT16 x,
- UINT16 y);
+ FREERDP_API void mf_press_mouse_button(void* context, rdpInput* intput, int button, int x,
+ int y, BOOL down);
+ FREERDP_API void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x,
+ UINT16 y);
+ FREERDP_API void mf_scale_mouse_event_ex(void* context, rdpInput* input, UINT16 flags, UINT16 x,
+ UINT16 y);
-/**
- * Client Interface
- */
+ /**
+ * Client Interface
+ */
-FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
+ FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
#ifdef __cplusplus
}
diff --git a/client/Mac/mf_client.m b/client/Mac/mf_client.m
index 54c646654..10fb1b40a 100644
--- a/client/Mac/mf_client.m
+++ b/client/Mac/mf_client.m
@@ -40,26 +40,27 @@ static void mfreerdp_client_global_uninit(void)
{
}
-static int mfreerdp_client_start(rdpContext* context)
+static int mfreerdp_client_start(rdpContext *context)
{
- MRDPView* view;
- mfContext* mfc = (mfContext*) context;
+ MRDPView *view;
+ mfContext *mfc = (mfContext *)context;
if (mfc->view == NULL)
{
// view not specified beforehand. Create view dynamically
- mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0,
- context->settings->DesktopWidth, context->settings->DesktopHeight)];
+ mfc->view =
+ [[MRDPView alloc] initWithFrame:NSMakeRect(0, 0, context->settings->DesktopWidth,
+ context->settings->DesktopHeight)];
mfc->view_ownership = TRUE;
}
- view = (MRDPView*) mfc->view;
+ view = (MRDPView *)mfc->view;
return [view rdpStart:context];
}
-static int mfreerdp_client_stop(rdpContext* context)
+static int mfreerdp_client_stop(rdpContext *context)
{
- mfContext* mfc = (mfContext*) context;
+ mfContext *mfc = (mfContext *)context;
if (mfc->thread)
{
@@ -71,7 +72,7 @@ static int mfreerdp_client_stop(rdpContext* context)
if (mfc->view_ownership)
{
- MRDPView* view = (MRDPView*) mfc->view;
+ MRDPView *view = (MRDPView *)mfc->view;
[view releaseResources];
[view release];
mfc->view = nil;
@@ -80,11 +81,11 @@ static int mfreerdp_client_stop(rdpContext* context)
return 0;
}
-static BOOL mfreerdp_client_new(freerdp* instance, rdpContext* context)
+static BOOL mfreerdp_client_new(freerdp *instance, rdpContext *context)
{
- mfContext* mfc;
- rdpSettings* settings;
- mfc = (mfContext*) instance->context;
+ mfContext *mfc;
+ rdpSettings *settings;
+ mfc = (mfContext *)instance->context;
mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
context->instance->PreConnect = mac_pre_connect;
context->instance->PostConnect = mac_post_connect;
@@ -101,18 +102,18 @@ static BOOL mfreerdp_client_new(freerdp* instance, rdpContext* context)
return TRUE;
}
-static void mfreerdp_client_free(freerdp* instance, rdpContext* context)
+static void mfreerdp_client_free(freerdp *instance, rdpContext *context)
{
- mfContext* mfc;
+ mfContext *mfc;
if (!instance || !context)
return;
- mfc = (mfContext*) instance->context;
+ mfc = (mfContext *)instance->context;
CloseHandle(mfc->stopEvent);
}
-static void mf_scale_mouse_coordinates(mfContext* mfc, UINT16* px, UINT16* py)
+static void mf_scale_mouse_coordinates(mfContext *mfc, UINT16 *px, UINT16 *py)
{
UINT16 x = *px;
UINT16 y = *py;
@@ -128,7 +129,6 @@ static void mf_scale_mouse_coordinates(mfContext* mfc, UINT16* px, UINT16* py)
y -= (dh - wh);
x -= (dw - ww);
-
}
else
{
@@ -140,11 +140,10 @@ static void mf_scale_mouse_coordinates(mfContext* mfc, UINT16* px, UINT16* py)
*py = y;
}
-void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags,
- UINT16 x, UINT16 y)
+void mf_scale_mouse_event(void *context, rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
{
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
// Convert to windows coordinates
y = [view frame].size.height - y;
@@ -153,11 +152,10 @@ void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags,
freerdp_input_send_mouse_event(input, flags, x, y);
}
-void mf_scale_mouse_event_ex(void* context, rdpInput* input, UINT16 flags,
- UINT16 x, UINT16 y)
+void mf_scale_mouse_event_ex(void *context, rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
{
- mfContext* mfc = (mfContext*) context;
- MRDPView* view = (MRDPView*) mfc->view;
+ mfContext *mfc = (mfContext *)context;
+ MRDPView *view = (MRDPView *)mfc->view;
// Convert to windows coordinates
y = [view frame].size.height - y;
@@ -165,7 +163,7 @@ void mf_scale_mouse_event_ex(void* context, rdpInput* input, UINT16 flags,
freerdp_input_send_extended_mouse_event(input, flags, x, y);
}
-void mf_press_mouse_button(void* context, rdpInput* input, int button, int x, int y, BOOL down)
+void mf_press_mouse_button(void *context, rdpInput *input, int button, int x, int y, BOOL down)
{
UINT16 flags = 0;
UINT16 xflags = 0;
@@ -179,28 +177,23 @@ void mf_press_mouse_button(void* context, rdpInput* input, int button, int x, in
switch (button)
{
case 0:
- mf_scale_mouse_event(context, input,
- flags | PTR_FLAGS_BUTTON1, x, y);
+ mf_scale_mouse_event(context, input, flags | PTR_FLAGS_BUTTON1, x, y);
break;
case 1:
- mf_scale_mouse_event(context, input,
- flags | PTR_FLAGS_BUTTON2, x, y);
+ mf_scale_mouse_event(context, input, flags | PTR_FLAGS_BUTTON2, x, y);
break;
case 2:
- mf_scale_mouse_event(context, input,
- flags | PTR_FLAGS_BUTTON3, x, y);
+ mf_scale_mouse_event(context, input, flags | PTR_FLAGS_BUTTON3, x, y);
break;
case 3:
- mf_scale_mouse_event_ex(context, input,
- xflags | PTR_XFLAGS_BUTTON1, x, y);
+ mf_scale_mouse_event_ex(context, input, xflags | PTR_XFLAGS_BUTTON1, x, y);
break;
case 4:
- mf_scale_mouse_event_ex(context, input,
- xflags | PTR_XFLAGS_BUTTON2, x, y);
+ mf_scale_mouse_event_ex(context, input, xflags | PTR_XFLAGS_BUTTON2, x, y);
break;
default:
@@ -208,7 +201,7 @@ void mf_press_mouse_button(void* context, rdpInput* input, int button, int x, in
}
}
-int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
+int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
{
pEntryPoints->Version = 1;
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
diff --git a/client/Mac/mfreerdp.h b/client/Mac/mfreerdp.h
index 75e5b7322..be39031a6 100644
--- a/client/Mac/mfreerdp.h
+++ b/client/Mac/mfreerdp.h
@@ -75,15 +75,15 @@ struct mf_context
// These variables are required for horizontal scrolling.
BOOL updating_scrollbars;
BOOL xScrollVisible;
- int xMinScroll; // minimum horizontal scroll value
- int xCurrentScroll; // current horizontal scroll value
- int xMaxScroll; // maximum horizontal scroll value
+ int xMinScroll; // minimum horizontal scroll value
+ int xCurrentScroll; // current horizontal scroll value
+ int xMaxScroll; // maximum horizontal scroll value
// These variables are required for vertical scrolling.
BOOL yScrollVisible;
- int yMinScroll; // minimum vertical scroll value
- int yCurrentScroll; // current vertical scroll value
- int yMaxScroll; // maximum vertical scroll value
+ int yMinScroll; // minimum vertical scroll value
+ int yCurrentScroll; // current vertical scroll value
+ int yMaxScroll; // maximum vertical scroll value
CGEventFlags kbdFlags;
};
diff --git a/client/Sample/tf_channels.c b/client/Sample/tf_channels.c
index 38bad83cc..51e55afeb 100644
--- a/client/Sample/tf_channels.c
+++ b/client/Sample/tf_channels.c
@@ -40,7 +40,7 @@
* @return 0 on success, otherwise a Win32 error code
*/
static UINT tf_encomsp_participant_created(EncomspClientContext* context,
- ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
+ ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
{
WINPR_UNUSED(context);
WINPR_UNUSED(participantCreated);
@@ -50,7 +50,7 @@ static UINT tf_encomsp_participant_created(EncomspClientContext* context,
static void tf_encomsp_init(tfContext* tf, EncomspClientContext* encomsp)
{
tf->encomsp = encomsp;
- encomsp->custom = (void*) tf;
+ encomsp->custom = (void*)tf;
encomsp->ParticipantCreated = tf_encomsp_participant_created;
}
@@ -66,22 +66,20 @@ static void tf_encomsp_uninit(tfContext* tf, EncomspClientContext* encomsp)
tf->encomsp = NULL;
}
-
-void tf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e)
+void tf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
{
- tfContext* tf = (tfContext*) context;
+ tfContext* tf = (tfContext*)context;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
- tf->rdpei = (RdpeiClientContext*) e->pInterface;
+ tf->rdpei = (RdpeiClientContext*)e->pInterface;
}
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
{
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- gdi_graphics_pipeline_init(tf->context.gdi, (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(tf->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
@@ -91,14 +89,13 @@ void tf_OnChannelConnectedEventHandler(void* context,
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- tf_encomsp_init(tf, (EncomspClientContext*) e->pInterface);
+ tf_encomsp_init(tf, (EncomspClientContext*)e->pInterface);
}
}
-void tf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e)
+void tf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e)
{
- tfContext* tf = (tfContext*) context;
+ tfContext* tf = (tfContext*)context;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
@@ -109,8 +106,7 @@ void tf_OnChannelDisconnectedEventHandler(void* context,
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- gdi_graphics_pipeline_uninit(tf->context.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(tf->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
@@ -120,6 +116,6 @@ void tf_OnChannelDisconnectedEventHandler(void* context,
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- tf_encomsp_uninit(tf, (EncomspClientContext*) e->pInterface);
+ tf_encomsp_uninit(tf, (EncomspClientContext*)e->pInterface);
}
}
diff --git a/client/Sample/tf_channels.h b/client/Sample/tf_channels.h
index 5cb3202bf..b1c0b8655 100644
--- a/client/Sample/tf_channels.h
+++ b/client/Sample/tf_channels.h
@@ -24,14 +24,10 @@
#include
#include
-int tf_on_channel_connected(freerdp* instance, const char* name,
- void* pInterface);
-int tf_on_channel_disconnected(freerdp* instance, const char* name,
- void* pInterface);
+int tf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
+int tf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
-void tf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e);
-void tf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e);
+void tf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e);
+void tf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e);
#endif /* FREERDP_CLIENT_SAMPLE_CHANNELS_H */
diff --git a/client/Sample/tf_freerdp.c b/client/Sample/tf_freerdp.c
index 41179ec44..325cc943c 100644
--- a/client/Sample/tf_freerdp.c
+++ b/client/Sample/tf_freerdp.c
@@ -71,8 +71,7 @@ static BOOL tf_end_paint(rdpContext* context)
}
/* This function is called to output a System BEEP */
-static BOOL tf_play_sound(rdpContext* context,
- const PLAY_SOUND_UPDATE* play_sound)
+static BOOL tf_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound)
{
/* TODO: Implement */
WINPR_UNUSED(context);
@@ -97,7 +96,8 @@ static BOOL tf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32
return FALSE;
WLog_WARN(TAG,
- "KeyboardSetImeStatus(unitId=%04"PRIx16", imeState=%08"PRIx32", imeConvMode=%08"PRIx32") ignored",
+ "KeyboardSetImeStatus(unitId=%04" PRIx16 ", imeState=%08" PRIx32
+ ", imeConvMode=%08" PRIx32 ") ignored",
imeId, imeState, imeConvMode);
return TRUE;
}
@@ -116,15 +116,13 @@ static BOOL tf_pre_connect(freerdp* instance)
* callbacks or deactiveate certain features. */
/* Register the channel listeners.
* They are required to set up / tear down channels if they are loaded. */
- PubSub_SubscribeChannelConnected(instance->context->pubSub,
- tf_OnChannelConnectedEventHandler);
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, tf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
tf_OnChannelDisconnectedEventHandler);
/* Load all required plugins / channels / libraries specified by current
* settings. */
- if (!freerdp_client_load_addins(instance->context->channels,
- instance->settings))
+ if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
return FALSE;
/* TODO: Any code your client requires */
@@ -165,7 +163,7 @@ static void tf_post_disconnect(freerdp* instance)
if (!instance->context)
return;
- context = (tfContext*) instance->context;
+ context = (tfContext*)instance->context;
PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
tf_OnChannelConnectedEventHandler);
PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
@@ -205,7 +203,7 @@ static DWORD WINAPI tf_client_thread_proc(LPVOID arg)
if (status == WAIT_FAILED)
{
- WLog_ERR(TAG, "%s: WaitForMultipleObjects failed with %"PRIu32"", __FUNCTION__,
+ WLog_ERR(TAG, "%s: WaitForMultipleObjects failed with %" PRIu32 "", __FUNCTION__,
status);
break;
}
@@ -248,7 +246,7 @@ static int tf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
if (!instance || !instance->context)
return -1;
- tf = (tfContext*) instance->context;
+ tf = (tfContext*)instance->context;
WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
WINPR_UNUSED(tf);
@@ -257,7 +255,7 @@ static int tf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
static BOOL tf_client_new(freerdp* instance, rdpContext* context)
{
- tfContext* tf = (tfContext*) context;
+ tfContext* tf = (tfContext*)context;
if (!instance || !context)
return FALSE;
@@ -275,10 +273,9 @@ static BOOL tf_client_new(freerdp* instance, rdpContext* context)
return TRUE;
}
-
static void tf_client_free(freerdp* instance, rdpContext* context)
{
- tfContext* tf = (tfContext*) instance->context;
+ tfContext* tf = (tfContext*)instance->context;
if (!context)
return;
@@ -328,10 +325,9 @@ int main(int argc, char* argv[])
if (!context)
goto fail;
- status = freerdp_client_settings_parse_command_line(context->settings, argc,
- argv, FALSE);
- status = freerdp_client_settings_command_line_status_print(context->settings,
- status, argc, argv);
+ status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
+ status =
+ freerdp_client_settings_command_line_status_print(context->settings, status, argc, argv);
if (status)
return 0;
diff --git a/client/Wayland/wlf_channels.c b/client/Wayland/wlf_channels.c
index babea04e6..743dd54af 100644
--- a/client/Wayland/wlf_channels.c
+++ b/client/Wayland/wlf_channels.c
@@ -34,7 +34,7 @@
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wlf_encomsp_participant_created(EncomspClientContext* context,
- ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
+ ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
{
return CHANNEL_RC_OK;
}
@@ -42,7 +42,7 @@ static UINT wlf_encomsp_participant_created(EncomspClientContext* context,
static void wlf_encomsp_init(wlfContext* wlf, EncomspClientContext* encomsp)
{
wlf->encomsp = encomsp;
- encomsp->custom = (void*) wlf;
+ encomsp->custom = (void*)wlf;
encomsp->ParticipantCreated = wlf_encomsp_participant_created;
}
@@ -58,22 +58,20 @@ static void wlf_encomsp_uninit(wlfContext* wlf, EncomspClientContext* encomsp)
wlf->encomsp = NULL;
}
-
-void wlf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e)
+void wlf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
{
- wlfContext* wlf = (wlfContext*) context;
+ wlfContext* wlf = (wlfContext*)context;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
- wlf->rdpei = (RdpeiClientContext*) e->pInterface;
+ wlf->rdpei = (RdpeiClientContext*)e->pInterface;
}
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
{
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- gdi_graphics_pipeline_init(wlf->context.gdi, (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(wlf->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
@@ -84,7 +82,7 @@ void wlf_OnChannelConnectedEventHandler(void* context,
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- wlf_encomsp_init(wlf, (EncomspClientContext*) e->pInterface);
+ wlf_encomsp_init(wlf, (EncomspClientContext*)e->pInterface);
}
else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
{
@@ -92,10 +90,9 @@ void wlf_OnChannelConnectedEventHandler(void* context,
}
}
-void wlf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e)
+void wlf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e)
{
- wlfContext* wlf = (wlfContext*) context;
+ wlfContext* wlf = (wlfContext*)context;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
@@ -106,8 +103,7 @@ void wlf_OnChannelDisconnectedEventHandler(void* context,
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- gdi_graphics_pipeline_uninit(wlf->context.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(wlf->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
@@ -118,7 +114,7 @@ void wlf_OnChannelDisconnectedEventHandler(void* context,
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- wlf_encomsp_uninit(wlf, (EncomspClientContext*) e->pInterface);
+ wlf_encomsp_uninit(wlf, (EncomspClientContext*)e->pInterface);
}
else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
{
diff --git a/client/Wayland/wlf_channels.h b/client/Wayland/wlf_channels.h
index 1b6c591fe..d4469cbfc 100644
--- a/client/Wayland/wlf_channels.h
+++ b/client/Wayland/wlf_channels.h
@@ -29,14 +29,10 @@
#include
#include
-int wlf_on_channel_connected(freerdp* instance, const char* name,
- void* pInterface);
-int wlf_on_channel_disconnected(freerdp* instance, const char* name,
- void* pInterface);
+int wlf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
+int wlf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
-void wlf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e);
-void wlf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e);
+void wlf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e);
+void wlf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e);
#endif /* FREERDP_CLIENT_WAYLAND_CHANNELS_H */
diff --git a/client/Wayland/wlf_cliprdr.c b/client/Wayland/wlf_cliprdr.c
index 44f3b4439..c88b32a22 100644
--- a/client/Wayland/wlf_cliprdr.c
+++ b/client/Wayland/wlf_cliprdr.c
@@ -38,39 +38,20 @@
#define TAG CLIENT_TAG("wayland.cliprdr")
-#define MAX_CLIPBOARD_FORMATS 255
+#define MAX_CLIPBOARD_FORMATS 255
-static const char* mime_text[] =
-{
- "text/plain",
- "text/plain;charset=utf-8",
- "UTF8_STRING",
- "COMPOUND_TEXT",
- "TEXT",
- "STRING"
-};
+static const char* mime_text[] = { "text/plain", "text/plain;charset=utf-8",
+ "UTF8_STRING", "COMPOUND_TEXT",
+ "TEXT", "STRING" };
-static const char* mime_image[] =
-{
- "image/png",
- "image/bmp",
- "image/x-bmp",
- "image/x-MS-bmp",
- "image/x-icon",
- "image/x-ico",
- "image/x-win-bitmap",
- "image/vmd.microsoft.icon",
- "application/ico",
- "image/ico",
- "image/icon",
- "image/jpeg",
+static const char* mime_image[] = {
+ "image/png", "image/bmp", "image/x-bmp", "image/x-MS-bmp",
+ "image/x-icon", "image/x-ico", "image/x-win-bitmap", "image/vmd.microsoft.icon",
+ "application/ico", "image/ico", "image/icon", "image/jpeg",
"image/tiff"
};
-static const char* mime_html[] =
-{
- "text/html"
-};
+static const char* mime_html[] = { "text/html" };
struct wlf_clipboard
{
@@ -253,13 +234,11 @@ static void wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mi
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard,
- UINT32 formatId)
+static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, UINT32 formatId)
{
CLIPRDR_FORMAT_DATA_REQUEST request = { 0 };
request.requestedFormatId = formatId;
- return clipboard->context->ClientFormatDataRequest(clipboard->context,
- &request);
+ return clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
}
/**
@@ -267,8 +246,7 @@ static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* data,
- size_t size)
+static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* data, size_t size)
{
CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
@@ -278,8 +256,7 @@ static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* d
response.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
response.dataLen = (UINT32)size;
response.requestedFormatData = data;
- return clipboard->context->ClientFormatDataResponse(clipboard->context,
- &response);
+ return clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
}
BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent* event)
@@ -321,19 +298,16 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
- (generalCapabilitySet);
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = CB_CAPS_VERSION_2;
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
if (clipboard->streams_supported && clipboard->file_formats_registered)
- generalCapabilitySet.generalFlags |=
- CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS;
+ generalCapabilitySet.generalFlags |= CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS;
- return clipboard->context->ClientCapabilities(clipboard->context,
- &capabilities);
+ return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
}
/**
@@ -341,15 +315,13 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard,
- BOOL status)
+static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard, BOOL status)
{
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
formatListResponse.dataLen = 0;
- return clipboard->context->ClientFormatListResponse(clipboard->context,
- &formatListResponse);
+ return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse);
}
/**
@@ -360,7 +332,7 @@ static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard,
static UINT wlf_cliprdr_monitor_ready(CliprdrClientContext* context,
const CLIPRDR_MONITOR_READY* monitorReady)
{
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
UINT ret;
WINPR_UNUSED(monitorReady);
@@ -380,20 +352,21 @@ static UINT wlf_cliprdr_monitor_ready(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wlf_cliprdr_server_capabilities(CliprdrClientContext* context,
- const CLIPRDR_CAPABILITIES* capabilities)
+ const CLIPRDR_CAPABILITIES* capabilities)
{
UINT32 i;
- const BYTE* capsPtr = (const BYTE*) capabilities->capabilitySets;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ const BYTE* capsPtr = (const BYTE*)capabilities->capabilitySets;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
clipboard->streams_supported = FALSE;
for (i = 0; i < capabilities->cCapabilitiesSets; i++)
{
- const CLIPRDR_CAPABILITY_SET* caps = (const CLIPRDR_CAPABILITY_SET*) capsPtr;
+ const CLIPRDR_CAPABILITY_SET* caps = (const CLIPRDR_CAPABILITY_SET*)capsPtr;
if (caps->capabilitySetType == CB_CAPSTYPE_GENERAL)
{
- const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps = (const CLIPRDR_GENERAL_CAPABILITY_SET*) caps;
+ const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps =
+ (const CLIPRDR_GENERAL_CAPABILITY_SET*)caps;
if (generalCaps->generalFlags & CB_STREAM_FILECLIP_ENABLED)
{
@@ -457,7 +430,8 @@ static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char*
if (clipboard->responseFile)
wlf_cliprdr_send_data_request(clipboard, clipboard->responseFormat);
else
- WLog_Print(clipboard->log, WLOG_ERROR, "failed to open clipboard file descriptor for MIME %s",
+ WLog_Print(clipboard->log, WLOG_ERROR,
+ "failed to open clipboard file descriptor for MIME %s",
clipboard->responseMime);
}
}
@@ -477,7 +451,7 @@ static void wlf_cliprdr_cancel_data(UwacSeat* seat, void* context)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_LIST* formatList)
+ const CLIPRDR_FORMAT_LIST* formatList)
{
UINT32 i;
wfClipboard* clipboard;
@@ -488,13 +462,14 @@ static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context,
if (!context || !context->custom)
return ERROR_INVALID_PARAMETER;
- clipboard = (wfClipboard*) context->custom;
+ clipboard = (wfClipboard*)context->custom;
wlf_cliprdr_free_server_formats(clipboard);
- if (!(clipboard->serverFormats = (CLIPRDR_FORMAT*) calloc(
- formatList->numFormats, sizeof(CLIPRDR_FORMAT))))
+ if (!(clipboard->serverFormats =
+ (CLIPRDR_FORMAT*)calloc(formatList->numFormats, sizeof(CLIPRDR_FORMAT))))
{
- WLog_Print(clipboard->log, WLOG_ERROR, "failed to allocate %"PRIuz" CLIPRDR_FORMAT structs",
+ WLog_Print(clipboard->log, WLOG_ERROR,
+ "failed to allocate %" PRIuz " CLIPRDR_FORMAT structs",
clipboard->numServerFormats);
return CHANNEL_RC_NO_MEMORY;
}
@@ -503,7 +478,8 @@ static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context,
if (!clipboard->seat)
{
- WLog_Print(clipboard->log, WLOG_ERROR, "clipboard->seat=NULL, check your client implementation");
+ WLog_Print(clipboard->log, WLOG_ERROR,
+ "clipboard->seat=NULL, check your client implementation");
return ERROR_INTERNAL_ERROR;
}
@@ -586,10 +562,11 @@ static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_server_format_list_response(CliprdrClientContext*
- context, const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+wlf_cliprdr_server_format_list_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
- //wfClipboard* clipboard = (wfClipboard*) context->custom;
+ // wfClipboard* clipboard = (wfClipboard*) context->custom;
return CHANNEL_RC_OK;
}
@@ -598,8 +575,9 @@ static UINT wlf_cliprdr_server_format_list_response(CliprdrClientContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_server_format_data_request(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+static UINT
+wlf_cliprdr_server_format_data_request(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
int cnv;
UINT rc = CHANNEL_RC_OK;
@@ -608,7 +586,7 @@ static UINT wlf_cliprdr_server_format_data_request(CliprdrClientContext* context
size_t size;
const char* mime;
UINT32 formatId = formatDataRequest->requestedFormatId;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
switch (formatId)
{
@@ -680,8 +658,9 @@ static UINT wlf_cliprdr_server_format_data_request(CliprdrClientContext* context
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wlf_cliprdr_server_format_data_response(CliprdrClientContext*
- context, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+wlf_cliprdr_server_format_data_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
int cnv;
UINT rc = ERROR_INTERNAL_ERROR;
@@ -689,7 +668,7 @@ static UINT wlf_cliprdr_server_format_data_response(CliprdrClientContext*
LPSTR cdata = NULL;
LPCSTR data = (LPCSTR)formatDataResponse->requestedFormatData;
const WCHAR* wdata = (const WCHAR*)formatDataResponse->requestedFormatData;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
if (size > INT_MAX * sizeof(WCHAR))
return ERROR_INTERNAL_ERROR;
@@ -697,7 +676,8 @@ static UINT wlf_cliprdr_server_format_data_response(CliprdrClientContext*
switch (clipboard->responseFormat)
{
case CF_UNICODETEXT:
- cnv = ConvertFromUnicode(CP_UTF8, 0, wdata, (int)(size / sizeof(WCHAR)), &cdata, 0, NULL, NULL);
+ cnv = ConvertFromUnicode(CP_UTF8, 0, wdata, (int)(size / sizeof(WCHAR)), &cdata, 0,
+ NULL, NULL);
if (cnv < 0)
return ERROR_INTERNAL_ERROR;
@@ -718,8 +698,9 @@ static UINT wlf_cliprdr_server_format_data_response(CliprdrClientContext*
return rc;
}
-static UINT wlf_cliprdr_server_file_size_request(wfClipboard* clipboard,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+wlf_cliprdr_server_file_size_request(wfClipboard* clipboard,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wClipboardFileSizeRequest request = { 0 };
request.streamId = fileContentsRequest->streamId;
@@ -727,15 +708,17 @@ static UINT wlf_cliprdr_server_file_size_request(wfClipboard* clipboard,
if (fileContentsRequest->cbRequested != sizeof(UINT64))
{
- WLog_Print(clipboard->log, WLOG_WARN, "unexpected FILECONTENTS_SIZE request: %"PRIu32" bytes",
+ WLog_Print(clipboard->log, WLOG_WARN,
+ "unexpected FILECONTENTS_SIZE request: %" PRIu32 " bytes",
fileContentsRequest->cbRequested);
}
return clipboard->delegate->ClientRequestFileSize(clipboard->delegate, &request);
}
-static UINT wlf_cliprdr_server_file_range_request(wfClipboard* clipboard,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+wlf_cliprdr_server_file_range_request(wfClipboard* clipboard,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wClipboardFileRangeRequest request = { 0 };
request.streamId = fileContentsRequest->streamId;
@@ -746,8 +729,9 @@ static UINT wlf_cliprdr_server_file_range_request(wfClipboard* clipboard,
return clipboard->delegate->ClientRequestFileRange(clipboard->delegate, &request);
}
-static UINT wlf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+wlf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
response.msgFlags = CB_RESPONSE_FAIL;
@@ -755,8 +739,9 @@ static UINT wlf_cliprdr_send_file_contents_failure(CliprdrClientContext* context
return context->ClientFileContentsResponse(context, &response);
}
-static UINT wlf_cliprdr_server_file_contents_request(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+wlf_cliprdr_server_file_contents_request(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
UINT error = NO_ERROR;
wfClipboard* clipboard = context->custom;
@@ -780,8 +765,8 @@ static UINT wlf_cliprdr_server_file_contents_request(CliprdrClientContext* conte
if (error)
{
- WLog_Print(clipboard->log, WLOG_ERROR, "failed to handle CLIPRDR_FILECONTENTS_REQUEST: 0x%08X",
- error);
+ WLog_Print(clipboard->log, WLOG_ERROR,
+ "failed to handle CLIPRDR_FILECONTENTS_REQUEST: 0x%08X", error);
return wlf_cliprdr_send_file_contents_failure(context, fileContentsRequest);
}
@@ -789,19 +774,21 @@ static UINT wlf_cliprdr_server_file_contents_request(CliprdrClientContext* conte
}
static UINT wlf_cliprdr_clipboard_file_size_success(wClipboardDelegate* delegate,
- const wClipboardFileSizeRequest* request, UINT64 fileSize)
+ const wClipboardFileSizeRequest* request,
+ UINT64 fileSize)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
wfClipboard* clipboard = delegate->custom;
response.msgFlags = CB_RESPONSE_OK;
response.streamId = request->streamId;
response.cbRequested = sizeof(UINT64);
- response.requestedData = (BYTE*) &fileSize;
+ response.requestedData = (BYTE*)&fileSize;
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
}
static UINT wlf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate,
- const wClipboardFileSizeRequest* request, UINT errorCode)
+ const wClipboardFileSizeRequest* request,
+ UINT errorCode)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
wfClipboard* clipboard = delegate->custom;
@@ -812,19 +799,21 @@ static UINT wlf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate
}
static UINT wlf_cliprdr_clipboard_file_range_success(wClipboardDelegate* delegate,
- const wClipboardFileRangeRequest* request, const BYTE* data, UINT32 size)
+ const wClipboardFileRangeRequest* request,
+ const BYTE* data, UINT32 size)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
wfClipboard* clipboard = delegate->custom;
response.msgFlags = CB_RESPONSE_OK;
response.streamId = request->streamId;
response.cbRequested = size;
- response.requestedData = (const BYTE*) data;
+ response.requestedData = (const BYTE*)data;
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
}
static UINT wlf_cliprdr_clipboard_file_range_failure(wClipboardDelegate* delegate,
- const wClipboardFileRangeRequest* request, UINT errorCode)
+ const wClipboardFileRangeRequest* request,
+ UINT errorCode)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
wfClipboard* clipboard = delegate->custom;
@@ -839,7 +828,7 @@ wfClipboard* wlf_clipboard_new(wlfContext* wfc)
rdpChannels* channels;
wfClipboard* clipboard;
- if (!(clipboard = (wfClipboard*) calloc(1, sizeof(wfClipboard))))
+ if (!(clipboard = (wfClipboard*)calloc(1, sizeof(wfClipboard))))
return NULL;
clipboard->wfc = wfc;
@@ -875,7 +864,7 @@ BOOL wlf_cliprdr_init(wfClipboard* clipboard, CliprdrClientContext* cliprdr)
return FALSE;
clipboard->context = cliprdr;
- cliprdr->custom = (void*) clipboard;
+ cliprdr->custom = (void*)clipboard;
cliprdr->MonitorReady = wlf_cliprdr_monitor_ready;
cliprdr->ServerCapabilities = wlf_cliprdr_server_capabilities;
cliprdr->ServerFormatList = wlf_cliprdr_server_format_list;
diff --git a/client/Wayland/wlf_disp.c b/client/Wayland/wlf_disp.c
index 012ca0879..609c4ef2f 100644
--- a/client/Wayland/wlf_disp.c
+++ b/client/Wayland/wlf_disp.c
@@ -111,9 +111,9 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp)
/* TODO: Multimonitor support for wayland
if (wlc->fullscreen && (settings->MonitorCount > 0))
{
- if (wlf_disp_sendLayout(wlfDisp->disp, settings->MonitorDefArray,
- settings->MonitorCount) != CHANNEL_RC_OK)
- return FALSE;
+ if (wlf_disp_sendLayout(wlfDisp->disp, settings->MonitorDefArray,
+ settings->MonitorCount) != CHANNEL_RC_OK)
+ return FALSE;
}
else
*/
@@ -334,7 +334,8 @@ static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitor
wlfDispContext* wlfDisp = (wlfDispContext*)disp->custom;
rdpSettings* settings = wlfDisp->wlc->context.settings;
WLog_DBG(TAG,
- "DisplayControlCapsPdu: MaxNumMonitors: %"PRIu32" MaxMonitorAreaFactorA: %"PRIu32" MaxMonitorAreaFactorB: %"PRIu32"",
+ "DisplayControlCapsPdu: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32
+ " MaxMonitorAreaFactorB: %" PRIu32 "",
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
wlfDisp->activated = TRUE;
@@ -358,7 +359,7 @@ BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp)
return FALSE;
wlfDisp->disp = disp;
- disp->custom = (void*) wlfDisp;
+ disp->custom = (void*)wlfDisp;
if (settings->DynamicResolutionUpdate)
{
diff --git a/client/Wayland/wlf_input.c b/client/Wayland/wlf_input.c
index e21949643..33352cf13 100644
--- a/client/Wayland/wlf_input.c
+++ b/client/Wayland/wlf_input.c
@@ -117,7 +117,6 @@ BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent*
return FALSE;
}
-
BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
{
rdpInput* input;
@@ -159,7 +158,7 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev)
step = (uint32_t)abs(direction);
if (step > WheelRotationMask)
step = WheelRotationMask;
- flags |= step;
+ flags |= step;
return freerdp_input_send_mouse_event(input, flags, (UINT16)x, (UINT16)y);
}
diff --git a/client/Wayland/wlf_input.h b/client/Wayland/wlf_input.h
index 39431baee..fb362c4cb 100644
--- a/client/Wayland/wlf_input.h
+++ b/client/Wayland/wlf_input.h
@@ -26,8 +26,7 @@
#include
#include
-BOOL wlf_handle_pointer_enter(freerdp* instance,
- const UwacPointerEnterLeaveEvent* ev);
+BOOL wlf_handle_pointer_enter(freerdp* instance, const UwacPointerEnterLeaveEvent* ev);
BOOL wlf_handle_pointer_motion(freerdp* instance, const UwacPointerMotionEvent* ev);
BOOL wlf_handle_pointer_buttons(freerdp* instance, const UwacPointerButtonEvent* ev);
BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev);
diff --git a/client/Wayland/wlf_pointer.c b/client/Wayland/wlf_pointer.c
index 9dad61717..64166590c 100644
--- a/client/Wayland/wlf_pointer.c
+++ b/client/Wayland/wlf_pointer.c
@@ -49,11 +49,9 @@ static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer)
return FALSE;
if (!freerdp_image_copy_from_pointer_data(
- ptr->data, PIXEL_FORMAT_BGRA32,
- 0, 0, 0, pointer->width, pointer->height,
- pointer->xorMaskData, pointer->lengthXorMask,
- pointer->andMaskData, pointer->lengthAndMask,
- pointer->xorBpp, &context->gdi->palette))
+ ptr->data, PIXEL_FORMAT_BGRA32, 0, 0, 0, pointer->width, pointer->height,
+ pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
+ pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
{
_aligned_free(ptr->data);
return FALSE;
@@ -71,8 +69,7 @@ static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
_aligned_free(ptr->data);
}
-static BOOL wlf_Pointer_Set(rdpContext* context,
- const rdpPointer* pointer)
+static BOOL wlf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
wlfContext* wlf = (wlfContext*)context;
wlfPointer* ptr = (wlfPointer*)pointer;
@@ -106,8 +103,8 @@ static BOOL wlf_Pointer_Set(rdpContext* context,
area.right = (UINT16)pointer->width;
area.bottom = (UINT16)pointer->height;
- if (!wlf_copy_image(ptr->data, pointer->width * 4, pointer->width, pointer->height, data, w * 4, w,
- h, &area, context->settings->SmartSizing))
+ if (!wlf_copy_image(ptr->data, pointer->width * 4, pointer->width, pointer->height, data, w * 4,
+ w, h, &area, context->settings->SmartSizing))
goto fail;
rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y);
@@ -157,7 +154,7 @@ BOOL wlf_register_pointer(rdpGraphics* graphics)
{
rdpPointer* pointer = NULL;
- if (!(pointer = (rdpPointer*) calloc(1, sizeof(rdpPointer))))
+ if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer))))
return FALSE;
pointer->size = sizeof(wlfPointer);
diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c
index 301463cf5..cabc56061 100644
--- a/client/Wayland/wlfreerdp.c
+++ b/client/Wayland/wlfreerdp.c
@@ -100,8 +100,8 @@ static BOOL wl_update_buffer(wlfContext* context_w, INT32 ix, INT32 iy, INT32 iw
area.right = x + w;
area.bottom = y + h;
- if (!wlf_copy_image(gdi->primary_buffer, gdi->stride, gdi->width, gdi->height,
- data, stride, geometry.width, geometry.height, &area,
+ if (!wlf_copy_image(gdi->primary_buffer, gdi->stride, gdi->width, gdi->height, data, stride,
+ geometry.width, geometry.height, &area,
context_w->context.settings->SmartSizing))
return FALSE;
@@ -139,7 +139,7 @@ static BOOL wl_end_paint(rdpContext* context)
y = gdi->primary->hdc->hwnd->invalid->y;
w = gdi->primary->hdc->hwnd->invalid->w;
h = gdi->primary->hdc->hwnd->invalid->h;
- context_w = (wlfContext*) context;
+ context_w = (wlfContext*)context;
return wl_update_buffer(context_w, x, y, w, h);
}
@@ -176,7 +176,7 @@ static BOOL wl_pre_connect(freerdp* instance)
if (!instance)
return FALSE;
- context = (wlfContext*) instance->context;
+ context = (wlfContext*)instance->context;
settings = instance->settings;
if (!context || !settings)
@@ -184,8 +184,7 @@ static BOOL wl_pre_connect(freerdp* instance)
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_WAYLAND;
- PubSub_SubscribeChannelConnected(instance->context->pubSub,
- wlf_OnChannelConnectedEventHandler);
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, wlf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
wlf_OnChannelDisconnectedEventHandler);
@@ -196,8 +195,8 @@ static BOOL wl_pre_connect(freerdp* instance)
if (output != NULL && UwacOutputGetResolution(output, &resolution) == UWAC_SUCCESS)
{
- settings->DesktopWidth = (UINT32) resolution.width;
- settings->DesktopHeight = (UINT32) resolution.height;
+ settings->DesktopWidth = (UINT32)resolution.width;
+ settings->DesktopHeight = (UINT32)resolution.height;
}
else
{
@@ -205,8 +204,7 @@ static BOOL wl_pre_connect(freerdp* instance)
}
}
- if (!freerdp_client_load_addins(instance->context->channels,
- instance->settings))
+ if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
return FALSE;
return TRUE;
@@ -223,7 +221,7 @@ static BOOL wl_post_connect(freerdp* instance)
if (!instance || !instance->context)
return FALSE;
- context = (wlfContext*) instance->context;
+ context = (wlfContext*)instance->context;
settings = instance->context->settings;
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
@@ -283,7 +281,7 @@ static void wl_post_disconnect(freerdp* instance)
if (!instance->context)
return;
- context = (wlfContext*) instance->context;
+ context = (wlfContext*)instance->context;
gdi_free(instance);
wlf_clipboard_free(context->clipboard);
wlf_disp_free(context->disp);
@@ -364,7 +362,8 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
break;
case UWAC_EVENT_CONFIGURE:
- if (!wlf_disp_handle_configure(context->disp, event.configure.width, event.configure.height))
+ if (!wlf_disp_handle_configure(context->disp, event.configure.width,
+ event.configure.height))
return FALSE;
if (!wl_refresh_display(context))
@@ -457,9 +456,9 @@ static int wlfreerdp_run(freerdp* instance)
else
{
/*
- * Indicate an unsuccessful connection attempt if reconnect
- * did not succeed and no other error was specified.
- */
+ * Indicate an unsuccessful connection attempt if reconnect
+ * did not succeed and no other error was specified.
+ */
if (freerdp_error_info(instance) == 0)
status = 42;
}
@@ -498,15 +497,15 @@ static int wlf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
if (!instance || !instance->context)
return -1;
- wlf = (wlfContext*) instance->context;
- WLog_Print(wlf->log, WLOG_INFO, "Logon Error Info %s [%s]", str_data, str_type);
+ wlf = (wlfContext*)instance->context;
+ WLog_Print(wlf->log, WLOG_INFO, "Logon Error Info %s [%s]", str_data, str_type);
return 1;
}
static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
{
UwacReturnCode status;
- wlfContext* wfl = (wlfContext*) context;
+ wlfContext* wfl = (wlfContext*)context;
if (!instance || !context)
return FALSE;
@@ -526,7 +525,7 @@ static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
return FALSE;
wfl->displayHandle = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
- UwacDisplayGetFd(wfl->display), WINPR_FD_READ);
+ UwacDisplayGetFd(wfl->display), WINPR_FD_READ);
if (!wfl->displayHandle)
return FALSE;
@@ -534,10 +533,9 @@ static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
return TRUE;
}
-
static void wlf_client_free(freerdp* instance, rdpContext* context)
{
- wlfContext* wlf = (wlfContext*) instance->context;
+ wlfContext* wlf = (wlfContext*)instance->context;
if (!context)
return;
@@ -588,10 +586,9 @@ int main(int argc, char* argv[])
if (!context)
goto fail;
- status = freerdp_client_settings_parse_command_line(context->settings, argc,
- argv, FALSE);
- status = freerdp_client_settings_command_line_status_print(context->settings,
- status, argc, argv);
+ status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
+ status =
+ freerdp_client_settings_command_line_status_print(context->settings, status, argc, argv);
if (status)
return 0;
@@ -609,9 +606,9 @@ fail:
return rc;
}
-BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight,
- void* dst, size_t dstStride, size_t dstWidth, size_t dstHeight,
- const RECTANGLE_16* area, BOOL scale)
+BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst,
+ size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area,
+ BOOL scale)
{
BOOL rc = FALSE;
diff --git a/client/Wayland/wlfreerdp.h b/client/Wayland/wlfreerdp.h
index 0f57ae5d0..09d056ae4 100644
--- a/client/Wayland/wlfreerdp.h
+++ b/client/Wayland/wlfreerdp.h
@@ -53,9 +53,8 @@ struct wlf_context
};
BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP);
-BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight,
- void* dst, size_t dstStride, size_t dstWidth, size_t dstHeight,
- const RECTANGLE_16* area, BOOL scale);
+BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t srcHeight, void* dst,
+ size_t dstStride, size_t dstWidth, size_t dstHeight, const RECTANGLE_16* area,
+ BOOL scale);
#endif /* FREERDP_CLIENT_WAYLAND_FREERDP_H */
-
diff --git a/client/Windows/cli/wfreerdp.c b/client/Windows/cli/wfreerdp.c
index 2357ff813..7a76eeb9b 100644
--- a/client/Windows/cli/wfreerdp.c
+++ b/client/Windows/cli/wfreerdp.c
@@ -42,8 +42,7 @@
#include
-INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
+INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
int status;
HANDLE thread;
@@ -94,19 +93,17 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
if (!argv[i])
goto out;
- if (WideCharToMultiByte(CP_UTF8, 0, args[i], -1, argv[i], size, NULL,
- NULL) != size)
+ if (WideCharToMultiByte(CP_UTF8, 0, args[i], -1, argv[i], size, NULL, NULL) != size)
goto out;
}
settings = context->settings;
- wfc = (wfContext*) context;
+ wfc = (wfContext*)context;
if (!settings || !wfc)
goto out;
- status = freerdp_client_settings_parse_command_line(settings, argc, argv,
- FALSE);
+ status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE);
if (status)
{
diff --git a/client/Windows/resource.h b/client/Windows/resource.h
index fe79d5068..35991fc6b 100644
--- a/client/Windows/resource.h
+++ b/client/Windows/resource.h
@@ -1,12 +1,12 @@
-#define IDI_ICON1 101
-#define IDB_MINIMIZE 103
-#define IDB_MINIMIZE_ACT 104
-#define IDB_LOCK 105
-#define IDB_LOCK_ACT 106
-#define IDB_UNLOCK 107
-#define IDB_UNLOCK_ACT 108
-#define IDB_CLOSE 109
-#define IDB_CLOSE_ACT 100
-#define IDB_RESTORE 111
-#define IDB_RESTORE_ACT 112
+#define IDI_ICON1 101
+#define IDB_MINIMIZE 103
+#define IDB_MINIMIZE_ACT 104
+#define IDB_LOCK 105
+#define IDB_LOCK_ACT 106
+#define IDB_UNLOCK 107
+#define IDB_UNLOCK_ACT 108
+#define IDB_CLOSE 109
+#define IDB_CLOSE_ACT 100
+#define IDB_RESTORE 111
+#define IDB_RESTORE_ACT 112
diff --git a/client/Windows/wf_channels.c b/client/Windows/wf_channels.c
index 73aac5c43..3afd52dbb 100644
--- a/client/Windows/wf_channels.c
+++ b/client/Windows/wf_channels.c
@@ -30,10 +30,9 @@
#include
#define TAG CLIENT_TAG("windows")
-void wf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e)
+void wf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
rdpSettings* settings = wfc->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
@@ -42,28 +41,27 @@ void wf_OnChannelConnectedEventHandler(void* context,
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (!settings->SoftwareGdi)
- WLog_WARN(TAG,
- "Channel "RDPGFX_DVC_CHANNEL_NAME" does not support hardware acceleration, using fallback.");
+ WLog_WARN(TAG, "Channel " RDPGFX_DVC_CHANNEL_NAME
+ " does not support hardware acceleration, using fallback.");
- gdi_graphics_pipeline_init(wfc->context.gdi, (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(wfc->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
- wf_rail_init(wfc, (RailClientContext*) e->pInterface);
+ wf_rail_init(wfc, (RailClientContext*)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- wf_cliprdr_init(wfc, (CliprdrClientContext*) e->pInterface);
+ wf_cliprdr_init(wfc, (CliprdrClientContext*)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
}
}
-void wf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e)
+void wf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
rdpSettings* settings = wfc->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
@@ -71,16 +69,15 @@ void wf_OnChannelDisconnectedEventHandler(void* context,
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- gdi_graphics_pipeline_uninit(wfc->context.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(wfc->context.gdi, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
- wf_rail_uninit(wfc, (RailClientContext*) e->pInterface);
+ wf_rail_uninit(wfc, (RailClientContext*)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- wf_cliprdr_uninit(wfc, (CliprdrClientContext*) e->pInterface);
+ wf_cliprdr_uninit(wfc, (CliprdrClientContext*)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
diff --git a/client/Windows/wf_channels.h b/client/Windows/wf_channels.h
index 90ee0daa0..5e4ca52e3 100644
--- a/client/Windows/wf_channels.h
+++ b/client/Windows/wf_channels.h
@@ -28,9 +28,7 @@
#include "wf_client.h"
-void wf_OnChannelConnectedEventHandler(void* context,
- ChannelConnectedEventArgs* e);
-void wf_OnChannelDisconnectedEventHandler(void* context,
- ChannelDisconnectedEventArgs* e);
+void wf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e);
+void wf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e);
#endif /* FREERDP_CLIENT_WIN_CHANNELS_H */
diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c
index f4208aca9..fa8d2c5c7 100644
--- a/client/Windows/wf_client.c
+++ b/client/Windows/wf_client.c
@@ -68,7 +68,7 @@ static BOOL wf_create_console(void)
freopen("CONIN$", "r", stdin);
clearerr(stdin);
- WLog_INFO(TAG, "Debug console created.");
+ WLog_INFO(TAG, "Debug console created.");
return TRUE;
}
@@ -152,12 +152,11 @@ static BOOL wf_desktop_resize(rdpContext* context)
{
same = (wfc->primary == wfc->drawing) ? TRUE : FALSE;
wf_image_free(wfc->primary);
- wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
- settings->DesktopHeight, context->gdi->dstFormat, NULL);
+ wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight,
+ context->gdi->dstFormat, NULL);
}
- if (!gdi_resize_ex(context->gdi, settings->DesktopWidth,
- settings->DesktopHeight, 0,
+ if (!gdi_resize_ex(context->gdi, settings->DesktopWidth, settings->DesktopHeight, 0,
context->gdi->dstFormat, wfc->primary->pdata, NULL))
return FALSE;
@@ -192,7 +191,7 @@ static BOOL wf_pre_connect(freerdp* instance)
return FALSE;
context = instance->context;
- wfc = (wfContext*) instance->context;
+ wfc = (wfContext*)instance->context;
settings = instance->settings;
settings->OsMajorType = OSMAJORTYPE_WINDOWS;
settings->OsMinorType = OSMINORTYPE_WINDOWS_NT;
@@ -249,9 +248,8 @@ static BOOL wf_pre_connect(freerdp* instance)
return -1;
freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout,
- (int) GetKeyboardLayout(0) & 0x0000FFFF);
- PubSub_SubscribeChannelConnected(instance->context->pubSub,
- wf_OnChannelConnectedEventHandler);
+ (int)GetKeyboardLayout(0) & 0x0000FFFF);
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, wf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
wf_OnChannelDisconnectedEventHandler);
return TRUE;
@@ -269,14 +267,13 @@ static void wf_add_system_menu(wfContext* wfc)
hMenu = GetSystemMenu(wfc->hwnd, FALSE);
ZeroMemory(&item_info, sizeof(MENUITEMINFO));
- item_info.fMask = MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING |
- MIIM_DATA;
+ item_info.fMask = MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_DATA;
item_info.cbSize = sizeof(MENUITEMINFO);
item_info.wID = SYSCOMMAND_ID_SMARTSIZING;
item_info.fType = MFT_STRING;
item_info.dwTypeData = _wcsdup(_T("Smart sizing"));
- item_info.cch = (UINT) _wcslen(_T("Smart sizing"));
- item_info.dwItemData = (ULONG_PTR) wfc;
+ item_info.cch = (UINT)_wcslen(_T("Smart sizing"));
+ item_info.dwItemData = (ULONG_PTR)wfc;
InsertMenuItem(hMenu, 6, TRUE, &item_info);
if (wfc->context.settings->SmartSizing)
@@ -331,10 +328,9 @@ static BOOL wf_post_connect(freerdp* instance)
const UINT32 format = PIXEL_FORMAT_BGRX32;
settings = instance->settings;
context = instance->context;
- wfc = (wfContext*) instance->context;
+ wfc = (wfContext*)instance->context;
cache = instance->context->cache;
- wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
- settings->DesktopHeight, format, NULL);
+ wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL);
if (!gdi_init_ex(instance, format, 0, wfc->primary->pdata, NULL))
return FALSE;
@@ -359,25 +355,24 @@ static BOOL wf_post_connect(freerdp* instance)
else if (!settings->Decorations)
dwStyle = WS_CHILD | WS_BORDER;
else
- dwStyle = WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX
- | WS_MAXIMIZEBOX;
+ dwStyle =
+ WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX;
if (!wfc->hwnd)
{
- wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, wfc->window_title,
- dwStyle,
- 0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
- SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc);
+ wfc->hwnd = CreateWindowEx((DWORD)NULL, wfc->wndClassName, wfc->window_title, dwStyle, 0, 0,
+ 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
+ SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR)wfc);
}
wf_resize_window(wfc);
wf_add_system_menu(wfc);
- BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight,
- NULL, 0, 0, BLACKNESS);
+ BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight, NULL, 0, 0,
+ BLACKNESS);
wfc->drawing = wfc->primary;
EventArgsInit(&e, "wfreerdp");
e.embed = FALSE;
- e.handle = (void*) wfc->hwnd;
+ e.handle = (void*)wfc->hwnd;
PubSub_OnEmbedWindow(context->pubSub, context, &e);
ShowWindow(wfc->hwnd, SW_SHOWNORMAL);
UpdateWindow(wfc->hwnd);
@@ -408,21 +403,15 @@ static void wf_post_disconnect(freerdp* instance)
if (!instance || !instance->context || !instance->settings)
return;
- wfc = (wfContext*) instance->context;
+ wfc = (wfContext*)instance->context;
free(wfc->window_title);
}
-static CREDUI_INFOA wfUiInfo =
-{
- sizeof(CREDUI_INFOA),
- NULL,
- "Enter your credentials",
- "Remote Desktop Security",
- NULL
-};
+static CREDUI_INFOA wfUiInfo = { sizeof(CREDUI_INFOA), NULL, "Enter your credentials",
+ "Remote Desktop Security", NULL };
-static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
- char** username, char** password, char** domain)
+static BOOL wf_authenticate_raw(freerdp* instance, const char* title, char** username,
+ char** password, char** domain)
{
wfContext* wfc;
BOOL fSave;
@@ -435,19 +424,19 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
if (!instance || !instance->context)
return FALSE;
- wfc = (wfContext*) instance->context;
+ wfc = (wfContext*)instance->context;
fSave = FALSE;
dwFlags = CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_EXCLUDE_CERTIFICATES;
if (wfc->isConsole)
- status = CredUICmdLinePromptForCredentialsA(title, NULL, 0,
- UserName, CREDUI_MAX_USERNAME_LENGTH + 1,
- Password, CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
+ status = CredUICmdLinePromptForCredentialsA(
+ title, NULL, 0, UserName, CREDUI_MAX_USERNAME_LENGTH + 1, Password,
+ CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
else
- status = CredUIPromptForCredentialsA(&wfUiInfo, title, NULL, 0,
- UserName, CREDUI_MAX_USERNAME_LENGTH + 1,
- Password, CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
+ status = CredUIPromptForCredentialsA(&wfUiInfo, title, NULL, 0, UserName,
+ CREDUI_MAX_USERNAME_LENGTH + 1, Password,
+ CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
if (status != NO_ERROR)
{
@@ -455,9 +444,8 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
return FALSE;
}
- status = CredUIParseUserNameA(UserName, User, sizeof(User), Domain,
- sizeof(Domain));
- //WLog_ERR(TAG, "User: %s Domain: %s Password: %s", User, Domain, Password);
+ status = CredUIParseUserNameA(UserName, User, sizeof(User), Domain, sizeof(Domain));
+ // WLog_ERR(TAG, "User: %s Domain: %s Password: %s", User, Domain, Password);
*username = _strdup(User);
if (!(*username))
@@ -490,15 +478,13 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
return TRUE;
}
-static BOOL wf_authenticate(freerdp* instance,
- char** username, char** password, char** domain)
+static BOOL wf_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
- return wf_authenticate_raw(instance, instance->settings->ServerHostname,
- username, password, domain);
+ return wf_authenticate_raw(instance, instance->settings->ServerHostname, username, password,
+ domain);
}
-static BOOL wf_gw_authenticate(freerdp* instance,
- char** username, char** password, char** domain)
+static BOOL wf_gw_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
char tmp[MAX_PATH];
sprintf_s(tmp, sizeof(tmp), "Gateway %s", instance->settings->GatewayHostname);
@@ -532,42 +518,38 @@ static WCHAR* wf_format_text(const WCHAR* fmt, ...)
goto fail;
buffer = tmp;
- }
- while(TRUE);
+ } while (TRUE);
fail:
free(buffer);
return NULL;
}
-static DWORD wf_verify_certificate_ex(freerdp* instance,
- const char* host,
- UINT16 port,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* fingerprint,
- DWORD flags)
+static DWORD wf_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
+ const char* common_name, const char* subject,
+ const char* issuer, const char* fingerprint, DWORD flags)
{
WCHAR* buffer;
WCHAR* caption;
int what = IDCANCEL;
- buffer = wf_format_text(L"Certificate details:\n"
- L"\tCommonName: %S\n"
- L"\tSubject: %S\n"
- L"\tIssuer: %S\n"
- L"\tThumbprint: %S\n"
- L"\tHostMismatch: %S\n"
- L"\n"
- L"The above X.509 certificate could not be verified, possibly because you do not have "
- L"the CA certificate in your certificate store, or the certificate has expired. "
- L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n"
- L"\n"
- L"YES\tAccept permanently\n"
- L"NO\tAccept for this session only\n"
- L"CANCEL\tAbort connection\n",
- common_name, subject, issuer, fingerprint, flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No");
+ buffer = wf_format_text(
+ L"Certificate details:\n"
+ L"\tCommonName: %S\n"
+ L"\tSubject: %S\n"
+ L"\tIssuer: %S\n"
+ L"\tThumbprint: %S\n"
+ L"\tHostMismatch: %S\n"
+ L"\n"
+ L"The above X.509 certificate could not be verified, possibly because you do not have "
+ L"the CA certificate in your certificate store, or the certificate has expired. "
+ L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n"
+ L"\n"
+ L"YES\tAccept permanently\n"
+ L"NO\tAccept for this session only\n"
+ L"CANCEL\tAbort connection\n",
+ common_name, subject, issuer, fingerprint,
+ flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No");
caption = wf_format_text(L"Verify certificate for %S:%hu", host, port);
if (!buffer || !caption)
@@ -580,53 +562,48 @@ fail:
/* return 1 to accept and store a certificate, 2 to accept
* a certificate only for this session, 0 otherwise */
- switch(what)
+ switch (what)
{
- case IDYES:
- return 1;
- case IDNO:
- return 2;
- default:
- return 0;
+ case IDYES:
+ return 1;
+ case IDNO:
+ return 2;
+ default:
+ return 0;
}
}
-static DWORD wf_verify_changed_certificate_ex(freerdp* instance,
- const char* host,
- UINT16 port,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* new_fingerprint,
- const char* old_subject,
- const char* old_issuer,
- const char* old_fingerprint,
- DWORD flags)
+static DWORD wf_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port,
+ const char* common_name, const char* subject,
+ const char* issuer, const char* new_fingerprint,
+ const char* old_subject, const char* old_issuer,
+ const char* old_fingerprint, DWORD flags)
{
WCHAR* buffer;
WCHAR* caption;
int what = IDCANCEL;
- buffer = wf_format_text( L"New Certificate details:\n"
- L"\tCommonName: %S\n"
- L"\tSubject: %S\n"
- L"\tIssuer: %S\n"
- L"\tThumbprint: %S\n"
- L"\tHostMismatch: %S\n"
- L"\n"
- L"Old Certificate details:\n"
- L"\tSubject: %S\n"
- L"\tIssuer: %S\n"
- L"\tThumbprint: %S"
- L"The above X.509 certificate could not be verified, possibly because you do not have "
- L"the CA certificate in your certificate store, or the certificate has expired. "
- L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n"
- L"\n"
- L"YES\tAccept permanently\n"
- L"NO\tAccept for this session only\n"
- L"CANCEL\tAbort connection\n",
- common_name, subject, issuer, new_fingerprint, flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No",
- old_subject, old_issuer, old_fingerprint);
+ buffer = wf_format_text(
+ L"New Certificate details:\n"
+ L"\tCommonName: %S\n"
+ L"\tSubject: %S\n"
+ L"\tIssuer: %S\n"
+ L"\tThumbprint: %S\n"
+ L"\tHostMismatch: %S\n"
+ L"\n"
+ L"Old Certificate details:\n"
+ L"\tSubject: %S\n"
+ L"\tIssuer: %S\n"
+ L"\tThumbprint: %S"
+ L"The above X.509 certificate could not be verified, possibly because you do not have "
+ L"the CA certificate in your certificate store, or the certificate has expired. "
+ L"Please look at the OpenSSL documentation on how to add a private CA to the store.\n"
+ L"\n"
+ L"YES\tAccept permanently\n"
+ L"NO\tAccept for this session only\n"
+ L"CANCEL\tAbort connection\n",
+ common_name, subject, issuer, new_fingerprint,
+ flags & VERIFY_CERT_FLAG_MISMATCH ? "Yes" : "No", old_subject, old_issuer, old_fingerprint);
caption = wf_format_text(L"Verify certificate change for %S:%hu", host, port);
if (!buffer || !caption)
@@ -639,14 +616,14 @@ fail:
/* return 1 to accept and store a certificate, 2 to accept
* a certificate only for this session, 0 otherwise */
- switch(what)
+ switch (what)
{
- case IDYES:
- return 1;
- case IDNO:
- return 2;
- default:
- return 0;
+ case IDYES:
+ return 1;
+ case IDNO:
+ return 2;
+ default:
+ return 0;
}
}
@@ -655,7 +632,7 @@ static DWORD WINAPI wf_input_thread(LPVOID arg)
int status;
wMessage message;
wMessageQueue* queue;
- freerdp* instance = (freerdp*) arg;
+ freerdp* instance = (freerdp*)arg;
assert(NULL != instance);
status = 1;
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
@@ -664,8 +641,8 @@ static DWORD WINAPI wf_input_thread(LPVOID arg)
{
while (MessageQueue_Peek(queue, &message, TRUE))
{
- status = freerdp_message_queue_process_message(instance,
- FREERDP_INPUT_MESSAGE_QUEUE, &message);
+ status = freerdp_message_queue_process_message(instance, FREERDP_INPUT_MESSAGE_QUEUE,
+ &message);
if (!status)
break;
@@ -696,9 +673,9 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
rdpSettings* settings;
BOOL async_input;
HANDLE input_thread;
- instance = (freerdp*) lpParam;
+ instance = (freerdp*)lpParam;
context = instance->context;
- wfc = (wfContext*) instance->context;
+ wfc = (wfContext*)instance->context;
if (!freerdp_connect(instance))
goto end;
@@ -709,8 +686,7 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
if (async_input)
{
- if (!(input_thread = CreateThread(NULL, 0, wf_input_thread,
- instance, 0, NULL)))
+ if (!(input_thread = CreateThread(NULL, 0, wf_input_thread, instance, 0, NULL)))
{
WLog_ERR(TAG, "Failed to create async input thread.");
goto disconnect;
@@ -739,11 +715,9 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
nCount += tmp;
}
- if (MsgWaitForMultipleObjects(nCount, handles, FALSE, 1000,
- QS_ALLINPUT) == WAIT_FAILED)
+ if (MsgWaitForMultipleObjects(nCount, handles, FALSE, 1000, QS_ALLINPUT) == WAIT_FAILED)
{
- WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%08lX",
- GetLastError());
+ WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%08lX", GetLastError());
break;
}
@@ -829,10 +803,9 @@ static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
BOOL status;
wfContext* wfc;
HHOOK hook_handle;
- wfc = (wfContext*) lpParam;
+ wfc = (wfContext*)lpParam;
assert(NULL != wfc);
- hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance,
- 0);
+ hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance, 0);
if (hook_handle)
{
@@ -859,7 +832,7 @@ static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
WLog_DBG(TAG, "Keyboard thread exited.");
ExitThread(0);
- return (DWORD) NULL;
+ return (DWORD)NULL;
}
static rdpSettings* freerdp_client_get_settings(wfContext* wfc)
@@ -881,19 +854,18 @@ static int freerdp_client_focus_out(wfContext* wfc)
int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
{
- WLog_DBG(TAG, "freerdp_client_set_window_size %d, %d", width, height);
+ WLog_DBG(TAG, "freerdp_client_set_window_size %d, %d", width, height);
if ((width != wfc->client_width) || (height != wfc->client_height))
{
PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED,
- ((UINT) height << 16) | (UINT) width);
+ ((UINT)height << 16) | (UINT)width);
}
return 0;
}
-void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
- UINT32 client_height)
+void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_height)
{
if (wfc->disablewindowtracking)
return;
@@ -925,9 +897,9 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
{
horiz = TRUE;
}
- else if (horiz
- && client_width >=
- wfc->context.settings->DesktopWidth/* - GetSystemMetrics(SM_CXVSCROLL)*/)
+ else if (horiz &&
+ client_width >=
+ wfc->context.settings->DesktopWidth /* - GetSystemMetrics(SM_CXVSCROLL)*/)
{
horiz = FALSE;
}
@@ -936,15 +908,14 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
{
vert = TRUE;
}
- else if (vert
- && client_height >=
- wfc->context.settings->DesktopHeight/* - GetSystemMetrics(SM_CYHSCROLL)*/)
+ else if (vert &&
+ client_height >=
+ wfc->context.settings->DesktopHeight /* - GetSystemMetrics(SM_CYHSCROLL)*/)
{
vert = FALSE;
}
- if (horiz == vert && (horiz != wfc->xScrollVisible
- && vert != wfc->yScrollVisible))
+ if (horiz == vert && (horiz != wfc->xScrollVisible && vert != wfc->yScrollVisible))
{
if (ShowScrollBar(wfc->hwnd, SB_BOTH, horiz))
{
@@ -977,11 +948,11 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
wfc->xMaxScroll = MAX(wfc->context.settings->DesktopWidth - client_width, 0);
wfc->xCurrentScroll = MIN(wfc->xCurrentScroll, wfc->xMaxScroll);
si.cbSize = sizeof(si);
- si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
- si.nMin = wfc->xMinScroll;
- si.nMax = wfc->context.settings->DesktopWidth;
- si.nPage = client_width;
- si.nPos = wfc->xCurrentScroll;
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = wfc->xMinScroll;
+ si.nMax = wfc->context.settings->DesktopWidth;
+ si.nPage = client_width;
+ si.nPos = wfc->xCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
}
@@ -990,15 +961,14 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
// The vertical scrolling range is defined by
// (bitmap_height) - (client_height). The current vertical
// scroll value remains within the vertical scrolling range.
- wfc->yMaxScroll = MAX(wfc->context.settings->DesktopHeight - client_height,
- 0);
+ wfc->yMaxScroll = MAX(wfc->context.settings->DesktopHeight - client_height, 0);
wfc->yCurrentScroll = MIN(wfc->yCurrentScroll, wfc->yMaxScroll);
si.cbSize = sizeof(si);
- si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
- si.nMin = wfc->yMinScroll;
- si.nMax = wfc->context.settings->DesktopHeight;
- si.nPage = client_height;
- si.nPos = wfc->yCurrentScroll;
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = wfc->yMinScroll;
+ si.nMax = wfc->context.settings->DesktopHeight;
+ si.nPage = client_height;
+ si.nPos = wfc->yCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
}
}
@@ -1064,10 +1034,10 @@ static int wfreerdp_client_start(rdpContext* context)
{
HWND hWndParent;
HINSTANCE hInstance;
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
freerdp* instance = context->instance;
hInstance = GetModuleHandle(NULL);
- hWndParent = (HWND) instance->settings->ParentWindowId;
+ hWndParent = (HWND)instance->settings->ParentWindowId;
instance->settings->EmbeddedWindow = (hWndParent) ? TRUE : FALSE;
wfc->hWndParent = hWndParent;
wfc->hInstance = hInstance;
@@ -1080,21 +1050,20 @@ static int wfreerdp_client_start(rdpContext* context)
wfc->wndClass.cbClsExtra = 0;
wfc->wndClass.cbWndExtra = 0;
wfc->wndClass.hCursor = wfc->cursor;
- wfc->wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
+ wfc->wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wfc->wndClass.lpszMenuName = NULL;
wfc->wndClass.lpszClassName = wfc->wndClassName;
wfc->wndClass.hInstance = hInstance;
wfc->wndClass.hIcon = wfc->icon;
wfc->wndClass.hIconSm = wfc->icon;
RegisterClassEx(&(wfc->wndClass));
- wfc->keyboardThread = CreateThread(NULL, 0, wf_keyboard_thread, (void*) wfc, 0,
- &wfc->keyboardThreadId);
+ wfc->keyboardThread =
+ CreateThread(NULL, 0, wf_keyboard_thread, (void*)wfc, 0, &wfc->keyboardThreadId);
if (!wfc->keyboardThread)
return -1;
- wfc->thread = CreateThread(NULL, 0, wf_client_thread, (void*) instance, 0,
- &wfc->mainThreadId);
+ wfc->thread = CreateThread(NULL, 0, wf_client_thread, (void*)instance, 0, &wfc->mainThreadId);
if (!wfc->thread)
return -1;
@@ -1104,7 +1073,7 @@ static int wfreerdp_client_start(rdpContext* context)
static int wfreerdp_client_stop(rdpContext* context)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
if (wfc->thread)
{
diff --git a/client/Windows/wf_client.h b/client/Windows/wf_client.h
index ad8e32773..29f194a8e 100644
--- a/client/Windows/wf_client.h
+++ b/client/Windows/wf_client.h
@@ -48,102 +48,101 @@ typedef struct wf_context wfContext;
#include "wf_cliprdr.h"
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
// System menu constants
#define SYSCOMMAND_ID_SMARTSIZING 1000
-struct wf_bitmap
-{
- rdpBitmap _bitmap;
- HDC hdc;
- HBITMAP bitmap;
- HBITMAP org_bitmap;
- BYTE* pdata;
-};
-typedef struct wf_bitmap wfBitmap;
+ struct wf_bitmap
+ {
+ rdpBitmap _bitmap;
+ HDC hdc;
+ HBITMAP bitmap;
+ HBITMAP org_bitmap;
+ BYTE* pdata;
+ };
+ typedef struct wf_bitmap wfBitmap;
-struct wf_pointer
-{
- rdpPointer pointer;
- HCURSOR cursor;
-};
-typedef struct wf_pointer wfPointer;
+ struct wf_pointer
+ {
+ rdpPointer pointer;
+ HCURSOR cursor;
+ };
+ typedef struct wf_pointer wfPointer;
-struct wf_context
-{
- rdpContext context;
- DEFINE_RDP_CLIENT_COMMON();
+ struct wf_context
+ {
+ rdpContext context;
+ DEFINE_RDP_CLIENT_COMMON();
- int offset_x;
- int offset_y;
- int fullscreen_toggle;
- int fullscreen;
- int percentscreen;
- WCHAR* window_title;
- int client_x;
- int client_y;
- int client_width;
- int client_height;
+ int offset_x;
+ int offset_y;
+ int fullscreen_toggle;
+ int fullscreen;
+ int percentscreen;
+ WCHAR* window_title;
+ int client_x;
+ int client_y;
+ int client_width;
+ int client_height;
- HANDLE keyboardThread;
+ HANDLE keyboardThread;
- HICON icon;
- HWND hWndParent;
- HINSTANCE hInstance;
- WNDCLASSEX wndClass;
- LPCTSTR wndClassName;
- HCURSOR hDefaultCursor;
+ HICON icon;
+ HWND hWndParent;
+ HINSTANCE hInstance;
+ WNDCLASSEX wndClass;
+ LPCTSTR wndClassName;
+ HCURSOR hDefaultCursor;
- HWND hwnd;
- POINT diff;
+ HWND hwnd;
+ POINT diff;
- wfBitmap* primary;
- wfBitmap* drawing;
- HCURSOR cursor;
- HBRUSH brush;
- HBRUSH org_brush;
- RECT update_rect;
- RECT scale_update_rect;
+ wfBitmap* primary;
+ wfBitmap* drawing;
+ HCURSOR cursor;
+ HBRUSH brush;
+ HBRUSH org_brush;
+ RECT update_rect;
+ RECT scale_update_rect;
- DWORD mainThreadId;
- DWORD keyboardThreadId;
+ DWORD mainThreadId;
+ DWORD keyboardThreadId;
- rdpFile* connectionRdpFile;
+ rdpFile* connectionRdpFile;
- BOOL disablewindowtracking;
+ BOOL disablewindowtracking;
- BOOL updating_scrollbars;
- BOOL xScrollVisible;
- int xMinScroll;
- int xCurrentScroll;
- int xMaxScroll;
+ BOOL updating_scrollbars;
+ BOOL xScrollVisible;
+ int xMinScroll;
+ int xCurrentScroll;
+ int xMaxScroll;
- BOOL yScrollVisible;
- int yMinScroll;
- int yCurrentScroll;
- int yMaxScroll;
+ BOOL yScrollVisible;
+ int yMinScroll;
+ int yCurrentScroll;
+ int yMaxScroll;
- void* clipboard;
- CliprdrClientContext* cliprdr;
+ void* clipboard;
+ CliprdrClientContext* cliprdr;
- wfFloatBar* floatbar;
+ wfFloatBar* floatbar;
- RailClientContext* rail;
- wHashTable* railWindows;
- BOOL isConsole;
-};
+ RailClientContext* rail;
+ wHashTable* railWindows;
+ BOOL isConsole;
+ };
-/**
- * Client Interface
- */
+ /**
+ * Client Interface
+ */
-FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
-FREERDP_API int freerdp_client_set_window_size(wfContext* wfc, int width,
- int height);
-FREERDP_API void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
- UINT32 client_height);
+ FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
+ FREERDP_API int freerdp_client_set_window_size(wfContext* wfc, int width, int height);
+ FREERDP_API void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_height);
#ifdef __cplusplus
}
diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c
index da6430286..d1824172a 100644
--- a/client/Windows/wf_cliprdr.c
+++ b/client/Windows/wf_cliprdr.c
@@ -50,13 +50,16 @@
#ifdef WITH_DEBUG_CLIPRDR
#define DEBUG_CLIPRDR(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_CLIPRDR(...) do { } while (0)
+#define DEBUG_CLIPRDR(...) \
+ do \
+ { \
+ } while (0)
#endif
-typedef BOOL (WINAPI* fnAddClipboardFormatListener)(HWND hwnd);
-typedef BOOL (WINAPI* fnRemoveClipboardFormatListener)(HWND hwnd);
-typedef BOOL (WINAPI* fnGetUpdatedClipboardFormats)(PUINT lpuiFormats,
- UINT cFormats, PUINT pcFormatsOut);
+typedef BOOL(WINAPI* fnAddClipboardFormatListener)(HWND hwnd);
+typedef BOOL(WINAPI* fnRemoveClipboardFormatListener)(HWND hwnd);
+typedef BOOL(WINAPI* fnGetUpdatedClipboardFormats)(PUINT lpuiFormats, UINT cFormats,
+ PUINT pcFormatsOut);
struct format_mapping
{
@@ -143,25 +146,22 @@ struct wf_clipboard
};
typedef struct wf_clipboard wfClipboard;
-#define WM_CLIPRDR_MESSAGE (WM_USER + 156)
-#define OLE_SETCLIPBOARD 1
+#define WM_CLIPRDR_MESSAGE (WM_USER + 156)
+#define OLE_SETCLIPBOARD 1
-static BOOL wf_create_file_obj(wfClipboard* cliprdrrdr,
- IDataObject** ppDataObject);
+static BOOL wf_create_file_obj(wfClipboard* cliprdrrdr, IDataObject** ppDataObject);
static void wf_destroy_file_obj(IDataObject* instance);
static UINT32 get_remote_format_id(wfClipboard* clipboard, UINT32 local_format);
static UINT cliprdr_send_data_request(wfClipboard* clipboard, UINT32 format);
static UINT cliprdr_send_lock(wfClipboard* clipboard);
static UINT cliprdr_send_unlock(wfClipboard* clipboard);
-static UINT cliprdr_send_request_filecontents(wfClipboard* clipboard,
- const void* streamid,
- ULONG index, UINT32 flag, DWORD positionhigh,
- DWORD positionlow, ULONG request);
+static UINT cliprdr_send_request_filecontents(wfClipboard* clipboard, const void* streamid,
+ ULONG index, UINT32 flag, DWORD positionhigh,
+ DWORD positionlow, ULONG request);
static void CliprdrDataObject_Delete(CliprdrDataObject* instance);
-static CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats,
- FORMATETC* pFormatEtc);
+static CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pFormatEtc);
static void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance);
static void CliprdrStream_Delete(CliprdrStream* instance);
@@ -170,8 +170,8 @@ static void CliprdrStream_Delete(CliprdrStream* instance);
* IStream
*/
-static HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream* This,
- REFIID riid, void** ppvObject)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream* This, REFIID riid,
+ void** ppvObject)
{
if (IsEqualIID(riid, &IID_IStream) || IsEqualIID(riid, &IID_IUnknown))
{
@@ -188,7 +188,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_QueryInterface(IStream* This,
static ULONG STDMETHODCALLTYPE CliprdrStream_AddRef(IStream* This)
{
- CliprdrStream* instance = (CliprdrStream*) This;
+ CliprdrStream* instance = (CliprdrStream*)This;
if (!instance)
return 0;
@@ -199,7 +199,7 @@ static ULONG STDMETHODCALLTYPE CliprdrStream_AddRef(IStream* This)
static ULONG STDMETHODCALLTYPE CliprdrStream_Release(IStream* This)
{
LONG count;
- CliprdrStream* instance = (CliprdrStream*) This;
+ CliprdrStream* instance = (CliprdrStream*)This;
if (!instance)
return 0;
@@ -217,25 +217,25 @@ static ULONG STDMETHODCALLTYPE CliprdrStream_Release(IStream* This)
}
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream* This, void* pv,
- ULONG cb, ULONG* pcbRead)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream* This, void* pv, ULONG cb,
+ ULONG* pcbRead)
{
int ret;
- CliprdrStream* instance = (CliprdrStream*) This;
+ CliprdrStream* instance = (CliprdrStream*)This;
wfClipboard* clipboard;
if (!pv || !pcbRead || !instance)
return E_INVALIDARG;
- clipboard = (wfClipboard*) instance->m_pData;
+ clipboard = (wfClipboard*)instance->m_pData;
*pcbRead = 0;
if (instance->m_lOffset.QuadPart >= instance->m_lSize.QuadPart)
return S_FALSE;
- ret = cliprdr_send_request_filecontents(clipboard, (void*) This,
- instance->m_lIndex, FILECONTENTS_RANGE,
- instance->m_lOffset.HighPart, instance->m_lOffset.LowPart, cb);
+ ret = cliprdr_send_request_filecontents(clipboard, (void*)This, instance->m_lIndex,
+ FILECONTENTS_RANGE, instance->m_lOffset.HighPart,
+ instance->m_lOffset.LowPart, cb);
if (ret < 0)
return E_FAIL;
@@ -255,9 +255,8 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream* This, void* pv,
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream* This,
- const void* pv,
- ULONG cb, ULONG* pcbWritten)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream* This, const void* pv, ULONG cb,
+ ULONG* pcbWritten)
{
(void)This;
(void)pv;
@@ -266,12 +265,11 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Write(IStream* This,
return STG_E_ACCESSDENIED;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream* This,
- LARGE_INTEGER dlibMove,
- DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream* This, LARGE_INTEGER dlibMove,
+ DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
{
ULONGLONG newoffset;
- CliprdrStream* instance = (CliprdrStream*) This;
+ CliprdrStream* instance = (CliprdrStream*)This;
if (!instance)
return E_INVALIDARG;
@@ -307,18 +305,16 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Seek(IStream* This,
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_SetSize(IStream* This,
- ULARGE_INTEGER libNewSize)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_SetSize(IStream* This, ULARGE_INTEGER libNewSize)
{
(void)This;
(void)libNewSize;
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream* This,
- IStream* pstm,
- ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead,
- ULARGE_INTEGER* pcbWritten)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream* This, IStream* pstm,
+ ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead,
+ ULARGE_INTEGER* pcbWritten)
{
(void)This;
(void)pstm;
@@ -328,8 +324,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_CopyTo(IStream* This,
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Commit(IStream* This,
- DWORD grfCommitFlags)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Commit(IStream* This, DWORD grfCommitFlags)
{
(void)This;
(void)grfCommitFlags;
@@ -342,9 +337,8 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Revert(IStream* This)
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream* This,
- ULARGE_INTEGER libOffset,
- ULARGE_INTEGER cb, DWORD dwLockType)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream* This, ULARGE_INTEGER libOffset,
+ ULARGE_INTEGER cb, DWORD dwLockType)
{
(void)This;
(void)libOffset;
@@ -353,9 +347,8 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_LockRegion(IStream* This,
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream* This,
- ULARGE_INTEGER libOffset,
- ULARGE_INTEGER cb, DWORD dwLockType)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream* This, ULARGE_INTEGER libOffset,
+ ULARGE_INTEGER cb, DWORD dwLockType)
{
(void)This;
(void)libOffset;
@@ -364,10 +357,10 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_UnlockRegion(IStream* This,
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream* This,
- STATSTG* pstatstg, DWORD grfStatFlag)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream* This, STATSTG* pstatstg,
+ DWORD grfStatFlag)
{
- CliprdrStream* instance = (CliprdrStream*) This;
+ CliprdrStream* instance = (CliprdrStream*)This;
if (!instance)
return E_INVALIDARG;
@@ -400,29 +393,27 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Stat(IStream* This,
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream* This,
- IStream** ppstm)
+static HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream* This, IStream** ppstm)
{
(void)This;
(void)ppstm;
return E_NOTIMPL;
}
-static CliprdrStream* CliprdrStream_New(ULONG index, void* pData,
- const FILEDESCRIPTORW* dsc)
+static CliprdrStream* CliprdrStream_New(ULONG index, void* pData, const FILEDESCRIPTORW* dsc)
{
IStream* iStream;
BOOL success = FALSE;
BOOL isDir = FALSE;
CliprdrStream* instance;
- wfClipboard* clipboard = (wfClipboard*) pData;
- instance = (CliprdrStream*) calloc(1, sizeof(CliprdrStream));
+ wfClipboard* clipboard = (wfClipboard*)pData;
+ instance = (CliprdrStream*)calloc(1, sizeof(CliprdrStream));
if (instance)
{
instance->m_Dsc = *dsc;
iStream = &instance->iStream;
- iStream->lpVtbl = (IStreamVtbl*) calloc(1, sizeof(IStreamVtbl));
+ iStream->lpVtbl = (IStreamVtbl*)calloc(1, sizeof(IStreamVtbl));
if (iStream->lpVtbl)
{
@@ -454,14 +445,14 @@ static CliprdrStream* CliprdrStream_New(ULONG index, void* pData,
if (((instance->m_Dsc.dwFlags & FD_FILESIZE) == 0) && !isDir)
{
/* get content size of this stream */
- if (cliprdr_send_request_filecontents(clipboard, (void*) instance,
- instance->m_lIndex,
- FILECONTENTS_SIZE, 0, 0, 8) == CHANNEL_RC_OK)
+ if (cliprdr_send_request_filecontents(clipboard, (void*)instance,
+ instance->m_lIndex, FILECONTENTS_SIZE, 0, 0,
+ 8) == CHANNEL_RC_OK)
{
success = TRUE;
}
- instance->m_lSize.QuadPart = *((LONGLONG*) clipboard->req_fdata);
+ instance->m_lSize.QuadPart = *((LONGLONG*)clipboard->req_fdata);
free(clipboard->req_fdata);
}
else
@@ -491,8 +482,7 @@ void CliprdrStream_Delete(CliprdrStream* instance)
* IDataObject
*/
-static LONG cliprdr_lookup_format(CliprdrDataObject* instance,
- FORMATETC* pFormatEtc)
+static LONG cliprdr_lookup_format(CliprdrDataObject* instance, FORMATETC* pFormatEtc)
{
ULONG i;
@@ -512,8 +502,8 @@ static LONG cliprdr_lookup_format(CliprdrDataObject* instance,
return -1;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(
- IDataObject* This, REFIID riid, void** ppvObject)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(IDataObject* This, REFIID riid,
+ void** ppvObject)
{
(void)This;
@@ -535,7 +525,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryInterface(
static ULONG STDMETHODCALLTYPE CliprdrDataObject_AddRef(IDataObject* This)
{
- CliprdrDataObject* instance = (CliprdrDataObject*) This;
+ CliprdrDataObject* instance = (CliprdrDataObject*)This;
if (!instance)
return E_INVALIDARG;
@@ -546,7 +536,7 @@ static ULONG STDMETHODCALLTYPE CliprdrDataObject_AddRef(IDataObject* This)
static ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject* This)
{
LONG count;
- CliprdrDataObject* instance = (CliprdrDataObject*) This;
+ CliprdrDataObject* instance = (CliprdrDataObject*)This;
if (!instance)
return E_INVALIDARG;
@@ -562,18 +552,18 @@ static ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject* This)
return count;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(
- IDataObject* This, FORMATETC* pFormatEtc, STGMEDIUM* pMedium)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject* This, FORMATETC* pFormatEtc,
+ STGMEDIUM* pMedium)
{
ULONG i;
LONG idx;
- CliprdrDataObject* instance = (CliprdrDataObject*) This;
+ CliprdrDataObject* instance = (CliprdrDataObject*)This;
wfClipboard* clipboard;
if (!pFormatEtc || !pMedium || !instance)
return E_INVALIDARG;
- clipboard = (wfClipboard*) instance->m_pData;
+ clipboard = (wfClipboard*)instance->m_pData;
if (!clipboard)
return E_INVALIDARG;
@@ -584,22 +574,19 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(
pMedium->tymed = instance->m_pFormatEtc[idx].tymed;
pMedium->pUnkForRelease = 0;
- if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(
- CFSTR_FILEDESCRIPTORW))
+ if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW))
{
FILEGROUPDESCRIPTOR* dsc;
- DWORD remote = get_remote_format_id(clipboard,
- instance->m_pFormatEtc[idx].cfFormat);
+ DWORD remote = get_remote_format_id(clipboard, instance->m_pFormatEtc[idx].cfFormat);
if (cliprdr_send_data_request(clipboard, remote) != 0)
return E_UNEXPECTED;
- pMedium->hGlobal =
- clipboard->hmem; /* points to a FILEGROUPDESCRIPTOR structure */
+ pMedium->hGlobal = clipboard->hmem; /* points to a FILEGROUPDESCRIPTOR structure */
/* GlobalLock returns a pointer to the first byte of the memory block,
- * in which is a FILEGROUPDESCRIPTOR structure, whose first UINT member
- * is the number of FILEDESCRIPTOR's */
- dsc = (FILEGROUPDESCRIPTOR*) GlobalLock(clipboard->hmem);
+ * in which is a FILEGROUPDESCRIPTOR structure, whose first UINT member
+ * is the number of FILEDESCRIPTOR's */
+ dsc = (FILEGROUPDESCRIPTOR*)GlobalLock(clipboard->hmem);
instance->m_nStreams = dsc->cItems;
GlobalUnlock(clipboard->hmem);
@@ -607,15 +594,14 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(
{
if (!instance->m_pStream)
{
- instance->m_pStream = (LPSTREAM*) calloc(instance->m_nStreams,
- sizeof(LPSTREAM));
+ instance->m_pStream = (LPSTREAM*)calloc(instance->m_nStreams, sizeof(LPSTREAM));
if (instance->m_pStream)
{
for (i = 0; i < instance->m_nStreams; i++)
{
- instance->m_pStream[i] = (IStream*) CliprdrStream_New(i, clipboard,
- &dsc->fgd[i]);
+ instance->m_pStream[i] =
+ (IStream*)CliprdrStream_New(i, clipboard, &dsc->fgd[i]);
if (!instance->m_pStream[i])
return E_OUTOFMEMORY;
@@ -636,8 +622,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(
return E_OUTOFMEMORY;
}
}
- else if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(
- CFSTR_FILECONTENTS))
+ else if (instance->m_pFormatEtc[idx].cfFormat == RegisterClipboardFormat(CFSTR_FILECONTENTS))
{
if (pFormatEtc->lindex < instance->m_nStreams)
{
@@ -653,8 +638,9 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(
- IDataObject* This, FORMATETC* pformatetc, STGMEDIUM* pmedium)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(IDataObject* This,
+ FORMATETC* pformatetc,
+ STGMEDIUM* pmedium)
{
(void)This;
(void)pformatetc;
@@ -662,10 +648,10 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetDataHere(
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(
- IDataObject* This, FORMATETC* pformatetc)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(IDataObject* This,
+ FORMATETC* pformatetc)
{
- CliprdrDataObject* instance = (CliprdrDataObject*) This;
+ CliprdrDataObject* instance = (CliprdrDataObject*)This;
if (!pformatetc)
return E_INVALIDARG;
@@ -676,8 +662,9 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_QueryGetData(
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(
- IDataObject* This, FORMATETC* pformatectIn, FORMATETC* pformatetcOut)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(IDataObject* This,
+ FORMATETC* pformatectIn,
+ FORMATETC* pformatetcOut)
{
(void)This;
(void)pformatectIn;
@@ -689,8 +676,8 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetCanonicalFormatEtc(
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(
- IDataObject* This, FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(IDataObject* This, FORMATETC* pformatetc,
+ STGMEDIUM* pmedium, BOOL fRelease)
{
(void)This;
(void)pformatetc;
@@ -699,18 +686,19 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_SetData(
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(
- IDataObject* This, DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(IDataObject* This,
+ DWORD dwDirection,
+ IEnumFORMATETC** ppenumFormatEtc)
{
- CliprdrDataObject* instance = (CliprdrDataObject*) This;
+ CliprdrDataObject* instance = (CliprdrDataObject*)This;
if (!instance || !ppenumFormatEtc)
return E_INVALIDARG;
if (dwDirection == DATADIR_GET)
{
- *ppenumFormatEtc = (IEnumFORMATETC*) CliprdrEnumFORMATETC_New(
- instance->m_nNumFormats, instance->m_pFormatEtc);
+ *ppenumFormatEtc = (IEnumFORMATETC*)CliprdrEnumFORMATETC_New(instance->m_nNumFormats,
+ instance->m_pFormatEtc);
return (*ppenumFormatEtc) ? S_OK : E_OUTOFMEMORY;
}
else
@@ -719,9 +707,9 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumFormatEtc(
}
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(
- IDataObject* This, FORMATETC* pformatetc, DWORD advf,
- IAdviseSink* pAdvSink, DWORD* pdwConnection)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(IDataObject* This, FORMATETC* pformatetc,
+ DWORD advf, IAdviseSink* pAdvSink,
+ DWORD* pdwConnection)
{
(void)This;
(void)pformatetc;
@@ -731,35 +719,34 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DAdvise(
return OLE_E_ADVISENOTSUPPORTED;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DUnadvise(
- IDataObject* This, DWORD dwConnection)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_DUnadvise(IDataObject* This, DWORD dwConnection)
{
(void)This;
(void)dwConnection;
return OLE_E_ADVISENOTSUPPORTED;
}
-static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(
- IDataObject* This, IEnumSTATDATA** ppenumAdvise)
+static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(IDataObject* This,
+ IEnumSTATDATA** ppenumAdvise)
{
(void)This;
(void)ppenumAdvise;
return OLE_E_ADVISENOTSUPPORTED;
}
-static CliprdrDataObject* CliprdrDataObject_New(
- FORMATETC* fmtetc, STGMEDIUM* stgmed, ULONG count, void* data)
+static CliprdrDataObject* CliprdrDataObject_New(FORMATETC* fmtetc, STGMEDIUM* stgmed, ULONG count,
+ void* data)
{
int i;
CliprdrDataObject* instance;
IDataObject* iDataObject;
- instance = (CliprdrDataObject*) calloc(1, sizeof(CliprdrDataObject));
+ instance = (CliprdrDataObject*)calloc(1, sizeof(CliprdrDataObject));
if (!instance)
goto error;
iDataObject = &instance->iDataObject;
- iDataObject->lpVtbl = (IDataObjectVtbl*) calloc(1, sizeof(IDataObjectVtbl));
+ iDataObject->lpVtbl = (IDataObjectVtbl*)calloc(1, sizeof(IDataObjectVtbl));
if (!iDataObject->lpVtbl)
goto error;
@@ -770,8 +757,7 @@ static CliprdrDataObject* CliprdrDataObject_New(
iDataObject->lpVtbl->GetData = CliprdrDataObject_GetData;
iDataObject->lpVtbl->GetDataHere = CliprdrDataObject_GetDataHere;
iDataObject->lpVtbl->QueryGetData = CliprdrDataObject_QueryGetData;
- iDataObject->lpVtbl->GetCanonicalFormatEtc =
- CliprdrDataObject_GetCanonicalFormatEtc;
+ iDataObject->lpVtbl->GetCanonicalFormatEtc = CliprdrDataObject_GetCanonicalFormatEtc;
iDataObject->lpVtbl->SetData = CliprdrDataObject_SetData;
iDataObject->lpVtbl->EnumFormatEtc = CliprdrDataObject_EnumFormatEtc;
iDataObject->lpVtbl->DAdvise = CliprdrDataObject_DAdvise;
@@ -785,12 +771,12 @@ static CliprdrDataObject* CliprdrDataObject_New(
if (count > 0)
{
- instance->m_pFormatEtc = (FORMATETC*) calloc(count, sizeof(FORMATETC));
+ instance->m_pFormatEtc = (FORMATETC*)calloc(count, sizeof(FORMATETC));
if (!instance->m_pFormatEtc)
goto error;
- instance->m_pStgMedium = (STGMEDIUM*) calloc(count, sizeof(STGMEDIUM));
+ instance->m_pStgMedium = (STGMEDIUM*)calloc(count, sizeof(STGMEDIUM));
if (!instance->m_pStgMedium)
goto error;
@@ -830,8 +816,7 @@ void CliprdrDataObject_Delete(CliprdrDataObject* instance)
}
}
-static BOOL wf_create_file_obj(wfClipboard* clipboard,
- IDataObject** ppDataObject)
+static BOOL wf_create_file_obj(wfClipboard* clipboard, IDataObject** ppDataObject)
{
FORMATETC fmtetc[2];
STGMEDIUM stgmeds[2];
@@ -855,8 +840,7 @@ static BOOL wf_create_file_obj(wfClipboard* clipboard,
stgmeds[1].tymed = TYMED_ISTREAM;
stgmeds[1].pstm = NULL;
stgmeds[1].pUnkForRelease = NULL;
- *ppDataObject = (IDataObject*) CliprdrDataObject_New(fmtetc, stgmeds, 2,
- clipboard);
+ *ppDataObject = (IDataObject*)CliprdrDataObject_New(fmtetc, stgmeds, 2, clipboard);
return (*ppDataObject) ? TRUE : FALSE;
}
@@ -876,15 +860,15 @@ static void cliprdr_format_deep_copy(FORMATETC* dest, FORMATETC* source)
if (source->ptd)
{
- dest->ptd = (DVTARGETDEVICE*) CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
+ dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
if (dest->ptd)
*(dest->ptd) = *(source->ptd);
}
}
-static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(
- IEnumFORMATETC* This, REFIID riid, void** ppvObject)
+static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(IEnumFORMATETC* This,
+ REFIID riid, void** ppvObject)
{
(void)This;
@@ -903,7 +887,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_QueryInterface(
static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_AddRef(IEnumFORMATETC* This)
{
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance)
return 0;
@@ -911,11 +895,10 @@ static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_AddRef(IEnumFORMATETC* This)
return InterlockedIncrement(&instance->m_lRefCount);
}
-static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(
- IEnumFORMATETC* This)
+static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(IEnumFORMATETC* This)
{
LONG count;
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance)
return 0;
@@ -933,20 +916,18 @@ static ULONG STDMETHODCALLTYPE CliprdrEnumFORMATETC_Release(
}
}
-static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC* This,
- ULONG celt,
- FORMATETC* rgelt, ULONG* pceltFetched)
+static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC* This, ULONG celt,
+ FORMATETC* rgelt, ULONG* pceltFetched)
{
- ULONG copied = 0;
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ ULONG copied = 0;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance || !celt || !rgelt)
return E_INVALIDARG;
while ((instance->m_nIndex < instance->m_nNumFormats) && (copied < celt))
{
- cliprdr_format_deep_copy(&rgelt[copied++],
- &instance->m_pFormatEtc[instance->m_nIndex++]);
+ cliprdr_format_deep_copy(&rgelt[copied++], &instance->m_pFormatEtc[instance->m_nIndex++]);
}
if (pceltFetched != 0)
@@ -955,25 +936,23 @@ static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Next(IEnumFORMATETC* This,
return (copied == celt) ? S_OK : E_FAIL;
}
-static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Skip(IEnumFORMATETC* This,
- ULONG celt)
+static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Skip(IEnumFORMATETC* This, ULONG celt)
{
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance)
return E_INVALIDARG;
- if (instance->m_nIndex + (LONG) celt > instance->m_nNumFormats)
+ if (instance->m_nIndex + (LONG)celt > instance->m_nNumFormats)
return E_FAIL;
instance->m_nIndex += celt;
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(
- IEnumFORMATETC* This)
+static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(IEnumFORMATETC* This)
{
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance)
return E_INVALIDARG;
@@ -982,26 +961,25 @@ static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Reset(
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(
- IEnumFORMATETC* This, IEnumFORMATETC** ppEnum)
+static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(IEnumFORMATETC* This,
+ IEnumFORMATETC** ppEnum)
{
- CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*) This;
+ CliprdrEnumFORMATETC* instance = (CliprdrEnumFORMATETC*)This;
if (!instance || !ppEnum)
return E_INVALIDARG;
- *ppEnum = (IEnumFORMATETC*) CliprdrEnumFORMATETC_New(instance->m_nNumFormats,
- instance->m_pFormatEtc);
+ *ppEnum =
+ (IEnumFORMATETC*)CliprdrEnumFORMATETC_New(instance->m_nNumFormats, instance->m_pFormatEtc);
if (!*ppEnum)
return E_OUTOFMEMORY;
- ((CliprdrEnumFORMATETC*) *ppEnum)->m_nIndex = instance->m_nIndex;
+ ((CliprdrEnumFORMATETC*)*ppEnum)->m_nIndex = instance->m_nIndex;
return S_OK;
}
-CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats,
- FORMATETC* pFormatEtc)
+CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pFormatEtc)
{
ULONG i;
CliprdrEnumFORMATETC* instance;
@@ -1010,14 +988,13 @@ CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats,
if ((nFormats != 0) && !pFormatEtc)
return NULL;
- instance = (CliprdrEnumFORMATETC*) calloc(1, sizeof(CliprdrEnumFORMATETC));
+ instance = (CliprdrEnumFORMATETC*)calloc(1, sizeof(CliprdrEnumFORMATETC));
if (!instance)
goto error;
iEnumFORMATETC = &instance->iEnumFORMATETC;
- iEnumFORMATETC->lpVtbl = (IEnumFORMATETCVtbl*) calloc(1,
- sizeof(IEnumFORMATETCVtbl));
+ iEnumFORMATETC->lpVtbl = (IEnumFORMATETCVtbl*)calloc(1, sizeof(IEnumFORMATETCVtbl));
if (!iEnumFORMATETC->lpVtbl)
goto error;
@@ -1035,7 +1012,7 @@ CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats,
if (nFormats > 0)
{
- instance->m_pFormatEtc = (FORMATETC*) calloc(nFormats, sizeof(FORMATETC));
+ instance->m_pFormatEtc = (FORMATETC*)calloc(nFormats, sizeof(FORMATETC));
if (!instance->m_pFormatEtc)
goto error;
@@ -1075,8 +1052,7 @@ void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance)
/***********************************************************************************/
-static UINT32 get_local_format_id_by_name(wfClipboard* clipboard,
- const TCHAR* format_name)
+static UINT32 get_local_format_id_by_name(wfClipboard* clipboard, const TCHAR* format_name)
{
size_t i;
formatMapping* map;
@@ -1097,8 +1073,7 @@ static UINT32 get_local_format_id_by_name(wfClipboard* clipboard,
if (!unicode_name)
return 0;
- MultiByteToWideChar(CP_OEMCP, 0, format_name, strlen(format_name), unicode_name,
- size);
+ MultiByteToWideChar(CP_OEMCP, 0, format_name, strlen(format_name), unicode_name, size);
#endif
if (!unicode_name)
@@ -1124,8 +1099,7 @@ static UINT32 get_local_format_id_by_name(wfClipboard* clipboard,
static INLINE BOOL file_transferring(wfClipboard* clipboard)
{
- return get_local_format_id_by_name(clipboard,
- CFSTR_FILEDESCRIPTORW) ? TRUE : FALSE;
+ return get_local_format_id_by_name(clipboard, CFSTR_FILEDESCRIPTORW) ? TRUE : FALSE;
}
static UINT32 get_remote_format_id(wfClipboard* clipboard, UINT32 local_format)
@@ -1157,8 +1131,8 @@ static void map_ensure_capacity(wfClipboard* clipboard)
size_t new_size;
formatMapping* new_map;
new_size = clipboard->map_capacity * 2;
- new_map = (formatMapping*) realloc(clipboard->format_mappings,
- sizeof(formatMapping) * new_size);
+ new_map =
+ (formatMapping*)realloc(clipboard->format_mappings, sizeof(formatMapping) * new_size);
if (!new_map)
return;
@@ -1199,23 +1173,22 @@ static UINT cliprdr_send_tempdir(wfClipboard* clipboard)
if (!clipboard)
return -1;
- if (GetEnvironmentVariableA("TEMP", tempDirectory.szTempDir,
- sizeof(tempDirectory.szTempDir)) == 0)
+ if (GetEnvironmentVariableA("TEMP", tempDirectory.szTempDir, sizeof(tempDirectory.szTempDir)) ==
+ 0)
return -1;
return clipboard->context->TempDirectory(clipboard->context, &tempDirectory);
}
-static BOOL cliprdr_GetUpdatedClipboardFormats(wfClipboard* clipboard,
- PUINT lpuiFormats, UINT cFormats, PUINT pcFormatsOut)
+static BOOL cliprdr_GetUpdatedClipboardFormats(wfClipboard* clipboard, PUINT lpuiFormats,
+ UINT cFormats, PUINT pcFormatsOut)
{
UINT index = 0;
UINT format = 0;
BOOL clipboardOpen = FALSE;
if (!clipboard->legacyApi)
- return clipboard->GetUpdatedClipboardFormats(lpuiFormats, cFormats,
- pcFormatsOut);
+ return clipboard->GetUpdatedClipboardFormats(lpuiFormats, cFormats, pcFormatsOut);
clipboardOpen = OpenClipboard(clipboard->hwnd);
@@ -1258,8 +1231,8 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard)
return ERROR_INTERNAL_ERROR;
count = CountClipboardFormats();
- numFormats = (UINT32) count;
- formats = (CLIPRDR_FORMAT*) calloc(numFormats, sizeof(CLIPRDR_FORMAT));
+ numFormats = (UINT32)count;
+ formats = (CLIPRDR_FORMAT*)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
if (!formats)
{
@@ -1290,8 +1263,7 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard)
for (index = 0; index < numFormats; index++)
{
- if (GetClipboardFormatNameA(formats[index].formatId, formatName,
- sizeof(formatName)))
+ if (GetClipboardFormatNameA(formats[index].formatId, formatName, sizeof(formatName)))
{
formats[index].formatName = _strdup(formatName);
}
@@ -1313,17 +1285,14 @@ static UINT cliprdr_send_data_request(wfClipboard* clipboard, UINT32 formatId)
UINT rc;
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
- if (!clipboard || !clipboard->context ||
- !clipboard->context->ClientFormatDataRequest)
+ if (!clipboard || !clipboard->context || !clipboard->context->ClientFormatDataRequest)
return ERROR_INTERNAL_ERROR;
formatDataRequest.requestedFormatId = formatId;
clipboard->requestedFormatId = formatId;
- rc = clipboard->context->ClientFormatDataRequest(clipboard->context,
- &formatDataRequest);
+ rc = clipboard->context->ClientFormatDataRequest(clipboard->context, &formatDataRequest);
- if (WaitForSingleObject(clipboard->response_data_event,
- INFINITE) != WAIT_OBJECT_0)
+ if (WaitForSingleObject(clipboard->response_data_event, INFINITE) != WAIT_OBJECT_0)
rc = ERROR_INTERNAL_ERROR;
else if (!ResetEvent(clipboard->response_data_event))
rc = ERROR_INTERNAL_ERROR;
@@ -1331,19 +1300,17 @@ static UINT cliprdr_send_data_request(wfClipboard* clipboard, UINT32 formatId)
return rc;
}
-UINT cliprdr_send_request_filecontents(wfClipboard* clipboard,
- const void* streamid,
- ULONG index, UINT32 flag, DWORD positionhigh,
- DWORD positionlow, ULONG nreq)
+UINT cliprdr_send_request_filecontents(wfClipboard* clipboard, const void* streamid, ULONG index,
+ UINT32 flag, DWORD positionhigh, DWORD positionlow,
+ ULONG nreq)
{
UINT rc;
CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest;
- if (!clipboard || !clipboard->context ||
- !clipboard->context->ClientFileContentsRequest)
+ if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsRequest)
return ERROR_INTERNAL_ERROR;
- fileContentsRequest.streamId = (UINT32) streamid;
+ fileContentsRequest.streamId = (UINT32)streamid;
fileContentsRequest.listIndex = index;
fileContentsRequest.dwFlags = flag;
fileContentsRequest.nPositionLow = positionlow;
@@ -1351,8 +1318,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard* clipboard,
fileContentsRequest.cbRequested = nreq;
fileContentsRequest.clipDataId = 0;
fileContentsRequest.msgFlags = 0;
- rc = clipboard->context->ClientFileContentsRequest(clipboard->context,
- &fileContentsRequest);
+ rc = clipboard->context->ClientFileContentsRequest(clipboard->context, &fileContentsRequest);
if (WaitForSingleObject(clipboard->req_fevent, INFINITE) != WAIT_OBJECT_0)
rc = ERROR_INTERNAL_ERROR;
@@ -1362,13 +1328,12 @@ UINT cliprdr_send_request_filecontents(wfClipboard* clipboard,
return rc;
}
-static UINT cliprdr_send_response_filecontents(wfClipboard* clipboard,
- UINT32 streamId, UINT32 size, BYTE* data)
+static UINT cliprdr_send_response_filecontents(wfClipboard* clipboard, UINT32 streamId, UINT32 size,
+ BYTE* data)
{
CLIPRDR_FILE_CONTENTS_RESPONSE fileContentsResponse;
- if (!clipboard || !clipboard->context ||
- !clipboard->context->ClientFileContentsResponse)
+ if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsResponse)
return ERROR_INTERNAL_ERROR;
fileContentsResponse.streamId = streamId;
@@ -1376,11 +1341,10 @@ static UINT cliprdr_send_response_filecontents(wfClipboard* clipboard,
fileContentsResponse.requestedData = data;
fileContentsResponse.msgFlags = CB_RESPONSE_OK;
return clipboard->context->ClientFileContentsResponse(clipboard->context,
- &fileContentsResponse);
+ &fileContentsResponse);
}
-static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam,
- LPARAM lParam)
+static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
static wfClipboard* clipboard = NULL;
@@ -1388,7 +1352,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam,
{
case WM_CREATE:
DEBUG_CLIPRDR("info: WM_CREATE");
- clipboard = (wfClipboard*)((CREATESTRUCT*) lParam)->lpCreateParams;
+ clipboard = (wfClipboard*)((CREATESTRUCT*)lParam)->lpCreateParams;
clipboard->hwnd = hWnd;
if (!clipboard->legacyApi)
@@ -1449,13 +1413,13 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam,
case WM_RENDERFORMAT:
DEBUG_CLIPRDR("info: WM_RENDERFORMAT");
- if (cliprdr_send_data_request(clipboard, (UINT32) wParam) != 0)
+ if (cliprdr_send_data_request(clipboard, (UINT32)wParam) != 0)
{
DEBUG_CLIPRDR("error: cliprdr_send_data_request failed.");
break;
}
- if (!SetClipboardData((UINT) wParam, clipboard->hmem))
+ if (!SetClipboardData((UINT)wParam, clipboard->hmem))
{
DEBUG_CLIPRDR("SetClipboardData failed with 0x%x", GetLastError());
@@ -1486,8 +1450,8 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam,
case WM_CHANGECBCHAIN:
if (clipboard->legacyApi)
{
- HWND hWndCurrViewer = (HWND) wParam;
- HWND hWndNextViewer = (HWND) lParam;
+ HWND hWndCurrViewer = (HWND)wParam;
+ HWND hWndNextViewer = (HWND)lParam;
if (hWndCurrViewer == clipboard->hWndNextViewer)
clipboard->hWndNextViewer = hWndNextViewer;
@@ -1555,10 +1519,9 @@ static int create_cliprdr_window(wfClipboard* clipboard)
wnd_cls.hInstance = GetModuleHandle(NULL);
wnd_cls.hIconSm = NULL;
RegisterClassEx(&wnd_cls);
- clipboard->hwnd = CreateWindowEx(WS_EX_LEFT,
- _T("ClipboardHiddenMessageProcessor"),
- _T("rdpclip"), 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, GetModuleHandle(NULL),
- clipboard);
+ clipboard->hwnd =
+ CreateWindowEx(WS_EX_LEFT, _T("ClipboardHiddenMessageProcessor"), _T("rdpclip"), 0, 0, 0, 0,
+ 0, HWND_MESSAGE, NULL, GetModuleHandle(NULL), clipboard);
if (!clipboard->hwnd)
{
@@ -1574,7 +1537,7 @@ static DWORD WINAPI cliprdr_thread_func(LPVOID arg)
int ret;
MSG msg;
BOOL mcode;
- wfClipboard* clipboard = (wfClipboard*) arg;
+ wfClipboard* clipboard = (wfClipboard*)arg;
OleInitialize(0);
if ((ret = create_cliprdr_window(clipboard)) != 0)
@@ -1638,9 +1601,8 @@ static void clear_file_array(wfClipboard* clipboard)
clipboard->nFiles = 0;
}
-static BOOL wf_cliprdr_get_file_contents(WCHAR* file_name, BYTE* buffer,
- LONG positionLow, LONG positionHigh,
- DWORD nRequested, DWORD* puSize)
+static BOOL wf_cliprdr_get_file_contents(WCHAR* file_name, BYTE* buffer, LONG positionLow,
+ LONG positionHigh, DWORD nRequested, DWORD* puSize)
{
BOOL res = FALSE;
HANDLE hFile;
@@ -1648,12 +1610,11 @@ static BOOL wf_cliprdr_get_file_contents(WCHAR* file_name, BYTE* buffer,
if (!file_name || !buffer || !puSize)
{
- WLog_ERR(TAG, "get file contents Invalid Arguments.");
+ WLog_ERR(TAG, "get file contents Invalid Arguments.");
return FALSE;
}
- hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING,
+ hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE)
@@ -1683,18 +1644,17 @@ error:
}
/* path_name has a '\' at the end. e.g. c:\newfolder\, file_name is c:\newfolder\new.txt */
-static FILEDESCRIPTORW* wf_cliprdr_get_file_descriptor(WCHAR* file_name,
- size_t pathLen)
+static FILEDESCRIPTORW* wf_cliprdr_get_file_descriptor(WCHAR* file_name, size_t pathLen)
{
HANDLE hFile;
FILEDESCRIPTORW* fd;
- fd = (FILEDESCRIPTORW*) calloc(1, sizeof(FILEDESCRIPTORW));
+ fd = (FILEDESCRIPTORW*)calloc(1, sizeof(FILEDESCRIPTORW));
if (!fd)
return NULL;
- hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ hFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
@@ -1727,13 +1687,13 @@ static BOOL wf_cliprdr_array_ensure_capacity(wfClipboard* clipboard)
FILEDESCRIPTORW** new_fd;
WCHAR** new_name;
new_size = (clipboard->file_array_size + 1) * 2;
- new_fd = (FILEDESCRIPTORW**) realloc(clipboard->fileDescriptor,
- new_size * sizeof(FILEDESCRIPTORW*));
+ new_fd = (FILEDESCRIPTORW**)realloc(clipboard->fileDescriptor,
+ new_size * sizeof(FILEDESCRIPTORW*));
if (new_fd)
clipboard->fileDescriptor = new_fd;
- new_name = (WCHAR**) realloc(clipboard->file_names, new_size * sizeof(WCHAR*));
+ new_name = (WCHAR**)realloc(clipboard->file_names, new_size * sizeof(WCHAR*));
if (new_name)
clipboard->file_names = new_name;
@@ -1747,14 +1707,14 @@ static BOOL wf_cliprdr_array_ensure_capacity(wfClipboard* clipboard)
return TRUE;
}
-static BOOL wf_cliprdr_add_to_file_arrays(wfClipboard* clipboard,
- WCHAR* full_file_name, size_t pathLen)
+static BOOL wf_cliprdr_add_to_file_arrays(wfClipboard* clipboard, WCHAR* full_file_name,
+ size_t pathLen)
{
if (!wf_cliprdr_array_ensure_capacity(clipboard))
return FALSE;
/* add to name array */
- clipboard->file_names[clipboard->nFiles] = (LPWSTR) malloc(MAX_PATH * 2);
+ clipboard->file_names[clipboard->nFiles] = (LPWSTR)malloc(MAX_PATH * 2);
if (!clipboard->file_names[clipboard->nFiles])
return FALSE;
@@ -1774,8 +1734,7 @@ static BOOL wf_cliprdr_add_to_file_arrays(wfClipboard* clipboard,
return TRUE;
}
-static BOOL wf_cliprdr_traverse_directory(wfClipboard* clipboard,
- WCHAR* Dir, size_t pathLen)
+static BOOL wf_cliprdr_traverse_directory(wfClipboard* clipboard, WCHAR* Dir, size_t pathLen)
{
HANDLE hFind;
WCHAR DirSpec[MAX_PATH];
@@ -1796,9 +1755,9 @@ static BOOL wf_cliprdr_traverse_directory(wfClipboard* clipboard,
while (FindNextFile(hFind, &FindFileData))
{
- if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0
- && wcscmp(FindFileData.cFileName, _T(".")) == 0
- || wcscmp(FindFileData.cFileName, _T("..")) == 0)
+ if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 &&
+ wcscmp(FindFileData.cFileName, _T(".")) == 0 ||
+ wcscmp(FindFileData.cFileName, _T("..")) == 0)
{
continue;
}
@@ -1837,22 +1796,17 @@ static UINT wf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
- if (!clipboard || !clipboard->context ||
- !clipboard->context->ClientCapabilities)
+ if (!clipboard || !clipboard->context || !clipboard->context->ClientCapabilities)
return ERROR_INTERNAL_ERROR;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
- (generalCapabilitySet);
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = CB_CAPS_VERSION_2;
generalCapabilitySet.generalFlags =
- CB_USE_LONG_FORMAT_NAMES |
- CB_STREAM_FILECLIP_ENABLED |
- CB_FILECLIP_NO_FILE_PATHS;
- return clipboard->context->ClientCapabilities(clipboard->context,
- &capabilities);
+ CB_USE_LONG_FORMAT_NAMES | CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS;
+ return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
}
/**
@@ -1864,7 +1818,7 @@ static UINT wf_cliprdr_monitor_ready(CliprdrClientContext* context,
const CLIPRDR_MONITOR_READY* monitorReady)
{
UINT rc;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
if (!context || !monitorReady)
return ERROR_INTERNAL_ERROR;
@@ -1884,11 +1838,11 @@ static UINT wf_cliprdr_monitor_ready(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_cliprdr_server_capabilities(CliprdrClientContext* context,
- const CLIPRDR_CAPABILITIES* capabilities)
+ const CLIPRDR_CAPABILITIES* capabilities)
{
UINT32 index;
CLIPRDR_CAPABILITY_SET* capabilitySet;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
if (!context || !capabilities)
return ERROR_INTERNAL_ERROR;
@@ -1900,8 +1854,8 @@ static UINT wf_cliprdr_server_capabilities(CliprdrClientContext* context,
if ((capabilitySet->capabilitySetType == CB_CAPSTYPE_GENERAL) &&
(capabilitySet->capabilitySetLength >= CB_CAPSTYPE_GENERAL_LEN))
{
- CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet
- = (CLIPRDR_GENERAL_CAPABILITY_SET*) capabilitySet;
+ CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet =
+ (CLIPRDR_GENERAL_CAPABILITY_SET*)capabilitySet;
clipboard->capabilities = generalCapabilitySet->generalFlags;
break;
}
@@ -1916,13 +1870,13 @@ static UINT wf_cliprdr_server_capabilities(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_LIST* formatList)
+ const CLIPRDR_FORMAT_LIST* formatList)
{
UINT rc = ERROR_INTERNAL_ERROR;
UINT32 i;
formatMapping* mapping;
CLIPRDR_FORMAT* format;
- wfClipboard* clipboard = (wfClipboard*) context->custom;
+ wfClipboard* clipboard = (wfClipboard*)context->custom;
if (!clear_format_map(clipboard))
return ERROR_INTERNAL_ERROR;
@@ -1936,15 +1890,14 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context,
if (format->formatName)
{
int size = MultiByteToWideChar(CP_UTF8, 0, format->formatName,
- strlen(format->formatName),
- NULL, 0);
+ strlen(format->formatName), NULL, 0);
mapping->name = calloc(size + 1, sizeof(WCHAR));
if (mapping->name)
{
MultiByteToWideChar(CP_UTF8, 0, format->formatName, strlen(format->formatName),
mapping->name, size);
- mapping->local_format_id = RegisterClipboardFormatW((LPWSTR) mapping->name);
+ mapping->local_format_id = RegisterClipboardFormatW((LPWSTR)mapping->name);
}
}
else
@@ -1969,7 +1922,7 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context,
if (EmptyClipboard())
{
- for (i = 0; i < (UINT32) clipboard->map_size; i++)
+ for (i = 0; i < (UINT32)clipboard->map_size; i++)
SetClipboardData(clipboard->format_mappings[i].local_format_id, NULL);
rc = CHANNEL_RC_OK;
@@ -1987,9 +1940,9 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_format_list_response(CliprdrClientContext*
- context,
- const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+wf_cliprdr_server_format_list_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
(void)context;
(void)formatListResponse;
@@ -2005,8 +1958,9 @@ static UINT wf_cliprdr_server_format_list_response(CliprdrClientContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_lock_clipboard_data(CliprdrClientContext* context,
- const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
+static UINT
+wf_cliprdr_server_lock_clipboard_data(CliprdrClientContext* context,
+ const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
{
(void)context;
(void)lockClipboardData;
@@ -2018,17 +1972,16 @@ static UINT wf_cliprdr_server_lock_clipboard_data(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_unlock_clipboard_data(CliprdrClientContext*
- context,
- const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
+static UINT
+wf_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* context,
+ const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
{
(void)context;
(void)unlockClipboardData;
return CHANNEL_RC_OK;
}
-static BOOL wf_cliprdr_process_filename(wfClipboard* clipboard,
- WCHAR* wFileName, size_t str_len)
+static BOOL wf_cliprdr_process_filename(wfClipboard* clipboard, WCHAR* wFileName, size_t str_len)
{
size_t pathLen;
size_t offset = str_len;
@@ -2050,7 +2003,7 @@ static BOOL wf_cliprdr_process_filename(wfClipboard* clipboard,
if (!wf_cliprdr_add_to_file_arrays(clipboard, wFileName, pathLen))
return FALSE;
- if ((clipboard->fileDescriptor[clipboard->nFiles - 1]->dwFileAttributes&
+ if ((clipboard->fileDescriptor[clipboard->nFiles - 1]->dwFileAttributes &
FILE_ATTRIBUTE_DIRECTORY) != 0)
{
/* this is a directory */
@@ -2066,8 +2019,9 @@ static BOOL wf_cliprdr_process_filename(wfClipboard* clipboard,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+static UINT
+wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
UINT rc;
size_t size = 0;
@@ -2081,7 +2035,7 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
if (!context || !formatDataRequest)
return ERROR_INTERNAL_ERROR;
- clipboard = (wfClipboard*) context->custom;
+ clipboard = (wfClipboard*)context->custom;
if (!clipboard)
return ERROR_INTERNAL_ERROR;
@@ -2119,7 +2073,7 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
goto exit;
}
- dropFiles = (DROPFILES*) GlobalLock(stg_medium.hGlobal);
+ dropFiles = (DROPFILES*)GlobalLock(stg_medium.hGlobal);
if (!dropFiles)
{
@@ -2144,13 +2098,13 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
{
char* p;
- for (p = (char*)((char*)dropFiles + dropFiles->pFiles);
- (len = strlen(p)) > 0; p += len + 1, clipboard->nFiles++)
+ for (p = (char*)((char*)dropFiles + dropFiles->pFiles); (len = strlen(p)) > 0;
+ p += len + 1, clipboard->nFiles++)
{
int cchWideChar;
WCHAR* wFileName;
cchWideChar = MultiByteToWideChar(CP_ACP, MB_COMPOSITE, p, len, NULL, 0);
- wFileName = (LPWSTR) calloc(cchWideChar, sizeof(WCHAR));
+ wFileName = (LPWSTR)calloc(cchWideChar, sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, MB_COMPOSITE, p, len, wFileName, cchWideChar);
wf_cliprdr_process_filename(clipboard, wFileName, cchWideChar);
}
@@ -2160,7 +2114,7 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
ReleaseStgMedium(&stg_medium);
exit:
size = 4 + clipboard->nFiles * sizeof(FILEDESCRIPTORW);
- groupDsc = (FILEGROUPDESCRIPTORW*) malloc(size);
+ groupDsc = (FILEGROUPDESCRIPTORW*)malloc(size);
if (groupDsc)
{
@@ -2190,8 +2144,8 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
return ERROR_INTERNAL_ERROR;
}
- globlemem = (char*) GlobalLock(hClipdata);
- size = (int) GlobalSize(hClipdata);
+ globlemem = (char*)GlobalLock(hClipdata);
+ size = (int)GlobalSize(hClipdata);
buff = malloc(size);
CopyMemory(buff, globlemem, size);
GlobalUnlock(hClipdata);
@@ -2200,9 +2154,8 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
response.msgFlags = CB_RESPONSE_OK;
response.dataLen = size;
- response.requestedFormatData = (BYTE*) buff;
- rc = clipboard->context->ClientFormatDataResponse(clipboard->context,
- &response);
+ response.requestedFormatData = (BYTE*)buff;
+ rc = clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
free(buff);
return rc;
}
@@ -2212,9 +2165,9 @@ static UINT wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_format_data_response(CliprdrClientContext*
- context,
- const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+wf_cliprdr_server_format_data_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
BYTE* data;
HANDLE hMem;
@@ -2226,7 +2179,7 @@ static UINT wf_cliprdr_server_format_data_response(CliprdrClientContext*
if (formatDataResponse->msgFlags != CB_RESPONSE_OK)
return E_FAIL;
- clipboard = (wfClipboard*) context->custom;
+ clipboard = (wfClipboard*)context->custom;
if (!clipboard)
return ERROR_INTERNAL_ERROR;
@@ -2236,7 +2189,7 @@ static UINT wf_cliprdr_server_format_data_response(CliprdrClientContext*
if (!hMem)
return ERROR_INTERNAL_ERROR;
- data = (BYTE*) GlobalLock(hMem);
+ data = (BYTE*)GlobalLock(hMem);
if (!data)
{
@@ -2244,8 +2197,7 @@ static UINT wf_cliprdr_server_format_data_response(CliprdrClientContext*
return ERROR_INTERNAL_ERROR;
}
- CopyMemory(data, formatDataResponse->requestedFormatData,
- formatDataResponse->dataLen);
+ CopyMemory(data, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
if (!GlobalUnlock(hMem) && GetLastError())
{
@@ -2266,18 +2218,18 @@ static UINT wf_cliprdr_server_format_data_response(CliprdrClientContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
- context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+wf_cliprdr_server_file_contents_request(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
DWORD uSize = 0;
BYTE* pData = NULL;
- HRESULT hRet = S_OK;
+ HRESULT hRet = S_OK;
FORMATETC vFormatEtc;
LPDATAOBJECT pDataObj = NULL;
STGMEDIUM vStgMedium;
BOOL bIsStreamFile = TRUE;
- static LPSTREAM pStreamStc = NULL;
+ static LPSTREAM pStreamStc = NULL;
static UINT32 uStreamIdStc = 0;
wfClipboard* clipboard;
UINT rc = ERROR_INTERNAL_ERROR;
@@ -2287,7 +2239,7 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
if (!context || !fileContentsRequest)
return ERROR_INTERNAL_ERROR;
- clipboard = (wfClipboard*) context->custom;
+ clipboard = (wfClipboard*)context->custom;
if (!clipboard)
return ERROR_INTERNAL_ERROR;
@@ -2296,7 +2248,7 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
if (fileContentsRequest->dwFlags == FILECONTENTS_SIZE)
cbRequested = sizeof(UINT64);
- pData = (BYTE*) calloc(1, cbRequested);
+ pData = (BYTE*)calloc(1, cbRequested);
if (!pData)
goto error;
@@ -2305,7 +2257,7 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
if (FAILED(hRet))
{
- WLog_ERR(TAG, "filecontents: get ole clipboard failed.");
+ WLog_ERR(TAG, "filecontents: get ole clipboard failed.");
goto error;
}
@@ -2354,8 +2306,7 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
break;
}
}
- }
- while (hRet == S_OK);
+ } while (hRet == S_OK);
}
}
@@ -2369,8 +2320,8 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
if (hRet == S_OK)
{
- *((UINT32*) &pData[0]) = vStatStg.cbSize.LowPart;
- *((UINT32*) &pData[4]) = vStatStg.cbSize.HighPart;
+ *((UINT32*)&pData[0]) = vStatStg.cbSize.LowPart;
+ *((UINT32*)&pData[4]) = vStatStg.cbSize.HighPart;
uSize = cbRequested;
}
}
@@ -2383,17 +2334,16 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
hRet = IStream_Seek(pStreamStc, dlibMove, STREAM_SEEK_SET, &dlibNewPosition);
if (SUCCEEDED(hRet))
- hRet = IStream_Read(pStreamStc, pData, cbRequested,
- (PULONG) &uSize);
+ hRet = IStream_Read(pStreamStc, pData, cbRequested, (PULONG)&uSize);
}
}
else
{
if (fileContentsRequest->dwFlags == FILECONTENTS_SIZE)
{
- *((UINT32*) &pData[0]) =
+ *((UINT32*)&pData[0]) =
clipboard->fileDescriptor[fileContentsRequest->listIndex]->nFileSizeLow;
- *((UINT32*) &pData[4]) =
+ *((UINT32*)&pData[4]) =
clipboard->fileDescriptor[fileContentsRequest->listIndex]->nFileSizeHigh;
uSize = cbRequested;
}
@@ -2401,9 +2351,9 @@ static UINT wf_cliprdr_server_file_contents_request(CliprdrClientContext*
{
BOOL bRet;
bRet = wf_cliprdr_get_file_contents(
- clipboard->file_names[fileContentsRequest->listIndex], pData,
- fileContentsRequest->nPositionLow, fileContentsRequest->nPositionHigh,
- cbRequested, &uSize);
+ clipboard->file_names[fileContentsRequest->listIndex], pData,
+ fileContentsRequest->nPositionLow, fileContentsRequest->nPositionHigh, cbRequested,
+ &uSize);
if (bRet == FALSE)
{
@@ -2426,9 +2376,8 @@ error:
pData = NULL;
}
- sRc = cliprdr_send_response_filecontents(clipboard,
- fileContentsRequest->streamId,
- uSize, pData);
+ sRc =
+ cliprdr_send_response_filecontents(clipboard, fileContentsRequest->streamId, uSize, pData);
free(pData);
if (sRc != CHANNEL_RC_OK)
@@ -2442,9 +2391,9 @@ error:
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT wf_cliprdr_server_file_contents_response(CliprdrClientContext*
- context,
- const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
+static UINT
+wf_cliprdr_server_file_contents_response(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
{
wfClipboard* clipboard;
@@ -2454,13 +2403,13 @@ static UINT wf_cliprdr_server_file_contents_response(CliprdrClientContext*
if (fileContentsResponse->msgFlags != CB_RESPONSE_OK)
return E_FAIL;
- clipboard = (wfClipboard*) context->custom;
+ clipboard = (wfClipboard*)context->custom;
if (!clipboard)
return ERROR_INTERNAL_ERROR;
clipboard->req_fsize = fileContentsResponse->cbRequested;
- clipboard->req_fdata = (char*) malloc(fileContentsResponse->cbRequested);
+ clipboard->req_fdata = (char*)malloc(fileContentsResponse->cbRequested);
if (!clipboard->req_fdata)
return ERROR_INTERNAL_ERROR;
@@ -2480,12 +2429,12 @@ static UINT wf_cliprdr_server_file_contents_response(CliprdrClientContext*
BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr)
{
wfClipboard* clipboard;
- rdpContext* context = (rdpContext*) wfc;
+ rdpContext* context = (rdpContext*)wfc;
if (!context || !cliprdr)
return FALSE;
- wfc->clipboard = (wfClipboard*) calloc(1, sizeof(wfClipboard));
+ wfc->clipboard = (wfClipboard*)calloc(1, sizeof(wfClipboard));
if (!wfc->clipboard)
return FALSE;
@@ -2501,21 +2450,20 @@ BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr)
if (clipboard->hUser32)
{
- clipboard->AddClipboardFormatListener = (fnAddClipboardFormatListener)
- GetProcAddress(clipboard->hUser32, "AddClipboardFormatListener");
- clipboard->RemoveClipboardFormatListener = (fnRemoveClipboardFormatListener)
- GetProcAddress(clipboard->hUser32, "RemoveClipboardFormatListener");
- clipboard->GetUpdatedClipboardFormats = (fnGetUpdatedClipboardFormats)
- GetProcAddress(clipboard->hUser32, "GetUpdatedClipboardFormats");
+ clipboard->AddClipboardFormatListener = (fnAddClipboardFormatListener)GetProcAddress(
+ clipboard->hUser32, "AddClipboardFormatListener");
+ clipboard->RemoveClipboardFormatListener = (fnRemoveClipboardFormatListener)GetProcAddress(
+ clipboard->hUser32, "RemoveClipboardFormatListener");
+ clipboard->GetUpdatedClipboardFormats = (fnGetUpdatedClipboardFormats)GetProcAddress(
+ clipboard->hUser32, "GetUpdatedClipboardFormats");
}
- if (!(clipboard->hUser32 && clipboard->AddClipboardFormatListener
- && clipboard->RemoveClipboardFormatListener
- && clipboard->GetUpdatedClipboardFormats))
+ if (!(clipboard->hUser32 && clipboard->AddClipboardFormatListener &&
+ clipboard->RemoveClipboardFormatListener && clipboard->GetUpdatedClipboardFormats))
clipboard->legacyApi = TRUE;
- if (!(clipboard->format_mappings = (formatMapping*) calloc(clipboard->map_capacity,
- sizeof(formatMapping))))
+ if (!(clipboard->format_mappings =
+ (formatMapping*)calloc(clipboard->map_capacity, sizeof(formatMapping))))
goto error;
if (!(clipboard->response_data_event = CreateEvent(NULL, TRUE, FALSE, NULL)))
@@ -2537,7 +2485,7 @@ BOOL wf_cliprdr_init(wfContext* wfc, CliprdrClientContext* cliprdr)
cliprdr->ServerFormatDataResponse = wf_cliprdr_server_format_data_response;
cliprdr->ServerFileContentsRequest = wf_cliprdr_server_file_contents_request;
cliprdr->ServerFileContentsResponse = wf_cliprdr_server_file_contents_response;
- cliprdr->custom = (void*) wfc->clipboard;
+ cliprdr->custom = (void*)wfc->clipboard;
return TRUE;
error:
wf_cliprdr_uninit(wfc, cliprdr);
diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c
index 9c3395a78..7de3487fb 100644
--- a/client/Windows/wf_event.c
+++ b/client/Windows/wf_event.c
@@ -36,13 +36,12 @@
static HWND g_focus_hWnd;
-#define X_POS(lParam) ((UINT16) (lParam & 0xFFFF))
-#define Y_POS(lParam) ((UINT16) ((lParam >> 16) & 0xFFFF))
+#define X_POS(lParam) ((UINT16)(lParam & 0xFFFF))
+#define Y_POS(lParam) ((UINT16)((lParam >> 16) & 0xFFFF))
-static BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
- HDC hdcSrc, int x1, int y1, DWORD rop);
-static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
- UINT16 x, UINT16 y);
+static BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1,
+ int y1, DWORD rop);
+static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
#if (_WIN32_WINNT >= 0x0500)
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags,
UINT16 buttonMask, UINT16 x, UINT16 y);
@@ -53,8 +52,7 @@ static BOOL g_flipping_out;
static BOOL alt_ctrl_down()
{
- return ((GetAsyncKeyState(VK_CONTROL) & 0x8000) ||
- (GetAsyncKeyState(VK_MENU) & 0x8000));
+ return ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || (GetAsyncKeyState(VK_MENU) & 0x8000));
}
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
@@ -63,8 +61,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
DWORD rdp_scancode;
rdpInput* input;
PKBDLLHOOKSTRUCT p;
- DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd,
- nCode, wParam);
+ DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd, nCode, wParam);
if (g_flipping_in)
{
@@ -82,14 +79,14 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
- wfc = (wfContext*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
- p = (PKBDLLHOOKSTRUCT) lParam;
+ wfc = (wfContext*)GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
+ p = (PKBDLLHOOKSTRUCT)lParam;
if (!wfc || !p)
return 1;
input = wfc->context.input;
- rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
+ rdp_scancode = MAKE_RDP_SCANCODE((BYTE)p->scanCode, p->flags & LLKHF_EXTENDED);
DEBUG_KBD("keydown %d scanCode 0x%08lX flags 0x%08lX vkCode 0x%08lX",
(wParam == WM_KEYDOWN), p->scanCode, p->flags, p->vkCode);
@@ -114,7 +111,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
else if (rdp_scancode == RDP_SCANCODE_NUMLOCK)
{
/* Windows sends Pause as if it was a RDP NumLock (handled above).
- * It must however be sent as a one-shot Ctrl+NumLock */
+ * It must however be sent as a one-shot Ctrl+NumLock */
if (wParam == WM_KEYDOWN)
{
DEBUG_KBD("Pause, sent as Ctrl+NumLock");
@@ -136,12 +133,12 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
rdp_scancode = RDP_SCANCODE_RSHIFT;
}
- freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP),
- rdp_scancode);
+ freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP), rdp_scancode);
- if (p->vkCode == VK_NUMLOCK || p->vkCode == VK_CAPITAL
- || p->vkCode == VK_SCROLL || p->vkCode == VK_KANA)
- DEBUG_KBD("lock keys are processed on client side too to toggle their indicators");
+ if (p->vkCode == VK_NUMLOCK || p->vkCode == VK_CAPITAL || p->vkCode == VK_SCROLL ||
+ p->vkCode == VK_KANA)
+ DEBUG_KBD(
+ "lock keys are processed on client side too to toggle their indicators");
else
return 1;
@@ -192,15 +189,15 @@ void wf_event_focus_in(wfContext* wfc)
input->MouseEvent(input, PTR_FLAGS_MOVE, (UINT16)pt.x, (UINT16)pt.y);
}
-static BOOL wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
- WPARAM wParam, LPARAM lParam, BOOL horizontal, UINT16 x, UINT16 y)
+static BOOL wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam,
+ LPARAM lParam, BOOL horizontal, UINT16 x, UINT16 y)
{
int delta;
UINT16 flags = 0;
rdpInput* input;
DefWindowProc(hWnd, Msg, wParam, lParam);
input = wfc->context.input;
- delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
+ delta = ((signed short)HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
if (horizontal)
flags |= PTR_FLAGS_HWHEEL;
@@ -225,7 +222,7 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
if (settings->SmartSizing && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
{
- rect = (LPRECT) wParam;
+ rect = (LPRECT)wParam;
switch (lParam)
{
@@ -233,8 +230,8 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
// Adjust height
- rect->bottom = rect->top + settings->DesktopHeight * (rect->right -
- rect->left) / settings->DesktopWidth;
+ rect->bottom = rect->top + settings->DesktopHeight * (rect->right - rect->left) /
+ settings->DesktopWidth;
break;
case WMSZ_TOP:
@@ -242,21 +239,20 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
case WMSZ_TOPRIGHT:
// Adjust width
rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) /
- settings->DesktopHeight;
+ settings->DesktopHeight;
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
// adjust width
- rect->left = rect->right - (settings->DesktopWidth * (rect->bottom -
- rect->top) / settings->DesktopHeight);
+ rect->left = rect->right - (settings->DesktopWidth * (rect->bottom - rect->top) /
+ settings->DesktopHeight);
break;
}
}
}
-LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
- LPARAM lParam)
+LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
LONG_PTR ptr;
@@ -269,7 +265,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
SCROLLINFO si;
processed = TRUE;
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
- wfc = (wfContext*) ptr;
+ wfc = (wfContext*)ptr;
if (wfc != NULL)
{
@@ -281,8 +277,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
case WM_MOVE:
if (!wfc->disablewindowtracking)
{
- int x = (int)(short) LOWORD(lParam);
- int y = (int)(short) HIWORD(lParam);
+ int x = (int)(short)LOWORD(lParam);
+ int y = (int)(short)HIWORD(lParam);
wfc->client_x = x;
wfc->client_y = y;
}
@@ -297,11 +293,11 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
else
{
// Set maximum window size for resizing
- minmax = (MINMAXINFO*) lParam;
+ minmax = (MINMAXINFO*)lParam;
- //always use the last determined canvas diff, because it could be
- //that the window is minimized when this gets called
- //wf_update_canvas_diff(wfc);
+ // always use the last determined canvas diff, because it could be
+ // that the window is minimized when this gets called
+ // wf_update_canvas_diff(wfc);
if (!wfc->fullscreen)
{
@@ -332,10 +328,12 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
{
wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));
- // Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
+ // Workaround: when the window is maximized, the call to "ShowScrollBars"
+ // returns TRUE but has no effect.
if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left,
- windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);
+ windowRect.bottom - windowRect.top,
+ SWP_NOMOVE | SWP_FRAMECHANGED);
}
break;
@@ -346,7 +344,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
case WM_ERASEBKGND:
/* Say we handled it - prevents flickering */
- return (LRESULT) 1;
+ return (LRESULT)1;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
@@ -363,12 +361,14 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
case WM_XBUTTONDOWN:
wf_scale_mouse_event_ex(wfc, input, PTR_XFLAGS_DOWN, GET_XBUTTON_WPARAM(wParam),
- X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
+ X_POS(lParam) - wfc->offset_x,
+ Y_POS(lParam) - wfc->offset_y);
break;
case WM_XBUTTONUP:
wf_scale_mouse_event_ex(wfc, input, 0, GET_XBUTTON_WPARAM(wParam),
- X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
+ X_POS(lParam) - wfc->offset_x,
+ Y_POS(lParam) - wfc->offset_y);
break;
#endif
@@ -378,8 +378,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
break;
case WM_MBUTTONUP:
- wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON3,
- X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
+ wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON3, X_POS(lParam) - wfc->offset_x,
+ Y_POS(lParam) - wfc->offset_y);
break;
case WM_LBUTTONDOWN:
@@ -388,8 +388,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
break;
case WM_LBUTTONUP:
- wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1,
- X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
+ wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x,
+ Y_POS(lParam) - wfc->offset_y);
break;
case WM_RBUTTONDOWN:
@@ -398,8 +398,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
break;
case WM_RBUTTONUP:
- wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2,
- X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
+ wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x,
+ Y_POS(lParam) - wfc->offset_y);
break;
case WM_MOUSEMOVE:
@@ -432,161 +432,159 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
break;
case WM_HSCROLL:
+ {
+ int xDelta; // xDelta = new_pos - current_pos
+ int xNewPos; // new position
+ int yDelta = 0;
+
+ switch (LOWORD(wParam))
{
- int xDelta; // xDelta = new_pos - current_pos
- int xNewPos; // new position
- int yDelta = 0;
-
- switch (LOWORD(wParam))
- {
- // User clicked the scroll bar shaft left of the scroll box.
- case SB_PAGEUP:
- xNewPos = wfc->xCurrentScroll - 50;
- break;
-
- // User clicked the scroll bar shaft right of the scroll box.
- case SB_PAGEDOWN:
- xNewPos = wfc->xCurrentScroll + 50;
- break;
-
- // User clicked the left arrow.
- case SB_LINEUP:
- xNewPos = wfc->xCurrentScroll - 5;
- break;
-
- // User clicked the right arrow.
- case SB_LINEDOWN:
- xNewPos = wfc->xCurrentScroll + 5;
- break;
-
- // User dragged the scroll box.
- case SB_THUMBPOSITION:
- xNewPos = HIWORD(wParam);
- break;
-
- // user is dragging the scrollbar
- case SB_THUMBTRACK :
- xNewPos = HIWORD(wParam);
- break;
-
- default:
- xNewPos = wfc->xCurrentScroll;
- }
-
- // New position must be between 0 and the screen width.
- xNewPos = MAX(0, xNewPos);
- xNewPos = MIN(wfc->xMaxScroll, xNewPos);
-
- // If the current position does not change, do not scroll.
- if (xNewPos == wfc->xCurrentScroll)
+ // User clicked the scroll bar shaft left of the scroll box.
+ case SB_PAGEUP:
+ xNewPos = wfc->xCurrentScroll - 50;
break;
- // Determine the amount scrolled (in pixels).
- xDelta = xNewPos - wfc->xCurrentScroll;
- // Reset the current scroll position.
- wfc->xCurrentScroll = xNewPos;
- // Scroll the window. (The system repaints most of the
- // client area when ScrollWindowEx is called; however, it is
- // necessary to call UpdateWindow in order to repaint the
- // rectangle of pixels that were invalidated.)
- ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
- (CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
- SW_INVALIDATE);
- UpdateWindow(wfc->hwnd);
- // Reset the scroll bar.
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS;
- si.nPos = wfc->xCurrentScroll;
- SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
+ // User clicked the scroll bar shaft right of the scroll box.
+ case SB_PAGEDOWN:
+ xNewPos = wfc->xCurrentScroll + 50;
+ break;
+
+ // User clicked the left arrow.
+ case SB_LINEUP:
+ xNewPos = wfc->xCurrentScroll - 5;
+ break;
+
+ // User clicked the right arrow.
+ case SB_LINEDOWN:
+ xNewPos = wfc->xCurrentScroll + 5;
+ break;
+
+ // User dragged the scroll box.
+ case SB_THUMBPOSITION:
+ xNewPos = HIWORD(wParam);
+ break;
+
+ // user is dragging the scrollbar
+ case SB_THUMBTRACK:
+ xNewPos = HIWORD(wParam);
+ break;
+
+ default:
+ xNewPos = wfc->xCurrentScroll;
}
- break;
+
+ // New position must be between 0 and the screen width.
+ xNewPos = MAX(0, xNewPos);
+ xNewPos = MIN(wfc->xMaxScroll, xNewPos);
+
+ // If the current position does not change, do not scroll.
+ if (xNewPos == wfc->xCurrentScroll)
+ break;
+
+ // Determine the amount scrolled (in pixels).
+ xDelta = xNewPos - wfc->xCurrentScroll;
+ // Reset the current scroll position.
+ wfc->xCurrentScroll = xNewPos;
+ // Scroll the window. (The system repaints most of the
+ // client area when ScrollWindowEx is called; however, it is
+ // necessary to call UpdateWindow in order to repaint the
+ // rectangle of pixels that were invalidated.)
+ ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*)NULL, (CONST RECT*)NULL,
+ (HRGN)NULL, (PRECT)NULL, SW_INVALIDATE);
+ UpdateWindow(wfc->hwnd);
+ // Reset the scroll bar.
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = wfc->xCurrentScroll;
+ SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
+ }
+ break;
case WM_VSCROLL:
+ {
+ int xDelta = 0;
+ int yDelta; // yDelta = new_pos - current_pos
+ int yNewPos; // new position
+
+ switch (LOWORD(wParam))
{
- int xDelta = 0;
- int yDelta; // yDelta = new_pos - current_pos
- int yNewPos; // new position
-
- switch (LOWORD(wParam))
- {
- // User clicked the scroll bar shaft above the scroll box.
- case SB_PAGEUP:
- yNewPos = wfc->yCurrentScroll - 50;
- break;
-
- // User clicked the scroll bar shaft below the scroll box.
- case SB_PAGEDOWN:
- yNewPos = wfc->yCurrentScroll + 50;
- break;
-
- // User clicked the top arrow.
- case SB_LINEUP:
- yNewPos = wfc->yCurrentScroll - 5;
- break;
-
- // User clicked the bottom arrow.
- case SB_LINEDOWN:
- yNewPos = wfc->yCurrentScroll + 5;
- break;
-
- // User dragged the scroll box.
- case SB_THUMBPOSITION:
- yNewPos = HIWORD(wParam);
- break;
-
- // user is dragging the scrollbar
- case SB_THUMBTRACK :
- yNewPos = HIWORD(wParam);
- break;
-
- default:
- yNewPos = wfc->yCurrentScroll;
- }
-
- // New position must be between 0 and the screen height.
- yNewPos = MAX(0, yNewPos);
- yNewPos = MIN(wfc->yMaxScroll, yNewPos);
-
- // If the current position does not change, do not scroll.
- if (yNewPos == wfc->yCurrentScroll)
+ // User clicked the scroll bar shaft above the scroll box.
+ case SB_PAGEUP:
+ yNewPos = wfc->yCurrentScroll - 50;
break;
- // Determine the amount scrolled (in pixels).
- yDelta = yNewPos - wfc->yCurrentScroll;
- // Reset the current scroll position.
- wfc->yCurrentScroll = yNewPos;
- // Scroll the window. (The system repaints most of the
- // client area when ScrollWindowEx is called; however, it is
- // necessary to call UpdateWindow in order to repaint the
- // rectangle of pixels that were invalidated.)
- ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
- (CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
- SW_INVALIDATE);
- UpdateWindow(wfc->hwnd);
- // Reset the scroll bar.
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS;
- si.nPos = wfc->yCurrentScroll;
- SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
+ // User clicked the scroll bar shaft below the scroll box.
+ case SB_PAGEDOWN:
+ yNewPos = wfc->yCurrentScroll + 50;
+ break;
+
+ // User clicked the top arrow.
+ case SB_LINEUP:
+ yNewPos = wfc->yCurrentScroll - 5;
+ break;
+
+ // User clicked the bottom arrow.
+ case SB_LINEDOWN:
+ yNewPos = wfc->yCurrentScroll + 5;
+ break;
+
+ // User dragged the scroll box.
+ case SB_THUMBPOSITION:
+ yNewPos = HIWORD(wParam);
+ break;
+
+ // user is dragging the scrollbar
+ case SB_THUMBTRACK:
+ yNewPos = HIWORD(wParam);
+ break;
+
+ default:
+ yNewPos = wfc->yCurrentScroll;
}
- break;
+
+ // New position must be between 0 and the screen height.
+ yNewPos = MAX(0, yNewPos);
+ yNewPos = MIN(wfc->yMaxScroll, yNewPos);
+
+ // If the current position does not change, do not scroll.
+ if (yNewPos == wfc->yCurrentScroll)
+ break;
+
+ // Determine the amount scrolled (in pixels).
+ yDelta = yNewPos - wfc->yCurrentScroll;
+ // Reset the current scroll position.
+ wfc->yCurrentScroll = yNewPos;
+ // Scroll the window. (The system repaints most of the
+ // client area when ScrollWindowEx is called; however, it is
+ // necessary to call UpdateWindow in order to repaint the
+ // rectangle of pixels that were invalidated.)
+ ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*)NULL, (CONST RECT*)NULL,
+ (HRGN)NULL, (PRECT)NULL, SW_INVALIDATE);
+ UpdateWindow(wfc->hwnd);
+ // Reset the scroll bar.
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = wfc->yCurrentScroll;
+ SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
+ }
+ break;
case WM_SYSCOMMAND:
+ {
+ if (wParam == SYSCOMMAND_ID_SMARTSIZING)
{
- if (wParam == SYSCOMMAND_ID_SMARTSIZING)
- {
- HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
- freerdp_set_param_bool(wfc->context.settings, FreeRDP_SmartSizing,
- !wfc->context.settings->SmartSizing);
- CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
- wfc->context.settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
- }
- else
- {
- processed = FALSE;
- }
+ HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
+ freerdp_set_param_bool(wfc->context.settings, FreeRDP_SmartSizing,
+ !wfc->context.settings->SmartSizing);
+ CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
+ wfc->context.settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
}
- break;
+ else
+ {
+ processed = FALSE;
+ }
+ }
+ break;
default:
processed = FALSE;
@@ -631,24 +629,24 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
break;
case WM_ACTIVATE:
+ {
+ int activate = (int)(short)LOWORD(wParam);
+
+ if (activate != WA_INACTIVE)
{
- int activate = (int)(short) LOWORD(wParam);
+ if (alt_ctrl_down())
+ g_flipping_in = TRUE;
- if (activate != WA_INACTIVE)
- {
- if (alt_ctrl_down())
- g_flipping_in = TRUE;
-
- g_focus_hWnd = hWnd;
- }
- else
- {
- if (alt_ctrl_down())
- g_flipping_out = TRUE;
- else
- g_focus_hWnd = NULL;
- }
+ g_focus_hWnd = hWnd;
}
+ else
+ {
+ if (alt_ctrl_down())
+ g_flipping_out = TRUE;
+ else
+ g_focus_hWnd = NULL;
+ }
+ }
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
@@ -658,8 +656,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
return 0;
}
-BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
- HDC hdcSrc, int x1, int y1, DWORD rop)
+BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1,
+ DWORD rop)
{
rdpSettings* settings;
UINT32 ww, wh, dw, dh;
@@ -682,8 +680,7 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
if (!wh)
wh = dh;
- if (wfc->fullscreen || !wfc->context.settings->SmartSizing || (ww == dw
- && wh == dh))
+ if (wfc->fullscreen || !wfc->context.settings->SmartSizing || (ww == dw && wh == dh))
{
return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY);
}
@@ -736,8 +733,7 @@ static BOOL wf_scale_mouse_pos(wfContext* wfc, UINT16* x, UINT16* y)
return TRUE;
}
-static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
- UINT16 x, UINT16 y)
+static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
MouseEventEventArgs eventArgs;
@@ -754,10 +750,9 @@ static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
return TRUE;
}
-#if(_WIN32_WINNT >= 0x0500)
+#if (_WIN32_WINNT >= 0x0500)
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags,
- UINT16 buttonMask,
- UINT16 x, UINT16 y)
+ UINT16 buttonMask, UINT16 x, UINT16 y)
{
MouseEventExEventArgs eventArgs;
diff --git a/client/Windows/wf_event.h b/client/Windows/wf_event.h
index a9d710851..f879f873a 100644
--- a/client/Windows/wf_event.h
+++ b/client/Windows/wf_event.h
@@ -26,8 +26,7 @@
#include
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam);
-LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
- LPARAM lParam);
+LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
void wf_event_focus_in(wfContext* wfc);
@@ -35,7 +34,10 @@ void wf_event_focus_in(wfContext* wfc);
#ifdef WITH_DEBUG_KBD
#define DEBUG_KBD(...) WLog_DBG(KBD_TAG, __VA_ARGS__)
#else
-#define DEBUG_KBD(...) do { } while (0)
+#define DEBUG_KBD(...) \
+ do \
+ { \
+ } while (0)
#endif
#endif /* FREERDP_CLIENT_WIN_EVENT_H */
diff --git a/client/Windows/wf_floatbar.c b/client/Windows/wf_floatbar.c
index ed3a2b764..512c66b47 100644
--- a/client/Windows/wf_floatbar.c
+++ b/client/Windows/wf_floatbar.c
@@ -25,38 +25,38 @@
#include "wf_client.h"
#include "wf_floatbar.h"
#include "wf_gdi.h"
-#pragma comment( lib, "Msimg32.lib" )
+#pragma comment(lib, "Msimg32.lib")
#define TAG CLIENT_TAG("windows.floatbar")
typedef struct _Button Button;
/* TIMERs */
-#define TIMER_HIDE 1
-#define TIMER_ANIMAT_SHOW 2
-#define TIMER_ANIMAT_HIDE 3
+#define TIMER_HIDE 1
+#define TIMER_ANIMAT_SHOW 2
+#define TIMER_ANIMAT_HIDE 3
/* Button Type */
-#define BUTTON_LOCKPIN 0
-#define BUTTON_MINIMIZE 1
-#define BUTTON_RESTORE 2
-#define BUTTON_CLOSE 3
-#define BTN_MAX 4
+#define BUTTON_LOCKPIN 0
+#define BUTTON_MINIMIZE 1
+#define BUTTON_RESTORE 2
+#define BUTTON_CLOSE 3
+#define BTN_MAX 4
/* bmp size */
-#define BACKGROUND_W 576
-#define BACKGROUND_H 27
-#define BUTTON_OFFSET 5
-#define BUTTON_Y 2
-#define BUTTON_WIDTH 23
-#define BUTTON_HEIGHT 21
-#define BUTTON_SPACING 1
+#define BACKGROUND_W 576
+#define BACKGROUND_H 27
+#define BUTTON_OFFSET 5
+#define BUTTON_Y 2
+#define BUTTON_WIDTH 23
+#define BUTTON_HEIGHT 21
+#define BUTTON_SPACING 1
-#define LOCK_X ( BACKGROUND_H + BUTTON_OFFSET )
-#define CLOSE_X ( (BACKGROUND_W - ( BACKGROUND_H + BUTTON_OFFSET ) ) - BUTTON_WIDTH )
-#define RESTORE_X ( CLOSE_X - ( BUTTON_WIDTH + BUTTON_SPACING ) )
-#define MINIMIZE_X ( RESTORE_X - ( BUTTON_WIDTH + BUTTON_SPACING ) )
-#define TEXT_X ( BACKGROUND_H + ( ( BUTTON_WIDTH + BUTTON_SPACING ) * 3 ) + 5 )
+#define LOCK_X (BACKGROUND_H + BUTTON_OFFSET)
+#define CLOSE_X ((BACKGROUND_W - (BACKGROUND_H + BUTTON_OFFSET)) - BUTTON_WIDTH)
+#define RESTORE_X (CLOSE_X - (BUTTON_WIDTH + BUTTON_SPACING))
+#define MINIMIZE_X (RESTORE_X - (BUTTON_WIDTH + BUTTON_SPACING))
+#define TEXT_X (BACKGROUND_H + ((BUTTON_WIDTH + BUTTON_SPACING) * 3) + 5)
struct _Button
{
@@ -96,12 +96,7 @@ struct _FloatBar
static BOOL floatbar_kill_timers(wfFloatBar* floatbar)
{
size_t x;
- UINT_PTR timers[] =
- {
- TIMER_HIDE,
- TIMER_ANIMAT_HIDE,
- TIMER_ANIMAT_SHOW
- };
+ UINT_PTR timers[] = { TIMER_HIDE, TIMER_ANIMAT_HIDE, TIMER_ANIMAT_SHOW };
if (!floatbar)
return FALSE;
@@ -115,7 +110,7 @@ static BOOL floatbar_kill_timers(wfFloatBar* floatbar)
static BOOL floatbar_animation(wfFloatBar* const floatbar, const BOOL show)
{
- UINT_PTR timer = show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE;
+ UINT_PTR timer = show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE;
if (!floatbar)
return FALSE;
@@ -131,7 +126,7 @@ static BOOL floatbar_animation(wfFloatBar* const floatbar, const BOOL show)
if (SetTimer(floatbar->hwnd, timer, USER_TIMER_MINIMUM, NULL) == NULL)
{
DWORD err = GetLastError();
- WLog_ERR(TAG, "SetTimer failed with %08"PRIx32, err);
+ WLog_ERR(TAG, "SetTimer failed with %08" PRIx32, err);
return FALSE;
}
@@ -148,7 +143,7 @@ static BOOL floatbar_trigger_hide(wfFloatBar* floatbar)
if (SetTimer(floatbar->hwnd, TIMER_HIDE, 3000, NULL) == NULL)
{
DWORD err = GetLastError();
- WLog_ERR(TAG, "SetTimer failed with %08"PRIx32, err);
+ WLog_ERR(TAG, "SetTimer failed with %08" PRIx32, err);
return FALSE;
}
}
@@ -163,11 +158,11 @@ static BOOL floatbar_hide(wfFloatBar* floatbar)
floatbar->offset = floatbar->height - 2;
- if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset,
- floatbar->width, floatbar->height, TRUE))
+ if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, floatbar->width,
+ floatbar->height, TRUE))
{
DWORD err = GetLastError();
- WLog_ERR(TAG, "MoveWindow failed with %08"PRIx32, err);
+ WLog_ERR(TAG, "MoveWindow failed with %08" PRIx32, err);
return FALSE;
}
@@ -186,11 +181,11 @@ static BOOL floatbar_show(wfFloatBar* floatbar)
floatbar->offset = 0;
- if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset,
- floatbar->width, floatbar->height, TRUE))
+ if (!MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, floatbar->width,
+ floatbar->height, TRUE))
{
DWORD err = GetLastError();
- WLog_ERR(TAG, "MoveWindow failed with %08"PRIx32, err);
+ WLog_ERR(TAG, "MoveWindow failed with %08" PRIx32, err);
return FALSE;
}
@@ -235,7 +230,7 @@ static BOOL update_locked_state(wfFloatBar* floatbar)
return TRUE;
}
-static int button_hit(Button* const button)
+static int button_hit(Button* const button)
{
wfFloatBar* const floatbar = button->floatbar;
@@ -276,17 +271,18 @@ static int button_paint(const Button* const button, const HDC hdc)
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 255;
bf.AlphaFormat = AC_SRC_ALPHA;
- AlphaBlend(hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0, 0, button->w,
- button->h, bf);
+ AlphaBlend(hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0, 0,
+ button->w, button->h, bf);
}
return 0;
}
static Button* floatbar_create_button(wfFloatBar* const floatbar, const int type, const int resid,
- const int resid_act, const int x, const int y, const int h, const int w)
+ const int resid_act, const int x, const int y, const int h,
+ const int w)
{
- Button* button = (Button*) calloc(1, sizeof(Button));
+ Button* button = (Button*)calloc(1, sizeof(Button));
if (!button)
return NULL;
@@ -306,12 +302,12 @@ static Button* floatbar_create_button(wfFloatBar* const floatbar, const int type
}
static Button* floatbar_create_lock_button(wfFloatBar* const floatbar, const int unlock_resid,
- const int unlock_resid_act, const int lock_resid, const int lock_resid_act, const int x,
- const int y, const int h, const int w)
+ const int unlock_resid_act, const int lock_resid,
+ const int lock_resid_act, const int x, const int y,
+ const int h, const int w)
{
- Button* button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid, unlock_resid_act, x,
- y, h,
- w);
+ Button* button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid,
+ unlock_resid_act, x, y, h, w);
if (!button)
return NULL;
@@ -320,8 +316,9 @@ static Button* floatbar_create_lock_button(wfFloatBar* const floatbar, const int
button->unlocked_bmp_act = button->bmp_act;
button->locked_bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid),
IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
- button->locked_bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
- MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+ button->locked_bmp_act =
+ (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP,
+ 0, 0, LR_DEFAULTCOLOR);
return button;
}
@@ -358,21 +355,18 @@ static BOOL floatbar_paint(wfFloatBar* const floatbar, const HDC hdc)
int bottom = BACKGROUND_H - 1;
int right = BACKGROUND_W - 1;
const int angleOffset = BACKGROUND_H - 1;
- TRIVERTEX triVertext[2] =
- {
- left,
- top,
- GetRValue(rgbTop) << 8,
- GetGValue(rgbTop) << 8,
- GetBValue(rgbTop) << 8,
- 0x0000,
- right,
- bottom,
- GetRValue(rgbBottom) << 8,
- GetGValue(rgbBottom) << 8,
- GetBValue(rgbBottom) << 8,
- 0x0000
- };
+ TRIVERTEX triVertext[2] = { left,
+ top,
+ GetRValue(rgbTop) << 8,
+ GetGValue(rgbTop) << 8,
+ GetBValue(rgbTop) << 8,
+ 0x0000,
+ right,
+ bottom,
+ GetRValue(rgbBottom) << 8,
+ GetGValue(rgbBottom) << 8,
+ GetBValue(rgbBottom) << 8,
+ 0x0000 };
if (!floatbar)
return FALSE;
@@ -397,7 +391,8 @@ static BOOL floatbar_paint(wfFloatBar* const floatbar, const HDC hdc)
LineTo(hdc, right + 1, top - 1);
DeleteObject(hpen);
SelectObject(hdc, orig);
- DrawText(hdc, floatbar->wfc->window_title, wcslen(floatbar->wfc->window_title), &floatbar->textRect,
+ DrawText(hdc, floatbar->wfc->window_title, wcslen(floatbar->wfc->window_title),
+ &floatbar->textRect,
DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
/* paint buttons */
@@ -427,7 +422,7 @@ static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPA
switch (Msg)
{
case WM_CREATE:
- floatbar = ((wfFloatBar*)((CREATESTRUCT*) lParam)->lpCreateParams);
+ floatbar = ((wfFloatBar*)((CREATESTRUCT*)lParam)->lpCreateParams);
floatbar->hwnd = hWnd;
GetWindowRect(floatbar->hwnd, &floatbar->rect);
floatbar->width = floatbar->rect.right - floatbar->rect.left;
@@ -537,23 +532,23 @@ static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPA
break;
case WM_MOUSELEAVE:
+ {
+ int i;
+
+ for (i = 0; i < BTN_MAX; i++)
{
- int i;
-
- for (i = 0; i < BTN_MAX; i++)
+ if (floatbar->buttons[i] != NULL)
{
- if (floatbar->buttons[i] != NULL)
- {
- floatbar->buttons[i]->active = FALSE;
- }
+ floatbar->buttons[i]->active = FALSE;
}
-
- InvalidateRect(hWnd, NULL, FALSE);
- UpdateWindow(hWnd);
- floatbar_trigger_hide(floatbar);
- break;
}
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+ floatbar_trigger_hide(floatbar);
+ break;
+ }
+
case WM_TIMER:
switch (wParam)
{
@@ -562,28 +557,28 @@ static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPA
break;
case TIMER_ANIMAT_SHOW:
- {
- floatbar->offset--;
- MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset, floatbar->width,
- floatbar->height, TRUE);
+ {
+ floatbar->offset--;
+ MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset,
+ floatbar->width, floatbar->height, TRUE);
- if (floatbar->offset <= 0)
- floatbar_show(floatbar);
+ if (floatbar->offset <= 0)
+ floatbar_show(floatbar);
- break;
- }
+ break;
+ }
case TIMER_ANIMAT_HIDE:
- {
- floatbar->offset++;
- MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset,
- floatbar->width, floatbar->height, TRUE);
+ {
+ floatbar->offset++;
+ MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->offset,
+ floatbar->width, floatbar->height, TRUE);
- if (floatbar->offset >= floatbar->height - 2)
- floatbar_hide(floatbar);
+ if (floatbar->offset >= floatbar->height - 2)
+ floatbar_hide(floatbar);
- break;
- }
+ break;
+ }
default:
break;
@@ -619,22 +614,21 @@ static BOOL floatbar_window_create(wfFloatBar* floatbar)
return FALSE;
x = (rect.right - rect.left - BACKGROUND_W) / 2;
- wnd_cls.cbSize = sizeof(WNDCLASSEX);
- wnd_cls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wnd_cls.lpfnWndProc = floatbar_proc;
- wnd_cls.cbClsExtra = 0;
- wnd_cls.cbWndExtra = 0;
- wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wnd_cls.hCursor = LoadCursor(floatbar->root_window, IDC_ARROW);
+ wnd_cls.cbSize = sizeof(WNDCLASSEX);
+ wnd_cls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wnd_cls.lpfnWndProc = floatbar_proc;
+ wnd_cls.cbClsExtra = 0;
+ wnd_cls.cbWndExtra = 0;
+ wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wnd_cls.hCursor = LoadCursor(floatbar->root_window, IDC_ARROW);
wnd_cls.hbrBackground = NULL;
- wnd_cls.lpszMenuName = NULL;
+ wnd_cls.lpszMenuName = NULL;
wnd_cls.lpszClassName = L"floatbar";
- wnd_cls.hInstance = floatbar->root_window;
- wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+ wnd_cls.hInstance = floatbar->root_window;
+ wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wnd_cls);
- barWnd = CreateWindowEx(WS_EX_TOPMOST, L"floatbar", L"floatbar", WS_CHILD, x, 0,
- BACKGROUND_W, BACKGROUND_H, floatbar->parent, NULL,
- floatbar->root_window, floatbar);
+ barWnd = CreateWindowEx(WS_EX_TOPMOST, L"floatbar", L"floatbar", WS_CHILD, x, 0, BACKGROUND_W,
+ BACKGROUND_H, floatbar->parent, NULL, floatbar->root_window, floatbar);
if (barWnd == NULL)
return FALSE;
@@ -672,7 +666,7 @@ wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags)
return NULL;
// TODO: Disable for remote app
- floatbar = (wfFloatBar*) calloc(1, sizeof(wfFloatBar));
+ floatbar = (wfFloatBar*)calloc(1, sizeof(wfFloatBar));
if (!floatbar)
return NULL;
@@ -688,10 +682,12 @@ wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags)
if (wfc->fullscreen_toggle)
{
- floatbar->buttons[0] = floatbar_create_button(floatbar, BUTTON_MINIMIZE, IDB_MINIMIZE,
- IDB_MINIMIZE_ACT, MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
- floatbar->buttons[1] = floatbar_create_button(floatbar, BUTTON_RESTORE, IDB_RESTORE,
- IDB_RESTORE_ACT, RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+ floatbar->buttons[0] =
+ floatbar_create_button(floatbar, BUTTON_MINIMIZE, IDB_MINIMIZE, IDB_MINIMIZE_ACT,
+ MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+ floatbar->buttons[1] =
+ floatbar_create_button(floatbar, BUTTON_RESTORE, IDB_RESTORE, IDB_RESTORE_ACT,
+ RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
}
else
{
@@ -700,9 +696,10 @@ wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags)
}
floatbar->buttons[2] = floatbar_create_button(floatbar, BUTTON_CLOSE, IDB_CLOSE, IDB_CLOSE_ACT,
- CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
- floatbar->buttons[3] = floatbar_create_lock_button(floatbar, IDB_UNLOCK, IDB_UNLOCK_ACT, IDB_LOCK,
- IDB_LOCK_ACT, LOCK_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+ CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+ floatbar->buttons[3] =
+ floatbar_create_lock_button(floatbar, IDB_UNLOCK, IDB_UNLOCK_ACT, IDB_LOCK, IDB_LOCK_ACT,
+ LOCK_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
if (!floatbar_window_create(floatbar))
goto fail;
diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c
index d91c00481..329f43a75 100644
--- a/client/Windows/wf_gdi.c
+++ b/client/Windows/wf_gdi.c
@@ -43,8 +43,7 @@
#define TAG CLIENT_TAG("windows.gdi")
-static const BYTE wf_rop2_table[] =
-{
+static const BYTE wf_rop2_table[] = {
R2_BLACK, /* 0 */
R2_NOTMERGEPEN, /* DPon */
R2_MASKNOTPEN, /* DPna */
@@ -63,8 +62,7 @@ static const BYTE wf_rop2_table[] =
R2_WHITE, /* 1 */
};
-static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor,
- COLORREF* color, UINT32* format)
+static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor, COLORREF* color, UINT32* format)
{
rdpGdi* gdi;
rdpSettings* settings;
@@ -102,8 +100,7 @@ static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor,
return FALSE;
}
- *color = FreeRDPConvertColor(srcColor, SrcFormat,
- DstFormat, &gdi->palette);
+ *color = FreeRDPConvertColor(srcColor, SrcFormat, DstFormat, &gdi->palette);
return TRUE;
}
@@ -111,7 +108,7 @@ static BOOL wf_set_rop2(HDC hdc, int rop2)
{
if ((rop2 < 0x01) || (rop2 > 0x10))
{
- WLog_ERR(TAG, "Unsupported ROP2: %d", rop2);
+ WLog_ERR(TAG, "Unsupported ROP2: %d", rop2);
return FALSE;
}
@@ -122,8 +119,7 @@ static BOOL wf_set_rop2(HDC hdc, int rop2)
static wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
{
wfBitmap* glyph_bmp;
- glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
- glyph->aj);
+ glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO, glyph->aj);
return glyph_bmp;
}
@@ -143,7 +139,7 @@ static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
int dst_bytes_per_row;
src_bytes_per_row = (width + 7) / 8;
dst_bytes_per_row = src_bytes_per_row + (src_bytes_per_row % 2);
- cdata = (BYTE*) malloc(dst_bytes_per_row * height);
+ cdata = (BYTE*)malloc(dst_bytes_per_row * height);
src = data;
for (indexy = 0; indexy < height; indexy++)
@@ -162,8 +158,7 @@ static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
return cdata;
}
-static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
- UINT32 bpp)
+static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UINT32 bpp)
{
UINT32 i;
HBRUSH br;
@@ -173,8 +168,8 @@ static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
HBITMAP pattern = NULL;
lbr.lbStyle = brush->style;
- if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8
- || lbr.lbStyle == BS_DIBPATTERNPT)
+ if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8 ||
+ lbr.lbStyle == BS_DIBPATTERNPT)
lbr.lbColor = DIB_RGB_COLORS;
else
lbr.lbColor = color;
@@ -185,7 +180,7 @@ static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
{
UINT32 format = gdi_get_pixel_format(bpp);
pattern = wf_create_dib(wfc, 8, 8, format, brush->data, NULL);
- lbr.lbHatch = (ULONG_PTR) pattern;
+ lbr.lbHatch = (ULONG_PTR)pattern;
}
else
{
@@ -194,7 +189,7 @@ static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
cdata = wf_glyph_convert(wfc, 8, 8, ipattern);
pattern = CreateBitmap(8, 8, 1, 1, cdata);
- lbr.lbHatch = (ULONG_PTR) pattern;
+ lbr.lbHatch = (ULONG_PTR)pattern;
free(cdata);
}
}
@@ -262,8 +257,7 @@ static BOOL wf_scale_rect(wfContext* wfc, RECT* source)
return TRUE;
}
-void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width,
- UINT32 height)
+void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height)
{
RECT rect;
rdpGdi* gdi = wfc->context.gdi;
@@ -278,8 +272,7 @@ void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width,
rect.top = y;
rect.bottom = height;
wf_scale_rect(wfc, &rect);
- gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right,
- rect.bottom);
+ gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right, rect.bottom);
}
void wf_update_offset(wfContext* wfc)
@@ -363,14 +356,14 @@ void wf_resize_window(wfContext* wfc)
wf_update_canvas_diff(wfc);
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y,
- wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
- 0 /*SWP_FRAMECHANGED*/);
+ wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
+ 0 /*SWP_FRAMECHANGED*/);
}
else
{
/* Now resize to get full canvas size and room for caption and borders */
- SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth,
- settings->DesktopHeight, SWP_FRAMECHANGED);
+ SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth, settings->DesktopHeight,
+ SWP_FRAMECHANGED);
wf_update_canvas_diff(wfc);
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x,
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
@@ -380,7 +373,7 @@ void wf_resize_window(wfContext* wfc)
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE,
WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX |
- WS_MAXIMIZEBOX);
+ WS_MAXIMIZEBOX);
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
@@ -399,7 +392,7 @@ void wf_resize_window(wfContext* wfc)
SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y,
wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
0 /*SWP_FRAMECHANGED*/);
- //wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
+ // wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
}
wf_update_offset(wfc);
@@ -423,13 +416,13 @@ void wf_toggle_fullscreen(wfContext* wfc)
if (!wfc->fullscreen)
{
- // Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning errors.
+ // Reenable window tracking AFTER resizing it back, otherwise it can lean to repositioning
+ // errors.
wfc->disablewindowtracking = FALSE;
}
}
-static BOOL wf_gdi_palette_update(rdpContext* context,
- const PALETTE_UPDATE* palette)
+static BOOL wf_gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palette)
{
return TRUE;
}
@@ -457,8 +450,7 @@ static BOOL wf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
if (bounds != NULL)
{
- hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1,
- bounds->bottom + 1);
+ hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1, bounds->bottom + 1);
SelectClipRgn(wfc->drawing->hdc, hrgn);
DeleteObject(hrgn);
}
@@ -475,12 +467,11 @@ static BOOL wf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
if (!context || !dstblt)
return FALSE;
- if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
+ if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth,
+ dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
return FALSE;
- wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight);
+ wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
return TRUE;
}
@@ -505,14 +496,13 @@ static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
if (!wf_decode_color(wfc, patblt->backColor, &bgcolor, NULL))
return FALSE;
- brush = wf_create_brush(wfc, &patblt->brush, fgcolor,
- context->settings->ColorDepth);
+ brush = wf_create_brush(wfc, &patblt->brush, fgcolor, context->settings->ColorDepth);
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);
- rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
- patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
+ rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth,
+ patblt->nHeight, gdi_rop3_code(patblt->bRop));
SelectObject(wfc->drawing->hdc, org_brush);
DeleteObject(brush);
SetBkMode(wfc->drawing->hdc, org_bkmode);
@@ -533,18 +523,16 @@ static BOOL wf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
if (!context || !scrblt || !wfc->drawing)
return FALSE;
- if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
- scrblt->nWidth, scrblt->nHeight, wfc->primary->hdc,
- scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)))
+ if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth,
+ scrblt->nHeight, wfc->primary->hdc, scrblt->nXSrc, scrblt->nYSrc,
+ gdi_rop3_code(scrblt->bRop)))
return FALSE;
- wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect,
- scrblt->nWidth, scrblt->nHeight);
+ wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth, scrblt->nHeight);
return TRUE;
}
-static BOOL wf_gdi_opaque_rect(rdpContext* context,
- const OPAQUE_RECT_ORDER* opaque_rect)
+static BOOL wf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
{
RECT rect;
HBRUSH brush;
@@ -584,8 +572,7 @@ static BOOL wf_gdi_multi_opaque_rect(rdpContext* context,
if (!context || !multi_opaque_rect)
return FALSE;
- if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color,
- NULL))
+ if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color, NULL))
return FALSE;
for (i = 0; i < multi_opaque_rect->numRectangles; i++)
@@ -624,15 +611,15 @@ static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
wf_set_rop2(wfc->drawing->hdc, line_to->bRop2);
- org_pen = (HPEN) SelectObject(wfc->drawing->hdc, pen);
+ org_pen = (HPEN)SelectObject(wfc->drawing->hdc, pen);
MoveToEx(wfc->drawing->hdc, line_to->nXStart, line_to->nYStart, NULL);
LineTo(wfc->drawing->hdc, line_to->nXEnd, line_to->nYEnd);
x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd;
y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd;
w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart)
- : (line_to->nXStart - line_to->nXEnd);
+ : (line_to->nXStart - line_to->nXEnd);
h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart)
- : (line_to->nYStart - line_to->nYEnd);
+ : (line_to->nYStart - line_to->nYEnd);
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, x, y, w, h);
@@ -658,20 +645,20 @@ static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
hpen = CreatePen(0, 1, pen_color);
org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2);
- org_hpen = (HPEN) SelectObject(wfc->drawing->hdc, hpen);
+ org_hpen = (HPEN)SelectObject(wfc->drawing->hdc, hpen);
if (polyline->numDeltaEntries > 0)
{
- POINT* pts;
- POINT temp;
- int numPoints;
- int i;
+ POINT* pts;
+ POINT temp;
+ int numPoints;
+ int i;
numPoints = polyline->numDeltaEntries + 1;
- pts = (POINT*) malloc(sizeof(POINT) * numPoints);
+ pts = (POINT*)malloc(sizeof(POINT) * numPoints);
pts[0].x = temp.x = polyline->xStart;
pts[0].y = temp.y = polyline->yStart;
- for (i = 0; i < (int) polyline->numDeltaEntries; i++)
+ for (i = 0; i < (int)polyline->numDeltaEntries; i++)
{
temp.x += polyline->points[i].x;
temp.y += polyline->points[i].y;
@@ -701,14 +688,14 @@ static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
if (!context || !memblt)
return FALSE;
- bitmap = (wfBitmap*) memblt->bitmap;
+ bitmap = (wfBitmap*)memblt->bitmap;
if (!bitmap || !wfc->drawing || !wfc->drawing->hdc)
return FALSE;
- if (!BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
- memblt->nWidth, memblt->nHeight, bitmap->hdc,
- memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop)))
+ if (!BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth,
+ memblt->nHeight, bitmap->hdc, memblt->nXSrc, memblt->nYSrc,
+ gdi_rop3_code(memblt->bRop)))
return FALSE;
if (wfc->drawing == wfc->primary)
@@ -730,7 +717,7 @@ static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
if (!context || !mem3blt)
return FALSE;
- bitmap = (wfBitmap*) mem3blt->bitmap;
+ bitmap = (wfBitmap*)mem3blt->bitmap;
if (!bitmap || !wfc->drawing || !wfc->drawing->hdc)
return FALSE;
@@ -753,11 +740,11 @@ static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
case GDI_BS_HATCHED:
case GDI_BS_PATTERN:
- {
- HBITMAP bmp = CreateBitmap(8, 8, 1, mem3blt->brush.bpp, mem3blt->brush.data);
- brush = CreatePatternBrush(bmp);
- }
- break;
+ {
+ HBITMAP bmp = CreateBitmap(8, 8, 1, mem3blt->brush.bpp, mem3blt->brush.data);
+ brush = CreatePatternBrush(bmp);
+ }
+ break;
default:
goto fail;
@@ -765,14 +752,12 @@ static BOOL wf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
orgBrush = SelectObject(hdc, brush);
- if (!BitBlt(hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
- mem3blt->nWidth, mem3blt->nHeight, bitmap->hdc,
- mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop)))
+ if (!BitBlt(hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight,
+ bitmap->hdc, mem3blt->nXSrc, mem3blt->nYSrc, gdi_rop3_code(mem3blt->bRop)))
goto fail;
if (wfc->drawing == wfc->primary)
- wf_invalidate_region(wfc, mem3blt->nLeftRect, mem3blt->nTopRect,
- mem3blt->nWidth,
+ wf_invalidate_region(wfc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth,
mem3blt->nHeight);
rc = TRUE;
@@ -798,8 +783,8 @@ static BOOL wf_gdi_surface_frame_marker(rdpContext* context,
if (!settings)
return FALSE;
- if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END
- && settings->FrameAcknowledge > 0)
+ if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END &&
+ settings->FrameAcknowledge > 0)
{
IFCALL(context->instance->update->SurfaceFrameAcknowledge, context,
surface_frame_marker->frameId);
diff --git a/client/Windows/wf_gdi.h b/client/Windows/wf_gdi.h
index 3ceec490f..a093e1a8c 100644
--- a/client/Windows/wf_gdi.h
+++ b/client/Windows/wf_gdi.h
@@ -24,10 +24,8 @@
#include "wf_client.h"
-void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width,
- UINT32 height);
-wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 bpp,
- const BYTE* data);
+void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height);
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 bpp, const BYTE* data);
void wf_image_free(wfBitmap* image);
void wf_update_offset(wfContext* wfc);
void wf_resize_window(wfContext* wfc);
diff --git a/client/Windows/wf_graphics.c b/client/Windows/wf_graphics.c
index 28682cd1e..da1afcf48 100644
--- a/client/Windows/wf_graphics.c
+++ b/client/Windows/wf_graphics.c
@@ -31,8 +31,8 @@
#define TAG CLIENT_TAG("windows")
-HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height,
- UINT32 srcFormat, const BYTE* data, BYTE** pdata)
+HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height, UINT32 srcFormat,
+ const BYTE* data, BYTE** pdata)
{
HDC hdc;
int negHeight;
@@ -54,11 +54,11 @@ HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height,
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = GetBitsPerPixel(dstFormat);
bmi.bmiHeader.biCompression = BI_RGB;
- bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &cdata, NULL, 0);
+ bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&cdata, NULL, 0);
if (data)
- freerdp_image_copy(cdata, dstFormat, 0, 0, 0, width, height, data, srcFormat, 0,
- 0, 0, &wfc->context.gdi->palette, FREERDP_FLIP_NONE);
+ freerdp_image_copy(cdata, dstFormat, 0, 0, 0, width, height, data, srcFormat, 0, 0, 0,
+ &wfc->context.gdi->palette, FREERDP_FLIP_NONE);
if (pdata)
*pdata = cdata;
@@ -68,17 +68,15 @@ HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height,
return bitmap;
}
-wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height,
- UINT32 format, const BYTE* data)
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format, const BYTE* data)
{
HDC hdc;
wfBitmap* image;
hdc = GetDC(NULL);
- image = (wfBitmap*) malloc(sizeof(wfBitmap));
+ image = (wfBitmap*)malloc(sizeof(wfBitmap));
image->hdc = CreateCompatibleDC(hdc);
- image->bitmap = wf_create_dib(wfc, width, height, format, data,
- &(image->pdata));
- image->org_bitmap = (HBITMAP) SelectObject(image->hdc, image->bitmap);
+ image->bitmap = wf_create_dib(wfc, width, height, format, data, &(image->pdata));
+ image->org_bitmap = (HBITMAP)SelectObject(image->hdc, image->bitmap);
ReleaseDC(NULL, hdc);
return image;
}
@@ -100,30 +98,29 @@ static BOOL wf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
HDC hdc;
wfContext* wfc = (wfContext*)context;
- wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
+ wfBitmap* wf_bitmap = (wfBitmap*)bitmap;
if (!context || !bitmap)
return FALSE;
- wf_bitmap = (wfBitmap*) bitmap;
+ wf_bitmap = (wfBitmap*)bitmap;
hdc = GetDC(NULL);
wf_bitmap->hdc = CreateCompatibleDC(hdc);
if (!bitmap->data)
wf_bitmap->bitmap = CreateCompatibleBitmap(hdc, bitmap->width, bitmap->height);
else
- wf_bitmap->bitmap = wf_create_dib(wfc, bitmap->width, bitmap->height,
- bitmap->format, bitmap->data, NULL);
+ wf_bitmap->bitmap =
+ wf_create_dib(wfc, bitmap->width, bitmap->height, bitmap->format, bitmap->data, NULL);
- wf_bitmap->org_bitmap = (HBITMAP) SelectObject(wf_bitmap->hdc,
- wf_bitmap->bitmap);
+ wf_bitmap->org_bitmap = (HBITMAP)SelectObject(wf_bitmap->hdc, wf_bitmap->bitmap);
ReleaseDC(NULL, hdc);
return TRUE;
}
static void wf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
{
- wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
+ wfBitmap* wf_bitmap = (wfBitmap*)bitmap;
if (wf_bitmap != 0)
{
@@ -141,24 +138,23 @@ static BOOL wf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
BOOL rc;
UINT32 width, height;
wfContext* wfc = (wfContext*)context;
- wfBitmap* wf_bitmap = (wfBitmap*) bitmap;
+ wfBitmap* wf_bitmap = (wfBitmap*)bitmap;
if (!context || !bitmap)
return FALSE;
width = bitmap->right - bitmap->left + 1;
height = bitmap->bottom - bitmap->top + 1;
- rc = BitBlt(wfc->primary->hdc, bitmap->left, bitmap->top,
- width, height, wf_bitmap->hdc, 0, 0, SRCCOPY);
+ rc = BitBlt(wfc->primary->hdc, bitmap->left, bitmap->top, width, height, wf_bitmap->hdc, 0, 0,
+ SRCCOPY);
wf_invalidate_region(wfc, bitmap->left, bitmap->top, width, height);
return rc;
}
-static BOOL wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
- BOOL primary)
+static BOOL wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
{
wfContext* wfc = (wfContext*)context;
- wfBitmap* bmp = (wfBitmap*) bitmap;
+ wfBitmap* bmp = (wfBitmap*)bitmap;
rdpGdi* gdi = context->gdi;
if (!gdi || !wfc)
@@ -176,8 +172,7 @@ static BOOL wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
/* Pointer Class */
-static BOOL flip_bitmap(const BYTE* src, BYTE* dst, UINT32 scanline,
- UINT32 nHeight)
+static BOOL flip_bitmap(const BYTE* src, BYTE* dst, UINT32 scanline, UINT32 nHeight)
{
UINT32 x;
BYTE* bottomLine = dst + scanline * (nHeight - 1);
@@ -213,15 +208,13 @@ static BOOL wf_Pointer_New(rdpContext* context, const rdpPointer* pointer)
if (pointer->xorBpp == 1)
{
- BYTE* pdata = (BYTE*) _aligned_malloc(pointer->lengthAndMask +
- pointer->lengthXorMask, 16);
+ BYTE* pdata = (BYTE*)_aligned_malloc(pointer->lengthAndMask + pointer->lengthXorMask, 16);
if (!pdata)
goto fail;
CopyMemory(pdata, pointer->andMaskData, pointer->lengthAndMask);
- CopyMemory(pdata + pointer->lengthAndMask, pointer->xorMaskData,
- pointer->lengthXorMask);
+ CopyMemory(pdata + pointer->lengthAndMask, pointer->xorMaskData, pointer->lengthXorMask);
info.hbmMask = CreateBitmap(pointer->width, pointer->height * 2, 1, 1, pdata);
_aligned_free(pdata);
info.hbmColor = NULL;
@@ -229,13 +222,12 @@ static BOOL wf_Pointer_New(rdpContext* context, const rdpPointer* pointer)
else
{
UINT32 srcFormat;
- BYTE* pdata = (BYTE*) _aligned_malloc(pointer->lengthAndMask, 16);
+ BYTE* pdata = (BYTE*)_aligned_malloc(pointer->lengthAndMask, 16);
if (!pdata)
goto fail;
- flip_bitmap(pointer->andMaskData, pdata, (pointer->width + 7) / 8,
- pointer->height);
+ flip_bitmap(pointer->andMaskData, pdata, (pointer->width + 7) / 8, pointer->height);
info.hbmMask = CreateBitmap(pointer->width, pointer->height, 1, 1, pdata);
_aligned_free(pdata);
@@ -245,22 +237,23 @@ static BOOL wf_Pointer_New(rdpContext* context, const rdpPointer* pointer)
if (!srcFormat)
goto fail;
- info.hbmColor = wf_create_dib((wfContext*)context, pointer->width, pointer->height, srcFormat, NULL, &pdata);
+ info.hbmColor = wf_create_dib((wfContext*)context, pointer->width, pointer->height,
+ srcFormat, NULL, &pdata);
if (!info.hbmColor)
goto fail;
- if (!freerdp_image_copy_from_pointer_data(pdata, gdi->dstFormat, 0, 0, 0,
- pointer->width, pointer->height,
- pointer->xorMaskData, pointer->lengthXorMask,
- pointer->andMaskData, pointer->lengthAndMask, pointer->xorBpp, &gdi->palette))
+ if (!freerdp_image_copy_from_pointer_data(
+ pdata, gdi->dstFormat, 0, 0, 0, pointer->width, pointer->height,
+ pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
+ pointer->lengthAndMask, pointer->xorBpp, &gdi->palette))
{
goto fail;
}
}
hCur = CreateIconIndirect(&info);
- ((wfPointer*) pointer)->cursor = hCur;
+ ((wfPointer*)pointer)->cursor = hCur;
rc = TRUE;
fail:
@@ -280,7 +273,7 @@ static BOOL wf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
if (!context || !pointer)
return FALSE;
- hCur = ((wfPointer*) pointer)->cursor;
+ hCur = ((wfPointer*)pointer)->cursor;
if (hCur != 0)
DestroyIcon(hCur);
@@ -296,7 +289,7 @@ static BOOL wf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
if (!context || !pointer)
return FALSE;
- hCur = ((wfPointer*) pointer)->cursor;
+ hCur = ((wfPointer*)pointer)->cursor;
if (hCur != NULL)
{
@@ -339,7 +332,7 @@ BOOL wf_register_pointer(rdpGraphics* graphics)
if (!graphics)
return FALSE;
- wfc = (wfContext*) graphics->context;
+ wfc = (wfContext*)graphics->context;
ZeroMemory(&pointer, sizeof(rdpPointer));
pointer.size = sizeof(wfPointer);
pointer.New = wf_Pointer_New;
@@ -363,7 +356,7 @@ BOOL wf_register_graphics(rdpGraphics* graphics)
if (!graphics)
return FALSE;
- wfc = (wfContext*) graphics->context;
+ wfc = (wfContext*)graphics->context;
bitmap = *graphics->Bitmap_Prototype;
bitmap.size = sizeof(wfBitmap);
bitmap.New = wf_Bitmap_New;
diff --git a/client/Windows/wf_graphics.h b/client/Windows/wf_graphics.h
index da2e36eff..241575fd2 100644
--- a/client/Windows/wf_graphics.h
+++ b/client/Windows/wf_graphics.h
@@ -22,10 +22,10 @@
#include "wf_client.h"
-HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height,
- UINT32 format, const BYTE* data, BYTE** pdata);
-wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height,
- UINT32 format, const BYTE* data);
+HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format, const BYTE* data,
+ BYTE** pdata);
+wfBitmap* wf_image_new(wfContext* wfc, UINT32 width, UINT32 height, UINT32 format,
+ const BYTE* data);
void wf_image_free(wfBitmap* image);
BOOL wf_register_pointer(rdpGraphics* graphics);
diff --git a/client/Windows/wf_rail.c b/client/Windows/wf_rail.c
index 9b4034995..24865c51d 100644
--- a/client/Windows/wf_rail.c
+++ b/client/Windows/wf_rail.c
@@ -29,8 +29,8 @@
#define TAG CLIENT_TAG("windows")
-#define GET_X_LPARAM(lParam) ((UINT16) (lParam & 0xFFFF))
-#define GET_Y_LPARAM(lParam) ((UINT16) ((lParam >> 16) & 0xFFFF))
+#define GET_X_LPARAM(lParam) ((UINT16)(lParam & 0xFFFF))
+#define GET_Y_LPARAM(lParam) ((UINT16)((lParam >> 16) & 0xFFFF))
/* RemoteApp Core Protocol Extension */
@@ -42,35 +42,31 @@ struct _WINDOW_STYLE
};
typedef struct _WINDOW_STYLE WINDOW_STYLE;
-static const WINDOW_STYLE WINDOW_STYLES[] =
-{
- { WS_BORDER, "WS_BORDER", FALSE },
- { WS_CAPTION, "WS_CAPTION", FALSE },
- { WS_CHILD, "WS_CHILD", FALSE },
- { WS_CLIPCHILDREN, "WS_CLIPCHILDREN", FALSE },
- { WS_CLIPSIBLINGS, "WS_CLIPSIBLINGS", FALSE },
- { WS_DISABLED, "WS_DISABLED", FALSE },
- { WS_DLGFRAME, "WS_DLGFRAME", FALSE },
- { WS_GROUP, "WS_GROUP", FALSE },
- { WS_HSCROLL, "WS_HSCROLL", FALSE },
- { WS_ICONIC, "WS_ICONIC", FALSE },
- { WS_MAXIMIZE, "WS_MAXIMIZE", FALSE },
- { WS_MAXIMIZEBOX, "WS_MAXIMIZEBOX", FALSE },
- { WS_MINIMIZE, "WS_MINIMIZE", FALSE },
- { WS_MINIMIZEBOX, "WS_MINIMIZEBOX", FALSE },
- { WS_OVERLAPPED, "WS_OVERLAPPED", FALSE },
- { WS_OVERLAPPEDWINDOW, "WS_OVERLAPPEDWINDOW", TRUE },
- { WS_POPUP, "WS_POPUP", FALSE },
- { WS_POPUPWINDOW, "WS_POPUPWINDOW", TRUE },
- { WS_SIZEBOX, "WS_SIZEBOX", FALSE },
- { WS_SYSMENU, "WS_SYSMENU", FALSE },
- { WS_TABSTOP, "WS_TABSTOP", FALSE },
- { WS_THICKFRAME, "WS_THICKFRAME", FALSE },
- { WS_VISIBLE, "WS_VISIBLE", FALSE }
-};
+static const WINDOW_STYLE WINDOW_STYLES[] = { { WS_BORDER, "WS_BORDER", FALSE },
+ { WS_CAPTION, "WS_CAPTION", FALSE },
+ { WS_CHILD, "WS_CHILD", FALSE },
+ { WS_CLIPCHILDREN, "WS_CLIPCHILDREN", FALSE },
+ { WS_CLIPSIBLINGS, "WS_CLIPSIBLINGS", FALSE },
+ { WS_DISABLED, "WS_DISABLED", FALSE },
+ { WS_DLGFRAME, "WS_DLGFRAME", FALSE },
+ { WS_GROUP, "WS_GROUP", FALSE },
+ { WS_HSCROLL, "WS_HSCROLL", FALSE },
+ { WS_ICONIC, "WS_ICONIC", FALSE },
+ { WS_MAXIMIZE, "WS_MAXIMIZE", FALSE },
+ { WS_MAXIMIZEBOX, "WS_MAXIMIZEBOX", FALSE },
+ { WS_MINIMIZE, "WS_MINIMIZE", FALSE },
+ { WS_MINIMIZEBOX, "WS_MINIMIZEBOX", FALSE },
+ { WS_OVERLAPPED, "WS_OVERLAPPED", FALSE },
+ { WS_OVERLAPPEDWINDOW, "WS_OVERLAPPEDWINDOW", TRUE },
+ { WS_POPUP, "WS_POPUP", FALSE },
+ { WS_POPUPWINDOW, "WS_POPUPWINDOW", TRUE },
+ { WS_SIZEBOX, "WS_SIZEBOX", FALSE },
+ { WS_SYSMENU, "WS_SYSMENU", FALSE },
+ { WS_TABSTOP, "WS_TABSTOP", FALSE },
+ { WS_THICKFRAME, "WS_THICKFRAME", FALSE },
+ { WS_VISIBLE, "WS_VISIBLE", FALSE } };
-static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] =
-{
+static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] = {
{ WS_EX_ACCEPTFILES, "WS_EX_ACCEPTFILES", FALSE },
{ WS_EX_APPWINDOW, "WS_EX_APPWINDOW", FALSE },
{ WS_EX_CLIENTEDGE, "WS_EX_CLIENTEDGE", FALSE },
@@ -130,8 +126,7 @@ void PrintExtendedWindowStyles(UINT32 style)
{
if (EXTENDED_WINDOW_STYLES[i].multi)
{
- if ((style & EXTENDED_WINDOW_STYLES[i].style) !=
- EXTENDED_WINDOW_STYLES[i].style)
+ if ((style & EXTENDED_WINDOW_STYLES[i].style) != EXTENDED_WINDOW_STYLES[i].style)
continue;
}
@@ -141,7 +136,7 @@ void PrintExtendedWindowStyles(UINT32 style)
}
static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
- const WINDOW_STATE_ORDER* windowState)
+ const WINDOW_STATE_ORDER* windowState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW)
WLog_INFO(TAG, "WindowCreate: WindowId: 0x%08X", orderInfo->windowId);
@@ -157,8 +152,8 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
- WLog_INFO(TAG, "\tStyle: 0x%08X ExtendedStyle: 0x%08X",
- windowState->style, windowState->extendedStyle);
+ WLog_INFO(TAG, "\tStyle: 0x%08X ExtendedStyle: 0x%08X", windowState->style,
+ windowState->extendedStyle);
PrintWindowStyles(windowState->style);
PrintExtendedWindowStyles(windowState->extendedStyle);
}
@@ -171,23 +166,22 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
{
char* title = NULL;
- ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL);
- WLog_INFO(TAG, "\tTitleInfo: %s (length = %hu)", title,
- windowState->titleInfo.length);
+ WLog_INFO(TAG, "\tTitleInfo: %s (length = %hu)", title, windowState->titleInfo.length);
free(title);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
{
- WLog_INFO(TAG, "\tClientOffsetX: %d ClientOffsetY: %d",
- windowState->clientOffsetX, windowState->clientOffsetY);
+ WLog_INFO(TAG, "\tClientOffsetX: %d ClientOffsetY: %d", windowState->clientOffsetX,
+ windowState->clientOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
- WLog_INFO(TAG, "\tClientAreaWidth: %u ClientAreaHeight: %u",
- windowState->clientAreaWidth, windowState->clientAreaHeight);
+ WLog_INFO(TAG, "\tClientAreaWidth: %u ClientAreaHeight: %u", windowState->clientAreaWidth,
+ windowState->clientAreaHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
@@ -202,8 +196,8 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
{
- WLog_INFO(TAG, "\tWindowOffsetX: %d WindowOffsetY: %d",
- windowState->windowOffsetX, windowState->windowOffsetY);
+ WLog_INFO(TAG, "\tWindowOffsetX: %d WindowOffsetY: %d", windowState->windowOffsetX,
+ windowState->windowOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
@@ -214,8 +208,8 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
{
- WLog_INFO(TAG, "\tWindowWidth: %u WindowHeight: %u",
- windowState->windowWidth, windowState->windowHeight);
+ WLog_INFO(TAG, "\tWindowWidth: %u WindowHeight: %u", windowState->windowWidth,
+ windowState->windowHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
@@ -227,15 +221,15 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
for (index = 0; index < windowState->numWindowRects; index++)
{
rect = &windowState->windowRects[index];
- WLog_INFO(TAG, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu",
- index, rect->left, rect->top, rect->right, rect->bottom);
+ WLog_INFO(TAG, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
+ rect->left, rect->top, rect->right, rect->bottom);
}
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
{
- WLog_INFO(TAG, "\tvisibileOffsetX: %d visibleOffsetY: %d",
- windowState->visibleOffsetX, windowState->visibleOffsetY);
+ WLog_INFO(TAG, "\tvisibileOffsetX: %d visibleOffsetY: %d", windowState->visibleOffsetX,
+ windowState->visibleOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
@@ -247,8 +241,8 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo,
for (index = 0; index < windowState->numVisibilityRects; index++)
{
rect = &windowState->visibilityRects[index];
- WLog_INFO(TAG, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu",
- index, rect->left, rect->top, rect->right, rect->bottom);
+ WLog_INFO(TAG, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index,
+ rect->left, rect->top, rect->right, rect->bottom);
}
}
@@ -269,14 +263,13 @@ static void PrintRailIconInfo(const WINDOW_ORDER_INFO* orderInfo, const ICON_INF
WLog_INFO(TAG, "\tcbColorTable: %u", iconInfo->cbColorTable);
WLog_INFO(TAG, "\tcbBitsMask: %u", iconInfo->cbBitsMask);
WLog_INFO(TAG, "\tcbBitsColor: %u", iconInfo->cbBitsColor);
- WLog_INFO(TAG, "\tcolorTable: %p", (void*) iconInfo->colorTable);
- WLog_INFO(TAG, "\tbitsMask: %p", (void*) iconInfo->bitsMask);
- WLog_INFO(TAG, "\tbitsColor: %p", (void*) iconInfo->bitsColor);
+ WLog_INFO(TAG, "\tcolorTable: %p", (void*)iconInfo->colorTable);
+ WLog_INFO(TAG, "\tbitsMask: %p", (void*)iconInfo->bitsMask);
+ WLog_INFO(TAG, "\tbitsColor: %p", (void*)iconInfo->bitsColor);
WLog_INFO(TAG, "}");
}
-LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
- LPARAM lParam)
+LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
int x, y;
@@ -290,13 +283,13 @@ LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
rdpInput* input = NULL;
rdpContext* context = NULL;
wfRailWindow* railWindow;
- railWindow = (wfRailWindow*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ railWindow = (wfRailWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if (railWindow)
wfc = railWindow->wfc;
if (wfc)
- context = (rdpContext*) wfc;
+ context = (rdpContext*)wfc;
if (context)
input = context->input;
@@ -304,90 +297,90 @@ LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
switch (msg)
{
case WM_PAINT:
- {
- if (!wfc)
- return 0;
+ {
+ if (!wfc)
+ return 0;
- hDC = BeginPaint(hWnd, &ps);
- x = ps.rcPaint.left;
- y = ps.rcPaint.top;
- width = ps.rcPaint.right - ps.rcPaint.left + 1;
- height = ps.rcPaint.bottom - ps.rcPaint.top + 1;
- BitBlt(hDC, x, y, width, height, wfc->primary->hdc,
- railWindow->x + x, railWindow->y + y, SRCCOPY);
- EndPaint(hWnd, &ps);
- }
- break;
+ hDC = BeginPaint(hWnd, &ps);
+ x = ps.rcPaint.left;
+ y = ps.rcPaint.top;
+ width = ps.rcPaint.right - ps.rcPaint.left + 1;
+ height = ps.rcPaint.bottom - ps.rcPaint.top + 1;
+ BitBlt(hDC, x, y, width, height, wfc->primary->hdc, railWindow->x + x,
+ railWindow->y + y, SRCCOPY);
+ EndPaint(hWnd, &ps);
+ }
+ break;
case WM_LBUTTONDOWN:
- {
- if (!railWindow || !input)
- return 0;
+ {
+ if (!railWindow || !input)
+ return 0;
- xPos = GET_X_LPARAM(lParam) + railWindow->x;
- yPos = GET_Y_LPARAM(lParam) + railWindow->y;
- inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1;
+ xPos = GET_X_LPARAM(lParam) + railWindow->x;
+ yPos = GET_Y_LPARAM(lParam) + railWindow->y;
+ inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1;
- if (input)
- input->MouseEvent(input, inputFlags, xPos, yPos);
- }
- break;
+ if (input)
+ input->MouseEvent(input, inputFlags, xPos, yPos);
+ }
+ break;
case WM_LBUTTONUP:
- {
- if (!railWindow || !input)
- return 0;
+ {
+ if (!railWindow || !input)
+ return 0;
- xPos = GET_X_LPARAM(lParam) + railWindow->x;
- yPos = GET_Y_LPARAM(lParam) + railWindow->y;
- inputFlags = PTR_FLAGS_BUTTON1;
+ xPos = GET_X_LPARAM(lParam) + railWindow->x;
+ yPos = GET_Y_LPARAM(lParam) + railWindow->y;
+ inputFlags = PTR_FLAGS_BUTTON1;
- if (input)
- input->MouseEvent(input, inputFlags, xPos, yPos);
- }
- break;
+ if (input)
+ input->MouseEvent(input, inputFlags, xPos, yPos);
+ }
+ break;
case WM_RBUTTONDOWN:
- {
- if (!railWindow || !input)
- return 0;
+ {
+ if (!railWindow || !input)
+ return 0;
- xPos = GET_X_LPARAM(lParam) + railWindow->x;
- yPos = GET_Y_LPARAM(lParam) + railWindow->y;
- inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2;
+ xPos = GET_X_LPARAM(lParam) + railWindow->x;
+ yPos = GET_Y_LPARAM(lParam) + railWindow->y;
+ inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2;
- if (input)
- input->MouseEvent(input, inputFlags, xPos, yPos);
- }
- break;
+ if (input)
+ input->MouseEvent(input, inputFlags, xPos, yPos);
+ }
+ break;
case WM_RBUTTONUP:
- {
- if (!railWindow || !input)
- return 0;
+ {
+ if (!railWindow || !input)
+ return 0;
- xPos = GET_X_LPARAM(lParam) + railWindow->x;
- yPos = GET_Y_LPARAM(lParam) + railWindow->y;
- inputFlags = PTR_FLAGS_BUTTON2;
+ xPos = GET_X_LPARAM(lParam) + railWindow->x;
+ yPos = GET_Y_LPARAM(lParam) + railWindow->y;
+ inputFlags = PTR_FLAGS_BUTTON2;
- if (input)
- input->MouseEvent(input, inputFlags, xPos, yPos);
- }
- break;
+ if (input)
+ input->MouseEvent(input, inputFlags, xPos, yPos);
+ }
+ break;
case WM_MOUSEMOVE:
- {
- if (!railWindow || !input)
- return 0;
+ {
+ if (!railWindow || !input)
+ return 0;
- xPos = GET_X_LPARAM(lParam) + railWindow->x;
- yPos = GET_Y_LPARAM(lParam) + railWindow->y;
- inputFlags = PTR_FLAGS_MOVE;
+ xPos = GET_X_LPARAM(lParam) + railWindow->x;
+ yPos = GET_Y_LPARAM(lParam) + railWindow->y;
+ inputFlags = PTR_FLAGS_MOVE;
- if (input)
- input->MouseEvent(input, inputFlags, xPos, yPos);
- }
- break;
+ if (input)
+ input->MouseEvent(input, inputFlags, xPos, yPos);
+ }
+ break;
case WM_MOUSEWHEEL:
break;
@@ -407,15 +400,17 @@ LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
return 0;
}
-#define RAIL_DISABLED_WINDOW_STYLES (WS_BORDER | WS_THICKFRAME | WS_DLGFRAME | WS_CAPTION | \
- WS_OVERLAPPED | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
-#define RAIL_DISABLED_EXTENDED_WINDOW_STYLES (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE)
+#define RAIL_DISABLED_WINDOW_STYLES \
+ (WS_BORDER | WS_THICKFRAME | WS_DLGFRAME | WS_CAPTION | WS_OVERLAPPED | WS_VSCROLL | \
+ WS_HSCROLL | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
+#define RAIL_DISABLED_EXTENDED_WINDOW_STYLES \
+ (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE)
-static BOOL wf_rail_window_common(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo,const WINDOW_STATE_ORDER* windowState)
+static BOOL wf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_STATE_ORDER* windowState)
{
wfRailWindow* railWindow = NULL;
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
UINT32 fieldFlags = orderInfo->fieldFlags;
PrintRailWindowState(orderInfo, windowState);
@@ -425,7 +420,7 @@ static BOOL wf_rail_window_common(rdpContext* context,
HANDLE hInstance;
WCHAR* titleW = NULL;
WNDCLASSEX wndClassEx;
- railWindow = (wfRailWindow*) calloc(1, sizeof(wfRailWindow));
+ railWindow = (wfRailWindow*)calloc(1, sizeof(wfRailWindow));
if (!railWindow)
return FALSE;
@@ -452,8 +447,9 @@ static BOOL wf_rail_window_common(rdpContext* context,
/* error handled below */
}
}
- else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
- windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
+ else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
+ windowState->titleInfo.length / 2, &title, 0, NULL,
+ NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
/* error handled below */
@@ -489,38 +485,35 @@ static BOOL wf_rail_window_common(rdpContext* context,
wndClassEx.hInstance = hInstance;
wndClassEx.hIconSm = NULL;
RegisterClassEx(&wndClassEx);
- railWindow->hWnd = CreateWindowExW(
- railWindow->dwExStyle, /* dwExStyle */
- _T("RdpRailWindow"), /* lpClassName */
- titleW, /* lpWindowName */
- railWindow->dwStyle, /* dwStyle */
- railWindow->x, /* x */
- railWindow->y, /* y */
- railWindow->width, /* nWidth */
- railWindow->height, /* nHeight */
- NULL, /* hWndParent */
- NULL, /* hMenu */
- hInstance, /* hInstance */
- NULL /* lpParam */
- );
- SetWindowLongPtr(railWindow->hWnd, GWLP_USERDATA, (LONG_PTR) railWindow);
- HashTable_Add(wfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId,
- (void*) railWindow);
+ railWindow->hWnd = CreateWindowExW(railWindow->dwExStyle, /* dwExStyle */
+ _T("RdpRailWindow"), /* lpClassName */
+ titleW, /* lpWindowName */
+ railWindow->dwStyle, /* dwStyle */
+ railWindow->x, /* x */
+ railWindow->y, /* y */
+ railWindow->width, /* nWidth */
+ railWindow->height, /* nHeight */
+ NULL, /* hWndParent */
+ NULL, /* hMenu */
+ hInstance, /* hInstance */
+ NULL /* lpParam */
+ );
+ SetWindowLongPtr(railWindow->hWnd, GWLP_USERDATA, (LONG_PTR)railWindow);
+ HashTable_Add(wfc->railWindows, (void*)(UINT_PTR)orderInfo->windowId, (void*)railWindow);
free(titleW);
UpdateWindow(railWindow->hWnd);
return TRUE;
}
else
{
- railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
- (void*)(UINT_PTR) orderInfo->windowId);
+ railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows,
+ (void*)(UINT_PTR)orderInfo->windowId);
}
if (!railWindow)
return TRUE;
- if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) ||
- (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE))
+ if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE))
{
if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
{
@@ -534,12 +527,8 @@ static BOOL wf_rail_window_common(rdpContext* context,
railWindow->height = windowState->windowHeight;
}
- SetWindowPos(railWindow->hWnd, NULL,
- railWindow->x,
- railWindow->y,
- railWindow->width,
- railWindow->height,
- 0);
+ SetWindowPos(railWindow->hWnd, NULL, railWindow->x, railWindow->y, railWindow->width,
+ railWindow->height, 0);
}
if (fieldFlags & WINDOW_ORDER_FIELD_OWNER)
@@ -552,8 +541,8 @@ static BOOL wf_rail_window_common(rdpContext* context,
railWindow->dwStyle &= ~RAIL_DISABLED_WINDOW_STYLES;
railWindow->dwExStyle = windowState->extendedStyle;
railWindow->dwExStyle &= ~RAIL_DISABLED_EXTENDED_WINDOW_STYLES;
- SetWindowLongPtr(railWindow->hWnd, GWL_STYLE, (LONG) railWindow->dwStyle);
- SetWindowLongPtr(railWindow->hWnd, GWL_EXSTYLE, (LONG) railWindow->dwExStyle);
+ SetWindowLongPtr(railWindow->hWnd, GWL_STYLE, (LONG)railWindow->dwStyle);
+ SetWindowLongPtr(railWindow->hWnd, GWL_EXSTYLE, (LONG)railWindow->dwExStyle);
}
if (fieldFlags & WINDOW_ORDER_FIELD_SHOW)
@@ -574,7 +563,7 @@ static BOOL wf_rail_window_common(rdpContext* context,
return FALSE;
}
}
- else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
+ else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
@@ -645,27 +634,26 @@ static BOOL wf_rail_window_common(rdpContext* context,
return TRUE;
}
-static BOOL wf_rail_window_delete(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL wf_rail_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
wfRailWindow* railWindow = NULL;
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailWindowDelete");
- railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
- (void*)(UINT_PTR) orderInfo->windowId);
+ railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows,
+ (void*)(UINT_PTR)orderInfo->windowId);
if (!railWindow)
return TRUE;
- HashTable_Remove(wfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId);
+ HashTable_Remove(wfc->railWindows, (void*)(UINT_PTR)orderInfo->windowId);
DestroyWindow(railWindow->hWnd);
free(railWindow);
return TRUE;
}
-static BOOL wf_rail_window_icon(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const WINDOW_ICON_ORDER* windowIcon)
+static BOOL wf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_ICON_ORDER* windowIcon)
{
HDC hDC;
int bpp;
@@ -677,12 +665,12 @@ static BOOL wf_rail_window_icon(rdpContext* context,
BITMAPINFO bitmapInfo;
wfRailWindow* railWindow;
BITMAPINFOHEADER* bitmapInfoHeader;
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailWindowIcon");
PrintRailIconInfo(orderInfo, windowIcon->iconInfo);
- railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
- (void*)(UINT_PTR) orderInfo->windowId);
+ railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows,
+ (void*)(UINT_PTR)orderInfo->windowId);
if (!railWindow)
return TRUE;
@@ -708,22 +696,19 @@ static BOOL wf_rail_window_icon(rdpContext* context,
bitmapInfoHeader->biYPelsPerMeter = height;
bitmapInfoHeader->biClrUsed = 0;
bitmapInfoHeader->biClrImportant = 0;
- iconInfo.hbmMask = CreateDIBitmap(hDC,
- bitmapInfoHeader, CBM_INIT,
- windowIcon->iconInfo->bitsMask,
- &bitmapInfo, DIB_RGB_COLORS);
- iconInfo.hbmColor = CreateDIBitmap(hDC,
- bitmapInfoHeader, CBM_INIT,
- windowIcon->iconInfo->bitsColor,
- &bitmapInfo, DIB_RGB_COLORS);
+ iconInfo.hbmMask = CreateDIBitmap(hDC, bitmapInfoHeader, CBM_INIT,
+ windowIcon->iconInfo->bitsMask, &bitmapInfo, DIB_RGB_COLORS);
+ iconInfo.hbmColor =
+ CreateDIBitmap(hDC, bitmapInfoHeader, CBM_INIT, windowIcon->iconInfo->bitsColor,
+ &bitmapInfo, DIB_RGB_COLORS);
hIcon = CreateIconIndirect(&iconInfo);
if (hIcon)
{
WPARAM wParam;
LPARAM lParam;
- wParam = (WPARAM) bigIcon ? ICON_BIG : ICON_SMALL;
- lParam = (LPARAM) hIcon;
+ wParam = (WPARAM)bigIcon ? ICON_BIG : ICON_SMALL;
+ lParam = (LPARAM)hIcon;
SendMessage(railWindow->hWnd, WM_SETICON, wParam, lParam);
}
@@ -737,15 +722,15 @@ static BOOL wf_rail_window_icon(rdpContext* context,
return TRUE;
}
-static BOOL wf_rail_window_cached_icon(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
+static BOOL wf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
{
WLog_DBG(TAG, "RailWindowCachedIcon");
return TRUE;
}
-static void wf_rail_notify_icon_common(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static void wf_rail_notify_icon_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
{
@@ -774,48 +759,46 @@ static void wf_rail_notify_icon_common(rdpContext* context,
}
}
-static BOOL wf_rail_notify_icon_create(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static BOOL wf_rail_notify_icon_create(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailNotifyIconCreate");
wf_rail_notify_icon_common(context, orderInfo, notifyIconState);
return TRUE;
}
-static BOOL wf_rail_notify_icon_update(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static BOOL wf_rail_notify_icon_update(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailNotifyIconUpdate");
wf_rail_notify_icon_common(context, orderInfo, notifyIconState);
return TRUE;
}
-static BOOL wf_rail_notify_icon_delete(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL wf_rail_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailNotifyIconDelete");
return TRUE;
}
-static BOOL wf_rail_monitored_desktop(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const MONITORED_DESKTOP_ORDER* monitoredDesktop)
+static BOOL wf_rail_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const MONITORED_DESKTOP_ORDER* monitoredDesktop)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailMonitorDesktop");
return TRUE;
}
-static BOOL wf_rail_non_monitored_desktop(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL wf_rail_non_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
- wfContext* wfc = (wfContext*) context;
+ wfContext* wfc = (wfContext*)context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailNonMonitorDesktop");
return TRUE;
@@ -844,7 +827,7 @@ void wf_rail_register_update_callbacks(rdpUpdate* update)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_execute_result(RailClientContext* context,
- const RAIL_EXEC_RESULT_ORDER* execResult)
+ const RAIL_EXEC_RESULT_ORDER* execResult)
{
WLog_DBG(TAG, "RailServerExecuteResult: 0x%08X", execResult->rawResult);
return CHANNEL_RC_OK;
@@ -873,7 +856,7 @@ static UINT wf_rail_server_handshake(RailClientContext* context,
RAIL_SYSPARAM_ORDER sysparam;
RAIL_HANDSHAKE_ORDER clientHandshake;
RAIL_CLIENT_STATUS_ORDER clientStatus;
- wfContext* wfc = (wfContext*) context->custom;
+ wfContext* wfc = (wfContext*)context->custom;
rdpSettings* settings = wfc->context.settings;
clientHandshake.buildNumber = 0x00001DB0;
context->ClientHandshake(context, &clientHandshake);
@@ -934,7 +917,7 @@ static UINT wf_rail_server_handshake_ex(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_local_move_size(RailClientContext* context,
- const RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+ const RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
return CHANNEL_RC_OK;
}
@@ -956,7 +939,7 @@ static UINT wf_rail_server_min_max_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_language_bar_info(RailClientContext* context,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
return CHANNEL_RC_OK;
}
@@ -967,7 +950,7 @@ static UINT wf_rail_server_language_bar_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_get_appid_response(RailClientContext* context,
- const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+ const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
return CHANNEL_RC_OK;
}
@@ -987,8 +970,7 @@ void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion)
for (index = 0; index < count; index++)
{
- railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
- (void*) pKeys[index]);
+ railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, (void*)pKeys[index]);
if (railWindow)
{
@@ -1016,9 +998,9 @@ void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion)
BOOL wf_rail_init(wfContext* wfc, RailClientContext* rail)
{
- rdpContext* context = (rdpContext*) wfc;
+ rdpContext* context = (rdpContext*)wfc;
wfc->rail = rail;
- rail->custom = (void*) wfc;
+ rail->custom = (void*)wfc;
rail->ServerExecuteResult = wf_rail_server_execute_result;
rail->ServerSystemParam = wf_rail_server_system_param;
rail->ServerHandshake = wf_rail_server_handshake;
diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c
index 3492f4353..c8a77f335 100644
--- a/client/X11/cli/xfreerdp.c
+++ b/client/X11/cli/xfreerdp.c
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
return 1;
settings = context->settings;
- xfc = (xfContext*) context;
+ xfc = (xfContext*)context;
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
diff --git a/client/X11/generate_argument_docbook.c b/client/X11/generate_argument_docbook.c
index 1a3ebf563..d3af6415e 100644
--- a/client/X11/generate_argument_docbook.c
+++ b/client/X11/generate_argument_docbook.c
@@ -35,7 +35,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not allocate string buffer.\n");
+ fprintf(stderr, "Could not allocate string buffer.\n");
exit(-2);
}
@@ -56,7 +56,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not reallocate string buffer.\n");
+ fprintf(stderr, "Could not reallocate string buffer.\n");
exit(-3);
}
@@ -80,7 +80,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not reallocate string buffer.\n");
+ fprintf(stderr, "Could not reallocate string buffer.\n");
exit(-4);
}
@@ -103,7 +103,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not reallocate string buffer.\n");
+ fprintf(stderr, "Could not reallocate string buffer.\n");
exit(-5);
}
@@ -124,7 +124,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not reallocate string buffer.\n");
+ fprintf(stderr, "Could not reallocate string buffer.\n");
exit(-6);
}
@@ -145,7 +145,7 @@ LPSTR tr_esc_str(LPCSTR arg, bool format)
if (NULL == tmp)
{
- fprintf(stderr, "Could not reallocate string buffer.\n");
+ fprintf(stderr, "Could not reallocate string buffer.\n");
exit(-7);
}
@@ -179,7 +179,7 @@ int main(int argc, char* argv[])
if (NULL == fp)
{
- fprintf(stderr, "Could not open '%s' for writing.\n", fname);
+ fprintf(stderr, "Could not open '%s' for writing.\n", fname);
return -1;
}
@@ -192,17 +192,17 @@ int main(int argc, char* argv[])
* compatible XML */
if (elements < 2)
{
- fprintf(stderr, "The argument array 'args' is empty, writing an empty file.\n");
+ fprintf(stderr, "The argument array 'args' is empty, writing an empty file.\n");
elements = 1;
}
for (x = 0; x < elements - 1; x++)
{
const COMMAND_LINE_ARGUMENT_A* arg = &args[x];
- char* name = tr_esc_str((LPSTR) arg->Name, FALSE);
- char* alias = tr_esc_str((LPSTR) arg->Alias, FALSE);
+ char* name = tr_esc_str((LPSTR)arg->Name, FALSE);
+ char* alias = tr_esc_str((LPSTR)arg->Alias, FALSE);
char* format = tr_esc_str(arg->Format, TRUE);
- char* text = tr_esc_str((LPSTR) arg->Text, FALSE);
+ char* text = tr_esc_str((LPSTR)arg->Text, FALSE);
fprintf(fp, "\t\t\t\n");
do
@@ -234,8 +234,7 @@ int main(int argc, char* argv[])
free(name);
name = alias;
- }
- while (alias);
+ } while (alias);
if (text)
{
@@ -249,7 +248,7 @@ int main(int argc, char* argv[])
fprintf(fp, " (default:%s)", arg->Default ? "on" : "off");
else if (arg->Default)
{
- char* value = tr_esc_str((LPSTR) arg->Default, FALSE);
+ char* value = tr_esc_str((LPSTR)arg->Default, FALSE);
fprintf(fp, " (default:%s)", value);
free(value);
}
@@ -269,4 +268,3 @@ int main(int argc, char* argv[])
fclose(fp);
return 0;
}
-
diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c
index 09a454f97..4241a1dc6 100644
--- a/client/X11/xf_channels.c
+++ b/client/X11/xf_channels.c
@@ -36,31 +36,31 @@
void xf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
{
- xfc->rdpei = (RdpeiClientContext*) e->pInterface;
+ xfc->rdpei = (RdpeiClientContext*)e->pInterface;
}
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
{
- xf_tsmf_init(xfc, (TsmfClientContext*) e->pInterface);
+ xf_tsmf_init(xfc, (TsmfClientContext*)e->pInterface);
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- xf_graphics_pipeline_init(xfc, (RdpgfxClientContext*) e->pInterface);
+ xf_graphics_pipeline_init(xfc, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
- xf_rail_init(xfc, (RailClientContext*) e->pInterface);
+ xf_rail_init(xfc, (RailClientContext*)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- xf_cliprdr_init(xfc, (CliprdrClientContext*) e->pInterface);
+ xf_cliprdr_init(xfc, (CliprdrClientContext*)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- xf_encomsp_init(xfc, (EncomspClientContext*) e->pInterface);
+ xf_encomsp_init(xfc, (EncomspClientContext*)e->pInterface);
}
else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
{
@@ -82,7 +82,7 @@ void xf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs*
void xf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = xfc->context.settings;
if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0)
@@ -95,23 +95,23 @@ void xf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEven
}
else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0)
{
- xf_tsmf_uninit(xfc, (TsmfClientContext*) e->pInterface);
+ xf_tsmf_uninit(xfc, (TsmfClientContext*)e->pInterface);
}
else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
- xf_graphics_pipeline_uninit(xfc, (RdpgfxClientContext*) e->pInterface);
+ xf_graphics_pipeline_uninit(xfc, (RdpgfxClientContext*)e->pInterface);
}
else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
{
- xf_rail_uninit(xfc, (RailClientContext*) e->pInterface);
+ xf_rail_uninit(xfc, (RailClientContext*)e->pInterface);
}
else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
{
- xf_cliprdr_uninit(xfc, (CliprdrClientContext*) e->pInterface);
+ xf_cliprdr_uninit(xfc, (CliprdrClientContext*)e->pInterface);
}
else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0)
{
- xf_encomsp_uninit(xfc, (EncomspClientContext*) e->pInterface);
+ xf_encomsp_uninit(xfc, (EncomspClientContext*)e->pInterface);
}
else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0)
{
diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c
index d0f3be38d..04f43b34f 100644
--- a/client/X11/xf_client.c
+++ b/client/X11/xf_client.c
@@ -102,7 +102,6 @@
#include "xf_channels.h"
#include "xfreerdp.h"
-
#include
#define TAG CLIENT_TAG("x11")
@@ -155,8 +154,8 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
if (XSubtractRegion(reg1, reg2, reg1) && !XEmptyRegion(reg1))
{
XSetRegion(xfc->display, xfc->gc, reg1);
- XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0,
- xfc->window->width, xfc->window->height);
+ XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0, xfc->window->width,
+ xfc->window->height);
XSetClipMask(xfc->display, xfc->gc, None);
}
@@ -165,10 +164,10 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
}
picFormat = XRenderFindVisualFormat(xfc->display, xfc->visual);
pa.subwindow_mode = IncludeInferiors;
- primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat,
- CPSubwindowMode, &pa);
- windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle,
- picFormat, CPSubwindowMode, &pa);
+ primaryPicture =
+ XRenderCreatePicture(xfc->display, xfc->primary, picFormat, CPSubwindowMode, &pa);
+ windowPicture =
+ XRenderCreatePicture(xfc->display, xfc->window->handle, picFormat, CPSubwindowMode, &pa);
// avoid blurry filter when scaling factor is 2x, 3x, etc
// useful when the client has high-dpi monitor
filter = FilterBilinear;
@@ -199,8 +198,8 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
w = ceil(x2 / xScalingFactor) + 1 - x;
h = ceil(y2 / yScalingFactor) + 1 - y;
XRenderSetPictureTransform(xfc->display, primaryPicture, &transform);
- XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x,
- y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h);
+ XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x, y, 0, 0,
+ xfc->offset_x + x, xfc->offset_y + y, w, h);
XRenderFreePicture(xfc->display, primaryPicture);
XRenderFreePicture(xfc->display, windowPicture);
}
@@ -243,7 +242,7 @@ void xf_draw_screen(xfContext* xfc, int x, int y, int w, int h)
static BOOL xf_desktop_resize(rdpContext* context)
{
rdpSettings* settings;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
settings = context->settings;
if (xfc->primary)
@@ -251,10 +250,8 @@ static BOOL xf_desktop_resize(rdpContext* context)
BOOL same = (xfc->primary == xfc->drawing) ? TRUE : FALSE;
XFreePixmap(xfc->display, xfc->primary);
- if (!(xfc->primary = XCreatePixmap(
- xfc->display, xfc->drawable,
- settings->DesktopWidth,
- settings->DesktopHeight, xfc->depth)))
+ if (!(xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth,
+ settings->DesktopHeight, xfc->depth)))
return FALSE;
if (same)
@@ -305,7 +302,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
UINT32 w, h;
int ninvalid;
HGDI_RGN cinvalid;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpGdi* gdi = context->gdi;
if (gdi->suppressOutput)
@@ -326,8 +323,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
return TRUE;
xf_lock_x11(xfc, FALSE);
- XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image,
- x, y, x, y, w, h);
+ XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h);
xf_draw_screen(xfc, x, y, w, h);
xf_unlock_x11(xfc, FALSE);
}
@@ -344,8 +340,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
y = cinvalid[i].y;
w = cinvalid[i].w;
h = cinvalid[i].h;
- XPutImage(xfc->display, xfc->primary, xfc->gc,
- xfc->image, x, y, x, y, w, h);
+ XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, x, y, x, y, w, h);
xf_draw_screen(xfc, x, y, w, h);
}
@@ -371,7 +366,7 @@ static BOOL xf_sw_end_paint(rdpContext* context)
static BOOL xf_sw_desktop_resize(rdpContext* context)
{
rdpGdi* gdi = context->gdi;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
BOOL ret = FALSE;
xf_lock_x11(xfc, TRUE);
@@ -385,9 +380,9 @@ static BOOL xf_sw_desktop_resize(rdpContext* context)
XDestroyImage(xfc->image);
}
- if (!(xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap,
- 0, (char*)gdi->primary_buffer, gdi->width,
- gdi->height, xfc->scanline_pad, gdi->stride)))
+ if (!(xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
+ (char*)gdi->primary_buffer, gdi->width, gdi->height,
+ xfc->scanline_pad, gdi->stride)))
{
goto out;
}
@@ -404,7 +399,7 @@ static BOOL xf_hw_end_paint(rdpContext* context)
{
INT32 x, y;
UINT32 w, h;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
if (xfc->context.gdi->suppressOutput)
return TRUE;
@@ -472,7 +467,7 @@ static BOOL xf_hw_end_paint(rdpContext* context)
static BOOL xf_hw_desktop_resize(rdpContext* context)
{
rdpGdi* gdi = context->gdi;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
BOOL ret = FALSE;
xf_lock_x11(xfc, TRUE);
@@ -491,7 +486,7 @@ static BOOL xf_process_x_events(freerdp* instance)
BOOL status;
XEvent xevent;
int pending_status;
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
status = TRUE;
pending_status = TRUE;
@@ -624,8 +619,7 @@ BOOL xf_create_window(xfContext* xfc)
xfc->gc = XCreateGC(xfc->display, xfc->drawable, GCGraphicsExposures, &gcv);
if (!xfc->primary)
- xfc->primary = XCreatePixmap(xfc->display, xfc->drawable,
- settings->DesktopWidth,
+ xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth,
settings->DesktopHeight, xfc->depth);
xfc->drawing = xfc->primary;
@@ -634,25 +628,21 @@ BOOL xf_create_window(xfContext* xfc)
xfc->bitmap_mono = XCreatePixmap(xfc->display, xfc->drawable, 8, 8, 1);
if (!xfc->gc_mono)
- xfc->gc_mono = XCreateGC(xfc->display, xfc->bitmap_mono, GCGraphicsExposures,
- &gcv);
+ xfc->gc_mono = XCreateGC(xfc->display, xfc->bitmap_mono, GCGraphicsExposures, &gcv);
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen));
- XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0,
- settings->DesktopWidth,
+ XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, settings->DesktopWidth,
settings->DesktopHeight);
XFlush(xfc->display);
if (!xfc->image)
{
rdpGdi* gdi = xfc->context.gdi;
- xfc->image = XCreateImage(xfc->display, xfc->visual,
- xfc->depth,
- ZPixmap, 0, (char*) gdi->primary_buffer,
- settings->DesktopWidth, settings->DesktopHeight,
- xfc->scanline_pad, gdi->stride);
+ xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
+ (char*)gdi->primary_buffer, settings->DesktopWidth,
+ settings->DesktopHeight, xfc->scanline_pad, gdi->stride);
xfc->image->byte_order = LSBFirst;
xfc->image->bitmap_bit_order = LSBFirst;
}
@@ -721,7 +711,7 @@ static void xf_window_free(xfContext* xfc)
void xf_toggle_fullscreen(xfContext* xfc)
{
WindowStateChangeEventArgs e;
- rdpContext* context = (rdpContext*) xfc;
+ rdpContext* context = (rdpContext*)xfc;
rdpSettings* settings = context->settings;
/*
@@ -767,7 +757,7 @@ BOOL xf_toggle_control(xfContext* xfc)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_encomsp_participant_created(EncomspClientContext* context,
- ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
+ ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated)
{
return CHANNEL_RC_OK;
}
@@ -775,7 +765,7 @@ static UINT xf_encomsp_participant_created(EncomspClientContext* context,
void xf_encomsp_init(xfContext* xfc, EncomspClientContext* encomsp)
{
xfc->encomsp = encomsp;
- encomsp->custom = (void*) xfc;
+ encomsp->custom = (void*)xfc;
encomsp->ParticipantCreated = xf_encomsp_participant_created;
}
@@ -847,15 +837,14 @@ static BOOL xf_get_pixmap_info(xfContext* xfc)
tpl.class = TrueColor;
tpl.screen = xfc->screen_number;
- if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen),
- &window_attributes) == 0)
+ if (XGetWindowAttributes(xfc->display, RootWindowOfScreen(xfc->screen), &window_attributes) ==
+ 0)
{
WLog_ERR(TAG, "XGetWindowAttributes failed");
return FALSE;
}
- vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask,
- &tpl, &vi_count);
+ vis = XGetVisualInfo(xfc->display, VisualClassMask | VisualScreenMask, &tpl, &vi_count);
if (!vis)
{
@@ -923,10 +912,9 @@ static int _xf_error_handler(Display* d, XErrorEvent* ev)
return xf_error_handler(d, ev);
}
-static BOOL xf_play_sound(rdpContext* context,
- const PLAY_SOUND_UPDATE* play_sound)
+static BOOL xf_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
WINPR_UNUSED(play_sound);
XkbBell(xfc->display, None, 100, 0);
return TRUE;
@@ -938,9 +926,9 @@ static void xf_check_extensions(xfContext* context)
int xkb_major = XkbMajorVersion;
int xkb_minor = XkbMinorVersion;
- if (XkbLibraryVersion(&xkb_major, &xkb_minor)
- && XkbQueryExtension(context->display, &xkb_opcode, &xkb_event,
- &xkb_error, &xkb_major, &xkb_minor))
+ if (XkbLibraryVersion(&xkb_major, &xkb_minor) &&
+ XkbQueryExtension(context->display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_major,
+ &xkb_minor))
{
context->xkbAvailable = TRUE;
}
@@ -950,8 +938,7 @@ static void xf_check_extensions(xfContext* context)
int xrender_event_base;
int xrender_error_base;
- if (XRenderQueryExtension(context->display, &xrender_event_base,
- &xrender_error_base))
+ if (XRenderQueryExtension(context->display, &xrender_event_base, &xrender_error_base))
{
context->xrenderAvailable = TRUE;
}
@@ -962,7 +949,7 @@ static void xf_check_extensions(xfContext* context)
#ifdef WITH_XI
/* Input device which does NOT have the correct mapping. We must disregard */
/* this device when trying to find the input device which is the pointer. */
-static const char TEST_PTR_STR [] = "Virtual core XTEST pointer";
+static const char TEST_PTR_STR[] = "Virtual core XTEST pointer";
static const size_t TEST_PTR_LEN = sizeof(TEST_PTR_STR) / sizeof(char);
/* Invalid device identifier which indicate failure. */
@@ -1054,19 +1041,18 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map)
/* Assignment of physical (not logical) mouse buttons to wire flags. */
/* Notice that the middle button is 2 in X11, but 3 in RDP. */
-static const button_map xf_button_flags[NUM_BUTTONS_MAPPED] =
-{
- {Button1, PTR_FLAGS_BUTTON1},
- {Button2, PTR_FLAGS_BUTTON3},
- {Button3, PTR_FLAGS_BUTTON2},
- {Button4, PTR_FLAGS_WHEEL | 0x78},
- {Button5, PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x78},
- {6, PTR_FLAGS_HWHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x78},
- {7, PTR_FLAGS_HWHEEL | 0x78},
- {8, PTR_XFLAGS_BUTTON1},
- {9, PTR_XFLAGS_BUTTON2},
- {97, PTR_XFLAGS_BUTTON1},
- {112, PTR_XFLAGS_BUTTON2}
+static const button_map xf_button_flags[NUM_BUTTONS_MAPPED] = {
+ { Button1, PTR_FLAGS_BUTTON1 },
+ { Button2, PTR_FLAGS_BUTTON3 },
+ { Button3, PTR_FLAGS_BUTTON2 },
+ { Button4, PTR_FLAGS_WHEEL | 0x78 },
+ { Button5, PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x78 },
+ { 6, PTR_FLAGS_HWHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x78 },
+ { 7, PTR_FLAGS_HWHEEL | 0x78 },
+ { 8, PTR_XFLAGS_BUTTON1 },
+ { 9, PTR_XFLAGS_BUTTON2 },
+ { 97, PTR_XFLAGS_BUTTON1 },
+ { 112, PTR_XFLAGS_BUTTON2 }
};
static UINT16 get_flags_for_button(int button)
@@ -1135,29 +1121,29 @@ static void xf_button_map_init(xfContext* xfc)
}
/**
-* Callback given to freerdp_connect() to process the pre-connect operations.
-* It will fill the rdp_freerdp structure (instance) with the appropriate options to use for the connection.
-*
-* @param instance - pointer to the rdp_freerdp structure that contains the connection's parameters, and will
-* be filled with the appropriate informations.
-*
-* @return TRUE if successful. FALSE otherwise.
-* Can exit with error code XF_EXIT_PARSE_ARGUMENTS if there is an error in the parameters.
-*/
+ * Callback given to freerdp_connect() to process the pre-connect operations.
+ * It will fill the rdp_freerdp structure (instance) with the appropriate options to use for the
+ * connection.
+ *
+ * @param instance - pointer to the rdp_freerdp structure that contains the connection's parameters,
+ * and will be filled with the appropriate informations.
+ *
+ * @return TRUE if successful. FALSE otherwise.
+ * Can exit with error code XF_EXIT_PARSE_ARGUMENTS if there is an error in the parameters.
+ */
static BOOL xf_pre_connect(freerdp* instance)
{
rdpChannels* channels;
rdpSettings* settings;
rdpContext* context = instance->context;
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
UINT32 maxWidth = 0;
UINT32 maxHeight = 0;
settings = instance->settings;
channels = context->channels;
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER;
- PubSub_SubscribeChannelConnected(instance->context->pubSub,
- xf_OnChannelConnectedEventHandler);
+ PubSub_SubscribeChannelConnected(instance->context->pubSub, xf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
xf_OnChannelDisconnectedEventHandler);
@@ -1208,8 +1194,8 @@ static BOOL xf_pre_connect(freerdp* instance)
* If /f is specified in combination with /smart-sizing:widthxheight then
* we run the session in the /smart-sizing dimensions scaled to full screen
*/
- if (settings->Fullscreen && settings->SmartSizing &&
- settings->SmartSizingWidth && settings->SmartSizingHeight)
+ if (settings->Fullscreen && settings->SmartSizing && settings->SmartSizingWidth &&
+ settings->SmartSizingHeight)
{
settings->DesktopWidth = settings->SmartSizingWidth;
settings->DesktopHeight = settings->SmartSizingHeight;
@@ -1225,17 +1211,17 @@ static BOOL xf_pre_connect(freerdp* instance)
}
/**
-* Callback given to freerdp_connect() to perform post-connection operations.
-* It will be called only if the connection was initialized properly, and will continue the initialization based on the
-* newly created connection.
-*/
+ * Callback given to freerdp_connect() to perform post-connection operations.
+ * It will be called only if the connection was initialized properly, and will continue the
+ * initialization based on the newly created connection.
+ */
static BOOL xf_post_connect(freerdp* instance)
{
rdpUpdate* update;
rdpContext* context;
rdpSettings* settings;
ResizeWindowEventArgs e;
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
context = instance->context;
settings = instance->settings;
update = context->update;
@@ -1333,7 +1319,7 @@ static void xf_post_disconnect(freerdp* instance)
return;
context = instance->context;
- xfc = (xfContext*) context;
+ xfc = (xfContext*)context;
PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
xf_OnChannelConnectedEventHandler);
PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
@@ -1363,7 +1349,7 @@ static void xf_post_disconnect(freerdp* instance)
static int xf_logon_error_info(freerdp* instance, UINT32 data, UINT32 type)
{
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
const char* str_data = freerdp_get_logon_error_info_data(data);
const char* str_type = freerdp_get_logon_error_info_type(type);
WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type);
@@ -1382,8 +1368,8 @@ static DWORD WINAPI xf_input_thread(LPVOID arg)
wMessageQueue* queue;
int pending_status = 1;
int process_status = 1;
- freerdp* instance = (freerdp*) arg;
- xfContext* xfc = (xfContext*) instance->context;
+ freerdp* instance = (freerdp*)arg;
+ xfContext* xfc = (xfContext*)instance->context;
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
nCount = 0;
events[nCount++] = MessageQueue_Event(queue);
@@ -1427,8 +1413,7 @@ static DWORD WINAPI xf_input_thread(LPVOID arg)
if (!process_status)
break;
}
- }
- while (pending_status);
+ } while (pending_status);
if (!process_status)
{
@@ -1475,12 +1460,12 @@ static BOOL handle_window_events(freerdp* instance)
}
/** Main loop for the rdp connection.
-* It will be run from the thread's entry point (thread_func()).
-* It initiates the connection, and will continue to run until the session ends,
-* processing events as they are received.
-* @param instance - pointer to the rdp_freerdp structure that contains the session's settings
-* @return A code from the enum XF_EXIT_CODE (0 if successful)
-*/
+ * It will be run from the thread's entry point (thread_func()).
+ * It initiates the connection, and will continue to run until the session ends,
+ * processing events as they are received.
+ * @param instance - pointer to the rdp_freerdp structure that contains the session's settings
+ * @return A code from the enum XF_EXIT_CODE (0 if successful)
+ */
static DWORD WINAPI xf_client_thread(LPVOID param)
{
BOOL status;
@@ -1498,17 +1483,17 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
rdpSettings* settings;
TimerEventArgs timerEvent;
EventArgsInit(&timerEvent, "xfreerdp");
- instance = (freerdp*) param;
+ instance = (freerdp*)param;
context = instance->context;
status = freerdp_connect(instance);
- xfc = (xfContext*) instance->context;
+ xfc = (xfContext*)instance->context;
if (!status)
{
- if (freerdp_get_last_error(instance->context) ==
- FREERDP_ERROR_AUTHENTICATION_FAILED)
+ if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_AUTHENTICATION_FAILED)
exit_code = XF_EXIT_AUTH_FAILURE;
- else if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED)
+ else if (freerdp_get_last_error(instance->context) ==
+ FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED)
exit_code = XF_EXIT_NEGO_FAILURE;
else
exit_code = XF_EXIT_CONN_FAILED;
@@ -1522,17 +1507,16 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
/* --authonly ? */
if (instance->settings->AuthenticationOnly)
{
- WLog_ERR(TAG, "Authentication only, exit status %"PRId32"", !status);
+ WLog_ERR(TAG, "Authentication only, exit status %" PRId32 "", !status);
goto disconnect;
}
if (!status)
{
- WLog_ERR(TAG, "Freerdp connect error exit status %"PRId32"", !status);
+ WLog_ERR(TAG, "Freerdp connect error exit status %" PRId32 "", !status);
exit_code = freerdp_error_info(instance);
- if (freerdp_get_last_error(instance->context) ==
- FREERDP_ERROR_AUTHENTICATION_FAILED)
+ if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_AUTHENTICATION_FAILED)
exit_code = XF_EXIT_AUTH_FAILURE;
else if (exit_code == ERRINFO_SUCCESS)
exit_code = XF_EXIT_CONN_FAILED;
@@ -1590,7 +1574,8 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
}
{
- DWORD tmp = freerdp_get_event_handles(context, &handles[nCount], ARRAYSIZE(handles) - nCount);
+ DWORD tmp =
+ freerdp_get_event_handles(context, &handles[nCount], ARRAYSIZE(handles) - nCount);
if (tmp == 0)
{
@@ -1655,8 +1640,8 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
freerdp_get_disconnect_ultimatum(context) == Disconnect_Ultimatum_user_requested)
{
/* This situation might be limited to Windows XP. */
- WLog_INFO(TAG,
- "Error info says user did not initiate but disconnect ultimatum says they did; treat this as a user logoff");
+ WLog_INFO(TAG, "Error info says user did not initiate but disconnect ultimatum says "
+ "they did; treat this as a user logoff");
exit_code = XF_EXIT_LOGOFF;
}
}
@@ -1674,8 +1659,7 @@ end:
DWORD xf_exit_code_from_disconnect_reason(DWORD reason)
{
- if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS
- && reason <= XF_EXIT_NEGO_FAILURE))
+ if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS && reason <= XF_EXIT_NEGO_FAILURE))
return reason;
/* License error set */
else if (reason >= 0x100 && reason <= 0x10A)
@@ -1698,10 +1682,9 @@ static void xf_TerminateEventHandler(void* context, TerminateEventArgs* e)
}
#ifdef WITH_XRENDER
-static void xf_ZoomingChangeEventHandler(void* context,
- ZoomingChangeEventArgs* e)
+static void xf_ZoomingChangeEventHandler(void* context, ZoomingChangeEventArgs* e)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = xfc->context.settings;
int w = xfc->scaledWidth + e->dx;
int h = xfc->scaledHeight + e->dy;
@@ -1723,10 +1706,9 @@ static void xf_ZoomingChangeEventHandler(void* context,
xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
}
-static void xf_PanningChangeEventHandler(void* context,
- PanningChangeEventArgs* e)
+static void xf_PanningChangeEventHandler(void* context, PanningChangeEventArgs* e)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = xfc->context.settings;
if (e->dx == 0 && e->dy == 0)
@@ -1739,8 +1721,8 @@ static void xf_PanningChangeEventHandler(void* context,
#endif
/**
-* Client Interface
-*/
+ * Client Interface
+ */
static BOOL xfreerdp_client_global_init()
{
@@ -1758,18 +1740,16 @@ static void xfreerdp_client_global_uninit()
static int xfreerdp_client_start(rdpContext* context)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
if (!settings->ServerHostname)
{
- WLog_ERR(TAG,
- "error: server hostname was not specified with /v:[:port]");
+ WLog_ERR(TAG, "error: server hostname was not specified with /v:[:port]");
return -1;
}
- if (!(xfc->thread = CreateThread(NULL, 0, xf_client_thread,
- context->instance, 0, NULL)))
+ if (!(xfc->thread = CreateThread(NULL, 0, xf_client_thread, context->instance, 0, NULL)))
{
WLog_ERR(TAG, "failed to create client thread");
return -1;
@@ -1780,7 +1760,7 @@ static int xfreerdp_client_start(rdpContext* context)
static int xfreerdp_client_stop(rdpContext* context)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
freerdp_abort_connect(context->instance);
if (xfc->thread)
@@ -1798,7 +1778,7 @@ static Atom get_supported_atom(xfContext* xfc, const char* atomName)
unsigned long i;
const Atom atom = XInternAtom(xfc->display, atomName, False);
- for (i = 0; i < xfc->supportedAtomCount; i++)
+ for (i = 0; i < xfc->supportedAtomCount; i++)
{
if (xfc->supportedAtoms[i] == atom)
return atom;
@@ -1808,7 +1788,7 @@ static Atom get_supported_atom(xfContext* xfc, const char* atomName)
}
static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
{
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
assert(context);
assert(xfc);
assert(!xfc->display);
@@ -1822,13 +1802,10 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
instance->VerifyCertificateEx = client_cli_verify_certificate_ex;
instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex;
instance->LogonErrorInfo = xf_logon_error_info;
- PubSub_SubscribeTerminate(context->pubSub,
- xf_TerminateEventHandler);
+ PubSub_SubscribeTerminate(context->pubSub, xf_TerminateEventHandler);
#ifdef WITH_XRENDER
- PubSub_SubscribeZoomingChange(context->pubSub,
- xf_ZoomingChangeEventHandler);
- PubSub_SubscribePanningChange(context->pubSub,
- xf_PanningChangeEventHandler);
+ PubSub_SubscribeZoomingChange(context->pubSub, xf_ZoomingChangeEventHandler);
+ PubSub_SubscribePanningChange(context->pubSub, xf_PanningChangeEventHandler);
#endif
xfc->UseXThreads = TRUE;
/* uncomment below if debugging to prevent keyboard grap */
@@ -1848,8 +1825,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
if (!xfc->display)
{
WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL));
- WLog_ERR(TAG,
- "Please check that the $DISPLAY environment variable is properly set.");
+ WLog_ERR(TAG, "Please check that the $DISPLAY environment variable is properly set.");
goto fail_open_display;
}
@@ -1878,8 +1854,8 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
unsigned long nitems, after;
unsigned char* data = NULL;
int status = XGetWindowProperty(xfc->display, RootWindowOfScreen(xfc->screen),
- xfc->_NET_SUPPORTED, 0, 1024, False, XA_ATOM,
- &actual_type, &actual_format, &nitems, &after, &data);
+ xfc->_NET_SUPPORTED, 0, 1024, False, XA_ATOM, &actual_type,
+ &actual_format, &nitems, &after, &data);
if ((status == Success) && (actual_type == XA_ATOM) && (actual_format == 32))
{
@@ -1894,46 +1870,39 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context)
xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False);
xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False);
- xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP",
- False);
+ xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP", False);
xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False);
xfc->_NET_WM_STATE = get_supported_atom(xfc, "_NET_WM_STATE");
xfc->_NET_WM_STATE_FULLSCREEN = get_supported_atom(xfc, "_NET_WM_STATE_FULLSCREEN");
- xfc->_NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(xfc->display,
- "_NET_WM_STATE_MAXIMIZED_HORZ", False);
- xfc->_NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(xfc->display,
- "_NET_WM_STATE_MAXIMIZED_VERT", False);
+ xfc->_NET_WM_STATE_MAXIMIZED_HORZ =
+ XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+ xfc->_NET_WM_STATE_MAXIMIZED_VERT =
+ XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
xfc->_NET_WM_FULLSCREEN_MONITORS = get_supported_atom(xfc, "_NET_WM_FULLSCREEN_MONITORS");
xfc->_NET_WM_NAME = XInternAtom(xfc->display, "_NET_WM_NAME", False);
xfc->_NET_WM_PID = XInternAtom(xfc->display, "_NET_WM_PID", False);
- xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE",
- False);
- xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_NORMAL", False);
- xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_DIALOG", False);
- xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_POPUP", False);
- xfc->_NET_WM_WINDOW_TYPE_POPUP_MENU = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_POPUP_MENU", False);
- xfc->_NET_WM_WINDOW_TYPE_UTILITY = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_UTILITY", False);
- xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = XInternAtom(xfc->display,
- "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False);
- xfc->_NET_WM_STATE_SKIP_TASKBAR = XInternAtom(xfc->display,
- "_NET_WM_STATE_SKIP_TASKBAR", False);
- xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display,
- "_NET_WM_STATE_SKIP_PAGER", False);
- xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE",
- False);
- xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display,
- "_NET_MOVERESIZE_WINDOW", False);
+ xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE", False);
+ xfc->_NET_WM_WINDOW_TYPE_NORMAL =
+ XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
+ xfc->_NET_WM_WINDOW_TYPE_DIALOG =
+ XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_POPUP", False);
+ xfc->_NET_WM_WINDOW_TYPE_POPUP_MENU =
+ XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_POPUP_MENU", False);
+ xfc->_NET_WM_WINDOW_TYPE_UTILITY =
+ XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
+ xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU =
+ XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False);
+ xfc->_NET_WM_STATE_SKIP_TASKBAR =
+ XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_TASKBAR", False);
+ xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_PAGER", False);
+ xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE", False);
+ xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display, "_NET_MOVERESIZE_WINDOW", False);
xfc->UTF8_STRING = XInternAtom(xfc->display, "UTF8_STRING", FALSE);
xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False);
xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False);
xfc->WM_STATE = XInternAtom(xfc->display, "WM_STATE", False);
- xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds,
- WINPR_FD_READ);
+ xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds, WINPR_FD_READ);
if (!xfc->x11event)
{
@@ -1980,18 +1949,15 @@ fail_open_display:
static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
{
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
if (!context)
return;
- PubSub_UnsubscribeTerminate(context->pubSub,
- xf_TerminateEventHandler);
+ PubSub_UnsubscribeTerminate(context->pubSub, xf_TerminateEventHandler);
#ifdef WITH_XRENDER
- PubSub_UnsubscribeZoomingChange(context->pubSub,
- xf_ZoomingChangeEventHandler);
- PubSub_UnsubscribePanningChange(context->pubSub,
- xf_PanningChangeEventHandler);
+ PubSub_UnsubscribeZoomingChange(context->pubSub, xf_ZoomingChangeEventHandler);
+ PubSub_UnsubscribePanningChange(context->pubSub, xf_PanningChangeEventHandler);
#endif
if (xfc->display)
diff --git a/client/X11/xf_client.h b/client/X11/xf_client.h
index 34535a1e1..e3b00bf9b 100644
--- a/client/X11/xf_client.h
+++ b/client/X11/xf_client.h
@@ -36,15 +36,15 @@
#include
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-/**
- * Client Interface
- */
+ /**
+ * Client Interface
+ */
-
-FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
+ FREERDP_API int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints);
#ifdef __cplusplus
}
diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c
index befc1126f..461dc5b6a 100644
--- a/client/X11/xf_cliprdr.c
+++ b/client/X11/xf_cliprdr.c
@@ -45,7 +45,7 @@
#define TAG CLIENT_TAG("x11")
-#define MAX_CLIPBOARD_FORMATS 255
+#define MAX_CLIPBOARD_FORMATS 255
struct xf_cliprdr_format
{
@@ -132,17 +132,15 @@ static void xf_cliprdr_check_owner(xfClipboard* clipboard)
static BOOL xf_cliprdr_is_self_owned(xfClipboard* clipboard)
{
xfContext* xfc = clipboard->xfc;
- return XGetSelectionOwner(xfc->display,
- clipboard->clipboard_atom) == xfc->drawable;
+ return XGetSelectionOwner(xfc->display, clipboard->clipboard_atom) == xfc->drawable;
}
-static void xf_cliprdr_set_raw_transfer_enabled(xfClipboard* clipboard,
- BOOL enabled)
+static void xf_cliprdr_set_raw_transfer_enabled(xfClipboard* clipboard, BOOL enabled)
{
UINT32 data = enabled;
xfContext* xfc = clipboard->xfc;
- XChangeProperty(xfc->display, xfc->drawable, clipboard->raw_transfer_atom,
- XA_INTEGER, 32, PropModeReplace, (BYTE*) &data, 1);
+ XChangeProperty(xfc->display, xfc->drawable, clipboard->raw_transfer_atom, XA_INTEGER, 32,
+ PropModeReplace, (BYTE*)&data, 1);
}
static BOOL xf_cliprdr_is_raw_transfer_available(xfClipboard* clipboard)
@@ -160,9 +158,9 @@ static BOOL xf_cliprdr_is_raw_transfer_available(xfClipboard* clipboard)
if (owner != None)
{
- result = XGetWindowProperty(xfc->display, owner,
- clipboard->raw_transfer_atom, 0, 4, 0, XA_INTEGER,
- &type, &format, &length, &bytes_left, (BYTE**) &data);
+ result =
+ XGetWindowProperty(xfc->display, owner, clipboard->raw_transfer_atom, 0, 4, 0,
+ XA_INTEGER, &type, &format, &length, &bytes_left, (BYTE**)&data);
}
if (data)
@@ -180,14 +178,12 @@ static BOOL xf_cliprdr_is_raw_transfer_available(xfClipboard* clipboard)
return is_enabled ? TRUE : FALSE;
}
-static BOOL xf_cliprdr_formats_equal(const CLIPRDR_FORMAT* server,
- const xfCliprdrFormat* client)
+static BOOL xf_cliprdr_formats_equal(const CLIPRDR_FORMAT* server, const xfCliprdrFormat* client)
{
if (server->formatName && client->formatName)
{
/* The server may be using short format names while we store them in full form. */
- return (0 == strncmp(server->formatName, client->formatName,
- strlen(server->formatName)));
+ return (0 == strncmp(server->formatName, client->formatName, strlen(server->formatName)));
}
if (!server->formatName && !client->formatName)
@@ -198,8 +194,7 @@ static BOOL xf_cliprdr_formats_equal(const CLIPRDR_FORMAT* server,
return FALSE;
}
-static xfCliprdrFormat* xf_cliprdr_get_client_format_by_id(
- xfClipboard* clipboard, UINT32 formatId)
+static xfCliprdrFormat* xf_cliprdr_get_client_format_by_id(xfClipboard* clipboard, UINT32 formatId)
{
int index;
xfCliprdrFormat* format;
@@ -215,8 +210,7 @@ static xfCliprdrFormat* xf_cliprdr_get_client_format_by_id(
return NULL;
}
-static xfCliprdrFormat* xf_cliprdr_get_client_format_by_atom(
- xfClipboard* clipboard, Atom atom)
+static xfCliprdrFormat* xf_cliprdr_get_client_format_by_atom(xfClipboard* clipboard, Atom atom)
{
int i;
xfCliprdrFormat* format;
@@ -232,8 +226,7 @@ static xfCliprdrFormat* xf_cliprdr_get_client_format_by_atom(
return NULL;
}
-static CLIPRDR_FORMAT* xf_cliprdr_get_server_format_by_atom(
- xfClipboard* clipboard, Atom atom)
+static CLIPRDR_FORMAT* xf_cliprdr_get_server_format_by_atom(xfClipboard* clipboard, Atom atom)
{
int i, j;
xfCliprdrFormat* client_format;
@@ -263,13 +256,11 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_server_format_by_atom(
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_send_data_request(xfClipboard* clipboard,
- UINT32 formatId)
+static UINT xf_cliprdr_send_data_request(xfClipboard* clipboard, UINT32 formatId)
{
CLIPRDR_FORMAT_DATA_REQUEST request = { 0 };
request.requestedFormatId = formatId;
- return clipboard->context->ClientFormatDataRequest(clipboard->context,
- &request);
+ return clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
}
/**
@@ -277,15 +268,13 @@ static UINT xf_cliprdr_send_data_request(xfClipboard* clipboard,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_send_data_response(xfClipboard* clipboard, BYTE* data,
- int size)
+static UINT xf_cliprdr_send_data_response(xfClipboard* clipboard, BYTE* data, int size)
{
CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
response.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
response.dataLen = size;
response.requestedFormatData = data;
- return clipboard->context->ClientFormatDataResponse(clipboard->context,
- &response);
+ return clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
}
static wStream* xf_cliprdr_serialize_server_format_list(xfClipboard* clipboard)
@@ -302,8 +291,7 @@ static wStream* xf_cliprdr_serialize_server_format_list(xfClipboard* clipboard)
}
/* If present, the last format is always synthetic CF_RAW. Do not include it. */
- formatCount = (clipboard->numServerFormats > 0) ? clipboard->numServerFormats -
- 1 : 0;
+ formatCount = (clipboard->numServerFormats > 0) ? clipboard->numServerFormats - 1 : 0;
Stream_Write_UINT32(s, formatCount);
for (i = 0; i < formatCount; i++)
@@ -332,8 +320,8 @@ error:
return NULL;
}
-static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data,
- size_t length, UINT32* numFormats)
+static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data, size_t length,
+ UINT32* numFormats)
{
UINT32 i;
wStream* s = NULL;
@@ -355,11 +343,11 @@ static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data,
if (*numFormats > MAX_CLIPBOARD_FORMATS)
{
- WLog_ERR(TAG, "unexpectedly large number of formats: %"PRIu32"", *numFormats);
+ WLog_ERR(TAG, "unexpectedly large number of formats: %" PRIu32 "", *numFormats);
goto error;
}
- if (!(formats = (CLIPRDR_FORMAT*) calloc(*numFormats, sizeof(CLIPRDR_FORMAT))))
+ if (!(formats = (CLIPRDR_FORMAT*)calloc(*numFormats, sizeof(CLIPRDR_FORMAT))))
{
WLog_ERR(TAG, "failed to allocate format list");
goto error;
@@ -377,12 +365,12 @@ static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data,
}
Stream_Read_UINT32(s, formats[i].formatId);
- formatName = (const char*) Stream_Pointer(s);
+ formatName = (const char*)Stream_Pointer(s);
formatNameLength = strnlen(formatName, Stream_GetRemainingLength(s));
if (formatNameLength == Stream_GetRemainingLength(s))
{
- WLog_ERR(TAG, "missing terminating null byte, %"PRIuz" bytes left to read",
+ WLog_ERR(TAG, "missing terminating null byte, %" PRIuz " bytes left to read",
formatNameLength);
goto error;
}
@@ -412,8 +400,7 @@ static void xf_cliprdr_free_formats(CLIPRDR_FORMAT* formats, UINT32 numFormats)
free(formats);
}
-static CLIPRDR_FORMAT* xf_cliprdr_get_raw_server_formats(xfClipboard* clipboard,
- UINT32* numFormats)
+static CLIPRDR_FORMAT* xf_cliprdr_get_raw_server_formats(xfClipboard* clipboard, UINT32* numFormats)
{
Atom type = None;
int format = 0;
@@ -423,22 +410,21 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_raw_server_formats(xfClipboard* clipboard,
CLIPRDR_FORMAT* formats = NULL;
xfContext* xfc = clipboard->xfc;
*numFormats = 0;
- XGetWindowProperty(xfc->display, clipboard->owner,
- clipboard->raw_format_list_atom,
- 0, 4096, False, clipboard->raw_format_list_atom, &type, &format,
- &length, &remaining, &data);
+ XGetWindowProperty(xfc->display, clipboard->owner, clipboard->raw_format_list_atom, 0, 4096,
+ False, clipboard->raw_format_list_atom, &type, &format, &length, &remaining,
+ &data);
- if (data && length > 0 && format == 8
- && type == clipboard->raw_format_list_atom)
+ if (data && length > 0 && format == 8 && type == clipboard->raw_format_list_atom)
{
formats = xf_cliprdr_parse_server_format_list(data, length, numFormats);
}
else
{
WLog_ERR(TAG,
- "failed to retrieve raw format list: data=%p, length=%lu, format=%d, type=%lu (expected=%lu)",
- (void*) data, length, format, (unsigned long) type,
- (unsigned long) clipboard->raw_format_list_atom);
+ "failed to retrieve raw format list: data=%p, length=%lu, format=%d, type=%lu "
+ "(expected=%lu)",
+ (void*)data, length, format, (unsigned long)type,
+ (unsigned long)clipboard->raw_format_list_atom);
}
if (data)
@@ -447,8 +433,8 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_raw_server_formats(xfClipboard* clipboard,
return formats;
}
-static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(
- xfClipboard* clipboard, UINT32* numFormats)
+static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(xfClipboard* clipboard,
+ UINT32* numFormats)
{
unsigned long i;
Atom atom;
@@ -460,8 +446,8 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(
CLIPRDR_FORMAT* formats = NULL;
xfContext* xfc = clipboard->xfc;
*numFormats = 0;
- XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom,
- 0, 200, 0, XA_ATOM, &atom, &format_property, &length, &bytes_left, &data);
+ XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom, 0, 200, 0, XA_ATOM,
+ &atom, &format_property, &length, &bytes_left, &data);
if (length > 0)
{
@@ -471,7 +457,7 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(
goto out;
}
- if (!(formats = (CLIPRDR_FORMAT*) calloc(length, sizeof(CLIPRDR_FORMAT))))
+ if (!(formats = (CLIPRDR_FORMAT*)calloc(length, sizeof(CLIPRDR_FORMAT))))
{
WLog_ERR(TAG, "failed to allocate %lu CLIPRDR_FORMAT structs", length);
goto out;
@@ -480,7 +466,7 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(
for (i = 0; i < length; i++)
{
- atom = ((Atom*) data)[i];
+ atom = ((Atom*)data)[i];
format = xf_cliprdr_get_client_format_by_atom(clipboard, atom);
if (format)
@@ -499,8 +485,7 @@ out:
return formats;
}
-static CLIPRDR_FORMAT* xf_cliprdr_get_client_formats(xfClipboard* clipboard,
- UINT32* numFormats)
+static CLIPRDR_FORMAT* xf_cliprdr_get_client_formats(xfClipboard* clipboard, UINT32* numFormats)
{
CLIPRDR_FORMAT* formats = NULL;
*numFormats = 0;
@@ -528,8 +513,8 @@ static void xf_cliprdr_provide_server_format_list(xfClipboard* clipboard)
if (formats)
{
XChangeProperty(xfc->display, xfc->drawable, clipboard->raw_format_list_atom,
- clipboard->raw_format_list_atom, 8, PropModeReplace,
- Stream_Buffer(formats), Stream_Length(formats));
+ clipboard->raw_format_list_atom, 8, PropModeReplace, Stream_Buffer(formats),
+ Stream_Length(formats));
}
else
{
@@ -552,8 +537,8 @@ static void xf_cliprdr_get_requested_targets(xfClipboard* clipboard)
xf_cliprdr_free_formats(formats, numFormats);
}
-static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
- BOOL hasData, BYTE* data, int size)
+static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasData, BYTE* data,
+ int size)
{
BOOL bSuccess;
UINT32 SrcSize;
@@ -566,8 +551,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
if (clipboard->incr_starts && hasData)
return;
- format = xf_cliprdr_get_client_format_by_id(clipboard,
- clipboard->requestedFormatId);
+ format = xf_cliprdr_get_client_format_by_id(clipboard, clipboard->requestedFormatId);
if (!hasData || !data || !format)
{
@@ -586,7 +570,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
case CF_TEXT:
case CF_OEMTEXT:
case CF_UNICODETEXT:
- size = strlen((char*) data) + 1;
+ size = strlen((char*)data) + 1;
srcFormatId = ClipboardGetFormatId(clipboard->system, "UTF8_STRING");
break;
@@ -603,7 +587,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
break;
}
- SrcSize = (UINT32) size;
+ SrcSize = (UINT32)size;
bSuccess = ClipboardSetData(clipboard->system, srcFormatId, data, SrcSize);
if (format->formatName)
@@ -614,7 +598,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
if (bSuccess)
{
DstSize = 0;
- pDstData = (BYTE*) ClipboardGetData(clipboard->system, dstFormatId, &DstSize);
+ pDstData = (BYTE*)ClipboardGetData(clipboard->system, dstFormatId, &DstSize);
}
if (!pDstData)
@@ -634,7 +618,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
(dstFormatId == ClipboardGetFormatId(clipboard->system, "FileGroupDescriptorW")))
{
UINT error = NO_ERROR;
- FILEDESCRIPTOR* file_array = (FILEDESCRIPTOR*) pDstData;
+ FILEDESCRIPTOR* file_array = (FILEDESCRIPTOR*)pDstData;
UINT32 file_count = DstSize / sizeof(FILEDESCRIPTOR);
pDstData = NULL;
DstSize = 0;
@@ -646,7 +630,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard,
free(file_array);
}
- xf_cliprdr_send_data_response(clipboard, pDstData, (int) DstSize);
+ xf_cliprdr_send_data_response(clipboard, pDstData, (int)DstSize);
free(pDstData);
}
@@ -661,8 +645,7 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
unsigned long bytes_left;
xfCliprdrFormat* format;
xfContext* xfc = clipboard->xfc;
- format = xf_cliprdr_get_client_format_by_id(clipboard,
- clipboard->requestedFormatId);
+ format = xf_cliprdr_get_client_format_by_id(clipboard, clipboard->requestedFormatId);
if (!format || (format->atom != target))
{
@@ -670,8 +653,7 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
return FALSE;
}
- XGetWindowProperty(xfc->display, xfc->drawable,
- clipboard->property_atom, 0, 0, 0, target,
+ XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom, 0, 0, 0, target,
&type, &format_property, &length, &bytes_left, &data);
if (data)
@@ -708,23 +690,22 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
clipboard->incr_starts = 0;
has_data = TRUE;
}
- else if (XGetWindowProperty(xfc->display, xfc->drawable,
- clipboard->property_atom, 0, bytes_left, 0, target,
- &type, &format_property, &length, &dummy, &data) == Success)
+ else if (XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom, 0,
+ bytes_left, 0, target, &type, &format_property, &length, &dummy,
+ &data) == Success)
{
if (clipboard->incr_starts)
{
BYTE* new_data;
bytes_left = length * format_property / 8;
- new_data = (BYTE*) realloc(clipboard->incr_data,
- clipboard->incr_data_length + bytes_left);
+ new_data =
+ (BYTE*)realloc(clipboard->incr_data, clipboard->incr_data_length + bytes_left);
if (!new_data)
return FALSE;
clipboard->incr_data = new_data;
- CopyMemory(clipboard->incr_data + clipboard->incr_data_length, data,
- bytes_left);
+ CopyMemory(clipboard->incr_data + clipboard->incr_data_length, data, bytes_left);
clipboard->incr_data_length += bytes_left;
XFree(data);
data = NULL;
@@ -738,7 +719,7 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
}
XDeleteProperty(xfc->display, xfc->drawable, clipboard->property_atom);
- xf_cliprdr_process_requested_data(clipboard, has_data, data, (int) bytes_left);
+ xf_cliprdr_process_requested_data(clipboard, has_data, data, (int)bytes_left);
if (data)
XFree(data);
@@ -771,27 +752,25 @@ static void xf_cliprdr_provide_targets(xfClipboard* clipboard, XEvent* respond)
if (respond->xselection.property != None)
{
- XChangeProperty(xfc->display, respond->xselection.requestor,
- respond->xselection.property, XA_ATOM, 32, PropModeReplace,
- (BYTE*) clipboard->targets, clipboard->numTargets);
+ XChangeProperty(xfc->display, respond->xselection.requestor, respond->xselection.property,
+ XA_ATOM, 32, PropModeReplace, (BYTE*)clipboard->targets,
+ clipboard->numTargets);
}
}
-static void xf_cliprdr_provide_data(xfClipboard* clipboard, XEvent* respond,
- BYTE* data, UINT32 size)
+static void xf_cliprdr_provide_data(xfClipboard* clipboard, XEvent* respond, BYTE* data,
+ UINT32 size)
{
xfContext* xfc = clipboard->xfc;
if (respond->xselection.property != None)
{
- XChangeProperty(xfc->display, respond->xselection.requestor,
- respond->xselection.property, respond->xselection.target,
- 8, PropModeReplace, data, size);
+ XChangeProperty(xfc->display, respond->xselection.requestor, respond->xselection.property,
+ respond->xselection.target, 8, PropModeReplace, data, size);
}
}
-static BOOL xf_cliprdr_process_selection_notify(xfClipboard* clipboard,
- XEvent* xevent)
+static BOOL xf_cliprdr_process_selection_notify(xfClipboard* clipboard, XEvent* xevent)
{
if (xevent->xselection.target == clipboard->targets[1])
{
@@ -831,8 +810,7 @@ static void xf_cliprdr_clear_cached_data(xfClipboard* clipboard)
clipboard->data_raw_length = 0;
}
-static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
- XEvent* xevent)
+static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard, XEvent* xevent)
{
int fmt;
Atom type;
@@ -853,7 +831,7 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
delayRespond = FALSE;
- if (!(respond = (XEvent*) calloc(1, sizeof(XEvent))))
+ if (!(respond = (XEvent*)calloc(1, sizeof(XEvent))))
{
WLog_ERR(TAG, "failed to allocate XEvent data");
return FALSE;
@@ -871,8 +849,7 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
{
/* TODO */
}
- else if (xevent->xselectionrequest.target ==
- clipboard->targets[1]) /* TARGETS */
+ else if (xevent->xselectionrequest.target == clipboard->targets[1]) /* TARGETS */
{
/* Someone else requests our available formats */
respond->xselection.property = xevent->xselectionrequest.property;
@@ -880,8 +857,7 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
}
else
{
- format = xf_cliprdr_get_server_format_by_atom(clipboard,
- xevent->xselectionrequest.target);
+ format = xf_cliprdr_get_server_format_by_atom(clipboard, xevent->xselectionrequest.target);
if (format && (xevent->xselectionrequest.requestor != xfc->drawable))
{
@@ -892,8 +868,8 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
if (formatId == CF_RAW)
{
if (XGetWindowProperty(xfc->display, xevent->xselectionrequest.requestor,
- clipboard->property_atom, 0, 4, 0, XA_INTEGER,
- &type, &fmt, &length, &bytes_left, &data) != Success)
+ clipboard->property_atom, 0, 4, 0, XA_INTEGER, &type, &fmt,
+ &length, &bytes_left, &data) != Success)
{
}
@@ -907,8 +883,8 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
/* We can compare format names by pointer value here as they are both
* taken from the same clipboard->serverFormats array */
- matchingFormat = (formatId == clipboard->data_format_id)
- && (formatName == clipboard->data_format_name);
+ matchingFormat = (formatId == clipboard->data_format_id) &&
+ (formatName == clipboard->data_format_name);
if (matchingFormat && (clipboard->data != 0) && !rawTransfer)
{
@@ -921,7 +897,8 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
{
/* Cached raw clipboard data available. Send it now */
respond->xselection.property = xevent->xselectionrequest.property;
- xf_cliprdr_provide_data(clipboard, respond, clipboard->data_raw, clipboard->data_raw_length);
+ xf_cliprdr_provide_data(clipboard, respond, clipboard->data_raw,
+ clipboard->data_raw_length);
}
else if (clipboard->respond)
{
@@ -955,8 +932,7 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
return TRUE;
}
-static BOOL xf_cliprdr_process_selection_clear(xfClipboard* clipboard,
- XEvent* xevent)
+static BOOL xf_cliprdr_process_selection_clear(xfClipboard* clipboard, XEvent* xevent)
{
xfContext* xfc = clipboard->xfc;
@@ -969,8 +945,7 @@ static BOOL xf_cliprdr_process_selection_clear(xfClipboard* clipboard,
return TRUE;
}
-static BOOL xf_cliprdr_process_property_notify(xfClipboard* clipboard,
- XEvent* xevent)
+static BOOL xf_cliprdr_process_property_notify(xfClipboard* clipboard, XEvent* xevent)
{
xfCliprdrFormat* format;
xfContext* xfc = NULL;
@@ -990,8 +965,7 @@ static BOOL xf_cliprdr_process_property_notify(xfClipboard* clipboard,
else if ((xevent->xproperty.window == xfc->drawable) &&
(xevent->xproperty.state == PropertyNewValue) && clipboard->incr_starts)
{
- format = xf_cliprdr_get_client_format_by_id(clipboard,
- clipboard->requestedFormatId);
+ format = xf_cliprdr_get_client_format_by_id(clipboard, clipboard->requestedFormatId);
if (format)
xf_cliprdr_get_requested_data(clipboard, format->atom);
@@ -1014,10 +988,10 @@ void xf_cliprdr_handle_xevent(xfContext* xfc, XEvent* event)
#ifdef WITH_XFIXES
- if (clipboard->xfixes_supported
- && event->type == XFixesSelectionNotify + clipboard->xfixes_event_base)
+ if (clipboard->xfixes_supported &&
+ event->type == XFixesSelectionNotify + clipboard->xfixes_event_base)
{
- XFixesSelectionNotifyEvent* se = (XFixesSelectionNotifyEvent*) event;
+ XFixesSelectionNotifyEvent* se = (XFixesSelectionNotifyEvent*)event;
if (se->subtype == XFixesSetSelectionOwnerNotify)
{
@@ -1074,19 +1048,16 @@ static UINT xf_cliprdr_send_client_capabilities(xfClipboard* clipboard)
CLIPRDR_CAPABILITIES capabilities;
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
capabilities.cCapabilitiesSets = 1;
- capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
- (generalCapabilitySet);
+ capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
generalCapabilitySet.capabilitySetLength = 12;
generalCapabilitySet.version = CB_CAPS_VERSION_2;
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
if (clipboard->streams_supported && clipboard->file_formats_registered)
- generalCapabilitySet.generalFlags |=
- CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS;
+ generalCapabilitySet.generalFlags |= CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS;
- return clipboard->context->ClientCapabilities(clipboard->context,
- &capabilities);
+ return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
}
/**
@@ -1105,9 +1076,9 @@ static UINT xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
if (numFormats)
{
- if (!(formats = (CLIPRDR_FORMAT*) calloc(numFormats, sizeof(CLIPRDR_FORMAT))))
+ if (!(formats = (CLIPRDR_FORMAT*)calloc(numFormats, sizeof(CLIPRDR_FORMAT))))
{
- WLog_ERR(TAG, "failed to allocate %"PRIu32" CLIPRDR_FORMAT structs", numFormats);
+ WLog_ERR(TAG, "failed to allocate %" PRIu32 " CLIPRDR_FORMAT structs", numFormats);
return CHANNEL_RC_NO_MEMORY;
}
}
@@ -1127,8 +1098,8 @@ static UINT xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
if (clipboard->owner && clipboard->owner != xfc->drawable)
{
/* Request the owner for TARGETS, and wait for SelectionNotify event */
- XConvertSelection(xfc->display, clipboard->clipboard_atom,
- clipboard->targets[1], clipboard->property_atom, xfc->drawable, CurrentTime);
+ XConvertSelection(xfc->display, clipboard->clipboard_atom, clipboard->targets[1],
+ clipboard->property_atom, xfc->drawable, CurrentTime);
}
return ret;
@@ -1139,15 +1110,13 @@ static UINT xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_send_client_format_list_response(xfClipboard* clipboard,
- BOOL status)
+static UINT xf_cliprdr_send_client_format_list_response(xfClipboard* clipboard, BOOL status)
{
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
formatListResponse.dataLen = 0;
- return clipboard->context->ClientFormatListResponse(clipboard->context,
- &formatListResponse);
+ return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse);
}
/**
@@ -1158,7 +1127,7 @@ static UINT xf_cliprdr_send_client_format_list_response(xfClipboard* clipboard,
static UINT xf_cliprdr_monitor_ready(CliprdrClientContext* context,
const CLIPRDR_MONITOR_READY* monitorReady)
{
- xfClipboard* clipboard = (xfClipboard*) context->custom;
+ xfClipboard* clipboard = (xfClipboard*)context->custom;
UINT ret;
WINPR_UNUSED(monitorReady);
@@ -1179,22 +1148,22 @@ static UINT xf_cliprdr_monitor_ready(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_cliprdr_server_capabilities(CliprdrClientContext* context,
- const CLIPRDR_CAPABILITIES* capabilities)
+ const CLIPRDR_CAPABILITIES* capabilities)
{
UINT32 i;
const CLIPRDR_CAPABILITY_SET* caps;
const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps;
- const BYTE* capsPtr = (const BYTE*) capabilities->capabilitySets;
- xfClipboard* clipboard = (xfClipboard*) context->custom;
+ const BYTE* capsPtr = (const BYTE*)capabilities->capabilitySets;
+ xfClipboard* clipboard = (xfClipboard*)context->custom;
clipboard->streams_supported = FALSE;
for (i = 0; i < capabilities->cCapabilitiesSets; i++)
{
- caps = (const CLIPRDR_CAPABILITY_SET*) capsPtr;
+ caps = (const CLIPRDR_CAPABILITY_SET*)capsPtr;
if (caps->capabilitySetType == CB_CAPSTYPE_GENERAL)
{
- generalCaps = (const CLIPRDR_GENERAL_CAPABILITY_SET*) caps;
+ generalCaps = (const CLIPRDR_GENERAL_CAPABILITY_SET*)caps;
if (generalCaps->generalFlags & CB_STREAM_FILECLIP_ENABLED)
{
@@ -1214,11 +1183,11 @@ static UINT xf_cliprdr_server_capabilities(CliprdrClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_LIST* formatList)
+ const CLIPRDR_FORMAT_LIST* formatList)
{
UINT32 i;
int j;
- xfClipboard* clipboard = (xfClipboard*) context->custom;
+ xfClipboard* clipboard = (xfClipboard*)context->custom;
xfContext* xfc = clipboard->xfc;
UINT ret;
xf_cliprdr_clear_cached_data(clipboard);
@@ -1237,11 +1206,10 @@ static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context,
clipboard->numServerFormats = formatList->numFormats + 1; /* +1 for CF_RAW */
- if (!(clipboard->serverFormats = (CLIPRDR_FORMAT*) calloc(
- clipboard->numServerFormats, sizeof(CLIPRDR_FORMAT))))
+ if (!(clipboard->serverFormats =
+ (CLIPRDR_FORMAT*)calloc(clipboard->numServerFormats, sizeof(CLIPRDR_FORMAT))))
{
- WLog_ERR(TAG, "failed to allocate %d CLIPRDR_FORMAT structs",
- clipboard->numServerFormats);
+ WLog_ERR(TAG, "failed to allocate %d CLIPRDR_FORMAT structs", clipboard->numServerFormats);
return CHANNEL_RC_NO_MEMORY;
}
@@ -1292,8 +1260,7 @@ static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context,
}
ret = xf_cliprdr_send_client_format_list_response(clipboard, TRUE);
- XSetSelectionOwner(xfc->display, clipboard->clipboard_atom, xfc->drawable,
- CurrentTime);
+ XSetSelectionOwner(xfc->display, clipboard->clipboard_atom, xfc->drawable, CurrentTime);
XFlush(xfc->display);
return ret;
}
@@ -1303,10 +1270,11 @@ static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_server_format_list_response(CliprdrClientContext*
- context, const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
+static UINT
+xf_cliprdr_server_format_list_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
{
- //xfClipboard* clipboard = (xfClipboard*) context->custom;
+ // xfClipboard* clipboard = (xfClipboard*) context->custom;
return CHANNEL_RC_OK;
}
@@ -1315,21 +1283,22 @@ static UINT xf_cliprdr_server_format_list_response(CliprdrClientContext*
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_server_format_data_request(CliprdrClientContext* context,
- const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
+static UINT
+xf_cliprdr_server_format_data_request(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
{
BOOL rawTransfer;
xfCliprdrFormat* format = NULL;
UINT32 formatId = formatDataRequest->requestedFormatId;
- xfClipboard* clipboard = (xfClipboard*) context->custom;
+ xfClipboard* clipboard = (xfClipboard*)context->custom;
xfContext* xfc = clipboard->xfc;
rawTransfer = xf_cliprdr_is_raw_transfer_available(clipboard);
if (rawTransfer)
{
format = xf_cliprdr_get_client_format_by_id(clipboard, CF_RAW);
- XChangeProperty(xfc->display, xfc->drawable, clipboard->property_atom,
- XA_INTEGER, 32, PropModeReplace, (BYTE*) &formatId, 1);
+ XChangeProperty(xfc->display, xfc->drawable, clipboard->property_atom, XA_INTEGER, 32,
+ PropModeReplace, (BYTE*)&formatId, 1);
}
else
format = xf_cliprdr_get_client_format_by_id(clipboard, formatId);
@@ -1338,8 +1307,8 @@ static UINT xf_cliprdr_server_format_data_request(CliprdrClientContext* context,
return xf_cliprdr_send_data_response(clipboard, NULL, 0);
clipboard->requestedFormatId = rawTransfer ? CF_RAW : formatId;
- XConvertSelection(xfc->display, clipboard->clipboard_atom,
- format->atom, clipboard->property_atom, xfc->drawable, CurrentTime);
+ XConvertSelection(xfc->display, clipboard->clipboard_atom, format->atom,
+ clipboard->property_atom, xfc->drawable, CurrentTime);
XFlush(xfc->display);
/* After this point, we expect a SelectionNotify event from the clipboard owner. */
return CHANNEL_RC_OK;
@@ -1350,8 +1319,9 @@ static UINT xf_cliprdr_server_format_data_request(CliprdrClientContext* context,
*
* @return 0 on success, otherwise a Win32 error code
*/
-static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
- context, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
+static UINT
+xf_cliprdr_server_format_data_response(CliprdrClientContext* context,
+ const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
BOOL bSuccess;
BYTE* pDstData;
@@ -1362,7 +1332,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
BOOL nullTerminated = FALSE;
UINT32 size = formatDataResponse->dataLen;
const BYTE* data = formatDataResponse->requestedFormatData;
- xfClipboard* clipboard = (xfClipboard*) context->custom;
+ xfClipboard* clipboard = (xfClipboard*)context->custom;
xfContext* xfc = clipboard->xfc;
if (!clipboard->respond)
@@ -1427,7 +1397,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
}
}
- SrcSize = (UINT32) size;
+ SrcSize = (UINT32)size;
bSuccess = ClipboardSetData(clipboard->system, srcFormatId, data, SrcSize);
if (bSuccess)
@@ -1438,7 +1408,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
return CHANNEL_RC_OK;
}
- pDstData = (BYTE*) ClipboardGetData(clipboard->system, dstFormatId, &DstSize);
+ pDstData = (BYTE*)ClipboardGetData(clipboard->system, dstFormatId, &DstSize);
if (!pDstData)
{
@@ -1462,7 +1432,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
/* We have to copy the original data again, as pSrcData is now owned
* by clipboard->system. Memory allocation failure is not fatal here
* as this is only a cached value. */
- clipboard->data_raw = (BYTE*) malloc(size);
+ clipboard->data_raw = (BYTE*)malloc(size);
if (clipboard->data_raw)
{
@@ -1471,20 +1441,21 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
}
else
{
- WLog_WARN(TAG, "failed to allocate %"PRIu32" bytes for a copy of raw clipboard data", size);
+ WLog_WARN(TAG, "failed to allocate %" PRIu32 " bytes for a copy of raw clipboard data",
+ size);
}
xf_cliprdr_provide_data(clipboard, clipboard->respond, pDstData, DstSize);
- XSendEvent(xfc->display, clipboard->respond->xselection.requestor, 0, 0,
- clipboard->respond);
+ XSendEvent(xfc->display, clipboard->respond->xselection.requestor, 0, 0, clipboard->respond);
XFlush(xfc->display);
free(clipboard->respond);
clipboard->respond = NULL;
return CHANNEL_RC_OK;
}
-static UINT xf_cliprdr_server_file_size_request(xfClipboard* clipboard,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+xf_cliprdr_server_file_size_request(xfClipboard* clipboard,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wClipboardFileSizeRequest request = { 0 };
request.streamId = fileContentsRequest->streamId;
@@ -1492,15 +1463,16 @@ static UINT xf_cliprdr_server_file_size_request(xfClipboard* clipboard,
if (fileContentsRequest->cbRequested != sizeof(UINT64))
{
- WLog_WARN(TAG, "unexpected FILECONTENTS_SIZE request: %"PRIu32" bytes",
+ WLog_WARN(TAG, "unexpected FILECONTENTS_SIZE request: %" PRIu32 " bytes",
fileContentsRequest->cbRequested);
}
return clipboard->delegate->ClientRequestFileSize(clipboard->delegate, &request);
}
-static UINT xf_cliprdr_server_file_range_request(xfClipboard* clipboard,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+xf_cliprdr_server_file_range_request(xfClipboard* clipboard,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
wClipboardFileRangeRequest request = { 0 };
request.streamId = fileContentsRequest->streamId;
@@ -1511,8 +1483,9 @@ static UINT xf_cliprdr_server_file_range_request(xfClipboard* clipboard,
return clipboard->delegate->ClientRequestFileRange(clipboard->delegate, &request);
}
-static UINT xf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+xf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
response.msgFlags = CB_RESPONSE_FAIL;
@@ -1520,8 +1493,9 @@ static UINT xf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
return context->ClientFileContentsResponse(context, &response);
}
-static UINT xf_cliprdr_server_file_contents_request(CliprdrClientContext* context,
- const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
+static UINT
+xf_cliprdr_server_file_contents_request(CliprdrClientContext* context,
+ const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
{
UINT error = NO_ERROR;
xfClipboard* clipboard = context->custom;
@@ -1553,19 +1527,21 @@ static UINT xf_cliprdr_server_file_contents_request(CliprdrClientContext* contex
}
static UINT xf_cliprdr_clipboard_file_size_success(wClipboardDelegate* delegate,
- const wClipboardFileSizeRequest* request, UINT64 fileSize)
+ const wClipboardFileSizeRequest* request,
+ UINT64 fileSize)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
xfClipboard* clipboard = delegate->custom;
response.msgFlags = CB_RESPONSE_OK;
response.streamId = request->streamId;
response.cbRequested = sizeof(UINT64);
- response.requestedData = (BYTE*) &fileSize;
+ response.requestedData = (BYTE*)&fileSize;
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
}
static UINT xf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate,
- const wClipboardFileSizeRequest* request, UINT errorCode)
+ const wClipboardFileSizeRequest* request,
+ UINT errorCode)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
xfClipboard* clipboard = delegate->custom;
@@ -1577,19 +1553,21 @@ static UINT xf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate,
}
static UINT xf_cliprdr_clipboard_file_range_success(wClipboardDelegate* delegate,
- const wClipboardFileRangeRequest* request, const BYTE* data, UINT32 size)
+ const wClipboardFileRangeRequest* request,
+ const BYTE* data, UINT32 size)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
xfClipboard* clipboard = delegate->custom;
response.msgFlags = CB_RESPONSE_OK;
response.streamId = request->streamId;
response.cbRequested = size;
- response.requestedData = (BYTE*) data;
+ response.requestedData = (BYTE*)data;
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
}
static UINT xf_cliprdr_clipboard_file_range_failure(wClipboardDelegate* delegate,
- const wClipboardFileRangeRequest* request, UINT errorCode)
+ const wClipboardFileRangeRequest* request,
+ UINT errorCode)
{
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
xfClipboard* clipboard = delegate->custom;
@@ -1606,7 +1584,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
rdpChannels* channels;
xfClipboard* clipboard;
- if (!(clipboard = (xfClipboard*) calloc(1, sizeof(xfClipboard))))
+ if (!(clipboard = (xfClipboard*)calloc(1, sizeof(xfClipboard))))
{
WLog_ERR(TAG, "failed to allocate xfClipboard data");
return NULL;
@@ -1614,7 +1592,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
xfc->clipboard = clipboard;
clipboard->xfc = xfc;
- channels = ((rdpContext*) xfc)->channels;
+ channels = ((rdpContext*)xfc)->channels;
clipboard->channels = channels;
clipboard->system = ClipboardCreate();
clipboard->requestedFormatId = -1;
@@ -1629,8 +1607,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
clipboard->property_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR", FALSE);
clipboard->raw_transfer_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_RAW", FALSE);
- clipboard->raw_format_list_atom =
- XInternAtom(xfc->display, "_FREERDP_CLIPRDR_FORMATS", FALSE);
+ clipboard->raw_format_list_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_FORMATS", FALSE);
xf_cliprdr_set_raw_transfer_enabled(clipboard, TRUE);
XSelectInput(xfc->display, clipboard->root_window, PropertyChangeMask);
#ifdef WITH_XFIXES
@@ -1643,7 +1620,8 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
if (XFixesQueryVersion(xfc->display, &xfmajor, &xfminor))
{
XFixesSelectSelectionInput(xfc->display, clipboard->root_window,
- clipboard->clipboard_atom, XFixesSetSelectionOwnerNotifyMask);
+ clipboard->clipboard_atom,
+ XFixesSetSelectionOwnerNotifyMask);
clipboard->xfixes_supported = TRUE;
}
else
@@ -1657,8 +1635,9 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
}
#else
- WLog_ERR(TAG,
- "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!");
+ WLog_ERR(
+ TAG,
+ "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!");
#endif
clipboard->clientFormats[n].atom = XInternAtom(xfc->display, "_FREERDP_RAW", False);
clipboard->clientFormats[n].formatId = CF_RAW;
@@ -1767,7 +1746,7 @@ void xf_cliprdr_init(xfContext* xfc, CliprdrClientContext* cliprdr)
{
xfc->cliprdr = cliprdr;
xfc->clipboard->context = cliprdr;
- cliprdr->custom = (void*) xfc->clipboard;
+ cliprdr->custom = (void*)xfc->clipboard;
cliprdr->MonitorReady = xf_cliprdr_monitor_ready;
cliprdr->ServerCapabilities = xf_cliprdr_server_capabilities;
cliprdr->ServerFormatList = xf_cliprdr_server_format_list;
diff --git a/client/X11/xf_disp.c b/client/X11/xf_disp.c
index 33d9dd612..8c596527d 100644
--- a/client/X11/xf_disp.c
+++ b/client/X11/xf_disp.c
@@ -25,7 +25,7 @@
#include
#if (RANDR_MAJOR * 100 + RANDR_MINOR) >= 105
-# define USABLE_XRANDR
+#define USABLE_XRANDR
#endif
#endif
@@ -33,7 +33,6 @@
#include "xf_disp.h"
#include "xf_monitor.h"
-
#define TAG CLIENT_TAG("x11disp")
#define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */
@@ -121,8 +120,8 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp)
if (xfc->fullscreen && (settings->MonitorCount > 0))
{
- if (xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray,
- settings->MonitorCount) != CHANNEL_RC_OK)
+ if (xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) !=
+ CHANNEL_RC_OK)
return FALSE;
}
else
@@ -378,8 +377,8 @@ BOOL xf_disp_handle_xevent(xfContext* xfc, XEvent* event)
#endif
xf_detect_monitors(xfc, &maxWidth, &maxHeight);
- return xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray,
- settings->MonitorCount) == CHANNEL_RC_OK;
+ return xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) ==
+ CHANNEL_RC_OK;
}
BOOL xf_disp_handle_configureNotify(xfContext* xfc, int width, int height)
@@ -406,7 +405,8 @@ static UINT xf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors
xfDispContext* xfDisp = (xfDispContext*)disp->custom;
rdpSettings* settings = xfDisp->xfc->context.settings;
WLog_DBG(TAG,
- "DisplayControlCapsPdu: MaxNumMonitors: %"PRIu32" MaxMonitorAreaFactorA: %"PRIu32" MaxMonitorAreaFactorB: %"PRIu32"",
+ "DisplayControlCapsPdu: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32
+ " MaxMonitorAreaFactorB: %" PRIu32 "",
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
xfDisp->activated = TRUE;
@@ -430,7 +430,7 @@ BOOL xf_disp_init(xfDispContext* xfDisp, DispClientContext* disp)
return FALSE;
xfDisp->disp = disp;
- disp->custom = (void*) xfDisp;
+ disp->custom = (void*)xfDisp;
if (settings->DynamicResolutionUpdate)
{
diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c
index 3c227eb2d..c3c38550c 100644
--- a/client/X11/xf_event.c
+++ b/client/X11/xf_event.c
@@ -39,7 +39,11 @@
#define TAG CLIENT_TAG("x11")
-#define CLAMP_COORDINATES(x, y) if (x < 0) x = 0; if (y < 0) y = 0
+#define CLAMP_COORDINATES(x, y) \
+ if (x < 0) \
+ x = 0; \
+ if (y < 0) \
+ y = 0
static const char* x11_event_string(int event)
{
@@ -155,7 +159,10 @@ static const char* x11_event_string(int event)
#ifdef WITH_DEBUG_X11
#define DEBUG_X11(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_X11(...) do { } while (0)
+#define DEBUG_X11(...) \
+ do \
+ { \
+ } while (0)
#endif
BOOL xf_event_action_script_init(xfContext* xfc)
@@ -224,7 +231,7 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
for (index = 0; index < count; index++)
{
- name = (char*) ArrayList_GetItem(xfc->xevents, index);
+ name = (char*)ArrayList_GetItem(xfc->xevents, index);
if (_stricmp(name, xeventName) == 0)
{
@@ -236,8 +243,8 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
if (!match)
return FALSE;
- sprintf_s(command, sizeof(command), "%s xevent %s %lu",
- xfc->context.settings->ActionScript, xeventName, (unsigned long) xfc->window->handle);
+ sprintf_s(command, sizeof(command), "%s xevent %s %lu", xfc->context.settings->ActionScript,
+ xeventName, (unsigned long)xfc->window->handle);
actionScript = popen(command, "r");
if (!actionScript)
@@ -326,8 +333,7 @@ static BOOL xf_event_VisibilityNotify(xfContext* xfc, XEvent* event, BOOL app)
xfc->unobscured = event->xvisibility.state == VisibilityUnobscured;
return TRUE;
}
-BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state,
- Window window, BOOL app)
+BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app)
{
rdpInput* input;
Window childWindow;
@@ -346,9 +352,8 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state,
return TRUE;
/* Translate to desktop coordinates */
- XTranslateCoordinates(xfc->display, window,
- RootWindowOfScreen(xfc->screen),
- x, y, &x, &y, &childWindow);
+ XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y,
+ &childWindow);
}
xf_event_adjust_coordinates(xfc, &x, &y);
@@ -356,8 +361,7 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state,
if (xfc->fullscreen && !app)
{
- XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot,
- CurrentTime);
+ XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
}
return TRUE;
@@ -370,12 +374,12 @@ static BOOL xf_event_MotionNotify(xfContext* xfc, XEvent* event, BOOL app)
if (xfc->window)
xf_floatbar_set_root_y(xfc->window->floatbar, event->xmotion.y);
- return xf_generic_MotionNotify(xfc, event->xmotion.x, event->xmotion.y,
- event->xmotion.state, event->xmotion.window, app);
+ return xf_generic_MotionNotify(xfc, event->xmotion.x, event->xmotion.y, event->xmotion.state,
+ event->xmotion.window, app);
}
-BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button,
- Window window, BOOL app, BOOL down)
+BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app,
+ BOOL down)
{
UINT16 flags = 0;
rdpInput* input;
@@ -426,9 +430,8 @@ BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button,
return TRUE;
/* Translate to desktop coordinates */
- XTranslateCoordinates(xfc->display, window,
- RootWindowOfScreen(xfc->screen),
- x, y, &x, &y, &childWindow);
+ XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y,
+ &x, &y, &childWindow);
}
xf_event_adjust_coordinates(xfc, &x, &y);
@@ -447,8 +450,8 @@ static BOOL xf_event_ButtonPress(xfContext* xfc, XEvent* event, BOOL app)
if (xfc->use_xinput)
return TRUE;
- return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y,
- event->xbutton.button, event->xbutton.window, app, TRUE);
+ return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y, event->xbutton.button,
+ event->xbutton.window, app, TRUE);
}
static BOOL xf_event_ButtonRelease(xfContext* xfc, XEvent* event, BOOL app)
@@ -456,15 +459,15 @@ static BOOL xf_event_ButtonRelease(xfContext* xfc, XEvent* event, BOOL app)
if (xfc->use_xinput)
return TRUE;
- return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y,
- event->xbutton.button, event->xbutton.window, app, FALSE);
+ return xf_generic_ButtonEvent(xfc, event->xbutton.x, event->xbutton.y, event->xbutton.button,
+ event->xbutton.window, app, FALSE);
}
static BOOL xf_event_KeyPress(xfContext* xfc, XEvent* event, BOOL app)
{
KeySym keysym;
char str[256];
WINPR_UNUSED(app);
- XLookupString((XKeyEvent*) event, str, sizeof(str), &keysym, NULL);
+ XLookupString((XKeyEvent*)event, str, sizeof(str), &keysym, NULL);
xf_keyboard_key_press(xfc, event->xkey.keycode, keysym);
return TRUE;
}
@@ -473,7 +476,7 @@ static BOOL xf_event_KeyRelease(xfContext* xfc, XEvent* event, BOOL app)
KeySym keysym;
char str[256];
WINPR_UNUSED(app);
- XLookupString((XKeyEvent*) event, str, sizeof(str), &keysym, NULL);
+ XLookupString((XKeyEvent*)event, str, sizeof(str), &keysym, NULL);
xf_keyboard_key_release(xfc, event->xkey.keycode, keysym);
return TRUE;
}
@@ -489,8 +492,8 @@ static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app)
if (!xfc->window)
return FALSE;
- XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync,
- GrabModeAsync, CurrentTime);
+ XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync,
+ CurrentTime);
}
if (app)
@@ -499,7 +502,8 @@ static BOOL xf_event_FocusIn(xfContext* xfc, XEvent* event, BOOL app)
xf_rail_send_activate(xfc, event->xany.window, TRUE);
appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
- /* Update the server with any window changes that occurred while the window was not focused. */
+ /* Update the server with any window changes that occurred while the window was not focused.
+ */
if (appWindow)
{
xf_rail_adjust_position(xfc, appWindow);
@@ -543,8 +547,8 @@ static BOOL xf_event_MappingNotify(xfContext* xfc, XEvent* event, BOOL app)
}
static BOOL xf_event_ClientMessage(xfContext* xfc, XEvent* event, BOOL app)
{
- if ((event->xclient.message_type == xfc->WM_PROTOCOLS)
- && ((Atom) event->xclient.data.l[0] == xfc->WM_DELETE_WINDOW))
+ if ((event->xclient.message_type == xfc->WM_PROTOCOLS) &&
+ ((Atom)event->xclient.data.l[0] == xfc->WM_DELETE_WINDOW))
{
if (app)
{
@@ -577,12 +581,11 @@ static BOOL xf_event_EnterNotify(xfContext* xfc, XEvent* event, BOOL app)
xfc->mouse_active = TRUE;
if (xfc->fullscreen)
- XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot,
- CurrentTime);
+ XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
if (xfc->focused)
- XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync,
- GrabModeAsync, CurrentTime);
+ XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync,
+ CurrentTime);
}
else
{
@@ -638,8 +641,7 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
xfc->offset_x = 0;
xfc->offset_y = 0;
- if (xfc->context.settings->SmartSizing
- || xfc->context.settings->MultiTouchGestures)
+ if (xfc->context.settings->SmartSizing || xfc->context.settings->MultiTouchGestures)
{
xfc->scaledWidth = xfc->window->width;
xfc->scaledHeight = xfc->window->height;
@@ -674,9 +676,8 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
* ConfigureNotify coordinates are expressed relative to the window parent.
* Translate these to root window coordinates.
*/
- XTranslateCoordinates(xfc->display, appWindow->handle,
- RootWindowOfScreen(xfc->screen),
- 0, 0, &appWindow->x, &appWindow->y, &childWindow);
+ XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen), 0,
+ 0, &appWindow->x, &appWindow->y, &childWindow);
appWindow->width = event->xconfigure.width;
appWindow->height = event->xconfigure.height;
@@ -693,9 +694,8 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, XEvent* event, BOOL app)
}
else
{
- if ((!event->xconfigure.send_event
- || appWindow->local_move.state == LMS_NOT_ACTIVE)
- && !appWindow->rail_ignore_configure && xfc->focused)
+ if ((!event->xconfigure.send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
+ !appWindow->rail_ignore_configure && xfc->focused)
xf_rail_adjust_position(xfc, appWindow);
}
}
@@ -752,10 +752,10 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
* when the window has been minimized, maximized, restored locally
* ie. not using the buttons on the rail window itself
*/
- if ((((Atom) event->xproperty.atom == xfc->_NET_WM_STATE)
- && (event->xproperty.state != PropertyDelete)) ||
- (((Atom) event->xproperty.atom == xfc->WM_STATE)
- && (event->xproperty.state != PropertyDelete)))
+ if ((((Atom)event->xproperty.atom == xfc->_NET_WM_STATE) &&
+ (event->xproperty.state != PropertyDelete)) ||
+ (((Atom)event->xproperty.atom == xfc->WM_STATE) &&
+ (event->xproperty.state != PropertyDelete)))
{
unsigned long i;
BOOL status;
@@ -776,23 +776,23 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
- if ((Atom) event->xproperty.atom == xfc->_NET_WM_STATE)
+ if ((Atom)event->xproperty.atom == xfc->_NET_WM_STATE)
{
- status = xf_GetWindowProperty(xfc, event->xproperty.window,
- xfc->_NET_WM_STATE, 12, &nitems, &bytes, &prop);
+ status = xf_GetWindowProperty(xfc, event->xproperty.window, xfc->_NET_WM_STATE, 12,
+ &nitems, &bytes, &prop);
if (status)
{
for (i = 0; i < nitems; i++)
{
- if ((Atom)((UINT16**) prop)[i] == XInternAtom(xfc->display,
- "_NET_WM_STATE_MAXIMIZED_VERT", False))
+ if ((Atom)((UINT16**)prop)[i] ==
+ XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False))
{
maxVert = TRUE;
}
- if ((Atom)((UINT16**) prop)[i] == XInternAtom(xfc->display,
- "_NET_WM_STATE_MAXIMIZED_HORZ", False))
+ if ((Atom)((UINT16**)prop)[i] ==
+ XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False))
{
maxHorz = TRUE;
}
@@ -802,15 +802,15 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
}
}
- if ((Atom) event->xproperty.atom == xfc->WM_STATE)
+ if ((Atom)event->xproperty.atom == xfc->WM_STATE)
{
- status = xf_GetWindowProperty(xfc, event->xproperty.window,
- xfc->WM_STATE, 1, &nitems, &bytes, &prop);
+ status = xf_GetWindowProperty(xfc, event->xproperty.window, xfc->WM_STATE, 1, &nitems,
+ &bytes, &prop);
if (status)
{
/* If the window is in the iconic state */
- if (((UINT32) *prop == 3))
+ if (((UINT32)*prop == 3))
minimized = TRUE;
else
minimized = FALSE;
@@ -822,8 +822,8 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
if (app)
{
- if (maxVert && maxHorz && !minimized
- && (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED))
+ if (maxVert && maxHorz && !minimized &&
+ (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED))
{
appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
@@ -833,8 +833,8 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
}
- else if (!minimized && !maxVert && !maxHorz
- && (appWindow->rail_state != WINDOW_SHOW) && (appWindow->rail_state != WINDOW_HIDE))
+ else if (!minimized && !maxVert && !maxHorz && (appWindow->rail_state != WINDOW_SHOW) &&
+ (appWindow->rail_state != WINDOW_HIDE))
{
appWindow->rail_state = WINDOW_SHOW;
xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
@@ -846,8 +846,7 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, XEvent* event, BOOL app)
return TRUE;
}
-static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow,
- XEvent* event)
+static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, XEvent* event)
{
if (!xfc->remote_app)
return FALSE;
@@ -858,7 +857,8 @@ static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow,
/* No local move in progress, nothing to do */
- /* Prevent Configure from happening during indeterminant state of Horz or Vert Max only */
+ /* Prevent Configure from happening during indeterminant state of Horz or Vert Max only
+ */
if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
{
appWindow->rail_ignore_configure = FALSE;
@@ -869,13 +869,16 @@ static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow,
case LMS_STARTING:
- /* Local move initiated by RDP server, but we have not yet seen any updates from the X server */
+ /* Local move initiated by RDP server, but we have not yet seen any updates from the X
+ * server */
switch (event->type)
{
case ConfigureNotify:
- /* Starting to see move events from the X server. Local move is now in progress. */
+ /* Starting to see move events from the X server. Local move is now in progress.
+ */
appWindow->local_move.state = LMS_ACTIVE;
- /* Allow these events to be processed during move to keep our state up to date. */
+ /* Allow these events to be processed during move to keep our state up to date.
+ */
break;
case ButtonPress:
@@ -936,7 +939,7 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
{
BOOL status = TRUE;
xfAppWindow* appWindow;
- xfContext* xfc = (xfContext*) instance->context;
+ xfContext* xfc = (xfContext*)instance->context;
rdpSettings* settings = xfc->context.settings;
if (xfc->remote_app)
@@ -966,8 +969,8 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
if (event->type != MotionNotify)
{
- DEBUG_X11("%s Event(%d): wnd=0x%08lX", x11_event_string(event->type),
- event->type, (unsigned long) event->xany.window);
+ DEBUG_X11("%s Event(%d): wnd=0x%08lX", x11_event_string(event->type), event->type,
+ (unsigned long)event->xany.window);
}
switch (event->type)
diff --git a/client/X11/xf_floatbar.c b/client/X11/xf_floatbar.c
index f504f0669..de221fd41 100644
--- a/client/X11/xf_floatbar.c
+++ b/client/X11/xf_floatbar.c
@@ -30,33 +30,35 @@
#define TAG CLIENT_TAG("x11")
-#define FLOATBAR_HEIGHT 26
-#define FLOATBAR_DEFAULT_WIDTH 576
-#define FLOATBAR_MIN_WIDTH 200
-#define FLOATBAR_BORDER 24
-#define FLOATBAR_BUTTON_WIDTH 24
-#define FLOATBAR_COLOR_BACKGROUND "RGB:31/6c/a9"
-#define FLOATBAR_COLOR_BORDER "RGB:75/9a/c8"
-#define FLOATBAR_COLOR_FOREGROUND "RGB:FF/FF/FF"
+#define FLOATBAR_HEIGHT 26
+#define FLOATBAR_DEFAULT_WIDTH 576
+#define FLOATBAR_MIN_WIDTH 200
+#define FLOATBAR_BORDER 24
+#define FLOATBAR_BUTTON_WIDTH 24
+#define FLOATBAR_COLOR_BACKGROUND "RGB:31/6c/a9"
+#define FLOATBAR_COLOR_BORDER "RGB:75/9a/c8"
+#define FLOATBAR_COLOR_FOREGROUND "RGB:FF/FF/FF"
#ifdef WITH_DEBUG_X11
#define DEBUG_X11(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_X11(...) do { } while (0)
+#define DEBUG_X11(...) \
+ do \
+ { \
+ } while (0)
#endif
-#define XF_FLOATBAR_MODE_NONE 0
-#define XF_FLOATBAR_MODE_DRAGGING 1
-#define XF_FLOATBAR_MODE_RESIZE_LEFT 2
-#define XF_FLOATBAR_MODE_RESIZE_RIGHT 3
+#define XF_FLOATBAR_MODE_NONE 0
+#define XF_FLOATBAR_MODE_DRAGGING 1
+#define XF_FLOATBAR_MODE_RESIZE_LEFT 2
+#define XF_FLOATBAR_MODE_RESIZE_RIGHT 3
-
-#define XF_FLOATBAR_BUTTON_CLOSE 1
-#define XF_FLOATBAR_BUTTON_RESTORE 2
+#define XF_FLOATBAR_BUTTON_CLOSE 1
+#define XF_FLOATBAR_BUTTON_RESTORE 2
#define XF_FLOATBAR_BUTTON_MINIMIZE 3
-#define XF_FLOATBAR_BUTTON_LOCKED 4
+#define XF_FLOATBAR_BUTTON_LOCKED 4
-typedef BOOL(*OnClick)(xfFloatbar*);
+typedef BOOL (*OnClick)(xfFloatbar*);
typedef struct xf_floatbar_button xfFloatbarButton;
@@ -187,10 +189,9 @@ static BOOL create_floatbar(xfFloatbar* floatbar)
if (((floatbar->flags & 0x0004) == 0) && !floatbar->locked)
floatbar->y = -FLOATBAR_HEIGHT + 1;
- floatbar->handle = XCreateWindow(xfc->display, floatbar->root_window,
- floatbar->x, 0, FLOATBAR_DEFAULT_WIDTH,
- FLOATBAR_HEIGHT, 0,
- CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
+ floatbar->handle =
+ XCreateWindow(xfc->display, floatbar->root_window, floatbar->x, 0, FLOATBAR_DEFAULT_WIDTH,
+ FLOATBAR_HEIGHT, 0, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
floatbar->width = FLOATBAR_DEFAULT_WIDTH;
floatbar->height = FLOATBAR_HEIGHT;
floatbar->mode = XF_FLOATBAR_MODE_NONE;
@@ -198,9 +199,10 @@ static BOOL create_floatbar(xfFloatbar* floatbar)
floatbar->buttons[1] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_RESTORE);
floatbar->buttons[2] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_MINIMIZE);
floatbar->buttons[3] = xf_floatbar_new_button(floatbar, XF_FLOATBAR_BUTTON_LOCKED);
- XSelectInput(xfc->display, floatbar->handle, ExposureMask | ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask | FocusChangeMask | LeaveWindowMask | EnterWindowMask | StructureNotifyMask |
- PropertyChangeMask);
+ XSelectInput(xfc->display, floatbar->handle,
+ ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
+ FocusChangeMask | LeaveWindowMask | EnterWindowMask | StructureNotifyMask |
+ PropertyChangeMask);
floatbar->created = TRUE;
return TRUE;
}
@@ -256,7 +258,7 @@ BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen)
xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar, int type)
{
xfFloatbarButton* button;
- button = (xfFloatbarButton*) calloc(1, sizeof(xfFloatbarButton));
+ button = (xfFloatbarButton*)calloc(1, sizeof(xfFloatbarButton));
button->type = type;
switch (type)
@@ -288,11 +290,11 @@ xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar, int type)
button->y = 0;
button->focus = FALSE;
button->handle = XCreateWindow(floatbar->xfc->display, floatbar->handle, button->x, 0,
- FLOATBAR_BUTTON_WIDTH,
- FLOATBAR_BUTTON_WIDTH, 0, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
+ FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH, 0, CopyFromParent,
+ InputOutput, CopyFromParent, 0, NULL);
XSelectInput(floatbar->xfc->display, button->handle,
- ExposureMask | ButtonPressMask | ButtonReleaseMask |
- FocusChangeMask | LeaveWindowMask | EnterWindowMask | StructureNotifyMask);
+ ExposureMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
+ LeaveWindowMask | EnterWindowMask | StructureNotifyMask);
return button;
}
@@ -311,7 +313,7 @@ xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* name, DWO
if (xfc->remote_app)
return NULL;
- floatbar = (xfFloatbar*) calloc(1, sizeof(xfFloatbar));
+ floatbar = (xfFloatbar*)calloc(1, sizeof(xfFloatbar));
if (!floatbar)
return NULL;
@@ -380,8 +382,7 @@ static void xf_floatbar_event_expose(xfFloatbar* floatbar, XEvent* event)
border[4].y = border[0].y;
/* Fill all pixels with 0 */
XSetForeground(display, shape_gc, 0);
- XFillRectangle(display, pmap, shape_gc, 0, 0, floatbar->width,
- floatbar->height);
+ XFillRectangle(display, pmap, shape_gc, 0, 0, floatbar->width, floatbar->height);
/* Fill all pixels which should be shown with 1 */
XSetForeground(display, shape_gc, 1);
XFillPolygon(display, pmap, shape_gc, shape, 5, 0, CoordModeOrigin);
@@ -395,8 +396,8 @@ static void xf_floatbar_event_expose(xfFloatbar* floatbar, XEvent* event)
/* draw the host name connected to (limit to maximum file name) */
len = strnlen(floatbar->title, MAX_PATH);
XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND));
- XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15,
- floatbar->title, len);
+ XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15, floatbar->title,
+ len);
XFreeGC(display, gc);
XFreeGC(display, shape_gc);
}
@@ -431,15 +432,18 @@ static void xf_floatbar_button_update_positon(xfFloatbar* floatbar, XEvent* even
switch (button->type)
{
case XF_FLOATBAR_BUTTON_CLOSE:
- button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
+ button->x =
+ floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
break;
case XF_FLOATBAR_BUTTON_RESTORE:
- button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
+ button->x =
+ floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
break;
case XF_FLOATBAR_BUTTON_MINIMIZE:
- button->x = floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
+ button->x =
+ floatbar->width - FLOATBAR_BORDER - FLOATBAR_BUTTON_WIDTH * button->type;
break;
default:
@@ -495,7 +499,8 @@ static void xf_floatbar_button_event_expose(xfFloatbar* floatbar, XEvent* event)
FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH);
if (!(button->focus))
- XSetForeground(xfc->display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND));
+ XSetForeground(xfc->display, gc,
+ xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND));
else
XSetForeground(xfc->display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER));
@@ -533,7 +538,7 @@ static void xf_floatbar_event_buttonpress(xfFloatbar* floatbar, XEvent* event)
case Button1:
if (event->xmotion.x <= FLOATBAR_BORDER)
floatbar->mode = XF_FLOATBAR_MODE_RESIZE_LEFT;
- else if (event->xmotion.x >= (floatbar->width - FLOATBAR_BORDER))
+ else if (event->xmotion.x >= (floatbar->width - FLOATBAR_BORDER))
floatbar->mode = XF_FLOATBAR_MODE_RESIZE_RIGHT;
else
floatbar->mode = XF_FLOATBAR_MODE_DRAGGING;
diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c
index d23e115ae..218e1c9d4 100644
--- a/client/X11/xf_gdi.c
+++ b/client/X11/xf_gdi.c
@@ -39,18 +39,16 @@
#include
#define TAG CLIENT_TAG("x11")
-static const UINT8 GDI_BS_HATCHED_PATTERNS[] =
-{
+static const UINT8 GDI_BS_HATCHED_PATTERNS[] = {
0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* HS_HORIZONTAL */
0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_VERTICAL */
0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F, /* HS_FDIAGONAL */
0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE, /* HS_BDIAGONAL */
0xF7, 0xF7, 0xF7, 0x00, 0xF7, 0xF7, 0xF7, 0xF7, /* HS_CROSS */
- 0x7E, 0xBD, 0xDB, 0xE7, 0xE7, 0xDB, 0xBD, 0x7E /* HS_DIACROSS */
+ 0x7E, 0xBD, 0xDB, 0xE7, 0xE7, 0xDB, 0xBD, 0x7E /* HS_DIACROSS */
};
-static const BYTE xf_rop2_table[] =
-{
+static const BYTE xf_rop2_table[] = {
0,
GXclear, /* 0 */
GXnor, /* DPon */
@@ -74,7 +72,7 @@ static BOOL xf_set_rop2(xfContext* xfc, int rop2)
{
if ((rop2 < 0x01) || (rop2 > 0x10))
{
- WLog_ERR(TAG, "Unsupported ROP2: %d", rop2);
+ WLog_ERR(TAG, "Unsupported ROP2: %d", rop2);
return FALSE;
}
@@ -210,7 +208,7 @@ static BOOL xf_set_rop3(xfContext* xfc, UINT32 rop3)
if (function < 0)
{
- WLog_ERR(TAG, "Unsupported ROP3: 0x%08"PRIX32"", rop3);
+ WLog_ERR(TAG, "Unsupported ROP3: 0x%08" PRIX32 "", rop3);
XSetFunction(xfc->display, xfc->gc, GXclear);
return FALSE;
}
@@ -219,9 +217,7 @@ static BOOL xf_set_rop3(xfContext* xfc, UINT32 rop3)
return TRUE;
}
-static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height,
- UINT32 bpp,
- BYTE* data)
+static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height, UINT32 bpp, BYTE* data)
{
GC gc;
Pixmap bitmap;
@@ -235,12 +231,11 @@ static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height,
if (data)
{
brushFormat = gdi_get_pixel_format(bpp);
- cdata = (BYTE*) _aligned_malloc(width * height * 4, 16);
- freerdp_image_copy(cdata, gdi->dstFormat, 0, 0, 0,
- width, height, data, brushFormat, 0, 0, 0,
- &xfc->context.gdi->palette, FREERDP_FLIP_NONE);
- image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
- ZPixmap, 0, (char*) cdata, width, height, xfc->scanline_pad, 0);
+ cdata = (BYTE*)_aligned_malloc(width * height * 4, 16);
+ freerdp_image_copy(cdata, gdi->dstFormat, 0, 0, 0, width, height, data, brushFormat, 0, 0,
+ 0, &xfc->context.gdi->palette, FREERDP_FLIP_NONE);
+ image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)cdata, width,
+ height, xfc->scanline_pad, 0);
image->byte_order = LSBFirst;
image->bitmap_bit_order = LSBFirst;
gc = XCreateGC(xfc->display, xfc->drawable, 0, NULL);
@@ -257,16 +252,15 @@ static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height,
return bitmap;
}
-static Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height,
- const BYTE* data)
+static Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height, const BYTE* data)
{
int scanline;
XImage* image;
Pixmap bitmap;
scanline = (width + 7) / 8;
bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, 1);
- image = XCreateImage(xfc->display, xfc->visual, 1,
- ZPixmap, 0, (char*) data, width, height, 8, scanline);
+ image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*)data, width, height, 8,
+ scanline);
image->byte_order = LSBFirst;
image->bitmap_bit_order = LSBFirst;
XPutImage(xfc->display, bitmap, xfc->gc_mono, image, 0, 0, 0, 0, width, height);
@@ -275,11 +269,10 @@ static Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height,
return bitmap;
}
-static BOOL xf_gdi_set_bounds(rdpContext* context,
- const rdpBounds* bounds)
+static BOOL xf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
{
XRectangle clip;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
if (bounds)
@@ -301,7 +294,7 @@ static BOOL xf_gdi_set_bounds(rdpContext* context,
static BOOL xf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
xf_lock_x11(xfc, FALSE);
@@ -309,14 +302,13 @@ static BOOL xf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
goto fail;
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- dstblt->nLeftRect, dstblt->nTopRect,
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight);
ret = TRUE;
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight);
+ ret = gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth,
+ dstblt->nHeight);
fail:
XSetFunction(xfc->display, xfc->gc, GXcopy);
@@ -327,7 +319,7 @@ fail:
static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
const rdpBrush* brush;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
XColor xfg, xbg;
@@ -349,24 +341,24 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetBackground(xfc->display, xfc->gc, xbg.pixel);
XSetForeground(xfc->display, xfc->gc, xfg.pixel);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect,
+ patblt->nWidth, patblt->nHeight);
break;
case GDI_BS_HATCHED:
- {
- Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8,
- &GDI_BS_HATCHED_PATTERNS[8 * brush->hatch]);
- XSetBackground(xfc->display, xfc->gc, xbg.pixel);
- XSetForeground(xfc->display, xfc->gc, xfg.pixel);
- XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
- XSetStipple(xfc->display, xfc->gc, pattern);
- XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
- XFreePixmap(xfc->display, pattern);
- }
- break;
+ {
+ Pixmap pattern =
+ xf_mono_bitmap_new(xfc, 8, 8, &GDI_BS_HATCHED_PATTERNS[8 * brush->hatch]);
+ XSetBackground(xfc->display, xfc->gc, xbg.pixel);
+ XSetForeground(xfc->display, xfc->gc, xfg.pixel);
+ XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
+ XSetStipple(xfc->display, xfc->gc, pattern);
+ XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect,
+ patblt->nWidth, patblt->nHeight);
+ XFreePixmap(xfc->display, pattern);
+ }
+ break;
case GDI_BS_PATTERN:
if (brush->bpp > 1)
@@ -380,8 +372,8 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
XSetFillStyle(xfc->display, xfc->gc, FillTiled);
XSetTile(xfc->display, xfc->gc, pattern);
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect,
+ patblt->nTopRect, patblt->nWidth, patblt->nHeight);
XSetTile(xfc->display, xfc->gc, xfc->primary);
XFreePixmap(xfc->display, pattern);
}
@@ -393,23 +385,23 @@ static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled);
XSetStipple(xfc->display, xfc->gc, pattern);
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect,
+ patblt->nTopRect, patblt->nWidth, patblt->nHeight);
XFreePixmap(xfc->display, pattern);
}
break;
default:
- WLog_ERR(TAG, "unimplemented brush style:%"PRIu32"", brush->style);
+ WLog_ERR(TAG, "unimplemented brush style:%" PRIu32 "", brush->style);
goto fail;
}
ret = TRUE;
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect,
- patblt->nWidth, patblt->nHeight);
+ ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth,
+ patblt->nHeight);
fail:
XSetFunction(xfc->display, xfc->gc, GXcopy);
@@ -419,7 +411,7 @@ fail:
static BOOL xf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
if (!xfc->display || !xfc->drawing)
@@ -430,14 +422,13 @@ static BOOL xf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
if (!xf_set_rop3(xfc, gdi_rop3_code(scrblt->bRop)))
goto fail;
- XCopyArea(xfc->display, xfc->primary, xfc->drawing, xfc->gc, scrblt->nXSrc,
- scrblt->nYSrc,
+ XCopyArea(xfc->display, xfc->primary, xfc->drawing, xfc->gc, scrblt->nXSrc, scrblt->nYSrc,
scrblt->nWidth, scrblt->nHeight, scrblt->nLeftRect, scrblt->nTopRect);
ret = TRUE;
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect,
- scrblt->nWidth, scrblt->nHeight);
+ ret = gdi_InvalidateRegion(xfc->hdc, scrblt->nLeftRect, scrblt->nTopRect, scrblt->nWidth,
+ scrblt->nHeight);
XSetFunction(xfc->display, xfc->gc, GXcopy);
fail:
@@ -445,11 +436,10 @@ fail:
return ret;
}
-static BOOL xf_gdi_opaque_rect(rdpContext* context,
- const OPAQUE_RECT_ORDER* opaque_rect)
+static BOOL xf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
{
XColor color;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
if (!xf_decode_color(xfc, opaque_rect->color, &color))
@@ -459,13 +449,11 @@ static BOOL xf_gdi_opaque_rect(rdpContext* context,
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- opaque_rect->nLeftRect, opaque_rect->nTopRect,
- opaque_rect->nWidth, opaque_rect->nHeight);
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, opaque_rect->nLeftRect,
+ opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight);
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect,
- opaque_rect->nTopRect,
+ ret = gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight);
xf_unlock_x11(xfc, FALSE);
@@ -476,7 +464,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
UINT32 i;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
XColor color;
@@ -491,8 +479,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
for (i = 0; i < multi_opaque_rect->numRectangles; i++)
{
const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
- XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
- rectangle->left, rectangle->top,
+ XFillRectangle(xfc->display, xfc->drawing, xfc->gc, rectangle->left, rectangle->top,
rectangle->width, rectangle->height);
if (xfc->drawing == xfc->primary)
@@ -510,7 +497,7 @@ static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
{
XColor color;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
if (!xf_decode_color(xfc, line_to->penColor, &color))
@@ -520,8 +507,8 @@ static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
xf_set_rop2(xfc, line_to->bRop2);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
- XDrawLine(xfc->display, xfc->drawing, xfc->gc,
- line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd);
+ XDrawLine(xfc->display, xfc->drawing, xfc->gc, line_to->nXStart, line_to->nYStart,
+ line_to->nXEnd, line_to->nYEnd);
if (xfc->drawing == xfc->primary)
{
@@ -538,8 +525,7 @@ static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
return ret;
}
-static BOOL xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points,
- int npoints)
+static BOOL xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points, int npoints)
{
int x, y, x1, y1, x2, y2;
@@ -573,14 +559,13 @@ static BOOL xf_gdi_invalidate_poly_region(xfContext* xfc, XPoint* points,
return gdi_InvalidateRegion(xfc->hdc, x1, y1, x2 - x1, y2 - y1);
}
-static BOOL xf_gdi_polyline(rdpContext* context,
- const POLYLINE_ORDER* polyline)
+static BOOL xf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
{
UINT32 i;
int npoints;
XColor color;
XPoint* points;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
if (!xf_decode_color(xfc, polyline->penColor, &color))
@@ -608,8 +593,7 @@ static BOOL xf_gdi_polyline(rdpContext* context,
points[i + 1].y = polyline->points[i].y;
}
- XDrawLines(xfc->display, xfc->drawing, xfc->gc, points, npoints,
- CoordModePrevious);
+ XDrawLines(xfc->display, xfc->drawing, xfc->gc, points, npoints, CoordModePrevious);
if (xfc->drawing == xfc->primary)
{
@@ -632,8 +616,8 @@ static BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
if (!context || !memblt)
return FALSE;
- bitmap = (xfBitmap*) memblt->bitmap;
- xfc = (xfContext*) context;
+ bitmap = (xfBitmap*)memblt->bitmap;
+ xfc = (xfContext*)context;
if (!bitmap || !xfc || !xfc->display || !xfc->drawing)
return FALSE;
@@ -642,14 +626,12 @@ static BOOL xf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
if (xf_set_rop3(xfc, gdi_rop3_code(memblt->bRop)))
{
- XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc,
- memblt->nXSrc, memblt->nYSrc, memblt->nWidth, memblt->nHeight,
- memblt->nLeftRect, memblt->nTopRect);
+ XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, memblt->nXSrc, memblt->nYSrc,
+ memblt->nWidth, memblt->nHeight, memblt->nLeftRect, memblt->nTopRect);
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect,
- memblt->nTopRect, memblt->nWidth,
- memblt->nHeight);
+ ret = gdi_InvalidateRegion(xfc->hdc, memblt->nLeftRect, memblt->nTopRect,
+ memblt->nWidth, memblt->nHeight);
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
@@ -664,7 +646,7 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
XColor foreColor;
XColor backColor;
Pixmap pattern = 0;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
if (!xfc->display || !xfc->drawing)
@@ -678,7 +660,7 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
xf_lock_x11(xfc, FALSE);
brush = &mem3blt->brush;
- bitmap = (xfBitmap*) mem3blt->bitmap;
+ bitmap = (xfBitmap*)mem3blt->bitmap;
if (!xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop)))
goto fail;
@@ -718,18 +700,17 @@ static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
break;
default:
- WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%"PRIu32"", brush->style);
+ WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%" PRIu32 "", brush->style);
goto fail;
}
- XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc,
- mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight,
- mem3blt->nLeftRect, mem3blt->nTopRect);
+ XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, mem3blt->nXSrc, mem3blt->nYSrc,
+ mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect);
ret = TRUE;
if (xfc->drawing == xfc->primary)
- ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect,
- mem3blt->nWidth, mem3blt->nHeight);
+ ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth,
+ mem3blt->nHeight);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
@@ -743,15 +724,13 @@ fail:
return ret;
}
-
-static BOOL xf_gdi_polygon_sc(rdpContext* context,
- const POLYGON_SC_ORDER* polygon_sc)
+static BOOL xf_gdi_polygon_sc(rdpContext* context, const POLYGON_SC_ORDER* polygon_sc)
{
UINT32 i;
int npoints;
XPoint* points;
XColor brush_color;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
if (!xf_decode_color(xfc, polygon_sc->brushColor, &brush_color))
@@ -788,14 +767,13 @@ static BOOL xf_gdi_polygon_sc(rdpContext* context,
break;
default:
- WLog_ERR(TAG, "PolygonSC unknown fillMode: %"PRIu32"", polygon_sc->fillMode);
+ WLog_ERR(TAG, "PolygonSC unknown fillMode: %" PRIu32 "", polygon_sc->fillMode);
break;
}
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, brush_color.pixel);
- XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
- points, npoints, Complex, CoordModePrevious);
+ XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious);
if (xfc->drawing == xfc->primary)
{
@@ -809,8 +787,7 @@ static BOOL xf_gdi_polygon_sc(rdpContext* context,
return ret;
}
-static BOOL xf_gdi_polygon_cb(rdpContext* context,
- POLYGON_CB_ORDER* polygon_cb)
+static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
{
UINT32 i;
int npoints;
@@ -819,7 +796,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context,
const rdpBrush* brush;
XColor foreColor;
XColor backColor;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
if (!xf_decode_color(xfc, polygon_cb->foreColor, &foreColor))
@@ -860,7 +837,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context,
break;
default:
- WLog_ERR(TAG, "PolygonCB unknown fillMode: %"PRIu32"", polygon_cb->fillMode);
+ WLog_ERR(TAG, "PolygonCB unknown fillMode: %" PRIu32 "", polygon_cb->fillMode);
break;
}
@@ -892,8 +869,8 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context,
}
XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y);
- XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
- points, npoints, Complex, CoordModePrevious);
+ XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex,
+ CoordModePrevious);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetTSOrigin(xfc->display, xfc->gc, 0, 0);
XFreePixmap(xfc->display, pattern);
@@ -906,7 +883,7 @@ static BOOL xf_gdi_polygon_cb(rdpContext* context,
}
else
{
- WLog_ERR(TAG, "PolygonCB unimplemented brush style:%"PRIu32"", brush->style);
+ WLog_ERR(TAG, "PolygonCB unimplemented brush style:%" PRIu32 "", brush->style);
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
@@ -919,7 +896,7 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
const SURFACE_FRAME_MARKER* surface_frame_marker)
{
rdpSettings* settings;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
settings = xfc->context.settings;
xf_lock_x11(xfc, FALSE);
@@ -939,7 +916,8 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
if ((xfc->frame_x2 > xfc->frame_x1) && (xfc->frame_y2 > xfc->frame_y1))
ret = gdi_InvalidateRegion(xfc->hdc, xfc->frame_x1, xfc->frame_y1,
- xfc->frame_x2 - xfc->frame_x1, xfc->frame_y2 - xfc->frame_y1);
+ xfc->frame_x2 - xfc->frame_x1,
+ xfc->frame_y2 - xfc->frame_y1);
if (settings->FrameAcknowledge > 0)
{
@@ -954,8 +932,8 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
return ret;
}
-static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty,
- UINT16 width, UINT16 height)
+static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty, UINT16 width,
+ UINT16 height)
{
BOOL ret = TRUE;
@@ -991,8 +969,8 @@ static BOOL xf_gdi_surface_update_frame(xfContext* xfc, UINT16 tx, UINT16 ty,
return ret;
}
-static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData,
- UINT32 scanline, const REGION16* pRegion)
+static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData, UINT32 scanline,
+ const REGION16* pRegion)
{
BOOL ret = FALSE;
XImage* image;
@@ -1023,8 +1001,8 @@ static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData,
UINT32 width = rects[i].right - rects[i].left;
UINT32 height = rects[i].bottom - rects[i].top;
const BYTE* src = pSrcData + top * scanline + bpp * left;
- image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
- (char*) src, width, height, xfc->scanline_pad, scanline);
+ image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)src, width,
+ height, xfc->scanline_pad, scanline);
if (!image)
break;
@@ -1041,11 +1019,10 @@ static BOOL xf_gdi_update_screen(xfContext* xfc, const BYTE* pSrcData,
return ret;
}
-static BOOL xf_gdi_surface_bits(rdpContext* context,
- const SURFACE_BITS_COMMAND* cmd)
+static BOOL xf_gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND* cmd)
{
BYTE* pSrcData;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = FALSE;
DWORD format;
rdpGdi* gdi;
@@ -1068,17 +1045,18 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
case RDP_CODEC_ID_REMOTEFX:
if (!rfx_process_message(context->codecs->rfx, cmd->bmp.bitmapData,
cmd->bmp.bitmapDataLength, cmd->destLeft, cmd->destTop,
- gdi->primary_buffer, gdi->dstFormat, gdi->stride,
- gdi->height, ®ion))
+ gdi->primary_buffer, gdi->dstFormat, gdi->stride, gdi->height,
+ ®ion))
goto fail;
break;
case RDP_CODEC_ID_NSCODEC:
if (!nsc_process_message(context->codecs->nsc, cmd->bmp.bpp, cmd->bmp.width,
- cmd->bmp.height, cmd->bmp.bitmapData, cmd->bmp.bitmapDataLength,
- gdi->primary_buffer, gdi->dstFormat, gdi->stride,
- 0, 0, cmd->bmp.width, cmd->bmp.height, FREERDP_FLIP_VERTICAL))
+ cmd->bmp.height, cmd->bmp.bitmapData,
+ cmd->bmp.bitmapDataLength, gdi->primary_buffer, gdi->dstFormat,
+ gdi->stride, 0, 0, cmd->bmp.width, cmd->bmp.height,
+ FREERDP_FLIP_VERTICAL))
goto fail;
region16_union_rect(®ion, ®ion, &cmdRect);
@@ -1088,17 +1066,16 @@ static BOOL xf_gdi_surface_bits(rdpContext* context,
pSrcData = cmd->bmp.bitmapData;
format = gdi_get_pixel_format(cmd->bmp.bpp);
- if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
- cmd->destLeft, cmd->destTop, cmd->bmp.width, cmd->bmp.height,
- pSrcData, format, 0, 0, 0,
- &xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL))
+ if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride, cmd->destLeft,
+ cmd->destTop, cmd->bmp.width, cmd->bmp.height, pSrcData, format,
+ 0, 0, 0, &xfc->context.gdi->palette, FREERDP_FLIP_VERTICAL))
goto fail;
region16_union_rect(®ion, ®ion, &cmdRect);
break;
default:
- WLog_ERR(TAG, "Unsupported codecID %"PRIu16"", cmd->bmp.codecID);
+ WLog_ERR(TAG, "Unsupported codecID %" PRIu16 "", cmd->bmp.codecID);
ret = TRUE;
goto fail;
}
@@ -1128,4 +1105,3 @@ void xf_gdi_register_update_callbacks(rdpUpdate* update)
update->SurfaceBits = xf_gdi_surface_bits;
update->SurfaceFrameMarker = xf_gdi_surface_frame_marker;
}
-
diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c
index 5fbf7e775..9e94a88ee 100644
--- a/client/X11/xf_gfx.c
+++ b/client/X11/xf_gfx.c
@@ -50,8 +50,8 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
XSetClipMask(xfc->display, xfc->gc, None);
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
- region16_intersect_rect(&(surface->gdi.invalidRegion),
- &(surface->gdi.invalidRegion), &surfaceRect);
+ region16_intersect_rect(&(surface->gdi.invalidRegion), &(surface->gdi.invalidRegion),
+ &surfaceRect);
sx = surface->gdi.outputTargetWidth / (double)surface->gdi.mappedWidth;
sy = surface->gdi.outputTargetHeight / (double)surface->gdi.mappedHeight;
@@ -71,40 +71,34 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
if (surface->stage)
{
- if (!freerdp_image_scale(surface->stage, gdi->dstFormat,
- surface->stageScanline, nXSrc, nYSrc,
- dwidth, dheight,
- surface->gdi.data, surface->gdi.format,
- surface->gdi.scanline, nXSrc, nYSrc,
- swidth, sheight))
+ if (!freerdp_image_scale(surface->stage, gdi->dstFormat, surface->stageScanline, nXSrc,
+ nYSrc, dwidth, dheight, surface->gdi.data, surface->gdi.format,
+ surface->gdi.scanline, nXSrc, nYSrc, swidth, sheight))
goto fail;
}
if (xfc->remote_app)
{
- XPutImage(xfc->display, xfc->primary, xfc->gc,
- surface->image, nXSrc, nYSrc,
- nXDst, nYDst, dwidth, dheight);
+ XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image, nXSrc, nYSrc, nXDst,
+ nYDst, dwidth, dheight);
xf_lock_x11(xfc, FALSE);
xf_rail_paint(xfc, nXDst, nYDst, nXDst + dwidth, nYDst + dheight);
xf_unlock_x11(xfc, FALSE);
}
else
#ifdef WITH_XRENDER
- if (xfc->context.settings->SmartSizing
- || xfc->context.settings->MultiTouchGestures)
- {
- XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image,
- nXSrc, nYSrc, nXDst, nYDst, dwidth, dheight);
- xf_draw_screen(xfc, nXDst, nYDst, dwidth, dheight);
- }
- else
+ if (xfc->context.settings->SmartSizing || xfc->context.settings->MultiTouchGestures)
+ {
+ XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image, nXSrc, nYSrc, nXDst,
+ nYDst, dwidth, dheight);
+ xf_draw_screen(xfc, nXDst, nYDst, dwidth, dheight);
+ }
+ else
#endif
- {
- XPutImage(xfc->display, xfc->drawable, xfc->gc,
- surface->image, nXSrc, nYSrc,
- nXDst, nYDst, dwidth, dheight);
- }
+ {
+ XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image, nXSrc, nYSrc, nXDst,
+ nYDst, dwidth, dheight);
+ }
}
rc = CHANNEL_RC_OK;
@@ -133,13 +127,13 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context)
if (gdi->suppressOutput)
return CHANNEL_RC_OK;
- xfc = (xfContext*) gdi->context;
+ xfc = (xfContext*)gdi->context;
EnterCriticalSection(&context->mux);
context->GetSurfaceIds(context, &pSurfaceIds, &count);
for (index = 0; index < count; index++)
{
- xfGfxSurface* surface = (xfGfxSurface*) context->GetSurfaceData(context, pSurfaceIds[index]);
+ xfGfxSurface* surface = (xfGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]);
if (!surface)
continue;
@@ -165,8 +159,7 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context)
return status;
}
-UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y,
- UINT32 width, UINT32 height)
+UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height)
{
UINT16 count;
UINT32 index;
@@ -190,7 +183,7 @@ UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y,
for (index = 0; index < count; index++)
{
- surface = (xfGfxSurface*) context->GetSurfaceData(context, pSurfaceIds[index]);
+ surface = (xfGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]);
if (!surface || !surface->gdi.outputMapped)
continue;
@@ -207,8 +200,7 @@ UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y,
intersection.top -= surfaceRect.top;
intersection.right -= surfaceRect.left;
intersection.bottom -= surfaceRect.top;
- region16_union_rect(&surface->gdi.invalidRegion,
- &surface->gdi.invalidRegion,
+ region16_union_rect(&surface->gdi.invalidRegion, &surface->gdi.invalidRegion,
&intersection);
}
}
@@ -243,7 +235,6 @@ UINT32 x11_pad_scanline(UINT32 scanline, UINT32 inPad)
return scanline;
}
-
/**
* Function description
*
@@ -256,8 +247,8 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
size_t size;
xfGfxSurface* surface;
rdpGdi* gdi = (rdpGdi*)context->custom;
- xfContext* xfc = (xfContext*) gdi->context;
- surface = (xfGfxSurface*) calloc(1, sizeof(xfGfxSurface));
+ xfContext* xfc = (xfContext*)gdi->context;
+ surface = (xfGfxSurface*)calloc(1, sizeof(xfGfxSurface));
if (!surface)
return CHANNEL_RC_NO_MEMORY;
@@ -289,7 +280,8 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
break;
default:
- WLog_ERR(TAG, "%s: unknown pixelFormat 0x%"PRIx32"", __FUNCTION__, createSurface->pixelFormat);
+ WLog_ERR(TAG, "%s: unknown pixelFormat 0x%" PRIx32 "", __FUNCTION__,
+ createSurface->pixelFormat);
ret = ERROR_INTERNAL_ERROR;
goto out_free;
}
@@ -309,9 +301,10 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
if (AreColorFormatsEqualNoAlpha(gdi->dstFormat, surface->gdi.format))
{
- surface->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
- (char*) surface->gdi.data, surface->gdi.mappedWidth, surface->gdi.mappedHeight,
- xfc->scanline_pad, surface->gdi.scanline);
+ surface->image =
+ XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
+ (char*)surface->gdi.data, surface->gdi.mappedWidth,
+ surface->gdi.mappedHeight, xfc->scanline_pad, surface->gdi.scanline);
}
else
{
@@ -320,7 +313,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
surface->stageScanline = width * bytes;
surface->stageScanline = x11_pad_scanline(surface->stageScanline, xfc->scanline_pad);
size = surface->stageScanline * surface->gdi.height;
- surface->stage = (BYTE*) _aligned_malloc(size, 16);
+ surface->stage = (BYTE*)_aligned_malloc(size, 16);
if (!surface->stage)
{
@@ -329,10 +322,10 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
}
ZeroMemory(surface->stage, size);
- surface->image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
- ZPixmap, 0, (char*) surface->stage,
- surface->gdi.mappedWidth, surface->gdi.mappedHeight,
- xfc->scanline_pad, surface->stageScanline);
+ surface->image =
+ XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)surface->stage,
+ surface->gdi.mappedWidth, surface->gdi.mappedHeight, xfc->scanline_pad,
+ surface->stageScanline);
}
if (!surface->image)
@@ -346,7 +339,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
surface->gdi.outputMapped = FALSE;
region16_init(&surface->gdi.invalidRegion);
- if (context->SetSurfaceData(context, surface->gdi.surfaceId, (void*) surface) != CHANNEL_RC_OK)
+ if (context->SetSurfaceData(context, surface->gdi.surfaceId, (void*)surface) != CHANNEL_RC_OK)
{
WLog_ERR(TAG, "%s: an error occurred during SetSurfaceData", __FUNCTION__);
goto error_set_surface_data;
@@ -377,8 +370,7 @@ static UINT xf_DeleteSurface(RdpgfxClientContext* context,
xfGfxSurface* surface = NULL;
UINT status;
EnterCriticalSection(&context->mux);
- surface = (xfGfxSurface*) context->GetSurfaceData(context,
- deleteSurface->surfaceId);
+ surface = (xfGfxSurface*)context->GetSurfaceData(context, deleteSurface->surfaceId);
if (surface)
{
@@ -400,8 +392,7 @@ static UINT xf_DeleteSurface(RdpgfxClientContext* context,
status = context->SetSurfaceData(context, deleteSurface->surfaceId, NULL);
if (codecs && codecs->progressive)
- progressive_delete_surface_context(codecs->progressive,
- deleteSurface->surfaceId);
+ progressive_delete_surface_context(codecs->progressive, deleteSurface->surfaceId);
LeaveCriticalSection(&context->mux);
return status;
diff --git a/client/X11/xf_gfx.h b/client/X11/xf_gfx.h
index ecca7994e..934e85a0b 100644
--- a/client/X11/xf_gfx.h
+++ b/client/X11/xf_gfx.h
@@ -36,8 +36,7 @@ struct xf_gfx_surface
};
typedef struct xf_gfx_surface xfGfxSurface;
-UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y,
- UINT32 width, UINT32 height);
+UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height);
void xf_graphics_pipeline_init(xfContext* xfc, RdpgfxClientContext* gfx);
diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c
index 2d95ff49e..fc3cb955e 100644
--- a/client/X11/xf_graphics.c
+++ b/client/X11/xf_graphics.c
@@ -104,7 +104,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
BYTE* data;
rdpGdi* gdi;
xfBitmap* xbitmap = (xfBitmap*)bitmap;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
if (!context || !bitmap || !context->gdi)
return FALSE;
@@ -112,8 +112,8 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
gdi = context->gdi;
xf_lock_x11(xfc, FALSE);
depth = GetBitsPerPixel(bitmap->format);
- xbitmap->pixmap = XCreatePixmap(xfc->display, xfc->drawable, bitmap->width,
- bitmap->height, xfc->depth);
+ xbitmap->pixmap =
+ XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth);
if (!xbitmap->pixmap)
goto unlock;
@@ -127,10 +127,9 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
if (!(data = _aligned_malloc(bitmap->width * bitmap->height * 4, 16)))
goto unlock;
- if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
- bitmap->width, bitmap->height,
- bitmap->data, bitmap->format,
- 0, 0, 0, &context->gdi->palette, FREERDP_FLIP_NONE))
+ if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0, bitmap->width, bitmap->height,
+ bitmap->data, bitmap->format, 0, 0, 0, &context->gdi->palette,
+ FREERDP_FLIP_NONE))
{
_aligned_free(data);
goto unlock;
@@ -141,9 +140,9 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
bitmap->format = gdi->dstFormat;
}
- xbitmap->image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
- ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height,
- xfc->scanline_pad, 0);
+ xbitmap->image =
+ XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)bitmap->data,
+ bitmap->width, bitmap->height, xfc->scanline_pad, 0);
if (!xbitmap->image)
goto unlock;
@@ -162,7 +161,7 @@ unlock:
static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xfBitmap* xbitmap = (xfBitmap*)bitmap;
if (!xfc || !xbitmap)
@@ -191,7 +190,7 @@ static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
int width, height;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xfBitmap* xbitmap = (xfBitmap*)bitmap;
BOOL ret;
@@ -202,17 +201,16 @@ static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
height = bitmap->bottom - bitmap->top + 1;
xf_lock_x11(xfc, FALSE);
XSetFunction(xfc->display, xfc->gc, GXcopy);
- XPutImage(xfc->display, xfc->primary, xfc->gc,
- xbitmap->image, 0, 0, bitmap->left, bitmap->top, width, height);
+ XPutImage(xfc->display, xfc->primary, xfc->gc, xbitmap->image, 0, 0, bitmap->left, bitmap->top,
+ width, height);
ret = gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height);
xf_unlock_x11(xfc, FALSE);
return ret;
}
-static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
- BOOL primary)
+static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
if (!context || (!bitmap && !primary))
return FALSE;
@@ -222,7 +220,7 @@ static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
if (primary)
xfc->drawing = xfc->primary;
else
- xfc->drawing = ((xfBitmap*) bitmap)->pixmap;
+ xfc->drawing = ((xfBitmap*)bitmap)->pixmap;
xf_unlock_x11(xfc, FALSE);
return TRUE;
@@ -235,7 +233,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
UINT32 CursorFormat;
size_t size;
XcursorImage ci;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xfPointer* xpointer = (xfPointer*)pointer;
if (!context || !pointer || !context->gdi)
@@ -256,18 +254,16 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
ci.yhot = pointer->yPos;
size = ci.height * ci.width * GetBytesPerPixel(CursorFormat);
- if (!(ci.pixels = (XcursorPixel*) _aligned_malloc(size, 16)))
+ if (!(ci.pixels = (XcursorPixel*)_aligned_malloc(size, 16)))
{
xf_unlock_x11(xfc, FALSE);
return FALSE;
}
if (!freerdp_image_copy_from_pointer_data(
- (BYTE*) ci.pixels, CursorFormat,
- 0, 0, 0, pointer->width, pointer->height,
- pointer->xorMaskData, pointer->lengthXorMask,
- pointer->andMaskData, pointer->lengthAndMask,
- pointer->xorBpp, &context->gdi->palette))
+ (BYTE*)ci.pixels, CursorFormat, 0, 0, 0, pointer->width, pointer->height,
+ pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
+ pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
{
_aligned_free(ci.pixels);
xf_unlock_x11(xfc, FALSE);
@@ -284,23 +280,22 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
- if (((xfPointer*) pointer)->cursor)
- XFreeCursor(xfc->display, ((xfPointer*) pointer)->cursor);
+ if (((xfPointer*)pointer)->cursor)
+ XFreeCursor(xfc->display, ((xfPointer*)pointer)->cursor);
xf_unlock_x11(xfc, FALSE);
#endif
}
-static BOOL xf_Pointer_Set(rdpContext* context,
- const rdpPointer* pointer)
+static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
- xfc->pointer = (xfPointer*) pointer;
+ xfc->pointer = (xfPointer*)pointer;
/* in RemoteApp mode, window can be null if none has had focus */
@@ -315,7 +310,7 @@ static BOOL xf_Pointer_Set(rdpContext* context,
static BOOL xf_Pointer_SetNull(rdpContext* context)
{
#ifdef WITH_XCURSOR
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
static Cursor nullcursor = None;
xf_lock_x11(xfc, FALSE);
@@ -345,7 +340,7 @@ static BOOL xf_Pointer_SetNull(rdpContext* context)
static BOOL xf_Pointer_SetDefault(rdpContext* context)
{
#ifdef WITH_XCURSOR
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
xfc->pointer = NULL;
@@ -359,7 +354,7 @@ static BOOL xf_Pointer_SetDefault(rdpContext* context)
static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
XWindowAttributes current;
XSetWindowAttributes tmp;
BOOL ret = FALSE;
@@ -374,8 +369,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
tmp.event_mask = (current.your_event_mask & ~(PointerMotionMask));
- if (XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask,
- &tmp) == 0)
+ if (XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask, &tmp) == 0)
goto out;
XWarpPointer(xfc->display, None, xfc->window->handle, 0, 0, 0, 0, x, y);
@@ -393,19 +387,18 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
int scanline;
XImage* image;
xfGlyph* xf_glyph;
- xf_glyph = (xfGlyph*) glyph;
- xfContext* xfc = (xfContext*) context;
+ xf_glyph = (xfGlyph*)glyph;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
scanline = (glyph->cx + 7) / 8;
- xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx,
- glyph->cy, 1);
- image = XCreateImage(xfc->display, xfc->visual, 1,
- ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline);
+ xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx, glyph->cy, 1);
+ image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*)glyph->aj, glyph->cx,
+ glyph->cy, 8, scanline);
image->byte_order = MSBFirst;
image->bitmap_bit_order = MSBFirst;
XInitImage(image);
- XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0,
- glyph->cx, glyph->cy);
+ XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0, glyph->cx,
+ glyph->cy);
image->data = NULL;
XDestroyImage(image);
xf_unlock_x11(xfc, FALSE);
@@ -414,24 +407,23 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_lock_x11(xfc, FALSE);
- if (((xfGlyph*) glyph)->pixmap != 0)
- XFreePixmap(xfc->display, ((xfGlyph*) glyph)->pixmap);
+ if (((xfGlyph*)glyph)->pixmap != 0)
+ XFreePixmap(xfc->display, ((xfGlyph*)glyph)->pixmap);
xf_unlock_x11(xfc, FALSE);
free(glyph->aj);
free(glyph);
}
-static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x,
- INT32 y, INT32 w, INT32 h, INT32 sx, INT32 sy,
- BOOL fOpRedundant)
+static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x, INT32 y, INT32 w,
+ INT32 h, INT32 sx, INT32 sy, BOOL fOpRedundant)
{
xfGlyph* xf_glyph;
- xfContext* xfc = (xfContext*) context;
- xf_glyph = (xfGlyph*) glyph;
+ xfContext* xfc = (xfContext*)context;
+ xf_glyph = (xfGlyph*)glyph;
xf_lock_x11(xfc, FALSE);
if (!fOpRedundant)
@@ -446,18 +438,17 @@ static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x,
if (sx || sy)
WLog_ERR(TAG, "");
- //XSetClipOrigin(xfc->display, xfc->gc, sx, sy);
+ // XSetClipOrigin(xfc->display, xfc->gc, sx, sy);
XSetTSOrigin(xfc->display, xfc->gc, x, y);
XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, w, h);
xf_unlock_x11(xfc, FALSE);
return TRUE;
}
-static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y,
- INT32 width, INT32 height, UINT32 bgcolor,
- UINT32 fgcolor, BOOL fOpRedundant)
+static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y, INT32 width, INT32 height,
+ UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
XRectangle rect;
XColor xbgcolor, xfgcolor;
@@ -487,11 +478,10 @@ static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y,
return TRUE;
}
-static BOOL xf_Glyph_EndDraw(rdpContext* context, INT32 x, INT32 y,
- INT32 width, INT32 height,
+static BOOL xf_Glyph_EndDraw(rdpContext* context, INT32 x, INT32 y, INT32 width, INT32 height,
UINT32 bgcolor, UINT32 fgcolor)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
BOOL ret = TRUE;
XColor xfgcolor, xbgcolor;
@@ -512,7 +502,7 @@ BOOL xf_register_pointer(rdpGraphics* graphics)
{
rdpPointer* pointer = NULL;
- if (!(pointer = (rdpPointer*) calloc(1, sizeof(rdpPointer))))
+ if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer))))
return FALSE;
pointer->size = sizeof(xfPointer);
diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c
index 2fae52593..2197e2ddf 100644
--- a/client/X11/xf_input.c
+++ b/client/X11/xf_input.c
@@ -88,7 +88,6 @@ const char* xf_input_get_class_string(int class)
return "XIUnknownClass";
}
-
int xf_input_init(xfContext* xfc, Window window)
{
int i, j;
@@ -137,7 +136,7 @@ int xf_input_init(xfContext* xfc, Window window)
for (j = 0; j < dev->num_classes; j++)
{
XIAnyClassInfo* class = dev->classes[j];
- XITouchClassInfo* t = (XITouchClassInfo*) class;
+ XITouchClassInfo* t = (XITouchClassInfo*)class;
if ((class->type == XITouchClass) && (t->mode == XIDirectTouch) &&
(strcmp(dev->name, "Virtual core pointer") != 0))
@@ -149,12 +148,11 @@ int xf_input_init(xfContext* xfc, Window window)
for (j = 0; j < dev->num_classes; j++)
{
XIAnyClassInfo* class = dev->classes[j];
- XITouchClassInfo* t = (XITouchClassInfo*) class;
+ XITouchClassInfo* t = (XITouchClassInfo*)class;
if (xfc->context.settings->MultiTouchInput)
{
- WLog_INFO(TAG, "%s (%d) \"%s\" id: %d",
- xf_input_get_class_string(class->type),
+ WLog_INFO(TAG, "%s (%d) \"%s\" id: %d", xf_input_get_class_string(class->type),
class->type, dev->name, dev->deviceid);
}
@@ -181,12 +179,11 @@ int xf_input_init(xfContext* xfc, Window window)
if (xfc->use_xinput)
{
- if (!touch && (class->type == XIButtonClass)
- && strcmp(dev->name, "Virtual core pointer"))
+ if (!touch && (class->type == XIButtonClass) &&
+ strcmp(dev->name, "Virtual core pointer"))
{
- WLog_INFO(TAG, "%s button device (id: %d, mode: %d)",
- dev->name,
- dev->deviceid, t->mode);
+ WLog_INFO(TAG, "%s button device (id: %d, mode: %d)", dev->name, dev->deviceid,
+ t->mode);
XISetMask(masks[nmasks], XI_ButtonPress);
XISetMask(masks[nmasks], XI_ButtonRelease);
XISetMask(masks[nmasks], XI_Motion);
@@ -209,10 +206,8 @@ static BOOL xf_input_is_duplicate(XGenericEventCookie* cookie)
XIDeviceEvent* event;
event = cookie->data;
- if ((lastEvent.time == event->time) &&
- (lastEvType == cookie->evtype) &&
- (lastEvent.detail == event->detail) &&
- (lastEvent.event_x == event->event_x) &&
+ if ((lastEvent.time == event->time) && (lastEvType == cookie->evtype) &&
+ (lastEvent.detail == event->detail) && (lastEvent.event_x == event->event_x) &&
(lastEvent.event_y == event->event_y))
{
return TRUE;
@@ -553,8 +548,8 @@ static int xf_input_touch_remote(xfContext* xfc, XIDeviceEvent* event, int evtyp
xf_input_hide_cursor(xfc);
touchId = event->detail;
- x = (int) event->event_x;
- y = (int) event->event_y;
+ x = (int)event->event_x;
+ y = (int)event->event_y;
xf_event_adjust_coordinates(xfc, &x, &y);
if (evtype == XI_TouchBegin)
@@ -583,18 +578,18 @@ static int xf_input_event(xfContext* xfc, XIDeviceEvent* event, int evtype)
switch (evtype)
{
case XI_ButtonPress:
- xf_generic_ButtonEvent(xfc, (int) event->event_x, (int) event->event_y,
- event->detail, event->event, xfc->remote_app, TRUE);
+ xf_generic_ButtonEvent(xfc, (int)event->event_x, (int)event->event_y, event->detail,
+ event->event, xfc->remote_app, TRUE);
break;
case XI_ButtonRelease:
- xf_generic_ButtonEvent(xfc, (int) event->event_x, (int) event->event_y,
- event->detail, event->event, xfc->remote_app, FALSE);
+ xf_generic_ButtonEvent(xfc, (int)event->event_x, (int)event->event_y, event->detail,
+ event->event, xfc->remote_app, FALSE);
break;
case XI_Motion:
- xf_generic_MotionNotify(xfc, (int) event->event_x, (int) event->event_y,
- event->detail, event->event, xfc->remote_app);
+ xf_generic_MotionNotify(xfc, (int)event->event_x, (int)event->event_y, event->detail,
+ event->event, xfc->remote_app);
break;
}
diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c
index 384de53fc..50b259308 100644
--- a/client/X11/xf_keyboard.c
+++ b/client/X11/xf_keyboard.c
@@ -172,8 +172,7 @@ void xf_keyboard_release_all_keypress(xfContext* xfc)
// release tab before releasing the windows key.
// this stops the start menu from opening on unfocus event.
if (rdp_scancode == RDP_SCANCODE_LWIN)
- freerdp_input_send_keyboard_event_ex(xfc->context.input, FALSE,
- RDP_SCANCODE_TAB);
+ freerdp_input_send_keyboard_event_ex(xfc->context.input, FALSE, RDP_SCANCODE_TAB);
freerdp_input_send_keyboard_event_ex(xfc->context.input, FALSE, rdp_scancode);
xfc->KeyboardState[keycode] = FALSE;
@@ -196,11 +195,10 @@ void xf_keyboard_send_key(xfContext* xfc, BOOL down, BYTE keycode)
if (rdp_scancode == RDP_SCANCODE_UNKNOWN)
{
- WLog_ERR(TAG, "Unknown key with X keycode 0x%02"PRIx8"", keycode);
+ WLog_ERR(TAG, "Unknown key with X keycode 0x%02" PRIx8 "", keycode);
}
- else if (rdp_scancode == RDP_SCANCODE_PAUSE &&
- !xf_keyboard_key_pressed(xfc, XK_Control_L)
- && !xf_keyboard_key_pressed(xfc, XK_Control_R))
+ else if (rdp_scancode == RDP_SCANCODE_PAUSE && !xf_keyboard_key_pressed(xfc, XK_Control_L) &&
+ !xf_keyboard_key_pressed(xfc, XK_Control_R))
{
/* Pause without Ctrl has to be sent as a series of keycodes
* in a single input PDU. Pause only happens on "press";
@@ -232,13 +230,13 @@ int xf_keyboard_read_keyboard_state(xfContext* xfc)
if (!xfc->remote_app)
{
- XQueryPointer(xfc->display, xfc->window->handle,
- &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
+ XQueryPointer(xfc->display, xfc->window->handle, &wdummy, &wdummy, &dummy, &dummy, &dummy,
+ &dummy, &state);
}
else
{
- XQueryPointer(xfc->display, DefaultRootWindow(xfc->display),
- &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
+ XQueryPointer(xfc->display, DefaultRootWindow(xfc->display), &wdummy, &wdummy, &dummy,
+ &dummy, &dummy, &dummy, &state);
}
return state;
@@ -292,8 +290,7 @@ static BOOL xf_keyboard_set_key_state(xfContext* xfc, BOOL on, int keysym)
return FALSE;
}
- return XkbLockModifiers(xfc->display, XkbUseCoreKbd, keysymMask,
- on ? keysymMask : 0);
+ return XkbLockModifiers(xfc->display, XkbUseCoreKbd, keysymMask, on ? keysymMask : 0);
}
UINT32 xf_keyboard_get_toggle_keys_state(xfContext* xfc)
@@ -322,9 +319,8 @@ static void xk_keyboard_update_modifier_keys(xfContext* xfc)
int state;
size_t i;
KeyCode keycode;
- int keysyms[] = {XK_Shift_L, XK_Shift_R, XK_Alt_L, XK_Alt_R,
- XK_Control_L, XK_Control_R, XK_Super_L, XK_Super_R
- };
+ int keysyms[] = { XK_Shift_L, XK_Shift_R, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, XK_Super_L, XK_Super_R };
xf_keyboard_clear(xfc);
@@ -360,8 +356,7 @@ void xf_keyboard_focus_in(xfContext* xfc)
if (xfc->remote_app)
return;
- if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y,
- &state))
+ if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state))
{
if (x >= 0 && x < xfc->window->width && y >= 0 && y < xfc->window->height)
{
@@ -371,9 +366,7 @@ void xf_keyboard_focus_in(xfContext* xfc)
}
}
-static int xf_keyboard_execute_action_script(xfContext* xfc,
- XF_MODIFIER_KEYS* mod,
- KeySym keysym)
+static int xf_keyboard_execute_action_script(xfContext* xfc, XF_MODIFIER_KEYS* mod, KeySym keysym)
{
int index;
int count;
@@ -389,9 +382,8 @@ static int xf_keyboard_execute_action_script(xfContext* xfc,
if (!xfc->actionScriptExists)
return 1;
- if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R) ||
- (keysym == XK_Alt_L) || (keysym == XK_Alt_R) ||
- (keysym == XK_Control_L) || (keysym == XK_Control_R))
+ if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R) || (keysym == XK_Alt_L) ||
+ (keysym == XK_Alt_R) || (keysym == XK_Control_L) || (keysym == XK_Control_R))
{
return 1;
}
@@ -420,7 +412,7 @@ static int xf_keyboard_execute_action_script(xfContext* xfc,
for (index = 0; index < count; index++)
{
- keyCombination = (char*) ArrayList_GetItem(xfc->keyCombinations, index);
+ keyCombination = (char*)ArrayList_GetItem(xfc->keyCombinations, index);
if (_stricmp(keyCombination, combination) == 0)
{
@@ -432,8 +424,8 @@ static int xf_keyboard_execute_action_script(xfContext* xfc,
if (!match)
return 1;
- sprintf_s(command, sizeof(command), "%s key %s",
- xfc->context.settings->ActionScript, combination);
+ sprintf_s(command, sizeof(command), "%s key %s", xfc->context.settings->ActionScript,
+ combination);
keyScript = popen(command, "r");
if (!keyScript)
@@ -635,9 +627,8 @@ void xf_keyboard_handle_special_keys_release(xfContext* xfc, KeySym keysym)
BOOL xf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
{
- xfContext* xfc = (xfContext*) context;
- xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_SCROLL_LOCK,
- XK_Scroll_Lock);
+ xfContext* xfc = (xfContext*)context;
+ xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_SCROLL_LOCK, XK_Scroll_Lock);
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_NUM_LOCK, XK_Num_Lock);
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_CAPS_LOCK, XK_Caps_Lock);
xf_keyboard_set_key_state(xfc, led_flags & KBD_SYNC_KANA_LOCK, XK_Kana_Lock);
@@ -651,7 +642,8 @@ BOOL xf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeSta
return FALSE;
WLog_WARN(TAG,
- "KeyboardSetImeStatus(unitId=%04"PRIx16", imeState=%08"PRIx32", imeConvMode=%08"PRIx32") ignored",
+ "KeyboardSetImeStatus(unitId=%04" PRIx16 ", imeState=%08" PRIx32
+ ", imeConvMode=%08" PRIx32 ") ignored",
imeId, imeState, imeConvMode);
return TRUE;
}
diff --git a/client/X11/xf_keyboard.h b/client/X11/xf_keyboard.h
index c7e601b1b..2f7dfb786 100644
--- a/client/X11/xf_keyboard.h
+++ b/client/X11/xf_keyboard.h
@@ -57,6 +57,7 @@ void xf_keyboard_focus_in(xfContext* xfc);
BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym);
void xf_keyboard_handle_special_keys_release(xfContext* xfc, KeySym keysym);
BOOL xf_keyboard_set_indicators(rdpContext* context, UINT16 led_flags);
-BOOL xf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState, UINT32 imeConvMode);
+BOOL xf_keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
+ UINT32 imeConvMode);
#endif /* FREERDP_CLIENT_X11_XF_KEYBOARD_H */
diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c
index 4dc16d548..30a0b8b37 100644
--- a/client/X11/xf_monitor.c
+++ b/client/X11/xf_monitor.c
@@ -44,14 +44,15 @@
#include
#if (RANDR_MAJOR * 100 + RANDR_MINOR) >= 105
-# define USABLE_XRANDR
+#define USABLE_XRANDR
#endif
#endif
#include "xf_monitor.h"
-/* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */
+/* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071
+ */
int xf_list_monitors(xfContext* xfc)
{
@@ -69,18 +70,15 @@ int xf_list_monitors(xfContext* xfc)
#if defined(USABLE_XRANDR)
if (XRRQueryExtension(xfc->display, &major, &minor) &&
- (XRRQueryVersion(xfc->display, &major, &minor) == True) &&
- (major * 100 + minor >= 105))
+ (XRRQueryVersion(xfc->display, &major, &minor) == True) && (major * 100 + minor >= 105))
{
- XRRMonitorInfo* monitors = XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1,
- &nmonitors);
+ XRRMonitorInfo* monitors =
+ XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &nmonitors);
for (i = 0; i < nmonitors; i++)
{
- printf(" %s [%d] %dx%d\t+%d+%d\n",
- monitors[i].primary ? "*" : " ", i,
- monitors[i].width, monitors[i].height,
- monitors[i].x, monitors[i].y);
+ printf(" %s [%d] %dx%d\t+%d+%d\n", monitors[i].primary ? "*" : " ", i,
+ monitors[i].width, monitors[i].height, monitors[i].x, monitors[i].y);
}
XRRFreeMonitors(monitors);
@@ -88,24 +86,22 @@ int xf_list_monitors(xfContext* xfc)
else
#endif
#ifdef WITH_XINERAMA
- if (XineramaQueryExtension(display, &major, &minor))
+ if (XineramaQueryExtension(display, &major, &minor))
+ {
+ if (XineramaIsActive(display))
{
- if (XineramaIsActive(display))
+ XineramaScreenInfo* screen = XineramaQueryScreens(display, &nmonitors);
+
+ for (i = 0; i < nmonitors; i++)
{
- XineramaScreenInfo* screen = XineramaQueryScreens(display, &nmonitors);
-
- for (i = 0; i < nmonitors; i++)
- {
- printf(" %s [%d] %hdx%hd\t+%hd+%hd\n",
- (i == 0) ? "*" : " ", i,
- screen[i].width, screen[i].height,
- screen[i].x_org, screen[i].y_org);
- }
-
- XFree(screen);
+ printf(" %s [%d] %hdx%hd\t+%hd+%hd\n", (i == 0) ? "*" : " ", i,
+ screen[i].width, screen[i].height, screen[i].x_org, screen[i].y_org);
}
+
+ XFree(screen);
}
- else
+ }
+ else
#else
{
Screen* screen = ScreenOfDisplay(display, DefaultScreen(display));
@@ -113,7 +109,7 @@ int xf_list_monitors(xfContext* xfc)
}
#endif
- XCloseDisplay(display);
+ XCloseDisplay(display);
return 0;
}
@@ -163,19 +159,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
*pMaxHeight = settings->DesktopHeight;
/* get mouse location */
- if (!XQueryPointer(xfc->display, DefaultRootWindow(xfc->display),
- &_dummy_w, &_dummy_w, &mouse_x, &mouse_y,
- &_dummy_i, &_dummy_i, (void*) &_dummy_i))
+ if (!XQueryPointer(xfc->display, DefaultRootWindow(xfc->display), &_dummy_w, &_dummy_w,
+ &mouse_x, &mouse_y, &_dummy_i, &_dummy_i, (void*)&_dummy_i))
mouse_x = mouse_y = 0;
#if defined(USABLE_XRANDR)
if (XRRQueryExtension(xfc->display, &major, &minor) &&
- (XRRQueryVersion(xfc->display, &major, &minor) == True) &&
- (major * 100 + minor >= 105))
+ (XRRQueryVersion(xfc->display, &major, &minor) == True) && (major * 100 + minor >= 105))
{
- XRRMonitorInfo* rrmonitors = XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1,
- &vscreen->nmonitors);
+ XRRMonitorInfo* rrmonitors =
+ XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &vscreen->nmonitors);
if (vscreen->nmonitors > 16)
vscreen->nmonitors = 0;
@@ -200,32 +194,32 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
else
#endif
#ifdef WITH_XINERAMA
- if (XineramaQueryExtension(xfc->display, &major, &minor) && XineramaIsActive(xfc->display))
+ if (XineramaQueryExtension(xfc->display, &major, &minor) && XineramaIsActive(xfc->display))
+ {
+ XineramaScreenInfo* screenInfo = XineramaQueryScreens(xfc->display, &vscreen->nmonitors);
+
+ if (vscreen->nmonitors > 16)
+ vscreen->nmonitors = 0;
+
+ if (vscreen->nmonitors)
{
- XineramaScreenInfo* screenInfo = XineramaQueryScreens(xfc->display, &vscreen->nmonitors);
+ int i;
- if (vscreen->nmonitors > 16)
- vscreen->nmonitors = 0;
-
- if (vscreen->nmonitors)
+ for (i = 0; i < vscreen->nmonitors; i++)
{
- int i;
-
- for (i = 0; i < vscreen->nmonitors; i++)
- {
- vscreen->monitors[i].area.left = screenInfo[i].x_org;
- vscreen->monitors[i].area.top = screenInfo[i].y_org;
- vscreen->monitors[i].area.right = screenInfo[i].x_org + screenInfo[i].width - 1;
- vscreen->monitors[i].area.bottom = screenInfo[i].y_org + screenInfo[i].height - 1;
- }
+ vscreen->monitors[i].area.left = screenInfo[i].x_org;
+ vscreen->monitors[i].area.top = screenInfo[i].y_org;
+ vscreen->monitors[i].area.right = screenInfo[i].x_org + screenInfo[i].width - 1;
+ vscreen->monitors[i].area.bottom = screenInfo[i].y_org + screenInfo[i].height - 1;
}
-
- XFree(screenInfo);
}
+ XFree(screenInfo);
+ }
+
#endif
- xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom =
- xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right = 0;
+ xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom = xfc->fullscreenMonitors.left =
+ xfc->fullscreenMonitors.right = 0;
/* Determine which monitor that the mouse cursor is on */
if (vscreen->monitors)
@@ -256,7 +250,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if ((!settings->UseMultimon && !settings->SpanMonitors) ||
(settings->Workarea && !settings->RemoteApplicationMode))
{
- /* If no monitors were specified on the command-line then set the current monitor as active */
+ /* If no monitors were specified on the command-line then set the current monitor as active
+ */
if (!settings->NumMonitorIds)
{
settings->MonitorIds[0] = current_monitor;
@@ -329,12 +324,14 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if (settings->PercentScreenUseWidth)
*pMaxWidth = ((vscreen->monitors[current_monitor].area.right -
- vscreen->monitors[current_monitor].area.left + 1) * settings->PercentScreen) /
+ vscreen->monitors[current_monitor].area.left + 1) *
+ settings->PercentScreen) /
100;
if (settings->PercentScreenUseHeight)
*pMaxHeight = ((vscreen->monitors[current_monitor].area.bottom -
- vscreen->monitors[current_monitor].area.top + 1) * settings->PercentScreen) /
+ vscreen->monitors[current_monitor].area.top + 1) *
+ settings->PercentScreen) /
100;
}
else
@@ -355,7 +352,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
*pMaxHeight = settings->DesktopHeight;
}
- /* Create array of all active monitors by taking into account monitors requested on the command-line */
+ /* Create array of all active monitors by taking into account monitors requested on the
+ * command-line */
{
int i;
@@ -402,7 +400,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
}
}
- /* If no monitor is active(bogus command-line monitor specification) - then lets try to fallback to go fullscreen on the current monitor only */
+ /* If no monitor is active(bogus command-line monitor specification) - then lets try to fallback
+ * to go fullscreen on the current monitor only */
if (nmonitors == 0 && vscreen->nmonitors > 0)
{
INT32 width, height;
@@ -412,7 +411,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
width = vscreen->monitors[current_monitor].area.right -
vscreen->monitors[current_monitor].area.left + 1L;
height = vscreen->monitors[current_monitor].area.bottom -
- vscreen->monitors[current_monitor].area.top + 1L;
+ vscreen->monitors[current_monitor].area.top + 1L;
settings->MonitorDefArray[0].x = vscreen->monitors[current_monitor].area.left;
settings->MonitorDefArray[0].y = vscreen->monitors[current_monitor].area.top;
@@ -434,8 +433,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
int vR = vX + settings->MonitorDefArray[0].width;
int vB = vY + settings->MonitorDefArray[0].height;
xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom =
- xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right =
- settings->MonitorDefArray[0].orig_screen;
+ xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right =
+ settings->MonitorDefArray[0].orig_screen;
/* Calculate bounding rectangle around all monitors to be used AND
* also set the Xinerama indices which define left/top/right/bottom monitors.
@@ -445,10 +444,10 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
/* does the same as gdk_rectangle_union */
int destX = MIN(vX, settings->MonitorDefArray[i].x);
int destY = MIN(vY, settings->MonitorDefArray[i].y);
- int destR = MAX(vR, settings->MonitorDefArray[i].x +
- settings->MonitorDefArray[i].width);
- int destB = MAX(vB, settings->MonitorDefArray[i].y +
- settings->MonitorDefArray[i].height);
+ int destR =
+ MAX(vR, settings->MonitorDefArray[i].x + settings->MonitorDefArray[i].width);
+ int destB =
+ MAX(vB, settings->MonitorDefArray[i].y + settings->MonitorDefArray[i].height);
if (vX != destX)
xfc->fullscreenMonitors.left = settings->MonitorDefArray[i].orig_screen;
@@ -485,7 +484,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if (settings->NumMonitorIds)
{
/* The first monitor is the first in the setting which should be used */
- monitor_index = settings->MonitorIds[0];
+ monitor_index = settings->MonitorIds[0];
}
else
{
@@ -509,11 +508,12 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
}
else
{
- /* Lets try to see if there is a monitor with a 0,0 coordinate and use it as a fallback*/
+ /* Lets try to see if there is a monitor with a 0,0 coordinate and use it as a
+ * fallback*/
for (i = 0; i < settings->MonitorCount; i++)
{
- if (!primaryMonitorFound && settings->MonitorDefArray[i].x == 0
- && settings->MonitorDefArray[i].y == 0)
+ if (!primaryMonitorFound && settings->MonitorDefArray[i].x == 0 &&
+ settings->MonitorDefArray[i].y == 0)
{
settings->MonitorDefArray[i].is_primary = TRUE;
settings->MonitorLocalShiftX = settings->MonitorDefArray[i].x;
@@ -525,20 +525,22 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
}
/* Subtract monitor shift from monitor variables for server-side use.
- * We maintain monitor shift value as Window requires the primary monitor to have a coordinate of 0,0
- * In some X configurations, no monitor may have a coordinate of 0,0. This can also be happen if the user
- * requests specific monitors from the command-line as well. So, we make sure to translate our primary monitor's
- * upper-left corner to 0,0 on the server.
+ * We maintain monitor shift value as Window requires the primary monitor to have a
+ * coordinate of 0,0 In some X configurations, no monitor may have a coordinate of 0,0. This
+ * can also be happen if the user requests specific monitors from the command-line as well.
+ * So, we make sure to translate our primary monitor's upper-left corner to 0,0 on the
+ * server.
*/
for (i = 0; i < settings->MonitorCount; i++)
{
- settings->MonitorDefArray[i].x = settings->MonitorDefArray[i].x -
- settings->MonitorLocalShiftX;
- settings->MonitorDefArray[i].y = settings->MonitorDefArray[i].y -
- settings->MonitorLocalShiftY;
+ settings->MonitorDefArray[i].x =
+ settings->MonitorDefArray[i].x - settings->MonitorLocalShiftX;
+ settings->MonitorDefArray[i].y =
+ settings->MonitorDefArray[i].y - settings->MonitorLocalShiftY;
}
- /* Set the desktop width and height according to the bounding rectangle around the active monitors */
+ /* Set the desktop width and height according to the bounding rectangle around the active
+ * monitors */
*pMaxWidth = MIN(*pMaxWidth, (UINT32)vscreen->area.right - vscreen->area.left + 1);
*pMaxHeight = MIN(*pMaxHeight, (UINT32)vscreen->area.bottom - vscreen->area.top + 1);
}
diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c
index a391add38..d712604e0 100644
--- a/client/X11/xf_rail.c
+++ b/client/X11/xf_rail.c
@@ -33,32 +33,20 @@
#define TAG CLIENT_TAG("x11")
-static const char* error_code_names[] =
-{
- "RAIL_EXEC_S_OK",
- "RAIL_EXEC_E_HOOK_NOT_LOADED",
- "RAIL_EXEC_E_DECODE_FAILED",
- "RAIL_EXEC_E_NOT_IN_ALLOWLIST",
- "RAIL_EXEC_E_FILE_NOT_FOUND",
- "RAIL_EXEC_E_FAIL",
- "RAIL_EXEC_E_SESSION_LOCKED"
-};
+static const char* error_code_names[] = { "RAIL_EXEC_S_OK",
+ "RAIL_EXEC_E_HOOK_NOT_LOADED",
+ "RAIL_EXEC_E_DECODE_FAILED",
+ "RAIL_EXEC_E_NOT_IN_ALLOWLIST",
+ "RAIL_EXEC_E_FILE_NOT_FOUND",
+ "RAIL_EXEC_E_FAIL",
+ "RAIL_EXEC_E_SESSION_LOCKED" };
#ifdef WITH_DEBUG_RAIL
-static const char* movetype_names[] =
-{
- "(invalid)",
- "RAIL_WMSZ_LEFT",
- "RAIL_WMSZ_RIGHT",
- "RAIL_WMSZ_TOP",
- "RAIL_WMSZ_TOPLEFT",
- "RAIL_WMSZ_TOPRIGHT",
- "RAIL_WMSZ_BOTTOM",
- "RAIL_WMSZ_BOTTOMLEFT",
- "RAIL_WMSZ_BOTTOMRIGHT",
- "RAIL_WMSZ_MOVE",
- "RAIL_WMSZ_KEYMOVE",
- "RAIL_WMSZ_KEYSIZE"
+static const char* movetype_names[] = {
+ "(invalid)", "RAIL_WMSZ_LEFT", "RAIL_WMSZ_RIGHT",
+ "RAIL_WMSZ_TOP", "RAIL_WMSZ_TOPLEFT", "RAIL_WMSZ_TOPRIGHT",
+ "RAIL_WMSZ_BOTTOM", "RAIL_WMSZ_BOTTOMLEFT", "RAIL_WMSZ_BOTTOMRIGHT",
+ "RAIL_WMSZ_MOVE", "RAIL_WMSZ_KEYMOVE", "RAIL_WMSZ_KEYSIZE"
};
#endif
@@ -117,8 +105,7 @@ void xf_rail_send_activate(xfContext* xfc, Window xwindow, BOOL enabled)
xfc->rail->ClientActivate(xfc->rail, &activate);
}
-void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId,
- UINT16 command)
+void xf_rail_send_client_system_command(xfContext* xfc, UINT32 windowId, UINT16 command)
{
RAIL_SYSCOMMAND_ORDER syscommand;
syscommand.windowId = windowId;
@@ -140,14 +127,14 @@ void xf_rail_adjust_position(xfContext* xfc, xfAppWindow* appWindow)
return;
/* If current window position disagrees with RDP window position, send update to RDP server */
- if (appWindow->x != appWindow->windowOffsetX ||
- appWindow->y != appWindow->windowOffsetY ||
+ if (appWindow->x != appWindow->windowOffsetX || appWindow->y != appWindow->windowOffsetY ||
appWindow->width != (INT64)appWindow->windowWidth ||
appWindow->height != (INT64)appWindow->windowHeight)
{
windowMove.windowId = appWindow->windowId;
/*
- * Calculate new size/position for the rail window(new values for windowOffsetX/windowOffsetY/windowWidth/windowHeight) on the server
+ * Calculate new size/position for the rail window(new values for
+ * windowOffsetX/windowOffsetY/windowWidth/windowHeight) on the server
*/
windowMove.left = appWindow->x;
windowMove.top = appWindow->y;
@@ -172,20 +159,22 @@ void xf_rail_end_local_move(xfContext* xfc, xfAppWindow* appWindow)
*/
windowMove.windowId = appWindow->windowId;
/*
- * Calculate new size/position for the rail window(new values for windowOffsetX/windowOffsetY/windowWidth/windowHeight) on the server
+ * Calculate new size/position for the rail window(new values for
+ * windowOffsetX/windowOffsetY/windowWidth/windowHeight) on the server
*
*/
windowMove.left = appWindow->x;
windowMove.top = appWindow->y;
- windowMove.right = windowMove.left +
- appWindow->width; /* In the update to RDP the position is one past the window */
+ windowMove.right =
+ windowMove.left +
+ appWindow->width; /* In the update to RDP the position is one past the window */
windowMove.bottom = windowMove.top + appWindow->height;
xfc->rail->ClientWindowMove(xfc->rail, &windowMove);
/*
* Simulate button up at new position to end the local move (per RDP spec)
*/
- XQueryPointer(xfc->display, appWindow->handle,
- &root_window, &child_window, &x, &y, &child_x, &child_y, &mask);
+ XQueryPointer(xfc->display, appWindow->handle, &root_window, &child_window, &x, &y, &child_x,
+ &child_y, &mask);
/* only send the mouse coordinates if not a keyboard move or size */
if ((appWindow->local_move.direction != _NET_WM_MOVERESIZE_MOVE_KEYBOARD) &&
@@ -251,8 +240,7 @@ static void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion)
region16_uninit(&windowInvalidRegion);
}
-void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright,
- UINT32 ubottom)
+void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom)
{
REGION16 invalidRegion;
RECTANGLE_16 invalidRect;
@@ -268,11 +256,11 @@ void xf_rail_paint(xfContext* xfc, INT32 uleft, INT32 utop, UINT32 uright,
/* RemoteApp Core Protocol Extension */
-static BOOL xf_rail_window_common(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const WINDOW_STATE_ORDER* windowState)
+static BOOL xf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_STATE_ORDER* windowState)
{
xfAppWindow* appWindow = NULL;
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
UINT32 fieldFlags = orderInfo->fieldFlags;
BOOL position_or_size_updated = FALSE;
appWindow = xf_rail_get_window(xfc, orderInfo->windowId);
@@ -303,8 +291,9 @@ static BOOL xf_rail_window_common(rdpContext* context,
/* error handled below */
}
}
- else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
- windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
+ else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
+ windowState->titleInfo.length / 2, &title, 0, NULL,
+ NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
/* error handled below */
@@ -332,7 +321,7 @@ static BOOL xf_rail_window_common(rdpContext* context,
/* Keep track of any position/size update so that we can force a refresh of the window */
if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) ||
- (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) ||
+ (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) ||
(fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) ||
(fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) ||
(fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) ||
@@ -384,7 +373,7 @@ static BOOL xf_rail_window_common(rdpContext* context,
return FALSE;
}
}
- else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
+ else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
@@ -425,8 +414,8 @@ static BOOL xf_rail_window_common(rdpContext* context,
if (appWindow->numWindowRects)
{
- appWindow->windowRects = (RECTANGLE_16*) calloc(appWindow->numWindowRects,
- sizeof(RECTANGLE_16));
+ appWindow->windowRects =
+ (RECTANGLE_16*)calloc(appWindow->numWindowRects, sizeof(RECTANGLE_16));
if (!appWindow->windowRects)
return FALSE;
@@ -454,8 +443,8 @@ static BOOL xf_rail_window_common(rdpContext* context,
if (appWindow->numVisibilityRects)
{
- appWindow->visibilityRects = (RECTANGLE_16*) calloc(
- appWindow->numVisibilityRects, sizeof(RECTANGLE_16));
+ appWindow->visibilityRects =
+ (RECTANGLE_16*)calloc(appWindow->numVisibilityRects, sizeof(RECTANGLE_16));
if (!appWindow->visibilityRects)
return FALSE;
@@ -484,15 +473,17 @@ static BOOL xf_rail_window_common(rdpContext* context,
if (position_or_size_updated)
{
- UINT32 visibilityRectsOffsetX = (appWindow->visibleOffsetX -
- (appWindow->clientOffsetX - appWindow->windowClientDeltaX));
- UINT32 visibilityRectsOffsetY = (appWindow->visibleOffsetY -
- (appWindow->clientOffsetY - appWindow->windowClientDeltaY));
+ UINT32 visibilityRectsOffsetX =
+ (appWindow->visibleOffsetX -
+ (appWindow->clientOffsetX - appWindow->windowClientDeltaX));
+ UINT32 visibilityRectsOffsetY =
+ (appWindow->visibleOffsetY -
+ (appWindow->clientOffsetY - appWindow->windowClientDeltaY));
/*
- * The rail server like to set the window to a small size when it is minimized even though it is hidden
- * in some cases this can cause the window not to restore back to its original size. Therefore we don't
- * update our local window when that rail window state is minimized
+ * The rail server like to set the window to a small size when it is minimized even though
+ * it is hidden in some cases this can cause the window not to restore back to its original
+ * size. Therefore we don't update our local window when that rail window state is minimized
*/
if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED)
{
@@ -507,8 +498,7 @@ static BOOL xf_rail_window_common(rdpContext* context,
}
else
{
- xf_MoveWindow(xfc, appWindow, appWindow->windowOffsetX,
- appWindow->windowOffsetY,
+ xf_MoveWindow(xfc, appWindow, appWindow->windowOffsetX, appWindow->windowOffsetY,
appWindow->windowWidth, appWindow->windowHeight);
}
@@ -521,15 +511,14 @@ static BOOL xf_rail_window_common(rdpContext* context,
/* We should only be using the visibility rects for shaping the window */
/*if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
- xf_SetWindowRects(xfc, appWindow, appWindow->windowRects, appWindow->numWindowRects);
+ xf_SetWindowRects(xfc, appWindow, appWindow->windowRects, appWindow->numWindowRects);
}*/
return TRUE;
}
-static BOOL xf_rail_window_delete(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL xf_rail_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
return xf_rail_del_window(xfc, orderInfo->windowId);
}
@@ -543,13 +532,12 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings)
cache->numCaches = settings->RemoteAppNumIconCaches;
cache->numCacheEntries = settings->RemoteAppNumIconCacheEntries;
- cache->entries = calloc(cache->numCaches * cache->numCacheEntries,
- sizeof(xfRailIcon));
+ cache->entries = calloc(cache->numCaches * cache->numCacheEntries, sizeof(xfRailIcon));
if (!cache->entries)
{
- WLog_ERR(TAG, "failed to allocate icon cache %d x %d entries",
- cache->numCaches, cache->numCacheEntries);
+ WLog_ERR(TAG, "failed to allocate icon cache %d x %d entries", cache->numCaches,
+ cache->numCacheEntries);
free(cache);
return NULL;
}
@@ -574,8 +562,7 @@ static void RailIconCache_Free(xfRailIconCache* cache)
}
}
-static xfRailIcon* RailIconCache_Lookup(xfRailIconCache* cache,
- UINT8 cacheId, UINT16 cacheEntry)
+static xfRailIcon* RailIconCache_Lookup(xfRailIconCache* cache, UINT8 cacheId, UINT16 cacheEntry)
{
/*
* MS-RDPERP 2.2.1.2.3 Icon Info (TS_ICON_INFO)
@@ -620,12 +607,10 @@ static BOOL convert_rail_icon(ICON_INFO* iconInfo, xfRailIcon* railIcon)
if (!argbPixels)
goto error;
- if (!freerdp_image_copy_from_icon_data(argbPixels,
- PIXEL_FORMAT_ARGB32, 0, 0, 0,
- iconInfo->width, iconInfo->height,
- iconInfo->bitsColor, iconInfo->cbBitsColor,
- iconInfo->bitsMask, iconInfo->cbBitsMask,
- iconInfo->colorTable, iconInfo->cbColorTable, iconInfo->bpp))
+ if (!freerdp_image_copy_from_icon_data(
+ argbPixels, PIXEL_FORMAT_ARGB32, 0, 0, 0, iconInfo->width, iconInfo->height,
+ iconInfo->bitsColor, iconInfo->cbBitsColor, iconInfo->bitsMask, iconInfo->cbBitsMask,
+ iconInfo->colorTable, iconInfo->cbColorTable, iconInfo->bpp))
goto error;
nelements = 2 + iconInfo->width * iconInfo->height;
@@ -653,20 +638,19 @@ error:
return FALSE;
}
-static void xf_rail_set_window_icon(xfContext* xfc,
- xfAppWindow* railWindow, xfRailIcon* icon,
+static void xf_rail_set_window_icon(xfContext* xfc, xfAppWindow* railWindow, xfRailIcon* icon,
BOOL replace)
{
- XChangeProperty(xfc->display, railWindow->handle, xfc->_NET_WM_ICON,
- XA_CARDINAL, 32, replace ? PropModeReplace : PropModeAppend,
- (unsigned char*) icon->data, icon->length);
+ XChangeProperty(xfc->display, railWindow->handle, xfc->_NET_WM_ICON, XA_CARDINAL, 32,
+ replace ? PropModeReplace : PropModeAppend, (unsigned char*)icon->data,
+ icon->length);
XFlush(xfc->display);
}
-static BOOL xf_rail_window_icon(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const WINDOW_ICON_ORDER* windowIcon)
+static BOOL xf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_ICON_ORDER* windowIcon)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xfAppWindow* railWindow;
xfRailIcon* icon;
BOOL replaceIcon;
@@ -675,14 +659,12 @@ static BOOL xf_rail_window_icon(rdpContext* context,
if (!railWindow)
return TRUE;
- icon = RailIconCache_Lookup(xfc->railIconCache,
- windowIcon->iconInfo->cacheId,
+ icon = RailIconCache_Lookup(xfc->railIconCache, windowIcon->iconInfo->cacheId,
windowIcon->iconInfo->cacheEntry);
if (!icon)
{
- WLog_WARN(TAG, "failed to get icon from cache %02X:%04X",
- windowIcon->iconInfo->cacheId,
+ WLog_WARN(TAG, "failed to get icon from cache %02X:%04X", windowIcon->iconInfo->cacheId,
windowIcon->iconInfo->cacheEntry);
return FALSE;
}
@@ -698,10 +680,10 @@ static BOOL xf_rail_window_icon(rdpContext* context,
return TRUE;
}
-static BOOL xf_rail_window_cached_icon(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
+static BOOL xf_rail_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xfAppWindow* railWindow;
xfRailIcon* icon;
BOOL replaceIcon;
@@ -710,15 +692,13 @@ static BOOL xf_rail_window_cached_icon(rdpContext* context,
if (!railWindow)
return TRUE;
- icon = RailIconCache_Lookup(xfc->railIconCache,
- windowCachedIcon->cachedIcon.cacheId,
+ icon = RailIconCache_Lookup(xfc->railIconCache, windowCachedIcon->cachedIcon.cacheId,
windowCachedIcon->cachedIcon.cacheEntry);
if (!icon)
{
WLog_WARN(TAG, "failed to get icon from cache %02X:%04X",
- windowCachedIcon->cachedIcon.cacheId,
- windowCachedIcon->cachedIcon.cacheEntry);
+ windowCachedIcon->cachedIcon.cacheId, windowCachedIcon->cachedIcon.cacheEntry);
return FALSE;
}
@@ -727,8 +707,8 @@ static BOOL xf_rail_window_cached_icon(rdpContext* context,
return TRUE;
}
-static BOOL xf_rail_notify_icon_common(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static BOOL xf_rail_notify_icon_common(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
{
@@ -757,34 +737,32 @@ static BOOL xf_rail_notify_icon_common(rdpContext* context,
return TRUE;
}
-static BOOL xf_rail_notify_icon_create(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static BOOL xf_rail_notify_icon_create(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
return xf_rail_notify_icon_common(context, orderInfo, notifyIconState);
}
-static BOOL xf_rail_notify_icon_update(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const NOTIFY_ICON_STATE_ORDER* notifyIconState)
+static BOOL xf_rail_notify_icon_update(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
return xf_rail_notify_icon_common(context, orderInfo, notifyIconState);
}
-static BOOL xf_rail_notify_icon_delete(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL xf_rail_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
return TRUE;
}
-static BOOL xf_rail_monitored_desktop(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo, const MONITORED_DESKTOP_ORDER* monitoredDesktop)
+static BOOL xf_rail_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
+ const MONITORED_DESKTOP_ORDER* monitoredDesktop)
{
return TRUE;
}
-static BOOL xf_rail_non_monitored_desktop(rdpContext* context,
- const WINDOW_ORDER_INFO* orderInfo)
+static BOOL xf_rail_non_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
- xfContext* xfc = (xfContext*) context;
+ xfContext* xfc = (xfContext*)context;
xf_rail_disable_remoteapp_mode(xfc);
return TRUE;
}
@@ -812,9 +790,9 @@ static void xf_rail_register_update_callbacks(rdpUpdate* update)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_rail_server_execute_result(RailClientContext* context,
- const RAIL_EXEC_RESULT_ORDER* execResult)
+ const RAIL_EXEC_RESULT_ORDER* execResult)
{
- xfContext* xfc = (xfContext*) context->custom;
+ xfContext* xfc = (xfContext*)context->custom;
if (execResult->execResult != RAIL_EXEC_S_OK)
{
@@ -848,7 +826,7 @@ static UINT xf_rail_server_start_cmd(RailClientContext* context)
RAIL_EXEC_ORDER exec = { 0 };
RAIL_SYSPARAM_ORDER sysparam = { 0 };
RAIL_CLIENT_STATUS_ORDER clientStatus = { 0 };
- xfContext* xfc = (xfContext*) context->custom;
+ xfContext* xfc = (xfContext*)context->custom;
rdpSettings* settings = xfc->context.settings;
clientStatus.flags = TS_RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE;
@@ -872,7 +850,7 @@ static UINT xf_rail_server_start_cmd(RailClientContext* context)
status = context->ClientLanguageBarInfo(context, &langBarInfo);
/* We want the language bar, but the server might not support it. */
- switch(status)
+ switch (status)
{
case CHANNEL_RC_OK:
case ERROR_BAD_CONFIGURATION:
@@ -939,12 +917,12 @@ static UINT xf_rail_server_handshake_ex(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_rail_server_local_move_size(RailClientContext* context,
- const RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
+ const RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
int x = 0, y = 0;
int direction = 0;
Window child_window;
- xfContext* xfc = (xfContext*) context->custom;
+ xfContext* xfc = (xfContext*)context->custom;
xfAppWindow* appWindow = xf_rail_get_window(xfc, localMoveSize->windowId);
if (!appWindow)
@@ -1002,8 +980,7 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
case RAIL_WMSZ_MOVE:
direction = _NET_WM_MOVERESIZE_MOVE;
- XTranslateCoordinates(xfc->display, appWindow->handle,
- RootWindowOfScreen(xfc->screen),
+ XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen),
localMoveSize->posX, localMoveSize->posY, &x, &y, &child_window);
break;
@@ -1038,16 +1015,15 @@ static UINT xf_rail_server_local_move_size(RailClientContext* context,
static UINT xf_rail_server_min_max_info(RailClientContext* context,
const RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
- xfContext* xfc = (xfContext*) context->custom;
+ xfContext* xfc = (xfContext*)context->custom;
xfAppWindow* appWindow = xf_rail_get_window(xfc, minMaxInfo->windowId);
if (appWindow)
{
- xf_SetWindowMinMaxInfo(xfc, appWindow,
- minMaxInfo->maxWidth, minMaxInfo->maxHeight,
- minMaxInfo->maxPosX, minMaxInfo->maxPosY,
- minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight,
- minMaxInfo->maxTrackWidth, minMaxInfo->maxTrackHeight);
+ xf_SetWindowMinMaxInfo(xfc, appWindow, minMaxInfo->maxWidth, minMaxInfo->maxHeight,
+ minMaxInfo->maxPosX, minMaxInfo->maxPosY, minMaxInfo->minTrackWidth,
+ minMaxInfo->minTrackHeight, minMaxInfo->maxTrackWidth,
+ minMaxInfo->maxTrackHeight);
}
return CHANNEL_RC_OK;
@@ -1059,7 +1035,7 @@ static UINT xf_rail_server_min_max_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_rail_server_language_bar_info(RailClientContext* context,
- const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
+ const RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
return CHANNEL_RC_OK;
}
@@ -1070,7 +1046,7 @@ static UINT xf_rail_server_language_bar_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT xf_rail_server_get_appid_response(RailClientContext* context,
- const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
+ const RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
return CHANNEL_RC_OK;
}
@@ -1089,12 +1065,12 @@ static BOOL rail_window_key_equals(void* key1, void* key2)
static UINT32 rail_window_key_hash(void* key)
{
const UINT64* k1 = (const UINT64*)key;
- return (UINT32) * k1;
+ return (UINT32)*k1;
}
static void rail_window_free(void* value)
{
- xfAppWindow* appWindow = (xfAppWindow*) value;
+ xfAppWindow* appWindow = (xfAppWindow*)value;
if (!appWindow)
return;
@@ -1104,14 +1080,14 @@ static void rail_window_free(void* value)
int xf_rail_init(xfContext* xfc, RailClientContext* rail)
{
- rdpContext* context = (rdpContext*) xfc;
+ rdpContext* context = (rdpContext*)xfc;
if (!xfc || !rail)
return 0;
xfc->rail = rail;
xf_rail_register_update_callbacks(context->update);
- rail->custom = (void*) xfc;
+ rail->custom = (void*)xfc;
rail->ServerExecuteResult = xf_rail_server_execute_result;
rail->ServerSystemParam = xf_rail_server_system_param;
rail->ServerHandshake = xf_rail_server_handshake;
@@ -1172,7 +1148,7 @@ xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, U
if (!xfc)
return NULL;
- appWindow = (xfAppWindow*) calloc(1, sizeof(xfAppWindow));
+ appWindow = (xfAppWindow*)calloc(1, sizeof(xfAppWindow));
if (!appWindow)
return NULL;
@@ -1185,7 +1161,7 @@ xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, U
appWindow->width = width;
appWindow->height = height;
xf_AppWindowCreate(xfc, appWindow);
- HashTable_Add(xfc->railWindows, &appWindow->windowId, (void*) appWindow);
+ HashTable_Add(xfc->railWindows, &appWindow->windowId, (void*)appWindow);
return appWindow;
}
@@ -1210,4 +1186,3 @@ xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id)
return HashTable_GetItemValue(xfc->railWindows, &id);
}
-
diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h
index 0953ae6be..c99ed7050 100644
--- a/client/X11/xf_rail.h
+++ b/client/X11/xf_rail.h
@@ -33,15 +33,15 @@ void xf_rail_end_local_move(xfContext* xfc, xfAppWindow* appWindow);
void xf_rail_enable_remoteapp_mode(xfContext* xfc);
void xf_rail_disable_remoteapp_mode(xfContext* xfc);
-xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y,
- UINT32 width, UINT32 height, UINT32 surfaceId);
+xfAppWindow* xf_rail_add_window(xfContext* xfc, UINT64 id, UINT32 x, UINT32 y, UINT32 width,
+ UINT32 height, UINT32 surfaceId);
xfAppWindow* xf_rail_get_window(xfContext* xfc, UINT64 id);
BOOL xf_rail_del_window(xfContext* xfc, UINT64 id);
-BOOL xf_rail_draw_window(xfContext* xfc, xfAppWindow* window, const char* data,
- UINT32 scanline, UINT32 width, UINT32 height,
- const RECTANGLE_16* src, const RECTANGLE_16* dst);
+BOOL xf_rail_draw_window(xfContext* xfc, xfAppWindow* window, const char* data, UINT32 scanline,
+ UINT32 width, UINT32 height, const RECTANGLE_16* src,
+ const RECTANGLE_16* dst);
int xf_rail_init(xfContext* xfc, RailClientContext* rail);
int xf_rail_uninit(xfContext* xfc, RailClientContext* rail);
diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c
index 6d7205036..87f10471a 100644
--- a/client/X11/xf_tsmf.c
+++ b/client/X11/xf_tsmf.c
@@ -94,12 +94,12 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
if (!tsmf)
return -1;
- xfc = (xfContext*) tsmf->custom;
+ xfc = (xfContext*)tsmf->custom;
if (!xfc)
return -1;
- xv = (xfXvContext*) xfc->xv_context;
+ xv = (xfXvContext*)xfc->xv_context;
if (!xv)
return -1;
@@ -118,7 +118,7 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
if (numRects > 0)
{
- xrects = (XRectangle*) calloc(numRects, sizeof(XRectangle));
+ xrects = (XRectangle*)calloc(numRects, sizeof(XRectangle));
if (!xrects)
return -1;
@@ -186,13 +186,13 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
}
else
{
- WLog_DBG(TAG, "pixel format 0x%"PRIX32" not supported by hardware.", pixfmt);
+ WLog_DBG(TAG, "pixel format 0x%" PRIX32 " not supported by hardware.", pixfmt);
free(xrects);
return -1003;
}
- image = XvShmCreateImage(xfc->display, xv->xv_port,
- xvpixfmt, 0, event->frameWidth, event->frameHeight, &shminfo);
+ image = XvShmCreateImage(xfc->display, xv->xv_port, xvpixfmt, 0, event->frameWidth,
+ event->frameHeight, &shminfo);
if (xv->xv_image_size != image->data_size)
{
@@ -228,17 +228,15 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
/* Y */
if (image->pitches[0] == event->frameWidth)
{
- CopyMemory(image->data + image->offsets[0],
- event->frameData,
- event->frameWidth * event->frameHeight);
+ CopyMemory(image->data + image->offsets[0], event->frameData,
+ event->frameWidth * event->frameHeight);
}
else
{
for (i = 0; i < event->frameHeight; i++)
{
CopyMemory(image->data + image->offsets[0] + i * image->pitches[0],
- event->frameData + i * event->frameWidth,
- event->frameWidth);
+ event->frameData + i * event->frameWidth, event->frameWidth);
}
}
/* UV */
@@ -247,35 +245,31 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
{
data1 = event->frameData + event->frameWidth * event->frameHeight;
data2 = event->frameData + event->frameWidth * event->frameHeight +
- event->frameWidth * event->frameHeight / 4;
+ event->frameWidth * event->frameHeight / 4;
}
else
{
data2 = event->frameData + event->frameWidth * event->frameHeight;
data1 = event->frameData + event->frameWidth * event->frameHeight +
- event->frameWidth * event->frameHeight / 4;
+ event->frameWidth * event->frameHeight / 4;
image->id = pixfmt == RDP_PIXFMT_I420 ? RDP_PIXFMT_YV12 : RDP_PIXFMT_I420;
}
if (image->pitches[1] * 2 == event->frameWidth)
{
- CopyMemory(image->data + image->offsets[1],
- data1,
- event->frameWidth * event->frameHeight / 4);
- CopyMemory(image->data + image->offsets[2],
- data2,
- event->frameWidth * event->frameHeight / 4);
+ CopyMemory(image->data + image->offsets[1], data1,
+ event->frameWidth * event->frameHeight / 4);
+ CopyMemory(image->data + image->offsets[2], data2,
+ event->frameWidth * event->frameHeight / 4);
}
else
{
for (i = 0; i < event->frameHeight / 2; i++)
{
CopyMemory(image->data + image->offsets[1] + i * image->pitches[1],
- data1 + i * event->frameWidth / 2,
- event->frameWidth / 2);
+ data1 + i * event->frameWidth / 2, event->frameWidth / 2);
CopyMemory(image->data + image->offsets[2] + i * image->pitches[2],
- data2 + i * event->frameWidth / 2,
- event->frameWidth / 2);
+ data2 + i * event->frameWidth / 2, event->frameWidth / 2);
}
}
break;
@@ -288,16 +282,17 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM
}
else
{
- const size_t size = ((UINT32)image->data_size <= event->frameSize) ?
- (UINT32)image->data_size : event->frameSize;
+ const size_t size = ((UINT32)image->data_size <= event->frameSize)
+ ? (UINT32)image->data_size
+ : event->frameSize;
CopyMemory(image->data, event->frameData, size);
}
break;
}
- XvShmPutImage(xfc->display, xv->xv_port, xfc->window->handle, xfc->gc,
- image, 0, 0, image->width, image->height,
- event->x, event->y, event->width, event->height, FALSE);
+ XvShmPutImage(xfc->display, xv->xv_port, xfc->window->handle, xfc->gc, image, 0, 0,
+ image->width, image->height, event->x, event->y, event->width, event->height,
+ FALSE);
if (xv->xv_colorkey_atom == None)
XSetClipMask(xfc->display, xfc->gc, None);
@@ -330,7 +325,7 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
if (xfc->xv_context)
return 1; /* context already created */
- xv = (xfXvContext*) calloc(1, sizeof(xfXvContext));
+ xv = (xfXvContext*)calloc(1, sizeof(xfXvContext));
if (!xv)
return -1;
@@ -347,7 +342,8 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
return -1;
}
- ret = XvQueryExtension(xfc->display, &version, &release, &request_base, &event_base, &error_base);
+ ret =
+ XvQueryExtension(xfc->display, &version, &release, &request_base, &event_base, &error_base);
if (ret != Success)
{
@@ -357,8 +353,7 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
WLog_DBG(TAG, "version %u release %u", version, release);
- ret = XvQueryAdaptors(xfc->display, DefaultRootWindow(xfc->display),
- &num_adaptors, &ai);
+ ret = XvQueryAdaptors(xfc->display, DefaultRootWindow(xfc->display), &num_adaptors, &ai);
if (ret != Success)
{
@@ -369,7 +364,7 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
for (i = 0; i < num_adaptors; i++)
{
WLog_DBG(TAG, "adapter port %lu-%lu (%s)", ai[i].base_id,
- ai[i].base_id + ai[i].num_ports - 1, ai[i].name);
+ ai[i].base_id + ai[i].num_ports - 1, ai[i].name);
if (xv->xv_port == 0 && i == num_adaptors - 1)
xv->xv_port = ai[i].base_id;
@@ -392,7 +387,8 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
if (strcmp(attr[i].name, "XV_COLORKEY") == 0)
{
xv->xv_colorkey_atom = XInternAtom(xfc->display, "XV_COLORKEY", FALSE);
- XvSetPortAttribute(xfc->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1);
+ XvSetPortAttribute(xfc->display, xv->xv_port, xv->xv_colorkey_atom,
+ attr[i].min_value + 1);
break;
}
}
@@ -404,13 +400,14 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
if (ret > 0)
{
- xv->xv_pixfmts = (UINT32*) calloc((ret + 1), sizeof(UINT32));
+ xv->xv_pixfmts = (UINT32*)calloc((ret + 1), sizeof(UINT32));
for (i = 0; i < (unsigned int)ret; i++)
{
xv->xv_pixfmts[i] = fo[i].id;
- WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0], ((char*)(xv->xv_pixfmts + i))[1],
- ((char*)(xv->xv_pixfmts + i))[2], ((char*)(xv->xv_pixfmts + i))[3]);
+ WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0],
+ ((char*)(xv->xv_pixfmts + i))[1], ((char*)(xv->xv_pixfmts + i))[2],
+ ((char*)(xv->xv_pixfmts + i))[3]);
}
xv->xv_pixfmts[i] = 0;
}
@@ -419,7 +416,7 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
if (tsmf)
{
xfc->tsmf = tsmf;
- tsmf->custom = (void*) xfc;
+ tsmf->custom = (void*)xfc;
tsmf->FrameEvent = xf_tsmf_xv_video_frame_event;
}
@@ -429,7 +426,7 @@ int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf)
int xf_tsmf_xv_uninit(xfContext* xfc, TsmfClientContext* tsmf)
{
- xfXvContext* xv = (xfXvContext*) xfc->xv_context;
+ xfXvContext* xv = (xfXvContext*)xfc->xv_context;
WINPR_UNUSED(tsmf);
if (xv)
@@ -476,4 +473,3 @@ int xf_tsmf_uninit(xfContext* xfc, TsmfClientContext* tsmf)
return 1;
}
-
diff --git a/client/X11/xf_video.c b/client/X11/xf_video.c
index a956f9ce8..9520454cb 100644
--- a/client/X11/xf_video.c
+++ b/client/X11/xf_video.c
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-
#include
#include
#include
@@ -33,7 +32,7 @@ typedef struct
} xfVideoSurface;
static VideoSurface* xfVideoCreateSurface(VideoClientContext* video, BYTE* data, UINT32 x, UINT32 y,
- UINT32 width, UINT32 height)
+ UINT32 width, UINT32 height)
{
xfContext* xfc = (xfContext*)video->custom;
xfVideoSurface* ret = calloc(1, sizeof(*ret));
@@ -46,8 +45,8 @@ static VideoSurface* xfVideoCreateSurface(VideoClientContext* video, BYTE* data,
ret->base.y = y;
ret->base.w = width;
ret->base.h = height;
- ret->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
- (char*)data, width, height, 8, width * 4);
+ ret->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)data, width,
+ height, 8, width * 4);
if (!ret->image)
{
@@ -59,26 +58,23 @@ static VideoSurface* xfVideoCreateSurface(VideoClientContext* video, BYTE* data,
return &ret->base;
}
-
static BOOL xfVideoShowSurface(VideoClientContext* video, VideoSurface* surface)
{
xfVideoSurface* xfSurface = (xfVideoSurface*)surface;
xfContext* xfc = video->custom;
#ifdef WITH_XRENDER
- if (xfc->context.settings->SmartSizing
- || xfc->context.settings->MultiTouchGestures)
+ if (xfc->context.settings->SmartSizing || xfc->context.settings->MultiTouchGestures)
{
- XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image,
- 0, 0, surface->x, surface->y, surface->w, surface->h);
+ XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0, surface->x,
+ surface->y, surface->w, surface->h);
xf_draw_screen(xfc, surface->x, surface->y, surface->w, surface->h);
}
else
#endif
{
- XPutImage(xfc->display, xfc->drawable, xfc->gc, xfSurface->image,
- 0, 0,
- surface->x, surface->y, surface->w, surface->h);
+ XPutImage(xfc->display, xfc->drawable, xfc->gc, xfSurface->image, 0, 0, surface->x,
+ surface->y, surface->w, surface->h);
}
return TRUE;
@@ -105,7 +101,6 @@ void xf_video_control_init(xfContext* xfc, VideoClientContext* video)
video->deleteSurface = xfVideoDeleteSurface;
}
-
void xf_video_control_uninit(xfContext* xfc, VideoClientContext* video)
{
gdi_video_control_uninit(xfc->context.gdi, video);
diff --git a/client/X11/xf_video.h b/client/X11/xf_video.h
index 47af49c2c..83708f0df 100644
--- a/client/X11/xf_video.h
+++ b/client/X11/xf_video.h
@@ -30,5 +30,4 @@ void xf_video_control_uninit(xfContext* xfc, VideoClientContext* video);
xfVideoContext* xf_video_new(xfContext* xfc);
void xf_video_free(xfVideoContext* context);
-
#endif /* CLIENT_X11_XF_VIDEO_H_ */
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c
index 83c2553ff..b865eb7cc 100644
--- a/client/X11/xf_window.c
+++ b/client/X11/xf_window.c
@@ -60,7 +60,10 @@
#ifdef WITH_DEBUG_X11
#define DEBUG_X11(...) WLog_DBG(TAG, __VA_ARGS__)
#else
-#define DEBUG_X11(...) do { } while (0)
+#define DEBUG_X11(...) \
+ do \
+ { \
+ } while (0)
#endif
#include "FreeRDP_Icon_256px.h"
@@ -71,29 +74,29 @@
/* Extended Window Manager Hints: http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html */
/* bit definitions for MwmHints.flags */
-#define MWM_HINTS_FUNCTIONS (1L << 0)
-#define MWM_HINTS_DECORATIONS (1L << 1)
-#define MWM_HINTS_INPUT_MODE (1L << 2)
-#define MWM_HINTS_STATUS (1L << 3)
+#define MWM_HINTS_FUNCTIONS (1L << 0)
+#define MWM_HINTS_DECORATIONS (1L << 1)
+#define MWM_HINTS_INPUT_MODE (1L << 2)
+#define MWM_HINTS_STATUS (1L << 3)
/* bit definitions for MwmHints.functions */
-#define MWM_FUNC_ALL (1L << 0)
-#define MWM_FUNC_RESIZE (1L << 1)
-#define MWM_FUNC_MOVE (1L << 2)
-#define MWM_FUNC_MINIMIZE (1L << 3)
-#define MWM_FUNC_MAXIMIZE (1L << 4)
-#define MWM_FUNC_CLOSE (1L << 5)
+#define MWM_FUNC_ALL (1L << 0)
+#define MWM_FUNC_RESIZE (1L << 1)
+#define MWM_FUNC_MOVE (1L << 2)
+#define MWM_FUNC_MINIMIZE (1L << 3)
+#define MWM_FUNC_MAXIMIZE (1L << 4)
+#define MWM_FUNC_CLOSE (1L << 5)
/* bit definitions for MwmHints.decorations */
-#define MWM_DECOR_ALL (1L << 0)
-#define MWM_DECOR_BORDER (1L << 1)
-#define MWM_DECOR_RESIZEH (1L << 2)
-#define MWM_DECOR_TITLE (1L << 3)
-#define MWM_DECOR_MENU (1L << 4)
-#define MWM_DECOR_MINIMIZE (1L << 5)
-#define MWM_DECOR_MAXIMIZE (1L << 6)
+#define MWM_DECOR_ALL (1L << 0)
+#define MWM_DECOR_BORDER (1L << 1)
+#define MWM_DECOR_RESIZEH (1L << 2)
+#define MWM_DECOR_TITLE (1L << 3)
+#define MWM_DECOR_MENU (1L << 4)
+#define MWM_DECOR_MINIMIZE (1L << 5)
+#define MWM_DECOR_MAXIMIZE (1L << 6)
-#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
+#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
struct _PropMotifWmHints
{
@@ -111,15 +114,14 @@ static void xf_SetWindowTitleText(xfContext* xfc, Window window, const char* nam
XStoreName(xfc->display, window, name);
Atom wm_Name = xfc->_NET_WM_NAME;
Atom utf8Str = xfc->UTF8_STRING;
- XChangeProperty(xfc->display, window, wm_Name, utf8Str, 8,
- PropModeReplace, (const unsigned char*)name, (int)i);
+ XChangeProperty(xfc->display, window, wm_Name, utf8Str, 8, PropModeReplace,
+ (const unsigned char*)name, (int)i);
}
/**
* Post an event from the client to the X server
*/
-void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom,
- unsigned int numArgs, ...)
+void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom, unsigned int numArgs, ...)
{
XEvent xevent;
unsigned int i;
@@ -139,7 +141,7 @@ void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom,
xevent.xclient.data.l[i] = va_arg(argp, int);
}
- DEBUG_X11("Send ClientMessage Event: wnd=0x%04lX", (unsigned long) xevent.xclient.window);
+ DEBUG_X11("Send ClientMessage Event: wnd=0x%04lX", (unsigned long)xevent.xclient.window);
XSendEvent(xfc->display, RootWindowOfScreen(xfc->screen), False,
SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
XSync(xfc->display, False);
@@ -158,7 +160,8 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
int startX, startY;
UINT32 width = window->width;
UINT32 height = window->height;
- /* xfc->decorations is set by caller depending on settings and whether it is fullscreen or not */
+ /* xfc->decorations is set by caller depending on settings and whether it is fullscreen or not
+ */
window->decorations = xfc->decorations;
/* show/hide decorations (e.g. title bar) as guided by xfc->decorations */
xf_SetWindowDecorations(xfc, window->handle, window->decorations);
@@ -204,7 +207,8 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
}
/*
- It is safe to proceed with simply toogling _NET_WM_STATE_FULLSCREEN window state on the following conditions:
+ It is safe to proceed with simply toogling _NET_WM_STATE_FULLSCREEN window state on the
+ following conditions:
- The window manager supports multiple monitor full screen
- The user requested to use a single monitor to render the remote desktop
*/
@@ -233,11 +237,8 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
if (settings->MonitorCount > 1)
{
xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_FULLSCREEN_MONITORS, 5,
- xfc->fullscreenMonitors.top,
- xfc->fullscreenMonitors.bottom,
- xfc->fullscreenMonitors.left,
- xfc->fullscreenMonitors.right,
- 1);
+ xfc->fullscreenMonitors.top, xfc->fullscreenMonitors.bottom,
+ xfc->fullscreenMonitors.left, xfc->fullscreenMonitors.right, 1);
}
}
else
@@ -248,8 +249,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
if (xfc->fullscreenMonitors.top)
{
- xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_ADD,
+ xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD,
xfc->fullscreenMonitors.top, 0, 0);
}
else
@@ -270,16 +270,17 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
unsigned long bytes;
BYTE* prop;
- if (xf_GetWindowProperty(xfc, window->handle, xfc->_NET_WM_STATE, 255, &nitems, &bytes, &prop))
+ if (xf_GetWindowProperty(xfc, window->handle, xfc->_NET_WM_STATE, 255, &nitems,
+ &bytes, &prop))
{
state = 0;
while (nitems-- > 0)
{
- if (((Atom*) prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_VERT)
+ if (((Atom*)prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_VERT)
state |= 0x01;
- if (((Atom*) prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_HORZ)
+ if (((Atom*)prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_HORZ)
state |= 0x02;
}
@@ -312,24 +313,21 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
if (xfc->fullscreenMonitors.top)
{
- xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_REMOVE,
+ xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_REMOVE,
xfc->fullscreenMonitors.top, 0, 0);
}
/* restore maximized state, if the window was maximized before setting fullscreen */
if (xfc->savedMaximizedState & 0x01)
{
- xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_ADD, xfc->_NET_WM_STATE_MAXIMIZED_VERT,
- 0, 0);
+ xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD,
+ xfc->_NET_WM_STATE_MAXIMIZED_VERT, 0, 0);
}
if (xfc->savedMaximizedState & 0x02)
{
- xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_ADD, xfc->_NET_WM_STATE_MAXIMIZED_HORZ,
- 0, 0);
+ xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD,
+ xfc->_NET_WM_STATE_MAXIMIZED_HORZ, 0, 0);
}
xfc->savedMaximizedState = 0;
@@ -339,8 +337,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
/* http://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html */
-BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property,
- int length,
+BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property, int length,
unsigned long* nitems, unsigned long* bytes, BYTE** prop)
{
int status;
@@ -350,8 +347,7 @@ BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property,
if (property == None)
return FALSE;
- status = XGetWindowProperty(xfc->display, window,
- property, 0, length, False, AnyPropertyType,
+ status = XGetWindowProperty(xfc->display, window, property, 0, length, False, AnyPropertyType,
&actual_type, &actual_format, nitems, bytes, prop);
if (status != Success)
@@ -359,7 +355,7 @@ BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property,
if (actual_type == None)
{
- WLog_INFO(TAG, "Property %lu does not exist", (unsigned long) property);
+ WLog_INFO(TAG, "Property %lu does not exist", (unsigned long)property);
return FALSE;
}
@@ -372,13 +368,13 @@ BOOL xf_GetCurrentDesktop(xfContext* xfc)
unsigned long nitems;
unsigned long bytes;
unsigned char* prop;
- status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display),
- xfc->_NET_CURRENT_DESKTOP, 1, &nitems, &bytes, &prop);
+ status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display), xfc->_NET_CURRENT_DESKTOP,
+ 1, &nitems, &bytes, &prop);
if (!status)
return FALSE;
- xfc->current_desktop = (int) * prop;
+ xfc->current_desktop = (int)*prop;
free(prop);
return TRUE;
}
@@ -395,8 +391,8 @@ BOOL xf_GetWorkArea(xfContext* xfc)
if (!status)
return FALSE;
- status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display),
- xfc->_NET_WORKAREA, 32 * 4, &nitems, &bytes, &prop);
+ status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display), xfc->_NET_WORKAREA, 32 * 4,
+ &nitems, &bytes, &prop);
if (!status)
return FALSE;
@@ -407,7 +403,7 @@ BOOL xf_GetWorkArea(xfContext* xfc)
return FALSE;
}
- plong = (long*) prop;
+ plong = (long*)prop;
xfc->workArea.x = plong[xfc->current_desktop * 4 + 0];
xfc->workArea.y = plong[xfc->current_desktop * 4 + 1];
xfc->workArea.width = plong[xfc->current_desktop * 4 + 2];
@@ -420,13 +416,12 @@ void xf_SetWindowDecorations(xfContext* xfc, Window window, BOOL show)
{
PropMotifWmHints hints;
hints.decorations = (show) ? MWM_DECOR_ALL : 0;
- hints.functions = MWM_FUNC_ALL ;
+ hints.functions = MWM_FUNC_ALL;
hints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
hints.inputMode = 0;
hints.status = 0;
- XChangeProperty(xfc->display, window, xfc->_MOTIF_WM_HINTS,
- xfc->_MOTIF_WM_HINTS, 32,
- PropModeReplace, (BYTE*) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
+ XChangeProperty(xfc->display, window, xfc->_MOTIF_WM_HINTS, xfc->_MOTIF_WM_HINTS, 32,
+ PropModeReplace, (BYTE*)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
}
void xf_SetWindowUnlisted(xfContext* xfc, Window window)
@@ -434,8 +429,8 @@ void xf_SetWindowUnlisted(xfContext* xfc, Window window)
Atom window_state[2];
window_state[0] = xfc->_NET_WM_STATE_SKIP_PAGER;
window_state[1] = xfc->_NET_WM_STATE_SKIP_TASKBAR;
- XChangeProperty(xfc->display, window, xfc->_NET_WM_STATE,
- XA_ATOM, 32, PropModeReplace, (BYTE*) &window_state, 2);
+ XChangeProperty(xfc->display, window, xfc->_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
+ (BYTE*)&window_state, 2);
}
static void xf_SetWindowPID(xfContext* xfc, Window window, pid_t pid)
@@ -446,22 +441,20 @@ static void xf_SetWindowPID(xfContext* xfc, Window window, pid_t pid)
pid = getpid();
am_wm_pid = xfc->_NET_WM_PID;
- XChangeProperty(xfc->display, window, am_wm_pid, XA_CARDINAL,
- 32, PropModeReplace, (BYTE*) &pid, 1);
+ XChangeProperty(xfc->display, window, am_wm_pid, XA_CARDINAL, 32, PropModeReplace, (BYTE*)&pid,
+ 1);
}
static const char* get_shm_id(void)
{
static char shm_id[64];
- sprintf_s(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X",
- GetCurrentProcessId());
+ sprintf_s(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X", GetCurrentProcessId());
return shm_id;
}
Window xf_CreateDummyWindow(xfContext* xfc)
{
- return XCreateSimpleWindow(xfc->display, DefaultRootWindow(xfc->display),
- 0, 0, 1, 1, 0, 0, 0);
+ return XCreateSimpleWindow(xfc->display, DefaultRootWindow(xfc->display), 0, 0, 1, 1, 0, 0, 0);
}
void xf_DestroyDummyWindow(xfContext* xfc, Window window)
@@ -470,8 +463,7 @@ void xf_DestroyDummyWindow(xfContext* xfc, Window window)
XDestroyWindow(xfc->display, window);
}
-xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
- int height)
+xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int height)
{
XEvent xevent;
int input_mask;
@@ -479,25 +471,25 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
Window parentWindow;
XClassHint* classHints;
rdpSettings* settings;
- window = (xfWindow*) calloc(1, sizeof(xfWindow));
+ window = (xfWindow*)calloc(1, sizeof(xfWindow));
if (!window)
return NULL;
settings = xfc->context.settings;
- parentWindow = (Window) xfc->context.settings->ParentWindowId;
+ parentWindow = (Window)xfc->context.settings->ParentWindowId;
window->width = width;
window->height = height;
window->decorations = xfc->decorations;
window->is_mapped = FALSE;
window->is_transient = FALSE;
- window->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen),
- xfc->workArea.x, xfc->workArea.y, xfc->workArea.width, xfc->workArea.height,
- 0, xfc->depth, InputOutput, xfc->visual,
+ window->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), xfc->workArea.x,
+ xfc->workArea.y, xfc->workArea.width, xfc->workArea.height, 0,
+ xfc->depth, InputOutput, xfc->visual,
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
- CWBorderPixel | CWWinGravity | CWBitGravity, &xfc->attribs);
- window->shmid = shm_open(get_shm_id(), (O_CREAT | O_RDWR),
- (S_IREAD | S_IWRITE));
+ CWBorderPixel | CWWinGravity | CWBitGravity,
+ &xfc->attribs);
+ window->shmid = shm_open(get_shm_id(), (O_CREAT | O_RDWR), (S_IREAD | S_IWRITE));
if (window->shmid < 0)
{
@@ -507,12 +499,12 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
{
void* mem;
ftruncate(window->shmid, sizeof(window->handle));
- mem = mmap(0, sizeof(window->handle), PROT_READ | PROT_WRITE, MAP_SHARED,
- window->shmid, 0);
+ mem = mmap(0, sizeof(window->handle), PROT_READ | PROT_WRITE, MAP_SHARED, window->shmid, 0);
if (mem == MAP_FAILED)
{
- DEBUG_X11("xf_CreateDesktopWindow: failed to assign pointer to the memory address - shmat()\n");
+ DEBUG_X11("xf_CreateDesktopWindow: failed to assign pointer to the memory address - "
+ "shmat()\n");
}
else
{
@@ -539,17 +531,15 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
xf_ResizeDesktopWindow(xfc, window, width, height);
xf_SetWindowDecorations(xfc, window->handle, window->decorations);
xf_SetWindowPID(xfc, window->handle, 0);
- input_mask =
- KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
- VisibilityChangeMask | FocusChangeMask | StructureNotifyMask |
- PointerMotionMask | ExposureMask | PropertyChangeMask;
+ input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
+ VisibilityChangeMask | FocusChangeMask | StructureNotifyMask | PointerMotionMask |
+ ExposureMask | PropertyChangeMask;
if (xfc->grab_keyboard)
input_mask |= EnterWindowMask | LeaveWindowMask;
- XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_ICON, XA_CARDINAL,
- 32,
- PropModeReplace, (BYTE*) xf_icon_prop, ARRAYSIZE(xf_icon_prop));
+ XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_ICON, XA_CARDINAL, 32,
+ PropModeReplace, (BYTE*)xf_icon_prop, ARRAYSIZE(xf_icon_prop));
if (parentWindow)
XReparentWindow(xfc->display, window->handle, parentWindow, 0, 0);
@@ -567,8 +557,7 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
do
{
XMaskEvent(xfc->display, VisibilityChangeMask, &xevent);
- }
- while (xevent.type != VisibilityNotify);
+ } while (xevent.type != VisibilityNotify);
/*
* The XCreateWindow call will start the window in the upper-left corner of our current
@@ -581,16 +570,14 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
}
else if (settings->DesktopPosX != UINT32_MAX && settings->DesktopPosY != UINT32_MAX)
{
- XMoveWindow(xfc->display, window->handle, settings->DesktopPosX,
- settings->DesktopPosY);
+ XMoveWindow(xfc->display, window->handle, settings->DesktopPosX, settings->DesktopPosY);
}
window->floatbar = xf_floatbar_new(xfc, window->handle, name, settings->Floatbar);
return window;
}
-void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width,
- int height)
+void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int height)
{
XSizeHints* size_hints;
rdpSettings* settings = NULL;
@@ -652,13 +639,12 @@ void xf_DestroyDesktopWindow(xfContext* xfc, xfWindow* window)
close(window->shmid);
shm_unlink(get_shm_id());
- window->xfwin = (Window*) - 1;
+ window->xfwin = (Window*)-1;
window->shmid = -1;
free(window);
}
-void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style,
- UINT32 ex_style)
+void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style, UINT32 ex_style)
{
Atom window_type;
BOOL redirect = FALSE;
@@ -671,8 +657,8 @@ void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style,
window_type = xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
}
/*
- * TOPMOST window that is not a tool window is treated like a regular window (i.e. task manager).
- * Want to do this here, since the window may have type WS_POPUP
+ * TOPMOST window that is not a tool window is treated like a regular window (i.e. task
+ * manager). Want to do this here, since the window may have type WS_POPUP
*/
else if (ex_style & WS_EX_TOPMOST)
{
@@ -702,12 +688,11 @@ void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style,
*/
XSetWindowAttributes attrs;
attrs.override_redirect = redirect ? True : False;
- XChangeWindowAttributes(xfc->display, appWindow->handle, CWOverrideRedirect,
- &attrs);
+ XChangeWindowAttributes(xfc->display, appWindow->handle, CWOverrideRedirect, &attrs);
}
- XChangeProperty(xfc->display, appWindow->handle, xfc->_NET_WM_WINDOW_TYPE,
- XA_ATOM, 32, PropModeReplace, (BYTE*) &window_type, 1);
+ XChangeProperty(xfc->display, appWindow->handle, xfc->_NET_WM_WINDOW_TYPE, XA_ATOM, 32,
+ PropModeReplace, (BYTE*)&window_type, 1);
}
void xf_SetWindowText(xfContext* xfc, xfAppWindow* appWindow, const char* name)
@@ -715,8 +700,7 @@ void xf_SetWindowText(xfContext* xfc, xfAppWindow* appWindow, const char* name)
xf_SetWindowTitleText(xfc, appWindow->handle, name);
}
-static void xf_FixWindowCoordinates(xfContext* xfc, int* x, int* y, int* width,
- int* height)
+static void xf_FixWindowCoordinates(xfContext* xfc, int* x, int* y, int* width, int* height)
{
int vscreen_width;
int vscreen_height;
@@ -768,8 +752,7 @@ int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
XClearWindow(xfc->display, appWindow->handle);
XMapWindow(xfc->display, appWindow->handle);
/* Move doesn't seem to work until window is mapped. */
- xf_MoveWindow(xfc, appWindow, appWindow->x, appWindow->y, appWindow->width,
- appWindow->height);
+ xf_MoveWindow(xfc, appWindow, appWindow->x, appWindow->y, appWindow->width, appWindow->height);
xf_SetWindowText(xfc, appWindow, appWindow->title);
return 1;
}
@@ -789,16 +772,15 @@ int xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
appWindow->is_transient = FALSE;
appWindow->rail_state = 0;
appWindow->rail_ignore_configure = FALSE;
- appWindow->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen),
- appWindow->x, appWindow->y, appWindow->width, appWindow->height,
- 0, xfc->depth, InputOutput, xfc->visual, 0, &xfc->attribs);
+ appWindow->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), appWindow->x,
+ appWindow->y, appWindow->width, appWindow->height, 0,
+ xfc->depth, InputOutput, xfc->visual, 0, &xfc->attribs);
if (!appWindow->handle)
return -1;
ZeroMemory(&gcv, sizeof(gcv));
- appWindow->gc = XCreateGC(xfc->display, appWindow->handle, GCGraphicsExposures,
- &gcv);
+ appWindow->gc = XCreateGC(xfc->display, appWindow->handle, GCGraphicsExposures, &gcv);
class_hints = XAllocClassHint();
if (class_hints)
@@ -812,7 +794,7 @@ int xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
else
{
class = malloc(sizeof("RAIL:00000000"));
- sprintf_s(class, sizeof("RAIL:00000000"), "RAIL:%08"PRIX64"", appWindow->windowId);
+ sprintf_s(class, sizeof("RAIL:00000000"), "RAIL:%08" PRIX64 "", appWindow->windowId);
class_hints->res_class = class;
}
@@ -829,22 +811,20 @@ int xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
XSetWMHints(xfc->display, appWindow->handle, InputModeHint);
XFree(InputModeHint);
XSetWMProtocols(xfc->display, appWindow->handle, &(xfc->WM_DELETE_WINDOW), 1);
- input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
- PointerMotionMask | Button1MotionMask | Button2MotionMask |
- Button3MotionMask | Button4MotionMask | Button5MotionMask |
- ButtonMotionMask | KeymapStateMask | ExposureMask |
- VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask |
- SubstructureRedirectMask | FocusChangeMask | PropertyChangeMask |
- ColormapChangeMask | OwnerGrabButtonMask;
+ input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
+ EnterWindowMask | LeaveWindowMask | PointerMotionMask | Button1MotionMask |
+ Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
+ ButtonMotionMask | KeymapStateMask | ExposureMask | VisibilityChangeMask |
+ StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask |
+ FocusChangeMask | PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask;
XSelectInput(xfc->display, appWindow->handle, input_mask);
return 1;
}
-void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow,
- int maxWidth, int maxHeight, int maxPosX, int maxPosY,
- int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight)
+void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, int maxWidth, int maxHeight,
+ int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight,
+ int maxTrackWidth, int maxTrackHeight)
{
XSizeHints* size_hints;
size_hints = XAllocSizeHints();
@@ -852,9 +832,9 @@ void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow,
if (size_hints)
{
size_hints->flags = PMinSize | PMaxSize | PResizeInc;
- size_hints->min_width = minTrackWidth;
+ size_hints->min_width = minTrackWidth;
size_hints->min_height = minTrackHeight;
- size_hints->max_width = maxTrackWidth;
+ size_hints->max_width = maxTrackWidth;
size_hints->max_height = maxTrackHeight;
/* to speedup window drawing we need to select optimal value for sizing step. */
size_hints->width_inc = size_hints->height_inc = 1;
@@ -863,29 +843,29 @@ void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow,
}
}
-void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow,
- int direction, int x, int y)
+void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction, int x, int y)
{
if (appWindow->local_move.state != LMS_NOT_ACTIVE)
return;
/*
- * Save original mouse location relative to root. This will be needed
- * to end local move to RDP server and/or X server
- */
+ * Save original mouse location relative to root. This will be needed
+ * to end local move to RDP server and/or X server
+ */
appWindow->local_move.root_x = x;
appWindow->local_move.root_y = y;
appWindow->local_move.state = LMS_STARTING;
appWindow->local_move.direction = direction;
XUngrabPointer(xfc->display, CurrentTime);
- xf_SendClientEvent(xfc, appWindow->handle,
- xfc->_NET_WM_MOVERESIZE, /* request X window manager to initiate a local move */
- 5, /* 5 arguments to follow */
- x, /* x relative to root window */
- y, /* y relative to root window */
- direction, /* extended ICCM direction flag */
- 1, /* simulated mouse button 1 */
- 1); /* 1 == application request per extended ICCM */
+ xf_SendClientEvent(
+ xfc, appWindow->handle,
+ xfc->_NET_WM_MOVERESIZE, /* request X window manager to initiate a local move */
+ 5, /* 5 arguments to follow */
+ x, /* x relative to root window */
+ y, /* y relative to root window */
+ direction, /* extended ICCM direction flag */
+ 1, /* simulated mouse button 1 */
+ 1); /* 1 == application request per extended ICCM */
}
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow)
@@ -901,21 +881,21 @@ void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow)
* RDP server for local moves. We must cancel the X window manager move.
* Per ICCM, the X client can ask to cancel an active move.
*/
- xf_SendClientEvent(xfc, appWindow->handle,
- xfc->_NET_WM_MOVERESIZE, /* request X window manager to abort a local move */
- 5, /* 5 arguments to follow */
- appWindow->local_move.root_x, /* x relative to root window */
- appWindow->local_move.root_y, /* y relative to root window */
- _NET_WM_MOVERESIZE_CANCEL, /* extended ICCM direction flag */
- 1, /* simulated mouse button 1 */
- 1); /* 1 == application request per extended ICCM */
+ xf_SendClientEvent(
+ xfc, appWindow->handle,
+ xfc->_NET_WM_MOVERESIZE, /* request X window manager to abort a local move */
+ 5, /* 5 arguments to follow */
+ appWindow->local_move.root_x, /* x relative to root window */
+ appWindow->local_move.root_y, /* y relative to root window */
+ _NET_WM_MOVERESIZE_CANCEL, /* extended ICCM direction flag */
+ 1, /* simulated mouse button 1 */
+ 1); /* 1 == application request per extended ICCM */
}
appWindow->local_move.state = LMS_NOT_ACTIVE;
}
-void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
- int width, int height)
+void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow, int x, int y, int width, int height)
{
BOOL resize = FALSE;
@@ -925,8 +905,7 @@ void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
if ((appWindow->width != width) || (appWindow->height != height))
resize = TRUE;
- if (appWindow->local_move.state == LMS_STARTING ||
- appWindow->local_move.state == LMS_ACTIVE)
+ if (appWindow->local_move.state == LMS_STARTING || appWindow->local_move.state == LMS_ACTIVE)
return;
appWindow->x = x;
@@ -956,16 +935,17 @@ void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state)
case WINDOW_SHOW_MAXIMIZED:
/* Set the window as maximized */
- xf_SendClientEvent(xfc, appWindow->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_ADD,
- xfc->_NET_WM_STATE_MAXIMIZED_VERT,
- xfc->_NET_WM_STATE_MAXIMIZED_HORZ, 0);
+ xf_SendClientEvent(xfc, appWindow->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD,
+ xfc->_NET_WM_STATE_MAXIMIZED_VERT, xfc->_NET_WM_STATE_MAXIMIZED_HORZ,
+ 0);
/*
- * This is a workaround for the case where the window is maximized locally before the rail server is told to maximize
- * the window, this appears to be a race condition where the local window with incomplete data and once the window is
- * actually maximized on the server - an update of the new areas may not happen. So, we simply to do a full update of
- * the entire window once the rail server notifies us that the window is now maximized.
+ * This is a workaround for the case where the window is maximized locally before the
+ * rail server is told to maximize the window, this appears to be a race condition where
+ * the local window with incomplete data and once the window is actually maximized on
+ * the server
+ * - an update of the new areas may not happen. So, we simply to do a full update of the
+ * entire window once the rail server notifies us that the window is now maximized.
*/
if (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED)
{
@@ -977,16 +957,15 @@ void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state)
case WINDOW_SHOW:
/* Ensure the window is not maximized */
- xf_SendClientEvent(xfc, appWindow->handle, xfc->_NET_WM_STATE, 4,
- _NET_WM_STATE_REMOVE,
- xfc->_NET_WM_STATE_MAXIMIZED_VERT,
- xfc->_NET_WM_STATE_MAXIMIZED_HORZ, 0);
+ xf_SendClientEvent(xfc, appWindow->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_REMOVE,
+ xfc->_NET_WM_STATE_MAXIMIZED_VERT, xfc->_NET_WM_STATE_MAXIMIZED_HORZ,
+ 0);
/*
* Ignore configure requests until both the Maximized properties have been processed
- * to prevent condition where WM overrides size of request due to one or both of these properties
- * still being set - which causes a position adjustment to be sent back to the server
- * thus causing the window to not return to its original size
+ * to prevent condition where WM overrides size of request due to one or both of these
+ * properties still being set - which causes a position adjustment to be sent back to
+ * the server thus causing the window to not return to its original size
*/
if (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED)
appWindow->rail_ignore_configure = TRUE;
@@ -1003,8 +982,7 @@ void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state)
XFlush(xfc->display);
}
-void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow,
- RECTANGLE_16* rects, int nrects)
+void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rects, int nrects)
{
int i;
XRectangle* xrects;
@@ -1013,7 +991,7 @@ void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow,
return;
#ifdef WITH_XEXT
- xrects = (XRectangle*) calloc(nrects, sizeof(XRectangle));
+ xrects = (XRectangle*)calloc(nrects, sizeof(XRectangle));
for (i = 0; i < nrects; i++)
{
@@ -1023,14 +1001,14 @@ void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow,
xrects[i].height = rects[i].bottom - rects[i].top;
}
- XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding, 0, 0,
- xrects, nrects, ShapeSet, 0);
+ XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding, 0, 0, xrects, nrects,
+ ShapeSet, 0);
free(xrects);
#endif
}
-void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow,
- UINT32 rectsOffsetX, UINT32 rectsOffsetY, RECTANGLE_16* rects, int nrects)
+void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32 rectsOffsetX,
+ UINT32 rectsOffsetY, RECTANGLE_16* rects, int nrects)
{
int i;
XRectangle* xrects;
@@ -1039,7 +1017,7 @@ void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow,
return;
#ifdef WITH_XEXT
- xrects = (XRectangle*) calloc(nrects, sizeof(XRectangle));
+ xrects = (XRectangle*)calloc(nrects, sizeof(XRectangle));
for (i = 0; i < nrects; i++)
{
@@ -1049,14 +1027,14 @@ void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow,
xrects[i].height = rects[i].bottom - rects[i].top;
}
- XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding,
- rectsOffsetX, rectsOffsetY, xrects, nrects, ShapeSet, 0);
+ XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding, rectsOffsetX,
+ rectsOffsetY, xrects, nrects, ShapeSet, 0);
free(xrects);
#endif
}
-void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
- int width, int height)
+void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, int width,
+ int height)
{
int ax, ay;
@@ -1079,12 +1057,12 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
if (xfc->context.settings->SoftwareGdi)
{
- XPutImage(xfc->display, xfc->primary, appWindow->gc, xfc->image,
- ax, ay, ax, ay, width, height);
+ XPutImage(xfc->display, xfc->primary, appWindow->gc, xfc->image, ax, ay, ax, ay, width,
+ height);
}
- XCopyArea(xfc->display, xfc->primary, appWindow->handle, appWindow->gc,
- ax, ay, width, height, x, y);
+ XCopyArea(xfc->display, xfc->primary, appWindow->handle, appWindow->gc, ax, ay, width, height,
+ x, y);
XFlush(xfc->display);
xf_unlock_x11(xfc, TRUE);
}
@@ -1110,7 +1088,7 @@ void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow)
close(appWindow->shmid);
shm_unlink(get_shm_id());
- appWindow->xfwin = (Window*) - 1;
+ appWindow->xfwin = (Window*)-1;
appWindow->shmid = -1;
free(appWindow->title);
free(appWindow->windowRects);
diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h
index 6e4b90966..3adaa3c7f 100644
--- a/client/X11/xf_window.h
+++ b/client/X11/xf_window.h
@@ -34,21 +34,21 @@ typedef struct xf_window xfWindow;
#include "xfreerdp.h"
// Extended ICCM flags http://standards.freedesktop.org/wm-spec/wm-spec-latest.html
-#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
-#define _NET_WM_MOVERESIZE_SIZE_TOP 1
-#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
-#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
-#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
-#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
-#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
-#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
-#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
-#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
-#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
-#define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */
+#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
+#define _NET_WM_MOVERESIZE_SIZE_TOP 1
+#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
+#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
+#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
+#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
+#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
+#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
+#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
+#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
+#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
+#define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
-#define _NET_WM_STATE_ADD 1 /* add/set property */
+#define _NET_WM_STATE_ADD 1 /* add/set property */
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
enum xf_localmove_state
@@ -166,7 +166,7 @@ int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow);
void xf_SetWindowText(xfContext* xfc, xfAppWindow* appWindow, const char* name);
void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow, int x, int y, int width, int height);
void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state);
-//void xf_SetWindowIcon(xfContext* xfc, xfAppWindow* appWindow, rdpIcon* icon);
+// void xf_SetWindowIcon(xfContext* xfc, xfAppWindow* appWindow, rdpIcon* icon);
void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rects, int nrects);
void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32 rectsOffsetX,
UINT32 rectsOffsetY, RECTANGLE_16* rects, int nrects);
@@ -174,9 +174,9 @@ void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style, UIN
void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, int width,
int height);
void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow);
-void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow,
- int maxWidth, int maxHeight, int maxPosX, int maxPosY,
- int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight);
+void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, int maxWidth, int maxHeight,
+ int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight,
+ int maxTrackWidth, int maxTrackHeight);
void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction, int x, int y);
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow);
xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd);
diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h
index fc3005cd3..31bb8dc4c 100644
--- a/client/X11/xfreerdp.h
+++ b/client/X11/xfreerdp.h
@@ -295,4 +295,3 @@ void xf_draw_screen(xfContext* xfc, int x, int y, int w, int h);
FREERDP_API DWORD xf_exit_code_from_disconnect_reason(DWORD reason);
#endif /* FREERDP_CLIENT_X11_FREERDP_H */
-
diff --git a/client/common/client.c b/client/common/client.c
index 47355c34d..ed96c8138 100644
--- a/client/common/client.c
+++ b/client/common/client.c
@@ -68,8 +68,7 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
instance->ContextSize = pEntryPoints->ContextSize;
instance->ContextNew = freerdp_client_common_new;
instance->ContextFree = freerdp_client_common_free;
- instance->pClientEntryPoints = (RDP_CLIENT_ENTRY_POINTS*) malloc(
- pEntryPoints->Size);
+ instance->pClientEntryPoints = (RDP_CLIENT_ENTRY_POINTS*)malloc(pEntryPoints->Size);
if (!instance->pClientEntryPoints)
goto out_fail;
@@ -83,8 +82,8 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
context->instance = instance;
context->settings = instance->settings;
- if (freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry,
- 0) != CHANNEL_RC_OK)
+ if (freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0) !=
+ CHANNEL_RC_OK)
goto out_fail2;
return context;
@@ -152,7 +151,7 @@ HANDLE freerdp_client_get_thread(rdpContext* context)
if (!context)
return NULL;
- return ((rdpClientContext*) context)->thread;
+ return ((rdpClientContext*)context)->thread;
}
static BOOL freerdp_client_settings_post_process(rdpSettings* settings)
@@ -212,9 +211,8 @@ out_error:
return FALSE;
}
-
-int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
- char** argv, BOOL allowUnknown)
+int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv,
+ BOOL allowUnknown)
{
int status;
@@ -224,8 +222,8 @@ int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
if (!argv)
return -1;
- status = freerdp_client_settings_parse_command_line_arguments(settings, argc,
- argv, allowUnknown);
+ status =
+ freerdp_client_settings_parse_command_line_arguments(settings, argc, argv, allowUnknown);
if (status < 0)
return status;
@@ -238,8 +236,7 @@ int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
return status;
}
-int freerdp_client_settings_parse_connection_file(rdpSettings* settings,
- const char* filename)
+int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename)
{
rdpFile* file;
int ret = -1;
@@ -260,8 +257,8 @@ out:
return ret;
}
-int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings,
- const BYTE* buffer, size_t size)
+int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer,
+ size_t size)
{
rdpFile* file;
int status = -1;
@@ -270,8 +267,8 @@ int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings,
if (!file)
return -1;
- if (freerdp_client_parse_rdp_file_buffer(file, buffer, size)
- && freerdp_client_populate_settings_from_rdp_file(file, settings))
+ if (freerdp_client_parse_rdp_file_buffer(file, buffer, size) &&
+ freerdp_client_populate_settings_from_rdp_file(file, settings))
{
status = 0;
}
@@ -280,8 +277,8 @@ int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings,
return status;
}
-int freerdp_client_settings_write_connection_file(const rdpSettings* settings,
- const char* filename, BOOL unicode)
+int freerdp_client_settings_write_connection_file(const rdpSettings* settings, const char* filename,
+ BOOL unicode)
{
rdpFile* file;
int ret = -1;
@@ -302,8 +299,7 @@ out:
return ret;
}
-int freerdp_client_settings_parse_assistance_file(rdpSettings* settings,
- int argc, char* argv[])
+int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, int argc, char* argv[])
{
int status, x;
int ret = -1;
@@ -349,29 +345,19 @@ out:
* @see rdp_server_accept_nego() and rdp_check_fds()
* @param instance - pointer to the rdp_freerdp structure that contains the connection settings
* @param username - unused
- * @param password - on return: pointer to a character string that will be filled by the password entered by the user.
- * Note that this character string will be allocated inside the function, and needs to be deallocated by the caller
- * using free(), even in case this function fails.
+ * @param password - on return: pointer to a character string that will be filled by the password
+ * entered by the user. Note that this character string will be allocated inside the function, and
+ * needs to be deallocated by the caller using free(), even in case this function fails.
* @param domain - unused
- * @return TRUE if a password was successfully entered. See freerdp_passphrase_read() for more details.
+ * @return TRUE if a password was successfully entered. See freerdp_passphrase_read() for more
+ * details.
*/
-static BOOL client_cli_authenticate_raw(freerdp* instance, BOOL gateway,
- char** username,
+static BOOL client_cli_authenticate_raw(freerdp* instance, BOOL gateway, char** username,
char** password, char** domain)
{
static const size_t password_size = 512;
- const char* auth[] =
- {
- "Username: ",
- "Domain: ",
- "Password: "
- };
- const char* gw[] =
- {
- "GatewayUsername: ",
- "GatewayDomain: ",
- "GatewayPassword: "
- };
+ const char* auth[] = { "Username: ", "Domain: ", "Password: " };
+ const char* gw[] = { "GatewayUsername: ", "GatewayDomain: ", "GatewayPassword: " };
const char** prompt = (gateway) ? gw : auth;
if (!username || !password || !domain)
@@ -436,8 +422,7 @@ fail:
return FALSE;
}
-BOOL client_cli_authenticate(freerdp* instance, char** username,
- char** password, char** domain)
+BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
if (instance->settings->SmartcardLogon)
{
@@ -448,8 +433,7 @@ BOOL client_cli_authenticate(freerdp* instance, char** username,
return client_cli_authenticate_raw(instance, FALSE, username, password, domain);
}
-BOOL client_cli_gw_authenticate(freerdp* instance, char** username,
- char** password, char** domain)
+BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
return client_cli_authenticate_raw(instance, TRUE, username, password, domain);
}
@@ -515,9 +499,8 @@ static DWORD client_cli_accept_certificate(rdpSettings* settings)
* @param host_mismatch Indicates the certificate host does not match.
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
*/
-DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint, BOOL host_mismatch)
+DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name, const char* subject,
+ const char* issuer, const char* fingerprint, BOOL host_mismatch)
{
WINPR_UNUSED(common_name);
WINPR_UNUSED(host_mismatch);
@@ -549,9 +532,8 @@ DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name,
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
*/
DWORD client_cli_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port,
- const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint, DWORD flags)
+ const char* common_name, const char* subject,
+ const char* issuer, const char* fingerprint, DWORD flags)
{
const char* type = "RDP-Server";
@@ -561,7 +543,7 @@ DWORD client_cli_verify_certificate_ex(freerdp* instance, const char* host, UINT
if (flags & VERIFY_CERT_FLAG_REDIRECT)
type = "RDP-Redirect";
- printf("Certificate details for %s:%"PRIu16" (%s):\n", host, port, type);
+ printf("Certificate details for %s:%" PRIu16 " (%s):\n", host, port, type);
printf("\tCommon Name: %s\n", common_name);
printf("\tSubject: %s\n", subject);
printf("\tIssuer: %s\n", issuer);
@@ -587,16 +569,15 @@ DWORD client_cli_verify_certificate_ex(freerdp* instance, const char* host, UINT
* @param old_fingerprint
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
*/
-DWORD client_cli_verify_changed_certificate(freerdp* instance,
- const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint,
- const char* old_subject, const char* old_issuer,
- const char* old_fingerprint)
+DWORD client_cli_verify_changed_certificate(freerdp* instance, const char* common_name,
+ const char* subject, const char* issuer,
+ const char* fingerprint, const char* old_subject,
+ const char* old_issuer, const char* old_fingerprint)
{
WINPR_UNUSED(common_name);
- printf("WARNING: This callback is deprecated, migrate to client_cli_verify_changed_certificate_ex\n");
+ printf("WARNING: This callback is deprecated, migrate to "
+ "client_cli_verify_changed_certificate_ex\n");
printf("!!! Certificate has changed !!!\n");
printf("\n");
printf("New Certificate details:\n");
@@ -609,7 +590,8 @@ DWORD client_cli_verify_changed_certificate(freerdp* instance,
printf("\tIssuer: %s\n", old_issuer);
printf("\tThumbprint: %s\n", old_fingerprint);
printf("\n");
- printf("The above X.509 certificate does not match the certificate used for previous connections.\n"
+ printf("The above X.509 certificate does not match the certificate used for previous "
+ "connections.\n"
"This may indicate that the certificate has been tampered with.\n"
"Please contact the administrator of the RDP server and clarify.\n");
return client_cli_accept_certificate(instance->settings);
@@ -619,7 +601,8 @@ DWORD client_cli_verify_changed_certificate(freerdp* instance,
* when a stored certificate does not match the remote counterpart.
* This function will actually be called by tls_verify_certificate().
* @see rdp_client_connect() and tls_connect()
- * @param instance pointer to the rdp_freerdp structure that contains the connection settings
+ * @param instance pointer to the rdp_freerdp structure that contains the connection
+ * settings
* @param host The host currently connecting to
* @param port The port currently connecting to
* @param common_name The common name of the certificate, should match host or an alias of it
@@ -633,13 +616,11 @@ DWORD client_cli_verify_changed_certificate(freerdp* instance,
*
* @return 1 if the certificate is trusted, 2 if temporary trusted, 0 otherwise.
*/
-DWORD client_cli_verify_changed_certificate_ex(freerdp* instance,
- const char* host, UINT16 port,
- const char* common_name,
- const char* subject, const char* issuer,
- const char* fingerprint,
- const char* old_subject, const char* old_issuer,
- const char* old_fingerprint, DWORD flags)
+DWORD client_cli_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port,
+ const char* common_name, const char* subject,
+ const char* issuer, const char* fingerprint,
+ const char* old_subject, const char* old_issuer,
+ const char* old_fingerprint, DWORD flags)
{
const char* type = "RDP-Server";
@@ -649,7 +630,7 @@ DWORD client_cli_verify_changed_certificate_ex(freerdp* instance,
if (flags & VERIFY_CERT_FLAG_REDIRECT)
type = "RDP-Redirect";
- printf("!!!Certificate for %s:%"PRIu16" (%s) has changed!!!\n", host, port, type);
+ printf("!!!Certificate for %s:%" PRIu16 " (%s) has changed!!!\n", host, port, type);
printf("\n");
printf("New Certificate details:\n");
printf("\tCommon Name: %s\n", common_name);
@@ -662,7 +643,8 @@ DWORD client_cli_verify_changed_certificate_ex(freerdp* instance,
printf("\tIssuer: %s\n", old_issuer);
printf("\tThumbprint: %s\n", old_fingerprint);
printf("\n");
- printf("The above X.509 certificate does not match the certificate used for previous connections.\n"
+ printf("The above X.509 certificate does not match the certificate used for previous "
+ "connections.\n"
"This may indicate that the certificate has been tampered with.\n"
"Please contact the administrator of the RDP server and clarify.\n");
return client_cli_accept_certificate(instance->settings);
@@ -673,7 +655,7 @@ BOOL client_auto_reconnect(freerdp* instance)
return client_auto_reconnect_ex(instance, NULL);
}
-BOOL client_auto_reconnect_ex(freerdp* instance, BOOL(*window_events)(freerdp* instance))
+BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* instance))
{
UINT32 maxRetries;
UINT32 numRetries = 0;
@@ -710,7 +692,7 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL(*window_events)(freerdp* i
}
/* Attempt the next reconnect */
- WLog_INFO(TAG, "Attempting reconnect (%"PRIu32" of %"PRIu32")", numRetries, maxRetries);
+ WLog_INFO(TAG, "Attempting reconnect (%" PRIu32 " of %" PRIu32 ")", numRetries, maxRetries);
if (freerdp_reconnect(instance))
return TRUE;
@@ -727,5 +709,3 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL(*window_events)(freerdp* i
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
return FALSE;
}
-
-
diff --git a/client/common/cmdline.c b/client/common/cmdline.c
index 39027ee90..71b8c2a0f 100644
--- a/client/common/cmdline.c
+++ b/client/common/cmdline.c
@@ -57,8 +57,10 @@ static BOOL freerdp_path_valid(const char* path, BOOL* special)
return FALSE;
isSpecial = (strncmp(path, "*", 2) == 0) ||
- (strncmp(path, DynamicDrives, sizeof(DynamicDrives)) == 0) ||
- (strncmp(path, "%", 2) == 0) ? TRUE : FALSE;
+ (strncmp(path, DynamicDrives, sizeof(DynamicDrives)) == 0) ||
+ (strncmp(path, "%", 2) == 0)
+ ? TRUE
+ : FALSE;
if (!isSpecial)
isPath = PathFileExistsA(path);
@@ -75,13 +77,13 @@ static BOOL freerdp_sanitize_drive_name(char* name, const char* invalid, const c
if (strlen(invalid) != strlen(replacement))
return FALSE;
- while(*invalid != '\0')
+ while (*invalid != '\0')
{
const char what = *invalid++;
const char with = *replacement++;
char* cur = name;
- while((cur = strchr(cur, what)) != NULL)
+ while ((cur = strchr(cur, what)) != NULL)
*cur = with;
}
return TRUE;
@@ -91,7 +93,7 @@ static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, co
{
RDPDR_DRIVE* drive;
- drive = (RDPDR_DRIVE*) calloc(1, sizeof(RDPDR_DRIVE));
+ drive = (RDPDR_DRIVE*)calloc(1, sizeof(RDPDR_DRIVE));
if (!drive)
return FALSE;
@@ -118,8 +120,8 @@ static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, co
goto fail;
}
else /* We need a name to send to the server. */
- if (!(drive->Name = _strdup(path)))
- goto fail;
+ if (!(drive->Name = _strdup(path)))
+ goto fail;
if (!path || !freerdp_sanitize_drive_name(drive->Name, "\\/", "__"))
goto fail;
@@ -132,7 +134,7 @@ static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, co
goto fail;
}
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) drive))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)drive))
goto fail;
return TRUE;
@@ -196,8 +198,7 @@ static BOOL value_to_uint(const char* value, ULONGLONG* result, ULONGLONG min, U
BOOL freerdp_client_print_version(void)
{
- printf("This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL,
- GIT_REVISION);
+ printf("This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL, GIT_REVISION);
return TRUE;
}
@@ -210,8 +211,8 @@ BOOL freerdp_client_print_buildconfig(void)
static char* print_token(char* text, size_t start_offset, size_t* current, size_t limit,
const char delimiter)
{
- int rc;
- size_t len = strlen(text);
+ int rc;
+ size_t len = strlen(text);
if (*current < start_offset)
{
@@ -271,7 +272,7 @@ static size_t print_description(const char* text, size_t start_offset, size_t cu
}
free(str);
- current += (size_t) printf("\n");
+ current += (size_t)printf("\n");
return current;
}
@@ -295,8 +296,8 @@ static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
return;
pos += (size_t)rc;
- if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED)
- || (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
+ if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) ||
+ (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
{
if (arg->Format)
{
@@ -343,8 +344,7 @@ static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
}
print_description(arg->Text, description_offset, pos);
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
}
BOOL freerdp_client_print_command_line_help(int argc, char** argv)
@@ -353,7 +353,7 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
}
BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
- COMMAND_LINE_ARGUMENT_A* custom)
+ COMMAND_LINE_ARGUMENT_A* custom)
{
const char* name = "FreeRDP";
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(args)];
@@ -380,7 +380,8 @@ BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
printf(" %s connection.rdp /p:Pwd123! /f\n", name);
printf(" %s /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n", name);
printf(" %s /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n", name);
- printf(" %s /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 /v:192.168.1.100\n",
+ printf(" %s /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 "
+ "/v:192.168.1.100\n",
name);
printf("\n");
printf("Clipboard Redirection: +clipboard\n");
@@ -415,8 +416,7 @@ BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
return TRUE;
}
-static int freerdp_client_command_line_pre_filter(void* context, int index,
- int argc, LPSTR* argv)
+static int freerdp_client_command_line_pre_filter(void* context, int index, int argc, LPSTR* argv)
{
if (index == 1)
{
@@ -432,7 +432,7 @@ static int freerdp_client_command_line_pre_filter(void* context, int index,
{
if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
{
- settings = (rdpSettings*) context;
+ settings = (rdpSettings*)context;
if (!copy_value(argv[index], &settings->ConnectionFile))
return COMMAND_LINE_ERROR_MEMORY;
@@ -445,7 +445,7 @@ static int freerdp_client_command_line_pre_filter(void* context, int index,
{
if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
{
- settings = (rdpSettings*) context;
+ settings = (rdpSettings*)context;
if (!copy_value(argv[index], &settings->AssistanceFile))
return COMMAND_LINE_ERROR_MEMORY;
@@ -458,9 +458,7 @@ static int freerdp_client_command_line_pre_filter(void* context, int index,
return 0;
}
-
-BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
- char** params)
+BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, char** params)
{
if (strcmp(params[0], "drive") == 0)
{
@@ -488,7 +486,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
if (count > 1)
{
- printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
+ printer = (RDPDR_PRINTER*)calloc(1, sizeof(RDPDR_PRINTER));
if (!printer)
return FALSE;
@@ -511,7 +509,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
}
}
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)printer))
{
free(printer->DriverName);
free(printer->Name);
@@ -531,7 +529,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
settings->RedirectSmartCards = TRUE;
settings->DeviceRedirection = TRUE;
- smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
+ smartcard = (RDPDR_SMARTCARD*)calloc(1, sizeof(RDPDR_SMARTCARD));
if (!smartcard)
return FALSE;
@@ -547,7 +545,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
}
}
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)smartcard))
{
free(smartcard->Name);
free(smartcard);
@@ -565,7 +563,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
settings->RedirectSerialPorts = TRUE;
settings->DeviceRedirection = TRUE;
- serial = (RDPDR_SERIAL*) calloc(1, sizeof(RDPDR_SERIAL));
+ serial = (RDPDR_SERIAL*)calloc(1, sizeof(RDPDR_SERIAL));
if (!serial)
return FALSE;
@@ -614,7 +612,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
}
}
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)serial))
{
free(serial->Permissive);
free(serial->Driver);
@@ -635,7 +633,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
settings->RedirectParallelPorts = TRUE;
settings->DeviceRedirection = TRUE;
- parallel = (RDPDR_PARALLEL*) calloc(1, sizeof(RDPDR_PARALLEL));
+ parallel = (RDPDR_PARALLEL*)calloc(1, sizeof(RDPDR_PARALLEL));
if (!parallel)
return FALSE;
@@ -661,7 +659,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
}
}
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) parallel))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)parallel))
{
free(parallel->Path);
free(parallel->Name);
@@ -675,8 +673,7 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count,
return FALSE;
}
-BOOL freerdp_client_add_static_channel(rdpSettings* settings, size_t count,
- char** params)
+BOOL freerdp_client_add_static_channel(rdpSettings* settings, size_t count, char** params)
{
int index;
ADDIN_ARGV* args;
@@ -687,13 +684,13 @@ BOOL freerdp_client_add_static_channel(rdpSettings* settings, size_t count,
if (freerdp_static_channel_collection_find(settings, params[0]))
return TRUE;
- args = (ADDIN_ARGV*) calloc(1, sizeof(ADDIN_ARGV));
+ args = (ADDIN_ARGV*)calloc(1, sizeof(ADDIN_ARGV));
if (!args)
return FALSE;
args->argc = (int)count;
- args->argv = (char**) calloc((size_t)args->argc, sizeof(char*));
+ args->argv = (char**)calloc((size_t)args->argc, sizeof(char*));
if (!args->argv)
goto error_argv;
@@ -727,8 +724,7 @@ error_argv:
return FALSE;
}
-BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, size_t count,
- char** params)
+BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, size_t count, char** params)
{
int index;
ADDIN_ARGV* args;
@@ -739,13 +735,13 @@ BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, size_t count,
if (freerdp_dynamic_channel_collection_find(settings, params[0]))
return TRUE;
- args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
+ args = (ADDIN_ARGV*)malloc(sizeof(ADDIN_ARGV));
if (!args)
return FALSE;
args->argc = (int)count;
- args->argv = (char**) calloc((size_t)args->argc, sizeof(char*));
+ args->argv = (char**)calloc((size_t)args->argc, sizeof(char*));
if (!args->argv)
goto error_argv;
@@ -780,8 +776,7 @@ error_argv:
}
static char** freerdp_command_line_parse_comma_separated_values_ex(const char* name,
- const char* list,
- size_t* count)
+ const char* list, size_t* count)
{
char** p;
char* str;
@@ -798,7 +793,7 @@ static char** freerdp_command_line_parse_comma_separated_values_ex(const char* n
if (name)
{
size_t len = strlen(name);
- p = (char**) calloc(2UL + len, sizeof(char*));
+ p = (char**)calloc(2UL + len, sizeof(char*));
if (p)
{
@@ -830,7 +825,7 @@ static char** freerdp_command_line_parse_comma_separated_values_ex(const char* n
prefix = (nArgs + 1UL) * sizeof(char*);
len = strlen(list);
- p = (char**) calloc(len + prefix + 1, sizeof(char*));
+ p = (char**)calloc(len + prefix + 1, sizeof(char*));
if (!p)
return NULL;
@@ -857,26 +852,23 @@ static char** freerdp_command_line_parse_comma_separated_values_ex(const char* n
return p;
}
-static char** freerdp_command_line_parse_comma_separated_values(char* list,
- size_t* count)
+static char** freerdp_command_line_parse_comma_separated_values(char* list, size_t* count)
{
return freerdp_command_line_parse_comma_separated_values_ex(NULL, list, count);
}
-static char** freerdp_command_line_parse_comma_separated_values_offset(
- const char* name, char* list, size_t* count)
+static char** freerdp_command_line_parse_comma_separated_values_offset(const char* name, char* list,
+ size_t* count)
{
return freerdp_command_line_parse_comma_separated_values_ex(name, list, count);
}
-static int freerdp_client_command_line_post_filter(void* context,
- COMMAND_LINE_ARGUMENT_A* arg)
+static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT_A* arg)
{
- rdpSettings* settings = (rdpSettings*) context;
+ rdpSettings* settings = (rdpSettings*)context;
BOOL status = TRUE;
BOOL enable = arg->Value ? TRUE : FALSE;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "a")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "a")
{
char** p;
size_t count;
@@ -909,8 +901,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value, &count);
status = freerdp_client_add_device_channel(settings, count, p);
free(p);
}
@@ -918,8 +909,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value, &count);
status = freerdp_client_add_device_channel(settings, count, p);
free(p);
}
@@ -927,8 +917,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value, &count);
status = freerdp_client_add_device_channel(settings, count, p);
free(p);
}
@@ -936,8 +925,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value, &count);
status = freerdp_client_add_device_channel(settings, count, p);
free(p);
}
@@ -945,8 +933,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value, &count);
status = freerdp_client_add_device_channel(settings, count, p);
free(p);
}
@@ -954,8 +941,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset("urbdrc", arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset("urbdrc", arg->Value, &count);
status = freerdp_client_add_dynamic_channel(settings, count, p);
free(p);
}
@@ -992,8 +978,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset("rdpsnd", arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset("rdpsnd", arg->Value, &count);
status = freerdp_client_add_static_channel(settings, count, p);
free(p);
}
@@ -1001,8 +986,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset("audin", arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset("audin", arg->Value, &count);
status = freerdp_client_add_dynamic_channel(settings, count, p);
free(p);
}
@@ -1010,8 +994,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
char** p;
size_t count;
- p = freerdp_command_line_parse_comma_separated_values_offset("tsmf", arg->Value,
- &count);
+ p = freerdp_command_line_parse_comma_separated_values_offset("tsmf", arg->Value, &count);
status = freerdp_client_add_dynamic_channel(settings, count, p);
free(p);
}
@@ -1024,8 +1007,8 @@ static int freerdp_client_command_line_post_filter(void* context,
settings->SupportMultitransport = enable;
if (settings->SupportMultitransport)
- settings->MultitransportFlags = (TRANSPORT_TYPE_UDP_FECR |
- TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
+ settings->MultitransportFlags =
+ (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
else
settings->MultitransportFlags = 0;
}
@@ -1033,8 +1016,7 @@ static int freerdp_client_command_line_post_filter(void* context,
{
settings->PasswordIsSmartcardPin = enable;
}
- CommandLineSwitchEnd(arg)
- return status ? 1 : -1;
+ CommandLineSwitchEnd(arg) return status ? 1 : -1;
}
BOOL freerdp_parse_username(const char* username, char** user, char** domain)
@@ -1053,7 +1035,7 @@ BOOL freerdp_parse_username(const char* username, char** user, char** domain)
if (!*user)
return FALSE;
- *domain = (char*) calloc(length + 1UL, sizeof(char));
+ *domain = (char*)calloc(length + 1UL, sizeof(char));
if (!*domain)
{
@@ -1104,7 +1086,7 @@ BOOL freerdp_parse_hostname(const char* hostname, char** host, int* port)
if (!value_to_int(p + 1, &val, 1, UINT16_MAX))
return FALSE;
- *host = (char*) calloc(length + 1UL, sizeof(char));
+ *host = (char*)calloc(length + 1UL, sizeof(char));
if (!(*host))
return FALSE;
@@ -1266,8 +1248,7 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
return 0;
}
-static int freerdp_detect_command_line_pre_filter(void* context, int index,
- int argc, LPSTR* argv)
+static int freerdp_detect_command_line_pre_filter(void* context, int index, int argc, LPSTR* argv)
{
size_t length;
WINPR_UNUSED(context);
@@ -1299,8 +1280,8 @@ static int freerdp_detect_command_line_pre_filter(void* context, int index,
return 0;
}
-static int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv,
- size_t* count, BOOL ignoreUnknown)
+static int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv, size_t* count,
+ BOOL ignoreUnknown)
{
int status;
DWORD flags;
@@ -1320,8 +1301,8 @@ static int freerdp_detect_windows_style_command_line_syntax(int argc, char** arg
*count = 0;
detect_status = 0;
CommandLineClearArgumentsA(largs);
- status = CommandLineParseArgumentsA(argc, argv, largs, flags,
- NULL, freerdp_detect_command_line_pre_filter, NULL);
+ status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
+ freerdp_detect_command_line_pre_filter, NULL);
if (status < 0)
return status;
@@ -1334,8 +1315,7 @@ static int freerdp_detect_windows_style_command_line_syntax(int argc, char** arg
continue;
(*count)++;
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
detect_status = -1;
@@ -1343,8 +1323,8 @@ static int freerdp_detect_windows_style_command_line_syntax(int argc, char** arg
return detect_status;
}
-int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
- size_t* count, BOOL ignoreUnknown)
+int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv, size_t* count,
+ BOOL ignoreUnknown)
{
int status;
DWORD flags;
@@ -1365,8 +1345,8 @@ int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
*count = 0;
detect_status = 0;
CommandLineClearArgumentsA(largs);
- status = CommandLineParseArgumentsA(argc, argv, largs, flags,
- NULL, freerdp_detect_command_line_pre_filter, NULL);
+ status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
+ freerdp_detect_command_line_pre_filter, NULL);
if (status < 0)
return status;
@@ -1379,8 +1359,7 @@ int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
continue;
(*count)++;
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
detect_status = -1;
@@ -1388,8 +1367,7 @@ int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
return detect_status;
}
-static BOOL freerdp_client_detect_command_line(int argc, char** argv,
- DWORD* flags)
+static BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
{
int old_cli_status;
size_t old_cli_count;
@@ -1399,12 +1377,11 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
size_t windows_cli_count;
BOOL compatibility = FALSE;
const BOOL ignoreUnknown = TRUE;
- windows_cli_status = freerdp_detect_windows_style_command_line_syntax(argc,
- argv, &windows_cli_count, ignoreUnknown);
- posix_cli_status = freerdp_detect_posix_style_command_line_syntax(argc, argv,
- &posix_cli_count, ignoreUnknown);
- old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv,
- &old_cli_count);
+ windows_cli_status = freerdp_detect_windows_style_command_line_syntax(
+ argc, argv, &windows_cli_count, ignoreUnknown);
+ posix_cli_status =
+ freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown);
+ old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv, &old_cli_count);
/* Default is POSIX syntax */
*flags = COMMAND_LINE_SEPARATOR_SPACE;
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
@@ -1414,8 +1391,8 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
return compatibility;
/* Check, if this may be windows style syntax... */
- if ((windows_cli_count && (windows_cli_count >= posix_cli_count))
- || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
+ if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) ||
+ (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
{
windows_cli_count = 1;
*flags = COMMAND_LINE_SEPARATOR_COLON;
@@ -1424,8 +1401,7 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
else if (old_cli_status >= 0)
{
/* Ignore legacy parsing in case there is an error in the command line. */
- if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count)
- && (old_cli_status != -1)))
+ if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1)))
{
*flags = COMMAND_LINE_SEPARATOR_SPACE;
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
@@ -1434,20 +1410,19 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
}
WLog_DBG(TAG, "windows: %d/%d posix: %d/%d compat: %d/%d", windows_cli_status,
- windows_cli_count,
- posix_cli_status, posix_cli_count, old_cli_status, old_cli_count);
+ windows_cli_count, posix_cli_status, posix_cli_count, old_cli_status, old_cli_count);
return compatibility;
}
-int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
- int status, int argc, char** argv)
+int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc,
+ char** argv)
{
- return freerdp_client_settings_command_line_status_print_ex(
- settings, status, argc, argv, NULL);
+ return freerdp_client_settings_command_line_status_print_ex(settings, status, argc, argv, NULL);
}
-int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
- int status, int argc, char** argv, COMMAND_LINE_ARGUMENT_A* custom)
+int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, int status,
+ int argc, char** argv,
+ COMMAND_LINE_ARGUMENT_A* custom)
{
COMMAND_LINE_ARGUMENT_A* arg;
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(args)];
@@ -1474,27 +1449,27 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
DWORD i;
RDP_KEYBOARD_LAYOUT* layouts;
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
- //if (!layouts) /* FIXME*/
+ // if (!layouts) /* FIXME*/
printf("\nKeyboard Layouts\n");
for (i = 0; layouts[i].code; i++)
- printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
+ printf("0x%08" PRIX32 "\t%s\n", layouts[i].code, layouts[i].name);
freerdp_keyboard_layouts_free(layouts);
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
- //if (!layouts) /* FIXME*/
+ // if (!layouts) /* FIXME*/
printf("\nKeyboard Layout Variants\n");
for (i = 0; layouts[i].code; i++)
- printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
+ printf("0x%08" PRIX32 "\t%s\n", layouts[i].code, layouts[i].name);
freerdp_keyboard_layouts_free(layouts);
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
- //if (!layouts) /* FIXME*/
+ // if (!layouts) /* FIXME*/
printf("\nKeyboard Input Method Editors (IMEs)\n");
for (i = 0; layouts[i].code; i++)
- printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
+ printf("0x%08" PRIX32 "\t%s\n", layouts[i].code, layouts[i].name);
freerdp_keyboard_layouts_free(layouts);
printf("\n");
@@ -1568,7 +1543,7 @@ static BOOL parseSizeValue(const char* input, unsigned long* v1, unsigned long*
if ((v == 0 || v == ULONG_MAX) && (errno != 0))
return FALSE;
- if (*endPtr != '\0')
+ if (*endPtr != '\0')
return FALSE;
if (v2)
@@ -1577,8 +1552,8 @@ static BOOL parseSizeValue(const char* input, unsigned long* v1, unsigned long*
return TRUE;
}
-int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
- int argc, char** argv, BOOL allowUnknown)
+int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int argc,
+ char** argv, BOOL allowUnknown)
{
char* p;
char* user = NULL;
@@ -1631,14 +1606,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (assist)
{
- if (freerdp_client_settings_parse_assistance_file(settings,
- argc, argv) < 0)
+ if (freerdp_client_settings_parse_assistance_file(settings, argc, argv) < 0)
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
CommandLineClearArgumentsA(largs);
- status = CommandLineParseArgumentsA(argc, argv, largs, flags,
- settings,
+ status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
freerdp_client_command_line_pre_filter,
freerdp_client_command_line_post_filter);
@@ -1657,8 +1630,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "v")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "v")
{
assert(arg->Value);
free(settings->ServerHostname);
@@ -1680,7 +1652,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
length = (size_t)(p - arg->Value);
settings->ServerPort = (UINT16)val;
- if (!(settings->ServerHostname = (char*) calloc(length + 1UL, sizeof(char))))
+ if (!(settings->ServerHostname = (char*)calloc(length + 1UL, sizeof(char))))
return COMMAND_LINE_ERROR_MEMORY;
strncpy(settings->ServerHostname, arg->Value, length);
@@ -1702,7 +1674,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
length = (size_t)(p2 - p);
- if (!(settings->ServerHostname = (char*) calloc(length, sizeof(char))))
+ if (!(settings->ServerHostname = (char*)calloc(length, sizeof(char))))
return COMMAND_LINE_ERROR_MEMORY;
strncpy(settings->ServerHostname, p + 1, length - 1);
@@ -1717,7 +1689,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
settings->ServerPort = (UINT16)val;
}
- printf("hostname %s port %"PRIu32"\n", settings->ServerHostname, settings->ServerPort);
+ printf("hostname %s port %" PRIu32 "\n", settings->ServerHostname,
+ settings->ServerPort);
}
}
CommandLineSwitchCase(arg, "spn-class")
@@ -1756,8 +1729,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
mask = (mask & 0x07);
settings->RedirectionPreferType |= mask << (count * 3);
count++;
- }
- while (cur != NULL);
+ } while (cur != NULL);
if (count > 3)
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
@@ -1902,7 +1874,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (count > 16)
count = 16;
- settings->NumMonitorIds = (UINT32) count;
+ settings->NumMonitorIds = (UINT32)count;
for (i = 0; i < settings->NumMonitorIds; i++)
{
@@ -2029,7 +2001,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
errno = 0;
}
- settings->KeyboardLayout = (UINT32) val;
+ settings->KeyboardLayout = (UINT32)val;
}
CommandLineSwitchCase(arg, "kbd-type")
{
@@ -2092,7 +2064,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
s = (size_t)(p - arg->Value);
settings->GatewayPort = (UINT32)val;
- if (!(settings->GatewayHostname = (char*) calloc(s + 1UL, sizeof(char))))
+ if (!(settings->GatewayHostname = (char*)calloc(s + 1UL, sizeof(char))))
return COMMAND_LINE_ERROR_MEMORY;
strncpy(settings->GatewayHostname, arg->Value, s);
@@ -2162,7 +2134,9 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (!colonPtr || (colonPtr > atPtr))
{
- WLog_ERR(TAG, "invalid syntax for proxy, expected syntax is user:password@host:port");
+ WLog_ERR(
+ TAG,
+ "invalid syntax for proxy, expected syntax is user:password@host:port");
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
@@ -2198,7 +2172,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
length = (size_t)(p - arg->Value);
settings->ProxyPort = (UINT16)val;
- settings->ProxyHostname = (char*) malloc(length + 1);
+ settings->ProxyHostname = (char*)malloc(length + 1);
strncpy(settings->ProxyHostname, arg->Value, length);
settings->ProxyHostname[length] = '\0';
}
@@ -2269,7 +2243,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
{
LONGLONG val;
- if (!value_to_int(arg->Value, &val, TSC_PROXY_MODE_NONE_DIRECT, TSC_PROXY_MODE_NONE_DETECT))
+ if (!value_to_int(arg->Value, &val, TSC_PROXY_MODE_NONE_DIRECT,
+ TSC_PROXY_MODE_NONE_DETECT))
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
}
@@ -2296,8 +2271,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (!copy_value(arg->Value, (char**)&settings->LoadBalanceInfo))
return COMMAND_LINE_ERROR_MEMORY;
- settings->LoadBalanceInfoLength = (UINT32) strlen((char*)
- settings->LoadBalanceInfo);
+ settings->LoadBalanceInfoLength = (UINT32)strlen((char*)settings->LoadBalanceInfo);
}
CommandLineSwitchCase(arg, "app-name")
{
@@ -2406,8 +2380,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
else if (_stricmp(arg->Value, "lan") == 0)
type = CONNECTION_TYPE_LAN;
else if ((_stricmp(arg->Value, "autodetect") == 0) ||
- (_stricmp(arg->Value, "auto") == 0) ||
- (_stricmp(arg->Value, "detect") == 0))
+ (_stricmp(arg->Value, "auto") == 0) || (_stricmp(arg->Value, "detect") == 0))
{
type = CONNECTION_TYPE_AUTODETECT;
}
@@ -2491,7 +2464,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
}
else
#endif
- if (_strnicmp("RFX", arg->Value, 4) == 0)
+ if (_strnicmp("RFX", arg->Value, 4) == 0)
{
settings->GfxAVC444 = FALSE;
settings->GfxH264 = FALSE;
@@ -2840,8 +2813,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
}
else
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
- }
- while (start);
+ } while (start);
}
}
CommandLineSwitchCase(arg, "mouse-motion")
@@ -2867,8 +2839,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
}
CommandLineSwitchCase(arg, "glyph-cache")
{
- settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL :
- GLYPH_SUPPORT_NONE;
+ settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE;
}
CommandLineSwitchCase(arg, "codec-cache")
{
@@ -2917,7 +2888,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
if (val < 0)
- settings->MaxTimeInCheckLoop = 10 * 60 * 60 * 1000; /* 10 hours can be considered as infinite */
+ settings->MaxTimeInCheckLoop =
+ 10 * 60 * 60 * 1000; /* 10 hours can be considered as infinite */
else
settings->MaxTimeInCheckLoop = (UINT32)val;
}
@@ -2967,8 +2939,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
BYTE* base64 = NULL;
int length;
assert(arg->Value);
- crypto_base64_decode((const char*)(arg->Value), (int) strlen(arg->Value),
- &base64, &length);
+ crypto_base64_decode((const char*)(arg->Value), (int)strlen(arg->Value), &base64,
+ &length);
if ((base64 != NULL) && (length == sizeof(ARC_SC_PRIVATE_PACKET)))
{
@@ -3089,8 +3061,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
if (user)
{
@@ -3153,7 +3124,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
if (!settings->GatewayPassword)
return COMMAND_LINE_ERROR;
- if (!freerdp_passphrase_read("Gateway Password: ", settings->GatewayPassword, size, 1))
+ if (!freerdp_passphrase_read("Gateway Password: ", settings->GatewayPassword, size,
+ 1))
return COMMAND_LINE_ERROR;
}
}
@@ -3161,8 +3133,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
freerdp_performance_flags_make(settings);
- if (settings->RemoteFxCodec || settings->NSCodec
- || settings->SupportGraphicsPipeline)
+ if (settings->RemoteFxCodec || settings->NSCodec || settings->SupportGraphicsPipeline)
{
settings->FastPathOutput = TRUE;
settings->LargePointerFlag = TRUE;
@@ -3199,13 +3170,13 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
return status;
}
-static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels,
- rdpSettings* settings, char* name, void* data)
+static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
+ char* name, void* data)
{
PVIRTUALCHANNELENTRY entry = NULL;
PVIRTUALCHANNELENTRYEX entryEx = NULL;
- entryEx = (PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry(name, NULL, NULL,
- FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
+ entryEx = (PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry(
+ name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
if (!entryEx)
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
@@ -3237,10 +3208,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->AudioPlayback)
{
- char* p[] =
- {
- "rdpsnd"
- };
+ char* p[] = { "rdpsnd" };
if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(p), p))
return FALSE;
@@ -3248,10 +3216,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->AudioCapture)
{
- char* p[] =
- {
- "audin"
- };
+ char* p[] = { "audin" };
if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(p), p))
return FALSE;
@@ -3261,8 +3226,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
(freerdp_dynamic_channel_collection_find(settings, "tsmf")))
{
settings->DeviceRedirection = TRUE; /* rdpsnd requires rdpdr to be registered */
- settings->AudioPlayback =
- TRUE; /* Both rdpsnd and tsmf require this flag to be set */
+ settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */
}
if (freerdp_dynamic_channel_collection_find(settings, "audin"))
@@ -3270,12 +3234,10 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
settings->AudioCapture = TRUE;
}
- if (settings->NetworkAutoDetect ||
- settings->SupportHeartbeatPdu ||
+ if (settings->NetworkAutoDetect || settings->SupportHeartbeatPdu ||
settings->SupportMultitransport)
{
- settings->DeviceRedirection =
- TRUE; /* these RDP8 features require rdpdr to be registered */
+ settings->DeviceRedirection = TRUE; /* these RDP8 features require rdpdr to be registered */
}
if (settings->DrivesToRedirect && (strlen(settings->DrivesToRedirect) != 0))
@@ -3301,7 +3263,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
return FALSE;
}
- while(tok)
+ while (tok)
{
/* Syntax: Comma seperated list of the following entries:
* '*' ... Redirect all drives, including hotplug
@@ -3352,14 +3314,13 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
params[1] = "media";
params[2] = "*";
- if (!freerdp_client_add_device_channel(settings, 3, (char**) params))
+ if (!freerdp_client_add_device_channel(settings, 3, (char**)params))
return FALSE;
}
}
- if (settings->RedirectDrives || settings->RedirectHomeDrive
- || settings->RedirectSerialPorts
- || settings->RedirectSmartCards || settings->RedirectPrinters)
+ if (settings->RedirectDrives || settings->RedirectHomeDrive || settings->RedirectSerialPorts ||
+ settings->RedirectSmartCards || settings->RedirectPrinters)
{
settings->DeviceRedirection = TRUE; /* All of these features require rdpdr */
}
@@ -3373,15 +3334,14 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
params[1] = "home";
params[2] = "%";
- if (!freerdp_client_add_device_channel(settings, 3, (char**) params))
+ if (!freerdp_client_add_device_channel(settings, 3, (char**)params))
return FALSE;
}
}
if (settings->DeviceRedirection)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "rdpdr",
- settings))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "rdpdr", settings))
return FALSE;
if (!freerdp_static_channel_collection_find(settings, "rdpsnd"))
@@ -3390,7 +3350,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
params[0] = "rdpsnd";
params[1] = "sys:fake";
- if (!freerdp_client_add_static_channel(settings, 2, (char**) params))
+ if (!freerdp_client_add_static_channel(settings, 2, (char**)params))
return FALSE;
}
}
@@ -3401,14 +3361,14 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_SMARTCARD))
{
- smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
+ smartcard = (RDPDR_SMARTCARD*)calloc(1, sizeof(RDPDR_SMARTCARD));
if (!smartcard)
return FALSE;
smartcard->Type = RDPDR_DTYP_SMARTCARD;
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)smartcard))
return FALSE;
}
}
@@ -3419,14 +3379,14 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_PRINT))
{
- printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
+ printer = (RDPDR_PRINTER*)calloc(1, sizeof(RDPDR_PRINTER));
if (!printer)
return FALSE;
printer->Type = RDPDR_DTYP_PRINT;
- if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer))
+ if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*)printer))
return FALSE;
}
}
@@ -3436,7 +3396,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
char* params[1];
params[0] = "cliprdr";
- if (!freerdp_client_add_static_channel(settings, 1, (char**) params))
+ if (!freerdp_client_add_static_channel(settings, 1, (char**)params))
return FALSE;
}
@@ -3456,21 +3416,20 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->EncomspVirtualChannel)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "encomsp",
- settings))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "encomsp", settings))
return FALSE;
}
if (settings->RemdeskVirtualChannel)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "remdesk",
- settings))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "remdesk", settings))
return FALSE;
}
if (settings->RDP2TCPArgs)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "rdp2tcp", settings->RDP2TCPArgs))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "rdp2tcp",
+ settings->RDP2TCPArgs))
return FALSE;
}
@@ -3478,15 +3437,13 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
{
args = settings->StaticChannelArray[index];
- if (!freerdp_client_load_static_channel_addin(channels, settings, args->argv[0],
- args))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, args->argv[0], args))
return FALSE;
}
if (settings->RemoteApplicationMode)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "rail",
- settings))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "rail", settings))
return FALSE;
}
@@ -3572,8 +3529,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->SupportDynamicChannels)
{
- if (!freerdp_client_load_static_channel_addin(channels, settings, "drdynvc",
- settings))
+ if (!freerdp_client_load_static_channel_addin(channels, settings, "drdynvc", settings))
return FALSE;
}
diff --git a/client/common/cmdline.h b/client/common/cmdline.h
index 19d3d05bd..e47a26449 100644
--- a/client/common/cmdline.h
+++ b/client/common/cmdline.h
@@ -22,8 +22,7 @@
#include
-static const COMMAND_LINE_ARGUMENT_A args[] =
-{
+static const COMMAND_LINE_ARGUMENT_A args[] = {
{ "a", COMMAND_LINE_VALUE_REQUIRED, "[,]", NULL, NULL, -1, "addin", "Addin" },
{ "action-script", COMMAND_LINE_VALUE_REQUIRED, "", "~/.config/freerdp/action.sh",
NULL, -1, NULL, "Action script" },
@@ -328,9 +327,12 @@ static const COMMAND_LINE_ARGUMENT_A args[] =
"Hyper-V console (use port 2179, disable negotiation)" },
{ "w", COMMAND_LINE_VALUE_REQUIRED, "", "1024", NULL, -1, NULL, "Width" },
{ "wallpaper", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "wallpaper" },
- { "window-drag", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "full window drag" },
- { "window-position", COMMAND_LINE_VALUE_REQUIRED, "x", NULL, NULL, -1, NULL, "window position" },
- { "wm-class", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Set the WM_CLASS hint for the window instance" },
+ { "window-drag", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
+ "full window drag" },
+ { "window-position", COMMAND_LINE_VALUE_REQUIRED, "x", NULL, NULL, -1, NULL,
+ "window position" },
+ { "wm-class", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ "Set the WM_CLASS hint for the window instance" },
{ "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
};
diff --git a/client/common/compatibility.c b/client/common/compatibility.c
index 79436c5e1..b9b70c893 100644
--- a/client/common/compatibility.c
+++ b/client/common/compatibility.c
@@ -41,55 +41,79 @@
#define TAG CLIENT_TAG("common.compatibility")
-static const COMMAND_LINE_ARGUMENT_A old_args[] =
-{
+static const COMMAND_LINE_ARGUMENT_A old_args[] = {
{ "0", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "connect to console session" },
- { "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set color depth in bits, default is 16" },
+ { "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "set color depth in bits, default is 16" },
{ "c", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "shell working directory" },
{ "D", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "hide window decorations" },
{ "T", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Window title" },
{ "d", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "domain" },
{ "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "fullscreen mode" },
- { "g", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set geometry, using format WxH or X%% or 'workarea', default is 1024x768" },
- { "h", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help", "print this help" },
+ { "g", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "set geometry, using format WxH or X%% or 'workarea', default is 1024x768" },
+ { "h", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help",
+ "print this help" },
{ "k", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set keyboard layout ID" },
- { "K", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "do not interfere with window manager bindings" },
+ { "K", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "do not interfere with window manager bindings" },
{ "n", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "hostname" },
{ "o", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "console audio" },
{ "p", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "password" },
{ "s", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set startup-shell" },
- { "t", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "alternative port number, default is 3389" },
+ { "t", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "alternative port number, default is 3389" },
{ "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" },
- { "x", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "performance flags (m[odem], b[roadband] or l[an])" },
- { "X", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "embed into another window with a given XID." },
+ { "x", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "performance flags (m[odem], b[roadband] or l[an])" },
+ { "X", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "embed into another window with a given XID." },
{ "z", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable compression" },
- { "app", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "RemoteApp connection. This implies -g workarea" },
+ { "app", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "RemoteApp connection. This implies -g workarea" },
{ "ext", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "load an extension" },
{ "no-auth", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable authentication" },
- { "authonly", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "authentication only, no UI" },
- { "from-stdin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "unspecified username, password, domain and hostname params are prompted" },
+ { "authonly", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "authentication only, no UI" },
+ { "from-stdin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "unspecified username, password, domain and hostname params are prompted" },
{ "no-fastpath", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable fast-path" },
- { "no-motion", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "don't send mouse motion events" },
- { "gdi", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "graphics rendering (hw, sw)" },
+ { "no-motion", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "don't send mouse motion events" },
+ { "gdi", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "graphics rendering (hw, sw)" },
{ "no-osb", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable offscreen bitmaps" },
{ "no-bmp-cache", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable bitmap cache" },
- { "plugin", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "load a virtual channel plugin" },
+ { "plugin", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "load a virtual channel plugin" },
{ "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable RemoteFX" },
- { "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "RemoteFX operational flags (v[ideo], i[mage]), default is video" },
+ { "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "RemoteFX operational flags (v[ideo], i[mage]), default is video" },
{ "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable NSCodec (experimental)" },
- { "disable-wallpaper", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables wallpaper" },
- { "composition", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable desktop composition" },
- { "disable-full-window-drag", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables full window drag" },
- { "disable-menu-animations", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables menu animations" },
+ { "disable-wallpaper", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "disables wallpaper" },
+ { "composition", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "enable desktop composition" },
+ { "disable-full-window-drag", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "disables full window drag" },
+ { "disable-menu-animations", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "disables menu animations" },
{ "disable-theming", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables theming" },
- { "no-rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable Standard RDP encryption" },
+ { "no-rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "disable Standard RDP encryption" },
{ "no-tls", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable TLS encryption" },
- { "no-nla", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable network level authentication" },
- { "ntlm", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "force NTLM authentication protocol version (1 or 2)" },
- { "ignore-certificate", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "ignore verification of logon certificate" },
- { "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "force protocol security (rdp, tls or nla)" },
- { "secure-checksum", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "use salted checksums with Standard RDP encryption" },
- { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, "print version information" },
+ { "no-nla", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "disable network level authentication" },
+ { "ntlm", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "force NTLM authentication protocol version (1 or 2)" },
+ { "ignore-certificate", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "ignore verification of logon certificate" },
+ { "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ "force protocol security (rdp, tls or nla)" },
+ { "secure-checksum", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ "use salted checksums with Standard RDP encryption" },
+ { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL,
+ "print version information" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
};
@@ -98,8 +122,8 @@ static BOOL freerdp_client_old_parse_hostname(char* str, char** ServerHostname,
char* p;
char* host = NULL;
- if (str[0] == '[' && (p = strchr(str, ']'))
- && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
+ if (str[0] == '[' && (p = strchr(str, ']')) &&
+ (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
{
/* Either "[...]" or "[...]:..." with at most one : after the brackets */
if (!(host = _strdup(str + 1)))
@@ -160,7 +184,7 @@ static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV*
{
args_handled++;
settings->RedirectClipboard = TRUE;
- WLog_WARN(TAG, "--plugin cliprdr -> +clipboard");
+ WLog_WARN(TAG, "--plugin cliprdr -> +clipboard");
}
else if (strcmp(args->argv[0], "rdpdr") == 0)
{
@@ -171,8 +195,7 @@ static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV*
args_handled++;
- if ((strcmp(args->argv[1], "disk") == 0) ||
- (strcmp(args->argv[1], "drive") == 0))
+ if ((strcmp(args->argv[1], "disk") == 0) || (strcmp(args->argv[1], "drive") == 0))
{
freerdp_addin_replace_argument(args, "disk", "drive");
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
@@ -181,8 +204,7 @@ static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV*
{
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
}
- else if ((strcmp(args->argv[1], "scard") == 0) ||
- (strcmp(args->argv[1], "smartcard") == 0))
+ else if ((strcmp(args->argv[1], "scard") == 0) || (strcmp(args->argv[1], "smartcard") == 0))
{
freerdp_addin_replace_argument(args, "scard", "smartcard");
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
@@ -232,16 +254,15 @@ static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV*
return args_handled;
}
static int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc,
- LPSTR* argv)
+ LPSTR* argv)
{
- rdpSettings* settings = (rdpSettings*) context;
+ rdpSettings* settings = (rdpSettings*)context;
if (index == (argc - 1))
{
if (argv[index][0] != '-')
{
- if ((strcmp(argv[index - 1], "-v") == 0) ||
- (strcmp(argv[index - 1], "/v") == 0))
+ if ((strcmp(argv[index - 1], "-v") == 0) || (strcmp(argv[index - 1], "/v") == 0))
{
return -1;
}
@@ -251,8 +272,8 @@ static int freerdp_client_old_command_line_pre_filter(void* context, int index,
return -1;
}
- if (!freerdp_client_old_parse_hostname(argv[index],
- &settings->ServerHostname, &settings->ServerPort))
+ if (!freerdp_client_old_parse_hostname(argv[index], &settings->ServerHostname,
+ &settings->ServerPort))
return -1;
return 2;
@@ -267,7 +288,7 @@ static int freerdp_client_old_command_line_pre_filter(void* context, int index,
{
int args_handled = 0;
int length;
- char* a, *p;
+ char *a, *p;
int i, j, t;
int old_index;
ADDIN_ARGV* args;
@@ -278,12 +299,12 @@ static int freerdp_client_old_command_line_pre_filter(void* context, int index,
if (index == argc)
return -1;
- args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
+ args = (ADDIN_ARGV*)malloc(sizeof(ADDIN_ARGV));
if (!args)
return -1;
- args->argv = (char**) calloc(argc, sizeof(char*));
+ args->argv = (char**)calloc(argc, sizeof(char*));
if (!args->argv)
{
@@ -334,7 +355,7 @@ static int freerdp_client_old_command_line_pre_filter(void* context, int index,
{
length = (int)(p - a);
- if (!(args->argv[j + 1] = (char*) malloc(length + 1)))
+ if (!(args->argv[j + 1] = (char*)malloc(length + 1)))
{
for (; j >= 0; --j)
free(args->argv[j]);
@@ -422,7 +443,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
- settings = (rdpSettings*) calloc(1, sizeof(rdpSettings));
+ settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
if (!settings)
return -1;
@@ -444,12 +465,11 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "a")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "a")
{
- if ((strcmp(arg->Value, "8") == 0) ||
- (strcmp(arg->Value, "15") == 0) || (strcmp(arg->Value, "16") == 0) ||
- (strcmp(arg->Value, "24") == 0) || (strcmp(arg->Value, "32") == 0))
+ if ((strcmp(arg->Value, "8") == 0) || (strcmp(arg->Value, "15") == 0) ||
+ (strcmp(arg->Value, "16") == 0) || (strcmp(arg->Value, "24") == 0) ||
+ (strcmp(arg->Value, "32") == 0))
{
detect_status = 1;
}
@@ -457,10 +477,8 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
CommandLineSwitchDefault(arg)
{
}
- CommandLineSwitchEnd(arg)
- (*count)++;
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ CommandLineSwitchEnd(arg)(*count)++;
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
detect_status = -1;
@@ -491,7 +509,8 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
- freerdp_client_old_command_line_pre_filter, freerdp_client_old_command_line_post_filter);
+ freerdp_client_old_command_line_pre_filter,
+ freerdp_client_old_command_line_post_filter);
if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
{
@@ -522,11 +541,10 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
continue;
- CommandLineSwitchStart(arg)
- CommandLineSwitchCase(arg, "0")
+ CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "0")
{
settings->ConsoleSession = TRUE;
- WLog_WARN(TAG, "-0 -> /admin");
+ WLog_WARN(TAG, "-0 -> /admin");
}
CommandLineSwitchCase(arg, "a")
{
@@ -536,11 +554,11 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
settings->ColorDepth = val;
- WLog_WARN(TAG, "-a %s -> /bpp:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-a %s -> /bpp:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "c")
{
- WLog_WARN(TAG, "-c %s -> /shell-dir:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-c %s -> /shell-dir:%s", arg->Value, arg->Value);
if (!(settings->ShellWorkingDirectory = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
@@ -548,26 +566,26 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
CommandLineSwitchCase(arg, "D")
{
settings->Decorations = FALSE;
- WLog_WARN(TAG, "-D -> -decorations");
+ WLog_WARN(TAG, "-D -> -decorations");
}
CommandLineSwitchCase(arg, "T")
{
if (!(settings->WindowTitle = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-T %s -> /title:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-T %s -> /title:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "d")
{
if (!(settings->Domain = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-d %s -> /d:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-d %s -> /d:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "f")
{
settings->Fullscreen = TRUE;
- WLog_WARN(TAG, "-f -> /f");
+ WLog_WARN(TAG, "-f -> /f");
}
CommandLineSwitchCase(arg, "g")
{
@@ -600,37 +618,37 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
}
free(str);
- WLog_WARN(TAG, "-g %s -> /size:%s or /w:%"PRIu32" /h:%"PRIu32"", arg->Value, arg->Value,
- settings->DesktopWidth, settings->DesktopHeight);
+ WLog_WARN(TAG, "-g %s -> /size:%s or /w:%" PRIu32 " /h:%" PRIu32 "", arg->Value,
+ arg->Value, settings->DesktopWidth, settings->DesktopHeight);
}
CommandLineSwitchCase(arg, "k")
{
sscanf(arg->Value, "%X", &(settings->KeyboardLayout));
- WLog_WARN(TAG, "-k %s -> /kbd:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-k %s -> /kbd:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "K")
{
settings->GrabKeyboard = FALSE;
- WLog_WARN(TAG, "-K -> -grab-keyboard");
+ WLog_WARN(TAG, "-K -> -grab-keyboard");
}
CommandLineSwitchCase(arg, "n")
{
if (!(settings->ClientHostname = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-n -> /client-hostname:%s", arg->Value);
+ WLog_WARN(TAG, "-n -> /client-hostname:%s", arg->Value);
}
CommandLineSwitchCase(arg, "o")
{
settings->RemoteConsoleAudio = TRUE;
- WLog_WARN(TAG, "-o -> /audio-mode:1");
+ WLog_WARN(TAG, "-o -> /audio-mode:1");
}
CommandLineSwitchCase(arg, "p")
{
if (!(settings->Password = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-p ****** -> /p:******");
+ WLog_WARN(TAG, "-p ****** -> /p:******");
/* Hide the value from 'ps'. */
FillMemory(arg->Value, strlen(arg->Value), '*');
}
@@ -639,7 +657,7 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
if (!(settings->AlternateShell = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-s %s -> /shell:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-s %s -> /shell:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "t")
{
@@ -649,14 +667,14 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
settings->ServerPort = p;
- WLog_WARN(TAG, "-t %s -> /port:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-t %s -> /port:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "u")
{
if (!(settings->Username = _strdup(arg->Value)))
return COMMAND_LINE_ERROR_MEMORY;
- WLog_WARN(TAG, "-u %s -> /u:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-u %s -> /u:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "x")
{
@@ -686,16 +704,16 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
freerdp_performance_flags_split(settings);
}
- WLog_WARN(TAG, "-x %s -> /network:", arg->Value);
+ WLog_WARN(TAG, "-x %s -> /network:", arg->Value);
if (type == CONNECTION_TYPE_MODEM)
- WLog_WARN(TAG, "modem");
+ WLog_WARN(TAG, "modem");
else if (CONNECTION_TYPE_BROADBAND_HIGH)
- WLog_WARN(TAG, "broadband");
+ WLog_WARN(TAG, "broadband");
else if (CONNECTION_TYPE_LAN)
- WLog_WARN(TAG, "lan");
+ WLog_WARN(TAG, "lan");
- WLog_WARN(TAG, "");
+ WLog_WARN(TAG, "");
}
CommandLineSwitchCase(arg, "X")
{
@@ -704,17 +722,17 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
if (errno != 0)
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
- WLog_WARN(TAG, "-X %s -> /parent-window:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "-X %s -> /parent-window:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "z")
{
settings->CompressionEnabled = TRUE;
- WLog_WARN(TAG, "-z -> /compression");
+ WLog_WARN(TAG, "-z -> /compression");
}
CommandLineSwitchCase(arg, "app")
{
settings->RemoteApplicationMode = TRUE;
- WLog_WARN(TAG, "--app -> /app: + program name or alias");
+ WLog_WARN(TAG, "--app -> /app: + program name or alias");
}
CommandLineSwitchCase(arg, "ext")
{
@@ -722,7 +740,7 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
CommandLineSwitchCase(arg, "no-auth")
{
settings->Authentication = FALSE;
- WLog_WARN(TAG, "--no-auth -> -authentication");
+ WLog_WARN(TAG, "--no-auth -> -authentication");
}
CommandLineSwitchCase(arg, "authonly")
{
@@ -736,12 +754,12 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
{
settings->FastPathInput = FALSE;
settings->FastPathOutput = FALSE;
- WLog_WARN(TAG, "--no-fastpath -> -fast-path");
+ WLog_WARN(TAG, "--no-fastpath -> -fast-path");
}
CommandLineSwitchCase(arg, "no-motion")
{
settings->MouseMotion = FALSE;
- WLog_WARN(TAG, "--no-motion -> -mouse-motion");
+ WLog_WARN(TAG, "--no-motion -> -mouse-motion");
}
CommandLineSwitchCase(arg, "gdi")
{
@@ -750,26 +768,26 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
else if (strcmp(arg->Value, "hw") == 0)
settings->SoftwareGdi = FALSE;
- WLog_WARN(TAG, "--gdi %s -> /gdi:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "--gdi %s -> /gdi:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "no-osb")
{
settings->OffscreenSupportLevel = FALSE;
- WLog_WARN(TAG, "--no-osb -> -offscreen-cache");
+ WLog_WARN(TAG, "--no-osb -> -offscreen-cache");
}
CommandLineSwitchCase(arg, "no-bmp-cache")
{
settings->BitmapCacheEnabled = FALSE;
- WLog_WARN(TAG, "--no-bmp-cache -> -bitmap-cache");
+ WLog_WARN(TAG, "--no-bmp-cache -> -bitmap-cache");
}
CommandLineSwitchCase(arg, "plugin")
{
- WLog_WARN(TAG, "--plugin -> /a, /vc, /dvc and channel-specific options");
+ WLog_WARN(TAG, "--plugin -> /a, /vc, /dvc and channel-specific options");
}
CommandLineSwitchCase(arg, "rfx")
{
settings->RemoteFxCodec = TRUE;
- WLog_WARN(TAG, "--rfx -> /rfx");
+ WLog_WARN(TAG, "--rfx -> /rfx");
}
CommandLineSwitchCase(arg, "rfx-mode")
{
@@ -778,37 +796,38 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
else if (arg->Value[0] == 'i')
settings->RemoteFxCodecMode = 0x02;
- WLog_WARN(TAG, "--rfx-mode -> /rfx-mode:%s", settings->RemoteFxCodecMode ? "image" : "video");
+ WLog_WARN(TAG, "--rfx-mode -> /rfx-mode:%s",
+ settings->RemoteFxCodecMode ? "image" : "video");
}
CommandLineSwitchCase(arg, "nsc")
{
settings->NSCodec = TRUE;
- WLog_WARN(TAG, "--nsc -> /nsc");
+ WLog_WARN(TAG, "--nsc -> /nsc");
}
CommandLineSwitchCase(arg, "disable-wallpaper")
{
settings->DisableWallpaper = TRUE;
- WLog_WARN(TAG, "--disable-wallpaper -> -wallpaper");
+ WLog_WARN(TAG, "--disable-wallpaper -> -wallpaper");
}
CommandLineSwitchCase(arg, "composition")
{
settings->AllowDesktopComposition = TRUE;
- WLog_WARN(TAG, "--composition -> +composition");
+ WLog_WARN(TAG, "--composition -> +composition");
}
CommandLineSwitchCase(arg, "disable-full-window-drag")
{
settings->DisableFullWindowDrag = TRUE;
- WLog_WARN(TAG, "--disable-full-window-drag -> -window-drag");
+ WLog_WARN(TAG, "--disable-full-window-drag -> -window-drag");
}
CommandLineSwitchCase(arg, "disable-menu-animations")
{
settings->DisableMenuAnims = TRUE;
- WLog_WARN(TAG, "--disable-menu-animations -> -menu-anims");
+ WLog_WARN(TAG, "--disable-menu-animations -> -menu-anims");
}
CommandLineSwitchCase(arg, "disable-theming")
{
settings->DisableThemes = TRUE;
- WLog_WARN(TAG, "--disable-theming -> -themes");
+ WLog_WARN(TAG, "--disable-theming -> -themes");
}
CommandLineSwitchCase(arg, "ntlm")
{
@@ -816,7 +835,7 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
CommandLineSwitchCase(arg, "ignore-certificate")
{
settings->IgnoreCertificate = TRUE;
- WLog_WARN(TAG, "--ignore-certificate -> /cert-ignore");
+ WLog_WARN(TAG, "--ignore-certificate -> /cert-ignore");
}
CommandLineSwitchCase(arg, "sec")
{
@@ -840,22 +859,22 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
settings->NlaSecurity = TRUE;
}
- WLog_WARN(TAG, "--sec %s -> /sec:%s", arg->Value, arg->Value);
+ WLog_WARN(TAG, "--sec %s -> /sec:%s", arg->Value, arg->Value);
}
CommandLineSwitchCase(arg, "no-rdp")
{
settings->RdpSecurity = FALSE;
- WLog_WARN(TAG, "--no-rdp -> -sec-rdp");
+ WLog_WARN(TAG, "--no-rdp -> -sec-rdp");
}
CommandLineSwitchCase(arg, "no-tls")
{
settings->TlsSecurity = FALSE;
- WLog_WARN(TAG, "--no-tls -> -sec-tls");
+ WLog_WARN(TAG, "--no-tls -> -sec-tls");
}
CommandLineSwitchCase(arg, "no-nla")
{
settings->NlaSecurity = FALSE;
- WLog_WARN(TAG, "--no-nla -> -sec-nla");
+ WLog_WARN(TAG, "--no-nla -> -sec-nla");
}
CommandLineSwitchCase(arg, "secure-checksum")
{
@@ -865,14 +884,13 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
{
}
CommandLineSwitchEnd(arg)
- }
- while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
- WLog_WARN(TAG, "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname);
+ WLog_WARN(TAG, "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname);
if (settings->ServerPort != 3389)
- WLog_WARN(TAG, " /port:%"PRIu32"", settings->ServerPort);
+ WLog_WARN(TAG, " /port:%" PRIu32 "", settings->ServerPort);
- WLog_WARN(TAG, "");
+ WLog_WARN(TAG, "");
return 0;
}
diff --git a/client/common/compatibility.h b/client/common/compatibility.h
index 83c0d984f..b512a40da 100644
--- a/client/common/compatibility.h
+++ b/client/common/compatibility.h
@@ -24,7 +24,7 @@
#include
FREERDP_LOCAL int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count);
-FREERDP_LOCAL int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings);
+FREERDP_LOCAL int freerdp_client_parse_old_command_line_arguments(int argc, char** argv,
+ rdpSettings* settings);
#endif /* FREERDP_CLIENT_COMMON_COMPATIBILITY_H */
-
diff --git a/client/common/file.c b/client/common/file.c
index 3be1a237e..dbfc65ce8 100644
--- a/client/common/file.c
+++ b/client/common/file.c
@@ -18,7 +18,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include
@@ -40,7 +40,7 @@
#include
#ifdef HAVE_UNISTD_H
-# include
+#include
#endif
#include
@@ -121,7 +121,7 @@ struct rdp_file
DWORD BitmapCacheSize; /* bitmapcachesize */
DWORD BitmapCachePersistEnable; /* bitmapcachepersistenable */
- DWORD ServerPort; /* server port */
+ DWORD ServerPort; /* server port */
LPSTR Username; /* username */
LPSTR Domain; /* domain */
@@ -154,8 +154,8 @@ struct rdp_file
DWORD NegotiateSecurityLayer; /* negotiate security layer */
DWORD EnableCredSSPSupport; /* enablecredsspsupport */
- DWORD RemoteApplicationMode; /* remoteapplicationmode */
- LPSTR LoadBalanceInfo; /* loadbalanceinfo */
+ DWORD RemoteApplicationMode; /* remoteapplicationmode */
+ LPSTR LoadBalanceInfo; /* loadbalanceinfo */
LPSTR RemoteApplicationName; /* remoteapplicationname */
LPSTR RemoteApplicationIcon; /* remoteapplicationicon */
@@ -178,7 +178,7 @@ struct rdp_file
DWORD UseRedirectionServerName; /* use redirection server name */
- LPSTR GatewayAccessToken; /* gatewayaccesstoken */
+ LPSTR GatewayAccessToken; /* gatewayaccesstoken */
LPSTR DrivesToRedirect; /* drivestoredirect */
LPSTR DevicesToRedirect; /* devicestoredirect */
@@ -211,7 +211,7 @@ struct rdp_file
*/
static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, long value,
- SSIZE_T index)
+ SSIZE_T index)
{
BOOL standard = TRUE;
#ifdef DEBUG_CLIENT_FILE
@@ -371,15 +371,15 @@ static BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name,
}
static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file, const char* name,
- const char* value, SSIZE_T index)
+ const char* value, SSIZE_T index)
{
char* endptr;
long ivalue;
errno = 0;
ivalue = strtol(value, &endptr, 0);
- if ((endptr == NULL) || (errno != 0) || (endptr == value) ||
- (ivalue > INT32_MAX) || (ivalue < INT32_MIN))
+ if ((endptr == NULL) || (errno != 0) || (endptr == value) || (ivalue > INT32_MAX) ||
+ (ivalue < INT32_MIN))
{
if (file->flags & RDP_FILE_FLAG_PARSE_INT_RELAXED)
{
@@ -407,7 +407,7 @@ static BOOL freerdp_client_parse_rdp_file_integer(rdpFile* file, const char* nam
*/
static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value,
- SSIZE_T index)
+ SSIZE_T index)
{
int standard = 0;
LPSTR* tmp = NULL;
@@ -551,7 +551,8 @@ static SSIZE_T freerdp_client_parse_rdp_file_add_line(rdpFile* file, const char*
return index;
}
-static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value, SSIZE_T index)
+static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value,
+ SSIZE_T index)
{
BOOL ret = TRUE;
char* valueA = _strdup(value);
@@ -593,10 +594,10 @@ static BOOL trim(char** strptr)
return TRUE;
end = str + strlen(str) - 1;
- while(isspace(*str))
+ while (isspace(*str))
str++;
- while((end > str) && isspace(*end))
+ while ((end > str) && isspace(*end))
end--;
end[1] = '\0';
if (start == str)
@@ -844,12 +845,14 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_
#define SETTING_MODIFIED(_settings, _field) \
(WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field])
#define SETTING_MODIFIED_SET(_target, _settings, _field) \
- if SETTING_MODIFIED(_settings, _field) \
- _target = _settings->_field
+ if \
+ SETTING_MODIFIED(_settings, _field) \
+ _target = _settings->_field
#define SETTING_MODIFIED_SET_BOOL(_target, _settings, _field) \
- if SETTING_MODIFIED(_settings, _field) \
- _target = _settings->_field ? 1 : 0
+ if \
+ SETTING_MODIFIED(_settings, _field) \
+ _target = _settings->_field ? 1 : 0
#define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) \
do \
@@ -980,7 +983,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static SSIZE_T freerdp_client_write_setting_to_buffer(char** buffer, size_t* bufferSize,
- const char* fmt, ...)
+ const char* fmt, ...)
{
va_list ap;
SSIZE_T len;
@@ -1031,87 +1034,88 @@ size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, s
if ((!buffer || !size) && (buffer || size))
return 0;
-#define WRITE_SETTING_(fmt_, param_) \
- { \
+#define WRITE_SETTING_(fmt_, param_) \
+ { \
SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size, fmt_, param_); \
- if (res < 0) \
- return 0; \
+ if (res < 0) \
+ return 0; \
totalSize += (size_t)res; \
}
#define WRITE_SETTING_INT(fmt_, param_) \
if (~(param_)) \
- WRITE_SETTING_(fmt_, param_)
+ WRITE_SETTING_(fmt_, param_)
#define WRITE_SETTING_STR(fmt_, param_) \
if (~(size_t)(param_)) \
- WRITE_SETTING_(fmt_, param_)
+ WRITE_SETTING_(fmt_, param_)
/* integer parameters */
- WRITE_SETTING_INT("use multimon:i:%"PRIu32, file->UseMultiMon);
- WRITE_SETTING_INT("screen mode id:i:%"PRIu32, file->ScreenModeId);
- WRITE_SETTING_INT("span monitors:i:%"PRIu32, file->SpanMonitors);
- WRITE_SETTING_INT("smart sizing:i:%"PRIu32, file->SmartSizing);
- WRITE_SETTING_INT("enablesuperpan:i:%"PRIu32, file->EnableSuperSpan);
- WRITE_SETTING_INT("superpanaccelerationfactor:i:%"PRIu32, file->SuperSpanAccelerationFactor);
- WRITE_SETTING_INT("desktopwidth:i:%"PRIu32, file->DesktopWidth);
- WRITE_SETTING_INT("desktopheight:i:%"PRIu32, file->DesktopHeight);
- WRITE_SETTING_INT("desktop size id:i:%"PRIu32, file->DesktopSizeId);
- WRITE_SETTING_INT("session bpp:i:%"PRIu32, file->SessionBpp);
- WRITE_SETTING_INT("compression:i:%"PRIu32, file->Compression);
- WRITE_SETTING_INT("keyboardhook:i:%"PRIu32, file->KeyboardHook);
- WRITE_SETTING_INT("disable ctrl+alt+del:i:%"PRIu32, file->DisableCtrlAltDel);
- WRITE_SETTING_INT("audiomode:i:%"PRIu32, file->AudioMode);
- WRITE_SETTING_INT("audioqualitymode:i:%"PRIu32, file->AudioQualityMode);
- WRITE_SETTING_INT("audiocapturemode:i:%"PRIu32, file->AudioCaptureMode);
- WRITE_SETTING_INT("videoplaybackmode:i:%"PRIu32, file->VideoPlaybackMode);
- WRITE_SETTING_INT("connection type:i:%"PRIu32, file->ConnectionType);
- WRITE_SETTING_INT("networkautodetect:i:%"PRIu32, file->NetworkAutoDetect);
- WRITE_SETTING_INT("bandwidthautodetect:i:%"PRIu32, file->BandwidthAutoDetect);
- WRITE_SETTING_INT("pinconnectionbar:i:%"PRIu32, file->PinConnectionBar);
- WRITE_SETTING_INT("displayconnectionbar:i:%"PRIu32, file->DisplayConnectionBar);
- WRITE_SETTING_INT("workspaceid:i:%"PRIu32, file->WorkspaceId);
- WRITE_SETTING_INT("enableworkspacereconnect:i:%"PRIu32, file->EnableWorkspaceReconnect);
- WRITE_SETTING_INT("disable wallpaper:i:%"PRIu32, file->DisableWallpaper);
- WRITE_SETTING_INT("allow font smoothing:i:%"PRIu32, file->AllowFontSmoothing);
- WRITE_SETTING_INT("allow desktop composition:i:%"PRIu32, file->AllowDesktopComposition);
- WRITE_SETTING_INT("disable full window drag:i:%"PRIu32, file->DisableFullWindowDrag);
- WRITE_SETTING_INT("disable menu anims:i:%"PRIu32, file->DisableMenuAnims);
- WRITE_SETTING_INT("disable themes:i:%"PRIu32, file->DisableThemes);
- WRITE_SETTING_INT("disable cursor setting:i:%"PRIu32, file->DisableCursorSetting);
- WRITE_SETTING_INT("bitmapcachesize:i:%"PRIu32, file->BitmapCacheSize);
- WRITE_SETTING_INT("bitmapcachepersistenable:i:%"PRIu32, file->BitmapCachePersistEnable);
- WRITE_SETTING_INT("server port:i:%"PRIu32, file->ServerPort);
- WRITE_SETTING_INT("redirectdrives:i:%"PRIu32, file->RedirectDrives);
- WRITE_SETTING_INT("redirectprinters:i:%"PRIu32, file->RedirectPrinters);
- WRITE_SETTING_INT("redirectcomports:i:%"PRIu32, file->RedirectComPorts);
- WRITE_SETTING_INT("redirectsmartcards:i:%"PRIu32, file->RedirectSmartCards);
- WRITE_SETTING_INT("redirectclipboard:i:%"PRIu32, file->RedirectClipboard);
- WRITE_SETTING_INT("redirectposdevices:i:%"PRIu32, file->RedirectPosDevices);
- WRITE_SETTING_INT("redirectdirectx:i:%"PRIu32, file->RedirectDirectX);
- WRITE_SETTING_INT("disableprinterredirection:i:%"PRIu32, file->DisablePrinterRedirection);
- WRITE_SETTING_INT("disableclipboardredirection:i:%"PRIu32, file->DisableClipboardRedirection);
- WRITE_SETTING_INT("connect to console:i:%"PRIu32, file->ConnectToConsole);
- WRITE_SETTING_INT("administrative session:i:%"PRIu32, file->AdministrativeSession);
- WRITE_SETTING_INT("autoreconnection enabled:i:%"PRIu32, file->AutoReconnectionEnabled);
- WRITE_SETTING_INT("autoreconnect max retries:i:%"PRIu32, file->AutoReconnectMaxRetries);
- WRITE_SETTING_INT("public mode:i:%"PRIu32, file->PublicMode);
- WRITE_SETTING_INT("authentication level:i:%"PRId32, file->AuthenticationLevel);
- WRITE_SETTING_INT("promptcredentialonce:i:%"PRIu32, file->PromptCredentialOnce);
- WRITE_SETTING_INT("prompt for credentials:i:%"PRIu32, file->PromptForCredentials);
- WRITE_SETTING_INT("negotiate security layer:i:%"PRIu32, file->NegotiateSecurityLayer);
- WRITE_SETTING_INT("enablecredsspsupport:i:%"PRIu32, file->EnableCredSSPSupport);
- WRITE_SETTING_INT("remoteapplicationmode:i:%"PRIu32, file->RemoteApplicationMode);
- WRITE_SETTING_INT("remoteapplicationexpandcmdline:i:%"PRIu32, file->RemoteApplicationExpandCmdLine);
- WRITE_SETTING_INT("remoteapplicationexpandworkingdir:i:%"PRIu32,
- file->RemoteApplicationExpandWorkingDir);
- WRITE_SETTING_INT("disableconnectionsharing:i:%"PRIu32, file->DisableConnectionSharing);
- WRITE_SETTING_INT("disableremoteappcapscheck:i:%"PRIu32, file->DisableRemoteAppCapsCheck);
- WRITE_SETTING_INT("gatewayusagemethod:i:%"PRIu32, file->GatewayUsageMethod);
- WRITE_SETTING_INT("gatewayprofileusagemethod:i:%"PRIu32, file->GatewayProfileUsageMethod);
- WRITE_SETTING_INT("gatewaycredentialssource:i:%"PRIu32, file->GatewayCredentialsSource);
- WRITE_SETTING_INT("use redirection server name:i:%"PRIu32, file->UseRedirectionServerName);
- WRITE_SETTING_INT("rdgiskdcproxy:i:%"PRIu32, file->RdgIsKdcProxy);
+ WRITE_SETTING_INT("use multimon:i:%" PRIu32, file->UseMultiMon);
+ WRITE_SETTING_INT("screen mode id:i:%" PRIu32, file->ScreenModeId);
+ WRITE_SETTING_INT("span monitors:i:%" PRIu32, file->SpanMonitors);
+ WRITE_SETTING_INT("smart sizing:i:%" PRIu32, file->SmartSizing);
+ WRITE_SETTING_INT("enablesuperpan:i:%" PRIu32, file->EnableSuperSpan);
+ WRITE_SETTING_INT("superpanaccelerationfactor:i:%" PRIu32, file->SuperSpanAccelerationFactor);
+ WRITE_SETTING_INT("desktopwidth:i:%" PRIu32, file->DesktopWidth);
+ WRITE_SETTING_INT("desktopheight:i:%" PRIu32, file->DesktopHeight);
+ WRITE_SETTING_INT("desktop size id:i:%" PRIu32, file->DesktopSizeId);
+ WRITE_SETTING_INT("session bpp:i:%" PRIu32, file->SessionBpp);
+ WRITE_SETTING_INT("compression:i:%" PRIu32, file->Compression);
+ WRITE_SETTING_INT("keyboardhook:i:%" PRIu32, file->KeyboardHook);
+ WRITE_SETTING_INT("disable ctrl+alt+del:i:%" PRIu32, file->DisableCtrlAltDel);
+ WRITE_SETTING_INT("audiomode:i:%" PRIu32, file->AudioMode);
+ WRITE_SETTING_INT("audioqualitymode:i:%" PRIu32, file->AudioQualityMode);
+ WRITE_SETTING_INT("audiocapturemode:i:%" PRIu32, file->AudioCaptureMode);
+ WRITE_SETTING_INT("videoplaybackmode:i:%" PRIu32, file->VideoPlaybackMode);
+ WRITE_SETTING_INT("connection type:i:%" PRIu32, file->ConnectionType);
+ WRITE_SETTING_INT("networkautodetect:i:%" PRIu32, file->NetworkAutoDetect);
+ WRITE_SETTING_INT("bandwidthautodetect:i:%" PRIu32, file->BandwidthAutoDetect);
+ WRITE_SETTING_INT("pinconnectionbar:i:%" PRIu32, file->PinConnectionBar);
+ WRITE_SETTING_INT("displayconnectionbar:i:%" PRIu32, file->DisplayConnectionBar);
+ WRITE_SETTING_INT("workspaceid:i:%" PRIu32, file->WorkspaceId);
+ WRITE_SETTING_INT("enableworkspacereconnect:i:%" PRIu32, file->EnableWorkspaceReconnect);
+ WRITE_SETTING_INT("disable wallpaper:i:%" PRIu32, file->DisableWallpaper);
+ WRITE_SETTING_INT("allow font smoothing:i:%" PRIu32, file->AllowFontSmoothing);
+ WRITE_SETTING_INT("allow desktop composition:i:%" PRIu32, file->AllowDesktopComposition);
+ WRITE_SETTING_INT("disable full window drag:i:%" PRIu32, file->DisableFullWindowDrag);
+ WRITE_SETTING_INT("disable menu anims:i:%" PRIu32, file->DisableMenuAnims);
+ WRITE_SETTING_INT("disable themes:i:%" PRIu32, file->DisableThemes);
+ WRITE_SETTING_INT("disable cursor setting:i:%" PRIu32, file->DisableCursorSetting);
+ WRITE_SETTING_INT("bitmapcachesize:i:%" PRIu32, file->BitmapCacheSize);
+ WRITE_SETTING_INT("bitmapcachepersistenable:i:%" PRIu32, file->BitmapCachePersistEnable);
+ WRITE_SETTING_INT("server port:i:%" PRIu32, file->ServerPort);
+ WRITE_SETTING_INT("redirectdrives:i:%" PRIu32, file->RedirectDrives);
+ WRITE_SETTING_INT("redirectprinters:i:%" PRIu32, file->RedirectPrinters);
+ WRITE_SETTING_INT("redirectcomports:i:%" PRIu32, file->RedirectComPorts);
+ WRITE_SETTING_INT("redirectsmartcards:i:%" PRIu32, file->RedirectSmartCards);
+ WRITE_SETTING_INT("redirectclipboard:i:%" PRIu32, file->RedirectClipboard);
+ WRITE_SETTING_INT("redirectposdevices:i:%" PRIu32, file->RedirectPosDevices);
+ WRITE_SETTING_INT("redirectdirectx:i:%" PRIu32, file->RedirectDirectX);
+ WRITE_SETTING_INT("disableprinterredirection:i:%" PRIu32, file->DisablePrinterRedirection);
+ WRITE_SETTING_INT("disableclipboardredirection:i:%" PRIu32, file->DisableClipboardRedirection);
+ WRITE_SETTING_INT("connect to console:i:%" PRIu32, file->ConnectToConsole);
+ WRITE_SETTING_INT("administrative session:i:%" PRIu32, file->AdministrativeSession);
+ WRITE_SETTING_INT("autoreconnection enabled:i:%" PRIu32, file->AutoReconnectionEnabled);
+ WRITE_SETTING_INT("autoreconnect max retries:i:%" PRIu32, file->AutoReconnectMaxRetries);
+ WRITE_SETTING_INT("public mode:i:%" PRIu32, file->PublicMode);
+ WRITE_SETTING_INT("authentication level:i:%" PRId32, file->AuthenticationLevel);
+ WRITE_SETTING_INT("promptcredentialonce:i:%" PRIu32, file->PromptCredentialOnce);
+ WRITE_SETTING_INT("prompt for credentials:i:%" PRIu32, file->PromptForCredentials);
+ WRITE_SETTING_INT("negotiate security layer:i:%" PRIu32, file->NegotiateSecurityLayer);
+ WRITE_SETTING_INT("enablecredsspsupport:i:%" PRIu32, file->EnableCredSSPSupport);
+ WRITE_SETTING_INT("remoteapplicationmode:i:%" PRIu32, file->RemoteApplicationMode);
+ WRITE_SETTING_INT("remoteapplicationexpandcmdline:i:%" PRIu32,
+ file->RemoteApplicationExpandCmdLine);
+ WRITE_SETTING_INT("remoteapplicationexpandworkingdir:i:%" PRIu32,
+ file->RemoteApplicationExpandWorkingDir);
+ WRITE_SETTING_INT("disableconnectionsharing:i:%" PRIu32, file->DisableConnectionSharing);
+ WRITE_SETTING_INT("disableremoteappcapscheck:i:%" PRIu32, file->DisableRemoteAppCapsCheck);
+ WRITE_SETTING_INT("gatewayusagemethod:i:%" PRIu32, file->GatewayUsageMethod);
+ WRITE_SETTING_INT("gatewayprofileusagemethod:i:%" PRIu32, file->GatewayProfileUsageMethod);
+ WRITE_SETTING_INT("gatewaycredentialssource:i:%" PRIu32, file->GatewayCredentialsSource);
+ WRITE_SETTING_INT("use redirection server name:i:%" PRIu32, file->UseRedirectionServerName);
+ WRITE_SETTING_INT("rdgiskdcproxy:i:%" PRIu32, file->RdgIsKdcProxy);
/* string parameters */
WRITE_SETTING_STR("username:s:%s", file->Username);
@@ -1234,27 +1238,29 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->ConnectToConsole)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, file->ConnectToConsole != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession,
+ file->ConnectToConsole != 0))
return FALSE;
}
if (~file->AdministrativeSession)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession,
- file->AdministrativeSession != 0))
+ file->AdministrativeSession != 0))
return FALSE;
}
if (~file->NegotiateSecurityLayer)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer,
- file->NegotiateSecurityLayer != 0))
+ file->NegotiateSecurityLayer != 0))
return FALSE;
}
if (~file->EnableCredSSPSupport)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity,
+ file->EnableCredSSPSupport != 0))
return FALSE;
}
@@ -1335,7 +1341,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->AudioMode)
{
- switch(file->AudioMode)
+ switch (file->AudioMode)
{
case AUDIO_MODE_REDIRECT:
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE))
@@ -1367,7 +1373,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->Compression)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, file->Compression != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled,
+ file->Compression != 0))
return FALSE;
}
@@ -1407,21 +1414,21 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->PromptCredentialOnce)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayUseSameCredentials,
- file->PromptCredentialOnce != 0))
+ file->PromptCredentialOnce != 0))
return FALSE;
}
if (~file->PromptForCredentials)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_PromptForCredentials,
- file->PromptForCredentials != 0))
+ file->PromptForCredentials != 0))
return FALSE;
}
if (~file->RemoteApplicationMode)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteApplicationMode,
- file->RemoteApplicationMode != 0))
+ file->RemoteApplicationMode != 0))
return FALSE;
}
@@ -1482,26 +1489,28 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->AllowFontSmoothing)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing,
- file->AllowFontSmoothing != 0))
+ file->AllowFontSmoothing != 0))
return FALSE;
}
if (~file->DisableWallpaper)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper,
+ file->DisableWallpaper != 0))
return FALSE;
}
if (~file->DisableFullWindowDrag)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag,
- file->DisableFullWindowDrag != 0))
+ file->DisableFullWindowDrag != 0))
return FALSE;
}
if (~file->DisableMenuAnims)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims,
+ file->DisableMenuAnims != 0))
return FALSE;
}
@@ -1514,14 +1523,14 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->AllowDesktopComposition)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition,
- file->AllowDesktopComposition != 0))
+ file->AllowDesktopComposition != 0))
return FALSE;
}
if (~file->BitmapCachePersistEnable)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled,
- file->BitmapCachePersistEnable != 0))
+ file->BitmapCachePersistEnable != 0))
return FALSE;
}
@@ -1540,7 +1549,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
return FALSE;
setDefaultConnectionType = FALSE;
}
- if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, file->BandwidthAutoDetect != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
+ file->BandwidthAutoDetect != 0))
return FALSE;
}
@@ -1550,23 +1560,30 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
{
if (file->BandwidthAutoDetect != CONNECTION_TYPE_AUTODETECT)
{
- WLog_WARN(TAG, "Got networkautodetect:i:%"PRIu32" and bandwidthautodetect:i:%"PRIu32". Correcting to bandwidthautodetect:i:%"PRIu32,
- file->NetworkAutoDetect, file->BandwidthAutoDetect, CONNECTION_TYPE_AUTODETECT);
- WLog_WARN(TAG, "Add bandwidthautodetect:i:%"PRIu32" to your RDP file to eliminate this warning.", CONNECTION_TYPE_AUTODETECT);
+ WLog_WARN(TAG,
+ "Got networkautodetect:i:%" PRIu32 " and bandwidthautodetect:i:%" PRIu32
+ ". Correcting to bandwidthautodetect:i:%" PRIu32,
+ file->NetworkAutoDetect, file->BandwidthAutoDetect,
+ CONNECTION_TYPE_AUTODETECT);
+ WLog_WARN(TAG,
+ "Add bandwidthautodetect:i:%" PRIu32
+ " to your RDP file to eliminate this warning.",
+ CONNECTION_TYPE_AUTODETECT);
}
if (!freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT))
return FALSE;
setDefaultConnectionType = FALSE;
}
- if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, file->NetworkAutoDetect == 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect,
+ file->NetworkAutoDetect == 0))
return FALSE;
}
if (~file->AutoReconnectionEnabled)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoReconnectionEnabled,
- file->AutoReconnectionEnabled != 0))
+ file->AutoReconnectionEnabled != 0))
return FALSE;
}
@@ -1580,20 +1597,21 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->RedirectSmartCards)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards,
- file->RedirectSmartCards != 0))
+ file->RedirectSmartCards != 0))
return FALSE;
}
if (~file->RedirectClipboard)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard,
- file->RedirectClipboard != 0))
+ file->RedirectClipboard != 0))
return FALSE;
}
if (~file->RedirectPrinters)
{
- if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters, file->RedirectPrinters != 0))
+ if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters,
+ file->RedirectPrinters != 0))
return FALSE;
}
@@ -1606,18 +1624,18 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->RedirectPosDevices)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
- file->RedirectComPorts != 0) ||
+ file->RedirectComPorts != 0) ||
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
- file->RedirectComPorts != 0))
+ file->RedirectComPorts != 0))
return FALSE;
}
if (~file->RedirectComPorts)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
- file->RedirectComPorts != 0) ||
+ file->RedirectComPorts != 0) ||
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
- file->RedirectComPorts != 0))
+ file->RedirectComPorts != 0))
return FALSE;
}
@@ -1658,7 +1676,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~((size_t)file->DrivesToRedirect))
{
- if (!freerdp_settings_set_string(settings, FreeRDP_DrivesToRedirect, file->DrivesToRedirect))
+ if (!freerdp_settings_set_string(settings, FreeRDP_DrivesToRedirect,
+ file->DrivesToRedirect))
return FALSE;
}
@@ -1682,7 +1701,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
char* ConnectionFile = settings->ConnectionFile;
settings->ConnectionFile = NULL;
- if (freerdp_client_settings_parse_command_line(settings, (int)file->argc, file->argv, FALSE) < 0)
+ if (freerdp_client_settings_parse_command_line(settings, (int)file->argc, file->argv,
+ FALSE) < 0)
return FALSE;
settings->ConnectionFile = ConnectionFile;
diff --git a/client/common/test/TestClientChannels.c b/client/common/test/TestClientChannels.c
index b63cf983b..d6a55d319 100644
--- a/client/common/test/TestClientChannels.c
+++ b/client/common/test/TestClientChannels.c
@@ -23,8 +23,8 @@ int TestClientChannels(int argc, char* argv[])
{
pAddin = ppAddins[index];
- printf("Addin: Name: %s Subsystem: %s Type: %s\n",
- pAddin->cName, pAddin->cSubsystem, pAddin->cType);
+ printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem,
+ pAddin->cType);
}
freerdp_channels_addin_list_free(ppAddins);
@@ -36,8 +36,8 @@ int TestClientChannels(int argc, char* argv[])
{
pAddin = ppAddins[index];
- printf("Addin: Name: %s Subsystem: %s Type: %s\n",
- pAddin->cName, pAddin->cSubsystem, pAddin->cType);
+ printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem,
+ pAddin->cType);
}
freerdp_channels_addin_list_free(ppAddins);
@@ -49,8 +49,8 @@ int TestClientChannels(int argc, char* argv[])
{
pAddin = ppAddins[index];
- printf("Addin: Name: %s Subsystem: %s Type: %s\n",
- pAddin->cName, pAddin->cSubsystem, pAddin->cType);
+ printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem,
+ pAddin->cType);
}
freerdp_channels_addin_list_free(ppAddins);
@@ -61,8 +61,8 @@ int TestClientChannels(int argc, char* argv[])
{
pAddin = ppAddins[index];
- printf("Addin: Name: %s Subsystem: %s Type: %s\n",
- pAddin->cName, pAddin->cSubsystem, pAddin->cType);
+ printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem,
+ pAddin->cType);
}
freerdp_channels_addin_list_free(ppAddins);
@@ -76,8 +76,8 @@ int TestClientChannels(int argc, char* argv[])
{
pAddin = ppAddins[index];
- printf("Addin: Name: %s Subsystem: %s Type: %s\n",
- pAddin->cName, pAddin->cSubsystem, pAddin->cType);
+ printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem,
+ pAddin->cType);
}
freerdp_channels_addin_list_free(ppAddins);
diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c
index ccf23b228..55754f7ba 100644
--- a/client/common/test/TestClientCmdLine.c
+++ b/client/common/test/TestClientCmdLine.c
@@ -6,34 +6,34 @@
#include
#include
-
typedef BOOL (*validate_settings_pr)(rdpSettings* settings);
#define printref() printf("%s:%d: in function %-40s:", __FILE__, __LINE__, __FUNCTION__)
-#define ERROR(format, ...) \
- do{ \
- fprintf(stderr, format, ##__VA_ARGS__); \
- printref(); \
- printf(format, ##__VA_ARGS__); \
- fflush(stdout); \
- }while(0)
-
-#define FAILURE(format, ...) \
- do{ \
- printref(); \
- printf(" FAILURE "); \
- printf(format, ##__VA_ARGS__); \
- fflush(stdout); \
- }while(0)
+#define ERROR(format, ...) \
+ do \
+ { \
+ fprintf(stderr, format, ##__VA_ARGS__); \
+ printref(); \
+ printf(format, ##__VA_ARGS__); \
+ fflush(stdout); \
+ } while (0)
+#define FAILURE(format, ...) \
+ do \
+ { \
+ printref(); \
+ printf(" FAILURE "); \
+ printf(format, ##__VA_ARGS__); \
+ fflush(stdout); \
+ } while (0)
static void print_test_title(int argc, char** argv)
{
int i;
printf("Running test:");
- for (i = 0; i < argc; i ++)
+ for (i = 0; i < argc; i++)
{
printf(" %s", argv[i]);
}
@@ -41,8 +41,8 @@ static void print_test_title(int argc, char** argv)
printf("\n");
}
-static INLINE BOOL testcase(const char* name, char** argv, size_t argc,
- int expected_return, validate_settings_pr validate_settings)
+static INLINE BOOL testcase(const char* name, char** argv, size_t argc, int expected_return,
+ validate_settings_pr validate_settings)
{
int status;
BOOL valid_settings = TRUE;
@@ -113,117 +113,96 @@ typedef struct
struct
{
int index;
- const char* expected_value;
+ const char* expected_value;
} modified_arguments[8];
} test;
-static test tests[] =
-{
- {
- COMMAND_LINE_STATUS_PRINT_HELP, check_settings_smartcard_no_redirection,
- {"testfreerdp", "--help", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT_HELP, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/help", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT_HELP, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-help", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT_VERSION, check_settings_smartcard_no_redirection,
- {"testfreerdp", "--version", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT_VERSION, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/version", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT_VERSION, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-version", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-v", "test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "--v", "test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/v:test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data", "disk:media:"DRIVE_REDIRECT_PATH, "--", "test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/sound", "/drive:media,"DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0},
- {{0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-u", "test", "-p", "test", "test.freerdp.com", 0},
- {{4, "****"}, {0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com", 0},
- {{4, "****"}, {0}}
- },
- {
- 0, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/u:test", "/p:test", "/v:test.freerdp.com", 0},
- {{2, "/p:****"}, {0}}
- },
- {
- COMMAND_LINE_ERROR_NO_KEYWORD, check_settings_smartcard_no_redirection,
- {"testfreerdp", "-invalid", 0},
- {{0}}
- },
- {
- COMMAND_LINE_ERROR_NO_KEYWORD, check_settings_smartcard_no_redirection,
- {"testfreerdp", "--invalid", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/kbd-list", 0},
- {{0}}
- },
- {
- COMMAND_LINE_STATUS_PRINT, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/monitor-list", 0},
- {{0}}
- },
- {
- COMMAND_LINE_ERROR, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/sound", "/drive:media:"DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0},
- {{0}}
- },
- {
- COMMAND_LINE_ERROR, check_settings_smartcard_no_redirection,
- {"testfreerdp", "/sound", "/drive:media,/foo/bar/blabla", "/v:test.freerdp.com", 0},
- {{0}}
- },
+static test tests[] = {
+ { COMMAND_LINE_STATUS_PRINT_HELP,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "--help", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT_HELP,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/help", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT_HELP,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-help", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT_VERSION,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "--version", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT_VERSION,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/version", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT_VERSION,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-version", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-v", "test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "--v", "test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/v:test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data",
+ "disk:media:" DRIVE_REDIRECT_PATH, "--", "test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/sound", "/drive:media," DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0 },
+ { { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-u", "test", "-p", "test", "test.freerdp.com", 0 },
+ { { 4, "****" }, { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com", 0 },
+ { { 4, "****" }, { 0 } } },
+ { 0,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/u:test", "/p:test", "/v:test.freerdp.com", 0 },
+ { { 2, "/p:****" }, { 0 } } },
+ { COMMAND_LINE_ERROR_NO_KEYWORD,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "-invalid", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_ERROR_NO_KEYWORD,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "--invalid", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/kbd-list", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_STATUS_PRINT,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/monitor-list", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_ERROR,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/sound", "/drive:media:" DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0 },
+ { { 0 } } },
+ { COMMAND_LINE_ERROR,
+ check_settings_smartcard_no_redirection,
+ { "testfreerdp", "/sound", "/drive:media,/foo/bar/blabla", "/v:test.freerdp.com", 0 },
+ { { 0 } } },
#if 0
{
@@ -234,13 +213,12 @@ static test tests[] =
#endif
};
-
void check_modified_arguments(test* test, char** command_line, int* rc)
{
int k;
- const char* expected_argument;
+ const char* expected_argument;
- for (k = 0; (expected_argument = test->modified_arguments[k].expected_value); k ++)
+ for (k = 0; (expected_argument = test->modified_arguments[k].expected_value); k++)
{
int index = test->modified_arguments[k].index;
char* actual_argument = command_line[index];
@@ -248,10 +226,10 @@ void check_modified_arguments(test* test, char** command_line, int* rc)
if (0 != strcmp(actual_argument, expected_argument))
{
printref();
- printf("Failure: overridden argument %d is %s but it should be %s\n",
- index, actual_argument, expected_argument);
+ printf("Failure: overridden argument %d is %s but it should be %s\n", index,
+ actual_argument, expected_argument);
fflush(stdout);
- * rc = -1;
+ *rc = -1;
}
}
}
@@ -263,24 +241,24 @@ int TestClientCmdLine(int argc, char* argv[])
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i ++)
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
{
int failure = 0;
char** command_line = string_list_copy(tests[i].command_line);
- if (!testcase(__FUNCTION__,
- command_line, string_list_length((const char * const*)command_line),
+ if (!testcase(__FUNCTION__, command_line,
+ string_list_length((const char* const*)command_line),
tests[i].expected_status, tests[i].validate_settings))
{
FAILURE("parsing arguments.\n");
failure = 1;
}
- check_modified_arguments(& tests[i], command_line, & failure);
+ check_modified_arguments(&tests[i], command_line, &failure);
if (failure)
{
- string_list_print(stdout, (const char * const*)command_line);
+ string_list_print(stdout, (const char* const*)command_line);
rc = -1;
}
diff --git a/client/common/test/TestClientRdpFile.c b/client/common/test/TestClientRdpFile.c
index c9d852744..ca4a79499 100644
--- a/client/common/test/TestClientRdpFile.c
+++ b/client/common/test/TestClientRdpFile.c
@@ -7,261 +7,209 @@
#include
-static const BYTE testRdpFileUTF16[] =
-{
- 0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00,
- 0x6e, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
- 0x20, 0x00, 0x69, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00,
- 0x20, 0x00, 0x6d, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x69, 0x00,
- 0x6d, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00,
- 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x77, 0x00, 0x69, 0x00,
- 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x31, 0x00, 0x39, 0x00, 0x32, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
- 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00,
- 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00,
- 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00,
- 0x38, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x73, 0x00, 0x65, 0x00,
- 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00,
- 0x62, 0x00, 0x70, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x33, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x69, 0x00,
- 0x6e, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x74, 0x00,
- 0x72, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x2c, 0x00,
- 0x31, 0x00, 0x2c, 0x00, 0x35, 0x00, 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00,
- 0x32, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x33, 0x00,
- 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00, 0x38, 0x00, 0x31, 0x00, 0x31, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00,
- 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
- 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x79, 0x00, 0x62, 0x00, 0x6f, 0x00,
- 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6f, 0x00,
- 0x6b, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00,
- 0x63, 0x00, 0x61, 0x00, 0x70, 0x00, 0x74, 0x00, 0x75, 0x00, 0x72, 0x00,
- 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x76, 0x00,
- 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6c, 0x00,
- 0x61, 0x00, 0x79, 0x00, 0x62, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00,
- 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00,
- 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
- 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
- 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x70, 0x00,
- 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x37, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x77, 0x00, 0x6f, 0x00,
- 0x72, 0x00, 0x6b, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00,
- 0x64, 0x00, 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
- 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
- 0x62, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x77, 0x00, 0x69, 0x00,
- 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00,
- 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00,
- 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6c, 0x00,
- 0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
- 0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00,
- 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00,
- 0x6b, 0x00, 0x73, 0x00, 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00,
- 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00,
- 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x77, 0x00,
- 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x70, 0x00, 0x61, 0x00, 0x70, 0x00,
- 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
- 0x77, 0x00, 0x20, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00,
- 0x20, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
- 0x68, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00,
- 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00,
- 0x6c, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00,
- 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x20, 0x00,
- 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00,
- 0x69, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
- 0x20, 0x00, 0x66, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00,
- 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x77, 0x00,
- 0x20, 0x00, 0x64, 0x00, 0x72, 0x00, 0x61, 0x00, 0x67, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
- 0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x20, 0x00,
- 0x61, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
- 0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00,
- 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
- 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00,
- 0x73, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00,
- 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x62, 0x00,
- 0x69, 0x00, 0x74, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x63, 0x00,
- 0x61, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x70, 0x00, 0x65, 0x00,
- 0x72, 0x00, 0x73, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00,
- 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x66, 0x00,
- 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x61, 0x00, 0x64, 0x00,
- 0x64, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x3a, 0x00,
- 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x42, 0x00, 0x31, 0x00,
- 0x2d, 0x00, 0x57, 0x00, 0x37, 0x00, 0x2d, 0x00, 0x44, 0x00, 0x4d, 0x00,
- 0x2d, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00,
- 0x62, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00,
- 0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00,
- 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
- 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00,
- 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x72, 0x00, 0x69, 0x00,
- 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00,
- 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
- 0x74, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00,
- 0x72, 0x00, 0x74, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x73, 0x00,
- 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x63, 0x00, 0x61, 0x00,
- 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x63, 0x00,
- 0x6c, 0x00, 0x69, 0x00, 0x70, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00,
- 0x72, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00,
- 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x6f, 0x00,
- 0x73, 0x00, 0x64, 0x00, 0x65, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00,
- 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00,
- 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
- 0x20, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00,
- 0x65, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x68, 0x00,
- 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00,
- 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6c, 0x00,
- 0x65, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x69, 0x00,
- 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00,
- 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x20, 0x00, 0x66, 0x00,
- 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
- 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
- 0x6c, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6f, 0x00,
- 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00,
- 0x73, 0x00, 0x65, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00, 0x69, 0x00,
- 0x74, 0x00, 0x79, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x79, 0x00,
- 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00,
- 0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6c, 0x00,
- 0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00,
- 0x6e, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00,
- 0x6c, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
- 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00,
- 0x6c, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00,
- 0x0a, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00,
- 0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x69, 0x00,
- 0x6e, 0x00, 0x67, 0x00, 0x20, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x79, 0x00,
- 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00,
- 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00,
- 0x68, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6e, 0x00, 0x61, 0x00,
- 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
- 0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x32, 0x00,
- 0x4b, 0x00, 0x38, 0x00, 0x52, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x47, 0x00,
- 0x57, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x62, 0x00, 0x31, 0x00,
- 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00,
- 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
- 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x75, 0x00, 0x73, 0x00, 0x61, 0x00,
- 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00,
- 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
- 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
- 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
- 0x6c, 0x00, 0x73, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x72, 0x00,
- 0x63, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
- 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
- 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x75, 0x00, 0x73, 0x00,
- 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00,
- 0x68, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
- 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
- 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
- 0x6c, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x63, 0x00, 0x65, 0x00, 0x3a, 0x00,
- 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00,
- 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
- 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
- 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00,
- 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00,
- 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x64, 0x00, 0x67, 0x00, 0x69, 0x00,
- 0x73, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00, 0x70, 0x00, 0x72, 0x00,
- 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
- 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00,
- 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x6e, 0x00,
- 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00,
- 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x72, 0x00, 0x69, 0x00, 0x76, 0x00,
- 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00,
- 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
- 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x2a, 0x00, 0x0d, 0x00, 0x0a, 0x00,
- 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
- 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
- 0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x5c, 0x00, 0x4a, 0x00, 0x6f, 0x00,
- 0x68, 0x00, 0x6e, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x65, 0x00, 0x0d, 0x00,
- 0x0a, 0x00
+static const BYTE testRdpFileUTF16[] = {
+ 0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, 0x00,
+ 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x64, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00,
+ 0x20, 0x00, 0x6d, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
+ 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x77, 0x00, 0x69, 0x00,
+ 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x39, 0x00,
+ 0x32, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00,
+ 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00,
+ 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00, 0x38, 0x00, 0x30, 0x00,
+ 0x0d, 0x00, 0x0a, 0x00, 0x73, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x20, 0x00, 0x62, 0x00, 0x70, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x33, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x70, 0x00,
+ 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00,
+ 0x30, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x35, 0x00, 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00,
+ 0x32, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x33, 0x00, 0x35, 0x00, 0x33, 0x00,
+ 0x2c, 0x00, 0x38, 0x00, 0x31, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0x6d, 0x00, 0x70, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00,
+ 0x65, 0x00, 0x79, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x68, 0x00,
+ 0x6f, 0x00, 0x6f, 0x00, 0x6b, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00,
+ 0x70, 0x00, 0x74, 0x00, 0x75, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00,
+ 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x76, 0x00,
+ 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x79, 0x00,
+ 0x62, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
+ 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
+ 0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x70, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x37, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x77, 0x00, 0x6f, 0x00,
+ 0x72, 0x00, 0x6b, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
+ 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
+ 0x0d, 0x00, 0x0a, 0x00, 0x62, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x77, 0x00, 0x69, 0x00,
+ 0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x64, 0x00,
+ 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6c, 0x00,
+ 0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00,
+ 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00,
+ 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x73, 0x00,
+ 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
+ 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x70, 0x00,
+ 0x61, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
+ 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00,
+ 0x66, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x20, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00,
+ 0x6f, 0x00, 0x74, 0x00, 0x68, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00,
+ 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
+ 0x77, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00,
+ 0x70, 0x00, 0x20, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00,
+ 0x69, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
+ 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x66, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00,
+ 0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00, 0x64, 0x00,
+ 0x72, 0x00, 0x61, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
+ 0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00,
+ 0x69, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
+ 0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00,
+ 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00,
+ 0x73, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00, 0x74, 0x00, 0x74, 0x00,
+ 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x62, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x63, 0x00,
+ 0x61, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x70, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00,
+ 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00,
+ 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x66, 0x00,
+ 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x61, 0x00, 0x64, 0x00, 0x64, 0x00, 0x72, 0x00,
+ 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00,
+ 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x37, 0x00, 0x2d, 0x00, 0x44, 0x00, 0x4d, 0x00,
+ 0x2d, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x62, 0x00, 0x31, 0x00,
+ 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x6c, 0x00,
+ 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
+ 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
+ 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x72, 0x00, 0x69, 0x00,
+ 0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
+ 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00,
+ 0x72, 0x00, 0x74, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
+ 0x74, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x63, 0x00, 0x61, 0x00,
+ 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
+ 0x74, 0x00, 0x63, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x70, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00,
+ 0x72, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
+ 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x64, 0x00, 0x65, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00,
+ 0x65, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
+ 0x20, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x64, 0x00,
+ 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
+ 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00,
+ 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x76, 0x00,
+ 0x65, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x20, 0x00, 0x66, 0x00,
+ 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
+ 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00,
+ 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6f, 0x00,
+ 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00,
+ 0x63, 0x00, 0x75, 0x00, 0x72, 0x00, 0x69, 0x00, 0x74, 0x00, 0x79, 0x00, 0x20, 0x00, 0x6c, 0x00,
+ 0x61, 0x00, 0x79, 0x00, 0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
+ 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00,
+ 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00,
+ 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x74, 0x00,
+ 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00,
+ 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00,
+ 0x0a, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x77, 0x00,
+ 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x20, 0x00, 0x64, 0x00,
+ 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x79, 0x00,
+ 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00,
+ 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x74, 0x00,
+ 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
+ 0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x32, 0x00, 0x4b, 0x00, 0x38, 0x00,
+ 0x52, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x47, 0x00, 0x57, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00,
+ 0x62, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00,
+ 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x75, 0x00,
+ 0x73, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00,
+ 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x63, 0x00,
+ 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
+ 0x6c, 0x00, 0x73, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x72, 0x00, 0x63, 0x00, 0x65, 0x00,
+ 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00,
+ 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
+ 0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x75, 0x00, 0x73, 0x00, 0x61, 0x00, 0x67, 0x00,
+ 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00,
+ 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
+ 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x65, 0x00,
+ 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x63, 0x00,
+ 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00,
+ 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
+ 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x73, 0x00,
+ 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00,
+ 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
+ 0x72, 0x00, 0x64, 0x00, 0x67, 0x00, 0x69, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00,
+ 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
+ 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00, 0x70, 0x00, 0x72, 0x00,
+ 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00,
+ 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x72, 0x00, 0x69, 0x00, 0x76, 0x00,
+ 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00,
+ 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x2a, 0x00,
+ 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
+ 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x42, 0x00,
+ 0x31, 0x00, 0x5c, 0x00, 0x4a, 0x00, 0x6f, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x44, 0x00, 0x6f, 0x00,
+ 0x65, 0x00, 0x0d, 0x00, 0x0a, 0x00
};
-static char testRdpFileUTF8[] =
- "screen mode id:i:2\n"
- "use multimon:i:0\n"
- "desktopwidth:i:1920\n"
- "desktopheight:i:1080\n"
- "session bpp:i:32\n"
- "winposstr:s:0,1,553,211,1353,811\n"
- "compression:i:1\n"
- "keyboardhook:i:2\n"
- "audiocapturemode:i:0\n"
- "videoplaybackmode:i:1\n"
- "connection type:i:7\n"
- "networkautodetect:i:1\n"
- "bandwidthautodetect:i:1\n"
- "displayconnectionbar:i:1\n"
- "enableworkspacereconnect:i:0\n"
- "disable wallpaper:i:0\n"
- "allow font smoothing:i:0\n"
- "allow desktop composition:i:0\n"
- "disable full window drag:i:1\n"
- "disable menu anims:i:1\n"
- "disable themes:i:0\n"
- "disable cursor setting:i:0\n"
- "bitmapcachepersistenable:i:1\n"
- "full address:s:LAB1-W7-DM-01.lab1.awake.local\n"
- "alternate full address:s:LAB1-W7-DM-01.lab1.awake.global\n"
- "audiomode:i:0\n"
- "redirectprinters:i:1\n"
- "redirectcomports:i:0\n"
- "redirectsmartcards:i:1\n"
- "redirectclipboard:i:1\n"
- "redirectposdevices:i:0\n"
- "autoreconnection enabled:i:1\n"
- "authentication level:i:2\n"
- "prompt for credentials:i:0\n"
- "negotiate security layer:i:1\n"
- "remoteapplicationmode:i:0\n"
- "alternate shell:s:\n"
- "shell working directory:s:\n"
- "gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n"
- "gatewayusagemethod:i:1\n"
- "gatewaycredentialssource:i:0\n"
- "gatewayprofileusagemethod:i:1\n"
- "promptcredentialonce:i:1\n"
- "use redirection server name:i:0\n"
- "rdgiskdcproxy:i:0\n"
- "kdcproxyname:s:\n"
- "drivestoredirect:s:*\n"
- "username:s:LAB1\\JohnDoe\n"
- "vendor integer:i:123\n"
- "vendor string:s:microsoft\n";
+static char testRdpFileUTF8[] = "screen mode id:i:2\n"
+ "use multimon:i:0\n"
+ "desktopwidth:i:1920\n"
+ "desktopheight:i:1080\n"
+ "session bpp:i:32\n"
+ "winposstr:s:0,1,553,211,1353,811\n"
+ "compression:i:1\n"
+ "keyboardhook:i:2\n"
+ "audiocapturemode:i:0\n"
+ "videoplaybackmode:i:1\n"
+ "connection type:i:7\n"
+ "networkautodetect:i:1\n"
+ "bandwidthautodetect:i:1\n"
+ "displayconnectionbar:i:1\n"
+ "enableworkspacereconnect:i:0\n"
+ "disable wallpaper:i:0\n"
+ "allow font smoothing:i:0\n"
+ "allow desktop composition:i:0\n"
+ "disable full window drag:i:1\n"
+ "disable menu anims:i:1\n"
+ "disable themes:i:0\n"
+ "disable cursor setting:i:0\n"
+ "bitmapcachepersistenable:i:1\n"
+ "full address:s:LAB1-W7-DM-01.lab1.awake.local\n"
+ "alternate full address:s:LAB1-W7-DM-01.lab1.awake.global\n"
+ "audiomode:i:0\n"
+ "redirectprinters:i:1\n"
+ "redirectcomports:i:0\n"
+ "redirectsmartcards:i:1\n"
+ "redirectclipboard:i:1\n"
+ "redirectposdevices:i:0\n"
+ "autoreconnection enabled:i:1\n"
+ "authentication level:i:2\n"
+ "prompt for credentials:i:0\n"
+ "negotiate security layer:i:1\n"
+ "remoteapplicationmode:i:0\n"
+ "alternate shell:s:\n"
+ "shell working directory:s:\n"
+ "gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n"
+ "gatewayusagemethod:i:1\n"
+ "gatewaycredentialssource:i:0\n"
+ "gatewayprofileusagemethod:i:1\n"
+ "promptcredentialonce:i:1\n"
+ "use redirection server name:i:0\n"
+ "rdgiskdcproxy:i:0\n"
+ "kdcproxyname:s:\n"
+ "drivestoredirect:s:*\n"
+ "username:s:LAB1\\JohnDoe\n"
+ "vendor integer:i:123\n"
+ "vendor string:s:microsoft\n";
static char* append(const char* fmt, ...)
{
@@ -324,13 +272,14 @@ int TestClientRdpFile(int argc, char* argv[])
if (settings->UseMultimon)
{
- printf("UseMultiMon mismatch: Actual: %"PRIu32", Expected: 0\n", settings->UseMultimon);
+ printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n", settings->UseMultimon);
goto fail;
}
if (!settings->Fullscreen)
{
- printf("ScreenModeId mismatch: Actual: %"PRIu32", Expected: TRUE\n", settings->Fullscreen);
+ printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
+ settings->Fullscreen);
goto fail;
}
@@ -345,15 +294,15 @@ int TestClientRdpFile(int argc, char* argv[])
if (strcmp(settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{
- printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
- settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local");
+ printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", settings->GatewayHostname,
+ "LAB1-W2K8R2-GW.lab1.awake.local");
goto fail;
}
if (strcmp(settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.local") != 0)
{
- printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
- settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.local");
+ printf("ServerHostname mismatch: Actual: %s, Expected: %s\n", settings->ServerHostname,
+ "LAB1-W7-DM-01.lab1.awake.local");
goto fail;
}
@@ -368,7 +317,8 @@ int TestClientRdpFile(int argc, char* argv[])
goto fail;
}
- if (!freerdp_client_parse_rdp_file_buffer(file, (BYTE*) testRdpFileUTF8, sizeof(testRdpFileUTF8)))
+ if (!freerdp_client_parse_rdp_file_buffer(file, (BYTE*)testRdpFileUTF8,
+ sizeof(testRdpFileUTF8)))
goto fail;
if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
@@ -376,13 +326,14 @@ int TestClientRdpFile(int argc, char* argv[])
if (settings->UseMultimon != 0)
{
- printf("UseMultiMon mismatch: Actual: %"PRIu32", Expected: 0\n", settings->UseMultimon);
+ printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n", settings->UseMultimon);
return -1;
}
if (!settings->Fullscreen)
{
- printf("ScreenModeId mismatch: Actual: %"PRIu32", Expected: TRUE\n", settings->Fullscreen);
+ printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
+ settings->Fullscreen);
return -1;
}
@@ -397,15 +348,15 @@ int TestClientRdpFile(int argc, char* argv[])
if (strcmp(settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.global") != 0)
{
- printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
- settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.global");
+ printf("ServerHostname mismatch: Actual: %s, Expected: %s\n", settings->ServerHostname,
+ "LAB1-W7-DM-01.lab1.awake.global");
goto fail;
}
if (strcmp(settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{
- printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
- settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local");
+ printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", settings->GatewayHostname,
+ "LAB1-W2K8R2-GW.lab1.awake.local");
goto fail;
}
@@ -446,7 +397,7 @@ int TestClientRdpFile(int argc, char* argv[])
if (!tmp)
goto fail;
- base = append("%s/rdp-file-test-%"PRIx64, tmp, id);
+ base = append("%s/rdp-file-test-%" PRIx64, tmp, id);
if (!base)
goto fail;
if (!CreateDirectoryA(base, NULL))
@@ -463,7 +414,7 @@ int TestClientRdpFile(int argc, char* argv[])
if (!freerdp_client_write_rdp_file(file, utfname, FALSE))
goto fail;
- if (!freerdp_client_write_rdp_file(file, uniname, TRUE))
+ if (!freerdp_client_write_rdp_file(file, uniname, TRUE))
goto fail;
rc = 0;
diff --git a/client/iOS/Additions/OrderedDictionary.m b/client/iOS/Additions/OrderedDictionary.m
index 63b8cff34..e7081948e 100644
--- a/client/iOS/Additions/OrderedDictionary.m
+++ b/client/iOS/Additions/OrderedDictionary.m
@@ -129,18 +129,18 @@ NSString *DescriptionForObject(NSObject *object, id locale, NSUInteger indent)
- (NSUInteger)indexForKey:(id)key
{
- return [array indexOfObject:key];
+ return [array indexOfObject:key];
}
- (NSUInteger)indexForValue:(id)value
{
- NSArray* keys = [self allKeysForObject:value];
- if ([keys count] > 0)
- {
- return [self indexForKey:[keys objectAtIndex:0]];
- }
-
- return NSNotFound;
+ NSArray *keys = [self allKeysForObject:value];
+ if ([keys count] > 0)
+ {
+ return [self indexForKey:[keys objectAtIndex:0]];
+ }
+
+ return NSNotFound;
}
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level
@@ -151,15 +151,14 @@ NSString *DescriptionForObject(NSObject *object, id locale, NSUInteger indent)
{
[indentString appendFormat:@" "];
}
-
+
NSMutableString *description = [NSMutableString string];
[description appendFormat:@"%@{\n", indentString];
for (NSObject *key in self)
{
- [description appendFormat:@"%@ %@ = %@;\n",
- indentString,
- DescriptionForObject(key, locale, level),
- DescriptionForObject([self objectForKey:key], locale, level)];
+ [description appendFormat:@"%@ %@ = %@;\n", indentString,
+ DescriptionForObject(key, locale, level),
+ DescriptionForObject([self objectForKey:key], locale, level)];
}
[description appendFormat:@"%@}\n", indentString];
return description;
diff --git a/client/iOS/Additions/TSXAdditions.h b/client/iOS/Additions/TSXAdditions.h
index d18cc33c8..1f041331e 100644
--- a/client/iOS/Additions/TSXAdditions.h
+++ b/client/iOS/Additions/TSXAdditions.h
@@ -1,10 +1,11 @@
/*
Additions to Cocoa touch classes
-
+
Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson, Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -15,9 +16,12 @@
#pragma mark -
@interface NSString (TSXAdditions)
-+ (NSString*)stringWithUUID;
-- (NSData*)dataFromHexString;
-+ (NSString*)hexStringFromData:(const unsigned char *)data ofSize:(unsigned int)size withSeparator:(NSString *)sep afterNthChar:(int)sepnth;
++ (NSString *)stringWithUUID;
+- (NSData *)dataFromHexString;
++ (NSString *)hexStringFromData:(const unsigned char *)data
+ ofSize:(unsigned int)size
+ withSeparator:(NSString *)sep
+ afterNthChar:(int)sepnth;
@end
@interface NSDictionary (TSXAdditions)
diff --git a/client/iOS/Additions/TSXAdditions.m b/client/iOS/Additions/TSXAdditions.m
index bc2c6a0c4..9a5ac3d74 100644
--- a/client/iOS/Additions/TSXAdditions.m
+++ b/client/iOS/Additions/TSXAdditions.m
@@ -1,10 +1,11 @@
/*
Additions to Cocoa touch classes
-
+
Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson, Martin Fleisz
-
+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "TSXAdditions.h"
@@ -21,12 +22,12 @@
- mutableDeepCopy
{
- if([self respondsToSelector:@selector(mutableCopyWithZone:)])
- return [self mutableCopy];
- else if([self respondsToSelector:@selector(copyWithZone:)])
- return [self copy];
- else
- return [self retain];
+ if ([self respondsToSelector:@selector(mutableCopyWithZone:)])
+ return [self mutableCopy];
+ else if ([self respondsToSelector:@selector(copyWithZone:)])
+ return [self copy];
+ else
+ return [self retain];
}
@end
@@ -36,71 +37,88 @@
@implementation NSString (TSXAdditions)
#pragma mark Creation routines
-+ (NSString*)stringWithUUID
++ (NSString *)stringWithUUID
{
CFUUIDRef uuidObj = CFUUIDCreate(nil);
- NSString* uuidString = (NSString*)CFUUIDCreateString(nil, uuidObj);
+ NSString *uuidString = (NSString *)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
return [uuidString autorelease];
}
-/* Code from http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSData%2BHex.m?r=344 */
-- (NSData*)dataFromHexString
+/* Code from
+ * http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSData%2BHex.m?r=344
+ */
+- (NSData *)dataFromHexString
{
- NSData *hexData = [self dataUsingEncoding:NSASCIIStringEncoding];
- const char *hexBuf = [hexData bytes];
- NSUInteger hexLen = [hexData length];
-
- // This indicates an error converting to ASCII.
- if (!hexData)
- return nil;
-
- if ((hexLen % 2) != 0) {
- return nil;
- }
-
- NSMutableData *binaryData = [NSMutableData dataWithLength:(hexLen / 2)];
- unsigned char *binaryPtr = [binaryData mutableBytes];
- unsigned char value = 0;
- for (NSUInteger i = 0; i < hexLen; i++) {
- char c = hexBuf[i];
-
- if (!isxdigit(c)) {
- return nil;
- }
-
- if (isdigit(c)) {
- value += c - '0';
- } else if (islower(c)) {
- value += 10 + c - 'a';
- } else {
- value += 10 + c - 'A';
- }
-
- if (i & 1) {
- *binaryPtr++ = value;
- value = 0;
- } else {
- value <<= 4;
- }
- }
-
- return [NSData dataWithData:binaryData];
+ NSData *hexData = [self dataUsingEncoding:NSASCIIStringEncoding];
+ const char *hexBuf = [hexData bytes];
+ NSUInteger hexLen = [hexData length];
+
+ // This indicates an error converting to ASCII.
+ if (!hexData)
+ return nil;
+
+ if ((hexLen % 2) != 0)
+ {
+ return nil;
+ }
+
+ NSMutableData *binaryData = [NSMutableData dataWithLength:(hexLen / 2)];
+ unsigned char *binaryPtr = [binaryData mutableBytes];
+ unsigned char value = 0;
+ for (NSUInteger i = 0; i < hexLen; i++)
+ {
+ char c = hexBuf[i];
+
+ if (!isxdigit(c))
+ {
+ return nil;
+ }
+
+ if (isdigit(c))
+ {
+ value += c - '0';
+ }
+ else if (islower(c))
+ {
+ value += 10 + c - 'a';
+ }
+ else
+ {
+ value += 10 + c - 'A';
+ }
+
+ if (i & 1)
+ {
+ *binaryPtr++ = value;
+ value = 0;
+ }
+ else
+ {
+ value <<= 4;
+ }
+ }
+
+ return [NSData dataWithData:binaryData];
}
-+ (NSString*)hexStringFromData:(const unsigned char *)data ofSize:(unsigned int)size withSeparator:(NSString *)sep afterNthChar:(int)sepnth
++ (NSString *)hexStringFromData:(const unsigned char *)data
+ ofSize:(unsigned int)size
+ withSeparator:(NSString *)sep
+ afterNthChar:(int)sepnth
{
int i;
NSMutableString *result;
NSString *immutableResult;
-
+
result = [[NSMutableString alloc] init];
- for (i = 0; i < size; i++) {
- if(i && sep && sepnth && i%sepnth==0)
+ for (i = 0; i < size; i++)
+ {
+ if (i && sep && sepnth && i % sepnth == 0)
[result appendString:sep];
[result appendFormat:@"%02X", data[i]];
}
-
+
immutableResult = [NSString stringWithString:result];
[result release];
return immutableResult;
@@ -114,16 +132,16 @@
- mutableDeepCopy
{
- NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] init];
- NSEnumerator *enumerator = [self keyEnumerator];
- id key;
- while((key = [enumerator nextObject]))
- {
- id obj = [[self objectForKey:key] mutableDeepCopy];
- [newDictionary setObject:obj forKey:key];
- [obj release];
- }
- return newDictionary;
+ NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] init];
+ NSEnumerator *enumerator = [self keyEnumerator];
+ id key;
+ while ((key = [enumerator nextObject]))
+ {
+ id obj = [[self objectForKey:key] mutableDeepCopy];
+ [newDictionary setObject:obj forKey:key];
+ [obj release];
+ }
+ return newDictionary;
}
@end
@@ -132,16 +150,16 @@
- mutableDeepCopy
{
- NSMutableArray *newArray = [[NSMutableArray alloc] init];
- NSEnumerator *enumerator = [self objectEnumerator];
- id obj;
- while((obj = [enumerator nextObject]))
- {
- obj = [obj mutableDeepCopy];
- [newArray addObject:obj];
- [obj release];
- }
- return newArray;
+ NSMutableArray *newArray = [[NSMutableArray alloc] init];
+ NSEnumerator *enumerator = [self objectEnumerator];
+ id obj;
+ while ((obj = [enumerator nextObject]))
+ {
+ obj = [obj mutableDeepCopy];
+ [newArray addObject:obj];
+ [obj release];
+ }
+ return newArray;
}
@end
@@ -150,68 +168,71 @@
- mutableDeepCopy
{
- NSMutableSet *newSet = [[NSMutableSet alloc] init];
- NSEnumerator *enumerator = [self objectEnumerator];
- id obj;
- while((obj = [enumerator nextObject]))
- {
- obj = [obj mutableDeepCopy];
- [newSet addObject:obj];
- [obj release];
- }
- return newSet;
+ NSMutableSet *newSet = [[NSMutableSet alloc] init];
+ NSEnumerator *enumerator = [self objectEnumerator];
+ id obj;
+ while ((obj = [enumerator nextObject]))
+ {
+ obj = [obj mutableDeepCopy];
+ [newSet addObject:obj];
+ [obj release];
+ }
+ return newSet;
}
@end
-
#pragma mark -
-/* Code from http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string */
+/* Code from
+ * http://stackoverflow.com/questions/1305225/best-way-to-serialize-a-nsdata-into-an-hexadeximal-string
+ */
@implementation NSData (TSXAdditions)
#pragma mark - String Conversion
-- (NSString *)hexadecimalString {
- /* Returns hexadecimal string of NSData. Empty string if data is empty. */
-
- const unsigned char *dataBuffer = (const unsigned char *)[self bytes];
-
- if (!dataBuffer)
- return [NSString string];
-
- NSUInteger dataLength = [self length];
- NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
-
- for (int i = 0; i < dataLength; ++i)
- [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
-
- return [NSString stringWithString:hexString];
+- (NSString *)hexadecimalString
+{
+ /* Returns hexadecimal string of NSData. Empty string if data is empty. */
+
+ const unsigned char *dataBuffer = (const unsigned char *)[self bytes];
+
+ if (!dataBuffer)
+ return [NSString string];
+
+ NSUInteger dataLength = [self length];
+ NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
+
+ for (int i = 0; i < dataLength; ++i)
+ [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
+
+ return [NSString stringWithString:hexString];
}
/* Code from http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html */
- (NSString *)base64EncodedString
{
- // Construct an OpenSSL context
- BIO *context = BIO_new(BIO_s_mem());
-
- // Tell the context to encode base64
- BIO *command = BIO_new(BIO_f_base64());
- context = BIO_push(command, context);
- BIO_set_flags(context, BIO_FLAGS_BASE64_NO_NL);
-
- // Encode all the data
- BIO_write(context, [self bytes], [self length]);
- (void)BIO_flush(context);
-
- // Get the data out of the context
- char *outputBuffer;
- long outputLength = BIO_get_mem_data(context, &outputBuffer);
- NSString *encodedString = [[NSString alloc] initWithBytes:outputBuffer length:outputLength encoding:NSASCIIStringEncoding];
-
- BIO_free_all(context);
-
- return encodedString;
+ // Construct an OpenSSL context
+ BIO *context = BIO_new(BIO_s_mem());
+
+ // Tell the context to encode base64
+ BIO *command = BIO_new(BIO_f_base64());
+ context = BIO_push(command, context);
+ BIO_set_flags(context, BIO_FLAGS_BASE64_NO_NL);
+
+ // Encode all the data
+ BIO_write(context, [self bytes], [self length]);
+ (void)BIO_flush(context);
+
+ // Get the data out of the context
+ char *outputBuffer;
+ long outputLength = BIO_get_mem_data(context, &outputBuffer);
+ NSString *encodedString = [[NSString alloc] initWithBytes:outputBuffer
+ length:outputLength
+ encoding:NSASCIIStringEncoding];
+
+ BIO_free_all(context);
+
+ return encodedString;
}
@end
-
diff --git a/client/iOS/Additions/Toast+UIView.h b/client/iOS/Additions/Toast+UIView.h
index 623e70571..03f90c16e 100644
--- a/client/iOS/Additions/Toast+UIView.h
+++ b/client/iOS/Additions/Toast+UIView.h
@@ -1,11 +1,11 @@
/***************************************************************************
-
+
Toast+UIView.h
Toast
Version 0.1
Copyright (c) 2011 Charles Scalesse.
-
+
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@@ -13,10 +13,10 @@
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
-
+
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -24,9 +24,8 @@
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-***************************************************************************/
+***************************************************************************/
#import
#import
@@ -38,14 +37,24 @@
#define ToastDurationShort 1.0
// each makeToast method creates a view and displays it as toast
--(void)makeToast:(NSString *)message;
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point;
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point title:(NSString *)title;
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point title:(NSString *)title image:(UIImage *)image;
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point image:(UIImage *)image;
+- (void)makeToast:(NSString *)message;
+- (void)makeToast:(NSString *)message duration:(float)interval position:(id)point;
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ title:(NSString *)title;
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ title:(NSString *)title
+ image:(UIImage *)image;
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ image:(UIImage *)image;
// the showToast method displays an existing view as toast
--(void)showToast:(UIView *)toast;
--(void)showToast:(UIView *)toast duration:(float)interval position:(id)point;
+- (void)showToast:(UIView *)toast;
+- (void)showToast:(UIView *)toast duration:(float)interval position:(id)point;
@end
diff --git a/client/iOS/Additions/Toast+UIView.m b/client/iOS/Additions/Toast+UIView.m
index 649add3f1..38d1bef87 100644
--- a/client/iOS/Additions/Toast+UIView.m
+++ b/client/iOS/Additions/Toast+UIView.m
@@ -1,11 +1,11 @@
/***************************************************************************
-
+
Toast+UIView.h
Toast
Version 0.1
-
+
Copyright (c) 2011 Charles Scalesse.
-
+
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@@ -13,10 +13,10 @@
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
-
+
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -24,284 +24,344 @@
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
+
***************************************************************************/
#import "Toast+UIView.h"
#import
#import
-#define kMaxWidth 0.8
-#define kMaxHeight 0.8
+#define kMaxWidth 0.8
+#define kMaxHeight 0.8
-#define kHorizontalPadding 10.0
-#define kVerticalPadding 10.0
-#define kCornerRadius 10.0
-#define kOpacity 0.8
-#define kFontSize 16.0
-#define kMaxTitleLines 999
-#define kMaxMessageLines 999
+#define kHorizontalPadding 10.0
+#define kVerticalPadding 10.0
+#define kCornerRadius 10.0
+#define kOpacity 0.8
+#define kFontSize 16.0
+#define kMaxTitleLines 999
+#define kMaxMessageLines 999
-#define kFadeDuration 0.2
+#define kFadeDuration 0.2
-#define kDefaultLength 3
-#define kDefaultPosition @"bottom"
+#define kDefaultLength 3
+#define kDefaultPosition @"bottom"
-#define kImageWidth 80.0
-#define kImageHeight 80.0
+#define kImageWidth 80.0
+#define kImageHeight 80.0
static NSString *kDurationKey = @"duration";
-
@interface UIView (ToastPrivate)
--(CGPoint)getPositionFor:(id)position toast:(UIView *)toast;
--(UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image;
+- (CGPoint)getPositionFor:(id)position toast:(UIView *)toast;
+- (UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image;
@end
-
@implementation UIView (Toast)
#pragma mark -
#pragma mark Toast Methods
--(void)makeToast:(NSString *)message {
- [self makeToast:message duration:kDefaultLength position:kDefaultPosition];
+- (void)makeToast:(NSString *)message
+{
+ [self makeToast:message duration:kDefaultLength position:kDefaultPosition];
}
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point {
- UIView *toast = [self makeViewForMessage:message title:nil image:nil];
- [self showToast:toast duration:interval position:point];
+- (void)makeToast:(NSString *)message duration:(float)interval position:(id)point
+{
+ UIView *toast = [self makeViewForMessage:message title:nil image:nil];
+ [self showToast:toast duration:interval position:point];
}
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point title:(NSString *)title {
- UIView *toast = [self makeViewForMessage:message title:title image:nil];
- [self showToast:toast duration:interval position:point];
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ title:(NSString *)title
+{
+ UIView *toast = [self makeViewForMessage:message title:title image:nil];
+ [self showToast:toast duration:interval position:point];
}
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point image:(UIImage *)image {
- UIView *toast = [self makeViewForMessage:message title:nil image:image];
- [self showToast:toast duration:interval position:point];
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ image:(UIImage *)image
+{
+ UIView *toast = [self makeViewForMessage:message title:nil image:image];
+ [self showToast:toast duration:interval position:point];
}
--(void)makeToast:(NSString *)message duration:(float)interval position:(id)point title:(NSString *)title image:(UIImage *)image {
- UIView *toast = [self makeViewForMessage:message title:title image:image];
- [self showToast:toast duration:interval position:point];
+- (void)makeToast:(NSString *)message
+ duration:(float)interval
+ position:(id)point
+ title:(NSString *)title
+ image:(UIImage *)image
+{
+ UIView *toast = [self makeViewForMessage:message title:title image:image];
+ [self showToast:toast duration:interval position:point];
}
--(void)showToast:(UIView *)toast {
- [self showToast:toast duration:kDefaultLength position:kDefaultPosition];
+- (void)showToast:(UIView *)toast
+{
+ [self showToast:toast duration:kDefaultLength position:kDefaultPosition];
}
--(void)showToast:(UIView *)toast duration:(float)interval position:(id)point {
-
- /****************************************************
- * *
- * Displays a view for a given duration & position. *
- * *
- ****************************************************/
-
- CGPoint toastPoint = [self getPositionFor:point toast:toast];
-
- //use an associative reference to associate the toast view with the display interval
- objc_setAssociatedObject (toast, &kDurationKey, [NSNumber numberWithFloat:interval], OBJC_ASSOCIATION_RETAIN);
-
- [toast setCenter:toastPoint];
- [toast setAlpha:0.0];
- [self addSubview:toast];
-
- [UIView beginAnimations:@"fade_in" context:toast];
- [UIView setAnimationDuration:kFadeDuration];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
- [toast setAlpha:1.0];
- [UIView commitAnimations];
-
+- (void)showToast:(UIView *)toast duration:(float)interval position:(id)point
+{
+
+ /****************************************************
+ * *
+ * Displays a view for a given duration & position. *
+ * *
+ ****************************************************/
+
+ CGPoint toastPoint = [self getPositionFor:point toast:toast];
+
+ // use an associative reference to associate the toast view with the display interval
+ objc_setAssociatedObject(toast, &kDurationKey, [NSNumber numberWithFloat:interval],
+ OBJC_ASSOCIATION_RETAIN);
+
+ [toast setCenter:toastPoint];
+ [toast setAlpha:0.0];
+ [self addSubview:toast];
+
+ [UIView beginAnimations:@"fade_in" context:toast];
+ [UIView setAnimationDuration:kFadeDuration];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
+ [toast setAlpha:1.0];
+ [UIView commitAnimations];
}
#pragma mark -
#pragma mark Animation Delegate Method
-- (void)animationDidStop:(NSString*)animationID finished:(BOOL)finished context:(void *)context {
-
- UIView *toast = (UIView *)context;
-
- // retrieve the display interval associated with the view
- float interval = [(NSNumber *)objc_getAssociatedObject(toast, &kDurationKey) floatValue];
-
- if([animationID isEqualToString:@"fade_in"]) {
-
- [UIView beginAnimations:@"fade_out" context:toast];
- [UIView setAnimationDelay:interval];
- [UIView setAnimationDuration:kFadeDuration];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
- [toast setAlpha:0.0];
- [UIView commitAnimations];
-
- } else if ([animationID isEqualToString:@"fade_out"]) {
-
- [toast removeFromSuperview];
-
- }
-
+- (void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context
+{
+
+ UIView *toast = (UIView *)context;
+
+ // retrieve the display interval associated with the view
+ float interval = [(NSNumber *)objc_getAssociatedObject(toast, &kDurationKey) floatValue];
+
+ if ([animationID isEqualToString:@"fade_in"])
+ {
+
+ [UIView beginAnimations:@"fade_out" context:toast];
+ [UIView setAnimationDelay:interval];
+ [UIView setAnimationDuration:kFadeDuration];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
+ [toast setAlpha:0.0];
+ [UIView commitAnimations];
+ }
+ else if ([animationID isEqualToString:@"fade_out"])
+ {
+
+ [toast removeFromSuperview];
+ }
}
#pragma mark -
#pragma mark Private Methods
--(CGPoint)getPositionFor:(id)point toast:(UIView *)toast {
-
- /*************************************************************************************
- * *
- * Converts string literals @"top", @"bottom", @"center", or any point wrapped in an *
- * NSValue object into a CGPoint *
- * *
- *************************************************************************************/
-
- if([point isKindOfClass:[NSString class]]) {
-
- if( [point caseInsensitiveCompare:@"top"] == NSOrderedSame ) {
- return CGPointMake(self.bounds.size.width/2, (toast.frame.size.height / 2) + kVerticalPadding);
- } else if( [point caseInsensitiveCompare:@"bottom"] == NSOrderedSame ) {
- return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - kVerticalPadding);
- } else if( [point caseInsensitiveCompare:@"center"] == NSOrderedSame ) {
- return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
- }
-
- } else if ([point isKindOfClass:[NSValue class]]) {
- return [point CGPointValue];
- }
-
- NSLog(@"Error: Invalid position for toast.");
- return [self getPositionFor:kDefaultPosition toast:toast];
+- (CGPoint)getPositionFor:(id)point toast:(UIView *)toast
+{
+
+ /*************************************************************************************
+ * *
+ * Converts string literals @"top", @"bottom", @"center", or any point wrapped in an *
+ * NSValue object into a CGPoint *
+ * *
+ *************************************************************************************/
+
+ if ([point isKindOfClass:[NSString class]])
+ {
+
+ if ([point caseInsensitiveCompare:@"top"] == NSOrderedSame)
+ {
+ return CGPointMake(self.bounds.size.width / 2,
+ (toast.frame.size.height / 2) + kVerticalPadding);
+ }
+ else if ([point caseInsensitiveCompare:@"bottom"] == NSOrderedSame)
+ {
+ return CGPointMake(self.bounds.size.width / 2,
+ (self.bounds.size.height - (toast.frame.size.height / 2)) -
+ kVerticalPadding);
+ }
+ else if ([point caseInsensitiveCompare:@"center"] == NSOrderedSame)
+ {
+ return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
+ }
+ }
+ else if ([point isKindOfClass:[NSValue class]])
+ {
+ return [point CGPointValue];
+ }
+
+ NSLog(@"Error: Invalid position for toast.");
+ return [self getPositionFor:kDefaultPosition toast:toast];
}
--(UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image {
-
- /***********************************************************************************
- * *
- * Dynamically build a toast view with any combination of message, title, & image. *
- * *
- ***********************************************************************************/
-
- if((message == nil) && (title == nil) && (image == nil)) return nil;
+- (UIView *)makeViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image
+{
- UILabel *messageLabel = nil;
- UILabel *titleLabel = nil;
- UIImageView *imageView = nil;
-
- // create the parent view
- UIView *wrapperView = [[[UIView alloc] init] autorelease];
- [wrapperView.layer setCornerRadius:kCornerRadius];
- [wrapperView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:kOpacity]];
- wrapperView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
+ /***********************************************************************************
+ * *
+ * Dynamically build a toast view with any combination of message, title, & image. *
+ * *
+ ***********************************************************************************/
- if(image != nil) {
- imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
- [imageView setContentMode:UIViewContentModeScaleAspectFit];
- [imageView setFrame:CGRectMake(kHorizontalPadding, kVerticalPadding, kImageWidth, kImageHeight)];
- }
-
- float imageWidth, imageHeight, imageLeft;
-
- // the imageView frame values will be used to size & position the other views
- if(imageView != nil) {
- imageWidth = imageView.bounds.size.width;
- imageHeight = imageView.bounds.size.height;
- imageLeft = kHorizontalPadding;
- } else {
- imageWidth = imageHeight = imageLeft = 0;
- }
-
- if (title != nil) {
- titleLabel = [[[UILabel alloc] init] autorelease];
- [titleLabel setNumberOfLines:kMaxTitleLines];
- [titleLabel setFont:[UIFont boldSystemFontOfSize:kFontSize]];
- [titleLabel setTextAlignment:UITextAlignmentLeft];
- [titleLabel setLineBreakMode:UILineBreakModeWordWrap];
- [titleLabel setTextColor:[UIColor whiteColor]];
- [titleLabel setBackgroundColor:[UIColor clearColor]];
- [titleLabel setAlpha:1.0];
- [titleLabel setText:title];
-
- // size the title label according to the length of the text
- CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth, self.bounds.size.height * kMaxHeight);
- CGSize expectedSizeTitle = [title sizeWithFont:titleLabel.font constrainedToSize:maxSizeTitle lineBreakMode:titleLabel.lineBreakMode];
- [titleLabel setFrame:CGRectMake(0, 0, expectedSizeTitle.width, expectedSizeTitle.height)];
- }
-
- if (message != nil) {
- messageLabel = [[[UILabel alloc] init] autorelease];
- [messageLabel setNumberOfLines:kMaxMessageLines];
- [messageLabel setFont:[UIFont systemFontOfSize:kFontSize]];
- [messageLabel setLineBreakMode:UILineBreakModeWordWrap];
- [messageLabel setTextColor:[UIColor whiteColor]];
- [messageLabel setTextAlignment:UITextAlignmentCenter];
- [messageLabel setBackgroundColor:[UIColor clearColor]];
- [messageLabel setAlpha:1.0];
- [messageLabel setText:message];
-
- // size the message label according to the length of the text
- CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth, self.bounds.size.height * kMaxHeight);
- CGSize expectedSizeMessage = [message sizeWithFont:messageLabel.font constrainedToSize:maxSizeMessage lineBreakMode:messageLabel.lineBreakMode];
- [messageLabel setFrame:CGRectMake(0, 0, expectedSizeMessage.width, expectedSizeMessage.height)];
- }
-
- // titleLabel frame values
- float titleWidth, titleHeight, titleTop, titleLeft;
-
- if(titleLabel != nil) {
- titleWidth = titleLabel.bounds.size.width;
- titleHeight = titleLabel.bounds.size.height;
- titleTop = kVerticalPadding;
- titleLeft = imageLeft + imageWidth + kHorizontalPadding;
- } else {
- titleWidth = titleHeight = titleTop = titleLeft = 0;
- }
-
- // messageLabel frame values
- float messageWidth, messageHeight, messageLeft, messageTop;
+ if ((message == nil) && (title == nil) && (image == nil))
+ return nil;
- if(messageLabel != nil) {
- messageWidth = messageLabel.bounds.size.width;
- messageHeight = messageLabel.bounds.size.height;
- messageLeft = imageLeft + imageWidth + kHorizontalPadding;
- messageTop = titleTop + titleHeight + kVerticalPadding;
- } else {
- messageWidth = messageHeight = messageLeft = messageTop = 0;
- }
-
- // compare the title & message widths and use the longer value to calculate the size of the wrapper width
- // the same logic applies to the x value (left)
- float longerWidth = (messageWidth < titleWidth) ? titleWidth : messageWidth;
- float longerLeft = (messageLeft < titleLeft) ? titleLeft : messageLeft;
-
- // if the image width is larger than longerWidth, use the image width to calculate the wrapper width.
- // the same logic applies to the wrapper height
- float wrapperWidth = ((longerLeft + longerWidth + kHorizontalPadding) < imageWidth + (kHorizontalPadding * 2)) ? imageWidth + (kHorizontalPadding * 2) : (longerLeft + longerWidth + kHorizontalPadding);
- float wrapperHeight = ((messageTop + messageHeight + kVerticalPadding) < imageHeight + (kVerticalPadding * 2)) ? imageHeight + (kVerticalPadding * 2) : (messageTop + messageHeight + kVerticalPadding);
-
- [wrapperView setFrame:CGRectMake(0, 0, wrapperWidth, wrapperHeight)];
-
- if(titleLabel != nil) {
- [titleLabel setFrame:CGRectMake(titleLeft, titleTop, titleWidth, titleHeight)];
- [wrapperView addSubview:titleLabel];
- }
-
- if(messageLabel != nil) {
- [messageLabel setFrame:CGRectMake(messageLeft, messageTop, messageWidth, messageHeight)];
- [wrapperView addSubview:messageLabel];
- }
-
- if(imageView != nil) {
- [wrapperView addSubview:imageView];
- }
-
- return wrapperView;
+ UILabel *messageLabel = nil;
+ UILabel *titleLabel = nil;
+ UIImageView *imageView = nil;
+
+ // create the parent view
+ UIView *wrapperView = [[[UIView alloc] init] autorelease];
+ [wrapperView.layer setCornerRadius:kCornerRadius];
+ [wrapperView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:kOpacity]];
+ wrapperView.autoresizingMask =
+ UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin |
+ UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
+
+ if (image != nil)
+ {
+ imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
+ [imageView setContentMode:UIViewContentModeScaleAspectFit];
+ [imageView
+ setFrame:CGRectMake(kHorizontalPadding, kVerticalPadding, kImageWidth, kImageHeight)];
+ }
+
+ float imageWidth, imageHeight, imageLeft;
+
+ // the imageView frame values will be used to size & position the other views
+ if (imageView != nil)
+ {
+ imageWidth = imageView.bounds.size.width;
+ imageHeight = imageView.bounds.size.height;
+ imageLeft = kHorizontalPadding;
+ }
+ else
+ {
+ imageWidth = imageHeight = imageLeft = 0;
+ }
+
+ if (title != nil)
+ {
+ titleLabel = [[[UILabel alloc] init] autorelease];
+ [titleLabel setNumberOfLines:kMaxTitleLines];
+ [titleLabel setFont:[UIFont boldSystemFontOfSize:kFontSize]];
+ [titleLabel setTextAlignment:UITextAlignmentLeft];
+ [titleLabel setLineBreakMode:UILineBreakModeWordWrap];
+ [titleLabel setTextColor:[UIColor whiteColor]];
+ [titleLabel setBackgroundColor:[UIColor clearColor]];
+ [titleLabel setAlpha:1.0];
+ [titleLabel setText:title];
+
+ // size the title label according to the length of the text
+ CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth,
+ self.bounds.size.height * kMaxHeight);
+ CGSize expectedSizeTitle = [title sizeWithFont:titleLabel.font
+ constrainedToSize:maxSizeTitle
+ lineBreakMode:titleLabel.lineBreakMode];
+ [titleLabel setFrame:CGRectMake(0, 0, expectedSizeTitle.width, expectedSizeTitle.height)];
+ }
+
+ if (message != nil)
+ {
+ messageLabel = [[[UILabel alloc] init] autorelease];
+ [messageLabel setNumberOfLines:kMaxMessageLines];
+ [messageLabel setFont:[UIFont systemFontOfSize:kFontSize]];
+ [messageLabel setLineBreakMode:UILineBreakModeWordWrap];
+ [messageLabel setTextColor:[UIColor whiteColor]];
+ [messageLabel setTextAlignment:UITextAlignmentCenter];
+ [messageLabel setBackgroundColor:[UIColor clearColor]];
+ [messageLabel setAlpha:1.0];
+ [messageLabel setText:message];
+
+ // size the message label according to the length of the text
+ CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * kMaxWidth) - imageWidth,
+ self.bounds.size.height * kMaxHeight);
+ CGSize expectedSizeMessage = [message sizeWithFont:messageLabel.font
+ constrainedToSize:maxSizeMessage
+ lineBreakMode:messageLabel.lineBreakMode];
+ [messageLabel
+ setFrame:CGRectMake(0, 0, expectedSizeMessage.width, expectedSizeMessage.height)];
+ }
+
+ // titleLabel frame values
+ float titleWidth, titleHeight, titleTop, titleLeft;
+
+ if (titleLabel != nil)
+ {
+ titleWidth = titleLabel.bounds.size.width;
+ titleHeight = titleLabel.bounds.size.height;
+ titleTop = kVerticalPadding;
+ titleLeft = imageLeft + imageWidth + kHorizontalPadding;
+ }
+ else
+ {
+ titleWidth = titleHeight = titleTop = titleLeft = 0;
+ }
+
+ // messageLabel frame values
+ float messageWidth, messageHeight, messageLeft, messageTop;
+
+ if (messageLabel != nil)
+ {
+ messageWidth = messageLabel.bounds.size.width;
+ messageHeight = messageLabel.bounds.size.height;
+ messageLeft = imageLeft + imageWidth + kHorizontalPadding;
+ messageTop = titleTop + titleHeight + kVerticalPadding;
+ }
+ else
+ {
+ messageWidth = messageHeight = messageLeft = messageTop = 0;
+ }
+
+ // compare the title & message widths and use the longer value to calculate the size of the
+ // wrapper width the same logic applies to the x value (left)
+ float longerWidth = (messageWidth < titleWidth) ? titleWidth : messageWidth;
+ float longerLeft = (messageLeft < titleLeft) ? titleLeft : messageLeft;
+
+ // if the image width is larger than longerWidth, use the image width to calculate the wrapper
+ // width. the same logic applies to the wrapper height
+ float wrapperWidth =
+ ((longerLeft + longerWidth + kHorizontalPadding) < imageWidth + (kHorizontalPadding * 2))
+ ? imageWidth + (kHorizontalPadding * 2)
+ : (longerLeft + longerWidth + kHorizontalPadding);
+ float wrapperHeight =
+ ((messageTop + messageHeight + kVerticalPadding) < imageHeight + (kVerticalPadding * 2))
+ ? imageHeight + (kVerticalPadding * 2)
+ : (messageTop + messageHeight + kVerticalPadding);
+
+ [wrapperView setFrame:CGRectMake(0, 0, wrapperWidth, wrapperHeight)];
+
+ if (titleLabel != nil)
+ {
+ [titleLabel setFrame:CGRectMake(titleLeft, titleTop, titleWidth, titleHeight)];
+ [wrapperView addSubview:titleLabel];
+ }
+
+ if (messageLabel != nil)
+ {
+ [messageLabel setFrame:CGRectMake(messageLeft, messageTop, messageWidth, messageHeight)];
+ [wrapperView addSubview:messageLabel];
+ }
+
+ if (imageView != nil)
+ {
+ [wrapperView addSubview:imageView];
+ }
+
+ return wrapperView;
}
@end
diff --git a/client/iOS/AppDelegate.h b/client/iOS/AppDelegate.h
index 6ccc9c51e..dc13cd8fa 100644
--- a/client/iOS/AppDelegate.h
+++ b/client/iOS/AppDelegate.h
@@ -1,22 +1,24 @@
/*
App delegate
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@class MainTabBarController;
-@interface AppDelegate : NSObject {
+@interface AppDelegate : NSObject
+{
- MainTabBarController* _tabBarController;
+ MainTabBarController *_tabBarController;
}
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) IBOutlet MainTabBarController* tabBarController;
+@property(nonatomic, retain) IBOutlet UIWindow *window;
+@property(nonatomic, retain) IBOutlet MainTabBarController *tabBarController;
@end
diff --git a/client/iOS/AppDelegate.m b/client/iOS/AppDelegate.m
index a73923cfd..b964593fb 100644
--- a/client/iOS/AppDelegate.m
+++ b/client/iOS/AppDelegate.m
@@ -1,10 +1,11 @@
/*
App delegate
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "AppDelegate.h"
@@ -18,89 +19,109 @@
@implementation AppDelegate
-
@synthesize window = _window, tabBarController = _tabBarController;
-
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-{
+- (BOOL)application:(UIApplication *)application
+ didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
// Set default values for most NSUserDefaults
- [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]]];
+ [[NSUserDefaults standardUserDefaults]
+ registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]
+ pathForResource:@"Defaults"
+ ofType:@"plist"]]];
- // init global settings
- SetSwapMouseButtonsFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]);
- SetInvertScrollingFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]);
-
- // create bookmark view and navigation controller
- BookmarkListController* bookmarkListController = [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView" bundle:nil] autorelease];
- UINavigationController* bookmarkNavigationController = [[[UINavigationController alloc] initWithRootViewController:bookmarkListController] autorelease];
+ // init global settings
+ SetSwapMouseButtonsFlag(
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]);
+ SetInvertScrollingFlag(
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]);
- // create app settings view and navigation controller
- AppSettingsController* appSettingsController = [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
- UINavigationController* appSettingsNavigationController = [[[UINavigationController alloc] initWithRootViewController:appSettingsController] autorelease];
-
- // create help view controller
- HelpController* helpViewController = [[[HelpController alloc] initWithNibName:nil bundle:nil] autorelease];
+ // create bookmark view and navigation controller
+ BookmarkListController *bookmarkListController =
+ [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView"
+ bundle:nil] autorelease];
+ UINavigationController *bookmarkNavigationController = [[[UINavigationController alloc]
+ initWithRootViewController:bookmarkListController] autorelease];
- // create about view controller
- AboutController* aboutViewController = [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease];
-
- // add tab-bar controller to the main window and display everything
- NSArray* tabItems = [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController, helpViewController, aboutViewController, nil];
- [_tabBarController setViewControllers:tabItems];
- if ([_window respondsToSelector:@selector(setRootViewController:)])
- [_window setRootViewController:_tabBarController];
- else
- [_window addSubview:[_tabBarController view]];
- [_window makeKeyAndVisible];
+ // create app settings view and navigation controller
+ AppSettingsController *appSettingsController =
+ [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
+ UINavigationController *appSettingsNavigationController = [[[UINavigationController alloc]
+ initWithRootViewController:appSettingsController] autorelease];
- return YES;
+ // create help view controller
+ HelpController *helpViewController = [[[HelpController alloc] initWithNibName:nil
+ bundle:nil] autorelease];
+
+ // create about view controller
+ AboutController *aboutViewController =
+ [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease];
+
+ // add tab-bar controller to the main window and display everything
+ NSArray *tabItems =
+ [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController,
+ helpViewController, aboutViewController, nil];
+ [_tabBarController setViewControllers:tabItems];
+ if ([_window respondsToSelector:@selector(setRootViewController:)])
+ [_window setRootViewController:_tabBarController];
+ else
+ [_window addSubview:[_tabBarController view]];
+ [_window makeKeyAndVisible];
+
+ return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
- /*
- Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
- */
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for
+ certain types of temporary interruptions (such as an incoming phone call or SMS message) or
+ when the user quits the application and it begins the transition to the background state. Use
+ this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
+ Games should use this method to pause the game.
+ */
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
- /*
- Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- */
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store
+ enough application state information to restore your application to its current state in case
+ it is terminated later. If your application supports background execution, this method is
+ called instead of applicationWillTerminate: when the user quits.
+ */
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
- /*
- Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
- */
- // cancel disconnect timer
+ /*
+ Called as part of the transition from the background to the inactive state; here you can undo
+ many of the changes made on entering the background.
+ */
+ // cancel disconnect timer
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
- /*
- Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
- */
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If
+ the application was previously in the background, optionally refresh the user interface.
+ */
}
- (void)applicationWillTerminate:(UIApplication *)application
{
- /*
- Called when the application is about to terminate.
- Save data if appropriate.
- See also applicationDidEnterBackground:.
- */
+ /*
+ Called when the application is about to terminate.
+ Save data if appropriate.
+ See also applicationDidEnterBackground:.
+ */
}
- (void)dealloc
{
- [_window release];
- [super dealloc];
+ [_window release];
+ [super dealloc];
}
@end
diff --git a/client/iOS/Controllers/AboutController.h b/client/iOS/Controllers/AboutController.h
index ca3755f29..7af340c74 100644
--- a/client/iOS/Controllers/AboutController.h
+++ b/client/iOS/Controllers/AboutController.h
@@ -1,19 +1,19 @@
/*
Application info controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
-
@interface AboutController : UIViewController
{
- NSString* last_link_clicked;
- UIWebView* webView;
+ NSString *last_link_clicked;
+ UIWebView *webView;
}
@end
diff --git a/client/iOS/Controllers/AboutController.m b/client/iOS/Controllers/AboutController.m
index 6bd8f4a36..1d7f8a2ad 100644
--- a/client/iOS/Controllers/AboutController.m
+++ b/client/iOS/Controllers/AboutController.m
@@ -1,10 +1,11 @@
/*
Application info controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "AboutController.h"
@@ -13,80 +14,104 @@
@implementation AboutController
- // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
+// The designated initializer. Override if you create the controller programmatically and want to
+// perform customization that is not appropriate for viewDidLoad.
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
+ {
// set title and tab-bar image
[self setTitle:NSLocalizedString(@"About", @"About Controller title")];
- UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about" ofType:@"png"]];
- [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"About", @"Tabbar item about") image:tabBarIcon tag:0] autorelease]];
-
- last_link_clicked = nil;
- }
- return self;
+ UIImage *tabBarIcon = [UIImage
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about"
+ ofType:@"png"]];
+ [self setTabBarItem:[[[UITabBarItem alloc]
+ initWithTitle:NSLocalizedString(@"About", @"Tabbar item about")
+ image:tabBarIcon
+ tag:0] autorelease]];
+
+ last_link_clicked = nil;
+ }
+ return self;
}
- (void)dealloc
{
- [super dealloc];
- [last_link_clicked release];
+ [super dealloc];
+ [last_link_clicked release];
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
-- (void)loadView
+- (void)loadView
{
webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
- [webView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+ [webView
+ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[webView setAutoresizesSubviews:YES];
- [webView setDelegate:self];
- [webView setDataDetectorTypes:UIDataDetectorTypeNone];
- [self setView:webView];
+ [webView setDelegate:self];
+ [webView setDataDetectorTypes:UIDataDetectorTypeNone];
+ [self setView:webView];
}
-
-
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad
+- (void)viewDidLoad
{
- [super viewDidLoad];
-
- NSString *filename = (IsPhone() ? @"about_phone" : @"about");
- NSString *htmlString = [[[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"html" inDirectory:@"about_page"] encoding:NSUTF8StringEncoding error:nil] autorelease];
-
- [webView loadHTMLString:[NSString stringWithFormat:htmlString,
- TSXAppFullVersion(),
- [[UIDevice currentDevice] systemName],
- [[UIDevice currentDevice] systemVersion],
- [[UIDevice currentDevice] model]] baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"about_page"]]];
+ [super viewDidLoad];
+
+ NSString *filename = (IsPhone() ? @"about_phone" : @"about");
+ NSString *htmlString = [[[NSString alloc]
+ initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
+ ofType:@"html"
+ inDirectory:@"about_page"]
+ encoding:NSUTF8StringEncoding
+ error:nil] autorelease];
+
+ [webView
+ loadHTMLString:[NSString stringWithFormat:htmlString, TSXAppFullVersion(),
+ [[UIDevice currentDevice] systemName],
+ [[UIDevice currentDevice] systemVersion],
+ [[UIDevice currentDevice] model]]
+ baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
+ stringByAppendingPathComponent:@"about_page"]]];
}
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
}
#pragma mark -
#pragma mark UIWebView callbacks
-- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
-{
- if([[request URL] isFileURL])
+- (BOOL)webView:(UIWebView *)webView
+ shouldStartLoadWithRequest:(NSURLRequest *)request
+ navigationType:(UIWebViewNavigationType)navigationType
+{
+ if ([[request URL] isFileURL])
return YES;
-
- if(navigationType == UIWebViewNavigationTypeLinkClicked)
- {
- [last_link_clicked release];
- last_link_clicked = [[[request URL] absoluteString] retain];
- BlockAlertView *alert = [BlockAlertView alertWithTitle:NSLocalizedString(@"External Link", @"External Link Alert Title")
- message:[NSString stringWithFormat:NSLocalizedString(@"Open [%@] in Browser?", @"Open link in browser (with link as parameter)"), last_link_clicked]];
- [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
- [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK Button") block:^{
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:last_link_clicked]];
- }];
-
- [alert show];
-
+ if (navigationType == UIWebViewNavigationTypeLinkClicked)
+ {
+ [last_link_clicked release];
+ last_link_clicked = [[[request URL] absoluteString] retain];
+ BlockAlertView *alert = [BlockAlertView
+ alertWithTitle:NSLocalizedString(@"External Link", @"External Link Alert Title")
+ message:[NSString stringWithFormat:
+ NSLocalizedString(
+ @"Open [%@] in Browser?",
+ @"Open link in browser (with link as parameter)"),
+ last_link_clicked]];
+
+ [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK Button")
+ block:^{
+ [[UIApplication sharedApplication]
+ openURL:[NSURL URLWithString:last_link_clicked]];
+ }];
+
+ [alert show];
+
return NO;
}
return YES;
diff --git a/client/iOS/Controllers/AdvancedBookmarkEditorController.h b/client/iOS/Controllers/AdvancedBookmarkEditorController.h
index 9982ccf6c..1257d46de 100644
--- a/client/iOS/Controllers/AdvancedBookmarkEditorController.h
+++ b/client/iOS/Controllers/AdvancedBookmarkEditorController.h
@@ -1,10 +1,11 @@
/*
Controller to edit advanced bookmark settings
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -14,12 +15,12 @@
@interface AdvancedBookmarkEditorController : EditorBaseController
{
-@private
- ComputerBookmark* _bookmark;
- ConnectionParams* _params;
+ @private
+ ComputerBookmark *_bookmark;
+ ConnectionParams *_params;
}
// init for the given bookmark
-- (id)initWithBookmark:(ComputerBookmark*)bookmark;
+- (id)initWithBookmark:(ComputerBookmark *)bookmark;
@end
diff --git a/client/iOS/Controllers/AdvancedBookmarkEditorController.m b/client/iOS/Controllers/AdvancedBookmarkEditorController.m
index 1f1851cc0..30434cc74 100644
--- a/client/iOS/Controllers/AdvancedBookmarkEditorController.m
+++ b/client/iOS/Controllers/AdvancedBookmarkEditorController.m
@@ -1,10 +1,11 @@
/*
Controller to edit advanced bookmark settings
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "AdvancedBookmarkEditorController.h"
@@ -24,48 +25,49 @@
@implementation AdvancedBookmarkEditorController
-- (id)initWithBookmark:(ComputerBookmark*)bookmark
+- (id)initWithBookmark:(ComputerBookmark *)bookmark
{
- if ((self = [super initWithStyle:UITableViewStyleGrouped]))
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
// set additional settings state according to bookmark data
_bookmark = [bookmark retain];
- _params = [bookmark params];
- }
- return self;
+ _params = [bookmark params];
+ }
+ return self;
}
- (void)viewDidLoad
{
- [super viewDidLoad];
- [self setTitle:NSLocalizedString(@"Advanced Settings", @"Advanced Settings title")];
+ [super viewDidLoad];
+ [self setTitle:NSLocalizedString(@"Advanced Settings", @"Advanced Settings title")];
}
- (void)viewWillAppear:(BOOL)animated
{
- [super viewWillAppear:animated];
-
- // we need to reload the table view data here to have up-to-date data for the
- // advanced settings accessory items (like for resolution/color mode settings)
- [[self tableView] reloadData];
+ [super viewWillAppear:animated];
+
+ // we need to reload the table view data here to have up-to-date data for the
+ // advanced settings accessory items (like for resolution/color mode settings)
+ [[self tableView] reloadData];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
#pragma mark -
#pragma mark Table view data source
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return SECTION_COUNT;
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ // Return the number of sections.
+ return SECTION_COUNT;
}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ // Return the number of rows in the section.
switch (section)
{
case SECTION_ADVANCED_SETTINGS: // advanced settings
@@ -73,15 +75,14 @@
default:
break;
}
-
- return 0;
-}
+ return 0;
+}
// set section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- switch(section)
+ switch (section)
{
case SECTION_ADVANCED_SETTINGS:
return NSLocalizedString(@"Advanced", @"'Advanced': advanced settings header");
@@ -89,203 +90,248 @@
return @"unknown";
}
-
// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+
// determine the required cell type
- NSString* cellType = nil;
- switch([indexPath section])
+ NSString *cellType = nil;
+ switch ([indexPath section])
{
- case SECTION_ADVANCED_SETTINGS: // advanced settings
- {
- switch([indexPath row])
- {
- case 0: // Enable/Disable TSG Settings
- cellType = TableCellIdentifierYesNo;
- break;
- case 1: // TS Gateway Settings
- cellType = TableCellIdentifierSubEditor;
- break;
- case 2: // 3G Settings
- cellType = TableCellIdentifierYesNo;
- break;
- case 3: // 3G screen/color depth
- cellType = TableCellIdentifierSelection;
- break;
- case 4: // 3G performance settings
- cellType = TableCellIdentifierSubEditor;
- break;
- case 5: // security mode
- cellType = TableCellIdentifierSelection;
- break;
- case 6: // remote program
- case 7: // work dir
- cellType = TableCellIdentifierText;
- break;
- case 8: // console mode
- cellType = TableCellIdentifierYesNo;
- break;
- default:
- break;
- }
+ case SECTION_ADVANCED_SETTINGS: // advanced settings
+ {
+ switch ([indexPath row])
+ {
+ case 0: // Enable/Disable TSG Settings
+ cellType = TableCellIdentifierYesNo;
+ break;
+ case 1: // TS Gateway Settings
+ cellType = TableCellIdentifierSubEditor;
+ break;
+ case 2: // 3G Settings
+ cellType = TableCellIdentifierYesNo;
+ break;
+ case 3: // 3G screen/color depth
+ cellType = TableCellIdentifierSelection;
+ break;
+ case 4: // 3G performance settings
+ cellType = TableCellIdentifierSubEditor;
+ break;
+ case 5: // security mode
+ cellType = TableCellIdentifierSelection;
+ break;
+ case 6: // remote program
+ case 7: // work dir
+ cellType = TableCellIdentifierText;
+ break;
+ case 8: // console mode
+ cellType = TableCellIdentifierYesNo;
+ break;
+ default:
+ break;
+ }
break;
- }
- }
- NSAssert(cellType != nil, @"Couldn't determine cell type");
-
+ }
+ }
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
+
// get the table view cell
UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
- NSAssert(cell, @"Invalid cell");
-
+ NSAssert(cell, @"Invalid cell");
+
// set cell values
- switch([indexPath section])
+ switch ([indexPath section])
{
- // advanced settings
+ // advanced settings
case SECTION_ADVANCED_SETTINGS:
[self initAdvancedSettings:indexPath cell:cell];
break;
-
+
default:
break;
- }
-
- return cell;
+ }
+
+ return cell;
}
// updates advanced settings in the UI
-- (void)initAdvancedSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initAdvancedSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- BOOL enable_3G_settings = [_params boolForKey:@"enable_3g_settings"];
- switch(indexPath.row)
+ BOOL enable_3G_settings = [_params boolForKey:@"enable_3g_settings"];
+ switch (indexPath.row)
{
case 0:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Enable TS Gateway", @"'Enable TS Gateway': Bookmark enable TSG settings")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
- case 1:
- {
- BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"];
- EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell;
- [[editCell label] setText:NSLocalizedString(@"TS Gateway Settings", @"'TS Gateway Settings': Bookmark TS Gateway Settings")];
- [[editCell label] setEnabled:enable_tsg_settings];
- [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"Enable TS Gateway",
+ @"'Enable TS Gateway': Bookmark enable TSG settings")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
+ case 1:
+ {
+ BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"];
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
+ [[editCell label]
+ setText:NSLocalizedString(@"TS Gateway Settings",
+ @"'TS Gateway Settings': Bookmark TS Gateway Settings")];
+ [[editCell label] setEnabled:enable_tsg_settings];
+ [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue
+ : UITableViewCellSelectionStyleNone];
+ break;
+ }
case 2:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"3G Settings", @"'3G Settings': Bookmark enable 3G settings")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[_params boolForKey:@"enable_3g_settings"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"3G Settings",
+ @"'3G Settings': Bookmark enable 3G settings")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle] setOn:[_params boolForKey:@"enable_3g_settings"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
case 3:
- {
- EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell;
- [[selCell label] setText:NSLocalizedString(@"3G Screen", @"'3G Screen': Bookmark 3G Screen settings")];
- NSString* resolution = ScreenResolutionDescription([_params intForKeyPath:@"settings_3g.screen_resolution_type"], [_params intForKeyPath:@"settings_3g.width"], [_params intForKeyPath:@"settings_3g.height"]);
- int colorBits = [_params intForKeyPath:@"settings_3g.colors"];
- [[selCell selection] setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
- [[selCell label] setEnabled:enable_3G_settings];
- [[selCell selection] setEnabled:enable_3G_settings];
- [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone];
- break;
- }
+ {
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
+ [[selCell label]
+ setText:NSLocalizedString(@"3G Screen",
+ @"'3G Screen': Bookmark 3G Screen settings")];
+ NSString *resolution = ScreenResolutionDescription(
+ [_params intForKeyPath:@"settings_3g.screen_resolution_type"],
+ [_params intForKeyPath:@"settings_3g.width"],
+ [_params intForKeyPath:@"settings_3g.height"]);
+ int colorBits = [_params intForKeyPath:@"settings_3g.colors"];
+ [[selCell selection]
+ setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
+ [[selCell label] setEnabled:enable_3G_settings];
+ [[selCell selection] setEnabled:enable_3G_settings];
+ [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue
+ : UITableViewCellSelectionStyleNone];
+ break;
+ }
case 4:
- {
- EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell;
- [[editCell label] setText:NSLocalizedString(@"3G Performance", @"'3G Performance': Bookmark 3G Performance Settings")];
- [[editCell label] setEnabled:enable_3G_settings];
- [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone];
- break;
- }
+ {
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
+ [[editCell label]
+ setText:NSLocalizedString(@"3G Performance",
+ @"'3G Performance': Bookmark 3G Performance Settings")];
+ [[editCell label] setEnabled:enable_3G_settings];
+ [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue
+ : UITableViewCellSelectionStyleNone];
+ break;
+ }
case 5:
- {
- EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell;
- [[selCell label] setText:NSLocalizedString(@"Security", @"'Security': Bookmark protocl security settings")];
- [[selCell selection] setText:ProtocolSecurityDescription([_params intForKey:@"security"])];
- break;
- }
+ {
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
+ [[selCell label]
+ setText:NSLocalizedString(@"Security",
+ @"'Security': Bookmark protocl security settings")];
+ [[selCell selection]
+ setText:ProtocolSecurityDescription([_params intForKey:@"security"])];
+ break;
+ }
case 6:
- {
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell label] setText:NSLocalizedString(@"Remote Program", @"'Remote Program': Bookmark remote program settings")];
- [[textCell textfield] setText:[_params StringForKey:@"remote_program"]];
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
- [self adjustEditTextTableViewCell:textCell];
- break;
- }
+ {
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell label]
+ setText:NSLocalizedString(@"Remote Program",
+ @"'Remote Program': Bookmark remote program settings")];
+ [[textCell textfield] setText:[_params StringForKey:@"remote_program"]];
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [self adjustEditTextTableViewCell:textCell];
+ break;
+ }
case 7:
- {
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell label] setText:NSLocalizedString(@"Working Directory", @"'Working Directory': Bookmark working directory settings")];
- [[textCell textfield] setText:[_params StringForKey:@"working_dir"]];
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
- [self adjustEditTextTableViewCell:textCell];
- break;
- }
+ {
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell label]
+ setText:NSLocalizedString(
+ @"Working Directory",
+ @"'Working Directory': Bookmark working directory settings")];
+ [[textCell textfield] setText:[_params StringForKey:@"working_dir"]];
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [self adjustEditTextTableViewCell:textCell];
+ break;
+ }
case 8:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Console Mode", @"'Console Mode': Bookmark console mode settings")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[_params boolForKey:@"console"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"Console Mode",
+ @"'Console Mode': Bookmark console mode settings")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle] setOn:[_params boolForKey:@"console"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
- }
+ }
}
#pragma mark -
#pragma mark Table view delegate
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- UIViewController* viewCtrl = nil;
-
- // determine view
- switch ([indexPath row])
- {
- case 1:
- if ([_params boolForKey:@"enable_tsg_settings"])
- viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark] autorelease];
- break;
- case 3:
- if ([_params boolForKey:@"enable_3g_settings"])
- viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease];
- break;
- case 4:
- if ([_params boolForKey:@"enable_3g_settings"])
- viewCtrl = [[[PerformanceEditorController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease];
- break;
- case 5:
- viewCtrl = [[[EditorSelectionController alloc] initWithConnectionParams:_params entries:[NSArray arrayWithObject:@"security"] selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]] autorelease];
- break;
- default:
- break;
- }
-
- // display view
- if(viewCtrl)
- [[self navigationController] pushViewController:viewCtrl animated:YES];
-}
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UIViewController *viewCtrl = nil;
+ // determine view
+ switch ([indexPath row])
+ {
+ case 1:
+ if ([_params boolForKey:@"enable_tsg_settings"])
+ viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark]
+ autorelease];
+ break;
+ case 3:
+ if ([_params boolForKey:@"enable_3g_settings"])
+ viewCtrl = [[[ScreenSelectionController alloc]
+ initWithConnectionParams:_params
+ keyPath:@"settings_3g"] autorelease];
+ break;
+ case 4:
+ if ([_params boolForKey:@"enable_3g_settings"])
+ viewCtrl = [[[PerformanceEditorController alloc]
+ initWithConnectionParams:_params
+ keyPath:@"settings_3g"] autorelease];
+ break;
+ case 5:
+ viewCtrl = [[[EditorSelectionController alloc]
+ initWithConnectionParams:_params
+ entries:[NSArray arrayWithObject:@"security"]
+ selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]]
+ autorelease];
+ break;
+ default:
+ break;
+ }
+
+ // display view
+ if (viewCtrl)
+ [[self navigationController] pushViewController:viewCtrl animated:YES];
+}
#pragma mark -
#pragma mark Text Field delegate
-- (BOOL)textFieldShouldReturn:(UITextField*)textField
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
@@ -293,21 +339,21 @@
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
- switch(textField.tag)
+ switch (textField.tag)
{
- // update remote program/work dir settings
- case GET_TAG(SECTION_ADVANCED_SETTINGS, 6):
- {
- [_params setValue:[textField text] forKey:@"remote_program"];
- break;
- }
-
- case GET_TAG(SECTION_ADVANCED_SETTINGS, 7):
- {
- [_params setValue:[textField text] forKey:@"working_dir"];
- break;
- }
-
+ // update remote program/work dir settings
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 6):
+ {
+ [_params setValue:[textField text] forKey:@"remote_program"];
+ break;
+ }
+
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 7):
+ {
+ [_params setValue:[textField text] forKey:@"working_dir"];
+ break;
+ }
+
default:
break;
}
@@ -318,32 +364,44 @@
- (void)toggleSettingValue:(id)sender
{
- UISwitch* valueSwitch = (UISwitch*)sender;
- switch(valueSwitch.tag)
- {
- case GET_TAG(SECTION_ADVANCED_SETTINGS, 0):
- {
- [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"];
- NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil];
- [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
- break;
- }
+ UISwitch *valueSwitch = (UISwitch *)sender;
+ switch (valueSwitch.tag)
+ {
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 0):
+ {
+ [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"];
+ NSArray *indexPaths =
+ [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1
+ inSection:SECTION_ADVANCED_SETTINGS],
+ [NSIndexPath indexPathForRow:2
+ inSection:SECTION_ADVANCED_SETTINGS],
+ nil];
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
+ withRowAnimation:UITableViewRowAnimationNone];
+ break;
+ }
- case GET_TAG(SECTION_ADVANCED_SETTINGS, 2):
- {
- [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"];
- NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil];
- [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
- break;
- }
-
- case GET_TAG(SECTION_ADVANCED_SETTINGS, 8):
- [_params setBool:[valueSwitch isOn] forKey:@"console"];
- break;
-
- default:
- break;
- }
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 2):
+ {
+ [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"];
+ NSArray *indexPaths =
+ [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3
+ inSection:SECTION_ADVANCED_SETTINGS],
+ [NSIndexPath indexPathForRow:2
+ inSection:SECTION_ADVANCED_SETTINGS],
+ nil];
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
+ withRowAnimation:UITableViewRowAnimationNone];
+ break;
+ }
+
+ case GET_TAG(SECTION_ADVANCED_SETTINGS, 8):
+ [_params setBool:[valueSwitch isOn] forKey:@"console"];
+ break;
+
+ default:
+ break;
+ }
}
@end
diff --git a/client/iOS/Controllers/AppSettingsController.h b/client/iOS/Controllers/AppSettingsController.h
index 2d59dac01..4de1271b0 100644
--- a/client/iOS/Controllers/AppSettingsController.h
+++ b/client/iOS/Controllers/AppSettingsController.h
@@ -1,10 +1,11 @@
/*
Controller to specify application wide settings
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
diff --git a/client/iOS/Controllers/AppSettingsController.m b/client/iOS/Controllers/AppSettingsController.m
index 0f1d68601..5596e168d 100644
--- a/client/iOS/Controllers/AppSettingsController.m
+++ b/client/iOS/Controllers/AppSettingsController.m
@@ -1,10 +1,11 @@
/*
Controller to specify application wide settings
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "AppSettingsController.h"
@@ -21,195 +22,224 @@
#pragma mark -
#pragma mark Initialization
-
- (id)initWithStyle:(UITableViewStyle)style
{
- if ((self = [super initWithStyle:style]))
- {
- UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_settings" ofType:@"png"]];
- [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings") image:tabBarIcon tag:0] autorelease]];
- }
- return self;
+ if ((self = [super initWithStyle:style]))
+ {
+ UIImage *tabBarIcon = [UIImage
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_settings"
+ ofType:@"png"]];
+ [self
+ setTabBarItem:[[[UITabBarItem alloc]
+ initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings")
+ image:tabBarIcon
+ tag:0] autorelease]];
+ }
+ return self;
}
#pragma mark -
#pragma mark View lifecycle
-- (void)viewDidLoad {
- [super viewDidLoad];
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
- // set title
- [self setTitle:NSLocalizedString(@"Settings", @"App Settings title")];
+ // set title
+ [self setTitle:NSLocalizedString(@"Settings", @"App Settings title")];
}
-
-- (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
+- (void)viewWillDisappear:(BOOL)animated
+{
+ [super viewWillDisappear:animated];
}
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
}
-
-- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super dealloc];
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
}
#pragma mark -
#pragma mark Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return SECTION_NUM_SECTIONS;
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ // Return the number of sections.
+ return SECTION_NUM_SECTIONS;
}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
- switch (section)
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ // Return the number of rows in the section.
+ switch (section)
{
- case SECTION_UI_SETTINGS: // UI settings
- return 5;
- case SECTION_CERTIFICATE_HANDLING_SETTINGS: // certificate handling settings
- return 2;
+ case SECTION_UI_SETTINGS: // UI settings
+ return 5;
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS: // certificate handling settings
+ return 2;
default:
break;
}
-
- return 0;
-}
+ return 0;
+}
// set section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- switch(section)
+ switch (section)
{
- case SECTION_UI_SETTINGS:
+ case SECTION_UI_SETTINGS:
return NSLocalizedString(@"User Interface", @"UI settings section title");
- case SECTION_CERTIFICATE_HANDLING_SETTINGS:
- return NSLocalizedString(@"Server Certificate Handling", @"Server Certificate Handling section title");
- default:
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
+ return NSLocalizedString(@"Server Certificate Handling",
+ @"Server Certificate Handling section title");
+ default:
return nil;
}
return @"unknown";
}
// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+
// determine the required cell type
- NSString* cellIdentifier = nil;
- switch([indexPath section])
+ NSString *cellIdentifier = nil;
+ switch ([indexPath section])
{
- case SECTION_UI_SETTINGS:
- {
- switch([indexPath row])
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- cellIdentifier = TableCellIdentifierYesNo;
- break;
- }
- break;
- }
- case SECTION_CERTIFICATE_HANDLING_SETTINGS:
- {
- switch([indexPath row])
- {
- case 0:
- cellIdentifier = TableCellIdentifierYesNo;
- break;
- case 1:
- cellIdentifier = TableCellIdentifierSubEditor;
- break;
- }
- break;
- }
- }
- NSAssert(cellIdentifier != nil, @"Couldn't determine cell type");
-
+ case SECTION_UI_SETTINGS:
+ {
+ switch ([indexPath row])
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ cellIdentifier = TableCellIdentifierYesNo;
+ break;
+ }
+ break;
+ }
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
+ {
+ switch ([indexPath row])
+ {
+ case 0:
+ cellIdentifier = TableCellIdentifierYesNo;
+ break;
+ case 1:
+ cellIdentifier = TableCellIdentifierSubEditor;
+ break;
+ }
+ break;
+ }
+ }
+ NSAssert(cellIdentifier != nil, @"Couldn't determine cell type");
+
// get the table view cell
UITableViewCell *cell = [self tableViewCellFromIdentifier:cellIdentifier];
- NSAssert(cell, @"Invalid cell");
-
+ NSAssert(cell, @"Invalid cell");
+
// set cell values
- switch([indexPath section])
- {
- case SECTION_UI_SETTINGS:
- [self initUISettings:indexPath cell:cell];
- break;
-
- case SECTION_CERTIFICATE_HANDLING_SETTINGS:
- [self initCertificateHandlingSettings:indexPath cell:cell];
- break;
-
+ switch ([indexPath section])
+ {
+ case SECTION_UI_SETTINGS:
+ [self initUISettings:indexPath cell:cell];
+ break;
+
+ case SECTION_CERTIFICATE_HANDLING_SETTINGS:
+ [self initCertificateHandlingSettings:indexPath cell:cell];
+ break;
+
default:
break;
- }
-
- return cell;
+ }
+
+ return cell;
}
#pragma mark - Initialization helpers
// updates UI settings in the UI
-- (void)initUISettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initUISettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- switch([indexPath row])
+ switch ([indexPath row])
{
case 0:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Hide Status Bar", "Show/Hide Phone Status Bar setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
- case 1:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Hide Tool Bar", "Show/Hide Tool Bar setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label] setText:NSLocalizedString(@"Hide Status Bar",
+ "Show/Hide Phone Status Bar setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle]
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
break;
- }
+ }
+ case 1:
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"Hide Tool Bar", "Show/Hide Tool Bar setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle]
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
case 2:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Swap Mouse Buttons", "Swap Mouse Button UI setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"Swap Mouse Buttons", "Swap Mouse Button UI setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle]
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
case 3:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Invert Scrolling", "Invert Scrolling UI setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label]
+ setText:NSLocalizedString(@"Invert Scrolling", "Invert Scrolling UI setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle]
+ setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
case 4:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Touch Pointer Auto Scroll", "Touch Pointer Auto Scroll UI setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"ui.auto_scroll_touchpointer"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label] setText:NSLocalizedString(@"Touch Pointer Auto Scroll",
+ "Touch Pointer Auto Scroll UI setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults]
+ boolForKey:@"ui.auto_scroll_touchpointer"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
@@ -217,25 +247,30 @@
}
// updates certificate handling settings in the UI
-- (void)initCertificateHandlingSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initCertificateHandlingSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- switch([indexPath row])
+ switch ([indexPath row])
{
case 0:
- {
- EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell;
- [[flagCell label] setText:NSLocalizedString(@"Accept all Certificates", "Accept All Certificates setting")];
- [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"security.accept_certificates"]];
- [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged];
- break;
- }
+ {
+ EditFlagTableViewCell *flagCell = (EditFlagTableViewCell *)cell;
+ [[flagCell label] setText:NSLocalizedString(@"Accept all Certificates",
+ "Accept All Certificates setting")];
+ [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[flagCell toggle] setOn:[[NSUserDefaults standardUserDefaults]
+ boolForKey:@"security.accept_certificates"]];
+ [[flagCell toggle] addTarget:self
+ action:@selector(toggleSettingValue:)
+ forControlEvents:UIControlEventValueChanged];
+ break;
+ }
case 1:
- {
- EditSubEditTableViewCell* subCell = (EditSubEditTableViewCell*)cell;
- [[subCell label] setText:NSLocalizedString(@"Erase Certificate Cache", @"Erase certificate cache button")];
- break;
- }
+ {
+ EditSubEditTableViewCell *subCell = (EditSubEditTableViewCell *)cell;
+ [[subCell label] setText:NSLocalizedString(@"Erase Certificate Cache",
+ @"Erase certificate cache button")];
+ break;
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
@@ -245,24 +280,35 @@
#pragma mark -
#pragma mark Table view delegate
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
- // deselect any row to fake a button-pressed like effect
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
+ // deselect any row to fake a button-pressed like effect
+ [tableView deselectRowAtIndexPath:indexPath animated:YES];
- // ensure everything is stored in our settings before we proceed
- [[self view] endEditing:NO];
-
- // clear certificate cache
- if([indexPath section] == SECTION_CERTIFICATE_HANDLING_SETTINGS && [indexPath row] == 1)
- {
- // delete certificates cache
- NSError* err;
- if ([[NSFileManager defaultManager] removeItemAtPath:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"/.freerdp"] error:&err])
- [[self view] makeToast:NSLocalizedString(@"Certificate Cache cleared!", @"Clear Certificate cache success message") duration:ToastDurationNormal position:@"center"];
- else
- [[self view] makeToast:NSLocalizedString(@"Error clearing the Certificate Cache!", @"Clear Certificate cache failed message") duration:ToastDurationNormal position:@"center"];
- }
+ // ensure everything is stored in our settings before we proceed
+ [[self view] endEditing:NO];
+
+ // clear certificate cache
+ if ([indexPath section] == SECTION_CERTIFICATE_HANDLING_SETTINGS && [indexPath row] == 1)
+ {
+ // delete certificates cache
+ NSError *err;
+ if ([[NSFileManager defaultManager]
+ removeItemAtPath:[[NSSearchPathForDirectoriesInDomains(
+ NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
+ stringByAppendingPathComponent:@"/.freerdp"]
+ error:&err])
+ [[self view] makeToast:NSLocalizedString(@"Certificate Cache cleared!",
+ @"Clear Certificate cache success message")
+ duration:ToastDurationNormal
+ position:@"center"];
+ else
+ [[self view] makeToast:NSLocalizedString(@"Error clearing the Certificate Cache!",
+ @"Clear Certificate cache failed message")
+ duration:ToastDurationNormal
+ position:@"center"];
+ }
}
#pragma mark -
@@ -270,40 +316,45 @@
- (void)toggleSettingValue:(id)sender
{
- UISwitch* valueSwitch = (UISwitch*)sender;
- switch([valueSwitch tag])
- {
- case GET_TAG(SECTION_UI_SETTINGS, 0):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"ui.hide_status_bar"];
- break;
+ UISwitch *valueSwitch = (UISwitch *)sender;
+ switch ([valueSwitch tag])
+ {
+ case GET_TAG(SECTION_UI_SETTINGS, 0):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"ui.hide_status_bar"];
+ break;
- case GET_TAG(SECTION_UI_SETTINGS, 1):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"ui.hide_tool_bar"];
- break;
+ case GET_TAG(SECTION_UI_SETTINGS, 1):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"ui.hide_tool_bar"];
+ break;
- case GET_TAG(SECTION_UI_SETTINGS, 2):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"ui.swap_mouse_buttons"];
- SetSwapMouseButtonsFlag([valueSwitch isOn]);
- break;
+ case GET_TAG(SECTION_UI_SETTINGS, 2):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"ui.swap_mouse_buttons"];
+ SetSwapMouseButtonsFlag([valueSwitch isOn]);
+ break;
- case GET_TAG(SECTION_UI_SETTINGS, 3):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"ui.invert_scrolling"];
- SetInvertScrollingFlag([valueSwitch isOn]);
- break;
+ case GET_TAG(SECTION_UI_SETTINGS, 3):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"ui.invert_scrolling"];
+ SetInvertScrollingFlag([valueSwitch isOn]);
+ break;
- case GET_TAG(SECTION_UI_SETTINGS, 4):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"ui.auto_scroll_touchpointer"];
- SetInvertScrollingFlag([valueSwitch isOn]);
- break;
+ case GET_TAG(SECTION_UI_SETTINGS, 4):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"ui.auto_scroll_touchpointer"];
+ SetInvertScrollingFlag([valueSwitch isOn]);
+ break;
- case GET_TAG(SECTION_CERTIFICATE_HANDLING_SETTINGS, 0):
- [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn] forKey:@"security.accept_certificates"];
- break;
-
- default:
- break;
- }
+ case GET_TAG(SECTION_CERTIFICATE_HANDLING_SETTINGS, 0):
+ [[NSUserDefaults standardUserDefaults] setBool:[valueSwitch isOn]
+ forKey:@"security.accept_certificates"];
+ break;
+
+ default:
+ break;
+ }
}
@end
-
diff --git a/client/iOS/Controllers/BookmarkEditorController.h b/client/iOS/Controllers/BookmarkEditorController.h
index 2fdf6170f..10dbf705c 100644
--- a/client/iOS/Controllers/BookmarkEditorController.h
+++ b/client/iOS/Controllers/BookmarkEditorController.h
@@ -1,12 +1,12 @@
/*
Bookmark editor controller
-
- Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import
#import "EditorBaseController.h"
@@ -14,27 +14,25 @@
@class ComputerBookmark;
@class ConnectionParams;
-
@protocol BookmarkEditorDelegate
// bookmark editing finsihed
-- (void)commitBookmark:(ComputerBookmark*)bookmark;
+- (void)commitBookmark:(ComputerBookmark *)bookmark;
@end
-
@interface BookmarkEditorController : EditorBaseController
{
-@private
- ComputerBookmark* _bookmark;
- ConnectionParams* _params;
-
- BOOL _display_server_settings;
-
- id delegate;
+ @private
+ ComputerBookmark *_bookmark;
+ ConnectionParams *_params;
+
+ BOOL _display_server_settings;
+
+ id delegate;
}
-@property (nonatomic, assign) id delegate;
+@property(nonatomic, assign) id delegate;
// init for the given bookmark
-- (id)initWithBookmark:(ComputerBookmark*)bookmark;
+- (id)initWithBookmark:(ComputerBookmark *)bookmark;
@end
diff --git a/client/iOS/Controllers/BookmarkEditorController.m b/client/iOS/Controllers/BookmarkEditorController.m
index 20ef7fef3..de49e3e86 100644
--- a/client/iOS/Controllers/BookmarkEditorController.m
+++ b/client/iOS/Controllers/BookmarkEditorController.m
@@ -1,10 +1,11 @@
/*
Bookmark editor controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "BookmarkEditorController.h"
@@ -26,63 +27,74 @@
#define SECTION_COUNT 3
#pragma mark -
-#pragma mark Initialization
+#pragma mark Initialization
-- (id)initWithBookmark:(ComputerBookmark*)bookmark
+- (id)initWithBookmark:(ComputerBookmark *)bookmark
{
- if ((self = [super initWithStyle:UITableViewStyleGrouped]))
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
// set additional settings state according to bookmark data
- if ([[bookmark uuid] length] == 0)
- _bookmark = [bookmark copy];
- else
- _bookmark = [bookmark copyWithUUID];
- _params = [_bookmark params];
+ if ([[bookmark uuid] length] == 0)
+ _bookmark = [bookmark copy];
+ else
+ _bookmark = [bookmark copyWithUUID];
+ _params = [_bookmark params];
- _display_server_settings = YES;
- }
- return self;
+ _display_server_settings = YES;
+ }
+ return self;
}
-
#pragma mark -
#pragma mark View lifecycle
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- // replace back button with a custom handler that checks if the required bookmark settings were specified
- UIBarButtonItem* saveButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", @"Save Button title") style:UIBarButtonItemStyleDone target:self action:@selector(handleSave:)] autorelease];
- UIBarButtonItem* cancelButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button title") style:UIBarButtonItemStyleBordered target:self action:@selector(handleCancel:)] autorelease];
- [[self navigationItem] setLeftBarButtonItem:cancelButton];
- [[self navigationItem] setRightBarButtonItem:saveButton];
+ // replace back button with a custom handler that checks if the required bookmark settings were
+ // specified
+ UIBarButtonItem *saveButton =
+ [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", @"Save Button title")
+ style:UIBarButtonItemStyleDone
+ target:self
+ action:@selector(handleSave:)] autorelease];
+ UIBarButtonItem *cancelButton =
+ [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button title")
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(handleCancel:)] autorelease];
+ [[self navigationItem] setLeftBarButtonItem:cancelButton];
+ [[self navigationItem] setRightBarButtonItem:saveButton];
}
-- (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
+- (void)viewWillAppear:(BOOL)animated
+{
+ [super viewWillAppear:animated];
- // we need to reload the table view data here to have up-to-date data for the
- // advanced settings accessory items (like for resolution/color mode settings)
- [[self tableView] reloadData];
+ // we need to reload the table view data here to have up-to-date data for the
+ // advanced settings accessory items (like for resolution/color mode settings)
+ [[self tableView] reloadData];
}
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
}
#pragma mark -
#pragma mark Table view data source
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return SECTION_COUNT;
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ // Return the number of sections.
+ return SECTION_COUNT;
}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ // Return the number of rows in the section.
switch (section)
{
case SECTION_SERVER: // server settings
@@ -94,18 +106,19 @@
default:
break;
}
-
- return 0;
-}
+ return 0;
+}
// set section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- switch(section)
+ switch (section)
{
case SECTION_SERVER:
- return (_display_server_settings ? NSLocalizedString(@"Host", @"'Host': host settings header") : nil);
+ return (_display_server_settings
+ ? NSLocalizedString(@"Host", @"'Host': host settings header")
+ : nil);
case SECTION_CREDENTIALS:
return NSLocalizedString(@"Credentials", @"'Credentials': credentials settings header");
case SECTION_SETTINGS:
@@ -114,56 +127,57 @@
return @"unknown";
}
-
// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
// determine the required cell type
- NSString* cellType = nil;
- switch([indexPath section])
+ NSString *cellType = nil;
+ switch ([indexPath section])
{
case SECTION_SERVER:
- cellType = TableCellIdentifierText;
+ cellType = TableCellIdentifierText;
break;
- case SECTION_CREDENTIALS:
- cellType = TableCellIdentifierSelection;
- break;
-
- case SECTION_SETTINGS: // settings
- {
- switch([indexPath row])
- {
- case 0: // screen/color depth
- cellType = TableCellIdentifierSelection;
- break;
- case 1: // performance settings
- case 2: // advanced settings
- cellType = TableCellIdentifierSubEditor;
- break;
- default:
- break;
- }
- }
- break;
+ case SECTION_CREDENTIALS:
+ cellType = TableCellIdentifierSelection;
+ break;
+
+ case SECTION_SETTINGS: // settings
+ {
+ switch ([indexPath row])
+ {
+ case 0: // screen/color depth
+ cellType = TableCellIdentifierSelection;
+ break;
+ case 1: // performance settings
+ case 2: // advanced settings
+ cellType = TableCellIdentifierSubEditor;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
- default:
- break;
- }
- NSAssert(cellType != nil, @"Couldn't determine cell type");
-
// get the table view cell
UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
- NSAssert(cell, @"Invalid cell");
-
+ NSAssert(cell, @"Invalid cell");
+
// set cell values
- switch([indexPath section])
+ switch ([indexPath section])
{
// server settings
case SECTION_SERVER:
[self initServerSettings:indexPath cell:cell];
break;
-
+
// credentials
case SECTION_CREDENTIALS:
[self initCredentialSettings:indexPath cell:cell];
@@ -176,50 +190,54 @@
default:
break;
- }
-
- return cell;
+ }
+
+ return cell;
}
// updates server settings in the UI
-- (void)initServerSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initServerSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
[[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- switch([indexPath row])
+ switch ([indexPath row])
{
case 0:
[[textCell label] setText:NSLocalizedString(@"Label", @"'Label': Bookmark label")];
[[textCell textfield] setText:[_bookmark label]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
case 1:
[[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")];
[[textCell textfield] setText:[_params StringForKey:@"hostname"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
case 2:
[[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")];
- [[textCell textfield] setText:[NSString stringWithFormat:@"%d", [_params intForKey:@"port"]]];
- [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
+ [[textCell textfield]
+ setText:[NSString stringWithFormat:@"%d", [_params intForKey:@"port"]]];
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
break;
default:
NSLog(@"Invalid row index in settings table!");
break;
- }
+ }
- [self adjustEditTextTableViewCell:textCell];
+ [self adjustEditTextTableViewCell:textCell];
}
// updates credentials in the UI
-- (void)initCredentialSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initCredentialSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell;
- switch(indexPath.row)
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
+ switch (indexPath.row)
{
case 0:
- [[selCell label] setText:NSLocalizedString(@"Credentials", @"'Credentials': Bookmark credentials")];
- [[selCell selection] setText:[_params StringForKey:@"username"]];
+ [[selCell label]
+ setText:NSLocalizedString(@"Credentials", @"'Credentials': Bookmark credentials")];
+ [[selCell selection] setText:[_params StringForKey:@"username"]];
break;
default:
NSLog(@"Invalid row index in settings table!");
@@ -228,85 +246,95 @@
}
// updates session settings in the UI
-- (void)initSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
-{
- switch(indexPath.row)
+- (void)initSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
+{
+ switch (indexPath.row)
{
case 0:
- {
- EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell;
- [[selCell label] setText:NSLocalizedString(@"Screen", @"'Screen': Bookmark Screen settings")];
- NSString* resolution = ScreenResolutionDescription([_params intForKey:@"screen_resolution_type"], [_params intForKey:@"width"], [_params intForKey:@"height"]);
- int colorBits = [_params intForKey:@"colors"];
- [[selCell selection] setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
- break;
- }
+ {
+ EditSelectionTableViewCell *selCell = (EditSelectionTableViewCell *)cell;
+ [[selCell label]
+ setText:NSLocalizedString(@"Screen", @"'Screen': Bookmark Screen settings")];
+ NSString *resolution = ScreenResolutionDescription(
+ [_params intForKey:@"screen_resolution_type"], [_params intForKey:@"width"],
+ [_params intForKey:@"height"]);
+ int colorBits = [_params intForKey:@"colors"];
+ [[selCell selection]
+ setText:[NSString stringWithFormat:@"%@@%d", resolution, colorBits]];
+ break;
+ }
case 1:
- {
- EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell;
- [[editCell label] setText:NSLocalizedString(@"Performance", @"'Performance': Bookmark Performance Settings")];
- break;
- }
+ {
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
+ [[editCell label]
+ setText:NSLocalizedString(@"Performance",
+ @"'Performance': Bookmark Performance Settings")];
+ break;
+ }
case 2:
- {
- EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell;
- [[editCell label] setText:NSLocalizedString(@"Advanced", @"'Advanced': Bookmark Advanced Settings")];
- break;
- }
+ {
+ EditSubEditTableViewCell *editCell = (EditSubEditTableViewCell *)cell;
+ [[editCell label]
+ setText:NSLocalizedString(@"Advanced", @"'Advanced': Bookmark Advanced Settings")];
+ break;
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
- }
+ }
}
-
#pragma mark -
#pragma mark Table view delegate
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- UIViewController* viewCtrl = nil;
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UIViewController *viewCtrl = nil;
- // determine view
- switch([indexPath section])
- {
- case SECTION_CREDENTIALS:
- {
- if ([indexPath row] == 0)
- viewCtrl = [[[CredentialsEditorController alloc] initWithBookmark:_bookmark] autorelease];
- break;
- }
-
- case SECTION_SETTINGS:
- {
- switch ([indexPath row])
- {
- case 0:
- viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params] autorelease];
- break;
- case 1:
- viewCtrl = [[[PerformanceEditorController alloc] initWithConnectionParams:_params] autorelease];
- break;
- case 2:
- viewCtrl = [[[AdvancedBookmarkEditorController alloc] initWithBookmark:_bookmark] autorelease];
- break;
- default:
- break;
- }
-
- break;
- }
- }
+ // determine view
+ switch ([indexPath section])
+ {
+ case SECTION_CREDENTIALS:
+ {
+ if ([indexPath row] == 0)
+ viewCtrl =
+ [[[CredentialsEditorController alloc] initWithBookmark:_bookmark] autorelease];
+ break;
+ }
- // display view
- if(viewCtrl)
- [[self navigationController] pushViewController:viewCtrl animated:YES];
+ case SECTION_SETTINGS:
+ {
+ switch ([indexPath row])
+ {
+ case 0:
+ viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params]
+ autorelease];
+ break;
+ case 1:
+ viewCtrl = [[[PerformanceEditorController alloc]
+ initWithConnectionParams:_params] autorelease];
+ break;
+ case 2:
+ viewCtrl = [[[AdvancedBookmarkEditorController alloc]
+ initWithBookmark:_bookmark] autorelease];
+ break;
+ default:
+ break;
+ }
+
+ break;
+ }
+ }
+
+ // display view
+ if (viewCtrl)
+ [[self navigationController] pushViewController:viewCtrl animated:YES];
}
-
#pragma mark -
#pragma mark Text Field delegate
-- (BOOL)textFieldShouldReturn:(UITextField*)textField
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
@@ -314,7 +342,7 @@
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
- switch(textField.tag)
+ switch (textField.tag)
{
// update server settings
case GET_TAG(SECTION_SERVER, 0):
@@ -328,7 +356,7 @@
case GET_TAG(SECTION_SERVER, 2):
[_params setInt:[[textField text] intValue] forKey:@"port"];
break;
-
+
default:
break;
}
@@ -340,51 +368,60 @@
- (void)handleSave:(id)sender
{
- // resign any first responder (so that we finish editing any bookmark parameter that might be currently edited)
- [[self view] endEditing:NO];
-
- // verify that bookmark is complete (only for manual bookmarks)
- if ([[_bookmark label] length] == 0 || [[_params StringForKey:@"hostname"] length] == 0 || [_params intForKey:@"port"] == 0)
- {
- BlockAlertView* alertView = [BlockAlertView alertWithTitle:NSLocalizedString(@"Cancel without saving?", @"Incomplete bookmark error title") message:NSLocalizedString(@"Press 'Cancel' to abort!\nPress 'Continue' to specify the required fields!", @"Incomplete bookmark error message")];
- [alertView setCancelButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button") block:^{
- // cancel bookmark editing and return to previous view controller
- [[self navigationController] popViewControllerAnimated:YES];
- }];
- [alertView addButtonWithTitle:NSLocalizedString(@"Continue", @"Continue Button") block:nil];
- [alertView show];
- return;
- }
-
- // commit bookmark
- if ([[self delegate] respondsToSelector:@selector(commitBookmark:)])
- [[self delegate] commitBookmark:_bookmark];
-
- // return to previous view controller
- [[self navigationController] popViewControllerAnimated:YES];
+ // resign any first responder (so that we finish editing any bookmark parameter that might be
+ // currently edited)
+ [[self view] endEditing:NO];
+
+ // verify that bookmark is complete (only for manual bookmarks)
+ if ([[_bookmark label] length] == 0 || [[_params StringForKey:@"hostname"] length] == 0 ||
+ [_params intForKey:@"port"] == 0)
+ {
+ BlockAlertView *alertView = [BlockAlertView
+ alertWithTitle:NSLocalizedString(@"Cancel without saving?",
+ @"Incomplete bookmark error title")
+ message:NSLocalizedString(@"Press 'Cancel' to abort!\nPress 'Continue' to "
+ @"specify the required fields!",
+ @"Incomplete bookmark error message")];
+ [alertView
+ setCancelButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
+ block:^{
+ // cancel bookmark editing and return to previous view controller
+ [[self navigationController] popViewControllerAnimated:YES];
+ }];
+ [alertView addButtonWithTitle:NSLocalizedString(@"Continue", @"Continue Button") block:nil];
+ [alertView show];
+ return;
+ }
+
+ // commit bookmark
+ if ([[self delegate] respondsToSelector:@selector(commitBookmark:)])
+ [[self delegate] commitBookmark:_bookmark];
+
+ // return to previous view controller
+ [[self navigationController] popViewControllerAnimated:YES];
}
- (void)handleCancel:(id)sender
{
- // return to previous view controller
- [[self navigationController] popViewControllerAnimated:YES];
+ // return to previous view controller
+ [[self navigationController] popViewControllerAnimated:YES];
}
#pragma mark -
#pragma mark Memory management
-- (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Relinquish ownership any cached data, images, etc that aren't in use.
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Relinquish ownership any cached data, images, etc that aren't in use.
}
-- (void)dealloc {
- [super dealloc];
- [_bookmark autorelease];
+- (void)dealloc
+{
+ [super dealloc];
+ [_bookmark autorelease];
}
-
@end
-
diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.h b/client/iOS/Controllers/BookmarkGatewaySettingsController.h
index d663d7bda..26b059a73 100644
--- a/client/iOS/Controllers/BookmarkGatewaySettingsController.h
+++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.h
@@ -1,10 +1,11 @@
/*
Controller to edit ts gateway bookmark settings
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -14,12 +15,12 @@
@interface BookmarkGatewaySettingsController : EditorBaseController
{
-@private
- ComputerBookmark* _bookmark;
- ConnectionParams* _params;
+ @private
+ ComputerBookmark *_bookmark;
+ ConnectionParams *_params;
}
// init for the given bookmark
-- (id)initWithBookmark:(ComputerBookmark*)bookmark;
+- (id)initWithBookmark:(ComputerBookmark *)bookmark;
@end
diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.m b/client/iOS/Controllers/BookmarkGatewaySettingsController.m
index 32803b1ba..d58bdbd4c 100644
--- a/client/iOS/Controllers/BookmarkGatewaySettingsController.m
+++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.m
@@ -20,54 +20,54 @@
@implementation BookmarkGatewaySettingsController
-- (id)initWithBookmark:(ComputerBookmark*)bookmark
+- (id)initWithBookmark:(ComputerBookmark *)bookmark
{
- if ((self = [super initWithStyle:UITableViewStyleGrouped]))
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
// set additional settings state according to bookmark data
_bookmark = [bookmark retain];
- _params = [bookmark params];
- }
- return self;
+ _params = [bookmark params];
+ }
+ return self;
}
- (void)viewDidLoad
{
- [super viewDidLoad];
- [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")];
+ [super viewDidLoad];
+ [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")];
}
- (void)viewWillAppear:(BOOL)animated
{
- [super viewWillAppear:animated];
-
- // we need to reload the table view data here to have up-to-date data for the
- // advanced settings accessory items (like for resolution/color mode settings)
- [[self tableView] reloadData];
+ [super viewWillAppear:animated];
+
+ // we need to reload the table view data here to have up-to-date data for the
+ // advanced settings accessory items (like for resolution/color mode settings)
+ [[self tableView] reloadData];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
- (void)dealloc
{
- [super dealloc];
- [_bookmark release];
+ [super dealloc];
+ [_bookmark release];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
- // Return the number of sections.
- return SECTION_COUNT;
+ // Return the number of sections.
+ return SECTION_COUNT;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
- // Return the number of rows in the section.
+ // Return the number of rows in the section.
switch (section)
{
case SECTION_TSGATEWAY_SETTINGS: // ts gateway settings
@@ -75,14 +75,14 @@
default:
break;
}
-
- return 0;
+
+ return 0;
}
// set section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- switch(section)
+ switch (section)
{
case SECTION_TSGATEWAY_SETTINGS:
return NSLocalizedString(@"TS Gateway", @"'TS Gateway': ts gateway settings header");
@@ -90,112 +90,119 @@
return @"unknown";
}
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// determine the required cell type
- NSString* cellType = nil;
- switch([indexPath section])
+ NSString *cellType = nil;
+ switch ([indexPath section])
{
- case SECTION_TSGATEWAY_SETTINGS: // advanced settings
- {
- switch([indexPath row])
- {
- case 0: // hostname
- case 1: // port
- case 2: // username
- case 4: // domain
- cellType = TableCellIdentifierText;
- break;
- case 3: // password
- cellType = TableCellIdentifierSecretText;
- break;
- default:
- break;
- }
+ case SECTION_TSGATEWAY_SETTINGS: // advanced settings
+ {
+ switch ([indexPath row])
+ {
+ case 0: // hostname
+ case 1: // port
+ case 2: // username
+ case 4: // domain
+ cellType = TableCellIdentifierText;
+ break;
+ case 3: // password
+ cellType = TableCellIdentifierSecretText;
+ break;
+ default:
+ break;
+ }
break;
- }
+ }
}
NSAssert(cellType != nil, @"Couldn't determine cell type");
-
+
// get the table view cell
UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
NSAssert(cell, @"Invalid cell");
-
+
// set cell values
- switch([indexPath section])
+ switch ([indexPath section])
{
- // advanced settings
+ // advanced settings
case SECTION_TSGATEWAY_SETTINGS:
[self initGatewaySettings:indexPath cell:cell];
break;
-
+
default:
break;
}
-
- return cell;
+
+ return cell;
}
// updates server settings in the UI
-- (void)initGatewaySettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initGatewaySettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
[[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- switch([indexPath row])
+ switch ([indexPath row])
{
case 0:
- {
+ {
[[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")];
[[textCell textfield] setText:[_params StringForKey:@"tsg_hostname"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
- }
+ }
case 1:
- {
- int port = [_params intForKey:@"tsg_port"];
- if (port == 0) port = 443;
+ {
+ int port = [_params intForKey:@"tsg_port"];
+ if (port == 0)
+ port = 443;
[[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")];
[[textCell textfield] setText:[NSString stringWithFormat:@"%d", port]];
- [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
- break;
- }
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
+ break;
+ }
case 2:
- {
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell label] setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
+ {
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell label]
+ setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
[[textCell textfield] setText:[_params StringForKey:@"tsg_username"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
- }
+ }
case 3:
- {
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell label] setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
+ {
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell label]
+ setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
[[textCell textfield] setText:[_params StringForKey:@"tsg_password"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
- }
+ }
case 4:
- {
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ {
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
[[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")];
[[textCell textfield] setText:[_params StringForKey:@"tsg_domain"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
- }
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
}
-
- [self adjustEditTextTableViewCell:textCell];
-}
+ [self adjustEditTextTableViewCell:textCell];
+}
#pragma mark -
#pragma mark Text Field delegate
-- (BOOL)textFieldShouldReturn:(UITextField*)textField
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
@@ -203,34 +210,33 @@
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
- switch(textField.tag)
+ switch (textField.tag)
{
- // update server settings
+ // update server settings
case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 0):
[_params setValue:[textField text] forKey:@"tsg_hostname"];
break;
-
+
case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 1):
[_params setInt:[[textField text] intValue] forKey:@"tsg_port"];
break;
-
+
case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 2):
[_params setValue:[textField text] forKey:@"tsg_username"];
break;
-
+
case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 3):
[_params setValue:[textField text] forKey:@"tsg_password"];
break;
-
+
case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 4):
[_params setValue:[textField text] forKey:@"tsg_domain"];
- break;
-
+ break;
+
default:
break;
}
return YES;
}
-
@end
diff --git a/client/iOS/Controllers/BookmarkListController.h b/client/iOS/Controllers/BookmarkListController.h
index d67325f5a..79734523d 100644
--- a/client/iOS/Controllers/BookmarkListController.h
+++ b/client/iOS/Controllers/BookmarkListController.h
@@ -1,10 +1,11 @@
/*
bookmarks and active session view controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -14,41 +15,42 @@
#import "BookmarkEditorController.h"
#import "Reachability.h"
-@interface BookmarkListController : UIViewController
-{
+@interface BookmarkListController : UIViewController
+{
// custom bookmark and session table cells
- BookmarkTableCell* _bmTableCell;
- SessionTableCell* _sessTableCell;
+ BookmarkTableCell *_bmTableCell;
+ SessionTableCell *_sessTableCell;
// child views
- UISearchBar* _searchBar;
- UITableView* _tableView;
-
- // array with search results (or nil if no search active)
- NSMutableArray* _manual_search_result;
- NSMutableArray* _history_search_result;
+ UISearchBar *_searchBar;
+ UITableView *_tableView;
- // bookmark arrays
- NSMutableArray* _manual_bookmarks;
-
- // bookmark star images
- UIImage* _star_on_img;
- UIImage* _star_off_img;
-
- // array with active sessions
- NSMutableArray* _active_sessions;
-
- // array with connection history entries
- NSMutableArray* _connection_history;
-
- // temporary bookmark when asking if the user wants to store a bookmark for a session initiated by a quick connect
- ComputerBookmark* _temporary_bookmark;
+ // array with search results (or nil if no search active)
+ NSMutableArray *_manual_search_result;
+ NSMutableArray *_history_search_result;
+
+ // bookmark arrays
+ NSMutableArray *_manual_bookmarks;
+
+ // bookmark star images
+ UIImage *_star_on_img;
+ UIImage *_star_off_img;
+
+ // array with active sessions
+ NSMutableArray *_active_sessions;
+
+ // array with connection history entries
+ NSMutableArray *_connection_history;
+
+ // temporary bookmark when asking if the user wants to store a bookmark for a session initiated
+ // by a quick connect
+ ComputerBookmark *_temporary_bookmark;
}
-@property (nonatomic, retain) IBOutlet UISearchBar* searchBar;
-@property (nonatomic, retain) IBOutlet UITableView* tableView;
-@property (nonatomic, retain) IBOutlet BookmarkTableCell* bmTableCell;
-@property (nonatomic, retain) IBOutlet SessionTableCell* sessTableCell;
-
+@property(nonatomic, retain) IBOutlet UISearchBar *searchBar;
+@property(nonatomic, retain) IBOutlet UITableView *tableView;
+@property(nonatomic, retain) IBOutlet BookmarkTableCell *bmTableCell;
+@property(nonatomic, retain) IBOutlet SessionTableCell *sessTableCell;
@end
diff --git a/client/iOS/Controllers/BookmarkListController.m b/client/iOS/Controllers/BookmarkListController.m
index e3497df91..1d37caf66 100644
--- a/client/iOS/Controllers/BookmarkListController.m
+++ b/client/iOS/Controllers/BookmarkListController.m
@@ -1,10 +1,11 @@
/*
bookmarks and active session view controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "BookmarkListController.h"
@@ -16,406 +17,458 @@
#import "GlobalDefaults.h"
#import "BlockAlertView.h"
-#define SECTION_SESSIONS 0
-#define SECTION_BOOKMARKS 1
-#define NUM_SECTIONS 2
+#define SECTION_SESSIONS 0
+#define SECTION_BOOKMARKS 1
+#define NUM_SECTIONS 2
@interface BookmarkListController (Private)
#pragma mark misc functions
-- (UIButton*)disclosureButtonWithImage:(UIImage*)image;
-- (void)performSearch:(NSString*)searchText;
+- (UIButton *)disclosureButtonWithImage:(UIImage *)image;
+- (void)performSearch:(NSString *)searchText;
#pragma mark Persisting bookmarks
- (void)scheduleWriteBookmarksToDataStore;
- (void)writeBookmarksToDataStore;
- (void)scheduleWriteManualBookmarksToDataStore;
- (void)writeManualBookmarksToDataStore;
- (void)readManualBookmarksFromDataStore;
-- (void)writeArray:(NSArray*)bookmarks toDataStoreURL:(NSURL*)url;
-- (NSMutableArray*)arrayFromDataStoreURL:(NSURL*)url;
-- (NSURL*)manualBookmarksDataStoreURL;
-- (NSURL*)connectionHistoryDataStoreURL;
+- (void)writeArray:(NSArray *)bookmarks toDataStoreURL:(NSURL *)url;
+- (NSMutableArray *)arrayFromDataStoreURL:(NSURL *)url;
+- (NSURL *)manualBookmarksDataStoreURL;
+- (NSURL *)connectionHistoryDataStoreURL;
@end
-
@implementation BookmarkListController
-@synthesize searchBar = _searchBar, tableView = _tableView, bmTableCell = _bmTableCell, sessTableCell = _sessTableCell;
+@synthesize searchBar = _searchBar, tableView = _tableView, bmTableCell = _bmTableCell,
+ sessTableCell = _sessTableCell;
- // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
- {
- // load bookmarks
- [self readManualBookmarksFromDataStore];
+// The designated initializer. Override if you create the controller programmatically and want to
+// perform customization that is not appropriate for viewDidLoad.
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
+ {
+ // load bookmarks
+ [self readManualBookmarksFromDataStore];
+
+ // load connection history
+ [self readConnectionHistoryFromDataStore];
- // load connection history
- [self readConnectionHistoryFromDataStore];
-
// init search result array
- _manual_search_result = nil;
-
- // register for session notifications
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionDisconnected:) name:TSXSessionDidDisconnectNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionFailedToConnect:) name:TSXSessionDidFailToConnectNotification object:nil];
-
- // set title and tabbar controller image
- [self setTitle:NSLocalizedString(@"Connections", @"'Connections': bookmark controller title")];
- [self setTabBarItem:[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0] autorelease]];
+ _manual_search_result = nil;
- // load images
- _star_on_img = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_on" ofType:@"png"]] retain];
- _star_off_img = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_off" ofType:@"png"]] retain];
+ // register for session notifications
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(sessionDisconnected:)
+ name:TSXSessionDidDisconnectNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(sessionFailedToConnect:)
+ name:TSXSessionDidFailToConnectNotification
+ object:nil];
- // init reachability detection
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
-
- // init other properties
- _active_sessions = [[NSMutableArray alloc] init];
- _temporary_bookmark = nil;
- }
- return self;
+ // set title and tabbar controller image
+ [self setTitle:NSLocalizedString(@"Connections",
+ @"'Connections': bookmark controller title")];
+ [self setTabBarItem:[[[UITabBarItem alloc]
+ initWithTabBarSystemItem:UITabBarSystemItemBookmarks
+ tag:0] autorelease]];
+
+ // load images
+ _star_on_img = [[UIImage
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_on"
+ ofType:@"png"]] retain];
+ _star_off_img =
+ [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]
+ pathForResource:@"icon_accessory_star_off"
+ ofType:@"png"]] retain];
+
+ // init reachability detection
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(reachabilityChanged:)
+ name:kReachabilityChangedNotification
+ object:nil];
+
+ // init other properties
+ _active_sessions = [[NSMutableArray alloc] init];
+ _temporary_bookmark = nil;
+ }
+ return self;
}
- (void)loadView
{
- [super loadView];
+ [super loadView];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- // set edit button to allow bookmark list editing
- [[self navigationItem] setRightBarButtonItem:[self editButtonItem]];
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ // set edit button to allow bookmark list editing
+ [[self navigationItem] setRightBarButtonItem:[self editButtonItem]];
}
-
-- (void)viewWillAppear:(BOOL)animated
+- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
-
- // in case we had a search - search again cause the bookmark searchable items could have changed
- if ([[_searchBar text] length] > 0)
- [self performSearch:[_searchBar text]];
- // to reflect any bookmark changes - reload table
- [_tableView reloadData];
+ // in case we had a search - search again cause the bookmark searchable items could have changed
+ if ([[_searchBar text] length] > 0)
+ [self performSearch:[_searchBar text]];
+
+ // to reflect any bookmark changes - reload table
+ [_tableView reloadData];
}
- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
-
- // clear any search
- [_searchBar setText:@""];
- [_searchBar resignFirstResponder];
- [self performSearch:@""];
+ [super viewWillDisappear:animated];
+
+ // clear any search
+ [_searchBar setText:@""];
+ [_searchBar resignFirstResponder];
+ [self performSearch:@""];
}
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return YES;
-}
-
-
-- (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
-}
-
-- (void)viewDidUnload {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-}
-
-
-- (void)dealloc
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- [_temporary_bookmark release];
- [_connection_history release];
- [_active_sessions release];
- [_manual_search_result release];
- [_manual_bookmarks release];
-
- [_star_on_img release];
- [_star_off_img release];
-
- [super dealloc];
+ // Return YES for supported orientations
+ return YES;
}
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [_temporary_bookmark release];
+ [_connection_history release];
+ [_active_sessions release];
+ [_manual_search_result release];
+ [_manual_bookmarks release];
+
+ [_star_on_img release];
+ [_star_off_img release];
+
+ [super dealloc];
+}
#pragma mark -
#pragma mark Table view data source
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ // Return the number of sections.
return NUM_SECTIONS;
}
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- switch(section)
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+
+ switch (section)
{
- case SECTION_SESSIONS:
- return 0;
- break;
-
+ case SECTION_SESSIONS:
+ return 0;
+ break;
+
case SECTION_BOOKMARKS:
- {
- // (+1 for Add Bookmark entry)
- if(_manual_search_result != nil)
- return ([_manual_search_result count] + [_history_search_result count] + 1);
- return ([_manual_bookmarks count] + 1);
- }
- break;
-
+ {
+ // (+1 for Add Bookmark entry)
+ if (_manual_search_result != nil)
+ return ([_manual_search_result count] + [_history_search_result count] + 1);
+ return ([_manual_bookmarks count] + 1);
+ }
+ break;
+
default:
break;
}
return 0;
}
-- (UITableViewCell*)cellForGenericListEntry
+- (UITableViewCell *)cellForGenericListEntry
{
- static NSString *CellIdentifier = @"BookmarkListCell";
- UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:CellIdentifier];
- if(cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setAccessoryView:[self disclosureButtonWithImage:_star_off_img]];
- }
+ static NSString *CellIdentifier = @"BookmarkListCell";
+ UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil)
+ {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
+ reuseIdentifier:CellIdentifier];
+ [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
+ [cell setAccessoryView:[self disclosureButtonWithImage:_star_off_img]];
+ }
- return cell;
+ return cell;
}
-- (BookmarkTableCell*)cellForBookmark
+- (BookmarkTableCell *)cellForBookmark
{
- static NSString *BookmarkCellIdentifier = @"BookmarkCell";
- BookmarkTableCell *cell = (BookmarkTableCell*)[[self tableView] dequeueReusableCellWithIdentifier:BookmarkCellIdentifier];
- if(cell == nil)
- {
- [[NSBundle mainBundle] loadNibNamed:@"BookmarkTableViewCell" owner:self options:nil];
- [_bmTableCell setAccessoryView:[self disclosureButtonWithImage:_star_on_img]];
- cell = _bmTableCell;
- _bmTableCell = nil;
- }
-
- return cell;
+ static NSString *BookmarkCellIdentifier = @"BookmarkCell";
+ BookmarkTableCell *cell = (BookmarkTableCell *)[[self tableView]
+ dequeueReusableCellWithIdentifier:BookmarkCellIdentifier];
+ if (cell == nil)
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"BookmarkTableViewCell" owner:self options:nil];
+ [_bmTableCell setAccessoryView:[self disclosureButtonWithImage:_star_on_img]];
+ cell = _bmTableCell;
+ _bmTableCell = nil;
+ }
+
+ return cell;
}
// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
-
- switch ([indexPath section])
- {
- case SECTION_SESSIONS:
- {
- // get custom session cell
- static NSString *SessionCellIdentifier = @"SessionCell";
- SessionTableCell *cell = (SessionTableCell*)[tableView dequeueReusableCellWithIdentifier:SessionCellIdentifier];
- if(cell == nil)
- {
- [[NSBundle mainBundle] loadNibNamed:@"SessionTableViewCell" owner:self options:nil];
- cell = _sessTableCell;
- _sessTableCell = nil;
- }
-
- // set cell data
- RDPSession* session = [_active_sessions objectAtIndex:[indexPath row]];
- [[cell title] setText:[session sessionName]];
- [[cell server] setText:[[session params] StringForKey:@"hostname"]];
- [[cell username] setText:[[session params] StringForKey:@"username"]];
- [[cell screenshot] setImage:[session getScreenshotWithSize:[[cell screenshot] bounds].size]];
- [[cell disconnectButton] setTag:[indexPath row]];
- return cell;
- }
-
- case SECTION_BOOKMARKS:
- {
- // special handling for first cell - quick connect/quick create Bookmark cell
- if([indexPath row] == 0)
- {
- // if a search text is entered the cell becomes a quick connect/quick create bookmark cell - otherwise it's just an add bookmark cell
- UITableViewCell* cell = [self cellForGenericListEntry];
- if ([[_searchBar text] length] == 0)
- {
- [[cell textLabel] setText:[@" " stringByAppendingString:NSLocalizedString(@"Add Connection", @"'Add Connection': button label")]];
- [((UIButton*)[cell accessoryView]) setHidden:YES];
- }
- else
- {
- [[cell textLabel] setText:[@" " stringByAppendingString:[_searchBar text]]];
- [((UIButton*)[cell accessoryView]) setHidden:NO];
- }
-
- return cell;
- }
- else
- {
- // do we have a history cell or bookmark cell?
- if ([self isIndexPathToHistoryItem:indexPath])
- {
- UITableViewCell* cell = [self cellForGenericListEntry];
- [[cell textLabel] setText:[@" " stringByAppendingString:[_history_search_result objectAtIndex:[self historyIndexFromIndexPath:indexPath]]]];
- [((UIButton*)[cell accessoryView]) setHidden:NO];
- return cell;
- }
- else
- {
- // set cell properties
- ComputerBookmark* entry;
- BookmarkTableCell* cell = [self cellForBookmark];
- if(_manual_search_result == nil)
- entry = [_manual_bookmarks objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
- else
- entry = [[_manual_search_result objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]] valueForKey:@"bookmark"];
-
- [[cell title] setText:[entry label]];
- [[cell subTitle] setText:[[entry params] StringForKey:@"hostname"]];
- return cell;
- }
- }
- }
-
- default:
- break;
- }
-
- NSAssert(0, @"Failed to create cell");
- return nil;
-}
-
-
-
-// Override to support conditional editing of the table view.
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
- // dont allow to edit Add Bookmark item
- if([indexPath section] == SECTION_SESSIONS)
- return NO;
- if([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
- return NO;
- return YES;
-}
-
-
-
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
- if(editingStyle == UITableViewCellEditingStyleDelete)
+
+ switch ([indexPath section])
{
- // Delete the row from the data source
- switch([indexPath section])
+ case SECTION_SESSIONS:
{
- case SECTION_BOOKMARKS:
- {
- if (_manual_search_result == nil)
- [_manual_bookmarks removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
- else
- {
- // history item or bookmark?
- if ([self isIndexPathToHistoryItem:indexPath])
- {
- [_connection_history removeObject:[_history_search_result objectAtIndex:[self historyIndexFromIndexPath:indexPath]]];
- [_history_search_result removeObjectAtIndex:[self historyIndexFromIndexPath:indexPath]];
- }
- else
- {
- [_manual_bookmarks removeObject:[[_manual_search_result objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]] valueForKey:@"bookmark"]];
- [_manual_search_result removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
- }
- }
- [self scheduleWriteManualBookmarksToDataStore];
- break;
- }
+ // get custom session cell
+ static NSString *SessionCellIdentifier = @"SessionCell";
+ SessionTableCell *cell = (SessionTableCell *)[tableView
+ dequeueReusableCellWithIdentifier:SessionCellIdentifier];
+ if (cell == nil)
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"SessionTableViewCell" owner:self options:nil];
+ cell = _sessTableCell;
+ _sessTableCell = nil;
+ }
+
+ // set cell data
+ RDPSession *session = [_active_sessions objectAtIndex:[indexPath row]];
+ [[cell title] setText:[session sessionName]];
+ [[cell server] setText:[[session params] StringForKey:@"hostname"]];
+ [[cell username] setText:[[session params] StringForKey:@"username"]];
+ [[cell screenshot]
+ setImage:[session getScreenshotWithSize:[[cell screenshot] bounds].size]];
+ [[cell disconnectButton] setTag:[indexPath row]];
+ return cell;
}
- [tableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationNone];
- }
+ case SECTION_BOOKMARKS:
+ {
+ // special handling for first cell - quick connect/quick create Bookmark cell
+ if ([indexPath row] == 0)
+ {
+ // if a search text is entered the cell becomes a quick connect/quick create
+ // bookmark cell - otherwise it's just an add bookmark cell
+ UITableViewCell *cell = [self cellForGenericListEntry];
+ if ([[_searchBar text] length] == 0)
+ {
+ [[cell textLabel]
+ setText:[@" " stringByAppendingString:
+ NSLocalizedString(@"Add Connection",
+ @"'Add Connection': button label")]];
+ [((UIButton *)[cell accessoryView]) setHidden:YES];
+ }
+ else
+ {
+ [[cell textLabel] setText:[@" " stringByAppendingString:[_searchBar text]]];
+ [((UIButton *)[cell accessoryView]) setHidden:NO];
+ }
+
+ return cell;
+ }
+ else
+ {
+ // do we have a history cell or bookmark cell?
+ if ([self isIndexPathToHistoryItem:indexPath])
+ {
+ UITableViewCell *cell = [self cellForGenericListEntry];
+ [[cell textLabel]
+ setText:[@" " stringByAppendingString:
+ [_history_search_result
+ objectAtIndex:
+ [self historyIndexFromIndexPath:indexPath]]]];
+ [((UIButton *)[cell accessoryView]) setHidden:NO];
+ return cell;
+ }
+ else
+ {
+ // set cell properties
+ ComputerBookmark *entry;
+ BookmarkTableCell *cell = [self cellForBookmark];
+ if (_manual_search_result == nil)
+ entry = [_manual_bookmarks
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
+ else
+ entry = [[_manual_search_result
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
+ valueForKey:@"bookmark"];
+
+ [[cell title] setText:[entry label]];
+ [[cell subTitle] setText:[[entry params] StringForKey:@"hostname"]];
+ return cell;
+ }
+ }
+ }
+
+ default:
+ break;
+ }
+
+ NSAssert(0, @"Failed to create cell");
+ return nil;
}
+// Override to support conditional editing of the table view.
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // dont allow to edit Add Bookmark item
+ if ([indexPath section] == SECTION_SESSIONS)
+ return NO;
+ if ([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
+ return NO;
+ return YES;
+}
+
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView
+ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
+ forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if (editingStyle == UITableViewCellEditingStyleDelete)
+ {
+ // Delete the row from the data source
+ switch ([indexPath section])
+ {
+ case SECTION_BOOKMARKS:
+ {
+ if (_manual_search_result == nil)
+ [_manual_bookmarks
+ removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
+ else
+ {
+ // history item or bookmark?
+ if ([self isIndexPathToHistoryItem:indexPath])
+ {
+ [_connection_history
+ removeObject:
+ [_history_search_result
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]]];
+ [_history_search_result
+ removeObjectAtIndex:[self historyIndexFromIndexPath:indexPath]];
+ }
+ else
+ {
+ [_manual_bookmarks
+ removeObject:
+ [[_manual_search_result
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
+ valueForKey:@"bookmark"]];
+ [_manual_search_result
+ removeObjectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]];
+ }
+ }
+ [self scheduleWriteManualBookmarksToDataStore];
+ break;
+ }
+ }
+
+ [tableView reloadSections:[NSIndexSet indexSetWithIndex:[indexPath section]]
+ withRowAnimation:UITableViewRowAnimationNone];
+ }
+}
// Override to support rearranging the table view.
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
+- (void)tableView:(UITableView *)tableView
+ moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
+ toIndexPath:(NSIndexPath *)toIndexPath
{
- if([fromIndexPath compare:toIndexPath] != NSOrderedSame)
+ if ([fromIndexPath compare:toIndexPath] != NSOrderedSame)
{
- switch([fromIndexPath section])
+ switch ([fromIndexPath section])
{
- case SECTION_BOOKMARKS:
- {
- int fromIdx = [self bookmarkIndexFromIndexPath:fromIndexPath];
- int toIdx = [self bookmarkIndexFromIndexPath:toIndexPath];
- ComputerBookmark* temp_bookmark = [[_manual_bookmarks objectAtIndex:fromIdx] retain];
- [_manual_bookmarks removeObjectAtIndex:fromIdx];
- if (toIdx >= [_manual_bookmarks count])
- [_manual_bookmarks addObject:temp_bookmark];
- else
- [_manual_bookmarks insertObject:temp_bookmark atIndex:toIdx];
- [temp_bookmark release];
-
- [self scheduleWriteManualBookmarksToDataStore];
- break;
- }
+ case SECTION_BOOKMARKS:
+ {
+ int fromIdx = [self bookmarkIndexFromIndexPath:fromIndexPath];
+ int toIdx = [self bookmarkIndexFromIndexPath:toIndexPath];
+ ComputerBookmark *temp_bookmark =
+ [[_manual_bookmarks objectAtIndex:fromIdx] retain];
+ [_manual_bookmarks removeObjectAtIndex:fromIdx];
+ if (toIdx >= [_manual_bookmarks count])
+ [_manual_bookmarks addObject:temp_bookmark];
+ else
+ [_manual_bookmarks insertObject:temp_bookmark atIndex:toIdx];
+ [temp_bookmark release];
+
+ [self scheduleWriteManualBookmarksToDataStore];
+ break;
+ }
}
}
}
-
// prevent that an item is moved befoer the Add Bookmark item
--(NSIndexPath*)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
+- (NSIndexPath *)tableView:(UITableView *)tableView
+ targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath
+ toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
- // don't allow to move:
- // - items between sections
- // - the quick connect/quick create bookmark cell
- // - any item while a search is applied
- if([proposedDestinationIndexPath row] == 0 || ([sourceIndexPath section] != [proposedDestinationIndexPath section]) ||
- _manual_search_result != nil)
- {
- return sourceIndexPath;
- }
- else
- {
- return proposedDestinationIndexPath;
- }
+ // don't allow to move:
+ // - items between sections
+ // - the quick connect/quick create bookmark cell
+ // - any item while a search is applied
+ if ([proposedDestinationIndexPath row] == 0 ||
+ ([sourceIndexPath section] != [proposedDestinationIndexPath section]) ||
+ _manual_search_result != nil)
+ {
+ return sourceIndexPath;
+ }
+ else
+ {
+ return proposedDestinationIndexPath;
+ }
}
-
// Override to support conditional rearranging of the table view.
-- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
+- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
+{
// dont allow to reorder Add Bookmark item
- if([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
+ if ([indexPath section] == SECTION_BOOKMARKS && [indexPath row] == 0)
return NO;
- return YES;
+ return YES;
}
-- (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- if(section == SECTION_SESSIONS && [_active_sessions count] > 0)
+ if (section == SECTION_SESSIONS && [_active_sessions count] > 0)
return NSLocalizedString(@"My Sessions", @"'My Session': section sessions header");
- if(section == SECTION_BOOKMARKS)
- return NSLocalizedString(@"Manual Connections", @"'Manual Connections': section manual bookmarks header");
+ if (section == SECTION_BOOKMARKS)
+ return NSLocalizedString(@"Manual Connections",
+ @"'Manual Connections': section manual bookmarks header");
return nil;
}
-- (NSString*)tableView:(UITableView*)tableView titleForFooterInSection:(NSInteger)section
+- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
- if([indexPath section] == SECTION_SESSIONS)
- return 72;
- return [tableView rowHeight];
+ if ([indexPath section] == SECTION_SESSIONS)
+ return 72;
+ return [tableView rowHeight];
}
#pragma mark -
@@ -423,141 +476,172 @@
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
- [super setEditing:editing animated:animated];
- [[self tableView] setEditing:editing animated:animated];
+ [super setEditing:editing animated:animated];
+ [[self tableView] setEditing:editing animated:animated];
}
-- (void)accessoryButtonTapped:(UIControl*)button withEvent:(UIEvent*)event
+- (void)accessoryButtonTapped:(UIControl *)button withEvent:(UIEvent *)event
{
- // forward a tap on our custom accessory button to the real accessory button handler
- NSIndexPath* indexPath = [[self tableView] indexPathForRowAtPoint:[[[event touchesForView:button] anyObject] locationInView:[self tableView]]];
- if (indexPath == nil)
- return;
-
- [[[self tableView] delegate] tableView:[self tableView] accessoryButtonTappedForRowWithIndexPath:indexPath];
+ // forward a tap on our custom accessory button to the real accessory button handler
+ NSIndexPath *indexPath =
+ [[self tableView] indexPathForRowAtPoint:[[[event touchesForView:button] anyObject]
+ locationInView:[self tableView]]];
+ if (indexPath == nil)
+ return;
+
+ [[[self tableView] delegate] tableView:[self tableView]
+ accessoryButtonTappedForRowWithIndexPath:indexPath];
}
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
-{
- if([indexPath section] == SECTION_SESSIONS)
- {
- // resume session
- RDPSession* session = [_active_sessions objectAtIndex:[indexPath row]];
- UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease];
- [ctrl setHidesBottomBarWhenPushed:YES];
- [[self navigationController] pushViewController:ctrl animated:YES];
- }
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if ([indexPath section] == SECTION_SESSIONS)
+ {
+ // resume session
+ RDPSession *session = [_active_sessions objectAtIndex:[indexPath row]];
+ UIViewController *ctrl =
+ [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView"
+ bundle:nil
+ session:session] autorelease];
+ [ctrl setHidesBottomBarWhenPushed:YES];
+ [[self navigationController] pushViewController:ctrl animated:YES];
+ }
else
{
- ComputerBookmark* bookmark = nil;
- if([indexPath section] == SECTION_BOOKMARKS)
+ ComputerBookmark *bookmark = nil;
+ if ([indexPath section] == SECTION_BOOKMARKS)
{
- // first row has either quick connect or add bookmark item
- if([indexPath row] == 0)
- {
- if ([[_searchBar text] length] == 0)
- {
- // show add bookmark controller
- ComputerBookmark *bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
- BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
- [bookmarkEditorController setTitle:NSLocalizedString(@"Add Connection", @"Add Connection title")];
- [bookmarkEditorController setDelegate:self];
- [bookmarkEditorController setHidesBottomBarWhenPushed:YES];
- [[self navigationController] pushViewController:bookmarkEditorController animated:YES];
- }
- else
- {
- // create a quick connect bookmark and add an entry to the quick connect history (if not already in the history)
- bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
- if (![_connection_history containsObject:[_searchBar text]])
- {
- [_connection_history addObject:[_searchBar text]];
- [self scheduleWriteConnectionHistoryToDataStore];
- }
- }
- }
- else
- {
- if(_manual_search_result != nil)
- {
- if ([self isIndexPathToHistoryItem:indexPath])
- {
- // create a quick connect bookmark for a history item
- NSString* item = [_history_search_result objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
- bookmark = [self bookmarkForQuickConnectTo:item];
- }
- else
- bookmark = [[_manual_search_result objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]] valueForKey:@"bookmark"];
- }
- else
- bookmark = [_manual_bookmarks objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]; // -1 because of ADD BOOKMARK entry
- }
-
- // set reachability status
- WakeUpWWAN();
- [bookmark setConntectedViaWLAN:[[Reachability reachabilityWithHostName:[[bookmark params] StringForKey:@"hostname"]] currentReachabilityStatus] == ReachableViaWiFi];
+ // first row has either quick connect or add bookmark item
+ if ([indexPath row] == 0)
+ {
+ if ([[_searchBar text] length] == 0)
+ {
+ // show add bookmark controller
+ ComputerBookmark *bookmark =
+ [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
+ BookmarkEditorController *bookmarkEditorController =
+ [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
+ [bookmarkEditorController
+ setTitle:NSLocalizedString(@"Add Connection", @"Add Connection title")];
+ [bookmarkEditorController setDelegate:self];
+ [bookmarkEditorController setHidesBottomBarWhenPushed:YES];
+ [[self navigationController] pushViewController:bookmarkEditorController
+ animated:YES];
+ }
+ else
+ {
+ // create a quick connect bookmark and add an entry to the quick connect history
+ // (if not already in the history)
+ bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
+ if (![_connection_history containsObject:[_searchBar text]])
+ {
+ [_connection_history addObject:[_searchBar text]];
+ [self scheduleWriteConnectionHistoryToDataStore];
+ }
+ }
+ }
+ else
+ {
+ if (_manual_search_result != nil)
+ {
+ if ([self isIndexPathToHistoryItem:indexPath])
+ {
+ // create a quick connect bookmark for a history item
+ NSString *item = [_history_search_result
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
+ bookmark = [self bookmarkForQuickConnectTo:item];
+ }
+ else
+ bookmark = [[_manual_search_result
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
+ valueForKey:@"bookmark"];
+ }
+ else
+ bookmark = [_manual_bookmarks
+ objectAtIndex:[self bookmarkIndexFromIndexPath:
+ indexPath]]; // -1 because of ADD BOOKMARK entry
+ }
+
+ // set reachability status
+ WakeUpWWAN();
+ [bookmark
+ setConntectedViaWLAN:[[Reachability
+ reachabilityWithHostName:[[bookmark params]
+ StringForKey:@"hostname"]]
+ currentReachabilityStatus] == ReachableViaWiFi];
}
-
- if(bookmark != nil)
- {
+
+ if (bookmark != nil)
+ {
// create rdp session
- RDPSession* session = [[[RDPSession alloc] initWithBookmark:bookmark] autorelease];
- UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease];
- [ctrl setHidesBottomBarWhenPushed:YES];
- [[self navigationController] pushViewController:ctrl animated:YES];
- [_active_sessions addObject:session];
- }
+ RDPSession *session = [[[RDPSession alloc] initWithBookmark:bookmark] autorelease];
+ UIViewController *ctrl =
+ [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView"
+ bundle:nil
+ session:session] autorelease];
+ [ctrl setHidesBottomBarWhenPushed:YES];
+ [[self navigationController] pushViewController:ctrl animated:YES];
+ [_active_sessions addObject:session];
+ }
}
}
-
-- (void)tableView:(UITableView*)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath*)indexPath
-{
+- (void)tableView:(UITableView *)tableView
+ accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
+{
// get the bookmark
- NSString* bookmark_editor_title = NSLocalizedString(@"Edit Connection", @"Edit Connection title");
- ComputerBookmark* bookmark = nil;
+ NSString *bookmark_editor_title =
+ NSLocalizedString(@"Edit Connection", @"Edit Connection title");
+ ComputerBookmark *bookmark = nil;
if ([indexPath section] == SECTION_BOOKMARKS)
{
- if ([indexPath row] == 0)
- {
- // create a new bookmark and init hostname and label
- bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
- bookmark_editor_title = NSLocalizedString(@"Add Connection", @"Add Connection title");
- }
- else
- {
- if (_manual_search_result != nil)
- {
- if ([self isIndexPathToHistoryItem:indexPath])
- {
- // create a new bookmark and init hostname and label
- NSString* item = [_history_search_result objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
- bookmark = [self bookmarkForQuickConnectTo:item];
- bookmark_editor_title = NSLocalizedString(@"Add Connection", @"Add Connection title");
- }
- else
- bookmark = [[_manual_search_result objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]] valueForKey:@"bookmark"];
- }
- else
- bookmark = [_manual_bookmarks objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]; // -1 because of ADD BOOKMARK entry
- }
+ if ([indexPath row] == 0)
+ {
+ // create a new bookmark and init hostname and label
+ bookmark = [self bookmarkForQuickConnectTo:[_searchBar text]];
+ bookmark_editor_title = NSLocalizedString(@"Add Connection", @"Add Connection title");
+ }
+ else
+ {
+ if (_manual_search_result != nil)
+ {
+ if ([self isIndexPathToHistoryItem:indexPath])
+ {
+ // create a new bookmark and init hostname and label
+ NSString *item = [_history_search_result
+ objectAtIndex:[self historyIndexFromIndexPath:indexPath]];
+ bookmark = [self bookmarkForQuickConnectTo:item];
+ bookmark_editor_title =
+ NSLocalizedString(@"Add Connection", @"Add Connection title");
+ }
+ else
+ bookmark = [[_manual_search_result
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]
+ valueForKey:@"bookmark"];
+ }
+ else
+ bookmark = [_manual_bookmarks
+ objectAtIndex:[self bookmarkIndexFromIndexPath:indexPath]]; // -1 because of ADD
+ // BOOKMARK entry
+ }
}
- // bookmark found? - start the editor
+ // bookmark found? - start the editor
if (bookmark != nil)
{
- BookmarkEditorController* editBookmarkController = [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
- [editBookmarkController setHidesBottomBarWhenPushed:YES];
- [editBookmarkController setTitle:bookmark_editor_title];
- [editBookmarkController setDelegate:self];
- [[self navigationController] pushViewController:editBookmarkController animated:YES];
+ BookmarkEditorController *editBookmarkController =
+ [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease];
+ [editBookmarkController setHidesBottomBarWhenPushed:YES];
+ [editBookmarkController setTitle:bookmark_editor_title];
+ [editBookmarkController setDelegate:self];
+ [[self navigationController] pushViewController:editBookmarkController animated:YES];
}
}
#pragma mark -
#pragma mark Search Bar Delegates
-- (BOOL)searchBarShouldBeginEditing:(UISearchBar*)searchBar
+- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
// show cancel button
[searchBar setShowsCancelButton:YES animated:YES];
@@ -569,19 +653,19 @@
// clear search result
[_manual_search_result release];
_manual_search_result = nil;
-
+
// clear text and remove cancel button
[searchBar setText:@""];
[searchBar resignFirstResponder];
}
-- (BOOL)searchBarShouldEndEditing:(UISearchBar*)searchBar
-{
+- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
+{
[searchBar setShowsCancelButton:NO animated:YES];
-
+
// re-enable table selection
[_tableView setAllowsSelection:YES];
-
+
return YES;
}
@@ -590,163 +674,183 @@
[_searchBar resignFirstResponder];
}
-- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText
+- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
- [self performSearch:searchText];
+ [self performSearch:searchText];
[_tableView reloadData];
}
#pragma mark - Session handling
// session was added
-- (void)sessionDisconnected:(NSNotification*)notification
+- (void)sessionDisconnected:(NSNotification *)notification
{
- // remove session from active sessions
- RDPSession* session = (RDPSession*)[notification object];
- [_active_sessions removeObject:session];
+ // remove session from active sessions
+ RDPSession *session = (RDPSession *)[notification object];
+ [_active_sessions removeObject:session];
- // if this view is currently active refresh entries
- if([[self navigationController] visibleViewController] == self)
- [_tableView reloadSections:[NSIndexSet indexSetWithIndex:SECTION_SESSIONS] withRowAnimation:UITableViewRowAnimationNone];
-
- // if session's bookmark is not in the bookmark list ask the user if he wants to add it
- // (this happens if the session is created using the quick connect feature)
- if (![_manual_bookmarks containsObject:[session bookmark]])
- {
- // retain the bookmark in case we want to save it later
- _temporary_bookmark = [[session bookmark] retain];
-
- // ask the user if he wants to save the bookmark
- NSString* title = NSLocalizedString(@"Save Connection Settings?", @"Save connection settings title");
- NSString* message = NSLocalizedString(@"Your Connection Settings have not been saved. Do you want to save them?", @"Save connection settings message");
- BlockAlertView* alert = [BlockAlertView alertWithTitle:title message:message];
- [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
- [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Yes Button") block:^{
- if (_temporary_bookmark)
- {
- [_manual_bookmarks addObject:_temporary_bookmark];
- [_tableView reloadSections:[NSIndexSet indexSetWithIndex:SECTION_BOOKMARKS] withRowAnimation:UITableViewRowAnimationNone];
- [_temporary_bookmark autorelease];
- _temporary_bookmark = nil;
- }
- }];
- [alert show];
- }
+ // if this view is currently active refresh entries
+ if ([[self navigationController] visibleViewController] == self)
+ [_tableView reloadSections:[NSIndexSet indexSetWithIndex:SECTION_SESSIONS]
+ withRowAnimation:UITableViewRowAnimationNone];
+
+ // if session's bookmark is not in the bookmark list ask the user if he wants to add it
+ // (this happens if the session is created using the quick connect feature)
+ if (![_manual_bookmarks containsObject:[session bookmark]])
+ {
+ // retain the bookmark in case we want to save it later
+ _temporary_bookmark = [[session bookmark] retain];
+
+ // ask the user if he wants to save the bookmark
+ NSString *title =
+ NSLocalizedString(@"Save Connection Settings?", @"Save connection settings title");
+ NSString *message = NSLocalizedString(
+ @"Your Connection Settings have not been saved. Do you want to save them?",
+ @"Save connection settings message");
+ BlockAlertView *alert = [BlockAlertView alertWithTitle:title message:message];
+ [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
+ [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Yes Button")
+ block:^{
+ if (_temporary_bookmark)
+ {
+ [_manual_bookmarks addObject:_temporary_bookmark];
+ [_tableView
+ reloadSections:[NSIndexSet
+ indexSetWithIndex:SECTION_BOOKMARKS]
+ withRowAnimation:UITableViewRowAnimationNone];
+ [_temporary_bookmark autorelease];
+ _temporary_bookmark = nil;
+ }
+ }];
+ [alert show];
+ }
}
-- (void)sessionFailedToConnect:(NSNotification*)notification
+- (void)sessionFailedToConnect:(NSNotification *)notification
{
- // remove session from active sessions
- RDPSession* session = (RDPSession*)[notification object];
- [_active_sessions removeObject:session];
-
- // display error toast
- [[self view] makeToast:NSLocalizedString(@"Failed to connect to session!", @"Failed to connect error message") duration:ToastDurationNormal position:@"center"];
+ // remove session from active sessions
+ RDPSession *session = (RDPSession *)[notification object];
+ [_active_sessions removeObject:session];
+
+ // display error toast
+ [[self view] makeToast:NSLocalizedString(@"Failed to connect to session!",
+ @"Failed to connect error message")
+ duration:ToastDurationNormal
+ position:@"center"];
}
#pragma mark - Reachability notification
-- (void)reachabilityChanged:(NSNotification*)notification
+- (void)reachabilityChanged:(NSNotification *)notification
{
- // no matter how the network changed - we will disconnect
- // disconnect session (if there is any)
- if ([_active_sessions count] > 0)
- {
- RDPSession* session = [_active_sessions objectAtIndex:0];
- [session disconnect];
- }
+ // no matter how the network changed - we will disconnect
+ // disconnect session (if there is any)
+ if ([_active_sessions count] > 0)
+ {
+ RDPSession *session = [_active_sessions objectAtIndex:0];
+ [session disconnect];
+ }
}
#pragma mark - BookmarkEditorController delegate
- (void)commitBookmark:(ComputerBookmark *)bookmark
{
- // if we got a manual bookmark that is not in the list yet - add it otherwise replace it
- BOOL found = NO;
- for (int idx = 0; idx < [_manual_bookmarks count]; ++idx)
- {
- if ([[bookmark uuid] isEqualToString:[[_manual_bookmarks objectAtIndex:idx] uuid]])
- {
- [_manual_bookmarks replaceObjectAtIndex:idx withObject:bookmark];
- found = YES;
- break;
- }
- }
- if (!found)
- [_manual_bookmarks addObject:bookmark];
-
- // remove any quick connect history entry with the same hostname
- NSString* hostname = [[bookmark params] StringForKey:@"hostname"];
- if ([_connection_history containsObject:hostname])
- {
- [_connection_history removeObject:hostname];
- [self scheduleWriteConnectionHistoryToDataStore];
- }
-
- [self scheduleWriteManualBookmarksToDataStore];
+ // if we got a manual bookmark that is not in the list yet - add it otherwise replace it
+ BOOL found = NO;
+ for (int idx = 0; idx < [_manual_bookmarks count]; ++idx)
+ {
+ if ([[bookmark uuid] isEqualToString:[[_manual_bookmarks objectAtIndex:idx] uuid]])
+ {
+ [_manual_bookmarks replaceObjectAtIndex:idx withObject:bookmark];
+ found = YES;
+ break;
+ }
+ }
+ if (!found)
+ [_manual_bookmarks addObject:bookmark];
+
+ // remove any quick connect history entry with the same hostname
+ NSString *hostname = [[bookmark params] StringForKey:@"hostname"];
+ if ([_connection_history containsObject:hostname])
+ {
+ [_connection_history removeObject:hostname];
+ [self scheduleWriteConnectionHistoryToDataStore];
+ }
+
+ [self scheduleWriteManualBookmarksToDataStore];
}
- (IBAction)disconnectButtonPressed:(id)sender
{
- // disconnect session and refresh table view
- RDPSession* session = [_active_sessions objectAtIndex:[sender tag]];
- [session disconnect];
+ // disconnect session and refresh table view
+ RDPSession *session = [_active_sessions objectAtIndex:[sender tag]];
+ [session disconnect];
}
#pragma mark - Misc functions
- (BOOL)hasNoBookmarks
{
- return ([_manual_bookmarks count] == 0);
+ return ([_manual_bookmarks count] == 0);
}
-- (UIButton*)disclosureButtonWithImage:(UIImage*)image
+- (UIButton *)disclosureButtonWithImage:(UIImage *)image
{
- // we make the button a little bit bigger (image widht * 2, height + 10) so that the user doesn't accidentally connect to the bookmark ...
- UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setFrame:CGRectMake(0, 0, [image size].width * 2, [image size].height + 10)];
- [button setImage:image forState:UIControlStateNormal];
- [button addTarget:self action:@selector(accessoryButtonTapped:withEvent:) forControlEvents:UIControlEventTouchUpInside];
- [button setUserInteractionEnabled:YES];
- return button;
+ // we make the button a little bit bigger (image widht * 2, height + 10) so that the user
+ // doesn't accidentally connect to the bookmark ...
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
+ [button setFrame:CGRectMake(0, 0, [image size].width * 2, [image size].height + 10)];
+ [button setImage:image forState:UIControlStateNormal];
+ [button addTarget:self
+ action:@selector(accessoryButtonTapped:withEvent:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [button setUserInteractionEnabled:YES];
+ return button;
}
-- (void)performSearch:(NSString*)searchText
+- (void)performSearch:(NSString *)searchText
{
- [_manual_search_result autorelease];
-
- if([searchText length] > 0)
+ [_manual_search_result autorelease];
+
+ if ([searchText length] > 0)
{
- _manual_search_result = [FilterBookmarks(_manual_bookmarks, [searchText componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]) retain];
- _history_search_result = [FilterHistory(_connection_history, searchText) retain];
- }
+ _manual_search_result = [FilterBookmarks(
+ _manual_bookmarks,
+ [searchText componentsSeparatedByCharactersInSet:[NSCharacterSet
+ whitespaceAndNewlineCharacterSet]])
+ retain];
+ _history_search_result = [FilterHistory(_connection_history, searchText) retain];
+ }
else
{
- _history_search_result = nil;
+ _history_search_result = nil;
_manual_search_result = nil;
- }
+ }
}
-- (int)bookmarkIndexFromIndexPath:(NSIndexPath*)indexPath
+- (int)bookmarkIndexFromIndexPath:(NSIndexPath *)indexPath
{
- return [indexPath row] - ((_history_search_result != nil) ? [_history_search_result count] : 0) - 1;
+ return [indexPath row] -
+ ((_history_search_result != nil) ? [_history_search_result count] : 0) - 1;
}
-- (int)historyIndexFromIndexPath:(NSIndexPath*)indexPath
+- (int)historyIndexFromIndexPath:(NSIndexPath *)indexPath
{
- return [indexPath row] - 1;
+ return [indexPath row] - 1;
}
-- (BOOL)isIndexPathToHistoryItem:(NSIndexPath*)indexPath
+- (BOOL)isIndexPathToHistoryItem:(NSIndexPath *)indexPath
{
- return (([indexPath row] - 1) < [_history_search_result count]);
+ return (([indexPath row] - 1) < [_history_search_result count]);
}
-- (ComputerBookmark*)bookmarkForQuickConnectTo:(NSString*)host
+- (ComputerBookmark *)bookmarkForQuickConnectTo:(NSString *)host
{
- ComputerBookmark* bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
- [bookmark setLabel:host];
- [[bookmark params] setValue:host forKey:@"hostname"];
- return bookmark;
+ ComputerBookmark *bookmark =
+ [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
+ [bookmark setLabel:host];
+ [[bookmark params] setValue:host forKey:@"hostname"];
+ return bookmark;
}
#pragma mark - Persisting bookmarks
@@ -759,76 +863,95 @@
}
- (void)writeBookmarksToDataStore
-{
- [self writeManualBookmarksToDataStore];
+{
+ [self writeManualBookmarksToDataStore];
}
- (void)scheduleWriteManualBookmarksToDataStore
{
- [[NSOperationQueue mainQueue] addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(writeManualBookmarksToDataStore) object:nil] autorelease]];
+ [[NSOperationQueue mainQueue]
+ addOperation:[[[NSInvocationOperation alloc]
+ initWithTarget:self
+ selector:@selector(writeManualBookmarksToDataStore)
+ object:nil] autorelease]];
}
- (void)writeManualBookmarksToDataStore
-{
- [self writeArray:_manual_bookmarks toDataStoreURL:[self manualBookmarksDataStoreURL]];
+{
+ [self writeArray:_manual_bookmarks toDataStoreURL:[self manualBookmarksDataStoreURL]];
}
- (void)scheduleWriteConnectionHistoryToDataStore
{
- [[NSOperationQueue mainQueue] addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(writeConnectionHistoryToDataStore) object:nil] autorelease]];
+ [[NSOperationQueue mainQueue]
+ addOperation:[[[NSInvocationOperation alloc]
+ initWithTarget:self
+ selector:@selector(writeConnectionHistoryToDataStore)
+ object:nil] autorelease]];
}
- (void)writeConnectionHistoryToDataStore
-{
- [self writeArray:_connection_history toDataStoreURL:[self connectionHistoryDataStoreURL]];
+{
+ [self writeArray:_connection_history toDataStoreURL:[self connectionHistoryDataStoreURL]];
}
-- (void)writeArray:(NSArray*)bookmarks toDataStoreURL:(NSURL*)url
+- (void)writeArray:(NSArray *)bookmarks toDataStoreURL:(NSURL *)url
{
- NSData* archived_data = [NSKeyedArchiver archivedDataWithRootObject:bookmarks];
- [archived_data writeToURL:url atomically:YES];
+ NSData *archived_data = [NSKeyedArchiver archivedDataWithRootObject:bookmarks];
+ [archived_data writeToURL:url atomically:YES];
}
- (void)readManualBookmarksFromDataStore
{
- [_manual_bookmarks autorelease];
- _manual_bookmarks = [self arrayFromDataStoreURL:[self manualBookmarksDataStoreURL]];
+ [_manual_bookmarks autorelease];
+ _manual_bookmarks = [self arrayFromDataStoreURL:[self manualBookmarksDataStoreURL]];
- if(_manual_bookmarks == nil)
- {
- _manual_bookmarks = [[NSMutableArray alloc] init];
- [_manual_bookmarks addObject:[[[GlobalDefaults sharedGlobalDefaults] newTestServerBookmark] autorelease]];
- }
+ if (_manual_bookmarks == nil)
+ {
+ _manual_bookmarks = [[NSMutableArray alloc] init];
+ [_manual_bookmarks
+ addObject:[[[GlobalDefaults sharedGlobalDefaults] newTestServerBookmark] autorelease]];
+ }
}
- (void)readConnectionHistoryFromDataStore
{
- [_connection_history autorelease];
- _connection_history = [self arrayFromDataStoreURL:[self connectionHistoryDataStoreURL]];
-
- if(_connection_history == nil)
- _connection_history = [[NSMutableArray alloc] init];
+ [_connection_history autorelease];
+ _connection_history = [self arrayFromDataStoreURL:[self connectionHistoryDataStoreURL]];
+
+ if (_connection_history == nil)
+ _connection_history = [[NSMutableArray alloc] init];
}
-- (NSMutableArray*)arrayFromDataStoreURL:(NSURL*)url
+- (NSMutableArray *)arrayFromDataStoreURL:(NSURL *)url
{
- NSData* archived_data = [NSData dataWithContentsOfURL:url];
-
+ NSData *archived_data = [NSData dataWithContentsOfURL:url];
+
if (!archived_data)
return nil;
-
+
return [[NSKeyedUnarchiver unarchiveObjectWithData:archived_data] retain];
}
-- (NSURL*)manualBookmarksDataStoreURL
+- (NSURL *)manualBookmarksDataStoreURL
{
- return [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], @"com.freerdp.ifreerdp.bookmarks.plist"]];
+ return [NSURL
+ fileURLWithPath:[NSString stringWithFormat:@"%@/%@",
+ [NSSearchPathForDirectoriesInDomains(
+ NSDocumentDirectory, NSUserDomainMask, YES)
+ lastObject],
+ @"com.freerdp.ifreerdp.bookmarks.plist"]];
}
-- (NSURL*)connectionHistoryDataStoreURL
+- (NSURL *)connectionHistoryDataStoreURL
{
- return [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], @"com.freerdp.ifreerdp.connection_history.plist"]];
+ return [NSURL
+ fileURLWithPath:[NSString
+ stringWithFormat:@"%@/%@",
+ [NSSearchPathForDirectoriesInDomains(
+ NSDocumentDirectory, NSUserDomainMask, YES)
+ lastObject],
+ @"com.freerdp.ifreerdp.connection_history.plist"]];
}
@end
-
diff --git a/client/iOS/Controllers/CredentialsEditorController.h b/client/iOS/Controllers/CredentialsEditorController.h
index 7fc5e2f42..4dc12c3ef 100644
--- a/client/iOS/Controllers/CredentialsEditorController.h
+++ b/client/iOS/Controllers/CredentialsEditorController.h
@@ -1,10 +1,11 @@
/*
Controller to edit bookmark credentials
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -14,12 +15,12 @@
@interface CredentialsEditorController : EditorBaseController
{
-@private
- ComputerBookmark* _bookmark;
- ConnectionParams* _params;
+ @private
+ ComputerBookmark *_bookmark;
+ ConnectionParams *_params;
}
// init for the given bookmark
-- (id)initWithBookmark:(ComputerBookmark*)bookmark;
+- (id)initWithBookmark:(ComputerBookmark *)bookmark;
@end
diff --git a/client/iOS/Controllers/CredentialsEditorController.m b/client/iOS/Controllers/CredentialsEditorController.m
index 365da4cd4..4dbea53bc 100644
--- a/client/iOS/Controllers/CredentialsEditorController.m
+++ b/client/iOS/Controllers/CredentialsEditorController.m
@@ -1,10 +1,11 @@
/*
Controller to edit bookmark credentials
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "CredentialsEditorController.h"
@@ -20,59 +21,60 @@
@implementation CredentialsEditorController
-- (id)initWithBookmark:(ComputerBookmark*)bookmark
+- (id)initWithBookmark:(ComputerBookmark *)bookmark
{
- if ((self = [super initWithStyle:UITableViewStyleGrouped]))
+ if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
// set additional settings state according to bookmark data
_bookmark = [bookmark retain];
- _params = [bookmark params];
- }
- return self;
+ _params = [bookmark params];
+ }
+ return self;
}
- (void)viewDidLoad
{
- [super viewDidLoad];
- [self setTitle:NSLocalizedString(@"Credentials", @"Credentials title")];
+ [super viewDidLoad];
+ [self setTitle:NSLocalizedString(@"Credentials", @"Credentials title")];
}
- (void)viewDidUnload
{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
}
- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
-
- // foce any active editing to stop
- [[self view] endEditing:NO];
+ [super viewWillDisappear:animated];
+
+ // foce any active editing to stop
+ [[self view] endEditing:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
- (void)dealloc
{
- [super dealloc];
- [_bookmark release];
+ [super dealloc];
+ [_bookmark release];
}
#pragma mark -
#pragma mark Table view data source
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return SECTION_COUNT;
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ // Return the number of sections.
+ return SECTION_COUNT;
}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ // Return the number of rows in the section.
switch (section)
{
case SECTION_CREDENTIALS: // credentials
@@ -80,15 +82,14 @@
default:
break;
}
-
- return 0;
-}
+ return 0;
+}
// set section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
- switch(section)
+ switch (section)
{
case SECTION_CREDENTIALS:
return NSLocalizedString(@"Credentials", @"'Credentials': credentials settings header");
@@ -96,88 +97,93 @@
return @"unknown";
}
-
// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+
// determine the required cell type
- NSString* cellType = nil;
- switch([indexPath section])
+ NSString *cellType = nil;
+ switch ([indexPath section])
{
case SECTION_CREDENTIALS: // credentials
- if([indexPath row] == 1)
- cellType = TableCellIdentifierSecretText; // password field
- else
- cellType = TableCellIdentifierText;
+ if ([indexPath row] == 1)
+ cellType = TableCellIdentifierSecretText; // password field
+ else
+ cellType = TableCellIdentifierText;
break;
-
- default:
- break;
- }
- NSAssert(cellType != nil, @"Couldn't determine cell type");
-
- // get the table view cell
- UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
- NSAssert(cell, @"Invalid cell");
-
- // set cell values
- switch([indexPath section])
- {
- // credentials
- case SECTION_CREDENTIALS:
- [self initCredentialSettings:indexPath cell:cell];
- break;
-
+
default:
break;
- }
-
- return cell;
+ }
+ NSAssert(cellType != nil, @"Couldn't determine cell type");
+
+ // get the table view cell
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType];
+ NSAssert(cell, @"Invalid cell");
+
+ // set cell values
+ switch ([indexPath section])
+ {
+ // credentials
+ case SECTION_CREDENTIALS:
+ [self initCredentialSettings:indexPath cell:cell];
+ break;
+
+ default:
+ break;
+ }
+
+ return cell;
}
-
// updates credentials in the UI
-- (void)initCredentialSettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell
+- (void)initCredentialSettings:(NSIndexPath *)indexPath cell:(UITableViewCell *)cell
{
- switch(indexPath.row)
+ switch (indexPath.row)
{
case 0:
- {
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell label] setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
+ {
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell label]
+ setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")];
[[textCell textfield] setText:[_params StringForKey:@"username"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
- break;
- }
- case 1:
- {
- EditSecretTextTableViewCell* textCell = (EditSecretTextTableViewCell*)cell;
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[textCell label] setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
- [[textCell textfield] setText:[_params StringForKey:@"password"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
break;
- }
+ }
+ case 1:
+ {
+ EditSecretTextTableViewCell *textCell = (EditSecretTextTableViewCell *)cell;
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ [[textCell label]
+ setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")];
+ [[textCell textfield] setText:[_params StringForKey:@"password"]];
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ break;
+ }
case 2:
- {
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
+ {
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)];
[[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")];
[[textCell textfield] setText:[_params StringForKey:@"domain"]];
- [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
- break;
- }
+ [[textCell textfield]
+ setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")];
+ break;
+ }
default:
NSLog(@"Invalid row index in settings table!");
break;
- }
+ }
}
#pragma mark -
#pragma mark Text Field delegate
-- (BOOL)textFieldShouldReturn:(UITextField*)textField
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
@@ -185,13 +191,13 @@
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
- switch(textField.tag)
- {
- // update credentials settings
+ switch (textField.tag)
+ {
+ // update credentials settings
case GET_TAG(SECTION_CREDENTIALS, 0):
[_params setValue:[textField text] forKey:@"username"];
break;
-
+
case GET_TAG(SECTION_CREDENTIALS, 1):
[_params setValue:[textField text] forKey:@"password"];
break;
@@ -199,7 +205,7 @@
case GET_TAG(SECTION_CREDENTIALS, 2):
[_params setValue:[textField text] forKey:@"domain"];
break;
-
+
default:
break;
}
diff --git a/client/iOS/Controllers/CredentialsInputController.h b/client/iOS/Controllers/CredentialsInputController.h
index 9a4c5e204..9bfbda549 100644
--- a/client/iOS/Controllers/CredentialsInputController.h
+++ b/client/iOS/Controllers/CredentialsInputController.h
@@ -1,10 +1,11 @@
/*
Credentials input controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -13,19 +14,22 @@
@interface CredentialsInputController : UIViewController
{
-@private
- IBOutlet UITextField* _textfield_username;
- IBOutlet UITextField* _textfield_password;
- IBOutlet UITextField* _textfield_domain;
- IBOutlet UIButton* _btn_login;
- IBOutlet UIButton* _btn_cancel;
- IBOutlet UIScrollView* _scroll_view;
- IBOutlet UILabel* _lbl_message;
-
- RDPSession* _session;
- NSMutableDictionary* _params;
+ @private
+ IBOutlet UITextField *_textfield_username;
+ IBOutlet UITextField *_textfield_password;
+ IBOutlet UITextField *_textfield_domain;
+ IBOutlet UIButton *_btn_login;
+ IBOutlet UIButton *_btn_cancel;
+ IBOutlet UIScrollView *_scroll_view;
+ IBOutlet UILabel *_lbl_message;
+
+ RDPSession *_session;
+ NSMutableDictionary *_params;
}
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession*)session params:(NSMutableDictionary*)params;
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session
+ params:(NSMutableDictionary *)params;
@end
diff --git a/client/iOS/Controllers/CredentialsInputController.m b/client/iOS/Controllers/CredentialsInputController.m
index c48f616a1..fed6c727c 100644
--- a/client/iOS/Controllers/CredentialsInputController.m
+++ b/client/iOS/Controllers/CredentialsInputController.m
@@ -1,10 +1,11 @@
/*
Credentials input controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "CredentialsInputController.h"
@@ -13,121 +14,147 @@
@implementation CredentialsInputController
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession *)session params:(NSMutableDictionary *)params
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session
+ params:(NSMutableDictionary *)params
{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- _session = session;
- _params = params;
- [self setModalPresentationStyle:UIModalPresentationFormSheet];
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self)
+ {
+ _session = session;
+ _params = params;
+ [self setModalPresentationStyle:UIModalPresentationFormSheet];
- // on iphone we have the problem that the buttons are hidden by the keyboard
- // we solve this issue by registering keyboard notification handlers and adjusting the scrollview accordingly
- if (IsPhone())
- {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name: UIKeyboardWillHideNotification object:nil];
- }
- }
- return self;
+ // on iphone we have the problem that the buttons are hidden by the keyboard
+ // we solve this issue by registering keyboard notification handlers and adjusting the
+ // scrollview accordingly
+ if (IsPhone())
+ {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:)
+ name:UIKeyboardWillShowNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:)
+ name:UIKeyboardWillHideNotification
+ object:nil];
+ }
+ }
+ return self;
}
- (void)viewDidLoad
{
- [super viewDidLoad];
+ [super viewDidLoad];
- // set localized strings
- [_lbl_message setText:NSLocalizedString(@"Please provide the missing user information in order to proceed and login.", @"Credentials input view message")];
- [_textfield_username setPlaceholder:NSLocalizedString(@"Username", @"Credentials Input Username hint")];
- [_textfield_password setPlaceholder:NSLocalizedString(@"Password", @"Credentials Input Password hint")];
- [_textfield_domain setPlaceholder:NSLocalizedString(@"Domain", @"Credentials Input Domain hint")];
- [_btn_login setTitle:NSLocalizedString(@"Login", @"Login Button") forState:UIControlStateNormal];
- [_btn_cancel setTitle:NSLocalizedString(@"Cancel", @"Cancel Button") forState:UIControlStateNormal];
+ // set localized strings
+ [_lbl_message
+ setText:NSLocalizedString(
+ @"Please provide the missing user information in order to proceed and login.",
+ @"Credentials input view message")];
+ [_textfield_username
+ setPlaceholder:NSLocalizedString(@"Username", @"Credentials Input Username hint")];
+ [_textfield_password
+ setPlaceholder:NSLocalizedString(@"Password", @"Credentials Input Password hint")];
+ [_textfield_domain
+ setPlaceholder:NSLocalizedString(@"Domain", @"Credentials Input Domain hint")];
+ [_btn_login setTitle:NSLocalizedString(@"Login", @"Login Button")
+ forState:UIControlStateNormal];
+ [_btn_cancel setTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
+ forState:UIControlStateNormal];
- // init scrollview content size
- [_scroll_view setContentSize:[_scroll_view frame].size];
-
- // set params in the view
- [_textfield_username setText:[_params valueForKey:@"username"]];
- [_textfield_password setText:[_params valueForKey:@"password"]];
- [_textfield_domain setText:[_params valueForKey:@"domain"]];
+ // init scrollview content size
+ [_scroll_view setContentSize:[_scroll_view frame].size];
+
+ // set params in the view
+ [_textfield_username setText:[_params valueForKey:@"username"]];
+ [_textfield_password setText:[_params valueForKey:@"password"]];
+ [_textfield_domain setText:[_params valueForKey:@"domain"]];
}
- (void)viewDidUnload
{
- [super viewDidUnload];
+ [super viewDidUnload];
}
- (void)viewDidDisappear:(BOOL)animated
{
- [super viewDidDisappear:animated];
- // set signal
- [[_session uiRequestCompleted] signal];
+ [super viewDidDisappear:animated];
+ // set signal
+ [[_session uiRequestCompleted] signal];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
- (void)dealloc
{
- [super dealloc];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark -
#pragma mark iOS Keyboard Notification Handlers
- (void)keyboardWillShow:(NSNotification *)notification
-{
- CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
-
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
- [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
+{
+ CGRect keyboardEndFrame =
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
+
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationCurve:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
+ [UIView
+ setAnimationDuration:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
CGRect frame = [_scroll_view frame];
- frame.size.height -= keyboardFrame.size.height;
+ frame.size.height -= keyboardFrame.size.height;
[_scroll_view setFrame:frame];
- [UIView commitAnimations];
+ [UIView commitAnimations];
}
- (void)keyboardWillHide:(NSNotification *)notification
{
- CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
+ CGRect keyboardEndFrame =
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
- [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationCurve:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
+ [UIView
+ setAnimationDuration:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
CGRect frame = [_scroll_view frame];
- frame.size.height += keyboardFrame.size.height;
+ frame.size.height += keyboardFrame.size.height;
[_scroll_view setFrame:frame];
- [UIView commitAnimations];
+ [UIView commitAnimations];
}
-
#pragma mark - Action handlers
- (IBAction)loginPressed:(id)sender
{
- // read input back in
- [_params setValue:[_textfield_username text] forKey:@"username"];
- [_params setValue:[_textfield_password text] forKey:@"password"];
- [_params setValue:[_textfield_domain text] forKey:@"domain"];
- [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
+ // read input back in
+ [_params setValue:[_textfield_username text] forKey:@"username"];
+ [_params setValue:[_textfield_password text] forKey:@"password"];
+ [_params setValue:[_textfield_domain text] forKey:@"domain"];
+ [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
- // dismiss controller
- [self dismissModalViewControllerAnimated:YES];
+ // dismiss controller
+ [self dismissModalViewControllerAnimated:YES];
}
- (IBAction)cancelPressed:(id)sender
{
- [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
-
- // dismiss controller
- [self dismissModalViewControllerAnimated:YES];
+ [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
+
+ // dismiss controller
+ [self dismissModalViewControllerAnimated:YES];
}
@end
diff --git a/client/iOS/Controllers/EditorBaseController.h b/client/iOS/Controllers/EditorBaseController.h
index 547eed54a..780bff9ce 100644
--- a/client/iOS/Controllers/EditorBaseController.h
+++ b/client/iOS/Controllers/EditorBaseController.h
@@ -1,12 +1,12 @@
/*
Basic interface for settings editors
-
- Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import
#import "EditTextTableViewCell.h"
@@ -16,29 +16,29 @@
#import "EditSecretTextTableViewCell.h"
#import "EditButtonTableViewCell.h"
-extern NSString* TableCellIdentifierText;
-extern NSString* TableCellIdentifierSecretText;
-extern NSString* TableCellIdentifierYesNo;
-extern NSString* TableCellIdentifierSelection;
-extern NSString* TableCellIdentifierSubEditor;
-extern NSString* TableCellIdentifierMultiChoice;
-extern NSString* TableCellIdentifierButton;
+extern NSString *TableCellIdentifierText;
+extern NSString *TableCellIdentifierSecretText;
+extern NSString *TableCellIdentifierYesNo;
+extern NSString *TableCellIdentifierSelection;
+extern NSString *TableCellIdentifierSubEditor;
+extern NSString *TableCellIdentifierMultiChoice;
+extern NSString *TableCellIdentifierButton;
@interface EditorBaseController : UITableViewController
-{
-@private
- IBOutlet EditTextTableViewCell* _textTableViewCell;
- IBOutlet EditSecretTextTableViewCell* _secretTextTableViewCell;
- IBOutlet EditFlagTableViewCell* _flagTableViewCell;
- IBOutlet EditSelectionTableViewCell* _selectionTableViewCell;
- IBOutlet EditSubEditTableViewCell* _subEditTableViewCell;
- IBOutlet EditButtonTableViewCell* _buttonTableViewCell;
+{
+ @private
+ IBOutlet EditTextTableViewCell *_textTableViewCell;
+ IBOutlet EditSecretTextTableViewCell *_secretTextTableViewCell;
+ IBOutlet EditFlagTableViewCell *_flagTableViewCell;
+ IBOutlet EditSelectionTableViewCell *_selectionTableViewCell;
+ IBOutlet EditSubEditTableViewCell *_subEditTableViewCell;
+ IBOutlet EditButtonTableViewCell *_buttonTableViewCell;
}
// returns one of the requested table view cells
-- (UITableViewCell*)tableViewCellFromIdentifier:(NSString*)identifier;
+- (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier;
// Adjust text input cells label/textfield widht according to the label's text size
-- (void)adjustEditTextTableViewCell:(EditTextTableViewCell*)cell;
+- (void)adjustEditTextTableViewCell:(EditTextTableViewCell *)cell;
@end
diff --git a/client/iOS/Controllers/EditorBaseController.m b/client/iOS/Controllers/EditorBaseController.m
index 48be42e3d..70c5f4e98 100644
--- a/client/iOS/Controllers/EditorBaseController.m
+++ b/client/iOS/Controllers/EditorBaseController.m
@@ -1,10 +1,11 @@
/*
Basic interface for settings editors
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -13,96 +14,97 @@
@end
-NSString* TableCellIdentifierText = @"cellIdText";
-NSString* TableCellIdentifierSecretText = @"cellIdSecretText";
-NSString* TableCellIdentifierYesNo = @"cellIdYesNo";
-NSString* TableCellIdentifierSelection = @"cellIdSelection";
-NSString* TableCellIdentifierSubEditor = @"cellIdSubEditor";
-NSString* TableCellIdentifierMultiChoice = @"cellIdMultiChoice";
-NSString* TableCellIdentifierButton = @"cellIdButton";
+NSString *TableCellIdentifierText = @"cellIdText";
+NSString *TableCellIdentifierSecretText = @"cellIdSecretText";
+NSString *TableCellIdentifierYesNo = @"cellIdYesNo";
+NSString *TableCellIdentifierSelection = @"cellIdSelection";
+NSString *TableCellIdentifierSubEditor = @"cellIdSubEditor";
+NSString *TableCellIdentifierMultiChoice = @"cellIdMultiChoice";
+NSString *TableCellIdentifierButton = @"cellIdButton";
@implementation EditorBaseController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
#pragma mark - Create table view cells
-- (UITableViewCell*)tableViewCellFromIdentifier:(NSString*)identifier
+- (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier
{
- // try to reuse a cell
- UITableViewCell* cell = [[self tableView] dequeueReusableCellWithIdentifier:identifier];
- if (cell != nil)
- return cell;
+ // try to reuse a cell
+ UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:identifier];
+ if (cell != nil)
+ return cell;
- // we have to create a new cell
- if ([identifier isEqualToString:TableCellIdentifierText])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditTextTableViewCell" owner:self options:nil];
- cell = _textTableViewCell;
- _textTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierSecretText])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditSecretTextTableViewCell" owner:self options:nil];
- cell = _secretTextTableViewCell;
- _secretTextTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierYesNo])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditFlagTableViewCell" owner:self options:nil];
- cell = _flagTableViewCell;
- _flagTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierSelection])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditSelectionTableViewCell" owner:self options:nil];
- cell = _selectionTableViewCell;
- _selectionTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierSubEditor])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditSubEditTableViewCell" owner:self options:nil];
- cell = _subEditTableViewCell;
- _subEditTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierButton])
- {
- [[NSBundle mainBundle] loadNibNamed:@"EditButtonTableViewCell" owner:self options:nil];
- cell = _buttonTableViewCell;
- _buttonTableViewCell = nil;
- }
- else if ([identifier isEqualToString:TableCellIdentifierMultiChoice])
- {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier] autorelease];
- }
- else
- {
- NSAssert(false, @"Unknown table cell identifier");
- }
-
- return cell;
+ // we have to create a new cell
+ if ([identifier isEqualToString:TableCellIdentifierText])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditTextTableViewCell" owner:self options:nil];
+ cell = _textTableViewCell;
+ _textTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierSecretText])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditSecretTextTableViewCell" owner:self options:nil];
+ cell = _secretTextTableViewCell;
+ _secretTextTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierYesNo])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditFlagTableViewCell" owner:self options:nil];
+ cell = _flagTableViewCell;
+ _flagTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierSelection])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditSelectionTableViewCell" owner:self options:nil];
+ cell = _selectionTableViewCell;
+ _selectionTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierSubEditor])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditSubEditTableViewCell" owner:self options:nil];
+ cell = _subEditTableViewCell;
+ _subEditTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierButton])
+ {
+ [[NSBundle mainBundle] loadNibNamed:@"EditButtonTableViewCell" owner:self options:nil];
+ cell = _buttonTableViewCell;
+ _buttonTableViewCell = nil;
+ }
+ else if ([identifier isEqualToString:TableCellIdentifierMultiChoice])
+ {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
+ reuseIdentifier:identifier] autorelease];
+ }
+ else
+ {
+ NSAssert(false, @"Unknown table cell identifier");
+ }
+
+ return cell;
}
#pragma mark - Utility functions
-- (void)adjustEditTextTableViewCell:(EditTextTableViewCell*)cell
+- (void)adjustEditTextTableViewCell:(EditTextTableViewCell *)cell
{
- UILabel* label = [cell label];
- UITextField* textField = [cell textfield];
-
- // adjust label
- CGFloat width = [[label text] sizeWithFont:[label font]].width;
- CGRect frame = [label frame];
- CGFloat delta = width - frame.size.width;
- frame.size.width = width;
- [label setFrame:frame];
-
- // adjust text field
- frame = [textField frame];
- frame.origin.x += delta;
- frame.size.width -= delta;
- [textField setFrame:frame];
+ UILabel *label = [cell label];
+ UITextField *textField = [cell textfield];
+
+ // adjust label
+ CGFloat width = [[label text] sizeWithFont:[label font]].width;
+ CGRect frame = [label frame];
+ CGFloat delta = width - frame.size.width;
+ frame.size.width = width;
+ [label setFrame:frame];
+
+ // adjust text field
+ frame = [textField frame];
+ frame.origin.x += delta;
+ frame.size.width -= delta;
+ [textField setFrame:frame];
}
@end
diff --git a/client/iOS/Controllers/EditorSelectionController.h b/client/iOS/Controllers/EditorSelectionController.h
index a240f1537..11c96389f 100644
--- a/client/iOS/Controllers/EditorSelectionController.h
+++ b/client/iOS/Controllers/EditorSelectionController.h
@@ -1,10 +1,11 @@
/*
Generic controller to select a single item from a list of options
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -13,18 +14,21 @@
@interface EditorSelectionController : EditorBaseController
{
- ConnectionParams* _params;
+ ConnectionParams *_params;
- // array with entries in connection parameters that are altered
- NSArray* _entries;
+ // array with entries in connection parameters that are altered
+ NSArray *_entries;
- // array with dictionaries containing label/value pairs that represent the available values for each entry
- NSArray* _selections;
-
- // current selections
- NSMutableArray* _cur_selections;
+ // array with dictionaries containing label/value pairs that represent the available values for
+ // each entry
+ NSArray *_selections;
+
+ // current selections
+ NSMutableArray *_cur_selections;
}
-- (id)initWithConnectionParams:(ConnectionParams*)params entries:(NSArray*)entries selections:(NSArray*)selections;
+- (id)initWithConnectionParams:(ConnectionParams *)params
+ entries:(NSArray *)entries
+ selections:(NSArray *)selections;
@end
diff --git a/client/iOS/Controllers/EditorSelectionController.m b/client/iOS/Controllers/EditorSelectionController.m
index 3313a8b16..13a7363b8 100644
--- a/client/iOS/Controllers/EditorSelectionController.m
+++ b/client/iOS/Controllers/EditorSelectionController.m
@@ -1,10 +1,11 @@
/*
Generic controller to select a single item from a list of options
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorSelectionController.h"
@@ -12,88 +13,92 @@
#import "OrderedDictionary.h"
@interface EditorSelectionController (Private)
-- (OrderedDictionary*)selectionForIndex:(int)index;
+- (OrderedDictionary *)selectionForIndex:(int)index;
@end
@implementation EditorSelectionController
-- (id)initWithConnectionParams:(ConnectionParams*)params entries:(NSArray *)entries selections:(NSArray *)selections
+- (id)initWithConnectionParams:(ConnectionParams *)params
+ entries:(NSArray *)entries
+ selections:(NSArray *)selections
{
- self = [super initWithStyle:UITableViewStyleGrouped];
- if (self)
- {
- _params = [params retain];
- _entries = [entries retain];
- _selections = [selections retain];
-
- // allocate and init current selections array
- _cur_selections = [[NSMutableArray alloc] initWithCapacity:[_entries count]];
- for (int i = 0; i < [entries count]; ++i)
- {
- NSString* entry = [entries objectAtIndex:i];
- if([_params hasValueForKeyPath:entry])
- {
- NSUInteger idx = [(OrderedDictionary*)[selections objectAtIndex:i] indexForValue:[NSNumber numberWithInt:[_params intForKeyPath:entry]]];
- [_cur_selections addObject:[NSNumber numberWithInt:(idx != NSNotFound ? idx : 0)]];
- }
- else
- [_cur_selections addObject:[NSNumber numberWithInt:0]];
- }
- }
- return self;
+ self = [super initWithStyle:UITableViewStyleGrouped];
+ if (self)
+ {
+ _params = [params retain];
+ _entries = [entries retain];
+ _selections = [selections retain];
+
+ // allocate and init current selections array
+ _cur_selections = [[NSMutableArray alloc] initWithCapacity:[_entries count]];
+ for (int i = 0; i < [entries count]; ++i)
+ {
+ NSString *entry = [entries objectAtIndex:i];
+ if ([_params hasValueForKeyPath:entry])
+ {
+ NSUInteger idx = [(OrderedDictionary *)[selections objectAtIndex:i]
+ indexForValue:[NSNumber numberWithInt:[_params intForKeyPath:entry]]];
+ [_cur_selections addObject:[NSNumber numberWithInt:(idx != NSNotFound ? idx : 0)]];
+ }
+ else
+ [_cur_selections addObject:[NSNumber numberWithInt:0]];
+ }
+ }
+ return self;
}
- (void)didReceiveMemoryWarning
{
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
- [_params autorelease];
- [_entries autorelease];
- [_selections autorelease];
- [_cur_selections autorelease];
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+ [_params autorelease];
+ [_entries autorelease];
+ [_selections autorelease];
+ [_cur_selections autorelease];
}
#pragma mark - View lifecycle
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- // Return YES for supported orientations
- return YES;
+ // Return YES for supported orientations
+ return YES;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
- // Return the number of sections.
- return [_entries count];
+ // Return the number of sections.
+ return [_entries count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
- // Return the number of rows in the section.
- return [[self selectionForIndex:section] count];
+ // Return the number of rows in the section.
+ return [[self selectionForIndex:section] count];
}
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
- UITableViewCell *cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
-
- // get selection
- OrderedDictionary* selection = [self selectionForIndex:[indexPath section]];
-
- // set cell properties
+ UITableViewCell *cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
+
+ // get selection
+ OrderedDictionary *selection = [self selectionForIndex:[indexPath section]];
+
+ // set cell properties
[[cell textLabel] setText:[selection keyAtIndex:[indexPath row]]];
-
+
// set default checkmark
- if([indexPath row] == [[_cur_selections objectAtIndex:[indexPath section]] intValue])
+ if ([indexPath row] == [[_cur_selections objectAtIndex:[indexPath section]] intValue])
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
-
- return cell;
+
+ return cell;
}
#pragma mark - Table view delegate
@@ -101,36 +106,38 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// has selection change?
- int cur_selection = [[_cur_selections objectAtIndex:[indexPath section]] intValue];
- if([indexPath row] != cur_selection)
+ int cur_selection = [[_cur_selections objectAtIndex:[indexPath section]] intValue];
+ if ([indexPath row] != cur_selection)
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
-
- NSIndexPath* oldIndexPath = [NSIndexPath indexPathForRow:cur_selection inSection:[indexPath section]];
-
+
+ NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:cur_selection
+ inSection:[indexPath section]];
+
// clear old checkmark
- UITableViewCell* old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
+ UITableViewCell *old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
old_sel_cell.accessoryType = UITableViewCellAccessoryNone;
-
+
// set new checkmark
- UITableViewCell* new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
+ UITableViewCell *new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
new_sel_cell.accessoryType = UITableViewCellAccessoryCheckmark;
- // get value from selection dictionary
- OrderedDictionary* dict = [self selectionForIndex:[indexPath section]];
- int sel_value = [[dict valueForKey:[dict keyAtIndex:[indexPath row]]] intValue];
+ // get value from selection dictionary
+ OrderedDictionary *dict = [self selectionForIndex:[indexPath section]];
+ int sel_value = [[dict valueForKey:[dict keyAtIndex:[indexPath row]]] intValue];
// update selection index and params value
- [_cur_selections replaceObjectAtIndex:[indexPath section] withObject:[NSNumber numberWithInt:[indexPath row]]];
- [_params setInt:sel_value forKeyPath:[_entries objectAtIndex:[indexPath section]]];
- }
+ [_cur_selections replaceObjectAtIndex:[indexPath section]
+ withObject:[NSNumber numberWithInt:[indexPath row]]];
+ [_params setInt:sel_value forKeyPath:[_entries objectAtIndex:[indexPath section]]];
+ }
}
#pragma mark - Convenience functions
-- (OrderedDictionary*)selectionForIndex:(int)index
+- (OrderedDictionary *)selectionForIndex:(int)index
{
- return (OrderedDictionary*)[_selections objectAtIndex:index];
+ return (OrderedDictionary *)[_selections objectAtIndex:index];
}
@end
diff --git a/client/iOS/Controllers/EncryptionController.h b/client/iOS/Controllers/EncryptionController.h
index cc3430394..f516cf635 100644
--- a/client/iOS/Controllers/EncryptionController.h
+++ b/client/iOS/Controllers/EncryptionController.h
@@ -1,10 +1,11 @@
/*
Password Encryption Controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -12,13 +13,13 @@
@interface EncryptionController : NSObject
{
- Encryptor* _shared_encryptor;
+ Encryptor *_shared_encryptor;
}
-+ (EncryptionController*)sharedEncryptionController;
++ (EncryptionController *)sharedEncryptionController;
// Return a Encryptor suitable for encrypting or decrypting with the master password
-- (Encryptor*)decryptor;
-- (Encryptor*)encryptor;
+- (Encryptor *)decryptor;
+- (Encryptor *)encryptor;
@end
diff --git a/client/iOS/Controllers/EncryptionController.m b/client/iOS/Controllers/EncryptionController.m
index 7f5a2599f..d7431bf55 100644
--- a/client/iOS/Controllers/EncryptionController.m
+++ b/client/iOS/Controllers/EncryptionController.m
@@ -1,10 +1,11 @@
/*
Password Encryption Controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EncryptionController.h"
@@ -13,63 +14,65 @@
@interface EncryptionController (Private)
-- (BOOL)verifyPassword:(Encryptor*)decryptor;
-- (NSData*)encryptedVerificationData;
-- (void)setEncryptedVerificationData:(Encryptor*)encryptor;
+- (BOOL)verifyPassword:(Encryptor *)decryptor;
+- (NSData *)encryptedVerificationData;
+- (void)setEncryptedVerificationData:(Encryptor *)encryptor;
-- (NSString*)keychainServerName;
-- (NSString*)keychainUsername;
-- (void)setKeychainPassword:(NSString*)password;
-- (NSString*)keychainPassword;
-- (NSString*)keychainDefaultPassword;
+- (NSString *)keychainServerName;
+- (NSString *)keychainUsername;
+- (void)setKeychainPassword:(NSString *)password;
+- (NSString *)keychainPassword;
+- (NSString *)keychainDefaultPassword;
@end
-static EncryptionController* _shared_encryption_controller = nil;
-
+static EncryptionController *_shared_encryption_controller = nil;
#pragma mark -
@implementation EncryptionController
-+ (EncryptionController*)sharedEncryptionController
++ (EncryptionController *)sharedEncryptionController
{
@synchronized(self)
{
if (_shared_encryption_controller == nil)
- _shared_encryption_controller = [[EncryptionController alloc] init];
+ _shared_encryption_controller = [[EncryptionController alloc] init];
}
-
- return _shared_encryption_controller;
+
+ return _shared_encryption_controller;
}
#pragma mark Getting an encryptor or decryptor
-- (Encryptor*)encryptor
+- (Encryptor *)encryptor
{
if (_shared_encryptor)
return _shared_encryptor;
-
- NSString* saved_password = [self keychainPassword];
+
+ NSString *saved_password = [self keychainPassword];
if (saved_password == nil)
- {
- saved_password = [self keychainDefaultPassword];
- Encryptor* encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
- [self setEncryptedVerificationData:encryptor];
- _shared_encryptor = [encryptor retain];
- }
- else
- {
- Encryptor* encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
- if ([self verifyPassword:encryptor])
- _shared_encryptor = [encryptor retain];
- }
-
- return _shared_encryptor;
+ {
+ saved_password = [self keychainDefaultPassword];
+ Encryptor *encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
+ [self setEncryptedVerificationData:encryptor];
+ _shared_encryptor = [encryptor retain];
+ }
+ else
+ {
+ Encryptor *encryptor = [[[Encryptor alloc] initWithPassword:saved_password] autorelease];
+ if ([self verifyPassword:encryptor])
+ _shared_encryptor = [encryptor retain];
+ }
+
+ return _shared_encryptor;
}
// For the current implementation, decryptors and encryptors are equivilant.
-- (Encryptor*)decryptor { return [self encryptor]; }
+- (Encryptor *)decryptor
+{
+ return [self encryptor];
+}
@end
@@ -80,62 +83,73 @@ static EncryptionController* _shared_encryption_controller = nil;
#pragma mark -
#pragma mark Keychain password storage
-- (NSString*)keychainServerName
+- (NSString *)keychainServerName
{
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
}
-- (NSString*)keychainUsername
+- (NSString *)keychainUsername
{
return @"master.password";
}
-- (void)setKeychainPassword:(NSString*)password
-{
- NSError* error;
+- (void)setKeychainPassword:(NSString *)password
+{
+ NSError *error;
if (password == nil)
{
- [SFHFKeychainUtils deleteItemForUsername:[self keychainUsername] andServerName:[self keychainServerName] error:&error];
+ [SFHFKeychainUtils deleteItemForUsername:[self keychainUsername]
+ andServerName:[self keychainServerName]
+ error:&error];
return;
}
- [SFHFKeychainUtils storeUsername:[self keychainUsername] andPassword:password forServerName:[self keychainServerName] updateExisting:YES error:&error];
+ [SFHFKeychainUtils storeUsername:[self keychainUsername]
+ andPassword:password
+ forServerName:[self keychainServerName]
+ updateExisting:YES
+ error:&error];
}
-- (NSString*)keychainPassword
+- (NSString *)keychainPassword
{
- NSError* error;
- return [SFHFKeychainUtils getPasswordForUsername:[self keychainUsername] andServerName:[self keychainServerName] error:&error];
+ NSError *error;
+ return [SFHFKeychainUtils getPasswordForUsername:[self keychainUsername]
+ andServerName:[self keychainServerName]
+ error:&error];
}
-- (NSString*)keychainDefaultPassword
+- (NSString *)keychainDefaultPassword
{
- NSString* password = [[NSUserDefaults standardUserDefaults] stringForKey:@"UUID"];
- if ([password length] == 0)
- {
- password = [NSString stringWithUUID];
- [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TSXMasterPasswordVerification"];
- }
- return password;
+ NSString *password = [[NSUserDefaults standardUserDefaults] stringForKey:@"UUID"];
+ if ([password length] == 0)
+ {
+ password = [NSString stringWithUUID];
+ [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"];
+ [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TSXMasterPasswordVerification"];
+ }
+ return password;
}
#pragma mark -
#pragma mark Verification of encryption key against verification data
-- (BOOL)verifyPassword:(Encryptor*)decryptor
+- (BOOL)verifyPassword:(Encryptor *)decryptor
{
- return [[decryptor plaintextPassword] isEqualToString:[decryptor decryptString:[self encryptedVerificationData]]];
+ return [[decryptor plaintextPassword]
+ isEqualToString:[decryptor decryptString:[self encryptedVerificationData]]];
}
-- (NSData*)encryptedVerificationData
+- (NSData *)encryptedVerificationData
{
return [[NSUserDefaults standardUserDefaults] dataForKey:@"TSXMasterPasswordVerification"];
}
-- (void)setEncryptedVerificationData:(Encryptor*)encryptor
+- (void)setEncryptedVerificationData:(Encryptor *)encryptor
{
- [[NSUserDefaults standardUserDefaults] setObject:[encryptor encryptString:[encryptor plaintextPassword]] forKey:@"TSXMasterPasswordVerification"];
+ [[NSUserDefaults standardUserDefaults]
+ setObject:[encryptor encryptString:[encryptor plaintextPassword]]
+ forKey:@"TSXMasterPasswordVerification"];
}
@end
diff --git a/client/iOS/Controllers/HelpController.h b/client/iOS/Controllers/HelpController.h
index 0d6c736be..9e7b93341 100644
--- a/client/iOS/Controllers/HelpController.h
+++ b/client/iOS/Controllers/HelpController.h
@@ -1,16 +1,17 @@
/*
Application help controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@interface HelpController : UIViewController
{
- UIWebView* webView;
+ UIWebView *webView;
}
@end
diff --git a/client/iOS/Controllers/HelpController.m b/client/iOS/Controllers/HelpController.m
index f7b44dc79..7ea97c799 100644
--- a/client/iOS/Controllers/HelpController.m
+++ b/client/iOS/Controllers/HelpController.m
@@ -1,10 +1,11 @@
/*
Application help controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "HelpController.h"
@@ -14,45 +15,62 @@
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self)
+ {
// set title and tab-bar image
[self setTitle:NSLocalizedString(@"Help", @"Help Controller title")];
- UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_help" ofType:@"png"]];
- [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help") image:tabBarIcon tag:0] autorelease]];
- }
- return self;
+ UIImage *tabBarIcon = [UIImage
+ imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_help"
+ ofType:@"png"]];
+ [self setTabBarItem:[[[UITabBarItem alloc]
+ initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help")
+ image:tabBarIcon
+ tag:0] autorelease]];
+ }
+ return self;
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
-- (void)loadView
+- (void)loadView
{
webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
- [webView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+ [webView
+ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[webView setAutoresizesSubviews:YES];
- [webView setDelegate:self];
- [webView setDataDetectorTypes:UIDataDetectorTypeNone];
+ [webView setDelegate:self];
+ [webView setDataDetectorTypes:UIDataDetectorTypeNone];
[self setView:webView];
}
-- (void)dealloc {
- [super dealloc];
+- (void)dealloc
+{
+ [super dealloc];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad
+- (void)viewDidLoad
{
- [super viewDidLoad];
-
- NSString *filename = (IsPhone() ? @"gestures_phone" : @"gestures");
- NSString *htmlString = [[[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"html" inDirectory:@"help_page"] encoding:NSUTF8StringEncoding error:nil] autorelease];
-
- [webView loadHTMLString:htmlString baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"help_page"]]];
+ [super viewDidLoad];
+
+ NSString *filename = (IsPhone() ? @"gestures_phone" : @"gestures");
+ NSString *htmlString = [[[NSString alloc]
+ initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
+ ofType:@"html"
+ inDirectory:@"help_page"]
+ encoding:NSUTF8StringEncoding
+ error:nil] autorelease];
+
+ [webView
+ loadHTMLString:htmlString
+ baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
+ stringByAppendingPathComponent:@"help_page"]]];
}
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
}
@end
diff --git a/client/iOS/Controllers/MainTabBarController.h b/client/iOS/Controllers/MainTabBarController.h
index f369d8a30..d1b4c584b 100644
--- a/client/iOS/Controllers/MainTabBarController.h
+++ b/client/iOS/Controllers/MainTabBarController.h
@@ -1,17 +1,18 @@
/*
main tabbar controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
#import
-@interface MainTabBarController : UITabBarController {
-
+@interface MainTabBarController : UITabBarController
+{
}
@end
diff --git a/client/iOS/Controllers/MainTabBarController.m b/client/iOS/Controllers/MainTabBarController.m
index 76a437e56..afd71e8be 100644
--- a/client/iOS/Controllers/MainTabBarController.m
+++ b/client/iOS/Controllers/MainTabBarController.m
@@ -1,20 +1,20 @@
/*
main tabbar controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "MainTabBarController.h"
-
@implementation MainTabBarController
--(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
- return YES;
+ return YES;
}
@end
diff --git a/client/iOS/Controllers/PerformanceEditorController.h b/client/iOS/Controllers/PerformanceEditorController.h
index 5d6fafb24..c83cb47ee 100644
--- a/client/iOS/Controllers/PerformanceEditorController.h
+++ b/client/iOS/Controllers/PerformanceEditorController.h
@@ -1,10 +1,11 @@
/*
controller for performance settings selection
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -13,12 +14,12 @@
@interface PerformanceEditorController : EditorBaseController
{
-@private
- ConnectionParams* _params;
- NSString* _keyPath;
+ @private
+ ConnectionParams *_params;
+ NSString *_keyPath;
}
-- (id)initWithConnectionParams:(ConnectionParams*)params;
-- (id)initWithConnectionParams:(ConnectionParams*)params keyPath:(NSString*)keyPath;
+- (id)initWithConnectionParams:(ConnectionParams *)params;
+- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
@end
diff --git a/client/iOS/Controllers/PerformanceEditorController.m b/client/iOS/Controllers/PerformanceEditorController.m
index 3f15e2219..1c50982c4 100644
--- a/client/iOS/Controllers/PerformanceEditorController.m
+++ b/client/iOS/Controllers/PerformanceEditorController.m
@@ -4,26 +4,26 @@
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "PerformanceEditorController.h"
#import "ConnectionParams.h"
#import "Utils.h"
-@interface PerformanceEditorController(Private)
--(NSString*)keyPathForKey:(NSString*)key;
+@interface PerformanceEditorController (Private)
+- (NSString *)keyPathForKey:(NSString *)key;
@end
@implementation PerformanceEditorController
-- (id)initWithConnectionParams:(ConnectionParams*)params
+- (id)initWithConnectionParams:(ConnectionParams *)params
{
return [self initWithConnectionParams:params keyPath:nil];
}
-- (id)initWithConnectionParams:(ConnectionParams*)params keyPath:
- (NSString*)keyPath;
+- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
{
self = [super initWithStyle:UITableViewStyleGrouped];
@@ -48,13 +48,12 @@
// Release any retained subviews of the main view.
}
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
- interfaceOrientation
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
--(NSString*)keyPathForKey:(NSString*)key
+- (NSString *)keyPathForKey:(NSString *)key
{
if (_keyPath)
return [_keyPath stringByAppendingFormat:@".%@", key];
@@ -71,124 +70,118 @@
#pragma mark -
#pragma mark Table view data source
-- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
-
-- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:
- (NSInteger)section
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 7;
}
-
// set section headers
-- (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:
- (NSInteger)section
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return NSLocalizedString(@"Performance Settings",
@"'Performance Settings': performance settings header");
}
// Customize the appearance of table view cells.
-- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:
- (NSIndexPath*)indexPath
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// get the table view cell
- EditFlagTableViewCell* cell = (EditFlagTableViewCell*)[self
- tableViewCellFromIdentifier:TableCellIdentifierYesNo];
+ EditFlagTableViewCell *cell =
+ (EditFlagTableViewCell *)[self tableViewCellFromIdentifier:TableCellIdentifierYesNo];
NSAssert(cell, @"Invalid cell");
switch ([indexPath row])
{
case 0:
- {
- [[cell label] setText:NSLocalizedString(@"RemoteFX",
- @"RemoteFX performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_remotefx"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"RemoteFX", @"RemoteFX performance setting")];
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_remotefx"]]];
+ break;
+ }
case 1:
- {
- [[cell label] setText:NSLocalizedString(@"GFX", @"GFX performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_gfx"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"GFX", @"GFX performance setting")];
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_gfx"]]];
+ break;
+ }
case 2:
- {
- [[cell label] setText:NSLocalizedString(@"H264", @"H264 performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_h264"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"H264", @"H264 performance setting")];
+ [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_h264"]]];
+ break;
+ }
case 3:
- {
- [[cell label] setText:NSLocalizedString(@"Desktop Background",
- @"Desktop background performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_show_desktop"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"Desktop Background",
+ @"Desktop background performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_show_desktop"]]];
+ break;
+ }
case 4:
- {
- [[cell label] setText:NSLocalizedString(@"Font Smoothing",
- @"Font smoothing performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_font_smoothing"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"Font Smoothing",
+ @"Font smoothing performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_font_smoothing"]]];
+ break;
+ }
case 5:
- {
- [[cell label] setText:NSLocalizedString(@"Desktop Composition",
- @"Desktop composition performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_desktop_composition"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"Desktop Composition",
+ @"Desktop composition performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_desktop_composition"]]];
+ break;
+ }
case 6:
- {
- [[cell label] setText:NSLocalizedString(@"Window contents while dragging",
- @"Window Dragging performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_window_dragging"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"Window contents while dragging",
+ @"Window Dragging performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_window_dragging"]]];
+ break;
+ }
case 7:
- {
- [[cell label] setText:NSLocalizedString(@"Menu Animation",
- @"Menu Animations performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_menu_animation"]]];
- break;
- }
+ {
+ [[cell label] setText:NSLocalizedString(@"Menu Animation",
+ @"Menu Animations performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_menu_animation"]]];
+ break;
+ }
case 8:
- {
- [[cell label] setText:NSLocalizedString(@"Visual Styles",
- @"Use Themes performance setting")];
- [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:
- @"perf_windows_themes"]]];
- break;
- }
+ {
+ [[cell label]
+ setText:NSLocalizedString(@"Visual Styles", @"Use Themes performance setting")];
+ [[cell toggle]
+ setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_windows_themes"]]];
+ break;
+ }
default:
break;
}
[[cell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
- [[cell toggle] addTarget:self action:@selector(togglePerformanceSetting:)
- forControlEvents:UIControlEventValueChanged];
+ [[cell toggle] addTarget:self
+ action:@selector(togglePerformanceSetting:)
+ forControlEvents:UIControlEventValueChanged];
return cell;
}
@@ -197,53 +190,50 @@
- (void)togglePerformanceSetting:(id)sender
{
- UISwitch* valueSwitch = (UISwitch*)sender;
+ UISwitch *valueSwitch = (UISwitch *)sender;
switch (valueSwitch.tag)
{
case GET_TAG(0, 0):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_remotefx"]];
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_remotefx"]];
break;
case GET_TAG(0, 1):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_gfx"]];
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_gfx"]];
break;
case GET_TAG(0, 2):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_h264"]];
+ [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_h264"]];
break;
case GET_TAG(0, 3):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_show_desktop"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_show_desktop"]];
break;
case GET_TAG(0, 4):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_font_smoothing"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_font_smoothing"]];
break;
case GET_TAG(0, 5):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_desktop_composition"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_desktop_composition"]];
break;
case GET_TAG(0, 6):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_window_dragging"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_window_dragging"]];
break;
case GET_TAG(0, 7):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_menu_animation"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_menu_animation"]];
break;
case GET_TAG(0, 8):
- [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:
- @"perf_windows_themes"]];
+ [_params setBool:[valueSwitch isOn]
+ forKeyPath:[self keyPathForKey:@"perf_windows_themes"]];
break;
default:
diff --git a/client/iOS/Controllers/RDPSessionViewController.h b/client/iOS/Controllers/RDPSessionViewController.h
index 36e64a93d..202708e25 100644
--- a/client/iOS/Controllers/RDPSessionViewController.h
+++ b/client/iOS/Controllers/RDPSessionViewController.h
@@ -1,10 +1,11 @@
/*
RDP Session View Controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -14,57 +15,61 @@
#import "TouchPointerView.h"
#import "AdvancedKeyboardView.h"
-@interface RDPSessionViewController : UIViewController
+@interface RDPSessionViewController
+ : UIViewController
{
// scrollview that hosts the rdp session view
- IBOutlet UIScrollView* _session_scrollview;
-
- // rdp session view
- IBOutlet RDPSessionView* _session_view;
+ IBOutlet UIScrollView *_session_scrollview;
- // touch pointer view
- IBOutlet TouchPointerView* _touchpointer_view;
- BOOL _autoscroll_with_touchpointer;
- BOOL _is_autoscrolling;
+ // rdp session view
+ IBOutlet RDPSessionView *_session_view;
+
+ // touch pointer view
+ IBOutlet TouchPointerView *_touchpointer_view;
+ BOOL _autoscroll_with_touchpointer;
+ BOOL _is_autoscrolling;
// rdp session toolbar
- IBOutlet UIToolbar* _session_toolbar;
- BOOL _session_toolbar_visible;
-
+ IBOutlet UIToolbar *_session_toolbar;
+ BOOL _session_toolbar_visible;
+
// dummy text field used to display the keyboard
- IBOutlet UITextField* _dummy_textfield;
-
- // connecting view and the controls within that view
- IBOutlet UIView* _connecting_view;
- IBOutlet UILabel* _lbl_connecting;
- IBOutlet UIActivityIndicatorView* _connecting_indicator_view;
- IBOutlet UIButton* _cancel_connect_button;
-
- // extended keyboard toolbar
- UIToolbar* _keyboard_toolbar;
-
- // rdp session
- RDPSession* _session;
- BOOL _session_initilized;
-
+ IBOutlet UITextField *_dummy_textfield;
+
+ // connecting view and the controls within that view
+ IBOutlet UIView *_connecting_view;
+ IBOutlet UILabel *_lbl_connecting;
+ IBOutlet UIActivityIndicatorView *_connecting_indicator_view;
+ IBOutlet UIButton *_cancel_connect_button;
+
+ // extended keyboard toolbar
+ UIToolbar *_keyboard_toolbar;
+
+ // rdp session
+ RDPSession *_session;
+ BOOL _session_initilized;
+
// flag that indicates whether the keyboard is visible or not
BOOL _keyboard_visible;
-
- // flag to switch between left/right mouse button mode
- BOOL _toggle_mouse_button;
-
- // keyboard extension view
- AdvancedKeyboardView* _advanced_keyboard_view;
- BOOL _advanced_keyboard_visible;
- BOOL _requesting_advanced_keyboard;
- CGFloat _keyboard_last_height;
-
- // delayed mouse move event sending
- NSTimer* _mouse_move_event_timer;
- int _mouse_move_events_skipped;
- CGPoint _prev_long_press_position;
+
+ // flag to switch between left/right mouse button mode
+ BOOL _toggle_mouse_button;
+
+ // keyboard extension view
+ AdvancedKeyboardView *_advanced_keyboard_view;
+ BOOL _advanced_keyboard_visible;
+ BOOL _requesting_advanced_keyboard;
+ CGFloat _keyboard_last_height;
+
+ // delayed mouse move event sending
+ NSTimer *_mouse_move_event_timer;
+ int _mouse_move_events_skipped;
+ CGPoint _prev_long_press_position;
}
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession*)session;
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session;
@end
diff --git a/client/iOS/Controllers/RDPSessionViewController.m b/client/iOS/Controllers/RDPSessionViewController.m
index c312cef96..257f70af8 100644
--- a/client/iOS/Controllers/RDPSessionViewController.m
+++ b/client/iOS/Controllers/RDPSessionViewController.m
@@ -1,10 +1,11 @@
/*
RDP Session View Controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -23,489 +24,539 @@
#define AUTOSCROLLTIMEOUT 0.05
@interface RDPSessionViewController (Private)
--(void)showSessionToolbar:(BOOL)show;
--(UIToolbar*)keyboardToolbar;
--(void)initGestureRecognizers;
+- (void)showSessionToolbar:(BOOL)show;
+- (UIToolbar *)keyboardToolbar;
+- (void)initGestureRecognizers;
- (void)suspendSession;
-- (NSDictionary*)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position;
+- (NSDictionary *)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position;
- (void)handleMouseMoveForPosition:(CGPoint)position;
@end
-
@implementation RDPSessionViewController
#pragma mark class methods
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession *)session
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session
{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self)
- {
- _session = [session retain];
- [_session setDelegate:self];
- _session_initilized = NO;
-
- _mouse_move_events_skipped = 0;
- _mouse_move_event_timer = nil;
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self)
+ {
+ _session = [session retain];
+ [_session setDelegate:self];
+ _session_initilized = NO;
- _advanced_keyboard_view = nil;
- _advanced_keyboard_visible = NO;
- _requesting_advanced_keyboard = NO;
+ _mouse_move_events_skipped = 0;
+ _mouse_move_event_timer = nil;
+
+ _advanced_keyboard_view = nil;
+ _advanced_keyboard_visible = NO;
+ _requesting_advanced_keyboard = NO;
_keyboard_last_height = 0;
- _session_toolbar_visible = NO;
-
- _toggle_mouse_button = NO;
-
- _autoscroll_with_touchpointer = [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.auto_scroll_touchpointer"];
- _is_autoscrolling = NO;
-
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationStopped:finished:context:)];
- }
-
- return self;
+ _session_toolbar_visible = NO;
+
+ _toggle_mouse_button = NO;
+
+ _autoscroll_with_touchpointer =
+ [[NSUserDefaults standardUserDefaults] boolForKey:@"ui.auto_scroll_touchpointer"];
+ _is_autoscrolling = NO;
+
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationStopped:finished:context:)];
+ }
+
+ return self;
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
-- (void)loadView
+- (void)loadView
{
// load default view and set background color and resizing mask
[super loadView];
- // init keyboard handling vars
- _keyboard_visible = NO;
+ // init keyboard handling vars
+ _keyboard_visible = NO;
- // init keyboard toolbar
- _keyboard_toolbar = [[self keyboardToolbar] retain];
- [_dummy_textfield setInputAccessoryView:_keyboard_toolbar];
-
- // init gesture recognizers
- [self initGestureRecognizers];
-
- // hide session toolbar
- [_session_toolbar setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
+ // init keyboard toolbar
+ _keyboard_toolbar = [[self keyboardToolbar] retain];
+ [_dummy_textfield setInputAccessoryView:_keyboard_toolbar];
+
+ // init gesture recognizers
+ [self initGestureRecognizers];
+
+ // hide session toolbar
+ [_session_toolbar
+ setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
}
-
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad
+- (void)viewDidLoad
{
- [super viewDidLoad];
+ [super viewDidLoad];
}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
- if (![_touchpointer_view isHidden])
- [_touchpointer_view ensurePointerIsVisible];
+ if (![_touchpointer_view isHidden])
+ [_touchpointer_view ensurePointerIsVisible];
}
-- (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc. that aren't in use.
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc. that aren't in use.
}
-- (void)viewDidUnload {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
}
-- (void)viewWillAppear:(BOOL)animated
+- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
- // hide navigation bar and (if enabled) the status bar
- if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"])
- {
- if(animated == YES)
- [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
- else
- [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
- }
- [[self navigationController] setNavigationBarHidden:YES animated:animated];
-
- // if sesssion is suspended - notify that we got a new bitmap context
- if ([_session isSuspended])
- [self sessionBitmapContextWillChange:_session];
+ // hide navigation bar and (if enabled) the status bar
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_status_bar"])
+ {
+ if (animated == YES)
+ [[UIApplication sharedApplication] setStatusBarHidden:YES
+ withAnimation:UIStatusBarAnimationSlide];
+ else
+ [[UIApplication sharedApplication] setStatusBarHidden:YES
+ withAnimation:UIStatusBarAnimationNone];
+ }
+ [[self navigationController] setNavigationBarHidden:YES animated:animated];
- // init keyboard
- [[RDPKeyboard getSharedRDPKeyboard] initWithSession:_session delegate:self];
+ // if sesssion is suspended - notify that we got a new bitmap context
+ if ([_session isSuspended])
+ [self sessionBitmapContextWillChange:_session];
+
+ // init keyboard
+ [[RDPKeyboard getSharedRDPKeyboard] initWithSession:_session delegate:self];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
-
- if (!_session_initilized)
- {
- if ([_session isSuspended])
- {
- [_session resume];
- [self sessionBitmapContextDidChange:_session];
- [_session_view setNeedsDisplay];
- }
- else
- [_session connect];
-
- _session_initilized = YES;
- }
+
+ if (!_session_initilized)
+ {
+ if ([_session isSuspended])
+ {
+ [_session resume];
+ [self sessionBitmapContextDidChange:_session];
+ [_session_view setNeedsDisplay];
+ }
+ else
+ [_session connect];
+
+ _session_initilized = YES;
+ }
}
-- (void)viewWillDisappear:(BOOL)animated
+- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
+ [super viewWillDisappear:animated];
- // show navigation and status bar again
- if(animated == YES)
- [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
+ // show navigation and status bar again
+ if (animated == YES)
+ [[UIApplication sharedApplication] setStatusBarHidden:NO
+ withAnimation:UIStatusBarAnimationSlide];
else
- [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
+ [[UIApplication sharedApplication] setStatusBarHidden:NO
+ withAnimation:UIStatusBarAnimationNone];
[[self navigationController] setNavigationBarHidden:NO animated:animated];
-
- // reset all modifier keys on rdp keyboard
- [[RDPKeyboard getSharedRDPKeyboard] reset];
-
+
+ // reset all modifier keys on rdp keyboard
+ [[RDPKeyboard getSharedRDPKeyboard] reset];
+
// hide toolbar and keyboard
- [self showSessionToolbar:NO];
+ [self showSessionToolbar:NO];
[_dummy_textfield resignFirstResponder];
}
+- (void)dealloc
+{
+ // remove any observers
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
-- (void)dealloc {
- // remove any observers
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- // the session lives on longer so set the delegate to nil
- [_session setDelegate:nil];
+ // the session lives on longer so set the delegate to nil
+ [_session setDelegate:nil];
- [_advanced_keyboard_view release];
- [_keyboard_toolbar release];
- [_session release];
- [super dealloc];
+ [_advanced_keyboard_view release];
+ [_keyboard_toolbar release];
+ [_session release];
+ [super dealloc];
}
#pragma mark -
#pragma mark ScrollView delegate methods
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
-{
- return _session_view;
+{
+ return _session_view;
}
--(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
+- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView
+ withView:(UIView *)view
+ atScale:(float)scale
{
- NSLog(@"New zoom scale: %f", scale);
+ NSLog(@"New zoom scale: %f", scale);
[_session_view setNeedsDisplay];
}
#pragma mark -
#pragma mark TextField delegate methods
--(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
+- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
_keyboard_visible = YES;
- _advanced_keyboard_visible = NO;
+ _advanced_keyboard_visible = NO;
return YES;
}
--(BOOL)textFieldShouldEndEditing:(UITextField *)textField
+- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
_keyboard_visible = NO;
- _advanced_keyboard_visible = NO;
+ _advanced_keyboard_visible = NO;
return YES;
}
-- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
-{
- if([string length] > 0)
+- (BOOL)textField:(UITextField *)textField
+ shouldChangeCharactersInRange:(NSRange)range
+ replacementString:(NSString *)string
+{
+ if ([string length] > 0)
{
- for(int i = 0 ; i < [string length] ; i++)
+ for (int i = 0; i < [string length]; i++)
{
- unichar curChar = [string characterAtIndex:i];
+ unichar curChar = [string characterAtIndex:i];
- // special handling for return/enter key
- if(curChar == '\n')
- [[RDPKeyboard getSharedRDPKeyboard] sendEnterKeyStroke];
- else
- [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:curChar];
+ // special handling for return/enter key
+ if (curChar == '\n')
+ [[RDPKeyboard getSharedRDPKeyboard] sendEnterKeyStroke];
+ else
+ [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:curChar];
}
}
else
{
[[RDPKeyboard getSharedRDPKeyboard] sendBackspaceKeyStroke];
- }
-
+ }
+
return NO;
}
#pragma mark -
#pragma mark AdvancedKeyboardDelegate functions
--(void)advancedKeyPressedVKey:(int)key
+- (void)advancedKeyPressedVKey:(int)key
{
- [[RDPKeyboard getSharedRDPKeyboard] sendVirtualKeyCode:key];
+ [[RDPKeyboard getSharedRDPKeyboard] sendVirtualKeyCode:key];
}
--(void)advancedKeyPressedUnicode:(int)key
+- (void)advancedKeyPressedUnicode:(int)key
{
- [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:key];
+ [[RDPKeyboard getSharedRDPKeyboard] sendUnicode:key];
}
#pragma mark - RDP keyboard handler
- (void)modifiersChangedForKeyboard:(RDPKeyboard *)keyboard
{
- UIBarButtonItem* curItem;
-
- // shift button (only on iPad)
- int objectIdx = 0;
- if (IsPad())
- {
- objectIdx = 2;
- curItem = (UIBarButtonItem*)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
- [curItem setStyle:[keyboard shiftPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
- }
-
- // ctrl button
- objectIdx += 2;
- curItem = (UIBarButtonItem*)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
- [curItem setStyle:[keyboard ctrlPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
-
- // win button
- objectIdx += 2;
- curItem = (UIBarButtonItem*)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
- [curItem setStyle:[keyboard winPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
-
- // alt button
- objectIdx += 2;
- curItem = (UIBarButtonItem*)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
- [curItem setStyle:[keyboard altPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
+ UIBarButtonItem *curItem;
+
+ // shift button (only on iPad)
+ int objectIdx = 0;
+ if (IsPad())
+ {
+ objectIdx = 2;
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
+ [curItem setStyle:[keyboard shiftPressed] ? UIBarButtonItemStyleDone
+ : UIBarButtonItemStyleBordered];
+ }
+
+ // ctrl button
+ objectIdx += 2;
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
+ [curItem
+ setStyle:[keyboard ctrlPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
+
+ // win button
+ objectIdx += 2;
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
+ [curItem
+ setStyle:[keyboard winPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
+
+ // alt button
+ objectIdx += 2;
+ curItem = (UIBarButtonItem *)[[_keyboard_toolbar items] objectAtIndex:objectIdx];
+ [curItem
+ setStyle:[keyboard altPressed] ? UIBarButtonItemStyleDone : UIBarButtonItemStyleBordered];
}
#pragma mark -
#pragma mark RDPSessionDelegate functions
-- (void)session:(RDPSession*)session didFailToConnect:(int)reason
+- (void)session:(RDPSession *)session didFailToConnect:(int)reason
{
- // remove and release connecting view
- [_connecting_indicator_view stopAnimating];
- [_connecting_view removeFromSuperview];
- [_connecting_view autorelease];
+ // remove and release connecting view
+ [_connecting_indicator_view stopAnimating];
+ [_connecting_view removeFromSuperview];
+ [_connecting_view autorelease];
- // return to bookmark list
- [[self navigationController] popViewControllerAnimated:YES];
+ // return to bookmark list
+ [[self navigationController] popViewControllerAnimated:YES];
}
-- (void)sessionWillConnect:(RDPSession*)session
+- (void)sessionWillConnect:(RDPSession *)session
{
- // load connecting view
- [[NSBundle mainBundle] loadNibNamed:@"RDPConnectingView" owner:self options:nil];
-
- // set strings
- [_lbl_connecting setText:NSLocalizedString(@"Connecting", @"Connecting progress view - label")];
- [_cancel_connect_button setTitle:NSLocalizedString(@"Cancel", @"Cancel Button") forState:UIControlStateNormal];
-
- // center view and give it round corners
- [_connecting_view setCenter:[[self view] center]];
- [[_connecting_view layer] setCornerRadius:10];
+ // load connecting view
+ [[NSBundle mainBundle] loadNibNamed:@"RDPConnectingView" owner:self options:nil];
- // display connecting view and start indicator
- [[self view] addSubview:_connecting_view];
- [_connecting_indicator_view startAnimating];
+ // set strings
+ [_lbl_connecting setText:NSLocalizedString(@"Connecting", @"Connecting progress view - label")];
+ [_cancel_connect_button setTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
+ forState:UIControlStateNormal];
+
+ // center view and give it round corners
+ [_connecting_view setCenter:[[self view] center]];
+ [[_connecting_view layer] setCornerRadius:10];
+
+ // display connecting view and start indicator
+ [[self view] addSubview:_connecting_view];
+ [_connecting_indicator_view startAnimating];
}
-- (void)sessionDidConnect:(RDPSession*)session
+- (void)sessionDidConnect:(RDPSession *)session
{
- // register keyboard notification handlers
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name: UIKeyboardWillHideNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name: UIKeyboardDidHideNotification object:nil];
+ // register keyboard notification handlers
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:)
+ name:UIKeyboardWillShowNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardDidShow:)
+ name:UIKeyboardDidShowNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:)
+ name:UIKeyboardWillHideNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardDidHide:)
+ name:UIKeyboardDidHideNotification
+ object:nil];
- // remove and release connecting view
- [_connecting_indicator_view stopAnimating];
- [_connecting_view removeFromSuperview];
- [_connecting_view autorelease];
-
- // check if session settings changed ...
- // The 2nd width check is to ignore changes in resolution settings due to the RDVH display bug (refer to RDPSEssion.m for more details)
- ConnectionParams* orig_params = [session params];
- rdpSettings* sess_params = [session getSessionParams];
- if (([orig_params intForKey:@"width"] != sess_params->DesktopWidth && [orig_params intForKey:@"width"] != (sess_params->DesktopWidth + 1)) ||
- [orig_params intForKey:@"height"] != sess_params->DesktopHeight || [orig_params intForKey:@"colors"] != sess_params->ColorDepth)
- {
- // display notification that the session params have been changed by the server
- NSString* message = [NSString stringWithFormat:NSLocalizedString(@"The server changed the screen settings to %dx%dx%d", @"Screen settings not supported message with width, height and colors parameter"), sess_params->DesktopWidth, sess_params->DesktopHeight, sess_params->ColorDepth];
- [[self view] makeToast:message duration:ToastDurationNormal position:@"bottom"];
- }
+ // remove and release connecting view
+ [_connecting_indicator_view stopAnimating];
+ [_connecting_view removeFromSuperview];
+ [_connecting_view autorelease];
+
+ // check if session settings changed ...
+ // The 2nd width check is to ignore changes in resolution settings due to the RDVH display bug
+ // (refer to RDPSEssion.m for more details)
+ ConnectionParams *orig_params = [session params];
+ rdpSettings *sess_params = [session getSessionParams];
+ if (([orig_params intForKey:@"width"] != sess_params->DesktopWidth &&
+ [orig_params intForKey:@"width"] != (sess_params->DesktopWidth + 1)) ||
+ [orig_params intForKey:@"height"] != sess_params->DesktopHeight ||
+ [orig_params intForKey:@"colors"] != sess_params->ColorDepth)
+ {
+ // display notification that the session params have been changed by the server
+ NSString *message =
+ [NSString stringWithFormat:NSLocalizedString(
+ @"The server changed the screen settings to %dx%dx%d",
+ @"Screen settings not supported message with width, "
+ @"height and colors parameter"),
+ sess_params->DesktopWidth, sess_params->DesktopHeight,
+ sess_params->ColorDepth];
+ [[self view] makeToast:message duration:ToastDurationNormal position:@"bottom"];
+ }
}
-- (void)sessionWillDisconnect:(RDPSession*)session
+- (void)sessionWillDisconnect:(RDPSession *)session
{
-
}
-- (void)sessionDidDisconnect:(RDPSession*)session
+- (void)sessionDidDisconnect:(RDPSession *)session
{
- // return to bookmark list
- [[self navigationController] popViewControllerAnimated:YES];
+ // return to bookmark list
+ [[self navigationController] popViewControllerAnimated:YES];
}
-- (void)sessionBitmapContextWillChange:(RDPSession*)session
+- (void)sessionBitmapContextWillChange:(RDPSession *)session
{
- // calc new view frame
- rdpSettings* sess_params = [session getSessionParams];
- CGRect view_rect = CGRectMake(0, 0, sess_params->DesktopWidth, sess_params->DesktopHeight);
+ // calc new view frame
+ rdpSettings *sess_params = [session getSessionParams];
+ CGRect view_rect = CGRectMake(0, 0, sess_params->DesktopWidth, sess_params->DesktopHeight);
- // reset zoom level and update content size
- [_session_scrollview setZoomScale:1.0];
- [_session_scrollview setContentSize:view_rect.size];
+ // reset zoom level and update content size
+ [_session_scrollview setZoomScale:1.0];
+ [_session_scrollview setContentSize:view_rect.size];
- // set session view size
- [_session_view setFrame:view_rect];
-
- // show/hide toolbar
- [_session setToolbarVisible:![[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
- [self showSessionToolbar:[_session toolbarVisible]];
+ // set session view size
+ [_session_view setFrame:view_rect];
+
+ // show/hide toolbar
+ [_session
+ setToolbarVisible:![[NSUserDefaults standardUserDefaults] boolForKey:@"ui.hide_tool_bar"]];
+ [self showSessionToolbar:[_session toolbarVisible]];
}
-- (void)sessionBitmapContextDidChange:(RDPSession*)session
+- (void)sessionBitmapContextDidChange:(RDPSession *)session
{
- // associate view with session
- [_session_view setSession:session];
+ // associate view with session
+ [_session_view setSession:session];
- // issue an update (this might be needed in case we had a resize for instance)
- [_session_view setNeedsDisplay];
+ // issue an update (this might be needed in case we had a resize for instance)
+ [_session_view setNeedsDisplay];
}
-- (void)session:(RDPSession*)session needsRedrawInRect:(CGRect)rect
+- (void)session:(RDPSession *)session needsRedrawInRect:(CGRect)rect
{
- [_session_view setNeedsDisplayInRect:rect];
+ [_session_view setNeedsDisplayInRect:rect];
}
- (void)session:(RDPSession *)session requestsAuthenticationWithParams:(NSMutableDictionary *)params
{
- CredentialsInputController* view_controller = [[[CredentialsInputController alloc] initWithNibName:@"CredentialsInputView" bundle:nil session:_session params:params] autorelease];
- [self presentModalViewController:view_controller animated:YES];
+ CredentialsInputController *view_controller =
+ [[[CredentialsInputController alloc] initWithNibName:@"CredentialsInputView"
+ bundle:nil
+ session:_session
+ params:params] autorelease];
+ [self presentModalViewController:view_controller animated:YES];
}
- (void)session:(RDPSession *)session verifyCertificateWithParams:(NSMutableDictionary *)params
{
- VerifyCertificateController* view_controller = [[[VerifyCertificateController alloc] initWithNibName:@"VerifyCertificateView" bundle:nil session:_session params:params] autorelease];
- [self presentModalViewController:view_controller animated:YES];
+ VerifyCertificateController *view_controller =
+ [[[VerifyCertificateController alloc] initWithNibName:@"VerifyCertificateView"
+ bundle:nil
+ session:_session
+ params:params] autorelease];
+ [self presentModalViewController:view_controller animated:YES];
}
-- (CGSize)sizeForFitScreenForSession:(RDPSession*)session
+- (CGSize)sizeForFitScreenForSession:(RDPSession *)session
{
- if (IsPad())
- return [self view].bounds.size;
- else
- {
- // on phones make a resolution that has a 16:10 ratio with the phone's height
- CGSize size = [self view].bounds.size;
- CGFloat maxSize = (size.width > size.height) ? size.width : size.height;
- return CGSizeMake(maxSize * 1.6f, maxSize);
- }
+ if (IsPad())
+ return [self view].bounds.size;
+ else
+ {
+ // on phones make a resolution that has a 16:10 ratio with the phone's height
+ CGSize size = [self view].bounds.size;
+ CGFloat maxSize = (size.width > size.height) ? size.width : size.height;
+ return CGSizeMake(maxSize * 1.6f, maxSize);
+ }
}
#pragma mark - Keyboard Toolbar Handlers
--(void)showAdvancedKeyboardAnimated
+- (void)showAdvancedKeyboardAnimated
{
- // calc initial and final rect of the advanced keyboard view
- CGRect rect = [[_keyboard_toolbar superview] bounds];
- rect.origin.y = [_keyboard_toolbar bounds].size.height;
- rect.size.height -= rect.origin.y;
-
- // create new view (hidden) and add to host-view of keyboard toolbar
- _advanced_keyboard_view = [[AdvancedKeyboardView alloc] initWithFrame:CGRectMake(rect.origin.x,
- [[_keyboard_toolbar superview] bounds].size.height,
- rect.size.width, rect.size.height) delegate:self];
- [[_keyboard_toolbar superview] addSubview:_advanced_keyboard_view];
- // we set autoresize to YES for the keyboard toolbar's superview so that our adv. keyboard view gets properly resized
- [[_keyboard_toolbar superview] setAutoresizesSubviews:YES];
-
- // show view with animation
- [UIView beginAnimations:nil context:NULL];
- [_advanced_keyboard_view setFrame:rect];
- [UIView commitAnimations];
+ // calc initial and final rect of the advanced keyboard view
+ CGRect rect = [[_keyboard_toolbar superview] bounds];
+ rect.origin.y = [_keyboard_toolbar bounds].size.height;
+ rect.size.height -= rect.origin.y;
+
+ // create new view (hidden) and add to host-view of keyboard toolbar
+ _advanced_keyboard_view = [[AdvancedKeyboardView alloc]
+ initWithFrame:CGRectMake(rect.origin.x, [[_keyboard_toolbar superview] bounds].size.height,
+ rect.size.width, rect.size.height)
+ delegate:self];
+ [[_keyboard_toolbar superview] addSubview:_advanced_keyboard_view];
+ // we set autoresize to YES for the keyboard toolbar's superview so that our adv. keyboard view
+ // gets properly resized
+ [[_keyboard_toolbar superview] setAutoresizesSubviews:YES];
+
+ // show view with animation
+ [UIView beginAnimations:nil context:NULL];
+ [_advanced_keyboard_view setFrame:rect];
+ [UIView commitAnimations];
}
--(IBAction)toggleKeyboardWhenOtherVisible:(id)sender
-{
- if(_advanced_keyboard_visible == NO)
- {
- [self showAdvancedKeyboardAnimated];
- }
- else
- {
- // hide existing view
- [UIView beginAnimations:@"hide_advanced_keyboard_view" context:NULL];
- CGRect rect = [_advanced_keyboard_view frame];
- rect.origin.y = [[_keyboard_toolbar superview] bounds].size.height;
- [_advanced_keyboard_view setFrame:rect];
- [UIView commitAnimations];
-
- // the view is released in the animationDidStop selector registered in init
- }
-
- // toggle flag
- _advanced_keyboard_visible = !_advanced_keyboard_visible;
+- (IBAction)toggleKeyboardWhenOtherVisible:(id)sender
+{
+ if (_advanced_keyboard_visible == NO)
+ {
+ [self showAdvancedKeyboardAnimated];
+ }
+ else
+ {
+ // hide existing view
+ [UIView beginAnimations:@"hide_advanced_keyboard_view" context:NULL];
+ CGRect rect = [_advanced_keyboard_view frame];
+ rect.origin.y = [[_keyboard_toolbar superview] bounds].size.height;
+ [_advanced_keyboard_view setFrame:rect];
+ [UIView commitAnimations];
+
+ // the view is released in the animationDidStop selector registered in init
+ }
+
+ // toggle flag
+ _advanced_keyboard_visible = !_advanced_keyboard_visible;
}
--(IBAction)toggleWinKey:(id)sender
+- (IBAction)toggleWinKey:(id)sender
{
- [[RDPKeyboard getSharedRDPKeyboard] toggleWinKey];
+ [[RDPKeyboard getSharedRDPKeyboard] toggleWinKey];
}
--(IBAction)toggleShiftKey:(id)sender
+- (IBAction)toggleShiftKey:(id)sender
{
- [[RDPKeyboard getSharedRDPKeyboard] toggleShiftKey];
+ [[RDPKeyboard getSharedRDPKeyboard] toggleShiftKey];
}
--(IBAction)toggleCtrlKey:(id)sender
+- (IBAction)toggleCtrlKey:(id)sender
{
- [[RDPKeyboard getSharedRDPKeyboard] toggleCtrlKey];
+ [[RDPKeyboard getSharedRDPKeyboard] toggleCtrlKey];
}
--(IBAction)toggleAltKey:(id)sender
+- (IBAction)toggleAltKey:(id)sender
{
- [[RDPKeyboard getSharedRDPKeyboard] toggleAltKey];
+ [[RDPKeyboard getSharedRDPKeyboard] toggleAltKey];
}
--(IBAction)pressEscKey:(id)sender
+- (IBAction)pressEscKey:(id)sender
{
- [[RDPKeyboard getSharedRDPKeyboard] sendEscapeKeyStroke];
+ [[RDPKeyboard getSharedRDPKeyboard] sendEscapeKeyStroke];
}
#pragma mark -
#pragma mark event handlers
-- (void)animationStopped:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context
+- (void)animationStopped:(NSString *)animationID
+ finished:(NSNumber *)finished
+ context:(void *)context
{
- if ([animationID isEqualToString:@"hide_advanced_keyboard_view"])
- {
- // cleanup advanced keyboard view
- [_advanced_keyboard_view removeFromSuperview];
- [_advanced_keyboard_view autorelease];
- _advanced_keyboard_view = nil;
- }
+ if ([animationID isEqualToString:@"hide_advanced_keyboard_view"])
+ {
+ // cleanup advanced keyboard view
+ [_advanced_keyboard_view removeFromSuperview];
+ [_advanced_keyboard_view autorelease];
+ _advanced_keyboard_view = nil;
+ }
}
- (IBAction)switchSession:(id)sender
{
- [self suspendSession];
+ [self suspendSession];
}
- (IBAction)toggleKeyboard:(id)sender
{
- if(!_keyboard_visible)
+ if (!_keyboard_visible)
[_dummy_textfield becomeFirstResponder];
else
[_dummy_textfield resignFirstResponder];
@@ -513,471 +564,550 @@
- (IBAction)toggleExtKeyboard:(id)sender
{
- // if the sys kb is shown but not the advanced kb then toggle the advanced kb
- if(_keyboard_visible && !_advanced_keyboard_visible)
- [self toggleKeyboardWhenOtherVisible:nil];
- else
- {
- // if not visible request the advanced keyboard view
- if(_advanced_keyboard_visible == NO)
- _requesting_advanced_keyboard = YES;
- [self toggleKeyboard:nil];
- }
+ // if the sys kb is shown but not the advanced kb then toggle the advanced kb
+ if (_keyboard_visible && !_advanced_keyboard_visible)
+ [self toggleKeyboardWhenOtherVisible:nil];
+ else
+ {
+ // if not visible request the advanced keyboard view
+ if (_advanced_keyboard_visible == NO)
+ _requesting_advanced_keyboard = YES;
+ [self toggleKeyboard:nil];
+ }
}
- (IBAction)toggleTouchPointer:(id)sender
{
- BOOL toggle_visibilty = ![_touchpointer_view isHidden];
- [_touchpointer_view setHidden:toggle_visibilty];
- if(toggle_visibilty)
- [_session_scrollview setContentInset:UIEdgeInsetsZero];
- else
- [_session_scrollview setContentInset:[_touchpointer_view getEdgeInsets]];
+ BOOL toggle_visibilty = ![_touchpointer_view isHidden];
+ [_touchpointer_view setHidden:toggle_visibilty];
+ if (toggle_visibilty)
+ [_session_scrollview setContentInset:UIEdgeInsetsZero];
+ else
+ [_session_scrollview setContentInset:[_touchpointer_view getEdgeInsets]];
}
- (IBAction)disconnectSession:(id)sender
{
- [_session disconnect];
+ [_session disconnect];
}
-
--(IBAction)cancelButtonPressed:(id)sender
+- (IBAction)cancelButtonPressed:(id)sender
{
- [_session disconnect];
+ [_session disconnect];
}
#pragma mark -
#pragma mark iOS Keyboard Notification Handlers
// the keyboard is given in a portrait frame of reference
-- (BOOL)isLandscape {
-
+- (BOOL)isLandscape
+{
+
UIInterfaceOrientation ori = [[UIApplication sharedApplication] statusBarOrientation];
- return ( ori == UIInterfaceOrientationLandscapeLeft || ori == UIInterfaceOrientationLandscapeRight );
-
+ return (ori == UIInterfaceOrientationLandscapeLeft ||
+ ori == UIInterfaceOrientationLandscapeRight);
}
-- (void)shiftKeyboard: (NSNotification*)notification {
-
- CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
-
+- (void)shiftKeyboard:(NSNotification *)notification
+{
+
+ CGRect keyboardEndFrame =
+ [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+
CGFloat previousHeight = _keyboard_last_height;
-
- if( [self isLandscape] ) {
+
+ if ([self isLandscape])
+ {
// landscape has the keyboard based on x, so x can go negative
_keyboard_last_height = keyboardEndFrame.size.width + keyboardEndFrame.origin.x;
- } else {
+ }
+ else
+ {
// portrait has the keyboard based on the difference of the height and the frames y.
CGFloat height = [[UIScreen mainScreen] bounds].size.height;
_keyboard_last_height = height - keyboardEndFrame.origin.y;
}
-
+
CGFloat shiftHeight = _keyboard_last_height - previousHeight;
-
+
[UIView beginAnimations:nil context:NULL];
- [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
- [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
+ [UIView setAnimationCurve:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
+ [UIView
+ setAnimationDuration:[[[notification userInfo]
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
CGRect frame = [_session_scrollview frame];
frame.size.height -= shiftHeight;
[_session_scrollview setFrame:frame];
- [_touchpointer_view setFrame:frame];
+ [_touchpointer_view setFrame:frame];
[UIView commitAnimations];
-
}
- (void)keyboardWillShow:(NSNotification *)notification
{
- [self shiftKeyboard: notification];
-
- [_touchpointer_view ensurePointerIsVisible];
+ [self shiftKeyboard:notification];
+
+ [_touchpointer_view ensurePointerIsVisible];
}
- (void)keyboardDidShow:(NSNotification *)notification
{
- if(_requesting_advanced_keyboard)
- {
- [self showAdvancedKeyboardAnimated];
- _advanced_keyboard_visible = YES;
- _requesting_advanced_keyboard = NO;
- }
+ if (_requesting_advanced_keyboard)
+ {
+ [self showAdvancedKeyboardAnimated];
+ _advanced_keyboard_visible = YES;
+ _requesting_advanced_keyboard = NO;
+ }
}
- (void)keyboardWillHide:(NSNotification *)notification
{
-
- [self shiftKeyboard: notification];
-
+
+ [self shiftKeyboard:notification];
}
-- (void)keyboardDidHide:(NSNotification*)notification
+- (void)keyboardDidHide:(NSNotification *)notification
{
- // release adanced keyboard view
- if(_advanced_keyboard_visible == YES)
- {
- _advanced_keyboard_visible = NO;
- [_advanced_keyboard_view removeFromSuperview];
- [_advanced_keyboard_view autorelease];
- _advanced_keyboard_view = nil;
- }
+ // release adanced keyboard view
+ if (_advanced_keyboard_visible == YES)
+ {
+ _advanced_keyboard_visible = NO;
+ [_advanced_keyboard_view removeFromSuperview];
+ [_advanced_keyboard_view autorelease];
+ _advanced_keyboard_view = nil;
+ }
}
#pragma mark -
#pragma mark Gesture handlers
-- (void)handleSingleTap:(UITapGestureRecognizer*)gesture
+- (void)handleSingleTap:(UITapGestureRecognizer *)gesture
{
CGPoint pos = [gesture locationInView:_session_view];
- if (_toggle_mouse_button)
- {
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(YES) position:pos]];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(NO) position:pos]];
- }
- else
- {
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES) position:pos]];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO) position:pos]];
- }
+ if (_toggle_mouse_button)
+ {
+ [_session
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(YES)
+ position:pos]];
+ [_session
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(NO)
+ position:pos]];
+ }
+ else
+ {
+ [_session
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
+ position:pos]];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
+ position:pos]];
+ }
- _toggle_mouse_button = NO;
+ _toggle_mouse_button = NO;
}
-- (void)handleDoubleTap:(UITapGestureRecognizer*)gesture
+- (void)handleDoubleTap:(UITapGestureRecognizer *)gesture
{
- CGPoint pos = [gesture locationInView:_session_view];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES) position:pos]];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO) position:pos]];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES) position:pos]];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO) position:pos]];
- _toggle_mouse_button = NO;
-}
-
-- (void)handleLongPress:(UILongPressGestureRecognizer*)gesture
-{
CGPoint pos = [gesture locationInView:_session_view];
-
- if([gesture state] == UIGestureRecognizerStateBegan)
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES) position:pos]];
- else if([gesture state] == UIGestureRecognizerStateChanged)
- [self handleMouseMoveForPosition:pos];
- else if([gesture state] == UIGestureRecognizerStateEnded)
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO) position:pos]];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
+ position:pos]];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
+ position:pos]];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
+ position:pos]];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
+ position:pos]];
+ _toggle_mouse_button = NO;
}
-
-- (void)handleDoubleLongPress:(UILongPressGestureRecognizer*)gesture
+- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
- // this point is mapped against the scroll view because we want to have relative movement to the screen/scrollview
+ CGPoint pos = [gesture locationInView:_session_view];
+
+ if ([gesture state] == UIGestureRecognizerStateBegan)
+ [_session
+ sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(YES)
+ position:pos]];
+ else if ([gesture state] == UIGestureRecognizerStateChanged)
+ [self handleMouseMoveForPosition:pos];
+ else if ([gesture state] == UIGestureRecognizerStateEnded)
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(NO)
+ position:pos]];
+}
+
+- (void)handleDoubleLongPress:(UILongPressGestureRecognizer *)gesture
+{
+ // this point is mapped against the scroll view because we want to have relative movement to the
+ // screen/scrollview
CGPoint pos = [gesture locationInView:_session_scrollview];
-
- if([gesture state] == UIGestureRecognizerStateBegan)
- _prev_long_press_position = pos;
- else if([gesture state] == UIGestureRecognizerStateChanged)
- {
- int delta = _prev_long_press_position.y - pos.y;
-
- if(delta > GetScrollGestureDelta())
- {
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(YES) position:pos]];
- _prev_long_press_position = pos;
- }
- else if(delta < -GetScrollGestureDelta())
- {
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(NO) position:pos]];
- _prev_long_press_position = pos;
- }
- }
+
+ if ([gesture state] == UIGestureRecognizerStateBegan)
+ _prev_long_press_position = pos;
+ else if ([gesture state] == UIGestureRecognizerStateChanged)
+ {
+ int delta = _prev_long_press_position.y - pos.y;
+
+ if (delta > GetScrollGestureDelta())
+ {
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(YES)
+ position:pos]];
+ _prev_long_press_position = pos;
+ }
+ else if (delta < -GetScrollGestureDelta())
+ {
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(NO)
+ position:pos]];
+ _prev_long_press_position = pos;
+ }
+ }
}
--(void)handleSingle2FingersTap:(UITapGestureRecognizer*)gesture
+- (void)handleSingle2FingersTap:(UITapGestureRecognizer *)gesture
{
- _toggle_mouse_button = !_toggle_mouse_button;
+ _toggle_mouse_button = !_toggle_mouse_button;
}
--(void)handleSingle3FingersTap:(UITapGestureRecognizer*)gesture
+- (void)handleSingle3FingersTap:(UITapGestureRecognizer *)gesture
{
- [_session setToolbarVisible:![_session toolbarVisible]];
- [self showSessionToolbar:[_session toolbarVisible]];
+ [_session setToolbarVisible:![_session toolbarVisible]];
+ [self showSessionToolbar:[_session toolbarVisible]];
}
#pragma mark -
#pragma mark Touch Pointer delegates
// callback if touch pointer should be closed
--(void)touchPointerClose
+- (void)touchPointerClose
{
- [self toggleTouchPointer:nil];
+ [self toggleTouchPointer:nil];
}
// callback for a left click action
--(void)touchPointerLeftClick:(CGPoint)pos down:(BOOL)down
+- (void)touchPointerLeftClick:(CGPoint)pos down:(BOOL)down
{
- CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(down) position:session_view_pos]];
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetLeftMouseButtonClickEvent(down)
+ position:session_view_pos]];
}
// callback for a right click action
--(void)touchPointerRightClick:(CGPoint)pos down:(BOOL)down
+- (void)touchPointerRightClick:(CGPoint)pos down:(BOOL)down
{
- CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(down) position:session_view_pos]];
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetRightMouseButtonClickEvent(down)
+ position:session_view_pos]];
}
- (void)doAutoScrolling
{
- int scrollX = 0;
- int scrollY = 0;
- CGPoint curPointerPos = [_touchpointer_view getPointerPosition];
- CGRect viewBounds = [_touchpointer_view bounds];
- CGRect scrollBounds = [_session_view bounds];
+ int scrollX = 0;
+ int scrollY = 0;
+ CGPoint curPointerPos = [_touchpointer_view getPointerPosition];
+ CGRect viewBounds = [_touchpointer_view bounds];
+ CGRect scrollBounds = [_session_view bounds];
- // add content insets to scroll bounds
- scrollBounds.size.width += [_session_scrollview contentInset].right;
- scrollBounds.size.height += [_session_scrollview contentInset].bottom;
-
- // add zoom factor
- scrollBounds.size.width *= [_session_scrollview zoomScale];
- scrollBounds.size.height *= [_session_scrollview zoomScale];
-
- if (curPointerPos.x > (viewBounds.size.width - [_touchpointer_view getPointerWidth]))
- scrollX = AUTOSCROLLDISTANCE;
- else if (curPointerPos.x < 0)
- scrollX = -AUTOSCROLLDISTANCE;
+ // add content insets to scroll bounds
+ scrollBounds.size.width += [_session_scrollview contentInset].right;
+ scrollBounds.size.height += [_session_scrollview contentInset].bottom;
- if (curPointerPos.y > (viewBounds.size.height - [_touchpointer_view getPointerHeight]))
- scrollY = AUTOSCROLLDISTANCE;
- else if (curPointerPos.y < (_session_toolbar_visible ? TOOLBAR_HEIGHT : 0))
- scrollY = -AUTOSCROLLDISTANCE;
+ // add zoom factor
+ scrollBounds.size.width *= [_session_scrollview zoomScale];
+ scrollBounds.size.height *= [_session_scrollview zoomScale];
- CGPoint newOffset = [_session_scrollview contentOffset];
- newOffset.x += scrollX;
- newOffset.y += scrollY;
+ if (curPointerPos.x > (viewBounds.size.width - [_touchpointer_view getPointerWidth]))
+ scrollX = AUTOSCROLLDISTANCE;
+ else if (curPointerPos.x < 0)
+ scrollX = -AUTOSCROLLDISTANCE;
- // if offset is going off screen - stop scrolling in that direction
- if (newOffset.x < 0)
- {
- scrollX = 0;
- newOffset.x = 0;
- }
- else if (newOffset.x > (scrollBounds.size.width - viewBounds.size.width))
- {
- scrollX = 0;
- newOffset.x = MAX(scrollBounds.size.width - viewBounds.size.width, 0);
- }
- if (newOffset.y < 0)
- {
- scrollY = 0;
- newOffset.y = 0;
- }
- else if (newOffset.y > (scrollBounds.size.height - viewBounds.size.height))
- {
- scrollY = 0;
- newOffset.y = MAX(scrollBounds.size.height - viewBounds.size.height, 0);
- }
+ if (curPointerPos.y > (viewBounds.size.height - [_touchpointer_view getPointerHeight]))
+ scrollY = AUTOSCROLLDISTANCE;
+ else if (curPointerPos.y < (_session_toolbar_visible ? TOOLBAR_HEIGHT : 0))
+ scrollY = -AUTOSCROLLDISTANCE;
- // perform scrolling
- [_session_scrollview setContentOffset:newOffset];
+ CGPoint newOffset = [_session_scrollview contentOffset];
+ newOffset.x += scrollX;
+ newOffset.y += scrollY;
- // continue scrolling?
- if (scrollX != 0 || scrollY != 0)
- [self performSelector:@selector(doAutoScrolling) withObject:nil afterDelay:AUTOSCROLLTIMEOUT];
- else
- _is_autoscrolling = NO;
+ // if offset is going off screen - stop scrolling in that direction
+ if (newOffset.x < 0)
+ {
+ scrollX = 0;
+ newOffset.x = 0;
+ }
+ else if (newOffset.x > (scrollBounds.size.width - viewBounds.size.width))
+ {
+ scrollX = 0;
+ newOffset.x = MAX(scrollBounds.size.width - viewBounds.size.width, 0);
+ }
+ if (newOffset.y < 0)
+ {
+ scrollY = 0;
+ newOffset.y = 0;
+ }
+ else if (newOffset.y > (scrollBounds.size.height - viewBounds.size.height))
+ {
+ scrollY = 0;
+ newOffset.y = MAX(scrollBounds.size.height - viewBounds.size.height, 0);
+ }
+
+ // perform scrolling
+ [_session_scrollview setContentOffset:newOffset];
+
+ // continue scrolling?
+ if (scrollX != 0 || scrollY != 0)
+ [self performSelector:@selector(doAutoScrolling)
+ withObject:nil
+ afterDelay:AUTOSCROLLTIMEOUT];
+ else
+ _is_autoscrolling = NO;
}
// callback for a right click action
--(void)touchPointerMove:(CGPoint)pos
+- (void)touchPointerMove:(CGPoint)pos
{
- CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
- [self handleMouseMoveForPosition:session_view_pos];
-
- if (_autoscroll_with_touchpointer && !_is_autoscrolling)
- {
- _is_autoscrolling = YES;
- [self performSelector:@selector(doAutoScrolling) withObject:nil afterDelay:AUTOSCROLLTIMEOUT];
- }
+ CGPoint session_view_pos = [_touchpointer_view convertPoint:pos toView:_session_view];
+ [self handleMouseMoveForPosition:session_view_pos];
+
+ if (_autoscroll_with_touchpointer && !_is_autoscrolling)
+ {
+ _is_autoscrolling = YES;
+ [self performSelector:@selector(doAutoScrolling)
+ withObject:nil
+ afterDelay:AUTOSCROLLTIMEOUT];
+ }
}
// callback if scrolling is performed
--(void)touchPointerScrollDown:(BOOL)down
-{
- [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(down) position:CGPointZero]];
+- (void)touchPointerScrollDown:(BOOL)down
+{
+ [_session sendInputEvent:[self eventDescriptorForMouseEvent:GetMouseWheelEvent(down)
+ position:CGPointZero]];
}
// callback for toggling the standard keyboard
--(void)touchPointerToggleKeyboard
+- (void)touchPointerToggleKeyboard
{
- if(_advanced_keyboard_visible)
- [self toggleKeyboardWhenOtherVisible:nil];
- else
- [self toggleKeyboard:nil];
+ if (_advanced_keyboard_visible)
+ [self toggleKeyboardWhenOtherVisible:nil];
+ else
+ [self toggleKeyboard:nil];
}
// callback for toggling the extended keyboard
--(void)touchPointerToggleExtendedKeyboard
+- (void)touchPointerToggleExtendedKeyboard
{
- [self toggleExtKeyboard:nil];
+ [self toggleExtKeyboard:nil];
}
// callback for reset view
--(void)touchPointerResetSessionView
+- (void)touchPointerResetSessionView
{
- [_session_scrollview setZoomScale:1.0 animated:YES];
+ [_session_scrollview setZoomScale:1.0 animated:YES];
}
@end
-
@implementation RDPSessionViewController (Private)
#pragma mark -
#pragma mark Helper functions
--(void)showSessionToolbar:(BOOL)show
+- (void)showSessionToolbar:(BOOL)show
{
- // already shown or hidden?
- if (_session_toolbar_visible == show)
- return;
-
- if(show)
- {
- [UIView beginAnimations:@"showToolbar" context:nil];
- [UIView setAnimationDuration:.4];
- [UIView setAnimationCurve:UIViewAnimationCurveLinear];
- [_session_toolbar setFrame:CGRectMake(0.0, 0.0, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
- [UIView commitAnimations];
- _session_toolbar_visible = YES;
- }
- else
- {
- [UIView beginAnimations:@"hideToolbar" context:nil];
- [UIView setAnimationDuration:.4];
- [UIView setAnimationCurve:UIViewAnimationCurveLinear];
- [_session_toolbar setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
- [UIView commitAnimations];
- _session_toolbar_visible = NO;
- }
+ // already shown or hidden?
+ if (_session_toolbar_visible == show)
+ return;
+
+ if (show)
+ {
+ [UIView beginAnimations:@"showToolbar" context:nil];
+ [UIView setAnimationDuration:.4];
+ [UIView setAnimationCurve:UIViewAnimationCurveLinear];
+ [_session_toolbar
+ setFrame:CGRectMake(0.0, 0.0, [[self view] bounds].size.width, TOOLBAR_HEIGHT)];
+ [UIView commitAnimations];
+ _session_toolbar_visible = YES;
+ }
+ else
+ {
+ [UIView beginAnimations:@"hideToolbar" context:nil];
+ [UIView setAnimationDuration:.4];
+ [UIView setAnimationCurve:UIViewAnimationCurveLinear];
+ [_session_toolbar setFrame:CGRectMake(0.0, -TOOLBAR_HEIGHT, [[self view] bounds].size.width,
+ TOOLBAR_HEIGHT)];
+ [UIView commitAnimations];
+ _session_toolbar_visible = NO;
+ }
}
--(UIToolbar*)keyboardToolbar
+- (UIToolbar *)keyboardToolbar
{
- UIToolbar* keyboard_toolbar = [[[UIToolbar alloc] initWithFrame:CGRectNull] autorelease];
+ UIToolbar *keyboard_toolbar = [[[UIToolbar alloc] initWithFrame:CGRectNull] autorelease];
[keyboard_toolbar setBarStyle:UIBarStyleBlackOpaque];
-
- UIBarButtonItem* esc_btn = [[[UIBarButtonItem alloc] initWithTitle:@"Esc" style:UIBarButtonItemStyleBordered target:self action:@selector(pressEscKey:)] autorelease];
- UIImage* win_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"toolbar_icon_win" ofType:@"png"]];
- UIBarButtonItem* win_btn = [[[UIBarButtonItem alloc] initWithImage:win_icon style:UIBarButtonItemStyleBordered target:self action:@selector(toggleWinKey:)] autorelease];
- UIBarButtonItem* ctrl_btn = [[[UIBarButtonItem alloc] initWithTitle:@"Ctrl" style:UIBarButtonItemStyleBordered target:self action:@selector(toggleCtrlKey:)] autorelease];
- UIBarButtonItem* alt_btn = [[[UIBarButtonItem alloc] initWithTitle:@"Alt" style:UIBarButtonItemStyleBordered target:self action:@selector(toggleAltKey:)] autorelease];
- UIBarButtonItem* ext_btn = [[[UIBarButtonItem alloc] initWithTitle:@"Ext" style:UIBarButtonItemStyleBordered target:self action:@selector(toggleKeyboardWhenOtherVisible:)] autorelease];
- UIBarButtonItem* done_btn = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(toggleKeyboard:)] autorelease];
- UIBarButtonItem* flex_spacer = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
-
- // iPad gets a shift button, iphone doesn't (there's just not enough space ...)
- NSArray* items;
- if(IsPad())
- {
- UIBarButtonItem* shift_btn = [[[UIBarButtonItem alloc] initWithTitle:@"Shift" style:UIBarButtonItemStyleBordered target:self action:@selector(toggleShiftKey:)] autorelease];
- items = [NSArray arrayWithObjects:esc_btn, flex_spacer,
- shift_btn, flex_spacer,
- ctrl_btn, flex_spacer,
- win_btn, flex_spacer,
- alt_btn, flex_spacer,
- ext_btn, flex_spacer, done_btn, nil];
- }
- else
- {
- items = [NSArray arrayWithObjects:esc_btn, flex_spacer, ctrl_btn, flex_spacer, win_btn, flex_spacer, alt_btn, flex_spacer, ext_btn, flex_spacer, done_btn, nil];
- }
-
+
+ UIBarButtonItem *esc_btn =
+ [[[UIBarButtonItem alloc] initWithTitle:@"Esc"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(pressEscKey:)] autorelease];
+ UIImage *win_icon =
+ [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"toolbar_icon_win"
+ ofType:@"png"]];
+ UIBarButtonItem *win_btn =
+ [[[UIBarButtonItem alloc] initWithImage:win_icon
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(toggleWinKey:)] autorelease];
+ UIBarButtonItem *ctrl_btn =
+ [[[UIBarButtonItem alloc] initWithTitle:@"Ctrl"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(toggleCtrlKey:)] autorelease];
+ UIBarButtonItem *alt_btn =
+ [[[UIBarButtonItem alloc] initWithTitle:@"Alt"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(toggleAltKey:)] autorelease];
+ UIBarButtonItem *ext_btn = [[[UIBarButtonItem alloc]
+ initWithTitle:@"Ext"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(toggleKeyboardWhenOtherVisible:)] autorelease];
+ UIBarButtonItem *done_btn = [[[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:UIBarButtonSystemItemDone
+ target:self
+ action:@selector(toggleKeyboard:)] autorelease];
+ UIBarButtonItem *flex_spacer =
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
+ target:nil
+ action:nil] autorelease];
+
+ // iPad gets a shift button, iphone doesn't (there's just not enough space ...)
+ NSArray *items;
+ if (IsPad())
+ {
+ UIBarButtonItem *shift_btn =
+ [[[UIBarButtonItem alloc] initWithTitle:@"Shift"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(toggleShiftKey:)] autorelease];
+ items = [NSArray arrayWithObjects:esc_btn, flex_spacer, shift_btn, flex_spacer, ctrl_btn,
+ flex_spacer, win_btn, flex_spacer, alt_btn, flex_spacer,
+ ext_btn, flex_spacer, done_btn, nil];
+ }
+ else
+ {
+ items = [NSArray arrayWithObjects:esc_btn, flex_spacer, ctrl_btn, flex_spacer, win_btn,
+ flex_spacer, alt_btn, flex_spacer, ext_btn, flex_spacer,
+ done_btn, nil];
+ }
+
[keyboard_toolbar setItems:items];
- [keyboard_toolbar sizeToFit];
- return keyboard_toolbar;
+ [keyboard_toolbar sizeToFit];
+ return keyboard_toolbar;
}
- (void)initGestureRecognizers
-{
- // single and double tap recognizer
- UITapGestureRecognizer* doubleTapRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)] autorelease];
- [doubleTapRecognizer setNumberOfTouchesRequired:1];
- [doubleTapRecognizer setNumberOfTapsRequired:2];
-
- UITapGestureRecognizer* singleTapRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)] autorelease];
- [singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
- [singleTapRecognizer setNumberOfTouchesRequired:1];
+{
+ // single and double tap recognizer
+ UITapGestureRecognizer *doubleTapRecognizer =
+ [[[UITapGestureRecognizer alloc] initWithTarget:self
+ action:@selector(handleDoubleTap:)] autorelease];
+ [doubleTapRecognizer setNumberOfTouchesRequired:1];
+ [doubleTapRecognizer setNumberOfTapsRequired:2];
+
+ UITapGestureRecognizer *singleTapRecognizer =
+ [[[UITapGestureRecognizer alloc] initWithTarget:self
+ action:@selector(handleSingleTap:)] autorelease];
+ [singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
+ [singleTapRecognizer setNumberOfTouchesRequired:1];
[singleTapRecognizer setNumberOfTapsRequired:1];
-
- // 2 fingers - tap recognizer
- UITapGestureRecognizer* single2FingersTapRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingle2FingersTap:)] autorelease];
- [single2FingersTapRecognizer setNumberOfTouchesRequired:2];
+
+ // 2 fingers - tap recognizer
+ UITapGestureRecognizer *single2FingersTapRecognizer = [[[UITapGestureRecognizer alloc]
+ initWithTarget:self
+ action:@selector(handleSingle2FingersTap:)] autorelease];
+ [single2FingersTapRecognizer setNumberOfTouchesRequired:2];
[single2FingersTapRecognizer setNumberOfTapsRequired:1];
-
+
// long press gesture recognizer
- UILongPressGestureRecognizer* longPressRecognizer = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
+ UILongPressGestureRecognizer *longPressRecognizer = [[[UILongPressGestureRecognizer alloc]
+ initWithTarget:self
+ action:@selector(handleLongPress:)] autorelease];
[longPressRecognizer setMinimumPressDuration:0.5];
-
- // double long press gesture recognizer
- UILongPressGestureRecognizer* doubleLongPressRecognizer = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleLongPress:)] autorelease];
- [doubleLongPressRecognizer setNumberOfTouchesRequired:2];
+
+ // double long press gesture recognizer
+ UILongPressGestureRecognizer *doubleLongPressRecognizer = [[[UILongPressGestureRecognizer alloc]
+ initWithTarget:self
+ action:@selector(handleDoubleLongPress:)] autorelease];
+ [doubleLongPressRecognizer setNumberOfTouchesRequired:2];
[doubleLongPressRecognizer setMinimumPressDuration:0.5];
-
- // 3 finger, single tap gesture for showing/hiding the toolbar
- UITapGestureRecognizer* single3FingersTapRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingle3FingersTap:)] autorelease];
- [single3FingersTapRecognizer setNumberOfTapsRequired:1];
- [single3FingersTapRecognizer setNumberOfTouchesRequired:3];
-
- // add gestures to scroll view
+
+ // 3 finger, single tap gesture for showing/hiding the toolbar
+ UITapGestureRecognizer *single3FingersTapRecognizer = [[[UITapGestureRecognizer alloc]
+ initWithTarget:self
+ action:@selector(handleSingle3FingersTap:)] autorelease];
+ [single3FingersTapRecognizer setNumberOfTapsRequired:1];
+ [single3FingersTapRecognizer setNumberOfTouchesRequired:3];
+
+ // add gestures to scroll view
[_session_scrollview addGestureRecognizer:singleTapRecognizer];
[_session_scrollview addGestureRecognizer:doubleTapRecognizer];
[_session_scrollview addGestureRecognizer:single2FingersTapRecognizer];
[_session_scrollview addGestureRecognizer:longPressRecognizer];
[_session_scrollview addGestureRecognizer:doubleLongPressRecognizer];
- [_session_scrollview addGestureRecognizer:single3FingersTapRecognizer];
+ [_session_scrollview addGestureRecognizer:single3FingersTapRecognizer];
}
- (void)suspendSession
{
// suspend session and pop navigation controller
- [_session suspend];
-
- // pop current view controller
- [[self navigationController] popViewControllerAnimated:YES];
+ [_session suspend];
+
+ // pop current view controller
+ [[self navigationController] popViewControllerAnimated:YES];
}
-- (NSDictionary*)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position
+- (NSDictionary *)eventDescriptorForMouseEvent:(int)event position:(CGPoint)position
{
- return [NSDictionary dictionaryWithObjectsAndKeys:
- @"mouse", @"type",
- [NSNumber numberWithUnsignedShort:event], @"flags",
- [NSNumber numberWithUnsignedShort:lrintf(position.x)], @"coord_x",
- [NSNumber numberWithUnsignedShort:lrintf(position.y)], @"coord_y",
- nil];
+ return [NSDictionary
+ dictionaryWithObjectsAndKeys:@"mouse", @"type", [NSNumber numberWithUnsignedShort:event],
+ @"flags",
+ [NSNumber numberWithUnsignedShort:lrintf(position.x)],
+ @"coord_x",
+ [NSNumber numberWithUnsignedShort:lrintf(position.y)],
+ @"coord_y", nil];
}
-- (void)sendDelayedMouseEventWithTimer:(NSTimer*)timer
+- (void)sendDelayedMouseEventWithTimer:(NSTimer *)timer
{
- _mouse_move_event_timer = nil;
- NSDictionary* event = [timer userInfo];
- [_session sendInputEvent:event];
- [timer autorelease];
+ _mouse_move_event_timer = nil;
+ NSDictionary *event = [timer userInfo];
+ [_session sendInputEvent:event];
+ [timer autorelease];
}
- (void)handleMouseMoveForPosition:(CGPoint)position
{
- NSDictionary* event = [self eventDescriptorForMouseEvent:PTR_FLAGS_MOVE position:position];
-
- // cancel pending mouse move events
- [_mouse_move_event_timer invalidate];
- _mouse_move_events_skipped++;
-
- if (_mouse_move_events_skipped >= 5)
- {
- [_session sendInputEvent:event];
- _mouse_move_events_skipped = 0;
- }
- else
- {
- [_mouse_move_event_timer autorelease];
- _mouse_move_event_timer = [[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(sendDelayedMouseEventWithTimer:) userInfo:event repeats:NO] retain];
- }
+ NSDictionary *event = [self eventDescriptorForMouseEvent:PTR_FLAGS_MOVE position:position];
+
+ // cancel pending mouse move events
+ [_mouse_move_event_timer invalidate];
+ _mouse_move_events_skipped++;
+
+ if (_mouse_move_events_skipped >= 5)
+ {
+ [_session sendInputEvent:event];
+ _mouse_move_events_skipped = 0;
+ }
+ else
+ {
+ [_mouse_move_event_timer autorelease];
+ _mouse_move_event_timer =
+ [[NSTimer scheduledTimerWithTimeInterval:0.05
+ target:self
+ selector:@selector(sendDelayedMouseEventWithTimer:)
+ userInfo:event
+ repeats:NO] retain];
+ }
}
@end
diff --git a/client/iOS/Controllers/ScreenSelectionController.h b/client/iOS/Controllers/ScreenSelectionController.h
index 3ccf973da..a4d8f9bab 100644
--- a/client/iOS/Controllers/ScreenSelectionController.h
+++ b/client/iOS/Controllers/ScreenSelectionController.h
@@ -1,10 +1,11 @@
/*
controller for screen settings selection
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "EditorBaseController.h"
@@ -14,20 +15,20 @@
@interface ScreenSelectionController : EditorBaseController
{
-@private
- NSString* _keyPath;
- ConnectionParams* _params;
-
- // avaiable options
- OrderedDictionary* _color_options;
- NSArray* _resolution_modes;
+ @private
+ NSString *_keyPath;
+ ConnectionParams *_params;
- // current selections
- int _selection_color;
- int _selection_resolution;
+ // avaiable options
+ OrderedDictionary *_color_options;
+ NSArray *_resolution_modes;
+
+ // current selections
+ int _selection_color;
+ int _selection_resolution;
}
-- (id)initWithConnectionParams:(ConnectionParams*)params;
-- (id)initWithConnectionParams:(ConnectionParams*)params keyPath:(NSString*)keyPath;
+- (id)initWithConnectionParams:(ConnectionParams *)params;
+- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
@end
diff --git a/client/iOS/Controllers/ScreenSelectionController.m b/client/iOS/Controllers/ScreenSelectionController.m
index 099e4c07f..cfe747dda 100644
--- a/client/iOS/Controllers/ScreenSelectionController.m
+++ b/client/iOS/Controllers/ScreenSelectionController.m
@@ -1,10 +1,11 @@
/*
controller for screen settings selection
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "ScreenSelectionController.h"
@@ -13,197 +14,213 @@
#import "ConnectionParams.h"
@interface ScreenSelectionController (Private)
--(NSString*)keyPathForKey:(NSString*)key;
+- (NSString *)keyPathForKey:(NSString *)key;
@end
@implementation ScreenSelectionController
-- (id)initWithConnectionParams:(ConnectionParams*)params
+- (id)initWithConnectionParams:(ConnectionParams *)params
{
- return [self initWithConnectionParams:params keyPath:nil];
+ return [self initWithConnectionParams:params keyPath:nil];
}
-- (id)initWithConnectionParams:(ConnectionParams*)params keyPath:(NSString*)keyPath
+- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath
{
- self = [super initWithStyle:UITableViewStyleGrouped];
- if (self)
- {
- _params = [params retain];
- _keyPath = (keyPath != nil ? [keyPath retain] : nil);
-
- _color_options = (OrderedDictionary*)[SelectionForColorSetting() retain];
- _resolution_modes = [ResolutionModes() retain];
-
- // init current selections
- NSUInteger idx = [_color_options indexForValue:[NSNumber numberWithInt:[_params intForKeyPath:[self keyPathForKey:@"colors"]]]];
- _selection_color = (idx != NSNotFound) ? idx : 0;
+ self = [super initWithStyle:UITableViewStyleGrouped];
+ if (self)
+ {
+ _params = [params retain];
+ _keyPath = (keyPath != nil ? [keyPath retain] : nil);
- idx = [_resolution_modes indexOfObject:ScreenResolutionDescription([_params intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]],
- [_params intForKeyPath:[self keyPathForKey:@"width"]],
- [_params intForKeyPath:[self keyPathForKey:@"height"]])];
- _selection_resolution = (idx != NSNotFound) ? idx : 0;
- }
- return self;
+ _color_options = (OrderedDictionary *)[SelectionForColorSetting() retain];
+ _resolution_modes = [ResolutionModes() retain];
+
+ // init current selections
+ NSUInteger idx = [_color_options
+ indexForValue:[NSNumber
+ numberWithInt:[_params
+ intForKeyPath:[self keyPathForKey:@"colors"]]]];
+ _selection_color = (idx != NSNotFound) ? idx : 0;
+
+ idx = [_resolution_modes
+ indexOfObject:ScreenResolutionDescription(
+ [_params
+ intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]],
+ [_params intForKeyPath:[self keyPathForKey:@"width"]],
+ [_params intForKeyPath:[self keyPathForKey:@"height"]])];
+ _selection_resolution = (idx != NSNotFound) ? idx : 0;
+ }
+ return self;
}
- (void)dealloc
{
- [super dealloc];
- [_params autorelease];
- [_keyPath autorelease];
- [_color_options autorelease];
- [_resolution_modes autorelease];
+ [super dealloc];
+ [_params autorelease];
+ [_keyPath autorelease];
+ [_color_options autorelease];
+ [_resolution_modes autorelease];
}
--(NSString*)keyPathForKey:(NSString*)key
+- (NSString *)keyPathForKey:(NSString *)key
{
- if (_keyPath)
- return [_keyPath stringByAppendingFormat:@".%@", key];
- return key;
+ if (_keyPath)
+ return [_keyPath stringByAppendingFormat:@".%@", key];
+ return key;
}
#pragma mark - View lifecycle
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- // Return YES for supported orientations
- return YES;
+ // Return YES for supported orientations
+ return YES;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
- return 2;
+ return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
- // Return the number of rows in the section.
- if (section == 0)
- return [_color_options count];
- return [_resolution_modes count] + 2; // +2 for custom width/height input fields
+ // Return the number of rows in the section.
+ if (section == 0)
+ return [_color_options count];
+ return [_resolution_modes count] + 2; // +2 for custom width/height input fields
}
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
- UITableViewCell *cell = nil;
- switch ([indexPath section])
- {
- case 0:
- cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
- [[cell textLabel] setText:[_color_options keyAtIndex:[indexPath row]]];
- break;
-
- case 1:
- if ([indexPath row] < [_resolution_modes count])
- {
- cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
- [[cell textLabel] setText:[_resolution_modes objectAtIndex:[indexPath row]]];
- }
- else
- cell = [self tableViewCellFromIdentifier:TableCellIdentifierText];
- break;
-
- default:
- break;
- }
-
- if ([indexPath section] == 1)
- {
- BOOL enabled = ([_params intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]] == TSXScreenOptionCustom);
- if ([indexPath row] == [_resolution_modes count])
- {
- int value = [_params intForKeyPath:[self keyPathForKey:@"width"]];
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell label] setText:NSLocalizedString(@"Width", @"Custom Screen Width")];
- [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 800]];
- [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
- [[textCell label] setEnabled:enabled];
- [[textCell textfield] setEnabled:enabled];
- [[textCell textfield] setTag:1];
- }
- else if ([indexPath row] == ([_resolution_modes count] + 1))
- {
- int value = [_params intForKeyPath:[self keyPathForKey:@"height"]];
- EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell;
- [[textCell label] setText:NSLocalizedString(@"Height", @"Custom Screen Height")];
- [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 600]];
- [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
- [[textCell label] setEnabled:enabled];
- [[textCell textfield] setEnabled:enabled];
- [[textCell textfield] setTag:2];
- }
- }
-
+ UITableViewCell *cell = nil;
+ switch ([indexPath section])
+ {
+ case 0:
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
+ [[cell textLabel] setText:[_color_options keyAtIndex:[indexPath row]]];
+ break;
+
+ case 1:
+ if ([indexPath row] < [_resolution_modes count])
+ {
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierMultiChoice];
+ [[cell textLabel] setText:[_resolution_modes objectAtIndex:[indexPath row]]];
+ }
+ else
+ cell = [self tableViewCellFromIdentifier:TableCellIdentifierText];
+ break;
+
+ default:
+ break;
+ }
+
+ if ([indexPath section] == 1)
+ {
+ BOOL enabled = ([_params intForKeyPath:[self keyPathForKey:@"screen_resolution_type"]] ==
+ TSXScreenOptionCustom);
+ if ([indexPath row] == [_resolution_modes count])
+ {
+ int value = [_params intForKeyPath:[self keyPathForKey:@"width"]];
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell label] setText:NSLocalizedString(@"Width", @"Custom Screen Width")];
+ [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 800]];
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
+ [[textCell label] setEnabled:enabled];
+ [[textCell textfield] setEnabled:enabled];
+ [[textCell textfield] setTag:1];
+ }
+ else if ([indexPath row] == ([_resolution_modes count] + 1))
+ {
+ int value = [_params intForKeyPath:[self keyPathForKey:@"height"]];
+ EditTextTableViewCell *textCell = (EditTextTableViewCell *)cell;
+ [[textCell label] setText:NSLocalizedString(@"Height", @"Custom Screen Height")];
+ [[textCell textfield] setText:[NSString stringWithFormat:@"%d", value ? value : 600]];
+ [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad];
+ [[textCell label] setEnabled:enabled];
+ [[textCell textfield] setEnabled:enabled];
+ [[textCell textfield] setTag:2];
+ }
+ }
+
// set default checkmark
- if([indexPath row] == ([indexPath section] == 0 ? _selection_color : _selection_resolution))
+ if ([indexPath row] == ([indexPath section] == 0 ? _selection_color : _selection_resolution))
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
-
- return cell;
+
+ return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- // custom widht/height cells are not selectable
- if ([indexPath section] == 1 && [indexPath row] >= [_resolution_modes count])
- return;
-
+ // custom widht/height cells are not selectable
+ if ([indexPath section] == 1 && [indexPath row] >= [_resolution_modes count])
+ return;
+
// has selection change?
- int cur_selection = ([indexPath section] == 0 ? _selection_color : _selection_resolution);
- if([indexPath row] != cur_selection)
+ int cur_selection = ([indexPath section] == 0 ? _selection_color : _selection_resolution);
+ if ([indexPath row] != cur_selection)
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
-
- NSIndexPath* oldIndexPath = [NSIndexPath indexPathForRow:cur_selection inSection:[indexPath section]];
-
- // clear old checkmark
- UITableViewCell* old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
- old_sel_cell.accessoryType = UITableViewCellAccessoryNone;
-
- // set new checkmark
- UITableViewCell* new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
- new_sel_cell.accessoryType = UITableViewCellAccessoryCheckmark;
-
- if ([indexPath section] == 0)
- {
- // get value from color dictionary
- int sel_value = [[_color_options valueForKey:[_color_options keyAtIndex:[indexPath row]]] intValue];
-
- // update selection index and params value
- [_params setInt:sel_value forKeyPath:[self keyPathForKey:@"colors"]];
- _selection_color = [indexPath row];
- }
- else
- {
- // update selection index and params value
- int width, height;
- TSXScreenOptions mode;
- ScanScreenResolution([_resolution_modes objectAtIndex:[indexPath row]], &width, &height, &mode);
- [_params setInt:mode forKeyPath:[self keyPathForKey:@"screen_resolution_type"]];
- if (mode != TSXScreenOptionCustom)
- {
- [_params setInt:width forKeyPath:[self keyPathForKey:@"width"]];
- [_params setInt:height forKeyPath:[self keyPathForKey:@"height"]];
- }
- _selection_resolution = [indexPath row];
- // refresh width/height edit fields if custom selection changed
- NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:[_resolution_modes count] inSection:1],
- [NSIndexPath indexPathForRow:([_resolution_modes count] + 1) inSection:1], nil];
- [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
- }
- }
+ NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:cur_selection
+ inSection:[indexPath section]];
+
+ // clear old checkmark
+ UITableViewCell *old_sel_cell = [tableView cellForRowAtIndexPath:oldIndexPath];
+ old_sel_cell.accessoryType = UITableViewCellAccessoryNone;
+
+ // set new checkmark
+ UITableViewCell *new_sel_cell = [tableView cellForRowAtIndexPath:indexPath];
+ new_sel_cell.accessoryType = UITableViewCellAccessoryCheckmark;
+
+ if ([indexPath section] == 0)
+ {
+ // get value from color dictionary
+ int sel_value =
+ [[_color_options valueForKey:[_color_options keyAtIndex:[indexPath row]]] intValue];
+
+ // update selection index and params value
+ [_params setInt:sel_value forKeyPath:[self keyPathForKey:@"colors"]];
+ _selection_color = [indexPath row];
+ }
+ else
+ {
+ // update selection index and params value
+ int width, height;
+ TSXScreenOptions mode;
+ ScanScreenResolution([_resolution_modes objectAtIndex:[indexPath row]], &width, &height,
+ &mode);
+ [_params setInt:mode forKeyPath:[self keyPathForKey:@"screen_resolution_type"]];
+ if (mode != TSXScreenOptionCustom)
+ {
+ [_params setInt:width forKeyPath:[self keyPathForKey:@"width"]];
+ [_params setInt:height forKeyPath:[self keyPathForKey:@"height"]];
+ }
+ _selection_resolution = [indexPath row];
+
+ // refresh width/height edit fields if custom selection changed
+ NSArray *indexPaths = [NSArray
+ arrayWithObjects:[NSIndexPath indexPathForRow:[_resolution_modes count]
+ inSection:1],
+ [NSIndexPath indexPathForRow:([_resolution_modes count] + 1)
+ inSection:1],
+ nil];
+ [[self tableView] reloadRowsAtIndexPaths:indexPaths
+ withRowAnimation:UITableViewRowAnimationNone];
+ }
+ }
}
#pragma mark -
#pragma mark Text Field delegate
-- (BOOL)textFieldShouldReturn:(UITextField*)textField
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return NO;
@@ -211,20 +228,22 @@
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
-
- switch([textField tag])
- {
- // update resolution settings (and check for invalid input)
+
+ switch ([textField tag])
+ {
+ // update resolution settings (and check for invalid input)
case 1:
- if ([[textField text] intValue] < 640) [textField setText:@"640"];
+ if ([[textField text] intValue] < 640)
+ [textField setText:@"640"];
[_params setInt:[[textField text] intValue] forKeyPath:[self keyPathForKey:@"width"]];
break;
-
+
case 2:
- if ([[textField text] intValue] < 480) [textField setText:@"480"];
+ if ([[textField text] intValue] < 480)
+ [textField setText:@"480"];
[_params setInt:[[textField text] intValue] forKeyPath:[self keyPathForKey:@"height"]];
break;
-
+
default:
break;
}
diff --git a/client/iOS/Controllers/VerifyCertificateController.h b/client/iOS/Controllers/VerifyCertificateController.h
index 78a0e7d5f..cc7453fa8 100644
--- a/client/iOS/Controllers/VerifyCertificateController.h
+++ b/client/iOS/Controllers/VerifyCertificateController.h
@@ -1,10 +1,11 @@
/*
Certificate verification controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -13,17 +14,20 @@
@interface VerifyCertificateController : UIViewController
{
-@private
- IBOutlet UILabel* _label_issuer;
- IBOutlet UIButton* _btn_accept;
- IBOutlet UIButton* _btn_decline;
- IBOutlet UILabel* _label_message;
- IBOutlet UILabel* _label_for_issuer;
+ @private
+ IBOutlet UILabel *_label_issuer;
+ IBOutlet UIButton *_btn_accept;
+ IBOutlet UIButton *_btn_decline;
+ IBOutlet UILabel *_label_message;
+ IBOutlet UILabel *_label_for_issuer;
- RDPSession* _session;
- NSMutableDictionary* _params;
+ RDPSession *_session;
+ NSMutableDictionary *_params;
}
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession*)session params:(NSMutableDictionary*)params;
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session
+ params:(NSMutableDictionary *)params;
@end
diff --git a/client/iOS/Controllers/VerifyCertificateController.m b/client/iOS/Controllers/VerifyCertificateController.m
index d677868a6..c6412393f 100644
--- a/client/iOS/Controllers/VerifyCertificateController.m
+++ b/client/iOS/Controllers/VerifyCertificateController.m
@@ -1,10 +1,11 @@
/*
Certificate verification controller
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "VerifyCertificateController.h"
@@ -12,68 +13,74 @@
@implementation VerifyCertificateController
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil session:(RDPSession *)session params:(NSMutableDictionary *)params
+- (id)initWithNibName:(NSString *)nibNameOrNil
+ bundle:(NSBundle *)nibBundleOrNil
+ session:(RDPSession *)session
+ params:(NSMutableDictionary *)params
{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- _session = session;
- _params = params;
- [self setModalPresentationStyle:UIModalPresentationFormSheet];
- }
- return self;
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self)
+ {
+ _session = session;
+ _params = params;
+ [self setModalPresentationStyle:UIModalPresentationFormSheet];
+ }
+ return self;
}
- (void)viewDidLoad
{
- [super viewDidLoad];
+ [super viewDidLoad];
- NSString* message = NSLocalizedString(@"The identity of the remote computer cannot be verified. Do you want to connect anyway?", @"Verify certificate view message");
-
- // init strings
- [_label_message setText:message];
- [_label_for_issuer setText:NSLocalizedString(@"Issuer:", @"Verify certificate view issuer label")];
- [_btn_accept setTitle:NSLocalizedString(@"Yes", @"Yes Button") forState:UIControlStateNormal];
- [_btn_decline setTitle:NSLocalizedString(@"No", @"No Button") forState:UIControlStateNormal];
+ NSString *message = NSLocalizedString(
+ @"The identity of the remote computer cannot be verified. Do you want to connect anyway?",
+ @"Verify certificate view message");
- [_label_issuer setText:[_params valueForKey:@"issuer"]];
+ // init strings
+ [_label_message setText:message];
+ [_label_for_issuer
+ setText:NSLocalizedString(@"Issuer:", @"Verify certificate view issuer label")];
+ [_btn_accept setTitle:NSLocalizedString(@"Yes", @"Yes Button") forState:UIControlStateNormal];
+ [_btn_decline setTitle:NSLocalizedString(@"No", @"No Button") forState:UIControlStateNormal];
+
+ [_label_issuer setText:[_params valueForKey:@"issuer"]];
}
- (void)viewDidUnload
{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
}
- (void)viewDidDisappear:(BOOL)animated
{
- [super viewDidDisappear:animated];
+ [super viewDidDisappear:animated];
- // set signal
- [[_session uiRequestCompleted] signal];
+ // set signal
+ [[_session uiRequestCompleted] signal];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
- return YES;
+ return YES;
}
-
#pragma mark - Action handlers
- (IBAction)acceptPressed:(id)sender
{
- [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
-
- // dismiss controller
- [self dismissModalViewControllerAnimated:YES];
+ [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
+
+ // dismiss controller
+ [self dismissModalViewControllerAnimated:YES];
}
- (IBAction)declinePressed:(id)sender
{
- [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
-
- // dismiss controller
- [self dismissModalViewControllerAnimated:YES];
+ [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
+
+ // dismiss controller
+ [self dismissModalViewControllerAnimated:YES];
}
@end
diff --git a/client/iOS/FreeRDP/ios_freerdp.h b/client/iOS/FreeRDP/ios_freerdp.h
index d374a321d..8cc7df5ed 100644
--- a/client/iOS/FreeRDP/ios_freerdp.h
+++ b/client/iOS/FreeRDP/ios_freerdp.h
@@ -1,10 +1,11 @@
/*
RDP run-loop
-
+
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
-
+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -18,40 +19,37 @@
// FreeRDP extended structs
typedef struct mf_info mfInfo;
-
typedef struct mf_context
{
rdpContext _p;
-
- mfInfo* mfi;
- rdpSettings* settings;
-} mfContext;
+ mfInfo *mfi;
+ rdpSettings *settings;
+} mfContext;
struct mf_info
{
// RDP
- freerdp* instance;
- mfContext* context;
- rdpContext* _context;
-
+ freerdp *instance;
+ mfContext *context;
+ rdpContext *_context;
+
// UI
- RDPSession* session;
-
+ RDPSession *session;
+
// Graphics
CGContextRef bitmap_context;
-
+
// Events
int event_pipe_producer, event_pipe_consumer;
// Tracking connection state
volatile TSXConnectionState connection_state;
- volatile BOOL unwanted; // set when controlling Session no longer wants the connection to continue
+ volatile BOOL
+ unwanted; // set when controlling Session no longer wants the connection to continue
};
-
-#define MFI_FROM_INSTANCE(inst) (((mfContext*)((inst)->context))->mfi)
-
+#define MFI_FROM_INSTANCE(inst) (((mfContext *)((inst)->context))->mfi)
enum MF_EXIT_CODE
{
@@ -59,17 +57,13 @@ enum MF_EXIT_CODE
MF_EXIT_CONN_FAILED = 128,
MF_EXIT_CONN_CANCELED = 129,
- MF_EXIT_LOGON_TIMEOUT = 130,
-
+ MF_EXIT_LOGON_TIMEOUT = 130,
+
MF_EXIT_UNKNOWN = 255
};
void ios_init_freerdp(void);
void ios_uninit_freerdp(void);
-freerdp* ios_freerdp_new(void);
-int ios_run_freerdp(freerdp* instance);
-void ios_freerdp_free(freerdp* instance);
-
-
-
-
+freerdp *ios_freerdp_new(void);
+int ios_run_freerdp(freerdp *instance);
+void ios_freerdp_free(freerdp *instance);
diff --git a/client/iOS/FreeRDP/ios_freerdp.m b/client/iOS/FreeRDP/ios_freerdp.m
index 4e63da50e..295d769a8 100644
--- a/client/iOS/FreeRDP/ios_freerdp.m
+++ b/client/iOS/FreeRDP/ios_freerdp.m
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -27,94 +28,85 @@
#pragma mark Connection helpers
-static void ios_OnChannelConnectedEventHandler(
- void* context,
- ChannelConnectedEventArgs* e)
+static void ios_OnChannelConnectedEventHandler(void *context, ChannelConnectedEventArgs *e)
{
- rdpSettings* settings;
- mfContext* afc;
+ rdpSettings *settings;
+ mfContext *afc;
if (!context || !e)
{
- WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p",
- __FUNCTION__, context, (void*) e);
+ WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p", __FUNCTION__, context, (void *)e);
return;
}
- afc = (mfContext*) context;
+ afc = (mfContext *)context;
settings = afc->_p.settings;
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
{
- gdi_graphics_pipeline_init(afc->_p.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_init(afc->_p.gdi, (RdpgfxClientContext *)e->pInterface);
}
else
{
WLog_WARN(TAG, "GFX without software GDI requested. "
- " This is not supported, add /gdi:sw");
+ " This is not supported, add /gdi:sw");
}
}
}
-static void ios_OnChannelDisconnectedEventHandler(
- void* context, ChannelDisconnectedEventArgs* e)
+static void ios_OnChannelDisconnectedEventHandler(void *context, ChannelDisconnectedEventArgs *e)
{
- rdpSettings* settings;
- mfContext* afc;
+ rdpSettings *settings;
+ mfContext *afc;
if (!context || !e)
{
- WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p",
- __FUNCTION__, context, (void*) e);
+ WLog_FATAL(TAG, "%s(context=%p, EventArgs=%p", __FUNCTION__, context, (void *)e);
return;
}
- afc = (mfContext*) context;
+ afc = (mfContext *)context;
settings = afc->_p.settings;
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
{
- gdi_graphics_pipeline_uninit(afc->_p.gdi,
- (RdpgfxClientContext*) e->pInterface);
+ gdi_graphics_pipeline_uninit(afc->_p.gdi, (RdpgfxClientContext *)e->pInterface);
}
else
{
WLog_WARN(TAG, "GFX without software GDI requested. "
- " This is not supported, add /gdi:sw");
+ " This is not supported, add /gdi:sw");
}
}
}
-static BOOL ios_pre_connect(freerdp* instance)
+static BOOL ios_pre_connect(freerdp *instance)
{
int rc;
- rdpSettings* settings;
+ rdpSettings *settings;
if (!instance || !instance->settings)
return FALSE;
settings = instance->settings;
- settings->AutoLogonEnabled = settings->Password
- && (strlen(settings->Password) > 0);
+ settings->AutoLogonEnabled = settings->Password && (strlen(settings->Password) > 0);
// Verify screen width/height are sane
- if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64)
- || (settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
+ if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) ||
+ (settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
{
NSLog(@"%s: invalid dimensions %d %d", __func__, settings->DesktopWidth,
settings->DesktopHeight);
return FALSE;
}
- rc = PubSub_SubscribeChannelConnected(
- instance->context->pubSub,
- ios_OnChannelConnectedEventHandler);
+ rc = PubSub_SubscribeChannelConnected(instance->context->pubSub,
+ ios_OnChannelConnectedEventHandler);
if (rc != CHANNEL_RC_OK)
{
@@ -122,9 +114,8 @@ static BOOL ios_pre_connect(freerdp* instance)
return FALSE;
}
- rc = PubSub_SubscribeChannelDisconnected(
- instance->context->pubSub,
- ios_OnChannelDisconnectedEventHandler);
+ rc = PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
+ ios_OnChannelDisconnectedEventHandler);
if (rc != CHANNEL_RC_OK)
{
@@ -132,8 +123,7 @@ static BOOL ios_pre_connect(freerdp* instance)
return FALSE;
}
- if (!freerdp_client_load_addins(instance->context->channels,
- instance->settings))
+ if (!freerdp_client_load_addins(instance->context->channels, instance->settings))
{
WLog_ERR(TAG, "Failed to load addins [%l08X]", GetLastError());
return FALSE;
@@ -142,7 +132,7 @@ static BOOL ios_pre_connect(freerdp* instance)
return TRUE;
}
-static BOOL ios_Pointer_New(rdpContext* context, rdpPointer* pointer)
+static BOOL ios_Pointer_New(rdpContext *context, rdpPointer *pointer)
{
if (!context || !pointer || !context->gdi)
return FALSE;
@@ -150,14 +140,13 @@ static BOOL ios_Pointer_New(rdpContext* context, rdpPointer* pointer)
return TRUE;
}
-static void ios_Pointer_Free(rdpContext* context, rdpPointer* pointer)
+static void ios_Pointer_Free(rdpContext *context, rdpPointer *pointer)
{
if (!context || !pointer)
return;
}
-static BOOL ios_Pointer_Set(rdpContext* context,
- const rdpPointer* pointer)
+static BOOL ios_Pointer_Set(rdpContext *context, const rdpPointer *pointer)
{
if (!context)
return FALSE;
@@ -165,8 +154,7 @@ static BOOL ios_Pointer_Set(rdpContext* context,
return TRUE;
}
-static BOOL ios_Pointer_SetPosition(rdpContext* context,
- UINT32 x, UINT32 y)
+static BOOL ios_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y)
{
if (!context)
return FALSE;
@@ -174,7 +162,7 @@ static BOOL ios_Pointer_SetPosition(rdpContext* context,
return TRUE;
}
-static BOOL ios_Pointer_SetNull(rdpContext* context)
+static BOOL ios_Pointer_SetNull(rdpContext *context)
{
if (!context)
return FALSE;
@@ -182,7 +170,7 @@ static BOOL ios_Pointer_SetNull(rdpContext* context)
return TRUE;
}
-static BOOL ios_Pointer_SetDefault(rdpContext* context)
+static BOOL ios_Pointer_SetDefault(rdpContext *context)
{
if (!context)
return FALSE;
@@ -190,7 +178,7 @@ static BOOL ios_Pointer_SetDefault(rdpContext* context)
return TRUE;
}
-static BOOL ios_register_pointer(rdpGraphics* graphics)
+static BOOL ios_register_pointer(rdpGraphics *graphics)
{
rdpPointer pointer;
@@ -208,9 +196,9 @@ static BOOL ios_register_pointer(rdpGraphics* graphics)
return TRUE;
}
-static BOOL ios_post_connect(freerdp* instance)
+static BOOL ios_post_connect(freerdp *instance)
{
- mfInfo* mfi;
+ mfInfo *mfi;
if (!instance)
return FALSE;
@@ -231,11 +219,12 @@ static BOOL ios_post_connect(freerdp* instance)
instance->update->EndPaint = ios_ui_end_paint;
instance->update->DesktopResize = ios_ui_resize_window;
[mfi->session performSelectorOnMainThread:@selector(sessionDidConnect)
- withObject:nil waitUntilDone:YES];
+ withObject:nil
+ waitUntilDone:YES];
return TRUE;
}
-static void ios_post_disconnect(freerdp* instance)
+static void ios_post_disconnect(freerdp *instance)
{
gdi_free(instance);
}
@@ -243,11 +232,11 @@ static void ios_post_disconnect(freerdp* instance)
#pragma mark -
#pragma mark Running the connection
-int ios_run_freerdp(freerdp* instance)
+int ios_run_freerdp(freerdp *instance)
{
- mfContext* context = (mfContext*)instance->context;
- mfInfo* mfi = context->mfi;
- rdpChannels* channels = instance->context->channels;
+ mfContext *context = (mfContext *)instance->context;
+ mfInfo *mfi = context->mfi;
+ rdpChannels *channels = instance->context->channels;
mfi->connection_state = TSXConnectionConnecting;
if (!freerdp_connect(instance))
@@ -261,14 +250,14 @@ int ios_run_freerdp(freerdp* instance)
mfi->connection_state = TSXConnectionConnected;
// Connection main loop
- NSAutoreleasePool* pool;
+ NSAutoreleasePool *pool;
int i;
int fds;
int max_fds;
int rcount;
int wcount;
- void* rfds[32];
- void* wfds[32];
+ void *rfds[32];
+ void *wfds[32];
fd_set rfds_set;
fd_set wfds_set;
struct timeval timeout;
@@ -287,8 +276,7 @@ int ios_run_freerdp(freerdp* instance)
break;
}
- if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds,
- &wcount) != TRUE)
+ if (freerdp_channels_get_fds(channels, instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
NSLog(@"%s: freerdp_chanman_get_fds failed", __func__);
break;
@@ -329,9 +317,7 @@ int ios_run_freerdp(freerdp* instance)
else if (select_status == -1)
{
/* these are not really errors */
- if (!((errno == EAGAIN) ||
- (errno == EWOULDBLOCK) ||
- (errno == EINPROGRESS) ||
+ if (!((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINPROGRESS) ||
(errno == EINTR))) /* signal occurred */
{
NSLog(@"%s: select failed!", __func__);
@@ -350,7 +336,7 @@ int ios_run_freerdp(freerdp* instance)
if (ios_events_check_fds(mfi, &rfds_set) != TRUE)
{
// This event will fail when the app asks for a disconnect.
- //NSLog(@"%s: ios_events_check_fds failed: terminating connection.", __func__);
+ // NSLog(@"%s: ios_events_check_fds failed: terminating connection.", __func__);
break;
}
@@ -380,9 +366,9 @@ int ios_run_freerdp(freerdp* instance)
#pragma mark -
#pragma mark Context callbacks
-static BOOL ios_client_new(freerdp* instance, rdpContext* context)
+static BOOL ios_client_new(freerdp *instance, rdpContext *context)
{
- mfContext* ctx = (mfContext*)context;
+ mfContext *ctx = (mfContext *)context;
if (!instance || !context)
return FALSE;
@@ -390,7 +376,7 @@ static BOOL ios_client_new(freerdp* instance, rdpContext* context)
if ((ctx->mfi = calloc(1, sizeof(mfInfo))) == NULL)
return FALSE;
- ctx->mfi->context = (mfContext*)context;
+ ctx->mfi->context = (mfContext *)context;
ctx->mfi->_context = context;
ctx->mfi->context->settings = instance->settings;
ctx->mfi->instance = instance;
@@ -409,19 +395,19 @@ static BOOL ios_client_new(freerdp* instance, rdpContext* context)
return TRUE;
}
-static void ios_client_free(freerdp* instance, rdpContext* context)
+static void ios_client_free(freerdp *instance, rdpContext *context)
{
- mfInfo* mfi;
+ mfInfo *mfi;
if (!context)
return;
- mfi = ((mfContext*) context)->mfi;
+ mfi = ((mfContext *)context)->mfi;
ios_events_free_pipe(mfi);
free(mfi);
}
-static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
+static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
{
ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION;
@@ -439,9 +425,9 @@ static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
#pragma mark -
#pragma mark Initialization and cleanup
-freerdp* ios_freerdp_new()
+freerdp *ios_freerdp_new()
{
- rdpContext* context;
+ rdpContext *context;
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
RdpClientEntry(&clientEntryPoints);
context = freerdp_client_context_new(&clientEntryPoints);
@@ -452,7 +438,7 @@ freerdp* ios_freerdp_new()
return context->instance;
}
-void ios_freerdp_free(freerdp* instance)
+void ios_freerdp_free(freerdp *instance)
{
if (!instance || !instance->context)
return;
@@ -470,7 +456,7 @@ void ios_uninit_freerdp()
}
/* compatibilty functions */
-size_t fwrite$UNIX2003(const void* ptr, size_t size, size_t nmemb, FILE* stream)
+size_t fwrite$UNIX2003(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fwrite(ptr, size, nmemb, stream);
}
diff --git a/client/iOS/FreeRDP/ios_freerdp_events.h b/client/iOS/FreeRDP/ios_freerdp_events.h
index 630c6b21e..7caf327f0 100644
--- a/client/iOS/FreeRDP/ios_freerdp_events.h
+++ b/client/iOS/FreeRDP/ios_freerdp_events.h
@@ -1,10 +1,11 @@
/*
- RDP event queuing
-
+ RDP event queuing
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#ifndef IOS_RDP_EVENT_H
@@ -14,12 +15,13 @@
#import "ios_freerdp.h"
// For UI: use to send events
-BOOL ios_events_send(mfInfo* mfi, NSDictionary * event_description);
+BOOL ios_events_send(mfInfo *mfi, NSDictionary *event_description);
// For connection runloop: use to poll for queued input events
-BOOL ios_events_get_fds(mfInfo* mfi, void ** read_fds, int * read_count, void ** write_fds, int * write_count);
-BOOL ios_events_check_fds(mfInfo* mfi, fd_set* rfds);
-BOOL ios_events_create_pipe(mfInfo* mfi);
-void ios_events_free_pipe(mfInfo* mfi);
+BOOL ios_events_get_fds(mfInfo *mfi, void **read_fds, int *read_count, void **write_fds,
+ int *write_count);
+BOOL ios_events_check_fds(mfInfo *mfi, fd_set *rfds);
+BOOL ios_events_create_pipe(mfInfo *mfi);
+void ios_events_free_pipe(mfInfo *mfi);
#endif /* IOS_RDP_EVENT_H */
diff --git a/client/iOS/FreeRDP/ios_freerdp_events.m b/client/iOS/FreeRDP/ios_freerdp_events.m
index c3e7b5888..0685c42d9 100644
--- a/client/iOS/FreeRDP/ios_freerdp_events.m
+++ b/client/iOS/FreeRDP/ios_freerdp_events.m
@@ -1,10 +1,11 @@
/*
- RDP event queuing
-
+ RDP event queuing
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#include "ios_freerdp_events.h"
@@ -12,107 +13,114 @@
#pragma mark -
#pragma mark Sending compacted input events (from main thread)
-// While this function may be called from any thread that has an autorelease pool allocated, it is not threadsafe: caller is responsible for synchronization
-BOOL ios_events_send(mfInfo* mfi, NSDictionary * event_description)
-{
- NSData * encoded_description = [NSKeyedArchiver archivedDataWithRootObject:event_description];
-
- if ([encoded_description length] > 32000 || (mfi->event_pipe_producer == -1) )
+// While this function may be called from any thread that has an autorelease pool allocated, it is
+// not threadsafe: caller is responsible for synchronization
+BOOL ios_events_send(mfInfo *mfi, NSDictionary *event_description)
+{
+ NSData *encoded_description = [NSKeyedArchiver archivedDataWithRootObject:event_description];
+
+ if ([encoded_description length] > 32000 || (mfi->event_pipe_producer == -1))
return FALSE;
-
+
uint32_t archived_data_len = (uint32_t)[encoded_description length];
-
- //NSLog(@"writing %d bytes to input event pipe", archived_data_len);
-
+
+ // NSLog(@"writing %d bytes to input event pipe", archived_data_len);
+
if (write(mfi->event_pipe_producer, &archived_data_len, 4) == -1)
{
NSLog(@"%s: Failed to write length descriptor to pipe.", __func__);
return FALSE;
}
-
+
if (write(mfi->event_pipe_producer, [encoded_description bytes], archived_data_len) == -1)
{
- NSLog(@"%s: Failed to write %d bytes into the event queue (event type: %@).", __func__, (int)[encoded_description length], [event_description objectForKey:@"type"]);
+ NSLog(@"%s: Failed to write %d bytes into the event queue (event type: %@).", __func__,
+ (int)[encoded_description length], [event_description objectForKey:@"type"]);
return FALSE;
}
-
- return TRUE;
-}
+ return TRUE;
+}
#pragma mark -
#pragma mark Processing compacted input events (from connection thread runloop)
-static BOOL ios_events_handle_event(mfInfo* mfi, NSDictionary * event_description)
+static BOOL ios_events_handle_event(mfInfo *mfi, NSDictionary *event_description)
{
- NSString * event_type = [event_description objectForKey:@"type"];
+ NSString *event_type = [event_description objectForKey:@"type"];
BOOL should_continue = TRUE;
- freerdp* instance = mfi->instance;
-
+ freerdp *instance = mfi->instance;
+
if ([event_type isEqualToString:@"mouse"])
- {
- instance->input->MouseEvent(instance->input,
- [[event_description objectForKey:@"flags"] unsignedShortValue],
- [[event_description objectForKey:@"coord_x"] unsignedShortValue],
- [[event_description objectForKey:@"coord_y"] unsignedShortValue]);
+ {
+ instance->input->MouseEvent(
+ instance->input, [[event_description objectForKey:@"flags"] unsignedShortValue],
+ [[event_description objectForKey:@"coord_x"] unsignedShortValue],
+ [[event_description objectForKey:@"coord_y"] unsignedShortValue]);
}
else if ([event_type isEqualToString:@"keyboard"])
{
if ([[event_description objectForKey:@"subtype"] isEqualToString:@"scancode"])
- instance->input->KeyboardEvent(instance->input,
- [[event_description objectForKey:@"flags"] unsignedShortValue],
- [[event_description objectForKey:@"scancode"] unsignedShortValue]);
+ instance->input->KeyboardEvent(
+ instance->input, [[event_description objectForKey:@"flags"] unsignedShortValue],
+ [[event_description objectForKey:@"scancode"] unsignedShortValue]);
else if ([[event_description objectForKey:@"subtype"] isEqualToString:@"unicode"])
- instance->input->UnicodeKeyboardEvent(instance->input,
- [[event_description objectForKey:@"flags"] unsignedShortValue],
- [[event_description objectForKey:@"unicode_char"] unsignedShortValue]);
+ instance->input->UnicodeKeyboardEvent(
+ instance->input, [[event_description objectForKey:@"flags"] unsignedShortValue],
+ [[event_description objectForKey:@"unicode_char"] unsignedShortValue]);
else
- NSLog(@"%s: doesn't know how to send keyboard input with subtype %@", __func__, [event_description objectForKey:@"subtype"]);
+ NSLog(@"%s: doesn't know how to send keyboard input with subtype %@", __func__,
+ [event_description objectForKey:@"subtype"]);
}
else if ([event_type isEqualToString:@"disconnect"])
should_continue = FALSE;
else
NSLog(@"%s: unrecognized event type: %@", __func__, event_type);
-
+
return should_continue;
}
-BOOL ios_events_check_fds(mfInfo* mfi, fd_set* rfds)
-{
- if ( (mfi->event_pipe_consumer == -1) || !FD_ISSET(mfi->event_pipe_consumer, rfds))
+BOOL ios_events_check_fds(mfInfo *mfi, fd_set *rfds)
+{
+ if ((mfi->event_pipe_consumer == -1) || !FD_ISSET(mfi->event_pipe_consumer, rfds))
return TRUE;
-
+
uint32_t archived_data_length = 0;
ssize_t bytes_read;
-
+
// First, read the length of the blob
bytes_read = read(mfi->event_pipe_consumer, &archived_data_length, 4);
-
+
if (bytes_read == -1 || archived_data_length < 1 || archived_data_length > 32000)
{
- NSLog(@"%s: just read length descriptor. bytes_read=%ld, archived_data_length=%u", __func__, bytes_read, archived_data_length);
+ NSLog(@"%s: just read length descriptor. bytes_read=%ld, archived_data_length=%u", __func__,
+ bytes_read, archived_data_length);
return FALSE;
}
-
- //NSLog(@"reading %d bytes from input event pipe", archived_data_length);
-
- NSMutableData * archived_object_data = [[NSMutableData alloc] initWithLength:archived_data_length];
- bytes_read = read(mfi->event_pipe_consumer, [archived_object_data mutableBytes], archived_data_length);
-
+
+ // NSLog(@"reading %d bytes from input event pipe", archived_data_length);
+
+ NSMutableData *archived_object_data =
+ [[NSMutableData alloc] initWithLength:archived_data_length];
+ bytes_read =
+ read(mfi->event_pipe_consumer, [archived_object_data mutableBytes], archived_data_length);
+
if (bytes_read != archived_data_length)
{
- NSLog(@"%s: attempted to read data; read %ld bytes but wanted %d bytes.", __func__, bytes_read, archived_data_length);
+ NSLog(@"%s: attempted to read data; read %ld bytes but wanted %d bytes.", __func__,
+ bytes_read, archived_data_length);
[archived_object_data release];
return FALSE;
}
-
+
id unarchived_object_data = [NSKeyedUnarchiver unarchiveObjectWithData:archived_object_data];
[archived_object_data release];
-
+
return ios_events_handle_event(mfi, unarchived_object_data);
}
-BOOL ios_events_get_fds(mfInfo* mfi, void ** read_fds, int * read_count, void ** write_fds, int * write_count)
+BOOL ios_events_get_fds(mfInfo *mfi, void **read_fds, int *read_count, void **write_fds,
+ int *write_count)
{
read_fds[*read_count] = (void *)(long)(mfi->event_pipe_consumer);
(*read_count)++;
@@ -120,26 +128,26 @@ BOOL ios_events_get_fds(mfInfo* mfi, void ** read_fds, int * read_count, void **
}
// Sets up the event pipe
-BOOL ios_events_create_pipe(mfInfo* mfi)
+BOOL ios_events_create_pipe(mfInfo *mfi)
{
int pipe_fds[2];
-
+
if (pipe(pipe_fds) == -1)
{
NSLog(@"%s: pipe failed.", __func__);
return FALSE;
}
-
+
mfi->event_pipe_consumer = pipe_fds[0];
mfi->event_pipe_producer = pipe_fds[1];
return TRUE;
}
-void ios_events_free_pipe(mfInfo* mfi)
+void ios_events_free_pipe(mfInfo *mfi)
{
int consumer_fd = mfi->event_pipe_consumer, producer_fd = mfi->event_pipe_producer;
-
+
mfi->event_pipe_consumer = mfi->event_pipe_producer = -1;
close(producer_fd);
- close(consumer_fd);
+ close(consumer_fd);
}
diff --git a/client/iOS/FreeRDP/ios_freerdp_ui.h b/client/iOS/FreeRDP/ios_freerdp_ui.h
index 9dc5b135e..daa6c1f7d 100644
--- a/client/iOS/FreeRDP/ios_freerdp_ui.h
+++ b/client/iOS/FreeRDP/ios_freerdp_ui.h
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "ios_freerdp.h"
@@ -13,23 +14,13 @@ BOOL ios_ui_begin_paint(rdpContext* context);
BOOL ios_ui_end_paint(rdpContext* context);
BOOL ios_ui_resize_window(rdpContext* context);
-BOOL ios_ui_authenticate(freerdp* instance, char** username, char** password,
- char** domain);
-BOOL ios_ui_gw_authenticate(freerdp* instance, char** username, char** password,
- char** domain);
-DWORD ios_ui_verify_certificate(freerdp* instance,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* fingerprint,
- BOOL host_mismatch);
-DWORD ios_ui_verify_changed_certificate(freerdp* instance,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* new_fingerprint,
- const char* old_subject,
- const char* old_issuer,
- const char* old_fingerprint);
+BOOL ios_ui_authenticate(freerdp* instance, char** username, char** password, char** domain);
+BOOL ios_ui_gw_authenticate(freerdp* instance, char** username, char** password, char** domain);
+DWORD ios_ui_verify_certificate(freerdp* instance, const char* common_name, const char* subject,
+ const char* issuer, const char* fingerprint, BOOL host_mismatch);
+DWORD ios_ui_verify_changed_certificate(freerdp* instance, const char* common_name,
+ const char* subject, const char* issuer,
+ const char* new_fingerprint, const char* old_subject,
+ const char* old_issuer, const char* old_fingerprint);
void ios_allocate_display_buffer(mfInfo* mfi);
diff --git a/client/iOS/FreeRDP/ios_freerdp_ui.m b/client/iOS/FreeRDP/ios_freerdp_ui.m
index abf3e722a..b7cb3626a 100644
--- a/client/iOS/FreeRDP/ios_freerdp_ui.m
+++ b/client/iOS/FreeRDP/ios_freerdp_ui.m
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -17,22 +18,26 @@
#pragma mark -
#pragma mark Certificate authentication
-static void ios_resize_display_buffer(mfInfo* mfi);
-static BOOL ios_ui_authenticate_raw(freerdp* instance, char** username,
- char** password,
- char** domain, const char* title)
+static void ios_resize_display_buffer(mfInfo *mfi);
+static BOOL ios_ui_authenticate_raw(freerdp *instance, char **username, char **password,
+ char **domain, const char *title)
{
- mfInfo* mfi = MFI_FROM_INSTANCE(instance);
- NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- (*username) ? [NSString stringWithUTF8String:*username] : @"", @"username",
- (*password) ? [NSString stringWithUTF8String:*password] : @"", @"password",
- (*domain) ? [NSString stringWithUTF8String:*domain] : @"", @"domain",
- [NSString stringWithUTF8String:instance->settings->ServerHostname],
- @"hostname", // used for the auth prompt message; not changed
- nil];
+ mfInfo *mfi = MFI_FROM_INSTANCE(instance);
+ NSMutableDictionary *params = [NSMutableDictionary
+ dictionaryWithObjectsAndKeys:(*username) ? [NSString stringWithUTF8String:*username] : @"",
+ @"username",
+ (*password) ? [NSString stringWithUTF8String:*password] : @"",
+ @"password",
+ (*domain) ? [NSString stringWithUTF8String:*domain] : @"",
+ @"domain",
+ [NSString
+ stringWithUTF8String:instance->settings->ServerHostname],
+ @"hostname", // used for the auth prompt message; not changed
+ nil];
// request auth UI
- [mfi->session performSelectorOnMainThread:@selector(
- sessionRequestsAuthenticationWithParams:) withObject:params waitUntilDone:YES];
+ [mfi->session performSelectorOnMainThread:@selector(sessionRequestsAuthenticationWithParams:)
+ withObject:params
+ waitUntilDone:YES];
// wait for UI request to be completed
[[mfi->session uiRequestCompleted] lock];
[[mfi->session uiRequestCompleted] wait];
@@ -64,40 +69,35 @@ static BOOL ios_ui_authenticate_raw(freerdp* instance, char** username,
return TRUE;
}
-BOOL ios_ui_authenticate(freerdp* instance, char** username, char** password,
- char** domain)
+BOOL ios_ui_authenticate(freerdp *instance, char **username, char **password, char **domain)
{
return ios_ui_authenticate_raw(instance, username, password, domain, "");
}
-BOOL ios_ui_gw_authenticate(freerdp* instance, char** username, char** password,
- char** domain)
+BOOL ios_ui_gw_authenticate(freerdp *instance, char **username, char **password, char **domain)
{
return ios_ui_authenticate_raw(instance, username, password, domain, "gateway");
}
-
-DWORD ios_ui_verify_certificate(freerdp* instance,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* fingerprint,
- BOOL host_mismatch)
+DWORD ios_ui_verify_certificate(freerdp *instance, const char *common_name, const char *subject,
+ const char *issuer, const char *fingerprint, BOOL host_mismatch)
{
// check whether we accept all certificates
- if ([[NSUserDefaults standardUserDefaults] boolForKey:
- @"security.accept_certificates"] == YES)
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"security.accept_certificates"] == YES)
return 2;
- mfInfo* mfi = MFI_FROM_INSTANCE(instance);
- NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- (subject) ? [NSString stringWithUTF8String:subject] : @"", @"subject",
- (issuer) ? [NSString stringWithUTF8String:issuer] : @"", @"issuer",
- (fingerprint) ? [NSString stringWithUTF8String:subject] : @"", @"fingerprint",
- nil];
+ mfInfo *mfi = MFI_FROM_INSTANCE(instance);
+ NSMutableDictionary *params = [NSMutableDictionary
+ dictionaryWithObjectsAndKeys:(subject) ? [NSString stringWithUTF8String:subject] : @"",
+ @"subject",
+ (issuer) ? [NSString stringWithUTF8String:issuer] : @"",
+ @"issuer",
+ (fingerprint) ? [NSString stringWithUTF8String:subject] : @"",
+ @"fingerprint", nil];
// request certificate verification UI
- [mfi->session performSelectorOnMainThread:@selector(
- sessionVerifyCertificateWithParams:) withObject:params waitUntilDone:YES];
+ [mfi->session performSelectorOnMainThread:@selector(sessionVerifyCertificateWithParams:)
+ withObject:params
+ waitUntilDone:YES];
// wait for UI request to be completed
[[mfi->session uiRequestCompleted] lock];
[[mfi->session uiRequestCompleted] wait];
@@ -112,51 +112,45 @@ DWORD ios_ui_verify_certificate(freerdp* instance,
return 1;
}
-DWORD ios_ui_verify_changed_certificate(freerdp* instance,
- const char* common_name,
- const char* subject,
- const char* issuer,
- const char* new_fingerprint,
- const char* old_subject,
- const char* old_issuer,
- const char* old_fingerprint)
+DWORD ios_ui_verify_changed_certificate(freerdp *instance, const char *common_name,
+ const char *subject, const char *issuer,
+ const char *new_fingerprint, const char *old_subject,
+ const char *old_issuer, const char *old_fingerprint)
{
- return ios_ui_verify_certificate(instance, common_name, subject, issuer,
- new_fingerprint, FALSE);
+ return ios_ui_verify_certificate(instance, common_name, subject, issuer, new_fingerprint,
+ FALSE);
}
-
#pragma mark -
#pragma mark Graphics updates
-BOOL ios_ui_begin_paint(rdpContext* context)
+BOOL ios_ui_begin_paint(rdpContext *context)
{
- rdpGdi* gdi = context->gdi;
+ rdpGdi *gdi = context->gdi;
gdi->primary->hdc->hwnd->invalid->null = TRUE;
return TRUE;
}
-BOOL ios_ui_end_paint(rdpContext* context)
+BOOL ios_ui_end_paint(rdpContext *context)
{
- mfInfo* mfi = MFI_FROM_INSTANCE(context->instance);
- rdpGdi* gdi = context->gdi;
- CGRect dirty_rect = CGRectMake(gdi->primary->hdc->hwnd->invalid->x,
- gdi->primary->hdc->hwnd->invalid->y, gdi->primary->hdc->hwnd->invalid->w,
- gdi->primary->hdc->hwnd->invalid->h);
+ mfInfo *mfi = MFI_FROM_INSTANCE(context->instance);
+ rdpGdi *gdi = context->gdi;
+ CGRect dirty_rect =
+ CGRectMake(gdi->primary->hdc->hwnd->invalid->x, gdi->primary->hdc->hwnd->invalid->y,
+ gdi->primary->hdc->hwnd->invalid->w, gdi->primary->hdc->hwnd->invalid->h);
if (!gdi->primary->hdc->hwnd->invalid->null)
- [mfi->session performSelectorOnMainThread:@selector(
- setNeedsDisplayInRectAsValue:) withObject:[NSValue valueWithCGRect:dirty_rect]
- waitUntilDone:NO];
+ [mfi->session performSelectorOnMainThread:@selector(setNeedsDisplayInRectAsValue:)
+ withObject:[NSValue valueWithCGRect:dirty_rect]
+ waitUntilDone:NO];
return TRUE;
}
-
-BOOL ios_ui_resize_window(rdpContext* context)
+BOOL ios_ui_resize_window(rdpContext *context)
{
- rdpSettings* settings;
- rdpGdi* gdi;
+ rdpSettings *settings;
+ rdpGdi *gdi;
if (!context || !context->settings)
return FALSE;
@@ -171,37 +165,38 @@ BOOL ios_ui_resize_window(rdpContext* context)
return TRUE;
}
-
#pragma mark -
#pragma mark Exported
-static void ios_create_bitmap_context(mfInfo* mfi)
+static void ios_create_bitmap_context(mfInfo *mfi)
{
- [mfi->session performSelectorOnMainThread:@selector(
- sessionBitmapContextWillChange) withObject:nil waitUntilDone:YES];
- rdpGdi* gdi = mfi->instance->context->gdi;
+ [mfi->session performSelectorOnMainThread:@selector(sessionBitmapContextWillChange)
+ withObject:nil
+ waitUntilDone:YES];
+ rdpGdi *gdi = mfi->instance->context->gdi;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (GetBytesPerPixel(gdi->dstFormat) == 2)
- mfi->bitmap_context = CGBitmapContextCreate(gdi->primary_buffer, gdi->width,
- gdi->height, 5, gdi->stride, colorSpace,
- kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
+ mfi->bitmap_context = CGBitmapContextCreate(
+ gdi->primary_buffer, gdi->width, gdi->height, 5, gdi->stride, colorSpace,
+ kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
else
- mfi->bitmap_context = CGBitmapContextCreate(gdi->primary_buffer, gdi->width,
- gdi->height, 8, gdi->stride, colorSpace,
- kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
+ mfi->bitmap_context = CGBitmapContextCreate(
+ gdi->primary_buffer, gdi->width, gdi->height, 8, gdi->stride, colorSpace,
+ kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
CGColorSpaceRelease(colorSpace);
- [mfi->session performSelectorOnMainThread:@selector(
- sessionBitmapContextDidChange) withObject:nil waitUntilDone:YES];
+ [mfi->session performSelectorOnMainThread:@selector(sessionBitmapContextDidChange)
+ withObject:nil
+ waitUntilDone:YES];
}
-void ios_allocate_display_buffer(mfInfo* mfi)
+void ios_allocate_display_buffer(mfInfo *mfi)
{
ios_create_bitmap_context(mfi);
}
-void ios_resize_display_buffer(mfInfo* mfi)
+void ios_resize_display_buffer(mfInfo *mfi)
{
// Release the old context in a thread-safe manner
CGContextRef old_context = mfi->bitmap_context;
@@ -210,4 +205,3 @@ void ios_resize_display_buffer(mfInfo* mfi)
// Create the new context
ios_create_bitmap_context(mfi);
}
-
diff --git a/client/iOS/Misc/Reachability.h b/client/iOS/Misc/Reachability.h
index fa5f9b64a..077ce93ee 100644
--- a/client/iOS/Misc/Reachability.h
+++ b/client/iOS/Misc/Reachability.h
@@ -1,16 +1,16 @@
/*
-
+
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
-
+
Version: 2.2
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
constitutes acceptance of these terms. If you do not agree with these terms,
please do not use, install, modify or redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and subject
to these terms, Apple grants you a personal, non-exclusive license, under
Apple's copyrights in this original Apple software (the "Apple Software"), to
@@ -26,13 +26,13 @@
including but not limited to any patent rights that may be infringed by your
derivative works or by other works in which the Apple Software may be
incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -40,50 +40,48 @@
DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
+ Copyright (C) 2010 Apple Inc. All Rights Reserved.
+
+*/
#import
#import
#import
-typedef enum {
+typedef enum
+{
NotReachable = 0,
ReachableViaWiFi = 1,
ReachableViaWWAN = 2
} NetworkStatus;
#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
-@interface Reachability: NSObject
+@interface Reachability : NSObject
{
BOOL localWiFiRef;
SCNetworkReachabilityRef reachabilityRef;
}
-//reachabilityWithHostName- Use to check the reachability of a particular host name.
-+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
+// reachabilityWithHostName- Use to check the reachability of a particular host name.
++ (Reachability *)reachabilityWithHostName:(NSString *)hostName;
-//reachabilityWithAddress- Use to check the reachability of a particular IP address.
-+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
+// reachabilityWithAddress- Use to check the reachability of a particular IP address.
++ (Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
-//reachabilityForInternetConnection- checks whether the default route is available.
+// reachabilityForInternetConnection- checks whether the default route is available.
// Should be used by applications that do not connect to a particular host
-+ (Reachability*) reachabilityForInternetConnection;
++ (Reachability *)reachabilityForInternetConnection;
-//reachabilityForLocalWiFi- checks whether a local wifi connection is available.
-+ (Reachability*) reachabilityForLocalWiFi;
+// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
++ (Reachability *)reachabilityForLocalWiFi;
-//Start listening for reachability notifications on the current run loop
-- (BOOL) startNotifier;
-- (void) stopNotifier;
+// Start listening for reachability notifications on the current run loop
+- (BOOL)startNotifier;
+- (void)stopNotifier;
-- (NetworkStatus) currentReachabilityStatus;
-//WWAN may be available, but not active until a connection has been established.
-//WiFi may require a connection for VPN on Demand.
-- (BOOL) connectionRequired;
+- (NetworkStatus)currentReachabilityStatus;
+// WWAN may be available, but not active until a connection has been established.
+// WiFi may require a connection for VPN on Demand.
+- (BOOL)connectionRequired;
@end
-
-
diff --git a/client/iOS/Misc/Reachability.m b/client/iOS/Misc/Reachability.m
index 5ecdcf4e3..6a3eb2ecd 100644
--- a/client/iOS/Misc/Reachability.m
+++ b/client/iOS/Misc/Reachability.m
@@ -1,16 +1,16 @@
/*
-
+
File: Reachability.m
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
-
+
Version: 2.2
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
constitutes acceptance of these terms. If you do not agree with these terms,
please do not use, install, modify or redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and subject
to these terms, Apple grants you a personal, non-exclusive license, under
Apple's copyrights in this original Apple software (the "Apple Software"), to
@@ -26,13 +26,13 @@
including but not limited to any patent rights that may be infringed by your
derivative works or by other works in which the Apple Software may be
incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -40,9 +40,9 @@
DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
+
*/
#import
@@ -58,52 +58,53 @@
#define kShouldPrintReachabilityFlags 1
-static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
+static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char *comment)
{
#if kShouldPrintReachabilityFlags
-
- NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
-
- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
- comment
- );
+
+ NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
+ (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
+
+ (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
+ (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
+ (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
+ (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', comment);
#endif
}
-
@implementation Reachability
-static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
+static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags,
+ void *info)
{
- #pragma unused (target, flags)
+#pragma unused(target, flags)
NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
- NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
+ NSCAssert([(NSObject *)info isKindOfClass:[Reachability class]],
+ @"info was wrong class in ReachabilityCallback");
- //We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
+ // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
// in case someon uses the Reachablity object in a different thread.
- NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
-
- Reachability* noteObject = (Reachability*) info;
+ NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
+
+ Reachability *noteObject = (Reachability *)info;
// Post a notification to notify the client that the network reachability changed.
- [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];
-
+ [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
+ object:noteObject];
+
[myPool release];
}
-- (BOOL) startNotifier
+- (BOOL)startNotifier
{
BOOL retVal = NO;
- SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL};
- if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
+ SCNetworkReachabilityContext context = { 0, self, NULL, NULL, NULL };
+ if (SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
{
- if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
+ if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(),
+ kCFRunLoopDefaultMode))
{
retVal = YES;
}
@@ -111,32 +112,34 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
return retVal;
}
-- (void) stopNotifier
+- (void)stopNotifier
{
- if(reachabilityRef!= NULL)
+ if (reachabilityRef != NULL)
{
- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+ SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(),
+ kCFRunLoopDefaultMode);
}
}
-- (void) dealloc
+- (void)dealloc
{
[self stopNotifier];
- if(reachabilityRef!= NULL)
+ if (reachabilityRef != NULL)
{
CFRelease(reachabilityRef);
}
[super dealloc];
}
-+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
++ (Reachability *)reachabilityWithHostName:(NSString *)hostName;
{
- Reachability* retVal = NULL;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
- if(reachability!= NULL)
+ Reachability *retVal = NULL;
+ SCNetworkReachabilityRef reachability =
+ SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
+ if (reachability != NULL)
{
- retVal= [[[self alloc] init] autorelease];
- if(retVal!= NULL)
+ retVal = [[[self alloc] init] autorelease];
+ if (retVal != NULL)
{
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
@@ -145,14 +148,15 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
return retVal;
}
-+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
++ (Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
{
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
- Reachability* retVal = NULL;
- if(reachability!= NULL)
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(
+ kCFAllocatorDefault, (const struct sockaddr *)hostAddress);
+ Reachability *retVal = NULL;
+ if (reachability != NULL)
{
- retVal= [[[self alloc] init] autorelease];
- if(retVal!= NULL)
+ retVal = [[[self alloc] init] autorelease];
+ if (retVal != NULL)
{
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
@@ -161,16 +165,16 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
return retVal;
}
-+ (Reachability*) reachabilityForInternetConnection;
++ (Reachability *)reachabilityForInternetConnection;
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
- return [self reachabilityWithAddress: &zeroAddress];
+ return [self reachabilityWithAddress:&zeroAddress];
}
-+ (Reachability*) reachabilityForLocalWiFi;
++ (Reachability *)reachabilityForLocalWiFi;
{
struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
@@ -178,8 +182,8 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
localWifiAddress.sin_family = AF_INET;
// IN_LINKLOCALNETNUM is defined in as 169.254.0.0
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
- Reachability* retVal = [self reachabilityWithAddress: &localWifiAddress];
- if(retVal!= NULL)
+ Reachability *retVal = [self reachabilityWithAddress:&localWifiAddress];
+ if (retVal != NULL)
{
retVal->localWiFiRef = YES;
}
@@ -188,19 +192,20 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
#pragma mark Network Flag Handling
-- (NetworkStatus) localWiFiStatusForFlags: (SCNetworkReachabilityFlags) flags
+- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
{
PrintReachabilityFlags(flags, "localWiFiStatusForFlags");
BOOL retVal = NotReachable;
- if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
+ if ((flags & kSCNetworkReachabilityFlagsReachable) &&
+ (flags & kSCNetworkReachabilityFlagsIsDirect))
{
- retVal = ReachableViaWiFi;
+ retVal = ReachableViaWiFi;
}
return retVal;
}
-- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags
+- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
{
PrintReachabilityFlags(flags, "networkStatusForFlags");
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
@@ -210,28 +215,27 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
BOOL retVal = NotReachable;
-
+
if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
{
// if target host is reachable and no connection is required
// then we'll assume (for now) that your on Wi-Fi
retVal = ReachableViaWiFi;
}
-
-
- if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
- {
- // ... and the connection is on-demand (or on-traffic) if the
- // calling application is using the CFSocketStream or higher APIs
- if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
- {
- // ... and no [user] intervention is needed
- retVal = ReachableViaWiFi;
- }
+ if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
+ {
+ // ... and the connection is on-demand (or on-traffic) if the
+ // calling application is using the CFSocketStream or higher APIs
+
+ if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
+ {
+ // ... and no [user] intervention is needed
+ retVal = ReachableViaWiFi;
}
-
+ }
+
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
{
// ... but WWAN connections are OK if the calling application
@@ -241,7 +245,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
return retVal;
}
-- (BOOL) connectionRequired;
+- (BOOL)connectionRequired;
{
NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
SCNetworkReachabilityFlags flags;
@@ -252,20 +256,20 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
return NO;
}
-- (NetworkStatus) currentReachabilityStatus
+- (NetworkStatus)currentReachabilityStatus
{
NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
NetworkStatus retVal = NotReachable;
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
- if(localWiFiRef)
+ if (localWiFiRef)
{
- retVal = [self localWiFiStatusForFlags: flags];
+ retVal = [self localWiFiStatusForFlags:flags];
}
else
{
- retVal = [self networkStatusForFlags: flags];
+ retVal = [self networkStatusForFlags:flags];
}
}
return retVal;
diff --git a/client/iOS/Misc/SFHFKeychainUtils.h b/client/iOS/Misc/SFHFKeychainUtils.h
index 45bd642b3..b85925f9f 100644
--- a/client/iOS/Misc/SFHFKeychainUtils.h
+++ b/client/iOS/Misc/SFHFKeychainUtils.h
@@ -29,13 +29,20 @@
#import
-
-@interface SFHFKeychainUtils : NSObject {
-
+@interface SFHFKeychainUtils : NSObject
+{
}
-+ (NSString *) getPasswordForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error;
-+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServerName: (NSString *) serverName updateExisting: (BOOL) updateExisting error: (NSError **) error;
-+ (BOOL) deleteItemForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error;
++ (NSString *)getPasswordForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error;
++ (BOOL)storeUsername:(NSString *)username
+ andPassword:(NSString *)password
+ forServerName:(NSString *)serverName
+ updateExisting:(BOOL)updateExisting
+ error:(NSError **)error;
++ (BOOL)deleteItemForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error;
@end
\ No newline at end of file
diff --git a/client/iOS/Misc/SFHFKeychainUtils.m b/client/iOS/Misc/SFHFKeychainUtils.m
index dba1e4706..ebf8ad2ed 100644
--- a/client/iOS/Misc/SFHFKeychainUtils.m
+++ b/client/iOS/Misc/SFHFKeychainUtils.m
@@ -34,7 +34,9 @@ static NSString *SFHFKeychainUtilsErrorDomain = @"SFHFKeychainUtilsErrorDomain";
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && TARGET_IPHONE_SIMULATOR
@interface SFHFKeychainUtils (PrivateMethods)
-+ (SecKeychainItemRef) getKeychainItemReferenceForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error;
++ (SecKeychainItemRef)getKeychainItemReferenceForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error;
@end
#endif
@@ -42,391 +44,456 @@ static NSString *SFHFKeychainUtilsErrorDomain = @"SFHFKeychainUtilsErrorDomain";
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && TARGET_IPHONE_SIMULATOR
-+ (NSString *) getPasswordForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error {
- if (!username || !serviceName) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
++ (NSString *)getPasswordForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error
+{
+ if (!username || !serviceName)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
return nil;
}
-
- SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername: username andServerName: serverName error: error];
-
- if (*error || !item) {
+
+ SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername:username
+ andServerName:serverName
+ error:error];
+
+ if (*error || !item)
+ {
return nil;
}
-
+
// from Advanced Mac OS X Programming, ch. 16
- UInt32 length;
- char *password;
- SecKeychainAttribute attributes[8];
- SecKeychainAttributeList list;
-
- attributes[0].tag = kSecAccountItemAttr;
- attributes[1].tag = kSecDescriptionItemAttr;
- attributes[2].tag = kSecLabelItemAttr;
- attributes[3].tag = kSecModDateItemAttr;
-
- list.count = 4;
- list.attr = attributes;
-
- OSStatus status = SecKeychainItemCopyContent(item, NULL, &list, &length, (void **)&password);
-
- if (status != noErr) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+ UInt32 length;
+ char *password;
+ SecKeychainAttribute attributes[8];
+ SecKeychainAttributeList list;
+
+ attributes[0].tag = kSecAccountItemAttr;
+ attributes[1].tag = kSecDescriptionItemAttr;
+ attributes[2].tag = kSecLabelItemAttr;
+ attributes[3].tag = kSecModDateItemAttr;
+
+ list.count = 4;
+ list.attr = attributes;
+
+ OSStatus status = SecKeychainItemCopyContent(item, NULL, &list, &length, (void **)&password);
+
+ if (status != noErr)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:status userInfo:nil];
return nil;
- }
-
+ }
+
NSString *passwordString = nil;
-
- if (password != NULL) {
+
+ if (password != NULL)
+ {
char passwordBuffer[1024];
-
- if (length > 1023) {
+
+ if (length > 1023)
+ {
length = 1023;
}
strncpy(passwordBuffer, password, length);
-
+
passwordBuffer[length] = '\0';
passwordString = [NSString stringWithCString:passwordBuffer];
}
-
+
SecKeychainItemFreeContent(&list, password);
-
- CFRelease(item);
-
- return passwordString;
+
+ CFRelease(item);
+
+ return passwordString;
}
-+ (void) storeUsername: (NSString *) username andPassword: (NSString *) password forServerName: (NSString *) serverName updateExisting: (BOOL) updateExisting error: (NSError **) error {
- if (!username || !password || !serverName) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
++ (void)storeUsername:(NSString *)username
+ andPassword:(NSString *)password
+ forServerName:(NSString *)serverName
+ updateExisting:(BOOL)updateExisting
+ error:(NSError **)error
+{
+ if (!username || !password || !serverName)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
return;
}
-
+
OSStatus status = noErr;
-
- SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername: username andServerName: serverName error: error];
-
- if (*error && [*error code] != noErr) {
+
+ SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername:username
+ andServerName:serverName
+ error:error];
+
+ if (*error && [*error code] != noErr)
+ {
return;
}
-
+
*error = nil;
-
- if (item) {
- status = SecKeychainItemModifyAttributesAndData(item,
- NULL,
- strlen([password UTF8String]),
- [password UTF8String]);
-
+
+ if (item)
+ {
+ status = SecKeychainItemModifyAttributesAndData(item, NULL, strlen([password UTF8String]),
+ [password UTF8String]);
+
CFRelease(item);
}
- else {
- status = SecKeychainAddGenericPassword(NULL,
- strlen([serverName UTF8String]),
- [serverName UTF8String],
- strlen([username UTF8String]),
- [username UTF8String],
- strlen([password UTF8String]),
- [password UTF8String],
- NULL);
+ else
+ {
+ status = SecKeychainAddGenericPassword(
+ NULL, strlen([serverName UTF8String]), [serverName UTF8String],
+ strlen([username UTF8String]), [username UTF8String], strlen([password UTF8String]),
+ [password UTF8String], NULL);
}
-
- if (status != noErr) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+
+ if (status != noErr)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:status userInfo:nil];
}
}
-+ (void) deleteItemForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error {
- if (!username || !serverName) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: 2000 userInfo: nil];
++ (void)deleteItemForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error
+{
+ if (!username || !serverName)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:2000 userInfo:nil];
return;
}
-
+
*error = nil;
-
- SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername: username andServerName: serverName error: error];
-
- if (*error && [*error code] != noErr) {
+
+ SecKeychainItemRef item = [SFHFKeychainUtils getKeychainItemReferenceForUsername:username
+ andServerName:serverName
+ error:error];
+
+ if (*error && [*error code] != noErr)
+ {
return;
}
-
+
OSStatus status;
-
- if (item) {
+
+ if (item)
+ {
status = SecKeychainItemDelete(item);
-
+
CFRelease(item);
}
-
- if (status != noErr) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+
+ if (status != noErr)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:status userInfo:nil];
}
}
-+ (SecKeychainItemRef) getKeychainItemReferenceForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error {
- if (!username || !serverName) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
++ (SecKeychainItemRef)getKeychainItemReferenceForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error
+{
+ if (!username || !serverName)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
return nil;
}
-
+
*error = nil;
-
+
SecKeychainItemRef item;
-
- OSStatus status = SecKeychainFindGenericPassword(NULL,
- strlen([serverName UTF8String]),
- [serverName UTF8String],
- strlen([username UTF8String]),
- [username UTF8String],
- NULL,
- NULL,
- &item);
-
- if (status != noErr) {
- if (status != errSecItemNotFound) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+
+ OSStatus status = SecKeychainFindGenericPassword(
+ NULL, strlen([serverName UTF8String]), [serverName UTF8String],
+ strlen([username UTF8String]), [username UTF8String], NULL, NULL, &item);
+
+ if (status != noErr)
+ {
+ if (status != errSecItemNotFound)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain
+ code:status
+ userInfo:nil];
}
-
- return nil;
+
+ return nil;
}
-
+
return item;
}
#else
-+ (NSString *) getPasswordForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error {
- if (!username || !serverName) {
- if (error != nil) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
++ (NSString *)getPasswordForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error
+{
+ if (!username || !serverName)
+ {
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
}
return nil;
}
-
- if (error != nil) {
+
+ if (error != nil)
+ {
*error = nil;
}
-
- // Set up a query dictionary with the base query attributes: item type (generic), username, and service
-
- NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, kSecAttrAccount, kSecAttrService, nil] autorelease];
- NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, username, serverName, nil] autorelease];
-
- NSMutableDictionary *query = [[[NSMutableDictionary alloc] initWithObjects: objects forKeys: keys] autorelease];
-
- // First do a query for attributes, in case we already have a Keychain item with no password data set.
- // One likely way such an incorrect item could have come about is due to the previous (incorrect)
- // version of this code (which set the password as a generic attribute instead of password data).
-
+
+ // Set up a query dictionary with the base query attributes: item type (generic), username, and
+ // service
+
+ NSArray *keys = [[[NSArray alloc]
+ initWithObjects:(NSString *)kSecClass, kSecAttrAccount, kSecAttrService, nil] autorelease];
+ NSArray *objects = [[[NSArray alloc] initWithObjects:(NSString *)kSecClassGenericPassword,
+ username, serverName, nil] autorelease];
+
+ NSMutableDictionary *query = [[[NSMutableDictionary alloc] initWithObjects:objects
+ forKeys:keys] autorelease];
+
+ // First do a query for attributes, in case we already have a Keychain item with no password
+ // data set. One likely way such an incorrect item could have come about is due to the previous
+ // (incorrect) version of this code (which set the password as a generic attribute instead of
+ // password data).
+
NSDictionary *attributeResult = NULL;
NSMutableDictionary *attributeQuery = [query mutableCopy];
- [attributeQuery setObject: (id) kCFBooleanTrue forKey:(id) kSecReturnAttributes];
- OSStatus status = SecItemCopyMatching((CFDictionaryRef) attributeQuery, (CFTypeRef *) &attributeResult);
-
+ [attributeQuery setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnAttributes];
+ OSStatus status =
+ SecItemCopyMatching((CFDictionaryRef)attributeQuery, (CFTypeRef *)&attributeResult);
+
[attributeResult release];
[attributeQuery release];
-
- if (status != noErr) {
+
+ if (status != noErr)
+ {
// No existing item found--simply return nil for the password
- if (error != nil && status != errSecItemNotFound) {
- //Only return an error if a real exception happened--not simply for "not found."
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+ if (error != nil && status != errSecItemNotFound)
+ {
+ // Only return an error if a real exception happened--not simply for "not found."
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain
+ code:status
+ userInfo:nil];
}
-
+
return nil;
}
-
+
// We have an existing item, now query for the password data associated with it.
-
+
NSData *resultData = nil;
NSMutableDictionary *passwordQuery = [query mutableCopy];
- [passwordQuery setObject: (id) kCFBooleanTrue forKey: (id) kSecReturnData];
-
- status = SecItemCopyMatching((CFDictionaryRef) passwordQuery, (CFTypeRef *) &resultData);
-
+ [passwordQuery setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData];
+
+ status = SecItemCopyMatching((CFDictionaryRef)passwordQuery, (CFTypeRef *)&resultData);
+
[resultData autorelease];
[passwordQuery release];
-
- if (status != noErr) {
- if (status == errSecItemNotFound) {
- // We found attributes for the item previously, but no password now, so return a special error.
- // Users of this API will probably want to detect this error and prompt the user to
- // re-enter their credentials. When you attempt to store the re-entered credentials
+
+ if (status != noErr)
+ {
+ if (status == errSecItemNotFound)
+ {
+ // We found attributes for the item previously, but no password now, so return a special
+ // error. Users of this API will probably want to detect this error and prompt the user
+ // to re-enter their credentials. When you attempt to store the re-entered credentials
// using storeUsername:andPassword:forServiceName:updateExisting:error
// the old, incorrect entry will be deleted and a new one with a properly encrypted
// password will be added.
- if (error != nil) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -1999 userInfo: nil];
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain
+ code:-1999
+ userInfo:nil];
}
}
- else {
+ else
+ {
// Something else went wrong. Simply return the normal Keychain API error code.
- if (error != nil) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain
+ code:status
+ userInfo:nil];
}
}
-
+
return nil;
}
-
- NSString *password = nil;
-
- if (resultData) {
- password = [[NSString alloc] initWithData: resultData encoding: NSUTF8StringEncoding];
+
+ NSString *password = nil;
+
+ if (resultData)
+ {
+ password = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
}
- else {
- // There is an existing item, but we weren't able to get password data for it for some reason,
- // Possibly as a result of an item being incorrectly entered by the previous code.
+ else
+ {
+ // There is an existing item, but we weren't able to get password data for it for some
+ // reason, Possibly as a result of an item being incorrectly entered by the previous code.
// Set the -1999 error so the code above us can prompt the user again.
- if (error != nil) {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -1999 userInfo: nil];
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-1999 userInfo:nil];
}
}
-
+
return [password autorelease];
}
-+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServerName: (NSString *) serverName updateExisting: (BOOL) updateExisting error: (NSError **) error
-{
- if (!username || !password || !serverName)
- {
- if (error != nil)
- {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
++ (BOOL)storeUsername:(NSString *)username
+ andPassword:(NSString *)password
+ forServerName:(NSString *)serverName
+ updateExisting:(BOOL)updateExisting
+ error:(NSError **)error
+{
+ if (!username || !password || !serverName)
+ {
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
}
return NO;
}
-
+
// See if we already have a password entered for these credentials.
NSError *getError = nil;
- NSString *existingPassword = [SFHFKeychainUtils getPasswordForUsername: username andServerName: serverName error:&getError];
-
- if ([getError code] == -1999)
- {
- // There is an existing entry without a password properly stored (possibly as a result of the previous incorrect version of this code.
- // Delete the existing item before moving on entering a correct one.
-
+ NSString *existingPassword = [SFHFKeychainUtils getPasswordForUsername:username
+ andServerName:serverName
+ error:&getError];
+
+ if ([getError code] == -1999)
+ {
+ // There is an existing entry without a password properly stored (possibly as a result of
+ // the previous incorrect version of this code. Delete the existing item before moving on
+ // entering a correct one.
+
getError = nil;
-
- [self deleteItemForUsername: username andServerName: serverName error: &getError];
-
- if ([getError code] != noErr)
- {
- if (error != nil)
- {
+
+ [self deleteItemForUsername:username andServerName:serverName error:&getError];
+
+ if ([getError code] != noErr)
+ {
+ if (error != nil)
+ {
*error = getError;
}
return NO;
}
}
- else if ([getError code] != noErr)
- {
- if (error != nil)
- {
+ else if ([getError code] != noErr)
+ {
+ if (error != nil)
+ {
*error = getError;
}
return NO;
}
-
- if (error != nil)
- {
+
+ if (error != nil)
+ {
*error = nil;
}
-
+
OSStatus status = noErr;
-
- if (existingPassword)
- {
+
+ if (existingPassword)
+ {
// We have an existing, properly entered item with a password.
// Update the existing item.
-
- if (![existingPassword isEqualToString:password] && updateExisting)
- {
- //Only update if we're allowed to update existing. If not, simply do nothing.
-
- NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass,
- kSecAttrService,
- kSecAttrLabel,
- kSecAttrAccount,
- nil] autorelease];
-
- NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword,
- serverName,
- serverName,
- username,
- nil] autorelease];
-
- NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease];
-
- status = SecItemUpdate((CFDictionaryRef) query, (CFDictionaryRef) [NSDictionary dictionaryWithObject: [password dataUsingEncoding: NSUTF8StringEncoding] forKey: (NSString *) kSecValueData]);
+
+ if (![existingPassword isEqualToString:password] && updateExisting)
+ {
+ // Only update if we're allowed to update existing. If not, simply do nothing.
+
+ NSArray *keys =
+ [[[NSArray alloc] initWithObjects:(NSString *)kSecClass, kSecAttrService,
+ kSecAttrLabel, kSecAttrAccount, nil] autorelease];
+
+ NSArray *objects =
+ [[[NSArray alloc] initWithObjects:(NSString *)kSecClassGenericPassword, serverName,
+ serverName, username, nil] autorelease];
+
+ NSDictionary *query = [[[NSDictionary alloc] initWithObjects:objects
+ forKeys:keys] autorelease];
+
+ status = SecItemUpdate(
+ (CFDictionaryRef)query,
+ (CFDictionaryRef)[NSDictionary
+ dictionaryWithObject:[password dataUsingEncoding:NSUTF8StringEncoding]
+ forKey:(NSString *)kSecValueData]);
}
}
- else
- {
+ else
+ {
// No existing entry (or an existing, improperly entered, and therefore now
// deleted, entry). Create a new entry.
-
- NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass,
- kSecAttrService,
- kSecAttrLabel,
- kSecAttrAccount,
- kSecValueData,
- nil] autorelease];
-
- NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword,
- serverName,
- serverName,
- username,
- [password dataUsingEncoding: NSUTF8StringEncoding],
- nil] autorelease];
-
- NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease];
-
- status = SecItemAdd((CFDictionaryRef) query, NULL);
+
+ NSArray *keys =
+ [[[NSArray alloc] initWithObjects:(NSString *)kSecClass, kSecAttrService, kSecAttrLabel,
+ kSecAttrAccount, kSecValueData, nil] autorelease];
+
+ NSArray *objects = [[[NSArray alloc]
+ initWithObjects:(NSString *)kSecClassGenericPassword, serverName, serverName, username,
+ [password dataUsingEncoding:NSUTF8StringEncoding], nil] autorelease];
+
+ NSDictionary *query = [[[NSDictionary alloc] initWithObjects:objects
+ forKeys:keys] autorelease];
+
+ status = SecItemAdd((CFDictionaryRef)query, NULL);
}
-
- if (error != nil && status != noErr)
- {
+
+ if (error != nil && status != noErr)
+ {
// Something went wrong with adding the new item. Return the Keychain error code.
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
-
- return NO;
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:status userInfo:nil];
+
+ return NO;
}
-
- return YES;
+
+ return YES;
}
-+ (BOOL) deleteItemForUsername: (NSString *) username andServerName: (NSString *) serverName error: (NSError **) error
++ (BOOL)deleteItemForUsername:(NSString *)username
+ andServerName:(NSString *)serverName
+ error:(NSError **)error
{
- if (!username || !serverName)
- {
- if (error != nil)
- {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil];
+ if (!username || !serverName)
+ {
+ if (error != nil)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:-2000 userInfo:nil];
}
return NO;
}
-
- if (error != nil)
- {
+
+ if (error != nil)
+ {
*error = nil;
}
-
- NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, kSecAttrAccount, kSecAttrService, kSecReturnAttributes, nil] autorelease];
- NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, username, serverName, kCFBooleanTrue, nil] autorelease];
-
- NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease];
-
- OSStatus status = SecItemDelete((CFDictionaryRef) query);
-
- if (error != nil && status != noErr)
- {
- *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil];
-
- return NO;
+
+ NSArray *keys =
+ [[[NSArray alloc] initWithObjects:(NSString *)kSecClass, kSecAttrAccount, kSecAttrService,
+ kSecReturnAttributes, nil] autorelease];
+ NSArray *objects =
+ [[[NSArray alloc] initWithObjects:(NSString *)kSecClassGenericPassword, username,
+ serverName, kCFBooleanTrue, nil] autorelease];
+
+ NSDictionary *query = [[[NSDictionary alloc] initWithObjects:objects forKeys:keys] autorelease];
+
+ OSStatus status = SecItemDelete((CFDictionaryRef)query);
+
+ if (error != nil && status != noErr)
+ {
+ *error = [NSError errorWithDomain:SFHFKeychainUtilsErrorDomain code:status userInfo:nil];
+
+ return NO;
}
-
- return YES;
+
+ return YES;
}
#endif
diff --git a/client/iOS/Misc/TSXTypes.h b/client/iOS/Misc/TSXTypes.h
index 1b18c5ef7..51c52c1fa 100644
--- a/client/iOS/Misc/TSXTypes.h
+++ b/client/iOS/Misc/TSXTypes.h
@@ -1,10 +1,11 @@
/*
Basic type defines for TSX RDC
-
+
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#ifndef TSXRemoteDesktop_TSXTypes_h
@@ -15,33 +16,40 @@
// Represents the underlying state of a TWSession RDP connection.
typedef enum _TSXConnectionState
{
- TSXConnectionClosed = 0, // Session either hasn't begun connecting, or its connection has finished disconnecting.
- TSXConnectionConnecting = 1, // Session is in the process of establishing an RDP connection. A TCP or SSL connection might be established, but the RDP initialization sequence isn't finished.
- TSXConnectionConnected = 2, // Session has a full RDP connection established; though if the windows computer doesn't support NLA, a login screen might be shown in the session.
- TSXConnectionDisconnected = 3 // Session is disconnected at the RDP layer. TSX RDC might still be disposing of resources, however.
+ TSXConnectionClosed =
+ 0, // Session either hasn't begun connecting, or its connection has finished disconnecting.
+ TSXConnectionConnecting =
+ 1, // Session is in the process of establishing an RDP connection. A TCP or SSL connection
+ // might be established, but the RDP initialization sequence isn't finished.
+ TSXConnectionConnected =
+ 2, // Session has a full RDP connection established; though if the windows computer doesn't
+ // support NLA, a login screen might be shown in the session.
+ TSXConnectionDisconnected = 3 // Session is disconnected at the RDP layer. TSX RDC might still
+ // be disposing of resources, however.
} TSXConnectionState;
#pragma mark Session settings
-// Represents the type of screen resolution the user has selected. Most are dynamic sizes, meaning that the actual session dimensions are calculated when connecting.
+// Represents the type of screen resolution the user has selected. Most are dynamic sizes, meaning
+// that the actual session dimensions are calculated when connecting.
typedef enum _TSXScreenOptions
{
- TSXScreenOptionFixed = 0, // A static resolution, like 1024x768
- TSXScreenOptionFitScreen = 1, // Upon connection, fit the session to the entire screen size
- TSXScreenOptionCustom = 2, // Like fixed just specified by the user
+ TSXScreenOptionFixed = 0, // A static resolution, like 1024x768
+ TSXScreenOptionFitScreen = 1, // Upon connection, fit the session to the entire screen size
+ TSXScreenOptionCustom = 2, // Like fixed just specified by the user
} TSXScreenOptions;
typedef enum _TSXAudioPlaybackOptions
{
- TSXAudioPlaybackLocal = 0,
+ TSXAudioPlaybackLocal = 0,
TSXAudioPlaybackServer = 1,
TSXAudioPlaybackSilent = 2
} TSXAudioPlaybackOptions;
typedef enum _TSXProtocolSecurityOptions
{
- TSXProtocolSecurityAutomatic = 0,
- TSXProtocolSecurityRDP = 1,
+ TSXProtocolSecurityAutomatic = 0,
+ TSXProtocolSecurityRDP = 1,
TSXProtocolSecurityTLS = 2,
TSXProtocolSecurityNLA = 3
} TSXProtocolSecurityOptions;
diff --git a/client/iOS/Misc/Utils.h b/client/iOS/Misc/Utils.h
index 8f64e57fc..65dace60d 100644
--- a/client/iOS/Misc/Utils.h
+++ b/client/iOS/Misc/Utils.h
@@ -1,42 +1,43 @@
/*
Utility functions
-
+
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
#import
#import "TSXTypes.h"
-// helper macro to encode a table path into a tag value (used to identify controls in their delegate handlers)
+// helper macro to encode a table path into a tag value (used to identify controls in their delegate
+// handlers)
#define GET_TAG(section, row) ((((int)section) << 16) | ((int)(row)))
#define GET_TAG_FROM_PATH(path) ((((int)path.section) << 16) | ((int)(path.row)))
-
-BOOL ScanHostNameAndPort(NSString* address, NSString** host, unsigned short* port);
+BOOL ScanHostNameAndPort(NSString *address, NSString **host, unsigned short *port);
#pragma mark -
#pragma mark Screen Resolutions
-NSString* ScreenResolutionDescription(TSXScreenOptions type, int width, int height);
-BOOL ScanScreenResolution(NSString* description, int* width, int* height, TSXScreenOptions* type);
+NSString *ScreenResolutionDescription(TSXScreenOptions type, int width, int height);
+BOOL ScanScreenResolution(NSString *description, int *width, int *height, TSXScreenOptions *type);
-NSDictionary* SelectionForColorSetting(void);
-NSArray* ResolutionModes(void);
+NSDictionary *SelectionForColorSetting(void);
+NSArray *ResolutionModes(void);
#pragma mark Security Protocol
-NSString* ProtocolSecurityDescription(TSXProtocolSecurityOptions type);
-BOOL ScanProtocolSecurity(NSString* description, TSXProtocolSecurityOptions* type);
-NSDictionary* SelectionForSecuritySetting(void);
+NSString *ProtocolSecurityDescription(TSXProtocolSecurityOptions type);
+BOOL ScanProtocolSecurity(NSString *description, TSXProtocolSecurityOptions *type);
+NSDictionary *SelectionForSecuritySetting(void);
#pragma mark Bookmarks
@class BookmarkBase;
-NSMutableArray* FilterBookmarks(NSArray* bookmarks, NSArray* filter_words);
-NSMutableArray* FilterHistory(NSArray* history, NSString* filterStr);
+NSMutableArray *FilterBookmarks(NSArray *bookmarks, NSArray *filter_words);
+NSMutableArray *FilterHistory(NSArray *history, NSString *filterStr);
#pragma mark iPad/iPhone detection
@@ -44,7 +45,7 @@ BOOL IsPad(void);
BOOL IsPhone(void);
#pragma mark Version Info
-NSString* TSXAppFullVersion(void);
+NSString *TSXAppFullVersion(void);
#pragma mark Touch/Mouse handling
@@ -54,10 +55,10 @@ void SetSwapMouseButtonsFlag(BOOL swapped);
// set invert scrolling flag
void SetInvertScrollingFlag(BOOL invert);
-// return event value for left mouse button
+// return event value for left mouse button
int GetLeftMouseButtonClickEvent(BOOL down);
-// return event value for right mouse button
+// return event value for right mouse button
int GetRightMouseButtonClickEvent(BOOL down);
// return event value for mouse move event
@@ -74,7 +75,6 @@ CGFloat GetScrollGestureDelta(void);
void WakeUpWWAN(void);
#pragma mark System Info functions
-NSString* TSXGetPlatform(void);
+NSString *TSXGetPlatform(void);
BOOL TSXDeviceHasJailBreak(void);
-NSString* TSXGetPrimaryMACAddress(NSString *sep);
-
+NSString *TSXGetPrimaryMACAddress(NSString *sep);
diff --git a/client/iOS/Misc/Utils.m b/client/iOS/Misc/Utils.m
index af41e108a..9b70b5cfc 100644
--- a/client/iOS/Misc/Utils.m
+++ b/client/iOS/Misc/Utils.m
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "Utils.h"
@@ -21,8 +22,7 @@
#include
#include
-BOOL ScanHostNameAndPort(NSString* address, NSString** host,
- unsigned short* port)
+BOOL ScanHostNameAndPort(NSString *address, NSString **host, unsigned short *port)
{
*host = @"";
*port = 0;
@@ -30,8 +30,7 @@ BOOL ScanHostNameAndPort(NSString* address, NSString** host,
if (![address length])
return NO;
- NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"rdp://%@",
- address]];
+ NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"rdp://%@", address]];
if (!url || ![[url host] length])
return NO;
@@ -44,19 +43,18 @@ BOOL ScanHostNameAndPort(NSString* address, NSString** host,
#pragma mark -
#pragma mark Working with Screen Resolutions
-NSString* LocalizedFitScreen()
+NSString *LocalizedFitScreen()
{
- return NSLocalizedString(@"Automatic",
- @"Screen resolution selector: Automatic resolution (Full Screen on iPad, reasonable size on iPhone)");
+ return NSLocalizedString(@"Automatic", @"Screen resolution selector: Automatic resolution "
+ @"(Full Screen on iPad, reasonable size on iPhone)");
}
-NSString* LocalizedCustom()
+NSString *LocalizedCustom()
{
return NSLocalizedString(@"Custom", @"Screen resolution selector: Custom");
}
-BOOL ScanScreenResolution(NSString* description, int* width, int* height,
- TSXScreenOptions* type)
+BOOL ScanScreenResolution(NSString *description, int *width, int *height, TSXScreenOptions *type)
{
*height = 0;
*width = 0;
@@ -73,9 +71,9 @@ BOOL ScanScreenResolution(NSString* description, int* width, int* height,
return YES;
}
- NSArray* resolution_components = [description
- componentsSeparatedByCharactersInSet:[NSCharacterSet
- characterSetWithCharactersInString:@"x*×"]];
+ NSArray *resolution_components = [description
+ componentsSeparatedByCharactersInSet:[NSCharacterSet
+ characterSetWithCharactersInString:@"x*×"]];
if ([resolution_components count] != 2)
return NO;
@@ -85,8 +83,7 @@ BOOL ScanScreenResolution(NSString* description, int* width, int* height,
return YES;
}
-NSString* ScreenResolutionDescription(TSXScreenOptions type, int width,
- int height)
+NSString *ScreenResolutionDescription(TSXScreenOptions type, int width, int height)
{
if (type == TSXScreenOptionFitScreen)
return LocalizedFitScreen();
@@ -96,48 +93,47 @@ NSString* ScreenResolutionDescription(TSXScreenOptions type, int width,
return [NSString stringWithFormat:@"%dx%d", width, height];
}
-
-NSDictionary* SelectionForColorSetting()
+NSDictionary *SelectionForColorSetting()
{
- OrderedDictionary* dict = [OrderedDictionary dictionaryWithCapacity:3];
- [dict setValue:[NSNumber numberWithInt:8] forKey:NSLocalizedString(
- @"Palette Color (8 Bit)", @"8 bit color selection")];
- [dict setValue:[NSNumber numberWithInt:15] forKey:NSLocalizedString(
- @"High Color (15 Bit)", @"15 bit color selection")];
- [dict setValue:[NSNumber numberWithInt:16] forKey:NSLocalizedString(
- @"High Color (16 Bit)", @"16 bit color selection")];
- [dict setValue:[NSNumber numberWithInt:24] forKey:NSLocalizedString(
- @"True Color (24 Bit)", @"24 bit color selection")];
- [dict setValue:[NSNumber numberWithInt:32] forKey:NSLocalizedString(
- @"Highest Quality (32 Bit)", @"32 bit color selection")];
+ OrderedDictionary *dict = [OrderedDictionary dictionaryWithCapacity:3];
+ [dict setValue:[NSNumber numberWithInt:8]
+ forKey:NSLocalizedString(@"Palette Color (8 Bit)", @"8 bit color selection")];
+ [dict setValue:[NSNumber numberWithInt:15]
+ forKey:NSLocalizedString(@"High Color (15 Bit)", @"15 bit color selection")];
+ [dict setValue:[NSNumber numberWithInt:16]
+ forKey:NSLocalizedString(@"High Color (16 Bit)", @"16 bit color selection")];
+ [dict setValue:[NSNumber numberWithInt:24]
+ forKey:NSLocalizedString(@"True Color (24 Bit)", @"24 bit color selection")];
+ [dict setValue:[NSNumber numberWithInt:32]
+ forKey:NSLocalizedString(@"Highest Quality (32 Bit)", @"32 bit color selection")];
return dict;
}
-NSArray* ResolutionModes()
+NSArray *ResolutionModes()
{
- NSArray* array = [NSArray arrayWithObjects:ScreenResolutionDescription(
- TSXScreenOptionFitScreen, 0, 0),
- ScreenResolutionDescription(TSXScreenOptionFixed, 640, 480),
- ScreenResolutionDescription(TSXScreenOptionFixed, 800, 600),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1024, 768),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1280, 1024),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1440, 900),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1440, 1050),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1600, 1200),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1920, 1080),
- ScreenResolutionDescription(TSXScreenOptionFixed, 1920, 1200),
- ScreenResolutionDescription(TSXScreenOptionCustom, 0, 0), nil];
+ NSArray *array =
+ [NSArray arrayWithObjects:ScreenResolutionDescription(TSXScreenOptionFitScreen, 0, 0),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 640, 480),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 800, 600),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1024, 768),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1280, 1024),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1440, 900),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1440, 1050),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1600, 1200),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1920, 1080),
+ ScreenResolutionDescription(TSXScreenOptionFixed, 1920, 1200),
+ ScreenResolutionDescription(TSXScreenOptionCustom, 0, 0), nil];
return array;
}
#pragma mark Working with Security Protocols
-NSString* LocalizedAutomaticSecurity()
+NSString *LocalizedAutomaticSecurity()
{
return NSLocalizedString(@"Automatic", @"Automatic protocl security selection");
}
-NSString* ProtocolSecurityDescription(TSXProtocolSecurityOptions type)
+NSString *ProtocolSecurityDescription(TSXProtocolSecurityOptions type)
{
if (type == TSXProtocolSecurityNLA)
return @"NLA";
@@ -149,8 +145,7 @@ NSString* ProtocolSecurityDescription(TSXProtocolSecurityOptions type)
return LocalizedAutomaticSecurity();
}
-BOOL ScanProtocolSecurity(NSString* description,
- TSXProtocolSecurityOptions* type)
+BOOL ScanProtocolSecurity(NSString *description, TSXProtocolSecurityOptions *type)
{
*type = TSXProtocolSecurityRDP;
@@ -178,69 +173,69 @@ BOOL ScanProtocolSecurity(NSString* description,
return NO;
}
-NSDictionary* SelectionForSecuritySetting()
+NSDictionary *SelectionForSecuritySetting()
{
- OrderedDictionary* dict = [OrderedDictionary dictionaryWithCapacity:4];
- [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityAutomatic] forKey:
- ProtocolSecurityDescription(TSXProtocolSecurityAutomatic)];
- [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityRDP] forKey:
- ProtocolSecurityDescription(TSXProtocolSecurityRDP)];
- [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityTLS] forKey:
- ProtocolSecurityDescription(TSXProtocolSecurityTLS)];
- [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityNLA] forKey:
- ProtocolSecurityDescription(TSXProtocolSecurityNLA)];
+ OrderedDictionary *dict = [OrderedDictionary dictionaryWithCapacity:4];
+ [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityAutomatic]
+ forKey:ProtocolSecurityDescription(TSXProtocolSecurityAutomatic)];
+ [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityRDP]
+ forKey:ProtocolSecurityDescription(TSXProtocolSecurityRDP)];
+ [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityTLS]
+ forKey:ProtocolSecurityDescription(TSXProtocolSecurityTLS)];
+ [dict setValue:[NSNumber numberWithInt:TSXProtocolSecurityNLA]
+ forKey:ProtocolSecurityDescription(TSXProtocolSecurityNLA)];
return dict;
}
-
#pragma mark -
#pragma mark Bookmarks
#import "Bookmark.h"
-NSMutableArray* FilterBookmarks(NSArray* bookmarks, NSArray* filter_words)
+NSMutableArray *FilterBookmarks(NSArray *bookmarks, NSArray *filter_words)
{
- NSMutableArray* matching_items = [NSMutableArray array];
- NSArray* searched_keys = [NSArray arrayWithObjects:@"label", @"params.hostname",
- @"params.username", @"params.domain", nil];
+ NSMutableArray *matching_items = [NSMutableArray array];
+ NSArray *searched_keys = [NSArray
+ arrayWithObjects:@"label", @"params.hostname", @"params.username", @"params.domain", nil];
- for (ComputerBookmark * cur_bookmark in bookmarks)
+ for (ComputerBookmark *cur_bookmark in bookmarks)
{
double match_score = 0.0;
for (int i = 0; i < [searched_keys count]; i++)
{
- NSString* val = [cur_bookmark valueForKeyPath:[searched_keys objectAtIndex:i]];
+ NSString *val = [cur_bookmark valueForKeyPath:[searched_keys objectAtIndex:i]];
if (![val isKindOfClass:[NSString class]] || ![val length])
continue;
- for (NSString * word in filter_words)
- if ([val rangeOfString:word options:(NSCaseInsensitiveSearch |
- NSWidthInsensitiveSearch)].location != NSNotFound)
+ for (NSString *word in filter_words)
+ if ([val rangeOfString:word
+ options:(NSCaseInsensitiveSearch | NSWidthInsensitiveSearch)]
+ .location != NSNotFound)
match_score += (1.0 / [filter_words count]) * pow(2, [searched_keys count] - i);
}
if (match_score > 0.001)
- [matching_items addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- cur_bookmark, @"bookmark",
- [NSNumber numberWithFloat:match_score], @"score",
- nil]];
+ [matching_items
+ addObject:[NSDictionary
+ dictionaryWithObjectsAndKeys:cur_bookmark, @"bookmark",
+ [NSNumber numberWithFloat:match_score],
+ @"score", nil]];
}
- [matching_items sortUsingComparator:^NSComparisonResult(NSDictionary * obj1,
- NSDictionary * obj2)
- {
- return [[obj2 objectForKey:@"score"] compare:[obj1 objectForKey:@"score"]];
- }];
+ [matching_items
+ sortUsingComparator:^NSComparisonResult(NSDictionary *obj1, NSDictionary *obj2) {
+ return [[obj2 objectForKey:@"score"] compare:[obj1 objectForKey:@"score"]];
+ }];
return matching_items;
}
-NSMutableArray* FilterHistory(NSArray* history, NSString* filterStr)
+NSMutableArray *FilterHistory(NSArray *history, NSString *filterStr)
{
- NSMutableArray* result = [NSMutableArray array];
+ NSMutableArray *result = [NSMutableArray array];
- for (NSString * item in history)
+ for (NSString *item in history)
{
if ([item rangeOfString:filterStr].location != NSNotFound)
[result addObject:item];
@@ -250,7 +245,7 @@ NSMutableArray* FilterHistory(NSArray* history, NSString* filterStr)
}
#pragma mark Version Info
-NSString* TSXAppFullVersion()
+NSString *TSXAppFullVersion()
{
return [NSString stringWithUTF8String:GIT_REVISION];
}
@@ -334,20 +329,18 @@ CGFloat GetScrollGestureDelta()
// this hack activates the iphone's WWAN interface in case it is offline
void WakeUpWWAN()
{
- NSURL* url = [[[NSURL alloc] initWithString:
- @"http://www.nonexistingdummyurl.com"] autorelease];
- //NSData * data =
- [NSData dataWithContentsOfURL:
- url]; // we don't need data but assigning one causes a "data not used" compiler warning
+ NSURL *url = [[[NSURL alloc] initWithString:@"http://www.nonexistingdummyurl.com"] autorelease];
+ // NSData * data =
+ [NSData dataWithContentsOfURL:url]; // we don't need data but assigning one causes a "data not
+ // used" compiler warning
}
-
#pragma mark System Info functions
-NSString* TSXGetPrimaryMACAddress(NSString* sep)
+NSString *TSXGetPrimaryMACAddress(NSString *sep)
{
- NSString* macaddress = @"";
- struct ifaddrs* addrs;
+ NSString *macaddress = @"";
+ struct ifaddrs *addrs;
if (getifaddrs(&addrs) < 0)
{
@@ -355,22 +348,24 @@ NSString* TSXGetPrimaryMACAddress(NSString* sep)
return macaddress;
}
- for (struct ifaddrs* cursor = addrs; cursor != NULL; cursor = cursor->ifa_next)
+ for (struct ifaddrs *cursor = addrs; cursor != NULL; cursor = cursor->ifa_next)
{
if (strcmp(cursor->ifa_name, "en0"))
continue;
- if ((cursor->ifa_addr->sa_family == AF_LINK)
- && (((struct sockaddr_dl*) cursor->ifa_addr)->sdl_type == 0x6 /*IFT_ETHER*/))
+ if ((cursor->ifa_addr->sa_family == AF_LINK) &&
+ (((struct sockaddr_dl *)cursor->ifa_addr)->sdl_type == 0x6 /*IFT_ETHER*/))
{
- struct sockaddr_dl* dlAddr = (struct sockaddr_dl*) cursor->ifa_addr;
+ struct sockaddr_dl *dlAddr = (struct sockaddr_dl *)cursor->ifa_addr;
if (dlAddr->sdl_alen != 6)
continue;
- unsigned char* base = (unsigned char*) &dlAddr->sdl_data[dlAddr->sdl_nlen];
- macaddress = [NSString hexStringFromData:base ofSize:6 withSeparator:sep
- afterNthChar:1];
+ unsigned char *base = (unsigned char *)&dlAddr->sdl_data[dlAddr->sdl_nlen];
+ macaddress = [NSString hexStringFromData:base
+ ofSize:6
+ withSeparator:sep
+ afterNthChar:1];
break;
}
}
@@ -381,8 +376,7 @@ NSString* TSXGetPrimaryMACAddress(NSString* sep)
BOOL TSXDeviceHasJailBreak()
{
- if ([[NSFileManager defaultManager] fileExistsAtPath:
- @"/Applications/Cydia.app/"])
+ if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app/"])
return YES;
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt/"])
@@ -391,15 +385,13 @@ BOOL TSXDeviceHasJailBreak()
return NO;
}
-NSString* TSXGetPlatform()
+NSString *TSXGetPlatform()
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
- char* machine = malloc(size);
+ char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
- NSString* platform = [NSString stringWithCString:machine encoding:
- NSASCIIStringEncoding];
+ NSString *platform = [NSString stringWithCString:machine encoding:NSASCIIStringEncoding];
free(machine);
return platform;
}
-
diff --git a/client/iOS/Models/Bookmark.h b/client/iOS/Models/Bookmark.h
index 1b7c542be..11f0fb2ce 100644
--- a/client/iOS/Models/Bookmark.h
+++ b/client/iOS/Models/Bookmark.h
@@ -1,32 +1,33 @@
/*
Bookmark model abstraction
-
- Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Authors: Dorian Johnson
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import
#import
#import "ConnectionParams.h"
-@interface ComputerBookmark : NSObject {
-@protected
- ComputerBookmark* _parent;
- NSString* _uuid, * _label;
- UIImage* _image;
- ConnectionParams* _connection_params;
- BOOL _connected_via_wlan;
+@interface ComputerBookmark : NSObject
+{
+ @protected
+ ComputerBookmark *_parent;
+ NSString *_uuid, *_label;
+ UIImage *_image;
+ ConnectionParams *_connection_params;
+ BOOL _connected_via_wlan;
}
-@property (nonatomic,assign) ComputerBookmark* parent;
-@property (nonatomic,readonly) NSString* uuid;
-@property (nonatomic,copy) NSString* label;
-@property (nonatomic,retain) UIImage* image;
-@property (readonly, nonatomic) ConnectionParams* params;
-@property (nonatomic, assign) BOOL conntectedViaWLAN;
+@property(nonatomic, assign) ComputerBookmark *parent;
+@property(nonatomic, readonly) NSString *uuid;
+@property(nonatomic, copy) NSString *label;
+@property(nonatomic, retain) UIImage *image;
+@property(readonly, nonatomic) ConnectionParams *params;
+@property(nonatomic, assign) BOOL conntectedViaWLAN;
// Creates a copy of this object, with a new UUID
- (id)copy;
@@ -38,11 +39,10 @@
- (BOOL)isRenamable;
- (BOOL)hasImmutableHost;
-- (id)initWithConnectionParameters:(ConnectionParams*)params;
+- (id)initWithConnectionParameters:(ConnectionParams *)params;
- (id)initWithBaseDefaultParameters;
// A copy of @params, with _bookmark_uuid set.
-- (ConnectionParams*)copyMarkedParams;
+- (ConnectionParams *)copyMarkedParams;
@end
-
diff --git a/client/iOS/Models/Bookmark.m b/client/iOS/Models/Bookmark.m
index dc3038032..b496c614b 100644
--- a/client/iOS/Models/Bookmark.m
+++ b/client/iOS/Models/Bookmark.m
@@ -1,12 +1,12 @@
/*
Bookmark model abstraction
-
- Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import "Bookmark.h"
#import "TSXAdditions.h"
@@ -21,67 +21,66 @@
@implementation ComputerBookmark
-@synthesize parent=_parent, uuid=_uuid, label=_label, image=_image;
-@synthesize params=_connection_params, conntectedViaWLAN = _connected_via_wlan;
-
+@synthesize parent = _parent, uuid = _uuid, label = _label, image = _image;
+@synthesize params = _connection_params, conntectedViaWLAN = _connected_via_wlan;
- (id)init
{
- if (!(self = [super init]))
+ if (!(self = [super init]))
return nil;
-
+
_uuid = [[NSString stringWithUUID] retain];
_label = @"";
- _connected_via_wlan = NO;
- return self;
-}
-
-// Designated initializer.
-- (id)initWithConnectionParameters:(ConnectionParams*)params
-{
- if (!(self = [self init]))
- return nil;
-
- _connection_params = [params copy];
- _connected_via_wlan = NO;
+ _connected_via_wlan = NO;
return self;
}
+// Designated initializer.
+- (id)initWithConnectionParameters:(ConnectionParams *)params
+{
+ if (!(self = [self init]))
+ return nil;
+
+ _connection_params = [params copy];
+ _connected_via_wlan = NO;
+ return self;
+}
- (id)initWithCoder:(NSCoder *)decoder
{
if (!(self = [self init]))
return nil;
-
+
if (![decoder allowsKeyedCoding])
[NSException raise:NSInvalidArgumentException format:@"coder must support keyed archiving"];
-
+
if ([decoder containsValueForKey:@"uuid"])
{
[_uuid release];
- _uuid = [[decoder decodeObjectForKey:@"uuid"] retain];
+ _uuid = [[decoder decodeObjectForKey:@"uuid"] retain];
}
-
+
if ([decoder containsValueForKey:@"label"])
[self setLabel:[decoder decodeObjectForKey:@"label"]];
-
+
if ([decoder containsValueForKey:@"connectionParams"])
{
[_connection_params release];
_connection_params = [[decoder decodeObjectForKey:@"connectionParams"] retain];
}
-
+
return self;
}
- (id)initWithBaseDefaultParameters
{
- return [self initWithConnectionParameters:[[[ConnectionParams alloc] initWithBaseDefaultParameters] autorelease]];
+ return [self initWithConnectionParameters:[[[ConnectionParams alloc]
+ initWithBaseDefaultParameters] autorelease]];
}
- (id)copy
{
- ComputerBookmark* copy = [[[self class] alloc] init];
+ ComputerBookmark *copy = [[[self class] alloc] init];
[copy setLabel:[self label]];
copy->_connection_params = [_connection_params copy];
return copy;
@@ -89,33 +88,36 @@
- (id)copyWithUUID
{
- ComputerBookmark* copy = [self copy];
- copy->_uuid = [[self uuid] copy];
- return copy;
+ ComputerBookmark *copy = [self copy];
+ copy->_uuid = [[self uuid] copy];
+ return copy;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
if (![coder allowsKeyedCoding])
[NSException raise:NSInvalidArgumentException format:@"coder must support keyed archiving"];
-
+
[coder encodeObject:_uuid forKey:@"uuid"];
[coder encodeObject:_label forKey:@"label"];
[coder encodeObject:_connection_params forKey:@"connectionParams"];
}
- (void)dealloc
-{
+{
_parent = nil;
- [_label release]; _label = nil;
- [_uuid release]; _uuid = nil;
- [_connection_params release]; _connection_params = nil;
+ [_label release];
+ _label = nil;
+ [_uuid release];
+ _uuid = nil;
+ [_connection_params release];
+ _connection_params = nil;
[super dealloc];
}
-- (UIImage*)image
+- (UIImage *)image
{
- return nil;
+ return nil;
}
- (BOOL)isEqual:(id)object
@@ -123,29 +125,40 @@
return [object respondsToSelector:@selector(uuid)] && [[object uuid] isEqual:_uuid];
}
-- (NSString*)description
+- (NSString *)description
{
- return ([self label] != nil) ? [self label] : _uuid;
+ return ([self label] != nil) ? [self label] : _uuid;
}
- (BOOL)validateValue:(id *)val forKey:(NSString *)key error:(NSError **)error
{
- NSString* string_value = *val;
-
+ NSString *string_value = *val;
+
if ([key isEqualToString:@"label"])
{
- if (![[string_value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length])
+ if (![[string_value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ length])
{
if (error)
- *error = [NSError errorWithDomain:@"" code:NSKeyValueValidationError userInfo:
- [NSDictionary dictionaryWithObjectsAndKeys:
- NSLocalizedString(@"Connection labels cannot be blank", @"Bookmark data validation: label blank title."), NSLocalizedDescriptionKey,
- NSLocalizedString(@"Please enter the short description of this Connection that will appear in the Connection list.", @"Bookmark data validation: label blank message."), NSLocalizedRecoverySuggestionErrorKey,
- nil]];
+ *error = [NSError
+ errorWithDomain:@""
+ code:NSKeyValueValidationError
+ userInfo:
+ [NSDictionary
+ dictionaryWithObjectsAndKeys:
+ NSLocalizedString(
+ @"Connection labels cannot be blank",
+ @"Bookmark data validation: label blank title."),
+ NSLocalizedDescriptionKey,
+ NSLocalizedString(
+ @"Please enter the short description of this Connection "
+ @"that will appear in the Connection list.",
+ @"Bookmark data validation: label blank message."),
+ NSLocalizedRecoverySuggestionErrorKey, nil]];
return NO;
}
}
-
+
return YES;
}
@@ -155,11 +168,22 @@
return [super validateValue:val forKeyPath:keyPath error:error];
}
-- (BOOL)isDeletable { return YES; }
-- (BOOL)isMovable { return YES; }
-- (BOOL)isRenamable { return YES; }
-- (BOOL)hasImmutableHost { return NO; }
-
+- (BOOL)isDeletable
+{
+ return YES;
+}
+- (BOOL)isMovable
+{
+ return YES;
+}
+- (BOOL)isRenamable
+{
+ return YES;
+}
+- (BOOL)hasImmutableHost
+{
+ return NO;
+}
#pragma mark Custom KVC
@@ -173,7 +197,7 @@
{
[_connection_params willChangeValueForKey:@"resolution"];
[[self params] setInt:type forKey:@"screen_resolution_type"];
-
+
if (type == TSXScreenOptionFixed)
{
[[self params] setInt:width forKey:@"width"];
@@ -182,12 +206,13 @@
[_connection_params didChangeValueForKey:@"resolution"];
}
else
- [NSException raise:NSInvalidArgumentException format:@"%s got invalid screen resolution '%@'", __func__, value];
+ [NSException raise:NSInvalidArgumentException
+ format:@"%s got invalid screen resolution '%@'", __func__, value];
}
else
{
[self willChangeValueForKeyPath:keyPath];
- [super setValue:value forKeyPath:keyPath];
+ [super setValue:value forKeyPath:keyPath];
[self didChangeValueForKeyPath:keyPath];
}
}
@@ -195,63 +220,93 @@
- (id)valueForKeyPath:(NSString *)keyPath
{
if ([keyPath isEqualToString:@"params.resolution"])
- return ScreenResolutionDescription([[self params] intForKey:@"screen_resolution_type"], [[self params] intForKey:@"width"], [[self params] intForKey:@"height"]);
-
+ return ScreenResolutionDescription([[self params] intForKey:@"screen_resolution_type"],
+ [[self params] intForKey:@"width"],
+ [[self params] intForKey:@"height"]);
+
return [super valueForKeyPath:keyPath];
}
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
+- (void)observeValueForKeyPath:(NSString *)keyPath
+ ofObject:(id)object
+ change:(NSDictionary *)change
+ context:(void *)context
+{
if ([[change objectForKey:NSKeyValueChangeNotificationIsPriorKey] boolValue])
[self willChangeValueForKeyPath:keyPath];
else
- [self didChangeValueForKeyPath:keyPath];
+ [self didChangeValueForKeyPath:keyPath];
}
-- (NSDictionary*)targetForChangeNotificationForKeyPath:(NSString*)keyPath
+- (NSDictionary *)targetForChangeNotificationForKeyPath:(NSString *)keyPath
{
- NSString* changed_key = keyPath;
- NSObject* changed_object = self;
-
+ NSString *changed_key = keyPath;
+ NSObject *changed_object = self;
+
if ([keyPath rangeOfString:@"params."].location == 0)
{
changed_key = [keyPath substringFromIndex:[@"params." length]];
changed_object = _connection_params;
}
-
- return [NSDictionary dictionaryWithObjectsAndKeys:changed_key, @"key", changed_object, @"object", nil];
+
+ return [NSDictionary
+ dictionaryWithObjectsAndKeys:changed_key, @"key", changed_object, @"object", nil];
}
- (void)willChangeValueForKeyPath:(NSString *)keyPath
{
- NSDictionary* target = [self targetForChangeNotificationForKeyPath:keyPath];
+ NSDictionary *target = [self targetForChangeNotificationForKeyPath:keyPath];
[[target objectForKey:@"object"] willChangeValueForKey:[target objectForKey:@"key"]];
}
- (void)didChangeValueForKeyPath:(NSString *)keyPath
{
- NSDictionary* target = [self targetForChangeNotificationForKeyPath:keyPath];
+ NSDictionary *target = [self targetForChangeNotificationForKeyPath:keyPath];
[[target objectForKey:@"object"] didChangeValueForKey:[target objectForKey:@"key"]];
}
-- (ConnectionParams*)copyMarkedParams
+- (ConnectionParams *)copyMarkedParams
{
- ConnectionParams* param_copy = [[self params] copy];
+ ConnectionParams *param_copy = [[self params] copy];
[param_copy setValue:[self uuid] forKey:@"_bookmark_uuid"];
return param_copy;
}
-
#pragma mark No children
-- (NSUInteger)numberOfChildren { return 0; }
-- (NSUInteger)numberOfDescendants { return 1; }
-- (BookmarkBase *)childAtIndex:(NSUInteger)index { return nil; }
-- (NSUInteger)indexOfChild:(BookmarkBase *)child { return 0; }
-- (void)removeChild:(BookmarkBase *)child { }
-- (void)addChild:(BookmarkBase *)child { }
-- (void)addChild:(BookmarkBase *)child afterExistingChild:(BookmarkBase *)existingChild { }
-- (void)addChild:(BookmarkBase *)child atIndex:(NSInteger)index { }
-- (BOOL)hasDescendant:(BookmarkBase *)needle { return NO; }
-- (BOOL)canContainChildren { return NO; }
+- (NSUInteger)numberOfChildren
+{
+ return 0;
+}
+- (NSUInteger)numberOfDescendants
+{
+ return 1;
+}
+- (BookmarkBase *)childAtIndex:(NSUInteger)index
+{
+ return nil;
+}
+- (NSUInteger)indexOfChild:(BookmarkBase *)child
+{
+ return 0;
+}
+- (void)removeChild:(BookmarkBase *)child
+{
+}
+- (void)addChild:(BookmarkBase *)child
+{
+}
+- (void)addChild:(BookmarkBase *)child afterExistingChild:(BookmarkBase *)existingChild
+{
+}
+- (void)addChild:(BookmarkBase *)child atIndex:(NSInteger)index
+{
+}
+- (BOOL)hasDescendant:(BookmarkBase *)needle
+{
+ return NO;
+}
+- (BOOL)canContainChildren
+{
+ return NO;
+}
@end
-
diff --git a/client/iOS/Models/ConnectionParams.h b/client/iOS/Models/ConnectionParams.h
index d6dc24966..e0e8fa405 100644
--- a/client/iOS/Models/ConnectionParams.h
+++ b/client/iOS/Models/ConnectionParams.h
@@ -1,47 +1,46 @@
/*
Connection Parameters abstraction
-
- Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import
@interface ConnectionParams : NSObject
{
-@private
- NSMutableDictionary* _connection_params;
+ @private
+ NSMutableDictionary *_connection_params;
}
// Designated initializer.
-- (id)initWithDictionary:(NSDictionary*)dict;
+- (id)initWithDictionary:(NSDictionary *)dict;
- (id)initWithBaseDefaultParameters;
// Getting/setting values
-- (NSArray*)allKeys;
+- (NSArray *)allKeys;
- (void)setValue:(id)value forKey:(NSString *)key;
-- (id)valueForKey:(NSString*)key;
-- (BOOL)hasValueForKey:(NSString*)key;
-- (void)setInt:(int)integer forKey:(NSString*)key;
-- (int)intForKey:(NSString*)key;
-- (void)setBool:(BOOL)v forKey:(NSString*)key;
-- (BOOL)boolForKey:(NSString*)key;
-- (const char*)UTF8StringForKey:(NSString*)key;
-- (NSString*)StringForKey:(NSString*)key;
+- (id)valueForKey:(NSString *)key;
+- (BOOL)hasValueForKey:(NSString *)key;
+- (void)setInt:(int)integer forKey:(NSString *)key;
+- (int)intForKey:(NSString *)key;
+- (void)setBool:(BOOL)v forKey:(NSString *)key;
+- (BOOL)boolForKey:(NSString *)key;
+- (const char *)UTF8StringForKey:(NSString *)key;
+- (NSString *)StringForKey:(NSString *)key;
-- (BOOL)hasValueForKeyPath:(NSString*)key;
-- (void)setInt:(int)integer forKeyPath:(NSString*)key;
-- (int)intForKeyPath:(NSString*)key;
-- (void)setBool:(BOOL)v forKeyPath:(NSString*)key;
-- (BOOL)boolForKeyPath:(NSString*)key;
-- (const char*)UTF8StringForKeyPath:(NSString*)key;
-- (NSString*)StringForKeyPath:(NSString*)key;
+- (BOOL)hasValueForKeyPath:(NSString *)key;
+- (void)setInt:(int)integer forKeyPath:(NSString *)key;
+- (int)intForKeyPath:(NSString *)key;
+- (void)setBool:(BOOL)v forKeyPath:(NSString *)key;
+- (BOOL)boolForKeyPath:(NSString *)key;
+- (const char *)UTF8StringForKeyPath:(NSString *)key;
+- (NSString *)StringForKeyPath:(NSString *)key;
-
-- (int)intForKey:(NSString*)key with3GEnabled:(BOOL)enabled;
-- (BOOL)boolForKey:(NSString*)key with3GEnabled:(BOOL)enabled;
+- (int)intForKey:(NSString *)key with3GEnabled:(BOOL)enabled;
+- (BOOL)boolForKey:(NSString *)key with3GEnabled:(BOOL)enabled;
@end
diff --git a/client/iOS/Models/ConnectionParams.m b/client/iOS/Models/ConnectionParams.m
index 0477c82a5..4cdc91464 100644
--- a/client/iOS/Models/ConnectionParams.m
+++ b/client/iOS/Models/ConnectionParams.m
@@ -1,12 +1,12 @@
/*
Connection Parameters abstraction
-
- Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import "ConnectionParams.h"
#import "GlobalDefaults.h"
@@ -15,37 +15,39 @@
#import "TSXAdditions.h"
@interface ConnectionParams (Private)
-- (id)initWithConnectionParams:(ConnectionParams*)params;
+- (id)initWithConnectionParams:(ConnectionParams *)params;
@end
@implementation ConnectionParams
// Designated initializer.
-- (id)initWithDictionary:(NSDictionary*)dict
+- (id)initWithDictionary:(NSDictionary *)dict
{
if (!(self = [super init]))
return nil;
-
+
_connection_params = [dict mutableDeepCopy];
-
- [self decryptPasswordForKey:@"password"];
- [self decryptPasswordForKey:@"tsg_password"];
-
+
+ [self decryptPasswordForKey:@"password"];
+ [self decryptPasswordForKey:@"tsg_password"];
+
return self;
}
-- (void)decryptPasswordForKey:(NSString*)key
+- (void)decryptPasswordForKey:(NSString *)key
{
if ([[_connection_params objectForKey:key] isKindOfClass:[NSData class]])
{
- NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:key]];
+ NSString *plaintext_password = [[[EncryptionController sharedEncryptionController]
+ decryptor] decryptString:[_connection_params objectForKey:key]];
[self setValue:plaintext_password forKey:key];
}
}
- (id)initWithBaseDefaultParameters
{
- return [self initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]];
+ return [self initWithDictionary:[[NSUserDefaults standardUserDefaults]
+ dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]];
}
- (id)init
@@ -53,13 +55,14 @@
return [self initWithDictionary:[NSDictionary dictionary]];
}
-- (id)initWithConnectionParams:(ConnectionParams*)params
+- (id)initWithConnectionParams:(ConnectionParams *)params
{
return [self initWithDictionary:params->_connection_params];
}
- (void)dealloc
{
- [_connection_params release]; _connection_params = nil;
+ [_connection_params release];
+ _connection_params = nil;
[super dealloc];
}
@@ -68,7 +71,7 @@
return [[ConnectionParams alloc] initWithDictionary:_connection_params];
}
-- (NSString*)description
+- (NSString *)description
{
return [NSString stringWithFormat:@"ConnectionParams: %@", [_connection_params description]];
}
@@ -80,36 +83,38 @@
{
if ([decoder containsValueForKey:@"connectionParams"])
return [self initWithDictionary:[decoder decodeObjectForKey:@"connectionParams"]];
-
+
return [self init];
}
- (void)encodeWithCoder:(NSCoder *)coder
-{
- NSSet* unserializable_keys = [NSSet setWithObjects:@"view", nil];
- NSMutableDictionary* serializable_params = [[NSMutableDictionary alloc] initWithCapacity:[_connection_params count]];
-
- for (NSString* k in _connection_params)
- if ( ([k characterAtIndex:0] != '_') && ![unserializable_keys containsObject:k])
+{
+ NSSet *unserializable_keys = [NSSet setWithObjects:@"view", nil];
+ NSMutableDictionary *serializable_params =
+ [[NSMutableDictionary alloc] initWithCapacity:[_connection_params count]];
+
+ for (NSString *k in _connection_params)
+ if (([k characterAtIndex:0] != '_') && ![unserializable_keys containsObject:k])
[serializable_params setObject:[_connection_params objectForKey:k] forKey:k];
-
+
if ([serializable_params objectForKey:@"password"] != nil)
- [self serializeDecryptedForKey:@"password" forParams:serializable_params];
+ [self serializeDecryptedForKey:@"password" forParams:serializable_params];
if ([serializable_params objectForKey:@"tsg_password"] != nil)
- [self serializeDecryptedForKey:@"tsg_password" forParams:serializable_params];
-
+ [self serializeDecryptedForKey:@"tsg_password" forParams:serializable_params];
+
[coder encodeObject:serializable_params forKey:@"connectionParams"];
[serializable_params release];
}
-- (void)serializeDecryptedForKey:(NSString*)key forParams:(NSMutableDictionary*)params
+- (void)serializeDecryptedForKey:(NSString *)key forParams:(NSMutableDictionary *)params
{
- NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[params objectForKey:key]];
-
- if (encrypted_password)
- [params setObject:encrypted_password forKey:key];
- else
- [params removeObjectForKey:key];
+ NSData *encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor]
+ encryptString:[params objectForKey:key]];
+
+ if (encrypted_password)
+ [params setObject:encrypted_password forKey:key];
+ else
+ [params removeObjectForKey:key];
}
#pragma mark -
@@ -118,24 +123,24 @@
- (void)setValue:(id)value forKey:(NSString *)key
{
[self willChangeValueForKey:key];
-
+
if (value == nil)
[self setNilValueForKey:key];
else
[_connection_params setValue:value forKey:key];
-
+
[self didChangeValueForKey:key];
}
- (void)setValue:(id)value forKeyPath:(NSString *)key
{
[self willChangeValueForKey:key];
-
+
if (value == nil)
[self setNilValueForKey:key];
else
[_connection_params setValue:value forKeyPath:key];
-
+
[self didChangeValueForKey:key];
}
@@ -144,12 +149,12 @@
[_connection_params removeObjectForKey:key];
}
-- (id)valueForKey:(NSString*)key
+- (id)valueForKey:(NSString *)key
{
return [_connection_params valueForKey:key];
}
-- (NSArray*)allKeys
+- (NSArray *)allKeys
{
return [_connection_params allKeys];
}
@@ -157,100 +162,97 @@
#pragma mark -
#pragma mark KV convenience
-- (BOOL)hasValueForKey:(NSString*)key
+- (BOOL)hasValueForKey:(NSString *)key
{
return [_connection_params objectForKey:key] != nil;
}
-- (void)setInt:(int)integer forKey:(NSString*)key
+- (void)setInt:(int)integer forKey:(NSString *)key
{
[self setValue:[NSNumber numberWithInteger:integer] forKey:key];
}
-- (int)intForKey:(NSString*)key
+- (int)intForKey:(NSString *)key
{
return [[self valueForKey:key] intValue];
}
-
-- (void)setBool:(BOOL)v forKey:(NSString*)key
+- (void)setBool:(BOOL)v forKey:(NSString *)key
{
[self setValue:[NSNumber numberWithBool:v] forKey:key];
}
-- (BOOL)boolForKey:(NSString*)key
+- (BOOL)boolForKey:(NSString *)key
{
return [[_connection_params objectForKey:key] boolValue];
}
-
-- (const char*)UTF8StringForKey:(NSString*)key
+- (const char *)UTF8StringForKey:(NSString *)key
{
id val = [self valueForKey:key];
- const char* str;
-
+ const char *str;
+
if ([val respondsToSelector:@selector(UTF8String)] && (str = [val UTF8String]))
return str;
-
+
return "";
}
-- (NSString*)StringForKey:(NSString*)key
+- (NSString *)StringForKey:(NSString *)key
{
return [self valueForKey:key];
}
-- (BOOL)hasValueForKeyPath:(NSString*)key
+- (BOOL)hasValueForKeyPath:(NSString *)key
{
- return [_connection_params valueForKeyPath:key] != nil;
+ return [_connection_params valueForKeyPath:key] != nil;
}
-- (void)setInt:(int)integer forKeyPath:(NSString*)key
+- (void)setInt:(int)integer forKeyPath:(NSString *)key
{
[self setValue:[NSNumber numberWithInteger:integer] forKeyPath:key];
}
-- (int)intForKeyPath:(NSString*)key
+- (int)intForKeyPath:(NSString *)key
{
return [[self valueForKeyPath:key] intValue];
}
-- (void)setBool:(BOOL)v forKeyPath:(NSString*)key
+- (void)setBool:(BOOL)v forKeyPath:(NSString *)key
{
[self setValue:[NSNumber numberWithBool:v] forKeyPath:key];
}
-- (BOOL)boolForKeyPath:(NSString*)key
+- (BOOL)boolForKeyPath:(NSString *)key
{
return [[self valueForKeyPath:key] boolValue];
}
-- (const char*)UTF8StringForKeyPath:(NSString*)key
+- (const char *)UTF8StringForKeyPath:(NSString *)key
{
id val = [self valueForKeyPath:key];
- const char* str;
-
+ const char *str;
+
if ([val respondsToSelector:@selector(UTF8String)] && (str = [val UTF8String]))
return str;
-
+
return "";
}
-- (NSString*)StringForKeyPath:(NSString*)key
+- (NSString *)StringForKeyPath:(NSString *)key
{
return [self valueForKeyPath:key];
}
-- (int)intForKey:(NSString*)key with3GEnabled:(BOOL)enabled
+- (int)intForKey:(NSString *)key with3GEnabled:(BOOL)enabled
{
- if (enabled && [self boolForKey:@"enable_3g_settings"])
- return [self intForKeyPath:[NSString stringWithFormat:@"settings_3g.%@", key]];
- return [self intForKeyPath:key];
+ if (enabled && [self boolForKey:@"enable_3g_settings"])
+ return [self intForKeyPath:[NSString stringWithFormat:@"settings_3g.%@", key]];
+ return [self intForKeyPath:key];
}
-- (BOOL)boolForKey:(NSString*)key with3GEnabled:(BOOL)enabled
+- (BOOL)boolForKey:(NSString *)key with3GEnabled:(BOOL)enabled
{
- if (enabled && [self boolForKey:@"enable_3g_settings"])
- return [self boolForKeyPath:[NSString stringWithFormat:@"settings_3g.%@", key]];
- return [self boolForKeyPath:key];
+ if (enabled && [self boolForKey:@"enable_3g_settings"])
+ return [self boolForKeyPath:[NSString stringWithFormat:@"settings_3g.%@", key]];
+ return [self boolForKeyPath:key];
}
@end
-
diff --git a/client/iOS/Models/Encryptor.h b/client/iOS/Models/Encryptor.h
index 7f3305733..c0592c0db 100644
--- a/client/iOS/Models/Encryptor.h
+++ b/client/iOS/Models/Encryptor.h
@@ -1,10 +1,11 @@
/*
Password Encryptor
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
/* Encrypts data using AES 128 with a 256 bit key derived using PBKDF2-HMAC-SHA1 */
@@ -23,20 +24,20 @@
#define TSXEncryptorPBKDF2SaltLen TSXEncryptorBlockCipherOptions
#define TSXEncryptorPBKDF2KeySize TSXEncryptorBlockCipherKeySize
-
-@interface Encryptor : NSObject {
-@private
- NSData* _encryption_key;
- NSString* _plaintext_password;
+@interface Encryptor : NSObject
+{
+ @private
+ NSData *_encryption_key;
+ NSString *_plaintext_password;
}
-@property(readonly) NSString* plaintextPassword;
+@property(readonly) NSString *plaintextPassword;
-- (id)initWithPassword:(NSString*)plaintext_password;
+- (id)initWithPassword:(NSString *)plaintext_password;
-- (NSData*)encryptData:(NSData*)plaintext_data;
-- (NSData*)decryptData:(NSData*)encrypted_data;
-- (NSData*)encryptString:(NSString*)plaintext_string;
-- (NSString*)decryptString:(NSData*)encrypted_string;
+- (NSData *)encryptData:(NSData *)plaintext_data;
+- (NSData *)decryptData:(NSData *)encrypted_data;
+- (NSData *)encryptString:(NSString *)plaintext_string;
+- (NSString *)decryptString:(NSData *)encrypted_string;
@end
diff --git a/client/iOS/Models/Encryptor.m b/client/iOS/Models/Encryptor.m
index 5ca686b98..7bebb9615 100644
--- a/client/iOS/Models/Encryptor.m
+++ b/client/iOS/Models/Encryptor.m
@@ -1,56 +1,64 @@
/*
Password Encryptor
-
+
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
-/* We try to use CommonCrypto as much as possible. PBKDF2 was added to CommonCrypto in iOS 5, so use OpenSSL only as a fallback to do PBKDF2 on pre iOS 5 systems. */
+/* We try to use CommonCrypto as much as possible. PBKDF2 was added to CommonCrypto in iOS 5, so use
+ * OpenSSL only as a fallback to do PBKDF2 on pre iOS 5 systems. */
#import "Encryptor.h"
-#import
-#import
-#import
+#import
+#import
+#import
#import // For PBKDF2 on < 5.0
#include
#pragma mark -
@interface Encryptor (Private)
-- (NSData*)randomInitializationVector;
+- (NSData *)randomInitializationVector;
@end
@implementation Encryptor
-@synthesize plaintextPassword=_plaintext_password;
+@synthesize plaintextPassword = _plaintext_password;
-- (id)initWithPassword:(NSString*)plaintext_password
+- (id)initWithPassword:(NSString *)plaintext_password
{
if (plaintext_password == nil)
- return nil;
-
- if ( !(self = [super init]) )
return nil;
-
+
+ if (!(self = [super init]))
+ return nil;
+
_plaintext_password = [plaintext_password retain];
- const char* plaintext_password_data = [plaintext_password length] ? [plaintext_password UTF8String] : " ";
-
+ const char *plaintext_password_data =
+ [plaintext_password length] ? [plaintext_password UTF8String] : " ";
+
if (!plaintext_password_data || !strlen(plaintext_password_data))
- [NSException raise:NSInternalInconsistencyException format:@"%s: plaintext password data is zero length!", __func__];
-
-
- uint8_t* derived_key = calloc(1, TSXEncryptorPBKDF2KeySize);
-
+ [NSException raise:NSInternalInconsistencyException
+ format:@"%s: plaintext password data is zero length!", __func__];
+
+ uint8_t *derived_key = calloc(1, TSXEncryptorPBKDF2KeySize);
+
if (CCKeyDerivationPBKDF != NULL)
{
- int ret = CCKeyDerivationPBKDF(kCCPBKDF2, plaintext_password_data, strlen(plaintext_password_data)-1, (const uint8_t*)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen, kCCPRFHmacAlgSHA1, TSXEncryptorPBKDF2Rounds, derived_key, TSXEncryptorPBKDF2KeySize);
- //NSLog(@"CCKeyDerivationPBKDF ret = %d; key: %@", ret, [NSData dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
-
+ int ret = CCKeyDerivationPBKDF(
+ kCCPBKDF2, plaintext_password_data, strlen(plaintext_password_data) - 1,
+ (const uint8_t *)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen, kCCPRFHmacAlgSHA1,
+ TSXEncryptorPBKDF2Rounds, derived_key, TSXEncryptorPBKDF2KeySize);
+ // NSLog(@"CCKeyDerivationPBKDF ret = %d; key: %@", ret, [NSData
+ // dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
+
if (ret)
{
- NSLog(@"%s: CCKeyDerivationPBKDF ret == %d, indicating some sort of failure.", __func__, ret);
- free(derived_key);
+ NSLog(@"%s: CCKeyDerivationPBKDF ret == %d, indicating some sort of failure.", __func__,
+ ret);
+ free(derived_key);
[self autorelease];
return nil;
}
@@ -58,115 +66,139 @@
else
{
// iOS 4.x or earlier -- use OpenSSL
- unsigned long ret = PKCS5_PBKDF2_HMAC_SHA1(plaintext_password_data, (int)strlen(plaintext_password_data)-1, (const unsigned char*)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen, TSXEncryptorPBKDF2Rounds, TSXEncryptorPBKDF2KeySize, derived_key);
- //NSLog(@"PKCS5_PBKDF2_HMAC_SHA1 ret = %lu; key: %@", ret, [NSData dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
-
+ unsigned long ret = PKCS5_PBKDF2_HMAC_SHA1(
+ plaintext_password_data, (int)strlen(plaintext_password_data) - 1,
+ (const unsigned char *)TSXEncryptorPBKDF2Salt, TSXEncryptorPBKDF2SaltLen,
+ TSXEncryptorPBKDF2Rounds, TSXEncryptorPBKDF2KeySize, derived_key);
+ // NSLog(@"PKCS5_PBKDF2_HMAC_SHA1 ret = %lu; key: %@", ret, [NSData
+ // dataWithBytesNoCopy:derived_key length:TWEncryptorPBKDF2KeySize freeWhenDone:NO]);
+
if (ret != 1)
{
- NSLog(@"%s: PKCS5_PBKDF2_HMAC_SHA1 ret == %lu, indicating some sort of failure.", __func__, ret);
- free(derived_key);
+ NSLog(@"%s: PKCS5_PBKDF2_HMAC_SHA1 ret == %lu, indicating some sort of failure.",
+ __func__, ret);
+ free(derived_key);
[self release];
return nil;
}
- }
-
-
- _encryption_key = [[NSData alloc] initWithBytesNoCopy:derived_key length:TSXEncryptorPBKDF2KeySize freeWhenDone:YES];
+ }
+
+ _encryption_key = [[NSData alloc] initWithBytesNoCopy:derived_key
+ length:TSXEncryptorPBKDF2KeySize
+ freeWhenDone:YES];
return self;
}
-
#pragma mark -
#pragma mark Encrypting/Decrypting data
-- (NSData*)encryptData:(NSData*)plaintext_data
+- (NSData *)encryptData:(NSData *)plaintext_data
{
if (![plaintext_data length])
return nil;
-
- NSData* iv = [self randomInitializationVector];
- NSMutableData* encrypted_data = [NSMutableData dataWithLength:[iv length] + [plaintext_data length] + TSXEncryptorBlockCipherBlockSize];
+
+ NSData *iv = [self randomInitializationVector];
+ NSMutableData *encrypted_data = [NSMutableData
+ dataWithLength:[iv length] + [plaintext_data length] + TSXEncryptorBlockCipherBlockSize];
[encrypted_data replaceBytesInRange:NSMakeRange(0, [iv length]) withBytes:[iv bytes]];
-
+
size_t data_out_moved = 0;
- int ret = CCCrypt(kCCEncrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions, [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [iv bytes], [plaintext_data bytes], [plaintext_data length], [encrypted_data mutableBytes]+[iv length], [encrypted_data length]-[iv length], &data_out_moved);
-
+ int ret = CCCrypt(kCCEncrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions,
+ [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [iv bytes],
+ [plaintext_data bytes], [plaintext_data length],
+ [encrypted_data mutableBytes] + [iv length],
+ [encrypted_data length] - [iv length], &data_out_moved);
+
switch (ret)
{
case kCCSuccess:
[encrypted_data setLength:[iv length] + data_out_moved];
return encrypted_data;
-
+
default:
- NSLog(@"%s: uncaught error, ret CCCryptorStatus = %d (plaintext len = %lu; buffer size = %lu)", __func__, ret, (unsigned long)[plaintext_data length], (unsigned long)([encrypted_data length]-[iv length]));
+ NSLog(
+ @"%s: uncaught error, ret CCCryptorStatus = %d (plaintext len = %lu; buffer size = "
+ @"%lu)",
+ __func__, ret, (unsigned long)[plaintext_data length],
+ (unsigned long)([encrypted_data length] - [iv length]));
return nil;
}
-
+
return nil;
}
-- (NSData*)decryptData:(NSData*)encrypted_data
+- (NSData *)decryptData:(NSData *)encrypted_data
{
if ([encrypted_data length] <= TSXEncryptorBlockCipherBlockSize)
return nil;
-
- NSMutableData* plaintext_data = [NSMutableData dataWithLength:[encrypted_data length] + TSXEncryptorBlockCipherBlockSize];
+
+ NSMutableData *plaintext_data =
+ [NSMutableData dataWithLength:[encrypted_data length] + TSXEncryptorBlockCipherBlockSize];
size_t data_out_moved = 0;
-
- int ret = CCCrypt(kCCDecrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions, [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [encrypted_data bytes], [encrypted_data bytes] + TSXEncryptorBlockCipherBlockSize, [encrypted_data length] - TSXEncryptorBlockCipherBlockSize, [plaintext_data mutableBytes], [plaintext_data length], &data_out_moved);
-
+
+ int ret =
+ CCCrypt(kCCDecrypt, TSXEncryptorBlockCipherAlgo, TSXEncryptorBlockCipherOptions,
+ [_encryption_key bytes], TSXEncryptorBlockCipherKeySize, [encrypted_data bytes],
+ [encrypted_data bytes] + TSXEncryptorBlockCipherBlockSize,
+ [encrypted_data length] - TSXEncryptorBlockCipherBlockSize,
+ [plaintext_data mutableBytes], [plaintext_data length], &data_out_moved);
+
switch (ret)
{
case kCCSuccess:
[plaintext_data setLength:data_out_moved];
return plaintext_data;
-
- case kCCBufferTooSmall: // Our output buffer is big enough to decrypt valid data. This return code indicates malformed data.
+
+ case kCCBufferTooSmall: // Our output buffer is big enough to decrypt valid data. This
+ // return code indicates malformed data.
case kCCAlignmentError: // Shouldn't get this, since we're using padding.
- case kCCDecodeError: // Wrong key.
+ case kCCDecodeError: // Wrong key.
return nil;
-
+
default:
- NSLog(@"%s: uncaught error, ret CCCryptorStatus = %d (encrypted data len = %lu; buffer size = %lu; dom = %lu)", __func__, ret, (unsigned long)[encrypted_data length], (unsigned long)[plaintext_data length], data_out_moved);
+ NSLog(@"%s: uncaught error, ret CCCryptorStatus = %d (encrypted data len = %lu; buffer "
+ @"size = %lu; dom = %lu)",
+ __func__, ret, (unsigned long)[encrypted_data length],
+ (unsigned long)[plaintext_data length], data_out_moved);
return nil;
}
-
+
return nil;
}
-
-- (NSData*)encryptString:(NSString*)plaintext_string
+- (NSData *)encryptString:(NSString *)plaintext_string
{
return [self encryptData:[plaintext_string dataUsingEncoding:NSUTF8StringEncoding]];
}
-- (NSString*)decryptString:(NSData*)encrypted_string
+- (NSString *)decryptString:(NSData *)encrypted_string
{
- return [[[NSString alloc] initWithData:[self decryptData:encrypted_string] encoding:NSUTF8StringEncoding] autorelease];
+ return [[[NSString alloc] initWithData:[self decryptData:encrypted_string]
+ encoding:NSUTF8StringEncoding] autorelease];
}
-- (NSData*)randomInitializationVector
+- (NSData *)randomInitializationVector
{
- NSMutableData* iv = [NSMutableData dataWithLength:TSXEncryptorBlockCipherBlockSize];
+ NSMutableData *iv = [NSMutableData dataWithLength:TSXEncryptorBlockCipherBlockSize];
int fd;
-
- if ( (fd = open("/dev/urandom", O_RDONLY)) < 0)
+
+ if ((fd = open("/dev/urandom", O_RDONLY)) < 0)
return nil;
-
+
NSInteger bytes_needed = [iv length];
- char* p = [iv mutableBytes];
-
+ char *p = [iv mutableBytes];
+
while (bytes_needed)
{
long bytes_read = read(fd, p, bytes_needed);
-
+
if (bytes_read < 0)
continue;
-
+
p += bytes_read;
bytes_needed -= bytes_read;
}
-
+
close(fd);
return iv;
}
diff --git a/client/iOS/Models/GlobalDefaults.h b/client/iOS/Models/GlobalDefaults.h
index 9bcc3f322..4d98aa3a5 100644
--- a/client/iOS/Models/GlobalDefaults.h
+++ b/client/iOS/Models/GlobalDefaults.h
@@ -1,29 +1,30 @@
/*
Global default bookmark settings
-
- Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
+ Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
+ */
#import
@class ConnectionParams, ComputerBookmark;
-@interface GlobalDefaults : NSObject{
-@private
- ComputerBookmark* _default_bookmark;
+@interface GlobalDefaults : NSObject
+{
+ @private
+ ComputerBookmark *_default_bookmark;
}
-+ (GlobalDefaults*)sharedGlobalDefaults;
++ (GlobalDefaults *)sharedGlobalDefaults;
// The same object is always returned from this method.
-@property (readonly,nonatomic) ComputerBookmark* bookmark;
+@property(readonly, nonatomic) ComputerBookmark *bookmark;
-- (ConnectionParams*)newParams;
-- (ComputerBookmark*)newBookmark;
-- (ComputerBookmark*)newTestServerBookmark;
+- (ConnectionParams *)newParams;
+- (ComputerBookmark *)newBookmark;
+- (ComputerBookmark *)newTestServerBookmark;
@end
diff --git a/client/iOS/Models/GlobalDefaults.m b/client/iOS/Models/GlobalDefaults.m
index fcb09b064..2ed06f05c 100644
--- a/client/iOS/Models/GlobalDefaults.m
+++ b/client/iOS/Models/GlobalDefaults.m
@@ -4,7 +4,8 @@
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "GlobalDefaults.h"
@@ -13,9 +14,9 @@
@implementation GlobalDefaults
-+ (GlobalDefaults*)sharedGlobalDefaults
++ (GlobalDefaults *)sharedGlobalDefaults
{
- static GlobalDefaults* _shared_global_defaults = nil;
+ static GlobalDefaults *_shared_global_defaults = nil;
if (_shared_global_defaults == nil)
{
@@ -34,16 +35,15 @@
if (!(self = [super init]))
return nil;
- ComputerBookmark* bookmark = nil;
- NSData* bookmark_data = [[NSUserDefaults standardUserDefaults] objectForKey:
- @"TSXSharedGlobalDefaultBookmark"];
+ ComputerBookmark *bookmark = nil;
+ NSData *bookmark_data =
+ [[NSUserDefaults standardUserDefaults] objectForKey:@"TSXSharedGlobalDefaultBookmark"];
if (bookmark_data && [bookmark_data length])
bookmark = [NSKeyedUnarchiver unarchiveObjectWithData:bookmark_data];
if (!bookmark)
- bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters]
- autorelease];
+ bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
_default_bookmark = [bookmark retain];
return self;
@@ -59,21 +59,20 @@
@synthesize bookmark = _default_bookmark;
-- (ComputerBookmark*)newBookmark
+- (ComputerBookmark *)newBookmark
{
- return [[ComputerBookmark alloc] initWithConnectionParameters:[[self newParams]
- autorelease]];
+ return [[ComputerBookmark alloc] initWithConnectionParameters:[[self newParams] autorelease]];
}
-- (ConnectionParams*)newParams
+- (ConnectionParams *)newParams
{
- ConnectionParams* param_copy = [[[self bookmark] params] copy];
+ ConnectionParams *param_copy = [[[self bookmark] params] copy];
return param_copy;
}
-- (ComputerBookmark*)newTestServerBookmark
+- (ComputerBookmark *)newTestServerBookmark
{
- ComputerBookmark* bm = [self newBookmark];
+ ComputerBookmark *bm = [self newBookmark];
[bm setLabel:@"Test Server"];
[[bm params] setValue:@"testservice.ifreerdp.com" forKey:@"hostname"];
[[bm params] setInt:0 forKey:@"screen_resolution_type"];
diff --git a/client/iOS/Models/RDPKeyboard.h b/client/iOS/Models/RDPKeyboard.h
index 3e23069ca..0757d994b 100644
--- a/client/iOS/Models/RDPKeyboard.h
+++ b/client/iOS/Models/RDPKeyboard.h
@@ -1,10 +1,11 @@
/*
- RDP Keyboard helper
-
+ RDP Keyboard helper
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -12,40 +13,39 @@
@class RDPKeyboard;
-
@protocol RDPKeyboardDelegate
@optional
-- (void)modifiersChangedForKeyboard:(RDPKeyboard*)keyboard;
+- (void)modifiersChangedForKeyboard:(RDPKeyboard *)keyboard;
@end
+@interface RDPKeyboard : NSObject
+{
-@interface RDPKeyboard : NSObject {
+ RDPSession *_session;
- RDPSession* _session;
-
int _virtual_key_map[256];
- int _unicode_map[256];
- NSDictionary* _special_keys;
+ int _unicode_map[256];
+ NSDictionary *_special_keys;
+
+ NSObject *_delegate;
- NSObject* _delegate;
-
BOOL _ctrl_pressed;
- BOOL _alt_pressed;
- BOOL _shift_pressed;
- BOOL _win_pressed;
+ BOOL _alt_pressed;
+ BOOL _shift_pressed;
+ BOOL _win_pressed;
}
-@property (assign) id delegate;
-@property (readonly) BOOL ctrlPressed;
-@property (readonly) BOOL altPressed;
-@property (readonly) BOOL shiftPressed;
-@property (readonly) BOOL winPressed;
+@property(assign) id delegate;
+@property(readonly) BOOL ctrlPressed;
+@property(readonly) BOOL altPressed;
+@property(readonly) BOOL shiftPressed;
+@property(readonly) BOOL winPressed;
// returns a keyboard instance
-+ (RDPKeyboard*)getSharedRDPKeyboard;
++ (RDPKeyboard *)getSharedRDPKeyboard;
// init the keyboard and assign the given rdp session and delegate
-- (void)initWithSession:(RDPSession*)session delegate:(NSObject*)delegate;
+- (void)initWithSession:(RDPSession *)session delegate:(NSObject *)delegate;
// called to reset any pending key states (i.e. pressed modifier keys)
- (void)reset;
diff --git a/client/iOS/Models/RDPKeyboard.m b/client/iOS/Models/RDPKeyboard.m
index 8b5545082..47ebdd90c 100644
--- a/client/iOS/Models/RDPKeyboard.m
+++ b/client/iOS/Models/RDPKeyboard.m
@@ -1,10 +1,11 @@
/*
- RDP Keyboard helper
-
+ RDP Keyboard helper
+
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import "RDPKeyboard.h"
@@ -19,17 +20,18 @@
@implementation RDPKeyboard
-@synthesize delegate = _delegate, ctrlPressed = _ctrl_pressed, altPressed = _alt_pressed, shiftPressed = _shift_pressed, winPressed = _win_pressed;
+@synthesize delegate = _delegate, ctrlPressed = _ctrl_pressed, altPressed = _alt_pressed,
+ shiftPressed = _shift_pressed, winPressed = _win_pressed;
- (id)init
{
- if((self = [super init]) != nil)
+ if ((self = [super init]) != nil)
{
- [self initWithSession:nil delegate:nil];
-
+ [self initWithSession:nil delegate:nil];
+
memset(_virtual_key_map, 0, sizeof(_virtual_key_map));
- memset(_unicode_map, 0, sizeof(_unicode_map));
-
+ memset(_unicode_map, 0, sizeof(_unicode_map));
+
// init vkey map - used for alpha-num characters
_virtual_key_map['0'] = VK_KEY_0;
_virtual_key_map['1'] = VK_KEY_1;
@@ -41,7 +43,7 @@
_virtual_key_map['7'] = VK_KEY_7;
_virtual_key_map['8'] = VK_KEY_8;
_virtual_key_map['9'] = VK_KEY_9;
-
+
_virtual_key_map['a'] = VK_KEY_A;
_virtual_key_map['b'] = VK_KEY_B;
_virtual_key_map['c'] = VK_KEY_C;
@@ -68,42 +70,42 @@
_virtual_key_map['x'] = VK_KEY_X;
_virtual_key_map['y'] = VK_KEY_Y;
_virtual_key_map['z'] = VK_KEY_Z;
-
- // init scancode map - used for special characters
- _unicode_map['-'] = 45;
- _unicode_map['/'] = 47;
- _unicode_map[':'] = 58;
- _unicode_map[';'] = 59;
- _unicode_map['('] = 40;
- _unicode_map[')'] = 41;
- _unicode_map['&'] = 38;
- _unicode_map['@'] = 64;
- _unicode_map['.'] = 46;
- _unicode_map[','] = 44;
- _unicode_map['?'] = 63;
- _unicode_map['!'] = 33;
- _unicode_map['\''] = 39;
- _unicode_map['\"'] = 34;
-
- _unicode_map['['] = 91;
- _unicode_map[']'] = 93;
- _unicode_map['{'] = 123;
- _unicode_map['}'] = 125;
- _unicode_map['#'] = 35;
- _unicode_map['%'] = 37;
- _unicode_map['^'] = 94;
- _unicode_map['*'] = 42;
- _unicode_map['+'] = 43;
- _unicode_map['='] = 61;
- _unicode_map['_'] = 95;
- _unicode_map['\\'] = 92;
- _unicode_map['|'] = 124;
- _unicode_map['~'] = 126;
- _unicode_map['<'] = 60;
- _unicode_map['>'] = 62;
- _unicode_map['$'] = 36;
- }
+ // init scancode map - used for special characters
+ _unicode_map['-'] = 45;
+ _unicode_map['/'] = 47;
+ _unicode_map[':'] = 58;
+ _unicode_map[';'] = 59;
+ _unicode_map['('] = 40;
+ _unicode_map[')'] = 41;
+ _unicode_map['&'] = 38;
+ _unicode_map['@'] = 64;
+ _unicode_map['.'] = 46;
+ _unicode_map[','] = 44;
+ _unicode_map['?'] = 63;
+ _unicode_map['!'] = 33;
+ _unicode_map['\''] = 39;
+ _unicode_map['\"'] = 34;
+
+ _unicode_map['['] = 91;
+ _unicode_map[']'] = 93;
+ _unicode_map['{'] = 123;
+ _unicode_map['}'] = 125;
+ _unicode_map['#'] = 35;
+ _unicode_map['%'] = 37;
+ _unicode_map['^'] = 94;
+ _unicode_map['*'] = 42;
+ _unicode_map['+'] = 43;
+ _unicode_map['='] = 61;
+
+ _unicode_map['_'] = 95;
+ _unicode_map['\\'] = 92;
+ _unicode_map['|'] = 124;
+ _unicode_map['~'] = 126;
+ _unicode_map['<'] = 60;
+ _unicode_map['>'] = 62;
+ _unicode_map['$'] = 36;
+ }
return self;
}
@@ -116,114 +118,114 @@
#pragma mark class methods
// return a keyboard instance
-+ (RDPKeyboard*)getSharedRDPKeyboard
++ (RDPKeyboard *)getSharedRDPKeyboard
{
- static RDPKeyboard* _shared_keyboard = nil;
-
+ static RDPKeyboard *_shared_keyboard = nil;
+
if (_shared_keyboard == nil)
{
@synchronized(self)
{
if (_shared_keyboard == nil)
- _shared_keyboard = [[RDPKeyboard alloc] init];
+ _shared_keyboard = [[RDPKeyboard alloc] init];
}
}
-
- return _shared_keyboard;
+
+ return _shared_keyboard;
}
// reset the keyboard instance and assign the given rdp instance
- (void)initWithSession:(RDPSession *)session delegate:(NSObject *)delegate
{
- _alt_pressed = NO;
- _ctrl_pressed = NO;
- _shift_pressed = NO;
- _win_pressed = NO;
-
- _session = session;
- _delegate = delegate;
+ _alt_pressed = NO;
+ _ctrl_pressed = NO;
+ _shift_pressed = NO;
+ _win_pressed = NO;
+
+ _session = session;
+ _delegate = delegate;
}
- (void)reset
{
- // reset pressed ctrl, alt, shift or win key
- if(_shift_pressed)
- [self toggleShiftKey];
- if(_alt_pressed)
- [self toggleAltKey];
- if(_ctrl_pressed)
- [self toggleCtrlKey];
- if(_win_pressed)
- [self toggleWinKey];
+ // reset pressed ctrl, alt, shift or win key
+ if (_shift_pressed)
+ [self toggleShiftKey];
+ if (_alt_pressed)
+ [self toggleAltKey];
+ if (_ctrl_pressed)
+ [self toggleCtrlKey];
+ if (_win_pressed)
+ [self toggleWinKey];
}
// handles button pressed input event from the iOS keyboard
// performs all conversions etc.
- (void)sendUnicode:(int)character
-{
- if(isalnum(character))
- [self handleAlphaNumChar:character];
- else
- [self handleSpecialKey:character];
+{
+ if (isalnum(character))
+ [self handleAlphaNumChar:character];
+ else
+ [self handleSpecialKey:character];
- [self reset];
+ [self reset];
}
// send a backspace key press
- (void)sendVirtualKeyCode:(int)keyCode
{
- [self sendVirtualKey:keyCode up:NO];
- [self sendVirtualKey:keyCode up:YES];
+ [self sendVirtualKey:keyCode up:NO];
+ [self sendVirtualKey:keyCode up:YES];
}
#pragma mark modifier key handling
// toggle ctrl key, returns true if pressed, otherwise false
- (void)toggleCtrlKey
-{
- [self sendVirtualKey:VK_LCONTROL up:_ctrl_pressed];
- _ctrl_pressed = !_ctrl_pressed;
- [self notifyDelegateModifiersChanged];
+{
+ [self sendVirtualKey:VK_LCONTROL up:_ctrl_pressed];
+ _ctrl_pressed = !_ctrl_pressed;
+ [self notifyDelegateModifiersChanged];
}
// toggle alt key, returns true if pressed, otherwise false
- (void)toggleAltKey
{
- [self sendVirtualKey:VK_LMENU up:_alt_pressed];
- _alt_pressed = !_alt_pressed;
- [self notifyDelegateModifiersChanged];
+ [self sendVirtualKey:VK_LMENU up:_alt_pressed];
+ _alt_pressed = !_alt_pressed;
+ [self notifyDelegateModifiersChanged];
}
// toggle shift key, returns true if pressed, otherwise false
- (void)toggleShiftKey
{
- [self sendVirtualKey:VK_LSHIFT up:_shift_pressed];
- _shift_pressed = !_shift_pressed;
- [self notifyDelegateModifiersChanged];
+ [self sendVirtualKey:VK_LSHIFT up:_shift_pressed];
+ _shift_pressed = !_shift_pressed;
+ [self notifyDelegateModifiersChanged];
}
// toggle windows key, returns true if pressed, otherwise false
- (void)toggleWinKey
{
- [self sendVirtualKey:(VK_LWIN | KBDEXT) up:_win_pressed];
- _win_pressed = !_win_pressed;
- [self notifyDelegateModifiersChanged];
+ [self sendVirtualKey:(VK_LWIN | KBDEXT) up:_win_pressed];
+ _win_pressed = !_win_pressed;
+ [self notifyDelegateModifiersChanged];
}
#pragma mark Sending special key strokes
- (void)sendEnterKeyStroke
{
- [self sendVirtualKeyCode:(VK_RETURN | KBDEXT)];
+ [self sendVirtualKeyCode:(VK_RETURN | KBDEXT)];
}
- (void)sendEscapeKeyStroke
{
- [self sendVirtualKeyCode:VK_ESCAPE];
+ [self sendVirtualKeyCode:VK_ESCAPE];
}
- (void)sendBackspaceKeyStroke
{
- [self sendVirtualKeyCode:VK_BACK];
+ [self sendVirtualKeyCode:VK_BACK];
}
@end
@@ -233,74 +235,76 @@
- (void)handleAlphaNumChar:(int)character
{
- // if we recive an uppercase letter - make it lower and send an shift down event to server
- BOOL shift_was_sent = NO;
- if(isupper(character) && _shift_pressed == NO)
- {
- character = tolower(character);
- [self sendVirtualKey:VK_LSHIFT up:NO];
- shift_was_sent = YES;
- }
-
- // convert the character to a VK
- int vk = _virtual_key_map[character];
- if(vk != 0)
- {
- // send key pressed
- [self sendVirtualKey:vk up:NO];
- [self sendVirtualKey:vk up:YES];
- }
-
- // send the missing shift up if we had a shift down
- if(shift_was_sent)
- [self sendVirtualKey:VK_LSHIFT up:YES];
+ // if we recive an uppercase letter - make it lower and send an shift down event to server
+ BOOL shift_was_sent = NO;
+ if (isupper(character) && _shift_pressed == NO)
+ {
+ character = tolower(character);
+ [self sendVirtualKey:VK_LSHIFT up:NO];
+ shift_was_sent = YES;
+ }
+
+ // convert the character to a VK
+ int vk = _virtual_key_map[character];
+ if (vk != 0)
+ {
+ // send key pressed
+ [self sendVirtualKey:vk up:NO];
+ [self sendVirtualKey:vk up:YES];
+ }
+
+ // send the missing shift up if we had a shift down
+ if (shift_was_sent)
+ [self sendVirtualKey:VK_LSHIFT up:YES];
}
- (void)handleSpecialKey:(int)character
{
- NSDictionary* eventDescriptor = nil;
- if(character < 256)
- {
- // convert the character to a unicode character
- int code = _unicode_map[character];
- if(code != 0)
- eventDescriptor = [NSDictionary dictionaryWithObjectsAndKeys:
- @"keyboard", @"type",
- @"unicode", @"subtype",
- [NSNumber numberWithUnsignedShort:0], @"flags",
- [NSNumber numberWithUnsignedShort:code], @"unicode_char",
- nil];
- }
+ NSDictionary *eventDescriptor = nil;
+ if (character < 256)
+ {
+ // convert the character to a unicode character
+ int code = _unicode_map[character];
+ if (code != 0)
+ eventDescriptor = [NSDictionary
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"unicode", @"subtype",
+ [NSNumber numberWithUnsignedShort:0], @"flags",
+ [NSNumber numberWithUnsignedShort:code],
+ @"unicode_char", nil];
+ }
- if (eventDescriptor == nil)
- eventDescriptor = [NSDictionary dictionaryWithObjectsAndKeys:
- @"keyboard", @"type",
- @"unicode", @"subtype",
- [NSNumber numberWithUnsignedShort:0], @"flags",
- [NSNumber numberWithUnsignedShort:character], @"unicode_char",
- nil];
+ if (eventDescriptor == nil)
+ eventDescriptor = [NSDictionary
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"unicode", @"subtype",
+ [NSNumber numberWithUnsignedShort:0], @"flags",
+ [NSNumber numberWithUnsignedShort:character],
+ @"unicode_char", nil];
- [_session sendInputEvent:eventDescriptor];
+ [_session sendInputEvent:eventDescriptor];
}
// sends the vk code to the session
- (void)sendVirtualKey:(int)vKey up:(BOOL)up
{
- DWORD scancode = GetVirtualScanCodeFromVirtualKeyCode(vKey, 4);
- int flags = (up ? KBD_FLAGS_RELEASE : KBD_FLAGS_DOWN);
- flags |= ((scancode & KBDEXT) ? KBD_FLAGS_EXTENDED : 0);
- [_session sendInputEvent:[NSDictionary dictionaryWithObjectsAndKeys:
- @"keyboard", @"type",
- @"scancode", @"subtype",
- [NSNumber numberWithUnsignedShort:flags], @"flags",
- [NSNumber numberWithUnsignedShort:(scancode & 0xFF)], @"scancode",
- nil]];
+ DWORD scancode = GetVirtualScanCodeFromVirtualKeyCode(vKey, 4);
+ int flags = (up ? KBD_FLAGS_RELEASE : KBD_FLAGS_DOWN);
+ flags |= ((scancode & KBDEXT) ? KBD_FLAGS_EXTENDED : 0);
+ [_session
+ sendInputEvent:[NSDictionary
+ dictionaryWithObjectsAndKeys:@"keyboard", @"type", @"scancode",
+ @"subtype",
+ [NSNumber numberWithUnsignedShort:flags],
+ @"flags",
+ [NSNumber
+ numberWithUnsignedShort:(scancode &
+ 0xFF)],
+ @"scancode", nil]];
}
- (void)notifyDelegateModifiersChanged
{
- if ([[self delegate] respondsToSelector:@selector(modifiersChangedForKeyboard:)])
- [[self delegate] modifiersChangedForKeyboard:self];
+ if ([[self delegate] respondsToSelector:@selector(modifiersChangedForKeyboard:)])
+ [[self delegate] modifiersChangedForKeyboard:self];
}
@end
diff --git a/client/iOS/Models/RDPSession.h b/client/iOS/Models/RDPSession.h
index 67e04eaa4..f010b775e 100644
--- a/client/iOS/Models/RDPSession.h
+++ b/client/iOS/Models/RDPSession.h
@@ -1,10 +1,11 @@
/*
- RDP Session object
-
+ RDP Session object
+
Copyright 2013 Thincast Technologies GmbH, Authors: Martin Fleisz, Dorian Johnson
-
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at
+ http://mozilla.org/MPL/2.0/.
*/
#import
@@ -18,91 +19,91 @@
@class ConnectionParams;
// notification handler for session disconnect
-extern NSString* TSXSessionDidDisconnectNotification;
-extern NSString* TSXSessionDidFailToConnectNotification;
+extern NSString *TSXSessionDidDisconnectNotification;
+extern NSString *TSXSessionDidFailToConnectNotification;
// protocol for session notifications
@protocol RDPSessionDelegate
@optional
-- (void)session:(RDPSession*)session didFailToConnect:(int)reason;
-- (void)sessionWillConnect:(RDPSession*)session;
-- (void)sessionDidConnect:(RDPSession*)session;
-- (void)sessionWillDisconnect:(RDPSession*)session;
-- (void)sessionDidDisconnect:(RDPSession*)session;
-- (void)sessionBitmapContextWillChange:(RDPSession*)session;
-- (void)sessionBitmapContextDidChange:(RDPSession*)session;
-- (void)session:(RDPSession*)session needsRedrawInRect:(CGRect)rect;
-- (CGSize)sizeForFitScreenForSession:(RDPSession*)session;
+- (void)session:(RDPSession *)session didFailToConnect:(int)reason;
+- (void)sessionWillConnect:(RDPSession *)session;
+- (void)sessionDidConnect:(RDPSession *)session;
+- (void)sessionWillDisconnect:(RDPSession *)session;
+- (void)sessionDidDisconnect:(RDPSession *)session;
+- (void)sessionBitmapContextWillChange:(RDPSession *)session;
+- (void)sessionBitmapContextDidChange:(RDPSession *)session;
+- (void)session:(RDPSession *)session needsRedrawInRect:(CGRect)rect;
+- (CGSize)sizeForFitScreenForSession:(RDPSession *)session;
-- (void)session:(RDPSession*)session requestsAuthenticationWithParams:(NSMutableDictionary*)params;
-- (void)session:(RDPSession*)session verifyCertificateWithParams:(NSMutableDictionary*)params;
+- (void)session:(RDPSession *)session
+ requestsAuthenticationWithParams:(NSMutableDictionary *)params;
+- (void)session:(RDPSession *)session verifyCertificateWithParams:(NSMutableDictionary *)params;
@end
// rdp session
-@interface RDPSession : NSObject
+@interface RDPSession : NSObject
{
-@private
- freerdp* _freerdp;
+ @private
+ freerdp *_freerdp;
+
+ ComputerBookmark *_bookmark;
+
+ ConnectionParams *_params;
+
+ NSObject