From d528fd37628377617b93b8d8d41d7c949439417c Mon Sep 17 00:00:00 2001 From: 21pages Date: Sun, 5 Nov 2023 21:53:21 +0800 Subject: [PATCH] permisson block input Signed-off-by: 21pages --- flutter/lib/common/widgets/toolbar.dart | 1 + .../desktop/pages/desktop_setting_page.dart | 4 +++ flutter/lib/desktop/pages/server_page.dart | 31 ++++++++++++++----- flutter/lib/models/server_model.dart | 3 ++ libs/hbb_common/protos/message.proto | 1 + src/client/io_loop.rs | 3 ++ src/ipc.rs | 1 + src/lang/ar.rs | 2 ++ src/lang/ca.rs | 2 ++ src/lang/cn.rs | 2 ++ src/lang/cs.rs | 2 ++ src/lang/da.rs | 2 ++ src/lang/de.rs | 2 ++ src/lang/el.rs | 2 ++ src/lang/eo.rs | 2 ++ src/lang/es.rs | 2 ++ src/lang/fa.rs | 2 ++ src/lang/fr.rs | 2 ++ src/lang/hu.rs | 2 ++ src/lang/id.rs | 2 ++ src/lang/it.rs | 2 ++ src/lang/ja.rs | 2 ++ src/lang/ko.rs | 2 ++ src/lang/kz.rs | 2 ++ src/lang/lt.rs | 2 ++ src/lang/lv.rs | 2 ++ src/lang/nl.rs | 2 ++ src/lang/pl.rs | 2 ++ src/lang/pt_PT.rs | 2 ++ src/lang/ptbr.rs | 2 ++ src/lang/ro.rs | 2 ++ src/lang/ru.rs | 2 ++ src/lang/sk.rs | 2 ++ src/lang/sl.rs | 2 ++ src/lang/sq.rs | 2 ++ src/lang/sr.rs | 2 ++ src/lang/sv.rs | 2 ++ src/lang/template.rs | 2 ++ src/lang/th.rs | 2 ++ src/lang/tr.rs | 2 ++ src/lang/tw.rs | 2 ++ src/lang/ua.rs | 2 ++ src/lang/vn.rs | 2 ++ src/server/connection.rs | 24 ++++++++++++-- src/ui/cm.css | 4 +++ src/ui/cm.rs | 3 +- src/ui/cm.tis | 13 +++++++- src/ui/index.tis | 1 + src/ui_cm_interface.rs | 9 ++++-- 49 files changed, 157 insertions(+), 13 deletions(-) diff --git a/flutter/lib/common/widgets/toolbar.dart b/flutter/lib/common/widgets/toolbar.dart index dbbcf9a90..44af82eb4 100644 --- a/flutter/lib/common/widgets/toolbar.dart +++ b/flutter/lib/common/widgets/toolbar.dart @@ -191,6 +191,7 @@ List toolbarControls(BuildContext context, String id, FFI ffi) { } // blockUserInput if (ffi.ffiModel.keyboard && + ffi.ffiModel.permissions['block_input'] != false && pi.platform == kPeerPlatformWindows) // privacy-mode != true ?? { v.add(TTextMenu( diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 5399d272b..a12830e63 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -649,6 +649,10 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { _OptionCheckBox( context, 'Enable Recording Session', 'enable-record-session', enabled: enabled, fakeValue: fakeValue), + if (Platform.isWindows) + _OptionCheckBox( + context, 'Enable Block User Input', 'enable-block-input', + enabled: enabled, fakeValue: fakeValue), _OptionCheckBox(context, 'Enable remote configuration modification', 'allow-remote-config-modification', enabled: enabled, fakeValue: fakeValue), diff --git a/flutter/lib/desktop/pages/server_page.dart b/flutter/lib/desktop/pages/server_page.dart index ebad74bcc..3439aa58d 100644 --- a/flutter/lib/desktop/pages/server_page.dart +++ b/flutter/lib/desktop/pages/server_page.dart @@ -536,7 +536,6 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> { child: Icon( iconData, color: Colors.white, - size: 32, ), ), ], @@ -548,9 +547,11 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> { @override Widget build(BuildContext context) { + final crossAxisCount = 4; + final spacing = 10.0; return Container( width: double.infinity, - height: 200.0, + height: 160.0, margin: EdgeInsets.all(5.0), padding: EdgeInsets.all(5.0), decoration: BoxDecoration( @@ -575,10 +576,10 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> { ).marginOnly(left: 4.0, bottom: 8.0), Expanded( child: GridView.count( - crossAxisCount: 3, - padding: EdgeInsets.symmetric(horizontal: 20.0), - mainAxisSpacing: 20.0, - crossAxisSpacing: 20.0, + crossAxisCount: crossAxisCount, + padding: EdgeInsets.symmetric(horizontal: spacing), + mainAxisSpacing: spacing, + crossAxisSpacing: spacing, children: [ buildPermissionIcon( client.keyboard, @@ -651,7 +652,23 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> { }); }, translate('Allow recording session'), - ) + ), + // only windows support block input + if (Platform.isWindows) + buildPermissionIcon( + client.blockInput, + Icons.block, + (enabled) { + bind.cmSwitchPermission( + connId: client.id, + name: "block_input", + enabled: enabled); + setState(() { + client.blockInput = enabled; + }); + }, + translate('Allow block user input'), + ) ], ), ), diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dart index 4c17632f5..1422596c2 100644 --- a/flutter/lib/models/server_model.dart +++ b/flutter/lib/models/server_model.dart @@ -690,6 +690,7 @@ class Client { bool file = false; bool restart = false; bool recording = false; + bool blockInput = false; bool disconnected = false; bool fromSwitch = false; bool inVoiceCall = false; @@ -713,6 +714,7 @@ class Client { file = json['file']; restart = json['restart']; recording = json['recording']; + blockInput = json['block_input']; disconnected = json['disconnected']; fromSwitch = json['from_switch']; inVoiceCall = json['in_voice_call']; @@ -733,6 +735,7 @@ class Client { data['file'] = file; data['restart'] = restart; data['recording'] = recording; + data['block_input'] = blockInput; data['disconnected'] = disconnected; data['from_switch'] = fromSwitch; return data; diff --git a/libs/hbb_common/protos/message.proto b/libs/hbb_common/protos/message.proto index fc531b44b..5fddf2cd4 100644 --- a/libs/hbb_common/protos/message.proto +++ b/libs/hbb_common/protos/message.proto @@ -526,6 +526,7 @@ message PermissionInfo { File = 4; Restart = 5; Recording = 6; + BlockInput = 7; } Permission permission = 1; diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index d3a6e727d..a65e3c626 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -1347,6 +1347,9 @@ impl Remote { Ok(Permission::Recording) => { self.handler.set_permission("recording", p.enabled); } + Ok(Permission::BlockInput) => { + self.handler.set_permission("block_input", p.enabled); + } _ => {} } } diff --git a/src/ipc.rs b/src/ipc.rs index 43cf96b79..aea90a498 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -177,6 +177,7 @@ pub enum Data { file_transfer_enabled: bool, restart: bool, recording: bool, + block_input: bool, from_switch: bool, }, ChatMessage { diff --git a/src/lang/ar.rs b/src/lang/ar.rs index a03dd87c2..30337f163 100644 --- a/src/lang/ar.rs +++ b/src/lang/ar.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ca.rs b/src/lang/ca.rs index 0294842b7..46b952f03 100644 --- a/src/lang/ca.rs +++ b/src/lang/ca.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index 0b76f3cb8..0107b7aab 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "虚拟显示器"), ("Plug out all", "拔出所有"), ("True color (4:4:4)", "真彩模式(4:4:4)"), + ("Enable Block User Input", "允许阻止用户输入"), + ("Allow block user input", "允许阻止用户输入"), ].iter().cloned().collect(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index fcefa89b1..fe2da8ee8 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Virtuální obrazovka"), ("Plug out all", "Odpojit všechny"), ("True color (4:4:4)", "Skutečné barvy (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index 86cc133ea..4fc782fd7 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index 80a15d4f2..a8872456b 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Virtueller Bildschirm"), ("Plug out all", "Alle ausschalten"), ("True color (4:4:4)", "True Color (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/el.rs b/src/lang/el.rs index a82dc99ea..92bf66fb3 100644 --- a/src/lang/el.rs +++ b/src/lang/el.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 48ed83bb0..75833d00b 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index 854a0fb59..158976fdc 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Pantalla virtual"), ("Plug out all", "Desconectar todo"), ("True color (4:4:4)", "Color real (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index 326c9779e..d62992213 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index eea7fcd6d..656a6e66e 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index 28530e490..9af47821f 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index f03d1ccd6..bef96953b 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Tampilan virtual"), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index 25a33fbce..1e98c1d1e 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Scehrmo virtuale"), ("Plug out all", "Scollega tutto"), ("True color (4:4:4)", "Colore reale (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index 486d5f07a..c9ada9d19 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index ce3c06838..9ba509b1a 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "가상 디스플레이"), ("Plug out all", "모두 플러그 아웃"), ("True color (4:4:4)", "트루컬러(4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index e37a6e34e..10c285f15 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/lt.rs b/src/lang/lt.rs index 4911137af..a1b1c276a 100644 --- a/src/lang/lt.rs +++ b/src/lang/lt.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/lv.rs b/src/lang/lv.rs index 0a0c7c6b2..4a82b7bba 100644 --- a/src/lang/lv.rs +++ b/src/lang/lv.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Virtuālais displejs"), ("Plug out all", "Atvienot visu"), ("True color (4:4:4)", "Īstā krāsa (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/nl.rs b/src/lang/nl.rs index a3715cea6..e2baa3673 100644 --- a/src/lang/nl.rs +++ b/src/lang/nl.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 76e393fe1..067f6673a 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Witualne ekrany"), ("Plug out all", "Odłącz wszystko"), ("True color (4:4:4)", "True color (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 9464dbb16..0c518ac2a 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index 394df5cad..ac03ad131 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ro.rs b/src/lang/ro.rs index 7e67702eb..0fb30fc58 100644 --- a/src/lang/ro.rs +++ b/src/lang/ro.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index ea6592d91..bdb07a9ba 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Виртуальный дисплей"), ("Plug out all", "Отключить все"), ("True color (4:4:4)", "Истинный цвет (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 2a54559f9..8f0373838 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Virtuálny displej"), ("Plug out all", "Odpojiť všetky"), ("True color (4:4:4)", "Skutočná farba (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sl.rs b/src/lang/sl.rs index 4f7c2dae0..d10bd15d2 100755 --- a/src/lang/sl.rs +++ b/src/lang/sl.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sq.rs b/src/lang/sq.rs index a8135d586..6811fb14a 100644 --- a/src/lang/sq.rs +++ b/src/lang/sq.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sr.rs b/src/lang/sr.rs index faf5d1d55..38fed8145 100644 --- a/src/lang/sr.rs +++ b/src/lang/sr.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sv.rs b/src/lang/sv.rs index 78facf447..775d2405c 100644 --- a/src/lang/sv.rs +++ b/src/lang/sv.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index 5069d56a2..1ca50acfb 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/th.rs b/src/lang/th.rs index c09610b98..74b550428 100644 --- a/src/lang/th.rs +++ b/src/lang/th.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index 26e8f84eb..6e86efb27 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index 941019245..37bbf5c80 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index cb508cf25..3cdd32202 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", "Віртуальний дисплей"), ("Plug out all", "Відключити все"), ("True color (4:4:4)", "Спражній колір (4:4:4)"), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 39b3950d7..1360e2d99 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -573,5 +573,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Virtual display", ""), ("Plug out all", ""), ("True color (4:4:4)", ""), + ("Enable Block User Input", ""), + ("Allow block user input", ""), ].iter().cloned().collect(); } diff --git a/src/server/connection.rs b/src/server/connection.rs index 1d330aa9a..842359b51 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -180,6 +180,7 @@ pub struct Connection { file: bool, restart: bool, recording: bool, + block_input: bool, last_test_delay: i64, network_delay: Option, lock_after_session_end: bool, @@ -326,6 +327,7 @@ impl Connection { file: Connection::permission("enable-file-transfer"), restart: Connection::permission("enable-remote-restart"), recording: Connection::permission("enable-record-session"), + block_input: Connection::permission("enable-block-input"), last_test_delay: 0, network_delay: None, lock_after_session_end: false, @@ -396,6 +398,9 @@ impl Connection { if !conn.recording { conn.send_permission(Permission::Recording, false).await; } + if !conn.block_input { + conn.send_permission(Permission::BlockInput, false).await; + } let mut test_delay_timer = time::interval_at(Instant::now() + TEST_DELAY_TIMEOUT, TEST_DELAY_TIMEOUT); let mut last_recv_time = Instant::now(); @@ -477,6 +482,9 @@ impl Connection { } else if &name == "recording" { conn.recording = enabled; conn.send_permission(Permission::Recording, enabled).await; + } else if &name == "block_input" { + conn.block_input = enabled; + conn.send_permission(Permission::BlockInput, enabled).await; } } ipc::Data::RawMessage(bytes) => { @@ -1271,6 +1279,7 @@ impl Connection { file_transfer_enabled: self.file, restart: self.restart, recording: self.recording, + block_input: self.block_input, from_switch: self.from_switch, }); } @@ -2525,8 +2534,8 @@ impl Connection { } } } - if self.keyboard { - if let Ok(q) = o.block_input.enum_value() { + if let Ok(q) = o.block_input.enum_value() { + if self.keyboard && self.block_input { match q { BoolOption::Yes => { self.tx_input.send(MessageInput::BlockOn).ok(); @@ -2536,6 +2545,17 @@ impl Connection { } _ => {} } + } else { + if q != BoolOption::NotSet { + let state = if q == BoolOption::Yes { + back_notification::BlockInputState::BlkOnFailed + } else { + back_notification::BlockInputState::BlkOffFailed + }; + if let Some(tx) = &self.inner.tx { + Self::send_block_input_error(tx, state, "No permission".to_string()); + } + } } } } diff --git a/src/ui/cm.css b/src/ui/cm.css index 960c8b567..d817f40a0 100644 --- a/src/ui/cm.css +++ b/src/ui/cm.css @@ -112,6 +112,10 @@ icon.recording { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAANpJREFUWEftltENAiEMhtsJ1NcynG6gI+gGugEOR591gppeQoIYSDBILxEeydH/57u2FMF4obE+TAOTwLoIhBDOAHBExG2n6rgR0akW640AM0sn4SWMiDycc7s8JjN7Ijro/k8NqAAR5RoeAPZxv2ggP9hCJiWZxtGbq3hqbJiBVHy4gVx8qAER8Yi4JFy6huVAKXemgb8icI+1b5KEitq0DOO/Nm1EEX1TK27p/bVvv36MOhl4EtHHbFF7jq8AoG1z08OAiFycczrkFNe6RrIet26NMQlMAuYEXiayryF/QQktAAAAAElFTkSuQmCC'); } +icon.block_input { + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjdJREFUWEe1V8tNAzEQfXOHAx2QG0UgQSqBFIIgHdABoQqOhBq4cCMlcMh90FvZq/HEXtvJxlKUZNceP783no+gY6jqNYBHAHcA+JufXTDBb37eRWTbalZqE82mz7W55v0ABMBGRCLA7PJJAKr6AiC3sT11NHyf2SEyQjvtAMKp3wBYo9VTGbYegjxxU65d5tg4YEBVbwF8ALgw2lLX4in80QqyZUEkAMLCb7P5n4hcdWifTA32Pg0bByA8AE4+oL3n9A1s7ERkEeeNAJzD/QC4OVaCAgjrU7wdK86zAHREJSKqyvvORRxVb67JFOT4NfYGpxwAqCo34oYcKxHZhOdzg7D2BhYigHj6RJ+5QbjrPezlqR61sZTOKYfztSUBWPoXpdA5FwjnC2sCGK+eiNRC8yw+oap0RiayLQHEPwf65zx7DibMoXcEEB0wq/85QJQAbEVkWbvP8f0pTFi/65ZgjtuRyJ7QYWL0OZnwTmiLDobH5nLqGDlUlcmON49jQwnsg/Wxma/VJ1zcGQIR7+OYJGyqbJWhhwlDPxh3JpNRL4Ba7nAsJckoYaFUv7UCyslBvQ3TNDWEfVsPJGH2FCkKTPAxD8ox+poFwJfZqqX15H6eYyK+TgJeriidLCJ7wAQHZ4Udy7u9iFxaG7mynEx4EF1leZDANzV7AE8i8joJICz2cvBxbExIYTZYTTQmxTxTzP+VnvC8rZlLOLEj7m5OW6JqtTs2US6247Hvy7XnX0OV05FP/gHde5fLZaGS8AAAAABJRU5ErkJggg=='); +} + div.outer_buttons { flow:vertical; border-spacing:8; diff --git a/src/ui/cm.rs b/src/ui/cm.rs index 56a01b946..c8c8c657f 100644 --- a/src/ui/cm.rs +++ b/src/ui/cm.rs @@ -28,7 +28,8 @@ impl InvokeUiCM for SciterHandler { client.audio, client.file, client.restart, - client.recording + client.recording, + client.block_input ), ); } diff --git a/src/ui/cm.tis b/src/ui/cm.tis index 4e46e217f..abbb5465a 100644 --- a/src/ui/cm.tis +++ b/src/ui/cm.tis @@ -57,6 +57,7 @@ class Body: Reactor.Component
+
} {c.port_forward ?
Port Forwarding: {c.port_forward}
: ""} @@ -143,6 +144,15 @@ class Body: Reactor.Component }); } + event click $(icon.block_input) { + var { cid, connection } = this; + checkClickTime(function() { + connection.block_input = !connection.block_input; + body.update(); + handler.switch_permission(cid, "block_input", connection.block_input); + }); + } + event click $(button#accept) { var { cid, connection } = this; checkClickTime(function() { @@ -346,7 +356,7 @@ function bring_to_top(idx=-1) { } } -handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording) { +handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, block_input) { stdout.println("new connection #" + id + ": " + peer_id); var conn; connections.map(function(c) { @@ -368,6 +378,7 @@ handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, na name: name, authorized: authorized, time: new Date(), now: new Date(), keyboard: keyboard, clipboard: clipboard, msgs: [], unreaded: 0, audio: audio, file: file, restart: restart, recording: recording, + block_input:block_input, disconnected: false }; if (idx < 0) { diff --git a/src/ui/index.tis b/src/ui/index.tis index 7a46e3b3f..ea4338902 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -306,6 +306,7 @@ class MyIdMenu: Reactor.Component {
  • {svg_checkmark}{translate('Enable File Transfer')}
  • {svg_checkmark}{translate('Enable Remote Restart')}
  • {svg_checkmark}{translate('Enable TCP Tunneling')}
  • + {is_win ?
  • {svg_checkmark}{translate('Enable Block User Input')}
  • : ""}
  • {svg_checkmark}{translate('Enable LAN Discovery')}
  • diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs index f259d61bd..b8de4fd82 100644 --- a/src/ui_cm_interface.rs +++ b/src/ui_cm_interface.rs @@ -53,6 +53,7 @@ pub struct Client { pub file: bool, pub restart: bool, pub recording: bool, + pub block_input: bool, pub from_switch: bool, pub in_voice_call: bool, pub incoming_voice_call: bool, @@ -133,6 +134,7 @@ impl ConnectionManager { file: bool, restart: bool, recording: bool, + block_input: bool, from_switch: bool, #[cfg(not(any(target_os = "ios")))] tx: mpsc::UnboundedSender, ) { @@ -150,6 +152,7 @@ impl ConnectionManager { file, restart, recording, + block_input, from_switch, #[cfg(not(any(target_os = "ios")))] tx, @@ -378,9 +381,9 @@ impl IpcTaskRunner { } Ok(Some(data)) => { match data { - Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled: _file_transfer_enabled, restart, recording, from_switch} => { + Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled: _file_transfer_enabled, restart, recording, block_input, from_switch} => { log::debug!("conn_id: {}", id); - self.cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, from_switch,self.tx.clone()); + self.cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, block_input, from_switch, self.tx.clone()); self.conn_id = id; #[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))] { @@ -632,6 +635,7 @@ pub async fn start_listen( file, restart, recording, + block_input, from_switch, .. }) => { @@ -649,6 +653,7 @@ pub async fn start_listen( file, restart, recording, + block_input, from_switch, tx.clone(), );