Skip to content

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

Refact/options (#9318)

fufesou9380f33d7c08
diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart
index f881bc840..2d20d5931 100644
--- a/flutter/lib/desktop/widgets/remote_toolbar.dart
+++ b/flutter/lib/desktop/widgets/remote_toolbar.dart
@@ -1718,7 +1718,9 @@ class _KeyboardMenu extends StatelessWidget {
if (value == null) return;
await bind.sessionToggleOption(
sessionId: ffi.sessionId, value: kOptionToggleViewOnly);
- ffiModel.setViewOnly(id, value);
+ final viewOnly = await bind.sessionGetToggleOption(
+ sessionId: ffi.sessionId, arg: kOptionToggleViewOnly);
+ ffiModel.setViewOnly(id, viewOnly ?? value);
}
: null,
ffi: ffi,
diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart
index 853cf8ac0..084ac1b43 100644
--- a/flutter/lib/models/model.dart
+++ b/flutter/lib/models/model.dart
@@ -795,7 +795,7 @@ class FfiModel with ChangeNotifier {
isRefreshing = false;
}
Map<String, dynamic> features = json.decode(evt['features']);
- _pi.features.privacyMode = features['privacy_mode'] == 1;
+ _pi.features.privacyMode = features['privacy_mode'] == true;
if (!isCache) {
handleResolutions(peerId, evt["resolutions"]);
}
diff --git a/flutter/lib/web/bridge.dart b/flutter/lib/web/bridge.dart
index 97cac31c9..26e94ff1c 100644
--- a/flutter/lib/web/bridge.dart
+++ b/flutter/lib/web/bridge.dart
@@ -196,8 +196,8 @@ class RustdeskImpl {
required bool on,
dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
- 'option:toggle',
- jsonEncode({implKey, on})
+ 'toggle_privacy_mode',
+ jsonEncode({'impl_key': implKey, 'on': on})
]));
}
@@ -1204,8 +1204,10 @@ class RustdeskImpl {
required int index,
required bool on,
dynamic hint}) {
- // TODO
- throw UnimplementedError();
+ return Future(() => js.context.callMethod('setByName', [
+ 'toggle_virtual_display',
+ jsonEncode({'index': index, 'on': on})
+ ]));
}
Future<void> mainSetHomeDir({required String home, dynamic hint}) {
diff --git a/libs/scrap/src/common/mod.rs b/libs/scrap/src/common/mod.rs
index 164f7157d..d6060e131 100644
--- a/libs/scrap/src/common/mod.rs
+++ b/libs/scrap/src/common/mod.rs
@@ -316,7 +316,7 @@ impl ToString for CodecFormat {
CodecFormat::AV1 => "AV1".into(),
CodecFormat::H264 => "H264".into(),
CodecFormat::H265 => "H265".into(),
- CodecFormat::Unknown => "Unknow".into(),
+ CodecFormat::Unknown => "Unknown".into(),
}
}
}
diff --git a/src/client.rs b/src/client.rs
index f1df8d20e..62a3ca0a8 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -1800,28 +1800,6 @@ impl LoginConfigHandler {
)
}
- pub fn get_option_message_after_login(&self) -> Option<OptionMessage> {
- if self.conn_type.eq(&ConnType::FILE_TRANSFER)
- || self.conn_type.eq(&ConnType::PORT_FORWARD)
- || self.conn_type.eq(&ConnType::RDP)
- {
- return None;
- }
- let mut n = 0;
- let mut msg = OptionMessage::new();
- if self.version < hbb_common::get_version_number("1.2.4") {
- if self.get_toggle_option("privacy-mode") {
- msg.privacy_mode = BoolOption::Yes.into();
- n += 1;
- }
- }
- if n > 0 {
- Some(msg)
- } else {
- None
- }
- }
-
/// Parse the image quality option.
/// Return [`ImageQuality`] if the option is valid, otherwise return `None`.
///
diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs
index 1a209ca0a..21a5af9a3 100644
--- a/src/client/io_loop.rs
+++ b/src/client/io_loop.rs
@@ -958,22 +958,6 @@ impl<T: InvokeUiSession> Remote<T> {
true
}
- async fn send_opts_after_login(&self, peer: &mut Stream) {
- if let Some(opts) = self
- .handler
- .lc
- .read()
- .unwrap()
- .get_option_message_after_login()
- {
- let mut misc = Misc::new();
- misc.set_option(opts);
- let mut msg_out = Message::new();
- msg_out.set_misc(misc);
- allow_err!(peer.send(&msg_out).await);
- }
- }
-
async fn send_toggle_virtual_display_msg(&self, peer: &mut Stream) {
if !self.peer_info.is_support_virtual_display() {
return;
@@ -1135,7 +1119,6 @@ impl<T: InvokeUiSession> Remote<T> {
self.first_frame = true;
self.handler.close_success();
self.handler.adapt_size();
- self.send_opts_after_login(peer).await;
self.send_toggle_virtual_display_msg(peer).await;
self.send_toggle_privacy_mode_msg(peer).await;
}
diff --git a/src/flutter.rs b/src/flutter.rs
index 03b5a5750..717615753 100644
--- a/src/flutter.rs
+++ b/src/flutter.rs
@@ -802,13 +802,13 @@ impl InvokeUiSession for FlutterHandler {
fn set_peer_info(&self, pi: &PeerInfo) {
let displays = Self::make_displays_msg(&pi.displays);
- let mut features: HashMap<&str, i32> = Default::default();
+ let mut features: HashMap<&str, bool> = Default::default();
for ref f in pi.features.iter() {
- features.insert("privacy_mode", if f.privacy_mode { 1 } else { 0 });
+ features.insert("privacy_mode", f.privacy_mode);
}
// compatible with 1.1.9
if get_version_number(&pi.version) < get_version_number("1.2.0") {
- features.insert("privacy_mode", 0);
+ features.insert("privacy_mode", false);
}
let features = serde_json::ser::to_string(&features).unwrap_or("".to_owned());
let resolutions = serialize_resolutions(&pi.resolutions.resolutions);