win, clipboard, debug
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
773bb1bad7
commit
53a1aeac61
@ -75,6 +75,13 @@ impl ClipboardFile {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_stopping_allowed_from_peer(&self) -> bool {
|
||||
match self {
|
||||
ClipboardFile::MonitorReady | ClipboardFile::FormatList { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_client_conn_id(session_uuid: &SessionID) -> Option<i32> {
|
||||
|
@ -1556,18 +1556,23 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn handle_cliprdr_msg(&self, clip: hbb_common::message_proto::Cliprdr) {
|
||||
if !self.handler.lc.read().unwrap().disable_clipboard.v {
|
||||
#[cfg(feature = "flutter")]
|
||||
if let Some(hbb_common::message_proto::cliprdr::Union::FormatList(_)) = &clip.union {
|
||||
if self.client_conn_id
|
||||
!= clipboard::get_client_conn_id(&crate::flutter::get_cur_session_id())
|
||||
.unwrap_or(0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#[cfg(feature = "flutter")]
|
||||
if let Some(hbb_common::message_proto::cliprdr::Union::FormatList(_)) = &clip.union {
|
||||
if self.client_conn_id
|
||||
!= clipboard::get_client_conn_id(&crate::flutter::get_cur_session_id()).unwrap_or(0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(clip) = crate::clipboard_file::msg_2_clip(clip) {
|
||||
if let Some(clip) = crate::clipboard_file::msg_2_clip(clip) {
|
||||
let is_stopping_allowed = clip.is_stopping_allowed_from_peer();
|
||||
let file_transfer_enabled = self.handler.lc.read().unwrap().enable_file_transfer.v;
|
||||
let stop = is_stopping_allowed && !file_transfer_enabled;
|
||||
log::debug!(
|
||||
"Process clipboard message from server peer, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}",
|
||||
stop, is_stopping_allowed, file_transfer_enabled);
|
||||
if !stop {
|
||||
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
|
||||
clipboard::server_clip_file(context, self.client_conn_id, clip)
|
||||
});
|
||||
|
@ -202,6 +202,7 @@ pub enum Data {
|
||||
SyncConfig(Option<Box<(Config, Config2)>>),
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
ClipboardFile(ClipboardFile),
|
||||
ClipboardFileEnabled(bool),
|
||||
PrivacyModeState((i32, PrivacyModeState)),
|
||||
TestRendezvousServer,
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
@ -438,15 +438,7 @@ impl Connection {
|
||||
}
|
||||
#[cfg(windows)]
|
||||
ipc::Data::ClipboardFile(clip) => {
|
||||
let is_stopping_allowed = clip.is_stopping_allowed();
|
||||
let file_transfer_enabled = conn.file_transfer_enabled();
|
||||
let stop = is_stopping_allowed && !file_transfer_enabled;
|
||||
log::debug!("Process clipboard message from cm, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, file_transfer_enabled);
|
||||
if stop {
|
||||
clipboard::ContextSend::set_is_stopped();
|
||||
} else {
|
||||
allow_err!(conn.stream.send(&clip_2_msg(clip)).await);
|
||||
}
|
||||
allow_err!(conn.stream.send(&clip_2_msg(clip)).await);
|
||||
}
|
||||
ipc::Data::PrivacyModeState((_, state)) => {
|
||||
let msg_out = match state {
|
||||
@ -2078,6 +2070,9 @@ impl Connection {
|
||||
if let Ok(q) = o.enable_file_transfer.enum_value() {
|
||||
if q != BoolOption::NotSet {
|
||||
self.enable_file_transfer = q == BoolOption::Yes;
|
||||
self.send_to_cm(ipc::Data::ClipboardFileEnabled(
|
||||
self.file_transfer_enabled(),
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Ok(q) = o.disable_clipboard.enum_value() {
|
||||
|
@ -72,6 +72,8 @@ struct IpcTaskRunner<T: InvokeUiCM> {
|
||||
conn_id: i32,
|
||||
#[cfg(windows)]
|
||||
file_transfer_enabled: bool,
|
||||
#[cfg(windows)]
|
||||
file_transfer_enabled_peer: bool,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@ -401,11 +403,13 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
Data::ClipboardFile(_clip) => {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let is_stopping_allowed = _clip.is_stopping_allowed();
|
||||
let is_stopping_allowed = _clip.is_stopping_allowed_from_peer();
|
||||
let is_clipboard_enabled = ContextSend::is_cm_enabled();
|
||||
let file_transfer_enabled = self.file_transfer_enabled;
|
||||
let stop = !is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled);
|
||||
log::debug!("Process clipboard message from peer, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, is_clipboard_enabled, file_transfer_enabled);
|
||||
log::debug!(
|
||||
"Process clipboard message from client peer, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}",
|
||||
stop, is_stopping_allowed, is_clipboard_enabled, file_transfer_enabled);
|
||||
if stop {
|
||||
ContextSend::set_is_stopped();
|
||||
} else {
|
||||
@ -416,6 +420,12 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::ClipboardFileEnabled(_enabled) => {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
self.file_transfer_enabled_peer =_enabled;
|
||||
}
|
||||
}
|
||||
Data::Theme(dark) => {
|
||||
self.cm.change_theme(dark);
|
||||
}
|
||||
@ -461,8 +471,11 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
let is_stopping_allowed = _clip.is_stopping_allowed();
|
||||
let is_clipboard_enabled = ContextSend::is_cm_enabled();
|
||||
let file_transfer_enabled = self.file_transfer_enabled;
|
||||
let stop = is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled);
|
||||
log::debug!("Process clipboard message from cm, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, is_clipboard_enabled, file_transfer_enabled);
|
||||
let file_transfer_enabled_peer = self.file_transfer_enabled_peer;
|
||||
let stop = is_stopping_allowed && !(is_clipboard_enabled && file_transfer_enabled && file_transfer_enabled_peer);
|
||||
log::debug!(
|
||||
"Process clipboard message from cm, stop: {}, is_stopping_allowed: {}, is_clipboard_enabled: {}, file_transfer_enabled: {}, file_transfer_enabled_peer: {}",
|
||||
stop, is_stopping_allowed, is_clipboard_enabled, file_transfer_enabled, file_transfer_enabled_peer);
|
||||
if stop {
|
||||
ContextSend::set_is_stopped();
|
||||
} else {
|
||||
@ -492,6 +505,8 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
conn_id: 0,
|
||||
#[cfg(windows)]
|
||||
file_transfer_enabled: false,
|
||||
#[cfg(windows)]
|
||||
file_transfer_enabled_peer: false,
|
||||
};
|
||||
|
||||
while task_runner.running {
|
||||
|
Loading…
x
Reference in New Issue
Block a user