fix cliprdr for windows after refactory
This commit is contained in:
parent
933969d1fe
commit
835db29c3f
@ -873,6 +873,8 @@ impl LoginConfigHandler {
|
|||||||
self.config.lock_after_session_end
|
self.config.lock_after_session_end
|
||||||
} else if name == "privacy-mode" {
|
} else if name == "privacy-mode" {
|
||||||
self.config.privacy_mode
|
self.config.privacy_mode
|
||||||
|
} else if name == "enable-file-transfer" {
|
||||||
|
self.config.enable_file_transfer
|
||||||
} else if name == "disable-audio" {
|
} else if name == "disable-audio" {
|
||||||
self.config.disable_audio
|
self.config.disable_audio
|
||||||
} else if name == "disable-clipboard" {
|
} else if name == "disable-clipboard" {
|
||||||
@ -1152,6 +1154,7 @@ pub enum Data {
|
|||||||
CancelJob(i32),
|
CancelJob(i32),
|
||||||
RemovePortForward(i32),
|
RemovePortForward(i32),
|
||||||
AddPortForward((i32, String, i32)),
|
AddPortForward((i32, String, i32)),
|
||||||
|
ToggleClipboardFile,
|
||||||
NewRDP,
|
NewRDP,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -143,6 +143,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Allow using keyboard and mouse", "允许使用键盘鼠标"),
|
("Allow using keyboard and mouse", "允许使用键盘鼠标"),
|
||||||
("Allow using clipboard", "允许使用剪贴板"),
|
("Allow using clipboard", "允许使用剪贴板"),
|
||||||
("Allow hearing sound", "允许听到声音"),
|
("Allow hearing sound", "允许听到声音"),
|
||||||
|
("Allow file transfer", "允许文件传输"),
|
||||||
|
("File transfer", "文件传输"),
|
||||||
("Connected", "已经连接"),
|
("Connected", "已经连接"),
|
||||||
("Direct and encrypted connection", "加密直连"),
|
("Direct and encrypted connection", "加密直连"),
|
||||||
("Relayed and encrypted connection", "加密中继连接"),
|
("Relayed and encrypted connection", "加密中继连接"),
|
||||||
|
|||||||
@ -851,7 +851,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
Some(message::Union::cliprdr(clip)) => {
|
Some(message::Union::cliprdr(clip)) => {
|
||||||
clipboard_file_service::handle_serve_clipboard_file_msg(self.inner.id, clip)
|
clipboard_file_service::handle_serve_cliprdr_msg(self.inner.id, clip)
|
||||||
}
|
}
|
||||||
Some(message::Union::file_action(fa)) => {
|
Some(message::Union::file_action(fa)) => {
|
||||||
if self.file_transfer.is_some() {
|
if self.file_transfer.is_some() {
|
||||||
@ -1017,6 +1017,7 @@ impl Connection {
|
|||||||
if let Ok(q) = o.enable_file_transfer.enum_value() {
|
if let Ok(q) = o.enable_file_transfer.enum_value() {
|
||||||
if q != BoolOption::NotSet {
|
if q != BoolOption::NotSet {
|
||||||
self.enable_file_transfer = q == BoolOption::Yes;
|
self.enable_file_transfer = q == BoolOption::Yes;
|
||||||
|
if let Some(s) = self.server.upgrade() {
|
||||||
s.write().unwrap().subscribe(
|
s.write().unwrap().subscribe(
|
||||||
super::clipboard_file_service::NAME,
|
super::clipboard_file_service::NAME,
|
||||||
self.inner.clone(),
|
self.inner.clone(),
|
||||||
@ -1024,6 +1025,7 @@ impl Connection {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if let Ok(q) = o.disable_clipboard.enum_value() {
|
if let Ok(q) = o.disable_clipboard.enum_value() {
|
||||||
if q != BoolOption::NotSet {
|
if q != BoolOption::NotSet {
|
||||||
self.disable_clipboard = q == BoolOption::Yes;
|
self.disable_clipboard = q == BoolOption::Yes;
|
||||||
|
|||||||
@ -406,7 +406,7 @@ function adjustHeader() {
|
|||||||
|
|
||||||
view.on("size", adjustHeader);
|
view.on("size", adjustHeader);
|
||||||
|
|
||||||
handler.addConnection(0, false, 0, "", "test1", true, false, false, true, true);
|
// handler.addConnection(0, false, 0, "", "test1", true, false, false, true, true);
|
||||||
// handler.addConnection(1, false, 0, "", "test2--------", true, false, false, false, false);
|
// handler.addConnection(1, false, 0, "", "test2--------", true, false, false, false, false);
|
||||||
// handler.addConnection(2, false, 0, "", "test3", true, false, false, false, false);
|
// handler.addConnection(2, false, 0, "", "test3", true, false, false, false, false);
|
||||||
// handler.newMessage(0, 'h');
|
// handler.newMessage(0, 'h');
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use crate::common::{
|
|||||||
};
|
};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use clipboard::{
|
use clipboard::{
|
||||||
cliprdrfile::CliprdrClientContext, create_cliprdr_context as create_clipboard_file_context,
|
cliprdr::CliprdrClientContext, create_cliprdr_context as create_clipboard_file_context,
|
||||||
get_rx_client_msg as get_clipboard_file_rx_client_msg, server_msg as clipboard_file_msg,
|
get_rx_client_msg as get_clipboard_file_rx_client_msg, server_msg as clipboard_file_msg,
|
||||||
ConnID as ClipboardFileConnID,
|
ConnID as ClipboardFileConnID,
|
||||||
};
|
};
|
||||||
@ -57,6 +57,7 @@ fn get_key_state(key: enigo::Key) -> bool {
|
|||||||
static mut IS_IN: bool = false;
|
static mut IS_IN: bool = false;
|
||||||
static mut KEYBOARD_HOOKED: bool = false;
|
static mut KEYBOARD_HOOKED: bool = false;
|
||||||
static mut SERVER_KEYBOARD_ENABLED: bool = true;
|
static mut SERVER_KEYBOARD_ENABLED: bool = true;
|
||||||
|
static mut SERVER_FILE_TRANSFER_ENABLED: bool = true;
|
||||||
static mut SERVER_CLIPBOARD_ENABLED: bool = true;
|
static mut SERVER_CLIPBOARD_ENABLED: bool = true;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -394,7 +395,10 @@ impl Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_option(&mut self, name: String) {
|
fn toggle_option(&mut self, name: String) {
|
||||||
let msg = self.lc.write().unwrap().toggle_option(name);
|
let msg = self.lc.write().unwrap().toggle_option(name.clone());
|
||||||
|
if name == "enable-file-transfer" {
|
||||||
|
self.send(Data::ToggleClipboardFile);
|
||||||
|
}
|
||||||
if let Some(msg) = msg {
|
if let Some(msg) = msg {
|
||||||
self.send(Data::Message(msg));
|
self.send(Data::Message(msg));
|
||||||
}
|
}
|
||||||
@ -1166,15 +1170,6 @@ async fn io_loop(handler: Handler) {
|
|||||||
.map(|v| v.render_frame(data).ok());
|
.map(|v| v.render_frame(data).ok());
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
let clipboard_file_context = match create_clipboard_file_context(true, false) {
|
|
||||||
Ok(context) => Some(context),
|
|
||||||
Err(err) => {
|
|
||||||
handler.msgbox("error", "Create clipboard error", &err.to_string());
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut remote = Remote {
|
let mut remote = Remote {
|
||||||
handler,
|
handler,
|
||||||
video_sender,
|
video_sender,
|
||||||
@ -1189,10 +1184,11 @@ async fn io_loop(handler: Handler) {
|
|||||||
last_update_jobs_status: (Instant::now(), Default::default()),
|
last_update_jobs_status: (Instant::now(), Default::default()),
|
||||||
first_frame: false,
|
first_frame: false,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
clipboard_file_context,
|
clipboard_file_context: None,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pid: std::process::id(),
|
pid: std::process::id(),
|
||||||
};
|
};
|
||||||
|
remote.check_clipboard_file_context();
|
||||||
remote.io_loop().await;
|
remote.io_loop().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1251,6 +1247,7 @@ impl Remote {
|
|||||||
unsafe {
|
unsafe {
|
||||||
SERVER_KEYBOARD_ENABLED = true;
|
SERVER_KEYBOARD_ENABLED = true;
|
||||||
SERVER_CLIPBOARD_ENABLED = true;
|
SERVER_CLIPBOARD_ENABLED = true;
|
||||||
|
SERVER_FILE_TRANSFER_ENABLED = true;
|
||||||
}
|
}
|
||||||
self.handler
|
self.handler
|
||||||
.call("setConnectionType", &make_args!(peer.is_secured(), direct));
|
.call("setConnectionType", &make_args!(peer.is_secured(), direct));
|
||||||
@ -1334,6 +1331,7 @@ impl Remote {
|
|||||||
unsafe {
|
unsafe {
|
||||||
SERVER_KEYBOARD_ENABLED = false;
|
SERVER_KEYBOARD_ENABLED = false;
|
||||||
SERVER_CLIPBOARD_ENABLED = false;
|
SERVER_CLIPBOARD_ENABLED = false;
|
||||||
|
SERVER_FILE_TRANSFER_ENABLED = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1414,6 +1412,9 @@ impl Remote {
|
|||||||
.handle_login_from_ui(password, remember, peer)
|
.handle_login_from_ui(password, remember, peer)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
Data::ToggleClipboardFile => {
|
||||||
|
self.check_clipboard_file_context();
|
||||||
|
}
|
||||||
Data::Message(msg) => {
|
Data::Message(msg) => {
|
||||||
allow_err!(peer.send(&msg).await);
|
allow_err!(peer.send(&msg).await);
|
||||||
}
|
}
|
||||||
@ -1679,7 +1680,7 @@ impl Remote {
|
|||||||
Some(message::Union::cliprdr(clip)) => {
|
Some(message::Union::cliprdr(clip)) => {
|
||||||
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 {
|
||||||
let res = clipboard_file_msg(
|
clipboard_file_msg(
|
||||||
context,
|
context,
|
||||||
ClipboardFileConnID {
|
ClipboardFileConnID {
|
||||||
server_conn_id: 0,
|
server_conn_id: 0,
|
||||||
@ -1753,6 +1754,10 @@ impl Remote {
|
|||||||
.call("setPermission", &make_args!("audio", p.enabled));
|
.call("setPermission", &make_args!("audio", p.enabled));
|
||||||
}
|
}
|
||||||
Permission::File => {
|
Permission::File => {
|
||||||
|
unsafe {
|
||||||
|
SERVER_FILE_TRANSFER_ENABLED = p.enabled;
|
||||||
|
}
|
||||||
|
self.check_clipboard_file_context();
|
||||||
self.handler
|
self.handler
|
||||||
.call("setPermission", &make_args!("file", p.enabled));
|
.call("setPermission", &make_args!("file", p.enabled));
|
||||||
}
|
}
|
||||||
@ -1796,6 +1801,34 @@ impl Remote {
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_clipboard_file_context(&mut self) {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
let enabled = unsafe { SERVER_FILE_TRANSFER_ENABLED }
|
||||||
|
&& self.handler.lc.read().unwrap().enable_file_transfer;
|
||||||
|
if enabled == self.clipboard_file_context.is_none() {
|
||||||
|
self.clipboard_file_context = if enabled {
|
||||||
|
match create_clipboard_file_context(true, false) {
|
||||||
|
Ok(context) => {
|
||||||
|
log::info!("clipboard context for file transfer created.");
|
||||||
|
Some(context)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!(
|
||||||
|
"Create clipboard context for file transfer: {}",
|
||||||
|
err.to_string()
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::info!("clipboard context for file transfer destroyed.");
|
||||||
|
None
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_fd(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> Value {
|
fn make_fd(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> Value {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user