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 };
// no need to handle result here
if conn_id == 0 {
VEC_MSG_CHANNEL
.read()
.unwrap()
// msg_channel is used for debug, VEC_MSG_CHANNEL cannot be inspected by the debugger.
let msg_channel = VEC_MSG_CHANNEL.read().unwrap();
msg_channel
.iter()
.for_each(|msg_channel| allow_err!(msg_channel.sender.send(data.clone())));
} else {

View File

@ -207,13 +207,12 @@ impl<T: InvokeUiSession> Remote<T> {
#[cfg(windows)]
match _msg {
Some(clip) => {
let mut send_msg = true;
if clip.is_stopping_allowed() {
if !(*self.handler.server_file_transfer_enabled.read().unwrap() && self.handler.lc.read().unwrap().enable_file_transfer.v) {
send_msg = false;
}
}
if send_msg {
let is_stopping_allowed = clip.is_stopping_allowed();
let server_file_transfer_enabled = *self.handler.server_file_transfer_enabled.read().unwrap();
let enable_file_transfer = self.handler.lc.read().unwrap().enable_file_transfer.v;
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 {
allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await);
}
}

View File

@ -438,7 +438,11 @@ impl Connection {
}
#[cfg(windows)]
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);
}
}

View File

@ -16,7 +16,7 @@ use crate::ipc::Connection;
#[cfg(not(any(target_os = "ios")))]
use crate::ipc::{self, Data};
#[cfg(windows)]
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend};
use clipboard::{cliprdr::CliprdrClientContext, ContextSend};
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::tokio::sync::mpsc::unbounded_channel;
#[cfg(windows)]
@ -382,7 +382,11 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
Data::ClipboardFile(_clip) => {
#[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;
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
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 {
Some(_clip) => {
#[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 => {