mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Privacy mode, msgbox, add details
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -471,11 +471,6 @@ impl Connection {
|
||||
back_notification::PrivacyModeState::PrvOffSucceeded,
|
||||
)
|
||||
}
|
||||
ipc::PrivacyModeState::OffFailed => {
|
||||
crate::common::make_privacy_mode_msg(
|
||||
back_notification::PrivacyModeState::PrvOffFailed,
|
||||
)
|
||||
}
|
||||
ipc::PrivacyModeState::OffByPeer => {
|
||||
video_service::set_privacy_mode_conn_id(0);
|
||||
crate::common::make_privacy_mode_msg(
|
||||
@@ -704,29 +699,34 @@ impl Connection {
|
||||
handle_pointer(&msg, id);
|
||||
}
|
||||
MessageInput::BlockOn => {
|
||||
if crate::platform::block_input(true) {
|
||||
let (ok, msg) = crate::platform::block_input(true);
|
||||
if ok {
|
||||
block_input_mode = true;
|
||||
} else {
|
||||
Self::send_block_input_error(
|
||||
&tx,
|
||||
back_notification::BlockInputState::BlkOnFailed,
|
||||
msg,
|
||||
);
|
||||
}
|
||||
}
|
||||
MessageInput::BlockOff => {
|
||||
if crate::platform::block_input(false) {
|
||||
let (ok, msg) = crate::platform::block_input(false);
|
||||
if ok {
|
||||
block_input_mode = false;
|
||||
} else {
|
||||
Self::send_block_input_error(
|
||||
&tx,
|
||||
back_notification::BlockInputState::BlkOffFailed,
|
||||
msg,
|
||||
);
|
||||
}
|
||||
}
|
||||
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
MessageInput::BlockOnPlugin(_peer) => {
|
||||
if crate::platform::block_input(true) {
|
||||
let (ok, _msg) = crate::platform::block_input(true);
|
||||
if ok {
|
||||
block_input_mode = true;
|
||||
}
|
||||
let _r = PLUGIN_BLOCK_INPUT_TX_RX
|
||||
@@ -738,7 +738,8 @@ impl Connection {
|
||||
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
MessageInput::BlockOffPlugin(_peer) => {
|
||||
if crate::platform::block_input(false) {
|
||||
let (ok, _msg) = crate::platform::block_input(false);
|
||||
if ok {
|
||||
block_input_mode = false;
|
||||
}
|
||||
let _r = PLUGIN_BLOCK_INPUT_TX_RX
|
||||
@@ -1209,7 +1210,11 @@ impl Connection {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn send_block_input_error(s: &Sender, state: back_notification::BlockInputState) {
|
||||
pub fn send_block_input_error(
|
||||
s: &Sender,
|
||||
state: back_notification::BlockInputState,
|
||||
details: String,
|
||||
) {
|
||||
let mut misc = Misc::new();
|
||||
let mut back_notification = BackNotification::new();
|
||||
back_notification.set_block_input_state(state);
|
||||
@@ -2221,13 +2226,16 @@ impl Connection {
|
||||
match q {
|
||||
BoolOption::Yes => {
|
||||
let msg_out = if !video_service::is_privacy_mode_supported() {
|
||||
crate::common::make_privacy_mode_msg(
|
||||
crate::common::make_privacy_mode_msg_with_details(
|
||||
back_notification::PrivacyModeState::PrvNotSupported,
|
||||
"Unsupported. 1 Multi-screen is not supported. 2 Please confirm the license is activated.".to_string(),
|
||||
)
|
||||
} else {
|
||||
match privacy_mode::turn_on_privacy(self.inner.id) {
|
||||
Ok(true) => {
|
||||
if video_service::test_create_capturer(self.inner.id, 5_000) {
|
||||
let err_msg =
|
||||
video_service::test_create_capturer(self.inner.id, 5_000);
|
||||
if err_msg.is_empty() {
|
||||
video_service::set_privacy_mode_conn_id(self.inner.id);
|
||||
crate::common::make_privacy_mode_msg(
|
||||
back_notification::PrivacyModeState::PrvOnSucceeded,
|
||||
@@ -2238,8 +2246,9 @@ impl Connection {
|
||||
);
|
||||
video_service::set_privacy_mode_conn_id(0);
|
||||
let _ = privacy_mode::turn_off_privacy(self.inner.id);
|
||||
crate::common::make_privacy_mode_msg(
|
||||
crate::common::make_privacy_mode_msg_with_details(
|
||||
back_notification::PrivacyModeState::PrvOnFailed,
|
||||
err_msg,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2261,8 +2270,9 @@ impl Connection {
|
||||
}
|
||||
BoolOption::No => {
|
||||
let msg_out = if !video_service::is_privacy_mode_supported() {
|
||||
crate::common::make_privacy_mode_msg(
|
||||
crate::common::make_privacy_mode_msg_with_details(
|
||||
back_notification::PrivacyModeState::PrvNotSupported,
|
||||
"Unsupported. 1 Multi-screen is not supported. 2 Please confirm the license is activated.".to_string(),
|
||||
)
|
||||
} else {
|
||||
video_service::set_privacy_mode_conn_id(0);
|
||||
@@ -2597,8 +2607,9 @@ mod privacy_mode {
|
||||
),
|
||||
Err(e) => {
|
||||
log::error!("Failed to turn off privacy mode {}", e);
|
||||
crate::common::make_privacy_mode_msg(
|
||||
crate::common::make_privacy_mode_msg_with_details(
|
||||
back_notification::PrivacyModeState::PrvOffFailed,
|
||||
e.to_string(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,17 +317,23 @@ fn create_capturer(
|
||||
}
|
||||
|
||||
// This function works on privacy mode. Windows only for now.
|
||||
pub fn test_create_capturer(privacy_mode_id: i32, timeout_millis: u64) -> bool {
|
||||
pub fn test_create_capturer(privacy_mode_id: i32, timeout_millis: u64) -> String {
|
||||
let test_begin = Instant::now();
|
||||
while test_begin.elapsed().as_millis() < timeout_millis as _ {
|
||||
if let Ok((_, current, display)) = get_current_display() {
|
||||
if let Ok(_) = create_capturer(privacy_mode_id, display, true, current, false) {
|
||||
return true;
|
||||
loop {
|
||||
let err = match get_current_display() {
|
||||
Ok((_, current, display)) => {
|
||||
match create_capturer(privacy_mode_id, display, true, current, false) {
|
||||
Ok(_) => return "".to_owned(),
|
||||
Err(e) => e,
|
||||
}
|
||||
}
|
||||
Err(e) => e,
|
||||
};
|
||||
if test_begin.elapsed().as_millis() >= timeout_millis as _ {
|
||||
return err.to_string();
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(300));
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -1025,7 +1031,7 @@ fn try_get_displays() -> ResultType<Vec<Display>> {
|
||||
// displays = Display::all()?;
|
||||
// }
|
||||
// }
|
||||
Ok( Display::all()?)
|
||||
Ok(Display::all()?)
|
||||
}
|
||||
|
||||
pub(super) fn get_current_display_2(mut all: Vec<Display>) -> ResultType<(usize, usize, Display)> {
|
||||
|
||||
Reference in New Issue
Block a user