patch: only enable file copy and paste under features
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
parent
fd1dc15576
commit
dc02ce3f97
17
Cargo.toml
17
Cargo.toml
@ -32,6 +32,13 @@ linux_headless = ["pam" ]
|
|||||||
virtual_display_driver = ["virtual_display"]
|
virtual_display_driver = ["virtual_display"]
|
||||||
plugin_framework = []
|
plugin_framework = []
|
||||||
linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"]
|
linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"]
|
||||||
|
unix-file-copy-paste = [
|
||||||
|
"dep:x11-clipboard",
|
||||||
|
"dep:x11rb",
|
||||||
|
"dep:percent-encoding",
|
||||||
|
"dep:once_cell",
|
||||||
|
"clipboard/unix-file-copy-paste",
|
||||||
|
]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@ -84,7 +91,7 @@ mac_address = "1.1"
|
|||||||
sciter-rs = { git = "https://github.com/open-trade/rust-sciter", branch = "dyn" }
|
sciter-rs = { git = "https://github.com/open-trade/rust-sciter", branch = "dyn" }
|
||||||
sys-locale = "0.3"
|
sys-locale = "0.3"
|
||||||
enigo = { path = "libs/enigo", features = [ "with_serde" ] }
|
enigo = { path = "libs/enigo", features = [ "with_serde" ] }
|
||||||
clipboard = { path = "libs/clipboard" }
|
clipboard = { path = "libs/clipboard", default-features = false }
|
||||||
ctrlc = "3.2"
|
ctrlc = "3.2"
|
||||||
arboard = "3.2"
|
arboard = "3.2"
|
||||||
system_shutdown = "4.0"
|
system_shutdown = "4.0"
|
||||||
@ -132,10 +139,10 @@ dbus = "0.9"
|
|||||||
dbus-crossroads = "0.5"
|
dbus-crossroads = "0.5"
|
||||||
pam = { git="https://github.com/fufesou/pam", optional = true }
|
pam = { git="https://github.com/fufesou/pam", optional = true }
|
||||||
users = { version = "0.11" }
|
users = { version = "0.11" }
|
||||||
x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch"}
|
x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch", optional = true}
|
||||||
x11rb = {version = "0.12", features = ["all-extensions"]}
|
x11rb = {version = "0.12", features = ["all-extensions"], optional = true}
|
||||||
percent-encoding = "2.3"
|
percent-encoding = {version = "2.3", optional = true}
|
||||||
once_cell = "1.18"
|
once_cell = {version = "1.18", optional = true}
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.13"
|
android_logger = "0.13"
|
||||||
|
@ -9,6 +9,19 @@ build = "build.rs"
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["unix-file-copy-paste"]
|
||||||
|
unix-file-copy-paste = [
|
||||||
|
"dep:x11rb",
|
||||||
|
"dep:x11-clipboard",
|
||||||
|
"dep:rand",
|
||||||
|
"dep:fuser",
|
||||||
|
"dep:libc",
|
||||||
|
"dep:dashmap",
|
||||||
|
"dep:percent-encoding",
|
||||||
|
"dep:utf16string"
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
@ -18,12 +31,12 @@ hbb_common = { path = "../hbb_common" }
|
|||||||
parking_lot = {version = "0.12"}
|
parking_lot = {version = "0.12"}
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||||
once_cell = "1.18"
|
once_cell = {version = "1.18", optional = true}
|
||||||
x11rb = {version = "0.12", features = ["all-extensions"]}
|
x11rb = {version = "0.12", features = ["all-extensions"], optional = true}
|
||||||
rand = {version = "0.8"}
|
rand = {version = "0.8", optional = true}
|
||||||
fuser = {version = "0.13"}
|
fuser = {version = "0.13", optional = true}
|
||||||
libc = {version = "0.2"}
|
libc = {version = "0.2", optional = true}
|
||||||
dashmap = "5.5"
|
dashmap = {version ="5.5", optional = true}
|
||||||
percent-encoding = "2.3"
|
percent-encoding = {version ="2.3", optional = true}
|
||||||
utf16string = "0.2"
|
utf16string = {version = "0.2", optional = true}
|
||||||
x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch"}
|
x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch", optional = true}
|
||||||
|
@ -108,6 +108,7 @@ pub enum ClipboardFile {
|
|||||||
struct MsgChannel {
|
struct MsgChannel {
|
||||||
peer_id: String,
|
peer_id: String,
|
||||||
conn_id: i32,
|
conn_id: i32,
|
||||||
|
#[allow(dead_code)]
|
||||||
sender: UnboundedSender<ClipboardFile>,
|
sender: UnboundedSender<ClipboardFile>,
|
||||||
receiver: Arc<TokioMutex<UnboundedReceiver<ClipboardFile>>>,
|
receiver: Arc<TokioMutex<UnboundedReceiver<ClipboardFile>>>,
|
||||||
}
|
}
|
||||||
@ -193,6 +194,7 @@ pub fn get_rx_cliprdr_server(conn_id: i32) -> Arc<TokioMutex<UnboundedReceiver<C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "windows", feature = "unix-file-copy-paste",))]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn send_data(conn_id: i32, data: ClipboardFile) {
|
fn send_data(conn_id: i32, data: ClipboardFile) {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
@ -204,7 +206,7 @@ fn send_data(conn_id: i32, data: ClipboardFile) {
|
|||||||
send_data_to_channel(conn_id, data);
|
send_data_to_channel(conn_id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(any(target_os = "windows", feature = "unix-file-copy-paste",))]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn send_data_to_channel(conn_id: i32, data: ClipboardFile) {
|
fn send_data_to_channel(conn_id: i32, data: ClipboardFile) {
|
||||||
// no need to handle result here
|
// no need to handle result here
|
||||||
@ -218,6 +220,7 @@ fn send_data_to_channel(conn_id: i32, data: ClipboardFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unix-file-copy-paste")]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn send_data_to_all(data: ClipboardFile) {
|
fn send_data_to_all(data: ClipboardFile) {
|
||||||
// no need to handle result here
|
// no need to handle result here
|
||||||
|
@ -14,26 +14,30 @@ pub fn create_cliprdr_context(
|
|||||||
Ok(boxed)
|
Ok(boxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unix-file-copy-paste")]
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
/// use FUSE for file pasting on these platforms
|
/// use FUSE for file pasting on these platforms
|
||||||
pub mod fuse;
|
pub mod fuse;
|
||||||
|
#[cfg(feature = "unix-file-copy-paste")]
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
pub mod unix;
|
pub mod unix;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn create_cliprdr_context(
|
pub fn create_cliprdr_context(
|
||||||
enable_files: bool,
|
_enable_files: bool,
|
||||||
_enable_others: bool,
|
_enable_others: bool,
|
||||||
response_wait_timeout_secs: u32,
|
_response_wait_timeout_secs: u32,
|
||||||
) -> crate::ResultType<Box<dyn crate::CliprdrServiceContext>> {
|
) -> crate::ResultType<Box<dyn crate::CliprdrServiceContext>> {
|
||||||
|
#[cfg(feature = "unix-file-copy-paste")]
|
||||||
|
{
|
||||||
use std::{fs::Permissions, os::unix::prelude::PermissionsExt};
|
use std::{fs::Permissions, os::unix::prelude::PermissionsExt};
|
||||||
|
|
||||||
use hbb_common::{config::APP_NAME, log};
|
use hbb_common::{config::APP_NAME, log};
|
||||||
|
|
||||||
if !enable_files {
|
if !_enable_files {
|
||||||
return Ok(Box::new(DummyCliprdrContext {}) as Box<_>);
|
return Ok(Box::new(DummyCliprdrContext {}) as Box<_>);
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeout = std::time::Duration::from_secs(response_wait_timeout_secs as u64);
|
let timeout = std::time::Duration::from_secs(_response_wait_timeout_secs as u64);
|
||||||
|
|
||||||
let app_name = APP_NAME.read().unwrap().clone();
|
let app_name = APP_NAME.read().unwrap().clone();
|
||||||
|
|
||||||
@ -53,6 +57,9 @@ pub fn create_cliprdr_context(
|
|||||||
linux_ctx.run().expect("failed to start cliprdr FUSE");
|
linux_ctx.run().expect("failed to start cliprdr FUSE");
|
||||||
|
|
||||||
Ok(Box::new(linux_ctx) as Box<_>)
|
Ok(Box::new(linux_ctx) as Box<_>)
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "unix-file-copy-paste"))]
|
||||||
|
return Ok(Box::new(DummyCliprdrContext {}) as Box<_>);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DummyCliprdrContext {}
|
struct DummyCliprdrContext {}
|
||||||
@ -73,6 +80,7 @@ impl CliprdrServiceContext for DummyCliprdrContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unix-file-copy-paste")]
|
||||||
// begin of epoch used by microsoft
|
// begin of epoch used by microsoft
|
||||||
// 1601-01-01 00:00:00 + LDAP_EPOCH_DELTA*(100 ns) = 1970-01-01 00:00:00
|
// 1601-01-01 00:00:00 + LDAP_EPOCH_DELTA*(100 ns) = 1970-01-01 00:00:00
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user