diff --git a/Cargo.lock b/Cargo.lock index e1425abb..e697ddff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2858,7 +2858,9 @@ dependencies = [ "ironrdp-cliprdr-format", "ironrdp-core", "ironrdp-futures", + "ironrdp-propertyset", "ironrdp-rdcleanpath", + "ironrdp-rdpfile", "js-sys", "png", "resize", diff --git a/crates/ironrdp-web/Cargo.toml b/crates/ironrdp-web/Cargo.toml index a2d0f9d2..286001a0 100644 --- a/crates/ironrdp-web/Cargo.toml +++ b/crates/ironrdp-web/Cargo.toml @@ -37,6 +37,8 @@ ironrdp-core.path = "../ironrdp-core" ironrdp-cliprdr-format.path = "../ironrdp-cliprdr-format" ironrdp-futures.path = "../ironrdp-futures" ironrdp-rdcleanpath.path = "../ironrdp-rdcleanpath" +ironrdp-propertyset.path = "../ironrdp-propertyset" +ironrdp-rdpfile.path = "../ironrdp-rdpfile" iron-remote-desktop.path = "../iron-remote-desktop" # WASM diff --git a/crates/ironrdp-web/src/config_parser.rs b/crates/ironrdp-web/src/config_parser.rs new file mode 100644 index 00000000..e772c2a0 --- /dev/null +++ b/crates/ironrdp-web/src/config_parser.rs @@ -0,0 +1,46 @@ +use wasm_bindgen::prelude::wasm_bindgen; + +#[wasm_bindgen] +pub struct RdpFile(ironrdp_propertyset::PropertySet); + +#[wasm_bindgen] +impl RdpFile { + #[wasm_bindgen(constructor)] + pub fn create() -> Self { + Self(ironrdp_propertyset::PropertySet::new()) + } + + pub fn parse(&mut self, config: &str) { + let parse_result = ironrdp_rdpfile::parse(config); + + self.0 = parse_result.properties; + + for e in parse_result.errors { + error!("Error when reading configuration: {e}"); + } + } + + pub fn write(&self) -> String { + ironrdp_rdpfile::write(&self.0) + } + + #[wasm_bindgen(js_name = "insertStr")] + pub fn insert_str(&mut self, key: String, value: &str) { + self.0.insert(key, value); + } + + #[wasm_bindgen(js_name = "insertInt")] + pub fn insert_int(&mut self, key: String, value: i32) { + self.0.insert(key, value); + } + + #[wasm_bindgen(js_name = "getStr")] + pub fn get_str(&self, key: &str) -> Option { + self.0.get::<&str>(key).map(|str| str.to_owned()) + } + + #[wasm_bindgen(js_name = "getInt")] + pub fn get_int(&self, key: &str) -> Option { + self.0.get::(key) + } +} diff --git a/crates/ironrdp-web/src/lib.rs b/crates/ironrdp-web/src/lib.rs index 55c185dd..259b802a 100644 --- a/crates/ironrdp-web/src/lib.rs +++ b/crates/ironrdp-web/src/lib.rs @@ -18,6 +18,7 @@ extern crate tracing; mod canvas; mod clipboard; +mod config_parser; mod error; mod image; mod input; diff --git a/web-client/iron-remote-desktop-rdp/src/main.ts b/web-client/iron-remote-desktop-rdp/src/main.ts index e50b0e1d..bd14578c 100644 --- a/web-client/iron-remote-desktop-rdp/src/main.ts +++ b/web-client/iron-remote-desktop-rdp/src/main.ts @@ -6,6 +6,7 @@ import wasm_init, { SessionBuilder, ClipboardData, Extension, + RdpFile, } from '../../../crates/ironrdp-web/pkg/ironrdp_web'; export async function init(log_level: string) { @@ -13,6 +14,8 @@ export async function init(log_level: string) { setup(log_level); } +export { RdpFile }; + export const Backend = { DesktopSize: DesktopSize, InputTransaction: InputTransaction,