mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
better control of clipboard file transfer
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -74,6 +74,7 @@ pub enum Data {
|
||||
clipboard: bool,
|
||||
audio: bool,
|
||||
file: bool,
|
||||
file_transfer_enabled: bool,
|
||||
},
|
||||
ChatMessage {
|
||||
text: String,
|
||||
@@ -105,6 +106,7 @@ pub enum Data {
|
||||
},
|
||||
SyncConfigToUserResp(bool),
|
||||
ClipbaordFile(ClipbaordFile),
|
||||
ClipboardFileEnabled(bool),
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
|
||||
@@ -246,6 +246,7 @@ impl Connection {
|
||||
} else if &name == "file" {
|
||||
conn.file = enabled;
|
||||
conn.send_permission(Permission::File, enabled).await;
|
||||
conn.send_to_cm(ipc::Data::ClipboardFileEnabled(conn.file_transfer_enabled()));
|
||||
}
|
||||
}
|
||||
ipc::Data::RawMessage(bytes) => {
|
||||
@@ -654,6 +655,7 @@ impl Connection {
|
||||
clipboard: self.clipboard,
|
||||
audio: self.audio,
|
||||
file: self.file,
|
||||
file_transfer_enabled: self.file_transfer_enabled(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1020,6 +1022,7 @@ impl Connection {
|
||||
if let Ok(q) = o.enable_file_transfer.enum_value() {
|
||||
if q != BoolOption::NotSet {
|
||||
self.enable_file_transfer = q == BoolOption::Yes;
|
||||
self.send_to_cm(ipc::Data::ClipboardFileEnabled(self.file_transfer_enabled()));
|
||||
}
|
||||
}
|
||||
if let Ok(q) = o.disable_clipboard.enum_value() {
|
||||
|
||||
12
src/ui/cm.rs
12
src/ui/cm.rs
@@ -1,6 +1,8 @@
|
||||
use crate::ipc::{self, new_listener, Connection, Data};
|
||||
#[cfg(windows)]
|
||||
use clipboard::{create_cliprdr_context, get_rx_clip_client, server_clip_file, ConnID};
|
||||
use clipboard::{
|
||||
create_cliprdr_context, get_rx_clip_client, server_clip_file, set_conn_enabled, ConnID,
|
||||
};
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::{Config, ICON},
|
||||
@@ -193,6 +195,9 @@ impl ConnectionManager {
|
||||
#[cfg(windows)]
|
||||
allow_err!(_tx_clip_file.send((id, _clip)));
|
||||
}
|
||||
Data::ClipboardFileEnabled(enabled) => {
|
||||
set_conn_enabled(id, 0, enabled);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -361,8 +366,9 @@ async fn start_ipc(cm: ConnectionManager) {
|
||||
}
|
||||
Ok(Some(data)) => {
|
||||
match data {
|
||||
Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file} => {
|
||||
Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled} => {
|
||||
conn_id = id;
|
||||
set_conn_enabled(id, 0, file_transfer_enabled);
|
||||
cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, tx.clone());
|
||||
}
|
||||
Data::Close => {
|
||||
@@ -532,7 +538,7 @@ async fn start_clipboard_file(
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn cmd_inner_send<'a>(cm: &'a ConnectionManager, id: i32, data: Data) {
|
||||
fn cmd_inner_send(cm: &ConnectionManager, id: i32, data: Data) {
|
||||
let lock = cm.read().unwrap();
|
||||
if id != 0 {
|
||||
if let Some(s) = lock.senders.get(&id) {
|
||||
|
||||
Reference in New Issue
Block a user