diff --git a/Cargo.lock b/Cargo.lock index e5a80c42..9b753c66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,27 @@ dependencies = [ "memchr", ] +[[package]] +name = "arboard" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" +dependencies = [ + "clipboard-win", + "core-graphics", + "image", + "log", + "objc", + "objc-foundation", + "objc_id", + "once_cell", + "parking_lot 0.12.1", + "thiserror", + "winapi", + "wl-clipboard-rs", + "x11rb", +] + [[package]] name = "arrayvec" version = "0.7.4" @@ -297,7 +318,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object", "rustc-demangle", ] @@ -375,6 +396,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + [[package]] name = "byteorder" version = "1.4.3" @@ -491,20 +518,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cli-clipboard" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04087c1d4a2aa259784a563932aee09cbb0869d490775e051096174b070f3e3d" -dependencies = [ - "clipboard-win", - "objc", - "objc-foundation", - "objc_id", - "wl-clipboard-rs", - "x11-clipboard", -] - [[package]] name = "clipboard-win" version = "4.5.0" @@ -543,6 +556,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "concurrent-queue" version = "2.2.0" @@ -565,6 +584,46 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" +dependencies = [ + "bitflags", + "core-foundation", + "libc", +] + [[package]] name = "cpufeatures" version = "0.2.8" @@ -589,6 +648,15 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-utils" version = "0.8.16" @@ -824,6 +892,15 @@ dependencies = [ "instant", ] +[[package]] +name = "fdeflate" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +dependencies = [ + "simd-adler32", +] + [[package]] name = "filetime" version = "0.2.21" @@ -842,6 +919,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide 0.7.1", +] + [[package]] name = "float-cmp" version = "0.9.0" @@ -857,6 +944,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.0" @@ -1166,6 +1268,21 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "image" +version = "0.24.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "num-rational", + "num-traits", + "png", + "tiff", +] + [[package]] name = "indenter" version = "0.3.3" @@ -1254,6 +1371,12 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" + [[package]] name = "js-sys" version = "0.3.64" @@ -1402,6 +1525,16 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + [[package]] name = "mio" version = "0.8.8" @@ -1518,6 +1651,27 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1729,6 +1883,19 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "png" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +dependencies = [ + "bitflags", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.7.1", +] + [[package]] name = "polling" version = "2.8.0" @@ -2200,6 +2367,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" + [[package]] name = "slab" version = "0.4.8" @@ -2402,6 +2575,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiff" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "time" version = "0.3.22" @@ -2820,6 +3004,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + [[package]] name = "winapi" version = "0.3.9" @@ -3014,10 +3204,10 @@ dependencies = [ name = "wormhole-rs" version = "0.6.0" dependencies = [ + "arboard", "async-std", "clap", "clap_complete", - "cli-clipboard", "color-eyre", "console", "ctrlc", @@ -3055,15 +3245,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "x11-clipboard" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464" -dependencies = [ - "x11rb", -] - [[package]] name = "x11rb" version = "0.10.1" @@ -3108,9 +3289,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52839dc911083a8ef63efa4d039d1f58b5e409f923e44c80828f206f66e5541c" +checksum = "5a56c84a8ccd4258aed21c92f70c0f6dea75356b6892ae27c24139da456f9336" [[package]] name = "xsalsa20poly1305" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 92f4bc80..1cedecae 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -24,5 +24,5 @@ dialoguer = "0.10.0" color-eyre = "0.6.0" number_prefix = "0.4.0" ctrlc = "3.2.1" -cli-clipboard = "0.4.0" qr2term = "0.3.0" +arboard = {version = "3.2.0", features = ["wayland-data-control"]} # Wayland by default, fallback to X11. diff --git a/cli/src/main.rs b/cli/src/main.rs index 154e0d1d..ffef5a36 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -3,9 +3,9 @@ mod util; use std::time::{Duration, Instant}; +use arboard::Clipboard; use async_std::sync::Arc; use clap::{Args, CommandFactory, Parser, Subcommand}; -use cli_clipboard::{ClipboardContext, ClipboardProvider}; use color_eyre::{eyre, eyre::Context}; use console::{style, Term}; use futures::{future::Either, Future, FutureExt}; @@ -294,7 +294,7 @@ async fn main() -> eyre::Result<()> { .try_init()?; } - let mut clipboard = ClipboardContext::new() + let mut clipboard = Clipboard::new() .map_err(|err| { log::warn!("Failed to initialize clipboard support: {}", err); }) @@ -619,7 +619,7 @@ async fn parse_and_connect( print_code: Option< &dyn Fn(&mut Term, &magic_wormhole::Code, &Option) -> eyre::Result<()>, >, - clipboard: Option<&mut ClipboardContext>, + clipboard: Option<&mut Clipboard>, ) -> eyre::Result<(Wormhole, magic_wormhole::Code, Vec)> { // TODO handle relay servers with multiple endpoints better let mut relay_hints: Vec = common_args @@ -665,7 +665,7 @@ async fn parse_and_connect( /* Print code and also copy it to clipboard */ if is_send { if let Some(clipboard) = clipboard { - match clipboard.set_contents(mailbox_connection.code.to_string()) { + match clipboard.set_text(mailbox_connection.code.to_string()) { Ok(()) => log::info!("Code copied to clipboard"), Err(err) => log::warn!("Failed to copy code to clipboard: {}", err), } diff --git a/src/core/test.rs b/src/core/test.rs index 6123550b..2d852750 100644 --- a/src/core/test.rs +++ b/src/core/test.rs @@ -228,8 +228,9 @@ pub async fn test_file_rust2rust_deprecated() -> eyre::Result<()> { futures::future::pending(), ) .await? - .unwrap() - else {panic!("v2 should be disabled for now")}; + .unwrap() else { + panic!("v2 should be disabled for now") + }; req.accept( &transit::log_transit_connection, &mut answer, @@ -302,8 +303,9 @@ pub async fn test_file_rust2rust() -> eyre::Result<()> { futures::future::pending(), ) .await? - .unwrap() - else {panic!("v2 should be disabled for now")}; + .unwrap() else { + panic!("v2 should be disabled for now") + }; req.accept( &transit::log_transit_connection, &mut answer, @@ -413,8 +415,9 @@ pub async fn test_send_many() -> eyre::Result<()> { futures::future::pending(), ) .await? - .unwrap() - else {panic!("v2 should be disabled for now")}; + .unwrap() else { + panic!("v2 should be disabled for now") + }; // Hacky v1-compat conversion for now let mut answer = (gen_accept() diff --git a/src/transfer/cancel.rs b/src/transfer/cancel.rs index bb99ddbd..4837b0f9 100644 --- a/src/transfer/cancel.rs +++ b/src/transfer/cancel.rs @@ -49,7 +49,11 @@ macro_rules! with_cancel_wormhole { ($wormhole:ident, run = $run:expr, $cancel:expr, ret_cancel = $ret_cancel:expr $(,)?) => {{ let run = Box::pin($run); let result = cancel::cancellable_2(run, $cancel).await; - let Some((transit, wormhole, cancel)) = cancel::handle_run_result_noclose($wormhole, result).await? else { return Ok($ret_cancel); }; + let Some((transit, wormhole, cancel)) = + cancel::handle_run_result_noclose($wormhole, result).await? + else { + return Ok($ret_cancel); + }; (transit, wormhole, cancel) }}; } @@ -238,8 +242,8 @@ pub async fn handle_run_result_transit( */ loop { let Ok(msg) = transit.receive_record().await else { - break; - }; + break; + }; match parse_message(&msg) { Ok(None) => continue, Ok(Some(err)) => {