1- // https://github.com/rustwasm/wasm-bindgen/issues/4080
2- #![ allow( non_snake_case) ]
3-
41use core:: cell:: RefCell ;
52use core:: num:: NonZeroU32 ;
63use core:: time:: Duration ;
@@ -15,7 +12,7 @@ use futures_util::io::{ReadHalf, WriteHalf};
1512use futures_util:: { select, AsyncWriteExt as _, FutureExt as _, StreamExt as _} ;
1613use gloo_net:: websocket;
1714use gloo_net:: websocket:: futures:: WebSocket ;
18- use iron_remote_desktop:: { CursorStyle , DesktopSize , IronErrorKind } ;
15+ use iron_remote_desktop:: { CursorStyle , DesktopSize , Extension , IronErrorKind } ;
1916use ironrdp:: cliprdr:: backend:: ClipboardMessage ;
2017use ironrdp:: cliprdr:: CliprdrClient ;
2118use ironrdp:: connector:: connection_activation:: ConnectionActivationState ;
@@ -31,7 +28,6 @@ use ironrdp::session::{fast_path, ActiveStage, ActiveStageOutput, GracefulDiscon
3128use ironrdp_core:: WriteBuf ;
3229use ironrdp_futures:: { single_sequence_step_read, FramedWrite } ;
3330use rgb:: AsPixels as _;
34- use serde:: { Deserialize , Serialize } ;
3531use tap:: prelude:: * ;
3632use wasm_bindgen:: JsValue ;
3733use wasm_bindgen_futures:: spawn_local;
@@ -208,16 +204,12 @@ impl iron_remote_desktop::SessionBuilder for SessionBuilder {
208204 self . clone ( )
209205 }
210206
211- fn extension ( & self , value : JsValue ) -> Self {
212- match serde_wasm_bindgen:: from_value :: < Extension > ( value) {
213- Ok ( value) => match value {
214- Extension :: KdcProxyUrl ( kdc_proxy_url) => self . 0 . borrow_mut ( ) . kdc_proxy_url = Some ( kdc_proxy_url) ,
215- Extension :: Pcb ( pcb) => self . 0 . borrow_mut ( ) . pcb = Some ( pcb) ,
216- Extension :: DisplayControl ( use_display_control) => {
217- self . 0 . borrow_mut ( ) . use_display_control = use_display_control
218- }
219- } ,
220- Err ( error) => error ! ( %error, "Unsupported extension value" ) ,
207+ fn extension ( & self , ext : Extension ) -> Self {
208+ iron_remote_desktop:: extension_match! {
209+ match ext;
210+ |pcb: String | { self . 0 . borrow_mut( ) . pcb = Some ( pcb) } ;
211+ |kdc_proxy_url: String | { self . 0 . borrow_mut( ) . kdc_proxy_url = Some ( kdc_proxy_url) } ;
212+ |display_control: bool | { self . 0 . borrow_mut( ) . use_display_control = display_control } ;
221213 }
222214
223215 self . clone ( )
@@ -355,13 +347,6 @@ impl iron_remote_desktop::SessionBuilder for SessionBuilder {
355347 }
356348}
357349
358- #[ derive( Debug , Serialize , Deserialize ) ]
359- enum Extension {
360- KdcProxyUrl ( String ) ,
361- Pcb ( String ) ,
362- DisplayControl ( bool ) ,
363- }
364-
365350pub ( crate ) type FastPathInputEvents = smallvec:: SmallVec < [ FastPathInputEvent ; 2 ] > ;
366351
367352#[ derive( Debug ) ]
@@ -814,13 +799,16 @@ impl iron_remote_desktop::Session for Session {
814799 }
815800
816801 fn supports_unicode_keyboard_shortcuts ( & self ) -> bool {
817- // RDP does not support Unicode keyboard shortcuts (When key combinations are executed, only
818- // plain scancode events are allowed to function correctly) .
802+ // RDP does not support Unicode keyboard shortcuts.
803+ // When key combinations are executed, only plain scancode events are allowed to function correctly.
819804 false
820805 }
821806
822- fn extension_call ( _value : JsValue ) -> Result < JsValue , Self :: Error > {
823- Ok ( JsValue :: null ( ) )
807+ fn extension_call ( ext : Extension ) -> Result < JsValue , Self :: Error > {
808+ Err (
809+ IronError :: from ( anyhow:: Error :: msg ( format ! ( "unknown extension: {}" , ext. ident( ) ) ) )
810+ . with_kind ( IronErrorKind :: General ) ,
811+ )
824812 }
825813}
826814
0 commit comments