mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
feat(web): add RdpFile helper to parse RDP configs (#877)
This commit is contained in:
Generated
+2
@@ -2858,7 +2858,9 @@ dependencies = [
|
||||
"ironrdp-cliprdr-format",
|
||||
"ironrdp-core",
|
||||
"ironrdp-futures",
|
||||
"ironrdp-propertyset",
|
||||
"ironrdp-rdcleanpath",
|
||||
"ironrdp-rdpfile",
|
||||
"js-sys",
|
||||
"png",
|
||||
"resize",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<String> {
|
||||
self.0.get::<&str>(key).map(|str| str.to_owned())
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = "getInt")]
|
||||
pub fn get_int(&self, key: &str) -> Option<i32> {
|
||||
self.0.get::<i32>(key)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ extern crate tracing;
|
||||
|
||||
mod canvas;
|
||||
mod clipboard;
|
||||
mod config_parser;
|
||||
mod error;
|
||||
mod image;
|
||||
mod input;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user