Merge pull request #5210 from dignow/refact/no_sync_file_clipboard_before_conn
Do not sync file clipboard before conn
This commit is contained in:
		
						commit
						5555cf8fbe
					
				@ -70,7 +70,6 @@ struct MsgChannel {
 | 
				
			|||||||
lazy_static::lazy_static! {
 | 
					lazy_static::lazy_static! {
 | 
				
			||||||
    static ref VEC_MSG_CHANNEL: RwLock<Vec<MsgChannel>> = Default::default();
 | 
					    static ref VEC_MSG_CHANNEL: RwLock<Vec<MsgChannel>> = Default::default();
 | 
				
			||||||
    static ref CLIENT_CONN_ID_COUNTER: Mutex<i32> = Mutex::new(0);
 | 
					    static ref CLIENT_CONN_ID_COUNTER: Mutex<i32> = Mutex::new(0);
 | 
				
			||||||
    static ref LAST_FILE_FORMAT_LIST: Arc<Mutex<Option<ClipboardFile>>> = Default::default();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ClipboardFile {
 | 
					impl ClipboardFile {
 | 
				
			||||||
@ -91,11 +90,6 @@ impl ClipboardFile {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inline]
 | 
					 | 
				
			||||||
pub fn get_last_file_format_list() -> Option<ClipboardFile> {
 | 
					 | 
				
			||||||
    LAST_FILE_FORMAT_LIST.lock().unwrap().clone()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub fn get_client_conn_id(session_uuid: &SessionID) -> Option<i32> {
 | 
					pub fn get_client_conn_id(session_uuid: &SessionID) -> Option<i32> {
 | 
				
			||||||
    VEC_MSG_CHANNEL
 | 
					    VEC_MSG_CHANNEL
 | 
				
			||||||
        .read()
 | 
					        .read()
 | 
				
			||||||
@ -187,24 +181,46 @@ pub fn server_clip_file(
 | 
				
			|||||||
        ClipboardFile::MonitorReady => {
 | 
					        ClipboardFile::MonitorReady => {
 | 
				
			||||||
            log::debug!("server_monitor_ready called");
 | 
					            log::debug!("server_monitor_ready called");
 | 
				
			||||||
            ret = server_monitor_ready(context, conn_id);
 | 
					            ret = server_monitor_ready(context, conn_id);
 | 
				
			||||||
            log::debug!("server_monitor_ready called, conn_id {}, return {}", conn_id, ret);
 | 
					            log::debug!(
 | 
				
			||||||
 | 
					                "server_monitor_ready called, conn_id {}, return {}",
 | 
				
			||||||
 | 
					                conn_id,
 | 
				
			||||||
 | 
					                ret
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ClipboardFile::FormatList { format_list } => {
 | 
					        ClipboardFile::FormatList { format_list } => {
 | 
				
			||||||
            log::debug!("server_format_list called, conn_id {}, format_list: {:?}", conn_id, &format_list);
 | 
					            log::debug!(
 | 
				
			||||||
 | 
					                "server_format_list called, conn_id {}, format_list: {:?}",
 | 
				
			||||||
 | 
					                conn_id,
 | 
				
			||||||
 | 
					                &format_list
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
            ret = server_format_list(context, conn_id, format_list);
 | 
					            ret = server_format_list(context, conn_id, format_list);
 | 
				
			||||||
            log::debug!("server_format_list called, conn_id {}, return {}", conn_id, ret);
 | 
					            log::debug!(
 | 
				
			||||||
 | 
					                "server_format_list called, conn_id {}, return {}",
 | 
				
			||||||
 | 
					                conn_id,
 | 
				
			||||||
 | 
					                ret
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ClipboardFile::FormatListResponse { msg_flags } => {
 | 
					        ClipboardFile::FormatListResponse { msg_flags } => {
 | 
				
			||||||
            log::debug!("server_format_list_response called");
 | 
					            log::debug!("server_format_list_response called");
 | 
				
			||||||
            ret = server_format_list_response(context, conn_id, msg_flags);
 | 
					            ret = server_format_list_response(context, conn_id, msg_flags);
 | 
				
			||||||
            log::debug!("server_format_list_response called, conn_id {}, msg_flags {}, return {}", conn_id, msg_flags, ret);
 | 
					            log::debug!(
 | 
				
			||||||
 | 
					                "server_format_list_response called, conn_id {}, msg_flags {}, return {}",
 | 
				
			||||||
 | 
					                conn_id,
 | 
				
			||||||
 | 
					                msg_flags,
 | 
				
			||||||
 | 
					                ret
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ClipboardFile::FormatDataRequest {
 | 
					        ClipboardFile::FormatDataRequest {
 | 
				
			||||||
            requested_format_id,
 | 
					            requested_format_id,
 | 
				
			||||||
        } => {
 | 
					        } => {
 | 
				
			||||||
            log::debug!("server_format_data_request called");
 | 
					            log::debug!("server_format_data_request called");
 | 
				
			||||||
            ret = server_format_data_request(context, conn_id, requested_format_id);
 | 
					            ret = server_format_data_request(context, conn_id, requested_format_id);
 | 
				
			||||||
            log::debug!("server_format_data_request called, conn_id {}, requested_format_id {}, return {}", conn_id, requested_format_id, ret);
 | 
					            log::debug!(
 | 
				
			||||||
 | 
					                "server_format_data_request called, conn_id {}, requested_format_id {}, return {}",
 | 
				
			||||||
 | 
					                conn_id,
 | 
				
			||||||
 | 
					                requested_format_id,
 | 
				
			||||||
 | 
					                ret
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ClipboardFile::FormatDataResponse {
 | 
					        ClipboardFile::FormatDataResponse {
 | 
				
			||||||
            msg_flags,
 | 
					            msg_flags,
 | 
				
			||||||
@ -565,9 +581,12 @@ extern "C" fn client_format_list(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        conn_id = (*clip_format_list).connID as i32;
 | 
					        conn_id = (*clip_format_list).connID as i32;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    log::debug!("client_format_list called, client id: {}, format_list: {:?}", conn_id, &format_list);
 | 
					    log::debug!(
 | 
				
			||||||
 | 
					        "client_format_list called, client id: {}, format_list: {:?}",
 | 
				
			||||||
 | 
					        conn_id,
 | 
				
			||||||
 | 
					        &format_list
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    let data = ClipboardFile::FormatList { format_list };
 | 
					    let data = ClipboardFile::FormatList { format_list };
 | 
				
			||||||
    *LAST_FILE_FORMAT_LIST.lock().unwrap() = Some(data.clone());
 | 
					 | 
				
			||||||
    // no need to handle result here
 | 
					    // no need to handle result here
 | 
				
			||||||
    if conn_id == 0 {
 | 
					    if conn_id == 0 {
 | 
				
			||||||
        // msg_channel is used for debug, VEC_MSG_CHANNEL cannot be inspected by the debugger.
 | 
					        // msg_channel is used for debug, VEC_MSG_CHANNEL cannot be inspected by the debugger.
 | 
				
			||||||
@ -592,7 +611,11 @@ extern "C" fn client_format_list_response(
 | 
				
			|||||||
        conn_id = (*format_list_response).connID as i32;
 | 
					        conn_id = (*format_list_response).connID as i32;
 | 
				
			||||||
        msg_flags = (*format_list_response).msgFlags as i32;
 | 
					        msg_flags = (*format_list_response).msgFlags as i32;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    log::debug!("client_format_list_response called, client id: {}, msg_flags: {}", conn_id, msg_flags);
 | 
					    log::debug!(
 | 
				
			||||||
 | 
					        "client_format_list_response called, client id: {}, msg_flags: {}",
 | 
				
			||||||
 | 
					        conn_id,
 | 
				
			||||||
 | 
					        msg_flags
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    let data = ClipboardFile::FormatListResponse { msg_flags };
 | 
					    let data = ClipboardFile::FormatListResponse { msg_flags };
 | 
				
			||||||
    send_data(conn_id, data);
 | 
					    send_data(conn_id, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -612,7 +635,11 @@ extern "C" fn client_format_data_request(
 | 
				
			|||||||
    let data = ClipboardFile::FormatDataRequest {
 | 
					    let data = ClipboardFile::FormatDataRequest {
 | 
				
			||||||
        requested_format_id,
 | 
					        requested_format_id,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    log::debug!("client_format_data_request called, conn_id: {}, requested_format_id: {}", conn_id, requested_format_id);
 | 
					    log::debug!(
 | 
				
			||||||
 | 
					        "client_format_data_request called, conn_id: {}, requested_format_id: {}",
 | 
				
			||||||
 | 
					        conn_id,
 | 
				
			||||||
 | 
					        requested_format_id
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    // no need to handle result here
 | 
					    // no need to handle result here
 | 
				
			||||||
    send_data(conn_id, data);
 | 
					    send_data(conn_id, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -639,7 +666,11 @@ extern "C" fn client_format_data_response(
 | 
				
			|||||||
            .to_vec();
 | 
					            .to_vec();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    log::debug!("client_format_data_response called, client id: {}, msg_flags: {}", conn_id, msg_flags);
 | 
					    log::debug!(
 | 
				
			||||||
 | 
					        "client_format_data_response called, client id: {}, msg_flags: {}",
 | 
				
			||||||
 | 
					        conn_id,
 | 
				
			||||||
 | 
					        msg_flags
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    let data = ClipboardFile::FormatDataResponse {
 | 
					    let data = ClipboardFile::FormatDataResponse {
 | 
				
			||||||
        msg_flags,
 | 
					        msg_flags,
 | 
				
			||||||
        format_data,
 | 
					        format_data,
 | 
				
			||||||
@ -726,7 +757,12 @@ extern "C" fn client_file_contents_response(
 | 
				
			|||||||
        stream_id,
 | 
					        stream_id,
 | 
				
			||||||
        requested_data,
 | 
					        requested_data,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    log::debug!("client_file_contents_response called, conn_id: {}, msg_flags: {}, stream_id: {}", conn_id, msg_flags, stream_id);
 | 
					    log::debug!(
 | 
				
			||||||
 | 
					        "client_file_contents_response called, conn_id: {}, msg_flags: {}, stream_id: {}",
 | 
				
			||||||
 | 
					        conn_id,
 | 
				
			||||||
 | 
					        msg_flags,
 | 
				
			||||||
 | 
					        stream_id
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    send_data(conn_id, data);
 | 
					    send_data(conn_id, data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    0
 | 
					    0
 | 
				
			||||||
 | 
				
			|||||||
@ -6,9 +6,7 @@ use std::sync::{
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(windows)]
 | 
					#[cfg(windows)]
 | 
				
			||||||
use clipboard::{
 | 
					use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend};
 | 
				
			||||||
    cliprdr::CliprdrClientContext, empty_clipboard, get_last_file_format_list, ContextSend,
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
use crossbeam_queue::ArrayQueue;
 | 
					use crossbeam_queue::ArrayQueue;
 | 
				
			||||||
use hbb_common::config::{PeerConfig, TransferSerde};
 | 
					use hbb_common::config::{PeerConfig, TransferSerde};
 | 
				
			||||||
use hbb_common::fs::{
 | 
					use hbb_common::fs::{
 | 
				
			||||||
@ -1053,13 +1051,6 @@ impl<T: InvokeUiSession> Remote<T> {
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        self.is_connected = true;
 | 
					                        self.is_connected = true;
 | 
				
			||||||
                        #[cfg(target_os = "windows")]
 | 
					 | 
				
			||||||
                        if self.handler.peer_platform() == crate::platform::PLATFORM_WINDOWS {
 | 
					 | 
				
			||||||
                            if let Some(last_file_format_list) = get_last_file_format_list() {
 | 
					 | 
				
			||||||
                                self.handle_local_clipboard_msg(peer, Some(last_file_format_list))
 | 
					 | 
				
			||||||
                                    .await;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    _ => {}
 | 
					                    _ => {}
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user