do not show privacy action if peer does not support

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-12-02 21:34:20 +08:00
parent 12bdd57a45
commit f2a6a8a88b
4 changed files with 28 additions and 6 deletions

View File

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

View File

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

View File

@ -8,7 +8,8 @@ use std::{
use flutter_rust_bridge::{StreamSink, ZeroCopyBuffer};
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;
@ -299,6 +300,15 @@ impl InvokeUiSession for FlutterHandler {
displays.push(h);
}
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(
"peer_info",
vec![
@ -308,6 +318,7 @@ impl InvokeUiSession for FlutterHandler {
("sas_enabled", &pi.sas_enabled.to_string()),
("displays", &displays),
("version", &pi.version),
("features", &features),
("current_display", &pi.current_display.to_string()),
],
);

View File

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