commit
944fde15a4
@ -18,8 +18,7 @@ extern "C"
|
|||||||
|
|
||||||
/* Clipboard Messages */
|
/* Clipboard Messages */
|
||||||
#define DEFINE_CLIPRDR_HEADER_COMMON() \
|
#define DEFINE_CLIPRDR_HEADER_COMMON() \
|
||||||
UINT32 serverConnID; \
|
UINT32 connID; \
|
||||||
UINT32 remoteConnID; \
|
|
||||||
UINT16 msgType; \
|
UINT16 msgType; \
|
||||||
UINT16 msgFlags; \
|
UINT16 msgFlags; \
|
||||||
UINT32 dataLen
|
UINT32 dataLen
|
||||||
@ -192,7 +191,7 @@ extern "C"
|
|||||||
typedef UINT (*pcCliprdrServerFileContentsResponse)(
|
typedef UINT (*pcCliprdrServerFileContentsResponse)(
|
||||||
CliprdrClientContext *context, const CLIPRDR_FILE_CONTENTS_RESPONSE *fileContentsResponse);
|
CliprdrClientContext *context, const CLIPRDR_FILE_CONTENTS_RESPONSE *fileContentsResponse);
|
||||||
|
|
||||||
typedef BOOL (*pcCheckEnabled)(UINT32 server_conn_id, UINT32 remote_conn_id);
|
typedef BOOL (*pcCheckEnabled)(UINT32 connID);
|
||||||
|
|
||||||
// TODO: hide more members of clipboard context
|
// TODO: hide more members of clipboard context
|
||||||
struct _cliprdr_client_context
|
struct _cliprdr_client_context
|
||||||
|
@ -175,8 +175,7 @@ pub const FALSE: ::std::os::raw::c_int = 0;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_HEADER {
|
pub struct _CLIPRDR_HEADER {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -201,8 +200,7 @@ pub type CLIPRDR_GENERAL_CAPABILITY_SET = _CLIPRDR_GENERAL_CAPABILITY_SET;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_CAPABILITIES {
|
pub struct _CLIPRDR_CAPABILITIES {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -213,8 +211,7 @@ pub type CLIPRDR_CAPABILITIES = _CLIPRDR_CAPABILITIES;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_MONITOR_READY {
|
pub struct _CLIPRDR_MONITOR_READY {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -223,8 +220,7 @@ pub type CLIPRDR_MONITOR_READY = _CLIPRDR_MONITOR_READY;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_TEMP_DIRECTORY {
|
pub struct _CLIPRDR_TEMP_DIRECTORY {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -241,8 +237,7 @@ pub type CLIPRDR_FORMAT = _CLIPRDR_FORMAT;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FORMAT_LIST {
|
pub struct _CLIPRDR_FORMAT_LIST {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -253,8 +248,7 @@ pub type CLIPRDR_FORMAT_LIST = _CLIPRDR_FORMAT_LIST;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FORMAT_LIST_RESPONSE {
|
pub struct _CLIPRDR_FORMAT_LIST_RESPONSE {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -263,8 +257,7 @@ pub type CLIPRDR_FORMAT_LIST_RESPONSE = _CLIPRDR_FORMAT_LIST_RESPONSE;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_LOCK_CLIPBOARD_DATA {
|
pub struct _CLIPRDR_LOCK_CLIPBOARD_DATA {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -274,8 +267,7 @@ pub type CLIPRDR_LOCK_CLIPBOARD_DATA = _CLIPRDR_LOCK_CLIPBOARD_DATA;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_UNLOCK_CLIPBOARD_DATA {
|
pub struct _CLIPRDR_UNLOCK_CLIPBOARD_DATA {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -285,8 +277,7 @@ pub type CLIPRDR_UNLOCK_CLIPBOARD_DATA = _CLIPRDR_UNLOCK_CLIPBOARD_DATA;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FORMAT_DATA_REQUEST {
|
pub struct _CLIPRDR_FORMAT_DATA_REQUEST {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -296,8 +287,7 @@ pub type CLIPRDR_FORMAT_DATA_REQUEST = _CLIPRDR_FORMAT_DATA_REQUEST;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FORMAT_DATA_RESPONSE {
|
pub struct _CLIPRDR_FORMAT_DATA_RESPONSE {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -307,8 +297,7 @@ pub type CLIPRDR_FORMAT_DATA_RESPONSE = _CLIPRDR_FORMAT_DATA_RESPONSE;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FILE_CONTENTS_REQUEST {
|
pub struct _CLIPRDR_FILE_CONTENTS_REQUEST {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -325,8 +314,7 @@ pub type CLIPRDR_FILE_CONTENTS_REQUEST = _CLIPRDR_FILE_CONTENTS_REQUEST;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct _CLIPRDR_FILE_CONTENTS_RESPONSE {
|
pub struct _CLIPRDR_FILE_CONTENTS_RESPONSE {
|
||||||
pub serverConnID: UINT32,
|
pub connID: UINT32,
|
||||||
pub remoteConnID: UINT32,
|
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
pub msgFlags: UINT16,
|
pub msgFlags: UINT16,
|
||||||
pub dataLen: UINT32,
|
pub dataLen: UINT32,
|
||||||
@ -457,7 +445,7 @@ pub type pcCliprdrServerFileContentsResponse = ::std::option::Option<
|
|||||||
) -> UINT,
|
) -> UINT,
|
||||||
>;
|
>;
|
||||||
pub type pcCheckEnabled = ::std::option::Option<
|
pub type pcCheckEnabled = ::std::option::Option<
|
||||||
unsafe extern "C" fn(server_conn_id: UINT32, remote_conn_id: UINT32) -> BOOL,
|
unsafe extern "C" fn(connID: UINT32) -> BOOL,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
// TODO: hide more members of clipboard context
|
// TODO: hide more members of clipboard context
|
||||||
@ -498,8 +486,7 @@ extern "C" {
|
|||||||
pub(crate) fn uninit_cliprdr(context: *mut CliprdrClientContext) -> BOOL;
|
pub(crate) fn uninit_cliprdr(context: *mut CliprdrClientContext) -> BOOL;
|
||||||
pub(crate) fn empty_cliprdr(
|
pub(crate) fn empty_cliprdr(
|
||||||
context: *mut CliprdrClientContext,
|
context: *mut CliprdrClientContext,
|
||||||
server_conn_id: UINT32,
|
connID: UINT32,
|
||||||
remote_conn_id: UINT32,
|
|
||||||
) -> BOOL;
|
) -> BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,39 +17,28 @@ use std::{
|
|||||||
|
|
||||||
pub mod cliprdr;
|
pub mod cliprdr;
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ConnID {
|
|
||||||
pub server_conn_id: u32,
|
|
||||||
pub remote_conn_id: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
#[serde(tag = "t", content = "c")]
|
#[serde(tag = "t", content = "c")]
|
||||||
pub enum ClipbaordFile {
|
pub enum ClipbaordFile {
|
||||||
ServerFormatList {
|
ServerFormatList {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
format_list: Vec<(i32, String)>,
|
format_list: Vec<(i32, String)>,
|
||||||
},
|
},
|
||||||
ServerFormatListResponse {
|
ServerFormatListResponse {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
},
|
},
|
||||||
ServerFormatDataRequest {
|
ServerFormatDataRequest {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
requested_format_id: i32,
|
requested_format_id: i32,
|
||||||
},
|
},
|
||||||
ServerFormatDataResponse {
|
ServerFormatDataResponse {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
format_data: Vec<u8>,
|
format_data: Vec<u8>,
|
||||||
},
|
},
|
||||||
FileContentsRequest {
|
FileContentsRequest {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
stream_id: i32,
|
stream_id: i32,
|
||||||
list_index: i32,
|
list_index: i32,
|
||||||
dw_flags: i32,
|
dw_flags: i32,
|
||||||
@ -60,8 +49,7 @@ pub enum ClipbaordFile {
|
|||||||
clip_data_id: i32,
|
clip_data_id: i32,
|
||||||
},
|
},
|
||||||
FileContentsResponse {
|
FileContentsResponse {
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
stream_id: i32,
|
stream_id: i32,
|
||||||
requested_data: Vec<u8>,
|
requested_data: Vec<u8>,
|
||||||
@ -70,12 +58,11 @@ pub enum ClipbaordFile {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ConnEnabled {
|
struct ConnEnabled {
|
||||||
server_conn_enabled: HashMap<i32, bool>,
|
conn_enabled: HashMap<i32, bool>,
|
||||||
remote_conn_enabled: HashMap<i32, bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref MSG_CHANNEL_CLIENT: (UnboundedSender<(ConnID, ClipbaordFile)>, TokioMutex<UnboundedReceiver<(ConnID, ClipbaordFile)>>) = {
|
static ref MSG_CHANNEL_CLIENT: (UnboundedSender<(i32, ClipbaordFile)>, TokioMutex<UnboundedReceiver<(i32, ClipbaordFile)>>) = {
|
||||||
let (tx, rx) = unbounded_channel();
|
let (tx, rx) = unbounded_channel();
|
||||||
(tx, TokioMutex::new(rx))
|
(tx, TokioMutex::new(rx))
|
||||||
};
|
};
|
||||||
@ -84,120 +71,78 @@ lazy_static::lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn get_rx_clip_client<'a>() -> &'a TokioMutex<UnboundedReceiver<(ConnID, ClipbaordFile)>> {
|
pub fn get_rx_clip_client<'a>() -> &'a TokioMutex<UnboundedReceiver<(i32, ClipbaordFile)>> {
|
||||||
&MSG_CHANNEL_CLIENT.1
|
&MSG_CHANNEL_CLIENT.1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_conn_enabled(server_conn_id: i32, remote_conn_id: i32, enabled: bool) {
|
pub fn set_conn_enabled(conn_id: i32, enabled: bool) {
|
||||||
let mut lock = CLIP_CONN_ENABLED.lock().unwrap();
|
let mut lock = CLIP_CONN_ENABLED.lock().unwrap();
|
||||||
if server_conn_id != 0 {
|
if conn_id != 0 {
|
||||||
let _ = lock.server_conn_enabled.insert(server_conn_id, enabled);
|
let _ = lock.conn_enabled.insert(conn_id, enabled);
|
||||||
}
|
|
||||||
if remote_conn_id != 0 {
|
|
||||||
let _ = lock.remote_conn_enabled.insert(remote_conn_id, enabled);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty_clipboard(
|
pub fn empty_clipboard(context: &mut Box<CliprdrClientContext>, conn_id: i32) -> bool {
|
||||||
context: &mut Box<CliprdrClientContext>,
|
unsafe { TRUE == cliprdr::empty_cliprdr(&mut (**context), conn_id as u32) }
|
||||||
server_conn_id: i32,
|
|
||||||
remote_conn_id: i32,
|
|
||||||
) -> bool {
|
|
||||||
unsafe {
|
|
||||||
TRUE == cliprdr::empty_cliprdr(
|
|
||||||
&mut (**context),
|
|
||||||
server_conn_id as u32,
|
|
||||||
remote_conn_id as u32,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn server_clip_file(
|
pub fn server_clip_file(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
conn_id: ConnID,
|
s_conn_id: i32,
|
||||||
msg: ClipbaordFile,
|
msg: ClipbaordFile,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
match msg {
|
match msg {
|
||||||
ClipbaordFile::ServerFormatList {
|
ClipbaordFile::ServerFormatList {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
format_list,
|
format_list,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("server_format_list called");
|
log::debug!("server_format_list called");
|
||||||
let ret = server_format_list(context, server_conn_id, remote_conn_id, format_list);
|
let ret = server_format_list(context, conn_id, format_list);
|
||||||
log::debug!("server_format_list called, return {}", ret);
|
log::debug!("server_format_list called, return {}", ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
ClipbaordFile::ServerFormatListResponse {
|
ClipbaordFile::ServerFormatListResponse {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("format_list_response called");
|
log::debug!("format_list_response called");
|
||||||
let ret =
|
let ret = server_format_list_response(context, conn_id, msg_flags);
|
||||||
server_format_list_response(context, server_conn_id, remote_conn_id, msg_flags);
|
|
||||||
log::debug!("server_format_list_response called, return {}", ret);
|
log::debug!("server_format_list_response called, return {}", ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
ClipbaordFile::ServerFormatDataRequest {
|
ClipbaordFile::ServerFormatDataRequest {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("format_data_request called");
|
log::debug!("format_data_request called");
|
||||||
let ret = server_format_data_request(
|
let ret = server_format_data_request(context, conn_id, requested_format_id);
|
||||||
context,
|
|
||||||
server_conn_id,
|
|
||||||
remote_conn_id,
|
|
||||||
requested_format_id,
|
|
||||||
);
|
|
||||||
log::debug!("server_format_data_request called, return {}", ret);
|
log::debug!("server_format_data_request called, return {}", ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
ClipbaordFile::ServerFormatDataResponse {
|
ClipbaordFile::ServerFormatDataResponse {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
format_data,
|
format_data,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("format_data_response called");
|
log::debug!("format_data_response called");
|
||||||
let ret = server_format_data_response(
|
let ret = server_format_data_response(context, conn_id, msg_flags, format_data);
|
||||||
context,
|
|
||||||
server_conn_id,
|
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
|
||||||
format_data,
|
|
||||||
);
|
|
||||||
log::debug!("server_format_data_response called, return {}", ret);
|
log::debug!("server_format_data_response called, return {}", ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
ClipbaordFile::FileContentsRequest {
|
ClipbaordFile::FileContentsRequest {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
stream_id,
|
stream_id,
|
||||||
list_index,
|
list_index,
|
||||||
dw_flags,
|
dw_flags,
|
||||||
@ -207,17 +152,13 @@ pub fn server_clip_file(
|
|||||||
have_clip_data_id,
|
have_clip_data_id,
|
||||||
clip_data_id,
|
clip_data_id,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("file_contents_request called");
|
log::debug!("file_contents_request called");
|
||||||
let ret = server_file_contents_request(
|
let ret = server_file_contents_request(
|
||||||
context,
|
context,
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
stream_id,
|
stream_id,
|
||||||
list_index,
|
list_index,
|
||||||
dw_flags,
|
dw_flags,
|
||||||
@ -231,23 +172,18 @@ pub fn server_clip_file(
|
|||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
ClipbaordFile::FileContentsResponse {
|
ClipbaordFile::FileContentsResponse {
|
||||||
mut server_conn_id,
|
mut conn_id,
|
||||||
mut remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
} => {
|
} => {
|
||||||
if conn_id.server_conn_id != 0 {
|
if s_conn_id != 0 {
|
||||||
server_conn_id = conn_id.server_conn_id as i32;
|
conn_id = s_conn_id as i32;
|
||||||
}
|
|
||||||
if conn_id.remote_conn_id != 0 {
|
|
||||||
remote_conn_id = conn_id.remote_conn_id as i32;
|
|
||||||
}
|
}
|
||||||
log::debug!("file_contents_response called");
|
log::debug!("file_contents_response called");
|
||||||
let ret = server_file_contents_response(
|
let ret = server_file_contents_response(
|
||||||
context,
|
context,
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
@ -260,8 +196,7 @@ pub fn server_clip_file(
|
|||||||
|
|
||||||
pub fn server_format_list(
|
pub fn server_format_list(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
format_list: Vec<(i32, String)>,
|
format_list: Vec<(i32, String)>,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -288,8 +223,7 @@ pub fn server_format_list(
|
|||||||
.collect::<Vec<CLIPRDR_FORMAT>>();
|
.collect::<Vec<CLIPRDR_FORMAT>>();
|
||||||
|
|
||||||
let format_list = CLIPRDR_FORMAT_LIST {
|
let format_list = CLIPRDR_FORMAT_LIST {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: 0 as UINT16,
|
msgFlags: 0 as UINT16,
|
||||||
dataLen: 0 as UINT32,
|
dataLen: 0 as UINT32,
|
||||||
@ -311,14 +245,12 @@ pub fn server_format_list(
|
|||||||
}
|
}
|
||||||
pub fn server_format_list_response(
|
pub fn server_format_list_response(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let format_list_response = CLIPRDR_FORMAT_LIST_RESPONSE {
|
let format_list_response = CLIPRDR_FORMAT_LIST_RESPONSE {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: msg_flags as UINT16,
|
msgFlags: msg_flags as UINT16,
|
||||||
dataLen: 0 as UINT32,
|
dataLen: 0 as UINT32,
|
||||||
@ -332,14 +264,12 @@ pub fn server_format_list_response(
|
|||||||
}
|
}
|
||||||
pub fn server_format_data_request(
|
pub fn server_format_data_request(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
requested_format_id: i32,
|
requested_format_id: i32,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let format_data_request = CLIPRDR_FORMAT_DATA_REQUEST {
|
let format_data_request = CLIPRDR_FORMAT_DATA_REQUEST {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: 0 as UINT16,
|
msgFlags: 0 as UINT16,
|
||||||
dataLen: 0 as UINT32,
|
dataLen: 0 as UINT32,
|
||||||
@ -352,15 +282,13 @@ pub fn server_format_data_request(
|
|||||||
}
|
}
|
||||||
pub fn server_format_data_response(
|
pub fn server_format_data_response(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
mut format_data: Vec<u8>,
|
mut format_data: Vec<u8>,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let format_data_response = CLIPRDR_FORMAT_DATA_RESPONSE {
|
let format_data_response = CLIPRDR_FORMAT_DATA_RESPONSE {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: msg_flags as UINT16,
|
msgFlags: msg_flags as UINT16,
|
||||||
dataLen: format_data.len() as UINT32,
|
dataLen: format_data.len() as UINT32,
|
||||||
@ -375,8 +303,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 Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
stream_id: i32,
|
stream_id: i32,
|
||||||
list_index: i32,
|
list_index: i32,
|
||||||
dw_flags: i32,
|
dw_flags: i32,
|
||||||
@ -388,8 +315,7 @@ pub fn server_file_contents_request(
|
|||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let file_contents_request = CLIPRDR_FILE_CONTENTS_REQUEST {
|
let file_contents_request = CLIPRDR_FILE_CONTENTS_REQUEST {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: 0 as UINT16,
|
msgFlags: 0 as UINT16,
|
||||||
dataLen: 0 as UINT32,
|
dataLen: 0 as UINT32,
|
||||||
@ -411,16 +337,14 @@ pub fn server_file_contents_request(
|
|||||||
}
|
}
|
||||||
pub fn server_file_contents_response(
|
pub fn server_file_contents_response(
|
||||||
context: &mut Box<CliprdrClientContext>,
|
context: &mut Box<CliprdrClientContext>,
|
||||||
server_conn_id: i32,
|
conn_id: i32,
|
||||||
remote_conn_id: i32,
|
|
||||||
msg_flags: i32,
|
msg_flags: i32,
|
||||||
stream_id: i32,
|
stream_id: i32,
|
||||||
mut requested_data: Vec<u8>,
|
mut requested_data: Vec<u8>,
|
||||||
) -> u32 {
|
) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let file_contents_response = CLIPRDR_FILE_CONTENTS_RESPONSE {
|
let file_contents_response = CLIPRDR_FILE_CONTENTS_RESPONSE {
|
||||||
serverConnID: server_conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
remoteConnID: remote_conn_id as UINT32,
|
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
msgFlags: msg_flags as UINT16,
|
msgFlags: msg_flags as UINT16,
|
||||||
dataLen: 4 + requested_data.len() as UINT32,
|
dataLen: 4 + requested_data.len() as UINT32,
|
||||||
@ -453,37 +377,19 @@ pub fn create_cliprdr_context(
|
|||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn check_enabled(server_conn_id: UINT32, remote_conn_id: UINT32) -> BOOL {
|
extern "C" fn check_enabled(conn_id: UINT32) -> BOOL {
|
||||||
let lock = CLIP_CONN_ENABLED.lock().unwrap();
|
let lock = CLIP_CONN_ENABLED.lock().unwrap();
|
||||||
if server_conn_id == 0 && remote_conn_id == 0 {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut server_conn_enabled = false;
|
let mut connd_enabled = false;
|
||||||
if server_conn_id != 0 {
|
if conn_id != 0 {
|
||||||
if let Some(true) = lock.server_conn_enabled.get(&(server_conn_id as i32)) {
|
if let Some(true) = lock.conn_enabled.get(&(conn_id as i32)) {
|
||||||
server_conn_enabled = true;
|
connd_enabled = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
server_conn_enabled = true;
|
connd_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let mut remote_conn_enabled = false;
|
return if connd_enabled { TRUE } else { FALSE };
|
||||||
// remote connection is always enabled
|
|
||||||
// if remote_conn_id != 0 {
|
|
||||||
// if let Some(true) = lock.remote_conn_enabled.get(&(remote_conn_id as i32)) {
|
|
||||||
// remote_conn_enabled = true;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// remote_conn_enabled = true;
|
|
||||||
// }
|
|
||||||
let remote_conn_enabled = true;
|
|
||||||
|
|
||||||
if server_conn_enabled && remote_conn_enabled {
|
|
||||||
return TRUE;
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn client_format_list(
|
extern "C" fn client_format_list(
|
||||||
@ -492,8 +398,7 @@ extern "C" fn client_format_list(
|
|||||||
) -> UINT {
|
) -> UINT {
|
||||||
log::debug!("client_format_list called");
|
log::debug!("client_format_list called");
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let mut format_list: Vec<(i32, String)> = Vec::new();
|
let mut format_list: Vec<(i32, String)> = Vec::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut i = 0u32;
|
let mut i = 0u32;
|
||||||
@ -515,16 +420,10 @@ extern "C" fn client_format_list(
|
|||||||
// log::debug!("format list item {}: format id: {}, format name: {}", i, format_data.formatId, &format_name);
|
// log::debug!("format list item {}: format id: {}, format name: {}", i, format_data.formatId, &format_name);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
server_conn_id = (*clip_format_list).serverConnID as i32;
|
conn_id = (*clip_format_list).connID as i32;
|
||||||
remote_conn_id = (*clip_format_list).remoteConnID as i32;
|
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
let data = ClipbaordFile::ServerFormatList {
|
let data = ClipbaordFile::ServerFormatList {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
format_list,
|
format_list,
|
||||||
};
|
};
|
||||||
// no need to handle result here
|
// no need to handle result here
|
||||||
@ -539,23 +438,13 @@ extern "C" fn client_format_list_response(
|
|||||||
) -> UINT {
|
) -> UINT {
|
||||||
log::debug!("client_format_list_response called");
|
log::debug!("client_format_list_response called");
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let msg_flags;
|
let msg_flags;
|
||||||
unsafe {
|
unsafe {
|
||||||
server_conn_id = (*format_list_response).serverConnID as i32;
|
conn_id = (*format_list_response).connID as i32;
|
||||||
remote_conn_id = (*format_list_response).remoteConnID as i32;
|
|
||||||
msg_flags = (*format_list_response).msgFlags as i32;
|
msg_flags = (*format_list_response).msgFlags as i32;
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
let data = ClipbaordFile::ServerFormatListResponse { conn_id, msg_flags };
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
let data = ClipbaordFile::ServerFormatListResponse {
|
|
||||||
server_conn_id,
|
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
|
||||||
};
|
|
||||||
// no need to handle result here
|
// no need to handle result here
|
||||||
MSG_CHANNEL_CLIENT.0.send((conn_id, data)).unwrap();
|
MSG_CHANNEL_CLIENT.0.send((conn_id, data)).unwrap();
|
||||||
|
|
||||||
@ -568,21 +457,14 @@ extern "C" fn client_format_data_request(
|
|||||||
) -> UINT {
|
) -> UINT {
|
||||||
log::debug!("client_format_data_request called");
|
log::debug!("client_format_data_request called");
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let requested_format_id;
|
let requested_format_id;
|
||||||
unsafe {
|
unsafe {
|
||||||
server_conn_id = (*format_data_request).serverConnID as i32;
|
conn_id = (*format_data_request).connID as i32;
|
||||||
remote_conn_id = (*format_data_request).remoteConnID as i32;
|
|
||||||
requested_format_id = (*format_data_request).requestedFormatId as i32;
|
requested_format_id = (*format_data_request).requestedFormatId as i32;
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
let data = ClipbaordFile::ServerFormatDataRequest {
|
let data = ClipbaordFile::ServerFormatDataRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
};
|
};
|
||||||
// no need to handle result here
|
// no need to handle result here
|
||||||
@ -595,15 +477,13 @@ extern "C" fn client_format_data_response(
|
|||||||
_context: *mut CliprdrClientContext,
|
_context: *mut CliprdrClientContext,
|
||||||
format_data_response: *const CLIPRDR_FORMAT_DATA_RESPONSE,
|
format_data_response: *const CLIPRDR_FORMAT_DATA_RESPONSE,
|
||||||
) -> UINT {
|
) -> UINT {
|
||||||
log::debug!("client_format_data_response called");
|
log::debug!("cconn_idlient_format_data_response called");
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let msg_flags;
|
let msg_flags;
|
||||||
let format_data;
|
let format_data;
|
||||||
unsafe {
|
unsafe {
|
||||||
server_conn_id = (*format_data_response).serverConnID as i32;
|
conn_id = (*format_data_response).connID as i32;
|
||||||
remote_conn_id = (*format_data_response).remoteConnID as i32;
|
|
||||||
msg_flags = (*format_data_response).msgFlags as i32;
|
msg_flags = (*format_data_response).msgFlags as i32;
|
||||||
if (*format_data_response).requestedFormatData.is_null() {
|
if (*format_data_response).requestedFormatData.is_null() {
|
||||||
format_data = Vec::new();
|
format_data = Vec::new();
|
||||||
@ -615,13 +495,8 @@ extern "C" fn client_format_data_response(
|
|||||||
.to_vec();
|
.to_vec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
let data = ClipbaordFile::ServerFormatDataResponse {
|
let data = ClipbaordFile::ServerFormatDataResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
format_data,
|
format_data,
|
||||||
};
|
};
|
||||||
@ -647,8 +522,7 @@ extern "C" fn client_file_contents_request(
|
|||||||
// return ERROR_INVALID_PARAMETER;
|
// return ERROR_INVALID_PARAMETER;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let stream_id;
|
let stream_id;
|
||||||
let list_index;
|
let list_index;
|
||||||
let dw_flags;
|
let dw_flags;
|
||||||
@ -658,8 +532,7 @@ extern "C" fn client_file_contents_request(
|
|||||||
let have_clip_data_id;
|
let have_clip_data_id;
|
||||||
let clip_data_id;
|
let clip_data_id;
|
||||||
unsafe {
|
unsafe {
|
||||||
server_conn_id = (*file_contents_request).serverConnID as i32;
|
conn_id = (*file_contents_request).connID as i32;
|
||||||
remote_conn_id = (*file_contents_request).remoteConnID as i32;
|
|
||||||
stream_id = (*file_contents_request).streamId as i32;
|
stream_id = (*file_contents_request).streamId as i32;
|
||||||
list_index = (*file_contents_request).listIndex as i32;
|
list_index = (*file_contents_request).listIndex as i32;
|
||||||
dw_flags = (*file_contents_request).dwFlags as i32;
|
dw_flags = (*file_contents_request).dwFlags as i32;
|
||||||
@ -669,14 +542,9 @@ extern "C" fn client_file_contents_request(
|
|||||||
have_clip_data_id = (*file_contents_request).haveClipDataId == TRUE;
|
have_clip_data_id = (*file_contents_request).haveClipDataId == TRUE;
|
||||||
clip_data_id = (*file_contents_request).clipDataId as i32;
|
clip_data_id = (*file_contents_request).clipDataId as i32;
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
|
|
||||||
let data = ClipbaordFile::FileContentsRequest {
|
let data = ClipbaordFile::FileContentsRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
stream_id,
|
stream_id,
|
||||||
list_index,
|
list_index,
|
||||||
dw_flags,
|
dw_flags,
|
||||||
@ -698,14 +566,12 @@ extern "C" fn client_file_contents_response(
|
|||||||
) -> UINT {
|
) -> UINT {
|
||||||
log::debug!("client_file_contents_response called");
|
log::debug!("client_file_contents_response called");
|
||||||
|
|
||||||
let server_conn_id;
|
let conn_id;
|
||||||
let remote_conn_id;
|
|
||||||
let msg_flags;
|
let msg_flags;
|
||||||
let stream_id;
|
let stream_id;
|
||||||
let requested_data;
|
let requested_data;
|
||||||
unsafe {
|
unsafe {
|
||||||
server_conn_id = (*file_contents_response).serverConnID as i32;
|
conn_id = (*file_contents_response).connID as i32;
|
||||||
remote_conn_id = (*file_contents_response).remoteConnID as i32;
|
|
||||||
msg_flags = (*file_contents_response).msgFlags as i32;
|
msg_flags = (*file_contents_response).msgFlags as i32;
|
||||||
stream_id = (*file_contents_response).streamId as i32;
|
stream_id = (*file_contents_response).streamId as i32;
|
||||||
if (*file_contents_response).requestedData.is_null() {
|
if (*file_contents_response).requestedData.is_null() {
|
||||||
@ -718,14 +584,8 @@ extern "C" fn client_file_contents_response(
|
|||||||
.to_vec();
|
.to_vec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: remote_conn_id as u32,
|
|
||||||
};
|
|
||||||
|
|
||||||
let data = ClipbaordFile::FileContentsResponse {
|
let data = ClipbaordFile::FileContentsResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
|
@ -99,17 +99,9 @@ struct _CLIPRDR_MFPICT
|
|||||||
};
|
};
|
||||||
typedef struct _CLIPRDR_MFPICT CLIPRDR_MFPICT;
|
typedef struct _CLIPRDR_MFPICT CLIPRDR_MFPICT;
|
||||||
|
|
||||||
struct _CONN_ID
|
|
||||||
{
|
|
||||||
UINT32 serverConnID;
|
|
||||||
UINT32 remoteConnID;
|
|
||||||
};
|
|
||||||
typedef struct _CONN_ID CONN_ID;
|
|
||||||
|
|
||||||
struct _FORMAT_IDS
|
struct _FORMAT_IDS
|
||||||
{
|
{
|
||||||
UINT32 serverConnID;
|
UINT32 connID;
|
||||||
UINT32 remoteConnID;
|
|
||||||
UINT32 size;
|
UINT32 size;
|
||||||
UINT32 *formats;
|
UINT32 *formats;
|
||||||
};
|
};
|
||||||
@ -186,8 +178,7 @@ struct _CliprdrStream
|
|||||||
ULARGE_INTEGER m_lOffset;
|
ULARGE_INTEGER m_lOffset;
|
||||||
FILEDESCRIPTORW m_Dsc;
|
FILEDESCRIPTORW m_Dsc;
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
UINT32 m_serverConnID;
|
UINT32 m_connID;
|
||||||
UINT32 m_remoteConnID;
|
|
||||||
};
|
};
|
||||||
typedef struct _CliprdrStream CliprdrStream;
|
typedef struct _CliprdrStream CliprdrStream;
|
||||||
|
|
||||||
@ -202,8 +193,7 @@ struct _CliprdrDataObject
|
|||||||
ULONG m_nStreams;
|
ULONG m_nStreams;
|
||||||
IStream **m_pStream;
|
IStream **m_pStream;
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
UINT32 m_serverConnID;
|
UINT32 m_connID;
|
||||||
UINT32 m_remoteConnID;
|
|
||||||
};
|
};
|
||||||
typedef struct _CliprdrDataObject CliprdrDataObject;
|
typedef struct _CliprdrDataObject CliprdrDataObject;
|
||||||
|
|
||||||
@ -256,13 +246,13 @@ BOOL wf_cliprdr_init(wfClipboard *clipboard, CliprdrClientContext *cliprdr);
|
|||||||
BOOL wf_cliprdr_uninit(wfClipboard *clipboard, CliprdrClientContext *cliprdr);
|
BOOL wf_cliprdr_uninit(wfClipboard *clipboard, CliprdrClientContext *cliprdr);
|
||||||
BOOL wf_do_empty_cliprdr(wfClipboard *clipboard);
|
BOOL wf_do_empty_cliprdr(wfClipboard *clipboard);
|
||||||
|
|
||||||
static BOOL wf_create_file_obj(UINT32 serverConnID, UINT32 remoteConnID, wfClipboard *cliprdrrdr, IDataObject **ppDataObject);
|
static BOOL wf_create_file_obj(UINT32 connID, wfClipboard *cliprdrrdr, IDataObject **ppDataObject);
|
||||||
static void wf_destroy_file_obj(IDataObject *instance);
|
static void wf_destroy_file_obj(IDataObject *instance);
|
||||||
static UINT32 get_remote_format_id(wfClipboard *clipboard, UINT32 local_format);
|
static UINT32 get_remote_format_id(wfClipboard *clipboard, UINT32 local_format);
|
||||||
static UINT cliprdr_send_data_request(UINT32 serverConnID, UINT32 remoteConnID, wfClipboard *clipboard, UINT32 format);
|
static UINT cliprdr_send_data_request(UINT32 connID, wfClipboard *clipboard, UINT32 format);
|
||||||
static UINT cliprdr_send_lock(wfClipboard *clipboard);
|
static UINT cliprdr_send_lock(wfClipboard *clipboard);
|
||||||
static UINT cliprdr_send_unlock(wfClipboard *clipboard);
|
static UINT cliprdr_send_unlock(wfClipboard *clipboard);
|
||||||
static UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 serverConnID, UINT32 remoteConnID, const void *streamid,
|
static UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 connID, const void *streamid,
|
||||||
ULONG index, UINT32 flag, DWORD positionhigh,
|
ULONG index, UINT32 flag, DWORD positionhigh,
|
||||||
DWORD positionlow, ULONG request);
|
DWORD positionlow, ULONG request);
|
||||||
|
|
||||||
@ -352,7 +342,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream *This, void *pv, ULO
|
|||||||
if (instance->m_lOffset.QuadPart >= instance->m_lSize.QuadPart)
|
if (instance->m_lOffset.QuadPart >= instance->m_lSize.QuadPart)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
ret = cliprdr_send_request_filecontents(clipboard, instance->m_serverConnID, instance->m_remoteConnID, (void *)This, instance->m_lIndex,
|
ret = cliprdr_send_request_filecontents(clipboard, instance->m_connID, (void *)This, instance->m_lIndex,
|
||||||
FILECONTENTS_RANGE, instance->m_lOffset.HighPart,
|
FILECONTENTS_RANGE, instance->m_lOffset.HighPart,
|
||||||
instance->m_lOffset.LowPart, cb);
|
instance->m_lOffset.LowPart, cb);
|
||||||
|
|
||||||
@ -519,7 +509,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Clone(IStream *This, IStream **pp
|
|||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CliprdrStream *CliprdrStream_New(UINT32 serverConnID, UINT32 remoteConnID, ULONG index, void *pData, const FILEDESCRIPTORW *dsc)
|
static CliprdrStream *CliprdrStream_New(UINT32 connID, ULONG index, void *pData, const FILEDESCRIPTORW *dsc)
|
||||||
{
|
{
|
||||||
IStream *iStream;
|
IStream *iStream;
|
||||||
BOOL success = FALSE;
|
BOOL success = FALSE;
|
||||||
@ -554,8 +544,7 @@ static CliprdrStream *CliprdrStream_New(UINT32 serverConnID, UINT32 remoteConnID
|
|||||||
instance->m_lIndex = index;
|
instance->m_lIndex = index;
|
||||||
instance->m_pData = pData;
|
instance->m_pData = pData;
|
||||||
instance->m_lOffset.QuadPart = 0;
|
instance->m_lOffset.QuadPart = 0;
|
||||||
instance->m_serverConnID = serverConnID;
|
instance->m_connID = connID;
|
||||||
instance->m_remoteConnID = remoteConnID;
|
|
||||||
|
|
||||||
if (instance->m_Dsc.dwFlags & FD_ATTRIBUTES)
|
if (instance->m_Dsc.dwFlags & FD_ATTRIBUTES)
|
||||||
{
|
{
|
||||||
@ -566,7 +555,7 @@ static CliprdrStream *CliprdrStream_New(UINT32 serverConnID, UINT32 remoteConnID
|
|||||||
if (((instance->m_Dsc.dwFlags & FD_FILESIZE) == 0) && !isDir)
|
if (((instance->m_Dsc.dwFlags & FD_FILESIZE) == 0) && !isDir)
|
||||||
{
|
{
|
||||||
/* get content size of this stream */
|
/* get content size of this stream */
|
||||||
if (cliprdr_send_request_filecontents(clipboard, instance->m_serverConnID, instance->m_remoteConnID, (void *)instance,
|
if (cliprdr_send_request_filecontents(clipboard, instance->m_connID, (void *)instance,
|
||||||
instance->m_lIndex, FILECONTENTS_SIZE, 0, 0,
|
instance->m_lIndex, FILECONTENTS_SIZE, 0, 0,
|
||||||
8) == CHANNEL_RC_OK)
|
8) == CHANNEL_RC_OK)
|
||||||
{
|
{
|
||||||
@ -685,7 +674,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject *This, FO
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
clipboard = (wfClipboard *)instance->m_pData;
|
clipboard = (wfClipboard *)instance->m_pData;
|
||||||
if (!clipboard->context->CheckEnabled(instance->m_serverConnID, instance->m_remoteConnID))
|
if (!clipboard->context->CheckEnabled(instance->m_connID))
|
||||||
{
|
{
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
@ -694,7 +683,10 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject *This, FO
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ((idx = cliprdr_lookup_format(instance, pFormatEtc)) == -1)
|
if ((idx = cliprdr_lookup_format(instance, pFormatEtc)) == -1)
|
||||||
|
{
|
||||||
|
// empty clipboard here?
|
||||||
return DV_E_FORMATETC;
|
return DV_E_FORMATETC;
|
||||||
|
}
|
||||||
|
|
||||||
pMedium->tymed = instance->m_pFormatEtc[idx].tymed;
|
pMedium->tymed = instance->m_pFormatEtc[idx].tymed;
|
||||||
pMedium->pUnkForRelease = 0;
|
pMedium->pUnkForRelease = 0;
|
||||||
@ -705,7 +697,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject *This, FO
|
|||||||
FILEGROUPDESCRIPTORW *dsc;
|
FILEGROUPDESCRIPTORW *dsc;
|
||||||
// DWORD remote_format_id = get_remote_format_id(clipboard, instance->m_pFormatEtc[idx].cfFormat);
|
// DWORD remote_format_id = get_remote_format_id(clipboard, instance->m_pFormatEtc[idx].cfFormat);
|
||||||
// FIXME: origin code may be failed here???
|
// FIXME: origin code may be failed here???
|
||||||
if (cliprdr_send_data_request(instance->m_serverConnID, instance->m_remoteConnID, clipboard, instance->m_pFormatEtc[idx].cfFormat) != 0)
|
if (cliprdr_send_data_request(instance->m_connID, clipboard, instance->m_pFormatEtc[idx].cfFormat) != 0)
|
||||||
{
|
{
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
}
|
}
|
||||||
@ -734,7 +726,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject *This, FO
|
|||||||
for (i = 0; i < instance->m_nStreams; i++)
|
for (i = 0; i < instance->m_nStreams; i++)
|
||||||
{
|
{
|
||||||
instance->m_pStream[i] =
|
instance->m_pStream[i] =
|
||||||
(IStream *)CliprdrStream_New(instance->m_serverConnID, instance->m_remoteConnID, i, clipboard, &dsc->fgd[i]);
|
(IStream *)CliprdrStream_New(instance->m_connID, i, clipboard, &dsc->fgd[i]);
|
||||||
|
|
||||||
if (!instance->m_pStream[i])
|
if (!instance->m_pStream[i])
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
@ -867,7 +859,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_EnumDAdvise(IDataObject *This
|
|||||||
return OLE_E_ADVISENOTSUPPORTED;
|
return OLE_E_ADVISENOTSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CliprdrDataObject *CliprdrDataObject_New(UINT32 serverConnID, UINT32 remoteConnID, FORMATETC *fmtetc, STGMEDIUM *stgmed, ULONG count,
|
static CliprdrDataObject *CliprdrDataObject_New(UINT32 connID, FORMATETC *fmtetc, STGMEDIUM *stgmed, ULONG count,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
CliprdrDataObject *instance;
|
CliprdrDataObject *instance;
|
||||||
@ -900,8 +892,7 @@ static CliprdrDataObject *CliprdrDataObject_New(UINT32 serverConnID, UINT32 remo
|
|||||||
instance->m_pData = data;
|
instance->m_pData = data;
|
||||||
instance->m_nStreams = 0;
|
instance->m_nStreams = 0;
|
||||||
instance->m_pStream = NULL;
|
instance->m_pStream = NULL;
|
||||||
instance->m_serverConnID = serverConnID;
|
instance->m_connID = connID;
|
||||||
instance->m_remoteConnID = remoteConnID;
|
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
@ -951,7 +942,7 @@ void CliprdrDataObject_Delete(CliprdrDataObject *instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL wf_create_file_obj(CONN_ID *conn_id, wfClipboard *clipboard, IDataObject **ppDataObject)
|
static BOOL wf_create_file_obj(UINT32 *connID, wfClipboard *clipboard, IDataObject **ppDataObject)
|
||||||
{
|
{
|
||||||
FORMATETC fmtetc[2];
|
FORMATETC fmtetc[2];
|
||||||
STGMEDIUM stgmeds[2];
|
STGMEDIUM stgmeds[2];
|
||||||
@ -975,7 +966,7 @@ static BOOL wf_create_file_obj(CONN_ID *conn_id, wfClipboard *clipboard, IDataOb
|
|||||||
stgmeds[1].tymed = TYMED_ISTREAM;
|
stgmeds[1].tymed = TYMED_ISTREAM;
|
||||||
stgmeds[1].pstm = NULL;
|
stgmeds[1].pstm = NULL;
|
||||||
stgmeds[1].pUnkForRelease = NULL;
|
stgmeds[1].pUnkForRelease = NULL;
|
||||||
*ppDataObject = (IDataObject *)CliprdrDataObject_New(conn_id->serverConnID, conn_id->remoteConnID, fmtetc, stgmeds, 2, clipboard);
|
*ppDataObject = (IDataObject *)CliprdrDataObject_New(*connID, fmtetc, stgmeds, 2, clipboard);
|
||||||
return (*ppDataObject) ? TRUE : FALSE;
|
return (*ppDataObject) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1424,8 +1415,7 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formatList.serverConnID = 0;
|
formatList.connID = 0;
|
||||||
formatList.remoteConnID = 0;
|
|
||||||
formatList.numFormats = numFormats;
|
formatList.numFormats = numFormats;
|
||||||
formatList.formats = formats;
|
formatList.formats = formats;
|
||||||
formatList.msgType = CB_FORMAT_LIST;
|
formatList.msgType = CB_FORMAT_LIST;
|
||||||
@ -1446,7 +1436,7 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT cliprdr_send_data_request(UINT32 serverConnID, UINT32 remoteConnID, wfClipboard *clipboard, UINT32 formatId)
|
static UINT cliprdr_send_data_request(UINT32 connID, wfClipboard *clipboard, UINT32 formatId)
|
||||||
{
|
{
|
||||||
UINT rc;
|
UINT rc;
|
||||||
UINT32 remoteFormatId;
|
UINT32 remoteFormatId;
|
||||||
@ -1457,8 +1447,7 @@ static UINT cliprdr_send_data_request(UINT32 serverConnID, UINT32 remoteConnID,
|
|||||||
|
|
||||||
remoteFormatId = get_remote_format_id(clipboard, formatId);
|
remoteFormatId = get_remote_format_id(clipboard, formatId);
|
||||||
|
|
||||||
formatDataRequest.serverConnID = serverConnID;
|
formatDataRequest.connID = connID;
|
||||||
formatDataRequest.remoteConnID = remoteConnID;
|
|
||||||
formatDataRequest.requestedFormatId = remoteFormatId;
|
formatDataRequest.requestedFormatId = remoteFormatId;
|
||||||
clipboard->requestedFormatId = formatId;
|
clipboard->requestedFormatId = formatId;
|
||||||
rc = clipboard->context->ClientFormatDataRequest(clipboard->context, &formatDataRequest);
|
rc = clipboard->context->ClientFormatDataRequest(clipboard->context, &formatDataRequest);
|
||||||
@ -1473,7 +1462,7 @@ static UINT cliprdr_send_data_request(UINT32 serverConnID, UINT32 remoteConnID,
|
|||||||
DWORD waitRes = WaitForSingleObject(clipboard->response_data_event, 50);
|
DWORD waitRes = WaitForSingleObject(clipboard->response_data_event, 50);
|
||||||
if (waitRes == WAIT_TIMEOUT)
|
if (waitRes == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
if (clipboard->context->CheckEnabled(serverConnID, remoteConnID))
|
if (clipboard->context->CheckEnabled(connID))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1514,7 +1503,7 @@ static UINT cliprdr_send_data_request(UINT32 serverConnID, UINT32 remoteConnID,
|
|||||||
return ERROR_INTERNAL_ERROR;
|
return ERROR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 serverConnID, UINT32 remoteConnID, const void *streamid, ULONG index,
|
UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 connID, const void *streamid, ULONG index,
|
||||||
UINT32 flag, DWORD positionhigh, DWORD positionlow,
|
UINT32 flag, DWORD positionhigh, DWORD positionlow,
|
||||||
ULONG nreq)
|
ULONG nreq)
|
||||||
{
|
{
|
||||||
@ -1524,8 +1513,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 serverConn
|
|||||||
if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsRequest)
|
if (!clipboard || !clipboard->context || !clipboard->context->ClientFileContentsRequest)
|
||||||
return ERROR_INTERNAL_ERROR;
|
return ERROR_INTERNAL_ERROR;
|
||||||
|
|
||||||
fileContentsRequest.serverConnID = serverConnID;
|
fileContentsRequest.connID = connID;
|
||||||
fileContentsRequest.remoteConnID = remoteConnID;
|
|
||||||
fileContentsRequest.streamId = (UINT32)(ULONG_PTR)streamid;
|
fileContentsRequest.streamId = (UINT32)(ULONG_PTR)streamid;
|
||||||
fileContentsRequest.listIndex = index;
|
fileContentsRequest.listIndex = index;
|
||||||
fileContentsRequest.dwFlags = flag;
|
fileContentsRequest.dwFlags = flag;
|
||||||
@ -1546,7 +1534,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 serverConn
|
|||||||
DWORD waitRes = WaitForSingleObject(clipboard->req_fevent, 50);
|
DWORD waitRes = WaitForSingleObject(clipboard->req_fevent, 50);
|
||||||
if (waitRes == WAIT_TIMEOUT)
|
if (waitRes == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
if (clipboard->context->CheckEnabled(serverConnID, remoteConnID))
|
if (clipboard->context->CheckEnabled(connID))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1588,8 +1576,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 serverConn
|
|||||||
|
|
||||||
static UINT cliprdr_send_response_filecontents(
|
static UINT cliprdr_send_response_filecontents(
|
||||||
wfClipboard *clipboard,
|
wfClipboard *clipboard,
|
||||||
UINT32 serverConnID,
|
UINT32 connID,
|
||||||
UINT32 remoteConnID,
|
|
||||||
UINT16 msgFlags,
|
UINT16 msgFlags,
|
||||||
UINT32 streamId,
|
UINT32 streamId,
|
||||||
UINT32 size,
|
UINT32 size,
|
||||||
@ -1604,8 +1591,7 @@ static UINT cliprdr_send_response_filecontents(
|
|||||||
msgFlags = CB_RESPONSE_FAIL;
|
msgFlags = CB_RESPONSE_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileContentsResponse.serverConnID = serverConnID;
|
fileContentsResponse.connID = connID;
|
||||||
fileContentsResponse.remoteConnID = remoteConnID;
|
|
||||||
fileContentsResponse.streamId = streamId;
|
fileContentsResponse.streamId = streamId;
|
||||||
fileContentsResponse.cbRequested = size;
|
fileContentsResponse.cbRequested = size;
|
||||||
fileContentsResponse.requestedData = data;
|
fileContentsResponse.requestedData = data;
|
||||||
@ -1749,7 +1735,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
|||||||
wf_destroy_file_obj(clipboard->data_obj);
|
wf_destroy_file_obj(clipboard->data_obj);
|
||||||
clipboard->data_obj = NULL;
|
clipboard->data_obj = NULL;
|
||||||
}
|
}
|
||||||
if (wf_create_file_obj((CONN_ID *)lParam, clipboard, &clipboard->data_obj))
|
if (wf_create_file_obj((UINT32 *)lParam, clipboard, &clipboard->data_obj))
|
||||||
{
|
{
|
||||||
HRESULT res = OleSetClipboard(clipboard->data_obj);
|
HRESULT res = OleSetClipboard(clipboard->data_obj);
|
||||||
if (res != S_OK)
|
if (res != S_OK)
|
||||||
@ -1779,7 +1765,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
for (UINT32 i = 0; i < format_ids->size; ++i)
|
for (UINT32 i = 0; i < format_ids->size; ++i)
|
||||||
{
|
{
|
||||||
if (cliprdr_send_data_request(format_ids->serverConnID, format_ids->remoteConnID, clipboard, format_ids->formats[i]) != 0)
|
if (cliprdr_send_data_request(format_ids->connID, clipboard, format_ids->formats[i]) != 0)
|
||||||
{
|
{
|
||||||
DEBUG_CLIPRDR("error: cliprdr_send_data_request failed.");
|
DEBUG_CLIPRDR("error: cliprdr_send_data_request failed.");
|
||||||
continue;
|
continue;
|
||||||
@ -2145,8 +2131,7 @@ static UINT wf_cliprdr_send_client_capabilities(wfClipboard *clipboard)
|
|||||||
if (!clipboard || !clipboard->context || !clipboard->context->ClientCapabilities)
|
if (!clipboard || !clipboard->context || !clipboard->context->ClientCapabilities)
|
||||||
return ERROR_INTERNAL_ERROR;
|
return ERROR_INTERNAL_ERROR;
|
||||||
|
|
||||||
capabilities.serverConnID = 0;
|
capabilities.connID = 0;
|
||||||
capabilities.remoteConnID = 0;
|
|
||||||
capabilities.cCapabilitiesSets = 1;
|
capabilities.cCapabilitiesSets = 1;
|
||||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
|
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
|
||||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||||
@ -2262,9 +2247,8 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext *context,
|
|||||||
{
|
{
|
||||||
if (context->enableFiles)
|
if (context->enableFiles)
|
||||||
{
|
{
|
||||||
CONN_ID *p_conn_id = (CONN_ID *)calloc(1, sizeof(CONN_ID));
|
UINT32 *p_conn_id = (UINT32 *)calloc(1, sizeof(UINT32));
|
||||||
p_conn_id->serverConnID = formatList->serverConnID;
|
*p_conn_id = formatList->connID;
|
||||||
p_conn_id->remoteConnID = formatList->remoteConnID;
|
|
||||||
if (PostMessage(clipboard->hwnd, WM_CLIPRDR_MESSAGE, OLE_SETCLIPBOARD, p_conn_id))
|
if (PostMessage(clipboard->hwnd, WM_CLIPRDR_MESSAGE, OLE_SETCLIPBOARD, p_conn_id))
|
||||||
rc = CHANNEL_RC_OK;
|
rc = CHANNEL_RC_OK;
|
||||||
}
|
}
|
||||||
@ -2287,8 +2271,7 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext *context,
|
|||||||
// SetClipboardData(clipboard->format_mappings[i].local_format_id, NULL);
|
// SetClipboardData(clipboard->format_mappings[i].local_format_id, NULL);
|
||||||
|
|
||||||
FORMAT_IDS *format_ids = (FORMAT_IDS *)calloc(1, sizeof(FORMAT_IDS));
|
FORMAT_IDS *format_ids = (FORMAT_IDS *)calloc(1, sizeof(FORMAT_IDS));
|
||||||
format_ids->serverConnID = formatList->serverConnID;
|
format_ids->connID = formatList->connID;
|
||||||
format_ids->remoteConnID = formatList->remoteConnID;
|
|
||||||
format_ids->size = (UINT32)clipboard->map_size;
|
format_ids->size = (UINT32)clipboard->map_size;
|
||||||
format_ids->formats = (UINT32 *)calloc(format_ids->size, sizeof(UINT32));
|
format_ids->formats = (UINT32 *)calloc(format_ids->size, sizeof(UINT32));
|
||||||
for (i = 0; i < format_ids->size; ++i)
|
for (i = 0; i < format_ids->size; ++i)
|
||||||
@ -2563,8 +2546,7 @@ exit:
|
|||||||
{
|
{
|
||||||
response.msgFlags = CB_RESPONSE_FAIL;
|
response.msgFlags = CB_RESPONSE_FAIL;
|
||||||
}
|
}
|
||||||
response.serverConnID = formatDataRequest->serverConnID;
|
response.connID = formatDataRequest->connID;
|
||||||
response.remoteConnID = formatDataRequest->remoteConnID;
|
|
||||||
response.dataLen = size;
|
response.dataLen = size;
|
||||||
response.requestedFormatData = (BYTE *)buff;
|
response.requestedFormatData = (BYTE *)buff;
|
||||||
if (ERROR_SUCCESS != clipboard->context->ClientFormatDataResponse(clipboard->context, &response))
|
if (ERROR_SUCCESS != clipboard->context->ClientFormatDataResponse(clipboard->context, &response))
|
||||||
@ -2848,8 +2830,7 @@ exit:
|
|||||||
sRc =
|
sRc =
|
||||||
cliprdr_send_response_filecontents(
|
cliprdr_send_response_filecontents(
|
||||||
clipboard,
|
clipboard,
|
||||||
fileContentsRequest->serverConnID,
|
fileContentsRequest->connID,
|
||||||
fileContentsRequest->remoteConnID,
|
|
||||||
rc == CHANNEL_RC_OK ? CB_RESPONSE_OK : CB_RESPONSE_FAIL,
|
rc == CHANNEL_RC_OK ? CB_RESPONSE_OK : CB_RESPONSE_FAIL,
|
||||||
fileContentsRequest->streamId,
|
fileContentsRequest->streamId,
|
||||||
uSize,
|
uSize,
|
||||||
@ -3047,7 +3028,7 @@ BOOL uninit_cliprdr(CliprdrClientContext *context)
|
|||||||
return wf_cliprdr_uninit(&clipboard, context);
|
return wf_cliprdr_uninit(&clipboard, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 server_conn_id, UINT32 remote_conn_id)
|
BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 connID)
|
||||||
{
|
{
|
||||||
wfClipboard *clipboard = NULL;
|
wfClipboard *clipboard = NULL;
|
||||||
CliprdrDataObject *instance = NULL;
|
CliprdrDataObject *instance = NULL;
|
||||||
@ -3056,7 +3037,7 @@ BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 server_conn_id, UINT32
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (server_conn_id == 0 && remote_conn_id == 0)
|
if (connID == 0)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -3070,11 +3051,7 @@ BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 server_conn_id, UINT32
|
|||||||
instance = clipboard->data_obj;
|
instance = clipboard->data_obj;
|
||||||
if (instance)
|
if (instance)
|
||||||
{
|
{
|
||||||
if (server_conn_id != 0 && instance->m_serverConnID != server_conn_id)
|
if (instance->m_connID != connID)
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (remote_conn_id != 0 && instance->m_remoteConnID != remote_conn_id)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -308,58 +308,50 @@ message FileDirCreate {
|
|||||||
|
|
||||||
// main logic from freeRDP
|
// main logic from freeRDP
|
||||||
message CliprdrMonitorReady {
|
message CliprdrMonitorReady {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrFormat {
|
message CliprdrFormat {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
int32 id = 2;
|
||||||
int32 id = 3;
|
string format = 3;
|
||||||
string format = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrServerFormatList {
|
message CliprdrServerFormatList {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
repeated CliprdrFormat formats = 2;
|
||||||
repeated CliprdrFormat formats = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrServerFormatListResponse {
|
message CliprdrServerFormatListResponse {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
int32 msg_flags = 2;
|
||||||
int32 msg_flags = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrServerFormatDataRequest {
|
message CliprdrServerFormatDataRequest {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
int32 requested_format_id = 2;
|
||||||
int32 requested_format_id = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrServerFormatDataResponse {
|
message CliprdrServerFormatDataResponse {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
int32 msg_flags = 2;
|
||||||
int32 msg_flags = 3;
|
bytes format_data = 3;
|
||||||
bytes format_data = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrFileContentsRequest {
|
message CliprdrFileContentsRequest {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
int32 stream_id = 2;
|
||||||
int32 stream_id = 3;
|
int32 list_index = 3;
|
||||||
int32 list_index = 4;
|
int32 dw_flags = 4;
|
||||||
int32 dw_flags = 5;
|
int32 n_position_low = 5;
|
||||||
int32 n_position_low = 6;
|
int32 n_position_high = 6;
|
||||||
int32 n_position_high = 7;
|
int32 cb_requested = 7;
|
||||||
int32 cb_requested = 8;
|
bool have_clip_data_id = 8;
|
||||||
bool have_clip_data_id = 9;
|
int32 clip_data_id = 9;
|
||||||
int32 clip_data_id = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CliprdrFileContentsResponse {
|
message CliprdrFileContentsResponse {
|
||||||
int32 server_conn_id = 1;
|
int32 conn_id = 1;
|
||||||
int32 remote_conn_id = 2;
|
|
||||||
int32 msg_flags = 3;
|
int32 msg_flags = 3;
|
||||||
int32 stream_id = 4;
|
int32 stream_id = 4;
|
||||||
bytes requested_data = 5;
|
bytes requested_data = 5;
|
||||||
|
@ -4,15 +4,13 @@ use hbb_common::message_proto::*;
|
|||||||
pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
||||||
match clip {
|
match clip {
|
||||||
ClipbaordFile::ServerFormatList {
|
ClipbaordFile::ServerFormatList {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
format_list,
|
format_list,
|
||||||
} => {
|
} => {
|
||||||
let mut formats: Vec<CliprdrFormat> = Vec::new();
|
let mut formats: Vec<CliprdrFormat> = Vec::new();
|
||||||
for v in format_list.iter() {
|
for v in format_list.iter() {
|
||||||
formats.push(CliprdrFormat {
|
formats.push(CliprdrFormat {
|
||||||
server_conn_id: 0,
|
conn_id: 0,
|
||||||
remote_conn_id: 0,
|
|
||||||
id: v.0,
|
id: v.0,
|
||||||
format: v.1.clone(),
|
format: v.1.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@ -21,8 +19,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
Message {
|
Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_list(CliprdrServerFormatList {
|
union: Some(cliprdr::Union::format_list(CliprdrServerFormatList {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
formats,
|
formats,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})),
|
})),
|
||||||
@ -31,16 +28,11 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClipbaordFile::ServerFormatListResponse {
|
ClipbaordFile::ServerFormatListResponse { conn_id, msg_flags } => Message {
|
||||||
server_conn_id,
|
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
|
||||||
} => Message {
|
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_list_response(
|
union: Some(cliprdr::Union::format_list_response(
|
||||||
CliprdrServerFormatListResponse {
|
CliprdrServerFormatListResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@ -50,15 +42,13 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ClipbaordFile::ServerFormatDataRequest {
|
ClipbaordFile::ServerFormatDataRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_data_request(
|
union: Some(cliprdr::Union::format_data_request(
|
||||||
CliprdrServerFormatDataRequest {
|
CliprdrServerFormatDataRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@ -68,16 +58,14 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ClipbaordFile::ServerFormatDataResponse {
|
ClipbaordFile::ServerFormatDataResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
format_data,
|
format_data,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_data_response(
|
union: Some(cliprdr::Union::format_data_response(
|
||||||
CliprdrServerFormatDataResponse {
|
CliprdrServerFormatDataResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
format_data,
|
format_data,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@ -88,8 +76,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ClipbaordFile::FileContentsRequest {
|
ClipbaordFile::FileContentsRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
stream_id,
|
stream_id,
|
||||||
list_index,
|
list_index,
|
||||||
dw_flags,
|
dw_flags,
|
||||||
@ -102,8 +89,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::file_contents_request(
|
union: Some(cliprdr::Union::file_contents_request(
|
||||||
CliprdrFileContentsRequest {
|
CliprdrFileContentsRequest {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
stream_id,
|
stream_id,
|
||||||
list_index,
|
list_index,
|
||||||
dw_flags,
|
dw_flags,
|
||||||
@ -120,8 +106,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ClipbaordFile::FileContentsResponse {
|
ClipbaordFile::FileContentsResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
@ -129,8 +114,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::file_contents_response(
|
union: Some(cliprdr::Union::file_contents_response(
|
||||||
CliprdrFileContentsResponse {
|
CliprdrFileContentsResponse {
|
||||||
server_conn_id,
|
conn_id,
|
||||||
remote_conn_id,
|
|
||||||
msg_flags,
|
msg_flags,
|
||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
@ -152,37 +136,32 @@ pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
|||||||
format_list.push((v.id, v.format.clone()));
|
format_list.push((v.id, v.format.clone()));
|
||||||
}
|
}
|
||||||
Some(ClipbaordFile::ServerFormatList {
|
Some(ClipbaordFile::ServerFormatList {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
format_list,
|
format_list,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_list_response(data)) => {
|
Some(cliprdr::Union::format_list_response(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatListResponse {
|
Some(ClipbaordFile::ServerFormatListResponse {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_data_request(data)) => {
|
Some(cliprdr::Union::format_data_request(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatDataRequest {
|
Some(ClipbaordFile::ServerFormatDataRequest {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
requested_format_id: data.requested_format_id,
|
requested_format_id: data.requested_format_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_data_response(data)) => {
|
Some(cliprdr::Union::format_data_response(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatDataResponse {
|
Some(ClipbaordFile::ServerFormatDataResponse {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
format_data: data.format_data,
|
format_data: data.format_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::file_contents_request(data)) => {
|
Some(cliprdr::Union::file_contents_request(data)) => {
|
||||||
Some(ClipbaordFile::FileContentsRequest {
|
Some(ClipbaordFile::FileContentsRequest {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
stream_id: data.stream_id,
|
stream_id: data.stream_id,
|
||||||
list_index: data.list_index,
|
list_index: data.list_index,
|
||||||
dw_flags: data.dw_flags,
|
dw_flags: data.dw_flags,
|
||||||
@ -195,8 +174,7 @@ pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
|||||||
}
|
}
|
||||||
Some(cliprdr::Union::file_contents_response(data)) => {
|
Some(cliprdr::Union::file_contents_response(data)) => {
|
||||||
Some(ClipbaordFile::FileContentsResponse {
|
Some(ClipbaordFile::FileContentsResponse {
|
||||||
server_conn_id: data.server_conn_id,
|
conn_id: data.conn_id,
|
||||||
remote_conn_id: data.remote_conn_id,
|
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
stream_id: data.stream_id,
|
stream_id: data.stream_id,
|
||||||
requested_data: data.requested_data,
|
requested_data: data.requested_data,
|
||||||
|
15
src/ui/cm.rs
15
src/ui/cm.rs
@ -1,8 +1,7 @@
|
|||||||
use crate::ipc::{self, new_listener, Connection, Data};
|
use crate::ipc::{self, new_listener, Connection, Data};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use clipboard::{
|
use clipboard::{
|
||||||
create_cliprdr_context, empty_clipboard, get_rx_clip_client, server_clip_file,
|
create_cliprdr_context, empty_clipboard, get_rx_clip_client, server_clip_file, set_conn_enabled,
|
||||||
set_conn_enabled, ConnID,
|
|
||||||
};
|
};
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
allow_err,
|
allow_err,
|
||||||
@ -514,7 +513,7 @@ async fn start_clipboard_file(
|
|||||||
Some((conn_id, clip)) => {
|
Some((conn_id, clip)) => {
|
||||||
cmd_inner_send(
|
cmd_inner_send(
|
||||||
&cm,
|
&cm,
|
||||||
conn_id.server_conn_id as i32,
|
conn_id,
|
||||||
Data::ClipbaordFile(clip)
|
Data::ClipbaordFile(clip)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -523,11 +522,7 @@ async fn start_clipboard_file(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
server_msg = rx.recv() => match server_msg {
|
server_msg = rx.recv() => match server_msg {
|
||||||
Some(ClipboardFileData::Clip((server_conn_id, clip))) => {
|
Some(ClipboardFileData::Clip((conn_id, clip))) => {
|
||||||
let conn_id = ConnID {
|
|
||||||
server_conn_id: server_conn_id as u32,
|
|
||||||
remote_conn_id: 0,
|
|
||||||
};
|
|
||||||
if let Some(ctx) = cliprdr_context.as_mut() {
|
if let Some(ctx) = cliprdr_context.as_mut() {
|
||||||
server_clip_file(ctx, conn_id, clip);
|
server_clip_file(ctx, conn_id, clip);
|
||||||
}
|
}
|
||||||
@ -548,10 +543,10 @@ async fn start_clipboard_file(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
set_conn_enabled(id, 0, enabled);
|
set_conn_enabled(id, enabled);
|
||||||
if !enabled {
|
if !enabled {
|
||||||
if let Some(ctx) = cliprdr_context.as_mut() {
|
if let Some(ctx) = cliprdr_context.as_mut() {
|
||||||
empty_clipboard(ctx, id, 0);
|
empty_clipboard(ctx, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use crate::{
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use clipboard::{
|
use clipboard::{
|
||||||
cliprdr::CliprdrClientContext, create_cliprdr_context as create_clipboard_file_context,
|
cliprdr::CliprdrClientContext, create_cliprdr_context as create_clipboard_file_context,
|
||||||
get_rx_clip_client, server_clip_file, ConnID as ClipboardFileConnID,
|
get_rx_clip_client, server_clip_file,
|
||||||
};
|
};
|
||||||
use enigo::{self, Enigo, KeyboardControllable};
|
use enigo::{self, Enigo, KeyboardControllable};
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
@ -349,7 +349,8 @@ impl Handler {
|
|||||||
} else {
|
} else {
|
||||||
let mut chr = match evt.name {
|
let mut chr = match evt.name {
|
||||||
Some(ref s) => {
|
Some(ref s) => {
|
||||||
if s.len() <= 2 { // exclude chinese characters
|
if s.len() <= 2 {
|
||||||
|
// exclude chinese characters
|
||||||
s.chars().next().unwrap_or('\0')
|
s.chars().next().unwrap_or('\0')
|
||||||
} else {
|
} else {
|
||||||
'\0'
|
'\0'
|
||||||
@ -357,7 +358,8 @@ impl Handler {
|
|||||||
}
|
}
|
||||||
_ => '\0',
|
_ => '\0',
|
||||||
};
|
};
|
||||||
if chr == '·' { // special for Chinese
|
if chr == '·' {
|
||||||
|
// special for Chinese
|
||||||
chr = '`';
|
chr = '`';
|
||||||
}
|
}
|
||||||
if chr == '\0' {
|
if chr == '\0' {
|
||||||
@ -1251,8 +1253,6 @@ async fn io_loop(handler: Handler) {
|
|||||||
first_frame: false,
|
first_frame: false,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
clipboard_file_context: None,
|
clipboard_file_context: None,
|
||||||
#[cfg(windows)]
|
|
||||||
pid: std::process::id(),
|
|
||||||
};
|
};
|
||||||
remote.io_loop().await;
|
remote.io_loop().await;
|
||||||
}
|
}
|
||||||
@ -1294,8 +1294,6 @@ struct Remote {
|
|||||||
first_frame: bool,
|
first_frame: bool,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
clipboard_file_context: Option<Box<CliprdrClientContext>>,
|
clipboard_file_context: Option<Box<CliprdrClientContext>>,
|
||||||
#[cfg(windows)]
|
|
||||||
pid: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Remote {
|
impl Remote {
|
||||||
@ -1356,11 +1354,9 @@ impl Remote {
|
|||||||
_msg = rx_clip_client.recv() => {
|
_msg = rx_clip_client.recv() => {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
match _msg {
|
match _msg {
|
||||||
Some((conn_id, clip)) => {
|
Some((_, clip)) => {
|
||||||
if conn_id.remote_conn_id == 0 || conn_id.remote_conn_id == self.pid {
|
|
||||||
allow_err!(peer.send(&clip_2_msg(clip)).await);
|
allow_err!(peer.send(&clip_2_msg(clip)).await);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None => {
|
None => {
|
||||||
// unreachable!()
|
// unreachable!()
|
||||||
}
|
}
|
||||||
@ -1747,14 +1743,7 @@ impl Remote {
|
|||||||
if !self.handler.lc.read().unwrap().disable_clipboard {
|
if !self.handler.lc.read().unwrap().disable_clipboard {
|
||||||
if let Some(context) = &mut self.clipboard_file_context {
|
if let Some(context) = &mut self.clipboard_file_context {
|
||||||
if let Some(clip) = msg_2_clip(clip) {
|
if let Some(clip) = msg_2_clip(clip) {
|
||||||
server_clip_file(
|
server_clip_file(context, 0, clip);
|
||||||
context,
|
|
||||||
ClipboardFileConnID {
|
|
||||||
server_conn_id: 0,
|
|
||||||
remote_conn_id: self.pid,
|
|
||||||
},
|
|
||||||
clip,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user