mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-12-04 15:46:07 +00:00
feat: add custom client options to hide session toolbar actions and menus (#17318)
* feat(toolbar): hide OS password and skip saved password auto-login Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding Send clipboard keystrokes Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding View camera Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding Terminal (beta) Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding TCP tunneling Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding Switch Sides Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding Take screenshot Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding Voice call while keeping text chat Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding the Display Settings menu Signed-off-by: 21pages <sunboeasy@gmail.com> * feat(toolbar): allow hiding the Keyboard Settings menu Signed-off-by: 21pages <sunboeasy@gmail.com> --------- Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
1 parent
68bf4ebe58
commit
8337837469
11 files changed
+309
-59
No files matched your search
@@ -476,7 +476,9 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
);
|
||||
}
|
||||
// osPassword
|
||||
if (isDefaultConn && perms['keyboard'] != false) {
|
||||
if (isDefaultConn &&
|
||||
perms['keyboard'] != false &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarOsPassword) != 'Y') {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Row(children: [
|
||||
@@ -501,7 +503,9 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
// paste
|
||||
if (isDefaultConn &&
|
||||
pi.platform != kPeerPlatformAndroid &&
|
||||
perms['keyboard'] != false) {
|
||||
perms['keyboard'] != false &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarSendClipboardKeystrokes) !=
|
||||
'Y') {
|
||||
v.add(TTextMenu(
|
||||
child: Text(translate('Send clipboard keystrokes')),
|
||||
onPressed: () async {
|
||||
@@ -595,21 +599,27 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
child: Text(translate('Transfer file')),
|
||||
onPressed: () => connectWithToken(isFileTransfer: true)),
|
||||
);
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('View camera')),
|
||||
onPressed: () => connectWithToken(isViewCamera: true)),
|
||||
);
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text('${translate('Terminal')} (beta)'),
|
||||
onPressed: () => connectWithToken(isTerminal: true)),
|
||||
);
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('TCP tunneling')),
|
||||
onPressed: () => connectWithToken(isTcpTunneling: true)),
|
||||
);
|
||||
if (bind.mainGetBuildinOption(key: kOptionHideToolbarViewCamera) != 'Y') {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('View camera')),
|
||||
onPressed: () => connectWithToken(isViewCamera: true)),
|
||||
);
|
||||
}
|
||||
if (bind.mainGetBuildinOption(key: kOptionHideToolbarTerminal) != 'Y') {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text('${translate('Terminal')} (beta)'),
|
||||
onPressed: () => connectWithToken(isTerminal: true)),
|
||||
);
|
||||
}
|
||||
if (bind.mainGetBuildinOption(key: kOptionHideToolbarTcpTunneling) != 'Y') {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('TCP tunneling')),
|
||||
onPressed: () => connectWithToken(isTcpTunneling: true)),
|
||||
);
|
||||
}
|
||||
}
|
||||
// note
|
||||
if (isDefaultConn && !bind.isDisableAccount()) {
|
||||
@@ -697,6 +707,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
ffiModel.keyboard &&
|
||||
pi.platform != kPeerPlatformAndroid &&
|
||||
versionCmp(pi.version, '1.2.0') >= 0 &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarSwitchSides) != 'Y' &&
|
||||
bind.peerGetSessionsCount(id: id, connType: ffi.connType.index) == 1) {
|
||||
v.add(TTextMenu(
|
||||
child: Text(translate('Switch Sides')),
|
||||
@@ -739,7 +750,9 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
// to-do:
|
||||
// 1. Web desktop
|
||||
// 2. Mobile, copy the image to the clipboard
|
||||
if ((isDefaultConn || ffi.connType == ConnType.viewCamera) && isDesktop) {
|
||||
if ((isDefaultConn || ffi.connType == ConnType.viewCamera) &&
|
||||
isDesktop &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarScreenshot) != 'Y') {
|
||||
final isScreenshotSupported = bind.sessionGetCommonSync(
|
||||
sessionId: sessionId, key: 'is_screenshot_supported', param: '');
|
||||
if ('true' == isScreenshotSupported) {
|
||||
@@ -1202,12 +1215,16 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
|
||||
child: Text(translate('True color (4:4:4)'))));
|
||||
}
|
||||
|
||||
if (isDefaultConn && isMobile) {
|
||||
final showMobileKeyboardSettings = isDefaultConn &&
|
||||
isMobile &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarKeyboardSettings) !=
|
||||
'Y';
|
||||
if (showMobileKeyboardSettings) {
|
||||
v.addAll(toolbarKeyboardToggles(ffi));
|
||||
}
|
||||
|
||||
// view mode (mobile only, desktop is in keyboard menu)
|
||||
if (isDefaultConn && isMobile && versionCmp(pi.version, '1.2.0') >= 0) {
|
||||
if (showMobileKeyboardSettings && versionCmp(pi.version, '1.2.0') >= 0) {
|
||||
v.add(TToggleMenu(
|
||||
value: ffiModel.viewOnly,
|
||||
onChanged: (value) async {
|
||||
|
||||
@@ -209,6 +209,19 @@ const String kOptionHideProxySetting = "hide-proxy-settings";
|
||||
const String kOptionHideWebSocketSetting = "hide-websocket-settings";
|
||||
const String kOptionHideStopService = "hide-stop-service";
|
||||
const String kOptionHideAccountPasswordLogin = "hide-account-password-login";
|
||||
const String kOptionHideToolbarOsPassword = "hide-toolbar-os-password";
|
||||
const String kOptionHideToolbarSendClipboardKeystrokes =
|
||||
"hide-toolbar-send-clipboard-keystrokes";
|
||||
const String kOptionHideToolbarViewCamera = "hide-toolbar-view-camera";
|
||||
const String kOptionHideToolbarTerminal = "hide-toolbar-terminal";
|
||||
const String kOptionHideToolbarTcpTunneling = "hide-toolbar-tcp-tunneling";
|
||||
const String kOptionHideToolbarSwitchSides = "hide-toolbar-switch-sides";
|
||||
const String kOptionHideToolbarScreenshot = "hide-toolbar-screenshot";
|
||||
const String kOptionHideToolbarVoiceCall = "hide-toolbar-voice-call";
|
||||
const String kOptionHideToolbarDisplaySettings =
|
||||
"hide-toolbar-display-settings";
|
||||
const String kOptionHideToolbarKeyboardSettings =
|
||||
"hide-toolbar-keyboard-settings";
|
||||
const String kOptionQuitButtonText = "quit-button-text";
|
||||
const String kOptionHideRemotePrinterSetting = "hide-remote-printer-settings";
|
||||
const String kOptionHideGeneralSetting = "hide-general-settings";
|
||||
|
||||
@@ -836,14 +836,19 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
|
||||
|
||||
toolbarItems
|
||||
.add(_ControlMenu(id: widget.id, ffi: widget.ffi, state: widget.state));
|
||||
toolbarItems.add(_DisplayMenu(
|
||||
id: widget.id,
|
||||
ffi: widget.ffi,
|
||||
state: widget.state,
|
||||
setFullscreen: _setFullscreen,
|
||||
));
|
||||
if (bind.mainGetBuildinOption(key: kOptionHideToolbarDisplaySettings) !=
|
||||
'Y') {
|
||||
toolbarItems.add(_DisplayMenu(
|
||||
id: widget.id,
|
||||
ffi: widget.ffi,
|
||||
state: widget.state,
|
||||
setFullscreen: _setFullscreen,
|
||||
));
|
||||
}
|
||||
// Do not show keyboard for camera connection type.
|
||||
if (widget.ffi.connType == ConnType.defaultConn) {
|
||||
if (widget.ffi.connType == ConnType.defaultConn &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarKeyboardSettings) !=
|
||||
'Y') {
|
||||
toolbarItems.add(_KeyboardMenu(id: widget.id, ffi: widget.ffi));
|
||||
}
|
||||
toolbarItems.add(_ChatMenu(id: widget.id, ffi: widget.ffi));
|
||||
@@ -2836,7 +2841,8 @@ class _ChatMenuState extends State<_ChatMenu> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isWeb) {
|
||||
if (isWeb ||
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarVoiceCall) == 'Y') {
|
||||
return buildTextChatButton();
|
||||
} else {
|
||||
return _IconSubmenuButton(
|
||||
|
||||
@@ -620,14 +620,17 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
||||
clientClose(sessionId, gFFI);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(context, widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
if (bind.mainGetBuildinOption(
|
||||
key: kOptionHideToolbarDisplaySettings) !=
|
||||
'Y')
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(context, widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
(isWebDesktop || ffiModel.viewOnly || !ffiModel.keyboard
|
||||
? []
|
||||
@@ -649,14 +652,17 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.keyboard),
|
||||
onPressed: openKeyboard),
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(gFFI.ffiModel.touchMode
|
||||
? Icons.touch_app
|
||||
: Icons.mouse),
|
||||
onPressed: () => setState(
|
||||
() => _showGestureHelp = !_showGestureHelp),
|
||||
),
|
||||
if (bind.mainGetBuildinOption(
|
||||
key: kOptionHideToolbarKeyboardSettings) !=
|
||||
'Y')
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(gFFI.ffiModel.touchMode
|
||||
? Icons.touch_app
|
||||
: Icons.mouse),
|
||||
onPressed: () => setState(
|
||||
() => _showGestureHelp = !_showGestureHelp),
|
||||
),
|
||||
]) +
|
||||
(isWeb
|
||||
? []
|
||||
@@ -899,6 +905,11 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
|
||||
VoiceCallStatus.waitingForResponse,
|
||||
VoiceCallStatus.connected
|
||||
].contains(gFFI.chatModel.voiceCallStatus.value);
|
||||
if (!isInVoice &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarVoiceCall) == 'Y') {
|
||||
onPressedTextChat(id);
|
||||
return;
|
||||
}
|
||||
final menus = [
|
||||
makeTextMenu('Text chat', Icon(Icons.message, color: MyTheme.accent),
|
||||
() => onPressedTextChat(widget.id)),
|
||||
|
||||
@@ -311,14 +311,17 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
||||
clientClose(sessionId, gFFI);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(context, widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
if (bind.mainGetBuildinOption(
|
||||
key: kOptionHideToolbarDisplaySettings) !=
|
||||
'Y')
|
||||
IconButton(
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(context, widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
(isWeb
|
||||
? []
|
||||
@@ -519,6 +522,11 @@ class _ViewCameraPageState extends State<ViewCameraPage>
|
||||
VoiceCallStatus.waitingForResponse,
|
||||
VoiceCallStatus.connected
|
||||
].contains(gFFI.chatModel.voiceCallStatus.value);
|
||||
if (!isInVoice &&
|
||||
bind.mainGetBuildinOption(key: kOptionHideToolbarVoiceCall) == 'Y') {
|
||||
onPressedTextChat(id);
|
||||
return;
|
||||
}
|
||||
final menus = [
|
||||
makeTextMenu('Text chat', Icon(Icons.message, color: MyTheme.accent),
|
||||
() => onPressedTextChat(widget.id)),
|
||||
|
||||
@@ -21,6 +21,18 @@ import '../models/state_model.dart';
|
||||
|
||||
typedef ShortcutCallback = FutureOr<void> Function();
|
||||
|
||||
Iterable<String> _actionsInGroup(String titleKey) {
|
||||
final groups = kKeyboardShortcutActionGroups.where((g) => g.titleKey == titleKey);
|
||||
return allActionEntries(groups).map((entry) => entry.id);
|
||||
}
|
||||
|
||||
final _toolbarOptionForShortcut = {
|
||||
for (final id in _actionsInGroup('Display'))
|
||||
id: kOptionHideToolbarDisplaySettings,
|
||||
for (final id in _actionsInGroup('Keyboard'))
|
||||
id: kOptionHideToolbarKeyboardSettings,
|
||||
};
|
||||
|
||||
/// Per-session shortcut dispatcher. Attached to FFI when a session is created.
|
||||
///
|
||||
/// The Rust matcher (src/keyboard/shortcuts.rs) emits `shortcut_triggered`
|
||||
@@ -82,6 +94,10 @@ class ShortcutModel {
|
||||
/// belongs to RustDesk and is never forwarded to the remote.
|
||||
void onTriggered(String actionId) {
|
||||
if (parent.target?.closed != false) return;
|
||||
final option = _toolbarOptionForShortcut[actionId];
|
||||
if (option != null && bind.mainGetBuildinOption(key: option) == 'Y') {
|
||||
return;
|
||||
}
|
||||
unawaited(Future.sync(() async {
|
||||
final refresh = _refreshers[actionId];
|
||||
if (refresh != null) {
|
||||
@@ -467,7 +483,8 @@ void registerSessionShortcutActions(
|
||||
if (status == VoiceCallStatus.connected ||
|
||||
status == VoiceCallStatus.waitingForResponse) {
|
||||
bind.sessionCloseVoiceCall(sessionId: sessionId);
|
||||
} else {
|
||||
} else if (bind.mainGetBuildinOption(key: kOptionHideToolbarVoiceCall) !=
|
||||
'Y') {
|
||||
bind.sessionRequestVoiceCall(sessionId: sessionId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,10 +2,12 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dash_chat_2/dash_chat_2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_hbb/common.dart' show SessionID;
|
||||
import 'package:flutter_hbb/common/widgets/keyboard_shortcuts/shortcut_constants.dart';
|
||||
import 'package:flutter_hbb/common/widgets/toolbar.dart';
|
||||
import 'package:flutter_hbb/generated_bridge.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
@@ -40,6 +42,35 @@ class _ChatBinding extends Fake implements RustdeskImpl {
|
||||
}
|
||||
}
|
||||
|
||||
class _ToolbarBinding extends _ChatBinding {
|
||||
String option = '';
|
||||
int voiceCallRequests = 0;
|
||||
@override
|
||||
Future<void> sessionRequestVoiceCall(
|
||||
{required SessionID sessionId, dynamic hint}) async {
|
||||
voiceCallRequests++;
|
||||
}
|
||||
|
||||
@override
|
||||
String mainGetBuildinOption({required String key, dynamic hint}) =>
|
||||
key == option ? 'Y' : '';
|
||||
@override
|
||||
bool isDisableAccount({dynamic hint}) => false;
|
||||
@override
|
||||
int versionToNumber({required String v, dynamic hint}) => 1;
|
||||
@override
|
||||
int peerGetSessionsCount(
|
||||
{required String id, required int connType, dynamic hint}) =>
|
||||
1;
|
||||
@override
|
||||
String? sessionGetCommonSync(
|
||||
{required SessionID sessionId,
|
||||
required String key,
|
||||
required String param,
|
||||
dynamic hint}) =>
|
||||
key == 'is_screenshot_supported' ? 'true' : null;
|
||||
}
|
||||
|
||||
class _Chat extends ChatModel {
|
||||
_Chat(FFI session) : super(WeakReference(session));
|
||||
|
||||
@@ -53,6 +84,9 @@ class _Chat extends ChatModel {
|
||||
}
|
||||
|
||||
class _LegacyBinding extends _ChatBinding {
|
||||
@override
|
||||
String mainGetBuildinOption({required String key, dynamic hint}) => '';
|
||||
|
||||
final keys = <(String, bool, bool)>[];
|
||||
|
||||
@override
|
||||
@@ -120,9 +154,11 @@ class _Session extends Fake implements FFI {
|
||||
@override
|
||||
late final _Chat chatModel = _Chat(this);
|
||||
@override
|
||||
late final ElevationModel elevationModel = ElevationModel(WeakReference(this));
|
||||
@override
|
||||
late ShortcutModel shortcutModel;
|
||||
@override
|
||||
ConnType get connType => ConnType.defaultConn;
|
||||
ConnType connType = ConnType.defaultConn;
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -189,6 +225,92 @@ void main() {
|
||||
}
|
||||
}
|
||||
|
||||
for (final (option, label) in [
|
||||
(kOptionHideToolbarOsPassword, 'OS Password'),
|
||||
(kOptionHideToolbarSendClipboardKeystrokes, 'Send clipboard keystrokes'),
|
||||
(kOptionHideToolbarViewCamera, 'View camera'),
|
||||
(kOptionHideToolbarTerminal, 'Terminal (beta)'),
|
||||
(kOptionHideToolbarTcpTunneling, 'TCP tunneling'),
|
||||
]) {
|
||||
testWidgets('hiding $label leaves file transfer available', (tester) async {
|
||||
final binding = _ToolbarBinding();
|
||||
platformFFI.setBindingForTesting(binding);
|
||||
Future<void> showControls() => tester.pumpWidget(MaterialApp(
|
||||
home: Builder(builder: (context) {
|
||||
return Column(children: [
|
||||
for (final item in toolbarControls(context, session.id, session))
|
||||
item.getChild(),
|
||||
]);
|
||||
}),
|
||||
));
|
||||
|
||||
await showControls();
|
||||
expect(find.text(label), findsOneWidget);
|
||||
binding.option = option;
|
||||
await showControls();
|
||||
expect(find.text(label), findsNothing);
|
||||
expect(find.text('Transfer file'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
for (final (option, action) in [
|
||||
(kOptionHideToolbarSwitchSides, kShortcutActionSwitchSides),
|
||||
(kOptionHideToolbarScreenshot, kShortcutActionScreenshot),
|
||||
]) {
|
||||
testWidgets('hiding $action removes its menu entry', (tester) async {
|
||||
final binding = _ToolbarBinding();
|
||||
platformFFI.setBindingForTesting(binding);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
final context = tester.element(find.byType(SizedBox));
|
||||
bool hasEntry() => toolbarControls(context, session.id, session)
|
||||
.any((item) => item.actionId == action);
|
||||
|
||||
expect(hasEntry(), isTrue);
|
||||
binding.option = option;
|
||||
expect(hasEntry(), isFalse);
|
||||
if (action == kShortcutActionScreenshot) {
|
||||
session.connType = ConnType.viewCamera;
|
||||
expect(hasEntry(), isFalse);
|
||||
binding.option = '';
|
||||
expect(hasEntry(), isTrue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (final (option, action) in [
|
||||
(kOptionHideToolbarDisplaySettings, kShortcutActionToggleMute),
|
||||
(kOptionHideToolbarKeyboardSettings, kShortcutActionKeyboardModeMap),
|
||||
]) {
|
||||
test('$option blocks $action but allows text chat',
|
||||
() async {
|
||||
final binding = _ToolbarBinding();
|
||||
platformFFI.setBindingForTesting(binding);
|
||||
final calls = <String>[];
|
||||
model.register(action, () => calls.add(action));
|
||||
model.register(kShortcutActionToggleChat, () => calls.add('chat'));
|
||||
model.onTriggered(action);
|
||||
await pumpEventQueue();
|
||||
binding.option = option;
|
||||
model.onTriggered(action);
|
||||
model.onTriggered(kShortcutActionToggleChat);
|
||||
await pumpEventQueue();
|
||||
expect(calls, [action, 'chat']);
|
||||
});
|
||||
}
|
||||
|
||||
test('the voice call shortcut respects the toolbar option', () async {
|
||||
final binding = _ToolbarBinding();
|
||||
platformFFI.setBindingForTesting(binding);
|
||||
registerSessionShortcutActions(session);
|
||||
model.onTriggered(kShortcutActionToggleVoiceCall);
|
||||
await pumpEventQueue();
|
||||
expect(binding.voiceCallRequests, 1);
|
||||
binding.option = kOptionHideToolbarVoiceCall;
|
||||
model.onTriggered(kShortcutActionToggleVoiceCall);
|
||||
await pumpEventQueue();
|
||||
expect(binding.voiceCallRequests, 1);
|
||||
});
|
||||
|
||||
test('fresh Chat shortcut sends through its outgoing session', () async {
|
||||
final binding = _ChatBinding();
|
||||
platformFFI.setBindingForTesting(binding);
|
||||
|
||||
@@ -127,6 +127,17 @@ pub const OPTION_HIDE_REMOTE_PRINTER_SETTINGS: &str = "hide-remote-printer-setti
|
||||
pub const OPTION_HIDE_WEBSOCKET_SETTINGS: &str = "hide-websocket-settings";
|
||||
pub const OPTION_HIDE_STOP_SERVICE: &str = "hide-stop-service";
|
||||
pub const OPTION_HIDE_ACCOUNT_PASSWORD_LOGIN: &str = "hide-account-password-login";
|
||||
pub const OPTION_HIDE_TOOLBAR_OS_PASSWORD: &str = "hide-toolbar-os-password";
|
||||
pub const OPTION_HIDE_TOOLBAR_SEND_CLIPBOARD_KEYSTROKES: &str =
|
||||
"hide-toolbar-send-clipboard-keystrokes";
|
||||
pub const OPTION_HIDE_TOOLBAR_VIEW_CAMERA: &str = "hide-toolbar-view-camera";
|
||||
pub const OPTION_HIDE_TOOLBAR_TERMINAL: &str = "hide-toolbar-terminal";
|
||||
pub const OPTION_HIDE_TOOLBAR_TCP_TUNNELING: &str = "hide-toolbar-tcp-tunneling";
|
||||
pub const OPTION_HIDE_TOOLBAR_SWITCH_SIDES: &str = "hide-toolbar-switch-sides";
|
||||
pub const OPTION_HIDE_TOOLBAR_SCREENSHOT: &str = "hide-toolbar-screenshot";
|
||||
pub const OPTION_HIDE_TOOLBAR_VOICE_CALL: &str = "hide-toolbar-voice-call";
|
||||
pub const OPTION_HIDE_TOOLBAR_DISPLAY_SETTINGS: &str = "hide-toolbar-display-settings";
|
||||
pub const OPTION_HIDE_TOOLBAR_KEYBOARD_SETTINGS: &str = "hide-toolbar-keyboard-settings";
|
||||
pub const OPTION_QUIT_BUTTON_TEXT: &str = "quit-button-text";
|
||||
pub const OPTION_ALLOW_COMMAND_LINE_SETTINGS_WHEN_SETTINGS_DISABLED: &str =
|
||||
"allow-command-line-settings-when-settings-disabled";
|
||||
@@ -363,6 +374,16 @@ pub const KEYS_BUILDIN_SETTINGS: &[&str] = &[
|
||||
OPTION_HIDE_WEBSOCKET_SETTINGS,
|
||||
OPTION_HIDE_STOP_SERVICE,
|
||||
OPTION_HIDE_ACCOUNT_PASSWORD_LOGIN,
|
||||
OPTION_HIDE_TOOLBAR_OS_PASSWORD,
|
||||
OPTION_HIDE_TOOLBAR_SEND_CLIPBOARD_KEYSTROKES,
|
||||
OPTION_HIDE_TOOLBAR_VIEW_CAMERA,
|
||||
OPTION_HIDE_TOOLBAR_TERMINAL,
|
||||
OPTION_HIDE_TOOLBAR_TCP_TUNNELING,
|
||||
OPTION_HIDE_TOOLBAR_SWITCH_SIDES,
|
||||
OPTION_HIDE_TOOLBAR_SCREENSHOT,
|
||||
OPTION_HIDE_TOOLBAR_VOICE_CALL,
|
||||
OPTION_HIDE_TOOLBAR_DISPLAY_SETTINGS,
|
||||
OPTION_HIDE_TOOLBAR_KEYBOARD_SETTINGS,
|
||||
OPTION_HIDE_USERNAME_ON_CARD,
|
||||
OPTION_HIDE_HELP_CARDS,
|
||||
OPTION_DEFAULT_CONNECT_PASSWORD,
|
||||
|
||||
@@ -3038,6 +3038,9 @@ impl LoginConfigHandler {
|
||||
/// Check if the client should auto login.
|
||||
/// Return password if the client should auto login, otherwise return empty string.
|
||||
pub fn should_auto_login(&self) -> String {
|
||||
if get_builtin_option(keys::OPTION_HIDE_TOOLBAR_OS_PASSWORD) == "Y" {
|
||||
return String::new();
|
||||
}
|
||||
let l = self.lock_after_session_end.v;
|
||||
let a = !self.get_option("auto-login").is_empty();
|
||||
let p = self.get_option("os-password");
|
||||
@@ -5799,6 +5802,33 @@ mod webrtc_race_tests {
|
||||
#[path = "client/tests/trusted_devices_tests.rs"]
|
||||
mod trusted_devices_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod auto_login_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn hidden_os_password_skips_auto_login_with_a_saved_password() {
|
||||
let mut login = LoginConfigHandler::default();
|
||||
login.config.lock_after_session_end.v = true;
|
||||
let options = &mut login.config.options;
|
||||
options.insert("auto-login".into(), "Y".into());
|
||||
options.insert("os-password".into(), "saved".into());
|
||||
|
||||
let key = keys::OPTION_HIDE_TOOLBAR_OS_PASSWORD;
|
||||
let settings = &config::BUILTIN_SETTINGS;
|
||||
let previous = settings.write().unwrap().insert(key.into(), "Y".into());
|
||||
let hidden = login.should_auto_login();
|
||||
settings.write().unwrap().remove(key);
|
||||
let visible = login.should_auto_login();
|
||||
if let Some(value) = previous {
|
||||
settings.write().unwrap().insert(key.into(), value);
|
||||
}
|
||||
|
||||
assert!(hidden.is_empty());
|
||||
assert_eq!(visible, "saved");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod kx_tests {
|
||||
use super::*;
|
||||
|
||||
+5
-5
@@ -149,8 +149,8 @@ class Header: Reactor.Component {
|
||||
</div>
|
||||
<span #chat>{svg_chat}</span>
|
||||
<span #action>{svg_action}</span>
|
||||
<span #display>{svg_display}</span>
|
||||
<span #keyboard>{svg_keyboard}</span>
|
||||
{handler.get_builtin_option("hide-toolbar-display-settings") != "Y" ? <span #display>{svg_display}</span> : ""}
|
||||
{handler.get_builtin_option("hide-toolbar-keyboard-settings") != "Y" ? <span #keyboard>{svg_keyboard}</span> : ""}
|
||||
{recording_enabled && show_recording_button ? <span #recording>{recording ? svg_recording_on : svg_recording_off}</span> : ""}
|
||||
{this.renderKeyboardPop()}
|
||||
{this.renderDisplayPop()}
|
||||
@@ -228,16 +228,16 @@ class Header: Reactor.Component {
|
||||
function renderActionPop() {
|
||||
return <popup>
|
||||
<menu.context #action-options>
|
||||
{keyboard_enabled ? <li #os-password>{translate('OS Password')}<EditOsPassword /></li> : ""}
|
||||
{keyboard_enabled && handler.get_builtin_option("hide-toolbar-os-password") != "Y" ? <li #os-password>{translate('OS Password')}<EditOsPassword /></li> : ""}
|
||||
<li #transfer-file>{translate('Transfer file')}</li>
|
||||
<li #tunnel>{translate('TCP tunneling')}</li>
|
||||
{handler.get_builtin_option("hide-toolbar-tcp-tunneling") != "Y" ? <li #tunnel>{translate('TCP tunneling')}</li> : ""}
|
||||
{handler.get_audit_server("conn") && <li #note>{translate('Note')}</li>}
|
||||
<div .separator />
|
||||
{keyboard_enabled && (pi.platform == "Linux" || pi.sas_enabled) ? <li #ctrl-alt-del>{translate('Insert')} Ctrl + Alt + Del</li> : ""}
|
||||
{restart_enabled && (pi.platform == "Linux" || pi.platform == "Windows" || pi.platform == "Mac OS") ? <li #restart_remote_device>{translate('Restart remote device')}</li> : ""}
|
||||
{keyboard_enabled ? <li #lock-screen>{translate('Insert Lock')}</li> : ""}
|
||||
{keyboard_enabled && pi.platform == "Windows" && pi.sas_enabled ? <li #block-input>{translate("Block user input")}</li> : ""}
|
||||
{handler.is_screenshot_supported() ? <li #take-screenshot>{translate('Take screenshot')}</li> : "" }
|
||||
{handler.is_screenshot_supported() && handler.get_builtin_option("hide-toolbar-screenshot") != "Y" ? <li #take-screenshot>{translate('Take screenshot')}</li> : "" }
|
||||
<li #refresh>{translate('Refresh')}</li>
|
||||
</menu>
|
||||
</popup>;
|
||||
|
||||
@@ -508,6 +508,7 @@ impl sciter::EventHandler for SciterSession {
|
||||
fn get_default_pi();
|
||||
fn get_option(String);
|
||||
fn get_local_option(String);
|
||||
fn get_builtin_option(String);
|
||||
fn t(String);
|
||||
fn set_option(String, String);
|
||||
fn input_os_password(String, bool);
|
||||
@@ -646,6 +647,10 @@ impl SciterSession {
|
||||
crate::ui_interface::get_local_option(key)
|
||||
}
|
||||
|
||||
fn get_builtin_option(&self, key: String) -> String {
|
||||
crate::ui_interface::get_builtin_option(&key)
|
||||
}
|
||||
|
||||
pub fn get_icon(&self) -> String {
|
||||
super::get_icon()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user