win_fix_multi_tab: build linux

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-10-26 06:40:22 -07:00
parent adf4f3eea4
commit a9602f95ed
4 changed files with 35 additions and 27 deletions

View File

@ -33,8 +33,8 @@ use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
#[cfg(windows)]
lazy_static::lazy_static! { lazy_static::lazy_static! {
#[cfg(windows)]
static ref CLIPBOARD_FILE_CONTEXT: Mutex<u64> = Mutex::new(0); static ref CLIPBOARD_FILE_CONTEXT: Mutex<u64> = Mutex::new(0);
} }
@ -1206,6 +1206,7 @@ impl<T: InvokeUiSession> Remote<T> {
} }
} }
#[cfg(windows)]
fn handle_cliprdr_msg(&self, clip: message_proto::Cliprdr) { fn handle_cliprdr_msg(&self, clip: message_proto::Cliprdr) {
if !self.handler.lc.read().unwrap().disable_clipboard { if !self.handler.lc.read().unwrap().disable_clipboard {
let mut lock = CLIPBOARD_FILE_CONTEXT.lock().unwrap(); let mut lock = CLIPBOARD_FILE_CONTEXT.lock().unwrap();

View File

@ -514,17 +514,17 @@ impl UI {
} }
fn get_lan_peers(&self) -> String { fn get_lan_peers(&self) -> String {
let peers = get_lan_peers() // let peers = get_lan_peers()
.into_iter() // .into_iter()
.map(|mut peer| { // .map(|mut peer| {
( // (
peer.remove("id").unwrap_or_default(), // peer.remove("id").unwrap_or_default(),
peer.remove("username").unwrap_or_default(), // peer.remove("username").unwrap_or_default(),
peer.remove("hostname").unwrap_or_default(), // peer.remove("hostname").unwrap_or_default(),
peer.remove("platform").unwrap_or_default(), // peer.remove("platform").unwrap_or_default(),
) // )
}) // })
.collect::<Vec<(String, String, String, String)>>(); // .collect::<Vec<(String, String, String, String)>>();
serde_json::to_string(&get_lan_peers()).unwrap_or_default() serde_json::to_string(&get_lan_peers()).unwrap_or_default()
} }

View File

@ -1,19 +1,24 @@
use std::ops::{Deref, DerefMut}; #[cfg(windows)]
use std::sync::Arc;
use std::{ use std::{
collections::HashMap, collections::HashMap,
iter::FromIterator, iter::FromIterator,
ops::{Deref, DerefMut},
sync::{ sync::{
atomic::{AtomicI64, Ordering}, atomic::{AtomicI64, Ordering},
Arc, RwLock, RwLock,
}, },
}; };
#[cfg(windows)]
use clipboard::empty_clipboard; use clipboard::empty_clipboard;
#[cfg(windows)]
use hbb_common::chrono::Duration; use hbb_common::chrono::Duration;
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::ipc::Data; use crate::ipc::{self, new_listener, Connection, Data};
use crate::ipc::{self, new_listener, Connection}; #[cfg(windows)]
use hbb_common::tokio::sync::Mutex as TokioMutex;
use hbb_common::{ use hbb_common::{
allow_err, allow_err,
config::Config, config::Config,
@ -24,10 +29,7 @@ use hbb_common::{
protobuf::Message as _, protobuf::Message as _,
tokio::{ tokio::{
self, self,
sync::{ sync::mpsc::{self, unbounded_channel, UnboundedSender},
mpsc::{self, unbounded_channel, UnboundedSender},
Mutex as TokioMutex,
},
task::spawn_blocking, task::spawn_blocking,
}, },
}; };
@ -269,6 +271,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
rx_clip1 = Arc::new(TokioMutex::new(rx_clip2)); rx_clip1 = Arc::new(TokioMutex::new(rx_clip2));
rx_clip = rx_clip1.lock().await; rx_clip = rx_clip1.lock().await;
} }
#[cfg(not(windows))]
{
(_tx_clip, rx_clip) = unbounded_channel::<i32>();
}
loop { loop {
tokio::select! { tokio::select! {
@ -280,13 +286,13 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
} }
Ok(Some(data)) => { Ok(Some(data)) => {
match 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); 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.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; self.conn_id = id;
#[cfg(windows)] #[cfg(windows)]
{ {
self.file_transfer_enabled = file_transfer_enabled; self.file_transfer_enabled = _file_transfer_enabled;
} }
break; break;
} }
@ -301,7 +307,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
log::info!("cm ipc connection disconnect"); log::info!("cm ipc connection disconnect");
break; break;
} }
Data::PrivacyModeState((id, _)) => { Data::PrivacyModeState(_) => {
self.conn_id = conn_id_tmp; self.conn_id = conn_id_tmp;
allow_err!(self.tx.send(data)); allow_err!(self.tx.send(data));
} }
@ -343,9 +349,9 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
} }
} }
clip_file = rx_clip.recv() => match clip_file { clip_file = rx_clip.recv() => match clip_file {
Some(clip) => { Some(_clip) => {
#[cfg(windows)] #[cfg(windows)]
allow_err!(self.tx.send(Data::ClipbaordFile(clip))); allow_err!(self.tx.send(Data::ClipbaordFile(_clip)));
} }
None => { None => {
// //
@ -389,6 +395,7 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
let cm_clip = cm.clone(); let cm_clip = cm.clone();
let (tx_file, _rx_file) = mpsc::unbounded_channel::<ClipboardFileData>(); let (tx_file, _rx_file) = mpsc::unbounded_channel::<ClipboardFileData>();
#[cfg(windows)]
std::thread::spawn(move || start_clipboard_file(_rx_file)); std::thread::spawn(move || start_clipboard_file(_rx_file));
#[cfg(windows)] #[cfg(windows)]

View File

@ -76,11 +76,11 @@ pub fn goto_install() {
} }
#[inline] #[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)] #[cfg(windows)]
std::thread::spawn(move || { std::thread::spawn(move || {
allow_err!(crate::platform::windows::install_me( allow_err!(crate::platform::windows::install_me(
&_options, _path, silent, debug &_options, _path, _silent, _debug
)); ));
std::process::exit(0); std::process::exit(0);
}); });