Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

patch: don't show enable file clipboard when anyone unsupporting

ClSlaid7aee76f5dee6
diff --git a/flutter/lib/common/widgets/toolbar.dart b/flutter/lib/common/widgets/toolbar.dart
index 17c8883a5..0bead716f 100644
--- a/flutter/lib/common/widgets/toolbar.dart
+++ b/flutter/lib/common/widgets/toolbar.dart
@@ -436,7 +436,9 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
child: Text(translate('Mute'))));
}
// file copy and paste
- if (perms['file'] != false) {
+ if (perms['file'] != false &&
+ bind.mainHasFileClipboard() &&
+ pi.platformAdditions.containsKey(kPlatformAdditionsHasFileClipboard)) {
final option = 'enable-file-transfer';
final value =
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart
index 073edbfec..460894c31 100644
--- a/flutter/lib/consts.dart
+++ b/flutter/lib/consts.dart
@@ -22,6 +22,7 @@ const String kPlatformAdditionsIsWayland = "is_wayland";
const String kPlatformAdditionsHeadless = "headless";
const String kPlatformAdditionsIsInstalled = "is_installed";
const String kPlatformAdditionsVirtualDisplays = "virtual_displays";
+const String kPlatformAdditionsHasFileClipboard = "has_file_clipboard";
const String kPeerPlatformWindows = "Windows";
const String kPeerPlatformLinux = "Linux";
diff --git a/libs/hbb_common/protos/message.proto b/libs/hbb_common/protos/message.proto
index 438206966..454bc0d3d 100644
--- a/libs/hbb_common/protos/message.proto
+++ b/libs/hbb_common/protos/message.proto
@@ -104,7 +104,6 @@ message PeerInfo {
// Use JSON's key-value format which is friendly for peer to handle.
// NOTE: Only support one-level dictionaries (for peer to update), and the key is of type string.
string platform_additions = 12;
- bool has_file_clipboard = 13;
}
message LoginResponse {
diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs
index 872d782d8..dc4a904d4 100644
--- a/src/flutter_ffi.rs
+++ b/src/flutter_ffi.rs
@@ -1725,6 +1725,17 @@ pub fn main_use_texture_render() -> SyncReturn<bool> {
}
}
+pub fn main_has_file_clipboard() -> SyncReturn<bool> {
+ let ret = cfg!(any(
+ target_os = "windows",
+ all(
+ feature = "unix-file-copy-paste",
+ any(target_os = "linux", target_os = "macos")
+ )
+ ));
+ SyncReturn(ret)
+}
+
pub fn cm_init() {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
crate::flutter::connection_manager::cm_init();
diff --git a/src/server/connection.rs b/src/server/connection.rs
index 8927eaf11..9601f3ca9 100644
--- a/src/server/connection.rs
+++ b/src/server/connection.rs
@@ -1019,13 +1019,6 @@ impl Connection {
let mut pi = PeerInfo {
username: username.clone(),
version: VERSION.to_owned(),
- has_file_clipboard: cfg!(any(
- target_os = "windows",
- all(
- feature = "unix-file-copy-paste",
- any(target_os = "linux", target_os = "macos")
- )
- )),
..Default::default()
};
@@ -1069,7 +1062,18 @@ impl Connection {
}
}
- #[cfg(any(target_os = "linux", target_os = "windows"))]
+ #[cfg(any(
+ target_os = "windows",
+ all(
+ any(target_os = "linux", target_os = "macos"),
+ feature = "unix-file-copy-paste"
+ )
+ ))]
+ {
+ platform_additions.insert("has_file_clipboard".into(), json!(true));
+ }
+
+ #[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
if !platform_additions.is_empty() {
pi.platform_additions = serde_json::to_string(&platform_additions).unwrap_or("".into());
}
diff --git a/src/server/display_service.rs b/src/server/display_service.rs
index 22103f790..30225e491 100644
--- a/src/server/display_service.rs
+++ b/src/server/display_service.rs
@@ -153,13 +153,6 @@ pub fn new() -> GenericService {
fn displays_to_msg(displays: Vec<DisplayInfo>) -> Message {
let mut pi = PeerInfo {
- has_file_clipboard: cfg!(any(
- target_os = "windows",
- all(
- feature = "unix-file-copy-paste",
- any(target_os = "linux", target_os = "macos")
- )
- )),
..Default::default()
};
pi.displays = displays.clone();
diff --git a/src/ui/header.tis b/src/ui/header.tis
index e0af9eed7..b0b21bc5e 100644
--- a/src/ui/header.tis
+++ b/src/ui/header.tis
@@ -196,7 +196,7 @@ class Header: Reactor.Component {
{!cursor_embedded && <li #show-remote-cursor .toggle-option><span>{svg_checkmark}</span>{translate('Show remote cursor')}</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")||(is_linux && pi.platform == "Linux")) && file_enabled ? <li #enable-file-transfer .toggle-option><span>{svg_checkmark}</span>{translate('Allow file copy and paste')}</li> : ""}
+ {(is_win && pi.platform == "Windows") && file_enabled ? <li #enable-file-transfer .toggle-option><span>{svg_checkmark}</span>{translate('Allow 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> : ""}
diff --git a/src/ui_interface.rs b/src/ui_interface.rs
index d60220634..5379b4a55 100644
--- a/src/ui_interface.rs
+++ b/src/ui_interface.rs
@@ -1008,6 +1008,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
#[cfg(not(feature = "flutter"))]
let mut id = "".to_owned();
#[cfg(any(target_os = "windows", target_os = "linux"))]
+ #[allow(unused_mut, dead_code)]
let mut enable_file_transfer = "".to_owned();
loop {