Disable file copy & paste in view mode (#6749)
* Disable file copy & paste in view mode Signed-off-by: fufesou <shuanglongchen@yeah.net> * hide 'Enable file copy & paste' when no keyboard perm Signed-off-by: fufesou <shuanglongchen@yeah.net> * Disable some functions in view mode Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
fc0fc5ea10
commit
6d0953dca4
@ -442,18 +442,22 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
|
||||
child: Text(translate('Mute'))));
|
||||
}
|
||||
// file copy and paste
|
||||
if (perms['file'] != false &&
|
||||
if (ffiModel.keyboard &&
|
||||
perms['file'] != false &&
|
||||
bind.mainHasFileClipboard() &&
|
||||
pi.platformAdditions.containsKey(kPlatformAdditionsHasFileClipboard)) {
|
||||
final enabled = !ffiModel.viewOnly;
|
||||
final option = 'enable-file-transfer';
|
||||
final value =
|
||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||
v.add(TToggleMenu(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
},
|
||||
onChanged: enabled
|
||||
? (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
}
|
||||
: null,
|
||||
child: Text(translate('Enable file copy and paste'))));
|
||||
}
|
||||
// disable clipboard
|
||||
@ -475,15 +479,18 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
|
||||
}
|
||||
// lock after session end
|
||||
if (ffiModel.keyboard) {
|
||||
final enabled = !ffiModel.viewOnly;
|
||||
final option = 'lock-after-session-end';
|
||||
final value =
|
||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||
v.add(TToggleMenu(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
},
|
||||
onChanged: enabled
|
||||
? (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
}
|
||||
: null,
|
||||
child: Text(translate('Lock after session end'))));
|
||||
}
|
||||
|
||||
@ -553,19 +560,27 @@ List<TToggleMenu> toolbarPrivacyMode(
|
||||
final sessionId = ffi.sessionId;
|
||||
|
||||
getDefaultMenu(Future<void> Function(SessionID sid, String opt) toggleFunc) {
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
return TToggleMenu(
|
||||
value: privacyModeState.isNotEmpty,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
if (ffiModel.pi.currentDisplay != 0 &&
|
||||
ffiModel.pi.currentDisplay != kAllDisplayValue) {
|
||||
msgBox(sessionId, 'custom-nook-nocancel-hasclose', 'info',
|
||||
'Please switch to Display 1 first', '', ffi.dialogManager);
|
||||
return;
|
||||
}
|
||||
final option = 'privacy-mode';
|
||||
toggleFunc(sessionId, option);
|
||||
},
|
||||
onChanged: enabled
|
||||
? (value) {
|
||||
if (value == null) return;
|
||||
if (ffiModel.pi.currentDisplay != 0 &&
|
||||
ffiModel.pi.currentDisplay != kAllDisplayValue) {
|
||||
msgBox(
|
||||
sessionId,
|
||||
'custom-nook-nocancel-hasclose',
|
||||
'info',
|
||||
'Please switch to Display 1 first',
|
||||
'',
|
||||
ffi.dialogManager);
|
||||
return;
|
||||
}
|
||||
final option = 'privacy-mode';
|
||||
toggleFunc(sessionId, option);
|
||||
}
|
||||
: null,
|
||||
child: Text(translate('Privacy mode')));
|
||||
}
|
||||
|
||||
|
@ -1422,10 +1422,14 @@ impl LoginConfigHandler {
|
||||
option.disable_keyboard = f(true);
|
||||
option.disable_clipboard = f(true);
|
||||
option.show_remote_cursor = f(true);
|
||||
option.enable_file_transfer = f(false);
|
||||
option.lock_after_session_end = f(false);
|
||||
} else {
|
||||
option.disable_keyboard = f(false);
|
||||
option.disable_clipboard = f(self.get_toggle_option("disable-clipboard"));
|
||||
option.show_remote_cursor = f(self.get_toggle_option("show-remote-cursor"));
|
||||
option.enable_file_transfer = f(self.config.enable_file_transfer.v);
|
||||
option.lock_after_session_end = f(self.config.lock_after_session_end.v);
|
||||
}
|
||||
} else {
|
||||
let is_set = self
|
||||
@ -1516,7 +1520,7 @@ impl LoginConfigHandler {
|
||||
msg.show_remote_cursor = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
if self.get_toggle_option("lock-after-session-end") {
|
||||
if !view_only && self.get_toggle_option("lock-after-session-end") {
|
||||
msg.lock_after_session_end = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
@ -1524,7 +1528,7 @@ impl LoginConfigHandler {
|
||||
msg.disable_audio = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
if self.get_toggle_option("enable-file-transfer") {
|
||||
if !view_only && self.get_toggle_option("enable-file-transfer") {
|
||||
msg.enable_file_transfer = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
|
@ -321,10 +321,15 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
*self.handler.server_file_transfer_enabled.read().unwrap();
|
||||
let file_transfer_enabled =
|
||||
self.handler.lc.read().unwrap().enable_file_transfer.v;
|
||||
let view_only = self.handler.lc.read().unwrap().view_only.v;
|
||||
let stop = is_stopping_allowed
|
||||
&& (!self.is_connected
|
||||
&& (view_only
|
||||
|| !self.is_connected
|
||||
|| !(server_file_transfer_enabled && file_transfer_enabled));
|
||||
log::debug!("Process clipboard message from system, stop: {}, is_stopping_allowed: {}, server_file_transfer_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, server_file_transfer_enabled, file_transfer_enabled);
|
||||
log::debug!(
|
||||
"Process clipboard message from system, stop: {}, is_stopping_allowed: {}, view_only: {}, server_file_transfer_enabled: {}, file_transfer_enabled: {}",
|
||||
view_only, stop, is_stopping_allowed, server_file_transfer_enabled, file_transfer_enabled
|
||||
);
|
||||
if stop {
|
||||
ContextSend::set_is_stopped();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user