diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index bf30cfae1..5ab6e3d85 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -33,8 +33,8 @@ use std::collections::HashMap; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; +#[cfg(windows)] lazy_static::lazy_static! { - #[cfg(windows)] static ref CLIPBOARD_FILE_CONTEXT: Mutex = Mutex::new(0); } @@ -1206,6 +1206,7 @@ impl Remote { } } + #[cfg(windows)] fn handle_cliprdr_msg(&self, clip: message_proto::Cliprdr) { if !self.handler.lc.read().unwrap().disable_clipboard { let mut lock = CLIPBOARD_FILE_CONTEXT.lock().unwrap(); diff --git a/src/ui.rs b/src/ui.rs index 63dc4704a..6a9837a59 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -514,17 +514,17 @@ impl UI { } fn get_lan_peers(&self) -> String { - let peers = get_lan_peers() - .into_iter() - .map(|mut peer| { - ( - peer.remove("id").unwrap_or_default(), - peer.remove("username").unwrap_or_default(), - peer.remove("hostname").unwrap_or_default(), - peer.remove("platform").unwrap_or_default(), - ) - }) - .collect::>(); + // let peers = get_lan_peers() + // .into_iter() + // .map(|mut peer| { + // ( + // peer.remove("id").unwrap_or_default(), + // peer.remove("username").unwrap_or_default(), + // peer.remove("hostname").unwrap_or_default(), + // peer.remove("platform").unwrap_or_default(), + // ) + // }) + // .collect::>(); serde_json::to_string(&get_lan_peers()).unwrap_or_default() } diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs index 0356a46a9..79152abe6 100644 --- a/src/ui_cm_interface.rs +++ b/src/ui_cm_interface.rs @@ -1,19 +1,24 @@ -use std::ops::{Deref, DerefMut}; +#[cfg(windows)] +use std::sync::Arc; use std::{ collections::HashMap, iter::FromIterator, + ops::{Deref, DerefMut}, sync::{ atomic::{AtomicI64, Ordering}, - Arc, RwLock, + RwLock, }, }; +#[cfg(windows)] use clipboard::empty_clipboard; +#[cfg(windows)] use hbb_common::chrono::Duration; use serde_derive::Serialize; -use crate::ipc::Data; -use crate::ipc::{self, new_listener, Connection}; +use crate::ipc::{self, new_listener, Connection, Data}; +#[cfg(windows)] +use hbb_common::tokio::sync::Mutex as TokioMutex; use hbb_common::{ allow_err, config::Config, @@ -24,10 +29,7 @@ use hbb_common::{ protobuf::Message as _, tokio::{ self, - sync::{ - mpsc::{self, unbounded_channel, UnboundedSender}, - Mutex as TokioMutex, - }, + sync::mpsc::{self, unbounded_channel, UnboundedSender}, task::spawn_blocking, }, }; @@ -269,6 +271,10 @@ impl IpcTaskRunner { rx_clip1 = Arc::new(TokioMutex::new(rx_clip2)); rx_clip = rx_clip1.lock().await; } + #[cfg(not(windows))] + { + (_tx_clip, rx_clip) = unbounded_channel::(); + } loop { tokio::select! { @@ -280,13 +286,13 @@ impl IpcTaskRunner { } Ok(Some(data)) => { match data { - Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled, restart, recording} => { + Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled: _file_transfer_enabled, restart, recording} => { log::debug!("conn_id: {}", id); self.cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, self.tx.clone()); self.conn_id = id; #[cfg(windows)] { - self.file_transfer_enabled = file_transfer_enabled; + self.file_transfer_enabled = _file_transfer_enabled; } break; } @@ -301,7 +307,7 @@ impl IpcTaskRunner { log::info!("cm ipc connection disconnect"); break; } - Data::PrivacyModeState((id, _)) => { + Data::PrivacyModeState(_) => { self.conn_id = conn_id_tmp; allow_err!(self.tx.send(data)); } @@ -343,9 +349,9 @@ impl IpcTaskRunner { } } clip_file = rx_clip.recv() => match clip_file { - Some(clip) => { + Some(_clip) => { #[cfg(windows)] - allow_err!(self.tx.send(Data::ClipbaordFile(clip))); + allow_err!(self.tx.send(Data::ClipbaordFile(_clip))); } None => { // @@ -389,6 +395,7 @@ pub async fn start_ipc(cm: ConnectionManager) { let cm_clip = cm.clone(); let (tx_file, _rx_file) = mpsc::unbounded_channel::(); + #[cfg(windows)] std::thread::spawn(move || start_clipboard_file(_rx_file)); #[cfg(windows)] diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 142c9cb43..0f7db9a1d 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -76,11 +76,11 @@ pub fn goto_install() { } #[inline] -pub fn install_me(_options: String, _path: String, silent: bool, debug: bool) { +pub fn install_me(_options: String, _path: String, _silent: bool, _debug: bool) { #[cfg(windows)] std::thread::spawn(move || { allow_err!(crate::platform::windows::install_me( - &_options, _path, silent, debug + &_options, _path, _silent, _debug )); std::process::exit(0); });