diff --git a/libs/hbb_common/protos/message.proto b/libs/hbb_common/protos/message.proto index 3a8f14421..5069fa2b0 100644 --- a/libs/hbb_common/protos/message.proto +++ b/libs/hbb_common/protos/message.proto @@ -499,33 +499,33 @@ message AudioFrame { message BackNotification { // no need to consider block input by someone else enum BlockInputState { - StateUnknown = 1; - OnSucceeded = 2; - OnFailed = 3; - OffSucceeded = 4; - OffFailed = 5; + BlkStateUnknown = 0; + BlkOnSucceeded = 2; + BlkOnFailed = 3; + BlkOffSucceeded = 4; + BlkOffFailed = 5; } enum PrivacyModeState { - StateUnknown = 1; + PrvStateUnknown = 0; // Privacy mode on by someone else - OnByOther = 2; + PrvOnByOther = 2; // Privacy mode is not supported on the remote side - NotSupported = 3; + PrvNotSupported = 3; // Privacy mode on by self - OnSucceeded = 4; + PrvOnSucceeded = 4; // Privacy mode on by self, but denied - OnFailedDenied = 5; + PrvOnFailedDenied = 5; // Some plugins are not found - OnFailedPlugin = 6; + PrvOnFailedPlugin = 6; // Privacy mode on by self, but failed - OnFailed = 7; + PrvOnFailed = 7; // Privacy mode off by self - OffSucceeded = 8; + PrvOffSucceeded = 8; // Ctrl + P - OffByPeer = 9; + PrvOffByPeer = 9; // Privacy mode off by self, but failed - OffFailed = 10; - OffUnknown = 11; + PrvOffFailed = 10; + PrvOffUnknown = 11; } oneof union { diff --git a/src/server.rs b/src/server.rs index abba6d71d..b9bd13e95 100644 --- a/src/server.rs +++ b/src/server.rs @@ -101,7 +101,7 @@ async fn accept_connection_(server: ServerPtr, socket: Stream, secure: bool) -> async fn check_privacy_mode_on(stream: &mut Stream) -> ResultType<()> { if video_service::get_privacy_mode_conn_id() > 0 { let msg_out = - crate::common::make_privacy_mode_msg(back_notification::PrivacyModeState::OnByOther); + crate::common::make_privacy_mode_msg(back_notification::PrivacyModeState::PrvOnByOther); timeout(CONNECT_TIMEOUT, stream.send(&msg_out)).await??; } Ok(()) diff --git a/src/server/connection.rs b/src/server/connection.rs index 880d5bbac..a3b8f3985 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -306,24 +306,24 @@ impl Connection { ipc::PrivacyModeState::OffSucceeded => { video_service::set_privacy_mode_conn_id(0); crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffSucceeded, + back_notification::PrivacyModeState::PrvOffSucceeded, ) } ipc::PrivacyModeState::OffFailed => { crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffFailed, + back_notification::PrivacyModeState::PrvOffFailed, ) } ipc::PrivacyModeState::OffByPeer => { video_service::set_privacy_mode_conn_id(0); crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffByPeer, + back_notification::PrivacyModeState::PrvOffByPeer, ) } ipc::PrivacyModeState::OffUnknown => { video_service::set_privacy_mode_conn_id(0); crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffUnknown, + back_notification::PrivacyModeState::PrvOffUnknown, ) } }; @@ -463,7 +463,7 @@ impl Connection { } else { Self::send_block_input_error( &tx, - back_notification::BlockInputState::OnFailed, + back_notification::BlockInputState::BlkOnFailed, ); } } @@ -473,7 +473,7 @@ impl Connection { } else { Self::send_block_input_error( &tx, - back_notification::BlockInputState::OffFailed, + back_notification::BlockInputState::BlkOffFailed, ); } } @@ -1316,7 +1316,7 @@ impl Connection { BoolOption::Yes => { let msg_out = if !video_service::is_privacy_mode_supported() { crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::NotSupported, + back_notification::PrivacyModeState::PrvNotSupported, ) } else { match privacy_mode::turn_on_privacy(self.inner.id) { @@ -1324,7 +1324,7 @@ impl Connection { if video_service::test_create_capturer(self.inner.id, 5_000) { video_service::set_privacy_mode_conn_id(self.inner.id); crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OnSucceeded, + back_notification::PrivacyModeState::PrvOnSucceeded, ) } else { log::error!( @@ -1333,12 +1333,12 @@ 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( - back_notification::PrivacyModeState::OnFailed, + back_notification::PrivacyModeState::PrvOnFailed, ) } } Ok(false) => crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OnFailedPlugin, + back_notification::PrivacyModeState::PrvOnFailedPlugin, ), Err(e) => { log::error!("Failed to turn on privacy mode. {}", e); @@ -1346,7 +1346,7 @@ impl Connection { let _ = privacy_mode::turn_off_privacy(0); } crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OnFailed, + back_notification::PrivacyModeState::PrvOnFailed, ) } } @@ -1356,7 +1356,7 @@ impl Connection { BoolOption::No => { let msg_out = if !video_service::is_privacy_mode_supported() { crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::NotSupported, + back_notification::PrivacyModeState::PrvNotSupported, ) } else { video_service::set_privacy_mode_conn_id(0); @@ -1531,12 +1531,12 @@ mod privacy_mode { let res = turn_off_privacy(_conn_id, None); match res { Ok(_) => crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffSucceeded, + back_notification::PrivacyModeState::PrvOffSucceeded, ), Err(e) => { log::error!("Failed to turn off privacy mode {}", e); crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OffFailed, + back_notification::PrivacyModeState::PrvOffFailed, ) } } diff --git a/src/server/video_service.rs b/src/server/video_service.rs index 03a068871..b22418398 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -583,7 +583,7 @@ fn check_privacy_mode_changed(sp: &GenericService, privacy_mode_id: i32) -> Resu if privacy_mode_id != privacy_mode_id_2 { if privacy_mode_id_2 != 0 { let msg_out = crate::common::make_privacy_mode_msg( - back_notification::PrivacyModeState::OnByOther, + back_notification::PrivacyModeState::PrvOnByOther, ); sp.send_to_others(msg_out, privacy_mode_id_2); } diff --git a/src/ui/remote.rs b/src/ui/remote.rs index ad6b3cbd5..48e059797 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -2398,14 +2398,14 @@ impl Remote { match notification.union { Some(back_notification::Union::BlockInputState(state)) => { self.handle_back_msg_block_input( - state.enum_value_or(back_notification::BlockInputState::StateUnknown), + state.enum_value_or(back_notification::BlockInputState::BlkStateUnknown), ) .await; } Some(back_notification::Union::PrivacyModeState(state)) => { if !self .handle_back_msg_privacy_mode( - state.enum_value_or(back_notification::PrivacyModeState::StateUnknown), + state.enum_value_or(back_notification::PrivacyModeState::PrvStateUnknown), ) .await { @@ -2424,18 +2424,18 @@ impl Remote { async fn handle_back_msg_block_input(&mut self, state: back_notification::BlockInputState) { match state { - back_notification::BlockInputState::OnSucceeded => { + back_notification::BlockInputState::BlkOnSucceeded => { self.update_block_input_state(true); } - back_notification::BlockInputState::OnFailed => { + back_notification::BlockInputState::BlkOnFailed => { self.handler .msgbox("custom-error", "Block user input", "Failed"); self.update_block_input_state(false); } - back_notification::BlockInputState::OffSucceeded => { + back_notification::BlockInputState::BlkOffSucceeded => { self.update_block_input_state(false); } - back_notification::BlockInputState::OffFailed => { + back_notification::BlockInputState::BlkOffFailed => { self.handler .msgbox("custom-error", "Unblock user input", "Failed"); } @@ -2457,7 +2457,7 @@ impl Remote { state: back_notification::PrivacyModeState, ) -> bool { match state { - back_notification::PrivacyModeState::OnByOther => { + back_notification::PrivacyModeState::PrvOnByOther => { self.handler.msgbox( "error", "Connecting...", @@ -2465,46 +2465,46 @@ impl Remote { ); return false; } - back_notification::PrivacyModeState::NotSupported => { + back_notification::PrivacyModeState::PrvNotSupported => { self.handler .msgbox("custom-error", "Privacy mode", "Unsupported"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OnSucceeded => { + back_notification::PrivacyModeState::PrvOnSucceeded => { self.handler .msgbox("custom-nocancel", "Privacy mode", "In privacy mode"); self.update_privacy_mode(true); } - back_notification::PrivacyModeState::OnFailedDenied => { + back_notification::PrivacyModeState::PrvOnFailedDenied => { self.handler .msgbox("custom-error", "Privacy mode", "Peer denied"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OnFailedPlugin => { + back_notification::PrivacyModeState::PrvOnFailedPlugin => { self.handler .msgbox("custom-error", "Privacy mode", "Please install plugins"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OnFailed => { + back_notification::PrivacyModeState::PrvOnFailed => { self.handler .msgbox("custom-error", "Privacy mode", "Failed"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OffSucceeded => { + back_notification::PrivacyModeState::PrvOffSucceeded => { self.handler .msgbox("custom-nocancel", "Privacy mode", "Out privacy mode"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OffByPeer => { + back_notification::PrivacyModeState::PrvOffByPeer => { self.handler .msgbox("custom-error", "Privacy mode", "Peer exit"); self.update_privacy_mode(false); } - back_notification::PrivacyModeState::OffFailed => { + back_notification::PrivacyModeState::PrvOffFailed => { self.handler .msgbox("custom-error", "Privacy mode", "Failed to turn off"); } - back_notification::PrivacyModeState::OffUnknown => { + back_notification::PrivacyModeState::PrvOffUnknown => { self.handler .msgbox("custom-error", "Privacy mode", "Turned off"); // log::error!("Privacy mode is turned off with unknown reason");