Merge pull request #5223 from dignow/refact/win_clipboard_use_ref_instead_of_box_ref
win clipboard context, use ref instead of box ref
This commit is contained in:
		
						commit
						17587bb299
					
				| @ -57,15 +57,10 @@ impl ContextSend { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn proc<F: FnOnce(&mut Box<CliprdrClientContext>) -> u32>(f: F) -> u32 { |     pub fn proc<F: FnOnce(&mut CliprdrClientContext) -> u32>(f: F) -> u32 { | ||||||
|         let lock = CONTEXT_SEND.addr.lock().unwrap(); |         let lock = CONTEXT_SEND.addr.lock().unwrap(); | ||||||
|         if *lock != 0 { |         if *lock != 0 { | ||||||
|             unsafe { |             unsafe { f(&mut *(*lock as *mut CliprdrClientContext)) } | ||||||
|                 let mut context = Box::from_raw(*lock as *mut CliprdrClientContext); |  | ||||||
|                 let code = f(&mut context); |  | ||||||
|                 std::mem::forget(context); |  | ||||||
|                 code |  | ||||||
|             } |  | ||||||
|         } else { |         } else { | ||||||
|             0 |             0 | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -164,12 +164,12 @@ fn send_data(conn_id: i32, data: ClipboardFile) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn empty_clipboard(context: &mut Box<CliprdrClientContext>, conn_id: i32) -> bool { | pub fn empty_clipboard(context: &mut CliprdrClientContext, conn_id: i32) -> bool { | ||||||
|     unsafe { TRUE == cliprdr::empty_cliprdr(&mut (**context), conn_id as u32) } |     unsafe { TRUE == cliprdr::empty_cliprdr(context, conn_id as u32) } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_clip_file( | pub fn server_clip_file( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     msg: ClipboardFile, |     msg: ClipboardFile, | ||||||
| ) -> u32 { | ) -> u32 { | ||||||
| @ -294,7 +294,7 @@ pub fn server_clip_file( | |||||||
|     ret |     ret | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_monitor_ready(context: &mut Box<CliprdrClientContext>, conn_id: i32) -> u32 { | pub fn server_monitor_ready(context: &mut CliprdrClientContext, conn_id: i32) -> u32 { | ||||||
|     unsafe { |     unsafe { | ||||||
|         let monitor_ready = CLIPRDR_MONITOR_READY { |         let monitor_ready = CLIPRDR_MONITOR_READY { | ||||||
|             connID: conn_id as UINT32, |             connID: conn_id as UINT32, | ||||||
| @ -302,8 +302,8 @@ pub fn server_monitor_ready(context: &mut Box<CliprdrClientContext>, conn_id: i3 | |||||||
|             msgFlags: 0 as UINT16, |             msgFlags: 0 as UINT16, | ||||||
|             dataLen: 0 as UINT32, |             dataLen: 0 as UINT32, | ||||||
|         }; |         }; | ||||||
|         if let Some(f) = (**context).MonitorReady { |         if let Some(f) = context.MonitorReady { | ||||||
|             let ret = f(&mut (**context), &monitor_ready); |             let ret = f(context, &monitor_ready); | ||||||
|             ret as u32 |             ret as u32 | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
| @ -312,7 +312,7 @@ pub fn server_monitor_ready(context: &mut Box<CliprdrClientContext>, conn_id: i3 | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_format_list( | pub fn server_format_list( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     format_list: Vec<(i32, String)>, |     format_list: Vec<(i32, String)>, | ||||||
| ) -> u32 { | ) -> u32 { | ||||||
| @ -348,8 +348,8 @@ pub fn server_format_list( | |||||||
|             formats: formats.as_mut_ptr(), |             formats: formats.as_mut_ptr(), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         let ret = if let Some(f) = (**context).ServerFormatList { |         let ret = if let Some(f) = context.ServerFormatList { | ||||||
|             f(&mut (**context), &format_list) |             f(context, &format_list) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         }; |         }; | ||||||
| @ -366,7 +366,7 @@ pub fn server_format_list( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_format_list_response( | pub fn server_format_list_response( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     msg_flags: i32, |     msg_flags: i32, | ||||||
| ) -> u32 { | ) -> u32 { | ||||||
| @ -378,8 +378,8 @@ pub fn server_format_list_response( | |||||||
|             dataLen: 0 as UINT32, |             dataLen: 0 as UINT32, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if let Some(f) = (**context).ServerFormatListResponse { |         if let Some(f) = context.ServerFormatListResponse { | ||||||
|             f(&mut (**context), &format_list_response) |             f(context, &format_list_response) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         } |         } | ||||||
| @ -387,7 +387,7 @@ pub fn server_format_list_response( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_format_data_request( | pub fn server_format_data_request( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     requested_format_id: i32, |     requested_format_id: i32, | ||||||
| ) -> u32 { | ) -> u32 { | ||||||
| @ -399,8 +399,8 @@ pub fn server_format_data_request( | |||||||
|             dataLen: 0 as UINT32, |             dataLen: 0 as UINT32, | ||||||
|             requestedFormatId: requested_format_id as UINT32, |             requestedFormatId: requested_format_id as UINT32, | ||||||
|         }; |         }; | ||||||
|         if let Some(f) = (**context).ServerFormatDataRequest { |         if let Some(f) = context.ServerFormatDataRequest { | ||||||
|             f(&mut (**context), &format_data_request) |             f(context, &format_data_request) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         } |         } | ||||||
| @ -408,7 +408,7 @@ pub fn server_format_data_request( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_format_data_response( | pub fn server_format_data_response( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     msg_flags: i32, |     msg_flags: i32, | ||||||
|     mut format_data: Vec<u8>, |     mut format_data: Vec<u8>, | ||||||
| @ -421,8 +421,8 @@ pub fn server_format_data_response( | |||||||
|             dataLen: format_data.len() as UINT32, |             dataLen: format_data.len() as UINT32, | ||||||
|             requestedFormatData: format_data.as_mut_ptr(), |             requestedFormatData: format_data.as_mut_ptr(), | ||||||
|         }; |         }; | ||||||
|         if let Some(f) = (**context).ServerFormatDataResponse { |         if let Some(f) = context.ServerFormatDataResponse { | ||||||
|             f(&mut (**context), &format_data_response) |             f(context, &format_data_response) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         } |         } | ||||||
| @ -430,7 +430,7 @@ pub fn server_format_data_response( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_file_contents_request( | pub fn server_file_contents_request( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     stream_id: i32, |     stream_id: i32, | ||||||
|     list_index: i32, |     list_index: i32, | ||||||
| @ -456,8 +456,8 @@ pub fn server_file_contents_request( | |||||||
|             haveClipDataId: if have_clip_data_id { TRUE } else { FALSE }, |             haveClipDataId: if have_clip_data_id { TRUE } else { FALSE }, | ||||||
|             clipDataId: clip_data_id as UINT32, |             clipDataId: clip_data_id as UINT32, | ||||||
|         }; |         }; | ||||||
|         if let Some(f) = (**context).ServerFileContentsRequest { |         if let Some(f) = context.ServerFileContentsRequest { | ||||||
|             f(&mut (**context), &file_contents_request) |             f(context, &file_contents_request) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         } |         } | ||||||
| @ -465,7 +465,7 @@ pub fn server_file_contents_request( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn server_file_contents_response( | pub fn server_file_contents_response( | ||||||
|     context: &mut Box<CliprdrClientContext>, |     context: &mut CliprdrClientContext, | ||||||
|     conn_id: i32, |     conn_id: i32, | ||||||
|     msg_flags: i32, |     msg_flags: i32, | ||||||
|     stream_id: i32, |     stream_id: i32, | ||||||
| @ -481,8 +481,8 @@ pub fn server_file_contents_response( | |||||||
|             cbRequested: requested_data.len() as UINT32, |             cbRequested: requested_data.len() as UINT32, | ||||||
|             requestedData: requested_data.as_mut_ptr(), |             requestedData: requested_data.as_mut_ptr(), | ||||||
|         }; |         }; | ||||||
|         if let Some(f) = (**context).ServerFileContentsResponse { |         if let Some(f) = context.ServerFileContentsResponse { | ||||||
|             f(&mut (**context), &file_contents_response) |             f(context, &file_contents_response) | ||||||
|         } else { |         } else { | ||||||
|             ERR_CODE_SERVER_FUNCTION_NONE |             ERR_CODE_SERVER_FUNCTION_NONE | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -251,7 +251,7 @@ impl<T: InvokeUiSession> Remote<T> { | |||||||
|         #[cfg(windows)] |         #[cfg(windows)] | ||||||
|         { |         { | ||||||
|             let conn_id = self.client_conn_id; |             let conn_id = self.client_conn_id; | ||||||
|             ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { |             ContextSend::proc(|context: &mut CliprdrClientContext| -> u32 { | ||||||
|                 empty_clipboard(context, conn_id); |                 empty_clipboard(context, conn_id); | ||||||
|                 0 |                 0 | ||||||
|             }); |             }); | ||||||
| @ -1624,7 +1624,7 @@ impl<T: InvokeUiSession> Remote<T> { | |||||||
|                 "Process clipboard message from server peer, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}", |                 "Process clipboard message from server peer, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}", | ||||||
|                 stop, is_stopping_allowed, file_transfer_enabled); |                 stop, is_stopping_allowed, file_transfer_enabled); | ||||||
|             if !stop { |             if !stop { | ||||||
|                 ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { |                 ContextSend::proc(|context: &mut CliprdrClientContext| -> u32 { | ||||||
|                     clipboard::server_clip_file(context, self.client_conn_id, clip) |                     clipboard::server_clip_file(context, self.client_conn_id, clip) | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -184,7 +184,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> { | |||||||
| 
 | 
 | ||||||
|         #[cfg(windows)] |         #[cfg(windows)] | ||||||
|         { |         { | ||||||
|             ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { |             ContextSend::proc(|context: &mut CliprdrClientContext| -> u32 { | ||||||
|                 empty_clipboard(context, id); |                 empty_clipboard(context, id); | ||||||
|                 0 |                 0 | ||||||
|             }); |             }); | ||||||
| @ -427,7 +427,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> { | |||||||
|                                                 continue; |                                                 continue; | ||||||
|                                             } |                                             } | ||||||
|                                             let conn_id = self.conn_id; |                                             let conn_id = self.conn_id; | ||||||
|                                             ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { |                                             ContextSend::proc(|context: &mut CliprdrClientContext| -> u32 { | ||||||
|                                                 clipboard::server_clip_file(context, conn_id, _clip) |                                                 clipboard::server_clip_file(context, conn_id, _clip) | ||||||
|                                             }); |                                             }); | ||||||
|                                         } |                                         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user