add debug msg

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-06-19 20:49:04 +08:00
parent a903ec065b
commit c5698df3aa
4 changed files with 28 additions and 15 deletions

View File

@ -485,9 +485,9 @@ extern "C" fn client_format_list(
let data = ClipboardFile::FormatList { format_list }; let data = ClipboardFile::FormatList { format_list };
// no need to handle result here // no need to handle result here
if conn_id == 0 { if conn_id == 0 {
VEC_MSG_CHANNEL // msg_channel is used for debug, VEC_MSG_CHANNEL cannot be inspected by the debugger.
.read() let msg_channel = VEC_MSG_CHANNEL.read().unwrap();
.unwrap() msg_channel
.iter() .iter()
.for_each(|msg_channel| allow_err!(msg_channel.sender.send(data.clone()))); .for_each(|msg_channel| allow_err!(msg_channel.sender.send(data.clone())));
} else { } else {

View File

@ -207,13 +207,12 @@ impl<T: InvokeUiSession> Remote<T> {
#[cfg(windows)] #[cfg(windows)]
match _msg { match _msg {
Some(clip) => { Some(clip) => {
let mut send_msg = true; let is_stopping_allowed = clip.is_stopping_allowed();
if clip.is_stopping_allowed() { let server_file_transfer_enabled = *self.handler.server_file_transfer_enabled.read().unwrap();
if !(*self.handler.server_file_transfer_enabled.read().unwrap() && self.handler.lc.read().unwrap().enable_file_transfer.v) { let enable_file_transfer = self.handler.lc.read().unwrap().enable_file_transfer.v;
send_msg = false; let stop = is_stopping_allowed && !(server_file_transfer_enabled && enable_file_transfer);
} log::debug!("Process clipboard message from system, stop: {}, is_stopping_allowed: {}, server_file_transfer_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, server_file_transfer_enabled, file_transfer_enabled);
} if !stop {
if send_msg {
allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await); allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await);
} }
} }

View File

@ -438,7 +438,11 @@ impl Connection {
} }
#[cfg(windows)] #[cfg(windows)]
ipc::Data::ClipboardFile(clip) => { ipc::Data::ClipboardFile(clip) => {
if !clip.is_stopping_allowed() || conn.file_transfer_enabled() { let is_stopping_allowed = clip.is_stopping_allowed();
let enable_file_transfer = conn.file_transfer_enabled();
let stop = is_stopping_allowed && !enable_file_transfer;
log::debug!("Process clipboard message from cm, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, file_transfer_enabled);
if !stop {
allow_err!(conn.stream.send(&clip_2_msg(clip)).await); allow_err!(conn.stream.send(&clip_2_msg(clip)).await);
} }
} }

View File

@ -16,7 +16,7 @@ use crate::ipc::Connection;
#[cfg(not(any(target_os = "ios")))] #[cfg(not(any(target_os = "ios")))]
use crate::ipc::{self, Data}; use crate::ipc::{self, Data};
#[cfg(windows)] #[cfg(windows)]
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend}; use clipboard::{cliprdr::CliprdrClientContext, ContextSend};
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::tokio::sync::mpsc::unbounded_channel; use hbb_common::tokio::sync::mpsc::unbounded_channel;
#[cfg(windows)] #[cfg(windows)]
@ -382,7 +382,11 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
Data::ClipboardFile(_clip) => { Data::ClipboardFile(_clip) => {
#[cfg(windows)] #[cfg(windows)]
{ {
if !_clip.is_stopping_allowed() || self.file_transfer_enabled { let is_stopping_allowed = _clip.is_stopping_allowed();
let file_transfer_enabled = self.file_transfer_enabled;
let stop = is_stopping_allowed && !file_transfer_enabled;
log::debug!("Process clipboard message from peer, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, file_transfer_enabled);
if !stop {
let conn_id = self.conn_id; let conn_id = self.conn_id;
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
clipboard::server_clip_file(context, conn_id, _clip) clipboard::server_clip_file(context, conn_id, _clip)
@ -431,8 +435,14 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
clip_file = rx_clip.recv() => match clip_file { clip_file = rx_clip.recv() => match clip_file {
Some(_clip) => { Some(_clip) => {
#[cfg(windows)] #[cfg(windows)]
if !_clip.is_stopping_allowed() || self.file_transfer_enabled { {
allow_err!(self.tx.send(Data::ClipboardFile(_clip))); let is_stopping_allowed = _clip.is_stopping_allowed();
let file_transfer_enabled = self.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 {
allow_err!(self.tx.send(Data::ClipboardFile(_clip)));
}
} }
} }
None => { None => {