Merge pull request #2433 from fufesou/feat_donot_show_privacy_mode_if_unsupported

do not show privacy action if peer does not support
This commit is contained in:
RustDesk 2022-12-02 21:43:59 +08:00 committed by GitHub
commit 9d062beb0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 6 deletions

View File

@ -1170,7 +1170,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
} }
displayMenu.add(_createSwitchMenuEntry( displayMenu.add(_createSwitchMenuEntry(
'Lock after session end', 'lock-after-session-end', padding, true)); 'Lock after session end', 'lock-after-session-end', padding, true));
if (pi.platform == 'Windows') { if (pi.features.privacyMode) {
displayMenu.add(MenuEntrySwitch2<String>( displayMenu.add(MenuEntrySwitch2<String>(
switchType: SwitchType.scheckbox, switchType: SwitchType.scheckbox,
text: translate('Privacy mode'), text: translate('Privacy mode'),

View File

@ -344,6 +344,8 @@ class FfiModel with ChangeNotifier {
_waitForImage[peerId] = true; _waitForImage[peerId] = true;
_reconnects = 1; _reconnects = 1;
} }
Map<String, dynamic> features = json.decode(evt['features']);
_pi.features.privacyMode = features['privacy_mode'] == 1;
} }
notifyListeners(); notifyListeners();
} }
@ -1328,6 +1330,10 @@ class Display {
} }
} }
class Features {
bool privacyMode = false;
}
class PeerInfo { class PeerInfo {
String version = ''; String version = '';
String username = ''; String username = '';
@ -1336,6 +1342,7 @@ class PeerInfo {
bool sasEnabled = false; bool sasEnabled = false;
int currentDisplay = 0; int currentDisplay = 0;
List<Display> displays = []; List<Display> displays = [];
Features features = Features();
} }
const canvasKey = 'canvas'; const canvasKey = 'canvas';

View File

@ -8,7 +8,8 @@ use std::{
use flutter_rust_bridge::{StreamSink, ZeroCopyBuffer}; use flutter_rust_bridge::{StreamSink, ZeroCopyBuffer};
use hbb_common::{ use hbb_common::{
bail, config::LocalConfig, message_proto::*, rendezvous_proto::ConnType, ResultType, bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
ResultType,
}; };
use serde_json::json; use serde_json::json;
@ -299,6 +300,15 @@ impl InvokeUiSession for FlutterHandler {
displays.push(h); displays.push(h);
} }
let displays = serde_json::ser::to_string(&displays).unwrap_or("".to_owned()); let displays = serde_json::ser::to_string(&displays).unwrap_or("".to_owned());
let mut features: HashMap<&str, i32> = Default::default();
for ref f in pi.features.iter() {
features.insert("privacy_mode", if f.privacy_mode { 1 } else { 0 });
}
// compatible with 1.1.9
if get_version_number(&pi.version) < get_version_number("1.2.0") {
features.insert("privacy_mode", 0);
}
let features = serde_json::ser::to_string(&features).unwrap_or("".to_owned());
self.push_event( self.push_event(
"peer_info", "peer_info",
vec![ vec![
@ -308,6 +318,7 @@ impl InvokeUiSession for FlutterHandler {
("sas_enabled", &pi.sas_enabled.to_string()), ("sas_enabled", &pi.sas_enabled.to_string()),
("displays", &displays), ("displays", &displays),
("version", &pi.version), ("version", &pi.version),
("features", &features),
("current_display", &pi.current_display.to_string()), ("current_display", &pi.current_display.to_string()),
], ],
); );

View File

@ -21,9 +21,12 @@
use super::{video_qos::VideoQoS, *}; use super::{video_qos::VideoQoS, *};
#[cfg(windows)] #[cfg(windows)]
use crate::portable_service::client::PORTABLE_SERVICE_RUNNING; use crate::portable_service::client::PORTABLE_SERVICE_RUNNING;
use hbb_common::tokio::sync::{ use hbb_common::{
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}, get_version_number,
Mutex as TokioMutex, tokio::sync::{
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
Mutex as TokioMutex,
},
}; };
#[cfg(not(windows))] #[cfg(not(windows))]
use scrap::Capturer; use scrap::Capturer;
@ -92,7 +95,8 @@ pub fn get_privacy_mode_conn_id() -> i32 {
pub fn is_privacy_mode_supported() -> bool { pub fn is_privacy_mode_supported() -> bool {
#[cfg(windows)] #[cfg(windows)]
return *IS_CAPTURER_MAGNIFIER_SUPPORTED; return *IS_CAPTURER_MAGNIFIER_SUPPORTED
&& get_version_number(&crate::VERSION) > get_version_number("1.1.9");
#[cfg(not(windows))] #[cfg(not(windows))]
return false; return false;
} }