refact: file copy&paste, cross platform (no macOS) (#10671)

* feat: unix, file copy&paste

Signed-off-by: fufesou <linlong1266@gmail.com>

* refact: unix file c&p, check peer version

Signed-off-by: fufesou <linlong1266@gmail.com>

* Update pubspec.yaml

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
fufesou
2025-02-04 20:33:02 +08:00
committed by GitHub
parent a27fa43081
commit fbba8f0b34
42 changed files with 2026 additions and 1778 deletions

View File

@@ -174,6 +174,13 @@ class Header: Reactor.Component {
}
}
var is_file_copy_paste_supported = false;
if (handler.version_cmp(pi.version, '1.2.4') < 0) {
is_file_copy_paste_supported = is_win && pi.platform == "Windows";
} else {
is_file_copy_paste_supported = handler.has_file_clipboard() && pi.platform_additions.has_file_clipboard;
}
return <popup>
<menu.context #display-options>
<li #adjust-window style="display:none">{translate('Adjust Window')}</li>
@@ -201,7 +208,7 @@ class Header: Reactor.Component {
{<li #follow-remote-window .toggle-option><span>{svg_checkmark}</span>{translate('Follow remote window focus')}</li>}
<li #show-quality-monitor .toggle-option><span>{svg_checkmark}</span>{translate('Show quality monitor')}</li>
{audio_enabled ? <li #disable-audio .toggle-option><span>{svg_checkmark}</span>{translate('Mute')}</li> : ""}
{(is_win && pi.platform == "Windows") && file_enabled ? <li #enable-file-copy-paste .toggle-option><span>{svg_checkmark}</span>{translate('Enable file copy and paste')}</li> : ""}
{is_file_copy_paste_supported && file_enabled ? <li #enable-file-copy-paste .toggle-option><span>{svg_checkmark}</span>{translate('Enable file copy and paste')}</li> : ""}
{keyboard_enabled && clipboard_enabled ? <li #disable-clipboard .toggle-option><span>{svg_checkmark}</span>{translate('Disable clipboard')}</li> : ""}
{keyboard_enabled ? <li #lock-after-session-end .toggle-option><span>{svg_checkmark}</span>{translate('Lock after session end')}</li> : ""}
{keyboard_enabled && pi.platform == "Windows" ? <li #privacy-mode><span>{svg_checkmark}</span>{translate('Privacy mode')}</li> : ""}

View File

@@ -66,6 +66,39 @@ impl SciterHandler {
}
displays_value
}
fn make_platform_additions(data: &str) -> Option<Value> {
if let Ok(v2) = serde_json::from_str::<HashMap<String, serde_json::Value>>(data) {
let mut value = Value::map();
for (k, v) in v2 {
match v {
serde_json::Value::String(s) => {
value.set_item(k, s);
}
serde_json::Value::Number(n) => {
if let Some(n) = n.as_i64() {
value.set_item(k, n as i32);
} else if let Some(n) = n.as_f64() {
value.set_item(k, n);
}
}
serde_json::Value::Bool(b) => {
value.set_item(k, b);
}
_ => {
// ignore for now
}
}
}
if value.len() > 0 {
return Some(value);
} else {
None
}
} else {
None
}
}
}
impl InvokeUiSession for SciterHandler {
@@ -245,6 +278,9 @@ impl InvokeUiSession for SciterHandler {
pi_sciter.set_item("displays", Self::make_displays_array(&pi.displays));
pi_sciter.set_item("current_display", pi.current_display);
pi_sciter.set_item("version", pi.version.clone());
if let Some(v) = Self::make_platform_additions(&pi.platform_additions) {
pi_sciter.set_item("platform_additions", v);
}
self.call("updatePi", &make_args!(pi_sciter));
}
@@ -500,6 +536,7 @@ impl sciter::EventHandler for SciterSession {
fn version_cmp(String, String);
fn set_selected_windows_session_id(String);
fn is_recording();
fn has_file_clipboard();
}
}
@@ -607,6 +644,10 @@ impl SciterSession {
self.send_selected_session_id(u_sid);
}
fn has_file_clipboard(&self) -> bool {
cfg!(any(target_os = "windows", feature = "unix-file-copy-paste"))
}
fn get_port_forwards(&mut self) -> Value {
let port_forwards = self.lc.read().unwrap().port_forwards.clone();
let mut v = Value::array(0);