Merge pull request #3803 from fufesou/refact/android_remove_warns

remove android build warns
This commit is contained in:
RustDesk 2023-03-27 21:59:59 +08:00 committed by GitHub
commit 679d3d9868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 101 additions and 43 deletions

View File

@ -297,6 +297,7 @@ pub struct TransferSerde {
pub read_jobs: Vec<String>, pub read_jobs: Vec<String>,
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn patch(path: PathBuf) -> PathBuf { fn patch(path: PathBuf) -> PathBuf {
if let Some(_tmp) = path.to_str() { if let Some(_tmp) = path.to_str() {
#[cfg(windows)] #[cfg(windows)]

View File

@ -1,7 +1,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::num::NonZeroI64; use std::num::NonZeroI64;
use std::sync::atomic::{AtomicUsize, Ordering}; #[cfg(not(any(target_os = "android", target_os = "ios")))]
use std::sync::{Arc, Mutex}; use std::sync::Mutex;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
#[cfg(windows)] #[cfg(windows)]
use clipboard::{cliprdr::CliprdrClientContext, ContextSend}; use clipboard::{cliprdr::CliprdrClientContext, ContextSend};
@ -13,6 +17,8 @@ use hbb_common::fs::{
use hbb_common::message_proto::permission_info::Permission; use hbb_common::message_proto::permission_info::Permission;
use hbb_common::protobuf::Message as _; use hbb_common::protobuf::Message as _;
use hbb_common::rendezvous_proto::ConnType; use hbb_common::rendezvous_proto::ConnType;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::sleep;
use hbb_common::tokio::sync::mpsc::error::TryRecvError; use hbb_common::tokio::sync::mpsc::error::TryRecvError;
#[cfg(windows)] #[cfg(windows)]
use hbb_common::tokio::sync::Mutex as TokioMutex; use hbb_common::tokio::sync::Mutex as TokioMutex;
@ -21,18 +27,17 @@ use hbb_common::tokio::{
sync::mpsc, sync::mpsc,
time::{self, Duration, Instant, Interval}, time::{self, Duration, Instant, Interval},
}; };
use hbb_common::{allow_err, get_time, message_proto::*, sleep}; use hbb_common::{allow_err, fs, get_time, log, message_proto::*, Stream};
use hbb_common::{fs, log, Stream};
use crate::client::{ use crate::client::{
new_voice_call_request, Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, new_voice_call_request, Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1,
SEC30, SEC30,
}; };
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::common::update_clipboard; use crate::common::{self, update_clipboard};
use crate::common::{get_default_sound_input, set_sound_input}; use crate::common::{get_default_sound_input, set_sound_input};
use crate::ui_session_interface::{InvokeUiSession, Session}; use crate::ui_session_interface::{InvokeUiSession, Session};
use crate::{audio_service, common, ConnInner, CLIENT_SERVER}; use crate::{audio_service, ConnInner, CLIENT_SERVER};
use crate::{client::Data, client::Interface}; use crate::{client::Data, client::Interface};
pub struct Remote<T: InvokeUiSession> { pub struct Remote<T: InvokeUiSession> {
@ -44,6 +49,7 @@ pub struct Remote<T: InvokeUiSession> {
// Stop sending local audio to remote client. // Stop sending local audio to remote client.
stop_voice_call_sender: Option<std::sync::mpsc::Sender<()>>, stop_voice_call_sender: Option<std::sync::mpsc::Sender<()>>,
voice_call_request_timestamp: Option<NonZeroI64>, voice_call_request_timestamp: Option<NonZeroI64>,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
old_clipboard: Arc<Mutex<String>>, old_clipboard: Arc<Mutex<String>>,
read_jobs: Vec<fs::TransferJob>, read_jobs: Vec<fs::TransferJob>,
write_jobs: Vec<fs::TransferJob>, write_jobs: Vec<fs::TransferJob>,
@ -74,6 +80,7 @@ impl<T: InvokeUiSession> Remote<T> {
audio_sender, audio_sender,
receiver, receiver,
sender, sender,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
old_clipboard: Default::default(), old_clipboard: Default::default(),
read_jobs: Vec::new(), read_jobs: Vec::new(),
write_jobs: Vec::new(), write_jobs: Vec::new(),
@ -840,7 +847,9 @@ impl<T: InvokeUiSession> Remote<T> {
self.handler.handle_peer_info(pi); self.handler.handle_peer_info(pi);
self.check_clipboard_file_context(); self.check_clipboard_file_context();
if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) { if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let sender = self.sender.clone(); let sender = self.sender.clone();
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let permission_config = self.handler.get_permission_config(); let permission_config = self.handler.get_permission_config();
#[cfg(feature = "flutter")] #[cfg(feature = "flutter")]

View File

@ -8,6 +8,7 @@ use hbb_common::platform::register_breakdown_handler;
/// [Note] /// [Note]
/// If it returns [`None`], then the process will terminate, and flutter gui will not be started. /// If it returns [`None`], then the process will terminate, and flutter gui will not be started.
/// If it returns [`Some`], then the process will continue, and flutter gui will be started. /// If it returns [`Some`], then the process will continue, and flutter gui will be started.
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn core_main() -> Option<Vec<String>> { pub fn core_main() -> Option<Vec<String>> {
let mut args = Vec::new(); let mut args = Vec::new();
let mut flutter_args = Vec::new(); let mut flutter_args = Vec::new();

View File

@ -168,14 +168,12 @@ pub fn session_reconnect(id: String, force_relay: bool) {
} }
pub fn session_toggle_option(id: String, value: String) { pub fn session_toggle_option(id: String, value: String) {
let mut is_found = false;
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) { if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
is_found = true;
log::warn!("toggle option {}", &value); log::warn!("toggle option {}", &value);
session.toggle_option(value.clone()); session.toggle_option(value.clone());
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
if is_found && value == "disable-clipboard" { if SESSIONS.read().unwrap().get(&id).is_some() && value == "disable-clipboard" {
crate::flutter::update_text_clipboard_required(); crate::flutter::update_text_clipboard_required();
} }
} }
@ -338,10 +336,10 @@ pub fn session_handle_flutter_key_event(
} }
} }
pub fn session_enter_or_leave(id: String, enter: bool) { pub fn session_enter_or_leave(_id: String, _enter: bool) {
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
if let Some(session) = SESSIONS.read().unwrap().get(&id) { if let Some(session) = SESSIONS.read().unwrap().get(&_id) {
if enter { if _enter {
session.enter(); session.enter();
} else { } else {
session.leave(); session.leave();
@ -1405,7 +1403,7 @@ pub mod server_side {
#[no_mangle] #[no_mangle]
pub unsafe extern "system" fn Java_com_carriez_flutter_1hbb_MainService_startService( pub unsafe extern "system" fn Java_com_carriez_flutter_1hbb_MainService_startService(
env: JNIEnv, _env: JNIEnv,
_class: JClass, _class: JClass,
) { ) {
log::debug!("startService from jvm"); log::debug!("startService from jvm");

View File

@ -16,6 +16,7 @@ lazy_static::lazy_static! {
static ref SENDER : Mutex<broadcast::Sender<Vec<i32>>> = Mutex::new(start_hbbs_sync()); static ref SENDER : Mutex<broadcast::Sender<Vec<i32>>> = Mutex::new(start_hbbs_sync());
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn start() { pub fn start() {
let _sender = SENDER.lock().unwrap(); let _sender = SENDER.lock().unwrap();
} }

View File

@ -179,6 +179,7 @@ pub mod client {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn lock_screen() { pub fn lock_screen() {
send_key_event(&event_lock_screen()); send_key_event(&event_lock_screen());
} }
@ -198,6 +199,7 @@ pub mod client {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn ctrl_alt_del() { pub fn ctrl_alt_del() {
send_key_event(&event_ctrl_alt_del()); send_key_event(&event_ctrl_alt_del());
} }
@ -364,6 +366,7 @@ pub fn get_keyboard_mode_enum() -> KeyboardMode {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn is_numpad_key(event: &Event) -> bool { fn is_numpad_key(event: &Event) -> bool {
matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key { matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key {
Key::Kp0 | Key::Kp1 | Key::Kp2 | Key::Kp3 | Key::Kp4 | Key::Kp5 | Key::Kp6 | Key::Kp7 | Key::Kp8 | Key::Kp0 | Key::Kp1 | Key::Kp2 | Key::Kp3 | Key::Kp4 | Key::Kp5 | Key::Kp6 | Key::Kp7 | Key::Kp8 |
@ -373,6 +376,7 @@ fn is_numpad_key(event: &Event) -> bool {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn is_letter_key(event: &Event) -> bool { fn is_letter_key(event: &Event) -> bool {
matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key { matches!(event.event_type, EventType::KeyPress(key) | EventType::KeyRelease(key) if match key {
Key::KeyA | Key::KeyB | Key::KeyC | Key::KeyD | Key::KeyE | Key::KeyF | Key::KeyG | Key::KeyH | Key::KeyA | Key::KeyB | Key::KeyC | Key::KeyD | Key::KeyE | Key::KeyF | Key::KeyG | Key::KeyH |
@ -456,7 +460,7 @@ fn update_modifiers_state(event: &Event) {
pub fn event_to_key_events( pub fn event_to_key_events(
event: &Event, event: &Event,
keyboard_mode: KeyboardMode, keyboard_mode: KeyboardMode,
lock_modes: Option<i32>, _lock_modes: Option<i32>,
) -> Vec<KeyEvent> { ) -> Vec<KeyEvent> {
let mut key_event = KeyEvent::new(); let mut key_event = KeyEvent::new();
update_modifiers_state(event); update_modifiers_state(event);
@ -475,7 +479,12 @@ pub fn event_to_key_events(
peer.retain(|c| !c.is_whitespace()); peer.retain(|c| !c.is_whitespace());
key_event.mode = keyboard_mode.into(); key_event.mode = keyboard_mode.into();
let mut key_events = match keyboard_mode {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let mut key_events;
#[cfg(any(target_os = "android", target_os = "ios"))]
let key_events;
key_events = match keyboard_mode {
KeyboardMode::Map => match map_keyboard_mode(peer.as_str(), event, key_event) { KeyboardMode::Map => match map_keyboard_mode(peer.as_str(), event, key_event) {
Some(event) => [event].to_vec(), Some(event) => [event].to_vec(),
None => Vec::new(), None => Vec::new(),
@ -493,12 +502,12 @@ pub fn event_to_key_events(
} }
}; };
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if keyboard_mode != KeyboardMode::Translate { if keyboard_mode != KeyboardMode::Translate {
let is_numpad_key = is_numpad_key(&event); let is_numpad_key = is_numpad_key(&event);
let is_letter_key = is_letter_key(&event); let is_letter_key = is_letter_key(&event);
for key_event in &mut key_events { for key_event in &mut key_events {
#[cfg(not(any(target_os = "android", target_os = "ios")))] if let Some(lock_modes) = _lock_modes {
if let Some(lock_modes) = lock_modes {
parse_add_lock_modes_modifiers(key_event, lock_modes, is_numpad_key, is_letter_key); parse_add_lock_modes_modifiers(key_event, lock_modes, is_numpad_key, is_letter_key);
} else { } else {
add_lock_modes_modifiers(key_event, is_numpad_key, is_letter_key); add_lock_modes_modifiers(key_event, is_numpad_key, is_letter_key);
@ -778,7 +787,7 @@ pub fn legacy_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Vec<KeyEv
events events
} }
pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) -> Option<KeyEvent> { pub fn map_keyboard_mode(_peer: &str, event: &Event, mut key_event: KeyEvent) -> Option<KeyEvent> {
match event.event_type { match event.event_type {
EventType::KeyPress(..) => { EventType::KeyPress(..) => {
key_event.down = true; key_event.down = true;
@ -790,7 +799,7 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) ->
}; };
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let keycode = match peer { let keycode = match _peer {
OS_LOWER_WINDOWS => { OS_LOWER_WINDOWS => {
// https://github.com/rustdesk/rustdesk/issues/1371 // https://github.com/rustdesk/rustdesk/issues/1371
// Filter scancodes that are greater than 255 and the hight word is not 0xE0. // Filter scancodes that are greater than 255 and the hight word is not 0xE0.
@ -809,13 +818,13 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) ->
_ => rdev::win_scancode_to_linux_code(event.position_code)?, _ => rdev::win_scancode_to_linux_code(event.position_code)?,
}; };
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
let keycode = match peer { let keycode = match _peer {
OS_LOWER_WINDOWS => rdev::macos_code_to_win_scancode(event.platform_code as _)?, OS_LOWER_WINDOWS => rdev::macos_code_to_win_scancode(event.platform_code as _)?,
OS_LOWER_MACOS => event.platform_code as _, OS_LOWER_MACOS => event.platform_code as _,
_ => rdev::macos_code_to_linux_code(event.platform_code as _)?, _ => rdev::macos_code_to_linux_code(event.platform_code as _)?,
}; };
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
let keycode = match peer { let keycode = match _peer {
OS_LOWER_WINDOWS => rdev::linux_code_to_win_scancode(event.position_code as _)?, OS_LOWER_WINDOWS => rdev::linux_code_to_win_scancode(event.position_code as _)?,
OS_LOWER_MACOS => { OS_LOWER_MACOS => {
if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" { if hbb_common::config::LocalConfig::get_kb_layout_type() == "ISO" {
@ -833,6 +842,7 @@ pub fn map_keyboard_mode(peer: &str, event: &Event, mut key_event: KeyEvent) ->
Some(key_event) Some(key_event)
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec<KeyEvent>) { fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec<KeyEvent>) {
match &event.unicode { match &event.unicode {
Some(unicode_info) => { Some(unicode_info) => {
@ -925,6 +935,8 @@ pub fn translate_keyboard_mode(peer: &str, event: &Event, key_event: KeyEvent) -
return events; return events;
} }
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if is_numpad_key(&event) { if is_numpad_key(&event) {
if let Some(evt) = translate_key_code(peer, event, key_event) { if let Some(evt) = translate_key_code(peer, event, key_event) {
events.push(evt); events.push(evt);

View File

@ -1,7 +1,9 @@
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::config::Config;
use hbb_common::{ use hbb_common::{
allow_err, allow_err,
anyhow::bail, anyhow::bail,
config::{self, Config, RENDEZVOUS_PORT}, config::{self, RENDEZVOUS_PORT},
log, log,
protobuf::Message as _, protobuf::Message as _,
rendezvous_proto::*, rendezvous_proto::*,
@ -11,6 +13,7 @@ use hbb_common::{
}, },
ResultType, ResultType,
}; };
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs, UdpSocket}, net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs, UdpSocket},
@ -19,6 +22,7 @@ use std::{
type Message = RendezvousMessage; type Message = RendezvousMessage;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub(super) fn start_listening() -> ResultType<()> { pub(super) fn start_listening() -> ResultType<()> {
let addr = SocketAddr::from(([0, 0, 0, 0], get_broadcast_port())); let addr = SocketAddr::from(([0, 0, 0, 0], get_broadcast_port()));
let socket = std::net::UdpSocket::bind(addr)?; let socket = std::net::UdpSocket::bind(addr)?;
@ -98,9 +102,9 @@ fn get_broadcast_port() -> u16 {
(RENDEZVOUS_PORT + 3) as _ (RENDEZVOUS_PORT + 3) as _
} }
fn get_mac(ip: &IpAddr) -> String { fn get_mac(_ip: &IpAddr) -> String {
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
if let Ok(mac) = get_mac_by_ip(ip) { if let Ok(mac) = get_mac_by_ip(_ip) {
mac.to_string() mac.to_string()
} else { } else {
"".to_owned() "".to_owned()
@ -119,6 +123,7 @@ fn get_all_ipv4s() -> ResultType<Vec<Ipv4Addr>> {
Ok(ipv4s) Ok(ipv4s)
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn get_mac_by_ip(ip: &IpAddr) -> ResultType<String> { fn get_mac_by_ip(ip: &IpAddr) -> ResultType<String> {
for interface in default_net::get_interfaces() { for interface in default_net::get_interfaces() {
match ip { match ip {

View File

@ -19,7 +19,7 @@ pub mod linux;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::{message_proto::CursorData, ResultType}; use hbb_common::{message_proto::CursorData, ResultType};
#[cfg(not(target_os = "macos"))] #[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))]
const SERVICE_INTERVAL: u64 = 300; const SERVICE_INTERVAL: u64 = 300;
pub fn is_xfce() -> bool { pub fn is_xfce() -> bool {

View File

@ -365,7 +365,7 @@ pub fn check_zombie() {
/// Otherwise, client will check if there's already a server and start one if not. /// Otherwise, client will check if there's already a server and start one if not.
#[cfg(any(target_os = "android", target_os = "ios"))] #[cfg(any(target_os = "android", target_os = "ios"))]
#[tokio::main] #[tokio::main]
pub async fn start_server(is_server: bool) { pub async fn start_server(_is_server: bool) {
crate::RendezvousMediator::start_all().await; crate::RendezvousMediator::start_all().await;
} }

View File

@ -64,6 +64,7 @@ mod pa_impl {
))) )))
.await .await
); );
#[cfg(target_os = "linux")]
let zero_audio_frame: Vec<f32> = vec![0.; AUDIO_DATA_SIZE_U8 / 4]; let zero_audio_frame: Vec<f32> = vec![0.; AUDIO_DATA_SIZE_U8 / 4];
while sp.ok() && !RESTARTING.load(Ordering::SeqCst) { while sp.ok() && !RESTARTING.load(Ordering::SeqCst) {
sp.snapshot(|sps| { sp.snapshot(|sps| {

View File

@ -64,7 +64,9 @@ pub struct ConnInner {
} }
enum MessageInput { enum MessageInput {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
Mouse((MouseEvent, i32)), Mouse((MouseEvent, i32)),
#[cfg(not(any(target_os = "android", target_os = "ios")))]
Key((KeyEvent, bool)), Key((KeyEvent, bool)),
BlockOn, BlockOn,
BlockOff, BlockOff,
@ -125,6 +127,7 @@ pub struct Connection {
#[cfg(windows)] #[cfg(windows)]
portable: PortableState, portable: PortableState,
from_switch: bool, from_switch: bool,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
origin_resolution: HashMap<String, Resolution>, origin_resolution: HashMap<String, Resolution>,
voice_call_request_timestamp: Option<NonZeroI64>, voice_call_request_timestamp: Option<NonZeroI64>,
audio_input_device_before_voice_call: Option<String>, audio_input_device_before_voice_call: Option<String>,
@ -187,9 +190,10 @@ impl Connection {
let (tx_to_cm, rx_to_cm) = mpsc::unbounded_channel::<ipc::Data>(); let (tx_to_cm, rx_to_cm) = mpsc::unbounded_channel::<ipc::Data>();
let (tx, mut rx) = mpsc::unbounded_channel::<(Instant, Arc<Message>)>(); let (tx, mut rx) = mpsc::unbounded_channel::<(Instant, Arc<Message>)>();
let (tx_video, mut rx_video) = mpsc::unbounded_channel::<(Instant, Arc<Message>)>(); let (tx_video, mut rx_video) = mpsc::unbounded_channel::<(Instant, Arc<Message>)>();
let (tx_input, rx_input) = std_mpsc::channel(); let (tx_input, _rx_input) = std_mpsc::channel();
let mut hbbs_rx = crate::hbbs_http::sync::signal_receiver(); let mut hbbs_rx = crate::hbbs_http::sync::signal_receiver();
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let tx_cloned = tx.clone(); let tx_cloned = tx.clone();
let mut conn = Self { let mut conn = Self {
inner: ConnInner { inner: ConnInner {
@ -233,6 +237,7 @@ impl Connection {
#[cfg(windows)] #[cfg(windows)]
portable: Default::default(), portable: Default::default(),
from_switch: false, from_switch: false,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
origin_resolution: Default::default(), origin_resolution: Default::default(),
audio_sender: None, audio_sender: None,
voice_call_request_timestamp: None, voice_call_request_timestamp: None,
@ -282,7 +287,7 @@ impl Connection {
); );
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
std::thread::spawn(move || Self::handle_input(rx_input, tx_cloned)); std::thread::spawn(move || Self::handle_input(_rx_input, tx_cloned));
let mut second_timer = time::interval(Duration::from_secs(1)); let mut second_timer = time::interval(Duration::from_secs(1));
loop { loop {
@ -1042,11 +1047,13 @@ impl Connection {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn input_mouse(&self, msg: MouseEvent, conn_id: i32) { fn input_mouse(&self, msg: MouseEvent, conn_id: i32) {
self.tx_input.send(MessageInput::Mouse((msg, conn_id))).ok(); self.tx_input.send(MessageInput::Mouse((msg, conn_id))).ok();
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn input_key(&self, msg: KeyEvent, press: bool) { fn input_key(&self, msg: KeyEvent, press: bool) {
self.tx_input.send(MessageInput::Key((msg, press))).ok(); self.tx_input.send(MessageInput::Key((msg, press))).ok();
} }
@ -1342,8 +1349,10 @@ impl Connection {
self.input_mouse(me, self.inner.id()); self.input_mouse(me, self.inner.id());
} }
} }
Some(message::Union::KeyEvent(me)) => { #[cfg(any(target_os = "android", target_os = "ios"))]
Some(message::Union::KeyEvent(..)) => {}
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
Some(message::Union::KeyEvent(me)) => {
if self.peer_keyboard_enabled() { if self.peer_keyboard_enabled() {
if is_enter(&me) { if is_enter(&me) {
CLICK_TIME.store(get_time(), Ordering::SeqCst); CLICK_TIME.store(get_time(), Ordering::SeqCst);
@ -1371,11 +1380,11 @@ impl Connection {
} }
} }
} }
Some(message::Union::Clipboard(cb)) => Some(message::Union::Clipboard(_cb)) =>
{ {
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
if self.clipboard { if self.clipboard {
update_clipboard(cb, None); update_clipboard(_cb, None);
} }
} }
Some(message::Union::Cliprdr(_clip)) => { Some(message::Union::Cliprdr(_clip)) => {

View File

@ -831,14 +831,13 @@ pub fn handle_one_frame_encoded(
} }
Ok(()) Ok(())
})?; })?;
let mut send_conn_ids: HashSet<i32> = Default::default();
let vp9_frame = EncodedVideoFrame { let vp9_frame = EncodedVideoFrame {
data: frame.to_vec().into(), data: frame.to_vec().into(),
key: true, key: true,
pts: ms, pts: ms,
..Default::default() ..Default::default()
}; };
send_conn_ids = sp.send_video_frame(create_msg(vec![vp9_frame])); let send_conn_ids = sp.send_video_frame(create_msg(vec![vp9_frame]));
Ok(send_conn_ids) Ok(send_conn_ids)
} }

View File

@ -15,7 +15,11 @@ use std::{
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend}; use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend};
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::ipc::{self, Connection, Data}; #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::ipc::Connection;
use crate::ipc::{self, Data};
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::tokio::sync::mpsc::unbounded_channel;
#[cfg(windows)] #[cfg(windows)]
use hbb_common::tokio::sync::Mutex as TokioMutex; use hbb_common::tokio::sync::Mutex as TokioMutex;
use hbb_common::{ use hbb_common::{
@ -28,7 +32,7 @@ use hbb_common::{
protobuf::Message as _, protobuf::Message as _,
tokio::{ tokio::{
self, self,
sync::mpsc::{self, unbounded_channel, UnboundedSender}, sync::mpsc::{self, UnboundedSender},
task::spawn_blocking, task::spawn_blocking,
}, },
}; };
@ -55,6 +59,7 @@ pub struct Client {
tx: UnboundedSender<Data>, tx: UnboundedSender<Data>,
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
struct IpcTaskRunner<T: InvokeUiCM> { struct IpcTaskRunner<T: InvokeUiCM> {
stream: Connection, stream: Connection,
cm: ConnectionManager<T>, cm: ConnectionManager<T>,
@ -143,7 +148,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
from_switch, from_switch,
tx, tx,
in_voice_call: false, in_voice_call: false,
incoming_voice_call: false incoming_voice_call: false,
}; };
CLIENTS CLIENTS
.write() .write()
@ -183,10 +188,12 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
self.ui_handler.remove_connection(id, close); self.ui_handler.remove_connection(id, close);
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn show_elevation(&self, show: bool) { fn show_elevation(&self, show: bool) {
self.ui_handler.show_elevation(show); self.ui_handler.show_elevation(show);
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn voice_call_started(&self, id: i32) { fn voice_call_started(&self, id: i32) {
if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) {
client.incoming_voice_call = false; client.incoming_voice_call = false;
@ -195,6 +202,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
} }
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn voice_call_incoming(&self, id: i32) { fn voice_call_incoming(&self, id: i32) {
if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) {
client.incoming_voice_call = true; client.incoming_voice_call = true;
@ -203,6 +211,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
} }
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn voice_call_closed(&self, id: i32, _reason: &str) { fn voice_call_closed(&self, id: i32, _reason: &str) {
if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) { if let Some(client) = CLIENTS.write().unwrap().get_mut(&id) {
client.incoming_voice_call = false; client.incoming_voice_call = false;
@ -282,6 +291,7 @@ pub fn switch_back(id: i32) {
}; };
} }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
impl<T: InvokeUiCM> IpcTaskRunner<T> { impl<T: InvokeUiCM> IpcTaskRunner<T> {
#[cfg(windows)] #[cfg(windows)]
async fn enable_cliprdr_file_context(&mut self, conn_id: i32, enabled: bool) { async fn enable_cliprdr_file_context(&mut self, conn_id: i32, enabled: bool) {

View File

@ -9,8 +9,12 @@ use hbb_common::password_security;
use hbb_common::{ use hbb_common::{
allow_err, allow_err,
config::{self, Config, LocalConfig, PeerConfig}, config::{self, Config, LocalConfig, PeerConfig},
directories_next, log, sleep, directories_next, log, tokio,
tokio::{self, sync::mpsc, time}, };
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use hbb_common::{
sleep,
tokio::{sync::mpsc, time},
}; };
use hbb_common::{ use hbb_common::{
@ -339,8 +343,8 @@ pub fn get_socks() -> Vec<String> {
} }
#[inline] #[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn set_socks(proxy: String, username: String, password: String) { pub fn set_socks(proxy: String, username: String, password: String) {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
ipc::set_socks(config::Socks5Server { ipc::set_socks(config::Socks5Server {
proxy, proxy,
username, username,
@ -349,6 +353,9 @@ pub fn set_socks(proxy: String, username: String, password: String) {
.ok(); .ok();
} }
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn set_socks(_: String, _: String, _: String) {}
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
#[inline] #[inline]
pub fn is_installed() -> bool { pub fn is_installed() -> bool {
@ -791,14 +798,15 @@ pub fn check_zombie(children: Children) {
} }
} }
// Make sure `SENDER` is inited here.
#[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn start_option_status_sync() { pub fn start_option_status_sync() {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
let _sender = SENDER.lock().unwrap(); let _sender = SENDER.lock().unwrap();
}
} }
// not call directly // not call directly
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn check_connect_status(reconnect: bool) -> mpsc::UnboundedSender<ipc::Data> { fn check_connect_status(reconnect: bool) -> mpsc::UnboundedSender<ipc::Data> {
let (tx, rx) = mpsc::unbounded_channel::<ipc::Data>(); let (tx, rx) = mpsc::unbounded_channel::<ipc::Data>();
std::thread::spawn(move || check_connect_status_(reconnect, rx)); std::thread::spawn(move || check_connect_status_(reconnect, rx));
@ -834,6 +842,7 @@ pub fn get_user_default_option(key: String) -> String {
// notice: avoiding create ipc connection repeatedly, // notice: avoiding create ipc connection repeatedly,
// because windows named pipe has serious memory leak issue. // because windows named pipe has serious memory leak issue.
#[cfg(not(any(target_os = "android", target_os = "ios")))]
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc::Data>) { async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc::Data>) {
let mut key_confirmed = false; let mut key_confirmed = false;

View File

@ -1053,6 +1053,9 @@ 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>) { pub async fn io_loop<T: InvokeUiSession>(handler: Session<T>) {
#[cfg(any(target_os = "android", target_os = "ios"))]
let (sender, receiver) = mpsc::unbounded_channel::<Data>();
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let (sender, mut receiver) = mpsc::unbounded_channel::<Data>(); let (sender, mut receiver) = mpsc::unbounded_channel::<Data>();
*handler.sender.write().unwrap() = Some(sender.clone()); *handler.sender.write().unwrap() = Some(sender.clone());
let token = LocalConfig::get_option("access_token"); let token = LocalConfig::get_option("access_token");