win_fix_multi_tab: refactor clipboard on windows, init debug done
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
007cdb1020
commit
c5c77808a5
@ -239,6 +239,8 @@ pub type CLIPRDR_FORMAT = _CLIPRDR_FORMAT;
|
|||||||
pub struct _CLIPRDR_FORMAT_LIST {
|
pub struct _CLIPRDR_FORMAT_LIST {
|
||||||
pub connID: UINT32,
|
pub connID: UINT32,
|
||||||
pub msgType: UINT16,
|
pub msgType: UINT16,
|
||||||
|
pub msgFlags: UINT16,
|
||||||
|
pub dataLen: UINT32,
|
||||||
pub numFormats: UINT32,
|
pub numFormats: UINT32,
|
||||||
pub formats: *mut CLIPRDR_FORMAT,
|
pub formats: *mut CLIPRDR_FORMAT,
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,17 @@ struct MsgChannel {
|
|||||||
receiver: Arc<TokioMutex<UnboundedReceiver<ClipbaordFile>>>,
|
receiver: Arc<TokioMutex<UnboundedReceiver<ClipbaordFile>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
pub enum ProcessSide {
|
||||||
|
UnknownSide,
|
||||||
|
ClientSide,
|
||||||
|
ServerSide,
|
||||||
|
}
|
||||||
|
|
||||||
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 CLIP_CONN_ENABLED: Mutex<ConnEnabled> = Mutex::new(ConnEnabled::default());
|
static ref CLIP_CONN_ENABLED: Mutex<ConnEnabled> = Mutex::new(ConnEnabled::default());
|
||||||
|
static ref PROCESS_SIDE: RwLock<ProcessSide> = RwLock::new(ProcessSide::UnknownSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -249,6 +257,8 @@ pub fn server_format_list(
|
|||||||
let format_list = CLIPRDR_FORMAT_LIST {
|
let format_list = CLIPRDR_FORMAT_LIST {
|
||||||
connID: conn_id as UINT32,
|
connID: conn_id as UINT32,
|
||||||
msgType: 0 as UINT16,
|
msgType: 0 as UINT16,
|
||||||
|
msgFlags: 0 as UINT16,
|
||||||
|
dataLen: 0 as UINT32,
|
||||||
numFormats: num_formats,
|
numFormats: num_formats,
|
||||||
formats: formats.as_mut_ptr(),
|
formats: formats.as_mut_ptr(),
|
||||||
};
|
};
|
||||||
@ -390,7 +400,10 @@ pub fn server_file_contents_response(
|
|||||||
pub fn create_cliprdr_context(
|
pub fn create_cliprdr_context(
|
||||||
enable_files: bool,
|
enable_files: bool,
|
||||||
enable_others: bool,
|
enable_others: bool,
|
||||||
|
process_side: ProcessSide,
|
||||||
) -> ResultType<Box<CliprdrClientContext>> {
|
) -> ResultType<Box<CliprdrClientContext>> {
|
||||||
|
*PROCESS_SIDE.write().unwrap() = process_side;
|
||||||
|
|
||||||
Ok(CliprdrClientContext::create(
|
Ok(CliprdrClientContext::create(
|
||||||
enable_files,
|
enable_files,
|
||||||
enable_others,
|
enable_others,
|
||||||
@ -405,8 +418,11 @@ pub fn create_cliprdr_context(
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn check_enabled(conn_id: UINT32) -> BOOL {
|
extern "C" fn check_enabled(conn_id: UINT32) -> BOOL {
|
||||||
let lock = CLIP_CONN_ENABLED.lock().unwrap();
|
if *PROCESS_SIDE.read().unwrap() == ProcessSide::ClientSide {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lock = CLIP_CONN_ENABLED.lock().unwrap();
|
||||||
let mut connd_enabled = false;
|
let mut connd_enabled = false;
|
||||||
if conn_id != 0 {
|
if conn_id != 0 {
|
||||||
if let Some(true) = lock.conn_enabled.get(&(conn_id as i32)) {
|
if let Some(true) = lock.conn_enabled.get(&(conn_id as i32)) {
|
||||||
|
@ -135,14 +135,14 @@ typedef struct _FORMAT_IDS FORMAT_IDS;
|
|||||||
|
|
||||||
#define TAG "windows"
|
#define TAG "windows"
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_CLIPRDR
|
// #ifdef WITH_DEBUG_CLIPRDR
|
||||||
#define DEBUG_CLIPRDR(...) printf(TAG, __VA_ARGS__)
|
#define DEBUG_CLIPRDR(fmt, ...) fprintf(stderr, "DEBUG %s[%d] %s() " fmt "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__);fflush(stderr)
|
||||||
#else
|
// #else
|
||||||
#define DEBUG_CLIPRDR(...) \
|
// #define DEBUG_CLIPRDR(fmt, ...) \
|
||||||
do \
|
// do \
|
||||||
{ \
|
// { \
|
||||||
} while (0)
|
// } while (0)
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
typedef BOOL(WINAPI *fnAddClipboardFormatListener)(HWND hwnd);
|
typedef BOOL(WINAPI *fnAddClipboardFormatListener)(HWND hwnd);
|
||||||
typedef BOOL(WINAPI *fnRemoveClipboardFormatListener)(HWND hwnd);
|
typedef BOOL(WINAPI *fnRemoveClipboardFormatListener)(HWND hwnd);
|
||||||
@ -974,7 +974,7 @@ static BOOL wf_create_file_obj(UINT32 *connID, wfClipboard *clipboard, IDataObje
|
|||||||
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(*connID, *(connID + 1), fmtetc, stgmeds, 2, clipboard);
|
*ppDataObject = (IDataObject *)CliprdrDataObject_New(*connID, fmtetc, stgmeds, 2, clipboard);
|
||||||
return (*ppDataObject) ? TRUE : FALSE;
|
return (*ppDataObject) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ fn check_clipboard_file_context(enable_file_transfer: bool) {
|
|||||||
let mut lock = CLIPBOARD_FILE_CONTEXT.lock().unwrap();
|
let mut lock = CLIPBOARD_FILE_CONTEXT.lock().unwrap();
|
||||||
if enabled {
|
if enabled {
|
||||||
if *lock == 0 {
|
if *lock == 0 {
|
||||||
match clipboard::create_cliprdr_context(true, false) {
|
match clipboard::create_cliprdr_context(true, false, clipboard::ProcessSide::ClientSide)
|
||||||
|
{
|
||||||
Ok(context) => {
|
Ok(context) => {
|
||||||
log::info!("clipboard context for file transfer created.");
|
log::info!("clipboard context for file transfer created.");
|
||||||
*lock = Box::into_raw(context) as _;
|
*lock = Box::into_raw(context) as _;
|
||||||
|
@ -730,7 +730,7 @@ pub async fn start_clipboard_file(mut rx: mpsc::UnboundedReceiver<ClipboardFileD
|
|||||||
}
|
}
|
||||||
Some(ClipboardFileData::Enable((id, enabled))) => {
|
Some(ClipboardFileData::Enable((id, enabled))) => {
|
||||||
if enabled && cliprdr_context.is_none() {
|
if enabled && cliprdr_context.is_none() {
|
||||||
cliprdr_context = Some(match clipboard::create_cliprdr_context(true, false) {
|
cliprdr_context = Some(match clipboard::create_cliprdr_context(true, false, clipboard::ProcessSide::ServerSide) {
|
||||||
Ok(context) => {
|
Ok(context) => {
|
||||||
log::info!("clipboard context for file transfer created.");
|
log::info!("clipboard context for file transfer created.");
|
||||||
context
|
context
|
||||||
|
Loading…
x
Reference in New Issue
Block a user