patch: forbid enable cliprdr without feature
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
parent
dc02ce3f97
commit
79f6b5c181
@ -19,7 +19,8 @@ unix-file-copy-paste = [
|
|||||||
"dep:libc",
|
"dep:libc",
|
||||||
"dep:dashmap",
|
"dep:dashmap",
|
||||||
"dep:percent-encoding",
|
"dep:percent-encoding",
|
||||||
"dep:utf16string"
|
"dep:utf16string",
|
||||||
|
"dep:once_cell"
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -1704,7 +1704,10 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_clipboard_file_context(&self) {
|
fn check_clipboard_file_context(&self) {
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
#[cfg(any(
|
||||||
|
target_os = "windows",
|
||||||
|
all(feature = "unix-file-copy-paste", target_os = "linux")
|
||||||
|
))]
|
||||||
{
|
{
|
||||||
let enabled = *self.handler.server_file_transfer_enabled.read().unwrap()
|
let enabled = *self.handler.server_file_transfer_enabled.read().unwrap()
|
||||||
&& self.handler.lc.read().unwrap().enable_file_transfer.v;
|
&& self.handler.lc.read().unwrap().enable_file_transfer.v;
|
||||||
|
@ -14,22 +14,22 @@ pub enum GrabState {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
all(target_os = "linux", not(feature = "wayland"))
|
all(target_os = "linux", feature = "unix-file-copy-paste")
|
||||||
)))]
|
)))]
|
||||||
pub use arboard::Clipboard as ClipboardContext;
|
pub use arboard::Clipboard as ClipboardContext;
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(feature = "wayland")))]
|
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
|
||||||
static X11_CLIPBOARD: once_cell::sync::OnceCell<x11_clipboard::Clipboard> =
|
static X11_CLIPBOARD: once_cell::sync::OnceCell<x11_clipboard::Clipboard> =
|
||||||
once_cell::sync::OnceCell::new();
|
once_cell::sync::OnceCell::new();
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(feature = "wayland")))]
|
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
|
||||||
fn get_clipboard() -> Result<&'static x11_clipboard::Clipboard, String> {
|
fn get_clipboard() -> Result<&'static x11_clipboard::Clipboard, String> {
|
||||||
X11_CLIPBOARD
|
X11_CLIPBOARD
|
||||||
.get_or_try_init(|| x11_clipboard::Clipboard::new())
|
.get_or_try_init(|| x11_clipboard::Clipboard::new())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(feature = "wayland")))]
|
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
|
||||||
pub struct ClipboardContext {
|
pub struct ClipboardContext {
|
||||||
string_setter: x11rb::protocol::xproto::Atom,
|
string_setter: x11rb::protocol::xproto::Atom,
|
||||||
string_getter: x11rb::protocol::xproto::Atom,
|
string_getter: x11rb::protocol::xproto::Atom,
|
||||||
@ -39,7 +39,7 @@ pub struct ClipboardContext {
|
|||||||
prop: x11rb::protocol::xproto::Atom,
|
prop: x11rb::protocol::xproto::Atom,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(feature = "wayland")))]
|
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
|
||||||
fn parse_plain_uri_list(v: Vec<u8>) -> Result<String, String> {
|
fn parse_plain_uri_list(v: Vec<u8>) -> Result<String, String> {
|
||||||
let text = String::from_utf8(v).map_err(|_| "ConversionFailure".to_owned())?;
|
let text = String::from_utf8(v).map_err(|_| "ConversionFailure".to_owned())?;
|
||||||
let mut list = String::new();
|
let mut list = String::new();
|
||||||
@ -56,7 +56,7 @@ fn parse_plain_uri_list(v: Vec<u8>) -> Result<String, String> {
|
|||||||
Ok(list)
|
Ok(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(feature = "wayland")))]
|
#[cfg(all(target_os = "linux", feature = "unix-file-copy-paste"))]
|
||||||
impl ClipboardContext {
|
impl ClipboardContext {
|
||||||
pub fn new() -> Result<Self, String> {
|
pub fn new() -> Result<Self, String> {
|
||||||
let clipboard = get_clipboard()?;
|
let clipboard = get_clipboard()?;
|
||||||
|
@ -575,12 +575,10 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log::debug!(
|
#[cfg(any(
|
||||||
"start_ipc enable context_send: {}",
|
target_os = "windows",
|
||||||
Config::get_option("enable-file-transfer").is_empty()
|
all(target_os = "linux", feature = "unix-file-copy-paste"),
|
||||||
);
|
))]
|
||||||
|
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
|
||||||
ContextSend::enable(Config::get_option("enable-file-transfer").is_empty());
|
ContextSend::enable(Config::get_option("enable-file-transfer").is_empty());
|
||||||
|
|
||||||
match ipc::new_listener("_cm").await {
|
match ipc::new_listener("_cm").await {
|
||||||
|
@ -1030,7 +1030,9 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
|||||||
*OPTIONS.lock().unwrap() = v;
|
*OPTIONS.lock().unwrap() = v;
|
||||||
*OPTION_SYNCED.lock().unwrap() = true;
|
*OPTION_SYNCED.lock().unwrap() = true;
|
||||||
|
|
||||||
#[cfg(any(target_os="windows", target_os="linux"))]
|
#[cfg(any(target_os="windows",
|
||||||
|
all(target_os="linux", feature = "unix-file-copy-paste")
|
||||||
|
))]
|
||||||
{
|
{
|
||||||
let b = OPTIONS.lock().unwrap().get("enable-file-transfer").map(|x| x.to_string()).unwrap_or_default();
|
let b = OPTIONS.lock().unwrap().get("enable-file-transfer").map(|x| x.to_string()).unwrap_or_default();
|
||||||
if b != enable_file_transfer {
|
if b != enable_file_transfer {
|
||||||
|
@ -1420,7 +1420,10 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn io_loop<T: InvokeUiSession>(handler: Session<T>, round: u32) {
|
pub async fn io_loop<T: InvokeUiSession>(handler: Session<T>, round: u32) {
|
||||||
// It is ok to call this function multiple times.
|
// It is ok to call this function multiple times.
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
#[cfg(any(
|
||||||
|
target_os = "windows",
|
||||||
|
all(target_os = "linux", feature = "unix-file-copy-paste")
|
||||||
|
))]
|
||||||
if !handler.is_file_transfer() && !handler.is_port_forward() {
|
if !handler.is_file_transfer() && !handler.is_port_forward() {
|
||||||
clipboard::ContextSend::enable(true);
|
clipboard::ContextSend::enable(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user